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

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,175 @@
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
+ (() => {
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 __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
10
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
11
+ }) : x)(function(x) {
12
+ if (typeof require !== "undefined") return require.apply(this, arguments);
13
+ throw Error('Dynamic require of "' + x + '" is not supported');
14
+ });
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+
32
+ // packages/react/collapsible/src/Collapsible.tsx
33
+ var React = __toESM(__require("react"));
34
+ var import_primitive = __require("@radix-ui/primitive");
35
+ var import_react_context = __require("@radix-ui/react-context");
36
+ var import_react_use_controllable_state = __require("@radix-ui/react-use-controllable-state");
37
+ var import_react_use_layout_effect = __require("@radix-ui/react-use-layout-effect");
38
+ var import_react_compose_refs = __require("@radix-ui/react-compose-refs");
39
+ var import_react_primitive = __require("@radix-ui/react-primitive");
40
+ var import_react_presence = __require("@radix-ui/react-presence");
41
+ var import_react_id = __require("@radix-ui/react-id");
42
+ var import_jsx_runtime = __require("react/jsx-runtime");
43
+ var COLLAPSIBLE_NAME = "Collapsible";
44
+ var [createCollapsibleContext, createCollapsibleScope] = (0, import_react_context.createContextScope)(COLLAPSIBLE_NAME);
45
+ var [CollapsibleProvider, useCollapsibleContext] = createCollapsibleContext(COLLAPSIBLE_NAME);
46
+ var Collapsible = React.forwardRef(
47
+ (props, forwardedRef) => {
48
+ const {
49
+ __scopeCollapsible,
50
+ open: openProp,
51
+ defaultOpen,
52
+ disabled,
53
+ onOpenChange,
54
+ ...collapsibleProps
55
+ } = props;
56
+ const [open = false, setOpen] = (0, import_react_use_controllable_state.useControllableState)({
44
57
  prop: openProp,
45
58
  defaultProp: defaultOpen,
46
59
  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);
60
+ });
61
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
62
+ CollapsibleProvider,
63
+ {
64
+ scope: __scopeCollapsible,
65
+ disabled,
66
+ contentId: (0, import_react_id.useId)(),
67
+ open,
68
+ onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
69
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
70
+ import_react_primitive.Primitive.div,
71
+ {
72
+ "data-state": getState(open),
73
+ "data-disabled": disabled ? "" : void 0,
74
+ ...collapsibleProps,
75
+ ref: forwardedRef
76
+ }
77
+ )
78
+ }
79
+ );
80
+ }
81
+ );
82
+ Collapsible.displayName = COLLAPSIBLE_NAME;
83
+ var TRIGGER_NAME = "CollapsibleTrigger";
84
+ var CollapsibleTrigger = React.forwardRef(
85
+ (props, forwardedRef) => {
86
+ const { __scopeCollapsible, ...triggerProps } = props;
87
+ const context = useCollapsibleContext(TRIGGER_NAME, __scopeCollapsible);
88
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
89
+ import_react_primitive.Primitive.button,
90
+ {
91
+ type: "button",
92
+ "aria-controls": context.contentId,
93
+ "aria-expanded": context.open || false,
94
+ "data-state": getState(context.open),
95
+ "data-disabled": context.disabled ? "" : void 0,
96
+ disabled: context.disabled,
97
+ ...triggerProps,
98
+ ref: forwardedRef,
99
+ onClick: (0, import_primitive.composeEventHandlers)(props.onClick, context.onOpenToggle)
100
+ }
101
+ );
102
+ }
103
+ );
104
+ CollapsibleTrigger.displayName = TRIGGER_NAME;
105
+ var CONTENT_NAME = "CollapsibleContent";
106
+ var CollapsibleContent = React.forwardRef(
107
+ (props, forwardedRef) => {
108
+ const { forceMount, ...contentProps } = props;
109
+ const context = useCollapsibleContext(CONTENT_NAME, props.__scopeCollapsible);
110
+ 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 }) });
111
+ }
112
+ );
113
+ CollapsibleContent.displayName = CONTENT_NAME;
114
+ var CollapsibleContentImpl = React.forwardRef((props, forwardedRef) => {
115
+ const { __scopeCollapsible, present, children, ...contentProps } = props;
116
+ const context = useCollapsibleContext(CONTENT_NAME, __scopeCollapsible);
117
+ const [isPresent, setIsPresent] = React.useState(present);
118
+ const ref = React.useRef(null);
119
+ const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, ref);
120
+ const heightRef = React.useRef(0);
113
121
  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
122
+ const widthRef = React.useRef(0);
123
+ const width = widthRef.current;
117
124
  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
- ;
125
+ const isMountAnimationPreventedRef = React.useRef(isOpen);
126
+ const originalStylesRef = React.useRef();
127
+ React.useEffect(() => {
128
+ const rAF = requestAnimationFrame(() => isMountAnimationPreventedRef.current = false);
129
+ return () => cancelAnimationFrame(rAF);
125
130
  }, []);
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);
131
+ (0, import_react_use_layout_effect.useLayoutEffect)(() => {
132
+ const node = ref.current;
133
+ if (node) {
134
+ originalStylesRef.current = originalStylesRef.current || {
135
+ transitionDuration: node.style.transitionDuration,
136
+ animationName: node.style.animationName
137
+ };
138
+ node.style.transitionDuration = "0s";
139
+ node.style.animationName = "none";
140
+ const rect = node.getBoundingClientRect();
141
+ heightRef.current = rect.height;
142
+ widthRef.current = rect.width;
143
+ if (!isMountAnimationPreventedRef.current) {
144
+ node.style.transitionDuration = originalStylesRef.current.transitionDuration;
145
+ node.style.animationName = originalStylesRef.current.animationName;
143
146
  }
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,
147
+ setIsPresent(present);
148
+ }
149
+ }, [context.open, present]);
150
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
151
+ import_react_primitive.Primitive.div,
152
+ {
153
+ "data-state": getState(context.open),
154
+ "data-disabled": context.disabled ? "" : void 0,
156
155
  id: context.contentId,
157
- hidden: !isOpen
158
- }, contentProps, {
156
+ hidden: !isOpen,
157
+ ...contentProps,
159
158
  ref: composedRefs,
160
159
  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
-
160
+ [`--radix-collapsible-content-height`]: height ? `${height}px` : void 0,
161
+ [`--radix-collapsible-content-width`]: width ? `${width}px` : void 0,
162
+ ...props.style
163
+ },
164
+ children: isOpen && children
165
+ }
166
+ );
167
+ });
168
+ function getState(open) {
169
+ return open ? "open" : "closed";
170
+ }
171
+ var Root = Collapsible;
172
+ var Trigger = CollapsibleTrigger;
173
+ var Content = CollapsibleContent;
174
+ })();
177
175
  //# 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,sCAA1B,CA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AY,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,GAAG;A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vD;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,152 @@
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";
11
-
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
1
+ // packages/react/collapsible/src/Collapsible.tsx
2
+ import * as React from "react";
3
+ import { composeEventHandlers } from "@radix-ui/primitive";
4
+ import { createContextScope } from "@radix-ui/react-context";
5
+ import { useControllableState } from "@radix-ui/react-use-controllable-state";
6
+ import { useLayoutEffect } from "@radix-ui/react-use-layout-effect";
7
+ import { useComposedRefs } from "@radix-ui/react-compose-refs";
8
+ import { Primitive } from "@radix-ui/react-primitive";
9
+ import { Presence } from "@radix-ui/react-presence";
10
+ import { useId } from "@radix-ui/react-id";
11
+ import { jsx } from "react/jsx-runtime";
12
+ var COLLAPSIBLE_NAME = "Collapsible";
13
+ var [createCollapsibleContext, createCollapsibleScope] = createContextScope(COLLAPSIBLE_NAME);
14
+ var [CollapsibleProvider, useCollapsibleContext] = createCollapsibleContext(COLLAPSIBLE_NAME);
15
+ var Collapsible = React.forwardRef(
16
+ (props, forwardedRef) => {
17
+ const {
18
+ __scopeCollapsible,
19
+ open: openProp,
20
+ defaultOpen,
21
+ disabled,
22
+ onOpenChange,
23
+ ...collapsibleProps
24
+ } = props;
25
+ const [open = false, setOpen] = useControllableState({
26
+ prop: openProp,
27
+ defaultProp: defaultOpen,
28
+ onChange: onOpenChange
33
29
  });
34
- return /*#__PURE__*/ $73KQ4$createElement($409067139f391064$var$CollapsibleProvider, {
30
+ return /* @__PURE__ */ jsx(
31
+ CollapsibleProvider,
32
+ {
35
33
  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({
34
+ disabled,
35
+ contentId: useId(),
36
+ open,
37
+ onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
38
+ children: /* @__PURE__ */ jsx(
39
+ Primitive.div,
40
+ {
41
+ "data-state": getState(open),
42
+ "data-disabled": disabled ? "" : void 0,
43
+ ...collapsibleProps,
44
+ ref: forwardedRef
45
+ }
46
+ )
47
+ }
48
+ );
49
+ }
50
+ );
51
+ Collapsible.displayName = COLLAPSIBLE_NAME;
52
+ var TRIGGER_NAME = "CollapsibleTrigger";
53
+ var CollapsibleTrigger = React.forwardRef(
54
+ (props, forwardedRef) => {
55
+ const { __scopeCollapsible, ...triggerProps } = props;
56
+ const context = useCollapsibleContext(TRIGGER_NAME, __scopeCollapsible);
57
+ return /* @__PURE__ */ jsx(
58
+ Primitive.button,
59
+ {
61
60
  type: "button",
62
61
  "aria-controls": context.contentId,
63
62
  "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, {
63
+ "data-state": getState(context.open),
64
+ "data-disabled": context.disabled ? "" : void 0,
65
+ disabled: context.disabled,
66
+ ...triggerProps,
68
67
  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
- }))
68
+ onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
69
+ }
87
70
  );
71
+ }
72
+ );
73
+ CollapsibleTrigger.displayName = TRIGGER_NAME;
74
+ var CONTENT_NAME = "CollapsibleContent";
75
+ var CollapsibleContent = React.forwardRef(
76
+ (props, forwardedRef) => {
77
+ const { forceMount, ...contentProps } = props;
78
+ const context = useCollapsibleContext(CONTENT_NAME, props.__scopeCollapsible);
79
+ return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: ({ present }) => /* @__PURE__ */ jsx(CollapsibleContentImpl, { ...contentProps, ref: forwardedRef, present }) });
80
+ }
81
+ );
82
+ CollapsibleContent.displayName = CONTENT_NAME;
83
+ var CollapsibleContentImpl = React.forwardRef((props, forwardedRef) => {
84
+ const { __scopeCollapsible, present, children, ...contentProps } = props;
85
+ const context = useCollapsibleContext(CONTENT_NAME, __scopeCollapsible);
86
+ const [isPresent, setIsPresent] = React.useState(present);
87
+ const ref = React.useRef(null);
88
+ const composedRefs = useComposedRefs(forwardedRef, ref);
89
+ const heightRef = React.useRef(0);
90
+ const height = heightRef.current;
91
+ const widthRef = React.useRef(0);
92
+ const width = widthRef.current;
93
+ const isOpen = context.open || isPresent;
94
+ const isMountAnimationPreventedRef = React.useRef(isOpen);
95
+ const originalStylesRef = React.useRef();
96
+ React.useEffect(() => {
97
+ const rAF = requestAnimationFrame(() => isMountAnimationPreventedRef.current = false);
98
+ return () => cancelAnimationFrame(rAF);
99
+ }, []);
100
+ useLayoutEffect(() => {
101
+ const node = ref.current;
102
+ if (node) {
103
+ originalStylesRef.current = originalStylesRef.current || {
104
+ transitionDuration: node.style.transitionDuration,
105
+ animationName: node.style.animationName
106
+ };
107
+ node.style.transitionDuration = "0s";
108
+ node.style.animationName = "none";
109
+ const rect = node.getBoundingClientRect();
110
+ heightRef.current = rect.height;
111
+ widthRef.current = rect.width;
112
+ if (!isMountAnimationPreventedRef.current) {
113
+ node.style.transitionDuration = originalStylesRef.current.transitionDuration;
114
+ node.style.animationName = originalStylesRef.current.animationName;
115
+ }
116
+ setIsPresent(present);
117
+ }
118
+ }, [context.open, present]);
119
+ return /* @__PURE__ */ jsx(
120
+ Primitive.div,
121
+ {
122
+ "data-state": getState(context.open),
123
+ "data-disabled": context.disabled ? "" : void 0,
124
+ id: context.contentId,
125
+ hidden: !isOpen,
126
+ ...contentProps,
127
+ ref: composedRefs,
128
+ style: {
129
+ [`--radix-collapsible-content-height`]: height ? `${height}px` : void 0,
130
+ [`--radix-collapsible-content-width`]: width ? `${width}px` : void 0,
131
+ ...props.style
132
+ },
133
+ children: isOpen && children
134
+ }
135
+ );
88
136
  });
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';
137
+ function getState(open) {
138
+ return open ? "open" : "closed";
155
139
  }
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};
140
+ var Root = Collapsible;
141
+ var Trigger = CollapsibleTrigger;
142
+ var Content = CollapsibleContent;
143
+ export {
144
+ Collapsible,
145
+ CollapsibleContent,
146
+ CollapsibleTrigger,
147
+ Content,
148
+ Root,
149
+ Trigger,
150
+ createCollapsibleScope
151
+ };
164
152
  //# 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,CAAA,oBAAA,CAAC,y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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;AAAA;AAAA,IACF;AAAA,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gB;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-rc.9",
