@ticatec/uniface-element 0.1.10 → 0.1.11

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.
@@ -1,4 +1,4 @@
1
- import dayjs from "dayjs";
1
+ import dayjs, { isDayjs } from "dayjs";
2
2
  /**
3
3
  * 获取今日的日期,时间清空
4
4
  */
@@ -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<Array<any>> = [];
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 newArr = nodes.slice(0, level + 1)
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
- busy = true;
45
- let list = await (onSelect?.(item));
46
- busy = false;
47
- if (list && list.length > 0) {
48
- nodes = [...newArr, list];
49
- await tick();
50
- contentPanel.scrollLeft = contentPanel.scrollWidth;
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 nodes as node, idx}
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,4 @@
1
+ /**
2
+ * 判断当前节点是否为末端节点
3
+ */
4
+ export type IsLeafDetermine = (item: any) => boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -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 "../common/date-utils";
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} style="user-select: none; width: {actionsColumn.width}px;">
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
- {#each rows as row, idx}
51
- <ActionsRow {row} {rowHeight} parentRect={rect} alternative={idx % 2 == 1} width={actionsColumn.width} actions={actionsColumn.getActions(row)}/>
52
- {#if row == expandRow}
53
- <div class="inline-panel" style="height: {inlineRowHeight??0}px">
54
- </div>
55
- {/if}
56
- {/each}
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 {dateUtils} from "../../lib/base-calendar";
7
+ import dateUtils from "../base-calendar/dateUtils";
8
8
 
9
9
  export let value: UniDate;
10
10
  export let style: string = '';
@@ -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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ticatec/uniface-element",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "uniface web elements",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -1,5 +0,0 @@
1
- import type { UniDate } from "../calendar/dateUtils";
2
- declare const _default: {
3
- formatDate: (d: UniDate, fmt: string) => string;
4
- };
5
- export default _default;
@@ -1,7 +0,0 @@
1
- import dayjs, { isDayjs } from "dayjs";
2
- const formatDate = (d, fmt) => {
3
- return (d == null) ? '' : isDayjs(d) ? d.format(fmt) : dayjs(d).format(fmt);
4
- };
5
- export default {
6
- formatDate
7
- };