@spear-ai/spectral 1.9.0 → 1.9.1

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.
@@ -15,8 +15,8 @@ const v = {
15
15
  hour24: { type: "hour", min: 0, max: 23, length: 2 },
16
16
  minute: { type: "minute", min: 0, max: 59, length: 2 },
17
17
  period: { type: "period", min: 0, max: 1, length: 2 }
18
- }, ue = (k, e) => k === 2 ? e % 4 === 0 && e % 100 !== 0 || e % 400 === 0 ? 29 : 28 : [4, 6, 9, 11].includes(k) ? 30 : 31, ce = ({ ariaLabel: k, config: e, disabled: y, onLeftFocus: N, onRightFocus: m, onValueChange: o, periodLabels: h, value: s }) => {
19
- const u = E(null), a = E(""), c = E(!1), I = D(() => {
18
+ }, ue = (k, e) => k === 2 ? e % 4 === 0 && e % 100 !== 0 || e % 400 === 0 ? 29 : 28 : [4, 6, 9, 11].includes(k) ? 30 : 31, ce = ({ ariaLabel: k, config: e, disabled: y, onLeftFocus: I, onRightFocus: m, onValueChange: u, periodLabels: h, value: s }) => {
19
+ const o = E(null), a = E(""), c = E(!1), M = D(() => {
20
20
  switch (e.type) {
21
21
  case "month":
22
22
  return "MM";
@@ -33,18 +33,18 @@ const v = {
33
33
  default:
34
34
  return "––";
35
35
  }
36
- }, [e.type, e.max, h]), d = D(() => s === void 0 ? I : e.type === "period" ? (s === 0 ? h?.am ?? "am" : h?.pm ?? "pm").toLowerCase() : s.toString().padStart(e.length, "0"), [s, e, h, I]);
36
+ }, [e.type, e.max, h]), d = D(() => s === void 0 ? M : e.type === "period" ? (s === 0 ? h?.am ?? "am" : h?.pm ?? "pm").toLowerCase() : s.toString().padStart(e.length, "0"), [s, e, h, M]);
37
37
  oe(() => {
38
- u.current && !c.current && (u.current.value = d);
38
+ o.current && !c.current && (o.current.value = d);
39
39
  }, [d]);
40
40
  const x = w(() => {
41
41
  const t = a.current;
42
42
  if (t) {
43
43
  let r = parseInt(t, 10);
44
- isNaN(r) || (r = Math.max(e.min, Math.min(e.max, r)), o(r));
44
+ isNaN(r) || (r = Math.max(e.min, Math.min(e.max, r)), u(r));
45
45
  }
46
- a.current = "", c.current = !1, u.current && (u.current.value = d);
47
- }, [e.min, e.max, d, o]), R = w(
46
+ a.current = "", c.current = !1, o.current && (o.current.value = d);
47
+ }, [e.min, e.max, d, u]), R = w(
48
48
  (t) => {
49
49
  if (!y) {
50
50
  if (t.key === "Tab") {
@@ -56,31 +56,31 @@ const v = {
56
56
  return;
57
57
  }
58
58
  if (t.key === "ArrowLeft") {
59
- t.preventDefault(), x(), N?.();
59
+ t.preventDefault(), x(), I?.();
60
60
  return;
61
61
  }
62
62
  if (e.type === "period") {
63
- t.preventDefault(), t.key === "ArrowUp" || t.key === "ArrowDown" ? o(s === 0 ? 1 : 0) : t.key.toLowerCase() === "a" ? o(0) : t.key.toLowerCase() === "p" && o(1);
63
+ t.preventDefault(), t.key === "ArrowUp" || t.key === "ArrowDown" ? u(s === 0 ? 1 : 0) : t.key.toLowerCase() === "a" ? u(0) : t.key.toLowerCase() === "p" && u(1);
64
64
  return;
65
65
  }
66
66
  if (t.key === "ArrowUp") {
67
67
  t.preventDefault(), a.current = "", c.current = !1;
68
68
  const r = s === void 0 || s >= e.max ? e.min : s + 1;
69
- o(r);
69
+ u(r);
70
70
  return;
71
71
  }
72
72
  if (t.key === "ArrowDown") {
73
73
  t.preventDefault(), a.current = "", c.current = !1;
74
74
  const r = s === void 0 || s <= e.min ? e.max : s - 1;
75
- o(r);
75
+ u(r);
76
76
  return;
77
77
  }
78
78
  if (t.key === "Home") {
79
- t.preventDefault(), a.current = "", c.current = !1, o(e.min);
79
+ t.preventDefault(), a.current = "", c.current = !1, u(e.min);
80
80
  return;
81
81
  }
82
82
  if (t.key === "End") {
83
- t.preventDefault(), a.current = "", c.current = !1, o(e.max);
83
+ t.preventDefault(), a.current = "", c.current = !1, u(e.max);
84
84
  return;
85
85
  }
86
86
  if (t.key >= "0" && t.key <= "9") {
@@ -89,38 +89,39 @@ const v = {
89
89
  if (e.length === 2)
90
90
  if (r.length >= 2) {
91
91
  const L = Math.max(e.min, Math.min(e.max, l));
92
- a.current = "", c.current = !1, o(L), m?.();
92
+ a.current = "", c.current = !1, u(L), m?.();
93
93
  } else if (l * 10 > e.max) {
94
94
  const L = Math.max(e.min, Math.min(e.max, l));
95
- a.current = "", c.current = !1, o(L), m?.();
95
+ a.current = "", c.current = !1, u(L), m?.();
96
96
  } else
97
- a.current = r, c.current = !0, u.current && (u.current.value = r);
97
+ a.current = r, c.current = !0, o.current && (o.current.value = r);
98
98
  else if (e.length === 4)
99
99
  if (r.length >= 4) {
100
100
  const L = Math.max(e.min, Math.min(e.max, l));
101
- a.current = "", c.current = !1, o(L), m?.();
101
+ a.current = "", c.current = !1, u(L), m?.();
102
102
  } else
103
- a.current = r, c.current = !0, u.current && (u.current.value = r);
103
+ a.current = r, c.current = !0, o.current && (o.current.value = r);
104
104
  return;
105
105
  }
106
- if (t.key === "Backspace" && (t.preventDefault(), a.current)) {
107
- const r = a.current.slice(0, -1);
108
- a.current = r, c.current = r.length > 0, u.current && (u.current.value = r || d);
109
- }
106
+ if (t.key === "Backspace")
107
+ if (t.preventDefault(), a.current) {
108
+ const r = a.current.slice(0, -1);
109
+ a.current = r, c.current = r.length > 0, o.current && (o.current.value = r || d);
110
+ } else s !== void 0 && (a.current = "", c.current = !0, u(e.min), o.current && (o.current.value = M));
110
111
  }
111
112
  },
112
- [y, e, s, d, o, N, m, x]
113
+ [y, e, s, d, M, u, I, m, x]
113
114
  ), T = w(() => {
114
115
  a.current && x();
115
- }, [x]), g = w(() => {
116
+ }, [x]), S = w(() => {
116
117
  c.current || (a.current = "");
117
- const t = u.current;
118
+ const t = o.current;
118
119
  if (t) {
119
120
  const r = t.value.length;
120
121
  t.setSelectionRange(r, r);
121
122
  }
122
123
  }, []), Y = w(() => {
123
- u.current && (u.current.value = a.current || d);
124
+ o.current && (o.current.value = a.current || d);
124
125
  }, [d]), H = w(() => {
125
126
  switch (e.type) {
126
127
  case "year":
@@ -138,7 +139,7 @@ const v = {
138
139
  default:
139
140
  return { width: 24, paddingLeft: 0 };
140
141
  }
141
- }, [e.type]), p = D(() => H(), [H]), M = D(() => s === void 0, [s]);
142
+ }, [e.type]), p = D(() => H(), [H]), g = D(() => s === void 0, [s]);
142
143
  return /* @__PURE__ */ b(
143
144
  "input",
144
145
  {
@@ -152,7 +153,7 @@ const v = {
152
153
  "focus:bg-bg-tertiary focus:text-text-primary focus:ring-accent focus:ring-1",
153
154
  "hover:bg-bg-secondary",
154
155
  y && "cursor-not-allowed opacity-50",
155
- M && "text-text-placeholder text-sm"
156
+ g && "text-text-placeholder text-sm"
156
157
  ),
157
158
  "data-segment": e.type,
158
159
  defaultValue: d,
@@ -160,9 +161,9 @@ const v = {
160
161
  inputMode: "numeric",
161
162
  onBlur: T,
162
163
  onChange: Y,
163
- onFocus: g,
164
+ onFocus: S,
164
165
  onKeyDown: R,
165
- ref: u,
166
+ ref: o,
166
167
  role: "spinbutton",
167
168
  style: p,
168
169
  tabIndex: y ? -1 : 0
@@ -173,21 +174,21 @@ const v = {
173
174
  className: k,
174
175
  defaultValue: e,
175
176
  disabled: y,
176
- endIcon: N,
177
+ endIcon: I,
177
178
  hourFormat: m = "12",
178
- id: o,
179
+ id: u,
179
180
  label: h,
180
181
  locale: s,
181
- onChange: u,
182
+ onChange: o,
182
183
  showTime: a = !0,
183
184
  state: c = "default",
184
- value: I,
185
+ value: M,
185
186
  // Legacy props (deprecated)
186
187
  date: d,
187
188
  onDateChange: x,
188
189
  ...R
189
190
  }, T) => {
190
- const g = E(null), Y = I ?? d, H = u ?? x, [p, M] = ae({
191
+ const S = E(null), Y = M ?? d, H = o ?? x, [p, g] = ae({
191
192
  defaultValue: e,
192
193
  onChange: H,
193
194
  value: Y
@@ -207,21 +208,21 @@ const v = {
207
208
  (i) => {
208
209
  const n = { ...l, ...i };
209
210
  if (n.month === void 0 && n.day === void 0 && n.year === void 0) {
210
- M(void 0);
211
+ g(void 0);
211
212
  return;
212
213
  }
213
- const f = /* @__PURE__ */ new Date(), A = (n.month ?? f.getMonth() + 1) - 1, P = n.day ?? f.getDate(), S = n.year ?? f.getFullYear(), j = ue(A + 1, S), G = Math.min(P, j), W = l.month !== void 0 && l.day !== void 0 && l.year !== void 0, X = n.month !== void 0 && n.day !== void 0 && n.year !== void 0, C = !W && X;
214
- let B;
214
+ const f = /* @__PURE__ */ new Date(), A = (n.month ?? f.getMonth() + 1) - 1, P = n.day ?? f.getDate(), N = n.year ?? f.getFullYear(), j = ue(A + 1, N), G = Math.min(P, j), W = l.month !== void 0 && l.day !== void 0 && l.year !== void 0, X = n.month !== void 0 && n.day !== void 0 && n.year !== void 0, B = !W && X;
215
+ let C;
215
216
  if (m === "24")
216
- B = C ? 0 : n.hour ?? 0;
217
+ C = B ? 0 : n.hour ?? 0;
217
218
  else {
218
- const F = C ? 12 : n.hour ?? 12, V = C ? 1 : n.period ?? 0, K = F, J = V;
219
- K === 12 ? B = J === 0 ? 0 : 12 : B = J === 0 ? K : K + 12;
219
+ const F = B ? 12 : n.hour ?? 12, V = B ? 1 : n.period ?? 0, K = F, J = V;
220
+ K === 12 ? C = J === 0 ? 0 : 12 : C = J === 0 ? K : K + 12;
220
221
  }
221
- const Z = C ? 0 : n.minute ?? 0, $ = new Date(S, A, G, B, Z, 0, 0);
222
- M($);
222
+ const Z = B ? 0 : n.minute ?? 0, $ = new Date(N, A, G, C, Z, 0, 0);
223
+ g($);
223
224
  },
224
- [l, m, M]
225
+ [l, m, g]
225
226
  ), q = D(() => {
226
227
  const i = [
227
228
  { key: "month", config: v.month, ariaLabel: "Month" },
@@ -239,15 +240,15 @@ const v = {
239
240
  ];
240
241
  return [...i, ...n];
241
242
  }, [a, m, r]), z = w((i) => {
242
- g.current?.querySelectorAll("[role='spinbutton']")[i]?.focus();
243
+ S.current?.querySelectorAll("[role='spinbutton']")[i]?.focus();
243
244
  }, []), Q = U(ie(c, k));
244
245
  return /* @__PURE__ */ O("div", { className: "flex flex-col gap-1.5", children: [
245
- h && /* @__PURE__ */ b(ne, { className: "text-text-primary text-sm font-medium", htmlFor: o, children: h }),
246
- /* @__PURE__ */ O("div", { className: U(Q, "relative", (y ?? c === "disabled") && "cursor-not-allowed", k), "data-slot": "datetime-display-input", id: o ?? "datetime-display-input", ref: T ?? g, ...R, children: [
247
- /* @__PURE__ */ b("div", { className: "flex items-center", ref: g, children: q.map((i, n) => {
248
- const f = ["month", "day", "year"].includes(i.key), A = ["hour", "minute", "period"].includes(i.key), P = i.key === "year", S = i.key === "hour", j = y ?? (A && !L);
246
+ h && /* @__PURE__ */ b(ne, { className: "text-text-primary text-sm font-medium", htmlFor: u, children: h }),
247
+ /* @__PURE__ */ O("div", { className: U(Q, "relative", (y ?? c === "disabled") && "cursor-not-allowed", k), "data-slot": "datetime-display-input", id: u ?? "datetime-display-input", ref: T ?? S, ...R, children: [
248
+ /* @__PURE__ */ b("div", { className: "flex items-center", ref: S, children: q.map((i, n) => {
249
+ const f = ["month", "day", "year"].includes(i.key), A = ["hour", "minute", "period"].includes(i.key), P = i.key === "year", N = i.key === "hour", j = y ?? (A && !L);
249
250
  return /* @__PURE__ */ O("span", { className: "flex items-center", children: [
250
- S && /* @__PURE__ */ b("span", { "aria-hidden": "true", className: "text-text-secondary select-none", children: ", " }),
251
+ N && /* @__PURE__ */ b("span", { "aria-hidden": "true", className: "text-text-secondary select-none", children: ", " }),
251
252
  /* @__PURE__ */ b(
252
253
  ce,
253
254
  {
@@ -262,10 +263,10 @@ const v = {
262
263
  }
263
264
  ),
264
265
  f && !P && /* @__PURE__ */ b("span", { "aria-hidden": "true", className: "text-text-secondary select-none", children: "/" }),
265
- S && /* @__PURE__ */ b("span", { "aria-hidden": "true", className: "text-inherit select-none", children: ":" })
266
+ N && /* @__PURE__ */ b("span", { "aria-hidden": "true", className: "text-inherit select-none", children: ":" })
266
267
  ] }, i.key);
267
268
  }) }),
268
- N
269
+ I
269
270
  ] })
270
271
  ] });
271
272
  }
@@ -1,6 +1,6 @@
1
1
  import { Period, TimePickerTranslations, TimePickerType } from './DateTimeUtils';
2
- import { ComponentProps } from 'react';
3
- export interface DateTimeInputProps extends Omit<ComponentProps<'input'>, 'onChange'> {
2
+ import { ComponentProps, Ref } from 'react';
3
+ export interface DateTimeInputProps extends Omit<ComponentProps<'input'>, 'onChange' | 'type'> {
4
4
  date: Date | undefined;
5
5
  /** Locale for number formatting */
6
6
  locale?: string;
@@ -13,7 +13,9 @@ export interface DateTimeInputProps extends Omit<ComponentProps<'input'>, 'onCha
13
13
  translations?: TimePickerTranslations;
14
14
  }
15
15
  export declare const DateTimeInput: {
16
- ({ className, date, disabled, id, locale, name, onKeyDown, onLeftFocus, onRightFocus, period, picker, setDate, translations, ...props }: DateTimeInputProps): import("react/jsx-runtime").JSX.Element;
16
+ ({ className, date, disabled, id, locale, name, onKeyDown, onLeftFocus, onRightFocus, period, picker, ref, setDate, translations, ...props }: DateTimeInputProps & {
17
+ ref?: Ref<HTMLInputElement>;
18
+ }): import("react/jsx-runtime").JSX.Element;
17
19
  displayName: string;
18
20
  };
19
21
  //# sourceMappingURL=DateTimeInput.d.ts.map
@@ -1,91 +1,144 @@
1
1
  "use client";
2
2
  import "../styles/main.css";
3
- import { jsx as K } from "react/jsx-runtime";
4
- import { getResolvedLocale as B, getDateByType as O, formatTimeNumber as R, getAriaValueMinMax as p, getAriaValueNow as _, getAriaLabel as P, DEFAULT_TRANSLATIONS as j, getArrowByType as C, setDateByType as c } from "./DateTimeUtils.js";
5
- import { Input as G } from "../primitives/input.js";
6
- import { cn as W } from "../utils/twUtils.js";
7
- import { useState as x, useMemo as i, useEffect as Y, useCallback as N } from "react";
8
- const q = 2e3, z = ({ className: V, date: f, disabled: b, id: S, locale: A, name: E, onKeyDown: L, onLeftFocus: T, onRightFocus: w, period: l, picker: e, setDate: m, translations: d = j, ...M }) => {
9
- const [n, y] = x(!1), [v, U] = x("0"), g = i(() => B(A), [A]), a = i(() => {
10
- if (f) return f;
3
+ import { jsx as C } from "react/jsx-runtime";
4
+ import { getResolvedLocale as P, getAriaValueMinMax as _, getDateByType as $, formatTimeNumber as v, getAriaValueNow as k, getAriaLabel as q, DEFAULT_TRANSLATIONS as z, setDateByType as x, getArrowByType as G } from "./DateTimeUtils.js";
5
+ import { Input as J } from "../primitives/input.js";
6
+ import { cn as Q } from "../utils/twUtils.js";
7
+ import { useRef as V, useMemo as y, useEffect as W, useCallback as M } from "react";
8
+ const X = (...N) => (m) => {
9
+ N.forEach((p) => {
10
+ p && (typeof p == "function" ? p(m) : p.current = m);
11
+ });
12
+ }, Y = ({ className: N, date: m, disabled: p, id: B, locale: A, name: b, onKeyDown: R, onLeftFocus: I, onRightFocus: g, period: w, picker: r, ref: E, setDate: D, translations: T = z, ...L }) => {
13
+ const o = V(null), H = X(o, E), n = V(""), i = V(!1), d = y(() => P(A), [A]), s = y(() => {
14
+ if (m) return m;
11
15
  const t = /* @__PURE__ */ new Date();
12
16
  return t.setHours(0, 0, 0, 0), t;
13
- }, [f]), r = i(() => O(a, e), [a, e]), D = i(() => R(parseInt(r, 10), g), [r, g]), $ = i(() => {
14
- const { min: t, max: o } = p(e);
15
- return {
16
- "aria-label": P(e, d),
17
- "aria-valuemin": t,
18
- "aria-valuemax": o,
19
- "aria-valuenow": _(a, e),
20
- "aria-valuetext": D
21
- };
22
- }, [a, e, D, d]);
23
- Y(() => {
24
- if (!n) return;
25
- const t = setTimeout(() => {
26
- y(!1);
27
- }, q);
28
- return () => clearTimeout(t);
29
- }, [n]);
30
- const I = N(
31
- (t) => e === "12hours" && n && r.startsWith("1") && v === "0" ? `0${t}` : n ? `${r[1]}${t}` : `0${t}`,
32
- [e, n, r, v]
33
- ), h = N(
17
+ }, [m]), { min: u, max: c } = y(() => _(r), [r]), h = y(() => $(s, r), [s, r]), f = y(() => v(parseInt(h, 10), d), [h, d]), U = y(
18
+ () => ({
19
+ "aria-label": q(r, T),
20
+ "aria-valuemin": u,
21
+ "aria-valuemax": c,
22
+ "aria-valuenow": k(s, r),
23
+ "aria-valuetext": f
24
+ }),
25
+ [s, r, f, T, u, c]
26
+ );
27
+ W(() => {
28
+ o.current && !i.current && (o.current.value = f);
29
+ }, [f]);
30
+ const l = M(
34
31
  (t) => {
35
- if (t.key !== "Tab") {
36
- if ((["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Home", "End"].includes(t.key) || t.key >= "0" && t.key <= "9") && t.preventDefault(), t.key === "ArrowRight") {
37
- w?.();
38
- return;
39
- }
40
- if (t.key === "ArrowLeft") {
41
- T?.();
42
- return;
43
- }
44
- if (t.key === "ArrowUp" || t.key === "ArrowDown") {
45
- const o = t.key === "ArrowUp" ? 1 : -1, s = C(o, e, r);
46
- n && y(!1);
47
- const u = new Date(a);
48
- m(c(u, e, s, l));
49
- return;
32
+ n.current = "", i.current = !1;
33
+ const e = new Date(s);
34
+ D(x(e, r, t, w));
35
+ },
36
+ [s, r, w, D]
37
+ ), K = M(
38
+ (t) => {
39
+ if (t.key === "Tab") {
40
+ if (n.current) {
41
+ const e = parseInt(n.current, 10);
42
+ if (!isNaN(e)) {
43
+ const a = Math.max(u, Math.min(c, e));
44
+ l(a.toString().padStart(2, "0"));
45
+ }
50
46
  }
51
- if (t.key === "Home" || t.key === "End") {
52
- const { min: o, max: s } = p(e), u = (t.key === "Home" ? o : s).toString().padStart(2, "0"), H = new Date(a);
53
- m(c(H, e, u, l));
54
- return;
47
+ return;
48
+ }
49
+ if (t.key === "ArrowRight") {
50
+ if (t.preventDefault(), n.current) {
51
+ const e = parseInt(n.current, 10);
52
+ if (!isNaN(e)) {
53
+ const a = Math.max(u, Math.min(c, e));
54
+ l(a.toString().padStart(2, "0"));
55
+ }
55
56
  }
56
- if (t.key >= "0" && t.key <= "9") {
57
- e === "12hours" && U(t.key);
58
- const o = I(t.key);
59
- n && w?.(), y((u) => !u);
60
- const s = new Date(a);
61
- m(c(s, e, o, l));
57
+ g?.();
58
+ return;
59
+ }
60
+ if (t.key === "ArrowLeft") {
61
+ if (t.preventDefault(), n.current) {
62
+ const e = parseInt(n.current, 10);
63
+ if (!isNaN(e)) {
64
+ const a = Math.max(u, Math.min(c, e));
65
+ l(a.toString().padStart(2, "0"));
66
+ }
62
67
  }
68
+ I?.();
69
+ return;
63
70
  }
71
+ if (t.key === "ArrowUp" || t.key === "ArrowDown") {
72
+ t.preventDefault(), n.current = "", i.current = !1;
73
+ const e = t.key === "ArrowUp" ? 1 : -1, a = G(e, r, h), S = new Date(s);
74
+ D(x(S, r, a, w));
75
+ return;
76
+ }
77
+ if (t.key === "Home" || t.key === "End") {
78
+ t.preventDefault(), n.current = "", i.current = !1;
79
+ const e = (t.key === "Home" ? u : c).toString().padStart(2, "0"), a = new Date(s);
80
+ D(x(a, r, e, w));
81
+ return;
82
+ }
83
+ if (t.key >= "0" && t.key <= "9") {
84
+ t.preventDefault();
85
+ const e = n.current + t.key, a = parseInt(e, 10);
86
+ if (e.length >= 2) {
87
+ const S = Math.max(u, Math.min(c, a));
88
+ l(S.toString().padStart(2, "0")), g?.();
89
+ } else if (a * 10 > c) {
90
+ const S = Math.max(u, Math.min(c, a));
91
+ l(S.toString().padStart(2, "0")), g?.();
92
+ } else
93
+ n.current = e, i.current = !0, o.current && (o.current.value = v(a, d));
94
+ return;
95
+ }
96
+ if (t.key === "Backspace")
97
+ if (t.preventDefault(), n.current) {
98
+ const e = n.current.slice(0, -1);
99
+ n.current = e, i.current = e.length > 0, o.current && (o.current.value = e ? v(parseInt(e, 10), d) : f);
100
+ } else
101
+ n.current = "", l(u.toString().padStart(2, "0")), o.current && (o.current.value = v(u, d));
64
102
  },
65
- [I, r, a, n, T, w, l, e, m]
66
- );
67
- return /* @__PURE__ */ K(
68
- G,
103
+ [h, s, u, c, I, g, w, r, D, l, f, d]
104
+ ), O = M(() => {
105
+ i.current || (n.current = "");
106
+ }, []), j = M(() => {
107
+ if (n.current) {
108
+ const t = parseInt(n.current, 10);
109
+ if (isNaN(t))
110
+ n.current = "", i.current = !1;
111
+ else {
112
+ const e = Math.max(u, Math.min(c, t));
113
+ l(e.toString().padStart(2, "0"));
114
+ }
115
+ }
116
+ }, [u, c, l]);
117
+ return /* @__PURE__ */ C(
118
+ J,
69
119
  {
70
- className: W("text-center tabular-nums", V),
120
+ className: Q("text-center tabular-nums", N),
71
121
  "data-slot": "datetime-input",
72
- "data-testid": `spectral-datetime-input-${e}`,
73
- disabled: b,
74
- id: S ?? e,
122
+ "data-testid": `spectral-datetime-input-${r}`,
123
+ defaultValue: f,
124
+ disabled: p,
125
+ id: B ?? r,
75
126
  inputMode: "numeric",
76
- name: E ?? e,
127
+ name: b ?? r,
128
+ onBlur: j,
129
+ onFocus: O,
77
130
  onKeyDown: (t) => {
78
- L?.(t), h(t);
131
+ R?.(t), K(t);
79
132
  },
80
133
  readOnly: !0,
134
+ ref: H,
81
135
  role: "spinbutton",
82
- value: D,
83
- ...$,
84
- ...M
136
+ ...U,
137
+ ...L
85
138
  }
86
139
  );
87
140
  };
88
- z.displayName = "DateTimeInput";
141
+ Y.displayName = "DateTimeInput";
89
142
  export {
90
- z as DateTimeInput
143
+ Y as DateTimeInput
91
144
  };
@@ -9,7 +9,7 @@ interface IconBaseProps extends Omit<IconProps, 'strokeWidth'>, ComponentPropsWi
9
9
  title?: string;
10
10
  color?: string;
11
11
  }
12
- declare const IconBase: ({ ref, children, title, size, ariaHidden, description, className, disabled, ...rest }: IconBaseProps & {
12
+ declare const IconBase: ({ ref, children, title, size, ariaHidden, description, className, disabled, onClick, onKeyDown, role, tabIndex, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...rest }: IconBaseProps & {
13
13
  ref?: Ref<SVGSVGElement>;
14
14
  }) => import("react/jsx-runtime").JSX.Element;
15
15
  export default IconBase;
@@ -1,26 +1,69 @@
1
1
  "use client";
2
2
  import "../styles/main.css";
3
- import { jsxs as x, jsx as t } from "react/jsx-runtime";
4
- import { createContext as B, useId as b } from "react";
5
- const g = B(""), A = function({
6
- ref: c,
7
- children: a,
8
- title: o,
9
- size: i = 24,
10
- ariaHidden: r = !0,
11
- description: d,
12
- className: h,
13
- disabled: f,
14
- ...v
3
+ import { jsxs as _, jsx as u } from "react/jsx-runtime";
4
+ import { createContext as D, useId as O, useCallback as w } from "react";
5
+ const P = D(""), S = function({
6
+ ref: x,
7
+ children: g,
8
+ title: c,
9
+ size: b = 24,
10
+ ariaHidden: p = !0,
11
+ description: s,
12
+ className: B,
13
+ disabled: n,
14
+ onClick: i,
15
+ onKeyDown: l,
16
+ role: y,
17
+ tabIndex: k,
18
+ "aria-label": h,
19
+ "aria-labelledby": f,
20
+ ...E
15
21
  }) {
16
- const s = b(), e = o !== void 0 ? !1 : r, l = !e && o ? `${s}_title` : "", n = !e && d ? `${s}_desc` : "", u = [l, n].filter(Boolean).join(" ") || void 0;
17
- return /* @__PURE__ */ x("svg", { "aria-hidden": e, "aria-labelledby": u, className: h, "data-disabled": f, fill: "none", height: i, ref: c, role: "img", viewBox: "0 0 24 24", width: i, xmlns: "http://www.w3.org/2000/svg", ...v, children: [
18
- !e && o && /* @__PURE__ */ t("title", { id: l, children: o }),
19
- !e && d && /* @__PURE__ */ t("desc", { id: n, children: d }),
20
- /* @__PURE__ */ t(g.Provider, { value: s, children: a })
21
- ] });
22
+ const r = O(), t = i !== void 0, o = t && !n, d = c !== void 0 || !!h || !!f;
23
+ process.env.NODE_ENV !== "production" && t && !d && console.warn("IconBase: an onClick handler was provided without an accessible name (title, aria-label, or aria-labelledby). Interactive icons must have an accessible name. The icon will be hidden from the accessibility tree.");
24
+ const v = t && !d, a = (d || t) && !v ? !1 : p, A = y ?? (t && !v ? "button" : "img"), C = k ?? (o && !v ? 0 : void 0), j = w(
25
+ (e) => {
26
+ l?.(e), !e.defaultPrevented && o && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.currentTarget.dispatchEvent(new MouseEvent("click", { bubbles: !0, cancelable: !0 })));
27
+ },
28
+ [o, l]
29
+ ), N = w(
30
+ (e) => {
31
+ n || i?.(e);
32
+ },
33
+ [n, i]
34
+ ), m = !a && c ? `${r}_title` : "", I = !a && s ? `${r}_desc` : "", T = [m, I].filter(Boolean).join(" ") || void 0;
35
+ return (
36
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- role is dynamic: 'button' when interactive, 'img' otherwise
37
+ /* @__PURE__ */ _(
38
+ "svg",
39
+ {
40
+ ...E,
41
+ "aria-disabled": n && t ? !0 : void 0,
42
+ "aria-hidden": a,
43
+ "aria-label": h,
44
+ "aria-labelledby": f ?? T,
45
+ className: B,
46
+ "data-disabled": n,
47
+ fill: "none",
48
+ height: b,
49
+ onClick: i ? N : void 0,
50
+ onKeyDown: o || l ? j : void 0,
51
+ ref: x,
52
+ role: A,
53
+ tabIndex: C,
54
+ viewBox: "0 0 24 24",
55
+ width: b,
56
+ xmlns: "http://www.w3.org/2000/svg",
57
+ children: [
58
+ !a && c && /* @__PURE__ */ u("title", { id: m, children: c }),
59
+ !a && s && /* @__PURE__ */ u("desc", { id: I, children: s }),
60
+ /* @__PURE__ */ u(P.Provider, { value: r, children: g })
61
+ ]
62
+ }
63
+ )
64
+ );
22
65
  };
23
66
  export {
24
- g as SvgIdContext,
25
- A as default
67
+ P as SvgIdContext,
68
+ S as default
26
69
  };
@@ -1 +1 @@
1
- {"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../src/primitives/popover.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAA;AAE3D,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,OAAO,CAAA;AAErD,eAAO,MAAM,OAAO,GAAI,cAAc,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,IAAI,CAAC,4CAE3F,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,cAAc,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,4CAErG,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,4CAA2D,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,4CAelJ,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,cAAc,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,MAAM,CAAC,4CAEnG,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,yBAAyB,wBAAwB,CAAC,KAAK,CAAC,4CAErF,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,yBAAyB,wBAAwB,CAAC,IAAI,CAAC,4CAEnF,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,yBAAyB,wBAAwB,CAAC,GAAG,CAAC,4CAExF,CAAA"}
1
+ {"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../src/primitives/popover.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAA;AAE3D,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,OAAO,CAAA;AAErD,eAAO,MAAM,OAAO,GAAI,cAAc,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,IAAI,CAAC,4CAE3F,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,cAAc,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,4CAErG,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,4CAA2D,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,4CAelJ,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,cAAc,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,MAAM,CAAC,4CAEnG,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,yBAAyB,wBAAwB,CAAC,KAAK,CAAC,4CAErF,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,yBAAyB,wBAAwB,CAAC,IAAI,CAAC,4CAKnF,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,yBAAyB,wBAAwB,CAAC,GAAG,CAAC,4CAExF,CAAA"}
@@ -14,7 +14,10 @@ const v = ({ ...o }) => /* @__PURE__ */ t(s, { "data-slot": "popover", ...o }),
14
14
  ),
15
15
  ...n
16
16
  }
17
- ) }), x = ({ ...o }) => /* @__PURE__ */ t(i, { "data-slot": "popover-anchor", ...o }), P = ({ className: o, ...e }) => /* @__PURE__ */ t("div", { "data-slot": "popover-header", className: a("flex flex-col gap-0.5 text-sm", o), ...e }), N = ({ className: o, ...e }) => /* @__PURE__ */ t("h2", { "data-slot": "popover-title", className: a("cn-font-heading font-medium", o), ...e }), T = ({ className: o, ...e }) => /* @__PURE__ */ t("p", { "data-slot": "popover-description", className: a("text-muted-foreground", o), ...e });
17
+ ) }), x = ({ ...o }) => /* @__PURE__ */ t(i, { "data-slot": "popover-anchor", ...o }), P = ({ className: o, ...e }) => /* @__PURE__ */ t("div", { "data-slot": "popover-header", className: a("flex flex-col gap-0.5 text-sm", o), ...e }), N = ({ className: o, ...e }) => (
18
+ // eslint-disable-next-line jsx-a11y/heading-has-content -- content provided via {...props}
19
+ /* @__PURE__ */ t("h2", { "data-slot": "popover-title", className: a("cn-font-heading font-medium", o), ...e })
20
+ ), T = ({ className: o, ...e }) => /* @__PURE__ */ t("p", { "data-slot": "popover-description", className: a("text-muted-foreground", o), ...e });
18
21
  export {
19
22
  v as Popover,
20
23
  x as PopoverAnchor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spear-ai/spectral",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "repository": {