@perspective-dev/viewer-datagrid 4.0.0 → 4.1.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 +4 -17
- package/dist/cdn/perspective-viewer-datagrid.js.map +4 -4
- package/dist/css/perspective-viewer-datagrid.css +1 -1
- package/dist/esm/color_utils.d.ts +9 -0
- package/dist/esm/custom_elements/datagrid.d.ts +52 -0
- package/dist/esm/custom_elements/toolbar.d.ts +10 -0
- package/dist/esm/data_listener/format_cell.d.ts +8 -0
- package/dist/esm/data_listener/format_tree_header.d.ts +13 -0
- package/dist/esm/data_listener/formatter_cache.d.ts +16 -0
- package/dist/esm/data_listener/index.d.ts +10 -0
- package/dist/esm/event_handlers/click/edit_click.d.ts +3 -0
- package/dist/esm/event_handlers/click.d.ts +7 -0
- package/dist/esm/event_handlers/deselect_all.d.ts +5 -0
- package/dist/esm/event_handlers/dispatch_click.d.ts +3 -0
- package/dist/esm/event_handlers/expand_collapse.d.ts +2 -0
- package/dist/esm/event_handlers/focus.d.ts +5 -0
- package/dist/esm/event_handlers/header_click.d.ts +3 -0
- package/dist/esm/event_handlers/keydown/edit_keydown.d.ts +4 -0
- package/dist/esm/event_handlers/row_select_click.d.ts +4 -0
- package/dist/esm/event_handlers/select_region.d.ts +9 -0
- package/dist/esm/event_handlers/sort.d.ts +7 -0
- package/dist/esm/get_cell_config.d.ts +8 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/model/column_overrides.d.ts +23 -0
- package/dist/esm/model/create.d.ts +3 -0
- package/dist/esm/model/index.d.ts +4 -0
- package/dist/esm/model/toolbar.d.ts +4 -0
- package/dist/esm/perspective-viewer-datagrid.js +3 -3
- package/dist/esm/perspective-viewer-datagrid.js.map +4 -4
- package/dist/esm/plugin/activate.d.ts +6 -0
- package/dist/esm/plugin/column_style_controls.d.ts +28 -0
- package/dist/esm/plugin/draw.d.ts +7 -0
- package/dist/esm/plugin/restore.d.ts +10 -0
- package/dist/esm/plugin/save.d.ts +2 -0
- package/dist/esm/style_handlers/body.d.ts +7 -0
- package/dist/esm/style_handlers/column_header.d.ts +13 -0
- package/dist/esm/style_handlers/consolidated.d.ts +57 -0
- package/dist/esm/style_handlers/editable.d.ts +7 -0
- package/dist/esm/style_handlers/focus.d.ts +16 -0
- package/dist/esm/style_handlers/group_header.d.ts +7 -0
- package/dist/esm/style_handlers/table_cell/boolean.d.ts +7 -0
- package/dist/esm/style_handlers/table_cell/cell_flash.d.ts +3 -0
- package/dist/esm/style_handlers/table_cell/datetime.d.ts +7 -0
- package/dist/esm/style_handlers/table_cell/numeric.d.ts +15 -0
- package/dist/esm/style_handlers/table_cell/row_header.d.ts +4 -0
- package/dist/esm/style_handlers/table_cell/string.d.ts +11 -0
- package/dist/esm/style_handlers/types.d.ts +20 -0
- package/dist/esm/types.d.ts +193 -0
- package/package.json +10 -5
- package/src/less/mitered-headers.less +65 -0
- package/src/less/pro.less +196 -0
- package/src/less/regular_table.less +509 -0
- package/src/less/row-hover.less +88 -0
- package/{index.d.ts → src/less/scrollbar.less} +18 -19
- package/src/less/sub-cell-scroll.less +82 -0
- package/src/less/toolbar.less +201 -0
- package/src/ts/color_utils.ts +70 -0
- package/src/ts/custom_elements/datagrid.ts +250 -0
- package/src/ts/custom_elements/toolbar.ts +75 -0
- package/src/ts/data_listener/format_cell.ts +84 -0
- package/src/ts/data_listener/format_tree_header.ts +82 -0
- package/src/ts/data_listener/formatter_cache.ts +191 -0
- package/src/ts/data_listener/index.ts +242 -0
- package/src/ts/event_handlers/click/edit_click.ts +73 -0
- package/src/ts/event_handlers/click.ts +92 -0
- package/src/ts/event_handlers/deselect_all.ts +28 -0
- package/src/ts/event_handlers/dispatch_click.ts +44 -0
- package/src/ts/event_handlers/expand_collapse.ts +44 -0
- package/src/ts/event_handlers/focus.ts +63 -0
- package/src/ts/event_handlers/header_click.ts +85 -0
- package/src/ts/event_handlers/keydown/edit_keydown.ts +213 -0
- package/src/ts/event_handlers/row_select_click.ts +87 -0
- package/src/ts/event_handlers/select_region.ts +427 -0
- package/src/ts/event_handlers/sort.ts +118 -0
- package/src/ts/get_cell_config.ts +68 -0
- package/src/ts/index.ts +49 -0
- package/src/ts/model/column_overrides.ts +112 -0
- package/src/ts/model/create.ts +247 -0
- package/src/ts/model/index.ts +19 -0
- package/src/ts/model/toolbar.ts +64 -0
- package/src/ts/plugin/activate.ts +235 -0
- package/src/ts/plugin/column_style_controls.ts +76 -0
- package/src/ts/plugin/draw.ts +69 -0
- package/src/ts/plugin/restore.ts +110 -0
- package/src/ts/plugin/save.ts +45 -0
- package/src/ts/style_handlers/body.ts +228 -0
- package/src/ts/style_handlers/column_header.ts +183 -0
- package/src/ts/style_handlers/consolidated.ts +223 -0
- package/src/ts/style_handlers/editable.ts +94 -0
- package/src/ts/style_handlers/focus.ts +106 -0
- package/src/ts/style_handlers/group_header.ts +78 -0
- package/src/ts/style_handlers/table_cell/boolean.ts +39 -0
- package/src/ts/style_handlers/table_cell/cell_flash.ts +75 -0
- package/src/ts/style_handlers/table_cell/datetime.ts +64 -0
- package/src/ts/style_handlers/table_cell/numeric.ts +186 -0
- package/src/ts/style_handlers/table_cell/row_header.ts +53 -0
- package/src/ts/style_handlers/table_cell/string.ts +102 -0
- package/src/ts/style_handlers/types.ts +41 -0
- package/src/ts/types.ts +279 -0
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
|
|
13
|
+
import { RegularTableElement } from "regular-table";
|
|
14
|
+
import type { DatagridModel } from "../types.js";
|
|
15
|
+
|
|
16
|
+
import { CollectedHeaderRow } from "./types.js";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Apply styles to group header rows.
|
|
20
|
+
*/
|
|
21
|
+
export function applyGroupHeaderStyles(
|
|
22
|
+
this: DatagridModel,
|
|
23
|
+
headerRows: CollectedHeaderRow[],
|
|
24
|
+
regularTable: RegularTableElement,
|
|
25
|
+
): void {
|
|
26
|
+
const header_depth = this._config.group_by.length;
|
|
27
|
+
const m: boolean[][] = [];
|
|
28
|
+
let marked = new Set<number>();
|
|
29
|
+
|
|
30
|
+
for (let y = 0; y < headerRows.length; y++) {
|
|
31
|
+
const { row, cells } = headerRows[y];
|
|
32
|
+
const tops = new Set<number>();
|
|
33
|
+
|
|
34
|
+
for (let x = 0; x < cells.length; x++) {
|
|
35
|
+
const { element: td, metadata } = cells[x];
|
|
36
|
+
if (!metadata) continue;
|
|
37
|
+
|
|
38
|
+
td.style.backgroundColor = "";
|
|
39
|
+
|
|
40
|
+
const needs_border =
|
|
41
|
+
(header_depth > 0 && metadata.row_header_x === header_depth) ||
|
|
42
|
+
(metadata.x ?? -1) >= 0;
|
|
43
|
+
|
|
44
|
+
td.classList.toggle("psp-align-right", false);
|
|
45
|
+
td.classList.toggle("psp-align-left", false);
|
|
46
|
+
td.classList.toggle("psp-header-group", true);
|
|
47
|
+
td.classList.toggle("psp-header-leaf", false);
|
|
48
|
+
td.classList.toggle("psp-header-border", needs_border);
|
|
49
|
+
td.classList.toggle(
|
|
50
|
+
"psp-header-group-corner",
|
|
51
|
+
typeof metadata.x === "undefined",
|
|
52
|
+
);
|
|
53
|
+
td.classList.toggle("psp-color-mode-bar", false);
|
|
54
|
+
td.classList.toggle("psp-header-sort-asc", false);
|
|
55
|
+
td.classList.toggle("psp-header-sort-desc", false);
|
|
56
|
+
td.classList.toggle("psp-header-sort-col-asc", false);
|
|
57
|
+
td.classList.toggle("psp-header-sort-col-desc", false);
|
|
58
|
+
td.classList.toggle("psp-sort-enabled", false);
|
|
59
|
+
|
|
60
|
+
// Calculate spanning for psp-is-top
|
|
61
|
+
let xx = x;
|
|
62
|
+
for (; m[y] && m[y][xx]; ++xx);
|
|
63
|
+
tops.add(xx);
|
|
64
|
+
|
|
65
|
+
const cell = td;
|
|
66
|
+
for (let tx = xx; tx < xx + cell.colSpan; ++tx) {
|
|
67
|
+
for (let ty = y; ty < y + cell.rowSpan; ++ty) {
|
|
68
|
+
if (!m[ty]) m[ty] = [];
|
|
69
|
+
m[ty][tx] = true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
cell.classList.toggle("psp-is-top", y === 0 || !marked.has(xx));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
marked = tops;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
|
|
13
|
+
import { CellMetadata } from "regular-table/dist/esm/types.js";
|
|
14
|
+
import type { DatagridModel, ColumnConfig, ColorRecord } from "../../types.js";
|
|
15
|
+
|
|
16
|
+
interface CellMetaWithFlags extends CellMetadata {
|
|
17
|
+
_is_hidden_by_aggregate_depth?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function cell_style_boolean(
|
|
21
|
+
this: DatagridModel,
|
|
22
|
+
_plugin: ColumnConfig | undefined,
|
|
23
|
+
td: HTMLElement,
|
|
24
|
+
metadata: CellMetaWithFlags,
|
|
25
|
+
): void {
|
|
26
|
+
if (metadata._is_hidden_by_aggregate_depth) {
|
|
27
|
+
td.style.backgroundColor = "";
|
|
28
|
+
td.style.color = "";
|
|
29
|
+
} else {
|
|
30
|
+
const [hex]: ColorRecord | [string, number, number, number, string] =
|
|
31
|
+
metadata.user === true
|
|
32
|
+
? this._pos_fg_color
|
|
33
|
+
: metadata.user === false
|
|
34
|
+
? this._neg_fg_color
|
|
35
|
+
: ["", 0, 0, 0, ""];
|
|
36
|
+
td.style.backgroundColor = "";
|
|
37
|
+
td.style.color = hex;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
|
|
13
|
+
import { CellMetadata } from "regular-table/dist/esm/types.js";
|
|
14
|
+
import type { DatagridModel, ColorRecord } from "../../types.js";
|
|
15
|
+
|
|
16
|
+
export function style_cell_flash(
|
|
17
|
+
this: DatagridModel,
|
|
18
|
+
metadata: CellMetadata,
|
|
19
|
+
td: HTMLElement,
|
|
20
|
+
[, , , , , pos_s, pos_e]: ColorRecord,
|
|
21
|
+
[, , , , , neg_s, neg_e]: ColorRecord,
|
|
22
|
+
is_settings_open: boolean,
|
|
23
|
+
): void {
|
|
24
|
+
const id = this._ids?.[metadata.dy ?? 0]?.join("|");
|
|
25
|
+
const metadata_path = (
|
|
26
|
+
is_settings_open
|
|
27
|
+
? (metadata.column_header ?? []).slice(0, -1)
|
|
28
|
+
: (metadata.column_header ?? [])
|
|
29
|
+
).join("|");
|
|
30
|
+
|
|
31
|
+
if (
|
|
32
|
+
this.last_reverse_columns?.has(metadata_path) &&
|
|
33
|
+
this.last_reverse_ids?.has(id)
|
|
34
|
+
) {
|
|
35
|
+
const row_idx = this.last_reverse_ids?.get(id);
|
|
36
|
+
const col_idx = this.last_reverse_columns.get(metadata_path);
|
|
37
|
+
if (!this._is_old_viewport) {
|
|
38
|
+
td.style.animation = "";
|
|
39
|
+
} else if (
|
|
40
|
+
col_idx !== undefined &&
|
|
41
|
+
row_idx !== undefined &&
|
|
42
|
+
(this.last_meta?.[col_idx]?.[row_idx] as number | undefined) !==
|
|
43
|
+
undefined &&
|
|
44
|
+
(this.last_meta![col_idx]![row_idx] as number) >
|
|
45
|
+
((metadata.user ?? 0) as number)
|
|
46
|
+
) {
|
|
47
|
+
td.style.setProperty("--pulse--background-color-start", neg_s);
|
|
48
|
+
td.style.setProperty("--pulse--background-color-end", neg_e);
|
|
49
|
+
if (td.style.animationName === "pulse_neg") {
|
|
50
|
+
td.style.animation = "pulse_neg2 0.5s linear";
|
|
51
|
+
} else {
|
|
52
|
+
td.style.animation = "pulse_neg 0.5s linear";
|
|
53
|
+
}
|
|
54
|
+
} else if (
|
|
55
|
+
col_idx !== undefined &&
|
|
56
|
+
row_idx !== undefined &&
|
|
57
|
+
(this.last_meta?.[col_idx]?.[row_idx] as number | undefined) !==
|
|
58
|
+
undefined &&
|
|
59
|
+
(this.last_meta![col_idx]![row_idx] as number) <
|
|
60
|
+
((metadata.user ?? 0) as number)
|
|
61
|
+
) {
|
|
62
|
+
td.style.setProperty("--pulse--background-color-start", pos_s);
|
|
63
|
+
td.style.setProperty("--pulse--background-color-end", pos_e);
|
|
64
|
+
if (td.style.animationName === "pulse_pos") {
|
|
65
|
+
td.style.animation = "pulse_pos2 0.5s linear";
|
|
66
|
+
} else {
|
|
67
|
+
td.style.animation = "pulse_pos 0.5s linear";
|
|
68
|
+
}
|
|
69
|
+
} else if (row_idx !== metadata.dy) {
|
|
70
|
+
td.style.animation = "";
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
td.style.animation = "";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
|
|
13
|
+
import { CellMetadata } from "regular-table/dist/esm/types.js";
|
|
14
|
+
import {
|
|
15
|
+
rgbaToRgb,
|
|
16
|
+
infer_foreground_from_background,
|
|
17
|
+
} from "../../color_utils.js";
|
|
18
|
+
import type { DatagridModel, ColumnConfig, ColorRecord } from "../../types.js";
|
|
19
|
+
|
|
20
|
+
interface CellMetaWithFlags extends CellMetadata {
|
|
21
|
+
_is_hidden_by_aggregate_depth?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function cell_style_datetime(
|
|
25
|
+
this: DatagridModel,
|
|
26
|
+
plugin: ColumnConfig,
|
|
27
|
+
td: HTMLElement,
|
|
28
|
+
metadata: CellMetaWithFlags,
|
|
29
|
+
): void {
|
|
30
|
+
const colorRecord: ColorRecord = //(() => {
|
|
31
|
+
// if (plugin?.color !== undefined) {
|
|
32
|
+
// return plugin.color;
|
|
33
|
+
// } else {
|
|
34
|
+
// return
|
|
35
|
+
this._color;
|
|
36
|
+
// }
|
|
37
|
+
// })();
|
|
38
|
+
|
|
39
|
+
const [hex, r, g, b] = colorRecord;
|
|
40
|
+
|
|
41
|
+
if (metadata._is_hidden_by_aggregate_depth) {
|
|
42
|
+
td.style.backgroundColor = "";
|
|
43
|
+
td.style.color = "";
|
|
44
|
+
} else if (
|
|
45
|
+
plugin?.datetime_color_mode === "foreground" &&
|
|
46
|
+
metadata.user !== null
|
|
47
|
+
) {
|
|
48
|
+
td.style.color = hex;
|
|
49
|
+
td.style.backgroundColor = "";
|
|
50
|
+
} else if (
|
|
51
|
+
plugin?.datetime_color_mode === "background" &&
|
|
52
|
+
metadata.user !== null
|
|
53
|
+
) {
|
|
54
|
+
const source = this._plugin_background as [number, number, number];
|
|
55
|
+
const foreground = infer_foreground_from_background(
|
|
56
|
+
rgbaToRgb([r, g, b, 1], source),
|
|
57
|
+
);
|
|
58
|
+
td.style.color = foreground;
|
|
59
|
+
td.style.backgroundColor = hex;
|
|
60
|
+
} else {
|
|
61
|
+
td.style.backgroundColor = "";
|
|
62
|
+
td.style.color = "";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
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
|
+
|
|
13
|
+
import { style_cell_flash } from "./cell_flash.js";
|
|
14
|
+
import {
|
|
15
|
+
rgbaToRgb,
|
|
16
|
+
infer_foreground_from_background,
|
|
17
|
+
} from "../../color_utils.js";
|
|
18
|
+
import type { DatagridModel, ColumnConfig, ColorRecord } from "../../types.js";
|
|
19
|
+
|
|
20
|
+
interface CellMetaWithExtras {
|
|
21
|
+
_is_hidden_by_aggregate_depth?: boolean;
|
|
22
|
+
user?: number;
|
|
23
|
+
dy: number;
|
|
24
|
+
column_header?: string[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface PluginWithColors
|
|
28
|
+
extends Omit<
|
|
29
|
+
ColumnConfig,
|
|
30
|
+
"pos_fg_color" | "neg_fg_color" | "pos_bg_color" | "neg_bg_color"
|
|
31
|
+
> {
|
|
32
|
+
pos_bg_color?: ColorRecord;
|
|
33
|
+
neg_bg_color?: ColorRecord;
|
|
34
|
+
pos_fg_color?: ColorRecord;
|
|
35
|
+
neg_fg_color?: ColorRecord;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function cell_style_numeric(
|
|
39
|
+
this: DatagridModel,
|
|
40
|
+
plugin: PluginWithColors | undefined,
|
|
41
|
+
td: HTMLElement,
|
|
42
|
+
metadata: CellMetaWithExtras,
|
|
43
|
+
is_settings_open: boolean,
|
|
44
|
+
): void {
|
|
45
|
+
const is_positive = (metadata.user ?? 0) > 0;
|
|
46
|
+
const is_negative = (metadata.user ?? 0) < 0;
|
|
47
|
+
|
|
48
|
+
let pos_bg_color: ColorRecord;
|
|
49
|
+
if (plugin?.pos_bg_color !== undefined) {
|
|
50
|
+
pos_bg_color = plugin.pos_bg_color;
|
|
51
|
+
} else {
|
|
52
|
+
pos_bg_color = this._pos_bg_color;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let neg_bg_color: ColorRecord;
|
|
56
|
+
if (plugin?.neg_bg_color !== undefined) {
|
|
57
|
+
neg_bg_color = plugin.neg_bg_color;
|
|
58
|
+
} else {
|
|
59
|
+
neg_bg_color = this._neg_bg_color;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const bg_tuple: ColorRecord = is_positive
|
|
63
|
+
? pos_bg_color
|
|
64
|
+
: is_negative
|
|
65
|
+
? neg_bg_color
|
|
66
|
+
: [
|
|
67
|
+
"",
|
|
68
|
+
this._plugin_background[0],
|
|
69
|
+
this._plugin_background[1],
|
|
70
|
+
this._plugin_background[2],
|
|
71
|
+
"",
|
|
72
|
+
"",
|
|
73
|
+
"",
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
{
|
|
77
|
+
const [hex, r, g, b] = bg_tuple;
|
|
78
|
+
|
|
79
|
+
td.style.position = "";
|
|
80
|
+
if (metadata._is_hidden_by_aggregate_depth) {
|
|
81
|
+
td.style.animation = "";
|
|
82
|
+
td.style.backgroundColor = "";
|
|
83
|
+
} else if (plugin?.number_bg_mode === "color") {
|
|
84
|
+
td.style.animation = "";
|
|
85
|
+
td.style.backgroundColor = hex;
|
|
86
|
+
} else if (plugin?.number_bg_mode === "gradient") {
|
|
87
|
+
const a = Math.max(
|
|
88
|
+
0,
|
|
89
|
+
Math.min(
|
|
90
|
+
1,
|
|
91
|
+
Math.abs((metadata.user ?? 0) / (plugin.bg_gradient ?? 1)),
|
|
92
|
+
),
|
|
93
|
+
);
|
|
94
|
+
const source = this._plugin_background as [number, number, number];
|
|
95
|
+
const foreground = infer_foreground_from_background(
|
|
96
|
+
rgbaToRgb([r, g, b, a], source),
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
td.style.animation = "";
|
|
100
|
+
td.style.color = foreground;
|
|
101
|
+
td.style.backgroundColor = `rgba(${r},${g},${b},${a})`;
|
|
102
|
+
} else if (plugin?.number_bg_mode === "pulse") {
|
|
103
|
+
style_cell_flash.call(
|
|
104
|
+
this,
|
|
105
|
+
metadata as any,
|
|
106
|
+
td,
|
|
107
|
+
pos_bg_color,
|
|
108
|
+
neg_bg_color,
|
|
109
|
+
is_settings_open,
|
|
110
|
+
);
|
|
111
|
+
td.style.backgroundColor = "";
|
|
112
|
+
} else if (
|
|
113
|
+
plugin?.number_bg_mode === "disabled" ||
|
|
114
|
+
!plugin?.number_bg_mode
|
|
115
|
+
) {
|
|
116
|
+
td.style.animation = "";
|
|
117
|
+
td.style.backgroundColor = "";
|
|
118
|
+
} else {
|
|
119
|
+
td.style.animation = "";
|
|
120
|
+
td.style.backgroundColor = "";
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const fg_tuple: ColorRecord = (() => {
|
|
125
|
+
if (plugin?.pos_fg_color !== undefined) {
|
|
126
|
+
return is_positive
|
|
127
|
+
? plugin.pos_fg_color
|
|
128
|
+
: is_negative
|
|
129
|
+
? plugin.neg_fg_color!
|
|
130
|
+
: [
|
|
131
|
+
"",
|
|
132
|
+
this._plugin_background[0],
|
|
133
|
+
this._plugin_background[1],
|
|
134
|
+
this._plugin_background[2],
|
|
135
|
+
"",
|
|
136
|
+
"",
|
|
137
|
+
"",
|
|
138
|
+
];
|
|
139
|
+
} else {
|
|
140
|
+
return is_positive
|
|
141
|
+
? this._pos_fg_color
|
|
142
|
+
: is_negative
|
|
143
|
+
? this._neg_fg_color
|
|
144
|
+
: [
|
|
145
|
+
"",
|
|
146
|
+
this._plugin_background[0],
|
|
147
|
+
this._plugin_background[1],
|
|
148
|
+
this._plugin_background[2],
|
|
149
|
+
"",
|
|
150
|
+
"",
|
|
151
|
+
"",
|
|
152
|
+
];
|
|
153
|
+
}
|
|
154
|
+
})();
|
|
155
|
+
|
|
156
|
+
const [hex, , , , gradhex] = fg_tuple;
|
|
157
|
+
|
|
158
|
+
if (metadata._is_hidden_by_aggregate_depth) {
|
|
159
|
+
td.style.backgroundColor = "";
|
|
160
|
+
td.style.color = "";
|
|
161
|
+
} else if (plugin?.number_fg_mode === "disabled") {
|
|
162
|
+
if (plugin?.number_bg_mode === "color") {
|
|
163
|
+
const source = this._plugin_background as [number, number, number];
|
|
164
|
+
const foreground = infer_foreground_from_background(
|
|
165
|
+
rgbaToRgb([bg_tuple[1], bg_tuple[2], bg_tuple[3], 1], source),
|
|
166
|
+
);
|
|
167
|
+
td.style.color = foreground;
|
|
168
|
+
} else if (plugin?.number_bg_mode === "gradient") {
|
|
169
|
+
// Color already set above
|
|
170
|
+
} else {
|
|
171
|
+
td.style.color = "";
|
|
172
|
+
}
|
|
173
|
+
} else if (plugin?.number_fg_mode === "bar") {
|
|
174
|
+
td.style.color = "";
|
|
175
|
+
td.style.position = "relative";
|
|
176
|
+
if (
|
|
177
|
+
gradhex !== "" &&
|
|
178
|
+
td.children.length > 0 &&
|
|
179
|
+
td.children[0].nodeType === Node.ELEMENT_NODE
|
|
180
|
+
) {
|
|
181
|
+
(td.children[0] as HTMLElement).style.background = gradhex;
|
|
182
|
+
}
|
|
183
|
+
} else if (plugin?.number_fg_mode === "color" || !plugin?.number_fg_mode) {
|
|
184
|
+
td.style.color = hex;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
|
|
13
|
+
import { CellMetadata } from "regular-table/dist/esm/types.js";
|
|
14
|
+
import type { DatagridModel } from "../../types.js";
|
|
15
|
+
import { RegularTableElement } from "regular-table";
|
|
16
|
+
|
|
17
|
+
interface NextMeta {
|
|
18
|
+
row_header?: unknown[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function cell_style_row_header(
|
|
22
|
+
this: DatagridModel,
|
|
23
|
+
regularTable: RegularTableElement,
|
|
24
|
+
td: HTMLElement,
|
|
25
|
+
metadata: CellMetadata,
|
|
26
|
+
): void {
|
|
27
|
+
const is_not_empty =
|
|
28
|
+
metadata.value !== undefined &&
|
|
29
|
+
metadata.value !== null &&
|
|
30
|
+
metadata.value?.toString()?.trim().length > 0;
|
|
31
|
+
const is_leaf =
|
|
32
|
+
(metadata.row_header_x ?? 0) >= this._config.group_by.length;
|
|
33
|
+
const next = regularTable.getMeta({
|
|
34
|
+
dx: 0,
|
|
35
|
+
dy: (metadata.y ?? 0) - (metadata.y0 ?? 0) + 1,
|
|
36
|
+
} as unknown as Element) as NextMeta | undefined;
|
|
37
|
+
const is_collapse =
|
|
38
|
+
next &&
|
|
39
|
+
next.row_header &&
|
|
40
|
+
typeof next.row_header[(metadata.row_header_x ?? 0) + 1] !==
|
|
41
|
+
"undefined";
|
|
42
|
+
td.classList.toggle("psp-tree-label", is_not_empty && !is_leaf);
|
|
43
|
+
td.classList.toggle(
|
|
44
|
+
"psp-tree-label-expand",
|
|
45
|
+
is_not_empty && !is_leaf && !is_collapse,
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
td.classList.toggle(
|
|
49
|
+
"psp-tree-label-collapse",
|
|
50
|
+
is_not_empty && !is_leaf && is_collapse,
|
|
51
|
+
);
|
|
52
|
+
td.classList.toggle("psp-tree-leaf", is_not_empty && is_leaf);
|
|
53
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
|
|
13
|
+
import chroma from "chroma-js";
|
|
14
|
+
import {
|
|
15
|
+
rgbaToRgb,
|
|
16
|
+
infer_foreground_from_background,
|
|
17
|
+
} from "../../color_utils.js";
|
|
18
|
+
import type { DatagridModel, ColumnConfig, ColorRecord } from "../../types.js";
|
|
19
|
+
|
|
20
|
+
interface CellMetaWithExtras {
|
|
21
|
+
_is_hidden_by_aggregate_depth?: boolean;
|
|
22
|
+
user?: string | null;
|
|
23
|
+
column_header?: string[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface PluginWithColor extends Omit<ColumnConfig, "color"> {
|
|
27
|
+
color?: ColorRecord;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function cell_style_string(
|
|
31
|
+
this: DatagridModel,
|
|
32
|
+
plugin: PluginWithColor | undefined,
|
|
33
|
+
td: HTMLElement,
|
|
34
|
+
metadata: CellMetaWithExtras,
|
|
35
|
+
): void {
|
|
36
|
+
const column_name = metadata.column_header?.[this._config.split_by.length];
|
|
37
|
+
const colorRecord: ColorRecord = (() => {
|
|
38
|
+
if (plugin?.color !== undefined) {
|
|
39
|
+
return plugin.color;
|
|
40
|
+
} else {
|
|
41
|
+
return this._color;
|
|
42
|
+
}
|
|
43
|
+
})();
|
|
44
|
+
|
|
45
|
+
const [hex, r, g, b] = colorRecord;
|
|
46
|
+
|
|
47
|
+
if (metadata._is_hidden_by_aggregate_depth) {
|
|
48
|
+
td.style.backgroundColor = "";
|
|
49
|
+
td.style.color = "";
|
|
50
|
+
} else if (
|
|
51
|
+
plugin?.string_color_mode === "foreground" &&
|
|
52
|
+
metadata.user !== null
|
|
53
|
+
) {
|
|
54
|
+
td.style.color = hex;
|
|
55
|
+
td.style.backgroundColor = "";
|
|
56
|
+
if (plugin?.format === "link" && td.children[0]) {
|
|
57
|
+
(td.children[0] as HTMLElement).style.color = hex;
|
|
58
|
+
}
|
|
59
|
+
} else if (
|
|
60
|
+
plugin?.string_color_mode === "background" &&
|
|
61
|
+
metadata.user !== null
|
|
62
|
+
) {
|
|
63
|
+
const source = this._plugin_background as [number, number, number];
|
|
64
|
+
const foreground = infer_foreground_from_background(
|
|
65
|
+
rgbaToRgb([r, g, b, 1], source),
|
|
66
|
+
);
|
|
67
|
+
td.style.color = foreground;
|
|
68
|
+
td.style.backgroundColor = hex;
|
|
69
|
+
} else if (
|
|
70
|
+
plugin?.string_color_mode === "series" &&
|
|
71
|
+
metadata.user !== null &&
|
|
72
|
+
column_name
|
|
73
|
+
) {
|
|
74
|
+
if (!this._series_color_map.has(column_name)) {
|
|
75
|
+
this._series_color_map.set(column_name, new Map());
|
|
76
|
+
this._series_color_seed.set(column_name, 0);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const series_map = this._series_color_map.get(column_name)!;
|
|
80
|
+
if (metadata.user && !series_map.has(metadata.user)) {
|
|
81
|
+
const seed = this._series_color_seed.get(column_name) ?? 0;
|
|
82
|
+
series_map.set(metadata.user, seed);
|
|
83
|
+
this._series_color_seed.set(column_name, seed + 1);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const color_seed = series_map.get(metadata.user!) ?? 0;
|
|
87
|
+
let [h, s, l] = chroma(hex).hsl();
|
|
88
|
+
h = h + ((color_seed * 150) % 360);
|
|
89
|
+
const color2 = chroma(h, s, l, "hsl");
|
|
90
|
+
const [r2, g2, b2] = color2.rgb();
|
|
91
|
+
const hex2 = color2.hex();
|
|
92
|
+
const source = this._plugin_background as [number, number, number];
|
|
93
|
+
const foreground = infer_foreground_from_background(
|
|
94
|
+
rgbaToRgb([r2, g2, b2, 1], source),
|
|
95
|
+
);
|
|
96
|
+
td.style.color = foreground;
|
|
97
|
+
td.style.backgroundColor = hex2;
|
|
98
|
+
} else {
|
|
99
|
+
td.style.backgroundColor = "";
|
|
100
|
+
td.style.color = "";
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
|
|
13
|
+
import { RegularTableElement } from "regular-table";
|
|
14
|
+
import { CellMetadata } from "regular-table/dist/esm/types.js";
|
|
15
|
+
import type { SelectedPosition } from "../types.js";
|
|
16
|
+
|
|
17
|
+
export interface CellMetaExtended extends CellMetadata {
|
|
18
|
+
_is_hidden_by_aggregate_depth?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface CollectedCell {
|
|
22
|
+
element: HTMLElement;
|
|
23
|
+
metadata: CellMetaExtended;
|
|
24
|
+
isHeader: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface CollectedHeaderRow {
|
|
28
|
+
row: HTMLTableRowElement;
|
|
29
|
+
cells: Array<{
|
|
30
|
+
element: HTMLTableCellElement;
|
|
31
|
+
metadata: CellMetadata | undefined;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Local types for selection maps - match the actual runtime usage
|
|
36
|
+
// (activate.ts uses `as any` casts when passing these)
|
|
37
|
+
export type LocalSelectedRowsMap = WeakMap<RegularTableElement, unknown[]>;
|
|
38
|
+
export type LocalSelectedPositionMap = WeakMap<
|
|
39
|
+
RegularTableElement,
|
|
40
|
+
SelectedPosition
|
|
41
|
+
>;
|