@ticatec/uniface-element 0.1.10 → 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/base-calendar/dateUtils.js +1 -1
- package/dist/cascade-options-select/CascadeOptionSelect.svelte +39 -11
- package/dist/cascade-options-select/isLeafDetermine.d.ts +4 -0
- package/dist/cascade-options-select/isLeafDetermine.js +1 -0
- package/dist/common/FullscreenOverlay.svelte +1 -1
- package/dist/common-editor/DateInput.svelte +1 -1
- package/dist/data-table/parts/ActionsPanel.svelte +11 -8
- package/dist/data-table/parts/FixedRow.svelte +1 -1
- package/dist/date-picker/TimePanel.svelte +1 -1
- package/dist/text-editor/TextEditor.svelte +1 -1
- package/dist/ticatec-uniface-web.css +8 -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
- package/dist/common/date-utils.d.ts +0 -5
- package/dist/common/date-utils.js +0 -7
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
import {DisplayMode} from "../common/DisplayMode";
|
|
4
4
|
import iconLoading from "../assets/loading.gif";
|
|
5
5
|
import OptionsBox from "./OptionsBox.svelte";
|
|
6
|
-
import {tick} from "svelte";
|
|
6
|
+
import {onMount, tick} from "svelte";
|
|
7
7
|
import CommonPicker from "../common/CommonPicker.svelte";
|
|
8
8
|
import type {OnChangeHandler} from "../common/OnChangeHandler";
|
|
9
|
+
import type {IsLeafDetermine} from "./isLeafDetermine";
|
|
9
10
|
|
|
10
11
|
type OnSelectOption = (item: any) => Promise<Array<any>>;
|
|
11
12
|
|
|
@@ -18,12 +19,14 @@
|
|
|
18
19
|
export let keyField: string = "code";
|
|
19
20
|
export let textField: string = "text";
|
|
20
21
|
export let abbrField: string = 'abbr';
|
|
22
|
+
export let childrenField: string = 'children';
|
|
21
23
|
export let style: string = '';
|
|
22
24
|
export let placeholder: string = "";
|
|
23
25
|
export let displayMode: DisplayMode = DisplayMode.Edit;
|
|
24
26
|
export let emptyText: string | null = null;
|
|
27
|
+
export let checkLeaf: IsLeafDetermine | null = null;
|
|
25
28
|
export let text: string = '';
|
|
26
|
-
export let nodes: Array<
|
|
29
|
+
export let nodes: Array<any> = [];
|
|
27
30
|
export let menu$height: number = 150;
|
|
28
31
|
export let onSelect: OnSelectOption;
|
|
29
32
|
export let box$style: string = "";
|
|
@@ -32,22 +35,45 @@
|
|
|
32
35
|
let oldValue = value;
|
|
33
36
|
let selectedItems: Array<any> = [];
|
|
34
37
|
let busy: boolean = false;
|
|
38
|
+
let list: Array<Array<any>> = [];
|
|
39
|
+
|
|
40
|
+
onMount(async () => {
|
|
41
|
+
list = [...nodes];
|
|
42
|
+
})
|
|
35
43
|
|
|
36
44
|
const selectOption = (level: number) => async (item: any) => {
|
|
37
45
|
value = item?.[keyField];
|
|
38
|
-
let
|
|
46
|
+
let newList = list.slice(0, level + 1)
|
|
39
47
|
if (level == 0) {
|
|
40
48
|
selectedItems = [item];
|
|
41
49
|
} else {
|
|
42
50
|
selectedItems = [...selectedItems.slice(0, level), item];
|
|
43
51
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
let isLeaf = checkLeaf == null ? false : checkLeaf(item);
|
|
53
|
+
if (!isLeaf) {
|
|
54
|
+
if (item[childrenField] == null && onSelect != null) {
|
|
55
|
+
busy = true;
|
|
56
|
+
let children = (await (onSelect(item))) ?? [];
|
|
57
|
+
busy = false;
|
|
58
|
+
item[childrenField] = children;
|
|
59
|
+
if (children.length > 0) {
|
|
60
|
+
list = [...newList, children];
|
|
61
|
+
await tick();
|
|
62
|
+
contentPanel.scrollLeft = contentPanel.scrollWidth;
|
|
63
|
+
} else {
|
|
64
|
+
showPopup = false;
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
|
|
68
|
+
if (item[childrenField] && item[childrenField].length > 0) {
|
|
69
|
+
console.log('存在子节点')
|
|
70
|
+
list = [...newList, item[childrenField]];
|
|
71
|
+
await tick();
|
|
72
|
+
contentPanel.scrollLeft = contentPanel.scrollWidth;
|
|
73
|
+
} else {
|
|
74
|
+
showPopup = false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
51
77
|
} else {
|
|
52
78
|
showPopup = false;
|
|
53
79
|
}
|
|
@@ -68,6 +94,8 @@
|
|
|
68
94
|
|
|
69
95
|
$: mh = `height: ${menu$height}px`;
|
|
70
96
|
|
|
97
|
+
$: list = [...nodes];
|
|
98
|
+
|
|
71
99
|
$: text = selectedItems && selectedItems.length > 0 ? selectedItems[selectedItems.length - 1][textField] : emptyText ?? '';
|
|
72
100
|
|
|
73
101
|
const cleanData = () => {
|
|
@@ -91,7 +119,7 @@
|
|
|
91
119
|
<div class="cascade-options-popover" style={mh} slot="popup-panel">
|
|
92
120
|
<div style="width: 100%; height: 100%; position: relative">
|
|
93
121
|
<div bind:this={contentPanel} style="width: 100%; height: 100%; display: flex; flex-direction: row; overflow: auto">
|
|
94
|
-
{#each
|
|
122
|
+
{#each list as node, idx}
|
|
95
123
|
<OptionsBox options={node} {keyField} textField={abbrField} {box$style} onSelect={selectOption(idx)}
|
|
96
124
|
selectedItem={selectedItems[idx]}/>
|
|
97
125
|
{/each}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import type {OnChangeHandler} from "../common/OnChangeHandler";
|
|
4
4
|
import type {UniDate} from "../base-calendar/dateUtils";
|
|
5
5
|
import {DateFormats} from "../common/DateFormats";
|
|
6
|
-
import dateUtils from "../
|
|
6
|
+
import dateUtils from "../base-calendar/dateUtils";
|
|
7
7
|
|
|
8
8
|
export let disabled: boolean = false;
|
|
9
9
|
export let readonly: boolean = false;
|
|
@@ -45,15 +45,18 @@
|
|
|
45
45
|
|
|
46
46
|
</script>
|
|
47
47
|
|
|
48
|
-
<div class="action-panel" bind:this={panel}
|
|
48
|
+
<div class="action-panel" bind:this={panel} style="user-select: none; width: {actionsColumn.width}px;">
|
|
49
49
|
<div bind:this={scrollPanel} class="scroll-panel" on:scroll|passive={handleActionPanelScroll}>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
<div>
|
|
51
|
+
{#each rows as row, idx}
|
|
52
|
+
<ActionsRow {row} {rowHeight} parentRect={rect} alternative={idx % 2 == 1} width={actionsColumn.width}
|
|
53
|
+
actions={actionsColumn.getActions(row.data)}/>
|
|
54
|
+
{#if row == expandRow}
|
|
55
|
+
<div class="inline-panel" style="height: {inlineRowHeight??0}px">
|
|
56
|
+
</div>
|
|
57
|
+
{/if}
|
|
58
|
+
{/each}
|
|
59
|
+
</div>
|
|
57
60
|
</div>
|
|
58
61
|
<div class="bottom-mask-overlay">
|
|
59
62
|
<!-- 用于匹配中间数据区域的滚动条 -->
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import dayjs from "dayjs";
|
|
5
5
|
import type {OnChangeHandler} from "../common/OnChangeHandler";
|
|
6
6
|
import type {UniDate} from "../base-calendar/dateUtils";
|
|
7
|
-
import
|
|
7
|
+
import dateUtils from "../base-calendar/dateUtils";
|
|
8
8
|
|
|
9
9
|
export let value: UniDate;
|
|
10
10
|
export let style: string = '';
|
|
@@ -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']}
|
|
@@ -203,6 +203,9 @@
|
|
|
203
203
|
--uniface-context-menu-box-shadow: rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 2px 6px 2px;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
+
.uniface-common-picker {
|
|
207
|
+
padding: 0 8px;
|
|
208
|
+
}
|
|
206
209
|
.uniface-common-picker .editor-dropdown {
|
|
207
210
|
visibility: hidden;
|
|
208
211
|
margin-left: 8px;
|
|
@@ -213,7 +216,6 @@
|
|
|
213
216
|
font-size: 18px;
|
|
214
217
|
color: var(--uniface-editor-text-color, #374151);
|
|
215
218
|
align-self: center;
|
|
216
|
-
margin-right: 4px;
|
|
217
219
|
cursor: pointer;
|
|
218
220
|
}
|
|
219
221
|
.uniface-common-picker .action-icon:active {
|
|
@@ -3632,6 +3634,11 @@
|
|
|
3632
3634
|
flex-wrap: nowrap;
|
|
3633
3635
|
flex-direction: row;
|
|
3634
3636
|
align-items: center;
|
|
3637
|
+
background-color: var(--uniface-data-table-background-color, #ffffff);
|
|
3638
|
+
height: 36px;
|
|
3639
|
+
}
|
|
3640
|
+
.uniface-data-table .table-row.alternative {
|
|
3641
|
+
background-color: var(--uniface-data-table-background-color, #f7f7f7);
|
|
3635
3642
|
}
|
|
3636
3643
|
.uniface-data-table.row-border .table-row {
|
|
3637
3644
|
border-bottom: 1px solid var(--uniface-data-table-row-border-color, #f0f0f0);
|
|
@@ -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
|
},
|