@spear-ai/spectral 1.4.12 → 1.4.14
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/Accordion.js +4 -4
- package/dist/Button.js +1 -1
- package/dist/Dialog.d.ts +16 -11
- package/dist/Dialog.js +68 -50
- package/dist/Drawer.js +1 -1
- package/dist/HoverCard.js +4 -4
- package/dist/Icons/IconBase.d.ts +1 -2
- package/dist/Icons/IconBase.js +8 -8
- package/dist/Popover.js +6 -6
- package/dist/RadioGroup.js +5 -5
- package/dist/Select.js +1 -1
- package/dist/Slider.js +3 -3
- package/dist/Tooltip.js +6 -6
- package/dist/Tray.js +1 -1
- package/dist/index-BFu0M-5-.js +240 -0
- package/dist/{index-y6Br5T4h.js → index-BRDfoF8s.js} +1 -1
- package/dist/{index-CevVJ05e.js → index-BSCg4Mei.js} +7 -7
- package/dist/{index-CVSxKOPp.js → index-CDYW5LDR.js} +1 -1
- package/dist/{index-BhufZRa2.js → index-CfypDjr2.js} +6 -6
- package/dist/{index-B-GQStVW.js → index-CpUJ8sN0.js} +171 -168
- package/dist/{index-B2oBi8ng.js → index-D-PVGGln.js} +1 -1
- package/dist/{index-NzygPVvJ.js → index-DMDsy0y2.js} +2 -2
- package/dist/{index-6Abv_Flm.js → index-DdOwqCfb.js} +1 -1
- package/dist/{index-UEFPWH8U.js → index-DvqEQspb.js} +7 -7
- package/dist/{index-CGALWSq_.js → index-bcth-MVh.js} +1 -1
- package/dist/index-jgQ7sgLl.js +1037 -0
- package/dist/primitives/select.js +1 -1
- package/dist/styles/main.css +1 -1
- package/package.json +3 -1
- package/dist/Dialog/DialogBase.d.ts +0 -86
- package/dist/Dialog/DialogBase.js +0 -215
- package/dist/index-CAKA12cC.js +0 -1265
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import "../styles/main.css";
|
|
3
|
-
import { jsx as r, jsxs as I } from "react/jsx-runtime";
|
|
4
|
-
import { CloseIcon as V } from "../Icons/CloseIcon.js";
|
|
5
|
-
import { cn as g } from "../utils/twUtils.js";
|
|
6
|
-
import { c as $ } from "../index-D29mdTf5.js";
|
|
7
|
-
import { createContext as j, useContext as W, useState as O, useMemo as B, useCallback as C, cloneElement as N, useEffect as h, useRef as D, useLayoutEffect as M, isValidElement as R } from "react";
|
|
8
|
-
import { createPortal as S } from "react-dom";
|
|
9
|
-
const z = j(null);
|
|
10
|
-
function p() {
|
|
11
|
-
const t = W(z);
|
|
12
|
-
if (!t)
|
|
13
|
-
throw new Error("Dialog components must be used within <Dialog>");
|
|
14
|
-
return t;
|
|
15
|
-
}
|
|
16
|
-
function P(t) {
|
|
17
|
-
return R(t) && typeof t.type != "string" ? !0 : R(t);
|
|
18
|
-
}
|
|
19
|
-
let E = 0;
|
|
20
|
-
function Q({ isOpen: t, defaultOpen: o = !1, onOpenChange: e, children: n, modal: a = !1 }) {
|
|
21
|
-
const [l, u] = O(o), s = t !== void 0, f = s ? t : l, y = B(
|
|
22
|
-
() => ({
|
|
23
|
-
contentId: `dialog-content-${++E}`,
|
|
24
|
-
descriptionId: `dialog-description-${E}`,
|
|
25
|
-
titleId: `dialog-title-${E}`
|
|
26
|
-
}),
|
|
27
|
-
[]
|
|
28
|
-
), b = C(
|
|
29
|
-
(c) => {
|
|
30
|
-
s || u(c), e?.(c);
|
|
31
|
-
},
|
|
32
|
-
[s, e]
|
|
33
|
-
), k = B(
|
|
34
|
-
() => ({
|
|
35
|
-
modal: a,
|
|
36
|
-
isOpen: f,
|
|
37
|
-
setIsOpen: b,
|
|
38
|
-
...y
|
|
39
|
-
}),
|
|
40
|
-
[f, b, a, y]
|
|
41
|
-
);
|
|
42
|
-
return /* @__PURE__ */ r(z.Provider, { value: k, children: n });
|
|
43
|
-
}
|
|
44
|
-
function X({ children: t, asChild: o = !0, dataTestId: e }) {
|
|
45
|
-
const { setIsOpen: n } = p(), a = C(() => {
|
|
46
|
-
n(!0);
|
|
47
|
-
}, [n]);
|
|
48
|
-
if (!o)
|
|
49
|
-
return /* @__PURE__ */ r("button", { "data-slot": "dialog-trigger", "data-testid": e, onClick: a, tabIndex: 0, children: t });
|
|
50
|
-
if (!P(t))
|
|
51
|
-
throw new Error("DialogTrigger expects a single React element as child");
|
|
52
|
-
const l = t.props.onClick;
|
|
53
|
-
return N(t, {
|
|
54
|
-
onClick: (...u) => {
|
|
55
|
-
l?.(...u), a();
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
function A({ children: t, asChild: o = !0, dataTestId: e }) {
|
|
60
|
-
const { setIsOpen: n } = p(), a = C(() => {
|
|
61
|
-
n(!1);
|
|
62
|
-
}, [n]);
|
|
63
|
-
if (!o)
|
|
64
|
-
return /* @__PURE__ */ r("button", { className: "cursor-pointer focus-visible:outline-none outline-transparent focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1", "data-slot": "dialog-close", "data-testid": e, onClick: a, tabIndex: 0, children: t });
|
|
65
|
-
if (!P(t))
|
|
66
|
-
throw new Error("DialogClose expects a single React element as child");
|
|
67
|
-
const l = t.props.onClick;
|
|
68
|
-
return N(t, {
|
|
69
|
-
onClick: (...u) => {
|
|
70
|
-
l?.(...u), a();
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
function T({ children: t, container: o }) {
|
|
75
|
-
const [e, n] = O(!1);
|
|
76
|
-
return h(() => (n(!0), () => n(!1)), []), e ? S(t, o ?? document.body) : null;
|
|
77
|
-
}
|
|
78
|
-
function Y({ className: t, dataTestId: o }) {
|
|
79
|
-
const { isOpen: e, setIsOpen: n } = p(), a = C(
|
|
80
|
-
(l) => {
|
|
81
|
-
l.target === l.currentTarget && n(!1);
|
|
82
|
-
},
|
|
83
|
-
[n]
|
|
84
|
-
);
|
|
85
|
-
return e ? /* @__PURE__ */ r(T, { children: /* @__PURE__ */ r(
|
|
86
|
-
"div",
|
|
87
|
-
{
|
|
88
|
-
"aria-hidden": "true",
|
|
89
|
-
className: g("fixed inset-0 z-40 bg-black/50 backdrop-blur-sm data-[state=open]:animate-in data-[state=open]:fade-in-0", "data-[state=closed]:animate-out data-[state=closed]:fade-out-0", t),
|
|
90
|
-
"data-state": e ? "open" : "closed",
|
|
91
|
-
"data-testid": o,
|
|
92
|
-
onClick: a
|
|
93
|
-
}
|
|
94
|
-
) }) : null;
|
|
95
|
-
}
|
|
96
|
-
const F = $(
|
|
97
|
-
[
|
|
98
|
-
"fixed left-1/2 top-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 rounded-lg shadow-lg outline-none data-[state=open]:animate-in data-[state=open]:fade-in-0",
|
|
99
|
-
"data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 max-h-[80vh] overflow-y-auto"
|
|
100
|
-
],
|
|
101
|
-
{
|
|
102
|
-
variants: {
|
|
103
|
-
size: {
|
|
104
|
-
sm: "max-w-sm",
|
|
105
|
-
md: "max-w-md",
|
|
106
|
-
lg: "max-w-lg",
|
|
107
|
-
xl: "max-w-xl",
|
|
108
|
-
"2xl": "max-w-2xl"
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
defaultVariants: {
|
|
112
|
-
size: "md"
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
);
|
|
116
|
-
function Z({ children: t, className: o, dataTestId: e, onEscapeKeyDown: n, onInteractOutside: a, onPointerDownOutside: l, size: u }) {
|
|
117
|
-
const { isOpen: s, setIsOpen: f, contentId: y, titleId: b, descriptionId: k, modal: c } = p(), m = D(null), x = D(null), w = D(!1);
|
|
118
|
-
return h(() => {
|
|
119
|
-
if (!s) {
|
|
120
|
-
w.current && x.current && typeof x.current.focus == "function" && x.current.focus(), x.current = null, w.current = !1;
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
if (!m.current || w.current) return;
|
|
124
|
-
w.current = !0;
|
|
125
|
-
const d = m.current;
|
|
126
|
-
x.current = document.activeElement, setTimeout(() => {
|
|
127
|
-
if (!d || !m.current) return;
|
|
128
|
-
const i = document.activeElement;
|
|
129
|
-
(!d.contains(i) || i === document.body) && d.focus();
|
|
130
|
-
}, 0);
|
|
131
|
-
}, [s, f]), h(() => {
|
|
132
|
-
if (!s) return;
|
|
133
|
-
const d = (i) => {
|
|
134
|
-
i.key === "Escape" && (n?.(i), a?.(i), i.defaultPrevented || (i.preventDefault(), f(!1)));
|
|
135
|
-
};
|
|
136
|
-
return document.addEventListener("keydown", d, { capture: !0 }), () => {
|
|
137
|
-
document.removeEventListener("keydown", d, { capture: !0 });
|
|
138
|
-
};
|
|
139
|
-
}, [s, n, a]), h(() => {
|
|
140
|
-
if (!s) return;
|
|
141
|
-
const d = (i) => {
|
|
142
|
-
const v = i.target;
|
|
143
|
-
m.current && !m.current.contains(v) && (l?.(i), a?.(i), !c && !i.defaultPrevented && f(!1));
|
|
144
|
-
};
|
|
145
|
-
return document.addEventListener("pointerdown", d), () => document.removeEventListener("pointerdown", d);
|
|
146
|
-
}, [s, l, a, f, c]), M(() => {
|
|
147
|
-
if (!s || !c || typeof window > "u") return;
|
|
148
|
-
const d = document.body.style.overflow, i = document.body.style.paddingRight, v = window.innerWidth - document.documentElement.clientWidth;
|
|
149
|
-
if (document.body.style.overflow = "hidden", v > 0) {
|
|
150
|
-
const L = window.getComputedStyle(document.body).paddingRight;
|
|
151
|
-
document.body.style.paddingRight = `calc(${L} + ${v}px)`;
|
|
152
|
-
}
|
|
153
|
-
return () => {
|
|
154
|
-
document.body.style.overflow = d, document.body.style.paddingRight = i;
|
|
155
|
-
};
|
|
156
|
-
}, [s, c]), s ? /* @__PURE__ */ r(T, { children: /* @__PURE__ */ I(
|
|
157
|
-
"div",
|
|
158
|
-
{
|
|
159
|
-
"aria-describedby": k,
|
|
160
|
-
"aria-labelledby": b,
|
|
161
|
-
"aria-modal": c ? "true" : void 0,
|
|
162
|
-
className: g(F({ size: u }), o),
|
|
163
|
-
"data-slot": "dialog-content",
|
|
164
|
-
"data-state": s ? "open" : "closed",
|
|
165
|
-
"data-testid": e,
|
|
166
|
-
id: y,
|
|
167
|
-
ref: m,
|
|
168
|
-
role: "dialog",
|
|
169
|
-
tabIndex: -1,
|
|
170
|
-
children: [
|
|
171
|
-
/* @__PURE__ */ r(A, { asChild: !0, children: /* @__PURE__ */ I(
|
|
172
|
-
"button",
|
|
173
|
-
{
|
|
174
|
-
"aria-label": "Close dialog",
|
|
175
|
-
className: g("absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100", "focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none cursor-pointer"),
|
|
176
|
-
"data-slot": "dialog-close",
|
|
177
|
-
"data-testid": "spectral-dialog-close-icon",
|
|
178
|
-
children: [
|
|
179
|
-
/* @__PURE__ */ r(V, { size: 16 }),
|
|
180
|
-
/* @__PURE__ */ r("span", { className: "sr-only", children: "Close" })
|
|
181
|
-
]
|
|
182
|
-
}
|
|
183
|
-
) }),
|
|
184
|
-
t
|
|
185
|
-
]
|
|
186
|
-
}
|
|
187
|
-
) }) : null;
|
|
188
|
-
}
|
|
189
|
-
function _({ children: t, className: o, dataTestId: e }) {
|
|
190
|
-
const { titleId: n } = p();
|
|
191
|
-
return /* @__PURE__ */ r("h2", { className: g("text-base font-semibold leading-none tracking-tight", o), "data-slot": "dialog-title", "data-testid": e, id: n, children: t });
|
|
192
|
-
}
|
|
193
|
-
function tt({ children: t, className: o, dataTestId: e }) {
|
|
194
|
-
const { descriptionId: n } = p();
|
|
195
|
-
return /* @__PURE__ */ r("p", { className: g("text-sm text-text-secondary", o), "data-slot": "dialog-description", "data-testid": e, id: n, children: t });
|
|
196
|
-
}
|
|
197
|
-
function et({ children: t, className: o, dataTestId: e }) {
|
|
198
|
-
return /* @__PURE__ */ r("div", { className: g("flex flex-col space-y-1.5 text-center text-left", o), "data-slot": "dialog-header", "data-testid": e, children: t });
|
|
199
|
-
}
|
|
200
|
-
function nt({ children: t, className: o, dataTestId: e }) {
|
|
201
|
-
return /* @__PURE__ */ r("div", { className: g("flex flex-col-reverse flex-row justify-end space-x-2", o), "data-slot": "dialog-footer", "data-testid": e, children: t });
|
|
202
|
-
}
|
|
203
|
-
export {
|
|
204
|
-
Q as DialogBase,
|
|
205
|
-
A as DialogCloseBase,
|
|
206
|
-
Z as DialogContentBase,
|
|
207
|
-
tt as DialogDescriptionBase,
|
|
208
|
-
nt as DialogFooterBase,
|
|
209
|
-
et as DialogHeaderBase,
|
|
210
|
-
Y as DialogOverlayBase,
|
|
211
|
-
T as DialogPortalBase,
|
|
212
|
-
_ as DialogTitleBase,
|
|
213
|
-
X as DialogTriggerBase,
|
|
214
|
-
p as useDialogContext
|
|
215
|
-
};
|