@spear-ai/spectral 1.8.9 → 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.
Files changed (58) hide show
  1. package/dist/.js +214 -210
  2. package/dist/Accordion.js +4 -4
  3. package/dist/Combobox/ComboboxBase.d.ts +8 -0
  4. package/dist/Combobox/ComboboxBase.js +80 -0
  5. package/dist/Combobox.d.ts +20 -0
  6. package/dist/Combobox.js +175 -0
  7. package/dist/ComboboxBase-CxNxYtdT.js +408 -0
  8. package/dist/ControlGroup/ControlGroupSelect.d.ts +33 -0
  9. package/dist/ControlGroup/ControlGroupSelect.js +104 -0
  10. package/dist/ControlGroup.d.ts +24 -0
  11. package/dist/ControlGroup.js +51 -0
  12. package/dist/DateTimePicker/DateTimeDisplayInput.js +53 -52
  13. package/dist/DateTimePicker/DateTimeInput.d.ts +5 -3
  14. package/dist/DateTimePicker/DateTimeInput.js +122 -69
  15. package/dist/Dialog.js +2 -2
  16. package/dist/Drawer.js +1 -1
  17. package/dist/HoverCard.js +4 -4
  18. package/dist/Icons/IconBase.d.ts +1 -1
  19. package/dist/Icons/IconBase.js +63 -20
  20. package/dist/MultiSelect/MultiSelectBase.js +128 -126
  21. package/dist/Popover.js +1 -1
  22. package/dist/RadioGroup.js +5 -5
  23. package/dist/Select.js +1 -1
  24. package/dist/Slider.js +3 -3
  25. package/dist/Tooltip.js +6 -6
  26. package/dist/Tray.d.ts +3 -1
  27. package/dist/Tray.js +36 -32
  28. package/dist/{Combination-CQ5bXZqE.js → index-6oYKCvIn.js} +179 -178
  29. package/dist/{index-CtqlhLRO.js → index-BFOf48AQ.js} +1 -1
  30. package/dist/{index-BJ6qs9i5.js → index-BlHU_t18.js} +7 -7
  31. package/dist/{index-D2Qxe4uK.js → index-Bm1RbF6w.js} +1 -1
  32. package/dist/{index-CXltlPV-.js → index-Bv2OIg5P.js} +6 -6
  33. package/dist/{index-Cgdmxb3F.js → index-CKEI0pDv.js} +1 -1
  34. package/dist/{index-CDkQCeZY.js → index-CM_hWgfC.js} +1 -1
  35. package/dist/{index-CJKg3MVV.js → index-C_YVr64u.js} +2 -2
  36. package/dist/{index-obMGvcdD.js → index-CwSyIPrv.js} +1 -1
  37. package/dist/{index-9OmOYyjJ.js → index-Dc0No4pV.js} +2 -1
  38. package/dist/{index-DqvTB1Bv.js → index-T6XEa11q.js} +7 -7
  39. package/dist/{index-CmWCa9Ae.js → index-pBCLb6Gr.js} +5 -5
  40. package/dist/{index-WBfSMXvE.js → index-psiVrsnE.js} +1 -1
  41. package/dist/index.d.ts +3 -1
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/primitives/button.d.ts +1 -1
  44. package/dist/primitives/button.d.ts.map +1 -1
  45. package/dist/primitives/button.js +4 -4
  46. package/dist/{InputGroup.d.ts → primitives/input-group.d.ts} +10 -7
  47. package/dist/primitives/input-group.d.ts.map +1 -0
  48. package/dist/primitives/input-group.js +74 -0
  49. package/dist/primitives/input.d.ts +6 -1
  50. package/dist/primitives/input.d.ts.map +1 -1
  51. package/dist/primitives/input.js +1 -1
  52. package/dist/primitives/popover.d.ts +10 -0
  53. package/dist/primitives/popover.d.ts.map +1 -0
  54. package/dist/primitives/popover.js +29 -0
  55. package/dist/primitives/select.js +2 -2
  56. package/dist/styles/spectral.css +2 -2
  57. package/package.json +1 -1
  58. package/dist/InputGroup.js +0 -84
@@ -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
  };
package/dist/Dialog.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import "./styles/main.css";
2
2
  import { jsx as o, jsxs as l } from "react/jsx-runtime";
3
3
  import { CloseIcon as m } from "./Icons/CloseIcon.js";
4
- import { R as p, C as i, a as f, D as u, O as x, P as b, T as h, b as v } from "./index-CmWCa9Ae.js";
4
+ import { R as p, C as i, a as f, D as u, O as x, P as b, T as h, b as v } from "./index-pBCLb6Gr.js";
5
5
  import { cn as e } from "./utils/twUtils.js";
6
6
  import "react";
7
- import { R as y } from "./Combination-CQ5bXZqE.js";
7
+ import { R as y } from "./index-6oYKCvIn.js";
8
8
  const j = ({
9
9
  isOpen: t,
10
10
  modal: a = !1,
package/dist/Drawer.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./styles/main.css";
2
2
  import { jsx as t, jsxs as s } from "react/jsx-runtime";
3
3
  import { SpectralProvider as f } from "./SpectralProvider.js";
4
- import { D as e } from "./index-D2Qxe4uK.js";
4
+ import { D as e } from "./index-Bm1RbF6w.js";
5
5
  const u = ({ children: l, defaultOpen: d = !1, description: i, direction: o = "right", dismissible: c = !0, modal: n = !0, onOpenChange: p, open: x, size: r = "380px", title: h, trigger: m }) => {
6
6
  const a = "font-sans! fixed", w = {
7
7
  left: {
package/dist/HoverCard.js CHANGED
@@ -3,10 +3,10 @@ import "./styles/main.css";
3
3
  import { jsx as i } from "react/jsx-runtime";
4
4
  import * as s from "react";
5
5
  import { createContext as I, useContext as B } from "react";
6
- import { e as U, c as m, P as $, u as W, a as z } from "./index-9OmOYyjJ.js";
7
- import { R as G, A as K, c as O, C as j, a as V } from "./index-CJKg3MVV.js";
8
- import { P as q, D as J } from "./index-BJ6qs9i5.js";
9
- import { P as T } from "./index-CtqlhLRO.js";
6
+ import { e as U, c as m, P as $, u as W, a as z } from "./index-Dc0No4pV.js";
7
+ import { R as G, A as K, c as O, C as j, a as V } from "./index-C_YVr64u.js";
8
+ import { P as q, D as J } from "./index-BlHU_t18.js";
9
+ import { P as T } from "./index-BFOf48AQ.js";
10
10
  import { cn as E } from "./utils/twUtils.js";
11
11
  var H, x = "HoverCard", [N] = z(x, [
12
12
  O
@@ -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
  };