@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.
- package/dist/concise-data-table/Column.d.ts +9 -0
- package/dist/concise-data-table/Column.js +1 -0
- package/dist/concise-data-table/ConciseListTable.svelte +154 -0
- package/dist/concise-data-table/ConciseListTable.svelte.d.ts +26 -0
- package/dist/concise-data-table/DataCell.svelte +22 -0
- package/dist/{data-table/parts/LinkButton.svelte.d.ts → concise-data-table/DataCell.svelte.d.ts} +7 -6
- package/dist/concise-data-table/DataRow.svelte +15 -0
- package/dist/concise-data-table/DataRow.svelte.d.ts +25 -0
- package/dist/concise-data-table/TableOptions.d.ts +11 -0
- package/dist/concise-data-table/TableOptions.js +1 -0
- package/dist/concise-data-table/index.d.ts +5 -0
- package/dist/concise-data-table/index.js +2 -0
- package/dist/concise-data-table/utils.d.ts +6 -0
- package/dist/concise-data-table/utils.js +38 -0
- package/dist/data-table/DataTable.svelte +85 -54
- package/dist/data-table/DataTable.svelte.d.ts +7 -5
- package/dist/data-table/UniDataTable.d.ts +4 -2
- package/dist/data-table/UniDataTable.js +8 -7
- package/dist/data-table/lib/ActionsColumn.d.ts +0 -4
- package/dist/data-table/lib/HrefLink.d.ts +1 -1
- package/dist/data-table/lib/IndicatorColumn.d.ts +2 -11
- package/dist/data-table/parts/ActionsPanel.svelte +9 -2
- package/dist/data-table/parts/ActionsPanel.svelte.d.ts +1 -1
- package/dist/data-table/parts/ActionsRow.svelte +3 -3
- package/dist/data-table/parts/ContentPanel.svelte +68 -76
- package/dist/data-table/parts/ContentPanel.svelte.d.ts +15 -8
- package/dist/data-table/parts/DataCell.svelte +3 -3
- package/dist/data-table/parts/DataRow.svelte +2 -4
- package/dist/data-table/parts/FixedColumnsPanel.svelte +52 -13
- package/dist/data-table/parts/FixedColumnsPanel.svelte.d.ts +12 -5
- package/dist/data-table/parts/FixedHeaderPanel.svelte +74 -11
- package/dist/data-table/parts/FixedHeaderPanel.svelte.d.ts +8 -2
- package/dist/data-table/parts/FixedRow.svelte +30 -17
- package/dist/data-table/parts/FixedRow.svelte.d.ts +6 -3
- package/dist/data-table/parts/HrefCell.svelte +8 -10
- package/dist/data-table/parts/TableHeaderPanel.svelte +32 -63
- package/dist/data-table/parts/TableHeaderPanel.svelte.d.ts +6 -10
- package/dist/data-table/parts/TableRow.d.ts +0 -10
- package/dist/data-table/parts/TableRow.js +0 -29
- package/dist/data-table/parts/TableRows.d.ts +0 -2
- package/dist/data-table/parts/TableRows.js +0 -2
- package/dist/data-table/parts/TextCell.svelte +6 -9
- package/dist/data-table/parts/TreeRootCell.svelte +3 -0
- package/dist/data-table/parts/TreeRootCell.svelte.d.ts +18 -0
- package/dist/pagination-panel/PaginationPanel.svelte +1 -1
- package/dist/pagination-panel/PaginationPanel.svelte.d.ts +1 -1
- package/dist/ticatec-uniface-web.css +214 -217
- package/dist/tree-view/TreeNodeView.svelte +6 -8
- package/dist/tree-view/TreeUtils.js +2 -2
- package/package.json +5 -1
- package/dist/data-table/parts/LinkButton.svelte +0 -19
|
@@ -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
|
-
|
|
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
|
|
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="
|
|
88
|
-
<div bind:this={cell}
|
|
89
|
-
style="
|
|
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,62 @@
|
|
|
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
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
6
|
+
import {onDestroy, 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
|
|
17
|
-
export let rows: Array<TableRow>; //{rows}
|
|
19
|
+
export let list: Array<any>;
|
|
18
20
|
|
|
19
|
-
export let
|
|
21
|
+
export let expandRow: TableRow | null;
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export let
|
|
24
|
-
export let rowHeight: number;
|
|
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
|
|
30
|
-
|
|
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
|
|
34
|
-
let tabWidth: number;
|
|
45
|
+
let viewPanel: any;
|
|
35
46
|
|
|
36
47
|
onMount(async () => {
|
|
37
48
|
resizeObserver = new ResizeObserver(() => {
|
|
38
49
|
// 每次 div 尺寸变化时,更新 clientWidth
|
|
39
|
-
|
|
50
|
+
viewWidth = Math.round(viewPanel?.clientWidth)-1;
|
|
40
51
|
});
|
|
41
|
-
resizeObserver.observe(
|
|
52
|
+
resizeObserver.observe(viewPanel);
|
|
42
53
|
});
|
|
43
54
|
|
|
55
|
+
onDestroy(()=>{
|
|
56
|
+
resizeObserver.disconnect();
|
|
57
|
+
})
|
|
58
|
+
|
|
44
59
|
const handleDataTableScroll = (e: Event) => {
|
|
45
|
-
if (
|
|
60
|
+
if (showVerticalScroll) {
|
|
46
61
|
scrollTop = e.target?.scrollTop;
|
|
47
62
|
}
|
|
48
63
|
scrollLeft = e.target?.scrollLeft;
|
|
@@ -51,7 +66,7 @@
|
|
|
51
66
|
|
|
52
67
|
const handleWheelEvent = (e: WheelEvent) => {
|
|
53
68
|
let maxSh = dataPanel.scrollHeight - dataPanel.clientHeight;
|
|
54
|
-
if (
|
|
69
|
+
if (!showVerticalScroll && maxSh > 0) {
|
|
55
70
|
if (e.deltaY != 0) {
|
|
56
71
|
scrollTop = scrollTop + e.deltaY;
|
|
57
72
|
if (scrollTop < 0) {
|
|
@@ -67,70 +82,50 @@
|
|
|
67
82
|
}
|
|
68
83
|
}
|
|
69
84
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
let fixedCols: Array<DataColumn> = [];
|
|
85
|
+
$: if (dataPanel && scrollTop > -1 && !showVerticalScroll) {
|
|
86
|
+
console.log('移动', scrollTop)
|
|
87
|
+
dataPanel.scrollTop = scrollTop;
|
|
88
|
+
}
|
|
76
89
|
|
|
77
90
|
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
} else {
|
|
83
|
-
if (expandRow != null) {
|
|
84
|
-
expandRow.expand = false;
|
|
85
|
-
}
|
|
86
|
-
expandRow = row;
|
|
91
|
+
$: {
|
|
92
|
+
if (table) {
|
|
93
|
+
table.data = [...list];
|
|
94
|
+
rows = table.rows;
|
|
87
95
|
}
|
|
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
96
|
}
|
|
99
97
|
|
|
100
|
-
let rowWidth: number;
|
|
101
98
|
|
|
102
|
-
|
|
99
|
+
let viewWidth: number;
|
|
100
|
+
$: rowWidth = Math.max(viewWidth, tabWidth);
|
|
103
101
|
|
|
104
|
-
$: if (
|
|
105
|
-
|
|
102
|
+
$: if (columns) {
|
|
103
|
+
tabWidth = table.width;
|
|
106
104
|
}
|
|
107
105
|
|
|
106
|
+
let hasWhitespace: boolean = true;
|
|
107
|
+
$: hasWhitespace = viewWidth > tabWidth;
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
let top: string = "0px";
|
|
111
|
+
let dataPanel: any;
|
|
112
|
+
|
|
113
|
+
|
|
108
114
|
</script>
|
|
109
|
-
<div class="data-content-panel">
|
|
110
|
-
|
|
111
|
-
|
|
115
|
+
<div class="data-content-panel" bind:this={viewPanel}>
|
|
116
|
+
|
|
117
|
+
<TableHeaderPanel {handleCellClick} {orderColumn} {orderDirection} dataCols={columns} {scrollLeft} width={tabWidth} {hasWhitespace} {handleWidthChange}/>
|
|
112
118
|
<div class="data-view-panel" bind:this={dataPanel} on:scroll|passive={handleDataTableScroll} on:wheel|passive={handleWheelEvent}
|
|
113
|
-
style="{
|
|
119
|
+
style="overflow-x: {displayHorizontalScroll ? 'scroll' : 'auto'}; overflow-y: {showVerticalScroll ?'auto': 'hidden' };">
|
|
114
120
|
{#if rows && rows.length > 0}
|
|
115
|
-
<div style="box-sizing: border-box; width: {rowWidth}px;">
|
|
121
|
+
<div style="box-sizing: border-box; width: {rowWidth}px; top: {top}">
|
|
116
122
|
{#each rows as row, idx}
|
|
117
|
-
<DataRow {rowHeight} {row} {columns} alternative={idx % 2 == 1}
|
|
118
|
-
{#if row == expandRow}
|
|
123
|
+
<DataRow {rowHeight} {row} {columns} alternative={idx % 2 == 1}/>
|
|
124
|
+
{#if row == expandRow && inlineComponent}
|
|
119
125
|
<div class="expand-data-row" bind:clientHeight={inlineRowHeight}
|
|
120
126
|
style="position: relative; box-sizing: content-box; width: 100%; height: auto">
|
|
121
127
|
<div class="inline-panel">
|
|
122
|
-
{
|
|
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}
|
|
128
|
+
<svelte:component this={inlineComponent} data={row.data}/>
|
|
134
129
|
</div>
|
|
135
130
|
</div>
|
|
136
131
|
{/if}
|
|
@@ -138,11 +133,8 @@
|
|
|
138
133
|
</div>
|
|
139
134
|
{:else}
|
|
140
135
|
<div class="empty-content-board" style="width: 100%">
|
|
141
|
-
<div>{
|
|
136
|
+
<div>{emptyIndicator ?? "Empty dataset."}</div>
|
|
142
137
|
</div>
|
|
143
138
|
{/if}
|
|
144
139
|
</div>
|
|
145
|
-
{#if actionsColumn}
|
|
146
|
-
<ActionPanel {expandRow} {rowHeight} {actionsColumn} {rows} {inlineRowHeight} bind:scrollTop/>
|
|
147
|
-
{/if}
|
|
148
140
|
</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
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
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,11 +18,11 @@
|
|
|
18
18
|
hint = column.hint?.(data);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
$: col$class = frozen ? `
|
|
21
|
+
$: col$class = frozen ? `fz_col-${colIdx}` : `col-${colIdx}`;
|
|
22
22
|
|
|
23
23
|
</script>
|
|
24
|
-
<div class="
|
|
25
|
-
<div>
|
|
24
|
+
<div class="data-cell {col$class}">
|
|
25
|
+
<div class="vertical-center">
|
|
26
26
|
{#if column.render}
|
|
27
27
|
<svelte:component this={column.render.component} {...column.render.props} {data}/>
|
|
28
28
|
{:else if column.href}
|
|
@@ -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="
|
|
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="
|
|
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
|
|
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
|
|
22
|
+
export let handleCellClick: (col: DataColumn) => any;
|
|
23
|
+
export let orderColumn: DataColumn;
|
|
24
|
+
export let orderDirection: OrderDirection;
|
|
18
25
|
|
|
19
|
-
|
|
26
|
+
let selectionMode: SelectionMode = SelectionMode.None;
|
|
27
|
+
|
|
28
|
+
export let selectedRows: Array<any> = [];
|
|
20
29
|
|
|
21
|
-
let
|
|
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
|
|
30
|
-
$: expandable = indicatorColumn
|
|
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
|
-
<
|
|
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.
|
|
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
|
|
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
|
|
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
|
-
|
|
25
|
-
|
|
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-
|
|
40
|
-
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
}, {
|