@ticatec/uniface-element 0.1.12 → 0.1.14

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.
Files changed (58) hide show
  1. package/dist/app-layout/ClassicLayout.svelte +1 -1
  2. package/dist/box/Box.svelte +8 -0
  3. package/dist/box/Box.svelte.d.ts +3 -0
  4. package/dist/card/Card.svelte +3 -2
  5. package/dist/card/CardAction.d.ts +1 -0
  6. package/dist/card/CommonCardActionBar.svelte +3 -3
  7. package/dist/checkbox/CheckBox.svelte +1 -1
  8. package/dist/data-table/DataTable.svelte +83 -54
  9. package/dist/data-table/DataTable.svelte.d.ts +7 -5
  10. package/dist/data-table/UniDataTable.d.ts +4 -2
  11. package/dist/data-table/UniDataTable.js +8 -7
  12. package/dist/data-table/lib/IndicatorColumn.d.ts +2 -11
  13. package/dist/data-table/parts/ActionsPanel.svelte +9 -2
  14. package/dist/data-table/parts/ActionsPanel.svelte.d.ts +1 -1
  15. package/dist/data-table/parts/ActionsRow.svelte +3 -3
  16. package/dist/data-table/parts/ContentPanel.svelte +65 -77
  17. package/dist/data-table/parts/ContentPanel.svelte.d.ts +15 -8
  18. package/dist/data-table/parts/DataCell.svelte +2 -2
  19. package/dist/data-table/parts/DataRow.svelte +2 -4
  20. package/dist/data-table/parts/FixedColumnsPanel.svelte +52 -13
  21. package/dist/data-table/parts/FixedColumnsPanel.svelte.d.ts +12 -5
  22. package/dist/data-table/parts/FixedHeaderPanel.svelte +74 -11
  23. package/dist/data-table/parts/FixedHeaderPanel.svelte.d.ts +8 -2
  24. package/dist/data-table/parts/FixedRow.svelte +30 -17
  25. package/dist/data-table/parts/FixedRow.svelte.d.ts +6 -3
  26. package/dist/data-table/parts/TableHeaderPanel.svelte +32 -63
  27. package/dist/data-table/parts/TableHeaderPanel.svelte.d.ts +6 -10
  28. package/dist/data-table/parts/TableRow.d.ts +0 -10
  29. package/dist/data-table/parts/TableRow.js +0 -29
  30. package/dist/data-table/parts/TableRows.d.ts +0 -2
  31. package/dist/data-table/parts/TableRows.js +0 -2
  32. package/dist/data-table/parts/TreeRootCell.svelte +3 -0
  33. package/dist/{list-box/ListViewItem.svelte.d.ts → data-table/parts/TreeRootCell.svelte.d.ts} +3 -3
  34. package/dist/date-picker/DatePicker.svelte +5 -0
  35. package/dist/date-picker/DateTimePicker.svelte +6 -1
  36. package/dist/dialog/Dialog.svelte +0 -1
  37. package/dist/index.d.ts +2 -2
  38. package/dist/index.js +2 -2
  39. package/dist/list-box/index.d.ts +1 -2
  40. package/dist/message-box/IMessageBox.d.ts +4 -4
  41. package/dist/message-box/IMessageBox.js +10 -10
  42. package/dist/message-box/MessageBoxBoard.svelte +3 -3
  43. package/dist/message-box/index.d.ts +2 -2
  44. package/dist/message-box/index.js +2 -2
  45. package/dist/number-range/NumberRange.svelte +3 -2
  46. package/dist/number-range/NumberRange.svelte.d.ts +1 -0
  47. package/dist/options-multi-select/OptionsMultiSelect.svelte +19 -3
  48. package/dist/options-multi-select/OptionsMultiSelect.svelte.d.ts +1 -0
  49. package/dist/options-select/OptionsSelect.svelte +8 -2
  50. package/dist/pagination-panel/PaginationPanel.svelte +1 -1
  51. package/dist/pagination-panel/PaginationPanel.svelte.d.ts +1 -1
  52. package/dist/split/Split.svelte +14 -2
  53. package/dist/split/Split.svelte.d.ts +1 -0
  54. package/dist/text-editor/TextEditor.svelte +7 -1
  55. package/dist/text-editor/TextEditor.svelte.d.ts +1 -0
  56. package/dist/ticatec-uniface-web.css +172 -208
  57. package/package.json +1 -1
  58. package/dist/list-box/ListViewItem.svelte +0 -6
