@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.mjs CHANGED
@@ -1,325 +1,337 @@
1
- import $3DjNB$babelruntimehelpersesmextends from "@babel/runtime/helpers/esm/extends";
2
- import $3DjNB$react from "react";
3
- import {createContextScope as $3DjNB$createContextScope} from "@radix-ui/react-context";
4
- import {createCollection as $3DjNB$createCollection} from "@radix-ui/react-collection";
5
- import {useComposedRefs as $3DjNB$useComposedRefs} from "@radix-ui/react-compose-refs";
6
- import {composeEventHandlers as $3DjNB$composeEventHandlers} from "@radix-ui/primitive";
7
- import {useControllableState as $3DjNB$useControllableState} from "@radix-ui/react-use-controllable-state";
8
- import {Primitive as $3DjNB$Primitive} from "@radix-ui/react-primitive";
9
- import {createCollapsibleScope as $3DjNB$createCollapsibleScope, Root as $3DjNB$Root, Trigger as $3DjNB$Trigger, Content as $3DjNB$Content} from "@radix-ui/react-collapsible";
10
- import {useId as $3DjNB$useId} from "@radix-ui/react-id";
11
- import {useDirection as $3DjNB$useDirection} from "@radix-ui/react-direction";
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
- const $1bf158f521e1b1b4$var$useCollapsibleScope = $3DjNB$createCollapsibleScope();
42
- const $1bf158f521e1b1b4$export$a766cd26d0d69044 = /*#__PURE__*/ $3DjNB$react.forwardRef((props, forwardedRef)=>{
43
- const { type: type , ...accordionProps } = props;
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 /*#__PURE__*/ $3DjNB$react.createElement($1bf158f521e1b1b4$var$Collection.Provider, {
47
- scope: props.__scopeAccordion
48
- }, type === 'multiple' ? /*#__PURE__*/ $3DjNB$react.createElement($1bf158f521e1b1b4$var$AccordionImplMultiple, $3DjNB$babelruntimehelpersesmextends({}, multipleProps, {
49
- ref: forwardedRef
50
- })) : /*#__PURE__*/ $3DjNB$react.createElement($1bf158f521e1b1b4$var$AccordionImplSingle, $3DjNB$babelruntimehelpersesmextends({}, singleProps, {
51
- ref: forwardedRef
52
- })));
53
- });
54
- /*#__PURE__*/ Object.assign($1bf158f521e1b1b4$export$a766cd26d0d69044, {
55
- displayName: $1bf158f521e1b1b4$var$ACCORDION_NAME
56
- });
57
- $1bf158f521e1b1b4$export$a766cd26d0d69044.propTypes = {
58
- type (props) {
59
- const value = props.value || props.defaultValue;
60
- if (props.type && ![
61
- 'single',
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
- /* -----------------------------------------------------------------------------------------------*/ const [$1bf158f521e1b1b4$var$AccordionValueProvider, $1bf158f521e1b1b4$var$useAccordionValueContext] = $1bf158f521e1b1b4$var$createAccordionContext($1bf158f521e1b1b4$var$ACCORDION_NAME);
70
- const [$1bf158f521e1b1b4$var$AccordionCollapsibleProvider, $1bf158f521e1b1b4$var$useAccordionCollapsibleContext] = $1bf158f521e1b1b4$var$createAccordionContext($1bf158f521e1b1b4$var$ACCORDION_NAME, {
71
- collapsible: false
72
- });
73
- const $1bf158f521e1b1b4$var$AccordionImplSingle = /*#__PURE__*/ $3DjNB$react.forwardRef((props, forwardedRef)=>{
74
- const { value: valueProp , defaultValue: defaultValue , onValueChange: onValueChange = ()=>{} , collapsible: collapsible = false , ...accordionSingleProps } = props;
75
- const [value, setValue] = $3DjNB$useControllableState({
76
- prop: valueProp,
77
- defaultProp: defaultValue,
78
- onChange: onValueChange
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 /*#__PURE__*/ $3DjNB$react.createElement($1bf158f521e1b1b4$var$AccordionValueProvider, {
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: $3DjNB$react.useCallback(()=>collapsible && setValue('')
87
- , [
88
- collapsible,
89
- setValue
90
- ])
91
- }, /*#__PURE__*/ $3DjNB$react.createElement($1bf158f521e1b1b4$var$AccordionCollapsibleProvider, {
92
- scope: props.__scopeAccordion,
93
- collapsible: collapsible
94
- }, /*#__PURE__*/ $3DjNB$react.createElement($1bf158f521e1b1b4$var$AccordionImpl, $3DjNB$babelruntimehelpersesmextends({}, accordionSingleProps, {
95
- ref: forwardedRef
96
- }))));
97
- });
98
- /* -----------------------------------------------------------------------------------------------*/ const $1bf158f521e1b1b4$var$AccordionImplMultiple = /*#__PURE__*/ $3DjNB$react.forwardRef((props, forwardedRef)=>{
99
- const { value: valueProp , defaultValue: defaultValue , onValueChange: onValueChange = ()=>{} , ...accordionMultipleProps } = props;
100
- const [value1 = [], setValue] = $3DjNB$useControllableState({
101
- prop: valueProp,
102
- defaultProp: defaultValue,
103
- onChange: onValueChange
104
- });
105
- const handleItemOpen = $3DjNB$react.useCallback((itemValue)=>setValue((prevValue = [])=>[
106
- ...prevValue,
107
- itemValue
108
- ]
109
- )
110
- , [
111
- setValue
112
- ]);
113
- const handleItemClose = $3DjNB$react.useCallback((itemValue)=>setValue((prevValue = [])=>prevValue.filter((value)=>value !== itemValue
114
- )
115
- )
116
- , [
117
- setValue
118
- ]);
119
- return /*#__PURE__*/ $3DjNB$react.createElement($1bf158f521e1b1b4$var$AccordionValueProvider, {
120
- scope: props.__scopeAccordion,
121
- value: value1,
122
- onItemOpen: handleItemOpen,
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
- /* -----------------------------------------------------------------------------------------------*/ const [$1bf158f521e1b1b4$var$AccordionImplProvider, $1bf158f521e1b1b4$var$useAccordionContext] = $1bf158f521e1b1b4$var$createAccordionContext($1bf158f521e1b1b4$var$ACCORDION_NAME);
132
- const $1bf158f521e1b1b4$var$AccordionImpl = /*#__PURE__*/ $3DjNB$react.forwardRef((props, forwardedRef)=>{
133
- const { __scopeAccordion: __scopeAccordion , disabled: disabled , dir: dir , orientation: orientation = 'vertical' , ...accordionProps } = props;
134
- const accordionRef = $3DjNB$react.useRef(null);
135
- const composedRefs = $3DjNB$useComposedRefs(accordionRef, forwardedRef);
136
- const getItems = $1bf158f521e1b1b4$var$useCollection(__scopeAccordion);
137
- const direction = $3DjNB$useDirection(dir);
138
- const isDirectionLTR = direction === 'ltr';
139
- const handleKeyDown = $3DjNB$composeEventHandlers(props.onKeyDown, (event)=>{
140
- var _triggerCollection$cl;
141
- if (!$1bf158f521e1b1b4$var$ACCORDION_KEYS.includes(event.key)) return;
142
- const target = event.target;
143
- const triggerCollection = getItems().filter((item)=>{
144
- var _item$ref$current;
145
- return !((_item$ref$current = item.ref.current) !== null && _item$ref$current !== void 0 && _item$ref$current.disabled);
146
- });
147
- const triggerIndex = triggerCollection.findIndex((item)=>item.ref.current === target
148
- );
149
- const triggerCount = triggerCollection.length;
150
- if (triggerIndex === -1) return; // Prevents page scroll while user is navigating
151
- event.preventDefault();
152
- let nextIndex = triggerIndex;
153
- const homeIndex = 0;
154
- const endIndex = triggerCount - 1;
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
- const clampedIndex = nextIndex % triggerCount;
190
- (_triggerCollection$cl = triggerCollection[clampedIndex].ref.current) === null || _triggerCollection$cl === void 0 || _triggerCollection$cl.focus();
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 /*#__PURE__*/ $3DjNB$react.createElement($1bf158f521e1b1b4$var$AccordionImplProvider, {
187
+ return /* @__PURE__ */ jsx(
188
+ AccordionImplProvider,
189
+ {
193
190
  scope: __scopeAccordion,
194
- disabled: disabled,
191
+ disabled,
195
192
  direction: dir,
196
- orientation: orientation
197
- }, /*#__PURE__*/ $3DjNB$react.createElement($1bf158f521e1b1b4$var$Collection.Slot, {
198
- scope: __scopeAccordion
199
- }, /*#__PURE__*/ $3DjNB$react.createElement($3DjNB$Primitive.div, $3DjNB$babelruntimehelpersesmextends({}, accordionProps, {
200
- "data-orientation": orientation,
201
- ref: composedRefs,
202
- onKeyDown: disabled ? undefined : handleKeyDown
203
- }))));
204
- });
205
- /* -------------------------------------------------------------------------------------------------
206
- * AccordionItem
207
- * -----------------------------------------------------------------------------------------------*/ const $1bf158f521e1b1b4$var$ITEM_NAME = 'AccordionItem';
208
- const [$1bf158f521e1b1b4$var$AccordionItemProvider, $1bf158f521e1b1b4$var$useAccordionItemContext] = $1bf158f521e1b1b4$var$createAccordionContext($1bf158f521e1b1b4$var$ITEM_NAME);
209
- /**
210
- * `AccordionItem` contains all of the parts of a collapsible section inside of an `Accordion`.
211
- */ const $1bf158f521e1b1b4$export$d99097c13d4dac9f = /*#__PURE__*/ $3DjNB$react.forwardRef((props, forwardedRef)=>{
212
- const { __scopeAccordion: __scopeAccordion , value: value , ...accordionItemProps } = props;
213
- const accordionContext = $1bf158f521e1b1b4$var$useAccordionContext($1bf158f521e1b1b4$var$ITEM_NAME, __scopeAccordion);
214
- const valueContext = $1bf158f521e1b1b4$var$useAccordionValueContext($1bf158f521e1b1b4$var$ITEM_NAME, __scopeAccordion);
215
- const collapsibleScope = $1bf158f521e1b1b4$var$useCollapsibleScope(__scopeAccordion);
216
- const triggerId = $3DjNB$useId();
217
- const open1 = value && valueContext.value.includes(value) || false;
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 /*#__PURE__*/ $3DjNB$react.createElement($1bf158f521e1b1b4$var$AccordionItemProvider, {
218
+ return /* @__PURE__ */ jsx(
219
+ AccordionItemProvider,
220
+ {
220
221
  scope: __scopeAccordion,
221
- open: open1,
222
- disabled: disabled,
223
- triggerId: triggerId
224
- }, /*#__PURE__*/ $3DjNB$react.createElement($3DjNB$Root, $3DjNB$babelruntimehelpersesmextends({
225
- "data-orientation": accordionContext.orientation,
226
- "data-state": $1bf158f521e1b1b4$var$getState(open1)
227
- }, collapsibleScope, accordionItemProps, {
228
- ref: forwardedRef,
229
- disabled: disabled,
230
- open: open1,
231
- onOpenChange: (open)=>{
232
- if (open) valueContext.onItemOpen(value);
233
- else valueContext.onItemClose(value);
234
- }
235
- })));
236
- });
237
- /*#__PURE__*/ Object.assign($1bf158f521e1b1b4$export$d99097c13d4dac9f, {
238
- displayName: $1bf158f521e1b1b4$var$ITEM_NAME
239
- });
240
- /* -------------------------------------------------------------------------------------------------
241
- * AccordionHeader
242
- * -----------------------------------------------------------------------------------------------*/ const $1bf158f521e1b1b4$var$HEADER_NAME = 'AccordionHeader';
243
- /**
244
- * `AccordionHeader` contains the content for the parts of an `AccordionItem` that will be visible
245
- * whether or not its content is collapsed.
246
- */ const $1bf158f521e1b1b4$export$5e3e5deaaf81ee41 = /*#__PURE__*/ $3DjNB$react.forwardRef((props, forwardedRef)=>{
247
- const { __scopeAccordion: __scopeAccordion , ...headerProps } = props;
248
- const accordionContext = $1bf158f521e1b1b4$var$useAccordionContext($1bf158f521e1b1b4$var$ACCORDION_NAME, __scopeAccordion);
249
- const itemContext = $1bf158f521e1b1b4$var$useAccordionItemContext($1bf158f521e1b1b4$var$HEADER_NAME, __scopeAccordion);
250
- return /*#__PURE__*/ $3DjNB$react.createElement($3DjNB$Primitive.h3, $3DjNB$babelruntimehelpersesmextends({
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": $1bf158f521e1b1b4$var$getState(itemContext.open),
253
- "data-disabled": itemContext.disabled ? '' : undefined
254
- }, headerProps, {
259
+ "data-state": getState(itemContext.open),
260
+ "data-disabled": itemContext.disabled ? "" : void 0,
261
+ ...headerProps,
255
262
  ref: forwardedRef
256
- }));
257
- });
258
- /*#__PURE__*/ Object.assign($1bf158f521e1b1b4$export$5e3e5deaaf81ee41, {
259
- displayName: $1bf158f521e1b1b4$var$HEADER_NAME
260
- });
261
- /* -------------------------------------------------------------------------------------------------
262
- * AccordionTrigger
263
- * -----------------------------------------------------------------------------------------------*/ const $1bf158f521e1b1b4$var$TRIGGER_NAME = 'AccordionTrigger';
264
- /**
265
- * `AccordionTrigger` is the trigger that toggles the collapsed state of an `AccordionItem`. It
266
- * should always be nested inside of an `AccordionHeader`.
267
- */ const $1bf158f521e1b1b4$export$94e939b1f85bdd73 = /*#__PURE__*/ $3DjNB$react.forwardRef((props, forwardedRef)=>{
268
- const { __scopeAccordion: __scopeAccordion , ...triggerProps } = props;
269
- const accordionContext = $1bf158f521e1b1b4$var$useAccordionContext($1bf158f521e1b1b4$var$ACCORDION_NAME, __scopeAccordion);
270
- const itemContext = $1bf158f521e1b1b4$var$useAccordionItemContext($1bf158f521e1b1b4$var$TRIGGER_NAME, __scopeAccordion);
271
- const collapsibleContext = $1bf158f521e1b1b4$var$useAccordionCollapsibleContext($1bf158f521e1b1b4$var$TRIGGER_NAME, __scopeAccordion);
272
- const collapsibleScope = $1bf158f521e1b1b4$var$useCollapsibleScope(__scopeAccordion);
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
- }, collapsibleScope, triggerProps, {
281
+ id: itemContext.triggerId,
282
+ ...collapsibleScope,
283
+ ...triggerProps,
280
284
  ref: forwardedRef
281
- })));
282
- });
283
- /*#__PURE__*/ Object.assign($1bf158f521e1b1b4$export$94e939b1f85bdd73, {
284
- displayName: $1bf158f521e1b1b4$var$TRIGGER_NAME
285
- });
286
- /* -------------------------------------------------------------------------------------------------
287
- * AccordionContent
288
- * -----------------------------------------------------------------------------------------------*/ const $1bf158f521e1b1b4$var$CONTENT_NAME = 'AccordionContent';
289
- /**
290
- * `AccordionContent` contains the collapsible content for an `AccordionItem`.
291
- */ const $1bf158f521e1b1b4$export$985b9a77379b54a0 = /*#__PURE__*/ $3DjNB$react.forwardRef((props, forwardedRef)=>{
292
- const { __scopeAccordion: __scopeAccordion , ...contentProps } = props;
293
- const accordionContext = $1bf158f521e1b1b4$var$useAccordionContext($1bf158f521e1b1b4$var$ACCORDION_NAME, __scopeAccordion);
294
- const itemContext = $1bf158f521e1b1b4$var$useAccordionItemContext($1bf158f521e1b1b4$var$CONTENT_NAME, __scopeAccordion);
295
- const collapsibleScope = $1bf158f521e1b1b4$var$useCollapsibleScope(__scopeAccordion);
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
- }, collapsibleScope, contentProps, {
302
+ "data-orientation": accordionContext.orientation,
303
+ ...collapsibleScope,
304
+ ...contentProps,
301
305
  ref: forwardedRef,
302
306
  style: {
303
- ['--radix-accordion-content-height']: 'var(--radix-collapsible-content-height)',
304
- ['--radix-accordion-content-width']: 'var(--radix-collapsible-content-width)',
305
- ...props.style
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
- /*#__PURE__*/ Object.assign($1bf158f521e1b1b4$export$985b9a77379b54a0, {
310
- displayName: $1bf158f521e1b1b4$var$CONTENT_NAME
311
- });
312
- /* -----------------------------------------------------------------------------------------------*/ function $1bf158f521e1b1b4$var$getState(open) {
313
- return open ? 'open' : 'closed';
311
+ }
312
+ );
313
+ }
314
+ );
315
+ AccordionContent.displayName = CONTENT_NAME;
316
+ function getState(open) {
317
+ return open ? "open" : "closed";
314
318
  }
315
- const $1bf158f521e1b1b4$export$be92b6f5f03c0fe9 = $1bf158f521e1b1b4$export$a766cd26d0d69044;
316
- const $1bf158f521e1b1b4$export$6d08773d2e66f8f2 = $1bf158f521e1b1b4$export$d99097c13d4dac9f;
317
- const $1bf158f521e1b1b4$export$8b251419efc915eb = $1bf158f521e1b1b4$export$5e3e5deaaf81ee41;
318
- const $1bf158f521e1b1b4$export$41fb9f06171c75f4 = $1bf158f521e1b1b4$export$94e939b1f85bdd73;
319
- const $1bf158f521e1b1b4$export$7c6e2c02157bb7d2 = $1bf158f521e1b1b4$export$985b9a77379b54a0;
320
-
321
-
322
-
323
-
324
- export {$1bf158f521e1b1b4$export$9748edc328a73be1 as createAccordionScope, $1bf158f521e1b1b4$export$a766cd26d0d69044 as Accordion, $1bf158f521e1b1b4$export$d99097c13d4dac9f as AccordionItem, $1bf158f521e1b1b4$export$5e3e5deaaf81ee41 as AccordionHeader, $1bf158f521e1b1b4$export$94e939b1f85bdd73 as AccordionTrigger, $1bf158f521e1b1b4$export$985b9a77379b54a0 as AccordionContent, $1bf158f521e1b1b4$export$be92b6f5f03c0fe9 as Root, $1bf158f521e1b1b4$export$6d08773d2e66f8f2 as Item, $1bf158f521e1b1b4$export$8b251419efc915eb as Header, $1bf158f521e1b1b4$export$41fb9f06171c75f4 as Trigger, $1bf158f521e1b1b4$export$7c6e2c02157bb7d2 as Content};
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