@ticatec/uniface-element 0.1.9 → 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.
@@ -22,7 +22,6 @@
22
22
  }
23
23
 
24
24
 
25
-
26
25
  </script>
27
26
 
28
27
  <div style="width: 100%; height: 100%; box-sizing: border-box; display: flex; flex-direction: column; position: relative">
@@ -30,14 +29,16 @@
30
29
  <slot name="header"></slot>
31
30
  </div>
32
31
  <div style="width: 100%; flex: 1 1 auto; overflow: hidden; display: flex; flex-direction: row;">
33
- <div bind:this={sidebar}
34
- style="height: 100%; flex: 0 0 auto; overflow: auto; width: {sidebarWidth}px; {minWidth} {maxWidth}">
35
- <slot name="sidebar"></slot>
36
- </div>
37
- {#if sidebarResize}
38
- <Split direction="vertical" bindingPanel={sidebar}/>
32
+ {#if $$slots['sidebar']}
33
+ <div bind:this={sidebar}
34
+ style="height: 100%; flex: 0 0 auto; overflow: auto; width: {sidebarWidth}; {minWidth} {maxWidth}">
35
+ <slot name="sidebar"></slot>
36
+ </div>
37
+ {#if sidebarResize}
38
+ <Split direction="vertical" bindingPanel={sidebar}/>
39
+ {/if}
39
40
  {/if}
40
- <div style="height: 100%; flex: 1 1 auto; overflow: auto">
41
+ <div style="height: 100%; flex: 1 1 auto; overflow: hidden">
41
42
  <slot></slot>
42
43
  </div>
43
44
  </div>
@@ -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;
@@ -32,7 +32,8 @@
32
32
  table = new UniDataTable(id, indicatorColumn.width);
33
33
  })
34
34
  const sortRows = (compareFun: CompareFunction, descending: boolean) => {
35
- //table.(compareFun, descending);
35
+ let oList = list.sort(compareFun);
36
+ displayList = descending ? oList.reverse() : oList;
36
37
  rows = table.rows;
37
38
  }
38
39
 
@@ -46,11 +47,12 @@
46
47
 
47
48
  $: selectedRows = selectedRows ?? [];
48
49
 
50
+ $: displayList = [...list];
49
51
 
50
52
  $: {
51
53
  if (table && columns) {
52
54
  table.setColumns(columns)
53
- table.data = list;
55
+ table.data = displayList;
54
56
  rows = table.rows;
55
57
  dataColumns = table.columns;
56
58
  colStyle = table.generateTemplateStyle();
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
 
3
3
  import ActionsRow from "./ActionsRow.svelte";
4
- import type {ActionsColumn} from "..";
4
+ import type ActionsColumn from "../lib/ActionsColumn";
5
5
  import type TableRow from "./TableRow";
6
6
  import {onDestroy, onMount} from "svelte";
7
7
 
@@ -13,6 +13,8 @@
13
13
 
14
14
  export let expandRow: TableRow;
15
15
 
16
+ export let rowHeight: number;
17
+
16
18
  const handleActionPanelScroll = (e: Event) => {
17
19
  scrollTop = e.target?.scrollTop;
18
20
  }
@@ -43,15 +45,18 @@
43
45
 
44
46
  </script>
45
47
 
46
- <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;">
47
49
  <div bind:this={scrollPanel} class="scroll-panel" on:scroll|passive={handleActionPanelScroll}>
48
- {#each rows as row, idx}
49
- <ActionsRow {row} parentRect={rect} alternative={idx % 2 == 1} width={actionsColumn.width} actions={actionsColumn.getActions(row)}/>
50
- {#if row == expandRow}
51
- <div class="inline-panel" style="height: {inlineRowHeight??0}px">
52
- </div>
53
- {/if}
54
- {/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>
55
60
  </div>
56
61
  <div class="bottom-mask-overlay">
57
62
  <!-- 用于匹配中间数据区域的滚动条 -->
@@ -1,4 +1,4 @@
1
- import type { ActionsColumn } from "..";
1
+ import type ActionsColumn from "../lib/ActionsColumn";
2
2
  import type TableRow from "./TableRow";
3
3
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
4
4
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
@@ -19,6 +19,7 @@ declare const ActionsPanel: $$__sveltets_2_IsomorphicComponent<{
19
19
  rows: Array<TableRow>;
20
20
  inlineRowHeight?: number;
21
21
  expandRow: TableRow;
22
+ rowHeight: number;
22
23
  }, {
23
24
  [evt: string]: CustomEvent<any>;
24
25
  }, {}, {}, string>;
@@ -6,8 +6,6 @@
6
6
  import {onDestroy, onMount, tick} from "svelte";
7
7
  import utils from "../../common/utils";
8
8
  import PopupMenu from "./PopupMenu.svelte";
9
-
10
-
11
9
  export let row: TableRow;
12
10
  export let actions: Array<RowAction>;
13
11
  export let alternative: boolean;
@@ -15,6 +13,11 @@
15
13
 
16
14
  export let width: number;
17
15
 
16
+ export let rowHeight: number;
17
+
18
+ let style: string;
19
+
20
+
18
21
  let actionList: Array<RowAction> = [...actions]
19
22
  let popupList: Array<RowAction> = [];
20
23
 
@@ -78,8 +81,10 @@
78
81
  checkOverflow();
79
82
  }
80
83
 
84
+ $: style = rowHeight== null ? '' : `height: ${rowHeight}px`
85
+
81
86
  </script>
82
- <div class="table-row" class:alternative style="position: relative; width: {width}px; height: 36px; display: block;">
87
+ <div class="table-row" class:alternative style="position: relative; width: {width}px; display: block; {style}">
83
88
  <div bind:this={cell}
84
89
  style="width: max-content; overflow-x: auto; white-space: nowrap; top: 50%; position: relative; transform: translateY(-50%);">
85
90
  {#each actionList as action}
@@ -19,6 +19,7 @@ declare const ActionsRow: $$__sveltets_2_IsomorphicComponent<{
19
19
  alternative: boolean;
20
20
  parentRect: DOMRect;
21
21
  width: number;
22
+ rowHeight: number;
22
23
  }, {
23
24
  [evt: string]: CustomEvent<any>;
24
25
  }, {}, {}, string>;
@@ -107,7 +107,7 @@
107
107
 
108
108
  </script>
109
109
  <div class="data-content-panel">
110
- <FixedColumnsPanel {indicatorColumn} {expandRow} {fixedCols} {inlineRowHeight} {rows} bind:scrollTop {handleRowExpand}
110
+ <FixedColumnsPanel {indicatorColumn} {expandRow} {rowHeight} {fixedCols} {inlineRowHeight} {rows} bind:scrollTop {handleRowExpand}
111
111
  {handleRowSelectChange}/>
112
112
  <div class="data-view-panel" bind:this={dataPanel} on:scroll|passive={handleDataTableScroll} on:wheel|passive={handleWheelEvent}
113
113
  style="{actionsColumn == null ? 'overflow-y: scroll' : ''}">
@@ -143,6 +143,6 @@
143
143
  {/if}
144
144
  </div>
145
145
  {#if actionsColumn}
146
- <ActionPanel {expandRow} {actionsColumn} {rows} {inlineRowHeight} bind:scrollTop/>
146
+ <ActionPanel {expandRow} {rowHeight} {actionsColumn} {rows} {inlineRowHeight} bind:scrollTop/>
147
147
  {/if}
148
148
  </div>
@@ -16,6 +16,8 @@
16
16
 
17
17
  export let expandRow: TableRow;
18
18
 
19
+ export let rowHeight: number;
20
+
19
21
  let width: number = indicatorColumn.width;
20
22
 
21
23
  export let inlineRowHeight: number = 0;
@@ -32,9 +34,9 @@
32
34
  <div class="fixed-panel" style="width: {width}px">
33
35
  <div class="scroll-panel" style="overflow-y: hidden">
34
36
  <div style="top: {-scrollTop}px">
35
- {#each rows??[] as row, idx}
37
+ {#each rows ?? [] as row, idx}
36
38
  <FixedRow rowNo={idx+1} {row} selected={row.selected} alternative={idx % 2 == 1} {selectable} cols={fixedCols}
37
- {expandable} {handleRowExpand} {handleRowSelectChange}/>
39
+ {rowHeight} {expandable} {handleRowExpand} {handleRowSelectChange}/>
38
40
  {#if row == expandRow}
39
41
  <div class="inline-panel" style="height: {inlineRowHeight}px">
40
42
 
@@ -23,6 +23,7 @@ declare const FixedColumnsPanel: $$__sveltets_2_IsomorphicComponent<{
23
23
  handleRowExpand: RowEventHandler;
24
24
  handleRowSelectChange: TableEventHandler;
25
25
  expandRow: TableRow;
26
+ rowHeight: number;
26
27
  inlineRowHeight?: number;
27
28
  }, {
28
29
  [evt: string]: CustomEvent<any>;
@@ -15,12 +15,9 @@
15
15
  export let handleRowSelectChange: RowEventHandler;
16
16
  export let selected: boolean = row.selected;
17
17
 
18
+ export let rowHeight: number;
18
19
 
19
-
20
- // const handleCheckBoxClick = (e: MouseEvent) => {
21
- // e.stopPropagation();
22
- // toggleRowSectionHandler?.(row);
23
- // }
20
+ let style: string;
24
21
 
25
22
  const showInlineData = (e: MouseEvent) => {
26
23
  handleRowExpand?.(row);
@@ -33,8 +30,10 @@
33
30
  handleRowSelectChange(row.selected);
34
31
  }
35
32
 
33
+ $: style = rowHeight== null ? '' : `height: ${rowHeight}px`
34
+
36
35
  </script>
37
- <div class="table-row" class:alternative >
36
+ <div class="table-row" class:alternative {style}>
38
37
  <div class="indicator-cell">
39
38
  {#if selectable}
40
39
  <input type="checkbox" bind:checked={selected}/>
@@ -24,6 +24,7 @@ declare const FixedRow: $$__sveltets_2_IsomorphicComponent<{
24
24
  handleRowExpand: RowEventHandler;
25
25
  handleRowSelectChange: RowEventHandler;
26
26
  selected?: boolean;
27
+ rowHeight: number;
27
28
  }, {
28
29
  [evt: string]: CustomEvent<any>;
29
30
  }, {}, {}, string>;
@@ -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 {
@@ -1510,6 +1512,7 @@
1510
1512
  height: var(--uniface-card-header-height, 54px);
1511
1513
  border-bottom: 1px solid var(--uniface-card-inside-border-color, #E2E8F0);
1512
1514
  box-sizing: border-box;
1515
+ font-weight: 600;
1513
1516
  }
1514
1517
  .uniface-card > div .card-header.simple {
1515
1518
  line-height: var(--uniface-card-header-height, 54px);
@@ -3631,6 +3634,11 @@
3631
3634
  flex-wrap: nowrap;
3632
3635
  flex-direction: row;
3633
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);
3634
3642
  }
3635
3643
  .uniface-data-table.row-border .table-row {
3636
3644
  border-bottom: 1px solid var(--uniface-data-table-row-border-color, #f0f0f0);
@@ -3748,13 +3756,19 @@
3748
3756
  height: 100%;
3749
3757
  position: relative;
3750
3758
  box-sizing: border-box;
3751
- padding: 0 4px;
3759
+ padding: 4px;
3752
3760
  }
3753
3761
  .uniface-data-table .data-content-panel .table-row .table-data-cell > div {
3754
3762
  position: relative;
3755
3763
  top: 50%;
3756
3764
  transform: translateY(-50%);
3757
3765
  }
3766
+ .uniface-data-table .data-content-panel .table-row .table-data-cell .cell-text {
3767
+ overflow: hidden;
3768
+ }
3769
+ .uniface-data-table .data-content-panel .table-row .table-data-cell:first-child {
3770
+ padding-left: 8px;
3771
+ }
3758
3772
  .uniface-data-table .data-content-panel .table-row .table-data-cell:last-child {
3759
3773
  padding: 0;
3760
3774
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ticatec/uniface-element",
3
- "version": "0.1.9",
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
- };