@perspective-dev/viewer-datagrid 4.2.0 → 4.4.0
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/cdn/perspective-viewer-datagrid.js +5 -4
- package/dist/cdn/perspective-viewer-datagrid.js.map +4 -4
- package/dist/css/perspective-viewer-datagrid-toolbar.css +1 -1
- package/dist/css/perspective-viewer-datagrid.css +1 -1
- package/dist/esm/custom_elements/datagrid.d.ts +1 -0
- package/dist/esm/data_listener/format_tree_header.d.ts +1 -0
- package/dist/esm/event_handlers/row_select_click.d.ts +1 -1
- package/dist/esm/perspective-viewer-datagrid.js +3 -3
- package/dist/esm/perspective-viewer-datagrid.js.map +3 -3
- package/dist/esm/style_handlers/table_cell/datetime.d.ts +6 -2
- package/dist/esm/types.d.ts +3 -8
- package/package.json +3 -3
- package/src/css/mitered-headers.css +64 -0
- package/src/css/perspective-viewer-datagrid.css +6 -0
- package/src/{less/pro.less → css/pro.css} +32 -31
- package/src/{less/regular_table.less → css/regular_table.css} +196 -172
- package/src/{less/row-hover.less → css/row-hover.css} +28 -22
- package/src/{less/scrollbar.less → css/scrollbar.css} +16 -15
- package/src/{less/sub-cell-scroll.less → css/sub-cell-scroll.css} +14 -13
- package/src/{less/toolbar.less → css/toolbar.css} +46 -39
- package/src/ts/custom_elements/datagrid.ts +5 -0
- package/src/ts/data_listener/format_tree_header.ts +16 -0
- package/src/ts/data_listener/index.ts +24 -4
- package/src/ts/event_handlers/row_select_click.ts +19 -16
- package/src/ts/event_handlers/sort.ts +10 -7
- package/src/ts/model/create.ts +12 -8
- package/src/ts/plugin/draw.ts +1 -0
- package/src/ts/style_handlers/body.ts +20 -13
- package/src/ts/style_handlers/column_header.ts +9 -8
- package/src/ts/style_handlers/table_cell/datetime.ts +12 -9
- package/src/ts/types.ts +3 -7
- package/src/less/mitered-headers.less +0 -65
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
/* ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
|
2
|
+
* ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
|
|
3
|
+
* ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
|
|
4
|
+
* ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
|
|
5
|
+
* ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
|
|
6
|
+
* ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
|
|
7
|
+
* ┃ Copyright (c) 2017, the Perspective Authors. ┃
|
|
8
|
+
* ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
|
|
9
|
+
* ┃ This file is part of the Perspective library, distributed under the terms ┃
|
|
10
|
+
* ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
|
|
11
|
+
* ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
12
|
+
*/
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
/* Scrollbar styling */
|
|
14
15
|
regular-table {
|
|
15
16
|
outline: none;
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
/* webkit (chrome, safari, etc) scrollbar styling */
|
|
18
19
|
&::-webkit-scrollbar,
|
|
19
20
|
&::-webkit-scrollbar-corner {
|
|
20
21
|
background-color: transparent;
|
|
@@ -24,8 +25,8 @@ regular-table {
|
|
|
24
25
|
|
|
25
26
|
&::-webkit-scrollbar-thumb {
|
|
26
27
|
background-clip: content-box;
|
|
27
|
-
background: var(--
|
|
28
|
-
border: 5.5px solid var(--
|
|
28
|
+
background: var(--psp--color);
|
|
29
|
+
border: 5.5px solid var(--psp--background-color);
|
|
29
30
|
max-height: 50%;
|
|
30
31
|
max-width: 50%;
|
|
31
32
|
min-width: 10%;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
/* ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
|
2
|
+
* ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
|
|
3
|
+
* ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
|
|
4
|
+
* ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
|
|
5
|
+
* ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
|
|
6
|
+
* ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
|
|
7
|
+
* ┃ Copyright (c) 2017, the Perspective Authors. ┃
|
|
8
|
+
* ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
|
|
9
|
+
* ┃ This file is part of the Perspective library, distributed under the terms ┃
|
|
10
|
+
* ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
|
|
11
|
+
* ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
12
|
+
*/
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
/* Handles sub-cell scrolling via CSS transform offset by variables set during */
|
|
15
|
+
/* rendering. */
|
|
15
16
|
perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table,
|
|
16
17
|
:host(:not(.sub-cell-scroll-disabled)) regular-table table {
|
|
17
18
|
tbody td,
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
/* ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
|
2
|
+
* ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
|
|
3
|
+
* ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
|
|
4
|
+
* ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
|
|
5
|
+
* ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
|
|
6
|
+
* ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
|
|
7
|
+
* ┃ Copyright (c) 2017, the Perspective Authors. ┃
|
|
8
|
+
* ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
|
|
9
|
+
* ┃ This file is part of the Perspective library, distributed under the terms ┃
|
|
10
|
+
* ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
|
|
11
|
+
* ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
12
|
+
*/
|
|
12
13
|
|
|
13
14
|
:host {
|
|
14
15
|
position: relative;
|
|
@@ -42,9 +43,9 @@
|
|
|
42
43
|
|
|
43
44
|
&:hover {
|
|
44
45
|
box-shadow:
|
|
45
|
-
-4px 0 0 var(--
|
|
46
|
-
4px 0 0 var(--
|
|
47
|
-
background-color: var(--
|
|
46
|
+
-4px 0 0 var(--psp--color),
|
|
47
|
+
4px 0 0 var(--psp--color);
|
|
48
|
+
background-color: var(--psp--color);
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
|
|
@@ -54,11 +55,11 @@
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
#scroll_lock.lock-scroll:before {
|
|
57
|
-
-webkit-mask-image: var(--toolbar-scroll-lock-active--content);
|
|
58
|
+
-webkit-mask-image: var(--psp-toolbar-scroll-lock-active--content);
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
#scroll_lock:before {
|
|
61
|
-
-webkit-mask-image: var(--toolbar-scroll-lock--content);
|
|
62
|
+
-webkit-mask-image: var(--psp-toolbar-scroll-lock--content);
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
#select_mode:before {
|
|
@@ -70,69 +71,75 @@
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
#edit_mode[data-edit-mode="READ_ONLY"]:before {
|
|
73
|
-
-webkit-mask-image: var(--toolbar-edit-mode
|
|
74
|
+
-webkit-mask-image: var(--psp-toolbar-edit-mode-read-only--content);
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
#edit_mode[data-edit-mode="EDIT"]:before {
|
|
77
|
-
-webkit-mask-image: var(--toolbar-edit-mode
|
|
78
|
+
-webkit-mask-image: var(--psp-toolbar-edit-mode-edit--content);
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
:host(.aggregated) #toolbar #edit_mode[data-edit-mode="EDIT"]:before {
|
|
81
|
-
-webkit-mask-image: var(--toolbar-edit-mode
|
|
82
|
+
-webkit-mask-image: var(--psp-toolbar-edit-mode-read-only--content);
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
#edit_mode[data-edit-mode="SELECT_ROW"]:before {
|
|
85
|
-
-webkit-mask-image: var(--toolbar-edit-mode
|
|
86
|
+
-webkit-mask-image: var(--psp-toolbar-edit-mode-select-row--content);
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
#edit_mode[data-edit-mode="SELECT_COLUMN"]:before {
|
|
89
|
-
-webkit-mask-image: var(--toolbar-edit-mode
|
|
90
|
+
-webkit-mask-image: var(--psp-toolbar-edit-mode-select-column--content);
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
#edit_mode[data-edit-mode="SELECT_REGION"]:before {
|
|
93
|
-
-webkit-mask-image: var(--toolbar-edit-mode
|
|
94
|
+
-webkit-mask-image: var(--psp-toolbar-edit-mode-select-region--content);
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
/* #edit_mode span:before { */
|
|
98
|
+
/* content: var(--edit-mode-toggle--content, "N/A"); */
|
|
99
|
+
/* } */
|
|
99
100
|
|
|
100
101
|
#edit_mode[data-edit-mode="READ_ONLY"] span:before {
|
|
101
|
-
content: var(--edit-mode
|
|
102
|
+
content: var(--psp-label--edit-mode-read-only--content, "Read Only");
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
#edit_mode[data-edit-mode="EDIT"] span:before {
|
|
105
|
-
content: var(--edit-mode
|
|
106
|
+
content: var(--psp-label--edit-mode-edit--content, "Editable");
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
#edit_mode[data-edit-mode="SELECT_ROW"] span:before {
|
|
109
|
-
content: var(--edit-mode
|
|
110
|
+
content: var(--psp-label--edit-mode-select-row--content, "Row Select");
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
#edit_mode[data-edit-mode="SELECT_COLUMN"] span:before {
|
|
113
|
-
content: var(
|
|
114
|
+
content: var(
|
|
115
|
+
--psp-label--edit-mode-select-column--content,
|
|
116
|
+
"Column Select"
|
|
117
|
+
);
|
|
114
118
|
}
|
|
115
119
|
|
|
116
120
|
#edit_mode[data-edit-mode="SELECT_REGION"] span:before {
|
|
117
|
-
content: var(
|
|
121
|
+
content: var(
|
|
122
|
+
--psp-label--edit-mode-select-region--content,
|
|
123
|
+
"Region Select"
|
|
124
|
+
);
|
|
118
125
|
}
|
|
119
126
|
|
|
120
127
|
#scroll_lock span:before {
|
|
121
|
-
content: var(--scroll-lock-toggle--content, "Free Scroll");
|
|
128
|
+
content: var(--psp-label--scroll-lock-toggle--content, "Free Scroll");
|
|
122
129
|
}
|
|
123
130
|
|
|
124
131
|
#scroll_lock.lock-scroll span:before {
|
|
125
|
-
content: var(--scroll-lock-alt-toggle--content, "Align Scroll");
|
|
132
|
+
content: var(--psp-label--scroll-lock-alt-toggle--content, "Align Scroll");
|
|
126
133
|
}
|
|
127
134
|
|
|
128
|
-
|
|
135
|
+
/* The icon. */
|
|
129
136
|
.button:before {
|
|
130
137
|
width: 21px;
|
|
131
138
|
height: 21px;
|
|
132
139
|
content: "";
|
|
133
140
|
-webkit-mask-size: cover;
|
|
134
141
|
mask-size: cover;
|
|
135
|
-
background-color: var(--
|
|
142
|
+
background-color: var(--psp--color);
|
|
136
143
|
}
|
|
137
144
|
|
|
138
145
|
.button.editable:before,
|
|
@@ -167,8 +174,8 @@
|
|
|
167
174
|
.hover-target:focus-within .button,
|
|
168
175
|
.hover-target:hover .button {
|
|
169
176
|
position: relative;
|
|
170
|
-
background-color: var(--
|
|
171
|
-
color: var(--
|
|
177
|
+
background-color: var(--psp--color);
|
|
178
|
+
color: var(--psp--background-color);
|
|
172
179
|
opacity: 1;
|
|
173
180
|
display: flex;
|
|
174
181
|
align-items: center;
|
|
@@ -177,10 +184,10 @@
|
|
|
177
184
|
|
|
178
185
|
.hover-target:focus-within .button:before,
|
|
179
186
|
.hover-target:hover .button:before {
|
|
180
|
-
background-color: var(--
|
|
187
|
+
background-color: var(--psp--background-color);
|
|
181
188
|
}
|
|
182
189
|
|
|
183
|
-
|
|
190
|
+
/* The label. */
|
|
184
191
|
.hover-target:focus-within .button > span,
|
|
185
192
|
.hover-target:hover .button > span {
|
|
186
193
|
display: block;
|
|
@@ -194,7 +201,7 @@
|
|
|
194
201
|
white-space: pre-wrap;
|
|
195
202
|
line-height: 1;
|
|
196
203
|
font-size: 9px;
|
|
197
|
-
background-color: var(--
|
|
204
|
+
background-color: var(--psp--color);
|
|
198
205
|
width: 35px;
|
|
199
206
|
text-align: center;
|
|
200
207
|
border-radius: 0 0 3px 3px;
|
|
@@ -133,6 +133,10 @@ export class HTMLPerspectiveViewerDatagridPluginElement
|
|
|
133
133
|
return ["Columns"];
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
get group_rollups(): string[] {
|
|
137
|
+
return ["rollup", "flat", "total"];
|
|
138
|
+
}
|
|
139
|
+
|
|
136
140
|
/**
|
|
137
141
|
* Give the Datagrid a higher priority so it is loaded
|
|
138
142
|
* over the default charts by default.
|
|
@@ -179,6 +183,7 @@ export class HTMLPerspectiveViewerDatagridPluginElement
|
|
|
179
183
|
viewport?.start_row !== null
|
|
180
184
|
? viewport.end_row - viewport.start_row
|
|
181
185
|
: await view.num_rows();
|
|
186
|
+
|
|
182
187
|
let out = "";
|
|
183
188
|
for (let ridx = 0; ridx < nrows; ridx++) {
|
|
184
189
|
for (const col_name of cols) {
|
|
@@ -52,6 +52,22 @@ export function* format_tree_header_row_path(
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
export function* format_flat_header_row_path(
|
|
56
|
+
this: DatagridModel,
|
|
57
|
+
paths: unknown[][] = [],
|
|
58
|
+
row_headers: string[],
|
|
59
|
+
regularTable: RegularTable,
|
|
60
|
+
): Generator<RowHeaderCell[]> {
|
|
61
|
+
const plugins: ColumnsConfig =
|
|
62
|
+
(regularTable as any)[PRIVATE_PLUGIN_SYMBOL] || {};
|
|
63
|
+
|
|
64
|
+
for (let path of paths) {
|
|
65
|
+
yield path.map((part, i) =>
|
|
66
|
+
format_cell.call(this, row_headers[i], part, plugins, true),
|
|
67
|
+
) as RowHeaderCell[];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
55
71
|
/**
|
|
56
72
|
* Format a single cell of the `group_by` tree header.
|
|
57
73
|
*/
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { PRIVATE_PLUGIN_SYMBOL } from "../types.js";
|
|
14
14
|
import { format_cell } from "./format_cell.js";
|
|
15
15
|
import {
|
|
16
|
+
format_flat_header_row_path,
|
|
16
17
|
format_tree_header,
|
|
17
18
|
format_tree_header_row_path,
|
|
18
19
|
} from "./format_tree_header.js";
|
|
@@ -23,7 +24,7 @@ import type {
|
|
|
23
24
|
Schema,
|
|
24
25
|
} from "../types.js";
|
|
25
26
|
import type { CellScalar, DataResponse } from "regular-table/dist/esm/types.js";
|
|
26
|
-
import { ViewWindow } from "@perspective-dev/client";
|
|
27
|
+
import { ViewConfig, ViewWindow } from "@perspective-dev/client";
|
|
27
28
|
|
|
28
29
|
interface ColumnData {
|
|
29
30
|
__ROW_PATH__?: unknown[][];
|
|
@@ -191,8 +192,10 @@ export function createDataListener(
|
|
|
191
192
|
column_paths.push(path);
|
|
192
193
|
}
|
|
193
194
|
|
|
195
|
+
const is_dim_call = x1 - x0 > 0 && y1 - y0 > 0;
|
|
196
|
+
|
|
194
197
|
// Only update the last state if this is not a "phantom" call.
|
|
195
|
-
if (
|
|
198
|
+
if (is_dim_call) {
|
|
196
199
|
this.last_column_paths = last_column_paths;
|
|
197
200
|
this.last_meta = last_meta;
|
|
198
201
|
this.last_ids = last_ids;
|
|
@@ -207,9 +210,12 @@ export function createDataListener(
|
|
|
207
210
|
}
|
|
208
211
|
|
|
209
212
|
const is_row_path = columns.__ROW_PATH__ !== undefined;
|
|
213
|
+
const is_flat = this._config.group_rollup_mode === "flat";
|
|
210
214
|
const row_headers = Array.from(
|
|
211
215
|
(is_row_path
|
|
212
|
-
?
|
|
216
|
+
? is_flat
|
|
217
|
+
? format_flat_header_row_path
|
|
218
|
+
: format_tree_header_row_path
|
|
213
219
|
: format_tree_header
|
|
214
220
|
).call(
|
|
215
221
|
this,
|
|
@@ -219,7 +225,9 @@ export function createDataListener(
|
|
|
219
225
|
),
|
|
220
226
|
) as (string | HTMLElement)[][];
|
|
221
227
|
|
|
222
|
-
const num_row_headers =
|
|
228
|
+
const num_row_headers = !is_dim_call
|
|
229
|
+
? row_header_depth(this._config)
|
|
230
|
+
: row_headers[0]?.length;
|
|
223
231
|
|
|
224
232
|
const result: DataResponse = {
|
|
225
233
|
num_column_headers:
|
|
@@ -240,3 +248,15 @@ export function createDataListener(
|
|
|
240
248
|
return result;
|
|
241
249
|
};
|
|
242
250
|
}
|
|
251
|
+
|
|
252
|
+
function row_header_depth(config: ViewConfig) {
|
|
253
|
+
if (config.group_rollup_mode === "flat") {
|
|
254
|
+
return config.group_by.length;
|
|
255
|
+
} else if (config.group_rollup_mode === "total") {
|
|
256
|
+
return 0;
|
|
257
|
+
} else if (config.group_by.length === 0) {
|
|
258
|
+
return 0;
|
|
259
|
+
} else {
|
|
260
|
+
return config.group_by.length + 1;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
12
12
|
|
|
13
13
|
import getCellConfig from "../get_cell_config.js";
|
|
14
|
-
import
|
|
15
|
-
RegularTable,
|
|
16
|
-
DatagridModel,
|
|
17
|
-
PerspectiveViewerElement,
|
|
18
|
-
HandledMouseEvent,
|
|
14
|
+
import {
|
|
15
|
+
type RegularTable,
|
|
16
|
+
type DatagridModel,
|
|
17
|
+
type PerspectiveViewerElement,
|
|
18
|
+
type HandledMouseEvent,
|
|
19
19
|
PerspectiveSelectDetail,
|
|
20
20
|
} from "../types.js";
|
|
21
21
|
|
|
@@ -52,28 +52,31 @@ export async function selectionListener(
|
|
|
52
52
|
const is_deselect =
|
|
53
53
|
!!selected && id.length === selected.length && key_match;
|
|
54
54
|
|
|
55
|
-
let detail: PerspectiveSelectDetail = {
|
|
56
|
-
selected: !is_deselect,
|
|
57
|
-
row: {},
|
|
58
|
-
config: { filter: [] },
|
|
59
|
-
};
|
|
60
|
-
|
|
61
55
|
const { row, column_names, config } = await getCellConfig(
|
|
62
56
|
this,
|
|
63
57
|
meta.y,
|
|
64
58
|
meta.type === "body" ? meta.x : 0,
|
|
65
59
|
);
|
|
66
60
|
|
|
61
|
+
let detail: PerspectiveSelectDetail;
|
|
67
62
|
if (is_deselect) {
|
|
68
63
|
selected_rows_map.delete(regularTable);
|
|
69
|
-
detail =
|
|
70
|
-
|
|
64
|
+
detail = new PerspectiveSelectDetail(
|
|
65
|
+
false,
|
|
71
66
|
row,
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
[],
|
|
68
|
+
[],
|
|
69
|
+
[{ filter: structuredClone(this._config.filter) }],
|
|
70
|
+
);
|
|
74
71
|
} else {
|
|
75
72
|
selected_rows_map.set(regularTable, id);
|
|
76
|
-
detail =
|
|
73
|
+
detail = new PerspectiveSelectDetail(
|
|
74
|
+
true,
|
|
75
|
+
row,
|
|
76
|
+
column_names,
|
|
77
|
+
[],
|
|
78
|
+
[config],
|
|
79
|
+
);
|
|
77
80
|
}
|
|
78
81
|
|
|
79
82
|
await regularTable.draw({ preserve_width: true });
|
|
@@ -28,13 +28,13 @@ const ROW_SORT_ORDER: SortRotationOrder = {
|
|
|
28
28
|
|
|
29
29
|
const ROW_COL_SORT_ORDER: SortRotationOrder = {
|
|
30
30
|
desc: "asc",
|
|
31
|
-
asc:
|
|
31
|
+
asc: undefined,
|
|
32
32
|
"desc abs": "asc abs",
|
|
33
|
-
"asc abs":
|
|
34
|
-
"col desc": "col asc",
|
|
35
|
-
"col asc": undefined,
|
|
36
|
-
"col desc abs": "col asc abs",
|
|
37
|
-
"col asc abs": undefined,
|
|
33
|
+
"asc abs": undefined,
|
|
34
|
+
// "col desc": "col asc",
|
|
35
|
+
// "col asc": undefined,
|
|
36
|
+
// "col desc abs": "col asc abs",
|
|
37
|
+
// "col asc abs": undefined,
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
export async function sortHandler(
|
|
@@ -49,7 +49,7 @@ export async function sortHandler(
|
|
|
49
49
|
const column_name = meta.column_header[this._config.split_by.length];
|
|
50
50
|
const sort_method =
|
|
51
51
|
event.ctrlKey ||
|
|
52
|
-
(event as MouseEvent & {
|
|
52
|
+
(event as MouseEvent & { metaKey?: boolean }).metaKey ||
|
|
53
53
|
event.altKey
|
|
54
54
|
? append_sort
|
|
55
55
|
: override_sort;
|
|
@@ -97,6 +97,7 @@ export function override_sort(
|
|
|
97
97
|
return sort ? [sort] : [];
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
+
|
|
100
101
|
return [[column_name, abs ? "desc abs" : "desc"]];
|
|
101
102
|
}
|
|
102
103
|
|
|
@@ -111,8 +112,10 @@ export function create_sort(
|
|
|
111
112
|
const inc_sort_dir: SortDir | undefined = sort_dir
|
|
112
113
|
? order[sort_dir]
|
|
113
114
|
: "desc";
|
|
115
|
+
|
|
114
116
|
if (inc_sort_dir) {
|
|
115
117
|
return [column_name, inc_sort_dir];
|
|
116
118
|
}
|
|
119
|
+
|
|
117
120
|
return undefined;
|
|
118
121
|
}
|
package/src/ts/model/create.ts
CHANGED
|
@@ -87,21 +87,21 @@ export async function createModel(
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
let split_by_changed = old.split_by.length !== config.split_by.length;
|
|
90
|
-
if (split_by_changed) {
|
|
90
|
+
if (!split_by_changed) {
|
|
91
91
|
for (const lvl in old.split_by) {
|
|
92
92
|
split_by_changed ||= config.split_by[lvl] !== old.split_by[lvl];
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
let columns_changed = old.columns.length !== config.columns.length;
|
|
97
|
-
if (columns_changed) {
|
|
97
|
+
if (!columns_changed) {
|
|
98
98
|
for (const lvl in old.columns) {
|
|
99
99
|
columns_changed ||= config.columns[lvl] !== old.columns[lvl];
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
let filter_changed = old.filter.length !== config.filter.length;
|
|
104
|
-
if (filter_changed) {
|
|
104
|
+
if (!filter_changed) {
|
|
105
105
|
for (const lvl in old.filter) {
|
|
106
106
|
for (const i in config.filter[lvl]) {
|
|
107
107
|
filter_changed ||=
|
|
@@ -112,7 +112,7 @@ export async function createModel(
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
let sort_changed = old.sort.length !== config.sort.length;
|
|
115
|
-
if (sort_changed) {
|
|
115
|
+
if (!sort_changed) {
|
|
116
116
|
for (const lvl in old.sort) {
|
|
117
117
|
for (const i in config.sort[lvl]) {
|
|
118
118
|
sort_changed ||=
|
|
@@ -122,6 +122,9 @@ export async function createModel(
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
const group_rollup_mode_changed =
|
|
126
|
+
old.group_rollup_mode !== config.group_rollup_mode;
|
|
127
|
+
|
|
125
128
|
this._reset_scroll_top = group_by_changed;
|
|
126
129
|
this._reset_scroll_left = split_by_changed;
|
|
127
130
|
this._reset_select =
|
|
@@ -132,6 +135,7 @@ export async function createModel(
|
|
|
132
135
|
columns_changed;
|
|
133
136
|
|
|
134
137
|
this._reset_column_size =
|
|
138
|
+
group_rollup_mode_changed ||
|
|
135
139
|
split_by_changed ||
|
|
136
140
|
group_by_changed ||
|
|
137
141
|
columns_changed ||
|
|
@@ -148,15 +152,15 @@ export async function createModel(
|
|
|
148
152
|
]);
|
|
149
153
|
|
|
150
154
|
const _plugin_background = chroma(
|
|
151
|
-
get_rule(regular, "--
|
|
155
|
+
get_rule(regular, "--psp--background-color", "#FFFFFF"),
|
|
152
156
|
).rgb();
|
|
153
157
|
|
|
154
158
|
const _pos_fg_color = make_color_record(
|
|
155
|
-
get_rule(regular, "--
|
|
159
|
+
get_rule(regular, "--psp-datagrid--pos-cell--color", "#338DCD"),
|
|
156
160
|
);
|
|
157
161
|
|
|
158
162
|
const _neg_fg_color = make_color_record(
|
|
159
|
-
get_rule(regular, "--
|
|
163
|
+
get_rule(regular, "--psp-datagrid--neg-cell--color", "#FF5942"),
|
|
160
164
|
);
|
|
161
165
|
|
|
162
166
|
const _pos_bg_color = make_color_record(
|
|
@@ -168,7 +172,7 @@ export async function createModel(
|
|
|
168
172
|
);
|
|
169
173
|
|
|
170
174
|
const _color = make_color_record(
|
|
171
|
-
get_rule(regular, "--active--color", "#ff0000"),
|
|
175
|
+
get_rule(regular, "--psp-active--color", "#ff0000"),
|
|
172
176
|
);
|
|
173
177
|
|
|
174
178
|
const _schema: Schema = {
|
package/src/ts/plugin/draw.ts
CHANGED
|
@@ -49,6 +49,11 @@ export function applyBodyCellStyles(
|
|
|
49
49
|
const hasSelected = selectedRowsMap.has(regularTable);
|
|
50
50
|
const selected = selectedRowsMap.get(regularTable);
|
|
51
51
|
|
|
52
|
+
regularTable.classList.toggle(
|
|
53
|
+
"flat-group-rollup-mode",
|
|
54
|
+
this._config.group_rollup_mode === "flat",
|
|
55
|
+
);
|
|
56
|
+
|
|
52
57
|
for (const { element: td, metadata, isHeader } of cells) {
|
|
53
58
|
const column_name =
|
|
54
59
|
metadata.column_header?.[this._config.split_by.length];
|
|
@@ -60,18 +65,20 @@ export function applyBodyCellStyles(
|
|
|
60
65
|
|
|
61
66
|
// Calculate aggregate depth visibility
|
|
62
67
|
// @ts-ignore
|
|
63
|
-
metadata._is_hidden_by_aggregate_depth =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
metadata._is_hidden_by_aggregate_depth =
|
|
69
|
+
this._config.group_rollup_mode === "rollup" &&
|
|
70
|
+
((x?: number) =>
|
|
71
|
+
x === 0 || x === undefined
|
|
72
|
+
? false
|
|
73
|
+
: x - 1 <
|
|
74
|
+
Math.min(
|
|
75
|
+
this._config.group_by.length,
|
|
76
|
+
plugin?.aggregate_depth || 0,
|
|
77
|
+
))(
|
|
78
|
+
(metadata.row_header as unknown[] | undefined)?.filter(
|
|
79
|
+
(x) => x !== undefined,
|
|
80
|
+
)?.length,
|
|
81
|
+
);
|
|
75
82
|
|
|
76
83
|
// Apply type-specific cell styling
|
|
77
84
|
if (is_numeric) {
|
|
@@ -87,7 +94,7 @@ export function applyBodyCellStyles(
|
|
|
87
94
|
} else if (type === "string") {
|
|
88
95
|
cell_style_string.call(this, plugin as any, td, metadata as any);
|
|
89
96
|
} else if (type === "date" || type === "datetime") {
|
|
90
|
-
cell_style_datetime.call(this, plugin as any, td, metadata
|
|
97
|
+
cell_style_datetime.call(this, plugin as any, td, metadata);
|
|
91
98
|
} else {
|
|
92
99
|
td.style.backgroundColor = "";
|
|
93
100
|
td.style.color = "";
|