@soroush.tech/design-system 2.0.0-rc.1 → 2.0.0-rc.3
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 +30 -10
- package/dist/AppBar.d.cts +1 -3
- package/dist/AppBar.d.mts +1 -3
- package/dist/Avatar.cjs +1 -1
- package/dist/Avatar.d.cts +1 -3
- package/dist/Avatar.d.mts +1 -3
- package/dist/Avatar.mjs +1 -1
- package/dist/Backdrop.d.cts +1 -1
- package/dist/Backdrop.d.mts +1 -1
- package/dist/Breadcrumbs.cjs +132 -0
- package/dist/Breadcrumbs.d.cts +40 -0
- package/dist/Breadcrumbs.d.mts +40 -0
- package/dist/Breadcrumbs.mjs +131 -0
- package/dist/Button.cjs +1 -1
- package/dist/Button.d.cts +1 -1
- package/dist/Button.d.mts +1 -1
- package/dist/Button.mjs +1 -1
- package/dist/ButtonGroup.d.cts +1 -1
- package/dist/ButtonGroup.d.mts +1 -1
- package/dist/Card.cjs +3 -3
- package/dist/Card.d.cts +4 -3
- package/dist/Card.d.mts +4 -3
- package/dist/Card.mjs +3 -3
- package/dist/Checkbox.d.cts +1 -2
- package/dist/Checkbox.d.mts +1 -2
- package/dist/CircularProgress.d.cts +2 -3
- package/dist/CircularProgress.d.mts +2 -3
- package/dist/Drawer.d.cts +3 -2
- package/dist/Drawer.d.mts +3 -2
- package/dist/Flex.d.cts +1 -1
- package/dist/Flex.d.mts +1 -1
- package/dist/Form.d.cts +1 -1
- package/dist/Form.d.mts +1 -1
- package/dist/FormControl.cjs +10 -2
- package/dist/FormControl.d.cts +9 -2
- package/dist/FormControl.d.mts +9 -2
- package/dist/FormControl.mjs +10 -2
- package/dist/FormHelperText.d.cts +1 -1
- package/dist/FormHelperText.d.mts +1 -1
- package/dist/FormLabel.cjs +9 -1
- package/dist/FormLabel.d.cts +2 -2
- package/dist/FormLabel.d.mts +2 -2
- package/dist/FormLabel.mjs +10 -2
- package/dist/Grid.d.cts +1 -3
- package/dist/Grid.d.mts +1 -3
- package/dist/{Icon-CH3asUJu.mjs → Icon-BihOAP4u.mjs} +52 -2
- package/dist/{Icon-CI6q2Eyi.cjs → Icon-D-EWsBVg.cjs} +52 -2
- package/dist/Icon.cjs +1 -1
- package/dist/Icon.d.cts +1 -1
- package/dist/Icon.d.mts +1 -1
- package/dist/Icon.mjs +1 -1
- package/dist/Image.d.cts +1 -2
- package/dist/Image.d.mts +1 -2
- package/dist/InputRange.cjs +675 -0
- package/dist/InputRange.d.cts +79 -0
- package/dist/InputRange.d.mts +79 -0
- package/dist/InputRange.mjs +673 -0
- package/dist/LinearProgress.d.cts +2 -3
- package/dist/LinearProgress.d.mts +2 -3
- package/dist/Link.cjs +1 -1
- package/dist/Link.d.cts +1 -1
- package/dist/Link.d.mts +1 -1
- package/dist/Link.mjs +1 -1
- package/dist/Menu/ContextMenu.cjs +146 -0
- package/dist/Menu/ContextMenu.d.cts +52 -0
- package/dist/Menu/ContextMenu.d.mts +52 -0
- package/dist/Menu/ContextMenu.mjs +145 -0
- package/dist/Menu/Menu.cjs +3 -0
- package/dist/Menu/Menu.d.cts +2 -0
- package/dist/Menu/Menu.d.mts +2 -0
- package/dist/Menu/Menu.mjs +2 -0
- package/dist/Menu/MenuDivider.cjs +29 -0
- package/dist/Menu/MenuDivider.d.cts +12 -0
- package/dist/Menu/MenuDivider.d.mts +12 -0
- package/dist/Menu/MenuDivider.mjs +28 -0
- package/dist/Menu/MenuItems.cjs +29 -0
- package/dist/Menu/MenuItems.d.cts +2 -0
- package/dist/Menu/MenuItems.d.mts +2 -0
- package/dist/Menu/MenuItems.mjs +28 -0
- package/dist/Menu/MenuList.cjs +3 -0
- package/dist/Menu/MenuList.d.cts +38 -0
- package/dist/Menu/MenuList.d.mts +38 -0
- package/dist/Menu/MenuList.mjs +2 -0
- package/dist/Menu-Cgg-sX4W.cjs +173 -0
- package/dist/Menu-CrzHc_cn.mjs +168 -0
- package/dist/Menu.cjs +13 -0
- package/dist/Menu.d.cts +7 -0
- package/dist/Menu.d.mts +7 -0
- package/dist/Menu.mjs +6 -0
- package/dist/MenuItem-BTP7Ijwi.cjs +673 -0
- package/dist/MenuItem-DUn4IZKK.mjs +649 -0
- package/dist/MenuItem.cjs +2 -148
- package/dist/MenuItem.d.cts +2 -52
- package/dist/MenuItem.d.mts +2 -52
- package/dist/MenuItem.mjs +1 -147
- package/dist/MenuList-B7msJ1IG.mjs +187 -0
- package/dist/MenuList-D4imLXAa.cjs +223 -0
- package/dist/MenuListContext-DKUOhNyw.d.cts +21 -0
- package/dist/MenuListContext-x-7lH4CH.d.mts +21 -0
- package/dist/Modal.d.cts +1 -1
- package/dist/Modal.d.mts +1 -1
- package/dist/NativeSelect.cjs +9 -8
- package/dist/NativeSelect.d.cts +3 -4
- package/dist/NativeSelect.d.mts +3 -4
- package/dist/NativeSelect.mjs +9 -8
- package/dist/NumberField.cjs +476 -0
- package/dist/NumberField.d.cts +74 -0
- package/dist/NumberField.d.mts +74 -0
- package/dist/NumberField.mjs +474 -0
- package/dist/Pagination/PaginationItem.cjs +1 -1
- package/dist/Pagination/PaginationItem.d.cts +1 -1
- package/dist/Pagination/PaginationItem.d.mts +1 -1
- package/dist/Pagination/PaginationItem.mjs +1 -1
- package/dist/Pagination.d.cts +2 -2
- package/dist/Pagination.d.mts +2 -2
- package/dist/Paper.cjs +1 -1
- package/dist/Paper.d.cts +2 -1
- package/dist/Paper.d.mts +2 -1
- package/dist/Paper.mjs +1 -1
- package/dist/{Popover-TpwRSORC.cjs → Popover-CiZfgiKE.cjs} +5 -125
- package/dist/Popover-QjM5Z1CR.mjs +133 -0
- package/dist/Popover.cjs +1 -1
- package/dist/Popover.d.cts +6 -7
- package/dist/Popover.d.mts +6 -7
- package/dist/Popover.mjs +1 -1
- package/dist/Pressable.cjs +1 -1
- package/dist/Pressable.d.cts +1 -1
- package/dist/Pressable.d.mts +1 -1
- package/dist/Pressable.mjs +1 -1
- package/dist/Quote.d.cts +2 -3
- package/dist/Quote.d.mts +2 -3
- package/dist/Radio.d.cts +1 -2
- package/dist/Radio.d.mts +1 -2
- package/dist/Rating.cjs +373 -0
- package/dist/Rating.d.cts +57 -0
- package/dist/Rating.d.mts +57 -0
- package/dist/Rating.mjs +371 -0
- package/dist/Select.cjs +5 -4
- package/dist/Select.d.cts +3 -4
- package/dist/Select.d.mts +3 -4
- package/dist/Select.mjs +7 -6
- package/dist/Sidebar/Sidebar.d.cts +1 -1
- package/dist/Sidebar/Sidebar.d.mts +1 -1
- package/dist/Sidebar/SidebarItem.cjs +1 -1
- package/dist/Sidebar/SidebarItem.d.cts +3 -4
- package/dist/Sidebar/SidebarItem.d.mts +3 -4
- package/dist/Sidebar/SidebarItem.mjs +3 -3
- package/dist/Skeleton.d.cts +1 -2
- package/dist/Skeleton.d.mts +1 -2
- package/dist/Switch.cjs +23 -16
- package/dist/Switch.d.cts +2 -3
- package/dist/Switch.d.mts +2 -3
- package/dist/Switch.mjs +25 -18
- package/dist/Table/Table.d.cts +2 -3
- package/dist/Table/Table.d.mts +2 -3
- package/dist/Table/TableBody.d.cts +1 -2
- package/dist/Table/TableBody.d.mts +1 -2
- package/dist/Table/TableCell.d.cts +1 -1
- package/dist/Table/TableCell.d.mts +1 -1
- package/dist/Table/TableContainer.d.cts +1 -3
- package/dist/Table/TableContainer.d.mts +1 -3
- package/dist/Table/TableControl.d.cts +1 -1
- package/dist/Table/TableControl.d.mts +1 -1
- package/dist/Table/TableControl.mjs +2 -2
- package/dist/Table/TableFooter.d.cts +1 -2
- package/dist/Table/TableFooter.d.mts +1 -2
- package/dist/Table/TableHead.d.cts +1 -2
- package/dist/Table/TableHead.d.mts +1 -2
- package/dist/Table/TablePagination.d.cts +2 -2
- package/dist/Table/TablePagination.d.mts +2 -2
- package/dist/Table/TablePaginationActions.cjs +1 -1
- package/dist/Table/TablePaginationActions.d.cts +1 -1
- package/dist/Table/TablePaginationActions.d.mts +1 -1
- package/dist/Table/TablePaginationActions.mjs +1 -1
- package/dist/Table/TableRow.d.cts +1 -2
- package/dist/Table/TableRow.d.mts +1 -2
- package/dist/Table/TableSortLabel.cjs +1 -1
- package/dist/Table/TableSortLabel.d.cts +1 -1
- package/dist/Table/TableSortLabel.d.mts +1 -1
- package/dist/Table/TableSortLabel.mjs +1 -1
- package/dist/Table/hooks.d.cts +1 -1
- package/dist/Table/hooks.d.mts +1 -1
- package/dist/Table.d.cts +5 -5
- package/dist/Table.d.mts +5 -5
- package/dist/{TableContext-BeCxbtHH.d.cts → TableContext-DhuRf6Wy.d.mts} +1 -1
- package/dist/{TableContext-BiRiYkVZ.d.mts → TableContext-Duj1nVG7.d.cts} +1 -1
- package/dist/Tabs/Tab.cjs +306 -0
- package/dist/Tabs/Tab.d.cts +62 -0
- package/dist/Tabs/Tab.d.mts +62 -0
- package/dist/Tabs/Tab.mjs +305 -0
- package/dist/Tabs/TabContext.cjs +34 -0
- package/dist/Tabs/TabContext.d.cts +20 -0
- package/dist/Tabs/TabContext.d.mts +20 -0
- package/dist/Tabs/TabContext.mjs +33 -0
- package/dist/Tabs/TabList.cjs +31 -0
- package/dist/Tabs/TabList.d.cts +11 -0
- package/dist/Tabs/TabList.d.mts +11 -0
- package/dist/Tabs/TabList.mjs +30 -0
- package/dist/Tabs/TabPanel.cjs +40 -0
- package/dist/Tabs/TabPanel.d.cts +27 -0
- package/dist/Tabs/TabPanel.d.mts +27 -0
- package/dist/Tabs/TabPanel.mjs +38 -0
- package/dist/Tabs/TabScrollButton.cjs +93 -0
- package/dist/Tabs/TabScrollButton.d.cts +2 -0
- package/dist/Tabs/TabScrollButton.d.mts +2 -0
- package/dist/Tabs/TabScrollButton.mjs +91 -0
- package/dist/Tabs/Tabs.cjs +3 -0
- package/dist/Tabs/Tabs.d.cts +3 -0
- package/dist/Tabs/Tabs.d.mts +3 -0
- package/dist/Tabs/Tabs.mjs +2 -0
- package/dist/Tabs-BTNOJx5v.mjs +634 -0
- package/dist/Tabs-D4tWCq78.cjs +646 -0
- package/dist/Tabs.cjs +13 -0
- package/dist/Tabs.d.cts +8 -0
- package/dist/Tabs.d.mts +8 -0
- package/dist/Tabs.mjs +7 -0
- package/dist/TabsContext-B_XHbjcS.d.cts +6 -0
- package/dist/TabsContext-Dn2kqUwr.d.mts +6 -0
- package/dist/TabsValueContext-D40zGCpE.cjs +19 -0
- package/dist/TabsValueContext-DvL3inf7.mjs +8 -0
- package/dist/TextInput.cjs +4 -4
- package/dist/TextInput.d.cts +2 -3
- package/dist/TextInput.d.mts +2 -3
- package/dist/TextInput.mjs +4 -4
- package/dist/ToggleButton/ToggleButton.cjs +1 -1
- package/dist/ToggleButton/ToggleButton.d.cts +1 -1
- package/dist/ToggleButton/ToggleButton.d.mts +1 -1
- package/dist/ToggleButton/ToggleButton.mjs +1 -1
- package/dist/ToggleButton/ToggleButtonGroup.cjs +1 -1
- package/dist/ToggleButton/ToggleButtonGroup.d.cts +1 -1
- package/dist/ToggleButton/ToggleButtonGroup.d.mts +1 -1
- package/dist/ToggleButton/ToggleButtonGroup.mjs +1 -1
- package/dist/TransferList.cjs +356 -0
- package/dist/TransferList.d.cts +67 -0
- package/dist/TransferList.d.mts +67 -0
- package/dist/TransferList.mjs +354 -0
- package/dist/Typography.cjs +1 -1
- package/dist/Typography.d.cts +2 -2
- package/dist/Typography.d.mts +2 -2
- package/dist/Typography.mjs +1 -1
- package/dist/View.d.cts +1 -1
- package/dist/View.d.mts +1 -1
- package/dist/catalog.cjs +4568 -0
- package/dist/catalog.d.cts +90 -0
- package/dist/catalog.d.mts +90 -0
- package/dist/catalog.mjs +4567 -0
- package/dist/computePopoverPosition-BIprs_xo.mjs +123 -0
- package/dist/computePopoverPosition-DiyEOHnU.cjs +128 -0
- package/dist/dividerLine-BNljcGlv.cjs +66 -0
- package/dist/dividerLine-FahY-M6_.mjs +31 -0
- package/dist/engine.d.cts +1 -1
- package/dist/engine.d.mts +1 -1
- package/dist/index-B1RFybA_.d.mts +72 -0
- package/dist/index-B4TeaB7b.d.cts +72 -0
- package/dist/{index-BUoVTCqX.d.mts → index-BGbTuHP9.d.mts} +1 -2
- package/dist/{index-Celm-8iN.d.cts → index-BHKgEOZJ.d.cts} +2 -3
- package/dist/{index-Chg6pSrr.d.mts → index-BQWjh4rK.d.mts} +2 -3
- package/dist/{index-B78VkB0-.d.cts → index-BelFIizY.d.cts} +2 -3
- package/dist/index-BkzZxHVj.d.mts +35 -0
- package/dist/{index-DbEnSf2m.d.cts → index-BrgwkY6z.d.mts} +3 -4
- package/dist/{index-Wnv6jCR3.d.mts → index-Bx0-6yeX.d.mts} +1 -2
- package/dist/index-BxVTIMnB.d.cts +1 -0
- package/dist/{index-BfZuh9c2.d.mts → index-ByYxVl9O.d.mts} +2 -3
- package/dist/index-CE5JG1us.d.mts +34 -0
- package/dist/{index-BhibLnZ0.d.cts → index-CG_1uPrD.d.mts} +2 -3
- package/dist/{themes-RX2UX5gD.d.mts → index-CJhK7JND.d.mts} +265 -8
- package/dist/{index-BB-dLv5V.d.mts → index-CQfJZADG.d.cts} +3 -4
- package/dist/{index-CxUsrlg1.d.cts → index-CUz2h5xY.d.mts} +2 -3
- package/dist/{index-Bid71KeF.d.cts → index-CbFaWtjK.d.mts} +2 -2
- package/dist/{index-DdqdSOct.d.cts → index-ChXeKJCk.d.cts} +1 -2
- package/dist/index-CknoXDLQ.d.cts +35 -0
- package/dist/{index-BSqet8aO.d.cts → index-ClZyaZrR.d.mts} +2 -3
- package/dist/{index-DXvQ-JVZ.d.mts → index-DAwcmIjN.d.cts} +2 -3
- package/dist/index-DGnXJwLj.d.mts +72 -0
- package/dist/{themes-Kbk9h5cN.d.cts → index-DJ0f69wh.d.cts} +262 -5
- package/dist/index-DWjz5ZzG.d.cts +72 -0
- package/dist/{index-DNwF3DUX.d.cts → index-DYF8sRE-.d.cts} +2 -3
- package/dist/index-DaIIo5QU.d.mts +1 -0
- package/dist/{index-CrN4MSUF.d.cts → index-DchHf5cF.d.cts} +1 -1
- package/dist/{index-S-ClM6WM.d.mts → index-DtYjdBvO.d.cts} +2 -2
- package/dist/{index-Ctqajtac.d.cts → index-Dv_fk1_F.d.cts} +27 -3
- package/dist/{index-smqjMLAZ.d.mts → index-K5exjvnX.d.cts} +2 -3
- package/dist/index-KnXhlKMr.d.cts +34 -0
- package/dist/index-WHFhjfgy.d.cts +98 -0
- package/dist/{index-GpnmW6vu.d.mts → index-YKrfFC_I.d.cts} +2 -3
- package/dist/index-bpnLB_4K.d.mts +98 -0
- package/dist/{index-VOsBSWEu.d.mts → index-h4dYtVrp.d.mts} +1 -1
- package/dist/{index-DO9J-Fla.d.mts → index-ha1WjSZ5.d.mts} +27 -3
- package/dist/{index-Belxmt1X.d.cts → index-nqUA_6J_.d.cts} +1 -2
- package/dist/{index-nc4Sxiy9.d.mts → index-pTNq3iQn.d.mts} +2 -3
- package/dist/index.d.cts +1 -2
- package/dist/index.d.mts +1 -2
- package/dist/isRtl-BJDtm86G.mjs +7 -0
- package/dist/isRtl-DTkYHRPo.cjs +12 -0
- package/dist/precision-B1lhxnnO.mjs +25 -0
- package/dist/precision-B58cTPB2.cjs +48 -0
- package/dist/style.cjs +1 -1
- package/dist/style.d.cts +2 -2
- package/dist/style.d.mts +2 -2
- package/dist/style.mjs +1 -1
- package/dist/surfaceSystem-BGQBoXv_.cjs +38 -0
- package/dist/surfaceSystem-D8TbmKy3.mjs +21 -0
- package/dist/theme-BxXuXRgQ.cjs +137 -0
- package/dist/theme-Z9_QludW.mjs +102 -0
- package/dist/theme.cjs +25 -24
- package/dist/theme.d.cts +3 -3
- package/dist/theme.d.mts +3 -3
- package/dist/theme.mjs +2 -1
- package/dist/{theme-CDVxig_g.mjs → themes-L-dE7_ck.mjs} +10 -110
- package/dist/{theme-BXlAP3xf.cjs → themes-gd6tcmqS.cjs} +0 -136
- package/dist/useControlled-C666KpQ0.cjs +18 -0
- package/dist/useControlled-CBRLsO-H.mjs +13 -0
- package/dist/{useTablePagination-COTiNH_8.d.mts → useTablePagination-C-u3ru4N.d.cts} +1 -1
- package/dist/{useTablePagination-WFkaUZu8.d.cts → useTablePagination-D-39ZmQh.d.mts} +1 -1
- package/package.json +83 -2
- package/dist/Popover-DwnSLpp1.mjs +0 -253
- package/dist/index-B_dKjEDR.d.mts +0 -23
- package/dist/index-C1WqEDtQ.d.mts +0 -69
- package/dist/index-CA7HnbtH.d.cts +0 -21
- package/dist/index-CKZaErxJ.d.mts +0 -21
- package/dist/index-DBUwu65Z.d.cts +0 -69
- package/dist/index-DzQJSYIh.d.cts +0 -23
- package/dist/index-cuv3o-L7.d.mts +0 -34
- package/dist/index-nB94D7UM.d.cts +0 -34
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { a as src_exports, o as styled, t as createShouldForwardProp } from "../src-DLGYOJMh.mjs";
|
|
2
|
+
import { n as useDefaultProps } from "../theme-Z9_QludW.mjs";
|
|
3
|
+
import { t as Icon } from "../Icon-BihOAP4u.mjs";
|
|
4
|
+
import { i as TabIndexContext, n as getDividerShadow, o as useTabsContext } from "../dividerLine-FahY-M6_.mjs";
|
|
5
|
+
import { useContext } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/Tabs/Tab/Tab.tsx
|
|
8
|
+
const shouldForwardProp = createShouldForwardProp([
|
|
9
|
+
"variant",
|
|
10
|
+
"color",
|
|
11
|
+
"textColor",
|
|
12
|
+
"sizeToken",
|
|
13
|
+
"isSelected",
|
|
14
|
+
"isDisabled",
|
|
15
|
+
"iconPlacement",
|
|
16
|
+
"isWrapped",
|
|
17
|
+
"fullWidth",
|
|
18
|
+
"isVertical",
|
|
19
|
+
"hasDivider",
|
|
20
|
+
"selectedBg",
|
|
21
|
+
"bg",
|
|
22
|
+
"borderRadius",
|
|
23
|
+
"lineColor",
|
|
24
|
+
"rowPaddingTop",
|
|
25
|
+
"rowPaddingBottom"
|
|
26
|
+
]);
|
|
27
|
+
const getEnclosedEdgeStyle = (theme, main, lineMain, isSelected, isVertical, hasDivider, radius) => {
|
|
28
|
+
const thin = theme.borderWidths.thin;
|
|
29
|
+
const top = `inset 0 ${thin} 0 ${main}`;
|
|
30
|
+
const right = `inset -${thin} 0 0 ${main}`;
|
|
31
|
+
const foot = `inset 0 -${thin} 0 ${main}`;
|
|
32
|
+
const left = `inset ${thin} 0 0 ${main}`;
|
|
33
|
+
const outline = isVertical ? [
|
|
34
|
+
top,
|
|
35
|
+
foot,
|
|
36
|
+
left
|
|
37
|
+
] : [
|
|
38
|
+
top,
|
|
39
|
+
right,
|
|
40
|
+
left
|
|
41
|
+
];
|
|
42
|
+
let edges = "none";
|
|
43
|
+
if (hasDivider) edges = isSelected ? outline.join(", ") : getDividerShadow(theme, isVertical, lineMain);
|
|
44
|
+
return {
|
|
45
|
+
border: "none",
|
|
46
|
+
padding: thin,
|
|
47
|
+
boxShadow: edges,
|
|
48
|
+
borderRadius: 0,
|
|
49
|
+
...isVertical ? {
|
|
50
|
+
borderStartStartRadius: radius,
|
|
51
|
+
borderEndStartRadius: radius
|
|
52
|
+
} : {
|
|
53
|
+
borderTopLeftRadius: radius,
|
|
54
|
+
borderTopRightRadius: radius
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
const TabRoot = styled("div", {
|
|
59
|
+
name: "Tab",
|
|
60
|
+
label: "Tab",
|
|
61
|
+
shouldForwardProp
|
|
62
|
+
})(({ theme, variant, color, isSelected, isDisabled, fullWidth, isVertical, hasDivider, selectedBg, bg, borderRadius, lineColor }) => {
|
|
63
|
+
const main = (0, src_exports.get)(theme, `palette.${color}.main`);
|
|
64
|
+
const isBoxed = variant === "boxed";
|
|
65
|
+
const outlineColor = isBoxed && isSelected ? `${main}59` : "transparent";
|
|
66
|
+
const raised = (0, src_exports.get)(theme, "background.paper");
|
|
67
|
+
const groundKey = isSelected && selectedBg ? selectedBg : bg;
|
|
68
|
+
const ground = groundKey ? (0, src_exports.get)(theme, `background.${groundKey}`) : "transparent";
|
|
69
|
+
const isRounded = isBoxed || variant === "enclosed";
|
|
70
|
+
let radius = 0;
|
|
71
|
+
if (borderRadius) radius = theme.radii[borderRadius];
|
|
72
|
+
else if (isRounded) radius = theme.radii.sm;
|
|
73
|
+
return {
|
|
74
|
+
position: "relative",
|
|
75
|
+
display: "flex",
|
|
76
|
+
alignItems: "stretch",
|
|
77
|
+
flexGrow: fullWidth ? 1 : 0,
|
|
78
|
+
flexShrink: fullWidth ? 1 : 0,
|
|
79
|
+
flexBasis: fullWidth ? 0 : "auto",
|
|
80
|
+
minWidth: 0,
|
|
81
|
+
backgroundColor: ground,
|
|
82
|
+
border: `${theme.borderWidths.thin} solid ${outlineColor}`,
|
|
83
|
+
borderRadius: radius,
|
|
84
|
+
...variant === "enclosed" && getEnclosedEdgeStyle(theme, main, (0, src_exports.get)(theme, `palette.${lineColor}.main`), isSelected, isVertical, hasDivider, String(radius)),
|
|
85
|
+
transition: "background-color 0.12s ease",
|
|
86
|
+
...isDisabled ? {} : { "&:hover": { backgroundColor: isBoxed ? raised : `${main}14` } },
|
|
87
|
+
"&:hover [data-tab-close]": { visibility: "visible" }
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
const TabLabel = styled("button", {
|
|
91
|
+
name: "Tab",
|
|
92
|
+
slot: "label",
|
|
93
|
+
label: "TabLabel",
|
|
94
|
+
shouldForwardProp
|
|
95
|
+
})(({ theme, variant, color, textColor, sizeToken, isSelected, isDisabled, iconPlacement, isWrapped, isVertical, rowPaddingTop, rowPaddingBottom }) => {
|
|
96
|
+
const { paddingTop, paddingBottom, paddingLeft, paddingRight, fontSize } = theme.sizes[sizeToken];
|
|
97
|
+
const main = (0, src_exports.get)(theme, `palette.${color}.main`);
|
|
98
|
+
const idleColor = (0, src_exports.get)(theme, `text.${textColor ?? "primary"}`);
|
|
99
|
+
let labelColor = isSelected ? variant === "boxed" ? idleColor : main : idleColor;
|
|
100
|
+
if (isDisabled) labelColor = (0, src_exports.get)(theme, "text.disabled");
|
|
101
|
+
return {
|
|
102
|
+
appearance: "none",
|
|
103
|
+
display: "grid",
|
|
104
|
+
gridAutoFlow: iconPlacement === "start" || iconPlacement === "end" ? "column" : "row",
|
|
105
|
+
alignContent: iconPlacement === "bottom" ? "start" : "end",
|
|
106
|
+
alignItems: "center",
|
|
107
|
+
justifyContent: "center",
|
|
108
|
+
justifyItems: "center",
|
|
109
|
+
gap: theme.space[1],
|
|
110
|
+
flex: 1,
|
|
111
|
+
minWidth: 0,
|
|
112
|
+
margin: 0,
|
|
113
|
+
paddingTop: theme.space[isVertical ? paddingTop : rowPaddingTop],
|
|
114
|
+
paddingBottom: theme.space[isVertical ? paddingBottom : rowPaddingBottom],
|
|
115
|
+
paddingLeft: theme.space[paddingLeft],
|
|
116
|
+
paddingRight: theme.space[paddingRight],
|
|
117
|
+
fontFamily: theme.fonts.body,
|
|
118
|
+
fontSize: theme.fontSizes[fontSize],
|
|
119
|
+
lineHeight: theme.lineHeights.base,
|
|
120
|
+
whiteSpace: isWrapped ? "normal" : "nowrap",
|
|
121
|
+
textAlign: "center",
|
|
122
|
+
textDecoration: "none",
|
|
123
|
+
color: labelColor,
|
|
124
|
+
backgroundColor: "transparent",
|
|
125
|
+
border: "none",
|
|
126
|
+
borderRadius: "inherit",
|
|
127
|
+
cursor: isDisabled ? "default" : "pointer",
|
|
128
|
+
outline: "none",
|
|
129
|
+
"&:focus-visible": {
|
|
130
|
+
outline: `${theme.borderWidths.base} solid ${main}`,
|
|
131
|
+
outlineOffset: `-${theme.borderWidths.base}`
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
});
|
|
135
|
+
const SecondaryActionSlot = styled("div", {
|
|
136
|
+
name: "Tab",
|
|
137
|
+
slot: "secondaryAction",
|
|
138
|
+
label: "TabSecondaryAction"
|
|
139
|
+
})({
|
|
140
|
+
display: "flex",
|
|
141
|
+
alignItems: "center",
|
|
142
|
+
flexShrink: 0
|
|
143
|
+
});
|
|
144
|
+
const TabClose = styled("button", {
|
|
145
|
+
name: "Tab",
|
|
146
|
+
slot: "close",
|
|
147
|
+
label: "TabClose",
|
|
148
|
+
shouldForwardProp
|
|
149
|
+
})(({ theme, color, isSelected }) => {
|
|
150
|
+
const main = (0, src_exports.get)(theme, `palette.${color}.main`);
|
|
151
|
+
return {
|
|
152
|
+
appearance: "none",
|
|
153
|
+
display: "grid",
|
|
154
|
+
placeItems: "center",
|
|
155
|
+
alignSelf: "center",
|
|
156
|
+
flexShrink: 0,
|
|
157
|
+
width: theme.icon.sm,
|
|
158
|
+
height: theme.icon.sm,
|
|
159
|
+
padding: 0,
|
|
160
|
+
marginInlineEnd: theme.space[.5],
|
|
161
|
+
border: "none",
|
|
162
|
+
borderRadius: theme.radii.sm,
|
|
163
|
+
backgroundColor: "transparent",
|
|
164
|
+
color: "inherit",
|
|
165
|
+
cursor: "pointer",
|
|
166
|
+
visibility: isSelected ? "visible" : "hidden",
|
|
167
|
+
"&:hover": { backgroundColor: `${main}1F` }
|
|
168
|
+
};
|
|
169
|
+
});
|
|
170
|
+
const IconSlot = styled("span", {
|
|
171
|
+
name: "Tab",
|
|
172
|
+
slot: "icon",
|
|
173
|
+
label: "TabIcon"
|
|
174
|
+
})({
|
|
175
|
+
display: "inline-flex",
|
|
176
|
+
flexShrink: 0
|
|
177
|
+
});
|
|
178
|
+
/**
|
|
179
|
+
* @description One tab of a `Tabs`. In a `tablist` it is a `tab` with `aria-selected` and
|
|
180
|
+
* `aria-controls`, the selected one alone in the page's tab order; in a navigation
|
|
181
|
+
* (`Tabs as="nav"`) a button or link marked `aria-current="page"` when it is the current
|
|
182
|
+
* one. It takes one `icon`, which `iconPosition` places on a side of its label.
|
|
183
|
+
*/
|
|
184
|
+
function Tab({ value: valueProp, label, icon, iconPosition = "top", isWrapped: isWrappedProp, bg: bgProp, borderRadius: borderRadiusProp, color: colorProp, textColor: textColorProp, size: sizeProp, selectedBg: selectedBgProp, disabled = false, href, as, onClick, title, closeLabel, secondaryAction, className, "data-testid": dataTestid }) {
|
|
185
|
+
const dp = useDefaultProps("Tab");
|
|
186
|
+
const iconPlacement = icon == null ? void 0 : iconPosition;
|
|
187
|
+
const isIconFirst = iconPlacement === "top" || iconPlacement === "start";
|
|
188
|
+
const iconSlot = icon == null ? null : /* @__PURE__ */ jsx(IconSlot, {
|
|
189
|
+
"aria-hidden": true,
|
|
190
|
+
children: icon
|
|
191
|
+
});
|
|
192
|
+
const isWrapped = isWrappedProp ?? dp.isWrapped ?? false;
|
|
193
|
+
const bg = bgProp ?? dp.bg;
|
|
194
|
+
const borderRadius = borderRadiusProp ?? dp.borderRadius;
|
|
195
|
+
const tabs = useTabsContext();
|
|
196
|
+
const index = useContext(TabIndexContext);
|
|
197
|
+
const value = valueProp ?? index;
|
|
198
|
+
const isSelected = tabs.selectedValue === value;
|
|
199
|
+
const { isNavigation, select, rowProps } = tabs;
|
|
200
|
+
const color = colorProp ?? rowProps.color ?? dp.color ?? tabs.color;
|
|
201
|
+
const textColor = textColorProp ?? rowProps.textColor ?? dp.textColor ?? tabs.textColor;
|
|
202
|
+
const size = sizeProp ?? rowProps.size ?? dp.size ?? tabs.size;
|
|
203
|
+
const selectedBg = selectedBgProp ?? rowProps.selectedBg ?? dp.selectedBg ?? tabs.selectedBg;
|
|
204
|
+
const handleClick = (event) => {
|
|
205
|
+
if (disabled) {
|
|
206
|
+
event.preventDefault();
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
onClick?.(event);
|
|
210
|
+
select(value);
|
|
211
|
+
};
|
|
212
|
+
const handleFocus = () => {
|
|
213
|
+
if (tabs.shouldSelectOnFocus && !disabled && !isSelected) select(value);
|
|
214
|
+
};
|
|
215
|
+
const isClosable = closeLabel !== void 0;
|
|
216
|
+
const close = () => tabs.onTabClose?.(value);
|
|
217
|
+
const handleMouseDown = (event) => {
|
|
218
|
+
if (isClosable && event.button === 1) event.preventDefault();
|
|
219
|
+
};
|
|
220
|
+
const handleAuxClick = (event) => {
|
|
221
|
+
if (isClosable && event.button === 1) close();
|
|
222
|
+
};
|
|
223
|
+
const handleKeyDown = (event) => {
|
|
224
|
+
if (isClosable && event.key === "Delete") {
|
|
225
|
+
event.preventDefault();
|
|
226
|
+
close();
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
const element = as ?? (href === void 0 ? "button" : "a");
|
|
230
|
+
const semantics = isNavigation ? { "aria-current": isSelected ? "page" : void 0 } : {
|
|
231
|
+
role: "tab",
|
|
232
|
+
"aria-selected": isSelected,
|
|
233
|
+
"aria-controls": tabs.getPanelId(value),
|
|
234
|
+
tabIndex: value === tabs.focusableValue ? 0 : -1
|
|
235
|
+
};
|
|
236
|
+
const styleProps = {
|
|
237
|
+
variant: tabs.variant,
|
|
238
|
+
color,
|
|
239
|
+
textColor,
|
|
240
|
+
sizeToken: size,
|
|
241
|
+
isSelected,
|
|
242
|
+
isDisabled: disabled,
|
|
243
|
+
iconPlacement,
|
|
244
|
+
isWrapped,
|
|
245
|
+
fullWidth: tabs.fullWidth,
|
|
246
|
+
isVertical: tabs.isVertical,
|
|
247
|
+
hasDivider: tabs.hasDivider,
|
|
248
|
+
selectedBg,
|
|
249
|
+
bg,
|
|
250
|
+
borderRadius,
|
|
251
|
+
lineColor: tabs.selectedColor,
|
|
252
|
+
rowPaddingTop: tabs.rowPaddingTop,
|
|
253
|
+
rowPaddingBottom: tabs.rowPaddingBottom
|
|
254
|
+
};
|
|
255
|
+
return /* @__PURE__ */ jsxs(TabRoot, {
|
|
256
|
+
...styleProps,
|
|
257
|
+
role: "presentation",
|
|
258
|
+
className,
|
|
259
|
+
"data-tab-value": String(value),
|
|
260
|
+
"data-tab-selected": isSelected || void 0,
|
|
261
|
+
children: [
|
|
262
|
+
/* @__PURE__ */ jsxs(TabLabel, {
|
|
263
|
+
...semantics,
|
|
264
|
+
as: element,
|
|
265
|
+
id: tabs.getTabId(value),
|
|
266
|
+
type: element === "button" ? "button" : void 0,
|
|
267
|
+
href,
|
|
268
|
+
title,
|
|
269
|
+
"aria-disabled": disabled || void 0,
|
|
270
|
+
"aria-keyshortcuts": isClosable ? "Delete" : void 0,
|
|
271
|
+
"data-tab": true,
|
|
272
|
+
"data-testid": dataTestid,
|
|
273
|
+
...styleProps,
|
|
274
|
+
onClick: handleClick,
|
|
275
|
+
onFocus: handleFocus,
|
|
276
|
+
onMouseDown: handleMouseDown,
|
|
277
|
+
onAuxClick: handleAuxClick,
|
|
278
|
+
onKeyDown: handleKeyDown,
|
|
279
|
+
children: [
|
|
280
|
+
isIconFirst && iconSlot,
|
|
281
|
+
label,
|
|
282
|
+
!isIconFirst && iconSlot
|
|
283
|
+
]
|
|
284
|
+
}),
|
|
285
|
+
secondaryAction != null && /* @__PURE__ */ jsx(SecondaryActionSlot, { children: secondaryAction }),
|
|
286
|
+
isClosable && /* @__PURE__ */ jsx(TabClose, {
|
|
287
|
+
type: "button",
|
|
288
|
+
"aria-hidden": true,
|
|
289
|
+
title: closeLabel,
|
|
290
|
+
tabIndex: -1,
|
|
291
|
+
"data-tab-close": true,
|
|
292
|
+
color,
|
|
293
|
+
isSelected,
|
|
294
|
+
onClick: close,
|
|
295
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
296
|
+
name: "close",
|
|
297
|
+
size: "0.75rem",
|
|
298
|
+
color: "inherit"
|
|
299
|
+
})
|
|
300
|
+
})
|
|
301
|
+
]
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
//#endregion
|
|
305
|
+
export { Tab };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_TabsValueContext = require("../TabsValueContext-D40zGCpE.cjs");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
//#region src/Tabs/TabContext/TabContext.tsx
|
|
6
|
+
/**
|
|
7
|
+
* @description Holds which tab is selected for a `Tabs` and the `TabPanel`s beside it, so
|
|
8
|
+
* the two can sit apart in the tree - the tabs in a header, the panels in the body - and
|
|
9
|
+
* still be linked (`aria-controls`, `aria-labelledby`).
|
|
10
|
+
*/
|
|
11
|
+
function TabContext({ children, value: valueProp, defaultValue = null, onChange }) {
|
|
12
|
+
const [valueState, setValueState] = (0, react.useState)(defaultValue);
|
|
13
|
+
const value = valueProp === void 0 ? valueState : valueProp;
|
|
14
|
+
const baseId = (0, react.useId)();
|
|
15
|
+
const select = (0, react.useCallback)((next) => {
|
|
16
|
+
setValueState(next);
|
|
17
|
+
onChange?.(next);
|
|
18
|
+
}, [onChange]);
|
|
19
|
+
const context = (0, react.useMemo)(() => ({
|
|
20
|
+
value,
|
|
21
|
+
select,
|
|
22
|
+
baseId
|
|
23
|
+
}), [
|
|
24
|
+
value,
|
|
25
|
+
select,
|
|
26
|
+
baseId
|
|
27
|
+
]);
|
|
28
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_TabsValueContext.TabsValueContext.Provider, {
|
|
29
|
+
value: context,
|
|
30
|
+
children
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
exports.TabContext = TabContext;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { t as TabValue } from "../TabsContext-B_XHbjcS.cjs";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/Tabs/TabContext/TabContext.d.ts
|
|
4
|
+
interface TabContextProps {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
/** The selected tab's value - `null` for none. Controlled with `onChange`. */
|
|
7
|
+
value?: TabValue | null;
|
|
8
|
+
/** The selected tab's value at first, when uncontrolled. */
|
|
9
|
+
defaultValue?: TabValue | null;
|
|
10
|
+
/** Fired with a tab's value when it is chosen. */
|
|
11
|
+
onChange?: (value: TabValue) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @description Holds which tab is selected for a `Tabs` and the `TabPanel`s beside it, so
|
|
15
|
+
* the two can sit apart in the tree - the tabs in a header, the panels in the body - and
|
|
16
|
+
* still be linked (`aria-controls`, `aria-labelledby`).
|
|
17
|
+
*/
|
|
18
|
+
declare function TabContext({ children, value: valueProp, defaultValue, onChange }: Readonly<TabContextProps>): import("react").JSX.Element;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { TabContext, TabContextProps };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { t as TabValue } from "../TabsContext-Dn2kqUwr.mjs";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/Tabs/TabContext/TabContext.d.ts
|
|
4
|
+
interface TabContextProps {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
/** The selected tab's value - `null` for none. Controlled with `onChange`. */
|
|
7
|
+
value?: TabValue | null;
|
|
8
|
+
/** The selected tab's value at first, when uncontrolled. */
|
|
9
|
+
defaultValue?: TabValue | null;
|
|
10
|
+
/** Fired with a tab's value when it is chosen. */
|
|
11
|
+
onChange?: (value: TabValue) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @description Holds which tab is selected for a `Tabs` and the `TabPanel`s beside it, so
|
|
15
|
+
* the two can sit apart in the tree - the tabs in a header, the panels in the body - and
|
|
16
|
+
* still be linked (`aria-controls`, `aria-labelledby`).
|
|
17
|
+
*/
|
|
18
|
+
declare function TabContext({ children, value: valueProp, defaultValue, onChange }: Readonly<TabContextProps>): import("react").JSX.Element;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { TabContext, TabContextProps };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { t as TabsValueContext } from "../TabsValueContext-DvL3inf7.mjs";
|
|
2
|
+
import { useCallback, useId, useMemo, useState } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/Tabs/TabContext/TabContext.tsx
|
|
5
|
+
/**
|
|
6
|
+
* @description Holds which tab is selected for a `Tabs` and the `TabPanel`s beside it, so
|
|
7
|
+
* the two can sit apart in the tree - the tabs in a header, the panels in the body - and
|
|
8
|
+
* still be linked (`aria-controls`, `aria-labelledby`).
|
|
9
|
+
*/
|
|
10
|
+
function TabContext({ children, value: valueProp, defaultValue = null, onChange }) {
|
|
11
|
+
const [valueState, setValueState] = useState(defaultValue);
|
|
12
|
+
const value = valueProp === void 0 ? valueState : valueProp;
|
|
13
|
+
const baseId = useId();
|
|
14
|
+
const select = useCallback((next) => {
|
|
15
|
+
setValueState(next);
|
|
16
|
+
onChange?.(next);
|
|
17
|
+
}, [onChange]);
|
|
18
|
+
const context = useMemo(() => ({
|
|
19
|
+
value,
|
|
20
|
+
select,
|
|
21
|
+
baseId
|
|
22
|
+
}), [
|
|
23
|
+
value,
|
|
24
|
+
select,
|
|
25
|
+
baseId
|
|
26
|
+
]);
|
|
27
|
+
return /* @__PURE__ */ jsx(TabsValueContext.Provider, {
|
|
28
|
+
value: context,
|
|
29
|
+
children
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { TabContext };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_TabsValueContext = require("../TabsValueContext-D40zGCpE.cjs");
|
|
3
|
+
const require_Tabs = require("../Tabs-D4tWCq78.cjs");
|
|
4
|
+
let react = require("react");
|
|
5
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
|
+
//#region src/Tabs/TabList/TabList.tsx
|
|
7
|
+
/**
|
|
8
|
+
* @description The `Tabs` of a `TabContext`: it shows the context's value and chooses through it,
|
|
9
|
+
* and links each tab to its `TabPanel` - the tab `aria-controls` its panel, which is named by
|
|
10
|
+
* the tab. Everything else is a `Tabs`'.
|
|
11
|
+
*/
|
|
12
|
+
function TabList({ onChange, ...rest }) {
|
|
13
|
+
const context = require_TabsValueContext.useTabsValue();
|
|
14
|
+
if (!context) throw new Error("A TabList must be inside a TabContext.");
|
|
15
|
+
const { baseId, value, select } = context;
|
|
16
|
+
const link = (0, react.useMemo)(() => ({ baseId }), [baseId]);
|
|
17
|
+
const handleChange = (next) => {
|
|
18
|
+
select(next);
|
|
19
|
+
onChange?.(next);
|
|
20
|
+
};
|
|
21
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Tabs.TabListContext.Provider, {
|
|
22
|
+
value: link,
|
|
23
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Tabs.Tabs, {
|
|
24
|
+
...rest,
|
|
25
|
+
value,
|
|
26
|
+
onChange: handleChange
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.TabList = TabList;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { a as TabsProps } from "../index-WHFhjfgy.cjs";
|
|
2
|
+
//#region src/Tabs/TabList/TabList.d.ts
|
|
3
|
+
type TabListProps = Omit<TabsProps, 'value' | 'defaultValue'>;
|
|
4
|
+
/**
|
|
5
|
+
* @description The `Tabs` of a `TabContext`: it shows the context's value and chooses through it,
|
|
6
|
+
* and links each tab to its `TabPanel` - the tab `aria-controls` its panel, which is named by
|
|
7
|
+
* the tab. Everything else is a `Tabs`'.
|
|
8
|
+
*/
|
|
9
|
+
declare function TabList({ onChange, ...rest }: Readonly<TabListProps>): import("react").JSX.Element;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { TabList, TabListProps };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { a as TabsProps } from "../index-bpnLB_4K.mjs";
|
|
2
|
+
//#region src/Tabs/TabList/TabList.d.ts
|
|
3
|
+
type TabListProps = Omit<TabsProps, 'value' | 'defaultValue'>;
|
|
4
|
+
/**
|
|
5
|
+
* @description The `Tabs` of a `TabContext`: it shows the context's value and chooses through it,
|
|
6
|
+
* and links each tab to its `TabPanel` - the tab `aria-controls` its panel, which is named by
|
|
7
|
+
* the tab. Everything else is a `Tabs`'.
|
|
8
|
+
*/
|
|
9
|
+
declare function TabList({ onChange, ...rest }: Readonly<TabListProps>): import("react").JSX.Element;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { TabList, TabListProps };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { n as useTabsValue } from "../TabsValueContext-DvL3inf7.mjs";
|
|
2
|
+
import { n as TabListContext, t as Tabs } from "../Tabs-BTNOJx5v.mjs";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/Tabs/TabList/TabList.tsx
|
|
6
|
+
/**
|
|
7
|
+
* @description The `Tabs` of a `TabContext`: it shows the context's value and chooses through it,
|
|
8
|
+
* and links each tab to its `TabPanel` - the tab `aria-controls` its panel, which is named by
|
|
9
|
+
* the tab. Everything else is a `Tabs`'.
|
|
10
|
+
*/
|
|
11
|
+
function TabList({ onChange, ...rest }) {
|
|
12
|
+
const context = useTabsValue();
|
|
13
|
+
if (!context) throw new Error("A TabList must be inside a TabContext.");
|
|
14
|
+
const { baseId, value, select } = context;
|
|
15
|
+
const link = useMemo(() => ({ baseId }), [baseId]);
|
|
16
|
+
const handleChange = (next) => {
|
|
17
|
+
select(next);
|
|
18
|
+
onChange?.(next);
|
|
19
|
+
};
|
|
20
|
+
return /* @__PURE__ */ jsx(TabListContext.Provider, {
|
|
21
|
+
value: link,
|
|
22
|
+
children: /* @__PURE__ */ jsx(Tabs, {
|
|
23
|
+
...rest,
|
|
24
|
+
value,
|
|
25
|
+
onChange: handleChange
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { TabList };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_src = require("../src-DU81aGy9.cjs");
|
|
3
|
+
const require_theme = require("../theme-BxXuXRgQ.cjs");
|
|
4
|
+
const require_TabsValueContext = require("../TabsValueContext-D40zGCpE.cjs");
|
|
5
|
+
const require_surfaceSystem = require("../surfaceSystem-BGQBoXv_.cjs");
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
let _soroush_tech_styled_system_should_forward_prop = require("@soroush.tech/styled-system/should-forward-prop");
|
|
8
|
+
//#region src/Tabs/TabPanel/TabPanel.tsx
|
|
9
|
+
const TabPanelRoot = require_src.styled("div", {
|
|
10
|
+
name: "TabPanel",
|
|
11
|
+
label: "TabPanel",
|
|
12
|
+
shouldForwardProp: (0, _soroush_tech_styled_system_should_forward_prop.createShouldForwardProp)([..._soroush_tech_styled_system_should_forward_prop.props]),
|
|
13
|
+
systemProps: [require_src.src_exports.space, require_surfaceSystem.surfaceSystem]
|
|
14
|
+
})({ outline: "none" });
|
|
15
|
+
/**
|
|
16
|
+
* @description The content a tab shows: a `role="tabpanel"` named by its tab, which in
|
|
17
|
+
* turn `aria-controls` it. Shown only while its tab is selected. It sits in a
|
|
18
|
+
* `TabContext` beside the `Tabs`, which links the two.
|
|
19
|
+
*/
|
|
20
|
+
function TabPanel({ value, children, shouldKeepMounted: shouldKeepMountedProp, className, "data-testid": dataTestid, ...spaceProps }) {
|
|
21
|
+
const dp = require_theme.useDefaultProps("TabPanel");
|
|
22
|
+
const shouldKeepMounted = shouldKeepMountedProp ?? dp.shouldKeepMounted ?? false;
|
|
23
|
+
const tabs = require_TabsValueContext.useTabsValue();
|
|
24
|
+
if (!tabs) throw new Error("A TabPanel must be inside a TabContext.");
|
|
25
|
+
const { baseId } = tabs;
|
|
26
|
+
const isSelected = tabs.value === value;
|
|
27
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TabPanelRoot, {
|
|
28
|
+
...spaceProps,
|
|
29
|
+
role: "tabpanel",
|
|
30
|
+
id: require_surfaceSystem.getPanelId(baseId, value),
|
|
31
|
+
"aria-labelledby": require_surfaceSystem.getTabId(baseId, value),
|
|
32
|
+
tabIndex: 0,
|
|
33
|
+
hidden: !isSelected,
|
|
34
|
+
className,
|
|
35
|
+
"data-testid": dataTestid,
|
|
36
|
+
children: isSelected || shouldKeepMounted ? children : null
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
exports.TabPanel = TabPanel;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { W as Theme } from "../index-DJ0f69wh.cjs";
|
|
2
|
+
import { t as TabValue } from "../TabsContext-B_XHbjcS.cjs";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { SpaceProps } from "@soroush.tech/styled-system";
|
|
5
|
+
//#region src/Tabs/TabPanel/TabPanel.d.ts
|
|
6
|
+
interface TabPanelProps extends SpaceProps<Theme> {
|
|
7
|
+
/** The value of the tab this panel belongs to. */
|
|
8
|
+
value: TabValue;
|
|
9
|
+
/** The panel's content. */
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
/** Keep the content mounted while the panel is hidden. Default: `false`. */
|
|
12
|
+
shouldKeepMounted?: boolean;
|
|
13
|
+
/** The panel's ground - resolves against `theme.background`. Match its tab's `selectedBg`. */
|
|
14
|
+
bg?: keyof Theme['background'];
|
|
15
|
+
/** The panel's corner radius - resolves against `theme.radii`. */
|
|
16
|
+
borderRadius?: keyof Theme['radii'];
|
|
17
|
+
className?: string;
|
|
18
|
+
'data-testid'?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @description The content a tab shows: a `role="tabpanel"` named by its tab, which in
|
|
22
|
+
* turn `aria-controls` it. Shown only while its tab is selected. It sits in a
|
|
23
|
+
* `TabContext` beside the `Tabs`, which links the two.
|
|
24
|
+
*/
|
|
25
|
+
declare function TabPanel({ value, children, shouldKeepMounted: shouldKeepMountedProp, className, 'data-testid': dataTestid, ...spaceProps }: Readonly<TabPanelProps>): import("react").JSX.Element;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { TabPanel, TabPanelProps };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { W as Theme } from "../index-CJhK7JND.mjs";
|
|
2
|
+
import { t as TabValue } from "../TabsContext-Dn2kqUwr.mjs";
|
|
3
|
+
import { SpaceProps } from "@soroush.tech/styled-system";
|
|
4
|
+
import { ReactNode } from "react";
|
|
5
|
+
//#region src/Tabs/TabPanel/TabPanel.d.ts
|
|
6
|
+
interface TabPanelProps extends SpaceProps<Theme> {
|
|
7
|
+
/** The value of the tab this panel belongs to. */
|
|
8
|
+
value: TabValue;
|
|
9
|
+
/** The panel's content. */
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
/** Keep the content mounted while the panel is hidden. Default: `false`. */
|
|
12
|
+
shouldKeepMounted?: boolean;
|
|
13
|
+
/** The panel's ground - resolves against `theme.background`. Match its tab's `selectedBg`. */
|
|
14
|
+
bg?: keyof Theme['background'];
|
|
15
|
+
/** The panel's corner radius - resolves against `theme.radii`. */
|
|
16
|
+
borderRadius?: keyof Theme['radii'];
|
|
17
|
+
className?: string;
|
|
18
|
+
'data-testid'?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @description The content a tab shows: a `role="tabpanel"` named by its tab, which in
|
|
22
|
+
* turn `aria-controls` it. Shown only while its tab is selected. It sits in a
|
|
23
|
+
* `TabContext` beside the `Tabs`, which links the two.
|
|
24
|
+
*/
|
|
25
|
+
declare function TabPanel({ value, children, shouldKeepMounted: shouldKeepMountedProp, className, 'data-testid': dataTestid, ...spaceProps }: Readonly<TabPanelProps>): import("react").JSX.Element;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { TabPanel, TabPanelProps };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { a as src_exports, i as props, o as styled, t as createShouldForwardProp } from "../src-DLGYOJMh.mjs";
|
|
2
|
+
import { n as useDefaultProps } from "../theme-Z9_QludW.mjs";
|
|
3
|
+
import { n as useTabsValue } from "../TabsValueContext-DvL3inf7.mjs";
|
|
4
|
+
import { n as getPanelId, r as getTabId, t as surfaceSystem } from "../surfaceSystem-D8TbmKy3.mjs";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/Tabs/TabPanel/TabPanel.tsx
|
|
7
|
+
const TabPanelRoot = styled("div", {
|
|
8
|
+
name: "TabPanel",
|
|
9
|
+
label: "TabPanel",
|
|
10
|
+
shouldForwardProp: createShouldForwardProp([...props]),
|
|
11
|
+
systemProps: [src_exports.space, surfaceSystem]
|
|
12
|
+
})({ outline: "none" });
|
|
13
|
+
/**
|
|
14
|
+
* @description The content a tab shows: a `role="tabpanel"` named by its tab, which in
|
|
15
|
+
* turn `aria-controls` it. Shown only while its tab is selected. It sits in a
|
|
16
|
+
* `TabContext` beside the `Tabs`, which links the two.
|
|
17
|
+
*/
|
|
18
|
+
function TabPanel({ value, children, shouldKeepMounted: shouldKeepMountedProp, className, "data-testid": dataTestid, ...spaceProps }) {
|
|
19
|
+
const dp = useDefaultProps("TabPanel");
|
|
20
|
+
const shouldKeepMounted = shouldKeepMountedProp ?? dp.shouldKeepMounted ?? false;
|
|
21
|
+
const tabs = useTabsValue();
|
|
22
|
+
if (!tabs) throw new Error("A TabPanel must be inside a TabContext.");
|
|
23
|
+
const { baseId } = tabs;
|
|
24
|
+
const isSelected = tabs.value === value;
|
|
25
|
+
return /* @__PURE__ */ jsx(TabPanelRoot, {
|
|
26
|
+
...spaceProps,
|
|
27
|
+
role: "tabpanel",
|
|
28
|
+
id: getPanelId(baseId, value),
|
|
29
|
+
"aria-labelledby": getTabId(baseId, value),
|
|
30
|
+
tabIndex: 0,
|
|
31
|
+
hidden: !isSelected,
|
|
32
|
+
className,
|
|
33
|
+
"data-testid": dataTestid,
|
|
34
|
+
children: isSelected || shouldKeepMounted ? children : null
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { TabPanel };
|