synthesisui 0.16.99 → 0.16.100
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/dist/doctor/transcribe.js +95 -13
- package/package.json +1 -1
|
@@ -241,6 +241,15 @@ const TAILWIND_COLOR = {
|
|
|
241
241
|
white: "#ffffff",
|
|
242
242
|
black: "#000000",
|
|
243
243
|
transparent: "transparent",
|
|
244
|
+
/**
|
|
245
|
+
* KEYWORDS ARE VALUES. `bg-current` is `background-color: currentColor` and
|
|
246
|
+
* `text-inherit` is `color: inherit` - real CSS, no palette needed, and they
|
|
247
|
+
* were being dropped as unreadable. Nine utilities across the owner's library,
|
|
248
|
+
* and `bg-current` is how a spinner takes its colour from its parent - drop it
|
|
249
|
+
* and the spinner is invisible (not-expressed.md, dono, 01/08).
|
|
250
|
+
*/
|
|
251
|
+
current: "currentColor",
|
|
252
|
+
inherit: "inherit",
|
|
244
253
|
// zinc and blue, because a real Select is styled entirely in them and every
|
|
245
254
|
// reference read as nothing (test14, 01/08). Tailwind's own values, verbatim.
|
|
246
255
|
"zinc-50": "#fafafa",
|
|
@@ -351,6 +360,9 @@ const STATE_SPELLING = {
|
|
|
351
360
|
first: "first",
|
|
352
361
|
last: "last",
|
|
353
362
|
empty: "empty",
|
|
363
|
+
/** Base UI's enter/exit faces - `data-[starting-style]:opacity-0`. */
|
|
364
|
+
"starting-style": "startingStyle",
|
|
365
|
+
"ending-style": "endingStyle",
|
|
354
366
|
};
|
|
355
367
|
const DATA_STATE = /^data-\[(?:state=)?([a-z-]+)\]$/;
|
|
356
368
|
/**
|
|
@@ -837,6 +849,33 @@ function refFor(name) {
|
|
|
837
849
|
return `{color.${name}}`;
|
|
838
850
|
return `{color.${m[1]}.${m[2]}}`;
|
|
839
851
|
}
|
|
852
|
+
/** Their breakpoint names, as Tailwind ships them. A project that renames these
|
|
853
|
+
* declares its own, and the census carries that - this is the default ladder. */
|
|
854
|
+
const BREAKPOINT = /^(sm|md|lg|xl|2xl|min-\[[^\]]+\]|max-\[[^\]]+\])$/;
|
|
855
|
+
/**
|
|
856
|
+
* The layer for one set of conditions, created once and reused.
|
|
857
|
+
*
|
|
858
|
+
* Reused rather than appended per utility, because `dark:hover:bg-x` and
|
|
859
|
+
* `dark:hover:border-y` are ONE conditional look with two declarations - two
|
|
860
|
+
* layers with identical conditions would compile to two identical rules.
|
|
861
|
+
*/
|
|
862
|
+
function layerFor(out, when, at) {
|
|
863
|
+
out.layers ??= [];
|
|
864
|
+
const same = out.layers.find((l) => (l.at ?? null) === (at ?? null) &&
|
|
865
|
+
(l.when?.state ?? null) === (when.state ?? null) &&
|
|
866
|
+
(l.when?.within ?? null) === (when.within ?? null) &&
|
|
867
|
+
(l.when?.scheme ?? null) === (when.scheme ?? null) &&
|
|
868
|
+
l.when?.variant == null);
|
|
869
|
+
if (same)
|
|
870
|
+
return same;
|
|
871
|
+
const created = {
|
|
872
|
+
...(Object.keys(when).length > 0 ? { when } : {}),
|
|
873
|
+
...(at ? { at } : {}),
|
|
874
|
+
style: {},
|
|
875
|
+
};
|
|
876
|
+
out.layers.push(created);
|
|
877
|
+
return created;
|
|
878
|
+
}
|
|
840
879
|
/**
|
|
841
880
|
* Read every class in a component's root element and route each declaration by
|
|
842
881
|
* its modifier.
|
|
@@ -1005,20 +1044,63 @@ export function transcribe(classes, declared) {
|
|
|
1005
1044
|
if (rest.length === 0) {
|
|
1006
1045
|
target = isDark ? out.dark : out.base;
|
|
1007
1046
|
}
|
|
1008
|
-
else if (rest.length === 1 && !isDark) {
|
|
1009
|
-
const raw = STATE_SPELLING[rest[0]] != null
|
|
1010
|
-
? rest[0]
|
|
1011
|
-
: (DATA_STATE.exec(rest[0])?.[1] ?? null);
|
|
1012
|
-
const state = raw ? (STATE_SPELLING[raw] ?? null) : null;
|
|
1013
|
-
if (state)
|
|
1014
|
-
target = out.states[state] ?? (out.states[state] = {});
|
|
1015
|
-
else
|
|
1016
|
-
unslotted = true;
|
|
1017
|
-
}
|
|
1018
1047
|
else {
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1048
|
+
/**
|
|
1049
|
+
* EVERY MODIFIER GETS A SLOT, and the contract has had one all along.
|
|
1050
|
+
*
|
|
1051
|
+
* This used to route a bare state and drop everything else, on a comment
|
|
1052
|
+
* that said "a recipe has no slot for it" - true when it was written and
|
|
1053
|
+
* false since the transcription grew `layers`, which hold `scheme`,
|
|
1054
|
+
* `state`, `within` and `at` TOGETHER. Measured on the owner's library:
|
|
1055
|
+
* 29 real decisions dropped on that stale line, most of them a `dark:`
|
|
1056
|
+
* over a state (not-expressed.md, dono, 01/08).
|
|
1057
|
+
*
|
|
1058
|
+
* A recipe that reconstructs the component must carry them, so the router
|
|
1059
|
+
* reads the whole modifier list and only gives up on a modifier that
|
|
1060
|
+
* genuinely has no home - and then it SAYS so.
|
|
1061
|
+
*/
|
|
1062
|
+
const when = {};
|
|
1063
|
+
let at;
|
|
1064
|
+
for (const mod of rest) {
|
|
1065
|
+
/** `group-hover:`, `group-data-[checked]:` - the PARENT's state. */
|
|
1066
|
+
const group = /^group-(.+)$/.exec(mod);
|
|
1067
|
+
const bare = group ? group[1] : mod;
|
|
1068
|
+
const raw = STATE_SPELLING[bare] != null
|
|
1069
|
+
? bare
|
|
1070
|
+
: (DATA_STATE.exec(bare)?.[1] ?? null);
|
|
1071
|
+
const state = raw ? (STATE_SPELLING[raw] ?? null) : null;
|
|
1072
|
+
if (state) {
|
|
1073
|
+
if (group)
|
|
1074
|
+
when.within = state;
|
|
1075
|
+
else
|
|
1076
|
+
when.state = state;
|
|
1077
|
+
continue;
|
|
1078
|
+
}
|
|
1079
|
+
/** `md:`, `lg:` - a breakpoint of theirs, by their own name. */
|
|
1080
|
+
if (BREAKPOINT.test(mod) && !at) {
|
|
1081
|
+
at = mod;
|
|
1082
|
+
continue;
|
|
1083
|
+
}
|
|
1084
|
+
unslotted = true;
|
|
1085
|
+
}
|
|
1086
|
+
if (!unslotted) {
|
|
1087
|
+
if (isDark)
|
|
1088
|
+
when.scheme = "dark";
|
|
1089
|
+
// A bare single state with no scheme keeps its own slot: `states` is what
|
|
1090
|
+
// the compiler and every lens already read, and moving it to a layer
|
|
1091
|
+
// would be a shape change nothing asked for.
|
|
1092
|
+
if (when.state &&
|
|
1093
|
+
!when.within &&
|
|
1094
|
+
!when.scheme &&
|
|
1095
|
+
!at &&
|
|
1096
|
+
rest.length === 1) {
|
|
1097
|
+
target = out.states[when.state] ?? (out.states[when.state] = {});
|
|
1098
|
+
}
|
|
1099
|
+
else {
|
|
1100
|
+
const layer = layerFor(out, when, at);
|
|
1101
|
+
target = layer.style;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1022
1104
|
}
|
|
1023
1105
|
const decl = readUtility(utility, declared);
|
|
1024
1106
|
if (unslotted) {
|
package/package.json
CHANGED