@takazudo/zdtp 0.4.2 → 0.4.4

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.
Files changed (173) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +20 -15
  3. package/dist/apply/apply-token-overrides.d.ts +0 -1
  4. package/dist/apply/build-apply-overrides.d.ts +20 -5
  5. package/dist/apply/route-tokens-to-files.d.ts +0 -1
  6. package/dist/apply/tier-resolver.d.ts +28 -1
  7. package/dist/apply-modal.d.ts +0 -1
  8. package/dist/astro/DesignTokenPanelHost.astro +2 -4
  9. package/dist/astro/host-adapter.d.ts +0 -1
  10. package/dist/astro/host-adapter.js +16 -16
  11. package/dist/astro/index.d.ts +0 -1
  12. package/dist/astro/index.js +1 -1
  13. package/dist/{autoload-state-DsvvPDih.js → autoload-state-CmhI7q9j.js} +1 -1
  14. package/dist/bin/cors.d.ts +0 -1
  15. package/dist/bin/parse-args.d.ts +0 -1
  16. package/dist/bin/server.d.ts +0 -1
  17. package/dist/bin/server.js +1 -1
  18. package/dist/components/color-picker/color-field.d.ts +0 -1
  19. package/dist/components/color-picker/color-picker.d.ts +12 -3
  20. package/dist/components/color-picker/custom-slider.d.ts +0 -1
  21. package/dist/components/color-picker/index.d.ts +0 -1
  22. package/dist/components/palette-chart/index.d.ts +0 -1
  23. package/dist/components/palette-chart/palette-chart.d.ts +0 -1
  24. package/dist/config/cluster-config.d.ts +36 -14
  25. package/dist/config/color-scheme-utils.d.ts +0 -1
  26. package/dist/config/color-schemes.d.ts +0 -1
  27. package/dist/config/panel-config.d.ts +11 -1
  28. package/dist/controls/dismiss-layer.d.ts +55 -0
  29. package/dist/controls/pill-slider-row.d.ts +0 -1
  30. package/dist/controls/role-button.d.ts +0 -1
  31. package/dist/controls/sanitize-css-value.d.ts +0 -1
  32. package/dist/controls/select-row.d.ts +0 -1
  33. package/dist/controls/slider-row.d.ts +0 -1
  34. package/dist/controls/text-row.d.ts +0 -1
  35. package/dist/controls/tier-ref-selector.d.ts +65 -22
  36. package/dist/controls/token-label.d.ts +0 -1
  37. package/dist/controls/tooltip.d.ts +0 -1
  38. package/dist/controls/use-dialog-backdrop-close.d.ts +32 -0
  39. package/dist/element-path/build-element-path.d.ts +0 -1
  40. package/dist/element-path/element-path-context.d.ts +0 -1
  41. package/dist/element-path/element-path-orchestrator.d.ts +0 -1
  42. package/dist/element-path/element-path-state.d.ts +0 -1
  43. package/dist/element-path/element-path-toast.d.ts +0 -1
  44. package/dist/element-path/element-path-toggle-button.d.ts +0 -1
  45. package/dist/element-path/index.d.ts +0 -1
  46. package/dist/element-path/inspector-overlay.d.ts +0 -1
  47. package/dist/export-modal.d.ts +0 -1
  48. package/dist/highlight/find-elements.d.ts +0 -1
  49. package/dist/highlight/highlight-orchestrator.d.ts +0 -1
  50. package/dist/highlight/highlight-overlay.d.ts +0 -1
  51. package/dist/highlight/highlight-settings-popover.d.ts +0 -1
  52. package/dist/highlight/highlight-state.d.ts +0 -1
  53. package/dist/highlight/highlight-toggle-button.d.ts +0 -1
  54. package/dist/import-modal.d.ts +0 -1
  55. package/dist/index.d.ts +1 -1
  56. package/dist/index.js +3432 -2717
  57. package/dist/{load-routing-XyKgftpe.js → load-routing-DtNTKoLW.js} +1 -1
  58. package/dist/panel-config-CXTCcYQs.js +824 -0
  59. package/dist/panel.d.ts +0 -1
  60. package/dist/server/create-apply-handler.d.ts +0 -1
  61. package/dist/server/index.d.ts +0 -1
  62. package/dist/server/index.js +1 -1
  63. package/dist/server/load-routing.d.ts +0 -1
  64. package/dist/server/path-safety.d.ts +0 -1
  65. package/dist/server/serialize-write.d.ts +0 -1
  66. package/dist/state/autoload-state.d.ts +0 -1
  67. package/dist/state/persist.d.ts +7 -3
  68. package/dist/state/tweak-state.d.ts +146 -10
  69. package/dist/styles/z-index-tokens.d.ts +35 -0
  70. package/dist/tabs/_generic-item-editor.d.ts +0 -1
  71. package/dist/tabs/color-tab.d.ts +13 -2
  72. package/dist/tabs/font-tab.d.ts +0 -1
  73. package/dist/tabs/generic-tab.d.ts +4 -3
  74. package/dist/tabs/palette/palette-check-view.d.ts +0 -1
  75. package/dist/tabs/palette/palette-edit-view.d.ts +0 -1
  76. package/dist/tabs/palette/palette-readout.d.ts +0 -1
  77. package/dist/tabs/palette/palette-tab.d.ts +0 -1
  78. package/dist/tabs/size-tab.d.ts +0 -1
  79. package/dist/tabs/spacing-tab.d.ts +0 -1
  80. package/dist/testing.d.ts +0 -1
  81. package/dist/testing.js +2 -2
  82. package/dist/tokens/manifest.d.ts +0 -1
  83. package/dist/tokens/tier-model.d.ts +50 -1
  84. package/dist/{tweak-state-DzZVbY25.js → tweak-state-BeXkzoj8.js} +662 -583
  85. package/dist/utils/color-convert.d.ts +0 -1
  86. package/dist/utils/color-hsla.d.ts +0 -1
  87. package/dist/utils/color-oklch.d.ts +0 -1
  88. package/dist/utils/copy-to-clipboard.d.ts +0 -1
  89. package/dist/utils/design-token-serde.d.ts +78 -11
  90. package/dist/utils/palette-curve.d.ts +0 -1
  91. package/dist/utils/structural-equal.d.ts +0 -1
  92. package/dist/utils/use-portal-mount.d.ts +0 -1
  93. package/dist/utils/wcag-contrast.d.ts +0 -1
  94. package/dist/zdtp.css +1 -1
  95. package/package.json +24 -11
  96. package/dist/apply/apply-token-overrides.d.ts.map +0 -1
  97. package/dist/apply/build-apply-overrides.d.ts.map +0 -1
  98. package/dist/apply/route-tokens-to-files.d.ts.map +0 -1
  99. package/dist/apply/tier-resolver.d.ts.map +0 -1
  100. package/dist/apply-modal.d.ts.map +0 -1
  101. package/dist/astro/host-adapter.d.ts.map +0 -1
  102. package/dist/astro/index.d.ts.map +0 -1
  103. package/dist/bin/cors.d.ts.map +0 -1
  104. package/dist/bin/parse-args.d.ts.map +0 -1
  105. package/dist/bin/server.d.ts.map +0 -1
  106. package/dist/components/color-picker/color-field.d.ts.map +0 -1
  107. package/dist/components/color-picker/color-picker.d.ts.map +0 -1
  108. package/dist/components/color-picker/custom-slider.d.ts.map +0 -1
  109. package/dist/components/color-picker/index.d.ts.map +0 -1
  110. package/dist/components/palette-chart/index.d.ts.map +0 -1
  111. package/dist/components/palette-chart/palette-chart.d.ts.map +0 -1
  112. package/dist/config/cluster-config.d.ts.map +0 -1
  113. package/dist/config/color-scheme-utils.d.ts.map +0 -1
  114. package/dist/config/color-schemes.d.ts.map +0 -1
  115. package/dist/config/panel-config.d.ts.map +0 -1
  116. package/dist/controls/pill-slider-row.d.ts.map +0 -1
  117. package/dist/controls/role-button.d.ts.map +0 -1
  118. package/dist/controls/sanitize-css-value.d.ts.map +0 -1
  119. package/dist/controls/select-row.d.ts.map +0 -1
  120. package/dist/controls/slider-row.d.ts.map +0 -1
  121. package/dist/controls/text-row.d.ts.map +0 -1
  122. package/dist/controls/tier-ref-selector.d.ts.map +0 -1
  123. package/dist/controls/token-label.d.ts.map +0 -1
  124. package/dist/controls/tooltip.d.ts.map +0 -1
  125. package/dist/element-path/build-element-path.d.ts.map +0 -1
  126. package/dist/element-path/element-path-context.d.ts.map +0 -1
  127. package/dist/element-path/element-path-orchestrator.d.ts.map +0 -1
  128. package/dist/element-path/element-path-state.d.ts.map +0 -1
  129. package/dist/element-path/element-path-toast.d.ts.map +0 -1
  130. package/dist/element-path/element-path-toggle-button.d.ts.map +0 -1
  131. package/dist/element-path/index.d.ts.map +0 -1
  132. package/dist/element-path/inspector-overlay.d.ts.map +0 -1
  133. package/dist/export-modal.d.ts.map +0 -1
  134. package/dist/highlight/find-elements.d.ts.map +0 -1
  135. package/dist/highlight/highlight-orchestrator.d.ts.map +0 -1
  136. package/dist/highlight/highlight-overlay.d.ts.map +0 -1
  137. package/dist/highlight/highlight-settings-popover.d.ts.map +0 -1
  138. package/dist/highlight/highlight-state.d.ts.map +0 -1
  139. package/dist/highlight/highlight-toggle-button.d.ts.map +0 -1
  140. package/dist/import-modal.d.ts.map +0 -1
  141. package/dist/index.d.ts.map +0 -1
  142. package/dist/panel-config-DyVRQ2n1.js +0 -415
  143. package/dist/panel.d.ts.map +0 -1
  144. package/dist/server/create-apply-handler.d.ts.map +0 -1
  145. package/dist/server/index.d.ts.map +0 -1
  146. package/dist/server/load-routing.d.ts.map +0 -1
  147. package/dist/server/path-safety.d.ts.map +0 -1
  148. package/dist/server/serialize-write.d.ts.map +0 -1
  149. package/dist/state/autoload-state.d.ts.map +0 -1
  150. package/dist/state/persist.d.ts.map +0 -1
  151. package/dist/state/tweak-state.d.ts.map +0 -1
  152. package/dist/tabs/_generic-item-editor.d.ts.map +0 -1
  153. package/dist/tabs/color-tab.d.ts.map +0 -1
  154. package/dist/tabs/font-tab.d.ts.map +0 -1
  155. package/dist/tabs/generic-tab.d.ts.map +0 -1
  156. package/dist/tabs/palette/palette-check-view.d.ts.map +0 -1
  157. package/dist/tabs/palette/palette-edit-view.d.ts.map +0 -1
  158. package/dist/tabs/palette/palette-readout.d.ts.map +0 -1
  159. package/dist/tabs/palette/palette-tab.d.ts.map +0 -1
  160. package/dist/tabs/size-tab.d.ts.map +0 -1
  161. package/dist/tabs/spacing-tab.d.ts.map +0 -1
  162. package/dist/testing.d.ts.map +0 -1
  163. package/dist/tokens/manifest.d.ts.map +0 -1
  164. package/dist/tokens/tier-model.d.ts.map +0 -1
  165. package/dist/utils/color-convert.d.ts.map +0 -1
  166. package/dist/utils/color-hsla.d.ts.map +0 -1
  167. package/dist/utils/color-oklch.d.ts.map +0 -1
  168. package/dist/utils/copy-to-clipboard.d.ts.map +0 -1
  169. package/dist/utils/design-token-serde.d.ts.map +0 -1
  170. package/dist/utils/palette-curve.d.ts.map +0 -1
  171. package/dist/utils/structural-equal.d.ts.map +0 -1
  172. package/dist/utils/use-portal-mount.d.ts.map +0 -1
  173. package/dist/utils/wcag-contrast.d.ts.map +0 -1
