@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
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { __rest } from 'tslib';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { useState, useEffect, useRef } from 'react';
|
|
5
|
+
import { useInterface, useBreakpointProps, Tag } from '@xanui/core';
|
|
6
|
+
|
|
7
|
+
const RangeSlider = (props) => {
|
|
8
|
+
var _a;
|
|
9
|
+
const { value, defaultValue, onChange, disabled } = props, rest = __rest(props, ["value", "defaultValue", "onChange", "disabled"]);
|
|
10
|
+
// interface system
|
|
11
|
+
let [{ color, min = 0, max = 100, step = 1, thumbContent, thumbSize = 16, size = "sm" }] = useInterface("RangeSlider", rest, {});
|
|
12
|
+
const bp = useBreakpointProps({
|
|
13
|
+
color,
|
|
14
|
+
size
|
|
15
|
+
});
|
|
16
|
+
color = (_a = bp.color) !== null && _a !== void 0 ? _a : "primary";
|
|
17
|
+
size = bp.size;
|
|
18
|
+
const sizesSX = {
|
|
19
|
+
xs: {
|
|
20
|
+
track: 2,
|
|
21
|
+
thumb: 8
|
|
22
|
+
},
|
|
23
|
+
sm: {
|
|
24
|
+
track: 4,
|
|
25
|
+
thumb: 14
|
|
26
|
+
},
|
|
27
|
+
md: {
|
|
28
|
+
track: 8,
|
|
29
|
+
thumb: 18
|
|
30
|
+
},
|
|
31
|
+
lg: {
|
|
32
|
+
track: 12,
|
|
33
|
+
thumb: 24
|
|
34
|
+
},
|
|
35
|
+
xl: {
|
|
36
|
+
track: 16,
|
|
37
|
+
thumb: 32
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const _size = sizesSX[size];
|
|
41
|
+
if (thumbSize) {
|
|
42
|
+
_size.thumb = thumbSize;
|
|
43
|
+
}
|
|
44
|
+
if (disabled) {
|
|
45
|
+
color = 'surface.divider';
|
|
46
|
+
}
|
|
47
|
+
const isControlled = value !== undefined;
|
|
48
|
+
const [internalValue, setInternalValue] = useState(() => {
|
|
49
|
+
if (value !== undefined)
|
|
50
|
+
return Array.isArray(value) ? value : [value];
|
|
51
|
+
if (defaultValue !== undefined)
|
|
52
|
+
return Array.isArray(defaultValue)
|
|
53
|
+
? defaultValue
|
|
54
|
+
: [defaultValue];
|
|
55
|
+
return [min];
|
|
56
|
+
});
|
|
57
|
+
// sync controlled
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (isControlled) {
|
|
60
|
+
setInternalValue(Array.isArray(value) ? value : [value]);
|
|
61
|
+
}
|
|
62
|
+
}, [value, isControlled]);
|
|
63
|
+
const containerRef = useRef(null);
|
|
64
|
+
const isDownRef = useRef(false);
|
|
65
|
+
const activeHandleRef = useRef(null);
|
|
66
|
+
const updateValue = (index, clientX) => {
|
|
67
|
+
if (!containerRef.current)
|
|
68
|
+
return;
|
|
69
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
70
|
+
let p = (clientX - rect.left) / rect.width;
|
|
71
|
+
p = Math.max(0, Math.min(1, p));
|
|
72
|
+
const raw = min + p * (max - min);
|
|
73
|
+
const stepped = Math.round((raw - min) / step) * step + min;
|
|
74
|
+
const next = [...internalValue];
|
|
75
|
+
next[index] = Math.min(max, Math.max(min, stepped));
|
|
76
|
+
if (!isControlled) {
|
|
77
|
+
setInternalValue(next);
|
|
78
|
+
}
|
|
79
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(next.length === 1 ? next[0] : next);
|
|
80
|
+
};
|
|
81
|
+
// global drag system
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
const handleMove = (e) => {
|
|
84
|
+
if (!isDownRef.current || activeHandleRef.current === null)
|
|
85
|
+
return;
|
|
86
|
+
updateValue(activeHandleRef.current, e.clientX);
|
|
87
|
+
};
|
|
88
|
+
const handleUp = () => {
|
|
89
|
+
isDownRef.current = false;
|
|
90
|
+
activeHandleRef.current = null;
|
|
91
|
+
};
|
|
92
|
+
window.addEventListener("mousemove", handleMove);
|
|
93
|
+
window.addEventListener("mouseup", handleUp);
|
|
94
|
+
return () => {
|
|
95
|
+
window.removeEventListener("mousemove", handleMove);
|
|
96
|
+
window.removeEventListener("mouseup", handleUp);
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
const sorted = [...internalValue].sort((a, b) => a - b);
|
|
100
|
+
const startValue = sorted.length === 1 ? min : sorted[0];
|
|
101
|
+
const endValue = sorted[sorted.length - 1];
|
|
102
|
+
const startPercent = ((startValue - min) / (max - min)) * 100;
|
|
103
|
+
const endPercent = ((endValue - min) / (max - min)) * 100;
|
|
104
|
+
return (jsxs(Tag, { ref: containerRef, onClick: (e) => {
|
|
105
|
+
if (disabled)
|
|
106
|
+
return;
|
|
107
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
108
|
+
const p = (e.clientX - rect.left) / rect.width;
|
|
109
|
+
const raw = min + p * (max - min);
|
|
110
|
+
const stepped = Math.round((raw - min) / step) * step + min;
|
|
111
|
+
let closestIndex = 0;
|
|
112
|
+
let minDist = Math.abs(internalValue[0] - stepped);
|
|
113
|
+
for (let i = 1; i < internalValue.length; i++) {
|
|
114
|
+
const d = Math.abs(internalValue[i] - stepped);
|
|
115
|
+
if (d < minDist) {
|
|
116
|
+
minDist = d;
|
|
117
|
+
closestIndex = i;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
updateValue(closestIndex, e.clientX);
|
|
121
|
+
}, sxr: Object.assign({ position: "relative", width: "100%", display: "flex", alignItems: "center" }, (disabled ? { cursor: "not-allowed" } : {})), children: [jsx(Tag, { sxr: {
|
|
122
|
+
position: "absolute",
|
|
123
|
+
width: "100%",
|
|
124
|
+
height: _size.track,
|
|
125
|
+
bgcolor: 'surface.divider',
|
|
126
|
+
radius: `${_size.track}px`,
|
|
127
|
+
} }), jsx(Tag, { sxr: {
|
|
128
|
+
position: "absolute",
|
|
129
|
+
height: _size.track,
|
|
130
|
+
bgcolor: color,
|
|
131
|
+
radius: `${_size.track}px`,
|
|
132
|
+
left: `${startPercent}%`,
|
|
133
|
+
width: `${endPercent - startPercent}%`,
|
|
134
|
+
} }), internalValue.map((v, i) => {
|
|
135
|
+
const percent = ((v - min) / (max - min)) * 100;
|
|
136
|
+
return (jsx(Tag, { sxr: {
|
|
137
|
+
position: "absolute",
|
|
138
|
+
width: _size.thumb,
|
|
139
|
+
height: _size.thumb,
|
|
140
|
+
radius: `${_size.thumb}px`,
|
|
141
|
+
bgcolor: color,
|
|
142
|
+
left: `${percent}%`,
|
|
143
|
+
transform: "translateX(-50%)",
|
|
144
|
+
cursor: disabled ? "not-allowed" : "initial",
|
|
145
|
+
}, onMouseDown: (e) => {
|
|
146
|
+
if (disabled)
|
|
147
|
+
return;
|
|
148
|
+
e.preventDefault();
|
|
149
|
+
isDownRef.current = true;
|
|
150
|
+
activeHandleRef.current = i;
|
|
151
|
+
}, children: thumbContent ? thumbContent({ value: percent }) : "" }, i));
|
|
152
|
+
})] }));
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export { RangeSlider as default };
|
|
156
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/RangeSlider/index.tsx"],"sourcesContent":["\"use client\";\nimport { ReactElement, useEffect, useRef, useState } from \"react\";\nimport {\n Tag,\n useBreakpointProps,\n useBreakpointPropsType,\n UseColorTemplateColor,\n useInterface,\n} from \"@xanui/core\";\n\nexport type RangeSliderValue = number | number[];\n\nexport type RangeSliderProps = {\n color?: useBreakpointPropsType<UseColorTemplateColor>;\n min?: number;\n max?: number;\n step?: number;\n value?: RangeSliderValue;\n defaultValue?: RangeSliderValue;\n onChange?: (value: RangeSliderValue) => void;\n disabled?: boolean;\n thumbContent?: (props: { value: number }) => ReactElement\n size?: \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\"\n thumbSize?: number;\n};\n\nconst RangeSlider = (props: RangeSliderProps) => {\n const { value, defaultValue, onChange, disabled, ...rest } = props;\n\n // interface system\n let [{ color, min = 0, max = 100, step = 1, thumbContent, thumbSize = 16, size = \"sm\" }] = useInterface<any>(\n \"RangeSlider\",\n rest,\n {}\n );\n\n const bp: any = useBreakpointProps({\n color,\n size\n });\n color = bp.color ?? \"primary\"\n size = bp.size;\n\n const sizesSX: any = {\n xs: {\n track: 2,\n thumb: 8\n },\n sm: {\n track: 4,\n thumb: 14\n },\n md: {\n track: 8,\n thumb: 18\n },\n lg: {\n track: 12,\n thumb: 24\n },\n xl: {\n track: 16,\n thumb: 32\n }\n }\n\n const _size = sizesSX[size]\n\n\n if (thumbSize) {\n _size.thumb = thumbSize\n }\n\n if (disabled) {\n color = 'surface.divider'\n }\n\n const isControlled = value !== undefined;\n\n const [internalValue, setInternalValue] = useState<number[]>(() => {\n if (value !== undefined) return Array.isArray(value) ? value : [value];\n if (defaultValue !== undefined)\n return Array.isArray(defaultValue)\n ? defaultValue\n : [defaultValue];\n return [min];\n });\n\n // sync controlled\n useEffect(() => {\n if (isControlled) {\n setInternalValue(Array.isArray(value) ? value : [value!]);\n }\n }, [value, isControlled]);\n\n const containerRef = useRef<HTMLDivElement | null>(null);\n const isDownRef = useRef(false);\n const activeHandleRef = useRef<number | null>(null);\n\n const updateValue = (index: number, clientX: number) => {\n if (!containerRef.current) return;\n\n const rect = containerRef.current.getBoundingClientRect();\n let p = (clientX - rect.left) / rect.width;\n p = Math.max(0, Math.min(1, p));\n\n const raw = min + p * (max - min);\n const stepped = Math.round((raw - min) / step) * step + min;\n\n const next = [...internalValue];\n next[index] = Math.min(max, Math.max(min, stepped));\n\n if (!isControlled) {\n setInternalValue(next);\n }\n\n onChange?.(next.length === 1 ? next[0] : next);\n };\n\n // global drag system\n useEffect(() => {\n const handleMove = (e: MouseEvent) => {\n if (!isDownRef.current || activeHandleRef.current === null) return;\n updateValue(activeHandleRef.current, e.clientX);\n };\n\n const handleUp = () => {\n isDownRef.current = false;\n activeHandleRef.current = null;\n };\n\n window.addEventListener(\"mousemove\", handleMove);\n window.addEventListener(\"mouseup\", handleUp);\n\n return () => {\n window.removeEventListener(\"mousemove\", handleMove);\n window.removeEventListener(\"mouseup\", handleUp);\n };\n });\n\n const sorted = [...internalValue].sort((a, b) => a - b);\n\n const startValue = sorted.length === 1 ? min : sorted[0];\n const endValue = sorted[sorted.length - 1];\n\n const startPercent = ((startValue - min) / (max - min)) * 100;\n const endPercent = ((endValue - min) / (max - min)) * 100;\n\n\n\n return (\n <Tag\n ref={containerRef}\n onClick={(e: any) => {\n if (disabled) return;\n\n const rect = e.currentTarget.getBoundingClientRect();\n const p = (e.clientX - rect.left) / rect.width;\n const raw = min + p * (max - min);\n const stepped = Math.round((raw - min) / step) * step + min;\n\n let closestIndex = 0;\n let minDist = Math.abs(internalValue[0] - stepped);\n\n for (let i = 1; i < internalValue.length; i++) {\n const d = Math.abs(internalValue[i] - stepped);\n if (d < minDist) {\n minDist = d;\n closestIndex = i;\n }\n }\n\n updateValue(closestIndex, e.clientX);\n }}\n sxr={{\n position: \"relative\",\n width: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n ...(disabled ? { cursor: \"not-allowed\" } : {}),\n }}\n >\n {/* Track */}\n <Tag\n sxr={{\n position: \"absolute\",\n width: \"100%\",\n height: _size.track,\n bgcolor: 'surface.divider',\n radius: `${_size.track}px`,\n }}\n />\n\n <Tag\n sxr={{\n position: \"absolute\",\n height: _size.track,\n bgcolor: color,\n radius: `${_size.track}px`,\n left: `${startPercent}%`,\n width: `${endPercent - startPercent}%`,\n }}\n />\n\n {internalValue.map((v, i) => {\n const percent = ((v - min) / (max - min)) * 100;\n return (\n <Tag\n key={i}\n sxr={{\n position: \"absolute\",\n width: _size.thumb,\n height: _size.thumb,\n radius: `${_size.thumb}px`,\n bgcolor: color,\n left: `${percent}%`,\n transform: \"translateX(-50%)\",\n cursor: disabled ? \"not-allowed\" : \"initial\",\n }}\n onMouseDown={(e) => {\n if (disabled) return;\n e.preventDefault();\n isDownRef.current = true;\n activeHandleRef.current = i;\n }}\n >\n {thumbContent ? thumbContent({ value: percent }) : \"\"}\n </Tag>\n );\n })}\n </Tag>\n );\n};\n\nexport default RangeSlider;"],"names":[],"mappings":";;;;;;AA0BA;;AACG;;AAGA;;;;AASC;AACD;AACA;AAEA;AACG;AACG;AACA;AACF;AACD;AACG;AACA;AACF;AACD;AACG;AACA;AACF;AACD;AACG;AACA;AACF;AACD;AACG;AACA;AACF;;AAGJ;;AAIG;;;;;AAOH;;;AAG4B;;AAEtB;AACG;AACA;;AAET;;;;AAKM;;AAEN;AAEA;AACA;AACA;AAEA;;;;AAIG;AACA;;AAGA;AAEA;AACA;;;;;AAOH;;;AAIG;;;;AAGA;;AAGG;AACA;AACH;AAEA;AACA;AAEA;AACG;AACA;AACH;AACH;;AAIA;;AAGA;AACA;AAIA;AAIS;;;AAGA;;AAEA;;AAGA;AAEA;AACG;AACA;;;;;AAMH;AACH;AAYM;AACA;;AAEA;AACA;AACF;AAKE;;AAEA;AACA;;AAEA;;AAKH;AACA;AAIS;;;AAGA;AACA;;AAEA;;AAEF;AAEE;;;AAEA;AACA;;;AASrB;;"}
|
package/Scrollbar/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ var core = require('@xanui/core');
|
|
|
7
7
|
var React = require('react');
|
|
8
8
|
|
|
9
9
|
const Scrollbar = React.forwardRef((_a, ref) => {
|
|
10
|
-
var { children,
|
|
10
|
+
var { children, size, thumbColor, trackColor } = _a, rest = tslib.__rest(_a, ["children", "size", "thumbColor", "trackColor"]);
|
|
11
11
|
let [_b] = core.useInterface("Scrollbar", rest, {}), { onScroll, onScrollEnd } = _b, props = tslib.__rest(_b, ["onScroll", "onScrollEnd"]);
|
|
12
12
|
const innerRef = React.useRef(null);
|
|
13
13
|
React.useImperativeHandle(ref, () => ({
|
|
@@ -49,20 +49,20 @@ const Scrollbar = React.forwardRef((_a, ref) => {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
let sxr = {};
|
|
52
|
-
if (
|
|
52
|
+
if (size) {
|
|
53
53
|
sxr['&::-webkit-scrollbar'] = {
|
|
54
|
-
width:
|
|
55
|
-
height:
|
|
54
|
+
width: size,
|
|
55
|
+
height: size,
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
if (thumbColor) {
|
|
59
59
|
sxr['&::-webkit-scrollbar-thumb'] = {
|
|
60
|
-
backgroundColor: thumbColor,
|
|
60
|
+
backgroundColor: thumbColor + "!important",
|
|
61
61
|
borderRadius: "6px",
|
|
62
62
|
opacity: 0.6,
|
|
63
63
|
};
|
|
64
64
|
sxr['&::-webkit-scrollbar-thumb:hover'] = {
|
|
65
|
-
backgroundColor: thumbColor,
|
|
65
|
+
backgroundColor: thumbColor + "!important",
|
|
66
66
|
opacity: 0.0,
|
|
67
67
|
};
|
|
68
68
|
}
|
package/Scrollbar/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/Scrollbar/index.tsx"],"sourcesContent":["\"use client\";\nimport { Tag, TagComponentType, TagProps, useInterface } from '@xanui/core';\nimport React, { ReactNode, UIEvent, useImperativeHandle, useRef } from 'react'\n\nexport type ScrollbarProps<T extends TagComponentType = \"div\"> = TagProps<T> & {\n
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/Scrollbar/index.tsx"],"sourcesContent":["\"use client\";\nimport { Tag, TagComponentType, TagProps, useInterface } from '@xanui/core';\nimport React, { ReactNode, UIEvent, useImperativeHandle, useRef } from 'react'\n\nexport type ScrollbarProps<T extends TagComponentType = \"div\"> = TagProps<T> & {\n size?: number;\n thumbColor?: TagProps['color'];\n trackColor?: TagProps['color'];\n children?: ReactNode;\n onScrollEnd?: (e: UIEvent<HTMLDivElement>) => void;\n}\n\nexport type ScrollbarHandle = {\n scrollTo: (pos: number) => void;\n scrollToBottom: () => void;\n scrollToTop: () => void;\n};\n\nconst Scrollbar = React.forwardRef(<T extends TagComponentType = \"div\">({ children, size, thumbColor, trackColor, ...rest }: ScrollbarProps<T>, ref: React.Ref<ScrollbarHandle>) => {\n let [{ onScroll, onScrollEnd, ...props }] = useInterface<any>(\"Scrollbar\", rest, {})\n const innerRef = useRef<HTMLDivElement>(null);\n\n useImperativeHandle(ref, () => ({\n scrollTo(pos: number) {\n innerRef.current?.scrollTo({\n top: pos,\n behavior: \"smooth\"\n });\n },\n scrollToBottom() {\n if (!innerRef.current) return;\n const ele = innerRef.current;\n ele.scrollTo({\n top: ele.scrollHeight,\n behavior: \"smooth\"\n });\n },\n scrollToTop() {\n innerRef.current?.scrollTo({\n top: 0,\n behavior: \"smooth\"\n });\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 let sxr: any = {}\n\n if (size) {\n sxr['&::-webkit-scrollbar'] = {\n width: size,\n height: size,\n }\n }\n if (thumbColor) {\n sxr['&::-webkit-scrollbar-thumb'] = {\n backgroundColor: thumbColor + \"!important\",\n borderRadius: \"6px\",\n opacity: 0.6,\n }\n sxr['&::-webkit-scrollbar-thumb:hover'] = {\n backgroundColor: thumbColor + \"!important\",\n opacity: 0.0,\n }\n }\n\n if (trackColor) {\n sxr['&::-webkit-scrollbar-track'] = {\n backgroundColor: trackColor,\n borderRadius: \"6px\",\n }\n }\n\n return (\n <Tag\n {...props}\n ref={innerRef}\n baseClass='scrollbar'\n sxr={{\n height: \"100%\",\n width: \"100%\",\n overflow: \"auto\",\n ...sxr,\n }}\n >\n {children}\n </Tag>\n )\n})\n\nexport default Scrollbar "],"names":[],"mappings":";;;;;;;;AAkBA;AAAwE;;AAEpE;AAEA;AACI;;AACI;AACI;AACA;AACH;;;;;AAID;;;AAGI;AACH;;;;AAGD;AACI;AACA;AACH;;AAER;AAED;AACI;;AAEQ;AACA;AACA;AACA;;AAEA;;AAEJ;AACJ;;;;;AAOI;AACA;;;;;;AAMA;AACA;;;;AAIA;;;;;AAMA;AACA;;;AAIR;AAeJ;;"}
|
package/Scrollbar/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TagComponentType, TagProps } from '@xanui/core';
|
|
2
|
-
import
|
|
2
|
+
import React__default, { ReactNode, UIEvent } from 'react';
|
|
3
3
|
|
|
4
4
|
type ScrollbarProps<T extends TagComponentType = "div"> = TagProps<T> & {
|
|
5
|
-
|
|
5
|
+
size?: number;
|
|
6
6
|
thumbColor?: TagProps['color'];
|
|
7
7
|
trackColor?: TagProps['color'];
|
|
8
8
|
children?: ReactNode;
|
|
@@ -13,7 +13,7 @@ type ScrollbarHandle = {
|
|
|
13
13
|
scrollToBottom: () => void;
|
|
14
14
|
scrollToTop: () => void;
|
|
15
15
|
};
|
|
16
|
-
declare const Scrollbar:
|
|
16
|
+
declare const Scrollbar: React__default.ForwardRefExoticComponent<Omit<ScrollbarProps<TagComponentType>, "ref"> & React__default.RefAttributes<ScrollbarHandle>>;
|
|
17
17
|
|
|
18
18
|
export { Scrollbar as default };
|
|
19
19
|
export type { ScrollbarHandle, ScrollbarProps };
|
package/Scrollbar/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { useInterface, Tag } from '@xanui/core';
|
|
|
5
5
|
import React, { useRef, useImperativeHandle } from 'react';
|
|
6
6
|
|
|
7
7
|
const Scrollbar = React.forwardRef((_a, ref) => {
|
|
8
|
-
var { children,
|
|
8
|
+
var { children, size, thumbColor, trackColor } = _a, rest = __rest(_a, ["children", "size", "thumbColor", "trackColor"]);
|
|
9
9
|
let [_b] = useInterface("Scrollbar", rest, {}), { onScroll, onScrollEnd } = _b, props = __rest(_b, ["onScroll", "onScrollEnd"]);
|
|
10
10
|
const innerRef = useRef(null);
|
|
11
11
|
useImperativeHandle(ref, () => ({
|
|
@@ -47,20 +47,20 @@ const Scrollbar = React.forwardRef((_a, ref) => {
|
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
let sxr = {};
|
|
50
|
-
if (
|
|
50
|
+
if (size) {
|
|
51
51
|
sxr['&::-webkit-scrollbar'] = {
|
|
52
|
-
width:
|
|
53
|
-
height:
|
|
52
|
+
width: size,
|
|
53
|
+
height: size,
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
if (thumbColor) {
|
|
57
57
|
sxr['&::-webkit-scrollbar-thumb'] = {
|
|
58
|
-
backgroundColor: thumbColor,
|
|
58
|
+
backgroundColor: thumbColor + "!important",
|
|
59
59
|
borderRadius: "6px",
|
|
60
60
|
opacity: 0.6,
|
|
61
61
|
};
|
|
62
62
|
sxr['&::-webkit-scrollbar-thumb:hover'] = {
|
|
63
|
-
backgroundColor: thumbColor,
|
|
63
|
+
backgroundColor: thumbColor + "!important",
|
|
64
64
|
opacity: 0.0,
|
|
65
65
|
};
|
|
66
66
|
}
|
package/Scrollbar/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Scrollbar/index.tsx"],"sourcesContent":["\"use client\";\nimport { Tag, TagComponentType, TagProps, useInterface } from '@xanui/core';\nimport React, { ReactNode, UIEvent, useImperativeHandle, useRef } from 'react'\n\nexport type ScrollbarProps<T extends TagComponentType = \"div\"> = TagProps<T> & {\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Scrollbar/index.tsx"],"sourcesContent":["\"use client\";\nimport { Tag, TagComponentType, TagProps, useInterface } from '@xanui/core';\nimport React, { ReactNode, UIEvent, useImperativeHandle, useRef } from 'react'\n\nexport type ScrollbarProps<T extends TagComponentType = \"div\"> = TagProps<T> & {\n size?: number;\n thumbColor?: TagProps['color'];\n trackColor?: TagProps['color'];\n children?: ReactNode;\n onScrollEnd?: (e: UIEvent<HTMLDivElement>) => void;\n}\n\nexport type ScrollbarHandle = {\n scrollTo: (pos: number) => void;\n scrollToBottom: () => void;\n scrollToTop: () => void;\n};\n\nconst Scrollbar = React.forwardRef(<T extends TagComponentType = \"div\">({ children, size, thumbColor, trackColor, ...rest }: ScrollbarProps<T>, ref: React.Ref<ScrollbarHandle>) => {\n let [{ onScroll, onScrollEnd, ...props }] = useInterface<any>(\"Scrollbar\", rest, {})\n const innerRef = useRef<HTMLDivElement>(null);\n\n useImperativeHandle(ref, () => ({\n scrollTo(pos: number) {\n innerRef.current?.scrollTo({\n top: pos,\n behavior: \"smooth\"\n });\n },\n scrollToBottom() {\n if (!innerRef.current) return;\n const ele = innerRef.current;\n ele.scrollTo({\n top: ele.scrollHeight,\n behavior: \"smooth\"\n });\n },\n scrollToTop() {\n innerRef.current?.scrollTo({\n top: 0,\n behavior: \"smooth\"\n });\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 let sxr: any = {}\n\n if (size) {\n sxr['&::-webkit-scrollbar'] = {\n width: size,\n height: size,\n }\n }\n if (thumbColor) {\n sxr['&::-webkit-scrollbar-thumb'] = {\n backgroundColor: thumbColor + \"!important\",\n borderRadius: \"6px\",\n opacity: 0.6,\n }\n sxr['&::-webkit-scrollbar-thumb:hover'] = {\n backgroundColor: thumbColor + \"!important\",\n opacity: 0.0,\n }\n }\n\n if (trackColor) {\n sxr['&::-webkit-scrollbar-track'] = {\n backgroundColor: trackColor,\n borderRadius: \"6px\",\n }\n }\n\n return (\n <Tag\n {...props}\n ref={innerRef}\n baseClass='scrollbar'\n sxr={{\n height: \"100%\",\n width: \"100%\",\n overflow: \"auto\",\n ...sxr,\n }}\n >\n {children}\n </Tag>\n )\n})\n\nexport default Scrollbar "],"names":[],"mappings":";;;;;;AAkBA;AAAwE;;AAEpE;AAEA;AACI;;AACI;AACI;AACA;AACH;;;;;AAID;;;AAGI;AACH;;;;AAGD;AACI;AACA;AACH;;AAER;AAED;AACI;;AAEQ;AACA;AACA;AACA;;AAEA;;AAEJ;AACJ;;;;;AAOI;AACA;;;;;;AAMA;AACA;;;;AAIA;;;;;AAMA;AACA;;;AAIR;AAeJ;;"}
|
package/Select/index.cjs
CHANGED
|
@@ -16,7 +16,7 @@ const Select = React.forwardRef((_a, ref) => {
|
|
|
16
16
|
var _b, _c, _d, _e, _f, _g;
|
|
17
17
|
var { onChange, value, children, error, helperText, name, refs } = _a, props = tslib.__rest(_a, ["onChange", "value", "children", "error", "helperText", "name", "refs"]);
|
|
18
18
|
let [_h] = core.useInterface("Select", props, {}), { slotProps, color, variant } = _h, inputProps = tslib.__rest(_h, ["slotProps", "color", "variant"]);
|
|
19
|
-
color !== null && color !== void 0 ? color : (color = "
|
|
19
|
+
color !== null && color !== void 0 ? color : (color = "primary");
|
|
20
20
|
variant !== null && variant !== void 0 ? variant : (variant = "fill");
|
|
21
21
|
const [target, setTarget] = React.useState();
|
|
22
22
|
const conRef = React.useRef(null);
|
|
@@ -42,7 +42,7 @@ const Select = React.forwardRef((_a, ref) => {
|
|
|
42
42
|
}, [children, value]);
|
|
43
43
|
const mergeRefs = core.useMergeRefs(ref, conRef);
|
|
44
44
|
const toggleMenu = () => setTarget(target ? null : conRef.current);
|
|
45
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(index, Object.assign({ ref: mergeRefs, color: color, variant: variant === "
|
|
45
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(index, Object.assign({ ref: mergeRefs, color: color, variant: variant === "ghost" ? "fill" : variant, endIcon: jsxRuntime.jsxs(index$1, { flexDirection: "row", component: "span", children: [" ", (target ? jsxRuntime.jsx(UpIcon, {}) : jsxRuntime.jsx(DownIcon, {}))] }), readOnly: true, value: typeof selectedProps.children === 'string' ? selectedProps.children : value, cursor: "pointer", userSelect: "none", startIcon: selectedProps.startIcon, focused: !!target, error: error, helperText: helperText, name: name }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.input, inputProps, { refs: Object.assign({ input: refs === null || refs === void 0 ? void 0 : refs.input }, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.input) === null || _b === void 0 ? void 0 : _b.refs), slotProps: {
|
|
46
46
|
rootContainer: Object.assign(Object.assign({ cursor: "pointer", userSelect: "none" }, (((_d = (_c = slotProps === null || slotProps === void 0 ? void 0 : slotProps.input) === null || _c === void 0 ? void 0 : _c.slotProps) === null || _d === void 0 ? void 0 : _d.container) || {})), { onClick: () => {
|
|
47
47
|
if (!target) {
|
|
48
48
|
toggleMenu();
|
package/Select/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/Select/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { ReactElement, useMemo, cloneElement, useState, Children, useRef } from 'react'\nimport Input, { InputProps } from '../Input'\nimport List, { ListProps } from '../List'\nimport Menu, { MenuProps } from '../Menu'\nimport Stack from '../Stack'\nimport { OptionProps } from '../Option'\nimport DownIcon from '@xanui/icons/KeyboardArrowDown';\nimport UpIcon from '@xanui/icons/KeyboardArrowUp';\nimport { useInterface, useMergeRefs } from '@xanui/core'\n\n\nexport type SelectProps = Omit<InputProps, \"onChange\" | \"value\" | \"children\" | \"slotProps\"> & {\n value?: string | number;\n onChange?: (value: string | number) => void;\n children: ReactElement<OptionProps> | ReactElement<OptionProps>[];\n\n refs?: {\n input?: React.Ref<any>;\n menu?: React.Ref<any>;\n list?: React.Ref<any>;\n };\n slotProps?: {\n menu?: Omit<MenuProps, 'children' | 'target'>;\n input?: Omit<InputProps, \"onChange\" | \"value\">;\n list?: Omit<ListProps, \"children\">\n }\n}\n\nconst Select = React.forwardRef(({ onChange, value, children, error, helperText, name, refs, ...props }: SelectProps, ref: React.Ref<any>) => {\n let [{ slotProps, color, variant, ...inputProps }] = useInterface<any>(\"Select\", props, {})\n color ??= \"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/Select/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { ReactElement, useMemo, cloneElement, useState, Children, useRef } from 'react'\nimport Input, { InputProps } from '../Input'\nimport List, { ListProps } from '../List'\nimport Menu, { MenuProps } from '../Menu'\nimport Stack from '../Stack'\nimport { OptionProps } from '../Option'\nimport DownIcon from '@xanui/icons/KeyboardArrowDown';\nimport UpIcon from '@xanui/icons/KeyboardArrowUp';\nimport { useInterface, useMergeRefs } from '@xanui/core'\n\n\nexport type SelectProps = Omit<InputProps, \"onChange\" | \"value\" | \"children\" | \"slotProps\"> & {\n value?: string | number;\n onChange?: (value: string | number) => void;\n children: ReactElement<OptionProps> | ReactElement<OptionProps>[];\n\n refs?: {\n input?: React.Ref<any>;\n menu?: React.Ref<any>;\n list?: React.Ref<any>;\n };\n slotProps?: {\n menu?: Omit<MenuProps, 'children' | 'target'>;\n input?: Omit<InputProps, \"onChange\" | \"value\">;\n list?: Omit<ListProps, \"children\">\n }\n}\n\nconst Select = React.forwardRef(({ onChange, value, children, error, helperText, name, refs, ...props }: SelectProps, ref: React.Ref<any>) => {\n let [{ slotProps, color, variant, ...inputProps }] = useInterface<any>(\"Select\", props, {})\n color ??= \"primary\"\n variant ??= \"fill\"\n const [target, setTarget] = useState<any>()\n const conRef = useRef(null)\n const { childs, selectedProps } = useMemo(() => {\n let sProps: any = {}\n const c = Children.map(children, (child: any) => {\n let selected = child.props.value === value\n if (selected) sProps = child.props\n return cloneElement(child, {\n value: undefined,\n selected,\n onClick: () => {\n setTarget(null)\n onChange && onChange(child.props.value)\n }\n })\n })\n return {\n childs: c,\n selectedProps: sProps as OptionProps\n }\n }, [children, value])\n\n const mergeRefs = useMergeRefs(ref, conRef)\n const toggleMenu = () => setTarget(target ? null : conRef.current)\n\n return (\n <>\n <Input\n ref={mergeRefs}\n color={color}\n variant={variant === \"ghost\" ? \"fill\" : variant}\n endIcon={<Stack flexDirection=\"row\" component=\"span\" > {(target ? <UpIcon /> : <DownIcon />)}</Stack>}\n readOnly\n value={typeof selectedProps.children === 'string' ? selectedProps.children : value}\n cursor=\"pointer\"\n userSelect=\"none\"\n startIcon={selectedProps.startIcon}\n focused={!!target}\n error={error}\n helperText={helperText}\n name={name}\n {...slotProps?.input}\n {...inputProps}\n refs={{\n input: refs?.input,\n ...slotProps?.input?.refs\n }}\n slotProps={{\n rootContainer: {\n cursor: \"pointer\",\n userSelect: \"none\",\n ...(slotProps?.input?.slotProps?.container || {}),\n onClick: () => {\n if (!target) {\n toggleMenu()\n }\n },\n }\n }}\n />\n <Menu\n ref={refs?.menu}\n target={target}\n placement=\"bottom-left\"\n {...slotProps?.menu}\n slotProps={{\n ...slotProps?.menu?.slotProps,\n content: {\n mt: .5,\n ...slotProps?.menu?.content,\n width: conRef && (conRef?.current as any)?.clientWidth,\n }\n }}\n onClickOutside={(e) => {\n if ((conRef.current as any).contains(e.target)) return;\n toggleMenu()\n }}\n >\n <List\n ref={refs?.list}\n {...slotProps?.list}\n color={color}\n variant={variant === \"outline\" ? \"fill\" : variant}\n maxHeight={typeof window === \"undefined\" ? \"auto\" : window?.innerHeight - 50}\n overflow={\"auto\"}\n >\n {childs}\n </List>\n </Menu>\n </>\n )\n})\n\nexport default Select"],"names":[],"mappings":";;;;;;;;;;;;;;AA6BA;;AAAiC;;;;;AAK7B;;;;;AAKQ;AAAc;;AAEV;;;;;;AAMH;AACL;;AAEI;AACA;;AAER;;AAGA;AAEA;AAuBgB;;AAMY;;AAER;AAEP;;;AAiBG;AACJ;AAehB;;"}
|
package/Select/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default, { ReactElement } from 'react';
|
|
2
2
|
import { InputProps } from '../Input/index.js';
|
|
3
3
|
import { ListProps } from '../List/index.js';
|
|
4
4
|
import { MenuProps } from '../Menu/index.js';
|
|
@@ -9,9 +9,9 @@ type SelectProps = Omit<InputProps, "onChange" | "value" | "children" | "slotPro
|
|
|
9
9
|
onChange?: (value: string | number) => void;
|
|
10
10
|
children: ReactElement<OptionProps> | ReactElement<OptionProps>[];
|
|
11
11
|
refs?: {
|
|
12
|
-
input?:
|
|
13
|
-
menu?:
|
|
14
|
-
list?:
|
|
12
|
+
input?: React__default.Ref<any>;
|
|
13
|
+
menu?: React__default.Ref<any>;
|
|
14
|
+
list?: React__default.Ref<any>;
|
|
15
15
|
};
|
|
16
16
|
slotProps?: {
|
|
17
17
|
menu?: Omit<MenuProps, 'children' | 'target'>;
|
|
@@ -19,7 +19,7 @@ type SelectProps = Omit<InputProps, "onChange" | "value" | "children" | "slotPro
|
|
|
19
19
|
list?: Omit<ListProps, "children">;
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
declare const Select:
|
|
22
|
+
declare const Select: React__default.ForwardRefExoticComponent<Omit<SelectProps, "ref"> & React__default.RefAttributes<any>>;
|
|
23
23
|
|
|
24
24
|
export { Select as default };
|
|
25
25
|
export type { SelectProps };
|
package/Select/index.js
CHANGED
|
@@ -14,7 +14,7 @@ const Select = React.forwardRef((_a, ref) => {
|
|
|
14
14
|
var _b, _c, _d, _e, _f, _g;
|
|
15
15
|
var { onChange, value, children, error, helperText, name, refs } = _a, props = __rest(_a, ["onChange", "value", "children", "error", "helperText", "name", "refs"]);
|
|
16
16
|
let [_h] = useInterface("Select", props, {}), { slotProps, color, variant } = _h, inputProps = __rest(_h, ["slotProps", "color", "variant"]);
|
|
17
|
-
color !== null && color !== void 0 ? color : (color = "
|
|
17
|
+
color !== null && color !== void 0 ? color : (color = "primary");
|
|
18
18
|
variant !== null && variant !== void 0 ? variant : (variant = "fill");
|
|
19
19
|
const [target, setTarget] = useState();
|
|
20
20
|
const conRef = useRef(null);
|
|
@@ -40,7 +40,7 @@ const Select = React.forwardRef((_a, ref) => {
|
|
|
40
40
|
}, [children, value]);
|
|
41
41
|
const mergeRefs = useMergeRefs(ref, conRef);
|
|
42
42
|
const toggleMenu = () => setTarget(target ? null : conRef.current);
|
|
43
|
-
return (jsxs(Fragment, { children: [jsx(Input, Object.assign({ ref: mergeRefs, color: color, variant: variant === "
|
|
43
|
+
return (jsxs(Fragment, { children: [jsx(Input, Object.assign({ ref: mergeRefs, color: color, variant: variant === "ghost" ? "fill" : variant, endIcon: jsxs(Stack, { flexDirection: "row", component: "span", children: [" ", (target ? jsx(UpIcon, {}) : jsx(DownIcon, {}))] }), readOnly: true, value: typeof selectedProps.children === 'string' ? selectedProps.children : value, cursor: "pointer", userSelect: "none", startIcon: selectedProps.startIcon, focused: !!target, error: error, helperText: helperText, name: name }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.input, inputProps, { refs: Object.assign({ input: refs === null || refs === void 0 ? void 0 : refs.input }, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.input) === null || _b === void 0 ? void 0 : _b.refs), slotProps: {
|
|
44
44
|
rootContainer: Object.assign(Object.assign({ cursor: "pointer", userSelect: "none" }, (((_d = (_c = slotProps === null || slotProps === void 0 ? void 0 : slotProps.input) === null || _c === void 0 ? void 0 : _c.slotProps) === null || _d === void 0 ? void 0 : _d.container) || {})), { onClick: () => {
|
|
45
45
|
if (!target) {
|
|
46
46
|
toggleMenu();
|
package/Select/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Select/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { ReactElement, useMemo, cloneElement, useState, Children, useRef } from 'react'\nimport Input, { InputProps } from '../Input'\nimport List, { ListProps } from '../List'\nimport Menu, { MenuProps } from '../Menu'\nimport Stack from '../Stack'\nimport { OptionProps } from '../Option'\nimport DownIcon from '@xanui/icons/KeyboardArrowDown';\nimport UpIcon from '@xanui/icons/KeyboardArrowUp';\nimport { useInterface, useMergeRefs } from '@xanui/core'\n\n\nexport type SelectProps = Omit<InputProps, \"onChange\" | \"value\" | \"children\" | \"slotProps\"> & {\n value?: string | number;\n onChange?: (value: string | number) => void;\n children: ReactElement<OptionProps> | ReactElement<OptionProps>[];\n\n refs?: {\n input?: React.Ref<any>;\n menu?: React.Ref<any>;\n list?: React.Ref<any>;\n };\n slotProps?: {\n menu?: Omit<MenuProps, 'children' | 'target'>;\n input?: Omit<InputProps, \"onChange\" | \"value\">;\n list?: Omit<ListProps, \"children\">\n }\n}\n\nconst Select = React.forwardRef(({ onChange, value, children, error, helperText, name, refs, ...props }: SelectProps, ref: React.Ref<any>) => {\n let [{ slotProps, color, variant, ...inputProps }] = useInterface<any>(\"Select\", props, {})\n color ??= \"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Select/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { ReactElement, useMemo, cloneElement, useState, Children, useRef } from 'react'\nimport Input, { InputProps } from '../Input'\nimport List, { ListProps } from '../List'\nimport Menu, { MenuProps } from '../Menu'\nimport Stack from '../Stack'\nimport { OptionProps } from '../Option'\nimport DownIcon from '@xanui/icons/KeyboardArrowDown';\nimport UpIcon from '@xanui/icons/KeyboardArrowUp';\nimport { useInterface, useMergeRefs } from '@xanui/core'\n\n\nexport type SelectProps = Omit<InputProps, \"onChange\" | \"value\" | \"children\" | \"slotProps\"> & {\n value?: string | number;\n onChange?: (value: string | number) => void;\n children: ReactElement<OptionProps> | ReactElement<OptionProps>[];\n\n refs?: {\n input?: React.Ref<any>;\n menu?: React.Ref<any>;\n list?: React.Ref<any>;\n };\n slotProps?: {\n menu?: Omit<MenuProps, 'children' | 'target'>;\n input?: Omit<InputProps, \"onChange\" | \"value\">;\n list?: Omit<ListProps, \"children\">\n }\n}\n\nconst Select = React.forwardRef(({ onChange, value, children, error, helperText, name, refs, ...props }: SelectProps, ref: React.Ref<any>) => {\n let [{ slotProps, color, variant, ...inputProps }] = useInterface<any>(\"Select\", props, {})\n color ??= \"primary\"\n variant ??= \"fill\"\n const [target, setTarget] = useState<any>()\n const conRef = useRef(null)\n const { childs, selectedProps } = useMemo(() => {\n let sProps: any = {}\n const c = Children.map(children, (child: any) => {\n let selected = child.props.value === value\n if (selected) sProps = child.props\n return cloneElement(child, {\n value: undefined,\n selected,\n onClick: () => {\n setTarget(null)\n onChange && onChange(child.props.value)\n }\n })\n })\n return {\n childs: c,\n selectedProps: sProps as OptionProps\n }\n }, [children, value])\n\n const mergeRefs = useMergeRefs(ref, conRef)\n const toggleMenu = () => setTarget(target ? null : conRef.current)\n\n return (\n <>\n <Input\n ref={mergeRefs}\n color={color}\n variant={variant === \"ghost\" ? \"fill\" : variant}\n endIcon={<Stack flexDirection=\"row\" component=\"span\" > {(target ? <UpIcon /> : <DownIcon />)}</Stack>}\n readOnly\n value={typeof selectedProps.children === 'string' ? selectedProps.children : value}\n cursor=\"pointer\"\n userSelect=\"none\"\n startIcon={selectedProps.startIcon}\n focused={!!target}\n error={error}\n helperText={helperText}\n name={name}\n {...slotProps?.input}\n {...inputProps}\n refs={{\n input: refs?.input,\n ...slotProps?.input?.refs\n }}\n slotProps={{\n rootContainer: {\n cursor: \"pointer\",\n userSelect: \"none\",\n ...(slotProps?.input?.slotProps?.container || {}),\n onClick: () => {\n if (!target) {\n toggleMenu()\n }\n },\n }\n }}\n />\n <Menu\n ref={refs?.menu}\n target={target}\n placement=\"bottom-left\"\n {...slotProps?.menu}\n slotProps={{\n ...slotProps?.menu?.slotProps,\n content: {\n mt: .5,\n ...slotProps?.menu?.content,\n width: conRef && (conRef?.current as any)?.clientWidth,\n }\n }}\n onClickOutside={(e) => {\n if ((conRef.current as any).contains(e.target)) return;\n toggleMenu()\n }}\n >\n <List\n ref={refs?.list}\n {...slotProps?.list}\n color={color}\n variant={variant === \"outline\" ? \"fill\" : variant}\n maxHeight={typeof window === \"undefined\" ? \"auto\" : window?.innerHeight - 50}\n overflow={\"auto\"}\n >\n {childs}\n </List>\n </Menu>\n </>\n )\n})\n\nexport default Select"],"names":[],"mappings":";;;;;;;;;;;;AA6BA;;AAAiC;;;;;AAK7B;;;;;AAKQ;AAAc;;AAEV;;;;;;AAMH;AACL;;AAEI;AACA;;AAER;;AAGA;AAEA;AAuBgB;;AAMY;;AAER;AAEP;;;AAiBG;AACJ;AAehB;;"}
|
package/Skeleton/index.cjs
CHANGED
|
@@ -12,12 +12,13 @@ const Skeleton = React.forwardRef((_a, ref) => {
|
|
|
12
12
|
loading = true;
|
|
13
13
|
if (loading) {
|
|
14
14
|
animation !== null && animation !== void 0 ? animation : (animation = 'pulse');
|
|
15
|
-
color !== null && color !== void 0 ? color : (color =
|
|
15
|
+
color !== null && color !== void 0 ? color : (color = 'surface');
|
|
16
16
|
let sxr = {};
|
|
17
17
|
switch (animation) {
|
|
18
18
|
case 'pulse':
|
|
19
19
|
sxr = {
|
|
20
|
-
|
|
20
|
+
radius: 1,
|
|
21
|
+
bgcolor: `${color}.divider`,
|
|
21
22
|
width: "100%",
|
|
22
23
|
animation: 'skpulse 1.5s infinite',
|
|
23
24
|
"@keyframes skpulse": {
|
|
@@ -32,9 +33,10 @@ const Skeleton = React.forwardRef((_a, ref) => {
|
|
|
32
33
|
break;
|
|
33
34
|
case 'wave':
|
|
34
35
|
sxr = {
|
|
36
|
+
radius: 1,
|
|
35
37
|
position: 'relative',
|
|
36
38
|
overflow: 'hidden',
|
|
37
|
-
bgcolor:
|
|
39
|
+
bgcolor: `${color}.ghost`,
|
|
38
40
|
"&::after": {
|
|
39
41
|
content: '""',
|
|
40
42
|
position: 'absolute',
|
|
@@ -42,8 +44,8 @@ const Skeleton = React.forwardRef((_a, ref) => {
|
|
|
42
44
|
left: "0%",
|
|
43
45
|
width: '100%',
|
|
44
46
|
height: '100%',
|
|
45
|
-
animation: 'skwave
|
|
46
|
-
background: `linear-gradient(90deg, transparent 0%, var(--color-divider
|
|
47
|
+
animation: 'skwave 2.5s infinite',
|
|
48
|
+
background: `linear-gradient(90deg, transparent 0%, var(--color-${color}-divider) 50%, transparent 100%)`,
|
|
47
49
|
},
|
|
48
50
|
"@keyframes skwave": {
|
|
49
51
|
'0%': { left: '-100%' },
|
package/Skeleton/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/Skeleton/index.tsx"],"sourcesContent":["\"use client\"\nimport React from 'react';\nimport { Tag, TagProps, TagComponentType } from '@xanui/core';\n\nexport type SkeletonProps<T extends TagComponentType = \"div\"> = TagProps<T> & {\n animation?: 'pulse' | 'wave' | 'none';\n loading?: boolean;\n}\n\nconst Skeleton = React.forwardRef(<T extends TagComponentType = \"div\">({ children, loading, color, animation, ...props }: SkeletonProps<T>, ref: React.Ref<any>) => {\n\n if (!children) loading = true\n\n if (loading) {\n animation ??= 'pulse'\n color ??= \
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/Skeleton/index.tsx"],"sourcesContent":["\"use client\"\nimport React from 'react';\nimport { Tag, TagProps, TagComponentType } from '@xanui/core';\n\nexport type SkeletonProps<T extends TagComponentType = \"div\"> = TagProps<T> & {\n animation?: 'pulse' | 'wave' | 'none';\n loading?: boolean;\n}\n\nconst Skeleton = React.forwardRef(<T extends TagComponentType = \"div\">({ children, loading, color, animation, ...props }: SkeletonProps<T>, ref: React.Ref<any>) => {\n\n if (!children) loading = true\n\n if (loading) {\n animation ??= 'pulse'\n color ??= 'surface'\n let sxr: any = {}\n switch (animation) {\n case 'pulse':\n sxr = {\n radius: 1,\n bgcolor: `${color}.divider`,\n width: \"100%\",\n animation: 'skpulse 1.5s infinite',\n \"@keyframes skpulse\": {\n '0%, 100%': {\n opacity: 1,\n },\n '50%': {\n opacity: 0.4,\n },\n }\n }\n break;\n case 'wave':\n sxr = {\n radius: 1,\n position: 'relative',\n overflow: 'hidden',\n bgcolor: `${color}.ghost`,\n \"&::after\": {\n content: '\"\"',\n position: 'absolute',\n top: 0,\n left: \"0%\",\n width: '100%',\n height: '100%',\n animation: 'skwave 2.5s infinite',\n background: `linear-gradient(90deg, transparent 0%, var(--color-${color}-divider) 50%, transparent 100%)`,\n },\n \"@keyframes skwave\": {\n '0%': { left: '-100%' },\n '100%': { left: '100%' }\n }\n }\n break;\n }\n return (\n <Tag\n {...props}\n baseClass='skeleton'\n ref={ref}\n sxr={sxr}\n />\n )\n }\n\n return children\n})\n\nexport default Skeleton\n\n"],"names":[],"mappings":";;;;;;;;AASA;AAAuE;AAEpE;;;;;;;AAOM;AACG;AACG;;AAEA;AACA;AACA;AACG;AACG;AACF;AACD;AACG;AACF;AACH;;;AAGP;AACG;AACG;AACA;AACA;;AAEA;AACG;AACA;AACA;AACA;AACA;AACA;AACA;;AAEF;AACD;AACG;AACA;AACF;;;;AAIV;;AAUH;AACH;;"}
|
package/Skeleton/index.js
CHANGED
|
@@ -10,12 +10,13 @@ const Skeleton = React.forwardRef((_a, ref) => {
|
|
|
10
10
|
loading = true;
|
|
11
11
|
if (loading) {
|
|
12
12
|
animation !== null && animation !== void 0 ? animation : (animation = 'pulse');
|
|
13
|
-
color !== null && color !== void 0 ? color : (color =
|
|
13
|
+
color !== null && color !== void 0 ? color : (color = 'surface');
|
|
14
14
|
let sxr = {};
|
|
15
15
|
switch (animation) {
|
|
16
16
|
case 'pulse':
|
|
17
17
|
sxr = {
|
|
18
|
-
|
|
18
|
+
radius: 1,
|
|
19
|
+
bgcolor: `${color}.divider`,
|
|
19
20
|
width: "100%",
|
|
20
21
|
animation: 'skpulse 1.5s infinite',
|
|
21
22
|
"@keyframes skpulse": {
|
|
@@ -30,9 +31,10 @@ const Skeleton = React.forwardRef((_a, ref) => {
|
|
|
30
31
|
break;
|
|
31
32
|
case 'wave':
|
|
32
33
|
sxr = {
|
|
34
|
+
radius: 1,
|
|
33
35
|
position: 'relative',
|
|
34
36
|
overflow: 'hidden',
|
|
35
|
-
bgcolor:
|
|
37
|
+
bgcolor: `${color}.ghost`,
|
|
36
38
|
"&::after": {
|
|
37
39
|
content: '""',
|
|
38
40
|
position: 'absolute',
|
|
@@ -40,8 +42,8 @@ const Skeleton = React.forwardRef((_a, ref) => {
|
|
|
40
42
|
left: "0%",
|
|
41
43
|
width: '100%',
|
|
42
44
|
height: '100%',
|
|
43
|
-
animation: 'skwave
|
|
44
|
-
background: `linear-gradient(90deg, transparent 0%, var(--color-divider
|
|
45
|
+
animation: 'skwave 2.5s infinite',
|
|
46
|
+
background: `linear-gradient(90deg, transparent 0%, var(--color-${color}-divider) 50%, transparent 100%)`,
|
|
45
47
|
},
|
|
46
48
|
"@keyframes skwave": {
|
|
47
49
|
'0%': { left: '-100%' },
|
package/Skeleton/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Skeleton/index.tsx"],"sourcesContent":["\"use client\"\nimport React from 'react';\nimport { Tag, TagProps, TagComponentType } from '@xanui/core';\n\nexport type SkeletonProps<T extends TagComponentType = \"div\"> = TagProps<T> & {\n animation?: 'pulse' | 'wave' | 'none';\n loading?: boolean;\n}\n\nconst Skeleton = React.forwardRef(<T extends TagComponentType = \"div\">({ children, loading, color, animation, ...props }: SkeletonProps<T>, ref: React.Ref<any>) => {\n\n if (!children) loading = true\n\n if (loading) {\n animation ??= 'pulse'\n color ??= \
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Skeleton/index.tsx"],"sourcesContent":["\"use client\"\nimport React from 'react';\nimport { Tag, TagProps, TagComponentType } from '@xanui/core';\n\nexport type SkeletonProps<T extends TagComponentType = \"div\"> = TagProps<T> & {\n animation?: 'pulse' | 'wave' | 'none';\n loading?: boolean;\n}\n\nconst Skeleton = React.forwardRef(<T extends TagComponentType = \"div\">({ children, loading, color, animation, ...props }: SkeletonProps<T>, ref: React.Ref<any>) => {\n\n if (!children) loading = true\n\n if (loading) {\n animation ??= 'pulse'\n color ??= 'surface'\n let sxr: any = {}\n switch (animation) {\n case 'pulse':\n sxr = {\n radius: 1,\n bgcolor: `${color}.divider`,\n width: \"100%\",\n animation: 'skpulse 1.5s infinite',\n \"@keyframes skpulse\": {\n '0%, 100%': {\n opacity: 1,\n },\n '50%': {\n opacity: 0.4,\n },\n }\n }\n break;\n case 'wave':\n sxr = {\n radius: 1,\n position: 'relative',\n overflow: 'hidden',\n bgcolor: `${color}.ghost`,\n \"&::after\": {\n content: '\"\"',\n position: 'absolute',\n top: 0,\n left: \"0%\",\n width: '100%',\n height: '100%',\n animation: 'skwave 2.5s infinite',\n background: `linear-gradient(90deg, transparent 0%, var(--color-${color}-divider) 50%, transparent 100%)`,\n },\n \"@keyframes skwave\": {\n '0%': { left: '-100%' },\n '100%': { left: '100%' }\n }\n }\n break;\n }\n return (\n <Tag\n {...props}\n baseClass='skeleton'\n ref={ref}\n sxr={sxr}\n />\n )\n }\n\n return children\n})\n\nexport default Skeleton\n\n"],"names":[],"mappings":";;;;;;AASA;AAAuE;AAEpE;;;;;;;AAOM;AACG;AACG;;AAEA;AACA;AACA;AACG;AACG;AACF;AACD;AACG;AACF;AACH;;;AAGP;AACG;AACG;AACA;AACA;;AAEA;AACG;AACA;AACA;AACA;AACA;AACA;AACA;;AAEF;AACD;AACG;AACA;AACF;;;;AAIV;;AAUH;AACH;;"}
|
package/Stack/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default from 'react';
|
|
2
2
|
import { TagComponentType, TagProps } from '@xanui/core';
|
|
3
3
|
|
|
4
4
|
type StackProps<T extends TagComponentType = "div"> = TagProps<T>;
|
|
5
|
-
declare const Stack:
|
|
5
|
+
declare const Stack: React__default.ForwardRefExoticComponent<Omit<StackProps<TagComponentType>, "ref"> & React__default.RefAttributes<any>>;
|
|
6
6
|
|
|
7
7
|
export { Stack as default };
|
|
8
8
|
export type { StackProps };
|
package/Switch/index.cjs
CHANGED
|
@@ -22,7 +22,7 @@ const Switch = React.forwardRef((props, ref) => {
|
|
|
22
22
|
_p.icon = icon;
|
|
23
23
|
const p = core.useBreakpointProps(_p);
|
|
24
24
|
size = (_a = p.size) !== null && _a !== void 0 ? _a : "medium";
|
|
25
|
-
color = (_b = p.color) !== null && _b !== void 0 ? _b : "
|
|
25
|
+
color = (_b = p.color) !== null && _b !== void 0 ? _b : "primary";
|
|
26
26
|
disabled = p.disabled;
|
|
27
27
|
trackSize = p.trackSize;
|
|
28
28
|
icon = p.icon;
|
|
@@ -55,7 +55,7 @@ const Switch = React.forwardRef((props, ref) => {
|
|
|
55
55
|
position: 'absolute',
|
|
56
56
|
top: "50%",
|
|
57
57
|
transform: "translateY(-50%)",
|
|
58
|
-
bgcolor: checked ? color :
|
|
58
|
+
bgcolor: checked ? color : 'surface.divider',
|
|
59
59
|
} })), jsxRuntime.jsx(core.Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.thumb, { baseClass: 'switch-thumb', sxr: {
|
|
60
60
|
transition: "all .25s",
|
|
61
61
|
width: height,
|
package/Switch/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/Switch/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { ReactElement, useState } from 'react';\nimport { Tag, TagProps, useBreakpointProps, UseColorTemplateColor, useInterface, useBreakpointPropsType } from '@xanui/core';\n\n\nexport type SwitchProps = Omit<TagProps<\"input\">, \"color\" | \"size\" | \"component\" | \"type\" | \"checked\"> & {\n checked?: boolean;\n size?: useBreakpointPropsType<number | \"small\" | \"medium\" | \"large\">;\n color?: useBreakpointPropsType<Omit<UseColorTemplateColor,
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/Switch/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { ReactElement, useState } from 'react';\nimport { Tag, TagProps, useBreakpointProps, UseColorTemplateColor, useInterface, useBreakpointPropsType } from '@xanui/core';\n\n\nexport type SwitchProps = Omit<TagProps<\"input\">, \"color\" | \"size\" | \"component\" | \"type\" | \"checked\"> & {\n checked?: boolean;\n size?: useBreakpointPropsType<number | \"small\" | \"medium\" | \"large\">;\n color?: useBreakpointPropsType<Omit<UseColorTemplateColor, 'surface'>>;\n disabled?: useBreakpointPropsType<boolean>;\n trackSize?: useBreakpointPropsType<number>;\n icon?: useBreakpointPropsType<ReactElement>;\n slotProps?: {\n thumb?: Omit<TagProps, 'children'>;\n track?: Omit<TagProps, 'children'>;\n }\n}\n\nconst Switch = React.forwardRef((props: SwitchProps, ref?: React.Ref<any>) => {\n let [{ size, checked, color, disabled, icon, onChange, trackSize, slotProps, ...rest }] = useInterface<any>(\"Switch\", props, {})\n const _p: any = {}\n if (size) _p.size = size\n if (color) _p.color = color\n if (disabled) _p.disabled = disabled\n if (trackSize) _p.trackSize = trackSize\n if (icon) _p.icon = icon\n const p: any = useBreakpointProps(_p)\n size = p.size ?? \"medium\"\n color = p.color ?? \"primary\"\n disabled = p.disabled\n trackSize = p.trackSize\n icon = p.icon\n\n const [c, set] = useState(false)\n checked ??= c\n\n onChange = onChange || (() => set(!c));\n\n let sizes: any = {\n small: 32,\n medium: 48,\n large: 60\n }\n let _size = sizes[size as any] || size\n\n let height = (_size / 2)\n trackSize ??= height + 4\n let isNormalSize = (height + 4) === trackSize\n let transform = checked ? \"92%\" : \"8%\"\n if (!isNormalSize) {\n transform = checked ? \"100%\" : \"-10%\"\n }\n\n return (\n <Tag\n disabled={disabled}\n sxr={{\n width: _size,\n height: height,\n position: \"relative\",\n cursor: \"pointer\",\n display: \"inline-block\"\n }}\n onClick={onChange}\n >\n <Tag\n {...slotProps?.track}\n baseClass='switch-track-bar'\n sxr={{\n width: _size,\n height: trackSize,\n borderRadius: height,\n position: 'absolute',\n top: \"50%\",\n transform: \"translateY(-50%)\",\n bgcolor: checked ? color : 'surface.divider',\n\n }}\n >\n </Tag>\n <Tag\n {...slotProps?.thumb}\n baseClass='switch-thumb'\n sxr={{\n transition: \"all .25s\",\n width: height,\n height: height,\n radius: height,\n bgcolor: \"#FFFFFF\",\n position: \"absolute\",\n top: \"50%\",\n border: isNormalSize ? 0 : 1,\n left: 0,\n transform: `translate(${transform}, -50%)`,\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\"\n }}\n >\n {\n icon\n }\n </Tag>\n <Tag\n {...rest}\n component='input'\n ref={ref}\n type=\"radio\"\n readOnly\n checked={checked}\n sxr={{\n display: \"none!important\"\n }}\n />\n </Tag>\n )\n})\n\nexport default Switch\n"],"names":[],"mappings":";;;;;;;;AAkBA;;AACI;;AAEA;AAAU;AACV;AAAW;AACX;AAAc;AACd;AAAe;AACf;AAAU;AACV;AACA;AACA;AACA;AACA;AACA;;;AAKA;AAEA;AACI;AACA;AACA;;;AAIJ;;;;;;;;AAYY;AACA;AACA;AACA;AACA;;AAQI;AACA;AACA;AACA;AACA;AACA;;AAGH;AAOG;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAeA;;AAKpB;;"}
|