@stylexjs/shared 0.2.0-beta.11 → 0.2.0-beta.12
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/common-types.d.ts +49 -0
- package/lib/common-types.js.flow +64 -0
- package/lib/convert-to-className.d.ts +16 -0
- package/lib/convert-to-className.js.flow +23 -0
- package/lib/generate-css-rule.d.ts +17 -0
- package/lib/generate-css-rule.js.flow +17 -0
- package/lib/hash.d.ts +11 -0
- package/lib/hash.js.flow +12 -0
- package/lib/index.d.ts +32 -95
- package/lib/index.js.flow +46 -3
- package/lib/messages.d.ts +32 -0
- package/lib/messages.js.flow +35 -0
- package/lib/physical-rtl/generate-ltr.d.ts +12 -0
- package/lib/physical-rtl/generate-ltr.js.flow +13 -0
- package/lib/physical-rtl/generate-rtl.d.ts +14 -0
- package/lib/physical-rtl/generate-rtl.js.flow +13 -0
- package/lib/preprocess-rules/PreRule.d.ts +52 -0
- package/lib/preprocess-rules/PreRule.js.flow +64 -0
- package/lib/preprocess-rules/application-order.d.ts +253 -0
- package/lib/preprocess-rules/application-order.js.flow +206 -0
- package/lib/preprocess-rules/basic-validation.d.ts +13 -0
- package/lib/preprocess-rules/basic-validation.js.flow +13 -0
- package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +25 -0
- package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +27 -0
- package/lib/preprocess-rules/index.d.ts +18 -0
- package/lib/preprocess-rules/index.js.flow +19 -0
- package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +122 -0
- package/lib/preprocess-rules/legacy-expand-shorthands.js +0 -139
- package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +101 -0
- package/lib/preprocess-rules/property-specificity.d.ts +76 -0
- package/lib/preprocess-rules/property-specificity.js.flow +87 -0
- package/lib/stylex-create-vars.d.ts +27 -0
- package/lib/stylex-create-vars.js.flow +22 -0
- package/lib/stylex-create.d.ts +23 -0
- package/lib/stylex-create.js.flow +30 -0
- package/lib/stylex-first-that-works.d.ts +14 -0
- package/lib/stylex-first-that-works.js.flow +13 -0
- package/lib/stylex-include.d.ts +19 -0
- package/lib/stylex-include.js.flow +21 -0
- package/lib/stylex-keyframes.d.ts +17 -0
- package/lib/stylex-keyframes.js.flow +20 -0
- package/lib/transform-value.d.ts +13 -0
- package/lib/transform-value.js.flow +15 -0
- package/lib/utils/Rule.d.ts +58 -0
- package/lib/utils/Rule.js.flow +64 -0
- package/lib/utils/dashify.d.ts +10 -0
- package/lib/utils/dashify.js.flow +9 -0
- package/lib/utils/default-options.d.ts +10 -0
- package/lib/utils/default-options.js.flow +24 -0
- package/lib/utils/file-based-identifier.d.ts +14 -0
- package/lib/utils/file-based-identifier.js +22 -0
- package/lib/utils/file-based-identifier.js.flow +13 -0
- package/lib/utils/genCSSRule.d.ts +16 -0
- package/lib/utils/genCSSRule.js.flow +16 -0
- package/lib/utils/normalize-value.d.ts +12 -0
- package/lib/utils/normalize-value.js.flow +14 -0
- package/lib/utils/normalizers/detect-unclosed-fns.d.ts +17 -0
- package/lib/utils/normalizers/detect-unclosed-fns.js.flow +16 -0
- package/lib/utils/normalizers/font-size-px-to-rem.d.ts +19 -0
- package/lib/utils/normalizers/font-size-px-to-rem.js +9 -4
- package/lib/utils/normalizers/font-size-px-to-rem.js.flow +18 -0
- package/lib/utils/normalizers/leading-zero.d.ts +17 -0
- package/lib/utils/normalizers/leading-zero.js.flow +16 -0
- package/lib/utils/normalizers/quotes.d.ts +19 -0
- package/lib/utils/normalizers/quotes.js.flow +18 -0
- package/lib/utils/normalizers/timings.d.ts +19 -0
- package/lib/utils/normalizers/timings.js.flow +18 -0
- package/lib/utils/normalizers/whitespace.d.ts +20 -0
- package/lib/utils/normalizers/whitespace.js.flow +19 -0
- package/lib/utils/normalizers/zero-dimensions.d.ts +19 -0
- package/lib/utils/normalizers/zero-dimensions.js.flow +18 -0
- package/lib/utils/object-utils.d.ts +61 -0
- package/lib/utils/object-utils.js.flow +81 -0
- package/lib/utils/property-priorities.d.ts +11 -0
- package/lib/utils/property-priorities.js.flow +10 -0
- package/lib/utils/split-css-value.d.ts +15 -0
- package/lib/utils/split-css-value.js.flow +16 -0
- package/lib/validate.d.ts +12 -0
- package/lib/validate.js.flow +12 -0
- package/package.json +3 -1
- package/lib/expand-shorthands.d.ts +0 -5
- package/lib/expand-shorthands.js +0 -330
- package/lib/namespace-transforms/__tests__/preflatten.test.js +0 -120
- package/lib/namespace-transforms/preflatten.js +0 -89
- package/lib/preprocess-rules/expand-shorthands.js +0 -156
- package/lib/preprocess-rules/null-out-longhand.js +0 -310
- package/lib/preprocess-rules/react-native-web.js +0 -142
- package/lib/stylex-defaultValue.js +0 -397
@@ -15,146 +15,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
15
15
|
*
|
16
16
|
*/
|
17
17
|
|
18
|
-
const borderWidthKeywords = new Set(['thin', 'medium', 'thick']);
|
19
|
-
const borderStyleKeywords = new Set(['none', 'hidden', 'solid', 'dashed', 'dotted', 'double', 'groove', 'ridge', 'inside',
|
20
|
-
// Non-standard
|
21
|
-
'inset', 'outset']);
|
22
|
-
const globalKeywords = new Set(['initial', 'inherit', 'unset']);
|
23
|
-
// eslint-disable-next-line no-unused-vars
|
24
|
-
function borderDetector(borderParts) {
|
25
|
-
const parts = borderParts.filter(Boolean).slice();
|
26
|
-
let suffix = '';
|
27
|
-
for (let i = 0; i < parts.length; i++) {
|
28
|
-
const part = parts[i];
|
29
|
-
if (typeof part === 'string' && part.endsWith('!important')) {
|
30
|
-
parts[i] = part.replace('!important', '').trim();
|
31
|
-
suffix = ' !important';
|
32
|
-
}
|
33
|
-
}
|
34
|
-
if (parts.length === 1 && typeof parts[0] === 'string' && globalKeywords.has(parts[0])) {
|
35
|
-
return [parts[0], parts[0], parts[0]];
|
36
|
-
}
|
37
|
-
|
38
|
-
// Find the part that starts with a number
|
39
|
-
// This is most likely to be the borderWidth
|
40
|
-
let width = parts.find(part => typeof part === 'number' || part.match(/^\.?\d+/) || borderWidthKeywords.has(part));
|
41
|
-
if (typeof width === 'number') {
|
42
|
-
width = String(width) + 'px';
|
43
|
-
}
|
44
|
-
// console.log('width', width);
|
45
|
-
if (width != null) {
|
46
|
-
parts.splice(parts.indexOf(width), 1);
|
47
|
-
}
|
48
|
-
if (parts.length === 0) {
|
49
|
-
return [String(width) + suffix, null, null];
|
50
|
-
}
|
51
|
-
const style = parts.find(part => typeof part === 'string' && borderStyleKeywords.has(part));
|
52
|
-
if (style != null) {
|
53
|
-
parts.splice(parts.indexOf(style), 1);
|
54
|
-
}
|
55
|
-
if (parts.length === 2 && width == null) {
|
56
|
-
width = parts[0];
|
57
|
-
parts.splice(0, 1);
|
58
|
-
}
|
59
|
-
if (width != null && parts.length > 1) {
|
60
|
-
throw new Error('Invalid border shorthand value');
|
61
|
-
}
|
62
|
-
const color = parts[0];
|
63
|
-
return [width, style, color].map(part => part != null ? part + suffix : null);
|
64
|
-
}
|
65
18
|
const expansions = {
|
66
|
-
// TODO: Due to UI regressions internally, we need to maintain the buggy behaviour of
|
67
|
-
// border shorthand for now. This will be fixed in a future release.
|
68
|
-
// border: (rawValue: TStyleValue): TReturn => {
|
69
|
-
// if (typeof rawValue === 'number') {
|
70
|
-
// return expansions.borderWidth(rawValue);
|
71
|
-
// }
|
72
|
-
|
73
|
-
// const parts = splitValue(rawValue);
|
74
|
-
// const [width, style, color] = borderDetector(parts);
|
75
|
-
|
76
|
-
// return [
|
77
|
-
// ...(width != null ? expansions.borderWidth(width) : []),
|
78
|
-
// ...(style != null ? expansions.borderStyle(style) : []),
|
79
|
-
// ...(color != null ? expansions.borderColor(color) : []),
|
80
|
-
// ];
|
81
|
-
// },
|
82
|
-
// borderTop: (rawValue: TStyleValue): TReturn => {
|
83
|
-
// if (typeof rawValue === 'number') {
|
84
|
-
// return [['borderTopWidth', rawValue]];
|
85
|
-
// }
|
86
|
-
// const parts = splitValue(rawValue);
|
87
|
-
// const [width, style, color] = borderDetector(parts);
|
88
|
-
|
89
|
-
// return [
|
90
|
-
// width != null ? ['borderTopWidth', width] : null,
|
91
|
-
// style != null ? ['borderTopStyle', style] : null,
|
92
|
-
// color != null ? ['borderTopColor', color] : null,
|
93
|
-
// ].filter(Boolean);
|
94
|
-
// },
|
95
|
-
// borderEnd: (rawValue: TStyleValue): TReturn => {
|
96
|
-
// if (typeof rawValue === 'number') {
|
97
|
-
// return [['borderEndWidth', rawValue]];
|
98
|
-
// }
|
99
|
-
|
100
|
-
// const parts = splitValue(rawValue);
|
101
|
-
// const [width, style, color] = borderDetector(parts);
|
102
|
-
|
103
|
-
// return [
|
104
|
-
// width != null ? ['borderEndWidth', width] : null,
|
105
|
-
// style != null ? ['borderEndStyle', style] : null,
|
106
|
-
// color != null ? ['borderEndColor', color] : null,
|
107
|
-
// ].filter(Boolean);
|
108
|
-
// },
|
109
|
-
// borderRight: (rawValue: TStyleValue): TReturn => {
|
110
|
-
// if (typeof rawValue === 'number') {
|
111
|
-
// return [['borderRightWidth', rawValue]];
|
112
|
-
// }
|
113
|
-
// const parts = splitValue(rawValue);
|
114
|
-
// const [width, style, color] = borderDetector(parts);
|
115
|
-
// return [
|
116
|
-
// width != null ? ['borderRightWidth', width] : null,
|
117
|
-
// style != null ? ['borderRightStyle', style] : null,
|
118
|
-
// color != null ? ['borderRightColor', color] : null,
|
119
|
-
// ].filter(Boolean);
|
120
|
-
// },
|
121
|
-
// borderBottom: (rawValue: TStyleValue): TReturn => {
|
122
|
-
// if (typeof rawValue === 'number') {
|
123
|
-
// return [['borderBottomWidth', rawValue]];
|
124
|
-
// }
|
125
|
-
// const parts = splitValue(rawValue);
|
126
|
-
// const [width, style, color] = borderDetector(parts);
|
127
|
-
// return [
|
128
|
-
// width != null ? ['borderBottomWidth', width] : null,
|
129
|
-
// style != null ? ['borderBottomStyle', style] : null,
|
130
|
-
// color != null ? ['borderBottomColor', color] : null,
|
131
|
-
// ].filter(Boolean);
|
132
|
-
// },
|
133
|
-
// borderStart: (rawValue: TStyleValue): TReturn => {
|
134
|
-
// if (typeof rawValue === 'number') {
|
135
|
-
// return [['borderStartWidth', rawValue]];
|
136
|
-
// }
|
137
|
-
// const parts = splitValue(rawValue);
|
138
|
-
// const [width, style, color] = borderDetector(parts);
|
139
|
-
// return [
|
140
|
-
// width != null ? ['borderStartWidth', width] : null,
|
141
|
-
// style != null ? ['borderStartStyle', style] : null,
|
142
|
-
// color != null ? ['borderStartColor', color] : null,
|
143
|
-
// ].filter(Boolean);
|
144
|
-
// },
|
145
|
-
// borderLeft: (rawValue: TStyleValue): TReturn => {
|
146
|
-
// if (typeof rawValue === 'number') {
|
147
|
-
// return [['borderLeftWidth', rawValue]];
|
148
|
-
// }
|
149
|
-
// const parts = splitValue(rawValue);
|
150
|
-
// const [width, style, color] = borderDetector(parts);
|
151
|
-
// return [
|
152
|
-
// width != null ? ['borderLeftWidth', width] : null,
|
153
|
-
// style != null ? ['borderLeftStyle', style] : null,
|
154
|
-
// color != null ? ['borderLeftColor', color] : null,
|
155
|
-
// ].filter(Boolean);
|
156
|
-
// },
|
157
|
-
|
158
19
|
border: rawValue => {
|
159
20
|
return [['borderTop', rawValue], ['borderEnd', rawValue], ['borderBottom', rawValue], ['borderStart', rawValue]];
|
160
21
|
},
|
@@ -0,0 +1,101 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
* @flow strict
|
8
|
+
*/
|
9
|
+
|
10
|
+
import type { TStyleValue } from '../common-types';
|
11
|
+
|
12
|
+
// TODO: to be added later.
|
13
|
+
// const aliases = {
|
14
|
+
// marginInlineStart: (rawValue) => [['marginStart', rawValue]],
|
15
|
+
// marginInlineEnd: (rawValue) => [['marginEnd', rawValue]],
|
16
|
+
// marginInline: (rawValue) => [
|
17
|
+
// ['marginStart', rawValue],
|
18
|
+
// ['marginEnd', rawValue],
|
19
|
+
// ],
|
20
|
+
// paddingInlineStart: (rawValue) => [['paddingStart', rawValue]],
|
21
|
+
// paddingInlineEnd: (rawValue) => [['paddingEnd', rawValue]],
|
22
|
+
// paddingInline: (rawValue) => [
|
23
|
+
// ['paddingStart', rawValue],
|
24
|
+
// ['paddingEnd', rawValue],
|
25
|
+
// ],
|
26
|
+
// // 'borderInlineStart': (rawValue) => [['borderStart', rawValue]],
|
27
|
+
// // 'borderInlineEnd': (rawValue) => [['borderEnd', rawValue]],
|
28
|
+
// // // This will need to change.
|
29
|
+
// // 'borderInline': (rawValue) => [
|
30
|
+
// // ['borderStart', rawValue],
|
31
|
+
// // ['borderEnd', rawValue],
|
32
|
+
// // ],
|
33
|
+
// };
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Shorthand properties:
|
37
|
+
* - [x] all - Should be banned
|
38
|
+
* - [ ] animation
|
39
|
+
* - [ ] background
|
40
|
+
* - [-] border
|
41
|
+
* - [x] border-block-end
|
42
|
+
* - [x] border-block-start
|
43
|
+
* - [ ] border-bottom
|
44
|
+
* - [x] border-color
|
45
|
+
* - [x] border-image
|
46
|
+
* - [x] border-inline-end
|
47
|
+
* - [x] border-inline-start
|
48
|
+
* - [ ] border-left
|
49
|
+
* - [x] border-radius
|
50
|
+
* - [ ] border-right
|
51
|
+
* - [x] border-style
|
52
|
+
* - [ ] border-top
|
53
|
+
* - [x] border-width
|
54
|
+
* - [ ] column-rule
|
55
|
+
* - [ ] columns
|
56
|
+
* - [ ] flex
|
57
|
+
* - [ ] flex-flow
|
58
|
+
* - [ ] font
|
59
|
+
* - [ ] gap
|
60
|
+
* - [ ] grid
|
61
|
+
* - [ ] grid-area
|
62
|
+
* - [ ] grid-column
|
63
|
+
* - [ ] grid-row
|
64
|
+
* - [ ] grid-template
|
65
|
+
* - [ ] list-style
|
66
|
+
* - [x] margin
|
67
|
+
* - [ ] mask
|
68
|
+
* - [ ] offset
|
69
|
+
* - [ ] outline
|
70
|
+
* - [x] overflow
|
71
|
+
* - [x] padding
|
72
|
+
* - [ ] place-content
|
73
|
+
* - [ ] place-items
|
74
|
+
* - [ ] place-self
|
75
|
+
* - [ ] scroll-margin
|
76
|
+
* - [ ] scroll-padding
|
77
|
+
* - [ ] text-decoration
|
78
|
+
* - [ ] text-emphasis
|
79
|
+
* - [ ] transition
|
80
|
+
*/
|
81
|
+
|
82
|
+
type TReturn = $ReadOnlyArray<[string, TStyleValue]>;
|
83
|
+
|
84
|
+
declare var expansions: {
|
85
|
+
border: (rawValue: TStyleValue) => TReturn,
|
86
|
+
borderColor: (rawValue: TStyleValue) => TReturn,
|
87
|
+
borderHorizontal: (rawValue: TStyleValue) => TReturn,
|
88
|
+
borderStyle: (rawValue: TStyleValue) => TReturn,
|
89
|
+
borderVertical: (rawValue: TStyleValue) => TReturn,
|
90
|
+
borderWidth: (rawValue: TStyleValue) => TReturn,
|
91
|
+
borderRadius: (rawValue: TStyleValue) => TReturn,
|
92
|
+
margin: (rawValue: TStyleValue) => TReturn,
|
93
|
+
marginHorizontal: (rawValue: TStyleValue) => TReturn,
|
94
|
+
marginVertical: (rawValue: TStyleValue) => TReturn,
|
95
|
+
overflow: (rawValue: TStyleValue) => TReturn,
|
96
|
+
padding: (rawValue: TStyleValue) => TReturn,
|
97
|
+
paddingHorizontal: (rawValue: TStyleValue) => TReturn,
|
98
|
+
paddingVertical: (rawValue: TStyleValue) => TReturn,
|
99
|
+
};
|
100
|
+
|
101
|
+
declare export default expansions;
|
@@ -0,0 +1,76 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
import type { TStyleValue } from '../common-types';
|
11
|
+
type TReturn = ReadonlyArray<[string, TStyleValue]>;
|
12
|
+
declare var shorthands: {
|
13
|
+
all: (_: TStyleValue) => TReturn;
|
14
|
+
animation: (_value: TStyleValue) => TReturn;
|
15
|
+
background: (_value: TStyleValue) => TReturn;
|
16
|
+
border: (_rawValue: TStyleValue) => TReturn;
|
17
|
+
borderInline: (_rawValue: TStyleValue) => TReturn;
|
18
|
+
borderBlock: (_rawValue: TStyleValue) => TReturn;
|
19
|
+
borderTop: (_rawValue: TStyleValue) => TReturn;
|
20
|
+
borderInlineEnd: (_rawValue: TStyleValue) => TReturn;
|
21
|
+
borderRight: (_rawValue: TStyleValue) => TReturn;
|
22
|
+
borderBottom: (_rawValue: TStyleValue) => TReturn;
|
23
|
+
borderInlineStart: (_rawValue: TStyleValue) => TReturn;
|
24
|
+
borderLeft: (_rawValue: TStyleValue) => TReturn;
|
25
|
+
margin: (value: TStyleValue) => TReturn;
|
26
|
+
padding: (rawValue: TStyleValue) => TReturn;
|
27
|
+
};
|
28
|
+
declare var aliases: {
|
29
|
+
borderHorizontal: any;
|
30
|
+
borderVertical: any;
|
31
|
+
borderBlockStart: any;
|
32
|
+
borderEnd: any;
|
33
|
+
borderBlockEnd: any;
|
34
|
+
borderStart: any;
|
35
|
+
borderHorizontalWidth: (value: TStyleValue) => TReturn;
|
36
|
+
borderHorizontalStyle: (value: TStyleValue) => TReturn;
|
37
|
+
borderHorizontalColor: (value: TStyleValue) => TReturn;
|
38
|
+
borderVerticalWidth: (value: TStyleValue) => TReturn;
|
39
|
+
borderVerticalStyle: (value: TStyleValue) => TReturn;
|
40
|
+
borderVerticalColor: (value: TStyleValue) => TReturn;
|
41
|
+
borderBlockStartColor: (value: TStyleValue) => TReturn;
|
42
|
+
borderBlockEndColor: (value: TStyleValue) => TReturn;
|
43
|
+
borderBlockStartStyle: (value: TStyleValue) => TReturn;
|
44
|
+
borderBlockEndStyle: (value: TStyleValue) => TReturn;
|
45
|
+
borderBlockStartWidth: (value: TStyleValue) => TReturn;
|
46
|
+
borderBlockEndWidth: (value: TStyleValue) => TReturn;
|
47
|
+
borderStartColor: (value: TStyleValue) => TReturn;
|
48
|
+
borderEndColor: (value: TStyleValue) => TReturn;
|
49
|
+
borderStartStyle: (value: TStyleValue) => TReturn;
|
50
|
+
borderEndStyle: (value: TStyleValue) => TReturn;
|
51
|
+
borderStartWidth: (value: TStyleValue) => TReturn;
|
52
|
+
borderEndWidth: (value: TStyleValue) => TReturn;
|
53
|
+
borderTopStartRadius: (value: TStyleValue) => TReturn;
|
54
|
+
borderTopEndRadius: (value: TStyleValue) => TReturn;
|
55
|
+
borderBottomStartRadius: (value: TStyleValue) => TReturn;
|
56
|
+
borderBottomEndRadius: (value: TStyleValue) => TReturn;
|
57
|
+
marginBlockStart: (value: TStyleValue) => TReturn;
|
58
|
+
marginBlockEnd: (value: TStyleValue) => TReturn;
|
59
|
+
marginStart: (value: TStyleValue) => TReturn;
|
60
|
+
marginEnd: (value: TStyleValue) => TReturn;
|
61
|
+
marginHorizontal: (value: TStyleValue) => TReturn;
|
62
|
+
marginVertical: (value: TStyleValue) => TReturn;
|
63
|
+
paddingBlockStart: (rawValue: TStyleValue) => TReturn;
|
64
|
+
paddingBlockEnd: (rawValue: TStyleValue) => TReturn;
|
65
|
+
paddingStart: (value: TStyleValue) => TReturn;
|
66
|
+
paddingEnd: (value: TStyleValue) => TReturn;
|
67
|
+
paddingHorizontal: (value: TStyleValue) => TReturn;
|
68
|
+
paddingVertical: (value: TStyleValue) => TReturn;
|
69
|
+
insetBlockStart: (value: TStyleValue) => TReturn;
|
70
|
+
insetBlockEnd: (value: TStyleValue) => TReturn;
|
71
|
+
start: (value: TStyleValue) => TReturn;
|
72
|
+
end: (value: TStyleValue) => TReturn;
|
73
|
+
};
|
74
|
+
declare var expansions: Omit<shorthands, keyof (aliases | {})> &
|
75
|
+
Omit<aliases, keyof ({})> & {};
|
76
|
+
export default expansions;
|
@@ -0,0 +1,87 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
* @flow strict
|
8
|
+
*/
|
9
|
+
|
10
|
+
import type { TStyleValue } from '../common-types';
|
11
|
+
|
12
|
+
/// # Handle CSS shorthands in a React Native compatible way.
|
13
|
+
///
|
14
|
+
/// This means:
|
15
|
+
/// - disallowing certain properties altogether by throwing errors
|
16
|
+
/// - disallowing multiple values within many shorthands
|
17
|
+
/// - Treating certain non-standard properties as aliases for real CSS properties
|
18
|
+
|
19
|
+
type TReturn = $ReadOnlyArray<[string, TStyleValue]>;
|
20
|
+
|
21
|
+
declare var shorthands: {
|
22
|
+
all: (_: TStyleValue) => TReturn,
|
23
|
+
animation: (_value: TStyleValue) => TReturn,
|
24
|
+
background: (_value: TStyleValue) => TReturn,
|
25
|
+
border: (_rawValue: TStyleValue) => TReturn,
|
26
|
+
borderInline: (_rawValue: TStyleValue) => TReturn,
|
27
|
+
borderBlock: (_rawValue: TStyleValue) => TReturn,
|
28
|
+
borderTop: (_rawValue: TStyleValue) => TReturn,
|
29
|
+
borderInlineEnd: (_rawValue: TStyleValue) => TReturn,
|
30
|
+
borderRight: (_rawValue: TStyleValue) => TReturn,
|
31
|
+
borderBottom: (_rawValue: TStyleValue) => TReturn,
|
32
|
+
borderInlineStart: (_rawValue: TStyleValue) => TReturn,
|
33
|
+
borderLeft: (_rawValue: TStyleValue) => TReturn,
|
34
|
+
margin: (value: TStyleValue) => TReturn,
|
35
|
+
padding: (rawValue: TStyleValue) => TReturn,
|
36
|
+
};
|
37
|
+
|
38
|
+
declare var aliases: {
|
39
|
+
borderHorizontal: $FlowFixMe,
|
40
|
+
borderVertical: $FlowFixMe,
|
41
|
+
borderBlockStart: $FlowFixMe,
|
42
|
+
borderEnd: $FlowFixMe,
|
43
|
+
borderBlockEnd: $FlowFixMe,
|
44
|
+
borderStart: $FlowFixMe,
|
45
|
+
borderHorizontalWidth: (value: TStyleValue) => TReturn,
|
46
|
+
borderHorizontalStyle: (value: TStyleValue) => TReturn,
|
47
|
+
borderHorizontalColor: (value: TStyleValue) => TReturn,
|
48
|
+
borderVerticalWidth: (value: TStyleValue) => TReturn,
|
49
|
+
borderVerticalStyle: (value: TStyleValue) => TReturn,
|
50
|
+
borderVerticalColor: (value: TStyleValue) => TReturn,
|
51
|
+
borderBlockStartColor: (value: TStyleValue) => TReturn,
|
52
|
+
borderBlockEndColor: (value: TStyleValue) => TReturn,
|
53
|
+
borderBlockStartStyle: (value: TStyleValue) => TReturn,
|
54
|
+
borderBlockEndStyle: (value: TStyleValue) => TReturn,
|
55
|
+
borderBlockStartWidth: (value: TStyleValue) => TReturn,
|
56
|
+
borderBlockEndWidth: (value: TStyleValue) => TReturn,
|
57
|
+
borderStartColor: (value: TStyleValue) => TReturn,
|
58
|
+
borderEndColor: (value: TStyleValue) => TReturn,
|
59
|
+
borderStartStyle: (value: TStyleValue) => TReturn,
|
60
|
+
borderEndStyle: (value: TStyleValue) => TReturn,
|
61
|
+
borderStartWidth: (value: TStyleValue) => TReturn,
|
62
|
+
borderEndWidth: (value: TStyleValue) => TReturn,
|
63
|
+
borderTopStartRadius: (value: TStyleValue) => TReturn,
|
64
|
+
borderTopEndRadius: (value: TStyleValue) => TReturn,
|
65
|
+
borderBottomStartRadius: (value: TStyleValue) => TReturn,
|
66
|
+
borderBottomEndRadius: (value: TStyleValue) => TReturn,
|
67
|
+
marginBlockStart: (value: TStyleValue) => TReturn,
|
68
|
+
marginBlockEnd: (value: TStyleValue) => TReturn,
|
69
|
+
marginStart: (value: TStyleValue) => TReturn,
|
70
|
+
marginEnd: (value: TStyleValue) => TReturn,
|
71
|
+
marginHorizontal: (value: TStyleValue) => TReturn,
|
72
|
+
marginVertical: (value: TStyleValue) => TReturn,
|
73
|
+
paddingBlockStart: (rawValue: TStyleValue) => TReturn,
|
74
|
+
paddingBlockEnd: (rawValue: TStyleValue) => TReturn,
|
75
|
+
paddingStart: (value: TStyleValue) => TReturn,
|
76
|
+
paddingEnd: (value: TStyleValue) => TReturn,
|
77
|
+
paddingHorizontal: (value: TStyleValue) => TReturn,
|
78
|
+
paddingVertical: (value: TStyleValue) => TReturn,
|
79
|
+
insetBlockStart: (value: TStyleValue) => TReturn,
|
80
|
+
insetBlockEnd: (value: TStyleValue) => TReturn,
|
81
|
+
start: (value: TStyleValue) => TReturn,
|
82
|
+
end: (value: TStyleValue) => TReturn,
|
83
|
+
};
|
84
|
+
|
85
|
+
declare var expansions: { ...shorthands, ...aliases };
|
86
|
+
|
87
|
+
declare export default expansions;
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
import type { StyleXOptions } from './common-types';
|
11
|
+
type VarsObject<Vars extends { readonly [$$Key$$: string]: string | number }> =
|
12
|
+
/**
|
13
|
+
* > 13 | ...$ObjMapConst<Vars, string>,
|
14
|
+
* | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unsupported feature: Translating "object types with complex spreads" is currently not supported.
|
15
|
+
**/
|
16
|
+
any;
|
17
|
+
declare function styleXCreateVars<
|
18
|
+
Vars extends { readonly [$$Key$$: string]: string }
|
19
|
+
>(
|
20
|
+
variables: Vars,
|
21
|
+
options: Readonly<
|
22
|
+
Omit<Partial<StyleXOptions>, keyof ({ themeName: string })> & {
|
23
|
+
themeName: string;
|
24
|
+
}
|
25
|
+
>
|
26
|
+
): [VarsObject<Vars>, { css: string }];
|
27
|
+
export default styleXCreateVars;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
* @flow strict
|
8
|
+
*/
|
9
|
+
|
10
|
+
import type { StyleXOptions } from './common-types';
|
11
|
+
|
12
|
+
type VarsObject<Vars: { +[string]: string | number }> = {
|
13
|
+
...$ObjMapConst<Vars, string>,
|
14
|
+
__themeName__: string,
|
15
|
+
};
|
16
|
+
|
17
|
+
// Similar to `stylex.create` it takes an object of variables with their values
|
18
|
+
// and returns a string after hashing it.
|
19
|
+
declare export default function styleXCreateVars<+Vars: { +[string]: string }>(
|
20
|
+
variables: Vars,
|
21
|
+
options: $ReadOnly<{ ...Partial<StyleXOptions>, themeName: string, ... }>
|
22
|
+
): [VarsObject<Vars>, { css: string }];
|
@@ -0,0 +1,23 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
import type {
|
11
|
+
RawStyles,
|
12
|
+
InjectableStyle,
|
13
|
+
StyleXOptions,
|
14
|
+
FlatCompiledStyles,
|
15
|
+
} from './common-types';
|
16
|
+
declare function styleXCreateSet(
|
17
|
+
namespaces: { readonly [$$Key$$: string]: RawStyles },
|
18
|
+
options?: StyleXOptions
|
19
|
+
): [
|
20
|
+
{ [$$Key$$: string]: FlatCompiledStyles },
|
21
|
+
{ [$$Key$$: string]: InjectableStyle }
|
22
|
+
];
|
23
|
+
export default styleXCreateSet;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
* @flow strict
|
8
|
+
*/
|
9
|
+
|
10
|
+
import type {
|
11
|
+
RawStyles,
|
12
|
+
InjectableStyle,
|
13
|
+
StyleXOptions,
|
14
|
+
FlatCompiledStyles,
|
15
|
+
} from './common-types';
|
16
|
+
|
17
|
+
// This takes the object of styles passed to `stylex.create` and transforms it.
|
18
|
+
// The transformation replaces style values with classNames.
|
19
|
+
//
|
20
|
+
// It also collects all injected styles along the way.
|
21
|
+
// It then returns a tuple of the transformed style Object and an object of injected styles.
|
22
|
+
//
|
23
|
+
// This function does some basic validation, and then uses `styleXCreateNamespace` to transform
|
24
|
+
// each namespace within,
|
25
|
+
//
|
26
|
+
// Before returning, it ensures that there are no duplicate styles being injected.
|
27
|
+
declare export default function styleXCreateSet(
|
28
|
+
namespaces: { +[string]: RawStyles },
|
29
|
+
options?: StyleXOptions
|
30
|
+
): [{ [string]: FlatCompiledStyles }, { [string]: InjectableStyle }];
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
*
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
|
11
|
+
declare function stylexFirstThatWorks<T>(
|
12
|
+
...args: ReadonlyArray<T>
|
13
|
+
): ReadonlyArray<T>;
|
14
|
+
export default stylexFirstThatWorks;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
* @flow strict
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
|
11
|
+
declare export default function stylexFirstThatWorks<T>(
|
12
|
+
...args: $ReadOnlyArray<T>
|
13
|
+
): $ReadOnlyArray<T>;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
*
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
|
11
|
+
export declare class IncludedStyles {
|
12
|
+
astNode: any;
|
13
|
+
constructor(astNode: any);
|
14
|
+
}
|
15
|
+
declare function stylexInclude(
|
16
|
+
firstArg: any,
|
17
|
+
...styles: any
|
18
|
+
): { [key: string]: IncludedStyles };
|
19
|
+
export default stylexInclude;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
* @flow strict
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
|
11
|
+
declare export class IncludedStyles {
|
12
|
+
astNode: any;
|
13
|
+
constructor(astNode: any): void;
|
14
|
+
}
|
15
|
+
|
16
|
+
declare export default function stylexInclude(
|
17
|
+
firstArg: any,
|
18
|
+
...styles: any
|
19
|
+
): {
|
20
|
+
[key: string]: IncludedStyles,
|
21
|
+
};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
import type { InjectableStyle, StyleXOptions } from './common-types';
|
11
|
+
declare function styleXKeyframes(
|
12
|
+
frames: {
|
13
|
+
readonly [$$Key$$: string]: { readonly [$$Key$$: string]: string | number };
|
14
|
+
},
|
15
|
+
options: StyleXOptions
|
16
|
+
): [string, InjectableStyle];
|
17
|
+
export default styleXKeyframes;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
* @flow strict
|
8
|
+
*/
|
9
|
+
|
10
|
+
import type { InjectableStyle, StyleXOptions } from './common-types';
|
11
|
+
|
12
|
+
// Similar to `stylex.create` it takes an object of keyframes
|
13
|
+
// and returns a string after hashing it.
|
14
|
+
//
|
15
|
+
// It also expands shorthand properties to maintain parity with
|
16
|
+
// `stylex.create`.
|
17
|
+
declare export default function styleXKeyframes(
|
18
|
+
frames: { +[string]: { +[string]: string | number } },
|
19
|
+
options: StyleXOptions
|
20
|
+
): [string, InjectableStyle];
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
*/
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Convert a CSS value in JS to the final CSS string value
|
11
|
+
*/
|
12
|
+
declare function transformValue(key: string, rawValue: string | number): string;
|
13
|
+
export default transformValue;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
* @flow strict
|
7
|
+
*/
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Convert a CSS value in JS to the final CSS string value
|
11
|
+
*/
|
12
|
+
declare export default function transformValue(
|
13
|
+
key: string,
|
14
|
+
rawValue: string | number
|
15
|
+
): string;
|