UNPKG

postcss-rtlcss

Version:

PostCSS plugin to build Cascading Style Sheets (CSS) with Left-To-Right (LTR) and Right-To-Left (RTL) rules

65 lines (64 loc) 2.26 kB
import { Plugin, Container, Root, Rule, AtRule } from 'postcss'; type DeclarationContainer = Rule | AtRule; declare enum Mode { combined = "combined", override = "override", diff = "diff" } declare enum Source { ltr = "ltr", rtl = "rtl" } type ModeValue = `${Mode}`; type SourceValue = `${Source}`; type strings = string | string[]; interface PluginStringMap { name?: string; search: strings; replace: strings; } interface DeclarationPluginProcessor { expr: RegExp; action: (prop: string, value: string, context: object) => object; } type DeclarationPlugin = { name: string; priority: number; processors: DeclarationPluginProcessor[]; }; type PrefixSelectorTransformer = (prefix: string, selector: string) => string | void; interface PluginOptions { mode?: ModeValue; ltrPrefix?: strings; rtlPrefix?: strings; bothPrefix?: strings; prefixSelectorTransformer?: PrefixSelectorTransformer; safeBothPrefix?: boolean; ignorePrefixedRules?: boolean; source?: SourceValue; processUrls?: boolean; processRuleNames?: boolean; processKeyFrames?: boolean; processEnv?: boolean; useCalc?: boolean; stringMap?: PluginStringMap[]; greedy?: boolean; aliases?: Record<string, string>; processDeclarationPlugins?: DeclarationPlugin[]; runOnExit?: boolean; } type RuleParser = (parsers: Parsers, container: Container, parentSourceDirective?: string, parentFreezeDirectiveActive?: boolean, hasParentRule?: boolean) => void; type AtRuleParser = (parsers: Parsers, container: Container, parentSourceDirective?: string, parentFreezeDirectiveActive?: boolean, hasParentRule?: boolean) => void; type KeyframeParser = (css: Root) => void; type DeclarationParser = (container: DeclarationContainer, hasParentRule: boolean, ruleSourceDirectiveValue: string, parentFreezeDirectiveActive: boolean, processRule: boolean, rename: boolean) => void; type Parsers = { parseRules: RuleParser; parseAtRules: AtRuleParser; parseKeyFrames: KeyframeParser; parseDeclarations: DeclarationParser; }; declare function postcssRTLCSS(options?: PluginOptions): Plugin; declare namespace postcssRTLCSS { var postcss: boolean; } export { postcssRTLCSS as default };