@perspective-dev/viewer-datagrid 4.1.1 → 4.2.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.
Files changed (39) hide show
  1. package/dist/cdn/perspective-viewer-datagrid.js +4 -4
  2. package/dist/cdn/perspective-viewer-datagrid.js.map +4 -4
  3. package/dist/esm/event_handlers/click/edit_click.d.ts +1 -1
  4. package/dist/esm/model/create.d.ts +1 -1
  5. package/dist/esm/perspective-viewer-datagrid.js +3 -3
  6. package/dist/esm/perspective-viewer-datagrid.js.map +3 -3
  7. package/dist/esm/style_handlers/body.d.ts +1 -1
  8. package/dist/esm/style_handlers/column_header.d.ts +1 -1
  9. package/dist/esm/style_handlers/consolidated.d.ts +2 -5
  10. package/dist/esm/style_handlers/table_cell/boolean.d.ts +1 -5
  11. package/dist/esm/style_handlers/table_cell/cell_flash.d.ts +2 -2
  12. package/dist/esm/style_handlers/table_cell/datetime.d.ts +1 -5
  13. package/dist/esm/style_handlers/table_cell/row_header.d.ts +2 -2
  14. package/dist/esm/style_handlers/types.d.ts +2 -5
  15. package/dist/esm/types.d.ts +1 -1
  16. package/package.json +3 -3
  17. package/src/ts/color_utils.ts +0 -1
  18. package/src/ts/event_handlers/click/edit_click.ts +13 -10
  19. package/src/ts/event_handlers/dispatch_click.ts +2 -4
  20. package/src/ts/event_handlers/expand_collapse.ts +4 -3
  21. package/src/ts/event_handlers/focus.ts +1 -1
  22. package/src/ts/event_handlers/header_click.ts +1 -1
  23. package/src/ts/event_handlers/keydown/edit_keydown.ts +2 -2
  24. package/src/ts/event_handlers/row_select_click.ts +6 -4
  25. package/src/ts/event_handlers/select_region.ts +23 -11
  26. package/src/ts/event_handlers/sort.ts +1 -1
  27. package/src/ts/get_cell_config.ts +1 -0
  28. package/src/ts/model/create.ts +11 -18
  29. package/src/ts/style_handlers/body.ts +16 -21
  30. package/src/ts/style_handlers/column_header.ts +15 -4
  31. package/src/ts/style_handlers/consolidated.ts +8 -13
  32. package/src/ts/style_handlers/focus.ts +4 -10
  33. package/src/ts/style_handlers/group_header.ts +6 -3
  34. package/src/ts/style_handlers/table_cell/boolean.ts +2 -5
  35. package/src/ts/style_handlers/table_cell/cell_flash.ts +2 -2
  36. package/src/ts/style_handlers/table_cell/datetime.ts +2 -5
  37. package/src/ts/style_handlers/table_cell/row_header.ts +8 -7
  38. package/src/ts/style_handlers/types.ts +6 -6
  39. package/src/ts/types.ts +15 -1
@@ -1,5 +1,5 @@
1
1
  import { RegularTableElement } from "regular-table";
2
- import type { DatagridModel, PerspectiveViewerElement, ColumnsConfig } from "../types.js";
2
+ import { type DatagridModel, type PerspectiveViewerElement, type ColumnsConfig } from "../types.js";
3
3
  import { CollectedCell, LocalSelectedPositionMap, LocalSelectedRowsMap } from "./types.js";
