@unpunnyfuns/swatchbook-blocks 0.55.0 → 0.57.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/README.md CHANGED
@@ -19,8 +19,8 @@ Inside Storybook the addon mounts a `SwatchbookProvider` for you:
19
19
  ```mdx
20
20
  import { ColorPalette, TokenTable, TokenDetail } from '@unpunnyfuns/swatchbook-addon';
21
21
 
22
- <ColorPalette filter="color.*" />
23
- <TokenTable filter="color.*" type="color" />
22
+ <ColorPalette filter="color.**" />
23
+ <TokenTable filter="color.**" type="color" />
24
24
  <TokenDetail path="color.accent.bg" />
25
25
  ```
26
26
 
package/dist/index.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _$react from "react";
2
2
  import { ReactElement, ReactNode } from "react";
3
- import { Axis, AxisVarianceResult, Diagnostic, Permutation, Preset } from "@unpunnyfuns/swatchbook-core";
3
+ import { Axis, AxisVarianceResult, Diagnostic, Preset } from "@unpunnyfuns/swatchbook-core";
4
+ import { SlimListedToken } from "@unpunnyfuns/swatchbook-core/snapshot-for-wire";
4
5
 
5
6
  //#region src/format-color.d.ts
6
7
  /**
@@ -65,15 +66,27 @@ declare function formatColor(value: unknown, format: ColorFormat, fallback?: str
65
66
  * in `packages/addon/src/virtual.d.ts` describe the same payload.
66
67
  */
67
68
  type VirtualAxisShape = Axis;
68
- type VirtualPermutationShape = Permutation;
69
69
  type VirtualDiagnosticShape = Diagnostic;
70
70
  interface VirtualTokenShape {
71
- $type?: string;
71
+ $type?: string | undefined;
72
72
  $value?: unknown;
73
- $description?: string;
74
- aliasOf?: string;
75
- aliasChain?: readonly string[];
76
- aliasedBy?: readonly string[];
73
+ $description?: string | undefined;
74
+ aliasOf?: string | undefined;
75
+ aliasChain?: readonly string[] | undefined;
76
+ aliasedBy?: readonly string[] | undefined;
77
+ /**
78
+ * Per-sub-field alias map for composite tokens whose value blends
79
+ * primitives with aliased fragments — Terrazzo populates this when
80
+ * one or more component fields of a composite ($type: 'border',
81
+ * 'shadow', 'typography', 'gradient', 'transition') resolve through
82
+ * an alias. The `CompositeBreakdown` block reads it to render the
83
+ * source path beside each component value. Typed as `unknown` because
84
+ * the shape varies per composite type (color carries a
85
+ * `{components: (string | undefined)[]}` sub-shape; typography/border
86
+ * carry a flat `Record<string, string | undefined>`); the block
87
+ * narrows it at the consumer.
88
+ */
89
+ partialAliasOf?: unknown;
77
90
  }
78
91
  /**
79
92
  * Subset of `@terrazzo/plugin-token-listing`'s `ListedToken` that the
@@ -81,28 +94,11 @@ interface VirtualTokenShape {
81
94
  * variable name and `previewValue` for the display-ready CSS string.
82
95
  * `source.loc` enables "jump to authoring source" affordances.
83
96
  *
84
- * Only the fields blocks consume are typed here; the plugin's full shape
85
- * lives in `@unpunnyfuns/swatchbook-core`.
97
+ * Aliases `SlimListedToken` from core's `/snapshot-for-wire` subpath —
98
+ * the single canonical wire shape; both the addon's plugin (server-side
99
+ * emit) and blocks (consumer-side read) reference the same definition.
86
100
  */
87
- interface VirtualTokenListingShape {
88
- names: Record<string, string>;
89
- previewValue?: string | number;
90
- source?: {
91
- resource: string;
92
- loc?: {
93
- start: {
94
- line: number;
95
- column: number;
96
- offset: number;
97
- };
98
- end: {
99
- line: number;
100
- column: number;
101
- offset: number;
102
- };
103
- };
104
- };
105
- }
101
+ type VirtualTokenListingShape = SlimListedToken;
106
102
  type VirtualPresetShape = Preset;
