@spear-ai/spectral 1.6.11 → 1.6.12

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,6 +1,6 @@
1
1
  "use client";
2
2
  import "../styles/main.css";
3
- import { jsxs as K, jsx as x } from "react/jsx-runtime";
3
+ import { jsxs as K, jsx as k } from "react/jsx-runtime";
4
4
  import { getResolvedLocale as ee, getLocalizedPeriodLabels as te, formatSelectPeriodLabel as re } from "./DateTimeUtils.js";
5
5
  import { Label as ne } from "../Label.js";
6
6
  import { useControllableState as ae } from "../hooks/useControllableState.js";
@@ -16,10 +16,10 @@ const h = {
16
16
  minute: { type: "minute", min: 0, max: 59, length: 2 },
17
17
  period: { type: "period", min: 0, max: 1, length: 2 }
18
18
  };
19
- function ue(v, e) {
20
- return v === 2 ? e % 4 === 0 && e % 100 !== 0 || e % 400 === 0 ? 29 : 28 : [4, 6, 9, 11].includes(v) ? 30 : 31;
19
+ function ue(x, e) {
20
+ return x === 2 ? e % 4 === 0 && e % 100 !== 0 || e % 400 === 0 ? 29 : 28 : [4, 6, 9, 11].includes(x) ? 30 : 31;
21
21
  }
22
- function ce({ ariaLabel: v, config: e, disabled: f, onLeftFocus: I, onRightFocus: w, onValueChange: c, periodLabels: D, value: s }) {
22
+ function ce({ ariaLabel: x, config: e, disabled: f, onLeftFocus: I, onRightFocus: v, onValueChange: c, periodLabels: w, value: s }) {
23
23
  const o = B(null), a = B(""), u = B(!1), b = g(() => {
24
24
  switch (e.type) {
25
25
  case "month":
@@ -33,11 +33,11 @@ function ce({ ariaLabel: v, config: e, disabled: f, onLeftFocus: I, onRightFocus
33
33
  case "minute":
34
34
  return "mm";
35
35
  case "period":
36
- return (D?.am ?? "am").toLowerCase();
36
+ return (w?.am ?? "am").toLowerCase();
37
37
  default:
38
38
  return "––";
39
39
  }
40
- }, [e.type, e.max, D]), m = g(() => s === void 0 ? b : e.type === "period" ? (s === 0 ? D?.am ?? "am" : D?.pm ?? "pm").toLowerCase() : s.toString().padStart(e.length, "0"), [s, e, D, b]);
40
+ }, [e.type, e.max, w]), m = g(() => s === void 0 ? b : e.type === "period" ? (s === 0 ? w?.am ?? "am" : w?.pm ?? "pm").toLowerCase() : s.toString().padStart(e.length, "0"), [s, e, w, b]);
41
41
  oe(() => {
42
42
  o.current && !u.current && (o.current.value = m);
43
43
  }, [m]);
@@ -56,7 +56,7 @@ function ce({ ariaLabel: v, config: e, disabled: f, onLeftFocus: I, onRightFocus
56
56
  return;
57
57
  }
58
58
  if (t.key === "ArrowRight") {
59
- t.preventDefault(), d(), w?.();
59
+ t.preventDefault(), d(), v?.();
60
60
  return;
61
61
  }
62
62
  if (t.key === "ArrowLeft") {
@@ -92,17 +92,17 @@ function ce({ ariaLabel: v, config: e, disabled: f, onLeftFocus: I, onRightFocus
92
92
  const r = a.current + t.key, l = parseInt(r, 10);
93
93
  if (e.length === 2)
94
94
  if (r.length >= 2) {
95
- const k = Math.max(e.min, Math.min(e.max, l));
96
- a.current = "", u.current = !1, c(k), w?.();
95
+ const D = Math.max(e.min, Math.min(e.max, l));
96
+ a.current = "", u.current = !1, c(D), v?.();
97
97
  } else if (l * 10 > e.max) {
98
- const k = Math.max(e.min, Math.min(e.max, l));
99
- a.current = "", u.current = !1, c(k), w?.();
98
+ const D = Math.max(e.min, Math.min(e.max, l));
99
+ a.current = "", u.current = !1, c(D), v?.();
100
100
  } else
101
101
  a.current = r, u.current = !0, o.current && (o.current.value = r);
102
102
  else if (e.length === 4)
103
103
  if (r.length >= 4) {
104
- const k = Math.max(e.min, Math.min(e.max, l));
105
- a.current = "", u.current = !1, c(k), w?.();
104
+ const D = Math.max(e.min, Math.min(e.max, l));
105
+ a.current = "", u.current = !1, c(D), v?.();
106
106
  } else
107
107
  a.current = r, u.current = !0, o.current && (o.current.value = r);
108
108
  return;
@@ -116,7 +116,7 @@ function ce({ ariaLabel: v, config: e, disabled: f, onLeftFocus: I, onRightFocus
116
116
  }
117
117
  }
118
118
  },
119
- [f, e, s, m, c, I, w, d]
119
+ [f, e, s, m, c, I, v, d]
120
120
  ), R = L(() => {
121
121
  a.current && d();
122
122
  }, [d]), S = L(() => {
@@ -146,10 +146,10 @@ function ce({ ariaLabel: v, config: e, disabled: f, onLeftFocus: I, onRightFocus
146
146
  return { width: 24, paddingLeft: 0 };
147
147
  }
148
148
  })(), M = s === void 0;
149
- return /* @__PURE__ */ x(
149
+ return /* @__PURE__ */ k(
150
150
  "input",
151
151
  {
152
- "aria-label": v,
152
+ "aria-label": x,
153
153
  "aria-valuemax": e.max,
154
154
  "aria-valuemin": e.min,
155
155
  "aria-valuenow": s,
@@ -178,15 +178,15 @@ function ce({ ariaLabel: v, config: e, disabled: f, onLeftFocus: I, onRightFocus
178
178
  }
179
179
  const le = se(
180
180
  ({
181
- className: v,
181
+ className: x,
182
182
  id: e,
183
183
  // New props
184
184
  defaultValue: f,
185
185
  onChange: I,
186
- value: w,
186
+ value: v,
187
187
  // Legacy props (deprecated)
188
188
  date: c,
189
- onDateChange: D,
189
+ onDateChange: w,
190
190
  // Other props
191
191
  disabled: s,
192
192
  endIcon: o,
@@ -197,7 +197,7 @@ const le = se(
197
197
  state: d = "default",
198
198
  ...E
199
199
  }, R) => {
200
- const S = B(null), T = w ?? c, U = I ?? D, [y, M] = ae({
200
+ const S = B(null), T = v ?? c, U = I ?? w, [y, M] = ae({
201
201
  value: T,
202
202
  defaultValue: f,
203
203
  onChange: U
@@ -213,7 +213,7 @@ const le = se(
213
213
  minute: y.getMinutes(),
214
214
  period: p
215
215
  };
216
- }, [y, a]), k = l.month !== void 0 && l.day !== void 0 && l.year !== void 0, _ = L(
216
+ }, [y, a]), D = l.month !== void 0 && l.day !== void 0 && l.year !== void 0, _ = L(
217
217
  (i) => {
218
218
  const n = { ...l, ...i };
219
219
  if (n.month === void 0 && n.day === void 0 && n.year === void 0) {
@@ -250,15 +250,15 @@ const le = se(
250
250
  return [...i, ...n];
251
251
  }, [m, a, r]), z = L((i) => {
252
252
  S.current?.querySelectorAll('[role="spinbutton"]')[i]?.focus();
253
- }, []), Q = O(ie(d, v));
253
+ }, []), Q = O(ie(d, x));
254
254
  return /* @__PURE__ */ K("div", { className: "flex flex-col gap-1.5", children: [
255
- u && /* @__PURE__ */ x(ne, { className: "text-text-primary text-sm font-medium", htmlFor: e, children: u }),
256
- /* @__PURE__ */ K("div", { className: O(Q, "relative", (s || d === "disabled") && "cursor-not-allowed", v), "data-slot": "datetime-display-input", id: e ?? "datetime-display-input", ref: R ?? S, ...E, children: [
257
- /* @__PURE__ */ x("div", { className: "flex items-center", ref: S, children: q.map((i, n) => {
258
- const p = ["month", "day", "year"].includes(i.key), H = ["hour", "minute", "period"].includes(i.key), Y = i.key === "year", N = i.key === "hour", P = s || H && !k;
255
+ u && /* @__PURE__ */ k(ne, { className: "text-text-primary text-sm font-medium", htmlFor: e, children: u }),
256
+ /* @__PURE__ */ K("div", { className: O(Q, "relative", (s || d === "disabled") && "cursor-not-allowed", x), "data-slot": "datetime-display-input", id: e ?? "datetime-display-input", ref: R ?? S, ...E, children: [
257
+ /* @__PURE__ */ k("div", { className: "flex items-center", ref: S, children: q.map((i, n) => {
258
+ const p = ["month", "day", "year"].includes(i.key), H = ["hour", "minute", "period"].includes(i.key), Y = i.key === "year", N = i.key === "hour", P = s || H && !D;
259
259
  return /* @__PURE__ */ K("span", { className: "flex items-center", children: [
260
- N && /* @__PURE__ */ x("span", { "aria-hidden": "true", className: "text-text-secondary select-none", children: ", " }),
261
- /* @__PURE__ */ x(
260
+ N && /* @__PURE__ */ k("span", { "aria-hidden": "true", className: "text-text-secondary select-none", children: ", " }),
261
+ /* @__PURE__ */ k(
262
262
  ce,
263
263
  {
264
264
  ariaLabel: i.ariaLabel,
@@ -271,11 +271,11 @@ const le = se(
271
271
  value: l[i.key]
272
272
  }
273
273
  ),
274
- p && !Y && /* @__PURE__ */ x("span", { "aria-hidden": "true", className: "text-text-secondary select-none", children: "/" }),
275
- N && /* @__PURE__ */ x("span", { "aria-hidden": "true", className: "text-inherit select-none", children: ":" })
274
+ p && !Y && /* @__PURE__ */ k("span", { "aria-hidden": "true", className: "text-text-secondary select-none", children: "/" }),
275
+ N && /* @__PURE__ */ k("span", { "aria-hidden": "true", className: "text-inherit select-none", children: ":" })
276
276
  ] }, i.key);
277
277
  }) }),
278
- /* @__PURE__ */ x("div", { className: "text-input-icon absolute top-1/2 right-4 -translate-y-1/2", children: o })
278
+ o
279
279
  ] })
280
280
  ] });
281
281
  }
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  import "./styles/main.css";
3
- import { jsxs as n, jsx as e } from "react/jsx-runtime";
3
+ import { jsxs as l, jsx as e } from "react/jsx-runtime";
4
4
  import { Calendar as b } from "./DateTimePicker/Calendar.js";
5
5
  import { DateTimeDisplayInput as w } from "./DateTimePicker/DateTimeDisplayInput.js";
6
6
  import { getResolvedLocale as I, detectHourFormat as L } from "./DateTimePicker/DateTimeUtils.js";
7
- import { DEFAULT_TRANSLATIONS as lr, DateTimeConfigSchema as nr, HourFormatSchema as sr, PICKER_TYPES as dr, PeriodSchema as cr, TIME_BOUNDS as ur, TimePickerTypeSchema as gr, TimeValueSchema as fr, convert12HourTo24Hour as hr, display12HourValue as Tr, formatSelectPeriodLabel as xr, formatTimeNumber as Hr, getAriaLabel as vr, getAriaValueMinMax as yr, getAriaValueNow as Vr, getArrowByType as Sr, getDateByType as Cr, getLocalizedPeriodLabel as Nr, getLocalizedPeriodLabels as Pr, getPeriodFromHours as Ar, getValid12Hour as Dr, getValidArrow12Hour as br, getValidArrowHour as wr, getValidArrowMinute as Ir, getValidArrowNumber as Lr, getValidHour as Mr, getValidMinute as kr, getValidNumber as Fr, isValid12Hour as Er, isValidHour as Br, isValidMinute as Or, set12Hours as jr, setDateByType as zr, setHours as Rr, setMinutes as _r } from "./DateTimePicker/DateTimeUtils.js";
7
+ import { DEFAULT_TRANSLATIONS as nr, DateTimeConfigSchema as lr, HourFormatSchema as sr, PICKER_TYPES as dr, PeriodSchema as cr, TIME_BOUNDS as ur, TimePickerTypeSchema as gr, TimeValueSchema as fr, convert12HourTo24Hour as hr, display12HourValue as Tr, formatSelectPeriodLabel as vr, formatTimeNumber as xr, getAriaLabel as Hr, getAriaValueMinMax as yr, getAriaValueNow as Vr, getArrowByType as Sr, getDateByType as Cr, getLocalizedPeriodLabel as Nr, getLocalizedPeriodLabels as Pr, getPeriodFromHours as Ar, getValid12Hour as Dr, getValidArrow12Hour as br, getValidArrowHour as wr, getValidArrowMinute as Ir, getValidArrowNumber as Lr, getValidHour as Mr, getValidMinute as kr, getValidNumber as Fr, isValid12Hour as Er, isValidHour as Br, isValidMinute as Or, set12Hours as jr, setDateByType as Rr, setHours as _r, setMinutes as zr } from "./DateTimePicker/DateTimeUtils.js";
8
8
  import { TimePicker as M } from "./DateTimePicker/TimePicker.js";
9
9
  import "./Icons/AnalyzeIcon.js";
10
10
  import "./Icons/AnnotationsIcon.js";
@@ -76,12 +76,12 @@ import { cn as a } from "./utils/twUtils.js";
76
76
  import { useMemo as g } from "react";
77
77
  import { DateTimeInput as Kr } from "./DateTimePicker/DateTimeInput.js";
78
78
  import { TimePeriodSelect as qr } from "./DateTimePicker/TimePeriodSelect.js";
79
- function z({ calendarProps: f, className: h, defaultValue: T, disabled: i = !1, disablePastDates: x = !0, errorMessage: s, hourFormat: d, label: H, locale: v, onChange: y, showTimePicker: o = !0, state: c = "default", timeLocale: u, timeTranslations: V, value: S, ...C }) {
79
+ function R({ calendarProps: f, className: h, defaultValue: T, disabled: i = !1, disablePastDates: v = !0, errorMessage: s, hourFormat: d, label: x, locale: H, onChange: y, showTimePicker: o = !0, state: c = "default", timeLocale: u, timeTranslations: V, value: S, ...C }) {
80
80
  const [r, m] = O({
81
81
  value: S,
82
82
  defaultValue: T,
83
83
  onChange: y
84
- }), l = g(() => I(u), [u]), p = g(() => d ?? L(l), [d, l]), N = (t) => {
84
+ }), n = g(() => I(u), [u]), p = g(() => d ?? L(n), [d, n]), N = (t) => {
85
85
  if (!t) {
86
86
  m(void 0);
87
87
  return;
@@ -93,8 +93,8 @@ function z({ calendarProps: f, className: h, defaultValue: T, disabled: i = !1,
93
93
  }, D = (t) => {
94
94
  m(t);
95
95
  };
96
- return /* @__PURE__ */ n(F, { children: [
97
- /* @__PURE__ */ n("div", { className: a("w-full", h), "data-slot": "datetime-picker", "data-testid": "spectral-datetime-picker", ...C, children: [
96
+ return /* @__PURE__ */ l(F, { children: [
97
+ /* @__PURE__ */ l("div", { className: a("w-full", h), "data-slot": "datetime-picker", "data-testid": "spectral-datetime-picker", ...C, children: [
98
98
  /* @__PURE__ */ e(
99
99
  w,
100
100
  {
@@ -105,13 +105,13 @@ function z({ calendarProps: f, className: h, defaultValue: T, disabled: i = !1,
105
105
  k,
106
106
  {
107
107
  "aria-label": "Open date picker",
108
- className: a("text-input-icon absolute top-1/2 right-4 size-5 -translate-y-1/2 focus:outline-none", i ? "pointer-events-none cursor-not-allowed opacity-50" : "hover:text-input-icon--hover cursor-pointer"),
108
+ className: a("text-input-icon hover:text-input-icon--hover absolute top-1/2 right-4 -translate-y-1/2 cursor-pointer focus:outline-none", i ? "pointer-events-none cursor-not-allowed opacity-50" : "hover:text-input-icon--hover cursor-pointer"),
109
109
  "data-testid": "spectral-datetime-picker-trigger",
110
110
  disabled: i
111
111
  }
112
112
  ) }),
113
113
  hourFormat: p,
114
- label: H,
114
+ label: x,
115
115
  onChange: D,
116
116
  showTime: o,
117
117
  state: c,
@@ -120,7 +120,7 @@ function z({ calendarProps: f, className: h, defaultValue: T, disabled: i = !1,
120
120
  ),
121
121
  c === "error" && s && /* @__PURE__ */ e(j, { message: s, dataTestId: "spectral-datetime-picker-error-message", id: "datetime-picker-error" })
122
122
  ] }),
123
- /* @__PURE__ */ n(
123
+ /* @__PURE__ */ l(
124
124
  B,
125
125
  {
126
126
  align: "start",
@@ -128,21 +128,21 @@ function z({ calendarProps: f, className: h, defaultValue: T, disabled: i = !1,
128
128
  "data-testid": "spectral-datetime-picker-popover",
129
129
  onOpenAutoFocus: (t) => t.preventDefault(),
130
130
  children: [
131
- /* @__PURE__ */ e(b, { ...f, disablePastDates: x, locale: v, mode: "single", onSelect: N, selected: r }),
132
- o && /* @__PURE__ */ e("div", { className: "border-border-secondary border-l pl-6", children: /* @__PURE__ */ e(M, { date: r, hourFormat: p, locale: l, onChange: P, onPeriodChange: A, translations: V }) })
131
+ /* @__PURE__ */ e(b, { ...f, disablePastDates: v, locale: H, mode: "single", onSelect: N, selected: r }),
132
+ o && /* @__PURE__ */ e("div", { className: "border-border-secondary border-l pl-6", children: /* @__PURE__ */ e(M, { date: r, hourFormat: p, locale: n, onChange: P, onPeriodChange: A, translations: V }) })
133
133
  ]
134
134
  }
135
135
  )
136
136
  ] });
137
137
  }
138
- z.displayName = "DateTimePicker";
138
+ R.displayName = "DateTimePicker";
139
139
  export {
140
140
  b as Calendar,
141
- lr as DEFAULT_TRANSLATIONS,
142
- nr as DateTimeConfigSchema,
141
+ nr as DEFAULT_TRANSLATIONS,
142
+ lr as DateTimeConfigSchema,
143
143
  w as DateTimeDisplayInput,
144
144
  Kr as DateTimeInput,
145
- z as DateTimePicker,
145
+ R as DateTimePicker,
146
146
  sr as HourFormatSchema,
147
147
  dr as PICKER_TYPES,
148
148
  cr as PeriodSchema,
@@ -154,9 +154,9 @@ export {
154
154
  hr as convert12HourTo24Hour,
155
155
  L as detectHourFormat,
156
156
  Tr as display12HourValue,
157
- xr as formatSelectPeriodLabel,
158
- Hr as formatTimeNumber,
159
- vr as getAriaLabel,
157
+ vr as formatSelectPeriodLabel,
158
+ xr as formatTimeNumber,
159
+ Hr as getAriaLabel,
160
160
  yr as getAriaValueMinMax,
161
161
  Vr as getAriaValueNow,
162
162
  Sr as getArrowByType,
@@ -177,7 +177,7 @@ export {
177
177
  Br as isValidHour,
178
178
  Or as isValidMinute,
179
179
  jr as set12Hours,
180
- zr as setDateByType,
181
- Rr as setHours,
182
- _r as setMinutes
180
+ Rr as setDateByType,
181
+ _r as setHours,
182
+ zr as setMinutes
183
183
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spear-ai/spectral",
3
- "version": "1.6.11",
3
+ "version": "1.6.12",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "repository": {