@radix-ui/react-collapsible 0.0.0-20250116175529

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/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # `react-collapsible`
2
+
3
+ ## Installation
4
+
5
+ ```sh
6
+ $ yarn add @radix-ui/react-collapsible
7
+ # or
8
+ $ npm install @radix-ui/react-collapsible
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ View docs [here](https://radix-ui.com/primitives/docs/components/collapsible).
@@ -0,0 +1,33 @@
1
+ import * as _radix_ui_react_context from '@radix-ui/react-context';
2
+ import * as React from 'react';
3
+ import { Primitive } from '@radix-ui/react-primitive';
4
+
5
+ declare const createCollapsibleScope: _radix_ui_react_context.CreateScope;
6
+ type PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;
7
+ interface CollapsibleProps extends PrimitiveDivProps {
8
+ defaultOpen?: boolean;
9
+ open?: boolean;
10
+ disabled?: boolean;
11
+ onOpenChange?(open: boolean): void;
12
+ }
13
+ declare const Collapsible: React.ForwardRefExoticComponent<CollapsibleProps & React.RefAttributes<HTMLDivElement>>;
14
+ type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;
15
+ interface CollapsibleTriggerProps extends PrimitiveButtonProps {
16
+ }
17
+ declare const CollapsibleTrigger: React.ForwardRefExoticComponent<CollapsibleTriggerProps & React.RefAttributes<HTMLButtonElement>>;
18
+ interface CollapsibleContentProps extends Omit<CollapsibleContentImplProps, 'present'> {
19
+ /**
20
+ * Used to force mounting when more control is needed. Useful when
21
+ * controlling animation with React animation libraries.
22
+ */
23
+ forceMount?: true;
24
+ }
25
+ declare const CollapsibleContent: React.ForwardRefExoticComponent<CollapsibleContentProps & React.RefAttributes<HTMLDivElement>>;
26
+ interface CollapsibleContentImplProps extends PrimitiveDivProps {
27
+ present: boolean;
28
+ }
29
+ declare const Root: React.ForwardRefExoticComponent<CollapsibleProps & React.RefAttributes<HTMLDivElement>>;
30
+ declare const Trigger: React.ForwardRefExoticComponent<CollapsibleTriggerProps & React.RefAttributes<HTMLButtonElement>>;
31
+ declare const Content: React.ForwardRefExoticComponent<CollapsibleContentProps & React.RefAttributes<HTMLDivElement>>;
32
+
33
+ export { Collapsible, CollapsibleContent, type CollapsibleContentProps, type CollapsibleProps, CollapsibleTrigger, type CollapsibleTriggerProps, Content, Root, Trigger, createCollapsibleScope };
@@ -0,0 +1,33 @@
1
+ import * as _radix_ui_react_context from '@radix-ui/react-context';
2
+ import * as React from 'react';
3
+ import { Primitive } from '@radix-ui/react-primitive';
4
+
5
+ declare const createCollapsibleScope: _radix_ui_react_context.CreateScope;
6
+ type PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;
7
+ interface CollapsibleProps extends PrimitiveDivProps {
8
+ defaultOpen?: boolean;
9
+ open?: boolean;
10
+ disabled?: boolean;
11
+ onOpenChange?(open: boolean): void;
12
+ }
13
+ declare const Collapsible: React.ForwardRefExoticComponent<CollapsibleProps & React.RefAttributes<HTMLDivElement>>;
14
+ type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;
15
+ interface CollapsibleTriggerProps extends PrimitiveButtonProps {
16
+ }
17
+ declare const CollapsibleTrigger: React.ForwardRefExoticComponent<CollapsibleTriggerProps & React.RefAttributes<HTMLButtonElement>>;
18
+ interface CollapsibleContentProps extends Omit<CollapsibleContentImplProps, 'present'> {
19
+ /**
20
+ * Used to force mounting when more control is needed. Useful when
21
+ * controlling animation with React animation libraries.
22
+ */
23
+ forceMount?: true;
24
+ }
25
+ declare const CollapsibleContent: React.ForwardRefExoticComponent<CollapsibleContentProps & React.RefAttributes<HTMLDivElement>>;
26
+ interface CollapsibleContentImplProps extends PrimitiveDivProps {
27
+ present: boolean;
28
+ }
29
+ declare const Root: React.ForwardRefExoticComponent<CollapsibleProps & React.RefAttributes<HTMLDivElement>>;
30
+ declare const Trigger: React.ForwardRefExoticComponent<CollapsibleTriggerProps & React.RefAttributes<HTMLButtonElement>>;
31
+ declare const Content: React.ForwardRefExoticComponent<CollapsibleContentProps & React.RefAttributes<HTMLDivElement>>;
32
+
33
+ export { Collapsible, CollapsibleContent, type CollapsibleContentProps, type CollapsibleProps, CollapsibleTrigger, type CollapsibleTriggerProps, Content, Root, Trigger, createCollapsibleScope };
package/dist/index.js ADDED
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // packages/react/collapsible/src/index.ts
32
+ var src_exports = {};
33
+ __export(src_exports, {
34
+ Collapsible: () => Collapsible,
35
+ CollapsibleContent: () => CollapsibleContent,
36
+ CollapsibleTrigger: () => CollapsibleTrigger,
37
+ Content: () => Content,
38
+ Root: () => Root,
39
+ Trigger: () => Trigger,
40
+ createCollapsibleScope: () => createCollapsibleScope
41
+ });
42
+ module.exports = __toCommonJS(src_exports);
43
+
44
+ // packages/react/collapsible/src/Collapsible.tsx
45
+ var React = __toESM(require("react"));
46
+ var import_primitive = require("@radix-ui/primitive");
47
+ var import_react_context = require("@radix-ui/react-context");
48
+ var import_react_use_controllable_state = require("@radix-ui/react-use-controllable-state");
49
+ var import_react_use_layout_effect = require("@radix-ui/react-use-layout-effect");
50
+ var import_react_compose_refs = require("@radix-ui/react-compose-refs");
51
+ var import_react_primitive = require("@radix-ui/react-primitive");
52
+ var import_react_presence = require("@radix-ui/react-presence");
53
+ var import_react_id = require("@radix-ui/react-id");
54
+ var import_jsx_runtime = require("react/jsx-runtime");
55
+ var COLLAPSIBLE_NAME = "Collapsible";
56
+ var [createCollapsibleContext, createCollapsibleScope] = (0, import_react_context.createContextScope)(COLLAPSIBLE_NAME);
57
+ var [CollapsibleProvider, useCollapsibleContext] = createCollapsibleContext(COLLAPSIBLE_NAME);
58
+ var Collapsible = React.forwardRef(
59
+ (props, forwardedRef) => {
60
+ const {
61
+ __scopeCollapsible,
62
+ open: openProp,
63
+ defaultOpen,
64
+ disabled,
65
+ onOpenChange,
66
+ ...collapsibleProps
67
+ } = props;
68
+ const [open = false, setOpen] = (0, import_react_use_controllable_state.useControllableState)({
69
+ prop: openProp,
70
+ defaultProp: defaultOpen,
71
+ onChange: onOpenChange
72
+ });
73
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
74
+ CollapsibleProvider,
75
+ {
76
+ scope: __scopeCollapsible,
77
+ disabled,
78
+ contentId: (0, import_react_id.useId)(),
79
+ open,
80
+ onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
81
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
82
+ import_react_primitive.Primitive.div,
83
+ {
84
+ "data-state": getState(open),
85
+ "data-disabled": disabled ? "" : void 0,
86
+ ...collapsibleProps,
87
+ ref: forwardedRef
88
+ }
89
+ )
90
+ }
91
+ );
92
+ }
93
+ );
94
+ Collapsible.displayName = COLLAPSIBLE_NAME;
95
+ var TRIGGER_NAME = "CollapsibleTrigger";
96
+ var CollapsibleTrigger = React.forwardRef(
97
+ (props, forwardedRef) => {
98
+ const { __scopeCollapsible, ...triggerProps } = props;
99
+ const context = useCollapsibleContext(TRIGGER_NAME, __scopeCollapsible);
100
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
101
+ import_react_primitive.Primitive.button,
102
+ {
103
+ type: "button",
104
+ "aria-controls": context.contentId,
105
+ "aria-expanded": context.open || false,
106
+ "data-state": getState(context.open),
107
+ "data-disabled": context.disabled ? "" : void 0,
108
+ disabled: context.disabled,
109
+ ...triggerProps,
110
+ ref: forwardedRef,
111
+ onClick: (0, import_primitive.composeEventHandlers)(props.onClick, context.onOpenToggle)
112
+ }
113
+ );
114
+ }
115
+ );
116
+ CollapsibleTrigger.displayName = TRIGGER_NAME;
117
+ var CONTENT_NAME = "CollapsibleContent";
118
+ var CollapsibleContent = React.forwardRef(
119
+ (props, forwardedRef) => {
120
+ const { forceMount, ...contentProps } = props;
121
+ const context = useCollapsibleContext(CONTENT_NAME, props.__scopeCollapsible);
122
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_presence.Presence, { present: forceMount || context.open, children: ({ present }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CollapsibleContentImpl, { ...contentProps, ref: forwardedRef, present }) });
123
+ }
124
+ );
125
+ CollapsibleContent.displayName = CONTENT_NAME;
126
+ var CollapsibleContentImpl = React.forwardRef((props, forwardedRef) => {
127
+ const { __scopeCollapsible, present, children, ...contentProps } = props;
128
+ const context = useCollapsibleContext(CONTENT_NAME, __scopeCollapsible);
129
+ const [isPresent, setIsPresent] = React.useState(present);
130
+ const ref = React.useRef(null);
131
+ const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, ref);
132
+ const heightRef = React.useRef(0);
133
+ const height = heightRef.current;
134
+ const widthRef = React.useRef(0);
135
+ const width = widthRef.current;
136
+ const isOpen = context.open || isPresent;
137
+ const isMountAnimationPreventedRef = React.useRef(isOpen);
138
+ const originalStylesRef = React.useRef(void 0);
139
+ React.useEffect(() => {
140
+ const rAF = requestAnimationFrame(() => isMountAnimationPreventedRef.current = false);
141
+ return () => cancelAnimationFrame(rAF);
142
+ }, []);
143
+ (0, import_react_use_layout_effect.useLayoutEffect)(() => {
144
+ const node = ref.current;
145
+ if (node) {
146
+ originalStylesRef.current = originalStylesRef.current || {
147
+ transitionDuration: node.style.transitionDuration,
148
+ animationName: node.style.animationName
149
+ };
150
+ node.style.transitionDuration = "0s";
151
+ node.style.animationName = "none";
152
+ const rect = node.getBoundingClientRect();
153
+ heightRef.current = rect.height;
154
+ widthRef.current = rect.width;
155
+ if (!isMountAnimationPreventedRef.current) {
156
+ node.style.transitionDuration = originalStylesRef.current.transitionDuration;
157
+ node.style.animationName = originalStylesRef.current.animationName;
158
+ }
159
+ setIsPresent(present);
160
+ }
161
+ }, [context.open, present]);
162
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
163
+ import_react_primitive.Primitive.div,
164
+ {
165
+ "data-state": getState(context.open),
166
+ "data-disabled": context.disabled ? "" : void 0,
167
+ id: context.contentId,
168
+ hidden: !isOpen,
169
+ ...contentProps,
170
+ ref: composedRefs,
171
+ style: {
172
+ [`--radix-collapsible-content-height`]: height ? `${height}px` : void 0,
173
+ [`--radix-collapsible-content-width`]: width ? `${width}px` : void 0,
174
+ ...props.style
175
+ },
176
+ children: isOpen && children
177
+ }
178
+ );
179
+ });
180
+ function getState(open) {
181
+ return open ? "open" : "closed";
182
+ }
183
+ var Root = Collapsible;
184
+ var Trigger = CollapsibleTrigger;
185
+ var Content = CollapsibleContent;
186
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts", "../src/Collapsible.tsx"],
4
+ "sourcesContent": ["'use client';\nexport {\n createCollapsibleScope,\n //\n Collapsible,\n CollapsibleTrigger,\n CollapsibleContent,\n //\n Root,\n Trigger,\n Content,\n} from './Collapsible';\nexport type {\n CollapsibleProps,\n CollapsibleTriggerProps,\n CollapsibleContentProps,\n} from './Collapsible';\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { Presence } from '@radix-ui/react-presence';\nimport { useId } from '@radix-ui/react-id';\n\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Collapsible\n * -----------------------------------------------------------------------------------------------*/\n\nconst COLLAPSIBLE_NAME = 'Collapsible';\n\ntype ScopedProps<P> = P & { __scopeCollapsible?: Scope };\nconst [createCollapsibleContext, createCollapsibleScope] = createContextScope(COLLAPSIBLE_NAME);\n\ntype CollapsibleContextValue = {\n contentId: string;\n disabled?: boolean;\n open: boolean;\n onOpenToggle(): void;\n};\n\nconst [CollapsibleProvider, useCollapsibleContext] =\n createCollapsibleContext<CollapsibleContextValue>(COLLAPSIBLE_NAME);\n\ntype CollapsibleElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface CollapsibleProps extends PrimitiveDivProps {\n defaultOpen?: boolean;\n open?: boolean;\n disabled?: boolean;\n onOpenChange?(open: boolean): void;\n}\n\nconst Collapsible = React.forwardRef<CollapsibleElement, CollapsibleProps>(\n (props: ScopedProps<CollapsibleProps>, forwardedRef) => {\n const {\n __scopeCollapsible,\n open: openProp,\n defaultOpen,\n disabled,\n onOpenChange,\n ...collapsibleProps\n } = props;\n\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n\n return (\n <CollapsibleProvider\n scope={__scopeCollapsible}\n disabled={disabled}\n contentId={useId()}\n open={open}\n onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])}\n >\n <Primitive.div\n data-state={getState(open)}\n data-disabled={disabled ? '' : undefined}\n {...collapsibleProps}\n ref={forwardedRef}\n />\n </CollapsibleProvider>\n );\n }\n);\n\nCollapsible.displayName = COLLAPSIBLE_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * CollapsibleTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'CollapsibleTrigger';\n\ntype CollapsibleTriggerElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface CollapsibleTriggerProps extends PrimitiveButtonProps {}\n\nconst CollapsibleTrigger = React.forwardRef<CollapsibleTriggerElement, CollapsibleTriggerProps>(\n (props: ScopedProps<CollapsibleTriggerProps>, forwardedRef) => {\n const { __scopeCollapsible, ...triggerProps } = props;\n const context = useCollapsibleContext(TRIGGER_NAME, __scopeCollapsible);\n return (\n <Primitive.button\n type=\"button\"\n aria-controls={context.contentId}\n aria-expanded={context.open || false}\n data-state={getState(context.open)}\n data-disabled={context.disabled ? '' : undefined}\n disabled={context.disabled}\n {...triggerProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, context.onOpenToggle)}\n />\n );\n }\n);\n\nCollapsibleTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * CollapsibleContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'CollapsibleContent';\n\ntype CollapsibleContentElement = CollapsibleContentImplElement;\ninterface CollapsibleContentProps extends Omit<CollapsibleContentImplProps, 'present'> {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst CollapsibleContent = React.forwardRef<CollapsibleContentElement, CollapsibleContentProps>(\n (props: ScopedProps<CollapsibleContentProps>, forwardedRef) => {\n const { forceMount, ...contentProps } = props;\n const context = useCollapsibleContext(CONTENT_NAME, props.__scopeCollapsible);\n return (\n <Presence present={forceMount || context.open}>\n {({ present }) => (\n <CollapsibleContentImpl {...contentProps} ref={forwardedRef} present={present} />\n )}\n </Presence>\n );\n }\n);\n\nCollapsibleContent.displayName = CONTENT_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype CollapsibleContentImplElement = React.ElementRef<typeof Primitive.div>;\ninterface CollapsibleContentImplProps extends PrimitiveDivProps {\n present: boolean;\n}\n\nconst CollapsibleContentImpl = React.forwardRef<\n CollapsibleContentImplElement,\n CollapsibleContentImplProps\n>((props: ScopedProps<CollapsibleContentImplProps>, forwardedRef) => {\n const { __scopeCollapsible, present, children, ...contentProps } = props;\n const context = useCollapsibleContext(CONTENT_NAME, __scopeCollapsible);\n const [isPresent, setIsPresent] = React.useState(present);\n const ref = React.useRef<CollapsibleContentImplElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const heightRef = React.useRef<number | undefined>(0);\n const height = heightRef.current;\n const widthRef = React.useRef<number | undefined>(0);\n const width = widthRef.current;\n // when opening we want it to immediately open to retrieve dimensions\n // when closing we delay `present` to retrieve dimensions before closing\n const isOpen = context.open || isPresent;\n const isMountAnimationPreventedRef = React.useRef(isOpen);\n const originalStylesRef = React.useRef<Record<string, string>>(undefined);\n\n React.useEffect(() => {\n const rAF = requestAnimationFrame(() => (isMountAnimationPreventedRef.current = false));\n return () => cancelAnimationFrame(rAF);\n }, []);\n\n useLayoutEffect(() => {\n const node = ref.current;\n if (node) {\n originalStylesRef.current = originalStylesRef.current || {\n transitionDuration: node.style.transitionDuration,\n animationName: node.style.animationName,\n };\n // block any animations/transitions so the element renders at its full dimensions\n node.style.transitionDuration = '0s';\n node.style.animationName = 'none';\n\n // get width and height from full dimensions\n const rect = node.getBoundingClientRect();\n heightRef.current = rect.height;\n widthRef.current = rect.width;\n\n // kick off any animations/transitions that were originally set up if it isn't the initial mount\n if (!isMountAnimationPreventedRef.current) {\n node.style.transitionDuration = originalStylesRef.current.transitionDuration;\n node.style.animationName = originalStylesRef.current.animationName;\n }\n\n setIsPresent(present);\n }\n /**\n * depends on `context.open` because it will change to `false`\n * when a close is triggered but `present` will be `false` on\n * animation end (so when close finishes). This allows us to\n * retrieve the dimensions *before* closing.\n */\n }, [context.open, present]);\n\n return (\n <Primitive.div\n data-state={getState(context.open)}\n data-disabled={context.disabled ? '' : undefined}\n id={context.contentId}\n hidden={!isOpen}\n {...contentProps}\n ref={composedRefs}\n style={{\n [`--radix-collapsible-content-height` as any]: height ? `${height}px` : undefined,\n [`--radix-collapsible-content-width` as any]: width ? `${width}px` : undefined,\n ...props.style,\n }}\n >\n {isOpen && children}\n </Primitive.div>\n );\n});\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open?: boolean) {\n return open ? 'open' : 'closed';\n}\n\nconst Root = Collapsible;\nconst Trigger = CollapsibleTrigger;\nconst Content = CollapsibleContent;\n\nexport {\n createCollapsibleScope,\n //\n Collapsible,\n CollapsibleTrigger,\n CollapsibleContent,\n //\n Root,\n Trigger,\n Content,\n};\nexport type { CollapsibleProps, CollapsibleTriggerProps, CollapsibleContentProps };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,uBAAqC;AACrC,2BAAmC;AACnC,0CAAqC;AACrC,qCAAgC;AAChC,gCAAgC;AAChC,6BAA0B;AAC1B,4BAAyB;AACzB,sBAAsB;AAyDd;AAjDR,IAAM,mBAAmB;AAGzB,IAAM,CAAC,0BAA0B,sBAAsB,QAAI,yCAAmB,gBAAgB;AAS9F,IAAM,CAAC,qBAAqB,qBAAqB,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AK;AACzB,eAAS,UAAU,KAAK;AAGxB,UAAI,CAAC,6BAA6B,SAAS;AACzC,aAAK,MAAM,qBAAqB,kBAAkB,QAAQ;AAC1D,aAAK,MAAM,gBAAgB,kBAAkB,QAAQ;AAAA,MACvD;AAEA,mBAAa,OAAO;AAAA,IACtB;AAAA,EAOF,GAAG,CAAC,QAAQ,MAAM,OAAO,CAAC;AAE1B,SACE;AAAA,IAAC,iCAAU;AAAA,IAAV;AAAA,MACC,cAAY,SAAS,QAAQ,IAAI;AAAA,MACjC,iBAAe,QAAQ,WAAW,KAAK;AAAA,MACvC,IAAI,QAAQ;AAAA,MACZ,QAAQ,CAAC;AAAA,MACR,GAAG;AAAA,MACJ,KAAK;AAAA,MACL,OAAO;AAAA,QACL,CAAC,oCAA2C,GAAG,SAAS,GAAG,MAAM,OAAO;AAAA,QACxE,CAAC,mCAA0C,GAAG,QAAQ,GAAG,KAAK,OAAO;AAAA,QACrE,GAAG,MAAM;AAAA,MACX;AAAA,MAEC,oBAAU;AAAA;AAAA,EACb;AAEJ,CAAC;AAID,SAAS,SAAS,MAAgB;AAChC,SAAO,OAAO,SAAS;AACzB;AAEA,IAAM,OAAO;AACb,IAAM,UAAU;AAChB,IAAM,UAAU;",
6
+ "names": []
7
+ }
package/dist/index.mjs ADDED
@@ -0,0 +1,154 @@
1
+ "use client";
2
+
3
+ // packages/react/collapsible/src/Collapsible.tsx
4
+ import * as React from "react";
5
+ import { composeEventHandlers } from "@radix-ui/primitive";
6
+ import { createContextScope } from "@radix-ui/react-context";
7
+ import { useControllableState } from "@radix-ui/react-use-controllable-state";
8
+ import { useLayoutEffect } from "@radix-ui/react-use-layout-effect";
9
+ import { useComposedRefs } from "@radix-ui/react-compose-refs";
10
+ import { Primitive } from "@radix-ui/react-primitive";
11
+ import { Presence } from "@radix-ui/react-presence";
12
+ import { useId } from "@radix-ui/react-id";
13
+ import { jsx } from "react/jsx-runtime";
14
+ var COLLAPSIBLE_NAME = "Collapsible";
15
+ var [createCollapsibleContext, createCollapsibleScope] = createContextScope(COLLAPSIBLE_NAME);
16
+ var [CollapsibleProvider, useCollapsibleContext] = createCollapsibleContext(COLLAPSIBLE_NAME);
17
+ var Collapsible = React.forwardRef(
18
+ (props, forwardedRef) => {
19
+ const {
20
+ __scopeCollapsible,
21
+ open: openProp,
22
+ defaultOpen,
23
+ disabled,
24
+ onOpenChange,
25
+ ...collapsibleProps
26
+ } = props;
27
+ const [open = false, setOpen] = useControllableState({
28
+ prop: openProp,
29
+ defaultProp: defaultOpen,
30
+ onChange: onOpenChange
31
+ });
32
+ return /* @__PURE__ */ jsx(
33
+ CollapsibleProvider,
34
+ {
35
+ scope: __scopeCollapsible,
36
+ disabled,
37
+ contentId: useId(),
38
+ open,
39
+ onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
40
+ children: /* @__PURE__ */ jsx(
41
+ Primitive.div,
42
+ {
43
+ "data-state": getState(open),
44
+ "data-disabled": disabled ? "" : void 0,
45
+ ...collapsibleProps,
46
+ ref: forwardedRef
47
+ }
48
+ )
49
+ }
50
+ );
51
+ }
52
+ );
53
+ Collapsible.displayName = COLLAPSIBLE_NAME;
54
+ var TRIGGER_NAME = "CollapsibleTrigger";
55
+ var CollapsibleTrigger = React.forwardRef(
56
+ (props, forwardedRef) => {
57
+ const { __scopeCollapsible, ...triggerProps } = props;
58
+ const context = useCollapsibleContext(TRIGGER_NAME, __scopeCollapsible);
59
+ return /* @__PURE__ */ jsx(
60
+ Primitive.button,
61
+ {
62
+ type: "button",
63
+ "aria-controls": context.contentId,
64
+ "aria-expanded": context.open || false,
65
+ "data-state": getState(context.open),
66
+ "data-disabled": context.disabled ? "" : void 0,
67
+ disabled: context.disabled,
68
+ ...triggerProps,
69
+ ref: forwardedRef,
70
+ onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
71
+ }
72
+ );
73
+ }
74
+ );
75
+ CollapsibleTrigger.displayName = TRIGGER_NAME;
76
+ var CONTENT_NAME = "CollapsibleContent";
77
+ var CollapsibleContent = React.forwardRef(
78
+ (props, forwardedRef) => {
79
+ const { forceMount, ...contentProps } = props;
80
+ const context = useCollapsibleContext(CONTENT_NAME, props.__scopeCollapsible);
81
+ return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: ({ present }) => /* @__PURE__ */ jsx(CollapsibleContentImpl, { ...contentProps, ref: forwardedRef, present }) });
82
+ }
83
+ );
84
+ CollapsibleContent.displayName = CONTENT_NAME;
85
+ var CollapsibleContentImpl = React.forwardRef((props, forwardedRef) => {
86
+ const { __scopeCollapsible, present, children, ...contentProps } = props;
87
+ const context = useCollapsibleContext(CONTENT_NAME, __scopeCollapsible);
88
+ const [isPresent, setIsPresent] = React.useState(present);
89
+ const ref = React.useRef(null);
90
+ const composedRefs = useComposedRefs(forwardedRef, ref);
91
+ const heightRef = React.useRef(0);
92
+ const height = heightRef.current;
93
+ const widthRef = React.useRef(0);
94
+ const width = widthRef.current;
95
+ const isOpen = context.open || isPresent;
96
+ const isMountAnimationPreventedRef = React.useRef(isOpen);
97
+ const originalStylesRef = React.useRef(void 0);
98
+ React.useEffect(() => {
99
+ const rAF = requestAnimationFrame(() => isMountAnimationPreventedRef.current = false);
100
+ return () => cancelAnimationFrame(rAF);
101
+ }, []);
102
+ useLayoutEffect(() => {
103
+ const node = ref.current;
104
+ if (node) {
105
+ originalStylesRef.current = originalStylesRef.current || {
106
+ transitionDuration: node.style.transitionDuration,
107
+ animationName: node.style.animationName
108
+ };
109
+ node.style.transitionDuration = "0s";
110
+ node.style.animationName = "none";
111
+ const rect = node.getBoundingClientRect();
112
+ heightRef.current = rect.height;
113
+ widthRef.current = rect.width;
114
+ if (!isMountAnimationPreventedRef.current) {
115
+ node.style.transitionDuration = originalStylesRef.current.transitionDuration;
116
+ node.style.animationName = originalStylesRef.current.animationName;
117
+ }
118
+ setIsPresent(present);
119
+ }
120
+ }, [context.open, present]);
121
+ return /* @__PURE__ */ jsx(
122
+ Primitive.div,
123
+ {
124
+ "data-state": getState(context.open),
125
+ "data-disabled": context.disabled ? "" : void 0,
126
+ id: context.contentId,
127
+ hidden: !isOpen,
128
+ ...contentProps,
129
+ ref: composedRefs,
130
+ style: {
131
+ [`--radix-collapsible-content-height`]: height ? `${height}px` : void 0,
132
+ [`--radix-collapsible-content-width`]: width ? `${width}px` : void 0,
133
+ ...props.style
134
+ },
135
+ children: isOpen && children
136
+ }
137
+ );
138
+ });
139
+ function getState(open) {
140
+ return open ? "open" : "closed";
141
+ }
142
+ var Root = Collapsible;
143
+ var Trigger = CollapsibleTrigger;
144
+ var Content = CollapsibleContent;
145
+ export {
146
+ Collapsible,
147
+ CollapsibleContent,
148
+ CollapsibleTrigger,
149
+ Content,
150
+ Root,
151
+ Trigger,
152
+ createCollapsibleScope
153
+ };
154
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/Collapsible.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { Presence } from '@radix-ui/react-presence';\nimport { useId } from '@radix-ui/react-id';\n\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Collapsible\n * -----------------------------------------------------------------------------------------------*/\n\nconst COLLAPSIBLE_NAME = 'Collapsible';\n\ntype ScopedProps<P> = P & { __scopeCollapsible?: Scope };\nconst [createCollapsibleContext, createCollapsibleScope] = createContextScope(COLLAPSIBLE_NAME);\n\ntype CollapsibleContextValue = {\n contentId: string;\n disabled?: boolean;\n open: boolean;\n onOpenToggle(): void;\n};\n\nconst [CollapsibleProvider, useCollapsibleContext] =\n createCollapsibleContext<CollapsibleContextValue>(COLLAPSIBLE_NAME);\n\ntype CollapsibleElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface CollapsibleProps extends PrimitiveDivProps {\n defaultOpen?: boolean;\n open?: boolean;\n disabled?: boolean;\n onOpenChange?(open: boolean): void;\n}\n\nconst Collapsible = React.forwardRef<CollapsibleElement, CollapsibleProps>(\n (props: ScopedProps<CollapsibleProps>, forwardedRef) => {\n const {\n __scopeCollapsible,\n open: openProp,\n defaultOpen,\n disabled,\n onOpenChange,\n ...collapsibleProps\n } = props;\n\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n\n return (\n <CollapsibleProvider\n scope={__scopeCollapsible}\n disabled={disabled}\n contentId={useId()}\n open={open}\n onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])}\n >\n <Primitive.div\n data-state={getState(open)}\n data-disabled={disabled ? '' : undefined}\n {...collapsibleProps}\n ref={forwardedRef}\n />\n </CollapsibleProvider>\n );\n }\n);\n\nCollapsible.displayName = COLLAPSIBLE_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * CollapsibleTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'CollapsibleTrigger';\n\ntype CollapsibleTriggerElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface CollapsibleTriggerProps extends PrimitiveButtonProps {}\n\nconst CollapsibleTrigger = React.forwardRef<CollapsibleTriggerElement, CollapsibleTriggerProps>(\n (props: ScopedProps<CollapsibleTriggerProps>, forwardedRef) => {\n const { __scopeCollapsible, ...triggerProps } = props;\n const context = useCollapsibleContext(TRIGGER_NAME, __scopeCollapsible);\n return (\n <Primitive.button\n type=\"button\"\n aria-controls={context.contentId}\n aria-expanded={context.open || false}\n data-state={getState(context.open)}\n data-disabled={context.disabled ? '' : undefined}\n disabled={context.disabled}\n {...triggerProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, context.onOpenToggle)}\n />\n );\n }\n);\n\nCollapsibleTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * CollapsibleContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'CollapsibleContent';\n\ntype CollapsibleContentElement = CollapsibleContentImplElement;\ninterface CollapsibleContentProps extends Omit<CollapsibleContentImplProps, 'present'> {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst CollapsibleContent = React.forwardRef<CollapsibleContentElement, CollapsibleContentProps>(\n (props: ScopedProps<CollapsibleContentProps>, forwardedRef) => {\n const { forceMount, ...contentProps } = props;\n const context = useCollapsibleContext(CONTENT_NAME, props.__scopeCollapsible);\n return (\n <Presence present={forceMount || context.open}>\n {({ present }) => (\n <CollapsibleContentImpl {...contentProps} ref={forwardedRef} present={present} />\n )}\n </Presence>\n );\n }\n);\n\nCollapsibleContent.displayName = CONTENT_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype CollapsibleContentImplElement = React.ElementRef<typeof Primitive.div>;\ninterface CollapsibleContentImplProps extends PrimitiveDivProps {\n present: boolean;\n}\n\nconst CollapsibleContentImpl = React.forwardRef<\n CollapsibleContentImplElement,\n CollapsibleContentImplProps\n>((props: ScopedProps<CollapsibleContentImplProps>, forwardedRef) => {\n const { __scopeCollapsible, present, children, ...contentProps } = props;\n const context = useCollapsibleContext(CONTENT_NAME, __scopeCollapsible);\n const [isPresent, setIsPresent] = React.useState(present);\n const ref = React.useRef<CollapsibleContentImplElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const heightRef = React.useRef<number | undefined>(0);\n const height = heightRef.current;\n const widthRef = React.useRef<number | undefined>(0);\n const width = widthRef.current;\n // when opening we want it to immediately open to retrieve dimensions\n // when closing we delay `present` to retrieve dimensions before closing\n const isOpen = context.open || isPresent;\n const isMountAnimationPreventedRef = React.useRef(isOpen);\n const originalStylesRef = React.useRef<Record<string, string>>(undefined);\n\n React.useEffect(() => {\n const rAF = requestAnimationFrame(() => (isMountAnimationPreventedRef.current = false));\n return () => cancelAnimationFrame(rAF);\n }, []);\n\n useLayoutEffect(() => {\n const node = ref.current;\n if (node) {\n originalStylesRef.current = originalStylesRef.current || {\n transitionDuration: node.style.transitionDuration,\n animationName: node.style.animationName,\n };\n // block any animations/transitions so the element renders at its full dimensions\n node.style.transitionDuration = '0s';\n node.style.animationName = 'none';\n\n // get width and height from full dimensions\n const rect = node.getBoundingClientRect();\n heightRef.current = rect.height;\n widthRef.current = rect.width;\n\n // kick off any animations/transitions that were originally set up if it isn't the initial mount\n if (!isMountAnimationPreventedRef.current) {\n node.style.transitionDuration = originalStylesRef.current.transitionDuration;\n node.style.animationName = originalStylesRef.current.animationName;\n }\n\n setIsPresent(present);\n }\n /**\n * depends on `context.open` because it will change to `false`\n * when a close is triggered but `present` will be `false` on\n * animation end (so when close finishes). This allows us to\n * retrieve the dimensions *before* closing.\n */\n }, [context.open, present]);\n\n return (\n <Primitive.div\n data-state={getState(context.open)}\n data-disabled={context.disabled ? '' : undefined}\n id={context.contentId}\n hidden={!isOpen}\n {...contentProps}\n ref={composedRefs}\n style={{\n [`--radix-collapsible-content-height` as any]: height ? `${height}px` : undefined,\n [`--radix-collapsible-content-width` as any]: width ? `${width}px` : undefined,\n ...props.style,\n }}\n >\n {isOpen && children}\n </Primitive.div>\n );\n});\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open?: boolean) {\n return open ? 'open' : 'closed';\n}\n\nconst Root = Collapsible;\nconst Trigger = CollapsibleTrigger;\nconst Content = CollapsibleContent;\n\nexport {\n createCollapsibleScope,\n //\n Collapsible,\n CollapsibleTrigger,\n CollapsibleContent,\n //\n Root,\n Trigger,\n Content,\n};\nexport type { CollapsibleProps, CollapsibleTriggerProps, CollapsibleContentProps };\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7
+ "import": {
8
+ "types": "./dist/index.d.mts",
9
+ "default": "./dist/index.mjs"
10
+ },
11
+ "require": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ }
15
+ }
16
+ },
17
+ "source": "./src/index.ts",
18
+ "main": "./dist/index.js",
19
+ "module": "./dist/index.mjs",
20
+ "types": "./dist/index.d.ts",
21
+ "files": [
22
+ "dist",
23
+ "README.md"
24
+ ],
25
+ "sideEffects": false,
26
+ "scripts": {
27
+ "clean": "rm -rf dist"
28
+ },
29
+ "dependencies": {
30
+ "@radix-ui/primitive": "workspace:*",
31
+ "@radix-ui/react-compose-refs": "workspace:*",
32
+ "@radix-ui/react-context": "workspace:*",
33
+ "@radix-ui/react-id": "workspace:*",
34
+ "@radix-ui/react-presence": "workspace:*",
35
+ "@radix-ui/react-primitive": "workspace:*",
36
+ "@radix-ui/react-use-controllable-state": "workspace:*",
37
+ "@radix-ui/react-use-layout-effect": "workspace:*"
38
+ },
39
+ "peerDependencies": {
40
+ "@types/react": "*",
41
+ "@types/react-dom": "*",
42
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
43
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
44
+ },
45
+ "peerDependenciesMeta": {
46
+ "@types/react": {
47
+ "optional": true
48
+ },
49
+ "@types/react-dom": {
50
+ "optional": true
51
+ }
52
+ },
53
+ "homepage": "https://radix-ui.com/primitives",
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "git+https://github.com/radix-ui/primitives.git"
57
+ },
58
+ "bugs": {
59
+ "url": "https://github.com/radix-ui/primitives/issues"
60
+ }
61
+ }