@unpunnyfuns/swatchbook-blocks 0.20.4 → 0.50.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/dist/index.d.mts +8 -8
- package/dist/index.mjs +115 -169
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +10 -0
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { Fragment, createContext, useCallback, useContext, useEffect, useMemo, u
|
|
|
4
4
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { makeCSSVar } from "@terrazzo/token-tools/css";
|
|
6
6
|
import { addons } from "storybook/preview-api";
|
|
7
|
-
import { axes, css, cssVarPrefix,
|
|
7
|
+
import { axes, css, cssVarPrefix, defaultPermutation, diagnostics, listing, permutations, permutationsResolved, presets } from "virtual:swatchbook/tokens";
|
|
8
8
|
import { fuzzyFilter } from "@unpunnyfuns/swatchbook-core/fuzzy";
|
|
9
9
|
import cx from "clsx";
|
|
10
10
|
import { analyzeAxisVariance } from "@unpunnyfuns/swatchbook-core/variance";
|
|
@@ -203,11 +203,9 @@ function EmptyState({ children }) {
|
|
|
203
203
|
//#endregion
|
|
204
204
|
//#region src/internal/channel-globals.ts
|
|
205
205
|
const AXES_GLOBAL_KEY = "swatchbookAxes";
|
|
206
|
-
const THEME_GLOBAL_KEY = "swatchbookTheme";
|
|
207
206
|
const COLOR_FORMAT_GLOBAL_KEY = "swatchbookColorFormat";
|
|
208
207
|
let snapshot$1 = {
|
|
209
208
|
axes: null,
|
|
210
|
-
theme: null,
|
|
211
209
|
format: null
|
|
212
210
|
};
|
|
213
211
|
const listeners$1 = /* @__PURE__ */ new Set();
|
|
@@ -228,11 +226,6 @@ function ensureSubscribed$1() {
|
|
|
228
226
|
...next,
|
|
229
227
|
axes: nextAxes
|
|
230
228
|
};
|
|
231
|
-
const nextTheme = globals[THEME_GLOBAL_KEY];
|
|
232
|
-
if (typeof nextTheme === "string") next = {
|
|
233
|
-
...next,
|
|
234
|
-
theme: nextTheme
|
|
235
|
-
};
|
|
236
229
|
const nextFormat = globals[COLOR_FORMAT_GLOBAL_KEY];
|
|
237
230
|
if (isColorFormat(nextFormat)) next = {
|
|
238
231
|
...next,
|
|
@@ -297,13 +290,13 @@ function useOptionalSwatchbookData() {
|
|
|
297
290
|
* `useGlobals` so the same hook works in autodocs / MDX renders where the
|
|
298
291
|
* preview-hooks context isn't available.
|
|
299
292
|
*/
|
|
300
|
-
const
|
|
301
|
-
function
|
|
302
|
-
return useContext(
|
|
293
|
+
const PermutationContext = createContext("");
|
|
294
|
+
function useActivePermutation() {
|
|
295
|
+
return useContext(PermutationContext);
|
|
303
296
|
}
|
|
304
297
|
/**
|
|
305
298
|
* Active axis tuple for the current story/docs render — `Record<axisName,
|
|
306
|
-
* contextName>`. Derived from the same input as {@link
|
|
299
|
+
* contextName>`. Derived from the same input as {@link PermutationContext}; split
|
|
307
300
|
* out so consumers needing per-axis info (toolbar, panel, tuple-aware
|
|
308
301
|
* blocks) don't have to reparse the composed permutation ID.
|
|
309
302
|
*/
|
|
@@ -350,9 +343,9 @@ const TOKENS_UPDATED_EVENT = "swatchbook/tokens-updated";
|
|
|
350
343
|
let snapshot = {
|
|
351
344
|
axes,
|
|
352
345
|
presets,
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
346
|
+
permutations,
|
|
347
|
+
defaultPermutation,
|
|
348
|
+
permutationsResolved,
|
|
356
349
|
diagnostics,
|
|
357
350
|
css,
|
|
358
351
|
cssVarPrefix,
|
|
@@ -368,9 +361,9 @@ function ensureSubscribed() {
|
|
|
368
361
|
snapshot = {
|
|
369
362
|
axes: payload.axes ?? snapshot.axes,
|
|
370
363
|
presets: payload.presets ?? snapshot.presets,
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
364
|
+
permutations: payload.permutations ?? snapshot.permutations,
|
|
365
|
+
defaultPermutation: payload.defaultPermutation ?? snapshot.defaultPermutation,
|
|
366
|
+
permutationsResolved: payload.permutationsResolved ?? snapshot.permutationsResolved,
|
|
374
367
|
diagnostics: payload.diagnostics ?? snapshot.diagnostics,
|
|
375
368
|
css: payload.css ?? snapshot.css,
|
|
376
369
|
cssVarPrefix: payload.cssVarPrefix ?? snapshot.cssVarPrefix,
|
|
@@ -412,9 +405,6 @@ function defaultTuple(axes) {
|
|
|
412
405
|
for (const axis of axes) out[axis.name] = axis.default;
|
|
413
406
|
return out;
|
|
414
407
|
}
|
|
415
|
-
function tupleForName(themesList, name) {
|
|
416
|
-
return themesList.find((t) => t.name === name)?.input;
|
|
417
|
-
}
|
|
418
408
|
function tuplesEqual(a, b) {
|
|
419
409
|
const keys = new Set([...Object.keys(a), ...Object.keys(b)]);
|
|
420
410
|
for (const k of keys) if (a[k] !== b[k]) return false;
|
|
@@ -425,12 +415,12 @@ function nameForTuple(themesList, tuple) {
|
|
|
425
415
|
}
|
|
426
416
|
function snapshotToData(snapshot) {
|
|
427
417
|
return {
|
|
428
|
-
|
|
418
|
+
activePermutation: snapshot.activePermutation,
|
|
429
419
|
activeAxes: { ...snapshot.activeAxes },
|
|
430
420
|
axes: snapshot.axes,
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
resolved: snapshot.
|
|
421
|
+
permutations: snapshot.permutations,
|
|
422
|
+
permutationsResolved: snapshot.permutationsResolved,
|
|
423
|
+
resolved: snapshot.permutationsResolved[snapshot.activePermutation] ?? {},
|
|
434
424
|
diagnostics: snapshot.diagnostics,
|
|
435
425
|
cssVarPrefix: snapshot.cssVarPrefix,
|
|
436
426
|
listing: snapshot.listing ?? {}
|
|
@@ -454,7 +444,7 @@ function useProject() {
|
|
|
454
444
|
return snapshot !== null ? snapshotToData(snapshot) : fallback;
|
|
455
445
|
}
|
|
456
446
|
function useVirtualModuleFallback(enabled) {
|
|
457
|
-
const
|
|
447
|
+
const contextPermutation = useActivePermutation();
|
|
458
448
|
const contextAxes = useActiveAxes();
|
|
459
449
|
const channelGlobals = useChannelGlobals();
|
|
460
450
|
/**
|
|
@@ -470,17 +460,15 @@ function useVirtualModuleFallback(enabled) {
|
|
|
470
460
|
ensureStylesheet(tokens.css);
|
|
471
461
|
}, [enabled, tokens.css]);
|
|
472
462
|
const activeAxes = Object.keys(contextAxes).length > 0 ? { ...contextAxes } : channelGlobals.axes ?? defaultTuple(tokens.axes);
|
|
473
|
-
const derivedName = nameForTuple(tokens.
|
|
474
|
-
const
|
|
475
|
-
const fallbackTupleName = channelTheme && tupleForName(tokens.themes, channelTheme) ? channelTheme : null;
|
|
476
|
-
const activeTheme = contextTheme || derivedName || fallbackTupleName || channelTheme || tokens.defaultTheme || tokens.themes[0]?.name || "";
|
|
463
|
+
const derivedName = nameForTuple(tokens.permutations, activeAxes);
|
|
464
|
+
const activePermutation = contextPermutation || derivedName || tokens.defaultPermutation || tokens.permutations[0]?.name || "";
|
|
477
465
|
return {
|
|
478
|
-
|
|
466
|
+
activePermutation,
|
|
479
467
|
activeAxes,
|
|
480
468
|
axes: tokens.axes,
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
resolved: tokens.
|
|
469
|
+
permutations: tokens.permutations,
|
|
470
|
+
permutationsResolved: tokens.permutationsResolved,
|
|
471
|
+
resolved: tokens.permutationsResolved[activePermutation] ?? {},
|
|
484
472
|
diagnostics: tokens.diagnostics,
|
|
485
473
|
cssVarPrefix: tokens.cssVarPrefix,
|
|
486
474
|
listing: tokens.listing
|
|
@@ -742,7 +730,7 @@ function formatSubColor$1(raw, format) {
|
|
|
742
730
|
}
|
|
743
731
|
function BorderPreview({ filter, caption, sortBy = "path", sortDir = "asc" }) {
|
|
744
732
|
const project = useProject();
|
|
745
|
-
const { resolved,
|
|
733
|
+
const { resolved, activePermutation, cssVarPrefix } = project;
|
|
746
734
|
const colorFormat = useColorFormat();
|
|
747
735
|
const rows = useMemo(() => {
|
|
748
736
|
return sortTokens(Object.entries(resolved).filter(([path, token]) => {
|
|
@@ -763,16 +751,16 @@ function BorderPreview({ filter, caption, sortBy = "path", sortDir = "asc" }) {
|
|
|
763
751
|
sortBy,
|
|
764
752
|
sortDir
|
|
765
753
|
]);
|
|
766
|
-
const captionText = caption ?? `${rows.length} border${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${
|
|
754
|
+
const captionText = caption ?? `${rows.length} border${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${activePermutation}`;
|
|
767
755
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
768
|
-
...themeAttrs(cssVarPrefix,
|
|
756
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
769
757
|
children: /* @__PURE__ */ jsx("div", {
|
|
770
758
|
className: "sb-block__empty",
|
|
771
759
|
children: "No border tokens match this filter."
|
|
772
760
|
})
|
|
773
761
|
});
|
|
774
762
|
return /* @__PURE__ */ jsxs("div", {
|
|
775
|
-
...themeAttrs(cssVarPrefix,
|
|
763
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
776
764
|
children: [/* @__PURE__ */ jsx("div", {
|
|
777
765
|
className: "sb-block__caption",
|
|
778
766
|
children: captionText
|
|
@@ -835,7 +823,7 @@ function fixedPrefixLength(filter) {
|
|
|
835
823
|
}
|
|
836
824
|
function ColorPalette({ filter, groupBy, caption, sortBy = "path", sortDir = "asc" }) {
|
|
837
825
|
const project = useProject();
|
|
838
|
-
const { resolved,
|
|
826
|
+
const { resolved, activePermutation, cssVarPrefix } = project;
|
|
839
827
|
const colorFormat = useColorFormat();
|
|
840
828
|
const groups = useMemo(() => {
|
|
841
829
|
const entries = sortTokens(Object.entries(resolved).filter(([path, token]) => {
|
|
@@ -874,16 +862,16 @@ function ColorPalette({ filter, groupBy, caption, sortBy = "path", sortDir = "as
|
|
|
874
862
|
sortDir
|
|
875
863
|
]);
|
|
876
864
|
const totalCount = groups.reduce((acc, [, swatches]) => acc + swatches.length, 0);
|
|
877
|
-
const captionText = caption ?? `${totalCount} color${totalCount === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${
|
|
865
|
+
const captionText = caption ?? `${totalCount} color${totalCount === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${activePermutation}`;
|
|
878
866
|
if (totalCount === 0) return /* @__PURE__ */ jsx("div", {
|
|
879
|
-
...themeAttrs(cssVarPrefix,
|
|
867
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
880
868
|
children: /* @__PURE__ */ jsx("div", {
|
|
881
869
|
className: "sb-block__empty",
|
|
882
870
|
children: "No color tokens match this filter."
|
|
883
871
|
})
|
|
884
872
|
});
|
|
885
873
|
return /* @__PURE__ */ jsxs("div", {
|
|
886
|
-
...themeAttrs(cssVarPrefix,
|
|
874
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
887
875
|
children: [/* @__PURE__ */ jsx("div", {
|
|
888
876
|
className: "sb-block__caption",
|
|
889
877
|
children: captionText
|
|
@@ -974,7 +962,7 @@ const BASE_LABEL = "base";
|
|
|
974
962
|
const COLUMN_COUNT = 6;
|
|
975
963
|
function ColorTable({ filter, caption, sortBy = "path", sortDir = "asc", searchable = true, onSelect, variants }) {
|
|
976
964
|
const project = useProject();
|
|
977
|
-
const { resolved,
|
|
965
|
+
const { resolved, activePermutation, cssVarPrefix } = project;
|
|
978
966
|
const colorFormat = useColorFormat();
|
|
979
967
|
const [query, setQuery] = useState("");
|
|
980
968
|
const [selectedByBase, setSelectedByBase] = useState({});
|
|
@@ -1061,16 +1049,16 @@ function ColorTable({ filter, caption, sortBy = "path", sortDir = "asc", searcha
|
|
|
1061
1049
|
}));
|
|
1062
1050
|
}, []);
|
|
1063
1051
|
const matchSuffix = searchable && query.trim() !== "" ? ` · ${visibleGroups.length} matching "${query.trim()}"` : "";
|
|
1064
|
-
const captionText = caption ?? `${totalTokens} color${totalTokens === 1 ? "" : "s"} across ${groups.length} group${groups.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""}${matchSuffix} · ${
|
|
1052
|
+
const captionText = caption ?? `${totalTokens} color${totalTokens === 1 ? "" : "s"} across ${groups.length} group${groups.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""}${matchSuffix} · ${activePermutation}`;
|
|
1065
1053
|
if (groups.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
1066
|
-
...themeAttrs(cssVarPrefix,
|
|
1054
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
1067
1055
|
children: /* @__PURE__ */ jsx("div", {
|
|
1068
1056
|
className: "sb-block__empty",
|
|
1069
1057
|
children: "No color tokens match this filter."
|
|
1070
1058
|
})
|
|
1071
1059
|
});
|
|
1072
1060
|
return /* @__PURE__ */ jsxs("div", {
|
|
1073
|
-
...themeAttrs(cssVarPrefix,
|
|
1061
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
1074
1062
|
children: [searchable && /* @__PURE__ */ jsx("div", {
|
|
1075
1063
|
className: "sb-color-table__search",
|
|
1076
1064
|
children: /* @__PURE__ */ jsx("input", {
|
|
@@ -1492,12 +1480,12 @@ function summaryVariant(diagnostics) {
|
|
|
1492
1480
|
* on their own MDX pages.
|
|
1493
1481
|
*/
|
|
1494
1482
|
function Diagnostics({ caption } = {}) {
|
|
1495
|
-
const {
|
|
1483
|
+
const { activePermutation, cssVarPrefix, diagnostics } = useProject();
|
|
1496
1484
|
const hasErrorsOrWarnings = diagnostics.some((d) => d.severity === "error" || d.severity === "warn");
|
|
1497
1485
|
const headingText = caption ?? `Diagnostics · ${summaryText(diagnostics)}`;
|
|
1498
1486
|
const variant = summaryVariant(diagnostics);
|
|
1499
1487
|
return /* @__PURE__ */ jsx("div", {
|
|
1500
|
-
...themeAttrs(cssVarPrefix,
|
|
1488
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
1501
1489
|
"data-testid": "diagnostics",
|
|
1502
1490
|
children: /* @__PURE__ */ jsxs("details", {
|
|
1503
1491
|
open: hasErrorsOrWarnings,
|
|
@@ -1599,31 +1587,17 @@ function DimensionBar({ path, kind = "length" }) {
|
|
|
1599
1587
|
//#endregion
|
|
1600
1588
|
//#region src/internal/format-token-value.ts
|
|
1601
1589
|
/**
|
|
1602
|
-
*
|
|
1603
|
-
*
|
|
1604
|
-
*
|
|
1605
|
-
*
|
|
1606
|
-
* Shape by type:
|
|
1607
|
-
* - `color` → `formatColor(value, colorFormat)` — e.g. `#3b82f6`, `oklch(...)`, `raw` JSON.
|
|
1608
|
-
* - `dimension|duration` → `value + unit` — e.g. `16px`, `200ms`.
|
|
1609
|
-
* - `fontFamily` → string or array joined with `, `.
|
|
1610
|
-
* - `fontWeight` → primitive.
|
|
1611
|
-
* - `cubicBezier` → `cubic-bezier(a, b, c, d)`.
|
|
1612
|
-
* - `strokeStyle` → primitive string, or `dashed · dashArray · lineCap` when it's the object shape.
|
|
1613
|
-
* - `shadow` → one or more `offsetX offsetY blur spread color` layers joined with `, `.
|
|
1614
|
-
* - `border` → `width style color`.
|
|
1615
|
-
* - `transition` → `duration easing [delay]`.
|
|
1616
|
-
* - `typography` → `family / size / line-height / weight`.
|
|
1617
|
-
* - `gradient` → `stops joined with →` — compact representation, not a CSS gradient string (those live in GradientPalette's preview).
|
|
1618
|
-
*
|
|
1619
|
-
* Unknown object shapes fall through to truncated JSON.
|
|
1590
|
+
* Single-line display string for any DTCG token `$value`. Prefers
|
|
1591
|
+
* plugin-css's `previewValue` from the Token Listing; for color
|
|
1592
|
+
* tokens only when the toolbar format is hex (other formats route
|
|
1593
|
+
* through local colorjs.io).
|
|
1620
1594
|
*/
|
|
1621
1595
|
function formatTokenValue(value, $type, colorFormat, listingEntry) {
|
|
1622
1596
|
if (value == null) return "";
|
|
1623
1597
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return String(value);
|
|
1624
1598
|
const preview = listingEntry?.previewValue;
|
|
1625
1599
|
if (preview !== void 0) {
|
|
1626
|
-
const previewStr = typeof preview === "string" ? preview : String(preview);
|
|
1600
|
+
const previewStr = typeof preview === "string" ? cleanFloatNoise(preview) : String(preview);
|
|
1627
1601
|
if ($type !== "color") return previewStr;
|
|
1628
1602
|
if (colorFormat === "hex") return previewStr;
|
|
1629
1603
|
}
|
|
@@ -1641,9 +1615,6 @@ function formatTokenValue(value, $type, colorFormat, listingEntry) {
|
|
|
1641
1615
|
case "strokeStyle": return formatStrokeStyle(value);
|
|
1642
1616
|
case "shadow": return formatShadow(value, colorFormat);
|
|
1643
1617
|
case "border": return formatBorder(value, colorFormat);
|
|
1644
|
-
case "transition": return formatTransition(value);
|
|
1645
|
-
case "typography": return formatTypography(value);
|
|
1646
|
-
case "gradient": return formatGradient(value, colorFormat);
|
|
1647
1618
|
default: return formatUnknown(value);
|
|
1648
1619
|
}
|
|
1649
1620
|
}
|
|
@@ -1655,6 +1626,9 @@ function formatDimension$1(v) {
|
|
|
1655
1626
|
}
|
|
1656
1627
|
return formatUnknown(v);
|
|
1657
1628
|
}
|
|
1629
|
+
function cleanFloatNoise(s) {
|
|
1630
|
+
return s.replace(/-?\d+\.\d{8,}/g, (m) => `${+Number(m).toFixed(3)}`);
|
|
1631
|
+
}
|
|
1658
1632
|
function formatFontFamily$1(v) {
|
|
1659
1633
|
if (typeof v === "string") return v;
|
|
1660
1634
|
if (Array.isArray(v)) return v.map(String).join(", ");
|
|
@@ -1703,35 +1677,6 @@ function formatBorder(v, colorFormat) {
|
|
|
1703
1677
|
formatColor(b["color"], colorFormat).value
|
|
1704
1678
|
].filter((p) => p !== "").join(" ");
|
|
1705
1679
|
}
|
|
1706
|
-
function formatTransition(v) {
|
|
1707
|
-
if (!v || typeof v !== "object") return formatUnknown(v);
|
|
1708
|
-
const t = v;
|
|
1709
|
-
const duration = formatDimension$1(t["duration"]);
|
|
1710
|
-
const easing = formatPrimitive$1(t["timingFunction"]);
|
|
1711
|
-
const delay = formatDimension$1(t["delay"]);
|
|
1712
|
-
const parts = [duration, easing];
|
|
1713
|
-
if (!/^0\D/.test(delay) && delay !== "") parts.push(delay);
|
|
1714
|
-
return parts.filter((p) => p !== "").join(" ");
|
|
1715
|
-
}
|
|
1716
|
-
function formatTypography(v) {
|
|
1717
|
-
if (!v || typeof v !== "object") return formatUnknown(v);
|
|
1718
|
-
const t = v;
|
|
1719
|
-
return [
|
|
1720
|
-
formatFontFamily$1(t["fontFamily"]),
|
|
1721
|
-
formatDimension$1(t["fontSize"]),
|
|
1722
|
-
formatPrimitive$1(t["lineHeight"]),
|
|
1723
|
-
formatPrimitive$1(t["fontWeight"])
|
|
1724
|
-
].filter((p) => p !== "").join(" / ");
|
|
1725
|
-
}
|
|
1726
|
-
function formatGradient(v, colorFormat) {
|
|
1727
|
-
if (!Array.isArray(v) || v.length === 0) return formatUnknown(v);
|
|
1728
|
-
return v.map((stop) => {
|
|
1729
|
-
if (!stop || typeof stop !== "object") return formatUnknown(stop);
|
|
1730
|
-
const s = stop;
|
|
1731
|
-
const position = typeof s["position"] === "number" ? `${Math.round(s["position"] * 100)}%` : "?";
|
|
1732
|
-
return `${formatColor(s["color"], colorFormat).value} ${position}`;
|
|
1733
|
-
}).join(" → ");
|
|
1734
|
-
}
|
|
1735
1680
|
function formatUnknown(v) {
|
|
1736
1681
|
if (v == null) return "";
|
|
1737
1682
|
if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") return String(v);
|
|
@@ -1757,7 +1702,7 @@ function toPixels(raw) {
|
|
|
1757
1702
|
}
|
|
1758
1703
|
function DimensionScale({ filter, kind = "length", caption, sortBy = "value", sortDir = "asc" }) {
|
|
1759
1704
|
const project = useProject();
|
|
1760
|
-
const { resolved,
|
|
1705
|
+
const { resolved, activePermutation, cssVarPrefix } = project;
|
|
1761
1706
|
const rows = useMemo(() => {
|
|
1762
1707
|
return sortTokens(Object.entries(resolved).filter(([path, token]) => {
|
|
1763
1708
|
if (token.$type !== "dimension") return false;
|
|
@@ -1782,16 +1727,16 @@ function DimensionScale({ filter, kind = "length", caption, sortBy = "value", so
|
|
|
1782
1727
|
sortBy,
|
|
1783
1728
|
sortDir
|
|
1784
1729
|
]);
|
|
1785
|
-
const captionText = caption ?? `${rows.length} dimension${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${
|
|
1730
|
+
const captionText = caption ?? `${rows.length} dimension${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${activePermutation}`;
|
|
1786
1731
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
1787
|
-
...themeAttrs(cssVarPrefix,
|
|
1732
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
1788
1733
|
children: /* @__PURE__ */ jsx("div", {
|
|
1789
1734
|
className: "sb-block__empty",
|
|
1790
1735
|
children: "No dimension tokens match this filter."
|
|
1791
1736
|
})
|
|
1792
1737
|
});
|
|
1793
1738
|
return /* @__PURE__ */ jsxs("div", {
|
|
1794
|
-
...themeAttrs(cssVarPrefix,
|
|
1739
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
1795
1740
|
children: [/* @__PURE__ */ jsx("div", {
|
|
1796
1741
|
className: "sb-block__caption",
|
|
1797
1742
|
children: captionText
|
|
@@ -1839,7 +1784,7 @@ function stackString(raw) {
|
|
|
1839
1784
|
}
|
|
1840
1785
|
function FontFamilySample({ filter, sample = "The quick brown fox jumps over the lazy dog.", caption, sortBy = "path", sortDir = "asc" }) {
|
|
1841
1786
|
const project = useProject();
|
|
1842
|
-
const { resolved,
|
|
1787
|
+
const { resolved, activePermutation, cssVarPrefix } = project;
|
|
1843
1788
|
const rows = useMemo(() => {
|
|
1844
1789
|
return sortTokens(Object.entries(resolved).filter(([path, token]) => {
|
|
1845
1790
|
if (token.$type !== "fontFamily") return false;
|
|
@@ -1859,16 +1804,16 @@ function FontFamilySample({ filter, sample = "The quick brown fox jumps over the
|
|
|
1859
1804
|
sortBy,
|
|
1860
1805
|
sortDir
|
|
1861
1806
|
]);
|
|
1862
|
-
const captionText = caption ?? `${rows.length} fontFamily token${rows.length === 1 ? "" : "s"}${filter && filter !== "fontFamily" ? ` matching \`${filter}\`` : ""} · ${
|
|
1807
|
+
const captionText = caption ?? `${rows.length} fontFamily token${rows.length === 1 ? "" : "s"}${filter && filter !== "fontFamily" ? ` matching \`${filter}\`` : ""} · ${activePermutation}`;
|
|
1863
1808
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
1864
|
-
...themeAttrs(cssVarPrefix,
|
|
1809
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
1865
1810
|
children: /* @__PURE__ */ jsx("div", {
|
|
1866
1811
|
className: "sb-block__empty",
|
|
1867
1812
|
children: "No fontFamily tokens match this filter."
|
|
1868
1813
|
})
|
|
1869
1814
|
});
|
|
1870
1815
|
return /* @__PURE__ */ jsxs("div", {
|
|
1871
|
-
...themeAttrs(cssVarPrefix,
|
|
1816
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
1872
1817
|
children: [/* @__PURE__ */ jsx("div", {
|
|
1873
1818
|
className: "sb-block__caption",
|
|
1874
1819
|
children: captionText
|
|
@@ -1910,7 +1855,7 @@ function toWeight(raw) {
|
|
|
1910
1855
|
}
|
|
1911
1856
|
function FontWeightScale({ filter, sample = "Aa", caption, sortBy = "value", sortDir = "asc" }) {
|
|
1912
1857
|
const project = useProject();
|
|
1913
|
-
const { resolved,
|
|
1858
|
+
const { resolved, activePermutation, cssVarPrefix } = project;
|
|
1914
1859
|
const rows = useMemo(() => {
|
|
1915
1860
|
return sortTokens(Object.entries(resolved).filter(([path, token]) => {
|
|
1916
1861
|
if (token.$type !== "fontWeight") return false;
|
|
@@ -1931,16 +1876,16 @@ function FontWeightScale({ filter, sample = "Aa", caption, sortBy = "value", sor
|
|
|
1931
1876
|
sortBy,
|
|
1932
1877
|
sortDir
|
|
1933
1878
|
]);
|
|
1934
|
-
const captionText = caption ?? `${rows.length} fontWeight token${rows.length === 1 ? "" : "s"}${filter && filter !== "fontWeight" ? ` matching \`${filter}\`` : ""} · ${
|
|
1879
|
+
const captionText = caption ?? `${rows.length} fontWeight token${rows.length === 1 ? "" : "s"}${filter && filter !== "fontWeight" ? ` matching \`${filter}\`` : ""} · ${activePermutation}`;
|
|
1935
1880
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
1936
|
-
...themeAttrs(cssVarPrefix,
|
|
1881
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
1937
1882
|
children: /* @__PURE__ */ jsx("div", {
|
|
1938
1883
|
className: "sb-block__empty",
|
|
1939
1884
|
children: "No fontWeight tokens match this filter."
|
|
1940
1885
|
})
|
|
1941
1886
|
});
|
|
1942
1887
|
return /* @__PURE__ */ jsxs("div", {
|
|
1943
|
-
...themeAttrs(cssVarPrefix,
|
|
1888
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
1944
1889
|
children: [/* @__PURE__ */ jsx("div", {
|
|
1945
1890
|
className: "sb-block__caption",
|
|
1946
1891
|
children: captionText
|
|
@@ -1990,7 +1935,7 @@ function stopKey(path, stop, fallback) {
|
|
|
1990
1935
|
}
|
|
1991
1936
|
function GradientPalette({ filter, caption, sortBy = "path", sortDir = "asc" }) {
|
|
1992
1937
|
const project = useProject();
|
|
1993
|
-
const { resolved,
|
|
1938
|
+
const { resolved, activePermutation, cssVarPrefix } = project;
|
|
1994
1939
|
const colorFormat = useColorFormat();
|
|
1995
1940
|
const rows = useMemo(() => {
|
|
1996
1941
|
return sortTokens(Object.entries(resolved).filter(([path, token]) => {
|
|
@@ -2011,16 +1956,16 @@ function GradientPalette({ filter, caption, sortBy = "path", sortDir = "asc" })
|
|
|
2011
1956
|
sortBy,
|
|
2012
1957
|
sortDir
|
|
2013
1958
|
]);
|
|
2014
|
-
const captionText = caption ?? `${rows.length} gradient${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${
|
|
1959
|
+
const captionText = caption ?? `${rows.length} gradient${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${activePermutation}`;
|
|
2015
1960
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
2016
|
-
...themeAttrs(cssVarPrefix,
|
|
1961
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
2017
1962
|
children: /* @__PURE__ */ jsx("div", {
|
|
2018
1963
|
className: "sb-block__empty",
|
|
2019
1964
|
children: "No gradient tokens match this filter."
|
|
2020
1965
|
})
|
|
2021
1966
|
});
|
|
2022
1967
|
return /* @__PURE__ */ jsxs("div", {
|
|
2023
|
-
...themeAttrs(cssVarPrefix,
|
|
1968
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
2024
1969
|
children: [/* @__PURE__ */ jsx("div", {
|
|
2025
1970
|
className: "sb-block__caption",
|
|
2026
1971
|
children: captionText
|
|
@@ -2257,7 +2202,7 @@ function formatSpec(row) {
|
|
|
2257
2202
|
}
|
|
2258
2203
|
function MotionPreview({ filter, caption }) {
|
|
2259
2204
|
const project = useProject();
|
|
2260
|
-
const { resolved,
|
|
2205
|
+
const { resolved, activePermutation, cssVarPrefix } = project;
|
|
2261
2206
|
const [speed, setSpeed] = useState(1);
|
|
2262
2207
|
const [run, setRun] = useState(0);
|
|
2263
2208
|
const reducedMotion = usePrefersReducedMotion();
|
|
@@ -2292,16 +2237,16 @@ function MotionPreview({ filter, caption }) {
|
|
|
2292
2237
|
filter,
|
|
2293
2238
|
project
|
|
2294
2239
|
]);
|
|
2295
|
-
const captionText = caption ?? `${rows.length} motion token${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${
|
|
2240
|
+
const captionText = caption ?? `${rows.length} motion token${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${activePermutation}`;
|
|
2296
2241
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
2297
|
-
...themeAttrs(cssVarPrefix,
|
|
2242
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
2298
2243
|
children: /* @__PURE__ */ jsx("div", {
|
|
2299
2244
|
className: "sb-block__empty",
|
|
2300
2245
|
children: "No motion tokens match this filter."
|
|
2301
2246
|
})
|
|
2302
2247
|
});
|
|
2303
2248
|
return /* @__PURE__ */ jsxs("div", {
|
|
2304
|
-
...themeAttrs(cssVarPrefix,
|
|
2249
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
2305
2250
|
children: [
|
|
2306
2251
|
/* @__PURE__ */ jsx("div", {
|
|
2307
2252
|
className: "sb-block__caption",
|
|
@@ -2375,7 +2320,7 @@ function toOpacity(raw) {
|
|
|
2375
2320
|
*/
|
|
2376
2321
|
function OpacityScale({ filter, type = "number", sampleColor = "color.accent.bg", caption, sortBy = "value", sortDir = "asc" }) {
|
|
2377
2322
|
const project = useProject();
|
|
2378
|
-
const { resolved,
|
|
2323
|
+
const { resolved, activePermutation, cssVarPrefix } = project;
|
|
2379
2324
|
const rows = useMemo(() => {
|
|
2380
2325
|
return sortTokens(Object.entries(resolved).filter(([path, token]) => {
|
|
2381
2326
|
if (token.$type !== type) return false;
|
|
@@ -2402,9 +2347,9 @@ function OpacityScale({ filter, type = "number", sampleColor = "color.accent.bg"
|
|
|
2402
2347
|
sortBy,
|
|
2403
2348
|
sortDir
|
|
2404
2349
|
]);
|
|
2405
|
-
const captionText = caption ?? `${rows.length} opacity token${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${
|
|
2350
|
+
const captionText = caption ?? `${rows.length} opacity token${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${activePermutation}`;
|
|
2406
2351
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
2407
|
-
...themeAttrs(cssVarPrefix,
|
|
2352
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
2408
2353
|
children: /* @__PURE__ */ jsx("div", {
|
|
2409
2354
|
className: "sb-block__empty",
|
|
2410
2355
|
children: "No opacity tokens match this filter."
|
|
@@ -2412,7 +2357,7 @@ function OpacityScale({ filter, type = "number", sampleColor = "color.accent.bg"
|
|
|
2412
2357
|
});
|
|
2413
2358
|
const sampleColorVar = resolveCssVar(sampleColor, project);
|
|
2414
2359
|
return /* @__PURE__ */ jsxs("div", {
|
|
2415
|
-
...themeAttrs(cssVarPrefix,
|
|
2360
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
2416
2361
|
children: [/* @__PURE__ */ jsx("div", {
|
|
2417
2362
|
className: "sb-block__caption",
|
|
2418
2363
|
children: captionText
|
|
@@ -2520,7 +2465,7 @@ function layerKey(path, layer, fallback) {
|
|
|
2520
2465
|
}
|
|
2521
2466
|
function ShadowPreview({ filter, caption, sortBy = "path", sortDir = "asc" }) {
|
|
2522
2467
|
const project = useProject();
|
|
2523
|
-
const { resolved,
|
|
2468
|
+
const { resolved, activePermutation, cssVarPrefix } = project;
|
|
2524
2469
|
const colorFormat = useColorFormat();
|
|
2525
2470
|
const rows = useMemo(() => {
|
|
2526
2471
|
return sortTokens(Object.entries(resolved).filter(([path, token]) => {
|
|
@@ -2541,16 +2486,16 @@ function ShadowPreview({ filter, caption, sortBy = "path", sortDir = "asc" }) {
|
|
|
2541
2486
|
sortBy,
|
|
2542
2487
|
sortDir
|
|
2543
2488
|
]);
|
|
2544
|
-
const captionText = caption ?? `${rows.length} shadow${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${
|
|
2489
|
+
const captionText = caption ?? `${rows.length} shadow${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${activePermutation}`;
|
|
2545
2490
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
2546
|
-
...themeAttrs(cssVarPrefix,
|
|
2491
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
2547
2492
|
children: /* @__PURE__ */ jsx("div", {
|
|
2548
2493
|
className: "sb-block__empty",
|
|
2549
2494
|
children: "No shadow tokens match this filter."
|
|
2550
2495
|
})
|
|
2551
2496
|
});
|
|
2552
2497
|
return /* @__PURE__ */ jsxs("div", {
|
|
2553
|
-
...themeAttrs(cssVarPrefix,
|
|
2498
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
2554
2499
|
children: [/* @__PURE__ */ jsx("div", {
|
|
2555
2500
|
className: "sb-block__caption",
|
|
2556
2501
|
children: captionText
|
|
@@ -2633,7 +2578,7 @@ function extractCssStyle(value) {
|
|
|
2633
2578
|
}
|
|
2634
2579
|
function StrokeStyleSample({ filter, caption, sortBy = "path", sortDir = "asc" }) {
|
|
2635
2580
|
const project = useProject();
|
|
2636
|
-
const { resolved,
|
|
2581
|
+
const { resolved, activePermutation, cssVarPrefix } = project;
|
|
2637
2582
|
const rows = useMemo(() => {
|
|
2638
2583
|
return sortTokens(Object.entries(resolved).filter(([path, token]) => {
|
|
2639
2584
|
if (token.$type !== "strokeStyle") return false;
|
|
@@ -2654,16 +2599,16 @@ function StrokeStyleSample({ filter, caption, sortBy = "path", sortDir = "asc" }
|
|
|
2654
2599
|
sortBy,
|
|
2655
2600
|
sortDir
|
|
2656
2601
|
]);
|
|
2657
|
-
const captionText = caption ?? `${rows.length} strokeStyle token${rows.length === 1 ? "" : "s"}${filter && filter !== "strokeStyle" ? ` matching \`${filter}\`` : ""} · ${
|
|
2602
|
+
const captionText = caption ?? `${rows.length} strokeStyle token${rows.length === 1 ? "" : "s"}${filter && filter !== "strokeStyle" ? ` matching \`${filter}\`` : ""} · ${activePermutation}`;
|
|
2658
2603
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
2659
|
-
...themeAttrs(cssVarPrefix,
|
|
2604
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
2660
2605
|
children: /* @__PURE__ */ jsx("div", {
|
|
2661
2606
|
className: "sb-block__empty",
|
|
2662
2607
|
children: "No strokeStyle tokens match this filter."
|
|
2663
2608
|
})
|
|
2664
2609
|
});
|
|
2665
2610
|
return /* @__PURE__ */ jsxs("div", {
|
|
2666
|
-
...themeAttrs(cssVarPrefix,
|
|
2611
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
2667
2612
|
children: [/* @__PURE__ */ jsx("div", {
|
|
2668
2613
|
className: "sb-block__caption",
|
|
2669
2614
|
children: captionText
|
|
@@ -2700,16 +2645,16 @@ function StrokeStyleSample({ filter, caption, sortBy = "path", sortDir = "asc" }
|
|
|
2700
2645
|
//#region src/token-detail/internal.ts
|
|
2701
2646
|
function useTokenDetailData(path) {
|
|
2702
2647
|
const project = useProject();
|
|
2703
|
-
const {
|
|
2648
|
+
const { activePermutation, activeAxes, axes, permutations, permutationsResolved, resolved, cssVarPrefix } = project;
|
|
2704
2649
|
const typedResolved = resolved;
|
|
2705
2650
|
return {
|
|
2706
2651
|
token: typedResolved[path],
|
|
2707
2652
|
cssVar: resolveCssVar(path, project),
|
|
2708
|
-
|
|
2653
|
+
activePermutation,
|
|
2709
2654
|
activeAxes,
|
|
2710
2655
|
axes,
|
|
2711
|
-
|
|
2712
|
-
|
|
2656
|
+
permutations,
|
|
2657
|
+
permutationsResolved,
|
|
2713
2658
|
resolved: typedResolved,
|
|
2714
2659
|
cssVarPrefix
|
|
2715
2660
|
};
|
|
@@ -2836,13 +2781,13 @@ function treeHasTruncation(nodes) {
|
|
|
2836
2781
|
//#endregion
|
|
2837
2782
|
//#region src/token-detail/AxisVariance.tsx
|
|
2838
2783
|
function AxisVariance({ path }) {
|
|
2839
|
-
const { token, cssVar, axes,
|
|
2784
|
+
const { token, cssVar, axes, permutations, permutationsResolved, activeAxes, cssVarPrefix } = useTokenDetailData(path);
|
|
2840
2785
|
const colorFormat = useColorFormat();
|
|
2841
2786
|
const tokenType = token?.$type;
|
|
2842
2787
|
const isColor = tokenType === "color";
|
|
2843
2788
|
const formatFn = (t) => valueFor(t, tokenType, colorFormat);
|
|
2844
2789
|
const variance = useMemo(() => {
|
|
2845
|
-
const result = analyzeAxisVariance(path, axes,
|
|
2790
|
+
const result = analyzeAxisVariance(path, axes, permutations, permutationsResolved);
|
|
2846
2791
|
return {
|
|
2847
2792
|
kind: result.kind === "constant" ? "constant" : result.kind === "single" ? "one-axis" : "multi-axis",
|
|
2848
2793
|
varyingAxes: result.varyingAxes
|
|
@@ -2850,13 +2795,13 @@ function AxisVariance({ path }) {
|
|
|
2850
2795
|
}, [
|
|
2851
2796
|
path,
|
|
2852
2797
|
axes,
|
|
2853
|
-
|
|
2854
|
-
|
|
2798
|
+
permutations,
|
|
2799
|
+
permutationsResolved
|
|
2855
2800
|
]);
|
|
2856
|
-
if (
|
|
2801
|
+
if (permutations.length === 0) return /* @__PURE__ */ jsx(Fragment$1, {});
|
|
2857
2802
|
if (variance.kind === "constant") {
|
|
2858
|
-
const
|
|
2859
|
-
const value =
|
|
2803
|
+
const anyPermutation = permutations[0];
|
|
2804
|
+
const value = anyPermutation ? formatFn(permutationsResolved[anyPermutation.name]?.[path]) : "—";
|
|
2860
2805
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
|
|
2861
2806
|
className: "sb-token-detail__section-header",
|
|
2862
2807
|
children: "Values across axes"
|
|
@@ -2882,7 +2827,7 @@ function AxisVariance({ path }) {
|
|
|
2882
2827
|
},
|
|
2883
2828
|
children: [
|
|
2884
2829
|
"same across all ",
|
|
2885
|
-
|
|
2830
|
+
permutations.length,
|
|
2886
2831
|
" tuples"
|
|
2887
2832
|
]
|
|
2888
2833
|
})
|
|
@@ -2901,14 +2846,14 @@ function AxisVariance({ path }) {
|
|
|
2901
2846
|
...activeAxes,
|
|
2902
2847
|
[axisName]: ctx
|
|
2903
2848
|
};
|
|
2904
|
-
const name =
|
|
2849
|
+
const name = permutations.find((t) => {
|
|
2905
2850
|
const input = t.input;
|
|
2906
2851
|
return Object.keys(input).every((k) => input[k] === target[k]);
|
|
2907
2852
|
})?.name ?? "";
|
|
2908
2853
|
return {
|
|
2909
2854
|
ctx,
|
|
2910
2855
|
themeName: name,
|
|
2911
|
-
value: name ? formatFn(
|
|
2856
|
+
value: name ? formatFn(permutationsResolved[name]?.[path]) : "—"
|
|
2912
2857
|
};
|
|
2913
2858
|
});
|
|
2914
2859
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
|
|
@@ -2974,12 +2919,12 @@ function AxisVariance({ path }) {
|
|
|
2974
2919
|
className: "sb-token-detail__theme-cell",
|
|
2975
2920
|
children: row
|
|
2976
2921
|
}), colAxis.contexts.map((col) => {
|
|
2977
|
-
const name = tupleName(
|
|
2922
|
+
const name = tupleName(permutations, {
|
|
2978
2923
|
...activeAxes,
|
|
2979
2924
|
[rowAxis.name]: row,
|
|
2980
2925
|
[colAxis.name]: col
|
|
2981
2926
|
});
|
|
2982
|
-
const value = name ? formatFn(
|
|
2927
|
+
const value = name ? formatFn(permutationsResolved[name]?.[path]) : "—";
|
|
2983
2928
|
return /* @__PURE__ */ jsxs("td", {
|
|
2984
2929
|
className: "sb-token-detail__theme-cell",
|
|
2985
2930
|
"data-row": row,
|
|
@@ -3009,8 +2954,8 @@ function valueFor(token, $type, format) {
|
|
|
3009
2954
|
if (!token) return "—";
|
|
3010
2955
|
return formatTokenValue(token.$value, $type, format);
|
|
3011
2956
|
}
|
|
3012
|
-
function tupleName(
|
|
3013
|
-
return
|
|
2957
|
+
function tupleName(permutations, tuple) {
|
|
2958
|
+
return permutations.find((t) => {
|
|
3014
2959
|
const input = t.input;
|
|
3015
2960
|
return Object.keys(input).every((k) => input[k] === tuple[k]);
|
|
3016
2961
|
})?.name;
|
|
@@ -3521,14 +3466,14 @@ async function copyToClipboard(text) {
|
|
|
3521
3466
|
//#endregion
|
|
3522
3467
|
//#region src/token-detail/TokenHeader.tsx
|
|
3523
3468
|
function TokenHeader({ path, heading }) {
|
|
3524
|
-
const { token, cssVar,
|
|
3469
|
+
const { token, cssVar, activePermutation } = useTokenDetailData(path);
|
|
3525
3470
|
if (!token) return /* @__PURE__ */ jsxs("div", {
|
|
3526
3471
|
className: "sb-token-detail__missing",
|
|
3527
3472
|
children: [
|
|
3528
3473
|
"Token ",
|
|
3529
3474
|
/* @__PURE__ */ jsx("code", { children: path }),
|
|
3530
3475
|
" not found in theme ",
|
|
3531
|
-
/* @__PURE__ */ jsx("strong", { children:
|
|
3476
|
+
/* @__PURE__ */ jsx("strong", { children: activePermutation }),
|
|
3532
3477
|
"."
|
|
3533
3478
|
]
|
|
3534
3479
|
});
|
|
@@ -3573,9 +3518,9 @@ function TokenUsageSnippet({ path }) {
|
|
|
3573
3518
|
//#endregion
|
|
3574
3519
|
//#region src/TokenDetail.tsx
|
|
3575
3520
|
function TokenDetail({ path, heading }) {
|
|
3576
|
-
const { token, cssVar,
|
|
3521
|
+
const { token, cssVar, activePermutation, cssVarPrefix } = useTokenDetailData(path);
|
|
3577
3522
|
const colorFormat = useColorFormat();
|
|
3578
|
-
const theme = themeAttrs(cssVarPrefix,
|
|
3523
|
+
const theme = themeAttrs(cssVarPrefix, activePermutation);
|
|
3579
3524
|
if (!token) return /* @__PURE__ */ jsx("div", {
|
|
3580
3525
|
...theme,
|
|
3581
3526
|
className: cx(theme["className"], "sb-token-detail"),
|
|
@@ -3585,7 +3530,7 @@ function TokenDetail({ path, heading }) {
|
|
|
3585
3530
|
"Token ",
|
|
3586
3531
|
/* @__PURE__ */ jsx("code", { children: path }),
|
|
3587
3532
|
" not found in theme ",
|
|
3588
|
-
/* @__PURE__ */ jsx("strong", { children:
|
|
3533
|
+
/* @__PURE__ */ jsx("strong", { children: activePermutation }),
|
|
3589
3534
|
"."
|
|
3590
3535
|
]
|
|
3591
3536
|
})
|
|
@@ -3605,7 +3550,7 @@ function TokenDetail({ path, heading }) {
|
|
|
3605
3550
|
}),
|
|
3606
3551
|
/* @__PURE__ */ jsxs("div", {
|
|
3607
3552
|
className: "sb-token-detail__section-header",
|
|
3608
|
-
children: ["Resolved value · ",
|
|
3553
|
+
children: ["Resolved value · ", activePermutation]
|
|
3609
3554
|
}),
|
|
3610
3555
|
/* @__PURE__ */ jsx(CompositePreview, { path }),
|
|
3611
3556
|
/* @__PURE__ */ jsx(CompositeBreakdown, { path }),
|
|
@@ -3769,7 +3714,7 @@ function pruneTreeForMatches(nodes, matches, expandOut) {
|
|
|
3769
3714
|
return out;
|
|
3770
3715
|
}
|
|
3771
3716
|
function TokenNavigator({ root, type, initiallyExpanded = 1, searchable = true, onSelect }) {
|
|
3772
|
-
const { resolved,
|
|
3717
|
+
const { resolved, activePermutation, cssVarPrefix } = useProject();
|
|
3773
3718
|
const typeFilter = useMemo(() => {
|
|
3774
3719
|
if (type === void 0) return void 0;
|
|
3775
3720
|
return new Set(Array.isArray(type) ? type : [type]);
|
|
@@ -3835,11 +3780,11 @@ function TokenNavigator({ root, type, initiallyExpanded = 1, searchable = true,
|
|
|
3835
3780
|
return n;
|
|
3836
3781
|
}, [visibleTree, searchExpanded]);
|
|
3837
3782
|
if (tree.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
3838
|
-
...themeAttrs(cssVarPrefix,
|
|
3783
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
3839
3784
|
children: /* @__PURE__ */ jsx(EmptyState, { children: root ? `No tokens under "${root}"${typeFilter ? ` matching ${typeLabel.slice(3)}` : ""}.` : typeFilter ? `No tokens matching ${typeLabel.slice(3)} in the active theme.` : "No tokens in the active theme." })
|
|
3840
3785
|
});
|
|
3841
3786
|
return /* @__PURE__ */ jsxs("div", {
|
|
3842
|
-
...themeAttrs(cssVarPrefix,
|
|
3787
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
3843
3788
|
children: [
|
|
3844
3789
|
searchable && /* @__PURE__ */ jsx("div", {
|
|
3845
3790
|
className: "sb-token-navigator__search",
|
|
@@ -3859,8 +3804,9 @@ function TokenNavigator({ root, type, initiallyExpanded = 1, searchable = true,
|
|
|
3859
3804
|
root ? `Tokens under ${root}` : "Token graph",
|
|
3860
3805
|
typeLabel,
|
|
3861
3806
|
trimmedQuery !== "" ? ` · ${matchCount} matching "${trimmedQuery}"` : "",
|
|
3862
|
-
" ·
|
|
3863
|
-
|
|
3807
|
+
" ·",
|
|
3808
|
+
" ",
|
|
3809
|
+
activePermutation
|
|
3864
3810
|
]
|
|
3865
3811
|
}),
|
|
3866
3812
|
visibleTree.length === 0 ? /* @__PURE__ */ jsxs("div", {
|
|
@@ -4039,7 +3985,7 @@ function LeafPreview({ path, token }) {
|
|
|
4039
3985
|
//#region src/TokenTable.tsx
|
|
4040
3986
|
function TokenTable({ filter, type, caption, sortBy = "path", sortDir = "asc", searchable = true, onSelect }) {
|
|
4041
3987
|
const project = useProject();
|
|
4042
|
-
const { resolved,
|
|
3988
|
+
const { resolved, activePermutation, cssVarPrefix } = project;
|
|
4043
3989
|
const colorFormat = useColorFormat();
|
|
4044
3990
|
const [selectedPath, setSelectedPath] = useState(null);
|
|
4045
3991
|
const [query, setQuery] = useState("");
|
|
@@ -4085,16 +4031,16 @@ function TokenTable({ filter, type, caption, sortBy = "path", sortDir = "asc", s
|
|
|
4085
4031
|
else setSelectedPath(path);
|
|
4086
4032
|
}, [onSelect]);
|
|
4087
4033
|
const matchSuffix = searchable && query.trim() !== "" ? ` · ${visibleRows.length} matching "${query.trim()}"` : "";
|
|
4088
|
-
const captionText = caption ?? `${rows.length} token${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""}${type ? ` · $type=${type}` : ""}${matchSuffix} · ${
|
|
4034
|
+
const captionText = caption ?? `${rows.length} token${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""}${type ? ` · $type=${type}` : ""}${matchSuffix} · ${activePermutation}`;
|
|
4089
4035
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
4090
|
-
...themeAttrs(cssVarPrefix,
|
|
4036
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
4091
4037
|
children: /* @__PURE__ */ jsx("div", {
|
|
4092
4038
|
className: "sb-block__empty",
|
|
4093
4039
|
children: "No tokens match this filter."
|
|
4094
4040
|
})
|
|
4095
4041
|
});
|
|
4096
4042
|
return /* @__PURE__ */ jsxs("div", {
|
|
4097
|
-
...themeAttrs(cssVarPrefix,
|
|
4043
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
4098
4044
|
children: [
|
|
4099
4045
|
searchable && /* @__PURE__ */ jsx("div", {
|
|
4100
4046
|
className: "sb-token-table__search",
|
|
@@ -4234,7 +4180,7 @@ function buildRow(path, composite) {
|
|
|
4234
4180
|
};
|
|
4235
4181
|
}
|
|
4236
4182
|
function TypographyScale({ filter, sample = "The quick brown fox jumps over the lazy dog.", caption, sortBy = "path", sortDir = "asc" }) {
|
|
4237
|
-
const { resolved,
|
|
4183
|
+
const { resolved, activePermutation, cssVarPrefix } = useProject();
|
|
4238
4184
|
const rows = useMemo(() => {
|
|
4239
4185
|
return sortTokens(Object.entries(resolved).filter(([path, token]) => {
|
|
4240
4186
|
if (token.$type !== "typography") return false;
|
|
@@ -4257,16 +4203,16 @@ function TypographyScale({ filter, sample = "The quick brown fox jumps over the
|
|
|
4257
4203
|
sortBy,
|
|
4258
4204
|
sortDir
|
|
4259
4205
|
]);
|
|
4260
|
-
const captionText = caption ?? `${rows.length} typography token${rows.length === 1 ? "" : "s"}${filter && filter !== "typography" ? ` matching \`${filter}\`` : ""} · ${
|
|
4206
|
+
const captionText = caption ?? `${rows.length} typography token${rows.length === 1 ? "" : "s"}${filter && filter !== "typography" ? ` matching \`${filter}\`` : ""} · ${activePermutation}`;
|
|
4261
4207
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
4262
|
-
...themeAttrs(cssVarPrefix,
|
|
4208
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
4263
4209
|
children: /* @__PURE__ */ jsx("div", {
|
|
4264
4210
|
className: "sb-block__empty",
|
|
4265
4211
|
children: "No typography tokens match this filter."
|
|
4266
4212
|
})
|
|
4267
4213
|
});
|
|
4268
4214
|
return /* @__PURE__ */ jsxs("div", {
|
|
4269
|
-
...themeAttrs(cssVarPrefix,
|
|
4215
|
+
...themeAttrs(cssVarPrefix, activePermutation),
|
|
4270
4216
|
children: [/* @__PURE__ */ jsx("div", {
|
|
4271
4217
|
className: "sb-block__caption",
|
|
4272
4218
|
children: captionText
|
|
@@ -4289,6 +4235,6 @@ function TypographyScale({ filter, sample = "The quick brown fox jumps over the
|
|
|
4289
4235
|
});
|
|
4290
4236
|
}
|
|
4291
4237
|
//#endregion
|
|
4292
|
-
export { AliasChain, AliasedBy, AxesContext, AxisVariance, BorderPreview, BorderSample, COLOR_FORMATS, ColorFormatContext, ColorPalette, ColorTable, CompositeBreakdown, CompositePreview, ConsumerOutput, Diagnostics, DimensionBar, DimensionScale, FontFamilySample, FontWeightScale, GradientPalette, MotionPreview, MotionSample, OpacityScale, ShadowPreview, ShadowSample, StrokeStyleSample, SwatchbookContext, SwatchbookProvider,
|
|
4238
|
+
export { AliasChain, AliasedBy, AxesContext, AxisVariance, BorderPreview, BorderSample, COLOR_FORMATS, ColorFormatContext, ColorPalette, ColorTable, CompositeBreakdown, CompositePreview, ConsumerOutput, Diagnostics, DimensionBar, DimensionScale, FontFamilySample, FontWeightScale, GradientPalette, MotionPreview, MotionSample, OpacityScale, PermutationContext, ShadowPreview, ShadowSample, StrokeStyleSample, SwatchbookContext, SwatchbookProvider, TokenDetail, TokenHeader, TokenNavigator, TokenTable, TokenUsageSnippet, TypographyScale, formatColor, useActiveAxes, useActivePermutation, useColorFormat, useOptionalSwatchbookData, useSwatchbookData };
|
|
4293
4239
|
|
|
4294
4240
|
//# sourceMappingURL=index.mjs.map
|