@cloudbase/weda-ui 3.4.11-alpha.1 → 3.4.12
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/common/form-input-required.js +3 -3
- package/dist/configs/components/dataView.js +20 -10
- package/dist/configs/components/form-checkbox.js +15 -2
- package/dist/configs/components/form-email.js +17 -2
- package/dist/configs/components/form-input.js +17 -2
- package/dist/configs/components/form-phone.js +17 -2
- package/dist/configs/components/form-radio.js +15 -2
- package/dist/configs/components/form-select-multiple.js +362 -0
- package/dist/configs/components/form-switch.js +15 -2
- package/dist/configs/components/form-text-area.js +15 -2
- package/dist/configs/components/form-url.js +17 -2
- package/dist/configs/components/listView.js +32 -49
- package/dist/configs/components/table.json +1 -54
- package/dist/configs/components/wd-bubble.js +46 -8
- package/dist/configs/components/wd-checkbox.js +464 -0
- package/dist/configs/components/wd-form.js +66 -10
- package/dist/configs/components/wd-input-email.js +37 -0
- package/dist/configs/components/wd-input-phone.js +43 -0
- package/dist/configs/components/wd-input-url.js +37 -0
- package/dist/configs/components/wd-input.js +94 -0
- package/dist/configs/components/wd-official-account.js +87 -0
- package/dist/configs/components/wd-radio.js +443 -0
- package/dist/configs/components/wd-switch.js +315 -0
- package/dist/configs/components/wd-table.js +1 -54
- package/dist/configs/components/wd-textarea.js +82 -0
- package/dist/configs/components/wd-tree.js +443 -0
- package/dist/configs/index.js +24 -1
- package/dist/configs/type-utils/type-form.js +681 -0
- package/dist/docs/common/components/methods-view.js +1 -1
- package/dist/docs/common/components/properties-view.js +3 -1
- package/dist/docs/common/format.js +7 -7
- package/dist/docs/common/tableView.js +3 -1
- package/dist/enum/index.js +196 -0
- package/dist/style/index.scss +1 -1
- package/dist/web/components/calendar/index.js +1 -1
- package/dist/web/components/customer-service/customer-service.js +19 -2
- package/dist/web/components/dataView/index.js +16 -3
- package/dist/web/components/flow/common/hooks/useCommonFlowData/flow-get.js +5 -1
- package/dist/web/components/flow/common/request.js +5 -5
- package/dist/web/components/flow/modules/operations/controls-items/flow-task-info-modal.js +8 -16
- package/dist/web/components/form/enumSelect/MultipleSelect.js +1 -0
- package/dist/web/components/form/enumSelect/SelectContainer.js +1 -0
- package/dist/web/components/form/formcell/index.css +13 -1
- package/dist/web/components/form/formcell/index.js +1 -1
- package/dist/web/components/form/location/components/LocationH5/location.h5.js +1 -1
- package/dist/web/components/form/location/components/LocationPC/Header.js +1 -0
- package/dist/web/components/form/location/index.js +1 -0
- package/dist/web/components/form/select/h5.js +8 -7
- package/dist/web/components/form/select/index.js +9 -9
- package/dist/web/components/form/select/region/index.js +1 -1
- package/dist/web/components/form/selectMultiple/dropdown-select/h5.js +111 -0
- package/dist/web/components/form/selectMultiple/dropdown-select/index.css +270 -0
- package/dist/web/components/form/selectMultiple/dropdown-select/index.js +206 -0
- package/dist/web/components/form/selectMultiple/dropdown-select/pc.js +115 -0
- package/dist/web/components/form/selectMultiple/dropdown-select/ui.js +113 -0
- package/dist/web/components/form/selectMultiple/h5.js +40 -0
- package/dist/web/components/form/selectMultiple/index.js +94 -0
- package/dist/web/components/form/selectMultiple/request.js +76 -0
- package/dist/web/components/form/selectMultiple/status/allEmpty.js +5 -0
- package/dist/web/components/form/selectMultiple/status/empty.js +19 -0
- package/dist/web/components/form/selectMultiple/status/index.css +63 -0
- package/dist/web/components/form/selectMultiple/status/index.js +7 -0
- package/dist/web/components/form/selectMultiple/status/loading.js +19 -0
- package/dist/web/components/form/selectMultiple/status/propsType.js +1 -0
- package/dist/web/components/form/selectMultiple/status/retry.js +19 -0
- package/dist/web/components/form/tips/index.css +9 -3
- package/dist/web/components/form/uploader/index.css +10 -0
- package/dist/web/components/form/uploader/uploader.h5.js +6 -6
- package/dist/web/components/form/uploader/uploader.pc.js +1 -1
- package/dist/web/components/form/uploaderFile/index.js +2 -0
- package/dist/web/components/form/uploaderFile/uploadFile.h5.js +0 -19
- package/dist/web/components/form/uploaderFile/uploadFile.pc.js +3 -24
- package/dist/web/components/form/userOrgSelect/common/fetch-data-service.js +7 -4
- package/dist/web/components/form/userOrgSelect/common/utils.js +1 -0
- package/dist/web/components/form/userOrgSelect/component/user-select-h5/index.js +15 -5
- package/dist/web/components/form-input-hooks/index.js +39 -14
- package/dist/web/components/form-select-multiple/index.js +26 -0
- package/dist/web/components/formdetail/index.css +31 -1
- package/dist/web/components/formdetail/index.js +30 -0
- package/dist/web/components/index.js +17 -1
- package/dist/web/components/listView/index.js +20 -5
- package/dist/web/components/phone/index.js +26 -1
- package/dist/web/components/phoneCode/index.js +3 -1
- package/dist/web/components/repeater/index.js +1 -0
- package/dist/web/components/repeater-item/index.js +1 -0
- package/dist/web/components/richText/index.css +70 -67
- package/dist/web/components/richText/index.js +311 -251
- package/dist/web/components/richText/richtext.module.css +1 -0
- package/dist/web/components/richTextView/index.css +39 -0
- package/dist/web/components/richTextView/index.js +1 -1
- package/dist/web/components/share/index.js +26 -1
- package/dist/web/components/statusContent/index.js +1 -0
- package/dist/web/components/wd-checkbox/checkbox.js +34 -0
- package/dist/web/components/wd-checkbox/index.js +3 -0
- package/dist/web/components/wd-checkbox-list/checkboxList.js +140 -0
- package/dist/web/components/wd-checkbox-list/index.js +3 -0
- package/dist/web/components/wd-form/index.js +25 -12
- package/dist/web/components/wd-form/wd-form.js +42 -0
- package/dist/web/components/wd-form-cell/index.js +3 -0
- package/dist/web/components/wd-form-cell/wd-form-cell.js +42 -0
- package/dist/web/components/wd-form-item/index.js +4 -0
- package/dist/web/components/wd-form-item/wd-form-item.js +55 -0
- package/dist/web/components/wd-form-item/wd-input-group.js +24 -0
- package/dist/web/components/wd-input/index.js +3 -0
- package/dist/web/components/wd-input/wd-input.js +155 -0
- package/dist/web/components/wd-input-email/index.js +3 -0
- package/dist/web/components/wd-input-email/wd-input-email.js +13 -0
- package/dist/web/components/wd-input-group/index.js +3 -0
- package/dist/web/components/wd-input-group/wd-input-group.js +10 -0
- package/dist/web/components/wd-input-phone/index.js +3 -0
- package/dist/web/components/wd-input-phone/wd-input-phone.js +14 -0
- package/dist/web/components/wd-input-url/index.js +3 -0
- package/dist/web/components/wd-input-url/wd-input-url.js +13 -0
- package/dist/web/components/wd-input-wrap/index.js +3 -0
- package/dist/web/components/wd-input-wrap/wd-input-wrap.js +18 -0
- package/dist/web/components/wd-official-account/index.css +29 -0
- package/dist/web/components/wd-official-account/index.js +36 -0
- package/dist/web/components/wd-radio/index.js +3 -0
- package/dist/web/components/wd-radio/wd-radio.js +30 -0
- package/dist/web/components/wd-radio-list/index.js +3 -0
- package/dist/web/components/wd-radio-list/wd-radio-list.js +104 -0
- package/dist/web/components/wd-switch/index.js +3 -0
- package/dist/web/components/wd-switch/wd-switch.js +52 -0
- package/dist/web/components/wd-table/components/Table/index.js +12 -2
- package/dist/web/components/wd-table/hooks/useQueryParams.js +4 -1
- package/dist/web/components/wd-table/utils/index.js +6 -2
- package/dist/web/components/wd-table/wd-table.js +70 -57
- package/dist/web/components/wd-textarea/index.js +3 -0
- package/dist/web/components/wd-textarea/wd-textarea.js +78 -0
- package/dist/web/components/wd-tree/index.js +3 -0
- package/dist/web/components/wd-tree/utils.js +291 -0
- package/dist/web/components/wd-tree/wd-tree.js +193 -0
- package/dist/web/utils/constant.js +16 -0
- package/dist/web/utils/datasource.js +2 -2
- package/dist/web/utils/hooks/useFormLegacy.js +111 -0
- package/dist/web/utils/tool.js +12 -2
- package/dist/web/weda-ui.css +193 -3
- package/package.json +6 -5
- package/dist/web/components/emptyContent/index.js +0 -46
- package/dist/web/components/flow/components/FlowModuleText/Content.js +0 -6
- package/dist/web/components/flow/components/FlowModuleText/Title.js +0 -16
- package/dist/web/components/flow/components/FlowModuleText/index.js +0 -7
- package/dist/web/components/flow/components/FlowModuleText/utils.js +0 -34
- package/dist/web/components/flow/components/FlowStatusText/index.js +0 -37
- package/dist/web/components/flow/components/HighLightComment/index.js +0 -31
- package/dist/web/components/flow/components/index.js +0 -3
- package/dist/web/components/flow/constants/index.js +0 -65
- package/dist/web/components/flow/frame/getCommonFlowData.js +0 -80
- package/dist/web/components/flow/frame/hooks/index.js +0 -2
- package/dist/web/components/flow/frame/hooks/useCommonFlowRequest.js +0 -148
- package/dist/web/components/flow/frame/hooks/useElementMediaQuery.js +0 -15
- package/dist/web/components/flow/frame/index.js +0 -76
- package/dist/web/components/flow/frame/types.js +0 -277
- package/dist/web/components/flow/frame/utils.js +0 -149
- package/dist/web/components/flow/modules/chart/Chart.js +0 -282
- package/dist/web/components/flow/modules/chart/constants.js +0 -28
- package/dist/web/components/flow/modules/chart/index.css +0 -84
- package/dist/web/components/flow/modules/chart/isString.js +0 -5
- package/dist/web/components/flow/modules/chart/utils.js +0 -111
- package/dist/web/components/flow/modules/process/Process.js +0 -73
- package/dist/web/components/flow/modules/process/ProcessMobile.js +0 -81
- package/dist/web/components/flow/modules/process/index.js +0 -14
- package/dist/web/components/flow/modules/process/utils/index.js +0 -32
- package/dist/web/components/flow/services/flow.js +0 -111
- package/dist/web/components/flow/services/ideData/chart.js +0 -88
- package/dist/web/components/flow/services/ideData/index.js +0 -5
- package/dist/web/components/flow/services/ideData/instance.js +0 -23
- package/dist/web/components/flow/services/ideData/pageDetail.js +0 -42
- package/dist/web/components/flow/services/ideData/process.js +0 -27
- package/dist/web/components/flow/services/index.js +0 -2
- package/dist/web/components/flow/services/user.js +0 -23
- package/dist/web/components/flow/services/utils.js +0 -28
- package/dist/web/components/form/userOrgSelect/component/OrgPaths.js +0 -12
- package/dist/web/components/form/userOrgSelect/component/depart-select/departTreeSelect.h5.js +0 -156
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/* eslint max-lines: [error, 500] */
|
|
3
|
+
import { forwardRef, useImperativeHandle, useEffect, useMemo, useRef, useState, useCallback, } from 'react';
|
|
4
|
+
import { WdFormItem, WdInputGroup } from '../wd-form-item';
|
|
5
|
+
import { useFormInputTrait } from '../form-input-hooks';
|
|
6
|
+
import { WdIcon } from '../wd-icon';
|
|
7
|
+
import { filterPropsWithOn, getUuid } from '../../utils/tool';
|
|
8
|
+
import { FORM_MAX_LENGTH, KEY_DOWN_CODE } from '../../utils/constant';
|
|
9
|
+
import classNames from '../../utils/classnames';
|
|
10
|
+
import { useSyncValue } from '../../utils/hooks/useSyncValue';
|
|
11
|
+
import { usePlatform } from '../../utils/platform';
|
|
12
|
+
import { useSize, useRules, converValueFix, converInputValue, useStringProp, } from '../../utils/hooks/useFormLegacy';
|
|
13
|
+
import { useConfig } from '../../utils/config-context';
|
|
14
|
+
import isEqual from 'lodash.isequal';
|
|
15
|
+
const inputTypes = { idcard: 'text', digit: 'number' };
|
|
16
|
+
/**
|
|
17
|
+
* 标准化:单行输入组件
|
|
18
|
+
*/
|
|
19
|
+
export const WdInput = forwardRef(function WdInput(props, ref) {
|
|
20
|
+
const { name, password = false, type = 'text', placeholder = '请输入', focus: _focus = false, maxLength = FORM_MAX_LENGTH, clearable = true, events, block: _block, prefixType, prefixIcon, prefixSrc, suffixType, suffixIcon, suffixSrc, classRoot = 'input', wrapClassName = '', counterVisible, label, required, inputPattern, } = props;
|
|
21
|
+
const { before, after, inputValue } = useStringProp(props);
|
|
22
|
+
const [innerHandle, setInnerHandle] = useState({}); // hook里挂出的属性
|
|
23
|
+
const [currentInputValue, setCurrentInputValue] = useSyncValue(inputValue); // 监听inputValue
|
|
24
|
+
const formValue = useMemo(() => converValueFix(inputValue, before, after, type), [inputValue, before, after, type]);
|
|
25
|
+
const rules = useRules(props); // 含前后缀和必填时,仅对输入框校验
|
|
26
|
+
const traitProps = {
|
|
27
|
+
...props,
|
|
28
|
+
rules,
|
|
29
|
+
value: formValue,
|
|
30
|
+
inputRef: ref,
|
|
31
|
+
setInnerHandle,
|
|
32
|
+
};
|
|
33
|
+
const { value, // 代表组件值,含前后缀
|
|
34
|
+
onChange: _onChange, disabled, readOnly, validateErrorMsg, validateState, visible, layout, } = useFormInputTrait(traitProps);
|
|
35
|
+
const wrapRef = useRef(null);
|
|
36
|
+
const valueRef = useRef(value);
|
|
37
|
+
const size = useSize(props);
|
|
38
|
+
const block = usePlatform() === 'h5' ? true : _block;
|
|
39
|
+
const { classPrefix } = useConfig();
|
|
40
|
+
const startWithOnProps = useMemo(() => filterPropsWithOn(props), [props]);
|
|
41
|
+
const inputId = useMemo(() => getUuid(), []);
|
|
42
|
+
const [focus, setFocus] = useSyncValue(_focus);
|
|
43
|
+
const inputType = password ? 'password' : inputTypes[type] || type;
|
|
44
|
+
const hasClearIcon = clearable && focus && !disabled && (currentInputValue === null || currentInputValue === void 0 ? void 0 : currentInputValue.length) > 0;
|
|
45
|
+
const counter = typeof currentInputValue === 'string' ? currentInputValue.length : 0;
|
|
46
|
+
const root = `${classPrefix}-${classRoot}`;
|
|
47
|
+
const inputWrap = `${classPrefix}-form-input-wrap`;
|
|
48
|
+
const inputCls = `${classPrefix}-form-input-wrap__input`;
|
|
49
|
+
const contentCls = `${inputWrap}__content`;
|
|
50
|
+
const prefixCls = `${inputWrap}__before`;
|
|
51
|
+
const prefixIconCls = `${root}__icon-before`;
|
|
52
|
+
const suffixCls = `${inputWrap}__after`;
|
|
53
|
+
const suffixIconCls = `${root}__icon-after`;
|
|
54
|
+
const cls = classNames(inputWrap, wrapClassName, `size-width-${size} size-font-${size}`, `${root}-${classRoot}`, `size-height-${size}`, {
|
|
55
|
+
'size-width-hundred': block,
|
|
56
|
+
'is-disabled': disabled,
|
|
57
|
+
[`${inputWrap}--no-radius-left`]: before,
|
|
58
|
+
[`${inputWrap}--no-radius-right`]: after,
|
|
59
|
+
[`${inputWrap}--no-radius`]: before && after,
|
|
60
|
+
});
|
|
61
|
+
const countCls = `${classPrefix}-input__limit-number`;
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
// eslint-disable-next-line rulesdir/no-timer
|
|
64
|
+
setTimeout(() => changeForm(value));
|
|
65
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
66
|
+
}, []);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (isEqual(valueRef.current, value))
|
|
69
|
+
return; // 监听非输入引起的value变化,比如调用 setValue, clearValue
|
|
70
|
+
const currentInputValue = converInputValue(value, before, after);
|
|
71
|
+
setCurrentInputValue(currentInputValue);
|
|
72
|
+
}, [value, before, after, setCurrentInputValue]);
|
|
73
|
+
const changeForm = useCallback((val) => {
|
|
74
|
+
valueRef.current = val;
|
|
75
|
+
_onChange(val);
|
|
76
|
+
}, [_onChange]);
|
|
77
|
+
const onChange = (e) => {
|
|
78
|
+
var _a;
|
|
79
|
+
const text = typeof e === 'string' ? e : e.target.value;
|
|
80
|
+
if (maxLength > 0 && text.length > maxLength) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const reg = new RegExp(inputPattern);
|
|
84
|
+
if (inputPattern && !reg.test(text)) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
setCurrentInputValue(text);
|
|
88
|
+
const newValue = converValueFix(text, before, after, type);
|
|
89
|
+
changeForm(newValue);
|
|
90
|
+
(_a = events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: newValue }, { originEvent: e });
|
|
91
|
+
};
|
|
92
|
+
const onClear = (e) => {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
setCurrentInputValue('');
|
|
95
|
+
const newValue = converValueFix('', before, after, type);
|
|
96
|
+
changeForm(newValue);
|
|
97
|
+
(_a = events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: newValue }, { originEvent: e });
|
|
98
|
+
(_b = events.clear) === null || _b === void 0 ? void 0 : _b.call(events, { originValue: value }, { originEvent: e });
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
};
|
|
101
|
+
const onKeyDown = (e) => {
|
|
102
|
+
if (e.key === 'enter' || e.keyCode === KEY_DOWN_CODE) {
|
|
103
|
+
events.confirm({ value: converValueFix(e.target.value, before, after, type) }, { originEvent: e });
|
|
104
|
+
}
|
|
105
|
+
if (inputType === 'number' && e.key === 'e') {
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const onFocus = (e) => {
|
|
110
|
+
events.focus({ value: converValueFix(e.target.value, before, after, type) }, { originEvent: e });
|
|
111
|
+
setFocus(true);
|
|
112
|
+
};
|
|
113
|
+
const onBlur = (e) => {
|
|
114
|
+
events.blur({ value: converValueFix(e.target.value, before, after, type) }, { originEvent: e });
|
|
115
|
+
setFocus(false);
|
|
116
|
+
};
|
|
117
|
+
useImperativeHandle(ref, () => ({
|
|
118
|
+
...innerHandle,
|
|
119
|
+
name,
|
|
120
|
+
value,
|
|
121
|
+
label,
|
|
122
|
+
required,
|
|
123
|
+
visible,
|
|
124
|
+
disabled,
|
|
125
|
+
readOnly,
|
|
126
|
+
before,
|
|
127
|
+
after,
|
|
128
|
+
}), [
|
|
129
|
+
innerHandle,
|
|
130
|
+
name,
|
|
131
|
+
value,
|
|
132
|
+
label,
|
|
133
|
+
required,
|
|
134
|
+
visible,
|
|
135
|
+
disabled,
|
|
136
|
+
readOnly,
|
|
137
|
+
before,
|
|
138
|
+
after,
|
|
139
|
+
]);
|
|
140
|
+
const formItemProps = {
|
|
141
|
+
...props,
|
|
142
|
+
validateErrorMsg,
|
|
143
|
+
validateState,
|
|
144
|
+
readOnly,
|
|
145
|
+
readValue: value,
|
|
146
|
+
disabled,
|
|
147
|
+
classRoot,
|
|
148
|
+
inputId,
|
|
149
|
+
layout,
|
|
150
|
+
};
|
|
151
|
+
const inputGroupProps = { before, after, block, classRoot, size };
|
|
152
|
+
if (!visible)
|
|
153
|
+
return null;
|
|
154
|
+
return (_jsx(WdFormItem, { ...formItemProps, children: _jsx(WdInputGroup, { ...inputGroupProps, children: _jsxs("div", { className: cls, ref: wrapRef, onFocus: () => { var _a, _b; return (_b = (_a = wrapRef.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.add('is-focused'); }, onBlur: () => { var _a, _b; return (_b = (_a = wrapRef.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.remove('is-focused'); }, children: [prefixType && (_jsx("div", { className: prefixCls, children: _jsx(WdIcon, { size: size, name: prefixIcon, type: prefixType, src: prefixSrc, className: prefixIconCls }) })), _jsx("div", { className: contentCls, children: _jsx("input", { id: inputId, className: inputCls, type: inputType, placeholder: placeholder, value: currentInputValue, disabled: disabled, name: name, autoFocus: focus, autoComplete: "off", maxLength: maxLength, onChange: onChange, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, ...startWithOnProps }) }), hasClearIcon && (_jsx("div", { className: suffixCls, children: _jsx(WdIcon, { className: `${classPrefix}-icon__trigger`, name: "td:close-circle-filled", onMouseDown: onClear }) })), !hasClearIcon && suffixType && (_jsx("div", { className: suffixCls, children: _jsx(WdIcon, { size: size, name: suffixIcon, type: suffixType, src: suffixSrc, className: suffixIconCls }) })), counterVisible && (_jsxs("span", { className: countCls, children: [counter, "/", maxLength] }))] }) }) }));
|
|
155
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { useConfig } from '../../utils/config-context';
|
|
4
|
+
import { WdInput } from '../wd-input';
|
|
5
|
+
const rules = [{ format: 'email', message: '邮箱校验失败' }];
|
|
6
|
+
/**
|
|
7
|
+
* 标准化:邮箱输入组件
|
|
8
|
+
*/
|
|
9
|
+
export const WdInputEmail = forwardRef(function WdInputEmail(props, ref) {
|
|
10
|
+
const { classPrefix } = useConfig();
|
|
11
|
+
const wrapCls = `${classPrefix}-form-input-email-wrap`;
|
|
12
|
+
return (_jsx(WdInput, { ...props, ref: ref, wrapClassName: wrapCls, classRoot: "input-email", rules: rules }));
|
|
13
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import classNames from '../../utils/classnames';
|
|
3
|
+
import { useConfig } from '../../utils/config-context';
|
|
4
|
+
export const WdInputGroup = ({ before, after, className, children, }) => {
|
|
5
|
+
// 兼容旧版组件的属性值
|
|
6
|
+
const { classPrefix } = useConfig();
|
|
7
|
+
const compClassName = `${classPrefix}-form-input-group `;
|
|
8
|
+
const classList = [compClassName];
|
|
9
|
+
return (_jsxs("div", { className: classNames(...classList, className), children: [before && (_jsx("div", { className: `${classPrefix}-form-input-group__addon ${classPrefix}-form-input-group__addon-left`, children: before })), _jsx("div", { className: `${classPrefix}-form-input-group__content`, children: children }), after && (_jsx("div", { className: `${classPrefix}-form-input-group__addon ${classPrefix}-form-input-group__addon-right`, children: after }))] }));
|
|
10
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { useConfig } from '../../utils/config-context';
|
|
4
|
+
import { WdInput } from '../wd-input';
|
|
5
|
+
const rules = [{ format: 'mobile', message: '手机校验失败' }];
|
|
6
|
+
/**
|
|
7
|
+
* 标准化:电话输入组件
|
|
8
|
+
*/
|
|
9
|
+
export const WdInputPhone = forwardRef(function WdInputPhone(props, ref) {
|
|
10
|
+
const { classPrefix } = useConfig();
|
|
11
|
+
const wrapCls = `${classPrefix}-form-input-number-wrap `;
|
|
12
|
+
const pattern = '^[0-9\\-]{0,11}$';
|
|
13
|
+
return (_jsx(WdInput, { ...props, inputPattern: pattern, maxLength: 11, wrapClassName: wrapCls, classRoot: "input-phone", rules: rules, ref: ref }));
|
|
14
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { useConfig } from '../../utils/config-context';
|
|
4
|
+
import { WdInput } from '../wd-input';
|
|
5
|
+
const rules = [{ format: 'url', message: 'url校验失败' }];
|
|
6
|
+
/**
|
|
7
|
+
* 标准化:URL输入组件
|
|
8
|
+
*/
|
|
9
|
+
export const WdInputUrl = forwardRef(function WdInputUrl(props, ref) {
|
|
10
|
+
const { classPrefix } = useConfig();
|
|
11
|
+
const wrapCls = `${classPrefix}-form-input-url-wrap`;
|
|
12
|
+
return (_jsx(WdInput, { ...props, ref: ref, classRoot: "input-url", wrapClassName: wrapCls, rules: rules }));
|
|
13
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import classNames from '../../utils/classnames';
|
|
4
|
+
import { useConfig } from '../../utils/config-context';
|
|
5
|
+
// import { WdIcon } from '../index';
|
|
6
|
+
export const WdInputWrap = ({ className, children, before, after, }) => {
|
|
7
|
+
// 兼容旧版组件的属性值
|
|
8
|
+
const { classPrefix } = useConfig();
|
|
9
|
+
const compClassName = `${classPrefix}-form-input-wrap `;
|
|
10
|
+
const classList = [compClassName];
|
|
11
|
+
classList.push(className);
|
|
12
|
+
const InputWrap = React.useRef(null);
|
|
13
|
+
return (_jsxs("div", { className: classNames(...classList), ref: InputWrap, onFocus: () => {
|
|
14
|
+
InputWrap.current.classList.add('is-focused');
|
|
15
|
+
}, onBlur: () => {
|
|
16
|
+
InputWrap.current.classList.remove('is-focused');
|
|
17
|
+
}, children: [before && (_jsx("div", { className: `${classPrefix}-form-input-wrap__before`, children: before })), children && (_jsx("div", { className: `${classPrefix}-form-input-wrap__content`, children: children })), after && (_jsx("div", { className: `${classPrefix}-form-input-wrap__after`, children: after }))] }));
|
|
18
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.weda-official-account {
|
|
2
|
+
height: 106px;
|
|
3
|
+
background-color: #fff;
|
|
4
|
+
padding: 10px 15px;
|
|
5
|
+
border: 1px solid #f2f2f2;
|
|
6
|
+
border-radius: 2px;
|
|
7
|
+
}
|
|
8
|
+
.weda-official-account__title {
|
|
9
|
+
margin-bottom: 12px;
|
|
10
|
+
font-size: 12px;
|
|
11
|
+
}
|
|
12
|
+
.weda-official-account__left {
|
|
13
|
+
display: flex;
|
|
14
|
+
}
|
|
15
|
+
.weda-official-account__left__img {
|
|
16
|
+
height: 54px;
|
|
17
|
+
width: 54px;
|
|
18
|
+
border-radius: 100%;
|
|
19
|
+
margin-right: 8px;
|
|
20
|
+
}
|
|
21
|
+
.weda-official-account .weda-official-account__label {
|
|
22
|
+
font-size: 12px;
|
|
23
|
+
}
|
|
24
|
+
.weda-official-account
|
|
25
|
+
.wedatea2td-justify-grid__col--right
|
|
26
|
+
.weda-official-account__btn {
|
|
27
|
+
border-color: var(--weui-WECHAT);
|
|
28
|
+
color: var(--weui-WECHAT);
|
|
29
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* @Date: 2023-04-18 19:14:42
|
|
4
|
+
* @LastEditTime: 2023-05-04 11:54:50
|
|
5
|
+
* @Description:
|
|
6
|
+
*/
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import { Text, Justify, ConfigProvider, Bubble } from 'tea-component';
|
|
9
|
+
import classNames from '../../utils/classnames';
|
|
10
|
+
import { WdButton } from '../../components/wd-button';
|
|
11
|
+
// @ts-ignore忽略ts交验
|
|
12
|
+
// eslint-disable-next-line rulesdir/no-phantom-deps,import/no-unresolved
|
|
13
|
+
import { autorun } from 'mobx';
|
|
14
|
+
import './index.css';
|
|
15
|
+
export default function WdOfficialAccount(props) {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
const { className, id, style } = props;
|
|
18
|
+
const [editorPlatforms, setEditorPlatforms] = React.useState([]);
|
|
19
|
+
const dispose = React.useMemo(() => {
|
|
20
|
+
return autorun(() => {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
setEditorPlatforms((_b = (_a = window === null || window === void 0 ? void 0 : window.$w) === null || _a === void 0 ? void 0 : _a.wedaContext) === null || _b === void 0 ? void 0 : _b.editorPlatforms);
|
|
23
|
+
});
|
|
24
|
+
}, []);
|
|
25
|
+
React.useEffect(() => {
|
|
26
|
+
return () => {
|
|
27
|
+
dispose();
|
|
28
|
+
};
|
|
29
|
+
}, [dispose]);
|
|
30
|
+
return (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: ((_b = (_a = window.$w) === null || _a === void 0 ? void 0 : _a.wedaContext) === null || _b === void 0 ? void 0 : _b.isEditorMode) ||
|
|
31
|
+
(editorPlatforms === null || editorPlatforms === void 0 ? void 0 : editorPlatforms.includes('MP')) ? (_jsx(Bubble, { content: _jsxs(_Fragment, { children: ["\u8BF7\u53D1\u5E03\u540E\u5728\u5FAE\u4FE1\u4E2D\u67E5\u770B\u8BE5\u7EC4\u4EF6\u5B9E\u9645\u6548\u679C\uFF0C\u5F53\u524D\u7EC4\u4EF6\u4EC5\u5728\u7279\u5B9A\u5C0F\u7A0B\u5E8F\u6253\u5F00\u573A\u666F\u4E0B\u5C55\u793A\uFF0C", _jsx("br", {}), _jsx("a", { href: "https://developers.weixin.qq.com/miniprogram/dev/component/official-account.html", target: "_blank", rel: "noreferrer", children: "\u67E5\u770B\u8BF4\u660E" })] }), children: _jsxs("div", { className: classNames({
|
|
32
|
+
[className]: className,
|
|
33
|
+
'weda-ui': true,
|
|
34
|
+
'weda-official-account': true,
|
|
35
|
+
}), id: id, style: style, children: [_jsx(Text, { parent: "p", theme: "label", className: "weda-official-account__title", children: "\u67D0\u67D0\u5C0F\u7A0B\u5E8F\u5173\u8054\u7684\u516C\u4F17\u53F7" }), _jsx(Justify, { left: _jsxs("div", { className: "weda-official-account__left", children: [_jsx("img", { className: "weda-official-account__left__img", src: "https://qcloudimg.tencent-cloud.cn/raw/4a29d51b504f12b4933ce4490110b4dc.svg", alt: "" }), _jsxs("div", { children: [_jsx(Text, { reset: true, parent: "p", children: "\u516C\u4F17\u53F7\u540D\u79F0" }), _jsx(Text, { className: "weda-official-account__label", reset: true, parent: "p", theme: "label", children: "\u516C\u4F17\u53F7\u7B80\u4ECB" })] })] }), right: _jsx(WdButton, { theme: "primary", variant: "outline", style: { fontSize: '14px' }, text: "\u5173\u6CE8", size: "mini", className: "weda-official-account__btn" }) })] }) })) : null }));
|
|
36
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import classNames from '../../utils/classnames';
|
|
4
|
+
import { useConfig } from '../../utils/config-context';
|
|
5
|
+
import getLocalCounter from '../../utils/getLocalCounter';
|
|
6
|
+
export const WdRadio = ({ index, option, name, size, disabled, readOnly, checkedItemValue, getChangeHandler, }) => {
|
|
7
|
+
const { classPrefix } = useConfig();
|
|
8
|
+
const { label, value: optionValue } = option;
|
|
9
|
+
// 类名
|
|
10
|
+
const classList = [];
|
|
11
|
+
switch (size) {
|
|
12
|
+
case 'sm':
|
|
13
|
+
classList.push(`size-sm `);
|
|
14
|
+
break;
|
|
15
|
+
case 'md':
|
|
16
|
+
classList.push(`size-md `);
|
|
17
|
+
break;
|
|
18
|
+
case 'lg':
|
|
19
|
+
classList.push(`size-lg `);
|
|
20
|
+
break;
|
|
21
|
+
default:
|
|
22
|
+
classList.push();
|
|
23
|
+
}
|
|
24
|
+
// 现在低码组件往源码组件传入的id不唯一, 暂时使用hashcode替代
|
|
25
|
+
const hashcode = useMemo(() => getLocalCounter(), []);
|
|
26
|
+
const _id = `radio-${hashcode}-${index}`;
|
|
27
|
+
const _name = `radio-${hashcode}-${name}`;
|
|
28
|
+
const NUMBER_1 = 1;
|
|
29
|
+
return (_jsxs("label", { className: `${classPrefix}-radio-wrap ${classNames(classList)} ${`${checkedItemValue}` === `${optionValue}` ? 'is-checked' : ''} ${disabled || readOnly ? 'is-disabled' : ''} ${'radio' + (index + NUMBER_1)}`, onClick: getChangeHandler(optionValue), children: [_jsx("input", { className: `${classPrefix}-radio-input `, id: _id, name: _name, type: "radio", value: optionValue, disabled: disabled || readOnly, checked: `${checkedItemValue}` === `${optionValue}`, onChange: (e) => e.stopPropagation(), onClick: (e) => e.stopPropagation() }), _jsx("span", { className: `${classPrefix}-radio-inner ` }), label && _jsx("span", { className: `${classPrefix}-radio-label`, children: label })] }));
|
|
30
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createElement as _createElement } from "react";
|
|
3
|
+
import React, { useState, useEffect } from 'react';
|
|
4
|
+
import classNames from '../../utils/classnames';
|
|
5
|
+
import { useConfig } from '../../utils/config-context';
|
|
6
|
+
import { WdRadio } from '../index';
|
|
7
|
+
import { WdFormItem } from '../wd-form-item';
|
|
8
|
+
import { emptyObject } from '../../utils/constant';
|
|
9
|
+
import { usePlatform } from '../../utils/platform';
|
|
10
|
+
import { useSize } from '../../utils/hooks/useFormLegacy';
|
|
11
|
+
import { useFormInputTrait } from '../form-input-hooks';
|
|
12
|
+
import { callWedaApi } from '../../utils/tcb';
|
|
13
|
+
import destr from 'destr';
|
|
14
|
+
export const WdRadioList = React.forwardRef(function WdRadioList(props, inputRef) {
|
|
15
|
+
const { range, direction, events = emptyObject, format = '', enumName = '', label, } = props;
|
|
16
|
+
const size = useSize(props);
|
|
17
|
+
const [innerHandle, setInnerHandle] = React.useState({}); // hook里挂出的属性
|
|
18
|
+
/** 兼容从 Form 获取属性,必须引入,自动挂载组件方法 */
|
|
19
|
+
const traitProps = { ...props, inputRef, setInnerHandle };
|
|
20
|
+
const { value: defaultValue, onChange: outerOnChange, disabled, readOnly, validateErrorMsg, validateState, visible, name, value, required, layout, } = useFormInputTrait(traitProps);
|
|
21
|
+
const [options, setOptions] = React.useState(format === 'x-enum' ? [] : range);
|
|
22
|
+
const [checkedItemValue, setCheckedItemValue] = useState(defaultValue);
|
|
23
|
+
const { classPrefix } = useConfig();
|
|
24
|
+
const platform = usePlatform();
|
|
25
|
+
const compClassName = `${classPrefix}-radio-group `;
|
|
26
|
+
// 类名
|
|
27
|
+
const classList = [compClassName];
|
|
28
|
+
['inline'].includes(direction) &&
|
|
29
|
+
classList.push(`${classPrefix}-radio-group--inner `);
|
|
30
|
+
/**
|
|
31
|
+
* 在ios h5端, label和input的绑定不生效
|
|
32
|
+
* 导致 onChange 事件触发有问题, 所以改为监听 onClick 事件
|
|
33
|
+
*/
|
|
34
|
+
const getChangeHandler = function (value) {
|
|
35
|
+
const onChange = function (e) {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
e.stopPropagation();
|
|
38
|
+
if (!disabled && !readOnly) {
|
|
39
|
+
if (checkedItemValue && `${checkedItemValue}` === `${value}`) {
|
|
40
|
+
setCheckedItemValue('');
|
|
41
|
+
(_a = events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: '' }, { originEvent: e });
|
|
42
|
+
outerOnChange === null || outerOnChange === void 0 ? void 0 : outerOnChange('');
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
setCheckedItemValue(value);
|
|
46
|
+
(_b = events.change) === null || _b === void 0 ? void 0 : _b.call(events, { value }, { originEvent: e });
|
|
47
|
+
outerOnChange === null || outerOnChange === void 0 ? void 0 : outerOnChange(value);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
return onChange;
|
|
52
|
+
};
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
setCheckedItemValue(defaultValue);
|
|
55
|
+
}, [defaultValue, options]);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (format !== 'x-enum') {
|
|
58
|
+
setOptions(range);
|
|
59
|
+
}
|
|
60
|
+
}, [range, format]);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
// 如果绑定字段类型为枚举,且传入自定义选项集的名称则默认使用自定义选项集的内容作为选项
|
|
63
|
+
if (format === 'x-enum' && enumName) {
|
|
64
|
+
fetchData({ OptNameList: [enumName], PageIndex: 1, PageSize: 10 });
|
|
65
|
+
}
|
|
66
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
67
|
+
}, []);
|
|
68
|
+
React.useImperativeHandle(inputRef, () => ({
|
|
69
|
+
...innerHandle,
|
|
70
|
+
name,
|
|
71
|
+
value,
|
|
72
|
+
label,
|
|
73
|
+
required,
|
|
74
|
+
visible,
|
|
75
|
+
disabled,
|
|
76
|
+
readOnly,
|
|
77
|
+
}), [innerHandle, name, value, label, required, visible, disabled, readOnly]);
|
|
78
|
+
const fetchData = async (param) => {
|
|
79
|
+
var _a, _b, _c;
|
|
80
|
+
const data = await callWedaApi({
|
|
81
|
+
action: 'DescribeGeneralOptionsDetailList',
|
|
82
|
+
data: param,
|
|
83
|
+
});
|
|
84
|
+
const config = (_c = destr((_b = (_a = data === null || data === void 0 ? void 0 : data.Items) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.Config)) !== null && _c !== void 0 ? _c : [];
|
|
85
|
+
const enumOption = config.map((item) => {
|
|
86
|
+
return {
|
|
87
|
+
label: item.value,
|
|
88
|
+
value: item.key,
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
setOptions(enumOption);
|
|
92
|
+
};
|
|
93
|
+
const labelSize = () => {
|
|
94
|
+
if (['h5'].includes(platform) ||
|
|
95
|
+
(['horizontal', ''].includes(layout) &&
|
|
96
|
+
['vertical'].includes(direction))) {
|
|
97
|
+
return 'xs';
|
|
98
|
+
}
|
|
99
|
+
return size;
|
|
100
|
+
};
|
|
101
|
+
return (visible && (_jsx(WdFormItem, { ...props, testId: "form-radio-group", validateErrorMsg: validateErrorMsg, validateState: validateState, readValue: defaultValue, disabled: disabled, classRoot: 'radio', size: labelSize(), layout: layout, children: _jsx("div", { className: classNames(classList), children: options === null || options === void 0 ? void 0 : options.map((Item, Index) => {
|
|
102
|
+
return (_createElement(WdRadio, { ...props, key: Index, index: Index, size: ['h5'].includes(platform) ? 'lg' : props === null || props === void 0 ? void 0 : props.size, option: Item, disabled: disabled, readOnly: readOnly, getChangeHandler: getChangeHandler, checkedItemValue: checkedItemValue }));
|
|
103
|
+
}) }) })));
|
|
104
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import classNames from '../../utils/classnames';
|
|
4
|
+
import { useConfig } from '../../utils/config-context';
|
|
5
|
+
import { usePlatform } from '../../utils/platform';
|
|
6
|
+
import { WdFormItem } from '../wd-form-item';
|
|
7
|
+
import getLocalCounter from '../../utils/getLocalCounter';
|
|
8
|
+
import { useSyncValue } from '../../utils/hooks/useSyncValue';
|
|
9
|
+
import { emptyObject } from '../../utils/constant';
|
|
10
|
+
import { useFormInputTrait } from '../form-input-hooks';
|
|
11
|
+
import { useSize } from '../../utils/hooks/useFormLegacy';
|
|
12
|
+
export const WdSwitch = React.forwardRef(function FormSwitch(props, inputRef) {
|
|
13
|
+
const {
|
|
14
|
+
// 系统属性
|
|
15
|
+
name, label, events = emptyObject, } = props;
|
|
16
|
+
const size = useSize(props);
|
|
17
|
+
const [innerHandle, setInnerHandle] = React.useState({}); // hook里挂出的属性
|
|
18
|
+
/** 兼容从 Form 获取属性,必须引入,自动挂载组件方法 */
|
|
19
|
+
const traitProps = { ...props, inputRef, setInnerHandle };
|
|
20
|
+
const { value: defaultChecked, onChange: outerOnChange, disabled, readOnly, validateErrorMsg, validateState, visible, value, required, layout, } = useFormInputTrait(traitProps);
|
|
21
|
+
const [checked, setChecked] = useSyncValue(defaultChecked);
|
|
22
|
+
const { classPrefix } = useConfig();
|
|
23
|
+
const platform = usePlatform();
|
|
24
|
+
// 现在低码组件往源码组件传入的id不唯一, 暂时使用hashcode替代
|
|
25
|
+
const hashcode = getLocalCounter();
|
|
26
|
+
const _id = `switch-${hashcode}`;
|
|
27
|
+
const switchCls = classNames({
|
|
28
|
+
'is-checked': checked,
|
|
29
|
+
'is-disabled': disabled || readOnly,
|
|
30
|
+
'size-sm': !['h5'].includes(platform) && ['sm'].includes(size),
|
|
31
|
+
'size-md': !['h5'].includes(platform) && ['md'].includes(size),
|
|
32
|
+
'size-lg': ['h5'].includes(platform) || ['lg'].includes(size),
|
|
33
|
+
});
|
|
34
|
+
React.useImperativeHandle(inputRef, () => ({
|
|
35
|
+
...innerHandle,
|
|
36
|
+
name,
|
|
37
|
+
value,
|
|
38
|
+
label,
|
|
39
|
+
required,
|
|
40
|
+
visible,
|
|
41
|
+
disabled,
|
|
42
|
+
readOnly,
|
|
43
|
+
}), [innerHandle, name, value, label, required, visible, disabled, readOnly]);
|
|
44
|
+
const onChange = (ev) => {
|
|
45
|
+
var _a;
|
|
46
|
+
const value = ev.target.checked;
|
|
47
|
+
setChecked(value);
|
|
48
|
+
outerOnChange === null || outerOnChange === void 0 ? void 0 : outerOnChange(value);
|
|
49
|
+
(_a = events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value }, { orgianalEvent: ev });
|
|
50
|
+
};
|
|
51
|
+
return (visible && (_jsx(WdFormItem, { ...props, testId: "form-switch", validateErrorMsg: validateErrorMsg, validateState: validateState, readValue: defaultChecked, classRoot: 'switch', disabled: disabled, layout: layout, children: _jsxs("label", { className: `${classPrefix}-switch ${switchCls}`, htmlFor: _id, children: [_jsx("input", { id: _id, name: name, className: `${classPrefix}-switch__input `, type: "checkbox", checked: checked, disabled: disabled || readOnly, onChange: onChange }), _jsx("div", { className: `${classPrefix}-switch__box` })] }, _id) })));
|
|
52
|
+
});
|
|
@@ -4,7 +4,7 @@ import { Icon, Table, StatusTip, ConfigProvider } from 'tea-component';
|
|
|
4
4
|
import { useResizeObserver } from '@react-hookz/web';
|
|
5
5
|
import { useConfig } from '../../../../utils/config-context';
|
|
6
6
|
import { isInIde } from '../../../../utils/platform';
|
|
7
|
-
const { sortable, radioable, selectable, injectable, pageable, autotip, scrollable, } = Table.addons;
|
|
7
|
+
const { sortable, radioable, selectable, injectable, pageable, autotip, scrollable, columnsResizable, } = Table.addons;
|
|
8
8
|
import StatusContent from '../../../statusContent';
|
|
9
9
|
import classNames from '../../../../utils/classnames';
|
|
10
10
|
import { setTableHeaderStyle } from './util';
|
|
@@ -16,7 +16,7 @@ const miniPageSize = 10;
|
|
|
16
16
|
const tableHeight = { sm: 500, md: 580, lg: 880 };
|
|
17
17
|
const tableHeaderHeight = 51;
|
|
18
18
|
// eslint-disable-next-line complexity
|
|
19
|
-
export const BaseTableCom = ({ recordKey, className, columns, records, sortColumns, sort, onSelectChange, selectedKeys, rowColor, isError, isLoading, queryParams, total = defaultTotal, refreshTable, onQueryChange, enablePagination, columnSelectType, defaultPageSize, defaultPageIndex, rowClick, currentSize, isNoDataSourceBind, isH5, emptyText: _emptyText, }) => {
|
|
19
|
+
export const BaseTableCom = ({ recordKey, className, columns, setColumns, records, sortColumns, sort, onSelectChange, selectedKeys, rowColor, isError, isLoading, queryParams, total = defaultTotal, refreshTable, onQueryChange, enablePagination, columnSelectType, defaultPageSize, defaultPageIndex, rowClick, currentSize, isNoDataSourceBind, isH5, emptyText: _emptyText, }) => {
|
|
20
20
|
var _a;
|
|
21
21
|
const tableRef = useRef(null);
|
|
22
22
|
const { classPrefix } = useConfig();
|
|
@@ -71,6 +71,16 @@ export const BaseTableCom = ({ recordKey, className, columns, records, sortColum
|
|
|
71
71
|
}),
|
|
72
72
|
}),
|
|
73
73
|
];
|
|
74
|
+
// 仅运行态可编辑
|
|
75
|
+
if (!isInIde()) {
|
|
76
|
+
tableAddons.push(columnsResizable({
|
|
77
|
+
onResizeEnd: (columns) => {
|
|
78
|
+
setColumns(columns);
|
|
79
|
+
},
|
|
80
|
+
minWidth: 92,
|
|
81
|
+
maxWidth: 1000,
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
74
84
|
// 支撑分页的最大高度
|
|
75
85
|
const tableDomHeight = (_a = tableRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight;
|
|
76
86
|
// 支持表格滚动,高度超过 500 开始显示滚动条
|
|
@@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from 'react';
|
|
|
2
2
|
import { getQueryParams } from '../utils';
|
|
3
3
|
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
4
4
|
// const defaultCount = 1;
|
|
5
|
-
export const useQueryParams = ({ queryParams, wList, viewFieldsData, connectorParams, isModel, isViewTable, events, }) => {
|
|
5
|
+
export const useQueryParams = ({ queryParams, wList, viewFieldsData, connectorParams, isModel, isViewTable, events, columns, }) => {
|
|
6
6
|
const queryRef = useRef({});
|
|
7
7
|
const [query, setQuery] = useState(() => {
|
|
8
8
|
return getQueryParams({
|
|
@@ -12,6 +12,7 @@ export const useQueryParams = ({ queryParams, wList, viewFieldsData, connectorPa
|
|
|
12
12
|
connectorParams,
|
|
13
13
|
isModel,
|
|
14
14
|
isViewTable,
|
|
15
|
+
columns,
|
|
15
16
|
});
|
|
16
17
|
});
|
|
17
18
|
useEffect(() => {
|
|
@@ -23,6 +24,7 @@ export const useQueryParams = ({ queryParams, wList, viewFieldsData, connectorPa
|
|
|
23
24
|
connectorParams,
|
|
24
25
|
isModel,
|
|
25
26
|
isViewTable,
|
|
27
|
+
columns,
|
|
26
28
|
});
|
|
27
29
|
if (!isObjectEqual(queryRef.current, query)) {
|
|
28
30
|
queryRef.current = query;
|
|
@@ -36,6 +38,7 @@ export const useQueryParams = ({ queryParams, wList, viewFieldsData, connectorPa
|
|
|
36
38
|
queryParams,
|
|
37
39
|
viewFieldsData,
|
|
38
40
|
wList,
|
|
41
|
+
columns,
|
|
39
42
|
]);
|
|
40
43
|
return { query };
|
|
41
44
|
};
|
|
@@ -86,8 +86,8 @@ export const whereList = (whereProxy) => {
|
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
// 获取最终的查询参数
|
|
89
|
-
export const getQueryParams = ({ queryParams, wList, viewFieldsData, connectorParams, isModel, isViewTable, }) => {
|
|
90
|
-
var _a, _b;
|
|
89
|
+
export const getQueryParams = ({ queryParams, wList, viewFieldsData, connectorParams, isModel, isViewTable, columns, }) => {
|
|
90
|
+
var _a, _b, _c;
|
|
91
91
|
const _defaultPageSize = 10;
|
|
92
92
|
const _defaultPageIndex = 1;
|
|
93
93
|
const { pageIndex: pageNo, pageSize, sort } = queryParams;
|
|
@@ -125,6 +125,10 @@ export const getQueryParams = ({ queryParams, wList, viewFieldsData, connectorPa
|
|
|
125
125
|
// 运行态主动排序进行覆盖
|
|
126
126
|
if ((sort === null || sort === void 0 ? void 0 : sort.length) && sort[0].order) {
|
|
127
127
|
params.orderBy = sort[0].by;
|
|
128
|
+
// 后端根据业务字段排序
|
|
129
|
+
params.orderBy =
|
|
130
|
+
((_c = columns === null || columns === void 0 ? void 0 : columns.find((i) => params.orderBy === i.slotKey)) === null || _c === void 0 ? void 0 : _c.fieldKey) ||
|
|
131
|
+
params.orderBy;
|
|
128
132
|
params.orderType = sort[0].order;
|
|
129
133
|
}
|
|
130
134
|
const _pageSize = parseInt(`${params.pageSize}`);
|