@stylexjs/shared 0.12.0 → 0.17.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 (140) hide show
  1. package/lib/index.d.ts +18 -36
  2. package/lib/index.js +8 -25
  3. package/lib/index.js.flow +10 -43
  4. package/lib/utils/property-priorities.d.ts +7 -0
  5. package/lib/utils/property-priorities.js +54 -8
  6. package/lib/utils/property-priorities.js.flow +8 -0
  7. package/package.json +5 -21
  8. package/README.md +0 -81
  9. package/lib/common-types.d.ts +0 -50
  10. package/lib/common-types.js +0 -1
  11. package/lib/common-types.js.flow +0 -63
  12. package/lib/convert-to-className.d.ts +0 -20
  13. package/lib/convert-to-className.js +0 -66
  14. package/lib/convert-to-className.js.flow +0 -27
  15. package/lib/generate-css-rule.d.ts +0 -17
  16. package/lib/generate-css-rule.js +0 -25
  17. package/lib/generate-css-rule.js.flow +0 -17
  18. package/lib/hash.d.ts +0 -12
  19. package/lib/hash.js +0 -50
  20. package/lib/hash.js.flow +0 -12
  21. package/lib/messages.d.ts +0 -42
  22. package/lib/messages.js +0 -39
  23. package/lib/messages.js.flow +0 -45
  24. package/lib/physical-rtl/generate-ltr.d.ts +0 -13
  25. package/lib/physical-rtl/generate-ltr.js +0 -103
  26. package/lib/physical-rtl/generate-ltr.js.flow +0 -12
  27. package/lib/physical-rtl/generate-rtl.d.ts +0 -13
  28. package/lib/physical-rtl/generate-rtl.js +0 -177
  29. package/lib/physical-rtl/generate-rtl.js.flow +0 -12
  30. package/lib/preprocess-rules/PreRule.d.ts +0 -50
  31. package/lib/preprocess-rules/PreRule.js +0 -76
  32. package/lib/preprocess-rules/PreRule.js.flow +0 -62
  33. package/lib/preprocess-rules/application-order.d.ts +0 -183
  34. package/lib/preprocess-rules/application-order.js +0 -186
  35. package/lib/preprocess-rules/application-order.js.flow +0 -134
  36. package/lib/preprocess-rules/basic-validation.d.ts +0 -13
  37. package/lib/preprocess-rules/basic-validation.js +0 -73
  38. package/lib/preprocess-rules/basic-validation.js.flow +0 -13
  39. package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +0 -20
  40. package/lib/preprocess-rules/flatten-raw-style-obj.js +0 -98
  41. package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +0 -23
  42. package/lib/preprocess-rules/index.d.ts +0 -18
  43. package/lib/preprocess-rules/index.js +0 -33
  44. package/lib/preprocess-rules/index.js.flow +0 -22
  45. package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +0 -165
  46. package/lib/preprocess-rules/legacy-expand-shorthands.js +0 -147
  47. package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +0 -144
  48. package/lib/preprocess-rules/property-specificity.d.ts +0 -78
  49. package/lib/preprocess-rules/property-specificity.js +0 -107
  50. package/lib/preprocess-rules/property-specificity.js.flow +0 -87
  51. package/lib/stylex-consts-utils.d.ts +0 -11
  52. package/lib/stylex-consts-utils.js +0 -1
  53. package/lib/stylex-consts-utils.js.flow +0 -14
  54. package/lib/stylex-create-theme.d.ts +0 -26
  55. package/lib/stylex-create-theme.js +0 -58
  56. package/lib/stylex-create-theme.js.flow +0 -19
  57. package/lib/stylex-create.d.ts +0 -27
  58. package/lib/stylex-create.js +0 -64
  59. package/lib/stylex-create.js.flow +0 -37
  60. package/lib/stylex-define-consts.d.ts +0 -23
  61. package/lib/stylex-define-consts.js +0 -42
  62. package/lib/stylex-define-consts.js.flow +0 -18
  63. package/lib/stylex-define-vars.d.ts +0 -28
  64. package/lib/stylex-define-vars.js +0 -96
  65. package/lib/stylex-define-vars.js.flow +0 -27
  66. package/lib/stylex-first-that-works.d.ts +0 -13
  67. package/lib/stylex-first-that-works.js +0 -26
  68. package/lib/stylex-first-that-works.js.flow +0 -12
  69. package/lib/stylex-include.d.ts +0 -18
  70. package/lib/stylex-include.js +0 -28
  71. package/lib/stylex-include.js.flow +0 -20
  72. package/lib/stylex-keyframes.d.ts +0 -17
  73. package/lib/stylex-keyframes.js +0 -55
  74. package/lib/stylex-keyframes.js.flow +0 -20
  75. package/lib/stylex-vars-utils.d.ts +0 -27
  76. package/lib/stylex-vars-utils.js +0 -69
  77. package/lib/stylex-vars-utils.js.flow +0 -31
  78. package/lib/transform-value.d.ts +0 -22
  79. package/lib/transform-value.js +0 -50
  80. package/lib/transform-value.js.flow +0 -25
  81. package/lib/types/index.d.ts +0 -240
  82. package/lib/types/index.js +0 -147
  83. package/lib/types/index.js.flow +0 -280
  84. package/lib/utils/Rule.d.ts +0 -58
  85. package/lib/utils/Rule.js +0 -50
  86. package/lib/utils/Rule.js.flow +0 -64
  87. package/lib/utils/dashify.d.ts +0 -11
  88. package/lib/utils/dashify.js +0 -9
  89. package/lib/utils/dashify.js.flow +0 -10
  90. package/lib/utils/default-options.d.ts +0 -11
  91. package/lib/utils/default-options.js +0 -17
  92. package/lib/utils/default-options.js.flow +0 -12
  93. package/lib/utils/file-based-identifier.d.ts +0 -15
  94. package/lib/utils/file-based-identifier.js +0 -14
  95. package/lib/utils/file-based-identifier.js.flow +0 -14
  96. package/lib/utils/genCSSRule.d.ts +0 -15
  97. package/lib/utils/genCSSRule.js +0 -15
  98. package/lib/utils/genCSSRule.js.flow +0 -15
  99. package/lib/utils/media-query-transform.d.ts +0 -16
  100. package/lib/utils/media-query-transform.js +0 -53
  101. package/lib/utils/media-query-transform.js.flow +0 -20
  102. package/lib/utils/normalize-value.d.ts +0 -16
  103. package/lib/utils/normalize-value.js +0 -28
  104. package/lib/utils/normalize-value.js.flow +0 -16
  105. package/lib/utils/normalizers/convert-camel-case-values.d.ts +0 -14
  106. package/lib/utils/normalizers/convert-camel-case-values.js +0 -23
  107. package/lib/utils/normalizers/convert-camel-case-values.js.flow +0 -13
  108. package/lib/utils/normalizers/detect-unclosed-fns.d.ts +0 -17
  109. package/lib/utils/normalizers/detect-unclosed-fns.js +0 -17
  110. package/lib/utils/normalizers/detect-unclosed-fns.js.flow +0 -16
  111. package/lib/utils/normalizers/font-size-px-to-rem.d.ts +0 -19
  112. package/lib/utils/normalizers/font-size-px-to-rem.js +0 -24
  113. package/lib/utils/normalizers/font-size-px-to-rem.js.flow +0 -18
  114. package/lib/utils/normalizers/leading-zero.d.ts +0 -17
  115. package/lib/utils/normalizers/leading-zero.js +0 -24
  116. package/lib/utils/normalizers/leading-zero.js.flow +0 -16
  117. package/lib/utils/normalizers/quotes.d.ts +0 -18
  118. package/lib/utils/normalizers/quotes.js +0 -17
  119. package/lib/utils/normalizers/quotes.js.flow +0 -17
  120. package/lib/utils/normalizers/timings.d.ts +0 -18
  121. package/lib/utils/normalizers/timings.js +0 -25
  122. package/lib/utils/normalizers/timings.js.flow +0 -17
  123. package/lib/utils/normalizers/whitespace.d.ts +0 -19
  124. package/lib/utils/normalizers/whitespace.js +0 -54
  125. package/lib/utils/normalizers/whitespace.js.flow +0 -18
  126. package/lib/utils/normalizers/zero-dimensions.d.ts +0 -19
  127. package/lib/utils/normalizers/zero-dimensions.js +0 -42
  128. package/lib/utils/normalizers/zero-dimensions.js.flow +0 -18
  129. package/lib/utils/object-utils.d.ts +0 -66
  130. package/lib/utils/object-utils.js +0 -99
  131. package/lib/utils/object-utils.js.flow +0 -78
  132. package/lib/utils/rule-utils.d.ts +0 -15
  133. package/lib/utils/rule-utils.js +0 -41
  134. package/lib/utils/rule-utils.js.flow +0 -16
  135. package/lib/utils/split-css-value.d.ts +0 -14
  136. package/lib/utils/split-css-value.js +0 -33
  137. package/lib/utils/split-css-value.js.flow +0 -15
  138. package/lib/validate.d.ts +0 -12
  139. package/lib/validate.js +0 -21
  140. package/lib/validate.js.flow +0 -12
