@tamagui/tabs 2.7.7 → 3.0.0-beta.643.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/cjs/StyledContext.cjs +16 -20
- package/dist/cjs/StyledContext.native.cjs +31 -0
- package/dist/cjs/StyledContext.native.js +17 -20
- package/dist/cjs/StyledContext.native.js.map +1 -1
- package/dist/cjs/Tabs.cjs +227 -68
- package/dist/cjs/Tabs.native.cjs +250 -0
- package/dist/cjs/Tabs.native.js +233 -67
- package/dist/cjs/Tabs.native.js.map +1 -1
- package/dist/cjs/index.cjs +10 -27
- package/dist/cjs/index.native.cjs +22 -0
- package/dist/cjs/index.native.js +11 -27
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/StyledContext.mjs +3 -4
- package/dist/esm/StyledContext.mjs.map +1 -1
- package/dist/esm/StyledContext.native.js +3 -4
- package/dist/esm/StyledContext.native.js.map +1 -1
- package/dist/esm/Tabs.mjs +206 -55
- package/dist/esm/Tabs.mjs.map +1 -1
- package/dist/esm/Tabs.native.js +212 -55
- package/dist/esm/Tabs.native.js.map +1 -1
- package/dist/esm/index.js +3 -11
- package/dist/esm/index.mjs +3 -11
- package/dist/esm/index.native.js +3 -11
- package/dist/jsx/StyledContext.mjs +3 -4
- package/dist/jsx/StyledContext.mjs.map +1 -1
- package/dist/jsx/StyledContext.native.cjs +31 -0
- package/dist/jsx/StyledContext.native.js +17 -20
- package/dist/jsx/StyledContext.native.js.map +1 -1
- package/dist/jsx/Tabs.mjs +206 -55
- package/dist/jsx/Tabs.mjs.map +1 -1
- package/dist/jsx/Tabs.native.cjs +250 -0
- package/dist/jsx/Tabs.native.js +233 -67
- package/dist/jsx/Tabs.native.js.map +1 -1
- package/dist/jsx/index.js +3 -11
- package/dist/jsx/index.mjs +3 -11
- package/dist/jsx/index.native.cjs +22 -0
- package/dist/jsx/index.native.js +11 -27
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +11 -17
- package/src/StyledContext.tsx +3 -3
- package/src/Tabs.tsx +368 -55
- package/src/index.ts +1 -9
- package/types/StyledContext.d.ts +3 -3
- package/types/StyledContext.d.ts.map +1 -1
- package/types/Tabs.d.ts +398 -35
- package/types/Tabs.d.ts.map +1 -1
- package/types/index.d.ts +1 -537
- package/types/index.d.ts.map +1 -1
- package/dist/cjs/createTabs.cjs +0 -293
- package/dist/cjs/createTabs.native.js +0 -308
- package/dist/cjs/createTabs.native.js.map +0 -1
- package/dist/esm/createTabs.mjs +0 -257
- package/dist/esm/createTabs.mjs.map +0 -1
- package/dist/esm/createTabs.native.js +0 -269
- package/dist/esm/createTabs.native.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/jsx/createTabs.mjs +0 -257
- package/dist/jsx/createTabs.mjs.map +0 -1
- package/dist/jsx/createTabs.native.js +0 -308
- package/dist/jsx/createTabs.native.js.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
- package/src/createTabs.tsx +0 -438
- package/types/createTabs.d.ts +0 -527
- package/types/createTabs.d.ts.map +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var index_exports = {};
|
|
20
|
+
module.exports = __toCommonJS(index_exports);
|
|
21
|
+
__reExport(index_exports, require("./StyledContext.native.js"), module.exports);
|
|
22
|
+
__reExport(index_exports, require("./Tabs.native.js"), module.exports);
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -1,40 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all) __defProp(target, name, {
|
|
9
|
-
get: all[name],
|
|
10
|
-
enumerable: true
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
8
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
21
16
|
};
|
|
22
17
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
23
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
24
|
-
value: true
|
|
25
|
-
}), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
19
|
var index_exports = {};
|
|
27
|
-
__export(index_exports, {
|
|
28
|
-
Tabs: () => Tabs
|
|
29
|
-
});
|
|
30
20
|
module.exports = __toCommonJS(index_exports);
|
|
31
|
-
var import_createTabs = require("./createTabs.native.js");
|
|
32
|
-
var import_Tabs = require("./Tabs.native.js");
|
|
33
|
-
__reExport(index_exports, require("./createTabs.native.js"), module.exports);
|
|
34
21
|
__reExport(index_exports, require("./StyledContext.native.js"), module.exports);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
TabFrame: import_Tabs.DefaultTabsTabFrame,
|
|
38
|
-
TabsFrame: import_Tabs.DefaultTabsFrame
|
|
39
|
-
});
|
|
22
|
+
__reExport(index_exports, require("./Tabs.native.js"), module.exports);
|
|
23
|
+
|
|
40
24
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["cjs/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, \"default\"), secondTarget && __copyProps(secondTarget, mod, \"default\"));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\nmodule.exports = __toCommonJS(index_exports);\n__reExport(index_exports, require(\"./StyledContext\"), module.exports);\n__reExport(index_exports, require(\"./Tabs\"), module.exports);\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,cAAc,QAAQ,KAAK,kBAAkB,YAAY,QAAQ,KAAK,SAAS,GAAG,gBAAgB,YAAY,cAAc,KAAK,SAAS;AAC9I,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,OAAO,UAAU,aAAa,aAAa;AAC3C,WAAW,eAAe,QAAQ,2BAAiB,GAAG,OAAO,OAAO;AACpE,WAAW,eAAe,QAAQ,kBAAQ,GAAG,OAAO,OAAO"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createStyledContext } from "@tamagui/core";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} = createStyledContext();
|
|
2
|
+
|
|
3
|
+
const { Provider: TabsProvider, useStyledContext: useTabsContext } = createStyledContext();
|
|
4
|
+
|
|
6
5
|
export { TabsProvider, useTabsContext };
|
|
7
6
|
//# sourceMappingURL=StyledContext.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"StyledContext.js","names":[],"sources":["esm/StyledContext.js"],"sourcesContent":["import { createStyledContext } from \"@tamagui/core\";\nconst { Provider: TabsProvider, useStyledContext: useTabsContext } = createStyledContext();\nexport {\n TabsProvider,\n useTabsContext\n};\n//# sourceMappingURL=StyledContext.js.map\n"],"mappings":";;;AACA,MAAM,EAAE,UAAU,cAAc,kBAAkB,mBAAmB,oBAAoB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createStyledContext } from "@tamagui/core";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} = createStyledContext();
|
|
2
|
+
|
|
3
|
+
var { Provider: TabsProvider, useStyledContext: useTabsContext } = createStyledContext();
|
|
4
|
+
|
|
6
5
|
export { TabsProvider, useTabsContext };
|
|
7
6
|
//# sourceMappingURL=StyledContext.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"StyledContext.native.js","names":[],"sources":["esm/StyledContext.native.js"],"sourcesContent":["import { createStyledContext } from \"@tamagui/core\";\nvar { Provider: TabsProvider, useStyledContext: useTabsContext } = createStyledContext();\nexport {\n TabsProvider,\n useTabsContext\n};\n//# sourceMappingURL=StyledContext.js.map\n"],"mappings":";;;AACA,IAAI,EAAE,UAAU,cAAc,kBAAkB,mBAAmB,oBAAoB"}
|
package/dist/esm/Tabs.mjs
CHANGED
|
@@ -1,56 +1,207 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
1
|
+
import { composeRefs } from "@tamagui/compose-refs";
|
|
2
|
+
import { isWeb } from "@tamagui/constants";
|
|
3
|
+
import { View, createStyledHOC, styled } from "@tamagui/core";
|
|
4
|
+
import { composeEventHandlers, withStaticProperties } from "@tamagui/helpers";
|
|
5
|
+
import { RovingFocusGroup } from "@tamagui/roving-focus";
|
|
6
|
+
import { SizeContext } from "@tamagui/size";
|
|
7
|
+
import { useTab, useTabContent, useTabs, useTabsList } from "@tamagui/tabs-headless";
|
|
8
|
+
import { useEvent } from "@tamagui/web";
|
|
9
|
+
import * as React from "react";
|
|
10
|
+
import { TabsProvider, useTabsContext } from "./StyledContext.mjs";
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
12
|
+
|
|
13
|
+
const TABS_CONTEXT = "TabsContext";
|
|
14
|
+
const TabsFrame = styled(View, {
|
|
15
|
+
displayName: "Tabs",
|
|
16
|
+
context: SizeContext
|
|
17
|
+
});
|
|
18
|
+
const TabsListFrame = styled(View, {
|
|
19
|
+
displayName: "TabsList",
|
|
20
|
+
context: SizeContext,
|
|
21
|
+
role: "tablist"
|
|
22
|
+
});
|
|
23
|
+
const TabsTabFrame = styled(View, {
|
|
24
|
+
displayName: "TabsTrigger",
|
|
25
|
+
context: SizeContext,
|
|
26
|
+
role: "tab",
|
|
27
|
+
variants: { disabled: { true: { pointerEvents: "none" } } }
|
|
28
|
+
});
|
|
29
|
+
const TabsContentFrame = styled(View, {
|
|
30
|
+
displayName: "TabsContent",
|
|
31
|
+
context: SizeContext
|
|
32
|
+
});
|
|
33
|
+
const TabsListDisabledContext = React.createContext(false);
|
|
34
|
+
const TabsList = createStyledHOC(TabsListFrame, function TabsList2(props, forwardedRef) {
|
|
35
|
+
const { __scopeTabs, loop = true, disabled = false, children, ...listProps } = props;
|
|
36
|
+
const context = useTabsContext(__scopeTabs);
|
|
37
|
+
const { listProps: headlessListProps } = useTabsList({
|
|
38
|
+
orientation: context.orientation,
|
|
39
|
+
disabled
|
|
40
|
+
});
|
|
41
|
+
return /* @__PURE__ */ jsx(TabsListDisabledContext.Provider, {
|
|
42
|
+
value: disabled,
|
|
43
|
+
children: /* @__PURE__ */ jsx(RovingFocusGroup, {
|
|
44
|
+
__scopeRovingFocusGroup: __scopeTabs || TABS_CONTEXT,
|
|
45
|
+
orientation: context.orientation,
|
|
46
|
+
dir: context.dir,
|
|
47
|
+
loop,
|
|
48
|
+
asChild: true,
|
|
49
|
+
children: /* @__PURE__ */ jsx(TabsListFrame, {
|
|
50
|
+
...headlessListProps,
|
|
51
|
+
flexDirection: context.orientation === "vertical" ? "column" : "row",
|
|
52
|
+
ref: forwardedRef,
|
|
53
|
+
...listProps,
|
|
54
|
+
children
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
const TabsTab = createStyledHOC(TabsTabFrame, function TabsTab2(props, forwardedRef) {
|
|
60
|
+
const { __scopeTabs, value, disabled: disabledProp, onInteraction, activeStyle, activeTheme, onLayout, onMouseEnter, onMouseLeave, onPress, onKeyDown, onFocus, onBlur, ...triggerProps } = props;
|
|
61
|
+
const context = useTabsContext(__scopeTabs);
|
|
62
|
+
const listDisabled = React.useContext(TabsListDisabledContext);
|
|
63
|
+
const disabled = disabledProp ?? listDisabled;
|
|
64
|
+
const { isSelected, tabProps } = useTab({
|
|
65
|
+
baseId: context.baseId,
|
|
66
|
+
value,
|
|
67
|
+
selectedValue: context.value,
|
|
68
|
+
disabled,
|
|
69
|
+
activationMode: context.activationMode,
|
|
70
|
+
onChange: context.onChange
|
|
71
|
+
});
|
|
72
|
+
const { onPress: activateOnPress, onKeyDown: activateOnKeyDown, onFocus: activateOnFocus, ...tabA11yProps } = tabProps;
|
|
73
|
+
const [layout, setLayout] = React.useState(null);
|
|
74
|
+
const triggerRef = React.useRef(null);
|
|
75
|
+
const emitInteraction = useEvent((type, layout2) => {
|
|
76
|
+
onInteraction?.(type, layout2);
|
|
77
|
+
});
|
|
78
|
+
React.useEffect(() => {
|
|
79
|
+
context.registerTrigger();
|
|
80
|
+
return () => context.unregisterTrigger();
|
|
81
|
+
}, []);
|
|
82
|
+
React.useEffect(() => {
|
|
83
|
+
if (!triggerRef.current || !isWeb) return;
|
|
84
|
+
const element = triggerRef.current;
|
|
85
|
+
function updateTriggerSize() {
|
|
86
|
+
const next = {
|
|
87
|
+
width: element.offsetWidth,
|
|
88
|
+
height: element.offsetHeight,
|
|
89
|
+
x: element.offsetLeft,
|
|
90
|
+
y: element.offsetTop
|
|
91
|
+
};
|
|
92
|
+
setLayout((previous) => previous && previous.width === next.width && previous.height === next.height && previous.x === next.x && previous.y === next.y ? previous : next);
|
|
93
|
+
}
|
|
94
|
+
updateTriggerSize();
|
|
95
|
+
const observer = new ResizeObserver(updateTriggerSize);
|
|
96
|
+
observer.observe(element);
|
|
97
|
+
return () => observer.disconnect();
|
|
98
|
+
}, [context.triggersCount]);
|
|
99
|
+
React.useEffect(() => {
|
|
100
|
+
if (isSelected && layout) {
|
|
101
|
+
emitInteraction("select", layout);
|
|
102
|
+
}
|
|
103
|
+
}, [
|
|
104
|
+
emitInteraction,
|
|
105
|
+
isSelected,
|
|
106
|
+
layout
|
|
107
|
+
]);
|
|
108
|
+
return /* @__PURE__ */ jsx(RovingFocusGroup.Item, {
|
|
109
|
+
__scopeRovingFocusGroup: __scopeTabs || TABS_CONTEXT,
|
|
110
|
+
asChild: true,
|
|
111
|
+
tabIndex: disabled ? -1 : 0,
|
|
112
|
+
active: isSelected,
|
|
113
|
+
children: /* @__PURE__ */ jsx(TabsTabFrame, {
|
|
114
|
+
onLayout: isWeb ? onLayout : composeEventHandlers(onLayout, (event) => {
|
|
115
|
+
setLayout(event.nativeEvent.layout);
|
|
116
|
+
}),
|
|
117
|
+
onMouseEnter: composeEventHandlers(onMouseEnter, () => {
|
|
118
|
+
if (layout) {
|
|
119
|
+
emitInteraction("hover", layout);
|
|
120
|
+
}
|
|
121
|
+
}),
|
|
122
|
+
onMouseLeave: composeEventHandlers(onMouseLeave, () => {
|
|
123
|
+
emitInteraction("hover", null);
|
|
124
|
+
}),
|
|
125
|
+
...tabA11yProps,
|
|
126
|
+
theme: isSelected ? activeTheme ?? null : null,
|
|
127
|
+
size: context.size,
|
|
128
|
+
...triggerProps,
|
|
129
|
+
...isSelected && activeStyle,
|
|
130
|
+
ref: composeRefs(forwardedRef, triggerRef),
|
|
131
|
+
onPress: composeEventHandlers(onPress ?? void 0, activateOnPress),
|
|
132
|
+
...isWeb && {
|
|
133
|
+
onKeyDown: composeEventHandlers(onKeyDown, activateOnKeyDown),
|
|
134
|
+
onFocus: composeEventHandlers(onFocus, composeEventHandlers(() => {
|
|
135
|
+
if (layout) {
|
|
136
|
+
emitInteraction("focus", layout);
|
|
137
|
+
}
|
|
138
|
+
}, activateOnFocus)),
|
|
139
|
+
onBlur: composeEventHandlers(onBlur, () => {
|
|
140
|
+
emitInteraction("focus", null);
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
const TabsContent = createStyledHOC(TabsContentFrame, function TabsContent2(props, forwardedRef) {
|
|
147
|
+
const { __scopeTabs, value, forceMount, children, ...contentProps } = props;
|
|
148
|
+
const context = useTabsContext(__scopeTabs);
|
|
149
|
+
const { shouldMount, contentProps: headlessContentProps } = useTabContent({
|
|
150
|
+
baseId: context.baseId,
|
|
151
|
+
value,
|
|
152
|
+
selectedValue: context.value,
|
|
153
|
+
orientation: context.orientation,
|
|
154
|
+
forceMount
|
|
155
|
+
});
|
|
156
|
+
if (!shouldMount) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
return /* @__PURE__ */ jsx(TabsContentFrame, {
|
|
160
|
+
...headlessContentProps,
|
|
161
|
+
...contentProps,
|
|
162
|
+
ref: forwardedRef,
|
|
163
|
+
children
|
|
164
|
+
}, value);
|
|
165
|
+
});
|
|
166
|
+
const TabsComponent = createStyledHOC(TabsFrame, function Tabs(props, forwardedRef) {
|
|
167
|
+
const { __scopeTabs, value: valueProp, onValueChange, defaultValue, orientation = "horizontal", dir, activationMode = "automatic", size = true, ...tabsProps } = props;
|
|
168
|
+
const { value, setValue, baseId, direction, triggersCount, registerTrigger, unregisterTrigger, tabsProps: headlessTabsProps } = useTabs({
|
|
169
|
+
value: valueProp,
|
|
170
|
+
onValueChange,
|
|
171
|
+
defaultValue,
|
|
172
|
+
orientation,
|
|
173
|
+
dir,
|
|
174
|
+
activationMode
|
|
175
|
+
});
|
|
176
|
+
return /* @__PURE__ */ jsx(SizeContext.Provider, {
|
|
177
|
+
size,
|
|
178
|
+
children: /* @__PURE__ */ jsx(TabsProvider, {
|
|
179
|
+
scope: __scopeTabs,
|
|
180
|
+
baseId,
|
|
181
|
+
value,
|
|
182
|
+
onChange: setValue,
|
|
183
|
+
orientation,
|
|
184
|
+
dir: direction,
|
|
185
|
+
activationMode,
|
|
186
|
+
size,
|
|
187
|
+
registerTrigger,
|
|
188
|
+
triggersCount,
|
|
189
|
+
unregisterTrigger,
|
|
190
|
+
children: /* @__PURE__ */ jsx(TabsFrame, {
|
|
191
|
+
direction,
|
|
192
|
+
...headlessTabsProps,
|
|
193
|
+
...tabsProps,
|
|
194
|
+
ref: forwardedRef
|
|
195
|
+
})
|
|
196
|
+
})
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
const Tabs2 = withStaticProperties(TabsComponent, {
|
|
200
|
+
Frame: TabsFrame,
|
|
201
|
+
List: TabsList,
|
|
202
|
+
Tab: TabsTab,
|
|
203
|
+
Content: TabsContent
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
export { Tabs2 as Tabs, TabsContent, TabsContentFrame, TabsFrame, TabsList, TabsListFrame, TabsTab, TabsTabFrame };
|
|
56
207
|
//# sourceMappingURL=Tabs.mjs.map
|
package/dist/esm/Tabs.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["styled","View","getButtonSized","SizableStack","ThemeableStack","TABS_NAME","DefaultTabsFrame","name","TRIGGER_NAME","DefaultTabsTabFrame","role","variants","size","disabled","true","pointerEvents","unstyled","false","borderWidth","backgroundColor","userSelect","justifyContent","alignItems","flexWrap","flexDirection","cursor","pressStyle","focusVisibleStyle","outlineColor","outlineWidth","outlineStyle","zIndex","defaultVariants","process","env","TAMAGUI_HEADLESS","accept","activeStyle","CONTENT_NAME","DefaultTabsContentFrame"],"sources":["../../src/Tabs.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAA,EAAQC,IAAA,QAAY;AAC7B,SAASC,cAAA,QAAsB;AAC/B,SAASC,YAAA,EAAcC,cAAA,QAAsB;AAE7C,MAAMC,SAAA,GAAY;AACX,MAAMC,gBAAA,GAAmBN,MAAA,CAAOG,YAAA,EAAc;EACnDI,IAAA,EAAMF;AACR,CAAC;AAED,MAAMG,YAAA,GAAe;AAEd,MAAMC,mBAAA,GAAsBT,MAAA,CACjCC,IAAA,EACA;EACEM,IAAA,EAAMC,YAAA;EACNE,IAAA,EAAM;EAENC,QAAA,EAAU;IACRC,IAAA,EAAM;MACJ,WAAWV;IACb;IAEAW,QAAA,EAAU;MACRC,IAAA,EAAM;QACJC,aAAA,EAAe;MACjB;IACF;IAEAC,QAAA,EAAU;MACRC,KAAA,EAAO;QACLC,WAAA,EAAa;QACbC,eAAA,EAAiB;QACjBC,UAAA,EAAY;QACZC,cAAA,EAAgB;QAChBC,UAAA,EAAY;QACZC,QAAA,EAAU;QACVC,aAAA,EAAe;QACfC,MAAA,EAAQ;QAERC,UAAA,EAAY;UACVP,eAAA,EAAiB;QACnB;QAEAQ,iBAAA,EAAmB;UACjBC,YAAA,EAAc;UACdC,YAAA,EAAc;UACdC,YAAA,EAAc;UACdC,MAAA,EAAQ;QACV;MACF;IACF;EACF;EAEAC,eAAA,EAAiB;IACfhB,QAAA,EAAUiB,OAAA,CAAQC,GAAA,CAAIC,gBAAA,KAAqB;EAC7C;AACF,GACA;EACEC,MAAA,EAAQ;IACNC,WAAA,EAAa;EACf;AACF,CACF;AAEA,MAAMC,YAAA,GAAe;AAEd,MAAMC,uBAAA,GAA0BvC,MAAA,CAAOI,cAAA,EAAgB;EAC5DG,IAAA,EAAM+B;AACR,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Tabs.js","names":[],"sources":["esm/Tabs.js"],"sourcesContent":["import { composeRefs } from \"@tamagui/compose-refs\";\nimport { isWeb } from \"@tamagui/constants\";\nimport { createStyledHOC, styled, View } from \"@tamagui/core\";\nimport { composeEventHandlers, withStaticProperties } from \"@tamagui/helpers\";\nimport { RovingFocusGroup } from \"@tamagui/roving-focus\";\nimport { SizeContext } from \"@tamagui/size\";\nimport { useTab, useTabContent, useTabs, useTabsList } from \"@tamagui/tabs-headless\";\nimport { useEvent } from \"@tamagui/web\";\nimport * as React from \"react\";\nimport { TabsProvider, useTabsContext } from \"./StyledContext\";\nimport { jsx } from \"react/jsx-runtime\";\nconst TABS_CONTEXT = \"TabsContext\";\nconst TabsFrame = styled(View, {\n displayName: \"Tabs\",\n context: SizeContext\n});\nconst TabsListFrame = styled(View, {\n displayName: \"TabsList\",\n context: SizeContext,\n role: \"tablist\"\n});\nconst TabsTabFrame = styled(View, {\n displayName: \"TabsTrigger\",\n context: SizeContext,\n role: \"tab\",\n variants: {\n disabled: {\n true: {\n pointerEvents: \"none\"\n }\n }\n }\n});\nconst TabsContentFrame = styled(View, {\n displayName: \"TabsContent\",\n context: SizeContext\n});\nconst TabsListDisabledContext = React.createContext(false);\nconst TabsList = createStyledHOC(\n TabsListFrame,\n function TabsList2(props, forwardedRef) {\n const { __scopeTabs, loop = true, disabled = false, children, ...listProps } = props;\n const context = useTabsContext(__scopeTabs);\n const { listProps: headlessListProps } = useTabsList({\n orientation: context.orientation,\n disabled\n });\n return /* @__PURE__ */ jsx(TabsListDisabledContext.Provider, { value: disabled, children: /* @__PURE__ */ jsx(\n RovingFocusGroup,\n {\n __scopeRovingFocusGroup: __scopeTabs || TABS_CONTEXT,\n orientation: context.orientation,\n dir: context.dir,\n loop,\n asChild: true,\n children: /* @__PURE__ */ jsx(\n TabsListFrame,\n {\n ...headlessListProps,\n flexDirection: context.orientation === \"vertical\" ? \"column\" : \"row\",\n ref: forwardedRef,\n ...listProps,\n children\n }\n )\n }\n ) });\n }\n);\nconst TabsTab = createStyledHOC(\n TabsTabFrame,\n function TabsTab2(props, forwardedRef) {\n const {\n __scopeTabs,\n value,\n disabled: disabledProp,\n onInteraction,\n activeStyle,\n activeTheme,\n onLayout,\n onMouseEnter,\n onMouseLeave,\n onPress,\n onKeyDown,\n onFocus,\n onBlur,\n ...triggerProps\n } = props;\n const context = useTabsContext(__scopeTabs);\n const listDisabled = React.useContext(TabsListDisabledContext);\n const disabled = disabledProp ?? listDisabled;\n const { isSelected, tabProps } = useTab({\n baseId: context.baseId,\n value,\n selectedValue: context.value,\n disabled,\n activationMode: context.activationMode,\n onChange: context.onChange\n });\n const {\n onPress: activateOnPress,\n onKeyDown: activateOnKeyDown,\n onFocus: activateOnFocus,\n ...tabA11yProps\n } = tabProps;\n const [layout, setLayout] = React.useState(null);\n const triggerRef = React.useRef(null);\n const emitInteraction = useEvent(\n (type, layout2) => {\n onInteraction?.(type, layout2);\n }\n );\n React.useEffect(() => {\n context.registerTrigger();\n return () => context.unregisterTrigger();\n }, []);\n React.useEffect(() => {\n if (!triggerRef.current || !isWeb) return;\n const element = triggerRef.current;\n function updateTriggerSize() {\n const next = {\n width: element.offsetWidth,\n height: element.offsetHeight,\n x: element.offsetLeft,\n y: element.offsetTop\n };\n setLayout(\n (previous) => previous && previous.width === next.width && previous.height === next.height && previous.x === next.x && previous.y === next.y ? previous : next\n );\n }\n updateTriggerSize();\n const observer = new ResizeObserver(updateTriggerSize);\n observer.observe(element);\n return () => observer.disconnect();\n }, [context.triggersCount]);\n React.useEffect(() => {\n if (isSelected && layout) {\n emitInteraction(\"select\", layout);\n }\n }, [emitInteraction, isSelected, layout]);\n return /* @__PURE__ */ jsx(\n RovingFocusGroup.Item,\n {\n __scopeRovingFocusGroup: __scopeTabs || TABS_CONTEXT,\n asChild: true,\n tabIndex: disabled ? -1 : 0,\n active: isSelected,\n children: /* @__PURE__ */ jsx(\n TabsTabFrame,\n {\n onLayout: isWeb ? onLayout : composeEventHandlers(onLayout, (event) => {\n setLayout(event.nativeEvent.layout);\n }),\n onMouseEnter: composeEventHandlers(onMouseEnter, () => {\n if (layout) {\n emitInteraction(\"hover\", layout);\n }\n }),\n onMouseLeave: composeEventHandlers(onMouseLeave, () => {\n emitInteraction(\"hover\", null);\n }),\n ...tabA11yProps,\n theme: isSelected ? activeTheme ?? null : null,\n size: context.size,\n ...triggerProps,\n ...isSelected && activeStyle,\n ref: composeRefs(forwardedRef, triggerRef),\n onPress: composeEventHandlers(onPress ?? void 0, activateOnPress),\n ...isWeb && {\n onKeyDown: composeEventHandlers(onKeyDown, activateOnKeyDown),\n // emit the focus interaction before activating, matching the order\n // the indicator animations were built against\n onFocus: composeEventHandlers(\n onFocus,\n composeEventHandlers(() => {\n if (layout) {\n emitInteraction(\"focus\", layout);\n }\n }, activateOnFocus)\n ),\n onBlur: composeEventHandlers(onBlur, () => {\n emitInteraction(\"focus\", null);\n })\n }\n }\n )\n }\n );\n }\n);\nconst TabsContent = createStyledHOC(\n TabsContentFrame,\n function TabsContent2(props, forwardedRef) {\n const { __scopeTabs, value, forceMount, children, ...contentProps } = props;\n const context = useTabsContext(__scopeTabs);\n const { shouldMount, contentProps: headlessContentProps } = useTabContent({\n baseId: context.baseId,\n value,\n selectedValue: context.value,\n orientation: context.orientation,\n forceMount\n });\n if (!shouldMount) {\n return null;\n }\n return /* @__PURE__ */ jsx(\n TabsContentFrame,\n {\n ...headlessContentProps,\n ...contentProps,\n ref: forwardedRef,\n children\n },\n value\n );\n }\n);\nconst TabsComponent = createStyledHOC(\n TabsFrame,\n function Tabs(props, forwardedRef) {\n const {\n __scopeTabs,\n value: valueProp,\n onValueChange,\n defaultValue,\n orientation = \"horizontal\",\n dir,\n activationMode = \"automatic\",\n size = true,\n ...tabsProps\n } = props;\n const {\n value,\n setValue,\n baseId,\n direction,\n triggersCount,\n registerTrigger,\n unregisterTrigger,\n tabsProps: headlessTabsProps\n } = useTabs({\n value: valueProp,\n onValueChange,\n defaultValue,\n orientation,\n dir,\n activationMode\n });\n return /* @__PURE__ */ jsx(SizeContext.Provider, { size, children: /* @__PURE__ */ jsx(\n TabsProvider,\n {\n scope: __scopeTabs,\n baseId,\n value,\n onChange: setValue,\n orientation,\n dir: direction,\n activationMode,\n size,\n registerTrigger,\n triggersCount,\n unregisterTrigger,\n children: /* @__PURE__ */ jsx(\n TabsFrame,\n {\n direction,\n ...headlessTabsProps,\n ...tabsProps,\n ref: forwardedRef\n }\n )\n }\n ) });\n }\n);\nconst Tabs2 = withStaticProperties(TabsComponent, {\n Frame: TabsFrame,\n List: TabsList,\n Tab: TabsTab,\n Content: TabsContent\n});\nexport {\n Tabs2 as Tabs,\n TabsContent,\n TabsContentFrame,\n TabsFrame,\n TabsList,\n TabsListFrame,\n TabsTab,\n TabsTabFrame\n};\n//# sourceMappingURL=Tabs.js.map\n"],"mappings":";;;;;;;;;;;;;AAWA,MAAM,eAAe;AACrB,MAAM,YAAY,OAAO,MAAM;CAC7B,aAAa;CACb,SAAS;AACX,CAAC;AACD,MAAM,gBAAgB,OAAO,MAAM;CACjC,aAAa;CACb,SAAS;CACT,MAAM;AACR,CAAC;AACD,MAAM,eAAe,OAAO,MAAM;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