@stylexjs/shared 0.2.0-beta.9 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. package/README.md +3 -3
  2. package/lib/common-types.d.ts +49 -0
  3. package/lib/common-types.js.flow +64 -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 +6 -17
  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 +21 -29
  15. package/lib/index.js.flow +57 -3
  16. package/lib/messages.d.ts +41 -0
  17. package/lib/messages.js +33 -53
  18. package/lib/messages.js.flow +44 -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 +60 -133
  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 +0 -9
  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 +90 -123
  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 +46 -74
  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 +67 -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 -146
  99. package/lib/stylex-create.js.flow +30 -0
  100. package/lib/stylex-define-vars.d.ts +29 -0
  101. package/lib/stylex-define-vars.js +73 -0
  102. package/lib/stylex-define-vars.js.flow +26 -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 +2 -12
  108. package/lib/stylex-include.js.flow +20 -0
  109. package/lib/stylex-keyframes.d.ts +17 -0
  110. package/lib/stylex-keyframes.js +6 -26
  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 +0 -21
  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 +13 -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 +8 -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 +2 -14
  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 +516 -101
  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 +0 -14
  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 -330
  178. package/lib/namespace-transforms/__tests__/preflatten.test.js +0 -120
  179. package/lib/namespace-transforms/preflatten.js +0 -89
  180. package/lib/preprocess-rules/expand-shorthands.js +0 -156
  181. package/lib/preprocess-rules/null-out-longhand.js +0 -310
  182. package/lib/preprocess-rules/react-native-web.js +0 -142
  183. package/lib/stylex-defaultValue.js +0 -397
