@radix-ui/react-collapsible 1.0.3 → 1.1.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,32 +1,44 @@
1
- import * as React from "react";
2
- import * as Radix from "@radix-ui/react-primitive";
3
- import { Primitive } from "@radix-ui/react-primitive";
4
- export const createCollapsibleScope: import("@radix-ui/react-context").CreateScope;
5
- type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
6
- export interface CollapsibleProps extends PrimitiveDivProps {
1
+ import * as React from 'react';
2
+ import * as Radix from '@radix-ui/react-primitive';
3
+ import { Primitive } from '@radix-ui/react-primitive';
4
+
5
+ declare type Scope<C = any> = {
6
+ [scopeName: string]: React.Context<C>[];
7
+ } | undefined;
8
+ declare type ScopeHook = (scope: Scope) => {
9
+ [__scopeProp: string]: Scope;
10
+ };
11
+ interface CreateScope {
12
+ scopeName: string;
13
+ (): ScopeHook;
14
+ }
15
+
16
+ declare const createCollapsibleScope: CreateScope;
17
+ declare type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
18
+ interface CollapsibleProps extends PrimitiveDivProps {
7
19
  defaultOpen?: boolean;
8
20
  open?: boolean;
9
21
  disabled?: boolean;
10
22
  onOpenChange?(open: boolean): void;
11
23
  }
12
- export const Collapsible: React.ForwardRefExoticComponent<CollapsibleProps & React.RefAttributes<HTMLDivElement>>;
13
- type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;
14
- export interface CollapsibleTriggerProps extends PrimitiveButtonProps {
24
+ declare const Collapsible: React.ForwardRefExoticComponent<CollapsibleProps & React.RefAttributes<HTMLDivElement>>;
25
+ declare type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;
26
+ interface CollapsibleTriggerProps extends PrimitiveButtonProps {
15
27
  }
16
- export const CollapsibleTrigger: React.ForwardRefExoticComponent<CollapsibleTriggerProps & React.RefAttributes<HTMLButtonElement>>;
17
- export interface CollapsibleContentProps extends Omit<CollapsibleContentImplProps, 'present'> {
28
+ declare const CollapsibleTrigger: React.ForwardRefExoticComponent<CollapsibleTriggerProps & React.RefAttributes<HTMLButtonElement>>;
29
+ interface CollapsibleContentProps extends Omit<CollapsibleContentImplProps, 'present'> {
18
30
  /**
19
31
  * Used to force mounting when more control is needed. Useful when
20
32
  * controlling animation with React animation libraries.
21
33
  */
22
34
  forceMount?: true;
23
35
  }
24
- export const CollapsibleContent: React.ForwardRefExoticComponent<CollapsibleContentProps & React.RefAttributes<HTMLDivElement>>;
36
+ declare const CollapsibleContent: React.ForwardRefExoticComponent<CollapsibleContentProps & React.RefAttributes<HTMLDivElement>>;
25
37
  interface CollapsibleContentImplProps extends PrimitiveDivProps {
26
38
  present: boolean;
27
39
  }
28
- export const Root: React.ForwardRefExoticComponent<CollapsibleProps & React.RefAttributes<HTMLDivElement>>;
29
- export const Trigger: React.ForwardRefExoticComponent<CollapsibleTriggerProps & React.RefAttributes<HTMLButtonElement>>;
30
- export const Content: React.ForwardRefExoticComponent<CollapsibleContentProps & React.RefAttributes<HTMLDivElement>>;
40
+ declare const Root: React.ForwardRefExoticComponent<CollapsibleProps & React.RefAttributes<HTMLDivElement>>;
41
+ declare const Trigger: React.ForwardRefExoticComponent<CollapsibleTriggerProps & React.RefAttributes<HTMLButtonElement>>;
42
+ declare const Content: React.ForwardRefExoticComponent<CollapsibleContentProps & React.RefAttributes<HTMLDivElement>>;
31
43
 
32
- //# sourceMappingURL=index.d.ts.map
44
+ export { Collapsible, CollapsibleContent, type CollapsibleContentProps, type CollapsibleProps, CollapsibleTrigger, type CollapsibleTriggerProps, Content, Root, Trigger, createCollapsibleScope };
package/dist/index.d.ts CHANGED
@@ -1,32 +1,44 @@
1
- import * as React from "react";
2
- import * as Radix from "@radix-ui/react-primitive";
3
- import { Primitive } from "@radix-ui/react-primitive";
4
- export const createCollapsibleScope: import("@radix-ui/react-context").CreateScope;
5
- type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
6
- export interface CollapsibleProps extends PrimitiveDivProps {
1
+ import * as React from 'react';
2
+ import * as Radix from '@radix-ui/react-primitive';
3
+ import { Primitive } from '@radix-ui/react-primitive';
4
+
5
+ declare type Scope<C = any> = {
6
+ [scopeName: string]: React.Context<C>[];
7
+ } | undefined;
8
+ declare type ScopeHook = (scope: Scope) => {
9
+ [__scopeProp: string]: Scope;
10
+ };
11
+ interface CreateScope {
12
+ scopeName: string;
13
+ (): ScopeHook;
14
+ }
15
+
16
+ declare const createCollapsibleScope: CreateScope;
17
+ declare type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
18
+ interface CollapsibleProps extends PrimitiveDivProps {
7
19
  defaultOpen?: boolean;
8
20
  open?: boolean;
9
21
  disabled?: boolean;
10
22
  onOpenChange?(open: boolean): void;
11
23
  }
12
- export const Collapsible: React.ForwardRefExoticComponent<CollapsibleProps & React.RefAttributes<HTMLDivElement>>;
13
- type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;
14
- export interface CollapsibleTriggerProps extends PrimitiveButtonProps {
24
+ declare const Collapsible: React.ForwardRefExoticComponent<CollapsibleProps & React.RefAttributes<HTMLDivElement>>;
25
+ declare type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;
26
+ interface CollapsibleTriggerProps extends PrimitiveButtonProps {
15
27
  }
16
- export const CollapsibleTrigger: React.ForwardRefExoticComponent<CollapsibleTriggerProps & React.RefAttributes<HTMLButtonElement>>;
17
- export interface CollapsibleContentProps extends Omit<CollapsibleContentImplProps, 'present'> {
28
+ declare const CollapsibleTrigger: React.ForwardRefExoticComponent<CollapsibleTriggerProps & React.RefAttributes<HTMLButtonElement>>;
29
+ interface CollapsibleContentProps extends Omit<CollapsibleContentImplProps, 'present'> {
18
30
  /**
19
31
  * Used to force mounting when more control is needed. Useful when
20
32
  * controlling animation with React animation libraries.
21
33
  */
22
34
  forceMount?: true;
23
35
  }
24
- export const CollapsibleContent: React.ForwardRefExoticComponent<CollapsibleContentProps & React.RefAttributes<HTMLDivElement>>;
36
+ declare const CollapsibleContent: React.ForwardRefExoticComponent<CollapsibleContentProps & React.RefAttributes<HTMLDivElement>>;
25
37
  interface CollapsibleContentImplProps extends PrimitiveDivProps {
26
38
  present: boolean;
27
39
  }
28
- export const Root: React.ForwardRefExoticComponent<CollapsibleProps & React.RefAttributes<HTMLDivElement>>;
29
- export const Trigger: React.ForwardRefExoticComponent<CollapsibleTriggerProps & React.RefAttributes<HTMLButtonElement>>;
30
- export const Content: React.ForwardRefExoticComponent<CollapsibleContentProps & React.RefAttributes<HTMLDivElement>>;
40
+ declare const Root: React.ForwardRefExoticComponent<CollapsibleProps & React.RefAttributes<HTMLDivElement>>;
41
+ declare const Trigger: React.ForwardRefExoticComponent<CollapsibleTriggerProps & React.RefAttributes<HTMLButtonElement>>;
42
+ declare const Content: React.ForwardRefExoticComponent<CollapsibleContentProps & React.RefAttributes<HTMLDivElement>>;
31
43
 
32
- //# sourceMappingURL=index.d.ts.map
44
+ export { Collapsible, CollapsibleContent, type CollapsibleContentProps, type CollapsibleProps, CollapsibleTrigger, type CollapsibleTriggerProps, Content, Root, Trigger, createCollapsibleScope };
package/dist/index.js CHANGED
@@ -1,177 +1,176 @@
1
- var $f0mF1$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
2
- var $f0mF1$react = require("react");
3
- var $f0mF1$radixuiprimitive = require("@radix-ui/primitive");
4
- var $f0mF1$radixuireactcontext = require("@radix-ui/react-context");
5
- var $f0mF1$radixuireactusecontrollablestate = require("@radix-ui/react-use-controllable-state");
6
- var $f0mF1$radixuireactuselayouteffect = require("@radix-ui/react-use-layout-effect");
7
- var $f0mF1$radixuireactcomposerefs = require("@radix-ui/react-compose-refs");
8
- var $f0mF1$radixuireactprimitive = require("@radix-ui/react-primitive");
9
- var $f0mF1$radixuireactpresence = require("@radix-ui/react-presence");
10
- var $f0mF1$radixuireactid = require("@radix-ui/react-id");
11
-
12
- function $parcel$export(e, n, v, s) {
13
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
14
- }
15
- function $parcel$interopDefault(a) {
16
- return a && a.__esModule ? a.default : a;
17
- }
18
-
19
- $parcel$export(module.exports, "createCollapsibleScope", () => $e729681ae85df948$export$952b32dcbe73087a);
20
- $parcel$export(module.exports, "Collapsible", () => $e729681ae85df948$export$6eb0f7ddcda6131f);
21
- $parcel$export(module.exports, "CollapsibleTrigger", () => $e729681ae85df948$export$c135dce7b15bbbdc);
22
- $parcel$export(module.exports, "CollapsibleContent", () => $e729681ae85df948$export$aadde00976f34151);
23
- $parcel$export(module.exports, "Root", () => $e729681ae85df948$export$be92b6f5f03c0fe9);
24
- $parcel$export(module.exports, "Trigger", () => $e729681ae85df948$export$41fb9f06171c75f4);
25
- $parcel$export(module.exports, "Content", () => $e729681ae85df948$export$7c6e2c02157bb7d2);
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
- /* -------------------------------------------------------------------------------------------------
37
- * Collapsible
38
- * -----------------------------------------------------------------------------------------------*/ const $e729681ae85df948$var$COLLAPSIBLE_NAME = 'Collapsible';
39
- const [$e729681ae85df948$var$createCollapsibleContext, $e729681ae85df948$export$952b32dcbe73087a] = $f0mF1$radixuireactcontext.createContextScope($e729681ae85df948$var$COLLAPSIBLE_NAME);
40
- const [$e729681ae85df948$var$CollapsibleProvider, $e729681ae85df948$var$useCollapsibleContext] = $e729681ae85df948$var$createCollapsibleContext($e729681ae85df948$var$COLLAPSIBLE_NAME);
41
- const $e729681ae85df948$export$6eb0f7ddcda6131f = /*#__PURE__*/ $f0mF1$react.forwardRef((props, forwardedRef)=>{
42
- const { __scopeCollapsible: __scopeCollapsible , open: openProp , defaultOpen: defaultOpen , disabled: disabled , onOpenChange: onOpenChange , ...collapsibleProps } = props;
43
- const [open = false, setOpen] = $f0mF1$radixuireactusecontrollablestate.useControllableState({
1
+ "use strict";
2
+ "use client";
3
+ (() => {
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
11
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
12
+ }) : x)(function(x) {
13
+ if (typeof require !== "undefined") return require.apply(this, arguments);
14
+ throw Error('Dynamic require of "' + x + '" is not supported');
15
+ });
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
32
+
33
+ // packages/react/collapsible/src/Collapsible.tsx
34
+ var React = __toESM(__require("react"));
35
+ var import_primitive = __require("@radix-ui/primitive");
36
+ var import_react_context = __require("@radix-ui/react-context");
37
+ var import_react_use_controllable_state = __require("@radix-ui/react-use-controllable-state");
38
+ var import_react_use_layout_effect = __require("@radix-ui/react-use-layout-effect");
39
+ var import_react_compose_refs = __require("@radix-ui/react-compose-refs");
40
+ var import_react_primitive = __require("@radix-ui/react-primitive");
41
+ var import_react_presence = __require("@radix-ui/react-presence");
42
+ var import_react_id = __require("@radix-ui/react-id");
43
+ var import_jsx_runtime = __require("react/jsx-runtime");
44
+ var COLLAPSIBLE_NAME = "Collapsible";
45
+ var [createCollapsibleContext, createCollapsibleScope] = (0, import_react_context.createContextScope)(COLLAPSIBLE_NAME);
46
+ var [CollapsibleProvider, useCollapsibleContext] = createCollapsibleContext(COLLAPSIBLE_NAME);
47
+ var Collapsible = React.forwardRef(
48
+ (props, forwardedRef) => {
49
+ const {
50
+ __scopeCollapsible,
51
+ open: openProp,
52
+ defaultOpen,
53
+ disabled,
54
+ onOpenChange,
55
+ ...collapsibleProps
56
+ } = props;
57
+ const [open = false, setOpen] = (0, import_react_use_controllable_state.useControllableState)({
44
58
  prop: openProp,
45
59
  defaultProp: defaultOpen,
46
60
  onChange: onOpenChange
47
- });
48
- return /*#__PURE__*/ $f0mF1$react.createElement($e729681ae85df948$var$CollapsibleProvider, {
49
- scope: __scopeCollapsible,
50
- disabled: disabled,
51
- contentId: $f0mF1$radixuireactid.useId(),
52
- open: open,
53
- onOpenToggle: $f0mF1$react.useCallback(()=>setOpen((prevOpen)=>!prevOpen
54
- )
55
- , [
56
- setOpen
57
- ])
58
- }, /*#__PURE__*/ $f0mF1$react.createElement($f0mF1$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($f0mF1$babelruntimehelpersextends))({
59
- "data-state": $e729681ae85df948$var$getState(open),
60
- "data-disabled": disabled ? '' : undefined
61
- }, collapsibleProps, {
62
- ref: forwardedRef
63
- })));
64
- });
65
- /*#__PURE__*/ Object.assign($e729681ae85df948$export$6eb0f7ddcda6131f, {
66
- displayName: $e729681ae85df948$var$COLLAPSIBLE_NAME
67
- });
68
- /* -------------------------------------------------------------------------------------------------
69
- * CollapsibleTrigger
70
- * -----------------------------------------------------------------------------------------------*/ const $e729681ae85df948$var$TRIGGER_NAME = 'CollapsibleTrigger';
71
- const $e729681ae85df948$export$c135dce7b15bbbdc = /*#__PURE__*/ $f0mF1$react.forwardRef((props, forwardedRef)=>{
72
- const { __scopeCollapsible: __scopeCollapsible , ...triggerProps } = props;
73
- const context = $e729681ae85df948$var$useCollapsibleContext($e729681ae85df948$var$TRIGGER_NAME, __scopeCollapsible);
74
- return /*#__PURE__*/ $f0mF1$react.createElement($f0mF1$radixuireactprimitive.Primitive.button, ($parcel$interopDefault($f0mF1$babelruntimehelpersextends))({
75
- type: "button",
76
- "aria-controls": context.contentId,
77
- "aria-expanded": context.open || false,
78
- "data-state": $e729681ae85df948$var$getState(context.open),
79
- "data-disabled": context.disabled ? '' : undefined,
80
- disabled: context.disabled
81
- }, triggerProps, {
82
- ref: forwardedRef,
83
- onClick: $f0mF1$radixuiprimitive.composeEventHandlers(props.onClick, context.onOpenToggle)
84
- }));
85
- });
86
- /*#__PURE__*/ Object.assign($e729681ae85df948$export$c135dce7b15bbbdc, {
87
- displayName: $e729681ae85df948$var$TRIGGER_NAME
88
- });
89
- /* -------------------------------------------------------------------------------------------------
90
- * CollapsibleContent
91
- * -----------------------------------------------------------------------------------------------*/ const $e729681ae85df948$var$CONTENT_NAME = 'CollapsibleContent';
92
- const $e729681ae85df948$export$aadde00976f34151 = /*#__PURE__*/ $f0mF1$react.forwardRef((props, forwardedRef)=>{
93
- const { forceMount: forceMount , ...contentProps } = props;
94
- const context = $e729681ae85df948$var$useCollapsibleContext($e729681ae85df948$var$CONTENT_NAME, props.__scopeCollapsible);
95
- return /*#__PURE__*/ $f0mF1$react.createElement($f0mF1$radixuireactpresence.Presence, {
96
- present: forceMount || context.open
97
- }, ({ present: present })=>/*#__PURE__*/ $f0mF1$react.createElement($e729681ae85df948$var$CollapsibleContentImpl, ($parcel$interopDefault($f0mF1$babelruntimehelpersextends))({}, contentProps, {
98
- ref: forwardedRef,
99
- present: present
100
- }))
101
- );
102
- });
103
- /*#__PURE__*/ Object.assign($e729681ae85df948$export$aadde00976f34151, {
104
- displayName: $e729681ae85df948$var$CONTENT_NAME
105
- });
106
- /* -----------------------------------------------------------------------------------------------*/ const $e729681ae85df948$var$CollapsibleContentImpl = /*#__PURE__*/ $f0mF1$react.forwardRef((props, forwardedRef)=>{
107
- const { __scopeCollapsible: __scopeCollapsible , present: present , children: children , ...contentProps } = props;
108
- const context = $e729681ae85df948$var$useCollapsibleContext($e729681ae85df948$var$CONTENT_NAME, __scopeCollapsible);
109
- const [isPresent, setIsPresent] = $f0mF1$react.useState(present);
110
- const ref = $f0mF1$react.useRef(null);
111
- const composedRefs = $f0mF1$radixuireactcomposerefs.useComposedRefs(forwardedRef, ref);
112
- const heightRef = $f0mF1$react.useRef(0);
61
+ });
62
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
63
+ CollapsibleProvider,
64
+ {
65
+ scope: __scopeCollapsible,
66
+ disabled,
67
+ contentId: (0, import_react_id.useId)(),
68
+ open,
69
+ onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
70
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
71
+ import_react_primitive.Primitive.div,
72
+ {
73
+ "data-state": getState(open),
74
+ "data-disabled": disabled ? "" : void 0,
75
+ ...collapsibleProps,
76
+ ref: forwardedRef
77
+ }
78
+ )
79
+ }
80
+ );
81
+ }
82
+ );
83
+ Collapsible.displayName = COLLAPSIBLE_NAME;
84
+ var TRIGGER_NAME = "CollapsibleTrigger";
85
+ var CollapsibleTrigger = React.forwardRef(
86
+ (props, forwardedRef) => {
87
+ const { __scopeCollapsible, ...triggerProps } = props;
88
+ const context = useCollapsibleContext(TRIGGER_NAME, __scopeCollapsible);
89
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
90
+ import_react_primitive.Primitive.button,
91
+ {
92
+ type: "button",
93
+ "aria-controls": context.contentId,
94
+ "aria-expanded": context.open || false,
95
+ "data-state": getState(context.open),
96
+ "data-disabled": context.disabled ? "" : void 0,
97
+ disabled: context.disabled,
98
+ ...triggerProps,
99
+ ref: forwardedRef,
100
+ onClick: (0, import_primitive.composeEventHandlers)(props.onClick, context.onOpenToggle)
101
+ }
102
+ );
103
+ }
104
+ );
105
+ CollapsibleTrigger.displayName = TRIGGER_NAME;
106
+ var CONTENT_NAME = "CollapsibleContent";
107
+ var CollapsibleContent = React.forwardRef(
108
+ (props, forwardedRef) => {
109
+ const { forceMount, ...contentProps } = props;
110
+ const context = useCollapsibleContext(CONTENT_NAME, props.__scopeCollapsible);
111
+ 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 }) });
112
+ }
113
+ );
114
+ CollapsibleContent.displayName = CONTENT_NAME;
115
+ var CollapsibleContentImpl = React.forwardRef((props, forwardedRef) => {
116
+ const { __scopeCollapsible, present, children, ...contentProps } = props;
117
+ const context = useCollapsibleContext(CONTENT_NAME, __scopeCollapsible);
118
+ const [isPresent, setIsPresent] = React.useState(present);
119
+ const ref = React.useRef(null);
120
+ const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, ref);
121
+ const heightRef = React.useRef(0);
113
122
  const height = heightRef.current;
114
- const widthRef = $f0mF1$react.useRef(0);
115
- const width = widthRef.current; // when opening we want it to immediately open to retrieve dimensions
116
- // when closing we delay `present` to retrieve dimensions before closing
123
+ const widthRef = React.useRef(0);
124
+ const width = widthRef.current;
117
125
  const isOpen = context.open || isPresent;
118
- const isMountAnimationPreventedRef = $f0mF1$react.useRef(isOpen);
119
- const originalStylesRef = $f0mF1$react.useRef();
120
- $f0mF1$react.useEffect(()=>{
121
- const rAF = requestAnimationFrame(()=>isMountAnimationPreventedRef.current = false
122
- );
123
- return ()=>cancelAnimationFrame(rAF)
124
- ;
126
+ const isMountAnimationPreventedRef = React.useRef(isOpen);
127
+ const originalStylesRef = React.useRef();
128
+ React.useEffect(() => {
129
+ const rAF = requestAnimationFrame(() => isMountAnimationPreventedRef.current = false);
130
+ return () => cancelAnimationFrame(rAF);
125
131
  }, []);
126
- $f0mF1$radixuireactuselayouteffect.useLayoutEffect(()=>{
127
- const node = ref.current;
128
- if (node) {
129
- originalStylesRef.current = originalStylesRef.current || {
130
- transitionDuration: node.style.transitionDuration,
131
- animationName: node.style.animationName
132
- }; // block any animations/transitions so the element renders at its full dimensions
133
- node.style.transitionDuration = '0s';
134
- node.style.animationName = 'none'; // get width and height from full dimensions
135
- const rect = node.getBoundingClientRect();
136
- heightRef.current = rect.height;
137
- widthRef.current = rect.width; // kick off any animations/transitions that were originally set up if it isn't the initial mount
138
- if (!isMountAnimationPreventedRef.current) {
139
- node.style.transitionDuration = originalStylesRef.current.transitionDuration;
140
- node.style.animationName = originalStylesRef.current.animationName;
141
- }
142
- setIsPresent(present);
132
+ (0, import_react_use_layout_effect.useLayoutEffect)(() => {
133
+ const node = ref.current;
134
+ if (node) {
135
+ originalStylesRef.current = originalStylesRef.current || {
136
+ transitionDuration: node.style.transitionDuration,
137
+ animationName: node.style.animationName
138
+ };
139
+ node.style.transitionDuration = "0s";
140
+ node.style.animationName = "none";
141
+ const rect = node.getBoundingClientRect();
142
+ heightRef.current = rect.height;
143
+ widthRef.current = rect.width;
144
+ if (!isMountAnimationPreventedRef.current) {
145
+ node.style.transitionDuration = originalStylesRef.current.transitionDuration;
146
+ node.style.animationName = originalStylesRef.current.animationName;
143
147
  }
144
- /**
145
- * depends on `context.open` because it will change to `false`
146
- * when a close is triggered but `present` will be `false` on
147
- * animation end (so when close finishes). This allows us to
148
- * retrieve the dimensions *before* closing.
149
- */ }, [
150
- context.open,
151
- present
152
- ]);
153
- return /*#__PURE__*/ $f0mF1$react.createElement($f0mF1$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($f0mF1$babelruntimehelpersextends))({
154
- "data-state": $e729681ae85df948$var$getState(context.open),
155
- "data-disabled": context.disabled ? '' : undefined,
148
+ setIsPresent(present);
149
+ }
150
+ }, [context.open, present]);
151
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
152
+ import_react_primitive.Primitive.div,
153
+ {
154
+ "data-state": getState(context.open),
155
+ "data-disabled": context.disabled ? "" : void 0,
156
156
  id: context.contentId,
157
- hidden: !isOpen
158
- }, contentProps, {
157
+ hidden: !isOpen,
158
+ ...contentProps,
159
159
  ref: composedRefs,
160
160
  style: {
161
- [`--radix-collapsible-content-height`]: height ? `${height}px` : undefined,
162
- [`--radix-collapsible-content-width`]: width ? `${width}px` : undefined,
163
- ...props.style
164
- }
165
- }), isOpen && children);
166
- });
167
- /* -----------------------------------------------------------------------------------------------*/ function $e729681ae85df948$var$getState(open) {
168
- return open ? 'open' : 'closed';
169
- }
170
- const $e729681ae85df948$export$be92b6f5f03c0fe9 = $e729681ae85df948$export$6eb0f7ddcda6131f;
171
- const $e729681ae85df948$export$41fb9f06171c75f4 = $e729681ae85df948$export$c135dce7b15bbbdc;
172
- const $e729681ae85df948$export$7c6e2c02157bb7d2 = $e729681ae85df948$export$aadde00976f34151;
173
-
174
-
175
-
176
-
161
+ [`--radix-collapsible-content-height`]: height ? `${height}px` : void 0,
162
+ [`--radix-collapsible-content-width`]: width ? `${width}px` : void 0,
163
+ ...props.style
164
+ },
165
+ children: isOpen && children
166
+ }
167
+ );
168
+ });
169
+ function getState(open) {
170
+ return open ? "open" : "closed";
171
+ }
172
+ var Root = Collapsible;
173
+ var Trigger = CollapsibleTrigger;
174
+ var Content = CollapsibleContent;
175
+ })();
177
176
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1,7 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;A;;;;;;;;;;ACaA;;oGAEA,CAEA,MAAMgB,sCAAgB,GAAG,aAAzB,AAAA;AAGA,MAAM,CAACC,8CAAD,EAA2BjB,yCAA3B,CAAA,GAAqDS,6CAAkB,CAACO,sCAAD,CAA7E,AAAA;AASA,MAAM,CAACE,yCAAD,EAAsBC,2CAAtB,CAAA,GACJF,8CAAwB,CAA0BD,sCAA1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B,YAAY,CAACJ,OAAD,CAAZ,CAAAI;SACD;IACD;;;;;OAKJ,EA7BiB,EA8BZ;QAACX,OAAO,CAAChB,IAAT;QAAeuB,OAAf;KA9BY,CAAf,CA8BC;IAED,OAAA,aACE,CAAA,0BAAA,CAAC,sCAAD,CAAW,GAAX,EADF,2DAAA,CAAA;QAEI,YAAA,EAAYX,8BAAQ,CAACI,OAAO,CAAChB,IAAT,CADtB;QAEE,eAAA,EAAegB,OAAO,CAACb,QAAR,GAAmB,EAAnB,GAAwBU,SAFzC;QAGE,EAAE,EAAEG,OAAO,CAACC,SAHd;QAIE,MAAM,EAAE,CAACoB,MAAT;KAJF,EAKMf,YALN,EAAA;QAME,GAAG,EAAES,YANP;QAOE,KAAK,EAAE;YACL,CAAE,CAAA,kCAAA,CAAF,CAAA,EAA+CE,MAAM,GAAI,CAAA,EAAEA,MAAO,CAAA,EAAA,CAAb,GAAmBpB,SADnE;YAEL,CAAE,CAAA,iCAAA,CAAF,CAAA,EAA8CuB,KAAK,GAAI,CAAA,EAAEA,KAAM,CAAA,EAAA,CAAZ,GAAkBvB,SAFhE;YAGL,GAAGhB,KAAK,CAACiD,KAAT;SAHK;KAPT,CAAA,EAaGT,MAAM,IAAIZ,QAbb,CADF,CACE;CAzD2B,CAA/B,AAyEC;AAED,oGAAA,CAEA,SAASb,8BAAT,CAAkBZ,IAAlB,EAAkC;IAChC,OAAOA,IAAI,GAAG,MAAH,GAAY,QAAvB,CAAA;CACD;AAED,MAAMpB,yCAAI,GAAGH,yCAAb,AAAA;AACA,MAAMI,yCAAO,GAAGH,yCAAhB,AAAA;AACA,MAAMI,yCAAO,GAAGH,yCAAhB,AAAA;;ADxOA","sources":["packages/react/collapsible/src/index.ts","packages/react/collapsible/src/Collapsible.tsx"],"sourcesContent":["export {\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 * as Radix from '@radix-ui/react-primitive';\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 = Radix.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 = Radix.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>>();\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"],"names":["createCollapsibleScope","Collapsible","CollapsibleTrigger","CollapsibleContent","Root","Trigger","Content","React","composeEventHandlers","createContextScope","useControllableState","useLayoutEffect","useComposedRefs","Primitive","Presence","useId","COLLAPSIBLE_NAME","createCollapsibleContext","CollapsibleProvider","useCollapsibleContext","forwardRef","props","forwardedRef","__scopeCollapsible","open","openProp","defaultOpen","disabled","onOpenChange","collapsibleProps","setOpen","prop","defaultProp","onChange","useCallback","prevOpen","getState","undefined","TRIGGER_NAME","triggerProps","context","contentId","onClick","onOpenToggle","CONTENT_NAME","forceMount","contentProps","present","CollapsibleContentImpl","children","isPresent","setIsPresent","useState","ref","useRef","composedRefs","heightRef","height","current","widthRef","width","isOpen","isMountAnimationPreventedRef","originalStylesRef","useEffect","rAF","requestAnimationFrame","cancelAnimationFrame","node","transitionDuration","style","animationName","rect","getBoundingClientRect"],"version":3,"file":"index.js.map"}
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 * as Radix from '@radix-ui/react-primitive';\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 = Radix.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 = Radix.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>>();\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,cAAuB;AACvB,yBAAqC;AACrC,6BAAmC;AACnC,4CAAqC;AACrC,uCAAgC;AAChC,kCAAgC;AAChC,+BAA0B;AAC1B,8BAAyB;AACzB,wBAAsB;AA0Dd;AAjDR,MAAM,mBAAmB;AAGzB,MAAM,CAAC,0BAA0B,sBAAsB,QAAI,yCAAmB,gBAAgB;AAS9F,MAAM,CAAC,qBAAqB,qBAAqB,IAC/C,yBAAkD,gBAAgB;AAWpE,MAAM,cAAoB;AAAA,IACxB,CAAC,OAAsC,iBAAiB;AACtD,YAAM;AAAA,QACJ;AAAA,QACA,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA,G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AA,QACvD;AAEA,qBAAa,OAAO;AAAA,MACtB;AAAA,IAOF,GAAG,CAAC,QAAQ,MAAM,OAAO,CAAC;AAE1B,WACE;AAAA,MAAC,iCAAU;AAAA,MAAV;AAAA,QACC,cAAY,SAAS,QAAQ,IAAI;AAAA,QACjC,iBAAe,QAAQ,WAAW,KAAK;AAAA,QACvC,IAAI,QAAQ;AAAA,QACZ,QAAQ,CAAC;AAAA,QACR,GAAG;AAAA,QACJ,KAAK;AAAA,QACL,OAAO;AAAA,UACL,CAAC,oCAA2C,GAAG,SAAS,GAAG,MAAM,OAAO;AAAA,UACxE,CAAC,mCAA0C,GAAG,QAAQ,GAAG,KAAK,OAAO;AAAA,UACrE,GAAG,MAAM;AAAA,QACX;AAAA,QAEC,oBAAU;AAAA;AAAA,IACb;AAAA,EAEJ,CAAC;AAID,WAAS,SAAS,MAAgB;AAChC,WAAO,OAAO,SAAS;AAAA,EACzB;AAEA,MAAM,OAAO;AACb,MAAM,UAAU;AAChB,MAAM,UAAU;",
6
+ "names": []
7
+ }
package/dist/index.mjs CHANGED
@@ -1,164 +1,154 @@
1
- import $73KQ4$babelruntimehelpersesmextends from "@babel/runtime/helpers/esm/extends";
2
- import {forwardRef as $73KQ4$forwardRef, createElement as $73KQ4$createElement, useCallback as $73KQ4$useCallback, useState as $73KQ4$useState, useRef as $73KQ4$useRef, useEffect as $73KQ4$useEffect} from "react";
3
- import {composeEventHandlers as $73KQ4$composeEventHandlers} from "@radix-ui/primitive";
4
- import {createContextScope as $73KQ4$createContextScope} from "@radix-ui/react-context";
5
- import {useControllableState as $73KQ4$useControllableState} from "@radix-ui/react-use-controllable-state";
6
- import {useLayoutEffect as $73KQ4$useLayoutEffect} from "@radix-ui/react-use-layout-effect";
7
- import {useComposedRefs as $73KQ4$useComposedRefs} from "@radix-ui/react-compose-refs";
8
- import {Primitive as $73KQ4$Primitive} from "@radix-ui/react-primitive";
9
- import {Presence as $73KQ4$Presence} from "@radix-ui/react-presence";
10
- import {useId as $73KQ4$useId} from "@radix-ui/react-id";
1
+ "use client";
11
2
 
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
- /* -------------------------------------------------------------------------------------------------
23
- * Collapsible
24
- * -----------------------------------------------------------------------------------------------*/ const $409067139f391064$var$COLLAPSIBLE_NAME = 'Collapsible';
25
- const [$409067139f391064$var$createCollapsibleContext, $409067139f391064$export$952b32dcbe73087a] = $73KQ4$createContextScope($409067139f391064$var$COLLAPSIBLE_NAME);
26
- const [$409067139f391064$var$CollapsibleProvider, $409067139f391064$var$useCollapsibleContext] = $409067139f391064$var$createCollapsibleContext($409067139f391064$var$COLLAPSIBLE_NAME);
27
- const $409067139f391064$export$6eb0f7ddcda6131f = /*#__PURE__*/ $73KQ4$forwardRef((props, forwardedRef)=>{
28
- const { __scopeCollapsible: __scopeCollapsible , open: openProp , defaultOpen: defaultOpen , disabled: disabled , onOpenChange: onOpenChange , ...collapsibleProps } = props;
29
- const [open = false, setOpen] = $73KQ4$useControllableState({
30
- prop: openProp,
31
- defaultProp: defaultOpen,
32
- onChange: onOpenChange
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
33
31
  });
34
- return /*#__PURE__*/ $73KQ4$createElement($409067139f391064$var$CollapsibleProvider, {
32
+ return /* @__PURE__ */ jsx(
33
+ CollapsibleProvider,
34
+ {
35
35
  scope: __scopeCollapsible,
36
- disabled: disabled,
37
- contentId: $73KQ4$useId(),
38
- open: open,
39
- onOpenToggle: $73KQ4$useCallback(()=>setOpen((prevOpen)=>!prevOpen
40
- )
41
- , [
42
- setOpen
43
- ])
44
- }, /*#__PURE__*/ $73KQ4$createElement($73KQ4$Primitive.div, $73KQ4$babelruntimehelpersesmextends({
45
- "data-state": $409067139f391064$var$getState(open),
46
- "data-disabled": disabled ? '' : undefined
47
- }, collapsibleProps, {
48
- ref: forwardedRef
49
- })));
50
- });
51
- /*#__PURE__*/ Object.assign($409067139f391064$export$6eb0f7ddcda6131f, {
52
- displayName: $409067139f391064$var$COLLAPSIBLE_NAME
53
- });
54
- /* -------------------------------------------------------------------------------------------------
55
- * CollapsibleTrigger
56
- * -----------------------------------------------------------------------------------------------*/ const $409067139f391064$var$TRIGGER_NAME = 'CollapsibleTrigger';
57
- const $409067139f391064$export$c135dce7b15bbbdc = /*#__PURE__*/ $73KQ4$forwardRef((props, forwardedRef)=>{
58
- const { __scopeCollapsible: __scopeCollapsible , ...triggerProps } = props;
59
- const context = $409067139f391064$var$useCollapsibleContext($409067139f391064$var$TRIGGER_NAME, __scopeCollapsible);
60
- return /*#__PURE__*/ $73KQ4$createElement($73KQ4$Primitive.button, $73KQ4$babelruntimehelpersesmextends({
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
+ {
61
62
  type: "button",
62
63
  "aria-controls": context.contentId,
63
64
  "aria-expanded": context.open || false,
64
- "data-state": $409067139f391064$var$getState(context.open),
65
- "data-disabled": context.disabled ? '' : undefined,
66
- disabled: context.disabled
67
- }, triggerProps, {
65
+ "data-state": getState(context.open),
66
+ "data-disabled": context.disabled ? "" : void 0,
67
+ disabled: context.disabled,
68
+ ...triggerProps,
68
69
  ref: forwardedRef,
69
- onClick: $73KQ4$composeEventHandlers(props.onClick, context.onOpenToggle)
70
- }));
71
- });
72
- /*#__PURE__*/ Object.assign($409067139f391064$export$c135dce7b15bbbdc, {
73
- displayName: $409067139f391064$var$TRIGGER_NAME
74
- });
75
- /* -------------------------------------------------------------------------------------------------
76
- * CollapsibleContent
77
- * -----------------------------------------------------------------------------------------------*/ const $409067139f391064$var$CONTENT_NAME = 'CollapsibleContent';
78
- const $409067139f391064$export$aadde00976f34151 = /*#__PURE__*/ $73KQ4$forwardRef((props, forwardedRef)=>{
79
- const { forceMount: forceMount , ...contentProps } = props;
80
- const context = $409067139f391064$var$useCollapsibleContext($409067139f391064$var$CONTENT_NAME, props.__scopeCollapsible);
81
- return /*#__PURE__*/ $73KQ4$createElement($73KQ4$Presence, {
82
- present: forceMount || context.open
83
- }, ({ present: present })=>/*#__PURE__*/ $73KQ4$createElement($409067139f391064$var$CollapsibleContentImpl, $73KQ4$babelruntimehelpersesmextends({}, contentProps, {
84
- ref: forwardedRef,
85
- present: present
86
- }))
70
+ onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
71
+ }
87
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();
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
+ );
88
138
  });
89
- /*#__PURE__*/ Object.assign($409067139f391064$export$aadde00976f34151, {
90
- displayName: $409067139f391064$var$CONTENT_NAME
91
- });
92
- /* -----------------------------------------------------------------------------------------------*/ const $409067139f391064$var$CollapsibleContentImpl = /*#__PURE__*/ $73KQ4$forwardRef((props, forwardedRef)=>{
93
- const { __scopeCollapsible: __scopeCollapsible , present: present , children: children , ...contentProps } = props;
94
- const context = $409067139f391064$var$useCollapsibleContext($409067139f391064$var$CONTENT_NAME, __scopeCollapsible);
95
- const [isPresent, setIsPresent] = $73KQ4$useState(present);
96
- const ref = $73KQ4$useRef(null);
97
- const composedRefs = $73KQ4$useComposedRefs(forwardedRef, ref);
98
- const heightRef = $73KQ4$useRef(0);
99
- const height = heightRef.current;
100
- const widthRef = $73KQ4$useRef(0);
101
- const width = widthRef.current; // when opening we want it to immediately open to retrieve dimensions
102
- // when closing we delay `present` to retrieve dimensions before closing
103
- const isOpen = context.open || isPresent;
104
- const isMountAnimationPreventedRef = $73KQ4$useRef(isOpen);
105
- const originalStylesRef = $73KQ4$useRef();
106
- $73KQ4$useEffect(()=>{
107
- const rAF = requestAnimationFrame(()=>isMountAnimationPreventedRef.current = false
108
- );
109
- return ()=>cancelAnimationFrame(rAF)
110
- ;
111
- }, []);
112
- $73KQ4$useLayoutEffect(()=>{
113
- const node = ref.current;
114
- if (node) {
115
- originalStylesRef.current = originalStylesRef.current || {
116
- transitionDuration: node.style.transitionDuration,
117
- animationName: node.style.animationName
118
- }; // block any animations/transitions so the element renders at its full dimensions
119
- node.style.transitionDuration = '0s';
120
- node.style.animationName = 'none'; // get width and height from full dimensions
121
- const rect = node.getBoundingClientRect();
122
- heightRef.current = rect.height;
123
- widthRef.current = rect.width; // kick off any animations/transitions that were originally set up if it isn't the initial mount
124
- if (!isMountAnimationPreventedRef.current) {
125
- node.style.transitionDuration = originalStylesRef.current.transitionDuration;
126
- node.style.animationName = originalStylesRef.current.animationName;
127
- }
128
- setIsPresent(present);
129
- }
130
- /**
131
- * depends on `context.open` because it will change to `false`
132
- * when a close is triggered but `present` will be `false` on
133
- * animation end (so when close finishes). This allows us to
134
- * retrieve the dimensions *before* closing.
135
- */ }, [
136
- context.open,
137
- present
138
- ]);
139
- return /*#__PURE__*/ $73KQ4$createElement($73KQ4$Primitive.div, $73KQ4$babelruntimehelpersesmextends({
140
- "data-state": $409067139f391064$var$getState(context.open),
141
- "data-disabled": context.disabled ? '' : undefined,
142
- id: context.contentId,
143
- hidden: !isOpen
144
- }, contentProps, {
145
- ref: composedRefs,
146
- style: {
147
- [`--radix-collapsible-content-height`]: height ? `${height}px` : undefined,
148
- [`--radix-collapsible-content-width`]: width ? `${width}px` : undefined,
149
- ...props.style
150
- }
151
- }), isOpen && children);
152
- });
153
- /* -----------------------------------------------------------------------------------------------*/ function $409067139f391064$var$getState(open) {
154
- return open ? 'open' : 'closed';
139
+ function getState(open) {
140
+ return open ? "open" : "closed";
155
141
  }
156
- const $409067139f391064$export$be92b6f5f03c0fe9 = $409067139f391064$export$6eb0f7ddcda6131f;
157
- const $409067139f391064$export$41fb9f06171c75f4 = $409067139f391064$export$c135dce7b15bbbdc;
158
- const $409067139f391064$export$7c6e2c02157bb7d2 = $409067139f391064$export$aadde00976f34151;
159
-
160
-
161
-
162
-
163
- export {$409067139f391064$export$952b32dcbe73087a as createCollapsibleScope, $409067139f391064$export$6eb0f7ddcda6131f as Collapsible, $409067139f391064$export$c135dce7b15bbbdc as CollapsibleTrigger, $409067139f391064$export$aadde00976f34151 as CollapsibleContent, $409067139f391064$export$be92b6f5f03c0fe9 as Root, $409067139f391064$export$41fb9f06171c75f4 as Trigger, $409067139f391064$export$7c6e2c02157bb7d2 as Content};
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
+ };
164
154
  //# sourceMappingURL=index.mjs.map
@@ -1 +1,7 @@
1
- {"mappings":";;;;;;;;;;;A;;;;;;;;;;ACaA;;oGAEA,CAEA,MAAMgB,sCAAgB,GAAG,aAAzB,AAAA;AAGA,MAAM,CAACC,8CAAD,EAA2BjB,yCAA3B,CAAA,GAAqDS,yBAAkB,CAACO,sCAAD,CAA7E,AAAA;AASA,MAAM,CAACE,yCAAD,EAAsBC,2CAAtB,CAAA,GACJF,8CAAwB,CAA0BD,sCAA1B,CAD1B,AAAA;AAYA,MAAMf,yCAAW,GAAA,aAAGM,CAAAA,iBAAA,CAClB,CAACc,KAAD,EAAuCC,YAAvC,GAAwD;IACtD,MAAM,E,oBACJC,kBADI,CAAA,EAEJC,IAAI,EAAEC,QAFF,CAAA,E,aAGJC,WAHI,CAAA,E,UAIJC,QAJI,CAAA,E,cAKJC,YALI,CAAA,EAMJ,GAAGC,gBAAH,EANI,GAOFR,KAPJ,AAAM;IASN,MAAM,CAACG,IAAI,GAAG,KAAR,EAAeM,OAAf,CAAA,GAA0BpB,2BAAoB,CAAC;QACnDqB,IAAI,EAAEN,QAD6C;QAEnDO,WAAW,EAAEN,WAFsC;QAGnDO,QAAQ,EAAEL,YAAVK;KAHkD,CAApD,AAAqD;IAMrD,OAAA,aACE,C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AAA,EAA+CE,MAAM,GAAI,CAAA,EAAEA,MAAO,CAAA,EAAA,CAAb,GAAmBpB,SADnE;YAEL,CAAE,CAAA,iCAAA,CAAF,CAAA,EAA8CuB,KAAK,GAAI,CAAA,EAAEA,KAAM,CAAA,EAAA,CAAZ,GAAkBvB,SAFhE;YAGL,GAAGhB,KAAK,CAACiD,KAAT;SAHK;KAPT,CAAA,EAaGT,MAAM,IAAIZ,QAbb,CADF,CACE;CAzD2B,CAA/B,AAyEC;AAED,oGAAA,CAEA,SAASb,8BAAT,CAAkBZ,IAAlB,EAAkC;IAChC,OAAOA,IAAI,GAAG,MAAH,GAAY,QAAvB,CAAA;CACD;AAED,MAAMpB,yCAAI,GAAGH,yCAAb,AAAA;AACA,MAAMI,yCAAO,GAAGH,yCAAhB,AAAA;AACA,MAAMI,yCAAO,GAAGH,yCAAhB,AAAA;;ADxOA","sources":["packages/react/collapsible/src/index.ts","packages/react/collapsible/src/Collapsible.tsx"],"sourcesContent":["export {\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 * as Radix from '@radix-ui/react-primitive';\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 = Radix.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 = Radix.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>>();\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"],"names":["createCollapsibleScope","Collapsible","CollapsibleTrigger","CollapsibleContent","Root","Trigger","Content","React","composeEventHandlers","createContextScope","useControllableState","useLayoutEffect","useComposedRefs","Primitive","Presence","useId","COLLAPSIBLE_NAME","createCollapsibleContext","CollapsibleProvider","useCollapsibleContext","forwardRef","props","forwardedRef","__scopeCollapsible","open","openProp","defaultOpen","disabled","onOpenChange","collapsibleProps","setOpen","prop","defaultProp","onChange","useCallback","prevOpen","getState","undefined","TRIGGER_NAME","triggerProps","context","contentId","onClick","onOpenToggle","CONTENT_NAME","forceMount","contentProps","present","CollapsibleContentImpl","children","isPresent","setIsPresent","useState","ref","useRef","composedRefs","heightRef","height","current","widthRef","width","isOpen","isMountAnimationPreventedRef","originalStylesRef","useEffect","rAF","requestAnimationFrame","cancelAnimationFrame","node","transitionDuration","style","animationName","rect","getBoundingClientRect"],"version":3,"file":"index.mjs.map"}
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 * as Radix from '@radix-ui/react-primitive';\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 = Radix.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 = Radix.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>>();\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,YAAY,WAAW;AACvB,SAAS,4BAA4B;AACrC,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AACzB,SAAS,aAAa;AA0Dd;AAjDR,IAAM,mBAAmB;AAGzB,IAAM,CAAC,0BAA0B,sBAAsB,IAAI,mBAAmB,gBAAgB;AAS9F,IAAM,CAAC,qBAAqB,qBAAqB,IAC/C,yBAAkD,gBAAgB;AAWpE,IAAM,cAAoB;AAAA,EACxB,CAAC,OAAsC,iBAAiB;AACtD,UAAM;AAAA,MACJ;AAAA,MACA,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AAEJ,UAAM,CAAC,OAAO,OAAO,OAAO,IAAI,qBAAqB;AAAA,MACnD,MAAM;AAAA,MACN,aAAa;AAAA,MACb,UAAU;AAAA,IACZ,CAAC;AAED,WACE;AAAA,MAAC;AAAA;AAAA,QACC,OAAO;AAAA,QACP;AAAA,QACA,WAAW,MAAM;AAAA,QACjB;AAAA,QACA,cAAoB,kBAAY,MAAM,QAAQ,CAAC,aAAa,CAAC,QAAQ,GAAG,CAAC,OAAO,CAAC;AAAA,QAEjF;AAAA,UAAC,UAAU;AAAA,UAAV;AAAA,YACC,cAAY,SAAS,IAAI;AAAA,YACzB,iBAAe,WAAW,KAAK;AAAA,YAC9B,GAAG;AAAA,YACJ,KAAK;AAAA;AAAA,QACP;A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;AAID,SAAS,SAAS,MAAgB;AAChC,SAAO,OAAO,SAAS;AACzB;AAEA,IAAM,OAAO;AACb,IAAM,UAAU;AAChB,IAAM,UAAU;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radix-ui/react-collapsible",
3
- "version": "1.0.3",
3
+ "version": "1.1.0-rc.2",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": {
@@ -28,15 +28,14 @@
28
28
  "version": "yarn version"
29
29
  },
30
30
  "dependencies": {
31
- "@babel/runtime": "^7.13.10",
32
- "@radix-ui/primitive": "1.0.1",
33
- "@radix-ui/react-compose-refs": "1.0.1",
34
- "@radix-ui/react-context": "1.0.1",
35
- "@radix-ui/react-id": "1.0.1",
36
- "@radix-ui/react-presence": "1.0.1",
37
- "@radix-ui/react-primitive": "1.0.3",
38
- "@radix-ui/react-use-controllable-state": "1.0.1",
39
- "@radix-ui/react-use-layout-effect": "1.0.1"
31
+ "@radix-ui/primitive": "1.1.0-rc.2",
32
+ "@radix-ui/react-compose-refs": "1.1.0-rc.2",
33
+ "@radix-ui/react-context": "1.1.0-rc.2",
34
+ "@radix-ui/react-id": "1.1.0-rc.2",
35
+ "@radix-ui/react-presence": "1.1.0-rc.2",
36
+ "@radix-ui/react-primitive": "1.1.0-rc.2",
37
+ "@radix-ui/react-use-controllable-state": "1.1.0-rc.2",
38
+ "@radix-ui/react-use-layout-effect": "1.1.0-rc.2"
40
39
  },
41
40
  "peerDependencies": {
42
41
  "@types/react": "*",
@@ -59,5 +58,6 @@
59
58
  },
60
59
  "bugs": {
61
60
  "url": "https://github.com/radix-ui/primitives/issues"
62
- }
61
+ },
62
+ "stableVersion": "1.0.3"
63
63
  }
