@1771technologies/lytenyte-pro 1.0.0-beta.3 → 1.0.0-beta.31

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 (103) hide show
  1. package/dist/+types.d.ts +88 -14
  2. package/dist/cell-selection/cell-selection-driver.js +9 -1
  3. package/dist/cell-selection/update-additive-cell-selection.js +0 -2
  4. package/dist/cells/cell-editor.js +11 -4
  5. package/dist/cells/cell.js +6 -3
  6. package/dist/column-manager/branch.d.ts +9 -3
  7. package/dist/column-manager/branch.js +20 -4
  8. package/dist/column-manager/column-manager.d.ts +3 -5
  9. package/dist/column-manager/column-manager.js +6 -8
  10. package/dist/column-manager/context.d.ts +2 -2
  11. package/dist/column-manager/label.d.ts +1 -1
  12. package/dist/column-manager/label.js +5 -5
  13. package/dist/column-manager/leaf.d.ts +2 -2
  14. package/dist/column-manager/leaf.js +22 -4
  15. package/dist/column-manager/move-handle.d.ts +3 -3
  16. package/dist/column-manager/move-handle.js +3 -5
  17. package/dist/column-manager/panel.d.ts +1 -0
  18. package/dist/column-manager/panel.js +2 -0
  19. package/dist/column-manager/root.d.ts +6 -7
  20. package/dist/column-manager/root.js +2 -15
  21. package/dist/column-manager/use-column-manager.d.ts +8 -18
  22. package/dist/column-manager/use-column-manager.js +18 -22
  23. package/dist/column-manager/use-columns-from-context.d.ts +2 -2
  24. package/dist/column-manager/use-columns-from-context.js +2 -2
  25. package/dist/column-manager/visibility-checkbox.d.ts +1 -1
  26. package/dist/column-manager/visibility-checkbox.js +2 -2
  27. package/dist/filter-tree/branch.js +1 -1
  28. package/dist/filter-tree/inclusion-checkbox.d.ts +1 -1
  29. package/dist/filter-tree/inclusion-checkbox.js +2 -2
  30. package/dist/filter-tree/label.d.ts +1 -1
  31. package/dist/filter-tree/label.js +2 -2
  32. package/dist/filter-tree/root.d.ts +3 -3
  33. package/dist/filter-tree/root.js +4 -4
  34. package/dist/grid-box/+types.d.ts +4 -2
  35. package/dist/grid-box/item.d.ts +4 -1
  36. package/dist/grid-box/item.js +39 -9
  37. package/dist/grid-box/use-aggregation-box-items.js +3 -1
  38. package/dist/grid-box/use-column-box-items.d.ts +6 -2
  39. package/dist/grid-box/use-column-box-items.js +11 -14
  40. package/dist/grid-box/use-row-group-box-items.d.ts +2 -2
  41. package/dist/grid-box/use-row-group-box-items.js +14 -15
  42. package/dist/grid.d.ts +0 -12
  43. package/dist/grid.js +0 -12
  44. package/dist/header/header-cell.d.ts +1 -1
  45. package/dist/header/header-cell.js +2 -2
  46. package/dist/header/header-group-cell.js +3 -1
  47. package/dist/header/resize-handler.d.ts +2 -2
  48. package/dist/header/resize-handler.js +8 -3
  49. package/dist/header/use-drag-move.js +9 -2
  50. package/dist/header/use-header-cell-renderer.js +4 -4
  51. package/dist/icons/index.d.ts +1 -0
  52. package/dist/icons/index.js +1 -0
  53. package/dist/index.d.ts +7 -0
  54. package/dist/index.js +7 -0
  55. package/dist/listbox/item.js +1 -1
  56. package/dist/row-data-source-client/filter/compute-filtered-rows.js +1 -1
  57. package/dist/row-data-source-client/use-client-data-source-paginated.d.ts +3 -3
  58. package/dist/row-data-source-client/use-client-data-source-paginated.js +66 -24
  59. package/dist/row-data-source-client/use-client-data-source.js +50 -20
  60. package/dist/row-data-source-client/use-client-tree-data-source.js +49 -20
  61. package/dist/row-data-source-server/use-server-data-source.js +20 -0
  62. package/dist/sort-manager/sort-add.d.ts +1 -1
  63. package/dist/sort-manager/sort-add.js +3 -3
  64. package/dist/sort-manager/sort-apply.d.ts +1 -1
  65. package/dist/sort-manager/sort-apply.js +3 -3
  66. package/dist/sort-manager/sort-cancel.d.ts +1 -1
  67. package/dist/sort-manager/sort-cancel.js +3 -3
  68. package/dist/sort-manager/sort-clear.d.ts +1 -1
  69. package/dist/sort-manager/sort-clear.js +3 -3
  70. package/dist/sort-manager/sort-column-select.d.ts +1 -1
  71. package/dist/sort-manager/sort-column-select.js +2 -2
  72. package/dist/sort-manager/sort-direction-select.d.ts +1 -1
  73. package/dist/sort-manager/sort-direction-select.js +2 -2
  74. package/dist/sort-manager/sort-remove.d.ts +1 -1
  75. package/dist/sort-manager/sort-remove.js +3 -3
  76. package/dist/sort-manager/sort-value-select.d.ts +1 -1
  77. package/dist/sort-manager/sort-value-select.js +2 -2
  78. package/dist/state/+types.d.ts +2 -1
  79. package/dist/state/api/column-autosize.js +1 -1
  80. package/dist/state/api/column-from-index.d.ts +1 -1
  81. package/dist/state/api/column-from-index.js +1 -1
  82. package/dist/state/api/column-update.d.ts +4 -1
  83. package/dist/state/api/column-update.js +13 -0
  84. package/dist/state/api/edit-end.js +1 -1
  85. package/dist/state/api/export-data-rect.js +1 -1
  86. package/dist/state/helpers/column-add-row-group.d.ts +2 -1
  87. package/dist/state/helpers/column-add-row-group.js +9 -1
  88. package/dist/state/helpers/column-marker.js +1 -1
  89. package/dist/state/helpers/edit-on-change.js +1 -0
  90. package/dist/state/helpers/empty-row-data-source.js +1 -0
  91. package/dist/state/helpers/resolve-column.d.ts +1 -1
  92. package/dist/state/helpers/resolve-column.js +7 -0
  93. package/dist/state/use-lytenyte.js +16 -4
  94. package/dist/tree-view/branch/branch.d.ts +4 -1
  95. package/dist/tree-view/branch/branch.js +4 -2
  96. package/dist/tree-view/hooks/use-tree-view-paths.d.ts +1 -1
  97. package/dist/tree-view/hooks/use-tree-view-paths.js +3 -3
  98. package/dist/tree-view/leaf.js +1 -0
  99. package/dist/viewport/begin-editing.js +1 -1
  100. package/main.css +4 -0
  101. package/package.json +12 -6
  102. package/dist/column-manager/passive-scroll.d.ts +0 -2
  103. package/dist/column-manager/passive-scroll.js +0 -2
