@soroush.tech/design-system 2.0.0-rc.1 → 2.0.0-rc.2
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 +17 -1
- 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 +1 -1
- package/dist/FormControl.d.cts +1 -2
- package/dist/FormControl.d.mts +1 -2
- package/dist/FormControl.mjs +1 -1
- package/dist/FormHelperText.d.cts +1 -1
- package/dist/FormHelperText.d.mts +1 -1
- package/dist/FormLabel.d.cts +1 -1
- package/dist/FormLabel.d.mts +1 -1
- package/dist/Grid.d.cts +1 -3
- package/dist/Grid.d.mts +1 -3
- package/dist/{Icon-CI6q2Eyi.cjs → Icon-Cvuhp9ek.cjs} +12 -2
- package/dist/{Icon-CH3asUJu.mjs → Icon-DlheCTJb.mjs} +12 -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/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-BkKPTOfh.cjs +172 -0
- package/dist/Menu-tECbAEFj.mjs +167 -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-BR7ingQx.mjs +654 -0
- package/dist/MenuItem-CfdN4axw.cjs +684 -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-Dml16k0X.d.mts +21 -0
- package/dist/MenuListContext-vujGcRk9.d.cts +21 -0
- package/dist/Modal.d.cts +1 -1
- package/dist/Modal.d.mts +1 -1
- package/dist/NativeSelect.cjs +2 -2
- package/dist/NativeSelect.d.cts +2 -3
- package/dist/NativeSelect.d.mts +2 -3
- package/dist/NativeSelect.mjs +2 -2
- 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/Select.cjs +3 -3
- package/dist/Select.d.cts +2 -3
- package/dist/Select.d.mts +2 -3
- package/dist/Select.mjs +3 -3
- 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 +1 -1
- package/dist/Skeleton.d.cts +1 -2
- package/dist/Skeleton.d.mts +1 -2
- package/dist/Switch.cjs +1 -1
- package/dist/Switch.d.cts +1 -2
- package/dist/Switch.d.mts +1 -2
- package/dist/Switch.mjs +1 -1
- 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/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-6PgGpUzM.d.mts} +1 -1
- package/dist/{TableContext-BiRiYkVZ.d.mts → TableContext-CBGk-Lh8.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-D_wkX-Jb.cjs +645 -0
- package/dist/Tabs-YfCUbkQV.mjs +633 -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-C2agsLBN.d.cts +6 -0
- package/dist/TabsContext-DqyxdmGW.d.mts +6 -0
- package/dist/TabsValueContext-D40zGCpE.cjs +19 -0
- package/dist/TabsValueContext-DvL3inf7.mjs +8 -0
- package/dist/TextInput.cjs +1 -1
- package/dist/TextInput.d.cts +1 -2
- package/dist/TextInput.d.mts +1 -2
- package/dist/TextInput.mjs +1 -1
- 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/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 +4110 -0
- package/dist/catalog.d.cts +90 -0
- package/dist/catalog.d.mts +90 -0
- package/dist/catalog.mjs +4109 -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-B3LIhqHR.d.cts +98 -0
- package/dist/{index-DbEnSf2m.d.cts → index-B8DNxyEw.d.mts} +3 -4
- package/dist/{index-CxUsrlg1.d.cts → index-BCnKYNlZ.d.cts} +1 -2
- package/dist/{index-BUoVTCqX.d.mts → index-BFruxTHv.d.cts} +2 -3
- package/dist/{index-BSqet8aO.d.cts → index-BSA6SKao.d.mts} +2 -3
- package/dist/{index-CrN4MSUF.d.cts → index-BVPrG1L0.d.mts} +1 -1
- package/dist/{index-Celm-8iN.d.cts → index-BbgFYfX_.d.mts} +3 -4
- package/dist/{index-B78VkB0-.d.cts → index-Bhdn4KTy.d.cts} +2 -3
- package/dist/{index-Chg6pSrr.d.mts → index-BiVvxOvj.d.cts} +3 -4
- package/dist/index-BjPX49XA.d.mts +34 -0
- package/dist/{index-BB-dLv5V.d.mts → index-BjfPEP_5.d.cts} +3 -4
- package/dist/{index-Bid71KeF.d.cts → index-BlLH6rlE.d.cts} +2 -2
- package/dist/{index-Ctqajtac.d.cts → index-BqpS_Huq.d.mts} +12 -4
- package/dist/{index-BhibLnZ0.d.cts → index-Bxd9NOWb.d.mts} +2 -3
- package/dist/index-C3KrFPCj.d.mts +35 -0
- package/dist/{themes-RX2UX5gD.d.mts → index-CVNJEUwJ.d.mts} +217 -8
- package/dist/index-CWnbCxgw.d.cts +72 -0
- package/dist/index-Cj5Rhh_9.d.mts +72 -0
- package/dist/index-CoEqjFYn.d.mts +98 -0
- package/dist/{index-S-ClM6WM.d.mts → index-CrIxI8Na.d.mts} +2 -2
- package/dist/index-DBteSahY.d.cts +1 -0
- package/dist/index-DCmH5f9I.d.cts +72 -0
- package/dist/{index-VOsBSWEu.d.mts → index-DDJuUfL5.d.cts} +1 -1
- package/dist/{index-DdqdSOct.d.cts → index-DIC7HKpP.d.mts} +2 -3
- package/dist/{index-BfZuh9c2.d.mts → index-DJCpnTH3.d.mts} +2 -3
- package/dist/index-DQcnJ5H4.d.cts +35 -0
- package/dist/{index-DNwF3DUX.d.cts → index-DXhMkjQ6.d.cts} +2 -3
- package/dist/index-DckSub2J.d.mts +72 -0
- package/dist/{index-nc4Sxiy9.d.mts → index-DeDxYlSQ.d.mts} +2 -3
- package/dist/{themes-Kbk9h5cN.d.cts → index-DmJ7yWWi.d.cts} +214 -5
- package/dist/{index-Wnv6jCR3.d.mts → index-DqjXDutI.d.mts} +1 -2
- package/dist/{index-GpnmW6vu.d.mts → index-DrVYWt-X.d.mts} +1 -2
- package/dist/{index-Belxmt1X.d.cts → index-DuVNRXP4.d.cts} +1 -2
- package/dist/{index-smqjMLAZ.d.mts → index-IdMqR82e.d.cts} +2 -3
- package/dist/{index-DXvQ-JVZ.d.mts → index-XxydXX8l.d.cts} +2 -3
- package/dist/index-_G1osn09.d.mts +1 -0
- package/dist/index-gnh-Oe0n.d.cts +34 -0
- package/dist/{index-DO9J-Fla.d.mts → index-qlfNErNd.d.cts} +12 -4
- package/dist/index.d.cts +1 -2
- package/dist/index.d.mts +1 -2
- 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/{useTablePagination-COTiNH_8.d.mts → useTablePagination-C5VKtqDp.d.cts} +1 -1
- package/dist/{useTablePagination-WFkaUZu8.d.cts → useTablePagination-C6LSlt3w.d.mts} +1 -1
- package/package.json +43 -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,223 @@
|
|
|
1
|
+
const require_src = require("./src-DU81aGy9.cjs");
|
|
2
|
+
const require_themeDefault = require("./themeDefault-Cebi08Cv.cjs");
|
|
3
|
+
const require_theme = require("./theme-BxXuXRgQ.cjs");
|
|
4
|
+
let react = require("react");
|
|
5
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
|
+
let _soroush_tech_styled_system_should_forward_prop = require("@soroush.tech/styled-system/should-forward-prop");
|
|
7
|
+
//#region src/Menu/MenuActivationContext.ts
|
|
8
|
+
/**
|
|
9
|
+
* Set by a `Menu` around its lists: told when any row anywhere in the menu is chosen, with
|
|
10
|
+
* or without a `value`, so the whole menu can close. Internal - not exported from the
|
|
11
|
+
* subpath.
|
|
12
|
+
*/
|
|
13
|
+
const MenuActivationContext = (0, react.createContext)(null);
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/Menu/MenuListContext.ts
|
|
16
|
+
/**
|
|
17
|
+
* Present inside a `MenuList`. A `MenuItem` that finds it renders as a menu row
|
|
18
|
+
* (`menuitem`); without it, the row is `Select`'s `option`.
|
|
19
|
+
*/
|
|
20
|
+
const MenuListContext = (0, react.createContext)(null);
|
|
21
|
+
const useMenuListContext = () => (0, react.useContext)(MenuListContext);
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/Menu/MenuList/utils/getOwnRows.ts
|
|
24
|
+
const ROW_SELECTOR = "[role=\"menuitem\"], [role=\"menuitemradio\"], [role=\"menuitemcheckbox\"]";
|
|
25
|
+
/**
|
|
26
|
+
* The rows that belong to `list` itself, in document order. A nested submenu is a
|
|
27
|
+
* `role="menu"` of its own inside the list, so a row counts only when its nearest
|
|
28
|
+
* `role="menu"` is `list` - no per-list index state is kept anywhere.
|
|
29
|
+
*/
|
|
30
|
+
function getOwnRows(list) {
|
|
31
|
+
return Array.from(list.querySelectorAll(ROW_SELECTOR)).filter((row) => row.closest("[role=\"menu\"]") === list);
|
|
32
|
+
}
|
|
33
|
+
/** Whether a row can take focus and be chosen. */
|
|
34
|
+
function isRowEnabled(row) {
|
|
35
|
+
return row.getAttribute("aria-disabled") !== "true";
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/Menu/MenuList/utils/getNextRow.ts
|
|
39
|
+
/**
|
|
40
|
+
* The enabled row a key moves to from `current` (which may be absent from `rows`, as when
|
|
41
|
+
* focus is still on the list itself). Disabled rows are skipped; `shouldWrap` carries
|
|
42
|
+
* `next` past the last row to the first and `previous` before the first to the last.
|
|
43
|
+
*/
|
|
44
|
+
function getNextRow(rows, current, step, shouldWrap) {
|
|
45
|
+
const enabled = rows.filter(isRowEnabled);
|
|
46
|
+
if (step === "first") return enabled[0];
|
|
47
|
+
if (step === "last") return enabled.at(-1);
|
|
48
|
+
const index = enabled.indexOf(current);
|
|
49
|
+
if (index === -1) return step === "next" ? enabled[0] : enabled.at(-1);
|
|
50
|
+
const target = index + (step === "next" ? 1 : -1);
|
|
51
|
+
if (target >= 0 && target < enabled.length) return enabled[target];
|
|
52
|
+
if (!shouldWrap) return void 0;
|
|
53
|
+
return target < 0 ? enabled.at(-1) : enabled[0];
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/Menu/MenuList/utils/findRowByText.ts
|
|
57
|
+
/** A row's label text, without its icon, shortcut or note. */
|
|
58
|
+
function getRowText(row) {
|
|
59
|
+
return (row.querySelector("[data-menu-label]") ?? row).textContent.trim().toLowerCase();
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The row type-ahead moves to. One key typed again and again (`r`, `r`, `r`) cycles
|
|
63
|
+
* through the rows starting with it; distinct keys typed together (`re`) build a prefix,
|
|
64
|
+
* matched from the current row onward so typing on stays where it is while it matches.
|
|
65
|
+
*/
|
|
66
|
+
function findRowByText(rows, current, typed) {
|
|
67
|
+
const enabled = rows.filter(isRowEnabled);
|
|
68
|
+
const query = typed.toLowerCase();
|
|
69
|
+
const isRepeating = [...query].every((key) => key === query[0]);
|
|
70
|
+
const start = enabled.indexOf(current);
|
|
71
|
+
const from = isRepeating ? start + 1 : Math.max(start, 0);
|
|
72
|
+
const ordered = [...enabled.slice(from), ...enabled.slice(0, from)];
|
|
73
|
+
const prefix = isRepeating ? query[0] : query;
|
|
74
|
+
return ordered.find((row) => getRowText(row).startsWith(prefix));
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/Menu/MenuList/MenuList.tsx
|
|
78
|
+
const STEP_BY_KEY = {
|
|
79
|
+
ArrowDown: "next",
|
|
80
|
+
ArrowUp: "previous",
|
|
81
|
+
Home: "first",
|
|
82
|
+
End: "last"
|
|
83
|
+
};
|
|
84
|
+
const TYPEAHEAD_TIMEOUT = 500;
|
|
85
|
+
const shouldForwardProp = (0, _soroush_tech_styled_system_should_forward_prop.createShouldForwardProp)([..._soroush_tech_styled_system_should_forward_prop.props]);
|
|
86
|
+
const layoutWithoutSize = (styleProps) => (0, require_src.src_exports.layout)({
|
|
87
|
+
...styleProps,
|
|
88
|
+
size: void 0
|
|
89
|
+
});
|
|
90
|
+
const MenuListRoot = require_src.styled("ul", {
|
|
91
|
+
name: "MenuList",
|
|
92
|
+
label: "MenuList",
|
|
93
|
+
shouldForwardProp,
|
|
94
|
+
systemProps: [require_src.src_exports.space, layoutWithoutSize]
|
|
95
|
+
})(({ theme }) => ({
|
|
96
|
+
listStyle: "none",
|
|
97
|
+
margin: 0,
|
|
98
|
+
paddingLeft: 0,
|
|
99
|
+
paddingRight: 0,
|
|
100
|
+
paddingTop: theme.space[.5],
|
|
101
|
+
paddingBottom: theme.space[.5],
|
|
102
|
+
outline: "none",
|
|
103
|
+
"&:focus-visible": {
|
|
104
|
+
outline: `${theme.borderWidths.base} solid ${theme.palette[require_themeDefault.themeDefault(theme, "color", "primary")].main}`,
|
|
105
|
+
outlineOffset: `-${theme.borderWidths.base}`
|
|
106
|
+
}
|
|
107
|
+
}));
|
|
108
|
+
const isPrintableKey = (event) => event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey;
|
|
109
|
+
/**
|
|
110
|
+
* @description A `role="menu"` list that owns the keyboard: the arrow keys, Home and End
|
|
111
|
+
* move focus between its own rows, skipping disabled ones; typing jumps to a row by its
|
|
112
|
+
* label. Rows are found in the DOM by their nearest `role="menu"`, so a nested submenu's
|
|
113
|
+
* rows are never this list's. Renders in place - `Menu` floats one next to a trigger.
|
|
114
|
+
*/
|
|
115
|
+
function MenuList({ children, onSelect, shouldWrap: shouldWrapProp, shouldAutoFocus = false, color, textColor, size, dense, onKeyDown, ...rest }) {
|
|
116
|
+
const listRef = (0, react.useRef)(null);
|
|
117
|
+
const typed = (0, react.useRef)({
|
|
118
|
+
keys: "",
|
|
119
|
+
time: 0
|
|
120
|
+
});
|
|
121
|
+
const onMenuActivate = (0, react.useContext)(MenuActivationContext);
|
|
122
|
+
const parent = useMenuListContext();
|
|
123
|
+
const dp = require_theme.useDefaultProps("MenuList");
|
|
124
|
+
const shouldWrap = shouldWrapProp ?? dp.shouldWrap ?? true;
|
|
125
|
+
const rowColor = color ?? parent?.color ?? dp.color;
|
|
126
|
+
const rowTextColor = textColor ?? parent?.textColor ?? dp.textColor;
|
|
127
|
+
const rowSize = size ?? parent?.size ?? dp.size;
|
|
128
|
+
const rowDense = dense ?? parent?.dense ?? dp.dense;
|
|
129
|
+
(0, react.useEffect)(() => {
|
|
130
|
+
const list = listRef.current;
|
|
131
|
+
if (!shouldAutoFocus || !list) return;
|
|
132
|
+
const rows = getOwnRows(list).filter(isRowEnabled);
|
|
133
|
+
(rows.find((row) => row.getAttribute("aria-checked") === "true") ?? rows[0] ?? list).focus();
|
|
134
|
+
}, [shouldAutoFocus]);
|
|
135
|
+
const context = (0, react.useMemo)(() => ({
|
|
136
|
+
onActivate: (value, event) => {
|
|
137
|
+
if (value !== void 0) onSelect?.(value);
|
|
138
|
+
if (parent) parent.onActivate(value, event);
|
|
139
|
+
else onMenuActivate?.(value, event);
|
|
140
|
+
},
|
|
141
|
+
color: rowColor,
|
|
142
|
+
textColor: rowTextColor,
|
|
143
|
+
size: rowSize,
|
|
144
|
+
dense: rowDense
|
|
145
|
+
}), [
|
|
146
|
+
onSelect,
|
|
147
|
+
onMenuActivate,
|
|
148
|
+
parent,
|
|
149
|
+
rowColor,
|
|
150
|
+
rowTextColor,
|
|
151
|
+
rowSize,
|
|
152
|
+
rowDense
|
|
153
|
+
]);
|
|
154
|
+
const handleKeyDown = (event) => {
|
|
155
|
+
const list = event.currentTarget;
|
|
156
|
+
if (event.target.closest("[role=\"menu\"]") !== list) return;
|
|
157
|
+
const rows = getOwnRows(list);
|
|
158
|
+
const current = list.ownerDocument.activeElement;
|
|
159
|
+
const step = STEP_BY_KEY[event.key];
|
|
160
|
+
let target;
|
|
161
|
+
if (step) target = getNextRow(rows, current, step, shouldWrap);
|
|
162
|
+
else if (isPrintableKey(event)) {
|
|
163
|
+
const now = Date.now();
|
|
164
|
+
const isFresh = now - typed.current.time > TYPEAHEAD_TIMEOUT;
|
|
165
|
+
typed.current = {
|
|
166
|
+
keys: (isFresh ? "" : typed.current.keys) + event.key,
|
|
167
|
+
time: now
|
|
168
|
+
};
|
|
169
|
+
target = findRowByText(rows, current, typed.current.keys);
|
|
170
|
+
}
|
|
171
|
+
if (step || target) event.preventDefault();
|
|
172
|
+
target?.focus();
|
|
173
|
+
onKeyDown?.(event);
|
|
174
|
+
};
|
|
175
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MenuListContext.Provider, {
|
|
176
|
+
value: context,
|
|
177
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MenuListRoot, {
|
|
178
|
+
...rest,
|
|
179
|
+
ref: listRef,
|
|
180
|
+
role: "menu",
|
|
181
|
+
tabIndex: -1,
|
|
182
|
+
onKeyDown: handleKeyDown,
|
|
183
|
+
children
|
|
184
|
+
})
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
//#endregion
|
|
188
|
+
Object.defineProperty(exports, "MenuActivationContext", {
|
|
189
|
+
enumerable: true,
|
|
190
|
+
get: function() {
|
|
191
|
+
return MenuActivationContext;
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
Object.defineProperty(exports, "MenuList", {
|
|
195
|
+
enumerable: true,
|
|
196
|
+
get: function() {
|
|
197
|
+
return MenuList;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
Object.defineProperty(exports, "MenuListContext", {
|
|
201
|
+
enumerable: true,
|
|
202
|
+
get: function() {
|
|
203
|
+
return MenuListContext;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
Object.defineProperty(exports, "getNextRow", {
|
|
207
|
+
enumerable: true,
|
|
208
|
+
get: function() {
|
|
209
|
+
return getNextRow;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
Object.defineProperty(exports, "getOwnRows", {
|
|
213
|
+
enumerable: true,
|
|
214
|
+
get: function() {
|
|
215
|
+
return getOwnRows;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
Object.defineProperty(exports, "useMenuListContext", {
|
|
219
|
+
enumerable: true,
|
|
220
|
+
get: function() {
|
|
221
|
+
return useMenuListContext;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { V as Theme } from "./index-CVNJEUwJ.mjs";
|
|
2
|
+
import "./index-BVPrG1L0.mjs";
|
|
3
|
+
import { SyntheticEvent } from "react";
|
|
4
|
+
//#region src/Menu/MenuListContext.d.ts
|
|
5
|
+
type MenuItemValue = string | number;
|
|
6
|
+
interface MenuListContextValue {
|
|
7
|
+
/** Fired when a row is chosen, with its `value` when it has one. */
|
|
8
|
+
onActivate: (value: MenuItemValue | undefined, event: SyntheticEvent) => void;
|
|
9
|
+
color?: keyof Theme['palette'];
|
|
10
|
+
textColor?: keyof Theme['text'];
|
|
11
|
+
size?: keyof Theme['sizes'];
|
|
12
|
+
dense?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Present inside a `MenuList`. A `MenuItem` that finds it renders as a menu row
|
|
16
|
+
* (`menuitem`); without it, the row is `Select`'s `option`.
|
|
17
|
+
*/
|
|
18
|
+
declare const MenuListContext: import("react").Context<MenuListContextValue | null>;
|
|
19
|
+
declare const useMenuListContext: () => MenuListContextValue | null;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { useMenuListContext as i, MenuListContext as n, MenuListContextValue as r, MenuItemValue as t };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { V as Theme } from "./index-DmJ7yWWi.cjs";
|
|
2
|
+
import "./index-DDJuUfL5.cjs";
|
|
3
|
+
import { SyntheticEvent } from "react";
|
|
4
|
+
//#region src/Menu/MenuListContext.d.ts
|
|
5
|
+
type MenuItemValue = string | number;
|
|
6
|
+
interface MenuListContextValue {
|
|
7
|
+
/** Fired when a row is chosen, with its `value` when it has one. */
|
|
8
|
+
onActivate: (value: MenuItemValue | undefined, event: SyntheticEvent) => void;
|
|
9
|
+
color?: keyof Theme['palette'];
|
|
10
|
+
textColor?: keyof Theme['text'];
|
|
11
|
+
size?: keyof Theme['sizes'];
|
|
12
|
+
dense?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Present inside a `MenuList`. A `MenuItem` that finds it renders as a menu row
|
|
16
|
+
* (`menuitem`); without it, the row is `Select`'s `option`.
|
|
17
|
+
*/
|
|
18
|
+
declare const MenuListContext: import("react").Context<MenuListContextValue | null>;
|
|
19
|
+
declare const useMenuListContext: () => MenuListContextValue | null;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { useMenuListContext as i, MenuListContext as n, MenuListContextValue as r, MenuItemValue as t };
|
package/dist/Modal.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as hideFromAria, c as ModalScroll, d as UseModalReturnValue, f as useModal, i as exposeToAria, l as ModalCloseReason, n as ManagedModalProps, o as Modal, r as ModalManager, s as ModalProps, t as ManagedModal, u as UseModalParameters } from "./index-
|
|
1
|
+
import { a as hideFromAria, c as ModalScroll, d as UseModalReturnValue, f as useModal, i as exposeToAria, l as ModalCloseReason, n as ManagedModalProps, o as Modal, r as ModalManager, s as ModalProps, t as ManagedModal, u as UseModalParameters } from "./index-DuVNRXP4.cjs";
|
|
2
2
|
export { ManagedModal, ManagedModalProps, Modal, ModalCloseReason, ModalManager, ModalProps, ModalScroll, UseModalParameters, UseModalReturnValue, exposeToAria, hideFromAria, useModal };
|
package/dist/Modal.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as hideFromAria, c as ModalScroll, d as UseModalReturnValue, f as useModal, i as exposeToAria, l as ModalCloseReason, n as ManagedModalProps, o as Modal, r as ModalManager, s as ModalProps, t as ManagedModal, u as UseModalParameters } from "./index-
|
|
1
|
+
import { a as hideFromAria, c as ModalScroll, d as UseModalReturnValue, f as useModal, i as exposeToAria, l as ModalCloseReason, n as ManagedModalProps, o as Modal, r as ModalManager, s as ModalProps, t as ManagedModal, u as UseModalParameters } from "./index-DqjXDutI.mjs";
|
|
2
2
|
export { ManagedModal, ManagedModalProps, Modal, ModalCloseReason, ModalManager, ModalProps, ModalScroll, UseModalParameters, UseModalReturnValue, exposeToAria, hideFromAria, useModal };
|
package/dist/NativeSelect.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_src = require("./src-DU81aGy9.cjs");
|
|
3
3
|
const require_themeDefault = require("./themeDefault-Cebi08Cv.cjs");
|
|
4
|
-
const require_theme = require("./theme-
|
|
5
|
-
const require_Icon = require("./Icon-
|
|
4
|
+
const require_theme = require("./theme-BxXuXRgQ.cjs");
|
|
5
|
+
const require_Icon = require("./Icon-Cvuhp9ek.cjs");
|
|
6
6
|
const require_FormControl = require("./FormControl.cjs");
|
|
7
7
|
const require_inputVariantStyles = require("./inputVariantStyles-BBkkYQtE.cjs");
|
|
8
8
|
require("react");
|
package/dist/NativeSelect.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./index-
|
|
3
|
-
import { n as IconProps, r as IconName } from "./index-Ctqajtac.cjs";
|
|
1
|
+
import { V as Theme } from "./index-DmJ7yWWi.cjs";
|
|
2
|
+
import { n as IconProps, r as IconName } from "./index-qlfNErNd.cjs";
|
|
4
3
|
import { SelectHTMLAttributes } from "react";
|
|
5
4
|
import { LayoutProps, SpaceProps } from "@soroush.tech/styled-system";
|
|
6
5
|
//#region src/NativeSelect/NativeSelect.d.ts
|
package/dist/NativeSelect.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./index-
|
|
3
|
-
import { n as IconProps, r as IconName } from "./index-DO9J-Fla.mjs";
|
|
1
|
+
import { V as Theme } from "./index-CVNJEUwJ.mjs";
|
|
2
|
+
import { n as IconProps, r as IconName } from "./index-BqpS_Huq.mjs";
|
|
4
3
|
import { LayoutProps, SpaceProps } from "@soroush.tech/styled-system";
|
|
5
4
|
import { SelectHTMLAttributes } from "react";
|
|
6
5
|
//#region src/NativeSelect/NativeSelect.d.ts
|
package/dist/NativeSelect.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as src_exports, i as props, o as styled, t as createShouldForwardProp } from "./src-DLGYOJMh.mjs";
|
|
2
2
|
import { t as themeDefault } from "./themeDefault-Z3KmyIbm.mjs";
|
|
3
|
-
import { r as useTheme } from "./theme-
|
|
4
|
-
import { t as Icon } from "./Icon-
|
|
3
|
+
import { r as useTheme } from "./theme-Z9_QludW.mjs";
|
|
4
|
+
import { t as Icon } from "./Icon-DlheCTJb.mjs";
|
|
5
5
|
import { useFormControl } from "./FormControl.mjs";
|
|
6
6
|
import { t as inputVariantStyles } from "./inputVariantStyles-CcqpGfuP.mjs";
|
|
7
7
|
import "react";
|
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_src = require("../src-DU81aGy9.cjs");
|
|
3
3
|
const require_themeDefault = require("../themeDefault-Cebi08Cv.cjs");
|
|
4
4
|
const require_utils = require("../utils.cjs");
|
|
5
|
-
const require_Icon = require("../Icon-
|
|
5
|
+
const require_Icon = require("../Icon-Cvuhp9ek.cjs");
|
|
6
6
|
require("react");
|
|
7
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
8
|
let _soroush_tech_styled_system_should_forward_prop = require("@soroush.tech/styled-system/should-forward-prop");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as PaginationItemSize, i as PaginationItemShape, n as PaginationItemColor, o as PaginationItemVariant, r as PaginationItemProps, t as PaginationItem } from "../index-
|
|
1
|
+
import { a as PaginationItemSize, i as PaginationItemShape, n as PaginationItemColor, o as PaginationItemVariant, r as PaginationItemProps, t as PaginationItem } from "../index-BFruxTHv.cjs";
|
|
2
2
|
export { PaginationItem, PaginationItemColor, PaginationItemProps, PaginationItemShape, PaginationItemSize, PaginationItemVariant };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as PaginationItemSize, i as PaginationItemShape, n as PaginationItemColor, o as PaginationItemVariant, r as PaginationItemProps, t as PaginationItem } from "../index-
|
|
1
|
+
import { a as PaginationItemSize, i as PaginationItemShape, n as PaginationItemColor, o as PaginationItemVariant, r as PaginationItemProps, t as PaginationItem } from "../index-DIC7HKpP.mjs";
|
|
2
2
|
export { PaginationItem, PaginationItemColor, PaginationItemProps, PaginationItemShape, PaginationItemSize, PaginationItemVariant };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as src_exports, i as props, o as styled, t as createShouldForwardProp } from "../src-DLGYOJMh.mjs";
|
|
2
2
|
import { t as themeDefault } from "../themeDefault-Z3KmyIbm.mjs";
|
|
3
3
|
import { alpha } from "../utils.mjs";
|
|
4
|
-
import { t as Icon } from "../Icon-
|
|
4
|
+
import { t as Icon } from "../Icon-DlheCTJb.mjs";
|
|
5
5
|
import "react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
//#region src/Pagination/PaginationItem/PaginationItem.tsx
|
package/dist/Pagination.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as PaginationItemSize, c as UsePaginationItem, i as PaginationItemShape, l as UsePaginationProps, n as PaginationItemColor, o as PaginationItemVariant, r as PaginationItemProps, s as PaginationItemType, t as PaginationItem, u as usePagination } from "./index-
|
|
2
|
-
import { a as PaginationSize, i as PaginationShape, n as PaginationColor, o as PaginationVariant, r as PaginationProps, t as Pagination } from "./index-
|
|
1
|
+
import { a as PaginationItemSize, c as UsePaginationItem, i as PaginationItemShape, l as UsePaginationProps, n as PaginationItemColor, o as PaginationItemVariant, r as PaginationItemProps, s as PaginationItemType, t as PaginationItem, u as usePagination } from "./index-BFruxTHv.cjs";
|
|
2
|
+
import { a as PaginationSize, i as PaginationShape, n as PaginationColor, o as PaginationVariant, r as PaginationProps, t as Pagination } from "./index-BiVvxOvj.cjs";
|
|
3
3
|
export { Pagination, PaginationColor, PaginationItem, PaginationItemColor, PaginationItemProps, PaginationItemShape, PaginationItemSize, PaginationItemType, PaginationItemVariant, PaginationProps, PaginationShape, PaginationSize, PaginationVariant, UsePaginationItem, UsePaginationProps, usePagination };
|
package/dist/Pagination.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as PaginationItemSize, c as UsePaginationItem, i as PaginationItemShape, l as UsePaginationProps, n as PaginationItemColor, o as PaginationItemVariant, r as PaginationItemProps, s as PaginationItemType, t as PaginationItem, u as usePagination } from "./index-
|
|
2
|
-
import { a as PaginationSize, i as PaginationShape, n as PaginationColor, o as PaginationVariant, r as PaginationProps, t as Pagination } from "./index-
|
|
1
|
+
import { a as PaginationItemSize, c as UsePaginationItem, i as PaginationItemShape, l as UsePaginationProps, n as PaginationItemColor, o as PaginationItemVariant, r as PaginationItemProps, s as PaginationItemType, t as PaginationItem, u as usePagination } from "./index-DIC7HKpP.mjs";
|
|
2
|
+
import { a as PaginationSize, i as PaginationShape, n as PaginationColor, o as PaginationVariant, r as PaginationProps, t as Pagination } from "./index-BbgFYfX_.mjs";
|
|
3
3
|
export { Pagination, PaginationColor, PaginationItem, PaginationItemColor, PaginationItemProps, PaginationItemShape, PaginationItemSize, PaginationItemType, PaginationItemVariant, PaginationProps, PaginationShape, PaginationSize, PaginationVariant, UsePaginationItem, UsePaginationProps, usePagination };
|
package/dist/Paper.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_src = require("./src-DU81aGy9.cjs");
|
|
3
3
|
const require_Flex = require("./Flex.cjs");
|
|
4
4
|
const require_themeDefault = require("./themeDefault-Cebi08Cv.cjs");
|
|
5
|
-
const require_theme = require("./theme-
|
|
5
|
+
const require_theme = require("./theme-BxXuXRgQ.cjs");
|
|
6
6
|
require("react");
|
|
7
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
8
|
//#region src/Paper/Paper.tsx
|
package/dist/Paper.d.cts
CHANGED
package/dist/Paper.d.mts
CHANGED
package/dist/Paper.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as src_exports, o as styled, t as createShouldForwardProp } from "./src-DLGYOJMh.mjs";
|
|
2
2
|
import { Flex } from "./Flex.mjs";
|
|
3
3
|
import { t as themeDefault } from "./themeDefault-Z3KmyIbm.mjs";
|
|
4
|
-
import { r as useTheme } from "./theme-
|
|
4
|
+
import { r as useTheme } from "./theme-Z9_QludW.mjs";
|
|
5
5
|
import "react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
//#region src/Paper/Paper.tsx
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_src = require("./src-DU81aGy9.cjs");
|
|
2
|
-
const require_theme = require("./theme-
|
|
2
|
+
const require_theme = require("./theme-BxXuXRgQ.cjs");
|
|
3
3
|
const require_Paper = require("./Paper.cjs");
|
|
4
|
+
const require_computePopoverPosition = require("./computePopoverPosition-DiyEOHnU.cjs");
|
|
4
5
|
const require_Modal = require("./Modal-CM3osOqj.cjs");
|
|
5
6
|
let react = require("react");
|
|
6
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -11,128 +12,6 @@ function resolveAnchorEl(anchorEl) {
|
|
|
11
12
|
return (typeof anchorEl === "function" ? anchorEl() : anchorEl) ?? null;
|
|
12
13
|
}
|
|
13
14
|
//#endregion
|
|
14
|
-
//#region src/Popover/utils/getOffset.ts
|
|
15
|
-
/** Vertical offset within a rect for an anchor/transform origin keyword or explicit px. */
|
|
16
|
-
function getOffsetTop(rect, vertical) {
|
|
17
|
-
if (typeof vertical === "number") return vertical;
|
|
18
|
-
if (vertical === "center") return rect.height / 2;
|
|
19
|
-
if (vertical === "bottom") return rect.height;
|
|
20
|
-
return 0;
|
|
21
|
-
}
|
|
22
|
-
/** Horizontal offset within a rect for an anchor/transform origin keyword or explicit px. */
|
|
23
|
-
function getOffsetLeft(rect, horizontal) {
|
|
24
|
-
if (typeof horizontal === "number") return horizontal;
|
|
25
|
-
if (horizontal === "center") return rect.width / 2;
|
|
26
|
-
if (horizontal === "right") return rect.width;
|
|
27
|
-
return 0;
|
|
28
|
-
}
|
|
29
|
-
//#endregion
|
|
30
|
-
//#region src/Popover/utils/getTransformOriginValue.ts
|
|
31
|
-
/** Serializes a resolved transform origin (in px) to a CSS `transform-origin` value. */
|
|
32
|
-
function getTransformOriginValue(origin) {
|
|
33
|
-
return `${origin.horizontal}px ${origin.vertical}px`;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region src/Popover/utils/computePopoverPosition.ts
|
|
37
|
-
/** Mirrors a keyword origin to the opposite edge; numbers and `center` are unchanged. */
|
|
38
|
-
function flipVertical(origin) {
|
|
39
|
-
if (origin === "top") return "bottom";
|
|
40
|
-
if (origin === "bottom") return "top";
|
|
41
|
-
return origin;
|
|
42
|
-
}
|
|
43
|
-
function flipHorizontal(origin) {
|
|
44
|
-
if (origin === "left") return "right";
|
|
45
|
-
if (origin === "right") return "left";
|
|
46
|
-
return origin;
|
|
47
|
-
}
|
|
48
|
-
function resolveAxis({ anchorStart, anchorSize, anchorOrigin, transformOrigin, paperSize, viewportSize, margin, offset, flip }) {
|
|
49
|
-
const preferredTransform = offset(paperSize, transformOrigin);
|
|
50
|
-
const preferredPosition = anchorStart + offset(anchorSize, anchorOrigin) - preferredTransform;
|
|
51
|
-
let position = preferredPosition;
|
|
52
|
-
let transformOffset = preferredTransform;
|
|
53
|
-
if (margin != null) {
|
|
54
|
-
const fits = (candidate) => candidate >= margin && candidate + paperSize <= viewportSize - margin;
|
|
55
|
-
if (!fits(preferredPosition)) {
|
|
56
|
-
const flippedTransform = offset(paperSize, flip(transformOrigin));
|
|
57
|
-
const flippedPosition = anchorStart + offset(anchorSize, flip(anchorOrigin)) - flippedTransform;
|
|
58
|
-
if (fits(flippedPosition)) {
|
|
59
|
-
position = flippedPosition;
|
|
60
|
-
transformOffset = flippedTransform;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (position < margin) {
|
|
64
|
-
const diff = position - margin;
|
|
65
|
-
position -= diff;
|
|
66
|
-
transformOffset += diff;
|
|
67
|
-
} else if (position + paperSize > viewportSize - margin) {
|
|
68
|
-
const diff = position + paperSize - (viewportSize - margin);
|
|
69
|
-
position -= diff;
|
|
70
|
-
transformOffset += diff;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
position,
|
|
75
|
-
transformOffset
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Places the paper so its `transformOrigin` meets the anchor's `anchorOrigin`, flipping
|
|
80
|
-
* to the opposite side at a viewport edge and clamping as a fallback. Returns `null`
|
|
81
|
-
* coordinates for `anchorReference === 'none'`.
|
|
82
|
-
*/
|
|
83
|
-
function computePopoverPosition(params) {
|
|
84
|
-
const { anchorReference, anchorRect, anchorPosition, paperRect, anchorOrigin, transformOrigin, viewport, marginThreshold } = params;
|
|
85
|
-
if (anchorReference === "none") return {
|
|
86
|
-
top: null,
|
|
87
|
-
left: null,
|
|
88
|
-
transformOrigin: getTransformOriginValue({
|
|
89
|
-
vertical: getOffsetTop(paperRect, transformOrigin.vertical),
|
|
90
|
-
horizontal: getOffsetLeft(paperRect, transformOrigin.horizontal)
|
|
91
|
-
})
|
|
92
|
-
};
|
|
93
|
-
const rect = anchorReference === "anchorPosition" ? {
|
|
94
|
-
top: anchorPosition?.top ?? 0,
|
|
95
|
-
left: anchorPosition?.left ?? 0,
|
|
96
|
-
width: 0,
|
|
97
|
-
height: 0
|
|
98
|
-
} : anchorRect ?? {
|
|
99
|
-
top: 0,
|
|
100
|
-
left: 0,
|
|
101
|
-
width: 0,
|
|
102
|
-
height: 0
|
|
103
|
-
};
|
|
104
|
-
const vertical = resolveAxis({
|
|
105
|
-
anchorStart: rect.top,
|
|
106
|
-
anchorSize: rect.height,
|
|
107
|
-
anchorOrigin: anchorOrigin.vertical,
|
|
108
|
-
transformOrigin: transformOrigin.vertical,
|
|
109
|
-
paperSize: paperRect.height,
|
|
110
|
-
viewportSize: viewport.height,
|
|
111
|
-
margin: marginThreshold,
|
|
112
|
-
offset: (size, origin) => getOffsetTop({ height: size }, origin),
|
|
113
|
-
flip: (origin) => flipVertical(origin)
|
|
114
|
-
});
|
|
115
|
-
const horizontal = resolveAxis({
|
|
116
|
-
anchorStart: rect.left,
|
|
117
|
-
anchorSize: rect.width,
|
|
118
|
-
anchorOrigin: anchorOrigin.horizontal,
|
|
119
|
-
transformOrigin: transformOrigin.horizontal,
|
|
120
|
-
paperSize: paperRect.width,
|
|
121
|
-
viewportSize: viewport.width,
|
|
122
|
-
margin: marginThreshold,
|
|
123
|
-
offset: (size, origin) => getOffsetLeft({ width: size }, origin),
|
|
124
|
-
flip: (origin) => flipHorizontal(origin)
|
|
125
|
-
});
|
|
126
|
-
return {
|
|
127
|
-
top: Math.floor(vertical.position),
|
|
128
|
-
left: Math.floor(horizontal.position),
|
|
129
|
-
transformOrigin: getTransformOriginValue({
|
|
130
|
-
vertical: vertical.transformOffset,
|
|
131
|
-
horizontal: horizontal.transformOffset
|
|
132
|
-
})
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
//#endregion
|
|
136
15
|
//#region src/Popover/Popover.tsx
|
|
137
16
|
const ANCHOR_ORIGIN_DEFAULT = {
|
|
138
17
|
vertical: "top",
|
|
@@ -176,9 +55,10 @@ function Popover({ open, children, anchorEl = null, anchorReference = "anchorEl"
|
|
|
176
55
|
const element = positionerRef.current;
|
|
177
56
|
if (!element) return;
|
|
178
57
|
const resolved = resolveAnchorEl(anchorEl);
|
|
179
|
-
const
|
|
58
|
+
const anchorRect = anchorReference === "anchorEl" && resolved ? resolved.getBoundingClientRect() : null;
|
|
59
|
+
const positioning = require_computePopoverPosition.computePopoverPosition({
|
|
180
60
|
anchorReference,
|
|
181
|
-
anchorRect
|
|
61
|
+
anchorRect,
|
|
182
62
|
anchorPosition: anchorTop != null && anchorLeft != null ? {
|
|
183
63
|
top: anchorTop,
|
|
184
64
|
left: anchorLeft
|