@xanui/ui 1.2.6 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Accordion/index.cjs +5 -5
- package/Accordion/index.cjs.map +1 -1
- package/Accordion/index.d.ts +3 -3
- package/Accordion/index.js +5 -5
- package/Accordion/index.js.map +1 -1
- package/Alert/index.cjs +19 -17
- package/Alert/index.cjs.map +1 -1
- package/Alert/index.d.ts +2 -2
- package/Alert/index.js +19 -17
- package/Alert/index.js.map +1 -1
- package/Autocomplete/index.cjs +2 -2
- package/Autocomplete/index.cjs.map +1 -1
- package/Autocomplete/index.d.ts +7 -7
- package/Autocomplete/index.js +2 -2
- package/Autocomplete/index.js.map +1 -1
- package/Avatar/index.cjs +2 -2
- package/Avatar/index.cjs.map +1 -1
- package/Avatar/index.d.ts +2 -2
- package/Avatar/index.js +2 -2
- package/Avatar/index.js.map +1 -1
- package/AvatarBox/index.cjs +19 -0
- package/AvatarBox/index.cjs.map +1 -0
- package/AvatarBox/index.d.ts +19 -0
- package/AvatarBox/index.js +17 -0
- package/AvatarBox/index.js.map +1 -0
- package/AvatarPicker/index.cjs +80 -0
- package/AvatarPicker/index.cjs.map +1 -0
- package/AvatarPicker/index.d.ts +27 -0
- package/AvatarPicker/index.js +78 -0
- package/AvatarPicker/index.js.map +1 -0
- package/Badge/index.cjs +1 -1
- package/Badge/index.cjs.map +1 -1
- package/Badge/index.d.ts +4 -4
- package/Badge/index.js +1 -1
- package/Badge/index.js.map +1 -1
- package/Box/index.d.ts +2 -2
- package/Button/index.cjs +5 -3
- package/Button/index.cjs.map +1 -1
- package/Button/index.d.ts +2 -2
- package/Button/index.js +5 -3
- package/Button/index.js.map +1 -1
- package/ButtonGroup/index.cjs +3 -2
- package/ButtonGroup/index.cjs.map +1 -1
- package/ButtonGroup/index.d.ts +2 -2
- package/ButtonGroup/index.js +3 -2
- package/ButtonGroup/index.js.map +1 -1
- package/Calendar/index.cjs +10 -10
- package/Calendar/index.cjs.map +1 -1
- package/Calendar/index.js +10 -10
- package/Calendar/index.js.map +1 -1
- package/CalendarInput/index.cjs +1 -1
- package/CalendarInput/index.cjs.map +1 -1
- package/CalendarInput/index.js +1 -1
- package/CalendarInput/index.js.map +1 -1
- package/Carousel/index.cjs +231 -0
- package/Carousel/index.cjs.map +1 -0
- package/Carousel/index.d.ts +28 -0
- package/Carousel/index.js +229 -0
- package/Carousel/index.js.map +1 -0
- package/Checkbox/index.cjs +2 -2
- package/Checkbox/index.cjs.map +1 -1
- package/Checkbox/index.d.ts +2 -2
- package/Checkbox/index.js +2 -2
- package/Checkbox/index.js.map +1 -1
- package/Chip/index.cjs +3 -3
- package/Chip/index.cjs.map +1 -1
- package/Chip/index.d.ts +2 -2
- package/Chip/index.js +3 -3
- package/Chip/index.js.map +1 -1
- package/CircleProgress/index.cjs +10 -10
- package/CircleProgress/index.cjs.map +1 -1
- package/CircleProgress/index.d.ts +2 -2
- package/CircleProgress/index.js +10 -10
- package/CircleProgress/index.js.map +1 -1
- package/ClickOutside/index.cjs +3 -12
- package/ClickOutside/index.cjs.map +1 -1
- package/ClickOutside/index.d.ts +3 -3
- package/ClickOutside/index.js +4 -13
- package/ClickOutside/index.js.map +1 -1
- package/Collaps/index.cjs +5 -5
- package/Collaps/index.cjs.map +1 -1
- package/Collaps/index.d.ts +2 -2
- package/Collaps/index.js +5 -5
- package/Collaps/index.js.map +1 -1
- package/Container/index.d.ts +2 -2
- package/DataFilter/index.d.ts +2 -2
- package/DataFilter/options/DateFilter.cjs +3 -3
- package/DataFilter/options/DateFilter.cjs.map +1 -1
- package/DataFilter/options/DateFilter.js +3 -3
- package/DataFilter/options/DateFilter.js.map +1 -1
- package/DataFilter/options/DateRangeFilter.cjs +2 -2
- package/DataFilter/options/DateRangeFilter.cjs.map +1 -1
- package/DataFilter/options/DateRangeFilter.js +2 -2
- package/DataFilter/options/DateRangeFilter.js.map +1 -1
- package/DataFilter/options/MultiSelectFilter.cjs +3 -3
- package/DataFilter/options/MultiSelectFilter.cjs.map +1 -1
- package/DataFilter/options/MultiSelectFilter.js +3 -3
- package/DataFilter/options/MultiSelectFilter.js.map +1 -1
- package/DataFilter/options/NumberFilter.cjs +2 -2
- package/DataFilter/options/NumberFilter.cjs.map +1 -1
- package/DataFilter/options/NumberFilter.js +2 -2
- package/DataFilter/options/NumberFilter.js.map +1 -1
- package/DataFilter/options/NumberRangeFilter.cjs +2 -2
- package/DataFilter/options/NumberRangeFilter.cjs.map +1 -1
- package/DataFilter/options/NumberRangeFilter.js +2 -2
- package/DataFilter/options/NumberRangeFilter.js.map +1 -1
- package/DataFilter/options/SelectFilter.cjs +3 -3
- package/DataFilter/options/SelectFilter.cjs.map +1 -1
- package/DataFilter/options/SelectFilter.js +3 -3
- package/DataFilter/options/SelectFilter.js.map +1 -1
- package/DataFilter/options/TextFilter.cjs +2 -2
- package/DataFilter/options/TextFilter.cjs.map +1 -1
- package/DataFilter/options/TextFilter.js +2 -2
- package/DataFilter/options/TextFilter.js.map +1 -1
- package/Datatable/FilterBox.cjs +2 -2
- package/Datatable/FilterBox.cjs.map +1 -1
- package/Datatable/FilterBox.js +2 -2
- package/Datatable/FilterBox.js.map +1 -1
- package/Datatable/Row.cjs +2 -2
- package/Datatable/Row.cjs.map +1 -1
- package/Datatable/Row.js +2 -2
- package/Datatable/Row.js.map +1 -1
- package/Datatable/SelectedBox.cjs +2 -2
- package/Datatable/SelectedBox.cjs.map +1 -1
- package/Datatable/SelectedBox.js +2 -2
- package/Datatable/SelectedBox.js.map +1 -1
- package/Datatable/Table.cjs +1 -1
- package/Datatable/Table.cjs.map +1 -1
- package/Datatable/Table.js +1 -1
- package/Datatable/Table.js.map +1 -1
- package/Datatable/TableHead.cjs +3 -3
- package/Datatable/TableHead.cjs.map +1 -1
- package/Datatable/TableHead.js +3 -3
- package/Datatable/TableHead.js.map +1 -1
- package/Datatable/index.cjs +1 -1
- package/Datatable/index.cjs.map +1 -1
- package/Datatable/index.d.ts +2 -2
- package/Datatable/index.js +1 -1
- package/Datatable/index.js.map +1 -1
- package/Divider/index.cjs +3 -3
- package/Divider/index.cjs.map +1 -1
- package/Divider/index.d.ts +2 -2
- package/Divider/index.js +3 -3
- package/Divider/index.js.map +1 -1
- package/Drawer/index.cjs +2 -2
- package/Drawer/index.cjs.map +1 -1
- package/Drawer/index.js +2 -2
- package/Drawer/index.js.map +1 -1
- package/FilePicker/index.cjs +115 -0
- package/FilePicker/index.cjs.map +1 -0
- package/FilePicker/index.d.ts +23 -0
- package/FilePicker/index.js +113 -0
- package/FilePicker/index.js.map +1 -0
- package/Form/index.cjs +1 -1
- package/Form/index.cjs.map +1 -1
- package/Form/index.d.ts +2 -2
- package/Form/index.js +1 -1
- package/Form/index.js.map +1 -1
- package/GalleryPicker/index.cjs +88 -0
- package/GalleryPicker/index.cjs.map +1 -0
- package/GalleryPicker/index.d.ts +26 -0
- package/GalleryPicker/index.js +86 -0
- package/GalleryPicker/index.js.map +1 -0
- package/GridContainer/index.d.ts +2 -2
- package/GridItem/index.d.ts +2 -2
- package/IconButton/index.cjs +6 -3
- package/IconButton/index.cjs.map +1 -1
- package/IconButton/index.d.ts +2 -2
- package/IconButton/index.js +6 -3
- package/IconButton/index.js.map +1 -1
- package/Image/index.cjs +2 -14
- package/Image/index.cjs.map +1 -1
- package/Image/index.d.ts +3 -5
- package/Image/index.js +3 -15
- package/Image/index.js.map +1 -1
- package/Input/index.cjs +10 -10
- package/Input/index.cjs.map +1 -1
- package/Input/index.d.ts +14 -14
- package/Input/index.js +10 -10
- package/Input/index.js.map +1 -1
- package/InputNumber/index.d.ts +2 -2
- package/Label/index.cjs +1 -1
- package/Label/index.cjs.map +1 -1
- package/Label/index.d.ts +2 -2
- package/Label/index.js +1 -1
- package/Label/index.js.map +1 -1
- package/Layer/index.cjs +12 -13
- package/Layer/index.cjs.map +1 -1
- package/Layer/index.d.ts +5 -5
- package/Layer/index.js +13 -14
- package/Layer/index.js.map +1 -1
- package/LineProgress/index.cjs +6 -6
- package/LineProgress/index.cjs.map +1 -1
- package/LineProgress/index.d.ts +2 -2
- package/LineProgress/index.js +6 -6
- package/LineProgress/index.js.map +1 -1
- package/Link/index.cjs +41 -0
- package/Link/index.cjs.map +1 -0
- package/Link/index.d.ts +17 -0
- package/Link/index.js +39 -0
- package/Link/index.js.map +1 -0
- package/List/index.cjs +1 -1
- package/List/index.cjs.map +1 -1
- package/List/index.d.ts +2 -2
- package/List/index.js +1 -1
- package/List/index.js.map +1 -1
- package/ListItem/index.cjs +8 -8
- package/ListItem/index.cjs.map +1 -1
- package/ListItem/index.d.ts +2 -2
- package/ListItem/index.js +8 -8
- package/ListItem/index.js.map +1 -1
- package/LoadingBox/index.cjs +2 -2
- package/LoadingBox/index.cjs.map +1 -1
- package/LoadingBox/index.d.ts +2 -2
- package/LoadingBox/index.js +2 -2
- package/LoadingBox/index.js.map +1 -1
- package/Menu/index.cjs +6 -21
- package/Menu/index.cjs.map +1 -1
- package/Menu/index.d.ts +6 -4
- package/Menu/index.js +6 -21
- package/Menu/index.js.map +1 -1
- package/Modal/index.cjs +5 -5
- package/Modal/index.cjs.map +1 -1
- package/Modal/index.js +5 -5
- package/Modal/index.js.map +1 -1
- package/Option/index.d.ts +2 -2
- package/PasswordInput/index.cjs +21 -0
- package/PasswordInput/index.cjs.map +1 -0
- package/PasswordInput/index.d.ts +11 -0
- package/PasswordInput/index.js +19 -0
- package/PasswordInput/index.js.map +1 -0
- package/Portal/index.d.ts +3 -3
- package/Radio/index.d.ts +2 -2
- package/RangeSlider/index.cjs +158 -0
- package/RangeSlider/index.cjs.map +1 -0
- package/RangeSlider/index.d.ts +24 -0
- package/RangeSlider/index.js +156 -0
- package/RangeSlider/index.js.map +1 -0
- package/Scrollbar/index.cjs +6 -6
- package/Scrollbar/index.cjs.map +1 -1
- package/Scrollbar/index.d.ts +3 -3
- package/Scrollbar/index.js +6 -6
- package/Scrollbar/index.js.map +1 -1
- package/Select/index.cjs +2 -2
- package/Select/index.cjs.map +1 -1
- package/Select/index.d.ts +5 -5
- package/Select/index.js +2 -2
- package/Select/index.js.map +1 -1
- package/Skeleton/index.cjs +7 -5
- package/Skeleton/index.cjs.map +1 -1
- package/Skeleton/index.js +7 -5
- package/Skeleton/index.js.map +1 -1
- package/Stack/index.d.ts +2 -2
- package/Switch/index.cjs +2 -2
- package/Switch/index.cjs.map +1 -1
- package/Switch/index.d.ts +3 -3
- package/Switch/index.js +2 -2
- package/Switch/index.js.map +1 -1
- package/Tab/index.cjs +23 -2
- package/Tab/index.cjs.map +1 -1
- package/Tab/index.d.ts +2 -2
- package/Tab/index.js +25 -4
- package/Tab/index.js.map +1 -1
- package/Table/index.cjs +9 -9
- package/Table/index.cjs.map +1 -1
- package/Table/index.d.ts +2 -2
- package/Table/index.js +9 -9
- package/Table/index.js.map +1 -1
- package/TableBody/index.d.ts +2 -2
- package/TableCell/index.cjs +1 -1
- package/TableCell/index.cjs.map +1 -1
- package/TableCell/index.d.ts +2 -2
- package/TableCell/index.js +1 -1
- package/TableCell/index.js.map +1 -1
- package/TableFooter/index.d.ts +2 -2
- package/TableHead/index.d.ts +2 -2
- package/TablePagination/index.cjs +2 -2
- package/TablePagination/index.cjs.map +1 -1
- package/TablePagination/index.d.ts +2 -2
- package/TablePagination/index.js +2 -2
- package/TablePagination/index.js.map +1 -1
- package/TableRow/index.d.ts +2 -2
- package/Tabs/context.cjs +11 -0
- package/Tabs/context.cjs.map +1 -0
- package/Tabs/context.js +8 -0
- package/Tabs/context.js.map +1 -0
- package/Tabs/index.cjs +83 -168
- package/Tabs/index.cjs.map +1 -1
- package/Tabs/index.d.ts +4 -22
- package/Tabs/index.js +86 -171
- package/Tabs/index.js.map +1 -1
- package/Tabs/types.d.ts +16 -0
- package/Text/index.cjs +1 -1
- package/Text/index.cjs.map +1 -1
- package/Text/index.d.ts +2 -2
- package/Text/index.js +1 -1
- package/Text/index.js.map +1 -1
- package/Toast/index.cjs +15 -16
- package/Toast/index.cjs.map +1 -1
- package/Toast/index.js +16 -17
- package/Toast/index.js.map +1 -1
- package/Tooltip/index.cjs +2 -2
- package/Tooltip/index.cjs.map +1 -1
- package/Tooltip/index.js +2 -2
- package/Tooltip/index.js.map +1 -1
- package/ViewBox/index.d.ts +2 -2
- package/index.cjs +124 -110
- package/index.cjs.map +1 -1
- package/index.d.ts +8 -1
- package/index.js +8 -1
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/readme.md +1 -1
- package/useBlurCss/index.cjs +1 -2
- package/useBlurCss/index.cjs.map +1 -1
- package/useBlurCss/index.js +1 -2
- package/useBlurCss/index.js.map +1 -1
- package/useContextMenu/index.cjs +2 -2
- package/useContextMenu/index.cjs.map +1 -1
- package/useContextMenu/index.d.ts +1 -1
- package/useContextMenu/index.js +2 -2
- package/useContextMenu/index.js.map +1 -1
- package/Paper/index.cjs +0 -16
- package/Paper/index.cjs.map +0 -1
- package/Paper/index.d.ts +0 -8
- package/Paper/index.js +0 -14
- package/Paper/index.js.map +0 -1
package/Tabs/index.js
CHANGED
|
@@ -1,198 +1,113 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { __rest } from 'tslib';
|
|
3
|
-
import {
|
|
4
|
-
import React, { useRef
|
|
5
|
-
import { useInterface, useBreakpointProps, Tag,
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
import React, { useRef } from 'react';
|
|
5
|
+
import { useInterface, useBreakpointProps, Tag, animate } from '@xanui/core';
|
|
6
|
+
import { TabContext } from './context.js';
|
|
6
7
|
|
|
7
|
-
const getRect = (ele, parent) => {
|
|
8
|
-
const _rect = {};
|
|
9
|
-
const parentRect = parent.getBoundingClientRect();
|
|
10
|
-
const childRect = ele.getBoundingClientRect();
|
|
11
|
-
_rect.top = childRect.top - parentRect.top;
|
|
12
|
-
_rect.right = childRect.right - parentRect.right;
|
|
13
|
-
_rect.bottom = childRect.bottom - parentRect.bottom;
|
|
14
|
-
_rect.left = childRect.left - parentRect.left;
|
|
15
|
-
_rect.width = childRect.width;
|
|
16
|
-
_rect.height = childRect.height;
|
|
17
|
-
return _rect;
|
|
18
|
-
};
|
|
19
8
|
const Tabs = React.forwardRef((_a, ref) => {
|
|
20
9
|
var _b, _c, _d;
|
|
21
10
|
var { onChange, value, children } = _a, props = __rest(_a, ["onChange", "value", "children"]);
|
|
22
|
-
let [_e] = useInterface("Tabs", props, {}), {
|
|
11
|
+
let [_e] = useInterface("Tabs", props, {}), { color, variant, indicatorSize, disableTransition, slotProps } = _e, rest = __rest(_e, ["color", "variant", "indicatorSize", "disableTransition", "slotProps"]);
|
|
23
12
|
const _p = {};
|
|
24
13
|
if (variant)
|
|
25
14
|
_p.variant = variant;
|
|
26
15
|
if (color)
|
|
27
16
|
_p.color = color;
|
|
28
|
-
if (verticle)
|
|
29
|
-
_p.verticle = verticle;
|
|
30
17
|
if (disableTransition)
|
|
31
18
|
_p.disableTransition = disableTransition;
|
|
32
19
|
if (indicatorSize)
|
|
33
20
|
_p.indicatorSize = indicatorSize;
|
|
34
21
|
const p = useBreakpointProps(_p);
|
|
35
22
|
variant = (_b = p.variant) !== null && _b !== void 0 ? _b : "end-line";
|
|
36
|
-
color = (_c = p.color) !== null && _c !== void 0 ? _c : "
|
|
37
|
-
verticle = p.verticle;
|
|
23
|
+
color = (_c = p.color) !== null && _c !== void 0 ? _c : "primary";
|
|
38
24
|
disableTransition = p.disableTransition;
|
|
39
25
|
indicatorSize = (_d = p.indicatorSize) !== null && _d !== void 0 ? _d : 3;
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
26
|
+
const indicatorRef = useRef(null);
|
|
27
|
+
const indicatorState = useRef({
|
|
28
|
+
left: 0,
|
|
29
|
+
width: 0
|
|
30
|
+
});
|
|
31
|
+
let indicatorProps = {};
|
|
32
|
+
switch (variant) {
|
|
33
|
+
case "outline":
|
|
34
|
+
indicatorProps = {
|
|
35
|
+
top: 0,
|
|
36
|
+
border: "1px solid",
|
|
37
|
+
borderColor: color,
|
|
38
|
+
bgcolor: "transparent"
|
|
39
|
+
};
|
|
40
|
+
break;
|
|
41
|
+
case "ghost":
|
|
42
|
+
indicatorProps = {
|
|
43
|
+
top: 0,
|
|
44
|
+
bgcolor: `${color}.ghost`
|
|
45
|
+
};
|
|
46
|
+
break;
|
|
47
|
+
case "text":
|
|
48
|
+
indicatorProps = {
|
|
49
|
+
display: "none"
|
|
50
|
+
};
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
return (jsx(TabContext.Provider, { value: {
|
|
54
|
+
value,
|
|
55
|
+
variant,
|
|
56
|
+
color,
|
|
57
|
+
disableTransition,
|
|
58
|
+
indicatorSize,
|
|
59
|
+
onChange: (v, e) => {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
onChange(v, e);
|
|
62
|
+
if (variant === 'text')
|
|
63
|
+
return;
|
|
64
|
+
const indicator = indicatorRef.current;
|
|
65
|
+
if (!indicator)
|
|
66
|
+
return;
|
|
67
|
+
const target = e.currentTarget;
|
|
68
|
+
switch (variant) {
|
|
69
|
+
case "start-line":
|
|
70
|
+
indicator.style.removeProperty("bottom");
|
|
71
|
+
indicator.style.top = `${target.offsetTop}px`;
|
|
72
|
+
indicator.style.height = `${indicatorSize}px`;
|
|
73
|
+
break;
|
|
74
|
+
case "end-line":
|
|
75
|
+
indicator.style.removeProperty("top");
|
|
76
|
+
indicator.style.bottom = `${target.offsetTop}px`;
|
|
77
|
+
indicator.style.height = `${indicatorSize}px`;
|
|
78
|
+
break;
|
|
79
|
+
case "fill":
|
|
80
|
+
case "outline":
|
|
81
|
+
case "ghost":
|
|
82
|
+
indicator.style.height = `${target.offsetHeight}px`;
|
|
83
|
+
indicator.style.top = `${target.offsetTop}px`;
|
|
84
|
+
break;
|
|
98
85
|
}
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
let v = {
|
|
86
|
+
animate({
|
|
103
87
|
from: {
|
|
104
|
-
left: (
|
|
105
|
-
width: (
|
|
88
|
+
left: (_a = indicatorState.current.left) !== null && _a !== void 0 ? _a : 0,
|
|
89
|
+
width: (_b = indicatorState.current.width) !== null && _b !== void 0 ? _b : 0,
|
|
106
90
|
},
|
|
107
91
|
to: {
|
|
108
|
-
left:
|
|
109
|
-
width:
|
|
92
|
+
left: target.offsetLeft,
|
|
93
|
+
width: target.clientWidth,
|
|
110
94
|
},
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
_indicatorProps = {
|
|
128
|
-
left: 0,
|
|
129
|
-
width: indicatorSize
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
_indicatorProps = {
|
|
134
|
-
top: 0,
|
|
135
|
-
height: indicatorSize
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
break;
|
|
139
|
-
case "end-line":
|
|
140
|
-
if (verticle) {
|
|
141
|
-
_indicatorProps = {
|
|
142
|
-
right: 0,
|
|
143
|
-
width: indicatorSize
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
_indicatorProps = {
|
|
148
|
-
bottom: 0,
|
|
149
|
-
height: indicatorSize
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
break;
|
|
153
|
-
case "fill":
|
|
154
|
-
_indicatorProps = {
|
|
155
|
-
top: 0,
|
|
156
|
-
bgcolor: color
|
|
157
|
-
};
|
|
158
|
-
break;
|
|
159
|
-
case "outline":
|
|
160
|
-
_indicatorProps = {
|
|
161
|
-
top: 0,
|
|
162
|
-
border: "1px solid",
|
|
163
|
-
borderColor: color,
|
|
164
|
-
bgcolor: "transparent"
|
|
165
|
-
};
|
|
166
|
-
break;
|
|
167
|
-
case "soft":
|
|
168
|
-
_indicatorProps = {
|
|
169
|
-
top: 0,
|
|
170
|
-
bgcolor: `${color}.soft.primary`
|
|
171
|
-
};
|
|
172
|
-
break;
|
|
173
|
-
case "text":
|
|
174
|
-
_indicatorProps = {
|
|
175
|
-
display: "none"
|
|
176
|
-
};
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
return _indicatorProps;
|
|
180
|
-
}, [selectedIndex, variant, color, verticle]);
|
|
181
|
-
return (jsxs(Tag, Object.assign({}, rest, { baseClass: 'tabs', ref: ref, sxr: {
|
|
182
|
-
position: "relative",
|
|
183
|
-
zIndex: 1,
|
|
184
|
-
display: "inline-block"
|
|
185
|
-
}, children: [jsx(Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.content, { baseClass: 'tabs-content', sxr: {
|
|
186
|
-
display: verticle ? "flex" : "inline-flex",
|
|
187
|
-
flexDirection: verticle ? "column" : "row",
|
|
188
|
-
}, ref: containerRef, children: childs })), jsx(Transition, { open: !!trans, variant: trans, duration: trans ? (disableTransition ? 0 : 250) : 0, easing: "smooth", children: jsx(Tag, Object.assign({ baseClass: 'tabs-indicator',
|
|
189
|
-
// className={classname}
|
|
190
|
-
sxr: {
|
|
191
|
-
position: "absolute",
|
|
192
|
-
zIndex: -1,
|
|
193
|
-
cursor: "pointer",
|
|
194
|
-
bgcolor: color
|
|
195
|
-
} }, indicatorProps)) })] })));
|
|
95
|
+
duration: 180,
|
|
96
|
+
easing: (t) => 1 - Math.pow(1 - t, 3),
|
|
97
|
+
onUpdate: ({ left, width }) => {
|
|
98
|
+
indicatorState.current.left = left;
|
|
99
|
+
indicatorState.current.width = width;
|
|
100
|
+
indicator.style.left = `${left}px`;
|
|
101
|
+
indicator.style.width = `${width}px`;
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
}, children: jsxs(Tag, Object.assign({}, rest, { baseClass: 'tabs', sxr: {
|
|
106
|
+
position: "relative",
|
|
107
|
+
zIndex: 1,
|
|
108
|
+
display: "flex",
|
|
109
|
+
flexDirection: "row",
|
|
110
|
+
}, ref: ref, children: [children, jsx(Tag, { ref: indicatorRef, baseClass: 'tabs-indicator', sxr: Object.assign({ radius: 1, position: "absolute", zIndex: -1, bgcolor: color, height: 2 }, indicatorProps) })] })) }));
|
|
196
111
|
});
|
|
197
112
|
|
|
198
113
|
export { Tabs as default };
|
package/Tabs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Tabs/index.tsx"],"sourcesContent":["\"use client\";\nimport React, {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Tabs/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { useRef } from 'react'\nimport { animate, Tag, useBreakpointProps, useInterface } from '@xanui/core'\nimport { TabContext } from './context';\nimport { TabsProps } from './types';\n\nexport type { TabsProps }\n\nconst Tabs = React.forwardRef(({ onChange, value, children, ...props }: TabsProps, ref: any) => {\n let [{ color, variant, indicatorSize, disableTransition, slotProps, ...rest }] = useInterface<any>(\"Tabs\", props, {})\n const _p: any = {}\n if (variant) _p.variant = variant\n if (color) _p.color = color\n if (disableTransition) _p.disableTransition = disableTransition\n if (indicatorSize) _p.indicatorSize = indicatorSize\n const p: any = useBreakpointProps(_p)\n\n variant = p.variant ?? \"end-line\"\n color = p.color ?? \"primary\"\n disableTransition = p.disableTransition\n indicatorSize = p.indicatorSize ?? 3\n\n const indicatorRef = useRef<HTMLElement>(null)\n const indicatorState = useRef({\n left: 0,\n width: 0\n })\n\n\n let indicatorProps: any = {}\n switch (variant) {\n case \"outline\":\n indicatorProps = {\n top: 0,\n border: \"1px solid\",\n borderColor: color,\n bgcolor: \"transparent\"\n }\n break;\n case \"ghost\":\n indicatorProps = {\n top: 0,\n bgcolor: `${color}.ghost`\n }\n break;\n case \"text\":\n indicatorProps = {\n display: \"none\"\n }\n break;\n }\n\n\n return (\n <TabContext.Provider\n value={{\n value,\n variant,\n color,\n disableTransition,\n indicatorSize,\n onChange: (v, e) => {\n onChange!(v, e)\n\n if (variant === 'text') return\n const indicator = indicatorRef.current;\n if (!indicator) return;\n\n const target = e.currentTarget as HTMLElement;\n\n switch (variant) {\n case \"start-line\":\n indicator.style.removeProperty(\"bottom\")\n indicator.style.top = `${target.offsetTop}px`\n indicator.style.height = `${indicatorSize}px`\n break;\n case \"end-line\":\n indicator.style.removeProperty(\"top\")\n indicator.style.bottom = `${target.offsetTop}px`\n indicator.style.height = `${indicatorSize}px`\n break;\n case \"fill\":\n case \"outline\":\n case \"ghost\":\n indicator.style.height = `${target.offsetHeight}px`\n indicator.style.top = `${target.offsetTop}px`\n break;\n }\n\n animate({\n from: {\n left: indicatorState.current.left ?? 0,\n width: indicatorState.current.width ?? 0,\n },\n to: {\n left: target.offsetLeft,\n width: target.clientWidth,\n },\n duration: 180,\n easing: (t) => 1 - Math.pow(1 - t, 3),\n onUpdate: ({ left, width }) => {\n indicatorState.current.left = left;\n indicatorState.current.width = width;\n\n indicator.style.left = `${left}px`;\n indicator.style.width = `${width}px`;\n },\n });\n },\n }}\n >\n <Tag\n {...rest}\n baseClass='tabs'\n sxr={{\n position: \"relative\",\n zIndex: 1,\n display: \"flex\",\n flexDirection: \"row\",\n }}\n ref={ref}\n >\n {children}\n <Tag\n ref={indicatorRef}\n baseClass='tabs-indicator'\n sxr={{\n radius: 1,\n position: \"absolute\",\n zIndex: -1,\n bgcolor: color,\n height: 2,\n ...indicatorProps\n }}\n />\n </Tag>\n </TabContext.Provider>\n )\n})\n\nexport default Tabs"],"names":[],"mappings":";;;;;;;AAQA;;;;;AAGI;AAAa;AACb;AAAW;AACX;AAAuB;AACvB;AAAmB;AACnB;AAEA;AACA;AACA;AACA;AAEA;;AAEI;AACA;AACH;;;AAKG;AACI;AACI;AACA;AACA;AACA;;;AAGR;AACI;AACI;;;;AAIR;AACI;AACI;;;;AAMZ;;;;;;AAQY;;AACI;;;AAGA;AACA;;AAEA;;AAGI;AACI;;;;AAIJ;AACI;;;;AAIJ;AACA;AACA;;;;;AAMJ;AACI;;;AAGC;AACD;;;AAGC;AACD;AACA;;AAEI;AACA;;;;AAKP;;;AAQD;AACA;AACA;AACA;;AAoBpB;;"}
|
package/Tabs/types.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { TabProps } from '../Tab/index.js';
|
|
3
|
+
import { TagProps, useBreakpointPropsType, UseColorTemplateColor } from '@xanui/core';
|
|
4
|
+
|
|
5
|
+
type ValueType = string | number;
|
|
6
|
+
type TabsProps = Omit<TagProps, 'onChange'> & {
|
|
7
|
+
children: ReactElement<TabProps> | ReactElement<TabProps>[];
|
|
8
|
+
value?: ValueType;
|
|
9
|
+
onChange?: (value: ValueType, e: React.MouseEvent) => void;
|
|
10
|
+
variant?: useBreakpointPropsType<"start-line" | "end-line" | "fill" | "outline" | "text" | "ghost">;
|
|
11
|
+
color?: useBreakpointPropsType<UseColorTemplateColor>;
|
|
12
|
+
disableTransition?: useBreakpointPropsType<boolean>;
|
|
13
|
+
indicatorSize?: useBreakpointPropsType<number>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type { TabsProps };
|
package/Text/index.cjs
CHANGED
package/Text/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/Text/index.tsx"],"sourcesContent":["\"use client\"\nimport React from 'react';\nimport { Tag, TagProps, TagComponentType, useBreakpointProps, useBreakpointPropsType } from '@xanui/core';\n\n\nexport type TextProps<T extends TagComponentType = \"p\"> = TagProps<T> & {\n variant?: useBreakpointPropsType<\"text\" | \"button\" | \"small\" | \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\">\n}\n\nconst Text = React.forwardRef(<T extends TagComponentType = \"p\">({ children, variant, ...props }: TextProps<T>, ref?: React.Ref<any>) => {\n const _p: any = {}\n if (variant) _p.variant = variant\n const p: any = useBreakpointProps(_p)\n variant = p.variant ?? 'text'\n\n return (\n <Tag\n component={(variant as string).startsWith('h') ? variant as any : \"p\"}\n {...props}\n sxr={{\n fontSize: variant,\n lineHeight: variant,\n fontWeight: variant,\n color: \"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/Text/index.tsx"],"sourcesContent":["\"use client\"\nimport React from 'react';\nimport { Tag, TagProps, TagComponentType, useBreakpointProps, useBreakpointPropsType } from '@xanui/core';\n\n\nexport type TextProps<T extends TagComponentType = \"p\"> = TagProps<T> & {\n variant?: useBreakpointPropsType<\"text\" | \"button\" | \"small\" | \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\">\n}\n\nconst Text = React.forwardRef(<T extends TagComponentType = \"p\">({ children, variant, ...props }: TextProps<T>, ref?: React.Ref<any>) => {\n const _p: any = {}\n if (variant) _p.variant = variant\n const p: any = useBreakpointProps(_p)\n variant = p.variant ?? 'text'\n\n return (\n <Tag\n component={(variant as string).startsWith('h') ? variant as any : \"p\"}\n {...props}\n sxr={{\n fontSize: variant,\n lineHeight: variant,\n fontWeight: variant,\n color: \"surface.contrast\",\n }}\n baseClass='text'\n ref={ref}\n >{children}</Tag>\n )\n})\n\nexport default Text\n"],"names":[],"mappings":";;;;;;;;AASA;;;;AAEI;AAAa;AACb;AACA;;AAOY;AACA;AACA;AACA;;AAMhB;;"}
|
package/Text/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default from 'react';
|
|
2
2
|
import { TagComponentType, TagProps, useBreakpointPropsType } from '@xanui/core';
|
|
3
3
|
|
|
4
4
|
type TextProps<T extends TagComponentType = "p"> = TagProps<T> & {
|
|
5
5
|
variant?: useBreakpointPropsType<"text" | "button" | "small" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6">;
|
|
6
6
|
};
|
|
7
|
-
declare const Text:
|
|
7
|
+
declare const Text: React__default.ForwardRefExoticComponent<Omit<TextProps<TagComponentType>, "ref"> & React__default.RefAttributes<any>>;
|
|
8
8
|
|
|
9
9
|
export { Text as default };
|
|
10
10
|
export type { TextProps };
|
package/Text/index.js
CHANGED
package/Text/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Text/index.tsx"],"sourcesContent":["\"use client\"\nimport React from 'react';\nimport { Tag, TagProps, TagComponentType, useBreakpointProps, useBreakpointPropsType } from '@xanui/core';\n\n\nexport type TextProps<T extends TagComponentType = \"p\"> = TagProps<T> & {\n variant?: useBreakpointPropsType<\"text\" | \"button\" | \"small\" | \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\">\n}\n\nconst Text = React.forwardRef(<T extends TagComponentType = \"p\">({ children, variant, ...props }: TextProps<T>, ref?: React.Ref<any>) => {\n const _p: any = {}\n if (variant) _p.variant = variant\n const p: any = useBreakpointProps(_p)\n variant = p.variant ?? 'text'\n\n return (\n <Tag\n component={(variant as string).startsWith('h') ? variant as any : \"p\"}\n {...props}\n sxr={{\n fontSize: variant,\n lineHeight: variant,\n fontWeight: variant,\n color: \"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Text/index.tsx"],"sourcesContent":["\"use client\"\nimport React from 'react';\nimport { Tag, TagProps, TagComponentType, useBreakpointProps, useBreakpointPropsType } from '@xanui/core';\n\n\nexport type TextProps<T extends TagComponentType = \"p\"> = TagProps<T> & {\n variant?: useBreakpointPropsType<\"text\" | \"button\" | \"small\" | \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\">\n}\n\nconst Text = React.forwardRef(<T extends TagComponentType = \"p\">({ children, variant, ...props }: TextProps<T>, ref?: React.Ref<any>) => {\n const _p: any = {}\n if (variant) _p.variant = variant\n const p: any = useBreakpointProps(_p)\n variant = p.variant ?? 'text'\n\n return (\n <Tag\n component={(variant as string).startsWith('h') ? variant as any : \"p\"}\n {...props}\n sxr={{\n fontSize: variant,\n lineHeight: variant,\n fontWeight: variant,\n color: \"surface.contrast\",\n }}\n baseClass='text'\n ref={ref}\n >{children}</Tag>\n )\n})\n\nexport default Text\n"],"names":[],"mappings":";;;;;;AASA;;;;AAEI;AAAa;AACb;AACA;;AAOY;AACA;AACA;AACA;;AAMhB;;"}
|
package/Toast/index.cjs
CHANGED
|
@@ -62,17 +62,17 @@ const formatPacement = (placement) => {
|
|
|
62
62
|
const ToastView = (props) => {
|
|
63
63
|
const [open, setOpen] = React.useState(true);
|
|
64
64
|
const [timer, setTimer] = React.useState(null);
|
|
65
|
-
const _a = props || {}, { placement = "bottom-right", content, closeable,
|
|
65
|
+
const _a = props || {}, { placement = "bottom-right", content, closeable, onExited, autoColose = true, pauseOnHover = true, autoColoseDelay = 6000, tid } = _a, rest = tslib.__rest(_a, ["placement", "content", "closeable", "onExited", "autoColose", "pauseOnHover", "autoColoseDelay", "tid"]);
|
|
66
66
|
const { transition } = formatPacement(placement);
|
|
67
|
-
return (jsxRuntime.jsx(core.Transition, { open: open, variant: transition,
|
|
68
|
-
|
|
69
|
-
},
|
|
67
|
+
return (jsxRuntime.jsx(core.Transition, { open: open, variant: transition, onExited: () => {
|
|
68
|
+
onExited(tid);
|
|
69
|
+
}, onEntered: () => {
|
|
70
70
|
if (autoColose) {
|
|
71
71
|
setTimer(setTimeout(() => {
|
|
72
72
|
setOpen(false);
|
|
73
73
|
}, autoColoseDelay));
|
|
74
74
|
}
|
|
75
|
-
}, children: jsxRuntime.jsx(index$1, Object.assign({ variant: "fill", color: "
|
|
75
|
+
}, children: jsxRuntime.jsx(index$1, Object.assign({ variant: "fill", color: "primary" }, rest, { direction: "row", mb: 1, onMouseEnter: () => {
|
|
76
76
|
(autoColose && pauseOnHover) && clearTimeout(timer);
|
|
77
77
|
}, onMouseLeave: () => {
|
|
78
78
|
if (autoColose && pauseOnHover) {
|
|
@@ -92,24 +92,22 @@ const State = {
|
|
|
92
92
|
};
|
|
93
93
|
const RenderToasts = () => {
|
|
94
94
|
let views = [];
|
|
95
|
+
const [, dispatch] = React.useState(0);
|
|
95
96
|
for (let placement in State) {
|
|
96
97
|
const items = State[placement];
|
|
97
98
|
const { sx } = formatPacement(placement);
|
|
98
99
|
if (!items.length)
|
|
99
100
|
continue;
|
|
100
|
-
views.push(jsxRuntime.jsx(index, { overflow: "hidden", p: 1, sx: Object.assign({ position: "fixed", zIndex: 99999999, display: "flex", justifyContent: "flex-end", flexDirection: "column", width:
|
|
101
|
-
return (jsxRuntime.jsx(ToastView, Object.assign({}, itemprops, {
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
views.push(jsxRuntime.jsx(index, { overflow: "hidden", p: 1, sx: Object.assign({ position: "fixed", zIndex: 99999999, display: "flex", justifyContent: "flex-end", flexDirection: "column", width: 300, height: "auto", maxHeight: "100vh" }, sx), children: items.map((itemprops) => {
|
|
102
|
+
return (jsxRuntime.jsx(ToastView, Object.assign({}, itemprops, { onExited: (tid) => {
|
|
103
|
+
var _a;
|
|
104
|
+
State[placement] = State[placement].filter((item) => item.tid !== tid);
|
|
105
|
+
if (!((_a = State[placement]) === null || _a === void 0 ? void 0 : _a.length))
|
|
104
106
|
delete State[placement];
|
|
105
|
-
|
|
106
|
-
else {
|
|
107
|
-
State[placement] = items;
|
|
108
|
-
}
|
|
109
|
-
if (!Object.keys(State).length) {
|
|
107
|
+
if (!Object.keys(State).length)
|
|
110
108
|
core.Renderar.unrender(RenderToasts);
|
|
111
|
-
|
|
112
|
-
} }), `toast-view-${
|
|
109
|
+
dispatch(Math.random());
|
|
110
|
+
} }), `toast-view-${itemprops.tid}`));
|
|
113
111
|
}) }, `toast-render-${placement}`));
|
|
114
112
|
}
|
|
115
113
|
return views;
|
|
@@ -120,6 +118,7 @@ const Toast = (props) => {
|
|
|
120
118
|
const length = Object.keys(State).length;
|
|
121
119
|
if (!State[placement])
|
|
122
120
|
State[placement] = [];
|
|
121
|
+
props.tid = Math.random().toString(32);
|
|
123
122
|
State[placement].push(props);
|
|
124
123
|
if (length) {
|
|
125
124
|
core.Renderar.updateProps(RenderToasts, {});
|
package/Toast/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/Toast/index.tsx"],"sourcesContent":["\"use client\";\nimport { UseColorTemplateColor, UseColorTemplateType, Transition, useBreakpointPropsType, Renderar } from \"@xanui/core\";\nimport React, { ReactElement } from \"react\";\nimport Alert, { AlertProps } from \"../Alert\";\nimport Scrollbar from \"../Scrollbar\";\n\ntype PlacementType = \"top-left\" | \"top-center\" | \"top-right\" | \"bottom-left\" | \"bottom-center\" | \"bottom-right\"\n\nexport type UseToastProps = {\n title?: useBreakpointPropsType<string | ReactElement>;\n content?: AlertProps['children'];\n variant?: useBreakpointPropsType<UseColorTemplateType>;\n color?: useBreakpointPropsType<UseColorTemplateColor>;\n icon?: useBreakpointPropsType<\"info\" | \"warning\" | \"success\" | \"error\" | false | ReactElement>;\n placement?: PlacementType;\n closeable?: useBreakpointPropsType<boolean>;\n autoColose?: boolean;\n autoColoseDelay?: number;\n pauseOnHover?: boolean;\n}\n\n\nconst formatPacement = (placement: PlacementType) => {\n let sx: any = {}\n let transition: any = \"\"\n switch (placement) {\n case \"top-left\":\n sx = {\n top: 0,\n left: 0\n }\n transition = \"fadeRight\"\n break;\n case \"top-right\":\n sx = {\n top: 0,\n right: 0\n }\n transition = \"fadeLeft\"\n break;\n case \"top-center\":\n sx = {\n top: 0,\n left: \"50%\",\n transform: \"translateX(-50%)\"\n }\n transition = \"fadeDown\"\n break;\n case \"bottom-right\":\n sx = {\n bottom: 0,\n right: 0\n }\n transition = \"fadeLeft\"\n break;\n case \"bottom-left\":\n sx = {\n bottom: 0,\n left: 0\n }\n transition = \"fadeRight\"\n break;\n case \"bottom-center\":\n sx = {\n bottom: 0,\n left: \"50%\",\n transform: \"translateX(-50%)\"\n }\n transition = \"fadeUp\"\n break;\n }\n return { sx, transition }\n}\n\nconst ToastView = (props: UseToastProps & {
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/Toast/index.tsx"],"sourcesContent":["\"use client\";\nimport { UseColorTemplateColor, UseColorTemplateType, Transition, useBreakpointPropsType, Renderar } from \"@xanui/core\";\nimport React, { ReactElement, useState } from \"react\";\nimport Alert, { AlertProps } from \"../Alert\";\nimport Scrollbar from \"../Scrollbar\";\n\ntype PlacementType = \"top-left\" | \"top-center\" | \"top-right\" | \"bottom-left\" | \"bottom-center\" | \"bottom-right\"\n\nexport type UseToastProps = {\n title?: useBreakpointPropsType<string | ReactElement>;\n content?: AlertProps['children'];\n variant?: useBreakpointPropsType<UseColorTemplateType>;\n color?: useBreakpointPropsType<UseColorTemplateColor>;\n icon?: useBreakpointPropsType<\"info\" | \"warning\" | \"success\" | \"error\" | false | ReactElement>;\n placement?: PlacementType;\n closeable?: useBreakpointPropsType<boolean>;\n autoColose?: boolean;\n autoColoseDelay?: number;\n pauseOnHover?: boolean;\n}\n\n\nconst formatPacement = (placement: PlacementType) => {\n let sx: any = {}\n let transition: any = \"\"\n switch (placement) {\n case \"top-left\":\n sx = {\n top: 0,\n left: 0\n }\n transition = \"fadeRight\"\n break;\n case \"top-right\":\n sx = {\n top: 0,\n right: 0\n }\n transition = \"fadeLeft\"\n break;\n case \"top-center\":\n sx = {\n top: 0,\n left: \"50%\",\n transform: \"translateX(-50%)\"\n }\n transition = \"fadeDown\"\n break;\n case \"bottom-right\":\n sx = {\n bottom: 0,\n right: 0\n }\n transition = \"fadeLeft\"\n break;\n case \"bottom-left\":\n sx = {\n bottom: 0,\n left: 0\n }\n transition = \"fadeRight\"\n break;\n case \"bottom-center\":\n sx = {\n bottom: 0,\n left: \"50%\",\n transform: \"translateX(-50%)\"\n }\n transition = \"fadeUp\"\n break;\n }\n return { sx, transition }\n}\n\nconst ToastView = (props: UseToastProps & { tid: string, onExited: (tid: string) => void }) => {\n const [open, setOpen] = React.useState(true)\n const [timer, setTimer] = React.useState<any>(null)\n const {\n placement = \"bottom-right\",\n content,\n closeable,\n onExited,\n autoColose = true,\n pauseOnHover = true,\n autoColoseDelay = 6000,\n tid,\n ...rest\n } = props || {}\n\n const { transition } = formatPacement(placement)\n\n return (<Transition\n open={open}\n variant={transition}\n onExited={() => {\n onExited(tid)\n }}\n onEntered={() => {\n if (autoColose) {\n setTimer(setTimeout(() => {\n setOpen(false)\n }, autoColoseDelay))\n }\n }}\n >\n <Alert\n variant=\"fill\"\n color=\"primary\"\n {...rest as any}\n direction={\"row\"}\n mb={1}\n onMouseEnter={() => {\n (autoColose && pauseOnHover) && clearTimeout(timer)\n }}\n onMouseLeave={() => {\n if (autoColose && pauseOnHover) {\n setTimer(setTimeout(() => {\n setOpen(false)\n }, autoColoseDelay))\n }\n }}\n onClose={closeable ? () => setOpen(false) : undefined}\n >{content}</Alert>\n </Transition>)\n}\n\nconst State: Record<PlacementType, UseToastProps[]> = {\n // \"top-left\": [],\n // \"top-center\": [],\n // \"top-right\": [],\n // \"bottom-left\": [],\n // \"bottom-center\": [],\n // \"bottom-right\": []\n} as any\n\nconst RenderToasts = () => {\n let views = []\n const [, dispatch] = useState(0)\n\n for (let placement in State) {\n const items = (State as any)[placement]\n const { sx } = formatPacement(placement as any)\n if (!items.length) continue;\n views.push(\n <Scrollbar\n key={`toast-render-${placement}`}\n overflow=\"hidden\"\n p={1}\n sx={{\n position: \"fixed\",\n zIndex: 99999999,\n display: \"flex\",\n justifyContent: \"flex-end\",\n flexDirection: \"column\",\n width: 300,\n height: \"auto\",\n maxHeight: \"100vh\",\n ...sx\n }}\n >\n\n {items.map((itemprops: UseToastProps & { tid: string }) => {\n return (\n <ToastView\n key={`toast-view-${itemprops.tid}`}\n {...itemprops}\n onExited={(tid) => {\n (State as any)[placement] = (State as any)[placement].filter((item: any) => item.tid !== tid)\n\n if (!(State as any)[placement]?.length) delete (State as any)[placement]\n if (!Object.keys(State).length) Renderar.unrender(RenderToasts)\n\n dispatch(Math.random())\n }}\n />\n )\n })}\n </Scrollbar >\n )\n }\n\n return views\n}\n\nconst Toast = (props?: UseToastProps['content'] | UseToastProps) => {\n props = React.isValidElement(props) ? { content: props } : props\n let { placement = \"bottom-right\" } = (props || {}) as UseToastProps\n const length = Object.keys(State).length\n if (!State[placement]) State[placement] = [];\n (props as any).tid = Math.random().toString(32);\n State[placement].push(props as any)\n if (length) {\n Renderar.updateProps(RenderToasts, {})\n } else {\n Renderar.render(RenderToasts)\n }\n}\n\nexport default Toast;"],"names":[],"mappings":";;;;;;;;;;AAsBA;;;;AAIQ;AACI;AACI;AACA;;;;AAIR;AACI;AACI;AACA;;;;AAIR;AACI;AACI;AACA;AACA;;;;AAIR;AACI;AACI;AACA;;;;AAIR;AACI;AACI;AACA;;;;AAIR;AACI;AACI;AACA;AACA;;;;;AAKZ;AACJ;AAEA;AACI;AACA;AACA;;AAcA;;AAKI;;AAGQ;;AAEA;;;;AAYJ;AAEI;AACI;;AAEA;;;AAMpB;AAEA;AACI;AACA;AACA;AACA;AACA;AACA;;AAGJ;;;AAII;AACI;;;;;;;;;AA6BgE;;AACR;AAEhC;;AAIhB;;AAKZ;AACJ;AAEA;AACI;;;AAGA;AAAuB;AACtB;;;AAGG;;;AAEA;;AAER;;"}
|
package/Toast/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { __rest } from 'tslib';
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { Renderar, Transition } from '@xanui/core';
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { useState } from 'react';
|
|
6
6
|
import Alert from '../Alert/index.js';
|
|
7
7
|
import Scrollbar from '../Scrollbar/index.js';
|
|
8
8
|
|
|
@@ -60,17 +60,17 @@ const formatPacement = (placement) => {
|
|
|
60
60
|
const ToastView = (props) => {
|
|
61
61
|
const [open, setOpen] = React.useState(true);
|
|
62
62
|
const [timer, setTimer] = React.useState(null);
|
|
63
|
-
const _a = props || {}, { placement = "bottom-right", content, closeable,
|
|
63
|
+
const _a = props || {}, { placement = "bottom-right", content, closeable, onExited, autoColose = true, pauseOnHover = true, autoColoseDelay = 6000, tid } = _a, rest = __rest(_a, ["placement", "content", "closeable", "onExited", "autoColose", "pauseOnHover", "autoColoseDelay", "tid"]);
|
|
64
64
|
const { transition } = formatPacement(placement);
|
|
65
|
-
return (jsx(Transition, { open: open, variant: transition,
|
|
66
|
-
|
|
67
|
-
},
|
|
65
|
+
return (jsx(Transition, { open: open, variant: transition, onExited: () => {
|
|
66
|
+
onExited(tid);
|
|
67
|
+
}, onEntered: () => {
|
|
68
68
|
if (autoColose) {
|
|
69
69
|
setTimer(setTimeout(() => {
|
|
70
70
|
setOpen(false);
|
|
71
71
|
}, autoColoseDelay));
|
|
72
72
|
}
|
|
73
|
-
}, children: jsx(Alert, Object.assign({ variant: "fill", color: "
|
|
73
|
+
}, children: jsx(Alert, Object.assign({ variant: "fill", color: "primary" }, rest, { direction: "row", mb: 1, onMouseEnter: () => {
|
|
74
74
|
(autoColose && pauseOnHover) && clearTimeout(timer);
|
|
75
75
|
}, onMouseLeave: () => {
|
|
76
76
|
if (autoColose && pauseOnHover) {
|
|
@@ -90,24 +90,22 @@ const State = {
|
|
|
90
90
|
};
|
|
91
91
|
const RenderToasts = () => {
|
|
92
92
|
let views = [];
|
|
93
|
+
const [, dispatch] = useState(0);
|
|
93
94
|
for (let placement in State) {
|
|
94
95
|
const items = State[placement];
|
|
95
96
|
const { sx } = formatPacement(placement);
|
|
96
97
|
if (!items.length)
|
|
97
98
|
continue;
|
|
98
|
-
views.push(jsx(Scrollbar, { overflow: "hidden", p: 1, sx: Object.assign({ position: "fixed", zIndex: 99999999, display: "flex", justifyContent: "flex-end", flexDirection: "column", width:
|
|
99
|
-
return (jsx(ToastView, Object.assign({}, itemprops, {
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
views.push(jsx(Scrollbar, { overflow: "hidden", p: 1, sx: Object.assign({ position: "fixed", zIndex: 99999999, display: "flex", justifyContent: "flex-end", flexDirection: "column", width: 300, height: "auto", maxHeight: "100vh" }, sx), children: items.map((itemprops) => {
|
|
100
|
+
return (jsx(ToastView, Object.assign({}, itemprops, { onExited: (tid) => {
|
|
101
|
+
var _a;
|
|
102
|
+
State[placement] = State[placement].filter((item) => item.tid !== tid);
|
|
103
|
+
if (!((_a = State[placement]) === null || _a === void 0 ? void 0 : _a.length))
|
|
102
104
|
delete State[placement];
|
|
103
|
-
|
|
104
|
-
else {
|
|
105
|
-
State[placement] = items;
|
|
106
|
-
}
|
|
107
|
-
if (!Object.keys(State).length) {
|
|
105
|
+
if (!Object.keys(State).length)
|
|
108
106
|
Renderar.unrender(RenderToasts);
|
|
109
|
-
|
|
110
|
-
} }), `toast-view-${
|
|
107
|
+
dispatch(Math.random());
|
|
108
|
+
} }), `toast-view-${itemprops.tid}`));
|
|
111
109
|
}) }, `toast-render-${placement}`));
|
|
112
110
|
}
|
|
113
111
|
return views;
|
|
@@ -118,6 +116,7 @@ const Toast = (props) => {
|
|
|
118
116
|
const length = Object.keys(State).length;
|
|
119
117
|
if (!State[placement])
|
|
120
118
|
State[placement] = [];
|
|
119
|
+
props.tid = Math.random().toString(32);
|
|
121
120
|
State[placement].push(props);
|
|
122
121
|
if (length) {
|
|
123
122
|
Renderar.updateProps(RenderToasts, {});
|