@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.
Files changed (67) hide show
  1. package/dist/cjs/StyledContext.cjs +16 -20
  2. package/dist/cjs/StyledContext.native.cjs +31 -0
  3. package/dist/cjs/StyledContext.native.js +17 -20
  4. package/dist/cjs/StyledContext.native.js.map +1 -1
  5. package/dist/cjs/Tabs.cjs +227 -68
  6. package/dist/cjs/Tabs.native.cjs +250 -0
  7. package/dist/cjs/Tabs.native.js +233 -67
  8. package/dist/cjs/Tabs.native.js.map +1 -1
  9. package/dist/cjs/index.cjs +10 -27
  10. package/dist/cjs/index.native.cjs +22 -0
  11. package/dist/cjs/index.native.js +11 -27
  12. package/dist/cjs/index.native.js.map +1 -1
  13. package/dist/esm/StyledContext.mjs +3 -4
  14. package/dist/esm/StyledContext.mjs.map +1 -1
  15. package/dist/esm/StyledContext.native.js +3 -4
  16. package/dist/esm/StyledContext.native.js.map +1 -1
  17. package/dist/esm/Tabs.mjs +206 -55
  18. package/dist/esm/Tabs.mjs.map +1 -1
  19. package/dist/esm/Tabs.native.js +212 -55
  20. package/dist/esm/Tabs.native.js.map +1 -1
  21. package/dist/esm/index.js +3 -11
  22. package/dist/esm/index.mjs +3 -11
  23. package/dist/esm/index.native.js +3 -11
  24. package/dist/jsx/StyledContext.mjs +3 -4
  25. package/dist/jsx/StyledContext.mjs.map +1 -1
  26. package/dist/jsx/StyledContext.native.cjs +31 -0
  27. package/dist/jsx/StyledContext.native.js +17 -20
  28. package/dist/jsx/StyledContext.native.js.map +1 -1
  29. package/dist/jsx/Tabs.mjs +206 -55
  30. package/dist/jsx/Tabs.mjs.map +1 -1
  31. package/dist/jsx/Tabs.native.cjs +250 -0
  32. package/dist/jsx/Tabs.native.js +233 -67
  33. package/dist/jsx/Tabs.native.js.map +1 -1
  34. package/dist/jsx/index.js +3 -11
  35. package/dist/jsx/index.mjs +3 -11
  36. package/dist/jsx/index.native.cjs +22 -0
  37. package/dist/jsx/index.native.js +11 -27
  38. package/dist/jsx/index.native.js.map +1 -1
  39. package/package.json +11 -17
  40. package/src/StyledContext.tsx +3 -3
  41. package/src/Tabs.tsx +368 -55
  42. package/src/index.ts +1 -9
  43. package/types/StyledContext.d.ts +3 -3
  44. package/types/StyledContext.d.ts.map +1 -1
  45. package/types/Tabs.d.ts +398 -35
  46. package/types/Tabs.d.ts.map +1 -1
  47. package/types/index.d.ts +1 -537
  48. package/types/index.d.ts.map +1 -1
  49. package/dist/cjs/createTabs.cjs +0 -293
  50. package/dist/cjs/createTabs.native.js +0 -308
  51. package/dist/cjs/createTabs.native.js.map +0 -1
  52. package/dist/esm/createTabs.mjs +0 -257
  53. package/dist/esm/createTabs.mjs.map +0 -1
  54. package/dist/esm/createTabs.native.js +0 -269
  55. package/dist/esm/createTabs.native.js.map +0 -1
  56. package/dist/esm/index.js.map +0 -1
  57. package/dist/esm/index.mjs.map +0 -1
  58. package/dist/esm/index.native.js.map +0 -1
  59. package/dist/jsx/createTabs.mjs +0 -257
  60. package/dist/jsx/createTabs.mjs.map +0 -1
  61. package/dist/jsx/createTabs.native.js +0 -308
  62. package/dist/jsx/createTabs.native.js.map +0 -1
  63. package/dist/jsx/index.js.map +0 -1
  64. package/dist/jsx/index.mjs.map +0 -1
  65. package/src/createTabs.tsx +0 -438
  66. package/types/createTabs.d.ts +0 -527
  67. package/types/createTabs.d.ts.map +0 -1
