@xanui/ui 1.2.5 → 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 +4 -4
- 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 +25 -14
- package/Menu/index.cjs.map +1 -1
- package/Menu/index.d.ts +6 -4
- package/Menu/index.js +25 -14
- 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.cjs +1 -1
- package/Portal/index.cjs.map +1 -1
- package/Portal/index.d.ts +3 -3
- package/Portal/index.js +1 -1
- package/Portal/index.js.map +1 -1
- 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 +3 -4
- 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/context.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../../src/Tabs/context.ts"],"sourcesContent":["\"use client\"\nimport { createContext, useContext } from \"react\";\nimport { TabsProps } from \"./types\";\n\nexport const TabContext = createContext<Omit<TabsProps, \"children\"> | null>(null)\nexport const useTabs = () => useContext(TabContext) as Omit<TabsProps, \"children\">"],"names":[],"mappings":";;;;AAKO;;"}
|
package/Tabs/index.cjs
CHANGED
|
@@ -5,196 +5,111 @@ var tslib = require('tslib');
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var core = require('@xanui/core');
|
|
8
|
+
var context = require('./context.cjs');
|
|
8
9
|
|
|
9
|
-
const getRect = (ele, parent) => {
|
|
10
|
-
const _rect = {};
|
|
11
|
-
const parentRect = parent.getBoundingClientRect();
|
|
12
|
-
const childRect = ele.getBoundingClientRect();
|
|
13
|
-
_rect.top = childRect.top - parentRect.top;
|
|
14
|
-
_rect.right = childRect.right - parentRect.right;
|
|
15
|
-
_rect.bottom = childRect.bottom - parentRect.bottom;
|
|
16
|
-
_rect.left = childRect.left - parentRect.left;
|
|
17
|
-
_rect.width = childRect.width;
|
|
18
|
-
_rect.height = childRect.height;
|
|
19
|
-
return _rect;
|
|
20
|
-
};
|
|
21
10
|
const Tabs = React.forwardRef((_a, ref) => {
|
|
22
11
|
var _b, _c, _d;
|
|
23
12
|
var { onChange, value, children } = _a, props = tslib.__rest(_a, ["onChange", "value", "children"]);
|
|
24
|
-
let [_e] = core.useInterface("Tabs", props, {}), {
|
|
13
|
+
let [_e] = core.useInterface("Tabs", props, {}), { color, variant, indicatorSize, disableTransition, slotProps } = _e, rest = tslib.__rest(_e, ["color", "variant", "indicatorSize", "disableTransition", "slotProps"]);
|
|
25
14
|
const _p = {};
|
|
26
15
|
if (variant)
|
|
27
16
|
_p.variant = variant;
|
|
28
17
|
if (color)
|
|
29
18
|
_p.color = color;
|
|
30
|
-
if (verticle)
|
|
31
|
-
_p.verticle = verticle;
|
|
32
19
|
if (disableTransition)
|
|
33
20
|
_p.disableTransition = disableTransition;
|
|
34
21
|
if (indicatorSize)
|
|
35
22
|
_p.indicatorSize = indicatorSize;
|
|
36
23
|
const p = core.useBreakpointProps(_p);
|
|
37
24
|
variant = (_b = p.variant) !== null && _b !== void 0 ? _b : "end-line";
|
|
38
|
-
color = (_c = p.color) !== null && _c !== void 0 ? _c : "
|
|
39
|
-
verticle = p.verticle;
|
|
25
|
+
color = (_c = p.color) !== null && _c !== void 0 ? _c : "primary";
|
|
40
26
|
disableTransition = p.disableTransition;
|
|
41
27
|
indicatorSize = (_d = p.indicatorSize) !== null && _d !== void 0 ? _d : 3;
|
|
42
|
-
|
|
43
|
-
const
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
28
|
+
const indicatorRef = React.useRef(null);
|
|
29
|
+
const indicatorState = React.useRef({
|
|
30
|
+
left: 0,
|
|
31
|
+
width: 0
|
|
32
|
+
});
|
|
33
|
+
let indicatorProps = {};
|
|
34
|
+
switch (variant) {
|
|
35
|
+
case "outline":
|
|
36
|
+
indicatorProps = {
|
|
37
|
+
top: 0,
|
|
38
|
+
border: "1px solid",
|
|
39
|
+
borderColor: color,
|
|
40
|
+
bgcolor: "transparent"
|
|
41
|
+
};
|
|
42
|
+
break;
|
|
43
|
+
case "ghost":
|
|
44
|
+
indicatorProps = {
|
|
45
|
+
top: 0,
|
|
46
|
+
bgcolor: `${color}.ghost`
|
|
47
|
+
};
|
|
48
|
+
break;
|
|
49
|
+
case "text":
|
|
50
|
+
indicatorProps = {
|
|
51
|
+
display: "none"
|
|
52
|
+
};
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
return (jsxRuntime.jsx(context.TabContext.Provider, { value: {
|
|
56
|
+
value,
|
|
57
|
+
variant,
|
|
58
|
+
color,
|
|
59
|
+
disableTransition,
|
|
60
|
+
indicatorSize,
|
|
61
|
+
onChange: (v, e) => {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
onChange(v, e);
|
|
64
|
+
if (variant === 'text')
|
|
65
|
+
return;
|
|
66
|
+
const indicator = indicatorRef.current;
|
|
67
|
+
if (!indicator)
|
|
68
|
+
return;
|
|
69
|
+
const target = e.currentTarget;
|
|
70
|
+
switch (variant) {
|
|
71
|
+
case "start-line":
|
|
72
|
+
indicator.style.removeProperty("bottom");
|
|
73
|
+
indicator.style.top = `${target.offsetTop}px`;
|
|
74
|
+
indicator.style.height = `${indicatorSize}px`;
|
|
75
|
+
break;
|
|
76
|
+
case "end-line":
|
|
77
|
+
indicator.style.removeProperty("top");
|
|
78
|
+
indicator.style.bottom = `${target.offsetTop}px`;
|
|
79
|
+
indicator.style.height = `${indicatorSize}px`;
|
|
80
|
+
break;
|
|
81
|
+
case "fill":
|
|
82
|
+
case "outline":
|
|
83
|
+
case "ghost":
|
|
84
|
+
indicator.style.height = `${target.offsetHeight}px`;
|
|
85
|
+
indicator.style.top = `${target.offsetTop}px`;
|
|
86
|
+
break;
|
|
100
87
|
}
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
let v = {
|
|
88
|
+
core.animate({
|
|
105
89
|
from: {
|
|
106
|
-
left: (
|
|
107
|
-
width: (
|
|
90
|
+
left: (_a = indicatorState.current.left) !== null && _a !== void 0 ? _a : 0,
|
|
91
|
+
width: (_b = indicatorState.current.width) !== null && _b !== void 0 ? _b : 0,
|
|
108
92
|
},
|
|
109
93
|
to: {
|
|
110
|
-
left:
|
|
111
|
-
width:
|
|
94
|
+
left: target.offsetLeft,
|
|
95
|
+
width: target.clientWidth,
|
|
112
96
|
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
_indicatorProps = {
|
|
130
|
-
left: 0,
|
|
131
|
-
width: indicatorSize
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
_indicatorProps = {
|
|
136
|
-
top: 0,
|
|
137
|
-
height: indicatorSize
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
break;
|
|
141
|
-
case "end-line":
|
|
142
|
-
if (verticle) {
|
|
143
|
-
_indicatorProps = {
|
|
144
|
-
right: 0,
|
|
145
|
-
width: indicatorSize
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
_indicatorProps = {
|
|
150
|
-
bottom: 0,
|
|
151
|
-
height: indicatorSize
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
break;
|
|
155
|
-
case "fill":
|
|
156
|
-
_indicatorProps = {
|
|
157
|
-
top: 0,
|
|
158
|
-
bgcolor: color
|
|
159
|
-
};
|
|
160
|
-
break;
|
|
161
|
-
case "outline":
|
|
162
|
-
_indicatorProps = {
|
|
163
|
-
top: 0,
|
|
164
|
-
border: "1px solid",
|
|
165
|
-
borderColor: color,
|
|
166
|
-
bgcolor: "transparent"
|
|
167
|
-
};
|
|
168
|
-
break;
|
|
169
|
-
case "soft":
|
|
170
|
-
_indicatorProps = {
|
|
171
|
-
top: 0,
|
|
172
|
-
bgcolor: `${color}.soft.primary`
|
|
173
|
-
};
|
|
174
|
-
break;
|
|
175
|
-
case "text":
|
|
176
|
-
_indicatorProps = {
|
|
177
|
-
display: "none"
|
|
178
|
-
};
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
return _indicatorProps;
|
|
182
|
-
}, [selectedIndex, variant, color, verticle]);
|
|
183
|
-
return (jsxRuntime.jsxs(core.Tag, Object.assign({}, rest, { baseClass: 'tabs', ref: ref, sxr: {
|
|
184
|
-
position: "relative",
|
|
185
|
-
zIndex: 1,
|
|
186
|
-
display: "inline-block"
|
|
187
|
-
}, children: [jsxRuntime.jsx(core.Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.content, { baseClass: 'tabs-content', sxr: {
|
|
188
|
-
display: verticle ? "flex" : "inline-flex",
|
|
189
|
-
flexDirection: verticle ? "column" : "row",
|
|
190
|
-
}, ref: containerRef, children: childs })), jsxRuntime.jsx(core.Transition, { open: !!trans, variant: trans, duration: trans ? (disableTransition ? 0 : 250) : 0, easing: "smooth", children: jsxRuntime.jsx(core.Tag, Object.assign({ baseClass: 'tabs-indicator',
|
|
191
|
-
// className={classname}
|
|
192
|
-
sxr: {
|
|
193
|
-
position: "absolute",
|
|
194
|
-
zIndex: -1,
|
|
195
|
-
cursor: "pointer",
|
|
196
|
-
bgcolor: color
|
|
197
|
-
} }, indicatorProps)) })] })));
|
|
97
|
+
duration: 180,
|
|
98
|
+
easing: (t) => 1 - Math.pow(1 - t, 3),
|
|
99
|
+
onUpdate: ({ left, width }) => {
|
|
100
|
+
indicatorState.current.left = left;
|
|
101
|
+
indicatorState.current.width = width;
|
|
102
|
+
indicator.style.left = `${left}px`;
|
|
103
|
+
indicator.style.width = `${width}px`;
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
}, children: jsxRuntime.jsxs(core.Tag, Object.assign({}, rest, { baseClass: 'tabs', sxr: {
|
|
108
|
+
position: "relative",
|
|
109
|
+
zIndex: 1,
|
|
110
|
+
display: "flex",
|
|
111
|
+
flexDirection: "row",
|
|
112
|
+
}, ref: ref, children: [children, jsxRuntime.jsx(core.Tag, { ref: indicatorRef, baseClass: 'tabs-indicator', sxr: Object.assign({ radius: 1, position: "absolute", zIndex: -1, bgcolor: color, height: 2 }, indicatorProps) })] })) }));
|
|
198
113
|
});
|
|
199
114
|
|
|
200
115
|
module.exports = Tabs;
|
package/Tabs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/Tabs/index.tsx"],"sourcesContent":["\"use client\";\nimport React, {
|
|
1
|
+
{"version":3,"file":"index.cjs","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/index.d.ts
CHANGED
|
@@ -1,24 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { TagProps, useBreakpointPropsType, UseColorTemplateColor } from '@xanui/core';
|
|
4
|
-
import { ButtonProps } from '../Button/index.js';
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { TabsProps } from './types.js';
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
type TabsProps = Omit<TagProps, 'onChange'> & {
|
|
8
|
-
children: ReactElement<TabProps> | ReactElement<TabProps>[];
|
|
9
|
-
value?: ValueType;
|
|
10
|
-
onChange?: (value: ValueType) => void;
|
|
11
|
-
variant?: useBreakpointPropsType<"start-line" | "end-line" | "fill" | "outline" | "text" | "soft">;
|
|
12
|
-
color?: useBreakpointPropsType<UseColorTemplateColor>;
|
|
13
|
-
verticle?: useBreakpointPropsType<boolean>;
|
|
14
|
-
disableTransition?: useBreakpointPropsType<boolean>;
|
|
15
|
-
indicatorSize?: useBreakpointPropsType<number>;
|
|
16
|
-
slotProps?: {
|
|
17
|
-
content?: Omit<TagProps, "children">;
|
|
18
|
-
button?: Omit<ButtonProps, "children" | "color" | "variant" | "classNames">;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
declare const Tabs: React.ForwardRefExoticComponent<Omit<TabsProps, "ref"> & React.RefAttributes<unknown>>;
|
|
4
|
+
declare const Tabs: React__default.ForwardRefExoticComponent<Omit<TabsProps, "ref"> & React__default.RefAttributes<unknown>>;
|
|
22
5
|
|
|
23
|
-
export { Tabs as default };
|
|
24
|
-
export type { TabsProps };
|
|
6
|
+
export { TabsProps, Tabs as default };
|