x-ui-design 1.0.31-gamma.1 → 1.0.31

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.
Files changed (219) hide show
  1. package/.github/workflows/x-ui-design.yml +14 -0
  2. package/README.md +22 -1
  3. package/compile.sh +15 -0
  4. package/dist/{components → esm/types/components}/DatePicker/DatePicker.d.ts +2 -1
  5. package/dist/{components → esm/types/components}/DatePicker/RangePicker/RangePicker.d.ts +2 -1
  6. package/dist/{components → esm/types/components}/Dropdown/Dropdown.d.ts +2 -1
  7. package/dist/{components → esm/types/components}/Empty/Empty.d.ts +2 -1
  8. package/dist/{components → esm/types/components}/Form/Item/Item.d.ts +2 -1
  9. package/dist/esm/types/components/Icons/Icons.d.ts +19 -0
  10. package/dist/esm/types/components/Input/Input.d.ts +16 -0
  11. package/dist/{components → esm/types/components}/Input/Textarea/Textarea.d.ts +2 -1
  12. package/dist/{components → esm/types/components}/Popover/Popover.d.ts +2 -1
  13. package/dist/{components → esm/types/components}/Radio/Button/Button.d.ts +2 -1
  14. package/dist/{components → esm/types/components}/Radio/Group/Group.d.ts +2 -1
  15. package/dist/{components → esm/types/components}/Radio/Radio.d.ts +2 -1
  16. package/dist/{components → esm/types/components}/Result/Result.d.ts +2 -1
  17. package/dist/{components → esm/types/components}/Switch/Switch.d.ts +2 -1
  18. package/dist/{components → esm/types/components}/Upload/Upload.d.ts +2 -1
  19. package/dist/esm/types/index.d.ts +56 -0
  20. package/dist/index.d.ts +150 -1
  21. package/dist/index.esm.js +4209 -3779
  22. package/dist/index.esm.js.map +1 -1
  23. package/dist/index.js +4325 -3895
  24. package/dist/index.js.map +1 -1
  25. package/eslint.config.mjs +16 -0
  26. package/lib/components/Button/Button.tsx +136 -0
  27. package/lib/components/Button/index.ts +1 -0
  28. package/lib/components/Button/style.css +197 -0
  29. package/lib/components/Checkbox/Checkbox.tsx +131 -0
  30. package/lib/components/Checkbox/index.ts +1 -0
  31. package/lib/components/Checkbox/style.css +95 -0
  32. package/lib/components/ConditionalWrapper/index.tsx +12 -0
  33. package/lib/components/DatePicker/DatePicker.tsx +526 -0
  34. package/lib/components/DatePicker/RangePicker/RangePicker.tsx +500 -0
  35. package/lib/components/DatePicker/RangePicker/index.ts +1 -0
  36. package/lib/components/DatePicker/RangePicker/style.css +434 -0
  37. package/lib/components/DatePicker/TimePicker/TimePicker.tsx +497 -0
  38. package/lib/components/DatePicker/TimePicker/index.ts +1 -0
  39. package/lib/components/DatePicker/TimePicker/style.css +197 -0
  40. package/lib/components/DatePicker/index.ts +1 -0
  41. package/lib/components/DatePicker/style.css +318 -0
  42. package/lib/components/Dropdown/Dropdown.tsx +234 -0
  43. package/lib/components/Dropdown/index.ts +1 -0
  44. package/lib/components/Dropdown/style.css +124 -0
  45. package/lib/components/Empty/Empty.tsx +45 -0
  46. package/lib/components/Empty/index.ts +1 -0
  47. package/lib/components/Empty/style.css +13 -0
  48. package/lib/components/Form/Form.tsx +130 -0
  49. package/lib/components/Form/Item/Item.tsx +294 -0
  50. package/lib/components/Form/Item/index.ts +1 -0
  51. package/lib/components/Form/Item/style.css +61 -0
  52. package/lib/components/Form/index.ts +1 -0
  53. package/lib/components/Icons/Icons.tsx +433 -0
  54. package/lib/components/Icons/index.ts +15 -0
  55. package/lib/components/Input/Input.tsx +228 -0
  56. package/lib/components/Input/Textarea/Textarea.tsx +110 -0
  57. package/lib/components/Input/Textarea/index.ts +1 -0
  58. package/lib/components/Input/Textarea/style.css +104 -0
  59. package/lib/components/Input/index.ts +1 -0
  60. package/lib/components/Input/style.css +137 -0
  61. package/lib/components/Menu/Item/Item.tsx +65 -0
  62. package/lib/components/Menu/Menu.tsx +261 -0
  63. package/lib/components/Menu/SubMenu/SubMenu.tsx +68 -0
  64. package/lib/components/Menu/index.css +145 -0
  65. package/lib/components/Menu/index.ts +1 -0
  66. package/lib/components/Popover/Popover.tsx +135 -0
  67. package/lib/components/Popover/index.ts +1 -0
  68. package/lib/components/Popover/style.css +82 -0
  69. package/lib/components/Radio/Button/Button.tsx +42 -0
  70. package/lib/components/Radio/Button/index.ts +1 -0
  71. package/lib/components/Radio/Button/style.css +43 -0
  72. package/lib/components/Radio/Group/Group.tsx +105 -0
  73. package/lib/components/Radio/Group/index.ts +1 -0
  74. package/lib/components/Radio/Group/style.css +53 -0
  75. package/lib/components/Radio/Radio.tsx +83 -0
  76. package/lib/components/Radio/index.ts +1 -0
  77. package/lib/components/Radio/style.css +73 -0
  78. package/lib/components/Result/Result.tsx +39 -0
  79. package/lib/components/Result/index.ts +1 -0
  80. package/lib/components/Result/style.css +173 -0
  81. package/lib/components/Select/Option/Option.tsx +49 -0
  82. package/lib/components/Select/Option/index.ts +1 -0
  83. package/lib/components/Select/Option/style.css +50 -0
  84. package/lib/components/Select/Select.tsx +935 -0
  85. package/lib/components/Select/Tag/Tag.tsx +43 -0
  86. package/lib/components/Select/Tag/index.ts +1 -0
  87. package/lib/components/Select/Tag/style.css +87 -0
  88. package/lib/components/Select/index.ts +1 -0
  89. package/lib/components/Select/style.css +186 -0
  90. package/lib/components/Skeleton/Avatar/Avatar.tsx +61 -0
  91. package/lib/components/Skeleton/Avatar/index.ts +1 -0
  92. package/lib/components/Skeleton/Avatar/style.css +27 -0
  93. package/lib/components/Skeleton/Button/Button.tsx +44 -0
  94. package/lib/components/Skeleton/Button/index.ts +1 -0
  95. package/lib/components/Skeleton/Button/style.css +50 -0
  96. package/lib/components/Skeleton/Image/Image.tsx +45 -0
  97. package/lib/components/Skeleton/Image/index.ts +1 -0
  98. package/lib/components/Skeleton/Image/style.css +23 -0
  99. package/lib/components/Skeleton/Input/Input.tsx +42 -0
  100. package/lib/components/Skeleton/Input/index.ts +1 -0
  101. package/lib/components/Skeleton/Input/style.css +56 -0
  102. package/lib/components/Skeleton/Skeleton.tsx +97 -0
  103. package/lib/components/Skeleton/index.ts +1 -0
  104. package/lib/components/Skeleton/style.css +84 -0
  105. package/lib/components/Switch/Switch.tsx +68 -0
  106. package/lib/components/Switch/index.css +50 -0
  107. package/lib/components/Switch/index.ts +1 -0
  108. package/lib/components/Upload/Upload.tsx +291 -0
  109. package/lib/components/Upload/index.ts +1 -0
  110. package/lib/components/Upload/style.css +151 -0
  111. package/lib/global.d.ts +1 -0
  112. package/lib/helpers/flatten.ts +26 -0
  113. package/lib/helpers/index.ts +52 -0
  114. package/lib/helpers/mask.ts +52 -0
  115. package/lib/hooks/useForm.ts +548 -0
  116. package/lib/hooks/usePosition.ts +206 -0
  117. package/lib/hooks/useWatch.ts +41 -0
  118. package/lib/hooks/useWatchError.ts +20 -0
  119. package/lib/index.ts +184 -0
  120. package/lib/styles/global.css +57 -0
  121. package/lib/types/button.ts +83 -0
  122. package/lib/types/checkbox.ts +32 -0
  123. package/lib/types/datepicker.ts +165 -0
  124. package/lib/types/dropdown.ts +41 -0
  125. package/lib/types/empty.ts +8 -0
  126. package/lib/types/form.ts +179 -0
  127. package/lib/types/index.ts +38 -0
  128. package/lib/types/input.ts +72 -0
  129. package/lib/types/menu.ts +55 -0
  130. package/lib/types/popover.ts +16 -0
  131. package/lib/types/radio.ts +69 -0
  132. package/lib/types/result.ts +22 -0
  133. package/lib/types/select.ts +126 -0
  134. package/lib/types/skeleton.ts +62 -0
  135. package/lib/types/switch.ts +22 -0
  136. package/lib/types/upload.ts +67 -0
  137. package/lib/utils/index.ts +37 -0
  138. package/lib/utils/lazy.ts +17 -0
  139. package/next.config.ts +7 -0
  140. package/package.json +20 -22
  141. package/rollup.config.js +71 -0
  142. package/src/app/favicon.ico +0 -0
  143. package/src/app/globals.css +48 -0
  144. package/src/app/layout.d.ts +5 -0
  145. package/src/app/layout.tsx +16 -0
  146. package/src/app/page.d.ts +1 -0
  147. package/src/app/page.tsx +21 -0
  148. package/tsconfig.json +46 -0
  149. package/dist/components/Icons/Icons.d.ts +0 -18
  150. package/dist/components/Input/Input.d.ts +0 -11
  151. /package/dist/{components → esm/types/components}/Button/Button.d.ts +0 -0
  152. /package/dist/{components → esm/types/components}/Button/index.d.ts +0 -0
  153. /package/dist/{components → esm/types/components}/Checkbox/Checkbox.d.ts +0 -0
  154. /package/dist/{components → esm/types/components}/Checkbox/index.d.ts +0 -0
  155. /package/dist/{components → esm/types/components}/ConditionalWrapper/index.d.ts +0 -0
  156. /package/dist/{components → esm/types/components}/DatePicker/RangePicker/index.d.ts +0 -0
  157. /package/dist/{components → esm/types/components}/DatePicker/TimePicker/TimePicker.d.ts +0 -0
  158. /package/dist/{components → esm/types/components}/DatePicker/TimePicker/index.d.ts +0 -0
  159. /package/dist/{components → esm/types/components}/DatePicker/index.d.ts +0 -0
  160. /package/dist/{components → esm/types/components}/Dropdown/index.d.ts +0 -0
  161. /package/dist/{components → esm/types/components}/Empty/index.d.ts +0 -0
  162. /package/dist/{components → esm/types/components}/Form/Form.d.ts +0 -0
  163. /package/dist/{components → esm/types/components}/Form/Item/index.d.ts +0 -0
  164. /package/dist/{components → esm/types/components}/Form/index.d.ts +0 -0
  165. /package/dist/{components → esm/types/components}/Icons/index.d.ts +0 -0
  166. /package/dist/{components → esm/types/components}/Input/Textarea/index.d.ts +0 -0
  167. /package/dist/{components → esm/types/components}/Input/index.d.ts +0 -0
  168. /package/dist/{components → esm/types/components}/Menu/Item/Item.d.ts +0 -0
  169. /package/dist/{components → esm/types/components}/Menu/Menu.d.ts +0 -0
  170. /package/dist/{components → esm/types/components}/Menu/SubMenu/SubMenu.d.ts +0 -0
  171. /package/dist/{components → esm/types/components}/Menu/index.d.ts +0 -0
  172. /package/dist/{components → esm/types/components}/Popover/index.d.ts +0 -0
  173. /package/dist/{components → esm/types/components}/Radio/Button/index.d.ts +0 -0
  174. /package/dist/{components → esm/types/components}/Radio/Group/index.d.ts +0 -0
  175. /package/dist/{components → esm/types/components}/Radio/index.d.ts +0 -0
  176. /package/dist/{components → esm/types/components}/Result/index.d.ts +0 -0
  177. /package/dist/{components → esm/types/components}/Select/Option/Option.d.ts +0 -0
  178. /package/dist/{components → esm/types/components}/Select/Option/index.d.ts +0 -0
  179. /package/dist/{components → esm/types/components}/Select/Select.d.ts +0 -0
  180. /package/dist/{components → esm/types/components}/Select/Tag/Tag.d.ts +0 -0
  181. /package/dist/{components → esm/types/components}/Select/Tag/index.d.ts +0 -0
  182. /package/dist/{components → esm/types/components}/Select/index.d.ts +0 -0
  183. /package/dist/{components → esm/types/components}/Skeleton/Avatar/Avatar.d.ts +0 -0
  184. /package/dist/{components → esm/types/components}/Skeleton/Avatar/index.d.ts +0 -0
  185. /package/dist/{components → esm/types/components}/Skeleton/Button/Button.d.ts +0 -0
  186. /package/dist/{components → esm/types/components}/Skeleton/Button/index.d.ts +0 -0
  187. /package/dist/{components → esm/types/components}/Skeleton/Image/Image.d.ts +0 -0
  188. /package/dist/{components → esm/types/components}/Skeleton/Image/index.d.ts +0 -0
  189. /package/dist/{components → esm/types/components}/Skeleton/Input/Input.d.ts +0 -0
  190. /package/dist/{components → esm/types/components}/Skeleton/Input/index.d.ts +0 -0
  191. /package/dist/{components → esm/types/components}/Skeleton/Skeleton.d.ts +0 -0
  192. /package/dist/{components → esm/types/components}/Skeleton/index.d.ts +0 -0
  193. /package/dist/{components → esm/types/components}/Switch/index.d.ts +0 -0
  194. /package/dist/{components → esm/types/components}/Upload/index.d.ts +0 -0
  195. /package/dist/{helpers → esm/types/helpers}/flatten.d.ts +0 -0
  196. /package/dist/{helpers → esm/types/helpers}/index.d.ts +0 -0
  197. /package/dist/{helpers → esm/types/helpers}/mask.d.ts +0 -0
  198. /package/dist/{hooks → esm/types/hooks}/useForm.d.ts +0 -0
  199. /package/dist/{hooks → esm/types/hooks}/usePosition.d.ts +0 -0
  200. /package/dist/{hooks → esm/types/hooks}/useWatch.d.ts +0 -0
  201. /package/dist/{hooks → esm/types/hooks}/useWatchError.d.ts +0 -0
  202. /package/dist/{types → esm/types/types}/button.d.ts +0 -0
  203. /package/dist/{types → esm/types/types}/checkbox.d.ts +0 -0
  204. /package/dist/{types → esm/types/types}/datepicker.d.ts +0 -0
  205. /package/dist/{types → esm/types/types}/dropdown.d.ts +0 -0
  206. /package/dist/{types → esm/types/types}/empty.d.ts +0 -0
  207. /package/dist/{types → esm/types/types}/form.d.ts +0 -0
  208. /package/dist/{types → esm/types/types}/index.d.ts +0 -0
  209. /package/dist/{types → esm/types/types}/input.d.ts +0 -0
  210. /package/dist/{types → esm/types/types}/menu.d.ts +0 -0
  211. /package/dist/{types → esm/types/types}/popover.d.ts +0 -0
  212. /package/dist/{types → esm/types/types}/radio.d.ts +0 -0
  213. /package/dist/{types → esm/types/types}/result.d.ts +0 -0
  214. /package/dist/{types → esm/types/types}/select.d.ts +0 -0
  215. /package/dist/{types → esm/types/types}/skeleton.d.ts +0 -0
  216. /package/dist/{types → esm/types/types}/switch.d.ts +0 -0
  217. /package/dist/{types → esm/types/types}/upload.d.ts +0 -0
  218. /package/dist/{utils → esm/types/utils}/index.d.ts +0 -0
  219. /package/dist/{utils → esm/types/utils}/lazy.d.ts +0 -0
