@elcrm/form 0.0.82 → 0.0.84

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.
@@ -1,19 +1,20 @@
1
1
  import e from "../styles/Field.module.js";
2
2
  import t from "../core/Field.js";
3
3
  import { useFormFieldState as n } from "../hooks/use.js";
4
- import r from "../styles/Color.module.js";
5
- import i from "react";
6
- import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
7
- import { createPortal as c } from "react-dom";
4
+ import { acquireOverlayZIndex as r, releaseOverlayZIndex as i } from "../overlayZ.js";
5
+ import a from "../styles/Color.module.js";
6
+ import o from "react";
7
+ import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
8
+ import { createPortal as u } from "react-dom";
8
9
  //#region src/lib/fields/Color.tsx
9
- var l = /* @__PURE__ */ "#FF2D55.#FF3B30.#FF453A.#FF6961.#FF8A80.#C11F3E.#AF52DE.#BF5AF2.#DA8FFF.#5856D6.#5E5CE6.#7D7AFF.#007AFF.#0A84FF.#409CFF.#64D2FF.#70D7FF.#5AC8FA.#32ADE6.#64D2FF.#40C8E0.#00C7BE.#63E6E2.#66D4CF.#34C759.#30D158.#30DB5B.#4CD964.#6DE6A0.#8EEDB3.#A8E10C.#B5F200.#D0FF00.#E4FF66.#F2FF99.#C6FF00.#FFCC00.#FFD60A.#FFEA00.#FFE066.#FFF3A3.#FFEB3B.#FF9500.#FF9F0A.#FFB340.#FFB340.#FFD580.#FF8C00.#A2845E.#AC8E68.#C4A484.#8E8E93.#636366.#48484A.#3A3A3C.#2C2C2E.#1C1C1E".split(".");
10
- function u(e, t, n) {
10
+ var d = /* @__PURE__ */ "#FF2D55.#FF3B30.#FF453A.#FF6961.#FF8A80.#C11F3E.#AF52DE.#BF5AF2.#DA8FFF.#5856D6.#5E5CE6.#7D7AFF.#007AFF.#0A84FF.#409CFF.#64D2FF.#70D7FF.#5AC8FA.#32ADE6.#64D2FF.#40C8E0.#00C7BE.#63E6E2.#66D4CF.#34C759.#30D158.#30DB5B.#4CD964.#6DE6A0.#8EEDB3.#A8E10C.#B5F200.#D0FF00.#E4FF66.#F2FF99.#C6FF00.#FFCC00.#FFD60A.#FFEA00.#FFE066.#FFF3A3.#FFEB3B.#FF9500.#FF9F0A.#FFB340.#FFB340.#FFD580.#FF8C00.#A2845E.#AC8E68.#C4A484.#8E8E93.#636366.#48484A.#3A3A3C.#2C2C2E.#1C1C1E".split(".");
11
+ function f(e, t, n) {
11
12
  return Math.min(n, Math.max(t, e));
12
13
  }
13
- function d(e) {
14
- return Math.round(u(e, 0, 255)).toString(16).padStart(2, "0").toUpperCase();
14
+ function p(e) {
15
+ return Math.round(f(e, 0, 255)).toString(16).padStart(2, "0").toUpperCase();
15
16
  }
16
- function f(e, t, n) {
17
+ function m(e, t, n) {
17
18
  let r = (e % 360 + 360) % 360, i = n * t, a = i * (1 - Math.abs(r / 60 % 2 - 1)), o = n - i, s = 0, c = 0, l = 0;
18
19
  return r < 60 ? [s, c, l] = [
19
20
  i,
@@ -45,7 +46,7 @@ function f(e, t, n) {
45
46
  b: (l + o) * 255
46
47
  };
47
48
  }
48
- function p(e, t, n) {
49
+ function h(e, t, n) {
49
50
  let r = e / 255, i = t / 255, a = n / 255, o = Math.max(r, i, a), s = o - Math.min(r, i, a), c = 0;
50
51
  s !== 0 && (c = o === r ? (i - a) / s % 6 : o === i ? (a - r) / s + 2 : (r - i) / s + 4, c *= 60, c < 0 && (c += 360));
51
52
  let l = o === 0 ? 0 : s / o;
@@ -55,7 +56,7 @@ function p(e, t, n) {
55
56
  v: o
56
57
  };
57
58
  }
58
- function m(e) {
59
+ function g(e) {
59
60
  if (typeof e != "string") return null;
60
61
  let t = e.trim();
61
62
  if (!t || (t[0] === "#" && (t = t.slice(1)), ![
@@ -66,99 +67,99 @@ function m(e) {
66
67
  ].includes(t.length)) || !/^[0-9a-fA-F]+$/.test(t)) return null;
67
68
  let n = 0, r = 0, i = 0, a = 1;
68
69
  return t.length === 3 || t.length === 4 ? (n = parseInt(t[0] + t[0], 16), r = parseInt(t[1] + t[1], 16), i = parseInt(t[2] + t[2], 16), t.length === 4 && (a = parseInt(t[3] + t[3], 16) / 255)) : (n = parseInt(t.slice(0, 2), 16), r = parseInt(t.slice(2, 4), 16), i = parseInt(t.slice(4, 6), 16), t.length === 8 && (a = parseInt(t.slice(6, 8), 16) / 255)), {
69
- ...p(n, r, i),
70
+ ...h(n, r, i),
70
71
  a
71
72
  };
72
73
  }
73
- function h(e, t) {
74
- let { r: n, g: r, b: i } = f(e.h, e.s, e.v), a = `#${d(n)}${d(r)}${d(i)}`;
75
- return !t || e.a >= .999 ? a : `${a}${d(e.a * 255)}`;
74
+ function _(e, t) {
75
+ let { r: n, g: r, b: i } = m(e.h, e.s, e.v), a = `#${p(n)}${p(r)}${p(i)}`;
76
+ return !t || e.a >= .999 ? a : `${a}${p(e.a * 255)}`;
76
77
  }
77
- function g(e) {
78
- let { r: t, g: n, b: r } = f(e.h, e.s, e.v), i = Math.round(t), a = Math.round(n), o = Math.round(r);
78
+ function v(e) {
79
+ let { r: t, g: n, b: r } = m(e.h, e.s, e.v), i = Math.round(t), a = Math.round(n), o = Math.round(r);
79
80
  return e.a >= .999 ? `rgb(${i}, ${a}, ${o})` : `rgba(${i}, ${a}, ${o}, ${Number(e.a.toFixed(3))})`;
80
81
  }
81
- function _(e) {
82
- let { r: t, g: n, b: r } = f(e, 1, 1);
82
+ function y(e) {
83
+ let { r: t, g: n, b: r } = m(e, 1, 1);
83
84
  return `rgb(${Math.round(t)},${Math.round(n)},${Math.round(r)})`;
84
85
  }
85
- function v(e) {
86
- let t = m(e);
87
- return t ? h(t, t.a < .999) : e.toUpperCase();
86
+ function b(e) {
87
+ let t = g(e);
88
+ return t ? _(t, t.a < .999) : e.toUpperCase();
88
89
  }
89
- function y(e) {
90
+ function x(e) {
90
91
  return e == null ? !0 : typeof e == "string" ? e.trim() === "" : !1;
91
92
  }
92
- function b(e) {
93
+ function S(e) {
93
94
  if (!(e instanceof HTMLElement)) return !1;
94
95
  let t = e.tagName;
95
96
  return t === "INPUT" || t === "TEXTAREA" || t === "SELECT" ? !0 : !!e.isContentEditable;
96
97
  }
97
- function x(e) {
98
+ function C(e) {
98
99
  let t = (e || "").trim();
99
100
  if (!t) return null;
100
- let n = m(t) ?? m(t[0] === "#" ? t : `#${t.replace(/^#/, "")}`);
101
+ let n = g(t) ?? g(t[0] === "#" ? t : `#${t.replace(/^#/, "")}`);
101
102
  if (n) return n;
102
103
  let r = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*([\d.]+))?\s*\)$/i.exec(t);
103
104
  if (r) {
104
- let e = u(Number(r[1]), 0, 255), t = u(Number(r[2]), 0, 255), n = u(Number(r[3]), 0, 255), i = r[4] === void 0 ? 1 : u(Number(r[4]), 0, 1);
105
+ let e = f(Number(r[1]), 0, 255), t = f(Number(r[2]), 0, 255), n = f(Number(r[3]), 0, 255), i = r[4] === void 0 ? 1 : f(Number(r[4]), 0, 1);
105
106
  return {
106
- ...p(e, t, n),
107
+ ...h(e, t, n),
107
108
  a: i
108
109
  };
109
110
  }
110
111
  return null;
111
112
  }
112
- function S() {
113
+ function w() {
113
114
  return typeof window < "u" && "EyeDropper" in window;
114
115
  }
115
- var C = {
116
+ var T = {
116
117
  h: 0,
117
118
  s: 1,
118
119
  v: .76,
119
120
  a: 1
120
121
  };
121
- function w({ value: u = "", form: d, onValue: f, onBlur: p, name: g = "", placeholder: _ = "#000000", label: v = "", error: S = "", hidden: w = !1, disabled: E = !1, className: D = "", after: O = "", before: k = "", colors: A, alpha: j = !0 }) {
122
- let { value: M } = n(d, g, u), N = typeof M == "string" ? M : M == null ? "" : String(M), [P, F] = i.useState(!1), [I, L] = i.useState(null), [R, z] = i.useState(() => m(N) ?? { ...C }), [B, V] = i.useState(() => h(m(N) ?? C, j)), H = A?.length ? A : l, U = m(N), W = U ?? (y(N) ? m(_) : null), G = U ? h(U, j) : "", K = W ? h(W, j) : "transparent";
123
- i.useEffect(() => {
124
- let e = m(N);
125
- e && (z(e), V(h(e, j)));
122
+ function E({ value: r = "", form: i, onValue: f, onBlur: p, name: m = "", placeholder: h = "#000000", label: v = "", error: y = "", hidden: b = !1, disabled: w = !1, className: E = "", after: O = "", before: k = "", colors: A, alpha: j = !0 }) {
123
+ let { value: M } = n(i, m, r), N = typeof M == "string" ? M : M == null ? "" : String(M), [P, F] = o.useState(!1), [I, L] = o.useState(null), [R, z] = o.useState(() => g(N) ?? { ...T }), [B, V] = o.useState(() => _(g(N) ?? T, j)), H = A?.length ? A : d, U = g(N), W = U ?? (x(N) ? g(h) : null), G = U ? _(U, j) : "", K = W ? _(W, j) : "transparent";
124
+ o.useEffect(() => {
125
+ let e = g(N);
126
+ e && (z(e), V(_(e, j)));
126
127
  }, [N, j]);
127
- let q = i.useCallback((e, t) => {
128
- let n = h(e, j), r = {
128
+ let q = o.useCallback((e, t) => {
129
+ let n = _(e, j), r = {
129
130
  value: n,
130
- name: g || ""
131
+ name: m || ""
131
132
  };
132
- d && g && (t === "live" ? d.onValue(r) : d.setValue(r)), f && f !== d?.onValue && f(r), V(n);
133
+ i && m && (t === "live" ? i.onValue(r) : i.setValue(r)), f && f !== i?.onValue && f(r), V(n);
133
134
  }, [
134
135
  j,
135
- d,
136
- g,
136
+ i,
137
+ m,
137
138
  f
138
139
  ]), J = (e) => {
139
- if (E) return;
140
- let t = m(N) ?? { ...R };
141
- z(t), V(h(t, j)), L(e.getBoundingClientRect()), F(!0);
140
+ if (w) return;
141
+ let t = g(N) ?? { ...R };
142
+ z(t), V(_(t, j)), L(e.getBoundingClientRect()), F(!0);
142
143
  }, Y = () => {
143
144
  F(!1), p?.({
144
- value: h(R, j),
145
- name: g || ""
145
+ value: _(R, j),
146
+ name: m || ""
146
147
  });
147
148
  };
148
- i.useEffect(() => {
149
- if (!P || E) return;
149
+ o.useEffect(() => {
150
+ if (!P || w) return;
150
151
  let e = "", t = (t) => {
151
- let n = x(t);
152
+ let n = C(t);
152
153
  if (!n) return !1;
153
154
  let r = {
154
155
  ...n,
155
156
  a: j ? n.a : 1
156
- }, i = h(r, j);
157
+ }, i = _(r, j);
157
158
  return i === e ? !0 : (e = i, z(r), q(r, "commit"), !0);
158
159
  }, n = (e) => {
159
- b(e.target) || t(e.clipboardData?.getData("text/plain") ?? "") && (e.preventDefault(), e.stopPropagation());
160
+ S(e.target) || t(e.clipboardData?.getData("text/plain") ?? "") && (e.preventDefault(), e.stopPropagation());
160
161
  }, r = (e) => {
161
- (e.ctrlKey || e.metaKey) && (e.key !== "v" && e.key !== "V" || b(e.target) || navigator.clipboard?.readText && (e.preventDefault(), navigator.clipboard.readText().then((e) => {
162
+ (e.ctrlKey || e.metaKey) && (e.key !== "v" && e.key !== "V" || S(e.target) || navigator.clipboard?.readText && (e.preventDefault(), navigator.clipboard.readText().then((e) => {
162
163
  t(e);
163
164
  })));
164
165
  };
@@ -167,12 +168,12 @@ function w({ value: u = "", form: d, onValue: f, onBlur: p, name: g = "", placeh
167
168
  };
168
169
  }, [
169
170
  P,
170
- E,
171
+ w,
171
172
  j,
172
173
  q
173
174
  ]);
174
175
  let X = (e) => {
175
- if (!E) {
176
+ if (!w) {
176
177
  if (!P && (e.key === "Enter" || e.key === " " || e.key === "ArrowDown")) {
177
178
  e.preventDefault(), J(e.currentTarget);
178
179
  return;
@@ -180,44 +181,44 @@ function w({ value: u = "", form: d, onValue: f, onBlur: p, name: g = "", placeh
180
181
  P && e.key === "Escape" && (e.preventDefault(), Y());
181
182
  }
182
183
  };
183
- return w && y(N) ? null : /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ s(t, {
184
+ return b && x(N) ? null : /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ l(t, {
184
185
  type: "color",
185
186
  label: v,
186
- error: S,
187
- element_blok: { className: [D || ""] },
187
+ error: y,
188
+ element_blok: { className: [E || ""] },
188
189
  element_input: {
189
190
  className: [e.w],
190
- props: { "data-disabled": E ? "true" : void 0 }
191
+ props: { "data-disabled": w ? "true" : void 0 }
191
192
  },
192
193
  children: [
193
- k ? /* @__PURE__ */ o("span", {
194
+ k ? /* @__PURE__ */ c("span", {
194
195
  className: e.affix,
195
196
  children: k
196
197
  }) : null,
197
- /* @__PURE__ */ s("div", {
198
- className: r.trigger,
198
+ /* @__PURE__ */ l("div", {
199
+ className: a.trigger,
199
200
  role: "combobox",
200
- tabIndex: E ? -1 : 0,
201
+ tabIndex: w ? -1 : 0,
201
202
  "aria-expanded": P,
202
203
  "aria-haspopup": "dialog",
203
- "aria-disabled": E,
204
+ "aria-disabled": w,
204
205
  "aria-label": v || "Цвет",
205
206
  onClick: (e) => J(e.currentTarget),
206
207
  onKeyDown: X,
207
- children: [/* @__PURE__ */ o("span", {
208
- className: r.preview,
208
+ children: [/* @__PURE__ */ c("span", {
209
+ className: a.preview,
209
210
  style: { "--preview-color": K }
210
- }), /* @__PURE__ */ o("span", {
211
- className: [r.hexText, G ? "" : r.placeholder].filter(Boolean).join(" "),
212
- children: G || _
211
+ }), /* @__PURE__ */ c("span", {
212
+ className: [a.hexText, G ? "" : a.placeholder].filter(Boolean).join(" "),
213
+ children: G || h
213
214
  })]
214
215
  }),
215
- O ? /* @__PURE__ */ o("span", {
216
+ O ? /* @__PURE__ */ c("span", {
216
217
  className: e.affix,
217
218
  children: O
218
219
  }) : null
219
220
  ]
220
- }), P && c(/* @__PURE__ */ o(T, {
221
+ }), P && u(/* @__PURE__ */ c(D, {
221
222
  parent: I || void 0,
222
223
  hsva: R,
223
224
  setHsva: z,
@@ -230,132 +231,135 @@ function w({ value: u = "", form: d, onValue: f, onBlur: p, name: g = "", placeh
230
231
  onClose: Y
231
232
  }), document.body)] });
232
233
  }
233
- w.displayName = "ColorField";
234
- function T({ parent: e, hsva: t, setHsva: n, hexDraft: i, setHexDraft: c, alpha: l, palette: d, onLive: f, onCommit: p, onClose: _ }) {
235
- if (!e) return null;
236
- let y = l ? 340 : 300, b = window.innerHeight - e.bottom < y + 8 ? Math.max(8, e.top - y - 8) : Math.min(window.innerHeight - y - 8, e.bottom + 8), x = Math.min(Math.max(8, e.left), window.innerWidth - 260 - 8), C = g({
234
+ E.displayName = "ColorField";
235
+ function D({ parent: e, hsva: t, setHsva: n, hexDraft: u, setHexDraft: d, alpha: p, palette: m, onLive: h, onCommit: y, onClose: x }) {
236
+ let [S] = o.useState(() => r());
237
+ if (o.useEffect(() => () => i(S), [S]), !e) return null;
238
+ let C = p ? 340 : 300, T = window.innerHeight - e.bottom < C + 8 ? Math.max(8, e.top - C - 8) : Math.min(window.innerHeight - C - 8, e.bottom + 8), E = Math.min(Math.max(8, e.left), window.innerWidth - 260 - 8), D = v({
237
239
  ...t,
238
240
  a: 1
239
- }), w = v(h(t, l)), T = (e, t) => {
240
- n(e), t === "live" ? f(e) : p(e);
241
- }, k = () => {
242
- let e = m(i);
241
+ }), j = b(_(t, p)), N = (e, t) => {
242
+ n(e), t === "live" ? h(e) : y(e);
243
+ }, P = () => {
244
+ let e = g(u);
243
245
  if (!e) {
244
- c(h(t, l));
246
+ d(_(t, p));
245
247
  return;
246
248
  }
247
- T(e, "commit");
248
- }, j = (e) => {
249
- let n = e.replace(/[^\d]/g, ""), r = u(Number(n || 0), 0, 100);
250
- T({
249
+ N(e, "commit");
250
+ }, F = (e) => {
251
+ let n = e.replace(/[^\d]/g, ""), r = f(Number(n || 0), 0, 100);
252
+ N({
251
253
  ...t,
252
254
  a: r / 100
253
255
  }, "commit");
254
- }, M = async () => {
255
- if (S()) try {
256
- let e = window.EyeDropper, n = m((await new e().open()).sRGBHex);
257
- n && T({
256
+ }, I = async () => {
257
+ if (w()) try {
258
+ let e = window.EyeDropper, n = g((await new e().open()).sRGBHex);
259
+ n && N({
258
260
  ...n,
259
261
  a: t.a
260
262
  }, "commit");
261
263
  } catch {}
262
264
  };
263
- return /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o("div", {
264
- className: r.o,
265
- onClick: _,
265
+ return /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("div", {
266
+ className: a.o,
267
+ style: { zIndex: S },
268
+ onClick: x,
266
269
  "aria-hidden": !0
267
- }), /* @__PURE__ */ s("div", {
268
- className: r.panel,
270
+ }), /* @__PURE__ */ l("div", {
271
+ className: a.panel,
269
272
  role: "dialog",
270
273
  "aria-label": "Выбор цвета",
271
274
  style: {
272
- top: b,
273
- left: x,
274
- width: 260
275
+ top: T,
276
+ left: E,
277
+ width: 260,
278
+ zIndex: S + 1
275
279
  },
276
280
  children: [
277
- /* @__PURE__ */ o(E, {
281
+ /* @__PURE__ */ c(O, {
278
282
  hsva: t,
279
- onChange: (e, n, r) => T({
283
+ onChange: (e, n, r) => N({
280
284
  ...t,
281
285
  s: e,
282
286
  v: n
283
287
  }, r)
284
288
  }),
285
- /* @__PURE__ */ s("div", {
286
- className: r.slidersRow,
287
- children: [S() ? /* @__PURE__ */ o("button", {
289
+ /* @__PURE__ */ l("div", {
290
+ className: a.slidersRow,
291
+ children: [w() ? /* @__PURE__ */ c("button", {
288
292
  type: "button",
289
- className: r.eyedropper,
293
+ className: a.eyedropper,
290
294
  "aria-label": "Пипетка",
291
- onClick: M,
292
- children: /* @__PURE__ */ o(A, {})
293
- }) : null, /* @__PURE__ */ s("div", {
294
- className: r.sliders,
295
- children: [/* @__PURE__ */ o(D, {
295
+ onClick: I,
296
+ children: /* @__PURE__ */ c(M, {})
297
+ }) : null, /* @__PURE__ */ l("div", {
298
+ className: a.sliders,
299
+ children: [/* @__PURE__ */ c(k, {
296
300
  h: t.h,
297
- onChange: (e, n) => T({
301
+ onChange: (e, n) => N({
298
302
  ...t,
299
303
  h: e
300
304
  }, n)
301
- }), l ? /* @__PURE__ */ o(O, {
305
+ }), p ? /* @__PURE__ */ c(A, {
302
306
  a: t.a,
303
- color: C,
304
- onChange: (e, n) => T({
307
+ color: D,
308
+ onChange: (e, n) => N({
305
309
  ...t,
306
310
  a: e
307
311
  }, n)
308
312
  }) : null]
309
313
  })]
310
314
  }),
311
- /* @__PURE__ */ s("div", {
312
- className: r.inputs,
315
+ /* @__PURE__ */ l("div", {
316
+ className: a.inputs,
313
317
  children: [
314
- /* @__PURE__ */ o("span", {
315
- className: r.format,
318
+ /* @__PURE__ */ c("span", {
319
+ className: a.format,
316
320
  children: "Hex"
317
321
  }),
318
- /* @__PURE__ */ o("input", {
319
- className: r.input,
320
- value: i.replace(/^#/, ""),
322
+ /* @__PURE__ */ c("input", {
323
+ className: a.input,
324
+ value: u.replace(/^#/, ""),
321
325
  spellCheck: !1,
322
326
  "aria-label": "Hex",
323
327
  onChange: (e) => {
324
328
  let t = e.target.value.replace(/[^0-9a-fA-F]/g, "");
325
- c(t ? `#${t}` : "");
329
+ d(t ? `#${t}` : "");
326
330
  },
327
- onBlur: k,
331
+ onBlur: P,
328
332
  onKeyDown: (e) => {
329
333
  e.key === "Enter" && (e.preventDefault(), e.target.blur());
330
334
  }
331
335
  }),
332
- l ? /* @__PURE__ */ o("input", {
333
- className: `${r.input} ${r.inputAlpha}`,
336
+ p ? /* @__PURE__ */ c("input", {
337
+ className: `${a.input} ${a.inputAlpha}`,
334
338
  value: `${Math.round(t.a * 100)} %`,
335
339
  "aria-label": "Прозрачность",
336
- onChange: (e) => j(e.target.value),
340
+ onChange: (e) => F(e.target.value),
337
341
  onFocus: (e) => e.target.select()
338
342
  }) : null
339
343
  ]
340
344
  }),
341
- /* @__PURE__ */ o("div", {
342
- className: r.palette,
345
+ /* @__PURE__ */ c("div", {
346
+ className: a.palette,
343
347
  role: "listbox",
344
348
  "aria-label": "Палитра",
345
- children: d.map((e) => {
346
- let t = v(e) === w;
347
- return /* @__PURE__ */ o("button", {
349
+ children: m.map((e) => {
350
+ let t = b(e) === j;
351
+ return /* @__PURE__ */ c("button", {
348
352
  type: "button",
349
353
  role: "option",
350
354
  "aria-checked": t,
351
355
  "aria-label": e,
352
- className: r.swatchBtn,
356
+ className: a.swatchBtn,
353
357
  style: { "--swatch": e },
354
358
  onClick: () => {
355
- let t = m(e);
356
- t && T({
359
+ let t = g(e);
360
+ t && N({
357
361
  ...t,
358
- a: l ? t.a : 1
362
+ a: p ? t.a : 1
359
363
  }, "commit");
360
364
  }
361
365
  }, e);
@@ -364,10 +368,10 @@ function T({ parent: e, hsva: t, setHsva: n, hexDraft: i, setHexDraft: c, alpha:
364
368
  ]
365
369
  })] });
366
370
  }
367
- function E({ hsva: e, onChange: t }) {
368
- let n = i.useRef(null), a = i.useRef(!1), c = i.useRef(t);
369
- c.current = t;
370
- let l = (t, r) => {
371
+ function O({ hsva: e, onChange: t }) {
372
+ let n = o.useRef(null), r = o.useRef(!1), i = o.useRef(t);
373
+ i.current = t;
374
+ let s = (t, r) => {
371
375
  let i = n.current;
372
376
  if (!i) return {
373
377
  s: e.s,
@@ -375,42 +379,42 @@ function E({ hsva: e, onChange: t }) {
375
379
  };
376
380
  let a = i.getBoundingClientRect();
377
381
  return {
378
- s: u((t - a.left) / a.width, 0, 1),
379
- v: u(1 - (r - a.top) / a.height, 0, 1)
382
+ s: f((t - a.left) / a.width, 0, 1),
383
+ v: f(1 - (r - a.top) / a.height, 0, 1)
380
384
  };
381
385
  };
382
- return i.useEffect(() => {
386
+ return o.useEffect(() => {
383
387
  let e = (e) => {
384
- if (!a.current) return;
385
- let { s: t, v: n } = l(e.clientX, e.clientY);
386
- c.current(t, n, "live");
388
+ if (!r.current) return;
389
+ let { s: t, v: n } = s(e.clientX, e.clientY);
390
+ i.current(t, n, "live");
387
391
  }, t = (e) => {
388
- if (!a.current) return;
389
- a.current = !1;
390
- let { s: t, v: n } = l(e.clientX, e.clientY);
391
- c.current(t, n, "commit");
392
+ if (!r.current) return;
393
+ r.current = !1;
394
+ let { s: t, v: n } = s(e.clientX, e.clientY);
395
+ i.current(t, n, "commit");
392
396
  };
393
397
  return window.addEventListener("pointermove", e), window.addEventListener("pointerup", t), () => {
394
398
  window.removeEventListener("pointermove", e), window.removeEventListener("pointerup", t);
395
399
  };
396
- }, []), /* @__PURE__ */ s("div", {
400
+ }, []), /* @__PURE__ */ l("div", {
397
401
  ref: n,
398
- className: r.sv,
399
- style: { background: _(e.h) },
402
+ className: a.sv,
403
+ style: { background: y(e.h) },
400
404
  onPointerDown: (e) => {
401
- a.current = !0;
402
- let { s: t, v: n } = l(e.clientX, e.clientY);
403
- c.current(t, n, "live");
405
+ r.current = !0;
406
+ let { s: t, v: n } = s(e.clientX, e.clientY);
407
+ i.current(t, n, "live");
404
408
  },
405
409
  children: [
406
- /* @__PURE__ */ o("div", { className: r.svWhite }),
407
- /* @__PURE__ */ o("div", { className: r.svBlack }),
408
- /* @__PURE__ */ o("div", {
409
- className: r.handle,
410
+ /* @__PURE__ */ c("div", { className: a.svWhite }),
411
+ /* @__PURE__ */ c("div", { className: a.svBlack }),
412
+ /* @__PURE__ */ c("div", {
413
+ className: a.handle,
410
414
  style: {
411
415
  left: `${e.s * 100}%`,
412
416
  top: `${(1 - e.v) * 100}%`,
413
- background: g({
417
+ background: v({
414
418
  ...e,
415
419
  a: 1
416
420
  })
@@ -419,57 +423,57 @@ function E({ hsva: e, onChange: t }) {
419
423
  ]
420
424
  });
421
425
  }
422
- function D({ h: e, onChange: t }) {
423
- return /* @__PURE__ */ o(k, {
424
- className: `${r.slider} ${r.sliderHue}`,
426
+ function k({ h: e, onChange: t }) {
427
+ return /* @__PURE__ */ c(j, {
428
+ className: `${a.slider} ${a.sliderHue}`,
425
429
  ratio: e / 360,
426
430
  onRatio: (e, n) => t(e * 360, n),
427
- handleColor: _(e)
431
+ handleColor: y(e)
428
432
  });
429
433
  }
430
- function O({ a: e, color: t, onChange: n }) {
431
- return /* @__PURE__ */ o(k, {
432
- className: `${r.slider} ${r.sliderAlpha}`,
434
+ function A({ a: e, color: t, onChange: n }) {
435
+ return /* @__PURE__ */ c(j, {
436
+ className: `${a.slider} ${a.sliderAlpha}`,
433
437
  style: { "--alpha-color": t },
434
438
  ratio: e,
435
439
  onRatio: n,
436
440
  handleColor: t
437
441
  });
438
442
  }
439
- function k({ className: e, style: t, ratio: n, onRatio: a, handleColor: s }) {
440
- let c = i.useRef(null), l = i.useRef(!1), d = (e, t) => {
441
- let n = c.current;
443
+ function j({ className: e, style: t, ratio: n, onRatio: r, handleColor: i }) {
444
+ let s = o.useRef(null), l = o.useRef(!1), u = (e, t) => {
445
+ let n = s.current;
442
446
  if (!n) return;
443
- let r = n.getBoundingClientRect();
444
- a(u((e - r.left) / r.width, 0, 1), t);
447
+ let i = n.getBoundingClientRect();
448
+ r(f((e - i.left) / i.width, 0, 1), t);
445
449
  };
446
- return i.useEffect(() => {
450
+ return o.useEffect(() => {
447
451
  let e = (e) => {
448
- l.current && d(e.clientX, "live");
452
+ l.current && u(e.clientX, "live");
449
453
  }, t = (e) => {
450
- l.current && (l.current = !1, d(e.clientX, "commit"));
454
+ l.current && (l.current = !1, u(e.clientX, "commit"));
451
455
  };
452
456
  return window.addEventListener("pointermove", e), window.addEventListener("pointerup", t), () => {
453
457
  window.removeEventListener("pointermove", e), window.removeEventListener("pointerup", t);
454
458
  };
455
- }, [a]), /* @__PURE__ */ o("div", {
456
- ref: c,
459
+ }, [r]), /* @__PURE__ */ c("div", {
460
+ ref: s,
457
461
  className: e,
458
462
  style: t,
459
463
  onPointerDown: (e) => {
460
- l.current = !0, d(e.clientX, "live");
464
+ l.current = !0, u(e.clientX, "live");
461
465
  },
462
- children: /* @__PURE__ */ o("div", {
463
- className: r.sliderHandle,
466
+ children: /* @__PURE__ */ c("div", {
467
+ className: a.sliderHandle,
464
468
  style: {
465
- left: `${u(n, 0, 1) * 100}%`,
466
- background: s
469
+ left: `${f(n, 0, 1) * 100}%`,
470
+ background: i
467
471
  }
468
472
  })
469
473
  });
470
474
  }
471
- function A() {
472
- return /* @__PURE__ */ s("svg", {
475
+ function M() {
476
+ return /* @__PURE__ */ l("svg", {
473
477
  width: "16",
474
478
  height: "16",
475
479
  viewBox: "0 0 24 24",
@@ -480,12 +484,12 @@ function A() {
480
484
  strokeLinejoin: "round",
481
485
  "aria-hidden": !0,
482
486
  children: [
483
- /* @__PURE__ */ o("path", { d: "m2 22 1-1h3l9-9" }),
484
- /* @__PURE__ */ o("path", { d: "M3 21v-3l9-9" }),
485
- /* @__PURE__ */ o("path", { d: "m15 5 3 3" }),
486
- /* @__PURE__ */ o("path", { d: "M17.5 2.5a2.12 2.12 0 0 1 3 3L12 14l-4 1 1-4Z" })
487
+ /* @__PURE__ */ c("path", { d: "m2 22 1-1h3l9-9" }),
488
+ /* @__PURE__ */ c("path", { d: "M3 21v-3l9-9" }),
489
+ /* @__PURE__ */ c("path", { d: "m15 5 3 3" }),
490
+ /* @__PURE__ */ c("path", { d: "M17.5 2.5a2.12 2.12 0 0 1 3 3L12 14l-4 1 1-4Z" })
487
491
  ]
488
492
  });
489
493
  }
490
494
  //#endregion
491
- export { l as DEFAULT_COLOR_PALETTE, w as default };
495
+ export { d as DEFAULT_COLOR_PALETTE, E as default };