@takazudo/zdtp 0.3.2 → 0.3.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.3
4
+
5
+ ### Features
6
+
7
+ - **OKLCH display & edit for opt-in GenericTab color items.** A `GenericTab` `{ kind: "color" }` tier item can now set `format: "oklch"` to route through the OKLCH/HSL `ColorPicker` instead of the native `<input type="color">`, so host/secondary panels can faithfully **display and edit** wide-gamut oklch/P3 palette values (e.g. a family-named `--palette-cool-700: oklch(...)`) with **no lossy hex round-trip on commit**. Additive and backward compatible — omitting `format` (or `"hex"`) keeps the native color input, so existing consumers, `ColorTab`, and the highlight popover are unchanged. ([#373](https://github.com/Takazudo/zudo-design-token-panel/issues/373), supersedes [#372](https://github.com/Takazudo/zudo-design-token-panel/issues/372))
8
+ - Add a `cssToOklcha` CSS Color 4 `oklch()` parser (number/percentage L, chroma `%` = 0.4, deg/rad/grad/turn hue, `none`, alpha; strict — rejects malformed channels). ([#374](https://github.com/Takazudo/zudo-design-token-panel/issues/374))
9
+ - Extend the public `{ kind: "color" }` tier-item type with optional `format?: "hex" | "oklch"`. ([#375](https://github.com/Takazudo/zudo-design-token-panel/issues/375))
10
+ - Give `ColorPicker` a `valueFormat` contract: in oklch mode a canonical `Oklcha` is the source of truth and wide-gamut chroma survives prop→edit→emit without sRGB clamping. ([#376](https://github.com/Takazudo/zudo-design-token-panel/issues/376))
11
+ - HSL/alpha/preset hardening: the OKLCH↔HSL mode toggle is emit-free; only an HSL slider edit is a (documented) sRGB-oriented path. ([#377](https://github.com/Takazudo/zudo-design-token-panel/issues/377))
12
+ - Add a shared `ColorField` (swatch-button → picker popover) and route both generic item editors through it. ([#378](https://github.com/Takazudo/zudo-design-token-panel/issues/378))
13
+
14
+ ### Fixed
15
+
16
+ - **Style the `ColorField` swatch and reject malformed oklch tokens.** The new opt-in swatch had no CSS (an empty `div` with only a background color → zero-size/invisible affordance); added sized swatch styles. The `cssToOklcha` tokenizer also accepted malformed channels (e.g. `oklch(50px 0.1 120)`) by silently extracting numeric substrings; it now requires exactly three fully-anchored channel tokens and rejects unknown suffixes. ([#380](https://github.com/Takazudo/zudo-design-token-panel/pull/380)) (2d045d0)
17
+
18
+ ### Other Changes
19
+
20
+ - Add an end-to-end test asserting the oklch round-trip (panel `onChange` + apply path both emit `oklch(...)`) and wide-gamut P3 preservation. ([#379](https://github.com/Takazudo/zudo-design-token-panel/issues/379)) (0595f28)
21
+
3
22
  ## 0.3.2
4
23
 
5
24
  ### Fixed
@@ -0,0 +1,38 @@
1
+ /**
2
+ * ColorField — swatch-button that opens a ColorPicker popover.
3
+ *
4
+ * A swatch div (div[role="button"]) + isOpen state + anchorRef pattern,
5
+ * mirroring ColorSwatch in color-tab.tsx.
6
+ *
7
+ * DOM-hygiene compliant: div-button with onClick + onKeyDown (Enter/Space);
8
+ * no banned semantic tags — hostile-host policy (CLAUDE.md).
9
+ */
10
+ import type { ColorPickerValueFormat } from './color-picker';
11
+ export interface ColorFieldProps {
12
+ /** Current color value. Hex string in hex mode; `oklch(...)` string in oklch mode. */
13
+ value: string;
14
+ /** Called with the new color string when the user commits a change. */
15
+ onChange: (next: string) => void;
16
+ /**
17
+ * Output format for `value` / `onChange`. Defaults to 'hex' (back-compatible
18
+ * with the native <input type="color"> path).
19
+ */
20
+ valueFormat?: ColorPickerValueFormat;
21
+ /** Display label shown in the picker header and aria-label. */
22
+ label: string;
23
+ /** Optional CSS custom property name (e.g. `--my-color`). Used for aria-label. */
24
+ cssVar?: string;
25
+ /**
26
+ * When true, the swatch is shown but clicking / Enter / Space does NOT open
27
+ * the picker. Mirrors the `disabled` behavior of the native <input type="color">.
28
+ */
29
+ readonly?: boolean;
30
+ }
31
+ /**
32
+ * Swatch-button that opens a ColorPicker popover.
33
+ *
34
+ * Readonly items show the swatch but do not open the picker on interaction.
35
+ */
36
+ export declare function ColorField({ value, onChange, valueFormat, label, cssVar, readonly: isReadonly, }: ColorFieldProps): import("preact").JSX.Element;
37
+ export default ColorField;
38
+ //# sourceMappingURL=color-field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-field.d.ts","sourceRoot":"","sources":["../../../src/components/color-picker/color-field.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAE7D,MAAM,WAAW,eAAe;IAC9B,sFAAsF;IACtF,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC;;;OAGG;IACH,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,kFAAkF;IAClF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,WAAmB,EACnB,KAAK,EACL,MAAM,EACN,QAAQ,EAAE,UAAkB,GAC7B,EAAE,eAAe,gCA6CjB;AAED,eAAe,UAAU,CAAC"}
@@ -19,11 +19,35 @@
19
19
  */
20
20
  import type { JSX } from 'preact';
21
21
  export type ColorPickerMode = 'oklch' | 'hsl';
22
+ /**
23
+ * Output value format for the picker.
24
+ *
25
+ * 'hex' — `color` prop is a hex string, `onChange` emits hex. The internal
26
+ * source of truth is the hex string. (Default — back-compatible.)
27
+ * 'oklch' — `color` prop is a CSS `oklch(...)` string (a hex is also tolerated
28
+ * on input), `onChange` emits a normalized `oklch(...)` string. The
29
+ * internal source of truth is a canonical `Oklcha`, so wide-gamut
30
+ * chroma and sub-step precision survive edits without sRGB clamping.
31
+ */
32
+ export type ColorPickerValueFormat = 'hex' | 'oklch';
22
33
  export interface ColorPickerProps {
23
- /** Current hex color (#RRGGBB or #RRGGBBAA). Source of truth. */
34
+ /**
35
+ * Current color. In `valueFormat='hex'` (default) this is a hex string
36
+ * (#RRGGBB or #RRGGBBAA). In `valueFormat='oklch'` this is a CSS `oklch(...)`
37
+ * string (a hex is tolerated and parsed via the hex path as a fallback).
38
+ */
24
39
  color: string;
25
- /** Called when the user commits a new color via any sub-control. */
26
- onChange: (hex: string) => void;
40
+ /**
41
+ * Called when the user commits a new color via any sub-control. The argument
42
+ * matches `valueFormat`: a hex string in 'hex' mode, an `oklch(...)` string
43
+ * in 'oklch' mode.
44
+ */
45
+ onChange: (value: string) => void;
46
+ /**
47
+ * Output format for `color` / `onChange`. Defaults to 'hex' (back-compatible
48
+ * with existing callers that pass no value).
49
+ */
50
+ valueFormat?: ColorPickerValueFormat;
27
51
  /** Optional label rendered in the picker header. */
28
52
  label?: string;
29
53
  /**
@@ -59,6 +83,6 @@ export declare function usePopoverClose(containerRef: React.RefObject<HTMLElemen
59
83
  * The parent renders `{isOpen && <ColorPicker ... />}`. This component does
60
84
  * NOT render a trigger swatch and does NOT use createPortal.
61
85
  */
62
- export declare function ColorPicker({ color, onChange, label, defaultMode, anchorRef, onClose, }: ColorPickerProps): JSX.Element;
86
+ export declare function ColorPicker({ color, onChange, valueFormat, label, defaultMode, anchorRef, onClose, }: ColorPickerProps): JSX.Element;
63
87
  export default ColorPicker;
64
88
  //# sourceMappingURL=color-picker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"color-picker.d.ts","sourceRoot":"","sources":["../../../src/components/color-picker/color-picker.tsx"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;GAkBG;AAUH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAiBlC,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,KAAK,CAAC;AAE9C,MAAM,WAAW,gBAAgB;IAC/B,iEAAiE;IACjE,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,2EAA2E;IAC3E,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC/C,gFAAgF;IAChF,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAID,eAAO,MAAM,iBAAiB,gCAAgC,CAAC;AAyJ/D;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,WAAW,GAAG,IAAI,EAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,GAAG,CAAC,aAAa,CAuCnB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACjD,OAAO,EAAE,MAAM,IAAI,GAClB,IAAI,CA2BN;AAID;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,QAAQ,EACR,KAAK,EACL,WAAqB,EACrB,SAAS,EACT,OAAO,GACR,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CAyehC;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"color-picker.d.ts","sourceRoot":"","sources":["../../../src/components/color-picker/color-picker.tsx"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;GAkBG;AAUH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAmBlC,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,KAAK,CAAC;AAE9C;;;;;;;;;GASG;AACH,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,OAAO,CAAC;AAErD,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;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