@stylexjs/shared 0.2.0-beta.8 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/README.md +81 -0
  2. package/lib/common-types.d.ts +50 -0
  3. package/lib/common-types.js.flow +65 -0
  4. package/lib/convert-to-className.d.ts +16 -0
  5. package/lib/convert-to-className.js +17 -26
  6. package/lib/convert-to-className.js.flow +23 -0
  7. package/lib/generate-css-rule.d.ts +17 -0
  8. package/lib/generate-css-rule.js +8 -47
  9. package/lib/generate-css-rule.js.flow +17 -0
  10. package/lib/hash.d.ts +11 -0
  11. package/lib/hash.js +3 -27
  12. package/lib/hash.js.flow +10 -0
  13. package/lib/index.d.ts +42 -85
  14. package/lib/index.js +19 -27
  15. package/lib/index.js.flow +59 -0
  16. package/lib/messages.d.ts +36 -0
  17. package/lib/messages.js +28 -55
  18. package/lib/messages.js.flow +39 -0
  19. package/lib/physical-rtl/generate-ltr.d.ts +11 -0
  20. package/lib/physical-rtl/generate-ltr.js +18 -46
  21. package/lib/physical-rtl/generate-ltr.js.flow +12 -0
  22. package/lib/physical-rtl/generate-rtl.d.ts +13 -0
  23. package/lib/physical-rtl/generate-rtl.js +18 -50
  24. package/lib/physical-rtl/generate-rtl.js.flow +12 -0
  25. package/lib/preprocess-rules/PreRule.d.ts +52 -0
  26. package/lib/preprocess-rules/PreRule.js +87 -0
  27. package/lib/preprocess-rules/PreRule.js.flow +64 -0
  28. package/lib/preprocess-rules/application-order.d.ts +290 -0
  29. package/lib/preprocess-rules/application-order.js +193 -0
  30. package/lib/preprocess-rules/application-order.js.flow +241 -0
  31. package/lib/preprocess-rules/basic-validation.d.ts +13 -0
  32. package/lib/preprocess-rules/basic-validation.js +83 -0
  33. package/lib/preprocess-rules/basic-validation.js.flow +13 -0
  34. package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +25 -0
  35. package/lib/preprocess-rules/flatten-raw-style-obj.js +120 -0
  36. package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +27 -0
  37. package/lib/preprocess-rules/index.d.ts +18 -0
  38. package/lib/preprocess-rules/index.js +30 -0
  39. package/lib/preprocess-rules/index.js.flow +19 -0
  40. package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +200 -0
  41. package/lib/preprocess-rules/legacy-expand-shorthands.js +136 -0
  42. package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +179 -0
  43. package/lib/preprocess-rules/property-specificity.d.ts +89 -0
  44. package/lib/preprocess-rules/property-specificity.js +107 -0
  45. package/lib/preprocess-rules/property-specificity.js.flow +98 -0
  46. package/lib/properties/CSS Animations.json +445 -0
  47. package/lib/properties/CSS Backgrounds and Borders.json +1085 -0
  48. package/lib/properties/CSS Basic User Interface.json +365 -0
  49. package/lib/properties/CSS Box Alignment.json +245 -0
  50. package/lib/properties/CSS Box Model.json +501 -0
  51. package/lib/properties/CSS Color.json +100 -0
  52. package/lib/properties/CSS Columns.json +185 -0
  53. package/lib/properties/CSS Containment.json +203 -0
  54. package/lib/properties/CSS Counter Styles.json +56 -0
  55. package/lib/properties/CSS Display.json +20 -0
  56. package/lib/properties/CSS Flexible Box Layout.json +167 -0
  57. package/lib/properties/CSS Fonts.json +684 -0
  58. package/lib/properties/CSS Fragmentation.json +110 -0
  59. package/lib/properties/CSS Generated Content.json +38 -0
  60. package/lib/properties/CSS Grid Layout.json +500 -0
  61. package/lib/properties/CSS Images.json +91 -0
  62. package/lib/properties/CSS Inline.json +38 -0
  63. package/lib/properties/CSS Lists and Counters.json +86 -0
  64. package/lib/properties/CSS Logical Properties.json +1086 -0
  65. package/lib/properties/CSS Masking.json +399 -0
  66. package/lib/properties/CSS Miscellaneous.json +38 -0
  67. package/lib/properties/CSS Motion Path.json +132 -0
  68. package/lib/properties/CSS Overflow.json +216 -0
  69. package/lib/properties/CSS Pages.json +83 -0
  70. package/lib/properties/CSS Positioning.json +166 -0
  71. package/lib/properties/CSS Ruby.json +55 -0
  72. package/lib/properties/CSS Scroll Anchoring.json +19 -0
  73. package/lib/properties/CSS Scroll Snap.json +604 -0
  74. package/lib/properties/CSS Scrollbars.json +38 -0
  75. package/lib/properties/CSS Shapes.json +56 -0
  76. package/lib/properties/CSS Speech.json +20 -0
  77. package/lib/properties/CSS Table.json +115 -0
  78. package/lib/properties/CSS Text Decoration.json +312 -0
  79. package/lib/properties/CSS Text.json +415 -0
  80. package/lib/properties/CSS Transforms.json +188 -0
  81. package/lib/properties/CSS Transitions.json +122 -0
  82. package/lib/properties/CSS Variables.json +20 -0
  83. package/lib/properties/CSS View Transitions.json +20 -0
  84. package/lib/properties/CSS Will Change.json +20 -0
  85. package/lib/properties/CSS Writing Modes.json +92 -0
  86. package/lib/properties/Compositing and Blending.json +62 -0
  87. package/lib/properties/Filter Effects.json +38 -0
  88. package/lib/properties/MathML.json +56 -0
  89. package/lib/properties/Microsoft Extensions.json +885 -0
  90. package/lib/properties/Mozilla Extensions.json +607 -0
  91. package/lib/properties/Pointer Events.json +20 -0
  92. package/lib/properties/WebKit Extensions.json +707 -0
  93. package/lib/properties.json +10122 -0
  94. package/lib/stylex-create-theme.d.ts +26 -0
  95. package/lib/stylex-create-theme.js +62 -0
  96. package/lib/stylex-create-theme.js.flow +19 -0
  97. package/lib/stylex-create.d.ts +23 -0
  98. package/lib/stylex-create.js +30 -142
  99. package/lib/stylex-create.js.flow +30 -0
  100. package/lib/stylex-define-vars.d.ts +36 -0
  101. package/lib/stylex-define-vars.js +72 -0
  102. package/lib/stylex-define-vars.js.flow +28 -0
  103. package/lib/stylex-first-that-works.d.ts +13 -0
  104. package/lib/stylex-first-that-works.js +0 -10
  105. package/lib/stylex-first-that-works.js.flow +12 -0
  106. package/lib/stylex-include.d.ts +18 -0
  107. package/lib/stylex-include.js +0 -10
  108. package/lib/stylex-include.js.flow +20 -0
  109. package/lib/stylex-keyframes.d.ts +17 -0
  110. package/lib/stylex-keyframes.js +22 -30
  111. package/lib/stylex-keyframes.js.flow +20 -0
  112. package/lib/transform-value.d.ts +22 -0
  113. package/lib/transform-value.js +9 -23
  114. package/lib/transform-value.js.flow +25 -0
  115. package/lib/types/index.d.ts +205 -0
  116. package/lib/types/index.js +191 -0
  117. package/lib/types/index.js.flow +241 -0
  118. package/lib/utils/Rule.d.ts +58 -0
  119. package/lib/utils/Rule.js +50 -0
  120. package/lib/utils/Rule.js.flow +64 -0
  121. package/lib/utils/dashify.d.ts +11 -0
  122. package/lib/utils/dashify.js +0 -8
  123. package/lib/utils/dashify.js.flow +10 -0
  124. package/lib/utils/default-options.d.ts +11 -0
  125. package/lib/utils/default-options.js +14 -0
  126. package/lib/utils/default-options.js.flow +25 -0
  127. package/lib/utils/file-based-identifier.d.ts +15 -0
  128. package/lib/utils/file-based-identifier.js +14 -0
  129. package/lib/utils/file-based-identifier.js.flow +14 -0
  130. package/lib/utils/genCSSRule.d.ts +15 -0
  131. package/lib/utils/genCSSRule.js +9 -18
  132. package/lib/utils/genCSSRule.js.flow +15 -0
  133. package/lib/utils/normalize-value.d.ts +16 -0
  134. package/lib/utils/normalize-value.js +11 -15
  135. package/lib/utils/normalize-value.js.flow +16 -0
  136. package/lib/utils/normalizers/convert-camel-case-transition-props.d.ts +14 -0
  137. package/lib/utils/normalizers/convert-camel-case-transition-props.js +23 -0
  138. package/lib/utils/normalizers/convert-camel-case-transition-props.js.flow +13 -0
  139. package/lib/utils/normalizers/convert-camel-case-values.d.ts +14 -0
  140. package/lib/utils/normalizers/convert-camel-case-values.js +23 -0
  141. package/lib/utils/normalizers/convert-camel-case-values.js.flow +13 -0
  142. package/lib/utils/normalizers/detect-unclosed-fns.d.ts +17 -0
  143. package/lib/utils/normalizers/detect-unclosed-fns.js +0 -12
  144. package/lib/utils/normalizers/detect-unclosed-fns.js.flow +16 -0
  145. package/lib/utils/normalizers/font-size-px-to-rem.d.ts +19 -0
  146. package/lib/utils/normalizers/font-size-px-to-rem.js +9 -19
  147. package/lib/utils/normalizers/font-size-px-to-rem.js.flow +18 -0
  148. package/lib/utils/normalizers/leading-zero.d.ts +17 -0
  149. package/lib/utils/normalizers/leading-zero.js +0 -12
  150. package/lib/utils/normalizers/leading-zero.js.flow +16 -0
  151. package/lib/utils/normalizers/quotes.d.ts +18 -0
  152. package/lib/utils/normalizers/quotes.js +0 -13
  153. package/lib/utils/normalizers/quotes.js.flow +17 -0
  154. package/lib/utils/normalizers/timings.d.ts +18 -0
  155. package/lib/utils/normalizers/timings.js +0 -14
  156. package/lib/utils/normalizers/timings.js.flow +17 -0
  157. package/lib/utils/normalizers/whitespace.d.ts +19 -0
  158. package/lib/utils/normalizers/whitespace.js +0 -15
  159. package/lib/utils/normalizers/whitespace.js.flow +18 -0
  160. package/lib/utils/normalizers/zero-dimensions.d.ts +19 -0
  161. package/lib/utils/normalizers/zero-dimensions.js +0 -15
  162. package/lib/utils/normalizers/zero-dimensions.js.flow +18 -0
  163. package/lib/utils/object-utils.d.ts +66 -0
  164. package/lib/utils/object-utils.js +21 -13
  165. package/lib/utils/object-utils.js.flow +77 -0
  166. package/lib/utils/property-priorities.d.ts +11 -0
  167. package/lib/utils/property-priorities.js +531 -0
  168. package/lib/utils/property-priorities.js.flow +10 -0
  169. package/lib/utils/split-css-value.d.ts +14 -0
  170. package/lib/utils/split-css-value.js +33 -0
  171. package/lib/utils/split-css-value.js.flow +15 -0
  172. package/lib/validate.d.ts +12 -0
  173. package/lib/validate.js +1 -10
  174. package/lib/validate.js.flow +12 -0
  175. package/package.json +4 -5
  176. package/lib/expand-shorthands.d.ts +0 -5
  177. package/lib/expand-shorthands.js +0 -387
  178. package/lib/stylex-defaultValue.js +0 -397