@@ -1 +0,0 @@
1
- {"mappings":";;;AAoBA,OAAA,6FAA+F,CAAC;AAahG,yBAAyB,MAAM,wBAAwB,CAAC,OAAO,UAAU,GAAG,CAAC,CAAC;AAC9E,iCAA2B,SAAQ,iBAAiB;IAClD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;CACpC;AAED,OAAA,MAAM,oGAkCL,CAAC;AAWF,4BAA4B,MAAM,wBAAwB,CAAC,OAAO,UAAU,MAAM,CAAC,CAAC;AACpF,wCAAkC,SAAQ,oBAAoB;CAAG;AAEjE,OAAA,MAAM,qHAkBL,CAAC;AAWF,wCAAkC,SAAQ,IAAI,CAAC,2BAA2B,EAAE,SAAS,CAAC;IACpF;;;OAGG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC;CACnB;AAED,OAAA,MAAM,kHAYL,CAAC;AAOF,qCAAsC,SAAQ,iBAAiB;IAC7D,OAAO,EAAE,OAAO,CAAC;CAClB;AAmFD,OAAA,MAAM,6FAAkB,CAAC;AACzB,OAAA,MAAM,0GAA4B,CAAC;AACnC,OAAA,MAAM,uGAA4B,CAAC","sources":["packages/react/collapsible/src/packages/react/collapsible/src/Collapsible.tsx","packages/react/collapsible/src/packages/react/collapsible/src/index.ts","packages/react/collapsible/src/index.ts"],"sourcesContent":[null,null,"export {\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"],"names":[],"version":3,"file":"index.d.ts.map"}