@spear-ai/spectral 1.4.16 → 1.4.17

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.
@@ -24,7 +24,17 @@ export type ItemRenderProps = {
24
24
  value: string;
25
25
  };
26
26
  export declare const ToggleGroupBase: (props: ToggleGroupProps & Record<`data-${string}`, any>) => import("react/jsx-runtime").JSX.Element;
27
- export type ToggleGroupItemProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange' | 'onPressedChange' | 'pressed' | 'defaultPressed'> & ItemRenderProps;
28
- export declare const ToggleGroupItemBase: import('react').ForwardRefExoticComponent<Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onChange" | "pressed" | "defaultPressed" | "onPressedChange"> & ItemRenderProps & import('react').RefAttributes<HTMLButtonElement>>;
27
+ export type ToggleGroupItemProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange' | 'onPressedChange' | 'pressed' | 'defaultPressed'> & ItemRenderProps & {
28
+ /** @deprecated This prop is ignored - pressed state is managed by ToggleGroup */
29
+ pressed?: boolean;
30
+ /** @deprecated This prop is ignored - pressed state is managed by ToggleGroup */
31
+ defaultPressed?: boolean;
32
+ };
33
+ export declare const ToggleGroupItemBase: import('react').ForwardRefExoticComponent<Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onChange" | "pressed" | "defaultPressed" | "onPressedChange"> & ItemRenderProps & {
34
+ /** @deprecated This prop is ignored - pressed state is managed by ToggleGroup */
35
+ pressed?: boolean;
36
+ /** @deprecated This prop is ignored - pressed state is managed by ToggleGroup */
37
+ defaultPressed?: boolean;
38
+ } & import('react').RefAttributes<HTMLButtonElement>>;
29
39
  export {};
30
40
  //# sourceMappingURL=ToggleGroupBase.d.ts.map
@@ -1,98 +1,98 @@
1
1
  "use client";
2
2
  import "../styles/main.css";
3
- import { jsx as C, jsxs as E } from "react/jsx-runtime";
3
+ import { jsx as k, jsxs as E } from "react/jsx-runtime";
4
4
  import { useControllableState as R } from "../hooks/useControllableState.js";
5
5
  import { clamp as M } from "../utils/sharedUtils.js";
