@tamagui/collapsible 1.88.13 → 1.89.0-1706308641099
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/esm/Collapsible.mjs +100 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/jsx/Collapsible.mjs +100 -0
- package/dist/jsx/index.mjs +1 -0
- package/package.json +10 -10
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { AnimatePresence, ResetPresence } from "@tamagui/animate-presence";
|
|
2
|
+
import { composeEventHandlers, withStaticProperties } from "@tamagui/helpers";
|
|
3
|
+
import { useControllableState } from "@tamagui/use-controllable-state";
|
|
4
|
+
import { Stack, createStyledContext, styled } from "@tamagui/web";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
const COLLAPSIBLE_NAME = "Collapsible",
|
|
8
|
+
{
|
|
9
|
+
Provider: CollapsibleProvider,
|
|
10
|
+
useStyledContext: useCollapsibleContext
|
|
11
|
+
} = createStyledContext(),
|
|
12
|
+
_Collapsible = React.forwardRef((props, forwardedRef) => {
|
|
13
|
+
const {
|
|
14
|
+
__scopeCollapsible,
|
|
15
|
+
open: openProp,
|
|
16
|
+
defaultOpen,
|
|
17
|
+
disabled,
|
|
18
|
+
onOpenChange,
|
|
19
|
+
...collapsibleProps
|
|
20
|
+
} = props,
|
|
21
|
+
[open = !1, setOpen] = useControllableState({
|
|
22
|
+
prop: openProp,
|
|
23
|
+
defaultProp: defaultOpen,
|
|
24
|
+
onChange: onOpenChange
|
|
25
|
+
});
|
|
26
|
+
return /* @__PURE__ */jsx(CollapsibleProvider, {
|
|
27
|
+
scope: __scopeCollapsible,
|
|
28
|
+
disabled,
|
|
29
|
+
contentId: React.useId(),
|
|
30
|
+
open,
|
|
31
|
+
onOpenToggle: React.useCallback(() => setOpen(prevOpen => !prevOpen), [setOpen]),
|
|
32
|
+
children: /* @__PURE__ */jsx(Stack, {
|
|
33
|
+
"data-state": getState(open),
|
|
34
|
+
"data-disabled": disabled ? "" : void 0,
|
|
35
|
+
...collapsibleProps,
|
|
36
|
+
ref: forwardedRef
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
_Collapsible.displayName = COLLAPSIBLE_NAME;
|
|
41
|
+
const TRIGGER_NAME = "CollapsibleTrigger",
|
|
42
|
+
CollapsibleTriggerFrame = styled(Stack, {
|
|
43
|
+
name: TRIGGER_NAME,
|
|
44
|
+
tag: "button"
|
|
45
|
+
}),
|
|
46
|
+
CollapsibleTrigger = CollapsibleTriggerFrame.styleable((props, forwardedRef) => {
|
|
47
|
+
const {
|
|
48
|
+
__scopeCollapsible,
|
|
49
|
+
children,
|
|
50
|
+
...triggerProps
|
|
51
|
+
} = props,
|
|
52
|
+
context = useCollapsibleContext(__scopeCollapsible);
|
|
53
|
+
return /* @__PURE__ */jsx(CollapsibleTriggerFrame, {
|
|
54
|
+
"aria-controls": context.contentId,
|
|
55
|
+
"aria-expanded": context.open || !1,
|
|
56
|
+
"data-state": getState(context.open),
|
|
57
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
58
|
+
disabled: context.disabled,
|
|
59
|
+
...triggerProps,
|
|
60
|
+
ref: forwardedRef,
|
|
61
|
+
onPress: composeEventHandlers(props.onPress, context.onOpenToggle),
|
|
62
|
+
children: typeof children == "function" ? children({
|
|
63
|
+
open: context.open
|
|
64
|
+
}) : children
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
CollapsibleTrigger.displayName = TRIGGER_NAME;
|
|
68
|
+
const CONTENT_NAME = "CollapsibleContent",
|
|
69
|
+
CollapsibleContentFrame = styled(Stack, {
|
|
70
|
+
name: CONTENT_NAME
|
|
71
|
+
}),
|
|
72
|
+
CollapsibleContent = CollapsibleContentFrame.styleable((props, forwardedRef) => {
|
|
73
|
+
const {
|
|
74
|
+
forceMount,
|
|
75
|
+
children,
|
|
76
|
+
// @ts-expect-error
|
|
77
|
+
__scopeCollapsible,
|
|
78
|
+
...contentProps
|
|
79
|
+
} = props,
|
|
80
|
+
context = useCollapsibleContext(__scopeCollapsible);
|
|
81
|
+
return /* @__PURE__ */jsx(AnimatePresence, {
|
|
82
|
+
...contentProps,
|
|
83
|
+
children: forceMount || context.open ? /* @__PURE__ */jsx(CollapsibleContentFrame, {
|
|
84
|
+
ref: forwardedRef,
|
|
85
|
+
...contentProps,
|
|
86
|
+
children: /* @__PURE__ */jsx(ResetPresence, {
|
|
87
|
+
children
|
|
88
|
+
})
|
|
89
|
+
}) : null
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
CollapsibleContent.displayName = CONTENT_NAME;
|
|
93
|
+
function getState(open) {
|
|
94
|
+
return open ? "open" : "closed";
|
|
95
|
+
}
|
|
96
|
+
const Collapsible = withStaticProperties(_Collapsible, {
|
|
97
|
+
Trigger: CollapsibleTrigger,
|
|
98
|
+
Content: CollapsibleContent
|
|
99
|
+
});
|
|
100
|
+
export { Collapsible, CollapsibleContent, CollapsibleContentFrame, CollapsibleTrigger, CollapsibleTriggerFrame };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Collapsible.mjs";
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { AnimatePresence, ResetPresence } from "@tamagui/animate-presence";
|
|
2
|
+
import { composeEventHandlers, withStaticProperties } from "@tamagui/helpers";
|
|
3
|
+
import { useControllableState } from "@tamagui/use-controllable-state";
|
|
4
|
+
import { Stack, createStyledContext, styled } from "@tamagui/web";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
const COLLAPSIBLE_NAME = "Collapsible",
|
|
8
|
+
{
|
|
9
|
+
Provider: CollapsibleProvider,
|
|
10
|
+
useStyledContext: useCollapsibleContext
|
|
11
|
+
} = createStyledContext(),
|
|
12
|
+
_Collapsible = React.forwardRef((props, forwardedRef) => {
|
|
13
|
+
const {
|
|
14
|
+
__scopeCollapsible,
|
|
15
|
+
open: openProp,
|
|
16
|
+
defaultOpen,
|
|
17
|
+
disabled,
|
|
18
|
+
onOpenChange,
|
|
19
|
+
...collapsibleProps
|
|
20
|
+
} = props,
|
|
21
|
+
[open = !1, setOpen] = useControllableState({
|
|
22
|
+
prop: openProp,
|
|
23
|
+
defaultProp: defaultOpen,
|
|
24
|
+
onChange: onOpenChange
|
|
25
|
+
});
|
|
26
|
+
return /* @__PURE__ */jsx(CollapsibleProvider, {
|
|
27
|
+
scope: __scopeCollapsible,
|
|
28
|
+
disabled,
|
|
29
|
+
contentId: React.useId(),
|
|
30
|
+
open,
|
|
31
|
+
onOpenToggle: React.useCallback(() => setOpen(prevOpen => !prevOpen), [setOpen]),
|
|
32
|
+
children: /* @__PURE__ */jsx(Stack, {
|
|
33
|
+
"data-state": getState(open),
|
|
34
|
+
"data-disabled": disabled ? "" : void 0,
|
|
35
|
+
...collapsibleProps,
|
|
36
|
+
ref: forwardedRef
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
_Collapsible.displayName = COLLAPSIBLE_NAME;
|
|
41
|
+
const TRIGGER_NAME = "CollapsibleTrigger",
|
|
42
|
+
CollapsibleTriggerFrame = styled(Stack, {
|
|
43
|
+
name: TRIGGER_NAME,
|
|
44
|
+
tag: "button"
|
|
45
|
+
}),
|
|
46
|
+
CollapsibleTrigger = CollapsibleTriggerFrame.styleable((props, forwardedRef) => {
|
|
47
|
+
const {
|
|
48
|
+
__scopeCollapsible,
|
|
49
|
+
children,
|
|
50
|
+
...triggerProps
|
|
51
|
+
} = props,
|
|
52
|
+
context = useCollapsibleContext(__scopeCollapsible);
|
|
53
|
+
return /* @__PURE__ */jsx(CollapsibleTriggerFrame, {
|
|
54
|
+
"aria-controls": context.contentId,
|
|
55
|
+
"aria-expanded": context.open || !1,
|
|
56
|
+
"data-state": getState(context.open),
|
|
57
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
58
|
+
disabled: context.disabled,
|
|
59
|
+
...triggerProps,
|
|
60
|
+
ref: forwardedRef,
|
|
61
|
+
onPress: composeEventHandlers(props.onPress, context.onOpenToggle),
|
|
62
|
+
children: typeof children == "function" ? children({
|
|
63
|
+
open: context.open
|
|
64
|
+
}) : children
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
CollapsibleTrigger.displayName = TRIGGER_NAME;
|
|
68
|
+
const CONTENT_NAME = "CollapsibleContent",
|
|
69
|
+
CollapsibleContentFrame = styled(Stack, {
|
|
70
|
+
name: CONTENT_NAME
|
|
71
|
+
}),
|
|
72
|
+
CollapsibleContent = CollapsibleContentFrame.styleable((props, forwardedRef) => {
|
|
73
|
+
const {
|
|
74
|
+
forceMount,
|
|
75
|
+
children,
|
|
76
|
+
// @ts-expect-error
|
|
77
|
+
__scopeCollapsible,
|
|
78
|
+
...contentProps
|
|
79
|
+
} = props,
|
|
80
|
+
context = useCollapsibleContext(__scopeCollapsible);
|
|
81
|
+
return /* @__PURE__ */jsx(AnimatePresence, {
|
|
82
|
+
...contentProps,
|
|
83
|
+
children: forceMount || context.open ? /* @__PURE__ */jsx(CollapsibleContentFrame, {
|
|
84
|
+
ref: forwardedRef,
|
|
85
|
+
...contentProps,
|
|
86
|
+
children: /* @__PURE__ */jsx(ResetPresence, {
|
|
87
|
+
children
|
|
88
|
+
})
|
|
89
|
+
}) : null
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
CollapsibleContent.displayName = CONTENT_NAME;
|
|
93
|
+
function getState(open) {
|
|
94
|
+
return open ? "open" : "closed";
|
|
95
|
+
}
|
|
96
|
+
const Collapsible = withStaticProperties(_Collapsible, {
|
|
97
|
+
Trigger: CollapsibleTrigger,
|
|
98
|
+
Content: CollapsibleContent
|
|
99
|
+
});
|
|
100
|
+
export { Collapsible, CollapsibleContent, CollapsibleContentFrame, CollapsibleTrigger, CollapsibleTriggerFrame };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Collapsible.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/collapsible",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.89.0-1706308641099",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -21,20 +21,20 @@
|
|
|
21
21
|
"clean:build": "tamagui-build clean:build"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@tamagui/animate-presence": "1.
|
|
25
|
-
"@tamagui/compose-refs": "1.
|
|
26
|
-
"@tamagui/core": "1.
|
|
27
|
-
"@tamagui/create-context": "1.
|
|
28
|
-
"@tamagui/helpers": "1.
|
|
29
|
-
"@tamagui/polyfill-dev": "1.
|
|
30
|
-
"@tamagui/stacks": "1.
|
|
31
|
-
"@tamagui/use-controllable-state": "1.
|
|
24
|
+
"@tamagui/animate-presence": "1.89.0-1706308641099",
|
|
25
|
+
"@tamagui/compose-refs": "1.89.0-1706308641099",
|
|
26
|
+
"@tamagui/core": "1.89.0-1706308641099",
|
|
27
|
+
"@tamagui/create-context": "1.89.0-1706308641099",
|
|
28
|
+
"@tamagui/helpers": "1.89.0-1706308641099",
|
|
29
|
+
"@tamagui/polyfill-dev": "1.89.0-1706308641099",
|
|
30
|
+
"@tamagui/stacks": "1.89.0-1706308641099",
|
|
31
|
+
"@tamagui/use-controllable-state": "1.89.0-1706308641099"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": "*"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@tamagui/build": "1.
|
|
37
|
+
"@tamagui/build": "1.89.0-1706308641099",
|
|
38
38
|
"react": "^18.2.0"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|