@uipath/apollo-react 7.11.3 → 7.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/dist/canvas/components/CanvasDiffView/CanvasDiffView.cjs +6 -6
  2. package/dist/canvas/components/CanvasDiffView/CanvasDiffView.js +6 -6
  3. package/dist/canvas/components/JsonTree/JsonTree.cjs +2 -2
  4. package/dist/canvas/components/JsonTree/JsonTree.js +2 -2
  5. package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.cjs +6 -6
  6. package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.js +6 -6
  7. package/dist/canvas/components/StageNode/tasks/TaskContent.cjs +1 -1
  8. package/dist/canvas/components/StageNode/tasks/TaskContent.js +1 -1
  9. package/dist/canvas/locales/de.cjs +1 -1
  10. package/dist/canvas/locales/de.d.ts.map +1 -1
  11. package/dist/canvas/locales/de.js +1 -1
  12. package/dist/canvas/locales/en.cjs +1 -1
  13. package/dist/canvas/locales/en.d.ts.map +1 -1
  14. package/dist/canvas/locales/en.js +1 -1
  15. package/dist/canvas/locales/es-MX.cjs +1 -1
  16. package/dist/canvas/locales/es-MX.d.ts.map +1 -1
  17. package/dist/canvas/locales/es-MX.js +1 -1
  18. package/dist/canvas/locales/es.cjs +1 -1
  19. package/dist/canvas/locales/es.d.ts.map +1 -1
  20. package/dist/canvas/locales/es.js +1 -1
  21. package/dist/canvas/locales/fr.cjs +1 -1
  22. package/dist/canvas/locales/fr.d.ts.map +1 -1
  23. package/dist/canvas/locales/fr.js +1 -1
  24. package/dist/canvas/locales/ja.cjs +1 -1
  25. package/dist/canvas/locales/ja.d.ts.map +1 -1
  26. package/dist/canvas/locales/ja.js +1 -1
  27. package/dist/canvas/locales/ko.cjs +1 -1
  28. package/dist/canvas/locales/ko.d.ts.map +1 -1
  29. package/dist/canvas/locales/ko.js +1 -1
  30. package/dist/canvas/locales/pt-BR.cjs +1 -1
  31. package/dist/canvas/locales/pt-BR.d.ts.map +1 -1
  32. package/dist/canvas/locales/pt-BR.js +1 -1
  33. package/dist/canvas/locales/pt.cjs +1 -1
  34. package/dist/canvas/locales/pt.d.ts.map +1 -1
  35. package/dist/canvas/locales/pt.js +1 -1
  36. package/dist/canvas/locales/ro.cjs +1 -1
  37. package/dist/canvas/locales/ro.d.ts.map +1 -1
  38. package/dist/canvas/locales/ro.js +1 -1
  39. package/dist/canvas/locales/ru.cjs +1 -1
  40. package/dist/canvas/locales/ru.d.ts.map +1 -1
  41. package/dist/canvas/locales/ru.js +1 -1
  42. package/dist/canvas/locales/tr.cjs +1 -1
  43. package/dist/canvas/locales/tr.d.ts.map +1 -1
  44. package/dist/canvas/locales/tr.js +1 -1
  45. package/dist/canvas/locales/zh-CN.cjs +1 -1
  46. package/dist/canvas/locales/zh-CN.d.ts.map +1 -1
  47. package/dist/canvas/locales/zh-CN.js +1 -1
  48. package/dist/canvas/locales/zh-TW.cjs +1 -1
  49. package/dist/canvas/locales/zh-TW.d.ts.map +1 -1
  50. package/dist/canvas/locales/zh-TW.js +1 -1
  51. package/dist/canvas/styles/tailwind.canvas.css +1 -1
  52. package/dist/chat/locales/de.cjs +1 -1
  53. package/dist/chat/locales/de.d.ts.map +1 -1
  54. package/dist/chat/locales/de.js +1 -1
  55. package/dist/chat/locales/en.cjs +1 -1
  56. package/dist/chat/locales/en.d.ts.map +1 -1
  57. package/dist/chat/locales/en.js +1 -1
  58. package/dist/chat/locales/es-MX.cjs +1 -1
  59. package/dist/chat/locales/es-MX.d.ts.map +1 -1
  60. package/dist/chat/locales/es-MX.js +1 -1
  61. package/dist/chat/locales/es.cjs +1 -1
  62. package/dist/chat/locales/es.d.ts.map +1 -1
  63. package/dist/chat/locales/es.js +1 -1
  64. package/dist/chat/locales/fr.cjs +1 -1
  65. package/dist/chat/locales/fr.d.ts.map +1 -1
  66. package/dist/chat/locales/fr.js +1 -1
  67. package/dist/chat/locales/ja.cjs +1 -1
  68. package/dist/chat/locales/ja.d.ts.map +1 -1
  69. package/dist/chat/locales/ja.js +1 -1
  70. package/dist/chat/locales/ko.cjs +1 -1
  71. package/dist/chat/locales/ko.d.ts.map +1 -1
  72. package/dist/chat/locales/ko.js +1 -1
  73. package/dist/chat/locales/pt-BR.cjs +1 -1
  74. package/dist/chat/locales/pt-BR.d.ts.map +1 -1
  75. package/dist/chat/locales/pt-BR.js +1 -1
  76. package/dist/chat/locales/pt.cjs +1 -1
  77. package/dist/chat/locales/pt.d.ts.map +1 -1
  78. package/dist/chat/locales/pt.js +1 -1
  79. package/dist/chat/locales/ro.cjs +1 -1
  80. package/dist/chat/locales/ro.d.ts.map +1 -1
  81. package/dist/chat/locales/ro.js +1 -1
  82. package/dist/chat/locales/ru.cjs +1 -1
  83. package/dist/chat/locales/ru.d.ts.map +1 -1
  84. package/dist/chat/locales/ru.js +1 -1
  85. package/dist/chat/locales/tr.cjs +1 -1
  86. package/dist/chat/locales/tr.d.ts.map +1 -1
  87. package/dist/chat/locales/tr.js +1 -1
  88. package/dist/chat/locales/zh-CN.cjs +1 -1
  89. package/dist/chat/locales/zh-CN.d.ts.map +1 -1
  90. package/dist/chat/locales/zh-CN.js +1 -1
  91. package/dist/chat/locales/zh-TW.cjs +1 -1
  92. package/dist/chat/locales/zh-TW.d.ts.map +1 -1
  93. package/dist/chat/locales/zh-TW.js +1 -1
  94. package/dist/chat/styles/tailwind.chat.css +1 -1
  95. package/dist/decision-table/DecisionTable.cjs +454 -0
  96. package/dist/decision-table/DecisionTable.d.ts +36 -0
  97. package/dist/decision-table/DecisionTable.d.ts.map +1 -0
  98. package/dist/decision-table/DecisionTable.js +410 -0
  99. package/dist/decision-table/GridCell.cjs +153 -0
  100. package/dist/decision-table/GridCell.d.ts +43 -0
  101. package/dist/decision-table/GridCell.d.ts.map +1 -0
  102. package/dist/decision-table/GridCell.js +116 -0
  103. package/dist/decision-table/GridMenu.cjs +135 -0
  104. package/dist/decision-table/GridMenu.d.ts +30 -0
  105. package/dist/decision-table/GridMenu.d.ts.map +1 -0
  106. package/dist/decision-table/GridMenu.js +101 -0
  107. package/dist/decision-table/MarkGlyph.cjs +51 -0
  108. package/dist/decision-table/MarkGlyph.d.ts +7 -0
  109. package/dist/decision-table/MarkGlyph.d.ts.map +1 -0
  110. package/dist/decision-table/MarkGlyph.js +17 -0
  111. package/dist/decision-table/clipboardCodec.cjs +123 -0
  112. package/dist/decision-table/clipboardCodec.d.ts +8 -0
  113. package/dist/decision-table/clipboardCodec.d.ts.map +1 -0
  114. package/dist/decision-table/clipboardCodec.js +80 -0
  115. package/dist/decision-table/clippedTitle.cjs +39 -0
  116. package/dist/decision-table/clippedTitle.d.ts +3 -0
  117. package/dist/decision-table/clippedTitle.d.ts.map +1 -0
  118. package/dist/decision-table/clippedTitle.js +5 -0
  119. package/dist/decision-table/columnSizing.cjs +92 -0
  120. package/dist/decision-table/columnSizing.d.ts +13 -0
  121. package/dist/decision-table/columnSizing.d.ts.map +1 -0
  122. package/dist/decision-table/columnSizing.js +52 -0
  123. package/dist/decision-table/constants.cjs +84 -0
  124. package/dist/decision-table/constants.d.ts +14 -0
  125. package/dist/decision-table/constants.d.ts.map +1 -0
  126. package/dist/decision-table/constants.js +14 -0
  127. package/dist/decision-table/gridClipboard.cjs +129 -0
  128. package/dist/decision-table/gridClipboard.d.ts +19 -0
  129. package/dist/decision-table/gridClipboard.d.ts.map +1 -0
  130. package/dist/decision-table/gridClipboard.js +89 -0
  131. package/dist/decision-table/gridEvents.cjs +72 -0
  132. package/dist/decision-table/gridEvents.d.ts +14 -0
  133. package/dist/decision-table/gridEvents.d.ts.map +1 -0
  134. package/dist/decision-table/gridEvents.js +23 -0
  135. package/dist/decision-table/gridStyles.cjs +196 -0
  136. package/dist/decision-table/gridStyles.d.ts +47 -0
  137. package/dist/decision-table/gridStyles.d.ts.map +1 -0
  138. package/dist/decision-table/gridStyles.js +54 -0
  139. package/dist/decision-table/gridTypes.cjs +18 -0
  140. package/dist/decision-table/gridTypes.d.ts +93 -0
  141. package/dist/decision-table/gridTypes.d.ts.map +1 -0
  142. package/dist/decision-table/gridTypes.js +0 -0
  143. package/dist/decision-table/index.cjs +271 -0
  144. package/dist/decision-table/index.d.ts +13 -0
  145. package/dist/decision-table/index.d.ts.map +1 -0
  146. package/dist/decision-table/index.js +12 -0
  147. package/dist/decision-table/marks.cjs +39 -0
  148. package/dist/decision-table/marks.d.ts +20 -0
  149. package/dist/decision-table/marks.d.ts.map +1 -0
  150. package/dist/decision-table/marks.js +5 -0
  151. package/dist/decision-table/styles/tailwind.decision-table.css +2 -0
  152. package/dist/decision-table/useColumnWidths.cjs +313 -0
  153. package/dist/decision-table/useColumnWidths.d.ts +21 -0
  154. package/dist/decision-table/useColumnWidths.d.ts.map +1 -0
  155. package/dist/decision-table/useColumnWidths.js +279 -0
  156. package/dist/decision-table/useDragReorder.cjs +229 -0
  157. package/dist/decision-table/useDragReorder.d.ts +31 -0
  158. package/dist/decision-table/useDragReorder.d.ts.map +1 -0
  159. package/dist/decision-table/useDragReorder.js +186 -0
  160. package/dist/decision-table/useDragSelection.cjs +75 -0
  161. package/dist/decision-table/useDragSelection.d.ts +18 -0
  162. package/dist/decision-table/useDragSelection.d.ts.map +1 -0
  163. package/dist/decision-table/useDragSelection.js +41 -0
  164. package/dist/decision-table/useGridClipboard.cjs +195 -0
  165. package/dist/decision-table/useGridClipboard.d.ts +13 -0
  166. package/dist/decision-table/useGridClipboard.d.ts.map +1 -0
  167. package/dist/decision-table/useGridClipboard.js +161 -0
  168. package/dist/decision-table/useGridLayout.cjs +248 -0
  169. package/dist/decision-table/useGridLayout.d.ts +50 -0
  170. package/dist/decision-table/useGridLayout.d.ts.map +1 -0
  171. package/dist/decision-table/useGridLayout.js +211 -0
  172. package/dist/decision-table/useGridNavigation.cjs +441 -0
  173. package/dist/decision-table/useGridNavigation.d.ts +67 -0
  174. package/dist/decision-table/useGridNavigation.d.ts.map +1 -0
  175. package/dist/decision-table/useGridNavigation.js +404 -0
  176. package/dist/decision-table/useVirtualizedAxis.cjs +256 -0
  177. package/dist/decision-table/useVirtualizedAxis.d.ts +34 -0
  178. package/dist/decision-table/useVirtualizedAxis.d.ts.map +1 -0
  179. package/dist/decision-table/useVirtualizedAxis.js +219 -0
  180. package/dist/test/setup.d.ts.map +1 -1
  181. package/package.json +20 -10
