@cloudbase/weda-ui 3.4.11 → 3.4.13
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/customer-service.js +3 -0
- package/dist/configs/components/dataView.js +20 -10
- package/dist/configs/components/form-checkbox.js +15 -2
- package/dist/configs/components/form-date.js +1 -1
- package/dist/configs/components/form-depart-tree-select.js +1 -1
- package/dist/configs/components/form-email.js +17 -2
- package/dist/configs/components/form-input.js +17 -2
- package/dist/configs/components/form-location.js +1 -1
- package/dist/configs/components/form-multi-region.js +1 -1
- package/dist/configs/components/form-phone.js +17 -2
- package/dist/configs/components/form-radio.js +15 -2
- package/dist/configs/components/form-rich-text.js +1 -1
- package/dist/configs/components/form-select-multiple.js +362 -0
- package/dist/configs/components/form-select.js +1 -1
- package/dist/configs/components/form-switch.js +16 -3
- package/dist/configs/components/form-text-area.js +15 -2
- package/dist/configs/components/form-time.js +1 -1
- package/dist/configs/components/form-url.js +17 -2
- package/dist/configs/components/form-user-tree-select.js +14 -1
- 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-button.js +3 -0
- 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 +11 -59
- package/dist/configs/components/wd-textarea.js +82 -0
- package/dist/configs/components/wd-tree.js +443 -0
- package/dist/configs/components/web-view.js +3 -0
- package/dist/configs/index.js +24 -1
- package/dist/configs/type-utils/type-form.js +681 -0
- package/dist/docs/common/components/json-schema-view.js +1 -1
- 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/actions/showMessage/index.js +4 -1
- package/dist/web/components/carousel/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 +90 -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/select/dropdown-select/index.js +9 -3
- package/dist/web/components/form/select/h5.js +18 -8
- package/dist/web/components/form/select/index.js +9 -10
- 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 +60 -62
- package/dist/web/components/form/uploader/uploader.pc.js +48 -41
- package/dist/web/components/form/uploaderFile/uploadFile.h5.js +8 -33
- package/dist/web/components/form/uploaderFile/uploadFile.pc.js +8 -37
- package/dist/web/components/form/userOrgSelect/common/fetch-data-service.js +76 -50
- package/dist/web/components/form/userOrgSelect/common/utils.js +24 -8
- package/dist/web/components/form/userOrgSelect/component/depart-select/depart-select-pc.js +3 -8
- package/dist/web/components/form/userOrgSelect/component/depart-select/index.js +14 -18
- package/dist/web/components/form/userOrgSelect/component/depart-select/org-modal-pc.js +20 -14
- package/dist/web/components/form/userOrgSelect/component/modal-select-h5.js +1 -1
- package/dist/web/components/form/userOrgSelect/component/org-tree.js +21 -9
- package/dist/web/components/form/userOrgSelect/component/user-select-h5/index.js +76 -15
- package/dist/web/components/form/userOrgSelect/component/user-select-pc/user-model.js +2 -7
- package/dist/web/components/form/userOrgSelect/component/user-select-pc/user-select-pc.js +6 -4
- package/dist/web/components/form/userOrgSelect/component/userOrgSelect.css +8 -2
- package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.js +25 -51
- package/dist/web/components/form/userOrgSelect/hooks/use-depart-data.js +10 -6
- package/dist/web/components/form-input-hooks/index.js +41 -15
- package/dist/web/components/form-select-multiple/index.js +26 -0
- package/dist/web/components/form-upload-file/index.js +0 -1
- package/dist/web/components/form-user-tree-select/index.js +2 -2
- package/dist/web/components/formdetail/index.css +31 -1
- package/dist/web/components/formdetail/index.js +33 -1
- package/dist/web/components/index.js +27 -11
- package/dist/web/components/listView/index.js +20 -5
- package/dist/web/components/navigationBar/common.js +1 -1
- package/dist/web/components/navigationBar/horizontalMenu.js +1 -1
- package/dist/web/components/navigationBar/index.css +11 -0
- package/dist/web/components/navigationBar/index.js +8 -1
- package/dist/web/components/phone/index.js +26 -1
- package/dist/web/components/phoneCode/index.js +3 -1
- 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/table/ImportFileModalByApi/uploadCSVFile.js +1 -1
- 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/hooks/use-remote-value.js +9 -2
- package/dist/web/components/wd-form/index.js +69 -34
- 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-icon/wd-icon.js +10 -2
- 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/FieldRender/index.js +5 -4
- package/dist/web/components/wd-table/components/FilterFieldsPanel/FilterFieldItem.js +4 -0
- package/dist/web/components/wd-table/components/Table/index.js +40 -9
- package/dist/web/components/wd-table/hooks/useQueryParams.js +4 -1
- package/dist/web/components/wd-table/hooks/useTableData.js +6 -1
- package/dist/web/components/wd-table/hooks/useViewFields.js +1 -1
- package/dist/web/components/wd-table/utils/index.js +6 -2
- package/dist/web/components/wd-table/wd-table.js +125 -99
- 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/date.js +3 -3
- package/dist/web/utils/hooks/useFormLegacy.js +112 -0
- package/dist/web/utils/tool.js +12 -2
- package/dist/web/weda-ui.css +197 -3
- package/package.json +6 -5
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useImperativeHandle, useRef, useEffect, useState, useMemo, } from 'react';
|
|
3
|
+
import classNames from '../../utils/classnames';
|
|
4
|
+
import { useConfig } from '../../utils/config-context';
|
|
5
|
+
import { WdFormItem } from '../wd-form-item';
|
|
6
|
+
import { FORM_MAX_LENGTH } from '../../utils/constant';
|
|
7
|
+
import { useFormInputTrait } from '../form-input-hooks';
|
|
8
|
+
import { filterPropsWithOn, getUuid } from '../../utils/tool';
|
|
9
|
+
import { useSize } from '../../utils/hooks/useFormLegacy';
|
|
10
|
+
import { usePlatform } from '../../utils/platform';
|
|
11
|
+
/**
|
|
12
|
+
* 标准化:多行输入组件
|
|
13
|
+
*/
|
|
14
|
+
export const WdTextarea = forwardRef(function WdTextarea(props, ref) {
|
|
15
|
+
const { name, placeholder = '请输入', counterVisible = true, focus = false, maxLength = FORM_MAX_LENGTH, events, block: _block, classRoot = 'textarea', label, required, } = props;
|
|
16
|
+
/** 兼容从 Form 获取属性,必须引入,自动挂载组件方法 */
|
|
17
|
+
const [innerHandle, setInnerHandle] = useState({});
|
|
18
|
+
const traitProps = { ...props, setInnerHandle, inputRef: ref };
|
|
19
|
+
const { value, onChange: onChangeForm, disabled, readOnly, validateErrorMsg, validateState, visible, layout, } = useFormInputTrait(traitProps);
|
|
20
|
+
const block = usePlatform() === 'h5' ? true : _block;
|
|
21
|
+
const { classPrefix } = useConfig();
|
|
22
|
+
const startWithOnProps = useMemo(() => filterPropsWithOn(props), [props]);
|
|
23
|
+
const inputId = useMemo(() => getUuid(), []);
|
|
24
|
+
const size = useSize(props);
|
|
25
|
+
const textareaRef = useRef(null);
|
|
26
|
+
const counter = typeof value === 'string' ? value.length : 0;
|
|
27
|
+
const wrapRef = useRef(null);
|
|
28
|
+
const root = `${classPrefix}-${classRoot}`;
|
|
29
|
+
const inputWrap = `${classPrefix}-form-input-wrap`;
|
|
30
|
+
const textareaWrap = `${classPrefix}-form-textarea-wrap`;
|
|
31
|
+
const cls = classNames(inputWrap, textareaWrap, `${root}-${classRoot}`, `size-width-${size}`, `size-font-${size}`, {
|
|
32
|
+
'size-width-hundred': block,
|
|
33
|
+
'is-disabled': disabled,
|
|
34
|
+
'textarea-restriction': counterVisible,
|
|
35
|
+
});
|
|
36
|
+
const countCls = `${textareaWrap}__label ${root}-${classRoot}__count-text`;
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
autoScroll();
|
|
39
|
+
}, []);
|
|
40
|
+
// 输入自动滚动
|
|
41
|
+
const autoScroll = function () {
|
|
42
|
+
if (!textareaRef.current)
|
|
43
|
+
return;
|
|
44
|
+
textareaRef.current.style.height = 'auto';
|
|
45
|
+
if (textareaRef.current.scrollHeight >= textareaRef.current.offsetHeight) {
|
|
46
|
+
textareaRef.current.style.height =
|
|
47
|
+
textareaRef.current.scrollHeight + 'px';
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
/** 内部事件 */
|
|
51
|
+
const onChange = function (e) {
|
|
52
|
+
var _a;
|
|
53
|
+
autoScroll();
|
|
54
|
+
const text = typeof e === 'string' ? e : e.target.value;
|
|
55
|
+
onChangeForm(text);
|
|
56
|
+
(_a = events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: text }, { originEvent: e });
|
|
57
|
+
};
|
|
58
|
+
const onFocus = function (e) {
|
|
59
|
+
var _a;
|
|
60
|
+
(_a = events.focus) === null || _a === void 0 ? void 0 : _a.call(events, { value: e.target.value }, { originEvent: e });
|
|
61
|
+
};
|
|
62
|
+
const onBlur = function (e) {
|
|
63
|
+
var _a;
|
|
64
|
+
(_a = events.blur) === null || _a === void 0 ? void 0 : _a.call(events, { value: e.target.value }, { originEvent: e });
|
|
65
|
+
};
|
|
66
|
+
/** widgets */
|
|
67
|
+
useImperativeHandle(ref, () => ({
|
|
68
|
+
...innerHandle,
|
|
69
|
+
name,
|
|
70
|
+
value,
|
|
71
|
+
label,
|
|
72
|
+
required,
|
|
73
|
+
visible,
|
|
74
|
+
disabled,
|
|
75
|
+
readOnly,
|
|
76
|
+
}), [innerHandle, name, value, label, required, visible, disabled, readOnly]);
|
|
77
|
+
return (visible && (_jsx(WdFormItem, { ...props, validateErrorMsg: validateErrorMsg, validateState: validateState, readOnly: readOnly, disabled: disabled, readValue: value, classRoot: classRoot, inputId: inputId, layout: layout, children: _jsxs("div", { className: cls, ref: wrapRef, onFocus: () => wrapRef.current.classList.add('is-focused'), onBlur: () => wrapRef.current.classList.remove('is-focused'), children: [_jsx("textarea", { id: inputId, ref: textareaRef, rows: 2, placeholder: placeholder, name: name, value: value, maxLength: maxLength, autoFocus: focus, disabled: disabled, readOnly: readOnly, onChange: onChange, onFocus: onFocus, onBlur: onBlur, ...startWithOnProps }), counterVisible && (_jsxs("label", { className: countCls, children: [counter, "/", maxLength] }))] }) })));
|
|
78
|
+
});
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/* eslint-disable max-lines */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
3
|
+
import { deepClone } from '../../utils/tool';
|
|
4
|
+
const TREE_INFO_GOT = [
|
|
5
|
+
{ key: 'value', infoKey: 'selected', alias: 'selected' },
|
|
6
|
+
{ key: 'value', infoKey: 'selected', alias: 'selectedPositions', aim: 'pos' },
|
|
7
|
+
{ key: 'value', infoKey: 'selected', alias: 'selectedNodes', aim: 'root' },
|
|
8
|
+
{ key: 'isExpand', value: true, alias: 'expanded' },
|
|
9
|
+
{ key: 'isExpand', value: true, alias: 'expandedPositions', aim: 'pos' },
|
|
10
|
+
{ key: 'isExpand', value: true, alias: 'expandedNodes', aim: 'root' },
|
|
11
|
+
{ key: 'searched', value: 'searched' },
|
|
12
|
+
{
|
|
13
|
+
key: 'searched',
|
|
14
|
+
value: 'searched',
|
|
15
|
+
alias: 'searchedPositions',
|
|
16
|
+
aim: 'pos',
|
|
17
|
+
},
|
|
18
|
+
{ key: 'searched', value: 'searched', alias: 'searchedNodes', aim: 'root' },
|
|
19
|
+
{ key: 'checked', value: 'checked' },
|
|
20
|
+
{ key: 'checked', value: 'checked', alias: 'checkedPositions', aim: 'pos' },
|
|
21
|
+
{ key: 'checked', value: 'checked', alias: 'checkedNodes', aim: 'root' },
|
|
22
|
+
{ key: 'checked', value: 'childChecked', alias: 'childChecked' },
|
|
23
|
+
{
|
|
24
|
+
key: 'checked',
|
|
25
|
+
value: 'childChecked',
|
|
26
|
+
alias: 'childCheckedPositions',
|
|
27
|
+
aim: 'pos',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
key: 'checked',
|
|
31
|
+
value: 'childChecked',
|
|
32
|
+
alias: 'childCheckedNodes',
|
|
33
|
+
aim: 'root',
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
/**
|
|
37
|
+
* 仅根据初始值判断当前节点的展开状态
|
|
38
|
+
* @param treeNode 当前节点
|
|
39
|
+
* @param expandType 节点展开类型
|
|
40
|
+
* @param expandCustom 自定义要展开的节点
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
const judgeExpand = (treeNode, expandType, expandCustom) => {
|
|
44
|
+
if (!expandType)
|
|
45
|
+
return treeNode.expanded || '';
|
|
46
|
+
if (expandType === 'all')
|
|
47
|
+
return 'expand';
|
|
48
|
+
if (expandType !== 'none') {
|
|
49
|
+
return (expandCustom === null || expandCustom === void 0 ? void 0 : expandCustom.includes(treeNode.value)) ? 'expand' : '';
|
|
50
|
+
}
|
|
51
|
+
return '';
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* 仅根据搜索关键字判断节点是否被搜索到
|
|
55
|
+
* @param treeNode 当前节点
|
|
56
|
+
* @param searchKey 关键字
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
const judgeSearch = (treeNode, searchKey) => {
|
|
60
|
+
var _a;
|
|
61
|
+
return searchKey && ((_a = treeNode.label) === null || _a === void 0 ? void 0 : _a.includes(searchKey)) ? 'searched' : '';
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* 仅根据初始值判断是否选中
|
|
65
|
+
* @param treeNode 当前节点
|
|
66
|
+
* @param checkedCustom 自定义选中的节点
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
const judgeCheck = (treeNode, checkedCustom) => {
|
|
70
|
+
if (!(checkedCustom === null || checkedCustom === void 0 ? void 0 : checkedCustom.length))
|
|
71
|
+
return treeNode.checked || '';
|
|
72
|
+
return checkedCustom.includes(treeNode.value) ? 'checked' : '';
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* 根据初始值获取用于组件展示的数据
|
|
76
|
+
* @param {IInitData} param0
|
|
77
|
+
* @returns
|
|
78
|
+
*/
|
|
79
|
+
const initData = ({ data, parent, showIcon, expendIcon, foldIcon, leafIcon, pos = '', }) => {
|
|
80
|
+
if (!Array.isArray(data))
|
|
81
|
+
return [];
|
|
82
|
+
return data
|
|
83
|
+
.filter((item) => item === null || item === void 0 ? void 0 : item.value)
|
|
84
|
+
.map((item, index) => {
|
|
85
|
+
var _a;
|
|
86
|
+
item.pos = `${pos ? `${pos}-` : ''}${index}`;
|
|
87
|
+
item.root = item.root || { ...deepClone(item), pos: item.pos };
|
|
88
|
+
if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
89
|
+
item.children = initData({
|
|
90
|
+
data: item.children,
|
|
91
|
+
parent: item,
|
|
92
|
+
showIcon,
|
|
93
|
+
expendIcon,
|
|
94
|
+
foldIcon,
|
|
95
|
+
leafIcon,
|
|
96
|
+
pos: item.pos,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
item.expendIcon = item.expendIcon || expendIcon;
|
|
100
|
+
item.foldIcon = item.foldIcon || foldIcon;
|
|
101
|
+
item.leafIcon = item.leafIcon || leafIcon;
|
|
102
|
+
item.showIcon = showIcon;
|
|
103
|
+
item.parent = parent;
|
|
104
|
+
return item;
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* 根据子节点的状态处理父节点的相关状态,如选中、展开
|
|
109
|
+
* @param {IGetStateOfChildrenParams} param0
|
|
110
|
+
* @returns
|
|
111
|
+
*/
|
|
112
|
+
const getStateOfChildren = ({ treeNode, key, state, }) => {
|
|
113
|
+
var _a, _b, _c;
|
|
114
|
+
const notHas = (_a = treeNode.children) === null || _a === void 0 ? void 0 : _a.map((v) => v[key]).includes(state.notHas);
|
|
115
|
+
const has = (_b = treeNode.children) === null || _b === void 0 ? void 0 : _b.map((v) => v[key]).includes(state.has);
|
|
116
|
+
const childHas = (_c = treeNode.children) === null || _c === void 0 ? void 0 : _c.map((v) => v[key]).includes(state.childHas);
|
|
117
|
+
if (notHas && !has && !childHas) {
|
|
118
|
+
return state.notHas;
|
|
119
|
+
}
|
|
120
|
+
else if (has && !notHas && !childHas) {
|
|
121
|
+
return state.has;
|
|
122
|
+
}
|
|
123
|
+
return state.childHas;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* 处理节点的搜索状态
|
|
127
|
+
* @param treeNode 节点
|
|
128
|
+
* @returns
|
|
129
|
+
*/
|
|
130
|
+
const getSearched = (treeNode) => getStateOfChildren({
|
|
131
|
+
treeNode,
|
|
132
|
+
key: 'searched',
|
|
133
|
+
state: {
|
|
134
|
+
notHas: '',
|
|
135
|
+
has: 'searched',
|
|
136
|
+
childHas: 'childSearched',
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
/**
|
|
140
|
+
* 处理节点的展开状态
|
|
141
|
+
* @param treeNode 节点
|
|
142
|
+
* @returns
|
|
143
|
+
*/
|
|
144
|
+
const getExpand = (treeNode) => getStateOfChildren({
|
|
145
|
+
treeNode,
|
|
146
|
+
key: 'expanded',
|
|
147
|
+
state: {
|
|
148
|
+
notHas: '',
|
|
149
|
+
has: 'expand',
|
|
150
|
+
childHas: 'childExpand',
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
/**
|
|
154
|
+
* 处理节点的选中状态
|
|
155
|
+
* @param treeNode 节点
|
|
156
|
+
* @returns
|
|
157
|
+
*/
|
|
158
|
+
const getChecked = (treeNode) => getStateOfChildren({
|
|
159
|
+
treeNode,
|
|
160
|
+
key: 'checked',
|
|
161
|
+
state: {
|
|
162
|
+
notHas: '',
|
|
163
|
+
has: 'checked',
|
|
164
|
+
childHas: 'childChecked',
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
/**
|
|
168
|
+
* 初始化节点状态
|
|
169
|
+
* @param param0
|
|
170
|
+
* @returns
|
|
171
|
+
*/
|
|
172
|
+
const initTreeState = ({ data, checkedCustom, expandType, expandCustom, searchKey = '', parentChecked = '', }) => {
|
|
173
|
+
if (!Array.isArray(data))
|
|
174
|
+
return [];
|
|
175
|
+
return data.map((item) => {
|
|
176
|
+
var _a, _b, _c;
|
|
177
|
+
const currentChecked = parentChecked || judgeCheck(item, checkedCustom);
|
|
178
|
+
const currentSearched = judgeSearch(item, searchKey);
|
|
179
|
+
const currentExpand = judgeExpand(item, expandType, expandCustom);
|
|
180
|
+
if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
181
|
+
item.children = initTreeState({
|
|
182
|
+
data: item.children,
|
|
183
|
+
checkedCustom,
|
|
184
|
+
expandType,
|
|
185
|
+
expandCustom,
|
|
186
|
+
searchKey,
|
|
187
|
+
parentChecked: currentChecked === 'checked' ? 'checked' : '', // 只有父节点选中才去操作子节点选中
|
|
188
|
+
});
|
|
189
|
+
item.checked = currentChecked || getChecked(item);
|
|
190
|
+
item.searched = currentSearched || getSearched(item);
|
|
191
|
+
item.expanded = currentExpand || getExpand(item);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
item.checked = currentChecked || judgeCheck(item, checkedCustom);
|
|
195
|
+
item.searched = currentSearched;
|
|
196
|
+
item.expanded = item.searched ? 'expand' : '';
|
|
197
|
+
}
|
|
198
|
+
// 被搜索到的或根据输入判断需要展开的都认为要展开
|
|
199
|
+
item.isExpand =
|
|
200
|
+
!!((_b = item.children) === null || _b === void 0 ? void 0 : _b.length) &&
|
|
201
|
+
(searchKey ? !!item.searched : !!item.expanded);
|
|
202
|
+
if (item.showIcon) {
|
|
203
|
+
if ((_c = item.children) === null || _c === void 0 ? void 0 : _c.length) {
|
|
204
|
+
item.iconShow = item.isExpand ? item.expendIcon : item.foldIcon;
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
item.iconShow = item.leafIcon;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return item;
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* 当某节点的选择状态变化时,处理该节点的父和子的选择状态
|
|
215
|
+
* @param treeNode
|
|
216
|
+
*/
|
|
217
|
+
const dealCheck = (treeNode) => {
|
|
218
|
+
var _a;
|
|
219
|
+
let parent = treeNode.parent;
|
|
220
|
+
const adjust = (arr, checked) => {
|
|
221
|
+
arr.forEach((item) => {
|
|
222
|
+
var _a;
|
|
223
|
+
item.checked = checked;
|
|
224
|
+
if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
225
|
+
adjust(item.children, item.checked);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
while (parent) {
|
|
230
|
+
parent.checked = getChecked(parent);
|
|
231
|
+
parent = parent.parent;
|
|
232
|
+
}
|
|
233
|
+
if ((_a = treeNode.children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
234
|
+
adjust(treeNode.children, treeNode.checked);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* 查找满足要求的节点
|
|
239
|
+
* @param tree 树
|
|
240
|
+
* @param condition 需要获取的内容
|
|
241
|
+
* @returns
|
|
242
|
+
*/
|
|
243
|
+
const findNode = (params) => {
|
|
244
|
+
const { tree, info, condition } = params;
|
|
245
|
+
const list = {};
|
|
246
|
+
tree.forEach((item) => {
|
|
247
|
+
var _a;
|
|
248
|
+
let childList = {};
|
|
249
|
+
if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
250
|
+
childList = findNode({ tree: item.children, info, condition });
|
|
251
|
+
}
|
|
252
|
+
condition.forEach((v) => {
|
|
253
|
+
var _a;
|
|
254
|
+
const { key, value, alias, aim, infoKey } = v;
|
|
255
|
+
const k = alias || key;
|
|
256
|
+
const aimValue = infoKey ? info[infoKey] : value;
|
|
257
|
+
if (!list[k])
|
|
258
|
+
list[k] = [];
|
|
259
|
+
if (item[key] === aimValue) {
|
|
260
|
+
list[k].push(item[aim || 'value']);
|
|
261
|
+
}
|
|
262
|
+
if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
263
|
+
list[k] = [...new Set([...list[k], ...childList[k]])];
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
return list;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* 根据checkable状态获取树信息
|
|
271
|
+
* @param params
|
|
272
|
+
* @param checkable
|
|
273
|
+
* @returns
|
|
274
|
+
*/
|
|
275
|
+
const getTreeInfo = (params, checkable) => {
|
|
276
|
+
const info = findNode(params);
|
|
277
|
+
// 如果未开启多选,则将点击状态覆盖选中状态
|
|
278
|
+
if (!checkable) {
|
|
279
|
+
info.checked = info.selected;
|
|
280
|
+
info.checkedNodes = info.selectedNodes;
|
|
281
|
+
info.checkedPositions = info.selectedPositions;
|
|
282
|
+
info.childChecked = [];
|
|
283
|
+
info.childCheckedNodes = [];
|
|
284
|
+
info.childCheckedPositions = [];
|
|
285
|
+
}
|
|
286
|
+
delete info.selected;
|
|
287
|
+
delete info.selectedNodes;
|
|
288
|
+
delete info.selectedPositions;
|
|
289
|
+
return info;
|
|
290
|
+
};
|
|
291
|
+
export { TREE_INFO_GOT, initData, initTreeState, dealCheck, findNode, getTreeInfo, };
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable max-lines */
|
|
3
|
+
import { forwardRef, useImperativeHandle, useEffect, useState, useCallback, } from 'react';
|
|
4
|
+
import classNames from '../../utils/classnames';
|
|
5
|
+
import { useConfig } from '../../utils/config-context';
|
|
6
|
+
import { usePlatform } from '../../utils/platform';
|
|
7
|
+
import WdCheckbox from '../wd-checkbox';
|
|
8
|
+
import WdIcon from '../wd-icon';
|
|
9
|
+
import { TREE_INFO_GOT, initData, initTreeState, dealCheck, getTreeInfo, } from './utils';
|
|
10
|
+
import { deepClone } from '../../utils/tool';
|
|
11
|
+
export const WdTree = forwardRef(function WdTree(props, ref) {
|
|
12
|
+
var _a;
|
|
13
|
+
const { className = '', style, id, events, data, checkable, checkedCustom, expandType, expandCustom, showIcon, foldIcon, expendIcon, leafIcon, line, } = props;
|
|
14
|
+
const platform = usePlatform();
|
|
15
|
+
// 样式
|
|
16
|
+
const { classPrefix } = useConfig();
|
|
17
|
+
// 响应式css api
|
|
18
|
+
const platformCss = `${classPrefix}-${platform}-tree`;
|
|
19
|
+
const classes = {
|
|
20
|
+
[`${classPrefix}-tree`]: true,
|
|
21
|
+
[platformCss]: true,
|
|
22
|
+
[`${classPrefix}-tree--line`]: props.line,
|
|
23
|
+
};
|
|
24
|
+
const nodeClassName = `${classPrefix}-tree-node`;
|
|
25
|
+
// 组件内树节点初始化
|
|
26
|
+
const [showData, setShowData] = useState([]);
|
|
27
|
+
const [treeInfo, setTreeInfo] = useState({});
|
|
28
|
+
// 点击的节点
|
|
29
|
+
const [selected, setSelected] = useState(((_a = props.checkedCustom) === null || _a === void 0 ? void 0 : _a.length) ? props.checkedCustom[0] : '');
|
|
30
|
+
// 搜索内容
|
|
31
|
+
const [searchKey, setSearchKey] = useState('');
|
|
32
|
+
/**
|
|
33
|
+
* 组件搜索节点方法
|
|
34
|
+
*/
|
|
35
|
+
const searchNode = useCallback(({ searchKey = '' } = {}) => {
|
|
36
|
+
setSearchKey(searchKey || '');
|
|
37
|
+
setShowData(initTreeState({
|
|
38
|
+
data: showData,
|
|
39
|
+
checkedCustom: [],
|
|
40
|
+
expandType: '',
|
|
41
|
+
expandCustom: [],
|
|
42
|
+
searchKey,
|
|
43
|
+
}));
|
|
44
|
+
}, [showData]);
|
|
45
|
+
// Widget API,挂载组件只读属性和组件方法
|
|
46
|
+
useImperativeHandle(ref, () => {
|
|
47
|
+
return {
|
|
48
|
+
methods: {
|
|
49
|
+
searchNode,
|
|
50
|
+
},
|
|
51
|
+
treeInfo,
|
|
52
|
+
data,
|
|
53
|
+
checkable,
|
|
54
|
+
checkedCustom,
|
|
55
|
+
expandType,
|
|
56
|
+
expandCustom,
|
|
57
|
+
showIcon,
|
|
58
|
+
foldIcon,
|
|
59
|
+
expendIcon,
|
|
60
|
+
leafIcon,
|
|
61
|
+
line,
|
|
62
|
+
};
|
|
63
|
+
}, [
|
|
64
|
+
checkable,
|
|
65
|
+
checkedCustom,
|
|
66
|
+
data,
|
|
67
|
+
expandCustom,
|
|
68
|
+
expandType,
|
|
69
|
+
expendIcon,
|
|
70
|
+
foldIcon,
|
|
71
|
+
leafIcon,
|
|
72
|
+
line,
|
|
73
|
+
searchNode,
|
|
74
|
+
showIcon,
|
|
75
|
+
treeInfo,
|
|
76
|
+
]);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
var _a;
|
|
79
|
+
const aimData = initTreeState({
|
|
80
|
+
data: initData({
|
|
81
|
+
data: deepClone(props.data),
|
|
82
|
+
parent: null,
|
|
83
|
+
showIcon: props.showIcon,
|
|
84
|
+
expendIcon: props.expendIcon,
|
|
85
|
+
foldIcon: props.foldIcon,
|
|
86
|
+
leafIcon: props.leafIcon,
|
|
87
|
+
}),
|
|
88
|
+
checkedCustom: props.checkedCustom,
|
|
89
|
+
expandType: props.expandType || 'all',
|
|
90
|
+
expandCustom: props.expandCustom,
|
|
91
|
+
});
|
|
92
|
+
setShowData(aimData);
|
|
93
|
+
const selected = ((_a = props.checkedCustom) === null || _a === void 0 ? void 0 : _a.length) ? props.checkedCustom[0] : '';
|
|
94
|
+
setTreeInfo({
|
|
95
|
+
event: 'init',
|
|
96
|
+
currentNode: [],
|
|
97
|
+
...getTreeInfo({ tree: aimData, info: { selected }, condition: TREE_INFO_GOT }, props.checkable),
|
|
98
|
+
});
|
|
99
|
+
setSelected(selected);
|
|
100
|
+
}, [props.data, props.checkedCustom, props.expandCustom, props.expandType, props.showIcon, props.expendIcon, props.foldIcon, props.leafIcon, props.checkable]);
|
|
101
|
+
/**
|
|
102
|
+
* 节点变化,check:选中节点改变,select:点击节点,expand:节点展开/折叠
|
|
103
|
+
* @param treeNode
|
|
104
|
+
* @param event
|
|
105
|
+
* @param state 改变的状态
|
|
106
|
+
*/
|
|
107
|
+
const change = (treeNode, event, state) => {
|
|
108
|
+
var _a;
|
|
109
|
+
if (treeNode.disabled && event !== 'expand')
|
|
110
|
+
return;
|
|
111
|
+
// 开启多选属性时, 点击节点事件去掉, 变成check事件
|
|
112
|
+
if (event === 'select' && props.checkable) {
|
|
113
|
+
event = 'check';
|
|
114
|
+
state = treeNode.checked !== 'checked';
|
|
115
|
+
}
|
|
116
|
+
const eventKey = {
|
|
117
|
+
check: 'selectNodeChange',
|
|
118
|
+
select: 'selectNodeChange',
|
|
119
|
+
expand: 'nodeExpandChange',
|
|
120
|
+
}[event];
|
|
121
|
+
let selectedKey = selected;
|
|
122
|
+
// 不同类型要执行的操作
|
|
123
|
+
const typeFunc = {
|
|
124
|
+
check: () => {
|
|
125
|
+
treeNode.checked = state ? 'checked' : '';
|
|
126
|
+
// 处理节点的父/子节点选中状态
|
|
127
|
+
dealCheck(treeNode);
|
|
128
|
+
},
|
|
129
|
+
select: () => {
|
|
130
|
+
state = selectedKey !== treeNode.value;
|
|
131
|
+
selectedKey = state ? treeNode.value : '';
|
|
132
|
+
setSelected(selectedKey);
|
|
133
|
+
},
|
|
134
|
+
expand: () => {
|
|
135
|
+
var _a;
|
|
136
|
+
treeNode.isExpand = state;
|
|
137
|
+
treeNode.expanded = state ? 'expand' : '';
|
|
138
|
+
if (treeNode.iconShow && ((_a = treeNode.children) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
139
|
+
treeNode.iconShow = state ? treeNode.expendIcon : treeNode.foldIcon;
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
}[event];
|
|
143
|
+
typeFunc === null || typeFunc === void 0 ? void 0 : typeFunc();
|
|
144
|
+
const info = {
|
|
145
|
+
event,
|
|
146
|
+
currentNode: [treeNode.root],
|
|
147
|
+
[`${event}State`]: state,
|
|
148
|
+
...getTreeInfo({
|
|
149
|
+
tree: showData,
|
|
150
|
+
info: { selected: selectedKey },
|
|
151
|
+
condition: TREE_INFO_GOT,
|
|
152
|
+
}, props.checkable),
|
|
153
|
+
};
|
|
154
|
+
(_a = events[eventKey]) === null || _a === void 0 ? void 0 : _a.call(events, info);
|
|
155
|
+
// events.change?.(info);
|
|
156
|
+
setTreeInfo(info);
|
|
157
|
+
event !== 'select' && setShowData([...showData]);
|
|
158
|
+
};
|
|
159
|
+
const list = [];
|
|
160
|
+
const renderNode = (d, count) => {
|
|
161
|
+
if (!Array.isArray(d))
|
|
162
|
+
return [];
|
|
163
|
+
// @ts-ignore const 会报错,应该是let
|
|
164
|
+
count = count || 0;
|
|
165
|
+
const STEP = 1;
|
|
166
|
+
d.filter((item) => item === null || item === void 0 ? void 0 : item.value).forEach((item, index) => {
|
|
167
|
+
var _a;
|
|
168
|
+
const subTree = ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) > 0 ? item.children : undefined;
|
|
169
|
+
const spaceDom = [];
|
|
170
|
+
const disableStyle = item.disabled
|
|
171
|
+
? { cursor: 'not-allowed', color: 'rgba(0,0,0,.26)' }
|
|
172
|
+
: {};
|
|
173
|
+
for (let i = 0; i < count; i++) {
|
|
174
|
+
spaceDom.push(_jsx("span", { className: `${classPrefix}-tree__space` }, Math.random()));
|
|
175
|
+
}
|
|
176
|
+
list.push(_jsxs("div", {
|
|
177
|
+
// 叶子节点 加 `${classPrefix}-tree-node--leaf` 为了连线的时候,对横线特殊处理
|
|
178
|
+
// 选中态,加 is-selected
|
|
179
|
+
className: `${nodeClassName} ${subTree ? '' : `${classPrefix}-tree-node--leaf`} ${selected === item.value && !props.checkable ? 'is-selected' : ''}`, "data-testid": nodeClassName, children: [spaceDom, _jsx("div", { className: `${classPrefix}-tree__switcher`, onClick: () => change(item, 'expand', !item.isExpand), children: subTree && (
|
|
180
|
+
// 展开/收起的图标
|
|
181
|
+
_jsx(WdIcon, { className: `${classPrefix}-tree__switcher-icon`, name: item.isExpand ? 'td:caret-down-small' : 'td:caret-right-small' })) }), _jsxs("div", { className: `${classPrefix}-tree__label`, onClick: () => change(item, 'select'), children: [props.checkable && (_jsx(WdCheckbox, { index: index + count, option: { value: item.value }, isAll: item.checked === 'childChecked', size: "md", disabled: item.disabled, getChangeHandler: () => {
|
|
182
|
+
if (item.disabled)
|
|
183
|
+
return;
|
|
184
|
+
change(item, 'check', item.checked !== 'checked');
|
|
185
|
+
}, checkedItemValue: { [item.value]: item.checked === 'checked' }, ...{} })), item.iconShow && (_jsx(WdIcon, { "data-testid": "wd-tree-icon-test", className: `${classPrefix}-tree__label-icon `, name: item.iconShow, src: item.iconShow, type: item.iconShow.startsWith('http') ? 'custom' : 'inner' })), _jsx("label", { className: `${classPrefix}-tree__label-text`, htmlFor: "", style: disableStyle, children: searchKey
|
|
186
|
+
? item.label.split(searchKey).map((v, i) => (_jsxs("span", { children: [i !== 0 && (_jsx("span", { className: `${classPrefix}-tree__label-text-search`, children: searchKey })), v] }, i)))
|
|
187
|
+
: item.label })] })] }, item.value));
|
|
188
|
+
subTree && item.isExpand && renderNode(subTree, count + STEP);
|
|
189
|
+
});
|
|
190
|
+
return list;
|
|
191
|
+
};
|
|
192
|
+
return (_jsx("div", { id: id, style: style, className: classNames(classes, className), "data-testid": "wd-tree-test", children: renderNode(showData, 0) }));
|
|
193
|
+
});
|
|
@@ -5,6 +5,20 @@ export const TitleType = {
|
|
|
5
5
|
NONE: 'none',
|
|
6
6
|
};
|
|
7
7
|
export const LOAD_ERR_IMG_BASE64 = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgdmlld0JveD0iMCAwIDMyIDMyIiBmaWxsPSJub25lIj4KICA8cGF0aCBkPSJNMjUuMzIgMTYuMzU5N0MyNi4wNzY0IDE2LjM1OTcgMjYuODI1NCAxNi41MDg3IDI3LjUyNDMgMTYuNzk4MUMyOC4yMjMxIDE3LjA4NzYgMjguODU4MSAxNy41MTE5IDI5LjM5MjkgMTguMDQ2OEMyOS45Mjc4IDE4LjU4MTYgMzAuMzUyMSAxOS4yMTY2IDMwLjY0MTYgMTkuOTE1NEMzMC45MzEgMjAuNjE0MyAzMS4wOCAyMS4zNjMzIDMxLjA4IDIyLjExOTdDMzEuMDggMjIuODc2MSAzMC45MzEgMjMuNjI1MSAzMC42NDE2IDI0LjMyMzlDMzAuMzUyMSAyNS4wMjI4IDI5LjkyNzggMjUuNjU3OCAyOS4zOTI5IDI2LjE5MjZDMjguODU4MSAyNi43Mjc1IDI4LjIyMzEgMjcuMTUxOCAyNy41MjQzIDI3LjQ0MTJDMjYuODI1NCAyNy43MzA3IDI2LjA3NjQgMjcuODc5NyAyNS4zMiAyNy44Nzk3QzIzLjc5MjQgMjcuODc5NyAyMi4zMjczIDI3LjI3MjggMjEuMjQ3MSAyNi4xOTI2QzIwLjE2NjkgMjUuMTEyNCAxOS41NiAyMy42NDczIDE5LjU2IDIyLjExOTdDMTkuNTYgMjAuNTkyIDIwLjE2NjkgMTkuMTI3IDIxLjI0NzEgMTguMDQ2OEMyMi4zMjczIDE2Ljk2NjUgMjMuNzkyNCAxNi4zNTk3IDI1LjMyIDE2LjM1OTdaTTI4IDMuNTU5NjlWMTQuODc2OEMyNy4xNzc3IDE0LjU4NjYgMjYuMTkyIDE0LjQzODggMjUuMzIgMTQuNDM5N0MyNC4wMzEgMTQuNDM5NyAyMi44MTU3IDE0Ljc1NzEgMjEuNzQ4OCAxNS4zMTg0TDIwLjc5NTIgMTMuMTU5N0wxNi4wMjU5IDIwLjAyNzVMOC40NDU3NiAxNi40NDFMMy41NiAyMy4zOTk3SDE3Ljc0NjJDMTcuOTg2NyAyNC44MjkgMTguNjI4MiAyNi4xNjA2IDE5LjU5NTggMjcuMjM5N0gxVjMuNTU5NjlIMjhaTTI1Ljk2IDI0LjAzOTdIMjQuNjhWMjUuMzE5N0gyNS45NlYyNC4wMzk3Wk0yNS45NiAxOC45MTk3SDI0LjY4VjIzLjM5OTdIMjUuOTZWMTguOTE5N1pNNi4xMiAxMC41OTk3QzYuMTIgMTEuOTk4MSA3LjE5OTA0IDEzLjEwODUgOC42MDc2OCAxMy4xNTg0QzEwLjAyMDggMTMuMjA3NyAxMS4yNCAxMi4wNDggMTEuMjQgMTAuNTk5N0MxMS4yNCA5LjI0NjA5IDEwLjA2NDMgOC4wODU3NyA4Ljc1MjMyIDguMDQwOTdDNy4yOTU2OCA3Ljk5MTY5IDYuMTIgOS4xNTEzNyA2LjEyIDEwLjU5OTdaIiBmaWxsPSIjQkNDNEQwIj48L3BhdGg+Cjwvc3ZnPgo=';
|
|
8
|
+
export const RICH_TEXT_ICON_PACK = {
|
|
9
|
+
mathFormula: '<svg class="icon" style="vertical-align:middle" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" fill="currentColor" overflow="hidden"><path d="M552 566l54-54-54-54-261-261h551v-77l-660 1v76l316 315-316 316v75l660 1v-77H291l261-261"></path></svg>',
|
|
10
|
+
leftTextAlign: '<svg style="width:16px;height:16px" viewBox="0 0 512 512" fill="currentColor"><path d="M384 106.666c11.782 0 21.334 9.552 21.334 21.334 0 10.94-8.236 19.958-18.846 21.19l-2.488 0.143h-277.334c-11.782 0-21.334-9.552-21.334-21.334 0-10.941 8.236-19.957 18.846-21.19l2.488-0.144h277.334z" ></path><path d="M277.334 234.667c11.782 0 21.334 9.552 21.334 21.333 0 10.94-8.236 19.957-18.846 21.19l-2.488 0.144h-170.667c-11.782 0-21.334-9.551-21.334-21.334 0-10.94 8.236-19.958 18.846-21.19l2.488-0.143h170.667z"></path><path d="M384 362.666c11.782 0 21.334 9.551 21.334 21.334 0 10.94-8.236 19.957-18.846 21.19l-2.488 0.144h-277.334c-11.782 0-21.334-9.551-21.334-21.334 0-10.94 8.236-19.957 18.846-21.19l2.488-0.144h277.334z"></path></svg>',
|
|
11
|
+
centerTextAlign: '<svg style="width:16px;height:16px" viewBox="0 0 512 512" fill="currentColor"><path d="M384 106.666c11.782 0 21.334 9.552 21.334 21.334 0 10.94-8.236 19.958-18.846 21.19l-2.488 0.143h-277.334c-11.782 0-21.334-9.552-21.334-21.334 0-10.941 8.236-19.957 18.846-21.19l2.488-0.144h277.334z"></path><path d="M330.666 234.667c11.782 0 21.334 9.552 21.334 21.333 0 10.94-8.236 19.957-18.846 21.19l-2.488 0.144h-170.667c-11.782 0-21.333-9.551-21.333-21.334 0-10.94 8.236-19.958 18.846-21.19l2.488-0.143h170.667z"></path><path d="M384 362.666c11.782 0 21.334 9.551 21.334 21.334 0 10.94-8.236 19.957-18.846 21.19l-2.488 0.144h-277.334c-11.782 0-21.334-9.551-21.334-21.334 0-10.94 8.236-19.957 18.846-21.19l2.488-0.144h277.334z"></path></svg>',
|
|
12
|
+
rightTextAlign: '<svg style="width:16px;height:16px" viewBox="0 0 512 512" fill="currentColor"><path d="M384 106.666c11.782 0 21.334 9.552 21.334 21.334 0 10.94-8.236 19.958-18.846 21.19l-2.488 0.143h-277.334c-11.782 0-21.334-9.552-21.334-21.334 0-10.941 8.236-19.957 18.846-21.19l2.488-0.144h277.334z"></path><path d="M384 234.667c11.782 0 21.334 9.552 21.334 21.333 0 10.94-8.236 19.957-18.846 21.19l-2.488 0.144h-170.667c-11.782 0-21.333-9.551-21.333-21.334 0-10.94 8.236-19.958 18.846-21.19l2.488-0.143h170.666z"></path><path d="M384 362.666c11.782 0 21.334 9.551 21.334 21.334 0 10.94-8.236 19.957-18.846 21.19l-2.488 0.144h-277.334c-11.782 0-21.334-9.551-21.334-21.334 0-10.94 8.236-19.957 18.846-21.19l2.488-0.144h277.334z"></path></svg>',
|
|
13
|
+
justifyTextAlign: '<svg style="width:16px;height:16px" viewBox="0 0 512 512" fill="currentColor"><path d="M384 106.666c11.782 0 21.334 9.552 21.334 21.334 0 10.94-8.236 19.958-18.846 21.19l-2.488 0.143h-277.334c-11.782 0-21.334-9.552-21.334-21.334 0-10.941 8.236-19.957 18.846-21.19l2.488-0.144h277.334z"></path><path d="M384 234.667c11.782 0 21.334 9.552 21.334 21.334 0 10.94-8.236 19.958-18.846 21.19l-2.488 0.143h-277.334c-11.782 0-21.334-9.552-21.334-21.334 0-10.941 8.236-19.957 18.846-21.19l2.488-0.144h277.334z"></path><path d="M384 362.666c11.782 0 21.334 9.551 21.334 21.334 0 10.94-8.236 19.957-18.846 21.19l-2.488 0.144h-277.334c-11.782 0-21.334-9.551-21.334-21.334 0-10.94 8.236-19.957 18.846-21.19l2.488-0.144h277.334z"></path></svg>',
|
|
14
|
+
textIndent: '<svg style="width:20px;height:20px" fill="currentColor" viewBox="0 0 24 24" style="transform: scale(1.25)"><path d="M5 17v1.25h14V17H5zm11-8v6l3-3-3-3zM5 13.25v1.25h9v-1.25H5zM5 9.5v1.25h9V9.5H5zm0-3.75V7h14V5.75H5z"></path></svg>',
|
|
15
|
+
heading: '<svg style="width:18px;height:18px" viewBox="0 0 512 512"><path transform="translate(80 20)" fill="currentColor" d="M286 85c11 0 20 9 21 19v280a21 21 0 0 1-42 2V267H85v117a21 21 0 0 1-42 2V107a21 21 0 0 1 42-3v120h180V107c0-12 9-22 21-22z"></path></svg>',
|
|
16
|
+
marginTop: '<svg style="width:18px;height:18px" fill="currentColor" viewBox="0 0 512 512"><path d="M106.666 292.607h280.448c11.782 0 21.334-9.551 21.334-21.334s-9.551-21.334-21.334-21.334h-280.448c-11.782 0-21.334 9.551-21.334 21.334s9.552 21.334 21.334 21.334z"></path><path d="M106.666 420.607h280.448c11.782 0 21.334-9.551 21.334-21.334s-9.551-21.334-21.334-21.334h-280.448c-11.782 0-21.334 9.551-21.334 21.334s9.552 21.334 21.334 21.334z"></path><path d="M232.697 114.138l-36.906 58.304c-6.315 9.963 1.578 22.422 14.186 22.422h73.835c12.608 0 20.502-12.458 14.208-22.422l-36.928-58.304c-6.315-9.963-22.080-9.963-28.394 0z"></path></svg>',
|
|
17
|
+
marginBottom: '<svg style="width:18px;height:18px" fill="currentColor" viewBox="0 0 512 512"><path d="M387.115 245.333h-280.448c-11.782 0-21.334 9.552-21.334 21.333s9.552 21.334 21.334 21.334h280.448c11.782 0 21.334-9.551 21.334-21.334s-9.551-21.334-21.334-21.334z"></path><path d="M387.115 117.334h-280.448c-11.782 0-21.334 9.552-21.334 21.334s9.552 21.333 21.334 21.333h280.448c11.782 0 21.334-9.552 21.334-21.334s-9.551-21.334-21.334-21.334z"></path><path d="M261.092 423.801l36.906-58.304c6.315-9.962-1.579-22.421-14.208-22.421h-73.814c-12.63 0-20.501 12.459-14.208 22.421l36.906 58.304c6.315 9.962 22.101 9.962 28.416 0z"></path></svg>',
|
|
18
|
+
marginSide: '<svg style="width:18px;height:18px" fill="currentColor" viewBox="0 0 24 24" style="transform:scale(1.125)"><path d="M5 5.8c0-.5.3-.8.7-.8h14.5a.8.8 0 0 1 0 1.5H5.7a.8.8 0 0 1-.7-.8Z"></path><path d="M9 14.8c0-.5.3-.8.7-.8h6.5a.8.8 0 0 1 0 1.5H9.7a.8.8 0 0 1-.7-.8Z"></path><path d="M9 9.8c0-.5.3-.8.7-.8h6.5a.8.8 0 0 1 0 1.5H9.7a.8.8 0 0 1-.7-.8Z"></path><path d="M5 18.8c0-.5.3-.8.7-.8h14.5a.8.8 0 0 1 0 1.5H5.7a.8.8 0 0 1-.7-.8Z"></path><path d="M5.5 14.5c-.2.2-.5 0-.5-.2V9.7c0-.2.3-.4.5-.2l2.3 2.3v.4l-2.3 2.3Z"></path><path d="M20.5 14.5c.2.2.5 0 .5-.2V9.7c0-.2-.3-.4-.5-.2l-2.3 2.3c-.1.1-.1.3 0 .4l2.3 2.3Z"></path></svg>',
|
|
19
|
+
lineSpace: '<svg style="width:18px;height:18px" viewBox="0 0 24 24" fill="currentColor" style="transform:scale(1.1)"><path fill-rule="evenodd" clip-rule="evenodd" d="M5 5.3c0-.5.3-.8.7-.8h14.5a.8.8 0 0 1 0 1.5H5.7a.8.8 0 0 1-.7-.8Zm7 9c0-.5.3-.8.7-.8h7.5a.8.8 0 0 1 0 1.5h-7.5a.8.8 0 0 1-.7-.8Zm0-4.5c0-.5.3-.8.7-.8h7.5a.8.8 0 0 1 0 1.5h-7.5a.8.8 0 0 1-.7-.8Zm-7 9c0-.5.3-.8.7-.8h14.5a.8.8 0 0 1 0 1.5H5.7a.8.8 0 0 1-.7-.8Zm5.3-8.8c.3.1.1.5-.1.5H5.8a.3.3 0 0 1-.2-.5l2.2-1.8c.1-.1.3-.1.4 0l2.1 1.8Zm0 4c.3-.1.1-.5-.1-.5H5.8c-.3 0-.4.4-.2.5l2.2 1.8c.1.1.3.1.4 0l2.1-1.8Z"></path></svg>',
|
|
20
|
+
wordSpace: '<svg style="width:18px;height:18px" viewBox="0 0 24 24" fill="none" style="transform: scale(1.1)"><path fill-rule="evenodd" clip-rule="evenodd" d="M9.75 13.25C9.33579 13.25 9 12.9142 9 12.5C9 12.0858 9.33579 11.75 9.75 11.75H15.25C15.6642 11.75 16 12.0858 16 12.5C16 12.9142 15.6642 13.25 15.25 13.25H9.75Z" fill="currentColor"></path><path d="M7.5 17L11.8719 6.42009C11.9769 6.16584 12.2249 6 12.5 6V6C12.7751 6 13.0231 6.16584 13.1281 6.42009L17.5 17" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M4.25 4.20001C4.66421 4.20001 5 4.5358 5 4.95001L5 18.95C5 19.3642 4.66421 19.7 4.25 19.7C3.83579 19.7 3.5 19.3642 3.5 18.95L3.5 4.95001C3.5 4.5358 3.83579 4.20001 4.25 4.20001Z" fill="currentColor"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M20.75 4.20001C21.1642 4.20001 21.5 4.5358 21.5 4.95001L21.5 18.95C21.5 19.3642 21.1642 19.7 20.75 19.7C20.3358 19.7 20 19.3642 20 18.95L20 4.95001C20 4.5358 20.3358 4.20001 20.75 4.20001Z" fill="currentColor"></path></svg>',
|
|
21
|
+
};
|
|
8
22
|
export const REL_DICT = {
|
|
9
23
|
equal: 'eq',
|
|
10
24
|
unequal: 'neq',
|
|
@@ -117,3 +131,5 @@ export const TABLE_SLOT_PREFIX = 'cell_';
|
|
|
117
131
|
export const CELL_CUSTOM_OPTION = 'cell__custom__option';
|
|
118
132
|
// 表格全局按钮插槽名称
|
|
119
133
|
export const GLOBAL_BUTTON = 'globalButton';
|
|
134
|
+
export const FORM_MAX_LENGTH = 140;
|
|
135
|
+
export const KEY_DOWN_CODE = 13;
|
|
@@ -110,7 +110,7 @@ export class DataSource {
|
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
export const getDataSourceByName = async (dbName, GetColumnAuth =
|
|
113
|
+
export const getDataSourceByName = async (dbName, GetColumnAuth = true) => {
|
|
114
114
|
var _a, _b;
|
|
115
115
|
try {
|
|
116
116
|
// dbName 为空时
|
|
@@ -124,7 +124,7 @@ export const getDataSourceByName = async (dbName, GetColumnAuth = false) => {
|
|
|
124
124
|
return getDataSourceByNameCompatibleProvite(dbName);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
const datasource = await window.app.cloud.getDataSourceProfileAsync(GetColumnAuth ? { Name: dbName, GetColumnAuth: true } : dbName);
|
|
127
|
+
const datasource = await window.app.cloud.getDataSourceProfileAsync(GetColumnAuth ? { Name: dbName, GetColumnAuth: true } : { Name: dbName });
|
|
128
128
|
return datasource;
|
|
129
129
|
}
|
|
130
130
|
catch (error) {
|
package/dist/web/utils/date.js
CHANGED
|
@@ -73,10 +73,10 @@ export const formatDateToNumber = (dateType = 'date', t = '') => {
|
|
|
73
73
|
*/
|
|
74
74
|
export const dateCalculation = ({ key, val, rel }, filterType) => {
|
|
75
75
|
const dateSearchvalue = [];
|
|
76
|
-
// 1.
|
|
77
|
-
// 2.
|
|
76
|
+
// 1.datetime日期时间查询精确到秒,换算成毫秒时间戳存储,区间相隔一秒
|
|
77
|
+
// 2.date日期查询精确到日,日期换算成毫秒时间戳存储,区间相隔一日 86400000(未满1日,86399999)
|
|
78
78
|
// 3.time时间查询精确到毫秒,换算成毫秒存储,区间相隔一秒
|
|
79
|
-
const endTime = filterType === 'date' ?
|
|
79
|
+
const endTime = filterType === 'date' ? 86399999 : 999;
|
|
80
80
|
switch (rel) {
|
|
81
81
|
case 'eq':
|
|
82
82
|
dateSearchvalue.push({
|