@1771technologies/lytenyte-pro 1.0.2 → 1.0.4

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 (61) hide show
  1. package/dist/+types.d.ts +24 -4
  2. package/dist/cell-selection/cell-selection-driver.js +3 -2
  3. package/dist/cell-selection/cell-style-row.d.ts +2 -2
  4. package/dist/cell-selection/cell-style-row.js +1 -1
  5. package/dist/cell-selection/get-root-cell.js +3 -83
  6. package/dist/cell-selection/index.d.ts +0 -1
  7. package/dist/cell-selection/index.js +0 -1
  8. package/dist/cell-selection/split-cell-selection-rect.d.ts +8 -1
  9. package/dist/cell-selection/split-cell-selection-rect.js +13 -4
  10. package/dist/cell-selection/split-on-pivot.d.ts +3 -0
  11. package/dist/cell-selection/split-on-pivot.js +50 -0
  12. package/dist/cells/cell-editor.js +1 -1
  13. package/dist/cells/cell-spacer.d.ts +3 -0
  14. package/dist/cells/cell-spacer.js +37 -0
  15. package/dist/cells/cell.d.ts +1 -3
  16. package/dist/cells/cell.js +11 -9
  17. package/dist/column-manager/branch.js +1 -1
  18. package/dist/column-manager/leaf.js +1 -1
  19. package/dist/column-manager/move-handle.d.ts +0 -7
  20. package/dist/column-manager/move-handle.js +23 -6
  21. package/dist/filter-tree/leaf.js +3 -1
  22. package/dist/grid-box/+types.d.ts +2 -2
  23. package/dist/grid-box/item.js +3 -3
  24. package/dist/grid-box/use-aggregation-box-items.js +1 -2
  25. package/dist/grid-box/use-column-box-items.d.ts +2 -3
  26. package/dist/grid-box/use-column-box-items.js +3 -3
  27. package/dist/grid-box/use-row-group-box-items.d.ts +3 -3
  28. package/dist/grid-box/use-row-group-box-items.js +41 -5
  29. package/dist/grid.d.ts +1 -1
  30. package/dist/header/resize-handler.js +21 -15
  31. package/dist/license.js +1 -1
  32. package/dist/row-data-source-client/use-client-data-source-paginated.js +154 -164
  33. package/dist/row-data-source-client/use-client-data-source.js +144 -177
  34. package/dist/row-data-source-client/use-client-tree-data-source.js +119 -152
  35. package/dist/row-data-source-server/use-server-data-source.js +102 -120
  36. package/dist/rows/row/row.d.ts +1 -1
  37. package/dist/rows/row/row.js +11 -4
  38. package/dist/rows/rows-sections.js +1 -1
  39. package/dist/sort-manager/+types.d.ts +2 -0
  40. package/dist/sort-manager/hooks/use-sort-row-item.js +6 -6
  41. package/dist/sort-manager/utils/sort-item-to-sort-model.js +5 -0
  42. package/dist/sort-manager/utils/sort-model-to-sort-items.js +2 -1
  43. package/dist/state/+types.d.ts +8 -10
  44. package/dist/state/api/cell-root.d.ts +5 -0
  45. package/dist/state/api/cell-root.js +64 -0
  46. package/dist/state/api/edit-begin.js +5 -9
  47. package/dist/state/api/edit-is-cell-active.d.ts +1 -1
  48. package/dist/state/api/edit-is-cell-active.js +2 -7
  49. package/dist/state/api/focus-cell.js +2 -2
  50. package/dist/state/helpers/column-layout.d.ts +3 -3
  51. package/dist/state/helpers/column-layout.js +9 -15
  52. package/dist/state/helpers/get-full-width-callback.d.ts +1 -1
  53. package/dist/state/helpers/get-full-width-callback.js +2 -0
  54. package/dist/state/helpers/get-span-callback.d.ts +1 -1
  55. package/dist/state/helpers/get-span-callback.js +2 -0
  56. package/dist/state/helpers/row-layout/row-layout.d.ts +5 -4
  57. package/dist/state/helpers/row-layout/row-layout.js +112 -346
  58. package/dist/state/use-lytenyte.js +398 -334
  59. package/dist/viewport/viewport.js +3 -2
  60. package/main.css +27 -3
  61. package/package.json +7 -7
@@ -1,4 +1,4 @@
1
- import { focusCell, isFullWidthMap } from "@1771technologies/lytenyte-shared";
1
+ import { focusCell } from "@1771technologies/lytenyte-shared";
2
2
  import { runWithBackoff } from "@1771technologies/lytenyte-js-utils";
3
3
  import { editOnChange } from "../helpers/edit-on-change.js";
