@react-spectrum/s2 3.0.0-nightly-5ae234603-240925 → 3.0.0-nightly-a626c2596-240926

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 (232) hide show
  1. package/dist/Button.cjs +5 -1
  2. package/dist/Button.cjs.map +1 -1
  3. package/dist/Button.css.map +1 -1
  4. package/dist/Button.mjs +5 -1
  5. package/dist/Button.mjs.map +1 -1
  6. package/dist/Card.cjs +1 -1
  7. package/dist/Card.cjs.map +1 -1
  8. package/dist/Card.css.map +1 -1
  9. package/dist/Card.mjs +1 -1
  10. package/dist/Card.mjs.map +1 -1
  11. package/dist/Checkbox.cjs +4 -1
  12. package/dist/Checkbox.cjs.map +1 -1
  13. package/dist/Checkbox.css +4 -0
  14. package/dist/Checkbox.css.map +1 -1
  15. package/dist/Checkbox.mjs +4 -1
  16. package/dist/Checkbox.mjs.map +1 -1
  17. package/dist/ComboBox.cjs +3 -0
  18. package/dist/ComboBox.cjs.map +1 -1
  19. package/dist/ComboBox.css.map +1 -1
  20. package/dist/ComboBox.mjs +3 -0
  21. package/dist/ComboBox.mjs.map +1 -1
  22. package/dist/Content.cjs +0 -2
  23. package/dist/Content.cjs.map +1 -1
  24. package/dist/Content.mjs +1 -2
  25. package/dist/Content.mjs.map +1 -1
  26. package/dist/Dialog.cjs +7 -5
  27. package/dist/Dialog.cjs.map +1 -1
  28. package/dist/Dialog.css.map +1 -1
  29. package/dist/Dialog.mjs +8 -6
  30. package/dist/Dialog.mjs.map +1 -1
  31. package/dist/MoveHorizontalCircleTableWidget.cjs +33 -0
  32. package/dist/MoveHorizontalCircleTableWidget.cjs.map +1 -0
  33. package/dist/MoveHorizontalCircleTableWidget.mjs +28 -0
  34. package/dist/MoveHorizontalCircleTableWidget.mjs.map +1 -0
  35. package/dist/Picker.cjs +3 -0
  36. package/dist/Picker.cjs.map +1 -1
  37. package/dist/Picker.css.map +1 -1
  38. package/dist/Picker.mjs +3 -0
  39. package/dist/Picker.mjs.map +1 -1
  40. package/dist/Popover.cjs +1 -0
  41. package/dist/Popover.cjs.map +1 -1
  42. package/dist/Popover.css +4 -0
  43. package/dist/Popover.css.map +1 -1
  44. package/dist/Popover.mjs +1 -0
  45. package/dist/Popover.mjs.map +1 -1
  46. package/dist/Table.cjs +1093 -0
  47. package/dist/Table.cjs.map +1 -0
  48. package/dist/Table.css +821 -0
  49. package/dist/Table.css.map +1 -0
  50. package/dist/Table.mjs +1083 -0
  51. package/dist/Table.mjs.map +1 -0
  52. package/dist/TagGroup.cjs +5 -3
  53. package/dist/TagGroup.cjs.map +1 -1
  54. package/dist/TagGroup.css.map +1 -1
  55. package/dist/TagGroup.mjs +5 -3
  56. package/dist/TagGroup.mjs.map +1 -1
  57. package/dist/ar-AE.cjs +5 -0
  58. package/dist/ar-AE.cjs.map +1 -1
  59. package/dist/ar-AE.mjs +5 -0
  60. package/dist/ar-AE.mjs.map +1 -1
  61. package/dist/bg-BG.cjs +5 -0
  62. package/dist/bg-BG.cjs.map +1 -1
  63. package/dist/bg-BG.mjs +5 -0
  64. package/dist/bg-BG.mjs.map +1 -1
  65. package/dist/cs-CZ.cjs +5 -0
  66. package/dist/cs-CZ.cjs.map +1 -1
  67. package/dist/cs-CZ.mjs +5 -0
  68. package/dist/cs-CZ.mjs.map +1 -1
  69. package/dist/da-DK.cjs +5 -0
  70. package/dist/da-DK.cjs.map +1 -1
  71. package/dist/da-DK.mjs +5 -0
  72. package/dist/da-DK.mjs.map +1 -1
  73. package/dist/de-DE.cjs +5 -0
  74. package/dist/de-DE.cjs.map +1 -1
  75. package/dist/de-DE.mjs +5 -0
  76. package/dist/de-DE.mjs.map +1 -1
  77. package/dist/el-GR.cjs +5 -0
  78. package/dist/el-GR.cjs.map +1 -1
  79. package/dist/el-GR.mjs +5 -0
  80. package/dist/el-GR.mjs.map +1 -1
  81. package/dist/en-US.cjs +5 -0
  82. package/dist/en-US.cjs.map +1 -1
  83. package/dist/en-US.mjs +5 -0
  84. package/dist/en-US.mjs.map +1 -1
  85. package/dist/es-ES.cjs +5 -0
  86. package/dist/es-ES.cjs.map +1 -1
  87. package/dist/es-ES.mjs +5 -0
  88. package/dist/es-ES.mjs.map +1 -1
  89. package/dist/et-EE.cjs +5 -0
  90. package/dist/et-EE.cjs.map +1 -1
  91. package/dist/et-EE.mjs +5 -0
  92. package/dist/et-EE.mjs.map +1 -1
  93. package/dist/fi-FI.cjs +5 -0
  94. package/dist/fi-FI.cjs.map +1 -1
  95. package/dist/fi-FI.mjs +5 -0
  96. package/dist/fi-FI.mjs.map +1 -1
  97. package/dist/fr-FR.cjs +5 -0
  98. package/dist/fr-FR.cjs.map +1 -1
  99. package/dist/fr-FR.mjs +5 -0
  100. package/dist/fr-FR.mjs.map +1 -1
  101. package/dist/he-IL.cjs +5 -0
  102. package/dist/he-IL.cjs.map +1 -1
  103. package/dist/he-IL.mjs +5 -0
  104. package/dist/he-IL.mjs.map +1 -1
  105. package/dist/hr-HR.cjs +5 -0
  106. package/dist/hr-HR.cjs.map +1 -1
  107. package/dist/hr-HR.mjs +5 -0
  108. package/dist/hr-HR.mjs.map +1 -1
  109. package/dist/hu-HU.cjs +5 -0
  110. package/dist/hu-HU.cjs.map +1 -1
  111. package/dist/hu-HU.mjs +5 -0
  112. package/dist/hu-HU.mjs.map +1 -1
  113. package/dist/it-IT.cjs +5 -0
  114. package/dist/it-IT.cjs.map +1 -1
  115. package/dist/it-IT.mjs +5 -0
  116. package/dist/it-IT.mjs.map +1 -1
  117. package/dist/ja-JP.cjs +5 -0
  118. package/dist/ja-JP.cjs.map +1 -1
  119. package/dist/ja-JP.mjs +5 -0
  120. package/dist/ja-JP.mjs.map +1 -1
  121. package/dist/ko-KR.cjs +5 -0
  122. package/dist/ko-KR.cjs.map +1 -1
  123. package/dist/ko-KR.mjs +5 -0
  124. package/dist/ko-KR.mjs.map +1 -1
  125. package/dist/lt-LT.cjs +5 -0
  126. package/dist/lt-LT.cjs.map +1 -1
  127. package/dist/lt-LT.mjs +5 -0
  128. package/dist/lt-LT.mjs.map +1 -1
  129. package/dist/lv-LV.cjs +5 -0
  130. package/dist/lv-LV.cjs.map +1 -1
  131. package/dist/lv-LV.mjs +5 -0
  132. package/dist/lv-LV.mjs.map +1 -1
  133. package/dist/main.cjs +8 -0
  134. package/dist/main.cjs.map +1 -1
  135. package/dist/module.mjs +3 -1
  136. package/dist/module.mjs.map +1 -1
  137. package/dist/nb-NO.cjs +5 -0
  138. package/dist/nb-NO.cjs.map +1 -1
  139. package/dist/nb-NO.mjs +5 -0
  140. package/dist/nb-NO.mjs.map +1 -1
  141. package/dist/nl-NL.cjs +5 -0
  142. package/dist/nl-NL.cjs.map +1 -1
  143. package/dist/nl-NL.mjs +5 -0
  144. package/dist/nl-NL.mjs.map +1 -1
  145. package/dist/pl-PL.cjs +5 -0
  146. package/dist/pl-PL.cjs.map +1 -1
  147. package/dist/pl-PL.mjs +5 -0
  148. package/dist/pl-PL.mjs.map +1 -1
  149. package/dist/pt-BR.cjs +5 -0
  150. package/dist/pt-BR.cjs.map +1 -1
  151. package/dist/pt-BR.mjs +5 -0
  152. package/dist/pt-BR.mjs.map +1 -1
  153. package/dist/pt-PT.cjs +5 -0
  154. package/dist/pt-PT.cjs.map +1 -1
  155. package/dist/pt-PT.mjs +5 -0
  156. package/dist/pt-PT.mjs.map +1 -1
  157. package/dist/ro-RO.cjs +5 -0
  158. package/dist/ro-RO.cjs.map +1 -1
  159. package/dist/ro-RO.mjs +5 -0
  160. package/dist/ro-RO.mjs.map +1 -1
  161. package/dist/ru-RU.cjs +5 -0
  162. package/dist/ru-RU.cjs.map +1 -1
  163. package/dist/ru-RU.mjs +5 -0
  164. package/dist/ru-RU.mjs.map +1 -1
  165. package/dist/sk-SK.cjs +5 -0
  166. package/dist/sk-SK.cjs.map +1 -1
  167. package/dist/sk-SK.mjs +5 -0
  168. package/dist/sk-SK.mjs.map +1 -1
  169. package/dist/sl-SI.cjs +5 -0
  170. package/dist/sl-SI.cjs.map +1 -1
  171. package/dist/sl-SI.mjs +5 -0
  172. package/dist/sl-SI.mjs.map +1 -1
  173. package/dist/sr-SP.cjs +5 -0
  174. package/dist/sr-SP.cjs.map +1 -1
  175. package/dist/sr-SP.mjs +5 -0
  176. package/dist/sr-SP.mjs.map +1 -1
  177. package/dist/sv-SE.cjs +5 -0
  178. package/dist/sv-SE.cjs.map +1 -1
  179. package/dist/sv-SE.mjs +5 -0
  180. package/dist/sv-SE.mjs.map +1 -1
  181. package/dist/tr-TR.cjs +5 -0
  182. package/dist/tr-TR.cjs.map +1 -1
  183. package/dist/tr-TR.mjs +5 -0
  184. package/dist/tr-TR.mjs.map +1 -1
  185. package/dist/types.d.ts +90 -1
  186. package/dist/types.d.ts.map +1 -1
  187. package/dist/uk-UA.cjs +5 -0
  188. package/dist/uk-UA.cjs.map +1 -1
  189. package/dist/uk-UA.mjs +5 -0
  190. package/dist/uk-UA.mjs.map +1 -1
  191. package/dist/utils.cjs +30 -0
  192. package/dist/utils.cjs.map +1 -0
  193. package/dist/utils.mjs +25 -0
  194. package/dist/utils.mjs.map +1 -0
  195. package/dist/zh-CN.cjs +5 -0
  196. package/dist/zh-CN.cjs.map +1 -1
  197. package/dist/zh-CN.mjs +5 -0
  198. package/dist/zh-CN.mjs.map +1 -1
  199. package/dist/zh-TW.cjs +5 -0
  200. package/dist/zh-TW.cjs.map +1 -1
  201. package/dist/zh-TW.mjs +5 -0
  202. package/dist/zh-TW.mjs.map +1 -1
  203. package/package.json +18 -16
  204. package/src/Button.tsx +22 -14
  205. package/src/Card.tsx +1 -1
  206. package/src/Checkbox.tsx +1 -0
  207. package/src/ComboBox.tsx +3 -0
  208. package/src/Content.tsx +1 -3
  209. package/src/Dialog.tsx +3 -2
  210. package/src/Picker.tsx +3 -0
  211. package/src/Popover.tsx +4 -1
  212. package/src/Table.tsx +1084 -48
  213. package/src/TagGroup.tsx +3 -2
  214. package/src/index.ts +2 -0
  215. package/src/utils.ts +28 -0
  216. package/style/__tests__/mergeStyles.test.js +32 -0
  217. package/style/__tests__/style-macro.test.js +128 -0
  218. package/style/dist/main.cjs +1984 -0
  219. package/style/dist/main.cjs.map +1 -0
  220. package/style/dist/module.mjs +1973 -0
  221. package/style/dist/module.mjs.map +1 -0
  222. package/style/dist/style-macro.cjs +543 -0
  223. package/style/dist/style-macro.cjs.map +1 -0
  224. package/style/dist/style-macro.mjs +534 -0
  225. package/style/dist/style-macro.mjs.map +1 -0
  226. package/style/dist/types.d.ts +780 -0
  227. package/style/dist/types.d.ts.map +1 -0
  228. package/style/runtime.ts +103 -0
  229. package/style/spectrum-theme.ts +974 -0
  230. package/style/style-macro.ts +638 -0
  231. package/style/tokens.ts +68 -0
  232. package/style/types.ts +177 -0