@@ -1,144 +0,0 @@
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: $ReadOnly<{
85
- [key: string]: (TStyleValue) => TReturn,
86
- }>;
87
-
88
- declare const aliases: {
89
- insetBlockStart: (val: TStyleValue) => TReturn,
90
- insetBlockEnd: (val: TStyleValue) => TReturn,
91
- insetInlineStart: $FlowFixMe,
92
- insetInlineEnd: $FlowFixMe,
93
- blockSize: (val: TStyleValue) => TReturn,
94
- inlineSize: (val: TStyleValue) => TReturn,
95
- minBlockSize: (val: TStyleValue) => TReturn,
96
- minInlineSize: (val: TStyleValue) => TReturn,
97
- maxBlockSize: (val: TStyleValue) => TReturn,
98
- maxInlineSize: (val: TStyleValue) => TReturn,
99
- borderBlockWidth: $FlowFixMe,
100
- borderBlockStyle: $FlowFixMe,
101
- borderBlockColor: $FlowFixMe,
102
- borderBlockStartWidth: (val: TStyleValue) => TReturn,
103
- borderBlockStartStyle: (val: TStyleValue) => TReturn,
104
- borderBlockStartColor: (val: TStyleValue) => TReturn,
105
- borderBlockEndWidth: (val: TStyleValue) => TReturn,
106
- borderBlockEndStyle: (val: TStyleValue) => TReturn,
107
- borderBlockEndColor: (val: TStyleValue) => TReturn,
108
- borderInlineWidth: $FlowFixMe,
109
- borderInlineStyle: $FlowFixMe,
110
- borderInlineColor: $FlowFixMe,
111
- borderInlineStartWidth: (val: TStyleValue) => TReturn,
112
- borderInlineStartStyle: (val: TStyleValue) => TReturn,
113
- borderInlineStartColor: (val: TStyleValue) => TReturn,
114
- borderInlineEndWidth: (val: TStyleValue) => TReturn,
115
- borderInlineEndStyle: (val: TStyleValue) => TReturn,
116
- borderInlineEndColor: (val: TStyleValue) => TReturn,
117
- borderStartStartRadius: (val: TStyleValue) => TReturn,
118
- borderStartEndRadius: (val: TStyleValue) => TReturn,
119
- borderEndStartRadius: (val: TStyleValue) => TReturn,
120
- borderEndEndRadius: (val: TStyleValue) => TReturn,
121
- gridGap: $FlowFixMe,
122
- gridRowGap: (value: TStyleValue) => TReturn,
123
- gridColumnGap: (value: TStyleValue) => TReturn,
124
- marginBlock: $FlowFixMe,
125
- marginBlockStart: (val: TStyleValue) => TReturn,
126
- marginBlockEnd: (val: TStyleValue) => TReturn,
127
- marginInline: $FlowFixMe,
128
- marginInlineStart: (val: TStyleValue) => TReturn,
129
- marginInlineEnd: (val: TStyleValue) => TReturn,
130
- overflowBlock: (value: TStyleValue) => TReturn,
131
- overflowInline: (value: TStyleValue) => TReturn,
132
- paddingBlock: $FlowFixMe,
133
- paddingBlockStart: (val: TStyleValue) => TReturn,
134
- paddingBlockEnd: (val: TStyleValue) => TReturn,
135
- paddingInline: $FlowFixMe,
136
- paddingInlineStart: (val: TStyleValue) => TReturn,
137
- paddingInlineEnd: (val: TStyleValue) => TReturn,
138
- scrollMarginBlockStart: (value: TStyleValue) => TReturn,
139
- scrollMarginBlockEnd: (value: TStyleValue) => TReturn,
140
- };
141
-
142
- declare const expansions: { ...shorthands, ...aliases };
143
-
144
- declare export default typeof expansions;
@@ -1,78 +0,0 @@
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: any;
17
- borderVertical: any;
18
- borderBlockStart: any;
19
- borderEnd: any;
20
- borderBlockEnd: any;
21
- borderStart: any;
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
- * > 85 | ...typeof shorthands,
75
- * | ^^^^^^^^^^^^^^^^^^^^ Unsupported feature: Translating "object types with complex spreads" is currently not supported.
76
- **/
77
- any>;
78
- export default $$EXPORT_DEFAULT_DECLARATION$$;
@@ -1,107 +0,0 @@
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;
@@ -1,87 +0,0 @@
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
- borderHorizontal: $FlowFixMe,
27
- borderVertical: $FlowFixMe,
28
- borderBlockStart: $FlowFixMe,
29
- borderEnd: $FlowFixMe,
30
- borderBlockEnd: $FlowFixMe,
31
- borderStart: $FlowFixMe,
32
- blockSize: (val: TStyleValue) => TReturn,
33
- inlineSize: (val: TStyleValue) => TReturn,
34
- minBlockSize: (val: TStyleValue) => TReturn,
35
- minInlineSize: (val: TStyleValue) => TReturn,
36
- maxBlockSize: (val: TStyleValue) => TReturn,
37
- maxInlineSize: (val: TStyleValue) => TReturn,
38
- borderHorizontalWidth: (val: TStyleValue) => TReturn,
39
- borderHorizontalStyle: (val: TStyleValue) => TReturn,
40
- borderHorizontalColor: (val: TStyleValue) => TReturn,
41
- borderVerticalWidth: (val: TStyleValue) => TReturn,
42
- borderVerticalStyle: (val: TStyleValue) => TReturn,
43
- borderVerticalColor: (val: TStyleValue) => TReturn,
44
- borderBlockStartColor: (value: TStyleValue) => TReturn,
45
- borderBlockEndColor: (value: TStyleValue) => TReturn,
46
- borderBlockStartStyle: (value: TStyleValue) => TReturn,
47
- borderBlockEndStyle: (value: TStyleValue) => TReturn,
48
- borderBlockStartWidth: (value: TStyleValue) => TReturn,
49
- borderBlockEndWidth: (value: TStyleValue) => TReturn,
50
- borderStartColor: (val: TStyleValue) => TReturn,
51
- borderEndColor: (val: TStyleValue) => TReturn,
52
- borderStartStyle: (val: TStyleValue) => TReturn,
53
- borderEndStyle: (val: TStyleValue) => TReturn,
54
- borderStartWidth: (val: TStyleValue) => TReturn,
55
- borderEndWidth: (val: TStyleValue) => TReturn,
56
- borderTopStartRadius: (value: TStyleValue) => TReturn,
57
- borderTopEndRadius: (value: TStyleValue) => TReturn,
58
- borderBottomStartRadius: (value: TStyleValue) => TReturn,
59
- borderBottomEndRadius: (value: TStyleValue) => TReturn,
60
- containIntrinsicBlockSize: (value: TStyleValue) => TReturn,
61
- containIntrinsicInlineSize: (value: TStyleValue) => TReturn,
62
- marginBlockStart: (value: TStyleValue) => TReturn,
63
- marginBlockEnd: (value: TStyleValue) => TReturn,
64
- marginStart: (val: TStyleValue) => TReturn,
65
- marginEnd: (val: TStyleValue) => TReturn,
66
- marginHorizontal: (val: TStyleValue) => TReturn,
67
- marginVertical: (val: TStyleValue) => TReturn,
68
- overflowBlock: (value: TStyleValue) => TReturn,
69
- overflowInline: (value: TStyleValue) => TReturn,
70
- paddingBlockStart: (rawValue: TStyleValue) => TReturn,
71
- paddingBlockEnd: (rawValue: TStyleValue) => TReturn,
72
- paddingStart: (val: TStyleValue) => TReturn,
73
- paddingEnd: (val: TStyleValue) => TReturn,
74
- paddingHorizontal: (val: TStyleValue) => TReturn,
75
- paddingVertical: (val: TStyleValue) => TReturn,
76
- scrollMarginBlockStart: (value: TStyleValue) => TReturn,
77
- scrollMarginBlockEnd: (value: TStyleValue) => TReturn,
78
- insetBlockStart: (value: TStyleValue) => TReturn,
79
- insetBlockEnd: (value: TStyleValue) => TReturn,
80
- start: (val: TStyleValue) => TReturn,
81
- end: (val: TStyleValue) => TReturn,
82
- };
83
-
84
- declare export default $ReadOnly<{
85
- ...typeof shorthands,
86
- ...typeof aliases,
87
- }>;
@@ -1,11 +0,0 @@
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 }>;
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,14 +0,0 @@
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
- }>;
@@ -1,26 +0,0 @@
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 __themeName__: 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;
@@ -1,58 +0,0 @@
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.__themeName__ !== 'string') {
14
- throw new Error('Can only override variables theme created with stylex.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
- if (atRule === 'default') {
40
- stylesToInject[overrideClassName] = {
41
- ltr: rule,
42
- priority: 0.5,
43
- rtl: null
44
- };
45
- } else {
46
- stylesToInject[overrideClassName + '-' + (0, _hash.default)(atRule)] = {
47
- ltr: (0, _stylexVarsUtils.wrapWithAtRules)(rule, atRule),
48
- priority: 0.5 + 0.1 * (0, _stylexVarsUtils.priorityForAtRule)(atRule),
49
- rtl: null
50
- };
51
- }
52
- }
53
- const themeClass = `${overrideClassName} ${themeVars.__themeName__}`;
54
- return [{
55
- $$css: true,
56
- [themeVars.__themeName__]: themeClass
57
- }, stylesToInject];
58
- }
@@ -1,19 +0,0 @@
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: { +__themeName__: string, +[string]: string },
17
- variables: { +[string]: string | { default: string, +[string]: string } },
18
- options?: StyleXOptions,
19
- ): [{ $$css: true, +[string]: string }, { [string]: InjectableStyle }];
@@ -1,27 +0,0 @@
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;
@@ -1,64 +0,0 @@
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) {
12
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _defaultOptions.defaultOptions;
13
- const resolvedNamespaces = {};
14
- const injectedStyles = {};
15
- const namespaceToClassPaths = {};
16
- for (const namespaceName of Object.keys(namespaces)) {
17
- const namespace = namespaces[namespaceName];
18
- const classPathsInNamespace = {};
19
- (0, _basicValidation.validateNamespace)(namespace);
20
- const seenProperties = new Set();
21
- const flattenedNamespace = (0, _flattenRawStyleObj.flattenRawStyleObject)(namespace, options).reduceRight((arr, curr) => {
22
- if (seenProperties.has(curr[0])) {
23
- return arr;
24
- }
25
- seenProperties.add(curr[0]);
26
- arr.unshift(curr);
27
- return arr;
28
- }, []);
29
- const compiledNamespaceTuples = flattenedNamespace.map(_ref => {
30
- let [key, value] = _ref;
31
- if (options.enableMinifiedKeys === true && !key.startsWith('--')) {
32
- const hashedKey = (0, _hash.createShortHash)('<>' + key);
33
- const displayKey = options.debug === true ? `${key}-k${hashedKey}` : `k${hashedKey}`;
34
- return [displayKey, value.compiled(options)];
35
- } else {
36
- return [key, value.compiled(options)];
37
- }
38
- });
39
- const namespaceObj = {};
40
- for (const [key, value] of compiledNamespaceTuples) {
41
- const classNameTuples = value.map(v => Array.isArray(v) ? v : null).filter(Boolean);
42
- classNameTuples.forEach(_ref2 => {
43
- let [_className, _, classesToOriginalPath] = _ref2;
44
- Object.assign(classPathsInNamespace, classesToOriginalPath);
45
- });
46
- const className = classNameTuples.map(_ref3 => {
47
- let [className] = _ref3;
48
- return className;
49
- }).join(' ') || null;
50
- namespaceObj[key] = className;
51
- for (const [className, injectable] of classNameTuples) {
52
- if (injectedStyles[className] == null) {
53
- injectedStyles[className] = injectable;
54
- }
55
- }
56
- }
57
- resolvedNamespaces[namespaceName] = {
58
- ...namespaceObj,
59
- $$css: true
60
- };
61
- namespaceToClassPaths[namespaceName] = classPathsInNamespace;
62
- }
63
- return [resolvedNamespaces, injectedStyles, namespaceToClassPaths];
64
- }