@1771technologies/lytenyte-pro 0.0.39

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 (168) hide show
  1. package/LICENSE +15 -0
  2. package/dist/DialogPortalContext-C2WZTqJ3.js +47 -0
  3. package/dist/InternalBackdrop-Dm9czgoC.js +6746 -0
  4. package/dist/MenuRoot-9n64jNWP.js +724 -0
  5. package/dist/anchor-context-B9sGQdR5.js +35 -0
  6. package/dist/arrow-down-icon-B-3ldODD.js +27 -0
  7. package/dist/arrow-svg-evmXDI_J.js +29 -0
  8. package/dist/column-manager.js +1241 -0
  9. package/dist/cross-icon-CEMLAlFX.js +20 -0
  10. package/dist/dialog.js +506 -0
  11. package/dist/filter-manager.js +1056 -0
  12. package/dist/getPseudoElementBounds-BSHt6WYm.js +26 -0
  13. package/dist/grid-container.js +18 -0
  14. package/dist/icons.js +512 -0
  15. package/dist/index.js +3730 -0
  16. package/dist/lytenyte-pro.css +1948 -0
  17. package/dist/manage-columns-icon-D4CElo5H.js +146 -0
  18. package/dist/menu.js +1639 -0
  19. package/dist/pill-C4Jhdf8E.js +985 -0
  20. package/dist/pill-manager.js +674 -0
  21. package/dist/plus-icon-ToqW5CC-.js +15 -0
  22. package/dist/popover.js +770 -0
  23. package/dist/row-group-icon-BOOju5Vu.js +205 -0
  24. package/dist/search-icon-CcG1lqsn.js +86 -0
  25. package/dist/select-C6xOZZLq.js +2231 -0
  26. package/dist/sort-manager.js +298 -0
  27. package/dist/tickmark-icon-CoogRMoO.js +51 -0
  28. package/dist/types/cell-selection/cell-selection-containers.d.ts +3 -0
  29. package/dist/types/cell-selection/cell-selection-driver.d.ts +1 -0
  30. package/dist/types/cell-selection/cell-style-row.d.ts +8 -0
  31. package/dist/types/column-manager/column-manager-drag-box-controls.d.ts +1 -0
  32. package/dist/types/column-manager/column-manager-drag-box-expander.d.ts +1 -0
  33. package/dist/types/column-manager/column-manager-drag-box-label.d.ts +5 -0
  34. package/dist/types/column-manager/column-manager-drag-box.d.ts +13 -0
  35. package/dist/types/column-manager/column-manager-drag-placeholder.d.ts +5 -0
  36. package/dist/types/column-manager/column-manager-drop-zone.d.ts +10 -0
  37. package/dist/types/column-manager/column-manager-impl.d.ts +36 -0
  38. package/dist/types/column-manager/column-manager-pill.d.ts +4 -0
  39. package/dist/types/column-manager/column-manager-pivot-mode-toggle.d.ts +1 -0
  40. package/dist/types/column-manager/column-manager-search.d.ts +1 -0
  41. package/dist/types/column-manager/column-manager-state.d.ts +8 -0
  42. package/dist/types/column-manager/column-manager-tree-item.d.ts +6 -0
  43. package/dist/types/column-manager/column-manager-tree.d.ts +11 -0
  44. package/dist/types/column-manager/column-manager-types.d.ts +1 -0
  45. package/dist/types/column-manager/column-manager.d.ts +1 -0
  46. package/dist/types/column-manager/column-mananger-context.d.ts +12 -0
  47. package/dist/types/column-manager/utils/all-leafs.d.ts +3 -0
  48. package/dist/types/column-manager/utils/can-hide-item.d.ts +3 -0
  49. package/dist/types/column-manager/utils/handle-item-hide.d.ts +3 -0
  50. package/dist/types/components-internal/button/button.d.ts +9 -0
  51. package/dist/types/components-internal/grid-frame/grid-frame.d.ts +11 -0
  52. package/dist/types/components-internal/radio/radio.d.ts +5 -0
  53. package/dist/types/components-internal/separator/separator.d.ts +8 -0
  54. package/dist/types/components-internal/toggle/toggle.d.ts +7 -0
  55. package/dist/types/dialog/dialog-driver.d.ts +1 -0
  56. package/dist/types/dialog/dialog-impl.d.ts +6 -0
  57. package/dist/types/dialog/dialog.d.ts +8 -0
  58. package/dist/types/dialog/use-dialog-class.d.ts +1 -0
  59. package/dist/types/external.d.ts +2 -0
  60. package/dist/types/filter-manager/combined-to-flat.d.ts +3 -0
  61. package/dist/types/filter-manager/components/apply-filter-button.d.ts +1 -0
  62. package/dist/types/filter-manager/components/clear-filter-button.d.ts +1 -0
  63. package/dist/types/filter-manager/components/flatten-tree-items.d.ts +4 -0
  64. package/dist/types/filter-manager/components/get-child-values.d.ts +2 -0
  65. package/dist/types/filter-manager/components/in-filter-container.d.ts +1 -0
  66. package/dist/types/filter-manager/components/in-filter-error.d.ts +5 -0
  67. package/dist/types/filter-manager/components/in-filter-loading.d.ts +1 -0
  68. package/dist/types/filter-manager/components/in-filter-root.d.ts +11 -0
  69. package/dist/types/filter-manager/components/in-filter-tree.d.ts +15 -0
  70. package/dist/types/filter-manager/components/simple-filter-additional-switch.d.ts +1 -0
  71. package/dist/types/filter-manager/components/simple-filter-operator/date-operator.d.ts +1 -0
  72. package/dist/types/filter-manager/components/simple-filter-operator/number-operator.d.ts +1 -0
  73. package/dist/types/filter-manager/components/simple-filter-operator/simple-filter-operator.d.ts +1 -0
  74. package/dist/types/filter-manager/components/simple-filter-operator/text-operator.d.ts +1 -0
  75. package/dist/types/filter-manager/components/simple-filter-root.d.ts +9 -0
  76. package/dist/types/filter-manager/components/simple-filter-value/date-value.d.ts +1 -0
  77. package/dist/types/filter-manager/components/simple-filter-value/number-value.d.ts +1 -0
  78. package/dist/types/filter-manager/components/simple-filter-value/simple-filter-value.d.ts +1 -0
  79. package/dist/types/filter-manager/components/simple-filter-value/text-value.d.ts +1 -0
  80. package/dist/types/filter-manager/components/use-date-filter-callbacks.d.ts +9 -0
  81. package/dist/types/filter-manager/components/use-in-filter-item-loader.d.ts +7 -0
  82. package/dist/types/filter-manager/components/use-number-filter-callbacks.d.ts +8 -0
  83. package/dist/types/filter-manager/components/use-text-filter-callbacks.d.ts +8 -0
  84. package/dist/types/filter-manager/filter-manager-impl.d.ts +27 -0
  85. package/dist/types/filter-manager/filter-manager.d.ts +1 -0
  86. package/dist/types/filter-manager/filter-state-context.d.ts +16 -0
  87. package/dist/types/filter-manager/flat-to-combined.d.ts +3 -0
  88. package/dist/types/filter-manager/flatten-combined-filter.d.ts +3 -0
  89. package/dist/types/filter-manager/is-filter-complete.d.ts +2 -0
  90. package/dist/types/filter-manager/types.d.ts +15 -0
  91. package/dist/types/filter-manager/use-in-filter.d.ts +5 -0
  92. package/dist/types/filter-manager/use-simple-filters.d.ts +8 -0
  93. package/dist/types/grid-container/grid-container-impl.d.ts +6 -0
  94. package/dist/types/grid-container/grid-container.d.ts +2 -0
  95. package/dist/types/icons.d.ts +1 -0
  96. package/dist/types/index.d.ts +7 -0
  97. package/dist/types/license.d.ts +12 -0
  98. package/dist/types/list-view/list-view-context.d.ts +21 -0
  99. package/dist/types/list-view/list-view.d.ts +26 -0
  100. package/dist/types/lytenyte-pro.d.ts +7 -0
  101. package/dist/types/menu/arrow-svg.d.ts +1 -0
  102. package/dist/types/menu/column-menu/column-menu-driver.d.ts +4 -0
  103. package/dist/types/menu/context-menu/context-menu-driver.d.ts +1 -0
  104. package/dist/types/menu/context-menu/use-context-menu-listener.d.ts +6 -0
  105. package/dist/types/menu/menu-impl.d.ts +17 -0
  106. package/dist/types/menu/menu.d.ts +18 -0
  107. package/dist/types/menu/use-menu-class-name.d.ts +1 -0
  108. package/dist/types/overlay/load-error-overlay.d.ts +1 -0
  109. package/dist/types/overlay/loading-overlay.d.ts +1 -0
  110. package/dist/types/overlay/no-data-overlay.d.ts +1 -0
  111. package/dist/types/overlay/overlay-driver.d.ts +1 -0
  112. package/dist/types/pill/pill.d.ts +5 -0
  113. package/dist/types/pill-manager/pill-manager-agg-menu.d.ts +7 -0
  114. package/dist/types/pill-manager/pill-manager-controls.d.ts +9 -0
  115. package/dist/types/pill-manager/pill-manager-drag-placeholder.d.ts +5 -0
  116. package/dist/types/pill-manager/pill-manager-expander.d.ts +1 -0
  117. package/dist/types/pill-manager/pill-manager-impl.d.ts +49 -0
  118. package/dist/types/pill-manager/pill-manager-pill.d.ts +4 -0
  119. package/dist/types/pill-manager/pill-manager-pills/pill-manager-pills.d.ts +2 -0
  120. package/dist/types/pill-manager/pill-manager-pills/use-aggregation-source.d.ts +2 -0
  121. package/dist/types/pill-manager/pill-manager-pills/use-column-pivot-source.d.ts +2 -0
  122. package/dist/types/pill-manager/pill-manager-pills/use-column-source.d.ts +2 -0
  123. package/dist/types/pill-manager/pill-manager-pills/use-measures-source.d.ts +2 -0
  124. package/dist/types/pill-manager/pill-manager-pills/use-row-groups-source.d.ts +2 -0
  125. package/dist/types/pill-manager/pill-manager-pills/utils.d.ts +3 -0
  126. package/dist/types/pill-manager/pill-manager-row-label.d.ts +22 -0
  127. package/dist/types/pill-manager/pill-manager-row.d.ts +12 -0
  128. package/dist/types/pill-manager/pill-manager-rows.d.ts +1 -0
  129. package/dist/types/pill-manager/pill-manager-separator.d.ts +1 -0
  130. package/dist/types/pill-manager/pill-manager-types.d.ts +36 -0
  131. package/dist/types/pill-manager/pill-manager.d.ts +1 -0
  132. package/dist/types/popover/anchor-context.d.ts +6 -0
  133. package/dist/types/popover/popover-driver.d.ts +1 -0
  134. package/dist/types/popover/popover-impl.d.ts +8 -0
  135. package/dist/types/popover/popover.d.ts +10 -0
  136. package/dist/types/popover/use-popover-class.d.ts +1 -0
  137. package/dist/types/select/select.d.ts +17 -0
  138. package/dist/types/sort-manager/sort-adder.d.ts +4 -0
  139. package/dist/types/sort-manager/sort-apply.d.ts +1 -0
  140. package/dist/types/sort-manager/sort-cancel.d.ts +1 -0
  141. package/dist/types/sort-manager/sort-clear.d.ts +1 -0
  142. package/dist/types/sort-manager/sort-column-select.d.ts +5 -0
  143. package/dist/types/sort-manager/sort-direction-select.d.ts +5 -0
  144. package/dist/types/sort-manager/sort-items-to-sort-model.d.ts +3 -0
  145. package/dist/types/sort-manager/sort-manager-container.d.ts +53 -0
  146. package/dist/types/sort-manager/sort-manager-context.d.ts +4 -0
  147. package/dist/types/sort-manager/sort-manager-impl.d.ts +30 -0
  148. package/dist/types/sort-manager/sort-manager.d.ts +1 -0
  149. package/dist/types/sort-manager/sort-model-to-sort-items.d.ts +4 -0
  150. package/dist/types/sort-manager/sort-remove.d.ts +4 -0
  151. package/dist/types/sort-manager/sort-sort-select.d.ts +5 -0
  152. package/dist/types/sort-manager/use-sort-state.d.ts +8 -0
  153. package/dist/types/sort-manager/use-sortable-column-items.d.ts +9 -0
  154. package/dist/types/types.d.ts +1 -0
  155. package/dist/types/use-client-data-source.d.ts +6 -0
  156. package/dist/types/use-edge-scroll.d.ts +7 -0
  157. package/dist/types/use-grid.d.ts +6 -0
  158. package/dist/types/use-lytenyte.d.ts +10 -0
  159. package/dist/types/use-tree-data-source.d.ts +3 -0
  160. package/dist/types/watermark.d.ts +3 -0
  161. package/dist/types.js +1 -0
  162. package/dist/use-grid-DKvzGZWc.js +916 -0
  163. package/dist/useAnchorPositioning-Cm44rb7y.js +252 -0
  164. package/dist/useBaseUiId-J66PFGv_.js +48 -0
  165. package/dist/useButton-Cy7tjZ__.js +183 -0
  166. package/dist/useCompositeListItem-I14CpQPi.js +51 -0
  167. package/dist/useScrollLock-D6h5lZYs.js +515 -0
  168. package/package.json +96 -0
