@1771technologies/lytenyte-pro 1.0.0-beta.15 → 1.0.0-beta.17

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.
@@ -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])))
@@ -4,7 +4,7 @@ import { Item } from "../listbox/item";
4
4
  import { dragState, DropWrap, useDraggable } from "@1771technologies/lytenyte-dragon";
5
5
  import { useCombinedRefs, useSlot, } from "@1771technologies/lytenyte-react-hooks";
6
6
  import { useGridBoxContext } from "./context";
7
- export const BoxItem = forwardRef(function BoxItem({ item, itemAs, itemClassName, itemStyle, ...props }, forwarded) {
7
+ export const BoxItem = forwardRef(function BoxItem({ item, itemAs, itemClassName, itemStyle, children, ...props }, forwarded) {
8
8
  const { accepted } = useGridBoxContext();
9
9
  const { dragProps } = useDraggable({
10
10
  getItems: () => {
@@ -26,7 +26,7 @@ export const BoxItem = forwardRef(function BoxItem({ item, itemAs, itemClassName
26
26
  }
27
27
  if (ev.key === "Backspace" || ev.key === "Delete")
28
28
  item.onDelete?.(ev.currentTarget);
29
- }, onClick: (ev) => item.onAction(ev.currentTarget), className: itemClassName, style: itemStyle, "data-ln-source": item.source })),
29
+ }, onClick: (ev) => item.onAction(ev.currentTarget), className: itemClassName, style: itemStyle, "data-ln-source": item.source, "data-ln-index": item.index, children: children })),
30
30
  },
31
31
  ],
32
32
  slot: itemAs ?? _jsx("div", {}),
@@ -41,11 +41,11 @@ export const BoxItem = forwardRef(function BoxItem({ item, itemAs, itemClassName
41
41
  e.setAttribute("data-ln-is-after", "true");
42
42
  return;
43
43
  }
44
- const thisIndex = Number.parseInt(e.getAttribute("data-ln-index"));
45
- const dragIndex = Number.parseInt(e.getAttribute("data-ln-index"));
46
- if (Number.isNaN(dragIndex) || Number.isNaN(thisIndex))
44
+ const overIndex = Number.parseInt(e.getAttribute("data-ln-index"));
45
+ const dragIndex = Number.parseInt(data.getAttribute("data-ln-index"));
46
+ if (Number.isNaN(dragIndex) || Number.isNaN(overIndex) || overIndex === dragIndex)
47
47
  return;
48
- if (thisIndex < dragIndex) {
48
+ if (overIndex < dragIndex) {
49
49
  e.setAttribute("data-ln-is-before", "true");
50
50
  }
51
51
  else {
@@ -54,5 +54,10 @@ export const BoxItem = forwardRef(function BoxItem({ item, itemAs, itemClassName
54
54
  }, onLeave: (el) => {
55
55
  el.removeAttribute("data-ln-is-before");
56
56
  el.removeAttribute("data-ln-is-after");
57
- }, "data-ln-source": item.source, "data-ln-index": item.index, accepted: accepted, onDrop: item.onDrop, as: renderer }));
57
+ }, "data-ln-source": item.source, "data-ln-index": item.index, accepted: accepted, onDrop: (e) => {
58
+ const el = e.dropElement;
59
+ el.removeAttribute("data-ln-is-before");
60
+ el.removeAttribute("data-ln-is-after");
61
+ item.onDrop(e);
62
+ }, as: renderer }));
58
63
  });