@@ -0,0 +1,534 @@
1
+ /*
2
+ * Copyright 2024 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ let $a42cf657cdea7060$var$defaultArbitraryProperty = (value, property)=>({
12
+ [property]: value
13
+ });
14
+ function $a42cf657cdea7060$export$e33e260cb0fb20f7(fn = $a42cf657cdea7060$var$defaultArbitraryProperty) {
15
+ return (value, property)=>{
16
+ let selector = Array.isArray(value) ? $a42cf657cdea7060$var$generateArbitraryValueSelector(value.map((v)=>String(v)).join('')) : $a42cf657cdea7060$var$generateArbitraryValueSelector(String(value));
17
+ return {
18
+ default: [
19
+ fn(value, property),
20
+ selector
21
+ ]
22
+ };
23
+ };
24
+ }
25
+ function $a42cf657cdea7060$var$recursiveValues(obj) {
26
+ return Object.values(obj).flatMap((v)=>typeof v === 'object' ? $a42cf657cdea7060$var$recursiveValues(v) : [
27
+ v
28
+ ]);
29
+ }
30
+ function $a42cf657cdea7060$export$40f4ff17b27355ab(fn, values) {
31
+ let valueMap = $a42cf657cdea7060$var$createValueLookup(Array.isArray(values) ? values : $a42cf657cdea7060$var$recursiveValues(values));
32
+ return (value, property)=>{
33
+ let v = $a42cf657cdea7060$var$parseArbitraryValue(value);
34
+ if (v) return {
35
+ default: [
36
+ fn(v[0], property),
37
+ v[1]
38
+ ]
39
+ };
40
+ // @ts-ignore
41
+ let val = Array.isArray(values) ? value : values[String(value)];
42
+ return $a42cf657cdea7060$var$mapConditionalValue(val, (value)=>{
43
+ return [
44
+ fn(value, property),
45
+ valueMap.get(value)
46
+ ];
47
+ });
48
+ };
49
+ }
50
+ function $a42cf657cdea7060$export$7fdf8c7af26ba416(name, values) {
51
+ return $a42cf657cdea7060$export$40f4ff17b27355ab((value, property)=>({
52
+ [property.startsWith('--') ? property : name]: value
53
+ }), values);
54
+ }
55
+ function $a42cf657cdea7060$export$852145629bb0d58b(colors, property) {
56
+ let valueMap = $a42cf657cdea7060$var$createValueLookup(Object.values(colors).flatMap((v)=>typeof v === 'object' ? Object.values(v) : [
57
+ v
58
+ ]));
59
+ return (value, key)=>{
60
+ let v = $a42cf657cdea7060$var$parseArbitraryValue(value);
61
+ if (v) return {
62
+ default: [
63
+ {
64
+ [property || key]: v[0]
65
+ },
66
+ v[1]
67
+ ]
68
+ };
69
+ let [color, opacity] = value.split('/');
70
+ // @ts-ignore
71
+ let c = colors[color];
72
+ return $a42cf657cdea7060$var$mapConditionalValue(c, (value)=>{
73
+ let css = opacity ? `rgb(from ${value} r g b / ${opacity}%)` : value;
74
+ let selector = valueMap.get(value) + (opacity ? opacity.replace('.', '-') : '');
75
+ return [
76
+ {
77
+ [property || key]: css
78
+ },
79
+ selector
80
+ ];
81
+ });
82
+ };
83
+ }
84
+ function $a42cf657cdea7060$var$mapConditionalValue(value, fn) {
85
+ if (typeof value === 'object') {
86
+ let res = {};
87
+ for(let condition in value)res[condition] = $a42cf657cdea7060$var$mapConditionalValue(value[condition], fn);
88
+ return res;
89
+ } else return fn(value);
90
+ }
91
+ function $a42cf657cdea7060$var$mapConditionalShorthand(value, fn) {
92
+ if (typeof value === 'object') {
93
+ let res = {};
94
+ for(let condition in value){
95
+ let properties = $a42cf657cdea7060$var$mapConditionalShorthand(value[condition], fn);
96
+ for(let property in properties){
97
+ res[property] ??= {};
98
+ res[property][condition] = properties[property];
99
+ }
100
+ }
101
+ return res;
102
+ } else return fn(value);
103
+ }
104
+ function $a42cf657cdea7060$var$createValueLookup(values, atStart = false) {
105
+ let map = new Map();
106
+ for (let value of values)if (!map.has(value)) map.set(value, $a42cf657cdea7060$var$generateName(map.size, atStart));
107
+ return map;
108
+ }
109
+ function $a42cf657cdea7060$var$parseArbitraryValue(value) {
110
+ if (typeof value === 'string' && value.startsWith('--')) return [
111
+ `var(${value})`,
112
+ $a42cf657cdea7060$var$generateArbitraryValueSelector(value)
113
+ ];
114
+ else if (typeof value === 'string' && value[0] === '[' && value[value.length - 1] === ']') {
115
+ let s = $a42cf657cdea7060$var$generateArbitraryValueSelector(value.slice(1, -1));
116
+ return [
117
+ value.slice(1, -1),
118
+ s
119
+ ];
120
+ }
121
+ }
122
+ function $a42cf657cdea7060$export$25d302a5b900a763(theme) {
123
+ let themePropertyMap = $a42cf657cdea7060$var$createValueLookup(Object.keys(theme.properties), true);
124
+ let themeConditionMap = $a42cf657cdea7060$var$createValueLookup(Object.keys(theme.conditions), true);
125
+ let propertyFunctions = new Map(Object.entries(theme.properties).map(([k, v])=>{
126
+ if (typeof v === 'function') return [
127
+ k,
128
+ v
129
+ ];
130
+ return [
131
+ k,
132
+ $a42cf657cdea7060$export$40f4ff17b27355ab((value, p)=>({
133
+ [p]: value
134
+ }), v)
135
+ ];
136
+ }));
137
+ let dependencies = new Set();
138
+ let hasConditions = false;
139
+ return function style(style, allowedOverrides) {
140
+ // Check if `this` is undefined, which means style was not called as a macro but as a normal function.
141
+ // We also check if this is globalThis, which happens in non-strict mode bundles.
142
+ // Also allow style to be called as a normal function in tests.
143
+ // @ts-ignore
144
+ // eslint-disable-next-line
145
+ if ((this == null || this === globalThis) && process.env.NODE_ENV !== 'test') throw new Error('The style macro must be imported with {type: "macro"}.');
146
+ // Generate rules for each property.
147
+ let rules = new Map();
148
+ let values = new Map();
149
+ dependencies.clear();
150
+ let usedPriorities = 1;
151
+ let setRules = (key, value)=>{
152
+ usedPriorities = Math.max(usedPriorities, value[0]);
153
+ rules.set(key, value[1]);
154
+ };
155
+ hasConditions = false;
156
+ for(let key in style){
157
+ let value = style[key];
158
+ let themeProperty = key;
159
+ values.set(key, value);
160
+ // Get the type of custom properties in the theme.
161
+ if (key.startsWith('--')) {
162
+ themeProperty = value.type;
163
+ value = value.value;
164
+ }
165
+ // Expand shorthands to longhands so that merging works as expected.
166
+ if (theme.shorthands[key]) {
167
+ let shorthand = theme.shorthands[key];
168
+ if (typeof shorthand === 'function') {
169
+ let expanded = $a42cf657cdea7060$var$mapConditionalShorthand(value, shorthand);
170
+ for(let k in expanded){
171
+ let v = expanded[k];
172
+ values.set(k, v);
173
+ setRules(k, compileValue(k, k, v));
174
+ }
175
+ } else for (let prop of shorthand){
176
+ values.set(prop, value);
177
+ setRules(prop, compileValue(prop, prop, value));
178
+ }
179
+ } else if (themeProperty in theme.properties) setRules(key, compileValue(key, themeProperty, value));
180
+ }
181
+ // For properties referenced by self(), rewrite the declarations to assign
182
+ // to an intermediary custom property so we can access the value.
183
+ for (let dep of dependencies){
184
+ let value = values.get(dep);
185
+ if (value != null) {
186
+ if (!(dep in theme.properties)) throw new Error(`Unknown dependency ${dep}`);
187
+ let name = `--${themePropertyMap.get(dep)}`;
188
+ // Could potentially use @property to prevent the var from inheriting in children.
189
+ setRules(name, compileValue(name, dep, value));
190
+ setRules(dep, compileValue(dep, dep, name));
191
+ }
192
+ }
193
+ dependencies.clear();
194
+ // Prevent all global styles from leaking into this element.
195
+ // The :not(#a#b) raises the specificity of the selector by 2 ids,
196
+ // which can never occur on a real element, and will win over other
197
+ // selectors such as class and element selectors.
198
+ let css = '.\\.:not(#a#b) { all: revert-layer }\n\n';
199
+ // Declare layers for each priority ahead of time so the order is always correct.
200
+ css += '@layer ';
201
+ let first = true;
202
+ for(let i = 0; i <= usedPriorities; i++){
203
+ if (first) first = false;
204
+ else css += ', ';
205
+ css += $a42cf657cdea7060$var$layerName($a42cf657cdea7060$var$generateName(i, true));
206
+ }
207
+ css += ', UNSAFE_overrides;\n\n';
208
+ // If allowed overrides are provided, generate code to match the input override string and include only allowed classes.
209
+ // Also generate a variable for each overridable property that overlaps with the style definition. If those are defined,
210
+ // the defaults from the style definition are omitted.
211
+ let allowedOverridesSet = new Set();
212
+ let js = 'let rules = " .";\n';
213
+ if (allowedOverrides?.length) {
214
+ for (let property of allowedOverrides)if (themePropertyMap.has(property)) allowedOverridesSet.add(themePropertyMap.get(property));
215
+ js += `let matches = (overrides || '').match(/(?:^|\\s)(?:${[
216
+ ...allowedOverridesSet
217
+ ].join('|')})[^\\s]+/g) || [];\n`;
218
+ js += 'rules += matches.join(\'\');\n';
219
+ let loop = '';
220
+ for (let property of rules.keys()){
221
+ let themeProperty = themePropertyMap.get(property);
222
+ if (themeProperty && allowedOverridesSet.has(themeProperty)) {
223
+ js += `let $${themeProperty} = false;\n`;
224
+ loop += ` if (/^\\s*${themeProperty}/.test(p)) $${themeProperty} = true;\n`;
225
+ }
226
+ }
227
+ if (loop) {
228
+ js += 'for (let p of matches) {\n';
229
+ js += loop;
230
+ js += '}\n';
231
+ }
232
+ }
233
+ // Generate JS and CSS for each rule.
234
+ let isStatic = !(hasConditions || allowedOverrides);
235
+ let className = ' .';
236
+ let rulesByLayer = new Map();
237
+ for (let [property, propertyRules] of rules){
238
+ if (isStatic) className += $a42cf657cdea7060$var$getStaticClassName(propertyRules);
239
+ else {
240
+ let themeProperty = themePropertyMap.get(property);
241
+ let allowsOverrides = themeProperty && allowedOverridesSet.has(themeProperty);
242
+ if (allowsOverrides) // Omit the value if an override was passed in.
243
+ js += `if (!$${themeProperty}) {\n`;
244
+ js += $a42cf657cdea7060$var$printJS(propertyRules) + '\n';
245
+ if (allowsOverrides) js += '}\n';
246
+ }
247
+ for (let rule of propertyRules)$a42cf657cdea7060$var$printRule(rule, rulesByLayer);
248
+ }
249
+ for (let [layer, rules] of rulesByLayer){
250
+ css += `@layer ${$a42cf657cdea7060$var$layerName(layer)} {\n`;
251
+ css += rules.join('\n\n');
252
+ css += '}\n\n';
253
+ }
254
+ if (this && typeof this.addAsset === 'function') this.addAsset({
255
+ type: 'css',
256
+ content: css
257
+ });
258
+ if (isStatic) return className;
259
+ js += 'return rules;';
260
+ if (allowedOverrides) return new Function('props', 'overrides', js);
261
+ return new Function('props', js);
262
+ };
263
+ function compileValue(property, themeProperty, value) {
264
+ return conditionalToRules(value, 0, new Set(), new Set(), (value, priority, conditions, skipConditions)=>{
265
+ return compileRule(property, themeProperty, value, priority, conditions, skipConditions);
266
+ });
267
+ }
268
+ function conditionalToRules(value, parentPriority, currentConditions, skipConditions, fn) {
269
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
270
+ let rules = [];
271
+ // Later conditions in parent rules override conditions in child rules.
272
+ let subSkipConditions = new Set([
273
+ ...skipConditions,
274
+ ...Object.keys(value)
275
+ ]);
276
+ // Skip the default condition if we're already filtering by one of the other possible conditions.
277
+ // For example, if someone specifies `dark: 'gray-400'`, only include the dark version of `gray-400` from the theme.
278
+ let skipDefault = Object.keys(value).some((k)=>currentConditions.has(k));
279
+ let wasCSSCondition = false;
280
+ let priority = parentPriority;
281
+ for(let condition in value){
282
+ if (skipConditions.has(condition) || condition === 'default' && skipDefault) continue;
283
+ subSkipConditions.delete(condition);
284
+ let val = value[condition];
285
+ // If a theme condition comes after runtime conditions, create a new grouping.
286
+ // This makes the CSS class unconditional so it appears outside the `else` block in the JS.
287
+ // The @layer order in the generated CSS will ensure that it overrides classes applied by runtime conditions.
288
+ let isCSSCondition = condition in theme.conditions || /^[@:]/.test(condition);
289
+ if (!wasCSSCondition && isCSSCondition && rules.length) rules = [
290
+ {
291
+ prelude: '',
292
+ condition: '',
293
+ layer: '',
294
+ body: rules
295
+ }
296
+ ];
297
+ wasCSSCondition = isCSSCondition;
298
+ // Increment the current priority whenever we see a new CSS condition.
299
+ if (isCSSCondition) priority++;
300
+ // If this is a runtime condition, inherit the priority from the parent rule.
301
+ // Otherwise, use the current maximum of the parent and current priorities.
302
+ let rulePriority = isCSSCondition ? priority : parentPriority;
303
+ if (condition === 'default' || isCSSCondition || /^is[A-Z]/.test(condition) || /^allows[A-Z]/.test(condition)) {
304
+ let subConditions = currentConditions;
305
+ if (isCSSCondition) subConditions = new Set([
306
+ ...currentConditions,
307
+ condition
308
+ ]);
309
+ let [subPriority, subRules] = conditionalToRules(val, rulePriority, subConditions, subSkipConditions, fn);
310
+ rules.push(...compileCondition(currentConditions, condition, priority, subRules));
311
+ priority = Math.max(priority, subPriority);
312
+ } else if (val && typeof val === 'object' && !Array.isArray(val)) for(let key in val){
313
+ let [subPriority, subRules] = conditionalToRules(val[key], rulePriority, currentConditions, subSkipConditions, fn);
314
+ rules.push(...compileCondition(currentConditions, `${condition} === ${JSON.stringify(key)}`, priority, subRules));
315
+ priority = Math.max(priority, subPriority);
316
+ }
317
+ }
318
+ return [
319
+ priority,
320
+ rules
321
+ ];
322
+ } else // @ts-ignore - broken in non-strict?
323
+ return fn(value, parentPriority, currentConditions, skipConditions);
324
+ }
325
+ function compileCondition(conditions, condition, priority, rules) {
326
+ if (condition === 'default' || conditions.has(condition)) return [
327
+ {
328
+ prelude: '',
329
+ condition: '',
330
+ layer: '',
331
+ body: rules
332
+ }
333
+ ];
334
+ if (condition in theme.conditions || /^[@:]/.test(condition)) {
335
+ // Conditions starting with : are CSS pseudo classes. Nest them inside the parent rule.
336
+ let prelude = theme.conditions[condition] || condition;
337
+ if (prelude.startsWith(':')) return [
338
+ {
339
+ prelude: '',
340
+ layer: $a42cf657cdea7060$var$generateName(priority, true),
341
+ body: rules.map((rule)=>$a42cf657cdea7060$var$nestRule(rule, prelude)),
342
+ condition: ''
343
+ }
344
+ ];
345
+ // Otherwise, wrap the rule in the condition (e.g. @media).
346
+ return [
347
+ {
348
+ // Top level layer is based on the priority of the rule, not the condition.
349
+ // Also group in a sub-layer based on the condition so that lightningcss can more effectively deduplicate rules.
350
+ layer: `${$a42cf657cdea7060$var$generateName(priority, true)}.${themeConditionMap.get(condition) || $a42cf657cdea7060$var$generateArbitraryValueSelector(condition, true)}`,
351
+ prelude: prelude,
352
+ body: rules,
353
+ condition: ''
354
+ }
355
+ ];
356
+ }
357
+ hasConditions = true;
358
+ return [
359
+ {
360
+ prelude: '',
361
+ layer: '',
362
+ condition: condition,
363
+ body: rules
364
+ }
365
+ ];
366
+ }
367
+ function compileRule(property, themeProperty, value, priority, conditions, skipConditions) {
368
+ // Generate selector. This consists of three parts:
369
+ // 1. Property. For custom properties we use a hash. For theme properties, we use the index within the theme.
370
+ // 2. Conditions. This uses the index within the theme.
371
+ // 3. Value. The index in the theme, or a hash for arbitrary values.
372
+ let prelude = '.';
373
+ if (property.startsWith('--')) // Include both custom property name and theme property in case the same var is reused between multiple theme properties.
374
+ prelude += $a42cf657cdea7060$var$generateArbitraryValueSelector(property, true) + '_' + themePropertyMap.get(themeProperty) + '-';
375
+ else prelude += themePropertyMap.get(themeProperty);
376
+ let propertyFunction = propertyFunctions.get(themeProperty);
377
+ if (propertyFunction) {
378
+ // Expand value to conditional CSS values, and then to rules.
379
+ let res = propertyFunction(value, property);
380
+ return conditionalToRules(res, priority, conditions, skipConditions, (value, priority, conditions)=>{
381
+ let [obj, p] = value;
382
+ let body = '';
383
+ for(let key in obj){
384
+ let k = key;
385
+ let value = obj[k];
386
+ if (value === undefined) continue;
387
+ if (typeof value === 'string') // Replace self() references with variables and track the dependencies.
388
+ value = value.replace(/self\(([a-zA-Z]+)/g, (_, v)=>{
389
+ dependencies.add(v);
390
+ return `var(--${themePropertyMap.get(v)}`;
391
+ });
392
+ body += `${$a42cf657cdea7060$var$kebab(key)}: ${value};`;
393
+ }
394
+ let selector = prelude;
395
+ if (conditions.size > 0) for (let condition of conditions)selector += themeConditionMap.get(condition) || $a42cf657cdea7060$var$generateArbitraryValueSelector(condition);
396
+ let rules = [
397
+ {
398
+ condition: '',
399
+ layer: '',
400
+ prelude: selector + p,
401
+ body: body
402
+ }
403
+ ];
404
+ return [
405
+ 0,
406
+ rules
407
+ ];
408
+ });
409
+ } else throw new Error('Unknown property ' + themeProperty);
410
+ }
411
+ }
412
+ function $a42cf657cdea7060$var$nestRule(rule, prelude) {
413
+ if (Array.isArray(rule.body)) return {
414
+ prelude: rule.prelude,
415
+ layer: rule.layer,
416
+ body: rule.body.map((r)=>$a42cf657cdea7060$var$nestRule(r, prelude)),
417
+ condition: rule.condition
418
+ };
419
+ else return {
420
+ prelude: rule.prelude,
421
+ layer: rule.layer,
422
+ body: [
423
+ {
424
+ ...rule,
425
+ prelude: '&' + prelude
426
+ }
427
+ ],
428
+ condition: ''
429
+ };
430
+ }
431
+ function $a42cf657cdea7060$var$kebab(property) {
432
+ if (property.startsWith('--')) return property;
433
+ return property.replace(/([a-z])([A-Z])/g, (_, a, b)=>`${a}-${b.toLowerCase()}`);
434
+ }
435
+ // Generate a class name from a number, e.g. index within the theme.
436
+ // This maps to an alphabet containing lower case letters, upper case letters, and numbers.
437
+ // For numbers larger than 62, an underscore is prepended.
438
+ // This encoding allows easy parsing to enable runtime merging by property.
439
+ function $a42cf657cdea7060$var$generateName(index, atStart = false) {
440
+ if (index < 26) // lower case letters
441
+ return String.fromCharCode(index + 97);
442
+ if (index < 52) // upper case letters
443
+ return String.fromCharCode(index - 26 + 65);
444
+ if (index < 62 && !atStart) // numbers
445
+ return String.fromCharCode(index - 52 + 48);
446
+ return '_' + $a42cf657cdea7060$var$generateName(index - (atStart ? 52 : 62));
447
+ }
448
+ // For arbitrary values, we use a hash of the string to generate the class name.
449
+ function $a42cf657cdea7060$var$generateArbitraryValueSelector(v, atStart = false) {
450
+ let c = $a42cf657cdea7060$var$hash(v).toString(36);
451
+ if (atStart && /^[0-9]/.test(c)) c = `_${c}`;
452
+ return `-${c}`;
453
+ }
454
+ // djb2 hash function.
455
+ // http://www.cse.yorku.ca/~oz/hash.html
456
+ function $a42cf657cdea7060$var$hash(v) {
457
+ let hash = 5381;
458
+ for(let i = 0; i < v.length; i++)hash = (hash << 5) + hash + v.charCodeAt(i) >>> 0;
459
+ return hash;
460
+ }
461
+ function $a42cf657cdea7060$var$layerName(name) {
462
+ // All of our layers should be sub-layers of a single parent layer, so that
463
+ // the unsafe overrides layer always comes after.
464
+ return `_.${name}`;
465
+ }
466
+ function $a42cf657cdea7060$var$printRule(rule, rulesByLayer, preludes = [], layer = 'a') {
467
+ if (rule.prelude) preludes.push(rule.prelude);
468
+ if (typeof rule.body === 'string') {
469
+ // Nest rule in our stack of preludes (e.g. media queries/selectors).
470
+ let content = ' ';
471
+ preludes.forEach((p, i)=>{
472
+ content += `${p} {\n${' '.repeat((i + 2) * 2)}`;
473
+ });
474
+ content += rule.body + '\n';
475
+ preludes.map((_, i)=>{
476
+ content += `${' '.repeat((preludes.length - i) * 2)}}\n`;
477
+ });
478
+ // Group rule into the appropriate layer.
479
+ let rules = rulesByLayer.get(rule.layer || layer);
480
+ if (!rules) {
481
+ rules = [];
482
+ rulesByLayer.set(rule.layer || layer, rules);
483
+ }
484
+ rules.push(content);
485
+ } else for (let b of rule.body)$a42cf657cdea7060$var$printRule(b, rulesByLayer, preludes, rule.layer || layer);
486
+ if (rule.prelude) preludes.pop();
487
+ }
488
+ function $a42cf657cdea7060$var$printJS(rules, indent = '') {
489
+ rules = rules.slice().reverse();
490
+ let conditional = rules.filter((rule)=>rule.condition).map((rule, i)=>{
491
+ return `${i > 0 ? ' else ' : ''}if (props.${rule.condition}) {\n${indent} ${$a42cf657cdea7060$var$printRuleChildren(rule, indent + ' ')}\n${indent}}`;
492
+ });
493
+ let elseCases = rules.filter((rule)=>!rule.condition).map((rule)=>$a42cf657cdea7060$var$printRuleChildren(rule, indent + ' '));
494
+ if (conditional.length && elseCases.length) return `${conditional.join('')} else {\n${indent} ${elseCases.join('\n' + indent + ' ')}\n${indent}}`;
495
+ if (conditional.length) return conditional.join('');
496
+ return elseCases.join('\n' + indent);
497
+ }
498
+ function $a42cf657cdea7060$var$printRuleChildren(rule, indent = '') {
499
+ let res = '';
500
+ if (rule.prelude.startsWith('.')) res += `rules += ' ${rule.prelude.slice(1)}';`;
501
+ if (Array.isArray(rule.body)) res += $a42cf657cdea7060$var$printJS(rule.body, indent);
502
+ return res;
503
+ }
504
+ function $a42cf657cdea7060$var$getStaticClassName(rules) {
505
+ return rules.map((rule)=>(rule.prelude.startsWith('.') ? ' ' + rule.prelude.slice(1) : '') + (Array.isArray(rule.body) ? $a42cf657cdea7060$var$getStaticClassName(rule.body) : '')).join('');
506
+ }
507
+ function $a42cf657cdea7060$export$1776c186c69df29e(css, layer = '_.a') {
508
+ let className = $a42cf657cdea7060$var$generateArbitraryValueSelector(css, true);
509
+ css = `@layer ${layer} {
510
+ .${className} {
511
+ ${css}
512
+ }
513
+ }`;
514
+ if (this && typeof this.addAsset === 'function') this.addAsset({
515
+ type: 'css',
516
+ content: css
517
+ });
518
+ return className;
519
+ }
520
+ function $a42cf657cdea7060$export$d25ddfdf17c3ad3e(css) {
521
+ let name = $a42cf657cdea7060$var$generateArbitraryValueSelector(css, true);
522
+ css = `@keyframes ${name} {
523
+ ${css}
524
+ }`;
525
+ if (this && typeof this.addAsset === 'function') this.addAsset({
526
+ type: 'css',
527
+ content: css
528
+ });
529
+ return name;
530
+ }
531
+
532
+
533
+ export {$a42cf657cdea7060$export$e33e260cb0fb20f7 as createArbitraryProperty, $a42cf657cdea7060$export$40f4ff17b27355ab as createMappedProperty, $a42cf657cdea7060$export$7fdf8c7af26ba416 as createRenamedProperty, $a42cf657cdea7060$export$852145629bb0d58b as createColorProperty, $a42cf657cdea7060$export$25d302a5b900a763 as createTheme, $a42cf657cdea7060$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;AACrK;AAEO,SAAS,0CAA+B,GAAW,EAAE,QAAQ,KAAK;IACvE,IAAI,YAAY,qDAA+B,KAAK;IACpD,MAAM,CAAC,OAAO,EAAE,MAAM;GACrB,EAAE,UAAU;EACb,EAAE,IAAI;;CAEP,CAAC;IACA,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,YACnC,IAAI,CAAC,QAAQ,CAAC;QACZ,MAAM;QACN,SAAS;IACX;IAEF,OAAO;AACT;AAEO,SAAS,0CAAqC,GAAW;IAC9D,IAAI,OAAO,qDAA+B,KAAK;IAC/C,MAAM,CAAC,WAAW,EAAE,KAAK;EACzB,EAAE,IAAI;CACP,CAAC;IACA,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,YACnC,IAAI,CAAC,QAAQ,CAAC;QACZ,MAAM;QACN,SAAS;IACX;IAEF,OAAO;AACT","sources":["packages/@react-spectrum/s2/style/style-macro.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type {Condition, CSSProperties, CSSValue, CustomValue, PropertyFunction, PropertyValueDefinition, PropertyValueMap, RenderProps, ShorthandProperty, StyleFunction, StyleValue, Theme, ThemeProperties, Value} from './types';\n\nlet defaultArbitraryProperty = <T extends Value>(value: T, property: string) => ({[property]: value} as CSSProperties);\nexport function createArbitraryProperty<T extends Value>(fn: (value: T, property: string) => CSSProperties = defaultArbitraryProperty): PropertyFunction<T> {\n return (value, property) => {\n let selector = Array.isArray(value) ? generateArbitraryValueSelector(value.map(v => String(v)).join('')) : generateArbitraryValueSelector(String(value));\n return {default: [fn(value, property), selector]};\n };\n}\n\nfunction recursiveValues(obj: object): string[] {\n return Object.values(obj).flatMap(v => typeof v === 'object' ? recursiveValues(v) : [v]);\n}\n\nexport function createMappedProperty<T extends CSSValue>(fn: (value: string, property: string) => CSSProperties, values: PropertyValueMap<T> | string[]): PropertyFunction<T> {\n let valueMap = createValueLookup(Array.isArray(values) ? values : recursiveValues(values));\n return (value, property) => {\n let v = parseArbitraryValue(value);\n if (v) {\n return {default: [fn(v[0], property), v[1]]};\n }\n\n // @ts-ignore\n let val = Array.isArray(values) ? value : values[String(value)];\n return mapConditionalValue(val, value => {\n return [fn(value, property), valueMap.get(value)!];\n });\n };\n}\n\nexport function createRenamedProperty<T extends CSSValue>(name: string, values: PropertyValueMap<T> | string[]): PropertyFunction<T> {\n return createMappedProperty((value, property) => ({[property.startsWith('--') ? property : name]: value}), values);\n}\n\nexport type Color<C extends string> = C | `${string}/${number}`;\nexport function createColorProperty<C extends string>(colors: PropertyValueMap<C>, property?: keyof CSSProperties): PropertyFunction<Color<C>> {\n let valueMap = createValueLookup(Object.values(colors).flatMap((v: any) => typeof v === 'object' ? Object.values(v) : [v]));\n return (value: Color<C>, key: string) => {\n let v = parseArbitraryValue(value);\n if (v) {\n return {default: [{[property || key]: v[0]}, v[1]]};\n }\n\n let [color, opacity] = value.split('/');\n // @ts-ignore\n let c = colors[color];\n return mapConditionalValue(c, value => {\n let css = opacity ? `rgb(from ${value} r g b / ${opacity}%)` : value;\n let selector = valueMap.get(value)! + (opacity ? opacity.replace('.', '-') : '');\n return [{[property || key]: css}, selector];\n });\n };\n}\n\nfunction mapConditionalValue<T, U>(value: PropertyValueDefinition<T>, fn: (value: T) => U): PropertyValueDefinition<U> {\n if (typeof value === 'object') {\n let res: PropertyValueDefinition<U> = {};\n for (let condition in value) {\n res[condition] = mapConditionalValue((value as any)[condition], fn);\n }\n return res;\n } else {\n return fn(value);\n }\n}\n\nfunction mapConditionalShorthand<T, C extends string, R extends RenderProps<string>>(value: PropertyValueDefinition<T>, fn: ShorthandProperty<T>): {[property: string]: StyleValue<Value, C, R>} {\n if (typeof value === 'object') {\n let res = {};\n for (let condition in value) {\n let properties = mapConditionalShorthand(value[condition], fn);\n for (let property in properties) {\n res[property] ??= {};\n res[property][condition] = properties[property];\n }\n }\n return res;\n } else {\n return fn(value);\n }\n}\n\nfunction createValueLookup(values: Array<CSSValue>, atStart = false) {\n let map = new Map<CSSValue, string>();\n for (let value of values) {\n if (!map.has(value)) {\n map.set(value, generateName(map.size, atStart));\n }\n }\n return map;\n}\n\nfunction parseArbitraryValue(value: any) {\n if (typeof value === 'string' && value.startsWith('--')) {\n return [`var(${value})`, generateArbitraryValueSelector(value)];\n } else if (typeof value === 'string' && value[0] === '[' && value[value.length - 1] === ']') {\n let s = generateArbitraryValueSelector(value.slice(1, -1));\n return [value.slice(1, -1), s];\n }\n}\n\ninterface MacroContext {\n addAsset(asset: {type: string, content: string}): void\n}\n\nexport function createTheme<T extends Theme>(theme: T): StyleFunction<ThemeProperties<T>, 'default' | Extract<keyof T['conditions'], string>> {\n let themePropertyMap = createValueLookup(Object.keys(theme.properties), true);\n let themeConditionMap = createValueLookup(Object.keys(theme.conditions), true);\n let propertyFunctions = new Map(Object.entries(theme.properties).map(([k, v]) => {\n if (typeof v === 'function') {\n return [k, v];\n }\n return [k, createMappedProperty((value, p) => ({[p]: value}), v) as PropertyFunction<Value>];\n }));\n\n let dependencies = new Set<string>();\n let hasConditions = false;\n return function style(this: MacroContext | void, style, allowedOverrides?: readonly string[]) {\n // Check if `this` is undefined, which means style was not called as a macro but as a normal function.\n // We also check if this is globalThis, which happens in non-strict mode bundles.\n // Also allow style to be called as a normal function in tests.\n // @ts-ignore\n // eslint-disable-next-line\n if ((this == null || this === globalThis) && process.env.NODE_ENV !== 'test') {\n throw new Error('The style macro must be imported with {type: \"macro\"}.');\n }\n\n // Generate rules for each property.\n let rules = new Map<string, Rule[]>();\n let values = new Map();\n dependencies.clear();\n let usedPriorities = 1;\n let setRules = (key: string, value: [number, Rule[]]) => {\n usedPriorities = Math.max(usedPriorities, value[0]);\n rules.set(key, value[1]);\n };\n\n hasConditions = false;\n for (let key in style) {\n let value = style[key]!;\n let themeProperty = key;\n values.set(key, value);\n\n // Get the type of custom properties in the theme.\n if (key.startsWith('--')) {\n themeProperty = value.type;\n value = value.value;\n }\n\n // Expand shorthands to longhands so that merging works as expected.\n if (theme.shorthands[key]) {\n let shorthand = theme.shorthands[key];\n if (typeof shorthand === 'function') {\n let expanded = mapConditionalShorthand(value, shorthand);\n for (let k in expanded) {\n let v = expanded[k];\n values.set(k, v);\n setRules(k, compileValue(k, k, v));\n }\n } else {\n for (let prop of shorthand) {\n values.set(prop, value);\n setRules(prop, compileValue(prop, prop, value));\n }\n }\n } else if (themeProperty in theme.properties) {\n setRules(key, compileValue(key, themeProperty, value));\n }\n }\n\n // For properties referenced by self(), rewrite the declarations to assign\n // to an intermediary custom property so we can access the value.\n for (let dep of dependencies) {\n let value = values.get(dep);\n if (value != null) {\n if (!(dep in theme.properties)) {\n throw new Error(`Unknown dependency ${dep}`);\n }\n let name = `--${themePropertyMap.get(dep)}`;\n // Could potentially use @property to prevent the var from inheriting in children.\n setRules(name, compileValue(name, dep, value));\n setRules(dep, compileValue(dep, dep, name));\n }\n }\n dependencies.clear();\n\n // Prevent all global styles from leaking into this element.\n // The :not(#a#b) raises the specificity of the selector by 2 ids,\n // which can never occur on a real element, and will win over other\n // selectors such as class and element selectors.\n let css = '.\\\\.:not(#a#b) { all: revert-layer }\\n\\n';\n\n // Declare layers for each priority ahead of time so the order is always correct.\n css += '@layer ';\n let first = true;\n for (let i = 0; i <= usedPriorities; i++) {\n if (first) {\n first = false;\n } else {\n css += ', ';\n }\n css += layerName(generateName(i, true));\n }\n css += ', UNSAFE_overrides;\\n\\n';\n\n // If allowed overrides are provided, generate code to match the input override string and include only allowed classes.\n // Also generate a variable for each overridable property that overlaps with the style definition. If those are defined,\n // the defaults from the style definition are omitted.\n let allowedOverridesSet = new Set<string>();\n let js = 'let rules = \" .\";\\n';\n if (allowedOverrides?.length) {\n for (let property of allowedOverrides) {\n if (themePropertyMap.has(property as string)) {\n allowedOverridesSet.add(themePropertyMap.get(property as string)!);\n }\n }\n\n js += `let matches = (overrides || '').match(/(?:^|\\\\s)(?:${[...allowedOverridesSet].join('|')})[^\\\\s]+/g) || [];\\n`;\n js += 'rules += matches.join(\\'\\');\\n';\n let loop = '';\n for (let property of rules.keys()) {\n let themeProperty = themePropertyMap.get(property);\n if (themeProperty && allowedOverridesSet.has(themeProperty)) {\n js += `let $${themeProperty} = false;\\n`;\n loop += ` if (/^\\\\s*${themeProperty}/.test(p)) $${themeProperty} = true;\\n`;\n }\n }\n if (loop) {\n js += 'for (let p of matches) {\\n';\n js += loop;\n js += '}\\n';\n }\n }\n\n // Generate JS and CSS for each rule.\n let isStatic = !(hasConditions || allowedOverrides);\n let className = ' .';\n let rulesByLayer = new Map<string, string[]>();\n for (let [property, propertyRules] of rules) {\n if (isStatic) {\n className += getStaticClassName(propertyRules);\n } else {\n let themeProperty = themePropertyMap.get(property);\n let allowsOverrides = themeProperty && allowedOverridesSet.has(themeProperty);\n if (allowsOverrides) {\n // Omit the value if an override was passed in.\n js += `if (!$${themeProperty}) {\\n`;\n }\n js += printJS(propertyRules) + '\\n';\n if (allowsOverrides) {\n js += '}\\n';\n }\n }\n for (let rule of propertyRules) {\n printRule(rule, rulesByLayer);\n }\n }\n\n for (let [layer, rules] of rulesByLayer) {\n css += `@layer ${layerName(layer)} {\\n`;\n css += rules.join('\\n\\n');\n css += '}\\n\\n';\n }\n\n if (this && typeof this.addAsset === 'function') {\n this.addAsset({\n type: 'css',\n content: css\n });\n }\n\n if (isStatic) {\n return className;\n }\n\n js += 'return rules;';\n if (allowedOverrides) {\n return new Function('props', 'overrides', js) as any;\n }\n return new Function('props', js) as any;\n };\n\n function compileValue(property: string, themeProperty: string, value: StyleValue<Value, Condition<T>, any>) {\n return conditionalToRules(value as any, 0, new Set(), new Set(), (value, priority, conditions, skipConditions) => {\n return compileRule(property, themeProperty, value, priority, conditions, skipConditions);\n });\n }\n\n function conditionalToRules<P extends CustomValue | any[]>(\n value: PropertyValueDefinition<P>,\n parentPriority: number,\n currentConditions: Set<string>,\n skipConditions: Set<string>,\n fn: (value: P, priority: number, conditions: Set<string>, skipConditions: Set<string>) => [number, Rule[]]\n ): [number, Rule[]] {\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n let rules: Rule[] = [];\n\n // Later conditions in parent rules override conditions in child rules.\n let subSkipConditions = new Set([...skipConditions, ...Object.keys(value)]);\n\n // Skip the default condition if we're already filtering by one of the other possible conditions.\n // For example, if someone specifies `dark: 'gray-400'`, only include the dark version of `gray-400` from the theme.\n let skipDefault = Object.keys(value).some(k => currentConditions.has(k));\n let wasCSSCondition = false;\n let priority = parentPriority;\n\n for (let condition in value) {\n if (skipConditions.has(condition) || (condition === 'default' && skipDefault)) {\n continue;\n }\n subSkipConditions.delete(condition);\n\n let val = value[condition];\n\n // If a theme condition comes after runtime conditions, create a new grouping.\n // This makes the CSS class unconditional so it appears outside the `else` block in the JS.\n // The @layer order in the generated CSS will ensure that it overrides classes applied by runtime conditions.\n let isCSSCondition = condition in theme.conditions || /^[@:]/.test(condition);\n if (!wasCSSCondition && isCSSCondition && rules.length) {\n rules = [{prelude: '', condition: '', layer: '', body: rules}];\n }\n wasCSSCondition = isCSSCondition;\n\n // Increment the current priority whenever we see a new CSS condition.\n if (isCSSCondition) {\n priority++;\n }\n\n // If this is a runtime condition, inherit the priority from the parent rule.\n // Otherwise, use the current maximum of the parent and current priorities.\n let rulePriority = isCSSCondition ? priority : parentPriority;\n\n if (condition === 'default' || isCSSCondition || /^is[A-Z]/.test(condition) || /^allows[A-Z]/.test(condition)) {\n let subConditions = currentConditions;\n if (isCSSCondition) {\n subConditions = new Set([...currentConditions, condition]);\n }\n let [subPriority, subRules] = conditionalToRules(val, rulePriority, subConditions, subSkipConditions, fn);\n rules.push(...compileCondition(currentConditions, condition, priority, subRules));\n priority = Math.max(priority, subPriority);\n } else if (val && typeof val === 'object' && !Array.isArray(val)) {\n for (let key in val) {\n let [subPriority, subRules] = conditionalToRules(val[key], rulePriority, currentConditions, subSkipConditions, fn);\n rules.push(...compileCondition(currentConditions, `${condition} === ${JSON.stringify(key)}`, priority, subRules));\n priority = Math.max(priority, subPriority);\n }\n }\n }\n return [priority, rules];\n } else {\n // @ts-ignore - broken in non-strict?\n return fn(value, parentPriority, currentConditions, skipConditions);\n }\n }\n\n function compileCondition(conditions: Set<string>, condition: string, priority: number, rules: Rule[]): Rule[] {\n if (condition === 'default' || conditions.has(condition)) {\n return [{prelude: '', condition: '', layer: '', body: rules}];\n }\n\n if (condition in theme.conditions || /^[@:]/.test(condition)) {\n // Conditions starting with : are CSS pseudo classes. Nest them inside the parent rule.\n let prelude = theme.conditions[condition] || condition;\n if (prelude.startsWith(':')) {\n return [{\n prelude: '',\n layer: generateName(priority, true),\n body: rules.map(rule => nestRule(rule, prelude)),\n condition: ''\n }];\n }\n\n // Otherwise, wrap the rule in the condition (e.g. @media).\n return [{\n // Top level layer is based on the priority of the rule, not the condition.\n // Also group in a sub-layer based on the condition so that lightningcss can more effectively deduplicate rules.\n layer: `${generateName(priority, true)}.${themeConditionMap.get(condition) || generateArbitraryValueSelector(condition, true)}`,\n prelude,\n body: rules,\n condition: ''\n }];\n }\n\n hasConditions = true;\n return [{prelude: '', layer: '', condition, body: rules}];\n }\n\n function compileRule(property: string, themeProperty: string, value: Value, priority: number, conditions: Set<string>, skipConditions: Set<string>): [number, Rule[]] {\n // Generate selector. This consists of three parts:\n // 1. Property. For custom properties we use a hash. For theme properties, we use the index within the theme.\n // 2. Conditions. This uses the index within the theme.\n // 3. Value. The index in the theme, or a hash for arbitrary values.\n let prelude = '.';\n if (property.startsWith('--')) {\n // Include both custom property name and theme property in case the same var is reused between multiple theme properties.\n prelude += generateArbitraryValueSelector(property, true) + '_' + themePropertyMap.get(themeProperty) + '-';\n } else {\n prelude += themePropertyMap.get(themeProperty);\n }\n\n let propertyFunction = propertyFunctions.get(themeProperty);\n if (propertyFunction) {\n // Expand value to conditional CSS values, and then to rules.\n let res = propertyFunction(value, property);\n return conditionalToRules(res, priority, conditions, skipConditions, (value, priority, conditions) => {\n let [obj, p] = value;\n let body = '';\n for (let key in obj) {\n let k = key as any;\n let value = obj[k];\n if (value === undefined) {\n continue;\n }\n if (typeof value === 'string') {\n // Replace self() references with variables and track the dependencies.\n value = value.replace(/self\\(([a-zA-Z]+)/g, (_, v) => {\n dependencies.add(v);\n return `var(--${themePropertyMap.get(v)}`;\n });\n }\n body += `${kebab(key)}: ${value};`;\n }\n\n let selector = prelude;\n if (conditions.size > 0) {\n for (let condition of conditions) {\n selector += themeConditionMap.get(condition) || generateArbitraryValueSelector(condition);\n }\n }\n\n let rules: Rule[] = [{\n condition: '',\n layer: '',\n prelude: selector + p,\n body\n }];\n\n return [0, rules];\n });\n } else {\n throw new Error('Unknown property ' + themeProperty);\n }\n }\n}\n\nfunction nestRule(rule: Rule, prelude: string): Rule {\n if (Array.isArray(rule.body)) {\n return {\n prelude: rule.prelude,\n layer: rule.layer,\n body: rule.body.map(r => nestRule(r, prelude)),\n condition: rule.condition\n };\n } else {\n return {\n prelude: rule.prelude,\n layer: rule.layer,\n body: [{...rule, prelude: '&' + prelude}],\n condition: ''\n };\n }\n}\n\nfunction kebab(property: string) {\n if (property.startsWith('--')) {\n return property;\n }\n return property.replace(/([a-z])([A-Z])/g, (_, a, b) => `${a}-${b.toLowerCase()}`);\n}\n\ninterface Rule {\n prelude: string,\n layer: string,\n condition: string,\n body: string | Rule[]\n}\n\n// Generate a class name from a number, e.g. index within the theme.\n// This maps to an alphabet containing lower case letters, upper case letters, and numbers.\n// For numbers larger than 62, an underscore is prepended.\n// This encoding allows easy parsing to enable runtime merging by property.\nfunction generateName(index: number, atStart = false): string {\n if (index < 26) {\n // lower case letters\n return String.fromCharCode(index + 97);\n }\n\n if (index < 52) {\n // upper case letters\n return String.fromCharCode((index - 26) + 65);\n }\n\n if (index < 62 && !atStart) {\n // numbers\n return String.fromCharCode((index - 52) + 48);\n }\n\n return '_' + generateName(index - (atStart ? 52 : 62));\n}\n\n// For arbitrary values, we use a hash of the string to generate the class name.\nfunction generateArbitraryValueSelector(v: string, atStart = false) {\n let c = hash(v).toString(36);\n if (atStart && /^[0-9]/.test(c)) {\n c = `_${c}`;\n }\n return `-${c}`;\n}\n\n// djb2 hash function.\n// http://www.cse.yorku.ca/~oz/hash.html\nfunction hash(v: string) {\n let hash = 5381;\n for (let i = 0; i < v.length; i++) {\n hash = ((hash << 5) + hash) + v.charCodeAt(i) >>> 0;\n }\n return hash;\n}\n\nfunction layerName(name: string) {\n // All of our layers should be sub-layers of a single parent layer, so that\n // the unsafe overrides layer always comes after.\n return `_.${name}`;\n}\n\nfunction printRule(rule: Rule, rulesByLayer: Map<string, string[]>, preludes: string[] = [], layer = 'a') {\n if (rule.prelude) {\n preludes.push(rule.prelude);\n }\n\n if (typeof rule.body === 'string') {\n // Nest rule in our stack of preludes (e.g. media queries/selectors).\n let content = ' ';\n preludes.forEach((p, i) => {\n content += `${p} {\\n${' '.repeat((i + 2) * 2)}`;\n });\n content += rule.body + '\\n';\n preludes.map((_, i) => {\n content += `${' '.repeat((preludes.length - i) * 2)}}\\n`;\n });\n\n // Group rule into the appropriate layer.\n let rules = rulesByLayer.get(rule.layer || layer);\n if (!rules) {\n rules = [];\n rulesByLayer.set(rule.layer || layer, rules);\n }\n rules.push(content);\n } else {\n for (let b of rule.body) {\n printRule(b, rulesByLayer, preludes, rule.layer || layer);\n }\n }\n\n if (rule.prelude) {\n preludes.pop();\n }\n}\n\nfunction printJS(rules: Rule[], indent = ''): string {\n rules = rules.slice().reverse();\n\n let conditional = rules.filter(rule => rule.condition).map((rule, i) => {\n return `${i > 0 ? ' else ' : ''}if (props.${rule.condition}) {\\n${indent} ${printRuleChildren(rule, indent + ' ')}\\n${indent}}`;\n });\n\n let elseCases = rules.filter(rule => !rule.condition).map(rule => printRuleChildren(rule, indent + ' '));\n\n if (conditional.length && elseCases.length) {\n return `${conditional.join('')} else {\\n${indent} ${elseCases.join('\\n' + indent + ' ')}\\n${indent}}`;\n }\n\n if (conditional.length) {\n return conditional.join('');\n }\n\n return elseCases.join('\\n' + indent);\n}\n\nfunction printRuleChildren(rule: Rule, indent = '') {\n let res = '';\n if (rule.prelude.startsWith('.')) {\n res += `rules += ' ${rule.prelude.slice(1)}';`;\n }\n\n if (Array.isArray(rule.body)) {\n res += printJS(rule.body, indent);\n }\n\n return res;\n}\n\nfunction getStaticClassName(rules: Rule[]): string {\n return rules.map(rule => (rule.prelude.startsWith('.') ? ' ' + rule.prelude.slice(1) : '') + (Array.isArray(rule.body) ? getStaticClassName(rule.body) : '')).join('');\n}\n\nexport function raw(this: MacroContext | void, css: string, layer = '_.a') {\n let className = generateArbitraryValueSelector(css, true);\n css = `@layer ${layer} {\n .${className} {\n ${css}\n }\n}`;\n if (this && typeof this.addAsset === 'function') {\n this.addAsset({\n type: 'css',\n content: css\n });\n }\n return className;\n}\n\nexport function keyframes(this: MacroContext | void, css: string) {\n let name = generateArbitraryValueSelector(css, true);\n css = `@keyframes ${name} {\n ${css}\n}`;\n if (this && typeof this.addAsset === 'function') {\n this.addAsset({\n type: 'css',\n content: css\n });\n }\n return name;\n}\n"],"names":[],"version":3,"file":"style-macro.mjs.map","sourceRoot":"../../../../../"}