package/dist/+types.d.ts CHANGED
@@ -892,7 +892,8 @@ export interface HeaderGroupCellLayout {
892
892
  */
893
893
  readonly isCollapsible: boolean;
894
894
  /**
895
- * A unique identifier that can be used for rendering keys or tracking elements.
895
+ * The id for the header group. Note this is not unique across all header groups. In particular
896
+ * split header groups with the same path will share the same id. Prefer `idOccurrence` for unique keys.
896
897
  */
897
898
  readonly id: string;
898
899
  /**
@@ -1232,7 +1233,7 @@ export interface ColumnBase<T> {
1232
1233
  /**
1233
1234
  * Function used to render a floating row cell. Only called when floating rows are enabled. Must return a React node.
1234
1235
  */
1235
- readonly floatingRenderer?: HeaderFloatingCellRenderer<T>;
1236
+ readonly floatingCellRenderer?: HeaderFloatingCellRenderer<T>;
1236
1237
  /**
1237
1238
  * Defines how to render the cell content. Accepts a renderer function or a string referencing a registered renderer.
1238
1239
  */
@@ -1287,7 +1288,7 @@ export interface ColumnMarker<T> {
1287
1288
  /**
1288
1289
  * Function used to render a floating row cell. Only called when floating rows are enabled. Must return a React node.
1289
1290
  */
1290
- readonly floatingRenderer?: HeaderFloatingCellRenderer<T>;
1291
+ readonly floatingCellRenderer?: HeaderFloatingCellRenderer<T>;
1291
1292
  /**
1292
1293
  * Specifies the preferred width of the column. This value is ignored if flex sizing is used, or if it violates the column's min/max bounds.
1293
1294
  */
@@ -1441,7 +1442,7 @@ export interface Column<T> {
1441
1442
  /**
1442
1443
  * Function used to render a floating row cell. Only called when floating rows are enabled. Must return a React node.
1443
1444
  */
1444
- readonly floatingRenderer?: HeaderFloatingCellRenderer<T>;
1445
+ readonly floatingCellRenderer?: HeaderFloatingCellRenderer<T>;
1445
1446
  /**
1446
1447
  * Defines how to render the cell content. Accepts a renderer function or a string referencing a registered renderer.
1447
1448
  */
@@ -1532,7 +1533,7 @@ export interface RowGroupColumn<T> {
1532
1533
  /**
1533
1534
  * Function used to render a floating row cell. Only called when floating rows are enabled. Must return a React node.
1534
1535
  */
1535
- readonly floatingRenderer?: HeaderFloatingCellRenderer<T>;
1536
+ readonly floatingCellRenderer?: HeaderFloatingCellRenderer<T>;
1536
1537
  /**
1537
1538
  * Describes the capabilities and intended UI behavior of the column. These hints are used by external UI components.
1538
1539
  */
@@ -1675,6 +1676,46 @@ export interface ColumnGroupMeta {
1675
1676
  * Used to build dynamic, collapsible column group layouts in LyteNyte Grid.
1676
1677
  */
1677
1678
  export type ColumnGroupVisibility = "always" | "close" | "open";
1679
+ /**
1680
+ * Parameters required to initialize a client-side row data source.
1681
+ */
1682
+ export interface ClientRowDataSourcePaginatedParams<T> {
1683
+ /**
1684
+ * The primary dataset passed to LyteNyte Grid for display.
1685
+ */
1686
+ readonly data: T[];
1687
+ /**
1688
+ * Rows to pin to the top of the grid, rendered above all scrollable rows.
1689
+ */
1690
+ readonly topData?: T[];
1691
+ /**
1692
+ * Rows to pin to the bottom of the grid, rendered below all scrollable rows.
1693
+ */
1694
+ readonly bottomData?: T[];
1695
+ /**
1696
+ * If true, the data source will reflect external mutations to the original data array.
1697
+ */
1698
+ readonly reflectData?: boolean;
1699
+ /**
1700
+ * Callback to derive a unique id for grouped (branch) rows based on group value path.
1701
+ */
1702
+ readonly rowIdBranch?: (path: string[]) => string;
1703
+ /**
1704
+ * Callback to derive a unique id for each leaf row. Receives the row data and index.
1705
+ */
1706
+ readonly rowIdLeaf?: (d: RowLeaf<T>, i: number) => string;
1707
+ /**
1708
+ * Callback that transforms a set of values for a given column into the in filter items LyteNyte Grid should use.
1709
+ */
1710
+ readonly transformInFilterItem?: (params: {
1711
+ column: Column<T>;
1712
+ values: unknown[];
1713
+ }) => FilterInFilterItem[];
1714
+ /**
1715
+ * The number of rows to have per page. This will impact the total page count.
1716
+ */
1717
+ readonly rowsPerPage?: number;
1718
+ }
1678
1719
  /**
1679
1720
  * Enhanced parameters for a client-side row data source with additional filtering support.
1680
1721
  */
@@ -1704,12 +1745,12 @@ export interface ClientRowDataSourceParams<T> {
1704
1745
  */
1705
1746
  readonly rowIdLeaf?: (d: RowLeaf<T>, i: number) => string;
1706
1747
  /**
1707
- * Callback that transforms a column in-filter item before it's applied.
1748
+ * Callback that transforms a set of values for a given column into the in filter items LyteNyte Grid should use.
1708
1749
  */
1709
1750
  readonly transformInFilterItem?: (params: {
1710
- field: unknown;
1711
1751
  column: Column<T>;
1712
- }) => FilterInFilterItem;
1752
+ values: unknown[];
1753
+ }) => FilterInFilterItem[];
1713
1754
  }
1714
1755
  /**
1715
1756
  * Parameters for initializing a tree-structured data source in LyteNyte Grid.
@@ -1740,12 +1781,12 @@ export interface ClientTreeDataSourceParams<T> {
1740
1781
  */
1741
1782
  readonly rowIdLeaf?: (d: RowLeaf<T>, i: number) => string;
1742
1783
  /**
1743
- * Callback that transforms a column in-filter item before it's applied.
1784
+ * Callback that transforms a set of values for a given column into the in filter items LyteNyte Grid should use.
1744
1785
  */
1745
1786
  readonly transformInFilterItem?: (params: {
1746
- field: unknown;
1747
1787
  column: Column<T>;
1748
- }) => FilterInFilterItem;
1788
+ values: unknown[];
1789
+ }) => FilterInFilterItem[];
1749
1790
  /**
1750
1791
  * Returns the hierarchical path to group a given data row in tree mode.
1751
1792
  */
@@ -1806,6 +1847,10 @@ export interface RowDataSourceClientPaginated<T> {
1806
1847
  * Adds new rows to the grid optionally at a specific index, beginning, or end.
1807
1848
  */
1808
1849
  readonly rowAdd: (newRows: any[], atIndex?: number | "beginning" | "end") => void;
1850
+ /**
1851
+ * Sets the data for the center rows (scrollable rows) of the grid. Effectively replacing the current row data.
1852
+ */
1853
+ readonly rowSetCenterData: (newRows: any[]) => void;
1809
1854
  /**
1810
1855
  * Sets the data for rows pinned to the top section.
1811
1856
  */
@@ -1823,6 +1868,10 @@ export interface RowDataSourceClientPaginated<T> {
1823
1868
  * May return items synchronously or as a Promise.
1824
1869
  */
1825
1870
  readonly inFilterItems: (column: Column<T>) => Promise<FilterInFilterItem[]> | FilterInFilterItem[];
1871
+ /**
1872
+ * A client data source method to retrieve the raw data passed to the data source.
1873
+ */
1874
+ readonly rowData: (section: RowSection) => T[];
1826
1875
  }
1827
1876
  /**
1828
1877
  * Represents pagination-related state for the client row data source in
@@ -1899,6 +1948,10 @@ export interface RowDataSourceClient<T> {
1899
1948
  * Adds new rows to the grid optionally at a specific index, beginning, or end.
1900
1949
  */
1901
1950
  readonly rowAdd: (newRows: any[], atIndex?: number | "beginning" | "end") => void;
1951
+ /**
1952
+ * Sets the data for the center rows (scrollable rows) of the grid. Effectively replacing the current row data.
1953
+ */
1954
+ readonly rowSetCenterData: (newRows: any[]) => void;
1902
1955
  /**
1903
1956
  * Sets the data for rows pinned to the top section.
1904
1957
  */
@@ -1912,6 +1965,10 @@ export interface RowDataSourceClient<T> {
1912
1965
  * May return items synchronously or as a Promise.
1913
1966
  */
1914
1967
  readonly inFilterItems: (column: Column<T>) => Promise<FilterInFilterItem[]> | FilterInFilterItem[];
1968
+ /**
1969
+ * A client data source method to retrieve the raw data passed to the data source.
1970
+ */
1971
+ readonly rowData: (section: RowSection) => T[];
1915
1972
  }
1916
1973
  /**
1917
1974
  * The row data source interface used by LyteNyte Grid to retrieve and manage row data.
@@ -1966,6 +2023,10 @@ export interface RowDataSource<T> {
1966
2023
  * Adds new rows to the grid optionally at a specific index, beginning, or end.
1967
2024
  */
1968
2025
  readonly rowAdd: (newRows: any[], atIndex?: number | "beginning" | "end") => void;
2026
+ /**
2027
+ * Sets the data for the center rows (scrollable rows) of the grid. Effectively replacing the current row data.
2028
+ */
2029
+ readonly rowSetCenterData: (newRows: any[]) => void;
1969
2030
  /**
1970
2031
  * Sets the data for rows pinned to the top section.
1971
2032
  */
@@ -2039,6 +2100,10 @@ export interface RowDataSourceServer<T> {
2039
2100
  * Adds new rows to the grid optionally at a specific index, beginning, or end.
2040
2101
  */
2041
2102
  readonly rowAdd: (newRows: any[], atIndex?: number | "beginning" | "end") => void;
2103
+ /**
2104
+ * Sets the data for the center rows (scrollable rows) of the grid. Effectively replacing the current row data.
2105
+ */
2106
+ readonly rowSetCenterData: (newRows: any[]) => void;
2042
2107
  /**
2043
2108
  * Sets the data for rows pinned to the top section.
2044
2109
  */
@@ -2573,6 +2638,10 @@ export interface CellRendererParams<T> {
2573
2638
  * Indicates whether the row is in an indeterminate selection state.
2574
2639
  */
2575
2640
  readonly rowIndeterminate: boolean;
2641
+ /**
2642
+ * The pinning state of a row, used to fix it to the top or bottom of the grid.
2643
+ */
2644
+ readonly rowPin: RowPin;
2576
2645
  }
2577
2646
  /**
2578
2647
  * The parameters the `columnAutosize` method accepts.
@@ -2641,7 +2710,7 @@ export interface GridApi<T> {
2641
2710
  * Returns the column at the specified visible index. If the index is out of bounds or
2642
2711
  * the column is hidden (due to visibility rules or collapsed groups), this will return null.
2643
2712
  */
2644
- readonly columnFromIndex: (columnIndex: number) => Column<T> | null;
2713
+ readonly columnByIndex: (columnIndex: number) => Column<T> | null;
2645
2714
  /**
2646
2715
  * Returns the index of a visible column based on its id or column object.
2647
2716
  * Returns -1 if the column is not currently visible (e.g., hidden or inside a collapsed group).
@@ -2805,7 +2874,7 @@ export interface GridApi<T> {
2805
2874
  * Returns the raw cell data within a rectangular selection of the grid.
2806
2875
  * This can be useful for custom data processing or exporting workflows.
2807
2876
  */
2808
- readonly exportDataRect: (params?: ExportDataRectParams) => ExportDataRectResult<T>;
2877
+ readonly exportDataRect: (params?: ExportDataRectParams) => Promise<ExportDataRectResult<T>>;
2809
2878
  /**
2810
2879
  * Exports the cell data for a given rectangle of the grid as a CSV-formatted string.
2811
2880
  * The rectangle can be customized through parameters such as selected rows, columns, or cell ranges.
@@ -4148,6 +4217,11 @@ export interface EditSetterParams<T> {
4148
4217
  * A reference to a column definition in LyteNyte Grid.
4149
4218
  */
4150
4219
  readonly column: Column<T>;
4220
+ /**
4221
+ * The current edit value of the cell being edited. Useful when the cell is derived from data and not
4222
+ * actually present in the row data.
4223
+ */
4224
+ readonly value: any;
4151
4225
  /**
4152
4226
  * The new row data after applying edits. This is an intermediate representation,
4153
4227
  * not yet committed to the grid.
@@ -4775,7 +4849,7 @@ export type ExportDataRectFn<T> = (
4775
4849
  /**
4776
4850
  * Optional parameters for exporting a DataRect.
4777
4851
  */
4778
- params: ExportDataRectParams) => ExportDataRectResult<T>;
4852
+ params: ExportDataRectParams) => Promise<ExportDataRectResult<T>>;
4779
4853
  /**
4780
4854
  * Parameters for exporting a specific rectangular region of the grid using a DataRect.
4781
4855
  */
@@ -2,7 +2,7 @@ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect } from "react";
3
3
  import { useGridRoot } from "../context";
