@weasel-js/ui 1.4.3 → 1.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 (53) hide show
  1. package/dist/chunks/Button-CExdkQcU.js +90 -0
  2. package/dist/chunks/{Button-Cq5LBUMD.js.map → Button-CExdkQcU.js.map} +1 -1
  3. package/dist/chunks/{ColorField-D0OxUlvu.js → ColorField-C20aRvCg.js} +2 -2
  4. package/dist/chunks/{ColorField-D0OxUlvu.js.map → ColorField-C20aRvCg.js.map} +1 -1
  5. package/dist/chunks/{DetentSlider-BVWKdRyC.js → DetentSlider-BpD7bgjN.js} +2 -2
  6. package/dist/chunks/{DetentSlider-BVWKdRyC.js.map → DetentSlider-BpD7bgjN.js.map} +1 -1
  7. package/dist/chunks/{GradientEditor-C5NVILLk.js → GradientEditor-BLpAtMDK.js} +3 -3
  8. package/dist/chunks/{GradientEditor-C5NVILLk.js.map → GradientEditor-BLpAtMDK.js.map} +1 -1
  9. package/dist/chunks/{InlineRange-50ulExCL.js → InlineRange-CcfzY80y.js} +2 -2
  10. package/dist/chunks/{InlineRange-50ulExCL.js.map → InlineRange-CcfzY80y.js.map} +1 -1
  11. package/dist/chunks/{PaintInput-67U-COE4.js → PaintInput-B7AScmHN.js} +3 -3
  12. package/dist/chunks/{PaintInput-67U-COE4.js.map → PaintInput-B7AScmHN.js.map} +1 -1
  13. package/dist/chunks/{Prefs-D0l0PXLF.js → Prefs-4JSEtuU-.js} +3 -3
  14. package/dist/chunks/{Prefs-D0l0PXLF.js.map → Prefs-4JSEtuU-.js.map} +1 -1
  15. package/dist/chunks/{Properties-CMLua9mU.js → Properties-BpUYKi7-.js} +125 -113
  16. package/dist/chunks/Properties-BpUYKi7-.js.map +1 -0
  17. package/dist/chunks/{RangeSlider-C3to8A52.js → RangeSlider-S2R3zA8N.js} +8 -8
  18. package/dist/chunks/RangeSlider-S2R3zA8N.js.map +1 -0
  19. package/dist/chunks/{SelectionPanel-BWXU8BqW.js → SelectionPanel-C59wavdA.js} +4 -4
  20. package/dist/chunks/{SelectionPanel-BWXU8BqW.js.map → SelectionPanel-C59wavdA.js.map} +1 -1
  21. package/dist/chunks/{Slider-Bk_G5sSW.js → Slider-Bs-KSYgQ.js} +14 -14
  22. package/dist/chunks/Slider-Bs-KSYgQ.js.map +1 -0
  23. package/dist/chunks/{Timeline-BmYwYjXd.js → Timeline-Bz806JbE.js} +2 -2
  24. package/dist/chunks/{Timeline-BmYwYjXd.js.map → Timeline-Bz806JbE.js.map} +1 -1
  25. package/dist/chunks/range.module-CvSfABmu.js +8 -0
  26. package/dist/chunks/range.module-CvSfABmu.js.map +1 -0
  27. package/dist/components/Button/Button.d.ts +5 -0
  28. package/dist/components/Button/Button.d.ts.map +1 -1
  29. package/dist/components/Button/index.js +1 -1
  30. package/dist/components/ColorField/index.js +1 -1
  31. package/dist/components/DetentSlider/index.js +1 -1
  32. package/dist/components/GradientEditor/index.js +1 -1
  33. package/dist/components/InlineRange/index.js +1 -1
  34. package/dist/components/PaintInput/index.js +1 -1
  35. package/dist/components/Prefs/index.js +1 -1
  36. package/dist/components/Properties/PropertyPanel.d.ts +27 -2
  37. package/dist/components/Properties/PropertyPanel.d.ts.map +1 -1
  38. package/dist/components/Properties/index.js +1 -1
  39. package/dist/components/RangeSlider/RangeSlider.d.ts +5 -0
  40. package/dist/components/RangeSlider/RangeSlider.d.ts.map +1 -1
  41. package/dist/components/RangeSlider/index.js +1 -1
  42. package/dist/components/SelectionPanel/index.js +1 -1
  43. package/dist/components/Slider/index.js +1 -1
  44. package/dist/components/Timeline/index.js +1 -1
  45. package/dist/index.js +12 -12
  46. package/dist/style.css +1 -1
  47. package/package.json +6 -6
  48. package/dist/chunks/Button-Cq5LBUMD.js +0 -87
  49. package/dist/chunks/Properties-CMLua9mU.js.map +0 -1
  50. package/dist/chunks/RangeSlider-C3to8A52.js.map +0 -1
  51. package/dist/chunks/Slider-Bk_G5sSW.js.map +0 -1
  52. package/dist/chunks/range.module-CgURq-Ua.js +0 -8
  53. package/dist/chunks/range.module-CgURq-Ua.js.map +0 -1
