@unpunnyfuns/swatchbook-blocks 0.63.0 → 0.64.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.mjs CHANGED
@@ -3640,7 +3640,7 @@ function isInView(path, ctx) {
3640
3640
  return true;
3641
3641
  }
3642
3642
  //#endregion
3643
- //#region src/token-navigator/RowIndicators.tsx
3643
+ //#region src/indicators/RowIndicators.tsx
3644
3644
  function relativeLabel(path, root) {
3645
3645
  if (root && path.startsWith(`${root}.`)) return path.slice(root.length + 1);
3646
3646
  return path;
@@ -3650,37 +3650,37 @@ function relativeLabel(path, root) {
3650
3650
  * capped to first … last beyond two hops (no width measurement). Each shown
3651
3651
  * node navigates when in view, else renders as plain text.
3652
3652
  */
3653
- function ForwardChain({ chain, root, resolveInView, onNavigate }) {
3653
+ function ForwardChain({ chain, root, canReference, onReferenceClick }) {
3654
3654
  const full = chain.map((p) => relativeLabel(p, root)).join(" → ");
3655
3655
  const capped = chain.length > 2;
3656
3656
  const shown = capped ? [chain[0], chain[chain.length - 1]] : [...chain];
3657
3657
  return /* @__PURE__ */ jsxs("span", {
3658
- className: "sb-token-navigator__alias-forward",
3658
+ className: "sb-indicator__alias-forward",
3659
3659
  "data-testid": "row-indicator-alias-forward",
3660
3660
  "aria-label": `aliases ${full}`,
3661
3661
  children: [/* @__PURE__ */ jsx("span", {
3662
- className: "sb-token-navigator__alias-arrow",
3662
+ className: "sb-indicator__alias-arrow",
3663
3663
  "aria-hidden": true,
3664
3664
  children: "→"
3665
3665
  }), shown.map((target, i) => {
3666
3666
  const label = relativeLabel(target, root);
3667
- return /* @__PURE__ */ jsxs("span", { children: [resolveInView(target) ? /* @__PURE__ */ jsx("button", {
3667
+ return /* @__PURE__ */ jsxs("span", { children: [canReference(target) ? /* @__PURE__ */ jsx("button", {
3668
3668
  type: "button",
3669
- className: "sb-token-navigator__alias-node",
3669
+ className: "sb-indicator__alias-node",
3670
3670
  "data-testid": "alias-node",
3671
3671
  "aria-label": target,
3672
3672
  onClick: (e) => {
3673
3673
  e.stopPropagation();
3674
- onNavigate(target);
3674
+ onReferenceClick(target);
3675
3675
  },
3676
3676
  children: label
3677
3677
  }) : /* @__PURE__ */ jsx("span", {
3678
- className: "sb-token-navigator__alias-node sb-token-navigator__alias-node--offview",
3678
+ className: "sb-indicator__alias-node sb-indicator__alias-node--offview",
3679
3679
  "data-testid": "alias-node",
3680
3680
  title: "outside current view",
3681
3681
  children: label
3682
3682
  }), capped && i === 0 ? /* @__PURE__ */ jsxs("span", {
3683
- className: "sb-token-navigator__alias-arrow",
3683
+ className: "sb-indicator__alias-arrow",
3684
3684
  "aria-hidden": true,
3685
3685
  children: [
3686
3686
  " ",
@@ -3688,7 +3688,7 @@ function ForwardChain({ chain, root, resolveInView, onNavigate }) {
3688
3688
  " "
3689
3689
  ]
3690
3690
  }) : i < shown.length - 1 ? /* @__PURE__ */ jsxs("span", {
3691
- className: "sb-token-navigator__alias-arrow",
3691
+ className: "sb-indicator__alias-arrow",
3692
3692
  "aria-hidden": true,
3693
3693
  children: [
3694
3694
  " ",
@@ -3702,7 +3702,7 @@ function ForwardChain({ chain, root, resolveInView, onNavigate }) {
3702
3702
  function DeprecatedBadge({ deprecated }) {
3703
3703
  const label = typeof deprecated === "string" ? `deprecated: ${deprecated}` : "deprecated";
3704
3704
  return /* @__PURE__ */ jsx("span", {
3705
- className: "sb-token-navigator__deprecated",
3705
+ className: "sb-indicator__deprecated",
3706
3706
  "data-testid": "row-indicator-deprecated",
3707
3707
  title: label,
3708
3708
  "aria-label": label,
@@ -3714,17 +3714,17 @@ function VarianceBadge({ variance }) {
3714
3714
  const axes = variance.varyingAxes;
3715
3715
  const label = variance.kind === "single" ? variance.axis : `${axes.length} axes`;
3716
3716
  return /* @__PURE__ */ jsxs("span", {
3717
- className: "sb-token-navigator__variance",
3717
+ className: "sb-indicator__variance",
3718
3718
  "data-testid": "row-indicator-variance",
3719
3719
  "aria-label": `varies by ${axes.join(", ")}`,
3720
3720
  children: [/* @__PURE__ */ jsx("span", {
3721
- className: "sb-token-navigator__variance-glyph",
3721
+ className: "sb-indicator__variance-glyph",
3722
3722
  "aria-hidden": true,
3723
3723
  children: "⊹"
3724
3724
  }), label]
3725
3725
  });
3726
3726
  }
3727
- function ReverseCount({ referents, resolveInView, onNavigate }) {
3727
+ function ReverseCount({ referents, canReference, onReferenceClick }) {
3728
3728
  const [open, setOpen] = useState(false);
3729
3729
  const wrapRef = useRef(null);
3730
3730
  const count = referents.length;
@@ -3742,42 +3742,42 @@ function ReverseCount({ referents, resolveInView, onNavigate }) {
3742
3742
  }, [open, single]);
3743
3743
  return /* @__PURE__ */ jsxs("span", {
3744
3744
  ref: wrapRef,
3745
- className: "sb-token-navigator__reverse-wrap",
3745
+ className: "sb-indicator__reverse-wrap",
3746
3746
  onKeyDown: (e) => {
3747
3747
  if (e.key === "Escape") setOpen(false);
3748
3748
  },
3749
3749
  children: [/* @__PURE__ */ jsxs("button", {
3750
3750
  type: "button",
3751
- className: "sb-token-navigator__alias-reverse",
3751
+ className: "sb-indicator__alias-reverse",
3752
3752
  "data-testid": "row-indicator-alias-reverse",
3753
3753
  "aria-label": `referenced by ${count} ${count === 1 ? "token" : "tokens"}`,
3754
3754
  "aria-haspopup": single ? void 0 : "menu",
3755
3755
  "aria-expanded": single ? void 0 : open,
3756
3756
  onClick: (e) => {
3757
3757
  e.stopPropagation();
3758
- if (single) onNavigate(referents[0]);
3758
+ if (single) onReferenceClick(referents[0]);
3759
3759
  else setOpen((v) => !v);
3760
3760
  },
3761
3761
  children: [/* @__PURE__ */ jsx("span", {
3762
- className: "sb-token-navigator__alias-arrow",
3762
+ className: "sb-indicator__alias-arrow",
3763
3763
  "aria-hidden": true,
3764
3764
  children: "←"
3765
3765
  }), count]
3766
3766
  }), !single && open && /* @__PURE__ */ jsx("ul", {
3767
- className: "sb-token-navigator__reverse-menu",
3767
+ className: "sb-indicator__reverse-menu",
3768
3768
  role: "menu",
3769
3769
  children: referents.map((ref) => /* @__PURE__ */ jsx("li", {
3770
3770
  role: "none",
3771
3771
  children: /* @__PURE__ */ jsx("button", {
3772
3772
  type: "button",
3773
3773
  role: "menuitem",
3774
- className: "sb-token-navigator__reverse-item",
3775
- disabled: !resolveInView(ref),
3776
- title: resolveInView(ref) ? void 0 : "outside current view",
3774
+ className: "sb-indicator__reverse-item",
3775
+ disabled: !canReference(ref),
3776
+ title: canReference(ref) ? void 0 : "outside current view",
3777
3777
  onClick: (e) => {
3778
3778
  e.stopPropagation();
3779
3779
  setOpen(false);
3780
- onNavigate(ref);
3780
+ onReferenceClick(ref);
3781
3781
  },
3782
3782
  children: ref
3783
3783
  })
@@ -3787,7 +3787,7 @@ function ReverseCount({ referents, resolveInView, onNavigate }) {
3787
3787
  }
3788
3788
  /** Per-row indicator strip: alias references, variance, gamut, deprecation. */
3789
3789
  function RowIndicators(props) {
3790
- const { token, root, variance, colorFormat, resolveInView, onNavigate } = props;
3790
+ const { token, root, variance, colorFormat, canReference, onReferenceClick } = props;
3791
3791
  const aliasChain = Array.isArray(token.aliasChain) && token.aliasChain.length > 0 ? token.aliasChain : void 0;
3792
3792
  const reverseCount = Array.isArray(token.aliasedBy) && token.aliasedBy.length > 0 ? token.aliasedBy.length : 0;
3793
3793
  const isVarying = variance !== void 0 && variance.kind !== "constant";
@@ -3796,23 +3796,23 @@ function RowIndicators(props) {
3796
3796
  const isDeprecated = deprecated === true || typeof deprecated === "string" && deprecated.length > 0;
3797
3797
  if (!aliasChain && reverseCount === 0 && !isVarying && !outOfGamut && !isDeprecated) return null;
3798
3798
  return /* @__PURE__ */ jsxs("span", {
3799
- className: "sb-token-navigator__indicators",
3799
+ className: "sb-indicator__indicators",
3800
3800
  children: [
3801
3801
  isDeprecated && deprecated !== void 0 && /* @__PURE__ */ jsx(DeprecatedBadge, { deprecated }),
3802
3802
  aliasChain && /* @__PURE__ */ jsx(ForwardChain, {
3803
3803
  chain: aliasChain,
3804
3804
  root,
3805
- resolveInView,
3806
- onNavigate
3805
+ canReference,
3806
+ onReferenceClick
3807
3807
  }),
3808
3808
  reverseCount > 0 && token.aliasedBy && /* @__PURE__ */ jsx(ReverseCount, {
3809
3809
  referents: token.aliasedBy,
3810
- resolveInView,
3811
- onNavigate
3810
+ canReference,
3811
+ onReferenceClick
3812
3812
  }),
3813
3813
  variance && /* @__PURE__ */ jsx(VarianceBadge, { variance }),
3814
3814
  outOfGamut && /* @__PURE__ */ jsx("span", {
3815
- className: "sb-token-navigator__gamut",
3815
+ className: "sb-indicator__gamut",
3816
3816
  title: "Out of sRGB gamut for this format",
3817
3817
  "aria-label": "out of gamut",
3818
3818
  children: "⚠"
@@ -4331,8 +4331,8 @@ const LeafRow = memo(function LeafRow({ node, isFocused, registerTreeItem, onFoc
4331
4331
  root,
4332
4332
  variance,
4333
4333
  colorFormat,
4334
- resolveInView,
4335
- onNavigate
4334
+ canReference: resolveInView,
4335
+ onReferenceClick: onNavigate
4336
4336
  }),
4337
4337
  /* @__PURE__ */ jsx(LeafPreview, {
4338
4338
  path: node.path,
@@ -4405,7 +4405,7 @@ const LeafPreview = memo(function LeafPreview({ path, token }) {
4405
4405
  //#endregion
4406
4406
  //#region src/TokenTable.tsx
4407
4407
  function TokenTable({ filter, type, caption, sortBy = "path", sortDir = "asc", searchable = true, onSelect, id }) {
4408
- const { resolved, activeTheme, activeAxes, cssVarPrefix, listing } = useProject();
4408
+ const { resolved, activeTheme, activeAxes, cssVarPrefix, listing, varianceByPath } = useProject();
4409
4409
  const colorFormat = useColorFormat();
4410
4410
  const blockKey = useBlockKey("TokenTable", [
4411
4411
  filter,
@@ -4499,79 +4499,110 @@ function TokenTable({ filter, type, caption, sortBy = "path", sortDir = "asc", s
4499
4499
  className: "sb-token-table__caption",
4500
4500
  children: captionText
4501
4501
  }),
4502
- /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
4503
- className: cx("sb-token-table__th", "sb-token-table__th--path"),
4504
- children: "Path"
4505
- }), /* @__PURE__ */ jsx("th", {
4506
- className: cx("sb-token-table__th", "sb-token-table__th--value"),
4507
- children: "Value"
4508
- })] }) }),
4502
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
4503
+ /* @__PURE__ */ jsx("th", {
4504
+ className: cx("sb-token-table__th", "sb-token-table__th--path"),
4505
+ children: "Path"
4506
+ }),
4507
+ /* @__PURE__ */ jsx("th", {
4508
+ className: cx("sb-token-table__th", "sb-token-table__th--value"),
4509
+ children: "Value"
4510
+ }),
4511
+ /* @__PURE__ */ jsx("th", {
4512
+ className: "sb-token-table__th sb-token-table__th--refs",
4513
+ children: /* @__PURE__ */ jsx("span", {
4514
+ className: "sb-token-table__sr-status",
4515
+ children: "References and status"
4516
+ })
4517
+ })
4518
+ ] }) }),
4509
4519
  /* @__PURE__ */ jsxs("tbody", { children: [visibleRows.length === 0 && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsxs("td", {
4510
- colSpan: 2,
4520
+ colSpan: 3,
4511
4521
  className: "sb-token-table__td sb-token-table__empty-row",
4512
4522
  children: [
4513
4523
  "No tokens match \"",
4514
4524
  query.trim(),
4515
4525
  "\"."
4516
4526
  ]
4517
- }) }), visibleRows.map((row) => /* @__PURE__ */ jsxs("tr", {
4518
- className: "sb-token-table__row",
4519
- onClick: () => handleRowClick(row.path),
4520
- onKeyDown: (e) => {
4521
- if (e.key === "Enter" || e.key === " ") {
4522
- e.preventDefault();
4523
- handleRowClick(row.path);
4524
- }
4525
- },
4526
- tabIndex: 0,
4527
- "aria-haspopup": "dialog",
4528
- "aria-label": `Inspect ${row.path}`,
4529
- "data-testid": "token-table-row",
4530
- "data-path": row.path,
4531
- children: [/* @__PURE__ */ jsx("td", {
4532
- className: cx("sb-token-table__td", "sb-token-table__path"),
4533
- children: row.path
4534
- }), /* @__PURE__ */ jsx("td", {
4535
- className: "sb-token-table__td",
4536
- children: /* @__PURE__ */ jsxs("span", {
4537
- className: "sb-token-table__value-cell",
4538
- children: [
4539
- row.type && /* @__PURE__ */ jsx("span", {
4540
- className: "sb-token-table__type-pill",
4541
- children: row.type
4542
- }),
4543
- row.isColor && /* @__PURE__ */ jsx("span", {
4544
- className: "sb-token-table__swatch",
4545
- style: { background: row.cssVar },
4546
- "aria-hidden": true
4547
- }),
4548
- /* @__PURE__ */ jsx("span", {
4549
- className: "sb-token-table__value-text",
4550
- title: row.value,
4551
- "data-testid": "token-table-value",
4552
- children: row.value
4553
- }),
4554
- row.outOfGamut && /* @__PURE__ */ jsx("span", {
4555
- title: "Out of sRGB gamut for this format",
4556
- "aria-label": "out of gamut",
4557
- className: "sb-token-table__gamut-warn",
4558
- children: ""
4559
- }),
4560
- /* @__PURE__ */ jsx("span", {
4561
- className: "sb-token-table__copy-wrap",
4562
- onClick: (e) => e.stopPropagation(),
4563
- onKeyDown: (e) => e.stopPropagation(),
4564
- role: "presentation",
4565
- children: /* @__PURE__ */ jsx(CopyButton$1, {
4566
- value: row.value,
4567
- label: `Copy value ${row.value}`,
4568
- className: "sb-token-table__copy"
4569
- })
4527
+ }) }), visibleRows.map((row) => {
4528
+ const token = resolved[row.path];
4529
+ const dep = token?.$deprecated;
4530
+ const isDeprecated = dep === true || typeof dep === "string" && dep.length > 0;
4531
+ return /* @__PURE__ */ jsxs("tr", {
4532
+ className: "sb-token-table__row",
4533
+ onClick: () => handleRowClick(row.path),
4534
+ onKeyDown: (e) => {
4535
+ if (e.key === "Enter" || e.key === " ") {
4536
+ e.preventDefault();
4537
+ handleRowClick(row.path);
4538
+ }
4539
+ },
4540
+ tabIndex: 0,
4541
+ "aria-haspopup": "dialog",
4542
+ "aria-label": `Inspect ${row.path}`,
4543
+ "data-testid": "token-table-row",
4544
+ "data-path": row.path,
4545
+ children: [
4546
+ /* @__PURE__ */ jsx("td", {
4547
+ className: cx("sb-token-table__td", "sb-token-table__path"),
4548
+ "data-deprecated": isDeprecated ? "true" : void 0,
4549
+ children: row.path
4550
+ }),
4551
+ /* @__PURE__ */ jsx("td", {
4552
+ className: "sb-token-table__td",
4553
+ children: /* @__PURE__ */ jsxs("span", {
4554
+ className: "sb-token-table__value-cell",
4555
+ children: [
4556
+ row.type && /* @__PURE__ */ jsx("span", {
4557
+ className: "sb-token-table__type-pill",
4558
+ children: row.type
4559
+ }),
4560
+ row.isColor && /* @__PURE__ */ jsx("span", {
4561
+ className: "sb-token-table__swatch",
4562
+ style: { background: row.cssVar },
4563
+ "aria-hidden": true
4564
+ }),
4565
+ /* @__PURE__ */ jsx("span", {
4566
+ className: "sb-token-table__value-text",
4567
+ title: row.value,
4568
+ "data-testid": "token-table-value",
4569
+ children: row.value
4570
+ }),
4571
+ row.outOfGamut && /* @__PURE__ */ jsx("span", {
4572
+ title: "Out of sRGB gamut for this format",
4573
+ "aria-label": "out of gamut",
4574
+ className: "sb-token-table__gamut-warn",
4575
+ children: "⚠"
4576
+ }),
4577
+ /* @__PURE__ */ jsx("span", {
4578
+ className: "sb-token-table__copy-wrap",
4579
+ onClick: (e) => e.stopPropagation(),
4580
+ onKeyDown: (e) => e.stopPropagation(),
4581
+ role: "presentation",
4582
+ children: /* @__PURE__ */ jsx(CopyButton$1, {
4583
+ value: row.value,
4584
+ label: `Copy value ${row.value}`,
4585
+ className: "sb-token-table__copy"
4586
+ })
4587
+ })
4588
+ ]
4570
4589
  })
4571
- ]
4572
- })
4573
- })]
4574
- }, row.path))] })
4590
+ }),
4591
+ /* @__PURE__ */ jsx("td", {
4592
+ className: "sb-token-table__td sb-token-table__refs",
4593
+ children: token && /* @__PURE__ */ jsx(RowIndicators, {
4594
+ path: row.path,
4595
+ token,
4596
+ root: void 0,
4597
+ variance: varianceByPath[row.path],
4598
+ colorFormat,
4599
+ canReference: (p) => p in resolved,
4600
+ onReferenceClick: (p) => setSelectedPath(p)
4601
+ })
4602
+ })
4603
+ ]
4604
+ }, row.path);
4605
+ })] })
4575
4606
  ]
4576
4607
  }),
4577
4608
  selectedPath !== null && /* @__PURE__ */ jsx(DetailOverlay, {