@@ -0,0 +1,241 @@
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
+ /**
13
+ * Shorthand properties:
14
+ * - [x] all - Should be banned
15
+ * - [x] animation
16
+ * - [x] background
17
+ * - [x] border
18
+ * - [x] border-block-end
19
+ * - [x] border-block-start
20
+ * - [x] border-bottom
21
+ * - [x] border-color
22
+ * - [x] border-image
23
+ * - [x] border-inline-end
24
+ * - [x] border-inline-start
25
+ * - [x] border-left
26
+ * - [x] border-radius
27
+ * - [x] border-right
28
+ * - [x] border-style
29
+ * - [x] border-top
30
+ * - [x] border-width
31
+ * - [x] column-rule
32
+ * - [x] columns
33
+ * - [x] container
34
+ * - [x] flex
35
+ * - [x] flex-flow
36
+ * - [x] font
37
+ * - [x] gap
38
+ * - [x] grid
39
+ * - [x] grid-area
40
+ * - [x] grid-column
41
+ * - [x] grid-row
42
+ * - [x] grid-template
43
+ * - [x] inset
44
+ * - [x] inset-block
45
+ * - [x] inset-inline
46
+ * - [x] list-style
47
+ * - [x] margin
48
+ * - [x] mask
49
+ * - [x] offset
50
+ * - [x] outline
51
+ * - [x] overflow
52
+ * - [x] padding
53
+ * - [x] place-content
54
+ * - [x] place-items
55
+ * - [x] place-self
56
+ * - [x] scroll-margin
57
+ * - [x] scroll-padding
58
+ * - [x] text-decoration
59
+ * - [x] text-emphasis
60
+ * - [x] transition
61
+ */
62
+
63
+ type TReturn = $ReadOnlyArray<[string, TStyleValue]>;
64
+
65
+ declare const shorthands: {
66
+ all: (_: TStyleValue) => TReturn,
67
+ animation: (value: TStyleValue) => Array<[string, TStyleValue]>,
68
+ animationRange: (value: TStyleValue) => TReturn,
69
+ background: (value: TStyleValue) => TReturn,
70
+ backgroundPosition: (value: TStyleValue) => TReturn,
71
+ border: (rawValue: TStyleValue) => TReturn,
72
+ borderInline: (rawValue: TStyleValue) => TReturn,
73
+ borderBlock: (rawValue: TStyleValue) => TReturn,
74
+ borderTop: (rawValue: TStyleValue) => TReturn,
75
+ borderInlineEnd: (rawValue: TStyleValue) => TReturn,
76
+ borderRight: (rawValue: TStyleValue) => TReturn,
77
+ borderBottom: (rawValue: TStyleValue) => TReturn,
78
+ borderInlineStart: (_rawValue: TStyleValue) => TReturn,
79
+ borderLeft: (_rawValue: TStyleValue) => TReturn,
80
+ borderInlineWidth: (rawValue: TStyleValue) => TReturn,
81
+ borderInlineStyle: (rawValue: TStyleValue) => TReturn,
82
+ borderInlineColor: (rawValue: TStyleValue) => TReturn,
83
+ borderBlockWidth: (rawValue: TStyleValue) => TReturn,
84
+ borderBlockStyle: (rawValue: TStyleValue) => TReturn,
85
+ borderBlockColor: (rawValue: TStyleValue) => TReturn,
86
+ borderColor: (value: TStyleValue) => TReturn,
87
+ borderStyle: (value: TStyleValue) => TReturn,
88
+ borderWidth: (value: TStyleValue) => TReturn,
89
+ borderInlineStartColor: (value: TStyleValue) => TReturn,
90
+ borderInlineEndColor: (value: TStyleValue) => TReturn,
91
+ borderInlineStartStyle: (value: TStyleValue) => TReturn,
92
+ borderInlineEndStyle: (value: TStyleValue) => TReturn,
93
+ borderInlineStartWidth: (value: TStyleValue) => TReturn,
94
+ borderInlineEndWidth: (value: TStyleValue) => TReturn,
95
+ borderLeftColor: (value: TStyleValue) => TReturn,
96
+ borderRightColor: (value: TStyleValue) => TReturn,
97
+ borderLeftStyle: (value: TStyleValue) => TReturn,
98
+ borderRightStyle: (value: TStyleValue) => TReturn,
99
+ borderLeftWidth: (value: TStyleValue) => TReturn,
100
+ borderRightWidth: (value: TStyleValue) => TReturn,
101
+ borderRadius: (value: TStyleValue) => TReturn,
102
+ borderStartStartRadius: (value: TStyleValue) => TReturn,
103
+ borderStartEndRadius: (value: TStyleValue) => TReturn,
104
+ borderEndStartRadius: (value: TStyleValue) => TReturn,
105
+ borderEndEndRadius: (value: TStyleValue) => TReturn,
106
+ borderTopLeftRadius: (value: TStyleValue) => TReturn,
107
+ borderTopRightRadius: (value: TStyleValue) => TReturn,
108
+ borderBottomLeftRadius: (value: TStyleValue) => TReturn,
109
+ borderBottomRightRadius: (value: TStyleValue) => TReturn,
110
+ borderImage: (value: TStyleValue) => TReturn,
111
+ columnRule: (value: TStyleValue) => TReturn,
112
+ columns: (value: TStyleValue) => TReturn,
113
+ container: (value: TStyleValue) => TReturn,
114
+ containIntrinsicSize: (value: TStyleValue) => TReturn,
115
+ flex: (value: TStyleValue) => TReturn,
116
+ flexFlow: (value: TStyleValue) => TReturn,
117
+ font: (value: TStyleValue) => TReturn,
118
+ fontVariant: (value: TStyleValue) => TReturn,
119
+ gap: (value: TStyleValue) => TReturn,
120
+ grid: (value: TStyleValue) => TReturn,
121
+ gridArea: (value: TStyleValue) => TReturn,
122
+ gridRow: (value: TStyleValue) => TReturn,
123
+ gridColumn: (value: TStyleValue) => TReturn,
124
+ gridTemplate: (value: TStyleValue) => TReturn,
125
+ inset: (value: TStyleValue) => TReturn,
126
+ insetInline: (value: TStyleValue) => TReturn,
127
+ insetBlock: (value: TStyleValue) => TReturn,
128
+ insetInlineStart: (value: TStyleValue) => TReturn,
129
+ insetInlineEnd: (value: TStyleValue) => TReturn,
130
+ left: (value: TStyleValue) => TReturn,
131
+ right: (value: TStyleValue) => TReturn,
132
+ listStyle: (value: TStyleValue) => TReturn,
133
+ margin: (value: TStyleValue) => TReturn,
134
+ marginInline: (value: TStyleValue) => TReturn,
135
+ marginBlock: (value: TStyleValue) => TReturn,
136
+ marginInlineStart: (value: TStyleValue) => TReturn,
137
+ marginInlineEnd: (value: TStyleValue) => TReturn,
138
+ marginLeft: (value: TStyleValue) => TReturn,
139
+ marginRight: (value: TStyleValue) => TReturn,
140
+ mask: (value: TStyleValue) => TReturn,
141
+ maskBorder: (value: TStyleValue) => TReturn,
142
+ offset: (value: TStyleValue) => TReturn,
143
+ outline: (value: TStyleValue) => TReturn,
144
+ overflow: (value: TStyleValue) => TReturn,
145
+ padding: (rawValue: TStyleValue) => TReturn,
146
+ paddingInline: (rawValue: TStyleValue) => TReturn,
147
+ paddingBlock: (rawValue: TStyleValue) => TReturn,
148
+ paddingInlineStart: (value: TStyleValue) => TReturn,
149
+ paddingInlineEnd: (value: TStyleValue) => TReturn,
150
+ paddingLeft: (value: TStyleValue) => TReturn,
151
+ paddingRight: (value: TStyleValue) => TReturn,
152
+ placeContent: (value: TStyleValue) => TReturn,
153
+ placeItems: (value: TStyleValue) => TReturn,
154
+ placeSelf: (value: TStyleValue) => TReturn,
155
+ scrollMargin: (value: TStyleValue) => TReturn,
156
+ scrollMarginBlock: (value: TStyleValue) => TReturn,
157
+ scrollMarginInline: (value: TStyleValue) => TReturn,
158
+ scrollMarginInlineStart: (value: TStyleValue) => TReturn,
159
+ scrollMarginInlineEnd: (value: TStyleValue) => TReturn,
160
+ scrollMarginLeft: (value: TStyleValue) => TReturn,
161
+ scrollMarginRight: (value: TStyleValue) => TReturn,
162
+ scrollPadding: (value: TStyleValue) => TReturn,
163
+ scrollPaddingBlock: (value: TStyleValue) => TReturn,
164
+ scrollPaddingInline: (value: TStyleValue) => TReturn,
165
+ scrollPaddingInlineStart: (value: TStyleValue) => TReturn,
166
+ scrollPaddingInlineEnd: (value: TStyleValue) => TReturn,
167
+ scrollPaddingLeft: (value: TStyleValue) => TReturn,
168
+ scrollPaddingRight: (value: TStyleValue) => TReturn,
169
+ scrollSnapType: (value: TStyleValue) => TReturn,
170
+ scrollTimeline: (value: TStyleValue) => TReturn,
171
+ textDecoration: (value: TStyleValue) => TReturn,
172
+ textEmphasis: (value: TStyleValue) => TReturn,
173
+ transition: (value: TStyleValue) => TReturn,
174
+ };
175
+
176
+ declare const aliases: {
177
+ borderHorizontal: $FlowFixMe,
178
+ borderVertical: $FlowFixMe,
179
+ borderBlockStart: $FlowFixMe,
180
+ borderEnd: $FlowFixMe,
181
+ borderBlockEnd: $FlowFixMe,
182
+ borderStart: $FlowFixMe,
183
+ blockSize: (val: TStyleValue) => TReturn,
184
+ inlineSize: (val: TStyleValue) => TReturn,
185
+ minBlockSize: (val: TStyleValue) => TReturn,
186
+ minInlineSize: (val: TStyleValue) => TReturn,
187
+ maxBlockSize: (val: TStyleValue) => TReturn,
188
+ maxInlineSize: (val: TStyleValue) => TReturn,
189
+ borderHorizontalWidth: $FlowFixMe,
190
+ borderHorizontalStyle: $FlowFixMe,
191
+ borderHorizontalColor: $FlowFixMe,
192
+ borderVerticalWidth: $FlowFixMe,
193
+ borderVerticalStyle: $FlowFixMe,
194
+ borderVerticalColor: $FlowFixMe,
195
+ borderBlockStartColor: (value: TStyleValue) => TReturn,
196
+ borderBlockEndColor: (value: TStyleValue) => TReturn,
197
+ borderBlockStartStyle: (value: TStyleValue) => TReturn,
198
+ borderBlockEndStyle: (value: TStyleValue) => TReturn,
199
+ borderBlockStartWidth: (value: TStyleValue) => TReturn,
200
+ borderBlockEndWidth: (value: TStyleValue) => TReturn,
201
+ borderStartColor: $FlowFixMe,
202
+ borderEndColor: $FlowFixMe,
203
+ borderStartStyle: $FlowFixMe,
204
+ borderEndStyle: $FlowFixMe,
205
+ borderStartWidth: $FlowFixMe,
206
+ borderEndWidth: $FlowFixMe,
207
+ borderTopStartRadius: (value: TStyleValue) => TReturn,
208
+ borderTopEndRadius: (value: TStyleValue) => TReturn,
209
+ borderBottomStartRadius: (value: TStyleValue) => TReturn,
210
+ borderBottomEndRadius: (value: TStyleValue) => TReturn,
211
+ containIntrinsicBlockSize: (value: TStyleValue) => TReturn,
212
+ containIntrinsicInlineSize: (value: TStyleValue) => TReturn,
213
+ gridGap: $FlowFixMe,
214
+ gridRowGap: (value: TStyleValue) => TReturn,
215
+ gridColumnGap: (value: TStyleValue) => TReturn,
216
+ marginBlockStart: (value: TStyleValue) => TReturn,
217
+ marginBlockEnd: (value: TStyleValue) => TReturn,
218
+ marginStart: $FlowFixMe,
219
+ marginEnd: $FlowFixMe,
220
+ marginHorizontal: $FlowFixMe,
221
+ marginVertical: $FlowFixMe,
222
+ overflowBlock: (value: TStyleValue) => TReturn,
223
+ overflowInline: (value: TStyleValue) => TReturn,
224
+ paddingBlockStart: (rawValue: TStyleValue) => TReturn,
225
+ paddingBlockEnd: (rawValue: TStyleValue) => TReturn,
226
+ paddingStart: $FlowFixMe,
227
+ paddingEnd: $FlowFixMe,
228
+ paddingHorizontal: $FlowFixMe,
229
+ paddingVertical: $FlowFixMe,
230
+ scrollMarginBlockStart: (value: TStyleValue) => TReturn,
231
+ scrollMarginBlockEnd: (value: TStyleValue) => TReturn,
232
+ insetBlockStart: (value: TStyleValue) => TReturn,
233
+ insetBlockEnd: (value: TStyleValue) => TReturn,
234
+ start: $FlowFixMe,
235
+ end: $FlowFixMe,
236
+ };
237
+
238
+ declare export default $ReadOnly<{
239
+ ...typeof shorthands,
240
+ ...typeof aliases,
241
+ }>;
@@ -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
+ export declare function validateNamespace(
11
+ namespace: unknown,
12
+ conditions: ReadonlyArray<string>,
13
+ ): void;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.validateNamespace = validateNamespace;
7
+ var _stylexInclude = require("../stylex-include");
8
+ var messages = _interopRequireWildcard(require("../messages"));
9
+ var _objectUtils = require("../utils/object-utils");
10
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
+ function validateNamespace(namespace) {
13
+ let conditions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
14
+ if (!(0, _objectUtils.isPlainObject)(namespace)) {
15
+ throw new Error(messages.ILLEGAL_NAMESPACE_VALUE);
16
+ }
17
+ const ns = namespace;
18
+ for (const key in ns) {
19
+ const val = ns[key];
20
+ if (val === null || typeof val === 'string' || typeof val === 'number') {
21
+ continue;
22
+ }
23
+ if (Array.isArray(val)) {
24
+ for (const v of val) {
25
+ if (v === null || typeof v === 'string' || typeof v === 'number') {
26
+ continue;
27
+ }
28
+ throw new Error(messages.ILLEGAL_PROP_ARRAY_VALUE);
29
+ }
30
+ continue;
31
+ }
32
+ if (val instanceof _stylexInclude.IncludedStyles) {
33
+ if (conditions.length === 0) {
34
+ continue;
35
+ }
36
+ throw new Error(messages.ONLY_TOP_LEVEL_INLCUDES);
37
+ }
38
+ if ((0, _objectUtils.isPlainObject)(val)) {
39
+ if (key.startsWith('@') || key.startsWith(':')) {
40
+ if (conditions.includes(key)) {
41
+ throw new Error(messages.DUPLICATE_CONDITIONAL);
42
+ }
43
+ validateNamespace(val, [...conditions, key]);
44
+ } else {
45
+ validateConditionalStyles(val);
46
+ }
47
+ continue;
48
+ }
49
+ throw new Error(messages.ILLEGAL_PROP_VALUE);
50
+ }
51
+ }
52
+ function validateConditionalStyles(val) {
53
+ let conditions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
54
+ for (const key in val) {
55
+ const v = val[key];
56
+ if (!(key.startsWith('@') || key.startsWith(':') || key === 'default')) {
57
+ throw new Error(messages.INVALID_PSEUDO_OR_AT_RULE);
58
+ }
59
+ if (conditions.includes(key)) {
60
+ throw new Error(messages.DUPLICATE_CONDITIONAL);
61
+ }
62
+ if (v === null || typeof v === 'string' || typeof v === 'number') {
63
+ continue;
64
+ }
65
+ if (Array.isArray(v)) {
66
+ for (const vv of v) {
67
+ if (vv === null || typeof vv === 'string' || typeof vv === 'number') {
68
+ continue;
69
+ }
70
+ throw new Error(messages.ILLEGAL_PROP_VALUE);
71
+ }
72
+ continue;
73
+ }
74
+ if (v instanceof _stylexInclude.IncludedStyles) {
75
+ throw new Error(messages.ONLY_TOP_LEVEL_INLCUDES);
76
+ }
77
+ if ((0, _objectUtils.isPlainObject)(v)) {
78
+ validateConditionalStyles(v, [...conditions, key]);
79
+ continue;
80
+ }
81
+ throw new Error(messages.ILLEGAL_PROP_VALUE);
82
+ }
83
+ }
@@ -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
+ declare export function validateNamespace(
11
+ namespace: mixed,
12
+ conditions: $ReadOnlyArray<string>,
13
+ ): void;
@@ -0,0 +1,25 @@
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 { RawStyles, StyleXOptions } from '../common-types';
11
+ import {
12
+ type AnyPreRule,
13
+ type IPreRule,
14
+ PreIncludedStylesRule,
15
+ } from './PreRule';
16
+ export declare function flattenRawStyleObject(
17
+ style: RawStyles,
18
+ options: StyleXOptions,
19
+ ): ReadonlyArray<Readonly<[string, IPreRule]>>;
20
+ export declare function _flattenRawStyleObject(
21
+ style: RawStyles,
22
+ pseudos: ReadonlyArray<string>,
23
+ atRules: ReadonlyArray<string>,
24
+ options: StyleXOptions,
25
+ ): Array<Readonly<[string, AnyPreRule | PreIncludedStylesRule]>>;
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports._flattenRawStyleObject = _flattenRawStyleObject;
7
+ exports.flattenRawStyleObject = flattenRawStyleObject;
8
+ var _index = _interopRequireDefault(require("./index"));
9
+ var _PreRule = require("./PreRule");
10
+ var _stylexInclude = require("../stylex-include");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ function flattenRawStyleObject(style, options) {
13
+ return _flattenRawStyleObject(style, [], [], options);
14
+ }
15
+ function _flattenRawStyleObject(style, pseudos, atRules, options) {
16
+ const flattened = [];
17
+ for (const _key in style) {
18
+ const value = style[_key];
19
+ const key = _key.match(/var\(--[a-z0-9]+\)/) ? _key.slice(4, -1) : _key;
20
+ if (typeof value === 'object' && value instanceof _stylexInclude.IncludedStyles) {
21
+ flattened.push([key, new _PreRule.PreIncludedStylesRule(value)]);
22
+ continue;
23
+ }
24
+ if (value === null || typeof value === 'string' || typeof value === 'number') {
25
+ const pairs = (0, _index.default)([key, value], options);
26
+ for (const [property, value] of pairs) {
27
+ if (value === null) {
28
+ flattened.push([property, new _PreRule.NullPreRule()]);
29
+ } else {
30
+ flattened.push([property, new _PreRule.PreRule(property, value, pseudos, atRules)]);
31
+ }
32
+ }
33
+ continue;
34
+ }
35
+ if (Array.isArray(value)) {
36
+ const equivalentPairs = {};
37
+ for (const eachVal of value) {
38
+ const pairs = (0, _index.default)([key, eachVal], options);
39
+ for (const [property, val] of pairs) {
40
+ if (Array.isArray(val)) {
41
+ if (equivalentPairs[property] == null) {
42
+ equivalentPairs[property] = [...val];
43
+ } else {
44
+ equivalentPairs[property].push(...val);
45
+ }
46
+ } else if (equivalentPairs[property] == null) {
47
+ equivalentPairs[property] = [val];
48
+ } else {
49
+ equivalentPairs[property].push(val);
50
+ }
51
+ }
52
+ }
53
+ Object.entries(equivalentPairs).map(_ref => {
54
+ let [property, values] = _ref;
55
+ return [property, [...new Set(values.filter(Boolean))]];
56
+ }).map(_ref2 => {
57
+ let [property, values] = _ref2;
58
+ return [property, values.length === 0 ? null : values.length === 1 ? values[0] : values];
59
+ }).forEach(_ref3 => {
60
+ let [property, value] = _ref3;
61
+ if (value === null) {
62
+ flattened.push([property, new _PreRule.NullPreRule()]);
63
+ } else {
64
+ flattened.push([property, new _PreRule.PreRule(property, value, pseudos, atRules)]);
65
+ }
66
+ });
67
+ continue;
68
+ }
69
+ if (typeof value === 'object' && !key.startsWith(':') && !key.startsWith('@')) {
70
+ const equivalentPairs = {};
71
+ for (const condition in value) {
72
+ const innerValue = value[condition];
73
+ const pseudosToPassDown = [...pseudos];
74
+ const atRulesToPassDown = [...atRules];
75
+ if (condition.startsWith(':')) {
76
+ pseudosToPassDown.push(condition);
77
+ } else if (condition.startsWith('@')) {
78
+ atRulesToPassDown.push(condition);
79
+ }
80
+ const pairs = _flattenRawStyleObject({
81
+ [key]: innerValue
82
+ }, pseudosToPassDown, atRulesToPassDown, options);
83
+ for (const [property, preRule] of pairs) {
84
+ if (preRule instanceof _PreRule.PreIncludedStylesRule) {
85
+ throw new Error('stylex.include can only be used at the top-level');
86
+ }
87
+ if (equivalentPairs[property] == null) {
88
+ equivalentPairs[property] = {
89
+ [condition]: preRule
90
+ };
91
+ } else {
92
+ equivalentPairs[property][condition] = preRule;
93
+ }
94
+ }
95
+ }
96
+ for (const [property, obj] of Object.entries(equivalentPairs)) {
97
+ const sortedKeys = Object.keys(obj);
98
+ const rules = [];
99
+ for (const condition of sortedKeys) {
100
+ rules.push(obj[condition]);
101
+ }
102
+ flattened.push([property, _PreRule.PreRuleSet.create(rules)]);
103
+ }
104
+ }
105
+ if (typeof value === 'object' && (key.startsWith(':') || key.startsWith('@'))) {
106
+ const pseudosToPassDown = [...pseudos];
107
+ const atRulesToPassDown = [...atRules];
108
+ if (key.startsWith(':')) {
109
+ pseudosToPassDown.push(key);
110
+ } else if (key.startsWith('@')) {
111
+ atRulesToPassDown.push(key);
112
+ }
113
+ const pairs = _flattenRawStyleObject(value, pseudosToPassDown, atRulesToPassDown, options);
114
+ for (const [property, preRule] of pairs) {
115
+ flattened.push([key + '_' + property, preRule]);
116
+ }
117
+ }
118
+ }
119
+ return flattened;
120
+ }
@@ -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
+ * @flow strict
8
+ */
9
+
10
+ import type { RawStyles, StyleXOptions } from '../common-types';
11
+
12
+ import {
13
+ type AnyPreRule,
14
+ type IPreRule,
15
+ PreIncludedStylesRule,
16
+ } from './PreRule';
17
+ declare export function flattenRawStyleObject(
18
+ style: RawStyles,
19
+ options: StyleXOptions,
20
+ ): $ReadOnlyArray<$ReadOnly<[string, IPreRule]>>;
21
+
22
+ declare export function _flattenRawStyleObject(
23
+ style: RawStyles,
24
+ pseudos: $ReadOnlyArray<string>,
25
+ atRules: $ReadOnlyArray<string>,
26
+ options: StyleXOptions,
27
+ ): Array<$ReadOnly<[string, AnyPreRule | PreIncludedStylesRule]>>;
@@ -0,0 +1,18 @@
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, TStyleValue } from '../common-types';
11
+ export declare function getExpandedKeys(
12
+ options: StyleXOptions,
13
+ ): ReadonlyArray<string>;
14
+ declare function flatMapExpandedShorthands(
15
+ objEntry: Readonly<[string, TStyleValue]>,
16
+ options: StyleXOptions,
17
+ ): ReadonlyArray<[string, TStyleValue]>;
18
+ export default flatMapExpandedShorthands;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = flatMapExpandedShorthands;
7
+ exports.getExpandedKeys = getExpandedKeys;
8
+ var _applicationOrder = _interopRequireDefault(require("./application-order"));
9
+ var _legacyExpandShorthands = _interopRequireDefault(require("./legacy-expand-shorthands"));
10
+ var _propertySpecificity = _interopRequireDefault(require("./property-specificity"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ const expansions = {
13
+ 'application-order': _applicationOrder.default,
14
+ 'property-specificity': _propertySpecificity.default,
15
+ 'legacy-expand-shorthands': _legacyExpandShorthands.default
16
+ };
17
+ function getExpandedKeys(options) {
18
+ return Object.keys(expansions[options.styleResolution ?? 'application-order']);
19
+ }
20
+ function flatMapExpandedShorthands(objEntry, options) {
21
+ const [key, value] = objEntry;
22
+ const expansion = expansions[options.styleResolution ?? 'application-order'][key];
23
+ if (expansion) {
24
+ if (Array.isArray(value)) {
25
+ throw new Error('Cannot use fallbacks for shorthands. Use the expansion instead.');
26
+ }
27
+ return expansion(value);
28
+ }
29
+ return [[key, value]];
30
+ }
@@ -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
+ * @flow strict
8
+ */
9
+
10
+ import type { StyleXOptions, TStyleValue } from '../common-types';
11
+
12
+ declare export function getExpandedKeys(
13
+ options: StyleXOptions,
14
+ ): $ReadOnlyArray<string>;
15
+
16
+ declare export default function flatMapExpandedShorthands(
17
+ objEntry: $ReadOnly<[string, TStyleValue]>,
18
+ options: StyleXOptions,
19
+ ): $ReadOnlyArray<[string, TStyleValue]>;