1 | export declare type PropertyValue = string | number | object
|
---|
2 |
|
---|
3 | export declare interface CommonConverterOptions {
|
---|
4 | value: string
|
---|
5 | }
|
---|
6 |
|
---|
7 | export declare interface BackgroundConverterOptions {
|
---|
8 | value: string
|
---|
9 | valuesToConvert: {[source: string]: string}
|
---|
10 | isRtl: boolean
|
---|
11 | bgImgDirectionRegex: RegExp
|
---|
12 | bgPosDirectionRegex: RegExp
|
---|
13 | }
|
---|
14 |
|
---|
15 | export declare interface BackgroundImageConverterOptions {
|
---|
16 | value: string
|
---|
17 | valuesToConvert: {[source: string]: string}
|
---|
18 | bgImgDirectionRegex: RegExp
|
---|
19 | }
|
---|
20 |
|
---|
21 | export declare interface BackgroundPositionConverterOptions {
|
---|
22 | value: string
|
---|
23 | valuesToConvert: {[source: string]: string}
|
---|
24 | isRtl: boolean
|
---|
25 | bgPosDirectionRegex: RegExp
|
---|
26 | }
|
---|
27 |
|
---|
28 | export declare interface PropertyValueConverter<
|
---|
29 | O extends CommonConverterOptions = CommonConverterOptions
|
---|
30 | > {
|
---|
31 | (options: O): string
|
---|
32 | }
|
---|
33 |
|
---|
34 | export declare interface PropertyValueConverters {
|
---|
35 | padding: PropertyValueConverter
|
---|
36 | textShadow: PropertyValueConverter
|
---|
37 | borderColor: PropertyValueConverter
|
---|
38 | borderRadius: PropertyValueConverter
|
---|
39 | background: PropertyValueConverter<BackgroundConverterOptions>
|
---|
40 | backgroundImage: PropertyValueConverter<BackgroundImageConverterOptions>
|
---|
41 | backgroundPosition: PropertyValueConverter<BackgroundPositionConverterOptions>
|
---|
42 | backgroundPositionX: PropertyValueConverter<
|
---|
43 | BackgroundPositionConverterOptions
|
---|
44 | >
|
---|
45 | objectPosition: PropertyValueConverter<BackgroundPositionConverterOptions>
|
---|
46 | transform: PropertyValueConverter
|
---|
47 | margin: PropertyValueConverter
|
---|
48 | borderWidth: PropertyValueConverter
|
---|
49 | boxShadow: PropertyValueConverter
|
---|
50 | webkitBoxShadow: PropertyValueConverter
|
---|
51 | mozBoxShadow: PropertyValueConverter
|
---|
52 | borderStyle: PropertyValueConverter
|
---|
53 | webkitTransform: PropertyValueConverter
|
---|
54 | mozTransform: PropertyValueConverter
|
---|
55 | 'text-shadow': PropertyValueConverter
|
---|
56 | 'border-color': PropertyValueConverter
|
---|
57 | 'border-radius': PropertyValueConverter
|
---|
58 | 'background-image': PropertyValueConverter<BackgroundImageConverterOptions>
|
---|
59 | 'background-position': PropertyValueConverter<
|
---|
60 | BackgroundPositionConverterOptions
|
---|
61 | >
|
---|
62 | 'background-position-x': PropertyValueConverter<
|
---|
63 | BackgroundPositionConverterOptions
|
---|
64 | >
|
---|
65 | 'object-position': PropertyValueConverter<
|
---|
66 | BackgroundPositionConverterOptions
|
---|
67 | >
|
---|
68 | 'border-width': PropertyValueConverter
|
---|
69 | 'box-shadow': PropertyValueConverter
|
---|
70 | '-webkit-box-shadow': PropertyValueConverter
|
---|
71 | '-moz-box-shadow': PropertyValueConverter
|
---|
72 | 'border-style': PropertyValueConverter
|
---|
73 | '-webkit-transform': PropertyValueConverter
|
---|
74 | '-moz-transform': PropertyValueConverter
|
---|
75 | }
|
---|
76 |
|
---|
77 | export declare const propertyValueConverters: PropertyValueConverters
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * Takes an array of [keyValue1, keyValue2] pairs and creates an object of {keyValue1: keyValue2, keyValue2: keyValue1}
|
---|
81 | * @param {Array} array the array of pairs
|
---|
82 | * @return {Object} the {key, value} pair object
|
---|
83 | */
|
---|
84 | export declare function arrayToObject(
|
---|
85 | array: string[][],
|
---|
86 | ): {[source: string]: string}
|
---|
87 |
|
---|
88 | /**
|
---|
89 | * Flip the sign of a CSS value, possibly with a unit.
|
---|
90 | *
|
---|
91 | * We can't just negate the value with unary minus due to the units.
|
---|
92 | *
|
---|
93 | * @private
|
---|
94 | * @param {String} value - the original value (for example 77%)
|
---|
95 | * @return {String} the result (for example -77%)
|
---|
96 | */
|
---|
97 | export declare function flipSign(value: string): string
|
---|
98 |
|
---|
99 | /**
|
---|
100 | * Takes a percentage for background position and inverts it.
|
---|
101 | * This was copied and modified from CSSJanus:
|
---|
102 | * https://github.com/cssjanus/cssjanus/blob/4245f834365f6cfb0239191a151432fb85abab23/src/cssjanus.js#L152-L175
|
---|
103 | * @param {String} value - the original value (for example 77%)
|
---|
104 | * @return {String} the result (for example 23%)
|
---|
105 | */
|
---|
106 | export declare function calculateNewBackgroundPosition(value: string): string
|
---|
107 |
|
---|
108 | /**
|
---|
109 | * This takes a list of CSS values and converts it to an array
|
---|
110 | * @param {String} value - something like `1px`, `1px 2em`, or `3pt rgb(150, 230, 550) 40px calc(100% - 5px)`
|
---|
111 | * @return {Array} the split values (for example: `['3pt', 'rgb(150, 230, 550)', '40px', 'calc(100% - 5px)']`)
|
---|
112 | */
|
---|
113 | export declare function getValuesAsList(value: string): string[]
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * This is intended for properties that are `top right bottom left` and will switch them to `top left bottom right`
|
---|
117 | * @param {String} value - `1px 2px 3px 4px` for example, but also handles cases where there are too few/too many and
|
---|
118 | * simply returns the value in those cases (which is the correct behavior)
|
---|
119 | * @return {String} the result - `1px 4px 3px 2px` for example.
|
---|
120 | */
|
---|
121 | export declare function handleQuartetValues(value: string): string
|
---|
122 |
|
---|
123 | export declare const propertiesToConvert: {[key: string]: string}
|
---|
124 |
|
---|
125 | export declare const valuesToConvert: {[key: string]: string}
|
---|
126 |
|
---|
127 | export declare const propsToIgnore: string[]
|
---|
128 |
|
---|
129 | /**
|
---|
130 | * converts properties and values in the CSS in JS object to their corresponding RTL values
|
---|
131 | * @param {Object} object the CSS in JS object
|
---|
132 | * @return {Object} the RTL converted object
|
---|
133 | */
|
---|
134 | export declare function convert<T extends object = object>(o: T): T
|
---|
135 |
|
---|
136 | /**
|
---|
137 | * Converts a property and its value to the corresponding RTL key and value
|
---|
138 | * @param {String} originalKey the original property key
|
---|
139 | * @param {Number|String|Object} originalValue the original css property value
|
---|
140 | * @return {Object} the new {key, value} pair
|
---|
141 | */
|
---|
142 | export declare function convertProperty<V extends PropertyValue>(
|
---|
143 | originalKey: string,
|
---|
144 | originalValue: V,
|
---|
145 | ): {key: string; value: V}
|
---|
146 |
|
---|
147 | /**
|
---|
148 | * This gets the RTL version of the given property if it has a corresponding RTL property
|
---|
149 | * @param {String} property the name of the property
|
---|
150 | * @return {String} the name of the RTL property
|
---|
151 | */
|
---|
152 | export declare function getPropertyDoppelganger(property: string): string
|
---|
153 |
|
---|
154 | /**
|
---|
155 | * This converts the given value to the RTL version of that value based on the key
|
---|
156 | * @param {String} key this is the key (note: this should be the RTL version of the originalKey)
|
---|
157 | * @param {String|Number|Object} originalValue the original css property value. If it's an object, then we'll convert that as well
|
---|
158 | * @return {String|Number|Object} the converted value
|
---|
159 | */
|
---|
160 | export declare function getValueDoppelganger<V extends PropertyValue>(
|
---|
161 | key: string,
|
---|
162 | originalValue: V,
|
---|
163 | ): V
|
---|