@@ -6,147 +6,58 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _splitCssValue = _interopRequireDefault(require("../utils/split-css-value"));
8
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- /**
10
- * Copyright (c) Meta Platforms, Inc. and affiliates.
11
- *
12
- * This source code is licensed under the MIT license found in the
13
- * LICENSE file in the root directory of this source tree.
14
- *
15
- *
16
- */
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
- function borderDetector(borderParts) {
24
- const parts = borderParts.filter(Boolean).slice();
25
- let suffix = '';
26
- for (let i = 0; i < parts.length; i++) {
27
- const part = parts[i];
28
- if (typeof part === 'string' && part.endsWith('!important')) {
29
- parts[i] = part.replace('!important', '').trim();
30
- suffix = ' !important';
31
- }
32
- }
33
- if (parts.length === 1 && globalKeywords.has(parts[0])) {
34
- return [parts[0], parts[0], parts[0]];
35
- }
36
-
37
- // Find the part that starts with a number
38
- // This is most likely to be the borderWidth
39
- let width = parts.find(part => typeof part === 'number' || part.match(/^\.?\d+/) || borderWidthKeywords.has(part));
40
- if (typeof width === 'number') {
41
- width = String(width) + 'px';
42
- }
43
- // console.log('width', width);
44
- if (width != null) {
45
- parts.splice(parts.indexOf(width), 1);
46
- }
47
- if (parts.length === 0) {
48
- return [String(width) + suffix, null, null];
49
- }
50
- const style = parts.find(part => typeof part === 'string' && borderStyleKeywords.has(part));
51
- if (style != null) {
52
- parts.splice(parts.indexOf(style), 1);
53
- }
54
- if (parts.length === 2 && width == null) {
55
- width = parts[0];
56
- parts.splice(0, 1);
57
- }
58
- if (width != null && parts.length > 1) {
59
- throw new Error('Invalid border shorthand value');
60
- }
61
- const color = parts[0];
62
- return [width, style, color].map(part => part != null ? part + suffix : null);
63
- }
64
- const expansions = {
9
+ const shorthands = {
65
10
  border: rawValue => {
66
- if (typeof rawValue === 'number') {
67
- return expansions.borderWidth(rawValue);
68
- }
69
- const parts = (0, _splitCssValue.default)(rawValue);
70
- const [width, style, color] = borderDetector(parts);
71
- return [...(width != null ? expansions.borderWidth(width) : []), ...(style != null ? expansions.borderStyle(style) : []), ...(color != null ? expansions.borderColor(color) : [])];
72
- },
73
- borderTop: rawValue => {
74
- if (typeof rawValue === 'number') {
75
- return [['borderTopWidth', rawValue]];
76
- }
77
- const parts = (0, _splitCssValue.default)(rawValue);
78
- const [width, style, color] = borderDetector(parts);
79
- return [width != null ? ['borderTopWidth', width] : null, style != null ? ['borderTopStyle', style] : null, color != null ? ['borderTopColor', color] : null].filter(Boolean);
80
- },
81
- borderEnd: rawValue => {
82
- if (typeof rawValue === 'number') {
83
- return [['borderEndWidth', rawValue]];
84
- }
85
- const parts = (0, _splitCssValue.default)(rawValue);
86
- const [width, style, color] = borderDetector(parts);
87
- return [width != null ? ['borderEndWidth', width] : null, style != null ? ['borderEndStyle', style] : null, color != null ? ['borderEndColor', color] : null].filter(Boolean);
88
- },
89
- borderRight: rawValue => {
90
- if (typeof rawValue === 'number') {
91
- return [['borderRightWidth', rawValue]];
92
- }
93
- const parts = (0, _splitCssValue.default)(rawValue);
94
- const [width, style, color] = borderDetector(parts);
95
- return [width != null ? ['borderRightWidth', width] : null, style != null ? ['borderRightStyle', style] : null, color != null ? ['borderRightColor', color] : null].filter(Boolean);
96
- },
97
- borderBottom: rawValue => {
98
- if (typeof rawValue === 'number') {
99
- return [['borderBottomWidth', rawValue]];
100
- }
101
- const parts = (0, _splitCssValue.default)(rawValue);
102
- const [width, style, color] = borderDetector(parts);
103
- return [width != null ? ['borderBottomWidth', width] : null, style != null ? ['borderBottomStyle', style] : null, color != null ? ['borderBottomColor', color] : null].filter(Boolean);
104
- },
105
- borderStart: rawValue => {
106
- if (typeof rawValue === 'number') {
107
- return [['borderStartWidth', rawValue]];
108
- }
109
- const parts = (0, _splitCssValue.default)(rawValue);
110
- const [width, style, color] = borderDetector(parts);
111
- return [width != null ? ['borderStartWidth', width] : null, style != null ? ['borderStartStyle', style] : null, color != null ? ['borderStartColor', color] : null].filter(Boolean);
112
- },
113
- borderLeft: rawValue => {
114
- if (typeof rawValue === 'number') {
115
- return [['borderLeftWidth', rawValue]];
116
- }
117
- const parts = (0, _splitCssValue.default)(rawValue);
118
- const [width, style, color] = borderDetector(parts);
119
- return [width != null ? ['borderLeftWidth', width] : null, style != null ? ['borderLeftStyle', style] : null, color != null ? ['borderLeftColor', color] : null].filter(Boolean);
11
+ return [['borderTop', rawValue], ['borderEnd', rawValue], ['borderBottom', rawValue], ['borderStart', rawValue]];
120
12
  },
121
13
  borderColor: rawValue => {
122
14
  const [top, right = top, bottom = top, left = right] = (0, _splitCssValue.default)(rawValue);
123
15
  return [['borderTopColor', top], ['borderEndColor', right], ['borderBottomColor', bottom], ['borderStartColor', left]];
124
16
  },
125
17
  borderHorizontal: rawValue => {
126
- return [...expansions.borderStart(rawValue), ...expansions.borderEnd(rawValue)];
18
+ return [['borderStart', rawValue], ['borderEnd', rawValue]];
127
19
  },
128
20
  borderStyle: rawValue => {
129
21
  const [top, right = top, bottom = top, left = right] = (0, _splitCssValue.default)(rawValue);
130
22
  return [['borderTopStyle', top], ['borderEndStyle', right], ['borderBottomStyle', bottom], ['borderStartStyle', left]];
131
23
  },
132
24
  borderVertical: rawValue => {
133
- return [...expansions.borderTop(rawValue), ...expansions.borderBottom(rawValue)];
25
+ return [['borderTop', rawValue], ['borderBottom', rawValue]];
134
26
  },
135
27
  borderWidth: rawValue => {
136
28
  const [top, right = top, bottom = top, left = right] = (0, _splitCssValue.default)(rawValue);
137
29
  return [['borderTopWidth', top], ['borderEndWidth', right], ['borderBottomWidth', bottom], ['borderStartWidth', left]];
138
30
  },
31
+ borderHorizontalColor: rawValue => [['borderStartColor', rawValue], ['borderEndColor', rawValue]],
32
+ borderHorizontalStyle: rawValue => [['borderStartStyle', rawValue], ['borderEndStyle', rawValue]],
33
+ borderHorizontalWidth: rawValue => [['borderStartWidth', rawValue], ['borderEndWidth', rawValue]],
34
+ borderVerticalColor: rawValue => [['borderTopColor', rawValue], ['borderBottomColor', rawValue]],
35
+ borderVerticalStyle: rawValue => [['borderTopStyle', rawValue], ['borderBottomStyle', rawValue]],
36
+ borderVerticalWidth: rawValue => [['borderTopWidth', rawValue], ['borderBottomWidth', rawValue]],
139
37
  borderRadius: rawValue => {
140
38
  const [top, right = top, bottom = top, left = right] = (0, _splitCssValue.default)(rawValue);
141
39
  return [['borderTopStartRadius', top], ['borderTopEndRadius', right], ['borderBottomEndRadius', bottom], ['borderBottomStartRadius', left]];
142
40
  },
41
+ inset: rawValue => [['top', rawValue], ['end', rawValue], ['bottom', rawValue], ['start', rawValue]],
42
+ insetInline: rawValue => [...shorthands.start(rawValue), ...shorthands.end(rawValue)],
43
+ insetBlock: rawValue => [['top', rawValue], ['bottom', rawValue]],
44
+ start: rawValue => [['start', rawValue], ['left', null], ['right', null]],
45
+ end: rawValue => [['end', rawValue], ['left', null], ['right', null]],
46
+ left: rawValue => [['left', rawValue], ['start', null], ['end', null]],
47
+ right: rawValue => [['right', rawValue], ['start', null], ['end', null]],
48
+ gap: rawValue => {
49
+ const [row, column = row] = (0, _splitCssValue.default)(rawValue);
50
+ return [['rowGap', row], ['columnGap', column]];
51
+ },
143
52
  margin: rawValue => {
144
53
  const [top, right = top, bottom = top, left = right] = (0, _splitCssValue.default)(rawValue);
145
54
  return [['marginTop', top], ['marginEnd', right], ['marginBottom', bottom], ['marginStart', left]];
146
55
  },
147
- marginHorizontal: rawValue => {
148
- return [['marginStart', rawValue], ['marginEnd', rawValue]];
149
- },
56
+ marginHorizontal: rawValue => [...shorthands.marginStart(rawValue), ...shorthands.marginEnd(rawValue)],
57
+ marginStart: rawValue => [['marginStart', rawValue], ['marginLeft', null], ['marginRight', null]],
58
+ marginEnd: rawValue => [['marginEnd', rawValue], ['marginLeft', null], ['marginRight', null]],
59
+ marginLeft: rawValue => [['marginLeft', rawValue], ['marginStart', null], ['marginEnd', null]],
60
+ marginRight: rawValue => [['marginRight', rawValue], ['marginStart', null], ['marginEnd', null]],
150
61
  marginVertical: rawValue => {
151
62
  return [['marginTop', rawValue], ['marginBottom', rawValue]];
152
63
  },
@@ -158,12 +69,68 @@ const expansions = {
158
69
  const [top, right = top, bottom = top, left = right] = (0, _splitCssValue.default)(rawValue);
159
70
  return [['paddingTop', top], ['paddingEnd', right], ['paddingBottom', bottom], ['paddingStart', left]];
160
71
  },
161
- paddingHorizontal: rawValue => {
162
- return [['paddingStart', rawValue], ['paddingEnd', rawValue]];
163
- },
164
- paddingVertical: rawValue => {
165
- return [['paddingTop', rawValue], ['paddingBottom', rawValue]];
166
- }
72
+ paddingHorizontal: val => [...shorthands.paddingStart(val), ...shorthands.paddingEnd(val)],
73
+ paddingStart: val => [['paddingStart', val], ['paddingLeft', null], ['paddingRight', null]],
74
+ paddingEnd: val => [['paddingEnd', val], ['paddingLeft', null], ['paddingRight', null]],
75
+ paddingLeft: val => [['paddingLeft', val], ['paddingStart', null], ['paddingEnd', null]],
76
+ paddingRight: val => [['paddingRight', val], ['paddingStart', null], ['paddingEnd', null]],
77
+ paddingVertical: val => [['paddingTop', val], ['paddingBottom', val]]
78
+ };
79
+ const aliases = {
80
+ insetBlockStart: val => [['top', val]],
81
+ insetBlockEnd: val => [['bottom', val]],
82
+ insetInlineStart: shorthands.start,
83
+ insetInlineEnd: shorthands.end,
84
+ blockSize: val => [['height', val]],
85
+ inlineSize: val => [['width', val]],
86
+ minBlockSize: val => [['minHeight', val]],
87
+ minInlineSize: val => [['minWidth', val]],
88
+ maxBlockSize: val => [['maxHeight', val]],
89
+ maxInlineSize: val => [['maxWidth', val]],
90
+ borderBlockWidth: shorthands.borderVerticalWidth,
91
+ borderBlockStyle: shorthands.borderVerticalStyle,
92
+ borderBlockColor: shorthands.borderVerticalColor,
93
+ borderBlockStartWidth: val => [['borderTopWidth', val]],
94
+ borderBlockStartStyle: val => [['borderTopStyle', val]],
95
+ borderBlockStartColor: val => [['borderTopColor', val]],
96
+ borderBlockEndWidth: val => [['borderBottomWidth', val]],
97
+ borderBlockEndStyle: val => [['borderBottomStyle', val]],
98
+ borderBlockEndColor: val => [['borderBottomColor', val]],
99
+ borderInlineWidth: shorthands.borderHorizontalWidth,
100
+ borderInlineStyle: shorthands.borderHorizontalStyle,
101
+ borderInlineColor: shorthands.borderHorizontalColor,
102
+ borderInlineStartWidth: val => [['borderStartWidth', val]],
103
+ borderInlineStartStyle: val => [['borderStartStyle', val]],
104
+ borderInlineStartColor: val => [['borderStartColor', val]],
105
+ borderInlineEndWidth: val => [['borderEndWidth', val]],
106
+ borderInlineEndStyle: val => [['borderEndStyle', val]],
107
+ borderInlineEndColor: val => [['borderEndColor', val]],
108
+ borderStartStartRadius: val => [['borderTopStartRadius', val]],
109
+ borderStartEndRadius: val => [['borderTopEndRadius', val]],
110
+ borderEndStartRadius: val => [['borderBottomStartRadius', val]],
111
+ borderEndEndRadius: val => [['borderBottomEndRadius', val]],
112
+ gridGap: shorthands.gap,
113
+ gridRowGap: value => [['rowGap', value]],
114
+ gridColumnGap: value => [['columnGap', value]],
115
+ marginBlock: shorthands.marginVertical,
116
+ marginBlockStart: val => [['marginTop', val]],
117
+ marginBlockEnd: val => [['marginBottom', val]],
118
+ marginInline: shorthands.marginHorizontal,
119
+ marginInlineStart: val => [['marginStart', val]],
120
+ marginInlineEnd: val => [['marginEnd', val]],
121
+ overflowBlock: value => [['overflowY', value]],
122
+ overflowInline: value => [['overflowX', value]],
123
+ paddingBlock: shorthands.paddingVertical,
124
+ paddingBlockStart: val => [['paddingTop', val]],
125
+ paddingBlockEnd: val => [['paddingBottom', val]],
126
+ paddingInline: shorthands.paddingHorizontal,
127
+ paddingInlineStart: val => [['paddingStart', val]],
128
+ paddingInlineEnd: val => [['paddingEnd', val]],
129
+ scrollMarginBlockStart: value => [['scrollMarginTop', value]],
130
+ scrollMarginBlockEnd: value => [['scrollMarginBottom', value]]
131
+ };
132
+ const expansions = {
133
+ ...shorthands,
134
+ ...aliases
167
135
  };
168
- var _default = expansions;
169
- exports.default = _default;
136
+ var _default = exports.default = expansions;
@@ -0,0 +1,179 @@
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 const shorthands: {
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
+ borderHorizontalColor: (rawValue: TStyleValue) => TReturn,
92
+ borderHorizontalStyle: (rawValue: TStyleValue) => TReturn,
93
+ borderHorizontalWidth: (rawValue: TStyleValue) => TReturn,
94
+ borderVerticalColor: (rawValue: TStyleValue) => TReturn,
95
+ borderVerticalStyle: (rawValue: TStyleValue) => TReturn,
96
+ borderVerticalWidth: (rawValue: TStyleValue) => TReturn,
97
+ borderRadius: (rawValue: TStyleValue) => TReturn,
98
+ inset: (rawValue: TStyleValue) => TReturn,
99
+ insetInline: (rawValue: TStyleValue) => TReturn,
100
+ insetBlock: (rawValue: TStyleValue) => TReturn,
101
+ start: (rawValue: TStyleValue) => TReturn,
102
+ end: (rawValue: TStyleValue) => TReturn,
103
+ left: (rawValue: TStyleValue) => TReturn,
104
+ right: (rawValue: TStyleValue) => TReturn,
105
+ gap: (rawValue: TStyleValue) => TReturn,
106
+ margin: (rawValue: TStyleValue) => TReturn,
107
+ marginHorizontal: (rawValue: TStyleValue) => TReturn,
108
+ marginStart: (rawValue: TStyleValue) => TReturn,
109
+ marginEnd: (rawValue: TStyleValue) => TReturn,
110
+ marginLeft: (rawValue: TStyleValue) => TReturn,
111
+ marginRight: (rawValue: TStyleValue) => TReturn,
112
+ marginVertical: (rawValue: TStyleValue) => TReturn,
113
+ overflow: (rawValue: TStyleValue) => TReturn,
114
+ padding: (rawValue: TStyleValue) => TReturn,
115
+ paddingHorizontal: (val: TStyleValue) => TReturn,
116
+ paddingStart: (val: TStyleValue) => TReturn,
117
+ paddingEnd: (val: TStyleValue) => TReturn,
118
+ paddingLeft: (val: TStyleValue) => TReturn,
119
+ paddingRight: (val: TStyleValue) => TReturn,
120
+ paddingVertical: (val: TStyleValue) => TReturn,
121
+ };
122
+
123
+ declare const aliases: {
124
+ insetBlockStart: (val: TStyleValue) => TReturn,
125
+ insetBlockEnd: (val: TStyleValue) => TReturn,
126
+ insetInlineStart: $FlowFixMe,
127
+ insetInlineEnd: $FlowFixMe,
128
+ blockSize: (val: TStyleValue) => TReturn,
129
+ inlineSize: (val: TStyleValue) => TReturn,
130
+ minBlockSize: (val: TStyleValue) => TReturn,
131
+ minInlineSize: (val: TStyleValue) => TReturn,
132
+ maxBlockSize: (val: TStyleValue) => TReturn,
133
+ maxInlineSize: (val: TStyleValue) => TReturn,
134
+ borderBlockWidth: $FlowFixMe,
135
+ borderBlockStyle: $FlowFixMe,
136
+ borderBlockColor: $FlowFixMe,
137
+ borderBlockStartWidth: (val: TStyleValue) => TReturn,
138
+ borderBlockStartStyle: (val: TStyleValue) => TReturn,
139
+ borderBlockStartColor: (val: TStyleValue) => TReturn,
140
+ borderBlockEndWidth: (val: TStyleValue) => TReturn,
141
+ borderBlockEndStyle: (val: TStyleValue) => TReturn,
142
+ borderBlockEndColor: (val: TStyleValue) => TReturn,
143
+ borderInlineWidth: $FlowFixMe,
144
+ borderInlineStyle: $FlowFixMe,
145
+ borderInlineColor: $FlowFixMe,
146
+ borderInlineStartWidth: (val: TStyleValue) => TReturn,
147
+ borderInlineStartStyle: (val: TStyleValue) => TReturn,
148
+ borderInlineStartColor: (val: TStyleValue) => TReturn,
149
+ borderInlineEndWidth: (val: TStyleValue) => TReturn,
150
+ borderInlineEndStyle: (val: TStyleValue) => TReturn,
151
+ borderInlineEndColor: (val: TStyleValue) => TReturn,
152
+ borderStartStartRadius: (val: TStyleValue) => TReturn,
153
+ borderStartEndRadius: (val: TStyleValue) => TReturn,
154
+ borderEndStartRadius: (val: TStyleValue) => TReturn,
155
+ borderEndEndRadius: (val: TStyleValue) => TReturn,
156
+ gridGap: $FlowFixMe,
157
+ gridRowGap: (value: TStyleValue) => TReturn,
158
+ gridColumnGap: (value: TStyleValue) => TReturn,
159
+ marginBlock: $FlowFixMe,
160
+ marginBlockStart: (val: TStyleValue) => TReturn,
161
+ marginBlockEnd: (val: TStyleValue) => TReturn,
162
+ marginInline: $FlowFixMe,
163
+ marginInlineStart: (val: TStyleValue) => TReturn,
164
+ marginInlineEnd: (val: TStyleValue) => TReturn,
165
+ overflowBlock: (value: TStyleValue) => TReturn,
166
+ overflowInline: (value: TStyleValue) => TReturn,
167
+ paddingBlock: $FlowFixMe,
168
+ paddingBlockStart: (val: TStyleValue) => TReturn,
169
+ paddingBlockEnd: (val: TStyleValue) => TReturn,
170
+ paddingInline: $FlowFixMe,
171
+ paddingInlineStart: (val: TStyleValue) => TReturn,
172
+ paddingInlineEnd: (val: TStyleValue) => TReturn,
173
+ scrollMarginBlockStart: (value: TStyleValue) => TReturn,
174
+ scrollMarginBlockEnd: (value: TStyleValue) => TReturn,
175
+ };
176
+
177
+ declare const expansions: { ...shorthands, ...aliases };
178
+
179
+ declare export default typeof expansions;
@@ -0,0 +1,89 @@
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 const 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
+ };
26
+ declare const aliases: {
27
+ borderHorizontal: any;
28
+ borderVertical: any;
29
+ borderBlockStart: any;
30
+ borderEnd: any;
31
+ borderBlockEnd: any;
32
+ borderStart: any;
33
+ blockSize: (val: TStyleValue) => TReturn;
34
+ inlineSize: (val: TStyleValue) => TReturn;
35
+ minBlockSize: (val: TStyleValue) => TReturn;
36
+ minInlineSize: (val: TStyleValue) => TReturn;
37
+ maxBlockSize: (val: TStyleValue) => TReturn;
38
+ maxInlineSize: (val: TStyleValue) => TReturn;
39
+ borderHorizontalWidth: (val: TStyleValue) => TReturn;
40
+ borderHorizontalStyle: (val: TStyleValue) => TReturn;
41
+ borderHorizontalColor: (val: TStyleValue) => TReturn;
42
+ borderVerticalWidth: (val: TStyleValue) => TReturn;
43
+ borderVerticalStyle: (val: TStyleValue) => TReturn;
44
+ borderVerticalColor: (val: TStyleValue) => TReturn;
45
+ borderBlockStartColor: (value: TStyleValue) => TReturn;
46
+ borderBlockEndColor: (value: TStyleValue) => TReturn;
47
+ borderBlockStartStyle: (value: TStyleValue) => TReturn;
48
+ borderBlockEndStyle: (value: TStyleValue) => TReturn;
49
+ borderBlockStartWidth: (value: TStyleValue) => TReturn;
50
+ borderBlockEndWidth: (value: TStyleValue) => TReturn;
51
+ borderStartColor: (val: TStyleValue) => TReturn;
52
+ borderEndColor: (val: TStyleValue) => TReturn;
53
+ borderStartStyle: (val: TStyleValue) => TReturn;
54
+ borderEndStyle: (val: TStyleValue) => TReturn;
55
+ borderStartWidth: (val: TStyleValue) => TReturn;
56
+ borderEndWidth: (val: TStyleValue) => TReturn;
57
+ borderTopStartRadius: (value: TStyleValue) => TReturn;
58
+ borderTopEndRadius: (value: TStyleValue) => TReturn;
59
+ borderBottomStartRadius: (value: TStyleValue) => TReturn;
60
+ borderBottomEndRadius: (value: TStyleValue) => TReturn;
61
+ containIntrinsicBlockSize: (value: TStyleValue) => TReturn;
62
+ containIntrinsicInlineSize: (value: TStyleValue) => TReturn;
63
+ marginBlockStart: (value: TStyleValue) => TReturn;
64
+ marginBlockEnd: (value: TStyleValue) => TReturn;
65
+ marginStart: (val: TStyleValue) => TReturn;
66
+ marginEnd: (val: TStyleValue) => TReturn;
67
+ marginHorizontal: (val: TStyleValue) => TReturn;
68
+ marginVertical: (val: TStyleValue) => TReturn;
69
+ overflowBlock: (value: TStyleValue) => TReturn;
70
+ overflowInline: (value: TStyleValue) => TReturn;
71
+ paddingBlockStart: (rawValue: TStyleValue) => TReturn;
72
+ paddingBlockEnd: (rawValue: TStyleValue) => TReturn;
73
+ paddingStart: (val: TStyleValue) => TReturn;
74
+ paddingEnd: (val: TStyleValue) => TReturn;
75
+ paddingHorizontal: (val: TStyleValue) => TReturn;
76
+ paddingVertical: (val: TStyleValue) => TReturn;
77
+ scrollMarginBlockStart: (value: TStyleValue) => TReturn;
78
+ scrollMarginBlockEnd: (value: TStyleValue) => TReturn;
79
+ insetBlockStart: (value: TStyleValue) => TReturn;
80
+ insetBlockEnd: (value: TStyleValue) => TReturn;
81
+ start: (val: TStyleValue) => TReturn;
82
+ end: (val: TStyleValue) => TReturn;
83
+ };
84
+ declare const $$EXPORT_DEFAULT_DECLARATION$$: Readonly</**
85
+ * > 96 | ...typeof shorthands,
86
+ * | ^^^^^^^^^^^^^^^^^^^^ Unsupported feature: Translating "object types with complex spreads" is currently not supported.
87
+ **/
88
+ any>;
89
+ export default $$EXPORT_DEFAULT_DECLARATION$$;