@unpunnyfuns/swatchbook-blocks 0.63.0 → 0.65.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 +28 -7
- package/dist/index.mjs +194 -109
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +74 -61
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -99,11 +99,14 @@ interface ProjectSnapshot {
|
|
|
99
99
|
/** The default tuple — `{ axis: axis.default }` for every axis. */
|
|
100
100
|
defaultTuple: Record<string, string>;
|
|
101
101
|
/**
|
|
102
|
-
* Pre-built `resolveAt(tuple)` accessor. The addon's preview
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
102
|
+
* Pre-built `resolveAt(tuple)` accessor. The addon's preview decorator
|
|
103
|
+
* instantiates this once per iframe lifetime. When present, use-project
|
|
104
|
+
* prefers it over building its own from `tokenGraph`, so it MUST preserve
|
|
105
|
+
* alias provenance — back it with `resolveAllWithProvenanceAt`, not the raw
|
|
106
|
+
* leaf `resolveAllAt`, or axis-varying aliases silently lose their chain /
|
|
107
|
+
* reverse refs / description at non-default tuples. Hand-built snapshots
|
|
108
|
+
* (tests, MDX) can omit this; blocks then fall back to a provenance-aware
|
|
109
|
+
* graph-backed resolver built from `tokenGraph`.
|
|
107
110
|
*/
|
|
108
111
|
resolveAt?: (tuple: Record<string, string>) => Record<string, VirtualTokenShape>;
|
|
109
112
|
}
|
|
@@ -765,6 +768,18 @@ declare function TokenUsageSnippet({
|
|
|
765
768
|
path
|
|
766
769
|
}: TokenUsageSnippetProps): ReactElement | null;
|
|
767
770
|
//#endregion
|
|
771
|
+
//#region src/indicators/resolve.d.ts
|
|
772
|
+
/** The individually-toggleable indicators in the row strip. `alias` covers the whole alias unit (forward chain + reverse count). */
|
|
773
|
+
type IndicatorName = 'alias' | 'variance' | 'gamut' | 'deprecation' | 'description';
|
|
774
|
+
/**
|
|
775
|
+
* Consumer-facing indicator config for the strip-hosting blocks:
|
|
776
|
+
* - `true` — every indicator on (including the opt-in `description`)
|
|
777
|
+
* - `false` — every indicator off
|
|
778
|
+
* - object — per-key override layered over the defaults
|
|
779
|
+
* - omitted — the defaults
|
|
780
|
+
*/
|
|
781
|
+
type IndicatorsProp = boolean | Partial<Record<IndicatorName, boolean>>;
|
|
782
|
+
//#endregion
|
|
768
783
|
//#region src/TokenNavigator.d.ts
|
|
769
784
|
interface TokenNavigatorProps {
|
|
770
785
|
/** If provided, mount at this dot-path subtree and hide everything outside it. */
|
|
@@ -805,6 +820,8 @@ interface TokenNavigatorProps {
|
|
|
805
820
|
* props otherwise.
|
|
806
821
|
*/
|
|
807
822
|
id?: string;
|
|
823
|
+
/** Configure the per-row indicator strip. See `IndicatorsProp`. */
|
|
824
|
+
indicators?: IndicatorsProp;
|
|
808
825
|
}
|
|
809
826
|
declare function TokenNavigator({
|
|
810
827
|
root,
|
|
@@ -812,7 +829,8 @@ declare function TokenNavigator({
|
|
|
812
829
|
initiallyExpanded,
|
|
813
830
|
searchable,
|
|
814
831
|
onSelect,
|
|
815
|
-
id
|
|
832
|
+
id,
|
|
833
|
+
indicators
|
|
816
834
|
}: TokenNavigatorProps): ReactElement;
|
|
817
835
|
//#endregion
|
|
818
836
|
//#region src/TokenTable.d.ts
|
|
@@ -855,6 +873,8 @@ interface TokenTableProps {
|
|
|
855
873
|
onSelect?(path: string): void;
|
|
856
874
|
/** Disambiguates persisted UI state for two identical-prop tables on a page. */
|
|
857
875
|
id?: string;
|
|
876
|
+
/** Configure the per-row indicator strip. See `IndicatorsProp`. */
|
|
877
|
+
indicators?: IndicatorsProp;
|
|
858
878
|
}
|
|
859
879
|
declare function TokenTable({
|
|
860
880
|
filter,
|
|
@@ -864,7 +884,8 @@ declare function TokenTable({
|
|
|
864
884
|
sortDir,
|
|
865
885
|
searchable,
|
|
866
886
|
onSelect,
|
|
867
|
-
id
|
|
887
|
+
id,
|
|
888
|
+
indicators
|
|
868
889
|
}: TokenTableProps): ReactElement;
|
|
869
890
|
//#endregion
|
|
870
891
|
//#region src/TypographyScale.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -3640,7 +3640,39 @@ function isInView(path, ctx) {
|
|
|
3640
3640
|
return true;
|
|
3641
3641
|
}
|
|
3642
3642
|
//#endregion
|
|
3643
|
-
//#region src/
|
|
3643
|
+
//#region src/indicators/resolve.ts
|
|
3644
|
+
/** Established-on set; `description` is opt-in. */
|
|
3645
|
+
const DEFAULT_INDICATORS = {
|
|
3646
|
+
alias: true,
|
|
3647
|
+
variance: true,
|
|
3648
|
+
gamut: true,
|
|
3649
|
+
deprecation: true,
|
|
3650
|
+
description: false
|
|
3651
|
+
};
|
|
3652
|
+
/** Normalize an `IndicatorsProp` into a full enabled-map by layering over the defaults. */
|
|
3653
|
+
function resolveIndicators(prop) {
|
|
3654
|
+
if (prop === void 0) return { ...DEFAULT_INDICATORS };
|
|
3655
|
+
if (prop === true) return {
|
|
3656
|
+
alias: true,
|
|
3657
|
+
variance: true,
|
|
3658
|
+
gamut: true,
|
|
3659
|
+
deprecation: true,
|
|
3660
|
+
description: true
|
|
3661
|
+
};
|
|
3662
|
+
if (prop === false) return {
|
|
3663
|
+
alias: false,
|
|
3664
|
+
variance: false,
|
|
3665
|
+
gamut: false,
|
|
3666
|
+
deprecation: false,
|
|
3667
|
+
description: false
|
|
3668
|
+
};
|
|
3669
|
+
return {
|
|
3670
|
+
...DEFAULT_INDICATORS,
|
|
3671
|
+
...prop
|
|
3672
|
+
};
|
|
3673
|
+
}
|
|
3674
|
+
//#endregion
|
|
3675
|
+
//#region src/indicators/RowIndicators.tsx
|
|
3644
3676
|
function relativeLabel(path, root) {
|
|
3645
3677
|
if (root && path.startsWith(`${root}.`)) return path.slice(root.length + 1);
|
|
3646
3678
|
return path;
|
|
@@ -3650,37 +3682,37 @@ function relativeLabel(path, root) {
|
|
|
3650
3682
|
* capped to first … last beyond two hops (no width measurement). Each shown
|
|
3651
3683
|
* node navigates when in view, else renders as plain text.
|
|
3652
3684
|
*/
|
|
3653
|
-
function ForwardChain({ chain, root,
|
|
3685
|
+
function ForwardChain({ chain, root, canReference, onReferenceClick }) {
|
|
3654
3686
|
const full = chain.map((p) => relativeLabel(p, root)).join(" → ");
|
|
3655
3687
|
const capped = chain.length > 2;
|
|
3656
3688
|
const shown = capped ? [chain[0], chain[chain.length - 1]] : [...chain];
|
|
3657
3689
|
return /* @__PURE__ */ jsxs("span", {
|
|
3658
|
-
className: "sb-
|
|
3690
|
+
className: "sb-indicator__alias-forward",
|
|
3659
3691
|
"data-testid": "row-indicator-alias-forward",
|
|
3660
3692
|
"aria-label": `aliases ${full}`,
|
|
3661
3693
|
children: [/* @__PURE__ */ jsx("span", {
|
|
3662
|
-
className: "sb-
|
|
3694
|
+
className: "sb-indicator__alias-arrow",
|
|
3663
3695
|
"aria-hidden": true,
|
|
3664
3696
|
children: "→"
|
|
3665
3697
|
}), shown.map((target, i) => {
|
|
3666
3698
|
const label = relativeLabel(target, root);
|
|
3667
|
-
return /* @__PURE__ */ jsxs("span", { children: [
|
|
3699
|
+
return /* @__PURE__ */ jsxs("span", { children: [canReference(target) ? /* @__PURE__ */ jsx("button", {
|
|
3668
3700
|
type: "button",
|
|
3669
|
-
className: "sb-
|
|
3701
|
+
className: "sb-indicator__alias-node",
|
|
3670
3702
|
"data-testid": "alias-node",
|
|
3671
3703
|
"aria-label": target,
|
|
3672
3704
|
onClick: (e) => {
|
|
3673
3705
|
e.stopPropagation();
|
|
3674
|
-
|
|
3706
|
+
onReferenceClick(target);
|
|
3675
3707
|
},
|
|
3676
3708
|
children: label
|
|
3677
3709
|
}) : /* @__PURE__ */ jsx("span", {
|
|
3678
|
-
className: "sb-
|
|
3710
|
+
className: "sb-indicator__alias-node sb-indicator__alias-node--offview",
|
|
3679
3711
|
"data-testid": "alias-node",
|
|
3680
3712
|
title: "outside current view",
|
|
3681
3713
|
children: label
|
|
3682
3714
|
}), capped && i === 0 ? /* @__PURE__ */ jsxs("span", {
|
|
3683
|
-
className: "sb-
|
|
3715
|
+
className: "sb-indicator__alias-arrow",
|
|
3684
3716
|
"aria-hidden": true,
|
|
3685
3717
|
children: [
|
|
3686
3718
|
" ",
|
|
@@ -3688,7 +3720,7 @@ function ForwardChain({ chain, root, resolveInView, onNavigate }) {
|
|
|
3688
3720
|
" "
|
|
3689
3721
|
]
|
|
3690
3722
|
}) : i < shown.length - 1 ? /* @__PURE__ */ jsxs("span", {
|
|
3691
|
-
className: "sb-
|
|
3723
|
+
className: "sb-indicator__alias-arrow",
|
|
3692
3724
|
"aria-hidden": true,
|
|
3693
3725
|
children: [
|
|
3694
3726
|
" ",
|
|
@@ -3702,7 +3734,7 @@ function ForwardChain({ chain, root, resolveInView, onNavigate }) {
|
|
|
3702
3734
|
function DeprecatedBadge({ deprecated }) {
|
|
3703
3735
|
const label = typeof deprecated === "string" ? `deprecated: ${deprecated}` : "deprecated";
|
|
3704
3736
|
return /* @__PURE__ */ jsx("span", {
|
|
3705
|
-
className: "sb-
|
|
3737
|
+
className: "sb-indicator__deprecated",
|
|
3706
3738
|
"data-testid": "row-indicator-deprecated",
|
|
3707
3739
|
title: label,
|
|
3708
3740
|
"aria-label": label,
|
|
@@ -3714,17 +3746,17 @@ function VarianceBadge({ variance }) {
|
|
|
3714
3746
|
const axes = variance.varyingAxes;
|
|
3715
3747
|
const label = variance.kind === "single" ? variance.axis : `${axes.length} axes`;
|
|
3716
3748
|
return /* @__PURE__ */ jsxs("span", {
|
|
3717
|
-
className: "sb-
|
|
3749
|
+
className: "sb-indicator__variance",
|
|
3718
3750
|
"data-testid": "row-indicator-variance",
|
|
3719
3751
|
"aria-label": `varies by ${axes.join(", ")}`,
|
|
3720
3752
|
children: [/* @__PURE__ */ jsx("span", {
|
|
3721
|
-
className: "sb-
|
|
3753
|
+
className: "sb-indicator__variance-glyph",
|
|
3722
3754
|
"aria-hidden": true,
|
|
3723
3755
|
children: "⊹"
|
|
3724
3756
|
}), label]
|
|
3725
3757
|
});
|
|
3726
3758
|
}
|
|
3727
|
-
function ReverseCount({ referents,
|
|
3759
|
+
function ReverseCount({ referents, canReference, onReferenceClick }) {
|
|
3728
3760
|
const [open, setOpen] = useState(false);
|
|
3729
3761
|
const wrapRef = useRef(null);
|
|
3730
3762
|
const count = referents.length;
|
|
@@ -3742,42 +3774,42 @@ function ReverseCount({ referents, resolveInView, onNavigate }) {
|
|
|
3742
3774
|
}, [open, single]);
|
|
3743
3775
|
return /* @__PURE__ */ jsxs("span", {
|
|
3744
3776
|
ref: wrapRef,
|
|
3745
|
-
className: "sb-
|
|
3777
|
+
className: "sb-indicator__reverse-wrap",
|
|
3746
3778
|
onKeyDown: (e) => {
|
|
3747
3779
|
if (e.key === "Escape") setOpen(false);
|
|
3748
3780
|
},
|
|
3749
3781
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
3750
3782
|
type: "button",
|
|
3751
|
-
className: "sb-
|
|
3783
|
+
className: "sb-indicator__alias-reverse",
|
|
3752
3784
|
"data-testid": "row-indicator-alias-reverse",
|
|
3753
3785
|
"aria-label": `referenced by ${count} ${count === 1 ? "token" : "tokens"}`,
|
|
3754
3786
|
"aria-haspopup": single ? void 0 : "menu",
|
|
3755
3787
|
"aria-expanded": single ? void 0 : open,
|
|
3756
3788
|
onClick: (e) => {
|
|
3757
3789
|
e.stopPropagation();
|
|
3758
|
-
if (single)
|
|
3790
|
+
if (single) onReferenceClick(referents[0]);
|
|
3759
3791
|
else setOpen((v) => !v);
|
|
3760
3792
|
},
|
|
3761
3793
|
children: [/* @__PURE__ */ jsx("span", {
|
|
3762
|
-
className: "sb-
|
|
3794
|
+
className: "sb-indicator__alias-arrow",
|
|
3763
3795
|
"aria-hidden": true,
|
|
3764
3796
|
children: "←"
|
|
3765
3797
|
}), count]
|
|
3766
3798
|
}), !single && open && /* @__PURE__ */ jsx("ul", {
|
|
3767
|
-
className: "sb-
|
|
3799
|
+
className: "sb-indicator__reverse-menu",
|
|
3768
3800
|
role: "menu",
|
|
3769
3801
|
children: referents.map((ref) => /* @__PURE__ */ jsx("li", {
|
|
3770
3802
|
role: "none",
|
|
3771
3803
|
children: /* @__PURE__ */ jsx("button", {
|
|
3772
3804
|
type: "button",
|
|
3773
3805
|
role: "menuitem",
|
|
3774
|
-
className: "sb-
|
|
3775
|
-
disabled: !
|
|
3776
|
-
title:
|
|
3806
|
+
className: "sb-indicator__reverse-item",
|
|
3807
|
+
disabled: !canReference(ref),
|
|
3808
|
+
title: canReference(ref) ? void 0 : "outside current view",
|
|
3777
3809
|
onClick: (e) => {
|
|
3778
3810
|
e.stopPropagation();
|
|
3779
3811
|
setOpen(false);
|
|
3780
|
-
|
|
3812
|
+
onReferenceClick(ref);
|
|
3781
3813
|
},
|
|
3782
3814
|
children: ref
|
|
3783
3815
|
})
|
|
@@ -3787,35 +3819,50 @@ function ReverseCount({ referents, resolveInView, onNavigate }) {
|
|
|
3787
3819
|
}
|
|
3788
3820
|
/** Per-row indicator strip: alias references, variance, gamut, deprecation. */
|
|
3789
3821
|
function RowIndicators(props) {
|
|
3790
|
-
const { token, root, variance, colorFormat,
|
|
3822
|
+
const { token, root, variance, colorFormat, canReference, onReferenceClick } = props;
|
|
3823
|
+
const en = props.enabled ?? resolveIndicators(void 0);
|
|
3791
3824
|
const aliasChain = Array.isArray(token.aliasChain) && token.aliasChain.length > 0 ? token.aliasChain : void 0;
|
|
3792
3825
|
const reverseCount = Array.isArray(token.aliasedBy) && token.aliasedBy.length > 0 ? token.aliasedBy.length : 0;
|
|
3793
3826
|
const isVarying = variance !== void 0 && variance.kind !== "constant";
|
|
3794
3827
|
const outOfGamut = token.$type === "color" && (formatColor(token.$value, colorFormat)?.outOfGamut ?? false);
|
|
3795
3828
|
const deprecated = token.$deprecated;
|
|
3796
3829
|
const isDeprecated = deprecated === true || typeof deprecated === "string" && deprecated.length > 0;
|
|
3797
|
-
|
|
3830
|
+
const description = typeof token.$description === "string" && token.$description.length > 0 ? token.$description : void 0;
|
|
3831
|
+
const showDeprecated = en.deprecation && isDeprecated;
|
|
3832
|
+
const showForward = en.alias && aliasChain !== void 0;
|
|
3833
|
+
const showReverse = en.alias && reverseCount > 0;
|
|
3834
|
+
const showVariance = en.variance && isVarying;
|
|
3835
|
+
const showGamut = en.gamut && outOfGamut;
|
|
3836
|
+
const showDescription = en.description && description !== void 0;
|
|
3837
|
+
if (!showDeprecated && !showForward && !showReverse && !showVariance && !showGamut && !showDescription) return null;
|
|
3798
3838
|
return /* @__PURE__ */ jsxs("span", {
|
|
3799
|
-
className: "sb-
|
|
3839
|
+
className: "sb-indicator__indicators",
|
|
3800
3840
|
children: [
|
|
3801
|
-
|
|
3802
|
-
aliasChain && /* @__PURE__ */ jsx(ForwardChain, {
|
|
3841
|
+
showDeprecated && deprecated !== void 0 && /* @__PURE__ */ jsx(DeprecatedBadge, { deprecated }),
|
|
3842
|
+
showForward && aliasChain && /* @__PURE__ */ jsx(ForwardChain, {
|
|
3803
3843
|
chain: aliasChain,
|
|
3804
3844
|
root,
|
|
3805
|
-
|
|
3806
|
-
|
|
3845
|
+
canReference,
|
|
3846
|
+
onReferenceClick
|
|
3807
3847
|
}),
|
|
3808
|
-
|
|
3848
|
+
showReverse && token.aliasedBy && /* @__PURE__ */ jsx(ReverseCount, {
|
|
3809
3849
|
referents: token.aliasedBy,
|
|
3810
|
-
|
|
3811
|
-
|
|
3850
|
+
canReference,
|
|
3851
|
+
onReferenceClick
|
|
3812
3852
|
}),
|
|
3813
|
-
variance && /* @__PURE__ */ jsx(VarianceBadge, { variance }),
|
|
3814
|
-
|
|
3815
|
-
className: "sb-
|
|
3853
|
+
showVariance && variance && /* @__PURE__ */ jsx(VarianceBadge, { variance }),
|
|
3854
|
+
showGamut && /* @__PURE__ */ jsx("span", {
|
|
3855
|
+
className: "sb-indicator__gamut",
|
|
3816
3856
|
title: "Out of sRGB gamut for this format",
|
|
3817
3857
|
"aria-label": "out of gamut",
|
|
3818
3858
|
children: "⚠"
|
|
3859
|
+
}),
|
|
3860
|
+
showDescription && description !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
3861
|
+
className: "sb-indicator__description",
|
|
3862
|
+
"data-testid": "row-indicator-description",
|
|
3863
|
+
title: description,
|
|
3864
|
+
"aria-label": `description: ${description}`,
|
|
3865
|
+
children: "ⓘ"
|
|
3819
3866
|
})
|
|
3820
3867
|
]
|
|
3821
3868
|
});
|
|
@@ -3924,7 +3971,7 @@ function pruneTreeForMatches(nodes, matches, expandOut) {
|
|
|
3924
3971
|
}
|
|
3925
3972
|
return out;
|
|
3926
3973
|
}
|
|
3927
|
-
function TokenNavigator({ root, type, initiallyExpanded = 1, searchable = true, onSelect, id }) {
|
|
3974
|
+
function TokenNavigator({ root, type, initiallyExpanded = 1, searchable = true, onSelect, id, indicators }) {
|
|
3928
3975
|
const { resolved, activeTheme, activeAxes, cssVarPrefix } = useProject();
|
|
3929
3976
|
const blockKey = useBlockKey("TokenNavigator", [
|
|
3930
3977
|
root,
|
|
@@ -3935,6 +3982,7 @@ function TokenNavigator({ root, type, initiallyExpanded = 1, searchable = true,
|
|
|
3935
3982
|
if (type === void 0) return void 0;
|
|
3936
3983
|
return new Set(Array.isArray(type) ? type : [type]);
|
|
3937
3984
|
}, [type]);
|
|
3985
|
+
const enabledIndicators = useMemo(() => resolveIndicators(indicators), [indicators]);
|
|
3938
3986
|
const tree = useMemo(() => buildTree(resolved, root, typeFilter), [
|
|
3939
3987
|
resolved,
|
|
3940
3988
|
root,
|
|
@@ -4206,6 +4254,7 @@ function TokenNavigator({ root, type, initiallyExpanded = 1, searchable = true,
|
|
|
4206
4254
|
root,
|
|
4207
4255
|
resolveInView,
|
|
4208
4256
|
onNavigate: navigateTo,
|
|
4257
|
+
enabled: enabledIndicators,
|
|
4209
4258
|
level: 1,
|
|
4210
4259
|
setsize: visibleTree.length,
|
|
4211
4260
|
posinset: i + 1
|
|
@@ -4219,7 +4268,7 @@ function TokenNavigator({ root, type, initiallyExpanded = 1, searchable = true,
|
|
|
4219
4268
|
]
|
|
4220
4269
|
});
|
|
4221
4270
|
}
|
|
4222
|
-
function TreeNodeRow({ node, expanded, focusedPath, registerTreeItem, onToggle, onFocusPath, onLeafClick, root, resolveInView, onNavigate, level, setsize, posinset }) {
|
|
4271
|
+
function TreeNodeRow({ node, expanded, focusedPath, registerTreeItem, onToggle, onFocusPath, onLeafClick, root, resolveInView, onNavigate, enabled, level, setsize, posinset }) {
|
|
4223
4272
|
if (node.kind === "leaf") return /* @__PURE__ */ jsx(LeafRow, {
|
|
4224
4273
|
node,
|
|
4225
4274
|
isFocused: focusedPath === node.path,
|
|
@@ -4229,6 +4278,7 @@ function TreeNodeRow({ node, expanded, focusedPath, registerTreeItem, onToggle,
|
|
|
4229
4278
|
root,
|
|
4230
4279
|
resolveInView,
|
|
4231
4280
|
onNavigate,
|
|
4281
|
+
enabled,
|
|
4232
4282
|
level,
|
|
4233
4283
|
setsize,
|
|
4234
4284
|
posinset
|
|
@@ -4279,6 +4329,7 @@ function TreeNodeRow({ node, expanded, focusedPath, registerTreeItem, onToggle,
|
|
|
4279
4329
|
root,
|
|
4280
4330
|
resolveInView,
|
|
4281
4331
|
onNavigate,
|
|
4332
|
+
enabled,
|
|
4282
4333
|
level: level + 1,
|
|
4283
4334
|
setsize: node.children.length,
|
|
4284
4335
|
posinset: i + 1
|
|
@@ -4286,7 +4337,7 @@ function TreeNodeRow({ node, expanded, focusedPath, registerTreeItem, onToggle,
|
|
|
4286
4337
|
})]
|
|
4287
4338
|
});
|
|
4288
4339
|
}
|
|
4289
|
-
const LeafRow = memo(function LeafRow({ node, isFocused, registerTreeItem, onFocusPath, onLeafClick, root, resolveInView, onNavigate, level, setsize, posinset }) {
|
|
4340
|
+
const LeafRow = memo(function LeafRow({ node, isFocused, registerTreeItem, onFocusPath, onLeafClick, root, resolveInView, onNavigate, enabled, level, setsize, posinset }) {
|
|
4290
4341
|
const type = node.token.$type ?? "";
|
|
4291
4342
|
const project = useProject();
|
|
4292
4343
|
const colorFormat = useColorFormat();
|
|
@@ -4306,7 +4357,7 @@ const LeafRow = memo(function LeafRow({ node, isFocused, registerTreeItem, onFoc
|
|
|
4306
4357
|
children: /* @__PURE__ */ jsxs("div", {
|
|
4307
4358
|
className: "sb-token-navigator__leaf-row",
|
|
4308
4359
|
"data-testid": "token-navigator-leaf-row",
|
|
4309
|
-
"data-deprecated": isDeprecated ? "true" : void 0,
|
|
4360
|
+
"data-deprecated": enabled.deprecation && isDeprecated ? "true" : void 0,
|
|
4310
4361
|
onClick: () => {
|
|
4311
4362
|
onFocusPath(node.path);
|
|
4312
4363
|
onLeafClick(node.path);
|
|
@@ -4331,8 +4382,9 @@ const LeafRow = memo(function LeafRow({ node, isFocused, registerTreeItem, onFoc
|
|
|
4331
4382
|
root,
|
|
4332
4383
|
variance,
|
|
4333
4384
|
colorFormat,
|
|
4334
|
-
resolveInView,
|
|
4335
|
-
onNavigate
|
|
4385
|
+
canReference: resolveInView,
|
|
4386
|
+
onReferenceClick: onNavigate,
|
|
4387
|
+
enabled
|
|
4336
4388
|
}),
|
|
4337
4389
|
/* @__PURE__ */ jsx(LeafPreview, {
|
|
4338
4390
|
path: node.path,
|
|
@@ -4404,8 +4456,8 @@ const LeafPreview = memo(function LeafPreview({ path, token }) {
|
|
|
4404
4456
|
});
|
|
4405
4457
|
//#endregion
|
|
4406
4458
|
//#region src/TokenTable.tsx
|
|
4407
|
-
function TokenTable({ filter, type, caption, sortBy = "path", sortDir = "asc", searchable = true, onSelect, id }) {
|
|
4408
|
-
const { resolved, activeTheme, activeAxes, cssVarPrefix, listing } = useProject();
|
|
4459
|
+
function TokenTable({ filter, type, caption, sortBy = "path", sortDir = "asc", searchable = true, onSelect, id, indicators }) {
|
|
4460
|
+
const { resolved, activeTheme, activeAxes, cssVarPrefix, listing, varianceByPath } = useProject();
|
|
4409
4461
|
const colorFormat = useColorFormat();
|
|
4410
4462
|
const blockKey = useBlockKey("TokenTable", [
|
|
4411
4463
|
filter,
|
|
@@ -4413,6 +4465,7 @@ function TokenTable({ filter, type, caption, sortBy = "path", sortDir = "asc", s
|
|
|
4413
4465
|
caption,
|
|
4414
4466
|
id
|
|
4415
4467
|
]);
|
|
4468
|
+
const enabledIndicators = useMemo(() => resolveIndicators(indicators), [indicators]);
|
|
4416
4469
|
const [selectedPath, setSelectedPath] = usePersistedState(`${blockKey}::selected`, null);
|
|
4417
4470
|
const [query, setQuery] = usePersistedState(`${blockKey}::query`, "");
|
|
4418
4471
|
const deferredQuery = useDeferredValue(query);
|
|
@@ -4499,79 +4552,111 @@ function TokenTable({ filter, type, caption, sortBy = "path", sortDir = "asc", s
|
|
|
4499
4552
|
className: "sb-token-table__caption",
|
|
4500
4553
|
children: captionText
|
|
4501
4554
|
}),
|
|
4502
|
-
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4555
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
4556
|
+
/* @__PURE__ */ jsx("th", {
|
|
4557
|
+
className: cx("sb-token-table__th", "sb-token-table__th--path"),
|
|
4558
|
+
children: "Path"
|
|
4559
|
+
}),
|
|
4560
|
+
/* @__PURE__ */ jsx("th", {
|
|
4561
|
+
className: cx("sb-token-table__th", "sb-token-table__th--value"),
|
|
4562
|
+
children: "Value"
|
|
4563
|
+
}),
|
|
4564
|
+
/* @__PURE__ */ jsx("th", {
|
|
4565
|
+
className: "sb-token-table__th sb-token-table__th--refs",
|
|
4566
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
4567
|
+
className: "sb-token-table__sr-status",
|
|
4568
|
+
children: "References and status"
|
|
4569
|
+
})
|
|
4570
|
+
})
|
|
4571
|
+
] }) }),
|
|
4509
4572
|
/* @__PURE__ */ jsxs("tbody", { children: [visibleRows.length === 0 && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsxs("td", {
|
|
4510
|
-
colSpan:
|
|
4573
|
+
colSpan: 3,
|
|
4511
4574
|
className: "sb-token-table__td sb-token-table__empty-row",
|
|
4512
4575
|
children: [
|
|
4513
4576
|
"No tokens match \"",
|
|
4514
4577
|
query.trim(),
|
|
4515
4578
|
"\"."
|
|
4516
4579
|
]
|
|
4517
|
-
}) }), visibleRows.map((row) =>
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
row.
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
className: "sb-token-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4580
|
+
}) }), visibleRows.map((row) => {
|
|
4581
|
+
const token = resolved[row.path];
|
|
4582
|
+
const dep = token?.$deprecated;
|
|
4583
|
+
const isDeprecated = dep === true || typeof dep === "string" && dep.length > 0;
|
|
4584
|
+
return /* @__PURE__ */ jsxs("tr", {
|
|
4585
|
+
className: "sb-token-table__row",
|
|
4586
|
+
onClick: () => handleRowClick(row.path),
|
|
4587
|
+
onKeyDown: (e) => {
|
|
4588
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
4589
|
+
e.preventDefault();
|
|
4590
|
+
handleRowClick(row.path);
|
|
4591
|
+
}
|
|
4592
|
+
},
|
|
4593
|
+
tabIndex: 0,
|
|
4594
|
+
"aria-haspopup": "dialog",
|
|
4595
|
+
"aria-label": `Inspect ${row.path}`,
|
|
4596
|
+
"data-testid": "token-table-row",
|
|
4597
|
+
"data-path": row.path,
|
|
4598
|
+
children: [
|
|
4599
|
+
/* @__PURE__ */ jsx("td", {
|
|
4600
|
+
className: cx("sb-token-table__td", "sb-token-table__path"),
|
|
4601
|
+
"data-deprecated": enabledIndicators.deprecation && isDeprecated ? "true" : void 0,
|
|
4602
|
+
children: row.path
|
|
4603
|
+
}),
|
|
4604
|
+
/* @__PURE__ */ jsx("td", {
|
|
4605
|
+
className: "sb-token-table__td",
|
|
4606
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
4607
|
+
className: "sb-token-table__value-cell",
|
|
4608
|
+
children: [
|
|
4609
|
+
row.type && /* @__PURE__ */ jsx("span", {
|
|
4610
|
+
className: "sb-token-table__type-pill",
|
|
4611
|
+
children: row.type
|
|
4612
|
+
}),
|
|
4613
|
+
row.isColor && /* @__PURE__ */ jsx("span", {
|
|
4614
|
+
className: "sb-token-table__swatch",
|
|
4615
|
+
style: { background: row.cssVar },
|
|
4616
|
+
"aria-hidden": true
|
|
4617
|
+
}),
|
|
4618
|
+
/* @__PURE__ */ jsx("span", {
|
|
4619
|
+
className: "sb-token-table__value-text",
|
|
4620
|
+
title: row.value,
|
|
4621
|
+
"data-testid": "token-table-value",
|
|
4622
|
+
children: row.value
|
|
4623
|
+
}),
|
|
4624
|
+
row.outOfGamut && /* @__PURE__ */ jsx("span", {
|
|
4625
|
+
title: "Out of sRGB gamut for this format",
|
|
4626
|
+
"aria-label": "out of gamut",
|
|
4627
|
+
className: "sb-token-table__gamut-warn",
|
|
4628
|
+
children: "⚠"
|
|
4629
|
+
}),
|
|
4630
|
+
/* @__PURE__ */ jsx("span", {
|
|
4631
|
+
className: "sb-token-table__copy-wrap",
|
|
4632
|
+
onClick: (e) => e.stopPropagation(),
|
|
4633
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
4634
|
+
role: "presentation",
|
|
4635
|
+
children: /* @__PURE__ */ jsx(CopyButton$1, {
|
|
4636
|
+
value: row.value,
|
|
4637
|
+
label: `Copy value ${row.value}`,
|
|
4638
|
+
className: "sb-token-table__copy"
|
|
4639
|
+
})
|
|
4640
|
+
})
|
|
4641
|
+
]
|
|
4570
4642
|
})
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4643
|
+
}),
|
|
4644
|
+
/* @__PURE__ */ jsx("td", {
|
|
4645
|
+
className: "sb-token-table__td sb-token-table__refs",
|
|
4646
|
+
children: token && /* @__PURE__ */ jsx(RowIndicators, {
|
|
4647
|
+
path: row.path,
|
|
4648
|
+
token,
|
|
4649
|
+
root: void 0,
|
|
4650
|
+
variance: varianceByPath[row.path],
|
|
4651
|
+
colorFormat,
|
|
4652
|
+
canReference: (p) => p in resolved,
|
|
4653
|
+
onReferenceClick: (p) => setSelectedPath(p),
|
|
4654
|
+
enabled: enabledIndicators
|
|
4655
|
+
})
|
|
4656
|
+
})
|
|
4657
|
+
]
|
|
4658
|
+
}, row.path);
|
|
4659
|
+
})] })
|
|
4575
4660
|
]
|
|
4576
4661
|
}),
|
|
4577
4662
|
selectedPath !== null && /* @__PURE__ */ jsx(DetailOverlay, {
|