@@ -0,0 +1,90 @@
1
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
+ import { forwardRef as n } from "react";
3
+ var r = {
4
+ button: "_button_1aa2p_3",
5
+ size_sm: "_size_sm_1aa2p_110",
6
+ size_md: "_size_md_1aa2p_111",
7
+ iconOnly: "_iconOnly_1aa2p_113",
8
+ variant_primary: "_variant_primary_1aa2p_121",
9
+ variant_secondary: "_variant_secondary_1aa2p_168",
10
+ variant_ghost: "_variant_ghost_1aa2p_203",
11
+ pressed: "_pressed_1aa2p_220",
12
+ fullWidth: "_fullWidth_1aa2p_228",
13
+ loading: "_loading_1aa2p_229",
14
+ label: "_label_1aa2p_229",
15
+ iconSlot: "_iconSlot_1aa2p_233",
16
+ spinner: "_spinner_1aa2p_247",
17
+ "wzl-btn-spin": "_wzl-btn-spin_1aa2p_1"
18
+ };
19
+ //#endregion
20
+ //#region src/components/Button/Button.tsx
21
+ function i() {
22
+ return /* @__PURE__ */ e("span", {
23
+ className: r.spinner,
24
+ "aria-hidden": "true",
25
+ children: /* @__PURE__ */ t("svg", {
26
+ viewBox: "0 0 16 16",
27
+ width: "14",
28
+ height: "14",
29
+ children: [/* @__PURE__ */ e("circle", {
30
+ cx: "8",
31
+ cy: "8",
32
+ r: "6",
33
+ fill: "none",
34
+ stroke: "currentColor",
35
+ strokeWidth: "2",
36
+ strokeOpacity: "0.25"
37
+ }), /* @__PURE__ */ e("path", {
38
+ d: "M 8 2 A 6 6 0 0 1 14 8",
39
+ fill: "none",
40
+ stroke: "currentColor",
41
+ strokeWidth: "2",
42
+ strokeLinecap: "round"
43
+ })]
44
+ })
45
+ });
46
+ }
47
+ var a = n(function(n, a) {
48
+ let { variant: o = "secondary", size: s = "md", pressed: c, disabled: l, loading: u, leadingIcon: d, trailingIcon: f, fullWidth: p, iconOnly: m, ariaLabel: h, type: g = "button", className: _, style: v, children: y, onClick: b } = n;
49
+ return /* @__PURE__ */ t("button", {
50
+ ref: a,
51
+ type: g,
52
+ className: [
53
+ r.button,
54
+ r[`variant_${o}`],
55
+ r[`size_${s}`],
56
+ p && r.fullWidth,
57
+ c && r.pressed,
58
+ m && r.iconOnly,
59
+ u && r.loading,
60
+ _
61
+ ].filter(Boolean).join(" "),
62
+ style: v,
63
+ disabled: l,
64
+ "aria-busy": u ? !0 : void 0,
65
+ "aria-pressed": c,
66
+ "aria-label": h,
67
+ onClick: b,
68
+ children: [
69
+ !m && (u || d) && /* @__PURE__ */ e("span", {
70
+ className: r.iconSlot,
71
+ children: u ? /* @__PURE__ */ e(i, {}) : d
72
+ }),
73
+ m ? u ? /* @__PURE__ */ e(i, {}) : /* @__PURE__ */ e("span", {
74
+ className: r.iconSlot,
75
+ children: y
76
+ }) : y !== void 0 && /* @__PURE__ */ e("span", {
77
+ className: r.label,
78
+ children: y
79
+ }),
80
+ !m && f && /* @__PURE__ */ e("span", {
81
+ className: r.iconSlot,
82
+ children: f
83
+ })
84
+ ]
85
+ });
86
+ });
87
+ //#endregion
88
+ export { a as t };
89
+
90
+ //# sourceMappingURL=Button-CExdkQcU.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button-Cq5LBUMD.js","names":[],"sources":["../../src/components/Button/Button.module.css","../../src/components/Button/Button.tsx"],"sourcesContent":["/* Aqua-glass button. Every visual parameter is exposed as a CSS custom\n property so the Button Lab can override per-instance via inline style. */\n.button {\n /* ---- Tunables (with Aqua-biased defaults) ---- */\n /* Corner radius = 10% of the button's height (the shorter axis on every\n realistic button shape). Using calc against --btn-height keeps the\n corners circular rather than elliptical, which a % value would\n otherwise produce on a wide-but-short pill. */\n --btn-radius: calc(var(--btn-height) * 0.1);\n --btn-fontweight: var(--wzl-font-weight-medium);\n --btn-fontsize: var(--wzl-font-size);\n --btn-height: 24px;\n --btn-padx: 12px;\n\n /* Body gradient — alpha-laced top, opaque bottom. Percentages are\n \"color-mix accent ratio\" so 45% = 45% accent + 55% transparent. */\n --btn-top-alpha: 45%;\n --btn-upper-alpha: 70%;\n --btn-equator: 52%; /* vertical position of the bright-to-deep transition */\n --btn-equator-spread: 12%; /* half-width of the equator transition band */\n --btn-equator-tint: 95%; /* accent vs white at equator */\n --btn-base-tint: 70%; /* accent vs black at base */\n --btn-blur: 6px;\n --btn-saturate: 1.3;\n\n /* Specular gloss (::before) */\n --btn-gloss-top: 0.42;\n --btn-gloss-mid: 0.12;\n --btn-gloss-bottom: 50%; /* inset from bottom — 50% = upper hemisphere */\n\n /* 3D shadows */\n --btn-rim: 0.22;\n --btn-drop-near: 0.30;\n --btn-drop-far: 0.18;\n --btn-inset-hi: 0.42;\n --btn-inset-lo: 0.3;\n\n /* Text — main shadow + a second engraving shadow you can angle.\n `inset-x` / `inset-y` are pre-projected offsets from `inset-angle` so\n the lab can drive them with a single slider. */\n --btn-text-shadow: 0.35;\n --btn-text-inset: 0.55;\n --btn-text-inset-x: 0px;\n --btn-text-inset-y: 1px;\n\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n border: none;\n border-radius: var(--btn-radius);\n font-family: var(--wzl-font-ui);\n font-weight: var(--btn-fontweight);\n font-style: normal;\n font-size: var(--btn-fontsize);\n height: var(--btn-height);\n padding: 0 var(--btn-padx);\n line-height: 1;\n cursor: pointer;\n user-select: none;\n -webkit-user-select: none;\n isolation: isolate;\n overflow: hidden;\n transition: filter var(--wzl-motion-fast), box-shadow var(--wzl-motion-fast), transform 80ms;\n}\n\n/* Specular gloss — covers the upper hemisphere of the pill with a bright\n white sheen that fades to nothing by the equator. The single detail that\n sells the glass-cylinder illusion. */\n.button::before {\n content: '';\n position: absolute;\n inset: 1px 1px var(--btn-gloss-bottom) 1px;\n /* Top corners hug the button's outline; bottom corners are flat so the\n gloss terminates in a straight line at the equator rather than two\n little arcs that read as `)(` brackets at smaller radii. */\n border-top-left-radius: var(--btn-radius);\n border-top-right-radius: var(--btn-radius);\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n background: linear-gradient(\n 180deg,\n rgba(255, 255, 255, var(--btn-gloss-top)) 0%,\n rgba(255, 255, 255, var(--btn-gloss-mid)) 60%,\n rgba(255, 255, 255, 0) 100%\n );\n pointer-events: none;\n z-index: 1;\n transition: opacity var(--wzl-motion-fast);\n}\n\n.button > * {\n position: relative;\n z-index: 2;\n}\n\n.button:focus-visible {\n outline: 2px solid var(--wzl-focus-ring);\n outline-offset: 1px;\n}\n\n.button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* ---------- Sizes — set defaults for the custom props ---------- */\n\n.size_sm { --btn-height: 20px; --btn-padx: 8px; --btn-fontsize: var(--wzl-font-size-sm); }\n.size_md { --btn-height: 24px; --btn-padx: 12px; --btn-fontsize: var(--wzl-font-size); }\n\n.iconOnly.size_sm { width: 20px; --btn-padx: 0; }\n.iconOnly.size_md { width: 24px; --btn-padx: 0; }\n\n/* ---------- Variants ---------- */\n\n/* Primary: tinted aqua glass — body uses --wzl-accent. The upper / equator\n / lower stops are positioned around --btn-equator so dragging the equator\n shifts the entire transition zone as one block. */\n.variant_primary {\n background: linear-gradient(\n 180deg,\n color-mix(in srgb, var(--wzl-accent) var(--btn-top-alpha), transparent) 0%,\n color-mix(in srgb, var(--wzl-accent) var(--btn-upper-alpha), transparent) calc(var(--btn-equator) - var(--btn-equator-spread)),\n color-mix(in srgb, var(--wzl-accent) var(--btn-equator-tint), white) var(--btn-equator),\n var(--wzl-accent) calc(var(--btn-equator) + var(--btn-equator-spread) * 1.6),\n color-mix(in srgb, var(--wzl-accent) var(--btn-base-tint), black) 100%\n );\n backdrop-filter: blur(var(--btn-blur)) saturate(var(--btn-saturate));\n -webkit-backdrop-filter: blur(var(--btn-blur)) saturate(var(--btn-saturate));\n color: var(--wzl-fg-on-accent);\n /* Main shadow below for legibility, then a second engraving shadow at a\n configurable angle (defaults below) — a near-black, lower-alpha stamp\n that sits underneath the glyphs and reads as recessed type. */\n text-shadow:\n 0 1px 0 rgba(0, 0, 0, var(--btn-text-shadow)),\n var(--btn-text-inset-x) var(--btn-text-inset-y) 0 rgba(0, 0, 0, var(--btn-text-inset)),\n 0 0 6px rgba(0, 0, 0, calc(var(--btn-text-shadow) * 0.5));\n box-shadow:\n inset 0 1px 0 rgba(255, 255, 255, var(--btn-inset-hi)),\n inset 0 -1px 2px rgba(0, 0, 0, var(--btn-inset-lo)),\n 0 0 0 1px rgba(0, 0, 0, var(--btn-rim)),\n 0 1px 2px rgba(0, 0, 0, var(--btn-drop-near)),\n 0 3px 6px rgba(0, 0, 0, var(--btn-drop-far));\n}\n\n.variant_primary:hover:not(:disabled) {\n filter: brightness(1.08) saturate(1.06);\n}\n\n.variant_primary:active:not(:disabled) {\n background: linear-gradient(\n 180deg,\n color-mix(in srgb, var(--wzl-accent) 80%, black) 0%,\n color-mix(in srgb, var(--wzl-accent) 95%, black) 50%,\n color-mix(in srgb, var(--wzl-accent) 60%, white) 100%\n );\n box-shadow:\n inset 0 2px 4px rgba(0, 0, 0, 0.35),\n inset 0 -1px 0 rgba(255, 255, 255, 0.25),\n 0 0 0 1px rgba(0, 0, 0, calc(var(--btn-rim) + 0.06));\n transform: translateY(0.5px);\n}\n.variant_primary:active::before { opacity: 0.3; }\n\n/* Secondary: neutral glass — drained of color. */\n.variant_secondary {\n background: linear-gradient(\n 180deg,\n color-mix(in srgb, var(--wzl-fg) 25%, transparent) 0%,\n color-mix(in srgb, var(--wzl-fg) 10%, transparent) calc(var(--btn-equator) - var(--btn-equator-spread)),\n color-mix(in srgb, var(--wzl-surface-raised) 90%, white) var(--btn-equator),\n var(--wzl-surface-raised) calc(var(--btn-equator) + var(--btn-equator-spread) * 1.6),\n color-mix(in srgb, var(--wzl-surface-sunken) 80%, black) 100%\n );\n backdrop-filter: blur(var(--btn-blur)) saturate(var(--btn-saturate));\n -webkit-backdrop-filter: blur(var(--btn-blur)) saturate(var(--btn-saturate));\n color: var(--wzl-fg);\n text-shadow:\n 0 1px 0 rgba(0, 0, 0, calc(var(--btn-text-shadow) * 0.7)),\n var(--btn-text-inset-x) var(--btn-text-inset-y) 0 rgba(0, 0, 0, calc(var(--btn-text-inset) * 0.7));\n box-shadow:\n inset 0 1px 0 rgba(255, 255, 255, calc(var(--btn-inset-hi) * 0.5)),\n inset 0 -1px 2px rgba(0, 0, 0, calc(var(--btn-inset-lo) * 0.83)),\n 0 0 0 1px rgba(0, 0, 0, calc(var(--btn-rim) + 0.03)),\n 0 1px 2px rgba(0, 0, 0, calc(var(--btn-drop-near) * 0.93)),\n 0 3px 6px rgba(0, 0, 0, calc(var(--btn-drop-far) * 0.89));\n}\n\n.variant_secondary:hover:not(:disabled) { filter: brightness(1.1); }\n\n.variant_secondary:active:not(:disabled) {\n background: linear-gradient(180deg, var(--wzl-surface-sunken) 0%, var(--wzl-surface-raised) 100%);\n box-shadow:\n inset 0 2px 4px rgba(0, 0, 0, 0.4),\n 0 0 0 1px rgba(0, 0, 0, 0.3);\n transform: translateY(0.5px);\n}\n.variant_secondary:active::before { opacity: 0.2; }\n\n/* Ghost: silhouette only — no glass body, no gloss. */\n.variant_ghost {\n background: transparent;\n color: var(--wzl-fg);\n box-shadow: none;\n}\n.variant_ghost::before { display: none; }\n\n.variant_ghost:hover:not(:disabled) {\n background: var(--wzl-surface-hover);\n}\n\n.variant_ghost:active:not(:disabled) {\n background: var(--wzl-surface-pressed);\n}\n\n/* ---------- Modifiers ---------- */\n\n.fullWidth { width: 100%; }\n.loading .label { opacity: 0.7; }\n\n/* ---------- Slots ---------- */\n\n.iconSlot {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n}\n\n.size_sm .iconSlot > svg { width: 12px; height: 12px; }\n.size_md .iconSlot > svg { width: 14px; height: 14px; }\n\n.label { display: inline-block; }\n\n/* ---------- Spinner ---------- */\n\n.spinner {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n animation: wzl-btn-spin 0.7s linear infinite;\n}\n\n@keyframes wzl-btn-spin {\n to { transform: rotate(360deg); }\n}\n","import { forwardRef, type ButtonHTMLAttributes, type ReactNode, type Ref } from 'react';\nimport s from './Button.module.css';\n\n/** Visual weight of a button. Defaults to `secondary`. */\nexport type ButtonVariant = 'primary' | 'secondary' | 'ghost';\n/** Button height and type scale. */\nexport type ButtonSize = 'sm' | 'md';\n\ntype ButtonBase = {\n variant?: ButtonVariant;\n size?: ButtonSize;\n disabled?: boolean;\n loading?: boolean;\n leadingIcon?: ReactNode;\n trailingIcon?: ReactNode;\n fullWidth?: boolean;\n type?: 'button' | 'submit' | 'reset';\n className?: string;\n style?: ButtonHTMLAttributes<HTMLButtonElement>['style'];\n children?: ReactNode;\n onClick?: ButtonHTMLAttributes<HTMLButtonElement>['onClick'];\n};\n\ntype ButtonRegular = ButtonBase & {\n iconOnly?: false;\n ariaLabel?: string;\n};\n\ntype ButtonIconOnly = ButtonBase & {\n iconOnly: true;\n ariaLabel: string;\n};\n\n/**\n * Props for {@link Button}. Setting `iconOnly` makes `ariaLabel` required,\n * since an icon-only button has no text for a screen reader to announce.\n */\nexport type ButtonProps = ButtonRegular | ButtonIconOnly;\n\nfunction Spinner(): ReactNode {\n return (\n <span className={s.spinner} aria-hidden=\"true\">\n <svg viewBox=\"0 0 16 16\" width=\"14\" height=\"14\">\n <circle\n cx=\"8\"\n cy=\"8\"\n r=\"6\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeOpacity=\"0.25\"\n />\n <path\n d=\"M 8 2 A 6 6 0 0 1 14 8\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n />\n </svg>\n </span>\n );\n}\n\n/**\n * Standard button. `loading` swaps the leading icon for a spinner, marks the\n * button `aria-busy`, and leaves the label in place; it does not disable the\n * button, so pass `disabled` too if the click should be blocked.\n *\n * `ref` forwards to the underlying `<button>`.\n */\nexport const Button = forwardRef(function Button(\n props: ButtonProps,\n ref: Ref<HTMLButtonElement>,\n) {\n const {\n variant = 'secondary',\n size = 'md',\n disabled,\n loading,\n leadingIcon,\n trailingIcon,\n fullWidth,\n iconOnly,\n ariaLabel,\n type = 'button',\n className,\n style,\n children,\n onClick,\n } = props;\n\n const cls = [\n s.button,\n s[`variant_${variant}`],\n s[`size_${size}`],\n fullWidth && s.fullWidth,\n iconOnly && s.iconOnly,\n loading && s.loading,\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const showLeading = !iconOnly && (loading || leadingIcon);\n\n return (\n <button\n ref={ref}\n type={type}\n className={cls}\n style={style}\n disabled={disabled}\n aria-busy={loading ? true : undefined}\n aria-label={ariaLabel}\n onClick={onClick}\n >\n {showLeading && (\n <span className={s.iconSlot}>{loading ? <Spinner /> : leadingIcon}</span>\n )}\n {iconOnly ? (\n loading ? <Spinner /> : <span className={s.iconSlot}>{children}</span>\n ) : (\n children !== undefined && <span className={s.label}>{children}</span>\n )}\n {!iconOnly && trailingIcon && (\n <span className={s.iconSlot}>{trailingIcon}</span>\n )}\n </button>\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;ACuCA,SAAS,IAAqB;AAC5B,QACE,kBAAC,QAAD;EAAM,WAAW,EAAE;EAAS,eAAY;YACtC,kBAAC,OAAD;GAAK,SAAQ;GAAY,OAAM;GAAK,QAAO;aAA3C,CACE,kBAAC,UAAD;IACE,IAAG;IACH,IAAG;IACH,GAAE;IACF,MAAK;IACL,QAAO;IACP,aAAY;IACZ,eAAc;IACd,CAAA,EACF,kBAAC,QAAD;IACE,GAAE;IACF,MAAK;IACL,QAAO;IACP,aAAY;IACZ,eAAc;IACd,CAAA,CACE;;EACD,CAAA;;AAWX,IAAa,IAAS,EAAW,SAC/B,GACA,GACA;CACA,IAAM,EACJ,aAAU,aACV,UAAO,MACP,aACA,YACA,gBACA,iBACA,cACA,aACA,cACA,UAAO,UACP,cACA,UACA,aACA,eACE;AAgBJ,QACE,kBAAC,UAAD;EACO;EACC;EACN,WAlBQ;GACV,EAAE;GACF,EAAE,WAAW;GACb,EAAE,QAAQ;GACV,KAAa,EAAE;GACf,KAAY,EAAE;GACd,KAAW,EAAE;GACb;GACD,CACE,OAAO,QAAQ,CACf,KAAK,IAQO;EACJ;EACG;EACV,aAAW,IAAU,KAAO,KAAA;EAC5B,cAAY;EACH;YARX;GAHkB,CAAC,MAAa,KAAW,MAcvC,kBAAC,QAAD;IAAM,WAAW,EAAE;cAAW,IAAU,kBAAC,GAAD,EAAW,CAAA,GAAG;IAAmB,CAAA;GAE1E,IACC,IAAU,kBAAC,GAAD,EAAW,CAAA,GAAG,kBAAC,QAAD;IAAM,WAAW,EAAE;IAAW;IAAgB,CAAA,GAEtE,MAAa,KAAA,KAAa,kBAAC,QAAD;IAAM,WAAW,EAAE;IAAQ;IAAgB,CAAA;GAEtE,CAAC,KAAY,KACZ,kBAAC,QAAD;IAAM,WAAW,EAAE;cAAW;IAAoB,CAAA;GAE7C;;EAEX"}
1
+ {"version":3,"file":"Button-CExdkQcU.js","names":[],"sources":["../../src/components/Button/Button.module.css","../../src/components/Button/Button.tsx"],"sourcesContent":["/* Aqua-glass button. Every visual parameter is exposed as a CSS custom\n property so the Button Lab can override per-instance via inline style. */\n.button {\n /* ---- Tunables (with Aqua-biased defaults) ---- */\n /* Corner radius = 10% of the button's height (the shorter axis on every\n realistic button shape). Using calc against --btn-height keeps the\n corners circular rather than elliptical, which a % value would\n otherwise produce on a wide-but-short pill. */\n --btn-radius: calc(var(--btn-height) * 0.1);\n --btn-fontweight: var(--wzl-font-weight-medium);\n --btn-fontsize: var(--wzl-font-size);\n --btn-height: 24px;\n --btn-padx: 12px;\n\n /* Body gradient — alpha-laced top, opaque bottom. Percentages are\n \"color-mix accent ratio\" so 45% = 45% accent + 55% transparent. */\n --btn-top-alpha: 45%;\n --btn-upper-alpha: 70%;\n --btn-equator: 52%; /* vertical position of the bright-to-deep transition */\n --btn-equator-spread: 12%; /* half-width of the equator transition band */\n --btn-equator-tint: 95%; /* accent vs white at equator */\n --btn-base-tint: 70%; /* accent vs black at base */\n --btn-blur: 6px;\n --btn-saturate: 1.3;\n\n /* Specular gloss (::before) */\n --btn-gloss-top: 0.42;\n --btn-gloss-mid: 0.12;\n --btn-gloss-bottom: 50%; /* inset from bottom — 50% = upper hemisphere */\n\n /* 3D shadows */\n --btn-rim: 0.22;\n --btn-drop-near: 0.30;\n --btn-drop-far: 0.18;\n --btn-inset-hi: 0.42;\n --btn-inset-lo: 0.3;\n\n /* Text — main shadow + a second engraving shadow you can angle.\n `inset-x` / `inset-y` are pre-projected offsets from `inset-angle` so\n the lab can drive them with a single slider. */\n --btn-text-shadow: 0.35;\n --btn-text-inset: 0.55;\n --btn-text-inset-x: 0px;\n --btn-text-inset-y: 1px;\n\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n border: none;\n border-radius: var(--btn-radius);\n font-family: var(--wzl-font-ui);\n font-weight: var(--btn-fontweight);\n font-style: normal;\n font-size: var(--btn-fontsize);\n height: var(--btn-height);\n padding: 0 var(--btn-padx);\n line-height: 1;\n cursor: pointer;\n user-select: none;\n -webkit-user-select: none;\n isolation: isolate;\n overflow: hidden;\n transition: filter var(--wzl-motion-fast), box-shadow var(--wzl-motion-fast), transform 80ms;\n}\n\n/* Specular gloss — covers the upper hemisphere of the pill with a bright\n white sheen that fades to nothing by the equator. The single detail that\n sells the glass-cylinder illusion. */\n.button::before {\n content: '';\n position: absolute;\n inset: 1px 1px var(--btn-gloss-bottom) 1px;\n /* Top corners hug the button's outline; bottom corners are flat so the\n gloss terminates in a straight line at the equator rather than two\n little arcs that read as `)(` brackets at smaller radii. */\n border-top-left-radius: var(--btn-radius);\n border-top-right-radius: var(--btn-radius);\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n background: linear-gradient(\n 180deg,\n rgba(255, 255, 255, var(--btn-gloss-top)) 0%,\n rgba(255, 255, 255, var(--btn-gloss-mid)) 60%,\n rgba(255, 255, 255, 0) 100%\n );\n pointer-events: none;\n z-index: 1;\n transition: opacity var(--wzl-motion-fast);\n}\n\n.button > * {\n position: relative;\n z-index: 2;\n}\n\n.button:focus-visible {\n outline: 2px solid var(--wzl-focus-ring);\n outline-offset: 1px;\n}\n\n.button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* ---------- Sizes — set defaults for the custom props ---------- */\n\n.size_sm { --btn-height: 20px; --btn-padx: 8px; --btn-fontsize: var(--wzl-font-size-sm); }\n.size_md { --btn-height: 24px; --btn-padx: 12px; --btn-fontsize: var(--wzl-font-size); }\n\n.iconOnly.size_sm { width: 20px; --btn-padx: 0; }\n.iconOnly.size_md { width: 24px; --btn-padx: 0; }\n\n/* ---------- Variants ---------- */\n\n/* Primary: tinted aqua glass — body uses --wzl-accent. The upper / equator\n / lower stops are positioned around --btn-equator so dragging the equator\n shifts the entire transition zone as one block. */\n.variant_primary {\n background: linear-gradient(\n 180deg,\n color-mix(in srgb, var(--wzl-accent) var(--btn-top-alpha), transparent) 0%,\n color-mix(in srgb, var(--wzl-accent) var(--btn-upper-alpha), transparent) calc(var(--btn-equator) - var(--btn-equator-spread)),\n color-mix(in srgb, var(--wzl-accent) var(--btn-equator-tint), white) var(--btn-equator),\n var(--wzl-accent) calc(var(--btn-equator) + var(--btn-equator-spread) * 1.6),\n color-mix(in srgb, var(--wzl-accent) var(--btn-base-tint), black) 100%\n );\n backdrop-filter: blur(var(--btn-blur)) saturate(var(--btn-saturate));\n -webkit-backdrop-filter: blur(var(--btn-blur)) saturate(var(--btn-saturate));\n color: var(--wzl-fg-on-accent);\n /* Main shadow below for legibility, then a second engraving shadow at a\n configurable angle (defaults below) — a near-black, lower-alpha stamp\n that sits underneath the glyphs and reads as recessed type. */\n text-shadow:\n 0 1px 0 rgba(0, 0, 0, var(--btn-text-shadow)),\n var(--btn-text-inset-x) var(--btn-text-inset-y) 0 rgba(0, 0, 0, var(--btn-text-inset)),\n 0 0 6px rgba(0, 0, 0, calc(var(--btn-text-shadow) * 0.5));\n box-shadow:\n inset 0 1px 0 rgba(255, 255, 255, var(--btn-inset-hi)),\n inset 0 -1px 2px rgba(0, 0, 0, var(--btn-inset-lo)),\n 0 0 0 1px rgba(0, 0, 0, var(--btn-rim)),\n 0 1px 2px rgba(0, 0, 0, var(--btn-drop-near)),\n 0 3px 6px rgba(0, 0, 0, var(--btn-drop-far));\n}\n\n.variant_primary:hover:not(:disabled) {\n filter: brightness(1.08) saturate(1.06);\n}\n\n.variant_primary:active:not(:disabled) {\n background: linear-gradient(\n 180deg,\n color-mix(in srgb, var(--wzl-accent) 80%, black) 0%,\n color-mix(in srgb, var(--wzl-accent) 95%, black) 50%,\n color-mix(in srgb, var(--wzl-accent) 60%, white) 100%\n );\n box-shadow:\n inset 0 2px 4px rgba(0, 0, 0, 0.35),\n inset 0 -1px 0 rgba(255, 255, 255, 0.25),\n 0 0 0 1px rgba(0, 0, 0, calc(var(--btn-rim) + 0.06));\n transform: translateY(0.5px);\n}\n.variant_primary:active::before { opacity: 0.3; }\n\n/* Secondary: neutral glass — drained of color. */\n.variant_secondary {\n background: linear-gradient(\n 180deg,\n color-mix(in srgb, var(--wzl-fg) 25%, transparent) 0%,\n color-mix(in srgb, var(--wzl-fg) 10%, transparent) calc(var(--btn-equator) - var(--btn-equator-spread)),\n color-mix(in srgb, var(--wzl-surface-raised) 90%, white) var(--btn-equator),\n var(--wzl-surface-raised) calc(var(--btn-equator) + var(--btn-equator-spread) * 1.6),\n color-mix(in srgb, var(--wzl-surface-sunken) 80%, black) 100%\n );\n backdrop-filter: blur(var(--btn-blur)) saturate(var(--btn-saturate));\n -webkit-backdrop-filter: blur(var(--btn-blur)) saturate(var(--btn-saturate));\n color: var(--wzl-fg);\n text-shadow:\n 0 1px 0 rgba(0, 0, 0, calc(var(--btn-text-shadow) * 0.7)),\n var(--btn-text-inset-x) var(--btn-text-inset-y) 0 rgba(0, 0, 0, calc(var(--btn-text-inset) * 0.7));\n box-shadow:\n inset 0 1px 0 rgba(255, 255, 255, calc(var(--btn-inset-hi) * 0.5)),\n inset 0 -1px 2px rgba(0, 0, 0, calc(var(--btn-inset-lo) * 0.83)),\n 0 0 0 1px rgba(0, 0, 0, calc(var(--btn-rim) + 0.03)),\n 0 1px 2px rgba(0, 0, 0, calc(var(--btn-drop-near) * 0.93)),\n 0 3px 6px rgba(0, 0, 0, calc(var(--btn-drop-far) * 0.89));\n}\n\n.variant_secondary:hover:not(:disabled) { filter: brightness(1.1); }\n\n.variant_secondary:active:not(:disabled) {\n background: linear-gradient(180deg, var(--wzl-surface-sunken) 0%, var(--wzl-surface-raised) 100%);\n box-shadow:\n inset 0 2px 4px rgba(0, 0, 0, 0.4),\n 0 0 0 1px rgba(0, 0, 0, 0.3);\n transform: translateY(0.5px);\n}\n.variant_secondary:active::before { opacity: 0.2; }\n\n/* Ghost: silhouette only — no glass body, no gloss. */\n.variant_ghost {\n background: transparent;\n color: var(--wzl-fg);\n box-shadow: none;\n}\n.variant_ghost::before { display: none; }\n\n.variant_ghost:hover:not(:disabled) {\n background: var(--wzl-surface-hover);\n}\n\n.variant_ghost:active:not(:disabled) {\n background: var(--wzl-surface-pressed);\n}\n\n/* ---------- Modifiers ---------- */\n\n.pressed:not(:disabled) {\n background: var(--wzl-surface-pressed);\n color: var(--wzl-fg);\n box-shadow: inset 0 1px 2px rgb(0 0 0 / 18%);\n}\n\n.variant_primary.pressed:not(:disabled) { filter: brightness(0.92); }\n\n.fullWidth { width: 100%; }\n.loading .label { opacity: 0.7; }\n\n/* ---------- Slots ---------- */\n\n.iconSlot {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n}\n\n.size_sm .iconSlot > svg { width: 12px; height: 12px; }\n.size_md .iconSlot > svg { width: 14px; height: 14px; }\n\n.label { display: inline-block; }\n\n/* ---------- Spinner ---------- */\n\n.spinner {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n animation: wzl-btn-spin 0.7s linear infinite;\n}\n\n@keyframes wzl-btn-spin {\n to { transform: rotate(360deg); }\n}\n","import { forwardRef, type ButtonHTMLAttributes, type ReactNode, type Ref } from 'react';\nimport s from './Button.module.css';\n\n/** Visual weight of a button. Defaults to `secondary`. */\nexport type ButtonVariant = 'primary' | 'secondary' | 'ghost';\n/** Button height and type scale. */\nexport type ButtonSize = 'sm' | 'md';\n\ntype ButtonBase = {\n variant?: ButtonVariant;\n size?: ButtonSize;\n /** A button that stays down: renders `aria-pressed` and holds the active\n * treatment while it is on. For a control that reports a state rather than\n * firing an action -- a panel toggle, a mode switch. Left off, the button\n * announces no pressed state at all, which is what an action button wants. */\n pressed?: boolean;\n disabled?: boolean;\n loading?: boolean;\n leadingIcon?: ReactNode;\n trailingIcon?: ReactNode;\n fullWidth?: boolean;\n type?: 'button' | 'submit' | 'reset';\n className?: string;\n style?: ButtonHTMLAttributes<HTMLButtonElement>['style'];\n children?: ReactNode;\n onClick?: ButtonHTMLAttributes<HTMLButtonElement>['onClick'];\n};\n\ntype ButtonRegular = ButtonBase & {\n iconOnly?: false;\n ariaLabel?: string;\n};\n\ntype ButtonIconOnly = ButtonBase & {\n iconOnly: true;\n ariaLabel: string;\n};\n\n/**\n * Props for {@link Button}. Setting `iconOnly` makes `ariaLabel` required,\n * since an icon-only button has no text for a screen reader to announce.\n */\nexport type ButtonProps = ButtonRegular | ButtonIconOnly;\n\nfunction Spinner(): ReactNode {\n return (\n <span className={s.spinner} aria-hidden=\"true\">\n <svg viewBox=\"0 0 16 16\" width=\"14\" height=\"14\">\n <circle\n cx=\"8\"\n cy=\"8\"\n r=\"6\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeOpacity=\"0.25\"\n />\n <path\n d=\"M 8 2 A 6 6 0 0 1 14 8\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n />\n </svg>\n </span>\n );\n}\n\n/**\n * Standard button. `loading` swaps the leading icon for a spinner, marks the\n * button `aria-busy`, and leaves the label in place; it does not disable the\n * button, so pass `disabled` too if the click should be blocked.\n *\n * `ref` forwards to the underlying `<button>`.\n */\nexport const Button = forwardRef(function Button(\n props: ButtonProps,\n ref: Ref<HTMLButtonElement>,\n) {\n const {\n variant = 'secondary',\n size = 'md',\n pressed,\n disabled,\n loading,\n leadingIcon,\n trailingIcon,\n fullWidth,\n iconOnly,\n ariaLabel,\n type = 'button',\n className,\n style,\n children,\n onClick,\n } = props;\n\n const cls = [\n s.button,\n s[`variant_${variant}`],\n s[`size_${size}`],\n fullWidth && s.fullWidth,\n pressed && s.pressed,\n iconOnly && s.iconOnly,\n loading && s.loading,\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const showLeading = !iconOnly && (loading || leadingIcon);\n\n return (\n <button\n ref={ref}\n type={type}\n className={cls}\n style={style}\n disabled={disabled}\n aria-busy={loading ? true : undefined}\n aria-pressed={pressed}\n aria-label={ariaLabel}\n onClick={onClick}\n >\n {showLeading && (\n <span className={s.iconSlot}>{loading ? <Spinner /> : leadingIcon}</span>\n )}\n {iconOnly ? (\n loading ? <Spinner /> : <span className={s.iconSlot}>{children}</span>\n ) : (\n children !== undefined && <span className={s.label}>{children}</span>\n )}\n {!iconOnly && trailingIcon && (\n <span className={s.iconSlot}>{trailingIcon}</span>\n )}\n </button>\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AC4CA,SAAS,IAAqB;AAC5B,QACE,kBAAC,QAAD;EAAM,WAAW,EAAE;EAAS,eAAY;YACtC,kBAAC,OAAD;GAAK,SAAQ;GAAY,OAAM;GAAK,QAAO;aAA3C,CACE,kBAAC,UAAD;IACE,IAAG;IACH,IAAG;IACH,GAAE;IACF,MAAK;IACL,QAAO;IACP,aAAY;IACZ,eAAc;IACd,CAAA,EACF,kBAAC,QAAD;IACE,GAAE;IACF,MAAK;IACL,QAAO;IACP,aAAY;IACZ,eAAc;IACd,CAAA,CACE;;EACD,CAAA;;AAWX,IAAa,IAAS,EAAW,SAC/B,GACA,GACA;CACA,IAAM,EACJ,aAAU,aACV,UAAO,MACP,YACA,aACA,YACA,gBACA,iBACA,cACA,aACA,cACA,UAAO,UACP,cACA,UACA,aACA,eACE;AAiBJ,QACE,kBAAC,UAAD;EACO;EACC;EACN,WAnBQ;GACV,EAAE;GACF,EAAE,WAAW;GACb,EAAE,QAAQ;GACV,KAAa,EAAE;GACf,KAAW,EAAE;GACb,KAAY,EAAE;GACd,KAAW,EAAE;GACb;GACD,CACE,OAAO,QAAQ,CACf,KAAK,IAQO;EACJ;EACG;EACV,aAAW,IAAU,KAAO,KAAA;EAC5B,gBAAc;EACd,cAAY;EACH;YATX;GAHkB,CAAC,MAAa,KAAW,MAevC,kBAAC,QAAD;IAAM,WAAW,EAAE;cAAW,IAAU,kBAAC,GAAD,EAAW,CAAA,GAAG;IAAmB,CAAA;GAE1E,IACC,IAAU,kBAAC,GAAD,EAAW,CAAA,GAAG,kBAAC,QAAD;IAAM,WAAW,EAAE;IAAW;IAAgB,CAAA,GAEtE,MAAa,KAAA,KAAa,kBAAC,QAAD;IAAM,WAAW,EAAE;IAAQ;IAAgB,CAAA;GAEtE,CAAC,KAAY,KACZ,kBAAC,QAAD;IAAM,WAAW,EAAE;cAAW;IAAoB,CAAA;GAE7C;;EAEX"}
@@ -1,4 +1,4 @@
1
- import { t as e } from "./InlineRange-50ulExCL.js";
1
+ import { t as e } from "./InlineRange-CcfzY80y.js";
2
2
  import { Fragment as t, jsx as n, jsxs as r } from "react/jsx-runtime";
3
3
  import { getAlpha01 as i, toHex8 as a, withAlpha01 as o } from "@weasel-js/core";
4
4
  import { useState as s } from "react";
@@ -57,4 +57,4 @@ function l(l) {
57
57
  //#endregion
58
58
  export { l as t };
59
59
 
60
- //# sourceMappingURL=ColorField-D0OxUlvu.js.map
60
+ //# sourceMappingURL=ColorField-C20aRvCg.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ColorField-D0OxUlvu.js","names":[],"sources":["../../src/components/ColorField/ColorField.module.css","../../src/components/ColorField/ColorField.tsx"],"sourcesContent":[".root {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n}\n\n.chip {\n position: relative;\n display: inline-flex;\n border-radius: var(--wzl-radius-sm);\n overflow: hidden;\n}\n\n.color {\n inline-size: 28px;\n block-size: 20px;\n padding: 0;\n border: 1px solid var(--wzl-border, #444);\n border-radius: var(--wzl-radius-sm);\n background: none;\n cursor: pointer;\n}\n\n.color:focus-visible {\n outline: none;\n border-color: var(--wzl-focus-ring);\n box-shadow: 0 0 0 1px var(--wzl-focus-ring);\n}\n\n/* Indeterminate (mixed) presentation: checkerboard overlay atop the\n * swatch. pointer-events: none so the input stays clickable. */\n.root[data-mixed] .chip::after {\n content: '';\n position: absolute;\n inset: 1px;\n border-radius: var(--wzl-radius-sm);\n pointer-events: none;\n background: repeating-conic-gradient(\n var(--wzl-border, #666) 0% 25%,\n var(--wzl-surface, #2e2f36) 0% 50%\n )\n 50% / 8px 8px;\n}\n\n/* `InlineRange` owns the track; this only says how it shares the row. */\n.alphaRange {\n flex: 1;\n}\n\n.alphaReadout {\n min-inline-size: 3ch;\n text-align: end;\n font-size: var(--wzl-font-size-sm);\n opacity: 0.7;\n}\n","import { useState } from 'react';\nimport { toHex8, getAlpha01, withAlpha01 } from '@weasel-js/core';\nimport { InlineRange } from '../InlineRange';\nimport s from './ColorField.module.css';\n\n/**\n * Props for {@link ColorField}. `onInput` fires throughout a gesture and\n * `onChange` once at its end.\n */\nexport interface ColorFieldProps {\n /** Current color, `#rrggbb` or `#rrggbbaa`. Omit when `mixed`. */\n value?: string;\n /** Indeterminate presentation (multi-selection with differing colors):\n * checkered chip, empty value. The first color edit produces a real\n * value; the opacity slider stays disabled until then (an alpha-only\n * edit would otherwise commit a value composed against the\n * placeholder black). */\n mixed?: boolean;\n /** Show the opacity slider; emitted values are `#rrggbbaa`. */\n alpha?: boolean;\n /** Live value during interaction (picker drag, slider drag). Optional —\n * wire it for live preview; omit it for commit-only consumers. */\n onInput?: (hex: string) => void;\n /** Committed value — picker close (blur) or slider release. One call\n * per user gesture; pair with an undoable write. */\n onChange: (hex: string) => void;\n 'aria-label'?: string;\n className?: string;\n}\n\n/**\n * Compact color editor: native color input + optional opacity slider.\n * Commit semantics are gesture-based (see `onChange`) because native\n * color/range inputs fire `change` continuously during interaction —\n * commit-on-change would emit one undo entry per tick.\n */\nexport function ColorField(props: ColorFieldProps) {\n const { value, mixed = false, alpha = false, onInput, onChange, className } = props;\n const hex8 = toHex8(value ?? '#000000');\n const rgb6 = hex8.slice(0, 7);\n const alpha01 = getAlpha01(hex8);\n const alphaPct = Math.round(alpha01 * 100);\n\n // Drafts track the control during a gesture (the committed prop only\n // updates after onChange), then reset to follow the prop again.\n const [colorDraft, setColorDraft] = useState<string | null>(null);\n const [alphaDraft, setAlphaDraft] = useState<number | null>(null);\n const visibleRgb = colorDraft ?? rgb6;\n const visibleAlphaPct = alphaDraft ?? alphaPct;\n\n const compose = (rgb: string, a01: number): string =>\n alpha ? withAlpha01(rgb, a01) : rgb;\n\n // Mixed with no color edit yet: the alpha slider has nothing real to\n // compose against (rgb6 is the placeholder black), so keep it disabled\n // until the first color edit lands.\n const alphaLocked = mixed && colorDraft === null;\n\n // Commit only when a gesture actually changed something — blur with no\n // preceding input must not emit (it would create a no-op undo entry).\n const commit = (rgb: string, a01: number): void => {\n if (colorDraft === null && alphaDraft === null) return;\n onChange(compose(rgb, a01));\n setColorDraft(null);\n setAlphaDraft(null);\n };\n\n return (\n <span\n className={[s.root, className].filter(Boolean).join(' ')}\n {...(mixed && colorDraft === null ? { 'data-mixed': '' } : {})}\n >\n <span className={s.chip}>\n <input\n className={s.color}\n type=\"color\"\n value={visibleRgb}\n aria-label={props['aria-label'] ?? 'Color'}\n onInput={(e) => {\n const rgb = (e.target as HTMLInputElement).value;\n setColorDraft(rgb);\n onInput?.(compose(rgb, visibleAlphaPct / 100));\n }}\n onBlur={() => commit(visibleRgb, visibleAlphaPct / 100)}\n />\n </span>\n {alpha && (\n <>\n <InlineRange\n className={s.alphaRange}\n min={0}\n max={100}\n step={1}\n value={visibleAlphaPct}\n disabled={alphaLocked}\n aria-label={props['aria-label'] ? `${props['aria-label']} opacity` : 'Opacity'}\n onInput={(e) => {\n const pct = Number((e.target as HTMLInputElement).value);\n setAlphaDraft(pct);\n onInput?.(compose(visibleRgb, pct / 100));\n }}\n onPointerUp={() => commit(visibleRgb, visibleAlphaPct / 100)}\n onPointerCancel={() => commit(visibleRgb, visibleAlphaPct / 100)}\n onKeyUp={() => commit(visibleRgb, visibleAlphaPct / 100)}\n onBlur={() => commit(visibleRgb, visibleAlphaPct / 100)}\n />\n <span className={s.alphaReadout} aria-hidden=\"true\">{visibleAlphaPct}%</span>\n </>\n )}\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;;;;ACoCA,SAAgB,EAAW,GAAwB;CACjD,IAAM,EAAE,UAAO,WAAQ,IAAO,WAAQ,IAAO,YAAS,aAAU,iBAAc,GACxE,IAAO,EAAO,KAAS,UAAU,EACjC,IAAO,EAAK,MAAM,GAAG,EAAE,EACvB,IAAU,EAAW,EAAK,EAC1B,IAAW,KAAK,MAAM,IAAU,IAAI,EAIpC,CAAC,GAAY,KAAiB,EAAwB,KAAK,EAC3D,CAAC,GAAY,KAAiB,EAAwB,KAAK,EAC3D,IAAa,KAAc,GAC3B,IAAkB,KAAc,GAEhC,KAAW,GAAa,MAC5B,IAAQ,EAAY,GAAK,EAAI,GAAG,GAK5B,IAAc,KAAS,MAAe,MAItC,KAAU,GAAa,MAAsB;AAC7C,QAAe,QAAQ,MAAe,SAC1C,EAAS,EAAQ,GAAK,EAAI,CAAC,EAC3B,EAAc,KAAK,EACnB,EAAc,KAAK;;AAGrB,QACE,kBAAC,QAAD;EACE,WAAW,CAAC,EAAE,MAAM,EAAU,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI;EACxD,GAAK,KAAS,MAAe,OAAO,EAAE,cAAc,IAAI,GAAG,EAAE;YAF/D,CAIE,kBAAC,QAAD;GAAM,WAAW,EAAE;aACjB,kBAAC,SAAD;IACE,WAAW,EAAE;IACb,MAAK;IACL,OAAO;IACP,cAAY,EAAM,iBAAiB;IACnC,UAAU,MAAM;KACd,IAAM,IAAO,EAAE,OAA4B;AAE3C,KADA,EAAc,EAAI,EAClB,IAAU,EAAQ,GAAK,IAAkB,IAAI,CAAC;;IAEhD,cAAc,EAAO,GAAY,IAAkB,IAAI;IACvD,CAAA;GACG,CAAA,EACN,KACC,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,GAAD;GACE,WAAW,EAAE;GACb,KAAK;GACL,KAAK;GACL,MAAM;GACN,OAAO;GACP,UAAU;GACV,cAAY,EAAM,gBAAgB,GAAG,EAAM,cAAc,YAAY;GACrE,UAAU,MAAM;IACd,IAAM,IAAM,OAAQ,EAAE,OAA4B,MAAM;AAExD,IADA,EAAc,EAAI,EAClB,IAAU,EAAQ,GAAY,IAAM,IAAI,CAAC;;GAE3C,mBAAmB,EAAO,GAAY,IAAkB,IAAI;GAC5D,uBAAuB,EAAO,GAAY,IAAkB,IAAI;GAChE,eAAe,EAAO,GAAY,IAAkB,IAAI;GACxD,cAAc,EAAO,GAAY,IAAkB,IAAI;GACvD,CAAA,EACF,kBAAC,QAAD;GAAM,WAAW,EAAE;GAAc,eAAY;aAA7C,CAAqD,GAAgB,IAAQ;KAC5E,EAAA,CAAA,CAEA"}
1
+ {"version":3,"file":"ColorField-C20aRvCg.js","names":[],"sources":["../../src/components/ColorField/ColorField.module.css","../../src/components/ColorField/ColorField.tsx"],"sourcesContent":[".root {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n}\n\n.chip {\n position: relative;\n display: inline-flex;\n border-radius: var(--wzl-radius-sm);\n overflow: hidden;\n}\n\n.color {\n inline-size: 28px;\n block-size: 20px;\n padding: 0;\n border: 1px solid var(--wzl-border, #444);\n border-radius: var(--wzl-radius-sm);\n background: none;\n cursor: pointer;\n}\n\n.color:focus-visible {\n outline: none;\n border-color: var(--wzl-focus-ring);\n box-shadow: 0 0 0 1px var(--wzl-focus-ring);\n}\n\n/* Indeterminate (mixed) presentation: checkerboard overlay atop the\n * swatch. pointer-events: none so the input stays clickable. */\n.root[data-mixed] .chip::after {\n content: '';\n position: absolute;\n inset: 1px;\n border-radius: var(--wzl-radius-sm);\n pointer-events: none;\n background: repeating-conic-gradient(\n var(--wzl-border, #666) 0% 25%,\n var(--wzl-surface, #2e2f36) 0% 50%\n )\n 50% / 8px 8px;\n}\n\n/* `InlineRange` owns the track; this only says how it shares the row. */\n.alphaRange {\n flex: 1;\n}\n\n.alphaReadout {\n min-inline-size: 3ch;\n text-align: end;\n font-size: var(--wzl-font-size-sm);\n opacity: 0.7;\n}\n","import { useState } from 'react';\nimport { toHex8, getAlpha01, withAlpha01 } from '@weasel-js/core';\nimport { InlineRange } from '../InlineRange';\nimport s from './ColorField.module.css';\n\n/**\n * Props for {@link ColorField}. `onInput` fires throughout a gesture and\n * `onChange` once at its end.\n */\nexport interface ColorFieldProps {\n /** Current color, `#rrggbb` or `#rrggbbaa`. Omit when `mixed`. */\n value?: string;\n /** Indeterminate presentation (multi-selection with differing colors):\n * checkered chip, empty value. The first color edit produces a real\n * value; the opacity slider stays disabled until then (an alpha-only\n * edit would otherwise commit a value composed against the\n * placeholder black). */\n mixed?: boolean;\n /** Show the opacity slider; emitted values are `#rrggbbaa`. */\n alpha?: boolean;\n /** Live value during interaction (picker drag, slider drag). Optional —\n * wire it for live preview; omit it for commit-only consumers. */\n onInput?: (hex: string) => void;\n /** Committed value — picker close (blur) or slider release. One call\n * per user gesture; pair with an undoable write. */\n onChange: (hex: string) => void;\n 'aria-label'?: string;\n className?: string;\n}\n\n/**\n * Compact color editor: native color input + optional opacity slider.\n * Commit semantics are gesture-based (see `onChange`) because native\n * color/range inputs fire `change` continuously during interaction —\n * commit-on-change would emit one undo entry per tick.\n */\nexport function ColorField(props: ColorFieldProps) {\n const { value, mixed = false, alpha = false, onInput, onChange, className } = props;\n const hex8 = toHex8(value ?? '#000000');\n const rgb6 = hex8.slice(0, 7);\n const alpha01 = getAlpha01(hex8);\n const alphaPct = Math.round(alpha01 * 100);\n\n // Drafts track the control during a gesture (the committed prop only\n // updates after onChange), then reset to follow the prop again.\n const [colorDraft, setColorDraft] = useState<string | null>(null);\n const [alphaDraft, setAlphaDraft] = useState<number | null>(null);\n const visibleRgb = colorDraft ?? rgb6;\n const visibleAlphaPct = alphaDraft ?? alphaPct;\n\n const compose = (rgb: string, a01: number): string =>\n alpha ? withAlpha01(rgb, a01) : rgb;\n\n // Mixed with no color edit yet: the alpha slider has nothing real to\n // compose against (rgb6 is the placeholder black), so keep it disabled\n // until the first color edit lands.\n const alphaLocked = mixed && colorDraft === null;\n\n // Commit only when a gesture actually changed something — blur with no\n // preceding input must not emit (it would create a no-op undo entry).\n const commit = (rgb: string, a01: number): void => {\n if (colorDraft === null && alphaDraft === null) return;\n onChange(compose(rgb, a01));\n setColorDraft(null);\n setAlphaDraft(null);\n };\n\n return (\n <span\n className={[s.root, className].filter(Boolean).join(' ')}\n {...(mixed && colorDraft === null ? { 'data-mixed': '' } : {})}\n >\n <span className={s.chip}>\n <input\n className={s.color}\n type=\"color\"\n value={visibleRgb}\n aria-label={props['aria-label'] ?? 'Color'}\n onInput={(e) => {\n const rgb = (e.target as HTMLInputElement).value;\n setColorDraft(rgb);\n onInput?.(compose(rgb, visibleAlphaPct / 100));\n }}\n onBlur={() => commit(visibleRgb, visibleAlphaPct / 100)}\n />\n </span>\n {alpha && (\n <>\n <InlineRange\n className={s.alphaRange}\n min={0}\n max={100}\n step={1}\n value={visibleAlphaPct}\n disabled={alphaLocked}\n aria-label={props['aria-label'] ? `${props['aria-label']} opacity` : 'Opacity'}\n onInput={(e) => {\n const pct = Number((e.target as HTMLInputElement).value);\n setAlphaDraft(pct);\n onInput?.(compose(visibleRgb, pct / 100));\n }}\n onPointerUp={() => commit(visibleRgb, visibleAlphaPct / 100)}\n onPointerCancel={() => commit(visibleRgb, visibleAlphaPct / 100)}\n onKeyUp={() => commit(visibleRgb, visibleAlphaPct / 100)}\n onBlur={() => commit(visibleRgb, visibleAlphaPct /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ACN,OAAO;GACP,UAAU;GACV,cAAY,EAAM,gBAAgB,GAAG,EAAM,cAAc,YAAY;GACrE,UAAU,MAAM;IACd,IAAM,IAAM,OAAQ,EAAE,OAA4B,MAAM;AAExD,IADA,EAAc,EAAI,EAClB,IAAU,EAAQ,GAAY,IAAM,IAAI,CAAC;;GAE3C,mBAAmB,EAAO,GAAY,IAAkB,IAAI;GAC5D,uBAAuB,EAAO,GAAY,IAAkB,IAAI;GAChE,eAAe,EAAO,GAAY,IAAkB,IAAI;GACxD,cAAc,EAAO,GAAY,IAAkB,IAAI;GACvD,CAAA,EACF,kBAAC,QAAD;GAAM,WAAW,EAAE;GAAc,eAAY;aAA7C,CAAqD,GAAgB,IAAQ;KAC5E,EAAA,CAAA,CAEA"}
@@ -1,4 +1,4 @@
1
- import { t as e } from "./Slider-Bk_G5sSW.js";
1
+ import { t as e } from "./Slider-Bs-KSYgQ.js";
2
2
  import { jsx as t, jsxs as n } from "react/jsx-runtime";
3
3
  import { useEffect as r, useRef as i } from "react";
4
4
  var a = {
@@ -80,4 +80,4 @@ function l(l) {
80
80
  //#endregion
81
81
  export { l as t };
82
82
 
83
- //# sourceMappingURL=DetentSlider-BVWKdRyC.js.map
83
+ //# sourceMappingURL=DetentSlider-BpD7bgjN.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DetentSlider-BVWKdRyC.js","names":[],"sources":["../../src/components/DetentSlider/DetentSlider.module.css","../../src/components/DetentSlider/DetentSlider.tsx"],"sourcesContent":[".root {\n position: relative;\n /* Read by Slider's track and stop marks. Detents run the full height of the\n * track so they read as notches rather than as tally marks beside it. */\n --rp-tick-inset: 0;\n --rp-tick-width: 1px;\n --rp-tick-color: var(--wzl-border-strong);\n --rp-track-cursor: pointer;\n font-family: var(--wzl-font-ui);\n}\n\n.slider {\n width: 100%;\n}\n\n.labels {\n position: relative;\n height: calc(var(--wzl-font-size-xs) * var(--wzl-leading-tight));\n margin-top: var(--wzl-space-xs);\n}\n\n.label {\n position: absolute;\n transform: translateX(-50%);\n white-space: nowrap;\n font-size: var(--wzl-font-size-xs);\n line-height: var(--wzl-leading-tight);\n font-variant-numeric: tabular-nums;\n color: var(--wzl-fg-subtle);\n}\n\n/* The end labels are pinned inside the track rather than centred on it, so a\n * wide one can't spill past the control and misalign whatever sits beside it. */\n.label[data-edge=\"start\"] {\n transform: none;\n}\n\n.label[data-edge=\"end\"] {\n transform: translateX(-100%);\n}\n\n.label[data-selected] {\n color: var(--wzl-fg);\n font-weight: var(--wzl-font-weight-medium);\n}\n","import { useEffect, useRef, type ReactElement, type ReactNode } from 'react';\nimport { Slider, type Thumb } from '../Slider/Slider';\nimport s from './DetentSlider.module.css';\n\n/** What a detent can carry. Narrowed so identity comparison and React keys\n * both work without a keying callback. */\nexport type DetentValue = string | number;\n\n/** One detent on a {@link DetentSlider}. */\nexport type DetentItem<V extends DetentValue = number> = {\n value: V;\n /** Drawn under the detent. Defaults to `formatLabel(value)`, then `value`. */\n label?: ReactNode;\n /** Spoken form, when the drawn label is not the right thing to say. */\n ariaLabel?: string;\n};\n\n/**\n * Props for {@link DetentSlider}.\n *\n * `items` takes bare values or `DetentItem`s interchangeably — a bare value is\n * a detent with no label of its own.\n *\n * `onChange` fires on every detent the control passes through, including\n * mid-drag: each one is a complete, legal choice, so there is no in-flight\n * value to withhold. `onCommit` fires once the gesture that changed things\n * ends, and is the one to write to history.\n */\nexport type DetentSliderProps<V extends DetentValue = number> = {\n items: readonly (V | DetentItem<V>)[];\n value: V;\n onChange: (value: V, index: number) => void;\n onCommit?: (value: V, index: number) => void;\n formatLabel?: (value: V, index: number) => ReactNode;\n labels?: 'all' | 'ends' | 'none';\n trackHeight?: number;\n ariaLabel?: string;\n className?: string;\n};\n\nfunction normalize<V extends DetentValue>(items: readonly (V | DetentItem<V>)[]): DetentItem<V>[] {\n return items.map(it => (typeof it === 'object' && it !== null ? it : ({ value: it } as DetentItem<V>)));\n}\n\n/**\n * The detent `value` selects. An exact match wins; a number that matches none\n * lands on the nearest one, so a value arriving from a numeric field or an\n * older save renders where it belongs rather than silently reading as the\n * first detent.\n */\nfunction resolveIndex<V extends DetentValue>(items: readonly DetentItem<V>[], value: V): number {\n const exact = items.findIndex(it => it.value === value);\n if (exact !== -1) return exact;\n if (typeof value !== 'number') return 0;\n let best = 0;\n let bestGap = Infinity;\n for (let i = 0; i < items.length; i++) {\n const v = items[i].value;\n if (typeof v !== 'number') continue;\n const gap = Math.abs(v - value);\n if (gap < bestGap) {\n bestGap = gap;\n best = i;\n }\n }\n return best;\n}\n\nfunction plainText(label: ReactNode, fallback: DetentValue): string {\n return typeof label === 'string' || typeof label === 'number' ? String(label) : String(fallback);\n}\n\n/**\n * Slider over a fixed list of values: one detent per value, evenly spaced, the\n * thumb resting on one of them.\n *\n * This is the shape to reach for when a numeric option has a small set of\n * allowed values along a line — playback rate, zoom step, stroke weight — in\n * place of a dropdown, which hides the ordering and the extent of the range\n * behind a click.\n *\n * The track addresses the *index* of `items`, not the value, which is what\n * makes the detents evenly spaced no matter how the values are distributed:\n * a geometric rate list (0.25/0.5/1/2/4) laid out linearly would crowd four\n * of its five detents into the first fifth of the track and leave the most\n * used one nearly unhittable. Since the index is meaningless to a screen\n * reader, the value is published as `aria-valuetext`.\n */\nexport function DetentSlider<V extends DetentValue = number>(props: DetentSliderProps<V>): ReactElement {\n const { value, onChange, onCommit, formatLabel, ariaLabel, className } = props;\n const items = normalize(props.items);\n const labelMode = props.labels ?? 'all';\n const index = resolveIndex(items, value);\n const lastIndex = Math.max(0, items.length - 1);\n\n const labelOf = (item: DetentItem<V>, i: number): ReactNode =>\n item.label ?? formatLabel?.(item.value, i) ?? String(item.value);\n\n // Deduped separately: `live` suppresses the repeat reports a drag produces\n // while the pointer crosses one detent, `changed` keeps a press that chose\n // nothing from landing a no-op entry in the consumer's history.\n const liveRef = useRef(index);\n const changedRef = useRef(false);\n useEffect(() => {\n liveRef.current = index;\n }, [index]);\n\n const at = (raw: number): number => Math.max(0, Math.min(lastIndex, Math.round(raw)));\n\n const handleInput = (next: Thumb[]) => {\n const i = at(next[0].value);\n if (i === liveRef.current) return;\n liveRef.current = i;\n changedRef.current = true;\n onChange(items[i].value, i);\n };\n\n const handleCommit = (next: Thumb[]) => {\n if (!changedRef.current) return;\n changedRef.current = false;\n const i = at(next[0].value);\n onCommit?.(items[i].value, i);\n };\n\n const current = items[index];\n if (!current) return <div className={className ? `${s.root} ${className}` : s.root} />;\n\n const thumbs: Thumb[] = [\n { value: index, valueText: current.ariaLabel ?? plainText(labelOf(current, index), current.value) },\n ];\n\n const shown =\n labelMode === 'ends'\n ? [...new Set([0, lastIndex])]\n : items.map((_, i) => i);\n\n return (\n <div className={className ? `${s.root} ${className}` : s.root}>\n <Slider\n className={s.slider}\n min={0}\n max={lastIndex}\n step={1}\n stops={items.map((_, i) => i)}\n trackClick=\"move-nearest\"\n trackHeight={props.trackHeight ?? 8}\n ariaLabel={ariaLabel}\n thumbs={thumbs}\n onInput={handleInput}\n onChange={handleCommit}\n />\n {labelMode !== 'none' && (\n <div className={s.labels} data-detent-labels aria-hidden=\"true\">\n {shown.map(i => (\n <span\n key={items[i].value}\n className={s.label}\n data-detent-label\n data-index={i}\n data-selected={i === index ? 'true' : undefined}\n data-edge={i === 0 ? 'start' : i === lastIndex ? 'end' : undefined}\n style={{ left: `${(lastIndex === 0 ? 0 : i / lastIndex) * 100}%` }}\n >\n {labelOf(items[i], i)}\n </span>\n ))}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;ACwCA,SAAS,EAAiC,GAAwD;AAChG,QAAO,EAAM,KAAI,MAAO,OAAO,KAAO,YAAY,IAAc,IAAM,EAAE,OAAO,GAAI,CAAoB;;AASzG,SAAS,EAAoC,GAAiC,GAAkB;CAC9F,IAAM,IAAQ,EAAM,WAAU,MAAM,EAAG,UAAU,EAAM;AACvD,KAAI,MAAU,GAAI,QAAO;AACzB,KAAI,OAAO,KAAU,SAAU,QAAO;CACtC,IAAI,IAAO,GACP,IAAU;AACd,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c,EAAE,MAAQ,CAAA;CAEtF,IAAM,IAAkB,CACtB;EAAE,OAAO;EAAO,WAAW,EAAQ,aAAa,EAAU,EAAQ,GAAS,EAAM,EAAE,EAAQ,MAAM;EAAE,CACpG,EAEK,IACJ,MAAc,SACV,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAU,CAAC,CAAC,GAC5B,EAAM,KAAK,GAAG,MAAM,EAAE;AAE5B,QACE,kBAAC,OAAD;EAAK,WAAW,IAAY,GAAG,EAAE,KAAK,GAAG,MAAc,EAAE;YAAzD,CACE,kBAAC,GAAD;GACE,WAAW,EAAE;GACb,KAAK;GACL,KAAK;GACL,MAAM;GACN,OAAO,EAAM,KAAK,GAAG,MAAM,EAAE;GAC7B,YAAW;GACX,aAAa,EAAM,eAAe;GACvB;GACH;GACR,SAAS;GACT,UAAU;GACV,CAAA,EACD,MAAc,UACb,kBAAC,OAAD;GAAK,WAAW,EAAE;GAAQ,sBAAA;GAAmB,eAAY;aACtD,EAAM,KAAI,MACT,kBAAC,QAAD;IAEE,WAAW,EAAE;IACb,qBAAA;IACA,cAAY;IACZ,iBAAe,MAAM,IAAQ,SAAS,KAAA;IACtC,aAAW,MAAM,IAAI,UAAU,MAAM,IAAY,QAAQ,KAAA;IACzD,OAAO,EAAE,MAAM,IAAI,MAAc,IAAI,IAAI,IAAI,KAAa,IAAI,IAAI;cAEjE,EAAQ,EAAM,IAAI,EAAE;IAChB,EATA,EAAM,GAAG,MAST,CACP;GACE,CAAA,CAEJ"}
1
+ {"version":3,"file":"DetentSlider-BpD7bgjN.js","names":[],"sources":["../../src/components/DetentSlider/DetentSlider.module.css","../../src/components/DetentSlider/DetentSlider.tsx"],"sourcesContent":[".root {\n position: relative;\n /* Read by Slider's track and stop marks. Detents run the full height of the\n * track so they read as notches rather than as tally marks beside it. */\n --rp-tick-inset: 0;\n --rp-tick-width: 1px;\n --rp-tick-color: var(--wzl-border-strong);\n --rp-track-cursor: pointer;\n font-family: var(--wzl-font-ui);\n}\n\n.slider {\n width: 100%;\n}\n\n.labels {\n position: relative;\n height: calc(var(--wzl-font-size-xs) * var(--wzl-leading-tight));\n margin-top: var(--wzl-space-xs);\n}\n\n.label {\n position: absolute;\n transform: translateX(-50%);\n white-space: nowrap;\n font-size: var(--wzl-font-size-xs);\n line-height: var(--wzl-leading-tight);\n font-variant-numeric: tabular-nums;\n color: var(--wzl-fg-subtle);\n}\n\n/* The end labels are pinned inside the track rather than centred on it, so a\n * wide one can't spill past the control and misalign whatever sits beside it. */\n.label[data-edge=\"start\"] {\n transform: none;\n}\n\n.label[data-edge=\"end\"] {\n transform: translateX(-100%);\n}\n\n.label[data-selected] {\n color: var(--wzl-fg);\n font-weight: var(--wzl-font-weight-medium);\n}\n","import { useEffect, useRef, type ReactElement, type ReactNode } from 'react';\nimport { Slider, type Thumb } from '../Slider/Slider';\nimport s from './DetentSlider.module.css';\n\n/** What a detent can carry. Narrowed so identity comparison and React keys\n * both work without a keying callback. */\nexport type DetentValue = string | number;\n\n/** One detent on a {@link DetentSlider}. */\nexport type DetentItem<V extends DetentValue = number> = {\n value: V;\n /** Drawn under the detent. Defaults to `formatLabel(value)`, then `value`. */\n label?: ReactNode;\n /** Spoken form, when the drawn label is not the right thing to say. */\n ariaLabel?: string;\n};\n\n/**\n * Props for {@link DetentSlider}.\n *\n * `items` takes bare values or `DetentItem`s interchangeably — a bare value is\n * a detent with no label of its own.\n *\n * `onChange` fires on every detent the control passes through, including\n * mid-drag: each one is a complete, legal choice, so there is no in-flight\n * value to withhold. `onCommit` fires once the gesture that changed things\n * ends, and is the one to write to history.\n */\nexport type DetentSliderProps<V extends DetentValue = number> = {\n items: readonly (V | DetentItem<V>)[];\n value: V;\n onChange: (value: V, index: number) => void;\n onCommit?: (value: V, index: number) => void;\n formatLabel?: (value: V, index: number) => ReactNode;\n labels?: 'all' | 'ends' | 'none';\n trackHeight?: number;\n ariaLabel?: string;\n className?: string;\n};\n\nfunction normalize<V extends DetentValue>(items: readonly (V | DetentItem<V>)[]): DetentItem<V>[] {\n return items.map(it => (typeof it === 'object' && it !== null ? it : ({ value: it } as DetentItem<V>)));\n}\n\n/**\n * The detent `value` selects. An exact match wins; a number that matches none\n * lands on the nearest one, so a value arriving from a numeric field or an\n * older save renders where it belongs rather than silently reading as the\n * first detent.\n */\nfunction resolveIndex<V extends DetentValue>(items: readonly DetentItem<V>[], value: V): number {\n const exact = items.findIndex(it => it.value === value);\n if (exact !== -1) return exact;\n if (typeof value !== 'number') return 0;\n let best = 0;\n let bestGap = Infinity;\n for (let i = 0; i < items.length; i++) {\n const v = items[i].value;\n if (typeof v !== 'number') continue;\n const gap = Math.abs(v - value);\n if (gap < bestGap) {\n bestGap = gap;\n best = i;\n }\n }\n return best;\n}\n\nfunction plainText(label: ReactNode, fallback: DetentValue): string {\n return typeof label === 'string' || typeof label === 'number' ? String(label) : String(fallback);\n}\n\n/**\n * Slider over a fixed list of values: one detent per value, evenly spaced, the\n * thumb resting on one of them.\n *\n * This is the shape to reach for when a numeric option has a small set of\n * allowed values along a line — playback rate, zoom step, stroke weight — in\n * place of a dropdown, which hides the ordering and the extent of the range\n * behind a click.\n *\n * The track addresses the *index* of `items`, not the value, which is what\n * makes the detents evenly spaced no matter how the values are distributed:\n * a geometric rate list (0.25/0.5/1/2/4) laid out linearly would crowd four\n * of its five detents into the first fifth of the track and leave the most\n * used one nearly unhittable. Since the index is meaningless to a screen\n * reader, the value is published as `aria-valuetext`.\n */\nexport function DetentSlider<V extends DetentValue = number>(props: DetentSliderProps<V>): ReactElement {\n const { value, onChange, onCommit, formatLabel, ariaLabel, className } = props;\n const items = normalize(props.items);\n const labelMode = props.labels ?? 'all';\n const index = resolveIndex(items, value);\n const lastIndex = Math.max(0, items.length - 1);\n\n const labelOf = (item: DetentItem<V>, i: number): ReactNode =>\n item.label ?? formatLabel?.(item.value, i) ?? String(item.value);\n\n // Deduped separately: `live` suppresses the repeat reports a drag produces\n // while the pointer crosses one detent, `changed` keeps a press that chose\n // nothing from landing a no-op entry in the consumer's history.\n const liveRef = useRef(index);\n const changedRef = useRef(false);\n useEffect(() => {\n liveRef.current = index;\n }, [index]);\n\n const at = (raw: number): number => Math.max(0, Math.min(lastIndex, Math.round(raw)));\n\n const handleInput = (next: Thumb[]) => {\n const i = at(next[0].value);\n if (i === liveRef.current) return;\n liveRef.current = i;\n changedRef.current = true;\n onChange(items[i].value, i);\n };\n\n const handleCommit = (next: Thumb[]) => {\n if (!changedRef.current) return;\n changedRef.current = false;\n const i = at(next[0].value);\n onCommit?.(items[i].value, i);\n };\n\n const current = items[index];\n if (!current) return <div className={className ? `${s.root} ${className}` : s.root} />;\n\n const thumbs: Thumb[] = [\n { value: index, valueText: current.ariaLabel ?? plainText(labelOf(current, index), current.value) },\n ];\n\n const shown =\n labelMode === 'ends'\n ? [...new Set([0, lastIndex])]\n : items.map((_, i) => i);\n\n return (\n <div className={className ? `${s.root} ${className}` : s.root}>\n <Slider\n className={s.slider}\n min={0}\n max={lastIndex}\n step={1}\n stops={items.map((_, i) => i)}\n trackClick=\"move-nearest\"\n trackHeight={props.trackHeight ?? 8}\n ariaLabel={ariaLabel}\n thumbs={thumbs}\n onInput={handleInput}\n onChange={handleCommit}\n />\n {labelMode !== 'none' && (\n <div className={s.labels} data-detent-labels aria-hidden=\"true\">\n {shown.map(i => (\n <span\n key={items[i].value}\n className={s.label}\n data-detent-label\n data-index={i}\n data-selected={i === index ? 'true' : undefined}\n data-edge={i === 0 ? 'start' : i === lastIndex ? 'end' : undefined}\n style={{ left: `${(lastIndex === 0 ? 0 : i / lastIndex) * 100}%` }}\n >\n {labelOf(items[i], i)}\n </span>\n ))}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;ACwCA,SAAS,EAAiC,GAAwD;AAChG,QAAO,EAAM,KAAI,MAAO,OAAO,KAAO,YAAY,IAAc,IAAM,EAAE,OAAO,GAAI,CAAoB;;AASzG,SAAS,EAAoC,GAAiC,GAAkB;CAC9F,IAAM,IAAQ,EAAM,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AM,GAAG,OAAO,EAAE;IAGzB,IAAU,EAAM;AACtB,KAAI,CAAC,EAAS,QAAO,kBAAC,OAAD,EAAK,WAAW,IAAY,GAAG,EAAE,KAAK,GAAG,MAAc,EAAE,MAAQ,CAAA;CAEtF,IAAM,IAAkB,CACtB;EAAE,OAAO;EAAO,WAAW,EAAQ,aAAa,EAAU,EAAQ,GAAS,EAAM,EAAE,EAAQ,MAAM;EAAE,CACpG,EAEK,IACJ,MAAc,SACV,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAU,CAAC,CAAC,GAC5B,EAAM,KAAK,GAAG,MAAM,EAAE;AAE5B,QACE,kBAAC,OAAD;EAAK,WAAW,IAAY,GAAG,EAAE,KAAK,GAAG,MAAc,EAAE;YAAzD,CACE,kBAAC,GAAD;GACE,WAAW,EAAE;GACb,KAAK;GACL,KAAK;GACL,MAAM;GACN,OAAO,EAAM,KAAK,GAAG,MAAM,EAAE;GAC7B,YAAW;GACX,aAAa,EAAM,eAAe;GACvB;GACH;GACR,SAAS;GACT,UAAU;GACV,CAAA,EACD,MAAc,UACb,kBAAC,OAAD;GAAK,WAAW,EAAE;GAAQ,sBAAA;GAAmB,eAAY;aACtD,EAAM,KAAI,MACT,kBAAC,QAAD;IAEE,WAAW,EAAE;IACb,qBAAA;IACA,cAAY;IACZ,iBAAe,MAAM,IAAQ,SAAS,KAAA;IACtC,aAAW,MAAM,IAAI,UAAU,MAAM,IAAY,QAAQ,KAAA;IACzD,OAAO,EAAE,MAAM,IAAI,MAAc,IAAI,IAAI,IAAI,KAAa,IAAI,IAAI;cAEjE,EAAQ,EAAM,IAAI,EAAE;IAChB,EATA,EAAM,GAAG,MAST,CACP;GACE,CAAA,CAEJ"}
@@ -1,6 +1,6 @@
1
- import { t as e } from "./Slider-Bk_G5sSW.js";
1
+ import { t as e } from "./Slider-Bs-KSYgQ.js";
2
2
  import { t } from "./ToggleBar-Bxwv6xvj.js";
3
- import { t as n } from "./ColorField-D0OxUlvu.js";
3
+ import { t as n } from "./ColorField-C20aRvCg.js";
4
4
  import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
5
5
  import { fillInPoseFrame as o, fillToBoundsFrame as s, gradientGeometry as c, isGradientFill as l, sampleGradientStops as u, useActionsRegistry as d, useHandleDrag as f, useNodeOverlayFrame as p, withGradientKind as m } from "@weasel-js/core";
6
6
  import { useCallback as h, useRef as g } from "react";
@@ -307,4 +307,4 @@ function N(e) {
307
307
  //#endregion
308
308
  export { v as i, w as n, S as r, j as t };
309
309
 
310
- //# sourceMappingURL=GradientEditor-C5NVILLk.js.map
310
+ //# sourceMappingURL=GradientEditor-BLpAtMDK.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GradientEditor-C5NVILLk.js","names":[],"sources":["../../src/paintGradientTrack.tsx","../../src/components/GradientEditor/GradientEditor.module.css","../../src/components/GradientEditor/GradientEditor.tsx","../../src/components/GradientEditor/GradientHandles.module.css","../../src/components/GradientEditor/GradientHandles.tsx","../../src/components/GradientEditor/SceneGradientHandles.tsx"],"sourcesContent":["import type { ReactNode, CSSProperties } from 'react';\nimport type { TrackCtx } from './components/Slider';\n\n/**\n * Options for {@link paintGradientTrack}.\n *\n * `gradient` maps a normalized position along the track (0 to 1) to a CSS\n * color; `samples` is how many stops the resulting linear-gradient uses.\n * `activeRange`, given in the slider's own value units, keeps that span at\n * full strength and dims + hatches the rest.\n */\nexport type GradientTrackOpts = {\n gradient: (t: number) => string;\n samples?: number;\n activeRange?: [number, number];\n hatch?: {\n angleDeg?: number;\n stripe?: number;\n gap?: number;\n dim?: number;\n };\n};\n\nconst DEFAULT_HATCH = { angleDeg: 135, stripe: 2, gap: 4, dim: 75 };\n\n/**\n * Builds a `Slider` `renderTrack` function that paints the track as a\n * sampled color gradient, optionally dimming and hatching the portions\n * outside an active range.\n */\nexport function paintGradientTrack(opts: GradientTrackOpts): (ctx: TrackCtx) => ReactNode {\n const { gradient, samples = 16, activeRange, hatch } = opts;\n\n return (ctx: TrackCtx) => {\n const stops: string[] = [];\n for (let i = 0; i <= samples; i++) {\n const t = i / samples;\n stops.push(`${gradient(t)} ${(t * 100).toFixed(1)}%`);\n }\n const baseGradient = `linear-gradient(to right, ${stops.join(', ')})`;\n\n const layers: string[] = [];\n if (activeRange) {\n const lowPct = ctx.valueToFraction(activeRange[0]) * 100;\n const highPct = ctx.valueToFraction(activeRange[1]) * 100;\n const h = { ...DEFAULT_HATCH, ...hatch };\n const stripe = `repeating-linear-gradient(${h.angleDeg}deg, transparent 0 ${h.stripe}px, var(--wzl-surface) ${h.stripe}px ${h.stripe + h.gap}px)`;\n const dimColor = `color-mix(in srgb, var(--wzl-surface) ${h.dim}%, transparent)`;\n const dimOverlay = `linear-gradient(${dimColor}, ${dimColor})`;\n\n if (lowPct > 0) {\n layers.push(`${dimOverlay} left 0 / ${lowPct.toFixed(2)}% 100% no-repeat`);\n layers.push(`${stripe} left 0 / ${lowPct.toFixed(2)}% 100% no-repeat`);\n }\n if (highPct < 100) {\n const wR = (100 - highPct).toFixed(2);\n layers.push(`${dimOverlay} right 0 / ${wR}% 100% no-repeat`);\n layers.push(`${stripe} right 0 / ${wR}% 100% no-repeat`);\n }\n }\n layers.push(baseGradient);\n\n const style: CSSProperties = {\n position: 'absolute',\n inset: 0,\n background: layers.join(', '),\n };\n return <div style={style} />;\n };\n}\n",".root {\n display: flex;\n flex-direction: column;\n gap: 8px;\n min-inline-size: 0;\n}\n\n.swatches {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n}\n\n/* Each stop's opacity slider would otherwise stretch the row to a width no\n * properties panel has; the chip stays legible, the slider yields. */\n.swatch {\n flex: 0 1 auto;\n min-inline-size: 0;\n}\n","import { useCallback, type ReactElement } from 'react';\nimport {\n sampleGradientStops,\n withGradientKind,\n type GradStop,\n type GradientFill,\n type GradientKind,\n} from '@weasel-js/core';\nimport { Slider, type Thumb } from '../Slider';\nimport { ColorField } from '../ColorField';\nimport { ToggleBar, type ToggleBarItem } from '../ToggleBar';\nimport { paintGradientTrack } from '../../paintGradientTrack';\nimport s from './GradientEditor.module.css';\n\nconst KINDS: readonly ToggleBarItem<GradientKind>[] = [\n { value: 'linear-gradient', label: 'Linear' },\n { value: 'radial-gradient', label: 'Radial' },\n { value: 'conic-gradient', label: 'Conic' },\n];\n\n/** Fewer than two stops is not a gradient any renderer can ramp between. */\nconst MIN_STOPS = 2;\n\n/**\n * Props for {@link GradientEditor}. `onInput` fires throughout a gesture and\n * `onChange` once at its end.\n */\nexport interface GradientEditorProps {\n /** The gradient being edited. */\n value: GradientFill;\n /**\n * Live value during a gesture — a stop drag, a color-picker scrub. Wire\n * it for preview; it fires many times per gesture and must not be\n * written to history.\n */\n onInput?: (next: GradientFill) => void;\n /** Committed value: one call per completed gesture. Pair with an\n * undoable write. */\n onChange: (next: GradientFill) => void;\n /** Show the linear / radial / conic switch. Default true; turn it off\n * when the surrounding UI already owns the kind. */\n kindSwitch?: boolean;\n className?: string;\n}\n\ntype StopThumb = Thumb & { color: string };\n\n/**\n * Editor for a gradient's kind and stop list.\n *\n * Geometry (`from`/`to`, `center`, `radius`, `angle`) is deliberately not\n * edited here — on a canvas that belongs on the artwork, via\n * `<GradientHandles>`. This component owns the parts with no spatial\n * meaning, so it composes into a properties panel at any width.\n *\n * Stops are addressed by their position in `value.stops`, which is never\n * reordered — dragging one stop past another leaves both indices alone, so\n * a drag can cross a neighbour without the two swapping under the pointer.\n * Rendering sorts a copy.\n */\nexport function GradientEditor(props: GradientEditorProps): ReactElement {\n const { value, onInput, onChange, kindSwitch = true, className } = props;\n const stops = value.stops;\n\n const withStops = useCallback(\n (next: GradStop[]): GradientFill => ({ ...value, stops: next }),\n [value],\n );\n\n const thumbs: StopThumb[] = stops.map((stop) => ({ value: stop.offset, color: stop.color }));\n\n const applyThumbs = (next: StopThumb[]): GradStop[] =>\n next.map((t) => ({ offset: t.value, color: t.color }));\n\n const setStopColor = (index: number, color: string): GradStop[] =>\n stops.map((stop, i) => (i === index ? { ...stop, color } : stop));\n\n // Sorted view for the swatch row, carrying each stop's real index so a\n // recolor writes back to the right entry.\n const ordered = stops\n .map((stop, index) => ({ stop, index }))\n .sort((a, b) => a.stop.offset - b.stop.offset);\n\n return (\n <div className={[s.root, className].filter(Boolean).join(' ')}>\n {kindSwitch && (\n <ToggleBar<GradientKind>\n items={KINDS}\n value={value.fill}\n size=\"sm\"\n ariaLabel=\"Gradient kind\"\n onChange={(kind) => kind && onChange(withGradientKind(value, kind))}\n />\n )}\n\n <Slider<StopThumb>\n min={0}\n max={1}\n step={0.005}\n constraint=\"free\"\n thumbs={thumbs}\n ariaLabel=\"Gradient stops\"\n readoutPlacement=\"none\"\n onInput={(next) => onInput?.(withStops(applyThumbs(next)))}\n onChange={(next) => onChange(withStops(applyThumbs(next)))}\n onAddThumb={(at) => ({ value: at, color: sampleGradientStops(stops, at) })}\n onRemoveThumb={() => stops.length > MIN_STOPS}\n renderTrack={paintGradientTrack({\n gradient: (t) => sampleGradientStops(stops, t),\n samples: 32,\n })}\n />\n\n <div className={s.swatches}>\n {ordered.map(({ stop, index }) => (\n <ColorField\n key={index}\n value={stop.color}\n alpha\n aria-label={`Stop ${index + 1} at ${Math.round(stop.offset * 100)}%`}\n className={s.swatch}\n onInput={(hex) => onInput?.(withStops(setStopColor(index, hex)))}\n onChange={(hex) => onChange(withStops(setStopColor(index, hex)))}\n />\n ))}\n </div>\n </div>\n );\n}\n","/* The overlay covers the canvas but must not intercept tool input; only the\n * handles opt back into hit-testing. */\n.overlay {\n position: absolute;\n inset: 0;\n pointer-events: none;\n}\n\n/* These sit over artwork of unknown color, not over the app's own surface,\n * so they are deliberately not themed: a themed handle disappears against\n * whatever the user painted underneath. White-on-dark reads on anything,\n * which is why every editor draws handles this way. */\n.guide {\n fill: none;\n stroke: #ffffff;\n stroke-opacity: 0.7;\n stroke-dasharray: 4 4;\n paint-order: stroke;\n}\n\n.handle {\n fill: #ffffff;\n stroke: #222222;\n stroke-width: 2;\n cursor: grab;\n pointer-events: auto;\n}\n\n.handle:active {\n cursor: grabbing;\n}\n\n.handle:focus-visible {\n outline: 2px solid var(--wzl-accent, #4a9eff);\n outline-offset: 2px;\n}\n","import { useRef, type KeyboardEvent as ReactKeyboardEvent, type ReactElement, type ReactNode } from 'react';\nimport { useHandleDrag, gradientGeometry, type GradientFill } from '@weasel-js/core';\nimport s from './GradientHandles.module.css';\n\n/** Structural, and deliberately not exported — `Plot2D` and `CurveEditor`\n * each publish their own `Point`, and a third would only be ambiguous at\n * the package barrel. Consumers pass any `{ x, y }`. */\ninterface Point {\n x: number;\n y: number;\n}\n\n/**\n * Props for {@link GradientHandles}. `onInput` fires throughout a drag and\n * `onChange` once at its end.\n */\nexport interface GradientHandlesProps {\n /**\n * The gradient whose geometry these handles move, in a **resolved,\n * isotropic** frame — one where `radius` is a length in the same units as\n * `center.x` and a right angle is a right angle.\n *\n * A `units: 'bounds'` gradient is not such a frame: `x` and `y` are\n * fractions of two different lengths, so a circle there is an ellipse on\n * screen and polar math silently mixes scales. Resolve it first with\n * `fillInPoseFrame(fill, box)` and convert edits back with\n * `fillToBoundsFrame(next, box)`.\n */\n value: GradientFill;\n /**\n * Gradient space → overlay pixels. For a `units: 'local'` gradient this\n * is the node's local-to-screen transform; for `'world'`, the view.\n */\n toScreen: (p: Point) => Point;\n /** Overlay pixels → gradient space. Must invert `toScreen`. */\n toLocal: (p: Point) => Point;\n /** Live during a drag — wire for preview, do not write to history. */\n onInput?: (next: GradientFill) => void;\n /** Committed at drag end: one call per gesture. */\n onChange: (next: GradientFill) => void;\n /** Overlay size in CSS pixels. */\n width: number;\n height: number;\n className?: string;\n}\n\n/**\n * Direct-manipulation handles for a gradient's geometry, drawn as an SVG\n * overlay above a canvas: endpoints for linear, center and radius for\n * radial, center and angle arm for conic.\n *\n * Positioning is entirely the consumer's `toScreen` / `toLocal` — this\n * component never sees a view or a scene node, so the same handles serve a\n * node-local gradient, a world-space one, and a plain unzoomed preview.\n *\n * The overlay ignores pointer events except on the handles themselves, so\n * it can sit over live canvas content without swallowing tool input.\n */\nexport function GradientHandles(props: GradientHandlesProps): ReactElement {\n const { value, toScreen, toLocal, onInput, onChange, width, height, className } = props;\n\n return (\n <svg\n className={[s.overlay, className].filter(Boolean).join(' ')}\n width={width}\n height={height}\n >\n {renderForKind(value, toScreen, toLocal, onInput, onChange)}\n </svg>\n );\n}\n\nfunction renderForKind(\n value: GradientFill,\n toScreen: (p: Point) => Point,\n toLocal: (p: Point) => Point,\n onInput: ((next: GradientFill) => void) | undefined,\n onChange: (next: GradientFill) => void,\n): ReactNode {\n const emit = (next: GradientFill, phase: 'input' | 'commit'): void => {\n if (phase === 'input') onInput?.(next);\n else onChange(next);\n };\n\n if (value.fill === 'linear-gradient') {\n const from = toScreen(value.from);\n const to = toScreen(value.to);\n return (\n <>\n <Guide x1={from.x} y1={from.y} x2={to.x} y2={to.y} />\n <DragPoint\n at={from}\n label=\"Gradient start\"\n onDrag={(p, phase) => emit({ ...value, from: toLocal(p) }, phase)}\n />\n <DragPoint\n at={to}\n label=\"Gradient end\"\n onDrag={(p, phase) => emit({ ...value, to: toLocal(p) }, phase)}\n />\n </>\n );\n }\n\n if (value.fill === 'radial-gradient') {\n const center = toScreen(value.center);\n // The radius handle rides the +x axis of gradient space, so it stays on\n // the drawn circle under a rotated or anisotropic transform.\n const edge = toScreen({ x: value.center.x + value.radius, y: value.center.y });\n const screenRadius = Math.hypot(edge.x - center.x, edge.y - center.y);\n return (\n <>\n <circle className={s.guide} cx={center.x} cy={center.y} r={screenRadius} />\n <DragPoint\n at={center}\n label=\"Gradient center\"\n onDrag={(p, phase) => emit({ ...value, center: toLocal(p) }, phase)}\n />\n <DragPoint\n at={edge}\n label=\"Gradient radius\"\n onDrag={(p, phase) => {\n const local = toLocal(p);\n const radius = Math.hypot(local.x - value.center.x, local.y - value.center.y);\n emit({ ...value, radius: Math.max(MIN_RADIUS, radius) }, phase);\n }}\n />\n </>\n );\n }\n\n const center = toScreen(value.center);\n const { radius } = gradientGeometry(value);\n const tip = toScreen({\n x: value.center.x + Math.cos(value.angle) * radius,\n y: value.center.y + Math.sin(value.angle) * radius,\n });\n return (\n <>\n <Guide x1={center.x} y1={center.y} x2={tip.x} y2={tip.y} />\n <DragPoint\n at={center}\n label=\"Gradient center\"\n onDrag={(p, phase) => emit({ ...value, center: toLocal(p) }, phase)}\n />\n <DragPoint\n at={tip}\n label=\"Gradient angle\"\n onDrag={(p, phase) => {\n const local = toLocal(p);\n const angle = Math.atan2(local.y - value.center.y, local.x - value.center.x);\n emit({ ...value, angle }, phase);\n }}\n />\n </>\n );\n}\n\n/** A radius of zero divides by zero in the shader's `t`; keep it off the floor. */\nconst MIN_RADIUS = 1;\n\nfunction Guide(props: { x1: number; y1: number; x2: number; y2: number }): ReactElement {\n return <line className={s.guide} {...props} />;\n}\n\nfunction DragPoint({\n at,\n label,\n onDrag,\n}: {\n at: Point;\n label: string;\n onDrag: (p: Point, phase: 'input' | 'commit') => void;\n}): ReactElement {\n const start = useRef<Point>(at);\n const drag = useHandleDrag<SVGCircleElement>({\n onStart: () => { start.current = at; },\n onMove: (p) => { onDrag(p, 'input'); },\n onEnd: ({ point, moved }) => {\n // A press that never moved is not an edit and must not write anything.\n if (moved) onDrag(point, 'commit');\n },\n // An abandoned gesture is not an edit either — put the live preview back\n // where it started rather than committing where it was left.\n onCancel: () => { onDrag(start.current, 'input'); },\n });\n const onKeyDown = (e: ReactKeyboardEvent<SVGCircleElement>): void => {\n const amount = e.shiftKey ? KEY_STEP * 10 : KEY_STEP;\n let dx = 0;\n let dy = 0;\n if (e.key === 'ArrowLeft') dx = -amount;\n else if (e.key === 'ArrowRight') dx = amount;\n else if (e.key === 'ArrowUp') dy = -amount;\n else if (e.key === 'ArrowDown') dy = amount;\n else return;\n e.preventDefault();\n const next = { x: at.x + dx, y: at.y + dy };\n onDrag(next, 'input');\n onDrag(next, 'commit');\n };\n return (\n <circle\n className={s.handle}\n cx={at.x}\n cy={at.y}\n r={HANDLE_RADIUS}\n // Not `slider`: the handle carries a 2-D position, not one value, so\n // it has no `aria-valuenow` to honor the role's contract with.\n role=\"button\"\n aria-label={label}\n tabIndex={0}\n onKeyDown={onKeyDown}\n {...drag}\n />\n );\n}\n\nconst HANDLE_RADIUS = 7;\n\n/** One arrow-key step, in overlay pixels. */\nconst KEY_STEP = 1;\n","import { useRef, type ReactElement, type RefObject } from 'react';\nimport {\n fillInPoseFrame,\n fillToBoundsFrame,\n isGradientFill,\n useActionsRegistry,\n useNodeOverlayFrame,\n type FillStyle,\n type GradientFill,\n type RectPose,\n type Scene,\n type Stroke,\n type UiOngoingControl,\n type View,\n} from '@weasel-js/core';\nimport { GradientHandles } from './GradientHandles';\n\n/** The paint slots a node carries. Either may hold a gradient, and each has\n * its own action, so the overlay is told which one it is editing. */\nexport type PaintSlot = 'fill' | 'stroke';\n\n/** What `SceneGradientHandles` reads off a node. Every field is optional, so\n * any richer app data shape satisfies it. */\nexport interface PaintedNodeData {\n fill?: FillStyle | null;\n stroke?: Stroke | null;\n}\n\nexport interface SceneGradientHandlesProps<\n TData extends PaintedNodeData,\n TLayer extends string,\n TPose extends RectPose,\n> {\n scene: Scene<TData, TLayer, TPose>;\n /** The element the overlay is positioned in. Must be the canvas's own box,\n * or the handles land somewhere other than the paint. */\n containerRef: RefObject<HTMLElement | null>;\n /** The node whose paint is being edited — usually the lone selected id. */\n nodeId: string | null | undefined;\n /** Which of the node's two paints these handles move. */\n slot: PaintSlot;\n /** Current viewport; a thunk is re-read per projection. See\n * `useNodeOverlayFrame`. */\n view?: View | (() => View);\n className?: string;\n}\n\n/**\n * Scene-aware `GradientHandles`: on-canvas geometry handles for the gradient\n * in one node's `fill` or `stroke`, committed through the `setFill` /\n * `setStroke` actions as a single undo entry per drag.\n *\n * Renders nothing unless the targeted slot holds a gradient. The node stores\n * its gradient in `units: 'bounds'` — fractions of its own box, so the paint\n * survives pan, zoom and resize — which is not a frame polar math can work\n * in; the handles get it resolved onto the box and every edit is normalized\n * back on the way out.\n *\n * `slot` is a prop rather than state the kit keeps: an app that edits fill\n * and stroke separately already knows which one has focus.\n */\nexport function SceneGradientHandles<\n TData extends PaintedNodeData,\n TLayer extends string,\n TPose extends RectPose,\n>(props: SceneGradientHandlesProps<TData, TLayer, TPose>): ReactElement | null {\n const { scene, containerRef, nodeId, slot, view, className } = props;\n const actions = useActionsRegistry();\n const frame = useNodeOverlayFrame(scene, containerRef, nodeId, { view });\n const ctrlRef = useRef<UiOngoingControl | null>(null);\n\n const gradient = frame ? gradientInSlot(paintOf(scene, nodeId, slot)) : null;\n if (!frame || !gradient) return null;\n\n const dispatch = (next: GradientFill, phase: 'input' | 'commit'): void => {\n const paint = fillToBoundsFrame(next, frame.box);\n const id = slot === 'fill' ? 'setFill' : 'setStroke';\n if (!ctrlRef.current) ctrlRef.current = actions?.begin(id, { paint }) ?? null;\n else ctrlRef.current.update({ paint });\n if (phase === 'commit' && ctrlRef.current) {\n ctrlRef.current.end('commit');\n ctrlRef.current = null;\n }\n };\n\n return (\n <GradientHandles\n value={fillInPoseFrame(gradient, frame.box) as GradientFill}\n toScreen={frame.toScreen}\n toLocal={frame.toLocal}\n width={frame.width}\n height={frame.height}\n className={className}\n onInput={(next) => dispatch(next, 'input')}\n onChange={(next) => dispatch(next, 'commit')}\n />\n );\n}\n\nfunction paintOf<TData extends PaintedNodeData, TLayer extends string, TPose extends RectPose>(\n scene: Scene<TData, TLayer, TPose>,\n nodeId: string | null | undefined,\n slot: PaintSlot,\n): FillStyle | null | undefined {\n if (nodeId == null) return undefined;\n const data = (scene.nodes as ReadonlyMap<string, { data: TData }>).get(nodeId)?.data;\n if (!data) return undefined;\n return slot === 'fill' ? data.fill : data.stroke?.paint;\n}\n\nfunction gradientInSlot(paint: FillStyle | null | undefined): GradientFill | null {\n return isGradientFill(paint) ? paint : null;\n}\n"],"mappings":";;;;;;;AAuBA,IAAM,IAAgB;CAAE,UAAU;CAAK,QAAQ;CAAG,KAAK;CAAG,KAAK;CAAI;AAOnE,SAAgB,EAAmB,GAAuD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AQ"}
1
+ {"version":3,"file":"GradientEditor-BLpAtMDK.js","names":[],"sources":["../../src/paintGradientTrack.tsx","../../src/components/GradientEditor/GradientEditor.module.css","../../src/components/GradientEditor/GradientEditor.tsx","../../src/components/GradientEditor/GradientHandles.module.css","../../src/components/GradientEditor/GradientHandles.tsx","../../src/components/GradientEditor/SceneGradientHandles.tsx"],"sourcesContent":["import type { ReactNode, CSSProperties } from 'react';\nimport type { TrackCtx } from './components/Slider';\n\n/**\n * Options for {@link paintGradientTrack}.\n *\n * `gradient` maps a normalized position along the track (0 to 1) to a CSS\n * color; `samples` is how many stops the resulting linear-gradient uses.\n * `activeRange`, given in the slider's own value units, keeps that span at\n * full strength and dims + hatches the rest.\n */\nexport type GradientTrackOpts = {\n gradient: (t: number) => string;\n samples?: number;\n activeRange?: [number, number];\n hatch?: {\n angleDeg?: number;\n stripe?: number;\n gap?: number;\n dim?: number;\n };\n};\n\nconst DEFAULT_HATCH = { angleDeg: 135, stripe: 2, gap: 4, dim: 75 };\n\n/**\n * Builds a `Slider` `renderTrack` function that paints the track as a\n * sampled color gradient, optionally dimming and hatching the portions\n * outside an active range.\n */\nexport function paintGradientTrack(opts: GradientTrackOpts): (ctx: TrackCtx) => ReactNode {\n const { gradient, samples = 16, activeRange, hatch } = opts;\n\n return (ctx: TrackCtx) => {\n const stops: string[] = [];\n for (let i = 0; i <= samples; i++) {\n const t = i / samples;\n stops.push(`${gradient(t)} ${(t * 100).toFixed(1)}%`);\n }\n const baseGradient = `linear-gradient(to right, ${stops.join(', ')})`;\n\n const layers: string[] = [];\n if (activeRange) {\n const lowPct = ctx.valueToFraction(activeRange[0]) * 100;\n const highPct = ctx.valueToFraction(activeRange[1]) * 100;\n const h = { ...DEFAULT_HATCH, ...hatch };\n const stripe = `repeating-linear-gradient(${h.angleDeg}deg, transparent 0 ${h.stripe}px, var(--wzl-surface) ${h.stripe}px ${h.stripe + h.gap}px)`;\n const dimColor = `color-mix(in srgb, var(--wzl-surface) ${h.dim}%, transparent)`;\n const dimOverlay = `linear-gradient(${dimColor}, ${dimColor})`;\n\n if (lowPct > 0) {\n layers.push(`${dimOverlay} left 0 / ${lowPct.toFixed(2)}% 100% no-repeat`);\n layers.push(`${stripe} left 0 / ${lowPct.toFixed(2)}% 100% no-repeat`);\n }\n if (highPct < 100) {\n const wR = (100 - highPct).toFixed(2);\n layers.push(`${dimOverlay} right 0 / ${wR}% 100% no-repeat`);\n layers.push(`${stripe} right 0 / ${wR}% 100% no-repeat`);\n }\n }\n layers.push(baseGradient);\n\n const style: CSSProperties = {\n position: 'absolute',\n inset: 0,\n background: layers.join(', '),\n };\n return <div style={style} />;\n };\n}\n",".root {\n display: flex;\n flex-direction: column;\n gap: 8px;\n min-inline-size: 0;\n}\n\n.swatches {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n}\n\n/* Each stop's opacity slider would otherwise stretch the row to a width no\n * properties panel has; the chip stays legible, the slider yields. */\n.swatch {\n flex: 0 1 auto;\n min-inline-size: 0;\n}\n","import { useCallback, type ReactElement } from 'react';\nimport {\n sampleGradientStops,\n withGradientKind,\n type GradStop,\n type GradientFill,\n type GradientKind,\n} from '@weasel-js/core';\nimport { Slider, type Thumb } from '../Slider';\nimport { ColorField } from '../ColorField';\nimport { ToggleBar, type ToggleBarItem } from '../ToggleBar';\nimport { paintGradientTrack } from '../../paintGradientTrack';\nimport s from './GradientEditor.module.css';\n\nconst KINDS: readonly ToggleBarItem<GradientKind>[] = [\n { value: 'linear-gradient', label: 'Linear' },\n { value: 'radial-gradient', label: 'Radial' },\n { value: 'conic-gradient', label: 'Conic' },\n];\n\n/** Fewer than two stops is not a gradient any renderer can ramp between. */\nconst MIN_STOPS = 2;\n\n/**\n * Props for {@link GradientEditor}. `onInput` fires throughout a gesture and\n * `onChange` once at its end.\n */\nexport interface GradientEditorProps {\n /** The gradient being edited. */\n value: GradientFill;\n /**\n * Live value during a gesture — a stop drag, a color-picker scrub. Wire\n * it for preview; it fires many times per gesture and must not be\n * written to history.\n */\n onInput?: (next: GradientFill) => void;\n /** Committed value: one call per completed gesture. Pair with an\n * undoable write. */\n onChange: (next: GradientFill) => void;\n /** Show the linear / radial / conic switch. Default true; turn it off\n * when the surrounding UI already owns the kind. */\n kindSwitch?: boolean;\n className?: string;\n}\n\ntype StopThumb = Thumb & { color: string };\n\n/**\n * Editor for a gradient's kind and stop list.\n *\n * Geometry (`from`/`to`, `center`, `radius`, `angle`) is deliberately not\n * edited here — on a canvas that belongs on the artwork, via\n * `<GradientHandles>`. This component owns the parts with no spatial\n * meaning, so it composes into a properties panel at any width.\n *\n * Stops are addressed by their position in `value.stops`, which is never\n * reordered — dragging one stop past another leaves both indices alone, so\n * a drag can cross a neighbour without the two swapping under the pointer.\n * Rendering sorts a copy.\n */\nexport function GradientEditor(props: GradientEditorProps): ReactElement {\n const { value, onInput, onChange, kindSwitch = true, className } = props;\n const stops = value.stops;\n\n const withStops = useCallback(\n (next: GradStop[]): GradientFill => ({ ...value, stops: next }),\n [value],\n );\n\n const thumbs: StopThumb[] = stops.map((stop) => ({ value: stop.offset, color: stop.color }));\n\n const applyThumbs = (next: StopThumb[]): GradStop[] =>\n next.map((t) => ({ offset: t.value, color: t.color }));\n\n const setStopColor = (index: number, color: string): GradStop[] =>\n stops.map((stop, i) => (i === index ? { ...stop, color } : stop));\n\n // Sorted view for the swatch row, carrying each stop's real index so a\n // recolor writes back to the right entry.\n const ordered = stops\n .map((stop, index) => ({ stop, index }))\n .sort((a, b) => a.stop.offset - b.stop.offset);\n\n return (\n <div className={[s.root, className].filter(Boolean).join(' ')}>\n {kindSwitch && (\n <ToggleBar<GradientKind>\n items={KINDS}\n value={value.fill}\n size=\"sm\"\n ariaLabel=\"Gradient kind\"\n onChange={(kind) => kind && onChange(withGradientKind(value, kind))}\n />\n )}\n\n <Slider<StopThumb>\n min={0}\n max={1}\n step={0.005}\n constraint=\"free\"\n thumbs={thumbs}\n ariaLabel=\"Gradient stops\"\n readoutPlacement=\"none\"\n onInput={(next) => onInput?.(withStops(applyThumbs(next)))}\n onChange={(next) => onChange(withStops(applyThumbs(next)))}\n onAddThumb={(at) => ({ value: at, color: sampleGradientStops(stops, at) })}\n onRemoveThumb={() => stops.length > MIN_STOPS}\n renderTrack={paintGradientTrack({\n gradient: (t) => sampleGradientStops(stops, t),\n samples: 32,\n })}\n />\n\n <div className={s.swatches}>\n {ordered.map(({ stop, index }) => (\n <ColorField\n key={index}\n value={stop.color}\n alpha\n aria-label={`Stop ${index + 1} at ${Math.round(stop.offset * 100)}%`}\n className={s.swatch}\n onInput={(hex) => onInput?.(withStops(setStopColor(index, hex)))}\n onChange={(hex) => onChange(withStops(setStopColor(index, hex)))}\n />\n ))}\n </div>\n </div>\n );\n}\n","/* The overlay covers the canvas but must not intercept tool input; only the\n * handles opt back into hit-testing. */\n.overlay {\n position: absolute;\n inset: 0;\n pointer-events: none;\n}\n\n/* These sit over artwork of unknown color, not over the app's own surface,\n * so they are deliberately not themed: a themed handle disappears against\n * whatever the user painted underneath. White-on-dark reads on anything,\n * which is why every editor draws handles this way. */\n.guide {\n fill: none;\n stroke: #ffffff;\n stroke-opacity: 0.7;\n stroke-dasharray: 4 4;\n paint-order: stroke;\n}\n\n.handle {\n fill: #ffffff;\n stroke: #222222;\n stroke-width: 2;\n cursor: grab;\n pointer-events: auto;\n}\n\n.handle:active {\n cursor: grabbing;\n}\n\n.handle:focus-visible {\n outline: 2px solid var(--wzl-accent, #4a9eff);\n outline-offset: 2px;\n}\n","import { useRef, type KeyboardEvent as ReactKeyboardEvent, type ReactElement, type ReactNode } from 'react';\nimport { useHandleDrag, gradientGeometry, type GradientFill } from '@weasel-js/core';\nimport s from './GradientHandles.module.css';\n\n/** Structural, and deliberately not exported — `Plot2D` and `CurveEditor`\n * each publish their own `Point`, and a third would only be ambiguous at\n * the package barrel. Consumers pass any `{ x, y }`. */\ninterface Point {\n x: number;\n y: number;\n}\n\n/**\n * Props for {@link GradientHandles}. `onInput` fires throughout a drag and\n * `onChange` once at its end.\n */\nexport interface GradientHandlesProps {\n /**\n * The gradient whose geometry these handles move, in a **resolved,\n * isotropic** frame — one where `radius` is a length in the same units as\n * `center.x` and a right angle is a right angle.\n *\n * A `units: 'bounds'` gradient is not such a frame: `x` and `y` are\n * fractions of two different lengths, so a circle there is an ellipse on\n * screen and polar math silently mixes scales. Resolve it first with\n * `fillInPoseFrame(fill, box)` and convert edits back with\n * `fillToBoundsFrame(next, box)`.\n */\n value: GradientFill;\n /**\n * Gradient space → overlay pixels. For a `units: 'local'` gradient this\n * is the node's local-to-screen transform; for `'world'`, the view.\n */\n toScreen: (p: Point) => Point;\n /** Overlay pixels → gradient space. Must invert `toScreen`. */\n toLocal: (p: Point) => Point;\n /** Live during a drag — wire for preview, do not write to history. */\n onInput?: (next: GradientFill) => void;\n /** Committed at drag end: one call per gesture. */\n onChange: (next: GradientFill) => void;\n /** Overlay size in CSS pixels. */\n width: number;\n height: number;\n className?: string;\n}\n\n/**\n * Direct-manipulation handles for a gradient's geometry, drawn as an SVG\n * overlay above a canvas: endpoints for linear, center and radius for\n * radial, center and angle arm for conic.\n *\n * Positioning is entirely the consumer's `toScreen` / `toLocal` — this\n * component never sees a view or a scene node, so the same handles serve a\n * node-local gradient, a world-space one, and a plain unzoomed preview.\n *\n * The overlay ignores pointer events except on the handles themselves, so\n * it can sit over live canvas content without swallowing tool input.\n */\nexport function GradientHandles(props: GradientHandlesProps): ReactElement {\n const { value, toScreen, toLocal, onInput, onChange, width, height, className } = props;\n\n return (\n <svg\n className={[s.overlay, className].filter(Boolean).join(' ')}\n width={width}\n height={height}\n >\n {renderForKind(value, toScreen, toLocal, onInput, onChange)}\n </svg>\n );\n}\n\nfunction renderForKind(\n value: GradientFill,\n toScreen: (p: Point) => Point,\n toLocal: (p: Point) => Point,\n onInput: ((next: GradientFill) => void) | undefined,\n onChange: (next: GradientFill) => void,\n): ReactNode {\n const emit = (next: GradientFill, phase: 'input' | 'commit'): void => {\n if (phase === 'input') onInput?.(next);\n else onChange(next);\n };\n\n if (value.fill === 'linear-gradient') {\n const from = toScreen(value.from);\n const to = toScreen(value.to);\n return (\n <>\n <Guide x1={from.x} y1={from.y} x2={to.x} y2={to.y} />\n <DragPoint\n at={from}\n label=\"Gradient start\"\n onDrag={(p, phase) => emit({ ...value, from: toLocal(p) }, phase)}\n />\n <DragPoint\n at={to}\n label=\"Gradient end\"\n onDrag={(p, phase) => emit({ ...value, to: toLocal(p) }, phase)}\n />\n </>\n );\n }\n\n if (value.fill === 'radial-gradient') {\n const center = toScreen(value.center);\n // The radius handle rides the +x axis of gradient space, so it stays on\n // the drawn circle under a rotated or anisotropic transform.\n const edge = toScreen({ x: value.center.x + value.radius, y: value.center.y });\n const screenRadius = Math.hypot(edge.x - center.x, edge.y - center.y);\n return (\n <>\n <circle className={s.guide} cx={center.x} cy={center.y} r={screenRadius} />\n <DragPoint\n at={center}\n label=\"Gradient center\"\n onDrag={(p, phase) => emit({ ...value, center: toLocal(p) }, phase)}\n />\n <DragPoint\n at={edge}\n label=\"Gradient radius\"\n onDrag={(p, phase) => {\n const local = toLocal(p);\n const radius = Math.hypot(local.x - value.center.x, local.y - value.center.y);\n emit({ ...value, radius: Math.max(MIN_RADIUS, radius) }, phase);\n }}\n />\n </>\n );\n }\n\n const center = toScreen(value.center);\n const { radius } = gradientGeometry(value);\n const tip = toScreen({\n x: value.center.x + Math.cos(value.angle) * radius,\n y: value.center.y + Math.sin(value.angle) * radius,\n });\n return (\n <>\n <Guide x1={center.x} y1={center.y} x2={tip.x} y2={tip.y} />\n <DragPoint\n at={center}\n label=\"Gradient center\"\n onDrag={(p, phase) => emit({ ...value, center: toLocal(p) }, phase)}\n />\n <DragPoint\n at={tip}\n label=\"Gradient angle\"\n onDrag={(p, phase) => {\n const local = toLocal(p);\n const angle = Math.atan2(local.y - value.center.y, local.x - value.center.x);\n emit({ ...value, angle }, phase);\n }}\n />\n </>\n );\n}\n\n/** A radius of zero divides by zero in the shader's `t`; keep it off the floor. */\nconst MIN_RADIUS = 1;\n\nfunction Guide(props: { x1: number; y1: number; x2: number; y2: number }): ReactElement {\n return <line className={s.guide} {...props} />;\n}\n\nfunction DragPoint({\n at,\n label,\n onDrag,\n}: {\n at: Point;\n label: string;\n onDrag: (p: Point, phase: 'input' | 'commit') => void;\n}): ReactElement {\n const start = useRef<Point>(at);\n const drag = useHandleDrag<SVGCircleElement>({\n onStart: () => { start.current = at; },\n onMove: (p) => { onDrag(p, 'input'); },\n onEnd: ({ point, moved }) => {\n // A press that never moved is not an edit and must not write anything.\n if (moved) onDrag(point, 'commit');\n },\n // An abandoned gesture is not an edit either — put the live preview back\n // where it started rather than committing where it was left.\n onCancel: () => { onDrag(start.current, 'input'); },\n });\n const onKeyDown = (e: ReactKeyboardEvent<SVGCircleElement>): void => {\n const amount = e.shiftKey ? KEY_STEP * 10 : KEY_STEP;\n let dx = 0;\n let dy = 0;\n if (e.key === 'ArrowLeft') dx = -amount;\n else if (e.key === 'ArrowRight') dx = amount;\n else if (e.key === 'ArrowUp') dy = -amount;\n else if (e.key === 'ArrowDown') dy = amount;\n else return;\n e.preventDefault();\n const next = { x: at.x + dx, y: at.y + dy };\n onDrag(next, 'input');\n onDrag(next, 'commit');\n };\n return (\n <circle\n className={s.handle}\n cx={at.x}\n cy={at.y}\n r={HANDLE_RADIUS}\n // Not `slider`: the handle carries a 2-D position, not one value, so\n // it has no `aria-valuenow` to honor the role's contract with.\n role=\"button\"\n aria-label={label}\n tabIndex={0}\n onKeyDown={onKeyDown}\n {...drag}\n />\n );\n}\n\nconst HANDLE_RADIUS = 7;\n\n/** One arrow-key step, in overlay pixels. */\nconst KEY_STEP = 1;\n","import { useRef, type ReactElement, type RefObject } from 'react';\nimport {\n fillInPoseFrame,\n fillToBoundsFrame,\n isGradientFill,\n useActionsRegistry,\n useNodeOverlayFrame,\n type FillStyle,\n type GradientFill,\n type RectPose,\n type Scene,\n type Stroke,\n type UiOngoingControl,\n type View,\n} from '@weasel-js/core';\nimport { GradientHandles } from './GradientHandles';\n\n/** The paint slots a node carries. Either may hold a gradient, and each has\n * its own action, so the overlay is told which one it is editing. */\nexport type PaintSlot = 'fill' | 'stroke';\n\n/** What `SceneGradientHandles` reads off a node. Every field is optional, so\n * any richer app data shape satisfies it. */\nexport interface PaintedNodeData {\n fill?: FillStyle | null;\n stroke?: Stroke | null;\n}\n\nexport interface SceneGradientHandlesProps<\n TData extends PaintedNodeData,\n TLayer extends string,\n TPose extends RectPose,\n> {\n scene: Scene<TData, TLayer, TPose>;\n /** The element the overlay is positioned in. Must be the canvas's own box,\n * or the handles land somewhere other than the paint. */\n containerRef: RefObject<HTMLElement | null>;\n /** The node whose paint is being edited — usually the lone selected id. */\n nodeId: string | null | undefined;\n /** Which of the node's two paints these handles move. */\n slot: PaintSlot;\n /** Current viewport; a thunk is re-read per projection. See\n * `useNodeOverlayFrame`. */\n view?: View | (() => View);\n className?: string;\n}\n\n/**\n * Scene-aware `GradientHandles`: on-canvas geometry handles for the gradient\n * in one node's `fill` or `stroke`, committed through the `setFill` /\n * `setStroke` actions as a single undo entry per drag.\n *\n * Renders nothing unless the targeted slot holds a gradient. The node stores\n * its gradient in `units: 'bounds'` — fractions of its own box, so the paint\n * survives pan, zoom and resize — which is not a frame polar math can work\n * in; the handles get it resolved onto the box and every edit is normalized\n * back on the way out.\n *\n * `slot` is a prop rather than state the kit keeps: an app that edits fill\n * and stroke separately already knows which one has focus.\n */\nexport function SceneGradientHandles<\n TData extends PaintedNodeData,\n TLayer extends string,\n TPose extends RectPose,\n>(props: SceneGradientHandlesProps<TData, TLayer, TPose>): ReactElement | null {\n const { scene, containerRef, nodeId, slot, view, className } = props;\n const actions = useActionsRegistry();\n const frame = useNodeOverlayFrame(scene, containerRef, nodeId, { view });\n const ctrlRef = useRef<UiOngoingControl | null>(null);\n\n const gradient = frame ? gradientInSlot(paintOf(scene, nodeId, slot)) : null;\n if (!frame || !gradient) return null;\n\n const dispatch = (next: GradientFill, phase: 'input' | 'commit'): void => {\n const paint = fillToBoundsFrame(next, frame.box);\n const id = slot === 'fill' ? 'setFill' : 'setStroke';\n if (!ctrlRef.current) ctrlRef.current = actions?.begin(id, { paint }) ?? null;\n else ctrlRef.current.update({ paint });\n if (phase === 'commit' && ctrlRef.current) {\n ctrlRef.current.end('commit');\n ctrlRef.current = null;\n }\n };\n\n return (\n <GradientHandles\n value={fillInPoseFrame(gradient, frame.box) as GradientFill}\n toScreen={frame.toScreen}\n toLocal={frame.toLocal}\n width={frame.width}\n height={frame.height}\n className={className}\n onInput={(next) => dispatch(next, 'input')}\n onChange={(next) => dispatch(next, 'commit')}\n />\n );\n}\n\nfunction paintOf<TData extends PaintedNodeData, TLayer extends string, TPose extends RectPose>(\n scene: Scene<TData, TLayer, TPose>,\n nodeId: string | null | undefined,\n slot: PaintSlot,\n): FillStyle | null | undefined {\n if (nodeId == null) return undefined;\n const data = (scene.nodes as ReadonlyMap<string, { data: TData }>).get(nodeId)?.data;\n if (!data) return undefined;\n return slot === 'fill' ? data.fill : data.stroke?.paint;\n}\n\nfunction gradientInSlot(paint: FillStyle | null | undefined): GradientFill | null {\n return isGradientFill(paint) ? paint : null;\n}\n"],"mappings":";;;;;;;AAuBA,IAAM,IAAgB;CAAE,UAAU;CAAK,QAAQ;CAAG,KAAK;CAAG,KAAK;CAAI;AAOnE,SAAgB,EAAmB,GAAuD;CACxF,IAAM,EAAE,aAAU,aAAU,IAAI,gBAAa,aAAU;AAEvD,SAAQ,MAAkB;EACxB,IAAM,IAAkB,EAAE;AAC1B,OAAK,IAAI,IAAI,GAAG,KAAK,GAAS,KAAK;GACjC,IAAM,IAAI,IAAI;AACd,KAAM,KAAK,GAAG,EAAS,EAAE,CAAC,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC,GAAG;;EAEvD,IAAM,IAAe,6BAA6B,EAAM,KAAK,KAAK,CAAC,IAE7D,IAAmB,EAAE;AAC3B,MAAI,GAAa;GACf,IAAM,IAAS,EAAI,gBAAgB,EAAY,GAAG,GAAG,KAC/C,IAAU,EAAI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AAC,GAAG;AACxE,KAAI,CAAC,KAAS,CAAC,EAAU,QAAO;CAEhC,IAAM,KAAY,GAAoB,MAAoC;EACxE,IAAM,IAAQ,EAAkB,GAAM,EAAM,IAAI,EAC1C,IAAK,MAAS,SAAS,YAAY;AAGzC,EAFK,EAAQ,UACR,EAAQ,QAAQ,OAAO,EAAE,UAAO,CAAC,GADhB,EAAQ,UAAU,GAAS,MAAM,GAAI,EAAE,UAAO,CAAC,IAAI,MAErE,MAAU,YAAY,EAAQ,YAChC,EAAQ,QAAQ,IAAI,SAAS,EAC7B,EAAQ,UAAU;;AAItB,QACE,kBAAC,GAAD;EACE,OAAO,EAAgB,GAAU,EAAM,IAAI;EAC3C,UAAU,EAAM;EAChB,SAAS,EAAM;EACf,OAAO,EAAM;EACb,QAAQ,EAAM;EACH;EACX,UAAU,MAAS,EAAS,GAAM,QAAQ;EAC1C,WAAW,MAAS,EAAS,GAAM,SAAS;EAC5C,CAAA;;AAIN,SAAS,EACP,GACA,GACA,GAC8B;AAC9B,KAAI,KAAU,KAAM;CACpB,IAAM,IAAQ,EAAM,MAA+C,IAAI,EAAO,EAAE;AAC3E,OACL,QAAO,MAAS,SAAS,EAAK,OAAO,EAAK,QAAQ;;AAGpD,SAAS,EAAe,GAA0D;AAChF,QAAO,EAAe,EAAM,GAAG,IAAQ"}
@@ -1,4 +1,4 @@
1
- import { t as e } from "./range.module-CgURq-Ua.js";
1
+ import { t as e } from "./range.module-CvSfABmu.js";
2
2
  import { jsx as t } from "react/jsx-runtime";
3
3
  import "react";
4
4
  var n = { range: "_range_1on6e_4" };
@@ -26,4 +26,4 @@ function r(r) {
26
26
  //#endregion
27
27
  export { r as t };
28
28
 
29
- //# sourceMappingURL=InlineRange-50ulExCL.js.map
29
+ //# sourceMappingURL=InlineRange-CcfzY80y.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InlineRange-50ulExCL.js","names":[],"sources":["../../src/components/InlineRange/InlineRange.module.css","../../src/components/InlineRange/InlineRange.tsx"],"sourcesContent":["/* Track and thumb come from the shared range skin. What is local to\n InlineRange is the filled-to-N% paint, which no other surface has:\n `--slider-fill` carries the value, since no static rule expresses it. */\n.range {\n flex: 1;\n --wzl-range-bg: linear-gradient(\n to right,\n var(--wzl-accent) 0 var(--slider-fill, 0%),\n var(--wzl-border-strong) var(--slider-fill, 0%) 100%\n );\n --wzl-range-box-h: var(--wzl-slider-track-h);\n /* The gradient above IS the track, so the shared track paint must not land on top of it. */\n --wzl-range-track-bg: transparent;\n border-radius: var(--wzl-radius-pill);\n}\n","import { type CSSProperties, type InputHTMLAttributes, type ReactElement } from 'react';\nimport shared from '../range.module.css';\nimport s from './InlineRange.module.css';\n\n/** Props for {@link InlineRange} — a range input's, with `value` required. */\nexport type InlineRangeProps = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'type' | 'value' | 'min' | 'max'\n> & {\n value: number;\n min?: number;\n max?: number;\n};\n\n/**\n * Compact range input for a property row: one track, no label, no output.\n *\n * Distinct from the kit's other two — `Slider` is shaped for canvas scrubbing,\n * and `RangeSlider` is a full-width labelled form control on React Aria. This\n * one exists to sit inline beside a swatch or a readout, and to own the track\n * painting both of those surfaces need.\n */\nexport function InlineRange(props: InlineRangeProps): ReactElement {\n const { value, min = 0, max = 100, className, style, ...rest } = props;\n const span = max - min;\n const filled = span > 0 ? ((Math.min(Math.max(value, min), max) - min) / span) * 100 : 0;\n return (\n <input\n {...rest}\n type=\"range\"\n value={value}\n min={min}\n max={max}\n className={[shared.range, s.range, className].filter(Boolean).join(' ')}\n style={{ ['--slider-fill' as string]: `${filled}%`, ...style } as CSSProperties}\n />\n );\n}\n"],"mappings":";;;;;;ACsBA,SAAgB,EAAY,GAAuC;CACjE,IAAM,EAAE,UAAO,SAAM,GAAG,SAAM,KAAK,cAAW,UAAO,GAAG,MAAS,GAC3D,IAAO,IAAM,GACb,IAAS,IAAO,KAAM,KAAK,IAAI,KAAK,IAAI,GAAO,EAAI,EAAE,EAAI,GAAG,KAAO,IAAQ,MAAM;AACvF,QACE,kBAAC,SAAD;EACE,GAAI;EACJ,MAAK;EACE;EACF;EACA;EACL,WAAW;GAAC,EAAO;GAAO,EAAE;GAAO;GAAU,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI;EACvE,OAAO;GAAG,iBAA4B,GAAG,EAAO;GAAI,GAAG;GAAO;EAC9D,CAAA"}
1
+ {"version":3,"file":"InlineRange-CcfzY80y.js","names":[],"sources":["../../src/components/InlineRange/InlineRange.module.css","../../src/components/InlineRange/InlineRange.tsx"],"sourcesContent":["/* Track and thumb come from the shared range skin. What is local to\n InlineRange is the filled-to-N% paint, which no other surface has:\n `--slider-fill` carries the value, since no static rule expresses it. */\n.range {\n flex: 1;\n --wzl-range-bg: linear-gradient(\n to right,\n var(--wzl-accent) 0 var(--slider-fill, 0%),\n var(--wzl-border-strong) var(--slider-fill, 0%) 100%\n );\n --wzl-range-box-h: var(--wzl-slider-track-h);\n /* The gradient above IS the track, so the shared track paint must not land on top of it. */\n --wzl-range-track-bg: transparent;\n border-radius: var(--wzl-radius-pill);\n}\n","import { type CSSProperties, type InputHTMLAttributes, type ReactElement } from 'react';\nimport shared from '../range.module.css';\nimport s from './InlineRange.module.css';\n\n/** Props for {@link InlineRange} — a range input's, with `value` required. */\nexport type InlineRangeProps = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'type' | 'value' | 'min' | 'max'\n> & {\n value: number;\n min?: number;\n max?: number;\n};\n\n/**\n * Compact range input for a property row: one track, no label, no output.\n *\n * Distinct from the kit's other two — `Slider` is shaped for canvas scrubbing,\n * and `RangeSlider` is a full-width labelled form control on React Aria. This\n * one exists to sit inline beside a swatch or a readout, and to own the track\n * painting both of those surfaces need.\n */\nexport function InlineRange(props: InlineRangeProps): ReactElement {\n const { value, min = 0, max = 100, className, style, ...rest } = props;\n const span = max - min;\n const filled = span > 0 ? ((Math.min(Math.max(value, min), max) - min) / span) * 100 : 0;\n return (\n <input\n {...rest}\n type=\"range\"\n value={value}\n min={min}\n max={max}\n className={[shared.range, s.range, className].filter(Boolean).join(' ')}\n style={{ ['--slider-fill' as string]: `${filled}%`, ...style } as CSSProperties}\n />\n );\n}\n"],"mappings":";;;;;;ACsBA,SAAgB,EAAY,GAAuC;CACjE,IAAM,EAAE,UAAO,SAAM,GAAG,SAAM,KAAK,cAAW,UAAO,GAAG,MAAS,GAC3D,IAAO,IAAM,GACb,IAAS,IAAO,KAAM,KAAK,IAAI,KAAK,IAAI,GAAO,EAAI,EAAE,EAAI,GAAG,KAAO,IAAQ,MAAM;AACvF,QACE,kBAAC,SAAD;EACE,GAAI;EACJ,MAAK;EACE;EACF;EACA;EACL,WAAW;GAAC,EAAO;GAAO,EAAE;GAAO;GAAU,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI;EACvE,OAAO;GAAG,iBAA4B,GAAG,EAAO;GAAI,GAAG;GAAO;EAC9D,CAAA"}
@@ -1,7 +1,7 @@
1
1
  import { n as e, t } from "./Icon-DBXtBB1f.js";
2
2
  import { t as n } from "./ToggleBar-Bxwv6xvj.js";
3
- import { t as r } from "./ColorField-D0OxUlvu.js";
4
- import { r as i } from "./GradientEditor-C5NVILLk.js";
3
+ import { t as r } from "./ColorField-C20aRvCg.js";
4
+ import { r as i } from "./GradientEditor-BLpAtMDK.js";
5
5
  import { t as a } from "./PatternPicker-Ba22Bf4L.js";
6
6
  import { jsx as o, jsxs as s } from "react/jsx-runtime";
7
7
  import { getPaintKind as c, listPaintKinds as l, withGradientKind as u } from "@weasel-js/core";
@@ -115,4 +115,4 @@ function b(b) {
115
115
  //#endregion
116
116
  export { b as t };
117
117
 
118
- //# sourceMappingURL=PaintInput-67U-COE4.js.map
118
+ //# sourceMappingURL=PaintInput-B7AScmHN.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PaintInput-67U-COE4.js","names":[],"sources":["../../src/components/PaintInput/PaintInput.module.css","../../src/components/PaintInput/PaintInput.tsx"],"sourcesContent":["/* Kind switch stacked over whichever paint body it selects. */\n.root {\n display: flex;\n flex-direction: column;\n gap: 6px;\n min-inline-size: 0;\n}\n\n/* A value is in effect but nobody chose it. Never louder than mixed. */\n.unset {\n opacity: 0.55;\n}\n","import { useCallback, useRef, type ReactElement } from 'react';\nimport {\n getPaintKind,\n listPaintKinds,\n withGradientKind,\n type FillStyle,\n type GradientFill,\n type GradientKind,\n type PaintKind,\n} from '@weasel-js/core';\nimport { Icon } from '../../icons/Icon';\nimport { ICON_PATHS, type IconName } from '../../icons/paths';\nimport { ColorField } from '../ColorField';\nimport { GradientEditor } from '../GradientEditor';\nimport { PatternPicker, type PatternFill } from '../PatternPicker';\nimport { ToggleBar, type ToggleBarItem } from '../ToggleBar';\nimport s from './PaintInput.module.css';\n\n/** What a kind with no color of its own seeds from. */\nconst FALLBACK_COLOR = '#000000ff';\n\n/** The bar's answer for \"no paint at all\". Not a registered kind — absence\n * has no seed, no color and nothing to render — so it is this control's own\n * segment rather than a registry entry. */\nconst NONE = 'none';\n\nconst GRADIENT_KINDS: readonly string[] = [\n 'linear-gradient',\n 'radial-gradient',\n 'conic-gradient',\n];\n\nfunction isGradient(paint: FillStyle | undefined): paint is GradientFill {\n return paint !== undefined && GRADIENT_KINDS.includes(paint.fill ?? '');\n}\n\nfunction isPattern(paint: FillStyle | undefined): paint is PatternFill {\n return paint?.fill === 'pattern';\n}\n\n/** A paint's own discriminant. The solid member leaves `fill` off, and an\n * explicit `null` is the absence of paint rather than an unknown one. */\nfunction kindOf(paint: FillStyle | null | undefined): PaintKind | null {\n if (paint === null) return NONE;\n if (paint === undefined) return null;\n return paint.fill ?? 'solid';\n}\n\n/** Props for {@link PaintInput}. `onInput` fires throughout a gesture and\n * `onChange` once at its end. */\nexport interface PaintInputProps {\n /** The paint being edited. `null` is an explicit \"no paint\"; `undefined`\n * is no value to show. */\n value: FillStyle | null | undefined;\n /** Indeterminate presentation: no kind lit, and the body withheld because\n * there is no single paint to show. */\n mixed?: boolean;\n /** Dim the control — a value is in effect but was never chosen. */\n unset?: boolean;\n /** Restrict the kind bar. Default: every registered kind. */\n kinds?: readonly PaintKind[];\n /** Offer \"None\". Default `true` — the bar answers \"what kind of paint is\n * this?\" and no-paint is one of the answers. Turn it off where the slot\n * cannot express absence. */\n allowNone?: boolean;\n onInput?: (next: FillStyle | null) => void;\n onChange: (next: FillStyle | null) => void;\n /** Names the paint this control edits — `Fill`, `Color`. Carried by the\n * solid body's swatch, which is the part with a value to announce. */\n 'aria-label'?: string;\n className?: string;\n}\n\n/**\n * Editor for a whole `FillStyle` — a kind bar over whichever body that kind\n * wants.\n *\n * The bar is driven by the paint-kind registry rather than a fixed list, so a\n * consumer's registered kind appears in it and renders that entry's `Editor`.\n * The five built-in kinds keep their branch here: their editors live in this\n * package and `@weasel-js/core`, which owns the registry, cannot import it.\n *\n * Geometry is deliberately absent — on a canvas it belongs on the artwork,\n * via `<SceneGradientHandles>`.\n */\nexport function PaintInput(props: PaintInputProps): ReactElement {\n const {\n value, mixed = false, unset = false, kinds, allowNone = true,\n onInput, onChange, className,\n } = props;\n const ariaLabel = props['aria-label'];\n\n // Per-kind memory, so linear → solid → linear comes back with its stops.\n // A ref, not state: it must not survive the control being pointed at a\n // different selection, and nothing renders off it directly.\n const remembered = useRef(new Map<PaintKind, FillStyle>());\n\n const active = mixed ? null : kindOf(value);\n if (value != null && active !== null) remembered.current.set(active, value);\n\n const entries = listPaintKinds().filter(\n (entry) => kinds === undefined || kinds.includes(entry.id),\n );\n const segment = (id: string, label: string, icon: string | undefined): ToggleBarItem<PaintKind> =>\n icon && icon in ICON_PATHS\n // Icon-only: six labelled segments do not fit a property row, and the\n // full label stays the accessible name.\n // 14 to match the panel's other glyph segments. A `sm` bar is 17px tall\n // over 1px of padding, so 15 fills the segment box edge to edge.\n ? { value: id, label: <Icon name={icon as IconName} size={14} />, ariaLabel: label }\n : { value: id, label };\n\n const items: readonly ToggleBarItem<PaintKind>[] = [\n ...(allowNone ? [segment(NONE, 'None', 'paintNone')] : []),\n ...entries.map((entry) => segment(entry.id, entry.label, entry.icon)),\n ];\n\n /** The color a switch seeds from: whatever the current paint shows. */\n const currentColor = useCallback((): string => {\n if (value == null) return FALLBACK_COLOR;\n return getPaintKind(kindOf(value) ?? 'solid')?.colorOf(value) ?? FALLBACK_COLOR;\n }, [value]);\n\n const switchKind = (kind: PaintKind): void => {\n if (kind === active) return;\n if (kind === NONE) {\n onChange(null);\n return;\n }\n const seen = remembered.current.get(kind);\n if (seen !== undefined) {\n onChange(seen);\n return;\n }\n if (value != null && isGradient(value) && GRADIENT_KINDS.includes(kind)) {\n onChange(withGradientKind(value, kind as GradientKind));\n return;\n }\n const entry = getPaintKind(kind);\n if (entry) onChange(entry.seed(currentColor()));\n };\n\n return (\n <div\n className={[s.root, unset && s.unset, className].filter(Boolean).join(' ')}\n title={unset ? 'Not set' : undefined}\n >\n <ToggleBar<PaintKind>\n items={items}\n value={active}\n size=\"sm\"\n ariaLabel=\"Paint kind\"\n onChange={(kind) => kind && switchKind(kind)}\n />\n {renderBody()}\n </div>\n );\n\n function renderBody(): ReactElement | null {\n if (mixed || value === undefined) {\n return (\n <ColorField\n mixed\n aria-label={ariaLabel}\n onChange={(color) => onChange({ fill: 'solid', color })}\n />\n );\n }\n // Absence has nothing to edit. The lit segment is the whole statement.\n if (value === null) return null;\n // A registered `Editor` wins even for a built-in id: re-registering one is\n // how a consumer replaces a kit control, and the built-in branches below\n // are the fallback for the ids that ship without an entry editor.\n const entry = getPaintKind(kindOf(value) ?? 'solid');\n if (entry?.Editor) {\n const Editor = entry.Editor;\n return <Editor value={value} onInput={onInput} onChange={onChange} />;\n }\n if (isGradient(value)) {\n return (\n <GradientEditor\n value={value}\n kindSwitch={false}\n onInput={onInput}\n onChange={onChange}\n />\n );\n }\n if (isPattern(value)) {\n return <PatternPicker value={value} color={currentColor()} onChange={onChange} />;\n }\n return (\n <ColorField\n value={currentColor()}\n alpha\n aria-label={ariaLabel}\n onInput={(color) => onInput?.({ fill: 'solid', color })}\n onChange={(color) => onChange({ fill: 'sol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AAO,CAAC;GACvD,WAAW,MAAU,EAAS;IAAE,MAAM;IAAS;IAAO,CAAC;GACvD,CAAA"}
1
+ {"version":3,"file":"PaintInput-B7AScmHN.js","names":[],"sources":["../../src/components/PaintInput/PaintInput.module.css","../../src/components/PaintInput/PaintInput.tsx"],"sourcesContent":["/* Kind switch stacked over whichever paint body it selects. */\n.root {\n display: flex;\n flex-direction: column;\n gap: 6px;\n min-inline-size: 0;\n}\n\n/* A value is in effect but nobody chose it. Never louder than mixed. */\n.unset {\n opacity: 0.55;\n}\n","import { useCallback, useRef, type ReactElement } from 'react';\nimport {\n getPaintKind,\n listPaintKinds,\n withGradientKind,\n type FillStyle,\n type GradientFill,\n type GradientKind,\n type PaintKind,\n} from '@weasel-js/core';\nimport { Icon } from '../../icons/Icon';\nimport { ICON_PATHS, type IconName } from '../../icons/paths';\nimport { ColorField } from '../ColorField';\nimport { GradientEditor } from '../GradientEditor';\nimport { PatternPicker, type PatternFill } from '../PatternPicker';\nimport { ToggleBar, type ToggleBarItem } from '../ToggleBar';\nimport s from './PaintInput.module.css';\n\n/** What a kind with no color of its own seeds from. */\nconst FALLBACK_COLOR = '#000000ff';\n\n/** The bar's answer for \"no paint at all\". Not a registered kind — absence\n * has no seed, no color and nothing to render — so it is this control's own\n * segment rather than a registry entry. */\nconst NONE = 'none';\n\nconst GRADIENT_KINDS: readonly string[] = [\n 'linear-gradient',\n 'radial-gradient',\n 'conic-gradient',\n];\n\nfunction isGradient(paint: FillStyle | undefined): paint is GradientFill {\n return paint !== undefined && GRADIENT_KINDS.includes(paint.fill ?? '');\n}\n\nfunction isPattern(paint: FillStyle | undefined): paint is PatternFill {\n return paint?.fill === 'pattern';\n}\n\n/** A paint's own discriminant. The solid member leaves `fill` off, and an\n * explicit `null` is the absence of paint rather than an unknown one. */\nfunction kindOf(paint: FillStyle | null | undefined): PaintKind | null {\n if (paint === null) return NONE;\n if (paint === undefined) return null;\n return paint.fill ?? 'solid';\n}\n\n/** Props for {@link PaintInput}. `onInput` fires throughout a gesture and\n * `onChange` once at its end. */\nexport interface PaintInputProps {\n /** The paint being edited. `null` is an explicit \"no paint\"; `undefined`\n * is no value to show. */\n value: FillStyle | null | undefined;\n /** Indeterminate presentation: no kind lit, and the body withheld because\n * there is no single paint to show. */\n mixed?: boolean;\n /** Dim the control — a value is in effect but was never chosen. */\n unset?: boolean;\n /** Restrict the kind bar. Default: every registered kind. */\n kinds?: readonly PaintKind[];\n /** Offer \"None\". Default `true` — the bar answers \"what kind of paint is\n * this?\" and no-paint is one of the answers. Turn it off where the slot\n * cannot express absence. */\n allowNone?: boolean;\n onInput?: (next: FillStyle | null) => void;\n onChange: (next: FillStyle | null) => void;\n /** Names the paint this control edits — `Fill`, `Color`. Carried by the\n * solid body's swatch, which is the part with a value to announce. */\n 'aria-label'?: string;\n className?: string;\n}\n\n/**\n * Editor for a whole `FillStyle` — a kind bar over whichever body that kind\n * wants.\n *\n * The bar is driven by the paint-kind registry rather than a fixed list, so a\n * consumer's registered kind appears in it and renders that entry's `Editor`.\n * The five built-in kinds keep their branch here: their editors live in this\n * package and `@weasel-js/core`, which owns the registry, cannot import it.\n *\n * Geometry is deliberately absent — on a canvas it belongs on the artwork,\n * via `<SceneGradientHandles>`.\n */\nexport function PaintInput(props: PaintInputProps): ReactElement {\n const {\n value, mixed = false, unset = false, kinds, allowNone = true,\n onInput, onChange, className,\n } = props;\n const ariaLabel = props['aria-label'];\n\n // Per-kind memory, so linear → solid → linear comes back with its stops.\n // A ref, not state: it must not survive the control being pointed at a\n // different selection, and nothing renders off it directly.\n const remembered = useRef(new Map<PaintKind, FillStyle>());\n\n const active = mixed ? null : kindOf(value);\n if (value != null && active !== null) remembered.current.set(active, value);\n\n const entries = listPaintKinds().filter(\n (entry) => kinds === undefined || kinds.includes(entry.id),\n );\n const segment = (id: string, label: string, icon: string | undefined): ToggleBarItem<PaintKind> =>\n icon && icon in ICON_PATHS\n // Icon-only: six labelled segments do not fit a property row, and the\n // full label stays the accessible name.\n // 14 to match the panel's other glyph segments. A `sm` bar is 17px tall\n // over 1px of padding, so 15 fills the segment box edge to edge.\n ? { value: id, label: <Icon name={icon as IconName} size={14} />, ariaLabel: label }\n : { value: id, label };\n\n const items: readonly ToggleBarItem<PaintKind>[] = [\n ...(allowNone ? [segment(NONE, 'None', 'paintNone')] : []),\n ...entries.map((entry) => segment(entry.id, entry.label, entry.icon)),\n ];\n\n /** The color a switch seeds from: whatever the current paint shows. */\n const currentColor = useCallback((): string => {\n if (value == null) return FALLBACK_COLOR;\n return getPaintKind(kindOf(value) ?? 'solid')?.colorOf(value) ?? FALLBACK_COLOR;\n }, [value]);\n\n const switchKind = (kind: PaintKind): void => {\n if (kind === active) return;\n if (kind === NONE) {\n onChange(null);\n return;\n }\n const seen = remembered.current.get(kind);\n if (seen !== undefined) {\n onChange(seen);\n return;\n }\n if (value != null && isGradient(value) && GRADIENT_KINDS.includes(kind)) {\n onChange(withGradientKind(value, kind as GradientKind));\n return;\n }\n const entry = getPaintKind(kind);\n if (entry) onChange(entry.seed(currentColor()));\n };\n\n return (\n <div\n className={[s.root, unset && s.unset, className].filter(Boolean).join(' ')}\n title={unset ? 'Not set' : undefined}\n >\n <ToggleBar<PaintKind>\n items={items}\n value={active}\n size=\"sm\"\n ariaLabel=\"Paint kind\"\n onChange={(kind) => kind && switchKind(kind)}\n />\n {renderBody()}\n </div>\n );\n\n function renderBody(): ReactElement | null {\n if (mixed || value === undefined) {\n return (\n <ColorField\n mixed\n aria-label={ariaLabel}\n onChange={(color) => onChange({ fill: 'solid', color })}\n />\n );\n }\n // Absence has nothing to edit. The lit segment is the whole statement.\n if (value === null) return null;\n // A registered `Editor` wins even for a built-in id: re-registering one is\n // how a consumer replaces a kit control, and the built-in branches below\n // are the fallback for the ids that ship without an entry editor.\n const entry = getPaintKind(kindOf(value) ?? 'solid');\n if (entry?.Editor) {\n const Editor = entry.Editor;\n return <Editor value={value} onInput={onInput} onChange={onChange} />;\n }\n if (isGradient(value)) {\n return (\n <GradientEditor\n value={value}\n kindSwitch={false}\n onInput={onInput}\n onChange={onChange}\n />\n );\n }\n if (isPattern(value)) {\n return <PatternPicker value={value} color={currentColor()} onChange={onChange} />;\n }\n return (\n <ColorField\n value={currentColor()}\n alpha\n aria-label={ariaLabel}\n onInput={(color) => onInput?.({ fill: 'solid', color })}\n onChange={(color) => onChange({ fill: 'solid', color })}\n />\n );\n }\n}\n"],"mappings":";;;;;;;;;;;GCmBM,IAAiB,aAKjB,IAAO,QAEP,IAAoC;CACxC;CACA;CACA;CACD;AAED,SAAS,EAAW,GAAqD;AACvE,QAAO,MAAU,KAAA,KAAa,EAAe,SAAS,EAAM,QAAQ,GAAG;;AAGzE,SAAS,EAAU,GAAoD;AACrE,QAAO,GAAO,SAAS;;AAKzB,SAAS,EAAO,GAAuD;AAGrE,QAFI,MAAU,OAAa,IACvB,MAAU,KAAA,IAAkB,OACzB,EAAM,QAAQ;;AAwCvB,SAAgB,EAAW,GAAsC;CAC/D,IAAM,EACJ,UAAO,WAAQ,IAAO,WAAQ,IAAO,UAAO,eAAY,IACxD,YAAS,aAAU,iBACjB,GACE,IAAY,EAAM,eAKlB,IAAa,kBAAO,IAAI,KAA2B,CAAC,EAEpD,IAAS,IAAQ,OAAO,EAAO,EAAM;AAC3C,CAAI,KAAS,QAAQ,MAAW,QAAM,EAAW,QAAQ,IAAI,GAAQ,EAAM;CAE3E,IAAM,IAAU,GAAgB,CAAC,QAC9B,MAAU,MAAU,KAAA,KAAa,EAAM,SAAS,EAAM,GAAG,CAC3D,EACK,KAAW,GAAY,GAAe,MAC1C,KAAQ,KAAQ,IAKZ;EAAE,OAAO;EAAI,OAAO,kBAAC,GAAD;GAAM,MAAM;GAAkB,MAAM;GAAM,CAAA;EAAE,WAAW;EAAO,GAClF;EAAE,OAAO;EAAI;EAAO,EAEpB,IAA6C,CACjD,GAAI,IAAY,CAAC,EAAQ,GAAM,QAAQ,YAAY,CAAC,GAAG,EAAE,EACzD,GAAG,EAAQ,KAAK,MAA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GAAD;GACS;GACP,YAAY;GACH;GACC;GACV,CAAA,GAGF,EAAU,EAAM,GACX,kBAAC,GAAD;GAAsB;GAAO,OAAO,GAAc;GAAY;GAAY,CAAA,GAGjF,kBAAC,GAAD;GACE,OAAO,GAAc;GACrB,OAAA;GACA,cAAY;GACZ,UAAU,MAAU,IAAU;IAAE,MAAM;IAAS;IAAO,CAAC;GACvD,WAAW,MAAU,EAAS;IAAE,MAAM;IAAS;IAAO,CAAC;GACvD,CAAA"}
@@ -1,12 +1,12 @@
1
1
  import { n as e, t } from "./Tooltip-BHre_vbI.js";
2
- import { t as n } from "./ColorField-D0OxUlvu.js";
2
+ import { t as n } from "./ColorField-C20aRvCg.js";
3
3
  import { t as r } from "./Checkbox-D-pVpobU.js";
4
4
  import { t as i } from "./Select-CacMfs4v.js";
5
5
  import { t as a } from "./FontFamilySelect-DIJ4phXz.js";
6
6
  import { t as o } from "./Input-CoKOtyD0.js";
7
7
  import { t as s } from "./NumberField-DBowmOfe.js";
8
8
  import { n as c, t as l } from "./RadioGroup-B2_LUgDp.js";
9
- import { t as u } from "./RangeSlider-C3to8A52.js";
9
+ import { t as u } from "./RangeSlider-S2R3zA8N.js";
10
10
  import { t as d } from "./Switch-C4NU-me1.js";
11
11
  import { i as f, n as p, r as m, t as h } from "./schema-CtWwGbqJ.js";
12
12
  import { t as g } from "./Dialog-CYBLjwbd.js";
@@ -291,4 +291,4 @@ function A(e) {
291
291
  //#endregion
292
292
  export { w as i, E as n, C as r, A as t };
293
293
 
294
- //# sourceMappingURL=Prefs-D0l0PXLF.js.map
294
+ //# sourceMappingURL=Prefs-4JSEtuU-.js.map