@@ -0,0 +1,16 @@
1
+ import { dirname } from "path";
2
+ import { fileURLToPath } from "url";
3
+ import { FlatCompat } from "@eslint/eslintrc";
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = dirname(__filename);
7
+
8
+ const compat = new FlatCompat({
9
+ baseDirectory: __dirname,
10
+ });
11
+
12
+ const eslintConfig = [
13
+ ...compat.extends("next/core-web-vitals", "next/typescript"),
14
+ ];
15
+
16
+ export default eslintConfig;
@@ -0,0 +1,136 @@
1
+ import React, { ReactElement, useEffect, useMemo, useState } from 'react';
2
+ import { clsx } from '../../helpers';
3
+ import { ButtonProps } from '../../types/button';
4
+ import { prefixClsButton, prefixClsButtonV3 } from '../../utils';
5
+ import './style.css';
6
+
7
+ const ButtonComponent = ({
8
+ type = 'default',
9
+ variant = 'solid',
10
+ color = 'default',
11
+ shape = 'default',
12
+ size = 'middle',
13
+ htmlType = 'button',
14
+ className,
15
+ rootClassName,
16
+ classNames: customClassNames = {},
17
+ styles = {},
18
+ prefixCls = prefixClsButton,
19
+ prefixClsV3 = prefixClsButtonV3,
20
+ icon,
21
+ iconPosition = 'start',
22
+ loading = false,
23
+ disabled = false,
24
+ ghost = false,
25
+ danger = false,
26
+ block = false,
27
+ children,
28
+ href,
29
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
30
+ // @ts-expect-error
31
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
+ __injected,
33
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
34
+ child,
35
+ ...restProps
36
+ }: ButtonProps): ReactElement => {
37
+ const [innerLoading, setInnerLoading] = useState(false);
38
+
39
+ useEffect(() => {
40
+ if (typeof loading === 'boolean') {
41
+ setInnerLoading(loading);
42
+ } else if (typeof loading === 'object' && loading.delay) {
43
+ const timeout = setTimeout(() => setInnerLoading(true), loading.delay);
44
+
45
+ return () => clearTimeout(timeout);
46
+ } else {
47
+ setInnerLoading(!!loading);
48
+ }
49
+ }, [loading]);
50
+
51
+ const classes = useMemo(() => {
52
+ return clsx([...new Set([
53
+ prefixCls,
54
+ prefixClsV3,
55
+ rootClassName,
56
+ `${prefixCls}-${type}`,
57
+ `${prefixCls}-variant-${variant}`,
58
+ `${prefixCls}-color-${color}`,
59
+ `${prefixCls}-shape-${shape}`,
60
+ `${prefixCls}-size-${size}`,
61
+ `${prefixClsV3}-${type}`,
62
+ `${prefixClsV3}-variant-${variant}`,
63
+ `${prefixClsV3}-color-${color}`,
64
+ `${prefixClsV3}-shape-${shape}`,
65
+ `${prefixClsV3}-size-${size}`,
66
+ {
67
+ [`${prefixCls}-block`]: block,
68
+ [`${prefixCls}-ghost`]: ghost,
69
+ [`${prefixCls}-danger`]: danger,
70
+ [`${prefixCls}-loading`]: innerLoading,
71
+ [`${prefixCls}-disabled`]: disabled,
72
+ [`${prefixClsV3}-block`]: block,
73
+ [`${prefixClsV3}-ghost`]: ghost,
74
+ [`${prefixClsV3}-danger`]: danger,
75
+ [`${prefixClsV3}-loading`]: innerLoading,
76
+ [`${prefixClsV3}-disabled`]: disabled
77
+ },
78
+ className
79
+ ])])
80
+ }, [block, className, color, danger, disabled, ghost, innerLoading, prefixCls, prefixClsV3, rootClassName, shape, size, type, variant]);
81
+
82
+ const iconNode = innerLoading
83
+ ? (typeof loading === 'object' && loading.icon) || (
84
+ <span className={`${prefixCls}-spinner ${prefixClsV3}-spinner`} />
85
+ )
86
+ : icon;
87
+
88
+ const content = (
89
+ <>
90
+ {iconNode && iconPosition === 'start' && (
91
+ <span
92
+ className={clsx(`${prefixCls}-icon ${prefixClsV3}-icon`, customClassNames.icon)}
93
+ style={styles.icon}
94
+ >
95
+ {iconNode}
96
+ </span>
97
+ )}
98
+ <span className={`${prefixCls}-content ${prefixClsV3}-content`}>{children}</span>
99
+ {iconNode && iconPosition === 'end' && (
100
+ <span
101
+ className={clsx(`${prefixCls}-icon ${prefixClsV3}-icon`, customClassNames.icon)}
102
+ style={styles.icon}
103
+ >
104
+ {iconNode}
105
+ </span>
106
+ )}
107
+ </>
108
+ );
109
+
110
+ const mergedDisabled = disabled || innerLoading;
111
+
112
+ if (href) {
113
+ return (
114
+ <a
115
+ className={classes}
116
+ href={mergedDisabled ? undefined : href}
117
+ aria-disabled={mergedDisabled}
118
+ >
119
+ {content}
120
+ </a>
121
+ );
122
+ }
123
+
124
+ return (
125
+ <button
126
+ type={htmlType}
127
+ className={classes}
128
+ disabled={mergedDisabled}
129
+ {...restProps}
130
+ >
131
+ {content}
132
+ </button>
133
+ );
134
+ };
135
+
136
+ export default ButtonComponent
@@ -0,0 +1 @@
1
+ export { default as Button } from './Button'
@@ -0,0 +1,197 @@
1
+ html .xUi-button {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ font-weight: 400;
6
+ white-space: nowrap;
7
+ vertical-align: middle;
8
+ user-select: none;
9
+ border: 1px solid transparent;
10
+ cursor: pointer;
11
+ transition: all 0.3s ease;
12
+ border-radius: 6px;
13
+ line-height: 1.5715;
14
+ }
15
+
16
+ html .xUi-button-content {
17
+ display: inline-flex;
18
+ align-items: center;
19
+ justify-content: center;
20
+ }
21
+
22
+ html .xUi-button-icon {
23
+ display: inline-flex;
24
+ align-items: center;
25
+ justify-content: center;
26
+ line-height: 0;
27
+ margin-right: 0.5em;
28
+ }
29
+
30
+ html .xUi-button-icon:last-child {
31
+ margin-right: 0;
32
+ margin-left: 0.5em;
33
+ }
34
+
35
+ html .xUi-button-spinner {
36
+ width: 1em;
37
+ height: 1em;
38
+ border: 1px solid transparent;
39
+ border-top-color: var(--xui-text-color);
40
+ border-radius: 50%;
41
+ animation: xUi-spin 1s linear infinite;
42
+ }
43
+
44
+ @keyframes xUi-spin {
45
+ 0% {
46
+ transform: rotate(0deg);
47
+ }
48
+ 100% {
49
+ transform: rotate(360deg);
50
+ }
51
+ }
52
+
53
+ html .xUi-button-size-small {
54
+ padding: 4px 12px;
55
+ font-size: 12px;
56
+ height: 24px;
57
+ }
58
+
59
+ html .xUi-button-size-middle {
60
+ padding: 0 16px;
61
+ font-size: 14px;
62
+ height: 32px;
63
+ }
64
+
65
+ html .xUi-button-size-large {
66
+ padding: 8px 20px;
67
+ font-size: 16px;
68
+ height: 44px;
69
+ }
70
+
71
+ html .xUi-button-shape-circle {
72
+ padding: 0;
73
+ border-radius: 50%;
74
+ justify-content: center;
75
+ }
76
+
77
+ html .xUi-button-shape-circle .xUi-button-size-small {
78
+ width: 24px;
79
+ height: 24px;
80
+ }
81
+
82
+ html .xUi-button-shape-circle .xUi-button-size-large {
83
+ width: 44px;
84
+ height: 44px;
85
+ }
86
+
87
+ html .xUi-button-shape-round {
88
+ border-radius: 9999px;
89
+ }
90
+
91
+ html .xUi-button-default {
92
+ background-color: #fff;
93
+ border-color: var(--xui-border-color);
94
+ color: rgba(0, 0, 0, 0.85);
95
+ }
96
+
97
+ html .xUi-button-default:hover {
98
+ border-color: var(--xui-primary-color);
99
+ color: var(--xui-primary-color);
100
+ }
101
+
102
+ html .xUi-button-primary {
103
+ background-color: var(--xui-primary-color);
104
+ border-color: var(--xui-primary-color);
105
+ color: #fff;
106
+ }
107
+
108
+ html .xUi-button-primary:hover {
109
+ background-color: var(--xui-primary-color-hover);
110
+ border-color: var(--xui-primary-color-hover);
111
+ color: #fff;
112
+ }
113
+
114
+ html .xUi-button-variant-dashed {
115
+ border-style: dashed;
116
+ background-color: #fff;
117
+ color: rgba(0, 0, 0, 0.85);
118
+ border-color: var(--xui-border-color);
119
+ }
120
+
121
+ html .xUi-button-variant-dashed:hover {
122
+ border-color: var(--xui-primary-color);
123
+ color: var(--xui-primary-color);
124
+ }
125
+
126
+ html .xUi-button-variant-text {
127
+ background-color: transparent;
128
+ border-color: transparent !important;
129
+ color: rgba(0, 0, 0, 0.88);
130
+ }
131
+
132
+ html .xUi-button-variant-text:hover {
133
+ color: rgba(0, 0, 0, 0.88);
134
+ border-color: transparent;
135
+ background-color: rgba(0, 0, 0, 0.04);
136
+ }
137
+
138
+ html .xUi-button-variant-link {
139
+ background-color: transparent;
140
+ border-color: transparent !important;
141
+ color: var(--xui-primary-color);
142
+ }
143
+
144
+ html .xUi-button-variant-link:hover {
145
+ border-color: transparent;
146
+ color: var(--xui-primary-color-light);
147
+ }
148
+
149
+ html .xUi-button-variant-outlined {
150
+ background-color: transparent;
151
+ border-color: var(--xui-border-color);
152
+ color: #fff;
153
+ }
154
+
155
+ html .xUi-button-variant-filled {
156
+ background-color: transparent;
157
+ color: var(--xui-text-color);
158
+ border-color: var(--xui-border-color);
159
+ }
160
+
161
+ html .xUi-button-danger {
162
+ background-color: transparent;
163
+ border-color: var(--xui-error-color);
164
+ color: var(--xui-error-color);
165
+ }
166
+
167
+ html .xUi-button-danger:hover {
168
+ color: var(--xui-error-color-light);
169
+ border-color: var(--xui-error-color-light);
170
+ }
171
+
172
+ html .xUi-button-ghost {
173
+ opacity: 0;
174
+ }
175
+
176
+ html .xUi-button-ghost:hover {
177
+ opacity: 1;
178
+ }
179
+
180
+ html .xUi-button-block {
181
+ display: flex;
182
+ width: 100%;
183
+ }
184
+
185
+ html .xUi-button-disabled,
186
+ html .xUi-button-loading {
187
+ cursor: not-allowed;
188
+ opacity: 0.5;
189
+ color: var(--xui-text-color);
190
+ border-color: var(--xui-border-color);
191
+ background-color: var(--xui-color-disabled);
192
+ pointer-events: none;
193
+ }
194
+
195
+ html .xUi-button-loading {
196
+ background-color: transparent
197
+ }
@@ -0,0 +1,131 @@
1
+ "use client"
2
+
3
+ import React, {
4
+ MouseEvent,
5
+ ReactElement,
6
+ useEffect,
7
+ useRef,
8
+ useState
9
+ } from 'react';
10
+ import { clsx } from '../../../lib/helpers';
11
+ import { SyntheticBaseEvent } from '../../types';
12
+ import { CheckboxProps } from '../../types/checkbox';
13
+ import { prefixClsCheckbox, prefixClsCheckboxV3 } from '../../../lib/utils';
14
+ import './style.css';
15
+
16
+ const Checkbox = ({
17
+ prefixCls = prefixClsCheckbox,
18
+ prefixClsV3 = prefixClsCheckboxV3,
19
+ className = '',
20
+ defaultChecked = false,
21
+ checked,
22
+ style,
23
+ disabled = false,
24
+ onChange,
25
+ onClick,
26
+ onMouseEnter,
27
+ onMouseLeave,
28
+ onKeyPress,
29
+ onKeyDown,
30
+ tabIndex,
31
+ name,
32
+ children,
33
+ id,
34
+ autoFocus,
35
+ type = 'checkbox',
36
+ value = false,
37
+ required = false,
38
+ noStyle,
39
+ titleClick,
40
+ ref,
41
+ controlled = false
42
+ }: CheckboxProps,
43
+ ): ReactElement => {
44
+ const isChecked = checked !== undefined ? checked : defaultChecked || value;
45
+ const [internalChecked, setInternalChecked] = useState(isChecked);
46
+
47
+ const checkboxRef = useRef<HTMLInputElement | null>(null);
48
+
49
+ const handleClick = (
50
+ e: MouseEvent<HTMLInputElement> & SyntheticBaseEvent
51
+ ) => {
52
+ if (disabled) {
53
+ e.stopPropagation();
54
+
55
+ return;
56
+ }
57
+
58
+ if (checkboxRef.current) {
59
+ if (!controlled) {
60
+ e.target.value = !internalChecked;
61
+ setInternalChecked(!internalChecked);
62
+ checkboxRef.current.checked = !internalChecked
63
+ } else {
64
+ e.target.value = !checked;
65
+ checkboxRef.current.checked = !checked
66
+ }
67
+ }
68
+
69
+ onClick?.(e);
70
+ onChange?.(e);
71
+ };
72
+
73
+ useEffect(() => {
74
+ if (checked !== undefined) {
75
+ setInternalChecked(checked);
76
+ }
77
+ }, [checked]);
78
+
79
+ return (
80
+ <div className={`${prefixCls}-wrapper ${prefixClsV3}-wrapper`}>
81
+ <div
82
+ ref={ref}
83
+ tabIndex={0}
84
+ role="button"
85
+ style={style}
86
+ onClick={handleClick}
87
+ className={clsx([
88
+ prefixCls,
89
+ prefixClsV3,
90
+ className,
91
+ {
92
+ noStyle: noStyle,
93
+ [`${prefixCls}-disabled ${prefixClsV3}-disabled`]: disabled,
94
+ [`${prefixCls}-checked ${prefixClsV3}-checked`]: internalChecked
95
+ }
96
+ ])}
97
+ >
98
+ <input
99
+ id={id}
100
+ type={type}
101
+ name={name}
102
+ ref={checkboxRef}
103
+ disabled={disabled}
104
+ tabIndex={tabIndex}
105
+ required={required}
106
+ autoFocus={autoFocus}
107
+ onKeyDown={onKeyDown}
108
+ onKeyPress={onKeyPress}
109
+ onMouseEnter={onMouseEnter}
110
+ onMouseLeave={onMouseLeave}
111
+ />
112
+
113
+ <span className={`${prefixCls}-box ${prefixClsV3}-box`}>
114
+ <span
115
+ className={`${prefixCls}-check ${prefixClsV3}-check`}
116
+ style={{ opacity: internalChecked ? 1 : 0 }}
117
+ />
118
+ </span>
119
+ </div>
120
+
121
+ {titleClick
122
+ ? <div onClick={handleClick}>{children}</div>
123
+ : children && <span className={`${prefixCls}-label ${prefixClsV3}-label`}>{children}</span>
124
+ }
125
+ </div>
126
+ );
127
+ };
128
+
129
+ Checkbox.displayName = 'Checkbox';
130
+
131
+ export default Checkbox;
@@ -0,0 +1 @@
1
+ export { default as Checkbox } from './Checkbox'
@@ -0,0 +1,95 @@
1
+ .xUi-checkbox-wrapper {
2
+ cursor: pointer;
3
+ font-size: var(--xui-font-size-md);
4
+ align-items: center;
5
+ display: inline-flex;
6
+ color: var(--xui-main-color);
7
+ margin: 16px 0;
8
+
9
+ &:has([tabindex="0"]:focus-visible) {
10
+ border-color: var(--xui-primary-color);
11
+ }
12
+ }
13
+
14
+ .xUi-checkbox {
15
+ width: 14px;
16
+ height: 14px;
17
+ position: relative;
18
+ border-radius: var(--xui-border-radius-sm);
19
+ transition: all 0.3s;
20
+ display: inline-block;
21
+ background-color: transparent;
22
+ border: 1px solid var(--xui-border-color);
23
+ }
24
+
25
+ .xUi-checkbox.xUi-checkbox-checked {
26
+ border-color: var(--xui-primary-color);
27
+ background-color: #f0f5ff;
28
+ }
29
+
30
+ .xUi-checkbox input {
31
+ inset: 0;
32
+ opacity: 0;
33
+ cursor: pointer;
34
+ position: absolute;
35
+ }
36
+
37
+ .xUi-checkbox-inner {
38
+ top: 50%;
39
+ left: 50%;
40
+ width: 10px;
41
+ height: 6px;
42
+ border-top: 0;
43
+ border-left: 0;
44
+ position: absolute;
45
+ border: 2px solid var(--xui-background-color);
46
+ transform: rotate(45deg) scale(0);
47
+ transition: transform 0.2s ease-in-out;
48
+ }
49
+
50
+ .xUi-checkbox-check {
51
+ width: 100%;
52
+ height: 100%;
53
+ display: block;
54
+ position: relative;
55
+ transition: 0.1s ease;
56
+ border-color: var(--xui-primary-color);
57
+ background-color: var(--xui-primary-color);
58
+ }
59
+
60
+ .xUi-checkbox-check::after {
61
+ top: 1px;
62
+ left: 3px;
63
+ width: 5px;
64
+ height: 8px;
65
+ content: "";
66
+ position: absolute;
67
+ border: solid white;
68
+ transform: rotate(45deg);
69
+ border-width: 0 2px 2px 0;
70
+ }
71
+
72
+ .xUi-checkbox-disabled,
73
+ .xUi-checkbox-disabled .xUi-checkbox-check {
74
+ opacity: 0.5;
75
+ cursor: not-allowed;
76
+ background-color: var(--xui-color-disabled);
77
+ border-color: var(--xui-border-color) !important;
78
+ }
79
+
80
+ .xUi-checkbox-label {
81
+ margin-left: 8px;
82
+ user-select: none;
83
+ font-size: 14px;
84
+ }
85
+
86
+ .xUi-checkbox:hover:not(.disabled),
87
+ .xUi-checkbox:focus:not(.disabled) {
88
+ border-color: var(--xui-primary-color);
89
+ cursor: pointer;
90
+ }
91
+
92
+ .xUi-checkbox.disabled {
93
+ opacity: 0.5;
94
+ cursor: not-allowed;
95
+ }
@@ -0,0 +1,12 @@
1
+ import { FC, PropsWithChildren, ReactElement } from 'react';
2
+
3
+ type Props = {
4
+ condition: boolean;
5
+ wrapper: (children: PropsWithChildren['children']) => ReactElement;
6
+ } & PropsWithChildren;
7
+
8
+ export const ConditionalWrapper: FC<Props> = ({
9
+ condition,
10
+ wrapper,
11
+ children
12
+ }) => (condition ? wrapper(children) : children);