@ticatec/uniface-element 0.1.13 → 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 (30) hide show
  1. package/dist/data-table/DataTable.svelte +83 -54
  2. package/dist/data-table/DataTable.svelte.d.ts +7 -5
  3. package/dist/data-table/UniDataTable.d.ts +4 -2
  4. package/dist/data-table/UniDataTable.js +8 -7
  5. package/dist/data-table/lib/IndicatorColumn.d.ts +2 -11
  6. package/dist/data-table/parts/ActionsPanel.svelte +9 -2
  7. package/dist/data-table/parts/ActionsPanel.svelte.d.ts +1 -1
  8. package/dist/data-table/parts/ActionsRow.svelte +3 -3
  9. package/dist/data-table/parts/ContentPanel.svelte +64 -76
  10. package/dist/data-table/parts/ContentPanel.svelte.d.ts +15 -8
  11. package/dist/data-table/parts/DataCell.svelte +2 -2
  12. package/dist/data-table/parts/DataRow.svelte +2 -4
  13. package/dist/data-table/parts/FixedColumnsPanel.svelte +52 -13
  14. package/dist/data-table/parts/FixedColumnsPanel.svelte.d.ts +12 -5
  15. package/dist/data-table/parts/FixedHeaderPanel.svelte +74 -11
  16. package/dist/data-table/parts/FixedHeaderPanel.svelte.d.ts +8 -2
  17. package/dist/data-table/parts/FixedRow.svelte +30 -17
  18. package/dist/data-table/parts/FixedRow.svelte.d.ts +6 -3
  19. package/dist/data-table/parts/TableHeaderPanel.svelte +32 -63
  20. package/dist/data-table/parts/TableHeaderPanel.svelte.d.ts +6 -10
  21. package/dist/data-table/parts/TableRow.d.ts +0 -10
  22. package/dist/data-table/parts/TableRow.js +0 -29
  23. package/dist/data-table/parts/TableRows.d.ts +0 -2
  24. package/dist/data-table/parts/TableRows.js +0 -2
  25. package/dist/data-table/parts/TreeRootCell.svelte +3 -0
  26. package/dist/data-table/parts/TreeRootCell.svelte.d.ts +18 -0
  27. package/dist/pagination-panel/PaginationPanel.svelte +1 -1
  28. package/dist/pagination-panel/PaginationPanel.svelte.d.ts +1 -1
  29. package/dist/ticatec-uniface-web.css +142 -208
  30. package/package.json +1 -1
@@ -1,91 +1,120 @@
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
 
76
99
  </script>
