@takazudo/zdtp 0.1.0-next.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.
Files changed (130) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/LICENSE +21 -0
  3. package/README.md +1044 -0
  4. package/dist/apply/apply-token-overrides.d.ts +81 -0
  5. package/dist/apply/apply-token-overrides.d.ts.map +1 -0
  6. package/dist/apply/build-apply-overrides.d.ts +71 -0
  7. package/dist/apply/build-apply-overrides.d.ts.map +1 -0
  8. package/dist/apply/route-tokens-to-files.d.ts +65 -0
  9. package/dist/apply/route-tokens-to-files.d.ts.map +1 -0
  10. package/dist/apply/tier-resolver.d.ts +75 -0
  11. package/dist/apply/tier-resolver.d.ts.map +1 -0
  12. package/dist/apply-modal.d.ts +49 -0
  13. package/dist/apply-modal.d.ts.map +1 -0
  14. package/dist/astro/DesignTokenPanelHost.astro +76 -0
  15. package/dist/astro/host-adapter.d.ts +47 -0
  16. package/dist/astro/host-adapter.d.ts.map +1 -0
  17. package/dist/astro/host-adapter.js +81 -0
  18. package/dist/astro/index.d.ts +30 -0
  19. package/dist/astro/index.d.ts.map +1 -0
  20. package/dist/astro/index.js +54 -0
  21. package/dist/bin/cors.d.ts +24 -0
  22. package/dist/bin/cors.d.ts.map +1 -0
  23. package/dist/bin/parse-args.d.ts +38 -0
  24. package/dist/bin/parse-args.d.ts.map +1 -0
  25. package/dist/bin/server.d.ts +23 -0
  26. package/dist/bin/server.d.ts.map +1 -0
  27. package/dist/bin/server.js +283 -0
  28. package/dist/color-schemes-CgzOBqGO.js +85 -0
  29. package/dist/components/color-picker/color-picker.d.ts +64 -0
  30. package/dist/components/color-picker/color-picker.d.ts.map +1 -0
  31. package/dist/components/color-picker/custom-slider.d.ts +25 -0
  32. package/dist/components/color-picker/custom-slider.d.ts.map +1 -0
  33. package/dist/components/color-picker/index.d.ts +3 -0
  34. package/dist/components/color-picker/index.d.ts.map +1 -0
  35. package/dist/config/cluster-config.d.ts +135 -0
  36. package/dist/config/cluster-config.d.ts.map +1 -0
  37. package/dist/config/color-scheme-utils.d.ts +105 -0
  38. package/dist/config/color-scheme-utils.d.ts.map +1 -0
  39. package/dist/config/color-schemes.d.ts +83 -0
  40. package/dist/config/color-schemes.d.ts.map +1 -0
  41. package/dist/config/panel-config.d.ts +258 -0
  42. package/dist/config/panel-config.d.ts.map +1 -0
  43. package/dist/controls/pill-slider-row.d.ts +37 -0
  44. package/dist/controls/pill-slider-row.d.ts.map +1 -0
  45. package/dist/controls/role-button.d.ts +18 -0
  46. package/dist/controls/role-button.d.ts.map +1 -0
  47. package/dist/controls/sanitize-css-value.d.ts +22 -0
  48. package/dist/controls/sanitize-css-value.d.ts.map +1 -0
  49. package/dist/controls/select-row.d.ts +26 -0
  50. package/dist/controls/select-row.d.ts.map +1 -0
  51. package/dist/controls/slider-row.d.ts +34 -0
  52. package/dist/controls/slider-row.d.ts.map +1 -0
  53. package/dist/controls/text-row.d.ts +28 -0
  54. package/dist/controls/text-row.d.ts.map +1 -0
  55. package/dist/controls/tier-ref-selector.d.ts +33 -0
  56. package/dist/controls/tier-ref-selector.d.ts.map +1 -0
  57. package/dist/controls/tooltip.d.ts +44 -0
  58. package/dist/controls/tooltip.d.ts.map +1 -0
  59. package/dist/export-modal.d.ts +33 -0
  60. package/dist/export-modal.d.ts.map +1 -0
  61. package/dist/highlight/find-elements.d.ts +113 -0
  62. package/dist/highlight/find-elements.d.ts.map +1 -0
  63. package/dist/highlight/highlight-orchestrator.d.ts +24 -0
  64. package/dist/highlight/highlight-orchestrator.d.ts.map +1 -0
  65. package/dist/highlight/highlight-overlay.d.ts +43 -0
  66. package/dist/highlight/highlight-overlay.d.ts.map +1 -0
  67. package/dist/highlight/highlight-settings-popover.d.ts +25 -0
  68. package/dist/highlight/highlight-settings-popover.d.ts.map +1 -0
  69. package/dist/highlight/highlight-state.d.ts +87 -0
  70. package/dist/highlight/highlight-state.d.ts.map +1 -0
  71. package/dist/highlight/highlight-toggle-button.d.ts +34 -0
  72. package/dist/highlight/highlight-toggle-button.d.ts.map +1 -0
  73. package/dist/import-modal.d.ts +33 -0
  74. package/dist/import-modal.d.ts.map +1 -0
  75. package/dist/index.d.ts +105 -0
  76. package/dist/index.d.ts.map +1 -0
  77. package/dist/index.js +5480 -0
  78. package/dist/load-routing-XyKgftpe.js +353 -0
  79. package/dist/manifest-DCReQE0k.js +24 -0
  80. package/dist/panel-config-DP2_P7dD.js +332 -0
  81. package/dist/panel.d.ts +3 -0
  82. package/dist/panel.d.ts.map +1 -0
  83. package/dist/route-tokens-to-files-1DvmWBdj.js +41 -0
  84. package/dist/server/create-apply-handler.d.ts +48 -0
  85. package/dist/server/create-apply-handler.d.ts.map +1 -0
  86. package/dist/server/index.d.ts +24 -0
  87. package/dist/server/index.d.ts.map +1 -0
  88. package/dist/server/index.js +10 -0
  89. package/dist/server/load-routing.d.ts +39 -0
  90. package/dist/server/load-routing.d.ts.map +1 -0
  91. package/dist/server/path-safety.d.ts +36 -0
  92. package/dist/server/path-safety.d.ts.map +1 -0
  93. package/dist/server/serialize-write.d.ts +7 -0
  94. package/dist/server/serialize-write.d.ts.map +1 -0
  95. package/dist/state/persist.d.ts +39 -0
  96. package/dist/state/persist.d.ts.map +1 -0
  97. package/dist/state/tweak-state.d.ts +344 -0
  98. package/dist/state/tweak-state.d.ts.map +1 -0
  99. package/dist/tabs/_generic-item-editor.d.ts +23 -0
  100. package/dist/tabs/_generic-item-editor.d.ts.map +1 -0
  101. package/dist/tabs/color-tab.d.ts +55 -0
  102. package/dist/tabs/color-tab.d.ts.map +1 -0
  103. package/dist/tabs/font-tab.d.ts +22 -0
  104. package/dist/tabs/font-tab.d.ts.map +1 -0
  105. package/dist/tabs/generic-tab.d.ts +43 -0
  106. package/dist/tabs/generic-tab.d.ts.map +1 -0
  107. package/dist/tabs/size-tab.d.ts +20 -0
  108. package/dist/tabs/size-tab.d.ts.map +1 -0
  109. package/dist/tabs/spacing-tab.d.ts +23 -0
  110. package/dist/tabs/spacing-tab.d.ts.map +1 -0
  111. package/dist/testing.d.ts +81 -0
  112. package/dist/testing.d.ts.map +1 -0
  113. package/dist/testing.js +23 -0
  114. package/dist/tokens/manifest.d.ts +148 -0
  115. package/dist/tokens/manifest.d.ts.map +1 -0
  116. package/dist/tokens/tier-model.d.ts +89 -0
  117. package/dist/tokens/tier-model.d.ts.map +1 -0
  118. package/dist/tweak-state-DSJa5csL.js +624 -0
  119. package/dist/utils/color-convert.d.ts +7 -0
  120. package/dist/utils/color-convert.d.ts.map +1 -0
  121. package/dist/utils/color-hsla.d.ts +9 -0
  122. package/dist/utils/color-hsla.d.ts.map +1 -0
  123. package/dist/utils/color-oklch.d.ts +51 -0
  124. package/dist/utils/color-oklch.d.ts.map +1 -0
  125. package/dist/utils/design-token-serde.d.ts +193 -0
  126. package/dist/utils/design-token-serde.d.ts.map +1 -0
  127. package/dist/utils/structural-equal.d.ts +22 -0
  128. package/dist/utils/structural-equal.d.ts.map +1 -0
  129. package/dist/zdtp.css +1 -0
  130. package/package.json +102 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../src/panel.tsx"],"names":[],"mappings":"AAwGA,MAAM,CAAC,OAAO,UAAU,qBAAqB,iCAkqB5C;AAED,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,41 @@