package/dist/index.js ADDED
@@ -0,0 +1,3730 @@
1
+ import { C as Checkbox, e as COLUMN_MARKER_ID, H as HEADER_CELL_POSITION, g as getTransform, f as COLUMN_EMPTY_PREFIX, h as HEADER_GROUP_CELL_POSITION, i as CollapseButton, F as FLOATING_CELL_POSITION, j as FULL_ENCODING, k as CellFullWidth, E as END_ENCODING, l as Cell, I as Input, u as useGrid$1, m as GRID_CELL_POSITION, n as GridButton, G as GridProvider } from "./use-grid-DKvzGZWc.js";
2
+ import { y, q, z, A, L, M, O, N, Q, v, t, w, x, P, r, J, o, B, R, s, p, K } from "./use-grid-DKvzGZWc.js";
3
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
4
+ import { Sizer } from "@1771technologies/react-sizer";
5
+ import { useEvent, useIsoEffect } from "@1771technologies/react-utils";
6
+ import { context } from "@1771technologies/grid-provider";
7
+ import * as React from "react";
8
+ import { useContext, useMemo, useEffect, useRef, useState, useCallback, memo } from "react";
9
+ import { sizeFromCoord, clsx, getClientX, IsoResizeObserver, getPreciseElementDimensions, getClientY, getFocusableElements, clamp, getRelativeXPosition, getRelativeYPosition } from "@1771technologies/js-utils";
10
+ import { useDraggable, useDroppable, dragState } from "@1771technologies/react-dragon";
11
+ import { getHoveredRowIndex, getHoveredColumnIndex, getRootCell } from "@1771technologies/grid-core";
12
+ import * as ReactDOM from "react-dom";
13
+ import { createPortal } from "react-dom";
14
+ import { cascada, signal } from "@1771technologies/react-cascada";
15
+ import { M as MenuRoot, a as MenuPortal, b as MenuPositioner, t as translateOpenChangeReason, P as PATIENT_CLICK_THRESHOLD } from "./MenuRoot-9n64jNWP.js";
16
+ import { SplitPane, splitPaneAxe } from "@1771technologies/react-split-pane";
17
+ import { F as FloatingPortal, P as PropTypes, H as HTMLElementType, r as refType, j as useEventCallback, y as useOpenChangeComplete, z as useFloatingRootContext, E as useRole, C as useClick, D as useDismiss, S as getTarget, K as useInteractions, m as mergeProps, A as useHover, B as safePolygon } from "./InternalBackdrop-Dm9czgoC.js";
18
+ import { u as useDialogRootContext, D as DialogPortalContext, b as useOptionalDialogRootContext, c as DialogContext, d as DialogRootContext } from "./DialogPortalContext-C2WZTqJ3.js";
19
+ import { a as useControlled, b as useTransitionStatus, c as useScrollLock } from "./useScrollLock-D6h5lZYs.js";
20
+ import { P as PopoverRootContext, u as usePopoverRootContext, c as PopoverPortalContext, A as AnchorProvider } from "./anchor-context-B9sGQdR5.js";
21
+ import { makeGridPro } from "@1771technologies/grid-store-pro";
22
+ import { createClientDataSource } from "@1771technologies/grid-client-data-source-pro";
23
+ import { createTreeDataSource } from "@1771technologies/grid-tree-data-source";
24
+ function useGrid() {
25
+ return useContext(context);
26
+ }
27
+ function useHeaderDisplayGridTemplate(levelsCount, headerHeight, groupHeaderHeight, floatingRowEnabled, floatingRowHeight) {
28
+ const gridTemplateRows = useMemo(() => {
29
+ const groupHeight = typeof groupHeaderHeight === "number" ? `${groupHeaderHeight}px` : "auto";
30
+ const height = typeof headerHeight === "number" ? `${headerHeight}px` : "auto";
31
+ const template = Array.from({ length: levelsCount }, () => groupHeight);
32
+ template.push(height);
33
+ if (floatingRowEnabled) {
34
+ const floatingHeight = typeof floatingRowHeight === "number" ? `${floatingRowHeight}px` : "auto";
35
+ template.push(floatingHeight);
36
+ }
37
+ return template.join(" ");
38
+ }, [floatingRowEnabled, floatingRowHeight, groupHeaderHeight, headerHeight, levelsCount]);
39
+ return gridTemplateRows;
40
+ }
41
+ function HeaderCellDefault({ column }) {
42
+ const label = column.headerName ?? column.id;
43
+ return /* @__PURE__ */ jsx(
44
+ "div",
45
+ {
46
+ style: {
47
+ display: "flex",
48
+ alignItems: "center",
49
+ boxSizing: "border-box",
50
+ width: "100%",
51
+ height: "100%",
52
+ paddingInline: 12
53
+ },
54
+ children: label
55
+ }
56
+ );
57
+ }
58
+ function HeaderCellMarker({ api }) {
59
+ const supportsSelectedAll = api.rowSelectionSelectAllSupported();
60
+ const allSelected = api.rowSelectionAllRowsSelected();
61
+ const selected = api.getState().rowSelectionSelectedIds.use();
62
+ const someSelected = useMemo(() => {
63
+ for (const c of selected) {
64
+ if (api.rowById(c)) return true;
65
+ }
66
+ return false;
67
+ }, [api, selected]);
68
+ if (!supportsSelectedAll) return null;
69
+ return /* @__PURE__ */ jsx(
70
+ "div",
71
+ {
72
+ style: {
73
+ display: "flex",
74
+ alignItems: "center",
75
+ justifyContent: "center",
76
+ width: "100%",
77
+ height: "100%"
78
+ },
79
+ children: /* @__PURE__ */ jsx(
80
+ Checkbox,
81
+ {
82
+ tabIndex: -1,
83
+ isChecked: allSelected || someSelected,
84
+ isDeterminate: !allSelected && someSelected,
85
+ onClick: () => {
86
+ if (allSelected) api.rowSelectionClear();
87
+ else api.rowSelectionSelectAll();
88
+ }
89
+ }
90
+ )
91
+ }
92
+ );
93
+ }
94
+ function useHeaderCellRenderer(api, column) {
95
+ const sx = api.getState();
96
+ const renderers = sx.columnHeaderRenderers.use();
97
+ const base = sx.columnBase.use();
98
+ const Renderer = useMemo(() => {
99
+ if (column.id === COLUMN_MARKER_ID) return HeaderCellMarker;
100
+ const fn = column.headerRenderer ?? base.headerRenderer;
101
+ if (!fn) return HeaderCellDefault;
102
+ if (typeof fn === "string") {
103
+ const cell = renderers[fn];
104
+ if (!cell) throw new Error(`Header cell renderer with name ${fn} does not exist.`);
105
+ return cell;
106
+ }
107
+ return fn;
108
+ }, [base.headerRenderer, column.headerRenderer, column.id, renderers]);
109
+ return Renderer;
110
+ }
111
+ function useHeaderMove(api, column, columnIndex) {
112
+ const gridId = api.getState().gridId.use();
113
+ const dragProps = useDraggable({
114
+ dragData: () => ({ columns: [column], columnIndex }),
115
+ dragTags: () => [`${gridId}:grid:${column.pin ?? "none"}`],
116
+ placeholder: () => /* @__PURE__ */ jsx(DragPlaceholder$1, { column })
117
+ });
118
+ const { canDrop, isOver, ...dropProps } = useDroppable({
119
+ tags: [`${gridId}:grid:${column.pin ?? "none"}`],
120
+ onDrop: (p2) => {
121
+ const data2 = p2.getData();
122
+ const dragIndex2 = data2.columnIndex;
123
+ const isBefore2 = columnIndex < dragIndex2;
124
+ const src = data2.columns.map((c) => c.id);
125
+ const target = column.id;
126
+ if (src.includes(target)) return;
127
+ if (isBefore2) api.columnMoveBefore(src, target);
128
+ else api.columnMoveAfter(src, target);
129
+ }
130
+ });
131
+ const dragData = dragState.dragData.use();
132
+ const data = dragData?.();
133
+ const dragIndex = data?.columnIndex ?? -1;
134
+ const isBefore = columnIndex < dragIndex;
135
+ const moveProps = api.columnIsMovable(column) ? dragProps : {};
136
+ return { moveProps, dropProps, isBefore, canDrop, isOver, dragIndex };
137
+ }
138
+ function DragPlaceholder$1(c) {
139
+ return /* @__PURE__ */ jsx("div", { className: "lng1771-drag-placeholder", children: c.column.headerName ?? c.column.id });
140
+ }
141
+ function useHeaderFocus(api, ref, columnIndex) {
142
+ useEffect(() => {
143
+ const sx = api.getState();
144
+ const unsub = sx.internal.navigatePosition.watch(() => {
145
+ const position = sx.internal.navigatePosition.peek();
146
+ if (!ref.current || !position || position.kind !== HEADER_CELL_POSITION) return;
147
+ if (position.columnIndex === columnIndex && !ref.current.contains(document.activeElement)) {
148
+ api.navigateScrollIntoView(null, columnIndex);
149
+ ref.current.focus();
150
+ }
151
+ });
152
+ return () => unsub();
153
+ }, [api, columnIndex, ref]);
154
+ const onFocus = useEvent(() => {
155
+ api.getState().internal.navigatePosition.set({ kind: HEADER_CELL_POSITION, columnIndex });
156
+ });
157
+ return { onFocus };
158
+ }
159
+ function HeaderCell({
160
+ api,
161
+ column,
162
+ columnIndex,
163
+ viewportWidth,
164
+ rowStart,
165
+ rowEnd,
166
+ xPositions
167
+ }) {
168
+ const isStart = column.pin === "start";
169
+ const isEnd = column.pin === "end";
170
+ const rtl = api.getState().rtl.use();
171
+ const style = useMemo(() => {
172
+ const x2 = isEnd ? xPositions[columnIndex] - xPositions.at(-1) + viewportWidth : xPositions[columnIndex];
173
+ const width = sizeFromCoord(columnIndex, xPositions);
174
+ const style2 = {
175
+ transform: getTransform(x2 * (rtl ? -1 : 1), 0),
176
+ gridRowStart: rowStart,
177
+ gridRowEnd: rowEnd,
178
+ width
179
+ };
180
+ if (isStart || isEnd) {
181
+ style2.insetInlineStart = "0px";
182
+ style2.position = "sticky";
183
+ style2.zIndex = 2;
184
+ }
185
+ return style2;
186
+ }, [columnIndex, isEnd, isStart, rowEnd, rowStart, rtl, viewportWidth, xPositions]);
187
+ const Renderer = useHeaderCellRenderer(api, column);
188
+ const { moveProps, dropProps, isBefore, isOver, canDrop, dragIndex } = useHeaderMove(
189
+ api,
190
+ column,
191
+ columnIndex
192
+ );
193
+ const sx = api.getState();
194
+ sx.sortModel.use();
195
+ const ref = useRef(null);
196
+ const events = useHeaderFocus(api, ref, columnIndex);
197
+ if (api.columnIsEmpty(column)) {
198
+ return /* @__PURE__ */ jsx(
199
+ "button",
200
+ {
201
+ ...events,
202
+ ref,
203
+ onClick: () => {
204
+ const id = column.id.replace(COLUMN_EMPTY_PREFIX, "").split("|>").slice(0, -1);
205
+ api.columnGroupToggle(id.join(api.getState().columnGroupIdDelimiter.peek()));
206
+ },
207
+ style,
208
+ className: "lng1771-header__cell-expand",
209
+ children: "+"
210
+ }
211
+ );
212
+ }
213
+ const sortDir = api.columnSortDirection(column);
214
+ return /* @__PURE__ */ jsx(
215
+ "div",
216
+ {
217
+ style,
218
+ ref,
219
+ role: "columnheader",
220
+ "data-lng1771-column-id": column.id,
221
+ "data-lng1771-kind": "header",
222
+ "aria-colindex": columnIndex + 1,
223
+ "aria-colspan": 1,
224
+ "aria-sort": sortDir === "asc" ? "ascending" : sortDir === "desc" ? "descending" : "none",
225
+ tabIndex: -1,
226
+ ...moveProps,
227
+ ...dropProps,
228
+ ...events,
229
+ className: clsx(
230
+ "lng1771-header__cell",
231
+ isOver && columnIndex !== dragIndex && "lng1771-header__cell--over",
232
+ isOver && isBefore && "lng1771-header__cell--over-before",
233
+ isOver && !isBefore && "lng1771-header__cell--over-after",
234
+ isOver && !canDrop && "lng1771-header__cell--over-not-allowed"
235
+ ),
236
+ children: /* @__PURE__ */ jsx(Renderer, { api, column })
237
+ }
238
+ );
239
+ }
240
+ function useHeaderCells(api) {
241
+ const sx = api.getState();
242
+ const visibleColumns = sx.columnsVisible.use();
243
+ const xPositions = sx.columnPositions.use();
244
+ const bounds = sx.internal.virtBounds.use();
245
+ const hierarchy = sx.columnGroupLevels.use();
246
+ const startCount = sx.columnVisibleStartCount.use();
247
+ const centerCount = sx.columnVisibleCenterCount.use();
248
+ const endCount = sx.columnVisibleEndCount.use();
249
+ const viewportWidth = sx.internal.viewportInnerWidth.use();
250
+ return useMemo(() => {
251
+ const cells = [];
252
+ const columnRowCount = hierarchy.length + 1;
253
+ function handleCell(i) {
254
+ const column = visibleColumns[i];
255
+ let rowStart = columnRowCount;
256
+ let level = columnRowCount - 2;
257
+ while (hierarchy[level]?.[i] === null) {
258
+ rowStart--;
259
+ level--;
260
+ }
261
+ cells.push(
262
+ /* @__PURE__ */ jsx(
263
+ HeaderCell,
264
+ {
265
+ api,
266
+ column,
267
+ columnIndex: i,
268
+ viewportWidth,
269
+ xPositions,
270
+ rowStart,
271
+ rowEnd: columnRowCount + 1,
272
+ startCount,
273
+ centerCount,
274
+ endCount
275
+ },
276
+ column.id
277
+ )
278
+ );
279
+ }
280
+ for (let i = 0; i < startCount; i++) {
281
+ handleCell(i);
282
+ }
283
+ for (let i = bounds.columnStart; i < bounds.columnEnd; i++) {
284
+ handleCell(i);
285
+ }
286
+ const first = startCount + centerCount;
287
+ for (let i = first; i < visibleColumns.length; i++) {
288
+ handleCell(i);
289
+ }
290
+ return cells;
291
+ }, [
292
+ api,
293
+ bounds.columnEnd,
294
+ bounds.columnStart,
295
+ centerCount,
296
+ endCount,
297
+ hierarchy,
298
+ startCount,
299
+ viewportWidth,
300
+ visibleColumns,
301
+ xPositions
302
+ ]);
303
+ }
304
+ function useResizeDivider(api, column) {
305
+ const isResizable = api.columnIsResizable(column);
306
+ const timeOutRef = useRef(null);
307
+ const dragStarted = useRef(false);
308
+ const resizeProps = useMemo(() => {
309
+ if (!isResizable) return {};
310
+ const onPointerDown = (e) => {
311
+ e.preventDefault();
312
+ const startWidth = api.columnVisualWidth(column);
313
+ const isRtl = api.getState().rtl.peek();
314
+ let startX = null;
315
+ let anim = null;
316
+ let delta = 0;
317
+ if (timeOutRef.current) clearTimeout(timeOutRef.current);
318
+ timeOutRef.current = setTimeout(() => {
319
+ dragStarted.current = true;
320
+ timeOutRef.current = null;
321
+ }, 100);
322
+ const controller = new AbortController();
323
+ document.addEventListener(
324
+ "pointermove",
325
+ (ev) => {
326
+ if (dragStarted.current === false) return;
327
+ if (startX === null) {
328
+ startX = getClientX(ev);
329
+ return;
330
+ }
331
+ const endAdjust = column.pin === "end" ? -1 : 1;
332
+ const rtlAdjust = isRtl ? -1 : 1;
333
+ delta = (getClientX(ev) - startX) * endAdjust * rtlAdjust;
334
+ if (anim) cancelAnimationFrame(anim);
335
+ anim = requestAnimationFrame(() => {
336
+ api.getState().internal.columnWidthDeltas.set({ [column.id]: delta });
337
+ });
338
+ },
339
+ { signal: controller.signal }
340
+ );
341
+ window.addEventListener(
342
+ "pointerup",
343
+ () => {
344
+ if (timeOutRef.current) clearTimeout(timeOutRef.current);
345
+ if (anim) cancelAnimationFrame(anim);
346
+ dragStarted.current = false;
347
+ const newWidth = startWidth + delta;
348
+ api.columnResize(column, newWidth);
349
+ api.getState().internal.columnWidthDeltas.set(null);
350
+ controller.abort();
351
+ },
352
+ { signal: controller.signal }
353
+ );
354
+ };
355
+ return { onPointerDown };
356
+ }, [api, column, isResizable]);
357
+ return resizeProps;
358
+ }
359
+ function HeaderDivider({
360
+ api,
361
+ columnIndex,
362
+ xPositions,
363
+ viewportWidth,
364
+ rowStart,
365
+ rowEnd,
366
+ column,
367
+ startCount,
368
+ centerCount,
369
+ endCount
370
+ }) {
371
+ const isResizable = api.columnIsResizable(column);
372
+ const isLastStart = startCount > 0 && columnIndex === startCount - 1;
373
+ const isFirstEnd = endCount > 0 && startCount + centerCount === columnIndex;
374
+ const isLast = startCount + centerCount + endCount - 1 === columnIndex;
375
+ const resizeProps = useResizeDivider(api, column);
376
+ const rtl = api.getState().rtl.use();
377
+ const style = useMemo(() => {
378
+ const isStart = column.pin === "start";
379
+ const isEnd = column.pin == "end";
380
+ const endAdjustment = centerCount + startCount - 1 === columnIndex && endCount > 0 ? 2 : 0;
381
+ const x2 = isEnd ? xPositions[columnIndex] - xPositions.at(-1) + viewportWidth - 2 : xPositions[columnIndex] + sizeFromCoord(columnIndex, xPositions) - 3 - endAdjustment;
382
+ const xAdjustment = isLastStart ? 1 : isFirstEnd ? 0 : isLast ? 1 : 0;
383
+ const style2 = {
384
+ transform: getTransform((x2 - xAdjustment) * (rtl ? -1 : 1), 0),
385
+ gridRowStart: rowStart,
386
+ gridRowEnd: rowEnd
387
+ };
388
+ if (isStart || isEnd) {
389
+ style2.insetInlineStart = "0px";
390
+ style2.position = "sticky";
391
+ style2.zIndex = 2;
392
+ }
393
+ if (isLast && !isResizable) style2.opacity = 0;
394
+ return style2;
395
+ }, [
396
+ centerCount,
397
+ column.pin,
398
+ columnIndex,
399
+ endCount,
400
+ isFirstEnd,
401
+ isLast,
402
+ isLastStart,
403
+ isResizable,
404
+ rowEnd,
405
+ rowStart,
406
+ rtl,
407
+ startCount,
408
+ viewportWidth,
409
+ xPositions
410
+ ]);
411
+ return /* @__PURE__ */ jsx(
412
+ "div",
413
+ {
414
+ ...resizeProps,
415
+ onDoubleClick: () => {
416
+ const autosize = api.getState().autosizeDoubleClickHeader.peek();
417
+ if (autosize) api.autosizeColumn(column, { includeHeader: true });
418
+ },
419
+ className: clsx(
420
+ "lng1771-header__cell-divider",
421
+ isResizable && "lng1771-header__cell-divider--resizable"
422
+ ),
423
+ style,
424
+ children: /* @__PURE__ */ jsx("div", {})
425
+ }
426
+ );
427
+ }
428
+ function useHeaderDividers(api) {
429
+ const sx = api.getState();
430
+ const xPositions = sx.columnPositions.use();
431
+ const hierarchy = sx.columnGroupLevels.use();
432
+ const viewportWidth = sx.internal.viewportInnerWidth.use();
433
+ const bounds = sx.internal.virtBounds.use();
434
+ const startCount = sx.columnVisibleStartCount.use();
435
+ const centerCount = sx.columnVisibleCenterCount.use();
436
+ const endCount = sx.columnVisibleEndCount.use();
437
+ const columns = sx.columnsVisible.use();
438
+ return useMemo(() => {
439
+ const firstEndIndex = xPositions.length - 1 - endCount;
440
+ const columnRowCount = hierarchy.length + 1;
441
+ const dividers = [];
442
+ const indices = Array.from(
443
+ { length: bounds.columnEnd - bounds.columnStart },
444
+ (_, i) => i + bounds.columnStart
445
+ );
446
+ for (let i = startCount - 1; i >= 0; i--) indices.unshift(i);
447
+ const first = startCount + centerCount;
448
+ for (let j = first; j < centerCount + startCount + endCount; j++) indices.push(j);
449
+ for (let i = 0; i < indices.length - endCount; i++) {
450
+ const columnIndex = indices[i];
451
+ const rowStart = getRowStart(hierarchy, startCount, firstEndIndex, columnIndex);
452
+ const column = columns[columnIndex];
453
+ dividers.push(
454
+ /* @__PURE__ */ jsx(
455
+ HeaderDivider,
456
+ {
457
+ api,
458
+ column,
459
+ xPositions,
460
+ viewportWidth,
461
+ rowStart,
462
+ rowEnd: columnRowCount + 1,
463
+ columnIndex,
464
+ startCount,
465
+ centerCount,
466
+ endCount
467
+ },
468
+ column.id
469
+ )
470
+ );
471
+ }
472
+ for (let i = indices.length - endCount; i < indices.length; i++) {
473
+ const columnIndex = indices[i];
474
+ const rowStart = getRowStart(hierarchy, startCount, firstEndIndex, columnIndex);
475
+ const column = columns[columnIndex];
476
+ dividers.push(
477
+ /* @__PURE__ */ jsx(
478
+ HeaderDivider,
479
+ {
480
+ api,
481
+ column,
482
+ xPositions,
483
+ viewportWidth,
484
+ rowStart,
485
+ rowEnd: columnRowCount + 1,
486
+ columnIndex,
487
+ startCount,
488
+ centerCount,
489
+ endCount
490
+ },
491
+ column.id
492
+ )
493
+ );
494
+ }
495
+ return dividers;
496
+ }, [
497
+ api,
498
+ bounds.columnEnd,
499
+ bounds.columnStart,
500
+ centerCount,
501
+ columns,
502
+ endCount,
503
+ hierarchy,
504
+ startCount,
505
+ viewportWidth,
506
+ xPositions
507
+ ]);
508
+ }
509
+ function isPartOfGroup(columnIndex, hierarchy) {
510
+ if (!hierarchy.length) return false;
511
+ return hierarchy.length > 0 && hierarchy[0][columnIndex] != null;
512
+ }
513
+ function getRowStart(hierarchy, startCount, firstEndIndex, columnIndex) {
514
+ const isFirstEndIndex = columnIndex === firstEndIndex;
515
+ const isLastStartIndex = columnIndex === startCount - 1 && startCount > 0;
516
+ const hasGroup = isPartOfGroup(columnIndex, hierarchy);
517
+ if (isFirstEndIndex || isLastStartIndex || !hasGroup) return 1;
518
+ let level = 0;
519
+ while (level < hierarchy.length && hierarchy[level][columnIndex] != null) {
520
+ level++;
521
+ }
522
+ while (hierarchy[level - 1]?.[columnIndex] && hierarchy[level - 1][columnIndex].end - 1 === columnIndex) {
523
+ level--;
524
+ }
525
+ return level + 1;
526
+ }
527
+ function useHeaderGroupMove(api, item, pin) {
528
+ const sx = api.getState();
529
+ const gridId = sx.gridId.use();
530
+ const visible = sx.columnsVisible.use();
531
+ const columns = useMemo(() => {
532
+ return visible.slice(item.start, item.end);
533
+ }, [item.end, item.start, visible]);
534
+ const move = useDraggable({
535
+ dragTags: () => [`${gridId}:grid:${pin ?? "none"}`],
536
+ dragData: () => ({ columns, columnIndex: item.start }),
537
+ placeholder: () => /* @__PURE__ */ jsx(
538
+ DragPlaceholder,
539
+ {
540
+ cnt: item.end - item.start,
541
+ label: item.id.split(sx.columnGroupIdDelimiter.peek()).at(-1)
542
+ }
543
+ )
544
+ });
545
+ const isMovable = columns.every((c) => api.columnIsMovable(c));
546
+ return { moveProps: isMovable ? move : {} };
547
+ }
548
+ function DragPlaceholder(c) {
549
+ return /* @__PURE__ */ jsxs("div", { className: "lng1771-drag-placeholder", children: [
550
+ c.label,
551
+ " | moving ",
552
+ c.cnt,
553
+ " columns"
554
+ ] });
555
+ }
556
+ function HeaderGroupCell({
557
+ api,
558
+ groupItem,
559
+ pin,
560
+ viewportWidth,
561
+ rowStart,
562
+ xPositions
563
+ }) {
564
+ const rtl = api.getState().rtl.use();
565
+ const style = useMemo(() => {
566
+ const isStart = pin === "start";
567
+ const isEnd = pin == "end";
568
+ const width = sizeFromCoord(groupItem.start, xPositions, groupItem.end - groupItem.start);
569
+ const columnIndex = groupItem.start;
570
+ const x2 = isEnd ? xPositions[columnIndex] - xPositions.at(-1) + viewportWidth : xPositions[columnIndex];
571
+ const style2 = {
572
+ transform: getTransform(x2 * (rtl ? -1 : 1), 0),
573
+ gridRowStart: rowStart,
574
+ gridRowEnd: rowStart + 1,
575
+ width
576
+ };
577
+ if (isStart || isEnd) {
578
+ style2.insetInlineStart = "0px";
579
+ style2.position = "sticky";
580
+ style2.zIndex = 2;
581
+ }
582
+ return style2;
583
+ }, [groupItem.end, groupItem.start, pin, rowStart, rtl, viewportWidth, xPositions]);
584
+ const headerMove = useHeaderGroupMove(api, groupItem, pin);
585
+ const ref = useRef(null);
586
+ const skipRef = useRef(false);
587
+ useEffect(() => {
588
+ const sx = api.getState();
589
+ const position = sx.internal.navigatePosition;
590
+ const unsub = position.watch(() => {
591
+ const pos = position.peek();
592
+ if (!pos || !ref.current || pos.kind !== HEADER_GROUP_CELL_POSITION) return;
593
+ if (groupItem.start === pos.columnStartIndex && groupItem.end === pos.columnEndIndex && pos.hierarchyRowIndex === rowStart - 1 && !ref.current.contains(document.activeElement) && ref.current !== document.activeElement) {
594
+ api.navigateScrollIntoView(null, pos.columnIndex);
595
+ skipRef.current = true;
596
+ ref.current.focus();
597
+ }
598
+ });
599
+ return () => unsub();
600
+ }, [api, groupItem.end, groupItem.start, rowStart]);
601
+ const onFocus = useEvent(() => {
602
+ if (skipRef.current) {
603
+ skipRef.current = false;
604
+ return;
605
+ }
606
+ api.getState().internal.navigatePosition.set({
607
+ kind: HEADER_GROUP_CELL_POSITION,
608
+ columnStartIndex: groupItem.start,
609
+ columnEndIndex: groupItem.end,
610
+ columnIndex: groupItem.start,
611
+ hierarchyRowIndex: rowStart - 1
612
+ });
613
+ });
614
+ return /* @__PURE__ */ jsx(
615
+ "div",
616
+ {
617
+ ref,
618
+ onFocus,
619
+ style,
620
+ "data-lng1771-group-id": groupItem.id,
621
+ "data-lng1771-kind": "header-group",
622
+ "aria-colindex": groupItem.start + 1,
623
+ "aria-colspan": groupItem.end - groupItem.start,
624
+ role: "columnheader",
625
+ tabIndex: -1,
626
+ ...headerMove.moveProps,
627
+ className: "lng1771-header__group",
628
+ children: /* @__PURE__ */ jsx(HeaderGroupDefault, { group: groupItem, api })
629
+ }
630
+ );
631
+ }
632
+ function HeaderGroupDefault({ group, api }) {
633
+ const label = useMemo(() => {
634
+ const delimiter = api.getState().columnGroupIdDelimiter.peek();
635
+ return group.id.split(delimiter).at(-1);
636
+ }, [api, group.id]);
637
+ return /* @__PURE__ */ jsxs(
638
+ "div",
639
+ {
640
+ style: {
641
+ width: "100%",
642
+ height: "100%",
643
+ display: "flex",
644
+ alignItems: "center",
645
+ boxSizing: "border-box",
646
+ justifyContent: "space-between",
647
+ paddingInline: 12
648
+ },
649
+ children: [
650
+ label,
651
+ group.isCollapsible && /* @__PURE__ */ jsx(CollapseButton, { onClick: () => api.columnGroupToggle(group.id), children: "-" })
652
+ ]
653
+ }
654
+ );
655
+ }
656
+ function useHeaderGroupCells(api) {
657
+ const sx = api.getState();
658
+ const bounds = sx.internal.virtBounds.use();
659
+ const hierarchy = sx.columnGroupLevels.use();
660
+ const xPositions = sx.columnPositions.use();
661
+ const startCount = sx.columnVisibleStartCount.use();
662
+ const centerCount = sx.columnVisibleCenterCount.use();
663
+ const endCount = sx.columnVisibleEndCount.use();
664
+ const viewportWidth = sx.internal.viewportInnerWidth.use();
665
+ return useMemo(() => {
666
+ const cells = [];
667
+ function handleCell(groupItem, levelIndex, pin) {
668
+ cells.push(
669
+ /* @__PURE__ */ jsx(
670
+ HeaderGroupCell,
671
+ {
672
+ api,
673
+ groupItem,
674
+ pin,
675
+ rowStart: levelIndex + 1,
676
+ viewportWidth,
677
+ centerCount,
678
+ startCount,
679
+ endCount,
680
+ xPositions
681
+ },
682
+ groupItem.occurrenceKey
683
+ )
684
+ );
685
+ }
686
+ for (let level = 0; level < hierarchy.length; level++) {
687
+ const processedIndices = /* @__PURE__ */ new Set();
688
+ const row = hierarchy[level];
689
+ for (let i = 0; i < startCount; i++) {
690
+ const groupItem = row[i];
691
+ if (!groupItem) continue;
692
+ if (!processedIndices.has(i)) handleCell(groupItem, level, "start");
693
+ for (let j = groupItem.start; j < groupItem.end; j++) processedIndices.add(j);
694
+ }
695
+ for (let i = bounds.columnStart; i < bounds.columnEnd; i++) {
696
+ const groupItem = row[i];
697
+ if (!groupItem) continue;
698
+ if (!processedIndices.has(i)) handleCell(groupItem, level, null);
699
+ for (let j = groupItem.start; j < groupItem.end; j++) processedIndices.add(j);
700
+ }
701
+ const first = startCount + centerCount;
702
+ for (let i = first; i < row.length; i++) {
703
+ const groupItem = row[i];
704
+ if (!groupItem) continue;
705
+ if (!processedIndices.has(i)) handleCell(groupItem, level, "end");
706
+ for (let j = groupItem.start; j < groupItem.end; j++) processedIndices.add(j);
707
+ }
708
+ }
709
+ return cells;
710
+ }, [
711
+ api,
712
+ bounds.columnEnd,
713
+ bounds.columnStart,
714
+ centerCount,
715
+ endCount,
716
+ hierarchy,
717
+ startCount,
718
+ viewportWidth,
719
+ xPositions
720
+ ]);
721
+ }
722
+ function useFloatingFocus(api, ref, columnIndex) {
723
+ useEffect(() => {
724
+ const sx = api.getState();
725
+ const unsub = sx.internal.navigatePosition.watch(() => {
726
+ const position = sx.internal.navigatePosition.peek();
727
+ if (!ref.current || !position || position.kind !== FLOATING_CELL_POSITION) return;
728
+ if (position.columnIndex === columnIndex && !ref.current.contains(document.activeElement)) {
729
+ api.navigateScrollIntoView(null, columnIndex);
730
+ ref.current.focus();
731
+ }
732
+ });
733
+ return () => unsub();
734
+ }, [api, columnIndex, ref]);
735
+ const onFocus = useEvent(() => {
736
+ api.getState().internal.navigatePosition.set({ kind: FLOATING_CELL_POSITION, columnIndex });
737
+ });
738
+ return { onFocus };
739
+ }
740
+ function FloatingCell({
741
+ api,
742
+ viewportWidth,
743
+ column,
744
+ xPositions,
745
+ columnIndex,
746
+ rowStart,
747
+ startCount
748
+ }) {
749
+ const isStart = column.pin === "start";
750
+ const isEnd = column.pin === "end";
751
+ const isLastStart = columnIndex === startCount - 1;
752
+ const rtl = api.getState().rtl.use();
753
+ const style = useMemo(() => {
754
+ const x2 = isEnd ? xPositions[columnIndex] - xPositions.at(-1) + viewportWidth : xPositions[columnIndex];
755
+ const width = sizeFromCoord(columnIndex, xPositions);
756
+ const style2 = {
757
+ transform: getTransform(x2 * (rtl ? -1 : 1), 0),
758
+ gridRowStart: rowStart,
759
+ gridRowEnd: rowStart + 1,
760
+ width
761
+ };
762
+ if (isStart || isEnd) {
763
+ style2.insetInlineStart = "0px";
764
+ style2.position = "sticky";
765
+ style2.zIndex = 2;
766
+ }
767
+ return style2;
768
+ }, [columnIndex, isEnd, isStart, rowStart, rtl, viewportWidth, xPositions]);
769
+ const sx = api.getState();
770
+ const base = sx.columnBase.use();
771
+ const rendererKey = column.floatingCellRenderer ?? base.floatingCellRenderer;
772
+ const renderers = sx.floatingCellRenderers.use();
773
+ const Component = useMemo(() => {
774
+ if (typeof rendererKey === "string") {
775
+ if (renderers[rendererKey])
776
+ throw new Error(`Failed to find floating renderer: ${rendererKey}`);
777
+ return renderers[rendererKey];
778
+ }
779
+ if (!rendererKey) return () => /* @__PURE__ */ jsx(Fragment, {});
780
+ return rendererKey;
781
+ }, [rendererKey, renderers]);
782
+ const ref = useRef(null);
783
+ const events = useFloatingFocus(api, ref, columnIndex);
784
+ const hide = api.columnIsGridGenerated(column) && !api.columnIsGroupAutoColumn(column);
785
+ return /* @__PURE__ */ jsx(
786
+ "div",
787
+ {
788
+ ref,
789
+ style,
790
+ ...events,
791
+ role: "columnheader",
792
+ "data-lng1771-kind": "floating",
793
+ "data-lng1771-pin": column.pin ?? "center",
794
+ "data-lng1771-last-start": isLastStart ? true : void 0,
795
+ "data-lng1771-column-id": column.id,
796
+ "aria-colindex": columnIndex,
797
+ "aria-colspan": 1,
798
+ tabIndex: -1,
799
+ className: "lng1771-header__cell-floating",
800
+ children: !hide && /* @__PURE__ */ jsx(Component, { api, column })
801
+ }
802
+ );
803
+ }
804
+ function useFloatingCells(api, enabled) {
805
+ const sx = api.getState();
806
+ const visibleColumns = sx.columnsVisible.use();
807
+ const xPositions = sx.columnPositions.use();
808
+ const bounds = sx.internal.virtBounds.use();
809
+ const hierarchy = sx.columnGroupLevels.use();
810
+ const startCount = sx.columnVisibleStartCount.use();
811
+ const centerCount = sx.columnVisibleCenterCount.use();
812
+ const endCount = sx.columnVisibleEndCount.use();
813
+ const viewportWidth = sx.internal.viewportInnerWidth.use();
814
+ return useMemo(() => {
815
+ if (!enabled) return [];
816
+ const cells = [];
817
+ const columnRowCount = hierarchy.length + 1;
818
+ function handleCell(i) {
819
+ const column = visibleColumns[i];
820
+ const rowStart = columnRowCount + 1;
821
+ cells.push(
822
+ /* @__PURE__ */ jsx(
823
+ FloatingCell,
824
+ {
825
+ api,
826
+ column,
827
+ columnIndex: i,
828
+ viewportWidth,
829
+ xPositions,
830
+ rowStart,
831
+ startCount,
832
+ centerCount,
833
+ endCount
834
+ },
835
+ column.id
836
+ )
837
+ );
838
+ }
839
+ for (let i = 0; i < startCount; i++) {
840
+ handleCell(i);
841
+ }
842
+ for (let i = bounds.columnStart; i < bounds.columnEnd; i++) {
843
+ handleCell(i);
844
+ }
845
+ const first = startCount + centerCount;
846
+ for (let i = first; i < visibleColumns.length; i++) {
847
+ handleCell(i);
848
+ }
849
+ return cells;
850
+ }, [
851
+ api,
852
+ bounds.columnEnd,
853
+ bounds.columnStart,
854
+ centerCount,
855
+ enabled,
856
+ endCount,
857
+ hierarchy.length,
858
+ startCount,
859
+ viewportWidth,
860
+ visibleColumns,
861
+ xPositions
862
+ ]);
863
+ }
864
+ function Header() {
865
+ const { state, api } = useGrid();
866
+ const columnHeaderHeight = state.columnHeaderHeight.use();
867
+ const columnGroupHeaderHeight = state.columnGroupHeaderHeight.use();
868
+ const floatingRowHeight = state.floatingRowHeight.use();
869
+ const floatingRowEnabled = state.floatingRowEnabled.use();
870
+ const hierarchy = state.columnGroupLevels.use();
871
+ const headerGroupCells = useHeaderGroupCells(api);
872
+ const headerCells = useHeaderCells(api);
873
+ const headerDividers = useHeaderDividers(api);
874
+ const floatingCells = useFloatingCells(api, floatingRowEnabled);
875
+ const gridTemplateRows = useHeaderDisplayGridTemplate(
876
+ hierarchy.length,
877
+ columnHeaderHeight,
878
+ columnGroupHeaderHeight,
879
+ floatingRowEnabled,
880
+ floatingRowHeight
881
+ );
882
+ const headerHeightSetting = state.internal.viewportHeaderHeight.use();
883
+ const headerHeight = useMemo(() => {
884
+ return `${headerHeightSetting - (floatingRowEnabled ? floatingRowHeight : 0)}px`;
885
+ }, [floatingRowEnabled, floatingRowHeight, headerHeightSetting]);
886
+ return /* @__PURE__ */ jsxs(
887
+ "div",
888
+ {
889
+ role: "row",
890
+ className: "lng1771-header",
891
+ style: { gridTemplateRows, "--lng1771-header-height": headerHeight },
892
+ children: [
893
+ headerGroupCells,
894
+ headerCells,
895
+ headerDividers,
896
+ floatingCells
897
+ ]
898
+ }
899
+ );
900
+ }
901
+ function HeaderContainer({ style }) {
902
+ const { state } = useGrid();
903
+ const [header, setHeader] = useState(null);
904
+ useIsoEffect(() => {
905
+ if (!header) return;
906
+ const resize = new IsoResizeObserver(() => {
907
+ if (!header) return;
908
+ const prec = getPreciseElementDimensions(header);
909
+ state.internal.viewportHeaderHeight.set(prec.outerHeight);
910
+ });
911
+ resize.observe(header);
912
+ return () => resize.disconnect();
913
+ }, [header]);
914
+ return /* @__PURE__ */ jsx("div", { ref: setHeader, className: "lng1771-header-container", style, children: /* @__PURE__ */ jsx(Header, {}) });
915
+ }
916
+ function RowDetail({ api, row, rowPin, yPositions, rowIndex, height }) {
917
+ const sx = api.getState();
918
+ const width = sx.internal.viewportInnerWidth.use();
919
+ const Renderer = sx.rowDetailRenderer.use() ?? RowDetailDefault;
920
+ const style = useMemo(() => {
921
+ const isTop = rowPin === "top";
922
+ const isBot = rowPin === "bottom";
923
+ const rowCount = sx.internal.rowCount.peek();
924
+ const rowTopCount = sx.internal.rowTopCount.peek();
925
+ const rowBotCount = sx.internal.rowBottomCount.peek();
926
+ const firstBotIndex = rowCount - rowBotCount;
927
+ const offset = sizeFromCoord(rowIndex, yPositions) - height;
928
+ const y2 = isBot ? yPositions[rowIndex] - yPositions[firstBotIndex] : isTop ? yPositions[rowIndex] : yPositions[rowIndex] - yPositions[rowTopCount];
929
+ const transform = getTransform(0, y2 + offset);
930
+ return { width, height, transform };
931
+ }, [
932
+ height,
933
+ rowIndex,
934
+ rowPin,
935
+ sx.internal.rowBottomCount,
936
+ sx.internal.rowCount,
937
+ sx.internal.rowTopCount,
938
+ width,
939
+ yPositions
940
+ ]);
941
+ return /* @__PURE__ */ jsx("div", { style, className: "lng1771-row-detail", children: /* @__PURE__ */ jsx(Renderer, { api, row }) });
942
+ }
943
+ function RowDetailDefault() {
944
+ return /* @__PURE__ */ jsx("div", { children: "Not Implemented" });
945
+ }
946
+ function RowDragIndicator({ section }) {
947
+ const { state } = useGrid();
948
+ const rowIndex = state.internal.rowDragOverIndex.use();
949
+ const dragIndex = state.internal.rowDragStartIndex.use();
950
+ const yPositions = state.internal.rowPositions.use();
951
+ const width = state.internal.viewportInnerWidth.use();
952
+ const topCount = state.internal.rowTopCount.use();
953
+ const bottomCount = state.internal.rowBottomCount.use();
954
+ const rowCount = state.internal.rowCount.use();
955
+ const isBefore = rowIndex < dragIndex;
956
+ if (rowIndex === -1 || rowIndex == null) return null;
957
+ if (section === "top" && rowIndex > topCount) return null;
958
+ if (section === "center" && rowIndex < topCount || rowIndex >= rowCount - bottomCount)
959
+ return null;
960
+ if (section === "bottom" && rowIndex < rowCount - bottomCount) return null;
961
+ const firstBotIndex = rowCount - bottomCount;
962
+ const height = sizeFromCoord(rowIndex, yPositions);
963
+ const y2 = section === "bottom" ? yPositions[rowIndex] - yPositions[firstBotIndex] : section === "top" ? yPositions[rowIndex] : yPositions[rowIndex] - yPositions[topCount];
964
+ return /* @__PURE__ */ jsx(
965
+ "div",
966
+ {
967
+ style: { transform: getTransform(0, y2 + (isBefore ? 0 : height)), width },
968
+ className: "lng1771-row-drag-indicator"
969
+ }
970
+ );
971
+ }
972
+ function Rows({
973
+ width,
974
+ ...els
975
+ }) {
976
+ const { state, api } = useGrid();
977
+ const layout = state.internal.virtLayout.use();
978
+ const xPositions = state.columnPositions.use();
979
+ const yPositions = state.internal.rowPositions.use();
980
+ const columns = state.columnsVisible.use();
981
+ const refreshKey = state.internal.rowRefreshCount.use();
982
+ const headerHeight = state.internal.viewportHeaderHeight.use();
983
+ const rowCount = state.internal.rowCount.use();
984
+ const topCount = state.internal.rowTopCount.use();
985
+ const botCount = state.internal.rowBottomCount.use();
986
+ const topHeight = yPositions[topCount];
987
+ const botHeight = yPositions.at(-1) - yPositions[rowCount - botCount];
988
+ const detailHeight = state.internal.rowDetailHeight.use();
989
+ const [fullWidthCache, cellCache] = useMemo(() => {
990
+ return [{}, {}];
991
+ }, [botCount, columns, headerHeight, refreshKey, rowCount, topCount, xPositions, yPositions]);
992
+ const firstBotIndex = rowCount - botCount;
993
+ const paginate = state.paginate.use();
994
+ const currentPage = state.paginateCurrentPage.use();
995
+ const [top, center, bottom] = useMemo(() => {
996
+ const top2 = [];
997
+ const center2 = [];
998
+ const bottom2 = [];
999
+ let paginateOffset = 0;
1000
+ if (paginate) {
1001
+ const [rowStart] = api.paginateRowStartAndEndForPage(currentPage);
1002
+ paginateOffset = yPositions[rowStart];
1003
+ }
1004
+ for (const [rowIndex, cells] of layout) {
1005
+ if (rowIndex >= rowCount) continue;
1006
+ const isTop = rowIndex < topCount;
1007
+ const isBot = rowIndex >= firstBotIndex;
1008
+ const isCenter = !isTop && !isBot;
1009
+ const place = isCenter ? center2 : isTop ? top2 : bottom2;
1010
+ const row = api.rowByIndex(rowIndex);
1011
+ if (!row) continue;
1012
+ let i = 0;
1013
+ while (i < cells.length) {
1014
+ const encoding = cells[i];
1015
+ if (encoding === FULL_ENCODING) {
1016
+ fullWidthCache[rowIndex] ??= /* @__PURE__ */ jsx(
1017
+ CellFullWidth,
1018
+ {
1019
+ api,
1020
+ row,
1021
+ colCount: columns.length,
1022
+ rowPin: rowIndex < topCount ? "top" : rowIndex >= firstBotIndex ? "bottom" : null,
1023
+ rowIndex,
1024
+ yPositions,
1025
+ paginateOffset
1026
+ },
1027
+ `${rowIndex}-full`
1028
+ );
1029
+ place.push(fullWidthCache[rowIndex]);
1030
+ i++;
1031
+ } else if (encoding === END_ENCODING) {
1032
+ break;
1033
+ } else {
1034
+ const rowIndex2 = cells[i++];
1035
+ const rowSpan = cells[i++];
1036
+ const colIndex = cells[i++];
1037
+ const colSpan = cells[i++];
1038
+ cellCache[rowIndex2] ??= {};
1039
+ cellCache[rowIndex2][colIndex] = /* @__PURE__ */ jsx(
1040
+ Cell,
1041
+ {
1042
+ api,
1043
+ column: columns[colIndex],
1044
+ rowIndex: rowIndex2,
1045
+ rowSpan,
1046
+ colSpan,
1047
+ rowPin: rowIndex2 < topCount ? "top" : rowIndex2 >= firstBotIndex ? "bottom" : null,
1048
+ rowNode: row,
1049
+ columnIndex: colIndex,
1050
+ yPositions,
1051
+ xPositions,
1052
+ paginateOffset
1053
+ },
1054
+ `r${rowIndex2}-c${colIndex}`
1055
+ );
1056
+ place.push(cellCache[rowIndex2][colIndex]);
1057
+ }
1058
+ }
1059
+ const rowDetailHeight = detailHeight(rowIndex);
1060
+ if (rowDetailHeight > 0) {
1061
+ place.push(
1062
+ /* @__PURE__ */ jsx(
1063
+ RowDetail,
1064
+ {
1065
+ api,
1066
+ height: rowDetailHeight,
1067
+ row,
1068
+ rowPin: rowIndex < topCount ? "top" : rowIndex >= firstBotIndex ? "bottom" : null,
1069
+ rowIndex,
1070
+ yPositions
1071
+ }
1072
+ )
1073
+ );
1074
+ }
1075
+ }
1076
+ return [top2, center2, bottom2];
1077
+ }, [
1078
+ api,
1079
+ cellCache,
1080
+ columns,
1081
+ currentPage,
1082
+ detailHeight,
1083
+ firstBotIndex,
1084
+ fullWidthCache,
1085
+ layout,
1086
+ paginate,
1087
+ rowCount,
1088
+ topCount,
1089
+ xPositions,
1090
+ yPositions
1091
+ ]);
1092
+ const viewportWidth = state.internal.viewportInnerWidth.use();
1093
+ const endCount = state.columnVisibleEndCount.use();
1094
+ const minWidth = Math.max(endCount > 0 ? viewportWidth : 0, width);
1095
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1096
+ topHeight > 0 && /* @__PURE__ */ jsxs(
1097
+ "div",
1098
+ {
1099
+ style: {
1100
+ width,
1101
+ minWidth,
1102
+ top: headerHeight,
1103
+ height: topHeight,
1104
+ minHeight: topHeight,
1105
+ maxHeight: topHeight
1106
+ },
1107
+ className: "lng1771-rows__top-section",
1108
+ children: [
1109
+ top,
1110
+ /* @__PURE__ */ jsx(RowDragIndicator, { section: "top" }),
1111
+ /* @__PURE__ */ jsx(els.top, {})
1112
+ ]
1113
+ }
1114
+ ),
1115
+ /* @__PURE__ */ jsxs(
1116
+ "div",
1117
+ {
1118
+ style: {
1119
+ width,
1120
+ minWidth
1121
+ },
1122
+ className: "lng1771-rows__center-section",
1123
+ children: [
1124
+ center,
1125
+ /* @__PURE__ */ jsx(RowDragIndicator, { section: "center" }),
1126
+ /* @__PURE__ */ jsx(els.center, {})
1127
+ ]
1128
+ }
1129
+ ),
1130
+ botHeight > 0 && /* @__PURE__ */ jsxs(
1131
+ "div",
1132
+ {
1133
+ style: {
1134
+ bottom: 0,
1135
+ width,
1136
+ minWidth,
1137
+ height: botHeight,
1138
+ minHeight: botHeight,
1139
+ maxHeight: botHeight
1140
+ },
1141
+ className: "lng1771-rows__bottom-section",
1142
+ children: [
1143
+ bottom,
1144
+ /* @__PURE__ */ jsx(RowDragIndicator, { section: "bottom" }),
1145
+ /* @__PURE__ */ jsx(els.bottom, {})
1146
+ ]
1147
+ }
1148
+ )
1149
+ ] });
1150
+ }
1151
+ function RowContainer({
1152
+ totalHeight,
1153
+ totalWidth,
1154
+ children
1155
+ }) {
1156
+ const { api, state } = useGrid();
1157
+ const gridId = state.gridId.use();
1158
+ const { onDragOver, onDrop } = useDroppable({
1159
+ tags: [`${gridId}:row-drag`],
1160
+ onDrop: (p2) => {
1161
+ const overIndex = state.internal.rowDragOverIndex.peek();
1162
+ const data = p2.getData();
1163
+ if (!data?.rows || !data?.api) return;
1164
+ const isExternal = data.api !== api;
1165
+ const additional = isExternal ? { externalGridApi: data.api, isExternal: true } : {};
1166
+ api.eventFire("onRowDragDrop", {
1167
+ api,
1168
+ event: p2.event,
1169
+ overIndex,
1170
+ rows: data.rows,
1171
+ ...additional
1172
+ });
1173
+ }
1174
+ });
1175
+ const columns = state.columnsVisible.use();
1176
+ if (columns.length === 0) return /* @__PURE__ */ jsx(Fragment, {});
1177
+ return /* @__PURE__ */ jsx(
1178
+ "div",
1179
+ {
1180
+ style: { width: totalWidth, minHeight: totalHeight },
1181
+ onDrop,
1182
+ onDragOver,
1183
+ className: "lng1771-row-container",
1184
+ children
1185
+ }
1186
+ );
1187
+ }
1188
+ function NavigationDriver() {
1189
+ const { state, api } = useGrid();
1190
+ const viewport = state.internal.viewport.use();
1191
+ const rtl = state.rtl.use();
1192
+ useEffect(() => {
1193
+ if (!viewport) return;
1194
+ const controller = new AbortController();
1195
+ viewport.addEventListener(
1196
+ "keydown",
1197
+ (ev) => {
1198
+ const key = ev.key;
1199
+ const startDir = rtl ? "ArrowRight" : "ArrowLeft";
1200
+ const endDir = rtl ? "ArrowLeft" : "ArrowRight";
1201
+ const position = state.internal.navigatePosition.peek();
1202
+ const activeEdit = state.internal.cellEditActiveLocation.peek();
1203
+ if (activeEdit || ev.shiftKey) return;
1204
+ if (document.activeElement === viewport && (key === "ArrowDown" || key === endDir)) {
1205
+ if (state.columnsVisible.peek().length) {
1206
+ state.internal.navigatePosition.set({ kind: HEADER_CELL_POSITION, columnIndex: 0 });
1207
+ }
1208
+ ev.preventDefault();
1209
+ ev.stopPropagation();
1210
+ }
1211
+ if (!position) return;
1212
+ let handled = false;
1213
+ const meta = ev.ctrlKey || ev.metaKey;
1214
+ if (key === "PageUp") {
1215
+ api.navigatePageUp();
1216
+ handled = true;
1217
+ } else if (key === "PageDown") {
1218
+ api.navigatePageDown();
1219
+ handled = true;
1220
+ } else if (key === "Home") {
1221
+ api.navigateToTop();
1222
+ handled = true;
1223
+ } else if (key === "End") {
1224
+ api.navigateToBottom();
1225
+ handled = true;
1226
+ } else if (key === "ArrowUp") {
1227
+ if (meta) {
1228
+ api.navigateToTop();
1229
+ } else {
1230
+ api.navigateUp();
1231
+ }
1232
+ handled = true;
1233
+ } else if (key === "ArrowDown") {
1234
+ if (meta) {
1235
+ api.navigateToBottom();
1236
+ } else {
1237
+ api.navigateDown();
1238
+ }
1239
+ handled = true;
1240
+ } else if (key === startDir) {
1241
+ if (meta) {
1242
+ api.navigateToStart();
1243
+ } else {
1244
+ api.navigatePrev();
1245
+ }
1246
+ handled = true;
1247
+ } else if (key === endDir) {
1248
+ if (meta) {
1249
+ api.navigateToEnd();
1250
+ } else {
1251
+ api.navigateNext();
1252
+ }
1253
+ handled = true;
1254
+ }
1255
+ if (handled) {
1256
+ ev.preventDefault();
1257
+ ev.stopPropagation();
1258
+ }
1259
+ },
1260
+ { signal: controller.signal }
1261
+ );
1262
+ const unsub = state.internal.navigatePosition.watch(() => {
1263
+ const position = state.internal.navigatePosition.peek();
1264
+ if (!position) return;
1265
+ const rowIndex = "rowIndex" in position ? position.rowIndex : null;
1266
+ const columnIndex = position.columnIndex;
1267
+ api.navigateScrollIntoView(rowIndex, columnIndex);
1268
+ });
1269
+ viewport.addEventListener(
1270
+ "focusout",
1271
+ () => {
1272
+ setTimeout(() => {
1273
+ if (viewport.contains(document.activeElement)) {
1274
+ return;
1275
+ }
1276
+ api.getState().internal.navigatePosition.set(null);
1277
+ }, 100);
1278
+ },
1279
+ { signal: controller.signal }
1280
+ );
1281
+ return () => {
1282
+ controller.abort();
1283
+ unsub();
1284
+ };
1285
+ }, [
1286
+ api,
1287
+ rtl,
1288
+ state.columnsVisible,
1289
+ state.internal.cellEditActiveLocation,
1290
+ state.internal.navigatePosition,
1291
+ viewport
1292
+ ]);
1293
+ return /* @__PURE__ */ jsx(Fragment, {});
1294
+ }
1295
+ function cellEditLocation(c) {
1296
+ return `r${c.rowIndex}-c${c.columnIndex}`;
1297
+ }
1298
+ function handleBeginCellEditFromEvent(api, event) {
1299
+ if (event.button !== 0) return;
1300
+ const clientY = getClientY(event);
1301
+ const clientX = getClientX(event);
1302
+ const rowIndex = getHoveredRowIndex(api, clientY);
1303
+ const columnIndex = getHoveredColumnIndex(api, clientX);
1304
+ if (rowIndex == null || columnIndex == null) return;
1305
+ const sx = api.getState();
1306
+ const active = sx.internal.cellEditActiveEdits.peek();
1307
+ const l = { rowIndex, columnIndex };
1308
+ const key = cellEditLocation(l);
1309
+ if (active.has(key)) return;
1310
+ api.cellEditBegin(l, true);
1311
+ }
1312
+ function CellEditDriver() {
1313
+ const { state, api } = useGrid();
1314
+ const viewport = state.internal.viewport.use();
1315
+ const cellEditActivator = state.cellEditPointerActivator.use();
1316
+ useEffect(() => {
1317
+ if (!viewport) return;
1318
+ const controller = new AbortController();
1319
+ const signal2 = controller.signal;
1320
+ if (cellEditActivator === "single-click") {
1321
+ viewport.addEventListener("pointerdown", (ev) => handleBeginCellEditFromEvent(api, ev), {
1322
+ signal: signal2
1323
+ });
1324
+ }
1325
+ if (cellEditActivator === "double-click") {
1326
+ viewport.addEventListener(
1327
+ "dblclick",
1328
+ (ev) => {
1329
+ if (state.internal.cellEditActiveEdits.peek().size > 0) return;
1330
+ handleBeginCellEditFromEvent(api, ev);
1331
+ },
1332
+ { signal: signal2 }
1333
+ );
1334
+ }
1335
+ return () => controller.abort();
1336
+ }, [
1337
+ api,
1338
+ cellEditActivator,
1339
+ state.columnsVisible,
1340
+ state.internal.cellEditActiveEdits,
1341
+ state.internal.cellEditActiveLocation,
1342
+ viewport
1343
+ ]);
1344
+ return /* @__PURE__ */ jsx(Fragment, {});
1345
+ }
1346
+ function RowHoverDriver() {
1347
+ const s3 = useGrid();
1348
+ const gridId = s3.state.gridId.use();
1349
+ const hoveredRow = s3.state.internal.hoveredRow.use();
1350
+ if (hoveredRow == null) return;
1351
+ return /* @__PURE__ */ jsx("style", { children: `
1352
+ #${gridId} > div > div > [aria-rowindex="${hoveredRow + 1}"] {
1353
+ background-color: var(--lng1771-gray-10);
1354
+ }
1355
+ ` });
1356
+ }
1357
+ function Viewport({
1358
+ children,
1359
+ ...els
1360
+ }) {
1361
+ const { state } = useGrid();
1362
+ const onSizeChange = useEvent((size) => {
1363
+ state.internal.viewportInnerHeight.set(size.innerHeight);
1364
+ state.internal.viewportInnerWidth.set(size.innerWidth);
1365
+ state.internal.viewportOuterWidth.set(size.outerWidth);
1366
+ state.internal.viewportOuterHeight.set(size.outerHeight);
1367
+ const el = state.internal.viewport.peek();
1368
+ if (el) {
1369
+ state.internal.viewportXScroll.set(Math.abs(el.scrollLeft));
1370
+ state.internal.viewportYScroll.set(Math.abs(el.scrollTop));
1371
+ state.internal.viewportInnerWidth.set(el.clientWidth);
1372
+ state.internal.viewportInnerHeight.set(el.clientHeight);
1373
+ }
1374
+ });
1375
+ const onInit = useEvent((_, size) => {
1376
+ onSizeChange(size);
1377
+ });
1378
+ const onScroll = useEvent(() => {
1379
+ const viewport = state.internal.viewport.peek();
1380
+ if (!viewport) return;
1381
+ state.internal.viewportXScroll.set(Math.abs(viewport.scrollLeft));
1382
+ state.internal.viewportYScroll.set(Math.abs(viewport.scrollTop));
1383
+ });
1384
+ const ref = useEvent((el) => {
1385
+ state.internal.viewport.set(el);
1386
+ });
1387
+ const paginate = state.paginate.use();
1388
+ const totalHeight = paginate ? void 0 : state.internal.rowPositions.use().at(-1);
1389
+ const totalWidth = state.columnPositions.use().at(-1);
1390
+ const rtl = state.rtl.use();
1391
+ const grid = state.gridId.use();
1392
+ return /* @__PURE__ */ jsxs(
1393
+ Sizer,
1394
+ {
1395
+ onInit,
1396
+ onSizeChange,
1397
+ onScroll,
1398
+ elRef: ref,
1399
+ style: { direction: rtl ? "rtl" : void 0 },
1400
+ id: grid,
1401
+ className: "lng1771-viewport",
1402
+ children: [
1403
+ /* @__PURE__ */ jsx(HeaderContainer, { style: { width: totalWidth } }),
1404
+ /* @__PURE__ */ jsx(RowContainer, { totalHeight, totalWidth, children: /* @__PURE__ */ jsx(Rows, { width: totalWidth, ...els }) }),
1405
+ /* @__PURE__ */ jsx(NavigationDriver, {}),
1406
+ /* @__PURE__ */ jsx(CellEditDriver, {}),
1407
+ /* @__PURE__ */ jsx(RowHoverDriver, {}),
1408
+ children
1409
+ ]
1410
+ }
1411
+ );
1412
+ }
1413
+ function getEditRows(locations, predicate) {
1414
+ const validLocations = Object.groupBy(
1415
+ [...locations].filter(([_, l]) => predicate(l)).map(([_, l]) => l),
1416
+ (l) => l.rowIndex
1417
+ );
1418
+ return Object.entries(validLocations);
1419
+ }
1420
+ function TextEditor({
1421
+ value,
1422
+ setValue,
1423
+ isValid,
1424
+ column
1425
+ }) {
1426
+ const opts = column.cellEditParams ?? {};
1427
+ return /* @__PURE__ */ jsx(
1428
+ Input,
1429
+ {
1430
+ error: !isValid,
1431
+ maxLength: opts.maxLength,
1432
+ className: "lng1771-cell__edit-input",
1433
+ value: `${value}`,
1434
+ onChange: (event) => setValue(event.target.value)
1435
+ }
1436
+ );
1437
+ }
1438
+ function NumberEditor({
1439
+ value,
1440
+ setValue,
1441
+ isValid,
1442
+ column
1443
+ }) {
1444
+ const opts = column.cellEditParams ?? {};
1445
+ return /* @__PURE__ */ jsx(
1446
+ Input,
1447
+ {
1448
+ type: "number",
1449
+ min: opts.min,
1450
+ max: opts.max,
1451
+ step: opts.step,
1452
+ error: !isValid,
1453
+ className: "lng1771-cell__edit-input",
1454
+ value: `${value ?? ""}`,
1455
+ onChange: (event) => setValue(Number.parseFloat(event.target.value))
1456
+ }
1457
+ );
1458
+ }
1459
+ function DateEditor({
1460
+ value,
1461
+ setValue,
1462
+ isValid,
1463
+ column
1464
+ }) {
1465
+ const opts = column.cellEditParams ?? {};
1466
+ return /* @__PURE__ */ jsx(
1467
+ Input,
1468
+ {
1469
+ type: "date",
1470
+ className: "lng1771-cell__edit-input",
1471
+ error: !isValid,
1472
+ min: opts.min,
1473
+ max: opts.max,
1474
+ value: String(value),
1475
+ onChange: (event) => setValue(event.target.value)
1476
+ }
1477
+ );
1478
+ }
1479
+ function getBuiltInEditorForType(c) {
1480
+ if (c.type === "number") return "number";
1481
+ if (c.type === "date") return "date";
1482
+ return "text";
1483
+ }
1484
+ function getCellEditor(api, c, base) {
1485
+ const editor = c.cellEditProvider ?? base.cellEditProvider ?? getBuiltInEditorForType(c);
1486
+ if (typeof editor === "string") {
1487
+ if (editor === "text") return TextEditor;
1488
+ if (editor === "date") return DateEditor;
1489
+ if (editor === "number") return NumberEditor;
1490
+ const cell = api.getState().cellEditProviders.peek()[editor];
1491
+ if (!cell) throw new Error(`No cell editor with id: ${editor} found.`);
1492
+ return cell;
1493
+ }
1494
+ return editor;
1495
+ }
1496
+ function useCellEditStyle(column, xPositions, yPositions, location) {
1497
+ const { state, api } = useGrid();
1498
+ const vpWidth = state.internal.viewportInnerWidth.use();
1499
+ const rtl = state.rtl.use();
1500
+ const style = useMemo(() => {
1501
+ const isStart = column.pin === "start";
1502
+ const isEnd = column.pin === "end";
1503
+ const root = getRootCell(api, location.rowIndex, location.columnIndex);
1504
+ const rowIndex = root?.rowIndex ?? location.rowIndex;
1505
+ const colIndex = root?.columnIndex ?? location.columnIndex;
1506
+ const rowSpan = root?.rowSpan ?? 1;
1507
+ const colSpan = root?.columnSpan ?? 1;
1508
+ const x2 = isEnd ? xPositions[colIndex] - xPositions.at(-1) + vpWidth : xPositions[colIndex];
1509
+ const height = sizeFromCoord(rowIndex, yPositions, rowSpan);
1510
+ const width = sizeFromCoord(colIndex, xPositions, colSpan);
1511
+ const rowCount = state.internal.rowCount.peek();
1512
+ const rowTopCount = state.internal.rowTopCount.peek();
1513
+ const rowBotCount = state.internal.rowBottomCount.peek();
1514
+ const firstBotIndex = rowCount - rowBotCount;
1515
+ const isTop = rowIndex < rowTopCount;
1516
+ const isBot = rowIndex >= rowCount - rowBotCount;
1517
+ let paginateOffset = 0;
1518
+ if (state.paginate.peek()) {
1519
+ const [rowStart] = api.paginateRowStartAndEndForPage(state.paginateCurrentPage.peek());
1520
+ paginateOffset = yPositions[rowStart];
1521
+ }
1522
+ const y2 = isBot ? yPositions[rowIndex] - yPositions[firstBotIndex] : isTop ? yPositions[rowIndex] : yPositions[rowIndex] - yPositions[rowTopCount] - paginateOffset;
1523
+ const transform = getTransform(x2 * (rtl ? -1 : 1), y2);
1524
+ const style2 = { width, height, transform, zIndex: 3 };
1525
+ if (isStart || isEnd) {
1526
+ style2.insetInlineStart = "0px";
1527
+ style2.position = "sticky";
1528
+ style2.zIndex = 5;
1529
+ }
1530
+ return style2;
1531
+ }, [
1532
+ api,
1533
+ column.pin,
1534
+ location.columnIndex,
1535
+ location.rowIndex,
1536
+ rtl,
1537
+ state.internal.rowBottomCount,
1538
+ state.internal.rowCount,
1539
+ state.internal.rowTopCount,
1540
+ state.paginate,
1541
+ state.paginateCurrentPage,
1542
+ vpWidth,
1543
+ xPositions,
1544
+ yPositions
1545
+ ]);
1546
+ return style;
1547
+ }
1548
+ function useCellEditNavigation(api, location) {
1549
+ const onKeyDown = useEvent((ev) => {
1550
+ const sx = api.getState();
1551
+ let handled = false;
1552
+ if (ev.key === "Escape") {
1553
+ api.cellEditEnd(location);
1554
+ handled = true;
1555
+ sx.internal.cellFocusQueue.set({
1556
+ kind: "cell",
1557
+ columnIndex: location.columnIndex,
1558
+ rowIndex: location.rowIndex
1559
+ });
1560
+ }
1561
+ const meta = ev.ctrlKey || ev.metaKey;
1562
+ if (ev.key === "Enter" && !meta) {
1563
+ const visible = sx.columnsVisible.peek();
1564
+ const columnIndex = location.columnIndex;
1565
+ const rowCount = sx.internal.rowCount.peek();
1566
+ let nextLocal = null;
1567
+ let currentRow = location.rowIndex;
1568
+ do {
1569
+ if (currentRow >= rowCount) break;
1570
+ const root = getRootCell(api, currentRow, columnIndex);
1571
+ currentRow = root ? root.rowIndex + root.rowSpan : currentRow + 1;
1572
+ const row = api.rowByIndex(currentRow);
1573
+ const isFull = sx.internal.rowIsFullWidthInternal.peek()(currentRow);
1574
+ if (!row) break;
1575
+ if (api.cellEditPredicate(row, visible[columnIndex]) && !isFull) {
1576
+ nextLocal = { rowIndex: currentRow, columnIndex };
1577
+ break;
1578
+ }
1579
+ } while (true);
1580
+ if (!nextLocal) {
1581
+ api.cellEditEnd(location);
1582
+ sx.internal.cellFocusQueue.set({
1583
+ kind: "cell",
1584
+ columnIndex: location.columnIndex,
1585
+ rowIndex: location.rowIndex
1586
+ });
1587
+ handled = true;
1588
+ } else {
1589
+ api.navigateScrollIntoView(nextLocal.rowIndex, nextLocal.columnIndex);
1590
+ api.cellEditBegin(nextLocal, true);
1591
+ handled = true;
1592
+ }
1593
+ }
1594
+ if (ev.key === "Enter" && meta) {
1595
+ api.cellEditEnd(location);
1596
+ sx.internal.cellFocusQueue.set({
1597
+ kind: "cell",
1598
+ columnIndex: location.columnIndex,
1599
+ rowIndex: location.rowIndex
1600
+ });
1601
+ }
1602
+ if (ev.key === "Tab") {
1603
+ const visible = sx.columnsVisible.peek();
1604
+ const row = api.rowByIndex(location.rowIndex);
1605
+ if (!row) return;
1606
+ const indices = visible.map((c, i) => api.cellEditPredicate(row, c) ? i : null).filter((c) => c !== null);
1607
+ const check = ev.shiftKey ? Math.min(...indices) : Math.max(...indices);
1608
+ if (check === location.columnIndex) {
1609
+ handled = true;
1610
+ } else {
1611
+ const currentIndex = indices.findIndex((c) => c === location.columnIndex);
1612
+ const next = ev.shiftKey ? indices[currentIndex - 1] : indices[currentIndex + 1];
1613
+ const nextLocation = { rowIndex: location.rowIndex, columnIndex: next };
1614
+ api.navigateScrollIntoView(nextLocation.rowIndex, nextLocation.columnIndex);
1615
+ api.cellEditBegin(nextLocation, true);
1616
+ }
1617
+ }
1618
+ if (handled) {
1619
+ ev.preventDefault();
1620
+ ev.stopPropagation();
1621
+ }
1622
+ });
1623
+ return onKeyDown;
1624
+ }
1625
+ function CellEditorCell({
1626
+ column,
1627
+ row,
1628
+ xPositions,
1629
+ yPositions,
1630
+ location,
1631
+ isActive
1632
+ }) {
1633
+ const { state, api } = useGrid();
1634
+ const style = useCellEditStyle(column, xPositions, yPositions, location);
1635
+ const Renderer = getCellEditor(api, column, state.columnBase.use());
1636
+ const values = state.internal.cellEditActiveEditValues.use();
1637
+ const value = values.get(cellEditLocation(location));
1638
+ const autoFocus = useCallback(
1639
+ (el) => {
1640
+ if (!isActive || !el) return;
1641
+ const focusable = getFocusableElements(el)[0];
1642
+ if (!focusable) return;
1643
+ setTimeout(() => {
1644
+ if (el.contains(document.activeElement)) return;
1645
+ focusable.focus();
1646
+ }, 20);
1647
+ },
1648
+ [isActive]
1649
+ );
1650
+ const setValue = useCallback(
1651
+ (v2) => {
1652
+ api.cellEditSetValue(location, v2);
1653
+ },
1654
+ [api, location]
1655
+ );
1656
+ const onKeyDown = useCellEditNavigation(api, location);
1657
+ return /* @__PURE__ */ jsx(
1658
+ "div",
1659
+ {
1660
+ ref: autoFocus,
1661
+ style,
1662
+ className: "lng1771-cell__edit",
1663
+ onFocus: () => {
1664
+ state.internal.cellEditActiveLocation.set(location);
1665
+ },
1666
+ onBlur: () => {
1667
+ if (state.internal.cellEditActiveEdits.peek().has(cellEditLocation(location)))
1668
+ api.cellEditEnd(location);
1669
+ state.internal.cellEditActiveLocation.set(null);
1670
+ },
1671
+ onKeyDown,
1672
+ children: /* @__PURE__ */ jsx(
1673
+ Renderer,
1674
+ {
1675
+ api,
1676
+ column,
1677
+ row,
1678
+ value,
1679
+ setValue,
1680
+ isValid: api.cellEditIsValueValid(location)
1681
+ }
1682
+ )
1683
+ }
1684
+ );
1685
+ }
1686
+ function CellEditorRow({ locations }) {
1687
+ const rowIndex = locations[0].rowIndex;
1688
+ const { state: s3, api } = useGrid();
1689
+ const xPositions = s3.columnPositions.use();
1690
+ const yPositions = s3.internal.rowPositions.use();
1691
+ const active = s3.internal.cellEditActiveLocation.use();
1692
+ const row = api.rowByIndex(rowIndex);
1693
+ const columns = s3.columnsVisible.use();
1694
+ if (!row) return null;
1695
+ return /* @__PURE__ */ jsx(Fragment, { children: locations.map((l) => {
1696
+ const columnIndex = l.columnIndex;
1697
+ const column = columns[columnIndex];
1698
+ return /* @__PURE__ */ jsx(
1699
+ CellEditorCell,
1700
+ {
1701
+ location: l,
1702
+ isActive: l.rowIndex === active?.rowIndex && l.columnIndex === active.columnIndex,
1703
+ column,
1704
+ row,
1705
+ xPositions,
1706
+ yPositions
1707
+ },
1708
+ column.id
1709
+ );
1710
+ }) });
1711
+ }
1712
+ function CellEditorTop() {
1713
+ const { state } = useGrid();
1714
+ const p2 = state.internal.cellEditActiveEdits.use();
1715
+ const topCount = state.internal.rowTopCount.use();
1716
+ const locations = useMemo(() => {
1717
+ return getEditRows(p2, (l) => l.rowIndex < topCount);
1718
+ }, [p2, topCount]);
1719
+ return /* @__PURE__ */ jsx(Fragment, { children: locations.map(([key, locations2]) => {
1720
+ return /* @__PURE__ */ jsx(CellEditorRow, { locations: locations2 }, key);
1721
+ }) });
1722
+ }
1723
+ function CellEditorCenter() {
1724
+ const { state } = useGrid();
1725
+ const yPositions = state.internal.rowPositions.use();
1726
+ const topCount = state.internal.rowTopCount.use();
1727
+ const p2 = state.internal.cellEditActiveEdits.use();
1728
+ const botCount = state.internal.rowBottomCount.use();
1729
+ const firstBotIndex = yPositions.length - 1 - botCount;
1730
+ const locations = useMemo(() => {
1731
+ return getEditRows(p2, (l) => l.rowIndex >= topCount && l.rowIndex < firstBotIndex);
1732
+ }, [firstBotIndex, p2, topCount]);
1733
+ return /* @__PURE__ */ jsx(Fragment, { children: locations.map(([key, locations2]) => {
1734
+ return /* @__PURE__ */ jsx(CellEditorRow, { locations: locations2 }, key);
1735
+ }) });
1736
+ }
1737
+ function CellEditorBottom() {
1738
+ const { state } = useGrid();
1739
+ const yPositions = state.internal.rowPositions.use();
1740
+ const p2 = state.internal.cellEditActiveEdits.use();
1741
+ const botCount = state.internal.rowBottomCount.use();
1742
+ const firstBotIndex = yPositions.length - 1 - botCount;
1743
+ const locations = useMemo(() => {
1744
+ return getEditRows(p2, (l) => l.rowIndex >= firstBotIndex);
1745
+ }, [firstBotIndex, p2]);
1746
+ return /* @__PURE__ */ jsx(Fragment, { children: locations.map(([key, locations2]) => {
1747
+ return /* @__PURE__ */ jsx(CellEditorRow, { locations: locations2 }, key);
1748
+ }) });
1749
+ }
1750
+ function useEdgeScroll(api) {
1751
+ const intervalIdX = useRef(null);
1752
+ const intervalIdY = useRef(null);
1753
+ const cancelX = useCallback(() => {
1754
+ if (intervalIdX.current) {
1755
+ clearInterval(intervalIdX.current);
1756
+ intervalIdX.current = null;
1757
+ }
1758
+ }, []);
1759
+ const cancelY = useCallback(() => {
1760
+ if (intervalIdY.current) {
1761
+ clearInterval(intervalIdY.current);
1762
+ intervalIdY.current = null;
1763
+ }
1764
+ }, []);
1765
+ const edgeScrollY = useCallback(
1766
+ (visualPositionY) => {
1767
+ const s3 = api.getState();
1768
+ const viewportClientHeight = s3.internal.viewportInnerHeight.peek();
1769
+ const viewport = s3.internal.viewport.peek();
1770
+ const viewportHeight = Math.min(viewportClientHeight * 0.1, 100);
1771
+ const buffer = viewportHeight;
1772
+ const topBound = buffer + s3.internal.viewportHeaderHeight.peek();
1773
+ const botBound = viewportClientHeight - buffer;
1774
+ const speed = 3;
1775
+ if (visualPositionY < topBound && !intervalIdY.current) {
1776
+ intervalIdY.current = setInterval(() => {
1777
+ viewport.scrollBy({ top: -speed });
1778
+ }, 6);
1779
+ } else if (visualPositionY > botBound && !intervalIdY.current) {
1780
+ intervalIdY.current = setInterval(() => {
1781
+ viewport.scrollBy({ top: speed });
1782
+ }, 6);
1783
+ }
1784
+ if (intervalIdY.current && visualPositionY > topBound && visualPositionY < botBound) {
1785
+ cancelY();
1786
+ }
1787
+ },
1788
+ [api, cancelY]
1789
+ );
1790
+ const edgeScrollX = useCallback(
1791
+ (visualPositionX, isRtl) => {
1792
+ const s3 = api.getState();
1793
+ const viewportClientWidth = s3.internal.viewportInnerWidth.peek();
1794
+ const viewport = s3.internal.viewport.peek();
1795
+ const viewportWidth = Math.min(viewportClientWidth * 0.1, 100);
1796
+ const buffer = viewportWidth;
1797
+ const leftBound = buffer;
1798
+ const rightBound = viewportClientWidth - buffer;
1799
+ const speed = 3;
1800
+ if (visualPositionX < leftBound && !intervalIdX.current) {
1801
+ intervalIdX.current = setInterval(() => {
1802
+ viewport.scrollBy({ left: isRtl ? speed : -speed });
1803
+ }, 6);
1804
+ } else if (visualPositionX > rightBound && !intervalIdX.current) {
1805
+ intervalIdX.current = setInterval(() => {
1806
+ viewport.scrollBy({ left: isRtl ? -speed : speed });
1807
+ }, 6);
1808
+ }
1809
+ if (intervalIdX.current && visualPositionX > leftBound && visualPositionX < rightBound) {
1810
+ cancelX();
1811
+ }
1812
+ },
1813
+ [api, cancelX]
1814
+ );
1815
+ return { cancelX, edgeScrollX, cancelY, edgeScrollY };
1816
+ }
1817
+ function splitCellSelectionRect({
1818
+ rect,
1819
+ colStartCount,
1820
+ colCenterCount,
1821
+ rowTopCount,
1822
+ rowCenterCount
1823
+ }) {
1824
+ const colStartBound = colStartCount;
1825
+ const colEndBound = colStartCount + colCenterCount;
1826
+ const colSplits = [];
1827
+ if (rect.columnStart < colStartBound && rect.columnEnd > colStartBound) {
1828
+ const startSplit = {
1829
+ ...rect,
1830
+ columnEnd: colStartBound
1831
+ };
1832
+ colSplits.push(startSplit);
1833
+ rect = { ...rect, columnStart: colStartBound };
1834
+ }
1835
+ if (rect.columnStart < colEndBound && rect.columnEnd > colEndBound) {
1836
+ const endSplit = {
1837
+ ...rect,
1838
+ columnStart: colEndBound
1839
+ };
1840
+ rect = { ...rect, columnEnd: colEndBound };
1841
+ colSplits.push(endSplit);
1842
+ }
1843
+ colSplits.push(rect);
1844
+ const topBound = rowTopCount;
1845
+ const bottomBound = rowTopCount + rowCenterCount;
1846
+ const rowSplits = [];
1847
+ for (let split of colSplits) {
1848
+ if (split.rowStart < topBound && split.rowEnd > topBound) {
1849
+ const topSplit = { ...split, rowEnd: topBound };
1850
+ split = { ...split, rowStart: topBound };
1851
+ rowSplits.push(topSplit);
1852
+ }
1853
+ if (split.rowStart < bottomBound && split.rowEnd > bottomBound) {
1854
+ const bottomSplit = { ...split, rowStart: bottomBound };
1855
+ split = { ...split, rowEnd: bottomBound };
1856
+ rowSplits.push(bottomSplit);
1857
+ }
1858
+ rowSplits.push(split);
1859
+ }
1860
+ return rowSplits.sort((l, r2) => {
1861
+ return l.rowStart - r2.rowStart || l.columnStart - r2.columnStart;
1862
+ });
1863
+ }
1864
+ function boundSelectionRect(api, rect) {
1865
+ const s3 = api.getState();
1866
+ const rowCount = s3.internal.rowCount.peek();
1867
+ const maxRow = rowCount;
1868
+ const minRow = 0;
1869
+ const maxColumn = s3.columnsVisible.peek().length;
1870
+ const minColumn = 0;
1871
+ const rowStartMaybe = clamp(minRow, rect.rowStart, maxRow);
1872
+ const rowEndMaybe = clamp(minRow, rect.rowEnd, maxRow);
1873
+ const colStartMaybe = clamp(minColumn, rect.columnStart, maxColumn);
1874
+ const colEndMaybe = clamp(minColumn, rect.columnEnd, maxColumn);
1875
+ const rowStart = Math.min(rowStartMaybe, rowEndMaybe);
1876
+ const rowEnd = Math.max(rowStartMaybe, rowEndMaybe);
1877
+ const columnStart = Math.min(colStartMaybe, colEndMaybe);
1878
+ const columnEnd = Math.max(colStartMaybe, colEndMaybe);
1879
+ return { rowStart, rowEnd, columnStart, columnEnd };
1880
+ }
1881
+ function areRectsEqual(left, right) {
1882
+ return left.rowStart === right.rowStart && left.rowEnd === right.rowEnd && left.columnStart === right.columnStart && left.columnEnd === right.columnEnd;
1883
+ }
1884
+ function isOverlappingRect(rect1, rect2) {
1885
+ return !(rect1.rowEnd < rect2.rowStart || rect1.rowStart > rect2.rowEnd || rect1.columnEnd < rect2.columnStart || rect1.columnStart > rect2.columnEnd);
1886
+ }
1887
+ function deselectRectRange(rect, deselectRect) {
1888
+ if (!isOverlappingRect(rect, deselectRect)) return [rect];
1889
+ const result = [];
1890
+ if (deselectRect.rowStart > rect.rowStart) {
1891
+ result.push({
1892
+ rowStart: rect.rowStart,
1893
+ rowEnd: deselectRect.rowStart,
1894
+ columnStart: rect.columnStart,
1895
+ columnEnd: rect.columnEnd
1896
+ });
1897
+ }
1898
+ if (deselectRect.rowEnd < rect.rowEnd) {
1899
+ result.push({
1900
+ rowStart: deselectRect.rowEnd,
1901
+ rowEnd: rect.rowEnd,
1902
+ columnStart: rect.columnStart,
1903
+ columnEnd: rect.columnEnd
1904
+ });
1905
+ }
1906
+ if (deselectRect.columnStart > rect.columnStart) {
1907
+ result.push({
1908
+ rowStart: Math.max(deselectRect.rowStart, rect.rowStart),
1909
+ rowEnd: Math.min(deselectRect.rowEnd, rect.rowEnd),
1910
+ columnStart: rect.columnStart,
1911
+ columnEnd: deselectRect.columnStart
1912
+ });
1913
+ }
1914
+ if (deselectRect.columnEnd < rect.columnEnd) {
1915
+ result.push({
1916
+ rowStart: Math.max(deselectRect.rowStart, rect.rowStart),
1917
+ rowEnd: Math.min(deselectRect.rowEnd, rect.rowEnd),
1918
+ columnStart: deselectRect.columnEnd,
1919
+ columnEnd: rect.columnEnd
1920
+ });
1921
+ }
1922
+ return result.filter(
1923
+ (rect2) => !(rect2.rowStart >= rect2.rowEnd || rect2.columnStart >= rect2.columnEnd)
1924
+ );
1925
+ }
1926
+ function adjustRectForRowAndCellSpan(api, rect) {
1927
+ let { rowStart, rowEnd, columnStart, columnEnd } = rect;
1928
+ for (let i = columnStart; i < columnEnd; i++) {
1929
+ let cell = getRootCell(api, rowStart, i);
1930
+ if (cell) {
1931
+ columnStart = Math.min(columnStart, cell.columnIndex);
1932
+ columnEnd = Math.max(columnEnd, cell.columnIndex + cell.columnSpan);
1933
+ rowStart = Math.min(rowStart, cell.rowIndex);
1934
+ rowEnd = Math.max(rowEnd, cell.rowIndex + cell.rowSpan);
1935
+ }
1936
+ cell = getRootCell(api, rowEnd - 1, i);
1937
+ if (cell) {
1938
+ columnStart = Math.min(columnStart, cell.columnIndex);
1939
+ columnEnd = Math.max(columnEnd, cell.columnIndex + cell.columnSpan);
1940
+ rowStart = Math.min(rowStart, cell.rowIndex);
1941
+ rowEnd = Math.max(rowEnd, cell.rowIndex + cell.rowSpan);
1942
+ }
1943
+ }
1944
+ for (let i = rowStart; i < rowEnd; i++) {
1945
+ let cell = getRootCell(api, i, columnStart);
1946
+ if (cell) {
1947
+ columnStart = Math.min(columnStart, cell.columnIndex);
1948
+ columnEnd = Math.max(columnEnd, cell.columnIndex + cell.columnSpan);
1949
+ rowStart = Math.min(rowStart, cell.rowIndex);
1950
+ rowEnd = Math.max(rowEnd, cell.rowIndex + cell.rowSpan);
1951
+ }
1952
+ cell = getRootCell(api, i, columnEnd - 1);
1953
+ if (cell) {
1954
+ columnStart = Math.min(columnStart, cell.columnIndex);
1955
+ columnEnd = Math.max(columnEnd, cell.columnIndex + cell.columnSpan);
1956
+ rowStart = Math.min(rowStart, cell.rowIndex);
1957
+ rowEnd = Math.max(rowEnd, cell.rowIndex + cell.rowSpan);
1958
+ }
1959
+ }
1960
+ return {
1961
+ rowStart,
1962
+ rowEnd,
1963
+ columnStart,
1964
+ columnEnd
1965
+ };
1966
+ }
1967
+ function updateAdditiveCellSelection(api, rect) {
1968
+ const s3 = api.getState();
1969
+ const rects = splitCellSelectionRect({
1970
+ rect: boundSelectionRect(api, adjustRectForRowAndCellSpan(api, rect)),
1971
+ colCenterCount: s3.columnVisibleCenterCount.peek(),
1972
+ colStartCount: s3.columnVisibleStartCount.peek(),
1973
+ rowCenterCount: s3.internal.rowCount.peek() - s3.internal.rowTopCount.peek() - s3.internal.rowBottomCount.peek(),
1974
+ rowTopCount: s3.internal.rowTopCount.peek()
1975
+ });
1976
+ const current = s3.internal.cellSelectionAdditiveRects.peek();
1977
+ if (current && current.length === rects.length) {
1978
+ if (current.every((c, i) => areRectsEqual(c, rects[i]))) return;
1979
+ }
1980
+ s3.internal.cellSelectionAdditiveRects.set(rects);
1981
+ }
1982
+ function isBottomRect(api, rect) {
1983
+ const s3 = api.getState();
1984
+ const bottomStart = s3.internal.rowCount.peek() - s3.internal.rowBottomCount.peek();
1985
+ return rect.rowStart >= bottomStart;
1986
+ }
1987
+ function isCenterRect(api, rect) {
1988
+ const s3 = api.getState();
1989
+ const bottomStart = s3.internal.rowCount.peek() - s3.internal.rowBottomCount.peek();
1990
+ return rect.rowStart < bottomStart && rect.rowStart >= s3.internal.rowTopCount.peek();
1991
+ }
1992
+ function isTopRect(api, rect) {
1993
+ const topCount = api.getState().internal.rowTopCount.peek();
1994
+ return rect.rowStart < topCount;
1995
+ }
1996
+ function isNormalClick(event) {
1997
+ return event.button === 0 && !event.ctrlKey && !event.altKey && !event.metaKey;
1998
+ }
1999
+ function CellSelectionDriver() {
2000
+ const { state, api } = useGrid$1();
2001
+ const viewport = state.internal.viewport.use();
2002
+ const mode = state.cellSelectionMode.use();
2003
+ const { cancelX, cancelY, edgeScrollX, edgeScrollY } = useEdgeScroll(api);
2004
+ useEffect(() => {
2005
+ if (!viewport || mode === "none" || mode === "single") {
2006
+ return;
2007
+ }
2008
+ const isMultiRange = mode === "multi-range";
2009
+ let isAdditive = false;
2010
+ let startSelection = null;
2011
+ let pointerStartX = 0;
2012
+ let pointerStartY = 0;
2013
+ let lastRect = null;
2014
+ let animFrame = null;
2015
+ const pointerMove = (event) => {
2016
+ if (animFrame) cancelAnimationFrame(animFrame);
2017
+ animFrame = requestAnimationFrame(() => {
2018
+ animFrame = null;
2019
+ const s3 = api.getState();
2020
+ const clientX = getClientX(event);
2021
+ const clientY = getClientY(event);
2022
+ const columnIndex = getHoveredColumnIndex(api, clientX);
2023
+ const rowIndex = getHoveredRowIndex(api, clientY);
2024
+ if (rowIndex == null || columnIndex == null) return;
2025
+ if (pointerStartX != null && pointerStartY != null) {
2026
+ const moveDeltaX = Math.abs(pointerStartX - clientX);
2027
+ const moveDeltaY = Math.abs(pointerStartY - clientY);
2028
+ if (moveDeltaX < 20 && moveDeltaY < 20) return;
2029
+ pointerStartX = null;
2030
+ pointerStartY = null;
2031
+ }
2032
+ if (!startSelection) return;
2033
+ const relativeX = getRelativeXPosition(viewport, clientX);
2034
+ const isRtl = s3.rtl.peek();
2035
+ const visualX = isRtl ? relativeX.right : relativeX.left;
2036
+ edgeScrollX(visualX, isRtl);
2037
+ const relativeY = getRelativeYPosition(viewport, clientY);
2038
+ edgeScrollY(relativeY.top);
2039
+ const topCount = s3.internal.rowTopCount.peek();
2040
+ const centerCount = s3.internal.rowCount.peek() - topCount - s3.internal.rowBottomCount.peek();
2041
+ const scrollY = s3.internal.viewport.peek().scrollTop;
2042
+ if (rowIndex < topCount && scrollY > 0) return;
2043
+ const maxScroll = viewport.scrollHeight - viewport.clientHeight - 4;
2044
+ if (rowIndex > topCount + centerCount - 1 && scrollY < maxScroll) return;
2045
+ const startCount = s3.columnVisibleStartCount.peek();
2046
+ const firstEnd = s3.columnVisibleCenterCount.peek() + startCount;
2047
+ const scrollX = Math.abs(s3.internal.viewport.peek().scrollLeft);
2048
+ if (columnIndex < startCount && scrollX > 0) return;
2049
+ const maxScrollX = viewport.scrollWidth - viewport.clientWidth - 4;
2050
+ if (columnIndex >= firstEnd && scrollX < maxScrollX) return;
2051
+ const startRow = rowIndex < startSelection.rowStart ? rowIndex : startSelection.rowStart;
2052
+ const endRow = rowIndex < startSelection.rowStart ? startSelection.rowEnd : rowIndex + 1;
2053
+ const startCol = columnIndex < startSelection.columnStart ? columnIndex : startSelection.columnStart;
2054
+ const endCol = columnIndex < startSelection.columnStart ? startSelection.columnEnd : columnIndex + 1;
2055
+ const active = [
2056
+ { rowStart: startRow, rowEnd: endRow, columnStart: startCol, columnEnd: endCol }
2057
+ ];
2058
+ if (isAdditive) {
2059
+ updateAdditiveCellSelection(api, active[0]);
2060
+ } else {
2061
+ s3.cellSelections.set(active);
2062
+ }
2063
+ lastRect = active[0];
2064
+ });
2065
+ };
2066
+ const pointerDown = (event) => {
2067
+ if (!isMultiRange && !isNormalClick(event)) {
2068
+ document.removeEventListener("pointermove", pointerMove);
2069
+ event.preventDefault();
2070
+ return;
2071
+ }
2072
+ const s3 = api.getState();
2073
+ const contextMenuOpen = !!s3.internal.contextMenuTarget.peek();
2074
+ const columnMenuOpen = !!s3.internal.columnMenuColumn.peek();
2075
+ const panelFrameOpen = !!s3.internal.panelFrameOpen.peek();
2076
+ const floatingFrameOpen = !!s3.internal.floatingFrameOpen.peek();
2077
+ if (contextMenuOpen || columnMenuOpen || panelFrameOpen || floatingFrameOpen) {
2078
+ document.removeEventListener("pointermove", pointerMove);
2079
+ return;
2080
+ }
2081
+ isAdditive = isMultiRange && (event.ctrlKey || event.metaKey);
2082
+ const clientX = getClientX(event);
2083
+ const clientY = getClientY(event);
2084
+ const columnIndex = getHoveredColumnIndex(api, clientX);
2085
+ const rowIndex = getHoveredRowIndex(api, clientY);
2086
+ if (columnIndex == null || rowIndex == null) {
2087
+ s3.cellSelections.set([]);
2088
+ s3.internal.cellSelectionPivot.set(null);
2089
+ return;
2090
+ }
2091
+ const isDeselect = isAdditive && api.cellSelectionIsSelected(rowIndex, columnIndex);
2092
+ pointerStartX = event.clientX;
2093
+ pointerStartY = event.clientY;
2094
+ startSelection = {
2095
+ columnStart: columnIndex,
2096
+ columnEnd: columnIndex + 1,
2097
+ rowStart: rowIndex,
2098
+ rowEnd: rowIndex + 1
2099
+ };
2100
+ const pivot = s3.internal.cellSelectionPivot.peek();
2101
+ if (event.shiftKey && pivot) {
2102
+ const active = { ...pivot };
2103
+ active.columnStart = Math.min(columnIndex, active.columnStart);
2104
+ active.columnEnd = Math.max(columnIndex + 1, active.columnEnd);
2105
+ active.rowStart = Math.min(rowIndex, active.rowStart);
2106
+ active.rowEnd = Math.max(rowIndex + 1, active.rowEnd);
2107
+ s3.cellSelections.set([active]);
2108
+ event.preventDefault();
2109
+ return;
2110
+ }
2111
+ if (mode === "multi-range" && (event.metaKey || event.ctrlKey)) {
2112
+ event.preventDefault();
2113
+ }
2114
+ s3.internal.cellSelectionPivot.set(startSelection);
2115
+ s3.internal.cellSelectionIsDeselect.set(isDeselect);
2116
+ if (isAdditive) {
2117
+ updateAdditiveCellSelection(api, startSelection);
2118
+ } else {
2119
+ s3.cellSelections.set([startSelection]);
2120
+ }
2121
+ lastRect = startSelection;
2122
+ document.addEventListener("pointermove", pointerMove);
2123
+ document.addEventListener("contextmenu", pointerUp);
2124
+ document.addEventListener("pointerup", pointerUp);
2125
+ };
2126
+ const pointerUp = () => {
2127
+ startSelection = null;
2128
+ if (isAdditive) {
2129
+ const s3 = api.getState();
2130
+ const isDeselect = s3.internal.cellSelectionIsDeselect.peek();
2131
+ const rects = isDeselect ? s3.cellSelections.peek().flatMap((r2) => deselectRectRange(r2, lastRect)) : [...s3.cellSelections.peek(), lastRect];
2132
+ s3.cellSelections.set(rects);
2133
+ s3.internal.cellSelectionAdditiveRects.set(null);
2134
+ s3.internal.cellSelectionIsDeselect.set(false);
2135
+ isAdditive = false;
2136
+ }
2137
+ cancelX();
2138
+ cancelY();
2139
+ document.removeEventListener("pointerup", pointerUp);
2140
+ document.removeEventListener("contextmenu", pointerUp);
2141
+ document.removeEventListener("pointermove", pointerMove);
2142
+ };
2143
+ viewport.addEventListener("pointerdown", pointerDown);
2144
+ const handleKey = (ev) => {
2145
+ const rtl = state.rtl.peek();
2146
+ const start = rtl ? "ArrowRight" : "ArrowLeft";
2147
+ const end = rtl ? "ArrowLeft" : "ArrowRight";
2148
+ if (!ev.shiftKey) return;
2149
+ let handled = false;
2150
+ if (ev.key === start) {
2151
+ api.cellSelectionExpandStart();
2152
+ handled = true;
2153
+ } else if (ev.key === end) {
2154
+ api.cellSelectionExpandEnd();
2155
+ handled = true;
2156
+ } else if (ev.key === "ArrowDown") {
2157
+ api.cellSelectionExpandDown();
2158
+ handled = true;
2159
+ } else if (ev.key === "ArrowUp") {
2160
+ api.cellSelectionExpandUp();
2161
+ handled = true;
2162
+ }
2163
+ if (handled) {
2164
+ ev.preventDefault();
2165
+ ev.stopPropagation();
2166
+ }
2167
+ };
2168
+ viewport.addEventListener("keydown", handleKey);
2169
+ return () => {
2170
+ viewport.removeEventListener("pointerdown", pointerDown);
2171
+ viewport.removeEventListener("keydown", handleKey);
2172
+ };
2173
+ }, [
2174
+ api,
2175
+ cancelX,
2176
+ cancelY,
2177
+ edgeScrollX,
2178
+ edgeScrollY,
2179
+ mode,
2180
+ state.cellSelections,
2181
+ state.internal.cellSelectionPivot,
2182
+ state.internal.navigatePosition,
2183
+ state.rtl,
2184
+ viewport
2185
+ ]);
2186
+ useEffect(() => {
2187
+ if (mode === "none" || !viewport) return;
2188
+ const controller = new AbortController();
2189
+ viewport.addEventListener(
2190
+ "keydown",
2191
+ (ev) => {
2192
+ const meta = ev.ctrlKey || ev.metaKey;
2193
+ if (ev.key === "c" && meta) {
2194
+ api.clipboardCopyCells();
2195
+ } else if (ev.key === "x" && meta) {
2196
+ api.clipboardCutCells();
2197
+ } else if (ev.key === "v" && meta) {
2198
+ api.clipboardPasteCells();
2199
+ }
2200
+ },
2201
+ { signal: controller.signal }
2202
+ );
2203
+ const unsub = state.internal.navigatePosition.watch(() => {
2204
+ const pos = state.internal.navigatePosition.peek();
2205
+ if (!pos) return;
2206
+ if (pos.kind !== GRID_CELL_POSITION) return state.cellSelections.set([]);
2207
+ else {
2208
+ const rect = adjustRectForRowAndCellSpan(api, {
2209
+ rowStart: pos.rowIndex,
2210
+ rowEnd: pos.rowIndex + 1,
2211
+ columnStart: pos.columnIndex,
2212
+ columnEnd: pos.columnIndex + 1
2213
+ });
2214
+ state.internal.cellSelectionPivot.set(rect);
2215
+ state.cellSelections.set([rect]);
2216
+ }
2217
+ });
2218
+ return () => {
2219
+ unsub();
2220
+ controller.abort();
2221
+ };
2222
+ }, [
2223
+ api,
2224
+ mode,
2225
+ state.cellSelections,
2226
+ state.internal.cellSelectionPivot,
2227
+ state.internal.navigatePosition,
2228
+ viewport
2229
+ ]);
2230
+ return /* @__PURE__ */ jsx(Fragment, {});
2231
+ }
2232
+ function CellStyleRow({
2233
+ rect,
2234
+ isRowPinnedTop,
2235
+ isDeselect,
2236
+ isRowPinnedBottom,
2237
+ isPivot
2238
+ }) {
2239
+ const { state, api } = useGrid$1();
2240
+ const xPositions = state.columnPositions.use();
2241
+ const yPositions = state.internal.rowPositions.use();
2242
+ const rtl = state.rtl.use();
2243
+ const flash = state.internal.cellSelectionFlashOn.use();
2244
+ const startCount = state.columnVisibleStartCount.use();
2245
+ const centerCount = state.columnVisibleCenterCount.use();
2246
+ const paginate = state.paginate.use();
2247
+ const currentPage = state.paginateCurrentPage.use();
2248
+ const rowCount = state.internal.rowCount.use();
2249
+ const rowTopCount = state.internal.rowTopCount.use();
2250
+ const rowBotCount = state.internal.rowBottomCount.use();
2251
+ const vpWidth = state.internal.viewportInnerWidth.use();
2252
+ const style = useMemo(() => {
2253
+ const isStart = rect.columnStart < startCount;
2254
+ const isEnd = rect.columnStart >= startCount + centerCount;
2255
+ const isTop = isRowPinnedTop;
2256
+ const isBot = isRowPinnedBottom;
2257
+ const columnIndex = rect.columnStart;
2258
+ const rowIndex = rect.rowStart;
2259
+ const width = sizeFromCoord(rect.columnStart, xPositions, rect.columnEnd - rect.columnStart);
2260
+ const height = sizeFromCoord(rect.rowStart, yPositions, rect.rowEnd - rect.rowStart);
2261
+ const firstBotIndex = rowCount - rowBotCount;
2262
+ let paginateOffset = 0;
2263
+ if (paginate) {
2264
+ const [rowStart] = api.paginateRowStartAndEndForPage(currentPage);
2265
+ paginateOffset = yPositions[rowStart];
2266
+ }
2267
+ const x2 = isEnd ? xPositions[columnIndex] - xPositions.at(-1) + vpWidth : xPositions[columnIndex];
2268
+ const y2 = isBot ? yPositions[rowIndex] - yPositions[firstBotIndex] : isTop ? yPositions[rowIndex] : yPositions[rowIndex] - yPositions[rowTopCount] - paginateOffset;
2269
+ const transform = getTransform(x2 * (rtl ? -1 : 1), y2);
2270
+ const style2 = { height, width, transform };
2271
+ if (isStart || isEnd) {
2272
+ style2.insetInlineStart = "0px";
2273
+ style2.position = "sticky";
2274
+ style2.zIndex = 2;
2275
+ }
2276
+ if (isTop || isBot) {
2277
+ style2.position = "sticky";
2278
+ style2.top = "0px";
2279
+ style2.zIndex = isStart ? 4 : 3;
2280
+ }
2281
+ return style2;
2282
+ }, [
2283
+ api,
2284
+ centerCount,
2285
+ currentPage,
2286
+ isRowPinnedBottom,
2287
+ isRowPinnedTop,
2288
+ paginate,
2289
+ rect.columnEnd,
2290
+ rect.columnStart,
2291
+ rect.rowEnd,
2292
+ rect.rowStart,
2293
+ rowBotCount,
2294
+ rowCount,
2295
+ rowTopCount,
2296
+ rtl,
2297
+ startCount,
2298
+ vpWidth,
2299
+ xPositions,
2300
+ yPositions
2301
+ ]);
2302
+ return /* @__PURE__ */ jsx(
2303
+ "div",
2304
+ {
2305
+ style,
2306
+ className: clsx(
2307
+ "lng1771-cell-selection",
2308
+ isDeselect && "lng1771-cell-selection--deselect",
2309
+ isPivot && "lng1771-cell-selection--pivot",
2310
+ flash && "lng1771-cell-selection--flash"
2311
+ )
2312
+ }
2313
+ );
2314
+ }
2315
+ const CellSelectionTop = memo(function CellSelectionTop2() {
2316
+ const { state, api } = useGrid$1();
2317
+ const allRects = state.internal.cellSelectionSplits.use();
2318
+ const topRects = useMemo(() => {
2319
+ return allRects.filter((rect) => isTopRect(api, rect));
2320
+ }, [allRects, api]);
2321
+ const mode = state.cellSelectionMode.use();
2322
+ const showPivot = mode === "multi-range" || mode === "range";
2323
+ const additive = state.internal.cellSelectionAdditiveRects.use();
2324
+ const isDeselect = state.internal.cellSelectionIsDeselect.use();
2325
+ const pivot = state.internal.cellSelectionPivot.use();
2326
+ const additiveRects = useMemo(() => {
2327
+ if (!additive) return [];
2328
+ return additive.filter((rect) => isTopRect(api, rect));
2329
+ }, [additive, api]);
2330
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2331
+ topRects.map((rect, i) => {
2332
+ return /* @__PURE__ */ jsx(CellStyleRow, { rect, isRowPinnedTop: true }, i);
2333
+ }),
2334
+ additiveRects.map((rect) => {
2335
+ return /* @__PURE__ */ jsx(CellStyleRow, { rect, isDeselect }, rect.columnStart);
2336
+ }),
2337
+ showPivot && pivot && isTopRect(api, pivot) && /* @__PURE__ */ jsx(CellStyleRow, { rect: pivot, isPivot: true, isRowPinnedTop: true })
2338
+ ] });
2339
+ });
2340
+ const CellSelectionCenter = memo(function CellSelectionCenter2() {
2341
+ const { state, api } = useGrid$1();
2342
+ const allRects = state.internal.cellSelectionSplits.use();
2343
+ const pivot = state.internal.cellSelectionPivot.use();
2344
+ const centerRects = useMemo(() => {
2345
+ return allRects.filter((rect) => isCenterRect(api, rect));
2346
+ }, [allRects, api]);
2347
+ const additive = state.internal.cellSelectionAdditiveRects.use();
2348
+ const isDeselect = state.internal.cellSelectionIsDeselect.use();
2349
+ const additiveRects = useMemo(() => {
2350
+ if (!additive) return [];
2351
+ return additive.filter((rect) => isCenterRect(api, rect));
2352
+ }, [additive, api]);
2353
+ const mode = state.cellSelectionMode.use();
2354
+ const showPivot = mode === "multi-range" || mode === "range";
2355
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2356
+ centerRects.map((rect, i) => {
2357
+ return /* @__PURE__ */ jsx(CellStyleRow, { rect }, i);
2358
+ }),
2359
+ additiveRects.map((rect) => {
2360
+ return /* @__PURE__ */ jsx(CellStyleRow, { rect, isDeselect }, rect.columnStart);
2361
+ }),
2362
+ showPivot && pivot && isCenterRect(api, pivot) && /* @__PURE__ */ jsx(CellStyleRow, { rect: pivot, isPivot: true })
2363
+ ] });
2364
+ });
2365
+ const CellSelectionBottom = memo(function CellSelectionBottom2() {
2366
+ const { state, api } = useGrid$1();
2367
+ const allRects = state.internal.cellSelectionSplits.use();
2368
+ const pivot = state.internal.cellSelectionPivot.use();
2369
+ const bottomRects = useMemo(() => {
2370
+ return allRects.filter((rect) => isBottomRect(api, rect));
2371
+ }, [allRects, api]);
2372
+ const additive = state.internal.cellSelectionAdditiveRects.use();
2373
+ const isDeselect = state.internal.cellSelectionIsDeselect.use();
2374
+ const additiveRects = useMemo(() => {
2375
+ if (!additive) return [];
2376
+ return additive.filter((rect) => isBottomRect(api, rect));
2377
+ }, [additive, api]);
2378
+ const mode = state.cellSelectionMode.use();
2379
+ const showPivot = mode === "multi-range" || mode === "range";
2380
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2381
+ bottomRects.map((rect, i) => {
2382
+ return /* @__PURE__ */ jsx(CellStyleRow, { rect, isRowPinnedBottom: true }, i);
2383
+ }),
2384
+ additiveRects.map((rect) => {
2385
+ return /* @__PURE__ */ jsx(CellStyleRow, { rect, isDeselect }, rect.columnStart);
2386
+ }),
2387
+ showPivot && pivot && isBottomRect(api, pivot) && /* @__PURE__ */ jsx(CellStyleRow, { rect: pivot, isPivot: true, isRowPinnedBottom: true })
2388
+ ] });
2389
+ });
2390
+ const hashSalt = "faec0f3c45281b1fe12d87e64a6c3271";
2391
+ const issueDate = /* @__PURE__ */ new Date("2025-01-26");
2392
+ function getHostname() {
2393
+ const win = globalThis?.document?.defaultView || (typeof window !== "undefined" ? window : null);
2394
+ const loc = win?.location;
2395
+ const { hostname = "" } = loc ?? {};
2396
+ return hostname;
2397
+ }
2398
+ function isWebsiteUrl() {
2399
+ const hostname = getHostname();
2400
+ return hostname.match(/^((?:\w+\.)?1771technologies\.com)$/) !== null;
2401
+ }
2402
+ function isLocalhost() {
2403
+ const hostname = getHostname();
2404
+ return hostname.match(/^(?:127\.0\.0\.1|localhost)$/) !== null;
2405
+ }
2406
+ let hasAValidLicense = isWebsiteUrl() || isLocalhost();
2407
+ function activateLicense(license) {
2408
+ const parts = license.split("|");
2409
+ const details = parts[0];
2410
+ const hash = parts[1];
2411
+ const detailHash = new MD5().md5(details + hashSalt);
2412
+ if (detailHash !== hash) {
2413
+ console.error(
2414
+ `
2415
+ ********************************************************************************
2416
+ INVALID LICENSE KEY SUPPLIED
2417
+
2418
+ The license key you provided is not a valid LyteNyte Grid license key. If you
2419
+ purchased a valid license from 1771 Technologies, please reach out to
2420
+ our dedicated support email support@1771technologies.com.
2421
+
2422
+ If you are interested in purchasing a valid license, please
2423
+ visit https://1771technolgies.com
2424
+ ********************************************************************************
2425
+ `
2426
+ );
2427
+ return false;
2428
+ }
2429
+ const detailParts = details.split(" ");
2430
+ const endDate = new Date(detailParts[1]);
2431
+ if (issueDate > endDate) {
2432
+ console.error(`
2433
+ ********************************************************************************
2434
+ LICENSE EXPIRED
2435
+
2436
+ The license provided is a valid LyteNyte license, however it is not valid for the
2437
+ current version of LyteNyte Grid being used. Please renew your license or use
2438
+ the fallback version valid under your license.
2439
+
2440
+ To purchase a new license or learn more about which versions your license is valid
2441
+ for please visit https://1771technologies.com.
2442
+ ********************************************************************************
2443
+ `);
2444
+ return false;
2445
+ }
2446
+ hasAValidLicense = true;
2447
+ return true;
2448
+ }
2449
+ class MD5 {
2450
+ md5cycle(x2, k) {
2451
+ let a = x2[0];
2452
+ let b = x2[1];
2453
+ let c = x2[2];
2454
+ let d = x2[3];
2455
+ a = this.ff(a, b, c, d, k[0], 7, -680876936);
2456
+ d = this.ff(d, a, b, c, k[1], 12, -389564586);
2457
+ c = this.ff(c, d, a, b, k[2], 17, 606105819);
2458
+ b = this.ff(b, c, d, a, k[3], 22, -1044525330);
2459
+ a = this.ff(a, b, c, d, k[4], 7, -176418897);
2460
+ d = this.ff(d, a, b, c, k[5], 12, 1200080426);
2461
+ c = this.ff(c, d, a, b, k[6], 17, -1473231341);
2462
+ b = this.ff(b, c, d, a, k[7], 22, -45705983);
2463
+ a = this.ff(a, b, c, d, k[8], 7, 1770035416);
2464
+ d = this.ff(d, a, b, c, k[9], 12, -1958414417);
2465
+ c = this.ff(c, d, a, b, k[10], 17, -42063);
2466
+ b = this.ff(b, c, d, a, k[11], 22, -1990404162);
2467
+ a = this.ff(a, b, c, d, k[12], 7, 1804603682);
2468
+ d = this.ff(d, a, b, c, k[13], 12, -40341101);
2469
+ c = this.ff(c, d, a, b, k[14], 17, -1502002290);
2470
+ b = this.ff(b, c, d, a, k[15], 22, 1236535329);
2471
+ a = this.gg(a, b, c, d, k[1], 5, -165796510);
2472
+ d = this.gg(d, a, b, c, k[6], 9, -1069501632);
2473
+ c = this.gg(c, d, a, b, k[11], 14, 643717713);
2474
+ b = this.gg(b, c, d, a, k[0], 20, -373897302);
2475
+ a = this.gg(a, b, c, d, k[5], 5, -701558691);
2476
+ d = this.gg(d, a, b, c, k[10], 9, 38016083);
2477
+ c = this.gg(c, d, a, b, k[15], 14, -660478335);
2478
+ b = this.gg(b, c, d, a, k[4], 20, -405537848);
2479
+ a = this.gg(a, b, c, d, k[9], 5, 568446438);
2480
+ d = this.gg(d, a, b, c, k[14], 9, -1019803690);
2481
+ c = this.gg(c, d, a, b, k[3], 14, -187363961);
2482
+ b = this.gg(b, c, d, a, k[8], 20, 1163531501);
2483
+ a = this.gg(a, b, c, d, k[13], 5, -1444681467);
2484
+ d = this.gg(d, a, b, c, k[2], 9, -51403784);
2485
+ c = this.gg(c, d, a, b, k[7], 14, 1735328473);
2486
+ b = this.gg(b, c, d, a, k[12], 20, -1926607734);
2487
+ a = this.hh(a, b, c, d, k[5], 4, -378558);
2488
+ d = this.hh(d, a, b, c, k[8], 11, -2022574463);
2489
+ c = this.hh(c, d, a, b, k[11], 16, 1839030562);
2490
+ b = this.hh(b, c, d, a, k[14], 23, -35309556);
2491
+ a = this.hh(a, b, c, d, k[1], 4, -1530992060);
2492
+ d = this.hh(d, a, b, c, k[4], 11, 1272893353);
2493
+ c = this.hh(c, d, a, b, k[7], 16, -155497632);
2494
+ b = this.hh(b, c, d, a, k[10], 23, -1094730640);
2495
+ a = this.hh(a, b, c, d, k[13], 4, 681279174);
2496
+ d = this.hh(d, a, b, c, k[0], 11, -358537222);
2497
+ c = this.hh(c, d, a, b, k[3], 16, -722521979);
2498
+ b = this.hh(b, c, d, a, k[6], 23, 76029189);
2499
+ a = this.hh(a, b, c, d, k[9], 4, -640364487);
2500
+ d = this.hh(d, a, b, c, k[12], 11, -421815835);
2501
+ c = this.hh(c, d, a, b, k[15], 16, 530742520);
2502
+ b = this.hh(b, c, d, a, k[2], 23, -995338651);
2503
+ a = this.ii(a, b, c, d, k[0], 6, -198630844);
2504
+ d = this.ii(d, a, b, c, k[7], 10, 1126891415);
2505
+ c = this.ii(c, d, a, b, k[14], 15, -1416354905);
2506
+ b = this.ii(b, c, d, a, k[5], 21, -57434055);
2507
+ a = this.ii(a, b, c, d, k[12], 6, 1700485571);
2508
+ d = this.ii(d, a, b, c, k[3], 10, -1894986606);
2509
+ c = this.ii(c, d, a, b, k[10], 15, -1051523);
2510
+ b = this.ii(b, c, d, a, k[1], 21, -2054922799);
2511
+ a = this.ii(a, b, c, d, k[8], 6, 1873313359);
2512
+ d = this.ii(d, a, b, c, k[15], 10, -30611744);
2513
+ c = this.ii(c, d, a, b, k[6], 15, -1560198380);
2514
+ b = this.ii(b, c, d, a, k[13], 21, 1309151649);
2515
+ a = this.ii(a, b, c, d, k[4], 6, -145523070);
2516
+ d = this.ii(d, a, b, c, k[11], 10, -1120210379);
2517
+ c = this.ii(c, d, a, b, k[2], 15, 718787259);
2518
+ b = this.ii(b, c, d, a, k[9], 21, -343485551);
2519
+ x2[0] = this.add32(a, x2[0]);
2520
+ x2[1] = this.add32(b, x2[1]);
2521
+ x2[2] = this.add32(c, x2[2]);
2522
+ x2[3] = this.add32(d, x2[3]);
2523
+ }
2524
+ cmn(q2, a, b, x2, s3, t2) {
2525
+ a = this.add32(this.add32(a, q2), this.add32(x2, t2));
2526
+ return this.add32(a << s3 | a >>> 32 - s3, b);
2527
+ }
2528
+ ff(a, b, c, d, x2, s3, t2) {
2529
+ return this.cmn(b & c | ~b & d, a, b, x2, s3, t2);
2530
+ }
2531
+ gg(a, b, c, d, x2, s3, t2) {
2532
+ return this.cmn(b & d | c & ~d, a, b, x2, s3, t2);
2533
+ }
2534
+ hh(a, b, c, d, x2, s3, t2) {
2535
+ return this.cmn(b ^ c ^ d, a, b, x2, s3, t2);
2536
+ }
2537
+ ii(a, b, c, d, x2, s3, t2) {
2538
+ return this.cmn(c ^ (b | ~d), a, b, x2, s3, t2);
2539
+ }
2540
+ md51(s3) {
2541
+ const n = s3.length;
2542
+ const state = [1732584193, -271733879, -1732584194, 271733878];
2543
+ let i;
2544
+ for (i = 64; i <= s3.length; i += 64) {
2545
+ this.md5cycle(state, this.md5blk(s3.substring(i - 64, i)));
2546
+ }
2547
+ s3 = s3.substring(i - 64);
2548
+ const tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
2549
+ for (i = 0; i < s3.length; i++) {
2550
+ tail[i >> 2] |= s3.charCodeAt(i) << (i % 4 << 3);
2551
+ }
2552
+ tail[i >> 2] |= 128 << (i % 4 << 3);
2553
+ if (i > 55) {
2554
+ this.md5cycle(state, tail);
2555
+ for (i = 0; i < 16; i++) {
2556
+ tail[i] = 0;
2557
+ }
2558
+ }
2559
+ tail[14] = n * 8;
2560
+ this.md5cycle(state, tail);
2561
+ return state;
2562
+ }
2563
+ /* there needs to be support for Unicode here, * unless we pretend that we can redefine the MD-5
2564
+ * algorithm for multi-byte characters (perhaps by adding every four 16-bit characters and
2565
+ * shortening the sum to 32 bits). Otherwise I suthis.ggest performing MD-5 as if every character
2566
+ * was two bytes--e.g., 0040 0025 = @%--but then how will an ordinary MD-5 sum be matched?
2567
+ * There is no way to standardize text to something like UTF-8 before transformation; speed cost is
2568
+ * utterly prohibitive. The JavaScript standard itself needs to look at this: it should start
2569
+ * providing access to strings as preformed UTF-8 8-bit unsigned value arrays.
2570
+ */
2571
+ md5blk(s3) {
2572
+ const md5blks = [];
2573
+ for (let i = 0; i < 64; i += 4) {
2574
+ md5blks[i >> 2] = s3.charCodeAt(i) + (s3.charCodeAt(i + 1) << 8) + (s3.charCodeAt(i + 2) << 16) + (s3.charCodeAt(i + 3) << 24);
2575
+ }
2576
+ return md5blks;
2577
+ }
2578
+ rhex(n) {
2579
+ const hex_chr = "0123456789abcdef".split("");
2580
+ let s3 = "";
2581
+ let j = 0;
2582
+ for (; j < 4; j++) {
2583
+ s3 += hex_chr[n >> j * 8 + 4 & 15] + hex_chr[n >> j * 8 & 15];
2584
+ }
2585
+ return s3;
2586
+ }
2587
+ hex(x2) {
2588
+ for (let i = 0; i < x2.length; i++) {
2589
+ x2[i] = this.rhex(x2[i]);
2590
+ }
2591
+ return x2.join("");
2592
+ }
2593
+ md5(s3) {
2594
+ return this.hex(this.md51(s3));
2595
+ }
2596
+ add32(a, b) {
2597
+ return this.add32Std(a, b);
2598
+ }
2599
+ add32Std(a, b) {
2600
+ return a + b & 4294967295;
2601
+ }
2602
+ }
2603
+ const s2 = cascada(() => {
2604
+ return {
2605
+ showing: signal(null)
2606
+ };
2607
+ });
2608
+ function Watermark({
2609
+ id
2610
+ }) {
2611
+ const showing = s2.showing.use();
2612
+ const [mountable, setMountable] = useState(false);
2613
+ useEffect(() => {
2614
+ setMountable(true);
2615
+ }, []);
2616
+ useEffect(() => {
2617
+ if (showing && showing === id) s2.showing.set(id);
2618
+ return () => s2.showing.set(null);
2619
+ });
2620
+ useEffect(() => {
2621
+ if (hasAValidLicense) return;
2622
+ console.log(`
2623
+ ********************************************************************************
2624
+ No valid license was detected for the version of LyteNyte Grid being used.
2625
+
2626
+ If you are only evaluating LyteNyte Grid you do not need to purchase license.
2627
+
2628
+ For commercial use a license for developers must be purchased.
2629
+
2630
+ Please visit https://1771technologies.com to learn more.
2631
+ ********************************************************************************
2632
+ `);
2633
+ }, []);
2634
+ if (!mountable) return null;
2635
+ if (hasAValidLicense) return null;
2636
+ if (showing && showing !== id) return null;
2637
+ if (typeof document === "undefined") return null;
2638
+ setTimeout(() => {
2639
+ s2.showing.set(id);
2640
+ });
2641
+ return createPortal(/* @__PURE__ */ jsx("div", {
2642
+ className: "c7kkngm",
2643
+ children: /* @__PURE__ */ jsx("div", {
2644
+ children: /* @__PURE__ */ jsxs("div", {
2645
+ style: {
2646
+ fontWeight: "bolder",
2647
+ fontSize: "1.25rem"
2648
+ },
2649
+ children: ["LyteNyte Grid for evaluation only.", /* @__PURE__ */ jsx("a", {
2650
+ style: {
2651
+ color: "blue"
2652
+ },
2653
+ href: "https://1771Technologies.com/pricing",
2654
+ children: "Click here"
2655
+ }), " ", "to secure your license."]
2656
+ })
2657
+ })
2658
+ }), document.body);
2659
+ }
2660
+ function LoadingOverlay() {
2661
+ return /* @__PURE__ */ jsx("div", { className: "lng1771-loading-overlay", children: /* @__PURE__ */ jsx("div", { className: "lng1771-loading-overlay__container", children: "Loading..." }) });
2662
+ }
2663
+ function NoDataOverlay() {
2664
+ return /* @__PURE__ */ jsx("div", { className: "lng1771-no-data-overlay", children: /* @__PURE__ */ jsx("div", { className: "lng1771-no-data-overlay__container", children: "No Data" }) });
2665
+ }
2666
+ function LoadErrorOverlay() {
2667
+ const { state, api } = useGrid$1();
2668
+ return /* @__PURE__ */ jsx("div", { className: "lng1771-loading-error-overlay", children: /* @__PURE__ */ jsxs("div", { className: "lng1771-loading-error-overlay__container", children: [
2669
+ /* @__PURE__ */ jsx("div", { children: "Loading data from external source failed." }),
2670
+ /* @__PURE__ */ jsx(
2671
+ GridButton,
2672
+ {
2673
+ onClick: () => {
2674
+ state.overlayToShow.set(null);
2675
+ api.rowReload();
2676
+ },
2677
+ style: { marginInlineStart: 4 },
2678
+ children: "Retry?"
2679
+ }
2680
+ )
2681
+ ] }) });
2682
+ }
2683
+ function OverlayDriver() {
2684
+ const { state, api } = useGrid$1();
2685
+ const headerHeight = state.internal.viewportHeaderHeight.use();
2686
+ const overlayId = state.overlayToShow.use();
2687
+ const overlays = state.overlays.use();
2688
+ const width = state.internal.viewportInnerWidth.use();
2689
+ const height = state.internal.viewportInnerHeight.use();
2690
+ if (!overlayId) return;
2691
+ let overlay = overlays[overlayId];
2692
+ if (!overlay && overlayId === "lng1771-loading-overlay") overlay = { renderer: LoadingOverlay };
2693
+ if (!overlay && overlayId === "lng1771-load-error-overlay")
2694
+ overlay = { renderer: LoadErrorOverlay, overRows: true };
2695
+ if (!overlay && overlayId === "lng1771-no-data-overlay")
2696
+ overlay = { renderer: NoDataOverlay, overRows: true };
2697
+ const rowsOnly = !!overlay.overRows;
2698
+ return /* @__PURE__ */ jsx(
2699
+ "div",
2700
+ {
2701
+ style: { position: "sticky", width: 0, height: 0, insetInlineStart: 0, top: 0, zIndex: 20 },
2702
+ children: /* @__PURE__ */ jsx(
2703
+ "div",
2704
+ {
2705
+ onPointerDown: (e) => {
2706
+ e.stopPropagation();
2707
+ },
2708
+ onKeyDown: (e) => {
2709
+ e.stopPropagation();
2710
+ },
2711
+ className: "lng1771-overlay",
2712
+ style: {
2713
+ height: rowsOnly ? height - headerHeight : height,
2714
+ width,
2715
+ top: rowsOnly ? headerHeight : void 0
2716
+ },
2717
+ children: /* @__PURE__ */ jsx(overlay.renderer, { api })
2718
+ }
2719
+ )
2720
+ }
2721
+ );
2722
+ }
2723
+ const emptyBB = {
2724
+ getBoundingClientRect: () => ({
2725
+ x: 0,
2726
+ y: 0,
2727
+ width: 0,
2728
+ height: 0,
2729
+ top: 0,
2730
+ bottom: 0,
2731
+ left: 0,
2732
+ right: 0,
2733
+ toJSON: () => ""
2734
+ })
2735
+ };
2736
+ function ColumnMenuDriver() {
2737
+ const grid = useGrid$1();
2738
+ const menuColumn = grid.state.internal.columnMenuColumn.use();
2739
+ const target = grid.state.internal.columnMenuTarget.use();
2740
+ const MenuRenderer = grid.state.columnMenuRenderer.use();
2741
+ const [open, setOpen] = useState(false);
2742
+ useEffect(() => {
2743
+ if (menuColumn == null || target == null) {
2744
+ setOpen(false);
2745
+ return;
2746
+ }
2747
+ setOpen(true);
2748
+ }, [menuColumn, target]);
2749
+ return /* @__PURE__ */ jsx(
2750
+ MenuRoot,
2751
+ {
2752
+ open,
2753
+ onOpenChange: (c) => {
2754
+ setOpen(c);
2755
+ },
2756
+ onOpenChangeComplete: (c) => {
2757
+ if (!c) grid.api.columnMenuClose();
2758
+ },
2759
+ children: /* @__PURE__ */ jsx(MenuPortal, { children: /* @__PURE__ */ jsx(
2760
+ MenuPositioner,
2761
+ {
2762
+ anchor: target ? "getBoundingClientRect" in target ? target : {
2763
+ getBoundingClientRect: () => ({
2764
+ x: target.x,
2765
+ y: target.y,
2766
+ width: target.width,
2767
+ height: target.height,
2768
+ top: target.y,
2769
+ left: target.x,
2770
+ bottom: target.y,
2771
+ right: target.x,
2772
+ toJSON: () => ""
2773
+ })
2774
+ } : emptyBB,
2775
+ children: MenuRenderer && menuColumn && /* @__PURE__ */ jsx(MenuRenderer, { api: grid.api, column: menuColumn })
2776
+ }
2777
+ ) })
2778
+ }
2779
+ );
2780
+ }
2781
+ function GridFrame({
2782
+ grid: { api, state },
2783
+ children,
2784
+ axe
2785
+ }) {
2786
+ const buttons = state.panelFrameButtons.use();
2787
+ const frames = state.panelFrames.use();
2788
+ const openId = state.internal.panelFrameOpen.use();
2789
+ const frame = openId ? frames[openId] : null;
2790
+ const [frameSplit, setFrameSplit] = useState(70);
2791
+ const template = useMemo(() => {
2792
+ const f = ["1fr"];
2793
+ if (buttons.length) f.push("32px");
2794
+ return f.join(" ");
2795
+ }, [buttons.length]);
2796
+ const cellSelectionEnabled = state.cellSelectionMode.use() !== "none";
2797
+ return /* @__PURE__ */ jsxs(
2798
+ "div",
2799
+ {
2800
+ "data-lng1771-cell-selection-enabled": cellSelectionEnabled ? true : void 0,
2801
+ className: "lng1771-grid-frame",
2802
+ style: { gridTemplateColumns: template },
2803
+ children: [
2804
+ frame ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
2805
+ SplitPane,
2806
+ {
2807
+ axe: axe ?? splitPaneAxe,
2808
+ orientation: "vertical",
2809
+ primary: /* @__PURE__ */ jsx("div", { className: "lng1771-grid-frame__grid-area", children }),
2810
+ secondary: /* @__PURE__ */ jsx(Sizer, { className: "lng1771-grid-frame__open-panel", children: /* @__PURE__ */ jsx(frame.component, { api, frame }) }),
2811
+ split: frame ? frameSplit : 100,
2812
+ onSplitChange: (n) => setFrameSplit(n),
2813
+ min: 20,
2814
+ max: 80,
2815
+ splitterClassName: "lng1771-grid-frame__open-panel--splitter"
2816
+ }
2817
+ ) }) : /* @__PURE__ */ jsx("div", { children }),
2818
+ buttons.length > 0 && /* @__PURE__ */ jsx("div", { className: "lng1771-grid-frame__controls", children: buttons.map((c) => {
2819
+ const isActive = c.id === openId;
2820
+ return /* @__PURE__ */ jsxs(
2821
+ "button",
2822
+ {
2823
+ onClick: () => {
2824
+ if (isActive) api.panelFrameClose();
2825
+ else api.panelFrameOpen(c.id);
2826
+ },
2827
+ className: clsx(
2828
+ "lng1771-grid-frame__control-button",
2829
+ c.id === openId && "lng1771-grid-frame__control-button--open"
2830
+ ),
2831
+ children: [
2832
+ /* @__PURE__ */ jsx("span", { className: "lng1771-grid-frame__control-button-icon", children: c.icon && /* @__PURE__ */ jsx(c.icon, {}) }),
2833
+ /* @__PURE__ */ jsx("span", { children: c.label })
2834
+ ]
2835
+ },
2836
+ c.id
2837
+ );
2838
+ }) })
2839
+ ]
2840
+ }
2841
+ );
2842
+ }
2843
+ function useContextMenuListener(setMenu) {
2844
+ const grid = useGrid$1();
2845
+ const viewport = grid.state.internal.viewport.use();
2846
+ const menuRenderer = grid.state.contextMenuRenderer.use();
2847
+ const target = grid.state.internal.contextMenuTarget.use();
2848
+ useEffect(() => {
2849
+ if (!viewport || !menuRenderer) return;
2850
+ const controller = new AbortController();
2851
+ viewport.addEventListener(
2852
+ "contextmenu",
2853
+ (e) => {
2854
+ if (e.ctrlKey || e.metaKey) return;
2855
+ if (target) {
2856
+ e.preventDefault();
2857
+ e.stopPropagation();
2858
+ return;
2859
+ }
2860
+ const x2 = getClientX(e);
2861
+ const hoveredCell = getHoveredColumnIndex(grid.api, x2);
2862
+ const y2 = getClientY(e);
2863
+ const hoveredRow = getHoveredRowIndex(grid.api, y2);
2864
+ let menuTarget = hoveredRow != null ? "cell" : null;
2865
+ if (hoveredRow == null) {
2866
+ let current = e.target;
2867
+ while (current && current.getAttribute("data-lng1771-kind") == null && current !== viewport) {
2868
+ current = current.parentElement;
2869
+ }
2870
+ if (current && current !== viewport) {
2871
+ const kind = current.getAttribute("data-lng1771-kind");
2872
+ if (kind === "floating") menuTarget = "header-floating";
2873
+ if (kind === "header") menuTarget = "header";
2874
+ if (kind === "header-group") menuTarget = "header-group";
2875
+ }
2876
+ }
2877
+ if (!menuTarget || hoveredCell == null) {
2878
+ setMenu(null);
2879
+ return;
2880
+ }
2881
+ setMenu({
2882
+ menuTarget,
2883
+ hoveredRow,
2884
+ hoveredColumn: hoveredCell
2885
+ });
2886
+ e.stopPropagation();
2887
+ e.preventDefault();
2888
+ const cellSelectionMode = grid.state.cellSelectionMode.peek();
2889
+ if (menuTarget === "cell" && cellSelectionMode !== "none" && !grid.api.cellSelectionIsSelected(hoveredRow, hoveredCell)) {
2890
+ grid.state.cellSelections.set([
2891
+ {
2892
+ rowStart: hoveredRow,
2893
+ rowEnd: hoveredRow + 1,
2894
+ columnStart: hoveredCell,
2895
+ columnEnd: hoveredCell + 1
2896
+ }
2897
+ ]);
2898
+ }
2899
+ grid.state.internal.contextMenuTarget.set({ x: x2, y: y2, width: 1, height: 1 });
2900
+ },
2901
+ { signal: controller.signal }
2902
+ );
2903
+ return () => controller.abort();
2904
+ }, [
2905
+ target,
2906
+ grid.api,
2907
+ grid.state.cellSelectionMode,
2908
+ grid.state.cellSelections,
2909
+ grid.state.internal.contextMenuTarget,
2910
+ menuRenderer,
2911
+ viewport,
2912
+ setMenu
2913
+ ]);
2914
+ }
2915
+ function ContextMenuDriver() {
2916
+ const grid = useGrid$1();
2917
+ const [menu, setMenu] = useState(null);
2918
+ const MenuRenderer = grid.state.contextMenuRenderer.use();
2919
+ const target = grid.state.internal.contextMenuTarget.use();
2920
+ useContextMenuListener(setMenu);
2921
+ const [open, setOpen] = useState(false);
2922
+ useEffect(() => {
2923
+ if (menu !== null) {
2924
+ setOpen(true);
2925
+ }
2926
+ }, [menu]);
2927
+ return /* @__PURE__ */ jsx(
2928
+ MenuRoot,
2929
+ {
2930
+ open,
2931
+ onOpenChange: (c) => {
2932
+ setOpen(c);
2933
+ },
2934
+ onOpenChangeComplete: (c) => {
2935
+ if (!c) {
2936
+ grid.api.contextMenuClose();
2937
+ setMenu(null);
2938
+ }
2939
+ },
2940
+ children: /* @__PURE__ */ jsx(MenuPortal, { children: /* @__PURE__ */ jsx(
2941
+ MenuPositioner,
2942
+ {
2943
+ side: "bottom",
2944
+ align: "start",
2945
+ anchor: target ? "getBoundingClientRect" in target ? target : {
2946
+ getBoundingClientRect: () => ({
2947
+ x: target.x,
2948
+ y: target.y,
2949
+ width: target.width,
2950
+ height: target.height,
2951
+ top: target.y,
2952
+ left: target.x,
2953
+ bottom: target.y,
2954
+ right: target.x,
2955
+ toJSON: () => ""
2956
+ })
2957
+ } : emptyBB,
2958
+ children: menu && MenuRenderer && /* @__PURE__ */ jsx(
2959
+ MenuRenderer,
2960
+ {
2961
+ api: grid.api,
2962
+ menuTarget: menu.menuTarget,
2963
+ columnIndex: menu.hoveredColumn,
2964
+ rowIndex: menu.hoveredRow
2965
+ }
2966
+ )
2967
+ }
2968
+ ) })
2969
+ }
2970
+ );
2971
+ }
2972
+ function DialogPortal(props) {
2973
+ const {
2974
+ children,
2975
+ keepMounted = false,
2976
+ container
2977
+ } = props;
2978
+ const {
2979
+ mounted
2980
+ } = useDialogRootContext();
2981
+ const shouldRender = mounted || keepMounted;
2982
+ if (!shouldRender) {
2983
+ return null;
2984
+ }
2985
+ return /* @__PURE__ */ jsx(DialogPortalContext.Provider, {
2986
+ value: keepMounted,
2987
+ children: /* @__PURE__ */ jsx(FloatingPortal, {
2988
+ root: container,
2989
+ children
2990
+ })
2991
+ });
2992
+ }
2993
+ process.env.NODE_ENV !== "production" ? DialogPortal.propTypes = {
2994
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
2995
+ // │ These PropTypes are generated from the TypeScript type definitions. │
2996
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
2997
+ // └─────────────────────────────────────────────────────────────────────┘
2998
+ /**
2999
+ * @ignore
3000
+ */
3001
+ children: PropTypes.node,
3002
+ /**
3003
+ * A parent element to render the portal element into.
3004
+ */
3005
+ container: PropTypes.oneOfType([HTMLElementType, refType]),
3006
+ /**
3007
+ * Whether to keep the portal mounted in the DOM while the popup is hidden.
3008
+ * @default false
3009
+ */
3010
+ keepMounted: PropTypes.bool
3011
+ } : void 0;
3012
+ function useEnhancedClickHandler(handler) {
3013
+ const lastClickInteractionTypeRef = React.useRef("");
3014
+ const handlePointerDown = React.useCallback((event) => {
3015
+ if (event.defaultPrevented) {
3016
+ return;
3017
+ }
3018
+ lastClickInteractionTypeRef.current = event.pointerType;
3019
+ }, []);
3020
+ const handleClick = React.useCallback((event) => {
3021
+ if (event.detail === 0) {
3022
+ handler(event, "keyboard");
3023
+ return;
3024
+ }
3025
+ if ("pointerType" in event) {
3026
+ handler(event, event.pointerType);
3027
+ }
3028
+ handler(event, lastClickInteractionTypeRef.current);
3029
+ lastClickInteractionTypeRef.current = "";
3030
+ }, [handler]);
3031
+ return {
3032
+ onClick: handleClick,
3033
+ onPointerDown: handlePointerDown
3034
+ };
3035
+ }
3036
+ function useOpenInteractionType(open) {
3037
+ const [openMethod, setOpenMethod] = React.useState(null);
3038
+ if (!open && openMethod !== null) {
3039
+ setOpenMethod(null);
3040
+ }
3041
+ const handleTriggerClick = React.useCallback((_, interactionType) => {
3042
+ if (!open) {
3043
+ setOpenMethod(interactionType);
3044
+ }
3045
+ }, [open, setOpenMethod]);
3046
+ const {
3047
+ onClick,
3048
+ onPointerDown
3049
+ } = useEnhancedClickHandler(handleTriggerClick);
3050
+ return React.useMemo(() => ({
3051
+ openMethod,
3052
+ triggerProps: {
3053
+ onClick,
3054
+ onPointerDown
3055
+ }
3056
+ }), [openMethod, onClick, onPointerDown]);
3057
+ }
3058
+ function useDialogRoot(params) {
3059
+ const {
3060
+ defaultOpen,
3061
+ dismissible,
3062
+ modal,
3063
+ onNestedDialogClose,
3064
+ onNestedDialogOpen,
3065
+ onOpenChange: onOpenChangeParameter,
3066
+ open: openParam,
3067
+ onOpenChangeComplete
3068
+ } = params;
3069
+ const [open, setOpenUnwrapped] = useControlled({
3070
+ controlled: openParam,
3071
+ default: defaultOpen,
3072
+ name: "DialogRoot",
3073
+ state: "open"
3074
+ });
3075
+ const popupRef = React.useRef(null);
3076
+ const backdropRef = React.useRef(null);
3077
+ const internalBackdropRef = React.useRef(null);
3078
+ const [titleElementId, setTitleElementId] = React.useState(void 0);
3079
+ const [descriptionElementId, setDescriptionElementId] = React.useState(void 0);
3080
+ const [triggerElement, setTriggerElement] = React.useState(null);
3081
+ const [popupElement, setPopupElement] = React.useState(null);
3082
+ const {
3083
+ mounted,
3084
+ setMounted,
3085
+ transitionStatus
3086
+ } = useTransitionStatus(open);
3087
+ const setOpen = useEventCallback((nextOpen, event, reason) => {
3088
+ onOpenChangeParameter?.(nextOpen, event, reason);
3089
+ setOpenUnwrapped(nextOpen);
3090
+ });
3091
+ const handleUnmount = useEventCallback(() => {
3092
+ setMounted(false);
3093
+ onOpenChangeComplete?.(false);
3094
+ });
3095
+ useOpenChangeComplete({
3096
+ enabled: !params.actionsRef,
3097
+ open,
3098
+ ref: popupRef,
3099
+ onComplete() {
3100
+ if (!open) {
3101
+ handleUnmount();
3102
+ }
3103
+ }
3104
+ });
3105
+ React.useImperativeHandle(params.actionsRef, () => ({
3106
+ unmount: handleUnmount
3107
+ }), [handleUnmount]);
3108
+ useScrollLock(open && modal, popupElement);
3109
+ const handleFloatingUIOpenChange = (nextOpen, event, reason) => {
3110
+ setOpen(nextOpen, event, translateOpenChangeReason(reason));
3111
+ };
3112
+ const context2 = useFloatingRootContext({
3113
+ elements: {
3114
+ reference: triggerElement,
3115
+ floating: popupElement
3116
+ },
3117
+ open,
3118
+ onOpenChange: handleFloatingUIOpenChange
3119
+ });
3120
+ const [ownNestedOpenDialogs, setOwnNestedOpenDialogs] = React.useState(0);
3121
+ const isTopmost = ownNestedOpenDialogs === 0;
3122
+ const role = useRole(context2);
3123
+ const click = useClick(context2);
3124
+ const dismiss = useDismiss(context2, {
3125
+ outsidePressEvent: "mousedown",
3126
+ outsidePress(event) {
3127
+ const target = getTarget(event);
3128
+ if (isTopmost && dismissible) {
3129
+ const backdrop = target;
3130
+ if (modal) {
3131
+ return backdrop ? [internalBackdropRef.current, backdropRef.current].includes(backdrop) : false;
3132
+ }
3133
+ return true;
3134
+ }
3135
+ return false;
3136
+ },
3137
+ escapeKey: isTopmost
3138
+ });
3139
+ const {
3140
+ getReferenceProps,
3141
+ getFloatingProps
3142
+ } = useInteractions([role, click, dismiss]);
3143
+ React.useEffect(() => {
3144
+ if (onNestedDialogOpen && open) {
3145
+ onNestedDialogOpen(ownNestedOpenDialogs);
3146
+ }
3147
+ if (onNestedDialogClose && !open) {
3148
+ onNestedDialogClose();
3149
+ }
3150
+ return () => {
3151
+ if (onNestedDialogClose && open) {
3152
+ onNestedDialogClose();
3153
+ }
3154
+ };
3155
+ }, [open, onNestedDialogClose, onNestedDialogOpen, ownNestedOpenDialogs]);
3156
+ const handleNestedDialogOpen = React.useCallback((ownChildrenCount) => {
3157
+ setOwnNestedOpenDialogs(ownChildrenCount + 1);
3158
+ }, []);
3159
+ const handleNestedDialogClose = React.useCallback(() => {
3160
+ setOwnNestedOpenDialogs(0);
3161
+ }, []);
3162
+ const {
3163
+ openMethod,
3164
+ triggerProps
3165
+ } = useOpenInteractionType(open);
3166
+ const getTriggerProps = React.useCallback((externalProps = {}) => getReferenceProps(mergeProps(triggerProps, externalProps)), [getReferenceProps, triggerProps]);
3167
+ return React.useMemo(() => {
3168
+ return {
3169
+ modal,
3170
+ setOpen,
3171
+ open,
3172
+ titleElementId,
3173
+ setTitleElementId,
3174
+ descriptionElementId,
3175
+ setDescriptionElementId,
3176
+ onNestedDialogOpen: handleNestedDialogOpen,
3177
+ onNestedDialogClose: handleNestedDialogClose,
3178
+ nestedOpenDialogCount: ownNestedOpenDialogs,
3179
+ openMethod,
3180
+ mounted,
3181
+ transitionStatus,
3182
+ getTriggerProps,
3183
+ getPopupProps: getFloatingProps,
3184
+ setTriggerElement,
3185
+ setPopupElement,
3186
+ popupRef,
3187
+ backdropRef,
3188
+ internalBackdropRef,
3189
+ floatingRootContext: context2
3190
+ };
3191
+ }, [modal, setOpen, open, titleElementId, descriptionElementId, handleNestedDialogOpen, handleNestedDialogClose, ownNestedOpenDialogs, openMethod, mounted, transitionStatus, getTriggerProps, getFloatingProps, context2]);
3192
+ }
3193
+ const DialogRoot = function DialogRoot2(props) {
3194
+ const {
3195
+ children,
3196
+ defaultOpen = false,
3197
+ dismissible = true,
3198
+ modal = true,
3199
+ onOpenChange,
3200
+ open,
3201
+ actionsRef,
3202
+ onOpenChangeComplete
3203
+ } = props;
3204
+ const parentDialogRootContext = useOptionalDialogRootContext();
3205
+ const dialogRoot = useDialogRoot({
3206
+ open,
3207
+ defaultOpen,
3208
+ onOpenChange,
3209
+ modal,
3210
+ dismissible,
3211
+ actionsRef,
3212
+ onOpenChangeComplete,
3213
+ onNestedDialogClose: parentDialogRootContext?.onNestedDialogClose,
3214
+ onNestedDialogOpen: parentDialogRootContext?.onNestedDialogOpen
3215
+ });
3216
+ const nested = Boolean(parentDialogRootContext);
3217
+ const dialogContextValue = React.useMemo(() => ({
3218
+ ...dialogRoot,
3219
+ nested,
3220
+ onOpenChangeComplete
3221
+ }), [dialogRoot, nested, onOpenChangeComplete]);
3222
+ const dialogRootContextValue = React.useMemo(() => ({
3223
+ dismissible
3224
+ }), [dismissible]);
3225
+ return /* @__PURE__ */ jsx(DialogContext.Provider, {
3226
+ value: dialogContextValue,
3227
+ children: /* @__PURE__ */ jsx(DialogRootContext.Provider, {
3228
+ value: dialogRootContextValue,
3229
+ children
3230
+ })
3231
+ });
3232
+ };
3233
+ process.env.NODE_ENV !== "production" ? DialogRoot.propTypes = {
3234
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
3235
+ // │ These PropTypes are generated from the TypeScript type definitions. │
3236
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
3237
+ // └─────────────────────────────────────────────────────────────────────┘
3238
+ /**
3239
+ * A ref to imperative actions.
3240
+ */
3241
+ actionsRef: PropTypes.shape({
3242
+ current: PropTypes.shape({
3243
+ unmount: PropTypes.func.isRequired
3244
+ }).isRequired
3245
+ }),
3246
+ /**
3247
+ * @ignore
3248
+ */
3249
+ children: PropTypes.node,
3250
+ /**
3251
+ * Whether the dialog is initially open.
3252
+ *
3253
+ * To render a controlled dialog, use the `open` prop instead.
3254
+ * @default false
3255
+ */
3256
+ defaultOpen: PropTypes.bool,
3257
+ /**
3258
+ * Determines whether the dialog should close on outside clicks.
3259
+ * @default true
3260
+ */
3261
+ dismissible: PropTypes.bool,
3262
+ /**
3263
+ * Whether the dialog should prevent outside clicks and lock page scroll when open.
3264
+ * @default true
3265
+ */
3266
+ modal: PropTypes.bool,
3267
+ /**
3268
+ * Event handler called when the dialog is opened or closed.
3269
+ */
3270
+ onOpenChange: PropTypes.func,
3271
+ /**
3272
+ * Event handler called after any animations complete when the dialog is opened or closed.
3273
+ */
3274
+ onOpenChangeComplete: PropTypes.func,
3275
+ /**
3276
+ * Whether the dialog is currently open.
3277
+ */
3278
+ open: PropTypes.bool
3279
+ } : void 0;
3280
+ function DialogDriver() {
3281
+ const grid = useGrid$1();
3282
+ const frames = grid.state.dialogFrames.use();
3283
+ const frameId = grid.state.internal.dialogFrameOpen.use();
3284
+ const frame = frameId ? frames[frameId] : null;
3285
+ const [open, setOpen] = useState(false);
3286
+ useEffect(() => {
3287
+ if (!frame) {
3288
+ setOpen(false);
3289
+ return;
3290
+ }
3291
+ setOpen(true);
3292
+ }, [frame]);
3293
+ return /* @__PURE__ */ jsx(
3294
+ DialogRoot,
3295
+ {
3296
+ open,
3297
+ onOpenChange: (c) => setOpen(c),
3298
+ onOpenChangeComplete: (c) => {
3299
+ if (!c) grid.api.dialogFrameClose();
3300
+ },
3301
+ children: /* @__PURE__ */ jsx(DialogPortal, { children: frame && /* @__PURE__ */ jsx(frame.component, { api: grid.api, frame }) })
3302
+ }
3303
+ );
3304
+ }
3305
+ const OPEN_DELAY = 300;
3306
+ function usePopoverRoot(params) {
3307
+ const {
3308
+ open: externalOpen,
3309
+ onOpenChange: onOpenChangeProp,
3310
+ defaultOpen = false,
3311
+ delay,
3312
+ closeDelay,
3313
+ openOnHover = false,
3314
+ onOpenChangeComplete,
3315
+ modal
3316
+ } = params;
3317
+ const delayWithDefault = delay ?? OPEN_DELAY;
3318
+ const closeDelayWithDefault = closeDelay ?? 0;
3319
+ const [instantType, setInstantType] = React.useState();
3320
+ const [titleId, setTitleId] = React.useState();
3321
+ const [descriptionId, setDescriptionId] = React.useState();
3322
+ const [triggerElement, setTriggerElement] = React.useState(null);
3323
+ const [positionerElement, setPositionerElement] = React.useState(null);
3324
+ const [openReason, setOpenReason] = React.useState(null);
3325
+ const [stickIfOpen, setStickIfOpen] = React.useState(true);
3326
+ const popupRef = React.useRef(null);
3327
+ const stickIfOpenTimeoutRef = React.useRef(-1);
3328
+ const [open, setOpenUnwrapped] = useControlled({
3329
+ controlled: externalOpen,
3330
+ default: defaultOpen,
3331
+ name: "Popover",
3332
+ state: "open"
3333
+ });
3334
+ const onOpenChange = useEventCallback(onOpenChangeProp);
3335
+ const {
3336
+ mounted,
3337
+ setMounted,
3338
+ transitionStatus
3339
+ } = useTransitionStatus(open);
3340
+ useScrollLock(open && modal && openReason !== "hover", triggerElement);
3341
+ const setOpen = useEventCallback((nextOpen, event, reason) => {
3342
+ onOpenChange(nextOpen, event, reason);
3343
+ setOpenUnwrapped(nextOpen);
3344
+ if (nextOpen) {
3345
+ setOpenReason(reason ?? null);
3346
+ }
3347
+ });
3348
+ const handleUnmount = useEventCallback(() => {
3349
+ setMounted(false);
3350
+ setStickIfOpen(true);
3351
+ setOpenReason(null);
3352
+ onOpenChangeComplete?.(false);
3353
+ });
3354
+ useOpenChangeComplete({
3355
+ enabled: !params.actionsRef,
3356
+ open,
3357
+ ref: popupRef,
3358
+ onComplete() {
3359
+ if (!open) {
3360
+ handleUnmount();
3361
+ }
3362
+ }
3363
+ });
3364
+ React.useImperativeHandle(params.actionsRef, () => ({
3365
+ unmount: handleUnmount
3366
+ }), [handleUnmount]);
3367
+ const clearStickIfOpenTimeout = useEventCallback(() => {
3368
+ clearTimeout(stickIfOpenTimeoutRef.current);
3369
+ });
3370
+ React.useEffect(() => {
3371
+ if (!open) {
3372
+ clearStickIfOpenTimeout();
3373
+ }
3374
+ }, [clearStickIfOpenTimeout, open]);
3375
+ React.useEffect(() => {
3376
+ return clearStickIfOpenTimeout;
3377
+ }, [clearStickIfOpenTimeout]);
3378
+ const context2 = useFloatingRootContext({
3379
+ elements: {
3380
+ reference: triggerElement,
3381
+ floating: positionerElement
3382
+ },
3383
+ open,
3384
+ onOpenChange(openValue, eventValue, reasonValue) {
3385
+ const isHover = reasonValue === "hover" || reasonValue === "safe-polygon";
3386
+ const isKeyboardClick = reasonValue === "click" && eventValue.detail === 0;
3387
+ const isDismissClose = !openValue && (reasonValue === "escape-key" || reasonValue == null);
3388
+ function changeState() {
3389
+ setOpen(openValue, eventValue, translateOpenChangeReason(reasonValue));
3390
+ }
3391
+ if (isHover) {
3392
+ setStickIfOpen(true);
3393
+ clearStickIfOpenTimeout();
3394
+ stickIfOpenTimeoutRef.current = window.setTimeout(() => {
3395
+ setStickIfOpen(false);
3396
+ }, PATIENT_CLICK_THRESHOLD);
3397
+ ReactDOM.flushSync(changeState);
3398
+ } else {
3399
+ changeState();
3400
+ }
3401
+ if (isKeyboardClick || isDismissClose) {
3402
+ setInstantType(isKeyboardClick ? "click" : "dismiss");
3403
+ } else {
3404
+ setInstantType(void 0);
3405
+ }
3406
+ }
3407
+ });
3408
+ const {
3409
+ openMethod,
3410
+ triggerProps
3411
+ } = useOpenInteractionType(open);
3412
+ const computedRestMs = delayWithDefault;
3413
+ const hover = useHover(context2, {
3414
+ enabled: openOnHover && (openMethod !== "touch" || openReason !== "click"),
3415
+ mouseOnly: true,
3416
+ move: false,
3417
+ handleClose: safePolygon({
3418
+ blockPointerEvents: true
3419
+ }),
3420
+ restMs: computedRestMs,
3421
+ delay: {
3422
+ close: closeDelayWithDefault
3423
+ }
3424
+ });
3425
+ const click = useClick(context2, {
3426
+ stickIfOpen
3427
+ });
3428
+ const dismiss = useDismiss(context2);
3429
+ const role = useRole(context2);
3430
+ const {
3431
+ getReferenceProps,
3432
+ getFloatingProps
3433
+ } = useInteractions([hover, click, dismiss, role]);
3434
+ const getRootTriggerProps = React.useCallback((externalProps = {}) => getReferenceProps(mergeProps(triggerProps, externalProps)), [getReferenceProps, triggerProps]);
3435
+ return React.useMemo(() => ({
3436
+ open,
3437
+ setOpen,
3438
+ mounted,
3439
+ setMounted,
3440
+ transitionStatus,
3441
+ setTriggerElement,
3442
+ positionerElement,
3443
+ setPositionerElement,
3444
+ popupRef,
3445
+ titleId,
3446
+ setTitleId,
3447
+ descriptionId,
3448
+ setDescriptionId,
3449
+ getRootTriggerProps,
3450
+ getRootPopupProps: getFloatingProps,
3451
+ floatingRootContext: context2,
3452
+ instantType,
3453
+ openMethod,
3454
+ openReason,
3455
+ onOpenChangeComplete
3456
+ }), [open, setOpen, mounted, setMounted, transitionStatus, positionerElement, titleId, descriptionId, getRootTriggerProps, getFloatingProps, context2, instantType, openMethod, openReason, onOpenChangeComplete]);
3457
+ }
3458
+ const PopoverRoot = function PopoverRoot2(props) {
3459
+ const {
3460
+ defaultOpen = false,
3461
+ onOpenChange,
3462
+ open,
3463
+ openOnHover = false,
3464
+ delay,
3465
+ closeDelay = 0,
3466
+ actionsRef,
3467
+ onOpenChangeComplete,
3468
+ modal = false
3469
+ } = props;
3470
+ const delayWithDefault = delay ?? OPEN_DELAY;
3471
+ const popoverRoot = usePopoverRoot({
3472
+ ...props,
3473
+ defaultOpen,
3474
+ onOpenChange,
3475
+ open,
3476
+ openOnHover,
3477
+ onOpenChangeComplete,
3478
+ delay: delayWithDefault,
3479
+ closeDelay,
3480
+ actionsRef,
3481
+ modal
3482
+ });
3483
+ const contextValue = React.useMemo(() => ({
3484
+ ...popoverRoot,
3485
+ openOnHover,
3486
+ delay: delayWithDefault,
3487
+ closeDelay,
3488
+ modal
3489
+ }), [popoverRoot, openOnHover, delayWithDefault, closeDelay, modal]);
3490
+ return /* @__PURE__ */ jsx(PopoverRootContext.Provider, {
3491
+ value: contextValue,
3492
+ children: props.children
3493
+ });
3494
+ };
3495
+ process.env.NODE_ENV !== "production" ? PopoverRoot.propTypes = {
3496
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
3497
+ // │ These PropTypes are generated from the TypeScript type definitions. │
3498
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
3499
+ // └─────────────────────────────────────────────────────────────────────┘
3500
+ /**
3501
+ * A ref to imperative actions.
3502
+ */
3503
+ actionsRef: PropTypes.shape({
3504
+ current: PropTypes.shape({
3505
+ unmount: PropTypes.func.isRequired
3506
+ }).isRequired
3507
+ }),
3508
+ /**
3509
+ * @ignore
3510
+ */
3511
+ children: PropTypes.node,
3512
+ /**
3513
+ * How long to wait before closing the popover that was opened on hover.
3514
+ * Specified in milliseconds.
3515
+ *
3516
+ * Requires the `openOnHover` prop.
3517
+ * @default 0
3518
+ */
3519
+ closeDelay: PropTypes.number,
3520
+ /**
3521
+ * Whether the popover is initially open.
3522
+ *
3523
+ * To render a controlled popover, use the `open` prop instead.
3524
+ * @default false
3525
+ */
3526
+ defaultOpen: PropTypes.bool,
3527
+ /**
3528
+ * How long to wait before the popover may be opened on hover. Specified in milliseconds.
3529
+ *
3530
+ * Requires the `openOnHover` prop.
3531
+ * @default 300
3532
+ */
3533
+ delay: PropTypes.number,
3534
+ /**
3535
+ * Whether the popover should prevent outside clicks and lock page scroll when open.
3536
+ * @default false
3537
+ */
3538
+ modal: PropTypes.bool,
3539
+ /**
3540
+ * Event handler called when the popover is opened or closed.
3541
+ */
3542
+ onOpenChange: PropTypes.func,
3543
+ /**
3544
+ * Event handler called after any animations complete when the popover is opened or closed.
3545
+ */
3546
+ onOpenChangeComplete: PropTypes.func,
3547
+ /**
3548
+ * Whether the popover is currently open.
3549
+ */
3550
+ open: PropTypes.bool,
3551
+ /**
3552
+ * Whether the popover should also open when the trigger is hovered.
3553
+ * @default false
3554
+ */
3555
+ openOnHover: PropTypes.bool
3556
+ } : void 0;
3557
+ function PopoverPortal(props) {
3558
+ const {
3559
+ children,
3560
+ keepMounted = false,
3561
+ container
3562
+ } = props;
3563
+ const {
3564
+ mounted
3565
+ } = usePopoverRootContext();
3566
+ const shouldRender = mounted || keepMounted;
3567
+ if (!shouldRender) {
3568
+ return null;
3569
+ }
3570
+ return /* @__PURE__ */ jsx(PopoverPortalContext.Provider, {
3571
+ value: keepMounted,
3572
+ children: /* @__PURE__ */ jsx(FloatingPortal, {
3573
+ root: container,
3574
+ children
3575
+ })
3576
+ });
3577
+ }
3578
+ process.env.NODE_ENV !== "production" ? PopoverPortal.propTypes = {
3579
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
3580
+ // │ These PropTypes are generated from the TypeScript type definitions. │
3581
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
3582
+ // └─────────────────────────────────────────────────────────────────────┘
3583
+ /**
3584
+ * @ignore
3585
+ */
3586
+ children: PropTypes.node,
3587
+ /**
3588
+ * A parent element to render the portal element into.
3589
+ */
3590
+ container: PropTypes.oneOfType([HTMLElementType, refType]),
3591
+ /**
3592
+ * Whether to keep the portal mounted in the DOM while the popup is hidden.
3593
+ * @default false
3594
+ */
3595
+ keepMounted: PropTypes.bool
3596
+ } : void 0;
3597
+ function PopoverDriver() {
3598
+ const grid = useGrid$1();
3599
+ const frames = grid.state.popoverFrames.use();
3600
+ const frameId = grid.state.internal.popoverFrameOpen.use();
3601
+ const frameBB = grid.state.internal.popoverFrameBB.use();
3602
+ const frame = frameId ? frames[frameId] : null;
3603
+ const [open, setOpen] = useState(false);
3604
+ useEffect(() => {
3605
+ if (!frame || !frameBB) {
3606
+ setOpen(false);
3607
+ return;
3608
+ }
3609
+ setOpen(true);
3610
+ }, [frame, frameBB]);
3611
+ return /* @__PURE__ */ jsx(
3612
+ PopoverRoot,
3613
+ {
3614
+ open,
3615
+ onOpenChange: (c) => setOpen(c),
3616
+ onOpenChangeComplete: (c) => {
3617
+ if (!c) grid.api.popoverFrameClose();
3618
+ },
3619
+ children: /* @__PURE__ */ jsx(AnchorProvider, { anchor: frameBB, children: /* @__PURE__ */ jsx(PopoverPortal, { children: frame && frameBB && /* @__PURE__ */ jsx(frame.component, { api: grid.api, frame }) }) })
3620
+ }
3621
+ );
3622
+ }
3623
+ function LyteNyteGrid({ grid, frameAxe }) {
3624
+ return /* @__PURE__ */ jsx(GridProvider, { value: grid, children: /* @__PURE__ */ jsxs(GridFrame, { grid, axe: frameAxe, children: [
3625
+ /* @__PURE__ */ jsx(LyteNyteProImpl, {}),
3626
+ /* @__PURE__ */ jsx(ColumnMenuDriver, {}),
3627
+ /* @__PURE__ */ jsx(ContextMenuDriver, {}),
3628
+ /* @__PURE__ */ jsx(DialogDriver, {}),
3629
+ /* @__PURE__ */ jsx(PopoverDriver, {})
3630
+ ] }) });
3631
+ }
3632
+ function LyteNyteProImpl() {
3633
+ const { state } = useGrid$1();
3634
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3635
+ /* @__PURE__ */ jsx(OverlayDriver, {}),
3636
+ /* @__PURE__ */ jsxs(Viewport, { top: Top, center: Center, bottom: Bottom, children: [
3637
+ /* @__PURE__ */ jsx(CellSelectionDriver, {}),
3638
+ /* @__PURE__ */ jsx(Watermark, { id: state.gridId.use() })
3639
+ ] })
3640
+ ] });
3641
+ }
3642
+ function Center() {
3643
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3644
+ /* @__PURE__ */ jsx(CellEditorCenter, {}),
3645
+ /* @__PURE__ */ jsx(CellSelectionCenter, {})
3646
+ ] });
3647
+ }
3648
+ function Top() {
3649
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3650
+ /* @__PURE__ */ jsx(CellEditorTop, {}),
3651
+ /* @__PURE__ */ jsx(CellSelectionTop, {})
3652
+ ] });
3653
+ }
3654
+ function Bottom() {
3655
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3656
+ /* @__PURE__ */ jsx(CellEditorBottom, {}),
3657
+ /* @__PURE__ */ jsx(CellSelectionBottom, {})
3658
+ ] });
3659
+ }
3660
+ const useLyteNytePro = (p2) => {
3661
+ const [grid] = useState(() => {
3662
+ const s3 = makeGridPro(p2);
3663
+ const useSignalWatcher = (c, fn) => {
3664
+ const signal2 = s3.state[c];
3665
+ useEffect(() => {
3666
+ const unsub = signal2.watch(fn);
3667
+ return () => unsub();
3668
+ }, [fn, signal2]);
3669
+ };
3670
+ const useEvent2 = (ev, fn) => {
3671
+ useEffect(() => {
3672
+ const unsub = s3.api.eventAddListener(ev, fn);
3673
+ return () => unsub();
3674
+ }, [ev, fn]);
3675
+ };
3676
+ return { ...s3, useSignalWatcher, useEvent: useEvent2 };
3677
+ });
3678
+ return grid;
3679
+ };
3680
+ const createClientDataSourceReact = (init) => {
3681
+ return createClientDataSource(init);
3682
+ };
3683
+ function useClientDataSource(init) {
3684
+ return useState(() => createClientDataSource(init))[0];
3685
+ }
3686
+ function useTreeDataSource(init) {
3687
+ const [ds] = useState(() => {
3688
+ return createTreeDataSource(init);
3689
+ });
3690
+ return ds;
3691
+ }
3692
+ export {
3693
+ COLUMN_EMPTY_PREFIX,
3694
+ y as COLUMN_GROUP_HEADER_HEIGHT,
3695
+ q as COLUMN_GROUP_ID_DELIMITER,
3696
+ z as COLUMN_HEADER_HEIGHT,
3697
+ COLUMN_MARKER_ID,
3698
+ A as COLUMN_SCAN_DISTANCE,
3699
+ L as DEFAULT_MAX_WIDTH,
3700
+ M as DEFAULT_MIN_WIDTH,
3701
+ O as DEFAULT_SORT_CYCLE,
3702
+ N as DEFAULT_WIDTH,
3703
+ END_ENCODING,
3704
+ FLOATING_CELL_POSITION,
3705
+ FULL_ENCODING,
3706
+ Q as FULL_WIDTH_POSITION,
3707
+ GRID_CELL_POSITION,
3708
+ v as GROUP_COLUMN_MULTI_PREFIX,
3709
+ t as GROUP_COLUMN_PREFIX,
3710
+ w as GROUP_COLUMN_SINGLE_ID,
3711
+ x as GROUP_COLUMN_TREE_DATA,
3712
+ HEADER_CELL_POSITION,
3713
+ HEADER_GROUP_CELL_POSITION,
3714
+ LyteNyteGrid,
3715
+ P as PAGINATE_PAGE_SIZE,
3716
+ r as ROW_DEFAULT_PATH_SEPARATOR,
3717
+ J as ROW_DETAIL_HEIGHT,
3718
+ o as ROW_GROUP_KIND,
3719
+ B as ROW_HEIGHT,
3720
+ R as ROW_LEAF_KIND,
3721
+ s as ROW_TOTAL_ID,
3722
+ p as ROW_TOTAL_KIND,
3723
+ K as ROW_UPDATE_STACK_SIZE,
3724
+ activateLicense,
3725
+ createClientDataSourceReact,
3726
+ hasAValidLicense,
3727
+ useClientDataSource,
3728
+ useLyteNytePro,
3729
+ useTreeDataSource
3730
+ };