@spear-ai/spectral 1.6.10 → 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/dist/Tabs.d.ts CHANGED
@@ -8,7 +8,7 @@ export interface TabValue {
8
8
  'aria-label'?: string | undefined;
9
9
  'aria-describedby'?: string | undefined;
10
10
  }
11
- export interface TabsProps extends Omit<TabsBaseProps, 'children' | 'defaultValue' | 'onError' | 'disabled'> {
11
+ export interface TabsProps extends Omit<TabsBaseProps, 'children' | 'defaultValue' | 'onError' | 'disabled' | 'value'> {
12
12
  activationMode?: 'automatic' | 'manual' | undefined;
13
13
  ariaLabel?: string | undefined;
14
14
  className?: string | undefined;
@@ -17,12 +17,23 @@ export interface TabsProps extends Omit<TabsBaseProps, 'children' | 'defaultValu
17
17
  onBeforeChange?: (newValue: string, oldValue: string) => boolean | Promise<boolean> | undefined;
18
18
  onError?: ((error: Error) => void) | undefined;
19
19
  loading?: boolean | undefined;
20
+ /**
21
+ * Initial tab to open (uncontrolled mode).
22
+ * Mutually exclusive with `value` - use one or the other.
23
+ */
20
24
  openOnLoad?: string | undefined;
21
25
  rightSlot?: ReactNode | undefined;
22
26
  tabValues: TabValue[] | undefined;
27
+ /**
28
+ * Controlled value - the currently active tab key.
29
+ * When provided, the component operates in controlled mode and the parent
30
+ * must manage the active tab state via `onValueChange`.
31
+ * Mutually exclusive with `openOnLoad` - use one or the other.
32
+ */
33
+ value?: string | undefined;
23
34
  variant?: 'enclosed' | 'default';
24
35
  }
25
- export declare const Tabs: ({ activationMode, ariaLabel, className, hideContent, loading, onBeforeChange, onError, onValueChange, openOnLoad, orientation, rightSlot, tabValues, variant, ...props }: TabsProps) => import("react/jsx-runtime").JSX.Element;
36
+ export declare const Tabs: ({ activationMode, ariaLabel, className, hideContent, loading, onBeforeChange, onError, onValueChange, openOnLoad, orientation, rightSlot, tabValues, value: controlledValue, variant, ...props }: TabsProps) => import("react/jsx-runtime").JSX.Element;
26
37
  export { TabsContent, TabsContentContainer, TabsList, TabsBase as TabsRoot, TabsTrigger };
27
38
  export type { TabsBaseProps, TabsContentContainerProps, TabsContentProps, TabsListProps, TabsTriggerProps } from './TabsBase';
28
39
  export type TabKeys<T extends TabValue[]> = T[number]['key'];
package/dist/Tabs.js CHANGED
@@ -1,80 +1,110 @@
1
1
  import "./styles/main.css";
2
- import { jsx as l, jsxs as y } from "react/jsx-runtime";
3
- import { TabsBase as z, TabsList as k, TabsTrigger as j, TabsContentContainer as C, TabsContent as V } from "./Tabs/TabsBase.js";
4
- import { validateTabValues as E, getTabKeys as K } from "./Tabs/tabsUtils.js";
2
+ import { jsx as l, jsxs as N } from "react/jsx-runtime";
3
+ import { TabsBase as j, TabsList as E, TabsTrigger as K, TabsContentContainer as $, TabsContent as A } from "./Tabs/TabsBase.js";
4
+ import { validateTabValues as B, getTabKeys as I } from "./Tabs/tabsUtils.js";
5
5
  import { cn as r } from "./utils/twUtils.js";
6
6
  import "react";
7
- const A = ({ tabCount: d, orientation: s, hideContent: n }) => /* @__PURE__ */ y("div", { className: "relative flex w-full flex-col", role: "status", children: [
8
- /* @__PURE__ */ l("div", { className: r("inline-flex w-full items-center justify-start", s === "horizontal" && "border-b border-neutral-600", s === "vertical" && "flex-col items-stretch border-r border-neutral-600"), children: Array.from({ length: Math.min(d, 5) }, (b, u) => /* @__PURE__ */ l("div", { className: r("animate-pulse rounded bg-neutral-600", s === "horizontal" ? "mx-2 my-2 h-6 w-16" : "mx-2 my-1 h-6 w-full"), "aria-hidden": "true" }, u)) }),
9
- !n && /* @__PURE__ */ l("div", { className: "mt-4 h-32 w-full animate-pulse rounded bg-neutral-600", "aria-hidden": "true" }),
7
+ const L = ({ tabCount: f, orientation: s, hideContent: v }) => /* @__PURE__ */ N("div", { className: "relative flex w-full flex-col", role: "status", children: [
8
+ /* @__PURE__ */ l("div", { className: r("inline-flex w-full items-center justify-start", s === "horizontal" && "border-b border-neutral-600", s === "vertical" && "flex-col items-stretch border-r border-neutral-600"), children: Array.from({ length: Math.min(f, 5) }, (h, x) => /* @__PURE__ */ l("div", { className: r("animate-pulse rounded bg-neutral-600", s === "horizontal" ? "mx-2 my-2 h-6 w-16" : "mx-2 my-1 h-6 w-full"), "aria-hidden": "true" }, x)) }),
9
+ !v && /* @__PURE__ */ l("div", { className: "mt-4 h-32 w-full animate-pulse rounded bg-neutral-600", "aria-hidden": "true" }),
10
10
  /* @__PURE__ */ l("span", { className: "sr-only", children: "Loading tabs…" })
11
- ] }), S = ({ activationMode: d = "automatic", ariaLabel: s, className: n, hideContent: b = !1, loading: u = !1, onBeforeChange: x, onError: f, onValueChange: m, openOnLoad: i, orientation: a = "horizontal", rightSlot: g, tabValues: p = [], variant: t = "default", ...w }) => {
12
- const c = p.filter((e) => e.key !== void 0);
13
- if (!E(c)) {
11
+ ] }), _ = ({
12
+ activationMode: f = "automatic",
13
+ ariaLabel: s,
14
+ className: v,
15
+ hideContent: h = !1,
16
+ loading: x = !1,
17
+ onBeforeChange: y,
18
+ onError: m,
19
+ onValueChange: g,
20
+ openOnLoad: o,
21
+ orientation: a = "horizontal",
22
+ rightSlot: T,
23
+ tabValues: w = [],
24
+ value: d,
25
+ variant: t = "default",
26
+ ...k
27
+ }) => {
28
+ const n = w.filter((e) => e.key !== void 0), b = d !== void 0;
29
+ if (!B(n)) {
14
30
  const e = new Error("Invalid tabValues provided to Tabs component");
15
- return f?.(e), /* @__PURE__ */ l("div", { className: "relative flex w-full flex-col p-4 text-center text-gray-500", role: "alert", "aria-live": "polite", children: /* @__PURE__ */ l("p", { children: "No valid tabs provided" }) });
31
+ return m?.(e), /* @__PURE__ */ l("div", { className: "relative flex w-full flex-col p-4 text-center text-gray-500", role: "alert", "aria-live": "polite", children: /* @__PURE__ */ l("p", { children: "No valid tabs provided" }) });
16
32
  }
17
- if (u)
18
- return /* @__PURE__ */ l(A, { tabCount: p.length || 3, orientation: a, hideContent: b });
19
- const h = K(c);
20
- let o = i ?? h[0];
21
- if (i && !h.includes(i) && (console.warn(`Tabs: openOnLoad value '${i}' is not a valid tab key`), o = h[0]), !o) {
33
+ if (x)
34
+ return /* @__PURE__ */ l(L, { tabCount: w.length || 3, orientation: a, hideContent: h });
35
+ const i = I(n);
36
+ let u;
37
+ b && (i.includes(d) ? u = d : (console.warn(`Tabs: value '${d}' is not a valid tab key, falling back to first tab`), u = i[0]));
38
+ let c;
39
+ if (!b && (c = o ?? i[0], o && !i.includes(o) && (console.warn(`Tabs: openOnLoad value '${o}' is not a valid tab key`), c = i[0]), !c)) {
22
40
  const e = new Error("No valid default tab available");
23
- return f?.(e), /* @__PURE__ */ l("div", { className: "text-text-secondary relative flex w-full flex-col p-4 text-center", role: "alert", "aria-live": "polite", children: /* @__PURE__ */ l("p", { children: "Unable to render tabs" }) });
41
+ return m?.(e), /* @__PURE__ */ l("div", { className: "text-text-secondary relative flex w-full flex-col p-4 text-center", role: "alert", "aria-live": "polite", children: /* @__PURE__ */ l("p", { children: "Unable to render tabs" }) });
24
42
  }
25
- const N = async (e) => {
26
- if (x && m) {
27
- const T = o;
43
+ const z = async (e) => {
44
+ if (y && g) {
45
+ const C = b ? u : c;
28
46
  try {
29
- if (await x(e, T) === !1) return;
30
- } catch (v) {
31
- f?.(v instanceof Error ? v : new Error("Before change callback failed"));
47
+ if (await y(e, C) === !1) return;
48
+ } catch (p) {
49
+ m?.(p instanceof Error ? p : new Error("Before change callback failed"));
32
50
  return;
33
51
  }
34
52
  }
35
- m?.(e);
53
+ g?.(e);
36
54
  };
37
- return /* @__PURE__ */ l("div", { className: "relative flex w-full flex-col", children: /* @__PURE__ */ y(z, { "aria-label": s, className: r("relative w-full data-[orientation=vertical]:flex", t, n), defaultValue: o, orientation: a, activationMode: d, onValueChange: N, ...w, children: [
38
- /* @__PURE__ */ l(
39
- k,
40
- {
41
- className: r(
42
- "inline-flex w-full items-center justify-between",
43
- a === "horizontal" && t === "default" && ["border-tabs-border border-b"],
44
- a === "vertical" && t === "default" && ["border-tabs-border relative m-0 h-auto w-auto flex-col items-stretch border-r py-1"],
45
- a === "horizontal" && t === "enclosed" && ["bg-tabs-group-bg relative rounded-lg border-0 p-1"],
46
- a === "vertical" && t === "enclosed" && ["bg-tabs-group-bg w-auto flex-col rounded-lg border-0 p-1"]
47
- ),
48
- rightSlot: g,
49
- children: c.map((e) => /* @__PURE__ */ l(
50
- j,
55
+ return /* @__PURE__ */ l("div", { className: "relative flex w-full flex-col", children: /* @__PURE__ */ N(
56
+ j,
57
+ {
58
+ "aria-label": s,
59
+ className: r("relative w-full data-[orientation=vertical]:flex", t, v),
60
+ ...b ? { value: u } : { defaultValue: c },
61
+ orientation: a,
62
+ activationMode: f,
63
+ onValueChange: z,
64
+ ...k,
65
+ children: [
66
+ /* @__PURE__ */ l(
67
+ E,
51
68
  {
52
- value: e.key,
53
- disabled: e.disabled,
54
- "aria-label": e["aria-label"],
55
- "aria-describedby": e["aria-describedby"],
56
69
  className: r(
57
- "relative font-semibold whitespace-nowrap transition-all duration-500 ease-in-out focus:outline-none focus-visible:outline-none",
58
- a === "horizontal" && t === "default" && ["text-text-primary hover:text-accent hover:bg-tabs-bg--hover px-4 py-2"],
59
- a === "vertical" && t === "default" && ["text-text-primary data-[state=active]:text-accent hover:text-accent hover:bg-tabs-bg--hover flex h-10 items-center px-4 py-2"],
60
- a === "horizontal" && t === "enclosed" && ["text-text-primary data-[state=active]:text-accent hover:text-accent hover:bg-tabs-bg--hover z-[1] inline-flex items-center justify-center px-4 py-2"],
61
- a === "vertical" && t === "enclosed" && ["text-text-primary data-[state=active]:text-accent hover:text-accent hover:bg-tabs-bg--hover z-[1] px-4 py-2"],
62
- "disabled:hover:text-text-primary disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent"
70
+ "inline-flex w-full items-center justify-between",
71
+ a === "horizontal" && t === "default" && ["border-tabs-border border-b"],
72
+ a === "vertical" && t === "default" && ["border-tabs-border relative m-0 h-auto w-auto flex-col items-stretch border-r py-1"],
73
+ a === "horizontal" && t === "enclosed" && ["bg-tabs-group-bg relative rounded-lg border-0 p-1"],
74
+ a === "vertical" && t === "enclosed" && ["bg-tabs-group-bg w-auto flex-col rounded-lg border-0 p-1"]
63
75
  ),
64
- children: e.label
65
- },
66
- e.key
67
- ))
68
- }
69
- ),
70
- !b && /* @__PURE__ */ l(C, { className: r(a === "vertical" && "flex-1"), children: c.map((e) => /* @__PURE__ */ l(V, { value: e.key, className: r("focus-visible:outline-accent text-text-primary focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2", a === "horizontal" && "pb-4", a === "vertical" && "px-4 py-2"), children: e.children }, e.key)) })
71
- ] }) });
76
+ rightSlot: T,
77
+ children: n.map((e) => /* @__PURE__ */ l(
78
+ K,
79
+ {
80
+ value: e.key,
81
+ disabled: e.disabled,
82
+ "aria-label": e["aria-label"],
83
+ "aria-describedby": e["aria-describedby"],
84
+ className: r(
85
+ "relative font-semibold whitespace-nowrap transition-all duration-500 ease-in-out focus:outline-none focus-visible:outline-none",
86
+ a === "horizontal" && t === "default" && ["text-text-primary hover:text-accent hover:bg-tabs-bg--hover px-4 py-2"],
87
+ a === "vertical" && t === "default" && ["text-text-primary data-[state=active]:text-accent hover:text-accent hover:bg-tabs-bg--hover flex h-10 items-center px-4 py-2"],
88
+ a === "horizontal" && t === "enclosed" && ["text-text-primary data-[state=active]:text-accent hover:text-accent hover:bg-tabs-bg--hover z-[1] inline-flex items-center justify-center px-4 py-2"],
89
+ a === "vertical" && t === "enclosed" && ["text-text-primary data-[state=active]:text-accent hover:text-accent hover:bg-tabs-bg--hover z-[1] px-4 py-2"],
90
+ "disabled:hover:text-text-primary disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent"
91
+ ),
92
+ children: e.label
93
+ },
94
+ e.key
95
+ ))
96
+ }
97
+ ),
98
+ !h && /* @__PURE__ */ l($, { className: r(a === "vertical" && "flex-1"), children: n.map((e) => /* @__PURE__ */ l(A, { value: e.key, className: r("focus-visible:outline-accent text-text-primary focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2", a === "horizontal" && "pb-4", a === "vertical" && "px-4 py-2"), children: e.children }, e.key)) })
99
+ ]
100
+ }
101
+ ) });
72
102
  };
73
103
  export {
74
- S as Tabs,
75
- V as TabsContent,
76
- C as TabsContentContainer,
77
- k as TabsList,
78
- z as TabsRoot,
79
- j as TabsTrigger
104
+ _ as Tabs,
105
+ A as TabsContent,
106
+ $ as TabsContentContainer,
107
+ E as TabsList,
108
+ j as TabsRoot,
109
+ K as TabsTrigger
80
110
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spear-ai/spectral",
3
- "version": "1.6.10",
3
+ "version": "1.6.12",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "repository": {