@ticatec/uniface-element 0.1.13 → 0.1.15

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 (51) hide show
  1. package/dist/concise-data-table/Column.d.ts +9 -0
  2. package/dist/concise-data-table/Column.js +1 -0
  3. package/dist/concise-data-table/ConciseListTable.svelte +154 -0
  4. package/dist/concise-data-table/ConciseListTable.svelte.d.ts +26 -0
  5. package/dist/concise-data-table/DataCell.svelte +22 -0
  6. package/dist/{data-table/parts/LinkButton.svelte.d.ts → concise-data-table/DataCell.svelte.d.ts} +7 -6
  7. package/dist/concise-data-table/DataRow.svelte +15 -0
  8. package/dist/concise-data-table/DataRow.svelte.d.ts +25 -0
  9. package/dist/concise-data-table/TableOptions.d.ts +11 -0
  10. package/dist/concise-data-table/TableOptions.js +1 -0
  11. package/dist/concise-data-table/index.d.ts +5 -0
  12. package/dist/concise-data-table/index.js +2 -0
  13. package/dist/concise-data-table/utils.d.ts +6 -0
  14. package/dist/concise-data-table/utils.js +38 -0
  15. package/dist/data-table/DataTable.svelte +85 -54
  16. package/dist/data-table/DataTable.svelte.d.ts +7 -5
  17. package/dist/data-table/UniDataTable.d.ts +4 -2
  18. package/dist/data-table/UniDataTable.js +8 -7
  19. package/dist/data-table/lib/ActionsColumn.d.ts +0 -4
  20. package/dist/data-table/lib/HrefLink.d.ts +1 -1
  21. package/dist/data-table/lib/IndicatorColumn.d.ts +2 -11
  22. package/dist/data-table/parts/ActionsPanel.svelte +9 -2
  23. package/dist/data-table/parts/ActionsPanel.svelte.d.ts +1 -1
  24. package/dist/data-table/parts/ActionsRow.svelte +3 -3
  25. package/dist/data-table/parts/ContentPanel.svelte +68 -76
  26. package/dist/data-table/parts/ContentPanel.svelte.d.ts +15 -8
  27. package/dist/data-table/parts/DataCell.svelte +3 -3
  28. package/dist/data-table/parts/DataRow.svelte +2 -4
  29. package/dist/data-table/parts/FixedColumnsPanel.svelte +52 -13
  30. package/dist/data-table/parts/FixedColumnsPanel.svelte.d.ts +12 -5
  31. package/dist/data-table/parts/FixedHeaderPanel.svelte +74 -11
  32. package/dist/data-table/parts/FixedHeaderPanel.svelte.d.ts +8 -2
  33. package/dist/data-table/parts/FixedRow.svelte +30 -17
  34. package/dist/data-table/parts/FixedRow.svelte.d.ts +6 -3
  35. package/dist/data-table/parts/HrefCell.svelte +8 -10
  36. package/dist/data-table/parts/TableHeaderPanel.svelte +32 -63
  37. package/dist/data-table/parts/TableHeaderPanel.svelte.d.ts +6 -10
  38. package/dist/data-table/parts/TableRow.d.ts +0 -10
  39. package/dist/data-table/parts/TableRow.js +0 -29
  40. package/dist/data-table/parts/TableRows.d.ts +0 -2
  41. package/dist/data-table/parts/TableRows.js +0 -2
  42. package/dist/data-table/parts/TextCell.svelte +6 -9
  43. package/dist/data-table/parts/TreeRootCell.svelte +3 -0
  44. package/dist/data-table/parts/TreeRootCell.svelte.d.ts +18 -0
  45. package/dist/pagination-panel/PaginationPanel.svelte +1 -1
  46. package/dist/pagination-panel/PaginationPanel.svelte.d.ts +1 -1
  47. package/dist/ticatec-uniface-web.css +214 -217
  48. package/dist/tree-view/TreeNodeView.svelte +6 -8
  49. package/dist/tree-view/TreeUtils.js +2 -2
  50. package/package.json +5 -1
  51. package/dist/data-table/parts/LinkButton.svelte +0 -19