6
- import { createContext as j, forwardRef as H, useContext as K, useRef as S, useImperativeHandle as L, useEffect as N, useCallback as l, useMemo as U } from "react";
7
- const T = j(null), W = (z) => {
6
+ import { createContext as j, forwardRef as H, useContext as K, useRef as S, useImperativeHandle as L, useEffect as N, useCallback as u, useMemo as _ } from "react";
7
+ const T = j(null), Q = (B) => {
8
8
  const {
9
- className: o,
10
- defaultValue: i,
11
- disabled: x = !1,
12
- loop: c = !0,
13
- name: u,
14
- onValueChange: v,
15
- orientation: b = "horizontal",
16
- type: d = "single",
17
- value: a,
18
- "data-variant": V,
19
- "data-size": w,
20
- "data-slot": f,
21
- "data-layout": A,
22
- ...G
23
- } = z, p = d === "multiple", [n, m] = R({
24
- defaultValue: typeof i < "u" ? i : p ? [] : "",
25
- onChange: v,
26
- value: a
27
- }), r = S([]), g = l((t, s) => {
28
- const P = { val: t, el: s, disabled: !!s?.disabled };
29
- return r.current = [...r.current.filter((D) => D.val !== t), P], () => {
30
- r.current = r.current.filter((D) => D.val !== t);
9
+ className: r,
10
+ defaultValue: d,
11
+ disabled: I = !1,
12
+ loop: g = !0,
13
+ name: c,
14
+ onValueChange: x,
15
+ orientation: D = "horizontal",
16
+ type: y = "single",
17
+ value: C,
18
+ "data-variant": z,
19
+ "data-size": o,
20
+ "data-slot": P,
21
+ "data-layout": v,
22
+ ...h
23
+ } = B, f = y === "multiple", [n, b] = R({
24
+ defaultValue: typeof d < "u" ? d : f ? [] : "",
25
+ onChange: x,
26
+ value: C
27
+ }), a = S([]), w = u((t, s) => {
28
+ const A = { val: t, el: s, disabled: !!s?.disabled };
29
+ return a.current = [...a.current.filter((m) => m.val !== t), A], () => {
30
+ a.current = a.current.filter((m) => m.val !== t);
31
31
  };
32
- }, []), k = l(() => r.current.slice(), []), B = l(
33
- (t) => p ? Array.isArray(n) && n.includes(t) : n === t,
34
- [p, n]
35
- ), e = l((t) => m(t), [m]), y = l(
32
+ }, []), i = u(() => a.current.slice(), []), p = u(
33
+ (t) => f ? Array.isArray(n) && n.includes(t) : n === t,
34
+ [f, n]
35
+ ), V = u((t) => b(t), [b]), G = u(
36
36
  (t) => {
37
- const s = r.current;
37
+ const s = a.current;
38
38
  if (s.length === 0) return;
39
- const P = s.length - 1, D = c ? (t % s.length + s.length) % s.length : M(t, 0, P);
40
- s[D]?.el?.focus();
39
+ const A = s.length - 1, m = g ? (t % s.length + s.length) % s.length : M(t, 0, A);
40
+ s[m]?.el?.focus();
41
41
  },
42
- [c]
43
- ), h = U(
42
+ [g]
43
+ ), e = _(
44
44
  () => ({
45
- focusItemByIndex: y,
46
- groupDisabled: x,
47
- isItemPressed: B,
48
- itemsSnapshot: k,
49
- loop: c,
50
- name: u,
51
- orientation: b,
52
- register: g,
53
- setValue: e,
54
- type: d,
45
+ focusItemByIndex: G,
46
+ groupDisabled: I,
47
+ isItemPressed: p,
48
+ itemsSnapshot: i,
49
+ loop: g,
50
+ name: c,
51
+ orientation: D,
52
+ register: w,
53
+ setValue: V,
54
+ type: y,
55
55
  value: n
56
56
  }),
57
- [x, B, k, c, u, b, e, d, n]
58
- ), I = u;
59
- return /* @__PURE__ */ E("div", { className: o, "data-disabled": x ? "" : void 0, "data-layout": A, "data-orientation": b, "data-size": w, "data-slot": f, "data-variant": V, role: "group", ...G, children: [
60
- /* @__PURE__ */ C(T.Provider, { value: h, children: z.children }),
61
- I && d === "single" && typeof n == "string" ? /* @__PURE__ */ C("input", { type: "hidden", name: I, value: n }) : null,
62
- I && d === "multiple" && Array.isArray(n) ? n.map((t) => /* @__PURE__ */ C("input", { type: "hidden", name: I + "[]", value: t }, t)) : null
57
+ [I, p, i, g, c, D, V, y, n]
58
+ ), l = c;
59
+ return /* @__PURE__ */ E("div", { className: r, "data-disabled": I ? "" : void 0, "data-layout": v, "data-orientation": D, "data-size": o, "data-slot": P, "data-variant": z, role: "group", ...h, children: [
60
+ /* @__PURE__ */ k(T.Provider, { value: e, children: B.children }),
61
+ l && y === "single" && typeof n == "string" ? /* @__PURE__ */ k("input", { type: "hidden", name: l, value: n }) : null,
62
+ l && y === "multiple" && Array.isArray(n) ? n.map((t) => /* @__PURE__ */ k("input", { type: "hidden", name: l + "[]", value: t }, t)) : null
63
63
  ] });
64
- }, X = H(function({ value: o, disabled: i, className: x, children: c, onKeyDown: u, onClick: v, ...b }, d) {
65
- const a = K(T);
66
- if (!a) throw new Error("ToggleGroupItem must be used within ToggleGroup");
67
- const { type: V, orientation: w, groupDisabled: f, setValue: A, isItemPressed: G, itemsSnapshot: p, register: n } = a, m = S(null);
68
- L(d, () => m.current), N(() => n(o, m.current), [n, o]);
69
- const r = G(o), g = l(() => {
70
- if (!(f || i))
71
- if (V === "single") A(r ? "" : o);
64
+ }, W = H(function({ value: r, disabled: d, className: I, children: g, onKeyDown: c, onClick: x, pressed: D, defaultPressed: y, ...C }, z) {
65
+ const o = K(T);
66
+ if (!o) throw new Error("ToggleGroupItem must be used within ToggleGroup");
67
+ const { type: P, orientation: v, groupDisabled: h, setValue: f, isItemPressed: n, itemsSnapshot: b, register: a } = o, w = S(null);
68
+ L(z, () => w.current), N(() => a(r, w.current), [a, r]);
69
+ const i = n(r), p = u(() => {
70
+ if (!(h || d))
71
+ if (P === "single") f(i ? "" : r);
72
72
  else {
73
- const e = a.value, y = r ? e.filter((h) => h !== o) : [...e, o];
74
- A(y);
73
+ const e = o.value, l = i ? e.filter((t) => t !== r) : [...e, r];
74
+ f(l);
75
75
  }
76
- }, [a.value, i, f, r, A, V, o]), k = l(
76
+ }, [o.value, d, h, i, f, P, r]), V = u(
77
77
  (e) => {
78
- if (u && u(e), e.defaultPrevented) return;
78
+ if (c && c(e), e.defaultPrevented) return;
79
79
  if (e.key === " " || e.key === "Enter") {
80
- e.preventDefault(), g();
80
+ e.preventDefault(), p();
81
81
  return;
82
82
  }
83
- const y = p(), h = y.findIndex((s) => s.val === o), I = w === "horizontal" ? "ArrowLeft" : "ArrowUp", t = w === "horizontal" ? "ArrowRight" : "ArrowDown";
84
- e.key === I ? (e.preventDefault(), a.focusItemByIndex(h - 1)) : e.key === t ? (e.preventDefault(), a.focusItemByIndex(h + 1)) : e.key === "Home" ? (e.preventDefault(), a.focusItemByIndex(0)) : e.key === "End" && (e.preventDefault(), a.focusItemByIndex(y.length - 1));
83
+ const l = b(), t = l.findIndex((m) => m.val === r), s = v === "horizontal" ? "ArrowLeft" : "ArrowUp", A = v === "horizontal" ? "ArrowRight" : "ArrowDown";
84
+ e.key === s ? (e.preventDefault(), o.focusItemByIndex(t - 1)) : e.key === A ? (e.preventDefault(), o.focusItemByIndex(t + 1)) : e.key === "Home" ? (e.preventDefault(), o.focusItemByIndex(0)) : e.key === "End" && (e.preventDefault(), o.focusItemByIndex(l.length - 1));
85
85
  },
86
- [a, p, u, w, g, o]
87
- ), B = l(
86
+ [o, b, c, v, p, r]
87
+ ), G = u(
88
88
  (e) => {
89
- v && v(e), !e.defaultPrevented && g();
89
+ x && x(e), !e.defaultPrevented && p();
90
90
  },
91
- [v, g]
91
+ [x, p]
92
92
  );
93
- return /* @__PURE__ */ C("button", { "aria-pressed": r, className: x, "data-disabled": f || i ? "" : void 0, "data-state": r ? "on" : "off", disabled: f || i, onClick: B, onKeyDown: k, ref: m, type: "button", ...b, children: c });
93
+ return /* @__PURE__ */ k("button", { "aria-pressed": i, className: I, "data-disabled": h || d ? "" : void 0, "data-state": i ? "on" : "off", disabled: h || d, onClick: G, onKeyDown: V, ref: w, type: "button", ...C, children: g });
94
94
  });
95
95
  export {
96
- W as ToggleGroupBase,
97
- X as ToggleGroupItemBase
96
+ Q as ToggleGroupBase,
97
+ W as ToggleGroupItemBase
98
98
  };
@@ -4,7 +4,10 @@ import { VariantProps } from 'class-variance-authority';
4
4
  import { ComponentProps } from 'react';
5
5
  export type ToggleGroupProps = ComponentProps<typeof ToggleGroupBase> & VariantProps<typeof toggleVariants>;
6
6
  export declare const ToggleGroup: ({ className, variant, size, layout, children, ...props }: ToggleGroupProps) => import("react/jsx-runtime").JSX.Element;
7
- export declare const ToggleGroupItem: import('react').ForwardRefExoticComponent<Omit<Omit<import('react').ButtonHTMLAttributes<HTMLButtonElement>, "onChange" | "pressed" | "defaultPressed" | "onPressedChange"> & import('./ToggleGroupBase').ItemRenderProps & import('react').RefAttributes<HTMLButtonElement> & VariantProps<(props?: ({
7
+ export declare const ToggleGroupItem: import('react').ForwardRefExoticComponent<Omit<Omit<import('react').ButtonHTMLAttributes<HTMLButtonElement>, "onChange" | "pressed" | "defaultPressed" | "onPressedChange"> & import('./ToggleGroupBase').ItemRenderProps & {
8
+ pressed?: boolean;
9
+ defaultPressed?: boolean;
10
+ } & import('react').RefAttributes<HTMLButtonElement> & VariantProps<(props?: ({
8
11
  variant?: "default" | "outline" | null | undefined;
9
12
  size?: "default" | "sm" | "lg" | null | undefined;
10
13
  layout?: "default" | "expanded" | null | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spear-ai/spectral",
3
- "version": "1.4.16",
3
+ "version": "1.4.17",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "repository": {