@xanui/ui 1.0.0
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.d.ts +32 -0
- package/Accordion/index.js +82 -0
- package/Accordion/index.js.map +1 -0
- package/Accordion/index.mjs +82 -0
- package/Accordion/index.mjs.map +1 -0
- package/Alert/index.d.ts +41 -0
- package/Alert/index.js +137 -0
- package/Alert/index.js.map +1 -0
- package/Alert/index.mjs +137 -0
- package/Alert/index.mjs.map +1 -0
- package/Avatar/index.d.ts +10 -0
- package/Avatar/index.js +34 -0
- package/Avatar/index.js.map +1 -0
- package/Avatar/index.mjs +34 -0
- package/Avatar/index.mjs.map +1 -0
- package/Badge/index.d.ts +16 -0
- package/Badge/index.js +68 -0
- package/Badge/index.js.map +1 -0
- package/Badge/index.mjs +68 -0
- package/Badge/index.mjs.map +1 -0
- package/Box/index.d.ts +8 -0
- package/Box/index.js +4 -0
- package/Box/index.js.map +1 -0
- package/Box/index.mjs +4 -0
- package/Box/index.mjs.map +1 -0
- package/Button/index.d.ts +22 -0
- package/Button/index.js +77 -0
- package/Button/index.js.map +1 -0
- package/Button/index.mjs +77 -0
- package/Button/index.mjs.map +1 -0
- package/ButtonGroup/index.d.ts +14 -0
- package/ButtonGroup/index.js +47 -0
- package/ButtonGroup/index.js.map +1 -0
- package/ButtonGroup/index.mjs +47 -0
- package/ButtonGroup/index.mjs.map +1 -0
- package/Calendar/index.d.ts +14 -0
- package/Calendar/index.js +140 -0
- package/Calendar/index.js.map +1 -0
- package/Calendar/index.mjs +140 -0
- package/Calendar/index.mjs.map +1 -0
- package/CalendarInput/index.d.ts +18 -0
- package/CalendarInput/index.js +11 -0
- package/CalendarInput/index.js.map +1 -0
- package/CalendarInput/index.mjs +11 -0
- package/CalendarInput/index.mjs.map +1 -0
- package/Checkbox/index.d.ts +15 -0
- package/Checkbox/index.js +44 -0
- package/Checkbox/index.js.map +1 -0
- package/Checkbox/index.mjs +44 -0
- package/Checkbox/index.mjs.map +1 -0
- package/Chip/index.d.ts +17 -0
- package/Chip/index.js +59 -0
- package/Chip/index.js.map +1 -0
- package/Chip/index.mjs +59 -0
- package/Chip/index.mjs.map +1 -0
- package/CircleProgress/index.d.ts +20 -0
- package/CircleProgress/index.js +118 -0
- package/CircleProgress/index.js.map +1 -0
- package/CircleProgress/index.mjs +118 -0
- package/CircleProgress/index.mjs.map +1 -0
- package/ClickOutside/index.d.ts +10 -0
- package/ClickOutside/index.js +16 -0
- package/ClickOutside/index.js.map +1 -0
- package/ClickOutside/index.mjs +16 -0
- package/ClickOutside/index.mjs.map +1 -0
- package/Collaps/index.d.ts +8 -0
- package/Collaps/index.js +18 -0
- package/Collaps/index.js.map +1 -0
- package/Collaps/index.mjs +18 -0
- package/Collaps/index.mjs.map +1 -0
- package/Container/index.d.ts +10 -0
- package/Container/index.js +19 -0
- package/Container/index.js.map +1 -0
- package/Container/index.mjs +19 -0
- package/Container/index.mjs.map +1 -0
- package/Datatable/FilterBox.js +19 -0
- package/Datatable/FilterBox.js.map +1 -0
- package/Datatable/FilterBox.mjs +19 -0
- package/Datatable/FilterBox.mjs.map +1 -0
- package/Datatable/Row.js +41 -0
- package/Datatable/Row.js.map +1 -0
- package/Datatable/Row.mjs +41 -0
- package/Datatable/Row.mjs.map +1 -0
- package/Datatable/SelectedBox.js +11 -0
- package/Datatable/SelectedBox.js.map +1 -0
- package/Datatable/SelectedBox.mjs +11 -0
- package/Datatable/SelectedBox.mjs.map +1 -0
- package/Datatable/Table.js +11 -0
- package/Datatable/Table.js.map +1 -0
- package/Datatable/Table.mjs +11 -0
- package/Datatable/Table.mjs.map +1 -0
- package/Datatable/TableHead.js +35 -0
- package/Datatable/TableHead.js.map +1 -0
- package/Datatable/TableHead.mjs +35 -0
- package/Datatable/TableHead.mjs.map +1 -0
- package/Datatable/index.d.ts +71 -0
- package/Datatable/index.js +35 -0
- package/Datatable/index.js.map +1 -0
- package/Datatable/index.mjs +35 -0
- package/Datatable/index.mjs.map +1 -0
- package/Divider/index.d.ts +12 -0
- package/Divider/index.js +21 -0
- package/Divider/index.js.map +1 -0
- package/Divider/index.mjs +21 -0
- package/Divider/index.mjs.map +1 -0
- package/Drawer/index.d.ts +25 -0
- package/Drawer/index.js +57 -0
- package/Drawer/index.js.map +1 -0
- package/Drawer/index.mjs +57 -0
- package/Drawer/index.mjs.map +1 -0
- package/Form/index.d.ts +8 -0
- package/Form/index.js +34 -0
- package/Form/index.js.map +1 -0
- package/Form/index.mjs +34 -0
- package/Form/index.mjs.map +1 -0
- package/GridContainer/index.d.ts +8 -0
- package/GridContainer/index.js +9 -0
- package/GridContainer/index.js.map +1 -0
- package/GridContainer/index.mjs +9 -0
- package/GridContainer/index.mjs.map +1 -0
- package/GridItem/index.d.ts +14 -0
- package/GridItem/index.js +10 -0
- package/GridItem/index.js.map +1 -0
- package/GridItem/index.mjs +10 -0
- package/GridItem/index.mjs.map +1 -0
- package/IconButton/index.d.ts +13 -0
- package/IconButton/index.js +48 -0
- package/IconButton/index.js.map +1 -0
- package/IconButton/index.mjs +48 -0
- package/IconButton/index.mjs.map +1 -0
- package/Image/index.d.ts +10 -0
- package/Image/index.js +16 -0
- package/Image/index.js.map +1 -0
- package/Image/index.mjs +16 -0
- package/Image/index.mjs.map +1 -0
- package/Input/index.d.ts +26 -0
- package/Input/index.js +149 -0
- package/Input/index.js.map +1 -0
- package/Input/index.mjs +149 -0
- package/Input/index.mjs.map +1 -0
- package/Label/index.d.ts +8 -0
- package/Label/index.js +10 -0
- package/Label/index.js.map +1 -0
- package/Label/index.mjs +10 -0
- package/Label/index.mjs.map +1 -0
- package/Layer/index.d.ts +34 -0
- package/Layer/index.js +73 -0
- package/Layer/index.js.map +1 -0
- package/Layer/index.mjs +73 -0
- package/Layer/index.mjs.map +1 -0
- package/LineProgress/index.d.ts +15 -0
- package/LineProgress/index.js +48 -0
- package/LineProgress/index.js.map +1 -0
- package/LineProgress/index.mjs +48 -0
- package/LineProgress/index.mjs.map +1 -0
- package/List/index.d.ts +13 -0
- package/List/index.js +51 -0
- package/List/index.js.map +1 -0
- package/List/index.mjs +51 -0
- package/List/index.mjs.map +1 -0
- package/ListItem/index.d.ts +13 -0
- package/ListItem/index.js +26 -0
- package/ListItem/index.js.map +1 -0
- package/ListItem/index.mjs +26 -0
- package/ListItem/index.mjs.map +1 -0
- package/LoadingBox/index.d.ts +15 -0
- package/LoadingBox/index.js +22 -0
- package/LoadingBox/index.js.map +1 -0
- package/LoadingBox/index.mjs +22 -0
- package/LoadingBox/index.mjs.map +1 -0
- package/Menu/getOrigin.js +42 -0
- package/Menu/getOrigin.js.map +1 -0
- package/Menu/getOrigin.mjs +42 -0
- package/Menu/getOrigin.mjs.map +1 -0
- package/Menu/index.d.ts +22 -0
- package/Menu/index.js +47 -0
- package/Menu/index.js.map +1 -0
- package/Menu/index.mjs +47 -0
- package/Menu/index.mjs.map +1 -0
- package/Menu/placedMenu.d.ts +5 -0
- package/Menu/placedMenu.js +95 -0
- package/Menu/placedMenu.js.map +1 -0
- package/Menu/placedMenu.mjs +95 -0
- package/Menu/placedMenu.mjs.map +1 -0
- package/Modal/index.d.ts +19 -0
- package/Modal/index.js +38 -0
- package/Modal/index.js.map +1 -0
- package/Modal/index.mjs +38 -0
- package/Modal/index.mjs.map +1 -0
- package/NoSSR/index.d.ts +3 -0
- package/NoSSR/index.js +7 -0
- package/NoSSR/index.js.map +1 -0
- package/NoSSR/index.mjs +7 -0
- package/NoSSR/index.mjs.map +1 -0
- package/Option/index.d.ts +10 -0
- package/Option/index.js +4 -0
- package/Option/index.js.map +1 -0
- package/Option/index.mjs +4 -0
- package/Option/index.mjs.map +1 -0
- package/Paper/index.d.ts +8 -0
- package/Paper/index.js +5 -0
- package/Paper/index.js.map +1 -0
- package/Paper/index.mjs +5 -0
- package/Paper/index.mjs.map +1 -0
- package/Portal/index.d.ts +11 -0
- package/Portal/index.js +26 -0
- package/Portal/index.js.map +1 -0
- package/Portal/index.mjs +26 -0
- package/Portal/index.mjs.map +1 -0
- package/Radio/index.d.ts +6 -0
- package/Radio/index.js +4 -0
- package/Radio/index.js.map +1 -0
- package/Radio/index.mjs +4 -0
- package/Radio/index.mjs.map +1 -0
- package/Scrollbar/index.d.ts +14 -0
- package/Scrollbar/index.js +65 -0
- package/Scrollbar/index.js.map +1 -0
- package/Scrollbar/index.mjs +65 -0
- package/Scrollbar/index.mjs.map +1 -0
- package/Select/index.d.ts +24 -0
- package/Select/index.js +35 -0
- package/Select/index.js.map +1 -0
- package/Select/index.mjs +35 -0
- package/Select/index.mjs.map +1 -0
- package/Stack/index.d.ts +8 -0
- package/Stack/index.js +7 -0
- package/Stack/index.js.map +1 -0
- package/Stack/index.mjs +7 -0
- package/Stack/index.mjs.map +1 -0
- package/Switch/index.d.ts +19 -0
- package/Switch/index.js +68 -0
- package/Switch/index.js.map +1 -0
- package/Switch/index.mjs +68 -0
- package/Switch/index.mjs.map +1 -0
- package/Tab/index.d.ts +11 -0
- package/Tab/index.js +5 -0
- package/Tab/index.js.map +1 -0
- package/Tab/index.mjs +5 -0
- package/Tab/index.mjs.map +1 -0
- package/Table/index.d.ts +14 -0
- package/Table/index.js +77 -0
- package/Table/index.js.map +1 -0
- package/Table/index.mjs +77 -0
- package/Table/index.mjs.map +1 -0
- package/TableBody/index.d.ts +8 -0
- package/TableBody/index.js +4 -0
- package/TableBody/index.js.map +1 -0
- package/TableBody/index.mjs +4 -0
- package/TableBody/index.mjs.map +1 -0
- package/TableCell/index.d.ts +10 -0
- package/TableCell/index.js +4 -0
- package/TableCell/index.js.map +1 -0
- package/TableCell/index.mjs +4 -0
- package/TableCell/index.mjs.map +1 -0
- package/TableFooter/index.d.ts +8 -0
- package/TableFooter/index.js +4 -0
- package/TableFooter/index.js.map +1 -0
- package/TableFooter/index.mjs +4 -0
- package/TableFooter/index.mjs.map +1 -0
- package/TableHead/index.d.ts +8 -0
- package/TableHead/index.js +4 -0
- package/TableHead/index.js.map +1 -0
- package/TableHead/index.mjs +4 -0
- package/TableHead/index.mjs.map +1 -0
- package/TablePagination/index.d.ts +26 -0
- package/TablePagination/index.js +51 -0
- package/TablePagination/index.js.map +1 -0
- package/TablePagination/index.mjs +51 -0
- package/TablePagination/index.mjs.map +1 -0
- package/TableRow/index.d.ts +8 -0
- package/TableRow/index.js +4 -0
- package/TableRow/index.js.map +1 -0
- package/TableRow/index.mjs +4 -0
- package/TableRow/index.mjs.map +1 -0
- package/Tabs/index.d.ts +24 -0
- package/Tabs/index.js +188 -0
- package/Tabs/index.js.map +1 -0
- package/Tabs/index.mjs +188 -0
- package/Tabs/index.mjs.map +1 -0
- package/Text/index.d.ts +10 -0
- package/Text/index.js +10 -0
- package/Text/index.js.map +1 -0
- package/Text/index.mjs +10 -0
- package/Text/index.mjs.map +1 -0
- package/ThemeProvider/RenderRoot.js +22 -0
- package/ThemeProvider/RenderRoot.js.map +1 -0
- package/ThemeProvider/RenderRoot.mjs +22 -0
- package/ThemeProvider/RenderRoot.mjs.map +1 -0
- package/ThemeProvider/index.d.ts +8 -0
- package/ThemeProvider/index.js +4 -0
- package/ThemeProvider/index.js.map +1 -0
- package/ThemeProvider/index.mjs +4 -0
- package/ThemeProvider/index.mjs.map +1 -0
- package/Toast/index.d.ts +20 -0
- package/Toast/index.js +145 -0
- package/Toast/index.js.map +1 -0
- package/Toast/index.mjs +145 -0
- package/Toast/index.mjs.map +1 -0
- package/Tooltip/index.d.ts +16 -0
- package/Tooltip/index.js +29 -0
- package/Tooltip/index.js.map +1 -0
- package/Tooltip/index.mjs +29 -0
- package/Tooltip/index.mjs.map +1 -0
- package/ViewBox/index.d.ts +16 -0
- package/ViewBox/index.js +21 -0
- package/ViewBox/index.js.map +1 -0
- package/ViewBox/index.mjs +21 -0
- package/ViewBox/index.mjs.map +1 -0
- package/index.d.ts +56 -0
- package/index.js +1 -0
- package/index.js.map +1 -0
- package/index.mjs +1 -0
- package/index.mjs.map +1 -0
- package/package.json +41 -0
- package/readme.md +0 -0
- package/useCorner/index.d.ts +5 -0
- package/useCorner/index.js +17 -0
- package/useCorner/index.js.map +1 -0
- package/useCorner/index.mjs +17 -0
- package/useCorner/index.mjs.map +1 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const placements = [
|
|
2
|
+
"top",
|
|
3
|
+
"top-left",
|
|
4
|
+
"top-right",
|
|
5
|
+
"bottom",
|
|
6
|
+
"bottom-left",
|
|
7
|
+
"bottom-right",
|
|
8
|
+
"right",
|
|
9
|
+
"right-top",
|
|
10
|
+
"right-bottom",
|
|
11
|
+
"left",
|
|
12
|
+
"left-top",
|
|
13
|
+
"left-bottom"
|
|
14
|
+
];
|
|
15
|
+
const isOffScreen = (menu) => {
|
|
16
|
+
const { x, y, width, height } = menu.getBoundingClientRect();
|
|
17
|
+
return x < 0 || y < 0 || x + width > window.innerWidth || y + height > window.innerHeight;
|
|
18
|
+
};
|
|
19
|
+
let setStyles = ({ place, menu, target }) => {
|
|
20
|
+
const { height, width } = menu.getBoundingClientRect();
|
|
21
|
+
const targetBoundary = target.getBoundingClientRect();
|
|
22
|
+
let targetTop = targetBoundary.top + window.scrollY;
|
|
23
|
+
let targetBottom = targetBoundary.bottom + window.scrollY;
|
|
24
|
+
let targetLeft = targetBoundary.left + window.scrollX;
|
|
25
|
+
let targetRight = targetBoundary.right + window.scrollX;
|
|
26
|
+
const _styles = {
|
|
27
|
+
"top": () => {
|
|
28
|
+
menu.style.top = `${targetTop - height}px`;
|
|
29
|
+
menu.style.left = `${(targetLeft + (targetBoundary.width / 2)) - (width / 2)}px`;
|
|
30
|
+
},
|
|
31
|
+
"top-left": () => {
|
|
32
|
+
menu.style.top = `${targetTop - height}px`;
|
|
33
|
+
menu.style.left = `${targetLeft}px`;
|
|
34
|
+
},
|
|
35
|
+
"top-right": () => {
|
|
36
|
+
menu.style.top = `${targetTop - height}px`;
|
|
37
|
+
menu.style.left = `${targetRight - width}px`;
|
|
38
|
+
},
|
|
39
|
+
"bottom": () => {
|
|
40
|
+
menu.style.top = `${targetBottom}px`;
|
|
41
|
+
menu.style.left = `${(targetLeft + (targetBoundary.width / 2)) - (width / 2)}px`;
|
|
42
|
+
},
|
|
43
|
+
"bottom-left": () => {
|
|
44
|
+
menu.style.top = `${targetBottom}px`;
|
|
45
|
+
menu.style.left = `${targetLeft}px`;
|
|
46
|
+
},
|
|
47
|
+
"bottom-right": () => {
|
|
48
|
+
menu.style.top = `${targetBottom}px`;
|
|
49
|
+
menu.style.left = `${targetRight - width}px`;
|
|
50
|
+
},
|
|
51
|
+
"right": () => {
|
|
52
|
+
menu.style.top = `${(targetTop + (targetBoundary.height / 2)) - (height / 2)}px`;
|
|
53
|
+
menu.style.left = `${targetRight}px`;
|
|
54
|
+
},
|
|
55
|
+
"right-top": () => {
|
|
56
|
+
menu.style.top = `${targetTop}px`;
|
|
57
|
+
menu.style.left = `${targetRight}px`;
|
|
58
|
+
},
|
|
59
|
+
"right-bottom": () => {
|
|
60
|
+
menu.style.top = `${(targetTop + targetBoundary.height) - height}px`;
|
|
61
|
+
menu.style.left = `${targetRight}px`;
|
|
62
|
+
},
|
|
63
|
+
"left": () => {
|
|
64
|
+
menu.style.left = `${targetLeft - width}px`;
|
|
65
|
+
menu.style.top = `${(targetTop + (targetBoundary.height / 2)) - (height / 2)}px`;
|
|
66
|
+
},
|
|
67
|
+
"left-top": () => {
|
|
68
|
+
menu.style.top = `${targetTop}px`;
|
|
69
|
+
menu.style.left = `${targetLeft - width}px`;
|
|
70
|
+
},
|
|
71
|
+
"left-bottom": () => {
|
|
72
|
+
menu.style.top = `${targetBottom - height}px`;
|
|
73
|
+
menu.style.left = `${targetLeft - width}px`;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
_styles[place] && _styles[place]();
|
|
77
|
+
};
|
|
78
|
+
const placedMenu = ({ place, menu, target }) => {
|
|
79
|
+
setStyles({ place, menu, target });
|
|
80
|
+
if (isOffScreen(menu)) {
|
|
81
|
+
let found_placement = false;
|
|
82
|
+
for (let i = 0; i < placements.length; i++) {
|
|
83
|
+
let _place = placements[i];
|
|
84
|
+
setStyles({ place: _place, menu, target });
|
|
85
|
+
if (!isOffScreen(menu)) {
|
|
86
|
+
found_placement = true;
|
|
87
|
+
return _place;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (!found_placement) {
|
|
91
|
+
setStyles({ place, menu, target });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return place;
|
|
95
|
+
};export{placedMenu,placements};//# sourceMappingURL=placedMenu.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"placedMenu.mjs","sources":["../../src/Menu/placedMenu.ts"],"sourcesContent":["\n\nexport const placements = [\n \"top\",\n \"top-left\",\n \"top-right\",\n \"bottom\",\n \"bottom-left\",\n \"bottom-right\",\n \"right\",\n \"right-top\",\n \"right-bottom\",\n \"left\",\n \"left-top\",\n \"left-bottom\"\n] as const\n\n\nexport type PlacementTypes = typeof placements[number]\n\nconst isOffScreen = (menu: HTMLElement) => {\n const { x, y, width, height } = menu.getBoundingClientRect()\n return x < 0 || y < 0 || x + width > window.innerWidth || y + height > window.innerHeight\n};\n\ntype Props = {\n place: PlacementTypes,\n menu: HTMLElement,\n target: HTMLElement\n}\n\n\nlet setStyles = ({ place, menu, target }: Props) => {\n\n const { height, width } = menu.getBoundingClientRect()\n const targetBoundary = target.getBoundingClientRect()\n let targetTop = targetBoundary.top + window.scrollY\n let targetBottom = targetBoundary.bottom + window.scrollY\n let targetLeft = targetBoundary.left + window.scrollX\n let targetRight = targetBoundary.right + window.scrollX\n\n const _styles = {\n \"top\": () => {\n menu.style.top = `${targetTop - height}px`\n menu.style.left = `${(targetLeft + (targetBoundary.width / 2)) - (width / 2)}px`\n },\n \"top-left\": () => {\n menu.style.top = `${targetTop - height}px`\n menu.style.left = `${targetLeft}px`\n },\n \"top-right\": () => {\n menu.style.top = `${targetTop - height}px`\n menu.style.left = `${targetRight - width}px`\n },\n \"bottom\": () => {\n menu.style.top = `${targetBottom}px`\n menu.style.left = `${(targetLeft + (targetBoundary.width / 2)) - (width / 2)}px`\n },\n \"bottom-left\": () => {\n menu.style.top = `${targetBottom}px`\n menu.style.left = `${targetLeft}px`\n },\n \"bottom-right\": () => {\n menu.style.top = `${targetBottom}px`\n menu.style.left = `${targetRight - width}px`\n },\n \"right\": () => {\n menu.style.top = `${(targetTop + (targetBoundary.height / 2)) - (height / 2)}px`\n menu.style.left = `${targetRight}px`\n },\n \"right-top\": () => {\n menu.style.top = `${targetTop}px`\n menu.style.left = `${targetRight}px`\n },\n \"right-bottom\": () => {\n menu.style.top = `${(targetTop + targetBoundary.height) - height}px`\n menu.style.left = `${targetRight}px`\n },\n \"left\": () => {\n menu.style.left = `${targetLeft - width}px`\n menu.style.top = `${(targetTop + (targetBoundary.height / 2)) - (height / 2)}px`\n },\n \"left-top\": () => {\n menu.style.top = `${targetTop}px`\n menu.style.left = `${targetLeft - width}px`\n },\n \"left-bottom\": () => {\n menu.style.top = `${targetBottom - height}px`\n menu.style.left = `${targetLeft - width}px`\n }\n }\n _styles[place] && _styles[place]()\n}\n\nexport const placedMenu = ({ place, menu, target }: Props) => {\n setStyles({ place, menu, target })\n if (isOffScreen(menu)) {\n let found_placement = false\n for (let i = 0; i < placements.length; i++) {\n let _place = placements[i]\n setStyles({ place: _place, menu, target })\n if (!isOffScreen(menu)) {\n found_placement = true\n return _place\n }\n }\n if (!found_placement) {\n setStyles({ place, menu, target })\n }\n }\n return place\n}\n\n"],"names":[],"mappings":"AAEO,MAAM,UAAU,GAAG;IACtB,KAAK;IACL,UAAU;IACV,WAAW;IACX,QAAQ;IACR,aAAa;IACb,cAAc;IACd,OAAO;IACP,WAAW;IACX,cAAc;IACd,MAAM;IACN,UAAU;IACV;;AAMJ,MAAM,WAAW,GAAG,CAAC,IAAiB,KAAI;AACtC,IAAA,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,qBAAqB,EAAE;IAC5D,OAAO,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AE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1C,YAAA,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE;gBACpB,eAAe,GAAG,IAAI;AACtB,gBAAA,OAAO,MAAM;AAChB,YAAA;AACJ,QAAA;QACD,IAAI,CAAC,eAAe,EAAE;YAClB,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACrC,QAAA;AACJ,IAAA;AACD,IAAA,OAAO,KAAK;AAChB"}
|
package/Modal/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { LayerProps } from '../Layer/index.js';
|
|
4
|
+
import { useBreakpointPropsType, TagProps } from '@xanui/core';
|
|
5
|
+
|
|
6
|
+
type ModalProps = Omit<LayerProps, "slotProps"> & {
|
|
7
|
+
size?: useBreakpointPropsType<"xs" | "sm" | "md" | "lg" | "xl" | "fullWidth" | number>;
|
|
8
|
+
slotProps?: LayerProps['slotProps'] & {
|
|
9
|
+
modal?: Omit<TagProps<'div'>, "children">;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
declare const Modal: {
|
|
13
|
+
({ children, size, slotProps, ...props }: ModalProps): react_jsx_runtime.JSX.Element;
|
|
14
|
+
open(id: string, content: ReactNode, props?: Omit<ModalProps, "open" | "children">): void;
|
|
15
|
+
close(id: string): void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { Modal as default };
|
|
19
|
+
export type { ModalProps };
|
package/Modal/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var tslib=require('tslib'),jsxRuntime=require('react/jsx-runtime'),index=require('../Layer/index.js'),core=require('@xanui/core');const Modal = (_a) => {
|
|
2
|
+
var { children, size, slotProps } = _a, props = tslib.__rest(_a, ["children", "size", "slotProps"]);
|
|
3
|
+
const _p = {};
|
|
4
|
+
if (size)
|
|
5
|
+
_p.size = size;
|
|
6
|
+
const p = core.useBreakpointProps(_p);
|
|
7
|
+
size = p.size;
|
|
8
|
+
size !== null && size !== void 0 ? size : (size = "xs");
|
|
9
|
+
let sizes = {
|
|
10
|
+
xs: 420,
|
|
11
|
+
sm: 760,
|
|
12
|
+
md: 990,
|
|
13
|
+
lg: 1120,
|
|
14
|
+
xl: 1300,
|
|
15
|
+
fullWidth: "100%"
|
|
16
|
+
};
|
|
17
|
+
let _b = slotProps || {}, { modal } = _b, _slotProps = tslib.__rest(_b, ["modal"]);
|
|
18
|
+
return (jsxRuntime.jsx(index.default, Object.assign({ transition: "zoom" }, props, { slotProps: Object.assign(Object.assign({}, _slotProps), { root: Object.assign({ display: "flex", alignItems: 'center', justifyContent: "center" }, _slotProps === null || _slotProps === void 0 ? void 0 : _slotProps.root) }) }, { children: jsxRuntime.jsx(core.Tag, Object.assign({}, modal, { sxr: Object.assign({ maxWidth: sizes[size] || size, width: "100%", radius: 2, bgcolor: "background.primary", shadow: 15 }, modal === null || modal === void 0 ? void 0 : modal.sx), baseClass: 'modal' }, { children: children })) })));
|
|
19
|
+
};
|
|
20
|
+
Modal.open = (id, content, props) => {
|
|
21
|
+
id = "modal-" + id;
|
|
22
|
+
let { size, slotProps } = props || {};
|
|
23
|
+
size !== null && size !== void 0 ? size : (size = "xs");
|
|
24
|
+
let sizes = {
|
|
25
|
+
xs: 420,
|
|
26
|
+
sm: 760,
|
|
27
|
+
md: 990,
|
|
28
|
+
lg: 1120,
|
|
29
|
+
xl: 1300,
|
|
30
|
+
fullWidth: "100%"
|
|
31
|
+
};
|
|
32
|
+
let _a = slotProps || {}, { modal } = _a, _slotProps = tslib.__rest(_a, ["modal"]);
|
|
33
|
+
index.default.open(id, jsxRuntime.jsx(core.Tag, Object.assign({}, modal, { sxr: Object.assign({ maxWidth: sizes[size] || size, width: "100%", radius: 2, bgcolor: "background.primary", shadow: 15 }, modal === null || modal === void 0 ? void 0 : modal.sx), baseClass: 'modal' }, { children: content })), Object.assign(Object.assign({ transition: "zoom" }, props), { slotProps: Object.assign(Object.assign({}, _slotProps), { root: Object.assign({ display: "flex", alignItems: 'center', justifyContent: "center" }, _slotProps === null || _slotProps === void 0 ? void 0 : _slotProps.root) }) }));
|
|
34
|
+
};
|
|
35
|
+
Modal.close = (id) => {
|
|
36
|
+
id = "modal-" + id;
|
|
37
|
+
index.default.close(id);
|
|
38
|
+
};exports.default=Modal;//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Modal/index.tsx"],"sourcesContent":["\nimport { ReactNode } from 'react'\nimport Layer, { LayerProps } from \"../Layer\"\nimport { Tag, TagProps, useBreakpointProps, useBreakpointPropsType } from '@xanui/core'\n\n\n\nexport type ModalProps = Omit<LayerProps, \"slotProps\"> & {\n size?: useBreakpointPropsType<\"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"fullWidth\" | number>;\n slotProps?: LayerProps['slotProps'] & {\n modal?: Omit<TagProps<'div'>, \"children\">\n }\n}\n\n\nconst Modal = ({ children, size, slotProps, ...props }: ModalProps) => {\n const _p: any = {}\n if (size) _p.size = size\n const p: any = useBreakpointProps(_p)\n size = p.size\n size ??= \"xs\"\n let sizes: any = {\n xs: 420,\n sm: 760,\n md: 990,\n lg: 1120,\n xl: 1300,\n fullWidth: \"100%\"\n }\n\n let { modal, ..._slotProps }: any = slotProps || {}\n\n return (\n <Layer\n transition=\"zoom\"\n {...props}\n slotProps={{\n ..._slotProps,\n root: {\n display: \"flex\",\n alignItems: 'center',\n justifyContent: \"center\",\n ..._slotProps?.root,\n }\n }}\n >\n <Tag\n {...modal}\n sxr={{\n maxWidth: sizes[size as any] || size,\n width: \"100%\",\n radius: 2,\n bgcolor: \"background.primary\",\n shadow: 15,\n ...modal?.sx\n }}\n baseClass='modal'\n >\n {children}\n </Tag>\n </Layer>\n )\n}\n\n\nModal.open = (id: string, content: ReactNode, props?: Omit<ModalProps, \"open\" | \"children\">) => {\n id = \"modal-\" + id\n let { size, slotProps } = props || {}\n size ??= \"xs\"\n let sizes: any = {\n xs: 420,\n sm: 760,\n md: 990,\n lg: 1120,\n xl: 1300,\n fullWidth: \"100%\"\n }\n let { modal, ..._slotProps }: any = slotProps || {}\n\n Layer.open(id, <Tag\n {...modal}\n sxr={{\n maxWidth: sizes[size as any] || size,\n width: \"100%\",\n radius: 2,\n bgcolor: \"background.primary\",\n shadow: 15,\n ...modal?.sx\n }}\n baseClass='modal'\n >\n {content}\n </Tag>, {\n transition: \"zoom\",\n ...props,\n slotProps: {\n ..._slotProps,\n root: {\n display: \"flex\",\n alignItems: 'center',\n justifyContent: \"center\",\n ..._slotProps?.root,\n }\n }\n })\n}\n\nModal.close = (id: string) => {\n id = \"modal-\" + id\n Layer.close(id)\n}\n\nexport default Modal"],"names":["__rest","useBreakpointProps","_jsx","Layer","Tag"],"mappings":"wMAeA,MAAM,KAAK,GAAG,CAAC,EAAmD,KAAI;QAAvD,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,OAAwB,EAAnB,KAAK,GAAAA,YAAA,CAAA,EAAA,EAArC,CAAA,UAAA,EAAA,MAAA,EAAA,WAAA,CAAuC,CAAF;IAChD,MAAM,EAAE,GAAQ,EAAE;AAClB,IAAA,IAAI,IAAI;AAAE,QAAA,EAAE,CAAC,IAAI,GAAG,IAAI;AACxB,IAAA,MAAM,CAAC,GAAQC,uBAAkB,CAAC,EAAE,CAAC;AACrC,IAAA,IAAI,GAAG,CAAC,CAAC,IAAI;IACb,IAAI,KAAA,IAAA,IAAJ,IAAI,KAAA,MAAA,GAAJ,IAAI,IAAJ,IAAI,GAAK,IAAI,CAAA;AACb,IAAA,IAAI,KAAK,GAAQ;AACb,QAAA,EAAE,EAAE,GAAG;AACP,QAAA,EAAE,EAAE,GAAG;AACP,QAAA,EAAE,EAAE,GAAG;AACP,QAAA,EAAE,EAA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AA,GAAV,UAAU,CAAE,IAAI,QAG7B;AACN,CAAC;AAED,KAAK,CAAC,KAAK,GAAG,CAAC,EAAU,KAAI;AACzB,IAAA,EAAE,GAAG,QAAQ,GAAG,EAAE;AAClB,IAAAD,aAAK,CAAC,KAAK,CAAC,EAAE,CAAC;AACnB,CAAC"}
|
package/Modal/index.mjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {__rest}from'tslib';import {jsx}from'react/jsx-runtime';import Layer from'../Layer/index.mjs';import {useBreakpointProps,Tag}from'@xanui/core';const Modal = (_a) => {
|
|
2
|
+
var { children, size, slotProps } = _a, props = __rest(_a, ["children", "size", "slotProps"]);
|
|
3
|
+
const _p = {};
|
|
4
|
+
if (size)
|
|
5
|
+
_p.size = size;
|
|
6
|
+
const p = useBreakpointProps(_p);
|
|
7
|
+
size = p.size;
|
|
8
|
+
size !== null && size !== void 0 ? size : (size = "xs");
|
|
9
|
+
let sizes = {
|
|
10
|
+
xs: 420,
|
|
11
|
+
sm: 760,
|
|
12
|
+
md: 990,
|
|
13
|
+
lg: 1120,
|
|
14
|
+
xl: 1300,
|
|
15
|
+
fullWidth: "100%"
|
|
16
|
+
};
|
|
17
|
+
let _b = slotProps || {}, { modal } = _b, _slotProps = __rest(_b, ["modal"]);
|
|
18
|
+
return (jsx(Layer, Object.assign({ transition: "zoom" }, props, { slotProps: Object.assign(Object.assign({}, _slotProps), { root: Object.assign({ display: "flex", alignItems: 'center', justifyContent: "center" }, _slotProps === null || _slotProps === void 0 ? void 0 : _slotProps.root) }) }, { children: jsx(Tag, Object.assign({}, modal, { sxr: Object.assign({ maxWidth: sizes[size] || size, width: "100%", radius: 2, bgcolor: "background.primary", shadow: 15 }, modal === null || modal === void 0 ? void 0 : modal.sx), baseClass: 'modal' }, { children: children })) })));
|
|
19
|
+
};
|
|
20
|
+
Modal.open = (id, content, props) => {
|
|
21
|
+
id = "modal-" + id;
|
|
22
|
+
let { size, slotProps } = props || {};
|
|
23
|
+
size !== null && size !== void 0 ? size : (size = "xs");
|
|
24
|
+
let sizes = {
|
|
25
|
+
xs: 420,
|
|
26
|
+
sm: 760,
|
|
27
|
+
md: 990,
|
|
28
|
+
lg: 1120,
|
|
29
|
+
xl: 1300,
|
|
30
|
+
fullWidth: "100%"
|
|
31
|
+
};
|
|
32
|
+
let _a = slotProps || {}, { modal } = _a, _slotProps = __rest(_a, ["modal"]);
|
|
33
|
+
Layer.open(id, jsx(Tag, Object.assign({}, modal, { sxr: Object.assign({ maxWidth: sizes[size] || size, width: "100%", radius: 2, bgcolor: "background.primary", shadow: 15 }, modal === null || modal === void 0 ? void 0 : modal.sx), baseClass: 'modal' }, { children: content })), Object.assign(Object.assign({ transition: "zoom" }, props), { slotProps: Object.assign(Object.assign({}, _slotProps), { root: Object.assign({ display: "flex", alignItems: 'center', justifyContent: "center" }, _slotProps === null || _slotProps === void 0 ? void 0 : _slotProps.root) }) }));
|
|
34
|
+
};
|
|
35
|
+
Modal.close = (id) => {
|
|
36
|
+
id = "modal-" + id;
|
|
37
|
+
Layer.close(id);
|
|
38
|
+
};export{Modal as default};//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/Modal/index.tsx"],"sourcesContent":["\nimport { ReactNode } from 'react'\nimport Layer, { LayerProps } from \"../Layer\"\nimport { Tag, TagProps, useBreakpointProps, useBreakpointPropsType } from '@xanui/core'\n\n\n\nexport type ModalProps = Omit<LayerProps, \"slotProps\"> & {\n size?: useBreakpointPropsType<\"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"fullWidth\" | number>;\n slotProps?: LayerProps['slotProps'] & {\n modal?: Omit<TagProps<'div'>, \"children\">\n }\n}\n\n\nconst Modal = ({ children, size, slotProps, ...props }: ModalProps) => {\n const _p: any = {}\n if (size) _p.size = size\n const p: any = useBreakpointProps(_p)\n size = p.size\n size ??= \"xs\"\n let sizes: any = {\n xs: 420,\n sm: 760,\n md: 990,\n lg: 1120,\n xl: 1300,\n fullWidth: \"100%\"\n }\n\n let { modal, ..._slotProps }: any = slotProps || {}\n\n return (\n <Layer\n transition=\"zoom\"\n {...props}\n slotProps={{\n ..._slotProps,\n root: {\n display: \"flex\",\n alignItems: 'center',\n justifyContent: \"center\",\n ..._slotProps?.root,\n }\n }}\n >\n <Tag\n {...modal}\n sxr={{\n maxWidth: sizes[size as any] || size,\n width: \"100%\",\n radius: 2,\n bgcolor: \"background.primary\",\n shadow: 15,\n ...modal?.sx\n }}\n baseClass='modal'\n >\n {children}\n </Tag>\n </Layer>\n )\n}\n\n\nModal.open = (id: string, content: ReactNode, props?: Omit<ModalProps, \"open\" | \"children\">) => {\n id = \"modal-\" + id\n let { size, slotProps } = props || {}\n size ??= \"xs\"\n let sizes: any = {\n xs: 420,\n sm: 760,\n md: 990,\n lg: 1120,\n xl: 1300,\n fullWidth: \"100%\"\n }\n let { modal, ..._slotProps }: any = slotProps || {}\n\n Layer.open(id, <Tag\n {...modal}\n sxr={{\n maxWidth: sizes[size as any] || size,\n width: \"100%\",\n radius: 2,\n bgcolor: \"background.primary\",\n shadow: 15,\n ...modal?.sx\n }}\n baseClass='modal'\n >\n {content}\n </Tag>, {\n transition: \"zoom\",\n ...props,\n slotProps: {\n ..._slotProps,\n root: {\n display: \"flex\",\n alignItems: 'center',\n justifyContent: \"center\",\n ..._slotProps?.root,\n }\n }\n })\n}\n\nModal.close = (id: string) => {\n id = \"modal-\" + id\n Layer.close(id)\n}\n\nexport default Modal"],"names":["_jsx"],"mappings":"sJAeA,MAAM,KAAK,GAAG,CAAC,EAAmD,KAAI;QAAvD,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,OAAwB,EAAnB,KAAK,GAAA,MAAA,CAAA,EAAA,EAArC,CAAA,UAAA,EAAA,MAAA,EAAA,WAAA,CAAuC,CAAF;IAChD,MAAM,EAAE,GAAQ,EAAE;AAClB,IAAA,IAAI,IAAI;AAAE,QAAA,EAAE,CAAC,IAAI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MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EACF,UAAU,EAAE,MAAM,IACf,KAAK,CAAA,EAAA,EACR,SAAS,EAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACF,UAAU,KACb,IAAI,EAAA,MAAA,CAAA,MAAA,CAAA,EACA,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,QAAQ,EACpB,cAAc,EAAE,QAAQ,EAAA,EACrB,UAAU,aAAV,UAAU,KAAA,MAAA,GAAA,MAAA,GAAV,UAAU,CAAE,IAAI,QAG7B;AACN,CAAC;AAED,KAAK,CAAC,KAAK,GAAG,CAAC,EAAU,KAAI;AACzB,IAAA,EAAE,GAAG,QAAQ,GAAG,EAAE;AAClB,IAAA,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;AACnB,CAAC"}
|
package/NoSSR/index.d.ts
ADDED
package/NoSSR/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var React=require('react');const NoSSR = ({ children }) => {
|
|
2
|
+
const [isClient, setIsClient] = React.useState(false);
|
|
3
|
+
React.useEffect(() => {
|
|
4
|
+
setIsClient(true);
|
|
5
|
+
}, []);
|
|
6
|
+
return isClient ? children : null;
|
|
7
|
+
};exports.default=NoSSR;//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","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":["useState","useEffect"],"mappings":"iGAGA,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
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import {useState,useEffect}from'react';const NoSSR = ({ children }) => {
|
|
2
|
+
const [isClient, setIsClient] = useState(false);
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
setIsClient(true);
|
|
5
|
+
}, []);
|
|
6
|
+
return isClient ? children : null;
|
|
7
|
+
};export{NoSSR as default};//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +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":"uCAGA,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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ListItemProps } from '../ListItem/index.js';
|
|
3
|
+
|
|
4
|
+
type OptionProps = ListItemProps & {
|
|
5
|
+
value: string | number;
|
|
6
|
+
};
|
|
7
|
+
declare const Option: React.ForwardRefExoticComponent<Omit<OptionProps, "ref"> & React.RefAttributes<any>>;
|
|
8
|
+
|
|
9
|
+
export { Option as default };
|
|
10
|
+
export type { OptionProps };
|
package/Option/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var tslib=require('tslib'),jsxRuntime=require('react/jsx-runtime'),React=require('react'),index=require('../ListItem/index.js');const Option = React.forwardRef((_a, ref) => {
|
|
2
|
+
var { value, children } = _a, props = tslib.__rest(_a, ["value", "children"]);
|
|
3
|
+
return (jsxRuntime.jsx(index.default, Object.assign({}, props, { ref: ref }, { children: children })));
|
|
4
|
+
});exports.default=Option;//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","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":["__rest","_jsx","ListItem"],"mappings":"sMAQA,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,aAAQ,EAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAK,KAAK,EAAA,EAAE,GAAG,EAAE,GAAG,EAAA,EAAA,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAA,CAAY;AAE5D,CAAC"}
|
package/Option/index.mjs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import {__rest}from'tslib';import {jsx}from'react/jsx-runtime';import React from'react';import ListItem from'../ListItem/index.mjs';const Option = React.forwardRef((_a, ref) => {
|
|
2
|
+
var { value, children } = _a, props = __rest(_a, ["value", "children"]);
|
|
3
|
+
return (jsx(ListItem, Object.assign({}, props, { ref: ref }, { children: children })));
|
|
4
|
+
});export{Option as default};//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +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":"oIAQA,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,EAAA,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAA,CAAY;AAE5D,CAAC"}
|
package/Paper/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TagComponentType, TagProps } from '@xanui/core';
|
|
3
|
+
|
|
4
|
+
type PaperProps<T extends TagComponentType = "div"> = TagProps<T>;
|
|
5
|
+
declare const Paper: React.ForwardRefExoticComponent<Omit<PaperProps<TagComponentType>, "ref"> & React.RefAttributes<any>>;
|
|
6
|
+
|
|
7
|
+
export { Paper as default };
|
|
8
|
+
export type { PaperProps };
|
package/Paper/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var tslib=require('tslib'),jsxRuntime=require('react/jsx-runtime'),React=require('react'),core=require('@xanui/core');const Paper = React.forwardRef((_a, ref) => {
|
|
2
|
+
var { children } = _a, rest = tslib.__rest(_a, ["children"]);
|
|
3
|
+
let [props] = core.useInterface("default", rest, {});
|
|
4
|
+
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
|
+
});exports.default=Paper;//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","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":["__rest","useInterface","_jsx","Tag"],"mappings":"4LAMA,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,gBACV,QAAQ,EAAA,CAAA,CAAO;AAEzB,CAAC"}
|
package/Paper/index.mjs
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import {__rest}from'tslib';import {jsx}from'react/jsx-runtime';import React from'react';import {useInterface,Tag}from'@xanui/core';const Paper = React.forwardRef((_a, ref) => {
|
|
2
|
+
var { children } = _a, rest = __rest(_a, ["children"]);
|
|
3
|
+
let [props] = useInterface("default", rest, {});
|
|
4
|
+
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
|
+
});export{Paper as default};//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +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":"mIAMA,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,gBACV,QAAQ,EAAA,CAAA,CAAO;AAEzB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TagComponentType, TagProps } from '@xanui/core';
|
|
3
|
+
|
|
4
|
+
type PortalProps<T extends TagComponentType = "div"> = TagProps<T> & {
|
|
5
|
+
appendTo?: HTMLElement;
|
|
6
|
+
container?: HTMLElement;
|
|
7
|
+
};
|
|
8
|
+
declare const Portal: React.ForwardRefExoticComponent<Omit<PortalProps<TagComponentType>, "ref"> & React.RefAttributes<any>>;
|
|
9
|
+
|
|
10
|
+
export { Portal as default };
|
|
11
|
+
export type { PortalProps };
|
package/Portal/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var tslib=require('tslib'),jsxRuntime=require('react/jsx-runtime'),React=require('react'),ReactDOM=require('react-dom'),core=require('@xanui/core');const Portal = React.forwardRef((_a, ref) => {
|
|
2
|
+
var { children, component, appendTo, container } = _a, rest = tslib.__rest(_a, ["children", "component", "appendTo", "container"]);
|
|
3
|
+
const [_container, setContainer] = React.useState(container);
|
|
4
|
+
let props = core.useTagProps(rest);
|
|
5
|
+
const theme = core.useTheme();
|
|
6
|
+
React.useEffect(() => {
|
|
7
|
+
appendTo = appendTo || document.body;
|
|
8
|
+
let _con = _container || document.createElement(component || "div");
|
|
9
|
+
appendTo.appendChild(_con);
|
|
10
|
+
for (let prop in props) {
|
|
11
|
+
_con.setAttribute(prop, props[prop]);
|
|
12
|
+
}
|
|
13
|
+
if (!_container) {
|
|
14
|
+
setContainer(_con);
|
|
15
|
+
}
|
|
16
|
+
if (ref) {
|
|
17
|
+
ref.current = _con;
|
|
18
|
+
}
|
|
19
|
+
return () => {
|
|
20
|
+
appendTo.removeChild(_con);
|
|
21
|
+
};
|
|
22
|
+
}, []);
|
|
23
|
+
if (!_container)
|
|
24
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
25
|
+
return ReactDOM.createPortal(jsxRuntime.jsx(core.ThemeProvider, Object.assign({ theme: theme.name }, { children: children })), _container);
|
|
26
|
+
});exports.default=Portal;//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Portal/index.tsx"],"sourcesContent":["\nimport React, { useEffect, useState } from 'react'\nimport ReactDOM from 'react-dom';\nimport { useTagProps, TagProps, TagComponentType, useTheme, ThemeProvider } from '@xanui/core';\nexport type PortalProps<T extends TagComponentType = \"div\"> = TagProps<T> & {\n appendTo?: HTMLElement;\n container?: HTMLElement;\n}\n\nconst Portal = React.forwardRef(<T extends TagComponentType = \"div\">({ children, component, appendTo, container, ...rest }: PortalProps<T>, ref?: React.Ref<any>) => {\n const [_container, setContainer] = useState<HTMLElement | undefined>(container)\n let props = useTagProps(rest)\n const theme = useTheme()\n\n useEffect(() => {\n appendTo = appendTo || document.body\n let _con: HTMLElement = _container || document.createElement(component as any || \"div\");\n appendTo.appendChild(_con);\n for (let prop in props) {\n _con.setAttribute(prop, (props as any)[prop])\n }\n if (!_container) {\n setContainer(_con)\n }\n if (ref) {\n (ref as any).current = _con\n }\n return () => {\n (appendTo as any).removeChild(_con);\n }\n }, [])\n\n if (!_container) return <></>\n\n return ReactDOM.createPortal(\n <ThemeProvider theme={theme.name}>\n {children}\n </ThemeProvider>,\n _container,\n );\n})\n\nexport default Portal"],"names":["__rest","useState","useTagProps","useTheme","useEffect","_jsx","ThemeProvider"],"mappings":"0NASA,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,CAAqC,EAAqE,EAAE,GAAoB,KAAI;AAA/F,IAAA,IAAA,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAA,GAAA,EAA2B,EAAtB,IAAI,GAAAA,YAAA,CAAA,EAAA,EAAnD,CAAA,UAAA,EAAA,WAAA,EAAA,UAAA,EAAA,WAAA,CAAqD,CAAF;IACpH,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,GAAGC,cAAQ,CAA0B,SAAS,CAAC;AAC/E,IAAA,IAAI,KAAK,GAAGC,gBAAW,CAAC,IAAI,CAAC;AAC7B,IAAA,MAAM,KAAK,GAAGC,aAAQ,EAAE;IAExBC,eAAS,CAAC,MAAK;AACX,QAAA,QAAQ,GAAG,QAAQ,IAAI,QAAQ,CAAC,IAAI;AACpC,QAAA,IAAI,IAAI,GAAgB,UAAU,IAAI,QAAQ,CAAC,aAAa,CAAC,SAAgB,IAAI,KAAK,CAAC;AACvF,QAAA,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC;AAC1B,QAAA,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE;YACpB,IAAI,CAAC,YAAY,CAAC,IAAI,EAAG,KAAa,CAAC,IAAI,CAAC,CAAC;AAChD,QAAA;QACD,IAAI,CAAC,UAAU,EAAE;YACb,YAAY,CAAC,IAAI,CAAC;AACrB,QAAA;AACD,QAAA,IAAI,GAAG,EAAE;AACJ,YAAA,GAAW,CAAC,OAAO,GAAG,IAAI;AAC9B,QAAA;AACD,QAAA,OAAO,MAAK;AACP,YAAA,QAAgB,CAAC,WAAW,CAAC,IAAI,CAAC;AACvC,QAAA,CAAC;IACL,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,IAAI,CAAC,UAAU;AAAE,QAAA,OAAOC,uCAAK;AAE7B,IAAA,OAAO,QAAQ,CAAC,YAAY,CACxBA,cAAA,CAACC,kBAAa,kBAAC,KAAK,EAAE,KAAK,CAAC,IAAI,EAAA,EAAA,EAAA,QAAA,EAC3B,QAAQ,IACG,EAChB,UAAU,CACb;AACL,CAAC"}
|
package/Portal/index.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {__rest}from'tslib';import {jsx,Fragment}from'react/jsx-runtime';import React,{useState,useEffect}from'react';import ReactDOM from'react-dom';import {useTagProps,useTheme,ThemeProvider}from'@xanui/core';const Portal = React.forwardRef((_a, ref) => {
|
|
2
|
+
var { children, component, appendTo, container } = _a, rest = __rest(_a, ["children", "component", "appendTo", "container"]);
|
|
3
|
+
const [_container, setContainer] = useState(container);
|
|
4
|
+
let props = useTagProps(rest);
|
|
5
|
+
const theme = useTheme();
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
appendTo = appendTo || document.body;
|
|
8
|
+
let _con = _container || document.createElement(component || "div");
|
|
9
|
+
appendTo.appendChild(_con);
|
|
10
|
+
for (let prop in props) {
|
|
11
|
+
_con.setAttribute(prop, props[prop]);
|
|
12
|
+
}
|
|
13
|
+
if (!_container) {
|
|
14
|
+
setContainer(_con);
|
|
15
|
+
}
|
|
16
|
+
if (ref) {
|
|
17
|
+
ref.current = _con;
|
|
18
|
+
}
|
|
19
|
+
return () => {
|
|
20
|
+
appendTo.removeChild(_con);
|
|
21
|
+
};
|
|
22
|
+
}, []);
|
|
23
|
+
if (!_container)
|
|
24
|
+
return jsx(Fragment, {});
|
|
25
|
+
return ReactDOM.createPortal(jsx(ThemeProvider, Object.assign({ theme: theme.name }, { children: children })), _container);
|
|
26
|
+
});export{Portal as default};//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/Portal/index.tsx"],"sourcesContent":["\nimport React, { useEffect, useState } from 'react'\nimport ReactDOM from 'react-dom';\nimport { useTagProps, TagProps, TagComponentType, useTheme, ThemeProvider } from '@xanui/core';\nexport type PortalProps<T extends TagComponentType = \"div\"> = TagProps<T> & {\n appendTo?: HTMLElement;\n container?: HTMLElement;\n}\n\nconst Portal = React.forwardRef(<T extends TagComponentType = \"div\">({ children, component, appendTo, container, ...rest }: PortalProps<T>, ref?: React.Ref<any>) => {\n const [_container, setContainer] = useState<HTMLElement | undefined>(container)\n let props = useTagProps(rest)\n const theme = useTheme()\n\n useEffect(() => {\n appendTo = appendTo || document.body\n let _con: HTMLElement = _container || document.createElement(component as any || \"div\");\n appendTo.appendChild(_con);\n for (let prop in props) {\n _con.setAttribute(prop, (props as any)[prop])\n }\n if (!_container) {\n setContainer(_con)\n }\n if (ref) {\n (ref as any).current = _con\n }\n return () => {\n (appendTo as any).removeChild(_con);\n }\n }, [])\n\n if (!_container) return <></>\n\n return ReactDOM.createPortal(\n <ThemeProvider theme={theme.name}>\n {children}\n </ThemeProvider>,\n _container,\n );\n})\n\nexport default Portal"],"names":["_jsx"],"mappings":"kNASA,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,CAAqC,EAAqE,EAAE,GAAoB,KAAI;AAA/F,IAAA,IAAA,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAA,GAAA,EAA2B,EAAtB,IAAI,GAAA,MAAA,CAAA,EAAA,EAAnD,CAAA,UAAA,EAAA,WAAA,EAAA,UAAA,EAAA,WAAA,CAAqD,CAAF;IACpH,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,GAAG,QAAQ,CAA0B,SAAS,CAAC;AAC/E,IAAA,IAAI,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC;AAC7B,IAAA,MAAM,KAAK,GAAG,QAAQ,EAAE;IAExB,SAAS,CAAC,MAAK;AACX,QAAA,QAAQ,GAAG,QAAQ,IAAI,QAAQ,CAAC,IAAI;AACpC,QAAA,IAAI,IAAI,GAAgB,UAAU,IAAI,QAAQ,CAAC,aAAa,CAAC,SAAgB,IAAI,KAAK,CAAC;AACvF,QAAA,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC;AAC1B,QAAA,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE;YACpB,IAAI,CAAC,YAAY,CAAC,IAAI,EAAG,KAAa,CAAC,IAAI,CAAC,CAAC;AAChD,QAAA;QACD,IAAI,CAAC,UAAU,EAAE;YACb,YAAY,CAAC,IAAI,CAAC;AACrB,QAAA;AACD,QAAA,IAAI,GAAG,EAAE;AACJ,YAAA,GAAW,CAAC,OAAO,GAAG,IAAI;AAC9B,QAAA;AACD,QAAA,OAAO,MAAK;AACP,YAAA,QAAgB,CAAC,WAAW,CAAC,IAAI,CAAC;AACvC,QAAA,CAAC;IACL,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,IAAI,CAAC,UAAU;AAAE,QAAA,OAAOA,iBAAK;AAE7B,IAAA,OAAO,QAAQ,CAAC,YAAY,CACxBA,GAAA,CAAC,aAAa,kBAAC,KAAK,EAAE,KAAK,CAAC,IAAI,EAAA,EAAA,EAAA,QAAA,EAC3B,QAAQ,IACG,EAChB,UAAU,CACb;AACL,CAAC"}
|
package/Radio/index.d.ts
ADDED
package/Radio/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var jsxRuntime=require('react/jsx-runtime'),React=require('react'),core=require('@xanui/core'),CheckIcon=require('@xanui/icons/RadioButtonChecked'),UnCheckIcon=require('@xanui/icons/RadioButtonUnchecked'),index=require('../Checkbox/index.js');const Radio = React.forwardRef((props, ref) => {
|
|
2
|
+
let [rest] = core.useInterface("Radio", props, {});
|
|
3
|
+
return jsxRuntime.jsx(index.default, 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) || [])] }));
|
|
4
|
+
});exports.default=Radio;//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","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":["useInterface","_jsx","Checkbox"],"mappings":"yTAQA,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,aAAQ,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
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import {jsx}from'react/jsx-runtime';import React from'react';import {useInterface}from'@xanui/core';import CheckIcon from'@xanui/icons/RadioButtonChecked';import UnCheckIcon from'@xanui/icons/RadioButtonUnchecked';import Checkbox from'../Checkbox/index.mjs';const Radio = React.forwardRef((props, ref) => {
|
|
2
|
+
let [rest] = useInterface("Radio", props, {});
|
|
3
|
+
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
|
+
});export{Radio as default};//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +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":"kQAQA,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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TagComponentType, TagProps, useBreakpointPropsType } from '@xanui/core';
|
|
2
|
+
import React, { ReactNode, UIEvent } from 'react';
|
|
3
|
+
|
|
4
|
+
type ScrollbarProps<T extends TagComponentType = "div"> = TagProps<T> & {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
thumbSize?: useBreakpointPropsType<number>;
|
|
7
|
+
thumbColor?: useBreakpointPropsType<string>;
|
|
8
|
+
trackColor?: useBreakpointPropsType<string>;
|
|
9
|
+
onScrollEnd?: (e: UIEvent<HTMLDivElement>) => void;
|
|
10
|
+
};
|
|
11
|
+
declare const Scrollbar: React.ForwardRefExoticComponent<Omit<ScrollbarProps<TagComponentType>, "ref"> & React.RefAttributes<any>>;
|
|
12
|
+
|
|
13
|
+
export { Scrollbar as default };
|
|
14
|
+
export type { ScrollbarProps };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var tslib=require('tslib'),jsxRuntime=require('react/jsx-runtime'),core=require('@xanui/core'),React=require('react');const Scrollbar = React.forwardRef((_a, ref) => {
|
|
2
|
+
var _b, _c, _d;
|
|
3
|
+
var { children } = _a, rest = tslib.__rest(_a, ["children"]);
|
|
4
|
+
let [_e] = core.useInterface("Scrollbar", rest, {}), { thumbSize, thumbColor, trackColor, onScroll, onScrollEnd } = _e, props = tslib.__rest(_e, ["thumbSize", "thumbColor", "trackColor", "onScroll", "onScrollEnd"]);
|
|
5
|
+
const _p = {};
|
|
6
|
+
if (thumbSize)
|
|
7
|
+
_p.thumbSize = thumbSize;
|
|
8
|
+
if (thumbColor)
|
|
9
|
+
_p.thumbColor = thumbColor;
|
|
10
|
+
if (trackColor)
|
|
11
|
+
_p.trackColor = trackColor;
|
|
12
|
+
const p = core.useBreakpointProps(_p);
|
|
13
|
+
thumbSize = (_b = p.thumbSize) !== null && _b !== void 0 ? _b : 10;
|
|
14
|
+
thumbColor = (_c = p.thumbColor) !== null && _c !== void 0 ? _c : "var(--color-divider)";
|
|
15
|
+
trackColor = (_d = p.trackColor) !== null && _d !== void 0 ? _d : "var(--color-background-secondary)";
|
|
16
|
+
ref = ref || React.useRef(null);
|
|
17
|
+
React.useMemo(() => {
|
|
18
|
+
ref.scrollTo = (pos) => {
|
|
19
|
+
ref.current.scrollTo({ top: pos, behavior: 'smooth' });
|
|
20
|
+
};
|
|
21
|
+
ref.scrollToBottom = () => {
|
|
22
|
+
ref.scrollTo(ref.current.scrollHeight);
|
|
23
|
+
};
|
|
24
|
+
ref.scrollToTop = () => {
|
|
25
|
+
ref.scrollTo(0);
|
|
26
|
+
};
|
|
27
|
+
}, []);
|
|
28
|
+
if (onScroll || onScrollEnd) {
|
|
29
|
+
props.onScroll = (e) => {
|
|
30
|
+
if (onScrollEnd) {
|
|
31
|
+
const ele = e.target;
|
|
32
|
+
const scrollTop = ele.scrollTop;
|
|
33
|
+
const scrollHeight = ele.scrollHeight;
|
|
34
|
+
const clientHeight = ele.clientHeight;
|
|
35
|
+
const isScrollDown = scrollHeight - scrollTop <= clientHeight + 1;
|
|
36
|
+
isScrollDown && onScrollEnd(e);
|
|
37
|
+
}
|
|
38
|
+
onScroll && onScroll(e);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return (jsxRuntime.jsx(core.Tag, Object.assign({}, props, { ref: ref, baseClass: 'scrollbar', sxr: {
|
|
42
|
+
height: "100%",
|
|
43
|
+
width: "100%",
|
|
44
|
+
overflow: "auto",
|
|
45
|
+
// scrollbarWidth: "thin", // Firefox specific
|
|
46
|
+
// scrollbarColor: `${thumbColor} ${trackColor}`, //"#888 #f4f4f4", // Thumb and track colors for Firefox
|
|
47
|
+
// msOverflowStyle: "scrollbar", // Internet Explorer
|
|
48
|
+
"&::-webkit-scrollbar": {
|
|
49
|
+
width: thumbSize,
|
|
50
|
+
height: thumbSize, // Height of the horizontal scrollbar
|
|
51
|
+
},
|
|
52
|
+
"&::-webkit-scrollbar-thumb": {
|
|
53
|
+
backgroundColor: thumbColor,
|
|
54
|
+
borderRadius: "5px",
|
|
55
|
+
border: "2px solid #f4f4f4", // Space around the thumb
|
|
56
|
+
},
|
|
57
|
+
"&::-webkit-scrollbar-thumb:hover": {
|
|
58
|
+
backgroundColor: thumbColor, // Thumb color on hover
|
|
59
|
+
},
|
|
60
|
+
"&::-webkit-scrollbar-track": {
|
|
61
|
+
backgroundColor: trackColor,
|
|
62
|
+
borderRadius: "5px", // Rounded corners
|
|
63
|
+
},
|
|
64
|
+
} }, { children: children })));
|
|
65
|
+
});exports.default=Scrollbar;//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Scrollbar/index.tsx"],"sourcesContent":["\nimport { Tag, TagComponentType, TagProps, useBreakpointProps, useInterface, useBreakpointPropsType } from '@xanui/core';\n\nimport React, { ReactNode, UIEvent, useMemo, useRef } from 'react'\n\nexport type ScrollbarProps<T extends TagComponentType = \"div\"> = TagProps<T> & {\n children: ReactNode;\n thumbSize?: useBreakpointPropsType<number>;\n thumbColor?: useBreakpointPropsType<string>;\n trackColor?: useBreakpointPropsType<string>;\n onScrollEnd?: (e: UIEvent<HTMLDivElement>) => void;\n}\n\nconst Scrollbar = React.forwardRef(<T extends TagComponentType = \"div\">({ children, ...rest }: ScrollbarProps<T>, ref: React.Ref<any>) => {\n let [{ thumbSize, thumbColor, trackColor, onScroll, onScrollEnd, ...props }] = useInterface<any>(\"Scrollbar\", rest, {})\n const _p: any = {}\n if (thumbSize) _p.thumbSize = thumbSize\n if (thumbColor) _p.thumbColor = thumbColor\n if (trackColor) _p.trackColor = trackColor\n const p: any = useBreakpointProps(_p)\n\n thumbSize = p.thumbSize ?? 10\n thumbColor = p.thumbColor ?? \"var(--color-divider)\"\n trackColor = p.trackColor ?? \"var(--color-background-secondary)\"\n\n ref = ref || useRef(null)\n\n useMemo(() => {\n ((ref as any)).scrollTo = (pos: number) => {\n (ref as any).current.scrollTo({ top: pos, behavior: 'smooth' })\n }\n (ref as any).scrollToBottom = () => {\n (ref as any).scrollTo((ref as any).current.scrollHeight)\n }\n (ref as any).scrollToTop = () => {\n (ref as any).scrollTo(0)\n }\n }, [])\n\n if (onScroll || onScrollEnd) {\n props.onScroll = (e: UIEvent<HTMLDivElement>) => {\n if (onScrollEnd) {\n const ele: any = e.target\n const scrollTop = ele.scrollTop\n const scrollHeight = ele.scrollHeight\n const clientHeight = ele.clientHeight\n const isScrollDown = scrollHeight - scrollTop <= clientHeight + 1\n isScrollDown && onScrollEnd(e)\n }\n onScroll && onScroll(e)\n }\n }\n\n return (\n <Tag\n {...props}\n ref={ref}\n baseClass='scrollbar'\n sxr={{\n height: \"100%\",\n width: \"100%\",\n overflow: \"auto\",\n // scrollbarWidth: \"thin\", // Firefox specific\n // scrollbarColor: `${thumbColor} ${trackColor}`, //\"#888 #f4f4f4\", // Thumb and track colors for Firefox\n // msOverflowStyle: \"scrollbar\", // Internet Explorer\n \"&::-webkit-scrollbar\": {\n width: thumbSize, // Width of the vertical scrollbar\n height: thumbSize, // Height of the horizontal scrollbar\n },\n \"&::-webkit-scrollbar-thumb\": {\n backgroundColor: thumbColor, // Color of the scroll thumb\n borderRadius: \"5px\", // Rounded corners\n border: \"2px solid #f4f4f4\", // Space around the thumb\n },\n \"&::-webkit-scrollbar-thumb:hover\": {\n backgroundColor: thumbColor, // Thumb color on hover\n },\n \"&::-webkit-scrollbar-track\": {\n backgroundColor: trackColor, // Background color of the scrollbar track\n borderRadius: \"5px\", // Rounded corners\n },\n }}\n >\n {children}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