@cloudbase/weda-ui 3.10.2 → 3.11.0
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/configs/components/button.js +1 -1
- package/dist/configs/components/chart/bar.d.ts +146 -0
- package/dist/configs/components/chart/bar.js +1147 -0
- package/dist/configs/components/dataView.js +0 -16
- package/dist/configs/components/image.js +1 -1
- package/dist/configs/components/listView.js +0 -16
- package/dist/configs/components/lottery.js +1 -1
- package/dist/configs/components/navigationBar.json +1 -1
- package/dist/configs/components/wd-audio.js +1 -1
- package/dist/configs/components/wd-button.js +2 -2
- package/dist/configs/components/wd-icon.js +1 -1
- package/dist/configs/components/wd-image.js +1 -1
- package/dist/configs/components/wd-input-email.d.ts +2 -2
- package/dist/configs/components/wd-input-phone.d.ts +2 -2
- package/dist/configs/components/wd-input-url.d.ts +2 -2
- package/dist/configs/components/wd-link.js +1 -1
- package/dist/configs/components/wd-rating.js +2 -2
- package/dist/configs/components/wd-select-multiple.d.ts +23 -0
- package/dist/configs/components/wd-select-multiple.js +26 -1
- package/dist/configs/components/wd-select.d.ts +23 -0
- package/dist/configs/components/wd-select.js +25 -0
- package/dist/configs/components/wd-side-tab.js +2 -2
- package/dist/configs/components/wd-table.d.ts +1 -1
- package/dist/configs/components/wd-table.js +1 -0
- package/dist/configs/components/wd-top-tab.js +2 -2
- package/dist/configs/components/wd-upload-image.js +1 -1
- package/dist/configs/components/wedaVideo.js +3 -3
- package/dist/configs/components/wxOpenApi/share.js +1 -1
- package/dist/configs/index.d.ts +1674 -2996
- package/dist/configs/index.js +1 -1
- package/dist/configs/type-utils/type-form.d.ts +6 -0
- package/dist/configs/type-utils/type-form.js +63 -22
- package/dist/configs/type-utils/x-runtime-default.d.ts +1 -0
- package/dist/configs/type-utils/x-runtime-default.js +1 -0
- package/dist/enum/index.js +5 -1
- package/dist/style/index.css +2 -0
- package/dist/style/index.scss +1 -1
- package/dist/style/weda-ui.min.css +2 -2
- package/dist/web/components/form/select/index.css +2 -2
- package/dist/web/components/form/select/request.d.ts +3 -3
- package/dist/web/components/form/select/request.js +1 -0
- package/dist/web/components/form/select/status/index.d.ts +3 -1
- package/dist/web/components/form/select/status/index.js +3 -1
- package/dist/web/components/form/selectMultiple/dropdown-select/index.css +5 -5
- package/dist/web/components/form-date/index.d.ts +1 -1
- package/dist/web/components/form-email/index.d.ts +1 -1
- package/dist/web/components/form-input/index.d.ts +1 -1
- package/dist/web/components/form-input-hooks/index.js +10 -1
- package/dist/web/components/form-input-hooks/validator.d.ts +1 -0
- package/dist/web/components/form-input-hooks/validator.js +6 -2
- package/dist/web/components/form-phone/index.d.ts +1 -1
- package/dist/web/components/form-time/index.d.ts +1 -1
- package/dist/web/components/form-url/index.d.ts +1 -1
- package/dist/web/components/wd-date/elements/Modal.h5.d.ts +2 -0
- package/dist/web/components/wd-date/elements/Modal.h5.js +3 -3
- package/dist/web/components/wd-form/index.js +1 -1
- package/dist/web/components/wd-form-item/wd-form-item-read-only.d.ts +1 -0
- package/dist/web/components/wd-input/wd-input.d.ts +1 -1
- package/dist/web/components/wd-input-email/wd-input-email.d.ts +1 -1
- package/dist/web/components/wd-input-phone/wd-input-phone.d.ts +1 -1
- package/dist/web/components/wd-input-url/wd-input-url.d.ts +1 -1
- package/dist/web/components/wd-select/relationSelect/relationSelect.d.ts +4 -0
- package/dist/web/components/wd-select/relationSelect/relationSelect.js +202 -0
- package/dist/web/components/wd-select/{relationalSetting.js → relationSelect/relationalSetting.js} +4 -4
- package/dist/web/components/wd-select/select/index.d.ts +2 -0
- package/dist/web/components/wd-select/select/index.js +8 -0
- package/dist/web/components/wd-select/select/selectUI.d.ts +3 -0
- package/dist/web/components/wd-select/select/selectUI.js +190 -0
- package/dist/web/components/wd-select/style.d.ts +2 -0
- package/dist/web/components/wd-select/style.js +2 -0
- package/dist/web/components/wd-select/wd-select.css +83 -0
- package/dist/web/components/wd-select/wd-select.d.ts +0 -1
- package/dist/web/components/wd-select/wd-select.js +18 -8
- package/dist/web/components/wd-select-multiple/style.d.ts +2 -0
- package/dist/web/components/wd-select-multiple/style.js +2 -0
- package/dist/web/components/wd-select-multiple/wd-select-multiple.css +30 -4
- package/dist/web/components/wd-select-multiple/wd-select-multiple.js +18 -7
- package/dist/web/components/wd-table/components/FieldRender/index.d.ts +7 -4
- package/dist/web/components/wd-table/components/FieldRender/index.js +23 -7
- package/dist/web/components/wd-table/hooks/useChooseList.d.ts +1 -0
- package/dist/web/components/wd-table/hooks/useChooseList.js +55 -26
- package/dist/web/utils/platform.js +3 -3
- package/package.json +2 -2
- package/dist/configs/components/chart/bar.json +0 -1144
- /package/dist/web/components/wd-select/{relationalSetting.d.ts → relationSelect/relationalSetting.d.ts} +0 -0
|
@@ -9,16 +9,16 @@ type IRelationFetchOptions = {
|
|
|
9
9
|
where: unknown;
|
|
10
10
|
pageNo: number;
|
|
11
11
|
primaryField: string;
|
|
12
|
-
controlledValue
|
|
12
|
+
controlledValue?: OptionItem[];
|
|
13
13
|
};
|
|
14
14
|
type IEnumFetchOptions = {
|
|
15
15
|
format: 'x-enum';
|
|
16
16
|
enumName: string;
|
|
17
|
-
controlledValue
|
|
17
|
+
controlledValue?: OptionItem[];
|
|
18
18
|
};
|
|
19
19
|
export type IUseoptionsParams = (IRelationFetchOptions | IEnumFetchOptions | {
|
|
20
20
|
format?: string;
|
|
21
|
-
controlledValue
|
|
21
|
+
controlledValue?: OptionItem[];
|
|
22
22
|
}) & {
|
|
23
23
|
callWedaApi?: (params: any) => Promise<any> | any;
|
|
24
24
|
callDataSource?: (params: any) => Promise<any>;
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
border-radius: 3px;
|
|
119
119
|
display: block;
|
|
120
120
|
position: absolute;
|
|
121
|
-
left:
|
|
121
|
+
left: 5px;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
.weda-ui-custom-picker__cloumns.weda-ui-custom-picker__cloumns--select-multiple
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
border-radius: 3px;
|
|
131
131
|
display: block;
|
|
132
132
|
position: absolute;
|
|
133
|
-
left:
|
|
133
|
+
left: 5px;
|
|
134
134
|
background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTQiIGhlaWdodD0iMTAiIHZpZXdCb3g9IjAgMCAxNCAxMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTMuNDAxNDYgNy45NDI3QzMuNDAxNCA3Ljk0MjY0IDMuNDAxNTMgNy45NDI3NiAzLjQwMTQ2IDcuOTQyN0wwLjc1IDUuMjkxMjNMMi41NDM0OSAzLjU0OTE5TDUuMTcyMSA2LjE3NzhMMTEuMzY4NyAwTDEzLjEyNDQgMS43NTU3TDYuOTI3OCA3LjkzMzVMNi45MzcxOCA3Ljk0Mjg5TDYuOTExMDkgNy45NjgyM0M2Ljg1NyA4LjAyMDc3IDYuODAxMTQgOC4wNzAzNyA2Ljc0MzcxIDguMTE3MDRMNi4wNDEyMyA4LjgxNzM4QzUuNTUyODYgOS4zMDQyNyA0Ljc2MjQ0IDkuMzAzNjcgNC4yNzQ4MSA4LjgxNjA0TDMuNDAxNDYgNy45NDI3WiIgZmlsbD0id2hpdGUiIGZpbGwtb3BhY2l0eT0iMC45Ii8+Cjwvc3ZnPg==);
|
|
135
135
|
background-repeat: no-repeat;
|
|
136
136
|
background-position: center;
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
|
|
145
145
|
/* 下拉选择类型 */
|
|
146
146
|
.weda-ui-custom-picker__cloumns.weda-ui-custom-picker__cloumns--select-multiple {
|
|
147
|
-
padding: 0
|
|
147
|
+
padding: 0 16px;
|
|
148
148
|
height: 280px;
|
|
149
149
|
}
|
|
150
150
|
|
|
@@ -219,12 +219,12 @@
|
|
|
219
219
|
justify-content: space-between;
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
.wedatea2td-list.wedatea2td-list--option.wedatea2td-list--checkoption
|
|
222
|
+
/* .wedatea2td-list.wedatea2td-list--option.wedatea2td-list--checkoption
|
|
223
223
|
.wedatea2td-list__status
|
|
224
224
|
.wedatea2td-action-state
|
|
225
225
|
.wedatea2td-action-state__text {
|
|
226
226
|
display: none;
|
|
227
|
-
}
|
|
227
|
+
} */
|
|
228
228
|
|
|
229
229
|
.wedatea2td-list.wedatea2td-list--option.wedatea2td-list--checkoption
|
|
230
230
|
.wedatea2td-list__status
|
|
@@ -18,8 +18,8 @@ declare const FormDate: React.ForwardRefExoticComponent<CommonPropsType & {
|
|
|
18
18
|
start: string;
|
|
19
19
|
layout: "" | "vertical" | "horizontal";
|
|
20
20
|
mode: "datetime" | "year" | "month" | "day";
|
|
21
|
-
labelVisible: boolean;
|
|
22
21
|
clearable: boolean;
|
|
22
|
+
labelVisible: boolean;
|
|
23
23
|
requiredFlag: boolean;
|
|
24
24
|
requiredMsg: string;
|
|
25
25
|
} & {
|
|
@@ -17,8 +17,8 @@ declare const FormEmail: React.ForwardRefExoticComponent<CommonPropsType & {
|
|
|
17
17
|
maxLength: number;
|
|
18
18
|
placeholder: string;
|
|
19
19
|
layout: "" | "vertical" | "horizontal";
|
|
20
|
-
labelVisible: boolean;
|
|
21
20
|
clearable: boolean;
|
|
21
|
+
labelVisible: boolean;
|
|
22
22
|
requiredFlag: boolean;
|
|
23
23
|
requiredMsg: string;
|
|
24
24
|
} & {
|
|
@@ -18,9 +18,9 @@ declare const WdInput: React.ForwardRefExoticComponent<CommonPropsType & {
|
|
|
18
18
|
maxLength: number;
|
|
19
19
|
placeholder: string;
|
|
20
20
|
layout: "" | "vertical" | "horizontal";
|
|
21
|
+
clearable: boolean;
|
|
21
22
|
labelVisible: boolean;
|
|
22
23
|
isNickNameType: boolean;
|
|
23
|
-
clearable: boolean;
|
|
24
24
|
password: boolean;
|
|
25
25
|
rules: {
|
|
26
26
|
format: string;
|
|
@@ -143,7 +143,8 @@ export function useFormInputTrait(inputParams) {
|
|
|
143
143
|
setDisabled(originalDisabled);
|
|
144
144
|
};
|
|
145
145
|
},
|
|
146
|
-
async handleValidate() {
|
|
146
|
+
async handleValidate(throwError = true) {
|
|
147
|
+
var _a;
|
|
147
148
|
let finalValue = valueRef.current;
|
|
148
149
|
if (!required && !rules.length)
|
|
149
150
|
return;
|
|
@@ -236,6 +237,14 @@ export function useFormInputTrait(inputParams) {
|
|
|
236
237
|
if (errorArr.length > 0) {
|
|
237
238
|
setValidateState('error');
|
|
238
239
|
setValidateErrorMsg(errorArr[0].message);
|
|
240
|
+
if (throwError) {
|
|
241
|
+
const { compError } = errorHandler({
|
|
242
|
+
code: 'VALIDATE_ERROR',
|
|
243
|
+
error: errorArr,
|
|
244
|
+
message: `【${label}】${(_a = errorArr[0]) === null || _a === void 0 ? void 0 : _a.message}`,
|
|
245
|
+
});
|
|
246
|
+
throw compError;
|
|
247
|
+
}
|
|
239
248
|
}
|
|
240
249
|
else {
|
|
241
250
|
// console.log("校验成功>>>>>>>")
|
|
@@ -4,6 +4,7 @@ export declare const validType: {
|
|
|
4
4
|
readonly cn: (value: any) => boolean;
|
|
5
5
|
readonly mobile: (value: any) => boolean;
|
|
6
6
|
readonly tel: (value: any) => boolean;
|
|
7
|
+
readonly internationalTel: (value: any) => boolean;
|
|
7
8
|
readonly email: (value: any) => boolean;
|
|
8
9
|
readonly url: (value: any) => boolean;
|
|
9
10
|
readonly carId: (value: any) => boolean;
|
|
@@ -7,8 +7,9 @@ const pattern = {
|
|
|
7
7
|
cnName: /^[\u2E80-\uFE4F]{2,6}(?:·[\u2E80-\uFE4F]{2,6})*$/,
|
|
8
8
|
userName: /^[\da-zA-Z\u2E80-\uFE4F \s]{2,}$/,
|
|
9
9
|
carId: /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/,
|
|
10
|
-
mobile: /^
|
|
11
|
-
tel:
|
|
10
|
+
mobile: /^1[3-9]\d{9}$/,
|
|
11
|
+
tel: /(^(0\d{2,3}-)?|^\(\d{3}\)?|^(400|800)-?)(\d{3,8})(-\d{1,4})?$/,
|
|
12
|
+
internationalTel: /^(\+\d{1,4}[\s-]?)?(\(?\d{1,4}\)?[\s-]?)?(\d{1,4}[\s-]?)?(\d{1,4})?\d{1,9}(\s?(x|ext)\s?\d{1,6})?$/,
|
|
12
13
|
address: /^[\da-zA-Z\u2E80-\uFE4F \s-]{4,400}$/,
|
|
13
14
|
date: /((^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(10|12|0?[13578])([-\/\._])(3[01]|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(11|0?[469])([-\/\._])(30|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(0?2)([-\/\._])(2[0-8]|1[0-9]|0?[1-9])$)|(^([2468][048]00)([-\/\._])(0?2)([-\/\._])(29)$)|(^([3579][26]00)([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][0][48])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][0][48])([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][2468][048])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][2468][048])([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][13579][26])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][13579][26])([-\/\._])(0?2)([-\/\._])(29)$))/,
|
|
14
15
|
numVcode: /^[0-9]{4,8}$/,
|
|
@@ -58,6 +59,9 @@ export const validType = {
|
|
|
58
59
|
tel(value) {
|
|
59
60
|
return pattern.tel.test(String(value).trim());
|
|
60
61
|
},
|
|
62
|
+
internationalTel(value) {
|
|
63
|
+
return pattern.internationalTel.test(String(value).trim());
|
|
64
|
+
},
|
|
61
65
|
// 邮箱检测
|
|
62
66
|
email(value) {
|
|
63
67
|
return typeof value === 'string' && pattern.email.test(value.trim());
|
|
@@ -16,8 +16,8 @@ declare const FormPhone: React.ForwardRefExoticComponent<CommonPropsType & {
|
|
|
16
16
|
disabled: boolean;
|
|
17
17
|
placeholder: string;
|
|
18
18
|
layout: "" | "vertical" | "horizontal";
|
|
19
|
-
labelVisible: boolean;
|
|
20
19
|
clearable: boolean;
|
|
20
|
+
labelVisible: boolean;
|
|
21
21
|
requiredFlag: boolean;
|
|
22
22
|
requiredMsg: string;
|
|
23
23
|
} & {
|
|
@@ -17,8 +17,8 @@ declare const FormTime: React.ForwardRefExoticComponent<CommonPropsType & {
|
|
|
17
17
|
end: string;
|
|
18
18
|
start: string;
|
|
19
19
|
layout: "" | "vertical" | "horizontal";
|
|
20
|
-
labelVisible: boolean;
|
|
21
20
|
clearable: boolean;
|
|
21
|
+
labelVisible: boolean;
|
|
22
22
|
requiredFlag: boolean;
|
|
23
23
|
requiredMsg: string;
|
|
24
24
|
} & {
|
|
@@ -17,8 +17,8 @@ declare const FormUrl: React.ForwardRefExoticComponent<CommonPropsType & {
|
|
|
17
17
|
maxLength: number;
|
|
18
18
|
placeholder: string;
|
|
19
19
|
layout: "" | "vertical" | "horizontal";
|
|
20
|
-
labelVisible: boolean;
|
|
21
20
|
clearable: boolean;
|
|
21
|
+
labelVisible: boolean;
|
|
22
22
|
requiredFlag: boolean;
|
|
23
23
|
requiredMsg: string;
|
|
24
24
|
} & {
|
|
@@ -7,10 +7,10 @@ import classNames from '../../../utils/classnames';
|
|
|
7
7
|
* H5端 模态框
|
|
8
8
|
*/
|
|
9
9
|
export function Modal(props) {
|
|
10
|
-
const { onOk = noop, onClose = noop, visible, children, className, header, } = props;
|
|
10
|
+
const { onOk = noop, onClose = noop, visible, children, className, header, okButtonVisible = true, popupContainer, } = props;
|
|
11
11
|
const { classPrefix } = useConfig();
|
|
12
12
|
if (!visible)
|
|
13
13
|
return null;
|
|
14
|
-
const renderHeader = () => header ? (header) : (_jsxs("div", { className: `${classPrefix}-custom-picker__header`, children: [_jsx("div", { className: `${classPrefix}-custom-picker__header-cancle`, onClick: onClose, children: "\u53D6\u6D88" }), _jsx("div", { className: `${classPrefix}-custom-picker__header-confirm`, onClick: onOk, children: "\u786E\u5B9A" })] }));
|
|
15
|
-
return (_jsx(Portal, { type: "div", children: _jsxs("div", { className: classNames(`${classPrefix}-custom-picker`, className), children: [_jsx("div", { className: `${classPrefix}-custom-backdrop`, onClick: onClose }), _jsxs("div", { className: `${classPrefix}-custom-picker__inner`, children: [renderHeader(), _jsx("div", { className: `${classPrefix}-custom-picker__body`, children: children })] })] }) }));
|
|
14
|
+
const renderHeader = () => header ? (header) : (_jsxs("div", { className: `${classPrefix}-custom-picker__header`, children: [_jsx("div", { className: `${classPrefix}-custom-picker__header-cancle`, onClick: onClose, children: "\u53D6\u6D88" }), okButtonVisible && (_jsx("div", { className: `${classPrefix}-custom-picker__header-confirm`, onClick: onOk, children: "\u786E\u5B9A" }))] }));
|
|
15
|
+
return (_jsx(Portal, { type: "div", portalContainer: popupContainer, children: _jsxs("div", { className: classNames(`${classPrefix}-custom-picker`, className), children: [_jsx("div", { className: `${classPrefix}-custom-backdrop`, onClick: onClose }), _jsxs("div", { className: `${classPrefix}-custom-picker__inner`, children: [renderHeader(), _jsx("div", { className: `${classPrefix}-custom-picker__body`, children: children })] })] }) }));
|
|
16
16
|
}
|
|
@@ -86,7 +86,7 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
|
|
|
86
86
|
}
|
|
87
87
|
items.forEach((item) => {
|
|
88
88
|
if (item.handleValidate) {
|
|
89
|
-
const validate = item.handleValidate();
|
|
89
|
+
const validate = item.handleValidate(false);
|
|
90
90
|
const { name, label } = item;
|
|
91
91
|
if (validate) {
|
|
92
92
|
validatePromise.push(validate);
|
|
@@ -26,6 +26,7 @@ export declare const WdInput: React.ForwardRefExoticComponent<CommonPropsType &
|
|
|
26
26
|
suffixIcon?: string;
|
|
27
27
|
suffixSrc?: string;
|
|
28
28
|
labelWidth?: string;
|
|
29
|
+
clearable?: boolean;
|
|
29
30
|
inputValue?: string;
|
|
30
31
|
labelVisible?: boolean;
|
|
31
32
|
labelAlign?: string;
|
|
@@ -33,7 +34,6 @@ export declare const WdInput: React.ForwardRefExoticComponent<CommonPropsType &
|
|
|
33
34
|
labelTips?: string;
|
|
34
35
|
isNickNameType?: boolean;
|
|
35
36
|
cursorSpacing?: number;
|
|
36
|
-
clearable?: boolean;
|
|
37
37
|
isUnionValue?: boolean;
|
|
38
38
|
password?: boolean;
|
|
39
39
|
counterVisible?: boolean;
|
|
@@ -25,13 +25,13 @@ export declare const WdInputEmail: React.ForwardRefExoticComponent<CommonPropsTy
|
|
|
25
25
|
suffixIcon?: string;
|
|
26
26
|
suffixSrc?: string;
|
|
27
27
|
labelWidth?: string;
|
|
28
|
+
clearable?: boolean;
|
|
28
29
|
inputValue?: string;
|
|
29
30
|
labelVisible?: boolean;
|
|
30
31
|
labelAlign?: string;
|
|
31
32
|
labelWrap?: boolean;
|
|
32
33
|
labelTips?: string;
|
|
33
34
|
cursorSpacing?: number;
|
|
34
|
-
clearable?: boolean;
|
|
35
35
|
isUnionValue?: boolean;
|
|
36
36
|
counterVisible?: boolean;
|
|
37
37
|
borderedH5?: boolean;
|
|
@@ -42,6 +42,7 @@ export declare const WdInputPhone: React.ForwardRefExoticComponent<CommonPropsTy
|
|
|
42
42
|
suffixIcon?: string;
|
|
43
43
|
suffixSrc?: string;
|
|
44
44
|
labelWidth?: string;
|
|
45
|
+
clearable?: boolean;
|
|
45
46
|
inputValue?: string;
|
|
46
47
|
labelVisible?: boolean;
|
|
47
48
|
labelAlign?: string;
|
|
@@ -49,7 +50,6 @@ export declare const WdInputPhone: React.ForwardRefExoticComponent<CommonPropsTy
|
|
|
49
50
|
labelTips?: string;
|
|
50
51
|
isNickNameType?: boolean;
|
|
51
52
|
cursorSpacing?: number;
|
|
52
|
-
clearable?: boolean;
|
|
53
53
|
isUnionValue?: boolean;
|
|
54
54
|
password?: boolean;
|
|
55
55
|
counterVisible?: boolean;
|
|
@@ -41,13 +41,13 @@ export declare const WdInputUrl: React.ForwardRefExoticComponent<CommonPropsType
|
|
|
41
41
|
suffixIcon?: string;
|
|
42
42
|
suffixSrc?: string;
|
|
43
43
|
labelWidth?: string;
|
|
44
|
+
clearable?: boolean;
|
|
44
45
|
inputValue?: string;
|
|
45
46
|
labelVisible?: boolean;
|
|
46
47
|
labelAlign?: string;
|
|
47
48
|
labelWrap?: boolean;
|
|
48
49
|
labelTips?: string;
|
|
49
50
|
cursorSpacing?: number;
|
|
50
|
-
clearable?: boolean;
|
|
51
51
|
isUnionValue?: boolean;
|
|
52
52
|
counterVisible?: boolean;
|
|
53
53
|
borderedH5?: boolean;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
3
|
+
import { useState, useImperativeHandle, useMemo, useEffect, useCallback, } from 'react';
|
|
4
|
+
import { LoadingTip } from 'tea-component';
|
|
5
|
+
import { SelectUI as Select } from '../select/selectUI';
|
|
6
|
+
import { WdIcon } from '../../wd-icon';
|
|
7
|
+
import { getTableColumns } from '../../wd-table/components/FieldRender';
|
|
8
|
+
import { useAuthFields } from '../../wd-table/hooks/useAuthFields';
|
|
9
|
+
import { usePlatform } from '../../../utils/platform';
|
|
10
|
+
import { DataSource } from '../../../utils/datasource';
|
|
11
|
+
import { EnumHoc } from '../../../utils/hooks/EnumHoc';
|
|
12
|
+
import { useSyncValue } from '../../../utils/hooks/useSyncValue';
|
|
13
|
+
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
14
|
+
import { requestEnumOption } from '../../form/select/request';
|
|
15
|
+
import { convertWhere } from '../../../utils/getModelParams';
|
|
16
|
+
import { useChooseList } from '../../wd-table/hooks/useChooseList';
|
|
17
|
+
const OptionText = ({ mode, option, selectFields, authFields, onChange, onRelationOptionJump, enableRelationOptionJump, }) => {
|
|
18
|
+
const platform = usePlatform();
|
|
19
|
+
const columns = useMemo(() => {
|
|
20
|
+
return getTableColumns({
|
|
21
|
+
fields: authFields,
|
|
22
|
+
columnSets: selectFields.map((i) => {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
return ({
|
|
25
|
+
header: (_a = authFields.find((j) => j.name === i)) === null || _a === void 0 ? void 0 : _a.title,
|
|
26
|
+
key: (_b = authFields.find((j) => j.name === i)) === null || _b === void 0 ? void 0 : _b.name,
|
|
27
|
+
});
|
|
28
|
+
}),
|
|
29
|
+
isH5: false,
|
|
30
|
+
supportManyRelated: true,
|
|
31
|
+
slots: null,
|
|
32
|
+
fixedEnd: null,
|
|
33
|
+
fixedFront: null,
|
|
34
|
+
showRelationWithTag: false,
|
|
35
|
+
});
|
|
36
|
+
}, [authFields, selectFields]);
|
|
37
|
+
return (_jsxs("div", { className: "wd-relation-select-option-wrap", onClick: (e) => {
|
|
38
|
+
if (platform === 'pc' && mode !== 'multiple') {
|
|
39
|
+
e.stopPropagation();
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(option === null || option === void 0 ? void 0 : option.value);
|
|
42
|
+
}
|
|
43
|
+
}, children: [_jsxs("div", { className: "wd-relation-select-header", children: [_jsx("p", { className: "wd-relation-select-header-text", children: (option === null || option === void 0 ? void 0 : option.label) || (option === null || option === void 0 ? void 0 : option.value) }), enableRelationOptionJump && (_jsx("span", { onClick: () => {
|
|
44
|
+
onRelationOptionJump({ item: option });
|
|
45
|
+
}, children: _jsx(WdIcon, { name: "td:jump", size: "s", type: "inner" }) }))] }), _jsxs("div", { className: "wd-relation-select-option-group", children: [_jsx("div", { className: "wd-relation-select-option-header", children: columns.map((i) => (_jsx("div", { className: "wd-relation-select-option-text", style: { width: columns.length > 1 ? i.width : 'auto' }, children: i.header }, i.key))) }), _jsx("div", { className: "wd-relation-select-option-content", children: columns.map((i) => (_jsx("div", { className: "wd-relation-select-option-text", style: { width: columns.length > 1 ? i.width : 'auto' }, children: i.render(option === null || option === void 0 ? void 0 : option.extra) }, i.key))) })] })] }));
|
|
46
|
+
};
|
|
47
|
+
// 每次请求数据个数
|
|
48
|
+
const defaultSize = 50;
|
|
49
|
+
const defaultPage = 1;
|
|
50
|
+
export function RelationSelect(props) {
|
|
51
|
+
const { placeholder, size, disabled, onChange, value, onSearch, addRelationButton, childRef, dataSourceName, selectFields, selectFieldType, primaryField, setRefreshStatus, mode, onRelationOptionJump, enableRelationOptionJump, } = props;
|
|
52
|
+
const { authFields } = useAuthFields({
|
|
53
|
+
dbName: dataSourceName,
|
|
54
|
+
dbFieldNames: [],
|
|
55
|
+
isNewData: true,
|
|
56
|
+
isModel: true,
|
|
57
|
+
columnSetsKey: [],
|
|
58
|
+
connectorMethod: '',
|
|
59
|
+
isNoDataSourceBind: false,
|
|
60
|
+
isExpression: false,
|
|
61
|
+
isApis: false,
|
|
62
|
+
});
|
|
63
|
+
// 是否具备展示自定义字段的条件
|
|
64
|
+
const isRelationSelectOption = selectFieldType === 'custom' && (selectFields === null || selectFields === void 0 ? void 0 : selectFields.length) && (authFields === null || authFields === void 0 ? void 0 : authFields.length);
|
|
65
|
+
const dataSourceAPI = useMemo(() => new DataSource(dataSourceName), [dataSourceName]); // datasource 方法-模型
|
|
66
|
+
const whereList = convertWhere(props);
|
|
67
|
+
const [query, setQuery] = useSyncValue({
|
|
68
|
+
pageNo: defaultPage,
|
|
69
|
+
pageSize: defaultSize,
|
|
70
|
+
where: whereList,
|
|
71
|
+
}, isObjectEqual);
|
|
72
|
+
const { result: options, total, isValidating: isLoading, empty, getRelationOptions, } = useChooseList({
|
|
73
|
+
dataSourceAPI,
|
|
74
|
+
childDbName: dataSourceName,
|
|
75
|
+
queryParams: query,
|
|
76
|
+
primaryColumn: primaryField,
|
|
77
|
+
value,
|
|
78
|
+
});
|
|
79
|
+
// 下拉选项数据
|
|
80
|
+
const customOptions = useMemo(() => {
|
|
81
|
+
return isRelationSelectOption
|
|
82
|
+
? options === null || options === void 0 ? void 0 : options.map((i) => ({
|
|
83
|
+
...i,
|
|
84
|
+
text: (_jsx(OptionText, { mode: mode, option: i, selectFields: selectFields, authFields: authFields, onChange: onChange, onRelationOptionJump: onRelationOptionJump, enableRelationOptionJump: enableRelationOptionJump })),
|
|
85
|
+
}))
|
|
86
|
+
: options;
|
|
87
|
+
}, [
|
|
88
|
+
authFields,
|
|
89
|
+
enableRelationOptionJump,
|
|
90
|
+
isRelationSelectOption,
|
|
91
|
+
mode,
|
|
92
|
+
onChange,
|
|
93
|
+
onRelationOptionJump,
|
|
94
|
+
options,
|
|
95
|
+
selectFields,
|
|
96
|
+
]);
|
|
97
|
+
const searchOptionListWithWhere = useCallback((where = whereList) => {
|
|
98
|
+
empty();
|
|
99
|
+
setQuery({ ...query, pageNo: defaultPage, where });
|
|
100
|
+
}, [empty, query, setQuery, whereList]);
|
|
101
|
+
useImperativeHandle(childRef, () => {
|
|
102
|
+
return {
|
|
103
|
+
refresh: async () => {
|
|
104
|
+
setRefreshStatus(true);
|
|
105
|
+
if (query.pageNo === defaultPage) {
|
|
106
|
+
await getRelationOptions();
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
searchOptionListWithWhere();
|
|
110
|
+
}
|
|
111
|
+
// eslint-disable-next-line rulesdir/no-timer
|
|
112
|
+
const timer = setTimeout(() => {
|
|
113
|
+
setRefreshStatus(false);
|
|
114
|
+
clearTimeout(timer);
|
|
115
|
+
}, 500);
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}, [
|
|
119
|
+
getRelationOptions,
|
|
120
|
+
query.pageNo,
|
|
121
|
+
searchOptionListWithWhere,
|
|
122
|
+
setRefreshStatus,
|
|
123
|
+
]);
|
|
124
|
+
const searchHandle = (keyword) => {
|
|
125
|
+
let where = whereList;
|
|
126
|
+
if (keyword === null || keyword === void 0 ? void 0 : keyword.length) {
|
|
127
|
+
// 筛选面板的查询条件与数据过滤的查询条件是且的关系
|
|
128
|
+
where = {
|
|
129
|
+
$and: [
|
|
130
|
+
...whereList,
|
|
131
|
+
{ $and: [{ [primaryField]: { $search: keyword } }] },
|
|
132
|
+
],
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
searchOptionListWithWhere(where);
|
|
136
|
+
onSearch(keyword);
|
|
137
|
+
};
|
|
138
|
+
return (_jsx(EnumHoc, { fields: authFields, children: _jsx(Select, { ...props, overlayClassName: isRelationSelectOption ? 'wd-relation-select-overlay' : '', searchable: true, matchButtonWidth: true, placeholder: placeholder, appearance: 'button', size: size, disabled: disabled, autoClearSearchValue: true, options: customOptions, value: value, onChange: onChange, onSearch: searchHandle, tips: isLoading ? '' : undefined, bottomTips: isLoading ? _jsx(LoadingTip, {}) : undefined, onScrollBottom: () => {
|
|
139
|
+
if (!isLoading && customOptions.length < total) {
|
|
140
|
+
setQuery((query) => ({
|
|
141
|
+
...query,
|
|
142
|
+
pageNo: query.pageNo + defaultPage,
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
}, onOpen: () => {
|
|
146
|
+
searchOptionListWithWhere();
|
|
147
|
+
}, footer: addRelationButton, mode: mode }) }));
|
|
148
|
+
}
|
|
149
|
+
export function EnumSelect(props) {
|
|
150
|
+
const { placeholder, size, disabled, onChange, value, onSearch, addRelationButton, childRef, dataSourceName, enumName, primaryField, format, viewId, where, setRefreshStatus, mode, } = props;
|
|
151
|
+
const [enumOption, setEnumOption] = useState([]);
|
|
152
|
+
const [isLoading, setLoading] = useState(false);
|
|
153
|
+
// 获取枚举字段类型的下拉选项
|
|
154
|
+
const getEnumOption = useCallback(async () => {
|
|
155
|
+
const params = {
|
|
156
|
+
format,
|
|
157
|
+
dataSourceName,
|
|
158
|
+
viewId,
|
|
159
|
+
where,
|
|
160
|
+
primaryField,
|
|
161
|
+
enumName,
|
|
162
|
+
};
|
|
163
|
+
setLoading(true);
|
|
164
|
+
const options = await requestEnumOption(params);
|
|
165
|
+
setEnumOption(options);
|
|
166
|
+
setLoading(false);
|
|
167
|
+
}, [dataSourceName, enumName, format, primaryField, viewId, where]);
|
|
168
|
+
useEffect(() => {
|
|
169
|
+
getEnumOption();
|
|
170
|
+
}, [getEnumOption]);
|
|
171
|
+
useImperativeHandle(childRef, () => {
|
|
172
|
+
return {
|
|
173
|
+
refresh: async () => {
|
|
174
|
+
setRefreshStatus(true);
|
|
175
|
+
await getEnumOption();
|
|
176
|
+
// eslint-disable-next-line rulesdir/no-timer
|
|
177
|
+
const timer = setTimeout(() => {
|
|
178
|
+
setRefreshStatus(false);
|
|
179
|
+
clearTimeout(timer);
|
|
180
|
+
}, 500);
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
}, [getEnumOption, setRefreshStatus]);
|
|
184
|
+
const searchHandle = (keyword) => {
|
|
185
|
+
onSearch(keyword);
|
|
186
|
+
};
|
|
187
|
+
return (_jsx(Select, { ...props, mode: mode, searchable: true, matchButtonWidth: true, placeholder: placeholder, appearance: 'button', size: size, disabled: disabled, autoClearSearchValue: true, options: enumOption, value: value, onChange: onChange, onSearch: searchHandle, footer: addRelationButton, bottomTips: isLoading ? _jsx(LoadingTip, {}) : undefined }));
|
|
188
|
+
}
|
|
189
|
+
export function CustomSelect(props) {
|
|
190
|
+
const { format, addRelationButtonText, enableAddRelationButton, events } = props;
|
|
191
|
+
const isEnumType = format === 'x-enum';
|
|
192
|
+
const [refreshStatus, setRefreshStatus] = useState(false);
|
|
193
|
+
const listWidth = 700;
|
|
194
|
+
const addRelationButton = enableAddRelationButton && (_jsxs("span", { className: "wd-add-relation-button-wrap", onClick: () => {
|
|
195
|
+
var _a;
|
|
196
|
+
(_a = events === null || events === void 0 ? void 0 : events.onAddRelationButtonClick) === null || _a === void 0 ? void 0 : _a.call(events);
|
|
197
|
+
}, children: [_jsx(WdIcon, { size: 'xs', name: 'td:add-circle' }), addRelationButtonText] }));
|
|
198
|
+
if (refreshStatus) {
|
|
199
|
+
return _jsx(LoadingTip, {});
|
|
200
|
+
}
|
|
201
|
+
return isEnumType ? (_jsx(EnumSelect, { ...props, addRelationButton: addRelationButton, setRefreshStatus: setRefreshStatus, listWidth: listWidth })) : (_jsx(RelationSelect, { ...props, addRelationButton: addRelationButton, setRefreshStatus: setRefreshStatus, listWidth: listWidth, searchPlaceholder: '搜索主列' }));
|
|
202
|
+
}
|
package/dist/web/components/wd-select/{relationalSetting.js → relationSelect/relationalSetting.js}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import WdIcon from '
|
|
3
|
-
import { useConfig } from '
|
|
4
|
-
import { useSize } from '
|
|
5
|
-
import classNames from '
|
|
2
|
+
import WdIcon from '../../wd-icon';
|
|
3
|
+
import { useConfig } from '../../../utils/config-context';
|
|
4
|
+
import { useSize } from '../../../utils/hooks/useFormLegacy';
|
|
5
|
+
import classNames from '../../../utils/classnames';
|
|
6
6
|
export const RelationalSetting = ({ refresh, setting, size: _size, enableRelationalSetting, enableRelationalRefresh, }) => {
|
|
7
7
|
const { classPrefix } = useConfig();
|
|
8
8
|
const size = useSize({ size: _size });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ConfigProvider } from 'tea-component';
|
|
3
|
+
import { CustomSelect } from '../relationSelect/relationSelect';
|
|
4
|
+
import { SelectUI as Select } from './selectUI';
|
|
5
|
+
export function SelectCom(props) {
|
|
6
|
+
const { isRelation } = props;
|
|
7
|
+
return (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: isRelation ? _jsx(CustomSelect, { ...props }) : _jsx(Select, { ...props }) }));
|
|
8
|
+
}
|