@btst/stack 1.4.0 → 1.4.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.
- package/dist/node_modules/.pnpm/@radix-ui_react-accordion@1.2.12_@types_react-dom@19.2.3_@types_react@19.2.6__@types_re_947719a27ff11ec6f09710dd9e85efc5/node_modules/@radix-ui/react-accordion/dist/index.cjs +321 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-accordion@1.2.12_@types_react-dom@19.2.3_@types_react@19.2.6__@types_re_947719a27ff11ec6f09710dd9e85efc5/node_modules/@radix-ui/react-accordion/dist/index.mjs +306 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-collapsible@1.1.12_@types_react-dom@19.2.3_@types_react@19.2.6__@types__d025a77f62ee83ca6bd8b0ea1f9de738/node_modules/@radix-ui/react-collapsible/dist/index.cjs +168 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-collapsible@1.1.12_@types_react-dom@19.2.3_@types_react@19.2.6__@types__d025a77f62ee83ca6bd8b0ea1f9de738/node_modules/@radix-ui/react-collapsible/dist/index.mjs +146 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-interface.cjs +29 -3
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-interface.mjs +29 -3
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-layout.cjs +16 -3
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-layout.mjs +16 -3
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-message.cjs +35 -3
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-message.mjs +35 -3
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/tool-call-display.cjs +123 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/tool-call-display.mjs +121 -0
- package/dist/packages/ui/src/components/accordion.cjs +67 -0
- package/dist/packages/ui/src/components/accordion.mjs +62 -0
- package/dist/plugins/ai-chat/client/components/index.cjs +2 -0
- package/dist/plugins/ai-chat/client/components/index.d.cts +1 -1
- package/dist/plugins/ai-chat/client/components/index.d.mts +1 -1
- package/dist/plugins/ai-chat/client/components/index.d.ts +1 -1
- package/dist/plugins/ai-chat/client/components/index.mjs +1 -0
- package/dist/plugins/ai-chat/client/index.cjs +2 -0
- package/dist/plugins/ai-chat/client/index.d.cts +5 -176
- package/dist/plugins/ai-chat/client/index.d.mts +5 -176
- package/dist/plugins/ai-chat/client/index.d.ts +5 -176
- package/dist/plugins/ai-chat/client/index.mjs +1 -0
- package/dist/plugins/blog/client/components/shared/markdown-content-styles.css +6 -0
- package/dist/shared/stack.DaOcgmrM.d.cts +323 -0
- package/dist/shared/stack.DaOcgmrM.d.mts +323 -0
- package/dist/shared/stack.DaOcgmrM.d.ts +323 -0
- package/package.json +1 -1
- package/src/plugins/ai-chat/client/components/chat-interface.tsx +41 -2
- package/src/plugins/ai-chat/client/components/chat-layout.tsx +16 -1
- package/src/plugins/ai-chat/client/components/chat-message.tsx +59 -3
- package/src/plugins/ai-chat/client/components/index.ts +2 -0
- package/src/plugins/ai-chat/client/components/tool-call-display.tsx +197 -0
- package/src/plugins/ai-chat/client/index.ts +12 -1
- package/src/plugins/ai-chat/client/overrides.ts +71 -0
- package/src/plugins/blog/client/components/shared/markdown-content-styles.css +6 -0
- package/dist/shared/stack.DorMi9CZ.d.cts +0 -80
- package/dist/shared/stack.DorMi9CZ.d.mts +0 -80
- package/dist/shared/stack.DorMi9CZ.d.ts +0 -80
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const React = require('react');
|
|
5
|
+
const index$1 = require('../../../../../@radix-ui_react-context@1.1.2_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-context/dist/index.cjs');
|
|
6
|
+
const index = require('../../../../../@radix-ui_react-collection@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_re_59aa5e150e70a3e7bfb1567148b021b5/node_modules/@radix-ui/react-collection/dist/index.cjs');
|
|
7
|
+
const index$6 = require('../../../../../@radix-ui_react-compose-refs@1.1.2_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-compose-refs/dist/index.cjs');
|
|
8
|
+
const index$8 = require('../../../../../@radix-ui_primitive@1.1.3/node_modules/@radix-ui/primitive/dist/index.cjs');
|
|
9
|
+
const index$5 = require('../../../../../@radix-ui_react-use-controllable-state@1.2.2_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-use-controllable-state/dist/index.cjs');
|
|
10
|
+
const index$4 = require('../../../../../@radix-ui_react-primitive@2.1.3_@types_react-dom@19.2.3_@types_react@19.2.6__@types_rea_a92a69cb1cb39305138539e4fa72f596/node_modules/@radix-ui/react-primitive/dist/index.cjs');
|
|
11
|
+
const index$2 = require('../../../../../@radix-ui_react-collapsible@1.1.12_@types_react-dom@19.2.3_@types_react@19.2.6__@types__d025a77f62ee83ca6bd8b0ea1f9de738/node_modules/@radix-ui/react-collapsible/dist/index.cjs');
|
|
12
|
+
const index$3 = require('../../../../../@radix-ui_react-id@1.1.1_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-id/dist/index.cjs');
|
|
13
|
+
const index$7 = require('../../../../../@radix-ui_react-direction@1.1.1_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-direction/dist/index.cjs');
|
|
14
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
15
|
+
|
|
16
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
17
|
+
|
|
18
|
+
const React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
19
|
+
|
|
20
|
+
var ACCORDION_NAME = "Accordion";
|
|
21
|
+
var ACCORDION_KEYS = ["Home", "End", "ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"];
|
|
22
|
+
var [Collection, useCollection, createCollectionScope] = index.createCollection(ACCORDION_NAME);
|
|
23
|
+
var [createAccordionContext] = index$1.createContextScope(ACCORDION_NAME, [
|
|
24
|
+
createCollectionScope,
|
|
25
|
+
index$2.createCollapsibleScope
|
|
26
|
+
]);
|
|
27
|
+
var useCollapsibleScope = index$2.createCollapsibleScope();
|
|
28
|
+
var Accordion = React__default.forwardRef(
|
|
29
|
+
(props, forwardedRef) => {
|
|
30
|
+
const { type, ...accordionProps } = props;
|
|
31
|
+
const singleProps = accordionProps;
|
|
32
|
+
const multipleProps = accordionProps;
|
|
33
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Collection.Provider, { scope: props.__scopeAccordion, children: type === "multiple" ? /* @__PURE__ */ jsxRuntime.jsx(AccordionImplMultiple, { ...multipleProps, ref: forwardedRef }) : /* @__PURE__ */ jsxRuntime.jsx(AccordionImplSingle, { ...singleProps, ref: forwardedRef }) });
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
Accordion.displayName = ACCORDION_NAME;
|
|
37
|
+
var [AccordionValueProvider, useAccordionValueContext] = createAccordionContext(ACCORDION_NAME);
|
|
38
|
+
var [AccordionCollapsibleProvider, useAccordionCollapsibleContext] = createAccordionContext(
|
|
39
|
+
ACCORDION_NAME,
|
|
40
|
+
{ collapsible: false }
|
|
41
|
+
);
|
|
42
|
+
var AccordionImplSingle = React__default.forwardRef(
|
|
43
|
+
(props, forwardedRef) => {
|
|
44
|
+
const {
|
|
45
|
+
value: valueProp,
|
|
46
|
+
defaultValue,
|
|
47
|
+
onValueChange = () => {
|
|
48
|
+
},
|
|
49
|
+
collapsible = false,
|
|
50
|
+
...accordionSingleProps
|
|
51
|
+
} = props;
|
|
52
|
+
const [value, setValue] = index$5.useControllableState({
|
|
53
|
+
prop: valueProp,
|
|
54
|
+
defaultProp: defaultValue ?? "",
|
|
55
|
+
onChange: onValueChange,
|
|
56
|
+
caller: ACCORDION_NAME
|
|
57
|
+
});
|
|
58
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
59
|
+
AccordionValueProvider,
|
|
60
|
+
{
|
|
61
|
+
scope: props.__scopeAccordion,
|
|
62
|
+
value: React__default.useMemo(() => value ? [value] : [], [value]),
|
|
63
|
+
onItemOpen: setValue,
|
|
64
|
+
onItemClose: React__default.useCallback(() => collapsible && setValue(""), [collapsible, setValue]),
|
|
65
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(AccordionCollapsibleProvider, { scope: props.__scopeAccordion, collapsible, children: /* @__PURE__ */ jsxRuntime.jsx(AccordionImpl, { ...accordionSingleProps, ref: forwardedRef }) })
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
var AccordionImplMultiple = React__default.forwardRef((props, forwardedRef) => {
|
|
71
|
+
const {
|
|
72
|
+
value: valueProp,
|
|
73
|
+
defaultValue,
|
|
74
|
+
onValueChange = () => {
|
|
75
|
+
},
|
|
76
|
+
...accordionMultipleProps
|
|
77
|
+
} = props;
|
|
78
|
+
const [value, setValue] = index$5.useControllableState({
|
|
79
|
+
prop: valueProp,
|
|
80
|
+
defaultProp: defaultValue ?? [],
|
|
81
|
+
onChange: onValueChange,
|
|
82
|
+
caller: ACCORDION_NAME
|
|
83
|
+
});
|
|
84
|
+
const handleItemOpen = React__default.useCallback(
|
|
85
|
+
(itemValue) => setValue((prevValue = []) => [...prevValue, itemValue]),
|
|
86
|
+
[setValue]
|
|
87
|
+
);
|
|
88
|
+
const handleItemClose = React__default.useCallback(
|
|
89
|
+
(itemValue) => setValue((prevValue = []) => prevValue.filter((value2) => value2 !== itemValue)),
|
|
90
|
+
[setValue]
|
|
91
|
+
);
|
|
92
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
93
|
+
AccordionValueProvider,
|
|
94
|
+
{
|
|
95
|
+
scope: props.__scopeAccordion,
|
|
96
|
+
value,
|
|
97
|
+
onItemOpen: handleItemOpen,
|
|
98
|
+
onItemClose: handleItemClose,
|
|
99
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(AccordionCollapsibleProvider, { scope: props.__scopeAccordion, collapsible: true, children: /* @__PURE__ */ jsxRuntime.jsx(AccordionImpl, { ...accordionMultipleProps, ref: forwardedRef }) })
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
var [AccordionImplProvider, useAccordionContext] = createAccordionContext(ACCORDION_NAME);
|
|
104
|
+
var AccordionImpl = React__default.forwardRef(
|
|
105
|
+
(props, forwardedRef) => {
|
|
106
|
+
const { __scopeAccordion, disabled, dir, orientation = "vertical", ...accordionProps } = props;
|
|
107
|
+
const accordionRef = React__default.useRef(null);
|
|
108
|
+
const composedRefs = index$6.useComposedRefs(accordionRef, forwardedRef);
|
|
109
|
+
const getItems = useCollection(__scopeAccordion);
|
|
110
|
+
const direction = index$7.useDirection(dir);
|
|
111
|
+
const isDirectionLTR = direction === "ltr";
|
|
112
|
+
const handleKeyDown = index$8.composeEventHandlers(props.onKeyDown, (event) => {
|
|
113
|
+
if (!ACCORDION_KEYS.includes(event.key)) return;
|
|
114
|
+
const target = event.target;
|
|
115
|
+
const triggerCollection = getItems().filter((item) => !item.ref.current?.disabled);
|
|
116
|
+
const triggerIndex = triggerCollection.findIndex((item) => item.ref.current === target);
|
|
117
|
+
const triggerCount = triggerCollection.length;
|
|
118
|
+
if (triggerIndex === -1) return;
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
let nextIndex = triggerIndex;
|
|
121
|
+
const homeIndex = 0;
|
|
122
|
+
const endIndex = triggerCount - 1;
|
|
123
|
+
const moveNext = () => {
|
|
124
|
+
nextIndex = triggerIndex + 1;
|
|
125
|
+
if (nextIndex > endIndex) {
|
|
126
|
+
nextIndex = homeIndex;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const movePrev = () => {
|
|
130
|
+
nextIndex = triggerIndex - 1;
|
|
131
|
+
if (nextIndex < homeIndex) {
|
|
132
|
+
nextIndex = endIndex;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
switch (event.key) {
|
|
136
|
+
case "Home":
|
|
137
|
+
nextIndex = homeIndex;
|
|
138
|
+
break;
|
|
139
|
+
case "End":
|
|
140
|
+
nextIndex = endIndex;
|
|
141
|
+
break;
|
|
142
|
+
case "ArrowRight":
|
|
143
|
+
if (orientation === "horizontal") {
|
|
144
|
+
if (isDirectionLTR) {
|
|
145
|
+
moveNext();
|
|
146
|
+
} else {
|
|
147
|
+
movePrev();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
break;
|
|
151
|
+
case "ArrowDown":
|
|
152
|
+
if (orientation === "vertical") {
|
|
153
|
+
moveNext();
|
|
154
|
+
}
|
|
155
|
+
break;
|
|
156
|
+
case "ArrowLeft":
|
|
157
|
+
if (orientation === "horizontal") {
|
|
158
|
+
if (isDirectionLTR) {
|
|
159
|
+
movePrev();
|
|
160
|
+
} else {
|
|
161
|
+
moveNext();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
break;
|
|
165
|
+
case "ArrowUp":
|
|
166
|
+
if (orientation === "vertical") {
|
|
167
|
+
movePrev();
|
|
168
|
+
}
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
const clampedIndex = nextIndex % triggerCount;
|
|
172
|
+
triggerCollection[clampedIndex].ref.current?.focus();
|
|
173
|
+
});
|
|
174
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
175
|
+
AccordionImplProvider,
|
|
176
|
+
{
|
|
177
|
+
scope: __scopeAccordion,
|
|
178
|
+
disabled,
|
|
179
|
+
direction: dir,
|
|
180
|
+
orientation,
|
|
181
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Collection.Slot, { scope: __scopeAccordion, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
182
|
+
index$4.Primitive.div,
|
|
183
|
+
{
|
|
184
|
+
...accordionProps,
|
|
185
|
+
"data-orientation": orientation,
|
|
186
|
+
ref: composedRefs,
|
|
187
|
+
onKeyDown: disabled ? void 0 : handleKeyDown
|
|
188
|
+
}
|
|
189
|
+
) })
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
var ITEM_NAME = "AccordionItem";
|
|
195
|
+
var [AccordionItemProvider, useAccordionItemContext] = createAccordionContext(ITEM_NAME);
|
|
196
|
+
var AccordionItem = React__default.forwardRef(
|
|
197
|
+
(props, forwardedRef) => {
|
|
198
|
+
const { __scopeAccordion, value, ...accordionItemProps } = props;
|
|
199
|
+
const accordionContext = useAccordionContext(ITEM_NAME, __scopeAccordion);
|
|
200
|
+
const valueContext = useAccordionValueContext(ITEM_NAME, __scopeAccordion);
|
|
201
|
+
const collapsibleScope = useCollapsibleScope(__scopeAccordion);
|
|
202
|
+
const triggerId = index$3.useId();
|
|
203
|
+
const open = value && valueContext.value.includes(value) || false;
|
|
204
|
+
const disabled = accordionContext.disabled || props.disabled;
|
|
205
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
206
|
+
AccordionItemProvider,
|
|
207
|
+
{
|
|
208
|
+
scope: __scopeAccordion,
|
|
209
|
+
open,
|
|
210
|
+
disabled,
|
|
211
|
+
triggerId,
|
|
212
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
213
|
+
index$2.Root,
|
|
214
|
+
{
|
|
215
|
+
"data-orientation": accordionContext.orientation,
|
|
216
|
+
"data-state": getState(open),
|
|
217
|
+
...collapsibleScope,
|
|
218
|
+
...accordionItemProps,
|
|
219
|
+
ref: forwardedRef,
|
|
220
|
+
disabled,
|
|
221
|
+
open,
|
|
222
|
+
onOpenChange: (open2) => {
|
|
223
|
+
if (open2) {
|
|
224
|
+
valueContext.onItemOpen(value);
|
|
225
|
+
} else {
|
|
226
|
+
valueContext.onItemClose(value);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
);
|
|
235
|
+
AccordionItem.displayName = ITEM_NAME;
|
|
236
|
+
var HEADER_NAME = "AccordionHeader";
|
|
237
|
+
var AccordionHeader = React__default.forwardRef(
|
|
238
|
+
(props, forwardedRef) => {
|
|
239
|
+
const { __scopeAccordion, ...headerProps } = props;
|
|
240
|
+
const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);
|
|
241
|
+
const itemContext = useAccordionItemContext(HEADER_NAME, __scopeAccordion);
|
|
242
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
243
|
+
index$4.Primitive.h3,
|
|
244
|
+
{
|
|
245
|
+
"data-orientation": accordionContext.orientation,
|
|
246
|
+
"data-state": getState(itemContext.open),
|
|
247
|
+
"data-disabled": itemContext.disabled ? "" : void 0,
|
|
248
|
+
...headerProps,
|
|
249
|
+
ref: forwardedRef
|
|
250
|
+
}
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
AccordionHeader.displayName = HEADER_NAME;
|
|
255
|
+
var TRIGGER_NAME = "AccordionTrigger";
|
|
256
|
+
var AccordionTrigger = React__default.forwardRef(
|
|
257
|
+
(props, forwardedRef) => {
|
|
258
|
+
const { __scopeAccordion, ...triggerProps } = props;
|
|
259
|
+
const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);
|
|
260
|
+
const itemContext = useAccordionItemContext(TRIGGER_NAME, __scopeAccordion);
|
|
261
|
+
const collapsibleContext = useAccordionCollapsibleContext(TRIGGER_NAME, __scopeAccordion);
|
|
262
|
+
const collapsibleScope = useCollapsibleScope(__scopeAccordion);
|
|
263
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Collection.ItemSlot, { scope: __scopeAccordion, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
264
|
+
index$2.Trigger,
|
|
265
|
+
{
|
|
266
|
+
"aria-disabled": itemContext.open && !collapsibleContext.collapsible || void 0,
|
|
267
|
+
"data-orientation": accordionContext.orientation,
|
|
268
|
+
id: itemContext.triggerId,
|
|
269
|
+
...collapsibleScope,
|
|
270
|
+
...triggerProps,
|
|
271
|
+
ref: forwardedRef
|
|
272
|
+
}
|
|
273
|
+
) });
|
|
274
|
+
}
|
|
275
|
+
);
|
|
276
|
+
AccordionTrigger.displayName = TRIGGER_NAME;
|
|
277
|
+
var CONTENT_NAME = "AccordionContent";
|
|
278
|
+
var AccordionContent = React__default.forwardRef(
|
|
279
|
+
(props, forwardedRef) => {
|
|
280
|
+
const { __scopeAccordion, ...contentProps } = props;
|
|
281
|
+
const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);
|
|
282
|
+
const itemContext = useAccordionItemContext(CONTENT_NAME, __scopeAccordion);
|
|
283
|
+
const collapsibleScope = useCollapsibleScope(__scopeAccordion);
|
|
284
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
285
|
+
index$2.Content,
|
|
286
|
+
{
|
|
287
|
+
role: "region",
|
|
288
|
+
"aria-labelledby": itemContext.triggerId,
|
|
289
|
+
"data-orientation": accordionContext.orientation,
|
|
290
|
+
...collapsibleScope,
|
|
291
|
+
...contentProps,
|
|
292
|
+
ref: forwardedRef,
|
|
293
|
+
style: {
|
|
294
|
+
["--radix-accordion-content-height"]: "var(--radix-collapsible-content-height)",
|
|
295
|
+
["--radix-accordion-content-width"]: "var(--radix-collapsible-content-width)",
|
|
296
|
+
...props.style
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
);
|
|
302
|
+
AccordionContent.displayName = CONTENT_NAME;
|
|
303
|
+
function getState(open) {
|
|
304
|
+
return open ? "open" : "closed";
|
|
305
|
+
}
|
|
306
|
+
var Root2 = Accordion;
|
|
307
|
+
var Item = AccordionItem;
|
|
308
|
+
var Header = AccordionHeader;
|
|
309
|
+
var Trigger2 = AccordionTrigger;
|
|
310
|
+
var Content2 = AccordionContent;
|
|
311
|
+
|
|
312
|
+
exports.Accordion = Accordion;
|
|
313
|
+
exports.AccordionContent = AccordionContent;
|
|
314
|
+
exports.AccordionHeader = AccordionHeader;
|
|
315
|
+
exports.AccordionItem = AccordionItem;
|
|
316
|
+
exports.AccordionTrigger = AccordionTrigger;
|
|
317
|
+
exports.Content = Content2;
|
|
318
|
+
exports.Header = Header;
|
|
319
|
+
exports.Item = Item;
|
|
320
|
+
exports.Root = Root2;
|
|
321
|
+
exports.Trigger = Trigger2;
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { createContextScope } from '../../../../../@radix-ui_react-context@1.1.2_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-context/dist/index.mjs';
|
|
4
|
+
import { createCollection } from '../../../../../@radix-ui_react-collection@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_re_59aa5e150e70a3e7bfb1567148b021b5/node_modules/@radix-ui/react-collection/dist/index.mjs';
|
|
5
|
+
import { useComposedRefs } from '../../../../../@radix-ui_react-compose-refs@1.1.2_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-compose-refs/dist/index.mjs';
|
|
6
|
+
import { composeEventHandlers } from '../../../../../@radix-ui_primitive@1.1.3/node_modules/@radix-ui/primitive/dist/index.mjs';
|
|
7
|
+
import { useControllableState } from '../../../../../@radix-ui_react-use-controllable-state@1.2.2_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs';
|
|
8
|
+
import { Primitive } from '../../../../../@radix-ui_react-primitive@2.1.3_@types_react-dom@19.2.3_@types_react@19.2.6__@types_rea_a92a69cb1cb39305138539e4fa72f596/node_modules/@radix-ui/react-primitive/dist/index.mjs';
|
|
9
|
+
import { createCollapsibleScope, Root, Trigger, Content } from '../../../../../@radix-ui_react-collapsible@1.1.12_@types_react-dom@19.2.3_@types_react@19.2.6__@types__d025a77f62ee83ca6bd8b0ea1f9de738/node_modules/@radix-ui/react-collapsible/dist/index.mjs';
|
|
10
|
+
import { useId } from '../../../../../@radix-ui_react-id@1.1.1_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-id/dist/index.mjs';
|
|
11
|
+
import { useDirection } from '../../../../../@radix-ui_react-direction@1.1.1_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-direction/dist/index.mjs';
|
|
12
|
+
import { jsx } from 'react/jsx-runtime';
|
|
13
|
+
|
|
14
|
+
var ACCORDION_NAME = "Accordion";
|
|
15
|
+
var ACCORDION_KEYS = ["Home", "End", "ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"];
|
|
16
|
+
var [Collection, useCollection, createCollectionScope] = createCollection(ACCORDION_NAME);
|
|
17
|
+
var [createAccordionContext] = createContextScope(ACCORDION_NAME, [
|
|
18
|
+
createCollectionScope,
|
|
19
|
+
createCollapsibleScope
|
|
20
|
+
]);
|
|
21
|
+
var useCollapsibleScope = createCollapsibleScope();
|
|
22
|
+
var Accordion = React__default.forwardRef(
|
|
23
|
+
(props, forwardedRef) => {
|
|
24
|
+
const { type, ...accordionProps } = props;
|
|
25
|
+
const singleProps = accordionProps;
|
|
26
|
+
const multipleProps = accordionProps;
|
|
27
|
+
return /* @__PURE__ */ jsx(Collection.Provider, { scope: props.__scopeAccordion, children: type === "multiple" ? /* @__PURE__ */ jsx(AccordionImplMultiple, { ...multipleProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(AccordionImplSingle, { ...singleProps, ref: forwardedRef }) });
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
Accordion.displayName = ACCORDION_NAME;
|
|
31
|
+
var [AccordionValueProvider, useAccordionValueContext] = createAccordionContext(ACCORDION_NAME);
|
|
32
|
+
var [AccordionCollapsibleProvider, useAccordionCollapsibleContext] = createAccordionContext(
|
|
33
|
+
ACCORDION_NAME,
|
|
34
|
+
{ collapsible: false }
|
|
35
|
+
);
|
|
36
|
+
var AccordionImplSingle = React__default.forwardRef(
|
|
37
|
+
(props, forwardedRef) => {
|
|
38
|
+
const {
|
|
39
|
+
value: valueProp,
|
|
40
|
+
defaultValue,
|
|
41
|
+
onValueChange = () => {
|
|
42
|
+
},
|
|
43
|
+
collapsible = false,
|
|
44
|
+
...accordionSingleProps
|
|
45
|
+
} = props;
|
|
46
|
+
const [value, setValue] = useControllableState({
|
|
47
|
+
prop: valueProp,
|
|
48
|
+
defaultProp: defaultValue ?? "",
|
|
49
|
+
onChange: onValueChange,
|
|
50
|
+
caller: ACCORDION_NAME
|
|
51
|
+
});
|
|
52
|
+
return /* @__PURE__ */ jsx(
|
|
53
|
+
AccordionValueProvider,
|
|
54
|
+
{
|
|
55
|
+
scope: props.__scopeAccordion,
|
|
56
|
+
value: React__default.useMemo(() => value ? [value] : [], [value]),
|
|
57
|
+
onItemOpen: setValue,
|
|
58
|
+
onItemClose: React__default.useCallback(() => collapsible && setValue(""), [collapsible, setValue]),
|
|
59
|
+
children: /* @__PURE__ */ jsx(AccordionCollapsibleProvider, { scope: props.__scopeAccordion, collapsible, children: /* @__PURE__ */ jsx(AccordionImpl, { ...accordionSingleProps, ref: forwardedRef }) })
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
var AccordionImplMultiple = React__default.forwardRef((props, forwardedRef) => {
|
|
65
|
+
const {
|
|
66
|
+
value: valueProp,
|
|
67
|
+
defaultValue,
|
|
68
|
+
onValueChange = () => {
|
|
69
|
+
},
|
|
70
|
+
...accordionMultipleProps
|
|
71
|
+
} = props;
|
|
72
|
+
const [value, setValue] = useControllableState({
|
|
73
|
+
prop: valueProp,
|
|
74
|
+
defaultProp: defaultValue ?? [],
|
|
75
|
+
onChange: onValueChange,
|
|
76
|
+
caller: ACCORDION_NAME
|
|
77
|
+
});
|
|
78
|
+
const handleItemOpen = React__default.useCallback(
|
|
79
|
+
(itemValue) => setValue((prevValue = []) => [...prevValue, itemValue]),
|
|
80
|
+
[setValue]
|
|
81
|
+
);
|
|
82
|
+
const handleItemClose = React__default.useCallback(
|
|
83
|
+
(itemValue) => setValue((prevValue = []) => prevValue.filter((value2) => value2 !== itemValue)),
|
|
84
|
+
[setValue]
|
|
85
|
+
);
|
|
86
|
+
return /* @__PURE__ */ jsx(
|
|
87
|
+
AccordionValueProvider,
|
|
88
|
+
{
|
|
89
|
+
scope: props.__scopeAccordion,
|
|
90
|
+
value,
|
|
91
|
+
onItemOpen: handleItemOpen,
|
|
92
|
+
onItemClose: handleItemClose,
|
|
93
|
+
children: /* @__PURE__ */ jsx(AccordionCollapsibleProvider, { scope: props.__scopeAccordion, collapsible: true, children: /* @__PURE__ */ jsx(AccordionImpl, { ...accordionMultipleProps, ref: forwardedRef }) })
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
var [AccordionImplProvider, useAccordionContext] = createAccordionContext(ACCORDION_NAME);
|
|
98
|
+
var AccordionImpl = React__default.forwardRef(
|
|
99
|
+
(props, forwardedRef) => {
|
|
100
|
+
const { __scopeAccordion, disabled, dir, orientation = "vertical", ...accordionProps } = props;
|
|
101
|
+
const accordionRef = React__default.useRef(null);
|
|
102
|
+
const composedRefs = useComposedRefs(accordionRef, forwardedRef);
|
|
103
|
+
const getItems = useCollection(__scopeAccordion);
|
|
104
|
+
const direction = useDirection(dir);
|
|
105
|
+
const isDirectionLTR = direction === "ltr";
|
|
106
|
+
const handleKeyDown = composeEventHandlers(props.onKeyDown, (event) => {
|
|
107
|
+
if (!ACCORDION_KEYS.includes(event.key)) return;
|
|
108
|
+
const target = event.target;
|
|
109
|
+
const triggerCollection = getItems().filter((item) => !item.ref.current?.disabled);
|
|
110
|
+
const triggerIndex = triggerCollection.findIndex((item) => item.ref.current === target);
|
|
111
|
+
const triggerCount = triggerCollection.length;
|
|
112
|
+
if (triggerIndex === -1) return;
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
let nextIndex = triggerIndex;
|
|
115
|
+
const homeIndex = 0;
|
|
116
|
+
const endIndex = triggerCount - 1;
|
|
117
|
+
const moveNext = () => {
|
|
118
|
+
nextIndex = triggerIndex + 1;
|
|
119
|
+
if (nextIndex > endIndex) {
|
|
120
|
+
nextIndex = homeIndex;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const movePrev = () => {
|
|
124
|
+
nextIndex = triggerIndex - 1;
|
|
125
|
+
if (nextIndex < homeIndex) {
|
|
126
|
+
nextIndex = endIndex;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
switch (event.key) {
|
|
130
|
+
case "Home":
|
|
131
|
+
nextIndex = homeIndex;
|
|
132
|
+
break;
|
|
133
|
+
case "End":
|
|
134
|
+
nextIndex = endIndex;
|
|
135
|
+
break;
|
|
136
|
+
case "ArrowRight":
|
|
137
|
+
if (orientation === "horizontal") {
|
|
138
|
+
if (isDirectionLTR) {
|
|
139
|
+
moveNext();
|
|
140
|
+
} else {
|
|
141
|
+
movePrev();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
break;
|
|
145
|
+
case "ArrowDown":
|
|
146
|
+
if (orientation === "vertical") {
|
|
147
|
+
moveNext();
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
150
|
+
case "ArrowLeft":
|
|
151
|
+
if (orientation === "horizontal") {
|
|
152
|
+
if (isDirectionLTR) {
|
|
153
|
+
movePrev();
|
|
154
|
+
} else {
|
|
155
|
+
moveNext();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
break;
|
|
159
|
+
case "ArrowUp":
|
|
160
|
+
if (orientation === "vertical") {
|
|
161
|
+
movePrev();
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
const clampedIndex = nextIndex % triggerCount;
|
|
166
|
+
triggerCollection[clampedIndex].ref.current?.focus();
|
|
167
|
+
});
|
|
168
|
+
return /* @__PURE__ */ jsx(
|
|
169
|
+
AccordionImplProvider,
|
|
170
|
+
{
|
|
171
|
+
scope: __scopeAccordion,
|
|
172
|
+
disabled,
|
|
173
|
+
direction: dir,
|
|
174
|
+
orientation,
|
|
175
|
+
children: /* @__PURE__ */ jsx(Collection.Slot, { scope: __scopeAccordion, children: /* @__PURE__ */ jsx(
|
|
176
|
+
Primitive.div,
|
|
177
|
+
{
|
|
178
|
+
...accordionProps,
|
|
179
|
+
"data-orientation": orientation,
|
|
180
|
+
ref: composedRefs,
|
|
181
|
+
onKeyDown: disabled ? void 0 : handleKeyDown
|
|
182
|
+
}
|
|
183
|
+
) })
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
var ITEM_NAME = "AccordionItem";
|
|
189
|
+
var [AccordionItemProvider, useAccordionItemContext] = createAccordionContext(ITEM_NAME);
|
|
190
|
+
var AccordionItem = React__default.forwardRef(
|
|
191
|
+
(props, forwardedRef) => {
|
|
192
|
+
const { __scopeAccordion, value, ...accordionItemProps } = props;
|
|
193
|
+
const accordionContext = useAccordionContext(ITEM_NAME, __scopeAccordion);
|
|
194
|
+
const valueContext = useAccordionValueContext(ITEM_NAME, __scopeAccordion);
|
|
195
|
+
const collapsibleScope = useCollapsibleScope(__scopeAccordion);
|
|
196
|
+
const triggerId = useId();
|
|
197
|
+
const open = value && valueContext.value.includes(value) || false;
|
|
198
|
+
const disabled = accordionContext.disabled || props.disabled;
|
|
199
|
+
return /* @__PURE__ */ jsx(
|
|
200
|
+
AccordionItemProvider,
|
|
201
|
+
{
|
|
202
|
+
scope: __scopeAccordion,
|
|
203
|
+
open,
|
|
204
|
+
disabled,
|
|
205
|
+
triggerId,
|
|
206
|
+
children: /* @__PURE__ */ jsx(
|
|
207
|
+
Root,
|
|
208
|
+
{
|
|
209
|
+
"data-orientation": accordionContext.orientation,
|
|
210
|
+
"data-state": getState(open),
|
|
211
|
+
...collapsibleScope,
|
|
212
|
+
...accordionItemProps,
|
|
213
|
+
ref: forwardedRef,
|
|
214
|
+
disabled,
|
|
215
|
+
open,
|
|
216
|
+
onOpenChange: (open2) => {
|
|
217
|
+
if (open2) {
|
|
218
|
+
valueContext.onItemOpen(value);
|
|
219
|
+
} else {
|
|
220
|
+
valueContext.onItemClose(value);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
);
|
|
229
|
+
AccordionItem.displayName = ITEM_NAME;
|
|
230
|
+
var HEADER_NAME = "AccordionHeader";
|
|
231
|
+
var AccordionHeader = React__default.forwardRef(
|
|
232
|
+
(props, forwardedRef) => {
|
|
233
|
+
const { __scopeAccordion, ...headerProps } = props;
|
|
234
|
+
const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);
|
|
235
|
+
const itemContext = useAccordionItemContext(HEADER_NAME, __scopeAccordion);
|
|
236
|
+
return /* @__PURE__ */ jsx(
|
|
237
|
+
Primitive.h3,
|
|
238
|
+
{
|
|
239
|
+
"data-orientation": accordionContext.orientation,
|
|
240
|
+
"data-state": getState(itemContext.open),
|
|
241
|
+
"data-disabled": itemContext.disabled ? "" : void 0,
|
|
242
|
+
...headerProps,
|
|
243
|
+
ref: forwardedRef
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
AccordionHeader.displayName = HEADER_NAME;
|
|
249
|
+
var TRIGGER_NAME = "AccordionTrigger";
|
|
250
|
+
var AccordionTrigger = React__default.forwardRef(
|
|
251
|
+
(props, forwardedRef) => {
|
|
252
|
+
const { __scopeAccordion, ...triggerProps } = props;
|
|
253
|
+
const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);
|
|
254
|
+
const itemContext = useAccordionItemContext(TRIGGER_NAME, __scopeAccordion);
|
|
255
|
+
const collapsibleContext = useAccordionCollapsibleContext(TRIGGER_NAME, __scopeAccordion);
|
|
256
|
+
const collapsibleScope = useCollapsibleScope(__scopeAccordion);
|
|
257
|
+
return /* @__PURE__ */ jsx(Collection.ItemSlot, { scope: __scopeAccordion, children: /* @__PURE__ */ jsx(
|
|
258
|
+
Trigger,
|
|
259
|
+
{
|
|
260
|
+
"aria-disabled": itemContext.open && !collapsibleContext.collapsible || void 0,
|
|
261
|
+
"data-orientation": accordionContext.orientation,
|
|
262
|
+
id: itemContext.triggerId,
|
|
263
|
+
...collapsibleScope,
|
|
264
|
+
...triggerProps,
|
|
265
|
+
ref: forwardedRef
|
|
266
|
+
}
|
|
267
|
+
) });
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
AccordionTrigger.displayName = TRIGGER_NAME;
|
|
271
|
+
var CONTENT_NAME = "AccordionContent";
|
|
272
|
+
var AccordionContent = React__default.forwardRef(
|
|
273
|
+
(props, forwardedRef) => {
|
|
274
|
+
const { __scopeAccordion, ...contentProps } = props;
|
|
275
|
+
const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);
|
|
276
|
+
const itemContext = useAccordionItemContext(CONTENT_NAME, __scopeAccordion);
|
|
277
|
+
const collapsibleScope = useCollapsibleScope(__scopeAccordion);
|
|
278
|
+
return /* @__PURE__ */ jsx(
|
|
279
|
+
Content,
|
|
280
|
+
{
|
|
281
|
+
role: "region",
|
|
282
|
+
"aria-labelledby": itemContext.triggerId,
|
|
283
|
+
"data-orientation": accordionContext.orientation,
|
|
284
|
+
...collapsibleScope,
|
|
285
|
+
...contentProps,
|
|
286
|
+
ref: forwardedRef,
|
|
287
|
+
style: {
|
|
288
|
+
["--radix-accordion-content-height"]: "var(--radix-collapsible-content-height)",
|
|
289
|
+
["--radix-accordion-content-width"]: "var(--radix-collapsible-content-width)",
|
|
290
|
+
...props.style
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
);
|
|
296
|
+
AccordionContent.displayName = CONTENT_NAME;
|
|
297
|
+
function getState(open) {
|
|
298
|
+
return open ? "open" : "closed";
|
|
299
|
+
}
|
|
300
|
+
var Root2 = Accordion;
|
|
301
|
+
var Item = AccordionItem;
|
|
302
|
+
var Header = AccordionHeader;
|
|
303
|
+
var Trigger2 = AccordionTrigger;
|
|
304
|
+
var Content2 = AccordionContent;
|
|
305
|
+
|
|
306
|
+
export { Accordion, AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger, Content2 as Content, Header, Item, Root2 as Root, Trigger2 as Trigger };
|