@xanui/ui 1.1.37 → 1.1.40
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/Accordion/index.cjs +96 -0
- package/Accordion/index.cjs.map +1 -0
- package/Accordion/index.js +19 -21
- package/Accordion/index.js.map +1 -1
- package/Alert/index.cjs +121 -0
- package/Alert/index.cjs.map +1 -0
- package/Alert/index.js +33 -35
- package/Alert/index.js.map +1 -1
- package/Autocomplete/index.cjs +136 -0
- package/Autocomplete/index.cjs.map +1 -0
- package/Autocomplete/index.js +23 -25
- package/Autocomplete/index.js.map +1 -1
- package/Avatar/index.cjs +50 -0
- package/Avatar/index.cjs.map +1 -0
- package/Avatar/index.js +15 -17
- package/Avatar/index.js.map +1 -1
- package/Badge/index.cjs +109 -0
- package/Badge/index.cjs.map +1 -0
- package/Badge/index.js +12 -14
- package/Badge/index.js.map +1 -1
- package/Box/index.cjs +14 -0
- package/Box/index.cjs.map +1 -0
- package/Box/index.js +7 -9
- package/Box/index.js.map +1 -1
- package/Button/index.cjs +94 -0
- package/Button/index.cjs.map +1 -0
- package/Button/index.js +17 -19
- package/Button/index.js.map +1 -1
- package/ButtonGroup/index.cjs +58 -0
- package/ButtonGroup/index.cjs.map +1 -0
- package/ButtonGroup/index.js +12 -14
- package/ButtonGroup/index.js.map +1 -1
- package/Calendar/index.cjs +174 -0
- package/Calendar/index.cjs.map +1 -0
- package/Calendar/index.js +39 -41
- package/Calendar/index.js.map +1 -1
- package/CalendarInput/index.cjs +34 -0
- package/CalendarInput/index.cjs.map +1 -0
- package/CalendarInput/index.js +19 -21
- package/CalendarInput/index.js.map +1 -1
- package/Checkbox/index.cjs +58 -0
- package/Checkbox/index.cjs.map +1 -0
- package/Checkbox/index.js +14 -16
- package/Checkbox/index.js.map +1 -1
- package/Chip/index.cjs +76 -0
- package/Chip/index.cjs.map +1 -0
- package/Chip/index.js +12 -14
- package/Chip/index.js.map +1 -1
- package/CircleProgress/index.cjs +129 -0
- package/CircleProgress/index.cjs.map +1 -0
- package/CircleProgress/index.js +13 -15
- package/CircleProgress/index.js.map +1 -1
- package/ClickOutside/index.cjs +37 -0
- package/ClickOutside/index.cjs.map +1 -0
- package/ClickOutside/index.js +9 -11
- package/ClickOutside/index.js.map +1 -1
- package/Collaps/index.cjs +26 -0
- package/Collaps/index.cjs.map +1 -0
- package/Collaps/index.js +9 -11
- package/Collaps/index.js.map +1 -1
- package/Container/index.cjs +29 -0
- package/Container/index.cjs.map +1 -0
- package/Container/index.js +9 -11
- package/Container/index.js.map +1 -1
- package/DataFilter/index.cjs +78 -0
- package/DataFilter/index.cjs.map +1 -0
- package/DataFilter/index.js +30 -41
- package/DataFilter/index.js.map +1 -1
- package/DataFilter/options/DateFilter.cjs +32 -0
- package/DataFilter/options/DateFilter.cjs.map +1 -0
- package/DataFilter/options/DateFilter.js +16 -18
- package/DataFilter/options/DateFilter.js.map +1 -1
- package/DataFilter/options/DateRangeFilter.cjs +27 -0
- package/DataFilter/options/DateRangeFilter.cjs.map +1 -0
- package/DataFilter/options/DateRangeFilter.js +12 -14
- package/DataFilter/options/DateRangeFilter.js.map +1 -1
- package/DataFilter/options/MultiSelectFilter.cjs +38 -0
- package/DataFilter/options/MultiSelectFilter.cjs.map +1 -0
- package/DataFilter/options/MultiSelectFilter.js +20 -22
- package/DataFilter/options/MultiSelectFilter.js.map +1 -1
- package/DataFilter/options/NumberFilter.cjs +24 -0
- package/DataFilter/options/NumberFilter.cjs.map +1 -0
- package/DataFilter/options/NumberFilter.js +11 -13
- package/DataFilter/options/NumberFilter.js.map +1 -1
- package/DataFilter/options/NumberRangeFilter.cjs +29 -0
- package/DataFilter/options/NumberRangeFilter.cjs.map +1 -0
- package/DataFilter/options/NumberRangeFilter.js +12 -14
- package/DataFilter/options/NumberRangeFilter.js.map +1 -1
- package/DataFilter/options/SelectFilter.cjs +34 -0
- package/DataFilter/options/SelectFilter.cjs.map +1 -0
- package/DataFilter/options/SelectFilter.js +18 -20
- package/DataFilter/options/SelectFilter.js.map +1 -1
- package/DataFilter/options/TextFilter.cjs +24 -0
- package/DataFilter/options/TextFilter.cjs.map +1 -0
- package/DataFilter/options/TextFilter.js +11 -13
- package/DataFilter/options/TextFilter.js.map +1 -1
- package/Datatable/FilterBox.cjs +39 -0
- package/Datatable/FilterBox.cjs.map +1 -0
- package/Datatable/FilterBox.js +21 -23
- package/Datatable/FilterBox.js.map +1 -1
- package/Datatable/Row.cjs +59 -0
- package/Datatable/Row.cjs.map +1 -0
- package/Datatable/Row.js +19 -21
- package/Datatable/Row.js.map +1 -1
- package/Datatable/SelectedBox.cjs +21 -0
- package/Datatable/SelectedBox.cjs.map +1 -0
- package/Datatable/SelectedBox.js +10 -12
- package/Datatable/SelectedBox.js.map +1 -1
- package/Datatable/Table.cjs +23 -0
- package/Datatable/Table.cjs.map +1 -0
- package/Datatable/Table.js +8 -10
- package/Datatable/Table.js.map +1 -1
- package/Datatable/TableHead.cjs +61 -0
- package/Datatable/TableHead.cjs.map +1 -0
- package/Datatable/TableHead.js +18 -20
- package/Datatable/TableHead.js.map +1 -1
- package/Datatable/index.cjs +93 -0
- package/Datatable/index.cjs.map +1 -0
- package/Datatable/index.js +21 -23
- package/Datatable/index.js.map +1 -1
- package/Divider/index.cjs +31 -0
- package/Divider/index.cjs.map +1 -0
- package/Divider/index.js +8 -10
- package/Divider/index.js.map +1 -1
- package/Drawer/index.cjs +78 -0
- package/Drawer/index.cjs.map +1 -0
- package/Drawer/index.js +12 -14
- package/Drawer/index.js.map +1 -1
- package/Form/index.cjs +45 -0
- package/Form/index.cjs.map +1 -0
- package/Form/index.js +8 -10
- package/Form/index.js.map +1 -1
- package/GridContainer/index.cjs +19 -0
- package/GridContainer/index.cjs.map +1 -0
- package/GridContainer/index.js +7 -9
- package/GridContainer/index.js.map +1 -1
- package/GridItem/index.cjs +20 -0
- package/GridItem/index.cjs.map +1 -0
- package/GridItem/index.js +7 -9
- package/GridItem/index.js.map +1 -1
- package/IconButton/index.cjs +64 -0
- package/IconButton/index.cjs.map +1 -0
- package/IconButton/index.js +12 -14
- package/IconButton/index.js.map +1 -1
- package/Image/index.cjs +27 -0
- package/Image/index.cjs.map +1 -0
- package/Image/index.js +9 -11
- package/Image/index.js.map +1 -1
- package/Input/index.cjs +144 -0
- package/Input/index.cjs.map +1 -0
- package/Input/index.js +18 -20
- package/Input/index.js.map +1 -1
- package/InputNumber/index.cjs +32 -0
- package/InputNumber/index.cjs.map +1 -0
- package/InputNumber/index.js +6 -8
- package/InputNumber/index.js.map +1 -1
- package/Label/index.cjs +24 -0
- package/Label/index.cjs.map +1 -0
- package/Label/index.js +7 -9
- package/Label/index.js.map +1 -1
- package/Layer/index.cjs +62 -0
- package/Layer/index.cjs.map +1 -0
- package/Layer/index.js +19 -21
- package/Layer/index.js.map +1 -1
- package/LineProgress/index.cjs +59 -0
- package/LineProgress/index.cjs.map +1 -0
- package/LineProgress/index.js +11 -13
- package/LineProgress/index.js.map +1 -1
- package/List/ListContext.cjs +11 -0
- package/List/ListContext.cjs.map +1 -0
- package/List/ListContext.js +2 -5
- package/List/ListContext.js.map +1 -1
- package/List/index.cjs +63 -0
- package/List/index.cjs.map +1 -0
- package/List/index.js +12 -14
- package/List/index.js.map +1 -1
- package/ListItem/index.cjs +54 -0
- package/ListItem/index.cjs.map +1 -0
- package/ListItem/index.js +12 -14
- package/ListItem/index.js.map +1 -1
- package/LoadingBox/index.cjs +32 -0
- package/LoadingBox/index.cjs.map +1 -0
- package/LoadingBox/index.js +11 -13
- package/LoadingBox/index.js.map +1 -1
- package/Menu/index.cjs +150 -0
- package/Menu/index.cjs.map +1 -0
- package/Menu/index.js +18 -20
- package/Menu/index.js.map +1 -1
- package/Modal/index.cjs +59 -0
- package/Modal/index.cjs.map +1 -0
- package/Modal/index.js +15 -17
- package/Modal/index.js.map +1 -1
- package/NoSSR/index.cjs +15 -0
- package/NoSSR/index.cjs.map +1 -0
- package/NoSSR/index.js +4 -6
- package/NoSSR/index.js.map +1 -1
- package/Option/index.cjs +14 -0
- package/Option/index.cjs.map +1 -0
- package/Option/index.js +7 -9
- package/Option/index.js.map +1 -1
- package/Paper/index.cjs +15 -0
- package/Paper/index.cjs.map +1 -0
- package/Paper/index.js +8 -10
- package/Paper/index.js.map +1 -1
- package/Portal/index.cjs +27 -0
- package/Portal/index.cjs.map +1 -0
- package/Portal/index.js +9 -11
- package/Portal/index.js.map +1 -1
- package/Radio/index.cjs +16 -0
- package/Radio/index.cjs.map +1 -0
- package/Radio/index.js +9 -11
- package/Radio/index.js.map +1 -1
- package/Scrollbar/index.cjs +59 -0
- package/Scrollbar/index.cjs.map +1 -0
- package/Scrollbar/index.js +10 -12
- package/Scrollbar/index.js.map +1 -1
- package/Select/index.cjs +59 -0
- package/Select/index.cjs.map +1 -0
- package/Select/index.js +22 -24
- package/Select/index.js.map +1 -1
- package/Skeleton/index.cjs +60 -0
- package/Skeleton/index.cjs.map +1 -0
- package/Skeleton/index.js +7 -9
- package/Skeleton/index.js.map +1 -1
- package/Stack/index.cjs +17 -0
- package/Stack/index.cjs.map +1 -0
- package/Stack/index.js +7 -9
- package/Stack/index.js.map +1 -1
- package/Switch/index.cjs +79 -0
- package/Switch/index.cjs.map +1 -0
- package/Switch/index.js +12 -14
- package/Switch/index.js.map +1 -1
- package/Tab/index.cjs +17 -0
- package/Tab/index.cjs.map +1 -0
- package/Tab/index.js +9 -11
- package/Tab/index.js.map +1 -1
- package/Table/index.cjs +88 -0
- package/Table/index.cjs.map +1 -0
- package/Table/index.js +13 -15
- package/Table/index.js.map +1 -1
- package/TableBody/index.cjs +14 -0
- package/TableBody/index.cjs.map +1 -0
- package/TableBody/index.js +7 -9
- package/TableBody/index.js.map +1 -1
- package/TableCell/index.cjs +14 -0
- package/TableCell/index.cjs.map +1 -0
- package/TableCell/index.js +7 -9
- package/TableCell/index.js.map +1 -1
- package/TableFooter/index.cjs +14 -0
- package/TableFooter/index.cjs.map +1 -0
- package/TableFooter/index.js +7 -9
- package/TableFooter/index.js.map +1 -1
- package/TableHead/index.cjs +14 -0
- package/TableHead/index.cjs.map +1 -0
- package/TableHead/index.js +7 -9
- package/TableHead/index.js.map +1 -1
- package/TablePagination/index.cjs +59 -0
- package/TablePagination/index.cjs.map +1 -0
- package/TablePagination/index.js +21 -23
- package/TablePagination/index.js.map +1 -1
- package/TableRow/index.cjs +14 -0
- package/TableRow/index.cjs.map +1 -0
- package/TableRow/index.js +7 -9
- package/TableRow/index.js.map +1 -1
- package/Tabs/index.cjs +201 -0
- package/Tabs/index.cjs.map +1 -0
- package/Tabs/index.js +19 -21
- package/Tabs/index.js.map +1 -1
- package/Text/index.cjs +25 -0
- package/Text/index.cjs.map +1 -0
- package/Text/index.js +8 -10
- package/Text/index.js.map +1 -1
- package/Toast/index.cjs +120 -0
- package/Toast/index.cjs.map +1 -0
- package/Toast/index.js +18 -20
- package/Toast/index.js.map +1 -1
- package/Tooltip/index.cjs +40 -0
- package/Tooltip/index.cjs.map +1 -0
- package/Tooltip/index.js +11 -13
- package/Tooltip/index.js.map +1 -1
- package/ViewBox/index.cjs +32 -0
- package/ViewBox/index.cjs.map +1 -0
- package/ViewBox/index.js +11 -13
- package/ViewBox/index.js.map +1 -1
- package/index.cjs +134 -0
- package/index.cjs.map +1 -0
- package/index.js +64 -133
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/readme.md +4 -4
- package/useAlert/index.cjs +94 -0
- package/useAlert/index.cjs.map +1 -0
- package/useAlert/index.js +12 -14
- package/useAlert/index.js.map +1 -1
- package/useBlurCss/index.cjs +19 -0
- package/useBlurCss/index.cjs.map +1 -0
- package/useBlurCss/index.js +5 -7
- package/useBlurCss/index.js.map +1 -1
- package/useCorner/index.cjs +22 -0
- package/useCorner/index.cjs.map +1 -0
- package/useCorner/index.js +1 -3
- package/useCorner/index.js.map +1 -1
- package/useLayer/index.cjs +38 -0
- package/useLayer/index.cjs.map +1 -0
- package/useLayer/index.js +7 -9
- package/useLayer/index.js.map +1 -1
- package/useModal/index.cjs +37 -0
- package/useModal/index.cjs.map +1 -0
- package/useModal/index.js +8 -10
- package/useModal/index.js.map +1 -1
package/useLayer/index.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var index = require('../Layer/index.js');
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { usePortal } from '@xanui/core';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import Layer from '../Layer/index.js';
|
|
8
6
|
|
|
9
7
|
const useLayer = (children, props) => {
|
|
10
8
|
var _a;
|
|
11
|
-
const [open, setOpen] =
|
|
9
|
+
const [open, setOpen] = useState(false);
|
|
12
10
|
const portalProps = ((_a = props === null || props === void 0 ? void 0 : props.slotProps) === null || _a === void 0 ? void 0 : _a.portal) || {};
|
|
13
|
-
const portal =
|
|
11
|
+
const portal = usePortal(jsx(Layer, Object.assign({ blur: 20 }, props, { open: open, onClosed: () => {
|
|
14
12
|
portal.unmount();
|
|
15
13
|
if (props === null || props === void 0 ? void 0 : props.onClosed) {
|
|
16
14
|
props.onClosed();
|
|
@@ -34,5 +32,5 @@ const useLayer = (children, props) => {
|
|
|
34
32
|
};
|
|
35
33
|
};
|
|
36
34
|
|
|
37
|
-
|
|
35
|
+
export { useLayer as default };
|
|
38
36
|
//# sourceMappingURL=index.js.map
|
package/useLayer/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/useLayer/index.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useLayer/index.tsx"],"sourcesContent":["'use client'\r\n\r\nimport { usePortal } from \"@xanui/core\"\r\nimport { useState } from \"react\"\r\nimport Layer, { LayerProps } from \"../Layer\"\r\nimport { UsePortalOptions } from \"@xanui/core/hooks/usePortal\"\r\n\r\nexport type UseLayerProps = Omit<LayerProps, \"open\" | \"children\" | \"slotProps\"> & {\r\n slotProps?: LayerProps[\"slotProps\"] & {\r\n portal?: UsePortalOptions\r\n }\r\n}\r\n\r\nexport type UseLayerReturn = {\r\n open: () => void;\r\n close: () => void;\r\n}\r\n\r\nexport type UseLayerChildren = React.ReactElement | ((props: UseLayerReturn) => React.ReactElement)\r\n\r\nconst useLayer = (children: UseLayerChildren, props?: UseLayerProps): UseLayerReturn => {\r\n const [open, setOpen] = useState(false)\r\n const portalProps = props?.slotProps?.portal || {}\r\n const portal = usePortal(<Layer\r\n blur={20}\r\n {...props}\r\n open={open}\r\n onClosed={() => {\r\n portal.unmount()\r\n if (props?.onClosed) {\r\n props.onClosed()\r\n }\r\n }}\r\n onClickOutside={() => {\r\n if (props?.onClickOutside) {\r\n props.onClickOutside()\r\n } else {\r\n setOpen(false)\r\n }\r\n }}\r\n >\r\n {typeof children === \"function\" ? children({ open: () => setOpen(true), close: () => setOpen(false) }) : children}\r\n </Layer>, portalProps)\r\n\r\n return {\r\n open: () => {\r\n portal.mount()\r\n setOpen(true)\r\n },\r\n close: () => {\r\n setOpen(false)\r\n },\r\n }\r\n}\r\n\r\nexport default useLayer"],"names":[],"mappings":";;;;;;AAoBA;;;AAEG;;;;;;AAUG;;;;;;;AAOA;;;;;;;;;;AAcN;;"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var tslib = require('tslib');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var index = require('../useLayer/index.cjs');
|
|
7
|
+
var core = require('@xanui/core');
|
|
8
|
+
|
|
9
|
+
const useModal = (children, props) => {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
let sizes = {
|
|
12
|
+
xs: 420,
|
|
13
|
+
sm: 760,
|
|
14
|
+
md: 990,
|
|
15
|
+
lg: 1120,
|
|
16
|
+
xl: 1300,
|
|
17
|
+
full: "100%"
|
|
18
|
+
};
|
|
19
|
+
let _c = props || {}, { size, slotProps } = _c, useLayerProps = tslib.__rest(_c, ["size", "slotProps"]);
|
|
20
|
+
size = size !== null && size !== void 0 ? size : "xs";
|
|
21
|
+
slotProps = slotProps || {};
|
|
22
|
+
const root = (slotProps === null || slotProps === void 0 ? void 0 : slotProps.root) || {};
|
|
23
|
+
const layer = index(() => {
|
|
24
|
+
return (jsxRuntime.jsx(core.Tag, Object.assign({}, root, { sxr: Object.assign({ maxWidth: sizes[size] || size, width: "100%", radius: 2, bgcolor: "background.primary", shadow: 15 }, root === null || root === void 0 ? void 0 : root.sx), baseClass: 'modal', children: typeof children === "function" ? children({ open: layer.open, close: layer.close }) : children })));
|
|
25
|
+
}, Object.assign(Object.assign({}, useLayerProps), { onClickOutside: () => {
|
|
26
|
+
if (props === null || props === void 0 ? void 0 : props.onClickOutside) {
|
|
27
|
+
props.onClickOutside();
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
layer.close();
|
|
31
|
+
}
|
|
32
|
+
}, slotProps: Object.assign(Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.layer), { clickOutside: Object.assign({ maxWidth: sizes[size] || size, width: "100%" }, (_a = slotProps === null || slotProps === void 0 ? void 0 : slotProps.layer) === null || _a === void 0 ? void 0 : _a.clickOutside), root: Object.assign({ display: "flex", alignItems: 'center', justifyContent: "center" }, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.layer) === null || _b === void 0 ? void 0 : _b.root) }) }));
|
|
33
|
+
return layer;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
module.exports = useModal;
|
|
37
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/useModal/index.tsx"],"sourcesContent":["'use client'\r\n\r\nimport useLayer, { UseLayerProps } from \"../useLayer\";\r\nimport { Tag, TagProps } from '@xanui/core'\r\n\r\nexport type UseModalProps = Omit<UseLayerProps, \"slotProps\"> & {\r\n size?: \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\" | number;\r\n slotProps?: {\r\n layer?: UseLayerProps['slotProps'];\r\n root?: Omit<TagProps<'div'>, \"children\">\r\n }\r\n}\r\n\r\nexport type UseModalChildren = React.ReactElement | ((props: UseModalReturn) => React.ReactElement)\r\n\r\nexport type UseModalReturn = {\r\n open: () => void;\r\n close: () => void;\r\n}\r\n\r\nconst useModal = (children: UseModalChildren, props?: UseModalProps) => {\r\n\r\n let sizes: any = {\r\n xs: 420,\r\n sm: 760,\r\n md: 990,\r\n lg: 1120,\r\n xl: 1300,\r\n full: \"100%\"\r\n }\r\n let { size, slotProps, ...useLayerProps } = props || {}\r\n size = size ?? \"xs\"\r\n slotProps = slotProps || {} as any\r\n const root: any = slotProps?.root || {}\r\n\r\n const layer = useLayer(() => {\r\n return (\r\n <Tag\r\n {...root}\r\n sxr={{\r\n maxWidth: sizes[size as any] || size,\r\n width: \"100%\",\r\n radius: 2,\r\n bgcolor: \"background.primary\",\r\n shadow: 15,\r\n ...root?.sx\r\n }}\r\n baseClass='modal'\r\n >\r\n {typeof children === \"function\" ? children({ open: layer.open, close: layer.close }) : children}\r\n </Tag>\r\n )\r\n }, {\r\n ...useLayerProps,\r\n onClickOutside: () => {\r\n if (props?.onClickOutside) {\r\n props.onClickOutside()\r\n } else {\r\n layer.close()\r\n }\r\n },\r\n slotProps: {\r\n ...slotProps?.layer,\r\n clickOutside: {\r\n maxWidth: sizes[size as any] || size,\r\n width: \"100%\",\r\n ...slotProps?.layer?.clickOutside,\r\n },\r\n root: {\r\n display: \"flex\",\r\n alignItems: 'center',\r\n justifyContent: \"center\",\r\n ...slotProps?.layer?.root,\r\n }\r\n }\r\n })\r\n\r\n return layer\r\n}\r\n\r\nexport default useModal;"],"names":[],"mappings":";;;;;;;;AAoBA;;AAEG;AACG;AACA;AACA;AACA;AACA;AACA;;AAEH;;AAEA;AACA;AAEA;AACG;AAgBH;;;;;;;AAQG;AAiBH;AACH;;"}
|
package/useModal/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var index = require('../useLayer/index.js');
|
|
7
|
-
var core = require('@xanui/core');
|
|
2
|
+
import { __rest } from 'tslib';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import useLayer from '../useLayer/index.js';
|
|
5
|
+
import { Tag } from '@xanui/core';
|
|
8
6
|
|
|
9
7
|
const useModal = (children, props) => {
|
|
10
8
|
var _a, _b;
|
|
@@ -16,12 +14,12 @@ const useModal = (children, props) => {
|
|
|
16
14
|
xl: 1300,
|
|
17
15
|
full: "100%"
|
|
18
16
|
};
|
|
19
|
-
let _c = props || {}, { size, slotProps } = _c, useLayerProps =
|
|
17
|
+
let _c = props || {}, { size, slotProps } = _c, useLayerProps = __rest(_c, ["size", "slotProps"]);
|
|
20
18
|
size = size !== null && size !== void 0 ? size : "xs";
|
|
21
19
|
slotProps = slotProps || {};
|
|
22
20
|
const root = (slotProps === null || slotProps === void 0 ? void 0 : slotProps.root) || {};
|
|
23
|
-
const layer =
|
|
24
|
-
return (
|
|
21
|
+
const layer = useLayer(() => {
|
|
22
|
+
return (jsx(Tag, Object.assign({}, root, { sxr: Object.assign({ maxWidth: sizes[size] || size, width: "100%", radius: 2, bgcolor: "background.primary", shadow: 15 }, root === null || root === void 0 ? void 0 : root.sx), baseClass: 'modal', children: typeof children === "function" ? children({ open: layer.open, close: layer.close }) : children })));
|
|
25
23
|
}, Object.assign(Object.assign({}, useLayerProps), { onClickOutside: () => {
|
|
26
24
|
if (props === null || props === void 0 ? void 0 : props.onClickOutside) {
|
|
27
25
|
props.onClickOutside();
|
|
@@ -33,5 +31,5 @@ const useModal = (children, props) => {
|
|
|
33
31
|
return layer;
|
|
34
32
|
};
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
export { useModal as default };
|
|
37
35
|
//# sourceMappingURL=index.js.map
|
package/useModal/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/useModal/index.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useModal/index.tsx"],"sourcesContent":["'use client'\r\n\r\nimport useLayer, { UseLayerProps } from \"../useLayer\";\r\nimport { Tag, TagProps } from '@xanui/core'\r\n\r\nexport type UseModalProps = Omit<UseLayerProps, \"slotProps\"> & {\r\n size?: \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\" | number;\r\n slotProps?: {\r\n layer?: UseLayerProps['slotProps'];\r\n root?: Omit<TagProps<'div'>, \"children\">\r\n }\r\n}\r\n\r\nexport type UseModalChildren = React.ReactElement | ((props: UseModalReturn) => React.ReactElement)\r\n\r\nexport type UseModalReturn = {\r\n open: () => void;\r\n close: () => void;\r\n}\r\n\r\nconst useModal = (children: UseModalChildren, props?: UseModalProps) => {\r\n\r\n let sizes: any = {\r\n xs: 420,\r\n sm: 760,\r\n md: 990,\r\n lg: 1120,\r\n xl: 1300,\r\n full: \"100%\"\r\n }\r\n let { size, slotProps, ...useLayerProps } = props || {}\r\n size = size ?? \"xs\"\r\n slotProps = slotProps || {} as any\r\n const root: any = slotProps?.root || {}\r\n\r\n const layer = useLayer(() => {\r\n return (\r\n <Tag\r\n {...root}\r\n sxr={{\r\n maxWidth: sizes[size as any] || size,\r\n width: \"100%\",\r\n radius: 2,\r\n bgcolor: \"background.primary\",\r\n shadow: 15,\r\n ...root?.sx\r\n }}\r\n baseClass='modal'\r\n >\r\n {typeof children === \"function\" ? children({ open: layer.open, close: layer.close }) : children}\r\n </Tag>\r\n )\r\n }, {\r\n ...useLayerProps,\r\n onClickOutside: () => {\r\n if (props?.onClickOutside) {\r\n props.onClickOutside()\r\n } else {\r\n layer.close()\r\n }\r\n },\r\n slotProps: {\r\n ...slotProps?.layer,\r\n clickOutside: {\r\n maxWidth: sizes[size as any] || size,\r\n width: \"100%\",\r\n ...slotProps?.layer?.clickOutside,\r\n },\r\n root: {\r\n display: \"flex\",\r\n alignItems: 'center',\r\n justifyContent: \"center\",\r\n ...slotProps?.layer?.root,\r\n }\r\n }\r\n })\r\n\r\n return layer\r\n}\r\n\r\nexport default useModal;"],"names":[],"mappings":";;;;;;AAoBA;;AAEG;AACG;AACA;AACA;AACA;AACA;AACA;;AAEH;;AAEA;AACA;AAEA;AACG;AAgBH;;;;;;;AAQG;AAiBH;AACH;;"}
|