@xanui/ui 1.1.8 → 1.1.10
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.js → index.cjs} +17 -3
- package/Accordion/index.cjs.map +1 -0
- package/Accordion/index.mjs +14 -2
- package/Accordion/index.mjs.map +1 -1
- package/Alert/{index.js → index.cjs} +23 -5
- package/Alert/index.cjs.map +1 -0
- package/Alert/index.mjs +18 -2
- package/Alert/index.mjs.map +1 -1
- package/Avatar/{index.js → index.cjs} +13 -2
- package/Avatar/index.cjs.map +1 -0
- package/Avatar/index.mjs +11 -2
- package/Avatar/index.mjs.map +1 -1
- package/Badge/{index.js → index.cjs} +12 -2
- package/Badge/index.cjs.map +1 -0
- package/Badge/index.mjs +10 -2
- package/Badge/index.mjs.map +1 -1
- package/Box/index.cjs +14 -0
- package/Box/index.cjs.map +1 -0
- package/Box/index.mjs +10 -2
- package/Box/index.mjs.map +1 -1
- package/Button/{index.js → index.cjs} +16 -4
- package/Button/index.cjs.map +1 -0
- package/Button/index.mjs +12 -2
- package/Button/index.mjs.map +1 -1
- package/ButtonGroup/{index.js → index.cjs} +12 -2
- package/ButtonGroup/index.cjs.map +1 -0
- package/ButtonGroup/index.mjs +10 -2
- package/ButtonGroup/index.mjs.map +1 -1
- package/Calendar/{index.js → index.cjs} +34 -16
- package/Calendar/index.cjs.map +1 -0
- package/Calendar/index.mjs +18 -2
- package/Calendar/index.mjs.map +1 -1
- package/CalendarInput/index.cjs +29 -0
- package/CalendarInput/index.cjs.map +1 -0
- package/CalendarInput/index.mjs +18 -2
- package/CalendarInput/index.mjs.map +1 -1
- package/Checkbox/{index.js → index.cjs} +15 -2
- package/Checkbox/index.cjs.map +1 -0
- package/Checkbox/index.mjs +13 -2
- package/Checkbox/index.mjs.map +1 -1
- package/Chip/{index.js → index.cjs} +14 -3
- package/Chip/index.cjs.map +1 -0
- package/Chip/index.mjs +11 -2
- package/Chip/index.mjs.map +1 -1
- package/CircleProgress/{index.js → index.cjs} +12 -2
- package/CircleProgress/index.cjs.map +1 -0
- package/CircleProgress/index.mjs +10 -2
- package/CircleProgress/index.mjs.map +1 -1
- package/ClickOutside/{index.js → index.cjs} +15 -6
- package/ClickOutside/index.cjs.map +1 -0
- package/ClickOutside/index.d.ts +4 -3
- package/ClickOutside/index.mjs +13 -6
- package/ClickOutside/index.mjs.map +1 -1
- package/Collaps/{index.js → index.cjs} +14 -4
- package/Collaps/index.cjs.map +1 -0
- package/Collaps/index.mjs +12 -4
- package/Collaps/index.mjs.map +1 -1
- package/Container/{index.js → index.cjs} +12 -2
- package/Container/index.cjs.map +1 -0
- package/Container/index.mjs +10 -2
- package/Container/index.mjs.map +1 -1
- package/Datatable/FilterBox.cjs +33 -0
- package/Datatable/FilterBox.cjs.map +1 -0
- package/Datatable/FilterBox.mjs +14 -2
- package/Datatable/FilterBox.mjs.map +1 -1
- package/Datatable/{Row.js → Row.cjs} +24 -7
- package/Datatable/Row.cjs.map +1 -0
- package/Datatable/Row.mjs +17 -2
- package/Datatable/Row.mjs.map +1 -1
- package/Datatable/SelectedBox.cjs +22 -0
- package/Datatable/SelectedBox.cjs.map +1 -0
- package/Datatable/SelectedBox.mjs +11 -2
- package/Datatable/SelectedBox.mjs.map +1 -1
- package/Datatable/Table.cjs +22 -0
- package/Datatable/Table.cjs.map +1 -0
- package/Datatable/Table.mjs +11 -2
- package/Datatable/Table.mjs.map +1 -1
- package/Datatable/{TableHead.js → TableHead.cjs} +18 -5
- package/Datatable/TableHead.cjs.map +1 -0
- package/Datatable/TableHead.mjs +13 -2
- package/Datatable/TableHead.mjs.map +1 -1
- package/Datatable/index.cjs +50 -0
- package/Datatable/index.cjs.map +1 -0
- package/Datatable/index.mjs +15 -2
- package/Datatable/index.mjs.map +1 -1
- package/Divider/{index.js → index.cjs} +12 -2
- package/Divider/index.cjs.map +1 -0
- package/Divider/index.mjs +10 -2
- package/Divider/index.mjs.map +1 -1
- package/Drawer/{index.js → index.cjs} +17 -6
- package/Drawer/index.cjs.map +1 -0
- package/Drawer/index.mjs +13 -4
- package/Drawer/index.mjs.map +1 -1
- package/Form/{index.js → index.cjs} +12 -2
- package/Form/index.cjs.map +1 -0
- package/Form/index.mjs +10 -2
- package/Form/index.mjs.map +1 -1
- package/GridContainer/{index.js → index.cjs} +12 -2
- package/GridContainer/index.cjs.map +1 -0
- package/GridContainer/index.mjs +10 -2
- package/GridContainer/index.mjs.map +1 -1
- package/GridItem/{index.js → index.cjs} +12 -2
- package/GridItem/index.cjs.map +1 -0
- package/GridItem/index.mjs +10 -2
- package/GridItem/index.mjs.map +1 -1
- package/IconButton/{index.js → index.cjs} +14 -3
- package/IconButton/index.cjs.map +1 -0
- package/IconButton/index.mjs +11 -2
- package/IconButton/index.mjs.map +1 -1
- package/Image/{index.js → index.cjs} +12 -2
- package/Image/index.cjs.map +1 -0
- package/Image/index.mjs +10 -2
- package/Image/index.mjs.map +1 -1
- package/Input/{index.js → index.cjs} +17 -6
- package/Input/index.cjs.map +1 -0
- package/Input/index.mjs +14 -5
- package/Input/index.mjs.map +1 -1
- package/Label/{index.js → index.cjs} +12 -2
- package/Label/index.cjs.map +1 -0
- package/Label/index.mjs +10 -2
- package/Label/index.mjs.map +1 -1
- package/Layer/{index.js → index.cjs} +20 -7
- package/Layer/index.cjs.map +1 -0
- package/Layer/index.mjs +17 -6
- package/Layer/index.mjs.map +1 -1
- package/LineProgress/{index.js → index.cjs} +12 -2
- package/LineProgress/index.cjs.map +1 -0
- package/LineProgress/index.mjs +10 -2
- package/LineProgress/index.mjs.map +1 -1
- package/List/{index.js → index.cjs} +12 -2
- package/List/index.cjs.map +1 -0
- package/List/index.mjs +10 -2
- package/List/index.mjs.map +1 -1
- package/ListItem/{index.js → index.cjs} +14 -3
- package/ListItem/index.cjs.map +1 -0
- package/ListItem/index.mjs +11 -2
- package/ListItem/index.mjs.map +1 -1
- package/LoadingBox/{index.js → index.cjs} +14 -3
- package/LoadingBox/index.cjs.map +1 -0
- package/LoadingBox/index.mjs +11 -2
- package/LoadingBox/index.mjs.map +1 -1
- package/Menu/index.cjs +145 -0
- package/Menu/index.cjs.map +1 -0
- package/Menu/index.d.ts +4 -4
- package/Menu/index.mjs +125 -29
- package/Menu/index.mjs.map +1 -1
- package/Modal/{index.js → index.cjs} +14 -3
- package/Modal/index.cjs.map +1 -0
- package/Modal/index.mjs +11 -2
- package/Modal/index.mjs.map +1 -1
- package/NoSSR/index.cjs +14 -0
- package/NoSSR/index.cjs.map +1 -0
- package/NoSSR/index.mjs +7 -2
- package/NoSSR/index.mjs.map +1 -1
- package/Option/index.cjs +14 -0
- package/Option/index.cjs.map +1 -0
- package/Option/index.mjs +10 -2
- package/Option/index.mjs.map +1 -1
- package/Paper/{index.js → index.cjs} +12 -2
- package/Paper/index.cjs.map +1 -0
- package/Paper/index.mjs +10 -2
- package/Paper/index.mjs.map +1 -1
- package/Portal/index.cjs +26 -0
- package/Portal/index.cjs.map +1 -0
- package/Portal/index.d.ts +1 -2
- package/Portal/index.mjs +18 -13
- package/Portal/index.mjs.map +1 -1
- package/Radio/index.cjs +16 -0
- package/Radio/index.cjs.map +1 -0
- package/Radio/index.mjs +12 -2
- package/Radio/index.mjs.map +1 -1
- package/Scrollbar/{index.js → index.cjs} +12 -2
- package/Scrollbar/index.cjs.map +1 -0
- package/Scrollbar/index.mjs +10 -2
- package/Scrollbar/index.mjs.map +1 -1
- package/Select/{index.js → index.cjs} +21 -5
- package/Select/index.cjs.map +1 -0
- package/Select/index.mjs +16 -2
- package/Select/index.mjs.map +1 -1
- package/Stack/index.cjs +17 -0
- package/Stack/index.cjs.map +1 -0
- package/Stack/index.mjs +10 -2
- package/Stack/index.mjs.map +1 -1
- package/Switch/{index.js → index.cjs} +12 -2
- package/Switch/index.cjs.map +1 -0
- package/Switch/index.mjs +10 -2
- package/Switch/index.mjs.map +1 -1
- package/Tab/index.cjs +16 -0
- package/Tab/index.cjs.map +1 -0
- package/Tab/index.mjs +11 -2
- package/Tab/index.mjs.map +1 -1
- package/Table/{index.js → index.cjs} +14 -3
- package/Table/index.cjs.map +1 -0
- package/Table/index.mjs +11 -2
- package/Table/index.mjs.map +1 -1
- package/TableBody/index.cjs +14 -0
- package/TableBody/index.cjs.map +1 -0
- package/TableBody/index.mjs +10 -2
- package/TableBody/index.mjs.map +1 -1
- package/TableCell/{index.js → index.cjs} +12 -2
- package/TableCell/index.cjs.map +1 -0
- package/TableCell/index.mjs +10 -2
- package/TableCell/index.mjs.map +1 -1
- package/TableFooter/index.cjs +14 -0
- package/TableFooter/index.cjs.map +1 -0
- package/TableFooter/index.mjs +10 -2
- package/TableFooter/index.mjs.map +1 -1
- package/TableHead/index.cjs +14 -0
- package/TableHead/index.cjs.map +1 -0
- package/TableHead/index.mjs +10 -2
- package/TableHead/index.mjs.map +1 -1
- package/TablePagination/{index.js → index.cjs} +22 -6
- package/TablePagination/index.cjs.map +1 -0
- package/TablePagination/index.mjs +16 -2
- package/TablePagination/index.mjs.map +1 -1
- package/TableRow/index.cjs +14 -0
- package/TableRow/index.cjs.map +1 -0
- package/TableRow/index.mjs +10 -2
- package/TableRow/index.mjs.map +1 -1
- package/Tabs/{index.js → index.cjs} +13 -3
- package/Tabs/index.cjs.map +1 -0
- package/Tabs/index.mjs +11 -3
- package/Tabs/index.mjs.map +1 -1
- package/Text/{index.js → index.cjs} +12 -2
- package/Text/index.cjs.map +1 -0
- package/Text/index.mjs +10 -2
- package/Text/index.mjs.map +1 -1
- package/Toast/{index.js → index.cjs} +17 -4
- package/Toast/index.cjs.map +1 -0
- package/Toast/index.mjs +13 -2
- package/Toast/index.mjs.map +1 -1
- package/Tooltip/{index.js → index.cjs} +14 -4
- package/Tooltip/index.cjs.map +1 -0
- package/Tooltip/index.mjs +11 -3
- package/Tooltip/index.mjs.map +1 -1
- package/ViewBox/{index.js → index.cjs} +14 -3
- package/ViewBox/index.cjs.map +1 -0
- package/ViewBox/index.mjs +11 -2
- package/ViewBox/index.mjs.map +1 -1
- package/index.cjs +116 -0
- package/index.cjs.map +1 -0
- package/index.mjs +56 -1
- package/index.mjs.map +1 -1
- package/package.json +4 -14
- package/readme.md +104 -104
- package/useAlert/{index.js → index.cjs} +18 -5
- package/useAlert/index.cjs.map +1 -0
- package/useAlert/index.d.ts +2 -2
- package/useAlert/index.mjs +13 -2
- package/useAlert/index.mjs.map +1 -1
- package/useBlurCss/{index.js → index.cjs} +10 -2
- package/useBlurCss/index.cjs.map +1 -0
- package/useBlurCss/index.mjs +8 -2
- package/useBlurCss/index.mjs.map +1 -1
- package/useCorner/{index.js → index.cjs} +7 -2
- package/useCorner/index.cjs.map +1 -0
- package/useCorner/index.mjs +4 -1
- package/useCorner/index.mjs.map +1 -1
- package/useLayer/{index.js → index.cjs} +13 -3
- package/useLayer/index.cjs.map +1 -0
- package/useLayer/index.mjs +10 -2
- package/useLayer/index.mjs.map +1 -1
- package/useModal/{index.js → index.cjs} +13 -3
- package/useModal/index.cjs.map +1 -0
- package/useModal/index.mjs +10 -2
- package/useModal/index.mjs.map +1 -1
- package/Accordion/index.js.map +0 -1
- package/Alert/index.js.map +0 -1
- package/Avatar/index.js.map +0 -1
- package/Badge/index.js.map +0 -1
- package/Box/index.js +0 -4
- package/Box/index.js.map +0 -1
- package/Button/index.js.map +0 -1
- package/ButtonGroup/index.js.map +0 -1
- package/Calendar/index.js.map +0 -1
- package/CalendarInput/index.js +0 -11
- package/CalendarInput/index.js.map +0 -1
- package/Checkbox/index.js.map +0 -1
- package/Chip/index.js.map +0 -1
- package/CircleProgress/index.js.map +0 -1
- package/ClickOutside/index.js.map +0 -1
- package/Collaps/index.js.map +0 -1
- package/Container/index.js.map +0 -1
- package/Datatable/FilterBox.js +0 -19
- package/Datatable/FilterBox.js.map +0 -1
- package/Datatable/Row.js.map +0 -1
- package/Datatable/SelectedBox.js +0 -11
- package/Datatable/SelectedBox.js.map +0 -1
- package/Datatable/Table.js +0 -11
- package/Datatable/Table.js.map +0 -1
- package/Datatable/TableHead.js.map +0 -1
- package/Datatable/index.js +0 -35
- package/Datatable/index.js.map +0 -1
- package/Divider/index.js.map +0 -1
- package/Drawer/index.js.map +0 -1
- package/Form/index.js.map +0 -1
- package/GridContainer/index.js.map +0 -1
- package/GridItem/index.js.map +0 -1
- package/IconButton/index.js.map +0 -1
- package/Image/index.js.map +0 -1
- package/Input/index.js.map +0 -1
- package/Label/index.js.map +0 -1
- package/Layer/index.js.map +0 -1
- package/LineProgress/index.js.map +0 -1
- package/List/index.js.map +0 -1
- package/ListItem/index.js.map +0 -1
- package/LoadingBox/index.js.map +0 -1
- package/Menu/getOrigin.js +0 -42
- package/Menu/getOrigin.js.map +0 -1
- package/Menu/getOrigin.mjs +0 -42
- package/Menu/getOrigin.mjs.map +0 -1
- package/Menu/index.js +0 -47
- package/Menu/index.js.map +0 -1
- package/Menu/placedMenu.d.ts +0 -5
- package/Menu/placedMenu.js +0 -95
- package/Menu/placedMenu.js.map +0 -1
- package/Menu/placedMenu.mjs +0 -95
- package/Menu/placedMenu.mjs.map +0 -1
- package/Modal/index.js.map +0 -1
- package/NoSSR/index.js +0 -7
- package/NoSSR/index.js.map +0 -1
- package/Option/index.js +0 -4
- package/Option/index.js.map +0 -1
- package/Paper/index.js.map +0 -1
- package/Portal/index.js +0 -19
- package/Portal/index.js.map +0 -1
- package/Radio/index.js +0 -4
- package/Radio/index.js.map +0 -1
- package/Scrollbar/index.js.map +0 -1
- package/Select/index.js.map +0 -1
- package/Stack/index.js +0 -7
- package/Stack/index.js.map +0 -1
- package/Switch/index.js.map +0 -1
- package/Tab/index.js +0 -5
- package/Tab/index.js.map +0 -1
- package/Table/index.js.map +0 -1
- package/TableBody/index.js +0 -4
- package/TableBody/index.js.map +0 -1
- package/TableCell/index.js.map +0 -1
- package/TableFooter/index.js +0 -4
- package/TableFooter/index.js.map +0 -1
- package/TableHead/index.js +0 -4
- package/TableHead/index.js.map +0 -1
- package/TablePagination/index.js.map +0 -1
- package/TableRow/index.js +0 -4
- package/TableRow/index.js.map +0 -1
- package/Tabs/index.js.map +0 -1
- package/Text/index.js.map +0 -1
- package/Toast/index.js.map +0 -1
- package/Tooltip/index.js.map +0 -1
- package/ViewBox/index.js.map +0 -1
- package/index.js +0 -1
- package/index.js.map +0 -1
- package/useAlert/index.js.map +0 -1
- package/useBlurCss/index.js.map +0 -1
- package/useCorner/index.js.map +0 -1
- package/useLayer/index.js.map +0 -1
- package/useModal/index.js.map +0 -1
package/Menu/index.mjs
CHANGED
|
@@ -1,4 +1,96 @@
|
|
|
1
|
-
import {__rest
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useRef, useEffect } from 'react';
|
|
4
|
+
import { useInterface, useBreakpointProps, Transition, Tag } from '@xanui/core';
|
|
5
|
+
import Portal from '../Portal/index.mjs';
|
|
6
|
+
import ClickOutside from '../ClickOutside/index.mjs';
|
|
7
|
+
|
|
8
|
+
const placements = [
|
|
9
|
+
"top",
|
|
10
|
+
"top-left",
|
|
11
|
+
"top-right",
|
|
12
|
+
"bottom",
|
|
13
|
+
"bottom-left",
|
|
14
|
+
"bottom-right",
|
|
15
|
+
"right",
|
|
16
|
+
"right-top",
|
|
17
|
+
"right-bottom",
|
|
18
|
+
"left",
|
|
19
|
+
"left-top",
|
|
20
|
+
"left-bottom",
|
|
21
|
+
];
|
|
22
|
+
const getTransformOrigin = (placement) => {
|
|
23
|
+
switch (placement) {
|
|
24
|
+
case "top":
|
|
25
|
+
return "bottom";
|
|
26
|
+
case "top-left":
|
|
27
|
+
return "bottom left";
|
|
28
|
+
case "top-right":
|
|
29
|
+
return "bottom right";
|
|
30
|
+
case "bottom":
|
|
31
|
+
return "top";
|
|
32
|
+
case "bottom-left":
|
|
33
|
+
return "top left";
|
|
34
|
+
case "bottom-right":
|
|
35
|
+
return "top right";
|
|
36
|
+
case "left":
|
|
37
|
+
return "right";
|
|
38
|
+
case "left-top":
|
|
39
|
+
return "top right";
|
|
40
|
+
case "left-bottom":
|
|
41
|
+
return "bottom right";
|
|
42
|
+
case "right":
|
|
43
|
+
return "left";
|
|
44
|
+
case "right-top":
|
|
45
|
+
return "top left";
|
|
46
|
+
case "right-bottom":
|
|
47
|
+
return "bottom left";
|
|
48
|
+
default:
|
|
49
|
+
return "top";
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
// Compute coordinates for each placement
|
|
53
|
+
const computePosition = (placement, menu, target) => {
|
|
54
|
+
const { width: mw, height: mh } = menu.getBoundingClientRect();
|
|
55
|
+
const { top: tt, left: tl, bottom: tb, right: tr, width: tw, height: th, } = target.getBoundingClientRect();
|
|
56
|
+
const positions = {
|
|
57
|
+
"bottom-left": { top: tb, left: tl },
|
|
58
|
+
"bottom-right": { top: tb, left: tr - mw },
|
|
59
|
+
bottom: { top: tb, left: tl + (tw - mw) / 2 },
|
|
60
|
+
"top-left": { top: tt - mh, left: tl },
|
|
61
|
+
"top-right": { top: tt - mh, left: tr - mw },
|
|
62
|
+
top: { top: tt - mh, left: tl + (tw - mw) / 2 },
|
|
63
|
+
left: { top: tt + (th - mh) / 2, left: tl - mw },
|
|
64
|
+
"left-top": { top: tt, left: tl - mw },
|
|
65
|
+
"left-bottom": { top: tb - mh, left: tl - mw },
|
|
66
|
+
right: { top: tt + (th - mh) / 2, left: tr },
|
|
67
|
+
"right-top": { top: tt, left: tr },
|
|
68
|
+
"right-bottom": { top: tb - mh, left: tr },
|
|
69
|
+
};
|
|
70
|
+
return positions[placement];
|
|
71
|
+
};
|
|
72
|
+
// Check if menu is off-screen
|
|
73
|
+
const isOffScreen = (menu) => {
|
|
74
|
+
const { x, y, width, height } = menu.getBoundingClientRect();
|
|
75
|
+
return x < 0 || y < 0 || x + width > window.innerWidth || y + height > window.innerHeight;
|
|
76
|
+
};
|
|
77
|
+
// Try to place menu and fallback if off-screen
|
|
78
|
+
const placeMenu = (placement, menu, target) => {
|
|
79
|
+
let pos = computePosition(placement, menu, target);
|
|
80
|
+
menu.style.top = pos.top + "px";
|
|
81
|
+
menu.style.left = pos.left + "px";
|
|
82
|
+
if (isOffScreen(menu)) {
|
|
83
|
+
for (const p of placements) {
|
|
84
|
+
const fallbackPos = computePosition(p, menu, target);
|
|
85
|
+
menu.style.top = fallbackPos.top + "px";
|
|
86
|
+
menu.style.left = fallbackPos.left + "px";
|
|
87
|
+
if (!isOffScreen(menu))
|
|
88
|
+
return p;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return placement;
|
|
92
|
+
};
|
|
93
|
+
const Menu = (_a) => {
|
|
2
94
|
var _b;
|
|
3
95
|
var { children, target } = _a, props = __rest(_a, ["children", "target"]);
|
|
4
96
|
let [{ onClickOutside, placement, zIndex, slotProps }] = useInterface("Menu", props, {});
|
|
@@ -6,42 +98,46 @@ import {__rest}from'tslib';import {jsx,Fragment}from'react/jsx-runtime';import {
|
|
|
6
98
|
if (placement)
|
|
7
99
|
_p.placement = placement;
|
|
8
100
|
const p = useBreakpointProps(_p);
|
|
9
|
-
placement = p.placement;
|
|
101
|
+
placement = p.placement || "bottom-left";
|
|
10
102
|
const isOpen = Boolean(target);
|
|
11
103
|
const [closed, setClosed] = useState(!isOpen);
|
|
12
|
-
let id = "menu-" + useId().replace(":", "");
|
|
13
104
|
const [placed, setPlaced] = useState(placement);
|
|
14
|
-
|
|
105
|
+
const menuRef = useRef(null);
|
|
106
|
+
// Open/close effect
|
|
15
107
|
useEffect(() => {
|
|
16
|
-
if (closed && isOpen)
|
|
108
|
+
if (closed && isOpen)
|
|
17
109
|
setClosed(false);
|
|
18
|
-
}
|
|
19
110
|
}, [isOpen]);
|
|
20
111
|
useEffect(() => {
|
|
21
|
-
if (!closed) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
let p = placedMenu({
|
|
26
|
-
place: placement,
|
|
27
|
-
menu: ele,
|
|
28
|
-
target
|
|
29
|
-
});
|
|
112
|
+
if (!closed && target && menuRef.current) {
|
|
113
|
+
const updatePosition = () => {
|
|
114
|
+
if (menuRef.current && target) {
|
|
115
|
+
const p = placeMenu(placement, menuRef.current, target);
|
|
30
116
|
setPlaced(p);
|
|
31
117
|
}
|
|
32
|
-
}
|
|
118
|
+
};
|
|
119
|
+
updatePosition();
|
|
120
|
+
window.addEventListener("resize", updatePosition);
|
|
121
|
+
window.addEventListener("scroll", updatePosition, true);
|
|
122
|
+
return () => {
|
|
123
|
+
window.removeEventListener("resize", updatePosition);
|
|
124
|
+
window.removeEventListener("scroll", updatePosition, true);
|
|
125
|
+
};
|
|
33
126
|
}
|
|
34
|
-
|
|
127
|
+
return undefined;
|
|
128
|
+
}, [closed, target, placement]);
|
|
35
129
|
if (closed)
|
|
36
|
-
return
|
|
37
|
-
return (jsx(Portal, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.portal, { children: jsx(ClickOutside, { onClickOutside: () => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
130
|
+
return null;
|
|
131
|
+
return (jsx(Portal, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.portal, { children: jsx(ClickOutside, { onClickOutside: (e) => {
|
|
132
|
+
if (e.target !== target) {
|
|
133
|
+
onClickOutside && onClickOutside(e);
|
|
134
|
+
}
|
|
135
|
+
}, ref: menuRef, sx: { position: "fixed", zIndex: 1500 + (zIndex || 0) }, children: jsx(Transition, Object.assign({ duration: 200, easing: "fast", variant: "grow" }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.transition, { open: isOpen, onClosed: () => {
|
|
136
|
+
var _a, _b;
|
|
137
|
+
setClosed(true);
|
|
138
|
+
(_b = (_a = slotProps === null || slotProps === void 0 ? void 0 : slotProps.transition) === null || _a === void 0 ? void 0 : _a.onClosed) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
139
|
+
}, children: jsx(Tag, Object.assign({ baseClass: "menu-content" }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.content, { sxr: Object.assign({ overflow: "hidden", bgcolor: "background.primary", shadow: 2, radius: 1, transformOrigin: getTransformOrigin(placed) }, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.content) === null || _b === void 0 ? void 0 : _b.sx), children: children })) })) }) })));
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export { Menu as default };
|
|
143
|
+
//# sourceMappingURL=index.mjs.map
|
package/Menu/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/Menu/index.tsx"],"sourcesContent":["import { ReactNode, useEffect, useId, useState } from 'react'\nimport { Tag, TagProps, useBreakpointProps, useBreakpointPropsType, useInterface, TransitionProps, Transition } from \"@xanui/core\"\nimport { placedMenu, PlacementTypes } from \"./placedMenu\";\nimport Portal, { PortalProps } from \"../Portal\";\nimport { getOrigin } from './getOrigin';\nimport ClickOutside from '../ClickOutside';\n\n\nexport type MenuProps = {\n children?: ReactNode;\n target?: HTMLElement;\n placement?: useBreakpointPropsType<PlacementTypes>;\n zIndex?: number;\n onClickOutside?: () => void;\n slotProps?: {\n transition?: Omit<TransitionProps, \"open\">;\n portal?: Omit<PortalProps, \"children\">;\n content?: Omit<TagProps<\"div\">, \"children\">;\n }\n}\n\nconst Menu = ({ children, target, ...props }: MenuProps) => {\n let [{ onClickOutside, placement, zIndex, slotProps }] = useInterface<any>(\"Menu\", props, {})\n const _p: any = {}\n if (placement) _p.placement = placement\n const p: any = useBreakpointProps(_p)\n placement = p.placement\n\n const isOpen = Boolean(target)\n const [closed, setClosed] = useState(!isOpen)\n let id = \"menu-\" + useId().replace(\":\", \"\")\n const [placed, setPlaced] = useState<any>(placement)\n placement = placement || \"bottom-left\"\n\n useEffect(() => {\n if (closed && isOpen) {\n setClosed(false)\n }\n }, [isOpen])\n\n useEffect(() => {\n if (!closed) {\n setTimeout(() => {\n const ele = document.getElementById(id)\n if (target && ele) {\n let p = placedMenu({\n place: placement as any,\n menu: ele,\n target\n })\n setPlaced(p)\n }\n }, 1);\n }\n }, [closed])\n\n if (closed) return <></>\n\n return (\n <Portal {...slotProps?.portal}>\n <ClickOutside\n onClickOutside={() => {\n onClickOutside && onClickOutside()\n }}\n >\n <Tag\n baseClass=\"menu\"\n id={id}\n sx={{\n position: \"fixed\",\n zIndex: 1500 + (zIndex || 0)\n }}\n >\n <Transition\n duration={200}\n easing=\"easeInOut\"\n variant=\"grow\"\n {...slotProps?.transition}\n open={isOpen}\n onClosed={() => {\n setClosed(true)\n slotProps?.transition?.onClosed && slotProps?.transition?.onClosed()\n }}\n >\n <Tag\n baseClass='menu-content'\n {...slotProps?.content}\n sxr={{\n overflow: \"hidden\",\n bgcolor: \"background.primary\",\n shadow: 10,\n radius: 1,\n transformOrigin: getOrigin(placed) || \"top\",\n ...slotProps?.content?.sx\n }}\n >\n {children}\n </Tag>\n </Transition>\n </Tag>\n </ClickOutside>\n </Portal>\n )\n}\n\nexport default Menu"],"names":["_jsx"],"mappings":"4WAqBA,MAAM,IAAI,GAAG,CAAC,EAAyC,KAAI;;QAA7C,EAAE,QAAQ,EAAE,MAAM,EAAA,GAAA,EAAuB,EAAlB,KAAK,GAAA,MAAA,CAAA,EAAA,EAA5B,sBAA8B,CAAF;IACtC,IAAI,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,YAAY,CAAM,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;IAC7F,MAAM,EAAE,GAAQ,EAAE;AAClB,IAAA,IAAI,SAAS;AAAE,QAAA,EAAE,CAAC,SAAS,GAAG,SAAS;AACvC,IAAA,MAAM,CAAC,GAAQ,kBAAkB,CAAC,EAAE,CAAC;AACrC,IAAA,SAAS,GAAG,CAAC,CAAC,SAAS;AAEvB,IAAA,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC9B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAA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,EAAA,KAAA,MAAA,GAAA,MAAA,GAAA,EAAA,CAAE,EAAE,CAAA,EAAA,QAAA,EAG5B,QAAQ,EAAA,CAAA,CACP,EAAA,CAAA,CACG,EAAA,CACX,EAAA,CACK,EAAA,CAAA,CACV;AAEjB"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/Menu/index.tsx"],"sourcesContent":["import { ReactNode, useEffect, useState, useRef } from \"react\";\r\nimport { Tag, TagProps, useBreakpointProps, useBreakpointPropsType, useInterface, TransitionProps, Transition } from \"@xanui/core\";\r\nimport Portal, { PortalProps } from \"../Portal\";\r\nimport ClickOutside from \"../ClickOutside\";\r\n\r\nexport type PlacementTypes =\r\n | \"top\"\r\n | \"top-left\"\r\n | \"top-right\"\r\n | \"bottom\"\r\n | \"bottom-left\"\r\n | \"bottom-right\"\r\n | \"right\"\r\n | \"right-top\"\r\n | \"right-bottom\"\r\n | \"left\"\r\n | \"left-top\"\r\n | \"left-bottom\";\r\n\r\nexport type MenuProps = {\r\n children?: ReactNode;\r\n target?: HTMLElement;\r\n placement?: useBreakpointPropsType<PlacementTypes>;\r\n zIndex?: number;\r\n onClickOutside?: (e: MouseEvent) => void;\r\n slotProps?: {\r\n transition?: Omit<TransitionProps, \"open\">;\r\n portal?: Omit<PortalProps, \"children\">;\r\n content?: Omit<TagProps<\"div\">, \"children\">;\r\n };\r\n};\r\n\r\nconst placements: PlacementTypes[] = [\r\n \"top\",\r\n \"top-left\",\r\n \"top-right\",\r\n \"bottom\",\r\n \"bottom-left\",\r\n \"bottom-right\",\r\n \"right\",\r\n \"right-top\",\r\n \"right-bottom\",\r\n \"left\",\r\n \"left-top\",\r\n \"left-bottom\",\r\n];\r\n\r\nconst getTransformOrigin = (placement: PlacementTypes) => {\r\n switch (placement) {\r\n case \"top\":\r\n return \"bottom\";\r\n case \"top-left\":\r\n return \"bottom left\";\r\n case \"top-right\":\r\n return \"bottom right\";\r\n case \"bottom\":\r\n return \"top\";\r\n case \"bottom-left\":\r\n return \"top left\";\r\n case \"bottom-right\":\r\n return \"top right\";\r\n case \"left\":\r\n return \"right\";\r\n case \"left-top\":\r\n return \"top right\";\r\n case \"left-bottom\":\r\n return \"bottom right\";\r\n case \"right\":\r\n return \"left\";\r\n case \"right-top\":\r\n return \"top left\";\r\n case \"right-bottom\":\r\n return \"bottom left\";\r\n default:\r\n return \"top\";\r\n }\r\n};\r\n\r\n// Compute coordinates for each placement\r\nconst computePosition = (\r\n placement: PlacementTypes,\r\n menu: HTMLElement,\r\n target: HTMLElement\r\n) => {\r\n const { width: mw, height: mh } = menu.getBoundingClientRect();\r\n const {\r\n top: tt,\r\n left: tl,\r\n bottom: tb,\r\n right: tr,\r\n width: tw,\r\n height: th,\r\n } = target.getBoundingClientRect();\r\n\r\n const positions: Record<PlacementTypes, { top: number; left: number }> = {\r\n \"bottom-left\": { top: tb, left: tl },\r\n \"bottom-right\": { top: tb, left: tr - mw },\r\n bottom: { top: tb, left: tl + (tw - mw) / 2 },\r\n\r\n \"top-left\": { top: tt - mh, left: tl },\r\n \"top-right\": { top: tt - mh, left: tr - mw },\r\n top: { top: tt - mh, left: tl + (tw - mw) / 2 },\r\n\r\n left: { top: tt + (th - mh) / 2, left: tl - mw },\r\n \"left-top\": { top: tt, left: tl - mw },\r\n \"left-bottom\": { top: tb - mh, left: tl - mw },\r\n\r\n right: { top: tt + (th - mh) / 2, left: tr },\r\n \"right-top\": { top: tt, left: tr },\r\n \"right-bottom\": { top: tb - mh, left: tr },\r\n };\r\n\r\n return positions[placement];\r\n};\r\n\r\n\r\n// Check if menu is off-screen\r\nconst isOffScreen = (menu: HTMLElement) => {\r\n const { x, y, width, height } = menu.getBoundingClientRect();\r\n return x < 0 || y < 0 || x + width > window.innerWidth || y + height > window.innerHeight;\r\n};\r\n\r\n// Try to place menu and fallback if off-screen\r\nconst placeMenu = (placement: PlacementTypes, menu: HTMLElement, target: HTMLElement) => {\r\n let pos = computePosition(placement, menu, target);\r\n menu.style.top = pos.top + \"px\";\r\n menu.style.left = pos.left + \"px\";\r\n\r\n if (isOffScreen(menu)) {\r\n for (const p of placements) {\r\n const fallbackPos = computePosition(p, menu, target);\r\n menu.style.top = fallbackPos.top + \"px\";\r\n menu.style.left = fallbackPos.left + \"px\";\r\n if (!isOffScreen(menu)) return p;\r\n }\r\n }\r\n return placement;\r\n};\r\n\r\nconst Menu = ({ children, target, ...props }: MenuProps) => {\r\n let [{ onClickOutside, placement, zIndex, slotProps }] = useInterface<any>(\"Menu\", props, {});\r\n const _p: any = {};\r\n if (placement) _p.placement = placement;\r\n const p: any = useBreakpointProps(_p);\r\n placement = p.placement || \"bottom-left\";\r\n\r\n const isOpen = Boolean(target);\r\n const [closed, setClosed] = useState(!isOpen);\r\n const [placed, setPlaced] = useState<PlacementTypes>(placement);\r\n const menuRef = useRef<HTMLDivElement>(null);\r\n\r\n // Open/close effect\r\n useEffect(() => {\r\n if (closed && isOpen) setClosed(false);\r\n }, [isOpen]);\r\n\r\n\r\n useEffect(() => {\r\n if (!closed && target && menuRef.current) {\r\n const updatePosition = () => {\r\n if (menuRef.current && target) {\r\n const p = placeMenu(placement!, menuRef.current, target);\r\n setPlaced(p);\r\n }\r\n };\r\n\r\n updatePosition();\r\n\r\n window.addEventListener(\"resize\", updatePosition);\r\n window.addEventListener(\"scroll\", updatePosition, true);\r\n\r\n return () => {\r\n window.removeEventListener(\"resize\", updatePosition);\r\n window.removeEventListener(\"scroll\", updatePosition, true);\r\n };\r\n }\r\n return undefined;\r\n }, [closed, target, placement]);\r\n\r\n if (closed) return null;\r\n\r\n return (\r\n <Portal {...slotProps?.portal}>\r\n <ClickOutside\r\n onClickOutside={(e: MouseEvent) => {\r\n if (e.target !== target) {\r\n onClickOutside && onClickOutside(e);\r\n }\r\n }}\r\n ref={menuRef}\r\n sx={{ position: \"fixed\", zIndex: 1500 + (zIndex || 0) }}\r\n >\r\n <Transition\r\n duration={200}\r\n easing=\"fast\"\r\n variant=\"grow\"\r\n {...slotProps?.transition}\r\n open={isOpen}\r\n onClosed={() => {\r\n setClosed(true);\r\n slotProps?.transition?.onClosed?.();\r\n }}\r\n >\r\n <Tag\r\n baseClass=\"menu-content\"\r\n {...slotProps?.content}\r\n sxr={{\r\n overflow: \"hidden\",\r\n bgcolor: \"background.primary\",\r\n shadow: 2,\r\n radius: 1,\r\n transformOrigin: getTransformOrigin(placed),\r\n ...slotProps?.content?.sx,\r\n }}\r\n >\r\n {children}\r\n </Tag>\r\n </Transition>\r\n </ClickOutside>\r\n </Portal>\r\n );\r\n};\r\n\r\nexport default Menu;\r\n"],"names":["_jsx"],"mappings":";;;;;;;AAgCA,MAAM,UAAU,GAAqB;IACjC,KAAK;IACL,UAAU;IACV,WAAW;IACX,QAAQ;IACR,aAAa;IACb,cAAc;IACd,OAAO;IACP,WAAW;IACX,cAAc;IACd,MAAM;IACN,UAAU;IACV,aAAa;CAChB;AAED,MAAM,kBAAkB,GAAG,CAAC,SAAyB,KAAI;IACrD,QAAQ,SAAS;AACb,QAAA,KAAK,KAAK;AACN,YAAA,OAAO,QAAQ;AACnB,QAAA,KAAK,UAAU;AACX,YAAA,OAAO,aAAa;AACxB,QAAA,KAAK,WAAW;AACZ,YAAA,OAAO,cAAc;AACzB,QAAA,KAAK,QAAQ;AACT,YAAA,OAAO,KAAK;AAChB,QAAA,KAAK,aAAa;AACd,YAAA,OAAO,UAAU;AACrB,QAAA,KAAK,cAAc;AACf,YAAA,OAAO,WAAW;AACtB,QAAA,KAAK,MAAM;AACP,YAAA,OAAO,OAAO;AAClB,QAAA,KAAK,UAAU;AACX,YAAA,OAAO,WAAW;AACtB,QAAA,KAAK,aAAa;AACd,YAAA,OAAO,cAAc;AACzB,QAAA,KAAK,OAAO;AACR,YAAA,OAAO,MAAM;AACjB,QAAA,KAAK,WAAW;AACZ,YAAA,OAAO,UAAU;AACrB,QAAA,KAAK,cAAc;AACf,YAAA,OAAO,aAAa;AACxB,QAAA;AACI,YAAA,OAAO,KAAK;;AAExB,CAAC;AAED;AACA,MAA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
-
'use strict';
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var index = require('../useModal/index.cjs');
|
|
7
|
+
var core = require('@xanui/core');
|
|
8
|
+
|
|
9
|
+
const Modal = (_a) => {
|
|
2
10
|
var { children, open } = _a, props = tslib.__rest(_a, ["children", "open"]);
|
|
3
11
|
const ref = React.useRef(null);
|
|
4
|
-
const modal = index
|
|
12
|
+
const modal = index(jsxRuntime.jsx(jsxRuntime.Fragment, { children: children }), Object.assign(Object.assign({}, props), { onClickOutside: () => {
|
|
5
13
|
if (props === null || props === void 0 ? void 0 : props.onClickOutside) {
|
|
6
14
|
props.onClickOutside();
|
|
7
15
|
}
|
|
@@ -44,4 +52,7 @@ Modal.open = (children, props) => {
|
|
|
44
52
|
};
|
|
45
53
|
Modal.close = () => {
|
|
46
54
|
core.Renderar.unrender(ActionModal);
|
|
47
|
-
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
module.exports = Modal;
|
|
58
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/Modal/index.tsx"],"sourcesContent":["import { ReactNode, useEffect, useRef } from \"react\";\r\nimport useModal, { UseModalProps } from \"../useModal\";\r\nimport { Renderar, Tag } from \"@xanui/core\";\r\n\r\nexport type ModalProps = UseModalProps & {\r\n children: ReactNode;\r\n open: boolean;\r\n}\r\n\r\nconst Modal = ({ children, open, ...props }: ModalProps) => {\r\n const ref = useRef<HTMLDivElement>(null);\r\n\r\n const modal = useModal(<>{children}</>, {\r\n ...props,\r\n onClickOutside: () => {\r\n if (props?.onClickOutside) {\r\n props.onClickOutside()\r\n }\r\n },\r\n slotProps: {\r\n layer: {\r\n portal: {\r\n container: ref?.current || undefined\r\n }\r\n }\r\n }\r\n })\r\n\r\n useEffect(() => {\r\n if (open) {\r\n modal.open()\r\n } else {\r\n modal.close()\r\n }\r\n }, [open])\r\n return <Tag ref={ref}></Tag>\r\n}\r\n\r\nconst ActionModal = ({ children, ...props }: ModalProps) => {\r\n return (\r\n <Modal {...props}>\r\n {children}\r\n </Modal>\r\n )\r\n}\r\n\r\nModal.open = (children: ModalProps['children'], props?: Omit<ModalProps, 'children'>) => {\r\n const m = Renderar.render(ActionModal as any, {\r\n open: true,\r\n ...props,\r\n children,\r\n onClosed: () => {\r\n m.unrender()\r\n if (props?.onClosed) {\r\n props.onClosed()\r\n }\r\n }\r\n })\r\n\r\n return {\r\n open: () => {\r\n m.updateProps({ open: true })\r\n },\r\n close: () => {\r\n m.updateProps({ open: false })\r\n },\r\n }\r\n};\r\n\r\nModal.close = () => {\r\n Renderar.unrender(ActionModal as any)\r\n}\r\n\r\nexport default Modal;"],"names":["__rest","useRef","useModal","_jsx","_Fragment","useEffect","Tag","Renderar"],"mappings":";;;;;;;;AASA,MAAM,KAAK,GAAG,CAAC,EAAwC,KAAI;QAA5C,EAAE,QAAQ,EAAE,IAAI,EAAA,GAAA,EAAwB,EAAnB,KAAK,GAAAA,YAAA,CAAA,EAAA,EAA1B,oBAA4B,CAAF;AACtC,IAAA,MAAM,GAAG,GAAGC,YAAM,CAAiB,IAAI,CAAC;AAExC,IAAA,MAAM,KAAK,GAAGC,KAAQ,CAACC,cAAA,CAAAC,mBAAA,EAAA,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAI,EAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAChC,KAAK,CAAA,EAAA,EACR,cAAc,EAAE,MAAK;YAClB,IAAI,KAAK,aAAL,KAAK,KAAA,MAAA,GAAA,MAAA,GAAL,KAAK,CAAE,cAAc,EAAE;gBACxB,KAAK,CAAC,cAAc,EAAE;YACzB;QACH,CAAC,EACD,SAAS,EAAE;AACR,YAAA,KAAK,EAAE;AACJ,gBAAA,MAAM,EAAE;oBACL,SAA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T,CAAC,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACjC,CAAC;KACH;AACJ,CAAC;AAED,KAAK,CAAC,KAAK,GAAG,MAAK;AAChB,IAAAA,aAAQ,CAAC,QAAQ,CAAC,WAAkB,CAAC;AACxC,CAAC;;;;"}
|
package/Modal/index.mjs
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {__rest
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { useRef, useEffect } from 'react';
|
|
4
|
+
import useModal from '../useModal/index.mjs';
|
|
5
|
+
import { Tag, Renderar } from '@xanui/core';
|
|
6
|
+
|
|
7
|
+
const Modal = (_a) => {
|
|
2
8
|
var { children, open } = _a, props = __rest(_a, ["children", "open"]);
|
|
3
9
|
const ref = useRef(null);
|
|
4
10
|
const modal = useModal(jsx(Fragment, { children: children }), Object.assign(Object.assign({}, props), { onClickOutside: () => {
|
|
@@ -44,4 +50,7 @@ Modal.open = (children, props) => {
|
|
|
44
50
|
};
|
|
45
51
|
Modal.close = () => {
|
|
46
52
|
Renderar.unrender(ActionModal);
|
|
47
|
-
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { Modal as default };
|
|
56
|
+
//# sourceMappingURL=index.mjs.map
|
package/Modal/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/Modal/index.tsx"],"sourcesContent":["import { ReactNode, useEffect, useRef } from \"react\";\nimport useModal, { UseModalProps } from \"../useModal\";\nimport { Renderar, Tag } from \"@xanui/core\";\n\nexport type ModalProps = UseModalProps & {\n children: ReactNode;\n open: boolean;\n}\n\nconst Modal = ({ children, open, ...props }: ModalProps) => {\n const ref = useRef<HTMLDivElement>(null);\n\n const modal = useModal(<>{children}</>, {\n ...props,\n onClickOutside: () => {\n if (props?.onClickOutside) {\n props.onClickOutside()\n }\n },\n slotProps: {\n layer: {\n portal: {\n container: ref?.current || undefined\n }\n }\n }\n })\n\n useEffect(() => {\n if (open) {\n modal.open()\n } else {\n modal.close()\n }\n }, [open])\n return <Tag ref={ref}></Tag>\n}\n\nconst ActionModal = ({ children, ...props }: ModalProps) => {\n return (\n <Modal {...props}>\n {children}\n </Modal>\n )\n}\n\nModal.open = (children: ModalProps['children'], props?: Omit<ModalProps, 'children'>) => {\n const m = Renderar.render(ActionModal as any, {\n open: true,\n ...props,\n children,\n onClosed: () => {\n m.unrender()\n if (props?.onClosed) {\n props.onClosed()\n }\n }\n })\n\n return {\n open: () => {\n m.updateProps({ open: true })\n },\n close: () => {\n m.updateProps({ open: false })\n },\n }\n};\n\nModal.close = () => {\n Renderar.unrender(ActionModal as any)\n}\n\nexport default Modal;"],"names":["_jsx","_Fragment"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/Modal/index.tsx"],"sourcesContent":["import { ReactNode, useEffect, useRef } from \"react\";\r\nimport useModal, { UseModalProps } from \"../useModal\";\r\nimport { Renderar, Tag } from \"@xanui/core\";\r\n\r\nexport type ModalProps = UseModalProps & {\r\n children: ReactNode;\r\n open: boolean;\r\n}\r\n\r\nconst Modal = ({ children, open, ...props }: ModalProps) => {\r\n const ref = useRef<HTMLDivElement>(null);\r\n\r\n const modal = useModal(<>{children}</>, {\r\n ...props,\r\n onClickOutside: () => {\r\n if (props?.onClickOutside) {\r\n props.onClickOutside()\r\n }\r\n },\r\n slotProps: {\r\n layer: {\r\n portal: {\r\n container: ref?.current || undefined\r\n }\r\n }\r\n }\r\n })\r\n\r\n useEffect(() => {\r\n if (open) {\r\n modal.open()\r\n } else {\r\n modal.close()\r\n }\r\n }, [open])\r\n return <Tag ref={ref}></Tag>\r\n}\r\n\r\nconst ActionModal = ({ children, ...props }: ModalProps) => {\r\n return (\r\n <Modal {...props}>\r\n {children}\r\n </Modal>\r\n )\r\n}\r\n\r\nModal.open = (children: ModalProps['children'], props?: Omit<ModalProps, 'children'>) => {\r\n const m = Renderar.render(ActionModal as any, {\r\n open: true,\r\n ...props,\r\n children,\r\n onClosed: () => {\r\n m.unrender()\r\n if (props?.onClosed) {\r\n props.onClosed()\r\n }\r\n }\r\n })\r\n\r\n return {\r\n open: () => {\r\n m.updateProps({ open: true })\r\n },\r\n close: () => {\r\n m.updateProps({ open: false })\r\n },\r\n }\r\n};\r\n\r\nModal.close = () => {\r\n Renderar.unrender(ActionModal as any)\r\n}\r\n\r\nexport default Modal;"],"names":["_jsx","_Fragment"],"mappings":";;;;;;AASA,MAAM,KAAK,GAAG,CAAC,EAAwC,KAAI;QAA5C,EAAE,QAAQ,EAAE,IAAI,EAAA,GAAA,EAAwB,EAAnB,KAAK,GAAA,MAAA,CAAA,EAAA,EAA1B,oBAA4B,CAAF;AACtC,IAAA,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC;AAExC,IAAA,MAAM,KAAK,GAAG,QAAQ,CAACA,GAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAI,EAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAChC,KAAK,CAAA,EAAA,EACR,cAAc,EAAE,MAAK;YAClB,IAAI,KAAK,aAAL,KAAK,KAAA,MAAA,GAAA,MAAA,GAAL,KAAK,CAAE,cAAc,EAAE;gBACxB,KAAK,CAAC,cAAc,EAAE;YACzB;QACH,CAAC,EACD,SAAS,EAAE;AACR,YAAA,KAAK,EAAE;AACJ,gBAAA,MAAM,EAAE;oBACL,SAAS,EAAE,CAAA,GAAG,KAAA,IAAA,IAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,KAAI;AAC7B;AACH;AACH,SAAA,EAAA,CAAA,CACF;IAEF,SAAS,CAAC,MAAK;QACZ,IAAI,IAAI,EAAE;YACP,KAAK,CAAC,IAAI,EAAE;QACf;aAAO;YACJ,KAAK,CAAC,KAAK,EAAE;QAChB;AACH,IAAA,CAAC,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use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
const NoSSR = ({ children }) => {
|
|
6
|
+
const [isClient, setIsClient] = React.useState(false);
|
|
7
|
+
React.useEffect(() => {
|
|
8
|
+
setIsClient(true);
|
|
9
|
+
}, []);
|
|
10
|
+
return isClient ? children : null;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
module.exports = NoSSR;
|
|
14
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/NoSSR/index.tsx"],"sourcesContent":["\r\nimport { useEffect, useState } from \"react\";\r\n\r\nconst NoSSR = ({ children }: any) => {\r\n const [isClient, setIsClient] = useState(false);\r\n useEffect(() => {\r\n setIsClient(true);\r\n }, [])\r\n return isClient ? children : null\r\n}\r\n\r\nexport default NoSSR"],"names":["useState","useEffect"],"mappings":";;;;AAGA,MAAM,KAAK,GAAG,CAAC,EAAE,QAAQ,EAAO,KAAI;IAChC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC;IAC/CC,eAAS,CAAC,MAAK;QACX,WAAW,CAAC,IAAI,CAAC;IACrB,CAAC,EAAE,EAAE,CAAC;IACN,OAAO,QAAQ,GAAG,QAAQ,GAAG,IAAI;AACrC;;;;"}
|
package/NoSSR/index.mjs
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {useState,useEffect}from'react';
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
const NoSSR = ({ children }) => {
|
|
2
4
|
const [isClient, setIsClient] = useState(false);
|
|
3
5
|
useEffect(() => {
|
|
4
6
|
setIsClient(true);
|
|
5
7
|
}, []);
|
|
6
8
|
return isClient ? children : null;
|
|
7
|
-
};
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { NoSSR as default };
|
|
12
|
+
//# sourceMappingURL=index.mjs.map
|
package/NoSSR/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/NoSSR/index.tsx"],"sourcesContent":["\nimport { useEffect, useState } from \"react\";\n\nconst NoSSR = ({ children }: any) => {\n const [isClient, setIsClient] = useState(false);\n useEffect(() => {\n setIsClient(true);\n }, [])\n return isClient ? children : null\n}\n\nexport default NoSSR"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/NoSSR/index.tsx"],"sourcesContent":["\r\nimport { useEffect, useState } from \"react\";\r\n\r\nconst NoSSR = ({ children }: any) => {\r\n const [isClient, setIsClient] = useState(false);\r\n useEffect(() => {\r\n setIsClient(true);\r\n }, [])\r\n return isClient ? children : null\r\n}\r\n\r\nexport default NoSSR"],"names":[],"mappings":";;AAGA,MAAM,KAAK,GAAG,CAAC,EAAE,QAAQ,EAAO,KAAI;IAChC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC/C,SAAS,CAAC,MAAK;QACX,WAAW,CAAC,IAAI,CAAC;IACrB,CAAC,EAAE,EAAE,CAAC;IACN,OAAO,QAAQ,GAAG,QAAQ,GAAG,IAAI;AACrC;;;;"}
|
package/Option/index.cjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var index = require('../ListItem/index.cjs');
|
|
7
|
+
|
|
8
|
+
const Option = React.forwardRef((_a, ref) => {
|
|
9
|
+
var { value, children } = _a, props = tslib.__rest(_a, ["value", "children"]);
|
|
10
|
+
return (jsxRuntime.jsx(index, Object.assign({}, props, { ref: ref, children: children })));
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
module.exports = Option;
|
|
14
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/Option/index.tsx"],"sourcesContent":["\r\nimport React from 'react'\r\nimport ListItem, { ListItemProps } from '../ListItem'\r\n\r\nexport type OptionProps = ListItemProps & {\r\n value: string | number;\r\n}\r\n\r\nconst Option = React.forwardRef(({ value, children, ...props }: OptionProps, ref: React.Ref<any>) => {\r\n return (\r\n <ListItem {...props} ref={ref}>{children}</ListItem>\r\n )\r\n})\r\n\r\nexport default Option"],"names":["__rest","_jsx","ListItem"],"mappings":";;;;;;;AAQA,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,EAA0C,EAAE,GAAmB,KAAI;QAAnE,EAAE,KAAK,EAAE,QAAQ,EAAA,GAAA,EAAyB,EAApB,KAAK,GAAAA,YAAA,CAAA,EAAA,EAA3B,qBAA6B,CAAF;AACxD,IAAA,QACIC,cAAA,CAACC,KAAQ,EAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAK,KAAK,EAAA,EAAE,GAAG,EAAE,GAAG,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAA,CAAY;AAE5D,CAAC;;;;"}
|
package/Option/index.mjs
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {__rest
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import ListItem from '../ListItem/index.mjs';
|
|
5
|
+
|
|
6
|
+
const Option = React.forwardRef((_a, ref) => {
|
|
2
7
|
var { value, children } = _a, props = __rest(_a, ["value", "children"]);
|
|
3
8
|
return (jsx(ListItem, Object.assign({}, props, { ref: ref, children: children })));
|
|
4
|
-
});
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export { Option as default };
|
|
12
|
+
//# sourceMappingURL=index.mjs.map
|
package/Option/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/Option/index.tsx"],"sourcesContent":["\nimport React from 'react'\nimport ListItem, { ListItemProps } from '../ListItem'\n\nexport type OptionProps = ListItemProps & {\n value: string | number;\n}\n\nconst Option = React.forwardRef(({ value, children, ...props }: OptionProps, ref: React.Ref<any>) => {\n return (\n <ListItem {...props} ref={ref}>{children}</ListItem>\n )\n})\n\nexport default Option"],"names":["_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/Option/index.tsx"],"sourcesContent":["\r\nimport React from 'react'\r\nimport ListItem, { ListItemProps } from '../ListItem'\r\n\r\nexport type OptionProps = ListItemProps & {\r\n value: string | number;\r\n}\r\n\r\nconst Option = React.forwardRef(({ value, children, ...props }: OptionProps, ref: React.Ref<any>) => {\r\n return (\r\n <ListItem {...props} ref={ref}>{children}</ListItem>\r\n )\r\n})\r\n\r\nexport default Option"],"names":["_jsx"],"mappings":";;;;;AAQA,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,EAA0C,EAAE,GAAmB,KAAI;QAAnE,EAAE,KAAK,EAAE,QAAQ,EAAA,GAAA,EAAyB,EAApB,KAAK,GAAA,MAAA,CAAA,EAAA,EAA3B,qBAA6B,CAAF;AACxD,IAAA,QACIA,GAAA,CAAC,QAAQ,EAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAK,KAAK,EAAA,EAAE,GAAG,EAAE,GAAG,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAA,CAAY;AAE5D,CAAC;;;;"}
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
'use strict';
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var core = require('@xanui/core');
|
|
7
|
+
|
|
8
|
+
const Paper = React.forwardRef((_a, ref) => {
|
|
2
9
|
var { children } = _a, rest = tslib.__rest(_a, ["children"]);
|
|
3
10
|
let [props] = core.useInterface("default", rest, {});
|
|
4
11
|
return (jsxRuntime.jsx(core.Tag, Object.assign({}, props, { sxr: Object.assign({ radius: 1, p: 1.5, bgcolor: "background.secondary", color: "text.primary" }, props === null || props === void 0 ? void 0 : props.sx), baseClass: 'default', ref: ref, children: children })));
|
|
5
|
-
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
module.exports = Paper;
|
|
15
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/Paper/index.tsx"],"sourcesContent":["\r\nimport React from 'react';\r\nimport { Tag, TagProps, TagComponentType, useInterface } from '@xanui/core';\r\n\r\nexport type PaperProps<T extends TagComponentType = \"div\"> = TagProps<T>\r\n\r\nconst Paper = React.forwardRef(<T extends TagComponentType = \"div\">({ children, ...rest }: PaperProps<T>, ref?: React.Ref<any>) => {\r\n let [props] = useInterface<any>(\"default\", rest, {})\r\n return (\r\n <Tag\r\n {...props}\r\n sxr={{\r\n radius: 1,\r\n p: 1.5,\r\n bgcolor: \"background.secondary\",\r\n color: \"text.primary\",\r\n ...props?.sx\r\n }}\r\n baseClass='default'\r\n ref={ref}\r\n >{children}</Tag>\r\n )\r\n})\r\n\r\nexport default Paper\r\n"],"names":["__rest","useInterface","_jsx","Tag"],"mappings":";;;;;;;AAMA,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,CAAqC,EAAoC,EAAE,GAAoB,KAAI;AAA9D,IAAA,IAAA,EAAE,QAAQ,EAAA,GAAA,EAA0B,EAArB,IAAI,GAAAA,YAAA,CAAA,EAAA,EAAnB,YAAqB,CAAF;AACnF,IAAA,IAAI,CAAC,KAAK,CAAC,GAAGC,iBAAY,CAAM,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;AACpD,IAAA,QACIC,cAAA,CAACC,QAAG,oBACI,KAAK,EAAA,EACT,GAAG,EAAA,MAAA,CAAA,MAAA,CAAA,EACC,MAAM,EAAE,CAAC,EACT,CAAC,EAAE,GAAG,EACN,OAAO,EAAE,sBAAsB,EAC/B,KAAK,EAAE,cAAc,EAAA,EAClB,KAAK,KAAA,IAAA,IAAL,KAAK,uBAAL,KAAK,CAAE,EAAE,CAAA,EAEhB,SAAS,EAAC,SAAS,EACnB,GAAG,EAAE,GAAG,YACV,QAAQ,EAAA,CAAA,CAAO;AAEzB,CAAC;;;;"}
|
package/Paper/index.mjs
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import {__rest
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { useInterface, Tag } from '@xanui/core';
|
|
5
|
+
|
|
6
|
+
const Paper = React.forwardRef((_a, ref) => {
|
|
2
7
|
var { children } = _a, rest = __rest(_a, ["children"]);
|
|
3
8
|
let [props] = useInterface("default", rest, {});
|
|
4
9
|
return (jsx(Tag, Object.assign({}, props, { sxr: Object.assign({ radius: 1, p: 1.5, bgcolor: "background.secondary", color: "text.primary" }, props === null || props === void 0 ? void 0 : props.sx), baseClass: 'default', ref: ref, children: children })));
|
|
5
|
-
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export { Paper as default };
|
|
13
|
+
//# sourceMappingURL=index.mjs.map
|
package/Paper/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/Paper/index.tsx"],"sourcesContent":["\nimport React from 'react';\nimport { Tag, TagProps, TagComponentType, useInterface } from '@xanui/core';\n\nexport type PaperProps<T extends TagComponentType = \"div\"> = TagProps<T>\n\nconst Paper = React.forwardRef(<T extends TagComponentType = \"div\">({ children, ...rest }: PaperProps<T>, ref?: React.Ref<any>) => {\n let [props] = useInterface<any>(\"default\", rest, {})\n return (\n <Tag\n {...props}\n sxr={{\n radius: 1,\n p: 1.5,\n bgcolor: \"background.secondary\",\n color: \"text.primary\",\n ...props?.sx\n }}\n baseClass='default'\n ref={ref}\n >{children}</Tag>\n )\n})\n\nexport default Paper\n"],"names":["_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/Paper/index.tsx"],"sourcesContent":["\r\nimport React from 'react';\r\nimport { Tag, TagProps, TagComponentType, useInterface } from '@xanui/core';\r\n\r\nexport type PaperProps<T extends TagComponentType = \"div\"> = TagProps<T>\r\n\r\nconst Paper = React.forwardRef(<T extends TagComponentType = \"div\">({ children, ...rest }: PaperProps<T>, ref?: React.Ref<any>) => {\r\n let [props] = useInterface<any>(\"default\", rest, {})\r\n return (\r\n <Tag\r\n {...props}\r\n sxr={{\r\n radius: 1,\r\n p: 1.5,\r\n bgcolor: \"background.secondary\",\r\n color: \"text.primary\",\r\n ...props?.sx\r\n }}\r\n baseClass='default'\r\n ref={ref}\r\n >{children}</Tag>\r\n )\r\n})\r\n\r\nexport default Paper\r\n"],"names":["_jsx"],"mappings":";;;;;AAMA,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,CAAqC,EAAoC,EAAE,GAAoB,KAAI;AAA9D,IAAA,IAAA,EAAE,QAAQ,EAAA,GAAA,EAA0B,EAArB,IAAI,GAAA,MAAA,CAAA,EAAA,EAAnB,YAAqB,CAAF;AACnF,IAAA,IAAI,CAAC,KAAK,CAAC,GAAG,YAAY,CAAM,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;AACpD,IAAA,QACIA,GAAA,CAAC,GAAG,oBACI,KAAK,EAAA,EACT,GAAG,EAAA,MAAA,CAAA,MAAA,CAAA,EACC,MAAM,EAAE,CAAC,EACT,CAAC,EAAE,GAAG,EACN,OAAO,EAAE,sBAAsB,EAC/B,KAAK,EAAE,cAAc,EAAA,EAClB,KAAK,KAAA,IAAA,IAAL,KAAK,uBAAL,KAAK,CAAE,EAAE,CAAA,EAEhB,SAAS,EAAC,SAAS,EACnB,GAAG,EAAE,GAAG,YACV,QAAQ,EAAA,CAAA,CAAO;AAEzB,CAAC;;;;"}
|
package/Portal/index.cjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var ReactDOM = require('react-dom');
|
|
6
|
+
var core = require('@xanui/core');
|
|
7
|
+
|
|
8
|
+
const Portal = ({ children, appendTo, container }) => {
|
|
9
|
+
const theme = core.useTheme();
|
|
10
|
+
appendTo = appendTo || document.body;
|
|
11
|
+
const c = React.useMemo(() => {
|
|
12
|
+
let _con = container || document.createElement("div");
|
|
13
|
+
appendTo.appendChild(_con);
|
|
14
|
+
_con.className = "xui-portal";
|
|
15
|
+
return _con;
|
|
16
|
+
}, []);
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
return () => {
|
|
19
|
+
appendTo.removeChild(c);
|
|
20
|
+
};
|
|
21
|
+
}, []);
|
|
22
|
+
return ReactDOM.createPortal(jsxRuntime.jsx(core.ThemeProvider, { theme: theme.name, children: children }), c);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
module.exports = Portal;
|
|
26
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/Portal/index.tsx"],"sourcesContent":["\r\nimport React, { useEffect, useMemo } from 'react'\r\nimport ReactDOM from 'react-dom';\r\nimport { useTheme, ThemeProvider } from '@xanui/core';\r\nexport type PortalProps = {\r\n children?: React.ReactNode;\r\n appendTo?: HTMLElement;\r\n container?: HTMLElement;\r\n}\r\n\r\nconst Portal = ({ children, appendTo, container }: PortalProps) => {\r\n const theme = useTheme()\r\n appendTo = appendTo || document.body\r\n\r\n const c = useMemo(() => {\r\n let _con: HTMLElement = container || document.createElement(\"div\");\r\n appendTo.appendChild(_con);\r\n _con.className = \"xui-portal\"\r\n return _con\r\n }, [])\r\n\r\n useEffect(() => {\r\n return () => {\r\n (appendTo as any).removeChild(c);\r\n }\r\n }, [])\r\n\r\n return ReactDOM.createPortal(\r\n <ThemeProvider theme={theme.name}>\r\n {children}\r\n </ThemeProvider>,\r\n c,\r\n );\r\n}\r\n\r\nexport default Portal"],"names":["useTheme","useMemo","useEffect","_jsx","ThemeProvider"],"mappings":";;;;;;;AAUA,MAAM,MAAM,GAAG,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAe,KAAI;AAC9D,IAAA,MAAM,KAAK,GAAGA,aAAQ,EAAE;AACxB,IAAA,QAAQ,GAAG,QAAQ,IAAI,QAAQ,CAAC,IAAI;AAEpC,IAAA,MAAM,CAAC,GAAGC,aAAO,CAAC,MAAK;QACnB,IAAI,IAAI,GAAgB,SAAS,IAAI,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC;AAClE,QAAA,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC;AAC1B,QAAA,IAAI,CAAC,SAAS,GAAG,YAAY;AAC7B,QAAA,OAAO,IAAI;IACf,CAAC,EAAE,EAAE,CAAC;IAENC,eAAS,CAAC,MAAK;AACX,QAAA,OAAO,MAAK;AACP,YAAA,QAAgB,CAAC,WAAW,CAAC,CAAC,CAAC;AACpC,QAAA,CAAC;IACL,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,OAAO,QAAQ,CAAC,YAAY,CACxBC,cAAA,CAACC,kBAAa,IAAC,KAAK,EAAE,KAAK,CAAC,IAAI,EAAA,QAAA,EAC3B,QAAQ,GACG,EAChB,CAAC,CACJ;AACL;;;;"}
|
package/Portal/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
|
|
4
3
|
type PortalProps = {
|
|
@@ -6,7 +5,7 @@ type PortalProps = {
|
|
|
6
5
|
appendTo?: HTMLElement;
|
|
7
6
|
container?: HTMLElement;
|
|
8
7
|
};
|
|
9
|
-
declare const Portal: ({ children, appendTo, container }: PortalProps) =>
|
|
8
|
+
declare const Portal: ({ children, appendTo, container }: PortalProps) => React.ReactPortal;
|
|
10
9
|
|
|
11
10
|
export { Portal as default };
|
|
12
11
|
export type { PortalProps };
|
package/Portal/index.mjs
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import {jsx
|
|
2
|
-
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useMemo, useEffect } from 'react';
|
|
3
|
+
import ReactDOM from 'react-dom';
|
|
4
|
+
import { useTheme, ThemeProvider } from '@xanui/core';
|
|
5
|
+
|
|
6
|
+
const Portal = ({ children, appendTo, container }) => {
|
|
3
7
|
const theme = useTheme();
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
let _con =
|
|
8
|
+
appendTo = appendTo || document.body;
|
|
9
|
+
const c = useMemo(() => {
|
|
10
|
+
let _con = container || document.createElement("div");
|
|
7
11
|
appendTo.appendChild(_con);
|
|
8
12
|
_con.className = "xui-portal";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
return _con;
|
|
14
|
+
}, []);
|
|
15
|
+
useEffect(() => {
|
|
12
16
|
return () => {
|
|
13
|
-
appendTo.removeChild(
|
|
17
|
+
appendTo.removeChild(c);
|
|
14
18
|
};
|
|
15
19
|
}, []);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
return ReactDOM.createPortal(jsx(ThemeProvider, { theme: theme.name, children: children }), c);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { Portal as default };
|
|
24
|
+
//# sourceMappingURL=index.mjs.map
|
package/Portal/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/Portal/index.tsx"],"sourcesContent":["\nimport React, { useEffect,
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/Portal/index.tsx"],"sourcesContent":["\r\nimport React, { useEffect, useMemo } from 'react'\r\nimport ReactDOM from 'react-dom';\r\nimport { useTheme, ThemeProvider } from '@xanui/core';\r\nexport type PortalProps = {\r\n children?: React.ReactNode;\r\n appendTo?: HTMLElement;\r\n container?: HTMLElement;\r\n}\r\n\r\nconst Portal = ({ children, appendTo, container }: PortalProps) => {\r\n const theme = useTheme()\r\n appendTo = appendTo || document.body\r\n\r\n const c = useMemo(() => {\r\n let _con: HTMLElement = container || document.createElement(\"div\");\r\n appendTo.appendChild(_con);\r\n _con.className = \"xui-portal\"\r\n return _con\r\n }, [])\r\n\r\n useEffect(() => {\r\n return () => {\r\n (appendTo as any).removeChild(c);\r\n }\r\n }, [])\r\n\r\n return ReactDOM.createPortal(\r\n <ThemeProvider theme={theme.name}>\r\n {children}\r\n </ThemeProvider>,\r\n c,\r\n );\r\n}\r\n\r\nexport default Portal"],"names":["_jsx"],"mappings":";;;;;AAUA,MAAM,MAAM,GAAG,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAe,KAAI;AAC9D,IAAA,MAAM,KAAK,GAAG,QAAQ,EAAE;AACxB,IAAA,QAAQ,GAAG,QAAQ,IAAI,QAAQ,CAAC,IAAI;AAEpC,IAAA,MAAM,CAAC,GAAG,OAAO,CAAC,MAAK;QACnB,IAAI,IAAI,GAAgB,SAAS,IAAI,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC;AAClE,QAAA,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC;AAC1B,QAAA,IAAI,CAAC,SAAS,GAAG,YAAY;AAC7B,QAAA,OAAO,IAAI;IACf,CAAC,EAAE,EAAE,CAAC;IAEN,SAAS,CAAC,MAAK;AACX,QAAA,OAAO,MAAK;AACP,YAAA,QAAgB,CAAC,WAAW,CAAC,CAAC,CAAC;AACpC,QAAA,CAAC;IACL,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,OAAO,QAAQ,CAAC,YAAY,CACxBA,GAAA,CAAC,aAAa,IAAC,KAAK,EAAE,KAAK,CAAC,IAAI,EAAA,QAAA,EAC3B,QAAQ,GACG,EAChB,CAAC,CACJ;AACL;;;;"}
|
package/Radio/index.cjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var core = require('@xanui/core');
|
|
6
|
+
var CheckIcon = require('@xanui/icons/RadioButtonChecked');
|
|
7
|
+
var UnCheckIcon = require('@xanui/icons/RadioButtonUnchecked');
|
|
8
|
+
var index = require('../Checkbox/index.cjs');
|
|
9
|
+
|
|
10
|
+
const Radio = React.forwardRef((props, ref) => {
|
|
11
|
+
let [rest] = core.useInterface("Radio", props, {});
|
|
12
|
+
return jsxRuntime.jsx(index, Object.assign({ checkIcon: jsxRuntime.jsx(CheckIcon, {}), uncheckIcon: jsxRuntime.jsx(UnCheckIcon, {}) }, rest, { type: "radio", ref: ref, classNames: ['radio', ...((rest === null || rest === void 0 ? void 0 : rest.classNames) || [])] }));
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
module.exports = Radio;
|
|
16
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/Radio/index.tsx"],"sourcesContent":["\r\nimport React from 'react';\r\nimport { useInterface } from '@xanui/core';\r\nimport CheckIcon from '@xanui/icons/RadioButtonChecked'\r\nimport UnCheckIcon from '@xanui/icons/RadioButtonUnchecked'\r\nimport Checkbox, { CheckboxProps } from '../Checkbox';\r\n\r\nexport type RadioProps = CheckboxProps\r\nconst Radio = React.forwardRef((props: RadioProps, ref?: React.Ref<any>) => {\r\n let [rest] = useInterface<any>(\"Radio\", props, {})\r\n return <Checkbox\r\n checkIcon={<CheckIcon />}\r\n uncheckIcon={<UnCheckIcon />}\r\n {...rest}\r\n type=\"radio\"\r\n ref={ref}\r\n classNames={['radio', ...(rest?.classNames || [])]}\r\n />\r\n})\r\n\r\nexport default Radio\r\n"],"names":["useInterface","_jsx","Checkbox"],"mappings":";;;;;;;;;AAQA,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAiB,EAAE,GAAoB,KAAI;AACvE,IAAA,IAAI,CAAC,IAAI,CAAC,GAAGA,iBAAY,CAAM,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC;IAClD,OAAOC,cAAA,CAACC,KAAQ,EAAA,MAAA,CAAA,MAAA,CAAA,EACZ,SAAS,EAAED,cAAA,CAAC,SAAS,KAAG,EACxB,WAAW,EAAEA,cAAA,CAAC,WAAW,KAAG,EAAA,EACxB,IAAI,IACR,IAAI,EAAC,OAAO,EACZ,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,CAAC,OAAO,EAAE,IAAI,CAAA,IAAI,aAAJ,IAAI,KAAA,MAAA,GAAA,MAAA,GAAJ,IAAI,CAAE,UAAU,KAAI,EAAE,CAAC,CAAC,EAAA,CAAA,CACpD;AACN,CAAC;;;;"}
|
package/Radio/index.mjs
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import {jsx}from'react/jsx-runtime';
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useInterface } from '@xanui/core';
|
|
4
|
+
import CheckIcon from '@xanui/icons/RadioButtonChecked';
|
|
5
|
+
import UnCheckIcon from '@xanui/icons/RadioButtonUnchecked';
|
|
6
|
+
import Checkbox from '../Checkbox/index.mjs';
|
|
7
|
+
|
|
8
|
+
const Radio = React.forwardRef((props, ref) => {
|
|
2
9
|
let [rest] = useInterface("Radio", props, {});
|
|
3
10
|
return jsx(Checkbox, Object.assign({ checkIcon: jsx(CheckIcon, {}), uncheckIcon: jsx(UnCheckIcon, {}) }, rest, { type: "radio", ref: ref, classNames: ['radio', ...((rest === null || rest === void 0 ? void 0 : rest.classNames) || [])] }));
|
|
4
|
-
});
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export { Radio as default };
|
|
14
|
+
//# sourceMappingURL=index.mjs.map
|
package/Radio/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/Radio/index.tsx"],"sourcesContent":["\nimport React from 'react';\nimport { useInterface } from '@xanui/core';\nimport CheckIcon from '@xanui/icons/RadioButtonChecked'\nimport UnCheckIcon from '@xanui/icons/RadioButtonUnchecked'\nimport Checkbox, { CheckboxProps } from '../Checkbox';\n\nexport type RadioProps = CheckboxProps\nconst Radio = React.forwardRef((props: RadioProps, ref?: React.Ref<any>) => {\n let [rest] = useInterface<any>(\"Radio\", props, {})\n return <Checkbox\n checkIcon={<CheckIcon />}\n uncheckIcon={<UnCheckIcon />}\n {...rest}\n type=\"radio\"\n ref={ref}\n classNames={['radio', ...(rest?.classNames || [])]}\n />\n})\n\nexport default Radio\n"],"names":["_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/Radio/index.tsx"],"sourcesContent":["\r\nimport React from 'react';\r\nimport { useInterface } from '@xanui/core';\r\nimport CheckIcon from '@xanui/icons/RadioButtonChecked'\r\nimport UnCheckIcon from '@xanui/icons/RadioButtonUnchecked'\r\nimport Checkbox, { CheckboxProps } from '../Checkbox';\r\n\r\nexport type RadioProps = CheckboxProps\r\nconst Radio = React.forwardRef((props: RadioProps, ref?: React.Ref<any>) => {\r\n let [rest] = useInterface<any>(\"Radio\", props, {})\r\n return <Checkbox\r\n checkIcon={<CheckIcon />}\r\n uncheckIcon={<UnCheckIcon />}\r\n {...rest}\r\n type=\"radio\"\r\n ref={ref}\r\n classNames={['radio', ...(rest?.classNames || [])]}\r\n />\r\n})\r\n\r\nexport default Radio\r\n"],"names":["_jsx"],"mappings":";;;;;;;AAQA,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAiB,EAAE,GAAoB,KAAI;AACvE,IAAA,IAAI,CAAC,IAAI,CAAC,GAAG,YAAY,CAAM,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC;IAClD,OAAOA,GAAA,CAAC,QAAQ,EAAA,MAAA,CAAA,MAAA,CAAA,EACZ,SAAS,EAAEA,GAAA,CAAC,SAAS,KAAG,EACxB,WAAW,EAAEA,GAAA,CAAC,WAAW,KAAG,EAAA,EACxB,IAAI,IACR,IAAI,EAAC,OAAO,EACZ,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,CAAC,OAAO,EAAE,IAAI,CAAA,IAAI,aAAJ,IAAI,KAAA,MAAA,GAAA,MAAA,GAAJ,IAAI,CAAE,UAAU,KAAI,EAAE,CAAC,CAAC,EAAA,CAAA,CACpD;AACN,CAAC;;;;"}
|