@@ -37,16 +37,13 @@ export function useColumnBoxItems({ grid, onRootDrop, onDrop, onDelete, onAction
37
37
  onAction: (el) => onAction?.({ column: c, el }),
38
38
  onDelete: (el) => onDelete?.({ column: c, el }),
39
39
  onDrop: (p) => {
40
- const target = c;
41
40
  const src = p.state.siteLocalData?.[columnId];
42
- const isRtl = grid.state.rtl.get();
43
- let isBefore;
44
- if (orientation === "horizontal") {
45
- isBefore = isRtl ? !p.moveState.leftHalf : p.moveState.leftHalf;
46
- }
47
- else {
48
- isBefore = p.moveState.topHalf;
49
- }
41
+ const target = c;
42
+ const dragIndex = columns.findIndex((x) => x.id === src.id);
43
+ const overIndex = columns.findIndex((x) => x.id === c.id);
44
+ const isBefore = overIndex < dragIndex;
45
+ if (overIndex === dragIndex)
46
+ return;
50
47
  onDrop?.({ src, target, isBefore });
51
48
  },
52
49
  };
@@ -58,13 +55,11 @@ export function useColumnBoxItems({ grid, onRootDrop, onDrop, onDelete, onAction
58
55
  columns,
59
56
  dragPlaceholder,
60
57
  draggable,
61
- grid.state.rtl,
62
58
  gridId,
63
59
  itemFilter,
64
60
  onAction,
65
61
  onDelete,
66
62
  onDrop,
67
- orientation,
68
63
  ]);
69
64
  const onRootDropEv = useEvent((p) => {
70
65
  const columnId = `${gridId}-column`;
@@ -13,14 +13,11 @@ export function useRowGroupBoxItems({ grid, orientation, dragPlaceholder, hideCo
13
13
  const onDrop = (p) => {
14
14
  const target = c;
15
15
  const src = p.state.siteLocalData?.[groupId];
16
- const isRtl = grid.state.rtl.get();
17
- let isBefore;
18
- if (orientation === "horizontal") {
19
- isBefore = isRtl ? !p.moveState.leftHalf : p.moveState.leftHalf;
20
- }
21
- else {
22
- isBefore = p.moveState.topHalf;
23
- }
16
+ const overIndex = rowGroupModel.findIndex((x) => x === c);
17
+ const dragIndex = rowGroupModel.findIndex((x) => x === src);
18
+ const isBefore = overIndex < dragIndex;
19
+ if (overIndex === dragIndex)
20
+ return;
24
21
  const srcIndex = rowGroupModel.findIndex((x) => {
25
22
  if (typeof src !== typeof x)
26
23
  return;
@@ -88,10 +85,8 @@ export function useRowGroupBoxItems({ grid, orientation, dragPlaceholder, hideCo
88
85
  }, [
89
86
  grid.api,
90
87
  grid.state.rowGroupModel,
91
- grid.state.rtl,
92
88
  gridId,
93
89
  hideColumnOnGroup,
94
- orientation,
95
90
  dragPlaceholder,
96
91
  rowGroupModel,
97
92
  ]);
@@ -1,4 +1,4 @@
1
- import { getHoveredColumnIndex, getNearestFocusable, useDraggable, } from "@1771technologies/lytenyte-shared";
1
+ import { COLUMN_MARKER_ID, getHoveredColumnIndex, getNearestFocusable, useDraggable, } from "@1771technologies/lytenyte-shared";
2
2
  import { useMemo, useRef } from "react";
3
3
  export function useDragMove(grid, cell, onDragStart) {
4
4
  const ctx = grid.state;
@@ -53,6 +53,8 @@ export function useDragMove(grid, cell, onDragStart) {
53
53
  });
54
54
  if (index == null)
55
55
  return;
56
+ if (grid.api.columnFromIndex(index)?.id === COLUMN_MARKER_ID)
57
+ return;
56
58
  const first = columns[0];
57
59
  const currentIndex = grid.api.columnIndex(first);
58
60
  const columnIndices = columns.map((c) => grid.api.columnIndex(c));
@@ -6,7 +6,7 @@ export const makeColumnAutosize = (grid) => {
6
6
  const meta = grid.state.columnMeta.get();
7
7
  const columns = params.columns
8
8
  ?.map((c) => resolveColumn(c, errorRef, meta))
9
- .map((c) => c && grid.api.columnById(c))
9
+ .map((c) => c && (typeof c === "string" ? grid.api.columnById(c) : c))
10
10
  .filter(Boolean) ?? grid.state.columnMeta.get().columnsVisible;
11
11
  if (errorRef.current) {
12
12
  console.error("Invalid column autosize column params");
@@ -62,11 +62,12 @@ export function columnAddRowGroup({ columns, rowGroupModel, rowGroupDisplayMode,
62
62
  }
63
63
  if (!hasGroupColumn)
64
64
  columns = columns.filter((c) => !c.id.startsWith(GROUP_COLUMN_PREFIX));
65
+ // TODO: this can be improved - what if the columns are really large?
65
66
  const keys = Object.keys(rowGroupColumnState);
66
67
  for (let i = 0; i < keys.length; i++) {
67
- if (!lookup.has(keys[i]))
68
+ const column = columns.find((c) => c.id === keys[i]);
69
+ if (!column)
68
70
  continue;
69
- const column = lookup.get(keys[i]);
70
71
  Object.assign(column, rowGroupColumnState[keys[i]]);
71
72
  }
72
73
  return columns;
@@ -1,4 +1,4 @@
1
1
  import type { Column, ColumnMeta } from "../../+types";
2
2
  export declare function resolveColumn(c: string | number | Column<any>, errorRef: {
3
3
  current: boolean;
4
- }, meta: ColumnMeta<any>): string | undefined;
4
+ }, meta: ColumnMeta<any>): string | Column<any> | undefined;
@@ -1,5 +1,9 @@
1
+ import { GROUP_COLUMN_PREFIX } from "@1771technologies/lytenyte-shared";
1
2
  export function resolveColumn(c, errorRef, meta) {
2
3
  if (typeof c === "string") {
4
+ if (c.startsWith(GROUP_COLUMN_PREFIX)) {
5
+ return meta.columnsVisible.find((x) => x.id === c);
6
+ }
3
7
  if (!meta.columnLookup.has(c)) {
4
8
  errorRef.current = true;
5
9
  console.error(`Invalid column ${c}`);
@@ -14,6 +18,9 @@ export function resolveColumn(c, errorRef, meta) {
14
18
  }
15
19
  return col?.id;
16
20
  }
21
+ if (c.id.startsWith(GROUP_COLUMN_PREFIX)) {
22
+ return meta.columnsVisible.find((x) => x.id === c.id);
23
+ }
17
24
  if (!meta.columnLookup.has(c.id)) {
18
25
  errorRef.current = true;
19
26
  console.error(`Invalid column ${c.id}`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@1771technologies/lytenyte-pro",
3
3
  "description": "Blazingly fast headless React data grid with 100s of features.",
4
- "version": "1.0.0-beta.15",
4
+ "version": "1.0.0-beta.17",
5
5
  "type": "module",
6
6
  "license": "COMMERCIAL",
7
7
  "files": [
@@ -49,12 +49,12 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@1771technologies/atom": "^1.0.2",
52
- "@1771technologies/lytenyte-core": "1.0.0-beta.15",
53
- "@1771technologies/lytenyte-dragon": "1.0.0-beta.15",
54
- "@1771technologies/lytenyte-dom-utils": "1.0.0-beta.15",
55
- "@1771technologies/lytenyte-js-utils": "1.0.0-beta.15",
56
- "@1771technologies/lytenyte-shared": "1.0.0-beta.15",
57
- "@1771technologies/lytenyte-react-hooks": "1.0.0-beta.15"
52
+ "@1771technologies/lytenyte-core": "1.0.0-beta.17",
53
+ "@1771technologies/lytenyte-dragon": "1.0.0-beta.17",
54
+ "@1771technologies/lytenyte-shared": "1.0.0-beta.17",
55
+ "@1771technologies/lytenyte-dom-utils": "1.0.0-beta.17",
56
+ "@1771technologies/lytenyte-js-utils": "1.0.0-beta.17",
57
+ "@1771technologies/lytenyte-react-hooks": "1.0.0-beta.17"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "react": "^18.0.0 || ^19.0.0",