@radix-ui/react-accordion 1.1.2 → 1.2.0-rc.2

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