@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.js CHANGED
@@ -1,342 +1,357 @@
1
- var $47SRi$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
2
- var $47SRi$react = require("react");
3
- var $47SRi$radixuireactcontext = require("@radix-ui/react-context");
4
- var $47SRi$radixuireactcollection = require("@radix-ui/react-collection");
5
- var $47SRi$radixuireactcomposerefs = require("@radix-ui/react-compose-refs");
6
- var $47SRi$radixuiprimitive = require("@radix-ui/primitive");
7
- var $47SRi$radixuireactusecontrollablestate = require("@radix-ui/react-use-controllable-state");
8
- var $47SRi$radixuireactprimitive = require("@radix-ui/react-primitive");
9
- var $47SRi$radixuireactcollapsible = require("@radix-ui/react-collapsible");
10
- var $47SRi$radixuireactid = require("@radix-ui/react-id");
11
- var $47SRi$radixuireactdirection = require("@radix-ui/react-direction");
12
-
13
- function $parcel$export(e, n, v, s) {
14
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
15
- }
16
- function $parcel$interopDefault(a) {
17
- return a && a.__esModule ? a.default : a;
18
- }
19
-
20
- $parcel$export(module.exports, "createAccordionScope", () => $0f4a20de0660bfd8$export$9748edc328a73be1);
21
- $parcel$export(module.exports, "Accordion", () => $0f4a20de0660bfd8$export$a766cd26d0d69044);
22
- $parcel$export(module.exports, "AccordionItem", () => $0f4a20de0660bfd8$export$d99097c13d4dac9f);
23
- $parcel$export(module.exports, "AccordionHeader", () => $0f4a20de0660bfd8$export$5e3e5deaaf81ee41);
24
- $parcel$export(module.exports, "AccordionTrigger", () => $0f4a20de0660bfd8$export$94e939b1f85bdd73);
25
- $parcel$export(module.exports, "AccordionContent", () => $0f4a20de0660bfd8$export$985b9a77379b54a0);
26
- $parcel$export(module.exports, "Root", () => $0f4a20de0660bfd8$export$be92b6f5f03c0fe9);
27
- $parcel$export(module.exports, "Item", () => $0f4a20de0660bfd8$export$6d08773d2e66f8f2);
28
- $parcel$export(module.exports, "Header", () => $0f4a20de0660bfd8$export$8b251419efc915eb);
29
- $parcel$export(module.exports, "Trigger", () => $0f4a20de0660bfd8$export$41fb9f06171c75f4);
30
- $parcel$export(module.exports, "Content", () => $0f4a20de0660bfd8$export$7c6e2c02157bb7d2);
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
1
+ "use strict";
2
+ "use client";
3
+ (() => {
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
11
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
12
+ }) : x)(function(x) {
13
+ if (typeof require !== "undefined") return require.apply(this, arguments);
14
+ throw Error('Dynamic require of "' + x + '" is not supported');
15
+ });
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
42
32
 
