diff --git a/types/rtlcss/index.d.ts b/types/rtlcss/index.d.ts new file mode 100644 index 0000000000..3e2dcb1711 --- /dev/null +++ b/types/rtlcss/index.d.ts @@ -0,0 +1,80 @@ +// Type definitions for rtlcss 2.4 +// Project: http://rtlcss.com +// Definitions by: Adam Zerella +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.3 + +export interface MapOptions { + scope: string; + ignoreCase: boolean; + greedy?: boolean; +} + +export interface StringMap { + name: string; + priority: number; + exclusive?: boolean; + search: string|string[]; + replace: string|string[]; + options: MapOptions; +} + +export interface ConfigOptions { + /** + * Applies to CSS rules containing no directional properties, + * it will update the selector by applying String Map. + */ + autoRename: boolean; + /** + * Ensures autoRename is applied only if pair exists. + */ + autoRenameStrict: boolean; + /** + * An object map of disabled plugins directives, + * where keys are plugin names and value are object + * hash of disabled directives. e.g. {'rtlcss':{'config':true}}. + */ + blacklist: object; + /** + * Removes directives comments from output CSS. + */ + clean: boolean; + /** + * Fallback value for String Map options. + */ + greedy: boolean; + /** + * Applies String Map to URLs. You can also target specific node types using an object literal. + * e.g. {'atrule': true, 'decl': false}. + */ + processUrls: boolean|object; + /** + * The default array of String Map. + */ + stringMap: StringMap[]; + /** + * When enabled, flips background-position expressed in length units using calc. + */ + useCalc: boolean; +} + +export interface HookOptions { + /** + * The function to be called before processing the CSS. + */ + pre: () => void; + /** + * The function to be called after processing the CSS. + */ + post: () => void; +} + +/** + * Creates a new RTLCSS instance, process the input and return its result. + */ +export function process(css: string, options?: object, plugins?: object|string[], hooks?: HookOptions): string; + +/** + * Creates a new instance of RTLCSS using the passed configuration object. + */ +export function configure(config: ConfigOptions): object; diff --git a/types/rtlcss/rtlcss-tests.ts b/types/rtlcss/rtlcss-tests.ts new file mode 100644 index 0000000000..1355074c56 --- /dev/null +++ b/types/rtlcss/rtlcss-tests.ts @@ -0,0 +1,27 @@ +import * as rtlcss from "rtlcss"; + +rtlcss.process("body { direction:ltr; }"); + +const config = { + autoRename: false, + autoRenameStrict: false, + blacklist: {}, + clean: true, + greedy: false, + processUrls: false, + stringMap: [ + { + name : 'left-right', + priority: 100, + search : ['left', 'Left', 'LEFT'], + replace : ['right', 'Right', 'RIGHT'], + options : { + scope : '*', + ignoreCase : false + } + } + ], + useCalc: false +}; + +rtlcss.configure(config); diff --git a/types/rtlcss/tsconfig.json b/types/rtlcss/tsconfig.json new file mode 100644 index 0000000000..94644d49ad --- /dev/null +++ b/types/rtlcss/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [ + + ], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "rtlcss-tests.ts" + ] +} diff --git a/types/rtlcss/tslint.json b/types/rtlcss/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/rtlcss/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file