107
103
  /**
108
104
  * Wire shape of one `Project.jointOverrides` entry — same as core's
@@ -116,7 +112,7 @@ interface VirtualJointOverrideShape {
116
112
  /**
117
113
  * Map from path → cached `AxisVarianceResult`. Snapshot carries this
118
114
  * so the `AxisVariance` block can O(1) look up which axes affect a
119
- * token instead of re-running `analyzeAxisVariance` on every render.
115
+ * token instead of re-running variance analysis on every render.
120
116
  */
121
117
  type VirtualVarianceByPathShape = Record<string, AxisVarianceResult>;
122
118
  /**
@@ -129,18 +125,7 @@ interface ProjectSnapshot {
129
125
  /** Axis names suppressed via `config.disabledAxes` — pinned to their defaults, hidden from the toolbar. */
130
126
  disabledAxes: readonly string[];
131
127
  presets: readonly VirtualPresetShape[];
132
- /**
133
- * @deprecated Wire-shipped permutations were removed in PR 6a.
134
- * Hand-built snapshots (tests, MDX consumers) may still populate
135
- * this for backward compatibility with the legacy fallback path
136
- * in `useProject`. Production preview snapshots omit it.
137
- */
138
- permutations?: readonly VirtualPermutationShape[];
139
- /**
140
- * @deprecated See `permutations`. Wire format dropped in PR 6a.
141
- */
142
- permutationsResolved?: Record<string, Record<string, VirtualTokenShape>>;
143
- activePermutation: string;
128
+ activeTheme: string;
144
129
  activeAxes: Readonly<Record<string, string>>;
145
130
  cssVarPrefix: string;
146
131
  diagnostics: readonly VirtualDiagnosticShape[];
