@yahoo/uds-mobile 2.9.0 → 2.11.0
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/README.md +22 -24
- package/dist/components/Avatar.cjs +1 -1
- package/dist/components/Avatar.d.cts +1 -1
- package/dist/components/Avatar.d.ts +1 -1
- package/dist/components/Avatar.js +1 -1
- package/dist/components/Avatar.js.map +1 -1
- package/dist/components/Badge.cjs +1 -1
- package/dist/components/Badge.d.cts +1 -1
- package/dist/components/Badge.d.ts +1 -1
- package/dist/components/Badge.js +1 -1
- package/dist/components/Badge.js.map +1 -1
- package/dist/components/BlurTarget.cjs +2 -1
- package/dist/components/BlurTarget.d.cts +2 -1
- package/dist/components/BlurTarget.d.cts.map +1 -1
- package/dist/components/BlurTarget.d.ts +2 -1
- package/dist/components/BlurTarget.d.ts.map +1 -1
- package/dist/components/BlurTarget.js +2 -1
- package/dist/components/BlurTarget.js.map +1 -1
- package/dist/components/Box.cjs +1 -1
- package/dist/components/Box.d.cts +1 -1
- package/dist/components/Box.d.ts +1 -1
- package/dist/components/Box.js +1 -1
- package/dist/components/Box.js.map +1 -1
- package/dist/components/Button.cjs +1 -1
- package/dist/components/Button.d.cts +1 -1
- package/dist/components/Button.d.ts +1 -1
- package/dist/components/Button.js +1 -1
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Checkbox.cjs +1 -1
- package/dist/components/Checkbox.d.cts +1 -1
- package/dist/components/Checkbox.d.ts +1 -1
- package/dist/components/Checkbox.js +1 -1
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/Chip.cjs +1 -1
- package/dist/components/Chip.d.cts +1 -1
- package/dist/components/Chip.d.ts +1 -1
- package/dist/components/Chip.js +1 -1
- package/dist/components/Chip.js.map +1 -1
- package/dist/components/Divider/Divider.cjs +103 -0
- package/dist/components/Divider/Divider.d.cts +50 -0
- package/dist/components/Divider/Divider.d.cts.map +1 -0
- package/dist/components/Divider/Divider.d.ts +50 -0
- package/dist/components/Divider/Divider.d.ts.map +1 -0
- package/dist/components/Divider/Divider.js +103 -0
- package/dist/components/Divider/Divider.js.map +1 -0
- package/dist/components/Divider/DividerLabel.cjs +37 -0
- package/dist/components/Divider/DividerLabel.d.cts +18 -0
- package/dist/components/Divider/DividerLabel.d.cts.map +1 -0
- package/dist/components/Divider/DividerLabel.d.ts +18 -0
- package/dist/components/Divider/DividerLabel.d.ts.map +1 -0
- package/dist/components/Divider/DividerLabel.js +37 -0
- package/dist/components/Divider/DividerLabel.js.map +1 -0
- package/dist/components/Divider/DividerLine.cjs +62 -0
- package/dist/components/Divider/DividerLine.d.cts +19 -0
- package/dist/components/Divider/DividerLine.d.cts.map +1 -0
- package/dist/components/Divider/DividerLine.d.ts +19 -0
- package/dist/components/Divider/DividerLine.d.ts.map +1 -0
- package/dist/components/Divider/DividerLine.js +62 -0
- package/dist/components/Divider/DividerLine.js.map +1 -0
- package/dist/components/Divider/index.cjs +8 -0
- package/dist/components/Divider/index.d.cts +6 -0
- package/dist/components/Divider/index.d.ts +6 -0
- package/dist/components/Divider/index.js +5 -0
- package/dist/components/Divider/types.cjs +1 -0
- package/dist/components/Divider/types.d.cts +35 -0
- package/dist/components/Divider/types.d.cts.map +1 -0
- package/dist/components/Divider/types.d.ts +35 -0
- package/dist/components/Divider/types.d.ts.map +1 -0
- package/dist/components/Divider/types.js +1 -0
- package/dist/components/Divider/utils.cjs +33 -0
- package/dist/components/Divider/utils.d.cts +12 -0
- package/dist/components/Divider/utils.d.cts.map +1 -0
- package/dist/components/Divider/utils.d.ts +12 -0
- package/dist/components/Divider/utils.d.ts.map +1 -0
- package/dist/components/Divider/utils.js +31 -0
- package/dist/components/Divider/utils.js.map +1 -0
- package/dist/components/HStack.cjs +1 -1
- package/dist/components/HStack.d.cts +1 -1
- package/dist/components/HStack.d.ts +1 -1
- package/dist/components/HStack.js +1 -1
- package/dist/components/HStack.js.map +1 -1
- package/dist/components/Icon.cjs +1 -1
- package/dist/components/Icon.d.cts +2 -2
- package/dist/components/Icon.d.ts +2 -2
- package/dist/components/Icon.js +1 -1
- package/dist/components/Icon.js.map +1 -1
- package/dist/components/IconButton.cjs +1 -1
- package/dist/components/IconButton.d.cts +1 -1
- package/dist/components/IconButton.d.ts +1 -1
- package/dist/components/IconButton.js +1 -1
- package/dist/components/IconButton.js.map +1 -1
- package/dist/components/IconSlot.cjs +1 -1
- package/dist/components/IconSlot.d.cts +1 -1
- package/dist/components/IconSlot.d.ts +1 -1
- package/dist/components/IconSlot.js +1 -1
- package/dist/components/IconSlot.js.map +1 -1
- package/dist/components/Image.cjs +1 -1
- package/dist/components/Image.d.cts +1 -1
- package/dist/components/Image.d.ts +1 -1
- package/dist/components/Image.js +1 -1
- package/dist/components/Image.js.map +1 -1
- package/dist/components/Input.cjs +1 -1
- package/dist/components/Input.d.cts +1 -1
- package/dist/components/Input.d.ts +1 -1
- package/dist/components/Input.js +1 -1
- package/dist/components/Input.js.map +1 -1
- package/dist/components/Link.cjs +1 -1
- package/dist/components/Link.d.cts +1 -1
- package/dist/components/Link.d.ts +1 -1
- package/dist/components/Link.js +1 -1
- package/dist/components/Link.js.map +1 -1
- package/dist/components/Pressable.cjs +1 -1
- package/dist/components/Pressable.d.cts +1 -1
- package/dist/components/Pressable.d.ts +1 -1
- package/dist/components/Pressable.js +1 -1
- package/dist/components/Pressable.js.map +1 -1
- package/dist/components/Radio.cjs +1 -1
- package/dist/components/Radio.d.cts +1 -1
- package/dist/components/Radio.d.ts +1 -1
- package/dist/components/Radio.js +1 -1
- package/dist/components/Radio.js.map +1 -1
- package/dist/components/Screen.cjs +1 -1
- package/dist/components/Screen.d.cts +1 -1
- package/dist/components/Screen.d.ts +1 -1
- package/dist/components/Screen.js +1 -1
- package/dist/components/Screen.js.map +1 -1
- package/dist/components/Switch.cjs +1 -1
- package/dist/components/Switch.d.cts +1 -1
- package/dist/components/Switch.d.ts +1 -1
- package/dist/components/Switch.js +1 -1
- package/dist/components/Switch.js.map +1 -1
- package/dist/components/Tabs/Tab.cjs +174 -0
- package/dist/components/Tabs/Tab.d.cts +26 -0
- package/dist/components/Tabs/Tab.d.cts.map +1 -0
- package/dist/components/Tabs/Tab.d.ts +26 -0
- package/dist/components/Tabs/Tab.d.ts.map +1 -0
- package/dist/components/Tabs/Tab.js +174 -0
- package/dist/components/Tabs/Tab.js.map +1 -0
- package/dist/components/Tabs/TabList.cjs +142 -0
- package/dist/components/Tabs/TabList.d.cts +24 -0
- package/dist/components/Tabs/TabList.d.cts.map +1 -0
- package/dist/components/Tabs/TabList.d.ts +24 -0
- package/dist/components/Tabs/TabList.d.ts.map +1 -0
- package/dist/components/Tabs/TabList.js +141 -0
- package/dist/components/Tabs/TabList.js.map +1 -0
- package/dist/components/Tabs/TabPanel.cjs +31 -0
- package/dist/components/Tabs/TabPanel.d.cts +24 -0
- package/dist/components/Tabs/TabPanel.d.cts.map +1 -0
- package/dist/components/Tabs/TabPanel.d.ts +24 -0
- package/dist/components/Tabs/TabPanel.d.ts.map +1 -0
- package/dist/components/Tabs/TabPanel.js +31 -0
- package/dist/components/Tabs/TabPanel.js.map +1 -0
- package/dist/components/Tabs/Tabs.cjs +53 -0
- package/dist/components/Tabs/Tabs.d.cts +35 -0
- package/dist/components/Tabs/Tabs.d.cts.map +1 -0
- package/dist/components/Tabs/Tabs.d.ts +35 -0
- package/dist/components/Tabs/Tabs.d.ts.map +1 -0
- package/dist/components/Tabs/Tabs.js +53 -0
- package/dist/components/Tabs/Tabs.js.map +1 -0
- package/dist/components/Tabs/index.cjs +10 -0
- package/dist/components/Tabs/index.d.cts +13 -0
- package/dist/components/Tabs/index.d.cts.map +1 -0
- package/dist/components/Tabs/index.d.ts +13 -0
- package/dist/components/Tabs/index.d.ts.map +1 -0
- package/dist/components/Tabs/index.js +6 -0
- package/dist/components/Tabs/tabTheme.cjs +29 -0
- package/dist/components/Tabs/tabTheme.d.cts +23 -0
- package/dist/components/Tabs/tabTheme.d.cts.map +1 -0
- package/dist/components/Tabs/tabTheme.d.ts +23 -0
- package/dist/components/Tabs/tabTheme.d.ts.map +1 -0
- package/dist/components/Tabs/tabTheme.js +28 -0
- package/dist/components/Tabs/tabTheme.js.map +1 -0
- package/dist/components/Tabs/tabsContexts.cjs +91 -0
- package/dist/components/Tabs/tabsContexts.d.cts +35 -0
- package/dist/components/Tabs/tabsContexts.d.cts.map +1 -0
- package/dist/components/Tabs/tabsContexts.d.ts +35 -0
- package/dist/components/Tabs/tabsContexts.d.ts.map +1 -0
- package/dist/components/Tabs/tabsContexts.js +87 -0
- package/dist/components/Tabs/tabsContexts.js.map +1 -0
- package/dist/components/Text.cjs +1 -1
- package/dist/components/Text.d.cts +1 -1
- package/dist/components/Text.d.ts +1 -1
- package/dist/components/Text.js +1 -1
- package/dist/components/Text.js.map +1 -1
- package/dist/components/VStack.cjs +1 -1
- package/dist/components/VStack.d.cts +1 -1
- package/dist/components/VStack.d.ts +1 -1
- package/dist/components/VStack.js +1 -1
- package/dist/components/VStack.js.map +1 -1
- package/dist/jest/mocks/styles.cjs +22 -0
- package/dist/jest/mocks/styles.d.cts +4 -2
- package/dist/jest/mocks/styles.d.cts.map +1 -1
- package/dist/jest/mocks/styles.d.ts +4 -2
- package/dist/jest/mocks/styles.d.ts.map +1 -1
- package/dist/jest/mocks/styles.js +21 -1
- package/dist/jest/mocks/styles.js.map +1 -1
- package/dist/types/dist/index.d.cts +63 -2
- package/dist/types/dist/index.d.cts.map +1 -1
- package/dist/types/dist/index.d.ts +63 -2
- package/dist/types/dist/index.d.ts.map +1 -1
- package/fonts/uds-icons.ttf +0 -0
- package/generated/styles.cjs +87 -13
- package/generated/styles.d.ts +58 -0
- package/generated/styles.mjs +87 -13
- package/generated/unistyles.d.ts +62 -9
- package/package.json +21 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { useTabSelectionContext } from "./tabsContexts.js";
|
|
3
|
+
import { memo } from "react";
|
|
4
|
+
import { View } from "react-native";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/Tabs/TabPanel.tsx
|
|
7
|
+
/**
|
|
8
|
+
* **⚙️ TabPanel**
|
|
9
|
+
*
|
|
10
|
+
* @description
|
|
11
|
+
* Content associated with a tab id. Only the panel whose `tabId` matches the current
|
|
12
|
+
* selection is rendered.
|
|
13
|
+
*
|
|
14
|
+
* @category Navigation
|
|
15
|
+
* @platform mobile
|
|
16
|
+
*/
|
|
17
|
+
const TabPanel = memo(function TabPanel({ tabId, children, style, ...viewProps }) {
|
|
18
|
+
const { selectedId } = useTabSelectionContext();
|
|
19
|
+
if (selectedId !== tabId) return null;
|
|
20
|
+
return /* @__PURE__ */ jsx(View, {
|
|
21
|
+
accessibilityRole: "none",
|
|
22
|
+
style,
|
|
23
|
+
...viewProps,
|
|
24
|
+
children
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
TabPanel.displayName = "TabPanel";
|
|
28
|
+
//#endregion
|
|
29
|
+
export { TabPanel };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=TabPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabPanel.js","names":[],"sources":["../../../src/components/Tabs/TabPanel.tsx"],"sourcesContent":["import type { UniversalTabPanelProps } from '@yahoo/uds-types';\nimport { memo } from 'react';\nimport type { ViewProps, ViewStyle } from 'react-native';\nimport { View } from 'react-native';\n\nimport { useTabSelectionContext } from './tabsContexts';\n\ninterface TabPanelProps\n extends Omit<UniversalTabPanelProps, 'className'>, Omit<ViewProps, 'style' | 'children'> {\n children: UniversalTabPanelProps['children'];\n style?: ViewStyle;\n}\n\n/**\n * **⚙️ TabPanel**\n *\n * @description\n * Content associated with a tab id. Only the panel whose `tabId` matches the current\n * selection is rendered.\n *\n * @category Navigation\n * @platform mobile\n */\nconst TabPanel = memo(function TabPanel({ tabId, children, style, ...viewProps }: TabPanelProps) {\n const { selectedId } = useTabSelectionContext();\n\n if (selectedId !== tabId) {\n return null;\n }\n\n return (\n <View accessibilityRole=\"none\" style={style} {...viewProps}>\n {children}\n </View>\n );\n});\n\nTabPanel.displayName = 'TabPanel';\n\nexport { TabPanel };\nexport type { TabPanelProps };\n"],"mappings":";;;;;;;;;;;;;;;;AAuBA,MAAM,WAAW,KAAK,SAAS,SAAS,EAAE,OAAO,UAAU,OAAO,GAAG,aAA4B;CAC/F,MAAM,EAAE,eAAe,wBAAwB;AAE/C,KAAI,eAAe,MACjB,QAAO;AAGT,QACE,oBAAC,MAAD;EAAM,mBAAkB;EAAc;EAAO,GAAI;EAC9C;EACI,CAAA;EAET;AAEF,SAAS,cAAc"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
4
|
+
const require_components_Tabs_tabsContexts = require("./tabsContexts.cjs");
|
|
5
|
+
let react = require("react");
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
//#region src/components/Tabs/Tabs.tsx
|
|
8
|
+
/**
|
|
9
|
+
* **⚙️ Tabs**
|
|
10
|
+
*
|
|
11
|
+
* @description
|
|
12
|
+
* Organizes content into sections with a tab list and tab panels. Supports `primary` and
|
|
13
|
+
* `secondary` variants. When `reduceMotion` is false, a sliding indicator animates between
|
|
14
|
+
* tabs (240ms, cubic-bezier(0.2, 0, 0, 1)) to match web UDS.
|
|
15
|
+
*
|
|
16
|
+
* @category Navigation
|
|
17
|
+
* @platform mobile
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* import { Tabs, TabList, Tab, TabPanel } from '@yahoo/uds-mobile/Tabs';
|
|
22
|
+
*
|
|
23
|
+
* <Tabs variant="primary" defaultSelectedId="home">
|
|
24
|
+
* <TabList accessibilityLabel="Main">
|
|
25
|
+
* <Tab value="home">Home</Tab>
|
|
26
|
+
* <Tab value="about">About</Tab>
|
|
27
|
+
* </TabList>
|
|
28
|
+
* <TabPanel tabId="home">Home content</TabPanel>
|
|
29
|
+
* <TabPanel tabId="about">About content</TabPanel>
|
|
30
|
+
* </Tabs>
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
const Tabs = (0, react.memo)(function Tabs({ children, variant = "primary", reduceMotion = false, defaultSelectedId, selectedId, onSelectionChange }) {
|
|
34
|
+
const visual = (0, react.useMemo)(() => ({
|
|
35
|
+
variant,
|
|
36
|
+
reduceMotion
|
|
37
|
+
}), [variant, reduceMotion]);
|
|
38
|
+
const selection = require_components_Tabs_tabsContexts.useTabSelectionState({
|
|
39
|
+
defaultSelectedId,
|
|
40
|
+
selectedId,
|
|
41
|
+
onSelectionChange
|
|
42
|
+
});
|
|
43
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Tabs_tabsContexts.TabsVisualContext.Provider, {
|
|
44
|
+
value: visual,
|
|
45
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Tabs_tabsContexts.TabSelectionContext.Provider, {
|
|
46
|
+
value: selection,
|
|
47
|
+
children
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
Tabs.displayName = "Tabs";
|
|
52
|
+
//#endregion
|
|
53
|
+
exports.Tabs = Tabs;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
import { UniversalTabsProps } from "../../types/dist/index.cjs";
|
|
3
|
+
import * as _$react from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/Tabs/Tabs.d.ts
|
|
6
|
+
interface TabsProps extends UniversalTabsProps {}
|
|
7
|
+
/**
|
|
8
|
+
* **⚙️ Tabs**
|
|
9
|
+
*
|
|
10
|
+
* @description
|
|
11
|
+
* Organizes content into sections with a tab list and tab panels. Supports `primary` and
|
|
12
|
+
* `secondary` variants. When `reduceMotion` is false, a sliding indicator animates between
|
|
13
|
+
* tabs (240ms, cubic-bezier(0.2, 0, 0, 1)) to match web UDS.
|
|
14
|
+
*
|
|
15
|
+
* @category Navigation
|
|
16
|
+
* @platform mobile
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* import { Tabs, TabList, Tab, TabPanel } from '@yahoo/uds-mobile/Tabs';
|
|
21
|
+
*
|
|
22
|
+
* <Tabs variant="primary" defaultSelectedId="home">
|
|
23
|
+
* <TabList accessibilityLabel="Main">
|
|
24
|
+
* <Tab value="home">Home</Tab>
|
|
25
|
+
* <Tab value="about">About</Tab>
|
|
26
|
+
* </TabList>
|
|
27
|
+
* <TabPanel tabId="home">Home content</TabPanel>
|
|
28
|
+
* <TabPanel tabId="about">About content</TabPanel>
|
|
29
|
+
* </Tabs>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare const Tabs: _$react.NamedExoticComponent<TabsProps>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { Tabs, type TabsProps };
|
|
35
|
+
//# sourceMappingURL=Tabs.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tabs.d.cts","names":[],"sources":["../../../src/components/Tabs/Tabs.tsx"],"mappings":";;;;;UAMU,SAAA,SAAkB,kBAAA;;AAN+B;;;;;AAMb;;;;;;;;;;;;;;;;;;;cA2BxC,IAAA,EAAI,OAAA,CAAA,oBAAA,CAAA,SAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
import { UniversalTabsProps } from "../../types/dist/index.js";
|
|
3
|
+
import * as _$react from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/Tabs/Tabs.d.ts
|
|
6
|
+
interface TabsProps extends UniversalTabsProps {}
|
|
7
|
+
/**
|
|
8
|
+
* **⚙️ Tabs**
|
|
9
|
+
*
|
|
10
|
+
* @description
|
|
11
|
+
* Organizes content into sections with a tab list and tab panels. Supports `primary` and
|
|
12
|
+
* `secondary` variants. When `reduceMotion` is false, a sliding indicator animates between
|
|
13
|
+
* tabs (240ms, cubic-bezier(0.2, 0, 0, 1)) to match web UDS.
|
|
14
|
+
*
|
|
15
|
+
* @category Navigation
|
|
16
|
+
* @platform mobile
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* import { Tabs, TabList, Tab, TabPanel } from '@yahoo/uds-mobile/Tabs';
|
|
21
|
+
*
|
|
22
|
+
* <Tabs variant="primary" defaultSelectedId="home">
|
|
23
|
+
* <TabList accessibilityLabel="Main">
|
|
24
|
+
* <Tab value="home">Home</Tab>
|
|
25
|
+
* <Tab value="about">About</Tab>
|
|
26
|
+
* </TabList>
|
|
27
|
+
* <TabPanel tabId="home">Home content</TabPanel>
|
|
28
|
+
* <TabPanel tabId="about">About content</TabPanel>
|
|
29
|
+
* </Tabs>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare const Tabs: _$react.NamedExoticComponent<TabsProps>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { Tabs, type TabsProps };
|
|
35
|
+
//# sourceMappingURL=Tabs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tabs.d.ts","names":[],"sources":["../../../src/components/Tabs/Tabs.tsx"],"mappings":";;;;;UAMU,SAAA,SAAkB,kBAAA;;AAN+B;;;;;AAMb;;;;;;;;;;;;;;;;;;;cA2BxC,IAAA,EAAI,OAAA,CAAA,oBAAA,CAAA,SAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { TabSelectionContext, TabsVisualContext, useTabSelectionState } from "./tabsContexts.js";
|
|
3
|
+
import { memo, useMemo } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/Tabs/Tabs.tsx
|
|
6
|
+
/**
|
|
7
|
+
* **⚙️ Tabs**
|
|
8
|
+
*
|
|
9
|
+
* @description
|
|
10
|
+
* Organizes content into sections with a tab list and tab panels. Supports `primary` and
|
|
11
|
+
* `secondary` variants. When `reduceMotion` is false, a sliding indicator animates between
|
|
12
|
+
* tabs (240ms, cubic-bezier(0.2, 0, 0, 1)) to match web UDS.
|
|
13
|
+
*
|
|
14
|
+
* @category Navigation
|
|
15
|
+
* @platform mobile
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* import { Tabs, TabList, Tab, TabPanel } from '@yahoo/uds-mobile/Tabs';
|
|
20
|
+
*
|
|
21
|
+
* <Tabs variant="primary" defaultSelectedId="home">
|
|
22
|
+
* <TabList accessibilityLabel="Main">
|
|
23
|
+
* <Tab value="home">Home</Tab>
|
|
24
|
+
* <Tab value="about">About</Tab>
|
|
25
|
+
* </TabList>
|
|
26
|
+
* <TabPanel tabId="home">Home content</TabPanel>
|
|
27
|
+
* <TabPanel tabId="about">About content</TabPanel>
|
|
28
|
+
* </Tabs>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
const Tabs = memo(function Tabs({ children, variant = "primary", reduceMotion = false, defaultSelectedId, selectedId, onSelectionChange }) {
|
|
32
|
+
const visual = useMemo(() => ({
|
|
33
|
+
variant,
|
|
34
|
+
reduceMotion
|
|
35
|
+
}), [variant, reduceMotion]);
|
|
36
|
+
const selection = useTabSelectionState({
|
|
37
|
+
defaultSelectedId,
|
|
38
|
+
selectedId,
|
|
39
|
+
onSelectionChange
|
|
40
|
+
});
|
|
41
|
+
return /* @__PURE__ */ jsx(TabsVisualContext.Provider, {
|
|
42
|
+
value: visual,
|
|
43
|
+
children: /* @__PURE__ */ jsx(TabSelectionContext.Provider, {
|
|
44
|
+
value: selection,
|
|
45
|
+
children
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
Tabs.displayName = "Tabs";
|
|
50
|
+
//#endregion
|
|
51
|
+
export { Tabs };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=Tabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tabs.js","names":[],"sources":["../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import type { UniversalTabsProps } from '@yahoo/uds-types';\nimport { memo, useMemo } from 'react';\n\nimport { TabSelectionContext, TabsVisualContext, useTabSelectionState } from './tabsContexts';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- alias for doc extraction / parity with web\ninterface TabsProps extends UniversalTabsProps {}\n\n/**\n * **⚙️ Tabs**\n *\n * @description\n * Organizes content into sections with a tab list and tab panels. Supports `primary` and\n * `secondary` variants. When `reduceMotion` is false, a sliding indicator animates between\n * tabs (240ms, cubic-bezier(0.2, 0, 0, 1)) to match web UDS.\n *\n * @category Navigation\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Tabs, TabList, Tab, TabPanel } from '@yahoo/uds-mobile/Tabs';\n *\n * <Tabs variant=\"primary\" defaultSelectedId=\"home\">\n * <TabList accessibilityLabel=\"Main\">\n * <Tab value=\"home\">Home</Tab>\n * <Tab value=\"about\">About</Tab>\n * </TabList>\n * <TabPanel tabId=\"home\">Home content</TabPanel>\n * <TabPanel tabId=\"about\">About content</TabPanel>\n * </Tabs>\n * ```\n */\nconst Tabs = memo(function Tabs({\n children,\n variant = 'primary',\n reduceMotion = false,\n defaultSelectedId,\n selectedId,\n onSelectionChange,\n}: TabsProps) {\n const visual = useMemo(() => ({ variant, reduceMotion }), [variant, reduceMotion]);\n const selection = useTabSelectionState({\n defaultSelectedId,\n selectedId,\n onSelectionChange,\n });\n\n return (\n <TabsVisualContext.Provider value={visual}>\n <TabSelectionContext.Provider value={selection}>{children}</TabSelectionContext.Provider>\n </TabsVisualContext.Provider>\n );\n});\n\nTabs.displayName = 'Tabs';\n\nexport { Tabs };\nexport type { TabsProps };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,OAAO,KAAK,SAAS,KAAK,EAC9B,UACA,UAAU,WACV,eAAe,OACf,mBACA,YACA,qBACY;CACZ,MAAM,SAAS,eAAe;EAAE;EAAS;EAAc,GAAG,CAAC,SAAS,aAAa,CAAC;CAClF,MAAM,YAAY,qBAAqB;EACrC;EACA;EACA;EACD,CAAC;AAEF,QACE,oBAAC,kBAAkB,UAAnB;EAA4B,OAAO;YACjC,oBAAC,oBAAoB,UAArB;GAA8B,OAAO;GAAY;GAAwC,CAAA;EAC9D,CAAA;EAE/B;AAEF,KAAK,cAAc"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_components_Tabs_Tab = require("./Tab.cjs");
|
|
4
|
+
const require_components_Tabs_TabList = require("./TabList.cjs");
|
|
5
|
+
const require_components_Tabs_TabPanel = require("./TabPanel.cjs");
|
|
6
|
+
const require_components_Tabs_Tabs = require("./Tabs.cjs");
|
|
7
|
+
exports.Tab = require_components_Tabs_Tab.Tab;
|
|
8
|
+
exports.TabList = require_components_Tabs_TabList.TabList;
|
|
9
|
+
exports.TabPanel = require_components_Tabs_TabPanel.TabPanel;
|
|
10
|
+
exports.Tabs = require_components_Tabs_Tabs.Tabs;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
import { UniversalTabsVariant } from "../../types/dist/index.cjs";
|
|
3
|
+
import { Tab, TabProps } from "./Tab.cjs";
|
|
4
|
+
import { TabList, TabListProps } from "./TabList.cjs";
|
|
5
|
+
import { TabPanel, TabPanelProps } from "./TabPanel.cjs";
|
|
6
|
+
import { Tabs, TabsProps } from "./Tabs.cjs";
|
|
7
|
+
|
|
8
|
+
//#region src/components/Tabs/index.d.ts
|
|
9
|
+
/** @alias {@link UniversalTabsVariant} — matches web `TabsVariant` naming */
|
|
10
|
+
type TabsVariant = UniversalTabsVariant;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { Tab, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsProps, TabsVariant, type UniversalTabsVariant };
|
|
13
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/components/Tabs/index.ts"],"mappings":";;;;;;;;;KAQY,WAAA,GAAc,oBAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
import { UniversalTabsVariant } from "../../types/dist/index.js";
|
|
3
|
+
import { Tab, TabProps } from "./Tab.js";
|
|
4
|
+
import { TabList, TabListProps } from "./TabList.js";
|
|
5
|
+
import { TabPanel, TabPanelProps } from "./TabPanel.js";
|
|
6
|
+
import { Tabs, TabsProps } from "./Tabs.js";
|
|
7
|
+
|
|
8
|
+
//#region src/components/Tabs/index.d.ts
|
|
9
|
+
/** @alias {@link UniversalTabsVariant} — matches web `TabsVariant` naming */
|
|
10
|
+
type TabsVariant = UniversalTabsVariant;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { Tab, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsProps, TabsVariant, type UniversalTabsVariant };
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/Tabs/index.ts"],"mappings":";;;;;;;;;KAQY,WAAA,GAAc,oBAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
//#region src/components/Tabs/tabTheme.ts
|
|
4
|
+
function tabComponentPath(visual, active, layer, state) {
|
|
5
|
+
return `tab/variant/${visual}/active/${active}/${layer === "rootText" ? "rootText" : layer}/${state}`;
|
|
6
|
+
}
|
|
7
|
+
/** Default tab dimensions / spacing from tokens (`tab/size/default/...`). */
|
|
8
|
+
function getTabSizeLayerStyle(theme, layer) {
|
|
9
|
+
const path = `tab/size/default/${layer}/rest`;
|
|
10
|
+
const s = theme.components[path];
|
|
11
|
+
return s && typeof s === "object" ? s : {};
|
|
12
|
+
}
|
|
13
|
+
/** Variant + interaction layer (active on/off, pressed/rest). */
|
|
14
|
+
function getTabLayerStyle(theme, visual, active, layer, state) {
|
|
15
|
+
const path = tabComponentPath(visual, active, layer, state);
|
|
16
|
+
const s = theme.components[path];
|
|
17
|
+
return s && typeof s === "object" ? s : {};
|
|
18
|
+
}
|
|
19
|
+
/** Size tokens + variant state (matches web stacking size + variant classes). */
|
|
20
|
+
function getMergedTabLayerStyle(theme, visual, active, layer, state) {
|
|
21
|
+
return {
|
|
22
|
+
...getTabSizeLayerStyle(theme, layer === "rootText" ? "rootText" : layer === "icon" ? "icon" : "root"),
|
|
23
|
+
...getTabLayerStyle(theme, visual, active, layer, state)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.getMergedTabLayerStyle = getMergedTabLayerStyle;
|
|
28
|
+
exports.getTabLayerStyle = getTabLayerStyle;
|
|
29
|
+
exports.getTabSizeLayerStyle = getTabSizeLayerStyle;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
import { UniversalTabsVariant } from "../../types/dist/index.cjs";
|
|
3
|
+
import { TextStyle, ViewStyle } from "react-native";
|
|
4
|
+
|
|
5
|
+
//#region src/components/Tabs/tabTheme.d.ts
|
|
6
|
+
type TabActiveState = 'on' | 'off';
|
|
7
|
+
type TabLayer = 'root' | 'rootText' | 'icon';
|
|
8
|
+
type InteractionState = 'rest' | 'pressed';
|
|
9
|
+
/** Default tab dimensions / spacing from tokens (`tab/size/default/...`). */
|
|
10
|
+
declare function getTabSizeLayerStyle(theme: {
|
|
11
|
+
components: Record<string, any>;
|
|
12
|
+
}, layer: 'root' | 'rootText' | 'icon'): ViewStyle | TextStyle;
|
|
13
|
+
/** Variant + interaction layer (active on/off, pressed/rest). */
|
|
14
|
+
declare function getTabLayerStyle(theme: {
|
|
15
|
+
components: Record<string, any>;
|
|
16
|
+
}, visual: UniversalTabsVariant, active: TabActiveState, layer: TabLayer, state: InteractionState): ViewStyle | TextStyle;
|
|
17
|
+
/** Size tokens + variant state (matches web stacking size + variant classes). */
|
|
18
|
+
declare function getMergedTabLayerStyle(theme: {
|
|
19
|
+
components: Record<string, any>;
|
|
20
|
+
}, visual: UniversalTabsVariant, active: TabActiveState, layer: TabLayer, state: InteractionState): ViewStyle | TextStyle;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { getMergedTabLayerStyle, getTabLayerStyle, getTabSizeLayerStyle };
|
|
23
|
+
//# sourceMappingURL=tabTheme.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabTheme.d.cts","names":[],"sources":["../../../src/components/Tabs/tabTheme.ts"],"mappings":";;;;;KAGK,cAAA;AAAA,KACA,QAAA;AAAA,KACA,gBAAA;;iBAaW,oBAAA,CAEd,KAAA;EAAS,UAAA,EAAY,MAAA;AAAA,GACrB,KAAA,iCACC,SAAA,GAAY,SAAA;AAnBI;AAAA,iBA0BH,gBAAA,CAEd,KAAA;EAAS,UAAA,EAAY,MAAA;AAAA,GACrB,MAAA,EAAQ,oBAAA,EACR,MAAA,EAAQ,cAAA,EACR,KAAA,EAAO,QAAA,EACP,KAAA,EAAO,gBAAA,GACN,SAAA,GAAY,SAAA;;iBAOC,sBAAA,CAEd,KAAA;EAAS,UAAA,EAAY,MAAA;AAAA,GACrB,MAAA,EAAQ,oBAAA,EACR,MAAA,EAAQ,cAAA,EACR,KAAA,EAAO,QAAA,EACP,KAAA,EAAO,gBAAA,GACN,SAAA,GAAY,SAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
import { UniversalTabsVariant } from "../../types/dist/index.js";
|
|
3
|
+
import { TextStyle, ViewStyle } from "react-native";
|
|
4
|
+
|
|
5
|
+
//#region src/components/Tabs/tabTheme.d.ts
|
|
6
|
+
type TabActiveState = 'on' | 'off';
|
|
7
|
+
type TabLayer = 'root' | 'rootText' | 'icon';
|
|
8
|
+
type InteractionState = 'rest' | 'pressed';
|
|
9
|
+
/** Default tab dimensions / spacing from tokens (`tab/size/default/...`). */
|
|
10
|
+
declare function getTabSizeLayerStyle(theme: {
|
|
11
|
+
components: Record<string, any>;
|
|
12
|
+
}, layer: 'root' | 'rootText' | 'icon'): ViewStyle | TextStyle;
|
|
13
|
+
/** Variant + interaction layer (active on/off, pressed/rest). */
|
|
14
|
+
declare function getTabLayerStyle(theme: {
|
|
15
|
+
components: Record<string, any>;
|
|
16
|
+
}, visual: UniversalTabsVariant, active: TabActiveState, layer: TabLayer, state: InteractionState): ViewStyle | TextStyle;
|
|
17
|
+
/** Size tokens + variant state (matches web stacking size + variant classes). */
|
|
18
|
+
declare function getMergedTabLayerStyle(theme: {
|
|
19
|
+
components: Record<string, any>;
|
|
20
|
+
}, visual: UniversalTabsVariant, active: TabActiveState, layer: TabLayer, state: InteractionState): ViewStyle | TextStyle;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { getMergedTabLayerStyle, getTabLayerStyle, getTabSizeLayerStyle };
|
|
23
|
+
//# sourceMappingURL=tabTheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabTheme.d.ts","names":[],"sources":["../../../src/components/Tabs/tabTheme.ts"],"mappings":";;;;;KAGK,cAAA;AAAA,KACA,QAAA;AAAA,KACA,gBAAA;;iBAaW,oBAAA,CAEd,KAAA;EAAS,UAAA,EAAY,MAAA;AAAA,GACrB,KAAA,iCACC,SAAA,GAAY,SAAA;AAnBI;AAAA,iBA0BH,gBAAA,CAEd,KAAA;EAAS,UAAA,EAAY,MAAA;AAAA,GACrB,MAAA,EAAQ,oBAAA,EACR,MAAA,EAAQ,cAAA,EACR,KAAA,EAAO,QAAA,EACP,KAAA,EAAO,gBAAA,GACN,SAAA,GAAY,SAAA;;iBAOC,sBAAA,CAEd,KAAA;EAAS,UAAA,EAAY,MAAA;AAAA,GACrB,MAAA,EAAQ,oBAAA,EACR,MAAA,EAAQ,cAAA,EACR,KAAA,EAAO,QAAA,EACP,KAAA,EAAO,gBAAA,GACN,SAAA,GAAY,SAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
//#region src/components/Tabs/tabTheme.ts
|
|
3
|
+
function tabComponentPath(visual, active, layer, state) {
|
|
4
|
+
return `tab/variant/${visual}/active/${active}/${layer === "rootText" ? "rootText" : layer}/${state}`;
|
|
5
|
+
}
|
|
6
|
+
/** Default tab dimensions / spacing from tokens (`tab/size/default/...`). */
|
|
7
|
+
function getTabSizeLayerStyle(theme, layer) {
|
|
8
|
+
const path = `tab/size/default/${layer}/rest`;
|
|
9
|
+
const s = theme.components[path];
|
|
10
|
+
return s && typeof s === "object" ? s : {};
|
|
11
|
+
}
|
|
12
|
+
/** Variant + interaction layer (active on/off, pressed/rest). */
|
|
13
|
+
function getTabLayerStyle(theme, visual, active, layer, state) {
|
|
14
|
+
const path = tabComponentPath(visual, active, layer, state);
|
|
15
|
+
const s = theme.components[path];
|
|
16
|
+
return s && typeof s === "object" ? s : {};
|
|
17
|
+
}
|
|
18
|
+
/** Size tokens + variant state (matches web stacking size + variant classes). */
|
|
19
|
+
function getMergedTabLayerStyle(theme, visual, active, layer, state) {
|
|
20
|
+
return {
|
|
21
|
+
...getTabSizeLayerStyle(theme, layer === "rootText" ? "rootText" : layer === "icon" ? "icon" : "root"),
|
|
22
|
+
...getTabLayerStyle(theme, visual, active, layer, state)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { getMergedTabLayerStyle, getTabLayerStyle, getTabSizeLayerStyle };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=tabTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabTheme.js","names":[],"sources":["../../../src/components/Tabs/tabTheme.ts"],"sourcesContent":["import type { UniversalTabsVariant } from '@yahoo/uds-types';\nimport type { TextStyle, ViewStyle } from 'react-native';\n\ntype TabActiveState = 'on' | 'off';\ntype TabLayer = 'root' | 'rootText' | 'icon';\ntype InteractionState = 'rest' | 'pressed';\n\nfunction tabComponentPath(\n visual: UniversalTabsVariant,\n active: TabActiveState,\n layer: TabLayer,\n state: InteractionState,\n): string {\n const layerKey = layer === 'rootText' ? 'rootText' : layer;\n return `tab/variant/${visual}/active/${active}/${layerKey}/${state}`;\n}\n\n/** Default tab dimensions / spacing from tokens (`tab/size/default/...`). */\nexport function getTabSizeLayerStyle(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n theme: { components: Record<string, any> },\n layer: 'root' | 'rootText' | 'icon',\n): ViewStyle | TextStyle {\n const path = `tab/size/default/${layer}/rest`;\n const s = theme.components[path];\n return s && typeof s === 'object' ? s : {};\n}\n\n/** Variant + interaction layer (active on/off, pressed/rest). */\nexport function getTabLayerStyle(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n theme: { components: Record<string, any> },\n visual: UniversalTabsVariant,\n active: TabActiveState,\n layer: TabLayer,\n state: InteractionState,\n): ViewStyle | TextStyle {\n const path = tabComponentPath(visual, active, layer, state);\n const s = theme.components[path];\n return s && typeof s === 'object' ? s : {};\n}\n\n/** Size tokens + variant state (matches web stacking size + variant classes). */\nexport function getMergedTabLayerStyle(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n theme: { components: Record<string, any> },\n visual: UniversalTabsVariant,\n active: TabActiveState,\n layer: TabLayer,\n state: InteractionState,\n): ViewStyle | TextStyle {\n const sizeKey = layer === 'rootText' ? 'rootText' : layer === 'icon' ? 'icon' : 'root';\n return {\n ...(getTabSizeLayerStyle(theme, sizeKey) as object),\n ...(getTabLayerStyle(theme, visual, active, layer, state) as object),\n } as ViewStyle;\n}\n"],"mappings":";;AAOA,SAAS,iBACP,QACA,QACA,OACA,OACQ;AAER,QAAO,eAAe,OAAO,UAAU,OAAO,GAD7B,UAAU,aAAa,aAAa,MACK,GAAG;;;AAI/D,SAAgB,qBAEd,OACA,OACuB;CACvB,MAAM,OAAO,oBAAoB,MAAM;CACvC,MAAM,IAAI,MAAM,WAAW;AAC3B,QAAO,KAAK,OAAO,MAAM,WAAW,IAAI,EAAE;;;AAI5C,SAAgB,iBAEd,OACA,QACA,QACA,OACA,OACuB;CACvB,MAAM,OAAO,iBAAiB,QAAQ,QAAQ,OAAO,MAAM;CAC3D,MAAM,IAAI,MAAM,WAAW;AAC3B,QAAO,KAAK,OAAO,MAAM,WAAW,IAAI,EAAE;;;AAI5C,SAAgB,uBAEd,OACA,QACA,QACA,OACA,OACuB;AAEvB,QAAO;EACL,GAAI,qBAAqB,OAFX,UAAU,aAAa,aAAa,UAAU,SAAS,SAAS,OAEtC;EACxC,GAAI,iBAAiB,OAAO,QAAQ,QAAQ,OAAO,MAAM;EAC1D"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
4
|
+
let react = require("react");
|
|
5
|
+
//#region src/components/Tabs/tabsContexts.tsx
|
|
6
|
+
const TabsVisualContext = (0, react.createContext)({
|
|
7
|
+
variant: "primary",
|
|
8
|
+
reduceMotion: false
|
|
9
|
+
});
|
|
10
|
+
function useTabsVisualContext() {
|
|
11
|
+
return (0, react.useContext)(TabsVisualContext);
|
|
12
|
+
}
|
|
13
|
+
const TabSelectionContext = (0, react.createContext)(null);
|
|
14
|
+
function useTabSelectionContext() {
|
|
15
|
+
const ctx = (0, react.useContext)(TabSelectionContext);
|
|
16
|
+
if (!ctx) throw new Error("Tab components must be used within <Tabs>");
|
|
17
|
+
return ctx;
|
|
18
|
+
}
|
|
19
|
+
function useTabSelectionState({ defaultSelectedId, selectedId: selectedIdProp, onSelectionChange }) {
|
|
20
|
+
const isControlled = selectedIdProp !== void 0;
|
|
21
|
+
const [internalSelectedId, setInternalSelectedId] = (0, react.useState)(defaultSelectedId ?? null);
|
|
22
|
+
const [registeredIds, setRegisteredIds] = (0, react.useState)([]);
|
|
23
|
+
const [tabLayouts, setTabLayouts] = (0, react.useState)(() => /* @__PURE__ */ new Map());
|
|
24
|
+
const selectedId = isControlled ? selectedIdProp : internalSelectedId;
|
|
25
|
+
const setSelectedId = (0, react.useCallback)((id) => {
|
|
26
|
+
if (!isControlled) setInternalSelectedId(id);
|
|
27
|
+
onSelectionChange?.(id);
|
|
28
|
+
}, [isControlled, onSelectionChange]);
|
|
29
|
+
const registerTab = (0, react.useCallback)((id) => {
|
|
30
|
+
setRegisteredIds((prev) => prev.includes(id) ? prev : [...prev, id]);
|
|
31
|
+
}, []);
|
|
32
|
+
const unregisterTab = (0, react.useCallback)((id) => {
|
|
33
|
+
setRegisteredIds((prev) => prev.filter((x) => x !== id));
|
|
34
|
+
setTabLayouts((prev) => {
|
|
35
|
+
const next = new Map(prev);
|
|
36
|
+
next.delete(id);
|
|
37
|
+
return next;
|
|
38
|
+
});
|
|
39
|
+
}, []);
|
|
40
|
+
const setTabLayout = (0, react.useCallback)((id, layout) => {
|
|
41
|
+
setTabLayouts((prev) => {
|
|
42
|
+
const cur = prev.get(id);
|
|
43
|
+
if (cur && cur.x === layout.x && cur.y === layout.y && cur.width === layout.width && cur.height === layout.height) return prev;
|
|
44
|
+
const next = new Map(prev);
|
|
45
|
+
next.set(id, layout);
|
|
46
|
+
return next;
|
|
47
|
+
});
|
|
48
|
+
}, []);
|
|
49
|
+
const clearTabLayout = (0, react.useCallback)((id) => {
|
|
50
|
+
setTabLayouts((prev) => {
|
|
51
|
+
if (!prev.has(id)) return prev;
|
|
52
|
+
const next = new Map(prev);
|
|
53
|
+
next.delete(id);
|
|
54
|
+
return next;
|
|
55
|
+
});
|
|
56
|
+
}, []);
|
|
57
|
+
(0, react.useEffect)(() => {
|
|
58
|
+
if (isControlled || defaultSelectedId !== void 0) return;
|
|
59
|
+
if (internalSelectedId !== null) return;
|
|
60
|
+
if (registeredIds.length === 0) return;
|
|
61
|
+
setInternalSelectedId(registeredIds[0]);
|
|
62
|
+
}, [
|
|
63
|
+
isControlled,
|
|
64
|
+
defaultSelectedId,
|
|
65
|
+
internalSelectedId,
|
|
66
|
+
registeredIds
|
|
67
|
+
]);
|
|
68
|
+
return (0, react.useMemo)(() => ({
|
|
69
|
+
selectedId,
|
|
70
|
+
setSelectedId,
|
|
71
|
+
registerTab,
|
|
72
|
+
unregisterTab,
|
|
73
|
+
tabLayouts,
|
|
74
|
+
setTabLayout,
|
|
75
|
+
clearTabLayout
|
|
76
|
+
}), [
|
|
77
|
+
selectedId,
|
|
78
|
+
setSelectedId,
|
|
79
|
+
registerTab,
|
|
80
|
+
unregisterTab,
|
|
81
|
+
tabLayouts,
|
|
82
|
+
setTabLayout,
|
|
83
|
+
clearTabLayout
|
|
84
|
+
]);
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
exports.TabSelectionContext = TabSelectionContext;
|
|
88
|
+
exports.TabsVisualContext = TabsVisualContext;
|
|
89
|
+
exports.useTabSelectionContext = useTabSelectionContext;
|
|
90
|
+
exports.useTabSelectionState = useTabSelectionState;
|
|
91
|
+
exports.useTabsVisualContext = useTabsVisualContext;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
import { UniversalTabsVariant } from "../../types/dist/index.cjs";
|
|
3
|
+
import * as _$react from "react";
|
|
4
|
+
import { LayoutRectangle } from "react-native";
|
|
5
|
+
|
|
6
|
+
//#region src/components/Tabs/tabsContexts.d.ts
|
|
7
|
+
interface TabsVisualContextValue {
|
|
8
|
+
variant: UniversalTabsVariant;
|
|
9
|
+
reduceMotion: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const TabsVisualContext: _$react.Context<TabsVisualContextValue>;
|
|
12
|
+
declare function useTabsVisualContext(): TabsVisualContextValue;
|
|
13
|
+
interface TabSelectionContextValue {
|
|
14
|
+
selectedId: string | null | undefined;
|
|
15
|
+
setSelectedId: (id: string) => void;
|
|
16
|
+
registerTab: (id: string) => void;
|
|
17
|
+
unregisterTab: (id: string) => void;
|
|
18
|
+
tabLayouts: ReadonlyMap<string, LayoutRectangle>;
|
|
19
|
+
setTabLayout: (id: string, layout: LayoutRectangle) => void;
|
|
20
|
+
clearTabLayout: (id: string) => void;
|
|
21
|
+
}
|
|
22
|
+
declare const TabSelectionContext: _$react.Context<TabSelectionContextValue | null>;
|
|
23
|
+
declare function useTabSelectionContext(): TabSelectionContextValue;
|
|
24
|
+
declare function useTabSelectionState({
|
|
25
|
+
defaultSelectedId,
|
|
26
|
+
selectedId: selectedIdProp,
|
|
27
|
+
onSelectionChange
|
|
28
|
+
}: {
|
|
29
|
+
defaultSelectedId?: string;
|
|
30
|
+
selectedId?: string | null;
|
|
31
|
+
onSelectionChange?: (selectedId: string | null | undefined) => void;
|
|
32
|
+
}): TabSelectionContextValue;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { TabSelectionContext, TabSelectionContextValue, TabsVisualContext, TabsVisualContextValue, useTabSelectionContext, useTabSelectionState, useTabsVisualContext };
|
|
35
|
+
//# sourceMappingURL=tabsContexts.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabsContexts.d.cts","names":[],"sources":["../../../src/components/Tabs/tabsContexts.tsx"],"mappings":";;;;;;UAIiB,sBAAA;EACf,OAAA,EAAS,oBAAA;EACT,YAAA;AAAA;AAAA,cAGW,iBAAA,EAAiB,OAAA,CAAA,OAAA,CAAA,sBAAA;AAAA,iBAKd,oBAAA,CAAA,GAAwB,sBAAA;AAAA,UAIvB,wBAAA;EACf,UAAA;EACA,aAAA,GAAgB,EAAA;EAChB,WAAA,GAAc,EAAA;EACd,aAAA,GAAgB,EAAA;EAChB,UAAA,EAAY,WAAA,SAAoB,eAAA;EAChC,YAAA,GAAe,EAAA,UAAY,MAAA,EAAQ,eAAA;EACnC,cAAA,GAAiB,EAAA;AAAA;AAAA,cAGN,mBAAA,EAAmB,OAAA,CAAA,OAAA,CAAA,wBAAA;AAAA,iBAEhB,sBAAA,CAAA,GAA0B,wBAAA;AAAA,iBAQ1B,oBAAA,CAAA;EACd,iBAAA;EACA,UAAA,EAAY,cAAA;EACZ;AAAA;EAEA,iBAAA;EACA,UAAA;EACA,iBAAA,IAAqB,UAAA;AAAA,IACnB,wBAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
import { UniversalTabsVariant } from "../../types/dist/index.js";
|
|
3
|
+
import * as _$react from "react";
|
|
4
|
+
import { LayoutRectangle } from "react-native";
|
|
5
|
+
|
|
6
|
+
//#region src/components/Tabs/tabsContexts.d.ts
|
|
7
|
+
interface TabsVisualContextValue {
|
|
8
|
+
variant: UniversalTabsVariant;
|
|
9
|
+
reduceMotion: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const TabsVisualContext: _$react.Context<TabsVisualContextValue>;
|
|
12
|
+
declare function useTabsVisualContext(): TabsVisualContextValue;
|
|
13
|
+
interface TabSelectionContextValue {
|
|
14
|
+
selectedId: string | null | undefined;
|
|
15
|
+
setSelectedId: (id: string) => void;
|
|
16
|
+
registerTab: (id: string) => void;
|
|
17
|
+
unregisterTab: (id: string) => void;
|
|
18
|
+
tabLayouts: ReadonlyMap<string, LayoutRectangle>;
|
|
19
|
+
setTabLayout: (id: string, layout: LayoutRectangle) => void;
|
|
20
|
+
clearTabLayout: (id: string) => void;
|
|
21
|
+
}
|
|
22
|
+
declare const TabSelectionContext: _$react.Context<TabSelectionContextValue | null>;
|
|
23
|
+
declare function useTabSelectionContext(): TabSelectionContextValue;
|
|
24
|
+
declare function useTabSelectionState({
|
|
25
|
+
defaultSelectedId,
|
|
26
|
+
selectedId: selectedIdProp,
|
|
27
|
+
onSelectionChange
|
|
28
|
+
}: {
|
|
29
|
+
defaultSelectedId?: string;
|
|
30
|
+
selectedId?: string | null;
|
|
31
|
+
onSelectionChange?: (selectedId: string | null | undefined) => void;
|
|
32
|
+
}): TabSelectionContextValue;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { TabSelectionContext, TabSelectionContextValue, TabsVisualContext, TabsVisualContextValue, useTabSelectionContext, useTabSelectionState, useTabsVisualContext };
|
|
35
|
+
//# sourceMappingURL=tabsContexts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabsContexts.d.ts","names":[],"sources":["../../../src/components/Tabs/tabsContexts.tsx"],"mappings":";;;;;;UAIiB,sBAAA;EACf,OAAA,EAAS,oBAAA;EACT,YAAA;AAAA;AAAA,cAGW,iBAAA,EAAiB,OAAA,CAAA,OAAA,CAAA,sBAAA;AAAA,iBAKd,oBAAA,CAAA,GAAwB,sBAAA;AAAA,UAIvB,wBAAA;EACf,UAAA;EACA,aAAA,GAAgB,EAAA;EAChB,WAAA,GAAc,EAAA;EACd,aAAA,GAAgB,EAAA;EAChB,UAAA,EAAY,WAAA,SAAoB,eAAA;EAChC,YAAA,GAAe,EAAA,UAAY,MAAA,EAAQ,eAAA;EACnC,cAAA,GAAiB,EAAA;AAAA;AAAA,cAGN,mBAAA,EAAmB,OAAA,CAAA,OAAA,CAAA,wBAAA;AAAA,iBAEhB,sBAAA,CAAA,GAA0B,wBAAA;AAAA,iBAQ1B,oBAAA,CAAA;EACd,iBAAA;EACA,UAAA,EAAY,cAAA;EACZ;AAAA;EAEA,iBAAA;EACA,UAAA;EACA,iBAAA,IAAqB,UAAA;AAAA,IACnB,wBAAA"}
|