@@ -0,0 +1,9 @@
1
+ export default interface Column {
2
+ title: string;
3
+ field: string;
4
+ width: number;
5
+ align?: "left" | "center" | "right";
6
+ weight?: number;
7
+ formatter?: (value: any) => string;
8
+ escapeHTML?: boolean;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,154 @@
1
+ <script lang="ts">
2
+
3
+ import {onMount, onDestroy, tick} from 'svelte';
4
+ import DataRow from "./DataRow.svelte";
5
+ import {type RowClickHandler, type TableOptions} from "./TableOptions";
6
+ import utils from "./utils";
7
+
8
+ // list array to display
9
+ export let list: Array<any>;
10
+ // Column definitions with configuration
11
+ export let columns: Array<Column>;
12
+ // Enable auto-scroll feature
13
+ export let autoScroll: boolean = false;
14
+ // Milliseconds between each scroll step
15
+ export let scrollInterval: number = 2000;
16
+ export let rowClickHandler: RowClickHandler | null = null;
17
+ //行高
18
+
19
+ // Height of the component in pixels
20
+ //table background color
21
+ export let options: TableOptions;
22
+
23
+ let tabOptions: TableOptions;
24
+
25
+ $: tabOptions = {headerHeight: 36, rowHeight: 32, ...options}
26
+
27
+
28
+ let id = (new Date().getTime() * 1000 + Math.floor(Math.random() * 1000)).toString(36);
29
+ let tableStyle: string = '';
30
+ let tableContainer: any;
31
+ let viewPanel: any;
32
+ let headerRow: any;
33
+ let scrollTimer: any;
34
+ let currentScrollIndex: number = 0;
35
+ let visibleRowCount: number = 0;
36
+
37
+ $: totalWeight = columns.reduce((sum, col) => sum + (col.weight || 0), 0);
38
+
39
+ let rowHeight: number;
40
+
41
+
42
+ let clonedRows: Array<any> = []; // 用于无缝滚动的克隆行
43
+ let viewWidth = 0;
44
+ let viewHeight = 0;
45
+ let resizeObserver: any;
46
+
47
+ onMount(async () => {
48
+ resizeObserver = new ResizeObserver(() => {
49
+ viewWidth = Math.round(viewPanel?.clientWidth) - 1;
50
+ viewHeight = Math.round(viewPanel?.clientHeight) - 1;
51
+ });
52
+ resizeObserver.observe(viewPanel);
53
+ });
54
+
55
+ onDestroy(() => {
56
+ resizeObserver.disconnect();
57
+ })
58
+
59
+
60
+ const setupAutoScroll = async () => {
61
+ if (autoScroll && tableContainer && list.length > 0) {
62
+ await tick();
63
+ const tableBody = tableContainer.querySelector('.table-body');
64
+ if (tableBody && tableBody.children.length > 0) {
65
+ rowHeight = tableBody.children[0].offsetHeight;
66
+ visibleRowCount = Math.floor((tableContainer.offsetHeight - headerRow.offsetHeight) / rowHeight);
67
+ if (list.length <= visibleRowCount) return;
68
+ clonedRows = [...list];
69
+ startAutoScroll();
70
+ }
71
+ }
72
+ }
73
+
74
+ const startAutoScroll = () => {
75
+ // Clear any existing timer
76
+ if (scrollTimer) clearInterval(scrollTimer);
77
+
78
+ currentScrollIndex = 0;
79
+
80
+ scrollTimer = setInterval(() => {
81
+ currentScrollIndex++;
82
+ const tableBody = tableContainer.querySelector('.table-body');
83
+ if (tableBody) {
84
+ tableBody.style.transform = `translateY(-${currentScrollIndex * rowHeight}px)`;
85
+ if (currentScrollIndex >= list.length) {
86
+ setTimeout(() => {
87
+ tableBody.style.transition = 'none';
88
+ tableBody.style.transform = `translateY(0)`;
89
+ currentScrollIndex = 0;
90
+
91
+ // 恢复过渡效果
92
+ setTimeout(() => {
93
+ tableBody.style.transition = 'transform 2s ease';
94
+ }, 50);
95
+ }, 50);
96
+ }
97
+ }
98
+ }, scrollInterval);
99
+ }
100
+
101
+ const stopAutoScroll = () => {
102
+ if (scrollTimer) {
103
+ clearInterval(scrollTimer);
104
+ scrollTimer = null;
105
+ }
106
+ }
107
+
108
+ onMount(async () => {
109
+ await setupAutoScroll();
110
+ });
111
+
112
+ onDestroy(() => {
113
+ stopAutoScroll();
114
+ });
115
+
116
+ $: if (list || autoScroll || scrollInterval) {
117
+ stopAutoScroll();
118
+ setupAutoScroll();
119
+ }
120
+
121
+ $: tableStyle = utils.generateTableStyle(id, columns, tabOptions, viewWidth);
122
+
123
+
124
+ </script>
125
+
126
+ <div id="tab_{id}" class="uniface-concise-datatable">
127
+ {@html tableStyle}
128
+ <div class="table-container" bind:this={tableContainer}>
129
+ <!-- Fixed header -->
130
+ <div class="table-header">
131
+ <div class="table-row" bind:this={headerRow}>
132
+ {#each columns as column, idx}
133
+ <div class="data-cell col_{idx}">
134
+ {column.title ?? ''}
135
+ </div>
136
+ {/each}
137
+ </div>
138
+ </div>
139
+
140
+ <!-- Scrollable body -->
141
+ <div class="table-body-container" bind:this={viewPanel} class:auto-scroll={autoScroll}>
142
+ <div class="table-body" style="transition: transform {autoScroll ? '2s' : '0s'} ease;">
143
+ {#each list as row, rowIndex}
144
+ <DataRow data={row} {columns} showAlternative={rowIndex % 2 == 1} on:click={rowClickHandler?.(row)}/>
145
+ {/each}
146
+ {#if autoScroll && list.length > visibleRowCount}
147
+ {#each list.slice(0, visibleRowCount) as row, rowIndex}
148
+ <DataRow data={row} {columns} showAlternative={rowIndex % 2 == 1} on:click={rowClickHandler?.(row)}/>
149
+ {/each}
150
+ {/if}
151
+ </div>
152
+ </div>
153
+ </div>
154
+ </div>
@@ -0,0 +1,26 @@
1
+ import { type RowClickHandler, type TableOptions } from "./TableOptions";
2
+ 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> {
3
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
+ $$bindings?: Bindings;
5
+ } & Exports;
6
+ (internal: unknown, props: Props & {
7
+ $$events?: Events;
8
+ $$slots?: Slots;
9
+ }): Exports & {
10
+ $set?: any;
11
+ $on?: any;
12
+ };
13
+ z_$$bindings?: Bindings;
14
+ }
15
+ declare const ConciseListTable: $$__sveltets_2_IsomorphicComponent<{
16
+ list: Array<any>;
17
+ columns: Array<Column>;
18
+ autoScroll?: boolean;
19
+ scrollInterval?: number;
20
+ rowClickHandler?: RowClickHandler | null;
21
+ options: TableOptions;
22
+ }, {
23
+ [evt: string]: CustomEvent<any>;
24
+ }, {}, {}, string>;
25
+ type ConciseListTable = InstanceType<typeof ConciseListTable>;
26
+ export default ConciseListTable;
@@ -0,0 +1,22 @@
1
+ <script lang="ts">
2
+ import type Column from "./Column";
3
+
4
+ export let column: Column;
5
+ export let idx: number;
6
+
7
+ export let data: any;
8
+
9
+ let text: string;
10
+ let escapeHTML: boolean = false;
11
+
12
+ $: text = column.formatter ? column.formatter(data[column.field]) : data[column.field];
13
+
14
+ </script>
15
+
16
+ <div class="data-cell col_{idx}">
17
+ {#if escapeHTML}
18
+ {@html text}
19
+ {:else }
20
+ <span>{text}</span>
21
+ {/if}
22
+ </div>
@@ -1,3 +1,4 @@
1
+ import type Column from "./Column";
1
2
  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> {
2
3
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
4
  $$bindings?: Bindings;
@@ -11,12 +12,12 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
11
12
  };
12
13
  z_$$bindings?: Bindings;
13
14
  }
14
- declare const LinkButton: $$__sveltets_2_IsomorphicComponent<{
15
- text: any;
16
- action: any;
17
- style?: string;
15
+ declare const DataCell: $$__sveltets_2_IsomorphicComponent<{
16
+ column: Column;
17
+ idx: number;
18
+ data: any;
18
19
  }, {
19
20
  [evt: string]: CustomEvent<any>;
20
21
  }, {}, {}, string>;
21
- type LinkButton = InstanceType<typeof LinkButton>;
22
- export default LinkButton;
22
+ type DataCell = InstanceType<typeof DataCell>;
23
+ export default DataCell;
@@ -0,0 +1,15 @@
1
+ <script lang="ts">
2
+ import type Column from "./Column";
3
+ import DataCell from "./DataCell.svelte";
4
+
5
+ export let columns: Array<Column>;
6
+ export let data: any;
7
+
8
+ export let showAlternative: boolean;
9
+ </script>
10
+
11
+ <div class="table-row" class:alternative={showAlternative} on:click>
12
+ {#each columns as column, idx}
13
+ <DataCell {idx} {column} {data}/>
14
+ {/each}
15
+ </div>
@@ -0,0 +1,25 @@
1
+ import type Column from "./Column";
2
+ 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> {
3
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
+ $$bindings?: Bindings;
5
+ } & Exports;
6
+ (internal: unknown, props: Props & {
7
+ $$events?: Events;
8
+ $$slots?: Slots;
9
+ }): Exports & {
10
+ $set?: any;
11
+ $on?: any;
12
+ };
13
+ z_$$bindings?: Bindings;
14
+ }
15
+ declare const DataRow: $$__sveltets_2_IsomorphicComponent<{
16
+ columns: Array<Column>;
17
+ data: any;
18
+ showAlternative: boolean;
19
+ }, {
20
+ click: MouseEvent;
21
+ } & {
22
+ [evt: string]: CustomEvent<any>;
23
+ }, {}, {}, string>;
24
+ type DataRow = InstanceType<typeof DataRow>;
25
+ export default DataRow;
@@ -0,0 +1,11 @@
1
+ export interface TableOptions {
2
+ backgroundColor?: string;
3
+ color?: string;
4
+ headerHeight?: number;
5
+ headerBackgroundColor?: string;
6
+ headerColor?: string;
7
+ alternativeBackgroundColor?: string;
8
+ alternativeColor?: string;
9
+ rowHeight?: number;
10
+ }
11
+ export type RowClickHandler = (row: any) => (event: MouseEvent) => void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import ConciseListTable from "./ConciseListTable.svelte";
2
+ import type Column from "./Column";
3
+ import type { TableOptions } from "./TableOptions";
4
+ export default ConciseListTable;
5
+ export type { Column, TableOptions };
@@ -0,0 +1,2 @@
1
+ import ConciseListTable from "./ConciseListTable.svelte";
2
+ export default ConciseListTable;
@@ -0,0 +1,6 @@
1
+ import type Column from "./Column";
2
+ import type { TableOptions } from "./TableOptions";
3
+ declare const _default: {
4
+ generateTableStyle: (id: string, columns: Array<Column>, options: TableOptions, viewWidth: number) => string;
5
+ };
6
+ export default _default;
@@ -0,0 +1,38 @@
1
+ const generateBlockStyle = (prefix, options, keys) => {
2
+ let style = '';
3
+ keys.forEach(key => {
4
+ if (options[key.code]) {
5
+ style += `${key.attr}: ${options[key.code]}${key.suffix ?? ''};\n`;
6
+ }
7
+ });
8
+ if (style.length > 0) {
9
+ return `${prefix} { ${style} }`;
10
+ }
11
+ else {
12
+ return '';
13
+ }
14
+ };
15
+ /**
16
+ *
17
+ * @param id
18
+ * @param columns
19
+ * @param options
20
+ * @param viewWidth
21
+ */
22
+ const generateTableStyle = (id, columns, options, viewWidth) => {
23
+ let style = '';
24
+ if (options && columns) {
25
+ style += generateBlockStyle(`#tab_${id}`, options, [{ code: 'backgroundColor', attr: 'background-color' }, { code: 'color', attr: 'color' }]);
26
+ style += generateBlockStyle(`#tab_${id} .table-row.alternative `, options, [{ code: 'alternativeBackgroundColor', attr: 'background-color' }, { code: 'alternativeColor', attr: 'color' }]);
27
+ style += generateBlockStyle(`#tab_${id} .table-header .table-row `, options, [{ code: 'headerBackgroundColor', attr: 'background-color' }, { code: 'headerColor', attr: 'color' }, { code: 'headerHeight', attr: 'height', suffix: 'px' }]);
28
+ style += generateBlockStyle(`#tab_${id} .table-body .table-row`, options, [{ code: 'headerHeight', attr: 'height', suffix: 'px' }]);
29
+ let totalWeight = columns.reduce((sum, col) => sum + (col.weight || 0), 0);
30
+ let tabWidth = columns.reduce((sum, col) => sum + col.width, 0);
31
+ let diff = (viewWidth - tabWidth) / totalWeight;
32
+ columns.forEach((col, idx) => {
33
+ style += `#tab_${id} .col_${idx} {\n width: ${col.width + (col.weight ?? 0) * diff}px; \n text-align: ${col.align ?? 'left'};} \n`;
34
+ });
35
+ }
36
+ return `<style>${style}</style>`;
37
+ };
38
+ export default { generateTableStyle };
@@ -1,91 +1,122 @@
1
1
  <script lang="ts">
2
2
 
3
-
4
- import TableHeaderPanel from "./parts/TableHeaderPanel.svelte";
5
3
  import ContentPanel from "./parts/ContentPanel.svelte";
6
4
  import type DataColumn from "./lib/DataColumn";
7
5
  import type ActionsColumn from "./lib/ActionsColumn";
8
6
  import type IndicatorColumn from "./lib/IndicatorColumn";
9
7
  import type TableRow from "./parts/TableRow";
8
+ import UniDataTable from "./UniDataTable";
9
+ import {onMount} from "svelte";
10
+ import FixedColumnsPanel from "./parts/FixedColumnsPanel.svelte";
11
+ import ActionPanel from "./parts/ActionsPanel.svelte";
12
+ import {OrderDirection} from "./lib/OrderDirection";
10
13
  import type {CompareFunction} from "./lib/CompareFunction";
11
- import UniDataTable, {SelectionMode} from "./UniDataTable";
12
- import {onMount, tick} from "svelte";
13
14
 
14
15
  export let columns: Array<DataColumn>;
15
- export let actionsColumn: ActionsColumn | null;
16
- export let indicatorColumn: IndicatorColumn;
17
- export let rowHeight: number = null as unknown as number; //{ rowHeight}
18
- export let list;
16
+ export let actionsColumn: ActionsColumn | null = null;
17
+ export let indicatorColumn: IndicatorColumn | null = null;
18
+ export let rowHeight: number = 42; //{ rowHeight}
19
+ export let list: Array<any>;
19
20
  export let selectedRows: Array<any> = [];
21
+ export let inlineRowHeight: number = 80;
22
+ export let rowBorder: boolean = false;
23
+ export let colBorder: boolean = false;
24
+
25
+ export let style: string = '';
20
26
 
21
- let dataColumns: Array<DataColumn> = [];
27
+ let dataColumns: Array<DataColumn>;
22
28
 
23
- let colStyle: string = '';
24
- let scrollLeft: number = 0;
25
29
  let rows: Array<TableRow>;
26
30
  let table: UniDataTable = null as unknown as UniDataTable;
27
- export let selectionMode: SelectionMode = SelectionMode.None;
31
+ let tabStyle: string = '';
28
32
 
29
- let id: string = `${(new Date()).getTime().toString(16)}-${(Math.round(1000 * Math.random()) + 10000).toString(16)}`;
33
+ let id: string = (new Date()).getTime().toString(36);
30
34
 
31
35
  onMount(() => {
32
- table = new UniDataTable(id, indicatorColumn.width);
36
+ table = new UniDataTable(id, indicatorColumn?.width);
37
+ selectedRows = selectedRows ?? [];
38
+ initializeTable();
33
39
  })
34
- const sortRows = (compareFun: CompareFunction, descending: boolean) => {
35
- let oList = list.sort(compareFun);
36
- displayList = descending ? oList.reverse() : oList;
37
- rows = table.rows;
38
- }
39
40
 
40
- const handleDataSelected = async (value: boolean) => {
41
- rows.forEach(row => row.selected = value);
42
- selectedRows = rows.filter(item => item.selected).map(item => item.data);
43
- await tick();
44
- selectionMode = value ? SelectionMode.All : SelectionMode.None;
45
- rows = [...rows];
46
- }
41
+ let expandRow: TableRow | null = null;
42
+ let fixedCols: Array<DataColumn>;
43
+ let scrollTop: number;
47
44
 
48
- $: selectedRows = selectedRows ?? [];
45
+ const initializeTable = () => {
46
+ table.setColumns(columns);
47
+ rows = table.rows;
48
+ dataColumns = table.columns;
49
+ fixedCols = table.frozenColumns;
50
+ tabStyle = table.generateTemplateStyle();
51
+ tabWidth = table.width;
52
+ frozenWidth = table.frozenWidth;
53
+ }
49
54
 
50
- $: displayList = [...list];
51
55
 
52
- $: {
53
- if (table && columns) {
54
- table.setColumns(columns)
55
- table.data = displayList;
56
- rows = table.rows;
57
- dataColumns = table.columns;
58
- colStyle = table.generateTemplateStyle();
59
- tabWidth = table.width;
60
- }
56
+ $: if (table && columns) {
57
+ initializeTable();
61
58
  }
62
59
 
63
60
  let tabWidth: number;
64
-
61
+ let frozenWidth: number;
65
62
  const handleWidthChange = () => {
66
- colStyle = table.generateTemplateStyle();
63
+ tabStyle = table.generateTemplateStyle();
67
64
  tabWidth = table.width;
65
+ frozenWidth = table.frozenWidth;
68
66
  }
69
67
 
68
+ let orderColumn: DataColumn = null as unknown as DataColumn;
69
+ let orderDirection: OrderDirection = OrderDirection.Ascending;
70
+ const sortRows = (compareFun: CompareFunction, descending: boolean) => {
71
+ expandRow = null;
72
+ let oList = list.sort(compareFun);
73
+ table.data = descending ? oList.reverse() : oList;
74
+ rows = table.rows;
75
+ }
76
+ const handleCellClick = (col: DataColumn) => (e: MouseEvent) => {
77
+ if (col.compareFunction != null) {
78
+ if (col == orderColumn) {
79
+ orderDirection = orderDirection == OrderDirection.Ascending ? OrderDirection.Descending : OrderDirection.Ascending;
80
+ } else {
81
+ orderColumn = col;
82
+ orderDirection = OrderDirection.Ascending;
83
+ }
84
+ sortRows(col.compareFunction, orderDirection == OrderDirection.Descending);
85
+ }
86
+ }
70
87
 
71
- const handleRowSelectChange = async () => {
72
- selectedRows = rows.filter(item => item.selected).map(item => item.data);
73
- selectionMode = selectedRows.length == rows.length ? SelectionMode.All : selectedRows.length == 0 ? SelectionMode.None : SelectionMode.Partial;
88
+ let inlineComponent: any;
89
+ const handleRowExpand = async (row: TableRow) => {
90
+ if (row == expandRow) {
91
+ expandRow = null;
92
+ inlineComponent = null;
93
+ } else {
94
+ inlineComponent = await indicatorColumn?.buildInlineComponent?.(row.data);
95
+ expandRow = row;
96
+ }
74
97
  }
75
98
 
99
+ $: rowHeight = rowHeight ?? 42;
100
+
76
101
  </script>
77
102
 
78
- <div id="tab-{id}" class="uniface-data-table">
79
- {@html colStyle}
80
- {#if table}
81
- <div>
82
- <TableHeaderPanel sortData={sortRows} {selectionMode} frozenCols={[]} dataCols={dataColumns}
83
- {scrollLeft} width={tabWidth}
84
- {indicatorColumn} {actionsColumn} handleToggleSelectAll={handleDataSelected} {handleWidthChange}/>
85
- {#if colStyle.length > 0 && list}
86
- <ContentPanel columns={dataColumns} {rows} {indicatorColumn} {actionsColumn}
87
- bind:scrollLeft {rowHeight} width={tabWidth} {handleRowSelectChange}/>
88
- {/if}
89
- </div>
103
+ <div id="tab-{id}" {style} class="uniface-data-table" class:cell-border={colBorder} class:row-border={rowBorder}>
104
+ {@html tabStyle}
105
+ {#if table && dataColumns && fixedCols}
106
+ {#if indicatorColumn || fixedCols.length > 0}
107
+ <FixedColumnsPanel {handleRowExpand} bind:selectedRows {orderDirection} {orderColumn} {handleCellClick} {indicatorColumn}
108
+ bind:expandRow {table}
109
+ {rowHeight} {fixedCols} {inlineRowHeight} {rows} {handleWidthChange} width={frozenWidth}
110
+ bind:scrollTop/>
111
+ {/if}
112
+
113
+ <ContentPanel columns={dataColumns} {orderDirection} {orderColumn} {handleWidthChange} {handleCellClick} {tabWidth} bind:rows
114
+ bind:scrollTop {expandRow} {rowHeight} {list} {table} {inlineComponent} bind:inlineRowHeight
115
+ displayHorizontalScroll={actionsColumn!=null || indicatorColumn != null || fixedCols.length > 0}
116
+ showVerticalScroll={actionsColumn == null}/>
117
+ {/if}
118
+
119
+ {#if actionsColumn}
120
+ <ActionPanel {expandRow} {rowHeight} {actionsColumn} {rows} {inlineRowHeight} bind:scrollTop/>
90
121
  {/if}
91
122
  </div>
@@ -1,7 +1,6 @@
1
1
  import type DataColumn from "./lib/DataColumn";
2
2
  import type ActionsColumn from "./lib/ActionsColumn";
3
3
  import type IndicatorColumn from "./lib/IndicatorColumn";
4
- import { SelectionMode } from "./UniDataTable";
5
4
  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
5
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
7
6
  $$bindings?: Bindings;
@@ -17,12 +16,15 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
17
16
  }
18
17
  declare const DataTable: $$__sveltets_2_IsomorphicComponent<{
19
18
  columns: Array<DataColumn>;
20
- actionsColumn: ActionsColumn | null;
21
- indicatorColumn: IndicatorColumn;
19
+ actionsColumn?: ActionsColumn | null;
20
+ indicatorColumn?: IndicatorColumn | null;
22
21
  rowHeight?: number;
23
- list: any;
22
+ list: Array<any>;
24
23
  selectedRows?: Array<any>;
25
- selectionMode?: SelectionMode;
24
+ inlineRowHeight?: number;
25
+ rowBorder?: boolean;
26
+ colBorder?: boolean;
27
+ style?: string;
26
28
  }, {
27
29
  [evt: string]: CustomEvent<any>;
28
30
  }, {}, {}, string>;
@@ -1,6 +1,7 @@
1
1
  import type DataColumn from "./lib/DataColumn";
2
2
  import type TableRow from "./parts/TableRow";
3
3
  export type RowEventHandler = (row: TableRow) => void;
4
+ export type RowSelectEventHandler = (row: TableRow, value: boolean) => void;
4
5
  export type TableEventHandler = () => void;
5
6
  export type SelectionEventHandler = (value: boolean) => void;
6
7
  export declare enum SelectionMode {
@@ -16,7 +17,7 @@ export default class UniDataTable {
16
17
  readonly id: string;
17
18
  private _width;
18
19
  private _frozenWidth;
19
- constructor(id: string, indicatorWidth: number);
20
+ constructor(id: string, indicatorWidth?: number);
20
21
  set data(value: Array<any>);
21
22
  get data(): Array<any>;
22
23
  setColumns(columns: Array<DataColumn>): void;
@@ -24,5 +25,6 @@ export default class UniDataTable {
24
25
  get width(): number;
25
26
  get frozenWidth(): number;
26
27
  get rows(): Array<TableRow>;
27
- get columns(): DataColumn[];
28
+ get columns(): Array<DataColumn>;
29
+ get frozenColumns(): Array<DataColumn>;
28
30
  }
@@ -15,7 +15,7 @@ export default class UniDataTable {
15
15
  _frozenWidth = 0;
16
16
  constructor(id, indicatorWidth) {
17
17
  this.id = id;
18
- this.indicatorWidth = indicatorWidth;
18
+ this.indicatorWidth = indicatorWidth ?? 0;
19
19
  this.tableRows = new TableRows();
20
20
  }
21
21
  set data(value) {
@@ -25,12 +25,10 @@ export default class UniDataTable {
25
25
  return this.tableRows.data;
26
26
  }
27
27
  setColumns(columns) {
28
- let frozen = true;
29
28
  this._frozenColumns = [];
30
29
  this._columns = [];
31
30
  (columns ?? []).forEach(col => {
32
- frozen = frozen && col.frozen == true;
33
- if (frozen) {
31
+ if (col.frozen) {
34
32
  this._frozenColumns.push(col);
35
33
  }
36
34
  else {
@@ -40,12 +38,12 @@ export default class UniDataTable {
40
38
  }
41
39
  generateTemplateStyle() {
42
40
  this._width = 0;
43
- this._frozenWidth = this.indicatorWidth;
41
+ this._frozenWidth = 0;
44
42
  let colStyle = '';
45
43
  let inv = 0;
46
44
  this._frozenColumns.forEach((col, idx) => {
47
45
  if (col.visible != false) {
48
- this.indicatorWidth += col.width;
46
+ this._frozenWidth += col.width;
49
47
  colStyle += `#tab-${this.id} .fz_col-${idx - inv} {width: ${col.width}px; ext-align: ${col.align ?? 'left'}}\n`;
50
48
  }
51
49
  else {
@@ -68,7 +66,7 @@ export default class UniDataTable {
68
66
  return this._width;
69
67
  }
70
68
  get frozenWidth() {
71
- return this._frozenWidth;
69
+ return this._frozenWidth + this.indicatorWidth;
72
70
  }
73
71
  get rows() {
74
72
  return [...this.tableRows.rows];
@@ -76,4 +74,7 @@ export default class UniDataTable {
76
74
  get columns() {
77
75
  return this._columns;
78
76
  }
77
+ get frozenColumns() {
78
+ return this._frozenColumns;
79
+ }
79
80
  }
@@ -1,9 +1,5 @@
1
1
  import type { GetRowActions } from "./RowAction";
2
2
  export default interface ActionsColumn {
3
- /**
4
- * 栏标题
5
- */
6
- title: string;
7
3
  /**
8
4
  * 宽度
9
5
  */
@@ -1,4 +1,4 @@
1
- export type HrefBuilder = (item: any) => Array<HrefLink | string> | HrefLink;
1
+ export type HrefBuilder = (item: any) => Array<HrefLink> | HrefLink;
2
2
  export type HrefAction = () => void;
3
3
  export default interface HrefLink {
4
4
  /**