@@ -157,26 +142,23 @@ interface ProjectSnapshot {
157
142
  * Per-axis cell maps — `cells[axis][context]` is the resolved token
158
143
  * data for `{ ...defaults, [axis]: context }`. Bounded by
159
144
  * `Σ(axes × contexts)` regardless of cartesian product size.
160
- * Optional during the chain rollout empty fallback when the
161
- * snapshot pre-dates the wire format change.
145
+ * Non-default cells store only the tokens whose value differs from
146
+ * the default-cell baseline (delta cells).
162
147
  */
163
- cells?: Record<string, Record<string, Record<string, VirtualTokenShape>>>;
148
+ cells: Record<string, Record<string, Record<string, VirtualTokenShape>>>;
164
149
  /**
165
150
  * `Project.jointOverrides` flattened to entries for wire transport.
166
151
  * Same ascending-arity iteration order the Map carries on the
167
- * server side.
152
+ * server side. Empty array when no joint divergences exist.
168
153
  */
169
- jointOverrides?: readonly (readonly [string, VirtualJointOverrideShape])[];
154
+ jointOverrides: readonly (readonly [string, VirtualJointOverrideShape])[];
170
155
  /**
171
156
  * Cached per-path variance results. Blocks read this for O(1) axis
172
157
  * variance lookup instead of recomputing on each render.
173
158
  */
174
159
  varianceByPath?: VirtualVarianceByPathShape;
175
- /**
176
- * The default tuple — `{ axis: axis.default }` for every axis.
177
- * Replaces the legacy "look at `permutations[0].input`" pattern.
178
- */
179
- defaultTuple?: Record<string, string>;
160
+ /** The default tuple — `{ axis: axis.default }` for every axis. */
161
+ defaultTuple: Record<string, string>;
180
162
  /**
181
163
  * Pre-built `resolveAt(tuple)` accessor. The addon's preview
182
164
  * decorator instantiates this once per iframe lifetime — the
@@ -205,11 +187,11 @@ declare function useOptionalSwatchbookData(): ProjectSnapshot | null;
205
187
  * `useGlobals` so the same hook works in autodocs / MDX renders where the
206
188
  * preview-hooks context isn't available.
207
189
  */
208
- declare const PermutationContext: _$react.Context<string>;
209
- declare function useActivePermutation(): string;
190
+ declare const ThemeContext: _$react.Context<string>;
191
+ declare function useActiveTheme(): string;
210
192
  /**
211
193
  * Active axis tuple for the current story/docs render — `Record<axisName,
212
- * contextName>`. Derived from the same input as {@link PermutationContext}; split
194
+ * contextName>`. Derived from the same input as {@link ThemeContext}; split
213
195
  * out so consumers needing per-axis info (toolbar, panel, tuple-aware
214
196
  * blocks) don't have to reparse the composed permutation ID.
215
197
  */
@@ -901,5 +883,5 @@ declare function TypographyScale({
901
883
  sortDir
902
884
  }: TypographyScaleProps): ReactElement;
903
885
  //#endregion
904
- export { AliasChain, type AliasChainProps, AliasedBy, type AliasedByProps, AxesContext, AxisVariance, type AxisVarianceProps, BorderPreview, type BorderPreviewProps, BorderSample, type BorderSampleProps, COLOR_FORMATS, type ColorFormat, ColorFormatContext, ColorPalette, type ColorPaletteProps, ColorTable, type ColorTableProps, CompositeBreakdown, type CompositeBreakdownProps, CompositePreview, type CompositePreviewProps, ConsumerOutput, type ConsumerOutputProps, Diagnostics, type DiagnosticsProps, DimensionBar, type DimensionBarProps, type DimensionKind, DimensionScale, type DimensionScaleProps, FontFamilySample, type FontFamilySampleProps, FontWeightScale, type FontWeightScaleProps, type FormatColorResult, GradientPalette, type GradientPaletteProps, MotionPreview, type MotionPreviewProps, MotionSample, type MotionSampleProps, type MotionSpeed, type NormalizedColor, OpacityScale, type OpacityScaleProps, PermutationContext, type ProjectSnapshot, ShadowPreview, type ShadowPreviewProps, ShadowSample, type ShadowSampleProps, StrokeStyleSample, type StrokeStyleSampleProps, SwatchbookContext, SwatchbookProvider, type SwatchbookProviderProps, TokenDetail, type TokenDetailProps, TokenHeader, type TokenHeaderProps, TokenNavigator, type TokenNavigatorProps, TokenTable, type TokenTableProps, TokenUsageSnippet, type TokenUsageSnippetProps, TypographyScale, type TypographyScaleProps, type VirtualAxisShape as VirtualAxis, type VirtualAxisShape, type VirtualDiagnosticShape as VirtualDiagnostic, type VirtualDiagnosticShape, type VirtualPermutationShape as VirtualPermutation, type VirtualPermutationShape, type VirtualPresetShape as VirtualPreset, type VirtualPresetShape, type VirtualTokenShape as VirtualToken, type VirtualTokenShape, type VirtualTokenListingShape, formatColor, useActiveAxes, useActivePermutation, useColorFormat, useOptionalSwatchbookData, useSwatchbookData };
886
+ export { AliasChain, type AliasChainProps, AliasedBy, type AliasedByProps, AxesContext, AxisVariance, type AxisVarianceProps, BorderPreview, type BorderPreviewProps, BorderSample, type BorderSampleProps, COLOR_FORMATS, type ColorFormat, ColorFormatContext, ColorPalette, type ColorPaletteProps, ColorTable, type ColorTableProps, CompositeBreakdown, type CompositeBreakdownProps, CompositePreview, type CompositePreviewProps, ConsumerOutput, type ConsumerOutputProps, Diagnostics, type DiagnosticsProps, DimensionBar, type DimensionBarProps, type DimensionKind, DimensionScale, type DimensionScaleProps, FontFamilySample, type FontFamilySampleProps, FontWeightScale, type FontWeightScaleProps, type FormatColorResult, GradientPalette, type GradientPaletteProps, MotionPreview, type MotionPreviewProps, MotionSample, type MotionSampleProps, type MotionSpeed, type NormalizedColor, OpacityScale, type OpacityScaleProps, type ProjectSnapshot, ShadowPreview, type ShadowPreviewProps, ShadowSample, type ShadowSampleProps, StrokeStyleSample, type StrokeStyleSampleProps, SwatchbookContext, SwatchbookProvider, type SwatchbookProviderProps, ThemeContext, TokenDetail, type TokenDetailProps, TokenHeader, type TokenHeaderProps, TokenNavigator, type TokenNavigatorProps, TokenTable, type TokenTableProps, TokenUsageSnippet, type TokenUsageSnippetProps, TypographyScale, type TypographyScaleProps, type VirtualAxisShape as VirtualAxis, type VirtualAxisShape, type VirtualDiagnosticShape as VirtualDiagnostic, type VirtualDiagnosticShape, type VirtualPresetShape as VirtualPreset, type VirtualPresetShape, type VirtualTokenShape as VirtualToken, type VirtualTokenShape, type VirtualTokenListingShape, formatColor, useActiveAxes, useActiveTheme, useColorFormat, useOptionalSwatchbookData, useSwatchbookData };
905
887
  //# sourceMappingURL=index.d.mts.map