@tamagui/collapsible 1.0.1-beta.219 → 1.0.1-beta.221
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/cjs/Collapsible.js +3 -128
- package/dist/cjs/Collapsible.js.map +3 -3
- package/dist/esm/Collapsible.js +2 -118
- package/dist/esm/Collapsible.js.map +2 -2
- package/dist/jsx/Collapsible.js +2 -81
- package/dist/jsx/Collapsible.js.map +2 -2
- package/package.json +8 -8
- package/src/Collapsible.tsx +248 -254
- package/types/Collapsible.d.ts +1 -29
package/dist/cjs/Collapsible.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,138 +15,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
19
|
var Collapsible_exports = {};
|
|
26
20
|
__export(Collapsible_exports, {
|
|
27
|
-
Collapsible: () => Collapsible
|
|
28
|
-
CollapsibleContent: () => CollapsibleContent,
|
|
29
|
-
CollapsibleTrigger: () => CollapsibleTrigger,
|
|
30
|
-
Content: () => Content,
|
|
31
|
-
Root: () => Root,
|
|
32
|
-
Trigger: () => Trigger,
|
|
33
|
-
createCollapsibleScope: () => createCollapsibleScope
|
|
21
|
+
Collapsible: () => Collapsible
|
|
34
22
|
});
|
|
35
23
|
module.exports = __toCommonJS(Collapsible_exports);
|
|
36
|
-
|
|
37
|
-
var import_compose_refs = require("@tamagui/compose-refs");
|
|
38
|
-
var import_core = require("@tamagui/core");
|
|
39
|
-
var import_core2 = require("@tamagui/core");
|
|
40
|
-
var import_create_context = require("@tamagui/create-context");
|
|
41
|
-
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
42
|
-
var React = __toESM(require("react"));
|
|
43
|
-
const COLLAPSIBLE_NAME = "Collapsible";
|
|
44
|
-
const [createCollapsibleContext, createCollapsibleScope] = (0, import_create_context.createContextScope)(COLLAPSIBLE_NAME);
|
|
45
|
-
const [CollapsibleProvider, useCollapsibleContext] = createCollapsibleContext(COLLAPSIBLE_NAME);
|
|
46
|
-
const 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, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
57
|
-
prop: openProp,
|
|
58
|
-
defaultProp: defaultOpen || false,
|
|
59
|
-
onChange: onOpenChange
|
|
60
|
-
});
|
|
61
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CollapsibleProvider, {
|
|
62
|
-
scope: __scopeCollapsible,
|
|
63
|
-
disabled,
|
|
64
|
-
contentId: (0, import_core2.useId)() || "",
|
|
65
|
-
open,
|
|
66
|
-
onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
67
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Stack, {
|
|
68
|
-
"data-state": getState(open),
|
|
69
|
-
"data-disabled": disabled ? "" : void 0,
|
|
70
|
-
...collapsibleProps,
|
|
71
|
-
ref: forwardedRef
|
|
72
|
-
})
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
);
|
|
76
|
-
Collapsible.displayName = COLLAPSIBLE_NAME;
|
|
77
|
-
const TRIGGER_NAME = "CollapsibleTrigger";
|
|
78
|
-
const CollapsibleTrigger = React.forwardRef(
|
|
79
|
-
(props, forwardedRef) => {
|
|
80
|
-
const { __scopeCollapsible, ...triggerProps } = props;
|
|
81
|
-
const context = useCollapsibleContext(TRIGGER_NAME, __scopeCollapsible);
|
|
82
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Stack, {
|
|
83
|
-
type: "button",
|
|
84
|
-
"aria-controls": context.contentId,
|
|
85
|
-
"aria-expanded": context.open || false,
|
|
86
|
-
"data-state": getState(context.open),
|
|
87
|
-
"data-disabled": context.disabled ? "" : void 0,
|
|
88
|
-
disabled: context.disabled,
|
|
89
|
-
...triggerProps,
|
|
90
|
-
ref: forwardedRef,
|
|
91
|
-
onPress: (0, import_core.composeEventHandlers)(props.onPress, context.onOpenToggle)
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
);
|
|
95
|
-
CollapsibleTrigger.displayName = TRIGGER_NAME;
|
|
96
|
-
const CONTENT_NAME = "CollapsibleContent";
|
|
97
|
-
const CollapsibleContent = React.forwardRef(
|
|
98
|
-
(props, forwardedRef) => {
|
|
99
|
-
const { forceMount, ...contentProps } = props;
|
|
100
|
-
const context = useCollapsibleContext(CONTENT_NAME, props.__scopeCollapsible);
|
|
101
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
102
|
-
children: ({ present }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CollapsibleContentImpl, {
|
|
103
|
-
...contentProps,
|
|
104
|
-
ref: forwardedRef,
|
|
105
|
-
present
|
|
106
|
-
})
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
);
|
|
110
|
-
CollapsibleContent.displayName = CONTENT_NAME;
|
|
111
|
-
const CollapsibleContentImpl = React.forwardRef((props, forwardedRef) => {
|
|
112
|
-
const { __scopeCollapsible, present, children, ...contentProps } = props;
|
|
113
|
-
const context = useCollapsibleContext(CONTENT_NAME, __scopeCollapsible);
|
|
114
|
-
const [isPresent, setIsPresent] = React.useState(present);
|
|
115
|
-
const ref = React.useRef(null);
|
|
116
|
-
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref);
|
|
117
|
-
const heightRef = React.useRef(0);
|
|
118
|
-
const height = heightRef.current;
|
|
119
|
-
const widthRef = React.useRef(0);
|
|
120
|
-
const width = widthRef.current;
|
|
121
|
-
const isOpen = context.open || isPresent;
|
|
122
|
-
const isMountAnimationPreventedRef = React.useRef(isOpen);
|
|
123
|
-
const originalStylesRef = React.useRef();
|
|
124
|
-
React.useEffect(() => {
|
|
125
|
-
const rAF = requestAnimationFrame(() => isMountAnimationPreventedRef.current = false);
|
|
126
|
-
return () => cancelAnimationFrame(rAF);
|
|
127
|
-
}, []);
|
|
128
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Stack, {
|
|
129
|
-
"data-state": getState(context.open),
|
|
130
|
-
"data-disabled": context.disabled ? "" : void 0,
|
|
131
|
-
id: context.contentId,
|
|
132
|
-
hidden: !isOpen,
|
|
133
|
-
...contentProps,
|
|
134
|
-
ref: composedRefs,
|
|
135
|
-
children: isOpen && children
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
function getState(open) {
|
|
139
|
-
return open ? "open" : "closed";
|
|
140
|
-
}
|
|
141
|
-
const Root = Collapsible;
|
|
142
|
-
const Trigger = CollapsibleTrigger;
|
|
143
|
-
const Content = CollapsibleContent;
|
|
24
|
+
const Collapsible = {};
|
|
144
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
145
26
|
0 && (module.exports = {
|
|
146
|
-
Collapsible
|
|
147
|
-
CollapsibleContent,
|
|
148
|
-
CollapsibleTrigger,
|
|
149
|
-
Content,
|
|
150
|
-
Root,
|
|
151
|
-
Trigger,
|
|
152
|
-
createCollapsibleScope
|
|
27
|
+
Collapsible
|
|
153
28
|
});
|
|
154
29
|
//# sourceMappingURL=Collapsible.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Collapsible.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useComposedRefs } from '@tamagui/compose-refs'\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["export const Collapsible = {}\n\n// import { useComposedRefs } from '@tamagui/compose-refs'\n// import { Stack, StackProps, TamaguiElement, composeEventHandlers, useId } from '@tamagui/core'\n// import type { Scope } from '@tamagui/create-context'\n// import { createContextScope } from '@tamagui/create-context'\n// // import { Presence } from '@tamagui/react-presence'\n// import { useControllableState } from '@tamagui/use-controllable-state'\n// import * as React from 'react'\n\n// /* -------------------------------------------------------------------------------------------------\n// * Collapsible\n// * -----------------------------------------------------------------------------------------------*/\n\n// const COLLAPSIBLE_NAME = 'Collapsible'\n\n// type ScopedProps<P> = P & { __scopeCollapsible?: Scope }\n// const [createCollapsibleContext, createCollapsibleScope] = createContextScope(COLLAPSIBLE_NAME)\n\n// type CollapsibleContextValue = {\n// contentId: string\n// disabled?: boolean\n// open: boolean\n// onOpenToggle(): void\n// }\n\n// const [CollapsibleProvider, useCollapsibleContext] =\n// createCollapsibleContext<CollapsibleContextValue>(COLLAPSIBLE_NAME)\n\n// type CollapsibleElement = TamaguiElement\n// interface CollapsibleProps extends StackProps {\n// defaultOpen?: boolean\n// open?: boolean\n// disabled?: boolean\n// onOpenChange?(open: boolean): void\n// }\n\n// const 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, setOpen] = useControllableState({\n// prop: openProp,\n// defaultProp: defaultOpen || false,\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// <Stack\n// data-state={getState(open)}\n// data-disabled={disabled ? '' : undefined}\n// {...collapsibleProps}\n// ref={forwardedRef}\n// />\n// </CollapsibleProvider>\n// )\n// }\n// )\n\n// Collapsible.displayName = COLLAPSIBLE_NAME\n\n// /* -------------------------------------------------------------------------------------------------\n// * CollapsibleTrigger\n// * -----------------------------------------------------------------------------------------------*/\n\n// const TRIGGER_NAME = 'CollapsibleTrigger'\n\n// type CollapsibleTriggerElement = TamaguiElement\n// interface CollapsibleTriggerProps extends StackProps {}\n\n// const 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// <Stack\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// //\n// // onPress={composeEventHandlers(props.onPress, context.onOpenToggle)}\n// />\n// )\n// }\n// )\n\n// CollapsibleTrigger.displayName = TRIGGER_NAME\n\n// /* -------------------------------------------------------------------------------------------------\n// * CollapsibleContent\n// * -----------------------------------------------------------------------------------------------*/\n\n// const CONTENT_NAME = 'CollapsibleContent'\n\n// type CollapsibleContentElement = CollapsibleContentImplElement\n// interface 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\n// const 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// <>\n// {({ present }) => (\n// <CollapsibleContentImpl {...contentProps} ref={forwardedRef} present={present} />\n// )}\n// </>\n// // </Presence>\n// )\n// }\n// )\n\n// CollapsibleContent.displayName = CONTENT_NAME\n\n// /* -----------------------------------------------------------------------------------------------*/\n\n// type CollapsibleContentImplElement = TamaguiElement\n// interface CollapsibleContentImplProps extends StackProps {\n// present: boolean\n// }\n\n// const 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// // useIsomorphicLayoutEffect(() => {\n// // const node = ref.current\n// // if (node) {\n// // originalStylesRef.current = originalStylesRef.current || {\n// // transitionDuration: node.style.transitionDuration,\n// // animationDuration: node.style.animationDuration,\n// // animationFillMode: node.style.animationFillMode,\n// // }\n// // // block any animations/transitions so the element renders at its full dimensions\n// // node.style.transitionDuration = '0s'\n// // node.style.animationDuration = '0s'\n// // node.style.animationFillMode = '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.animationDuration = originalStylesRef.current.animationDuration\n// // node.style.animationFillMode = originalStylesRef.current.animationFillMode\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// <Stack\n// data-state={getState(context.open)}\n// data-disabled={context.disabled ? '' : undefined}\n// id={context.contentId}\n// hidden={!isOpen}\n// {...contentProps}\n// // @ts-expect-error\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// </Stack>\n// )\n// })\n\n// /* -----------------------------------------------------------------------------------------------*/\n\n// function getState(open?: boolean) {\n// return open ? 'open' : 'closed'\n// }\n\n// const Root = Collapsible\n// const Trigger = CollapsibleTrigger\n// const Content = CollapsibleContent\n\n// export {\n// createCollapsibleScope,\n// //\n// Collapsible,\n// CollapsibleTrigger,\n// CollapsibleContent,\n// //\n// Root,\n// Trigger,\n// Content,\n// }\n// export type { CollapsibleProps, CollapsibleTriggerProps, CollapsibleContentProps }\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc,CAAC;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/esm/Collapsible.js
CHANGED
|
@@ -1,121 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
3
|
-
import {
|
|
4
|
-
Stack,
|
|
5
|
-
composeEventHandlers
|
|
6
|
-
} from "@tamagui/core";
|
|
7
|
-
import { useId } from "@tamagui/core";
|
|
8
|
-
import { createContextScope } from "@tamagui/create-context";
|
|
9
|
-
import { useControllableState } from "@tamagui/use-controllable-state";
|
|
10
|
-
import * as React from "react";
|
|
11
|
-
const COLLAPSIBLE_NAME = "Collapsible";
|
|
12
|
-
const [createCollapsibleContext, createCollapsibleScope] = createContextScope(COLLAPSIBLE_NAME);
|
|
13
|
-
const [CollapsibleProvider, useCollapsibleContext] = createCollapsibleContext(COLLAPSIBLE_NAME);
|
|
14
|
-
const Collapsible = React.forwardRef(
|
|
15
|
-
(props, forwardedRef) => {
|
|
16
|
-
const {
|
|
17
|
-
__scopeCollapsible,
|
|
18
|
-
open: openProp,
|
|
19
|
-
defaultOpen,
|
|
20
|
-
disabled,
|
|
21
|
-
onOpenChange,
|
|
22
|
-
...collapsibleProps
|
|
23
|
-
} = props;
|
|
24
|
-
const [open, setOpen] = useControllableState({
|
|
25
|
-
prop: openProp,
|
|
26
|
-
defaultProp: defaultOpen || false,
|
|
27
|
-
onChange: onOpenChange
|
|
28
|
-
});
|
|
29
|
-
return /* @__PURE__ */ jsx(CollapsibleProvider, {
|
|
30
|
-
scope: __scopeCollapsible,
|
|
31
|
-
disabled,
|
|
32
|
-
contentId: useId() || "",
|
|
33
|
-
open,
|
|
34
|
-
onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
35
|
-
children: /* @__PURE__ */ jsx(Stack, {
|
|
36
|
-
"data-state": getState(open),
|
|
37
|
-
"data-disabled": disabled ? "" : void 0,
|
|
38
|
-
...collapsibleProps,
|
|
39
|
-
ref: forwardedRef
|
|
40
|
-
})
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
);
|
|
44
|
-
Collapsible.displayName = COLLAPSIBLE_NAME;
|
|
45
|
-
const TRIGGER_NAME = "CollapsibleTrigger";
|
|
46
|
-
const CollapsibleTrigger = React.forwardRef(
|
|
47
|
-
(props, forwardedRef) => {
|
|
48
|
-
const { __scopeCollapsible, ...triggerProps } = props;
|
|
49
|
-
const context = useCollapsibleContext(TRIGGER_NAME, __scopeCollapsible);
|
|
50
|
-
return /* @__PURE__ */ jsx(Stack, {
|
|
51
|
-
type: "button",
|
|
52
|
-
"aria-controls": context.contentId,
|
|
53
|
-
"aria-expanded": context.open || false,
|
|
54
|
-
"data-state": getState(context.open),
|
|
55
|
-
"data-disabled": context.disabled ? "" : void 0,
|
|
56
|
-
disabled: context.disabled,
|
|
57
|
-
...triggerProps,
|
|
58
|
-
ref: forwardedRef,
|
|
59
|
-
onPress: composeEventHandlers(props.onPress, context.onOpenToggle)
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
CollapsibleTrigger.displayName = TRIGGER_NAME;
|
|
64
|
-
const CONTENT_NAME = "CollapsibleContent";
|
|
65
|
-
const CollapsibleContent = React.forwardRef(
|
|
66
|
-
(props, forwardedRef) => {
|
|
67
|
-
const { forceMount, ...contentProps } = props;
|
|
68
|
-
const context = useCollapsibleContext(CONTENT_NAME, props.__scopeCollapsible);
|
|
69
|
-
return /* @__PURE__ */ jsx(Fragment, {
|
|
70
|
-
children: ({ present }) => /* @__PURE__ */ jsx(CollapsibleContentImpl, {
|
|
71
|
-
...contentProps,
|
|
72
|
-
ref: forwardedRef,
|
|
73
|
-
present
|
|
74
|
-
})
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
CollapsibleContent.displayName = CONTENT_NAME;
|
|
79
|
-
const CollapsibleContentImpl = React.forwardRef((props, forwardedRef) => {
|
|
80
|
-
const { __scopeCollapsible, present, children, ...contentProps } = props;
|
|
81
|
-
const context = useCollapsibleContext(CONTENT_NAME, __scopeCollapsible);
|
|
82
|
-
const [isPresent, setIsPresent] = React.useState(present);
|
|
83
|
-
const ref = React.useRef(null);
|
|
84
|
-
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
85
|
-
const heightRef = React.useRef(0);
|
|
86
|
-
const height = heightRef.current;
|
|
87
|
-
const widthRef = React.useRef(0);
|
|
88
|
-
const width = widthRef.current;
|
|
89
|
-
const isOpen = context.open || isPresent;
|
|
90
|
-
const isMountAnimationPreventedRef = React.useRef(isOpen);
|
|
91
|
-
const originalStylesRef = React.useRef();
|
|
92
|
-
React.useEffect(() => {
|
|
93
|
-
const rAF = requestAnimationFrame(() => isMountAnimationPreventedRef.current = false);
|
|
94
|
-
return () => cancelAnimationFrame(rAF);
|
|
95
|
-
}, []);
|
|
96
|
-
return /* @__PURE__ */ jsx(Stack, {
|
|
97
|
-
"data-state": getState(context.open),
|
|
98
|
-
"data-disabled": context.disabled ? "" : void 0,
|
|
99
|
-
id: context.contentId,
|
|
100
|
-
hidden: !isOpen,
|
|
101
|
-
...contentProps,
|
|
102
|
-
ref: composedRefs,
|
|
103
|
-
children: isOpen && children
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
function getState(open) {
|
|
107
|
-
return open ? "open" : "closed";
|
|
108
|
-
}
|
|
109
|
-
const Root = Collapsible;
|
|
110
|
-
const Trigger = CollapsibleTrigger;
|
|
111
|
-
const Content = CollapsibleContent;
|
|
1
|
+
const Collapsible = {};
|
|
112
2
|
export {
|
|
113
|
-
Collapsible
|
|
114
|
-
CollapsibleContent,
|
|
115
|
-
CollapsibleTrigger,
|
|
116
|
-
Content,
|
|
117
|
-
Root,
|
|
118
|
-
Trigger,
|
|
119
|
-
createCollapsibleScope
|
|
3
|
+
Collapsible
|
|
120
4
|
};
|
|
121
5
|
//# sourceMappingURL=Collapsible.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Collapsible.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useComposedRefs } from '@tamagui/compose-refs'\
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["export const Collapsible = {}\n\n// import { useComposedRefs } from '@tamagui/compose-refs'\n// import { Stack, StackProps, TamaguiElement, composeEventHandlers, useId } from '@tamagui/core'\n// import type { Scope } from '@tamagui/create-context'\n// import { createContextScope } from '@tamagui/create-context'\n// // import { Presence } from '@tamagui/react-presence'\n// import { useControllableState } from '@tamagui/use-controllable-state'\n// import * as React from 'react'\n\n// /* -------------------------------------------------------------------------------------------------\n// * Collapsible\n// * -----------------------------------------------------------------------------------------------*/\n\n// const COLLAPSIBLE_NAME = 'Collapsible'\n\n// type ScopedProps<P> = P & { __scopeCollapsible?: Scope }\n// const [createCollapsibleContext, createCollapsibleScope] = createContextScope(COLLAPSIBLE_NAME)\n\n// type CollapsibleContextValue = {\n// contentId: string\n// disabled?: boolean\n// open: boolean\n// onOpenToggle(): void\n// }\n\n// const [CollapsibleProvider, useCollapsibleContext] =\n// createCollapsibleContext<CollapsibleContextValue>(COLLAPSIBLE_NAME)\n\n// type CollapsibleElement = TamaguiElement\n// interface CollapsibleProps extends StackProps {\n// defaultOpen?: boolean\n// open?: boolean\n// disabled?: boolean\n// onOpenChange?(open: boolean): void\n// }\n\n// const 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, setOpen] = useControllableState({\n// prop: openProp,\n// defaultProp: defaultOpen || false,\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// <Stack\n// data-state={getState(open)}\n// data-disabled={disabled ? '' : undefined}\n// {...collapsibleProps}\n// ref={forwardedRef}\n// />\n// </CollapsibleProvider>\n// )\n// }\n// )\n\n// Collapsible.displayName = COLLAPSIBLE_NAME\n\n// /* -------------------------------------------------------------------------------------------------\n// * CollapsibleTrigger\n// * -----------------------------------------------------------------------------------------------*/\n\n// const TRIGGER_NAME = 'CollapsibleTrigger'\n\n// type CollapsibleTriggerElement = TamaguiElement\n// interface CollapsibleTriggerProps extends StackProps {}\n\n// const 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// <Stack\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// //\n// // onPress={composeEventHandlers(props.onPress, context.onOpenToggle)}\n// />\n// )\n// }\n// )\n\n// CollapsibleTrigger.displayName = TRIGGER_NAME\n\n// /* -------------------------------------------------------------------------------------------------\n// * CollapsibleContent\n// * -----------------------------------------------------------------------------------------------*/\n\n// const CONTENT_NAME = 'CollapsibleContent'\n\n// type CollapsibleContentElement = CollapsibleContentImplElement\n// interface 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\n// const 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// <>\n// {({ present }) => (\n// <CollapsibleContentImpl {...contentProps} ref={forwardedRef} present={present} />\n// )}\n// </>\n// // </Presence>\n// )\n// }\n// )\n\n// CollapsibleContent.displayName = CONTENT_NAME\n\n// /* -----------------------------------------------------------------------------------------------*/\n\n// type CollapsibleContentImplElement = TamaguiElement\n// interface CollapsibleContentImplProps extends StackProps {\n// present: boolean\n// }\n\n// const 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// // useIsomorphicLayoutEffect(() => {\n// // const node = ref.current\n// // if (node) {\n// // originalStylesRef.current = originalStylesRef.current || {\n// // transitionDuration: node.style.transitionDuration,\n// // animationDuration: node.style.animationDuration,\n// // animationFillMode: node.style.animationFillMode,\n// // }\n// // // block any animations/transitions so the element renders at its full dimensions\n// // node.style.transitionDuration = '0s'\n// // node.style.animationDuration = '0s'\n// // node.style.animationFillMode = '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.animationDuration = originalStylesRef.current.animationDuration\n// // node.style.animationFillMode = originalStylesRef.current.animationFillMode\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// <Stack\n// data-state={getState(context.open)}\n// data-disabled={context.disabled ? '' : undefined}\n// id={context.contentId}\n// hidden={!isOpen}\n// {...contentProps}\n// // @ts-expect-error\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// </Stack>\n// )\n// })\n\n// /* -----------------------------------------------------------------------------------------------*/\n\n// function getState(open?: boolean) {\n// return open ? 'open' : 'closed'\n// }\n\n// const Root = Collapsible\n// const Trigger = CollapsibleTrigger\n// const Content = CollapsibleContent\n\n// export {\n// createCollapsibleScope,\n// //\n// Collapsible,\n// CollapsibleTrigger,\n// CollapsibleContent,\n// //\n// Root,\n// Trigger,\n// Content,\n// }\n// export type { CollapsibleProps, CollapsibleTriggerProps, CollapsibleContentProps }\n"],
|
|
5
|
+
"mappings": "AAAO,MAAM,cAAc,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/Collapsible.js
CHANGED
|
@@ -1,84 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
Stack,
|
|
4
|
-
composeEventHandlers
|
|
5
|
-
} from "@tamagui/core";
|
|
6
|
-
import { useId } from "@tamagui/core";
|
|
7
|
-
import { createContextScope } from "@tamagui/create-context";
|
|
8
|
-
import { useControllableState } from "@tamagui/use-controllable-state";
|
|
9
|
-
import * as React from "react";
|
|
10
|
-
const COLLAPSIBLE_NAME = "Collapsible";
|
|
11
|
-
const [createCollapsibleContext, createCollapsibleScope] = createContextScope(COLLAPSIBLE_NAME);
|
|
12
|
-
const [CollapsibleProvider, useCollapsibleContext] = createCollapsibleContext(COLLAPSIBLE_NAME);
|
|
13
|
-
const Collapsible = React.forwardRef(
|
|
14
|
-
(props, forwardedRef) => {
|
|
15
|
-
const {
|
|
16
|
-
__scopeCollapsible,
|
|
17
|
-
open: openProp,
|
|
18
|
-
defaultOpen,
|
|
19
|
-
disabled,
|
|
20
|
-
onOpenChange,
|
|
21
|
-
...collapsibleProps
|
|
22
|
-
} = props;
|
|
23
|
-
const [open, setOpen] = useControllableState({
|
|
24
|
-
prop: openProp,
|
|
25
|
-
defaultProp: defaultOpen || false,
|
|
26
|
-
onChange: onOpenChange
|
|
27
|
-
});
|
|
28
|
-
return <CollapsibleProvider scope={__scopeCollapsible} disabled={disabled} contentId={useId() || ""} open={open} onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])}><Stack data-state={getState(open)} data-disabled={disabled ? "" : void 0} {...collapsibleProps} ref={forwardedRef} /></CollapsibleProvider>;
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
Collapsible.displayName = COLLAPSIBLE_NAME;
|
|
32
|
-
const TRIGGER_NAME = "CollapsibleTrigger";
|
|
33
|
-
const CollapsibleTrigger = React.forwardRef(
|
|
34
|
-
(props, forwardedRef) => {
|
|
35
|
-
const { __scopeCollapsible, ...triggerProps } = props;
|
|
36
|
-
const context = useCollapsibleContext(TRIGGER_NAME, __scopeCollapsible);
|
|
37
|
-
return <Stack type="button" aria-controls={context.contentId} aria-expanded={context.open || false} data-state={getState(context.open)} data-disabled={context.disabled ? "" : void 0} disabled={context.disabled} {...triggerProps} ref={forwardedRef} onPress={composeEventHandlers(props.onPress, context.onOpenToggle)} />;
|
|
38
|
-
}
|
|
39
|
-
);
|
|
40
|
-
CollapsibleTrigger.displayName = TRIGGER_NAME;
|
|
41
|
-
const CONTENT_NAME = "CollapsibleContent";
|
|
42
|
-
const CollapsibleContent = React.forwardRef(
|
|
43
|
-
(props, forwardedRef) => {
|
|
44
|
-
const { forceMount, ...contentProps } = props;
|
|
45
|
-
const context = useCollapsibleContext(CONTENT_NAME, props.__scopeCollapsible);
|
|
46
|
-
return <>{({ present }) => <CollapsibleContentImpl {...contentProps} ref={forwardedRef} present={present} />}</>;
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
CollapsibleContent.displayName = CONTENT_NAME;
|
|
50
|
-
const CollapsibleContentImpl = React.forwardRef((props, forwardedRef) => {
|
|
51
|
-
const { __scopeCollapsible, present, children, ...contentProps } = props;
|
|
52
|
-
const context = useCollapsibleContext(CONTENT_NAME, __scopeCollapsible);
|
|
53
|
-
const [isPresent, setIsPresent] = React.useState(present);
|
|
54
|
-
const ref = React.useRef(null);
|
|
55
|
-
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
56
|
-
const heightRef = React.useRef(0);
|
|
57
|
-
const height = heightRef.current;
|
|
58
|
-
const widthRef = React.useRef(0);
|
|
59
|
-
const width = widthRef.current;
|
|
60
|
-
const isOpen = context.open || isPresent;
|
|
61
|
-
const isMountAnimationPreventedRef = React.useRef(isOpen);
|
|
62
|
-
const originalStylesRef = React.useRef();
|
|
63
|
-
React.useEffect(() => {
|
|
64
|
-
const rAF = requestAnimationFrame(() => isMountAnimationPreventedRef.current = false);
|
|
65
|
-
return () => cancelAnimationFrame(rAF);
|
|
66
|
-
}, []);
|
|
67
|
-
return <Stack data-state={getState(context.open)} data-disabled={context.disabled ? "" : void 0} id={context.contentId} hidden={!isOpen} {...contentProps} ref={composedRefs}>{isOpen && children}</Stack>;
|
|
68
|
-
});
|
|
69
|
-
function getState(open) {
|
|
70
|
-
return open ? "open" : "closed";
|
|
71
|
-
}
|
|
72
|
-
const Root = Collapsible;
|
|
73
|
-
const Trigger = CollapsibleTrigger;
|
|
74
|
-
const Content = CollapsibleContent;
|
|
1
|
+
const Collapsible = {};
|
|
75
2
|
export {
|
|
76
|
-
Collapsible
|
|
77
|
-
CollapsibleContent,
|
|
78
|
-
CollapsibleTrigger,
|
|
79
|
-
Content,
|
|
80
|
-
Root,
|
|
81
|
-
Trigger,
|
|
82
|
-
createCollapsibleScope
|
|
3
|
+
Collapsible
|
|
83
4
|
};
|
|
84
5
|
//# sourceMappingURL=Collapsible.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Collapsible.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useComposedRefs } from '@tamagui/compose-refs'\
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["export const Collapsible = {}\n\n// import { useComposedRefs } from '@tamagui/compose-refs'\n// import { Stack, StackProps, TamaguiElement, composeEventHandlers, useId } from '@tamagui/core'\n// import type { Scope } from '@tamagui/create-context'\n// import { createContextScope } from '@tamagui/create-context'\n// // import { Presence } from '@tamagui/react-presence'\n// import { useControllableState } from '@tamagui/use-controllable-state'\n// import * as React from 'react'\n\n// /* -------------------------------------------------------------------------------------------------\n// * Collapsible\n// * -----------------------------------------------------------------------------------------------*/\n\n// const COLLAPSIBLE_NAME = 'Collapsible'\n\n// type ScopedProps<P> = P & { __scopeCollapsible?: Scope }\n// const [createCollapsibleContext, createCollapsibleScope] = createContextScope(COLLAPSIBLE_NAME)\n\n// type CollapsibleContextValue = {\n// contentId: string\n// disabled?: boolean\n// open: boolean\n// onOpenToggle(): void\n// }\n\n// const [CollapsibleProvider, useCollapsibleContext] =\n// createCollapsibleContext<CollapsibleContextValue>(COLLAPSIBLE_NAME)\n\n// type CollapsibleElement = TamaguiElement\n// interface CollapsibleProps extends StackProps {\n// defaultOpen?: boolean\n// open?: boolean\n// disabled?: boolean\n// onOpenChange?(open: boolean): void\n// }\n\n// const 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, setOpen] = useControllableState({\n// prop: openProp,\n// defaultProp: defaultOpen || false,\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// <Stack\n// data-state={getState(open)}\n// data-disabled={disabled ? '' : undefined}\n// {...collapsibleProps}\n// ref={forwardedRef}\n// />\n// </CollapsibleProvider>\n// )\n// }\n// )\n\n// Collapsible.displayName = COLLAPSIBLE_NAME\n\n// /* -------------------------------------------------------------------------------------------------\n// * CollapsibleTrigger\n// * -----------------------------------------------------------------------------------------------*/\n\n// const TRIGGER_NAME = 'CollapsibleTrigger'\n\n// type CollapsibleTriggerElement = TamaguiElement\n// interface CollapsibleTriggerProps extends StackProps {}\n\n// const 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// <Stack\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// //\n// // onPress={composeEventHandlers(props.onPress, context.onOpenToggle)}\n// />\n// )\n// }\n// )\n\n// CollapsibleTrigger.displayName = TRIGGER_NAME\n\n// /* -------------------------------------------------------------------------------------------------\n// * CollapsibleContent\n// * -----------------------------------------------------------------------------------------------*/\n\n// const CONTENT_NAME = 'CollapsibleContent'\n\n// type CollapsibleContentElement = CollapsibleContentImplElement\n// interface 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\n// const 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// <>\n// {({ present }) => (\n// <CollapsibleContentImpl {...contentProps} ref={forwardedRef} present={present} />\n// )}\n// </>\n// // </Presence>\n// )\n// }\n// )\n\n// CollapsibleContent.displayName = CONTENT_NAME\n\n// /* -----------------------------------------------------------------------------------------------*/\n\n// type CollapsibleContentImplElement = TamaguiElement\n// interface CollapsibleContentImplProps extends StackProps {\n// present: boolean\n// }\n\n// const 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// // useIsomorphicLayoutEffect(() => {\n// // const node = ref.current\n// // if (node) {\n// // originalStylesRef.current = originalStylesRef.current || {\n// // transitionDuration: node.style.transitionDuration,\n// // animationDuration: node.style.animationDuration,\n// // animationFillMode: node.style.animationFillMode,\n// // }\n// // // block any animations/transitions so the element renders at its full dimensions\n// // node.style.transitionDuration = '0s'\n// // node.style.animationDuration = '0s'\n// // node.style.animationFillMode = '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.animationDuration = originalStylesRef.current.animationDuration\n// // node.style.animationFillMode = originalStylesRef.current.animationFillMode\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// <Stack\n// data-state={getState(context.open)}\n// data-disabled={context.disabled ? '' : undefined}\n// id={context.contentId}\n// hidden={!isOpen}\n// {...contentProps}\n// // @ts-expect-error\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// </Stack>\n// )\n// })\n\n// /* -----------------------------------------------------------------------------------------------*/\n\n// function getState(open?: boolean) {\n// return open ? 'open' : 'closed'\n// }\n\n// const Root = Collapsible\n// const Trigger = CollapsibleTrigger\n// const Content = CollapsibleContent\n\n// export {\n// createCollapsibleScope,\n// //\n// Collapsible,\n// CollapsibleTrigger,\n// CollapsibleContent,\n// //\n// Root,\n// Trigger,\n// Content,\n// }\n// export type { CollapsibleProps, CollapsibleTriggerProps, CollapsibleContentProps }\n"],
|
|
5
|
+
"mappings": "AAAO,MAAM,cAAc,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/collapsible",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.221",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -17,19 +17,19 @@
|
|
|
17
17
|
"watch": "tamagui-build --watch"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@tamagui/compose-refs": "^1.0.1-beta.
|
|
21
|
-
"@tamagui/core": "^1.0.1-beta.
|
|
22
|
-
"@tamagui/create-context": "^1.0.1-beta.
|
|
23
|
-
"@tamagui/polyfill-dev": "^1.0.1-beta.
|
|
24
|
-
"@tamagui/stacks": "^1.0.1-beta.
|
|
25
|
-
"@tamagui/use-controllable-state": "^1.0.1-beta.
|
|
20
|
+
"@tamagui/compose-refs": "^1.0.1-beta.221",
|
|
21
|
+
"@tamagui/core": "^1.0.1-beta.221",
|
|
22
|
+
"@tamagui/create-context": "^1.0.1-beta.221",
|
|
23
|
+
"@tamagui/polyfill-dev": "^1.0.1-beta.221",
|
|
24
|
+
"@tamagui/stacks": "^1.0.1-beta.221",
|
|
25
|
+
"@tamagui/use-controllable-state": "^1.0.1-beta.221"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": ">=18",
|
|
29
29
|
"react-dom": ">=18"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
32
|
+
"@tamagui/build": "^1.0.1-beta.221",
|
|
33
33
|
"react": ">=18",
|
|
34
34
|
"react-dom": ">=18"
|
|
35
35
|
},
|
package/src/Collapsible.tsx
CHANGED
|
@@ -1,254 +1,248 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from '@tamagui/
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
//
|
|
250
|
-
Root,
|
|
251
|
-
Trigger,
|
|
252
|
-
Content,
|
|
253
|
-
}
|
|
254
|
-
export type { CollapsibleProps, CollapsibleTriggerProps, CollapsibleContentProps }
|
|
1
|
+
export const Collapsible = {}
|
|
2
|
+
|
|
3
|
+
// import { useComposedRefs } from '@tamagui/compose-refs'
|
|
4
|
+
// import { Stack, StackProps, TamaguiElement, composeEventHandlers, useId } from '@tamagui/core'
|
|
5
|
+
// import type { Scope } from '@tamagui/create-context'
|
|
6
|
+
// import { createContextScope } from '@tamagui/create-context'
|
|
7
|
+
// // import { Presence } from '@tamagui/react-presence'
|
|
8
|
+
// import { useControllableState } from '@tamagui/use-controllable-state'
|
|
9
|
+
// import * as React from 'react'
|
|
10
|
+
|
|
11
|
+
// /* -------------------------------------------------------------------------------------------------
|
|
12
|
+
// * Collapsible
|
|
13
|
+
// * -----------------------------------------------------------------------------------------------*/
|
|
14
|
+
|
|
15
|
+
// const COLLAPSIBLE_NAME = 'Collapsible'
|
|
16
|
+
|
|
17
|
+
// type ScopedProps<P> = P & { __scopeCollapsible?: Scope }
|
|
18
|
+
// const [createCollapsibleContext, createCollapsibleScope] = createContextScope(COLLAPSIBLE_NAME)
|
|
19
|
+
|
|
20
|
+
// type CollapsibleContextValue = {
|
|
21
|
+
// contentId: string
|
|
22
|
+
// disabled?: boolean
|
|
23
|
+
// open: boolean
|
|
24
|
+
// onOpenToggle(): void
|
|
25
|
+
// }
|
|
26
|
+
|
|
27
|
+
// const [CollapsibleProvider, useCollapsibleContext] =
|
|
28
|
+
// createCollapsibleContext<CollapsibleContextValue>(COLLAPSIBLE_NAME)
|
|
29
|
+
|
|
30
|
+
// type CollapsibleElement = TamaguiElement
|
|
31
|
+
// interface CollapsibleProps extends StackProps {
|
|
32
|
+
// defaultOpen?: boolean
|
|
33
|
+
// open?: boolean
|
|
34
|
+
// disabled?: boolean
|
|
35
|
+
// onOpenChange?(open: boolean): void
|
|
36
|
+
// }
|
|
37
|
+
|
|
38
|
+
// const Collapsible = React.forwardRef<CollapsibleElement, CollapsibleProps>(
|
|
39
|
+
// (props: ScopedProps<CollapsibleProps>, forwardedRef) => {
|
|
40
|
+
// const {
|
|
41
|
+
// __scopeCollapsible,
|
|
42
|
+
// open: openProp,
|
|
43
|
+
// defaultOpen,
|
|
44
|
+
// disabled,
|
|
45
|
+
// onOpenChange,
|
|
46
|
+
// ...collapsibleProps
|
|
47
|
+
// } = props
|
|
48
|
+
|
|
49
|
+
// const [open, setOpen] = useControllableState({
|
|
50
|
+
// prop: openProp,
|
|
51
|
+
// defaultProp: defaultOpen || false,
|
|
52
|
+
// onChange: onOpenChange,
|
|
53
|
+
// })
|
|
54
|
+
|
|
55
|
+
// return (
|
|
56
|
+
// <CollapsibleProvider
|
|
57
|
+
// scope={__scopeCollapsible}
|
|
58
|
+
// disabled={disabled}
|
|
59
|
+
// contentId={useId() || ''}
|
|
60
|
+
// open={open}
|
|
61
|
+
// onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])}
|
|
62
|
+
// >
|
|
63
|
+
// <Stack
|
|
64
|
+
// data-state={getState(open)}
|
|
65
|
+
// data-disabled={disabled ? '' : undefined}
|
|
66
|
+
// {...collapsibleProps}
|
|
67
|
+
// ref={forwardedRef}
|
|
68
|
+
// />
|
|
69
|
+
// </CollapsibleProvider>
|
|
70
|
+
// )
|
|
71
|
+
// }
|
|
72
|
+
// )
|
|
73
|
+
|
|
74
|
+
// Collapsible.displayName = COLLAPSIBLE_NAME
|
|
75
|
+
|
|
76
|
+
// /* -------------------------------------------------------------------------------------------------
|
|
77
|
+
// * CollapsibleTrigger
|
|
78
|
+
// * -----------------------------------------------------------------------------------------------*/
|
|
79
|
+
|
|
80
|
+
// const TRIGGER_NAME = 'CollapsibleTrigger'
|
|
81
|
+
|
|
82
|
+
// type CollapsibleTriggerElement = TamaguiElement
|
|
83
|
+
// interface CollapsibleTriggerProps extends StackProps {}
|
|
84
|
+
|
|
85
|
+
// const CollapsibleTrigger = React.forwardRef<CollapsibleTriggerElement, CollapsibleTriggerProps>(
|
|
86
|
+
// (props: ScopedProps<CollapsibleTriggerProps>, forwardedRef) => {
|
|
87
|
+
// const { __scopeCollapsible, ...triggerProps } = props
|
|
88
|
+
// const context = useCollapsibleContext(TRIGGER_NAME, __scopeCollapsible)
|
|
89
|
+
// return (
|
|
90
|
+
// <Stack
|
|
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 ? '' : undefined}
|
|
96
|
+
// disabled={context.disabled}
|
|
97
|
+
// {...triggerProps}
|
|
98
|
+
// ref={forwardedRef}
|
|
99
|
+
// //
|
|
100
|
+
// // onPress={composeEventHandlers(props.onPress, context.onOpenToggle)}
|
|
101
|
+
// />
|
|
102
|
+
// )
|
|
103
|
+
// }
|
|
104
|
+
// )
|
|
105
|
+
|
|
106
|
+
// CollapsibleTrigger.displayName = TRIGGER_NAME
|
|
107
|
+
|
|
108
|
+
// /* -------------------------------------------------------------------------------------------------
|
|
109
|
+
// * CollapsibleContent
|
|
110
|
+
// * -----------------------------------------------------------------------------------------------*/
|
|
111
|
+
|
|
112
|
+
// const CONTENT_NAME = 'CollapsibleContent'
|
|
113
|
+
|
|
114
|
+
// type CollapsibleContentElement = CollapsibleContentImplElement
|
|
115
|
+
// interface CollapsibleContentProps extends Omit<CollapsibleContentImplProps, 'present'> {
|
|
116
|
+
// /**
|
|
117
|
+
// * Used to force mounting when more control is needed. Useful when
|
|
118
|
+
// * controlling animation with React animation libraries.
|
|
119
|
+
// */
|
|
120
|
+
// forceMount?: true
|
|
121
|
+
// }
|
|
122
|
+
|
|
123
|
+
// const CollapsibleContent = React.forwardRef<CollapsibleContentElement, CollapsibleContentProps>(
|
|
124
|
+
// (props: ScopedProps<CollapsibleContentProps>, forwardedRef) => {
|
|
125
|
+
// const { forceMount, ...contentProps } = props
|
|
126
|
+
// const context = useCollapsibleContext(CONTENT_NAME, props.__scopeCollapsible)
|
|
127
|
+
// return (
|
|
128
|
+
// // <Presence present={forceMount || context.open}>
|
|
129
|
+
// <>
|
|
130
|
+
// {({ present }) => (
|
|
131
|
+
// <CollapsibleContentImpl {...contentProps} ref={forwardedRef} present={present} />
|
|
132
|
+
// )}
|
|
133
|
+
// </>
|
|
134
|
+
// // </Presence>
|
|
135
|
+
// )
|
|
136
|
+
// }
|
|
137
|
+
// )
|
|
138
|
+
|
|
139
|
+
// CollapsibleContent.displayName = CONTENT_NAME
|
|
140
|
+
|
|
141
|
+
// /* -----------------------------------------------------------------------------------------------*/
|
|
142
|
+
|
|
143
|
+
// type CollapsibleContentImplElement = TamaguiElement
|
|
144
|
+
// interface CollapsibleContentImplProps extends StackProps {
|
|
145
|
+
// present: boolean
|
|
146
|
+
// }
|
|
147
|
+
|
|
148
|
+
// const CollapsibleContentImpl = React.forwardRef<
|
|
149
|
+
// CollapsibleContentImplElement,
|
|
150
|
+
// CollapsibleContentImplProps
|
|
151
|
+
// >((props: ScopedProps<CollapsibleContentImplProps>, forwardedRef) => {
|
|
152
|
+
// const { __scopeCollapsible, present, children, ...contentProps } = props
|
|
153
|
+
// const context = useCollapsibleContext(CONTENT_NAME, __scopeCollapsible)
|
|
154
|
+
// const [isPresent, setIsPresent] = React.useState(present)
|
|
155
|
+
// const ref = React.useRef<CollapsibleContentImplElement>(null)
|
|
156
|
+
// const composedRefs = useComposedRefs(forwardedRef, ref)
|
|
157
|
+
// const heightRef = React.useRef<number | undefined>(0)
|
|
158
|
+
// const height = heightRef.current
|
|
159
|
+
// const widthRef = React.useRef<number | undefined>(0)
|
|
160
|
+
// const width = widthRef.current
|
|
161
|
+
// // when opening we want it to immediately open to retrieve dimensions
|
|
162
|
+
// // when closing we delay `present` to retrieve dimensions before closing
|
|
163
|
+
// const isOpen = context.open || isPresent
|
|
164
|
+
// const isMountAnimationPreventedRef = React.useRef(isOpen)
|
|
165
|
+
// const originalStylesRef = React.useRef<Record<string, string>>()
|
|
166
|
+
|
|
167
|
+
// React.useEffect(() => {
|
|
168
|
+
// const rAF = requestAnimationFrame(() => (isMountAnimationPreventedRef.current = false))
|
|
169
|
+
// return () => cancelAnimationFrame(rAF)
|
|
170
|
+
// }, [])
|
|
171
|
+
|
|
172
|
+
// // useIsomorphicLayoutEffect(() => {
|
|
173
|
+
// // const node = ref.current
|
|
174
|
+
// // if (node) {
|
|
175
|
+
// // originalStylesRef.current = originalStylesRef.current || {
|
|
176
|
+
// // transitionDuration: node.style.transitionDuration,
|
|
177
|
+
// // animationDuration: node.style.animationDuration,
|
|
178
|
+
// // animationFillMode: node.style.animationFillMode,
|
|
179
|
+
// // }
|
|
180
|
+
// // // block any animations/transitions so the element renders at its full dimensions
|
|
181
|
+
// // node.style.transitionDuration = '0s'
|
|
182
|
+
// // node.style.animationDuration = '0s'
|
|
183
|
+
// // node.style.animationFillMode = 'none'
|
|
184
|
+
|
|
185
|
+
// // // get width and height from full dimensions
|
|
186
|
+
// // const rect = node.getBoundingClientRect()
|
|
187
|
+
// // heightRef.current = rect.height
|
|
188
|
+
// // widthRef.current = rect.width
|
|
189
|
+
|
|
190
|
+
// // // kick off any animations/transitions that were originally set up if it isn't the initial mount
|
|
191
|
+
// // if (!isMountAnimationPreventedRef.current) {
|
|
192
|
+
// // node.style.transitionDuration = originalStylesRef.current.transitionDuration
|
|
193
|
+
// // node.style.animationDuration = originalStylesRef.current.animationDuration
|
|
194
|
+
// // node.style.animationFillMode = originalStylesRef.current.animationFillMode
|
|
195
|
+
// // }
|
|
196
|
+
|
|
197
|
+
// // setIsPresent(present)
|
|
198
|
+
// // }
|
|
199
|
+
// // /**
|
|
200
|
+
// // * depends on `context.open` because it will change to `false`
|
|
201
|
+
// // * when a close is triggered but `present` will be `false` on
|
|
202
|
+
// // * animation end (so when close finishes). This allows us to
|
|
203
|
+
// // * retrieve the dimensions *before* closing.
|
|
204
|
+
// // */
|
|
205
|
+
// // }, [context.open, present])
|
|
206
|
+
|
|
207
|
+
// return (
|
|
208
|
+
// <Stack
|
|
209
|
+
// data-state={getState(context.open)}
|
|
210
|
+
// data-disabled={context.disabled ? '' : undefined}
|
|
211
|
+
// id={context.contentId}
|
|
212
|
+
// hidden={!isOpen}
|
|
213
|
+
// {...contentProps}
|
|
214
|
+
// // @ts-expect-error
|
|
215
|
+
// ref={composedRefs}
|
|
216
|
+
// // style={{
|
|
217
|
+
// // [`--radix-collapsible-content-height` as any]: height ? `${height}px` : undefined,
|
|
218
|
+
// // [`--radix-collapsible-content-width` as any]: width ? `${width}px` : undefined,
|
|
219
|
+
// // ...props.style,
|
|
220
|
+
// // }}
|
|
221
|
+
// >
|
|
222
|
+
// {isOpen && children}
|
|
223
|
+
// </Stack>
|
|
224
|
+
// )
|
|
225
|
+
// })
|
|
226
|
+
|
|
227
|
+
// /* -----------------------------------------------------------------------------------------------*/
|
|
228
|
+
|
|
229
|
+
// function getState(open?: boolean) {
|
|
230
|
+
// return open ? 'open' : 'closed'
|
|
231
|
+
// }
|
|
232
|
+
|
|
233
|
+
// const Root = Collapsible
|
|
234
|
+
// const Trigger = CollapsibleTrigger
|
|
235
|
+
// const Content = CollapsibleContent
|
|
236
|
+
|
|
237
|
+
// export {
|
|
238
|
+
// createCollapsibleScope,
|
|
239
|
+
// //
|
|
240
|
+
// Collapsible,
|
|
241
|
+
// CollapsibleTrigger,
|
|
242
|
+
// CollapsibleContent,
|
|
243
|
+
// //
|
|
244
|
+
// Root,
|
|
245
|
+
// Trigger,
|
|
246
|
+
// Content,
|
|
247
|
+
// }
|
|
248
|
+
// export type { CollapsibleProps, CollapsibleTriggerProps, CollapsibleContentProps }
|
package/types/Collapsible.d.ts
CHANGED
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
declare const createCollapsibleScope: import("@tamagui/create-context").CreateScope;
|
|
4
|
-
interface CollapsibleProps extends StackProps {
|
|
5
|
-
defaultOpen?: boolean;
|
|
6
|
-
open?: boolean;
|
|
7
|
-
disabled?: boolean;
|
|
8
|
-
onOpenChange?(open: boolean): void;
|
|
9
|
-
}
|
|
10
|
-
declare const Collapsible: React.ForwardRefExoticComponent<CollapsibleProps & React.RefAttributes<TamaguiElement>>;
|
|
11
|
-
interface CollapsibleTriggerProps extends StackProps {
|
|
12
|
-
}
|
|
13
|
-
declare const CollapsibleTrigger: React.ForwardRefExoticComponent<CollapsibleTriggerProps & React.RefAttributes<TamaguiElement>>;
|
|
14
|
-
interface CollapsibleContentProps extends Omit<CollapsibleContentImplProps, 'present'> {
|
|
15
|
-
/**
|
|
16
|
-
* Used to force mounting when more control is needed. Useful when
|
|
17
|
-
* controlling animation with React animation libraries.
|
|
18
|
-
*/
|
|
19
|
-
forceMount?: true;
|
|
20
|
-
}
|
|
21
|
-
declare const CollapsibleContent: React.ForwardRefExoticComponent<CollapsibleContentProps & React.RefAttributes<TamaguiElement>>;
|
|
22
|
-
interface CollapsibleContentImplProps extends StackProps {
|
|
23
|
-
present: boolean;
|
|
24
|
-
}
|
|
25
|
-
declare const Root: React.ForwardRefExoticComponent<CollapsibleProps & React.RefAttributes<TamaguiElement>>;
|
|
26
|
-
declare const Trigger: React.ForwardRefExoticComponent<CollapsibleTriggerProps & React.RefAttributes<TamaguiElement>>;
|
|
27
|
-
declare const Content: React.ForwardRefExoticComponent<CollapsibleContentProps & React.RefAttributes<TamaguiElement>>;
|
|
28
|
-
export { createCollapsibleScope, Collapsible, CollapsibleTrigger, CollapsibleContent, Root, Trigger, Content, };
|
|
29
|
-
export type { CollapsibleProps, CollapsibleTriggerProps, CollapsibleContentProps };
|
|
1
|
+
export declare const Collapsible: {};
|
|
30
2
|
//# sourceMappingURL=Collapsible.d.ts.map
|