x-ui-design 1.0.30 → 1.0.31-gamma.1
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/README.md +1 -22
- package/dist/{esm/types/components → components}/DatePicker/DatePicker.d.ts +1 -2
- package/dist/{esm/types/components → components}/DatePicker/RangePicker/RangePicker.d.ts +1 -2
- package/dist/{esm/types/components → components}/Dropdown/Dropdown.d.ts +1 -2
- package/dist/{esm/types/components → components}/Empty/Empty.d.ts +1 -2
- package/dist/{esm/types/components → components}/Form/Item/Item.d.ts +1 -2
- package/dist/components/Icons/Icons.d.ts +18 -0
- package/dist/components/Input/Input.d.ts +11 -0
- package/dist/{esm/types/components → components}/Input/Textarea/Textarea.d.ts +1 -2
- package/dist/{esm/types/components → components}/Popover/Popover.d.ts +1 -2
- package/dist/{esm/types/components → components}/Radio/Button/Button.d.ts +1 -2
- package/dist/{esm/types/components → components}/Radio/Group/Group.d.ts +1 -2
- package/dist/{esm/types/components → components}/Radio/Radio.d.ts +1 -2
- package/dist/{esm/types/components → components}/Result/Result.d.ts +1 -2
- package/dist/{esm/types/components → components}/Switch/Switch.d.ts +1 -2
- package/dist/{esm/types/components → components}/Upload/Upload.d.ts +1 -2
- package/dist/esm/types/index.d.ts +0 -56
- package/dist/index.d.ts +1 -150
- package/dist/index.esm.js +3433 -3863
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3395 -3825
- package/dist/index.js.map +1 -1
- package/package.json +22 -20
- package/.github/workflows/x-ui-design.yml +0 -14
- package/compile.sh +0 -15
- package/dist/esm/types/components/Icons/Icons.d.ts +0 -19
- package/dist/esm/types/components/Input/Input.d.ts +0 -16
- package/eslint.config.mjs +0 -16
- package/lib/components/Button/Button.tsx +0 -136
- package/lib/components/Button/index.ts +0 -1
- package/lib/components/Button/style.css +0 -197
- package/lib/components/Checkbox/Checkbox.tsx +0 -131
- package/lib/components/Checkbox/index.ts +0 -1
- package/lib/components/Checkbox/style.css +0 -95
- package/lib/components/ConditionalWrapper/index.tsx +0 -12
- package/lib/components/DatePicker/DatePicker.tsx +0 -526
- package/lib/components/DatePicker/RangePicker/RangePicker.tsx +0 -500
- package/lib/components/DatePicker/RangePicker/index.ts +0 -1
- package/lib/components/DatePicker/RangePicker/style.css +0 -434
- package/lib/components/DatePicker/TimePicker/TimePicker.tsx +0 -497
- package/lib/components/DatePicker/TimePicker/index.ts +0 -1
- package/lib/components/DatePicker/TimePicker/style.css +0 -197
- package/lib/components/DatePicker/index.ts +0 -1
- package/lib/components/DatePicker/style.css +0 -318
- package/lib/components/Dropdown/Dropdown.tsx +0 -234
- package/lib/components/Dropdown/index.ts +0 -1
- package/lib/components/Dropdown/style.css +0 -124
- package/lib/components/Empty/Empty.tsx +0 -45
- package/lib/components/Empty/index.ts +0 -1
- package/lib/components/Empty/style.css +0 -13
- package/lib/components/Form/Form.tsx +0 -130
- package/lib/components/Form/Item/Item.tsx +0 -294
- package/lib/components/Form/Item/index.ts +0 -1
- package/lib/components/Form/Item/style.css +0 -61
- package/lib/components/Form/index.ts +0 -1
- package/lib/components/Icons/Icons.tsx +0 -433
- package/lib/components/Icons/index.ts +0 -15
- package/lib/components/Input/Input.tsx +0 -228
- package/lib/components/Input/Textarea/Textarea.tsx +0 -110
- package/lib/components/Input/Textarea/index.ts +0 -1
- package/lib/components/Input/Textarea/style.css +0 -104
- package/lib/components/Input/index.ts +0 -1
- package/lib/components/Input/style.css +0 -137
- package/lib/components/Menu/Item/Item.tsx +0 -65
- package/lib/components/Menu/Menu.tsx +0 -261
- package/lib/components/Menu/SubMenu/SubMenu.tsx +0 -68
- package/lib/components/Menu/index.css +0 -145
- package/lib/components/Menu/index.ts +0 -1
- package/lib/components/Popover/Popover.tsx +0 -135
- package/lib/components/Popover/index.ts +0 -1
- package/lib/components/Popover/style.css +0 -82
- package/lib/components/Radio/Button/Button.tsx +0 -42
- package/lib/components/Radio/Button/index.ts +0 -1
- package/lib/components/Radio/Button/style.css +0 -43
- package/lib/components/Radio/Group/Group.tsx +0 -105
- package/lib/components/Radio/Group/index.ts +0 -1
- package/lib/components/Radio/Group/style.css +0 -53
- package/lib/components/Radio/Radio.tsx +0 -83
- package/lib/components/Radio/index.ts +0 -1
- package/lib/components/Radio/style.css +0 -73
- package/lib/components/Result/Result.tsx +0 -39
- package/lib/components/Result/index.ts +0 -1
- package/lib/components/Result/style.css +0 -173
- package/lib/components/Select/Option/Option.tsx +0 -49
- package/lib/components/Select/Option/index.ts +0 -1
- package/lib/components/Select/Option/style.css +0 -50
- package/lib/components/Select/Select.tsx +0 -935
- package/lib/components/Select/Tag/Tag.tsx +0 -43
- package/lib/components/Select/Tag/index.ts +0 -1
- package/lib/components/Select/Tag/style.css +0 -87
- package/lib/components/Select/index.ts +0 -1
- package/lib/components/Select/style.css +0 -186
- package/lib/components/Skeleton/Avatar/Avatar.tsx +0 -61
- package/lib/components/Skeleton/Avatar/index.ts +0 -1
- package/lib/components/Skeleton/Avatar/style.css +0 -27
- package/lib/components/Skeleton/Button/Button.tsx +0 -44
- package/lib/components/Skeleton/Button/index.ts +0 -1
- package/lib/components/Skeleton/Button/style.css +0 -50
- package/lib/components/Skeleton/Image/Image.tsx +0 -45
- package/lib/components/Skeleton/Image/index.ts +0 -1
- package/lib/components/Skeleton/Image/style.css +0 -23
- package/lib/components/Skeleton/Input/Input.tsx +0 -42
- package/lib/components/Skeleton/Input/index.ts +0 -1
- package/lib/components/Skeleton/Input/style.css +0 -56
- package/lib/components/Skeleton/Skeleton.tsx +0 -97
- package/lib/components/Skeleton/index.ts +0 -1
- package/lib/components/Skeleton/style.css +0 -84
- package/lib/components/Switch/Switch.tsx +0 -68
- package/lib/components/Switch/index.css +0 -50
- package/lib/components/Switch/index.ts +0 -1
- package/lib/components/Upload/Upload.tsx +0 -291
- package/lib/components/Upload/index.ts +0 -1
- package/lib/components/Upload/style.css +0 -151
- package/lib/global.d.ts +0 -1
- package/lib/helpers/flatten.ts +0 -26
- package/lib/helpers/index.ts +0 -52
- package/lib/helpers/mask.ts +0 -52
- package/lib/hooks/useForm.ts +0 -548
- package/lib/hooks/usePosition.ts +0 -206
- package/lib/hooks/useWatch.ts +0 -41
- package/lib/hooks/useWatchError.ts +0 -20
- package/lib/index.ts +0 -184
- package/lib/styles/global.css +0 -57
- package/lib/types/button.ts +0 -83
- package/lib/types/checkbox.ts +0 -32
- package/lib/types/datepicker.ts +0 -165
- package/lib/types/dropdown.ts +0 -41
- package/lib/types/empty.ts +0 -8
- package/lib/types/form.ts +0 -179
- package/lib/types/index.ts +0 -38
- package/lib/types/input.ts +0 -72
- package/lib/types/menu.ts +0 -55
- package/lib/types/popover.ts +0 -16
- package/lib/types/radio.ts +0 -69
- package/lib/types/result.ts +0 -22
- package/lib/types/select.ts +0 -126
- package/lib/types/skeleton.ts +0 -62
- package/lib/types/switch.ts +0 -22
- package/lib/types/upload.ts +0 -67
- package/lib/utils/index.ts +0 -37
- package/lib/utils/lazy.ts +0 -17
- package/next.config.ts +0 -7
- package/rollup.config.js +0 -71
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +0 -48
- package/src/app/layout.d.ts +0 -5
- package/src/app/layout.tsx +0 -16
- package/src/app/page.d.ts +0 -1
- package/src/app/page.tsx +0 -21
- package/tsconfig.json +0 -46
- /package/dist/{esm/types/components → components}/Button/Button.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Button/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Checkbox/Checkbox.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Checkbox/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/ConditionalWrapper/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/DatePicker/RangePicker/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/DatePicker/TimePicker/TimePicker.d.ts +0 -0
- /package/dist/{esm/types/components → components}/DatePicker/TimePicker/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/DatePicker/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Dropdown/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Empty/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Form/Form.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Form/Item/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Form/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Icons/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Input/Textarea/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Input/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Menu/Item/Item.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Menu/Menu.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Menu/SubMenu/SubMenu.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Menu/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Popover/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Radio/Button/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Radio/Group/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Radio/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Result/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Select/Option/Option.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Select/Option/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Select/Select.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Select/Tag/Tag.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Select/Tag/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Select/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/Avatar/Avatar.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/Avatar/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/Button/Button.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/Button/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/Image/Image.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/Image/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/Input/Input.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/Input/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/Skeleton.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Switch/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Upload/index.d.ts +0 -0
- /package/dist/{esm/types/helpers → helpers}/flatten.d.ts +0 -0
- /package/dist/{esm/types/helpers → helpers}/index.d.ts +0 -0
- /package/dist/{esm/types/helpers → helpers}/mask.d.ts +0 -0
- /package/dist/{esm/types/hooks → hooks}/useForm.d.ts +0 -0
- /package/dist/{esm/types/hooks → hooks}/usePosition.d.ts +0 -0
- /package/dist/{esm/types/hooks → hooks}/useWatch.d.ts +0 -0
- /package/dist/{esm/types/hooks → hooks}/useWatchError.d.ts +0 -0
- /package/dist/{esm/types/types → types}/button.d.ts +0 -0
- /package/dist/{esm/types/types → types}/checkbox.d.ts +0 -0
- /package/dist/{esm/types/types → types}/datepicker.d.ts +0 -0
- /package/dist/{esm/types/types → types}/dropdown.d.ts +0 -0
- /package/dist/{esm/types/types → types}/empty.d.ts +0 -0
- /package/dist/{esm/types/types → types}/form.d.ts +0 -0
- /package/dist/{esm/types/types → types}/index.d.ts +0 -0
- /package/dist/{esm/types/types → types}/input.d.ts +0 -0
- /package/dist/{esm/types/types → types}/menu.d.ts +0 -0
- /package/dist/{esm/types/types → types}/popover.d.ts +0 -0
- /package/dist/{esm/types/types → types}/radio.d.ts +0 -0
- /package/dist/{esm/types/types → types}/result.d.ts +0 -0
- /package/dist/{esm/types/types → types}/select.d.ts +0 -0
- /package/dist/{esm/types/types → types}/skeleton.d.ts +0 -0
- /package/dist/{esm/types/types → types}/switch.d.ts +0 -0
- /package/dist/{esm/types/types → types}/upload.d.ts +0 -0
- /package/dist/{esm/types/utils → utils}/index.d.ts +0 -0
- /package/dist/{esm/types/utils → utils}/lazy.d.ts +0 -0
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import React, { ReactElement } from 'react';
|
|
2
|
-
import { clsx, createArray } from '../../helpers';
|
|
3
|
-
import { SkeletonProps } from '../../types/skeleton';
|
|
4
|
-
import { prefixClsSkeleton } from '../../utils';
|
|
5
|
-
import { SkeletonButton } from './Button';
|
|
6
|
-
import { SkeletonAvatar } from './Avatar';
|
|
7
|
-
import { GET_AVATAR_SKELETON_PROPS } from './Avatar/Avatar';
|
|
8
|
-
import { SkeletonImage } from './Image';
|
|
9
|
-
import { SkeletonInput } from './Input';
|
|
10
|
-
import './style.css';
|
|
11
|
-
|
|
12
|
-
const PARAGRAPH_AVATAR_ROWS = 2;
|
|
13
|
-
const PARAGRAPH_DEFAULT_ROWS = 3;
|
|
14
|
-
|
|
15
|
-
const SkeletonComponent = ({
|
|
16
|
-
prefixCls = prefixClsSkeleton,
|
|
17
|
-
active,
|
|
18
|
-
className,
|
|
19
|
-
style,
|
|
20
|
-
avatar,
|
|
21
|
-
paragraph,
|
|
22
|
-
round,
|
|
23
|
-
title,
|
|
24
|
-
teamLogo = true
|
|
25
|
-
}: SkeletonProps): ReactElement => {
|
|
26
|
-
const GET_TITLE_SKELETON_PROPS =
|
|
27
|
-
typeof title !== 'boolean'
|
|
28
|
-
? {
|
|
29
|
-
style: { width: title?.width, ...title?.style },
|
|
30
|
-
className: title?.className || ''
|
|
31
|
-
}
|
|
32
|
-
: {};
|
|
33
|
-
|
|
34
|
-
const PARAGRAPH_ROWS = avatar
|
|
35
|
-
? PARAGRAPH_AVATAR_ROWS
|
|
36
|
-
: PARAGRAPH_DEFAULT_ROWS;
|
|
37
|
-
|
|
38
|
-
const HAS_PHARAGRAPH =
|
|
39
|
-
typeof paragraph === 'boolean' || !paragraph
|
|
40
|
-
? PARAGRAPH_ROWS
|
|
41
|
-
: paragraph?.rows ?? PARAGRAPH_ROWS;
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<div
|
|
45
|
-
className={clsx([
|
|
46
|
-
prefixCls,
|
|
47
|
-
{
|
|
48
|
-
[`${prefixCls}__withAvatar`]: avatar,
|
|
49
|
-
[`${prefixCls}-active`]: active,
|
|
50
|
-
[`${prefixCls}-round`]: round
|
|
51
|
-
},
|
|
52
|
-
className
|
|
53
|
-
])}
|
|
54
|
-
style={style}
|
|
55
|
-
>
|
|
56
|
-
{avatar && teamLogo && (
|
|
57
|
-
<div className={`${prefixCls}__header`}>
|
|
58
|
-
<SkeletonAvatar {...GET_AVATAR_SKELETON_PROPS(avatar)} />
|
|
59
|
-
</div>
|
|
60
|
-
)}
|
|
61
|
-
|
|
62
|
-
<div className={`${prefixCls}-content`}>
|
|
63
|
-
<h3
|
|
64
|
-
className={clsx([
|
|
65
|
-
`${prefixCls}-title ${GET_TITLE_SKELETON_PROPS.className}`,
|
|
66
|
-
{ [`${prefixCls}-title-avatar`]: avatar }
|
|
67
|
-
])}
|
|
68
|
-
style={GET_TITLE_SKELETON_PROPS.style}
|
|
69
|
-
/>
|
|
70
|
-
|
|
71
|
-
{paragraph !== false && (
|
|
72
|
-
<ul
|
|
73
|
-
className={`${prefixCls}-paragraph`}
|
|
74
|
-
style={{
|
|
75
|
-
...(typeof paragraph !== 'boolean' && paragraph
|
|
76
|
-
? paragraph.style
|
|
77
|
-
: {})
|
|
78
|
-
}}
|
|
79
|
-
>
|
|
80
|
-
{createArray(HAS_PHARAGRAPH).map(key => (
|
|
81
|
-
<li key={key}></li>
|
|
82
|
-
))}
|
|
83
|
-
</ul>
|
|
84
|
-
)}
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const Skeleton = Object.assign(SkeletonComponent, {
|
|
91
|
-
Image: SkeletonImage,
|
|
92
|
-
Input: SkeletonInput,
|
|
93
|
-
Avatar: SkeletonAvatar,
|
|
94
|
-
Button: SkeletonButton
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
export default Skeleton
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Skeleton } from './Skeleton'
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
@keyframes xUi-skeleton-loading {
|
|
2
|
-
0% {
|
|
3
|
-
background-position: 100% 50%;
|
|
4
|
-
}
|
|
5
|
-
100% {
|
|
6
|
-
background-position: 0 50%;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.xUi-skeleton {
|
|
11
|
-
width: 100%;
|
|
12
|
-
display: table;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.xUi-skeleton__withAvatar {
|
|
16
|
-
display: flex;
|
|
17
|
-
gap: 12px;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.xUi-skeleton-content {
|
|
21
|
-
width: 100%;
|
|
22
|
-
display: table-cell;
|
|
23
|
-
vertical-align: top;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.xUi-skeleton__header {
|
|
27
|
-
display: table-cell;
|
|
28
|
-
vertical-align: top;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.xUi-skeleton-title {
|
|
32
|
-
width: 38%;
|
|
33
|
-
height: 16px;
|
|
34
|
-
margin-top: 16px;
|
|
35
|
-
border-radius: 4px;
|
|
36
|
-
background: rgba(190, 190, 190, 0.2);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.xUi-skeleton-title-avatar {
|
|
40
|
-
width: 100%;
|
|
41
|
-
margin-top: 12px;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.xUi-skeleton-title + .xUi-skeleton-paragraph {
|
|
45
|
-
margin-top: 24px;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.xUi-skeleton-paragraph {
|
|
49
|
-
padding: 0;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.xUi-skeleton-paragraph li {
|
|
53
|
-
width: 100%;
|
|
54
|
-
height: 16px;
|
|
55
|
-
list-style: none;
|
|
56
|
-
border-radius: 4px;
|
|
57
|
-
background: rgba(190, 190, 190, 0.2);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.xUi-skeleton-paragraph li + li {
|
|
61
|
-
margin-top: 16px;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.xUi-skeleton-paragraph li:last-child:not(:first-child) {
|
|
65
|
-
width: 61%;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.xUi-skeleton-active .xUi-skeleton-title,
|
|
69
|
-
.xUi-skeleton-active .xUi-skeleton-paragraph > li {
|
|
70
|
-
background: linear-gradient(
|
|
71
|
-
90deg,
|
|
72
|
-
rgba(190, 190, 190, 0.2) 25%,
|
|
73
|
-
rgba(129, 129, 129, 0.24) 37%,
|
|
74
|
-
rgba(190, 190, 190, 0.2) 63%
|
|
75
|
-
);
|
|
76
|
-
background-size: 400% 100%;
|
|
77
|
-
animation: xUi-skeleton-loading 1.4s ease infinite;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.xUi-skeleton-round .xUi-skeleton-title,
|
|
81
|
-
.xUi-skeleton-round .xUi-skeleton-content,
|
|
82
|
-
.xUi-skeleton-round .xUi-skeleton-paragraph > li {
|
|
83
|
-
border-radius: 100px;
|
|
84
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import React, { MouseEvent, useEffect, useState } from 'react';
|
|
2
|
-
import { SyntheticBaseEvent } from '../../types';
|
|
3
|
-
import { SwitchProps } from '../../types/switch';
|
|
4
|
-
import { prefixClsSwitch, prefixClsSwitchV3 } from '../../utils';
|
|
5
|
-
import './index.css';
|
|
6
|
-
|
|
7
|
-
const Switch = ({
|
|
8
|
-
prefixCls = prefixClsSwitch,
|
|
9
|
-
prefixClsV3 = prefixClsSwitchV3,
|
|
10
|
-
checked,
|
|
11
|
-
onChange,
|
|
12
|
-
onClick,
|
|
13
|
-
disabled = false,
|
|
14
|
-
className = '',
|
|
15
|
-
style = {},
|
|
16
|
-
defaultChecked,
|
|
17
|
-
value,
|
|
18
|
-
controlled = false
|
|
19
|
-
}: SwitchProps) => {
|
|
20
|
-
const isChecked = checked !== undefined ? checked : defaultChecked || value;
|
|
21
|
-
const [internalChecked, setInternalChecked] = useState(isChecked);
|
|
22
|
-
|
|
23
|
-
const handleClick = (
|
|
24
|
-
e: MouseEvent<HTMLInputElement> & SyntheticBaseEvent
|
|
25
|
-
) => {
|
|
26
|
-
e.stopPropagation();
|
|
27
|
-
|
|
28
|
-
if (disabled) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!controlled) {
|
|
33
|
-
setInternalChecked(!internalChecked);
|
|
34
|
-
e.target.value = !internalChecked;
|
|
35
|
-
} else {
|
|
36
|
-
e.target.value = !checked;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
onClick?.(e.target.value);
|
|
40
|
-
onChange?.(e.target.value);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (checked !== undefined) {
|
|
45
|
-
setInternalChecked(checked);
|
|
46
|
-
}
|
|
47
|
-
}, [checked]);
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<div
|
|
51
|
-
className={`${prefixCls}-wrapper ${prefixClsV3}-wrapper ${className} ${disabled ? `${prefixCls}__disabled ${prefixClsV3}__disabled` : ''}`}
|
|
52
|
-
style={style}
|
|
53
|
-
>
|
|
54
|
-
<div
|
|
55
|
-
tabIndex={0}
|
|
56
|
-
role="button"
|
|
57
|
-
className={`${prefixCls} ${prefixClsV3} ${internalChecked ? `${prefixCls}__checked ${prefixClsV3}__checked` : ''}`}
|
|
58
|
-
onClick={handleClick}
|
|
59
|
-
>
|
|
60
|
-
<div className={`${prefixCls}__slider ${prefixClsV3}__slider`}></div>
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
Switch.displayName = 'Switch';
|
|
67
|
-
|
|
68
|
-
export default Switch
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
.xUi-switch {
|
|
2
|
-
border: 0;
|
|
3
|
-
border-radius: 100px;
|
|
4
|
-
box-sizing: border-box;
|
|
5
|
-
color: #000000d9;
|
|
6
|
-
cursor: pointer;
|
|
7
|
-
display: inline-block;
|
|
8
|
-
font-size: 14px;
|
|
9
|
-
font-variant: tabular-nums;
|
|
10
|
-
height: 22px;
|
|
11
|
-
list-style: none;
|
|
12
|
-
margin: 0;
|
|
13
|
-
min-width: 44px;
|
|
14
|
-
padding: 0;
|
|
15
|
-
position: relative;
|
|
16
|
-
transition: all 0.2s;
|
|
17
|
-
user-select: none;
|
|
18
|
-
vertical-align: middle;
|
|
19
|
-
background-color: var(--xui-color-disabled);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.xUi-switch-wrapper {
|
|
23
|
-
&:has([tabindex="0"]:focus-visible) {
|
|
24
|
-
border-color: var(--xui-primary-color);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.xUi-switch.xUi-switch__disabled {
|
|
29
|
-
opacity: 0.5;
|
|
30
|
-
pointer-events: none;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.xUi-switch .xUi-switch__slider {
|
|
34
|
-
position: absolute;
|
|
35
|
-
height: 18px;
|
|
36
|
-
left: 2px;
|
|
37
|
-
top: 2px;
|
|
38
|
-
width: 18px;
|
|
39
|
-
border-radius: 50%;
|
|
40
|
-
background-color: white;
|
|
41
|
-
transition: transform 0.3s;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.xUi-switch__checked .xUi-switch__slider {
|
|
45
|
-
transform: translateX(21px);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.xUi-switch__checked {
|
|
49
|
-
background-color: var(--xui-primary-color);
|
|
50
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Switch } from './Switch'
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import React, { useRef, useState } from 'react';
|
|
4
|
-
import { clsx } from '../../helpers';
|
|
5
|
-
import { RuleType } from '../../types';
|
|
6
|
-
import {
|
|
7
|
-
RcFile,
|
|
8
|
-
UploadChangeParam,
|
|
9
|
-
UploadFile,
|
|
10
|
-
UploadProps
|
|
11
|
-
} from '../../types/upload';
|
|
12
|
-
import { prefixClsUpload, prefixClsUploadV3 } from '../../utils';
|
|
13
|
-
import './style.css';
|
|
14
|
-
import { StampleIcon, TrashIcon } from '../Icons/Icons';
|
|
15
|
-
|
|
16
|
-
const IMAGE_SIZE = 40;
|
|
17
|
-
const IMAGE_PROGRESS_PERCENT = 100;
|
|
18
|
-
|
|
19
|
-
const Upload = ({
|
|
20
|
-
prefixCls = prefixClsUpload,
|
|
21
|
-
prefixClsV3 = prefixClsUploadV3,
|
|
22
|
-
multiple = false,
|
|
23
|
-
style,
|
|
24
|
-
className,
|
|
25
|
-
onChange,
|
|
26
|
-
action,
|
|
27
|
-
name = 'file',
|
|
28
|
-
method = 'POST',
|
|
29
|
-
headers,
|
|
30
|
-
directory,
|
|
31
|
-
beforeUpload,
|
|
32
|
-
rootClassName,
|
|
33
|
-
onRemove,
|
|
34
|
-
disabled,
|
|
35
|
-
withCredentials,
|
|
36
|
-
openFileDialogOnClick = true,
|
|
37
|
-
maxCount,
|
|
38
|
-
fileList: controlledFileList,
|
|
39
|
-
customRequest,
|
|
40
|
-
accept,
|
|
41
|
-
listType = 'text',
|
|
42
|
-
showUploadList = true,
|
|
43
|
-
children,
|
|
44
|
-
noStyle,
|
|
45
|
-
defaultFileList
|
|
46
|
-
}: UploadProps) => {
|
|
47
|
-
const uploadRef = useRef<HTMLInputElement>(null);
|
|
48
|
-
const [fileList, setFileList] = useState<UploadFile<RuleType>[]>(() =>
|
|
49
|
-
(controlledFileList || defaultFileList || []).map((file, idx) => ({
|
|
50
|
-
...file,
|
|
51
|
-
uid: file.uid || `${Date.now()}-${idx}`,
|
|
52
|
-
status: file.status || 'done',
|
|
53
|
-
percent: file.percent || IMAGE_PROGRESS_PERCENT
|
|
54
|
-
}))
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
const updateFileList = (newList: UploadFile<RuleType>[]) => {
|
|
58
|
-
setFileList(newList);
|
|
59
|
-
|
|
60
|
-
if (onChange) {
|
|
61
|
-
onChange({
|
|
62
|
-
fileList: newList,
|
|
63
|
-
file: newList[0] || {}
|
|
64
|
-
} as UploadChangeParam);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const handleFileChange = async (
|
|
69
|
-
event: React.ChangeEvent<HTMLInputElement>
|
|
70
|
-
) => {
|
|
71
|
-
const rawFiles: File[] = Array.from(event.target.files || []);
|
|
72
|
-
let uploadFiles: UploadFile<RuleType>[] = rawFiles.map((file, i) => ({
|
|
73
|
-
uid: `${Date.now()}-${i}`,
|
|
74
|
-
name: file.name,
|
|
75
|
-
size: file.size,
|
|
76
|
-
type: file.type,
|
|
77
|
-
status: 'uploading',
|
|
78
|
-
percent: 0,
|
|
79
|
-
originFileObj: file
|
|
80
|
-
}));
|
|
81
|
-
|
|
82
|
-
if (beforeUpload) {
|
|
83
|
-
const filtered: UploadFile<RuleType>[] = [];
|
|
84
|
-
|
|
85
|
-
for (let i = 0; i < uploadFiles.length; i++) {
|
|
86
|
-
const file = uploadFiles[i].originFileObj as RcFile;
|
|
87
|
-
const result = await beforeUpload(file, rawFiles);
|
|
88
|
-
|
|
89
|
-
if (result === false) {
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
filtered.push(uploadFiles[i]);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
uploadFiles = filtered;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const newList = (
|
|
100
|
-
multiple ? [...fileList, ...uploadFiles] : uploadFiles
|
|
101
|
-
).slice(0, maxCount);
|
|
102
|
-
|
|
103
|
-
updateFileList(newList);
|
|
104
|
-
|
|
105
|
-
uploadFiles.forEach(file => {
|
|
106
|
-
const rcFile = file.originFileObj as RcFile;
|
|
107
|
-
|
|
108
|
-
const updateProgress = (percent: number) => {
|
|
109
|
-
file.percent = percent;
|
|
110
|
-
updateFileList([...newList]);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const markSuccess = () => {
|
|
114
|
-
file.status = 'done';
|
|
115
|
-
file.percent = 100;
|
|
116
|
-
updateFileList([...newList]);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const markError = () => {
|
|
120
|
-
file.status = 'error';
|
|
121
|
-
updateFileList([...newList]);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
if (customRequest) {
|
|
125
|
-
customRequest({
|
|
126
|
-
file: rcFile,
|
|
127
|
-
onSuccess: markSuccess,
|
|
128
|
-
onError: markError,
|
|
129
|
-
onProgress: event => {
|
|
130
|
-
const percent = Math.round(
|
|
131
|
-
(event.loaded / (event.total || event.loaded)) *
|
|
132
|
-
IMAGE_PROGRESS_PERCENT
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
updateProgress(percent);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
} else if (typeof action === 'string') {
|
|
139
|
-
const formData = new FormData();
|
|
140
|
-
formData.append(name, rcFile);
|
|
141
|
-
|
|
142
|
-
fetch(action, {
|
|
143
|
-
method,
|
|
144
|
-
body: formData,
|
|
145
|
-
headers,
|
|
146
|
-
credentials: withCredentials ? 'include' : 'same-origin'
|
|
147
|
-
})
|
|
148
|
-
.then(res => {
|
|
149
|
-
if (!res.ok) {
|
|
150
|
-
throw new Error('Upload failed');
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return res.json();
|
|
154
|
-
})
|
|
155
|
-
.then(markSuccess)
|
|
156
|
-
.catch(markError);
|
|
157
|
-
} else if (typeof action === 'function') {
|
|
158
|
-
action(rcFile);
|
|
159
|
-
markSuccess();
|
|
160
|
-
} else {
|
|
161
|
-
markSuccess();
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
if (uploadRef.current) {
|
|
166
|
-
uploadRef.current.value = '';
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
const handleRemove = (uid: string) => {
|
|
171
|
-
const filtered: UploadFile<RuleType>[] = [];
|
|
172
|
-
|
|
173
|
-
let removedFile: UploadFile<RuleType> | undefined = undefined;
|
|
174
|
-
|
|
175
|
-
fileList.forEach(file => {
|
|
176
|
-
if (file.uid !== uid) {
|
|
177
|
-
filtered.push(file);
|
|
178
|
-
} else {
|
|
179
|
-
removedFile = file;
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
updateFileList(filtered);
|
|
184
|
-
|
|
185
|
-
if (removedFile) {
|
|
186
|
-
onRemove?.(removedFile);
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
const handleClick = () => {
|
|
191
|
-
if (!disabled && openFileDialogOnClick && uploadRef.current) {
|
|
192
|
-
uploadRef.current.click();
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
return (
|
|
197
|
-
<div
|
|
198
|
-
className={clsx([
|
|
199
|
-
`${prefixCls}-wrapper ${prefixClsV3}-wrapper`,
|
|
200
|
-
className,
|
|
201
|
-
rootClassName,
|
|
202
|
-
{
|
|
203
|
-
noStyle: noStyle,
|
|
204
|
-
[`${prefixCls}-disabled`]: disabled,
|
|
205
|
-
[`${prefixClsV3}-disabled`]: disabled
|
|
206
|
-
}
|
|
207
|
-
])}
|
|
208
|
-
style={style}
|
|
209
|
-
>
|
|
210
|
-
<span
|
|
211
|
-
className={clsx([`${prefixCls}`, `${prefixCls}-${listType}`, `${prefixClsV3}`, `${prefixClsV3}-${listType}`])}
|
|
212
|
-
onClick={handleClick}
|
|
213
|
-
>
|
|
214
|
-
{children}
|
|
215
|
-
<input
|
|
216
|
-
type="file"
|
|
217
|
-
ref={uploadRef}
|
|
218
|
-
accept={accept}
|
|
219
|
-
multiple={multiple}
|
|
220
|
-
onChange={handleFileChange}
|
|
221
|
-
className={`${prefixCls}-input ${prefixClsV3}-input`}
|
|
222
|
-
disabled={disabled}
|
|
223
|
-
{...(directory
|
|
224
|
-
? {
|
|
225
|
-
directory: true,
|
|
226
|
-
webkitdirectory: true
|
|
227
|
-
}
|
|
228
|
-
: {})}
|
|
229
|
-
/>
|
|
230
|
-
</span>
|
|
231
|
-
|
|
232
|
-
{showUploadList && fileList.length > 0 && (
|
|
233
|
-
<ul className={`${prefixCls}-list ${prefixCls}-list-${listType} ${prefixClsV3}-list ${prefixClsV3}-list-${listType}`}>
|
|
234
|
-
{fileList.map(file => (
|
|
235
|
-
<li
|
|
236
|
-
key={file.uid}
|
|
237
|
-
className={`${prefixCls}-item ${prefixCls}-item-${file.status} ${prefixClsV3}-item ${prefixClsV3}-item-${file.status}`}
|
|
238
|
-
>
|
|
239
|
-
<span
|
|
240
|
-
className={`${prefixCls}-remove ${prefixClsV3}-remove`}
|
|
241
|
-
onClick={() => handleRemove(file.uid)}
|
|
242
|
-
>
|
|
243
|
-
{listType === 'picture' && (file.originFileObj || file.url) ? (
|
|
244
|
-
// eslint-disable-next-line @next/next/no-img-element
|
|
245
|
-
<img
|
|
246
|
-
width={IMAGE_SIZE}
|
|
247
|
-
height={IMAGE_SIZE}
|
|
248
|
-
alt={file.name}
|
|
249
|
-
src={file.url || URL.createObjectURL(file.originFileObj)}
|
|
250
|
-
className={`${prefixCls}-item-thumbnail ${prefixClsV3}-item-thumbnail`}
|
|
251
|
-
/>
|
|
252
|
-
) : (
|
|
253
|
-
<StampleIcon />
|
|
254
|
-
)}
|
|
255
|
-
</span>
|
|
256
|
-
<div style={{ width: '100%' }}>
|
|
257
|
-
<div
|
|
258
|
-
className={`${prefixCls}-item-title ${prefixClsV3}-item-title`}
|
|
259
|
-
style={{
|
|
260
|
-
...(file.status === 'uploading' ? { marginBottom: 12 } : {})
|
|
261
|
-
}}
|
|
262
|
-
>
|
|
263
|
-
<span
|
|
264
|
-
className={`${prefixCls}-item-remove-icon ${prefixClsV3}-item-remove-icon`}
|
|
265
|
-
onClick={() => handleRemove(file.uid)}
|
|
266
|
-
style={{ cursor: 'pointer', marginLeft: 'auto' }}
|
|
267
|
-
role="button"
|
|
268
|
-
aria-label="Remove file"
|
|
269
|
-
>
|
|
270
|
-
<TrashIcon />
|
|
271
|
-
</span>
|
|
272
|
-
</div>
|
|
273
|
-
{file.status === 'uploading' && (
|
|
274
|
-
<>
|
|
275
|
-
<div className={`${prefixCls}-item-progress-line ${prefixClsV3}-item-progress-line`} />
|
|
276
|
-
<div
|
|
277
|
-
className={`${prefixCls}-item-progress-line-percent ${prefixClsV3}-item-progress-line-percent`}
|
|
278
|
-
style={{ width: `${file.percent}%` }}
|
|
279
|
-
/>
|
|
280
|
-
</>
|
|
281
|
-
)}
|
|
282
|
-
</div>
|
|
283
|
-
</li>
|
|
284
|
-
))}
|
|
285
|
-
</ul>
|
|
286
|
-
)}
|
|
287
|
-
</div>
|
|
288
|
-
);
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
export default Upload;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Upload } from '../Upload/Upload'
|