@spear-ai/spectral 1.6.17 → 1.8.0
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 +201 -200
- package/dist/Accordion.d.ts +13 -15
- package/dist/Accordion.js +184 -179
- package/dist/Alert/AlertBase.d.ts +7 -7
- package/dist/Alert/AlertBase.js +21 -21
- package/dist/Alert.d.ts +2 -2
- package/dist/Alert.js +31 -31
- package/dist/Avatar.d.ts +2 -2
- package/dist/Avatar.js +30 -22
- package/dist/Badge.d.ts +1 -1
- package/dist/Badge.js +3 -2
- package/dist/Button.d.ts +3 -3
- package/dist/Button.js +108 -46
- package/dist/ButtonGroup/ButtonGroupButton.d.ts +1 -1
- package/dist/ButtonGroup/ButtonGroupButton.js +5 -5
- package/dist/ButtonGroup.d.ts +5 -5
- package/dist/ButtonGroup.js +21 -21
- package/dist/ButtonIcon.d.ts +2 -2
- package/dist/ButtonIcon.js +30 -31
- package/dist/Checkbox/CheckboxBase.d.ts +2 -2
- package/dist/Checkbox/CheckboxBase.js +50 -57
- package/dist/Checkbox.js +15 -19
- package/dist/DataCard/Card.d.ts +1 -1
- package/dist/DataCard/Card.js +1 -1
- package/dist/DataCard.js +1 -1
- package/dist/DateTimePicker/Calendar.d.ts +4 -4
- package/dist/DateTimePicker/Calendar.js +3 -3
- package/dist/DateTimePicker/DateTimeDisplayInput.js +126 -136
- package/dist/DateTimePicker/DateTimeInput.js +4 -4
- package/dist/DateTimePicker/DateTimeUtils.d.ts +31 -31
- package/dist/DateTimePicker/DateTimeUtils.js +139 -197
- package/dist/DateTimePicker/TimePicker.d.ts +4 -4
- package/dist/DateTimePicker/TimePicker.js +3 -3
- package/dist/DateTimePicker.d.ts +5 -5
- package/dist/DateTimePicker.js +90 -70
- package/dist/Dialog.d.ts +13 -13
- package/dist/Dialog.js +57 -84
- package/dist/Drawer.d.ts +2 -2
- package/dist/Drawer.js +8 -8
- package/dist/HoverCard.d.ts +6 -5
- package/dist/HoverCard.js +64 -64
- package/dist/Icons/PolygonIcon.d.ts +5 -0
- package/dist/Icons/PolygonIcon.js +40 -0
- package/dist/Icons/index.d.ts +1 -1
- package/dist/Icons.js +34 -34
- package/dist/IconsAnimated/PanelLeftCloseIcon.js +2 -2
- package/dist/IconsAnimated/PanelLeftOpenIcon.js +2 -2
- package/dist/Input/InputUtils.d.ts +2 -2
- package/dist/Input/InputUtils.js +4 -4
- package/dist/Input.d.ts +1 -1
- package/dist/Input.js +19 -19
- package/dist/InputOTP.d.ts +10 -10
- package/dist/InputOTP.js +114 -114
- package/dist/Kbd.d.ts +8 -5
- package/dist/Kbd.js +85 -20
- package/dist/Label.d.ts +4 -2
- package/dist/Label.js +3 -3
- package/dist/MultiSelect/MultiSelectBase.d.ts +1 -1
- package/dist/MultiSelect/MultiSelectBase.js +278 -202
- package/dist/MultiSelect.d.ts +6 -6
- package/dist/MultiSelect.js +9 -9
- package/dist/Popover.js +22 -237
- package/dist/RadioButtonGroup/RadioButtonGroupBase.d.ts +11 -11
- package/dist/RadioButtonGroup/RadioButtonGroupBase.js +28 -28
- package/dist/RadioButtonGroup.d.ts +1 -1
- package/dist/RadioGroup.d.ts +15 -15
- package/dist/RadioGroup.js +253 -236
- package/dist/Select.d.ts +3 -1
- package/dist/Select.js +91 -88
- package/dist/Separator.js +4 -4
- package/dist/Skeleton.d.ts +1 -2
- package/dist/Skeleton.js +2 -4
- package/dist/Slider.d.ts +6 -6
- package/dist/Slider.js +78 -78
- package/dist/Switch/SwitchBase.d.ts +4 -4
- package/dist/Switch/SwitchBase.js +75 -111
- package/dist/Switch.d.ts +4 -4
- package/dist/Switch.js +122 -33
- package/dist/Tabs/TabsBase.js +39 -38
- package/dist/Tabs/tabsUtils.js +7 -7
- package/dist/Tabs.d.ts +0 -4
- package/dist/Tabs.js +62 -66
- package/dist/Textarea/TextareaUtils.d.ts +7 -7
- package/dist/Textarea/TextareaUtils.js +13 -13
- package/dist/Textarea.js +28 -18
- package/dist/Toast.d.ts +43 -0
- package/dist/Toast.js +883 -0
- package/dist/Toggle/ToggleBase.d.ts +4 -4
- package/dist/Toggle/ToggleBase.js +32 -33
- package/dist/Toggle.d.ts +1 -1
- package/dist/Toggle.js +7 -12
- package/dist/ToggleGroup/ToggleGroupBase.d.ts +5 -5
- package/dist/ToggleGroup/ToggleGroupBase.js +30 -30
- package/dist/ToggleGroup.d.ts +1 -1
- package/dist/ToggleGroup.js +27 -30
- package/dist/Tooltip.d.ts +1 -1
- package/dist/Tooltip.js +97 -97
- package/dist/Tray.d.ts +9 -9
- package/dist/Tray.js +71 -70
- package/dist/hooks/useAccordionAutoScroll.d.ts.map +1 -1
- package/dist/hooks/useAccordionAutoScroll.js +42 -39
- package/dist/hooks/useControllableState.d.ts +2 -2
- package/dist/hooks/useControllableState.d.ts.map +1 -1
- package/dist/hooks/useControllableState.js +2 -2
- package/dist/index-C12FUuIW.js +13 -0
- package/dist/{index-yU8jOTzS.js → index-CpovUAO-.js} +1 -1
- package/dist/{index-BdS7Ix8W.js → index-CqbPiOid.js} +1 -1
- package/dist/{index-B3UpsZ2x.js → index-CrjD9cAD.js} +1 -1
- package/dist/index-DEYs15GP.js +66 -0
- package/dist/index-DdFoGvON.js +146 -0
- package/dist/index-Q3N6lgwg.js +225 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/primitives/button.d.ts +1 -1
- package/dist/primitives/button.js +4 -4
- package/dist/primitives/input.d.ts.map +1 -1
- package/dist/primitives/input.js +8 -5
- package/dist/primitives/select.d.ts +12 -13
- package/dist/primitives/select.d.ts.map +1 -1
- package/dist/primitives/select.js +59 -88
- package/dist/primitives/slot.d.ts +5 -5
- package/dist/primitives/slot.d.ts.map +1 -1
- package/dist/primitives/slot.js +24 -33
- package/dist/primitives/textarea.d.ts.map +1 -1
- package/dist/primitives/textarea.js +4 -3
- package/dist/{proxy-Cukf-VVj.js → proxy-CgaCj1WQ.js} +7 -3
- package/dist/styles/base-colors.css +30 -30
- package/dist/styles/horizon/base-colors.css +30 -30
- package/dist/styles/horizon/colors.css +43 -13
- package/dist/styles/horizon/utilities.css +26 -3
- package/dist/styles/main.css +1 -1
- package/dist/styles/spectral.css +2 -2
- package/dist/styles/theme.css +99 -46
- package/dist/{use-animation-zNd5Nq85.js → use-animation-CR-SdV2l.js} +1 -1
- package/dist/utils/formFieldUtils.d.ts +2 -2
- package/dist/utils/formFieldUtils.d.ts.map +1 -1
- package/dist/utils/formFieldUtils.js +14 -11
- package/dist/utils/sharedUtils.d.ts +3 -3
- package/dist/utils/sharedUtils.d.ts.map +1 -1
- package/dist/utils/sharedUtils.js +1 -4
- package/dist/utils/twUtils.d.ts +1 -1
- package/dist/utils/twUtils.d.ts.map +1 -1
- package/dist/utils/twUtils.js +1 -4
- package/package.json +6 -1
- package/dist/Icons/LineToolIcon2.d.ts +0 -5
- package/dist/Icons/LineToolIcon2.js +0 -49
- package/dist/createLucideIcon-D4r5Phnh.js +0 -70
- package/dist/index-CeP1E2kK.js +0 -209
- package/dist/index-Dy-Hzr7y.js +0 -13
package/dist/Tray.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "./styles/main.css";
|
|
3
|
-
import { jsx as
|
|
3
|
+
import { jsx as e, jsxs as x } from "react/jsx-runtime";
|
|
4
4
|
import { ButtonIcon as K } from "./ButtonIcon.js";
|
|
5
5
|
import "./Icons/AnalyzeIcon.js";
|
|
6
6
|
import "./Icons/AnnotationsIcon.js";
|
|
@@ -15,7 +15,7 @@ import "./Icons/ChevronDownIcon.js";
|
|
|
15
15
|
import "./Icons/ChevronUpIcon.js";
|
|
16
16
|
import "./Icons/ClockIcon.js";
|
|
17
17
|
import "./Icons/CloseCircleIcon.js";
|
|
18
|
-
import { CloseIcon as
|
|
18
|
+
import { CloseIcon as f } from "./Icons/CloseIcon.js";
|
|
19
19
|
import "./Icons/DashboardIcon.js";
|
|
20
20
|
import "./Icons/DatabaseIcon.js";
|
|
21
21
|
import "./Icons/DeleteIcon.js";
|
|
@@ -35,7 +35,6 @@ import "./Icons/KeyboardIcon.js";
|
|
|
35
35
|
import "./Icons/LabelIcon.js";
|
|
36
36
|
import "./Icons/LassoIcon.js";
|
|
37
37
|
import "./Icons/LineToolIcon.js";
|
|
38
|
-
import "./Icons/LineToolIcon2.js";
|
|
39
38
|
import "./Icons/LiveViewIcon.js";
|
|
40
39
|
import "./Icons/LoaderIcon.js";
|
|
41
40
|
import "./Icons/LocationIcon.js";
|
|
@@ -49,6 +48,7 @@ import "./Icons/PanelIconClose.js";
|
|
|
49
48
|
import "./Icons/PanelIconOpen.js";
|
|
50
49
|
import "./Icons/PlayIcon.js";
|
|
51
50
|
import "./Icons/PlusIcon.js";
|
|
51
|
+
import "./Icons/PolygonIcon.js";
|
|
52
52
|
import "./Icons/ResetIcon.js";
|
|
53
53
|
import "./Icons/ReviewedIcon.js";
|
|
54
54
|
import "./Icons/ScissorsIcon.js";
|
|
@@ -70,10 +70,11 @@ import "./Icons/ZoomXIcon.js";
|
|
|
70
70
|
import "./Icons/ZoomYIcon.js";
|
|
71
71
|
import { cn as a } from "./utils/twUtils.js";
|
|
72
72
|
import { c as M } from "./index-D29mdTf5.js";
|
|
73
|
-
import { createContext as H, useRef as
|
|
74
|
-
import { j as
|
|
75
|
-
import { D as
|
|
76
|
-
import { m as
|
|
73
|
+
import { createContext as H, useRef as h, useMemo as T, useContext as I } from "react";
|
|
74
|
+
import { j as g } from "./index-DEYs15GP.js";
|
|
75
|
+
import { D as s } from "./index-CrjD9cAD.js";
|
|
76
|
+
import { m as v } from "./proxy-CgaCj1WQ.js";
|
|
77
|
+
import { A as O } from "./index-DdFoGvON.js";
|
|
77
78
|
const j = M("fixed bottom-4 left-1/2 z-10 -translate-x-1/2 overflow-hidden rounded-2xl bg-drawer-bg outline-none w-full sm:max-md:max-w-full", {
|
|
78
79
|
variants: {
|
|
79
80
|
size: {
|
|
@@ -91,50 +92,50 @@ const j = M("fixed bottom-4 left-1/2 z-10 -translate-x-1/2 overflow-hidden round
|
|
|
91
92
|
if (!t)
|
|
92
93
|
throw new Error("Tray components must be used within Tray root");
|
|
93
94
|
return t;
|
|
94
|
-
}, B = ({
|
|
95
|
-
const i =
|
|
95
|
+
}, B = ({ children: t, size: r = "sm", ...o }) => {
|
|
96
|
+
const i = h("default"), n = T(
|
|
96
97
|
() => ({
|
|
97
|
-
size: t,
|
|
98
98
|
animationKey: i.current,
|
|
99
99
|
setAnimationKey: (p) => {
|
|
100
100
|
i.current = p;
|
|
101
|
-
}
|
|
101
|
+
},
|
|
102
|
+
size: r
|
|
102
103
|
}),
|
|
103
|
-
[
|
|
104
|
+
[r]
|
|
104
105
|
);
|
|
105
|
-
return /* @__PURE__ */
|
|
106
|
+
return /* @__PURE__ */ e(N.Provider, { value: n, children: /* @__PURE__ */ e(s.Root, { "data-testid": "spectral-tray", ...o, children: t }) });
|
|
106
107
|
};
|
|
107
108
|
B.displayName = "Tray";
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
const P = ({
|
|
110
|
+
className: t,
|
|
111
|
+
ref: r,
|
|
111
112
|
...o
|
|
112
|
-
}) => /* @__PURE__ */
|
|
113
|
-
|
|
113
|
+
}) => /* @__PURE__ */ e(s.Trigger, { className: a(t), "data-testid": "spectral-tray-trigger", "data-vaul-no-drag": "", ref: r, ...o });
|
|
114
|
+
P.displayName = "TrayTrigger";
|
|
114
115
|
const C = ({
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
className: t,
|
|
117
|
+
ref: r,
|
|
117
118
|
...o
|
|
118
|
-
}) => /* @__PURE__ */
|
|
119
|
+
}) => /* @__PURE__ */ e(s.Close, { asChild: !0, className: a(t), "data-testid": "spectral-tray-close", "data-vaul-no-drag": "", ref: r, ...o, children: /* @__PURE__ */ e(f, {}) });
|
|
119
120
|
C.displayName = "TrayClose";
|
|
120
121
|
const w = ({
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
className: t,
|
|
123
|
+
ref: r,
|
|
123
124
|
...o
|
|
124
|
-
}) => /* @__PURE__ */
|
|
125
|
+
}) => /* @__PURE__ */ e(s.Overlay, { className: a("bg-overlay fixed inset-0 z-10", t), ref: r, ...o });
|
|
125
126
|
w.displayName = "TrayOverlay";
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
className:
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
const S = ({
|
|
128
|
+
children: t,
|
|
129
|
+
className: r,
|
|
130
|
+
ref: o,
|
|
131
|
+
size: i,
|
|
131
132
|
...n
|
|
132
133
|
}) => {
|
|
133
|
-
const { size: p } = b(), l =
|
|
134
|
-
return /* @__PURE__ */ x(
|
|
135
|
-
/* @__PURE__ */
|
|
136
|
-
/* @__PURE__ */
|
|
137
|
-
|
|
134
|
+
const { size: p } = b(), l = i ?? p, [m, c] = g();
|
|
135
|
+
return /* @__PURE__ */ x(s.Portal, { children: [
|
|
136
|
+
/* @__PURE__ */ e(w, {}),
|
|
137
|
+
/* @__PURE__ */ e(s.Content, { asChild: !0, className: a(j({ size: l }), r), "data-testid": "spectral-tray-content", ref: o, ...n, children: /* @__PURE__ */ e(
|
|
138
|
+
v.div,
|
|
138
139
|
{
|
|
139
140
|
animate: {
|
|
140
141
|
height: c.height,
|
|
@@ -143,51 +144,51 @@ const V = ({
|
|
|
143
144
|
ease: [0.25, 1, 0.5, 1]
|
|
144
145
|
}
|
|
145
146
|
},
|
|
146
|
-
children: /* @__PURE__ */
|
|
147
|
+
children: /* @__PURE__ */ e("div", { ref: m, className: "px-6 pt-2.5 pb-6 antialiased", children: t })
|
|
147
148
|
}
|
|
148
149
|
) })
|
|
149
150
|
] });
|
|
150
151
|
};
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
className:
|
|
155
|
-
|
|
152
|
+
S.displayName = "TrayContent";
|
|
153
|
+
const V = ({
|
|
154
|
+
children: t,
|
|
155
|
+
className: r,
|
|
156
|
+
ref: o,
|
|
156
157
|
...i
|
|
157
|
-
}) => /* @__PURE__ */ x("div", { className: a("relative flex flex-col space-y-1.5 pb-4 text-start",
|
|
158
|
-
|
|
159
|
-
/* @__PURE__ */
|
|
158
|
+
}) => /* @__PURE__ */ x("div", { className: a("relative flex flex-col space-y-1.5 pb-4 text-start", r), "data-testid": "spectral-tray-header", ref: o, ...i, children: [
|
|
159
|
+
t,
|
|
160
|
+
/* @__PURE__ */ e(C, { className: "hover:bg-level-four absolute top-0 right-[-14px] z-10 cursor-pointer rounded-full p-1 text-neutral-400 transition-colors hover:scale-110 hover:text-neutral-100", children: /* @__PURE__ */ e(K, { icon: /* @__PURE__ */ e(f, {}), label: "Close tray", shape: "circle" }) })
|
|
160
161
|
] });
|
|
161
|
-
|
|
162
|
+
V.displayName = "TrayHeader";
|
|
162
163
|
const U = ({
|
|
163
|
-
|
|
164
|
-
className:
|
|
165
|
-
|
|
164
|
+
children: t,
|
|
165
|
+
className: r,
|
|
166
|
+
ref: o,
|
|
166
167
|
...i
|
|
167
|
-
}) => /* @__PURE__ */
|
|
168
|
+
}) => /* @__PURE__ */ e("h2", { className: a("text-text-primary text-xl font-semibold", r), "data-testid": "spectral-tray-title", ref: o, ...i, children: t });
|
|
168
169
|
U.displayName = "TrayTitle";
|
|
169
170
|
const _ = ({
|
|
170
|
-
|
|
171
|
-
|
|
171
|
+
className: t,
|
|
172
|
+
ref: r,
|
|
172
173
|
...o
|
|
173
|
-
}) => /* @__PURE__ */
|
|
174
|
+
}) => /* @__PURE__ */ e("p", { className: a("text-text-secondary text-sm", t), "data-testid": "spectral-tray-subtitle", ref: r, ...o });
|
|
174
175
|
_.displayName = "TraySubtitle";
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
176
|
+
const k = ({
|
|
177
|
+
animationKey: t,
|
|
178
|
+
children: r,
|
|
179
|
+
className: o,
|
|
180
|
+
ref: i,
|
|
180
181
|
...n
|
|
181
182
|
}) => {
|
|
182
|
-
const { animationKey: p } = b(), l =
|
|
183
|
-
const d = y.height, R =
|
|
184
|
-
if (!
|
|
185
|
-
return
|
|
186
|
-
const D = Math.abs(d - R);
|
|
187
|
-
return
|
|
183
|
+
const { animationKey: p } = b(), l = t ?? p, m = h(null), [c, y] = g(), z = T(() => {
|
|
184
|
+
const d = y.height, R = m.current, A = 0.27, u = 0.15;
|
|
185
|
+
if (!m.current)
|
|
186
|
+
return m.current = d, u;
|
|
187
|
+
const D = Math.abs(d - (R ?? 0));
|
|
188
|
+
return m.current = d, Math.min(Math.max(D / 500, u), A);
|
|
188
189
|
}, [y.height]);
|
|
189
|
-
return /* @__PURE__ */
|
|
190
|
-
|
|
190
|
+
return /* @__PURE__ */ e("div", { ref: i, "data-testid": "spectral-tray-body", className: a(o), ...n, children: /* @__PURE__ */ e(O, { initial: !1, mode: "popLayout", custom: l, children: /* @__PURE__ */ e(
|
|
191
|
+
v.div,
|
|
191
192
|
{
|
|
192
193
|
animate: { opacity: 1, scale: 1, y: 0 },
|
|
193
194
|
exit: { opacity: 0, scale: 0.96 },
|
|
@@ -197,19 +198,19 @@ const E = ({
|
|
|
197
198
|
duration: z,
|
|
198
199
|
ease: [0.26, 0.08, 0.25, 1]
|
|
199
200
|
},
|
|
200
|
-
children:
|
|
201
|
+
children: r
|
|
201
202
|
},
|
|
202
203
|
l
|
|
203
204
|
) }) });
|
|
204
205
|
};
|
|
205
|
-
|
|
206
|
+
k.displayName = "TrayBody";
|
|
206
207
|
export {
|
|
207
208
|
B as Tray,
|
|
208
|
-
|
|
209
|
+
k as TrayBody,
|
|
209
210
|
C as TrayClose,
|
|
210
|
-
|
|
211
|
-
|
|
211
|
+
S as TrayContent,
|
|
212
|
+
V as TrayHeader,
|
|
212
213
|
_ as TraySubtitle,
|
|
213
214
|
U as TrayTitle,
|
|
214
|
-
|
|
215
|
+
P as TrayTrigger
|
|
215
216
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAccordionAutoScroll.d.ts","sourceRoot":"","sources":["../../src/hooks/useAccordionAutoScroll.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAOvF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,YAAY,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"useAccordionAutoScroll.d.ts","sourceRoot":"","sources":["../../src/hooks/useAccordionAutoScroll.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAOvF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,YAAY,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,IAAI,eA8GxD,UAAU,CAAC,iBAAiB,CAAC,SAI3D,CAAA"}
|
|
@@ -1,64 +1,67 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useRef as h, useCallback as v, useEffect as O } from "react";
|
|
3
|
-
const A = (
|
|
4
|
-
const
|
|
3
|
+
const A = (f) => {
|
|
4
|
+
const e = h(null), s = h(null), a = v((t) => {
|
|
5
5
|
if (!t || t === document.body) return window;
|
|
6
|
-
const { overflow:
|
|
7
|
-
return /(auto|scroll)/.test(
|
|
6
|
+
const { overflow: i, overflowY: d } = window.getComputedStyle(t);
|
|
7
|
+
return /(auto|scroll)/.test(i) || /(auto|scroll)/.test(d) ? t : a(t.parentElement);
|
|
8
8
|
}, []);
|
|
9
9
|
return O(() => {
|
|
10
|
-
const t =
|
|
10
|
+
const t = f?.current ?? null;
|
|
11
11
|
if (!t) return;
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
const r =
|
|
16
|
-
if (!
|
|
12
|
+
const i = new MutationObserver((d) => {
|
|
13
|
+
d.forEach((w) => {
|
|
14
|
+
if (w.attributeName === "data-state") {
|
|
15
|
+
const r = w.target, p = r.getAttribute("data-state"), m = r.closest("[data-scroll-options]");
|
|
16
|
+
if (!m) return;
|
|
17
17
|
try {
|
|
18
|
-
const
|
|
19
|
-
if (!
|
|
20
|
-
const T = JSON.parse(
|
|
21
|
-
if (
|
|
22
|
-
const n =
|
|
23
|
-
if (
|
|
24
|
-
if (
|
|
25
|
-
n === window ?
|
|
18
|
+
const u = m.getAttribute("data-scroll-options");
|
|
19
|
+
if (!u) return;
|
|
20
|
+
const T = JSON.parse(u), { autoScroll: b, scrollPadding: S } = T;
|
|
21
|
+
if (b === "never") return;
|
|
22
|
+
const n = a(r);
|
|
23
|
+
if (p === "open") {
|
|
24
|
+
if (b === "mobile" && window.innerHeight >= 768) return;
|
|
25
|
+
n === window ? e.current = window.scrollY : e.current = n.scrollTop, s.current = n, setTimeout(() => {
|
|
26
26
|
if (!r) return;
|
|
27
|
-
const
|
|
27
|
+
const l = r.getBoundingClientRect(), o = 0, g = S;
|
|
28
28
|
if (n === window) {
|
|
29
|
-
const
|
|
29
|
+
const c = window.scrollY + l.top + g - o;
|
|
30
30
|
window.scrollTo({
|
|
31
|
-
top:
|
|
31
|
+
top: c,
|
|
32
32
|
behavior: "smooth"
|
|
33
33
|
});
|
|
34
34
|
} else {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
top:
|
|
35
|
+
const c = n, C = c.getBoundingClientRect(), E = l.top - C.top;
|
|
36
|
+
c.scrollTo({
|
|
37
|
+
top: c.scrollTop + E + g - o,
|
|
38
38
|
behavior: "smooth"
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
}, 100);
|
|
42
|
-
} else
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
} else if (p === "closed" && e.current !== null && s.current) {
|
|
43
|
+
const l = e.current;
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
const o = s.current;
|
|
46
|
+
o === window ? window.scrollTo({
|
|
47
|
+
top: l,
|
|
48
|
+
behavior: "smooth"
|
|
49
|
+
}) : o instanceof HTMLElement && o.scrollTo({
|
|
50
|
+
top: l,
|
|
51
|
+
behavior: "smooth"
|
|
52
|
+
}), e.current = null, s.current = null;
|
|
53
|
+
}, 100);
|
|
54
|
+
}
|
|
55
|
+
} catch (u) {
|
|
56
|
+
console.error("Error handling accordion scroll:", { error: u });
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
});
|
|
57
60
|
});
|
|
58
|
-
return
|
|
59
|
-
|
|
61
|
+
return i.observe(t, { attributes: !0 }), () => {
|
|
62
|
+
i.disconnect();
|
|
60
63
|
};
|
|
61
|
-
}, [
|
|
64
|
+
}, [f, a]), v((t) => {
|
|
62
65
|
}, []);
|
|
63
66
|
};
|
|
64
67
|
export {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hook for managing controllable state - supports both controlled and uncontrolled patterns
|
|
3
3
|
*/
|
|
4
|
-
export declare
|
|
4
|
+
export declare const useControllableState: <T>(options: {
|
|
5
5
|
value?: T;
|
|
6
6
|
defaultValue: T;
|
|
7
7
|
onChange?: (next: T) => void;
|
|
8
|
-
})
|
|
8
|
+
}) => [T, (next: T | ((prev: T) => T)) => void];
|
|
9
9
|
//# sourceMappingURL=useControllableState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useControllableState.d.ts","sourceRoot":"","sources":["../../src/hooks/useControllableState.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"useControllableState.d.ts","sourceRoot":"","sources":["../../src/hooks/useControllableState.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,EAAE,SAAS;IAAE,KAAK,CAAC,EAAE,CAAC,CAAC;IAAC,YAAY,EAAE,CAAC,CAAC;IAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAA;CAAE,KAAG,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,CAcvJ,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useState as f, useCallback as i } from "react";
|
|
3
|
-
|
|
3
|
+
const p = (c) => {
|
|
4
4
|
const { value: n, defaultValue: a, onChange: l } = c, [r, u] = f(a), t = n !== void 0, o = t ? n : r, d = i(
|
|
5
5
|
(e) => {
|
|
6
6
|
const s = typeof e == "function" ? e(o) : e;
|
|
@@ -9,7 +9,7 @@ function p(c) {
|
|
|
9
9
|
[t, l, o]
|
|
10
10
|
);
|
|
11
11
|
return [o, d];
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
13
|
export {
|
|
14
14
|
p as useControllableState
|
|
15
15
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as r from "react";
|
|
2
|
+
import { f as s } from "./index-OnYbwQjk.js";
|
|
3
|
+
var u = r[" useId ".trim().toString()] || (() => {
|
|
4
|
+
}), i = 0;
|
|
5
|
+
function n(e) {
|
|
6
|
+
const [t, o] = r.useState(u());
|
|
7
|
+
return s(() => {
|
|
8
|
+
o((a) => a ?? String(i++));
|
|
9
|
+
}, [e]), t ? `radix-${t}` : "";
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
n as u
|
|
13
|
+
};
|
|
@@ -6,7 +6,7 @@ import { e as Ee, c as st, u as k, P as M, b as R, f as Y, a as ct } from "./ind
|
|
|
6
6
|
import { u as lt, c as at } from "./index-DSXuB1g3.js";
|
|
7
7
|
import { P as it, D as dt } from "./index-u1k2AYWy.js";
|
|
8
8
|
import { h as ut, u as pt, R as ft, F as mt } from "./Combination-CK_g12Qb.js";
|
|
9
|
-
import { u as Ie } from "./index-
|
|
9
|
+
import { u as Ie } from "./index-C12FUuIW.js";
|
|
10
10
|
import { c as _e, R as ht, A as vt, C as gt, a as St } from "./index-B3FZpM60.js";
|
|
11
11
|
import { u as wt } from "./index-0ioNhtNM.js";
|
|
12
12
|
import { u as Ct } from "./index-BZPx6jYI.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./styles/main.css";
|
|
2
2
|
import * as i from "react";
|
|
3
3
|
import { c as V, a as q, P as p, u as _, b as g, d as K, e as U } from "./index-OnYbwQjk.js";
|
|
4
|
-
import { u as R } from "./index-
|
|
4
|
+
import { u as R } from "./index-C12FUuIW.js";
|
|
5
5
|
import { D as Y, P as Z } from "./index-u1k2AYWy.js";
|
|
6
6
|
import { R as z, h as J, u as Q, F as X } from "./Combination-CK_g12Qb.js";
|
|
7
7
|
import { P as h } from "./index-D6HcSXrq.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as me, a as pe, b as we, C as he, T as ge, D as ve, R as ye, P as be } from "./index-
|
|
1
|
+
import { O as me, a as pe, b as we, C as he, T as ge, D as ve, R as ye, P as be } from "./index-CqbPiOid.js";
|
|
2
2
|
import * as Se from "react";
|
|
3
3
|
import r, { useMemo as Te, useLayoutEffect as Re, useEffect as Ee } from "react";
|
|
4
4
|
function De(t) {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useState as T, useRef as g, useEffect as u, useMemo as j } from "react";
|
|
2
|
+
function p(t, r) {
|
|
3
|
+
let o;
|
|
4
|
+
return (...i) => {
|
|
5
|
+
window.clearTimeout(o), o = window.setTimeout(() => t(...i), r);
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
function Y({ debounce: t, scroll: r, polyfill: o, offsetSize: i } = { debounce: 0, scroll: !1, offsetSize: !1 }) {
|
|
9
|
+
const a = o || (typeof window > "u" ? class {
|
|
10
|
+
} : window.ResizeObserver);
|
|
11
|
+
if (!a) throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");
|
|
12
|
+
const [c, h] = T({ left: 0, top: 0, width: 0, height: 0, bottom: 0, right: 0, x: 0, y: 0 }), e = g({ element: null, scrollContainers: null, resizeObserver: null, lastBounds: c, orientationHandler: null }), d = t ? typeof t == "number" ? t : t.scroll : null, f = t ? typeof t == "number" ? t : t.resize : null, w = g(!1);
|
|
13
|
+
u(() => (w.current = !0, () => {
|
|
14
|
+
w.current = !1;
|
|
15
|
+
}));
|
|
16
|
+
const [z, m, s] = j(() => {
|
|
17
|
+
const n = () => {
|
|
18
|
+
if (!e.current.element) return;
|
|
19
|
+
const { left: y, top: C, width: H, height: O, bottom: x, right: S, x: B, y: R } = e.current.element.getBoundingClientRect(), l = { left: y, top: C, width: H, height: O, bottom: x, right: S, x: B, y: R };
|
|
20
|
+
e.current.element instanceof HTMLElement && i && (l.height = e.current.element.offsetHeight, l.width = e.current.element.offsetWidth), Object.freeze(l), w.current && !k(e.current.lastBounds, l) && h(e.current.lastBounds = l);
|
|
21
|
+
};
|
|
22
|
+
return [n, f ? p(n, f) : n, d ? p(n, d) : n];
|
|
23
|
+
}, [h, i, d, f]);
|
|
24
|
+
function v() {
|
|
25
|
+
e.current.scrollContainers && (e.current.scrollContainers.forEach((n) => n.removeEventListener("scroll", s, !0)), e.current.scrollContainers = null), e.current.resizeObserver && (e.current.resizeObserver.disconnect(), e.current.resizeObserver = null), e.current.orientationHandler && ("orientation" in screen && "removeEventListener" in screen.orientation ? screen.orientation.removeEventListener("change", e.current.orientationHandler) : "onorientationchange" in window && window.removeEventListener("orientationchange", e.current.orientationHandler));
|
|
26
|
+
}
|
|
27
|
+
function b() {
|
|
28
|
+
e.current.element && (e.current.resizeObserver = new a(s), e.current.resizeObserver.observe(e.current.element), r && e.current.scrollContainers && e.current.scrollContainers.forEach((n) => n.addEventListener("scroll", s, { capture: !0, passive: !0 })), e.current.orientationHandler = () => {
|
|
29
|
+
s();
|
|
30
|
+
}, "orientation" in screen && "addEventListener" in screen.orientation ? screen.orientation.addEventListener("change", e.current.orientationHandler) : "onorientationchange" in window && window.addEventListener("orientationchange", e.current.orientationHandler));
|
|
31
|
+
}
|
|
32
|
+
const L = (n) => {
|
|
33
|
+
!n || n === e.current.element || (v(), e.current.element = n, e.current.scrollContainers = E(n), b());
|
|
34
|
+
};
|
|
35
|
+
return W(s, !!r), M(m), u(() => {
|
|
36
|
+
v(), b();
|
|
37
|
+
}, [r, s, m]), u(() => v, []), [L, c, z];
|
|
38
|
+
}
|
|
39
|
+
function M(t) {
|
|
40
|
+
u(() => {
|
|
41
|
+
const r = t;
|
|
42
|
+
return window.addEventListener("resize", r), () => {
|
|
43
|
+
window.removeEventListener("resize", r);
|
|
44
|
+
};
|
|
45
|
+
}, [t]);
|
|
46
|
+
}
|
|
47
|
+
function W(t, r) {
|
|
48
|
+
u(() => {
|
|
49
|
+
if (r) {
|
|
50
|
+
const o = t;
|
|
51
|
+
return window.addEventListener("scroll", o, { capture: !0, passive: !0 }), () => {
|
|
52
|
+
window.removeEventListener("scroll", o, !0);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}, [t, r]);
|
|
56
|
+
}
|
|
57
|
+
function E(t) {
|
|
58
|
+
const r = [];
|
|
59
|
+
if (!t || t === document.body) return r;
|
|
60
|
+
const { overflow: o, overflowX: i, overflowY: a } = window.getComputedStyle(t);
|
|
61
|
+
return [o, i, a].some((c) => c === "auto" || c === "scroll") && r.push(t), [...r, ...E(t.parentElement)];
|
|
62
|
+
}
|
|
63
|
+
const X = ["x", "y", "top", "bottom", "left", "right", "width", "height"], k = (t, r) => X.every((o) => t[o] === r[o]);
|
|
64
|
+
export {
|
|
65
|
+
Y as j
|
|
66
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import "./styles/main.css";
|
|
2
|
+
import { jsx as w, Fragment as N } from "react/jsx-runtime";
|
|
3
|
+
import * as v from "react";
|
|
4
|
+
import { useId as T, useRef as P, useContext as D, useInsertionEffect as S, useMemo as $, Children as U, isValidElement as V, useState as z } from "react";
|
|
5
|
+
import { M as X, d as _, u as W, P as B, e as F, b as G, L as O } from "./proxy-CgaCj1WQ.js";
|
|
6
|
+
function A(e, s) {
|
|
7
|
+
if (typeof e == "function")
|
|
8
|
+
return e(s);
|
|
9
|
+
e != null && (e.current = s);
|
|
10
|
+
}
|
|
11
|
+
function Y(...e) {
|
|
12
|
+
return (s) => {
|
|
13
|
+
let t = !1;
|
|
14
|
+
const o = e.map((r) => {
|
|
15
|
+
const n = A(r, s);
|
|
16
|
+
return !t && typeof n == "function" && (t = !0), n;
|
|
17
|
+
});
|
|
18
|
+
if (t)
|
|
19
|
+
return () => {
|
|
20
|
+
for (let r = 0; r < o.length; r++) {
|
|
21
|
+
const n = o[r];
|
|
22
|
+
typeof n == "function" ? n() : A(e[r], null);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function q(...e) {
|
|
28
|
+
return v.useCallback(Y(...e), e);
|
|
29
|
+
}
|
|
30
|
+
class J extends v.Component {
|
|
31
|
+
getSnapshotBeforeUpdate(s) {
|
|
32
|
+
const t = this.props.childRef.current;
|
|
33
|
+
if (t && s.isPresent && !this.props.isPresent) {
|
|
34
|
+
const o = t.offsetParent, r = _(o) && o.offsetWidth || 0, n = this.props.sizeRef.current;
|
|
35
|
+
n.height = t.offsetHeight || 0, n.width = t.offsetWidth || 0, n.top = t.offsetTop, n.left = t.offsetLeft, n.right = r - n.width - n.left;
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Required with getSnapshotBeforeUpdate to stop React complaining.
|
|
41
|
+
*/
|
|
42
|
+
componentDidUpdate() {
|
|
43
|
+
}
|
|
44
|
+
render() {
|
|
45
|
+
return this.props.children;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function Q({ children: e, isPresent: s, anchorX: t, root: o }) {
|
|
49
|
+
const r = T(), n = P(null), p = P({
|
|
50
|
+
width: 0,
|
|
51
|
+
height: 0,
|
|
52
|
+
top: 0,
|
|
53
|
+
left: 0,
|
|
54
|
+
right: 0
|
|
55
|
+
}), { nonce: C } = D(X), x = q(n, e?.ref);
|
|
56
|
+
return S(() => {
|
|
57
|
+
const { width: i, height: g, top: c, left: u, right: a } = p.current;
|
|
58
|
+
if (s || !n.current || !i || !g)
|
|
59
|
+
return;
|
|
60
|
+
const h = t === "left" ? `left: ${u}` : `right: ${a}`;
|
|
61
|
+
n.current.dataset.motionPopId = r;
|
|
62
|
+
const l = document.createElement("style");
|
|
63
|
+
C && (l.nonce = C);
|
|
64
|
+
const R = o ?? document.head;
|
|
65
|
+
return R.appendChild(l), l.sheet && l.sheet.insertRule(`
|
|
66
|
+
[data-motion-pop-id="${r}"] {
|
|
67
|
+
position: absolute !important;
|
|
68
|
+
width: ${i}px !important;
|
|
69
|
+
height: ${g}px !important;
|
|
70
|
+
${h}px !important;
|
|
71
|
+
top: ${c}px !important;
|
|
72
|
+
}
|
|
73
|
+
`), () => {
|
|
74
|
+
R.contains(l) && R.removeChild(l);
|
|
75
|
+
};
|
|
76
|
+
}, [s]), w(J, { isPresent: s, childRef: n, sizeRef: p, children: v.cloneElement(e, { ref: x }) });
|
|
77
|
+
}
|
|
78
|
+
const Z = ({ children: e, initial: s, isPresent: t, onExitComplete: o, custom: r, presenceAffectsLayout: n, mode: p, anchorX: C, root: x }) => {
|
|
79
|
+
const i = W(ee), g = T();
|
|
80
|
+
let c = !0, u = $(() => (c = !1, {
|
|
81
|
+
id: g,
|
|
82
|
+
initial: s,
|
|
83
|
+
isPresent: t,
|
|
84
|
+
custom: r,
|
|
85
|
+
onExitComplete: (a) => {
|
|
86
|
+
i.set(a, !0);
|
|
87
|
+
for (const h of i.values())
|
|
88
|
+
if (!h)
|
|
89
|
+
return;
|
|
90
|
+
o && o();
|
|
91
|
+
},
|
|
92
|
+
register: (a) => (i.set(a, !1), () => i.delete(a))
|
|
93
|
+
}), [t, i, o]);
|
|
94
|
+
return n && c && (u = { ...u }), $(() => {
|
|
95
|
+
i.forEach((a, h) => i.set(h, !1));
|
|
96
|
+
}, [t]), v.useEffect(() => {
|
|
97
|
+
!t && !i.size && o && o();
|
|
98
|
+
}, [t]), p === "popLayout" && (e = w(Q, { isPresent: t, anchorX: C, root: x, children: e })), w(B.Provider, { value: u, children: e });
|
|
99
|
+
};
|
|
100
|
+
function ee() {
|
|
101
|
+
return /* @__PURE__ */ new Map();
|
|
102
|
+
}
|
|
103
|
+
const E = (e) => e.key || "";
|
|
104
|
+
function I(e) {
|
|
105
|
+
const s = [];
|
|
106
|
+
return U.forEach(e, (t) => {
|
|
107
|
+
V(t) && s.push(t);
|
|
108
|
+
}), s;
|
|
109
|
+
}
|
|
110
|
+
const oe = ({ children: e, custom: s, initial: t = !0, onExitComplete: o, presenceAffectsLayout: r = !0, mode: n = "sync", propagate: p = !1, anchorX: C = "left", root: x }) => {
|
|
111
|
+
const [i, g] = F(p), c = $(() => I(e), [e]), u = p && !i ? [] : c.map(E), a = P(!0), h = P(c), l = W(() => /* @__PURE__ */ new Map()), [R, j] = z(c), [m, b] = z(c);
|
|
112
|
+
G(() => {
|
|
113
|
+
a.current = !1, h.current = c;
|
|
114
|
+
for (let d = 0; d < m.length; d++) {
|
|
115
|
+
const f = E(m[d]);
|
|
116
|
+
u.includes(f) ? l.delete(f) : l.get(f) !== !0 && l.set(f, !1);
|
|
117
|
+
}
|
|
118
|
+
}, [m, u.length, u.join("-")]);
|
|
119
|
+
const M = [];
|
|
120
|
+
if (c !== R) {
|
|
121
|
+
let d = [...c];
|
|
122
|
+
for (let f = 0; f < m.length; f++) {
|
|
123
|
+
const y = m[f], L = E(y);
|
|
124
|
+
u.includes(L) || (d.splice(f, 0, y), M.push(y));
|
|
125
|
+
}
|
|
126
|
+
return n === "wait" && M.length && (d = M), b(I(d)), j(c), null;
|
|
127
|
+
}
|
|
128
|
+
process.env.NODE_ENV !== "production" && n === "wait" && m.length > 1 && console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);
|
|
129
|
+
const { forceRender: H } = D(O);
|
|
130
|
+
return w(N, { children: m.map((d) => {
|
|
131
|
+
const f = E(d), y = p && !i ? !1 : c === m || u.includes(f), L = () => {
|
|
132
|
+
if (l.has(f))
|
|
133
|
+
l.set(f, !0);
|
|
134
|
+
else
|
|
135
|
+
return;
|
|
136
|
+
let k = !0;
|
|
137
|
+
l.forEach((K) => {
|
|
138
|
+
K || (k = !1);
|
|
139
|
+
}), k && (H?.(), b(h.current), p && g?.(), o && o());
|
|
140
|
+
};
|
|
141
|
+
return w(Z, { isPresent: y, initial: !a.current || t ? void 0 : !1, custom: s, presenceAffectsLayout: r, mode: n, root: x, onExitComplete: y ? void 0 : L, anchorX: C, children: d }, f);
|
|
142
|
+
}) });
|
|
143
|
+
};
|
|
144
|
+
export {
|
|
145
|
+
oe as A
|
|
146
|
+
};
|