x-ui-design 0.6.31 → 0.6.33
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/components/Select/Select.d.ts +5 -53
- package/dist/esm/types/index.d.ts +1 -50
- package/dist/index.d.ts +1 -50
- package/dist/index.esm.js +11 -13
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +11 -13
- package/dist/index.js.map +1 -1
- package/lib/components/Select/Select.tsx +5 -7
- package/lib/hooks/useForm.ts +7 -6
- package/package.json +1 -1
- package/src/app/page.tsx +9 -23
|
@@ -1,57 +1,9 @@
|
|
|
1
|
-
import React, { ReactElement
|
|
2
|
-
import {
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
import { SelectProps } from '../../types/select';
|
|
3
3
|
import './style.css';
|
|
4
|
-
declare const Select:
|
|
5
|
-
id
|
|
6
|
-
|
|
7
|
-
onSearch?: (value: string) => void;
|
|
8
|
-
autoClearSearchValue?: boolean;
|
|
9
|
-
onSelect?: (value: import("../../types").RuleTypes, option?: OptionType) => void;
|
|
10
|
-
onDeselect?: (value: string, option?: OptionType) => void;
|
|
11
|
-
filterOption?: boolean | ((input: string, option: OptionType) => boolean);
|
|
12
|
-
optionFilterProp?: string;
|
|
13
|
-
options?: OptionType[];
|
|
14
|
-
children?: ReactNode;
|
|
15
|
-
defaultActiveFirstOption?: boolean;
|
|
16
|
-
listHeight?: number;
|
|
17
|
-
menuItemSelectedIcon?: ReactNode;
|
|
18
|
-
mode?: "default" | "multiple" | "tags";
|
|
19
|
-
value?: import("../../types").RuleTypes;
|
|
20
|
-
defaultValue?: import("../../types").RuleTypes;
|
|
21
|
-
maxCount?: number;
|
|
22
|
-
onChange?: (e: import("../../types").RuleTypes, option?: OptionType) => void;
|
|
23
|
-
onClose?: () => void;
|
|
24
|
-
disabled?: boolean;
|
|
25
|
-
loading?: boolean;
|
|
26
|
-
placeholder?: string;
|
|
27
|
-
allowClear?: boolean;
|
|
28
|
-
filterable?: boolean;
|
|
29
|
-
defaultOpen?: boolean;
|
|
30
|
-
size?: "small" | "middle" | "large";
|
|
31
|
-
onClear?: () => void;
|
|
32
|
-
error?: boolean;
|
|
33
|
-
showSearch?: boolean;
|
|
34
|
-
tagRender?: ((props: import("../../types/select").CustomTagProps) => ReactElement) | undefined;
|
|
35
|
-
maxTagPlaceholder?: ReactNode | ((omittedValues: import("../../types/select").DisplayValueType[]) => ReactNode);
|
|
36
|
-
dropdownClassName?: string;
|
|
37
|
-
showArrow?: boolean;
|
|
38
|
-
onBlur?: React.FocusEventHandler<HTMLElement> | undefined;
|
|
39
|
-
onDropdownVisibleChange?: ((open: boolean, selected: import("../../types").RuleType) => void) | undefined;
|
|
40
|
-
showAction?: ("click" | "focus")[] | undefined;
|
|
41
|
-
suffixIcon?: ReactNode;
|
|
42
|
-
searchIcon?: ReactNode;
|
|
43
|
-
open?: boolean;
|
|
44
|
-
notFoundContent?: ReactNode;
|
|
45
|
-
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
|
|
46
|
-
dropdownRender?: (menu: ReactNode) => ReactNode;
|
|
47
|
-
feedbackIcons?: boolean;
|
|
48
|
-
placement?: "bottomLeft" | "bottomRight" | "topLeft" | "topRight";
|
|
49
|
-
removeIcon?: ReactNode;
|
|
50
|
-
maxTagCount?: number | "responsive";
|
|
51
|
-
ref?: React.ForwardedRef<HTMLDivElement>;
|
|
52
|
-
closeFromParent?: boolean;
|
|
53
|
-
}> & {
|
|
54
|
-
readonly type: ({ prefixCls, id, searchValue, autoClearSearchValue, filterOption, optionFilterProp, children, options, listHeight, menuItemSelectedIcon, mode, value, defaultValue, maxCount, disabled, loading, placeholder, allowClear, filterable, defaultOpen, size, error, dropdownClassName, className, suffixIcon, searchIcon, style, showSearch, open, closeFromParent, showArrow, notFoundContent, noStyle, feedbackIcons, placement, removeIcon, maxTagCount, onSearch, onSelect, onDeselect, onClear, onChange, onClose, tagRender, getPopupContainer, dropdownRender, onDropdownVisibleChange, ref }: SelectProps) => ReactElement;
|
|
4
|
+
declare const Select: {
|
|
5
|
+
({ prefixCls, id, searchValue, autoClearSearchValue, filterOption, optionFilterProp, children, options, listHeight, menuItemSelectedIcon, mode, value, defaultValue, maxCount, disabled, loading, placeholder, allowClear, filterable, defaultOpen, size, error, dropdownClassName, className, suffixIcon, searchIcon, style, showSearch, open, closeFromParent, showArrow, notFoundContent, noStyle, feedbackIcons, placement, removeIcon, maxTagCount, onSearch, onSelect, onDeselect, onClear, onChange, onClose, tagRender, getPopupContainer, dropdownRender, onDropdownVisibleChange, ref }: SelectProps): ReactElement;
|
|
6
|
+
displayName: string;
|
|
55
7
|
} & {
|
|
56
8
|
Option: React.FC<import("../../types/select").OptionProps>;
|
|
57
9
|
};
|
|
@@ -35,56 +35,7 @@ declare const Textarea: import("react").ComponentType<import("@/types/input").Te
|
|
|
35
35
|
declare const Radio: import("react").ComponentType<import("@/types/radio").RadioProps>;
|
|
36
36
|
declare const RadioButton: import("react").ComponentType<import("@/types/radio").RadioButtonProps>;
|
|
37
37
|
declare const RadioGroup: import("react").ComponentType<import("@/types/radio").RadioGroupProps>;
|
|
38
|
-
declare const Select: import("react").ComponentType<import("@/types").
|
|
39
|
-
id?: string;
|
|
40
|
-
searchValue?: string;
|
|
41
|
-
onSearch?: (value: string) => void;
|
|
42
|
-
autoClearSearchValue?: boolean;
|
|
43
|
-
onSelect?: (value: import("@/types").RuleTypes, option?: import("@/types/select").OptionType) => void;
|
|
44
|
-
onDeselect?: (value: string, option?: import("@/types/select").OptionType) => void;
|
|
45
|
-
filterOption?: boolean | ((input: string, option: import("@/types/select").OptionType) => boolean);
|
|
46
|
-
optionFilterProp?: string;
|
|
47
|
-
options?: import("@/types/select").OptionType[];
|
|
48
|
-
children?: import("react").ReactNode;
|
|
49
|
-
defaultActiveFirstOption?: boolean;
|
|
50
|
-
listHeight?: number;
|
|
51
|
-
menuItemSelectedIcon?: import("react").ReactNode;
|
|
52
|
-
mode?: "default" | "multiple" | "tags";
|
|
53
|
-
value?: import("@/types").RuleTypes;
|
|
54
|
-
defaultValue?: import("@/types").RuleTypes;
|
|
55
|
-
maxCount?: number;
|
|
56
|
-
onChange?: (e: import("@/types").RuleTypes, option?: import("@/types/select").OptionType) => void;
|
|
57
|
-
onClose?: () => void;
|
|
58
|
-
disabled?: boolean;
|
|
59
|
-
loading?: boolean;
|
|
60
|
-
placeholder?: string;
|
|
61
|
-
allowClear?: boolean;
|
|
62
|
-
filterable?: boolean;
|
|
63
|
-
defaultOpen?: boolean;
|
|
64
|
-
size?: "small" | "middle" | "large";
|
|
65
|
-
onClear?: () => void;
|
|
66
|
-
error?: boolean;
|
|
67
|
-
showSearch?: boolean;
|
|
68
|
-
tagRender?: ((props: import("@/types/select").CustomTagProps) => import("react").ReactElement) | undefined;
|
|
69
|
-
maxTagPlaceholder?: import("react").ReactNode | ((omittedValues: import("@/types/select").DisplayValueType[]) => import("react").ReactNode);
|
|
70
|
-
dropdownClassName?: string;
|
|
71
|
-
showArrow?: boolean;
|
|
72
|
-
onBlur?: import("react").FocusEventHandler<HTMLElement> | undefined;
|
|
73
|
-
onDropdownVisibleChange?: ((open: boolean, selected: import("@/types").RuleType) => void) | undefined;
|
|
74
|
-
showAction?: ("click" | "focus")[] | undefined;
|
|
75
|
-
suffixIcon?: import("react").ReactNode;
|
|
76
|
-
searchIcon?: import("react").ReactNode;
|
|
77
|
-
open?: boolean;
|
|
78
|
-
notFoundContent?: import("react").ReactNode;
|
|
79
|
-
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
|
|
80
|
-
dropdownRender?: (menu: import("react").ReactNode) => import("react").ReactNode;
|
|
81
|
-
feedbackIcons?: boolean;
|
|
82
|
-
placement?: "bottomLeft" | "bottomRight" | "topLeft" | "topRight";
|
|
83
|
-
removeIcon?: import("react").ReactNode;
|
|
84
|
-
maxTagCount?: number | "responsive";
|
|
85
|
-
ref?: import("react").ForwardedRef<HTMLDivElement>;
|
|
86
|
-
closeFromParent?: boolean;
|
|
87
|
-
}>;
|
|
38
|
+
declare const Select: import("react").ComponentType<import("@/types/select").SelectProps>;
|
|
88
39
|
declare const Option: import("react").ComponentType<import("@/types/select").OptionProps>;
|
|
89
40
|
declare const Tag: import("react").ComponentType<import("@/types/select").CustomTagProps>;
|
|
90
41
|
declare const Skeleton: import("react").ComponentType<import("./types/skeleton").SkeletonProps>;
|
package/dist/index.d.ts
CHANGED
|
@@ -139,56 +139,7 @@ declare const Textarea: react.ComponentType<__types_input.TextareaProps>;
|
|
|
139
139
|
declare const Radio: react.ComponentType<__types_radio.RadioProps>;
|
|
140
140
|
declare const RadioButton: react.ComponentType<__types_radio.RadioButtonProps>;
|
|
141
141
|
declare const RadioGroup: react.ComponentType<__types_radio.RadioGroupProps>;
|
|
142
|
-
declare const Select: react.ComponentType<
|
|
143
|
-
id?: string;
|
|
144
|
-
searchValue?: string;
|
|
145
|
-
onSearch?: (value: string) => void;
|
|
146
|
-
autoClearSearchValue?: boolean;
|
|
147
|
-
onSelect?: (value: __types.RuleTypes, option?: __types_select.OptionType) => void;
|
|
148
|
-
onDeselect?: (value: string, option?: __types_select.OptionType) => void;
|
|
149
|
-
filterOption?: boolean | ((input: string, option: __types_select.OptionType) => boolean);
|
|
150
|
-
optionFilterProp?: string;
|
|
151
|
-
options?: __types_select.OptionType[];
|
|
152
|
-
children?: react.ReactNode;
|
|
153
|
-
defaultActiveFirstOption?: boolean;
|
|
154
|
-
listHeight?: number;
|
|
155
|
-
menuItemSelectedIcon?: react.ReactNode;
|
|
156
|
-
mode?: "default" | "multiple" | "tags";
|
|
157
|
-
value?: __types.RuleTypes;
|
|
158
|
-
defaultValue?: __types.RuleTypes;
|
|
159
|
-
maxCount?: number;
|
|
160
|
-
onChange?: (e: __types.RuleTypes, option?: __types_select.OptionType) => void;
|
|
161
|
-
onClose?: () => void;
|
|
162
|
-
disabled?: boolean;
|
|
163
|
-
loading?: boolean;
|
|
164
|
-
placeholder?: string;
|
|
165
|
-
allowClear?: boolean;
|
|
166
|
-
filterable?: boolean;
|
|
167
|
-
defaultOpen?: boolean;
|
|
168
|
-
size?: "small" | "middle" | "large";
|
|
169
|
-
onClear?: () => void;
|
|
170
|
-
error?: boolean;
|
|
171
|
-
showSearch?: boolean;
|
|
172
|
-
tagRender?: ((props: __types_select.CustomTagProps) => react.ReactElement) | undefined;
|
|
173
|
-
maxTagPlaceholder?: react.ReactNode | ((omittedValues: __types_select.DisplayValueType[]) => react.ReactNode);
|
|
174
|
-
dropdownClassName?: string;
|
|
175
|
-
showArrow?: boolean;
|
|
176
|
-
onBlur?: react.FocusEventHandler<HTMLElement> | undefined;
|
|
177
|
-
onDropdownVisibleChange?: ((open: boolean, selected: __types.RuleType) => void) | undefined;
|
|
178
|
-
showAction?: ("click" | "focus")[] | undefined;
|
|
179
|
-
suffixIcon?: react.ReactNode;
|
|
180
|
-
searchIcon?: react.ReactNode;
|
|
181
|
-
open?: boolean;
|
|
182
|
-
notFoundContent?: react.ReactNode;
|
|
183
|
-
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
|
|
184
|
-
dropdownRender?: (menu: react.ReactNode) => react.ReactNode;
|
|
185
|
-
feedbackIcons?: boolean;
|
|
186
|
-
placement?: "bottomLeft" | "bottomRight" | "topLeft" | "topRight";
|
|
187
|
-
removeIcon?: react.ReactNode;
|
|
188
|
-
maxTagCount?: number | "responsive";
|
|
189
|
-
ref?: react.ForwardedRef<HTMLDivElement>;
|
|
190
|
-
closeFromParent?: boolean;
|
|
191
|
-
}>;
|
|
142
|
+
declare const Select: react.ComponentType<__types_select.SelectProps>;
|
|
192
143
|
declare const Option: react.ComponentType<__types_select.OptionProps>;
|
|
193
144
|
declare const Tag: react.ComponentType<__types_select.CustomTagProps>;
|
|
194
145
|
declare const Skeleton: react.ComponentType<SkeletonProps>;
|
package/dist/index.esm.js
CHANGED
|
@@ -780,6 +780,13 @@ const useForm = ({
|
|
|
780
780
|
async function validateFields(nameList) {
|
|
781
781
|
const fieldsToValidate = nameList || Object.keys(formRef.current[stepRef.current]);
|
|
782
782
|
const results = await Promise.all(fieldsToValidate.map(name => validateField(name)));
|
|
783
|
+
const errorFields = formInstance.getFieldsError().filter(e => e.errors.length);
|
|
784
|
+
if (errorFields.length) {
|
|
785
|
+
formHandlersRef.current.onFinishFailed?.({
|
|
786
|
+
values: formInstance.getFieldsValue(),
|
|
787
|
+
errorFields
|
|
788
|
+
});
|
|
789
|
+
}
|
|
783
790
|
if (_scrollToFirstError.current) {
|
|
784
791
|
const firstErrorContent = document.querySelectorAll('.xUi-form-item-has-error')?.[0];
|
|
785
792
|
if (firstErrorContent) {
|
|
@@ -823,14 +830,7 @@ const useForm = ({
|
|
|
823
830
|
return (await validateFields()) ? (() => {
|
|
824
831
|
formHandlersRef.current.onFinish?.(formData);
|
|
825
832
|
return formData;
|
|
826
|
-
})() :
|
|
827
|
-
const errorFields = formInstance.getFieldsError().filter(e => e.errors.length);
|
|
828
|
-
formHandlersRef.current.onFinishFailed?.({
|
|
829
|
-
values: formInstance.getFieldsValue(),
|
|
830
|
-
errorFields
|
|
831
|
-
});
|
|
832
|
-
return undefined;
|
|
833
|
-
})();
|
|
833
|
+
})() : undefined;
|
|
834
834
|
}
|
|
835
835
|
function subscribeToField(name, callback) {
|
|
836
836
|
if (!fieldSubscribers.current[name]) {
|
|
@@ -3365,7 +3365,7 @@ function getTextFromNode(node) {
|
|
|
3365
3365
|
}
|
|
3366
3366
|
return '';
|
|
3367
3367
|
}
|
|
3368
|
-
const SelectComponent =
|
|
3368
|
+
const SelectComponent = ({
|
|
3369
3369
|
prefixCls = prefixClsSelect,
|
|
3370
3370
|
id,
|
|
3371
3371
|
searchValue = '',
|
|
@@ -3694,9 +3694,7 @@ const SelectComponent = /*#__PURE__*/memo(({
|
|
|
3694
3694
|
}
|
|
3695
3695
|
return options || [];
|
|
3696
3696
|
}, []);
|
|
3697
|
-
const extractedOptions =
|
|
3698
|
-
return children ? extractOptions(children) : Array.isArray(options) ? options : [];
|
|
3699
|
-
}, [children, options]);
|
|
3697
|
+
const extractedOptions = children ? extractOptions(children) : Array.isArray(options) ? options : [];
|
|
3700
3698
|
const triggerNode = useMemo(() => {
|
|
3701
3699
|
return selectRef.current?.querySelector(`.${prefixCls}-trigger`);
|
|
3702
3700
|
}, [prefixCls]);
|
|
@@ -3934,7 +3932,7 @@ const SelectComponent = /*#__PURE__*/memo(({
|
|
|
3934
3932
|
}, ArrowContainer, error && feedbackIcons ? /*#__PURE__*/React.createElement(ErrorIcon, null) : null), loading && /*#__PURE__*/React.createElement("span", {
|
|
3935
3933
|
className: `${prefixCls}-loading`
|
|
3936
3934
|
}, /*#__PURE__*/React.createElement(LoadingIcon, null)))), getPopupContainer?.(triggerNode) ? /*#__PURE__*/createPortal(dropdownContent, getPopupContainer(triggerNode)) : dropdownContent);
|
|
3937
|
-
}
|
|
3935
|
+
};
|
|
3938
3936
|
SelectComponent.displayName = 'Select';
|
|
3939
3937
|
const Select = Object.assign(SelectComponent, {
|
|
3940
3938
|
Option
|