@devalok/shilp-sutra 0.27.2 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,44 +25,44 @@ const _ = r.forwardRef(
25
25
  className: K,
26
26
  ...$
27
27
  }, z) => {
28
- const [f, G] = r.useState(!1), [i, S] = r.useState(""), [u, m] = r.useState(null), [C, y] = r.useState(!1), [a, p] = r.useState(-1), g = r.useRef(), I = r.useRef(null);
28
+ const [f, G] = r.useState(!1), [a, S] = r.useState(""), [u, m] = r.useState(null), [C, y] = r.useState(!1), [i, p] = r.useState(-1), g = r.useRef(), I = r.useRef(null);
29
29
  r.useEffect(() => {
30
30
  f || (S(""), m(null), p(-1));
31
31
  }, [f]), r.useEffect(() => {
32
32
  if (!(!c || !f)) {
33
- if (!i.trim()) {
33
+ if (!a.trim()) {
34
34
  m(null), y(!1);
35
35
  return;
36
36
  }
37
37
  return y(!0), clearTimeout(g.current), g.current = setTimeout(() => {
38
- c(i).then((e) => m(e)).catch(() => m([])).finally(() => y(!1));
38
+ c(a).then((e) => m(e)).catch(() => m([])).finally(() => y(!1));
39
39
  }, v), () => clearTimeout(g.current);
40
40
  }
41
- }, [i, c, v, f]);
41
+ }, [a, c, v, f]);
42
42
  const b = r.useMemo(() => u || (o ? o.flatMap((e) => e.items) : w ?? []), [w, o, u]), x = r.useMemo(() => {
43
43
  if (c) return b;
44
- const e = i.toLowerCase();
44
+ const e = a.toLowerCase();
45
45
  return e ? b.filter((s) => s.label.toLowerCase().includes(e)) : b;
46
- }, [b, i, c]), R = r.useMemo(() => {
46
+ }, [b, a, c]), R = r.useMemo(() => {
47
47
  if (!o || c || u) return null;
48
- const e = i.toLowerCase();
48
+ const e = a.toLowerCase();
49
49
  return o.map((s) => ({
50
50
  ...s,
51
51
  items: e ? s.items.filter((t) => t.label.toLowerCase().includes(e)) : s.items
52
52
  })).filter((s) => s.items.length > 0);
53
- }, [o, i, c, u]);
53
+ }, [o, a, c, u]);
54
54
  function M(e) {
55
55
  d.includes(e) ? h(d.filter((t) => t !== e)) : k && d.length >= k ? h([...d.slice(1), e]) : h([...d, e]);
56
56
  }