@@ -0,0 +1,211 @@
1
+ import { useCallback, useMemo, useRef } from "react";
2
+ import { COLUMN_ESTIMATE_PX, DEFAULT_COLUMN_OVERSCAN, DEFAULT_ROW_OVERSCAN, FALLBACK_COLUMN_VIEWPORT_PX, FALLBACK_ROW_VIEWPORT_PX, GROUP_SEPARATOR_WIDTH_PX } from "./constants.js";
3
+ import { useColumnWidths } from "./useColumnWidths.js";
4
+ import { useVirtualizedAxis } from "./useVirtualizedAxis.js";
5
+ const separatorFlexIndexes = (columns, pinnedCount = 0)=>{
6
+ const indexes = new Set();
7
+ for(let index = Math.max(1, pinnedCount); index < columns.length; index++){
8
+ const group = columns[index].group;
9
+ if (group?.separatorBefore && group.id !== columns[index - 1].group?.id) indexes.add(index);
10
+ }
11
+ return indexes;
12
+ };
13
+ const NO_OMITTED_BORDERS = [];
14
+ const RIGHT_OMITTED = [
15
+ 'right'
16
+ ];
17
+ const withHostFrame = (edges, isLast)=>isLast && !edges.includes('right') ? [
18
+ ...edges,
19
+ 'right'
20
+ ] : edges;
21
+ const resolveOmittedBorders = (columns, framedByHost)=>columns.map((column, index)=>{
22
+ const isLast = index === columns.length - 1;
23
+ const declared = column.group?.omitCellBorders;
24
+ if (!declared || 0 === declared.length) return framedByHost && isLast ? RIGHT_OMITTED : NO_OMITTED_BORDERS;
25
+ const inSameBand = (other)=>other?.group?.id !== void 0 && other.group.id === column.group?.id;
26
+ const opensBand = !inSameBand(columns[index - 1]);
27
+ const closesBand = !inSameBand(columns[index + 1]);
28
+ const kept = declared.filter((edge)=>!('left' === edge && opensBand) && !('right' === edge && closesBand));
29
+ return withHostFrame(kept.length === declared.length ? declared : kept, framedByHost && isLast);
30
+ });
31
+ const useGridLayout = ({ columns, rowCount, rowHeightPx, leadingColumnWidth, trailingColumnWidth, pinnedColumnCount = 0, initialColumnWidths, onColumnWidthsChange, containerRef, retainedRowIndex = null, retainedColumnIndex = null, framedByHost = false })=>{
32
+ const separatorsKey = columns.map((column)=>`${column.group?.id ?? ''}:${column.group?.separatorBefore ? '1' : ''}`).join(',');
33
+ const pinnedCount = Math.min(pinnedColumnCount, columns.length);
34
+ const separatorBefore = useMemo(()=>separatorFlexIndexes(columns, pinnedCount), [
35
+ separatorsKey,
36
+ pinnedCount
37
+ ]);
38
+ const omittedBorders = useMemo(()=>resolveOmittedBorders(columns, framedByHost), [
39
+ columns,
40
+ framedByHost
41
+ ]);
42
+ const { widths, totalWidth, setTableElement, setColElement, setSpacerElement, onResizeStart, onResizeKeyDown, onResizeReset } = useColumnWidths({
43
+ columns,
44
+ reservedPx: leadingColumnWidth + trailingColumnWidth + separatorBefore.size * GROUP_SEPARATOR_WIDTH_PX,
45
+ containerRef,
46
+ initialWidths: initialColumnWidths,
47
+ onWidthsChange: onColumnWidthsChange
48
+ });
49
+ const windowedCount = columns.length - pinnedCount;
50
+ const headerHeightRef = useRef(0);
51
+ const headerObserverRef = useRef(null);
52
+ const theadRef = useCallback((element)=>{
53
+ headerObserverRef.current?.disconnect();
54
+ headerObserverRef.current = null;
55
+ headerHeightRef.current = element?.offsetHeight ?? 0;
56
+ if (!element || "u" < typeof ResizeObserver) return;
57
+ const observer = new ResizeObserver(()=>{
58
+ headerHeightRef.current = element.offsetHeight;
59
+ });
60
+ observer.observe(element);
61
+ headerObserverRef.current = observer;
62
+ }, []);
63
+ const headerHeight = useCallback(()=>headerHeightRef.current, []);
64
+ const widthsKey = widths.join(',');
65
+ const stableWidths = useMemo(()=>widths, [
66
+ widthsKey
67
+ ]);
68
+ const widthsRef = useRef(stableWidths);
69
+ widthsRef.current = stableWidths;
70
+ const columnsRef = useRef(columns);
71
+ columnsRef.current = columns;
72
+ const columnLeading = useCallback(()=>{
73
+ let leading = leadingColumnWidth;
74
+ for(let index = 0; index < pinnedCount && index < columnsRef.current.length; index += 1)leading += widthsRef.current[index] ?? columnsRef.current[index].defaultWidth;
75
+ return leading;
76
+ }, [
77
+ leadingColumnWidth,
78
+ pinnedCount
79
+ ]);
80
+ const columnOffsets = useMemo(()=>{
81
+ const offsets = new Array(windowedCount + 1);
82
+ offsets[0] = 0;
83
+ for(let windowIndex = 0; windowIndex < windowedCount; windowIndex++){
84
+ const flexIndex = pinnedCount + windowIndex;
85
+ const separatorHere = separatorBefore.has(flexIndex) ? GROUP_SEPARATOR_WIDTH_PX : 0;
86
+ offsets[windowIndex + 1] = offsets[windowIndex] + separatorHere + (stableWidths[flexIndex] ?? columns[flexIndex].defaultWidth);
87
+ }
88
+ return offsets;
89
+ }, [
90
+ stableWidths,
91
+ windowedCount,
92
+ pinnedCount,
93
+ columns,
94
+ separatorBefore
95
+ ]);
96
+ const rowWindow = useVirtualizedAxis(rowCount, rowHeightPx, retainedRowIndex, {
97
+ axis: 'vertical',
98
+ overscanItems: DEFAULT_ROW_OVERSCAN,
99
+ fallbackViewportPx: FALLBACK_ROW_VIEWPORT_PX,
100
+ leadingFixedPx: headerHeight,
101
+ stickyLeadingPx: headerHeight
102
+ });
103
+ const columnWindow = useVirtualizedAxis(windowedCount, COLUMN_ESTIMATE_PX, retainedColumnIndex, {
104
+ axis: 'horizontal',
105
+ overscanItems: DEFAULT_COLUMN_OVERSCAN,
106
+ fallbackViewportPx: FALLBACK_COLUMN_VIEWPORT_PX,
107
+ leadingFixedPx: columnLeading,
108
+ stickyLeadingPx: columnLeading,
109
+ stickyTrailingPx: trailingColumnWidth,
110
+ itemOffsetsPx: columnOffsets
111
+ });
112
+ const visibleColumns = useMemo(()=>{
113
+ const result = [];
114
+ for(let flexIndex = 0; flexIndex < pinnedCount; flexIndex++)result.push({
115
+ type: 'column',
116
+ column: columns[flexIndex],
117
+ flexIndex,
118
+ windowIndex: null,
119
+ omitBorders: omittedBorders[flexIndex]
120
+ });
121
+ let cursor = 0;
122
+ columnWindow.segments.forEach((segment, segmentIndex)=>{
123
+ if ('spacer' === segment.type) {
124
+ const nextItems = columnWindow.segments.slice(segmentIndex + 1).find((other)=>'items' === other.type);
125
+ const gapEnd = nextItems?.type === 'items' ? nextItems.from : windowedCount;
126
+ const coveredIds = [];
127
+ let separatorPx = 0;
128
+ for(let windowIndex = cursor; windowIndex < gapEnd; windowIndex++){
129
+ const flexIndex = pinnedCount + windowIndex;
130
+ coveredIds.push(columns[flexIndex].id);
131
+ if (separatorBefore.has(flexIndex)) separatorPx += GROUP_SEPARATOR_WIDTH_PX;
132
+ }
133
+ result.push({
134
+ type: 'spacer',
135
+ widthPx: segment.sizePx,
136
+ coveredIds,
137
+ separatorPx
138
+ });
139
+ cursor = gapEnd;
140
+ return;
141
+ }
142
+ for(let windowIndex = segment.from; windowIndex < segment.to; windowIndex++){
143
+ const flexIndex = pinnedCount + windowIndex;
144
+ if (separatorBefore.has(flexIndex)) result.push({
145
+ type: 'separator',
146
+ widthPx: GROUP_SEPARATOR_WIDTH_PX,
147
+ beforeColumnId: columns[flexIndex].id
148
+ });
149
+ result.push({
150
+ type: 'column',
151
+ column: columns[flexIndex],
152
+ flexIndex,
153
+ windowIndex,
154
+ omitBorders: omittedBorders[flexIndex]
155
+ });
156
+ }
157
+ cursor = segment.to;
158
+ });
159
+ return result;
160
+ }, [
161
+ columnWindow.segments,
162
+ columns,
163
+ pinnedCount,
164
+ windowedCount,
165
+ separatorBefore,
166
+ omittedBorders
167
+ ]);
168
+ const scrollRowIntoView = useCallback((rowIndex)=>rowWindow.scrollItemIntoView(containerRef.current, rowIndex), [
169
+ rowWindow.scrollItemIntoView,
170
+ containerRef
171
+ ]);
172
+ const scrollColumnIntoView = useCallback((windowIndex)=>columnWindow.scrollItemIntoView(containerRef.current, windowIndex), [
173
+ columnWindow.scrollItemIntoView,
174
+ containerRef
175
+ ]);
176
+ const { measureRef: measureRows } = rowWindow;
177
+ const { measureRef: measureColumns } = columnWindow;
178
+ const attachContainer = useCallback((element)=>{
179
+ containerRef.current = element;
180
+ measureRows(element);
181
+ measureColumns(element);
182
+ }, [
183
+ containerRef,
184
+ measureRows,
185
+ measureColumns
186
+ ]);
187
+ return {
188
+ widths: stableWidths,
189
+ totalWidth,
190
+ columnOffsets,
191
+ columnLeading,
192
+ headerHeight,
193
+ pinnedColumnCount: pinnedCount,
194
+ leadingColumnWidth,
195
+ trailingColumnWidth,
196
+ containerRef,
197
+ visibleColumns,
198
+ rowSegments: rowWindow.segments,
199
+ theadRef,
200
+ attachContainer,
201
+ setTableElement,
202
+ setColElement,
203
+ setSpacerElement,
204
+ scrollRowIntoView,
205
+ scrollColumnIntoView,
206
+ onResizeStart,
207
+ onResizeKeyDown,
208
+ onResizeReset
209
+ };
210
+ };
211
+ export { separatorFlexIndexes, useGridLayout };
@@ -0,0 +1,441 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ normalizedRect: ()=>normalizedRect,
28
+ useGridNavigation: ()=>useGridNavigation
29
+ });
30
+ const external_react_namespaceObject = require("react");
31
+ const external_react_dom_namespaceObject = require("react-dom");
32
+ const normalizedRect = (range)=>({
33
+ top: Math.min(range.anchor.row, range.focus.row),
34
+ bottom: Math.max(range.anchor.row, range.focus.row),
35
+ left: Math.min(range.anchor.col, range.focus.col),
36
+ right: Math.max(range.anchor.col, range.focus.col)
37
+ });
38
+ const clamp = (value, max)=>Math.max(0, Math.min(value, max));
39
+ const GRID_ENTRY_KEYS = [
40
+ 'ArrowUp',
41
+ 'ArrowDown',
42
+ 'ArrowLeft',
43
+ 'ArrowRight',
44
+ 'Home',
45
+ 'End'
46
+ ];
47
+ const MOVE_DELTA = {
48
+ down: {
49
+ row: 1,
50
+ col: 0
51
+ },
52
+ right: {
53
+ row: 0,
54
+ col: 1
55
+ },
56
+ left: {
57
+ row: 0,
58
+ col: -1
59
+ },
60
+ none: {
61
+ row: 0,
62
+ col: 0
63
+ }
64
+ };
65
+ const isApplePlatform = ()=>{
66
+ if ("u" < typeof navigator) return false;
67
+ const platform = navigator.userAgentData?.platform ?? navigator.platform;
68
+ return /mac|iphone|ipad|ipod|ios/i.test(platform);
69
+ };
70
+ const isTypedCharacter = (event)=>{
71
+ if (1 !== event.key.length && 'Dead' !== event.key || event.metaKey || event.nativeEvent.isComposing) return false;
72
+ if (event.ctrlKey) return event.altKey && !isApplePlatform();
73
+ return !event.altKey || isApplePlatform();
74
+ };
75
+ const ARROW_DELTAS = {
76
+ ArrowUp: {
77
+ row: -1,
78
+ col: 0
79
+ },
80
+ ArrowDown: {
81
+ row: 1,
82
+ col: 0
83
+ },
84
+ ArrowLeft: {
85
+ row: 0,
86
+ col: -1
87
+ },
88
+ ArrowRight: {
89
+ row: 0,
90
+ col: 1
91
+ }
92
+ };
93
+ const useGridNavigation = ({ table, rowIds, colIds }, options = {})=>{
94
+ const [editing, setEditing] = (0, external_react_namespaceObject.useState)(false);
95
+ const [openedByTyping, setOpenedByTyping] = (0, external_react_namespaceObject.useState)(false);
96
+ const onSelectionReplacedRef = (0, external_react_namespaceObject.useRef)(options.onSelectionReplaced);
97
+ onSelectionReplacedRef.current = options.onSelectionReplaced;
98
+ const announceReplaced = (0, external_react_namespaceObject.useCallback)((gesture)=>onSelectionReplacedRef.current?.(gesture), []);
99
+ const canEditAtRef = (0, external_react_namespaceObject.useRef)(options.canEditAt);
100
+ canEditAtRef.current = options.canEditAt;
101
+ const onEscapeRef = (0, external_react_namespaceObject.useRef)(options.onEscape);
102
+ onEscapeRef.current = options.onEscape;
103
+ const tableRef = (0, external_react_namespaceObject.useRef)(table);
104
+ tableRef.current = table;
105
+ const pendingRestoreRef = (0, external_react_namespaceObject.useRef)(void 0);
106
+ const axisRectRef = (0, external_react_namespaceObject.useRef)(null);
107
+ const rowCount = rowIds.length;
108
+ const colCount = colIds.length;
109
+ const hasCells = rowCount > 0 && colCount > 0;
110
+ const rowIndexById = (0, external_react_namespaceObject.useMemo)(()=>new Map(rowIds.map((id, index)=>[
111
+ id,
112
+ index
113
+ ])), [
114
+ rowIds
115
+ ]);
116
+ const colIndexById = (0, external_react_namespaceObject.useMemo)(()=>new Map(colIds.map((id, index)=>[
117
+ id,
118
+ index
119
+ ])), [
120
+ colIds
121
+ ]);
122
+ const toIds = (0, external_react_namespaceObject.useCallback)((position)=>{
123
+ if (!hasCells) return null;
124
+ return {
125
+ rowId: rowIds[clamp(position.row, rowCount - 1)],
126
+ columnId: colIds[clamp(position.col, colCount - 1)]
127
+ };
128
+ }, [
129
+ hasCells,
130
+ rowIds,
131
+ colIds,
132
+ rowCount,
133
+ colCount
134
+ ]);
135
+ const setRange = (0, external_react_namespaceObject.useCallback)((anchor, focus)=>{
136
+ const anchorIds = toIds(anchor);
137
+ const focusIds = toIds(focus);
138
+ if (!anchorIds || !focusIds) return;
139
+ tableRef.current.setCellSelection([
140
+ {
141
+ anchorRowId: anchorIds.rowId,
142
+ anchorColumnId: anchorIds.columnId,
143
+ focusRowId: focusIds.rowId,
144
+ focusColumnId: focusIds.columnId
145
+ }
146
+ ]);
147
+ }, [
148
+ toIds
149
+ ]);
150
+ const active = table.state.cellSelection?.[0];
151
+ const anchorRow = active ? rowIndexById.get(active.anchorRowId) : void 0;
152
+ const anchorCol = active ? colIndexById.get(active.anchorColumnId) : void 0;
153
+ const focusRow = active ? rowIndexById.get(active.focusRowId) : void 0;
154
+ const focusCol = active ? colIndexById.get(active.focusColumnId) : void 0;
155
+ const range = (0, external_react_namespaceObject.useMemo)(()=>void 0 === anchorRow || void 0 === anchorCol || void 0 === focusRow || void 0 === focusCol ? null : {
156
+ anchor: {
157
+ row: anchorRow,
158
+ col: anchorCol
159
+ },
160
+ focus: {
161
+ row: focusRow,
162
+ col: focusCol
163
+ }
164
+ }, [
165
+ anchorRow,
166
+ anchorCol,
167
+ focusRow,
168
+ focusCol
169
+ ]);
170
+ const focus = (0, external_react_namespaceObject.useMemo)(()=>range?.focus ?? null, [
171
+ range
172
+ ]);
173
+ const axisSelection = range ? axisRectRef.current : null;
174
+ const singleSelection = (0, external_react_namespaceObject.useMemo)(()=>range && !axisSelection && range.anchor.row === range.focus.row && range.anchor.col === range.focus.col ? range.focus : null, [
175
+ range,
176
+ axisSelection
177
+ ]);
178
+ const focusRowId = range ? active?.focusRowId : void 0;
179
+ const focusColumnId = range ? active?.focusColumnId : void 0;
180
+ const selectedIds = (0, external_react_namespaceObject.useMemo)(()=>void 0 === focusRowId || void 0 === focusColumnId ? null : {
181
+ rowId: focusRowId,
182
+ columnId: focusColumnId
183
+ }, [
184
+ focusRowId,
185
+ focusColumnId
186
+ ]);
187
+ (0, external_react_namespaceObject.useEffect)(()=>{
188
+ if (table.state.cellSelection?.length && !range) {
189
+ table.setCellSelection([]);
190
+ setEditing(false);
191
+ }
192
+ }, [
193
+ table,
194
+ range
195
+ ]);
196
+ const select = (0, external_react_namespaceObject.useCallback)((position)=>{
197
+ announceReplaced('cell');
198
+ axisRectRef.current = null;
199
+ setRange(position, position);
200
+ setEditing(false);
201
+ }, [
202
+ setRange,
203
+ announceReplaced
204
+ ]);
205
+ const clear = (0, external_react_namespaceObject.useCallback)(()=>{
206
+ axisRectRef.current = null;
207
+ tableRef.current.setCellSelection([]);
208
+ setEditing(false);
209
+ }, []);
210
+ const restore = (0, external_react_namespaceObject.useCallback)((next)=>{
211
+ axisRectRef.current = null;
212
+ pendingRestoreRef.current = next;
213
+ setEditing(false);
214
+ }, []);
215
+ (0, external_react_namespaceObject.useEffect)(()=>{
216
+ const pending = pendingRestoreRef.current;
217
+ if (void 0 === pending) return;
218
+ pendingRestoreRef.current = void 0;
219
+ if (pending) setRange(pending.anchor, pending.focus);
220
+ else tableRef.current.setCellSelection([]);
221
+ });
222
+ const extendTo = (0, external_react_namespaceObject.useCallback)((position)=>{
223
+ axisRectRef.current = null;
224
+ const focusIds = toIds(position);
225
+ if (!focusIds) return;
226
+ tableRef.current.setCellSelection((previous)=>{
227
+ const active = previous?.[0];
228
+ return [
229
+ {
230
+ anchorRowId: active?.anchorRowId ?? focusIds.rowId,
231
+ anchorColumnId: active?.anchorColumnId ?? focusIds.columnId,
232
+ focusRowId: focusIds.rowId,
233
+ focusColumnId: focusIds.columnId
234
+ }
235
+ ];
236
+ });
237
+ setEditing(false);
238
+ }, [
239
+ toIds
240
+ ]);
241
+ const selectAll = (0, external_react_namespaceObject.useCallback)(()=>{
242
+ announceReplaced('cell');
243
+ axisRectRef.current = null;
244
+ setRange({
245
+ row: 0,
246
+ col: 0
247
+ }, {
248
+ row: rowCount - 1,
249
+ col: colCount - 1
250
+ });
251
+ setEditing(false);
252
+ }, [
253
+ setRange,
254
+ rowCount,
255
+ colCount,
256
+ announceReplaced
257
+ ]);
258
+ const selectRow = (0, external_react_namespaceObject.useCallback)((row)=>{
259
+ announceReplaced('row');
260
+ setRange({
261
+ row,
262
+ col: colCount - 1
263
+ }, {
264
+ row,
265
+ col: 0
266
+ });
267
+ axisRectRef.current = 'row';
268
+ setEditing(false);
269
+ }, [
270
+ setRange,
271
+ colCount,
272
+ announceReplaced
273
+ ]);
274
+ const selectColumn = (0, external_react_namespaceObject.useCallback)((col)=>{
275
+ announceReplaced('column');
276
+ setRange({
277
+ row: rowCount - 1,
278
+ col
279
+ }, {
280
+ row: 0,
281
+ col
282
+ });
283
+ axisRectRef.current = 'column';
284
+ setEditing(false);
285
+ }, [
286
+ setRange,
287
+ rowCount,
288
+ announceReplaced
289
+ ]);
290
+ const openEditAt = (0, external_react_namespaceObject.useCallback)((position, byTyping)=>{
291
+ announceReplaced('cell');
292
+ axisRectRef.current = null;
293
+ setRange(position, position);
294
+ setOpenedByTyping(byTyping);
295
+ setEditing(true);
296
+ }, [
297
+ setRange,
298
+ announceReplaced
299
+ ]);
300
+ const startEditAt = (0, external_react_namespaceObject.useCallback)((position)=>openEditAt(position, false), [
301
+ openEditAt
302
+ ]);
303
+ const commitEdit = (0, external_react_namespaceObject.useCallback)((move)=>{
304
+ axisRectRef.current = null;
305
+ tableRef.current.setCellSelection((previous)=>{
306
+ const active = previous?.[0];
307
+ if (!active) return previous ?? [];
308
+ const row = rowIndexById.get(active.focusRowId);
309
+ const col = colIndexById.get(active.focusColumnId);
310
+ if (void 0 === row || void 0 === col) return previous;
311
+ const next = toIds({
312
+ row: row + MOVE_DELTA[move].row,
313
+ col: col + MOVE_DELTA[move].col
314
+ });
315
+ if (!next) return previous;
316
+ return [
317
+ {
318
+ anchorRowId: next.rowId,
319
+ anchorColumnId: next.columnId,
320
+ focusRowId: next.rowId,
321
+ focusColumnId: next.columnId
322
+ }
323
+ ];
324
+ });
325
+ setEditing(false);
326
+ }, [
327
+ toIds,
328
+ rowIndexById,
329
+ colIndexById
330
+ ]);
331
+ const cancelEdit = (0, external_react_namespaceObject.useCallback)(()=>setEditing(false), []);
332
+ const onKeyDown = (0, external_react_namespaceObject.useCallback)((event)=>{
333
+ if (editing) return;
334
+ if (event.defaultPrevented) return;
335
+ if ('Escape' === event.key) {
336
+ if (range) event.preventDefault();
337
+ clear();
338
+ onEscapeRef.current?.();
339
+ return;
340
+ }
341
+ const meta = event.metaKey || event.ctrlKey;
342
+ if (!focus) {
343
+ if (hasCells && (GRID_ENTRY_KEYS.includes(event.key) || 'Enter' === event.key || 'F2' === event.key)) {
344
+ event.preventDefault();
345
+ select({
346
+ row: 0,
347
+ col: 0
348
+ });
349
+ }
350
+ return;
351
+ }
352
+ if (meta && 'a' === event.key.toLowerCase()) {
353
+ event.preventDefault();
354
+ selectAll();
355
+ return;
356
+ }
357
+ const delta = ARROW_DELTAS[event.key];
358
+ if (delta) {
359
+ event.preventDefault();
360
+ const from = event.shiftKey && range ? range.focus : focus;
361
+ const next = {
362
+ row: meta ? 0 === delta.row ? from.row : delta.row < 0 ? 0 : rowCount - 1 : from.row + delta.row,
363
+ col: meta ? 0 === delta.col ? from.col : delta.col < 0 ? 0 : colCount - 1 : from.col + delta.col
364
+ };
365
+ if (event.shiftKey) extendTo(next);
366
+ else select(next);
367
+ return;
368
+ }
369
+ if ('Home' === event.key || 'End' === event.key) {
370
+ event.preventDefault();
371
+ const next = {
372
+ row: meta ? 'Home' === event.key ? 0 : rowCount - 1 : focus.row,
373
+ col: 'Home' === event.key ? 0 : colCount - 1
374
+ };
375
+ if (event.shiftKey) extendTo(next);
376
+ else select(next);
377
+ return;
378
+ }
379
+ if ('Enter' === event.key || 'F2' === event.key) {
380
+ event.preventDefault();
381
+ if (canEditAtRef.current?.(focus, 'command') !== false) {
382
+ setOpenedByTyping(false);
383
+ setEditing(true);
384
+ }
385
+ return;
386
+ }
387
+ if ('Tab' === event.key && !meta && !event.altKey) {
388
+ const col = focus.col + (event.shiftKey ? -1 : 1);
389
+ if (col < 0 || col >= colCount) return;
390
+ event.preventDefault();
391
+ select({
392
+ row: focus.row,
393
+ col
394
+ });
395
+ return;
396
+ }
397
+ if (isTypedCharacter(event) && canEditAtRef.current?.(focus, 'type') !== false) (0, external_react_dom_namespaceObject.flushSync)(()=>openEditAt(focus, true));
398
+ }, [
399
+ editing,
400
+ focus,
401
+ range,
402
+ hasCells,
403
+ rowCount,
404
+ colCount,
405
+ extendTo,
406
+ select,
407
+ selectAll,
408
+ clear,
409
+ openEditAt
410
+ ]);
411
+ return {
412
+ focus,
413
+ singleSelection,
414
+ selectedIds,
415
+ range,
416
+ axisSelection,
417
+ focusRing: axisSelection ? null : focus,
418
+ editing,
419
+ openedByTyping: editing && openedByTyping,
420
+ select,
421
+ clear,
422
+ restore,
423
+ extendTo,
424
+ selectAll,
425
+ selectRow,
426
+ selectColumn,
427
+ startEditAt,
428
+ commitEdit,
429
+ cancelEdit,
430
+ onKeyDown
431
+ };
432
+ };
433
+ exports.normalizedRect = __webpack_exports__.normalizedRect;
434
+ exports.useGridNavigation = __webpack_exports__.useGridNavigation;
435
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
436
+ "normalizedRect",
437
+ "useGridNavigation"
438
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
439
+ Object.defineProperty(exports, '__esModule', {
440
+ value: true
441
+ });