forked from kentcdodds/rtl-css-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.d.ts
105 lines (94 loc) · 4.13 KB
/
core.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
export declare interface CommonConverterOptions {
value: string;
}
export declare interface BackgroundConverterOptions {
value: string;
valuesToConvert: { [source: string]: string };
isRtl: boolean;
bgImgDirectionRegex: RegExp;
bgPosDirectionRegex: RegExp;
}
export declare interface BackgroundImageConverterOptions {
value: string;
valuesToConvert: { [source: string]: string };
bgImgDirectionRegex: RegExp;
}
export declare interface BackgroundPositionConverterOptions {
value: string;
valuesToConvert: { [source: string]: string };
isRtl: boolean;
bgPosDirectionRegex: RegExp;
}
export declare interface PropertyValueConverter<O extends CommonConverterOptions = CommonConverterOptions> {
(options: O): string
}
export declare interface PropertyValueConverters {
padding: PropertyValueConverter;
textShadow: PropertyValueConverter;
borderColor: PropertyValueConverter;
borderRadius: PropertyValueConverter;
background: PropertyValueConverter<BackgroundConverterOptions>;
backgroundImage: PropertyValueConverter<BackgroundImageConverterOptions>;
backgroundPosition: PropertyValueConverter<BackgroundPositionConverterOptions>;
backgroundPositionX: PropertyValueConverter<BackgroundPositionConverterOptions>;
transform: PropertyValueConverter;
margin: PropertyValueConverter;
borderWidth: PropertyValueConverter;
boxShadow: PropertyValueConverter;
webkitBoxShadow: PropertyValueConverter;
mozBoxShadow: PropertyValueConverter;
borderStyle: PropertyValueConverter;
webkitTransform: PropertyValueConverter;
mozTransform: PropertyValueConverter;
'text-shadow': PropertyValueConverter;
'border-color': PropertyValueConverter;
'border-radius': PropertyValueConverter;
'background-image': PropertyValueConverter<BackgroundImageConverterOptions>;
'background-position': PropertyValueConverter<BackgroundPositionConverterOptions>;
'background-position-x': PropertyValueConverter<BackgroundPositionConverterOptions>;
'border-width': PropertyValueConverter;
'box-shadow': PropertyValueConverter;
'-webkit-box-shadow': PropertyValueConverter;
'-moz-box-shadow': PropertyValueConverter;
'border-style': PropertyValueConverter;
'-webkit-transform': PropertyValueConverter;
'-moz-transform': PropertyValueConverter;
}
export declare const propertyValueConverters: PropertyValueConverters;
/**
* Takes an array of [keyValue1, keyValue2] pairs and creates an object of {keyValue1: keyValue2, keyValue2: keyValue1}
* @param {Array} array the array of pairs
* @return {Object} the {key, value} pair object
*/
export declare function arrayToObject(array: string[][]): { [source: string]: string };
/**
* Flip the sign of a CSS value, possibly with a unit.
*
* We can't just negate the value with unary minus due to the units.
*
* @private
* @param {String} value - the original value (for example 77%)
* @return {String} the result (for example -77%)
*/
export declare function flipSign(value: string): string;
/**
* Takes a percentage for background position and inverts it.
* This was copied and modified from CSSJanus:
* https://github.com/cssjanus/cssjanus/blob/4245f834365f6cfb0239191a151432fb85abab23/src/cssjanus.js#L152-L175
* @param {String} value - the original value (for example 77%)
* @return {String} the result (for example 23%)
*/
export declare function calculateNewBackgroundPosition(value: string): string;
/**
* This takes a list of CSS values and converts it to an array
* @param {String} value - something like `1px`, `1px 2em`, or `3pt rgb(150, 230, 550) 40px calc(100% - 5px)`
* @return {Array} the split values (for example: `['3pt', 'rgb(150, 230, 550)', '40px', 'calc(100% - 5px)']`)
*/
export declare function getValuesAsList(value: string): string[];
/**
* This is intended for properties that are `top right bottom left` and will switch them to `top left bottom right`
* @param {String} value - `1px 2px 3px 4px` for example, but also handles cases where there are too few/too many and
* simply returns the value in those cases (which is the correct behavior)
* @return {String} the result - `1px 4px 3px 2px` for example.
*/
export declare function handleQuartetValues(value: string): string;