@radix-ui/react-accordion 1.2.17 → 1.2.18-rc.1784603841447
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +19 -10
- package/dist/index.d.ts +19 -10
- package/dist/index.js +30 -17
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +30 -17
- package/dist/index.mjs.map +3 -3
- package/package.json +10 -10
package/dist/index.d.mts
CHANGED
|
@@ -3,13 +3,27 @@ import * as React from 'react';
|
|
|
3
3
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
4
4
|
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
declare const AccordionType: {
|
|
7
|
+
readonly Single: "single";
|
|
8
|
+
readonly Multiple: "multiple";
|
|
9
|
+
};
|
|
10
|
+
type AccordionType = (typeof AccordionType)[keyof typeof AccordionType];
|
|
11
|
+
declare const Orientation: {
|
|
12
|
+
readonly Vertical: "vertical";
|
|
13
|
+
readonly Horizontal: "horizontal";
|
|
14
|
+
};
|
|
15
|
+
type Orientation = (typeof Orientation)[keyof typeof Orientation];
|
|
16
|
+
declare const Direction: {
|
|
17
|
+
readonly LTR: "ltr";
|
|
18
|
+
readonly RTL: "rtl";
|
|
19
|
+
};
|
|
20
|
+
type Direction = (typeof Direction)[keyof typeof Direction];
|
|
7
21
|
declare const createAccordionScope: _radix_ui_react_context.CreateScope;
|
|
8
22
|
interface AccordionSingleProps extends AccordionImplSingleProps {
|
|
9
|
-
type:
|
|
23
|
+
type: typeof AccordionType.Single;
|
|
10
24
|
}
|
|
11
25
|
interface AccordionMultipleProps extends AccordionImplMultipleProps {
|
|
12
|
-
type:
|
|
26
|
+
type: typeof AccordionType.Multiple;
|
|
13
27
|
}
|
|
14
28
|
declare const Accordion: React.ForwardRefExoticComponent<(AccordionSingleProps | AccordionMultipleProps) & React.RefAttributes<HTMLDivElement>>;
|
|
15
29
|
interface AccordionImplSingleProps extends AccordionImplProps {
|
|
@@ -59,7 +73,7 @@ interface AccordionImplProps extends PrimitiveDivProps {
|
|
|
59
73
|
* The layout in which the Accordion operates.
|
|
60
74
|
* @default vertical
|
|
61
75
|
*/
|
|
62
|
-
orientation?:
|
|
76
|
+
orientation?: Orientation;
|
|
63
77
|
/**
|
|
64
78
|
* The language read direction.
|
|
65
79
|
*/
|
|
@@ -105,10 +119,5 @@ interface AccordionContentProps extends CollapsibleContentProps {
|
|
|
105
119
|
* `AccordionContent` contains the collapsible content for an `AccordionItem`.
|
|
106
120
|
*/
|
|
107
121
|
declare const AccordionContent: React.ForwardRefExoticComponent<AccordionContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
108
|
-
declare const Root: React.ForwardRefExoticComponent<(AccordionSingleProps | AccordionMultipleProps) & React.RefAttributes<HTMLDivElement>>;
|
|
109
|
-
declare const Item: React.ForwardRefExoticComponent<AccordionItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
110
|
-
declare const Header: React.ForwardRefExoticComponent<AccordionHeaderProps & React.RefAttributes<HTMLHeadingElement>>;
|
|
111
|
-
declare const Trigger: React.ForwardRefExoticComponent<AccordionTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
112
|
-
declare const Content: React.ForwardRefExoticComponent<AccordionContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
113
122
|
|
|
114
|
-
export { Accordion, AccordionContent, type AccordionContentProps, AccordionHeader, type AccordionHeaderProps, AccordionItem, type AccordionItemProps, type AccordionMultipleProps, type AccordionSingleProps, AccordionTrigger, type AccordionTriggerProps, Content, Header, Item, Root, Trigger, createAccordionScope };
|
|
123
|
+
export { Accordion, AccordionContent, type AccordionContentProps, AccordionHeader, type AccordionHeaderProps, AccordionItem, type AccordionItemProps, type AccordionMultipleProps, type AccordionSingleProps, AccordionTrigger, type AccordionTriggerProps, AccordionContent as Content, AccordionHeader as Header, AccordionItem as Item, Accordion as Root, AccordionTrigger as Trigger, createAccordionScope };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,13 +3,27 @@ import * as React from 'react';
|
|
|
3
3
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
4
4
|
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
declare const AccordionType: {
|
|
7
|
+
readonly Single: "single";
|
|
8
|
+
readonly Multiple: "multiple";
|
|
9
|
+
};
|
|
10
|
+
type AccordionType = (typeof AccordionType)[keyof typeof AccordionType];
|
|
11
|
+
declare const Orientation: {
|
|
12
|
+
readonly Vertical: "vertical";
|
|
13
|
+
readonly Horizontal: "horizontal";
|
|
14
|
+
};
|
|
15
|
+
type Orientation = (typeof Orientation)[keyof typeof Orientation];
|
|
16
|
+
declare const Direction: {
|
|
17
|
+
readonly LTR: "ltr";
|
|
18
|
+
readonly RTL: "rtl";
|
|
19
|
+
};
|
|
20
|
+
type Direction = (typeof Direction)[keyof typeof Direction];
|
|
7
21
|
declare const createAccordionScope: _radix_ui_react_context.CreateScope;
|
|
8
22
|
interface AccordionSingleProps extends AccordionImplSingleProps {
|
|
9
|
-
type:
|
|
23
|
+
type: typeof AccordionType.Single;
|
|
10
24
|
}
|
|
11
25
|
interface AccordionMultipleProps extends AccordionImplMultipleProps {
|
|
12
|
-
type:
|
|
26
|
+
type: typeof AccordionType.Multiple;
|
|
13
27
|
}
|
|
14
28
|
declare const Accordion: React.ForwardRefExoticComponent<(AccordionSingleProps | AccordionMultipleProps) & React.RefAttributes<HTMLDivElement>>;
|
|
15
29
|
interface AccordionImplSingleProps extends AccordionImplProps {
|
|
@@ -59,7 +73,7 @@ interface AccordionImplProps extends PrimitiveDivProps {
|
|
|
59
73
|
* The layout in which the Accordion operates.
|
|
60
74
|
* @default vertical
|
|
61
75
|
*/
|
|
62
|
-
orientation?:
|
|
76
|
+
orientation?: Orientation;
|
|
63
77
|
/**
|
|
64
78
|
* The language read direction.
|
|
65
79
|
*/
|
|
@@ -105,10 +119,5 @@ interface AccordionContentProps extends CollapsibleContentProps {
|
|
|
105
119
|
* `AccordionContent` contains the collapsible content for an `AccordionItem`.
|
|
106
120
|
*/
|
|
107
121
|
declare const AccordionContent: React.ForwardRefExoticComponent<AccordionContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
108
|
-
declare const Root: React.ForwardRefExoticComponent<(AccordionSingleProps | AccordionMultipleProps) & React.RefAttributes<HTMLDivElement>>;
|
|
109
|
-
declare const Item: React.ForwardRefExoticComponent<AccordionItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
110
|
-
declare const Header: React.ForwardRefExoticComponent<AccordionHeaderProps & React.RefAttributes<HTMLHeadingElement>>;
|
|
111
|
-
declare const Trigger: React.ForwardRefExoticComponent<AccordionTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
112
|
-
declare const Content: React.ForwardRefExoticComponent<AccordionContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
113
122
|
|
|
114
|
-
export { Accordion, AccordionContent, type AccordionContentProps, AccordionHeader, type AccordionHeaderProps, AccordionItem, type AccordionItemProps, type AccordionMultipleProps, type AccordionSingleProps, AccordionTrigger, type AccordionTriggerProps, Content, Header, Item, Root, Trigger, createAccordionScope };
|
|
123
|
+
export { Accordion, AccordionContent, type AccordionContentProps, AccordionHeader, type AccordionHeaderProps, AccordionItem, type AccordionItemProps, type AccordionMultipleProps, type AccordionSingleProps, AccordionTrigger, type AccordionTriggerProps, AccordionContent as Content, AccordionHeader as Header, AccordionItem as Item, Accordion as Root, AccordionTrigger as Trigger, createAccordionScope };
|
package/dist/index.js
CHANGED
|
@@ -37,11 +37,11 @@ __export(index_exports, {
|
|
|
37
37
|
AccordionHeader: () => AccordionHeader,
|
|
38
38
|
AccordionItem: () => AccordionItem,
|
|
39
39
|
AccordionTrigger: () => AccordionTrigger,
|
|
40
|
-
Content: () =>
|
|
41
|
-
Header: () =>
|
|
42
|
-
Item: () =>
|
|
43
|
-
Root: () =>
|
|
44
|
-
Trigger: () =>
|
|
40
|
+
Content: () => AccordionContent,
|
|
41
|
+
Header: () => AccordionHeader,
|
|
42
|
+
Item: () => AccordionItem,
|
|
43
|
+
Root: () => Accordion,
|
|
44
|
+
Trigger: () => AccordionTrigger,
|
|
45
45
|
createAccordionScope: () => createAccordionScope
|
|
46
46
|
});
|
|
47
47
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -59,6 +59,18 @@ var import_react_collapsible = require("@radix-ui/react-collapsible");
|
|
|
59
59
|
var import_react_id = require("@radix-ui/react-id");
|
|
60
60
|
var import_react_direction = require("@radix-ui/react-direction");
|
|
61
61
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
62
|
+
var AccordionType = {
|
|
63
|
+
Single: "single",
|
|
64
|
+
Multiple: "multiple"
|
|
65
|
+
};
|
|
66
|
+
var Orientation = {
|
|
67
|
+
Vertical: "vertical",
|
|
68
|
+
Horizontal: "horizontal"
|
|
69
|
+
};
|
|
70
|
+
var Direction = {
|
|
71
|
+
LTR: "ltr",
|
|
72
|
+
RTL: "rtl"
|
|
73
|
+
};
|
|
62
74
|
var ACCORDION_NAME = "Accordion";
|
|
63
75
|
var ACCORDION_KEYS = ["Home", "End", "ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"];
|
|
64
76
|
var [Collection, useCollection, createCollectionScope] = (0, import_react_collection.createCollection)(ACCORDION_NAME);
|
|
@@ -73,7 +85,7 @@ var Accordion = /* @__PURE__ */ React.forwardRef(
|
|
|
73
85
|
const { type, ...accordionProps } = props;
|
|
74
86
|
const singleProps = accordionProps;
|
|
75
87
|
const multipleProps = accordionProps;
|
|
76
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Provider, { scope: props.__scopeAccordion, children: type ===
|
|
88
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Provider, { scope: props.__scopeAccordion, children: type === AccordionType.Multiple ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AccordionImplMultiple, { ...multipleProps, ref: forwardedRef }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AccordionImplSingle, { ...singleProps, ref: forwardedRef }) });
|
|
77
89
|
}, "Accordion")
|
|
78
90
|
);
|
|
79
91
|
var [AccordionValueProvider, useAccordionValueContext] = createAccordionContext(ACCORDION_NAME);
|
|
@@ -146,12 +158,18 @@ var AccordionImplMultiple = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __n
|
|
|
146
158
|
var [AccordionImplProvider, useAccordionContext] = createAccordionContext(ACCORDION_NAME);
|
|
147
159
|
var AccordionImpl = /* @__PURE__ */ React.forwardRef(
|
|
148
160
|
/* @__PURE__ */ __name(function AccordionImpl2(props, forwardedRef) {
|
|
149
|
-
const {
|
|
161
|
+
const {
|
|
162
|
+
__scopeAccordion,
|
|
163
|
+
disabled,
|
|
164
|
+
dir,
|
|
165
|
+
orientation = Orientation.Vertical,
|
|
166
|
+
...accordionProps
|
|
167
|
+
} = props;
|
|
150
168
|
const accordionRef = React.useRef(null);
|
|
151
169
|
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(accordionRef, forwardedRef);
|
|
152
170
|
const getItems = useCollection(__scopeAccordion);
|
|
153
171
|
const direction = (0, import_react_direction.useDirection)(dir);
|
|
154
|
-
const isDirectionLTR = direction ===
|
|
172
|
+
const isDirectionLTR = direction === Direction.LTR;
|
|
155
173
|
const handleKeyDown = (0, import_primitive.composeEventHandlers)(props.onKeyDown, (event) => {
|
|
156
174
|
if (!ACCORDION_KEYS.includes(event.key)) return;
|
|
157
175
|
const target = event.target;
|
|
@@ -183,7 +201,7 @@ var AccordionImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
183
201
|
nextIndex = endIndex;
|
|
184
202
|
break;
|
|
185
203
|
case "ArrowRight":
|
|
186
|
-
if (orientation ===
|
|
204
|
+
if (orientation === Orientation.Horizontal) {
|
|
187
205
|
if (isDirectionLTR) {
|
|
188
206
|
moveNext();
|
|
189
207
|
} else {
|
|
@@ -192,12 +210,12 @@ var AccordionImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
192
210
|
}
|
|
193
211
|
break;
|
|
194
212
|
case "ArrowDown":
|
|
195
|
-
if (orientation ===
|
|
213
|
+
if (orientation === Orientation.Vertical) {
|
|
196
214
|
moveNext();
|
|
197
215
|
}
|
|
198
216
|
break;
|
|
199
217
|
case "ArrowLeft":
|
|
200
|
-
if (orientation ===
|
|
218
|
+
if (orientation === Orientation.Horizontal) {
|
|
201
219
|
if (isDirectionLTR) {
|
|
202
220
|
movePrev();
|
|
203
221
|
} else {
|
|
@@ -206,7 +224,7 @@ var AccordionImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
206
224
|
}
|
|
207
225
|
break;
|
|
208
226
|
case "ArrowUp":
|
|
209
|
-
if (orientation ===
|
|
227
|
+
if (orientation === Orientation.Vertical) {
|
|
210
228
|
movePrev();
|
|
211
229
|
}
|
|
212
230
|
break;
|
|
@@ -346,9 +364,4 @@ function getState(open) {
|
|
|
346
364
|
return open ? "open" : "closed";
|
|
347
365
|
}
|
|
348
366
|
__name(getState, "getState");
|
|
349
|
-
var Root2 = Accordion;
|
|
350
|
-
var Item = AccordionItem;
|
|
351
|
-
var Header = AccordionHeader;
|
|
352
|
-
var Trigger2 = AccordionTrigger;
|
|
353
|
-
var Content2 = AccordionContent;
|
|
354
367
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/accordion.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client';\nexport {\n createAccordionScope,\n //\n Accordion,\n AccordionItem,\n AccordionHeader,\n AccordionTrigger,\n AccordionContent,\n //\n Root,\n Item,\n Header,\n Trigger,\n Content,\n} from './accordion';\nexport type {\n AccordionSingleProps,\n AccordionMultipleProps,\n AccordionItemProps,\n AccordionHeaderProps,\n AccordionTriggerProps,\n AccordionContentProps,\n} from './accordion';\n", "import * as React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { createCollection } from '@radix-ui/react-collection';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as CollapsiblePrimitive from '@radix-ui/react-collapsible';\nimport { createCollapsibleScope } from '@radix-ui/react-collapsible';\nimport { useId } from '@radix-ui/react-id';\n\nimport type { Scope } from '@radix-ui/react-context';\nimport { useDirection } from '@radix-ui/react-direction';\n\ntype Direction = 'ltr' | 'rtl';\n\n/* -------------------------------------------------------------------------------------------------\n * Accordion\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACCORDION_NAME = 'Accordion';\nconst ACCORDION_KEYS = ['Home', 'End', 'ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'];\n\nconst [Collection, useCollection, createCollectionScope] =\n createCollection<AccordionTriggerElement>(ACCORDION_NAME);\n\ntype ScopedProps<P> = P & { __scopeAccordion?: Scope };\nconst [createAccordionContext, createAccordionScope] = createContextScope(ACCORDION_NAME, [\n createCollectionScope,\n createCollapsibleScope,\n]);\nconst useCollapsibleScope = createCollapsibleScope();\n\ntype AccordionElement = AccordionImplMultipleElement | AccordionImplSingleElement;\ninterface AccordionSingleProps extends AccordionImplSingleProps {\n type: 'single';\n}\ninterface AccordionMultipleProps extends AccordionImplMultipleProps {\n type: 'multiple';\n}\n\nconst Accordion = /* @__PURE__ */ React.forwardRef<\n AccordionElement,\n AccordionSingleProps | AccordionMultipleProps\n>(\n // blank line to reduce diff noise\n function Accordion(\n props: ScopedProps<AccordionSingleProps | AccordionMultipleProps>,\n forwardedRef,\n ) {\n const { type, ...accordionProps } = props;\n const singleProps = accordionProps as AccordionImplSingleProps;\n const multipleProps = accordionProps as AccordionImplMultipleProps;\n return (\n <Collection.Provider scope={props.__scopeAccordion}>\n {type === 'multiple' ? (\n <AccordionImplMultiple {...multipleProps} ref={forwardedRef} />\n ) : (\n <AccordionImplSingle {...singleProps} ref={forwardedRef} />\n )}\n </Collection.Provider>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype AccordionValueContextValue = {\n value: string[];\n onItemOpen(value: string): void;\n onItemClose(value: string): void;\n};\n\nconst [AccordionValueProvider, useAccordionValueContext] =\n createAccordionContext<AccordionValueContextValue>(ACCORDION_NAME);\n\nconst [AccordionCollapsibleProvider, useAccordionCollapsibleContext] = createAccordionContext(\n ACCORDION_NAME,\n { collapsible: false },\n);\n\ntype AccordionImplSingleElement = AccordionImplElement;\ninterface AccordionImplSingleProps extends AccordionImplProps {\n /**\n * The controlled stateful value of the accordion item whose content is expanded.\n */\n value?: string;\n /**\n * The value of the item whose content is expanded when the accordion is initially rendered. Use\n * `defaultValue` if you do not need to control the state of an accordion.\n */\n defaultValue?: string;\n /**\n * The callback that fires when the state of the accordion changes.\n */\n onValueChange?(value: string): void;\n /**\n * Whether an accordion item can be collapsed after it has been opened.\n * @default false\n */\n collapsible?: boolean;\n}\n\nconst AccordionImplSingle = /* @__PURE__ */ React.forwardRef<\n AccordionImplSingleElement,\n AccordionImplSingleProps\n>(\n // blank line to reduce diff noise\n function AccordionImplSingle(props: ScopedProps<AccordionImplSingleProps>, forwardedRef) {\n const {\n value: valueProp,\n defaultValue,\n onValueChange = () => {},\n collapsible = false,\n ...accordionSingleProps\n } = props;\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue ?? '',\n onChange: onValueChange,\n caller: ACCORDION_NAME,\n });\n\n return (\n <AccordionValueProvider\n scope={props.__scopeAccordion}\n value={React.useMemo(() => (value ? [value] : []), [value])}\n onItemOpen={setValue}\n onItemClose={React.useCallback(() => collapsible && setValue(''), [collapsible, setValue])}\n >\n <AccordionCollapsibleProvider scope={props.__scopeAccordion} collapsible={collapsible}>\n <AccordionImpl {...accordionSingleProps} ref={forwardedRef} />\n </AccordionCollapsibleProvider>\n </AccordionValueProvider>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype AccordionImplMultipleElement = AccordionImplElement;\ninterface AccordionImplMultipleProps extends AccordionImplProps {\n /**\n * The controlled stateful value of the accordion items whose contents are expanded.\n */\n value?: string[];\n /**\n * The value of the items whose contents are expanded when the accordion is initially rendered. Use\n * `defaultValue` if you do not need to control the state of an accordion.\n */\n defaultValue?: string[];\n /**\n * The callback that fires when the state of the accordion changes.\n */\n onValueChange?(value: string[]): void;\n}\n\nconst AccordionImplMultiple = /* @__PURE__ */ React.forwardRef<\n AccordionImplMultipleElement,\n AccordionImplMultipleProps\n>(function AccordionImplMultiple(props: ScopedProps<AccordionImplMultipleProps>, forwardedRef) {\n const {\n value: valueProp,\n defaultValue,\n onValueChange = () => {},\n ...accordionMultipleProps\n } = props;\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue ?? [],\n onChange: onValueChange,\n caller: ACCORDION_NAME,\n });\n\n const handleItemOpen = React.useCallback(\n (itemValue: string) => setValue((prevValue = []) => [...prevValue, itemValue]),\n [setValue],\n );\n\n const handleItemClose = React.useCallback(\n (itemValue: string) =>\n setValue((prevValue = []) => prevValue.filter((value) => value !== itemValue)),\n [setValue],\n );\n\n return (\n <AccordionValueProvider\n scope={props.__scopeAccordion}\n value={value}\n onItemOpen={handleItemOpen}\n onItemClose={handleItemClose}\n >\n <AccordionCollapsibleProvider scope={props.__scopeAccordion} collapsible={true}>\n <AccordionImpl {...accordionMultipleProps} ref={forwardedRef} />\n </AccordionCollapsibleProvider>\n </AccordionValueProvider>\n );\n});\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype AccordionImplContextValue = {\n disabled?: boolean;\n direction: AccordionImplProps['dir'];\n orientation: AccordionImplProps['orientation'];\n};\n\nconst [AccordionImplProvider, useAccordionContext] =\n createAccordionContext<AccordionImplContextValue>(ACCORDION_NAME);\n\ntype AccordionImplElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface AccordionImplProps extends PrimitiveDivProps {\n /**\n * Whether or not an accordion is disabled from user interaction.\n *\n * @defaultValue false\n */\n disabled?: boolean;\n /**\n * The layout in which the Accordion operates.\n * @default vertical\n */\n orientation?: React.AriaAttributes['aria-orientation'];\n /**\n * The language read direction.\n */\n dir?: Direction;\n}\n\nconst AccordionImpl = /* @__PURE__ */ React.forwardRef<AccordionImplElement, AccordionImplProps>(\n function AccordionImpl(props: ScopedProps<AccordionImplProps>, forwardedRef) {\n const { __scopeAccordion, disabled, dir, orientation = 'vertical', ...accordionProps } = props;\n const accordionRef = React.useRef<AccordionImplElement>(null);\n const composedRefs = useComposedRefs(accordionRef, forwardedRef);\n const getItems = useCollection(__scopeAccordion);\n const direction = useDirection(dir);\n const isDirectionLTR = direction === 'ltr';\n\n const handleKeyDown = composeEventHandlers(props.onKeyDown, (event) => {\n if (!ACCORDION_KEYS.includes(event.key)) return;\n const target = event.target as HTMLElement;\n const triggerCollection = getItems().filter((item) => !item.ref.current?.disabled);\n const triggerIndex = triggerCollection.findIndex((item) => item.ref.current === target);\n const triggerCount = triggerCollection.length;\n\n if (triggerIndex === -1) return;\n\n // Prevents page scroll while user is navigating\n event.preventDefault();\n\n let nextIndex = triggerIndex;\n const homeIndex = 0;\n const endIndex = triggerCount - 1;\n\n const moveNext = () => {\n nextIndex = triggerIndex + 1;\n if (nextIndex > endIndex) {\n nextIndex = homeIndex;\n }\n };\n\n const movePrev = () => {\n nextIndex = triggerIndex - 1;\n if (nextIndex < homeIndex) {\n nextIndex = endIndex;\n }\n };\n\n switch (event.key) {\n case 'Home':\n nextIndex = homeIndex;\n break;\n case 'End':\n nextIndex = endIndex;\n break;\n case 'ArrowRight':\n if (orientation === 'horizontal') {\n if (isDirectionLTR) {\n moveNext();\n } else {\n movePrev();\n }\n }\n break;\n case 'ArrowDown':\n if (orientation === 'vertical') {\n moveNext();\n }\n break;\n case 'ArrowLeft':\n if (orientation === 'horizontal') {\n if (isDirectionLTR) {\n movePrev();\n } else {\n moveNext();\n }\n }\n break;\n case 'ArrowUp':\n if (orientation === 'vertical') {\n movePrev();\n }\n break;\n }\n\n const clampedIndex = nextIndex % triggerCount;\n triggerCollection[clampedIndex]!.ref.current?.focus();\n });\n\n return (\n <AccordionImplProvider\n scope={__scopeAccordion}\n disabled={disabled}\n direction={dir}\n orientation={orientation}\n >\n <Collection.Slot scope={__scopeAccordion}>\n <Primitive.div\n {...accordionProps}\n data-orientation={orientation}\n ref={composedRefs}\n onKeyDown={disabled ? undefined : handleKeyDown}\n />\n </Collection.Slot>\n </AccordionImplProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * AccordionItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'AccordionItem';\n\ntype AccordionItemContextValue = { open?: boolean; disabled?: boolean; triggerId: string };\nconst [AccordionItemProvider, useAccordionItemContext] =\n createAccordionContext<AccordionItemContextValue>(ITEM_NAME);\n\ntype AccordionItemElement = React.ComponentRef<typeof CollapsiblePrimitive.Root>;\ntype CollapsibleProps = React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Root>;\ninterface AccordionItemProps extends Omit<\n CollapsibleProps,\n 'open' | 'defaultOpen' | 'onOpenChange'\n> {\n /**\n * Whether or not an accordion item is disabled from user interaction.\n *\n * @defaultValue false\n */\n disabled?: boolean;\n /**\n * A string value for the accordion item. All items within an accordion should use a unique value.\n */\n value: string;\n}\n\n/**\n * `AccordionItem` contains all of the parts of a collapsible section inside of an `Accordion`.\n */\nconst AccordionItem = /* @__PURE__ */ React.forwardRef<AccordionItemElement, AccordionItemProps>(\n function AccordionItem(props: ScopedProps<AccordionItemProps>, forwardedRef) {\n const { __scopeAccordion, value, ...accordionItemProps } = props;\n const accordionContext = useAccordionContext(ITEM_NAME, __scopeAccordion);\n const valueContext = useAccordionValueContext(ITEM_NAME, __scopeAccordion);\n const collapsibleScope = useCollapsibleScope(__scopeAccordion);\n const triggerId = useId();\n const open = (value && valueContext.value.includes(value)) || false;\n const disabled = accordionContext.disabled || props.disabled;\n\n return (\n <AccordionItemProvider\n scope={__scopeAccordion}\n open={open}\n disabled={disabled}\n triggerId={triggerId}\n >\n <CollapsiblePrimitive.Root\n data-orientation={accordionContext.orientation}\n data-state={getState(open)}\n {...collapsibleScope}\n {...accordionItemProps}\n ref={forwardedRef}\n disabled={disabled}\n open={open}\n onOpenChange={(open) => {\n if (open) {\n valueContext.onItemOpen(value);\n } else {\n valueContext.onItemClose(value);\n }\n }}\n />\n </AccordionItemProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * AccordionHeader\n * -----------------------------------------------------------------------------------------------*/\n\nconst HEADER_NAME = 'AccordionHeader';\n\ntype AccordionHeaderElement = React.ComponentRef<typeof Primitive.h3>;\ntype PrimitiveHeading3Props = React.ComponentPropsWithoutRef<typeof Primitive.h3>;\ninterface AccordionHeaderProps extends PrimitiveHeading3Props {}\n\n/**\n * `AccordionHeader` contains the content for the parts of an `AccordionItem` that will be visible\n * whether or not its content is collapsed.\n */\nconst AccordionHeader = /* @__PURE__ */ React.forwardRef<\n AccordionHeaderElement,\n AccordionHeaderProps\n>(\n // blank line to reduce diff noise\n function AccordionHeader(props: ScopedProps<AccordionHeaderProps>, forwardedRef) {\n const { __scopeAccordion, ...headerProps } = props;\n const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);\n const itemContext = useAccordionItemContext(HEADER_NAME, __scopeAccordion);\n return (\n <Primitive.h3\n data-orientation={accordionContext.orientation}\n data-state={getState(itemContext.open)}\n data-disabled={itemContext.disabled ? '' : undefined}\n {...headerProps}\n ref={forwardedRef}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * AccordionTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'AccordionTrigger';\n\ntype AccordionTriggerElement = React.ComponentRef<typeof CollapsiblePrimitive.Trigger>;\ntype CollapsibleTriggerProps = React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Trigger>;\ninterface AccordionTriggerProps extends CollapsibleTriggerProps {}\n\n/**\n * `AccordionTrigger` is the trigger that toggles the collapsed state of an `AccordionItem`. It\n * should always be nested inside of an `AccordionHeader`.\n */\nconst AccordionTrigger = /* @__PURE__ */ React.forwardRef<\n AccordionTriggerElement,\n AccordionTriggerProps\n>(\n // blank line to reduce diff noise\n function AccordionTrigger(props: ScopedProps<AccordionTriggerProps>, forwardedRef) {\n const { __scopeAccordion, ...triggerProps } = props;\n const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);\n const itemContext = useAccordionItemContext(TRIGGER_NAME, __scopeAccordion);\n const collapsibleContext = useAccordionCollapsibleContext(TRIGGER_NAME, __scopeAccordion);\n const collapsibleScope = useCollapsibleScope(__scopeAccordion);\n return (\n <Collection.ItemSlot scope={__scopeAccordion}>\n <CollapsiblePrimitive.Trigger\n aria-disabled={(itemContext.open && !collapsibleContext.collapsible) || undefined}\n data-orientation={accordionContext.orientation}\n id={itemContext.triggerId}\n {...collapsibleScope}\n {...triggerProps}\n ref={forwardedRef}\n />\n </Collection.ItemSlot>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * AccordionContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'AccordionContent';\n\ntype AccordionContentElement = React.ComponentRef<typeof CollapsiblePrimitive.Content>;\ntype CollapsibleContentProps = React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Content>;\ninterface AccordionContentProps extends CollapsibleContentProps {}\n\n/**\n * `AccordionContent` contains the collapsible content for an `AccordionItem`.\n */\nconst AccordionContent = /* @__PURE__ */ React.forwardRef<\n AccordionContentElement,\n AccordionContentProps\n>(\n // blank line to reduce diff noise\n function AccordionContent(props: ScopedProps<AccordionContentProps>, forwardedRef) {\n const { __scopeAccordion, ...contentProps } = props;\n const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);\n const itemContext = useAccordionItemContext(CONTENT_NAME, __scopeAccordion);\n const collapsibleScope = useCollapsibleScope(__scopeAccordion);\n return (\n <CollapsiblePrimitive.Content\n role=\"region\"\n aria-labelledby={itemContext.triggerId}\n data-orientation={accordionContext.orientation}\n {...collapsibleScope}\n {...contentProps}\n ref={forwardedRef}\n style={{\n '--radix-accordion-content-height': 'var(--radix-collapsible-content-height)',\n '--radix-accordion-content-width': 'var(--radix-collapsible-content-width)',\n ...props.style,\n }}\n />\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open?: boolean) {\n return open ? 'open' : 'closed';\n}\n\nconst Root = Accordion;\nconst Item = AccordionItem;\nconst Header = AccordionHeader;\nconst Trigger = AccordionTrigger;\nconst Content = AccordionContent;\n\nexport {\n createAccordionScope,\n //\n Accordion,\n AccordionItem,\n AccordionHeader,\n AccordionTrigger,\n AccordionContent,\n //\n Root,\n Item,\n Header,\n Trigger,\n Content,\n};\nexport type {\n AccordionSingleProps,\n AccordionMultipleProps,\n AccordionItemProps,\n AccordionHeaderProps,\n AccordionTriggerProps,\n AccordionContentProps,\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["'use client';\nexport {\n createAccordionScope,\n //\n Accordion,\n AccordionItem,\n AccordionHeader,\n AccordionTrigger,\n AccordionContent,\n //\n Root,\n Item,\n Header,\n Trigger,\n Content,\n} from './accordion';\nexport type {\n AccordionSingleProps,\n AccordionMultipleProps,\n AccordionItemProps,\n AccordionHeaderProps,\n AccordionTriggerProps,\n AccordionContentProps,\n} from './accordion';\n", "import * as React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { createCollection } from '@radix-ui/react-collection';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as CollapsiblePrimitive from '@radix-ui/react-collapsible';\nimport { createCollapsibleScope } from '@radix-ui/react-collapsible';\nimport { useId } from '@radix-ui/react-id';\n\nimport type { Scope } from '@radix-ui/react-context';\nimport { useDirection } from '@radix-ui/react-direction';\n\nconst AccordionType = {\n Single: 'single',\n Multiple: 'multiple',\n} as const;\n\nconst Orientation = {\n Vertical: 'vertical',\n Horizontal: 'horizontal',\n} as const;\n\nconst Direction = {\n LTR: 'ltr',\n RTL: 'rtl',\n} as const;\n\ntype AccordionType = (typeof AccordionType)[keyof typeof AccordionType];\ntype Orientation = (typeof Orientation)[keyof typeof Orientation];\ntype Direction = (typeof Direction)[keyof typeof Direction];\n\n/* -------------------------------------------------------------------------------------------------\n * Accordion\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACCORDION_NAME = 'Accordion';\nconst ACCORDION_KEYS = ['Home', 'End', 'ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'];\n\nconst [Collection, useCollection, createCollectionScope] =\n createCollection<AccordionTriggerElement>(ACCORDION_NAME);\n\ntype ScopedProps<P> = P & { __scopeAccordion?: Scope };\nconst [createAccordionContext, createAccordionScope] = createContextScope(ACCORDION_NAME, [\n createCollectionScope,\n createCollapsibleScope,\n]);\nconst useCollapsibleScope = createCollapsibleScope();\n\ntype AccordionElement = AccordionImplMultipleElement | AccordionImplSingleElement;\ninterface AccordionSingleProps extends AccordionImplSingleProps {\n type: typeof AccordionType.Single;\n}\ninterface AccordionMultipleProps extends AccordionImplMultipleProps {\n type: typeof AccordionType.Multiple;\n}\n\nconst Accordion = /* @__PURE__ */ React.forwardRef<\n AccordionElement,\n AccordionSingleProps | AccordionMultipleProps\n>(\n // blank line to reduce diff noise\n function Accordion(\n props: ScopedProps<AccordionSingleProps | AccordionMultipleProps>,\n forwardedRef,\n ) {\n const { type, ...accordionProps } = props;\n const singleProps = accordionProps as AccordionImplSingleProps;\n const multipleProps = accordionProps as AccordionImplMultipleProps;\n return (\n <Collection.Provider scope={props.__scopeAccordion}>\n {type === AccordionType.Multiple ? (\n <AccordionImplMultiple {...multipleProps} ref={forwardedRef} />\n ) : (\n <AccordionImplSingle {...singleProps} ref={forwardedRef} />\n )}\n </Collection.Provider>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype AccordionValueContextValue = {\n value: string[];\n onItemOpen(value: string): void;\n onItemClose(value: string): void;\n};\n\nconst [AccordionValueProvider, useAccordionValueContext] =\n createAccordionContext<AccordionValueContextValue>(ACCORDION_NAME);\n\nconst [AccordionCollapsibleProvider, useAccordionCollapsibleContext] = createAccordionContext(\n ACCORDION_NAME,\n { collapsible: false },\n);\n\ntype AccordionImplSingleElement = AccordionImplElement;\ninterface AccordionImplSingleProps extends AccordionImplProps {\n /**\n * The controlled stateful value of the accordion item whose content is expanded.\n */\n value?: string;\n /**\n * The value of the item whose content is expanded when the accordion is initially rendered. Use\n * `defaultValue` if you do not need to control the state of an accordion.\n */\n defaultValue?: string;\n /**\n * The callback that fires when the state of the accordion changes.\n */\n onValueChange?(value: string): void;\n /**\n * Whether an accordion item can be collapsed after it has been opened.\n * @default false\n */\n collapsible?: boolean;\n}\n\nconst AccordionImplSingle = /* @__PURE__ */ React.forwardRef<\n AccordionImplSingleElement,\n AccordionImplSingleProps\n>(\n // blank line to reduce diff noise\n function AccordionImplSingle(props: ScopedProps<AccordionImplSingleProps>, forwardedRef) {\n const {\n value: valueProp,\n defaultValue,\n onValueChange = () => {},\n collapsible = false,\n ...accordionSingleProps\n } = props;\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue ?? '',\n onChange: onValueChange,\n caller: ACCORDION_NAME,\n });\n\n return (\n <AccordionValueProvider\n scope={props.__scopeAccordion}\n value={React.useMemo(() => (value ? [value] : []), [value])}\n onItemOpen={setValue}\n onItemClose={React.useCallback(() => collapsible && setValue(''), [collapsible, setValue])}\n >\n <AccordionCollapsibleProvider scope={props.__scopeAccordion} collapsible={collapsible}>\n <AccordionImpl {...accordionSingleProps} ref={forwardedRef} />\n </AccordionCollapsibleProvider>\n </AccordionValueProvider>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype AccordionImplMultipleElement = AccordionImplElement;\ninterface AccordionImplMultipleProps extends AccordionImplProps {\n /**\n * The controlled stateful value of the accordion items whose contents are expanded.\n */\n value?: string[];\n /**\n * The value of the items whose contents are expanded when the accordion is initially rendered. Use\n * `defaultValue` if you do not need to control the state of an accordion.\n */\n defaultValue?: string[];\n /**\n * The callback that fires when the state of the accordion changes.\n */\n onValueChange?(value: string[]): void;\n}\n\nconst AccordionImplMultiple = /* @__PURE__ */ React.forwardRef<\n AccordionImplMultipleElement,\n AccordionImplMultipleProps\n>(function AccordionImplMultiple(props: ScopedProps<AccordionImplMultipleProps>, forwardedRef) {\n const {\n value: valueProp,\n defaultValue,\n onValueChange = () => {},\n ...accordionMultipleProps\n } = props;\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue ?? [],\n onChange: onValueChange,\n caller: ACCORDION_NAME,\n });\n\n const handleItemOpen = React.useCallback(\n (itemValue: string) => setValue((prevValue = []) => [...prevValue, itemValue]),\n [setValue],\n );\n\n const handleItemClose = React.useCallback(\n (itemValue: string) =>\n setValue((prevValue = []) => prevValue.filter((value) => value !== itemValue)),\n [setValue],\n );\n\n return (\n <AccordionValueProvider\n scope={props.__scopeAccordion}\n value={value}\n onItemOpen={handleItemOpen}\n onItemClose={handleItemClose}\n >\n <AccordionCollapsibleProvider scope={props.__scopeAccordion} collapsible={true}>\n <AccordionImpl {...accordionMultipleProps} ref={forwardedRef} />\n </AccordionCollapsibleProvider>\n </AccordionValueProvider>\n );\n});\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype AccordionImplContextValue = {\n disabled?: boolean;\n direction: AccordionImplProps['dir'];\n orientation: AccordionImplProps['orientation'];\n};\n\nconst [AccordionImplProvider, useAccordionContext] =\n createAccordionContext<AccordionImplContextValue>(ACCORDION_NAME);\n\ntype AccordionImplElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface AccordionImplProps extends PrimitiveDivProps {\n /**\n * Whether or not an accordion is disabled from user interaction.\n *\n * @defaultValue false\n */\n disabled?: boolean;\n /**\n * The layout in which the Accordion operates.\n * @default vertical\n */\n orientation?: Orientation;\n /**\n * The language read direction.\n */\n dir?: Direction;\n}\n\nconst AccordionImpl = /* @__PURE__ */ React.forwardRef<AccordionImplElement, AccordionImplProps>(\n function AccordionImpl(props: ScopedProps<AccordionImplProps>, forwardedRef) {\n const {\n __scopeAccordion,\n disabled,\n dir,\n orientation = Orientation.Vertical,\n ...accordionProps\n } = props;\n const accordionRef = React.useRef<AccordionImplElement>(null);\n const composedRefs = useComposedRefs(accordionRef, forwardedRef);\n const getItems = useCollection(__scopeAccordion);\n const direction = useDirection(dir);\n const isDirectionLTR = direction === Direction.LTR;\n\n const handleKeyDown = composeEventHandlers(props.onKeyDown, (event) => {\n if (!ACCORDION_KEYS.includes(event.key)) return;\n const target = event.target as HTMLElement;\n const triggerCollection = getItems().filter((item) => !item.ref.current?.disabled);\n const triggerIndex = triggerCollection.findIndex((item) => item.ref.current === target);\n const triggerCount = triggerCollection.length;\n\n if (triggerIndex === -1) return;\n\n // Prevents page scroll while user is navigating\n event.preventDefault();\n\n let nextIndex = triggerIndex;\n const homeIndex = 0;\n const endIndex = triggerCount - 1;\n\n const moveNext = () => {\n nextIndex = triggerIndex + 1;\n if (nextIndex > endIndex) {\n nextIndex = homeIndex;\n }\n };\n\n const movePrev = () => {\n nextIndex = triggerIndex - 1;\n if (nextIndex < homeIndex) {\n nextIndex = endIndex;\n }\n };\n\n switch (event.key) {\n case 'Home':\n nextIndex = homeIndex;\n break;\n case 'End':\n nextIndex = endIndex;\n break;\n case 'ArrowRight':\n if (orientation === Orientation.Horizontal) {\n if (isDirectionLTR) {\n moveNext();\n } else {\n movePrev();\n }\n }\n break;\n case 'ArrowDown':\n if (orientation === Orientation.Vertical) {\n moveNext();\n }\n break;\n case 'ArrowLeft':\n if (orientation === Orientation.Horizontal) {\n if (isDirectionLTR) {\n movePrev();\n } else {\n moveNext();\n }\n }\n break;\n case 'ArrowUp':\n if (orientation === Orientation.Vertical) {\n movePrev();\n }\n break;\n }\n\n const clampedIndex = nextIndex % triggerCount;\n triggerCollection[clampedIndex]!.ref.current?.focus();\n });\n\n return (\n <AccordionImplProvider\n scope={__scopeAccordion}\n disabled={disabled}\n direction={dir}\n orientation={orientation}\n >\n <Collection.Slot scope={__scopeAccordion}>\n <Primitive.div\n {...accordionProps}\n data-orientation={orientation}\n ref={composedRefs}\n onKeyDown={disabled ? undefined : handleKeyDown}\n />\n </Collection.Slot>\n </AccordionImplProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * AccordionItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'AccordionItem';\n\ntype AccordionItemContextValue = { open?: boolean; disabled?: boolean; triggerId: string };\nconst [AccordionItemProvider, useAccordionItemContext] =\n createAccordionContext<AccordionItemContextValue>(ITEM_NAME);\n\ntype AccordionItemElement = React.ComponentRef<typeof CollapsiblePrimitive.Root>;\ntype CollapsibleProps = React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Root>;\ninterface AccordionItemProps extends Omit<\n CollapsibleProps,\n 'open' | 'defaultOpen' | 'onOpenChange'\n> {\n /**\n * Whether or not an accordion item is disabled from user interaction.\n *\n * @defaultValue false\n */\n disabled?: boolean;\n /**\n * A string value for the accordion item. All items within an accordion should use a unique value.\n */\n value: string;\n}\n\n/**\n * `AccordionItem` contains all of the parts of a collapsible section inside of an `Accordion`.\n */\nconst AccordionItem = /* @__PURE__ */ React.forwardRef<AccordionItemElement, AccordionItemProps>(\n function AccordionItem(props: ScopedProps<AccordionItemProps>, forwardedRef) {\n const { __scopeAccordion, value, ...accordionItemProps } = props;\n const accordionContext = useAccordionContext(ITEM_NAME, __scopeAccordion);\n const valueContext = useAccordionValueContext(ITEM_NAME, __scopeAccordion);\n const collapsibleScope = useCollapsibleScope(__scopeAccordion);\n const triggerId = useId();\n const open = (value && valueContext.value.includes(value)) || false;\n const disabled = accordionContext.disabled || props.disabled;\n\n return (\n <AccordionItemProvider\n scope={__scopeAccordion}\n open={open}\n disabled={disabled}\n triggerId={triggerId}\n >\n <CollapsiblePrimitive.Root\n data-orientation={accordionContext.orientation}\n data-state={getState(open)}\n {...collapsibleScope}\n {...accordionItemProps}\n ref={forwardedRef}\n disabled={disabled}\n open={open}\n onOpenChange={(open) => {\n if (open) {\n valueContext.onItemOpen(value);\n } else {\n valueContext.onItemClose(value);\n }\n }}\n />\n </AccordionItemProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * AccordionHeader\n * -----------------------------------------------------------------------------------------------*/\n\nconst HEADER_NAME = 'AccordionHeader';\n\ntype AccordionHeaderElement = React.ComponentRef<typeof Primitive.h3>;\ntype PrimitiveHeading3Props = React.ComponentPropsWithoutRef<typeof Primitive.h3>;\ninterface AccordionHeaderProps extends PrimitiveHeading3Props {}\n\n/**\n * `AccordionHeader` contains the content for the parts of an `AccordionItem` that will be visible\n * whether or not its content is collapsed.\n */\nconst AccordionHeader = /* @__PURE__ */ React.forwardRef<\n AccordionHeaderElement,\n AccordionHeaderProps\n>(\n // blank line to reduce diff noise\n function AccordionHeader(props: ScopedProps<AccordionHeaderProps>, forwardedRef) {\n const { __scopeAccordion, ...headerProps } = props;\n const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);\n const itemContext = useAccordionItemContext(HEADER_NAME, __scopeAccordion);\n return (\n <Primitive.h3\n data-orientation={accordionContext.orientation}\n data-state={getState(itemContext.open)}\n data-disabled={itemContext.disabled ? '' : undefined}\n {...headerProps}\n ref={forwardedRef}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * AccordionTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'AccordionTrigger';\n\ntype AccordionTriggerElement = React.ComponentRef<typeof CollapsiblePrimitive.Trigger>;\ntype CollapsibleTriggerProps = React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Trigger>;\ninterface AccordionTriggerProps extends CollapsibleTriggerProps {}\n\n/**\n * `AccordionTrigger` is the trigger that toggles the collapsed state of an `AccordionItem`. It\n * should always be nested inside of an `AccordionHeader`.\n */\nconst AccordionTrigger = /* @__PURE__ */ React.forwardRef<\n AccordionTriggerElement,\n AccordionTriggerProps\n>(\n // blank line to reduce diff noise\n function AccordionTrigger(props: ScopedProps<AccordionTriggerProps>, forwardedRef) {\n const { __scopeAccordion, ...triggerProps } = props;\n const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);\n const itemContext = useAccordionItemContext(TRIGGER_NAME, __scopeAccordion);\n const collapsibleContext = useAccordionCollapsibleContext(TRIGGER_NAME, __scopeAccordion);\n const collapsibleScope = useCollapsibleScope(__scopeAccordion);\n return (\n <Collection.ItemSlot scope={__scopeAccordion}>\n <CollapsiblePrimitive.Trigger\n aria-disabled={(itemContext.open && !collapsibleContext.collapsible) || undefined}\n data-orientation={accordionContext.orientation}\n id={itemContext.triggerId}\n {...collapsibleScope}\n {...triggerProps}\n ref={forwardedRef}\n />\n </Collection.ItemSlot>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * AccordionContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'AccordionContent';\n\ntype AccordionContentElement = React.ComponentRef<typeof CollapsiblePrimitive.Content>;\ntype CollapsibleContentProps = React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Content>;\ninterface AccordionContentProps extends CollapsibleContentProps {}\n\n/**\n * `AccordionContent` contains the collapsible content for an `AccordionItem`.\n */\nconst AccordionContent = /* @__PURE__ */ React.forwardRef<\n AccordionContentElement,\n AccordionContentProps\n>(\n // blank line to reduce diff noise\n function AccordionContent(props: ScopedProps<AccordionContentProps>, forwardedRef) {\n const { __scopeAccordion, ...contentProps } = props;\n const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);\n const itemContext = useAccordionItemContext(CONTENT_NAME, __scopeAccordion);\n const collapsibleScope = useCollapsibleScope(__scopeAccordion);\n return (\n <CollapsiblePrimitive.Content\n role=\"region\"\n aria-labelledby={itemContext.triggerId}\n data-orientation={accordionContext.orientation}\n {...collapsibleScope}\n {...contentProps}\n ref={forwardedRef}\n style={{\n '--radix-accordion-content-height': 'var(--radix-collapsible-content-height)',\n '--radix-accordion-content-width': 'var(--radix-collapsible-content-width)',\n ...props.style,\n }}\n />\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open?: boolean) {\n return open ? 'open' : 'closed';\n}\n\nexport {\n createAccordionScope,\n //\n Accordion,\n AccordionItem,\n AccordionHeader,\n AccordionTrigger,\n AccordionContent,\n //\n Accordion as Root,\n AccordionItem as Item,\n AccordionHeader as Header,\n AccordionTrigger as Trigger,\n AccordionContent as Content,\n};\nexport type {\n AccordionSingleProps,\n AccordionMultipleProps,\n AccordionItemProps,\n AccordionHeaderProps,\n AccordionTriggerProps,\n AccordionContentProps,\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,2BAAmC;AACnC,8BAAiC;AACjC,gCAAgC;AAChC,uBAAqC;AACrC,0CAAqC;AACrC,6BAA0B;AAC1B,2BAAsC;AACtC,+BAAuC;AACvC,sBAAsB;AAGtB,6BAA6B;AA6DnB;AA3DV,IAAM,gBAAgB;AAAA,EACpB,QAAQ;AAAA,EACR,UAAU;AACZ;AAEA,IAAM,cAAc;AAAA,EAClB,UAAU;AAAA,EACV,YAAY;AACd;AAEA,IAAM,YAAY;AAAA,EAChB,KAA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CAAC,mBAAmB,eAAgB;AAAA,QACxE,oBAAkB,iBAAiB;AAAA,QACnC,IAAI,YAAY;AAAA,QACf,GAAG;AAAA,QACH,GAAG;AAAA,QACJ,KAAK;AAAA;AAAA,IACP,GACF;AAAA,EAEJ,GAlBA;AAmBF;AAMA,IAAM,eAAe;AASrB,IAAM,mBAAmC,gBAAM;AAAA;AAAA,EAK7C,gCAASC,kBAAiB,OAA2C,cAAc;AACjF,UAAM,EAAE,kBAAkB,GAAG,aAAa,IAAI;AAC9C,UAAM,mBAAmB,oBAAoB,gBAAgB,gBAAgB;AAC7E,UAAM,cAAc,wBAAwB,cAAc,gBAAgB;AAC1E,UAAM,mBAAmB,oBAAoB,gBAAgB;AAC7D,WACE;AAAA,MAAsB;AAAA,MAArB;AAAA,QACC,MAAK;AAAA,QACL,mBAAiB,YAAY;AAAA,QAC7B,oBAAkB,iBAAiB;AAAA,QAClC,GAAG;AAAA,QACH,GAAG;AAAA,QACJ,KAAK;AAAA,QACL,OAAO;AAAA,UACL,oCAAoC;AAAA,UACpC,mCAAmC;AAAA,UACnC,GAAG,MAAM;AAAA,QACX;AAAA;AAAA,IACF;AAAA,EAEJ,GApBA;AAqBF;AAIA,SAAS,SAAS,MAAgB;AAChC,SAAO,OAAO,SAAS;AACzB;AAFS;",
|
|
6
|
+
"names": ["Accordion", "AccordionImplSingle", "AccordionImplMultiple", "value", "AccordionImpl", "AccordionItem", "open", "AccordionHeader", "AccordionTrigger", "AccordionContent"]
|
|
7
7
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -15,6 +15,18 @@ import { createCollapsibleScope } from "@radix-ui/react-collapsible";
|
|
|
15
15
|
import { useId } from "@radix-ui/react-id";
|
|
16
16
|
import { useDirection } from "@radix-ui/react-direction";
|
|
17
17
|
import { jsx } from "react/jsx-runtime";
|
|
18
|
+
var AccordionType = {
|
|
19
|
+
Single: "single",
|
|
20
|
+
Multiple: "multiple"
|
|
21
|
+
};
|
|
22
|
+
var Orientation = {
|
|
23
|
+
Vertical: "vertical",
|
|
24
|
+
Horizontal: "horizontal"
|
|
25
|
+
};
|
|
26
|
+
var Direction = {
|
|
27
|
+
LTR: "ltr",
|
|
28
|
+
RTL: "rtl"
|
|
29
|
+
};
|
|
18
30
|
var ACCORDION_NAME = "Accordion";
|
|
19
31
|
var ACCORDION_KEYS = ["Home", "End", "ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"];
|
|
20
32
|
var [Collection, useCollection, createCollectionScope] = createCollection(ACCORDION_NAME);
|
|
@@ -29,7 +41,7 @@ var Accordion = /* @__PURE__ */ React.forwardRef(
|
|
|
29
41
|
const { type, ...accordionProps } = props;
|
|
30
42
|
const singleProps = accordionProps;
|
|
31
43
|
const multipleProps = accordionProps;
|
|
32
|
-
return /* @__PURE__ */ jsx(Collection.Provider, { scope: props.__scopeAccordion, children: type ===
|
|
44
|
+
return /* @__PURE__ */ jsx(Collection.Provider, { scope: props.__scopeAccordion, children: type === AccordionType.Multiple ? /* @__PURE__ */ jsx(AccordionImplMultiple, { ...multipleProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(AccordionImplSingle, { ...singleProps, ref: forwardedRef }) });
|
|
33
45
|
}, "Accordion")
|
|
34
46
|
);
|
|
35
47
|
var [AccordionValueProvider, useAccordionValueContext] = createAccordionContext(ACCORDION_NAME);
|
|
@@ -102,12 +114,18 @@ var AccordionImplMultiple = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __n
|
|
|
102
114
|
var [AccordionImplProvider, useAccordionContext] = createAccordionContext(ACCORDION_NAME);
|
|
103
115
|
var AccordionImpl = /* @__PURE__ */ React.forwardRef(
|
|
104
116
|
/* @__PURE__ */ __name(function AccordionImpl2(props, forwardedRef) {
|
|
105
|
-
const {
|
|
117
|
+
const {
|
|
118
|
+
__scopeAccordion,
|
|
119
|
+
disabled,
|
|
120
|
+
dir,
|
|
121
|
+
orientation = Orientation.Vertical,
|
|
122
|
+
...accordionProps
|
|
123
|
+
} = props;
|
|
106
124
|
const accordionRef = React.useRef(null);
|
|
107
125
|
const composedRefs = useComposedRefs(accordionRef, forwardedRef);
|
|
108
126
|
const getItems = useCollection(__scopeAccordion);
|
|
109
127
|
const direction = useDirection(dir);
|
|
110
|
-
const isDirectionLTR = direction ===
|
|
128
|
+
const isDirectionLTR = direction === Direction.LTR;
|
|
111
129
|
const handleKeyDown = composeEventHandlers(props.onKeyDown, (event) => {
|
|
112
130
|
if (!ACCORDION_KEYS.includes(event.key)) return;
|
|
113
131
|
const target = event.target;
|
|
@@ -139,7 +157,7 @@ var AccordionImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
139
157
|
nextIndex = endIndex;
|
|
140
158
|
break;
|
|
141
159
|
case "ArrowRight":
|
|
142
|
-
if (orientation ===
|
|
160
|
+
if (orientation === Orientation.Horizontal) {
|
|
143
161
|
if (isDirectionLTR) {
|
|
144
162
|
moveNext();
|
|
145
163
|
} else {
|
|
@@ -148,12 +166,12 @@ var AccordionImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
148
166
|
}
|
|
149
167
|
break;
|
|
150
168
|
case "ArrowDown":
|
|
151
|
-
if (orientation ===
|
|
169
|
+
if (orientation === Orientation.Vertical) {
|
|
152
170
|
moveNext();
|
|
153
171
|
}
|
|
154
172
|
break;
|
|
155
173
|
case "ArrowLeft":
|
|
156
|
-
if (orientation ===
|
|
174
|
+
if (orientation === Orientation.Horizontal) {
|
|
157
175
|
if (isDirectionLTR) {
|
|
158
176
|
movePrev();
|
|
159
177
|
} else {
|
|
@@ -162,7 +180,7 @@ var AccordionImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
162
180
|
}
|
|
163
181
|
break;
|
|
164
182
|
case "ArrowUp":
|
|
165
|
-
if (orientation ===
|
|
183
|
+
if (orientation === Orientation.Vertical) {
|
|
166
184
|
movePrev();
|
|
167
185
|
}
|
|
168
186
|
break;
|
|
@@ -302,22 +320,17 @@ function getState(open) {
|
|
|
302
320
|
return open ? "open" : "closed";
|
|
303
321
|
}
|
|
304
322
|
__name(getState, "getState");
|
|
305
|
-
var Root2 = Accordion;
|
|
306
|
-
var Item = AccordionItem;
|
|
307
|
-
var Header = AccordionHeader;
|
|
308
|
-
var Trigger2 = AccordionTrigger;
|
|
309
|
-
var Content2 = AccordionContent;
|
|
310
323
|
export {
|
|
311
324
|
Accordion,
|
|
312
325
|
AccordionContent,
|
|
313
326
|
AccordionHeader,
|
|
314
327
|
AccordionItem,
|
|
315
328
|
AccordionTrigger,
|
|
316
|
-
|
|
317
|
-
Header,
|
|
318
|
-
Item,
|
|
319
|
-
|
|
320
|
-
|
|
329
|
+
AccordionContent as Content,
|
|
330
|
+
AccordionHeader as Header,
|
|
331
|
+
AccordionItem as Item,
|
|
332
|
+
Accordion as Root,
|
|
333
|
+
AccordionTrigger as Trigger,
|
|
321
334
|
createAccordionScope
|
|
322
335
|
};
|
|
323
336
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/accordion.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { createCollection } from '@radix-ui/react-collection';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as CollapsiblePrimitive from '@radix-ui/react-collapsible';\nimport { createCollapsibleScope } from '@radix-ui/react-collapsible';\nimport { useId } from '@radix-ui/react-id';\n\nimport type { Scope } from '@radix-ui/react-context';\nimport { useDirection } from '@radix-ui/react-direction';\n\ntype Direction = 'ltr' | 'rtl';\n\n/* -------------------------------------------------------------------------------------------------\n * Accordion\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACCORDION_NAME = 'Accordion';\nconst ACCORDION_KEYS = ['Home', 'End', 'ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'];\n\nconst [Collection, useCollection, createCollectionScope] =\n createCollection<AccordionTriggerElement>(ACCORDION_NAME);\n\ntype ScopedProps<P> = P & { __scopeAccordion?: Scope };\nconst [createAccordionContext, createAccordionScope] = createContextScope(ACCORDION_NAME, [\n createCollectionScope,\n createCollapsibleScope,\n]);\nconst useCollapsibleScope = createCollapsibleScope();\n\ntype AccordionElement = AccordionImplMultipleElement | AccordionImplSingleElement;\ninterface AccordionSingleProps extends AccordionImplSingleProps {\n type: 'single';\n}\ninterface AccordionMultipleProps extends AccordionImplMultipleProps {\n type: 'multiple';\n}\n\nconst Accordion = /* @__PURE__ */ React.forwardRef<\n AccordionElement,\n AccordionSingleProps | AccordionMultipleProps\n>(\n // blank line to reduce diff noise\n function Accordion(\n props: ScopedProps<AccordionSingleProps | AccordionMultipleProps>,\n forwardedRef,\n ) {\n const { type, ...accordionProps } = props;\n const singleProps = accordionProps as AccordionImplSingleProps;\n const multipleProps = accordionProps as AccordionImplMultipleProps;\n return (\n <Collection.Provider scope={props.__scopeAccordion}>\n {type === 'multiple' ? (\n <AccordionImplMultiple {...multipleProps} ref={forwardedRef} />\n ) : (\n <AccordionImplSingle {...singleProps} ref={forwardedRef} />\n )}\n </Collection.Provider>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype AccordionValueContextValue = {\n value: string[];\n onItemOpen(value: string): void;\n onItemClose(value: string): void;\n};\n\nconst [AccordionValueProvider, useAccordionValueContext] =\n createAccordionContext<AccordionValueContextValue>(ACCORDION_NAME);\n\nconst [AccordionCollapsibleProvider, useAccordionCollapsibleContext] = createAccordionContext(\n ACCORDION_NAME,\n { collapsible: false },\n);\n\ntype AccordionImplSingleElement = AccordionImplElement;\ninterface AccordionImplSingleProps extends AccordionImplProps {\n /**\n * The controlled stateful value of the accordion item whose content is expanded.\n */\n value?: string;\n /**\n * The value of the item whose content is expanded when the accordion is initially rendered. Use\n * `defaultValue` if you do not need to control the state of an accordion.\n */\n defaultValue?: string;\n /**\n * The callback that fires when the state of the accordion changes.\n */\n onValueChange?(value: string): void;\n /**\n * Whether an accordion item can be collapsed after it has been opened.\n * @default false\n */\n collapsible?: boolean;\n}\n\nconst AccordionImplSingle = /* @__PURE__ */ React.forwardRef<\n AccordionImplSingleElement,\n AccordionImplSingleProps\n>(\n // blank line to reduce diff noise\n function AccordionImplSingle(props: ScopedProps<AccordionImplSingleProps>, forwardedRef) {\n const {\n value: valueProp,\n defaultValue,\n onValueChange = () => {},\n collapsible = false,\n ...accordionSingleProps\n } = props;\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue ?? '',\n onChange: onValueChange,\n caller: ACCORDION_NAME,\n });\n\n return (\n <AccordionValueProvider\n scope={props.__scopeAccordion}\n value={React.useMemo(() => (value ? [value] : []), [value])}\n onItemOpen={setValue}\n onItemClose={React.useCallback(() => collapsible && setValue(''), [collapsible, setValue])}\n >\n <AccordionCollapsibleProvider scope={props.__scopeAccordion} collapsible={collapsible}>\n <AccordionImpl {...accordionSingleProps} ref={forwardedRef} />\n </AccordionCollapsibleProvider>\n </AccordionValueProvider>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype AccordionImplMultipleElement = AccordionImplElement;\ninterface AccordionImplMultipleProps extends AccordionImplProps {\n /**\n * The controlled stateful value of the accordion items whose contents are expanded.\n */\n value?: string[];\n /**\n * The value of the items whose contents are expanded when the accordion is initially rendered. Use\n * `defaultValue` if you do not need to control the state of an accordion.\n */\n defaultValue?: string[];\n /**\n * The callback that fires when the state of the accordion changes.\n */\n onValueChange?(value: string[]): void;\n}\n\nconst AccordionImplMultiple = /* @__PURE__ */ React.forwardRef<\n AccordionImplMultipleElement,\n AccordionImplMultipleProps\n>(function AccordionImplMultiple(props: ScopedProps<AccordionImplMultipleProps>, forwardedRef) {\n const {\n value: valueProp,\n defaultValue,\n onValueChange = () => {},\n ...accordionMultipleProps\n } = props;\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue ?? [],\n onChange: onValueChange,\n caller: ACCORDION_NAME,\n });\n\n const handleItemOpen = React.useCallback(\n (itemValue: string) => setValue((prevValue = []) => [...prevValue, itemValue]),\n [setValue],\n );\n\n const handleItemClose = React.useCallback(\n (itemValue: string) =>\n setValue((prevValue = []) => prevValue.filter((value) => value !== itemValue)),\n [setValue],\n );\n\n return (\n <AccordionValueProvider\n scope={props.__scopeAccordion}\n value={value}\n onItemOpen={handleItemOpen}\n onItemClose={handleItemClose}\n >\n <AccordionCollapsibleProvider scope={props.__scopeAccordion} collapsible={true}>\n <AccordionImpl {...accordionMultipleProps} ref={forwardedRef} />\n </AccordionCollapsibleProvider>\n </AccordionValueProvider>\n );\n});\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype AccordionImplContextValue = {\n disabled?: boolean;\n direction: AccordionImplProps['dir'];\n orientation: AccordionImplProps['orientation'];\n};\n\nconst [AccordionImplProvider, useAccordionContext] =\n createAccordionContext<AccordionImplContextValue>(ACCORDION_NAME);\n\ntype AccordionImplElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface AccordionImplProps extends PrimitiveDivProps {\n /**\n * Whether or not an accordion is disabled from user interaction.\n *\n * @defaultValue false\n */\n disabled?: boolean;\n /**\n * The layout in which the Accordion operates.\n * @default vertical\n */\n orientation?: React.AriaAttributes['aria-orientation'];\n /**\n * The language read direction.\n */\n dir?: Direction;\n}\n\nconst AccordionImpl = /* @__PURE__ */ React.forwardRef<AccordionImplElement, AccordionImplProps>(\n function AccordionImpl(props: ScopedProps<AccordionImplProps>, forwardedRef) {\n const { __scopeAccordion, disabled, dir, orientation = 'vertical', ...accordionProps } = props;\n const accordionRef = React.useRef<AccordionImplElement>(null);\n const composedRefs = useComposedRefs(accordionRef, forwardedRef);\n const getItems = useCollection(__scopeAccordion);\n const direction = useDirection(dir);\n const isDirectionLTR = direction === 'ltr';\n\n const handleKeyDown = composeEventHandlers(props.onKeyDown, (event) => {\n if (!ACCORDION_KEYS.includes(event.key)) return;\n const target = event.target as HTMLElement;\n const triggerCollection = getItems().filter((item) => !item.ref.current?.disabled);\n const triggerIndex = triggerCollection.findIndex((item) => item.ref.current === target);\n const triggerCount = triggerCollection.length;\n\n if (triggerIndex === -1) return;\n\n // Prevents page scroll while user is navigating\n event.preventDefault();\n\n let nextIndex = triggerIndex;\n const homeIndex = 0;\n const endIndex = triggerCount - 1;\n\n const moveNext = () => {\n nextIndex = triggerIndex + 1;\n if (nextIndex > endIndex) {\n nextIndex = homeIndex;\n }\n };\n\n const movePrev = () => {\n nextIndex = triggerIndex - 1;\n if (nextIndex < homeIndex) {\n nextIndex = endIndex;\n }\n };\n\n switch (event.key) {\n case 'Home':\n nextIndex = homeIndex;\n break;\n case 'End':\n nextIndex = endIndex;\n break;\n case 'ArrowRight':\n if (orientation === 'horizontal') {\n if (isDirectionLTR) {\n moveNext();\n } else {\n movePrev();\n }\n }\n break;\n case 'ArrowDown':\n if (orientation === 'vertical') {\n moveNext();\n }\n break;\n case 'ArrowLeft':\n if (orientation === 'horizontal') {\n if (isDirectionLTR) {\n movePrev();\n } else {\n moveNext();\n }\n }\n break;\n case 'ArrowUp':\n if (orientation === 'vertical') {\n movePrev();\n }\n break;\n }\n\n const clampedIndex = nextIndex % triggerCount;\n triggerCollection[clampedIndex]!.ref.current?.focus();\n });\n\n return (\n <AccordionImplProvider\n scope={__scopeAccordion}\n disabled={disabled}\n direction={dir}\n orientation={orientation}\n >\n <Collection.Slot scope={__scopeAccordion}>\n <Primitive.div\n {...accordionProps}\n data-orientation={orientation}\n ref={composedRefs}\n onKeyDown={disabled ? undefined : handleKeyDown}\n />\n </Collection.Slot>\n </AccordionImplProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * AccordionItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'AccordionItem';\n\ntype AccordionItemContextValue = { open?: boolean; disabled?: boolean; triggerId: string };\nconst [AccordionItemProvider, useAccordionItemContext] =\n createAccordionContext<AccordionItemContextValue>(ITEM_NAME);\n\ntype AccordionItemElement = React.ComponentRef<typeof CollapsiblePrimitive.Root>;\ntype CollapsibleProps = React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Root>;\ninterface AccordionItemProps extends Omit<\n CollapsibleProps,\n 'open' | 'defaultOpen' | 'onOpenChange'\n> {\n /**\n * Whether or not an accordion item is disabled from user interaction.\n *\n * @defaultValue false\n */\n disabled?: boolean;\n /**\n * A string value for the accordion item. All items within an accordion should use a unique value.\n */\n value: string;\n}\n\n/**\n * `AccordionItem` contains all of the parts of a collapsible section inside of an `Accordion`.\n */\nconst AccordionItem = /* @__PURE__ */ React.forwardRef<AccordionItemElement, AccordionItemProps>(\n function AccordionItem(props: ScopedProps<AccordionItemProps>, forwardedRef) {\n const { __scopeAccordion, value, ...accordionItemProps } = props;\n const accordionContext = useAccordionContext(ITEM_NAME, __scopeAccordion);\n const valueContext = useAccordionValueContext(ITEM_NAME, __scopeAccordion);\n const collapsibleScope = useCollapsibleScope(__scopeAccordion);\n const triggerId = useId();\n const open = (value && valueContext.value.includes(value)) || false;\n const disabled = accordionContext.disabled || props.disabled;\n\n return (\n <AccordionItemProvider\n scope={__scopeAccordion}\n open={open}\n disabled={disabled}\n triggerId={triggerId}\n >\n <CollapsiblePrimitive.Root\n data-orientation={accordionContext.orientation}\n data-state={getState(open)}\n {...collapsibleScope}\n {...accordionItemProps}\n ref={forwardedRef}\n disabled={disabled}\n open={open}\n onOpenChange={(open) => {\n if (open) {\n valueContext.onItemOpen(value);\n } else {\n valueContext.onItemClose(value);\n }\n }}\n />\n </AccordionItemProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * AccordionHeader\n * -----------------------------------------------------------------------------------------------*/\n\nconst HEADER_NAME = 'AccordionHeader';\n\ntype AccordionHeaderElement = React.ComponentRef<typeof Primitive.h3>;\ntype PrimitiveHeading3Props = React.ComponentPropsWithoutRef<typeof Primitive.h3>;\ninterface AccordionHeaderProps extends PrimitiveHeading3Props {}\n\n/**\n * `AccordionHeader` contains the content for the parts of an `AccordionItem` that will be visible\n * whether or not its content is collapsed.\n */\nconst AccordionHeader = /* @__PURE__ */ React.forwardRef<\n AccordionHeaderElement,\n AccordionHeaderProps\n>(\n // blank line to reduce diff noise\n function AccordionHeader(props: ScopedProps<AccordionHeaderProps>, forwardedRef) {\n const { __scopeAccordion, ...headerProps } = props;\n const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);\n const itemContext = useAccordionItemContext(HEADER_NAME, __scopeAccordion);\n return (\n <Primitive.h3\n data-orientation={accordionContext.orientation}\n data-state={getState(itemContext.open)}\n data-disabled={itemContext.disabled ? '' : undefined}\n {...headerProps}\n ref={forwardedRef}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * AccordionTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'AccordionTrigger';\n\ntype AccordionTriggerElement = React.ComponentRef<typeof CollapsiblePrimitive.Trigger>;\ntype CollapsibleTriggerProps = React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Trigger>;\ninterface AccordionTriggerProps extends CollapsibleTriggerProps {}\n\n/**\n * `AccordionTrigger` is the trigger that toggles the collapsed state of an `AccordionItem`. It\n * should always be nested inside of an `AccordionHeader`.\n */\nconst AccordionTrigger = /* @__PURE__ */ React.forwardRef<\n AccordionTriggerElement,\n AccordionTriggerProps\n>(\n // blank line to reduce diff noise\n function AccordionTrigger(props: ScopedProps<AccordionTriggerProps>, forwardedRef) {\n const { __scopeAccordion, ...triggerProps } = props;\n const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);\n const itemContext = useAccordionItemContext(TRIGGER_NAME, __scopeAccordion);\n const collapsibleContext = useAccordionCollapsibleContext(TRIGGER_NAME, __scopeAccordion);\n const collapsibleScope = useCollapsibleScope(__scopeAccordion);\n return (\n <Collection.ItemSlot scope={__scopeAccordion}>\n <CollapsiblePrimitive.Trigger\n aria-disabled={(itemContext.open && !collapsibleContext.collapsible) || undefined}\n data-orientation={accordionContext.orientation}\n id={itemContext.triggerId}\n {...collapsibleScope}\n {...triggerProps}\n ref={forwardedRef}\n />\n </Collection.ItemSlot>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * AccordionContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'AccordionContent';\n\ntype AccordionContentElement = React.ComponentRef<typeof CollapsiblePrimitive.Content>;\ntype CollapsibleContentProps = React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Content>;\ninterface AccordionContentProps extends CollapsibleContentProps {}\n\n/**\n * `AccordionContent` contains the collapsible content for an `AccordionItem`.\n */\nconst AccordionContent = /* @__PURE__ */ React.forwardRef<\n AccordionContentElement,\n AccordionContentProps\n>(\n // blank line to reduce diff noise\n function AccordionContent(props: ScopedProps<AccordionContentProps>, forwardedRef) {\n const { __scopeAccordion, ...contentProps } = props;\n const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);\n const itemContext = useAccordionItemContext(CONTENT_NAME, __scopeAccordion);\n const collapsibleScope = useCollapsibleScope(__scopeAccordion);\n return (\n <CollapsiblePrimitive.Content\n role=\"region\"\n aria-labelledby={itemContext.triggerId}\n data-orientation={accordionContext.orientation}\n {...collapsibleScope}\n {...contentProps}\n ref={forwardedRef}\n style={{\n '--radix-accordion-content-height': 'var(--radix-collapsible-content-height)',\n '--radix-accordion-content-width': 'var(--radix-collapsible-content-width)',\n ...props.style,\n }}\n />\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open?: boolean) {\n return open ? 'open' : 'closed';\n}\n\nconst Root = Accordion;\nconst Item = AccordionItem;\nconst Header = AccordionHeader;\nconst Trigger = AccordionTrigger;\nconst Content = AccordionContent;\n\nexport {\n createAccordionScope,\n //\n Accordion,\n AccordionItem,\n AccordionHeader,\n AccordionTrigger,\n AccordionContent,\n //\n Root,\n Item,\n Header,\n Trigger,\n Content,\n};\nexport type {\n AccordionSingleProps,\n AccordionMultipleProps,\n AccordionItemProps,\n AccordionHeaderProps,\n AccordionTriggerProps,\n AccordionContentProps,\n};\n"],
|
|
5
|
-
"mappings": ";;;;;AAAA,YAAY,WAAW;AACvB,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,iBAAiB;AAC1B,YAAY,0BAA0B;AACtC,SAAS,8BAA8B;AACvC,SAAS,aAAa;AAGtB,SAAS,oBAAoB;
|
|
6
|
-
"names": ["Accordion", "AccordionImplSingle", "AccordionImplMultiple", "value", "AccordionImpl", "AccordionItem", "open", "AccordionHeader", "AccordionTrigger", "AccordionContent"
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { createCollection } from '@radix-ui/react-collection';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as CollapsiblePrimitive from '@radix-ui/react-collapsible';\nimport { createCollapsibleScope } from '@radix-ui/react-collapsible';\nimport { useId } from '@radix-ui/react-id';\n\nimport type { Scope } from '@radix-ui/react-context';\nimport { useDirection } from '@radix-ui/react-direction';\n\nconst AccordionType = {\n Single: 'single',\n Multiple: 'multiple',\n} as const;\n\nconst Orientation = {\n Vertical: 'vertical',\n Horizontal: 'horizontal',\n} as const;\n\nconst Direction = {\n LTR: 'ltr',\n RTL: 'rtl',\n} as const;\n\ntype AccordionType = (typeof AccordionType)[keyof typeof AccordionType];\ntype Orientation = (typeof Orientation)[keyof typeof Orientation];\ntype Direction = (typeof Direction)[keyof typeof Direction];\n\n/* -------------------------------------------------------------------------------------------------\n * Accordion\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACCORDION_NAME = 'Accordion';\nconst ACCORDION_KEYS = ['Home', 'End', 'ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'];\n\nconst [Collection, useCollection, createCollectionScope] =\n createCollection<AccordionTriggerElement>(ACCORDION_NAME);\n\ntype ScopedProps<P> = P & { __scopeAccordion?: Scope };\nconst [createAccordionContext, createAccordionScope] = createContextScope(ACCORDION_NAME, [\n createCollectionScope,\n createCollapsibleScope,\n]);\nconst useCollapsibleScope = createCollapsibleScope();\n\ntype AccordionElement = AccordionImplMultipleElement | AccordionImplSingleElement;\ninterface AccordionSingleProps extends AccordionImplSingleProps {\n type: typeof AccordionType.Single;\n}\ninterface AccordionMultipleProps extends AccordionImplMultipleProps {\n type: typeof AccordionType.Multiple;\n}\n\nconst Accordion = /* @__PURE__ */ React.forwardRef<\n AccordionElement,\n AccordionSingleProps | AccordionMultipleProps\n>(\n // blank line to reduce diff noise\n function Accordion(\n props: ScopedProps<AccordionSingleProps | AccordionMultipleProps>,\n forwardedRef,\n ) {\n const { type, ...accordionProps } = props;\n const singleProps = accordionProps as AccordionImplSingleProps;\n const multipleProps = accordionProps as AccordionImplMultipleProps;\n return (\n <Collection.Provider scope={props.__scopeAccordion}>\n {type === AccordionType.Multiple ? (\n <AccordionImplMultiple {...multipleProps} ref={forwardedRef} />\n ) : (\n <AccordionImplSingle {...singleProps} ref={forwardedRef} />\n )}\n </Collection.Provider>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype AccordionValueContextValue = {\n value: string[];\n onItemOpen(value: string): void;\n onItemClose(value: string): void;\n};\n\nconst [AccordionValueProvider, useAccordionValueContext] =\n createAccordionContext<AccordionValueContextValue>(ACCORDION_NAME);\n\nconst [AccordionCollapsibleProvider, useAccordionCollapsibleContext] = createAccordionContext(\n ACCORDION_NAME,\n { collapsible: false },\n);\n\ntype AccordionImplSingleElement = AccordionImplElement;\ninterface AccordionImplSingleProps extends AccordionImplProps {\n /**\n * The controlled stateful value of the accordion item whose content is expanded.\n */\n value?: string;\n /**\n * The value of the item whose content is expanded when the accordion is initially rendered. Use\n * `defaultValue` if you do not need to control the state of an accordion.\n */\n defaultValue?: string;\n /**\n * The callback that fires when the state of the accordion changes.\n */\n onValueChange?(value: string): void;\n /**\n * Whether an accordion item can be collapsed after it has been opened.\n * @default false\n */\n collapsible?: boolean;\n}\n\nconst AccordionImplSingle = /* @__PURE__ */ React.forwardRef<\n AccordionImplSingleElement,\n AccordionImplSingleProps\n>(\n // blank line to reduce diff noise\n function AccordionImplSingle(props: ScopedProps<AccordionImplSingleProps>, forwardedRef) {\n const {\n value: valueProp,\n defaultValue,\n onValueChange = () => {},\n collapsible = false,\n ...accordionSingleProps\n } = props;\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue ?? '',\n onChange: onValueChange,\n caller: ACCORDION_NAME,\n });\n\n return (\n <AccordionValueProvider\n scope={props.__scopeAccordion}\n value={React.useMemo(() => (value ? [value] : []), [value])}\n onItemOpen={setValue}\n onItemClose={React.useCallback(() => collapsible && setValue(''), [collapsible, setValue])}\n >\n <AccordionCollapsibleProvider scope={props.__scopeAccordion} collapsible={collapsible}>\n <AccordionImpl {...accordionSingleProps} ref={forwardedRef} />\n </AccordionCollapsibleProvider>\n </AccordionValueProvider>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype AccordionImplMultipleElement = AccordionImplElement;\ninterface AccordionImplMultipleProps extends AccordionImplProps {\n /**\n * The controlled stateful value of the accordion items whose contents are expanded.\n */\n value?: string[];\n /**\n * The value of the items whose contents are expanded when the accordion is initially rendered. Use\n * `defaultValue` if you do not need to control the state of an accordion.\n */\n defaultValue?: string[];\n /**\n * The callback that fires when the state of the accordion changes.\n */\n onValueChange?(value: string[]): void;\n}\n\nconst AccordionImplMultiple = /* @__PURE__ */ React.forwardRef<\n AccordionImplMultipleElement,\n AccordionImplMultipleProps\n>(function AccordionImplMultiple(props: ScopedProps<AccordionImplMultipleProps>, forwardedRef) {\n const {\n value: valueProp,\n defaultValue,\n onValueChange = () => {},\n ...accordionMultipleProps\n } = props;\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue ?? [],\n onChange: onValueChange,\n caller: ACCORDION_NAME,\n });\n\n const handleItemOpen = React.useCallback(\n (itemValue: string) => setValue((prevValue = []) => [...prevValue, itemValue]),\n [setValue],\n );\n\n const handleItemClose = React.useCallback(\n (itemValue: string) =>\n setValue((prevValue = []) => prevValue.filter((value) => value !== itemValue)),\n [setValue],\n );\n\n return (\n <AccordionValueProvider\n scope={props.__scopeAccordion}\n value={value}\n onItemOpen={handleItemOpen}\n onItemClose={handleItemClose}\n >\n <AccordionCollapsibleProvider scope={props.__scopeAccordion} collapsible={true}>\n <AccordionImpl {...accordionMultipleProps} ref={forwardedRef} />\n </AccordionCollapsibleProvider>\n </AccordionValueProvider>\n );\n});\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype AccordionImplContextValue = {\n disabled?: boolean;\n direction: AccordionImplProps['dir'];\n orientation: AccordionImplProps['orientation'];\n};\n\nconst [AccordionImplProvider, useAccordionContext] =\n createAccordionContext<AccordionImplContextValue>(ACCORDION_NAME);\n\ntype AccordionImplElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface AccordionImplProps extends PrimitiveDivProps {\n /**\n * Whether or not an accordion is disabled from user interaction.\n *\n * @defaultValue false\n */\n disabled?: boolean;\n /**\n * The layout in which the Accordion operates.\n * @default vertical\n */\n orientation?: Orientation;\n /**\n * The language read direction.\n */\n dir?: Direction;\n}\n\nconst AccordionImpl = /* @__PURE__ */ React.forwardRef<AccordionImplElement, AccordionImplProps>(\n function AccordionImpl(props: ScopedProps<AccordionImplProps>, forwardedRef) {\n const {\n __scopeAccordion,\n disabled,\n dir,\n orientation = Orientation.Vertical,\n ...accordionProps\n } = props;\n const accordionRef = React.useRef<AccordionImplElement>(null);\n const composedRefs = useComposedRefs(accordionRef, forwardedRef);\n const getItems = useCollection(__scopeAccordion);\n const direction = useDirection(dir);\n const isDirectionLTR = direction === Direction.LTR;\n\n const handleKeyDown = composeEventHandlers(props.onKeyDown, (event) => {\n if (!ACCORDION_KEYS.includes(event.key)) return;\n const target = event.target as HTMLElement;\n const triggerCollection = getItems().filter((item) => !item.ref.current?.disabled);\n const triggerIndex = triggerCollection.findIndex((item) => item.ref.current === target);\n const triggerCount = triggerCollection.length;\n\n if (triggerIndex === -1) return;\n\n // Prevents page scroll while user is navigating\n event.preventDefault();\n\n let nextIndex = triggerIndex;\n const homeIndex = 0;\n const endIndex = triggerCount - 1;\n\n const moveNext = () => {\n nextIndex = triggerIndex + 1;\n if (nextIndex > endIndex) {\n nextIndex = homeIndex;\n }\n };\n\n const movePrev = () => {\n nextIndex = triggerIndex - 1;\n if (nextIndex < homeIndex) {\n nextIndex = endIndex;\n }\n };\n\n switch (event.key) {\n case 'Home':\n nextIndex = homeIndex;\n break;\n case 'End':\n nextIndex = endIndex;\n break;\n case 'ArrowRight':\n if (orientation === Orientation.Horizontal) {\n if (isDirectionLTR) {\n moveNext();\n } else {\n movePrev();\n }\n }\n break;\n case 'ArrowDown':\n if (orientation === Orientation.Vertical) {\n moveNext();\n }\n break;\n case 'ArrowLeft':\n if (orientation === Orientation.Horizontal) {\n if (isDirectionLTR) {\n movePrev();\n } else {\n moveNext();\n }\n }\n break;\n case 'ArrowUp':\n if (orientation === Orientation.Vertical) {\n movePrev();\n }\n break;\n }\n\n const clampedIndex = nextIndex % triggerCount;\n triggerCollection[clampedIndex]!.ref.current?.focus();\n });\n\n return (\n <AccordionImplProvider\n scope={__scopeAccordion}\n disabled={disabled}\n direction={dir}\n orientation={orientation}\n >\n <Collection.Slot scope={__scopeAccordion}>\n <Primitive.div\n {...accordionProps}\n data-orientation={orientation}\n ref={composedRefs}\n onKeyDown={disabled ? undefined : handleKeyDown}\n />\n </Collection.Slot>\n </AccordionImplProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * AccordionItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'AccordionItem';\n\ntype AccordionItemContextValue = { open?: boolean; disabled?: boolean; triggerId: string };\nconst [AccordionItemProvider, useAccordionItemContext] =\n createAccordionContext<AccordionItemContextValue>(ITEM_NAME);\n\ntype AccordionItemElement = React.ComponentRef<typeof CollapsiblePrimitive.Root>;\ntype CollapsibleProps = React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Root>;\ninterface AccordionItemProps extends Omit<\n CollapsibleProps,\n 'open' | 'defaultOpen' | 'onOpenChange'\n> {\n /**\n * Whether or not an accordion item is disabled from user interaction.\n *\n * @defaultValue false\n */\n disabled?: boolean;\n /**\n * A string value for the accordion item. All items within an accordion should use a unique value.\n */\n value: string;\n}\n\n/**\n * `AccordionItem` contains all of the parts of a collapsible section inside of an `Accordion`.\n */\nconst AccordionItem = /* @__PURE__ */ React.forwardRef<AccordionItemElement, AccordionItemProps>(\n function AccordionItem(props: ScopedProps<AccordionItemProps>, forwardedRef) {\n const { __scopeAccordion, value, ...accordionItemProps } = props;\n const accordionContext = useAccordionContext(ITEM_NAME, __scopeAccordion);\n const valueContext = useAccordionValueContext(ITEM_NAME, __scopeAccordion);\n const collapsibleScope = useCollapsibleScope(__scopeAccordion);\n const triggerId = useId();\n const open = (value && valueContext.value.includes(value)) || false;\n const disabled = accordionContext.disabled || props.disabled;\n\n return (\n <AccordionItemProvider\n scope={__scopeAccordion}\n open={open}\n disabled={disabled}\n triggerId={triggerId}\n >\n <CollapsiblePrimitive.Root\n data-orientation={accordionContext.orientation}\n data-state={getState(open)}\n {...collapsibleScope}\n {...accordionItemProps}\n ref={forwardedRef}\n disabled={disabled}\n open={open}\n onOpenChange={(open) => {\n if (open) {\n valueContext.onItemOpen(value);\n } else {\n valueContext.onItemClose(value);\n }\n }}\n />\n </AccordionItemProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * AccordionHeader\n * -----------------------------------------------------------------------------------------------*/\n\nconst HEADER_NAME = 'AccordionHeader';\n\ntype AccordionHeaderElement = React.ComponentRef<typeof Primitive.h3>;\ntype PrimitiveHeading3Props = React.ComponentPropsWithoutRef<typeof Primitive.h3>;\ninterface AccordionHeaderProps extends PrimitiveHeading3Props {}\n\n/**\n * `AccordionHeader` contains the content for the parts of an `AccordionItem` that will be visible\n * whether or not its content is collapsed.\n */\nconst AccordionHeader = /* @__PURE__ */ React.forwardRef<\n AccordionHeaderElement,\n AccordionHeaderProps\n>(\n // blank line to reduce diff noise\n function AccordionHeader(props: ScopedProps<AccordionHeaderProps>, forwardedRef) {\n const { __scopeAccordion, ...headerProps } = props;\n const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);\n const itemContext = useAccordionItemContext(HEADER_NAME, __scopeAccordion);\n return (\n <Primitive.h3\n data-orientation={accordionContext.orientation}\n data-state={getState(itemContext.open)}\n data-disabled={itemContext.disabled ? '' : undefined}\n {...headerProps}\n ref={forwardedRef}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * AccordionTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'AccordionTrigger';\n\ntype AccordionTriggerElement = React.ComponentRef<typeof CollapsiblePrimitive.Trigger>;\ntype CollapsibleTriggerProps = React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Trigger>;\ninterface AccordionTriggerProps extends CollapsibleTriggerProps {}\n\n/**\n * `AccordionTrigger` is the trigger that toggles the collapsed state of an `AccordionItem`. It\n * should always be nested inside of an `AccordionHeader`.\n */\nconst AccordionTrigger = /* @__PURE__ */ React.forwardRef<\n AccordionTriggerElement,\n AccordionTriggerProps\n>(\n // blank line to reduce diff noise\n function AccordionTrigger(props: ScopedProps<AccordionTriggerProps>, forwardedRef) {\n const { __scopeAccordion, ...triggerProps } = props;\n const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);\n const itemContext = useAccordionItemContext(TRIGGER_NAME, __scopeAccordion);\n const collapsibleContext = useAccordionCollapsibleContext(TRIGGER_NAME, __scopeAccordion);\n const collapsibleScope = useCollapsibleScope(__scopeAccordion);\n return (\n <Collection.ItemSlot scope={__scopeAccordion}>\n <CollapsiblePrimitive.Trigger\n aria-disabled={(itemContext.open && !collapsibleContext.collapsible) || undefined}\n data-orientation={accordionContext.orientation}\n id={itemContext.triggerId}\n {...collapsibleScope}\n {...triggerProps}\n ref={forwardedRef}\n />\n </Collection.ItemSlot>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * AccordionContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'AccordionContent';\n\ntype AccordionContentElement = React.ComponentRef<typeof CollapsiblePrimitive.Content>;\ntype CollapsibleContentProps = React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Content>;\ninterface AccordionContentProps extends CollapsibleContentProps {}\n\n/**\n * `AccordionContent` contains the collapsible content for an `AccordionItem`.\n */\nconst AccordionContent = /* @__PURE__ */ React.forwardRef<\n AccordionContentElement,\n AccordionContentProps\n>(\n // blank line to reduce diff noise\n function AccordionContent(props: ScopedProps<AccordionContentProps>, forwardedRef) {\n const { __scopeAccordion, ...contentProps } = props;\n const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);\n const itemContext = useAccordionItemContext(CONTENT_NAME, __scopeAccordion);\n const collapsibleScope = useCollapsibleScope(__scopeAccordion);\n return (\n <CollapsiblePrimitive.Content\n role=\"region\"\n aria-labelledby={itemContext.triggerId}\n data-orientation={accordionContext.orientation}\n {...collapsibleScope}\n {...contentProps}\n ref={forwardedRef}\n style={{\n '--radix-accordion-content-height': 'var(--radix-collapsible-content-height)',\n '--radix-accordion-content-width': 'var(--radix-collapsible-content-width)',\n ...props.style,\n }}\n />\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open?: boolean) {\n return open ? 'open' : 'closed';\n}\n\nexport {\n createAccordionScope,\n //\n Accordion,\n AccordionItem,\n AccordionHeader,\n AccordionTrigger,\n AccordionContent,\n //\n Accordion as Root,\n AccordionItem as Item,\n AccordionHeader as Header,\n AccordionTrigger as Trigger,\n AccordionContent as Content,\n};\nexport type {\n AccordionSingleProps,\n AccordionMultipleProps,\n AccordionItemProps,\n AccordionHeaderProps,\n AccordionTriggerProps,\n AccordionContentProps,\n};\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA,YAAY,WAAW;AACvB,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,iBAAiB;AAC1B,YAAY,0BAA0B;AACtC,SAAS,8BAA8B;AACvC,SAAS,aAAa;AAGtB,SAAS,oBAAoB;AA6DnB;AA3DV,IAAM,gBAAgB;AAAA,EACpB,QAAQ;AAAA,EACR,UAAU;AACZ;AAEA,IAAM,cAAc;AAAA,EAClB,UAAU;AAAA,EACV,YAAY;AACd;AAEA,IAAM,YAAY;AAAA,EAChB,KAAK;AAAA,EACL,KAAK;AACP;AAUA,IAAM,iBAAiB;AACvB,IAAM,iBAAiB,CAAC,QAAQ,OAAO,aAAa,WAAW,aAAa,YAAY;AAExF,IAAM,CAAC,YAAY,eAAe,qBAAqB,IACrD,iBAA0C,cAAc;AAG1D,IAAM,CAAC,wBAAwB,oBAAoB,IAAI,mBAAmB,gBAAgB;AAAA,EACxF;AAAA,EACA;AACF,CAAC;AACD,IAAM,sBAAsB,uBAAuB;AAUnD,IAAM,YAA4B,gBAAM;AAAA;AAAA,EAKtC,gCAASA,WACP,OACA,cACA;AACA,UAAM,EAAE,MAAM,GAAG,eAAe,IAAI;AACpC,UAAM,cAAc;AACpB,UAAM,gBAAgB;AACtB,WACE,oBAAC,WAAW,UAAX,EAAoB,OAAO,MAAM,kBAC/B,mBAAS,cAAc,WACtB,oBAAC,yBAAuB,GAAG,eAAe,KAAK,cAAc,IAE7D,oBAAC,uBA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,GAAG;AAAA,QACJ,KAAK;AAAA,QACL,OAAO;AAAA,UACL,oCAAoC;AAAA,UACpC,mCAAmC;AAAA,UACnC,GAAG,MAAM;AAAA,QACX;AAAA;AAAA,IACF;AAAA,EAEJ,GApBA;AAqBF;AAIA,SAAS,SAAS,MAAgB;AAChC,SAAO,OAAO,SAAS;AACzB;AAFS;",
|
|
6
|
+
"names": ["Accordion", "AccordionImplSingle", "AccordionImplMultiple", "value", "AccordionImpl", "AccordionItem", "open", "AccordionHeader", "AccordionTrigger", "AccordionContent"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-accordion",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.18-rc.1784603841447",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -12,20 +12,20 @@
|
|
|
12
12
|
"sideEffects": false,
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@radix-ui/primitive": "1.1.6",
|
|
15
|
-
"@radix-ui/react-collapsible": "1.1.17",
|
|
16
|
-
"@radix-ui/react-collection": "1.1.12",
|
|
17
15
|
"@radix-ui/react-compose-refs": "1.1.3",
|
|
16
|
+
"@radix-ui/react-collapsible": "1.1.18-rc.1784603841447",
|
|
18
17
|
"@radix-ui/react-context": "1.2.0",
|
|
19
|
-
"@radix-ui/react-direction": "1.1.
|
|
18
|
+
"@radix-ui/react-direction": "1.1.3-rc.1784603841447",
|
|
19
|
+
"@radix-ui/react-collection": "1.1.13-rc.1784603841447",
|
|
20
|
+
"@radix-ui/react-use-controllable-state": "1.2.4",
|
|
20
21
|
"@radix-ui/react-id": "1.1.2",
|
|
21
|
-
"@radix-ui/react-primitive": "2.1.
|
|
22
|
-
"@radix-ui/react-use-controllable-state": "1.2.4"
|
|
22
|
+
"@radix-ui/react-primitive": "2.1.8-rc.1784603841447"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@types/react": "^19.2.
|
|
26
|
-
"@types/react-dom": "^19.2.
|
|
27
|
-
"react": "^19.2.
|
|
28
|
-
"react-dom": "^19.2.
|
|
25
|
+
"@types/react": "^19.2.17",
|
|
26
|
+
"@types/react-dom": "^19.2.3",
|
|
27
|
+
"react": "^19.2.7",
|
|
28
|
+
"react-dom": "^19.2.7",
|
|
29
29
|
"typescript": "^5.9.3",
|
|
30
30
|
"@repo/builder": "0.0.0",
|
|
31
31
|
"@repo/typescript-config": "0.0.0"
|