57
57
  r.useEffect(() => {
58
58
  p(-1);
59
- }, [i]), r.useEffect(() => {
59
+ }, [a]), r.useEffect(() => {
60
60
  var t;
61
- if (a < 0) return;
61
+ if (i < 0) return;
62
62
  const e = I.current;
63
63
  if (!e) return;
64
- (t = e.querySelectorAll("[data-multiselect-item]")[a]) == null || t.scrollIntoView({ block: "nearest" });
65
- }, [a]);
64
+ (t = e.querySelectorAll("[data-multiselect-item]")[i]) == null || t.scrollIntoView({ block: "nearest" });
65
+ }, [i]);
66
66
  function U(e) {
67
67
  const s = x.length;
68
68
  if (s !== 0) {
@@ -70,16 +70,16 @@ const _ = r.forwardRef(
70
70
  e.preventDefault(), p((t) => t < s - 1 ? t + 1 : 0);
71
71
  else if (e.key === "ArrowUp")
72
72
  e.preventDefault(), p((t) => t <= 0 ? s - 1 : t - 1);
73
- else if (e.key === "Enter" && a >= 0) {
73
+ else if (e.key === "Enter" && i >= 0) {
74
74
  e.preventDefault();
75
- const t = x[a];
75
+ const t = x[i];
76
76
  t && !t.disabled && M(t.id);
77
77
  }
78
78
  }
79
79
  }
80
80
  let B = 0;
81
81
  function D(e) {
82
- const s = d.includes(e.id), t = B++, E = t === a;
82
+ const s = d.includes(e.id), t = B++, E = t === i;
83
83
  return /* @__PURE__ */ l(
84
84
  A.button,
85
85
  {
@@ -129,7 +129,7 @@ const _ = r.forwardRef(
129
129
  e.id
130
130
  );
131
131
  }
132
- return /* @__PURE__ */ l(J, { open: f, onOpenChange: G, children: [
132
+ return /* @__PURE__ */ l(J, { open: f, onOpenChange: G, modal: !1, children: [
133
133
  /* @__PURE__ */ n(Q, { asChild: !0, children: O }),
134
134
  /* @__PURE__ */ l(
135
135
  W,
@@ -151,11 +151,11 @@ const _ = r.forwardRef(
151
151
  {
152
152
  type: "text",
153
153
  placeholder: T,
154
- value: i,
154
+ value: a,
155
155
  onChange: (e) => S(e.target.value),
156
156
  onKeyDown: U,
157
157
  "aria-label": "Search",
158
- "aria-activedescendant": a >= 0 ? `msp-item-${a}` : void 0,
158
+ "aria-activedescendant": i >= 0 ? `msp-item-${i}` : void 0,
159
159
  className: "w-full bg-transparent text-ds-md font-body text-surface-fg placeholder:text-surface-fg-subtle outline-none"
160
160
  }
161
161
  ),
@@ -1,17 +1,31 @@
1
1
  "use client";
2
2
  import * as React from 'react';
3
+ type ColorFormat = 'hex' | 'rgb' | 'hsl';
3
4
  export interface ColorInputProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
4
5
  /** Current color value (hex string, e.g. "#d33163") */
5
6
  value?: string;
6
7
  /** Called when the color changes */
7
8
  onChange?: (value: string) => void;
8
- /** Optional preset color swatches */
9
- presets?: string[];
9
+ /** Preset color swatches. Defaults to 10 named colors. Pass `false` to hide. */
10
+ presets?: {
11
+ hex: string;
12
+ label: string;
13
+ }[] | string[] | false;
10
14
  /** Whether the input is disabled */
11
15
  disabled?: boolean;
12
- /** Additional className for the wrapper */
13
- className?: string;
16
+ /** Show the interactive color picker. Default: true. */
17
+ showPicker?: boolean;
18
+ /** Default format for the input fields. Default: 'hex'. */
19
+ defaultFormat?: ColorFormat;
20
+ /** Popover alignment. Default: 'start'. */
21
+ align?: 'start' | 'center' | 'end';
22
+ /**
23
+ * Trigger style variant.
24
+ * - `default`: Swatch bleeds to left edge + hex text
25
+ * - `inline`: Entire trigger is the selected color with hex text overlaid
26
+ */
27
+ variant?: 'default' | 'inline';
14
28
  }
15
- declare const ColorInput: React.ForwardRefExoticComponent<ColorInputProps & React.RefAttributes<HTMLInputElement>>;
29
+ declare const ColorInput: React.ForwardRefExoticComponent<ColorInputProps & React.RefAttributes<HTMLDivElement>>;
16
30
  export { ColorInput };
17
31
  //# sourceMappingURL=color-input.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"color-input.d.ts","sourceRoot":"","sources":["../../src/ui/color-input.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC;IAC7F,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,oCAAoC;IACpC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,QAAA,MAAM,UAAU,0FAmFf,CAAA;AAGD,OAAO,EAAE,UAAU,EAAE,CAAA"}
1
+ {"version":3,"file":"color-input.d.ts","sourceRoot":"","sources":["../../src/ui/color-input.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAiF9B,KAAK,WAAW,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAA;AAIxC,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC;IAC7F,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,oCAAoC;IACpC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,gFAAgF;IAChF,OAAO,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,MAAM,EAAE,GAAG,KAAK,CAAA;IAC7D,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,wDAAwD;IACxD,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,2DAA2D;IAC3D,aAAa,CAAC,EAAE,WAAW,CAAA;IAC3B,2CAA2C;IAC3C,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAA;IAClC;;;;OAIG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;CAC/B;AAuDD,QAAA,MAAM,UAAU,wFAqXf,CAAA;AAGD,OAAO,EAAE,UAAU,EAAE,CAAA"}
@@ -1,88 +1,380 @@
1
1
  "use client";
2
- import { jsxs as d, jsx as t } from "react/jsx-runtime";
3
- import * as m from "react";
4
- import { cn as c } from "./lib/utils.js";
5
- const b = m.forwardRef(
6
- ({ value: s = "#000000", onChange: l, presets: n, disabled: o = !1, className: i, ...u }, f) => {
7
- const a = (r) => {
8
- l == null || l(r);
9
- };
10
- return /* @__PURE__ */ d("div", { className: c("flex flex-col gap-ds-03", i), ...u, children: [
11
- /* @__PURE__ */ d("div", { className: "flex items-center gap-ds-03", children: [
12
- /* @__PURE__ */ d(
13
- "label",
14
- {
15
- "aria-label": "Pick a color",
16
- className: c(
17
- "relative flex h-ds-sm w-ds-sm shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-ds-md border border-surface-border-strong transition-colors hover:border-surface-border-strong",
18
- o && "cursor-not-allowed opacity-50"
2
+ import { jsx as a, jsxs as p } from "react/jsx-runtime";
3
+ import * as x from "react";
4
+ import { Z as K } from "../_chunks/vendor-client.js";
5
+ import { cn as k } from "./lib/utils.js";
6
+ import { springs as R } from "./lib/motion.js";
7
+ import { Popover as Q, PopoverTrigger as X, PopoverContent as Y } from "./popover.js";
8
+ import { m as g, A as V } from "../_chunks/framer.js";
9
+ function B(l) {
10
+ const t = /^#?([0-9a-f]{6})$/i.exec(l);
11
+ if (!t) return null;
12
+ const n = parseInt(t[1], 16);
13
+ return { r: n >> 16 & 255, g: n >> 8 & 255, b: n & 255 };
14
+ }
15
+ function O(l, t, n) {
16
+ return "#" + [l, t, n].map((r) => Math.max(0, Math.min(255, Math.round(r))).toString(16).padStart(2, "0")).join("");
17
+ }
18
+ function ee(l) {
19
+ const t = B(l);
20
+ if (!t) return null;
21
+ const n = t.r / 255, r = t.g / 255, i = t.b / 255, c = Math.max(n, r, i), o = Math.min(n, r, i), h = (c + o) / 2;
22
+ if (c === o) return { h: 0, s: 0, l: Math.round(h * 100) };
23
+ const m = c - o, v = h > 0.5 ? m / (2 - c - o) : m / (c - o);
24
+ let M = 0;
25
+ return c === n ? M = ((r - i) / m + (r < i ? 6 : 0)) / 6 : c === r ? M = ((i - n) / m + 2) / 6 : M = ((n - r) / m + 4) / 6, { h: Math.round(M * 360), s: Math.round(v * 100), l: Math.round(h * 100) };
26
+ }
27
+ function te(l, t, n) {
28
+ const r = t / 100, i = n / 100, c = r * Math.min(i, 1 - i), o = (h) => {
29
+ const m = (h + l / 30) % 12, v = i - c * Math.max(Math.min(m - 3, 9 - m, 1), -1);
30
+ return Math.round(255 * v);
31
+ };
32
+ return O(o(0), o(8), o(4));
33
+ }
34
+ const re = [
35
+ { hex: "#EF4444", label: "Red" },
36
+ { hex: "#F59E0B", label: "Amber" },
37
+ { hex: "#10B981", label: "Emerald" },
38
+ { hex: "#3B82F6", label: "Blue" },
39
+ { hex: "#8B5CF6", label: "Violet" },
40
+ { hex: "#EC4899", label: "Pink" },
41
+ { hex: "#06B6D4", label: "Cyan" },
42
+ { hex: "#F97316", label: "Orange" },
43
+ { hex: "#84CC16", label: "Lime" },
44
+ { hex: "#6366F1", label: "Indigo" }
45
+ ];
46
+ function ae(l) {
47
+ const t = B(l);
48
+ if (!t) return !1;
49
+ const [n, r, i] = [t.r, t.g, t.b].map((c) => {
50
+ const o = c / 255;
51
+ return o <= 0.03928 ? o / 12.92 : Math.pow((o + 0.055) / 1.055, 2.4);
52
+ });
53
+ return 0.2126 * n + 0.7152 * r + 0.0722 * i > 0.4;
54
+ }
55
+ function w({
56
+ label: l,
57
+ value: t,
58
+ onChange: n,
59
+ onBlur: r,
60
+ disabled: i,
61
+ maxLength: c = 3,
62
+ prefix: o,
63
+ className: h,
64
+ id: m
65
+ }) {
66
+ return /* @__PURE__ */ p("div", { className: k("flex flex-col gap-ds-01", h), children: [
67
+ /* @__PURE__ */ a("label", { htmlFor: m, className: "text-[10px] font-medium uppercase tracking-wider text-surface-fg-muted", children: l }),
68
+ /* @__PURE__ */ p("div", { className: "flex items-center", children: [
69
+ o && /* @__PURE__ */ a("span", { className: "text-ds-sm text-surface-fg-muted", children: o }),
70
+ /* @__PURE__ */ a(
71
+ "input",
72
+ {
73
+ id: m,
74
+ type: "text",
75
+ value: t,
76
+ disabled: i,
77
+ onChange: (v) => n(v.target.value),
78
+ onBlur: r,
79
+ maxLength: c,
80
+ className: k(
81
+ "h-ds-xs-plus w-full rounded-ds-sm border border-surface-border bg-surface-overlay px-ds-02 font-mono text-ds-sm text-surface-fg transition-colors",
82
+ "focus:border-accent-7 focus:outline-none focus:ring-1 focus:ring-accent-9",
83
+ i && "cursor-not-allowed opacity-50"
84
+ )
85
+ }
86
+ )
87
+ ] })
88
+ ] });
89
+ }
90
+ const se = x.forwardRef(
91
+ ({
92
+ value: l = "#000000",
93
+ onChange: t,
94
+ presets: n,
95
+ disabled: r = !1,
96
+ showPicker: i = !0,
97
+ defaultFormat: c = "hex",
98
+ align: o = "start",
99
+ variant: h = "default",
100
+ className: m,
101
+ ...v
102
+ }, M) => {
103
+ const [$, A] = x.useState(c), [j, D] = x.useState(!1), b = x.useId(), [s, S] = x.useState(l);
104
+ x.useEffect(() => {
105
+ S(l);
106
+ }, [l]);
107
+ const [C, W] = x.useState(l), [I, F] = x.useState([]), H = x.useRef(!1), G = (e) => {
108
+ r || (e && (W(s), F([])), D(e));
109
+ }, P = (e) => {
110
+ if (r) return;
111
+ const d = (e.startsWith("#") ? e : `#${e}`).toLowerCase();
112
+ F((u) => u[u.length - 1] === s ? u : [...u.slice(-19), s]), S(d), t == null || t(d);
113
+ }, Z = (e) => {
114
+ if (r) return;
115
+ const d = (e.startsWith("#") ? e : `#${e}`).toLowerCase();
116
+ H.current || (H.current = !0, F((u) => u[u.length - 1] === s ? u : [...u.slice(-19), s])), S(d), t == null || t(d);
117
+ }, E = () => {
118
+ H.current = !1;
119
+ }, _ = () => {
120
+ if (I.length === 0) return;
121
+ const e = I[I.length - 1];
122
+ F((f) => f.slice(0, -1)), S(e), t == null || t(e);
123
+ }, q = () => {
124
+ S(C), t == null || t(C), F([]);
125
+ }, z = n === !1 ? [] : n ? n.map(
126
+ (e) => typeof e == "string" ? { hex: e, label: e } : e
127
+ ) : re, y = B(s), N = ee(s), L = (e, f) => {
128
+ if (!y) return;
129
+ const d = parseInt(f, 10);
130
+ if (isNaN(d)) return;
131
+ const u = Math.max(0, Math.min(255, d));
132
+ P(O(
133
+ e === "r" ? u : y.r,
134
+ e === "g" ? u : y.g,
135
+ e === "b" ? u : y.b
136
+ ));
137
+ }, T = (e, f) => {
138
+ if (!N) return;
139
+ const d = parseInt(f, 10);
140
+ if (isNaN(d)) return;
141
+ const U = Math.max(0, Math.min(e === "h" ? 360 : 100, d));
142
+ P(te(
143
+ e === "h" ? U : N.h,
144
+ e === "s" ? U : N.s,
145
+ e === "l" ? U : N.l
146
+ ));
147
+ }, J = ["hex", "rgb", "hsl"];
148
+ return /* @__PURE__ */ a("div", { ref: M, className: k("inline-flex flex-col", m), ...v, children: /* @__PURE__ */ p(Q, { open: j, onOpenChange: G, children: [
149
+ /* @__PURE__ */ a(X, { asChild: !0, children: h === "inline" ? /* @__PURE__ */ a(
150
+ g.button,
151
+ {
152
+ type: "button",
153
+ disabled: r,
154
+ className: k(
155
+ "group flex items-center justify-center rounded-ds-md px-ds-04 py-ds-02 font-mono text-ds-sm font-medium",
156
+ "focus:outline-none focus:ring-2 focus:ring-accent-9 focus:ring-offset-2 focus:ring-offset-surface-base",
157
+ r && "cursor-not-allowed opacity-50"
158
+ ),
159
+ animate: {
160
+ backgroundColor: s,
161
+ color: ae(s) ? "rgba(0,0,0,0.8)" : "rgba(255,255,255,0.95)"
162
+ },
163
+ whileHover: { y: -1, boxShadow: "0 4px 12px rgba(0,0,0,0.12)" },
164
+ whileTap: { scale: 0.97 },
165
+ transition: R.smooth,
166
+ "aria-label": `Color picker: ${s}`,
167
+ children: s.toUpperCase()
168
+ }
169
+ ) : /* @__PURE__ */ p(
170
+ g.button,
171
+ {
172
+ type: "button",
173
+ disabled: r,
174
+ className: k(
175
+ "group relative flex items-center overflow-hidden rounded-ds-md border border-surface-border-strong",
176
+ "hover:border-accent-7 focus:border-accent-7 focus:outline-none focus:ring-1 focus:ring-accent-9",
177
+ r && "cursor-not-allowed opacity-50"
178
+ ),
179
+ whileHover: { scale: 1.02 },
180
+ whileTap: { scale: 0.98 },
181
+ transition: R.snappy,
182
+ "aria-label": `Color picker: ${s}`,
183
+ children: [
184
+ /* @__PURE__ */ a(
185
+ g.span,
186
+ {
187
+ className: "absolute inset-0",
188
+ animate: {
189
+ background: `linear-gradient(to right, ${s} 0%, ${s} 35%, transparent 70%)`
190
+ },
191
+ transition: { duration: 0.3 }
192
+ }
19
193
  ),
20
- children: [
21
- /* @__PURE__ */ t(
22
- "input",
194
+ /* @__PURE__ */ a("span", { className: "absolute inset-0 bg-surface-overlay/60", style: {
195
+ maskImage: "linear-gradient(to right, transparent 0%, black 40%)",
196
+ WebkitMaskImage: "linear-gradient(to right, transparent 0%, black 40%)"
197
+ } }),
198
+ /* @__PURE__ */ a("span", { className: "relative z-10 py-ds-02 pl-6 pr-ds-03 font-mono text-ds-sm text-surface-fg", children: s.toUpperCase() })
199
+ ]
200
+ }
201
+ ) }),
202
+ /* @__PURE__ */ a(
203
+ Y,
204
+ {
205
+ align: o,
206
+ sideOffset: 8,
207
+ className: "w-[272px] rounded-ds-xl border border-surface-border-strong bg-surface-overlay p-0 shadow-floating",
208
+ children: /* @__PURE__ */ p("div", { className: "flex flex-col", children: [
209
+ i && /* @__PURE__ */ a("div", { className: "p-ds-04 pb-ds-03", onPointerUp: E, onPointerLeave: E, children: /* @__PURE__ */ a(
210
+ K,
211
+ {
212
+ color: s,
213
+ onChange: Z,
214
+ className: "!w-full",
215
+ style: { height: 160 }
216
+ }
217
+ ) }),
218
+ /* @__PURE__ */ p("div", { className: "border-t border-surface-border px-ds-04 py-ds-03", children: [
219
+ /* @__PURE__ */ a("div", { className: "mb-ds-03 flex items-center gap-ds-01", children: J.map((e) => /* @__PURE__ */ p(
220
+ "button",
23
221
  {
24
- ref: f,
25
- type: "color",
26
- value: s,
27
- disabled: o,
28
- onChange: (r) => a(r.target.value),
29
- className: "absolute inset-0 h-full w-full cursor-pointer opacity-0"
30
- }
31
- ),
32
- /* @__PURE__ */ t(
33
- "span",
222
+ type: "button",
223
+ onClick: () => A(e),
224
+ className: k(
225
+ "relative rounded-ds-sm px-ds-02 py-px text-[10px] font-semibold uppercase tracking-wider transition-colors",
226
+ $ === e ? "text-accent-11" : "text-surface-fg-muted hover:text-surface-fg"
227
+ ),
228
+ children: [
229
+ $ === e && /* @__PURE__ */ a(
230
+ g.span,
231
+ {
232
+ layoutId: `color-input-format-pill-${b}`,
233
+ className: "absolute inset-0 rounded-ds-sm bg-accent-3",
234
+ transition: R.snappy
235
+ }
236
+ ),
237
+ /* @__PURE__ */ a("span", { className: "relative z-10", children: e })
238
+ ]
239
+ },
240
+ e
241
+ )) }),
242
+ /* @__PURE__ */ p(V, { mode: "wait", children: [
243
+ $ === "hex" && /* @__PURE__ */ a(
244
+ g.div,
245
+ {
246
+ initial: { opacity: 0, y: 4 },
247
+ animate: { opacity: 1, y: 0 },
248
+ exit: { opacity: 0, y: -4 },
249
+ transition: { duration: 0.15 },
250
+ className: "flex gap-ds-02",
251
+ children: /* @__PURE__ */ a(
252
+ w,
253
+ {
254
+ id: `${b}-hex`,
255
+ label: "Hex",
256
+ value: s.replace("#", "").toUpperCase(),
257
+ onChange: (e) => {
258
+ const f = e.replace(/[^0-9a-fA-F]/g, "").slice(0, 6);
259
+ f.length === 6 && P(`#${f}`);
260
+ },
261
+ onBlur: () => {
262
+ s.replace("#", "").toUpperCase().length !== 6 && S(s);
263
+ },
264
+ disabled: r,
265
+ maxLength: 6,
266
+ prefix: "#",
267
+ className: "flex-1"
268
+ }
269
+ )
270
+ },
271
+ "hex"
272
+ ),
273
+ $ === "rgb" && y && /* @__PURE__ */ p(
274
+ g.div,
275
+ {
276
+ initial: { opacity: 0, y: 4 },
277
+ animate: { opacity: 1, y: 0 },
278
+ exit: { opacity: 0, y: -4 },
279
+ transition: { duration: 0.15 },
280
+ className: "flex gap-ds-02",
281
+ children: [
282
+ /* @__PURE__ */ a(w, { id: `${b}-r`, label: "R", value: String(y.r), onChange: (e) => L("r", e), disabled: r, className: "flex-1" }),
283
+ /* @__PURE__ */ a(w, { id: `${b}-g`, label: "G", value: String(y.g), onChange: (e) => L("g", e), disabled: r, className: "flex-1" }),
284
+ /* @__PURE__ */ a(w, { id: `${b}-b`, label: "B", value: String(y.b), onChange: (e) => L("b", e), disabled: r, className: "flex-1" })
285
+ ]
286
+ },
287
+ "rgb"
288
+ ),
289
+ $ === "hsl" && N && /* @__PURE__ */ p(
290
+ g.div,
291
+ {
292
+ initial: { opacity: 0, y: 4 },
293
+ animate: { opacity: 1, y: 0 },
294
+ exit: { opacity: 0, y: -4 },
295
+ transition: { duration: 0.15 },
296
+ className: "flex gap-ds-02",
297
+ children: [
298
+ /* @__PURE__ */ a(w, { id: `${b}-h`, label: "H", value: String(N.h), onChange: (e) => T("h", e), disabled: r, className: "flex-1" }),
299
+ /* @__PURE__ */ a(w, { id: `${b}-s`, label: "S", value: String(N.s), onChange: (e) => T("s", e), disabled: r, className: "flex-1" }),
300
+ /* @__PURE__ */ a(w, { id: `${b}-l`, label: "L", value: String(N.l), onChange: (e) => T("l", e), disabled: r, className: "flex-1" })
301
+ ]
302
+ },
303
+ "hsl"
304
+ )
305
+ ] })
306
+ ] }),
307
+ z.length > 0 && /* @__PURE__ */ a("div", { className: "border-t border-surface-border px-ds-04 py-ds-03", children: /* @__PURE__ */ a("div", { className: "flex flex-wrap gap-ds-02", children: z.map((e, f) => {
308
+ const d = s.toLowerCase() === e.hex.toLowerCase();
309
+ return /* @__PURE__ */ a(
310
+ g.button,
34
311
  {
35
- className: "h-full w-full rounded-[inherit]",
36
- style: { backgroundColor: s }
37
- }
38
- )
39
- ]
40
- }
41
- ),
42
- /* @__PURE__ */ t(
43
- "input",
44
- {
45
- type: "text",
46
- "aria-label": "Hex color value",
47
- value: s,
48
- disabled: o,
49
- onChange: (r) => {
50
- const e = r.target.value;
51
- /^#[0-9a-fA-F]{0,6}$/.test(e) && a(e);
52
- },
53
- onBlur: (r) => {
54
- const e = r.target.value;
55
- /^#[0-9a-fA-F]{6}$/.test(e) && a(e);
56
- },
57
- maxLength: 7,
58
- className: c(
59
- "h-ds-sm w-[90px] rounded-ds-md border border-surface-border-strong bg-surface-overlay px-ds-03 font-mono text-ds-md text-surface-fg transition-colors",
60
- "focus:border-accent-7 focus:outline-none focus:ring-1 focus:ring-accent-9",
61
- o && "cursor-not-allowed opacity-50"
312
+ type: "button",
313
+ disabled: r,
314
+ onClick: () => P(e.hex),
315
+ initial: { opacity: 0, scale: 0.8 },
316
+ animate: { opacity: 1, scale: d ? 1.15 : 1 },
317
+ whileHover: { scale: d ? 1.15 : 1.1 },
318
+ whileTap: { scale: 0.9 },
319
+ transition: { ...R.bouncy, delay: f * 0.02 },
320
+ className: k(
321
+ "h-6 w-6 rounded-ds-sm border",
322
+ d ? "border-accent-7 ring-2 ring-accent-9/30" : "border-surface-border hover:border-surface-border-strong",
323
+ r && "cursor-not-allowed opacity-50"
324
+ ),
325
+ style: { backgroundColor: e.hex },
326
+ title: e.label,
327
+ "aria-label": `${e.label}: ${e.hex}`
328
+ },
329
+ e.hex
330
+ );
331
+ }) }) }),
332
+ (I.length > 0 || s !== C) && /* @__PURE__ */ p(
333
+ g.div,
334
+ {
335
+ initial: { opacity: 0, height: 0 },
336
+ animate: { opacity: 1, height: "auto" },
337
+ exit: { opacity: 0, height: 0 },
338
+ className: "flex items-center gap-ds-02 border-t border-surface-border px-ds-04 py-ds-02",
339
+ children: [
340
+ /* @__PURE__ */ a(
341
+ "span",
342
+ {
343
+ className: "h-4 w-4 shrink-0 rounded-full border border-surface-border",
344
+ style: { backgroundColor: C },
345
+ title: `Original: ${C}`
346
+ }
347
+ ),
348
+ /* @__PURE__ */ a("span", { className: "text-[10px] text-surface-fg-muted", children: C.toUpperCase() }),
349
+ /* @__PURE__ */ a("span", { className: "flex-1" }),
350
+ I.length > 0 && /* @__PURE__ */ a(
351
+ "button",
352
+ {
353
+ type: "button",
354
+ onClick: _,
355
+ className: "rounded-ds-sm px-ds-02 py-px text-[10px] font-medium text-surface-fg-muted transition-colors hover:text-surface-fg",
356
+ children: "Undo"
357
+ }
358
+ ),
359
+ s !== C && /* @__PURE__ */ a(
360
+ "button",
361
+ {
362
+ type: "button",
363
+ onClick: q,
364
+ className: "rounded-ds-sm px-ds-02 py-px text-[10px] font-medium text-surface-fg-muted transition-colors hover:text-error-11",
365
+ children: "Reset"
366
+ }
367
+ )
368
+ ]
369
+ }
62
370
  )
63
- }
64
- )
65
- ] }),
66
- n && n.length > 0 && /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-ds-02", children: n.map((r) => /* @__PURE__ */ t(
67
- "button",
68
- {
69
- type: "button",
70
- disabled: o,
71
- onClick: () => a(r),
72
- className: c(
73
- "h-ds-xs w-ds-xs rounded-ds-sm border transition-colors",
74
- s === r ? "border-accent-7 ring-1 ring-accent-9" : "border-surface-border-strong hover:border-surface-border-strong",
75
- o && "cursor-not-allowed opacity-50"
76
- ),
77
- style: { backgroundColor: r },
78
- "aria-label": `Select color ${r}`
79
- },
80
- r
81
- )) })
82
- ] });
371
+ ] })
372
+ }
373
+ )
374
+ ] }) });
83
375
  }
84
376
  );
85
- b.displayName = "ColorInput";
377
+ se.displayName = "ColorInput";
86
378
  export {
87
- b as ColorInput
379
+ se as ColorInput
88
380
  };
package/dist/ui/dialog.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as o, jsxs as d } from "react/jsx-runtime";
3
3
  import * as t from "react";
4
- import { a9 as g, aa as C, ab as f, ac as y, ad as x, ae as v, af as R, ag as j } from "../_chunks/primitives.js";
4
+ import { aa as g, ab as C, ac as f, ad as y, ae as x, af as v, ag as R, ah as j } from "../_chunks/primitives.js";
5
5
  import { IconX as M } from "@tabler/icons-react";
6
6
  import { cn as i } from "./lib/utils.js";
7
7
  import { tweens as p, springs as T } from "./lib/motion.js";
@@ -12,13 +12,13 @@ const N = t.createContext({ open: !1 }), z = () => t.useContext(N), A = ({
12
12
  onOpenChange: e,
13
13
  ...r
14
14
  }) => {
15
- const [l, b] = t.useState(s ?? !1), n = a !== void 0, c = n ? a : l, h = t.useCallback(
15
+ const [l, h] = t.useState(s ?? !1), n = a !== void 0, c = n ? a : l, b = t.useCallback(
16
16
  (m) => {
17
- n || b(m), e == null || e(m);
17
+ n || h(m), e == null || e(m);
18
18
  },
19
19
  [n, e]
20
20
  ), w = t.useMemo(() => ({ open: c }), [c]);
21
- return /* @__PURE__ */ o(N.Provider, { value: w, children: /* @__PURE__ */ o(R, { open: c, onOpenChange: h, ...r }) });
21
+ return /* @__PURE__ */ o(N.Provider, { value: w, children: /* @__PURE__ */ o(R, { open: c, onOpenChange: b, ...r }) });
22
22
  };
23
23
  A.displayName = "Dialog";
24
24
  const K = j, F = C, L = y, D = t.forwardRef(({ className: a, ...s }, e) => /* @__PURE__ */ o(