package/dist/jsx/Tabs.mjs CHANGED
@@ -1,56 +1,207 @@
1
- import { styled, View } from "@tamagui/core";
2
- import { getButtonSized } from "@tamagui/get-button-sized";
3
- import { SizableStack, ThemeableStack } from "@tamagui/stacks";
4
- const TABS_NAME = "Tabs";
5
- const DefaultTabsFrame = styled(SizableStack, {
6
- name: TABS_NAME
7
- });
8
- const TRIGGER_NAME = "TabsTrigger";
9
- const DefaultTabsTabFrame = styled(View, {
10
- name: TRIGGER_NAME,
11
- role: "tab",
12
- variants: {
13
- size: {
14
- "...size": getButtonSized
15
- },
16
- disabled: {
17
- true: {
18
- pointerEvents: "none"
19
- }
20
- },
21
- unstyled: {
22
- false: {
23
- borderWidth: 0,
24
- backgroundColor: "$background",
25
- userSelect: "none",
26
- justifyContent: "center",
27
- alignItems: "center",
28
- flexWrap: "nowrap",
29
- flexDirection: "row",
30
- cursor: "pointer",
31
- pressStyle: {
32
- backgroundColor: "$backgroundPress"
33
- },
34
- focusVisibleStyle: {
35
- outlineColor: "$outlineColor",
36
- outlineWidth: 2,
37
- outlineStyle: "solid",
38
- zIndex: 10
39
- }
40
- }
41
- }
42
- },
43
- defaultVariants: {
44
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
45
- }
46
- }, {
47
- accept: {
48
- activeStyle: "style"
49
- }
50
- });
51
- const CONTENT_NAME = "TabsContent";
52
- const DefaultTabsContentFrame = styled(ThemeableStack, {
53
- name: CONTENT_NAME
54
- });
55
- export { DefaultTabsContentFrame, DefaultTabsFrame, DefaultTabsTabFrame };
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
@@ -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":["jsx/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;CAChC,aAAa;CACb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AAC;AACL,CACF;AACA,MAAM,QAAQ,qBAAqB,eAAe;CAChD,OAAO;CACP,MAAM;CACN,KAAK;CACL,SAAS;AACX,CAAC"}
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+
3
+
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
+ get: () => from[key],
20
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
+ });
22
+ }
23
+ return to;
24
+ };
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: true
28
+ }) : target, mod));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var Tabs_exports = {};
31
+ __export(Tabs_exports, {
32
+ Tabs: () => Tabs2,
33
+ TabsContent: () => TabsContent,
34
+ TabsContentFrame: () => TabsContentFrame,
35
+ TabsFrame: () => TabsFrame,
36
+ TabsList: () => TabsList,
37
+ TabsListFrame: () => TabsListFrame,
38
+ TabsTab: () => TabsTab,
39
+ TabsTabFrame: () => TabsTabFrame
40
+ });
41
+ module.exports = __toCommonJS(Tabs_exports);
42
+ var import_jsx_runtime = require("react/jsx-runtime");
43
+ var import_compose_refs = require("@tamagui/compose-refs");
44
+ var import_constants = require("@tamagui/constants");
45
+ var import_core = require("@tamagui/core");
46
+ var import_helpers = require("@tamagui/helpers");
47
+ var import_roving_focus = require("@tamagui/roving-focus");
48
+ var import_size = require("@tamagui/size");
49
+ var import_tabs_headless = require("@tamagui/tabs-headless");
50
+ var import_web = require("@tamagui/web");
51
+ var React = __toESM(require("react"), 1);
52
+ var import_StyledContext = require("./StyledContext.native.js");
53
+ var TABS_CONTEXT = "TabsContext";
54
+ var TabsFrame = (0, import_core.styled)(import_core.View, {
55
+ displayName: "Tabs",
56
+ context: import_size.SizeContext
57
+ });
58
+ var TabsListFrame = (0, import_core.styled)(import_core.View, {
59
+ displayName: "TabsList",
60
+ context: import_size.SizeContext,
61
+ role: "tablist"
62
+ });
63
+ var TabsTabFrame = (0, import_core.styled)(import_core.View, {
64
+ displayName: "TabsTrigger",
65
+ context: import_size.SizeContext,
66
+ role: "tab",
67
+ variants: { disabled: { true: { pointerEvents: "none" } } }
68
+ });
69
+ var TabsContentFrame = (0, import_core.styled)(import_core.View, {
70
+ displayName: "TabsContent",
71
+ context: import_size.SizeContext
72
+ });
73
+ var TabsListDisabledContext = /* @__PURE__ */ React.createContext(false);
74
+ var TabsList = (0, import_core.createStyledHOC)(TabsListFrame, function TabsList2(props, forwardedRef) {
75
+ var { __scopeTabs, loop = true, disabled = false, children, ...listProps } = props;
76
+ var context = (0, import_StyledContext.useTabsContext)(__scopeTabs);
77
+ var { listProps: headlessListProps } = (0, import_tabs_headless.useTabsList)({
78
+ orientation: context.orientation,
79
+ disabled
80
+ });
81
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TabsListDisabledContext.Provider, {
82
+ value: disabled,
83
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_roving_focus.RovingFocusGroup, {
84
+ __scopeRovingFocusGroup: __scopeTabs || TABS_CONTEXT,
85
+ orientation: context.orientation,
86
+ dir: context.dir,
87
+ loop,
88
+ asChild: true,
89
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TabsListFrame, {
90
+ ...headlessListProps,
91
+ flexDirection: context.orientation === "vertical" ? "column" : "row",
92
+ ref: forwardedRef,
93
+ ...listProps,
94
+ children
95
+ })
96
+ })
97
+ });
98
+ });
99
+ var TabsTab = (0, import_core.createStyledHOC)(TabsTabFrame, function TabsTab2(props, forwardedRef) {
100
+ var { __scopeTabs, value, disabled: disabledProp, onInteraction, activeStyle, activeTheme, onLayout, onMouseEnter, onMouseLeave, onPress, onKeyDown, onFocus, onBlur, ...triggerProps } = props;
101
+ var context = (0, import_StyledContext.useTabsContext)(__scopeTabs);
102
+ var listDisabled = React.useContext(TabsListDisabledContext);
103
+ var disabled = disabledProp !== null && disabledProp !== void 0 ? disabledProp : listDisabled;
104
+ var { isSelected, tabProps } = (0, import_tabs_headless.useTab)({
105
+ baseId: context.baseId,
106
+ value,
107
+ selectedValue: context.value,
108
+ disabled,
109
+ activationMode: context.activationMode,
110
+ onChange: context.onChange
111
+ });
112
+ var { onPress: activateOnPress, onKeyDown: activateOnKeyDown, onFocus: activateOnFocus, ...tabA11yProps } = tabProps;
113
+ var [layout, setLayout] = React.useState(null);
114
+ var triggerRef = React.useRef(null);
115
+ var emitInteraction = (0, import_web.useEvent)(function(type, layout2) {
116
+ onInteraction === null || onInteraction === void 0 ? void 0 : onInteraction(type, layout2);
117
+ });
118
+ React.useEffect(function() {
119
+ context.registerTrigger();
120
+ return function() {
121
+ return context.unregisterTrigger();
122
+ };
123
+ }, []);
124
+ React.useEffect(function() {
125
+ if (!triggerRef.current || !import_constants.isWeb) return;
126
+ var element = triggerRef.current;
127
+ function updateTriggerSize() {
128
+ var next = {
129
+ width: element.offsetWidth,
130
+ height: element.offsetHeight,
131
+ x: element.offsetLeft,
132
+ y: element.offsetTop
133
+ };
134
+ setLayout(function(previous) {
135
+ return previous && previous.width === next.width && previous.height === next.height && previous.x === next.x && previous.y === next.y ? previous : next;
136
+ });
137
+ }
138
+ updateTriggerSize();
139
+ var observer = new ResizeObserver(updateTriggerSize);
140
+ observer.observe(element);
141
+ return function() {
142
+ return observer.disconnect();
143
+ };
144
+ }, [context.triggersCount]);
145
+ React.useEffect(function() {
146
+ if (isSelected && layout) {
147
+ emitInteraction("select", layout);
148
+ }
149
+ }, [
150
+ emitInteraction,
151
+ isSelected,
152
+ layout
153
+ ]);
154
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_roving_focus.RovingFocusGroup.Item, {
155
+ __scopeRovingFocusGroup: __scopeTabs || TABS_CONTEXT,
156
+ asChild: true,
157
+ tabIndex: disabled ? -1 : 0,
158
+ active: isSelected,
159
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TabsTabFrame, {
160
+ onLayout: import_constants.isWeb ? onLayout : (0, import_helpers.composeEventHandlers)(onLayout, function(event) {
161
+ setLayout(event.nativeEvent.layout);
162
+ }),
163
+ onMouseEnter: (0, import_helpers.composeEventHandlers)(onMouseEnter, function() {
164
+ if (layout) {
165
+ emitInteraction("hover", layout);
166
+ }
167
+ }),
168
+ onMouseLeave: (0, import_helpers.composeEventHandlers)(onMouseLeave, function() {
169
+ emitInteraction("hover", null);
170
+ }),
171
+ ...tabA11yProps,
172
+ theme: isSelected ? activeTheme !== null && activeTheme !== void 0 ? activeTheme : null : null,
173
+ size: context.size,
174
+ ...triggerProps,
175
+ ...isSelected && activeStyle,
176
+ ref: (0, import_compose_refs.composeRefs)(forwardedRef, triggerRef),
177
+ onPress: (0, import_helpers.composeEventHandlers)(onPress !== null && onPress !== void 0 ? onPress : void 0, activateOnPress),
178
+ ...import_constants.isWeb && {
179
+ onKeyDown: (0, import_helpers.composeEventHandlers)(onKeyDown, activateOnKeyDown),
180
+ onFocus: (0, import_helpers.composeEventHandlers)(onFocus, (0, import_helpers.composeEventHandlers)(function() {
181
+ if (layout) {
182
+ emitInteraction("focus", layout);
183
+ }
184
+ }, activateOnFocus)),
185
+ onBlur: (0, import_helpers.composeEventHandlers)(onBlur, function() {
186
+ emitInteraction("focus", null);
187
+ })
188
+ }
189
+ })
190
+ });
191
+ });
192
+ var TabsContent = (0, import_core.createStyledHOC)(TabsContentFrame, function TabsContent2(props, forwardedRef) {
193
+ var { __scopeTabs, value, forceMount, children, ...contentProps } = props;
194
+ var context = (0, import_StyledContext.useTabsContext)(__scopeTabs);
195
+ var { shouldMount, contentProps: headlessContentProps } = (0, import_tabs_headless.useTabContent)({
196
+ baseId: context.baseId,
197
+ value,
198
+ selectedValue: context.value,
199
+ orientation: context.orientation,
200
+ forceMount
201
+ });
202
+ if (!shouldMount) {
203
+ return null;
204
+ }
205
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TabsContentFrame, {
206
+ ...headlessContentProps,
207
+ ...contentProps,
208
+ ref: forwardedRef,
209
+ children
210
+ }, value);
211
+ });
212
+ var TabsComponent = (0, import_core.createStyledHOC)(TabsFrame, function Tabs(props, forwardedRef) {
213
+ var { __scopeTabs, value: valueProp, onValueChange, defaultValue, orientation = "horizontal", dir, activationMode = "automatic", size = true, ...tabsProps } = props;
214
+ var { value, setValue, baseId, direction, triggersCount, registerTrigger, unregisterTrigger, tabsProps: headlessTabsProps } = (0, import_tabs_headless.useTabs)({
215
+ value: valueProp,
216
+ onValueChange,
217
+ defaultValue,
218
+ orientation,
219
+ dir,
220
+ activationMode
221
+ });
222
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_size.SizeContext.Provider, {
223
+ size,
224
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_StyledContext.TabsProvider, {
225
+ scope: __scopeTabs,
226
+ baseId,
227
+ value,
228
+ onChange: setValue,
229
+ orientation,
230
+ dir: direction,
231
+ activationMode,
232
+ size,
233
+ registerTrigger,
234
+ triggersCount,
235
+ unregisterTrigger,
236
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TabsFrame, {
237
+ direction,
238
+ ...headlessTabsProps,
239
+ ...tabsProps,
240
+ ref: forwardedRef
241
+ })
242
+ })
243
+ });
244
+ });
245
+ var Tabs2 = (0, import_helpers.withStaticProperties)(TabsComponent, {
246
+ Frame: TabsFrame,
247
+ List: TabsList,
248
+ Tab: TabsTab,
249
+ Content: TabsContent
250
+ });