@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
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
const require_utils = require("./utils.cjs");
|
|
2
2
|
let _soroush_tech_styled_system = require("@soroush.tech/styled-system");
|
|
3
|
-
let react = require("react");
|
|
4
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
-
let _emotion_react = require("@emotion/react");
|
|
6
3
|
//#region src/theme/utils/spacing.ts
|
|
7
4
|
const spacing = (units) => units === 0 ? "0px" : `${Math.max(1, Math.round(8 * units))}px`;
|
|
8
5
|
//#endregion
|
|
@@ -26,37 +23,6 @@ const withBreakpointHelpers = (scale) => {
|
|
|
26
23
|
return sizes;
|
|
27
24
|
};
|
|
28
25
|
//#endregion
|
|
29
|
-
//#region src/theme/utils/createTheme.ts
|
|
30
|
-
const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31
|
-
const deepMerge = (base, overrides) => {
|
|
32
|
-
const merged = { ...base };
|
|
33
|
-
for (const [key, value] of Object.entries(overrides)) {
|
|
34
|
-
if (value === void 0) continue;
|
|
35
|
-
const baseValue = merged[key];
|
|
36
|
-
merged[key] = isPlainObject(baseValue) && isPlainObject(value) ? deepMerge(baseValue, value) : value;
|
|
37
|
-
}
|
|
38
|
-
return merged;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Builds a theme by deep-merging sparse `overrides` onto `base`.
|
|
42
|
-
*
|
|
43
|
-
* - Recurses only where both sides are plain objects; arrays (`shadows`,
|
|
44
|
-
* `fontSizes`) and functions replace wholesale.
|
|
45
|
-
* - `undefined` override values are ignored - a key can be added or replaced,
|
|
46
|
-
* never removed.
|
|
47
|
-
* - Neither argument is mutated; untouched branches keep referential identity.
|
|
48
|
-
* - `breakpoints` gets its query helpers back, built from the merged sizes.
|
|
49
|
-
*/
|
|
50
|
-
const createTheme = (base, overrides) => {
|
|
51
|
-
const theme = deepMerge(base, overrides);
|
|
52
|
-
return withHelpers(theme);
|
|
53
|
-
};
|
|
54
|
-
/** A theme whose `breakpoints` carry the query helpers - added when a hand-built theme lacks them. */
|
|
55
|
-
const withHelpers = (theme) => theme.breakpoints && !("up" in theme.breakpoints) ? {
|
|
56
|
-
...theme,
|
|
57
|
-
breakpoints: withBreakpointHelpers(theme.breakpoints)
|
|
58
|
-
} : theme;
|
|
59
|
-
//#endregion
|
|
60
26
|
//#region src/theme/themes.ts
|
|
61
27
|
const shadow = {
|
|
62
28
|
color: "#000000",
|
|
@@ -418,84 +384,6 @@ const baseTheme = {
|
|
|
418
384
|
*/
|
|
419
385
|
const { up, down, only, between, not, containerQueries } = breakpoints;
|
|
420
386
|
//#endregion
|
|
421
|
-
//#region src/theme/ThemeProvider.tsx
|
|
422
|
-
function ThemeProvider({ children, theme = baseTheme, defaults }) {
|
|
423
|
-
const value = (0, react.useMemo)(() => defaults ? createTheme(theme, { defaults }) : withHelpers(theme), [theme, defaults]);
|
|
424
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_emotion_react.ThemeProvider, {
|
|
425
|
-
theme: value,
|
|
426
|
-
children
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
//#endregion
|
|
430
|
-
//#region src/theme/LayoutProvider.tsx
|
|
431
|
-
const pageLayout = (theme, layout) => {
|
|
432
|
-
const page = layout;
|
|
433
|
-
let carried = {};
|
|
434
|
-
const merged = {};
|
|
435
|
-
for (const key of Object.keys(theme.breakpoints)) {
|
|
436
|
-
carried = deepMerge(carried, page[key] ?? {});
|
|
437
|
-
if (Object.keys(carried).length > 0) merged[key] = carried;
|
|
438
|
-
}
|
|
439
|
-
return merged;
|
|
440
|
-
};
|
|
441
|
-
/**
|
|
442
|
-
* @description A page-level layout: everything inside sees `theme.layout` with the page's
|
|
443
|
-
* values merged on top - `View`, `Flex` and `Grid` with `layout`, and `useTheme().layout`. It
|
|
444
|
-
* derives the theme from the one around it and changes nothing else, so colours, light/dark
|
|
445
|
-
* switching and every other token stay the app theme's. Nested providers stack.
|
|
446
|
-
*/
|
|
447
|
-
function LayoutProvider({ layout, children }) {
|
|
448
|
-
const derive = (0, react.useCallback)((outer) => {
|
|
449
|
-
const theme = "breakpoints" in outer ? outer : baseTheme;
|
|
450
|
-
return createTheme(theme, { layout: pageLayout(theme, layout) });
|
|
451
|
-
}, [layout]);
|
|
452
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_emotion_react.ThemeProvider, {
|
|
453
|
-
theme: derive,
|
|
454
|
-
children
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
//#endregion
|
|
458
|
-
//#region src/theme/hooks/useTheme.ts
|
|
459
|
-
/**
|
|
460
|
-
* The active theme, typed as this package's own `Theme` - Emotion is an
|
|
461
|
-
* internal implementation detail, never part of the public type surface.
|
|
462
|
-
*/
|
|
463
|
-
const useTheme = () => (0, _emotion_react.useTheme)();
|
|
464
|
-
//#endregion
|
|
465
|
-
//#region src/theme/hooks/useDefaultProps.ts
|
|
466
|
-
/**
|
|
467
|
-
* The theme-contributed default prop values for a component
|
|
468
|
-
* (`theme.components[name].defaultProps`), or an empty object.
|
|
469
|
-
*
|
|
470
|
-
* Components apply it as one step of the default-resolution chain:
|
|
471
|
-
* explicit prop → group context → `useDefaultProps` → `theme.defaults.*` → literal fallback.
|
|
472
|
-
*/
|
|
473
|
-
function useDefaultProps(name) {
|
|
474
|
-
return useTheme().components?.[name]?.defaultProps ?? {};
|
|
475
|
-
}
|
|
476
|
-
//#endregion
|
|
477
|
-
//#region src/theme/hoc/withTheme.tsx
|
|
478
|
-
function withTheme(WrappedComponent) {
|
|
479
|
-
return function WithTheme(props) {
|
|
480
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_emotion_react.ThemeContext.Consumer, { children: (theme) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WrappedComponent, {
|
|
481
|
-
...props,
|
|
482
|
-
theme
|
|
483
|
-
}) });
|
|
484
|
-
};
|
|
485
|
-
}
|
|
486
|
-
//#endregion
|
|
487
|
-
Object.defineProperty(exports, "LayoutProvider", {
|
|
488
|
-
enumerable: true,
|
|
489
|
-
get: function() {
|
|
490
|
-
return LayoutProvider;
|
|
491
|
-
}
|
|
492
|
-
});
|
|
493
|
-
Object.defineProperty(exports, "ThemeProvider", {
|
|
494
|
-
enumerable: true,
|
|
495
|
-
get: function() {
|
|
496
|
-
return ThemeProvider;
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
387
|
Object.defineProperty(exports, "avatar", {
|
|
500
388
|
enumerable: true,
|
|
501
389
|
get: function() {
|
|
@@ -532,12 +420,6 @@ Object.defineProperty(exports, "containerQueries", {
|
|
|
532
420
|
return containerQueries;
|
|
533
421
|
}
|
|
534
422
|
});
|
|
535
|
-
Object.defineProperty(exports, "createTheme", {
|
|
536
|
-
enumerable: true,
|
|
537
|
-
get: function() {
|
|
538
|
-
return createTheme;
|
|
539
|
-
}
|
|
540
|
-
});
|
|
541
423
|
Object.defineProperty(exports, "down", {
|
|
542
424
|
enumerable: true,
|
|
543
425
|
get: function() {
|
|
@@ -628,30 +510,12 @@ Object.defineProperty(exports, "up", {
|
|
|
628
510
|
return up;
|
|
629
511
|
}
|
|
630
512
|
});
|
|
631
|
-
Object.defineProperty(exports, "useDefaultProps", {
|
|
632
|
-
enumerable: true,
|
|
633
|
-
get: function() {
|
|
634
|
-
return useDefaultProps;
|
|
635
|
-
}
|
|
636
|
-
});
|
|
637
|
-
Object.defineProperty(exports, "useTheme", {
|
|
638
|
-
enumerable: true,
|
|
639
|
-
get: function() {
|
|
640
|
-
return useTheme;
|
|
641
|
-
}
|
|
642
|
-
});
|
|
643
513
|
Object.defineProperty(exports, "withBreakpointHelpers", {
|
|
644
514
|
enumerable: true,
|
|
645
515
|
get: function() {
|
|
646
516
|
return withBreakpointHelpers;
|
|
647
517
|
}
|
|
648
518
|
});
|
|
649
|
-
Object.defineProperty(exports, "withTheme", {
|
|
650
|
-
enumerable: true,
|
|
651
|
-
get: function() {
|
|
652
|
-
return withTheme;
|
|
653
|
-
}
|
|
654
|
-
});
|
|
655
519
|
Object.defineProperty(exports, "zOrder", {
|
|
656
520
|
enumerable: true,
|
|
657
521
|
get: function() {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
let react = require("react");
|
|
2
|
+
//#region src/utils/useControlled.ts
|
|
3
|
+
/**
|
|
4
|
+
* A value a control owns until its owner takes it over: the controlled value when there is one,
|
|
5
|
+
* otherwise its own state. The setter keeps that state moving either way, so a control that
|
|
6
|
+
* stays uncontrolled needs no branch.
|
|
7
|
+
*/
|
|
8
|
+
function useControlled({ controlled, default: defaultValue }) {
|
|
9
|
+
const [state, setState] = (0, react.useState)(defaultValue);
|
|
10
|
+
return [controlled !== void 0 ? controlled : state, setState];
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
Object.defineProperty(exports, "useControlled", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function() {
|
|
16
|
+
return useControlled;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
//#region src/utils/useControlled.ts
|
|
3
|
+
/**
|
|
4
|
+
* A value a control owns until its owner takes it over: the controlled value when there is one,
|
|
5
|
+
* otherwise its own state. The setter keeps that state moving either way, so a control that
|
|
6
|
+
* stays uncontrolled needs no branch.
|
|
7
|
+
*/
|
|
8
|
+
function useControlled({ controlled, default: defaultValue }) {
|
|
9
|
+
const [state, setState] = useState(defaultValue);
|
|
10
|
+
return [controlled !== void 0 ? controlled : state, setState];
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { useControlled as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as TableSortLabelDirection } from "./index-
|
|
1
|
+
import { n as TableSortLabelDirection } from "./index-DYF8sRE-.cjs";
|
|
2
2
|
//#region src/Table/hooks/useTableSort.d.ts
|
|
3
3
|
/** One column's sort state - spreads directly onto `TableSortLabel`. */
|
|
4
4
|
interface TableSortEntry {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as TableSortLabelDirection } from "./index-
|
|
1
|
+
import { n as TableSortLabelDirection } from "./index-pTNq3iQn.mjs";
|
|
2
2
|
//#region src/Table/hooks/useTableSort.d.ts
|
|
3
3
|
/** One column's sort state - spreads directly onto `TableSortLabel`. */
|
|
4
4
|
interface TableSortEntry {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soroush.tech/design-system",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.3",
|
|
4
4
|
"description": "Emotion + @soroush.tech/styled-system React component library - token-driven light/dark themes, layout primitives, forms, and overlays.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"design-system",
|
|
@@ -68,6 +68,16 @@
|
|
|
68
68
|
"default": "./dist/Backdrop.cjs"
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
|
+
"./Breadcrumbs": {
|
|
72
|
+
"import": {
|
|
73
|
+
"types": "./dist/Breadcrumbs.d.mts",
|
|
74
|
+
"default": "./dist/Breadcrumbs.mjs"
|
|
75
|
+
},
|
|
76
|
+
"require": {
|
|
77
|
+
"types": "./dist/Breadcrumbs.d.cts",
|
|
78
|
+
"default": "./dist/Breadcrumbs.cjs"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
71
81
|
"./Button": {
|
|
72
82
|
"import": {
|
|
73
83
|
"types": "./dist/Button.d.mts",
|
|
@@ -218,6 +228,16 @@
|
|
|
218
228
|
"default": "./dist/Image.cjs"
|
|
219
229
|
}
|
|
220
230
|
},
|
|
231
|
+
"./InputRange": {
|
|
232
|
+
"import": {
|
|
233
|
+
"types": "./dist/InputRange.d.mts",
|
|
234
|
+
"default": "./dist/InputRange.mjs"
|
|
235
|
+
},
|
|
236
|
+
"require": {
|
|
237
|
+
"types": "./dist/InputRange.d.cts",
|
|
238
|
+
"default": "./dist/InputRange.cjs"
|
|
239
|
+
}
|
|
240
|
+
},
|
|
221
241
|
"./LinearProgress": {
|
|
222
242
|
"import": {
|
|
223
243
|
"types": "./dist/LinearProgress.d.mts",
|
|
@@ -238,6 +258,16 @@
|
|
|
238
258
|
"default": "./dist/Link.cjs"
|
|
239
259
|
}
|
|
240
260
|
},
|
|
261
|
+
"./Menu": {
|
|
262
|
+
"import": {
|
|
263
|
+
"types": "./dist/Menu.d.mts",
|
|
264
|
+
"default": "./dist/Menu.mjs"
|
|
265
|
+
},
|
|
266
|
+
"require": {
|
|
267
|
+
"types": "./dist/Menu.d.cts",
|
|
268
|
+
"default": "./dist/Menu.cjs"
|
|
269
|
+
}
|
|
270
|
+
},
|
|
241
271
|
"./MenuItem": {
|
|
242
272
|
"import": {
|
|
243
273
|
"types": "./dist/MenuItem.d.mts",
|
|
@@ -268,6 +298,16 @@
|
|
|
268
298
|
"default": "./dist/NativeSelect.cjs"
|
|
269
299
|
}
|
|
270
300
|
},
|
|
301
|
+
"./NumberField": {
|
|
302
|
+
"import": {
|
|
303
|
+
"types": "./dist/NumberField.d.mts",
|
|
304
|
+
"default": "./dist/NumberField.mjs"
|
|
305
|
+
},
|
|
306
|
+
"require": {
|
|
307
|
+
"types": "./dist/NumberField.d.cts",
|
|
308
|
+
"default": "./dist/NumberField.cjs"
|
|
309
|
+
}
|
|
310
|
+
},
|
|
271
311
|
"./Pagination": {
|
|
272
312
|
"import": {
|
|
273
313
|
"types": "./dist/Pagination.d.mts",
|
|
@@ -338,6 +378,16 @@
|
|
|
338
378
|
"default": "./dist/Radio.cjs"
|
|
339
379
|
}
|
|
340
380
|
},
|
|
381
|
+
"./Rating": {
|
|
382
|
+
"import": {
|
|
383
|
+
"types": "./dist/Rating.d.mts",
|
|
384
|
+
"default": "./dist/Rating.mjs"
|
|
385
|
+
},
|
|
386
|
+
"require": {
|
|
387
|
+
"types": "./dist/Rating.d.cts",
|
|
388
|
+
"default": "./dist/Rating.cjs"
|
|
389
|
+
}
|
|
390
|
+
},
|
|
341
391
|
"./Select": {
|
|
342
392
|
"import": {
|
|
343
393
|
"types": "./dist/Select.d.mts",
|
|
@@ -388,6 +438,16 @@
|
|
|
388
438
|
"default": "./dist/Table.cjs"
|
|
389
439
|
}
|
|
390
440
|
},
|
|
441
|
+
"./Tabs": {
|
|
442
|
+
"import": {
|
|
443
|
+
"types": "./dist/Tabs.d.mts",
|
|
444
|
+
"default": "./dist/Tabs.mjs"
|
|
445
|
+
},
|
|
446
|
+
"require": {
|
|
447
|
+
"types": "./dist/Tabs.d.cts",
|
|
448
|
+
"default": "./dist/Tabs.cjs"
|
|
449
|
+
}
|
|
450
|
+
},
|
|
391
451
|
"./TextInput": {
|
|
392
452
|
"import": {
|
|
393
453
|
"types": "./dist/TextInput.d.mts",
|
|
@@ -398,6 +458,16 @@
|
|
|
398
458
|
"default": "./dist/TextInput.cjs"
|
|
399
459
|
}
|
|
400
460
|
},
|
|
461
|
+
"./catalog": {
|
|
462
|
+
"import": {
|
|
463
|
+
"types": "./dist/catalog.d.mts",
|
|
464
|
+
"default": "./dist/catalog.mjs"
|
|
465
|
+
},
|
|
466
|
+
"require": {
|
|
467
|
+
"types": "./dist/catalog.d.cts",
|
|
468
|
+
"default": "./dist/catalog.cjs"
|
|
469
|
+
}
|
|
470
|
+
},
|
|
401
471
|
"./theme": {
|
|
402
472
|
"import": {
|
|
403
473
|
"types": "./dist/theme.d.mts",
|
|
@@ -438,6 +508,16 @@
|
|
|
438
508
|
"default": "./dist/ToggleButton.cjs"
|
|
439
509
|
}
|
|
440
510
|
},
|
|
511
|
+
"./TransferList": {
|
|
512
|
+
"import": {
|
|
513
|
+
"types": "./dist/TransferList.d.mts",
|
|
514
|
+
"default": "./dist/TransferList.mjs"
|
|
515
|
+
},
|
|
516
|
+
"require": {
|
|
517
|
+
"types": "./dist/TransferList.d.cts",
|
|
518
|
+
"default": "./dist/TransferList.cjs"
|
|
519
|
+
}
|
|
520
|
+
},
|
|
441
521
|
"./Typography": {
|
|
442
522
|
"import": {
|
|
443
523
|
"types": "./dist/Typography.d.mts",
|
|
@@ -487,7 +567,7 @@
|
|
|
487
567
|
"@emotion/cache": "^11.14.0",
|
|
488
568
|
"@emotion/react": "^11.14.0",
|
|
489
569
|
"@emotion/styled": "^11.14.1",
|
|
490
|
-
"@soroush.tech/styled-system": "^6.0.0-rc.
|
|
570
|
+
"@soroush.tech/styled-system": "^6.0.0-rc.3"
|
|
491
571
|
},
|
|
492
572
|
"peerDependencies": {
|
|
493
573
|
"react": "^19.2.8",
|
|
@@ -516,6 +596,7 @@
|
|
|
516
596
|
"typescript": "~7.0.2",
|
|
517
597
|
"vitest": "^4.1.10",
|
|
518
598
|
"zod": "^4.4.3",
|
|
599
|
+
"@soroush.tech/docs-content": "0.1.0",
|
|
519
600
|
"@soroush.tech/eslint-config": "0.0.0"
|
|
520
601
|
},
|
|
521
602
|
"scripts": {
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { o as styled, t as createShouldForwardProp } from "./src-DLGYOJMh.mjs";
|
|
2
|
-
import { r as useTheme } from "./theme-CDVxig_g.mjs";
|
|
3
|
-
import { Paper } from "./Paper.mjs";
|
|
4
|
-
import { t as Modal } from "./Modal-BcsyrrpH.mjs";
|
|
5
|
-
import { useCallback, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
|
|
6
|
-
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
//#region src/Popover/utils/resolveAnchorEl.ts
|
|
8
|
-
/** Resolves the `anchorEl` prop, which may be an element or a function returning one. */
|
|
9
|
-
function resolveAnchorEl(anchorEl) {
|
|
10
|
-
return (typeof anchorEl === "function" ? anchorEl() : anchorEl) ?? null;
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region src/Popover/utils/getOffset.ts
|
|
14
|
-
/** Vertical offset within a rect for an anchor/transform origin keyword or explicit px. */
|
|
15
|
-
function getOffsetTop(rect, vertical) {
|
|
16
|
-
if (typeof vertical === "number") return vertical;
|
|
17
|
-
if (vertical === "center") return rect.height / 2;
|
|
18
|
-
if (vertical === "bottom") return rect.height;
|
|
19
|
-
return 0;
|
|
20
|
-
}
|
|
21
|
-
/** Horizontal offset within a rect for an anchor/transform origin keyword or explicit px. */
|
|
22
|
-
function getOffsetLeft(rect, horizontal) {
|
|
23
|
-
if (typeof horizontal === "number") return horizontal;
|
|
24
|
-
if (horizontal === "center") return rect.width / 2;
|
|
25
|
-
if (horizontal === "right") return rect.width;
|
|
26
|
-
return 0;
|
|
27
|
-
}
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/Popover/utils/getTransformOriginValue.ts
|
|
30
|
-
/** Serializes a resolved transform origin (in px) to a CSS `transform-origin` value. */
|
|
31
|
-
function getTransformOriginValue(origin) {
|
|
32
|
-
return `${origin.horizontal}px ${origin.vertical}px`;
|
|
33
|
-
}
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/Popover/utils/computePopoverPosition.ts
|
|
36
|
-
/** Mirrors a keyword origin to the opposite edge; numbers and `center` are unchanged. */
|
|
37
|
-
function flipVertical(origin) {
|
|
38
|
-
if (origin === "top") return "bottom";
|
|
39
|
-
if (origin === "bottom") return "top";
|
|
40
|
-
return origin;
|
|
41
|
-
}
|
|
42
|
-
function flipHorizontal(origin) {
|
|
43
|
-
if (origin === "left") return "right";
|
|
44
|
-
if (origin === "right") return "left";
|
|
45
|
-
return origin;
|
|
46
|
-
}
|
|
47
|
-
function resolveAxis({ anchorStart, anchorSize, anchorOrigin, transformOrigin, paperSize, viewportSize, margin, offset, flip }) {
|
|
48
|
-
const preferredTransform = offset(paperSize, transformOrigin);
|
|
49
|
-
const preferredPosition = anchorStart + offset(anchorSize, anchorOrigin) - preferredTransform;
|
|
50
|
-
let position = preferredPosition;
|
|
51
|
-
let transformOffset = preferredTransform;
|
|
52
|
-
if (margin != null) {
|
|
53
|
-
const fits = (candidate) => candidate >= margin && candidate + paperSize <= viewportSize - margin;
|
|
54
|
-
if (!fits(preferredPosition)) {
|
|
55
|
-
const flippedTransform = offset(paperSize, flip(transformOrigin));
|
|
56
|
-
const flippedPosition = anchorStart + offset(anchorSize, flip(anchorOrigin)) - flippedTransform;
|
|
57
|
-
if (fits(flippedPosition)) {
|
|
58
|
-
position = flippedPosition;
|
|
59
|
-
transformOffset = flippedTransform;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (position < margin) {
|
|
63
|
-
const diff = position - margin;
|
|
64
|
-
position -= diff;
|
|
65
|
-
transformOffset += diff;
|
|
66
|
-
} else if (position + paperSize > viewportSize - margin) {
|
|
67
|
-
const diff = position + paperSize - (viewportSize - margin);
|
|
68
|
-
position -= diff;
|
|
69
|
-
transformOffset += diff;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
position,
|
|
74
|
-
transformOffset
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Places the paper so its `transformOrigin` meets the anchor's `anchorOrigin`, flipping
|
|
79
|
-
* to the opposite side at a viewport edge and clamping as a fallback. Returns `null`
|
|
80
|
-
* coordinates for `anchorReference === 'none'`.
|
|
81
|
-
*/
|
|
82
|
-
function computePopoverPosition(params) {
|
|
83
|
-
const { anchorReference, anchorRect, anchorPosition, paperRect, anchorOrigin, transformOrigin, viewport, marginThreshold } = params;
|
|
84
|
-
if (anchorReference === "none") return {
|
|
85
|
-
top: null,
|
|
86
|
-
left: null,
|
|
87
|
-
transformOrigin: getTransformOriginValue({
|
|
88
|
-
vertical: getOffsetTop(paperRect, transformOrigin.vertical),
|
|
89
|
-
horizontal: getOffsetLeft(paperRect, transformOrigin.horizontal)
|
|
90
|
-
})
|
|
91
|
-
};
|
|
92
|
-
const rect = anchorReference === "anchorPosition" ? {
|
|
93
|
-
top: anchorPosition?.top ?? 0,
|
|
94
|
-
left: anchorPosition?.left ?? 0,
|
|
95
|
-
width: 0,
|
|
96
|
-
height: 0
|
|
97
|
-
} : anchorRect ?? {
|
|
98
|
-
top: 0,
|
|
99
|
-
left: 0,
|
|
100
|
-
width: 0,
|
|
101
|
-
height: 0
|
|
102
|
-
};
|
|
103
|
-
const vertical = resolveAxis({
|
|
104
|
-
anchorStart: rect.top,
|
|
105
|
-
anchorSize: rect.height,
|
|
106
|
-
anchorOrigin: anchorOrigin.vertical,
|
|
107
|
-
transformOrigin: transformOrigin.vertical,
|
|
108
|
-
paperSize: paperRect.height,
|
|
109
|
-
viewportSize: viewport.height,
|
|
110
|
-
margin: marginThreshold,
|
|
111
|
-
offset: (size, origin) => getOffsetTop({ height: size }, origin),
|
|
112
|
-
flip: (origin) => flipVertical(origin)
|
|
113
|
-
});
|
|
114
|
-
const horizontal = resolveAxis({
|
|
115
|
-
anchorStart: rect.left,
|
|
116
|
-
anchorSize: rect.width,
|
|
117
|
-
anchorOrigin: anchorOrigin.horizontal,
|
|
118
|
-
transformOrigin: transformOrigin.horizontal,
|
|
119
|
-
paperSize: paperRect.width,
|
|
120
|
-
viewportSize: viewport.width,
|
|
121
|
-
margin: marginThreshold,
|
|
122
|
-
offset: (size, origin) => getOffsetLeft({ width: size }, origin),
|
|
123
|
-
flip: (origin) => flipHorizontal(origin)
|
|
124
|
-
});
|
|
125
|
-
return {
|
|
126
|
-
top: Math.floor(vertical.position),
|
|
127
|
-
left: Math.floor(horizontal.position),
|
|
128
|
-
transformOrigin: getTransformOriginValue({
|
|
129
|
-
vertical: vertical.transformOffset,
|
|
130
|
-
horizontal: horizontal.transformOffset
|
|
131
|
-
})
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
//#endregion
|
|
135
|
-
//#region src/Popover/Popover.tsx
|
|
136
|
-
const ANCHOR_ORIGIN_DEFAULT = {
|
|
137
|
-
vertical: "top",
|
|
138
|
-
horizontal: "left"
|
|
139
|
-
};
|
|
140
|
-
const Positioner = styled("div", {
|
|
141
|
-
name: "Popover",
|
|
142
|
-
slot: "positioner",
|
|
143
|
-
label: "PopoverPositioner",
|
|
144
|
-
shouldForwardProp: createShouldForwardProp(["isPositioned"])
|
|
145
|
-
})(({ isPositioned }) => ({
|
|
146
|
-
position: "absolute",
|
|
147
|
-
...isPositioned ? {} : { opacity: 0 }
|
|
148
|
-
}));
|
|
149
|
-
const Surface = styled(Paper, {
|
|
150
|
-
name: "Popover",
|
|
151
|
-
label: "Popover"
|
|
152
|
-
})({
|
|
153
|
-
overflowY: "auto",
|
|
154
|
-
overflowX: "hidden",
|
|
155
|
-
minWidth: 16,
|
|
156
|
-
minHeight: 16,
|
|
157
|
-
maxWidth: "calc(100vw - 32px)",
|
|
158
|
-
maxHeight: "calc(100vh - 32px)",
|
|
159
|
-
outline: 0
|
|
160
|
-
});
|
|
161
|
-
/**
|
|
162
|
-
* @description Positions its content next to an anchor, portaled above the page.
|
|
163
|
-
* Built on `Modal`, so it inherits the portal, optional backdrop, focus management,
|
|
164
|
-
* scroll lock, and Escape/click-away close - then adds anchor positioning
|
|
165
|
-
* (`anchorOrigin`/`transformOrigin`/`marginThreshold`).
|
|
166
|
-
*/
|
|
167
|
-
function Popover({ open, children, anchorEl = null, anchorReference = "anchorEl", anchorPosition, anchorOrigin = ANCHOR_ORIGIN_DEFAULT, transformOrigin = ANCHOR_ORIGIN_DEFAULT, onClose, elevation = 8, marginThreshold = 2, container, action, slotProps, hasBackdrop = false, disableScrollLock = false, disableAriaHidden = false, shouldAutoFocus = true, shouldTrapFocus = true, shouldEnforceFocus = true, shouldRestoreFocus = true, shouldKeepMounted = false, layer = "modal" }) {
|
|
168
|
-
const theme = useTheme();
|
|
169
|
-
const positionerRef = useRef(null);
|
|
170
|
-
const [isPositioned, setIsPositioned] = useState(false);
|
|
171
|
-
const anchorTop = anchorPosition?.top;
|
|
172
|
-
const anchorLeft = anchorPosition?.left;
|
|
173
|
-
const marginThresholdPx = marginThreshold == null ? null : Number.parseFloat(String(theme.space[marginThreshold]));
|
|
174
|
-
const setPositioningStyles = useCallback(() => {
|
|
175
|
-
const element = positionerRef.current;
|
|
176
|
-
if (!element) return;
|
|
177
|
-
const resolved = resolveAnchorEl(anchorEl);
|
|
178
|
-
const positioning = computePopoverPosition({
|
|
179
|
-
anchorReference,
|
|
180
|
-
anchorRect: anchorReference === "anchorEl" && resolved ? resolved.getBoundingClientRect() : null,
|
|
181
|
-
anchorPosition: anchorTop != null && anchorLeft != null ? {
|
|
182
|
-
top: anchorTop,
|
|
183
|
-
left: anchorLeft
|
|
184
|
-
} : void 0,
|
|
185
|
-
paperRect: {
|
|
186
|
-
width: element.offsetWidth,
|
|
187
|
-
height: element.offsetHeight
|
|
188
|
-
},
|
|
189
|
-
anchorOrigin,
|
|
190
|
-
transformOrigin,
|
|
191
|
-
viewport: {
|
|
192
|
-
width: window.innerWidth,
|
|
193
|
-
height: window.innerHeight
|
|
194
|
-
},
|
|
195
|
-
marginThreshold: marginThresholdPx
|
|
196
|
-
});
|
|
197
|
-
if (positioning.top !== null) element.style.top = `${positioning.top}px`;
|
|
198
|
-
if (positioning.left !== null) element.style.left = `${positioning.left}px`;
|
|
199
|
-
element.style.transformOrigin = positioning.transformOrigin;
|
|
200
|
-
setIsPositioned(true);
|
|
201
|
-
}, [
|
|
202
|
-
anchorEl,
|
|
203
|
-
anchorReference,
|
|
204
|
-
anchorTop,
|
|
205
|
-
anchorLeft,
|
|
206
|
-
anchorOrigin,
|
|
207
|
-
transformOrigin,
|
|
208
|
-
marginThresholdPx
|
|
209
|
-
]);
|
|
210
|
-
useLayoutEffect(() => {
|
|
211
|
-
if (open) setPositioningStyles();
|
|
212
|
-
});
|
|
213
|
-
useEffect(() => {
|
|
214
|
-
if (!open) return;
|
|
215
|
-
const handle = () => setPositioningStyles();
|
|
216
|
-
window.addEventListener("resize", handle);
|
|
217
|
-
if (disableScrollLock) window.addEventListener("scroll", handle, true);
|
|
218
|
-
return () => {
|
|
219
|
-
window.removeEventListener("resize", handle);
|
|
220
|
-
window.removeEventListener("scroll", handle, true);
|
|
221
|
-
};
|
|
222
|
-
}, [
|
|
223
|
-
open,
|
|
224
|
-
disableScrollLock,
|
|
225
|
-
setPositioningStyles
|
|
226
|
-
]);
|
|
227
|
-
useImperativeHandle(action, () => ({ updatePosition: setPositioningStyles }), [setPositioningStyles]);
|
|
228
|
-
return /* @__PURE__ */ jsx(Modal, {
|
|
229
|
-
isOpen: open,
|
|
230
|
-
onClose,
|
|
231
|
-
hasBackdrop,
|
|
232
|
-
shouldKeepMounted,
|
|
233
|
-
shouldLockScroll: !disableScrollLock,
|
|
234
|
-
disableAriaHidden,
|
|
235
|
-
shouldAutoFocus,
|
|
236
|
-
shouldTrapFocus,
|
|
237
|
-
shouldEnforceFocus,
|
|
238
|
-
shouldRestoreFocus,
|
|
239
|
-
portalContainer: container,
|
|
240
|
-
layer,
|
|
241
|
-
children: /* @__PURE__ */ jsx(Positioner, {
|
|
242
|
-
ref: positionerRef,
|
|
243
|
-
isPositioned,
|
|
244
|
-
children: /* @__PURE__ */ jsx(Surface, {
|
|
245
|
-
elevation,
|
|
246
|
-
...slotProps?.paper,
|
|
247
|
-
children
|
|
248
|
-
})
|
|
249
|
-
})
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
//#endregion
|
|
253
|
-
export { Popover as t };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { T as Theme } from "./themes-RX2UX5gD.mjs";
|
|
2
|
-
import "./index-C1WqEDtQ.mjs";
|
|
3
|
-
import { n as FlexProps } from "./index-CKZaErxJ.mjs";
|
|
4
|
-
import { CSSProperties, ElementType } from "react";
|
|
5
|
-
//#region src/Paper/Paper.d.ts
|
|
6
|
-
type PaperElevation = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24;
|
|
7
|
-
interface PaperProps extends FlexProps {
|
|
8
|
-
/** Shadow depth - 0 (flat) to 24 (highest). Resolves to theme.shadows[n]. Default: 1. */
|
|
9
|
-
elevation?: PaperElevation;
|
|
10
|
-
/** CSS transition for surface animations (e.g. hover elevation change). */
|
|
11
|
-
transition?: CSSProperties['transition'];
|
|
12
|
-
/** Resolves against theme.border - light · primary · dark */
|
|
13
|
-
borderColor?: keyof Theme['border'];
|
|
14
|
-
/** Resolves against theme.borderWidths - none · thin · base · thick */
|
|
15
|
-
borderWidth?: keyof Theme['borderWidths'];
|
|
16
|
-
/** CSS border-style value (e.g. 'solid', 'dashed'). */
|
|
17
|
-
borderStyle?: CSSProperties['borderStyle'];
|
|
18
|
-
/** Renders the surface as a different element (e.g. 'section'). */
|
|
19
|
-
as?: ElementType;
|
|
20
|
-
}
|
|
21
|
-
declare function Paper({ elevation, p, bg, borderRadius, ...rest }: Readonly<PaperProps>): import("react").JSX.Element;
|
|
22
|
-
//#endregion
|
|
23
|
-
export { PaperElevation as n, PaperProps as r, Paper as t };
|