@unpunnyfuns/swatchbook-blocks 0.16.0 → 0.18.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 CHANGED
@@ -84,6 +84,34 @@ interface VirtualTokenShape {
84
84
  aliasChain?: readonly string[];
85
85
  aliasedBy?: readonly string[];
86
86
  }
87
+ /**
88
+ * Subset of `@terrazzo/plugin-token-listing`'s `ListedToken` that the
89
+ * snapshot carries. Blocks read `names.css` for the authoritative CSS
90
+ * variable name and `previewValue` for the display-ready CSS string.
91
+ * `source.loc` enables "jump to authoring source" affordances.
92
+ *
93
+ * Only the fields blocks consume are typed here; the plugin's full shape
94
+ * lives in `@unpunnyfuns/swatchbook-core`.
95
+ */
96
+ interface VirtualTokenListingShape {
97
+ names: Record<string, string>;
98
+ previewValue?: string | number;
99
+ source?: {
100
+ resource: string;
101
+ loc?: {
102
+ start: {
103
+ line: number;
104
+ column: number;
105
+ offset: number;
106
+ };
107
+ end: {
108
+ line: number;
109
+ column: number;
110
+ offset: number;
111
+ };
112
+ };
113
+ };
114
+ }
87
115
  interface VirtualPresetShape {
88
116
  name: string;
89
117
  axes: Partial<Record<string, string>>;
@@ -106,6 +134,14 @@ interface ProjectSnapshot {
106
134
  cssVarPrefix: string;
107
135
  diagnostics: readonly VirtualDiagnosticShape[];
108
136
  css: string;
137
+ /**
138
+ * Path-indexed Token Listing data produced by
139
+ * `@terrazzo/plugin-token-listing`. Blocks prefer reading authoritative
140
+ * CSS var names and preview values from here; empty for non-resolver
141
+ * projects. Treat as enrichment — fall back gracefully when a path is
142
+ * absent.
143
+ */
144
+ listing?: Readonly<Record<string, VirtualTokenListingShape>>;
109
145
  }
110
146
  /**
111
147
  * Context carrying the full {@link ProjectSnapshot}. `null` sentinel lets
@@ -246,33 +282,35 @@ interface ColorTableProps {
246
282
  /** `'asc'` (default) or `'desc'`. */
247
283
  sortDir?: SortDir;
248
284
  /**
249
- * Render a fuzzy-search input above the table (case-insensitive,
250
- * single-char typo tolerance, out-of-order terms, matches across path +
251
- * any format value). Defaults to `true`.
285
+ * Render a fuzzy-search input above the table. Defaults to `true`.
252
286
  */
253
287
  searchable?: boolean;
254
288
  /**
255
- * Called with the clicked row's dot-path. When set, the built-in
256
- * `<TokenDetail>` drawer is suppressed — the consumer owns follow-up UI.
289
+ * Called with the *currently-selected* variant's dot-path on row click.
290
+ * When set, the built-in expand-in-place behavior is suppressed — the
291
+ * consumer owns follow-up UI.
257
292
  */
258
293
  onSelect?(path: string): void;
259
294
  /**
260
295
  * Map from a display label to a suffix matched against each token's
261
- * trailing path segment. A row whose leaf matches one of the suffixes
262
- * gets the corresponding label rendered as a pill after the token name.
296
+ * trailing path segment. Tokens whose leaves match a suffix are grouped
297
+ * under a shared "base" path (the path with the suffix stripped), and
298
+ * the group renders as a single row with a pill selector — clicking a
299
+ * pill swaps the displayed values to that variant. Sibling tokens
300
+ * without a suffix that share the group's base path are labeled `base`.
263
301
  *
264
- * Accepts both DTCG-idiomatic and Backmarket-style conventions:
265
- * - **Dot segment** (`color.bg.hi.disabled`): the last dot-segment equals
266
- * the suffix exactly (`suffix === 'disabled'`).
267
- * - **Hyphen tail** (`color.bg.hi-d`): the last dot-segment ends in
268
- * `-<suffix>` (`suffix === 'd'`).
302
+ * Matches both DTCG-idiomatic and Backmarket-style conventions:
303
+ * - **Dot segment** (`color.bg.hi.disabled`): last dot-segment equals
304
+ * the suffix (`disabled`). Base path = drop the last segment.
305
+ * - **Hyphen tail** (`color.bg.hi-d`): last dot-segment ends in
306
+ * `-<suffix>` (`d`). Base path = trim the `-<suffix>` from the leaf.
269
307
  *
270
- * Longest-suffix-wins: `{ hover: 'h', hoverDark: 'h-dark' }` picks
271
- * `hoverDark` for a path ending in `-h-dark`. The hyphen-tail form
272
- * requires an actual hyphen boundary — suffix `0` does not match
273
- * `neutral-900`. Tokens that don't match any suffix render with no pill.
308
+ * Longest-suffix-wins. Hyphen-tail form requires an actual hyphen
309
+ * boundary — suffix `0` does not match `neutral-900`.
274
310
  *
275
- * Empty map (default) no pills; the block behaves exactly as before.
311
+ * Single-member groups render as plain rows (no pill selector). Empty
312
+ * map (default) disables grouping entirely; each token renders as its
313
+ * own row, identical to the pre-grouping behavior.
276
314
  */
277
315
  variants?: Record<string, string>;
278
316
  }