@@ -2,47 +2,58 @@
2
2
 
3
3
  import DataRow from "./DataRow.svelte";
4
4
  import type DataColumn from "../lib/DataColumn";
5
- import type ActionsColumn from "../lib/ActionsColumn";
6
- import type IndicatorColumn from "../lib/IndicatorColumn";
7
-
8
- import iconLoading from "../assets/loading.gif"
9
5
  import type TableRow from "./TableRow";
10
- import type {TableEventHandler} from "../UniDataTable";
11
- import ActionPanel from "./ActionsPanel.svelte";
12
- import FixedColumnsPanel from "./FixedColumnsPanel.svelte";
13
- import {onMount, tick} from "svelte";
6
+ import {onMount} from "svelte";
7
+ import TableHeaderPanel from "./TableHeaderPanel.svelte";
8
+ import UniDataTable, {type TableEventHandler} from "../UniDataTable";
9
+ import {OrderDirection} from "../lib/OrderDirection";
10
+
11
+
12
+ export let columns: Array<DataColumn>;
13
+ export let rows: Array<TableRow>;
14
+ export let orderColumn: DataColumn ;
15
+ export let orderDirection: OrderDirection;
14
16
 
17
+ export let emptyIndicator: string | null = null;
15
18
 
16
- export let columns: Array<DataColumn>; //columns={dataColumns}
17
- export let rows: Array<TableRow>; //{rows}
19
+ export let list: Array<any>;
18
20
 
19
- export let width: number = 0; //width={tabWidth}
21
+ export let expandRow: TableRow | null;
20
22
 
21
- export let actionsColumn: ActionsColumn | null; //{actionsColumn}
22
- export let indicatorColumn: IndicatorColumn; //{indicatorColumn}
23
- export let scrollLeft: number = 0; //bind:scrollLeft
24
- export let rowHeight: number; //{ rowHeight}
23
+ let width: number = 0;
24
+
25
+ export let scrollTop: number = 0;
26
+ export let rowHeight: number;
25
27
  export let inlineRowHeight: number = 80;
26
- export let handleRowSelectChange: TableEventHandler; //{handleRowSelectChange}
27
28
 
29
+ export let inlineComponent: any = null;
30
+
31
+ export let table: UniDataTable;
32
+
33
+ export let showVerticalScroll: boolean = false;
34
+ export let displayHorizontalScroll: boolean = true;
28
35
 
29
- let hasOperation: boolean = actionsColumn != null;
30
- let scrollTop: number = 0;
36
+ export let handleWidthChange: TableEventHandler;
37
+
38
+ export let handleCellClick: (col: DataColumn) => any;
39
+
40
+ export let tabWidth: number;
41
+
42
+ let scrollLeft: number = 0;
31
43
 
32
44
  let resizeObserver: ResizeObserver;
33
- let dataPanel: any;
34
- let tabWidth: number;
45
+ let viewPanel: any;
35
46
 
36
47
  onMount(async () => {
37
48
  resizeObserver = new ResizeObserver(() => {
38
49
  // 每次 div 尺寸变化时,更新 clientWidth
39
- tabWidth = dataPanel?.clientWidth;
50
+ viewWidth = Math.round(viewPanel?.clientWidth)-1;
40
51
  });
41
- resizeObserver.observe(dataPanel);
52
+ resizeObserver.observe(viewPanel);
42
53
  });
43
54
 