43
- /* -------------------------------------------------------------------------------------------------
44
- * Accordion
45
- * -----------------------------------------------------------------------------------------------*/ const $0f4a20de0660bfd8$var$ACCORDION_NAME = 'Accordion';
46
- const $0f4a20de0660bfd8$var$ACCORDION_KEYS = [
47
- 'Home',
48
- 'End',
49
- 'ArrowDown',
50
- 'ArrowUp',
51
- 'ArrowLeft',
52
- 'ArrowRight'
53
- ];
54
- const [$0f4a20de0660bfd8$var$Collection, $0f4a20de0660bfd8$var$useCollection, $0f4a20de0660bfd8$var$createCollectionScope] = $47SRi$radixuireactcollection.createCollection($0f4a20de0660bfd8$var$ACCORDION_NAME);
55
- const [$0f4a20de0660bfd8$var$createAccordionContext, $0f4a20de0660bfd8$export$9748edc328a73be1] = $47SRi$radixuireactcontext.createContextScope($0f4a20de0660bfd8$var$ACCORDION_NAME, [
56
- $0f4a20de0660bfd8$var$createCollectionScope,
57
- $47SRi$radixuireactcollapsible.createCollapsibleScope
58
- ]);
59
- const $0f4a20de0660bfd8$var$useCollapsibleScope = $47SRi$radixuireactcollapsible.createCollapsibleScope();
60
- const $0f4a20de0660bfd8$export$a766cd26d0d69044 = /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).forwardRef((props, forwardedRef)=>{
61
- const { type: type , ...accordionProps } = props;
62
- const singleProps = accordionProps;
63
- const multipleProps = accordionProps;
64
- return /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).createElement($0f4a20de0660bfd8$var$Collection.Provider, {
65
- scope: props.__scopeAccordion
66
- }, type === 'multiple' ? /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).createElement($0f4a20de0660bfd8$var$AccordionImplMultiple, ($parcel$interopDefault($47SRi$babelruntimehelpersextends))({}, multipleProps, {
67
- ref: forwardedRef
68
- })) : /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).createElement($0f4a20de0660bfd8$var$AccordionImplSingle, ($parcel$interopDefault($47SRi$babelruntimehelpersextends))({}, singleProps, {
69
- ref: forwardedRef
70
- })));
71
- });
72
- /*#__PURE__*/ Object.assign($0f4a20de0660bfd8$export$a766cd26d0d69044, {
73
- displayName: $0f4a20de0660bfd8$var$ACCORDION_NAME
74
- });
75
- $0f4a20de0660bfd8$export$a766cd26d0d69044.propTypes = {
76
- type (props) {
77
- const value = props.value || props.defaultValue;
78
- if (props.type && ![
79
- 'single',
80
- 'multiple'
81
- ].includes(props.type)) return new Error('Invalid prop `type` supplied to `Accordion`. Expected one of `single | multiple`.');
82
- 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`.');
83
- 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[]`.');
84
- return null;
33
+ // packages/react/accordion/src/Accordion.tsx
34
+ var import_react = __toESM(__require("react"));
35
+ var import_react_context = __require("@radix-ui/react-context");
36
+ var import_react_collection = __require("@radix-ui/react-collection");
37
+ var import_react_compose_refs = __require("@radix-ui/react-compose-refs");
38
+ var import_primitive = __require("@radix-ui/primitive");
39
+ var import_react_use_controllable_state = __require("@radix-ui/react-use-controllable-state");
40
+ var import_react_primitive = __require("@radix-ui/react-primitive");
41
+ var CollapsiblePrimitive = __toESM(__require("@radix-ui/react-collapsible"));
42
+ var import_react_collapsible = __require("@radix-ui/react-collapsible");
43
+ var import_react_id = __require("@radix-ui/react-id");
44
+ var import_react_direction = __require("@radix-ui/react-direction");
45
+ var import_jsx_runtime = __require("react/jsx-runtime");
46
+ var ACCORDION_NAME = "Accordion";
47
+ var ACCORDION_KEYS = ["Home", "End", "ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"];
48
+ var [Collection, useCollection, createCollectionScope] = (0, import_react_collection.createCollection)(ACCORDION_NAME);
49
+ var [createAccordionContext, createAccordionScope] = (0, import_react_context.createContextScope)(ACCORDION_NAME, [
50
+ createCollectionScope,
51
+ import_react_collapsible.createCollapsibleScope
52
+ ]);
53
+ var useCollapsibleScope = (0, import_react_collapsible.createCollapsibleScope)();
54
+ var Accordion = import_react.default.forwardRef(
55
+ (props, forwardedRef) => {
56
+ const { type, ...accordionProps } = props;
57
+ const singleProps = accordionProps;
58
+ const multipleProps = accordionProps;
59
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Provider, { scope: props.__scopeAccordion, children: type === "multiple" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AccordionImplMultiple, { ...multipleProps, ref: forwardedRef }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AccordionImplSingle, { ...singleProps, ref: forwardedRef }) });
85
60
  }
86
- };
87
- /* -----------------------------------------------------------------------------------------------*/ const [$0f4a20de0660bfd8$var$AccordionValueProvider, $0f4a20de0660bfd8$var$useAccordionValueContext] = $0f4a20de0660bfd8$var$createAccordionContext($0f4a20de0660bfd8$var$ACCORDION_NAME);
88
- const [$0f4a20de0660bfd8$var$AccordionCollapsibleProvider, $0f4a20de0660bfd8$var$useAccordionCollapsibleContext] = $0f4a20de0660bfd8$var$createAccordionContext($0f4a20de0660bfd8$var$ACCORDION_NAME, {
89
- collapsible: false
90
- });
91
- const $0f4a20de0660bfd8$var$AccordionImplSingle = /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).forwardRef((props, forwardedRef)=>{
92
- const { value: valueProp , defaultValue: defaultValue , onValueChange: onValueChange = ()=>{} , collapsible: collapsible = false , ...accordionSingleProps } = props;
93
- const [value, setValue] = $47SRi$radixuireactusecontrollablestate.useControllableState({
94
- prop: valueProp,
95
- defaultProp: defaultValue,
96
- onChange: onValueChange
97
- });
98
- return /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).createElement($0f4a20de0660bfd8$var$AccordionValueProvider, {
99
- scope: props.__scopeAccordion,
100
- value: value ? [
101
- value
102
- ] : [],
103
- onItemOpen: setValue,
104
- onItemClose: ($parcel$interopDefault($47SRi$react)).useCallback(()=>collapsible && setValue('')
105
- , [
106
- collapsible,
107
- setValue
108
- ])
109
- }, /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).createElement($0f4a20de0660bfd8$var$AccordionCollapsibleProvider, {
110
- scope: props.__scopeAccordion,
111
- collapsible: collapsible
112
- }, /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).createElement($0f4a20de0660bfd8$var$AccordionImpl, ($parcel$interopDefault($47SRi$babelruntimehelpersextends))({}, accordionSingleProps, {
113
- ref: forwardedRef
114
- }))));
115
- });
116
- /* -----------------------------------------------------------------------------------------------*/ const $0f4a20de0660bfd8$var$AccordionImplMultiple = /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).forwardRef((props, forwardedRef)=>{
117
- const { value: valueProp , defaultValue: defaultValue , onValueChange: onValueChange = ()=>{} , ...accordionMultipleProps } = props;
118
- const [value1 = [], setValue] = $47SRi$radixuireactusecontrollablestate.useControllableState({
61
+ );
62
+ Accordion.displayName = ACCORDION_NAME;
63
+ Accordion.propTypes = {
64
+ type(props) {
65
+ const value = props.value || props.defaultValue;
66
+ if (props.type && !["single", "multiple"].includes(props.type)) {
67
+ return new Error(
68
+ "Invalid prop `type` supplied to `Accordion`. Expected one of `single | multiple`."
69
+ );
70
+ }
71
+ if (props.type === "multiple" && typeof value === "string") {
72
+ return new Error(
73
+ "Invalid prop `type` supplied to `Accordion`. Expected `single` when `defaultValue` or `value` is type `string`."
74
+ );
75
+ }
76
+ if (props.type === "single" && Array.isArray(value)) {
77
+ return new Error(
78
+ "Invalid prop `type` supplied to `Accordion`. Expected `multiple` when `defaultValue` or `value` is type `string[]`."
79
+ );
80
+ }
81
+ return null;
82
+ }
83
+ };
84
+ var [AccordionValueProvider, useAccordionValueContext] = createAccordionContext(ACCORDION_NAME);
85
+ var [AccordionCollapsibleProvider, useAccordionCollapsibleContext] = createAccordionContext(
86
+ ACCORDION_NAME,
87
+ { collapsible: false }
88
+ );
89
+ var AccordionImplSingle = import_react.default.forwardRef(
90
+ (props, forwardedRef) => {
91
+ const {
92
+ value: valueProp,
93
+ defaultValue,
94
+ onValueChange = () => {
95
+ },
96
+ collapsible = false,
97
+ ...accordionSingleProps
98
+ } = props;
99
+ const [value, setValue] = (0, import_react_use_controllable_state.useControllableState)({
119
100
  prop: valueProp,
120
101
  defaultProp: defaultValue,
121
102
  onChange: onValueChange
103
+ });
104
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
105
+ AccordionValueProvider,
106
+ {
107
+ scope: props.__scopeAccordion,
108
+ value: value ? [value] : [],
109
+ onItemOpen: setValue,
110
+ onItemClose: import_react.default.useCallback(() => collapsible && setValue(""), [collapsible, setValue]),
111
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AccordionCollapsibleProvider, { scope: props.__scopeAccordion, collapsible, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AccordionImpl, { ...accordionSingleProps, ref: forwardedRef }) })
112
+ }
113
+ );
114
+ }
115
+ );
116
+ var AccordionImplMultiple = import_react.default.forwardRef((props, forwardedRef) => {
117
+ const {
118
+ value: valueProp,
119
+ defaultValue,
120
+ onValueChange = () => {
121
+ },
122
+ ...accordionMultipleProps
123
+ } = props;
124
+ const [value = [], setValue] = (0, import_react_use_controllable_state.useControllableState)({
125
+ prop: valueProp,
126
+ defaultProp: defaultValue,
127
+ onChange: onValueChange
122
128
  });
123
- const handleItemOpen = ($parcel$interopDefault($47SRi$react)).useCallback((itemValue)=>setValue((prevValue = [])=>[
124
- ...prevValue,
125
- itemValue
126
- ]
127
- )
128
- , [
129
- setValue
130
- ]);
131
- const handleItemClose = ($parcel$interopDefault($47SRi$react)).useCallback((itemValue)=>setValue((prevValue = [])=>prevValue.filter((value)=>value !== itemValue
132
- )
133
- )
134
- , [
135
- setValue
136
- ]);
137
- return /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).createElement($0f4a20de0660bfd8$var$AccordionValueProvider, {
129
+ const handleItemOpen = import_react.default.useCallback(
130
+ (itemValue) => setValue((prevValue = []) => [...prevValue, itemValue]),
131
+ [setValue]
132
+ );
133
+ const handleItemClose = import_react.default.useCallback(
134
+ (itemValue) => setValue((prevValue = []) => prevValue.filter((value2) => value2 !== itemValue)),
135
+ [setValue]
136
+ );
137
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
138
+ AccordionValueProvider,
139
+ {
138
140
  scope: props.__scopeAccordion,
139
- value: value1,
141
+ value,
140
142
  onItemOpen: handleItemOpen,
141
- onItemClose: handleItemClose
142
- }, /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).createElement($0f4a20de0660bfd8$var$AccordionCollapsibleProvider, {
143
- scope: props.__scopeAccordion,
144
- collapsible: true
145
- }, /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).createElement($0f4a20de0660bfd8$var$AccordionImpl, ($parcel$interopDefault($47SRi$babelruntimehelpersextends))({}, accordionMultipleProps, {
146
- ref: forwardedRef
147
- }))));
148
- });
149
- /* -----------------------------------------------------------------------------------------------*/ const [$0f4a20de0660bfd8$var$AccordionImplProvider, $0f4a20de0660bfd8$var$useAccordionContext] = $0f4a20de0660bfd8$var$createAccordionContext($0f4a20de0660bfd8$var$ACCORDION_NAME);
150
- const $0f4a20de0660bfd8$var$AccordionImpl = /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).forwardRef((props, forwardedRef)=>{
151
- const { __scopeAccordion: __scopeAccordion , disabled: disabled , dir: dir , orientation: orientation = 'vertical' , ...accordionProps } = props;
152
- const accordionRef = ($parcel$interopDefault($47SRi$react)).useRef(null);
153
- const composedRefs = $47SRi$radixuireactcomposerefs.useComposedRefs(accordionRef, forwardedRef);
154
- const getItems = $0f4a20de0660bfd8$var$useCollection(__scopeAccordion);
155
- const direction = $47SRi$radixuireactdirection.useDirection(dir);
156
- const isDirectionLTR = direction === 'ltr';
157
- const handleKeyDown = $47SRi$radixuiprimitive.composeEventHandlers(props.onKeyDown, (event)=>{
158
- var _triggerCollection$cl;
159
- if (!$0f4a20de0660bfd8$var$ACCORDION_KEYS.includes(event.key)) return;
143
+ onItemClose: handleItemClose,
144
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AccordionCollapsibleProvider, { scope: props.__scopeAccordion, collapsible: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AccordionImpl, { ...accordionMultipleProps, ref: forwardedRef }) })
145
+ }
146
+ );
147
+ });
148
+ var [AccordionImplProvider, useAccordionContext] = createAccordionContext(ACCORDION_NAME);
149
+ var AccordionImpl = import_react.default.forwardRef(
150
+ (props, forwardedRef) => {
151
+ const { __scopeAccordion, disabled, dir, orientation = "vertical", ...accordionProps } = props;
152
+ const accordionRef = import_react.default.useRef(null);
153
+ const composedRefs = (0, import_react_compose_refs.useComposedRefs)(accordionRef, forwardedRef);
154
+ const getItems = useCollection(__scopeAccordion);
155
+ const direction = (0, import_react_direction.useDirection)(dir);
156
+ const isDirectionLTR = direction === "ltr";
157
+ const handleKeyDown = (0, import_primitive.composeEventHandlers)(props.onKeyDown, (event) => {
158
+ if (!ACCORDION_KEYS.includes(event.key)) return;
160
159
  const target = event.target;
161
- const triggerCollection = getItems().filter((item)=>{
162
- var _item$ref$current;
163
- return !((_item$ref$current = item.ref.current) !== null && _item$ref$current !== void 0 && _item$ref$current.disabled);
164
- });
165
- const triggerIndex = triggerCollection.findIndex((item)=>item.ref.current === target
166
- );
160
+ const triggerCollection = getItems().filter((item) => !item.ref.current?.disabled);
161
+ const triggerIndex = triggerCollection.findIndex((item) => item.ref.current === target);
167
162
  const triggerCount = triggerCollection.length;
168
- if (triggerIndex === -1) return; // Prevents page scroll while user is navigating
163
+ if (triggerIndex === -1) return;
169
164
  event.preventDefault();
170
165
  let nextIndex = triggerIndex;
171
166
  const homeIndex = 0;
172
167
  const endIndex = triggerCount - 1;
173
- const moveNext = ()=>{
174
- nextIndex = triggerIndex + 1;
175
- if (nextIndex > endIndex) nextIndex = homeIndex;
168
+ const moveNext = () => {
169
+ nextIndex = triggerIndex + 1;
170
+ if (nextIndex > endIndex) {
171
+ nextIndex = homeIndex;
172
+ }
176
173
  };
177
- const movePrev = ()=>{
178
- nextIndex = triggerIndex - 1;
179
- if (nextIndex < homeIndex) nextIndex = endIndex;
174
+ const movePrev = () => {
175
+ nextIndex = triggerIndex - 1;
176
+ if (nextIndex < homeIndex) {
177
+ nextIndex = endIndex;
178
+ }
180
179
  };
181
- switch(event.key){
182
- case 'Home':
183
- nextIndex = homeIndex;
184
- break;
185
- case 'End':
186
- nextIndex = endIndex;
187
- break;
188
- case 'ArrowRight':
189
- if (orientation === 'horizontal') {
190
- if (isDirectionLTR) moveNext();
191
- else movePrev();
192
- }
193
- break;
194
- case 'ArrowDown':
195
- if (orientation === 'vertical') moveNext();
196
- break;
197
- case 'ArrowLeft':
198
- if (orientation === 'horizontal') {
199
- if (isDirectionLTR) movePrev();
200
- else moveNext();
201
- }
202
- break;
203
- case 'ArrowUp':
204
- if (orientation === 'vertical') movePrev();
205
- break;
180
+ switch (event.key) {
181
+ case "Home":
182
+ nextIndex = homeIndex;
183
+ break;
184
+ case "End":
185
+ nextIndex = endIndex;
186
+ break;
187
+ case "ArrowRight":
188
+ if (orientation === "horizontal") {
189
+ if (isDirectionLTR) {
190
+ moveNext();
191
+ } else {
192
+ movePrev();
193
+ }
194
+ }
195
+ break;
196
+ case "ArrowDown":
197
+ if (orientation === "vertical") {
198
+ moveNext();
199
+ }
200
+ break;
201
+ case "ArrowLeft":
202
+ if (orientation === "horizontal") {
203
+ if (isDirectionLTR) {
204
+ movePrev();
205
+ } else {
206
+ moveNext();
207
+ }
208
+ }
209
+ break;
210
+ case "ArrowUp":
211
+ if (orientation === "vertical") {
212
+ movePrev();
213
+ }
214
+ break;
206
215
  }
207
216
  const clampedIndex = nextIndex % triggerCount;
208
- (_triggerCollection$cl = triggerCollection[clampedIndex].ref.current) === null || _triggerCollection$cl === void 0 || _triggerCollection$cl.focus();
209
- });
210
- return /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).createElement($0f4a20de0660bfd8$var$AccordionImplProvider, {
211
- scope: __scopeAccordion,
212
- disabled: disabled,
213
- direction: dir,
214
- orientation: orientation
215
- }, /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).createElement($0f4a20de0660bfd8$var$Collection.Slot, {
216
- scope: __scopeAccordion
217
- }, /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).createElement($47SRi$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($47SRi$babelruntimehelpersextends))({}, accordionProps, {
218
- "data-orientation": orientation,
219
- ref: composedRefs,
220
- onKeyDown: disabled ? undefined : handleKeyDown
221
- }))));
222
- });
223
- /* -------------------------------------------------------------------------------------------------
224
- * AccordionItem
225
- * -----------------------------------------------------------------------------------------------*/ const $0f4a20de0660bfd8$var$ITEM_NAME = 'AccordionItem';
226
- const [$0f4a20de0660bfd8$var$AccordionItemProvider, $0f4a20de0660bfd8$var$useAccordionItemContext] = $0f4a20de0660bfd8$var$createAccordionContext($0f4a20de0660bfd8$var$ITEM_NAME);
227
- /**
228
- * `AccordionItem` contains all of the parts of a collapsible section inside of an `Accordion`.
229
- */ const $0f4a20de0660bfd8$export$d99097c13d4dac9f = /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).forwardRef((props, forwardedRef)=>{
230
- const { __scopeAccordion: __scopeAccordion , value: value , ...accordionItemProps } = props;
231
- const accordionContext = $0f4a20de0660bfd8$var$useAccordionContext($0f4a20de0660bfd8$var$ITEM_NAME, __scopeAccordion);
232
- const valueContext = $0f4a20de0660bfd8$var$useAccordionValueContext($0f4a20de0660bfd8$var$ITEM_NAME, __scopeAccordion);
233
- const collapsibleScope = $0f4a20de0660bfd8$var$useCollapsibleScope(__scopeAccordion);
234
- const triggerId = $47SRi$radixuireactid.useId();
235
- const open1 = value && valueContext.value.includes(value) || false;
236
- const disabled = accordionContext.disabled || props.disabled;
237
- return /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).createElement($0f4a20de0660bfd8$var$AccordionItemProvider, {
238
- scope: __scopeAccordion,
239
- open: open1,
240
- disabled: disabled,
241
- triggerId: triggerId
242
- }, /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).createElement($47SRi$radixuireactcollapsible.Root, ($parcel$interopDefault($47SRi$babelruntimehelpersextends))({
243
- "data-orientation": accordionContext.orientation,
244
- "data-state": $0f4a20de0660bfd8$var$getState(open1)
245
- }, collapsibleScope, accordionItemProps, {
246
- ref: forwardedRef,
247
- disabled: disabled,
248
- open: open1,
249
- onOpenChange: (open)=>{
250
- if (open) valueContext.onItemOpen(value);
251
- else valueContext.onItemClose(value);
217
+ triggerCollection[clampedIndex].ref.current?.focus();
218
+ });
219
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
220
+ AccordionImplProvider,
221
+ {
222
+ scope: __scopeAccordion,
223
+ disabled,
224
+ direction: dir,
225
+ orientation,
226
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Slot, { scope: __scopeAccordion, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
227
+ import_react_primitive.Primitive.div,
228
+ {
229
+ ...accordionProps,
230
+ "data-orientation": orientation,
231
+ ref: composedRefs,
232
+ onKeyDown: disabled ? void 0 : handleKeyDown
233
+ }
234
+ ) })
235
+ }
236
+ );
237
+ }
238
+ );
239
+ var ITEM_NAME = "AccordionItem";
240
+ var [AccordionItemProvider, useAccordionItemContext] = createAccordionContext(ITEM_NAME);
241
+ var AccordionItem = import_react.default.forwardRef(
242
+ (props, forwardedRef) => {
243
+ const { __scopeAccordion, value, ...accordionItemProps } = props;
244
+ const accordionContext = useAccordionContext(ITEM_NAME, __scopeAccordion);
245
+ const valueContext = useAccordionValueContext(ITEM_NAME, __scopeAccordion);
246
+ const collapsibleScope = useCollapsibleScope(__scopeAccordion);
247
+ const triggerId = (0, import_react_id.useId)();
248
+ const open = value && valueContext.value.includes(value) || false;
249
+ const disabled = accordionContext.disabled || props.disabled;
250
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
251
+ AccordionItemProvider,
252
+ {
253
+ scope: __scopeAccordion,
254
+ open,
255
+ disabled,
256
+ triggerId,
257
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
258
+ CollapsiblePrimitive.Root,
259
+ {
260
+ "data-orientation": accordionContext.orientation,
261
+ "data-state": getState(open),
262
+ ...collapsibleScope,
263
+ ...accordionItemProps,
264
+ ref: forwardedRef,
265
+ disabled,
266
+ open,
267
+ onOpenChange: (open2) => {
268
+ if (open2) {
269
+ valueContext.onItemOpen(value);
270
+ } else {
271
+ valueContext.onItemClose(value);
272
+ }
273
+ }
274
+ }
275
+ )
276
+ }
277
+ );
278
+ }
279
+ );
280
+ AccordionItem.displayName = ITEM_NAME;
281
+ var HEADER_NAME = "AccordionHeader";
282
+ var AccordionHeader = import_react.default.forwardRef(
283
+ (props, forwardedRef) => {
284
+ const { __scopeAccordion, ...headerProps } = props;
285
+ const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);
286
+ const itemContext = useAccordionItemContext(HEADER_NAME, __scopeAccordion);
287
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
288
+ import_react_primitive.Primitive.h3,
289
+ {
290
+ "data-orientation": accordionContext.orientation,
291
+ "data-state": getState(itemContext.open),
292
+ "data-disabled": itemContext.disabled ? "" : void 0,
293
+ ...headerProps,
294
+ ref: forwardedRef
252
295
  }
253
- })));
254
- });
255
- /*#__PURE__*/ Object.assign($0f4a20de0660bfd8$export$d99097c13d4dac9f, {
256
- displayName: $0f4a20de0660bfd8$var$ITEM_NAME
257
- });
258
- /* -------------------------------------------------------------------------------------------------
259
- * AccordionHeader
260
- * -----------------------------------------------------------------------------------------------*/ const $0f4a20de0660bfd8$var$HEADER_NAME = 'AccordionHeader';
261
- /**
262
- * `AccordionHeader` contains the content for the parts of an `AccordionItem` that will be visible
263
- * whether or not its content is collapsed.
264
- */ const $0f4a20de0660bfd8$export$5e3e5deaaf81ee41 = /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).forwardRef((props, forwardedRef)=>{
265
- const { __scopeAccordion: __scopeAccordion , ...headerProps } = props;
266
- const accordionContext = $0f4a20de0660bfd8$var$useAccordionContext($0f4a20de0660bfd8$var$ACCORDION_NAME, __scopeAccordion);
267
- const itemContext = $0f4a20de0660bfd8$var$useAccordionItemContext($0f4a20de0660bfd8$var$HEADER_NAME, __scopeAccordion);
268
- return /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).createElement($47SRi$radixuireactprimitive.Primitive.h3, ($parcel$interopDefault($47SRi$babelruntimehelpersextends))({
269
- "data-orientation": accordionContext.orientation,
270
- "data-state": $0f4a20de0660bfd8$var$getState(itemContext.open),
271
- "data-disabled": itemContext.disabled ? '' : undefined
272
- }, headerProps, {
273
- ref: forwardedRef
274
- }));
275
- });
276
- /*#__PURE__*/ Object.assign($0f4a20de0660bfd8$export$5e3e5deaaf81ee41, {
277
- displayName: $0f4a20de0660bfd8$var$HEADER_NAME
278
- });
279
- /* -------------------------------------------------------------------------------------------------
280
- * AccordionTrigger
281
- * -----------------------------------------------------------------------------------------------*/ const $0f4a20de0660bfd8$var$TRIGGER_NAME = 'AccordionTrigger';
282
- /**
283
- * `AccordionTrigger` is the trigger that toggles the collapsed state of an `AccordionItem`. It
284
- * should always be nested inside of an `AccordionHeader`.
285
- */ const $0f4a20de0660bfd8$export$94e939b1f85bdd73 = /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).forwardRef((props, forwardedRef)=>{
286
- const { __scopeAccordion: __scopeAccordion , ...triggerProps } = props;
287
- const accordionContext = $0f4a20de0660bfd8$var$useAccordionContext($0f4a20de0660bfd8$var$ACCORDION_NAME, __scopeAccordion);
288
- const itemContext = $0f4a20de0660bfd8$var$useAccordionItemContext($0f4a20de0660bfd8$var$TRIGGER_NAME, __scopeAccordion);
289
- const collapsibleContext = $0f4a20de0660bfd8$var$useAccordionCollapsibleContext($0f4a20de0660bfd8$var$TRIGGER_NAME, __scopeAccordion);
290
- const collapsibleScope = $0f4a20de0660bfd8$var$useCollapsibleScope(__scopeAccordion);
291
- return /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).createElement($0f4a20de0660bfd8$var$Collection.ItemSlot, {
292
- scope: __scopeAccordion
293
- }, /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).createElement($47SRi$radixuireactcollapsible.Trigger, ($parcel$interopDefault($47SRi$babelruntimehelpersextends))({
294
- "aria-disabled": itemContext.open && !collapsibleContext.collapsible || undefined,
295
- "data-orientation": accordionContext.orientation,
296
- id: itemContext.triggerId
297
- }, collapsibleScope, triggerProps, {
298
- ref: forwardedRef
299
- })));
300
- });
301
- /*#__PURE__*/ Object.assign($0f4a20de0660bfd8$export$94e939b1f85bdd73, {
302
- displayName: $0f4a20de0660bfd8$var$TRIGGER_NAME
303
- });
304
- /* -------------------------------------------------------------------------------------------------
305
- * AccordionContent
306
- * -----------------------------------------------------------------------------------------------*/ const $0f4a20de0660bfd8$var$CONTENT_NAME = 'AccordionContent';
307
- /**
308
- * `AccordionContent` contains the collapsible content for an `AccordionItem`.
309
- */ const $0f4a20de0660bfd8$export$985b9a77379b54a0 = /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).forwardRef((props, forwardedRef)=>{
310
- const { __scopeAccordion: __scopeAccordion , ...contentProps } = props;
311
- const accordionContext = $0f4a20de0660bfd8$var$useAccordionContext($0f4a20de0660bfd8$var$ACCORDION_NAME, __scopeAccordion);
312
- const itemContext = $0f4a20de0660bfd8$var$useAccordionItemContext($0f4a20de0660bfd8$var$CONTENT_NAME, __scopeAccordion);
313
- const collapsibleScope = $0f4a20de0660bfd8$var$useCollapsibleScope(__scopeAccordion);
314
- return /*#__PURE__*/ ($parcel$interopDefault($47SRi$react)).createElement($47SRi$radixuireactcollapsible.Content, ($parcel$interopDefault($47SRi$babelruntimehelpersextends))({
315
- role: "region",
316
- "aria-labelledby": itemContext.triggerId,
317
- "data-orientation": accordionContext.orientation
318
- }, collapsibleScope, contentProps, {
319
- ref: forwardedRef,
320
- style: {
321
- ['--radix-accordion-content-height']: 'var(--radix-collapsible-content-height)',
322
- ['--radix-accordion-content-width']: 'var(--radix-collapsible-content-width)',
296
+ );
297
+ }
298
+ );
299
+ AccordionHeader.displayName = HEADER_NAME;
300
+ var TRIGGER_NAME = "AccordionTrigger";
301
+ var AccordionTrigger = import_react.default.forwardRef(
302
+ (props, forwardedRef) => {
303
+ const { __scopeAccordion, ...triggerProps } = props;
304
+ const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);
305
+ const itemContext = useAccordionItemContext(TRIGGER_NAME, __scopeAccordion);
306
+ const collapsibleContext = useAccordionCollapsibleContext(TRIGGER_NAME, __scopeAccordion);
307
+ const collapsibleScope = useCollapsibleScope(__scopeAccordion);
308
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.ItemSlot, { scope: __scopeAccordion, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
309
+ CollapsiblePrimitive.Trigger,
310
+ {
311
+ "aria-disabled": itemContext.open && !collapsibleContext.collapsible || void 0,
312
+ "data-orientation": accordionContext.orientation,
313
+ id: itemContext.triggerId,
314
+ ...collapsibleScope,
315
+ ...triggerProps,
316
+ ref: forwardedRef
317
+ }
318
+ ) });
319
+ }
320
+ );
321
+ AccordionTrigger.displayName = TRIGGER_NAME;
322
+ var CONTENT_NAME = "AccordionContent";
323
+ var AccordionContent = import_react.default.forwardRef(
324
+ (props, forwardedRef) => {
325
+ const { __scopeAccordion, ...contentProps } = props;
326
+ const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);
327
+ const itemContext = useAccordionItemContext(CONTENT_NAME, __scopeAccordion);
328
+ const collapsibleScope = useCollapsibleScope(__scopeAccordion);
329
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
330
+ CollapsiblePrimitive.Content,
331
+ {
332
+ role: "region",
333
+ "aria-labelledby": itemContext.triggerId,
334
+ "data-orientation": accordionContext.orientation,
335
+ ...collapsibleScope,
336
+ ...contentProps,
337
+ ref: forwardedRef,
338
+ style: {
339
+ ["--radix-accordion-content-height"]: "var(--radix-collapsible-content-height)",
340
+ ["--radix-accordion-content-width"]: "var(--radix-collapsible-content-width)",
323
341
  ...props.style
342
+ }
324
343
  }
325
- }));
326
- });
327
- /*#__PURE__*/ Object.assign($0f4a20de0660bfd8$export$985b9a77379b54a0, {
328
- displayName: $0f4a20de0660bfd8$var$CONTENT_NAME
329
- });
330
- /* -----------------------------------------------------------------------------------------------*/ function $0f4a20de0660bfd8$var$getState(open) {
331
- return open ? 'open' : 'closed';
332
- }
333
- const $0f4a20de0660bfd8$export$be92b6f5f03c0fe9 = $0f4a20de0660bfd8$export$a766cd26d0d69044;
334
- const $0f4a20de0660bfd8$export$6d08773d2e66f8f2 = $0f4a20de0660bfd8$export$d99097c13d4dac9f;
335
- const $0f4a20de0660bfd8$export$8b251419efc915eb = $0f4a20de0660bfd8$export$5e3e5deaaf81ee41;
336
- const $0f4a20de0660bfd8$export$41fb9f06171c75f4 = $0f4a20de0660bfd8$export$94e939b1f85bdd73;
337
- const $0f4a20de0660bfd8$export$7c6e2c02157bb7d2 = $0f4a20de0660bfd8$export$985b9a77379b54a0;
338
-
339
-
340
-
341
-
344
+ );
345
+ }
346
+ );
347
+ AccordionContent.displayName = CONTENT_NAME;
348
+ function getState(open) {
349
+ return open ? "open" : "closed";
350
+ }
351
+ var Root2 = Accordion;
352
+ var Item = AccordionItem;
353
+ var Header = AccordionHeader;
354
+ var Trigger2 = AccordionTrigger;
355
+ var Content2 = AccordionContent;
356
+ })();
342
357
  //# sourceMappingURL=index.js.map