@spear-ai/spectral 1.3.43 → 1.3.44
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.
- package/dist/.js +142 -110
- package/dist/Alert.js +17 -12
- package/dist/Avatar.d.ts +2 -0
- package/dist/Avatar.js +1 -0
- package/dist/Button.js +24 -30
- package/dist/Dialog/DialogBase.d.ts +5 -5
- package/dist/Dialog/DialogBase.js +87 -86
- package/dist/Icons/CheckCircleIcon.d.ts +3 -0
- package/dist/Icons/CheckCircleIcon.js +29 -0
- package/dist/Icons/CheckSquareIcon.d.ts +3 -0
- package/dist/Icons/CheckSquareIcon.js +29 -0
- package/dist/Icons/ChevronDownIcon.d.ts +3 -0
- package/dist/Icons/ChevronDownIcon.js +28 -0
- package/dist/Icons/ChevronUpIcon.d.ts +3 -0
- package/dist/Icons/ChevronUpIcon.js +28 -0
- package/dist/Icons/{CheckIcon.d.ts → ErrorIcon.d.ts} +2 -2
- package/dist/Icons/ErrorIcon.js +30 -0
- package/dist/Icons/LoaderIcon.d.ts +3 -0
- package/dist/Icons/LoaderIcon.js +53 -0
- package/dist/Icons/index.d.ts +6 -1
- package/dist/Icons.js +82 -72
- package/dist/Input/InputUtils.d.ts +15 -0
- package/dist/Input/InputUtils.js +54 -0
- package/dist/Input.d.ts +24 -0
- package/dist/Input.js +170 -0
- package/dist/MultiSelect/MultiSelectBase.d.ts +34 -0
- package/dist/MultiSelect/MultiSelectBase.js +321 -0
- package/dist/MultiSelect/MutiSelect.d.ts +15 -0
- package/dist/MultiSelect/MutiSelect.js +30 -0
- package/dist/Popover.d.ts +1 -1
- package/dist/Popover.js +61 -59
- package/dist/RadioButtonGroup/RadioButtonGroupBase.js +18 -17
- package/dist/Select/SelectBase.d.ts +26 -0
- package/dist/Select/SelectBase.js +233 -0
- package/dist/Select.d.ts +50 -0
- package/dist/Select.js +136 -0
- package/dist/Textarea/TextareaUtils.d.ts +19 -0
- package/dist/Textarea/TextareaUtils.js +54 -0
- package/dist/Textarea.d.ts +17 -0
- package/dist/Textarea.js +160 -0
- package/dist/chevron-down-UbkgS76q.js +19 -0
- package/dist/components/Avatar/Avatar.d.ts +2 -0
- package/dist/components/Avatar/Avatar.d.ts.map +1 -0
- package/dist/components/Dialog/DialogBase.d.ts +5 -5
- package/dist/components/Dialog/DialogBase.d.ts.map +1 -1
- package/dist/components/Icons/CheckCircleIcon.d.ts +3 -0
- package/dist/components/Icons/CheckCircleIcon.d.ts.map +1 -0
- package/dist/components/Icons/CheckSquareIcon.d.ts +3 -0
- package/dist/components/Icons/CheckSquareIcon.d.ts.map +1 -0
- package/dist/components/Icons/ChevronDownIcon.d.ts +3 -0
- package/dist/components/Icons/ChevronDownIcon.d.ts.map +1 -0
- package/dist/components/Icons/ChevronUpIcon.d.ts +3 -0
- package/dist/components/Icons/ChevronUpIcon.d.ts.map +1 -0
- package/dist/components/Icons/{CheckIcon.d.ts → ErrorIcon.d.ts} +2 -2
- package/dist/components/Icons/ErrorIcon.d.ts.map +1 -0
- package/dist/components/Icons/LoaderIcon.d.ts +3 -0
- package/dist/components/Icons/LoaderIcon.d.ts.map +1 -0
- package/dist/components/Icons/index.d.ts +6 -1
- package/dist/components/Icons/index.d.ts.map +1 -1
- package/dist/components/Input/Input.d.ts +24 -0
- package/dist/components/Input/Input.d.ts.map +1 -0
- package/dist/components/Input/InputUtils.d.ts +15 -0
- package/dist/components/Input/InputUtils.d.ts.map +1 -0
- package/dist/components/MultiSelect/MultiSelectBase.d.ts +34 -0
- package/dist/components/MultiSelect/MultiSelectBase.d.ts.map +1 -0
- package/dist/components/MultiSelect/MutiSelect.d.ts +15 -0
- package/dist/components/MultiSelect/MutiSelect.d.ts.map +1 -0
- package/dist/components/Popover/Popover.d.ts +1 -1
- package/dist/components/Popover/Popover.d.ts.map +1 -1
- package/dist/components/RadioButtonGroup/RadioButtonGroupBase.d.ts.map +1 -1
- package/dist/components/Select/Select.d.ts +50 -0
- package/dist/components/Select/Select.d.ts.map +1 -0
- package/dist/components/Select/SelectBase.d.ts +26 -0
- package/dist/components/Select/SelectBase.d.ts.map +1 -0
- package/dist/components/Textarea/Textarea.d.ts +17 -0
- package/dist/components/Textarea/Textarea.d.ts.map +1 -0
- package/dist/components/Textarea/TextareaUtils.d.ts +19 -0
- package/dist/components/Textarea/TextareaUtils.d.ts.map +1 -0
- package/dist/features/LabelingTools.js +8 -3
- package/dist/features/SensorMetadata.js +12 -7
- package/dist/features/SettingsPopover.js +18 -13
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/loader-circle-CvdzOiQ_.js +11 -0
- package/dist/styles/base-colors.css +33 -33
- package/dist/styles/main.css +1 -1
- package/dist/utils/formFieldUtils.d.ts +70 -0
- package/dist/utils/formFieldUtils.d.ts.map +1 -0
- package/dist/utils/formFieldUtils.js +178 -0
- package/dist/x-BBpi7a_7.js +14 -0
- package/package.json +1 -1
- package/dist/Icons/CheckIcon.js +0 -29
- package/dist/components/Icons/CheckIcon.d.ts.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../styles/main.css";
|
|
3
3
|
import { jsx as s } from "react/jsx-runtime";
|
|
4
|
-
import { Slot as
|
|
4
|
+
import { Slot as m } from "../primitives/slot.js";
|
|
5
5
|
import { c as l } from "../twUtils-CRiPKpXj.js";
|
|
6
|
-
import { createContext as
|
|
7
|
-
const
|
|
6
|
+
import { createContext as x, useContext as h } from "react";
|
|
7
|
+
const c = x(null), G = ({
|
|
8
8
|
value: t,
|
|
9
|
-
onValueChange:
|
|
9
|
+
onValueChange: n,
|
|
10
10
|
children: i,
|
|
11
11
|
className: o,
|
|
12
|
-
isKeptActive:
|
|
12
|
+
isKeptActive: r = !1,
|
|
13
13
|
expanded: e = !1
|
|
14
|
-
}) => /* @__PURE__ */ s(
|
|
14
|
+
}) => /* @__PURE__ */ s(c.Provider, { value: { value: t, onValueChange: n, isKeptActive: r, expanded: e }, children: /* @__PURE__ */ s(
|
|
15
15
|
"div",
|
|
16
16
|
{
|
|
17
17
|
role: "radiogroup",
|
|
@@ -25,34 +25,35 @@ const u = h(null), G = ({
|
|
|
25
25
|
}
|
|
26
26
|
) }), R = ({
|
|
27
27
|
value: t,
|
|
28
|
-
children:
|
|
28
|
+
children: n,
|
|
29
29
|
className: i,
|
|
30
30
|
disabled: o = !1,
|
|
31
|
-
asChild:
|
|
31
|
+
asChild: r = !1
|
|
32
32
|
}) => {
|
|
33
|
-
const e =
|
|
33
|
+
const e = h(c);
|
|
34
34
|
if (!e)
|
|
35
35
|
throw new Error("RadioButtonGroupItem must be used within a RadioButtonGroup");
|
|
36
|
-
const { value:
|
|
36
|
+
const { value: g, onValueChange: a, isKeptActive: u, expanded: b } = e, d = g === t, f = () => {
|
|
37
37
|
!o && a && a(t);
|
|
38
|
-
},
|
|
38
|
+
}, v = r ? m : "button", p = {
|
|
39
39
|
role: "radio",
|
|
40
40
|
"aria-checked": d,
|
|
41
41
|
"data-state": d ? "on" : "off",
|
|
42
42
|
disabled: o,
|
|
43
|
-
onClick:
|
|
43
|
+
onClick: f,
|
|
44
44
|
className: l(
|
|
45
45
|
"bg-toggle-bg inline-flex items-center justify-center gap-2 border text-sm font-medium disabled:pointer-events-none disabled:opacity-50",
|
|
46
46
|
"disabled:cursor-not-allowed hover:cursor-pointer text-toggle-text hover:bg-toggle-bg--hover hover:text-toggle-text--hover transition-[colors]",
|
|
47
47
|
"[&_svg]:pointer-events-none [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] focus:outline-none",
|
|
48
|
-
'
|
|
49
|
-
"rounded-none shadow-none focus:z-10 focus-visible:z-10 [&:not(:first-child)]:border-l-0",
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
'outline-none border-toggle-border hover:border-toggle-border--hover h-9 px-3 min-w-9 [&_svg:not([class*="size-"]):not([width]):not([height])]:size-4',
|
|
49
|
+
"rounded-none shadow-none focus:z-10 focus-visible:z-10 [&:not(:first-child)]:border-l-0 active:bg-toggle-bg--active active:text-toggle-text--active",
|
|
50
|
+
"active:border-toggle-border--active",
|
|
51
|
+
b && "w-full",
|
|
52
|
+
u && "data-[state=on]:bg-toggle-bg--active data-[state=on]:text-toggle-text--active data-[state=on]:border-toggle-border--active",
|
|
52
53
|
i
|
|
53
54
|
)
|
|
54
55
|
};
|
|
55
|
-
return /* @__PURE__ */ s(
|
|
56
|
+
return /* @__PURE__ */ s(v, { ...!r && { type: "button" }, ...p, children: n });
|
|
56
57
|
};
|
|
57
58
|
export {
|
|
58
59
|
G as RadioButtonGroupBase,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type SelectState = 'default' | 'error' | 'disabled' | 'loading';
|
|
3
|
+
export interface SelectOption {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
group?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface SelectBaseProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'onChange'> {
|
|
10
|
+
value?: string;
|
|
11
|
+
defaultValue?: string;
|
|
12
|
+
onChange?: (value: string) => void;
|
|
13
|
+
options: SelectOption[];
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
state?: SelectState;
|
|
16
|
+
errorMessage?: string;
|
|
17
|
+
emptyMessage?: ReactNode;
|
|
18
|
+
loadingMessage?: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
id?: string;
|
|
21
|
+
label?: string;
|
|
22
|
+
'aria-label'?: string;
|
|
23
|
+
'aria-describedby'?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare const SelectBase: import('react').ForwardRefExoticComponent<SelectBaseProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
26
|
+
//# sourceMappingURL=SelectBase.d.ts.map
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../styles/main.css";
|
|
3
|
+
import { jsxs as p, jsx as n, Fragment as ee } from "react/jsx-runtime";
|
|
4
|
+
import { c as b } from "../twUtils-CRiPKpXj.js";
|
|
5
|
+
import { forwardRef as te, useId as re, useState as C, useRef as T, useMemo as _, useCallback as E, useEffect as S } from "react";
|
|
6
|
+
import { L as $ } from "../loader-circle-CvdzOiQ_.js";
|
|
7
|
+
import { C as se, a as ne } from "../chevron-down-UbkgS76q.js";
|
|
8
|
+
const B = "h-4 w-4", G = "h-5 w-5", ae = (t) => ({
|
|
9
|
+
error: "border-danger hover:border-danger focus-visible:border-danger focus-visible:ring-danger",
|
|
10
|
+
loading: "cursor-wait pointer-events-none border-input-border--disabled",
|
|
11
|
+
disabled: "cursor-not-allowed opacity-50 border-input-border--disabled bg-input-bg--disabled",
|
|
12
|
+
default: ""
|
|
13
|
+
})[t], de = (t, l, i) => b(
|
|
14
|
+
"flex h-12 w-full items-center justify-between rounded-lg border border-input-border bg-input-bg px-4 py-3 text-sm",
|
|
15
|
+
"hover:border-input-border--hover focus:border-input-border--focus focus:outline-none",
|
|
16
|
+
"focus:ring-2 focus:ring-black focus:ring-offset-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black focus-visible:ring-offset-2",
|
|
17
|
+
"disabled:cursor-not-allowed disabled:opacity-50 disabled:border-input-border--disabled disabled:bg-input-bg--disabled",
|
|
18
|
+
"transition duration-200 text-input-text [&>span]:line-clamp-1",
|
|
19
|
+
l && "border-input-border--focus ring-2 ring-black ring-offset-2",
|
|
20
|
+
ae(t),
|
|
21
|
+
i
|
|
22
|
+
), le = (t) => b(
|
|
23
|
+
"absolute top-full left-0 right-0 z-50 mt-1 max-h-96 min-w-[8rem] overflow-hidden rounded-lg border border-input-border bg-input-bg shadow-md",
|
|
24
|
+
"transition-all duration-200 origin-top",
|
|
25
|
+
t ? "scale-100 opacity-100 translate-y-0" : "scale-95 opacity-0 -translate-y-1 pointer-events-none"
|
|
26
|
+
), ie = (t) => {
|
|
27
|
+
const l = T(null);
|
|
28
|
+
return S(() => {
|
|
29
|
+
const i = (a) => {
|
|
30
|
+
l.current && !l.current.contains(a.target) && t();
|
|
31
|
+
};
|
|
32
|
+
return document.addEventListener("mousedown", i), () => document.removeEventListener("mousedown", i);
|
|
33
|
+
}, [t]), l;
|
|
34
|
+
}, oe = (t, l, i, a, m) => {
|
|
35
|
+
const [r, c] = C(-1);
|
|
36
|
+
S(() => {
|
|
37
|
+
if (m) {
|
|
38
|
+
const s = t.findIndex((g) => g.value === l);
|
|
39
|
+
c(s >= 0 ? s : 0);
|
|
40
|
+
} else
|
|
41
|
+
c(-1);
|
|
42
|
+
}, [m, l, t]);
|
|
43
|
+
const k = E(
|
|
44
|
+
(s) => {
|
|
45
|
+
if (!m)
|
|
46
|
+
return s.key === "ArrowDown" || s.key === "ArrowUp" || s.key === " " || s.key === "Enter" ? (s.preventDefault(), "open") : void 0;
|
|
47
|
+
const y = {
|
|
48
|
+
ArrowDown: () => {
|
|
49
|
+
s.preventDefault(), c((h) => {
|
|
50
|
+
const o = Math.min(h + 1, t.length - 1);
|
|
51
|
+
return t[o]?.disabled && o < t.length - 1 ? Math.min(o + 1, t.length - 1) : o;
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
ArrowUp: () => {
|
|
55
|
+
s.preventDefault(), c((h) => {
|
|
56
|
+
const o = Math.max(h - 1, 0);
|
|
57
|
+
return t[o]?.disabled && o > 0 ? Math.max(o - 1, 0) : o;
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
Enter: () => {
|
|
61
|
+
s.preventDefault(), r >= 0 && t[r] && !t[r].disabled && (i(t[r].value), a());
|
|
62
|
+
},
|
|
63
|
+
" ": () => {
|
|
64
|
+
s.preventDefault(), r >= 0 && t[r] && !t[r].disabled && (i(t[r].value), a());
|
|
65
|
+
},
|
|
66
|
+
Escape: () => {
|
|
67
|
+
s.preventDefault(), a();
|
|
68
|
+
},
|
|
69
|
+
Home: () => {
|
|
70
|
+
s.preventDefault(), c(0);
|
|
71
|
+
},
|
|
72
|
+
End: () => {
|
|
73
|
+
s.preventDefault(), c(t.length - 1);
|
|
74
|
+
}
|
|
75
|
+
}[s.key];
|
|
76
|
+
y && y();
|
|
77
|
+
},
|
|
78
|
+
[t, r, i, a, m]
|
|
79
|
+
);
|
|
80
|
+
return { focusedIndex: r, setFocusedIndex: c, handleKeyDown: k };
|
|
81
|
+
}, ce = te(
|
|
82
|
+
({
|
|
83
|
+
value: t,
|
|
84
|
+
defaultValue: l,
|
|
85
|
+
onChange: i,
|
|
86
|
+
options: a = [],
|
|
87
|
+
placeholder: m = "Select an option",
|
|
88
|
+
state: r = "default",
|
|
89
|
+
errorMessage: c,
|
|
90
|
+
emptyMessage: k = "No options found",
|
|
91
|
+
loadingMessage: s = "Loading...",
|
|
92
|
+
name: g,
|
|
93
|
+
id: y,
|
|
94
|
+
label: h,
|
|
95
|
+
className: o,
|
|
96
|
+
"aria-label": I,
|
|
97
|
+
"aria-describedby": U,
|
|
98
|
+
...j
|
|
99
|
+
}, Z) => {
|
|
100
|
+
const z = re(), L = y || `${g}-${z}`, M = `${L}-error`, [f, x] = C(!1), [P, W] = C(l || ""), A = t !== void 0, w = A ? t : P, q = ie(() => x(!1)), D = T(null), O = j.disabled || r === "disabled", J = r === "loading", Q = r === "error", v = _(() => {
|
|
101
|
+
const e = {}, u = [];
|
|
102
|
+
return a.forEach((d) => {
|
|
103
|
+
d.group ? (e[d.group] || (e[d.group] = []), e[d.group].push(d)) : u.push(d);
|
|
104
|
+
}), { groups: e, ungrouped: u, hasGroups: Object.keys(e).length > 0 };
|
|
105
|
+
}, [a]), K = _(() => a.find((e) => e.value === w), [a, w]), { focusedIndex: N, handleKeyDown: R } = oe(
|
|
106
|
+
a,
|
|
107
|
+
w,
|
|
108
|
+
F,
|
|
109
|
+
() => x(!1),
|
|
110
|
+
f
|
|
111
|
+
), V = E(() => {
|
|
112
|
+
O || x((e) => !e);
|
|
113
|
+
}, [O]);
|
|
114
|
+
function F(e) {
|
|
115
|
+
a.find((d) => d.value === e)?.disabled || (A || W(e), i?.(e), x(!1));
|
|
116
|
+
}
|
|
117
|
+
const X = E(
|
|
118
|
+
(e) => {
|
|
119
|
+
R(e) === "open" && x(!0);
|
|
120
|
+
},
|
|
121
|
+
[R]
|
|
122
|
+
);
|
|
123
|
+
S(() => {
|
|
124
|
+
if (f && N >= 0 && D.current) {
|
|
125
|
+
const e = D.current.children[N];
|
|
126
|
+
e && e.scrollIntoView({ block: "nearest" });
|
|
127
|
+
}
|
|
128
|
+
}, [N, f]);
|
|
129
|
+
const H = (e, u) => {
|
|
130
|
+
const d = w === e.value;
|
|
131
|
+
return /* @__PURE__ */ p(
|
|
132
|
+
"button",
|
|
133
|
+
{
|
|
134
|
+
type: "button",
|
|
135
|
+
className: b(
|
|
136
|
+
"relative flex w-full cursor-default items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none select-none",
|
|
137
|
+
"hover:bg-input-bg--hover focus:bg-input-bg--hover hover:cursor-pointer",
|
|
138
|
+
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
139
|
+
u === N && "bg-input-bg--hover",
|
|
140
|
+
d && "bg-input-bg--selected text-input-text"
|
|
141
|
+
),
|
|
142
|
+
onClick: () => F(e.value),
|
|
143
|
+
disabled: e.disabled,
|
|
144
|
+
"data-disabled": e.disabled,
|
|
145
|
+
"aria-selected": d,
|
|
146
|
+
role: "option",
|
|
147
|
+
children: [
|
|
148
|
+
/* @__PURE__ */ n("span", { className: "block truncate", children: e.label }),
|
|
149
|
+
d && /* @__PURE__ */ n("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ n(ne, { className: b(B, "text-input-text") }) })
|
|
150
|
+
]
|
|
151
|
+
},
|
|
152
|
+
e.value
|
|
153
|
+
);
|
|
154
|
+
}, Y = () => ({
|
|
155
|
+
"--select-min-width": "8rem",
|
|
156
|
+
"--select-border-radius": "0.5rem",
|
|
157
|
+
"--select-trigger-height": "3rem"
|
|
158
|
+
});
|
|
159
|
+
return /* @__PURE__ */ p("div", { className: "w-full", "data-testid": "select-root", children: [
|
|
160
|
+
/* @__PURE__ */ p("div", { ref: q, className: "relative", "data-testid": "select-wrapper", children: [
|
|
161
|
+
/* @__PURE__ */ p(
|
|
162
|
+
"button",
|
|
163
|
+
{
|
|
164
|
+
ref: Z,
|
|
165
|
+
type: "button",
|
|
166
|
+
id: L,
|
|
167
|
+
name: g,
|
|
168
|
+
className: de(r, f, o),
|
|
169
|
+
onClick: V,
|
|
170
|
+
onKeyDown: X,
|
|
171
|
+
disabled: O,
|
|
172
|
+
"aria-label": I || h,
|
|
173
|
+
"aria-describedby": b(Q && M, U),
|
|
174
|
+
"aria-expanded": f,
|
|
175
|
+
"aria-haspopup": "listbox",
|
|
176
|
+
"data-state": r,
|
|
177
|
+
style: Y(),
|
|
178
|
+
...j,
|
|
179
|
+
children: [
|
|
180
|
+
/* @__PURE__ */ n("span", { className: "block truncate", children: K ? K.label : /* @__PURE__ */ n("span", { className: "text-input-text-placeholder", children: m }) }),
|
|
181
|
+
/* @__PURE__ */ n("div", { className: "flex items-center", children: r === "loading" ? /* @__PURE__ */ n($, { className: b(G, "text-input-icon animate-spin") }) : /* @__PURE__ */ n(
|
|
182
|
+
se,
|
|
183
|
+
{
|
|
184
|
+
className: b(
|
|
185
|
+
G,
|
|
186
|
+
"text-input-icon transition-transform duration-200",
|
|
187
|
+
f && "rotate-180"
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
) })
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
/* @__PURE__ */ n("div", { className: le(f), "data-testid": "select-dropdown", children: /* @__PURE__ */ n("div", { className: "p-1", children: /* @__PURE__ */ n(
|
|
195
|
+
"div",
|
|
196
|
+
{
|
|
197
|
+
ref: D,
|
|
198
|
+
className: "max-h-80 overflow-x-hidden overflow-y-auto",
|
|
199
|
+
role: "listbox",
|
|
200
|
+
"aria-multiselectable": "false",
|
|
201
|
+
tabIndex: -1,
|
|
202
|
+
children: J ? /* @__PURE__ */ p("div", { className: "text-input-text-secondary flex items-center justify-center gap-2 py-6 text-sm", children: [
|
|
203
|
+
/* @__PURE__ */ n($, { className: b(B, "animate-spin") }),
|
|
204
|
+
s
|
|
205
|
+
] }) : a.length === 0 ? /* @__PURE__ */ n("div", { className: "text-input-text-secondary py-6 text-center text-sm", children: k }) : /* @__PURE__ */ p(ee, { children: [
|
|
206
|
+
v.ungrouped.length > 0 && /* @__PURE__ */ n("div", { className: "mb-1", children: v.ungrouped.map((e) => H(e, a.indexOf(e))) }),
|
|
207
|
+
Object.entries(v.groups).map(([e, u]) => /* @__PURE__ */ p("div", { className: "mb-1", children: [
|
|
208
|
+
(v.ungrouped.length > 0 || Object.keys(v.groups).indexOf(e) > 0) && /* @__PURE__ */ n("div", { className: "bg-input-border -mx-1 my-1 h-px" }),
|
|
209
|
+
/* @__PURE__ */ n("div", { className: "text-input-text-secondary px-2 py-1.5 text-sm font-semibold", children: e }),
|
|
210
|
+
u.map((d) => H(d, a.indexOf(d)))
|
|
211
|
+
] }, e))
|
|
212
|
+
] })
|
|
213
|
+
}
|
|
214
|
+
) }) })
|
|
215
|
+
] }),
|
|
216
|
+
r === "error" && c && /* @__PURE__ */ n(
|
|
217
|
+
"p",
|
|
218
|
+
{
|
|
219
|
+
id: M,
|
|
220
|
+
className: "text-danger mt-1.5 text-sm",
|
|
221
|
+
"data-testid": "select-error-message",
|
|
222
|
+
"aria-live": "polite",
|
|
223
|
+
"aria-atomic": "true",
|
|
224
|
+
children: c
|
|
225
|
+
}
|
|
226
|
+
)
|
|
227
|
+
] });
|
|
228
|
+
}
|
|
229
|
+
);
|
|
230
|
+
ce.displayName = "SelectBase";
|
|
231
|
+
export {
|
|
232
|
+
ce as SelectBase
|
|
233
|
+
};
|
package/dist/Select.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { SelectBase, SelectBaseProps, SelectOption } from './SelectBase';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export type SelectState = 'default' | 'error' | 'disabled' | 'loading';
|
|
4
|
+
export type SelectItem = {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export interface SelectProps extends Omit<SelectBaseProps, 'options' | 'onChange'> {
|
|
10
|
+
contentClassName?: string;
|
|
11
|
+
defaultValue?: string;
|
|
12
|
+
itemClassName?: string;
|
|
13
|
+
items: SelectItem[];
|
|
14
|
+
onValueChange?: (value: string) => void;
|
|
15
|
+
placeholder: string;
|
|
16
|
+
triggerClassName?: string;
|
|
17
|
+
value?: string;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
name?: string;
|
|
20
|
+
id?: string;
|
|
21
|
+
state?: SelectState;
|
|
22
|
+
emptyMessage?: ReactNode;
|
|
23
|
+
errorMessage?: string;
|
|
24
|
+
label?: string;
|
|
25
|
+
'aria-label'?: string;
|
|
26
|
+
'aria-describedby'?: string;
|
|
27
|
+
}
|
|
28
|
+
declare const Select: import('react').ForwardRefExoticComponent<SelectProps & import('react').RefAttributes<HTMLButtonElement>> & {
|
|
29
|
+
Root: ({ children, ...props }: {
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
} & any) => import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
Group: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
33
|
+
Value: ({ placeholder, children }: {
|
|
34
|
+
placeholder?: string;
|
|
35
|
+
children?: ReactNode;
|
|
36
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
Trigger: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import('react').RefAttributes<HTMLButtonElement>>;
|
|
38
|
+
Content: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
39
|
+
Label: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
40
|
+
Item: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
} & import('react').RefAttributes<HTMLDivElement>>;
|
|
43
|
+
Separator: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
44
|
+
EmptyMessage: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
45
|
+
LoadingMessage: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
46
|
+
message?: string;
|
|
47
|
+
} & import('react').RefAttributes<HTMLDivElement>>;
|
|
48
|
+
};
|
|
49
|
+
export { Select, SelectBase, type SelectBaseProps, type SelectOption };
|
|
50
|
+
//# sourceMappingURL=Select.d.ts.map
|
package/dist/Select.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "./styles/main.css";
|
|
3
|
+
import { jsx as s, jsxs as m } from "react/jsx-runtime";
|
|
4
|
+
import { SelectBase as E } from "./Select/SelectBase.js";
|
|
5
|
+
import { c as i } from "./twUtils-CRiPKpXj.js";
|
|
6
|
+
import { forwardRef as o, useId as $ } from "react";
|
|
7
|
+
import { a as k } from "./chevron-down-UbkgS76q.js";
|
|
8
|
+
import { L as O } from "./loader-circle-CvdzOiQ_.js";
|
|
9
|
+
const q = ({ children: e, ...t }) => /* @__PURE__ */ s("div", { ...t, children: e }), p = o(({ className: e, ...t }, a) => /* @__PURE__ */ s("div", { ref: a, className: i("text-text-secondary px-2 py-1.5 text-sm font-semibold", e), ...t }));
|
|
10
|
+
p.displayName = "SelectGroup";
|
|
11
|
+
const z = ({ placeholder: e, children: t }) => /* @__PURE__ */ s("span", { children: t || e }), b = o(
|
|
12
|
+
({ className: e, children: t, ...a }, l) => /* @__PURE__ */ s("button", { ref: l, className: e, ...a, children: t })
|
|
13
|
+
);
|
|
14
|
+
b.displayName = "SelectTrigger";
|
|
15
|
+
const u = o(
|
|
16
|
+
({ className: e, children: t, ...a }, l) => /* @__PURE__ */ s("div", { ref: l, className: e, ...a, children: t })
|
|
17
|
+
);
|
|
18
|
+
u.displayName = "SelectContent";
|
|
19
|
+
const g = o(({ className: e, ...t }, a) => /* @__PURE__ */ s("div", { ref: a, className: i("text-input-text-secondary px-2 py-1.5 text-sm font-semibold", e), ...t }));
|
|
20
|
+
g.displayName = "SelectLabel";
|
|
21
|
+
const y = o(
|
|
22
|
+
({ className: e, children: t, disabled: a, ...l }, r) => /* @__PURE__ */ m(
|
|
23
|
+
"div",
|
|
24
|
+
{
|
|
25
|
+
ref: r,
|
|
26
|
+
className: i(
|
|
27
|
+
"relative flex w-full cursor-default items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none select-none",
|
|
28
|
+
"hover:bg-input-bg--hover focus:bg-input-bg--hover hover:cursor-pointer",
|
|
29
|
+
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
30
|
+
e
|
|
31
|
+
),
|
|
32
|
+
"data-disabled": a,
|
|
33
|
+
...l,
|
|
34
|
+
children: [
|
|
35
|
+
/* @__PURE__ */ s("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ s(k, { className: "text-input-text h-4 w-4" }) }),
|
|
36
|
+
/* @__PURE__ */ s("span", { children: t })
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
y.displayName = "SelectItem";
|
|
42
|
+
const x = o(({ className: e, ...t }, a) => /* @__PURE__ */ s("div", { ref: a, className: i("bg-input-border -mx-1 my-1 h-px", e), ...t }));
|
|
43
|
+
x.displayName = "SelectSeparator";
|
|
44
|
+
const S = o(
|
|
45
|
+
({ className: e, children: t, ...a }, l) => /* @__PURE__ */ s(
|
|
46
|
+
"div",
|
|
47
|
+
{
|
|
48
|
+
ref: l,
|
|
49
|
+
className: i("text-input-text-secondary py-6 text-center text-sm", e),
|
|
50
|
+
role: "status",
|
|
51
|
+
...a,
|
|
52
|
+
children: t
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
);
|
|
56
|
+
S.displayName = "SelectEmptyMessage";
|
|
57
|
+
const f = o(
|
|
58
|
+
({ className: e, message: t = "Loading...", children: a, ...l }, r) => /* @__PURE__ */ m(
|
|
59
|
+
"div",
|
|
60
|
+
{
|
|
61
|
+
ref: r,
|
|
62
|
+
className: i("text-input-text-secondary flex items-center justify-center gap-2 py-6 text-sm", e),
|
|
63
|
+
role: "status",
|
|
64
|
+
"aria-live": "polite",
|
|
65
|
+
...l,
|
|
66
|
+
children: [
|
|
67
|
+
/* @__PURE__ */ s(O, { className: "h-4 w-4 animate-spin" }),
|
|
68
|
+
a || t
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
);
|
|
73
|
+
f.displayName = "SelectLoadingMessage";
|
|
74
|
+
const N = o((e, t) => {
|
|
75
|
+
const {
|
|
76
|
+
defaultValue: a,
|
|
77
|
+
items: l = [],
|
|
78
|
+
onValueChange: r,
|
|
79
|
+
placeholder: v,
|
|
80
|
+
triggerClassName: h,
|
|
81
|
+
value: C,
|
|
82
|
+
disabled: L,
|
|
83
|
+
name: c,
|
|
84
|
+
id: I,
|
|
85
|
+
state: d = "default",
|
|
86
|
+
emptyMessage: M = "No items found",
|
|
87
|
+
errorMessage: j,
|
|
88
|
+
label: w,
|
|
89
|
+
"aria-label": V,
|
|
90
|
+
"aria-describedby": D,
|
|
91
|
+
...G
|
|
92
|
+
} = e, R = $(), T = I || `${c}-${R}`, B = l.map((n) => ({
|
|
93
|
+
label: n.label,
|
|
94
|
+
value: n.value,
|
|
95
|
+
disabled: n.disabled
|
|
96
|
+
}));
|
|
97
|
+
return /* @__PURE__ */ s(
|
|
98
|
+
E,
|
|
99
|
+
{
|
|
100
|
+
ref: t,
|
|
101
|
+
id: T,
|
|
102
|
+
name: c,
|
|
103
|
+
value: C,
|
|
104
|
+
defaultValue: a,
|
|
105
|
+
onChange: r,
|
|
106
|
+
options: B,
|
|
107
|
+
placeholder: v,
|
|
108
|
+
state: d,
|
|
109
|
+
errorMessage: j,
|
|
110
|
+
emptyMessage: M,
|
|
111
|
+
label: w,
|
|
112
|
+
disabled: L || d === "disabled",
|
|
113
|
+
"aria-label": V,
|
|
114
|
+
"aria-describedby": D,
|
|
115
|
+
className: h,
|
|
116
|
+
...G
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
});
|
|
120
|
+
N.displayName = "Select";
|
|
121
|
+
const U = Object.assign(N, {
|
|
122
|
+
Root: q,
|
|
123
|
+
Group: p,
|
|
124
|
+
Value: z,
|
|
125
|
+
Trigger: b,
|
|
126
|
+
Content: u,
|
|
127
|
+
Label: g,
|
|
128
|
+
Item: y,
|
|
129
|
+
Separator: x,
|
|
130
|
+
EmptyMessage: S,
|
|
131
|
+
LoadingMessage: f
|
|
132
|
+
});
|
|
133
|
+
export {
|
|
134
|
+
U as Select,
|
|
135
|
+
E as SelectBase
|
|
136
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ChangeEvent, ClipboardEvent, FocusEvent } from 'react';
|
|
2
|
+
export type UseTextareaOptions = {
|
|
3
|
+
maxLength: number;
|
|
4
|
+
value: string;
|
|
5
|
+
onChange?: (e: ChangeEvent<HTMLTextAreaElement>) => void;
|
|
6
|
+
onFocus?: (e: FocusEvent<HTMLTextAreaElement>) => void;
|
|
7
|
+
onBlur?: (e: FocusEvent<HTMLTextAreaElement>) => void;
|
|
8
|
+
};
|
|
9
|
+
export type UseTextareaReturn = {
|
|
10
|
+
handleFocus: (e: FocusEvent<HTMLTextAreaElement>) => void;
|
|
11
|
+
handleBlur: (e: FocusEvent<HTMLTextAreaElement>) => void;
|
|
12
|
+
handleChange: (e: ChangeEvent<HTMLTextAreaElement>) => void;
|
|
13
|
+
handlePaste: (e: ClipboardEvent<HTMLTextAreaElement>) => void;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Custom hook for textarea functionality with character limits and event handling
|
|
17
|
+
*/
|
|
18
|
+
export declare const useTextarea: ({ maxLength, value, onChange, onFocus, onBlur }: UseTextareaOptions) => UseTextareaReturn;
|
|
19
|
+
//# sourceMappingURL=TextareaUtils.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback as i } from "react";
|
|
3
|
+
const v = (t, s, a) => {
|
|
4
|
+
t.target.value.length <= s && a?.(t);
|
|
5
|
+
}, V = (t, s, a, r) => {
|
|
6
|
+
const c = t.clipboardData.getData("text"), o = s || "", n = t.currentTarget, l = n.selectionStart || 0, u = n.selectionEnd || 0, e = o.substring(0, l), d = o.substring(u);
|
|
7
|
+
if ((e + c + d).length > a) {
|
|
8
|
+
t.preventDefault();
|
|
9
|
+
const b = u - l, f = a - o.length + b, p = c.substring(0, Math.max(0, f)), g = e + p + d, T = {
|
|
10
|
+
target: { value: g, name: n.name },
|
|
11
|
+
currentTarget: { value: g, name: n.name },
|
|
12
|
+
type: "change",
|
|
13
|
+
preventDefault: () => {
|
|
14
|
+
},
|
|
15
|
+
stopPropagation: () => {
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
r?.(T), setTimeout(() => {
|
|
19
|
+
const h = l + p.length;
|
|
20
|
+
n.setSelectionRange(h, h);
|
|
21
|
+
}, 0);
|
|
22
|
+
}
|
|
23
|
+
}, m = ({ maxLength: t, value: s, onChange: a, onFocus: r, onBlur: c }) => {
|
|
24
|
+
const o = i(
|
|
25
|
+
(e) => {
|
|
26
|
+
r?.(e);
|
|
27
|
+
},
|
|
28
|
+
[r]
|
|
29
|
+
), n = i(
|
|
30
|
+
(e) => {
|
|
31
|
+
c?.(e);
|
|
32
|
+
},
|
|
33
|
+
[c]
|
|
34
|
+
), l = i(
|
|
35
|
+
(e) => {
|
|
36
|
+
v(e, t, a);
|
|
37
|
+
},
|
|
38
|
+
[t, a]
|
|
39
|
+
), u = i(
|
|
40
|
+
(e) => {
|
|
41
|
+
V(e, s, t, a);
|
|
42
|
+
},
|
|
43
|
+
[s, t, a]
|
|
44
|
+
);
|
|
45
|
+
return {
|
|
46
|
+
handleFocus: o,
|
|
47
|
+
handleBlur: n,
|
|
48
|
+
handleChange: l,
|
|
49
|
+
handlePaste: u
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export {
|
|
53
|
+
m as useTextarea
|
|
54
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ChangeEvent, ComponentProps, FocusEvent } from 'react';
|
|
2
|
+
export type TextareaState = 'default' | 'error' | 'disabled' | 'loading';
|
|
3
|
+
export type TextareaProps = ComponentProps<'textarea'> & {
|
|
4
|
+
className?: string;
|
|
5
|
+
state?: TextareaState;
|
|
6
|
+
errorMessage?: string;
|
|
7
|
+
name: string;
|
|
8
|
+
id?: string;
|
|
9
|
+
label: string;
|
|
10
|
+
value?: string;
|
|
11
|
+
maxLength?: number;
|
|
12
|
+
onFocus?: (e: FocusEvent<HTMLTextAreaElement>) => void;
|
|
13
|
+
onBlur?: (e: FocusEvent<HTMLTextAreaElement>) => void;
|
|
14
|
+
onChange?: (e: ChangeEvent<HTMLTextAreaElement>) => void;
|
|
15
|
+
};
|
|
16
|
+
export declare const Textarea: import('react').ForwardRefExoticComponent<Omit<TextareaProps, "ref"> & import('react').RefAttributes<HTMLTextAreaElement>>;
|
|
17
|
+
//# sourceMappingURL=Textarea.d.ts.map
|