@stylexjs/shared 0.17.5 → 0.18.1

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 (145) hide show
  1. package/lib/common-types.d.ts +61 -0
  2. package/lib/common-types.js +1 -0
  3. package/lib/common-types.js.flow +85 -0
  4. package/lib/hash.d.ts +15 -0
  5. package/lib/hash.js +49 -0
  6. package/lib/hash.js.flow +12 -0
  7. package/lib/messages.d.ts +70 -0
  8. package/lib/messages.js +38 -0
  9. package/lib/messages.js.flow +44 -0
  10. package/lib/physical-rtl/generate-ltr.d.ts +15 -0
  11. package/lib/physical-rtl/generate-ltr.js +75 -0
  12. package/lib/physical-rtl/generate-ltr.js.flow +14 -0
  13. package/lib/physical-rtl/generate-rtl.d.ts +15 -0
  14. package/lib/physical-rtl/generate-rtl.js +157 -0
  15. package/lib/physical-rtl/generate-rtl.js.flow +14 -0
  16. package/lib/preprocess-rules/PreRule.d.ts +51 -0
  17. package/lib/preprocess-rules/PreRule.js +79 -0
  18. package/lib/preprocess-rules/PreRule.js.flow +63 -0
  19. package/lib/preprocess-rules/__tests__/PreRule-test.js +33 -0
  20. package/lib/preprocess-rules/__tests__/flatten-raw-style-obj-test.js +196 -0
  21. package/lib/preprocess-rules/application-order.d.ts +186 -0
  22. package/lib/preprocess-rules/application-order.js +195 -0
  23. package/lib/preprocess-rules/application-order.js.flow +141 -0
  24. package/lib/preprocess-rules/basic-validation.d.ts +13 -0
  25. package/lib/preprocess-rules/basic-validation.js +70 -0
  26. package/lib/preprocess-rules/basic-validation.js.flow +13 -0
  27. package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +20 -0
  28. package/lib/preprocess-rules/flatten-raw-style-obj.js +100 -0
  29. package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +23 -0
  30. package/lib/preprocess-rules/index.d.ts +21 -0
  31. package/lib/preprocess-rules/index.js +45 -0
  32. package/lib/preprocess-rules/index.js.flow +23 -0
  33. package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +170 -0
  34. package/lib/preprocess-rules/legacy-expand-shorthands.js +222 -0
  35. package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +142 -0
  36. package/lib/preprocess-rules/property-specificity.d.ts +79 -0
  37. package/lib/preprocess-rules/property-specificity.js +107 -0
  38. package/lib/preprocess-rules/property-specificity.js.flow +93 -0
  39. package/lib/stylex-consts-utils.d.ts +11 -0
  40. package/lib/stylex-consts-utils.js +1 -0
  41. package/lib/stylex-consts-utils.js.flow +14 -0
  42. package/lib/stylex-create-theme.d.ts +26 -0
  43. package/lib/stylex-create-theme.js +53 -0
  44. package/lib/stylex-create-theme.js.flow +19 -0
  45. package/lib/stylex-create.d.ts +27 -0
  46. package/lib/stylex-create.js +60 -0
  47. package/lib/stylex-create.js.flow +37 -0
  48. package/lib/stylex-defaultMarker.d.ts +14 -0
  49. package/lib/stylex-defaultMarker.js +14 -0
  50. package/lib/stylex-defaultMarker.js.flow +13 -0
  51. package/lib/stylex-define-consts.d.ts +23 -0
  52. package/lib/stylex-define-consts.js +40 -0
  53. package/lib/stylex-define-consts.js.flow +19 -0
  54. package/lib/stylex-define-vars.d.ts +28 -0
  55. package/lib/stylex-define-vars.js +90 -0
  56. package/lib/stylex-define-vars.js.flow +26 -0
  57. package/lib/stylex-first-that-works.d.ts +13 -0
  58. package/lib/stylex-first-that-works.js +23 -0
  59. package/lib/stylex-first-that-works.js.flow +12 -0
  60. package/lib/stylex-keyframes.d.ts +17 -0
  61. package/lib/stylex-keyframes.js +46 -0
  62. package/lib/stylex-keyframes.js.flow +20 -0
  63. package/lib/stylex-position-try.d.ts +15 -0
  64. package/lib/stylex-position-try.js +47 -0
  65. package/lib/stylex-position-try.js.flow +18 -0
  66. package/lib/stylex-vars-utils.d.ts +27 -0
  67. package/lib/stylex-vars-utils.js +66 -0
  68. package/lib/stylex-vars-utils.js.flow +31 -0
  69. package/lib/stylex-view-transition-class.d.ts +22 -0
  70. package/lib/stylex-view-transition-class.js +42 -0
  71. package/lib/stylex-view-transition-class.js.flow +23 -0
  72. package/lib/types/__tests__/stylex-types-test.js +178 -0
  73. package/lib/types/index.d.ts +254 -0
  74. package/lib/types/index.js +147 -0
  75. package/lib/types/index.js.flow +280 -0
  76. package/lib/utils/Rule.d.ts +58 -0
  77. package/lib/utils/Rule.js +50 -0
  78. package/lib/utils/Rule.js.flow +64 -0
  79. package/lib/utils/__tests__/convert-to-className-test.js +85 -0
  80. package/lib/utils/__tests__/property-priorities-test.js +33 -0
  81. package/lib/utils/__tests__/split-css-value-test.js +26 -0
  82. package/lib/utils/__tests__/transform-value-test.js +36 -0
  83. package/lib/utils/convert-to-className.d.ts +21 -0
  84. package/lib/utils/convert-to-className.js +61 -0
  85. package/lib/utils/convert-to-className.js.flow +29 -0
  86. package/lib/utils/css-properties.js.flow +155 -0
  87. package/lib/utils/dashify.d.ts +11 -0
  88. package/lib/utils/dashify.js +9 -0
  89. package/lib/utils/dashify.js.flow +10 -0
  90. package/lib/utils/default-options.d.ts +12 -0
  91. package/lib/utils/default-options.js +26 -0
  92. package/lib/utils/default-options.js.flow +12 -0
  93. package/lib/utils/file-based-identifier.d.ts +15 -0
  94. package/lib/utils/file-based-identifier.js +13 -0
  95. package/lib/utils/file-based-identifier.js.flow +14 -0
  96. package/lib/utils/generate-css-rule.d.ts +19 -0
  97. package/lib/utils/generate-css-rule.js +37 -0
  98. package/lib/utils/generate-css-rule.js.flow +19 -0
  99. package/lib/utils/normalize-value.d.ts +16 -0
  100. package/lib/utils/normalize-value.js +27 -0
  101. package/lib/utils/normalize-value.js.flow +16 -0
  102. package/lib/utils/normalizers/convert-camel-case-values.d.ts +14 -0
  103. package/lib/utils/normalizers/convert-camel-case-values.js +23 -0
  104. package/lib/utils/normalizers/convert-camel-case-values.js.flow +13 -0
  105. package/lib/utils/normalizers/detect-unclosed-fns.d.ts +17 -0
  106. package/lib/utils/normalizers/detect-unclosed-fns.js +16 -0
  107. package/lib/utils/normalizers/detect-unclosed-fns.js.flow +16 -0
  108. package/lib/utils/normalizers/font-size-px-to-rem.d.ts +19 -0
  109. package/lib/utils/normalizers/font-size-px-to-rem.js +24 -0
  110. package/lib/utils/normalizers/font-size-px-to-rem.js.flow +18 -0
  111. package/lib/utils/normalizers/leading-zero.d.ts +17 -0
  112. package/lib/utils/normalizers/leading-zero.js +24 -0
  113. package/lib/utils/normalizers/leading-zero.js.flow +16 -0
  114. package/lib/utils/normalizers/quotes.d.ts +18 -0
  115. package/lib/utils/normalizers/quotes.js +17 -0
  116. package/lib/utils/normalizers/quotes.js.flow +17 -0
  117. package/lib/utils/normalizers/timings.d.ts +18 -0
  118. package/lib/utils/normalizers/timings.js +25 -0
  119. package/lib/utils/normalizers/timings.js.flow +17 -0
  120. package/lib/utils/normalizers/whitespace.d.ts +19 -0
  121. package/lib/utils/normalizers/whitespace.js +54 -0
  122. package/lib/utils/normalizers/whitespace.js.flow +18 -0
  123. package/lib/utils/normalizers/zero-dimensions.d.ts +19 -0
  124. package/lib/utils/normalizers/zero-dimensions.js +45 -0
  125. package/lib/utils/normalizers/zero-dimensions.js.flow +18 -0
  126. package/lib/utils/object-utils.d.ts +68 -0
  127. package/lib/utils/object-utils.js +89 -0
  128. package/lib/utils/object-utils.js.flow +78 -0
  129. package/lib/utils/property-priorities.js +13 -1
  130. package/lib/utils/rule-utils.d.ts +17 -0
  131. package/lib/utils/rule-utils.js +41 -0
  132. package/lib/utils/rule-utils.js.flow +16 -0
  133. package/lib/utils/split-css-value.d.ts +14 -0
  134. package/lib/utils/split-css-value.js +41 -0
  135. package/lib/utils/split-css-value.js.flow +15 -0
  136. package/lib/utils/transform-value.d.ts +24 -0
  137. package/lib/utils/transform-value.js +50 -0
  138. package/lib/utils/transform-value.js.flow +25 -0
  139. package/lib/validate.d.ts +12 -0
  140. package/lib/validate.js +19 -0
  141. package/lib/validate.js.flow +14 -0
  142. package/lib/when/when.d.ts +67 -0
  143. package/lib/when/when.js +71 -0
  144. package/lib/when/when.js.flow +73 -0
  145. package/package.json +1 -1
