@ticatec/uniface-element 0.1.11 → 0.1.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/common/FullscreenOverlay.svelte +1 -1
- package/dist/data-table/parts/FixedRow.svelte +1 -1
- package/dist/text-editor/TextEditor.svelte +1 -1
- package/dist/tree-view/TreeNode.d.ts +8 -0
- package/dist/tree-view/TreeUtils.d.ts +5 -9
- package/dist/tree-view/TreeUtils.js +45 -28
- package/dist/tree-view/index.d.ts +4 -4
- package/dist/tree-view/index.js +2 -2
- package/package.json +2 -2
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
{#if visible}
|
|
10
10
|
<Portal target="body">
|
|
11
11
|
<div class="uniface-mask-overlay">
|
|
12
|
-
<div style="position: relative; width: 100%; height: 100%;"
|
|
12
|
+
<div style="position: relative; width: 100%; height: 100%; overflow: hidden"
|
|
13
13
|
on:click={()=>{visible = false}} aria-hidden="true">
|
|
14
14
|
<slot></slot>
|
|
15
15
|
</div>
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
|
|
42
42
|
</script>
|
|
43
43
|
<CommonEditor {displayMode} {style} {value} {suffix} {prefix} {readonly} {disabled} {variant} {compact}
|
|
44
|
-
showActionIcon={!readonly && !disabled && removable && value?.length > 0}
|
|
44
|
+
showActionIcon={!readonly && !disabled && removable && value?.length > 0} placeholder={input$['placeholder']}
|
|
45
45
|
class={className} clean={clean}>
|
|
46
46
|
<svelte:fragment slot="leading-icon">
|
|
47
47
|
{#if $$slots['leading-icon']}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import type TreeNode from "./TreeNode";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @param parentField
|
|
8
|
-
* @param rootParentCode
|
|
9
|
-
*/
|
|
10
|
-
export declare const buildTree: (arr: Array<any>, keyField: string, textField: string, parentField: string, rootParentCode?: string | null) => Array<TreeNode>;
|
|
2
|
+
import type { NodeLevelCompare, RootDetermine } from "./TreeNode";
|
|
3
|
+
declare const _default: {
|
|
4
|
+
buildTreeNode: (list: Array<any>, idKey: string, joinKey: string, textField: string, valueField?: string, isRoot?: RootDetermine, sortFun?: NodeLevelCompare) => Array<TreeNode>;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
@@ -1,36 +1,53 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @param
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
2
|
+
* 将一个数组转换成树状结构
|
|
3
|
+
* @param list 待转换的数组
|
|
4
|
+
* @param idKey 元素的主键
|
|
5
|
+
* @param joinKey 父子间连接字段
|
|
6
|
+
* @param valueField 取值的字段
|
|
7
|
+
* @param textField 显示文字的字段
|
|
8
|
+
* @param isRoot 判断是否是根节点,如果函数不存在,通过连接字段查询,无法获取到父节点就是根节点
|
|
9
|
+
* @param sortFun 比较函数,用于曾经排序
|
|
9
10
|
*/
|
|
10
|
-
const
|
|
11
|
+
const buildTreeNode = (list, idKey, joinKey, textField, valueField, isRoot, sortFun) => {
|
|
12
|
+
if (sortFun != null) {
|
|
13
|
+
list = list.sort(sortFun);
|
|
14
|
+
}
|
|
11
15
|
let nodes = [];
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
let map = new Map();
|
|
17
|
+
list.forEach(item => {
|
|
18
|
+
let node = { value: item[valueField ?? idKey], text: item[textField], data: item };
|
|
19
|
+
if (isRoot != null) {
|
|
20
|
+
if (isRoot(item)) {
|
|
21
|
+
nodes.push(node);
|
|
22
|
+
map.set(item[idKey], node);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
let parent = map.get(item[joinKey]);
|
|
26
|
+
if (parent != null) {
|
|
27
|
+
parent.children = [...parent.children, node];
|
|
28
|
+
node.parent = parent;
|
|
29
|
+
map.set(item[idKey], node);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
console.warn('Isolated node:', item);
|
|
33
|
+
}
|
|
20
34
|
}
|
|
21
|
-
nodes.push(node);
|
|
22
35
|
}
|
|
23
|
-
|
|
36
|
+
else {
|
|
37
|
+
let parent = map.get(item[joinKey]);
|
|
38
|
+
if (parent != null) {
|
|
39
|
+
parent.children = [...parent.children, item];
|
|
40
|
+
node.parent = parent;
|
|
41
|
+
map.set(item[idKey], node);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
nodes.push(node);
|
|
45
|
+
map.set(item[idKey], node);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
24
49
|
return nodes;
|
|
25
50
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* @param arr
|
|
29
|
-
* @param keyField
|
|
30
|
-
* @param textField
|
|
31
|
-
* @param parentField
|
|
32
|
-
* @param rootParentCode
|
|
33
|
-
*/
|
|
34
|
-
export const buildTree = (arr, keyField, textField, parentField, rootParentCode = null) => {
|
|
35
|
-
return convertArrayToTree(arr, keyField, textField, parentField, rootParentCode);
|
|
51
|
+
export default {
|
|
52
|
+
buildTreeNode
|
|
36
53
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import TreeView from "./TreeView.svelte";
|
|
2
2
|
import type TreeNode from "./TreeNode";
|
|
3
|
-
import type { LazyLoader, NodeVisibleFun, OnNodeSelectionChange, CheckBranchFun, LoadChildrenFun } from "./TreeNode";
|
|
4
|
-
import
|
|
3
|
+
import type { LazyLoader, NodeVisibleFun, OnNodeSelectionChange, CheckBranchFun, LoadChildrenFun, NodeLevelCompare, RootDetermine } from "./TreeNode";
|
|
4
|
+
import treeUtils from "./TreeUtils";
|
|
5
5
|
export default TreeView;
|
|
6
|
-
export {
|
|
7
|
-
export type { TreeNode, LazyLoader, NodeVisibleFun, OnNodeSelectionChange, CheckBranchFun, LoadChildrenFun };
|
|
6
|
+
export { treeUtils };
|
|
7
|
+
export type { TreeNode, LazyLoader, NodeVisibleFun, OnNodeSelectionChange, CheckBranchFun, LoadChildrenFun, NodeLevelCompare, RootDetermine };
|
package/dist/tree-view/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ticatec/uniface-element",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "uniface web elements",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite dev",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"types": "./dist/checkbox/index.d.ts",
|
|
97
97
|
"import": "./dist/checkbox/index.js"
|
|
98
98
|
},
|
|
99
|
-
"./
|
|
99
|
+
"./FullScreenOverlay": {
|
|
100
100
|
"types": "./dist/common/FullscreenOverlay.svelte.d.ts",
|
|
101
101
|
"import": "./dist/common/FullscreenOverlay.svelte"
|
|
102
102
|
},
|