4
4
  /**
5
5
  * Apply styles to all body cells in a single pass.
@@ -1,5 +1,5 @@
1
1
  import { RegularTableElement } from "regular-table";
2
- import type { DatagridModel, PerspectiveViewerElement } from "../types.js";
2
+ import { type DatagridModel, type PerspectiveViewerElement } from "../types.js";
3
3
  import { CollectedHeaderRow } from "./types.js";
4
4
  /**
5
5
  * Apply selected column styling in response to column settings toggle events.
@@ -1,12 +1,9 @@
1
1
  import { RegularTableElement } from "regular-table";
2
- import { CellMetadata } from "regular-table/dist/esm/types.js";
3
2
  import type { DatagridModel, PerspectiveViewerElement, ColumnsConfig, DatagridPluginElement, SelectedPosition } from "../types.js";
4
- interface CellMetaExtended extends CellMetadata {
5
- _is_hidden_by_aggregate_depth?: boolean;
6
- }
3
+ import { CellMetadata } from "regular-table/dist/esm/types.js";
7
4
  interface CollectedCell {
8
5
  element: HTMLElement;
9
- metadata: CellMetaExtended;
6
+ metadata: CellMetadata;
10
7
  isHeader: boolean;
11
8
  }
12
9
  interface CollectedHeaderRow {
@@ -1,7 +1,3 @@
1
1
  import { CellMetadata } from "regular-table/dist/esm/types.js";
2
2
  import type { DatagridModel, ColumnConfig } from "../../types.js";
3
- interface CellMetaWithFlags extends CellMetadata {
4
- _is_hidden_by_aggregate_depth?: boolean;
5
- }
6
- export declare function cell_style_boolean(this: DatagridModel, _plugin: ColumnConfig | undefined, td: HTMLElement, metadata: CellMetaWithFlags): void;
7
- export {};
3
+ export declare function cell_style_boolean(this: DatagridModel, _plugin: ColumnConfig | undefined, td: HTMLElement, metadata: CellMetadata): void;
@@ -1,3 +1,3 @@
1
- import { CellMetadata } from "regular-table/dist/esm/types.js";
1
+ import { CellMetadataBody } from "regular-table/dist/esm/types.js";
2
2
  import type { DatagridModel, ColorRecord } from "../../types.js";
3
- export declare function style_cell_flash(this: DatagridModel, metadata: CellMetadata, td: HTMLElement, [, , , , , pos_s, pos_e]: ColorRecord, [, , , , , neg_s, neg_e]: ColorRecord, is_settings_open: boolean): void;
3
+ export declare function style_cell_flash(this: DatagridModel, metadata: CellMetadataBody, td: HTMLElement, [, , , , , pos_s, pos_e]: ColorRecord, [, , , , , neg_s, neg_e]: ColorRecord, is_settings_open: boolean): void;
@@ -1,7 +1,3 @@
1
1
  import { CellMetadata } from "regular-table/dist/esm/types.js";
2
2
  import type { DatagridModel, ColumnConfig } from "../../types.js";
3
- interface CellMetaWithFlags extends CellMetadata {
4
- _is_hidden_by_aggregate_depth?: boolean;
5
- }
6
- export declare function cell_style_datetime(this: DatagridModel, plugin: ColumnConfig, td: HTMLElement, metadata: CellMetaWithFlags): void;
7
- export {};
3
+ export declare function cell_style_datetime(this: DatagridModel, plugin: ColumnConfig, td: HTMLElement, metadata: CellMetadata): void;
@@ -1,4 +1,4 @@
1
- import { CellMetadata } from "regular-table/dist/esm/types.js";
1
+ import { CellMetadataRowHeader } from "regular-table/dist/esm/types.js";
2
2
  import type { DatagridModel } from "../../types.js";
3
3
  import { RegularTableElement } from "regular-table";
4
- export declare function cell_style_row_header(this: DatagridModel, regularTable: RegularTableElement, td: HTMLElement, metadata: CellMetadata): void;
4
+ export declare function cell_style_row_header(this: DatagridModel, regularTable: RegularTableElement, td: HTMLElement, metadata: CellMetadataRowHeader): void;
@@ -1,12 +1,9 @@
1
1
  import { RegularTableElement } from "regular-table";
2
- import { CellMetadata } from "regular-table/dist/esm/types.js";
2
+ import { CellMetadata, CellMetadataBody, CellMetadataRowHeader } from "regular-table/dist/esm/types.js";
3
3
  import type { SelectedPosition } from "../types.js";
4
- export interface CellMetaExtended extends CellMetadata {
5
- _is_hidden_by_aggregate_depth?: boolean;
6
- }
7
4
  export interface CollectedCell {
8
5
  element: HTMLElement;
9
- metadata: CellMetaExtended;
6
+ metadata: CellMetadataRowHeader | CellMetadataBody;
10
7
  isHeader: boolean;
11
8
  }
12
9
  export interface CollectedHeaderRow {
@@ -2,7 +2,7 @@ import type { View, Table, ViewConfig, ColumnType, SortDir, ViewWindow } from "@
2
2
  import { RegularTableElement } from "regular-table";
3
3
  import { CellMetadata, DataResponse } from "regular-table/dist/esm/types";
4
4
  export type { RegularTableElement as RegularTable };
5
- export type { CellMetadata as CellMeta };
5
+ export declare function get_psp_type(model: DatagridModel, metadata: CellMetadata): ColumnType;
6
6
  export type EditMode = "READ_ONLY" | "EDIT" | "SELECT_COLUMN" | "SELECT_ROW" | "SELECT_REGION";
7
7
  export type ColorRecord = [
8
8
  string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perspective-dev/viewer-datagrid",
3
- "version": "4.1.1",
3
+ "version": "4.2.0",
4
4
  "description": "Perspective datagrid plugin based on `regular-table`",
5
5
  "unpkg": "dist/cdn/perspective-viewer-datagrid.js",
6
6
  "jsdelivr": "dist/cdn/perspective-viewer-datagrid.js",
@@ -32,10 +32,10 @@
32
32
  "@perspective-dev/client": "",
33
33
  "@perspective-dev/viewer": "",
34
34
  "chroma-js": ">=3 <4",
35
- "regular-table": "=0.8.0"
35
+ "regular-table": "=0.8.1"
36
36
  },
37
37
  "devDependencies": {
38
- "@prospective.co/procss": "0.1.17",
38
+ "@prospective.co/procss": "0.1.18",
39
39
  "@perspective-dev/esbuild-plugin": "",
40
40
  "@perspective-dev/test": "",
41
41
  "@types/chroma-js": "^3.1.2",
@@ -57,7 +57,6 @@ export function make_color_record(color: string): ColorRecord {
57
57
  const chroma_neg = chroma(color);
58
58
  const _neg_grad = make_gradient(chroma_neg);
59
59
  const rgb = chroma_neg.rgb();
60
-
61
60
  return [
62
61
  color,
63
62
  rgb[0],
@@ -10,10 +10,12 @@
10
10
  // ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11
11
  // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
12
 
13
- import type {
14
- RegularTable,
15
- DatagridModel,
16
- PerspectiveViewerElement,
13
+ import { CellMetadataBody } from "regular-table/dist/esm/types.js";
14
+ import {
15
+ type RegularTable,
16
+ type DatagridModel,
17
+ type PerspectiveViewerElement,
18
+ get_psp_type,
17
19
  } from "../../types.js";
18
20
 
19
21
  export function write_cell(
@@ -21,13 +23,13 @@ export function write_cell(
21
23
  model: DatagridModel,
22
24
  active_cell: HTMLElement,
23
25
  ): boolean {
24
- const meta = table.getMeta(active_cell);
26
+ const meta = table.getMeta(active_cell) as CellMetadataBody;
25
27
  if (!meta) {
26
28
  return false;
27
29
  }
28
- const type = model._schema[model._column_paths[meta.x]];
30
+ const type = model._schema[model._column_paths[meta.x!]];
29
31
  let text: string | number | boolean | null = active_cell.textContent || "";
30
- const id = model._ids[meta.y - meta.y0][0];
32
+ const id = model._ids[meta.y! - meta.y0][0];
31
33
  if (type === "float" || type === "integer") {
32
34
  const parsed = parseFloat(text.replace(/,/g, ""));
33
35
  if (isNaN(parsed)) {
@@ -59,13 +61,14 @@ export function clickListener(
59
61
  _viewer: PerspectiveViewerElement,
60
62
  event: MouseEvent,
61
63
  ): void {
62
- const meta = table.getMeta(event.target as Element);
63
- if (typeof meta?.x !== "undefined") {
64
+ const meta = table.getMeta(event.target as HTMLElement);
65
+ if (meta?.type === "body" || meta?.type === "column_header") {
64
66
  const is_editable2 = this._is_editable[meta.x];
65
- const is_bool = this.get_psp_type(meta) === "boolean";
67
+ const is_bool = get_psp_type(this, meta) === "boolean";
66
68
  const is_null = (event.target as Element).classList.contains(
67
69
  "psp-null",
68
70
  );
71
+
69
72
  if (is_editable2 && is_bool && !is_null) {
70
73
  write_cell(table, this, event.target as HTMLElement);
71
74
  }
@@ -24,12 +24,10 @@ export async function dispatch_click_listener(
24
24
  viewer: PerspectiveViewerElement,
25
25
  event: MouseEvent,
26
26
  ): Promise<void> {
27
- const meta = table.getMeta(event.target as Element);
28
- if (!meta) return;
27
+ const meta = table.getMeta(event.target as HTMLElement);
28
+ if (!meta || meta.type !== "body") return;
29
29
  const { x, y } = meta;
30
-
31
30
  const { row, column_names, config } = await getCellConfig(this, y, x);
32
-
33
31
  viewer.dispatchEvent(
34
32
  new CustomEvent<PerspectiveClickDetail>("perspective-click", {
35
33
  bubbles: true,
@@ -17,12 +17,12 @@ export async function expandCollapseHandler(
17
17
  regularTable: RegularTable,
18
18
  event: MouseEvent,
19
19
  ): Promise<void> {
20
- const meta = regularTable.getMeta(event.target as Element);
21
- if (!meta?.row_header) return;
22
-
20
+ const meta = regularTable.getMeta(event.target as HTMLElement);
21
+ if (!meta || meta.type !== "row_header") return;
23
22
  const is_collapse = (event.target as Element).classList.contains(
24
23
  "psp-tree-label-collapse",
25
24
  );
25
+
26
26
  if (event.shiftKey && is_collapse) {
27
27
  this._view.set_depth(
28
28
  (meta.row_header as unknown[]).filter((x) => x !== undefined)
@@ -38,6 +38,7 @@ export async function expandCollapseHandler(
38
38
  } else {
39
39
  this._view.expand(meta.y);
40
40
  }
41
+
41
42
  this._num_rows = await this._view.num_rows();
42
43
  this._num_columns = await this._view.num_columns();
43
44
  regularTable.draw();
@@ -52,7 +52,7 @@ export function focusinListener(
52
52
  ): void {
53
53
  const target = event.target as HTMLElement;
54
54
  const meta = table.getMeta(target);
55
- if (meta) {
55
+ if (meta?.type === "body") {
56
56
  const new_state: SelectedPosition = {
57
57
  x: meta.x,
58
58
  y: meta.y,
@@ -50,7 +50,7 @@ export async function mousedown_listener(
50
50
  if (target.classList.contains("psp-menu-enabled")) {
51
51
  const meta = regularTable.getMeta(target);
52
52
  const column_name = meta?.column_header?.[this._config.split_by.length];
53
- await viewer.toggleColumnSettings(column_name);
53
+ await viewer.toggleColumnSettings(`${column_name}`);
54
54
  } else if (target.classList.contains("psp-sort-enabled")) {
55
55
  sortHandler.call(this, regularTable, viewer, event, target);
56
56
  }
@@ -76,7 +76,7 @@ const moveSelection = lock(async function (
76
76
  dy: number,
77
77
  ): Promise<void> {
78
78
  const meta = table.getMeta(active_cell);
79
- if (!meta) return;
79
+ if (!meta || meta.type !== "body") return;
80
80
  const num_columns = this._column_paths.length;
81
81
  const num_rows = this._num_rows;
82
82
  const selected_position = selected_position_map.get(table);
@@ -118,7 +118,7 @@ function isLastCell(
118
118
  target: HTMLElement,
119
119
  ): boolean {
120
120
  const meta = table.getMeta(target);
121
- return meta !== undefined && meta.y === model._num_rows - 1;
121
+ return meta?.type === "body" && meta.y === model._num_rows - 1;
122
122
  }
123
123
 
124
124
  export function keydownListener(
@@ -28,21 +28,22 @@ export async function selectionListener(
28
28
  selected_rows_map: SelectedRowsMap,
29
29
  event: HandledMouseEvent,
30
30
  ): Promise<void> {
31
- const meta = regularTable.getMeta(event.target as Element);
31
+ const meta = regularTable.getMeta(event.target as HTMLElement);
32
32
  if (!viewer.hasAttribute("selectable")) return;
33
33
  if (event.handled) return;
34
34
  if (event.shiftKey) return;
35
35
  if (event.button !== 0) {
36
36
  return;
37
37
  }
38
+
38
39
  event.stopImmediatePropagation();
39
40
 
40
41
  if (!meta) {
41
42
  return;
42
43
  }
43
44
 
44
- const id = this._ids?.[meta.y - meta.y0];
45
- if (meta && meta.y >= 0) {
45
+ if ((meta.type === "body" || meta.type === "row_header") && meta.y >= 0) {
46
+ const id = this._ids?.[meta.y - meta.y0];
46
47
  const selected = selected_rows_map.get(regularTable);
47
48
  const key_match =
48
49
  !!selected &&
@@ -56,10 +57,11 @@ export async function selectionListener(
56
57
  row: {},
57
58
  config: { filter: [] },
58
59
  };
60
+
59
61
  const { row, column_names, config } = await getCellConfig(
60
62
  this,
61
63
  meta.y,
62
- meta.x,
64
+ meta.type === "body" ? meta.x : 0,
63
65
  );
64
66
 
65
67
  if (is_deselect) {
@@ -75,8 +75,12 @@ const getMousedownListener =
75
75
  datagrid.model!._edit_mode === "SELECT_COLUMN")
76
76
  ) {
77
77
  datagrid.model!._selection_state.CURRENT_MOUSEDOWN_COORDINATES = {};
78
- const meta = table.getMeta(mouseEvent.target as Element);
79
- if (meta && meta.x !== undefined && meta.y !== undefined) {
78
+ const meta = table.getMeta(mouseEvent.target as HTMLElement);
79
+ if (
80
+ meta?.type === "body" &&
81
+ meta.x !== undefined &&
82
+ meta.y !== undefined
83
+ ) {
80
84
  datagrid.model!._selection_state.CURRENT_MOUSEDOWN_COORDINATES =
81
85
  {
82
86
  x: meta.x,
@@ -129,8 +133,12 @@ const getMouseoverListener =
129
133
  datagrid.model!._selection_state.CURRENT_MOUSEDOWN_COORDINATES
130
134
  .x !== undefined
131
135
  ) {
132
- const meta = table.getMeta(mouseEvent.target as Element);
133
- if (meta && meta.x !== undefined && meta.y !== undefined) {
136
+ const meta = table.getMeta(mouseEvent.target as HTMLElement);
137
+ if (
138
+ meta?.type === "body" &&
139
+ meta.x !== undefined &&
140
+ meta.y !== undefined
141
+ ) {
134
142
  const potentialSelection: SelectionArea = {
135
143
  x0: Math.min(
136
144
  meta.x,
@@ -183,7 +191,7 @@ const getMouseupListener =
183
191
  datagrid.model!._edit_mode === "SELECT_ROW" ||
184
192
  datagrid.model!._edit_mode === "SELECT_COLUMN"
185
193
  ) {
186
- const meta = table.getMeta(mouseEvent.target as Element);
194
+ const meta = table.getMeta(mouseEvent.target as HTMLElement);
187
195
  if (!meta) return;
188
196
 
189
197
  if (
@@ -195,6 +203,7 @@ const getMouseupListener =
195
203
  if (
196
204
  selected.x0 === selected.x1 &&
197
205
  selected.y0 === selected.y1 &&
206
+ meta?.type === "body" &&
198
207
  selected.x0 === meta.x &&
199
208
  selected.y0 === meta.y
200
209
  ) {
@@ -216,6 +225,7 @@ const getMouseupListener =
216
225
  .CURRENT_MOUSEDOWN_COORDINATES &&
217
226
  datagrid.model!._selection_state.CURRENT_MOUSEDOWN_COORDINATES
218
227
  .x !== undefined &&
228
+ meta?.type === "body" &&
219
229
  meta.x !== undefined &&
220
230
  meta.y !== undefined
221
231
  ) {
@@ -338,8 +348,8 @@ const applyMouseAreaSelection = (
338
348
  const tds = table.querySelectorAll("tbody td");
339
349
 
340
350
  for (const td of tds) {
341
- const meta = table.getMeta(td);
342
- if (!meta) continue;
351
+ const meta = table.getMeta(td as HTMLElement);
352
+ if (!meta || meta.type !== "body") continue;
343
353
  let rendered = false;
344
354
  for (const { x0, x1, y0, y1 } of selected) {
345
355
  if (
@@ -372,7 +382,7 @@ const applyMouseAreaSelection = (
372
382
  const tds = table.querySelectorAll("tbody td");
373
383
 
374
384
  for (const td of tds) {
375
- const meta = table.getMeta(td);
385
+ const meta = table.getMeta(td as HTMLElement);
376
386
  if (!meta) continue;
377
387
  let rendered = false;
378
388
  for (const { x0, x1, y0, y1 } of selected) {
@@ -380,7 +390,8 @@ const applyMouseAreaSelection = (
380
390
  x0 !== undefined &&
381
391
  y0 !== undefined &&
382
392
  x1 !== undefined &&
383
- y1 !== undefined
393
+ y1 !== undefined &&
394
+ meta?.type === "body"
384
395
  ) {
385
396
  if (y0 <= meta.y && meta.y <= y1) {
386
397
  datagrid.model!._selection_state.dirty = true;
@@ -401,7 +412,7 @@ const applyMouseAreaSelection = (
401
412
  const tds = table.querySelectorAll("tbody td");
402
413
 
403
414
  for (const td of tds) {
404
- const meta = table.getMeta(td);
415
+ const meta = table.getMeta(td as HTMLElement);
405
416
  if (!meta) continue;
406
417
  let rendered = false;
407
418
  for (const { x0, x1, y0, y1 } of selected) {
@@ -409,7 +420,8 @@ const applyMouseAreaSelection = (
409
420
  x0 !== undefined &&
410
421
  y0 !== undefined &&
411
422
  x1 !== undefined &&
412
- y1 !== undefined
423
+ y1 !== undefined &&
424
+ meta?.type === "body"
413
425
  ) {
414
426
  if (x0 <= meta.x && meta.x <= x1) {
415
427
  datagrid.model!._selection_state.dirty = true;
@@ -55,7 +55,7 @@ export async function sortHandler(
55
55
  : override_sort;
56
56
 
57
57
  const abs = event.shiftKey;
58
- const sort = sort_method.call(this, column_name, abs);
58
+ const sort = sort_method.call(this, `${column_name}`, abs);
59
59
  await viewer.restore({ sort });
60
60
  }
61
61
 
@@ -49,6 +49,7 @@ export default async function getCellConfig(
49
49
  column_names: [],
50
50
  config: { filter: [] },
51
51
  };
52
+
52
53
  let column_filters: Filter[] = [];
53
54
  if (column_paths) {
54
55
  const split_by_values = column_paths.split("|");
@@ -19,16 +19,17 @@ import type {
19
19
  View,
20
20
  ViewConfig,
21
21
  } from "@perspective-dev/client";
22
- import type {
23
- DatagridModel,
24
- DatagridPluginElement,
25
- RegularTable,
26
- Schema,
27
- CellMeta,
28
- ElemFactory,
29
- EditMode,
30
- PerspectiveViewerElement,
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,
@@ -222,7 +215,7 @@ export async function createModel(
222
215
  }),
223
216
  _series_color_map: new Map<string, string>(),
224
217
  _series_color_seed: new Map<string, number>(),
225
- get_psp_type,
218
+ // get_psp_type,
226
219
  _div_factory: extend._div_factory || new ElemFactoryImpl("div"),
227
220
  }) as DatagridModel;
228
221
 
@@ -12,11 +12,12 @@
12
12
 
13
13
  import { RegularTableElement } from "regular-table";
14
14
 
15
- import type {
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.
@@ -71,6 +59,7 @@ export function applyBodyCellStyles(
71
59
  const is_numeric = type === "integer" || type === "float";
72
60
 
73
61
  // Calculate aggregate depth visibility
62
+ // @ts-ignore
74
63
  metadata._is_hidden_by_aggregate_depth = ((x?: number) =>
75
64
  x === 0 || x === undefined
76
65
  ? false
@@ -109,6 +98,7 @@ export function applyBodyCellStyles(
109
98
  "psp-bool-type",
110
99
  type === "boolean" && metadata.user !== null,
111
100
  );
101
+
112
102
  td.classList.toggle("psp-null", metadata.value === null);
113
103
  td.classList.toggle("psp-align-right", !isHeader && is_numeric);
114
104
  td.classList.toggle("psp-align-left", isHeader || !is_numeric);
@@ -138,14 +128,18 @@ export function applyBodyCellStyles(
138
128
  }
139
129
 
140
130
  if (
141
- metadata.row_header_x === undefined ||
131
+ metadata.type !== "row_header" ||
142
132
  metadata.row_header_x ===
143
133
  (metadata.row_header as unknown[]).length - 1 ||
144
134
  (metadata.row_header as unknown[])[metadata.row_header_x + 1] ===
145
135
  undefined
146
136
  ) {
147
137
  td.dataset.y = String(metadata.y);
148
- td.dataset.x = String(metadata.x);
138
+ if (metadata.type !== "row_header") {
139
+ td.dataset.x = String(metadata.x);
140
+ } else {
141
+ delete td.dataset.x;
142
+ }
149
143
  } else {
150
144
  delete td.dataset.y;
151
145
  delete td.dataset.x;
@@ -166,6 +160,7 @@ export function applyBodyCellStyles(
166
160
  const selectedArr = selected as unknown[];
167
161
  if (isHeader) {
168
162
  if (
163
+ metadata.type === "row_header" &&
169
164
  metadata.row_header_x !== undefined &&
170
165
  !!id[metadata.row_header_x]
171
166
  ) {
@@ -195,7 +190,7 @@ export function applyBodyCellStyles(
195
190
  }
196
191
 
197
192
  // Apply editable styling (if editable)
198
- if (!isHeader && metadata.x !== undefined) {
193
+ if (!isHeader && metadata.type === "body") {
199
194
  if (isEditable && this._is_editable[metadata.x]) {
200
195
  const col_name =
201
196
  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 type { DatagridModel, PerspectiveViewerElement } from "../types.js";
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
  /**
@@ -97,12 +101,19 @@ export function styleColumnHeaderRow(
97
101
  const selectedColumn = this._column_settings_selected_column;
98
102
 
99
103
  for (const { element: td, metadata } of headerRow.cells) {
100
- if (!metadata) continue;
104
+ if (
105
+ !metadata ||
106
+ metadata.type === "body" ||
107
+ metadata.type === "row_header"
108
+ )
109
+ continue;
101
110
 
102
111
  const column_name =
103
112
  metadata.column_header?.[this._config.split_by.length];
104
113
  const sort = this._config.sort.find((x) => x[0] === column_name);
105
- let needs_border = metadata.row_header_x === header_depth;
114
+ let needs_border =
115
+ metadata.type === "corner" &&
116
+ metadata.row_header_x === header_depth;
106
117
  const is_corner = typeof metadata.x === "undefined";
107
118
  needs_border =
108
119
  needs_border ||
@@ -147,7 +158,7 @@ export function styleColumnHeaderRow(
147
158
  !is_menu_row && !!sort && sort[1] === "col desc abs",
148
159
  );
149
160
 
150
- const type = this.get_psp_type(metadata);
161
+ const type = get_psp_type(this, metadata);
151
162
  const is_numeric = type === "integer" || type === "float";
152
163
  const is_string = type === "string";
153
164
  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: CellMetaExtended;
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(cell) as
122
- | CellMetaExtended
123
- | undefined;
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(cell) as
148
- | CellMetadata
149
- | undefined;
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,