@cloudbase/weda-ui 3.18.8 → 3.19.1
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/chart/bar.js +0 -62
- package/dist/configs/components/chart/line.js +0 -62
- package/dist/configs/components/chart/pie.js +0 -62
- package/dist/configs/components/chart/statisticsCard.json +3 -52
- package/dist/configs/components/lottery.d.ts +2 -0
- package/dist/configs/components/lottery.js +6 -1
- package/dist/configs/components/wd-checkbox.d.ts +4 -1
- package/dist/configs/components/wd-checkbox.js +15 -1
- package/dist/configs/components/wd-image.js +1 -0
- package/dist/configs/components/wd-radio.d.ts +4 -1
- package/dist/configs/components/wd-radio.js +4 -0
- package/dist/configs/components/wd-select-multiple.d.ts +4 -1
- package/dist/configs/components/wd-select-multiple.js +11 -1
- package/dist/configs/components/wd-select.d.ts +4 -1
- package/dist/configs/components/wd-table.d.ts +16 -0
- package/dist/configs/components/wd-table.js +19 -2
- package/dist/configs/components/wd-tag-select.d.ts +4 -1
- package/dist/configs/components/wd-tag-select.js +11 -1
- package/dist/configs/components/wd-top-tab.d.ts +6 -1
- package/dist/configs/components/wd-top-tab.js +16 -1
- 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 +112 -36
- package/dist/configs/type-utils/type-form.d.ts +8 -2
- package/dist/configs/type-utils/type-form.js +8 -1
- 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/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/wd-table/components/ExportFileModalByApi/index.js +1 -1
- package/dist/web/components/wd-table/hooks/useTableData.js +8 -3
- 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/package.json +5 -5
|
@@ -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
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/weda-ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.19.1",
|
|
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",
|