1
+ const p = Object.freeze({});
2
+ function h(o, r) {
3
+ if (!o.startsWith("--")) return null;
4
+ const s = Object.keys(r).sort((t, n) => n.length - t.length);
5
+ for (const t of s) {
6
+ const n = `--${t}-`;
7
+ if (o.startsWith(n) && o.length > n.length)
8
+ return t;
9
+ }
10
+ return null;
11
+ }
12
+ function a(o, r = p) {
13
+ const s = Object.keys(r), t = {};
14
+ for (const e of s) t[e] = {};
15
+ const n = [], i = [];
16
+ for (const [e, f] of Object.entries(o)) {
17
+ const u = h(e, r);
18
+ if (u === null) {
19
+ n.push(e), e.startsWith("--") ? s.length === 0 ? i.push(
20
+ `${e}: no applyRouting configured on PanelConfig (host has not enabled disk-rewrite)`
21
+ ) : i.push(
22
+ `${e}: no route configured for prefix family (known prefixes: ${s.map((l) => `"${l}"`).join(", ")})`
23
+ ) : i.push(`${e}: not a CSS custom property (must start with "--")`);
24
+ continue;
25
+ }
26
+ t[u][e] = f;
27
+ }
28
+ const c = [];
29
+ for (const e of s) {
30
+ const f = t[e];
31
+ Object.keys(f).length !== 0 && c.push({
32
+ prefix: e,
33
+ relativePath: r[e],
34
+ tokens: f
35
+ });
36
+ }
37
+ return { groups: c, rejected: n, rejectedReasons: i };
38
+ }
39
+ export {
40
+ a as r
41
+ };
@@ -0,0 +1,48 @@
1
+ import type { ApplyRoutingMap } from '../config/panel-config';
2
+ export interface ApplyHandlerOptions {
3
+ /**
4
+ * Absolute path to the repository root. Used as the CWD reference when
5
+ * resolving `routing` paths and normalising `file` values in the response.
6
+ */
7
+ rootDir: string;
8
+ /**
9
+ * Absolute path to the directory that is allowed to contain CSS token files.
10
+ * Paths resolved from `routing` must sit strictly inside this directory
11
+ * (enforced by `isPathSafe`).
12
+ */
13
+ writeRoot: string;
14
+ /**
15
+ * Prefix → repo-relative CSS file path map. Matches the shape of
16
+ * `PanelConfig.applyRouting` (e.g. `{ zd: 'tokens/tokens.css' }`).
17
+ */
18
+ routing: ApplyRoutingMap;
19
+ }
20
+ export interface PerFileResult {
21
+ file: string;
22
+ changed: string[];
23
+ unchanged: string[];
24
+ unknown: string[];
25
+ }
26
+ /**
27
+ * Create a framework-agnostic Fetch API handler for the design-token apply
28
+ * endpoint.
29
+ *
30
+ * The returned function accepts a standard `Request` and returns a
31
+ * `Promise<Response>`. No Astro, Express, http, or Vite dependencies.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * import { createApplyHandler } from '@takazudo/zdtp/server';
36
+ *
37
+ * const handler = createApplyHandler({
38
+ * rootDir: process.cwd(),
39
+ * writeRoot: resolve(process.cwd(), 'tokens'),
40
+ * routing: { zd: 'tokens/tokens.css' },
41
+ * });
42
+ *
43
+ * // Vite / Astro / any Fetch-compatible router:
44
+ * export const POST = ({ request }: { request: Request }) => handler(request);
45
+ * ```
46
+ */
47
+ export declare function createApplyHandler(options: ApplyHandlerOptions): (req: Request) => Promise<Response>;
48
+ //# sourceMappingURL=create-apply-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-apply-handler.d.ts","sourceRoot":"","sources":["../../src/server/create-apply-handler.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAI9D,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,OAAO,EAAE,eAAe,CAAC;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAoFD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,mBAAmB,GAC3B,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAuIrC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @takazudo/zdtp/server
3
+ *
4
+ * Node-only server-side apply pipeline. Zero framework dependencies —
5
+ * the handler factory uses standard Fetch API types (Node 18+).
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { createApplyHandler } from '@takazudo/zdtp/server';
10
+ * import { resolve } from 'node:path';
11
+ *
12
+ * const handler = createApplyHandler({
13
+ * rootDir: process.cwd(),
14
+ * writeRoot: resolve(process.cwd(), 'tokens'),
15
+ * routing: { zd: 'tokens/tokens.css' },
16
+ * });
17
+ * ```
18
+ */
19
+ export { createApplyHandler } from './create-apply-handler';
20
+ export type { ApplyHandlerOptions, PerFileResult } from './create-apply-handler';
21
+ export { serializeFileWrite } from './serialize-write';
22
+ export { CSS_VAR_NAME_RE, isPathSafe, isValidCssVarName, validateAndSanitizeTokens, } from './path-safety';
23
+ export { loadRoutingFromFile, type ApplyRoutingMap } from './load-routing';
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EACL,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,10 @@
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";
2
+ export {
3
+ s as CSS_VAR_NAME_RE,
4
+ i as createApplyHandler,
5
+ l as isPathSafe,
6
+ r as isValidCssVarName,
7
+ t as loadRoutingFromFile,
8
+ o as serializeFileWrite,
9
+ d as validateAndSanitizeTokens
10
+ };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * CSS-var prefix family → host-relative CSS file path.
3
+ *
4
+ * Shape: `{ "<prefix>": "<host-relative-css-path>", ... }`.
5
+ * Both the panel UI (`PanelConfig.applyRouting`) and the bin (`--routing` flag)
6
+ * share this type so the two readers stay in sync.
7
+ *
8
+ * Same logical shape as `ApplyRoutingMap` in `config/panel-config.ts`
9
+ * (which is `Record<string, string>`). Exported from the server entry so
10
+ * bin code and consumer tooling can import it from `./server` without
11
+ * pulling in the full panel client bundle.
12
+ */
13
+ export type ApplyRoutingMap = Record<string, string>;
14
+ /**
15
+ * Read a routing JSON file from disk, validate its shape, and return the map.
16
+ *
17
+ * Throws a descriptive `Error` for any of:
18
+ * - file does not exist / is unreadable
19
+ * - invalid JSON syntax
20
+ * - root value is not a plain object (null, array, primitive, etc.)
21
+ * - any value in the map is not a non-empty string
22
+ * - the map itself is empty (at least one prefix entry is required)
23
+ *
24
+ * Intended for Node.js / Vite plugin / bin contexts only — not for
25
+ * browser-side code (uses `node:fs`).
26
+ *
27
+ * @param absPath - Absolute path to the JSON file.
28
+ * @returns The validated routing map.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * import { loadRoutingFromFile } from '@takazudo/zdtp/server';
33
+ *
34
+ * const routing = loadRoutingFromFile('/abs/path/to/my.routing.json');
35
+ * // → { zd: 'tokens/tokens.css', ... }
36
+ * ```
37
+ */
38
+ export declare function loadRoutingFromFile(absPath: string): ApplyRoutingMap;
39
+ //# sourceMappingURL=load-routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-routing.d.ts","sourceRoot":"","sources":["../../src/server/load-routing.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAiDpE"}
@@ -0,0 +1,36 @@
1
+ export declare const CSS_VAR_NAME_RE: RegExp;
2
+ export declare function isValidCssVarName(v: unknown): v is string;
3
+ /**
4
+ * A resolved path is safe iff it sits strictly inside the write-root
5
+ * directory AND ends with `.css`. Cross-platform: uses `path.relative` to
6
+ * normalize separators and detect both escape attempts and (on Windows)
7
+ * different-drive resolutions. The naive `startsWith(${writeRoot}/)` check
8
+ * silently fails on Windows where the platform separator is a backslash.
9
+ *
10
+ * Reject conditions:
11
+ * - resolvedPath does not end with `.css`
12
+ * - resolvedPath equals writeRoot (relative is empty / `.`)
13
+ * - relative is absolute (different drive or unrelated root on Windows)
14
+ * - relative starts with `..` followed by a separator (escape) or is `..`
15
+ * itself. Note that filenames such as `..hidden.css` directly under
16
+ * writeRoot remain valid because `..hidden.css` is not `..` and does not
17
+ * start with a separator.
18
+ */
19
+ export declare function isPathSafe(writeRoot: string, resolvedPath: string): boolean;
20
+ /**
21
+ * Validate the incoming `tokens` map and return a sanitized copy.
22
+ *
23
+ * - Keys must match `CSS_VAR_NAME_RE` (`--[a-zA-Z0-9_-]+`).
24
+ * - Values must be strings. Each value runs through `sanitizeCssValue`.
25
+ * If sanitization changed the value, we still accept the sanitized form —
26
+ * rejecting here would surface as a confusing 400 for callers whose color
27
+ * picker briefly emits a trailing newline.
28
+ *
29
+ * Returns `{ sanitized }` on success, or `{ error }` describing the first
30
+ * offending key.
31
+ */
32
+ export declare function validateAndSanitizeTokens(tokens: Record<string, unknown>): {
33
+ sanitized?: Record<string, string>;
34
+ error?: string;
35
+ };
36
+ //# sourceMappingURL=path-safety.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-safety.d.ts","sourceRoot":"","sources":["../../src/server/path-safety.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,eAAe,QAAuB,CAAC;AAEpD,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,MAAM,CAEzD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAO3E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAYA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Serialize file writes per absolute path. Concurrent calls for the same path
3
+ * are chained so the next read-modify-write only starts after the previous
4
+ * one settles (success or error). Calls for different paths run in parallel.
5
+ */
6
+ export declare function serializeFileWrite<T>(absPath: string, fn: () => Promise<T>): Promise<T>;
7
+ //# sourceMappingURL=serialize-write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize-write.d.ts","sourceRoot":"","sources":["../../src/server/serialize-write.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAa7F"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * `usePersist` hook — orchestrates setState + DOM apply + localStorage write
3
+ * for the design-token panel. Each callback is a persist pipeline:
4
+ *
5
+ * updater → setState(updater) → applyFullState(next) → savePersistedState(next)
6
+ *
7
+ * The slice-specific helpers (`persistColor`, `persistSpacing`, etc.) wrap a
8
+ * slice updater into a full-state updater so callers don't have to thread the
9
+ * whole envelope themselves.
10
+ *
11
+ * Framework-agnostic wrt. the setState function: pass any
12
+ * `(updater) => void` that propagates `updater(prev)` to the caller's state.
13
+ * In practice the panel passes Preact's `setState` from `useState`.
14
+ */
15
+ import { type ColorTweakState, type TabOverrides, type TokenOverrides, type TweakState } from './tweak-state';
16
+ type SetState<T> = (updater: (prev: T | null) => T | null) => void;
17
+ export declare function usePersist(setState: SetState<TweakState>): {
18
+ persist: (updater: (prev: TweakState) => TweakState) => void;
19
+ persistTab: (tabId: string, updater: (prev: TabOverrides) => TabOverrides) => void;
20
+ persistColor: (updater: (prev: ColorTweakState) => ColorTweakState) => void;
21
+ persistSpacing: (updater: (prev: TokenOverrides) => TokenOverrides) => void;
22
+ persistTypography: (updater: (prev: TokenOverrides) => TokenOverrides) => void;
23
+ persistFont: (updater: (prev: TokenOverrides) => TokenOverrides) => void;
24
+ persistSize: (updater: (prev: TokenOverrides) => TokenOverrides) => void;
25
+ persistPanelPosition: (updater: (prev: TweakState["panelPosition"]) => TweakState["panelPosition"]) => void;
26
+ persistSecondary: (updater: (prev: ColorTweakState | undefined) => ColorTweakState | undefined) => void;
27
+ };
28
+ export type Persist = ReturnType<typeof usePersist>['persist'];
29
+ export type PersistTab = ReturnType<typeof usePersist>['persistTab'];
30
+ export type PersistColor = ReturnType<typeof usePersist>['persistColor'];
31
+ export type PersistSpacing = ReturnType<typeof usePersist>['persistSpacing'];
32
+ export type PersistTypography = ReturnType<typeof usePersist>['persistTypography'];
33
+ /** Upstream alias for `PersistTypography`. See `persistFont` above. */
34
+ export type PersistFont = PersistTypography;
35
+ export type PersistSize = ReturnType<typeof usePersist>['persistSize'];
36
+ export type PersistPanelPosition = ReturnType<typeof usePersist>['persistPanelPosition'];
37
+ export type PersistSecondary = ReturnType<typeof usePersist>['persistSecondary'];
38
+ export {};
39
+ //# sourceMappingURL=persist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persist.d.ts","sourceRoot":"","sources":["../../src/state/persist.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,UAAU,EAChB,MAAM,eAAe,CAAC;AAEvB,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;AAEnE,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC;uBAE3C,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU;wBAqBlC,MAAM,WAAW,CAAC,IAAI,EAAE,YAAY,KAAK,YAAY;4BAiBnD,CAAC,IAAI,EAAE,eAAe,KAAK,eAAe;8BAO1C,CAAC,IAAI,EAAE,cAAc,KAAK,cAAc;iCAOxC,CAAC,IAAI,EAAE,cAAc,KAAK,cAAc;2BAAxC,CAAC,IAAI,EAAE,cAAc,KAAK,cAAc;2BAOxC,CAAC,IAAI,EAAE,cAAc,KAAK,cAAc;oCAOxC,CAAC,IAAI,EAAE,UAAU,CAAC,eAAe,CAAC,KAAK,UAAU,CAAC,eAAe,CAAC;gCAYlE,CAAC,IAAI,EAAE,eAAe,GAAG,SAAS,KAAK,eAAe,GAAG,SAAS;EA6B/E;AAED,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC;AAC/D,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC;AACrE,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,cAAc,CAAC,CAAC;AACzE,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,gBAAgB,CAAC,CAAC;AAC7E,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,mBAAmB,CAAC,CAAC;AACnF,uEAAuE;AACvE,MAAM,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAC5C,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,aAAa,CAAC,CAAC;AACvE,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,sBAAsB,CAAC,CAAC;AACzF,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,kBAAkB,CAAC,CAAC"}
@@ -0,0 +1,344 @@
1
+ /**
2
+ * Tweak-state model for the design-token panel.
3
+ *
4
+ * This module owns:
5
+ * - The `ColorTweakState` shape (palette + base roles + semantic mappings + shikiTheme).
6
+ * - The unified `TweakState` envelope persisted under the v2 storage key.
7
+ * - Pure helpers for initialising state from a scheme, applying state to the
8
+ * DOM, and clearing applied inline styles.
9
+ *
10
+ * **Parameterisation — clusters come from `panelConfig`**
11
+ *
12
+ * The primary color cluster is read from the color TabConfig's colorExtras at
13
+ * call time, so a host that calls `configurePanel({ ..., colorCluster })`
14
+ * sees its own data flow through the apply / clear / load helpers without
15
+ * further plumbing. The package itself ships zero baked-in cluster data —
16
+ * a stub default lives only on `DEFAULT_PANEL_CONFIG` so the package imports
17
+ * cleanly when no host has yet called `configurePanel`.
18
+ *
19
+ * The cluster shape is `ColorClusterDataConfig` (re-exported here as
20
+ * `ColorClusterConfig` for backwards-compatibility). It is fully
21
+ * JSON-serializable: the palette CSS-var name is materialised at use sites
22
+ * by `resolvePaletteCssVar(cluster, i)`. Schemes and panel scheme settings
23
+ * (`panelSettings.colorScheme` + `colorMode`) live on the cluster too, so a
24
+ * host can swap the entire color story without editing
25
+ * `color-scheme-utils.ts` or `color-schemes.ts`.
26
+ *
27
+ * The secondary cluster is an opt-in field on `PanelConfig`. When the host
28
+ * does not configure one, the secondary slice is hidden / skipped end to end.
29
+ *
30
+ * **shikiTheme kept, applyShikiTheme stubbed**
31
+ *
32
+ * The `shikiTheme` field stays on the state + persist envelope so JSON
33
+ * round-tripping with external exports is seamless; the UI hides it and
34
+ * `applyShikiTheme` is a no-op. Removing the field would churn the serde
35
+ * format for no real benefit.
36
+ */
37
+ import type { ColorRef, ColorScheme } from '../config/color-schemes';
38
+ import type { TokenDef } from '../tokens/manifest';
39
+ import { type ColorClusterDataConfig } from '../config/cluster-config';
40
+ import { type TabOverrides } from '../apply/tier-resolver';
41
+ export type { BaseRoleKey, ColorClusterDataConfig } from '../config/cluster-config';
42
+ export { resolvePaletteCssVar } from '../config/cluster-config';
43
+ export type ColorClusterConfig = ColorClusterDataConfig;
44
+ export type { TabOverrides } from '../apply/tier-resolver';
45
+ /**
46
+ * - `getStorageKeyV1()` is the original flat-state format (Color-only).
47
+ * - `getStorageKeyV2()` is the new namespaced format (`{ color: ..., ... }`)
48
+ * that lets other tabs (Spacing, Typography, Size) add their own sub-states
49
+ * without colliding with Color.
50
+ *
51
+ * On first load at v2 we migrate v1 → v2, write the new key, and delete v1.
52
+ *
53
+ * **Lazy derivation**
54
+ *
55
+ * Each helper reads `getPanelConfig()` on every call so a `configurePanel`
56
+ * call that lands *after* this module is imported still influences the keys
57
+ * the panel hits. Capturing the values at module load would freeze them
58
+ * before the host has a chance to configure.
59
+ */
60
+ export declare function getStorageKeyV1(): string;
61
+ export declare function getStorageKeyV2(): string;
62
+ export declare function getStorageKeyV3(): string;
63
+ export declare function getOpenKey(): string;
64
+ export declare function getPositionKey(): string;
65
+ export declare function getSizeKey(): string;
66
+ export declare function getDensityKey(): string;
67
+ export interface PanelPosition {
68
+ top: number;
69
+ left: number;
70
+ }
71
+ /**
72
+ * SSR-safe static fallback. Kept exported so hosts that read the constant
73
+ * during SSR (where `window` is undefined) still get a deterministic value.
74
+ * Runtime callers should prefer `defaultPosition()`, which returns a
75
+ * viewport-centered position when `window` is available.
76
+ */
77
+ export declare const DEFAULT_POSITION: PanelPosition;
78
+ /**
79
+ * Compute a viewport-centered default panel position for first-open behaviour.
80
+ *
81
+ * The panel CSS-sizes itself up to 1200×800 but caps at 80% of the viewport,
82
+ * so we mirror the same min/0.8x rule here. The resulting `top` / `left`
83
+ * place the panel at the geometric center of the viewport.
84
+ *
85
+ * Falls back to the static `DEFAULT_POSITION` when `window` is undefined
86
+ * (e.g. SSR / node test setup without jsdom). Real browsers + jsdom-backed
87
+ * tests get the centered position.
88
+ */
89
+ export declare function defaultPosition(): PanelPosition;
90
+ export declare function loadPosition(): PanelPosition;
91
+ export declare function savePosition(pos: PanelPosition): void;
92
+ /** Keep at least VISIBLE_MIN px of the panel on-screen so the user can grab it back. */
93
+ export declare const VISIBLE_MIN = 60;
94
+ export interface PanelSize {
95
+ width: number;
96
+ height: number;
97
+ }
98
+ /** Minimum panel size — small enough to feel snappy, large enough to keep the header + tabbar usable. */
99
+ export declare const MIN_PANEL_WIDTH = 320;
100
+ export declare const MIN_PANEL_HEIGHT = 240;
101
+ /** Hard upper caps so the panel never grows past sensible bounds even before viewport clamping. */
102
+ export declare const MAX_PANEL_WIDTH = 1600;
103
+ export declare const MAX_PANEL_HEIGHT = 1200;
104
+ /**
105
+ * SSR-safe static fallback. Matches the historical CSS expression
106
+ * `min(1200, 0.8 * vw)` × `min(800, 0.8 * vh)` evaluated for a 1024×768
107
+ * viewport so the package stays usable when imported during SSR (no
108
+ * window). Runtime callers should prefer `defaultSize()`.
109
+ */
110
+ export declare const DEFAULT_SIZE: PanelSize;
111
+ /**
112
+ * Compute the first-open panel size in px. Mirrors the historical CSS
113
+ * `min(1200, 0.8 * vw)` × `min(800, 0.8 * vh)` rule so existing users
114
+ * experience the same default size after this PR ships.
115
+ */
116
+ export declare function defaultSize(): PanelSize;
117
+ /**
118
+ * Clamp a `{ width, height }` against the configured min caps and the current
119
+ * viewport. The viewport upper bound prevents a panel saved on a 4K monitor
120
+ * from rendering off-screen when reopened on a 1080p laptop.
121
+ */
122
+ export declare function clampSize(width: number, height: number): PanelSize;
123
+ export declare function loadSize(): PanelSize;
124
+ export declare function saveSize(size: PanelSize): void;
125
+ /**
126
+ * User-chosen tab-grid density. Three discrete stops exposed as integers so a
127
+ * native `<input type="range">` slider can read/write directly:
128
+ *
129
+ * 0 = dense — small min-card width, more columns fit on a wide panel
130
+ * 1 = cozy — the auto-fit minmax default
131
+ * 2 = wide — forces one column so long var names are fully readable
132
+ *
133
+ * Mapped to a CSS `min` length by `densityToGridMin()`; the resolved length is
134
+ * exposed on the panel shell via the `--tokenpanel-grid-min` custom property
135
+ * and consumed by `.tokenpanel-tab-grid` / `.tokenpanel-tab-advanced-grid`.
136
+ */
137
+ export type PanelDensity = 0 | 1 | 2;
138
+ export declare const DEFAULT_DENSITY: PanelDensity;
139
+ export declare function densityToGridMin(density: PanelDensity): string;
140
+ export declare function loadDensity(): PanelDensity;
141
+ export declare function saveDensity(density: PanelDensity): void;
142
+ export declare function clampPosition(top: number, left: number, panelWidth: number, _panelHeight: number): PanelPosition;
143
+ /**
144
+ * Upstream re-highlights every `<pre>` on the page when the Shiki theme
145
+ * changes. This package does not use Shiki — we keep the function for
146
+ * API shape + persisted-state round-tripping, but the body is a no-op.
147
+ */
148
+ export declare function applyShikiTheme(_themeName: string): Promise<void>;
149
+ /** Theme list kept identical to upstream so imported state keeps its shikiTheme. */
150
+ export declare const SHIKI_THEMES: string[];
151
+ /**
152
+ * ColorTweakState — palette + base roles + semantic mappings. Shape is
153
+ * identical to upstream so persisted JSON can round-trip across projects.
154
+ *
155
+ * The state is palette-size agnostic (just `string[]`); the cluster config
156
+ * below supplies the expected length for validation + defaults.
157
+ */
158
+ export interface ColorTweakState {
159
+ palette: string[];
160
+ background: number;
161
+ foreground: number;
162
+ cursor: number;
163
+ selectionBg: number;
164
+ selectionFg: number;
165
+ semanticMappings: Record<string, number | 'bg' | 'fg'>;
166
+ shikiTheme: string;
167
+ }
168
+ /**
169
+ * Per-token override map. Keys are `TokenDef.id` (e.g. `hsp-sm`); values are
170
+ * raw CSS length strings (e.g. `0.75rem`). Only overridden tokens appear in
171
+ * the map — absent keys mean "use the stylesheet default".
172
+ */
173
+ export type TokenOverrides = Record<string, string>;
174
+ /**
175
+ * Unified persist envelope. Each tab owns its own sub-state so they can
176
+ * evolve independently.
177
+ *
178
+ * `panelPosition` is persisted alongside the envelope so the user's drag
179
+ * location survives reloads. `secondary` carries a second (optional) color
180
+ * cluster — absent until a host opts in.
181
+ *
182
+ * `tabs` is the v3 extension: a tab-keyed map of `TabOverrides` for host-coined
183
+ * generic tabs that use the tier model. The existing `color`/`spacing`/
184
+ * `typography`/`size` slices are retained for internal back-compat until Wave 5
185
+ * migrates those dedicated tab components to consume `TabConfig.tiers` directly.
186
+ */
187
+ export interface TweakState {
188
+ color: ColorTweakState;
189
+ spacing: TokenOverrides;
190
+ typography: TokenOverrides;
191
+ size: TokenOverrides;
192
+ panelPosition?: PanelPosition;
193
+ secondary?: ColorTweakState;
194
+ /** Generic tab overrides keyed by tab id. Added in v3 envelope. */
195
+ tabs?: Record<string, TabOverrides>;
196
+ }
197
+ /** Produce an empty overrides map — `TweakState` default for new tabs. */
198
+ export declare function emptyOverrides(): TokenOverrides;
199
+ /**
200
+ * Resolve the active primary color cluster from the panel config's tabs.
201
+ * Returns the stub cluster when no color tab is configured.
202
+ */
203
+ export declare function getActivePrimaryCluster(cfg?: import("..").PanelConfig): ColorClusterDataConfig;
204
+ /**
205
+ * Produce a fresh `ColorTweakState` for a secondary color cluster.
206
+ * Generalises the no-scheme seed path: the palette length, semantic
207
+ * defaults, and shikiTheme all derive from the supplied cluster, so any
208
+ * host-supplied secondary cluster (any paletteSize, any semantic
209
+ * vocabulary) gets a deterministic neutral grayscale seed when the cluster
210
+ * does not ship its own scheme registry.
211
+ *
212
+ * Palette seed strategy:
213
+ * - Synthesise a deterministic neutral grayscale palette of
214
+ * `cluster.paletteSize` slots. Index 0 → black, last → white, middle
215
+ * slots interpolate. Functional but visually flat; hosts wanting a
216
+ * designed seed should ship a scheme registry on the cluster and call
217
+ * `initColorFromScheme(cluster)` instead.
218
+ *
219
+ * The base-role indices are kept on the state shape for envelope-round-trip
220
+ * compatibility but are inert — `applyColorState` only writes a base role
221
+ * when the cluster declares the corresponding `baseRoles` entry.
222
+ */
223
+ export declare function initSecondaryDefaults(cluster: ColorClusterDataConfig): ColorTweakState;
224
+ /**
225
+ * Convenience helper used by `panel.tsx` and tests: seed a fresh secondary
226
+ * `ColorTweakState` from the active panel config's secondary cluster.
227
+ * Returns `undefined` when the host opted out of the secondary cluster
228
+ * (`secondaryColorCluster: null` or omitted).
229
+ */
230
+ export declare function initSecondaryFromConfig(): ColorTweakState | undefined;
231
+ export declare function cssColorToHex(color: string): string;
232
+ export declare function setCssVar(name: string, value: string): void;
233
+ /**
234
+ * Resolve a `ColorRef` to a palette index. If it's already a number, use it.
235
+ * If it's a string, find an exact palette match or the nearest color by RGB
236
+ * distance. `fallback` is returned only when `ref` is undefined.
237
+ */
238
+ export declare function colorRefToIndex(ref: ColorRef | undefined, palette: string[], fallback: number): number;
239
+ /**
240
+ * Resolve the active scheme name for the given cluster, considering
241
+ * light/dark mode. Reads `panelSettings` from the cluster so a
242
+ * host-supplied cluster can declare its own scheme + light/dark pairing
243
+ * without editing the panel package.
244
+ */
245
+ export declare function getActiveSchemeName(cluster?: ColorClusterDataConfig): string;
246
+ /**
247
+ * Initialise a `ColorTweakState` from the active color scheme for the given
248
+ * cluster. Defaults to the host's primary cluster (derived from the color
249
+ * TabConfig).
250
+ *
251
+ * Reads the scheme registry from `cluster.colorSchemes`. Clusters that ship
252
+ * no schemes should not call this directly — they use
253
+ * `initSecondaryDefaults(cluster)` instead because there is no scheme to
254
+ * seed from.
255
+ */
256
+ export declare function initColorFromScheme(cluster?: ColorClusterDataConfig): ColorTweakState;
257
+ export declare function initColorFromSchemeData(scheme: ColorScheme, cluster?: ColorClusterDataConfig): ColorTweakState;
258
+ /** Resolve a semantic mapping to an actual color (bounds-checked). */
259
+ export declare function resolveMapping(mapping: number | 'bg' | 'fg', palette: string[], bgIndex: number, fgIndex: number): string;
260
+ export declare function safeIndex(index: number, len: number): number;
261
+ /** Apply a single `ColorTweakState` to the DOM using the given cluster config. */
262
+ export declare function applyColorState(state: ColorTweakState, cluster?: ColorClusterDataConfig): void;
263
+ /**
264
+ * Apply a `TokenOverrides` map for a given manifest — writes inline
265
+ * `--css-var: value` on `:root` for every overridden token, and removes the
266
+ * inline property for tokens absent from the map (so the stylesheet default
267
+ * comes back).
268
+ *
269
+ * Read-only tokens are skipped in both directions: they are informational rows
270
+ * in the UI and are never written to storage.
271
+ */
272
+ export declare function applyTokenOverrides(tokens: readonly TokenDef[], overrides: TokenOverrides): void;
273
+ /**
274
+ * Apply the full unified `TweakState` — primary color cluster + token
275
+ * overrides + optional secondary cluster.
276
+ *
277
+ * Tab configs AND the primary color cluster are read from `panelConfig`
278
+ * at call time so a host that calls `configurePanel` before mount sees its
279
+ * own data driving the apply pass.
280
+ */
281
+ export declare function applyFullState(state: TweakState): void;
282
+ /**
283
+ * Strip all tweak-applied inline CSS variables so the stylesheet-provided
284
+ * values from the active scheme take effect again.
285
+ *
286
+ * Accepts an optional list of clusters so callers can scope the wipe to a
287
+ * subset; the default wipes both the primary and secondary clusters so a
288
+ * panel-level reset leaves no stale inline overrides on `:root` regardless
289
+ * of which cluster was last edited.
290
+ */
291
+ export declare function clearAppliedStyles(clusters?: readonly ColorClusterDataConfig[]): void;
292
+ /**
293
+ * Test-friendly migration entry point. Reads from a provided storage (defaults
294
+ * to `localStorage`) and returns the loaded+migrated `TweakState`, or `null`
295
+ * when no usable state exists.
296
+ *
297
+ * Rules:
298
+ * 1. If v2 key exists and parses → use it (v2 wins).
299
+ * 2. Else if v1 key exists → parse with safe defaults, lift into `state.color`,
300
+ * write v2, delete v1.
301
+ * 3. Else → return null (caller initialises from the active scheme).
302
+ *
303
+ * Malformed JSON is caught with `console.warn` and returns null (caller falls
304
+ * back to fresh defaults).
305
+ */
306
+ export interface StorageLike {
307
+ getItem(key: string): string | null;
308
+ setItem(key: string, value: string): void;
309
+ removeItem(key: string): void;
310
+ }
311
+ /**
312
+ * Legacy zdtp-internal typography rename map — opt-in via
313
+ * `PanelConfig.legacyIdRenameMap`.
314
+ *
315
+ * An earlier zdtp-internal port step renamed the font-size manifest ids from
316
+ * panel-internal labels (`text-caption`, `text-small`, `text-body`,
317
+ * `text-subheading`, `text-heading`, `text-display`) to main-site Tailwind
318
+ * tiers (`text-xs`, `text-sm`, `text-base`, `text-lg`, `text-3xl`,
319
+ * `text-5xl`), and dropped `text-micro` entirely (no main-site equivalent
320
+ * exists). This map preserves persisted user tweaks across that one-time
321
+ * rename — including the drop of `text-micro` (`null` value) — for callers
322
+ * that opt in.
323
+ *
324
+ * Critically, this map is NOT applied by default any more (see issue #51):
325
+ * hosts whose canonical manifest ids share names with these "old" labels —
326
+ * e.g. `zudo-doc`, where `text-caption` IS the stable id — were having
327
+ * their valid overrides remapped to non-existent ids and silently dropped.
328
+ * The default `loadPersistedState` path now applies an empty rename map.
329
+ *
330
+ * The `text-micro: null` entry exists because dropping is the only way to
331
+ * keep an obsolete legacy id from persisting indefinitely as dead
332
+ * localStorage data: `applyTokenOverrides` silently ignores unknown ids,
333
+ * but every save round-trips the dead key back to disk.
334
+ *
335
+ * Spacing + size manifest ids were NOT renamed (hsp-/vsp- ids kept their
336
+ * labels), so this migration only applies to the typography slice.
337
+ */
338
+ export declare const ZDTP_LEGACY_TYPOGRAPHY_RENAME_MAP: Readonly<Record<string, string | null>>;
339
+ export declare function loadPersistedState(storage?: StorageLike, colorDefaults?: ColorTweakState, cluster?: ColorClusterDataConfig): TweakState | null;
340
+ /** Persist the full `TweakState` to v3. */
341
+ export declare function savePersistedState(state: TweakState, storage?: StorageLike): void;
342
+ /** Remove v3 (and lingering v2/v1) keys. */
343
+ export declare function clearPersistedState(storage?: StorageLike): void;
344
+ //# sourceMappingURL=tweak-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tweak-state.d.ts","sourceRoot":"","sources":["../../src/state/tweak-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAEL,KAAK,sBAAsB,EAE5B,MAAM,0BAA0B,CAAC;AAclC,OAAO,EACL,KAAK,YAAY,EAGlB,MAAM,wBAAwB,CAAC;AAMhC,YAAY,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AAKxD,YAAY,EAAE,YAAY,EAAE,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CAE5D;AAED,kFAAkF;AAClF,wBAAgB,eAAe,CAC7B,KAAK,EAAE,eAAe,EACtB,OAAO,GAAE,sBAAkD,QAqB5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,EAAE,SAAS,EAAE,cAAc,QAUzF;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,QAc/C;AA+DD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,GAAE,SAAS,sBAAsB,EAOrC,QA0BL;AAqED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACpC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CASrF,CAAC;AA0KF,wBAAgB,kBAAkB,CAChC,OAAO,GAAE,WAA0B,EACnC,aAAa,CAAC,EAAE,eAAe,EAC/B,OAAO,GAAE,sBAAkD,GAC1D,UAAU,GAAG,IAAI,CAgHnB;AAED,2CAA2C;AAC3C,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,GAAE,WAA0B,QAMxF;AAED,4CAA4C;AAC5C,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,WAA0B,QAgBtE"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * GenericItemEditor — dispatches to the right control for a TierItem based on
3
+ * `item.type.kind`. Used by SpacingTab, FontTab, and SizeTab to render
4
+ * non-reference items with the appropriate editor.
5
+ *
6
+ * For pill items (item.pill is set), a pill toggle is rendered above the
7
+ * number input row — matching the PillSliderRow behaviour from the legacy
8
+ * size tab, but without a range slider (sliders need meaningful min/max which
9
+ * token manifests may not always define well).
10
+ *
11
+ * This is an internal helper; not exported from the package index.
12
+ */
13
+ import type { TierItem } from '../tokens/tier-model';
14
+ export interface GenericItemEditorProps {
15
+ item: TierItem;
16
+ value: string;
17
+ /** Called with (itemId, newValue). */
18
+ onChange: (itemId: string, next: string) => void;
19
+ }
20
+ declare function GenericItemEditorInner({ item, value, onChange }: GenericItemEditorProps): import("preact").JSX.Element | null;
21
+ declare const _default: typeof GenericItemEditorInner;
22
+ export default _default;
23
+ //# sourceMappingURL=_generic-item-editor.d.ts.map