package/dist/panel.d.ts CHANGED
@@ -16,4 +16,3 @@ interface DesignTokenTweakPanelProps {
16
16
  }
17
17
  export default function DesignTokenTweakPanel({ instanceConfig: instanceConfigProp, }?: DesignTokenTweakPanelProps): import("preact").JSX.Element;
18
18
  export type { TweakState } from './state/tweak-state';
19
- //# sourceMappingURL=panel.d.ts.map
@@ -45,4 +45,3 @@ export interface PerFileResult {
45
45
  * ```
46
46
  */
47
47
  export declare function createApplyHandler(options: ApplyHandlerOptions): (req: Request) => Promise<Response>;
48
- //# sourceMappingURL=create-apply-handler.d.ts.map
@@ -21,4 +21,3 @@ export type { ApplyHandlerOptions, PerFileResult } from './create-apply-handler'
21
21
  export { serializeFileWrite } from './serialize-write';
22
22
  export { CSS_VAR_NAME_RE, isPathSafe, isValidCssVarName, validateAndSanitizeTokens, } from './path-safety';
23
23
  export { loadRoutingFromFile, type ApplyRoutingMap } from './load-routing';
24
- //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- import { C as s, c as i, i as l, a as r, l as t, s as o, v as d } from "../load-routing-XyKgftpe.js";
1
+ import { C as s, c as i, i as l, a as r, l as t, s as o, v as d } from "../load-routing-DtNTKoLW.js";
2
2
  export {
3
3
  s as CSS_VAR_NAME_RE,
4
4
  i as createApplyHandler,
@@ -36,4 +36,3 @@ export type ApplyRoutingMap = Record<string, string>;
36
36
  * ```
37
37
  */
38
38
  export declare function loadRoutingFromFile(absPath: string): ApplyRoutingMap;
39
- //# sourceMappingURL=load-routing.d.ts.map
@@ -33,4 +33,3 @@ export declare function validateAndSanitizeTokens(tokens: Record<string, unknown
33
33
  sanitized?: Record<string, string>;
34
34
  error?: string;
35
35
  };
36
- //# sourceMappingURL=path-safety.d.ts.map
@@ -4,4 +4,3 @@
4
4
  * one settles (success or error). Calls for different paths run in parallel.
5
5
  */
6
6
  export declare function serializeFileWrite<T>(absPath: string, fn: () => Promise<T>): Promise<T>;
7
- //# sourceMappingURL=serialize-write.d.ts.map
@@ -89,4 +89,3 @@ export declare function setAutoload(cfg: PanelConfig, on: boolean): void;
89
89
  * SSR-safe and quota-tolerant.
90
90
  */
91
91
  export declare function clearAutoload(cfg: PanelConfig): void;
92
- //# sourceMappingURL=autoload-state.d.ts.map
@@ -11,6 +11,13 @@
11
11
  * Framework-agnostic wrt. the setState function: pass any
12
12
  * `(updater) => void` that propagates `updater(prev)` to the caller's state.
13
13
  * In practice the panel passes Preact's `setState` from `useState`.
14
+ *
15
+ * `persistColor`'s updater is `(prev: ColorTweakState) => ColorTweakState`, so
16
+ * the widened `ColorTweakState.semanticMappings: Record<string, SemanticValue>`
17
+ * (#459) — including the `{ literal }` / `{ ref }` object variants added for
18
+ * #462 — already flows through this hook's generic pass-through unchanged; the
19
+ * actual validating hydrate/round-trip logic for those variants lives in
20
+ * `tweak-state.ts` (`hydrateSemanticMappings` / `savePersistedState`), not here.
14
21
  */
15
22
  import { type ColorTweakState, type TabOverrides, type TokenOverrides, type TweakState } from './tweak-state';
16
23
  import type { PanelConfig } from '../config/panel-config';
@@ -33,7 +40,6 @@ export declare function usePersist(setState: SetState<TweakState>, cfg?: PanelCo
33
40
  persistTypography: (updater: (prev: TokenOverrides) => TokenOverrides) => void;
34
41
  persistFont: (updater: (prev: TokenOverrides) => TokenOverrides) => void;
35
42
  persistSize: (updater: (prev: TokenOverrides) => TokenOverrides) => void;
36
- persistPanelPosition: (updater: (prev: TweakState["panelPosition"]) => TweakState["panelPosition"]) => void;
37
43
  persistSecondary: (updater: (prev: ColorTweakState | undefined) => ColorTweakState | undefined) => void;
38
44
  };
39
45
  export type Persist = ReturnType<typeof usePersist>['persist'];
@@ -44,7 +50,5 @@ export type PersistTypography = ReturnType<typeof usePersist>['persistTypography
44
50
  /** Upstream alias for `PersistTypography`. See `persistFont` above. */
45
51
  export type PersistFont = PersistTypography;
46
52
  export type PersistSize = ReturnType<typeof usePersist>['persistSize'];
47
- export type PersistPanelPosition = ReturnType<typeof usePersist>['persistPanelPosition'];
48
53
  export type PersistSecondary = ReturnType<typeof usePersist>['persistSecondary'];
49
54
  export {};
50
- //# sourceMappingURL=persist.d.ts.map
@@ -42,8 +42,11 @@
42
42
  import type { ColorRef, ColorScheme } from '../config/color-schemes';
43
43
  import type { TokenDef } from '../tokens/manifest';
44
44
  import { type ColorClusterDataConfig } from '../config/cluster-config';
45
+ import type { SemanticValue } from '../tokens/tier-model';
46
+ export type { SemanticValue } from '../tokens/tier-model';
45
47
  import { type ApplySink, type PanelConfig } from '../config/panel-config';
46
48
  export type { ApplySink } from '../config/panel-config';
49
+ import type { TabConfig } from '../tokens/tier-model';
47
50
  import { type TabOverrides } from '../apply/tier-resolver';
48
51
  export type { BaseRoleKey, ColorClusterDataConfig } from '../config/cluster-config';
49
52
  export { resolvePaletteCssVar } from '../config/cluster-config';
@@ -182,9 +185,47 @@ export interface ColorTweakState {
182
185
  cursor: number;
183
186
  selectionBg: number;
184
187
  selectionFg: number;
185
- semanticMappings: Record<string, number | 'bg' | 'fg'>;
188
+ /**
189
+ * Semantic token name → mapping. Widened from `Record<string, number | 'bg'
190
+ * | 'fg'>` to `Record<string, SemanticValue>` (#459 S1). This is additive
191
+ * for readers of the type (every legacy value is still a valid
192
+ * `SemanticValue`), but it BREAKS any exhaustive `switch`/equality check
193
+ * written against the old narrow union — callers that pattern-match on a
194
+ * mapping value must now also handle the new `{ literal }` / `{ ref }`
195
+ * object variants (see `isIndexMapping` / `isLiteralMapping` /
196
+ * `isPerModeLiteral` / `isRefMapping` below). `resolveMapping` (exported)
197
+ * still only resolves the legacy `number | 'bg' | 'fg'` shape — resolving
198
+ * the new variants is downstream work (#467/#469).
199
+ */
200
+ semanticMappings: Record<string, SemanticValue>;
186
201
  shikiTheme: string;
187
202
  }
203
+ /** True when `v` is a legacy index-style mapping (palette index or bg/fg alias). */
204
+ export declare function isIndexMapping(v: SemanticValue): v is number | 'bg' | 'fg';
205
+ /** True when `v` is either literal-color variant (plain string or light/dark pair). */
206
+ export declare function isLiteralMapping(v: SemanticValue): v is {
207
+ literal: string;
208
+ } | {
209
+ literal: {
210
+ light: string;
211
+ dark: string;
212
+ };
213
+ };
214
+ /** True when `v` is specifically the light/dark literal-color variant. */
215
+ export declare function isPerModeLiteral(v: SemanticValue): v is {
216
+ literal: {
217
+ light: string;
218
+ dark: string;
219
+ };
220
+ };
221
+ /** True when `v` is a cross-tab/tier ramp-item reference. */
222
+ export declare function isRefMapping(v: SemanticValue): v is {
223
+ ref: {
224
+ tab?: string;
225
+ tier: string;
226
+ item: string;
227
+ };
228
+ };
188
229
  /**
189
230
  * Per-token override map. Keys are `TokenDef.id` (e.g. `hsp-sm`); values are
190
231
  * raw CSS length strings (e.g. `0.75rem`). Only overridden tokens appear in
@@ -195,9 +236,13 @@ export type TokenOverrides = Record<string, string>;
195
236
  * Unified persist envelope. Each tab owns its own sub-state so they can
196
237
  * evolve independently.
197
238
  *
198
- * `panelPosition` is persisted alongside the envelope so the user's drag
199
- * location survives reloads. `secondary` carries a second (optional) color
200
- * cluster — absent until a host opts in.
239
+ * Panel position and size are stored in SEPARATE localStorage keys
240
+ * (`-position` / `-size`) and are NOT part of this envelope. The panel reads
241
+ * them via `loadPosition` / `loadSize` on mount; drags / resizes write them
242
+ * directly via `savePosition` / `saveSize`.
243
+ *
244
+ * `secondary` carries a second (optional) color cluster — absent until a host
245
+ * opts in.
201
246
  *
202
247
  * `tabs` is the v3 extension: a tab-keyed map of `TabOverrides` for host-coined
203
248
  * generic tabs that use the tier model. The existing `color`/`spacing`/
@@ -209,7 +254,6 @@ export interface TweakState {
209
254
  spacing: TokenOverrides;
210
255
  typography: TokenOverrides;
211
256
  size: TokenOverrides;
212
- panelPosition?: PanelPosition;
213
257
  secondary?: ColorTweakState;
214
258
  /** Generic tab overrides keyed by tab id. Added in v3 envelope. */
215
259
  tabs?: Record<string, TabOverrides>;
@@ -235,6 +279,10 @@ export declare function getActivePrimaryCluster(cfg?: PanelConfig): ColorCluster
235
279
  * slots interpolate. Functional but visually flat; hosts wanting a
236
280
  * designed seed should ship a scheme registry on the cluster and call
237
281
  * `initColorFromScheme(cluster)` instead.
282
+ * - A cluster with `paletteSize: 0` (a lone `semantic: true` tier with no
283
+ * palette sibling, #458/#466) seeds an EMPTY palette — there is nothing
284
+ * to ramp. Forcing a 1-slot grayscale floor here produced a phantom
285
+ * `--zudo-stub-p0` swatch/token with no backing tier; see #466.
238
286
  *
239
287
  * The base-role indices are kept on the state shape for envelope-round-trip
240
288
  * compatibility but are inert — `applyColorState` only writes a base role
@@ -304,14 +352,94 @@ export declare function getActiveSchemeName(cluster?: ColorClusterDataConfig, cf
304
352
  * no schemes should not call this directly — they use
305
353
  * `initSecondaryDefaults(cluster)` instead because there is no scheme to
306
354
  * seed from.
355
+ *
356
+ * @param cfg - The panel instance config. When provided and the config has
357
+ * `applySink`, the host's `data-theme` attribute is ignored and the scheme
358
+ * seed comes from `cluster.panelSettings.colorScheme` instead (sink-instance
359
+ * guard). Omitting it silently falls through to reading `data-theme`, which
360
+ * is the correct behavior for non-sink instances but wrong for sinks.
361
+ */
362
+ export declare function initColorFromScheme(cluster?: ColorClusterDataConfig, cfg?: PanelConfig): ColorTweakState;
363
+ /**
364
+ * Palette entry sanitiser. Raw `oklch(...)` values are preserved verbatim so
365
+ * wide-gamut chroma survives (and they never touch the canvas → no '#000000'
366
+ * under jsdom / engines whose 2D canvas can't parse oklch). Every NON-oklch entry
367
+ * goes through cssColorToHex() — the exact pre-OKLCH behaviour — which
368
+ * canonicalises valid hex/rgb and, crucially, turns an unparseable string into a
369
+ * safe '#000000' rather than leaking it into a CSS custom property. Without this,
370
+ * a bundled scheme's stray non-color entry (e.g. `Default Dark`'s slot-9 `"18"`,
371
+ * referenced by `background: 9`) would reach the apply path verbatim.
372
+ *
373
+ * Exported so the serde import path (design-token-serde.ts) can apply the same
374
+ * sanitiser to imported palette values — commit 8d54e07 hardened seeding; this
375
+ * export closes the equivalent gap in the JSON-import path.
307
376
  */
308
- export declare function initColorFromScheme(cluster?: ColorClusterDataConfig): ColorTweakState;
377
+ export declare function normalizeSchemePaletteEntry(value: string): string;
309
378
  export declare function initColorFromSchemeData(scheme: ColorScheme, cluster?: ColorClusterDataConfig): ColorTweakState;
310
- /** Resolve a semantic mapping to an actual color (bounds-checked). */
379
+ /**
380
+ * Resolve a semantic mapping to an actual color (bounds-checked).
381
+ *
382
+ * Only handles the legacy `number | 'bg' | 'fg'` index shape — the narrower
383
+ * type this function accepted before `ColorTweakState.semanticMappings` /
384
+ * `ColorClusterDataConfig.semanticDefaults` were widened to `SemanticValue`
385
+ * (#459 S1). Callers holding a `SemanticValue` must narrow with
386
+ * `isIndexMapping()` first; resolving the `{ literal }` / `{ ref }` variants
387
+ * is downstream work (#467/#469), not this function's job today.
388
+ */
311
389
  export declare function resolveMapping(mapping: number | 'bg' | 'fg', palette: string[], bgIndex: number, fgIndex: number): string;
312
390
  export declare function safeIndex(index: number, len: number): number;
313
- /** Apply a single `ColorTweakState` to the DOM using the given cluster config. */
314
- export declare function applyColorState(state: ColorTweakState, cluster?: ColorClusterDataConfig, sink?: ApplySink): void;
391
+ /**
392
+ * The cluster's configured default light/dark mode, or `'light'` when the
393
+ * cluster declares no `colorMode` (`colorMode === false`).
394
+ *
395
+ * This is the single runtime reader of `ClusterPanelSettings.colorMode.defaultMode`
396
+ * (#472). The field validates but was previously never read at runtime; this
397
+ * helper (consumed by `resolveSemanticPreviewColor`) gives it a real effect —
398
+ * it selects which side of a per-mode `{ literal: { light, dark } }` pair is the
399
+ * fallback when `light-dark()` cannot resolve.
400
+ */
401
+ export declare function getClusterDefaultMode(cluster: ColorClusterDataConfig): 'light' | 'dark';
402
+ /**
403
+ * Resolve a per-mode literal to a single concrete CSS color for `mode`.
404
+ *
405
+ * Used wherever CSS `light-dark()` cannot be used — a preview swatch, an SSR
406
+ * seed, or any non-browser consumer that needs one flat value rather than a
407
+ * `light-dark(...)` function. The emitters (`applyColorState`,
408
+ * `buildApplyOverrides`) deliberately do NOT call this; they emit
409
+ * `light-dark()` and let the browser choose.
410
+ */
411
+ export declare function resolvePerModeLiteral(value: {
412
+ literal: {
413
+ light: string;
414
+ dark: string;
415
+ };
416
+ }, mode: 'light' | 'dark'): string;
417
+ /**
418
+ * Resolve a semantic mapping to a single concrete CSS color suitable for a
419
+ * PREVIEW swatch — a flat value, never a `light-dark()` function. Mirrors the
420
+ * internal apply-path resolver, except a per-mode `{ literal: { light, dark } }`
421
+ * value collapses to `getClusterDefaultMode(cluster)`'s side (#472).
422
+ *
423
+ * This is the "preview/seed" consumer referenced by #472/#473: the per-mode
424
+ * editor UI (#473) renders its swatch from this so the user sees the cluster's
425
+ * default-mode color, while the applied CSS var still emits `light-dark()`.
426
+ */
427
+ export declare function resolveSemanticPreviewColor(mapping: SemanticValue, state: ColorTweakState, cluster?: ColorClusterDataConfig, currentTab?: TabConfig, tabs?: readonly TabConfig[]): string;
428
+ /**
429
+ * Apply a single `ColorTweakState` to the DOM using the given cluster config.
430
+ *
431
+ * `currentTab` / `tabs` are optional and exist so a cross-tab/tier `{ ref }`
432
+ * semantic mapping (#468) can resolve: `currentTab` should be the color
433
+ * TabConfig this cluster was derived from (id `'color'` or
434
+ * `'color-secondary'`), and `tabs` the panel's full tabs array so a ref
435
+ * pointing into another tab (e.g. the grouped Palette tab) resolves. Callers
436
+ * that never hold `{ ref }` mappings (or have no tab context, e.g. most
437
+ * existing tests) can omit both — `resolveSemanticCssValue` returns `null`
438
+ * for an unresolvable ref rather than throwing, and this function skips a
439
+ * `null` (leaving the token at its stylesheet default) rather than painting
440
+ * a fallback color.
441
+ */
442
+ export declare function applyColorState(state: ColorTweakState, cluster?: ColorClusterDataConfig, sink?: ApplySink, currentTab?: TabConfig, tabs?: readonly TabConfig[]): void;
315
443
  /**
316
444
  * Apply a `TokenOverrides` map for a given manifest — writes inline
317
445
  * `--css-var: value` on `:root` for every overridden token, and removes the
@@ -333,6 +461,15 @@ export declare function applyTokenOverrides(tokens: readonly TokenDef[], overrid
333
461
  * When `cfg` is supplied its `applySink` (if any) is used to route all
334
462
  * CSS-var writes for this instance. Omitting `cfg` uses the default active
335
463
  * config (single-panel path, unchanged behavior).
464
+ *
465
+ * `color-scheme` is managed as an AGGREGATE across the primary + secondary
466
+ * clusters, not per-cluster (#482 D3): `applyColorState` only ever SETS
467
+ * `color-scheme: light dark` when its OWN cluster needs it, it never clears
468
+ * it, so demoting the last per-mode-literal row (in either cluster) would
469
+ * otherwise leave the previous apply's value stale. A naive per-cluster
470
+ * clear inside `applyColorState` would let a per-mode-free secondary undo
471
+ * what the primary just required (or vice versa), so the clear-when-neither-
472
+ * needs-it decision is made here, once, after both clusters have applied.
336
473
  */
337
474
  export declare function applyFullState(state: TweakState, cfg?: PanelConfig): void;
338
475
  /**
@@ -440,4 +577,3 @@ export declare function savePersistedState(state: TweakState, storage?: StorageL
440
577
  * preserving the single-panel path.
441
578
  */
442
579
  export declare function clearPersistedState(storage?: StorageLike, cfg?: PanelConfig): void;
443
- //# sourceMappingURL=tweak-state.d.ts.map
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Semantic z-index scale for the design-token panel.
3
+ *
4
+ * Single source of truth shared with panel-tokens.css:
5
+ * - CSS reads `var(--tokentweak-z-*)` (declared in panel-tokens.css)
6
+ * - TSX reads the numeric exports here for inline `zIndex` styles
7
+ *
8
+ * Values in the INT32 high band so the panel sits above common host chrome
9
+ * (sticky headers, drawers typically use z-index 100–10000). Ceiling bounded
10
+ * by INT32_MAX = 2147483647; inspector-box and toast claim the two highest
11
+ * practical values so element-path affordances are never obscured.
12
+ *
13
+ * Tier order: overlay < shell < settingsPopover < colorPicker < tooltip
14
+ * < inspectorBox < toast
15
+ */
16
+ export declare const Z: {
17
+ /** Highlight rings — rendered just below the panel shell. */
18
+ readonly overlay: 2147482990;
19
+ /** Panel shell (position:fixed root-level). */
20
+ readonly shell: 2147482991;
21
+ /** Highlight-settings popover — body-sibling of the shell, competes at root. */
22
+ readonly settingsPopover: 2147482992;
23
+ /**
24
+ * Color-picker card (position:fixed) — DOM child of .tokenpanel-shell,
25
+ * which is a stacking context. This value is shell-local; against host
26
+ * content the picker paints at the shell's root-level z-index.
27
+ */
28
+ readonly colorPicker: 2147482993;
29
+ /** DOM tooltip portaled to document.body. */
30
+ readonly tooltip: 2147482994;
31
+ /** Element-path inspector box (body-mounted). */
32
+ readonly inspectorBox: 2147483000;
33
+ /** Element-path toast (body-mounted). */
34
+ readonly toast: 2147483001;
35
+ };
@@ -21,4 +21,3 @@ export interface GenericItemEditorProps {
21
21
  declare function GenericItemEditorInner({ item, value, onChange }: GenericItemEditorProps): import("preact").JSX.Element | null;
22
22
  declare const _default: typeof GenericItemEditorInner;
23
23
  export default _default;
24
- //# sourceMappingURL=_generic-item-editor.d.ts.map
@@ -35,6 +35,7 @@
35
35
  * in the panel.
36
36
  */
37
37
  import { type ColorTweakState } from '../state/tweak-state';
38
+ import { type PanelConfig } from '../config/panel-config';
38
39
  import type { TabConfig } from '../tokens/tier-model';
39
40
  import type { PersistColor, PersistSecondary } from '../state/persist';
40
41
  interface ColorTabProps {
@@ -52,7 +53,17 @@ interface ColorTabProps {
52
53
  secondaryTab: TabConfig | null;
53
54
  secondaryState: ColorTweakState | null;
54
55
  persistSecondary: PersistSecondary;
56
+ /**
57
+ * The mounted panel instance's config (multi-instance, #353/#357). When
58
+ * supplied, cross-tab cluster/ref resolution (cluster derivation, the
59
+ * grouped ref-or-literal picker's ramp groups, preview resolution, and the
60
+ * host preset list) reads THIS instance's `tabs` / `colorPresets` rather
61
+ * than the active default instance — matching the apply path, which
62
+ * already resolves against `cfg.tabs` via `usePersist` (`applyFullState`,
63
+ * `state/persist.ts`). Omitted (e.g. a direct test render) →
64
+ * `getPanelConfig()`, preserving the single-instance path.
65
+ */
66
+ instanceConfig?: PanelConfig;
55
67
  }
56
- export default function ColorTab({ tab, state, persistColor, secondaryTab, secondaryState, persistSecondary, }: ColorTabProps): import("preact").JSX.Element;
68
+ export default function ColorTab({ tab, state, persistColor, secondaryTab, secondaryState, persistSecondary, instanceConfig, }: ColorTabProps): import("preact").JSX.Element;
57
69
  export {};
58
- //# sourceMappingURL=color-tab.d.ts.map
@@ -19,4 +19,3 @@ interface FontTabProps {
19
19
  */
20
20
  export default function FontTab({ tab, state, persistFont }: FontTabProps): import("preact").JSX.Element;
21
21
  export {};
22
- //# sourceMappingURL=font-tab.d.ts.map
@@ -28,8 +28,10 @@ export interface GenericTabProps {
28
28
  * When an item has no override, its `TierItem.default` is used.
29
29
  */
30
30
  overrides: TabOverrides;
31
- /** Called when the user commits a change to any item. */
32
- onChange: (tierId: string, itemId: string, next: string) => void;
31
+ /** Called when the user commits a change to any item. `next: undefined`
32
+ * (only reachable for ref-tier items) means "drop the stored override for
33
+ * this item" rather than writing a literal value. */
34
+ onChange: (tierId: string, itemId: string, next: string | undefined) => void;
33
35
  }
34
36
  /**
35
37
  * Renders a non-reserved tab (any TabConfig whose id is not color/font/
@@ -40,4 +42,3 @@ export interface GenericTabProps {
40
42
  * components until Wave 5 migrates them to consume TabConfig.tiers.
41
43
  */
42
44
  export default function GenericTab({ tab, overrides, onChange }: GenericTabProps): import("preact").JSX.Element;
43
- //# sourceMappingURL=generic-tab.d.ts.map
@@ -19,4 +19,3 @@ export interface PaletteCheckViewProps {
19
19
  onChange: (tierId: string, itemId: string, next: string) => void;
20
20
  }
21
21
  export default function PaletteCheckView({ tab, overrides }: PaletteCheckViewProps): import("preact").JSX.Element;
22
- //# sourceMappingURL=palette-check-view.d.ts.map
@@ -53,4 +53,3 @@ export interface PaletteEditViewProps {
53
53
  onCommitBatch?: (tierId: string, patch: Record<string, string>) => void;
54
54
  }
55
55
  export default function PaletteEditView({ tab, overrides, onChange, onCommitBatch }: PaletteEditViewProps): import("preact").JSX.Element;
56
- //# sourceMappingURL=palette-edit-view.d.ts.map
@@ -20,4 +20,3 @@ export interface PaletteReadoutProps {
20
20
  outOfGamut: boolean;
21
21
  }
22
22
  export default function PaletteReadout({ oklcha, cssVar, outOfGamut }: PaletteReadoutProps): import("preact").JSX.Element;
23
- //# sourceMappingURL=palette-readout.d.ts.map
@@ -34,4 +34,3 @@ export interface PaletteTabProps {
34
34
  onCommitBatch?: (tierId: string, patch: Record<string, string>) => void;
35
35
  }
36
36
  export default function PaletteTab({ tab, overrides, onChange, onCommitBatch }: PaletteTabProps): import("preact").JSX.Element;
37
- //# sourceMappingURL=palette-tab.d.ts.map
@@ -17,4 +17,3 @@ interface SizeTabProps {
17
17
  */
18
18
  export default function SizeTab({ tab, state, persistSize }: SizeTabProps): import("preact").JSX.Element;
19
19
  export {};
20
- //# sourceMappingURL=size-tab.d.ts.map
@@ -20,4 +20,3 @@ interface SpacingTabProps {
20
20
  */
21
21
  export default function SpacingTab({ tab, state, persistSpacing }: SpacingTabProps): import("preact").JSX.Element;
22
22
  export {};
23
- //# sourceMappingURL=spacing-tab.d.ts.map
package/dist/testing.d.ts CHANGED
@@ -78,4 +78,3 @@ export interface PlaywrightLocatorLike {
78
78
  * include the unit suffix — the panel appends the configured unit itself.
79
79
  */
80
80
  export declare function setPanelInputValue(locator: PlaywrightLocatorLike, value: string): Promise<void>;
81
- //# sourceMappingURL=testing.d.ts.map
package/dist/testing.js CHANGED
@@ -1,5 +1,5 @@
1
- import { _ as r, c as i, f as _, h as n, i as g, b as R, a as p } from "./panel-config-DyVRQ2n1.js";
2
- import { a as l, b as y, l as O } from "./tweak-state-DzZVbY25.js";
1
+ import { _ as r, c as i, f as _, h as n, i as g, b as R, a as p } from "./panel-config-CXTCcYQs.js";
2
+ import { a as l, b as y, l as O } from "./tweak-state-BeXkzoj8.js";
3
3
  import { F as K, G as E, a as S, S as u } from "./manifest-DCReQE0k.js";
4
4
  async function s(a, e) {
5
5
  await a.fill(e), await a.dispatchEvent("input");
@@ -141,4 +141,3 @@ export declare const SIZE_GROUP_ORDER: readonly TokenGroup[];
141
141
  export declare function parseNumericValue(value: string): number | null;
142
142
  /** Format a numeric slider value back into the stored string form. */
143
143
  export declare function formatValue(n: number, unit: string): string;
144
- //# sourceMappingURL=manifest.d.ts.map
@@ -56,6 +56,33 @@ export interface PillSpec {
56
56
  value: string;
57
57
  customDefault: string;
58
58
  }
59
+ /**
60
+ * A semantic token's mapping value.
61
+ *
62
+ * Legacy shape stays valid: a palette index (`number`) or the `'bg'` / `'fg'`
63
+ * sentinel aliases. New variants (added for #459) let a semantic tier point at
64
+ * an arbitrary literal color (optionally split light/dark) or reference a ramp
65
+ * item living in another tab/tier — both resolved downstream by #467/#469.
66
+ *
67
+ * Defined here (not in `state/tweak-state.ts`) because `config/cluster-config.ts`
68
+ * needs it for `ColorClusterDataConfig.semanticDefaults`, and cluster-config.ts
69
+ * already imports types from this module — keeping the definition here avoids
70
+ * a new type-only import cycle. `state/tweak-state.ts` re-exports it.
71
+ */
72
+ export type SemanticValue = number | 'bg' | 'fg' | {
73
+ literal: string;
74
+ } | {
75
+ literal: {
76
+ light: string;
77
+ dark: string;
78
+ };
79
+ } | {
80
+ ref: {
81
+ tab?: string;
82
+ tier: string;
83
+ item: string;
84
+ };
85
+ };
59
86
  export interface TierItem {
60
87
  id: string;
61
88
  cssVar: string;
@@ -73,6 +100,29 @@ export interface TierConfig {
73
100
  * an item in the tier whose id matches referencesTier. The apply pipeline
74
101
  * emits var(--tier1-cssvar). */
75
102
  referencesTier?: string;
103
+ /**
104
+ * Marks this tier as a SEMANTIC tier (its items hold `SemanticValue`
105
+ * mappings, not raw palette entries) so the panel never mistakes it for
106
+ * the palette tier. Optional and additive — omitting it preserves today's
107
+ * behavior (palette-tier detection stays structural, via
108
+ * `resolveColorClusterFromTab`'s `kind: 'color'` check).
109
+ */
110
+ semantic?: true;
111
+ /**
112
+ * Cross-tab ramp-source declaration for a semantic tier: the ramp tier(s)
113
+ * this tier's `{ ref }` mappings are allowed to point into. Each entry names
114
+ * a tier id and an optional tab id (omitted `tab` means "this tab").
115
+ * `assertValidPanelConfig` validates every declared source up front (the
116
+ * tab/tier must exist and share this tier's kind); `resolveColorClusterFromTab`
117
+ * (`config/cluster-config.ts`) uses the allow-list to derive each row's
118
+ * `SemanticValue`; the grouped `TierRefSelector` picker
119
+ * (`controls/tier-ref-selector.tsx`) renders one `<optgroup>` per declared
120
+ * source.
121
+ */
122
+ referencesRamps?: readonly {
123
+ tab?: string;
124
+ tier: string;
125
+ }[];
76
126
  }
77
127
  export interface ColorClusterExtras {
78
128
  id: string;
@@ -89,4 +139,3 @@ export interface TabConfig {
89
139
  tiers: readonly TierConfig[];
90
140
  colorExtras?: ColorClusterExtras;
91
141
  }
92
- //# sourceMappingURL=tier-model.d.ts.map