44
55
  const handleDataTableScroll = (e: Event) => {
45
- if (!hasOperation) {
56
+ if (showVerticalScroll) {
46
57
  scrollTop = e.target?.scrollTop;
47
58
  }
48
59
  scrollLeft = e.target?.scrollLeft;
@@ -51,7 +62,7 @@
51
62
 
52
63
  const handleWheelEvent = (e: WheelEvent) => {
53
64
  let maxSh = dataPanel.scrollHeight - dataPanel.clientHeight;
54
- if (hasOperation && maxSh > 0) {
65
+ if (!showVerticalScroll && maxSh > 0) {
55
66
  if (e.deltaY != 0) {
56
67
  scrollTop = scrollTop + e.deltaY;
57
68
  if (scrollTop < 0) {
@@ -67,82 +78,59 @@
67
78
  }
68
79
  }
69
80
 
70
- let expandRow: any = null;
71
- let loadingRow: any = null;
72
- let inlineComponent: any;
73
- let inlineError: string | null = null;
74
-
75
- let fixedCols: Array<DataColumn> = [];
81
+ $: if (dataPanel && scrollTop > -1 && !showVerticalScroll) {
82
+ console.log('移动', scrollTop)
83
+ dataPanel.scrollTop = scrollTop;
84
+ }
76
85
 
77
86
 
78
- const handleRowExpand = async (row: TableRow) => {
79
- if (row == expandRow) {
80
- row.expand = false;
81
- expandRow = null;
82
- } else {
83
- if (expandRow != null) {
84
- expandRow.expand = false;
85
- }
86
- expandRow = row;
87
+ $: {
88
+ if (table) {
89
+ table.data = [...list];
90
+ rows = table.rows;
87
91
  }
88
- inlineComponent = null;
89
- await tick();
90
- loadingRow = true;
91
- try {
92
- inlineError = null;
93
- inlineComponent = await indicatorColumn?.buildInlineComponent(row.data);
94
- } catch (ex) {
95
- inlineError = indicatorColumn.getInlineError?.(ex as Error) ?? 'Unknown Error';
96
- }
97
- loadingRow = false;
98
92
  }
99
93
 
100
- let rowWidth: number;
101
94
 
102
- $: rowWidth = Math.max(width, tabWidth);
95
+ let viewWidth: number;
96
+ $: rowWidth = Math.max(viewWidth, tabWidth);
103
97
 
104
- $: if (dataPanel && scrollTop > -1) {
105
- dataPanel.scrollTop = scrollTop;
98
+ $: if (columns) {
99
+ tabWidth = table.width;
106
100
  }
107
101
 
102
+ let hasWhitespace: boolean = true;
103
+ $: hasWhitespace = viewWidth > tabWidth;
104
+
105
+
106
+ let top: string = "0px";
107
+ let dataPanel: any;
108
+
109
+
108
110
  </script>
109
- <div class="data-content-panel">
110
- <FixedColumnsPanel {indicatorColumn} {expandRow} {rowHeight} {fixedCols} {inlineRowHeight} {rows} bind:scrollTop {handleRowExpand}
111
- {handleRowSelectChange}/>
111
+ <div class="data-content-panel" bind:this={viewPanel}>
112
+
113
+ <TableHeaderPanel {handleCellClick} {orderColumn} {orderDirection} dataCols={columns} {scrollLeft} width={tabWidth} {hasWhitespace} {handleWidthChange}/>
112
114
  <div class="data-view-panel" bind:this={dataPanel} on:scroll|passive={handleDataTableScroll} on:wheel|passive={handleWheelEvent}
113
- style="{actionsColumn == null ? 'overflow-y: scroll' : ''}">
115
+ style="overflow-x: {displayHorizontalScroll ? 'scroll' : 'auto'}; overflow-y: {showVerticalScroll ?'auto': 'hidden' };">
114
116
  {#if rows && rows.length > 0}
115
- <div style="box-sizing: border-box; width: {rowWidth}px;">
117
+ <div style="box-sizing: border-box; width: {rowWidth}px; top: {top}">
116
118
  {#each rows as row, idx}
117
- <DataRow {rowHeight} {row} {columns} alternative={idx % 2 == 1} />
118
- {#if row == expandRow}
119
+ <DataRow {rowHeight} {row} {columns} alternative={idx % 2 == 1}/>
120
+ {#if row == expandRow && inlineComponent}
119
121
  <div class="expand-data-row" bind:clientHeight={inlineRowHeight}
120
122
  style="position: relative; box-sizing: content-box; width: 100%; height: auto">
121
123
  <div class="inline-panel">
122
- {#if loadingRow}
123
- <div style="text-align: center; padding: 16px">
124
- <img src={iconLoading} width="32" height="32" style="vertical-align: middle"/>
125
- <span style="">{indicatorColumn.loadingIndicator ?? 'Loading data...'}</span>
126
- </div>
127
- {:else if inlineError}
128
- <div style="text-align: center; padding: 16px">
129
- <span style="">{inlineError}</span>
130
- </div>
131
- {:else}
132
- <svelte:component this={inlineComponent} data={row}/>
133
- {/if}
124
+ <svelte:component this={inlineComponent} data={row}/>
134
125
  </div>
135
126
  </div>
136
127
  {/if}
137
128
  {/each}
138
129
  </div>
139
130
  {:else}
140
- <div class="empty-content-board" style="width: {width}px;">
141
- <div>{indicatorColumn.emptyIndicator ?? "Empty dataset."}</div>
131
+ <div class="empty-content-board" style="width: 100%">
132
+ <div>{emptyIndicator ?? "Empty dataset."}</div>
142
133
  </div>
143
134
  {/if}
144
135
  </div>
145
- {#if actionsColumn}
146
- <ActionPanel {expandRow} {rowHeight} {actionsColumn} {rows} {inlineRowHeight} bind:scrollTop/>
147
- {/if}
148
136
  </div>
@@ -1,8 +1,7 @@
1
1
  import type DataColumn from "../lib/DataColumn";
2
- import type ActionsColumn from "../lib/ActionsColumn";
3
- import type IndicatorColumn from "../lib/IndicatorColumn";
4
2
  import type TableRow from "./TableRow";
5
- import type { TableEventHandler } from "../UniDataTable";
3
+ import UniDataTable, { type TableEventHandler } from "../UniDataTable";
4
+ import { OrderDirection } from "../lib/OrderDirection";
6
5
  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> {
7
6
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
8
7
  $$bindings?: Bindings;
@@ -19,13 +18,21 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
19
18
  declare const ContentPanel: $$__sveltets_2_IsomorphicComponent<{
20
19
  columns: Array<DataColumn>;
21
20
  rows: Array<TableRow>;
22
- width?: number;
23
- actionsColumn: ActionsColumn | null;
24
- indicatorColumn: IndicatorColumn;
25
- scrollLeft?: number;
21
+ orderColumn: DataColumn;
22
+ orderDirection: OrderDirection;
23
+ emptyIndicator?: string | null;
24
+ list: Array<any>;
25
+ expandRow: TableRow | null;
26
+ scrollTop?: number;
26
27
  rowHeight: number;
27
28
  inlineRowHeight?: number;
28
- handleRowSelectChange: TableEventHandler;
29
+ inlineComponent?: any;
30
+ table: UniDataTable;
31
+ showVerticalScroll?: boolean;
32
+ displayHorizontalScroll?: boolean;
33
+ handleWidthChange: TableEventHandler;
34
+ handleCellClick: (col: DataColumn) => any;
35
+ tabWidth: number;
29
36
  }, {
30
37
  [evt: string]: CustomEvent<any>;
31
38
  }, {}, {}, string>;
@@ -18,10 +18,10 @@
18
18
  hint = column.hint?.(data);
19
19
  }
20
20
 
21
- $: col$class = frozen ? `fz-col-${colIdx}` : `col-${colIdx}`;
21
+ $: col$class = frozen ? `fz_col-${colIdx}` : `col-${colIdx}`;
22
22
 
23
23
  </script>
24
- <div class="table-data-cell {col$class}">
24
+ <div class="data-cell {col$class}">
25
25
  <div>
26
26
  {#if column.render}
27
27
  <svelte:component this={column.render.component} {...column.render.props} {data}/>
@@ -11,18 +11,16 @@
11
11
 
12
12
  let style: string = '';
13
13
 
14
-
15
-
16
14
  $: style = rowHeight== null ? '' : `height: ${rowHeight}px`
17
15
 
18
16
 
19
17
  </script>
20
18
 
21
- <div class="table-row" {style} class:alternative aria-hidden="true">
19
+ <div class="data-row" {style} class:alternative aria-hidden="true">
22
20
  {#each columns as col, idx}
23
21
  <DataCell colIdx={idx} data={row.data} column={col}/>
24
22
  {/each}
25
- <div class="table-data-cell" style="border-right: none">
23
+ <div class="data-cell" style="border-right: none; width: unset">
26
24
  </div>
27
25
  </div>
28
26
 
@@ -3,22 +3,33 @@
3
3
  import FixedRow from "./FixedRow.svelte";
4
4
  import type TableRow from "./TableRow";
5
5
  import type {IndicatorColumn} from "..";
6
- import type {RowEventHandler, TableEventHandler} from "../UniDataTable";
6
+ import UniDataTable, {type RowEventHandler, SelectionMode, type TableEventHandler} from "../UniDataTable";
7
7
  import type DataColumn from "../lib/DataColumn";
8
+ import FixedHeaderPanel from "./FixedHeaderPanel.svelte";
9
+ import {tick} from "svelte";
10
+ import {OrderDirection} from "../lib/OrderDirection";
8
11
 
9
12
 
10
- export let fixedCols: Array<DataColumn>;
11
- export let indicatorColumn: IndicatorColumn;
13
+ export let fixedCols: Array<DataColumn> = [];
14
+ export let indicatorColumn: IndicatorColumn | null;
15
+ export let width: number;
12
16
  export let scrollTop: number = 0;
13
17
  export let rows: Array<TableRow>;
18
+ export let table: UniDataTable;
19
+ export let handleWidthChange: TableEventHandler;
14
20
  export let handleRowExpand: RowEventHandler;
15
- export let handleRowSelectChange: TableEventHandler;
16
21
 
17
- export let expandRow: TableRow;
22
+ export let handleCellClick: (col: DataColumn) => any;
23
+ export let orderColumn: DataColumn;
24
+ export let orderDirection: OrderDirection;
18
25
 
19
- export let rowHeight: number;
26
+ let selectionMode: SelectionMode = SelectionMode.None;
27
+
28
+ export let selectedRows: Array<any> = [];
20
29
 
21
- let width: number = indicatorColumn.width;
30
+ export let expandRow: TableRow | null;
31
+
32
+ export let rowHeight: number;
22
33
 
23
34
  export let inlineRowHeight: number = 0;
24
35
 
@@ -26,17 +37,45 @@
26
37
  let selectable: boolean = false;
27
38
  let expandable: boolean = false;
28
39
 
29
- $: selectable = indicatorColumn.selectable == true;
30
- $: expandable = indicatorColumn.buildInlineComponent != null;
40
+ $: selectable = indicatorColumn?.selectable == true;
41
+ $: expandable = indicatorColumn?.buildInlineComponent != null;
42
+
43
+ const handleToggleSelectAll = async (value: boolean) => {
44
+ selectedRows = value ? rows.map(item => item.data) : [];
45
+ await tick();
46
+ selectionMode = value ? SelectionMode.All : SelectionMode.None;
47
+ rows = [...rows];
48
+ console.log('选中行', selectionMode)
49
+ }
50
+
51
+ const handleRowSelectChange = async (row: TableRow, value: boolean) => {
52
+ if (value) {
53
+ if (selectedRows.indexOf(row.data) < 0) {
54
+ selectedRows = [...selectedRows, row.data];
55
+ }
56
+ } else {
57
+ let pos = selectedRows.indexOf(row.data);
58
+ if (pos > -1) {
59
+ selectedRows.splice(pos, 1);
60
+ selectedRows = [...selectedRows];
61
+ }
62
+ }
63
+ selectionMode = selectedRows.length == rows.length ? SelectionMode.All : selectedRows.length == 0 ? SelectionMode.None : SelectionMode.Partial;
64
+ }
65
+
66
+
67
+ $: console.log('选中行', selectionMode)
31
68
 
32
69
  </script>
33
70
 
34
- <div class="fixed-panel" style="width: {width}px">
35
- <div class="scroll-panel" style="overflow-y: hidden">
71
+ <div class="left-fixed-panel" style="width: {width}px">
72
+ <FixedHeaderPanel {selectionMode} {orderColumn} {orderDirection} {handleCellClick} {handleWidthChange} columns={fixedCols} {indicatorColumn}
73
+ {handleToggleSelectAll} {rowHeight}/>
74
+ <div class="rows-container">
36
75
  <div style="top: {-scrollTop}px">
37
76
  {#each rows ?? [] as row, idx}
38
- <FixedRow rowNo={idx+1} {row} selected={row.selected} alternative={idx % 2 == 1} {selectable} cols={fixedCols}
39
- {rowHeight} {expandable} {handleRowExpand} {handleRowSelectChange}/>
77
+ <FixedRow rowNo={idx+1} {row} selected={selectedRows.indexOf(row.data) > -1} alternative={idx % 2 == 1} {selectable}
78
+ cols={fixedCols} {expandRow} {rowHeight} {expandable} {handleRowExpand} {handleRowSelectChange} {indicatorColumn}/>
40
79
  {#if row == expandRow}
41
80
  <div class="inline-panel" style="height: {inlineRowHeight}px">
42
81
 
@@ -1,7 +1,8 @@
1
1
  import type TableRow from "./TableRow";
2
2
  import type { IndicatorColumn } from "..";
3
- import type { RowEventHandler, TableEventHandler } from "../UniDataTable";
3
+ import UniDataTable, { type RowEventHandler, type TableEventHandler } from "../UniDataTable";
4
4
  import type DataColumn from "../lib/DataColumn";
5
+ import { OrderDirection } from "../lib/OrderDirection";
5
6
  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> {
6
7
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
7
8
  $$bindings?: Bindings;
@@ -16,13 +17,19 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
16
17
  z_$$bindings?: Bindings;
17
18
  }
18
19
  declare const FixedColumnsPanel: $$__sveltets_2_IsomorphicComponent<{
19
- fixedCols: Array<DataColumn>;
20
- indicatorColumn: IndicatorColumn;
20
+ fixedCols?: Array<DataColumn>;
21
+ indicatorColumn: IndicatorColumn | null;
22
+ width: number;
21
23
  scrollTop?: number;
22
24
  rows: Array<TableRow>;
25
+ table: UniDataTable;
26
+ handleWidthChange: TableEventHandler;
23
27
  handleRowExpand: RowEventHandler;
24
- handleRowSelectChange: TableEventHandler;
25
- expandRow: TableRow;
28
+ handleCellClick: (col: DataColumn) => any;
29
+ orderColumn: DataColumn;
30
+ orderDirection: OrderDirection;
31
+ selectedRows?: Array<any>;
32
+ expandRow: TableRow | null;
26
33
  rowHeight: number;
27
34
  inlineRowHeight?: number;
28
35
  }, {
@@ -2,14 +2,18 @@
2
2
 
3
3
  import type DataColumn from "../lib/DataColumn";
4
4
  import type {IndicatorColumn} from "..";
5
- import {type SelectionEventHandler, SelectionMode} from "../UniDataTable";
5
+ import {type SelectionEventHandler, SelectionMode, type TableEventHandler} from "../UniDataTable";
6
6
  import utils from "../../common/utils";
7
+ import {OrderDirection} from "../lib/OrderDirection";
8
+ import i18n from "../../i18nContext";
7
9
 
8
10
  export let columns: Array<DataColumn>;
9
- export let indicatorColumn: IndicatorColumn;
10
-
11
-
12
-
11
+ export let indicatorColumn: IndicatorColumn | null;
12
+ export let handleWidthChange: TableEventHandler;
13
+ export let rowHeight;
14
+ export let handleCellClick: (col: DataColumn) => any;
15
+ export let orderColumn: DataColumn;
16
+ export let orderDirection: OrderDirection;
13
17
  export let selectionMode: SelectionMode;
14
18
 
15
19
  export let handleToggleSelectAll: SelectionEventHandler;
@@ -33,13 +37,72 @@
33
37
  indeterminate = true;
34
38
  }
35
39
 
40
+ let resizeCol: any;
41
+ let startX: number = 0;
42
+ let startWidth: number = 0;
43
+ const handleResizeMouseDown = (col: DataColumn) => (event: MouseEvent) => {
44
+ if (col.resizable) {
45
+ resizeCol = col;
46
+ startX = event.clientX;
47
+ startWidth = resizeCol.width;
48
+
49
+ document.body.style.cursor = 'col-resize';
50
+ // 绑定鼠标移动和松开事件
51
+ window.addEventListener('mousemove', onMouseMove);
52
+ window.addEventListener('mouseup', onMouseUp);
53
+ }
54
+ }
55
+ const onMouseMove = (event: MouseEvent) => {
56
+ if (resizeCol !== null) {
57
+ const diff = event.clientX - startX;
58
+ let w = startWidth + diff;
59
+ if (w > (resizeCol.minWidth ?? 50)) {
60
+ resizeCol.width = startWidth + diff;
61
+ }
62
+
63
+ }
64
+ handleWidthChange?.();
65
+ }
66
+
67
+ // 结束拖动
68
+ function onMouseUp() {
69
+ resizeCol = null;
70
+ document.body.style.cursor = 'default';
71
+ window.removeEventListener('mousemove', onMouseMove);
72
+ window.removeEventListener('mouseup', onMouseUp);
73
+ }
36
74
 
37
75
  </script>
38
76
 
39
- <div class="header-indicator" style="width: {indicatorColumn.width}px">
40
- <div>
41
- {#if indicatorColumn.selectable==true}
42
- <input type="checkbox" tabindex="-1" bind:checked {indeterminate} on:click={handleHeaderCheckBoxClick}/>
43
- {/if}
44
- </div>
77
+ <div class="header-row" style="flex: 0 0 auto; {rowHeight}px">
78
+ {#if indicatorColumn}
79
+ <div class="data-cell" style="width: {indicatorColumn.width}px">
80
+ {#if indicatorColumn?.selectable === true}
81
+ <div style="text-align: center" class="vertical-center">
82
+ <input type="checkbox" tabindex="-1" bind:checked {indeterminate} on:click={handleHeaderCheckBoxClick}/>
83
+ </div>
84
+ {:else }
85
+ <div style="text-align: center" class="vertical-center">
86
+ {#if indicatorColumn.displayNo}
87
+ <span>{i18n.getText('uniface.dataTable.rowNo', '#No')}</span>
88
+ {/if}
89
+ </div>
90
+ {/if}
91
+ <div class="header-cell-divider"></div>
92
+ </div>
93
+ {/if}
94
+ {#each columns as column, index}
95
+ <div class="fz_col-{index} data-cell" class:sortable={column.compareFunction!=null} style="text-align: center">
96
+ <div class:sortable={column.compareFunction != null} on:click={handleCellClick(column)} aria-hidden="true" class="vertical-center">
97
+ <span>{column.text}</span>
98
+ {#if column === orderColumn}
99
+ <i style="margin-left: 2px; font-size: 12px; position: absolute; top: 0; right: 4px"
100
+ class={orderDirection===OrderDirection.Ascending ? 'uniface-icon-chevron-up' : 'uniface-icon-chevron-down'}></i>
101
+ {/if}
102
+ </div>
103
+
104
+ <div class="header-cell-divider" class:resizer={column.resizable} aria-hidden="true"
105
+ on:mousedown={handleResizeMouseDown(column)}></div>
106
+ </div>
107
+ {/each}
45
108
  </div>
@@ -1,6 +1,7 @@
1
1
  import type DataColumn from "../lib/DataColumn";
2
2
  import type { IndicatorColumn } from "..";
3
- import { type SelectionEventHandler, SelectionMode } from "../UniDataTable";
3
+ import { type SelectionEventHandler, SelectionMode, type TableEventHandler } from "../UniDataTable";
4
+ import { OrderDirection } from "../lib/OrderDirection";
4
5
  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> {
5
6
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
6
7
  $$bindings?: Bindings;
@@ -16,7 +17,12 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
16
17
  }
17
18
  declare const FixedHeaderPanel: $$__sveltets_2_IsomorphicComponent<{
18
19
  columns: Array<DataColumn>;
19
- indicatorColumn: IndicatorColumn;
20
+ indicatorColumn: IndicatorColumn | null;
21
+ handleWidthChange: TableEventHandler;
22
+ rowHeight: any;
23
+ handleCellClick: (col: DataColumn) => any;
24
+ orderColumn: DataColumn;
25
+ orderDirection: OrderDirection;
20
26
  selectionMode: SelectionMode;
21
27
  handleToggleSelectAll: SelectionEventHandler;
22
28
  }, {
@@ -1,9 +1,10 @@
1
1
  <script lang="ts">
2
2
 
3
3
  import type TableRow from "./TableRow";
4
- import type {RowEventHandler} from "../UniDataTable";
4
+ import type {RowEventHandler, RowSelectEventHandler} from "../UniDataTable";
5
5
  import DataCell from "./DataCell.svelte";
6
6
  import type DataColumn from "../lib/DataColumn";
7
+ import type {IndicatorColumn} from "../..";
7
8
 
8
9
  export let selectable: boolean = false;
9
10
  export let rowNo: number;
@@ -12,11 +13,15 @@
12
13
  export let row: TableRow;
13
14
  export let alternative: boolean;
14
15
  export let handleRowExpand: RowEventHandler;
15
- export let handleRowSelectChange: RowEventHandler;
16
- export let selected: boolean = row.selected;
16
+ export let handleRowSelectChange: RowSelectEventHandler;
17
+ export let selected: boolean;
18
+
19
+ export let expandRow: any = null;
17
20
 
18
21
  export let rowHeight: number;
19
22
 
23
+ export let indicatorColumn: IndicatorColumn | null;
24
+
20
25
  let style: string;
21
26
 
22
27
  const showInlineData = (e: MouseEvent) => {
@@ -25,24 +30,32 @@
25
30
  e.stopPropagation();
26
31
  }
27
32
 
28
- $: if (row.selected != selected) {
29
- row.selected = selected;
30
- handleRowSelectChange(row);
33
+ $: {
34
+ handleRowSelectChange(row, selected);
31
35
  }
32
36
 
33
- $: style = rowHeight== null ? '' : `height: ${rowHeight}px`
37
+ $: style = rowHeight == null ? '' : `height: ${rowHeight}px`
34
38
 
35
39
  </script>
36
- <div class="table-row" class:alternative {style}>
37
- <div class="indicator-cell">
38
- {#if selectable}
39
- <input type="checkbox" bind:checked={selected}/>
40
- {/if}
41
- <span>{rowNo}</span>
42
- {#if expandable}
43
- <i class={row.expand ? 'uniface-icon-folder' : "uniface-icon-folder-plus"} aria-hidden="true" on:click={showInlineData}></i>
44
- {/if}
45
- </div>
40
+ <div class="data-row" class:alternative style="width: 100%; {style}">
41
+ {#if indicatorColumn}
42
+ <div class="data-cell indicator-cell" style="width: {indicatorColumn.width}px">
43
+ {#if selectable}
44
+ <input type="checkbox" bind:checked={selected}/>
45
+ {/if}
46
+
47
+ {#if expandable}
48
+ <div class="expand-icon" style="">
49
+ <i class={row == expandRow ? 'uniface-icon-folder' : "uniface-icon-folder-plus"} aria-hidden="true" on:click={showInlineData}></i>
50
+ </div>
51
+ {/if}
52
+ {#if indicatorColumn.displayNo}
53
+ <div style="margin-left: 4px; width: 20px; text-align: left">
54
+ <span>{rowNo}</span>
55
+ </div>
56
+ {/if}
57
+ </div>
58
+ {/if}
46
59
  {#each cols as column, colIdx}
47
60
  <DataCell frozen={true} {colIdx} {column} data={row.data}/>
48
61
  {/each}
@@ -1,6 +1,7 @@
1
1
  import type TableRow from "./TableRow";
2
- import type { RowEventHandler } from "../UniDataTable";
2
+ import type { RowEventHandler, RowSelectEventHandler } from "../UniDataTable";
3
3
  import type DataColumn from "../lib/DataColumn";
4
+ import type { IndicatorColumn } from "../..";
4
5
  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> {
5
6
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
6
7
  $$bindings?: Bindings;
@@ -22,9 +23,11 @@ declare const FixedRow: $$__sveltets_2_IsomorphicComponent<{
22
23
  row: TableRow;
23
24
  alternative: boolean;
24
25
  handleRowExpand: RowEventHandler;
25
- handleRowSelectChange: RowEventHandler;
26
- selected?: boolean;
26
+ handleRowSelectChange: RowSelectEventHandler;
27
+ selected: boolean;
28
+ expandRow?: any;
27
29
  rowHeight: number;
30
+ indicatorColumn: IndicatorColumn | null;
28
31
  }, {
29
32
  [evt: string]: CustomEvent<any>;
30
33
  }, {}, {}, string>;