@cloudbase/weda-ui 3.18.8 → 3.20.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/lottery.d.ts +2 -0
- package/dist/configs/components/lottery.js +6 -1
- package/dist/configs/components/wd-checkbox.js +4 -0
- package/dist/configs/components/wd-form.d.ts +2 -2
- package/dist/configs/components/wd-form.js +2 -3
- package/dist/configs/components/wd-image.js +1 -0
- package/dist/configs/components/wd-radio.js +4 -0
- package/dist/configs/components/wd-table.d.ts +19 -3
- package/dist/configs/components/wd-table.js +16 -0
- package/dist/configs/components/wd-tree.d.ts +33 -0
- package/dist/configs/components/wd-tree.js +58 -0
- package/dist/configs/index.d.ts +66 -6
- package/dist/configs/type-utils/type-form.d.ts +2 -2
- package/dist/configs/type-utils/type-form.js +4 -0
- package/dist/style/index.css +2 -1
- package/dist/style/index.scss +1 -1
- package/dist/style/weda-ui.min.css +2 -2
- package/dist/web/components/customer-service/customer-service.js +4 -3
- package/dist/web/components/form-input-hooks/index.d.ts +3 -1
- package/dist/web/components/form-input-hooks/index.js +93 -54
- package/dist/web/components/form-rich-text/index.d.ts +1 -1
- package/dist/web/components/form-rich-text/index.js +6 -2
- package/dist/web/components/formdetail/index.d.ts +1 -1
- package/dist/web/components/formdetail/index.js +28 -42
- package/dist/web/components/lottery/index.d.ts +1 -0
- package/dist/web/components/lottery/index.js +19 -47
- package/dist/web/components/lottery/lotteryUtil.d.ts +1 -1
- package/dist/web/components/lottery/lotteryUtil.js +4 -5
- package/dist/web/components/richText/index.js +9 -3
- package/dist/web/components/wd-form/contexts/form-field-arr-context.d.ts +21 -0
- package/dist/web/components/wd-form/contexts/form-field-arr-context.js +10 -0
- package/dist/web/components/wd-form/contexts/form-field-context.d.ts +19 -0
- package/dist/web/components/wd-form/contexts/form-field-context.js +10 -0
- package/dist/web/components/wd-form/contexts/form-field-obj-context.d.ts +13 -0
- package/dist/web/components/wd-form/contexts/form-field-obj-context.js +10 -0
- package/dist/web/components/wd-form/form-utils.d.ts +1 -0
- package/dist/web/components/wd-form/form-utils.js +32 -0
- package/dist/web/components/wd-form/index.d.ts +4 -4
- package/dist/web/components/wd-form/index.js +137 -191
- package/dist/web/components/wd-form-item/wd-form-item.d.ts +2 -2
- package/dist/web/components/wd-form-item/wd-form-item.js +96 -14
- package/dist/web/components/wd-form-obj/base-form-obj.js +57 -197
- package/dist/web/components/wd-input/wd-input.js +1 -1
- package/dist/web/components/wd-input-number/wd-input-number.js +40 -2
- package/dist/web/components/wd-rich-text/wd-rich-text.d.ts +1 -1
- package/dist/web/components/wd-rich-text/wd-rich-text.js +7 -3
- package/dist/web/components/wd-table/components/Table/index.js +14 -9
- package/dist/web/components/wd-table/utils/index.d.ts +0 -1
- package/dist/web/components/wd-table/utils/index.js +1 -1
- package/dist/web/components/wd-table/wd-table.js +4 -0
- package/dist/web/components/wd-tree/utils.d.ts +29 -3
- package/dist/web/components/wd-tree/utils.js +26 -12
- package/dist/web/components/wd-tree/wd-tree.d.ts +1 -0
- package/dist/web/components/wd-tree/wd-tree.js +65 -40
- package/dist/web/utils/widget-api/index.d.ts +0 -14
- package/dist/web/utils/widget-api/index.js +0 -7
- package/package.json +5 -5
|
@@ -5,11 +5,10 @@ import { Icon, Table, StatusTip, ConfigProvider } from 'tea-component';
|
|
|
5
5
|
import { useResizeObserver } from '@react-hookz/web';
|
|
6
6
|
import { useConfig } from '../../../../utils/config-context';
|
|
7
7
|
import { isInIde } from '../../../../utils/platform';
|
|
8
|
-
const { sortable, radioable, selectable, injectable, pageable, autotip, scrollable, columnsResizable } = Table.addons;
|
|
8
|
+
const { sortable, radioable, selectable, injectable, pageable, autotip, scrollable, columnsResizable, } = Table.addons;
|
|
9
9
|
import StatusContent from '../../../statusContent';
|
|
10
10
|
import classNames from '../../../../utils/classnames';
|
|
11
11
|
import { setTableHeaderStyle } from './util';
|
|
12
|
-
import { orderByFieldKey } from '../../utils/index';
|
|
13
12
|
const { LoadingTip } = StatusTip;
|
|
14
13
|
const defaultTotal = 0;
|
|
15
14
|
const pageIndexSpan = 1;
|
|
@@ -17,7 +16,7 @@ const miniPageSize = 10;
|
|
|
17
16
|
// h5 端表格高度
|
|
18
17
|
const tableHeight = { sm: 500, md: 580, lg: 880 };
|
|
19
18
|
const tableHeaderHeight = 51;
|
|
20
|
-
const renderStatus = ({ isH5, status, isNoDataSourceBind, _emptyText, errorObj, __innerSlot }) => {
|
|
19
|
+
const renderStatus = ({ isH5, status, isNoDataSourceBind, _emptyText, errorObj, __innerSlot, }) => {
|
|
21
20
|
var _a, _b;
|
|
22
21
|
const text = {
|
|
23
22
|
loading: '数据加载中,请稍候...',
|
|
@@ -40,7 +39,9 @@ onQueryChange, enablePagination, columnSelectType, defaultPageSize, defaultPageI
|
|
|
40
39
|
const tableRef = useRef(null);
|
|
41
40
|
const { classPrefix } = useConfig();
|
|
42
41
|
// 是否展示全局loading
|
|
43
|
-
const isShowLoading = isH5
|
|
42
|
+
const isShowLoading = isH5
|
|
43
|
+
? (queryParams === null || queryParams === void 0 ? void 0 : queryParams.pageIndex) === pageIndexSpan && isLoading
|
|
44
|
+
: isLoading;
|
|
44
45
|
// table状态样式
|
|
45
46
|
const showStatus = isShowLoading || isError || !(records === null || records === void 0 ? void 0 : records.length);
|
|
46
47
|
const classes = {
|
|
@@ -63,7 +64,7 @@ onQueryChange, enablePagination, columnSelectType, defaultPageSize, defaultPageI
|
|
|
63
64
|
onQueryChange({ sort });
|
|
64
65
|
}
|
|
65
66
|
events === null || events === void 0 ? void 0 : events.sort({
|
|
66
|
-
sort: sort.map((i) => ({ orderType: i.order, orderBy:
|
|
67
|
+
sort: sort.map((i) => ({ orderType: i.order, orderBy: i.by })),
|
|
67
68
|
});
|
|
68
69
|
},
|
|
69
70
|
}),
|
|
@@ -147,16 +148,20 @@ onQueryChange, enablePagination, columnSelectType, defaultPageSize, defaultPageI
|
|
|
147
148
|
tableAddons.push(selectable({
|
|
148
149
|
value: selectedKeys,
|
|
149
150
|
onChange: onSelectChange,
|
|
150
|
-
render: (element, { disabled }) =>
|
|
151
|
-
targetColumnKey: (columns === null || columns === void 0 ? void 0 : columns.length) && columnSelectType === 'select'
|
|
151
|
+
render: (element, { disabled }) => disabled ? _jsx(Icon, { type: "loading" }) : element,
|
|
152
|
+
targetColumnKey: (columns === null || columns === void 0 ? void 0 : columns.length) && columnSelectType === 'select'
|
|
153
|
+
? 'weda_select'
|
|
154
|
+
: undefined,
|
|
152
155
|
}));
|
|
153
156
|
}
|
|
154
157
|
else if (columnSelectType === 'radio') {
|
|
155
158
|
tableAddons.push(radioable({
|
|
156
159
|
value: selectedKeys === null || selectedKeys === void 0 ? void 0 : selectedKeys[0],
|
|
157
160
|
onChange: onSelectChange,
|
|
158
|
-
render: (element, { disabled }) =>
|
|
159
|
-
targetColumnKey: (columns === null || columns === void 0 ? void 0 : columns.length) && columnSelectType === 'radio'
|
|
161
|
+
render: (element, { disabled }) => disabled ? _jsx(Icon, { type: "loading" }) : element,
|
|
162
|
+
targetColumnKey: (columns === null || columns === void 0 ? void 0 : columns.length) && columnSelectType === 'radio'
|
|
163
|
+
? 'weda_radio'
|
|
164
|
+
: undefined,
|
|
160
165
|
}));
|
|
161
166
|
}
|
|
162
167
|
const showLoadingBottomTip = isLoading && (queryParams === null || queryParams === void 0 ? void 0 : queryParams.pageIndex) !== pageIndexSpan;
|
|
@@ -20,7 +20,6 @@ export declare const getSearchValues: (searchValues?: any[]) => {
|
|
|
20
20
|
}[];
|
|
21
21
|
relatedSearchValues: any;
|
|
22
22
|
};
|
|
23
|
-
export declare const orderByFieldKey: (key: any, columns: any) => any;
|
|
24
23
|
export declare const getQueryParams: ({ queryParams, wList, viewFieldsData, connectorParams, isModel, isViewTable, authFields, supportManyRelated, columns, selectFieldType, selectFields, isSupportMultipleSort, }: any) => {
|
|
25
24
|
pageNo: number;
|
|
26
25
|
pageSize: number;
|
|
@@ -188,7 +188,7 @@ export const getSearchValues = (searchValues = []) => {
|
|
|
188
188
|
relatedSearchValues,
|
|
189
189
|
};
|
|
190
190
|
};
|
|
191
|
-
|
|
191
|
+
const orderByFieldKey = (key, columns) => {
|
|
192
192
|
var _a;
|
|
193
193
|
return ((_a = columns === null || columns === void 0 ? void 0 : columns.find((i) => key === (i === null || i === void 0 ? void 0 : i.slotKey))) === null || _a === void 0 ? void 0 : _a.fieldKey) || key;
|
|
194
194
|
};
|
|
@@ -549,6 +549,10 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
549
549
|
clearSelection: () => {
|
|
550
550
|
onSelectChange([], {}, true);
|
|
551
551
|
},
|
|
552
|
+
// 设置选中项
|
|
553
|
+
setSelectedKeys: (params) => {
|
|
554
|
+
setSelectedKeys(params.selectedKeys);
|
|
555
|
+
},
|
|
552
556
|
// 当前页数据
|
|
553
557
|
records: isExpression && !enableTotal && enablePagination
|
|
554
558
|
? getCurrentPageData(dataRef.current.tableRecords, query.pageNo, query.pageSize)
|
|
@@ -92,7 +92,32 @@ declare const TREE_INFO_GOT: ({
|
|
|
92
92
|
* @param {IInitData} param0
|
|
93
93
|
* @returns
|
|
94
94
|
*/
|
|
95
|
-
declare const initData: ({ data, parent, showIcon, expendIcon, foldIcon, leafIcon, pos
|
|
95
|
+
declare const initData: ({ data, parent, showIcon, expendIcon, foldIcon, leafIcon, pos }: IInitData) => {
|
|
96
|
+
checked?: CheckedState;
|
|
97
|
+
searched?: SearchedState;
|
|
98
|
+
expanded?: ExpandState;
|
|
99
|
+
isExpand?: boolean;
|
|
100
|
+
showIcon?: boolean;
|
|
101
|
+
root?: TreeNode;
|
|
102
|
+
parent?: TreeNode;
|
|
103
|
+
iconShow?: string;
|
|
104
|
+
pos?: string;
|
|
105
|
+
label: string;
|
|
106
|
+
children: {
|
|
107
|
+
label: string;
|
|
108
|
+
children: any[];
|
|
109
|
+
value: string;
|
|
110
|
+
disabled: boolean;
|
|
111
|
+
foldIcon: string;
|
|
112
|
+
expendIcon: string;
|
|
113
|
+
leafIcon: string;
|
|
114
|
+
}[];
|
|
115
|
+
value: string;
|
|
116
|
+
disabled: boolean;
|
|
117
|
+
foldIcon: string;
|
|
118
|
+
expendIcon: string;
|
|
119
|
+
leafIcon: string;
|
|
120
|
+
}[];
|
|
96
121
|
/**
|
|
97
122
|
* 初始化节点状态
|
|
98
123
|
* @param param0
|
|
@@ -103,7 +128,7 @@ declare const initTreeState: ({ data, checkedCustom, expandType, expandCustom, s
|
|
|
103
128
|
* 当某节点的选择状态变化时,处理该节点的父和子的选择状态
|
|
104
129
|
* @param treeNode
|
|
105
130
|
*/
|
|
106
|
-
declare const dealCheck: (
|
|
131
|
+
declare const dealCheck: (_treeNode: TreeNode, showData: TreeNode[]) => any;
|
|
107
132
|
/**
|
|
108
133
|
* 查找满足要求的节点
|
|
109
134
|
* @param tree 树
|
|
@@ -189,4 +214,5 @@ declare const getTreeInfo: (params: IFindNodeParams, checkable: boolean) => {
|
|
|
189
214
|
leafIcon: string;
|
|
190
215
|
}[];
|
|
191
216
|
};
|
|
192
|
-
export
|
|
217
|
+
export declare const getTreeNode: (tree: any[], node: any) => any;
|
|
218
|
+
export { TREE_INFO_GOT, initData, initTreeState, dealCheck, findNode, getTreeInfo };
|
|
@@ -74,19 +74,20 @@ const judgeCheck = (treeNode, checkedCustom) => {
|
|
|
74
74
|
* @param {IInitData} param0
|
|
75
75
|
* @returns
|
|
76
76
|
*/
|
|
77
|
-
const initData = ({ data, parent, showIcon, expendIcon, foldIcon, leafIcon, pos = ''
|
|
77
|
+
const initData = ({ data, parent, showIcon, expendIcon, foldIcon, leafIcon, pos = '' }) => {
|
|
78
78
|
if (!Array.isArray(data))
|
|
79
79
|
return [];
|
|
80
80
|
return data
|
|
81
81
|
.filter((item) => item === null || item === void 0 ? void 0 : item.value)
|
|
82
|
-
.map((
|
|
82
|
+
.map((_item, index) => {
|
|
83
83
|
var _a;
|
|
84
|
+
const item = { ..._item };
|
|
84
85
|
item.pos = `${pos ? `${pos}-` : ''}${index}`;
|
|
85
86
|
item.root = item.root || { ...deepClone(item), pos: item.pos };
|
|
86
87
|
if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
87
88
|
item.children = initData({
|
|
88
|
-
data:
|
|
89
|
-
parent: item,
|
|
89
|
+
data: _item.children,
|
|
90
|
+
parent: { ...item },
|
|
90
91
|
showIcon,
|
|
91
92
|
expendIcon,
|
|
92
93
|
foldIcon,
|
|
@@ -98,7 +99,7 @@ const initData = ({ data, parent, showIcon, expendIcon, foldIcon, leafIcon, pos
|
|
|
98
99
|
item.foldIcon = item.foldIcon || foldIcon;
|
|
99
100
|
item.leafIcon = item.leafIcon || leafIcon;
|
|
100
101
|
item.showIcon = showIcon;
|
|
101
|
-
item.parent = parent;
|
|
102
|
+
item.parent = { ...parent };
|
|
102
103
|
return item;
|
|
103
104
|
});
|
|
104
105
|
};
|
|
@@ -107,7 +108,7 @@ const initData = ({ data, parent, showIcon, expendIcon, foldIcon, leafIcon, pos
|
|
|
107
108
|
* @param {IGetStateOfChildrenParams} param0
|
|
108
109
|
* @returns
|
|
109
110
|
*/
|
|
110
|
-
const getStateOfChildren = ({ treeNode, key, state
|
|
111
|
+
const getStateOfChildren = ({ treeNode, key, state }) => {
|
|
111
112
|
var _a, _b, _c;
|
|
112
113
|
const notHas = (_a = treeNode.children) === null || _a === void 0 ? void 0 : _a.map((v) => v[key]).includes(state.notHas);
|
|
113
114
|
const has = (_b = treeNode.children) === null || _b === void 0 ? void 0 : _b.map((v) => v[key]).includes(state.has);
|
|
@@ -194,9 +195,7 @@ const initTreeState = ({ data, checkedCustom, expandType, expandCustom, searchKe
|
|
|
194
195
|
item.expanded = item.searched ? 'expand' : '';
|
|
195
196
|
}
|
|
196
197
|
// 被搜索到的或根据输入判断需要展开的都认为要展开
|
|
197
|
-
item.isExpand =
|
|
198
|
-
!!((_b = item.children) === null || _b === void 0 ? void 0 : _b.length) &&
|
|
199
|
-
(searchKey ? !!item.searched : !!item.expanded);
|
|
198
|
+
item.isExpand = !!((_b = item.children) === null || _b === void 0 ? void 0 : _b.length) && (searchKey ? !!item.searched : !!item.expanded);
|
|
200
199
|
if (item.showIcon) {
|
|
201
200
|
if ((_c = item.children) === null || _c === void 0 ? void 0 : _c.length) {
|
|
202
201
|
item.iconShow = item.isExpand ? item.expendIcon : item.foldIcon;
|
|
@@ -212,9 +211,10 @@ const initTreeState = ({ data, checkedCustom, expandType, expandCustom, searchKe
|
|
|
212
211
|
* 当某节点的选择状态变化时,处理该节点的父和子的选择状态
|
|
213
212
|
* @param treeNode
|
|
214
213
|
*/
|
|
215
|
-
const dealCheck = (
|
|
214
|
+
const dealCheck = (_treeNode, showData) => {
|
|
216
215
|
var _a;
|
|
217
|
-
|
|
216
|
+
const treeNode = getTreeNode(showData, _treeNode);
|
|
217
|
+
let parent = getTreeNode(showData, treeNode.parent);
|
|
218
218
|
const adjust = (arr, checked) => {
|
|
219
219
|
arr.forEach((item) => {
|
|
220
220
|
var _a;
|
|
@@ -231,6 +231,7 @@ const dealCheck = (treeNode) => {
|
|
|
231
231
|
if ((_a = treeNode.children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
232
232
|
adjust(treeNode.children, treeNode.checked);
|
|
233
233
|
}
|
|
234
|
+
return treeNode;
|
|
234
235
|
};
|
|
235
236
|
/**
|
|
236
237
|
* 查找满足要求的节点
|
|
@@ -286,4 +287,17 @@ const getTreeInfo = (params, checkable) => {
|
|
|
286
287
|
delete info.selectedPositions;
|
|
287
288
|
return info;
|
|
288
289
|
};
|
|
289
|
-
export
|
|
290
|
+
export const getTreeNode = (tree = [], node) => {
|
|
291
|
+
var _a;
|
|
292
|
+
for (const item of tree) {
|
|
293
|
+
if (item.value === (node === null || node === void 0 ? void 0 : node.value))
|
|
294
|
+
return item;
|
|
295
|
+
if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
296
|
+
const found = getTreeNode(item.children, node);
|
|
297
|
+
if (found)
|
|
298
|
+
return found; // 立即返回已找到的节点
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return null; // 明确返回null表示未找到
|
|
302
|
+
};
|
|
303
|
+
export { TREE_INFO_GOT, initData, initTreeState, dealCheck, findNode, getTreeInfo };
|
|
@@ -3,4 +3,5 @@ import type { CommonPropsType } from '../../types';
|
|
|
3
3
|
import type { DataType } from '../../../configs/components/wd-tree';
|
|
4
4
|
export declare const WdTree: React.ForwardRefExoticComponent<WdTreeProps & React.RefAttributes<unknown>>;
|
|
5
5
|
export interface WdTreeProps extends CommonPropsType, DataType {
|
|
6
|
+
contentSlot_treeNode?: any;
|
|
6
7
|
}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useImperativeHandle, useEffect, useState, useCallback, } from 'react';
|
|
2
|
+
import React, { forwardRef, useImperativeHandle, useEffect, useState, useCallback, useRef } from 'react';
|
|
3
3
|
import classNames from '../../utils/classnames';
|
|
4
4
|
import { useConfig } from '../../utils/config-context';
|
|
5
5
|
import { usePlatform } from '../../utils/platform';
|
|
6
6
|
import WdCheckbox from '../wd-checkbox';
|
|
7
7
|
import WdIcon from '../wd-icon';
|
|
8
|
-
import { TREE_INFO_GOT, initData, initTreeState, dealCheck, getTreeInfo
|
|
8
|
+
import { TREE_INFO_GOT, initData, initTreeState, dealCheck, getTreeInfo } from './utils';
|
|
9
9
|
import { deepClone } from '../../utils/tool';
|
|
10
|
+
import isObjectEqual from '../../utils/isObjectEqual';
|
|
11
|
+
const TreeNodeSlot = React.memo(function TreeNodeSlot({ Slot, item, itemIndex }) {
|
|
12
|
+
if (typeof Slot === 'function') {
|
|
13
|
+
return _jsx(Slot, { item: item, itemIndex: itemIndex });
|
|
14
|
+
}
|
|
15
|
+
return Slot !== null && Slot !== void 0 ? Slot : null;
|
|
16
|
+
});
|
|
10
17
|
export const WdTree = forwardRef(function WdTree(props, ref) {
|
|
11
18
|
var _a;
|
|
12
|
-
const { className = '', style, id, events, data, checkable, checkedCustom, expandType, expandCustom, showIcon, foldIcon, expendIcon, leafIcon, line, } = props;
|
|
19
|
+
const { className = '', style, id, events, data, checkable, checkedCustom, expandType, expandCustom, showIcon, foldIcon, expendIcon, leafIcon, line, enableSearchText = true, isSupportSlot, } = props;
|
|
13
20
|
const platform = usePlatform();
|
|
14
21
|
// 样式
|
|
15
22
|
const { classPrefix } = useConfig();
|
|
@@ -28,6 +35,8 @@ export const WdTree = forwardRef(function WdTree(props, ref) {
|
|
|
28
35
|
const [selected, setSelected] = useState(((_a = props.checkedCustom) === null || _a === void 0 ? void 0 : _a.length) ? props.checkedCustom[0] : '');
|
|
29
36
|
// 搜索内容
|
|
30
37
|
const [searchKey, setSearchKey] = useState('');
|
|
38
|
+
const [treeNodeList, setTreeNodeList] = useState([]);
|
|
39
|
+
const showDataRef = useRef(null);
|
|
31
40
|
/**
|
|
32
41
|
* 组件搜索节点方法
|
|
33
42
|
*/
|
|
@@ -47,6 +56,7 @@ export const WdTree = forwardRef(function WdTree(props, ref) {
|
|
|
47
56
|
methods: {
|
|
48
57
|
searchNode,
|
|
49
58
|
},
|
|
59
|
+
treeNodeList,
|
|
50
60
|
treeInfo,
|
|
51
61
|
data,
|
|
52
62
|
checkable,
|
|
@@ -62,6 +72,7 @@ export const WdTree = forwardRef(function WdTree(props, ref) {
|
|
|
62
72
|
expandedNodes: treeInfo === null || treeInfo === void 0 ? void 0 : treeInfo.expandedNodes,
|
|
63
73
|
};
|
|
64
74
|
}, [
|
|
75
|
+
treeNodeList,
|
|
65
76
|
checkable,
|
|
66
77
|
checkedCustom,
|
|
67
78
|
data,
|
|
@@ -124,7 +135,7 @@ export const WdTree = forwardRef(function WdTree(props, ref) {
|
|
|
124
135
|
check: () => {
|
|
125
136
|
treeNode.checked = state ? 'checked' : '';
|
|
126
137
|
// 处理节点的父/子节点选中状态
|
|
127
|
-
dealCheck(treeNode);
|
|
138
|
+
dealCheck(treeNode, showData);
|
|
128
139
|
},
|
|
129
140
|
select: () => {
|
|
130
141
|
state = selectedKey !== treeNode.value;
|
|
@@ -160,41 +171,55 @@ export const WdTree = forwardRef(function WdTree(props, ref) {
|
|
|
160
171
|
}, 0);
|
|
161
172
|
event !== 'select' && setShowData([...showData]);
|
|
162
173
|
};
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (item.disabled)
|
|
187
|
-
return;
|
|
188
|
-
change(item, 'check', item.checked !== 'checked');
|
|
189
|
-
}, 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') ||
|
|
190
|
-
item.iconShow.startsWith('data:')
|
|
191
|
-
? 'custom'
|
|
192
|
-
: 'inner', size: "sm" })), _jsx("label", { className: `${classPrefix}-tree__label-text`, htmlFor: "", style: disableStyle, children: searchKey
|
|
193
|
-
? item.label.split(searchKey).map((v, i) => (_jsxs("span", { children: [i !== 0 && (_jsx("span", { className: `${classPrefix}-tree__label-text-search`, children: searchKey })), v] }, i)))
|
|
194
|
-
: item.label })] })] }, item.value));
|
|
195
|
-
subTree && item.isExpand && renderNode(subTree, count + STEP);
|
|
196
|
-
});
|
|
197
|
-
return list;
|
|
174
|
+
const renderTreeNode = ({ item, count, index, itemIndex }) => {
|
|
175
|
+
var _a;
|
|
176
|
+
const subTree = ((_a = item === null || item === void 0 ? void 0 : item.children) === null || _a === void 0 ? void 0 : _a.length) > 0 ? true : false;
|
|
177
|
+
const spaceDom = [];
|
|
178
|
+
const disableStyle = (item === null || item === void 0 ? void 0 : item.disabled) ? { cursor: 'not-allowed', color: 'rgba(0,0,0,.26)' } : {};
|
|
179
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
180
|
+
const { children, parent, ...rest } = item;
|
|
181
|
+
const nodeItem = { ...rest };
|
|
182
|
+
for (let i = 0; i < count; i++) {
|
|
183
|
+
spaceDom.push(_jsx("span", { className: `${classPrefix}-tree__space` }, Math.random()));
|
|
184
|
+
}
|
|
185
|
+
return (_jsxs("div", {
|
|
186
|
+
// 叶子节点 加 `${classPrefix}-tree-node--leaf` 为了连线的时候,对横线特殊处理
|
|
187
|
+
// 选中态,加 is-selected
|
|
188
|
+
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 && (
|
|
189
|
+
// 展开/收起的图标
|
|
190
|
+
_jsx(WdIcon, { className: `${classPrefix}-tree__switcher-icon`, name: item.isExpand ? 'td:caret-down-small' : 'td:caret-right-small', size: "sm" })) }), _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: () => {
|
|
191
|
+
if (item.disabled)
|
|
192
|
+
return;
|
|
193
|
+
change(item, 'check', item.checked !== 'checked');
|
|
194
|
+
}, 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') || item.iconShow.startsWith('data:') ? 'custom' : 'inner', size: "sm" })), enableSearchText && (_jsx("label", { className: `${classPrefix}-tree__label-text`, htmlFor: "", style: disableStyle, children: searchKey
|
|
195
|
+
? item.label.split(searchKey).map((v, i) => (_jsxs("span", { children: [i !== 0 && _jsx("span", { className: `${classPrefix}-tree__label-text-search`, children: searchKey }), v] }, i)))
|
|
196
|
+
: item.label })), isSupportSlot && nodeItem && (_jsx("label", { className: `${classPrefix}-tree__label-text`, htmlFor: "", style: disableStyle, children: _jsx(TreeNodeSlot, { item: nodeItem, Slot: props.contentSlot_treeNode, itemIndex: itemIndex }) }))] })] }, item.value));
|
|
198
197
|
};
|
|
199
|
-
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
if (!isObjectEqual(showDataRef.current, showData)) {
|
|
200
|
+
const list = [];
|
|
201
|
+
const renderNode = (d, count) => {
|
|
202
|
+
if (!Array.isArray(d))
|
|
203
|
+
return [];
|
|
204
|
+
// @ts-ignore const 会报错,应该是let
|
|
205
|
+
count = count || 0;
|
|
206
|
+
const STEP = 1;
|
|
207
|
+
d.filter((item) => item === null || item === void 0 ? void 0 : item.value).forEach((item, index) => {
|
|
208
|
+
var _a;
|
|
209
|
+
const hasChildren = ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
210
|
+
const subTree = hasChildren ? [...item.children] : undefined;
|
|
211
|
+
list.push({ item, count, index });
|
|
212
|
+
subTree && item.isExpand && renderNode(subTree, count + STEP);
|
|
213
|
+
});
|
|
214
|
+
return list;
|
|
215
|
+
};
|
|
216
|
+
let _treeNode = renderNode(showData, 0);
|
|
217
|
+
_treeNode = (_treeNode === null || _treeNode === void 0 ? void 0 : _treeNode.length) > 0 ? _treeNode === null || _treeNode === void 0 ? void 0 : _treeNode.map((i, index) => ({ ...i, itemIndex: index })) : [];
|
|
218
|
+
setTreeNodeList(_treeNode);
|
|
219
|
+
showDataRef.current = { ...showData };
|
|
220
|
+
}
|
|
221
|
+
}, [showData]);
|
|
222
|
+
return (_jsx("div", { id: id, style: style, className: classNames(classes, className), "data-testid": "wd-tree-test", children: treeNodeList === null || treeNodeList === void 0 ? void 0 : treeNodeList.map((i, index) => {
|
|
223
|
+
return _jsxs(React.Fragment, { children: [" ", renderTreeNode(i), " "] }, index);
|
|
224
|
+
}) }));
|
|
200
225
|
});
|
|
@@ -7,22 +7,8 @@ export declare function useWedaAppContext(): {
|
|
|
7
7
|
export declare const FormDetailStatusContext: import("react").Context<string>;
|
|
8
8
|
export declare const useFormDetailContext: () => string;
|
|
9
9
|
export declare const FormObjContext: import("react").Context<{
|
|
10
|
-
formObjName: string;
|
|
11
10
|
status: 'edit' | 'disabled' | 'readOnly';
|
|
12
|
-
valueChangeFromChild: (params: {
|
|
13
|
-
name: string;
|
|
14
|
-
value: any;
|
|
15
|
-
}) => void;
|
|
16
|
-
addFormItem: (name: string, $widget: IWidget) => () => void;
|
|
17
11
|
}>;
|
|
18
12
|
export declare const useFormObjContext: () => {
|
|
19
|
-
formObjName: string;
|
|
20
13
|
status: 'edit' | 'disabled' | 'readOnly';
|
|
21
|
-
valueChangeFromChild: (params: {
|
|
22
|
-
name: string;
|
|
23
|
-
value: any;
|
|
24
|
-
}) => void;
|
|
25
|
-
addFormItem: (name: string, $widget: IWidget) => () => void;
|
|
26
14
|
};
|
|
27
|
-
export declare const FormObjWidgetContext: import("react").Context<IWidget>;
|
|
28
|
-
export declare const useFormObjWidget: () => IWidget;
|
|
@@ -57,15 +57,8 @@ export const useFormDetailContext = () => {
|
|
|
57
57
|
};
|
|
58
58
|
// 共享嵌套表单状态
|
|
59
59
|
export const FormObjContext = createContext({
|
|
60
|
-
formObjName: '',
|
|
61
60
|
status: 'edit',
|
|
62
|
-
valueChangeFromChild: () => { },
|
|
63
|
-
addFormItem: () => () => { },
|
|
64
61
|
}, 'FormObj');
|
|
65
62
|
export const useFormObjContext = () => {
|
|
66
63
|
return useContext(FormObjContext);
|
|
67
64
|
};
|
|
68
|
-
export const FormObjWidgetContext = createContext(null, 'FormObjWidget');
|
|
69
|
-
export const useFormObjWidget = () => {
|
|
70
|
-
return useContext(FormObjWidgetContext);
|
|
71
|
-
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/weda-ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.20.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index",
|
|
6
6
|
"miniprogram": "mpdist",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"description": "腾讯云微搭低代码组件库模板",
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"@antv/g6": "^4.8.5",
|
|
88
|
-
"@cloudbase/weda-client": "^1.1.
|
|
88
|
+
"@cloudbase/weda-client": "^1.1.33",
|
|
89
89
|
"@codemirror/autocomplete": "^6.16.0",
|
|
90
90
|
"@codemirror/lang-javascript": "^6.2.2",
|
|
91
91
|
"@codemirror/lang-json": "^6.0.1",
|
|
@@ -147,9 +147,9 @@
|
|
|
147
147
|
"@babel/preset-env": "^7.22.15",
|
|
148
148
|
"@babel/preset-react": "^7.22.15",
|
|
149
149
|
"@babel/preset-typescript": "^7.22.15",
|
|
150
|
-
"@cloudbase/cals": "^1.2.
|
|
151
|
-
"@cloudbase/lowcode-cli": "^0.22.
|
|
152
|
-
"@cloudbase/weda-cloud-sdk": "^1.0.
|
|
150
|
+
"@cloudbase/cals": "^1.2.15",
|
|
151
|
+
"@cloudbase/lowcode-cli": "^0.22.3",
|
|
152
|
+
"@cloudbase/weda-cloud-sdk": "^1.0.104",
|
|
153
153
|
"@commitlint/cli": "^16.0.2",
|
|
154
154
|
"@commitlint/config-conventional": "^17.7.0",
|
|
155
155
|
"@craco/craco": "^7.1.0",
|