@unpunnyfuns/swatchbook-blocks 0.67.0 → 0.69.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
@@ -4,7 +4,7 @@ React MDX doc blocks for [swatchbook](https://github.com/unpunnyfuns/swatchbook)
4
4
 
5
5
  Render your DTCG tokens in `.mdx` stories: swatch grids, type-specific previews, per-token inspectors. The blocks react to the toolbar's axis flips without any wiring in your story code.
6
6
 
7
- Most consumers pick this up transitively via [`@unpunnyfuns/swatchbook-addon`](../addon); `import { TokenTable } from '@unpunnyfuns/swatchbook-addon'` works out of the box. Install this package directly when you want blocks *without* the Storybook addon, such as unit tests or a standalone React app wrapping tokens in a custom surface.
7
+ Most consumers pick this up transitively via [`@unpunnyfuns/swatchbook-addon`](../addon); `import { TokenTable } from '@unpunnyfuns/swatchbook-addon'` works out of the box. Install this package directly when you want blocks _without_ the Storybook addon, such as unit tests or a standalone React app wrapping tokens in a custom surface.
8
8
 
9
9
  ## Install
10
10
 
@@ -32,7 +32,7 @@ import snapshot from './tokens-snapshot.json';
32
32
 
33
33
  <SwatchbookProvider value={snapshot}>
34
34
  <TokenTable filter="color.**" />
35
- </SwatchbookProvider>
35
+ </SwatchbookProvider>;
36
36
  ```
37
37
 
38
38
  Block catalogue, props, and composition patterns live in the [blocks reference](https://unpunnyfuns.github.io/swatchbook/reference/blocks) and the [authoring guide](https://unpunnyfuns.github.io/swatchbook/guides/authoring-doc-stories).
package/dist/index.d.mts CHANGED
@@ -304,6 +304,12 @@ interface ColorTableProps {
304
304
  /** Configure the per-row indicator strip. See `IndicatorsProp`. Gamut stays in the Value cell, so it is not part of this strip. */
305
305
  indicators?: IndicatorsProp;
306
306
  }
307
+ /**
308
+ * A grouped, searchable table of `$type: color` tokens. Suffix-matched
309
+ * variants (see `variants` prop) collapse into a single row with a pill
310
+ * selector; clicking a row expands it in place to show the description,
311
+ * alias chain, and (for grouped rows) every variant's hex/HSL/OKLCH values.
312
+ */
307
313
  declare function ColorTable({
308
314
  filter,
309
315
  caption,
@@ -543,10 +549,6 @@ interface OpacityScaleProps {
543
549
  * checkerboard backdrop, so the transparency is visually readable. The
544
550
  * number by itself (`0.4`) doesn't convey what the token looks like
545
551
  * applied to a surface; the sample does.
546
- *
547
- * Only tokens whose `$value` is a finite number between 0 and 1
548
- * inclusive are rendered — non-opacity `number` siblings (`line-height`,
549
- * `z-index`) fall out naturally.
550
552
  */
551
553
  declare function OpacityScale({
552
554
  filter,
@@ -576,6 +578,32 @@ interface ChannelGlobals {
576
578
  }
577
579
  declare function useChannelGlobals(): ChannelGlobals;
578
580
  //#endregion
581
+ //#region src/internal/channel.d.ts
582
+ /**
583
+ * Minimal event-source contract blocks need from their host. Storybook's
584
+ * preview Channel satisfies it structurally; a plain emitter or a test double
585
+ * does too. Blocks never import `storybook/preview-api` — the addon, which
586
+ * owns the Storybook relationship, injects the channel at preview init via
587
+ * {@link registerChannel}, mirroring how `registerTokenSource` injects the
588
+ * initial token snapshot.
589
+ */
590
+ interface BlockChannel {
591
+ on<T>(event: string, listener: (payload: T) => void): void;
592
+ }
593
+ /**
594
+ * Inject the host channel. Called once by the addon preview at init. Runs any
595
+ * subscribers that registered before the channel existed, then clears the
596
+ * queue. Idempotent for consumers: each subscriber guards its own attach, so a
597
+ * re-register (HMR) does not double-wire.
598
+ */
599
+ declare function registerChannel(next: BlockChannel): void;
600
+ /**
601
+ * Attach a subscriber to the host channel now if one is registered, else queue
602
+ * it to run the moment {@link registerChannel} fires. Blocks call this at
603
+ * module load; the queue absorbs the gap until the addon injects the channel.
604
+ */
605
+ declare function onChannel(attach: (channel: BlockChannel) => void): void;
606
+ //#endregion
579
607
  //#region src/provider.d.ts
580
608
  interface SwatchbookProviderProps {
581
609
  value: ProjectSnapshot;
@@ -835,6 +863,11 @@ interface TokenNavigatorProps {
835
863
  /** Configure the per-row indicator strip. See `IndicatorsProp`. */
836
864
  indicators?: IndicatorsProp;
837
865
  }
866
+ /**
867
+ * A collapsible, searchable tree of tokens with roving-tabindex keyboard
868
+ * navigation. Click a leaf to inspect it in a slide-over (unless `onSelect`
869
+ * is provided, which hands the follow-up to the consumer).
870
+ */
838
871
  declare function TokenNavigator({
839
872
  root,
840
873
  type,
@@ -888,6 +921,11 @@ interface TokenTableProps {
888
921
  /** Configure the per-row indicator strip. See `IndicatorsProp`. */
889
922
  indicators?: IndicatorsProp;
890
923
  }
924
+ /**
925
+ * A sortable, searchable table of tokens. Click a row to inspect it in a
926
+ * slide-over (unless `onSelect` is provided, which hands the follow-up to the
927
+ * consumer).
928
+ */
891
929
  declare function TokenTable({
892
930
  filter,
893
931
  type,
@@ -928,5 +966,5 @@ declare function TypographyScale({
928
966
  sortDir
929
967
  }: TypographyScaleProps): ReactElement;
930
968
  //#endregion
931
- export { AliasChain, type AliasChainProps, AliasedBy, type AliasedByProps, AxesContext, AxisVariance, type AxisVarianceProps, BorderPreview, type BorderPreviewProps, BorderSample, type BorderSampleProps, COLOR_FORMATS, type ChannelGlobals, type ColorFormat, ColorFormatContext, ColorPalette, type ColorPaletteProps, ColorTable, type ColorTableProps, CompositeBreakdown, type CompositeBreakdownProps, CompositePreview, type CompositePreviewProps, ConsumerOutput, type ConsumerOutputProps, Diagnostics, type DiagnosticsProps, DimensionBar, type DimensionBarProps, DimensionScale, type DimensionScaleProps, type DimensionVisual, FontFamilyPreview, type FontFamilyPreviewProps, 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, StrokeStylePreview, type StrokeStylePreviewProps, SwatchbookContext, SwatchbookProvider, type SwatchbookProviderProps, TOKENS_UPDATED_EVENT, ThemeContext, TokenDetail, type TokenDetailProps, TokenHeader, type TokenHeaderProps, TokenNavigator, type TokenNavigatorProps, type TokenSnapshot, 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 VirtualTokenGraph, type VirtualTokenListingShape, formatColor, registerTokenSource, useActiveAxes, useActiveTheme, useChannelGlobals, useColorFormat, useOptionalSwatchbookData, useSwatchbookData, useTokenSnapshot };
969
+ export { AliasChain, type AliasChainProps, AliasedBy, type AliasedByProps, AxesContext, AxisVariance, type AxisVarianceProps, type BlockChannel, BorderPreview, type BorderPreviewProps, BorderSample, type BorderSampleProps, COLOR_FORMATS, type ChannelGlobals, type ColorFormat, ColorFormatContext, ColorPalette, type ColorPaletteProps, ColorTable, type ColorTableProps, CompositeBreakdown, type CompositeBreakdownProps, CompositePreview, type CompositePreviewProps, ConsumerOutput, type ConsumerOutputProps, Diagnostics, type DiagnosticsProps, DimensionBar, type DimensionBarProps, DimensionScale, type DimensionScaleProps, type DimensionVisual, FontFamilyPreview, type FontFamilyPreviewProps, 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, StrokeStylePreview, type StrokeStylePreviewProps, SwatchbookContext, SwatchbookProvider, type SwatchbookProviderProps, TOKENS_UPDATED_EVENT, ThemeContext, TokenDetail, type TokenDetailProps, TokenHeader, type TokenHeaderProps, TokenNavigator, type TokenNavigatorProps, type TokenSnapshot, 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 VirtualTokenGraph, type VirtualTokenListingShape, formatColor, onChannel, registerChannel, registerTokenSource, useActiveAxes, useActiveTheme, useChannelGlobals, useColorFormat, useOptionalSwatchbookData, useSwatchbookData, useTokenSnapshot };
932
970
  //# sourceMappingURL=index.d.mts.map