77
100
 
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>
101
+ <div id="tab-{id}" {style} class="uniface-data-table" class:cell-border={colBorder} class:row-border={rowBorder}>
102
+ {@html tabStyle}
103
+ {#if table && dataColumns && fixedCols}
104
+ {#if indicatorColumn || fixedCols.length > 0}
105
+ <FixedColumnsPanel {handleRowExpand} bind:selectedRows {orderDirection} {orderColumn} {handleCellClick} {indicatorColumn}
106
+ bind:expandRow {table}
107
+ {rowHeight} {fixedCols} {inlineRowHeight} {rows} {handleWidthChange} width={frozenWidth}
108
+ bind:scrollTop/>
109
+ {/if}
110
+
111
+ <ContentPanel columns={dataColumns} {orderDirection} {orderColumn} {handleWidthChange} {handleCellClick} {tabWidth} bind:rows
112
+ bind:scrollTop {expandRow} {rowHeight} {list} {table} {inlineComponent} bind:inlineRowHeight
113
+ displayHorizontalScroll={actionsColumn!=null || indicatorColumn != null || fixedCols.length > 0}
114
+ showVerticalScroll={actionsColumn == null}/>
115
+ {/if}
116
+
117
+ {#if actionsColumn}
118
+ <ActionPanel {expandRow} {rowHeight} {actionsColumn} {rows} {inlineRowHeight} bind:scrollTop/>
90
119
  {/if}
91
120
  </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
  }
@@ -12,16 +12,7 @@ export default interface IndicatorColumn {
12
12
  */
13
13
  buildInlineComponent?: (data: any) => Promise<any>;
14
14
  /**
15
- *
16
- * @param ex
17
- */
18
- getInlineError?: (ex: Error) => string;
19
- /**
20
- * 读取数据的指示信息
21
- */
22
- loadingIndicator?: string;
23
- /**
24
- * 空数据指示信息
15
+ * 是否显示行号
25
16
  */
26
- emptyIndicator?: string;
17
+ displayNo?: boolean;
27
18
  }
@@ -4,6 +4,7 @@
4
4
  import type ActionsColumn from "../lib/ActionsColumn";
5
5
  import type TableRow from "./TableRow";
6
6
  import {onDestroy, onMount} from "svelte";
7
+ import i18n from "../../i18nContext";
7
8
 
8
9
  export let actionsColumn: ActionsColumn;
9
10
  export let scrollTop: number = 0;
@@ -11,7 +12,7 @@
11
12
 
12
13
  export let inlineRowHeight: number = 0;
13
14
 
14
- export let expandRow: TableRow;
15
+ export let expandRow: TableRow | null;
15
16
 
16
17
  export let rowHeight: number;
17
18
 
@@ -42,11 +43,17 @@
42
43
  resizeObserver.disconnect();
43
44
  });
44
45
 
46
+ let actionText = i18n.getText('uniface.element.tableActions', 'Actions');
45
47
 
46
48
  </script>
47
49
 
48
50
  <div class="action-panel" bind:this={panel} style="user-select: none; width: {actionsColumn.width}px;">
49
- <div bind:this={scrollPanel} class="scroll-panel" on:scroll|passive={handleActionPanelScroll}>
51
+ <div class="header-row">
52
+ <div class="vertical-center">
53
+ <span>{actionText}</span>
54
+ </div>
55
+ </div>
56
+ <div bind:this={scrollPanel} class="rows-container" style="overflow-y: auto" on:scroll|passive={handleActionPanelScroll}>
50
57
  <div>
51
58
  {#each rows as row, idx}
52
59
  <ActionsRow {row} {rowHeight} parentRect={rect} alternative={idx % 2 == 1} width={actionsColumn.width}
@@ -18,7 +18,7 @@ declare const ActionsPanel: $$__sveltets_2_IsomorphicComponent<{
18
18
  scrollTop?: number;
19
19
  rows: Array<TableRow>;
20
20
  inlineRowHeight?: number;
21
- expandRow: TableRow;
21
+ expandRow: TableRow | null;
22
22
  rowHeight: number;
23
23
  }, {
24
24
  [evt: string]: CustomEvent<any>;
@@ -84,9 +84,9 @@
84
84
  $: style = rowHeight== null ? '' : `height: ${rowHeight}px`
85
85
 
86
86
  </script>
87
- <div class="table-row" class:alternative style="position: relative; width: {width}px; display: block; {style}">
88
- <div bind:this={cell}
89
- style="width: max-content; overflow-x: auto; white-space: nowrap; top: 50%; position: relative; transform: translateY(-50%);">
87
+ <div class="data-row" class:alternative style="position: relative; width: {width}px; display: block; {style}">
88
+ <div class="action-cell" bind:this={cell}
89
+ style="">
90
90
  {#each actionList as action}
91
91
  <TextButton style="flex-shrink: 0; top: 0" size="mini" type="primary" label={action.label} onClick={()=>action.callback(row.data)}/>
92
92
  {/each}
@@ -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,70 +78,50 @@
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}
@@ -138,11 +129,8 @@
138
129
  </div>
139
130
  {:else}
140
131
  <div class="empty-content-board" style="width: 100%">
141
- <div>{indicatorColumn.emptyIndicator ?? "Empty dataset."}</div>
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