4
4
  export const makeEditBegin = (grid) => {
@@ -38,18 +38,14 @@ export const makeEditBegin = (grid) => {
38
38
  grid.api.scrollIntoView({ column, row: params.rowIndex });
39
39
  // Let's try begin the cell edit.
40
40
  const run = () => {
41
- const layout = i.layout.get();
42
- const row = layout.get(params.rowIndex);
43
- if (!row)
44
- return false;
45
- if (isFullWidthMap(row))
46
- return true;
47
41
  const columnIndex = meta.columnsVisible.indexOf(column);
48
- const cell = layout.get(columnIndex);
42
+ const cell = grid.api.cellRoot(params.rowIndex, columnIndex);
49
43
  if (!cell)
50
44
  return false;
45
+ if (cell.kind === "full-width")
46
+ return true;
51
47
  focusCell({
52
- layout,
48
+ getRootCell: grid.api.cellRoot,
53
49
  focusActive: i.focusActive,
54
50
  id: grid.state.gridId.get(),
55
51
  colIndex: columnIndex,
@@ -1,4 +1,4 @@
1
- import type { InternalAtoms } from "../+types.js";
1
+ import type { InternalAtoms } from "../+types";
2
2
  import type { Grid, GridApi } from "../../+types";
3
3
  export declare const makeEditIsCellActive: (grid: Grid<any> & {
4
4
  internal: InternalAtoms;
@@ -1,4 +1,3 @@
1
- import { isFullWidthMap } from "@1771technologies/lytenyte-shared";
2
1
  export const makeEditIsCellActive = (grid) => {
3
2
  return (params) => {
4
3
  const active = grid.internal.editActivePos.get();
@@ -14,13 +13,9 @@ export const makeEditIsCellActive = (grid) => {
14
13
  column = meta.columnsVisible.find((c) => c.id === params.column.id);
15
14
  if (!column)
16
15
  return false;
17
- const layout = grid.internal.layout.get();
18
- const row = layout.get(params.rowIndex);
19
- if (!row || isFullWidthMap(row))
20
- return false;
21
16
  const colIndex = meta.columnsVisible.indexOf(column);
22
- const cell = row.get(colIndex);
23
- if (!cell)
17
+ const cell = grid.api.cellRoot(params.rowIndex, colIndex);
18
+ if (!cell || cell.kind === "full-width")
24
19
  return false;
25
20
  return active.column.id === column.id && active.rowIndex === params.rowIndex;
26
21
  };
@@ -32,7 +32,7 @@ export const makeFocusCell = (grid) => {
32
32
  columnCount: grid.state.columnMeta.get().columnsVisible.length,
33
33
  focusActive: grid.internal.focusActive,
34
34
  id: grid.state.gridId.get(),
35
- layout: grid.internal.layout.get(),
35
+ getRootCell: grid.api.cellRoot,
36
36
  rtl: grid.state.rtl.get(),
37
37
  scrollIntoView: grid.api.scrollIntoView,
38
38
  });
@@ -108,7 +108,7 @@ export const makeFocusCell = (grid) => {
108
108
  rowIndex: position.row,
109
109
  focusActive: grid.internal.focusActive,
110
110
  id: grid.state.gridId.get(),
111
- layout: grid.internal.layout.get(),
111
+ getRootCell: grid.api.cellRoot,
112
112
  scrollIntoView: grid.api.scrollIntoView,
113
113
  vp,
114
114
  });
@@ -1,3 +1,3 @@
1
- import type { PathTableItem, SpanLayout } from "@1771technologies/lytenyte-shared";
2
- import type { Column, ColumnGroupMeta, HeaderLayoutCell, PositionUnion } from "../../+types";
3
- export declare function makeColumnLayout<T>(combinedView: PathTableItem<Column<T>>[][], groupMeta: ColumnGroupMeta, b: SpanLayout, focus: PositionUnion | null, floatingRowEnabled: boolean): HeaderLayoutCell<T>[][];
1
+ import type { HeaderLayoutCell } from "../../+types";
2
+ import type { MakeColumnViewReturn } from "./column-view";
3
+ export declare function makeColumnLayout<T>(view: MakeColumnViewReturn<T>, floatingRowEnabled: boolean): HeaderLayoutCell<T>[][];
@@ -1,5 +1,7 @@
1
- import { rangesOverlap } from "@1771technologies/lytenyte-js-utils";
2
- export function makeColumnLayout(combinedView, groupMeta, b, focus, floatingRowEnabled) {
1
+ export function makeColumnLayout(view, floatingRowEnabled) {
2
+ const combinedView = view.combinedView;
3
+ const groupMeta = view.meta;
4
+ const centerEnd = view.startCount + view.centerCount;
3
5
  const layout = [];
4
6
  const floatingRow = [];
5
7
  for (let r = 0; r < combinedView.length; r++) {
@@ -8,15 +10,7 @@ export function makeColumnLayout(combinedView, groupMeta, b, focus, floatingRowE
8
10
  for (let i = 0; i < row.length; i++) {
9
11
  const c = row[i];
10
12
  const colS = c.colStart;
11
- const colE = c.colStart + c.colSpan;
12
- if (!rangesOverlap(colS, colE, b.colStartStart, b.colStartEnd) && // not in start area
13
- !rangesOverlap(colS, colE, b.colCenterStart, b.colCenterEnd) && // not in center area
14
- !rangesOverlap(colS, colE, b.colEndStart, b.colEndEnd) && // not in end area
15
- !(focus && rangesOverlap(colS, colE, focus.colIndex, focus.colIndex + 1)) // not if a cell in the column is focused
16
- ) {
17
- continue;
18
- }
19
- const colPin = colS < b.colStartEnd ? "start" : colS >= b.colEndStart ? "end" : null;
13
+ const colPin = colS < view.startCount ? "start" : colS >= centerEnd ? "end" : null;
20
14
  if (c.kind === "leaf") {
21
15
  const vals = {
22
16
  id: c.data.id,
@@ -28,8 +22,8 @@ export function makeColumnLayout(combinedView, groupMeta, b, focus, floatingRowE
28
22
  colStart: c.colStart,
29
23
  colEnd: c.colStart + c.colSpan,
30
24
  colSpan: c.colSpan,
31
- colFirstEndPin: c.colStart === b.colCenterLast ? true : undefined,
32
- colLastStartPin: c.colStart + c.colSpan === b.colStartEnd ? true : undefined,
25
+ colFirstEndPin: c.colStart === centerEnd ? true : undefined,
26
+ colLastStartPin: c.colStart + c.colSpan === view.startCount ? true : undefined,
33
27
  };
34
28
  rowLayout.push({ kind: "cell", ...vals });
35
29
  if (floatingRowEnabled) {
@@ -53,8 +47,8 @@ export function makeColumnLayout(combinedView, groupMeta, b, focus, floatingRowE
53
47
  groupPath: c.data.groupPath,
54
48
  start: c.data.start,
55
49
  end: c.data.end,
56
- colFirstEndPin: c.colStart === b.colCenterLast ? true : undefined,
57
- colLastStartPin: c.colStart + c.colSpan === b.colStartEnd ? true : undefined,
50
+ colFirstEndPin: c.colStart === centerEnd ? true : undefined,
51
+ colLastStartPin: c.colStart + c.colSpan === view.startCount ? true : undefined,
58
52
  });
59
53
  }
60
54
  layout.push(rowLayout);
@@ -1,2 +1,2 @@
1
1
  import type { Grid, RowDataSource, RowFullWidthPredicate } from "../../+types";
2
- export declare function getFullWidthCallback<T>(rds: RowDataSource<T>, predicate: RowFullWidthPredicate<T>, grid: Grid<T>): (r: number) => boolean;
2
+ export declare function getFullWidthCallback<T>(rds: RowDataSource<T>, predicate: RowFullWidthPredicate<T> | null, grid: Grid<T>): ((r: number) => boolean) | null;
@@ -1,4 +1,6 @@
1
1
  export function getFullWidthCallback(rds, predicate, grid) {
2
+ if (!predicate)
3
+ return null;
2
4
  return (r) => {
3
5
  const rowNode = rds.rowByIndex(r);
4
6
  if (!rowNode)
@@ -1,2 +1,2 @@
1
1
  import type { Column, Grid, RowDataSource } from "../../+types";
2
- export declare function getSpanFn<T>(rds: RowDataSource<T>, grid: Grid<T>, visibleColumns: Column<T>[], span: "row" | "col"): (r: number, c: number) => number;
2
+ export declare function getSpanFn<T>(rds: RowDataSource<T>, grid: Grid<T>, visibleColumns: Column<T>[], span: "row" | "col"): ((r: number, c: number) => number) | null;
@@ -1,4 +1,6 @@
1
1
  export function getSpanFn(rds, grid, visibleColumns, span) {
2
+ if (visibleColumns.every((c) => !(span === "col" ? c.colSpan : c.rowSpan)))
3
+ return null;
2
4
  return (r, c) => {
3
5
  const row = rds.rowByIndex(r);
4
6
  const column = visibleColumns[c];
@@ -1,8 +1,9 @@
1
- import { type LayoutMap, type SpanLayout } from "@1771technologies/lytenyte-shared";
1
+ import { type LayoutState, type SpanLayout } from "@1771technologies/lytenyte-shared";
2
2
  import type { Column, PositionUnion, RowDataStore, RowLayout } from "../../../+types";
3
3
  interface MakeRowViewArgs<T> {
4
- layout: SpanLayout;
5
- layoutMap: LayoutMap;
4
+ view: SpanLayout;
5
+ layout: LayoutState;
6
+ viewCache: Map<number, RowLayout<T>>;
6
7
  rds: RowDataStore<T>;
7
8
  columns: Column<T>[];
8
9
  focus: PositionUnion | null;
@@ -10,7 +11,7 @@ interface MakeRowViewArgs<T> {
10
11
  /**
11
12
  * This is quite a complex function so read each part carefully.
12
13
  */
13
- export declare function makeRowLayout<T>({ layout: n, layoutMap, rds, columns, focus, }: MakeRowViewArgs<T>): {
14
+ export declare function makeRowLayout<T>({ view: n, viewCache, layout, rds, columns }: MakeRowViewArgs<T>): {
14
15
  top: RowLayout<T>[];
15
16
  center: RowLayout<T>[];
16
17
  bottom: RowLayout<T>[];