@perspective-dev/viewer-datagrid 4.1.1 → 4.3.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.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/click/edit_click.d.ts +1 -1
- package/dist/esm/event_handlers/row_select_click.d.ts +1 -1
- package/dist/esm/model/create.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/body.d.ts +1 -1
- package/dist/esm/style_handlers/column_header.d.ts +1 -1
- package/dist/esm/style_handlers/consolidated.d.ts +2 -5
- package/dist/esm/style_handlers/table_cell/boolean.d.ts +1 -5
- package/dist/esm/style_handlers/table_cell/cell_flash.d.ts +2 -2
- package/dist/esm/style_handlers/table_cell/datetime.d.ts +1 -5
- package/dist/esm/style_handlers/table_cell/row_header.d.ts +2 -2
- package/dist/esm/style_handlers/types.d.ts +2 -5
- package/dist/esm/types.d.ts +4 -9
- package/package.json +3 -3
- package/src/less/regular_table.less +39 -22
- package/src/ts/color_utils.ts +0 -1
- 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/click/edit_click.ts +13 -10
- package/src/ts/event_handlers/dispatch_click.ts +2 -4
- package/src/ts/event_handlers/expand_collapse.ts +4 -3
- package/src/ts/event_handlers/focus.ts +1 -1
- package/src/ts/event_handlers/header_click.ts +1 -1
- package/src/ts/event_handlers/keydown/edit_keydown.ts +2 -2
- package/src/ts/event_handlers/row_select_click.ts +24 -19
- package/src/ts/event_handlers/select_region.ts +23 -11
- package/src/ts/event_handlers/sort.ts +11 -8
- package/src/ts/get_cell_config.ts +1 -0
- package/src/ts/model/create.ts +19 -22
- package/src/ts/plugin/draw.ts +1 -0
- package/src/ts/style_handlers/body.ts +21 -21
- package/src/ts/style_handlers/column_header.ts +21 -9
- package/src/ts/style_handlers/consolidated.ts +8 -13
- package/src/ts/style_handlers/focus.ts +4 -10
- package/src/ts/style_handlers/group_header.ts +6 -3
- package/src/ts/style_handlers/table_cell/boolean.ts +2 -5
- package/src/ts/style_handlers/table_cell/cell_flash.ts +2 -2
- package/src/ts/style_handlers/table_cell/datetime.ts +2 -5
- package/src/ts/style_handlers/table_cell/row_header.ts +8 -7
- package/src/ts/style_handlers/types.ts +6 -6
- package/src/ts/types.ts +18 -8
|
@@ -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,13 +49,13 @@ 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;
|
|
56
56
|
|
|
57
57
|
const abs = event.shiftKey;
|
|
58
|
-
const sort = sort_method.call(this, column_name
|
|
58
|
+
const sort = sort_method.call(this, `${column_name}`, abs);
|
|
59
59
|
await viewer.restore({ sort });
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -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
|
@@ -19,16 +19,17 @@ import type {
|
|
|
19
19
|
View,
|
|
20
20
|
ViewConfig,
|
|
21
21
|
} from "@perspective-dev/client";
|
|
22
|
-
import
|
|
23
|
-
DatagridModel,
|
|
24
|
-
DatagridPluginElement,
|
|
25
|
-
RegularTable,
|
|
26
|
-
Schema,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
import {
|
|
23
|
+
type DatagridModel,
|
|
24
|
+
type DatagridPluginElement,
|
|
25
|
+
type RegularTable,
|
|
26
|
+
type Schema,
|
|
27
|
+
type ElemFactory,
|
|
28
|
+
type EditMode,
|
|
29
|
+
type PerspectiveViewerElement,
|
|
30
|
+
get_psp_type,
|
|
31
31
|
} from "../types.js";
|
|
32
|
+
import { CellMetadata } from "regular-table/dist/esm/types.js";
|
|
32
33
|
|
|
33
34
|
function get_rule(regular: HTMLElement, tag: string, def: string): string {
|
|
34
35
|
const color = window.getComputedStyle(regular).getPropertyValue(tag).trim();
|
|
@@ -64,14 +65,6 @@ class ElemFactoryImpl implements ElemFactory {
|
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
function get_psp_type(this: DatagridModel, metadata: CellMeta): ColumnType {
|
|
68
|
-
if (metadata.x !== undefined && metadata.x >= 0) {
|
|
69
|
-
return this._column_types[metadata.x];
|
|
70
|
-
} else {
|
|
71
|
-
return this._row_header_types[metadata.row_header_x! - 1];
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
68
|
export async function createModel(
|
|
76
69
|
this: DatagridPluginElement,
|
|
77
70
|
regular: RegularTable,
|
|
@@ -94,21 +87,21 @@ export async function createModel(
|
|
|
94
87
|
}
|
|
95
88
|
|
|
96
89
|
let split_by_changed = old.split_by.length !== config.split_by.length;
|
|
97
|
-
if (split_by_changed) {
|
|
90
|
+
if (!split_by_changed) {
|
|
98
91
|
for (const lvl in old.split_by) {
|
|
99
92
|
split_by_changed ||= config.split_by[lvl] !== old.split_by[lvl];
|
|
100
93
|
}
|
|
101
94
|
}
|
|
102
95
|
|
|
103
96
|
let columns_changed = old.columns.length !== config.columns.length;
|
|
104
|
-
if (columns_changed) {
|
|
97
|
+
if (!columns_changed) {
|
|
105
98
|
for (const lvl in old.columns) {
|
|
106
99
|
columns_changed ||= config.columns[lvl] !== old.columns[lvl];
|
|
107
100
|
}
|
|
108
101
|
}
|
|
109
102
|
|
|
110
103
|
let filter_changed = old.filter.length !== config.filter.length;
|
|
111
|
-
if (filter_changed) {
|
|
104
|
+
if (!filter_changed) {
|
|
112
105
|
for (const lvl in old.filter) {
|
|
113
106
|
for (const i in config.filter[lvl]) {
|
|
114
107
|
filter_changed ||=
|
|
@@ -119,7 +112,7 @@ export async function createModel(
|
|
|
119
112
|
}
|
|
120
113
|
|
|
121
114
|
let sort_changed = old.sort.length !== config.sort.length;
|
|
122
|
-
if (sort_changed) {
|
|
115
|
+
if (!sort_changed) {
|
|
123
116
|
for (const lvl in old.sort) {
|
|
124
117
|
for (const i in config.sort[lvl]) {
|
|
125
118
|
sort_changed ||=
|
|
@@ -129,6 +122,9 @@ export async function createModel(
|
|
|
129
122
|
}
|
|
130
123
|
}
|
|
131
124
|
|
|
125
|
+
const group_rollup_mode_changed =
|
|
126
|
+
old.group_rollup_mode !== config.group_rollup_mode;
|
|
127
|
+
|
|
132
128
|
this._reset_scroll_top = group_by_changed;
|
|
133
129
|
this._reset_scroll_left = split_by_changed;
|
|
134
130
|
this._reset_select =
|
|
@@ -139,6 +135,7 @@ export async function createModel(
|
|
|
139
135
|
columns_changed;
|
|
140
136
|
|
|
141
137
|
this._reset_column_size =
|
|
138
|
+
group_rollup_mode_changed ||
|
|
142
139
|
split_by_changed ||
|
|
143
140
|
group_by_changed ||
|
|
144
141
|
columns_changed ||
|
|
@@ -222,7 +219,7 @@ export async function createModel(
|
|
|
222
219
|
}),
|
|
223
220
|
_series_color_map: new Map<string, string>(),
|
|
224
221
|
_series_color_seed: new Map<string, number>(),
|
|
225
|
-
get_psp_type,
|
|
222
|
+
// get_psp_type,
|
|
226
223
|
_div_factory: extend._div_factory || new ElemFactoryImpl("div"),
|
|
227
224
|
}) as DatagridModel;
|
|
228
225
|
|
package/src/ts/plugin/draw.ts
CHANGED
|
@@ -12,11 +12,12 @@
|
|
|
12
12
|
|
|
13
13
|
import { RegularTableElement } from "regular-table";
|
|
14
14
|
|
|
15
|
-
import
|
|
16
|
-
DatagridModel,
|
|
17
|
-
PerspectiveViewerElement,
|
|
18
|
-
ColumnsConfig,
|
|
19
|
-
DatagridPluginElement,
|
|
15
|
+
import {
|
|
16
|
+
type DatagridModel,
|
|
17
|
+
type PerspectiveViewerElement,
|
|
18
|
+
type ColumnsConfig,
|
|
19
|
+
type DatagridPluginElement,
|
|
20
|
+
get_psp_type,
|
|
20
21
|
} from "../types.js";
|
|
21
22
|
|
|
22
23
|
import { cell_style_numeric } from "./table_cell/numeric.js";
|
|
@@ -28,20 +29,7 @@ import {
|
|
|
28
29
|
CollectedCell,
|
|
29
30
|
LocalSelectedPositionMap,
|
|
30
31
|
LocalSelectedRowsMap,
|
|
31
|
-
CellMetaExtended,
|
|
32
32
|
} from "./types.js";
|
|
33
|
-
import { ColumnType } from "@perspective-dev/client";
|
|
34
|
-
|
|
35
|
-
function get_psp_type(
|
|
36
|
-
model: DatagridModel,
|
|
37
|
-
metadata: CellMetaExtended,
|
|
38
|
-
): ColumnType {
|
|
39
|
-
if (metadata.x !== undefined && metadata.x >= 0) {
|
|
40
|
-
return model._column_types[metadata.x];
|
|
41
|
-
} else {
|
|
42
|
-
return model._row_header_types[(metadata.row_header_x ?? 0) - 1];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
33
|
|
|
46
34
|
/**
|
|
47
35
|
* Apply styles to all body cells in a single pass.
|
|
@@ -61,6 +49,11 @@ export function applyBodyCellStyles(
|
|
|
61
49
|
const hasSelected = selectedRowsMap.has(regularTable);
|
|
62
50
|
const selected = selectedRowsMap.get(regularTable);
|
|
63
51
|
|
|
52
|
+
regularTable.classList.toggle(
|
|
53
|
+
"flat-group-rollup-mode",
|
|
54
|
+
this._config.group_rollup_mode === "flat",
|
|
55
|
+
);
|
|
56
|
+
|
|
64
57
|
for (const { element: td, metadata, isHeader } of cells) {
|
|
65
58
|
const column_name =
|
|
66
59
|
metadata.column_header?.[this._config.split_by.length];
|
|
@@ -71,6 +64,7 @@ export function applyBodyCellStyles(
|
|
|
71
64
|
const is_numeric = type === "integer" || type === "float";
|
|
72
65
|
|
|
73
66
|
// Calculate aggregate depth visibility
|
|
67
|
+
// @ts-ignore
|
|
74
68
|
metadata._is_hidden_by_aggregate_depth = ((x?: number) =>
|
|
75
69
|
x === 0 || x === undefined
|
|
76
70
|
? false
|
|
@@ -109,6 +103,7 @@ export function applyBodyCellStyles(
|
|
|
109
103
|
"psp-bool-type",
|
|
110
104
|
type === "boolean" && metadata.user !== null,
|
|
111
105
|
);
|
|
106
|
+
|
|
112
107
|
td.classList.toggle("psp-null", metadata.value === null);
|
|
113
108
|
td.classList.toggle("psp-align-right", !isHeader && is_numeric);
|
|
114
109
|
td.classList.toggle("psp-align-left", isHeader || !is_numeric);
|
|
@@ -138,14 +133,18 @@ export function applyBodyCellStyles(
|
|
|
138
133
|
}
|
|
139
134
|
|
|
140
135
|
if (
|
|
141
|
-
metadata.
|
|
136
|
+
metadata.type !== "row_header" ||
|
|
142
137
|
metadata.row_header_x ===
|
|
143
138
|
(metadata.row_header as unknown[]).length - 1 ||
|
|
144
139
|
(metadata.row_header as unknown[])[metadata.row_header_x + 1] ===
|
|
145
140
|
undefined
|
|
146
141
|
) {
|
|
147
142
|
td.dataset.y = String(metadata.y);
|
|
148
|
-
|
|
143
|
+
if (metadata.type !== "row_header") {
|
|
144
|
+
td.dataset.x = String(metadata.x);
|
|
145
|
+
} else {
|
|
146
|
+
delete td.dataset.x;
|
|
147
|
+
}
|
|
149
148
|
} else {
|
|
150
149
|
delete td.dataset.y;
|
|
151
150
|
delete td.dataset.x;
|
|
@@ -166,6 +165,7 @@ export function applyBodyCellStyles(
|
|
|
166
165
|
const selectedArr = selected as unknown[];
|
|
167
166
|
if (isHeader) {
|
|
168
167
|
if (
|
|
168
|
+
metadata.type === "row_header" &&
|
|
169
169
|
metadata.row_header_x !== undefined &&
|
|
170
170
|
!!id[metadata.row_header_x]
|
|
171
171
|
) {
|
|
@@ -195,7 +195,7 @@ export function applyBodyCellStyles(
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
// Apply editable styling (if editable)
|
|
198
|
-
if (!isHeader && metadata.
|
|
198
|
+
if (!isHeader && metadata.type === "body") {
|
|
199
199
|
if (isEditable && this._is_editable[metadata.x]) {
|
|
200
200
|
const col_name =
|
|
201
201
|
metadata.column_header?.[this._config.split_by.length];
|
|
@@ -11,7 +11,11 @@
|
|
|
11
11
|
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
12
12
|
|
|
13
13
|
import { RegularTableElement } from "regular-table";
|
|
14
|
-
import
|
|
14
|
+
import {
|
|
15
|
+
get_psp_type,
|
|
16
|
+
type DatagridModel,
|
|
17
|
+
type PerspectiveViewerElement,
|
|
18
|
+
} from "../types.js";
|
|
15
19
|
import { CollectedHeaderRow } from "./types.js";
|
|
16
20
|
|
|
17
21
|
/**
|
|
@@ -93,20 +97,28 @@ export function styleColumnHeaderRow(
|
|
|
93
97
|
regularTable: RegularTableElement,
|
|
94
98
|
is_menu_row: boolean,
|
|
95
99
|
): void {
|
|
96
|
-
const header_depth =
|
|
97
|
-
|
|
100
|
+
const header_depth =
|
|
101
|
+
this._config.group_by.length -
|
|
102
|
+
(this._config.group_rollup_mode === "flat" ? 1 : 0);
|
|
98
103
|
|
|
104
|
+
const selectedColumn = this._column_settings_selected_column;
|
|
99
105
|
for (const { element: td, metadata } of headerRow.cells) {
|
|
100
|
-
if (
|
|
106
|
+
if (
|
|
107
|
+
!metadata ||
|
|
108
|
+
metadata.type === "body" ||
|
|
109
|
+
metadata.type === "row_header"
|
|
110
|
+
)
|
|
111
|
+
continue;
|
|
101
112
|
|
|
102
113
|
const column_name =
|
|
103
114
|
metadata.column_header?.[this._config.split_by.length];
|
|
115
|
+
|
|
104
116
|
const sort = this._config.sort.find((x) => x[0] === column_name);
|
|
105
|
-
let needs_border = metadata.row_header_x === header_depth;
|
|
106
117
|
const is_corner = typeof metadata.x === "undefined";
|
|
107
|
-
needs_border =
|
|
108
|
-
|
|
109
|
-
|
|
118
|
+
const needs_border =
|
|
119
|
+
(metadata.type === "corner" &&
|
|
120
|
+
metadata.row_header_x === header_depth) ||
|
|
121
|
+
(!is_corner &&
|
|
110
122
|
(metadata.x + 1) % this._config.columns.length === 0);
|
|
111
123
|
|
|
112
124
|
td.classList.toggle("psp-header-border", needs_border);
|
|
@@ -147,7 +159,7 @@ export function styleColumnHeaderRow(
|
|
|
147
159
|
!is_menu_row && !!sort && sort[1] === "col desc abs",
|
|
148
160
|
);
|
|
149
161
|
|
|
150
|
-
const type =
|
|
162
|
+
const type = get_psp_type(this, metadata);
|
|
151
163
|
const is_numeric = type === "integer" || type === "float";
|
|
152
164
|
const is_string = type === "string";
|
|
153
165
|
const is_date = type === "date";
|
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
12
12
|
|
|
13
13
|
import { RegularTableElement } from "regular-table";
|
|
14
|
-
import { CellMetadata } from "regular-table/dist/esm/types.js";
|
|
15
|
-
import { ColumnType } from "@perspective-dev/client";
|
|
16
14
|
import { PRIVATE_PLUGIN_SYMBOL } from "../model/index.js";
|
|
17
15
|
import type {
|
|
18
16
|
DatagridModel,
|
|
@@ -27,14 +25,11 @@ import { styleColumnHeaderRow } from "./column_header.js";
|
|
|
27
25
|
import { applyColumnHeaderStyles } from "./editable.js";
|
|
28
26
|
import { applyGroupHeaderStyles } from "./group_header.js";
|
|
29
27
|
import { applyBodyCellStyles } from "./body.js";
|
|
30
|
-
|
|
31
|
-
interface CellMetaExtended extends CellMetadata {
|
|
32
|
-
_is_hidden_by_aggregate_depth?: boolean;
|
|
33
|
-
}
|
|
28
|
+
import { CellMetadata } from "regular-table/dist/esm/types.js";
|
|
34
29
|
|
|
35
30
|
interface CollectedCell {
|
|
36
31
|
element: HTMLElement;
|
|
37
|
-
metadata:
|
|
32
|
+
metadata: CellMetadata;
|
|
38
33
|
isHeader: boolean;
|
|
39
34
|
}
|
|
40
35
|
|
|
@@ -118,9 +113,9 @@ export function createConsolidatedStyleListener(
|
|
|
118
113
|
if (tbody) {
|
|
119
114
|
for (const tr of tbody.children) {
|
|
120
115
|
for (const cell of tr.children) {
|
|
121
|
-
const metadata = regularTable.getMeta(
|
|
122
|
-
|
|
123
|
-
|
|
116
|
+
const metadata = regularTable.getMeta(
|
|
117
|
+
cell as HTMLElement,
|
|
118
|
+
) as CellMetadata | undefined;
|
|
124
119
|
|
|
125
120
|
if (metadata) {
|
|
126
121
|
const isHeader = cell.tagName === "TH";
|
|
@@ -144,9 +139,9 @@ export function createConsolidatedStyleListener(
|
|
|
144
139
|
};
|
|
145
140
|
|
|
146
141
|
for (const cell of tr.children) {
|
|
147
|
-
const metadata = regularTable.getMeta(
|
|
148
|
-
|
|
149
|
-
|
|
142
|
+
const metadata = regularTable.getMeta(
|
|
143
|
+
cell as HTMLElement,
|
|
144
|
+
) as CellMetadata | undefined;
|
|
150
145
|
|
|
151
146
|
rowData.cells.push({
|
|
152
147
|
element: cell as HTMLTableCellElement,
|
|
@@ -12,12 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import { RegularTableElement } from "regular-table";
|
|
14
14
|
import type { DatagridModel, SelectedPosition } from "../types.js";
|
|
15
|
-
|
|
16
|
-
import {
|
|
17
|
-
CollectedCell,
|
|
18
|
-
LocalSelectedPositionMap,
|
|
19
|
-
CellMetaExtended,
|
|
20
|
-
} from "./types.js";
|
|
15
|
+
import { CollectedCell, LocalSelectedPositionMap } from "./types.js";
|
|
21
16
|
|
|
22
17
|
/**
|
|
23
18
|
* Apply focus style to the selected cell.
|
|
@@ -35,6 +30,7 @@ export function applyFocusStyle(
|
|
|
35
30
|
if (selected_position) {
|
|
36
31
|
for (const { element: td, metadata } of cells) {
|
|
37
32
|
if (
|
|
33
|
+
metadata.type === "body" &&
|
|
38
34
|
metadata.x === selected_position.x &&
|
|
39
35
|
metadata.y === selected_position.y
|
|
40
36
|
) {
|
|
@@ -77,11 +73,9 @@ export function focusSelectedCell(
|
|
|
77
73
|
if (tbody) {
|
|
78
74
|
for (const tr of tbody.children) {
|
|
79
75
|
for (const cell of tr.children) {
|
|
80
|
-
const metadata = regularTable.getMeta(cell
|
|
81
|
-
| CellMetaExtended
|
|
82
|
-
| undefined;
|
|
76
|
+
const metadata = regularTable.getMeta(cell as HTMLElement);
|
|
83
77
|
if (
|
|
84
|
-
metadata &&
|
|
78
|
+
metadata?.type === "body" &&
|
|
85
79
|
metadata.x === selected_position.x &&
|
|
86
80
|
metadata.y === selected_position.y
|
|
87
81
|
) {
|
|
@@ -38,8 +38,10 @@ export function applyGroupHeaderStyles(
|
|
|
38
38
|
td.style.backgroundColor = "";
|
|
39
39
|
|
|
40
40
|
const needs_border =
|
|
41
|
-
(
|
|
42
|
-
|
|
41
|
+
(metadata.type === "corner" &&
|
|
42
|
+
header_depth > 0 &&
|
|
43
|
+
metadata.row_header_x === header_depth) ||
|
|
44
|
+
(metadata.type === "column_header" && metadata.x >= 0);
|
|
43
45
|
|
|
44
46
|
td.classList.toggle("psp-align-right", false);
|
|
45
47
|
td.classList.toggle("psp-align-left", false);
|
|
@@ -48,8 +50,9 @@ export function applyGroupHeaderStyles(
|
|
|
48
50
|
td.classList.toggle("psp-header-border", needs_border);
|
|
49
51
|
td.classList.toggle(
|
|
50
52
|
"psp-header-group-corner",
|
|
51
|
-
|
|
53
|
+
metadata.type === "corner",
|
|
52
54
|
);
|
|
55
|
+
|
|
53
56
|
td.classList.toggle("psp-color-mode-bar", false);
|
|
54
57
|
td.classList.toggle("psp-header-sort-asc", false);
|
|
55
58
|
td.classList.toggle("psp-header-sort-desc", false);
|
|
@@ -13,16 +13,13 @@
|
|
|
13
13
|
import { CellMetadata } from "regular-table/dist/esm/types.js";
|
|
14
14
|
import type { DatagridModel, ColumnConfig, ColorRecord } from "../../types.js";
|
|
15
15
|
|
|
16
|
-
interface CellMetaWithFlags extends CellMetadata {
|
|
17
|
-
_is_hidden_by_aggregate_depth?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
16
|
export function cell_style_boolean(
|
|
21
17
|
this: DatagridModel,
|
|
22
18
|
_plugin: ColumnConfig | undefined,
|
|
23
19
|
td: HTMLElement,
|
|
24
|
-
metadata:
|
|
20
|
+
metadata: CellMetadata,
|
|
25
21
|
): void {
|
|
22
|
+
// @ts-ignore
|
|
26
23
|
if (metadata._is_hidden_by_aggregate_depth) {
|
|
27
24
|
td.style.backgroundColor = "";
|
|
28
25
|
td.style.color = "";
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
|
|
11
11
|
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { CellMetadataBody } from "regular-table/dist/esm/types.js";
|
|
14
14
|
import type { DatagridModel, ColorRecord } from "../../types.js";
|
|
15
15
|
|
|
16
16
|
export function style_cell_flash(
|
|
17
17
|
this: DatagridModel,
|
|
18
|
-
metadata:
|
|
18
|
+
metadata: CellMetadataBody,
|
|
19
19
|
td: HTMLElement,
|
|
20
20
|
[, , , , , pos_s, pos_e]: ColorRecord,
|
|
21
21
|
[, , , , , neg_s, neg_e]: ColorRecord,
|
|
@@ -17,15 +17,11 @@ import {
|
|
|
17
17
|
} from "../../color_utils.js";
|
|
18
18
|
import type { DatagridModel, ColumnConfig, ColorRecord } from "../../types.js";
|
|
19
19
|
|
|
20
|
-
interface CellMetaWithFlags extends CellMetadata {
|
|
21
|
-
_is_hidden_by_aggregate_depth?: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
20
|
export function cell_style_datetime(
|
|
25
21
|
this: DatagridModel,
|
|
26
22
|
plugin: ColumnConfig,
|
|
27
23
|
td: HTMLElement,
|
|
28
|
-
metadata:
|
|
24
|
+
metadata: CellMetadata,
|
|
29
25
|
): void {
|
|
30
26
|
const colorRecord: ColorRecord = //(() => {
|
|
31
27
|
// if (plugin?.color !== undefined) {
|
|
@@ -38,6 +34,7 @@ export function cell_style_datetime(
|
|
|
38
34
|
|
|
39
35
|
const [hex, r, g, b] = colorRecord;
|
|
40
36
|
|
|
37
|
+
// @ts-ignore
|
|
41
38
|
if (metadata._is_hidden_by_aggregate_depth) {
|
|
42
39
|
td.style.backgroundColor = "";
|
|
43
40
|
td.style.color = "";
|
|
@@ -10,19 +10,18 @@
|
|
|
10
10
|
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
|
|
11
11
|
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
CellMetadata,
|
|
15
|
+
CellMetadataRowHeader,
|
|
16
|
+
} from "regular-table/dist/esm/types.js";
|
|
14
17
|
import type { DatagridModel } from "../../types.js";
|
|
15
18
|
import { RegularTableElement } from "regular-table";
|
|
16
19
|
|
|
17
|
-
interface NextMeta {
|
|
18
|
-
row_header?: unknown[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
20
|
export function cell_style_row_header(
|
|
22
21
|
this: DatagridModel,
|
|
23
22
|
regularTable: RegularTableElement,
|
|
24
23
|
td: HTMLElement,
|
|
25
|
-
metadata:
|
|
24
|
+
metadata: CellMetadataRowHeader,
|
|
26
25
|
): void {
|
|
27
26
|
const is_not_empty =
|
|
28
27
|
metadata.value !== undefined &&
|
|
@@ -33,12 +32,14 @@ export function cell_style_row_header(
|
|
|
33
32
|
const next = regularTable.getMeta({
|
|
34
33
|
dx: 0,
|
|
35
34
|
dy: (metadata.y ?? 0) - (metadata.y0 ?? 0) + 1,
|
|
36
|
-
} as
|
|
35
|
+
} as CellMetadata);
|
|
36
|
+
|
|
37
37
|
const is_collapse =
|
|
38
38
|
next &&
|
|
39
39
|
next.row_header &&
|
|
40
40
|
typeof next.row_header[(metadata.row_header_x ?? 0) + 1] !==
|
|
41
41
|
"undefined";
|
|
42
|
+
|
|
42
43
|
td.classList.toggle("psp-tree-label", is_not_empty && !is_leaf);
|
|
43
44
|
td.classList.toggle(
|
|
44
45
|
"psp-tree-label-expand",
|
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
12
12
|
|
|
13
13
|
import { RegularTableElement } from "regular-table";
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
CellMetadata,
|
|
16
|
+
CellMetadataBody,
|
|
17
|
+
CellMetadataRowHeader,
|
|
18
|
+
} from "regular-table/dist/esm/types.js";
|
|
15
19
|
import type { SelectedPosition } from "../types.js";
|
|
16
20
|
|
|
17
|
-
export interface CellMetaExtended extends CellMetadata {
|
|
18
|
-
_is_hidden_by_aggregate_depth?: boolean;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
21
|
export interface CollectedCell {
|
|
22
22
|
element: HTMLElement;
|
|
23
|
-
metadata:
|
|
23
|
+
metadata: CellMetadataRowHeader | CellMetadataBody;
|
|
24
24
|
isHeader: boolean;
|
|
25
25
|
}
|
|
26
26
|
|
package/src/ts/types.ts
CHANGED
|
@@ -17,13 +17,28 @@ import type {
|
|
|
17
17
|
ColumnType,
|
|
18
18
|
SortDir,
|
|
19
19
|
ViewWindow,
|
|
20
|
+
ViewConfigUpdate,
|
|
20
21
|
} from "@perspective-dev/client";
|
|
21
22
|
import { RegularTableElement } from "regular-table";
|
|
22
23
|
import { CellMetadata, DataResponse } from "regular-table/dist/esm/types";
|
|
23
24
|
|
|
24
25
|
// Re-export types from regular-table for use throughout the codebase
|
|
25
26
|
export type { RegularTableElement as RegularTable };
|
|
26
|
-
|
|
27
|
+
|
|
28
|
+
export function get_psp_type(
|
|
29
|
+
model: DatagridModel,
|
|
30
|
+
metadata: CellMetadata,
|
|
31
|
+
): ColumnType {
|
|
32
|
+
if (
|
|
33
|
+
metadata.type === "body" ||
|
|
34
|
+
metadata.type === "column_header" ||
|
|
35
|
+
metadata.type === "corner"
|
|
36
|
+
) {
|
|
37
|
+
return model._column_types[metadata.x];
|
|
38
|
+
} else {
|
|
39
|
+
return model._row_header_types[(metadata.row_header_x ?? 0) - 1];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
27
42
|
|
|
28
43
|
// Edit mode for the datagrid
|
|
29
44
|
export type EditMode =
|
|
@@ -230,7 +245,7 @@ export type FormatterCache = Map<string, FormatterCacheEntry>;
|
|
|
230
245
|
export interface CellConfigResult {
|
|
231
246
|
row: Record<string, unknown>;
|
|
232
247
|
column_names: string[];
|
|
233
|
-
config:
|
|
248
|
+
config: ViewConfigUpdate;
|
|
234
249
|
}
|
|
235
250
|
|
|
236
251
|
// Custom event detail types
|
|
@@ -240,12 +255,7 @@ export interface PerspectiveClickDetail {
|
|
|
240
255
|
config: Partial<ViewConfig>;
|
|
241
256
|
}
|
|
242
257
|
|
|
243
|
-
export
|
|
244
|
-
selected: boolean;
|
|
245
|
-
row: Record<string, unknown>;
|
|
246
|
-
column_names?: string[];
|
|
247
|
-
config: Partial<ViewConfig>;
|
|
248
|
-
}
|
|
258
|
+
export { PerspectiveSelectDetail } from "@perspective-dev/viewer";
|
|
249
259
|
|
|
250
260
|
// Mouse event with handled flag
|
|
251
261
|
export interface HandledMouseEvent extends MouseEvent {
|