@@ -0,0 +1,142 @@
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
+ declare export const LOGICAL_FLOAT_START_VAR: '--stylex-logical-start';
13
+ declare export const LOGICAL_FLOAT_END_VAR: '--stylex-logical-end';
14
+
15
+ // TODO: to be added later.
16
+ // const aliases = {
17
+ // marginInlineStart: (rawValue) => [['marginStart', rawValue]],
18
+ // marginInlineEnd: (rawValue) => [['marginEnd', rawValue]],
19
+ // marginInline: (rawValue) => [
20
+ // ['marginStart', rawValue],
21
+ // ['marginEnd', rawValue],
22
+ // ],
23
+ // paddingInlineStart: (rawValue) => [['paddingStart', rawValue]],
24
+ // paddingInlineEnd: (rawValue) => [['paddingEnd', rawValue]],
25
+ // paddingInline: (rawValue) => [
26
+ // ['paddingStart', rawValue],
27
+ // ['paddingEnd', rawValue],
28
+ // ],
29
+ // // 'borderInlineStart': (rawValue) => [['borderStart', rawValue]],
30
+ // // 'borderInlineEnd': (rawValue) => [['borderEnd', rawValue]],
31
+ // // // This will need to change.
32
+ // // 'borderInline': (rawValue) => [
33
+ // // ['borderStart', rawValue],
34
+ // // ['borderEnd', rawValue],
35
+ // // ],
36
+ // };
37
+
38
+ /**
39
+ * Shorthand properties:
40
+ * - [x] all - Should be banned
41
+ * - [ ] animation
42
+ * - [ ] background
43
+ * - [-] border
44
+ * - [x] border-block-end
45
+ * - [x] border-block-start
46
+ * - [ ] border-bottom
47
+ * - [x] border-color
48
+ * - [x] border-image
49
+ * - [x] border-inline-end
50
+ * - [x] border-inline-start
51
+ * - [ ] border-left
52
+ * - [x] border-radius
53
+ * - [ ] corner-shape
54
+ * - [ ] border-right
55
+ * - [x] border-style
56
+ * - [ ] border-top
57
+ * - [x] border-width
58
+ * - [ ] column-rule
59
+ * - [ ] columns
60
+ * - [ ] flex
61
+ * - [ ] flex-flow
62
+ * - [ ] font
63
+ * - [ ] gap
64
+ * - [ ] grid
65
+ * - [ ] grid-area
66
+ * - [ ] grid-column
67
+ * - [ ] grid-row
68
+ * - [ ] grid-template
69
+ * - [ ] list-style
70
+ * - [x] margin
71
+ * - [ ] mask
72
+ * - [ ] offset
73
+ * - [ ] outline
74
+ * - [x] overflow
75
+ * - [x] padding
76
+ * - [ ] place-content
77
+ * - [ ] place-items
78
+ * - [ ] place-self
79
+ * - [ ] scroll-margin
80
+ * - [ ] scroll-padding
81
+ * - [ ] text-decoration
82
+ * - [ ] text-emphasis
83
+ * - [ ] transition
84
+ */
85
+
86
+ type TReturn = $ReadOnlyArray<[string, TStyleValue]>;
87
+
88
+ declare const shorthands: $ReadOnly<{
89
+ [key: string]: (TStyleValue) => TReturn,
90
+ }>;
91
+
92
+ declare const aliases: {
93
+ insetBlockStart: (val: TStyleValue) => TReturn,
94
+ insetBlockEnd: (val: TStyleValue) => TReturn,
95
+ insetInlineStart: typeof shorthands.start,
96
+ insetInlineEnd: typeof shorthands.end,
97
+ blockSize: (val: TStyleValue) => TReturn,
98
+ inlineSize: (val: TStyleValue) => TReturn,
99
+ minBlockSize: (val: TStyleValue) => TReturn,
100
+ minInlineSize: (val: TStyleValue) => TReturn,
101
+ maxBlockSize: (val: TStyleValue) => TReturn,
102
+ maxInlineSize: (val: TStyleValue) => TReturn,
103
+ borderStart: (val: TStyleValue) => TReturn,
104
+ borderEnd: (val: TStyleValue) => TReturn,
105
+ borderBlockWidth: typeof shorthands.borderVerticalWidth,
106
+ borderBlockStyle: typeof shorthands.borderVerticalStyle,
107
+ borderBlockColor: typeof shorthands.borderVerticalColor,
108
+ borderBlockStartWidth: (val: TStyleValue) => TReturn,
109
+ borderBlockStartStyle: (val: TStyleValue) => TReturn,
110
+ borderBlockStartColor: (val: TStyleValue) => TReturn,
111
+ borderBlockEndWidth: (val: TStyleValue) => TReturn,
112
+ borderBlockEndStyle: (val: TStyleValue) => TReturn,
113
+ borderBlockEndColor: (val: TStyleValue) => TReturn,
114
+ borderInlineWidth: typeof shorthands.borderHorizontalWidth,
115
+ borderInlineStyle: typeof shorthands.borderHorizontalStyle,
116
+ borderInlineColor: typeof shorthands.borderHorizontalColor,
117
+ borderTopStartRadius: (val: TStyleValue) => TReturn,
118
+ borderTopEndRadius: (val: TStyleValue) => TReturn,
119
+ borderBottomStartRadius: (val: TStyleValue) => TReturn,
120
+ borderBottomEndRadius: (val: TStyleValue) => TReturn,
121
+ gridGap: typeof shorthands.gap,
122
+ gridRowGap: (value: TStyleValue) => TReturn,
123
+ gridColumnGap: (value: TStyleValue) => TReturn,
124
+ marginBlock: typeof shorthands.marginVertical,
125
+ marginBlockStart: (val: TStyleValue) => TReturn,
126
+ marginBlockEnd: (val: TStyleValue) => TReturn,
127
+ marginInline: typeof shorthands.marginHorizontal,
128
+ overflowBlock: (value: TStyleValue) => TReturn,
129
+ overflowInline: (value: TStyleValue) => TReturn,
130
+ paddingBlock: typeof shorthands.paddingVertical,
131
+ paddingBlockStart: (val: TStyleValue) => TReturn,
132
+ paddingBlockEnd: (val: TStyleValue) => TReturn,
133
+ paddingInline: typeof shorthands.paddingHorizontal,
134
+ scrollMarginBlockStart: (value: TStyleValue) => TReturn,
135
+ scrollMarginBlockEnd: (value: TStyleValue) => TReturn,
136
+ float: (value: TStyleValue) => TReturn,
137
+ clear: (value: TStyleValue) => TReturn,
138
+ };
139
+
140
+ declare const expansions: { ...typeof shorthands, ...typeof aliases };
141
+
142
+ declare export default typeof expansions;
@@ -0,0 +1,79 @@
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: Readonly<{
13
+ [key: string]: ($$PARAM_0$$: TStyleValue) => TReturn;
14
+ }>;
15
+ declare const aliases: {
16
+ borderHorizontal: typeof shorthands.borderInline;
17
+ borderVertical: typeof shorthands.borderBlock;
18
+ borderBlockStart: typeof shorthands.borderTop;
19
+ borderEnd: typeof shorthands.borderInlineEnd;
20
+ borderBlockEnd: typeof shorthands.borderBottom;
21
+ borderStart: typeof shorthands.borderInlineStart;
22
+ blockSize: (val: TStyleValue) => TReturn;
23
+ inlineSize: (val: TStyleValue) => TReturn;
24
+ minBlockSize: (val: TStyleValue) => TReturn;
25
+ minInlineSize: (val: TStyleValue) => TReturn;
26
+ maxBlockSize: (val: TStyleValue) => TReturn;
27
+ maxInlineSize: (val: TStyleValue) => TReturn;
28
+ borderHorizontalWidth: (val: TStyleValue) => TReturn;
29
+ borderHorizontalStyle: (val: TStyleValue) => TReturn;
30
+ borderHorizontalColor: (val: TStyleValue) => TReturn;
31
+ borderVerticalWidth: (val: TStyleValue) => TReturn;
32
+ borderVerticalStyle: (val: TStyleValue) => TReturn;
33
+ borderVerticalColor: (val: TStyleValue) => TReturn;
34
+ borderBlockStartColor: (value: TStyleValue) => TReturn;
35
+ borderBlockEndColor: (value: TStyleValue) => TReturn;
36
+ borderBlockStartStyle: (value: TStyleValue) => TReturn;
37
+ borderBlockEndStyle: (value: TStyleValue) => TReturn;
38
+ borderBlockStartWidth: (value: TStyleValue) => TReturn;
39
+ borderBlockEndWidth: (value: TStyleValue) => TReturn;
40
+ borderStartColor: (val: TStyleValue) => TReturn;
41
+ borderEndColor: (val: TStyleValue) => TReturn;
42
+ borderStartStyle: (val: TStyleValue) => TReturn;
43
+ borderEndStyle: (val: TStyleValue) => TReturn;
44
+ borderStartWidth: (val: TStyleValue) => TReturn;
45
+ borderEndWidth: (val: TStyleValue) => TReturn;
46
+ borderTopStartRadius: (value: TStyleValue) => TReturn;
47
+ borderTopEndRadius: (value: TStyleValue) => TReturn;
48
+ borderBottomStartRadius: (value: TStyleValue) => TReturn;
49
+ borderBottomEndRadius: (value: TStyleValue) => TReturn;
50
+ containIntrinsicBlockSize: (value: TStyleValue) => TReturn;
51
+ containIntrinsicInlineSize: (value: TStyleValue) => TReturn;
52
+ marginBlockStart: (value: TStyleValue) => TReturn;
53
+ marginBlockEnd: (value: TStyleValue) => TReturn;
54
+ marginStart: (val: TStyleValue) => TReturn;
55
+ marginEnd: (val: TStyleValue) => TReturn;
56
+ marginHorizontal: (val: TStyleValue) => TReturn;
57
+ marginVertical: (val: TStyleValue) => TReturn;
58
+ overflowBlock: (value: TStyleValue) => TReturn;
59
+ overflowInline: (value: TStyleValue) => TReturn;
60
+ paddingBlockStart: (rawValue: TStyleValue) => TReturn;
61
+ paddingBlockEnd: (rawValue: TStyleValue) => TReturn;
62
+ paddingStart: (val: TStyleValue) => TReturn;
63
+ paddingEnd: (val: TStyleValue) => TReturn;
64
+ paddingHorizontal: (val: TStyleValue) => TReturn;
65
+ paddingVertical: (val: TStyleValue) => TReturn;
66
+ scrollMarginBlockStart: (value: TStyleValue) => TReturn;
67
+ scrollMarginBlockEnd: (value: TStyleValue) => TReturn;
68
+ insetBlockStart: (value: TStyleValue) => TReturn;
69
+ insetBlockEnd: (value: TStyleValue) => TReturn;
70
+ start: (val: TStyleValue) => TReturn;
71
+ end: (val: TStyleValue) => TReturn;
72
+ };
73
+ declare const $$EXPORT_DEFAULT_DECLARATION$$: Readonly<
74
+ Omit<typeof shorthands, keyof typeof aliases | keyof {}> &
75
+ Omit<typeof aliases, keyof {}> & {}
76
+ >;
77
+ declare type $$EXPORT_DEFAULT_DECLARATION$$ =
78
+ typeof $$EXPORT_DEFAULT_DECLARATION$$;
79
+ export default $$EXPORT_DEFAULT_DECLARATION$$;
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const shorthands = {
8
+ all: _ => {
9
+ throw new Error('all is not supported');
10
+ },
11
+ animation: _value => {
12
+ throw new Error('animation is not supported');
13
+ },
14
+ background: _value => {
15
+ throw new Error('background is not supported. Use background-color, border-image etc. instead.');
16
+ },
17
+ border: _rawValue => {
18
+ throw new Error('border is not supported. Use border-width, border-style and border-color instead.');
19
+ },
20
+ borderInline: _rawValue => {
21
+ throw new Error('borderInline is not supported. Use borderInlineWidth, borderInlineStyle and borderInlineColor instead.');
22
+ },
23
+ borderBlock: _rawValue => {
24
+ throw new Error('borderBlock is not supported. Use borderBlockWidth, borderBlockStyle and borderBlockColor instead.');
25
+ },
26
+ borderTop: _rawValue => {
27
+ throw new Error('borderTop is not supported. Use borderTopWidth, borderTopStyle and borderTopColor instead.');
28
+ },
29
+ borderInlineEnd: _rawValue => {
30
+ throw new Error('borderInlineEnd is not supported. Use borderInlineEndWidth, borderInlineEndStyle and borderInlineEndColor instead.');
31
+ },
32
+ borderRight: _rawValue => {
33
+ throw new Error('borderRight is not supported. Use borderRightWidth, borderRightStyle and borderRightColor instead.');
34
+ },
35
+ borderBottom: _rawValue => {
36
+ throw new Error('borderBottom is not supported. Use borderBottomWidth, borderBottomStyle and borderBottomColor instead.');
37
+ },
38
+ borderInlineStart: _rawValue => {
39
+ throw new Error('borderInlineStart is not supported. Use borderInlineStartWidth, borderInlineStartStyle and borderInlineStartColor instead.');
40
+ },
41
+ borderLeft: _rawValue => {
42
+ throw new Error(['`borderLeft` is not supported.', 'You could use `borderLeftWidth`, `borderLeftStyle` and `borderLeftColor`,', 'but it is preferable to use `borderInlineStartWidth`, `borderInlineStartStyle` and `borderInlineStartColor`.'].join(' '));
43
+ }
44
+ };
45
+ const aliases = {
46
+ borderHorizontal: shorthands.borderInline,
47
+ borderVertical: shorthands.borderBlock,
48
+ borderBlockStart: shorthands.borderTop,
49
+ borderEnd: shorthands.borderInlineEnd,
50
+ borderBlockEnd: shorthands.borderBottom,
51
+ borderStart: shorthands.borderInlineStart,
52
+ blockSize: val => [['height', val]],
53
+ inlineSize: val => [['width', val]],
54
+ minBlockSize: val => [['minHeight', val]],
55
+ minInlineSize: val => [['minWidth', val]],
56
+ maxBlockSize: val => [['maxHeight', val]],
57
+ maxInlineSize: val => [['maxWidth', val]],
58
+ borderHorizontalWidth: val => [['borderInlineWidth', val]],
59
+ borderHorizontalStyle: val => [['borderInlineStyle', val]],
60
+ borderHorizontalColor: val => [['borderInlineColor', val]],
61
+ borderVerticalWidth: val => [['borderBlockWidth', val]],
62
+ borderVerticalStyle: val => [['borderBlockStyle', val]],
63
+ borderVerticalColor: val => [['borderBlockColor', val]],
64
+ borderBlockStartColor: value => [['borderTopColor', value]],
65
+ borderBlockEndColor: value => [['borderBottomColor', value]],
66
+ borderBlockStartStyle: value => [['borderTopStyle', value]],
67
+ borderBlockEndStyle: value => [['borderBottomStyle', value]],
68
+ borderBlockStartWidth: value => [['borderTopWidth', value]],
69
+ borderBlockEndWidth: value => [['borderBottomWidth', value]],
70
+ borderStartColor: val => [['borderInlineStartColor', val]],
71
+ borderEndColor: val => [['borderInlineEndColor', val]],
72
+ borderStartStyle: val => [['borderInlineStartStyle', val]],
73
+ borderEndStyle: val => [['borderInlineEndStyle', val]],
74
+ borderStartWidth: val => [['borderInlineStartWidth', val]],
75
+ borderEndWidth: val => [['borderInlineEndWidth', val]],
76
+ borderTopStartRadius: value => [['borderStartStartRadius', value]],
77
+ borderTopEndRadius: value => [['borderStartEndRadius', value]],
78
+ borderBottomStartRadius: value => [['borderEndStartRadius', value]],
79
+ borderBottomEndRadius: value => [['borderEndEndRadius', value]],
80
+ containIntrinsicBlockSize: value => [['containIntrinsicHeight', value]],
81
+ containIntrinsicInlineSize: value => [['containIntrinsicWidth', value]],
82
+ marginBlockStart: value => [['marginTop', value]],
83
+ marginBlockEnd: value => [['marginBottom', value]],
84
+ marginStart: val => [['marginInlineStart', val]],
85
+ marginEnd: val => [['marginInlineEnd', val]],
86
+ marginHorizontal: val => [['marginInline', val]],
87
+ marginVertical: val => [['marginBlock', val]],
88
+ overflowBlock: value => [['overflowY', value]],
89
+ overflowInline: value => [['overflowX', value]],
90
+ paddingBlockStart: rawValue => [['paddingTop', rawValue]],
91
+ paddingBlockEnd: rawValue => [['paddingBottom', rawValue]],
92
+ paddingStart: val => [['paddingInlineStart', val]],
93
+ paddingEnd: val => [['paddingInlineEnd', val]],
94
+ paddingHorizontal: val => [['paddingInline', val]],
95
+ paddingVertical: val => [['paddingBlock', val]],
96
+ scrollMarginBlockStart: value => [['scrollMarginTop', value]],
97
+ scrollMarginBlockEnd: value => [['scrollMarginBottom', value]],
98
+ insetBlockStart: value => [['top', value]],
99
+ insetBlockEnd: value => [['bottom', value]],
100
+ start: val => [['insetInlineStart', val]],
101
+ end: val => [['insetInlineEnd', val]]
102
+ };
103
+ const expansions = {
104
+ ...shorthands,
105
+ ...aliases
106
+ };
107
+ var _default = exports.default = expansions;
@@ -0,0 +1,93 @@
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 const shorthands: $ReadOnly<{
22
+ [key: string]: (TStyleValue) => TReturn,
23
+ }>;
24
+
25
+ declare const aliases: {
26
+ // @Deprecated
27
+ borderHorizontal: typeof shorthands.borderInline,
28
+ // @Deprecated
29
+ borderVertical: typeof shorthands.borderBlock,
30
+ // @Deprecated
31
+ borderBlockStart: typeof shorthands.borderTop,
32
+ // @Deprecated
33
+ borderEnd: typeof shorthands.borderInlineEnd,
34
+ // @Deprecated
35
+ borderBlockEnd: typeof shorthands.borderBottom,
36
+ // @Deprecated
37
+ borderStart: typeof shorthands.borderInlineStart,
38
+ blockSize: (val: TStyleValue) => TReturn,
39
+ inlineSize: (val: TStyleValue) => TReturn,
40
+ minBlockSize: (val: TStyleValue) => TReturn,
41
+ minInlineSize: (val: TStyleValue) => TReturn,
42
+ maxBlockSize: (val: TStyleValue) => TReturn,
43
+ maxInlineSize: (val: TStyleValue) => TReturn,
44
+ borderHorizontalWidth: (val: TStyleValue) => TReturn,
45
+ borderHorizontalStyle: (val: TStyleValue) => TReturn,
46
+ borderHorizontalColor: (val: TStyleValue) => TReturn,
47
+ borderVerticalWidth: (val: TStyleValue) => TReturn,
48
+ borderVerticalStyle: (val: TStyleValue) => TReturn,
49
+ borderVerticalColor: (val: TStyleValue) => TReturn,
50
+ borderBlockStartColor: (value: TStyleValue) => TReturn,
51
+ borderBlockEndColor: (value: TStyleValue) => TReturn,
52
+ borderBlockStartStyle: (value: TStyleValue) => TReturn,
53
+ borderBlockEndStyle: (value: TStyleValue) => TReturn,
54
+ borderBlockStartWidth: (value: TStyleValue) => TReturn,
55
+ borderBlockEndWidth: (value: TStyleValue) => TReturn,
56
+ borderStartColor: (val: TStyleValue) => TReturn,
57
+ borderEndColor: (val: TStyleValue) => TReturn,
58
+ borderStartStyle: (val: TStyleValue) => TReturn,
59
+ borderEndStyle: (val: TStyleValue) => TReturn,
60
+ borderStartWidth: (val: TStyleValue) => TReturn,
61
+ borderEndWidth: (val: TStyleValue) => TReturn,
62
+ borderTopStartRadius: (value: TStyleValue) => TReturn,
63
+ borderTopEndRadius: (value: TStyleValue) => TReturn,
64
+ borderBottomStartRadius: (value: TStyleValue) => TReturn,
65
+ borderBottomEndRadius: (value: TStyleValue) => TReturn,
66
+ containIntrinsicBlockSize: (value: TStyleValue) => TReturn,
67
+ containIntrinsicInlineSize: (value: TStyleValue) => TReturn,
68
+ marginBlockStart: (value: TStyleValue) => TReturn,
69
+ marginBlockEnd: (value: TStyleValue) => TReturn,
70
+ marginStart: (val: TStyleValue) => TReturn,
71
+ marginEnd: (val: TStyleValue) => TReturn,
72
+ marginHorizontal: (val: TStyleValue) => TReturn,
73
+ marginVertical: (val: TStyleValue) => TReturn,
74
+ overflowBlock: (value: TStyleValue) => TReturn,
75
+ overflowInline: (value: TStyleValue) => TReturn,
76
+ paddingBlockStart: (rawValue: TStyleValue) => TReturn,
77
+ paddingBlockEnd: (rawValue: TStyleValue) => TReturn,
78
+ paddingStart: (val: TStyleValue) => TReturn,
79
+ paddingEnd: (val: TStyleValue) => TReturn,
80
+ paddingHorizontal: (val: TStyleValue) => TReturn,
81
+ paddingVertical: (val: TStyleValue) => TReturn,
82
+ scrollMarginBlockStart: (value: TStyleValue) => TReturn,
83
+ scrollMarginBlockEnd: (value: TStyleValue) => TReturn,
84
+ insetBlockStart: (value: TStyleValue) => TReturn,
85
+ insetBlockEnd: (value: TStyleValue) => TReturn,
86
+ start: (val: TStyleValue) => TReturn,
87
+ end: (val: TStyleValue) => TReturn,
88
+ };
89
+
90
+ declare export default $ReadOnly<{
91
+ ...typeof shorthands,
92
+ ...typeof aliases,
93
+ }>;
@@ -0,0 +1,11 @@
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 type ConstsConfigValue = string | number;
11
+ export type ConstsConfig = Readonly<{ [$$Key$$: string]: ConstsConfigValue }>;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -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
+ * @flow strict
8
+ */
9
+
10
+ export type ConstsConfigValue = string | number;
11
+
12
+ export type ConstsConfig = $ReadOnly<{
13
+ [string]: ConstsConfigValue,
14
+ }>;
@@ -0,0 +1,26 @@
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 styleXCreateTheme(
12
+ themeVars: {
13
+ readonly __varGroupHash__: string;
14
+ readonly [$$Key$$: string]: string;
15
+ },
16
+ variables: {
17
+ readonly [$$Key$$: string]:
18
+ | string
19
+ | { default: string; readonly [$$Key$$: string]: string };
20
+ },
21
+ options?: StyleXOptions,
22
+ ): [
23
+ { $$css: true } & { readonly [$$Key$$: string]: string },
24
+ { [$$Key$$: string]: InjectableStyle },
25
+ ];
26
+ export default styleXCreateTheme;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = styleXCreateTheme;
7
+ var _hash = _interopRequireDefault(require("./hash"));
8
+ var _stylexVarsUtils = require("./stylex-vars-utils");
9
+ var _types = require("./types");
10
+ var _defaultOptions = require("./utils/default-options");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ function styleXCreateTheme(themeVars, variables, options) {
13
+ if (typeof themeVars.__varGroupHash__ !== 'string') {
14
+ throw new Error('Can only override variables theme created with defineVars().');
15
+ }
16
+ const {
17
+ classNamePrefix
18
+ } = {
19
+ ..._defaultOptions.defaultOptions,
20
+ ...options
21
+ };
22
+ const rulesByAtRule = {};
23
+ const sortedKeys = Object.keys(variables).sort();
24
+ for (const key of sortedKeys) {
25
+ const value = (0, _types.isCSSType)(variables[key]) ? variables[key].value : variables[key];
26
+ const nameHash = themeVars[key].slice(6, -1);
27
+ (0, _stylexVarsUtils.collectVarsByAtRule)(key, {
28
+ nameHash,
29
+ value
30
+ }, rulesByAtRule);
31
+ }
32
+ const sortedAtRules = Object.keys(rulesByAtRule).sort((a, b) => a === 'default' ? -1 : b === 'default' ? 1 : a.localeCompare(b));
33
+ const atRulesStringForHash = sortedAtRules.map(atRule => (0, _stylexVarsUtils.wrapWithAtRules)(rulesByAtRule[atRule].join(''), atRule)).join('');
34
+ const overrideClassName = classNamePrefix + (0, _hash.default)(atRulesStringForHash);
35
+ const stylesToInject = {};
36
+ for (const atRule of sortedAtRules) {
37
+ const decls = rulesByAtRule[atRule].join('');
38
+ const rule = `.${overrideClassName}, .${overrideClassName}:root{${decls}}`;
39
+ const priority = 0.4 + (0, _stylexVarsUtils.priorityForAtRule)(atRule) / 10;
40
+ const suffix = atRule === 'default' ? '' : `-${(0, _hash.default)(atRule)}`;
41
+ const ltr = atRule === 'default' ? rule : (0, _stylexVarsUtils.wrapWithAtRules)(rule, atRule);
42
+ stylesToInject[overrideClassName + suffix] = {
43
+ ltr: ltr,
44
+ priority: priority,
45
+ rtl: null
46
+ };
47
+ }
48
+ const themeClass = `${overrideClassName} ${themeVars.__varGroupHash__}`;
49
+ return [{
50
+ [themeVars.__varGroupHash__]: themeClass,
51
+ $$css: true
52
+ }, stylesToInject];
53
+ }
@@ -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 { InjectableStyle, StyleXOptions } from './common-types';
11
+
12
+ // It takes an object of variables with their values and the original set of variables to override
13
+ // and returns a hashed className with variables overrides.
14
+ //
15
+ declare export default function styleXCreateTheme(
16
+ themeVars: { +__varGroupHash__: string, +[string]: string },
17
+ variables: { +[string]: string | { default: string, +[string]: string } },
18
+ options?: StyleXOptions,
19
+ ): [{ $$css: true, +[string]: string }, { [string]: InjectableStyle }];
@@ -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 {
11
+ RawStyles,
12
+ InjectableStyle,
13
+ StyleXOptions,
14
+ FlatCompiledStyles,
15
+ } from './common-types';
16
+ type ClassPathsInNamespace = {
17
+ readonly [className: string]: ReadonlyArray<string>;
18
+ };
19
+ declare function styleXCreateSet(
20
+ namespaces: { readonly [$$Key$$: string]: RawStyles },
21
+ options?: StyleXOptions,
22
+ ): [
23
+ { [$$Key$$: string]: FlatCompiledStyles },
24
+ { [$$Key$$: string]: InjectableStyle },
25
+ { readonly [$$Key$$: string]: ClassPathsInNamespace },
26
+ ];
27
+ export default styleXCreateSet;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = styleXCreateSet;
7
+ var _hash = require("./hash");
8
+ var _defaultOptions = require("./utils/default-options");
9
+ var _flattenRawStyleObj = require("./preprocess-rules/flatten-raw-style-obj");
10
+ var _basicValidation = require("./preprocess-rules/basic-validation");
11
+ function styleXCreateSet(namespaces, options = _defaultOptions.defaultOptions) {
12
+ const resolvedNamespaces = {};
13
+ const injectedStyles = {};
14
+ const namespaceToClassPaths = {};
15
+ for (const namespaceName of Object.keys(namespaces)) {
16
+ const namespace = namespaces[namespaceName];
17
+ const classPathsInNamespace = {};
18
+ (0, _basicValidation.validateNamespace)(namespace);
19
+ const seenProperties = new Set();
20
+ const flattenedNamespace = (0, _flattenRawStyleObj.flattenRawStyleObject)(namespace, options).reduceRight((arr, curr) => {
21
+ if (seenProperties.has(curr[0])) {
22
+ return arr;
23
+ }
24
+ seenProperties.add(curr[0]);
25
+ arr.unshift(curr);
26
+ return arr;
27
+ }, []);
28
+ const compiledNamespaceTuples = flattenedNamespace.map(([key, value]) => {
29
+ if (options.enableMinifiedKeys === true && !key.startsWith('--')) {
30
+ const hashedKey = (0, _hash.createShortHash)('<>' + key);
31
+ const displayKey = options.debug === true ? `${key}-k${hashedKey}` : `k${hashedKey}`;
32
+ return [displayKey, value.compiled(options)];
33
+ } else {
34
+ return [key, value.compiled(options)];
35
+ }
36
+ });
37
+ const namespaceObj = {};
38
+ for (const [key, value] of compiledNamespaceTuples) {
39
+ const classNameTuples = value.map(v => Array.isArray(v) ? v : null).filter(Boolean);
40
+ classNameTuples.forEach(([_className, _, classesToOriginalPath]) => {
41
+ Object.assign(classPathsInNamespace, classesToOriginalPath);
42
+ });
43
+ const classNames = classNameTuples.map(([className]) => className);
44
+ const uniqueClassNames = new Set(classNames);
45
+ const className = Array.from(uniqueClassNames).join(' ');
46
+ namespaceObj[key] = className !== '' ? className : null;
47
+ for (const [className, injectable] of classNameTuples) {
48
+ if (injectedStyles[className] == null) {
49
+ injectedStyles[className] = injectable;
50
+ }
51
+ }
52
+ }
53
+ resolvedNamespaces[namespaceName] = {
54
+ ...namespaceObj,
55
+ $$css: true
56
+ };
57
+ namespaceToClassPaths[namespaceName] = classPathsInNamespace;
58
+ }
59
+ return [resolvedNamespaces, injectedStyles, namespaceToClassPaths];
60
+ }
@@ -0,0 +1,37 @@
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
+ type ClassPathsInNamespace = {
17
+ +[className: string]: $ReadOnlyArray<string>,
18
+ };
19
+
20
+ // This takes the object of styles passed to `stylex.create` and transforms it.
21
+ // The transformation replaces style values with classNames.
22
+ //
23
+ // It also collects all injected styles along the way.
24
+ // It then returns a tuple of the transformed style Object and an object of injected styles.
25
+ //
26
+ // This function does some basic validation, and then uses `styleXCreateNamespace` to transform
27
+ // each namespace within,
28
+ //
29
+ // Before returning, it ensures that there are no duplicate styles being injected.
30
+ declare export default function styleXCreateSet(
31
+ namespaces: { +[string]: RawStyles },
32
+ options?: StyleXOptions,
33
+ ): [
34
+ { [string]: FlatCompiledStyles },
35
+ { [string]: InjectableStyle },
36
+ { +[string]: ClassPathsInNamespace },
37
+ ];