3
+ "version": "1.1.0-rc.1",
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-rc.4",
33
- "@radix-ui/react-compose-refs": "1.0.1-rc.4",
34
- "@radix-ui/react-context": "1.0.1-rc.4",
35
- "@radix-ui/react-id": "1.0.1-rc.4",
36
- "@radix-ui/react-presence": "1.0.1-rc.4",
37
- "@radix-ui/react-primitive": "1.0.3-rc.9",
38
- "@radix-ui/react-use-controllable-state": "1.0.1-rc.4",
39
- "@radix-ui/react-use-layout-effect": "1.0.1-rc.4"
31
+ "@radix-ui/primitive": "1.1.0-rc.1",
32
+ "@radix-ui/react-compose-refs": "1.1.0-rc.1",
33
+ "@radix-ui/react-context": "1.1.0-rc.1",
34
+ "@radix-ui/react-id": "1.1.0-rc.1",
35
+ "@radix-ui/react-presence": "1.1.0-rc.1",
36
+ "@radix-ui/react-primitive": "1.1.0-rc.1",
37
+ "@radix-ui/react-use-controllable-state": "1.1.0-rc.1",
38
+ "@radix-ui/react-use-layout-effect": "1.1.0-rc.1"
40
39
  },
41
40
  "peerDependencies": {
42
41
  "@types/react": "*",
@@ -60,5 +59,5 @@
60
59
  "bugs": {
61
60
  "url": "https://github.com/radix-ui/primitives/issues"
62
61
  },
63
- "stableVersion": "1.0.2"
62
+ "stableVersion": "1.0.3"
64
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"}