@onereach/styles 27.0.2-beta.6106.0 → 27.0.2-beta.6108.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.6108.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.6108.0",
|
|
45
45
|
"postcss-nested": "6.2.0",
|
|
46
46
|
"tailwindcss": "4.3.2"
|
|
47
47
|
},
|
|
@@ -4,6 +4,8 @@ const postcssNested = require('postcss-nested');
|
|
|
4
4
|
const screens = require('../screens.json');
|
|
5
5
|
const {
|
|
6
6
|
importantMarker,
|
|
7
|
+
legacyImportantClasses,
|
|
8
|
+
toTailwind4ImportantClass,
|
|
7
9
|
} = require('../tailwind/compatibility/important');
|
|
8
10
|
const {
|
|
9
11
|
legacySpacingAliasEntries,
|
|
@@ -16,6 +18,9 @@ const legacyStateVariantOrder = new Map(
|
|
|
16
18
|
Object.keys(coreVariants)
|
|
17
19
|
.map((variant, index) => [variant, index]),
|
|
18
20
|
);
|
|
21
|
+
const legacyImportantSuffixClasses = new Set(
|
|
22
|
+
legacyImportantClasses.map(toTailwind4ImportantClass),
|
|
23
|
+
);
|
|
19
24
|
|
|
20
25
|
const legacySpacingAliases = legacySpacingAliasEntries(spacing)
|
|
21
26
|
.sort(([, left], [, right]) => right.length - left.length);
|
|
@@ -144,6 +149,7 @@ function tailwindV4Compat() {
|
|
|
144
149
|
await flattenUtilityLayers(root);
|
|
145
150
|
|
|
146
151
|
utilityLayers(root).forEach((layer) => {
|
|
152
|
+
restoreLegacyImportantClassNames(layer);
|
|
147
153
|
restoreLegacyGroupHover(layer);
|
|
148
154
|
restoreLegacyPseudoElementStateOrder(layer);
|
|
149
155
|
restoreStackedVariantOrder(layer);
|
|
@@ -163,6 +169,7 @@ function tailwindV4Compat() {
|
|
|
163
169
|
reorderLegacyComponentFactorySiblings(layer);
|
|
164
170
|
reorderResponsiveVariantSiblings(layer);
|
|
165
171
|
});
|
|
172
|
+
restoreLegacyImportantLayers(root);
|
|
166
173
|
},
|
|
167
174
|
};
|
|
168
175
|
}
|
|
@@ -174,7 +181,7 @@ function restoreNestedVariantOrder(root) {
|
|
|
174
181
|
const variants = classSegments(className).slice(0, -1);
|
|
175
182
|
const arbitraryIndex = variants.findIndex((variant) => variant.startsWith('[&'));
|
|
176
183
|
|
|
177
|
-
return variants.includes('children') || arbitraryIndex
|
|
184
|
+
return variants.includes('children') || arbitraryIndex >= 0;
|
|
178
185
|
});
|
|
179
186
|
|
|
180
187
|
if (!candidate) return;
|
|
@@ -533,6 +540,89 @@ function restoreImportantDeclarations(root) {
|
|
|
533
540
|
});
|
|
534
541
|
}
|
|
535
542
|
|
|
543
|
+
function restoreLegacyImportantClassNames(root) {
|
|
544
|
+
root.walkRules((rule) => {
|
|
545
|
+
const aliases = rule.selectors.flatMap((selector) => (
|
|
546
|
+
classNames(selector)
|
|
547
|
+
.filter((className) => legacyImportantSuffixClasses.has(className))
|
|
548
|
+
.map((className) => {
|
|
549
|
+
const segments = classSegments(className);
|
|
550
|
+
const utility = segments.pop().slice(0, -1);
|
|
551
|
+
const legacyClassName = [...segments, `!${utility}`].join(':');
|
|
552
|
+
|
|
553
|
+
return selector.replace(
|
|
554
|
+
`.${escapeClassName(className)}`,
|
|
555
|
+
`.${escapeClassName(legacyClassName)}`,
|
|
556
|
+
);
|
|
557
|
+
})
|
|
558
|
+
));
|
|
559
|
+
|
|
560
|
+
const uniqueAliases = [...new Set(aliases)];
|
|
561
|
+
|
|
562
|
+
if (uniqueAliases.length === 0) return;
|
|
563
|
+
|
|
564
|
+
const aliasRule = rule.clone({ selectors: uniqueAliases });
|
|
565
|
+
|
|
566
|
+
aliasRule.raws.onereachLegacyImportant = true;
|
|
567
|
+
rule.after(aliasRule);
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
function restoreLegacyImportantLayers(root) {
|
|
572
|
+
utilityLayers(root).forEach((utilityLayer) => {
|
|
573
|
+
const legacyImportantNodes = extractMarkedLegacyImportantNodes(utilityLayer);
|
|
574
|
+
|
|
575
|
+
if (legacyImportantNodes.length === 0) return;
|
|
576
|
+
|
|
577
|
+
let componentLayer = utilityLayer.prev();
|
|
578
|
+
|
|
579
|
+
if (
|
|
580
|
+
componentLayer?.type !== 'atrule'
|
|
581
|
+
|| componentLayer.name !== 'layer'
|
|
582
|
+
|| componentLayer.params.trim() !== 'components'
|
|
583
|
+
) {
|
|
584
|
+
componentLayer = postcss.atRule({
|
|
585
|
+
name: 'layer',
|
|
586
|
+
params: 'components',
|
|
587
|
+
});
|
|
588
|
+
utilityLayer.before(componentLayer);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
componentLayer.append(legacyImportantNodes);
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
function extractMarkedLegacyImportantNodes(container) {
|
|
596
|
+
return [...(container.nodes ?? [])].flatMap((node) => {
|
|
597
|
+
if (node.type === 'rule') {
|
|
598
|
+
if (!node.raws.onereachLegacyImportant) return [];
|
|
599
|
+
|
|
600
|
+
delete node.raws.onereachLegacyImportant;
|
|
601
|
+
node.remove();
|
|
602
|
+
return [node];
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
if (!node.nodes) return [];
|
|
606
|
+
|
|
607
|
+
const childNodes = extractMarkedLegacyImportantNodes(node);
|
|
608
|
+
|
|
609
|
+
if (childNodes.length === 0) return [];
|
|
610
|
+
if (node.type === 'atrule' && node.name === 'layer' && node.params === 'utilities') {
|
|
611
|
+
if (node.nodes.length === 0) node.remove();
|
|
612
|
+
|
|
613
|
+
return childNodes;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
const wrapper = node.clone();
|
|
617
|
+
|
|
618
|
+
wrapper.removeAll();
|
|
619
|
+
wrapper.append(childNodes);
|
|
620
|
+
if (node.nodes.length === 0) node.remove();
|
|
621
|
+
|
|
622
|
+
return [wrapper];
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
|
|
536
626
|
function restoreLegacyCoreUtilities(root) {
|
|
537
627
|
const restoredContainers = new WeakSet();
|
|
538
628
|
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
const importantMarker = '--or-tailwind-v3-important';
|
|
2
|
+
const legacyImportantClasses = [
|
|
3
|
+
'dark:disabled:!bg-on-disabled-dark',
|
|
4
|
+
'dark:invalid:read-only:!border-transparent',
|
|
5
|
+
'dark:read-only:!border-transparent',
|
|
6
|
+
'disabled:!bg-on-disabled',
|
|
7
|
+
'first:children:!ms-0',
|
|
8
|
+
'invalid:!border-dashed',
|
|
9
|
+
'invalid:read-only:!border-transparent',
|
|
10
|
+
'last:children:!me-0',
|
|
11
|
+
'md:!my-0',
|
|
12
|
+
'md:!pb-[7px]',
|
|
13
|
+
'md:!pt-[6px]',
|
|
14
|
+
'read-only:!border-transparent',
|
|
15
|
+
];
|
|
2
16
|
|
|
3
17
|
function markImportant(declarations) {
|
|
4
18
|
return {
|
|
@@ -7,7 +21,16 @@ function markImportant(declarations) {
|
|
|
7
21
|
};
|
|
8
22
|
}
|
|
9
23
|
|
|
24
|
+
function toTailwind4ImportantClass(className) {
|
|
25
|
+
const segments = className.split(':');
|
|
26
|
+
const utility = segments.pop();
|
|
27
|
+
|
|
28
|
+
return [...segments, `${utility.replace(/^!/, '')}!`].join(':');
|
|
29
|
+
}
|
|
30
|
+
|
|
10
31
|
module.exports = {
|
|
11
32
|
importantMarker,
|
|
33
|
+
legacyImportantClasses,
|
|
12
34
|
markImportant,
|
|
35
|
+
toTailwind4ImportantClass,
|
|
13
36
|
};
|
|
@@ -27,6 +27,10 @@ const spacingUtilities = [
|
|
|
27
27
|
'max-w',
|
|
28
28
|
'max-h',
|
|
29
29
|
];
|
|
30
|
+
const {
|
|
31
|
+
legacyImportantClasses,
|
|
32
|
+
toTailwind4ImportantClass,
|
|
33
|
+
} = require('./important');
|
|
30
34
|
|
|
31
35
|
const childrenUtilities = spacingUtilities.filter((utility) => (
|
|
32
36
|
/^(?:p[trblxyse]?|m[trblxyse]?)$/.test(utility)
|
|
@@ -38,6 +42,10 @@ const stateVariants = ['dark', 'hover', 'mobile', 'desktop'];
|
|
|
38
42
|
function generateLegacyCompatibilityCss({ spacing, screens }) {
|
|
39
43
|
const candidates = new Set();
|
|
40
44
|
|
|
45
|
+
legacyImportantClasses.forEach((className) => {
|
|
46
|
+
candidates.add(toTailwind4ImportantClass(className));
|
|
47
|
+
});
|
|
48
|
+
|
|
41
49
|
legacySpacingAliasEntries(spacing).forEach(([, alias]) => {
|
|
42
50
|
spacingUtilities.forEach((utility) => {
|
|
43
51
|
addCandidateVariants(candidates, `${utility}-${alias}`, screens);
|