@onereach/styles 27.0.2-beta.6104.0 → 27.0.2-beta.6106.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onereach/styles",
|
|
3
|
-
"version": "27.0.2-beta.
|
|
3
|
+
"version": "27.0.2-beta.6106.0",
|
|
4
4
|
"description": "Styles for or-ui-next",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"files": [
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"test:contract": "node --test tests/*.test.cjs"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@onereach/font-icons": "^27.0.2-beta.
|
|
44
|
+
"@onereach/font-icons": "^27.0.2-beta.6106.0",
|
|
45
45
|
"postcss-nested": "6.2.0",
|
|
46
46
|
"tailwindcss": "4.3.2"
|
|
47
47
|
},
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
const postcss = require('postcss');
|
|
2
|
+
const postcssNested = require('postcss-nested');
|
|
3
|
+
|
|
4
|
+
const screens = require('../screens.json');
|
|
1
5
|
const {
|
|
2
6
|
importantMarker,
|
|
3
7
|
} = require('../tailwind/compatibility/important');
|
|
4
8
|
const {
|
|
5
9
|
legacySpacingAliasEntries,
|
|
6
10
|
} = require('../tailwind/compatibility/legacy-spacing');
|
|
7
|
-
const
|
|
8
|
-
const
|
|
11
|
+
const coreVariants = require('../tailwind/plugins/core').variants;
|
|
12
|
+
const themePresetValues = require('../tailwind/plugins/theme-preset').values;
|
|
9
13
|
const spacing = require('../tailwind.config.preset.v4').theme.spacing;
|
|
10
|
-
|
|
14
|
+
|
|
15
|
+
const legacyStateVariantOrder = new Map(
|
|
16
|
+
Object.keys(coreVariants)
|
|
17
|
+
.map((variant, index) => [variant, index]),
|
|
18
|
+
);
|
|
11
19
|
|
|
12
20
|
const legacySpacingAliases = legacySpacingAliasEntries(spacing)
|
|
13
21
|
.sort(([, left], [, right]) => right.length - left.length);
|
|
@@ -15,6 +23,69 @@ const legacySpacingUtilityPattern = /^-?(?:p(?:[xytrblse])?|m(?:[xytrblse])?|gap
|
|
|
15
23
|
const responsiveVariantOrder = new Map(
|
|
16
24
|
['xs', ...Object.keys(screens)].map((variant, index) => [variant, index]),
|
|
17
25
|
);
|
|
26
|
+
const legacyPseudoElementVariants = new Map([
|
|
27
|
+
['after', '::after'],
|
|
28
|
+
['backdrop', '::backdrop'],
|
|
29
|
+
['before', '::before'],
|
|
30
|
+
['file', '::file-selector-button'],
|
|
31
|
+
['first-letter', '::first-letter'],
|
|
32
|
+
['first-line', '::first-line'],
|
|
33
|
+
['marker', '::marker'],
|
|
34
|
+
['placeholder', '::placeholder'],
|
|
35
|
+
['selection', '::selection'],
|
|
36
|
+
]);
|
|
37
|
+
const legacyTransformValue = [
|
|
38
|
+
'translate(var(--tw-translate-x, 0), var(--tw-translate-y, 0))',
|
|
39
|
+
'rotate(var(--tw-rotate, 0))',
|
|
40
|
+
'skewX(var(--tw-skew-x, 0))',
|
|
41
|
+
'skewY(var(--tw-skew-y, 0))',
|
|
42
|
+
'scaleX(var(--tw-scale-x, 1))',
|
|
43
|
+
'scaleY(var(--tw-scale-y, 1))',
|
|
44
|
+
].join(' ');
|
|
45
|
+
const legacyComponentFactories = [
|
|
46
|
+
['theme-outline', require('../tailwind/plugins/theme-outline').values],
|
|
47
|
+
['theme-background', require('../tailwind/plugins/theme-background').values],
|
|
48
|
+
['theme-foreground', require('../tailwind/plugins/theme-foreground').values],
|
|
49
|
+
['theme-preset-1', themePresetValues],
|
|
50
|
+
['theme-preset-2', themePresetValues],
|
|
51
|
+
['theme-preset-3', themePresetValues],
|
|
52
|
+
['theme-preset-4', themePresetValues],
|
|
53
|
+
['theme-divider', require('../tailwind/plugins/theme-divider').values],
|
|
54
|
+
['theme-border', require('../tailwind/plugins/theme-border').values],
|
|
55
|
+
]
|
|
56
|
+
.map(([factory, values]) => [
|
|
57
|
+
factory,
|
|
58
|
+
new Map(Object.keys(values).map((value, index) => [value, index])),
|
|
59
|
+
])
|
|
60
|
+
.sort(([left], [right]) => right.length - left.length);
|
|
61
|
+
const legacyComponentFactoryNames = [
|
|
62
|
+
'theme-background',
|
|
63
|
+
'theme-foreground',
|
|
64
|
+
'theme-preset-1',
|
|
65
|
+
'theme-preset-2',
|
|
66
|
+
'theme-preset-3',
|
|
67
|
+
'theme-preset-4',
|
|
68
|
+
'theme-divider',
|
|
69
|
+
'theme-outline',
|
|
70
|
+
'theme-border',
|
|
71
|
+
'iconography',
|
|
72
|
+
'typography',
|
|
73
|
+
'layout',
|
|
74
|
+
].sort((left, right) => right.length - left.length);
|
|
75
|
+
const legacyComponentFactoryOrder = new Map([
|
|
76
|
+
'layout',
|
|
77
|
+
'typography',
|
|
78
|
+
'iconography',
|
|
79
|
+
'theme-preset-1',
|
|
80
|
+
'theme-preset-2',
|
|
81
|
+
'theme-preset-3',
|
|
82
|
+
'theme-preset-4',
|
|
83
|
+
'theme-foreground',
|
|
84
|
+
'theme-background',
|
|
85
|
+
'theme-border',
|
|
86
|
+
'theme-divider',
|
|
87
|
+
'theme-outline',
|
|
88
|
+
].map((factory, index) => [factory, index]));
|
|
18
89
|
const legacyCoreUtilities = new Map([
|
|
19
90
|
['leading-none', [
|
|
20
91
|
['line-height', '1'],
|
|
@@ -24,6 +95,9 @@ const legacyCoreUtilities = new Map([
|
|
|
24
95
|
['line-height', 'inherit'],
|
|
25
96
|
['color', 'inherit'],
|
|
26
97
|
]],
|
|
98
|
+
['outline', [
|
|
99
|
+
['outline-style', 'solid'],
|
|
100
|
+
]],
|
|
27
101
|
['outline-none', [
|
|
28
102
|
['outline', '2px solid transparent'],
|
|
29
103
|
['outline-offset', '2px'],
|
|
@@ -41,6 +115,12 @@ const legacyCoreUtilities = new Map([
|
|
|
41
115
|
const legacyCoreReplacementProps = new Map([
|
|
42
116
|
['leading-none', new Set(['--tw-leading', 'line-height'])],
|
|
43
117
|
['text-inherit', new Set(['font-size', 'line-height', 'color'])],
|
|
118
|
+
['outline', new Set([
|
|
119
|
+
'--tw-outline-style',
|
|
120
|
+
'outline',
|
|
121
|
+
'outline-style',
|
|
122
|
+
'outline-width',
|
|
123
|
+
])],
|
|
44
124
|
['outline-none', new Set([
|
|
45
125
|
'--tw-outline-style',
|
|
46
126
|
'outline',
|
|
@@ -60,29 +140,46 @@ function tailwindV4Compat() {
|
|
|
60
140
|
return {
|
|
61
141
|
postcssPlugin: 'onereach-tailwind-v4-compat',
|
|
62
142
|
async OnceExit(root) {
|
|
63
|
-
utilityLayers(root).forEach(
|
|
143
|
+
utilityLayers(root).forEach(restoreNestedVariantOrder);
|
|
64
144
|
await flattenUtilityLayers(root);
|
|
65
145
|
|
|
66
146
|
utilityLayers(root).forEach((layer) => {
|
|
147
|
+
restoreLegacyGroupHover(layer);
|
|
148
|
+
restoreLegacyPseudoElementStateOrder(layer);
|
|
67
149
|
restoreStackedVariantOrder(layer);
|
|
68
150
|
restoreLegacySpacingClassNames(layer);
|
|
69
151
|
restoreImportantDeclarations(layer);
|
|
70
152
|
restoreLegacyCoreUtilities(layer);
|
|
153
|
+
restoreLegacyBorderWidthUtilities(layer);
|
|
154
|
+
restoreLegacyTransformUtilities(layer);
|
|
71
155
|
restoreArbitraryValueOrder(layer);
|
|
156
|
+
reorderLegacyComponentValueSiblings(layer);
|
|
157
|
+
reorderLegacyStateVariantSiblings(layer);
|
|
158
|
+
reorderLegacyOutlineSiblings(layer);
|
|
159
|
+
reorderResponsiveVariantSiblings(layer);
|
|
160
|
+
});
|
|
161
|
+
restoreLegacyComponentLayers(root);
|
|
162
|
+
componentLayers(root).forEach((layer) => {
|
|
163
|
+
reorderLegacyComponentFactorySiblings(layer);
|
|
72
164
|
reorderResponsiveVariantSiblings(layer);
|
|
73
165
|
});
|
|
74
166
|
},
|
|
75
167
|
};
|
|
76
168
|
}
|
|
77
169
|
|
|
78
|
-
function
|
|
170
|
+
function restoreNestedVariantOrder(root) {
|
|
79
171
|
root.walkRules((candidateRule) => {
|
|
80
172
|
const candidate = classNames(candidateRule.selector)
|
|
81
|
-
.find((className) =>
|
|
173
|
+
.find((className) => {
|
|
174
|
+
const variants = classSegments(className).slice(0, -1);
|
|
175
|
+
const arbitraryIndex = variants.findIndex((variant) => variant.startsWith('[&'));
|
|
176
|
+
|
|
177
|
+
return variants.includes('children') || arbitraryIndex > 0;
|
|
178
|
+
});
|
|
82
179
|
|
|
83
180
|
if (!candidate) return;
|
|
84
181
|
|
|
85
|
-
const segments = candidate
|
|
182
|
+
const segments = classSegments(candidate);
|
|
86
183
|
const variantDepth = segments.length - 1;
|
|
87
184
|
|
|
88
185
|
const paths = nestedContainerPaths(candidateRule, variantDepth);
|
|
@@ -106,6 +203,29 @@ function restoreNestedChildrenVariantOrder(root) {
|
|
|
106
203
|
});
|
|
107
204
|
}
|
|
108
205
|
|
|
206
|
+
function classSegments(className) {
|
|
207
|
+
const segments = [];
|
|
208
|
+
let bracketDepth = 0;
|
|
209
|
+
let segment = '';
|
|
210
|
+
|
|
211
|
+
for (const character of className) {
|
|
212
|
+
if (character === '[') bracketDepth += 1;
|
|
213
|
+
if (character === ']') bracketDepth -= 1;
|
|
214
|
+
|
|
215
|
+
if (character === ':' && bracketDepth === 0) {
|
|
216
|
+
segments.push(segment);
|
|
217
|
+
segment = '';
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
segment += character;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
segments.push(segment);
|
|
225
|
+
|
|
226
|
+
return segments;
|
|
227
|
+
}
|
|
228
|
+
|
|
109
229
|
function nestedContainerPaths(container, depth, containers = []) {
|
|
110
230
|
if (depth === 0) {
|
|
111
231
|
return [{
|
|
@@ -144,6 +264,173 @@ function utilityLayers(root) {
|
|
|
144
264
|
return layers;
|
|
145
265
|
}
|
|
146
266
|
|
|
267
|
+
function componentLayers(root) {
|
|
268
|
+
const layers = [];
|
|
269
|
+
|
|
270
|
+
root.walkAtRules('layer', (layer) => {
|
|
271
|
+
if (layer.params.trim() === 'components') layers.push(layer);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
return layers;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function restoreLegacyComponentLayers(root) {
|
|
278
|
+
utilityLayers(root).forEach((utilityLayer) => {
|
|
279
|
+
const componentNodes = extractLegacyComponentNodes(utilityLayer);
|
|
280
|
+
|
|
281
|
+
if (componentNodes.length === 0) return;
|
|
282
|
+
|
|
283
|
+
const componentLayer = postcss.atRule({
|
|
284
|
+
name: 'layer',
|
|
285
|
+
params: 'components',
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
componentLayer.append(componentNodes);
|
|
289
|
+
utilityLayer.before(componentLayer);
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function extractLegacyComponentNodes(container) {
|
|
294
|
+
return [...(container.nodes ?? [])].flatMap((node) => {
|
|
295
|
+
if (node.type === 'rule') {
|
|
296
|
+
const isLegacyComponent = classNames(node.selector)
|
|
297
|
+
.map(baseUtility)
|
|
298
|
+
.some((utility) => legacyComponentFactoryNames
|
|
299
|
+
.some((factory) => utility.startsWith(`${factory}-`)));
|
|
300
|
+
|
|
301
|
+
if (!isLegacyComponent) return [];
|
|
302
|
+
|
|
303
|
+
node.remove();
|
|
304
|
+
return [node];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (!node.nodes) return [];
|
|
308
|
+
|
|
309
|
+
const childNodes = extractLegacyComponentNodes(node);
|
|
310
|
+
|
|
311
|
+
if (childNodes.length === 0) return [];
|
|
312
|
+
if (node.type === 'atrule' && node.name === 'layer' && node.params === 'utilities') {
|
|
313
|
+
if (node.nodes.length === 0) node.remove();
|
|
314
|
+
|
|
315
|
+
return childNodes;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const wrapper = node.clone();
|
|
319
|
+
|
|
320
|
+
wrapper.removeAll();
|
|
321
|
+
wrapper.append(childNodes);
|
|
322
|
+
if (node.nodes.length === 0) node.remove();
|
|
323
|
+
|
|
324
|
+
return [wrapper];
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function reorderLegacyComponentValueSiblings(container) {
|
|
329
|
+
const groups = new Map();
|
|
330
|
+
|
|
331
|
+
container.nodes?.forEach((node, index) => {
|
|
332
|
+
if (node.type !== 'rule') return;
|
|
333
|
+
|
|
334
|
+
const candidate = classNames(node.selector)
|
|
335
|
+
.map((className) => ({
|
|
336
|
+
className,
|
|
337
|
+
utility: baseUtility(className),
|
|
338
|
+
}))
|
|
339
|
+
.map((entry) => ({
|
|
340
|
+
...entry,
|
|
341
|
+
factory: legacyComponentFactories
|
|
342
|
+
.find(([factory]) => entry.utility.startsWith(`${factory}-`)),
|
|
343
|
+
}))
|
|
344
|
+
.find(({ factory }) => factory);
|
|
345
|
+
|
|
346
|
+
if (!candidate) return;
|
|
347
|
+
|
|
348
|
+
const [factory, valueOrder] = candidate.factory;
|
|
349
|
+
const value = candidate.utility.slice(factory.length + 1);
|
|
350
|
+
const order = valueOrder.get(value);
|
|
351
|
+
|
|
352
|
+
if (order === undefined) return;
|
|
353
|
+
|
|
354
|
+
const variants = classSegments(candidate.className).slice(0, -1).join(':');
|
|
355
|
+
const key = `${factory}\0${variants}`;
|
|
356
|
+
const group = groups.get(key) ?? [];
|
|
357
|
+
|
|
358
|
+
group.push({
|
|
359
|
+
index,
|
|
360
|
+
node,
|
|
361
|
+
order,
|
|
362
|
+
});
|
|
363
|
+
groups.set(key, group);
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
groups.forEach((group) => {
|
|
367
|
+
const sorted = [...group].sort((left, right) => (
|
|
368
|
+
left.order - right.order || left.index - right.index
|
|
369
|
+
));
|
|
370
|
+
|
|
371
|
+
group.forEach(({ index }, sortedIndex) => {
|
|
372
|
+
const node = sorted[sortedIndex].node;
|
|
373
|
+
|
|
374
|
+
container.nodes[index] = node;
|
|
375
|
+
node.parent = container;
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
container.nodes?.forEach((node) => {
|
|
380
|
+
if (node.nodes) reorderLegacyComponentValueSiblings(node);
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function reorderLegacyComponentFactorySiblings(container) {
|
|
385
|
+
const nodes = container.nodes ?? [];
|
|
386
|
+
const componentNodes = nodes.flatMap((node, index) => {
|
|
387
|
+
const selectors = [];
|
|
388
|
+
|
|
389
|
+
if (node.type === 'rule') selectors.push(node.selector);
|
|
390
|
+
node.walkRules?.((rule) => selectors.push(rule.selector));
|
|
391
|
+
|
|
392
|
+
const selectorClassNames = selectors.flatMap(classNames);
|
|
393
|
+
const factory = selectorClassNames
|
|
394
|
+
.map(baseUtility)
|
|
395
|
+
.flatMap((utility) => [...legacyComponentFactoryOrder.keys()]
|
|
396
|
+
.filter((candidate) => utility.startsWith(`${candidate}-`)))
|
|
397
|
+
.at(0);
|
|
398
|
+
|
|
399
|
+
if (!factory) return [];
|
|
400
|
+
|
|
401
|
+
return [{
|
|
402
|
+
index,
|
|
403
|
+
node,
|
|
404
|
+
order: legacyComponentFactoryOrder.get(factory),
|
|
405
|
+
state: selectorClassNames.some((className) => (
|
|
406
|
+
classSegments(className)
|
|
407
|
+
.slice(0, -1)
|
|
408
|
+
.some((segment) => legacyStateVariantOrder.has(segment))
|
|
409
|
+
)),
|
|
410
|
+
}];
|
|
411
|
+
});
|
|
412
|
+
const componentSet = new Set(componentNodes.map(({ node }) => node));
|
|
413
|
+
const sorted = [...componentNodes].sort((left, right) => (
|
|
414
|
+
Number(left.state) - Number(right.state)
|
|
415
|
+
|| left.order - right.order
|
|
416
|
+
|| left.index - right.index
|
|
417
|
+
));
|
|
418
|
+
|
|
419
|
+
if (componentNodes.length > 0) {
|
|
420
|
+
container.nodes = [
|
|
421
|
+
...nodes.filter((node) => !componentSet.has(node)),
|
|
422
|
+
...sorted.map(({ node }) => node),
|
|
423
|
+
];
|
|
424
|
+
container.nodes.forEach((node) => {
|
|
425
|
+
node.parent = container;
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
container.nodes?.forEach((node) => {
|
|
430
|
+
if (node.nodes) reorderLegacyComponentFactorySiblings(node);
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
|
|
147
434
|
function restoreStackedVariantOrder(root) {
|
|
148
435
|
root.walkRules((rule) => {
|
|
149
436
|
const candidate = classNames(rule.selector)
|
|
@@ -255,6 +542,9 @@ function restoreLegacyCoreUtilities(root) {
|
|
|
255
542
|
.find((className) => legacyCoreUtilities.has(className));
|
|
256
543
|
|
|
257
544
|
if (!utility) return;
|
|
545
|
+
if (!candidateRule.selectors.every((selector) => classNames(selector)
|
|
546
|
+
.map(baseUtility)
|
|
547
|
+
.includes(utility))) return;
|
|
258
548
|
|
|
259
549
|
const declarations = legacyCoreUtilities.get(utility);
|
|
260
550
|
const replacedProps = legacyCoreReplacementProps.get(utility);
|
|
@@ -271,18 +561,199 @@ function restoreLegacyCoreUtilities(root) {
|
|
|
271
561
|
.filter((declaration) => replacedProps.has(declaration.prop))
|
|
272
562
|
.forEach((declaration) => declaration.remove());
|
|
273
563
|
declarations.slice().reverse().forEach(([prop, value]) => {
|
|
274
|
-
container.prepend({
|
|
564
|
+
container.prepend({
|
|
565
|
+
prop,
|
|
566
|
+
value,
|
|
567
|
+
important,
|
|
568
|
+
});
|
|
275
569
|
});
|
|
276
570
|
restoredContainers.add(container);
|
|
277
571
|
});
|
|
278
572
|
});
|
|
279
573
|
}
|
|
280
574
|
|
|
575
|
+
function restoreLegacyBorderWidthUtilities(root) {
|
|
576
|
+
root.walkRules((rule) => {
|
|
577
|
+
const isBorderWidthUtility = classNames(rule.selector)
|
|
578
|
+
.map(baseUtility)
|
|
579
|
+
.some((utility) => (
|
|
580
|
+
/^border(?:-[xytrblse])?(?:-(?:0|1|2|4|8|\[[^\]]+]))?$/.test(utility)
|
|
581
|
+
));
|
|
582
|
+
|
|
583
|
+
if (!isBorderWidthUtility) return;
|
|
584
|
+
|
|
585
|
+
rule.walkDecls((declaration) => {
|
|
586
|
+
if (
|
|
587
|
+
declaration.prop === 'border-style'
|
|
588
|
+
|| declaration.prop === '--tw-border-style'
|
|
589
|
+
) declaration.remove();
|
|
590
|
+
});
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
function restoreLegacyTransformUtilities(root) {
|
|
595
|
+
root.walkRules((rule) => {
|
|
596
|
+
const utility = classNames(rule.selector)
|
|
597
|
+
.map(baseUtility)
|
|
598
|
+
.find((className) => (
|
|
599
|
+
/^-?rotate-(?![xy]-)/.test(className)
|
|
600
|
+
|| /^-?translate-[xy]-/.test(className)
|
|
601
|
+
|| /^-?skew-[xy]-/.test(className)
|
|
602
|
+
|| /^scale(?:-[xy])?-/.test(className)
|
|
603
|
+
));
|
|
604
|
+
|
|
605
|
+
if (!utility) return;
|
|
606
|
+
if (!rule.selectors.every((selector) => classNames(selector)
|
|
607
|
+
.map(baseUtility)
|
|
608
|
+
.includes(utility))) return;
|
|
609
|
+
|
|
610
|
+
const declarations = directDeclarations(rule);
|
|
611
|
+
const important = declarations.some((declaration) => declaration.important);
|
|
612
|
+
const rotate = declarations.find((declaration) => declaration.prop === 'rotate');
|
|
613
|
+
const translate = declarations.find((declaration) => declaration.prop === 'translate');
|
|
614
|
+
const scale = declarations.find((declaration) => declaration.prop === 'scale');
|
|
615
|
+
const transform = declarations.find((declaration) => declaration.prop === 'transform');
|
|
616
|
+
|
|
617
|
+
if (rotate) {
|
|
618
|
+
rotate.cloneBefore({
|
|
619
|
+
prop: '--tw-rotate',
|
|
620
|
+
value: rotate.value,
|
|
621
|
+
important,
|
|
622
|
+
});
|
|
623
|
+
rotate.remove();
|
|
624
|
+
}
|
|
625
|
+
translate?.remove();
|
|
626
|
+
scale?.remove();
|
|
627
|
+
transform?.remove();
|
|
628
|
+
declarations
|
|
629
|
+
.filter(({ prop }) => prop === '--tw-scale-z')
|
|
630
|
+
.forEach((declaration) => declaration.remove());
|
|
631
|
+
declarations
|
|
632
|
+
.filter(({ prop }) => prop === '--tw-skew-x' || prop === '--tw-skew-y')
|
|
633
|
+
.forEach((declaration) => {
|
|
634
|
+
declaration.value = declaration.value.replace(/^skew[XY]\((.*)\)$/, '$1');
|
|
635
|
+
});
|
|
636
|
+
rule.append({
|
|
637
|
+
prop: 'transform',
|
|
638
|
+
value: legacyTransformValue,
|
|
639
|
+
important,
|
|
640
|
+
});
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function restoreLegacyGroupHover(root) {
|
|
645
|
+
const restoredByParent = new WeakMap();
|
|
646
|
+
|
|
647
|
+
root.walkRules((rule) => {
|
|
648
|
+
const selectors = rule.selectors.map(restoreLegacyGroupHoverSelector);
|
|
649
|
+
|
|
650
|
+
if (selectors.every((selector, index) => selector === rule.selectors[index])) return;
|
|
651
|
+
|
|
652
|
+
rule.selectors = [...new Set(selectors)];
|
|
653
|
+
|
|
654
|
+
const signature = [
|
|
655
|
+
rule.selector,
|
|
656
|
+
...directDeclarations(rule)
|
|
657
|
+
.map(({ prop, value, important }) => `${prop}:${value}:${important}`),
|
|
658
|
+
].join('\0');
|
|
659
|
+
const restored = restoredByParent.get(rule.parent) ?? new Set();
|
|
660
|
+
|
|
661
|
+
if (restored.has(signature)) {
|
|
662
|
+
rule.remove();
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
restored.add(signature);
|
|
667
|
+
restoredByParent.set(rule.parent, restored);
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
function restoreLegacyPseudoElementStateOrder(root) {
|
|
672
|
+
root.walkRules((rule) => {
|
|
673
|
+
rule.selectors = rule.selectors.map((selector) => {
|
|
674
|
+
const pseudoElement = classNames(selector)
|
|
675
|
+
.flatMap((className) => classSegments(className).slice(0, -1))
|
|
676
|
+
.map((variant) => legacyPseudoElementVariants.get(variant))
|
|
677
|
+
.find((pseudo) => pseudo && selector.includes(pseudo));
|
|
678
|
+
|
|
679
|
+
if (!pseudoElement) return selector;
|
|
680
|
+
|
|
681
|
+
const pseudoIndex = selector.indexOf(pseudoElement);
|
|
682
|
+
const suffix = selector.slice(pseudoIndex + pseudoElement.length);
|
|
683
|
+
|
|
684
|
+
if (!suffix || !/^[:[]/.test(suffix)) return selector;
|
|
685
|
+
|
|
686
|
+
return [
|
|
687
|
+
selector.slice(0, pseudoIndex),
|
|
688
|
+
suffix,
|
|
689
|
+
pseudoElement,
|
|
690
|
+
].join('');
|
|
691
|
+
});
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
function restoreLegacyGroupHoverSelector(selector) {
|
|
696
|
+
const candidate = classNames(selector)
|
|
697
|
+
.map((className) => ({
|
|
698
|
+
className,
|
|
699
|
+
variant: classSegments(className)
|
|
700
|
+
.find((segment) => segment === 'group-hover' || segment.startsWith('group-hover/')),
|
|
701
|
+
}))
|
|
702
|
+
.find(({ variant }) => variant);
|
|
703
|
+
|
|
704
|
+
if (!candidate) return selector;
|
|
705
|
+
|
|
706
|
+
const groupName = `group${candidate.variant.slice('group-hover'.length)}`;
|
|
707
|
+
const groupSelector = `.${escapeClassName(groupName)}`;
|
|
708
|
+
const compoundStart = selector.indexOf(`:is(:where(${groupSelector})`);
|
|
709
|
+
|
|
710
|
+
if (compoundStart < 0) return selector;
|
|
711
|
+
|
|
712
|
+
const compoundEnd = closingParenthesis(selector, compoundStart + 3);
|
|
713
|
+
|
|
714
|
+
if (compoundEnd < 0) return selector;
|
|
715
|
+
|
|
716
|
+
return [
|
|
717
|
+
`${groupSelector}:hover `,
|
|
718
|
+
selector.slice(0, compoundStart),
|
|
719
|
+
selector.slice(compoundEnd + 1),
|
|
720
|
+
].join('');
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
function closingParenthesis(value, openingIndex) {
|
|
724
|
+
let depth = 0;
|
|
725
|
+
|
|
726
|
+
for (let index = openingIndex;index < value.length;index += 1) {
|
|
727
|
+
if (value[index] === '(') depth += 1;
|
|
728
|
+
if (value[index] === ')') depth -= 1;
|
|
729
|
+
if (depth === 0) return index;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
return -1;
|
|
733
|
+
}
|
|
734
|
+
|
|
281
735
|
function classNames(selector) {
|
|
282
736
|
const names = [];
|
|
737
|
+
let attributeDepth = 0;
|
|
283
738
|
|
|
284
|
-
for (let index = 0;
|
|
285
|
-
if (selector[index]
|
|
739
|
+
for (let index = 0;index < selector.length;index += 1) {
|
|
740
|
+
if (selector[index] === '\\') {
|
|
741
|
+
index += 1;
|
|
742
|
+
continue;
|
|
743
|
+
}
|
|
744
|
+
if (selector[index] === '[') {
|
|
745
|
+
attributeDepth += 1;
|
|
746
|
+
continue;
|
|
747
|
+
}
|
|
748
|
+
if (selector[index] === ']') {
|
|
749
|
+
attributeDepth -= 1;
|
|
750
|
+
continue;
|
|
751
|
+
}
|
|
752
|
+
if (
|
|
753
|
+
attributeDepth > 0
|
|
754
|
+
|| selector[index] !== '.'
|
|
755
|
+
|| selector[index - 1] === '\\'
|
|
756
|
+
) continue;
|
|
286
757
|
|
|
287
758
|
let name = '';
|
|
288
759
|
index += 1;
|
|
@@ -335,6 +806,111 @@ function restoreArbitraryValueOrder(root) {
|
|
|
335
806
|
});
|
|
336
807
|
}
|
|
337
808
|
|
|
809
|
+
function reorderLegacyStateVariantSiblings(container) {
|
|
810
|
+
const nodes = container.nodes ?? [];
|
|
811
|
+
const stateNodes = nodes.flatMap((node, index) => {
|
|
812
|
+
if (node.type !== 'rule') return [];
|
|
813
|
+
|
|
814
|
+
const variants = classNames(node.selector)
|
|
815
|
+
.map((className) => classSegments(className)
|
|
816
|
+
.slice(0, -1)
|
|
817
|
+
.filter((segment) => legacyStateVariantOrder.has(segment))
|
|
818
|
+
.map((segment) => legacyStateVariantOrder.get(segment))
|
|
819
|
+
.reverse())
|
|
820
|
+
.find((order) => order.length > 0);
|
|
821
|
+
|
|
822
|
+
if (!variants) return [];
|
|
823
|
+
|
|
824
|
+
return [{
|
|
825
|
+
index,
|
|
826
|
+
node,
|
|
827
|
+
order: variants,
|
|
828
|
+
}];
|
|
829
|
+
});
|
|
830
|
+
const stateSet = new Set(stateNodes.map(({ node }) => node));
|
|
831
|
+
const sorted = [...stateNodes].sort((left, right) => (
|
|
832
|
+
Math.min(...left.order) - Math.min(...right.order)
|
|
833
|
+
|| compareVariantOrders(left.order, right.order)
|
|
834
|
+
|| left.index - right.index
|
|
835
|
+
));
|
|
836
|
+
|
|
837
|
+
if (stateNodes.length > 0) {
|
|
838
|
+
container.nodes = [
|
|
839
|
+
...nodes.filter((node) => !stateSet.has(node)),
|
|
840
|
+
...sorted.map(({ node }) => node),
|
|
841
|
+
];
|
|
842
|
+
container.nodes.forEach((node) => {
|
|
843
|
+
node.parent = container;
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
container.nodes?.forEach((node) => {
|
|
848
|
+
if (node.nodes) reorderLegacyStateVariantSiblings(node);
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
function compareVariantOrders(left, right) {
|
|
853
|
+
const length = Math.max(left.length, right.length);
|
|
854
|
+
|
|
855
|
+
for (let index = 0;index < length;index += 1) {
|
|
856
|
+
const difference = (left[index] ?? -1) - (right[index] ?? -1);
|
|
857
|
+
|
|
858
|
+
if (difference !== 0) return difference;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
return 0;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
function reorderLegacyOutlineSiblings(container) {
|
|
865
|
+
const groups = new Map();
|
|
866
|
+
|
|
867
|
+
container.nodes?.forEach((node, index) => {
|
|
868
|
+
if (node.type !== 'rule') return;
|
|
869
|
+
|
|
870
|
+
const candidate = classNames(node.selector)
|
|
871
|
+
.map((className) => ({
|
|
872
|
+
className,
|
|
873
|
+
utility: baseUtility(className),
|
|
874
|
+
}))
|
|
875
|
+
.find(({ utility }) => (
|
|
876
|
+
utility === 'outline-none'
|
|
877
|
+
|| utility.startsWith('outline-offset-')
|
|
878
|
+
));
|
|
879
|
+
|
|
880
|
+
if (!candidate) return;
|
|
881
|
+
|
|
882
|
+
const variants = classSegments(candidate.className).slice(0, -1).join(':');
|
|
883
|
+
const important = candidate.className.startsWith('!')
|
|
884
|
+
|| candidate.className.endsWith('!');
|
|
885
|
+
const key = `${variants}\0${important}`;
|
|
886
|
+
const group = groups.get(key) ?? [];
|
|
887
|
+
|
|
888
|
+
group.push({
|
|
889
|
+
index,
|
|
890
|
+
node,
|
|
891
|
+
order: candidate.utility === 'outline-none' ? 0 : 1,
|
|
892
|
+
});
|
|
893
|
+
groups.set(key, group);
|
|
894
|
+
});
|
|
895
|
+
|
|
896
|
+
groups.forEach((group) => {
|
|
897
|
+
const sorted = [...group].sort((left, right) => (
|
|
898
|
+
left.order - right.order || left.index - right.index
|
|
899
|
+
));
|
|
900
|
+
|
|
901
|
+
group.forEach(({ index }, sortedIndex) => {
|
|
902
|
+
const node = sorted[sortedIndex].node;
|
|
903
|
+
|
|
904
|
+
container.nodes[index] = node;
|
|
905
|
+
node.parent = container;
|
|
906
|
+
});
|
|
907
|
+
});
|
|
908
|
+
|
|
909
|
+
container.nodes?.forEach((node) => {
|
|
910
|
+
if (node.nodes) reorderLegacyOutlineSiblings(node);
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
|
|
338
914
|
function reorderArbitraryValueSiblings(container) {
|
|
339
915
|
const groups = new Map();
|
|
340
916
|
|
|
@@ -357,7 +933,11 @@ function reorderArbitraryValueSiblings(container) {
|
|
|
357
933
|
const key = `${normalizedCandidate}\0${declarationSignature.join('\0')}`;
|
|
358
934
|
const group = groups.get(key) ?? [];
|
|
359
935
|
|
|
360
|
-
group.push({
|
|
936
|
+
group.push({
|
|
937
|
+
candidate,
|
|
938
|
+
index,
|
|
939
|
+
node,
|
|
940
|
+
});
|
|
361
941
|
groups.set(key, group);
|
|
362
942
|
});
|
|
363
943
|
|
|
@@ -404,6 +984,13 @@ function reorderResponsiveVariantSiblings(container) {
|
|
|
404
984
|
}
|
|
405
985
|
|
|
406
986
|
function responsiveVariantForNode(node) {
|
|
987
|
+
if (node.type === 'atrule' && node.name === 'media') {
|
|
988
|
+
const screen = Object.entries(screens)
|
|
989
|
+
.find(([, minWidth]) => node.params.includes(`min-width: ${minWidth}`));
|
|
990
|
+
|
|
991
|
+
if (screen) return screen[0];
|
|
992
|
+
}
|
|
993
|
+
|
|
407
994
|
const selectors = [];
|
|
408
995
|
|
|
409
996
|
if (node.type === 'rule') selectors.push(node.selector);
|
|
@@ -37,6 +37,7 @@ module.exports = {
|
|
|
37
37
|
color: resolveThemeValue(theme, `textColor.on-${token}` + suffix),
|
|
38
38
|
backgroundColor: resolveThemeValue(theme, `backgroundColor.${token}` + suffix),
|
|
39
39
|
|
|
40
|
+
borderStyle: 'none',
|
|
40
41
|
outlineStyle: 'none',
|
|
41
42
|
|
|
42
43
|
[variants['mobile']]: {
|
|
@@ -77,6 +78,7 @@ module.exports = {
|
|
|
77
78
|
color: resolveThemeValue(theme, `textColor.${token}` + suffix),
|
|
78
79
|
backgroundColor: resolveThemeValue(theme, `backgroundColor.${token}-opacity-0-08` + suffix),
|
|
79
80
|
|
|
81
|
+
borderStyle: 'none',
|
|
80
82
|
outlineStyle: 'none',
|
|
81
83
|
|
|
82
84
|
[variants['mobile']]: {
|
|
@@ -117,6 +119,7 @@ module.exports = {
|
|
|
117
119
|
color: resolveThemeValue(theme, `textColor.${token}` + suffix),
|
|
118
120
|
backgroundColor: 'transparent',
|
|
119
121
|
|
|
122
|
+
borderStyle: 'none',
|
|
120
123
|
outlineStyle: 'none',
|
|
121
124
|
|
|
122
125
|
[variants['mobile']]: {
|
|
@@ -157,6 +160,7 @@ module.exports = {
|
|
|
157
160
|
color: resolveThemeValue(theme, `textColor.${token}` + suffix),
|
|
158
161
|
backgroundColor: 'transparent',
|
|
159
162
|
|
|
163
|
+
borderStyle: 'none',
|
|
160
164
|
outlineStyle: 'none',
|
|
161
165
|
|
|
162
166
|
[variants['mobile']]: {
|