4
4
  import { useEdgeScroll } from "./use-edge-scroll";
5
- import { getClientX, getClientY, getRelativeXPosition, getRelativeYPosition, } from "@1771technologies/lytenyte-js-utils";
5
+ import { equal, getClientX, getClientY, getRelativeXPosition, getRelativeYPosition, } from "@1771technologies/lytenyte-js-utils";
6
6
  import { getNearestFocusable, getPositionFromFocusable } from "@1771technologies/lytenyte-shared";
7
7
  import { isHTMLElement } from "@1771technologies/lytenyte-dom-utils";
8
8
  import { updateAdditiveCellSelection } from "./update-additive-cell-selection";
@@ -238,8 +238,16 @@ export function CellSelectionDriver() {
238
238
  };
239
239
  }, [cancelX, cancelY, edgeScrollX, edgeScrollY, grid, mode, viewport]);
240
240
  useEffect(() => {
241
+ let prev = null;
241
242
  return grid.internal.focusActive.watch(() => {
242
243
  const focus = grid.internal.focusActive.get();
244
+ // If the focus is null, then we should just return. This keeps the existing selection
245
+ // in place - for things like copy and paste.
246
+ if (!focus)
247
+ return;
248
+ if (equal(prev, focus))
249
+ return;
250
+ prev = focus;
243
251
  if (focus?.kind !== "cell" && focus?.kind !== "full-width") {
244
252
  grid.state.cellSelections.set([]);
245
253
  grid.internal.cellSelectionPivot.set(null);
@@ -7,7 +7,6 @@ export function updateAdditiveCellSelection(grid, rect) {
7
7
  const ds = grid.state.rowDataStore;
8
8
  const rowTopCount = ds.rowTopCount.get();
9
9
  const adjustedRect = adjustRectForRowAndCellSpan(grid, rect);
10
- console.log(adjustedRect);
11
10
  const rects = splitCellSelectionRect({
12
11
  rect: boundSelectionRect(grid, adjustedRect),
13
12
  colCenterCount: s.columnVisibleCenterCount,
@@ -15,7 +14,6 @@ export function updateAdditiveCellSelection(grid, rect) {
15
14
  rowCenterCount: ds.rowCenterCount.get(),
16
15
  rowTopCount: rowTopCount,
17
16
  });
18
- console.log(rects);
19
17
  const current = grid.internal.cellSelectionAdditiveRects.get();
20
18
  if (current && current.length === rects.length) {
21
19
  if (current.every((c, i) => areRectsEqual(c, rects[i])))
@@ -34,6 +34,13 @@ export function CellEditor({ cell }) {
34
34
  }
35
35
  if (e.key === "Enter") {
36
36
  const ds = grid.state.rowDataStore;
37
+ // Don't move if the there are validation errors.
38
+ const editValidation = grid.internal.editValidation.get();
39
+ if (typeof editValidation === "boolean"
40
+ ? editValidation === false
41
+ : Object.keys(editValidation).length >= 1) {
42
+ return;
43
+ }
37
44
  handleNavigationKeys({
38
45
  ctrlKey: false,
39
46
  metaKey: false,
@@ -81,12 +88,12 @@ function EditRenderer({ cell }) {
81
88
  if (!editRenderer) {
82
89
  const type = column.type;
83
90
  if (type === "number")
84
- return (_jsx("input", { type: "number", value: value, onChange: (e) => onChange(Number.parseFloat(e.target.value)) }));
91
+ return (_jsx("input", { type: "number", value: value ?? "", onChange: (e) => (e.target.value ? onChange(Number.parseFloat(e.target.value)) : 0) }));
85
92
  if (type === "date")
86
- return _jsx("input", { type: "date", value: value, onChange: (e) => onChange(e.target.value) });
93
+ return _jsx("input", { type: "date", value: value ?? "", onChange: (e) => onChange(e.target.value) });
87
94
  if (type === "datetime")
88
- return (_jsx("input", { type: "datetime-local", value: value, onChange: (e) => onChange(e.target.value) }));
89
- return _jsx("input", { value: value, onChange: (e) => onChange(e.target.value) });
95
+ return (_jsx("input", { type: "datetime-local", value: value ?? "", onChange: (e) => onChange(e.target.value) }));
96
+ return _jsx("input", { value: value ?? "", onChange: (e) => onChange(e.target.value) });
90
97
  }
91
98
  const Renderer = typeof editRenderer === "string" ? editFuncs[editRenderer] : editRenderer;
92
99
  const validation = ctx.grid.internal.editValidation.useValue();
@@ -2,7 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  import { forwardRef, useEffect, useState } from "react";
3
3
  import { fastDeepMemo } from "@1771technologies/lytenyte-react-hooks";
4
4
  import { useGridRoot } from "../context";
5
- import { CellReact } from "@1771technologies/lytenyte-shared";
5
+ import { CellReact, GROUP_COLUMN_SINGLE_ID } from "@1771technologies/lytenyte-shared";
6
6
  import { CellDefault } from "./cell-default";
7
7
  import { CellEditor } from "./cell-editor";
8
8
  import { useRowMeta } from "../rows/row/context";
@@ -10,9 +10,10 @@ const CellImpl = forwardRef(function Cell({ cell, children, ...props }, forwarde
10
10
  const grid = useGridRoot().grid;
11
11
  const cx = grid.state;
12
12
  grid.internal.refreshKey.useValue();
13
+ const base = grid.state.columnBase.useValue();
13
14
  const row = cell.row.useValue();
14
15
  const renderers = cx.cellRenderers.useValue();
15
- const providedRenderer = children ?? cell.column.cellRenderer;
16
+ const providedRenderer = children ?? cell.column.cellRenderer ?? base.cellRenderer;
16
17
  const Renderer = providedRenderer
17
18
  ? typeof providedRenderer === "string"
18
19
  ? (renderers[providedRenderer] ?? CellDefault)
@@ -32,6 +33,8 @@ const CellImpl = forwardRef(function Cell({ cell, children, ...props }, forwarde
32
33
  const rowMeta = useRowMeta();
33
34
  if (!row)
34
35
  return null;
35
- return (_jsxs(CellReact, { ...props, ref: forwarded, cell: cell, isEditing: isEditing, viewportWidth: cx.viewportWidthInner.useValue(), detailHeight: grid.api.rowDetailRenderedHeight(row ?? ""), rtl: cx.rtl.useValue(), xPosition: cx.xPositions.useValue(), yPosition: cx.yPositions.useValue(), children: [isEditing && _jsx(CellEditor, { cell: cell }), !isEditing && (_jsx(_Fragment, { children: typeof Renderer === "function" ? (_jsx(Renderer, { column: cell.column, rowSelected: rowMeta.selected, rowIndeterminate: rowMeta.indeterminate, row: row, grid: grid, rowIndex: cell.rowIndex, colIndex: cell.colIndex })) : (Renderer) }))] }));
36
+ if (cell.column.id === GROUP_COLUMN_SINGLE_ID)
37
+ console.log(cell.row.get());
38
+ return (_jsxs(CellReact, { ...props, ref: forwarded, cell: cell, isEditing: isEditing, viewportWidth: cx.viewportWidthInner.useValue(), detailHeight: grid.api.rowDetailRenderedHeight(row ?? ""), rtl: cx.rtl.useValue(), xPosition: cx.xPositions.useValue(), yPosition: cx.yPositions.useValue(), children: [isEditing && _jsx(CellEditor, { cell: cell }), !isEditing && (_jsx(_Fragment, { children: typeof Renderer === "function" ? (_jsx(Renderer, { column: cell.column, rowSelected: rowMeta.selected, rowIndeterminate: rowMeta.indeterminate, row: row, grid: grid, rowIndex: cell.rowIndex, colIndex: cell.colIndex, rowPin: cell.rowPin })) : (Renderer) }))] }));
36
39
  });
37
40
  export const Cell = fastDeepMemo(CellImpl);
@@ -1,9 +1,15 @@
1
- import type { TreeVirtualBranch } from "../tree-view/virtualized/make-virtual-tree";
1
+ import type { CSSProperties } from "react";
2
2
  import type { Column } from "../+types";
3
3
  import type { SlotComponent } from "@1771technologies/lytenyte-react-hooks";
4
+ import type { PathBranch } from "@1771technologies/lytenyte-shared";
4
5
  export interface ColumnManagerBranchProps {
5
- readonly item: TreeVirtualBranch<Column<any>>;
6
+ readonly item: PathBranch<Column<any>>;
6
7
  readonly label: SlotComponent;
7
- readonly expander?: SlotComponent;
8
+ readonly expander?: SlotComponent<{
9
+ expanded: boolean;
10
+ toggle: () => void;
11
+ }>;
12
+ readonly labelWrapClassName?: string;
13
+ readonly labelWrapStyle?: CSSProperties;
8
14
  }
9
15
  export declare const Branch: import("react").ForwardRefExoticComponent<Omit<ColumnManagerBranchProps & import("react").ClassAttributes<HTMLLIElement> & import("react").LiHTMLAttributes<HTMLLIElement>, "ref"> & import("react").RefAttributes<HTMLLIElement>>;
@@ -1,16 +1,31 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { forwardRef, useMemo } from "react";
2
+ import { forwardRef, useCallback, useMemo } from "react";
3
3
  import { TreeBranch } from "../tree-view/branch/branch";
4
4
  import { ColumnItemContext } from "./context";
5
5
  import { dragState, DropWrap } from "@1771technologies/lytenyte-dragon";
6
6
  import { useGrid } from "../grid-provider/use-grid";
7
7
  import { useColumnsFromContext } from "./use-columns-from-context";
8
- export const Branch = forwardRef(function Branch({ item, label, ...props }, forwarded) {
8
+ export const Branch = forwardRef(function Branch({ item, label, labelWrapClassName, labelWrapStyle, ...props }, forwarded) {
9
9
  const grid = useGrid();
10
10
  const id = grid.state.gridId.useValue();
11
11
  const accepted = `${id}/columns`;
12
+ const base = grid.state.columnBase.useValue();
12
13
  const columns = useColumnsFromContext(item);
13
- return (_jsx(ColumnItemContext, { value: useMemo(() => ({ item }), [item]), children: _jsx(TreeBranch, { ...props, itemId: item.branch.data.idOccurrence, ref: forwarded, ...item.attrs, labelWrap: _jsx(DropWrap, { "data-ln-column-manager-branch": true, "data-ln-column-id": item.branch.data.idOccurrence, accepted: [accepted], onEnter: (el) => {
14
+ const isVisible = useMemo(() => {
15
+ const allVisible = columns.every((c) => !(c.hide ?? base.hide));
16
+ return allVisible;
17
+ }, [base.hide, columns]);
18
+ const toggle = useCallback((s) => {
19
+ const next = s ?? isVisible;
20
+ grid.api.columnUpdate(Object.fromEntries(columns.map((c) => [c.id, { hide: next }])));
21
+ }, [columns, grid.api, isVisible]);
22
+ return (_jsx(ColumnItemContext, { value: useMemo(() => ({ item }), [item]), children: _jsx(TreeBranch, { ...props, itemId: item.data.idOccurrence, ref: forwarded, onKeyDown: (ev) => {
23
+ props.onKeyDown?.(ev);
24
+ if (ev.key === " ") {
25
+ toggle();
26
+ ev.preventDefault();
27
+ }
28
+ }, labelWrap: _jsx(DropWrap, { "data-ln-column-manager-branch": true, "data-ln-column-id": item.data.idOccurrence, accepted: [accepted], className: labelWrapClassName, style: labelWrapStyle, onEnter: (el) => {
14
29
  const data = dragState.data
15
30
  .get()
16
31
  ?.siteLocalData?.[accepted]?.at(-1);
@@ -25,7 +40,8 @@ export const Branch = forwardRef(function Branch({ item, label, ...props }, forw
25
40
  return;
26
41
  const thisIndex = allColumns.findIndex((c) => c.id === columns[0].id);
27
42
  const isBefore = thisIndex > moveIndex;
28
- if (isBefore) {
43
+ // Flipped since our source is the one moving
44
+ if (!isBefore) {
29
45
  el.setAttribute("data-ln-is-before", "true");
30
46
  }
31
47
  else {
@@ -1,15 +1,13 @@
1
- import { ForceSyncScrolling } from "../tree-view/virtualized/force-sync-scrolling";
2
1
  import { Root } from "./root";
3
2
  import { useColumnManager } from "./use-column-manager";
4
3
  import { VisibilityCheckbox } from "./visibility-checkbox";
5
4
  export declare const ColumnManager: {
6
5
  Root: typeof Root;
7
- Panel: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & import("react").RefAttributes<HTMLUListElement>>;
8
- PassiveScroll: typeof ForceSyncScrolling;
9
6
  Leaf: import("react").ForwardRefExoticComponent<Omit<import("./leaf").ColumnManagerLeafProps & import("react").ClassAttributes<HTMLLIElement> & import("react").LiHTMLAttributes<HTMLLIElement>, "ref"> & import("react").RefAttributes<HTMLLIElement>>;
10
- Branch: import("react").ForwardRefExoticComponent<Omit<import("./branch").ColumnManagerBranchProps & import("react").ClassAttributes<HTMLLIElement> & import("react").LiHTMLAttributes<HTMLLIElement>, "ref"> & import("react").RefAttributes<HTMLLIElement>>;
11
7
  Label: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & import("./label").LabelProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
12
- VisibilityCheckbox: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & VisibilityCheckbox, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
8
+ Branch: import("react").ForwardRefExoticComponent<Omit<import("./branch").ColumnManagerBranchProps & import("react").ClassAttributes<HTMLLIElement> & import("react").LiHTMLAttributes<HTMLLIElement>, "ref"> & import("react").RefAttributes<HTMLLIElement>>;
9
+ Panel: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & import("react").RefAttributes<HTMLUListElement>>;
13
10
  MoveHandle: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & import("./move-handle").MoveHandleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
11
+ VisibilityCheckbox: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & VisibilityCheckbox, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
14
12
  useColumnManager: typeof useColumnManager;
15
13
  };
@@ -1,20 +1,18 @@
1
- import { TreePanel } from "../tree-view/panel/panel";
2
- import { ForceSyncScrolling } from "../tree-view/virtualized/force-sync-scrolling";
3
1
  import { Branch } from "./branch";
4
2
  import { Label } from "./label";
5
3
  import { Leaf } from "./leaf";
6
4
  import { MoveHandle } from "./move-handle";
5
+ import { Panel } from "./panel";
7
6
  import { Root } from "./root";
8
7
  import { useColumnManager } from "./use-column-manager";
9
8
  import { VisibilityCheckbox } from "./visibility-checkbox";
10
9
  export const ColumnManager = {
11
- Root: Root,
12
- Panel: TreePanel,
13
- PassiveScroll: ForceSyncScrolling,
10
+ Root,
14
11
  Leaf,
15
- Branch,
16
12
  Label,
17
- VisibilityCheckbox,
13
+ Branch,
14
+ Panel,
18
15
  MoveHandle,
19
- useColumnManager,
16
+ VisibilityCheckbox,
17
+ useColumnManager: useColumnManager,
20
18
  };
@@ -1,7 +1,7 @@
1
- import type { TreeVirtualItem } from "../tree-view/virtualized/make-virtual-tree";
2
1
  import type { Column } from "../+types";
2
+ import type { PathBranch, PathLeaf } from "@1771technologies/lytenyte-shared";
3
3
  export interface TreeItemContextValue {
4
- readonly item: TreeVirtualItem<Column<any>>;
4
+ readonly item: PathBranch<Column<any>> | PathLeaf<Column<any>>;
5
5
  }
6
6
  export declare const ColumnItemContext: import("react").Context<TreeItemContextValue>;
7
7
  export declare const useColumnItemContext: () => TreeItemContextValue;
@@ -1,5 +1,5 @@
1
1
  import { type SlotComponent } from "@1771technologies/lytenyte-react-hooks";
2
2
  export interface LabelProps {
3
- readonly slot?: SlotComponent;
3
+ readonly as?: SlotComponent;
4
4
  }
5
5
  export declare const Label: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & LabelProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,18 +1,18 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useSlot } from "@1771technologies/lytenyte-react-hooks";
3
- import { useColumnItemContext } from "./context";
4
3
  import { forwardRef, useMemo } from "react";
5
- export const Label = forwardRef(function Label({ slot, ...props }, forwarded) {
4
+ import { useColumnItemContext } from "./context";
5
+ export const Label = forwardRef(function Label({ as, ...props }, forwarded) {
6
6
  const { item } = useColumnItemContext();
7
7
  const label = useMemo(() => {
8
8
  if (item.kind == "branch")
9
- return item.branch.id.split("#").at(-2);
10
- return item.leaf.data.name ?? item.leaf.data.id;
9
+ return item.id.split("#").at(-2);
10
+ return item.data.name ?? item.data.id;
11
11
  }, [item]);
12
12
  const rendered = useSlot({
13
13
  props: [{ children: label }, props],
14
14
  ref: forwarded,
15
- slot: slot ?? _jsx("div", {}),
15
+ slot: as ?? _jsx("div", {}),
16
16
  });
17
17
  return rendered;
18
18
  });
@@ -1,6 +1,6 @@
1
- import type { TreeVirtualLeaf } from "../tree-view/virtualized/make-virtual-tree";
2
1
  import type { Column } from "../+types";
2
+ import type { PathLeaf } from "@1771technologies/lytenyte-shared";
3
3
  export interface ColumnManagerLeafProps {
4
- readonly item: TreeVirtualLeaf<Column<any>>;
4
+ readonly item: PathLeaf<Column<any>>;
5
5
  }
6
6
  export declare const Leaf: import("react").ForwardRefExoticComponent<Omit<ColumnManagerLeafProps & import("react").ClassAttributes<HTMLLIElement> & import("react").LiHTMLAttributes<HTMLLIElement>, "ref"> & import("react").RefAttributes<HTMLLIElement>>;
@@ -1,9 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { forwardRef, useMemo } from "react";
2
+ import { forwardRef, useCallback, useMemo } from "react";
3
3
  import { ColumnItemContext } from "./context";
4
4
  import { TreeLeaf } from "../tree-view/leaf";
5
5
  import { dragState, DropWrap } from "@1771technologies/lytenyte-dragon";
6
6
  import { useGrid } from "../grid-provider/use-grid";
7
+ import { useColumnsFromContext } from "./use-columns-from-context";
7
8
  export const Leaf = forwardRef(function ColumnManagerLeaf({ item, ...props }, forwarded) {
8
9
  const context = useMemo(() => {
9
10
  return { item: item };
@@ -11,13 +12,23 @@ export const Leaf = forwardRef(function ColumnManagerLeaf({ item, ...props }, fo
11
12
  const grid = useGrid();
12
13
  const id = grid.state.gridId.useValue();
13
14
  const accepted = `${id}/columns`;
15
+ const base = grid.state.columnBase.useValue();
16
+ const columns = useColumnsFromContext(item);
17
+ const isVisible = useMemo(() => {
18
+ const allVisible = columns.every((c) => !(c.hide ?? base.hide));
19
+ return allVisible;
20
+ }, [base.hide, columns]);
21
+ const toggle = useCallback((s) => {
22
+ const next = s ?? isVisible;
23
+ grid.api.columnUpdate(Object.fromEntries(columns.map((c) => [c.id, { hide: next }])));
24
+ }, [columns, grid.api, isVisible]);
14
25
  return (_jsx(ColumnItemContext.Provider, { value: context, children: _jsx(DropWrap, { accepted: [accepted], onEnter: (el) => {
15
26
  const data = dragState.data
16
27
  .get()
17
28
  ?.siteLocalData?.[accepted]?.at(-1);
18
29
  if (!data)
19
30
  return;
20
- const columns = [item.leaf.data];
31
+ const columns = [item.data];
21
32
  const move = data.id;
22
33
  if (columns.some((c) => c.id === move))
23
34
  return;
@@ -27,7 +38,8 @@ export const Leaf = forwardRef(function ColumnManagerLeaf({ item, ...props }, fo
27
38
  return;
28
39
  const thisIndex = allColumns.findIndex((c) => c.id === columns[0].id);
29
40
  const isBefore = thisIndex > moveIndex;
30
- if (isBefore) {
41
+ // Flipped since our source is the one moving
42
+ if (!isBefore) {
31
43
  el.setAttribute("data-ln-is-before", "true");
32
44
  }
33
45
  else {
@@ -36,5 +48,11 @@ export const Leaf = forwardRef(function ColumnManagerLeaf({ item, ...props }, fo
36
48
  }, onLeave: (el) => {
37
49
  el.removeAttribute("data-ln-is-before");
38
50
  el.removeAttribute("data-ln-is-after");
39
- }, as: _jsx(TreeLeaf, { ...props, itemId: item.leaf.data.id, ref: forwarded, ...item.attrs, style: { ...props.style, ...item.attrs.style }, "data-ln-column-manager-leaf": true, "data-ln-column-id": item.leaf.data.id }) }) }));
51
+ }, as: _jsx(TreeLeaf, { ...props, itemId: item.data.id, ref: forwarded, onKeyDown: (ev) => {
52
+ props.onKeyDown?.(ev);
53
+ if (ev.key === " ") {
54
+ toggle();
55
+ ev.preventDefault();
56
+ }
57
+ }, "data-ln-column-manager-leaf": true, "data-ln-column-id": item.data.id }) }) }));
40
58
  });
@@ -1,12 +1,12 @@
1
1
  import { type SlotComponent } from "@1771technologies/lytenyte-react-hooks";
2
2
  import { type ReactNode } from "react";
3
3
  import type { Column } from "../+types";
4
- import type { TreeVirtualItem } from "../tree-view/virtualized/make-virtual-tree";
4
+ import type { PathBranch, PathLeaf } from "@1771technologies/lytenyte-shared";
5
5
  export interface MoveHandleProps {
6
- readonly slot?: SlotComponent;
6
+ readonly as?: SlotComponent;
7
7
  readonly placeholder?: (p: {
8
8
  columns: Column<any>[];
9
- item: TreeVirtualItem<Column<any>>;
9
+ item: PathBranch<Column<any>> | PathLeaf<Column<any>>;
10
10
  }) => ReactNode;
11
11
  }
12
12
  export declare const MoveHandle: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & MoveHandleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -5,7 +5,7 @@ import { forwardRef, useMemo } from "react";
5
5
  import { useColumnItemContext } from "./context";
6
6
  import { useColumnsFromContext } from "./use-columns-from-context";
7
7
  import { useGrid } from "../grid-provider/use-grid";
8
- export const MoveHandle = forwardRef(function MoveHandle({ slot, placeholder: Placeholder, ...props }, forwarded) {
8
+ export const MoveHandle = forwardRef(function MoveHandle({ as, placeholder: Placeholder, ...props }, forwarded) {
9
9
  const item = useColumnItemContext().item;
10
10
  const grid = useGrid();
11
11
  const columns = useColumnsFromContext(item);
@@ -42,9 +42,7 @@ export const MoveHandle = forwardRef(function MoveHandle({ slot, placeholder: Pl
42
42
  placeholder: () => {
43
43
  if (Placeholder)
44
44
  return _jsx(Placeholder, { columns: columns, item: item });
45
- return (_jsx("div", { children: item.kind === "branch"
46
- ? item.branch.data.joinPath.at(-1)
47
- : (item.leaf.data.name ?? item.leaf.data.id) }));
45
+ return (_jsx("div", { children: item.kind === "branch" ? item.data.joinPath.at(-1) : (item.data.name ?? item.data.id) }));
48
46
  },
49
47
  });
50
48
  const combined = useCombinedRefs(ref, forwarded);
@@ -52,7 +50,7 @@ export const MoveHandle = forwardRef(function MoveHandle({ slot, placeholder: Pl
52
50
  const renderer = useSlot({
53
51
  props: [{ "aria-label": "Drag to move column" }, additionalProps, props],
54
52
  ref: isMovable ? combined : forwarded,
55
- slot: slot ?? _jsx("div", {}),
53
+ slot: as ?? _jsx("div", {}),
56
54
  });
57
55
  return renderer;
58
56
  });
@@ -0,0 +1 @@
1
+ export declare const Panel: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & import("react").RefAttributes<HTMLUListElement>>;
@@ -0,0 +1,2 @@
1
+ import { TreePanel } from "../tree-view/panel/panel";
2
+ export const Panel = TreePanel;