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