x-ui-design 0.2.2 → 0.2.3
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/dist/esm/types/index.d.ts +0 -25
- package/dist/index.d.ts +2 -655
- package/dist/index.esm.js +9 -2962
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +5 -2994
- package/dist/index.js.map +1 -1
- package/lib/index.ts +0 -52
- package/package.json +1 -1
- package/{lib → src}/components/Checkbox/Checkbox.tsx +2 -2
- package/{lib → src}/components/Form/Form.tsx +1 -1
- package/{lib → src}/components/Form/Item/Item.tsx +2 -2
- package/{lib → src}/components/Input/Input.tsx +2 -2
- package/{lib → src}/components/Input/Textarea/Textarea.tsx +2 -2
- package/{lib → src}/components/Select/Option/Option.tsx +2 -2
- package/{lib → src}/components/Select/Select.tsx +2 -2
- package/{lib → src}/components/Select/Tag/Tag.tsx +1 -1
- package/{lib → src}/components/Skeleton/Avatar/Avatar.tsx +2 -2
- package/{lib → src}/components/Skeleton/Button/Button.tsx +2 -2
- package/{lib → src}/components/Skeleton/Image/Image.tsx +1 -1
- package/{lib → src}/components/Skeleton/Input/Input.tsx +2 -2
- package/{lib → src}/components/Skeleton/Skeleton.tsx +2 -2
- package/{lib → src}/hooks/useForm.ts +2 -2
- package/{lib → src}/hooks/useWatch.ts +2 -2
- package/{lib → src}/types/checkbox.ts +1 -1
- package/src/types/index.ts +27 -0
- package/dist/esm/types/components/Checkbox/Checkbox.d.ts +0 -23
- package/dist/esm/types/components/Checkbox/index.d.ts +0 -1
- package/dist/esm/types/components/DatePicker/DatePicker.d.ts +0 -9
- package/dist/esm/types/components/DatePicker/RangePicker/RangePicker.d.ts +0 -4
- package/dist/esm/types/components/DatePicker/RangePicker/index.d.ts +0 -1
- package/dist/esm/types/components/DatePicker/TimePicker/TimePicker.d.ts +0 -5
- package/dist/esm/types/components/DatePicker/TimePicker/index.d.ts +0 -1
- package/dist/esm/types/components/DatePicker/index.d.ts +0 -1
- package/dist/esm/types/components/Empty/Empty.d.ts +0 -4
- package/dist/esm/types/components/Empty/index.d.ts +0 -1
- package/dist/esm/types/components/Form/Form.d.ts +0 -7
- package/dist/esm/types/components/Form/Item/Item.d.ts +0 -7
- package/dist/esm/types/components/Form/Item/index.d.ts +0 -1
- package/dist/esm/types/components/Form/index.d.ts +0 -1
- package/dist/esm/types/components/Icons/Icons.d.ts +0 -16
- package/dist/esm/types/components/Icons/index.d.ts +0 -1
- package/dist/esm/types/components/Input/Input.d.ts +0 -28
- package/dist/esm/types/components/Input/Textarea/Textarea.d.ts +0 -27
- package/dist/esm/types/components/Input/Textarea/index.d.ts +0 -1
- package/dist/esm/types/components/Input/index.d.ts +0 -1
- package/dist/esm/types/components/Radio/Button/Button.d.ts +0 -4
- package/dist/esm/types/components/Radio/Button/index.d.ts +0 -1
- package/dist/esm/types/components/Radio/Group/Group.d.ts +0 -4
- package/dist/esm/types/components/Radio/Group/index.d.ts +0 -1
- package/dist/esm/types/components/Radio/Radio.d.ts +0 -30
- package/dist/esm/types/components/Radio/index.d.ts +0 -1
- package/dist/esm/types/components/Select/Option/Option.d.ts +0 -5
- package/dist/esm/types/components/Select/Option/index.d.ts +0 -1
- package/dist/esm/types/components/Select/Select.d.ts +0 -51
- package/dist/esm/types/components/Select/Tag/Tag.d.ts +0 -5
- package/dist/esm/types/components/Select/Tag/index.d.ts +0 -1
- package/dist/esm/types/components/Select/index.d.ts +0 -1
- package/dist/esm/types/components/Skeleton/Avatar/Avatar.d.ts +0 -8
- package/dist/esm/types/components/Skeleton/Avatar/index.d.ts +0 -1
- package/dist/esm/types/components/Skeleton/Button/Button.d.ts +0 -5
- package/dist/esm/types/components/Skeleton/Button/index.d.ts +0 -1
- package/dist/esm/types/components/Skeleton/Image/Image.d.ts +0 -5
- package/dist/esm/types/components/Skeleton/Image/index.d.ts +0 -1
- package/dist/esm/types/components/Skeleton/Input/Input.d.ts +0 -5
- package/dist/esm/types/components/Skeleton/Input/index.d.ts +0 -1
- package/dist/esm/types/components/Skeleton/Skeleton.d.ts +0 -11
- package/dist/esm/types/components/Skeleton/index.d.ts +0 -1
- package/dist/esm/types/components/Upload/Upload.d.ts +0 -4
- package/dist/esm/types/components/Upload/index.d.ts +0 -1
- package/dist/esm/types/hooks/useForm.d.ts +0 -4
- package/dist/esm/types/hooks/useWatch.d.ts +0 -9
- package/dist/esm/types/types/checkbox.d.ts +0 -22
- package/dist/esm/types/types/datepicker.d.ts +0 -119
- package/dist/esm/types/types/empty.d.ts +0 -7
- package/dist/esm/types/types/form.d.ts +0 -107
- package/dist/esm/types/types/input.d.ts +0 -47
- package/dist/esm/types/types/radio.d.ts +0 -57
- package/dist/esm/types/types/select.d.ts +0 -97
- package/dist/esm/types/types/skeleton.d.ts +0 -50
- package/dist/esm/types/types/upload.d.ts +0 -54
- /package/{lib → src}/components/Checkbox/index.ts +0 -0
- /package/{lib → src}/components/Checkbox/style.css +0 -0
- /package/{lib → src}/components/DatePicker/DatePicker.tsx +0 -0
- /package/{lib → src}/components/DatePicker/RangePicker/RangePicker.tsx +0 -0
- /package/{lib → src}/components/DatePicker/RangePicker/index.ts +0 -0
- /package/{lib → src}/components/DatePicker/RangePicker/style.css +0 -0
- /package/{lib → src}/components/DatePicker/TimePicker/TimePicker.tsx +0 -0
- /package/{lib → src}/components/DatePicker/TimePicker/index.ts +0 -0
- /package/{lib → src}/components/DatePicker/TimePicker/style.css +0 -0
- /package/{lib → src}/components/DatePicker/index.ts +0 -0
- /package/{lib → src}/components/DatePicker/style.css +0 -0
- /package/{lib → src}/components/Empty/Empty.tsx +0 -0
- /package/{lib → src}/components/Empty/index.ts +0 -0
- /package/{lib → src}/components/Empty/style.css +0 -0
- /package/{lib → src}/components/Form/Item/index.ts +0 -0
- /package/{lib → src}/components/Form/Item/style.css +0 -0
- /package/{lib → src}/components/Form/index.ts +0 -0
- /package/{lib → src}/components/Icons/Icons.tsx +0 -0
- /package/{lib → src}/components/Icons/index.ts +0 -0
- /package/{lib → src}/components/Input/Textarea/index.ts +0 -0
- /package/{lib → src}/components/Input/Textarea/style.css +0 -0
- /package/{lib → src}/components/Input/index.ts +0 -0
- /package/{lib → src}/components/Input/style.css +0 -0
- /package/{lib → src}/components/Radio/Button/Button.tsx +0 -0
- /package/{lib → src}/components/Radio/Button/index.ts +0 -0
- /package/{lib → src}/components/Radio/Button/style.css +0 -0
- /package/{lib → src}/components/Radio/Group/Group.tsx +0 -0
- /package/{lib → src}/components/Radio/Group/index.ts +0 -0
- /package/{lib → src}/components/Radio/Group/style.css +0 -0
- /package/{lib → src}/components/Radio/Radio.tsx +0 -0
- /package/{lib → src}/components/Radio/index.ts +0 -0
- /package/{lib → src}/components/Radio/style.css +0 -0
- /package/{lib → src}/components/Select/Option/index.ts +0 -0
- /package/{lib → src}/components/Select/Option/style.css +0 -0
- /package/{lib → src}/components/Select/Tag/index.ts +0 -0
- /package/{lib → src}/components/Select/Tag/style.css +0 -0
- /package/{lib → src}/components/Select/index.ts +0 -0
- /package/{lib → src}/components/Select/style.css +0 -0
- /package/{lib → src}/components/Skeleton/Avatar/index.ts +0 -0
- /package/{lib → src}/components/Skeleton/Avatar/style.css +0 -0
- /package/{lib → src}/components/Skeleton/Button/index.ts +0 -0
- /package/{lib → src}/components/Skeleton/Button/style.css +0 -0
- /package/{lib → src}/components/Skeleton/Image/index.ts +0 -0
- /package/{lib → src}/components/Skeleton/Image/style.css +0 -0
- /package/{lib → src}/components/Skeleton/Input/index.ts +0 -0
- /package/{lib → src}/components/Skeleton/Input/style.css +0 -0
- /package/{lib → src}/components/Skeleton/index.ts +0 -0
- /package/{lib → src}/components/Skeleton/style.css +0 -0
- /package/{lib → src}/components/Upload/Upload.tsx +0 -0
- /package/{lib → src}/components/Upload/index.ts +0 -0
- /package/{lib → src}/components/Upload/style.css +0 -0
- /package/{lib → src}/types/datepicker.ts +0 -0
- /package/{lib → src}/types/empty.ts +0 -0
- /package/{lib → src}/types/form.ts +0 -0
- /package/{lib → src}/types/input.ts +0 -0
- /package/{lib → src}/types/radio.ts +0 -0
- /package/{lib → src}/types/select.ts +0 -0
- /package/{lib → src}/types/skeleton.ts +0 -0
- /package/{lib → src}/types/upload.ts +0 -0
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { jsxs,
|
|
2
|
-
import {
|
|
3
|
-
import { createPortal } from 'react-dom';
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useEffect, useMemo } from 'react';
|
|
4
3
|
|
|
5
4
|
function styleInject(css, ref) {
|
|
6
5
|
if (ref === void 0) ref = {};
|
|
@@ -27,257 +26,9 @@ function styleInject(css, ref) {
|
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
var css_248z$
|
|
31
|
-
styleInject(css_248z$
|
|
32
|
-
|
|
33
|
-
const useForm = (initialValues = {}, onFieldsChange, onValuesChange) => {
|
|
34
|
-
const touchedFieldsRef = useRef(new Set());
|
|
35
|
-
const rulesRef = useRef({});
|
|
36
|
-
const warningsRef = useRef({});
|
|
37
|
-
const formRef = useRef({
|
|
38
|
-
...initialValues
|
|
39
|
-
});
|
|
40
|
-
const fieldInstancesRef = useRef({});
|
|
41
|
-
const [isReseting, setIsReseting] = useState(false);
|
|
42
|
-
const [errors, setErrors] = useState({});
|
|
43
|
-
const fieldSubscribers = useRef({});
|
|
44
|
-
const formSubscribers = useRef([]);
|
|
45
|
-
function getFieldInstance(name) {
|
|
46
|
-
return fieldInstancesRef.current[name] || null;
|
|
47
|
-
}
|
|
48
|
-
function getFieldValue(name) {
|
|
49
|
-
return formRef.current[name];
|
|
50
|
-
}
|
|
51
|
-
function getFieldsValue(nameList) {
|
|
52
|
-
if (!nameList) {
|
|
53
|
-
return {
|
|
54
|
-
...formRef.current
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
return nameList.reduce((acc, key) => {
|
|
58
|
-
acc[key] = formRef.current[key];
|
|
59
|
-
return acc;
|
|
60
|
-
}, {});
|
|
61
|
-
}
|
|
62
|
-
function getFieldError(name) {
|
|
63
|
-
return errors[name] || [];
|
|
64
|
-
}
|
|
65
|
-
function getFieldWarning(name) {
|
|
66
|
-
return warningsRef.current[name] || [];
|
|
67
|
-
}
|
|
68
|
-
function getFieldsError() {
|
|
69
|
-
return Object.entries(errors).map(([name, err]) => ({
|
|
70
|
-
name,
|
|
71
|
-
errors: err
|
|
72
|
-
}));
|
|
73
|
-
}
|
|
74
|
-
function setFieldValue(name, value, errors, reset) {
|
|
75
|
-
if (!reset && ([undefined, null].includes(value) || formRef.current[name] === value)) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
formRef.current[name] = value;
|
|
79
|
-
touchedFieldsRef.current.add(name);
|
|
80
|
-
if (!errors?.length) {
|
|
81
|
-
validateField(name).then(() => {
|
|
82
|
-
const allValues = getFieldsValue();
|
|
83
|
-
fieldSubscribers.current[name]?.forEach(callback => callback(value));
|
|
84
|
-
formSubscribers.current.forEach(callback => callback(allValues));
|
|
85
|
-
if (onValuesChange) {
|
|
86
|
-
onValuesChange({
|
|
87
|
-
[name]: value
|
|
88
|
-
}, allValues);
|
|
89
|
-
}
|
|
90
|
-
if (onFieldsChange) {
|
|
91
|
-
onFieldsChange([{
|
|
92
|
-
name,
|
|
93
|
-
value
|
|
94
|
-
}]);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
} else {
|
|
98
|
-
setErrors({
|
|
99
|
-
[name]: errors
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function setFieldsValue(values) {
|
|
104
|
-
Object.entries(values).forEach(([name, value]) => setFieldValue(name, value));
|
|
105
|
-
}
|
|
106
|
-
function setFields(fields) {
|
|
107
|
-
fields.forEach(({
|
|
108
|
-
name,
|
|
109
|
-
value,
|
|
110
|
-
errors
|
|
111
|
-
}) => setFieldValue(Array.isArray(name) ? name[0] : name, value, errors));
|
|
112
|
-
}
|
|
113
|
-
function isFieldTouched(name) {
|
|
114
|
-
return touchedFieldsRef.current.has(name);
|
|
115
|
-
}
|
|
116
|
-
function isFieldsTouched(nameList, allFieldsTouched = false) {
|
|
117
|
-
if (!nameList) {
|
|
118
|
-
return touchedFieldsRef.current.size > 0;
|
|
119
|
-
}
|
|
120
|
-
return allFieldsTouched ? nameList.every(name => touchedFieldsRef.current.has(name)) : nameList.some(name => touchedFieldsRef.current.has(name));
|
|
121
|
-
}
|
|
122
|
-
function isFieldValidating(name) {
|
|
123
|
-
return !!name;
|
|
124
|
-
}
|
|
125
|
-
function registerField(name, rules = []) {
|
|
126
|
-
if (!(name in formRef.current)) {
|
|
127
|
-
formRef.current[name] = initialValues?.[name];
|
|
128
|
-
}
|
|
129
|
-
rulesRef.current[name] = rules;
|
|
130
|
-
}
|
|
131
|
-
async function validateField(name) {
|
|
132
|
-
const value = formRef.current[name];
|
|
133
|
-
const rules = rulesRef.current[name] || [];
|
|
134
|
-
const fieldErrors = [];
|
|
135
|
-
const fieldWarnings = [];
|
|
136
|
-
await Promise.all([rules].flat(1).map(async rule => {
|
|
137
|
-
rule = typeof rule === 'function' ? rule(formInstance) : rule;
|
|
138
|
-
if (rule.required && (value === undefined || value === null || value === '' || Array.isArray(value) && !value.length)) {
|
|
139
|
-
fieldErrors.push(rule.message || 'This field is required');
|
|
140
|
-
}
|
|
141
|
-
if ((typeof value === 'string' || typeof value === 'number' || Array.isArray(value)) && rule.min !== undefined && String(value).length < rule.min) {
|
|
142
|
-
fieldErrors.push(rule.message || `Must be at least ${rule.min} characters`);
|
|
143
|
-
}
|
|
144
|
-
if ((typeof value === 'string' || typeof value === 'number' || Array.isArray(value)) && rule.max !== undefined && String(value).length > rule.max) {
|
|
145
|
-
fieldErrors.push(rule.message || `Must be at most ${rule.max} characters`);
|
|
146
|
-
}
|
|
147
|
-
if (rule.pattern && !rule.pattern.test(String(value))) {
|
|
148
|
-
fieldErrors.push(rule.message || 'Invalid format');
|
|
149
|
-
}
|
|
150
|
-
if (rule.warningPattern && !rule.warningPattern.test(String(value))) {
|
|
151
|
-
fieldWarnings.push(rule.warningMessage || 'Invalid format');
|
|
152
|
-
}
|
|
153
|
-
if (rule.validator) {
|
|
154
|
-
try {
|
|
155
|
-
await rule.validator(rule, value, error => error && fieldErrors.push(error));
|
|
156
|
-
} catch (error) {
|
|
157
|
-
fieldErrors.push(error instanceof Error ? error.message : String(error));
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}));
|
|
161
|
-
setErrors(prev => ({
|
|
162
|
-
...prev,
|
|
163
|
-
[name]: fieldErrors
|
|
164
|
-
}));
|
|
165
|
-
warningsRef.current[name] = fieldWarnings;
|
|
166
|
-
return fieldErrors.length === 0;
|
|
167
|
-
}
|
|
168
|
-
async function validateFields(nameList) {
|
|
169
|
-
const fieldsToValidate = nameList || Object.keys(formRef.current);
|
|
170
|
-
const results = await Promise.all(fieldsToValidate.map(name => validateField(name)));
|
|
171
|
-
return results.every(valid => valid);
|
|
172
|
-
}
|
|
173
|
-
function resetFields(nameList) {
|
|
174
|
-
if (nameList?.length) {
|
|
175
|
-
nameList.forEach(name => {
|
|
176
|
-
formRef.current[name] = initialValues[name];
|
|
177
|
-
touchedFieldsRef.current.delete(name);
|
|
178
|
-
delete warningsRef.current[name];
|
|
179
|
-
setErrors(prev => ({
|
|
180
|
-
...prev,
|
|
181
|
-
[name]: []
|
|
182
|
-
}));
|
|
183
|
-
setFieldValue(name, initialValues[name], undefined, true);
|
|
184
|
-
});
|
|
185
|
-
} else {
|
|
186
|
-
touchedFieldsRef.current.clear();
|
|
187
|
-
warningsRef.current = {};
|
|
188
|
-
Object.keys(formRef.current).forEach(name => {
|
|
189
|
-
setFieldValue(name, initialValues[name], undefined, true);
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
formSubscribers.current.forEach(callback => callback(getFieldsValue()));
|
|
193
|
-
setIsReseting(prev => !prev);
|
|
194
|
-
}
|
|
195
|
-
async function submit() {
|
|
196
|
-
return (await validateFields()) ? formRef.current : undefined;
|
|
197
|
-
}
|
|
198
|
-
function subscribeToField(name, callback) {
|
|
199
|
-
if (!fieldSubscribers.current[name]) {
|
|
200
|
-
fieldSubscribers.current[name] = [];
|
|
201
|
-
}
|
|
202
|
-
fieldSubscribers.current[name].push(callback);
|
|
203
|
-
return () => {
|
|
204
|
-
fieldSubscribers.current[name] = fieldSubscribers.current[name].filter(cb => cb !== callback);
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
function subscribeToForm(callback) {
|
|
208
|
-
formSubscribers.current.push(callback);
|
|
209
|
-
return () => {
|
|
210
|
-
formSubscribers.current = formSubscribers.current.filter(cb => cb !== callback);
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
function subscribeToFields(names, callback) {
|
|
214
|
-
const fieldCallbacks = names.map(name => subscribeToField(name, () => {
|
|
215
|
-
const updatedValues = getFieldsValue(names);
|
|
216
|
-
callback(updatedValues);
|
|
217
|
-
}));
|
|
218
|
-
return () => {
|
|
219
|
-
fieldCallbacks.forEach(unsubscribe => unsubscribe());
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
const formInstance = {
|
|
223
|
-
submit,
|
|
224
|
-
setFields,
|
|
225
|
-
resetFields,
|
|
226
|
-
getFieldError,
|
|
227
|
-
registerField,
|
|
228
|
-
setFieldValue,
|
|
229
|
-
getFieldValue,
|
|
230
|
-
validateFields,
|
|
231
|
-
setFieldsValue,
|
|
232
|
-
getFieldsValue,
|
|
233
|
-
isFieldTouched,
|
|
234
|
-
getFieldsError,
|
|
235
|
-
isFieldsTouched,
|
|
236
|
-
getFieldWarning,
|
|
237
|
-
isFieldValidating,
|
|
238
|
-
subscribeToField,
|
|
239
|
-
subscribeToForm,
|
|
240
|
-
onFieldsChange,
|
|
241
|
-
onValuesChange,
|
|
242
|
-
getFieldInstance,
|
|
243
|
-
subscribeToFields,
|
|
244
|
-
isReseting
|
|
245
|
-
};
|
|
246
|
-
return formInstance;
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
const prefixClsForm = 'xUi-form';
|
|
250
|
-
const prefixClsFormItem = 'xUi-form-item';
|
|
251
|
-
const prefixClsEmpty = 'xUi-empty';
|
|
252
|
-
const prefixClsInput = 'xUi-input';
|
|
253
|
-
const prefixClsSelect = 'xUi-select';
|
|
254
|
-
const prefixClsCheckbox = 'xUi-checkbox';
|
|
255
|
-
const prefixClsRadio = 'xUi-radio';
|
|
256
|
-
const prefixClsTextArea = 'xUi-textarea';
|
|
257
|
-
const prefixClsUpload = 'xUi-upload';
|
|
258
|
-
const prefixClsDatePicker = 'xUi-datepicker';
|
|
259
|
-
const prefixClsRangePicker = 'xUi-rangepicker';
|
|
260
|
-
const prefixClsTimePicker = 'xUi-timepicker';
|
|
261
|
-
const prefixClsButton = 'xUi-button';
|
|
262
|
-
const prefixClsSkeleton = 'xUi-skeleton';
|
|
29
|
+
var css_248z$1 = ":root{--xui-color-hover:#f5f5f5;--xui-color-disabled:#e6e6e6;--xui-primary-color:#1677ff;--xui-primary-color-light:#40a9ff;--xui-text-color:rgba(0,0,0,.88);--xui-text-color-light:rgba(0,0,0,.5);--xui-error-color:#ff4d4f;--xui-error-color-light:#ff6668;--xui-success-color:#52c41a;--xui-background-color:#fff;--xui-font-size-xs:12px;--xui-font-size-sm:14px;--xui-font-size-md:14px;--xui-font-size-lg:16px;--xui-border-radius-sm:4px;--xui-border-radius-md:4px;--xui-border-radius-lg:6px;--xui-border-color:#d9d9d9;--xui-select-primary-color:var(--xui-primary-color);--xui-select-background-color:var(--xui-background-color)}html{font-family:sans-serif}.globalEllipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}";
|
|
30
|
+
styleInject(css_248z$1);
|
|
263
31
|
|
|
264
|
-
const parseValue = value => {
|
|
265
|
-
if (value === 'true') {
|
|
266
|
-
return true;
|
|
267
|
-
}
|
|
268
|
-
if (value === 'false') {
|
|
269
|
-
return false;
|
|
270
|
-
}
|
|
271
|
-
if (!isNaN(Number(value))) {
|
|
272
|
-
return Number(value);
|
|
273
|
-
}
|
|
274
|
-
return value;
|
|
275
|
-
};
|
|
276
|
-
function createArray(length) {
|
|
277
|
-
return Array.from({
|
|
278
|
-
length
|
|
279
|
-
}, (_, index) => index);
|
|
280
|
-
}
|
|
281
32
|
function clsx(...args) {
|
|
282
33
|
return args.flatMap(arg => {
|
|
283
34
|
if (!arg) {
|
|
@@ -299,2388 +50,10 @@ function clsx(...args) {
|
|
|
299
50
|
}).filter(Boolean).join(' ');
|
|
300
51
|
}
|
|
301
52
|
|
|
302
|
-
|
|
303
|
-
styleInject(css_248z$k);
|
|
304
|
-
|
|
305
|
-
const REF_CLIENT_HEIGHT = 24;
|
|
306
|
-
const FormItem = ({
|
|
307
|
-
prefixCls = prefixClsFormItem,
|
|
308
|
-
name,
|
|
309
|
-
label,
|
|
310
|
-
rules = [],
|
|
311
|
-
children,
|
|
312
|
-
className = '',
|
|
313
|
-
layout = 'vertical',
|
|
314
|
-
style = {},
|
|
315
|
-
valuePropName,
|
|
316
|
-
dependencies = [],
|
|
317
|
-
initialValue,
|
|
318
|
-
feedbackIcons,
|
|
319
|
-
...props
|
|
320
|
-
}) => {
|
|
321
|
-
const formContext = useContext(FormContext);
|
|
322
|
-
const errorRef = useRef(null);
|
|
323
|
-
if (!formContext) {
|
|
324
|
-
throw new Error('FormItem must be used within a Form');
|
|
325
|
-
}
|
|
326
|
-
const {
|
|
327
|
-
isReseting,
|
|
328
|
-
registerField,
|
|
329
|
-
getFieldError,
|
|
330
|
-
getFieldValue,
|
|
331
|
-
setFieldValue,
|
|
332
|
-
getFieldInstance,
|
|
333
|
-
subscribeToFields,
|
|
334
|
-
validateFields
|
|
335
|
-
} = formContext;
|
|
336
|
-
const childrenList = useMemo(() => (Array.isArray(children) ? children : [children]).filter(Boolean), [children]);
|
|
337
|
-
useEffect(() => {
|
|
338
|
-
if (name && !getFieldInstance(name)) {
|
|
339
|
-
registerField(name, rules);
|
|
340
|
-
}
|
|
341
|
-
}, [name, rules]);
|
|
342
|
-
useEffect(() => {
|
|
343
|
-
if (initialValue) {
|
|
344
|
-
setFieldValue(name, initialValue);
|
|
345
|
-
}
|
|
346
|
-
}, []);
|
|
347
|
-
useEffect(() => {
|
|
348
|
-
if (name && dependencies.length > 0) {
|
|
349
|
-
const unsubscribe = subscribeToFields(dependencies, () => {
|
|
350
|
-
validateFields([name]);
|
|
351
|
-
});
|
|
352
|
-
return () => {
|
|
353
|
-
unsubscribe();
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
}, [dependencies, name]);
|
|
357
|
-
useEffect(() => {
|
|
358
|
-
if (errorRef.current && errorRef.current?.clientHeight >= REF_CLIENT_HEIGHT) {
|
|
359
|
-
errorRef.current.style.position = 'relative';
|
|
360
|
-
errorRef.current.style.marginTop = '-16px';
|
|
361
|
-
}
|
|
362
|
-
}, [errorRef.current]);
|
|
363
|
-
const isRequired = useMemo(() => rules.some(rule => rule.required), [rules]);
|
|
364
|
-
const errorMessage = getFieldError(valuePropName || name)?.[0];
|
|
365
|
-
return jsxs("div", {
|
|
366
|
-
style: style,
|
|
367
|
-
className: clsx([`${prefixCls}`, {
|
|
368
|
-
[layout]: layout,
|
|
369
|
-
[className]: className,
|
|
370
|
-
noStyle: props.noStyle
|
|
371
|
-
}]),
|
|
372
|
-
children: [!props.noStyle && (label || name) && jsxs("label", {
|
|
373
|
-
className: `${prefixCls}-label`,
|
|
374
|
-
htmlFor: name,
|
|
375
|
-
children: [label || name, ":", isRequired && jsx("span", {
|
|
376
|
-
className: `${prefixCls}-required`,
|
|
377
|
-
children: "*"
|
|
378
|
-
})]
|
|
379
|
-
}), Children.map(childrenList, (child, key) => {
|
|
380
|
-
if (/*#__PURE__*/isValidElement(child) && child.type !== Fragment) {
|
|
381
|
-
const {
|
|
382
|
-
value,
|
|
383
|
-
...childProps
|
|
384
|
-
} = child.props;
|
|
385
|
-
const fieldValue = getFieldValue(valuePropName || name) ?? initialValue;
|
|
386
|
-
return /*#__PURE__*/createElement(FormItemChildComponent, {
|
|
387
|
-
...childProps,
|
|
388
|
-
name: name,
|
|
389
|
-
child: child,
|
|
390
|
-
value: value,
|
|
391
|
-
fieldValue: fieldValue,
|
|
392
|
-
noStyle: props.noStyle,
|
|
393
|
-
normalize: props.normalize,
|
|
394
|
-
key: `${key}_${isReseting}`,
|
|
395
|
-
error: Boolean(errorMessage),
|
|
396
|
-
setFieldValue: setFieldValue,
|
|
397
|
-
valuePropName: valuePropName,
|
|
398
|
-
feedbackIcons: feedbackIcons,
|
|
399
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
400
|
-
// @ts-expect-error
|
|
401
|
-
size: childProps.size || props.size
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
return child;
|
|
405
|
-
}), !props.noStyle && errorMessage && jsx("span", {
|
|
406
|
-
ref: errorRef,
|
|
407
|
-
className: `${prefixCls}-error`,
|
|
408
|
-
children: errorMessage
|
|
409
|
-
})]
|
|
410
|
-
});
|
|
411
|
-
};
|
|
412
|
-
const FormItemChildComponent = ({
|
|
413
|
-
child,
|
|
414
|
-
name,
|
|
415
|
-
error,
|
|
416
|
-
fieldValue,
|
|
417
|
-
setFieldValue,
|
|
418
|
-
onChange,
|
|
419
|
-
valuePropName,
|
|
420
|
-
normalize,
|
|
421
|
-
...props
|
|
422
|
-
}) => {
|
|
423
|
-
const formContext = useContext(FormContext);
|
|
424
|
-
const [wasNormalize, setWasNormalize] = useState(false);
|
|
425
|
-
const {
|
|
426
|
-
getFieldsValue
|
|
427
|
-
} = formContext || {};
|
|
428
|
-
const handleChange = (e, option) => {
|
|
429
|
-
let rawValue = e?.target ? e.target.value : e;
|
|
430
|
-
if (normalize) {
|
|
431
|
-
const prevValue = fieldValue ?? props.value;
|
|
432
|
-
const allValues = getFieldsValue?.();
|
|
433
|
-
rawValue = normalize(rawValue, prevValue, allValues);
|
|
434
|
-
if (rawValue === prevValue) {
|
|
435
|
-
e.target.value = rawValue;
|
|
436
|
-
setWasNormalize(prev => !prev);
|
|
437
|
-
const timeout = setTimeout(() => {
|
|
438
|
-
document.querySelector(`[name='${name}']`)?.focus();
|
|
439
|
-
clearTimeout(timeout);
|
|
440
|
-
}, 0);
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
setFieldValue(valuePropName || name, rawValue);
|
|
445
|
-
onChange?.(e, option);
|
|
446
|
-
};
|
|
447
|
-
return /*#__PURE__*/createElement(child.type, {
|
|
448
|
-
...props,
|
|
449
|
-
name: name,
|
|
450
|
-
onChange: handleChange,
|
|
451
|
-
...(error ? {
|
|
452
|
-
error
|
|
453
|
-
} : {}),
|
|
454
|
-
key: `${name}_${wasNormalize}`,
|
|
455
|
-
value: fieldValue ?? props.value
|
|
456
|
-
});
|
|
457
|
-
};
|
|
458
|
-
FormItem.displayName = 'FormItem';
|
|
459
|
-
|
|
460
|
-
const FormContext = /*#__PURE__*/createContext(null);
|
|
461
|
-
const Form = ({
|
|
462
|
-
children,
|
|
463
|
-
form,
|
|
464
|
-
style = {},
|
|
465
|
-
prefixCls = prefixClsForm,
|
|
466
|
-
className = '',
|
|
467
|
-
onFinish,
|
|
468
|
-
onFinishFailed,
|
|
469
|
-
initialValues = {},
|
|
470
|
-
onValuesChange,
|
|
471
|
-
onFieldsChange,
|
|
472
|
-
layout = 'horizontal',
|
|
473
|
-
...rest
|
|
474
|
-
}) => {
|
|
475
|
-
const internalForm = useForm(initialValues, onFieldsChange, onValuesChange);
|
|
476
|
-
const formInstance = form || internalForm;
|
|
477
|
-
const formRef = useRef(null);
|
|
478
|
-
const handleSubmit = async e => {
|
|
479
|
-
e.preventDefault();
|
|
480
|
-
if (await formInstance.validateFields()) {
|
|
481
|
-
onFinish?.(formInstance.getFieldsValue());
|
|
482
|
-
} else if (onFinishFailed) {
|
|
483
|
-
const errorFields = formInstance.getFieldsError();
|
|
484
|
-
onFinishFailed({
|
|
485
|
-
values: formInstance.getFieldsValue(),
|
|
486
|
-
errorFields
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
|
-
const childrenList = useMemo(() => (Array.isArray(children) ? children : [children]).filter(Boolean), [children]);
|
|
491
|
-
useEffect(() => {
|
|
492
|
-
if (onFieldsChange) {
|
|
493
|
-
formInstance.onFieldsChange = onFieldsChange;
|
|
494
|
-
}
|
|
495
|
-
if (onValuesChange) {
|
|
496
|
-
formInstance.onValuesChange = onValuesChange;
|
|
497
|
-
}
|
|
498
|
-
}, [formInstance, onFieldsChange, onValuesChange]);
|
|
499
|
-
return jsx(FormContext.Provider, {
|
|
500
|
-
value: formInstance,
|
|
501
|
-
children: jsx("form", {
|
|
502
|
-
style: style,
|
|
503
|
-
ref: formRef,
|
|
504
|
-
onSubmit: handleSubmit,
|
|
505
|
-
className: `${prefixCls} ${className}`,
|
|
506
|
-
children: Children.map(childrenList, child => {
|
|
507
|
-
if (/*#__PURE__*/isValidElement(child) && child.type !== Fragment) {
|
|
508
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
509
|
-
// @ts-expect-error
|
|
510
|
-
const {
|
|
511
|
-
...childProps
|
|
512
|
-
} = child.props;
|
|
513
|
-
return jsx(child.type, {
|
|
514
|
-
...childProps,
|
|
515
|
-
child: child,
|
|
516
|
-
size: childProps.size || rest.size,
|
|
517
|
-
layout: childProps.layout || layout
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
return child;
|
|
521
|
-
})
|
|
522
|
-
})
|
|
523
|
-
});
|
|
524
|
-
};
|
|
525
|
-
Form.Item = FormItem;
|
|
526
|
-
|
|
527
|
-
var css_248z$j = ".xUi-rangepicker-range-container{font-size:14px;position:relative;user-select:none}.xUi-rangepicker-range-input-wrapper{background-color:#fff;border-radius:6px;display:flex;transition:all .3s;width:100%}.xUi-rangepicker-range-input-wrapper:hover{border-color:#4096ff}.xUi-rangepicker-range-input{align-items:center;border-right:1px solid var(--xui-border-color);cursor:pointer;display:flex;flex:1;padding:4px 11px}.xUi-rangepicker-range-input:last-child{border-right:none}.xUi-rangepicker-range-input input{background:transparent;border:none;color:#000;cursor:pointer;font-size:14px;outline:none;width:100%}.xUi-rangepicker-range-input input::placeholder{color:#bfbfbf}.xUi-rangepicker-range-clear,.xUi-rangepicker-range-icon{align-items:center;display:flex;margin-left:8px;transition:color .3s}.xUi-rangepicker-range-icon{color:rgba(0,0,0,.25)}.xUi-rangepicker-range-clear{color:rgba(0,0,0,.45);cursor:pointer}.xUi-rangepicker-range-clear:hover{color:#000}.xUi-rangepicker-range-dropdown-wrapper{background:#fff;border-radius:8px;box-shadow:0 4px 12px rgba(0,0,0,.15);display:none;left:0;margin-top:4px;min-width:560px;opacity:1;padding:8px;position:absolute;top:100%;transform:translateY(4px);transition:opacity .2s ease,transform .2s ease;z-index:1050}.xUi-rangepicker-range-dropdown-wrapper.show{display:flex}.xUi-rangepicker-dropdown-range,.xUi-rangepicker-range-dropdown{background-color:#fff;border:1px solid var(--xui-border-color);border-radius:6px;display:flex;margin-top:2px;overflow:hidden}.xUi-rangepicker-calendar{background:#fff;border-radius:6px;margin:12px}.xUi-rangepicker-calendar.month,.xUi-rangepicker-calendar.year{width:280px}.xUi-rangepicker-calendar-header{align-items:center;display:flex;font-weight:500;justify-content:space-between}.xUi-rangepicker-month,.xUi-rangepicker-year{background:none;border:none;border-radius:4px;color:var(--xui-text-color);cursor:pointer;height:30px;line-height:30px;margin:7px;min-width:30px;text-align:center;transition:all .2s}.xUi-rangepicker-day:disabled,.xUi-rangepicker-month:disabled,.xUi-rangepicker-select:disabled,.xUi-rangepicker-year:disabled{background-color:var(--xui-color-disabled);cursor:not-allowed;opacity:.5}.xUi-rangepicker-day:not(:disabled):hover,.xUi-rangepicker-month:not(:disabled):hover,.xUi-rangepicker-year:not(:disabled):hover{background:var(--xui-primary-color-light);color:#fff}.xUi-rangepicker-calendar-header button,.xUi-rangepicker-dropdown-selects button,.xUi-rangepicker-nav-buttons button{background:transparent;border:none;color:#595959;cursor:pointer;font-size:14px;font-weight:600;line-height:1;padding:0 6px;transition:color .2s ease}.xUi-rangepicker-nav-buttons button{font-size:20px;font-weight:400}.xUi-rangepicker-calendar-header button:hover,.xUi-rangepicker-dropdown-selects button:hover,.xUi-rangepicker-nav-buttons button:hover{color:var(--xui-primary-color)}.xUi-rangepicker-input{align-items:center;background-color:transparent;border:1px solid var(--xui-border-color);border-radius:6px;color:var(--xui-text-color);cursor:pointer;display:flex;gap:8px;justify-content:space-between;padding:3px 7px;transition:all .3s}.xUi-rangepicker-input.noBordered{border:none!important}.xUi-rangepicker-input input{border:none;color:var(--xui-text-color);font-size:var(--xui-font-size-sm);outline:none;padding:0}.xUi-rangepicker-input:placeholder-shown{text-overflow:ellipsis}.xUi-rangepicker-input:hover{border-color:var(--xui-primary-color)}.xUi-rangepicker-weekday-row{background-color:#fff;box-shadow:0 1px 0 rgba(0,0,0,.1);display:grid;gap:4px;grid-template-columns:repeat(7,1fr);position:sticky;top:0;z-index:1}.xUi-rangepicker-weekday{align-items:center;color:var(--xui-text-color);display:flex;font-size:12px;font-weight:500;font-weight:600;height:30px;justify-content:center;text-align:center}.xUi-rangepicker-days-grid,.xUi-rangepicker-grid{display:grid;gap:2px;grid-template-columns:repeat(3,1fr)}.xUi-rangepicker-days-grid.day{grid-template-columns:repeat(7,0fr)}.xUi-rangepicker-day{background-color:transparent;border:none;border-radius:4px;cursor:pointer;height:30px;line-height:30px;text-align:center;transition:background-color .3s,color .3s;width:30px}.xUi-rangepicker-day:hover{background-color:var(--xui-primary-color);border-radius:4px;color:#fff}.xUi-rangepicker-day.xUi-rangepicker-other-month:hover{background-color:var(--xui-color-disabled)!important;color:var(--xui-text-color)}.xUi-rangepicker-range-end:not(.xUi-rangepicker-other-month),.xUi-rangepicker-range-start:not(.xUi-rangepicker-other-month),.xUi-rangepicker-selected:not(.xUi-rangepicker-other-month){background-color:var(--xui-primary-color);color:#fff;font-weight:600}.xUi-rangepicker-in-range:not(.xUi-rangepicker-other-month){background-color:#f0f5ff}.xUi-rangepicker-hover-end{background-color:var(--xui-primary-color)!important}.xUi-rangepicker-disabled,.xUi-rangepicker-other-month{color:#ccc}.xUi-rangepicker-disabled{cursor:not-allowed}.xUi-rangepicker-footer{display:flex;grid-column:span 7;justify-content:center;padding-top:6px}.xUi-rangepicker-select{background:none;border:none;color:var(--xui-primary-color);cursor:pointer}.xUi-rangepicker-input.sm{font-size:var(--xui-font-size-sm);padding:4px 8px}.xUi-rangepicker-input.md{font-size:var(--xui-font-size-md);padding:8px 12px}.xUi-rangepicker-input.lg{font-size:var(--xui-font-size-lg);padding:10px 16px}.xUi-rangepicker-dropdown-wrapper{opacity:0;pointer-events:none;position:absolute;transform:scale(.95);transition:opacity .2s ease,transform .2s ease;z-index:1000}.xUi-rangepicker-dropdown-wrapper.bottomLeft{left:0;margin-top:4px;top:100%}.xUi-rangepicker-dropdown-wrapper.bottomRight{margin-top:4px;right:0;top:100%}.xUi-rangepicker-dropdown-wrapper.topLeft{bottom:100%;left:0;margin-bottom:4px}.xUi-rangepicker-dropdown-wrapper.topRight{bottom:100%;margin-bottom:4px;right:0}.xUi-rangepicker-dropdown-wrapper.show{opacity:1;pointer-events:auto;transform:scale(1)}.xUi-rangepicker-large .xUi-rangepicker-selected-date{font-size:16px}.xUi-rangepicker-large .xUi-rangepicker-input{padding:11px}.xUi-rangepicker-middle .xUi-rangepicker-input{padding:6px 11px}.xUi-rangepicker-dropdown-trigger{background-color:#fff;border:1px solid var(--xui-border-color);border-radius:2px;cursor:pointer;line-height:32px;padding:0 8px}.xUi-rangepicker-dropdown-menu{background:#fff;border:1px solid var(--xui-border-color);box-shadow:0 2px 8px rgba(0,0,0,.15);max-height:200px;overflow-y:auto;position:absolute;z-index:1000}.xUi-rangepicker-dropdown-item{cursor:pointer;padding:4px 12px}.xUi-rangepicker-dropdown-item:hover{background:#f5f5f5}.xUi-rangepicker-dropdown-item.active{background-color:#e6f7ff;font-weight:700}.xUi-rangepicker-header{align-items:center;border-bottom:1px solid var(--xui-border-color);display:flex;gap:8px;justify-content:space-between;margin-bottom:8px;padding-bottom:12px;width:100%}";
|
|
528
|
-
styleInject(css_248z$j);
|
|
529
|
-
|
|
530
|
-
const ClearIcon = () => jsx("svg", {
|
|
531
|
-
width: "10",
|
|
532
|
-
height: "10",
|
|
533
|
-
viewBox: "0 0 14 14",
|
|
534
|
-
fill: "none",
|
|
535
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
536
|
-
children: jsx("path", {
|
|
537
|
-
d: "M1 1L13 13M13 1L1 13",
|
|
538
|
-
stroke: "currentColor",
|
|
539
|
-
strokeWidth: "2",
|
|
540
|
-
strokeLinecap: "round"
|
|
541
|
-
})
|
|
542
|
-
});
|
|
543
|
-
const ArrowIcon = ({
|
|
544
|
-
isOpen
|
|
545
|
-
}) => jsx("svg", {
|
|
546
|
-
width: "18",
|
|
547
|
-
height: "18",
|
|
548
|
-
viewBox: "0 0 24 24",
|
|
549
|
-
fill: "none",
|
|
550
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
551
|
-
children: jsx("path", {
|
|
552
|
-
d: "M7 10L12 15L17 10",
|
|
553
|
-
stroke: "currentColor",
|
|
554
|
-
strokeWidth: "2",
|
|
555
|
-
strokeLinecap: "round",
|
|
556
|
-
strokeLinejoin: "round",
|
|
557
|
-
transform: isOpen ? 'rotate(180, 12, 12)' : ''
|
|
558
|
-
})
|
|
559
|
-
});
|
|
560
|
-
const LoadingIcon = () => jsx("svg", {
|
|
561
|
-
viewBox: "0 0 1024 1024",
|
|
562
|
-
focusable: "false",
|
|
563
|
-
"data-icon": "loading",
|
|
564
|
-
width: "12",
|
|
565
|
-
height: "12",
|
|
566
|
-
fill: "currentColor",
|
|
567
|
-
"aria-hidden": "true",
|
|
568
|
-
children: jsx("path", {
|
|
569
|
-
d: "M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
|
|
570
|
-
})
|
|
571
|
-
});
|
|
572
|
-
const CheckIcon = () => jsx("svg", {
|
|
573
|
-
viewBox: "64 64 896 896",
|
|
574
|
-
focusable: "false",
|
|
575
|
-
"data-icon": "check",
|
|
576
|
-
width: "12",
|
|
577
|
-
height: "12",
|
|
578
|
-
fill: "currentColor",
|
|
579
|
-
"aria-hidden": "true",
|
|
580
|
-
children: jsx("path", {
|
|
581
|
-
d: "M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 00-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z"
|
|
582
|
-
})
|
|
583
|
-
});
|
|
584
|
-
const SearchIcon = () => jsx("svg", {
|
|
585
|
-
viewBox: "64 64 896 896",
|
|
586
|
-
focusable: "false",
|
|
587
|
-
"data-icon": "search",
|
|
588
|
-
width: "1em",
|
|
589
|
-
height: "1em",
|
|
590
|
-
fill: "currentColor",
|
|
591
|
-
"aria-hidden": "true",
|
|
592
|
-
children: jsx("path", {
|
|
593
|
-
d: "M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"
|
|
594
|
-
})
|
|
595
|
-
});
|
|
596
|
-
const CalendarIcon = () => jsx("svg", {
|
|
597
|
-
viewBox: "64 64 896 896",
|
|
598
|
-
focusable: "false",
|
|
599
|
-
"data-icon": "calendar",
|
|
600
|
-
width: "1em",
|
|
601
|
-
height: "1em",
|
|
602
|
-
fill: "currentColor",
|
|
603
|
-
"aria-hidden": "true",
|
|
604
|
-
children: jsx("path", {
|
|
605
|
-
d: "M880 184H712v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H384v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H144c-17.7 0-32 14.3-32 32v664c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V216c0-17.7-14.3-32-32-32zm-40 656H184V460h656v380zM184 392V256h128v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h256v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h128v136H184z"
|
|
606
|
-
})
|
|
607
|
-
});
|
|
608
|
-
const SuccessIcon = () => jsx("svg", {
|
|
609
|
-
viewBox: "64 64 896 896",
|
|
610
|
-
focusable: "false",
|
|
611
|
-
"data-icon": "check-circle",
|
|
612
|
-
width: "1em",
|
|
613
|
-
height: "1em",
|
|
614
|
-
fill: "currentColor",
|
|
615
|
-
"aria-hidden": "true",
|
|
616
|
-
children: jsx("path", {
|
|
617
|
-
d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 01-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z"
|
|
618
|
-
})
|
|
619
|
-
});
|
|
620
|
-
const ErrorIcon = () => jsx("svg", {
|
|
621
|
-
className: "error-svg-icon",
|
|
622
|
-
viewBox: "64 64 896 896",
|
|
623
|
-
focusable: "false",
|
|
624
|
-
"data-icon": "close-circle",
|
|
625
|
-
width: "1em",
|
|
626
|
-
height: "1em",
|
|
627
|
-
fill: "currentColor",
|
|
628
|
-
"aria-hidden": "true",
|
|
629
|
-
children: jsx("path", {
|
|
630
|
-
d: "M512 64c247.4 0 448 200.6 448 448S759.4 960 512 960 64 759.4 64 512 264.6 64 512 64zm127.98 274.82h-.04l-.08.06L512 466.75 384.14 338.88c-.04-.05-.06-.06-.08-.06a.12.12 0 00-.07 0c-.03 0-.05.01-.09.05l-45.02 45.02a.2.2 0 00-.05.09.12.12 0 000 .07v.02a.27.27 0 00.06.06L466.75 512 338.88 639.86c-.05.04-.06.06-.06.08a.12.12 0 000 .07c0 .03.01.05.05.09l45.02 45.02a.2.2 0 00.09.05.12.12 0 00.07 0c.02 0 .04-.01.08-.05L512 557.25l127.86 127.87c.04.04.06.05.08.05a.12.12 0 00.07 0c.03 0 .05-.01.09-.05l45.02-45.02a.2.2 0 00.05-.09.12.12 0 000-.07v-.02a.27.27 0 00-.05-.06L557.25 512l127.87-127.86c.04-.04.05-.06.05-.08a.12.12 0 000-.07c0-.03-.01-.05-.05-.09l-45.02-45.02a.2.2 0 00-.09-.05.12.12 0 00-.07 0z"
|
|
631
|
-
})
|
|
632
|
-
});
|
|
633
|
-
const DateDistanceIcon = () => jsx("svg", {
|
|
634
|
-
viewBox: "0 0 1024 1024",
|
|
635
|
-
focusable: "false",
|
|
636
|
-
"data-icon": "swap-right",
|
|
637
|
-
width: "1em",
|
|
638
|
-
height: "1em",
|
|
639
|
-
fill: "currentColor",
|
|
640
|
-
"aria-hidden": "true",
|
|
641
|
-
children: jsx("path", {
|
|
642
|
-
d: "M873.1 596.2l-164-208A32 32 0 00684 376h-64.8c-6.7 0-10.4 7.7-6.3 13l144.3 183H152c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h695.9c26.8 0 41.7-30.8 25.2-51.8z"
|
|
643
|
-
})
|
|
644
|
-
});
|
|
645
|
-
const TimeIcon = () => jsxs("svg", {
|
|
646
|
-
viewBox: "64 64 896 896",
|
|
647
|
-
focusable: "false",
|
|
648
|
-
"data-icon": "clock-circle",
|
|
649
|
-
width: "1em",
|
|
650
|
-
height: "1em",
|
|
651
|
-
fill: "currentColor",
|
|
652
|
-
"aria-hidden": "true",
|
|
653
|
-
children: [jsx("path", {
|
|
654
|
-
d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"
|
|
655
|
-
}), jsx("path", {
|
|
656
|
-
d: "M686.7 638.6L544.1 535.5V288c0-4.4-3.6-8-8-8H488c-4.4 0-8 3.6-8 8v275.4c0 2.6 1.2 5 3.3 6.5l165.4 120.6c3.6 2.6 8.6 1.8 11.2-1.7l28.6-39c2.6-3.7 1.8-8.7-1.8-11.2z"
|
|
657
|
-
})]
|
|
658
|
-
});
|
|
659
|
-
const StampleIcon = () => jsx("svg", {
|
|
660
|
-
viewBox: "64 64 896 896",
|
|
661
|
-
focusable: "false",
|
|
662
|
-
"data-icon": "paper-clip",
|
|
663
|
-
width: "1em",
|
|
664
|
-
height: "1em",
|
|
665
|
-
fill: "currentColor",
|
|
666
|
-
"aria-hidden": "true",
|
|
667
|
-
children: jsx("path", {
|
|
668
|
-
d: "M779.3 196.6c-94.2-94.2-247.6-94.2-341.7 0l-261 260.8c-1.7 1.7-2.6 4-2.6 6.4s.9 4.7 2.6 6.4l36.9 36.9a9 9 0 0012.7 0l261-260.8c32.4-32.4 75.5-50.2 121.3-50.2s88.9 17.8 121.2 50.2c32.4 32.4 50.2 75.5 50.2 121.2 0 45.8-17.8 88.8-50.2 121.2l-266 265.9-43.1 43.1c-40.3 40.3-105.8 40.3-146.1 0-19.5-19.5-30.2-45.4-30.2-73s10.7-53.5 30.2-73l263.9-263.8c6.7-6.6 15.5-10.3 24.9-10.3h.1c9.4 0 18.1 3.7 24.7 10.3 6.7 6.7 10.3 15.5 10.3 24.9 0 9.3-3.7 18.1-10.3 24.7L372.4 653c-1.7 1.7-2.6 4-2.6 6.4s.9 4.7 2.6 6.4l36.9 36.9a9 9 0 0012.7 0l215.6-215.6c19.9-19.9 30.8-46.3 30.8-74.4s-11-54.6-30.8-74.4c-41.1-41.1-107.9-41-149 0L463 364 224.8 602.1A172.22 172.22 0 00174 724.8c0 46.3 18.1 89.8 50.8 122.5 33.9 33.8 78.3 50.7 122.7 50.7 44.4 0 88.8-16.9 122.6-50.7l309.2-309C824.8 492.7 850 432 850 367.5c.1-64.6-25.1-125.3-70.7-170.9z"
|
|
669
|
-
})
|
|
670
|
-
});
|
|
671
|
-
const TrashIcon = () => jsx("svg", {
|
|
672
|
-
viewBox: "64 64 896 896",
|
|
673
|
-
focusable: "false",
|
|
674
|
-
"data-icon": "delete",
|
|
675
|
-
width: "1em",
|
|
676
|
-
height: "1em",
|
|
677
|
-
fill: "currentColor",
|
|
678
|
-
"aria-hidden": "true",
|
|
679
|
-
children: jsx("path", {
|
|
680
|
-
d: "M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"
|
|
681
|
-
})
|
|
682
|
-
});
|
|
683
|
-
const SpinerIcon = () => jsx("svg", {
|
|
684
|
-
viewBox: "0 0 1024 1024",
|
|
685
|
-
focusable: "false",
|
|
686
|
-
"data-icon": "loading",
|
|
687
|
-
width: "1em",
|
|
688
|
-
height: "1em",
|
|
689
|
-
fill: "currentColor",
|
|
690
|
-
"aria-hidden": "true",
|
|
691
|
-
children: jsx("path", {
|
|
692
|
-
d: "M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
|
|
693
|
-
})
|
|
694
|
-
});
|
|
695
|
-
|
|
696
|
-
const RangePicker = ({
|
|
697
|
-
prefixCls = prefixClsRangePicker,
|
|
698
|
-
value,
|
|
699
|
-
onChange,
|
|
700
|
-
placeholder = ['Start date', 'End date'],
|
|
701
|
-
disabled,
|
|
702
|
-
error,
|
|
703
|
-
format = 'YYYY-MM-DD',
|
|
704
|
-
prefix,
|
|
705
|
-
allowClear = true,
|
|
706
|
-
inputReadOnly = false,
|
|
707
|
-
size = 'large',
|
|
708
|
-
picker = 'date',
|
|
709
|
-
locale,
|
|
710
|
-
disabledDate,
|
|
711
|
-
style = {},
|
|
712
|
-
className = '',
|
|
713
|
-
separator,
|
|
714
|
-
defaultValue,
|
|
715
|
-
bordered = true
|
|
716
|
-
}) => {
|
|
717
|
-
const containerRef = useRef(null);
|
|
718
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
719
|
-
const [selectedDates, setSelectedDates] = useState([value?.[0] || defaultValue?.[0] || null, value?.[1] || defaultValue?.[1] || null]);
|
|
720
|
-
const [hoveredDate, setHoveredDate] = useState(null);
|
|
721
|
-
const [currentMonth, setCurrentMonth] = useState(new Date().getMonth());
|
|
722
|
-
const [currentYear, setCurrentYear] = useState(new Date().getFullYear());
|
|
723
|
-
const [viewMode, setViewMode] = useState(picker === 'month' ? 'month' : picker === 'year' ? 'year' : 'day');
|
|
724
|
-
const localeMonths = locale?.shortMonths || Array.from({
|
|
725
|
-
length: 12
|
|
726
|
-
}, (_, i) => new Date(0, i).toLocaleString(locale?.locale || 'default', {
|
|
727
|
-
month: 'short'
|
|
728
|
-
}));
|
|
729
|
-
const localeWeekdays = locale?.shortWeekDays || ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
730
|
-
useEffect(() => {
|
|
731
|
-
const handleClickOutside = event => {
|
|
732
|
-
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
733
|
-
setIsOpen(false);
|
|
734
|
-
}
|
|
735
|
-
};
|
|
736
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
737
|
-
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
738
|
-
}, []);
|
|
739
|
-
const handleSelect = date => {
|
|
740
|
-
if (!selectedDates[0] || selectedDates[0] && selectedDates[1]) {
|
|
741
|
-
setSelectedDates([date, null]);
|
|
742
|
-
} else {
|
|
743
|
-
const start = selectedDates[0];
|
|
744
|
-
const end = date < start ? start : date;
|
|
745
|
-
const begin = date < start ? date : start;
|
|
746
|
-
setSelectedDates([begin, end]);
|
|
747
|
-
onChange?.([begin.toUTCString(), end.toUTCString()], [formatDate(begin), formatDate(end)]);
|
|
748
|
-
setIsOpen(false);
|
|
749
|
-
}
|
|
750
|
-
};
|
|
751
|
-
const isMonthDisabled = month => {
|
|
752
|
-
const date = new Date(currentYear, month + 1, 1);
|
|
753
|
-
return disabledDate?.(date, {
|
|
754
|
-
from: undefined,
|
|
755
|
-
to: undefined
|
|
756
|
-
});
|
|
757
|
-
};
|
|
758
|
-
const isYearDisabled = year => {
|
|
759
|
-
const date = new Date(year + 1, currentMonth, 1);
|
|
760
|
-
return disabledDate?.(date, {
|
|
761
|
-
from: undefined,
|
|
762
|
-
to: undefined
|
|
763
|
-
});
|
|
764
|
-
};
|
|
765
|
-
const formatDate = date => {
|
|
766
|
-
if (typeof format === 'function') {
|
|
767
|
-
return format(date);
|
|
768
|
-
}
|
|
769
|
-
return `${format}`.replace(/YYYY/, date.getFullYear().toString()).replace(/MM/, (date.getMonth() + 1).toString().padStart(2, '0')).replace(/DD/, date.getDate().toString().padStart(2, '0'));
|
|
770
|
-
};
|
|
771
|
-
const isInRange = date => {
|
|
772
|
-
const [start, end] = selectedDates;
|
|
773
|
-
return start && end && date > start && date < end;
|
|
774
|
-
};
|
|
775
|
-
const renderMonthYearSelector = (monthOffset = 0, all) => {
|
|
776
|
-
const baseYear = currentYear;
|
|
777
|
-
const baseMonth = currentMonth + monthOffset;
|
|
778
|
-
return jsxs("div", {
|
|
779
|
-
className: `${prefixCls}-header`,
|
|
780
|
-
children: [all || !monthOffset ? jsxs("div", {
|
|
781
|
-
className: `${prefixCls}-nav-buttons`,
|
|
782
|
-
children: [jsx("button", {
|
|
783
|
-
onClick: () => setCurrentYear(y => y - 1),
|
|
784
|
-
children: "\u00AB"
|
|
785
|
-
}), jsx("button", {
|
|
786
|
-
onClick: () => setCurrentMonth(m => m === 0 ? (setCurrentYear(y => y - 1), MONTH_LENGTH) : m - 1),
|
|
787
|
-
children: "\u2039"
|
|
788
|
-
})]
|
|
789
|
-
}) : jsx("span", {}), jsxs("div", {
|
|
790
|
-
className: `${prefixCls}-dropdown-selects`,
|
|
791
|
-
children: [jsx("button", {
|
|
792
|
-
type: "button",
|
|
793
|
-
className: `${prefixCls}-select`,
|
|
794
|
-
onClick: () => setViewMode('year'),
|
|
795
|
-
children: baseYear
|
|
796
|
-
}), jsx("button", {
|
|
797
|
-
type: "button",
|
|
798
|
-
className: `${prefixCls}-select`,
|
|
799
|
-
onClick: () => setViewMode('month'),
|
|
800
|
-
children: localeMonths[baseMonth]
|
|
801
|
-
})]
|
|
802
|
-
}), all || monthOffset ? jsxs("div", {
|
|
803
|
-
className: `${prefixCls}-nav-buttons`,
|
|
804
|
-
children: [jsx("button", {
|
|
805
|
-
onClick: () => setCurrentMonth(m => m === MONTH_LENGTH ? (setCurrentYear(y => y + 1), 0) : m + 1),
|
|
806
|
-
children: "\u203A"
|
|
807
|
-
}), jsx("button", {
|
|
808
|
-
onClick: () => setCurrentYear(y => y + 1),
|
|
809
|
-
children: "\u00BB"
|
|
810
|
-
})]
|
|
811
|
-
}) : jsx("span", {})]
|
|
812
|
-
});
|
|
813
|
-
};
|
|
814
|
-
const renderCalendar = (monthOffset = 0, all) => {
|
|
815
|
-
const baseDate = new Date(currentYear, currentMonth + monthOffset, 1);
|
|
816
|
-
const year = baseDate.getFullYear();
|
|
817
|
-
const month = baseDate.getMonth();
|
|
818
|
-
const firstDay = new Date(year, month, 1).getDay();
|
|
819
|
-
const daysInMonth = new Date(year, month + 1, 0).getDate();
|
|
820
|
-
const prevMonthDays = (() => {
|
|
821
|
-
const prevMonth = new Date(year, month, 0);
|
|
822
|
-
const totalDays = prevMonth.getDate();
|
|
823
|
-
return Array.from({
|
|
824
|
-
length: firstDay
|
|
825
|
-
}, (_, i) => new Date(year, month - 1, totalDays - firstDay + i + 1));
|
|
826
|
-
})();
|
|
827
|
-
const currentMonthDays = Array.from({
|
|
828
|
-
length: daysInMonth
|
|
829
|
-
}, (_, i) => new Date(year, month, i + 1));
|
|
830
|
-
const totalDisplayed = prevMonthDays.length + currentMonthDays.length;
|
|
831
|
-
const remaining = NEXT_DAYS_COUNT_AS_CURRENT_MUNTH - totalDisplayed;
|
|
832
|
-
const nextMonthDays = Array.from({
|
|
833
|
-
length: remaining
|
|
834
|
-
}, (_, i) => new Date(year, month + 1, i + 1));
|
|
835
|
-
const days = [...prevMonthDays, ...currentMonthDays, ...nextMonthDays];
|
|
836
|
-
return jsxs("div", {
|
|
837
|
-
className: `${prefixCls}-calendar ${viewMode}`,
|
|
838
|
-
children: [jsx("div", {
|
|
839
|
-
className: `${prefixCls}-calendar-header`,
|
|
840
|
-
children: renderMonthYearSelector(monthOffset, all)
|
|
841
|
-
}), viewMode === 'day' && jsxs("div", {
|
|
842
|
-
className: `${prefixCls}-days-grid day`,
|
|
843
|
-
children: [localeWeekdays.map((day, i) => jsx("div", {
|
|
844
|
-
className: `${prefixCls}-weekday`,
|
|
845
|
-
children: day
|
|
846
|
-
}, i)), days.map((day, i) => {
|
|
847
|
-
const isSelected = day && selectedDates.some(d => d?.toDateString() === day.toDateString());
|
|
848
|
-
const inRange = day && isInRange(day);
|
|
849
|
-
const isSameMonth = day?.getMonth() === month;
|
|
850
|
-
return jsx("button", {
|
|
851
|
-
disabled: disabledDate?.(day, {
|
|
852
|
-
from: undefined,
|
|
853
|
-
to: undefined
|
|
854
|
-
}),
|
|
855
|
-
onClick: () => day && handleSelect(day),
|
|
856
|
-
onMouseEnter: () => day && setHoveredDate(day),
|
|
857
|
-
className: clsx([`${prefixCls}-day`, {
|
|
858
|
-
[`${prefixCls}-selected`]: isSelected,
|
|
859
|
-
[`${prefixCls}-in-range`]: inRange,
|
|
860
|
-
[`${prefixCls}-hover-end`]: hoveredDate && selectedDates[0] && !selectedDates[1] && hoveredDate > selectedDates[0] && hoveredDate.toDateString() === day?.toDateString(),
|
|
861
|
-
[`${prefixCls}-other-month`]: !isSameMonth
|
|
862
|
-
}]),
|
|
863
|
-
children: day?.getDate()
|
|
864
|
-
}, i);
|
|
865
|
-
})]
|
|
866
|
-
}), viewMode === 'month' && jsx("div", {
|
|
867
|
-
className: `${prefixCls}-grid`,
|
|
868
|
-
children: localeMonths.map((m, i) => jsx("button", {
|
|
869
|
-
className: `${prefixCls}-month`,
|
|
870
|
-
onClick: () => {
|
|
871
|
-
setCurrentMonth(i);
|
|
872
|
-
setViewMode('day');
|
|
873
|
-
},
|
|
874
|
-
disabled: isMonthDisabled(i),
|
|
875
|
-
children: m
|
|
876
|
-
}, i))
|
|
877
|
-
}), viewMode === 'year' && jsx("div", {
|
|
878
|
-
className: `${prefixCls}-grid`,
|
|
879
|
-
children: Array.from({
|
|
880
|
-
length: 12
|
|
881
|
-
}, (_, i) => {
|
|
882
|
-
const year = currentYear - NUMBER_SIX + i;
|
|
883
|
-
return jsx("button", {
|
|
884
|
-
className: `${prefixCls}-year`,
|
|
885
|
-
disabled: isYearDisabled(year),
|
|
886
|
-
onClick: () => {
|
|
887
|
-
setCurrentYear(year);
|
|
888
|
-
setViewMode('month');
|
|
889
|
-
},
|
|
890
|
-
children: year
|
|
891
|
-
}, year);
|
|
892
|
-
})
|
|
893
|
-
})]
|
|
894
|
-
});
|
|
895
|
-
};
|
|
896
|
-
const handleClear = () => {
|
|
897
|
-
setSelectedDates([null, null]);
|
|
898
|
-
onChange?.(null, ['', '']);
|
|
899
|
-
};
|
|
900
|
-
return jsxs("div", {
|
|
901
|
-
ref: containerRef,
|
|
902
|
-
style: style,
|
|
903
|
-
className: clsx([`${prefixCls}-range-container`, {
|
|
904
|
-
[`${prefixCls}-${size}`]: size,
|
|
905
|
-
[className]: className
|
|
906
|
-
}]),
|
|
907
|
-
children: [jsx("div", {
|
|
908
|
-
className: `${prefixCls}-range-input-wrapper`,
|
|
909
|
-
children: jsxs("button", {
|
|
910
|
-
type: "button",
|
|
911
|
-
className: clsx([`${prefixCls}-input`, {
|
|
912
|
-
noBordered: !bordered,
|
|
913
|
-
[`${prefixCls}-error`]: error,
|
|
914
|
-
[`${prefixCls}-disabled`]: disabled
|
|
915
|
-
}]),
|
|
916
|
-
disabled: disabled,
|
|
917
|
-
onClick: () => setIsOpen(!isOpen),
|
|
918
|
-
children: [prefix, jsx("input", {
|
|
919
|
-
readOnly: inputReadOnly,
|
|
920
|
-
className: `${prefixCls}-selected-date`,
|
|
921
|
-
placeholder: placeholder[0],
|
|
922
|
-
value: selectedDates[0] ? formatDate(selectedDates[0]) : ''
|
|
923
|
-
}), jsx("span", {
|
|
924
|
-
className: `${prefixCls}-range-separator`,
|
|
925
|
-
children: separator || jsx(DateDistanceIcon, {})
|
|
926
|
-
}), jsx("input", {
|
|
927
|
-
readOnly: inputReadOnly,
|
|
928
|
-
className: `${prefixCls}-selected-date`,
|
|
929
|
-
placeholder: placeholder[1],
|
|
930
|
-
value: selectedDates[1] ? formatDate(selectedDates[1]) : ''
|
|
931
|
-
}), jsx("span", {
|
|
932
|
-
className: `${prefixCls}-icon`,
|
|
933
|
-
children: allowClear && (selectedDates[0] || selectedDates[1]) ? jsx("span", {
|
|
934
|
-
className: `${prefixCls}-clear`,
|
|
935
|
-
onClick: handleClear,
|
|
936
|
-
children: jsx(ClearIcon, {})
|
|
937
|
-
}) : jsx(CalendarIcon, {})
|
|
938
|
-
})]
|
|
939
|
-
})
|
|
940
|
-
}), isOpen && jsx("div", {
|
|
941
|
-
className: `${prefixCls}-dropdown-wrapper show`,
|
|
942
|
-
children: jsxs("div", {
|
|
943
|
-
className: `${prefixCls}-dropdown-range`,
|
|
944
|
-
children: [renderCalendar(0, viewMode !== 'day'), viewMode === 'day' && renderCalendar(1, viewMode !== 'day')]
|
|
945
|
-
})
|
|
946
|
-
})]
|
|
947
|
-
});
|
|
948
|
-
};
|
|
949
|
-
|
|
950
|
-
var css_248z$i = ".xUi-datepicker-container{font-family:Arial,sans-serif;height:max-content;position:relative}.xUi-datepicker-input{align-items:center;background-color:transparent;border:1px solid var(--xui-border-color);border-radius:6px;color:var(--xui-text-color);cursor:pointer;display:flex;gap:8px;justify-content:space-between;padding:3px 7px;transition:all .3s}.xUi-datepicker-input.noBordered{border:none!important}.xUi-datepicker-input input{border:none;color:var(--xui-text-color);font-size:var(--xui-font-size-sm);outline:none;padding:0}.xUi-datepicker-input:placeholder-shown{text-overflow:ellipsis}.xUi-datepicker-input:hover{border-color:var(--xui-primary-color)}.xUi-datepicker-icon{color:var(--xui-text-color);cursor:pointer;height:16px;opacity:.6;transition:.3s ease;width:16px}.xUi-datepicker-icon:hover{color:var(--xui-primary-color);opacity:1}.xUi-datepicker-selected-date{border:none;color:var(--xui-text-color);font-size:var(--xui-font-size-md);letter-spacing:.8px;outline:none}.xUi-datepicker-disabled{background-color:var(--xui-color-disabled);border-color:var(--xui-border-color)!important;cursor:not-allowed;opacity:.5}.xUi-datepicker-disabled .xUi-datepicker-selected-date{cursor:not-allowed;opacity:.6}.xUi-datepicker-disabled .xUi-datepicker-icon{cursor:not-allowed}.xUi-datepicker-icon{align-items:center;color:#8c8c8c;display:flex;font-size:16px;gap:6px}.xUi-datepicker-error{border-color:var(--xui-error-color)}.xUi-datepicker-error .error-svg-icon,.xUi-datepicker-error .xUi-datepicker-icon,.xUi-datepicker-icon .error-svg-icon{color:var(--xui-error-color)}.xUi-datepicker-input.sm{font-size:var(--xui-font-size-sm);padding:4px 8px}.xUi-datepicker-input.md{font-size:var(--xui-font-size-md);padding:8px 12px}.xUi-datepicker-input.lg{font-size:var(--xui-font-size-lg);padding:10px 16px}.xUi-datepicker-dropdown-wrapper{opacity:0;pointer-events:none;position:absolute;transform:scale(.95);transition:opacity .2s ease,transform .2s ease;z-index:1000}.xUi-datepicker-dropdown-wrapper.bottomLeft{left:0;margin-top:4px;top:100%}.xUi-datepicker-dropdown-wrapper.bottomRight{margin-top:4px;right:0;top:100%}.xUi-datepicker-dropdown-wrapper.topLeft{bottom:100%;left:0;margin-bottom:4px}.xUi-datepicker-dropdown-wrapper.topRight{bottom:100%;margin-bottom:4px;right:0}.xUi-datepicker-dropdown-wrapper.show{opacity:1;pointer-events:auto;transform:scale(1)}.xUi-datepicker-dropdown{background:var(--xui-background-color);border:1px solid var(--xui-border-color);border-radius:4px;box-shadow:0 2px 8px rgba(0,0,0,.15);min-width:250px;padding:12px}.xUi-datepicker-header{align-items:center;border-bottom:1px solid var(--xui-border-color);display:flex;gap:8px;justify-content:space-between;margin-bottom:8px;padding-bottom:12px}.xUi-datepicker-day-footer{align-items:center;border-top:1px solid var(--xui-border-color);display:flex;justify-content:center;margin-top:8px;padding-top:12px;width:100%}.xUi-datepicker-nav-buttons{display:flex;gap:4px}.xUi-datepicker-nav-buttons button{background:none;border:none;border-radius:4px;color:var(--xui-text-color);cursor:pointer;font-size:20px;opacity:.7;padding:2px 6px;transition:all .3s}.xUi-datepicker-nav-buttons button:not(:disabled):hover{color:var(--xui-primary-color)}.xUi-datepicker-dropdown-selects{align-items:center;display:flex;gap:6px}.xUi-datepicker-dropdown-selects button,.xUi-datepicker-select{background:var(--xui-background-color);border:none;border-radius:4px;color:var(--xui-text-color);cursor:pointer;font-weight:600;padding:4px 8px;transition:all .3s}.xUi-datepicker-dropdown-selects button:hover,.xUi-datepicker-select:not(:disabled):hover{color:var(--xui-primary-color)}.xUi-datepicker-grid{display:grid;gap:2px;grid-template-columns:repeat(3,1fr);text-align:center}.xUi-datepicker-grid.day{grid-template-columns:repeat(7,1fr)}.xUi-datepicker-day-header{color:var(--xui-text-color);font-size:14px;margin:4px 0;user-select:none}.xUi-datepicker-day,.xUi-datepicker-month,.xUi-datepicker-year{background:none;border:none;border-radius:4px;color:var(--xui-text-color);cursor:pointer;height:30px;line-height:30px;min-width:30px;text-align:center;transition:all .2s}.xUi-datepicker-month,.xUi-datepicker-year{margin:7px}.xUi-datepicker-day:disabled,.xUi-datepicker-month:disabled,.xUi-datepicker-select:disabled,.xUi-datepicker-year:disabled{background-color:var(--xui-color-disabled);cursor:not-allowed;opacity:.5}.xUi-datepicker-day:not(:disabled):hover,.xUi-datepicker-month:not(:disabled):hover,.xUi-datepicker-year:not(:disabled):hover{background:var(--xui-primary-color-light);color:#fff}.xUi-datepicker-selected{background:var(--xui-primary-color)!important;color:#fff!important;font-weight:700}.xUi-datepicker-other-month{color:var(--xui-text-color);opacity:.4}.xUi-datepicker-other-month:not(:disabled):hover{background-color:var(--xui-color-hover);color:var(--xui-text-color);user-select:none}.xUi-datepicker-footer{margin-top:12px;text-align:right}.xUi-datepicker-footer-today-btn{background:none;border:1px solid var(--xui-border-color);border-radius:4px;color:var(--xui-primary-color);cursor:pointer;font-size:13px;padding:4px 8px;transition:all .3s}.xUi-datepicker-footer-today-btn:not(:disabled):hover{background-color:var(--xui-primary-color-light);color:#fff}.xUi-datepicker-large .xUi-datepicker-selected-date{font-size:16px}.xUi-datepicker-large .xUi-datepicker-input{padding:11px}.xUi-datepicker-middle .xUi-datepicker-input{padding:6px 11px}";
|
|
951
|
-
styleInject(css_248z$i);
|
|
952
|
-
|
|
953
|
-
const INPUT_SIZE$1 = 12;
|
|
954
|
-
const CONTENT_PADDING = 6;
|
|
955
|
-
const NUMBER_SIX = 6;
|
|
956
|
-
const MONTH_LENGTH = 11;
|
|
957
|
-
const NEXT_DAYS_COUNT_AS_CURRENT_MUNTH = 35;
|
|
958
|
-
const DatePickerComponent = ({
|
|
959
|
-
value,
|
|
960
|
-
onChange,
|
|
961
|
-
onCalendarChange,
|
|
962
|
-
disabled,
|
|
963
|
-
error,
|
|
964
|
-
placeholder = 'Select date',
|
|
965
|
-
prefixCls = prefixClsDatePicker,
|
|
966
|
-
noStyle,
|
|
967
|
-
feedbackIcons,
|
|
968
|
-
locale,
|
|
969
|
-
placement = 'bottomLeft',
|
|
970
|
-
defaultValue,
|
|
971
|
-
size = 'large',
|
|
972
|
-
format = 'YYYY-MM-DD',
|
|
973
|
-
getPopupContainer,
|
|
974
|
-
showToday = true,
|
|
975
|
-
allowClear = false,
|
|
976
|
-
disabledDate,
|
|
977
|
-
suffixIcon,
|
|
978
|
-
picker = 'date',
|
|
979
|
-
prefix,
|
|
980
|
-
defaultOpen = false,
|
|
981
|
-
inputReadOnly = false,
|
|
982
|
-
bordered = true
|
|
983
|
-
}) => {
|
|
984
|
-
const containerRef = useRef(null);
|
|
985
|
-
const initialDate = value || defaultValue;
|
|
986
|
-
const popupContainerRef = useRef(null);
|
|
987
|
-
const [placementPossition, setPlacementPossition] = useState({});
|
|
988
|
-
const DateNow = new Date();
|
|
989
|
-
const [selectedDate, setSelectedDate] = useState(initialDate);
|
|
990
|
-
const [selectedDatePlaceholder, setSelectedDatePlaceholder] = useState(initialDate ? formatDate(initialDate) : undefined);
|
|
991
|
-
const [isOpen, setIsOpen] = useState(defaultOpen);
|
|
992
|
-
const [currentYear, setCurrentYear] = useState(initialDate ? new Date(initialDate).getFullYear() : DateNow.getFullYear());
|
|
993
|
-
const [currentMonth, setCurrentMonth] = useState(initialDate ? new Date(initialDate).getMonth() : DateNow.getMonth());
|
|
994
|
-
const [viewMode, setViewMode] = useState(picker === 'month' ? 'month' : picker === 'year' ? 'year' : 'day');
|
|
995
|
-
const localeMonths = locale?.shortMonths || Array.from({
|
|
996
|
-
length: 12
|
|
997
|
-
}, (_, i) => new Date(0, i).toLocaleString(locale?.locale || 'default', {
|
|
998
|
-
month: 'short'
|
|
999
|
-
}));
|
|
1000
|
-
const localeWeekdays = locale?.shortWeekDays || ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
1001
|
-
useEffect(() => {
|
|
1002
|
-
const handleClickOutside = event => {
|
|
1003
|
-
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
1004
|
-
setIsOpen(false);
|
|
1005
|
-
}
|
|
1006
|
-
};
|
|
1007
|
-
const controller = new AbortController();
|
|
1008
|
-
if (isOpen) {
|
|
1009
|
-
calculateDatePickerPopupPossition();
|
|
1010
|
-
document.addEventListener('scroll', calculateDatePickerPopupPossition, {
|
|
1011
|
-
signal: controller.signal
|
|
1012
|
-
});
|
|
1013
|
-
document.addEventListener('mousedown', handleClickOutside, {
|
|
1014
|
-
signal: controller.signal
|
|
1015
|
-
});
|
|
1016
|
-
}
|
|
1017
|
-
return () => {
|
|
1018
|
-
controller.abort();
|
|
1019
|
-
};
|
|
1020
|
-
}, [isOpen]);
|
|
1021
|
-
useEffect(() => {
|
|
1022
|
-
if (getPopupContainer && containerRef.current) {
|
|
1023
|
-
popupContainerRef.current = getPopupContainer(containerRef.current);
|
|
1024
|
-
}
|
|
1025
|
-
}, [getPopupContainer]);
|
|
1026
|
-
const daysInMonth = (year, month) => new Date(year, month + 1, 0).getDate();
|
|
1027
|
-
const firstDayOfMonth = (year, month) => new Date(year, month, 1).getDay();
|
|
1028
|
-
function formatDate(date) {
|
|
1029
|
-
if (typeof format === 'function') {
|
|
1030
|
-
return format(date);
|
|
1031
|
-
}
|
|
1032
|
-
if (typeof format === 'string') {
|
|
1033
|
-
date = new Date(date);
|
|
1034
|
-
return format.replace(/YYYY/, date.getFullYear().toString()).replace(/MM/, (date.getMonth() + 1).toString().padStart(2, '0')).replace(/DD/, date.getDate().toString().padStart(2, '0'));
|
|
1035
|
-
}
|
|
1036
|
-
return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
|
|
1037
|
-
}
|
|
1038
|
-
const handleSelect = (day, month, year) => {
|
|
1039
|
-
if (disabled) {
|
|
1040
|
-
return;
|
|
1041
|
-
}
|
|
1042
|
-
const date = new Date(year, month, day);
|
|
1043
|
-
if (disabledDate?.(date, {
|
|
1044
|
-
from: undefined,
|
|
1045
|
-
to: undefined
|
|
1046
|
-
})) {
|
|
1047
|
-
return;
|
|
1048
|
-
}
|
|
1049
|
-
setCurrentMonth(month);
|
|
1050
|
-
setCurrentYear(year);
|
|
1051
|
-
setSelectedDate(date);
|
|
1052
|
-
const formatted = formatDate(date);
|
|
1053
|
-
setSelectedDatePlaceholder(formatted);
|
|
1054
|
-
onChange?.(date.toUTCString(), formatted);
|
|
1055
|
-
onCalendarChange?.(date.toUTCString(), formatted, {
|
|
1056
|
-
range: undefined
|
|
1057
|
-
});
|
|
1058
|
-
setIsOpen(false);
|
|
1059
|
-
};
|
|
1060
|
-
const clearSelection = () => {
|
|
1061
|
-
setSelectedDate(undefined);
|
|
1062
|
-
setSelectedDatePlaceholder(undefined);
|
|
1063
|
-
onChange?.(null, '');
|
|
1064
|
-
};
|
|
1065
|
-
const isMonthDisabled = month => {
|
|
1066
|
-
const date = new Date(currentYear, month + 1, 1);
|
|
1067
|
-
return disabledDate?.(date, {
|
|
1068
|
-
from: undefined,
|
|
1069
|
-
to: undefined
|
|
1070
|
-
});
|
|
1071
|
-
};
|
|
1072
|
-
const isYearDisabled = year => {
|
|
1073
|
-
const date = new Date(year + 1, currentMonth, 1);
|
|
1074
|
-
return disabledDate?.(date, {
|
|
1075
|
-
from: undefined,
|
|
1076
|
-
to: undefined
|
|
1077
|
-
});
|
|
1078
|
-
};
|
|
1079
|
-
function calculateDatePickerPopupPossition() {
|
|
1080
|
-
const datePickerContainerHeight = (containerRef.current?.clientHeight || 0) + CONTENT_PADDING;
|
|
1081
|
-
const datePickerPossitionFromTop = containerRef.current?.getBoundingClientRect().top || 0;
|
|
1082
|
-
const datePickerPossitionFromBottom = window.innerHeight - (containerRef.current?.getBoundingClientRect().bottom || 0);
|
|
1083
|
-
const datePickerContainerPopupHeight = containerRef.current?.querySelector(`.${prefixCls}-dropdown`)?.clientHeight || 0;
|
|
1084
|
-
setPlacementPossition(['topLeft', 'topRight'].includes(placement) ? {
|
|
1085
|
-
position: 'absolute',
|
|
1086
|
-
top: datePickerPossitionFromTop - datePickerContainerPopupHeight < 0 ? datePickerContainerHeight : -datePickerContainerPopupHeight
|
|
1087
|
-
} : {
|
|
1088
|
-
position: 'absolute',
|
|
1089
|
-
top: datePickerPossitionFromBottom > datePickerContainerPopupHeight ? 0 : -(datePickerContainerPopupHeight + datePickerContainerHeight)
|
|
1090
|
-
});
|
|
1091
|
-
}
|
|
1092
|
-
const prevMonth = currentMonth === 0 ? MONTH_LENGTH : currentMonth - 1;
|
|
1093
|
-
const nextMonth = currentMonth === MONTH_LENGTH ? 0 : currentMonth + 1;
|
|
1094
|
-
const prevMonthYear = currentMonth === 0 ? currentYear - 1 : currentYear;
|
|
1095
|
-
const nextMonthYear = currentMonth === MONTH_LENGTH ? currentYear + 1 : currentYear;
|
|
1096
|
-
const totalDays = daysInMonth(currentYear, currentMonth);
|
|
1097
|
-
const firstDay = firstDayOfMonth(currentYear, currentMonth);
|
|
1098
|
-
const prevMonthDays = daysInMonth(prevMonthYear, prevMonth);
|
|
1099
|
-
const nextDaysCount = NEXT_DAYS_COUNT_AS_CURRENT_MUNTH - (firstDay + totalDays);
|
|
1100
|
-
const days = [...Array.from({
|
|
1101
|
-
length: firstDay
|
|
1102
|
-
}, (_, i) => ({
|
|
1103
|
-
day: prevMonthDays - firstDay + i + 1,
|
|
1104
|
-
current: false,
|
|
1105
|
-
month: prevMonth,
|
|
1106
|
-
year: prevMonthYear
|
|
1107
|
-
})), ...Array.from({
|
|
1108
|
-
length: totalDays
|
|
1109
|
-
}, (_, i) => ({
|
|
1110
|
-
day: i + 1,
|
|
1111
|
-
current: true,
|
|
1112
|
-
month: currentMonth,
|
|
1113
|
-
year: currentYear
|
|
1114
|
-
})), ...Array.from({
|
|
1115
|
-
length: nextDaysCount
|
|
1116
|
-
}, (_, i) => ({
|
|
1117
|
-
day: i + 1,
|
|
1118
|
-
current: false,
|
|
1119
|
-
month: nextMonth,
|
|
1120
|
-
year: nextMonthYear
|
|
1121
|
-
}))];
|
|
1122
|
-
return jsxs("div", {
|
|
1123
|
-
ref: containerRef,
|
|
1124
|
-
className: clsx([`${prefixCls}-container`, {
|
|
1125
|
-
noStyle,
|
|
1126
|
-
[`${prefixCls}-${size}`]: size
|
|
1127
|
-
}]),
|
|
1128
|
-
children: [jsx("div", {
|
|
1129
|
-
className: `${prefixCls}-input-wrapper`,
|
|
1130
|
-
children: jsxs("button", {
|
|
1131
|
-
type: "button",
|
|
1132
|
-
className: clsx([`${prefixCls}-input`, {
|
|
1133
|
-
noBordered: !bordered,
|
|
1134
|
-
[`${prefixCls}-error`]: error,
|
|
1135
|
-
[`${prefixCls}-${size}`]: size,
|
|
1136
|
-
[`${prefixCls}-disabled`]: disabled
|
|
1137
|
-
}]),
|
|
1138
|
-
disabled: disabled,
|
|
1139
|
-
onClick: () => setIsOpen(!isOpen),
|
|
1140
|
-
children: [prefix || null, jsx("input", {
|
|
1141
|
-
size: INPUT_SIZE$1,
|
|
1142
|
-
disabled: disabled,
|
|
1143
|
-
readOnly: inputReadOnly,
|
|
1144
|
-
className: `${prefixCls}-selected-date globalEllipsis`,
|
|
1145
|
-
placeholder: placeholder,
|
|
1146
|
-
style: {
|
|
1147
|
-
opacity: isOpen ? '0.6' : 1
|
|
1148
|
-
},
|
|
1149
|
-
defaultValue: selectedDatePlaceholder
|
|
1150
|
-
}), jsxs("span", {
|
|
1151
|
-
className: `${prefixCls}-icon`,
|
|
1152
|
-
children: [allowClear && selectedDate ? jsx("span", {
|
|
1153
|
-
className: `${prefixCls}-clear`,
|
|
1154
|
-
onClick: clearSelection,
|
|
1155
|
-
children: typeof allowClear === 'object' && allowClear.clearIcon ? allowClear.clearIcon : jsx(ClearIcon, {})
|
|
1156
|
-
}) : suffixIcon || jsx(CalendarIcon, {}), error && feedbackIcons ? jsx(ErrorIcon, {}) : null]
|
|
1157
|
-
})]
|
|
1158
|
-
})
|
|
1159
|
-
}), jsx("div", {
|
|
1160
|
-
style: popupContainerRef.current ? {
|
|
1161
|
-
position: 'absolute'
|
|
1162
|
-
} : {},
|
|
1163
|
-
className: clsx([placement, `${prefixCls}-dropdown-wrapper`, {
|
|
1164
|
-
show: isOpen
|
|
1165
|
-
}]),
|
|
1166
|
-
children: isOpen && jsxs("div", {
|
|
1167
|
-
className: `${prefixCls}-dropdown`,
|
|
1168
|
-
style: placementPossition,
|
|
1169
|
-
children: [jsxs("div", {
|
|
1170
|
-
className: `${prefixCls}-header`,
|
|
1171
|
-
children: [jsxs("div", {
|
|
1172
|
-
className: `${prefixCls}-nav-buttons`,
|
|
1173
|
-
children: [jsx("button", {
|
|
1174
|
-
onClick: () => setCurrentYear(y => y - 1),
|
|
1175
|
-
children: "\u00AB"
|
|
1176
|
-
}), jsx("button", {
|
|
1177
|
-
onClick: () => setCurrentMonth(m => m === 0 ? (setCurrentYear(y => y - 1), MONTH_LENGTH) : m - 1),
|
|
1178
|
-
children: "\u2039"
|
|
1179
|
-
})]
|
|
1180
|
-
}), jsxs("div", {
|
|
1181
|
-
className: `${prefixCls}-dropdown-selects`,
|
|
1182
|
-
children: [jsx("button", {
|
|
1183
|
-
type: "button",
|
|
1184
|
-
className: `${prefixCls}-select`,
|
|
1185
|
-
onClick: () => setViewMode('year'),
|
|
1186
|
-
children: currentYear
|
|
1187
|
-
}), jsx("button", {
|
|
1188
|
-
type: "button",
|
|
1189
|
-
className: `${prefixCls}-select`,
|
|
1190
|
-
onClick: () => setViewMode('month'),
|
|
1191
|
-
children: localeMonths[currentMonth]
|
|
1192
|
-
})]
|
|
1193
|
-
}), jsxs("div", {
|
|
1194
|
-
className: `${prefixCls}-nav-buttons`,
|
|
1195
|
-
children: [jsx("button", {
|
|
1196
|
-
onClick: () => setCurrentMonth(m => m === MONTH_LENGTH ? (setCurrentYear(y => y + 1), 0) : m + 1),
|
|
1197
|
-
children: "\u203A"
|
|
1198
|
-
}), jsx("button", {
|
|
1199
|
-
onClick: () => setCurrentYear(y => y + 1),
|
|
1200
|
-
children: "\u00BB"
|
|
1201
|
-
})]
|
|
1202
|
-
})]
|
|
1203
|
-
}), viewMode === 'day' && jsxs("div", {
|
|
1204
|
-
className: `${prefixCls}-grid day`,
|
|
1205
|
-
children: [localeWeekdays.map(day => jsx("div", {
|
|
1206
|
-
className: `${prefixCls}-day-header`,
|
|
1207
|
-
children: day
|
|
1208
|
-
}, day)), days.map(({
|
|
1209
|
-
day,
|
|
1210
|
-
current,
|
|
1211
|
-
month,
|
|
1212
|
-
year
|
|
1213
|
-
}, idx) => {
|
|
1214
|
-
const isSelected = selectedDate && selectedDate.getDate() === day && selectedDate.getMonth() === month && selectedDate.getFullYear() === year;
|
|
1215
|
-
return jsx("button", {
|
|
1216
|
-
className: clsx([`${prefixCls}-day`, {
|
|
1217
|
-
[`${prefixCls}-selected`]: isSelected,
|
|
1218
|
-
[`${prefixCls}-other-month`]: !current
|
|
1219
|
-
}]),
|
|
1220
|
-
onClick: () => handleSelect(day, month, year),
|
|
1221
|
-
disabled: disabledDate?.(new Date(year, month, day), {
|
|
1222
|
-
from: undefined,
|
|
1223
|
-
to: undefined
|
|
1224
|
-
}),
|
|
1225
|
-
children: day
|
|
1226
|
-
}, `${year}-${month}-${day}-${idx}`);
|
|
1227
|
-
})]
|
|
1228
|
-
}), viewMode === 'month' && jsx("div", {
|
|
1229
|
-
className: `${prefixCls}-grid`,
|
|
1230
|
-
children: localeMonths.map((m, i) => jsx("button", {
|
|
1231
|
-
className: `${prefixCls}-month`,
|
|
1232
|
-
onClick: () => {
|
|
1233
|
-
setCurrentMonth(i);
|
|
1234
|
-
setViewMode('day');
|
|
1235
|
-
},
|
|
1236
|
-
disabled: isMonthDisabled(i),
|
|
1237
|
-
children: m
|
|
1238
|
-
}, i))
|
|
1239
|
-
}), viewMode === 'year' && jsx("div", {
|
|
1240
|
-
className: `${prefixCls}-grid`,
|
|
1241
|
-
children: Array.from({
|
|
1242
|
-
length: 12
|
|
1243
|
-
}, (_, i) => {
|
|
1244
|
-
const year = currentYear - NUMBER_SIX + i;
|
|
1245
|
-
return jsx("button", {
|
|
1246
|
-
className: `${prefixCls}-year`,
|
|
1247
|
-
disabled: isYearDisabled(year),
|
|
1248
|
-
onClick: () => {
|
|
1249
|
-
setCurrentYear(year);
|
|
1250
|
-
setViewMode('month');
|
|
1251
|
-
},
|
|
1252
|
-
children: year
|
|
1253
|
-
}, year);
|
|
1254
|
-
})
|
|
1255
|
-
}), showToday && jsx("div", {
|
|
1256
|
-
className: `${prefixCls}-day-footer`,
|
|
1257
|
-
style: {
|
|
1258
|
-
gridColumn: 'span 7'
|
|
1259
|
-
},
|
|
1260
|
-
children: jsx("button", {
|
|
1261
|
-
className: `${prefixCls}-select`,
|
|
1262
|
-
disabled: disabledDate?.(new Date(DateNow.getDate(), DateNow.getMonth(), DateNow.getFullYear()), {
|
|
1263
|
-
from: undefined,
|
|
1264
|
-
to: undefined
|
|
1265
|
-
}),
|
|
1266
|
-
onClick: () => {
|
|
1267
|
-
handleSelect(DateNow.getDate(), DateNow.getMonth(), DateNow.getFullYear());
|
|
1268
|
-
},
|
|
1269
|
-
children: locale?.today || 'Today'
|
|
1270
|
-
})
|
|
1271
|
-
})]
|
|
1272
|
-
})
|
|
1273
|
-
})]
|
|
1274
|
-
});
|
|
1275
|
-
};
|
|
1276
|
-
const DatePicker = Object.assign(DatePickerComponent, {
|
|
1277
|
-
RangePicker
|
|
1278
|
-
});
|
|
1279
|
-
|
|
1280
|
-
var css_248z$h = ".xUi-timepicker-wrapper{display:inline-block;font-size:14px;position:relative}.xUi-timepicker-input-wrapper{position:relative;width:100%}.xUi-timepicker-input{border:1px solid var(--xui-border-color);border-radius:6px;box-sizing:border-box;font-size:14px;height:32px;line-height:32px;padding:4px 11px;transition:all .3s;width:100%}.xUi-timepicker-input:focus,.xUi-timepicker-input:hover{border-color:var(--xui-primary-color-light)}.xUi-timepicker-input:focus{outline:none}.xUi-timepicker-input::placeholder{opacity:.6}.xUi-timepicker-clear{color:rgba(0,0,0,.45);cursor:pointer;font-size:12px;position:absolute;right:8px;top:50%;transform:translateY(-50%);z-index:2}.xUi-timepicker-clear:hover{color:rgba(0,0,0,.75)}.xUi-timepicker-popup{background:#fff;border:1px solid var(--xui-border-color);border-radius:8px;box-shadow:0 4px 12px rgba(0,0,0,.15);display:flex;left:0;margin-top:4px;padding:8px 4px;position:absolute;top:100%;z-index:1}.xUi-timepicker-panel{display:flex;width:100%}.xUi-timepicker-column{align-items:center;display:flex;flex:1;flex-direction:column;margin-bottom:5px;max-height:169px;overflow-y:auto;padding-left:4px;width:45px}.xUi-timepicker-column::-webkit-scrollbar,.xUi-timepicker-column::-webkit-scrollbar-thumb{width:4px}.xUi-timepicker-column:nth-child(2){border-left:1px solid var(--xui-border-color);border-right:1px solid var(--xui-border-color)}.xUi-timepicker-cell{align-items:center;border-radius:4px;cursor:pointer;display:flex;font-size:14px;justify-content:center;padding:6px 0;text-align:center;transition:background .3s;width:40px}.xUi-timepicker-cell:hover{background-color:#e9e9e9}.xUi-timepicker-cell-selected{background-color:#e6f4ff;font-weight:500}.xUi-timepicker-cell-disabled{color:rgba(0,0,0,.25);pointer-events:none;user-select:none}.xUi-timepicker-now-btn{color:#4096ff;cursor:pointer;font-weight:500;margin-top:10px;padding:0 0 4px;text-align:center;transition:background .3s}.xUi-timepicker-icons{align-items:center;display:flex;gap:4px;position:absolute;right:8px;top:50%;transform:translateY(-50%)}.xUi-timepicker-suffix{align-items:center;cursor:pointer;display:flex;justify-content:center}.xUi-timepicker-suffix svg{color:#999;height:14px;width:14px}.xUi-timepicker-clear{right:0;top:1px}.xUi-timepicker-actions{align-items:center;border-top:1px solid var(--xui-border-color);display:flex;justify-content:space-between;padding:0 4px}.xUi-timepicker-ok-btn{background-color:var(--xui-primary-color);border:none;border-radius:4px;color:#fff;cursor:pointer;margin-top:7px;outline:none;padding:4px 8px;transition:.3s ease}.xUi-timepicker-ok-btn:disabled{background-color:var(--xui-color-disabled);color:grey;font-size:13px}.xUi-timepicker-ok-btn:not(:disabled):hover{background-color:var(--xui-primary-color-light)}";
|
|
1281
|
-
styleInject(css_248z$h);
|
|
1282
|
-
|
|
1283
|
-
const HOURS = 24;
|
|
1284
|
-
const INPUT_SIZE = 13;
|
|
1285
|
-
const TIME_OPTION_PADDING = 4;
|
|
1286
|
-
const MINUTES_AND_SECONDS = 60;
|
|
1287
|
-
const ADD_EMPTY_SECTION_COUNT = 5;
|
|
1288
|
-
const pad = num => String(num).padStart(2, '0');
|
|
1289
|
-
const TimePicker = ({
|
|
1290
|
-
prefixCls = prefixClsTimePicker,
|
|
1291
|
-
style = {},
|
|
1292
|
-
className = '',
|
|
1293
|
-
disabledTime,
|
|
1294
|
-
inputReadOnly = false,
|
|
1295
|
-
format = 'HH:mm:ss',
|
|
1296
|
-
defaultValue = null,
|
|
1297
|
-
value: propValue = null,
|
|
1298
|
-
onChange,
|
|
1299
|
-
onBlur,
|
|
1300
|
-
onSelect,
|
|
1301
|
-
showNow = true,
|
|
1302
|
-
clearIcon = jsx(ClearIcon, {}),
|
|
1303
|
-
suffixIcon = jsx(TimeIcon, {}),
|
|
1304
|
-
placeholder = 'Select time'
|
|
1305
|
-
}) => {
|
|
1306
|
-
const [open, setOpen] = useState(false);
|
|
1307
|
-
const [innerValue, setInnerValue] = useState(propValue || defaultValue ? new Date(propValue || defaultValue) : null);
|
|
1308
|
-
const [tempValue, setTempValue] = useState(null);
|
|
1309
|
-
const inputRef = useRef(null);
|
|
1310
|
-
const popupRef = useRef(null);
|
|
1311
|
-
const hourRef = useRef(null);
|
|
1312
|
-
const minuteRef = useRef(null);
|
|
1313
|
-
const secondRef = useRef(null);
|
|
1314
|
-
useEffect(() => {
|
|
1315
|
-
const handleClickOutside = e => {
|
|
1316
|
-
if (popupRef.current && !popupRef.current.contains(e.target) && inputRef.current && !inputRef.current.contains(e.target)) {
|
|
1317
|
-
setOpen(false);
|
|
1318
|
-
setTempValue(null);
|
|
1319
|
-
if (!innerValue) {
|
|
1320
|
-
onChange?.(null, '');
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
};
|
|
1324
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
1325
|
-
return () => {
|
|
1326
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
1327
|
-
};
|
|
1328
|
-
}, [innerValue, onChange]);
|
|
1329
|
-
useEffect(() => {
|
|
1330
|
-
if (open) {
|
|
1331
|
-
setTempValue(innerValue ? new Date(innerValue) : null);
|
|
1332
|
-
const {
|
|
1333
|
-
hour = 0,
|
|
1334
|
-
minute = 0,
|
|
1335
|
-
second = 0
|
|
1336
|
-
} = getTimeParts(innerValue);
|
|
1337
|
-
scrollToTop(hourRef, hour || 0);
|
|
1338
|
-
scrollToTop(minuteRef, minute || 0);
|
|
1339
|
-
scrollToTop(secondRef, second || 0);
|
|
1340
|
-
}
|
|
1341
|
-
}, [open, innerValue]);
|
|
1342
|
-
useEffect(() => {
|
|
1343
|
-
onSelect?.(tempValue);
|
|
1344
|
-
}, [tempValue, onSelect]);
|
|
1345
|
-
const formatDate = date => {
|
|
1346
|
-
if (!date) {
|
|
1347
|
-
return '';
|
|
1348
|
-
}
|
|
1349
|
-
return `${format}`.replace(/HH|hh/, pad(date.getHours())).replace(/MM|mm/, pad(date.getMinutes())).replace(/SS|ss/, pad(date.getSeconds()));
|
|
1350
|
-
};
|
|
1351
|
-
const getTimeParts = date => ({
|
|
1352
|
-
hour: date?.getHours() ?? null,
|
|
1353
|
-
minute: date?.getMinutes() ?? null,
|
|
1354
|
-
second: date?.getSeconds() ?? null
|
|
1355
|
-
});
|
|
1356
|
-
const getDisabled = (type, hour = 0, minute = 0) => {
|
|
1357
|
-
const disabled = disabledTime?.(tempValue || new Date());
|
|
1358
|
-
if (!disabled) {
|
|
1359
|
-
return [];
|
|
1360
|
-
}
|
|
1361
|
-
if (type === 'hour') {
|
|
1362
|
-
return disabled.disabledHours?.() || [];
|
|
1363
|
-
}
|
|
1364
|
-
if (type === 'minute') {
|
|
1365
|
-
return disabled.disabledMinutes?.(hour) || [];
|
|
1366
|
-
}
|
|
1367
|
-
if (type === 'second') {
|
|
1368
|
-
return disabled.disabledSeconds?.(hour, minute) || [];
|
|
1369
|
-
}
|
|
1370
|
-
return [];
|
|
1371
|
-
};
|
|
1372
|
-
const scrollToTop = (ref, selectedIndex) => {
|
|
1373
|
-
const el = ref.current?.querySelectorAll('div')[selectedIndex];
|
|
1374
|
-
if (el && ref.current) {
|
|
1375
|
-
ref.current.scrollTo({
|
|
1376
|
-
top: el.offsetTop - TIME_OPTION_PADDING * 2,
|
|
1377
|
-
behavior: 'smooth'
|
|
1378
|
-
});
|
|
1379
|
-
}
|
|
1380
|
-
};
|
|
1381
|
-
const updateTempValue = (hour, minute, second) => {
|
|
1382
|
-
const newDate = new Date();
|
|
1383
|
-
newDate.setHours(hour, minute, second, 0);
|
|
1384
|
-
setTempValue(newDate);
|
|
1385
|
-
};
|
|
1386
|
-
const onSelectHour = (h, auto) => {
|
|
1387
|
-
const {
|
|
1388
|
-
minute = 0,
|
|
1389
|
-
second = 0
|
|
1390
|
-
} = getTimeParts(tempValue);
|
|
1391
|
-
if (!auto) {
|
|
1392
|
-
if (!minute) {
|
|
1393
|
-
onSelectMinute(0, true);
|
|
1394
|
-
}
|
|
1395
|
-
if (!second) {
|
|
1396
|
-
onSelectSecond(0, true);
|
|
1397
|
-
}
|
|
1398
|
-
}
|
|
1399
|
-
updateTempValue(h, minute || 0, second || 0);
|
|
1400
|
-
scrollToTop(hourRef, h);
|
|
1401
|
-
};
|
|
1402
|
-
const onSelectMinute = (m, auto) => {
|
|
1403
|
-
const {
|
|
1404
|
-
hour = 0,
|
|
1405
|
-
second = 0
|
|
1406
|
-
} = getTimeParts(tempValue);
|
|
1407
|
-
if (!auto) {
|
|
1408
|
-
if (!hour) {
|
|
1409
|
-
onSelectHour(0, true);
|
|
1410
|
-
}
|
|
1411
|
-
if (!second) {
|
|
1412
|
-
onSelectSecond(0, true);
|
|
1413
|
-
}
|
|
1414
|
-
}
|
|
1415
|
-
updateTempValue(hour || 0, m, second || 0);
|
|
1416
|
-
scrollToTop(minuteRef, m);
|
|
1417
|
-
};
|
|
1418
|
-
const onSelectSecond = (s, auto) => {
|
|
1419
|
-
const {
|
|
1420
|
-
hour = 0,
|
|
1421
|
-
minute = 0
|
|
1422
|
-
} = getTimeParts(tempValue);
|
|
1423
|
-
if (!auto) {
|
|
1424
|
-
if (!hour) {
|
|
1425
|
-
onSelectHour(0, true);
|
|
1426
|
-
}
|
|
1427
|
-
if (!minute) {
|
|
1428
|
-
onSelectMinute(0, true);
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
|
-
updateTempValue(hour || 0, minute || 0, s);
|
|
1432
|
-
scrollToTop(secondRef, s);
|
|
1433
|
-
};
|
|
1434
|
-
const handleClear = e => {
|
|
1435
|
-
e?.stopPropagation();
|
|
1436
|
-
setInnerValue(null);
|
|
1437
|
-
setTempValue(null);
|
|
1438
|
-
onChange?.(null, '');
|
|
1439
|
-
};
|
|
1440
|
-
const handleShowNow = () => {
|
|
1441
|
-
const now = new Date();
|
|
1442
|
-
setTempValue(now);
|
|
1443
|
-
setInnerValue(now);
|
|
1444
|
-
onChange?.(now, formatDate(now));
|
|
1445
|
-
onSelect?.(now);
|
|
1446
|
-
setOpen(false);
|
|
1447
|
-
};
|
|
1448
|
-
const handleOkButton = () => {
|
|
1449
|
-
if (tempValue) {
|
|
1450
|
-
setInnerValue(tempValue);
|
|
1451
|
-
onChange?.(tempValue, formatDate(tempValue));
|
|
1452
|
-
onSelect?.(tempValue);
|
|
1453
|
-
}
|
|
1454
|
-
setOpen(false);
|
|
1455
|
-
};
|
|
1456
|
-
const handleOnChange = e => {
|
|
1457
|
-
const inputVal = e.target.value.trim();
|
|
1458
|
-
const timeRegex = /^(\d{2}):(\d{2}):(\d{2})$/;
|
|
1459
|
-
const match = inputVal.match(timeRegex);
|
|
1460
|
-
if (match) {
|
|
1461
|
-
const [, hStr, mStr, sStr] = match;
|
|
1462
|
-
const h = parseInt(hStr, 10);
|
|
1463
|
-
const m = parseInt(mStr, 10);
|
|
1464
|
-
const s = parseInt(sStr, 10);
|
|
1465
|
-
if (h >= 0 && h < HOURS && m >= 0 && m < MINUTES_AND_SECONDS && s >= 0 && s < MINUTES_AND_SECONDS && !getDisabled('hour').includes(h) && !getDisabled('minute', h).includes(m) && !getDisabled('second', h, m).includes(s)) {
|
|
1466
|
-
onSelectHour(h);
|
|
1467
|
-
onSelectMinute(m);
|
|
1468
|
-
onSelectSecond(s);
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
};
|
|
1472
|
-
const renderOptions = () => {
|
|
1473
|
-
const hours = Array.from({
|
|
1474
|
-
length: HOURS + ADD_EMPTY_SECTION_COUNT
|
|
1475
|
-
}, (_, i) => i < HOURS ? i : false);
|
|
1476
|
-
const minutesSeconds = Array.from({
|
|
1477
|
-
length: MINUTES_AND_SECONDS + ADD_EMPTY_SECTION_COUNT
|
|
1478
|
-
}, (_, i) => i < MINUTES_AND_SECONDS ? i : false);
|
|
1479
|
-
const {
|
|
1480
|
-
hour: selectedHour,
|
|
1481
|
-
minute: selectedMinute,
|
|
1482
|
-
second: selectedSecond
|
|
1483
|
-
} = getTimeParts(tempValue);
|
|
1484
|
-
const currentHour = selectedHour ?? 0;
|
|
1485
|
-
const currentMinute = selectedMinute ?? 0;
|
|
1486
|
-
return jsxs("div", {
|
|
1487
|
-
children: [jsxs("div", {
|
|
1488
|
-
className: `${prefixCls}-panel`,
|
|
1489
|
-
children: [jsx("div", {
|
|
1490
|
-
ref: hourRef,
|
|
1491
|
-
className: `${prefixCls}-column`,
|
|
1492
|
-
children: hours.map((h, index) => h === false ? jsx("div", {
|
|
1493
|
-
className: `${prefixCls}-cell`,
|
|
1494
|
-
style: {
|
|
1495
|
-
opacity: 0,
|
|
1496
|
-
userSelect: 'none',
|
|
1497
|
-
cursor: 'inherit'
|
|
1498
|
-
},
|
|
1499
|
-
children: "0"
|
|
1500
|
-
}, `${h}_${index}`) : jsx("div", {
|
|
1501
|
-
className: clsx([`${prefixCls}-cell`, {
|
|
1502
|
-
[`${prefixCls}-cell-disabled`]: getDisabled('hour').includes(h),
|
|
1503
|
-
[`${prefixCls}-cell-selected`]: selectedHour === h
|
|
1504
|
-
}]),
|
|
1505
|
-
onClick: () => !getDisabled('hour').includes(h) && onSelectHour(h),
|
|
1506
|
-
children: pad(h)
|
|
1507
|
-
}, h))
|
|
1508
|
-
}), jsx("div", {
|
|
1509
|
-
ref: minuteRef,
|
|
1510
|
-
className: `${prefixCls}-column`,
|
|
1511
|
-
children: minutesSeconds.map((m, index) => m === false ? jsx("div", {
|
|
1512
|
-
className: `${prefixCls}-cell`,
|
|
1513
|
-
style: {
|
|
1514
|
-
opacity: 0,
|
|
1515
|
-
userSelect: 'none',
|
|
1516
|
-
cursor: 'inherit'
|
|
1517
|
-
},
|
|
1518
|
-
children: "0"
|
|
1519
|
-
}, `${m}_${index}`) : jsx("div", {
|
|
1520
|
-
className: clsx([`${prefixCls}-cell`, {
|
|
1521
|
-
[`${prefixCls}-cell-disabled`]: getDisabled('minute', currentHour).includes(m),
|
|
1522
|
-
[`${prefixCls}-cell-selected`]: selectedMinute === m
|
|
1523
|
-
}]),
|
|
1524
|
-
onClick: () => !getDisabled('minute', currentHour).includes(m) && onSelectMinute(m),
|
|
1525
|
-
children: pad(m)
|
|
1526
|
-
}, m))
|
|
1527
|
-
}), jsx("div", {
|
|
1528
|
-
ref: secondRef,
|
|
1529
|
-
className: `${prefixCls}-column`,
|
|
1530
|
-
children: minutesSeconds.map((s, index) => s === false ? jsx("div", {
|
|
1531
|
-
className: `${prefixCls}-cell`,
|
|
1532
|
-
style: {
|
|
1533
|
-
opacity: 0,
|
|
1534
|
-
userSelect: 'none',
|
|
1535
|
-
cursor: 'inherit'
|
|
1536
|
-
},
|
|
1537
|
-
children: "0"
|
|
1538
|
-
}, `${s}_${index}`) : jsx("div", {
|
|
1539
|
-
className: clsx([`${prefixCls}-cell`, {
|
|
1540
|
-
[`${prefixCls}-cell-disabled`]: getDisabled('second', currentHour, currentMinute).includes(s),
|
|
1541
|
-
[`${prefixCls}-cell-selected`]: selectedSecond === s
|
|
1542
|
-
}]),
|
|
1543
|
-
onClick: () => !getDisabled('second', currentHour, currentMinute).includes(s) && onSelectSecond(s),
|
|
1544
|
-
children: pad(s)
|
|
1545
|
-
}, s))
|
|
1546
|
-
})]
|
|
1547
|
-
}), jsxs("div", {
|
|
1548
|
-
className: `${prefixCls}-actions`,
|
|
1549
|
-
children: [showNow ? jsx("div", {
|
|
1550
|
-
className: `${prefixCls}-now-btn`,
|
|
1551
|
-
onClick: handleShowNow,
|
|
1552
|
-
children: "Now"
|
|
1553
|
-
}) : jsx("span", {}), jsx("button", {
|
|
1554
|
-
className: `${prefixCls}-ok-btn`,
|
|
1555
|
-
disabled: selectedHour === null || selectedMinute === null || selectedSecond === null,
|
|
1556
|
-
onClick: handleOkButton,
|
|
1557
|
-
children: "OK"
|
|
1558
|
-
})]
|
|
1559
|
-
})]
|
|
1560
|
-
});
|
|
1561
|
-
};
|
|
1562
|
-
return jsxs("div", {
|
|
1563
|
-
className: clsx([`${prefixCls}-wrapper`, className]),
|
|
1564
|
-
style: style,
|
|
1565
|
-
children: [jsxs("div", {
|
|
1566
|
-
className: `${prefixCls}-input-wrapper`,
|
|
1567
|
-
onClick: () => setOpen(true),
|
|
1568
|
-
children: [jsx("input", {
|
|
1569
|
-
ref: inputRef,
|
|
1570
|
-
size: INPUT_SIZE,
|
|
1571
|
-
placeholder: placeholder,
|
|
1572
|
-
className: `${prefixCls}-input`,
|
|
1573
|
-
readOnly: inputReadOnly,
|
|
1574
|
-
onChange: handleOnChange,
|
|
1575
|
-
...(open ? {} : {
|
|
1576
|
-
value: formatDate(innerValue)
|
|
1577
|
-
}),
|
|
1578
|
-
onBlur: e => {
|
|
1579
|
-
onBlur?.(e, {
|
|
1580
|
-
source: 'input'
|
|
1581
|
-
});
|
|
1582
|
-
}
|
|
1583
|
-
}), jsx("div", {
|
|
1584
|
-
className: `${prefixCls}-icons`,
|
|
1585
|
-
children: clearIcon && innerValue ? jsx("span", {
|
|
1586
|
-
className: `${prefixCls}-clear`,
|
|
1587
|
-
onClick: handleClear,
|
|
1588
|
-
children: clearIcon
|
|
1589
|
-
}) : suffixIcon && jsx("span", {
|
|
1590
|
-
className: `${prefixCls}-suffix`,
|
|
1591
|
-
onClick: e => {
|
|
1592
|
-
e.stopPropagation();
|
|
1593
|
-
setOpen(true);
|
|
1594
|
-
},
|
|
1595
|
-
children: suffixIcon
|
|
1596
|
-
})
|
|
1597
|
-
})]
|
|
1598
|
-
}), open && jsx("div", {
|
|
1599
|
-
ref: popupRef,
|
|
1600
|
-
className: `${prefixCls}-popup`,
|
|
1601
|
-
children: renderOptions()
|
|
1602
|
-
})]
|
|
1603
|
-
});
|
|
1604
|
-
};
|
|
1605
|
-
|
|
1606
|
-
var css_248z$g = ".xUi-input-container{align-items:center;background-color:transparent;border:1px solid var(--xui-border-color);border-radius:var(--xui-border-radius-sm);display:flex;overflow:hidden}.xUi-input-container:not(.xUi-input-error):has(.xUi-input):hover,.xUi-input-container:not(.xUi-input-error):has(.xUi-input:focus){border:1px solid var(--xui-primary-color)}.xUi-input-container.xUi-input-error{border-color:var(--xui-error-color)}.xUi-input-container.xUi-input-error .error-svg-icon,.xUi-input-suffix .error-svg-icon{color:var(--xui-error-color)}.xUi-input-wrapper{align-items:center;display:flex;flex-grow:1;margin:-1px;position:relative;transition:border .3s}.xUi-input,.xUi-input-wrapper{background-color:transparent;height:-webkit-fill-available}.xUi-input{border:none;color:var(--xui-text-color);flex:1;outline:none;padding:0 7px;width:100%}.xUi-input:placeholder-shown{text-overflow:ellipsis}.xUi-input::placeholder{color:var(--xui-text-color);opacity:.6}.xUi-input-prefix,.xUi-input-suffix{background-color:transparent;gap:4px}.xUi-input-addon,.xUi-input-prefix,.xUi-input-suffix{align-items:center;color:var(--xui-text-color);display:flex;height:-webkit-fill-available;padding:0 7px}.xUi-input-addon.xUi-input-after{border-left:1px solid var(--xui-border-color)}.xUi-input-addon.xUi-input-before{border-right:1px solid var(--xui-border-color)}.xUi-input-large .xUi-input-addon{padding:0 10px}.xUi-input-clear{align-items:center;cursor:pointer;display:flex;margin:0 3px;position:relative;width:16px}.xUi-input-clear svg{color:var(--xui-text-color)}.xUi-input-disabled{background-color:var(--xui-color-disabled);cursor:not-allowed}.xUi-input-small{height:22px}.xUi-input-large .xUi-input-clear,.xUi-input-small .xUi-input,.xUi-input-small .xUi-input::placeholder{font-size:var(--xui-font-size-md)}.xUi-input-middle{border-radius:var(--xui-border-radius-md);height:30px}.xUi-input-large .xUi-input-clear,.xUi-input-middle .xUi-input,.xUi-input-middle .xUi-input::placeholder{font-size:var(--xui-font-size-md)}.xUi-input-large{border-radius:var(--xui-border-radius-lg);height:40px}.xUi-input-large .xUi-input,.xUi-input-large .xUi-input-clear,.xUi-input-large .xUi-input::placeholder{font-size:var(--xui-font-size-lg)}";
|
|
1607
|
-
styleInject(css_248z$g);
|
|
1608
|
-
|
|
1609
|
-
var css_248z$f = ".xUi-textarea-wrapper{margin-bottom:10px;position:relative;width:100%}.xUi-textarea{border:none;border-radius:6px;box-shadow:none;color:var(--xui-text-color);font-size:14px;min-height:14px;outline:none;padding:8px 12px;resize:vertical;transition:all .3s ease;width:100%}.xUi-textarea:placeholder-shown{font-size:14px;text-overflow:ellipsis}.xUi-textarea::placeholder{color:var(--xui-text-color);opacity:.6}.xUi-textarea-small{font-size:12px;padding:6px 10px}.xUi-textarea-middle{font-size:14px;padding:8px 12px}.xUi-textarea-large{padding:10px}.xUi-textarea-outlined{background:transparent;border:1px solid var(--xui-border-color)}.xUi-textarea-outlined:focus{border-color:var(--xui-primary-color)}.xUi-textarea-borderless{background:transparent;border:none}.xUi-textarea-filled{background:var(--xui-primary-color);border:1px solid var(--xui-border-color)}.xUi-textarea-filled:focus{background:var(--xui-background-color);border-color:var(--xui-primary-color)}.xUi-textarea-underlined{background:transparent;border:none;border-bottom:1px solid var(--xui-border-color)}.xUi-textarea-underlined:focus{border-bottom-color:var(--xui-primary-color)}.xUi-textarea-container:has(.xUi-textarea-bordered){border:1px solid var(--xui-border-color)}.xUi-textarea-container:has(.xUi-textarea-success){border-color:var(--xui-success-color)}.xUi-textarea-wrapper:has(.xUi-textarea-error) textarea,.xUi-textarea-wrapper:has(.xUi-textarea-error) textarea:focus{border-color:var(--xui-error-color)}.xUi-textarea-clear{background:transparent;border:none;color:#999;cursor:pointer;position:absolute;right:0;top:15px;transform:translateY(-50%)}.xUi-textarea-clear:hover{color:#333}";
|
|
1610
|
-
styleInject(css_248z$f);
|
|
1611
|
-
|
|
1612
|
-
const Textarea = /*#__PURE__*/forwardRef(({
|
|
1613
|
-
prefixCls = prefixClsTextArea,
|
|
1614
|
-
value,
|
|
1615
|
-
className = '',
|
|
1616
|
-
style,
|
|
1617
|
-
autoSize,
|
|
1618
|
-
onPressEnter,
|
|
1619
|
-
onResize,
|
|
1620
|
-
styles,
|
|
1621
|
-
bordered = true,
|
|
1622
|
-
size = 'large',
|
|
1623
|
-
status,
|
|
1624
|
-
rootClassName,
|
|
1625
|
-
variant = 'outlined',
|
|
1626
|
-
error,
|
|
1627
|
-
allowClear = false,
|
|
1628
|
-
...props
|
|
1629
|
-
}, ref) => {
|
|
1630
|
-
const [inputValue, setInputValue] = useState(value?.toString() || '');
|
|
1631
|
-
const textareaRef = useRef(null);
|
|
1632
|
-
useEffect(() => {
|
|
1633
|
-
const textarea = ref?.current || textareaRef.current;
|
|
1634
|
-
if (textarea && autoSize) {
|
|
1635
|
-
textarea.style.height = 'auto';
|
|
1636
|
-
textarea.style.height = `${textarea.scrollHeight}px`;
|
|
1637
|
-
if (onResize) {
|
|
1638
|
-
onResize({
|
|
1639
|
-
width: textarea.clientWidth,
|
|
1640
|
-
height: textarea.scrollHeight
|
|
1641
|
-
});
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
}, [inputValue, autoSize, onResize, ref]);
|
|
1645
|
-
const handleChange = e => {
|
|
1646
|
-
setInputValue(e.target.value);
|
|
1647
|
-
if (props.onChange) {
|
|
1648
|
-
props.onChange(e);
|
|
1649
|
-
}
|
|
1650
|
-
};
|
|
1651
|
-
const handleKeyDown = e => {
|
|
1652
|
-
if (e.key === 'Enter' && onPressEnter) {
|
|
1653
|
-
onPressEnter(e);
|
|
1654
|
-
}
|
|
1655
|
-
};
|
|
1656
|
-
const handleClear = () => {
|
|
1657
|
-
setInputValue('');
|
|
1658
|
-
if (props.onChange) {
|
|
1659
|
-
props.onChange({
|
|
1660
|
-
target: {
|
|
1661
|
-
value: ''
|
|
1662
|
-
}
|
|
1663
|
-
});
|
|
1664
|
-
}
|
|
1665
|
-
};
|
|
1666
|
-
return jsxs("div", {
|
|
1667
|
-
className: `${prefixCls}-wrapper ${rootClassName || ''}`,
|
|
1668
|
-
children: [jsx("textarea", {
|
|
1669
|
-
...props,
|
|
1670
|
-
ref: ref || textareaRef,
|
|
1671
|
-
value: inputValue,
|
|
1672
|
-
onChange: handleChange,
|
|
1673
|
-
onKeyDown: handleKeyDown,
|
|
1674
|
-
style: {
|
|
1675
|
-
...styles?.textarea,
|
|
1676
|
-
...style
|
|
1677
|
-
},
|
|
1678
|
-
className: clsx([`${prefixCls} ${prefixCls}-${size} ${prefixCls}-${variant} ${className}`, {
|
|
1679
|
-
[`${prefixCls}-bordered`]: bordered,
|
|
1680
|
-
[`${prefixCls}-success`]: status === 'success',
|
|
1681
|
-
[`${prefixCls}-error`]: status === 'error' || error
|
|
1682
|
-
}])
|
|
1683
|
-
}), allowClear && inputValue && jsx("button", {
|
|
1684
|
-
className: `${prefixCls}-clear`,
|
|
1685
|
-
onClick: handleClear,
|
|
1686
|
-
children: "\u2715"
|
|
1687
|
-
})]
|
|
1688
|
-
});
|
|
1689
|
-
});
|
|
1690
|
-
Textarea.displayName = 'Textarea';
|
|
1691
|
-
|
|
1692
|
-
const InputComponent = /*#__PURE__*/forwardRef(({
|
|
1693
|
-
size = 'large',
|
|
1694
|
-
error,
|
|
1695
|
-
suffix,
|
|
1696
|
-
prefix,
|
|
1697
|
-
addonAfter,
|
|
1698
|
-
addonBefore,
|
|
1699
|
-
onPressEnter,
|
|
1700
|
-
disabled = false,
|
|
1701
|
-
allowClear = false,
|
|
1702
|
-
prefixCls = prefixClsInput,
|
|
1703
|
-
className = '',
|
|
1704
|
-
value = undefined,
|
|
1705
|
-
iconRender,
|
|
1706
|
-
noStyle,
|
|
1707
|
-
feedbackIcons,
|
|
1708
|
-
...props
|
|
1709
|
-
}, ref) => {
|
|
1710
|
-
const inputRef = useRef(null);
|
|
1711
|
-
const [internalValue, setInternalValue] = useState(value ?? '');
|
|
1712
|
-
const [iconRenderVisible, setIconRenderVisible] = useState(false);
|
|
1713
|
-
useImperativeHandle(ref, () => ({
|
|
1714
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1715
|
-
// @ts-expect-error
|
|
1716
|
-
focus: inputRef.current?.focus,
|
|
1717
|
-
input: inputRef.current,
|
|
1718
|
-
blur: inputRef.current.blur,
|
|
1719
|
-
nativeElement: inputRef.current,
|
|
1720
|
-
setSelectionRange: (start, end) => {
|
|
1721
|
-
if (inputRef.current) {
|
|
1722
|
-
inputRef.current.setSelectionRange(start, end);
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
|
-
}));
|
|
1726
|
-
const handleChange = e => {
|
|
1727
|
-
setInternalValue(e.target.value);
|
|
1728
|
-
props.onChange?.(e);
|
|
1729
|
-
};
|
|
1730
|
-
const handleClear = e => {
|
|
1731
|
-
setInternalValue('');
|
|
1732
|
-
e.target.value = '';
|
|
1733
|
-
props.onChange?.(e);
|
|
1734
|
-
};
|
|
1735
|
-
const handleOnKeyDown = e => {
|
|
1736
|
-
if (e.key === 'Enter' && onPressEnter) {
|
|
1737
|
-
onPressEnter(e);
|
|
1738
|
-
}
|
|
1739
|
-
};
|
|
1740
|
-
return jsxs("div", {
|
|
1741
|
-
className: clsx([`${prefixCls}-container`, {
|
|
1742
|
-
[`${prefixCls}-error`]: error,
|
|
1743
|
-
[`${prefixCls}-disabled`]: disabled,
|
|
1744
|
-
[`${prefixCls}-${size}`]: size,
|
|
1745
|
-
noStyle: noStyle
|
|
1746
|
-
}, className]),
|
|
1747
|
-
style: props.style,
|
|
1748
|
-
children: [addonBefore && jsx("span", {
|
|
1749
|
-
className: `${prefixCls}-addon ${prefixCls}-before`,
|
|
1750
|
-
children: addonBefore
|
|
1751
|
-
}), jsxs("div", {
|
|
1752
|
-
className: `${prefixCls}-wrapper`,
|
|
1753
|
-
children: [prefix && jsx("span", {
|
|
1754
|
-
className: `${prefixCls}-prefix`,
|
|
1755
|
-
children: prefix
|
|
1756
|
-
}), jsx("input", {
|
|
1757
|
-
...props,
|
|
1758
|
-
ref: inputRef,
|
|
1759
|
-
...(props.type === 'password' && iconRender ? {
|
|
1760
|
-
type: iconRenderVisible ? 'text' : 'password'
|
|
1761
|
-
} : {}),
|
|
1762
|
-
disabled: disabled,
|
|
1763
|
-
value: internalValue,
|
|
1764
|
-
onChange: handleChange,
|
|
1765
|
-
onKeyDown: handleOnKeyDown,
|
|
1766
|
-
className: clsx([prefixCls, className])
|
|
1767
|
-
}), jsx("span", {
|
|
1768
|
-
className: `${prefixCls}-clear`,
|
|
1769
|
-
onClick: handleClear,
|
|
1770
|
-
children: allowClear && internalValue ? jsx(ErrorIcon, {}) : null
|
|
1771
|
-
}), (suffix || iconRender) && jsxs("span", {
|
|
1772
|
-
className: `${prefixCls}-suffix`,
|
|
1773
|
-
...(iconRender !== undefined ? {
|
|
1774
|
-
onClick: () => setIconRenderVisible(icon => !icon)
|
|
1775
|
-
} : {}),
|
|
1776
|
-
children: [suffix || iconRender?.(iconRenderVisible), error && feedbackIcons ? jsx(ErrorIcon, {}) : null]
|
|
1777
|
-
})]
|
|
1778
|
-
}), addonAfter ? jsx("span", {
|
|
1779
|
-
className: `${prefixCls}-addon ${prefixCls}-after`,
|
|
1780
|
-
children: addonAfter
|
|
1781
|
-
}) : null]
|
|
1782
|
-
});
|
|
1783
|
-
});
|
|
1784
|
-
InputComponent.displayName = 'Input';
|
|
1785
|
-
const Input = InputComponent;
|
|
1786
|
-
Input.TextArea = Textarea;
|
|
1787
|
-
|
|
1788
|
-
var css_248z$e = ".xUi-radio-button{align-items:center;background:var(--xui-background-color);border:1px solid var(--xui-border-color);border-radius:var(--xui-border-radius-sm);cursor:pointer;display:inline-flex;height:-webkit-fill-available;justify-content:center;margin:-1px;padding:8px 16px;transition:all .3s}.xUi-radio-button .xUi-radio{display:none}.xUi-radio-button.xUi-radio-button-middle{border-radius:var(--xui-border-radius-md)}.xUi-radio-button.xUi-radio-button-large{border-radius:var(--xui-border-radius-lg)}.xUi-radio-button-checked{background:var(--xui-primary-color);border-color:var(--xui-primary-color);color:var(--xui-background-color);z-index:1}.xUi-radio-button-content{font-size:14px}.xUi-radio-button.disabled{background:var(--xui-color-disabled);border-color:var(--xui-border-color);color:var(--xui-color-disabled);cursor:not-allowed}";
|
|
1789
|
-
styleInject(css_248z$e);
|
|
1790
|
-
|
|
1791
|
-
const RadioButton = ({
|
|
1792
|
-
prefixCls = prefixClsRadio,
|
|
1793
|
-
className = '',
|
|
1794
|
-
checked,
|
|
1795
|
-
disabled,
|
|
1796
|
-
children,
|
|
1797
|
-
size = 'large',
|
|
1798
|
-
...props
|
|
1799
|
-
}) => {
|
|
1800
|
-
return jsx(Radio, {
|
|
1801
|
-
...props,
|
|
1802
|
-
checked: checked,
|
|
1803
|
-
disabled: disabled,
|
|
1804
|
-
className: clsx([`${prefixCls}-button`, {
|
|
1805
|
-
disabled,
|
|
1806
|
-
[className]: className,
|
|
1807
|
-
[`${prefixCls}-button-${size}`]: size,
|
|
1808
|
-
[`${prefixCls}-button-checked`]: checked
|
|
1809
|
-
}]),
|
|
1810
|
-
children: jsx("span", {
|
|
1811
|
-
className: `${prefixCls}-button-content`,
|
|
1812
|
-
children: children ?? props.value
|
|
1813
|
-
})
|
|
1814
|
-
});
|
|
1815
|
-
};
|
|
1816
|
-
|
|
1817
|
-
var css_248z$d = ".xUi-radio-group.xUi-radio-group-small{height:24px}.xUi-radio-group.xUi-radio-group-small .xUi-radio-button:first-child{border-radius:var(--xui-border-radius-sm) 0 0 var(--xui-border-radius-sm)}.xUi-radio-group.xUi-radio-group-small .xUi-radio-button:last-child{border-radius:0 var(--xui-border-radius-sm) var(--xui-border-radius-sm) 0}.xUi-radio-group.xUi-radio-group-middle{height:32px}.xUi-radio-group.xUi-radio-group-middle .xUi-radio-button:first-child{border-radius:var(--xui-border-radius-md) 0 0 var(--xui-border-radius-md)}.xUi-radio-group.xUi-radio-group-middle .xUi-radio-button:last-child{border-radius:0 var(--xui-border-radius-md) var(--xui-border-radius-md) 0}.xUi-radio-group.xUi-radio-group-large{height:40px}.xUi-radio-group.xUi-radio-group-large .xUi-radio-button:first-child{border-radius:var(--xui-border-radius-lg) 0 0 var(--xui-border-radius-lg)}.xUi-radio-group.xUi-radio-group-large .xUi-radio-button:last-child{border-radius:0 var(--xui-border-radius-lg) var(--xui-border-radius-lg) 0}.xUi-radio-group .xUi-radio-button:not(:first-child){border-radius:0}.xUi-radio-group.block{display:inline-flex;width:100%}.xUi-radio-group.block .xUi-radio-button{width:100%}.xUi-radio-group:not(.xUi-radio-group-solid) .xUi-radio-button-checked{background-color:var(--xui-background-color);color:var(--xui-primary-color)}";
|
|
1818
|
-
styleInject(css_248z$d);
|
|
1819
|
-
|
|
1820
|
-
const RadioGroup = ({
|
|
1821
|
-
defaultValue,
|
|
1822
|
-
value,
|
|
1823
|
-
size = 'large',
|
|
1824
|
-
disabled,
|
|
1825
|
-
name,
|
|
1826
|
-
id,
|
|
1827
|
-
style = {},
|
|
1828
|
-
buttonStyle = 'outline',
|
|
1829
|
-
block,
|
|
1830
|
-
prefixCls = prefixClsRadio,
|
|
1831
|
-
className = '',
|
|
1832
|
-
options = [],
|
|
1833
|
-
children,
|
|
1834
|
-
...props
|
|
1835
|
-
}) => {
|
|
1836
|
-
const selectedValue = useMemo(() => value !== undefined ? value : defaultValue, [value, defaultValue]);
|
|
1837
|
-
const renderChildren = () => {
|
|
1838
|
-
if (options.length > 0) {
|
|
1839
|
-
return options.map((option, key) => {
|
|
1840
|
-
const optionValue = typeof option === 'object' ? option.value : option;
|
|
1841
|
-
const optionLabel = typeof option === 'object' ? option.label : option;
|
|
1842
|
-
return jsx(Radio, {
|
|
1843
|
-
value: optionValue,
|
|
1844
|
-
checked: selectedValue === optionValue,
|
|
1845
|
-
disabled: disabled || typeof option === 'object' && option.disabled,
|
|
1846
|
-
...props,
|
|
1847
|
-
children: optionLabel
|
|
1848
|
-
}, `${key}_${optionValue}`);
|
|
1849
|
-
});
|
|
1850
|
-
}
|
|
1851
|
-
return Children.map(children, child => {
|
|
1852
|
-
if (/*#__PURE__*/isValidElement(child) && (child.type === Radio || child.type === RadioButton)) {
|
|
1853
|
-
return /*#__PURE__*/cloneElement(child, {
|
|
1854
|
-
...props,
|
|
1855
|
-
...(child.type === RadioButton ? {
|
|
1856
|
-
size,
|
|
1857
|
-
buttonStyle
|
|
1858
|
-
} : {}),
|
|
1859
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1860
|
-
// @ts-expect-error
|
|
1861
|
-
defaultValue,
|
|
1862
|
-
disabled: disabled ?? child.props.disabled,
|
|
1863
|
-
checked: selectedValue === child.props.value,
|
|
1864
|
-
name: name ?? prefixClsRadio
|
|
1865
|
-
});
|
|
1866
|
-
}
|
|
1867
|
-
return child;
|
|
1868
|
-
});
|
|
1869
|
-
};
|
|
1870
|
-
return jsx("div", {
|
|
1871
|
-
id: id,
|
|
1872
|
-
style: style,
|
|
1873
|
-
className: clsx([`${prefixCls}-group`, {
|
|
1874
|
-
block,
|
|
1875
|
-
className,
|
|
1876
|
-
[`${prefixCls}-group-${size}`]: size,
|
|
1877
|
-
[`${prefixCls}-group-solid`]: buttonStyle === 'solid'
|
|
1878
|
-
}]),
|
|
1879
|
-
children: renderChildren()
|
|
1880
|
-
});
|
|
1881
|
-
};
|
|
1882
|
-
|
|
1883
|
-
var css_248z$c = ".xUi-radio-label{align-items:center;cursor:pointer;display:inline-flex;font-size:var(--xui-font-size-md);line-height:1;margin:16px 0;position:relative}.xUi-radio-label input{display:none}.xUi-radio{border:1px solid var(--xui-border-color);border-radius:50%;height:16px;position:relative;transition:all .3s;width:16px}.xUi-radio-error:not(.xUi-radio-disabled){border:1px solid var(--xui-error-color)}.xUi-radio-label input:checked+.xUi-radio-error:not(.xUi-radio-disabled){background:var(--xui-error-color)}.xUi-radio-group{display:flex}.xUi-radio-label .xUi-radio-enabled:not(.xUi-radio-error):hover{border:1px solid var(--xui-primary-color-light)!important}.xUi-radio-disabled{background-color:var(--xui-color-disabled)}.xUi-radio-title{color:var(--xui-text-color);padding-inline-end:8px;padding-inline-start:8px}.xUi-radio-label input:checked+.xUi-radio{background:var(--xui-primary-color)}.xUi-radio-label input:checked+.xUi-radio:after{background-color:#fff;border-radius:50%;content:\"\";height:6px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:6px}.xUi-radio-label.disabled{cursor:not-allowed;opacity:.5}";
|
|
1884
|
-
styleInject(css_248z$c);
|
|
1885
|
-
|
|
1886
|
-
const RadioComponent = /*#__PURE__*/forwardRef(({
|
|
1887
|
-
prefixCls = prefixClsRadio,
|
|
1888
|
-
className = '',
|
|
1889
|
-
value,
|
|
1890
|
-
onChange,
|
|
1891
|
-
onClick,
|
|
1892
|
-
disabled,
|
|
1893
|
-
children,
|
|
1894
|
-
name,
|
|
1895
|
-
title,
|
|
1896
|
-
defaultChecked,
|
|
1897
|
-
checked,
|
|
1898
|
-
onBlur,
|
|
1899
|
-
onFocus,
|
|
1900
|
-
onMouseEnter,
|
|
1901
|
-
onMouseLeave,
|
|
1902
|
-
noStyle
|
|
1903
|
-
}, ref) => {
|
|
1904
|
-
const handleChange = () => {
|
|
1905
|
-
if (!disabled) {
|
|
1906
|
-
onClick?.(parseValue(title ?? value));
|
|
1907
|
-
onChange?.(parseValue(title ?? value));
|
|
1908
|
-
}
|
|
1909
|
-
};
|
|
1910
|
-
useEffect(() => {
|
|
1911
|
-
if (defaultChecked ?? checked) {
|
|
1912
|
-
onChange?.(parseValue(value));
|
|
1913
|
-
}
|
|
1914
|
-
}, [defaultChecked, checked]);
|
|
1915
|
-
return jsxs("label", {
|
|
1916
|
-
ref: ref,
|
|
1917
|
-
title: title,
|
|
1918
|
-
onMouseEnter: onMouseEnter,
|
|
1919
|
-
onMouseLeave: onMouseLeave,
|
|
1920
|
-
className: clsx([`${prefixCls}-label`, {
|
|
1921
|
-
disabled,
|
|
1922
|
-
noStyle: noStyle,
|
|
1923
|
-
[className]: className
|
|
1924
|
-
}]),
|
|
1925
|
-
children: [jsx("input", {
|
|
1926
|
-
name: name,
|
|
1927
|
-
type: "radio",
|
|
1928
|
-
onClick: onClick,
|
|
1929
|
-
disabled: disabled,
|
|
1930
|
-
onChange: handleChange,
|
|
1931
|
-
onBlur: e => onBlur?.(e),
|
|
1932
|
-
onFocus: e => onFocus?.(e)
|
|
1933
|
-
}), jsx("span", {
|
|
1934
|
-
className: clsx([`${prefixCls} ${prefixCls}-${disabled ? 'disabled' : 'enabled'}`])
|
|
1935
|
-
}), jsx("span", {
|
|
1936
|
-
className: `${prefixCls}-title`,
|
|
1937
|
-
children: children ?? title ?? value
|
|
1938
|
-
})]
|
|
1939
|
-
});
|
|
1940
|
-
});
|
|
1941
|
-
RadioComponent.displayName = 'Radio';
|
|
1942
|
-
const Radio = Object.assign(RadioComponent, {
|
|
1943
|
-
Group: RadioGroup,
|
|
1944
|
-
Button: RadioButton
|
|
1945
|
-
});
|
|
1946
|
-
|
|
1947
|
-
var css_248z$b = ".xUi-select-options{list-style:none;margin:0;padding:4px}.xUi-select-option,.xUi-select-options{border-radius:var(--xui-border-radius-sm)}.xUi-select-option{align-items:center;color:var(--xui-text-color);cursor:pointer;display:flex;font-size:var(--xui-font-size-md);padding:8px 16px}.xUi-select-option.xUi-select-focused,.xUi-select-option:hover{background-color:var(--xui-primary-color);color:var(--xui-background-color)}.xUi-select-option.xUi-select-focused{align-items:center;display:flex;font-weight:600;justify-content:space-between}.xUi-select-option.xUi-select-disabled{color:rgba(0,0,0,.25);cursor:not-allowed}.xUi-select-option.selected{background-color:var(--xui-primary-color);color:var(--xui-background-color)}.xUi-select-option.selected:hover{background-color:var(--xui-primary-color-light)}";
|
|
1948
|
-
styleInject(css_248z$b);
|
|
1949
|
-
|
|
1950
|
-
const Option = ({
|
|
1951
|
-
value,
|
|
1952
|
-
children,
|
|
1953
|
-
disabled,
|
|
1954
|
-
className = '',
|
|
1955
|
-
style,
|
|
1956
|
-
onClick,
|
|
1957
|
-
render,
|
|
1958
|
-
prefixCls = prefixClsSelect,
|
|
1959
|
-
selected,
|
|
1960
|
-
title
|
|
1961
|
-
}) => {
|
|
1962
|
-
const handleClick = e => {
|
|
1963
|
-
if (disabled) {
|
|
1964
|
-
return;
|
|
1965
|
-
}
|
|
1966
|
-
onClick?.(e);
|
|
1967
|
-
};
|
|
1968
|
-
return jsx("div", {
|
|
1969
|
-
className: clsx([`${prefixCls}-option ${className} `, {
|
|
1970
|
-
selected: selected,
|
|
1971
|
-
disabled: disabled
|
|
1972
|
-
}]),
|
|
1973
|
-
style: style,
|
|
1974
|
-
onClick: handleClick,
|
|
1975
|
-
...(title ? {
|
|
1976
|
-
title
|
|
1977
|
-
} : {}),
|
|
1978
|
-
children: render ? render(value) : children || value
|
|
1979
|
-
});
|
|
1980
|
-
};
|
|
1981
|
-
|
|
1982
|
-
var css_248z$a = ".xUi-select .xUi-select-tag-container{display:flex;flex:auto;flex-wrap:wrap;gap:4px;line-height:12px;position:relative}.xUi-select.large .xUi-select-tag-container,.xUi-select.middle .xUi-select-tag-container{line-height:22px}.xUi-select .xUi-select-tag{align-items:center;align-self:center;background:rgba(0,0,0,.06);border:1px solid transparent;border-radius:var(--xui-border-radius-sm);box-sizing:border-box;cursor:default;display:flex;flex:none;height:100%;max-width:100%;overflow:hidden;padding:2px;text-overflow:ellipsis;transition:font-size .3s,line-height .3s,height .3s;white-space:nowrap}.xUi-select.middle .xUi-select-tag{padding:4px 8px}.xUi-select.large .xUi-select-tag{font-size:var(--xui-font-size-lg);padding:8px}.xUi-select .xUi-select-tag span{font-size:var(--xui-font-size-sm);margin:0 2px}.xUi-select .xUi-select-tag .xUi-select-tag-close-icon{color:rgba(0,0,0,.5);cursor:pointer;font-size:var(--xui-font-size-xs)}.xUi-select .xUi-select-tag .xUi-select-tag-close-icon:hover{color:var(--xui-text-color)}.xUi-select .xUi-select-tag:has([class=xUi-select-tag-input]){background:transparent;border:none;color:var(--xui-text-color);font-size:var(--xui-font-size-md);outline:none;padding:0}.xUi-select .xUi-select-tag:has([class=xUi-select-tag-input]) input{background-color:transparent;border:none;font-size:var(--xui-font-size-md);height:-webkit-fill-available;padding:0}.xUi-select .xUi-select-tag-input:focus{border:none;box-shadow:none;outline:none}";
|
|
1983
|
-
styleInject(css_248z$a);
|
|
1984
|
-
|
|
1985
|
-
const Tag = ({
|
|
1986
|
-
prefixCls = prefixClsSelect,
|
|
1987
|
-
style = {},
|
|
1988
|
-
onClose,
|
|
1989
|
-
value,
|
|
1990
|
-
label,
|
|
1991
|
-
closable,
|
|
1992
|
-
color,
|
|
1993
|
-
icon
|
|
1994
|
-
}) => {
|
|
1995
|
-
const handleOnClick = e => {
|
|
1996
|
-
e.preventDefault();
|
|
1997
|
-
e.stopPropagation();
|
|
1998
|
-
e.target.value = value;
|
|
1999
|
-
onClose(e);
|
|
2000
|
-
};
|
|
2001
|
-
return jsxs("div", {
|
|
2002
|
-
style: {
|
|
2003
|
-
...style,
|
|
2004
|
-
backgroundColor: color
|
|
2005
|
-
},
|
|
2006
|
-
className: `${prefixCls}-tag`,
|
|
2007
|
-
children: [jsx("span", {
|
|
2008
|
-
children: label !== undefined ? label : value
|
|
2009
|
-
}), closable && jsx("span", {
|
|
2010
|
-
className: `${prefixCls}-tag-close-icon`,
|
|
2011
|
-
onClick: handleOnClick,
|
|
2012
|
-
children: icon || jsx(Fragment$1, {
|
|
2013
|
-
children: "\u2715"
|
|
2014
|
-
})
|
|
2015
|
-
})]
|
|
2016
|
-
});
|
|
2017
|
-
};
|
|
2018
|
-
|
|
2019
|
-
var css_248z$9 = ".xUi-empty{align-items:center;display:grid;gap:4px;justify-content:center;padding:14px}.xUi-empty-description{color:var(--xui-text-color);font-size:var(--xui-font-size-md);text-align:center}";
|
|
2020
|
-
styleInject(css_248z$9);
|
|
2021
|
-
|
|
2022
|
-
const EmptyContent = ({
|
|
2023
|
-
icon,
|
|
2024
|
-
style = {},
|
|
2025
|
-
className = '',
|
|
2026
|
-
title = 'No Data',
|
|
2027
|
-
description = 'No data',
|
|
2028
|
-
prefixCls = prefixClsEmpty
|
|
2029
|
-
}) => jsxs("div", {
|
|
2030
|
-
style: style,
|
|
2031
|
-
className: `${prefixCls} ${prefixCls}-normal ${prefixCls}-small ${className}`,
|
|
2032
|
-
children: [jsx("div", {
|
|
2033
|
-
className: `${prefixCls}-image`,
|
|
2034
|
-
children: icon || jsxs("svg", {
|
|
2035
|
-
width: "64",
|
|
2036
|
-
height: "41",
|
|
2037
|
-
viewBox: "0 0 64 41",
|
|
2038
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
2039
|
-
children: [jsx("title", {
|
|
2040
|
-
children: title
|
|
2041
|
-
}), jsxs("g", {
|
|
2042
|
-
transform: "translate(0 1)",
|
|
2043
|
-
fill: "none",
|
|
2044
|
-
children: [jsx("ellipse", {
|
|
2045
|
-
fill: "#f5f5f5",
|
|
2046
|
-
cx: "32",
|
|
2047
|
-
cy: "33",
|
|
2048
|
-
rx: "32",
|
|
2049
|
-
ry: "7"
|
|
2050
|
-
}), jsxs("g", {
|
|
2051
|
-
stroke: "#d9d9d9",
|
|
2052
|
-
children: [jsx("path", {
|
|
2053
|
-
d: "M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"
|
|
2054
|
-
}), jsx("path", {
|
|
2055
|
-
d: "M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z",
|
|
2056
|
-
fill: "#fafafa"
|
|
2057
|
-
})]
|
|
2058
|
-
})]
|
|
2059
|
-
})]
|
|
2060
|
-
})
|
|
2061
|
-
}), jsx("div", {
|
|
2062
|
-
className: `${prefixCls}-description`,
|
|
2063
|
-
children: description
|
|
2064
|
-
})]
|
|
2065
|
-
});
|
|
2066
|
-
|
|
2067
|
-
var css_248z$8 = "@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.xUi-select{background-color:transparent;border:1px solid var(--xui-border-color);border-radius:var(--xui-border-radius-sm);box-sizing:border-box;color:var(--xui-text-color);display:inline-flex;flex-direction:row-reverse;margin-bottom:15px;min-height:24px;padding:2px 8px;position:relative;width:100%}.xUi-select-disabled{background:rgba(0,0,0,.04)}.xUi-select-arrow{align-items:center;color:var(--xui-text-color-light);display:flex;gap:6px;margin:0 4px}.xUi-select-arrow svg{align-items:center;display:flex;justify-content:center}.xUi-select-loading{animation:spin 1s linear infinite;color:var(--xui-text-color-light);display:inline-block;margin:0 8px}.xUi-select .xUi-select-trigger{align-items:center;background:transparent;border-radius:var(--xui-border-radius-sm);cursor:pointer;display:flex;justify-content:end;width:100%}.xUi-select .xUi-select-clear-btn{background:none;border:none;color:#999;cursor:pointer;font-size:var(--xui-font-size-lg);line-height:1;margin:0 8px;padding:0}.xUi-select .xUi-select-clear-btn:hover{color:var(--xui-primary-color)}.xUi-select-dropdown{background-color:var(--xui-select-background-color);border-radius:var(--xui-border-radius-sm);box-shadow:0 4px 12px rgba(0,0,0,.15);left:0;margin-top:5px;max-height:200px;min-width:max-content;overflow-y:auto;position:absolute;right:unset;top:100%;width:inherit;z-index:10}.xUi-select-dropdown.bottomRight,.xUi-select-dropdown.topRight{left:unset;right:0}.xUi-select .xUi-select-loading-spinner{color:#999;padding:10px;text-align:center}.xUi-select:focus-within{border-color:var(--xui-primary-color-light);box-shadow:none}.xUi-select:hover:not(.xUi-select-disabled){border-color:var(--xui-primary-color)}.xUi-select-disabled,.xUi-select-disabled .xUi-select-input,.xUi-select-disabled .xUi-select-trigger{cursor:not-allowed!important;opacity:.6!important}.xUi-select-selected-icon{color:var(--xui-primary-color-light)}.xUi-select-error{border-color:var(--xui-error-color)}.xUi-select-arrow .error-svg-icon,.xUi-select-error .error-svg-icon{color:var(--xui-error-color)}.xUi-select .xUi-select-input{align-items:center;background:transparent;border:none;color:var(--xui-text-color);cursor:pointer;display:inline-flex;font-size:var(--xui-font-size-md);height:-webkit-fill-available;outline:none;padding:0;user-select:none;width:100%}.xUi-select .xUi-select-input:focus{border:none;box-shadow:none;outline:none}.xUi-select.middle{border-radius:var(--xui-border-radius-md);min-height:30px}.xUi-select.middle,.xUi-select.middle input{font-size:var(--xui-font-size-md)}.xUi-select.middle .xUi-select-trigger{border-radius:var(--xui-border-radius-md)}.xUi-select.large{font-size:var(--xui-font-size-lg);min-height:40px}.xUi-select.large,.xUi-select.large .xUi-select-trigger{border-radius:var(--xui-border-radius-lg)}.xUi-select input{font-size:var(--xui-font-size-lg)}";
|
|
2068
|
-
styleInject(css_248z$8);
|
|
2069
|
-
|
|
2070
|
-
const LIST_HEIGHT = 200;
|
|
2071
|
-
const PADDING_PLACEMENT = 18;
|
|
2072
|
-
const PADDING_TAG_INPUT = 4;
|
|
2073
|
-
const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
2074
|
-
prefixCls = prefixClsSelect,
|
|
2075
|
-
id,
|
|
2076
|
-
searchValue = '',
|
|
2077
|
-
autoClearSearchValue = true,
|
|
2078
|
-
filterOption = true,
|
|
2079
|
-
optionFilterProp = 'value',
|
|
2080
|
-
children,
|
|
2081
|
-
options = [],
|
|
2082
|
-
listHeight = LIST_HEIGHT,
|
|
2083
|
-
menuItemSelectedIcon,
|
|
2084
|
-
mode = 'default',
|
|
2085
|
-
value,
|
|
2086
|
-
defaultValue,
|
|
2087
|
-
maxCount,
|
|
2088
|
-
disabled = false,
|
|
2089
|
-
loading = false,
|
|
2090
|
-
placeholder = 'Select',
|
|
2091
|
-
allowClear = false,
|
|
2092
|
-
filterable = false,
|
|
2093
|
-
defaultOpen = false,
|
|
2094
|
-
size = 'large',
|
|
2095
|
-
error = false,
|
|
2096
|
-
dropdownClassName = '',
|
|
2097
|
-
suffixIcon,
|
|
2098
|
-
style,
|
|
2099
|
-
onSearch,
|
|
2100
|
-
onSelect,
|
|
2101
|
-
onDeselect,
|
|
2102
|
-
onClear,
|
|
2103
|
-
onChange,
|
|
2104
|
-
showSearch = false,
|
|
2105
|
-
open = false,
|
|
2106
|
-
showArrow = true,
|
|
2107
|
-
notFoundContent = false,
|
|
2108
|
-
tagRender,
|
|
2109
|
-
getPopupContainer,
|
|
2110
|
-
dropdownRender,
|
|
2111
|
-
noStyle,
|
|
2112
|
-
feedbackIcons,
|
|
2113
|
-
placement = 'bottomLeft',
|
|
2114
|
-
removeIcon
|
|
2115
|
-
}, ref) => {
|
|
2116
|
-
const asTag = mode === 'tags';
|
|
2117
|
-
const asMultiple = mode === 'multiple';
|
|
2118
|
-
const hasMode = asTag || asMultiple;
|
|
2119
|
-
const initialValue = useMemo(() => value || defaultValue || '', [value, defaultValue]);
|
|
2120
|
-
const checkModeInitialValue = useMemo(() => (!Array.isArray(initialValue) ? [initialValue] : initialValue).filter(e => e), [initialValue]);
|
|
2121
|
-
const [isHover, setIsHover] = useState(false);
|
|
2122
|
-
const selectRef = useRef(null);
|
|
2123
|
-
const [searchInputWidth, setSearchInputWidth] = useState(0);
|
|
2124
|
-
const [isOpen, setIsOpen] = useState(defaultOpen || open);
|
|
2125
|
-
const [searchQuery, setSearchQuery] = useState(searchValue || '');
|
|
2126
|
-
const [dropdownPosition, setDropdownPosition] = useState({});
|
|
2127
|
-
const [selected, setSelected] = useState(hasMode ? checkModeInitialValue : initialValue);
|
|
2128
|
-
useImperativeHandle(ref, () => ({
|
|
2129
|
-
focus: () => selectRef.current?.focus(),
|
|
2130
|
-
blur: () => selectRef.current?.blur(),
|
|
2131
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2132
|
-
// @ts-expect-error
|
|
2133
|
-
scrollTo: (...args) =>
|
|
2134
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2135
|
-
// @ts-expect-error
|
|
2136
|
-
selectRef.current?.scrollTo(...args),
|
|
2137
|
-
nativeElement: selectRef.current
|
|
2138
|
-
}));
|
|
2139
|
-
const handleMouseEnter = () => !disabled && selected?.length && setIsHover(true);
|
|
2140
|
-
const handleMouseLeave = () => !disabled && setIsHover(false);
|
|
2141
|
-
const handleClearInputValue = useCallback(() => {
|
|
2142
|
-
if (!autoClearSearchValue) {
|
|
2143
|
-
return;
|
|
2144
|
-
}
|
|
2145
|
-
setSearchQuery('');
|
|
2146
|
-
const inputContainer = selectRef.current?.querySelector("[content-editable='plaintext-only']");
|
|
2147
|
-
if (inputContainer) {
|
|
2148
|
-
inputContainer.innerText = '';
|
|
2149
|
-
}
|
|
2150
|
-
}, [autoClearSearchValue]);
|
|
2151
|
-
useEffect(() => {
|
|
2152
|
-
const handleClickOutside = event => {
|
|
2153
|
-
if (selectRef.current && !selectRef.current.contains(event.target)) {
|
|
2154
|
-
setIsOpen(open);
|
|
2155
|
-
if (hasMode) {
|
|
2156
|
-
handleClearInputValue();
|
|
2157
|
-
}
|
|
2158
|
-
}
|
|
2159
|
-
};
|
|
2160
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
2161
|
-
return () => {
|
|
2162
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
2163
|
-
};
|
|
2164
|
-
}, [handleClearInputValue, open, hasMode]);
|
|
2165
|
-
useEffect(() => {
|
|
2166
|
-
if (!selectRef.current || !getPopupContainer) {
|
|
2167
|
-
return;
|
|
2168
|
-
}
|
|
2169
|
-
const selectBox = selectRef.current.getBoundingClientRect();
|
|
2170
|
-
const dropdownHeight = listHeight;
|
|
2171
|
-
const windowHeight = window.innerHeight;
|
|
2172
|
-
const spaceBelow = windowHeight - selectBox.bottom;
|
|
2173
|
-
const spaceAbove = selectBox.top;
|
|
2174
|
-
let positionStyle = {
|
|
2175
|
-
top: `${selectBox.bottom}px`,
|
|
2176
|
-
left: `${selectBox.left}px`,
|
|
2177
|
-
width: `${selectBox.width}px`
|
|
2178
|
-
};
|
|
2179
|
-
if (spaceBelow < dropdownHeight && spaceAbove > dropdownHeight) {
|
|
2180
|
-
positionStyle = {
|
|
2181
|
-
top: `${selectBox.top - dropdownHeight}px`,
|
|
2182
|
-
left: `${selectBox.left}px`,
|
|
2183
|
-
width: `${selectBox.width}px`
|
|
2184
|
-
};
|
|
2185
|
-
}
|
|
2186
|
-
setDropdownPosition(positionStyle);
|
|
2187
|
-
}, [listHeight, getPopupContainer]);
|
|
2188
|
-
const handleSearch = e => {
|
|
2189
|
-
setSearchQuery(e.target.value);
|
|
2190
|
-
onSearch?.(e.target.value);
|
|
2191
|
-
if (!isOpen) {
|
|
2192
|
-
setIsOpen(!isOpen || open);
|
|
2193
|
-
handleClearInputValue();
|
|
2194
|
-
}
|
|
2195
|
-
};
|
|
2196
|
-
const handleEnterAddNewTag = () => {
|
|
2197
|
-
if (asMultiple || maxCount && selected.length >= maxCount && !selected.includes(searchQuery)) {
|
|
2198
|
-
return;
|
|
2199
|
-
}
|
|
2200
|
-
const newOptionValue = searchQuery.trim();
|
|
2201
|
-
if (!newOptionValue || !hasMode || selected.includes(newOptionValue)) {
|
|
2202
|
-
return;
|
|
2203
|
-
}
|
|
2204
|
-
const updatedSelected = [...selected, newOptionValue];
|
|
2205
|
-
onChange?.(updatedSelected);
|
|
2206
|
-
onSelect?.(newOptionValue);
|
|
2207
|
-
const input = selectRef.current?.querySelector('input');
|
|
2208
|
-
if (input) {
|
|
2209
|
-
input.value = '';
|
|
2210
|
-
}
|
|
2211
|
-
setSelected(updatedSelected);
|
|
2212
|
-
handleClearInputValue();
|
|
2213
|
-
};
|
|
2214
|
-
const handleSelect = (e, optionValue, option) => {
|
|
2215
|
-
if (hasMode) {
|
|
2216
|
-
if (maxCount && selected.length >= maxCount && !selected.includes(optionValue)) {
|
|
2217
|
-
return;
|
|
2218
|
-
}
|
|
2219
|
-
const newSelection = selected.includes(optionValue) ? selected.filter(item => item !== optionValue) : [...selected, optionValue];
|
|
2220
|
-
setSelected(newSelection);
|
|
2221
|
-
onChange?.(newSelection, option);
|
|
2222
|
-
if (selected.includes(optionValue)) {
|
|
2223
|
-
onDeselect?.(optionValue, option);
|
|
2224
|
-
} else {
|
|
2225
|
-
onSelect?.(optionValue, option);
|
|
2226
|
-
}
|
|
2227
|
-
} else {
|
|
2228
|
-
setIsOpen(open);
|
|
2229
|
-
setSelected(optionValue);
|
|
2230
|
-
onChange?.(optionValue, option);
|
|
2231
|
-
onSelect?.(optionValue, option);
|
|
2232
|
-
}
|
|
2233
|
-
handleClearInputValue();
|
|
2234
|
-
};
|
|
2235
|
-
const handleClear = () => {
|
|
2236
|
-
const value = hasMode ? [] : '';
|
|
2237
|
-
setSelected(value);
|
|
2238
|
-
onChange?.('');
|
|
2239
|
-
onClear?.();
|
|
2240
|
-
handleClearInputValue();
|
|
2241
|
-
};
|
|
2242
|
-
const handleRemoveTag = e => {
|
|
2243
|
-
const updatedSelected = hasMode ? selected.filter(item => item !== e.target.value) : e.target.value;
|
|
2244
|
-
onChange?.(updatedSelected);
|
|
2245
|
-
setSelected(updatedSelected);
|
|
2246
|
-
};
|
|
2247
|
-
const handleOnKeyDown = e => {
|
|
2248
|
-
const timeout = setTimeout(() => {
|
|
2249
|
-
e.target.value = e.target.innerText.trim().replace('\n', '');
|
|
2250
|
-
setSearchQuery(e.target.value);
|
|
2251
|
-
onSearch?.(e.target.value);
|
|
2252
|
-
if (e.key === 'Enter' && searchQuery.trim() !== '') {
|
|
2253
|
-
if (!asTag) {
|
|
2254
|
-
e.stopPropagation();
|
|
2255
|
-
e.preventDefault();
|
|
2256
|
-
clearTimeout(timeout);
|
|
2257
|
-
return;
|
|
2258
|
-
}
|
|
2259
|
-
handleEnterAddNewTag();
|
|
2260
|
-
e.target.innerText = '';
|
|
2261
|
-
}
|
|
2262
|
-
if (e.key === 'Backspace' && (hasMode ? !searchQuery.trim().length : searchQuery.trim().length)) {
|
|
2263
|
-
const updatedSelected = hasMode ? selected.filter(item => item !== selected[selected.length - 1]) : searchQuery.trim();
|
|
2264
|
-
onChange?.(updatedSelected);
|
|
2265
|
-
setSelected(updatedSelected);
|
|
2266
|
-
}
|
|
2267
|
-
clearTimeout(timeout);
|
|
2268
|
-
});
|
|
2269
|
-
};
|
|
2270
|
-
const ArrowContainer = useMemo(() => {
|
|
2271
|
-
if (!showArrow) {
|
|
2272
|
-
return null;
|
|
2273
|
-
}
|
|
2274
|
-
return showSearch && isOpen ? jsx(SearchIcon, {}) : jsx("span", {
|
|
2275
|
-
children: suffixIcon || showArrow && jsx(ArrowIcon, {
|
|
2276
|
-
isOpen: isOpen
|
|
2277
|
-
})
|
|
2278
|
-
});
|
|
2279
|
-
}, [showArrow, showSearch, isOpen, suffixIcon]);
|
|
2280
|
-
const popupContainer = useMemo(() => {
|
|
2281
|
-
return selectRef.current ? getPopupContainer?.(selectRef.current) : selectRef.current;
|
|
2282
|
-
}, [getPopupContainer]);
|
|
2283
|
-
const extractedOptions = children ? (Array.isArray(children) ? children : [children]).filter(e => e).map(child => child.props) : options;
|
|
2284
|
-
const filteredOptions = extractedOptions.filter(option => {
|
|
2285
|
-
if (typeof filterOption === 'function') {
|
|
2286
|
-
return filterOption(searchQuery, option);
|
|
2287
|
-
}
|
|
2288
|
-
if (filterOption === false) {
|
|
2289
|
-
return true;
|
|
2290
|
-
}
|
|
2291
|
-
const valueToCheck = `${['string', 'number'].includes(typeof option.children) ? option.children :
|
|
2292
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2293
|
-
// @ts-expect-error
|
|
2294
|
-
option[optionFilterProp] || option.value}`;
|
|
2295
|
-
return valueToCheck.toLowerCase().includes(searchQuery.toLowerCase());
|
|
2296
|
-
});
|
|
2297
|
-
const handleTriggerClick = () => {
|
|
2298
|
-
if (!disabled) {
|
|
2299
|
-
setIsOpen(!isOpen);
|
|
2300
|
-
}
|
|
2301
|
-
const searchContent = document.getElementsByClassName(`${prefixCls}-tag-container`)?.[0];
|
|
2302
|
-
if (searchContent) {
|
|
2303
|
-
setSearchInputWidth(searchContent.clientWidth - PADDING_TAG_INPUT);
|
|
2304
|
-
}
|
|
2305
|
-
const timeout = setTimeout(() => {
|
|
2306
|
-
const searchInput = document.getElementById(`${prefixCls}-search-tag-input`);
|
|
2307
|
-
if (searchInput) {
|
|
2308
|
-
searchInput?.focus();
|
|
2309
|
-
}
|
|
2310
|
-
clearTimeout(timeout);
|
|
2311
|
-
}, 0);
|
|
2312
|
-
};
|
|
2313
|
-
const dataRender = (() => {
|
|
2314
|
-
const options = filteredOptions.map(({
|
|
2315
|
-
children,
|
|
2316
|
-
className = '',
|
|
2317
|
-
...props
|
|
2318
|
-
}) => {
|
|
2319
|
-
const isSelected = hasMode ? selected.includes(props.value) : props.value === selected;
|
|
2320
|
-
return jsxs(Option, {
|
|
2321
|
-
...props,
|
|
2322
|
-
selected: isSelected,
|
|
2323
|
-
className: clsx([className, {
|
|
2324
|
-
[`${prefixCls}-focused`]: hasMode ? isSelected : props.value === selected,
|
|
2325
|
-
[`${prefixCls}-disabled`]: maxCount && hasMode && !isSelected ? selected.length >= maxCount : false
|
|
2326
|
-
}]),
|
|
2327
|
-
onClick: e => {
|
|
2328
|
-
if (props.disabled) {
|
|
2329
|
-
return;
|
|
2330
|
-
}
|
|
2331
|
-
handleSelect(e, props.value, {
|
|
2332
|
-
children,
|
|
2333
|
-
className,
|
|
2334
|
-
...props
|
|
2335
|
-
});
|
|
2336
|
-
},
|
|
2337
|
-
"data-value": props.value,
|
|
2338
|
-
children: [children || props.value, hasMode && isSelected && jsx("span", {
|
|
2339
|
-
className: `${prefixCls}-selected-icon`,
|
|
2340
|
-
children: menuItemSelectedIcon === true ? jsx(CheckIcon, {}) : menuItemSelectedIcon
|
|
2341
|
-
})]
|
|
2342
|
-
}, `${props.value}`);
|
|
2343
|
-
});
|
|
2344
|
-
return dropdownRender ? dropdownRender(options) : options;
|
|
2345
|
-
})();
|
|
2346
|
-
const dropdownContent = !loading && isOpen && jsxs("div", {
|
|
2347
|
-
className: clsx([`${prefixCls}-dropdown`, {
|
|
2348
|
-
[placement]: placement,
|
|
2349
|
-
[dropdownClassName]: dropdownClassName
|
|
2350
|
-
}]),
|
|
2351
|
-
style: {
|
|
2352
|
-
...dropdownPosition,
|
|
2353
|
-
maxHeight: listHeight,
|
|
2354
|
-
...(['topLeft', 'topRight'].includes(placement) ? {
|
|
2355
|
-
top: -((selectRef.current?.querySelector(`.${prefixCls}-dropdown`)?.clientHeight || listHeight) + PADDING_PLACEMENT) + (selectRef.current?.clientHeight || 0)
|
|
2356
|
-
} : {})
|
|
2357
|
-
},
|
|
2358
|
-
children: [filterable && jsx("input", {
|
|
2359
|
-
type: "text",
|
|
2360
|
-
className: `${prefixCls}-search`,
|
|
2361
|
-
value: searchQuery,
|
|
2362
|
-
onChange: handleSearch,
|
|
2363
|
-
placeholder: "Search..."
|
|
2364
|
-
}), !loading && jsxs("div", {
|
|
2365
|
-
className: `${prefixCls}-options globalEllipsis`,
|
|
2366
|
-
style: {
|
|
2367
|
-
maxHeight: listHeight,
|
|
2368
|
-
overflowY: 'auto'
|
|
2369
|
-
},
|
|
2370
|
-
children: [asTag && !!searchQuery && jsx(Option, {
|
|
2371
|
-
value: searchQuery,
|
|
2372
|
-
className: `${prefixCls}-focused`,
|
|
2373
|
-
onClick: e => {
|
|
2374
|
-
handleSelect(e, searchQuery);
|
|
2375
|
-
},
|
|
2376
|
-
"data-value": searchQuery,
|
|
2377
|
-
children: searchQuery
|
|
2378
|
-
}), filteredOptions.length ? dataRender : !asTag ? notFoundContent || jsx(EmptyContent, {}) : null]
|
|
2379
|
-
})]
|
|
2380
|
-
});
|
|
2381
|
-
return jsxs("div", {
|
|
2382
|
-
id: id,
|
|
2383
|
-
ref: selectRef,
|
|
2384
|
-
style: style,
|
|
2385
|
-
className: clsx([{
|
|
2386
|
-
[size]: size,
|
|
2387
|
-
noStyle: noStyle,
|
|
2388
|
-
[prefixCls]: prefixCls,
|
|
2389
|
-
[`${prefixCls}-error`]: error,
|
|
2390
|
-
[`${prefixCls}-multi`]: hasMode,
|
|
2391
|
-
[`${prefixCls}-disabled`]: disabled
|
|
2392
|
-
}]),
|
|
2393
|
-
children: [jsxs("div", {
|
|
2394
|
-
onClick: handleTriggerClick,
|
|
2395
|
-
onMouseEnter: handleMouseEnter,
|
|
2396
|
-
onMouseLeave: handleMouseLeave,
|
|
2397
|
-
className: `${prefixCls}-trigger`,
|
|
2398
|
-
children: [showSearch ? jsxs("div", {
|
|
2399
|
-
style: {
|
|
2400
|
-
...style,
|
|
2401
|
-
...(isOpen ? {
|
|
2402
|
-
maxWidth: `${searchInputWidth}px`
|
|
2403
|
-
} : {}),
|
|
2404
|
-
minWidth: `${searchInputWidth}px`
|
|
2405
|
-
},
|
|
2406
|
-
className: `${prefixCls}-tag-container`,
|
|
2407
|
-
children: [hasMode && selected.map((tag, index) => tagRender ? jsx("div", {
|
|
2408
|
-
children: tagRender?.({
|
|
2409
|
-
label: extractedOptions.find(e => e.value === tag)?.children || tag,
|
|
2410
|
-
value: tag,
|
|
2411
|
-
onClose: handleRemoveTag,
|
|
2412
|
-
closable: true
|
|
2413
|
-
})
|
|
2414
|
-
}, `${index}_${tag}`) : jsx(Tag, {
|
|
2415
|
-
closable: true,
|
|
2416
|
-
value: tag,
|
|
2417
|
-
label: tag === '' ? placeholder : extractedOptions.find(e => e.value === tag)?.children || tag,
|
|
2418
|
-
onClose: handleRemoveTag
|
|
2419
|
-
}, `${index}_${tag}`)), isOpen ? jsx("div", {
|
|
2420
|
-
className: `${prefixCls}-tag`,
|
|
2421
|
-
children: jsx("div", {
|
|
2422
|
-
onClick: e => {
|
|
2423
|
-
if (disabled) {
|
|
2424
|
-
e.preventDefault();
|
|
2425
|
-
e.stopPropagation();
|
|
2426
|
-
return;
|
|
2427
|
-
}
|
|
2428
|
-
},
|
|
2429
|
-
onKeyDown: handleOnKeyDown,
|
|
2430
|
-
style: {
|
|
2431
|
-
width: 'auto',
|
|
2432
|
-
display: 'ruby',
|
|
2433
|
-
textAlign: 'center'
|
|
2434
|
-
},
|
|
2435
|
-
contentEditable: "plaintext-only",
|
|
2436
|
-
id: `${prefixCls}-search-tag-input`,
|
|
2437
|
-
className: `${prefixCls}-tag-input`
|
|
2438
|
-
})
|
|
2439
|
-
}) : !hasMode ? jsx("div", {
|
|
2440
|
-
className: `${prefixCls}-input`,
|
|
2441
|
-
style: {
|
|
2442
|
-
opacity: isOpen || selected === '' ? '0.6' : '1'
|
|
2443
|
-
},
|
|
2444
|
-
children: selected === '' ? placeholder : extractedOptions.find(e => e.value === selected)?.children || selected
|
|
2445
|
-
}) : null]
|
|
2446
|
-
}) : !hasMode ? jsx("div", {
|
|
2447
|
-
className: `${prefixCls}-input`,
|
|
2448
|
-
onClick: () => !disabled && setIsOpen(!isOpen || open),
|
|
2449
|
-
style: {
|
|
2450
|
-
opacity: isOpen || selected === '' ? '0.6' : '1'
|
|
2451
|
-
},
|
|
2452
|
-
children: selected === '' ? placeholder : (() => {
|
|
2453
|
-
const option = extractedOptions.find(e => e.value === selected);
|
|
2454
|
-
return option?.children || option?.value || null;
|
|
2455
|
-
})()
|
|
2456
|
-
}) : null, isHover && !loading ? allowClear && selected ? jsx("button", {
|
|
2457
|
-
className: `${prefixCls}-clear-btn`,
|
|
2458
|
-
onClick: handleClear,
|
|
2459
|
-
children: removeIcon || jsx(ClearIcon, {})
|
|
2460
|
-
}) : jsxs("span", {
|
|
2461
|
-
className: `${prefixCls}-arrow`,
|
|
2462
|
-
children: [ArrowContainer, error && feedbackIcons ? jsx(ErrorIcon, {}) : null]
|
|
2463
|
-
}) : jsxs(Fragment$1, {
|
|
2464
|
-
children: [!loading && jsxs("span", {
|
|
2465
|
-
className: `${prefixCls}-arrow`,
|
|
2466
|
-
children: [ArrowContainer, error && feedbackIcons ? jsx(ErrorIcon, {}) : null]
|
|
2467
|
-
}), loading && jsx("span", {
|
|
2468
|
-
className: `${prefixCls}-loading`,
|
|
2469
|
-
children: jsx(LoadingIcon, {})
|
|
2470
|
-
})]
|
|
2471
|
-
})]
|
|
2472
|
-
}), popupContainer ? /*#__PURE__*/createPortal(dropdownContent, popupContainer) : dropdownContent]
|
|
2473
|
-
});
|
|
2474
|
-
});
|
|
2475
|
-
SelectComponent.displayName = 'Select';
|
|
2476
|
-
const Select = Object.assign(SelectComponent, {
|
|
2477
|
-
Option
|
|
2478
|
-
});
|
|
2479
|
-
|
|
2480
|
-
var css_248z$7 = "@keyframes xUi-skeleton-loading{0%{background-position:100% 50%}to{background-position:0 50%}}.xUi-skeleton-element{display:inline-block!important;width:auto!important}.xUi-skeleton-button{background:hsla(0,0%,75%,.2);border-radius:4px;display:inline-block;height:32px;line-height:32px;min-width:64px;vertical-align:top;width:64px}.xUi-skeleton-button-sm{height:24px;line-height:24px;min-width:48px;width:48px}.xUi-skeleton-button-lg{height:40px;line-height:40px;min-width:80px;width:80px}.xUi-skeleton-active .xUi-skeleton-button{animation:xUi-skeleton-loading 1.4s ease infinite;background:linear-gradient(90deg,hsla(0,0%,75%,.2) 25%,hsla(0,0%,51%,.24) 37%,hsla(0,0%,75%,.2) 63%);background-size:400% 100%}";
|
|
2481
|
-
styleInject(css_248z$7);
|
|
2482
|
-
|
|
2483
|
-
const BUTTON_SKELETON_SIZE = {
|
|
2484
|
-
small: `${prefixClsSkeleton}-button-sm`,
|
|
2485
|
-
large: `${prefixClsSkeleton}-button-lg`,
|
|
2486
|
-
default: ''
|
|
2487
|
-
};
|
|
2488
|
-
const SkeletonButton = ({
|
|
2489
|
-
prefixCls = prefixClsSkeleton,
|
|
2490
|
-
style = {},
|
|
2491
|
-
active,
|
|
2492
|
-
className,
|
|
2493
|
-
size = 'default',
|
|
2494
|
-
applyElementStyle = true
|
|
2495
|
-
}) => {
|
|
2496
|
-
return jsx("div", {
|
|
2497
|
-
className: clsx([`${prefixCls}`, {
|
|
2498
|
-
[`${prefixCls}-element`]: applyElementStyle,
|
|
2499
|
-
[`${prefixCls}-active`]: active
|
|
2500
|
-
}, className]),
|
|
2501
|
-
children: jsx("span", {
|
|
2502
|
-
className: clsx([`${prefixCls}-button `, BUTTON_SKELETON_SIZE[size], className]),
|
|
2503
|
-
style: style
|
|
2504
|
-
})
|
|
2505
|
-
});
|
|
2506
|
-
};
|
|
2507
|
-
|
|
2508
|
-
var css_248z$6 = "@keyframes xUi-skeleton-loading{0%{background-position:100% 50%}to{background-position:0 50%}}.xUi-skeleton-avatar{animation:xUi-skeleton-loading 1.4s ease infinite;background:linear-gradient(90deg,hsla(0,0%,75%,.2) 25%,hsla(0,0%,51%,.24) 37%,hsla(0,0%,75%,.2) 63%);background-size:400% 100%;display:block;height:40px;line-height:40px;width:40px}.xUi-skeleton-avatar-circle{border-radius:50%}.xUi-skeleton-avatar-square{border-radius:4px}";
|
|
2509
|
-
styleInject(css_248z$6);
|
|
2510
|
-
|
|
2511
|
-
const AVATAR_DEFAULT_SIZE = 32;
|
|
2512
|
-
const AVATAR_GLOBAL_SIZE = 40;
|
|
2513
|
-
const GET_AVATAR_SKELETON_PROPS = avatar => {
|
|
2514
|
-
return typeof avatar !== 'boolean' ? {
|
|
2515
|
-
shape: avatar?.shape || 'circle',
|
|
2516
|
-
size: avatar?.size || AVATAR_GLOBAL_SIZE,
|
|
2517
|
-
style: avatar?.style || {},
|
|
2518
|
-
className: avatar?.className || ''
|
|
2519
|
-
} : {
|
|
2520
|
-
shape: 'circle',
|
|
2521
|
-
size: AVATAR_GLOBAL_SIZE
|
|
2522
|
-
};
|
|
2523
|
-
};
|
|
2524
|
-
const SkeletonAvatar = ({
|
|
2525
|
-
prefixCls = prefixClsSkeleton,
|
|
2526
|
-
className,
|
|
2527
|
-
shape = 'circle',
|
|
2528
|
-
style,
|
|
2529
|
-
wrapperStyle,
|
|
2530
|
-
size = AVATAR_DEFAULT_SIZE,
|
|
2531
|
-
active,
|
|
2532
|
-
applyElementStyle = true,
|
|
2533
|
-
...props
|
|
2534
|
-
}) => {
|
|
2535
|
-
return jsx("div", {
|
|
2536
|
-
className: clsx([`${prefixCls}`, {
|
|
2537
|
-
[`${prefixCls}-element`]: applyElementStyle,
|
|
2538
|
-
[`${prefixCls}-active`]: active
|
|
2539
|
-
}, className]),
|
|
2540
|
-
style: wrapperStyle,
|
|
2541
|
-
...props,
|
|
2542
|
-
children: jsx("span", {
|
|
2543
|
-
className: clsx([`${prefixCls}-avatar ${prefixCls}-avatar-${shape}`]),
|
|
2544
|
-
style: {
|
|
2545
|
-
...(size ? {
|
|
2546
|
-
width: size,
|
|
2547
|
-
height: size,
|
|
2548
|
-
lineHeight: size
|
|
2549
|
-
} : {}),
|
|
2550
|
-
...(style || {})
|
|
2551
|
-
}
|
|
2552
|
-
})
|
|
2553
|
-
});
|
|
2554
|
-
};
|
|
2555
|
-
|
|
2556
|
-
var css_248z$5 = ".xUi-skeleton-image{align-items:center;background:hsla(0,0%,75%,.2);display:flex;height:96px;justify-content:center;line-height:96px;vertical-align:top;width:96px}.xUi-skeleton-image .xUi-skeleton-icon{font-size:inherit!important}.xUi-skeleton-image svg{height:100%;line-height:48px;max-width:192px;width:48px}";
|
|
2557
|
-
styleInject(css_248z$5);
|
|
2558
|
-
|
|
2559
|
-
const CUSTOm_ICON_SIZE = 48;
|
|
2560
|
-
const SkeletonImage = ({
|
|
2561
|
-
prefixCls = prefixClsSkeleton,
|
|
2562
|
-
className,
|
|
2563
|
-
style = {}
|
|
2564
|
-
}) => {
|
|
2565
|
-
return jsx("div", {
|
|
2566
|
-
className: `${prefixCls}-image ${className || ''}`,
|
|
2567
|
-
style: style,
|
|
2568
|
-
children: jsx("span", {
|
|
2569
|
-
className: `${prefixCls}-icon`,
|
|
2570
|
-
style: {
|
|
2571
|
-
fontSize: `${style?.width || CUSTOm_ICON_SIZE}px`,
|
|
2572
|
-
color: '#bfbfbf',
|
|
2573
|
-
position: 'relative',
|
|
2574
|
-
width: '100%',
|
|
2575
|
-
height: '100%',
|
|
2576
|
-
...(style?.backgroundColor ? {
|
|
2577
|
-
backgroundColor: style?.backgroundColor
|
|
2578
|
-
} : {})
|
|
2579
|
-
},
|
|
2580
|
-
children: jsx("svg", {
|
|
2581
|
-
viewBox: "0 0 1098 1024",
|
|
2582
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
2583
|
-
width: "1em",
|
|
2584
|
-
height: "1em",
|
|
2585
|
-
fill: "currentColor",
|
|
2586
|
-
children: jsx("path", {
|
|
2587
|
-
d: "M365.714286 329.142857q0 45.714286-32.036571 77.677714t-77.677714 32.036571-77.677714-32.036571-32.036571-77.677714 32.036571-77.677714 77.677714-32.036571 77.677714 32.036571 32.036571 77.677714zM950.857143 548.571429l0 256-804.571429 0 0-109.714286 182.857143-182.857143 91.428571 91.428571 292.571429-292.571429zM1005.714286 146.285714l-914.285714 0q-7.460571 0-12.873143 5.412571t-5.412571 12.873143l0 694.857143q0 7.460571 5.412571 12.873143t12.873143 5.412571l914.285714 0q7.460571 0 12.873143-5.412571t5.412571-12.873143l0-694.857143q0-7.460571-5.412571-12.873143t-12.873143-5.412571zM1097.142857 164.571429l0 694.857143q0 37.741714-26.843429 64.585143t-64.585143 26.843429l-914.285714 0q-37.741714 0-64.585143-26.843429t-26.843429-64.585143l0-694.857143q0-37.741714 26.843429-64.585143t64.585143-26.843429l914.285714 0q37.741714 0 64.585143 26.843429t26.843429 64.585143z",
|
|
2588
|
-
className: `${prefixCls}-image-path`
|
|
2589
|
-
})
|
|
2590
|
-
})
|
|
2591
|
-
})
|
|
2592
|
-
});
|
|
2593
|
-
};
|
|
2594
|
-
|
|
2595
|
-
var css_248z$4 = "@keyframes xUi-skeleton-loading{0%{background-position:100% 50%}to{background-position:0 50%}}.xUi-skeleton-element{display:inline-block!important;width:auto!important}.xUi-skeleton-input{background:hsla(0,0%,75%,.2);display:inline-block;height:32px;line-height:32px;min-width:160px;vertical-align:top;width:160px}.xUi-skeleton-input-sm{height:24px;line-height:24px;min-width:120px;width:120px}.xUi-skeleton-input-lg{height:40px;line-height:40px;min-width:200px;width:200px}.xUi-skeleton-active .xUi-skeleton-input{animation:xUi-skeleton-loading 1.4s ease infinite;background:linear-gradient(90deg,hsla(0,0%,75%,.2) 25%,hsla(0,0%,51%,.24) 37%,hsla(0,0%,75%,.2) 63%);background-size:400% 100%}.xUi-skeleton-block,.xUi-skeleton-block .xUi-skeleton-input{width:100%}";
|
|
2596
|
-
styleInject(css_248z$4);
|
|
2597
|
-
|
|
2598
|
-
const INPUT_SKELETON_SIZE = {
|
|
2599
|
-
small: `${prefixClsSkeleton}-input-sm`,
|
|
2600
|
-
large: `${prefixClsSkeleton}-input-lg`,
|
|
2601
|
-
default: ''
|
|
2602
|
-
};
|
|
2603
|
-
const SkeletonInput = ({
|
|
2604
|
-
prefixCls = prefixClsSkeleton,
|
|
2605
|
-
style,
|
|
2606
|
-
block,
|
|
2607
|
-
active,
|
|
2608
|
-
className,
|
|
2609
|
-
size = 'default'
|
|
2610
|
-
}) => {
|
|
2611
|
-
return jsx("div", {
|
|
2612
|
-
className: clsx([`${prefixCls}-element`, {
|
|
2613
|
-
[`${prefixCls}-active`]: active,
|
|
2614
|
-
[`${prefixCls}-block`]: block
|
|
2615
|
-
}, className]),
|
|
2616
|
-
children: jsx("span", {
|
|
2617
|
-
className: `${prefixCls}-input ${INPUT_SKELETON_SIZE[size]} ${className || ''}`,
|
|
2618
|
-
style: style
|
|
2619
|
-
})
|
|
2620
|
-
});
|
|
2621
|
-
};
|
|
2622
|
-
|
|
2623
|
-
var css_248z$3 = "@keyframes xUi-skeleton-loading{0%{background-position:100% 50%}to{background-position:0 50%}}.xUi-skeleton{display:table;width:100%}.xUi-skeleton__withAvatar{display:flex;gap:12px}.xUi-skeleton-content{width:100%}.xUi-skeleton-content,.xUi-skeleton__header{display:table-cell;vertical-align:top}.xUi-skeleton-title{background:hsla(0,0%,75%,.2);border-radius:4px;height:16px;margin-top:16px;width:38%}.xUi-skeleton-title-avatar{margin-top:12px;width:100%}.xUi-skeleton-title+.xUi-skeleton-paragraph{margin-top:24px}.xUi-skeleton-paragraph{padding:0}.xUi-skeleton-paragraph li{background:hsla(0,0%,75%,.2);border-radius:4px;height:16px;list-style:none;width:100%}.xUi-skeleton-paragraph li+li{margin-top:16px}.xUi-skeleton-paragraph li:last-child:not(:first-child){width:61%}.xUi-skeleton-active .xUi-skeleton-paragraph>li,.xUi-skeleton-active .xUi-skeleton-title{animation:xUi-skeleton-loading 1.4s ease infinite;background:linear-gradient(90deg,hsla(0,0%,75%,.2) 25%,hsla(0,0%,51%,.24) 37%,hsla(0,0%,75%,.2) 63%);background-size:400% 100%}.xUi-skeleton-round .xUi-skeleton-content,.xUi-skeleton-round .xUi-skeleton-paragraph>li,.xUi-skeleton-round .xUi-skeleton-title{border-radius:100px}";
|
|
2624
|
-
styleInject(css_248z$3);
|
|
2625
|
-
|
|
2626
|
-
const PARAGRAPH_AVATAR_ROWS = 2;
|
|
2627
|
-
const PARAGRAPH_DEFAULT_ROWS = 3;
|
|
2628
|
-
const Skeleton = ({
|
|
2629
|
-
prefixCls = prefixClsSkeleton,
|
|
2630
|
-
active,
|
|
2631
|
-
className,
|
|
2632
|
-
style,
|
|
2633
|
-
avatar,
|
|
2634
|
-
paragraph,
|
|
2635
|
-
round,
|
|
2636
|
-
title,
|
|
2637
|
-
teamLogo = true
|
|
2638
|
-
}) => {
|
|
2639
|
-
const GET_TITLE_SKELETON_PROPS = typeof title !== 'boolean' ? {
|
|
2640
|
-
style: {
|
|
2641
|
-
width: title?.width,
|
|
2642
|
-
...title?.style
|
|
2643
|
-
},
|
|
2644
|
-
className: title?.className || ''
|
|
2645
|
-
} : {};
|
|
2646
|
-
const PARAGRAPH_ROWS = avatar ? PARAGRAPH_AVATAR_ROWS : PARAGRAPH_DEFAULT_ROWS;
|
|
2647
|
-
const HAS_PHARAGRAPH = typeof paragraph === 'boolean' || !paragraph ? PARAGRAPH_ROWS : paragraph?.rows ?? PARAGRAPH_ROWS;
|
|
2648
|
-
return jsxs("div", {
|
|
2649
|
-
className: clsx([prefixCls, {
|
|
2650
|
-
[`${prefixCls}__withAvatar`]: avatar,
|
|
2651
|
-
[`${prefixCls}-active`]: active,
|
|
2652
|
-
[`${prefixCls}-round`]: round
|
|
2653
|
-
}, className]),
|
|
2654
|
-
style: style,
|
|
2655
|
-
children: [avatar && teamLogo && jsx("div", {
|
|
2656
|
-
className: `${prefixCls}__header`,
|
|
2657
|
-
children: jsx(SkeletonAvatar, {
|
|
2658
|
-
...GET_AVATAR_SKELETON_PROPS(avatar)
|
|
2659
|
-
})
|
|
2660
|
-
}), jsxs("div", {
|
|
2661
|
-
className: `${prefixCls}-content`,
|
|
2662
|
-
children: [jsx("h3", {
|
|
2663
|
-
className: clsx([`${prefixCls}-title ${GET_TITLE_SKELETON_PROPS.className}`, {
|
|
2664
|
-
[`${prefixCls}-title-avatar`]: avatar
|
|
2665
|
-
}]),
|
|
2666
|
-
style: GET_TITLE_SKELETON_PROPS.style
|
|
2667
|
-
}), paragraph !== false && jsx("ul", {
|
|
2668
|
-
className: `${prefixCls}-paragraph`,
|
|
2669
|
-
style: {
|
|
2670
|
-
...(typeof paragraph !== 'boolean' && paragraph ? paragraph.style : {})
|
|
2671
|
-
},
|
|
2672
|
-
children: createArray(HAS_PHARAGRAPH).map(key => jsx("li", {}, key))
|
|
2673
|
-
})]
|
|
2674
|
-
})]
|
|
2675
|
-
});
|
|
2676
|
-
};
|
|
2677
|
-
Skeleton.Image = SkeletonImage;
|
|
2678
|
-
Skeleton.Input = SkeletonInput;
|
|
2679
|
-
Skeleton.Avatar = SkeletonAvatar;
|
|
2680
|
-
Skeleton.Button = SkeletonButton;
|
|
53
|
+
const prefixClsButton = 'xUi-button';
|
|
2681
54
|
|
|
2682
|
-
var css_248z
|
|
2683
|
-
styleInject(css_248z
|
|
55
|
+
var css_248z = ".xUi-button{border:1px solid transparent;border-radius:6px;cursor:pointer;font-weight:400;line-height:1.5715;transition:all .3s ease;user-select:none;vertical-align:middle;white-space:nowrap}.xUi-button,.xUi-button-content,.xUi-button-icon{align-items:center;display:inline-flex;justify-content:center}.xUi-button-icon{line-height:0;margin-right:.5em}.xUi-button-icon:last-child{margin-left:.5em;margin-right:0}.xUi-button-spinner{animation:xUi-spin 1s linear infinite;border:1px solid transparent;border-radius:50%;border-top:1px solid var(--xui-text-color);height:1em;width:1em}@keyframes xUi-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.xUi-button-size-small{font-size:12px;height:24px;padding:4px 12px}.xUi-button-size-middle{font-size:14px;height:32px;padding:0 16px}.xUi-button-size-large{font-size:16px;height:40px;padding:8px 20px}.xUi-button-circle{border-radius:50%;justify-content:center;padding:0}.xUi-button-circle.xUi-button-size-small{height:24px;width:24px}.xUi-button-circle.xUi-button-size-large{height:40px;width:40px}.xUi-button-round{border-radius:9999px}.xUi-button-default{background-color:#fff;border-color:var(--xui-border-color);color:rgba(0,0,0,.85)}.xUi-button-default:hover{border-color:var(--xui-primary-color);color:var(--xui-primary-color)}.xUi-button-primary{background-color:var(--xui-primary-color);border-color:var(--xui-primary-color);color:#fff}.xUi-button-primary:hover{background-color:var(--xui-primary-color-light);border-color:var(--xui-primary-color-light);color:#fff}.xUi-button-dashed{background-color:#fff;border-color:var(--xui-border-color);border-style:dashed;color:rgba(0,0,0,.85)}.xUi-button-dashed:hover{border-color:var(--xui-primary-color);color:var(--xui-primary-color)}.xUi-button-text{background-color:transparent;border-color:transparent!important;color:rgba(0,0,0,.88)}.xUi-button-text:hover{background-color:rgba(0,0,0,.04);border-color:transparent;color:rgba(0,0,0,.88)}.xUi-button-link{background-color:transparent;border-color:transparent!important;color:var(--xui-primary-color)}.xUi-button-link:hover{border-color:transparent;color:var(--xui-primary-color-light)}.xUi-button-outlined{color:#fff}.xUi-button-filled,.xUi-button-outlined{background-color:transparent;border-color:var(--xui-border-color)}.xUi-button-filled{color:var(--xui-text-color)}.xUi-button-danger{background-color:transparent;border-color:var(--xui-error-color);color:var(--xui-error-color)}.xUi-button-danger:hover{border-color:var(--xui-error-color-light);color:var(--xui-error-color-light)}.xUi-button-ghost{opacity:0}.xUi-button-ghost:hover{opacity:1}.xUi-button-block{display:flex;width:100%}.xUi-button-disabled,.xUi-button-loading{background-color:var(--xui-color-disabled);border-color:var(--xui-border-color);color:var(--xui-text-color);cursor:not-allowed;opacity:.5;pointer-events:none}.xUi-button-loading{background-color:transparent}";
|
|
56
|
+
styleInject(css_248z);
|
|
2684
57
|
|
|
2685
58
|
const ButtonBase = ({
|
|
2686
59
|
type = 'default',
|
|
@@ -2713,7 +86,7 @@ const ButtonBase = ({
|
|
|
2713
86
|
[`${prefixCls}-disabled`]: disabled
|
|
2714
87
|
}, className);
|
|
2715
88
|
const mergedDisabled = disabled || isLoading;
|
|
2716
|
-
const content = jsxs(Fragment
|
|
89
|
+
const content = jsxs(Fragment, {
|
|
2717
90
|
children: [iconNode && iconPosition === 'start' && jsx("span", {
|
|
2718
91
|
className: clsx(`${prefixCls}-icon`, customClassNames.icon),
|
|
2719
92
|
style: styles.icon,
|
|
@@ -2773,331 +146,5 @@ const MyButton = props => {
|
|
|
2773
146
|
});
|
|
2774
147
|
};
|
|
2775
148
|
|
|
2776
|
-
|
|
2777
|
-
styleInject(css_248z$1);
|
|
2778
|
-
|
|
2779
|
-
const IMAGE_SIZE = 40;
|
|
2780
|
-
const IMAGE_PROGRESS_PERCENT = 100;
|
|
2781
|
-
const Upload = ({
|
|
2782
|
-
prefixCls = prefixClsUpload,
|
|
2783
|
-
multiple = false,
|
|
2784
|
-
style,
|
|
2785
|
-
className,
|
|
2786
|
-
onChange,
|
|
2787
|
-
action,
|
|
2788
|
-
name = 'file',
|
|
2789
|
-
method = 'POST',
|
|
2790
|
-
headers,
|
|
2791
|
-
directory,
|
|
2792
|
-
beforeUpload,
|
|
2793
|
-
rootClassName,
|
|
2794
|
-
onRemove,
|
|
2795
|
-
disabled,
|
|
2796
|
-
withCredentials,
|
|
2797
|
-
openFileDialogOnClick = true,
|
|
2798
|
-
maxCount,
|
|
2799
|
-
fileList: controlledFileList,
|
|
2800
|
-
customRequest,
|
|
2801
|
-
accept,
|
|
2802
|
-
listType = 'text',
|
|
2803
|
-
showUploadList = true,
|
|
2804
|
-
children,
|
|
2805
|
-
noStyle,
|
|
2806
|
-
defaultFileList
|
|
2807
|
-
}) => {
|
|
2808
|
-
const uploadRef = useRef(null);
|
|
2809
|
-
const [fileList, setFileList] = useState(() => (controlledFileList || defaultFileList || []).map((file, idx) => ({
|
|
2810
|
-
...file,
|
|
2811
|
-
uid: file.uid || `${Date.now()}-${idx}`,
|
|
2812
|
-
status: file.status || 'done',
|
|
2813
|
-
percent: file.percent || IMAGE_PROGRESS_PERCENT
|
|
2814
|
-
})));
|
|
2815
|
-
const updateFileList = newList => {
|
|
2816
|
-
setFileList(newList);
|
|
2817
|
-
if (onChange) {
|
|
2818
|
-
onChange({
|
|
2819
|
-
fileList: newList,
|
|
2820
|
-
file: newList[0] || {}
|
|
2821
|
-
});
|
|
2822
|
-
}
|
|
2823
|
-
};
|
|
2824
|
-
const handleFileChange = async event => {
|
|
2825
|
-
const rawFiles = Array.from(event.target.files || []);
|
|
2826
|
-
let uploadFiles = rawFiles.map((file, i) => ({
|
|
2827
|
-
uid: `${Date.now()}-${i}`,
|
|
2828
|
-
name: file.name,
|
|
2829
|
-
size: file.size,
|
|
2830
|
-
type: file.type,
|
|
2831
|
-
status: 'uploading',
|
|
2832
|
-
percent: 0,
|
|
2833
|
-
originFileObj: file
|
|
2834
|
-
}));
|
|
2835
|
-
if (beforeUpload) {
|
|
2836
|
-
const filtered = [];
|
|
2837
|
-
for (let i = 0; i < uploadFiles.length; i++) {
|
|
2838
|
-
const file = uploadFiles[i].originFileObj;
|
|
2839
|
-
const result = await beforeUpload(file, rawFiles);
|
|
2840
|
-
if (result === false) {
|
|
2841
|
-
continue;
|
|
2842
|
-
}
|
|
2843
|
-
filtered.push(uploadFiles[i]);
|
|
2844
|
-
}
|
|
2845
|
-
uploadFiles = filtered;
|
|
2846
|
-
}
|
|
2847
|
-
const newList = (multiple ? [...fileList, ...uploadFiles] : uploadFiles).slice(0, maxCount);
|
|
2848
|
-
updateFileList(newList);
|
|
2849
|
-
uploadFiles.forEach(file => {
|
|
2850
|
-
const rcFile = file.originFileObj;
|
|
2851
|
-
const updateProgress = percent => {
|
|
2852
|
-
file.percent = percent;
|
|
2853
|
-
updateFileList([...newList]);
|
|
2854
|
-
};
|
|
2855
|
-
const markSuccess = () => {
|
|
2856
|
-
file.status = 'done';
|
|
2857
|
-
file.percent = 100;
|
|
2858
|
-
updateFileList([...newList]);
|
|
2859
|
-
};
|
|
2860
|
-
const markError = () => {
|
|
2861
|
-
file.status = 'error';
|
|
2862
|
-
updateFileList([...newList]);
|
|
2863
|
-
};
|
|
2864
|
-
if (customRequest) {
|
|
2865
|
-
customRequest({
|
|
2866
|
-
file: rcFile,
|
|
2867
|
-
onSuccess: markSuccess,
|
|
2868
|
-
onError: markError,
|
|
2869
|
-
onProgress: event => {
|
|
2870
|
-
const percent = Math.round(event.loaded / (event.total || event.loaded) * IMAGE_PROGRESS_PERCENT);
|
|
2871
|
-
updateProgress(percent);
|
|
2872
|
-
}
|
|
2873
|
-
});
|
|
2874
|
-
} else if (typeof action === 'string') {
|
|
2875
|
-
const formData = new FormData();
|
|
2876
|
-
formData.append(name, rcFile);
|
|
2877
|
-
fetch(action, {
|
|
2878
|
-
method,
|
|
2879
|
-
body: formData,
|
|
2880
|
-
headers,
|
|
2881
|
-
credentials: withCredentials ? 'include' : 'same-origin'
|
|
2882
|
-
}).then(res => {
|
|
2883
|
-
if (!res.ok) {
|
|
2884
|
-
throw new Error('Upload failed');
|
|
2885
|
-
}
|
|
2886
|
-
return res.json();
|
|
2887
|
-
}).then(markSuccess).catch(markError);
|
|
2888
|
-
} else if (typeof action === 'function') {
|
|
2889
|
-
action(rcFile);
|
|
2890
|
-
markSuccess();
|
|
2891
|
-
} else {
|
|
2892
|
-
markSuccess();
|
|
2893
|
-
}
|
|
2894
|
-
});
|
|
2895
|
-
if (uploadRef.current) {
|
|
2896
|
-
uploadRef.current.value = '';
|
|
2897
|
-
}
|
|
2898
|
-
};
|
|
2899
|
-
const handleRemove = uid => {
|
|
2900
|
-
const filtered = [];
|
|
2901
|
-
let removedFile = undefined;
|
|
2902
|
-
fileList.forEach(file => {
|
|
2903
|
-
if (file.uid !== uid) {
|
|
2904
|
-
filtered.push(file);
|
|
2905
|
-
} else {
|
|
2906
|
-
removedFile = file;
|
|
2907
|
-
}
|
|
2908
|
-
});
|
|
2909
|
-
updateFileList(filtered);
|
|
2910
|
-
if (removedFile) {
|
|
2911
|
-
onRemove?.(removedFile);
|
|
2912
|
-
}
|
|
2913
|
-
};
|
|
2914
|
-
const handleClick = () => {
|
|
2915
|
-
if (!disabled && openFileDialogOnClick && uploadRef.current) {
|
|
2916
|
-
uploadRef.current.click();
|
|
2917
|
-
}
|
|
2918
|
-
};
|
|
2919
|
-
return jsxs("div", {
|
|
2920
|
-
className: clsx([`${prefixCls}-wrapper`, className, rootClassName, {
|
|
2921
|
-
noStyle: noStyle,
|
|
2922
|
-
[`${prefixCls}-disabled`]: disabled
|
|
2923
|
-
}]),
|
|
2924
|
-
style: style,
|
|
2925
|
-
children: [jsxs("span", {
|
|
2926
|
-
className: clsx([`${prefixCls}`, `${prefixCls}-${listType}`]),
|
|
2927
|
-
onClick: handleClick,
|
|
2928
|
-
children: [children, jsx("input", {
|
|
2929
|
-
type: "file",
|
|
2930
|
-
ref: uploadRef,
|
|
2931
|
-
accept: accept,
|
|
2932
|
-
multiple: multiple,
|
|
2933
|
-
onChange: handleFileChange,
|
|
2934
|
-
className: `${prefixCls}-input`,
|
|
2935
|
-
disabled: disabled,
|
|
2936
|
-
...(directory ? {
|
|
2937
|
-
directory: true,
|
|
2938
|
-
webkitdirectory: true
|
|
2939
|
-
} : {})
|
|
2940
|
-
})]
|
|
2941
|
-
}), showUploadList && fileList.length > 0 && jsx("ul", {
|
|
2942
|
-
className: `${prefixCls}-list ${prefixCls}-list-${listType}`,
|
|
2943
|
-
children: fileList.map(file => jsxs("li", {
|
|
2944
|
-
className: `${prefixCls}-item ${prefixCls}-item-${file.status}`,
|
|
2945
|
-
children: [jsx("span", {
|
|
2946
|
-
className: `${prefixCls}-remove`,
|
|
2947
|
-
onClick: () => handleRemove(file.uid),
|
|
2948
|
-
children: listType === 'picture' && (file.originFileObj || file.url) ?
|
|
2949
|
-
// eslint-disable-next-line @next/next/no-img-element
|
|
2950
|
-
jsx("img", {
|
|
2951
|
-
width: IMAGE_SIZE,
|
|
2952
|
-
height: IMAGE_SIZE,
|
|
2953
|
-
alt: file.name,
|
|
2954
|
-
src: file.url || URL.createObjectURL(file.originFileObj),
|
|
2955
|
-
className: `${prefixCls}-item-thumbnail`
|
|
2956
|
-
}) : jsx(StampleIcon, {})
|
|
2957
|
-
}), jsxs("div", {
|
|
2958
|
-
style: {
|
|
2959
|
-
width: '100%'
|
|
2960
|
-
},
|
|
2961
|
-
children: [jsx("div", {
|
|
2962
|
-
className: `${prefixCls}-item-title`,
|
|
2963
|
-
style: {
|
|
2964
|
-
...(file.status === 'uploading' ? {
|
|
2965
|
-
marginBottom: 12
|
|
2966
|
-
} : {})
|
|
2967
|
-
},
|
|
2968
|
-
children: jsx("span", {
|
|
2969
|
-
className: `${prefixCls}-item-remove-icon`,
|
|
2970
|
-
onClick: () => handleRemove(file.uid),
|
|
2971
|
-
style: {
|
|
2972
|
-
cursor: 'pointer',
|
|
2973
|
-
marginLeft: 'auto'
|
|
2974
|
-
},
|
|
2975
|
-
role: "button",
|
|
2976
|
-
"aria-label": "Remove file",
|
|
2977
|
-
children: jsx(TrashIcon, {})
|
|
2978
|
-
})
|
|
2979
|
-
}), file.status === 'uploading' && jsxs(Fragment$1, {
|
|
2980
|
-
children: [jsx("div", {
|
|
2981
|
-
className: `${prefixCls}-item-progress-line`
|
|
2982
|
-
}), jsx("div", {
|
|
2983
|
-
className: `${prefixCls}-item-progress-line-percent`,
|
|
2984
|
-
style: {
|
|
2985
|
-
width: `${file.percent}%`
|
|
2986
|
-
}
|
|
2987
|
-
})]
|
|
2988
|
-
})]
|
|
2989
|
-
})]
|
|
2990
|
-
}, file.uid))
|
|
2991
|
-
})]
|
|
2992
|
-
});
|
|
2993
|
-
};
|
|
2994
|
-
|
|
2995
|
-
var css_248z = ".xUi-checkbox-wrapper{align-items:center;color:var(--xui-main-color);cursor:pointer;display:inline-flex;font-size:var(--xui-font-size-md);margin:16px 0}.xUi-checkbox{background-color:transparent;border:1px solid var(--xui-border-color);border-radius:var(--xui-border-radius-sm);display:inline-block;height:14px;position:relative;transition:all .3s;width:14px}.xUi-checkbox.xUi-checkbox-checked{background-color:#f0f5ff;border-color:var(--xui-primary-color)}.xUi-checkbox input{cursor:pointer;inset:0;opacity:0;position:absolute}.xUi-checkbox-inner{border-left:0;border-top:0;border:2px solid var(--xui-background-color);height:6px;left:50%;position:absolute;top:50%;transform:rotate(45deg) scale(0);transition:transform .2s ease-in-out;width:10px}.xUi-checkbox-check{background-color:var(--xui-primary-color);border-color:var(--xui-primary-color);display:block;height:100%;position:relative;transition:.1s ease;width:100%}.xUi-checkbox-check:after{border:solid #fff;border-width:0 2px 2px 0;content:\"\";height:8px;left:3px;position:absolute;top:1px;transform:rotate(45deg);width:5px}.xUi-checkbox-disabled,.xUi-checkbox-disabled .xUi-checkbox-check{background-color:var(--xui-color-disabled);border-color:var(--xui-border-color)!important;cursor:not-allowed;opacity:.5}.xUi-checkbox-label{font-size:14px;margin-left:8px;user-select:none}.xUi-checkbox:focus:not(.disabled),.xUi-checkbox:hover:not(.disabled){border-color:var(--xui-primary-color);cursor:pointer}.xUi-checkbox.disabled{cursor:not-allowed;opacity:.5}";
|
|
2996
|
-
styleInject(css_248z);
|
|
2997
|
-
|
|
2998
|
-
const Checkbox = /*#__PURE__*/forwardRef(({
|
|
2999
|
-
prefixCls = prefixClsCheckbox,
|
|
3000
|
-
className = '',
|
|
3001
|
-
defaultChecked = false,
|
|
3002
|
-
checked,
|
|
3003
|
-
style,
|
|
3004
|
-
disabled = false,
|
|
3005
|
-
onChange,
|
|
3006
|
-
onClick,
|
|
3007
|
-
onMouseEnter,
|
|
3008
|
-
onMouseLeave,
|
|
3009
|
-
onKeyPress,
|
|
3010
|
-
onKeyDown,
|
|
3011
|
-
tabIndex,
|
|
3012
|
-
name,
|
|
3013
|
-
children,
|
|
3014
|
-
id,
|
|
3015
|
-
autoFocus,
|
|
3016
|
-
type = 'checkbox',
|
|
3017
|
-
value = false,
|
|
3018
|
-
required = false,
|
|
3019
|
-
noStyle
|
|
3020
|
-
}, ref) => {
|
|
3021
|
-
const isChecked = checked !== undefined ? checked : defaultChecked || value;
|
|
3022
|
-
const [internalChecked, setInternalChecked] = useState(isChecked);
|
|
3023
|
-
const handleClick = e => {
|
|
3024
|
-
e.stopPropagation();
|
|
3025
|
-
if (disabled) {
|
|
3026
|
-
return;
|
|
3027
|
-
}
|
|
3028
|
-
setInternalChecked(!internalChecked);
|
|
3029
|
-
e.target.value = !internalChecked;
|
|
3030
|
-
onClick?.(e);
|
|
3031
|
-
onChange?.(e);
|
|
3032
|
-
};
|
|
3033
|
-
useEffect(() => {
|
|
3034
|
-
if (checked !== undefined) {
|
|
3035
|
-
setInternalChecked(checked);
|
|
3036
|
-
}
|
|
3037
|
-
}, [checked]);
|
|
3038
|
-
return jsxs("div", {
|
|
3039
|
-
className: `${prefixCls}-wrapper`,
|
|
3040
|
-
children: [jsxs("div", {
|
|
3041
|
-
ref: ref,
|
|
3042
|
-
style: style,
|
|
3043
|
-
onClick: handleClick,
|
|
3044
|
-
className: clsx([prefixCls, className, {
|
|
3045
|
-
noStyle: noStyle,
|
|
3046
|
-
[`${prefixCls}-disabled`]: disabled,
|
|
3047
|
-
[`${prefixCls}-checked`]: internalChecked
|
|
3048
|
-
}]),
|
|
3049
|
-
children: [jsx("input", {
|
|
3050
|
-
id: id,
|
|
3051
|
-
type: type,
|
|
3052
|
-
name: name,
|
|
3053
|
-
disabled: disabled,
|
|
3054
|
-
tabIndex: tabIndex,
|
|
3055
|
-
required: required,
|
|
3056
|
-
autoFocus: autoFocus,
|
|
3057
|
-
onKeyDown: onKeyDown,
|
|
3058
|
-
onKeyPress: onKeyPress,
|
|
3059
|
-
onMouseEnter: onMouseEnter,
|
|
3060
|
-
onMouseLeave: onMouseLeave
|
|
3061
|
-
}), jsx("span", {
|
|
3062
|
-
className: `${prefixCls}-box`,
|
|
3063
|
-
children: jsx("span", {
|
|
3064
|
-
className: `${prefixCls}-check`,
|
|
3065
|
-
style: {
|
|
3066
|
-
opacity: Number(internalChecked)
|
|
3067
|
-
}
|
|
3068
|
-
})
|
|
3069
|
-
})]
|
|
3070
|
-
}), children && jsx("span", {
|
|
3071
|
-
className: `${prefixCls}-label`,
|
|
3072
|
-
children: children
|
|
3073
|
-
})]
|
|
3074
|
-
});
|
|
3075
|
-
});
|
|
3076
|
-
Checkbox.displayName = 'Checkbox';
|
|
3077
|
-
|
|
3078
|
-
const useWatch = ({
|
|
3079
|
-
name,
|
|
3080
|
-
defaultValue,
|
|
3081
|
-
form
|
|
3082
|
-
}) => {
|
|
3083
|
-
const formContext = useContext(FormContext);
|
|
3084
|
-
const formInstance = form || formContext;
|
|
3085
|
-
if (!formInstance) {
|
|
3086
|
-
throw new Error('useWatch must be used within a Form or with a form instance.');
|
|
3087
|
-
}
|
|
3088
|
-
const [value, setValue] = useState(() => {
|
|
3089
|
-
return name ? formInstance.getFieldValue(name) ?? defaultValue : formInstance.getFieldsValue() ?? defaultValue;
|
|
3090
|
-
});
|
|
3091
|
-
useEffect(() => {
|
|
3092
|
-
if (!name) {
|
|
3093
|
-
const unsubscribe = formInstance.subscribeToForm(setValue);
|
|
3094
|
-
return () => unsubscribe();
|
|
3095
|
-
}
|
|
3096
|
-
const unsubscribe = formInstance.subscribeToField(name, setValue);
|
|
3097
|
-
return () => unsubscribe();
|
|
3098
|
-
}, [name, formInstance]);
|
|
3099
|
-
return value;
|
|
3100
|
-
};
|
|
3101
|
-
|
|
3102
|
-
export { ArrowIcon, MyButton as Button, CalendarIcon, CheckIcon, Checkbox, ClearIcon, DateDistanceIcon, DatePicker, EmptyContent as Empty, ErrorIcon, Form, FormItem, Input, LoadingIcon, Option, Radio, RadioButton, RadioGroup, RangePicker, SearchIcon, Select, Skeleton, SkeletonAvatar, SkeletonButton, SkeletonImage, SkeletonInput, SpinerIcon, StampleIcon, SuccessIcon, Tag, Textarea, TimeIcon, TimePicker, TrashIcon, Upload, useForm, useWatch };
|
|
149
|
+
export { MyButton as Button };
|
|
3103
150
|
//# sourceMappingURL=index.esm.js.map
|