@uipath/apollo-react 7.11.4 → 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 (89) hide show
  1. package/dist/canvas/styles/tailwind.canvas.css +1 -1
  2. package/dist/chat/styles/tailwind.chat.css +1 -1
  3. package/dist/decision-table/DecisionTable.cjs +454 -0
  4. package/dist/decision-table/DecisionTable.d.ts +36 -0
  5. package/dist/decision-table/DecisionTable.d.ts.map +1 -0
  6. package/dist/decision-table/DecisionTable.js +410 -0
  7. package/dist/decision-table/GridCell.cjs +153 -0
  8. package/dist/decision-table/GridCell.d.ts +43 -0
  9. package/dist/decision-table/GridCell.d.ts.map +1 -0
  10. package/dist/decision-table/GridCell.js +116 -0
  11. package/dist/decision-table/GridMenu.cjs +135 -0
  12. package/dist/decision-table/GridMenu.d.ts +30 -0
  13. package/dist/decision-table/GridMenu.d.ts.map +1 -0
  14. package/dist/decision-table/GridMenu.js +101 -0
  15. package/dist/decision-table/MarkGlyph.cjs +51 -0
  16. package/dist/decision-table/MarkGlyph.d.ts +7 -0
  17. package/dist/decision-table/MarkGlyph.d.ts.map +1 -0
  18. package/dist/decision-table/MarkGlyph.js +17 -0
  19. package/dist/decision-table/clipboardCodec.cjs +123 -0
  20. package/dist/decision-table/clipboardCodec.d.ts +8 -0
  21. package/dist/decision-table/clipboardCodec.d.ts.map +1 -0
  22. package/dist/decision-table/clipboardCodec.js +80 -0
  23. package/dist/decision-table/clippedTitle.cjs +39 -0
  24. package/dist/decision-table/clippedTitle.d.ts +3 -0
  25. package/dist/decision-table/clippedTitle.d.ts.map +1 -0
  26. package/dist/decision-table/clippedTitle.js +5 -0
  27. package/dist/decision-table/columnSizing.cjs +92 -0
  28. package/dist/decision-table/columnSizing.d.ts +13 -0
  29. package/dist/decision-table/columnSizing.d.ts.map +1 -0
  30. package/dist/decision-table/columnSizing.js +52 -0
  31. package/dist/decision-table/constants.cjs +84 -0
  32. package/dist/decision-table/constants.d.ts +14 -0
  33. package/dist/decision-table/constants.d.ts.map +1 -0
  34. package/dist/decision-table/constants.js +14 -0
  35. package/dist/decision-table/gridClipboard.cjs +129 -0
  36. package/dist/decision-table/gridClipboard.d.ts +19 -0
  37. package/dist/decision-table/gridClipboard.d.ts.map +1 -0
  38. package/dist/decision-table/gridClipboard.js +89 -0
  39. package/dist/decision-table/gridEvents.cjs +72 -0
  40. package/dist/decision-table/gridEvents.d.ts +14 -0
  41. package/dist/decision-table/gridEvents.d.ts.map +1 -0
  42. package/dist/decision-table/gridEvents.js +23 -0
  43. package/dist/decision-table/gridStyles.cjs +196 -0
  44. package/dist/decision-table/gridStyles.d.ts +47 -0
  45. package/dist/decision-table/gridStyles.d.ts.map +1 -0
  46. package/dist/decision-table/gridStyles.js +54 -0
  47. package/dist/decision-table/gridTypes.cjs +18 -0
  48. package/dist/decision-table/gridTypes.d.ts +93 -0
  49. package/dist/decision-table/gridTypes.d.ts.map +1 -0
  50. package/dist/decision-table/gridTypes.js +0 -0
  51. package/dist/decision-table/index.cjs +271 -0
  52. package/dist/decision-table/index.d.ts +13 -0
  53. package/dist/decision-table/index.d.ts.map +1 -0
  54. package/dist/decision-table/index.js +12 -0
  55. package/dist/decision-table/marks.cjs +39 -0
  56. package/dist/decision-table/marks.d.ts +20 -0
  57. package/dist/decision-table/marks.d.ts.map +1 -0
  58. package/dist/decision-table/marks.js +5 -0
  59. package/dist/decision-table/styles/tailwind.decision-table.css +2 -0
  60. package/dist/decision-table/useColumnWidths.cjs +313 -0
  61. package/dist/decision-table/useColumnWidths.d.ts +21 -0
  62. package/dist/decision-table/useColumnWidths.d.ts.map +1 -0
  63. package/dist/decision-table/useColumnWidths.js +279 -0
  64. package/dist/decision-table/useDragReorder.cjs +229 -0
  65. package/dist/decision-table/useDragReorder.d.ts +31 -0
  66. package/dist/decision-table/useDragReorder.d.ts.map +1 -0
  67. package/dist/decision-table/useDragReorder.js +186 -0
  68. package/dist/decision-table/useDragSelection.cjs +75 -0
  69. package/dist/decision-table/useDragSelection.d.ts +18 -0
  70. package/dist/decision-table/useDragSelection.d.ts.map +1 -0
  71. package/dist/decision-table/useDragSelection.js +41 -0
  72. package/dist/decision-table/useGridClipboard.cjs +195 -0
  73. package/dist/decision-table/useGridClipboard.d.ts +13 -0
  74. package/dist/decision-table/useGridClipboard.d.ts.map +1 -0
  75. package/dist/decision-table/useGridClipboard.js +161 -0
  76. package/dist/decision-table/useGridLayout.cjs +248 -0
  77. package/dist/decision-table/useGridLayout.d.ts +50 -0
  78. package/dist/decision-table/useGridLayout.d.ts.map +1 -0
  79. package/dist/decision-table/useGridLayout.js +211 -0
  80. package/dist/decision-table/useGridNavigation.cjs +441 -0
  81. package/dist/decision-table/useGridNavigation.d.ts +67 -0
  82. package/dist/decision-table/useGridNavigation.d.ts.map +1 -0
  83. package/dist/decision-table/useGridNavigation.js +404 -0
  84. package/dist/decision-table/useVirtualizedAxis.cjs +256 -0
  85. package/dist/decision-table/useVirtualizedAxis.d.ts +34 -0
  86. package/dist/decision-table/useVirtualizedAxis.d.ts.map +1 -0
  87. package/dist/decision-table/useVirtualizedAxis.js +219 -0
  88. package/dist/test/setup.d.ts.map +1 -1
  89. package/package.json +20 -10
@@ -0,0 +1,410 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { cn } from "@uipath/apollo-wind";
3
+ import { ArrowRight } from "lucide-react";
4
+ import react, { forwardRef, useCallback, useEffect, useImperativeHandle, useRef } from "react";
5
+ import { BODY_ROW_HEIGHT_PX, MIN_COLUMN_WIDTH } from "./constants.js";
6
+ import { GRID_FRAME_CLASS, GRID_PANE_CLASS, GROUP_CELL_CLASS, GROUP_GUTTER_CLASS, HEADER_CELL_CLASS, HOST_FRAMED_CONTAINER_CLASS, OMIT_BORDER_CLASS, RESIZE_HANDLE_CLASS, SEPARATOR_GROUP_CELL_CLASS, SEPARATOR_HEADER_CELL_CLASS, TABLE_EDGE_CLASS, TABLE_HUG_EDGE_CLASS } from "./gridStyles.js";
7
+ import { useDragReorder } from "./useDragReorder.js";
8
+ import { useGridClipboard } from "./useGridClipboard.js";
9
+ import { useGridLayout } from "./useGridLayout.js";
10
+ const groupColumnRuns = (visibleColumns, pinnedLeftPxOf)=>{
11
+ const runs = [];
12
+ const openedGroups = new Set();
13
+ for (const visible of visibleColumns){
14
+ if ('spacer' === visible.type) {
15
+ runs.push({
16
+ type: 'spacer',
17
+ widthPx: visible.widthPx,
18
+ firstCoveredId: visible.coveredIds[0]
19
+ });
20
+ continue;
21
+ }
22
+ if ('separator' === visible.type) {
23
+ runs.push({
24
+ type: 'separator',
25
+ widthPx: visible.widthPx,
26
+ beforeColumnId: visible.beforeColumnId
27
+ });
28
+ continue;
29
+ }
30
+ const { column, flexIndex } = visible;
31
+ const last = runs[runs.length - 1];
32
+ const pinnedLeftPx = pinnedLeftPxOf(flexIndex);
33
+ const samePinning = (previous)=>void 0 !== previous.pinnedLeftPx === (void 0 !== pinnedLeftPx);
34
+ if (!column.group) {
35
+ if (last?.type === 'gutter' && samePinning(last)) last.count += 1;
36
+ else runs.push({
37
+ type: 'gutter',
38
+ count: 1,
39
+ firstFlexIndex: flexIndex,
40
+ pinnedLeftPx
41
+ });
42
+ continue;
43
+ }
44
+ if (last?.type === 'group' && last.group.id === column.group.id && samePinning(last)) last.count += 1;
45
+ else {
46
+ runs.push({
47
+ type: 'group',
48
+ group: column.group,
49
+ first: column,
50
+ firstFlexIndex: flexIndex,
51
+ count: 1,
52
+ pinnedLeftPx,
53
+ isFirstRunOfGroup: !openedGroups.has(column.group.id)
54
+ });
55
+ openedGroups.add(column.group.id);
56
+ }
57
+ }
58
+ return runs;
59
+ };
60
+ const DecisionTable = /*#__PURE__*/ forwardRef(({ columns, rowCount, rowHeightPx = BODY_ROW_HEIGHT_PX, leadingColumnWidth = 0, trailingColumnWidth = 0, pinnedColumnCount = 0, initialColumnWidths = {}, onColumnWidthsChange, columnsResizable = false, framedByHost = false, columnGroupSizes, onRowMove, onColumnMove, retainedRowIndex = null, retainedColumnIndex = null, renderHeaderCell, renderRow, renderFooterRow, trailingHeaderCell, trailingGroupCell, tableAriaLabel, clipboard, containerProps, dataTestId, labels, children }, ref)=>{
61
+ const containerRef = useRef(null);
62
+ const layoutRef = useRef(null);
63
+ const headerHeight = useCallback(()=>layoutRef.current?.headerHeight() ?? 0, []);
64
+ const columnLeading = useCallback(()=>layoutRef.current?.columnLeading() ?? 0, []);
65
+ const columnOffsets = useCallback(()=>layoutRef.current?.columnOffsets ?? [], []);
66
+ const onRowMoveRef = useRef(onRowMove);
67
+ onRowMoveRef.current = onRowMove;
68
+ const onColumnMoveRef = useRef(onColumnMove);
69
+ onColumnMoveRef.current = onColumnMove;
70
+ const sizesKey = (columnGroupSizes ?? []).join(',');
71
+ const boundaries = react.useMemo(()=>{
72
+ const out = [
73
+ 0
74
+ ];
75
+ for (const size of columnGroupSizes ?? [])out.push(out[out.length - 1] + size);
76
+ return out;
77
+ }, [
78
+ sizesKey
79
+ ]);
80
+ const { dragState, startRowDrag, startColumnDrag: beginColumnDrag } = useDragReorder({
81
+ containerRef,
82
+ headerHeight,
83
+ columnLeading,
84
+ columnOffsets,
85
+ rowHeightPx,
86
+ rowCount,
87
+ columnGroupBoundaries: boundaries,
88
+ onDropRow: (from, to)=>onRowMoveRef.current?.(from, to),
89
+ onDropColumn: (groupIndex, from, to)=>onColumnMoveRef.current?.(groupIndex, from, to)
90
+ });
91
+ const boundariesRef = useRef(boundaries);
92
+ boundariesRef.current = boundaries;
93
+ const startColumnDrag = useCallback((groupIndex, indexInGroup, event)=>{
94
+ if (boundariesRef.current.length >= 2) beginColumnDrag(groupIndex, indexInGroup, event);
95
+ }, [
96
+ beginColumnDrag
97
+ ]);
98
+ const dragRetainedRow = dragState?.axis === 'row' ? dragState.from : null;
99
+ const dragRetainedColumn = dragState?.axis === 'column' ? (boundaries[dragState.groupIndex] ?? 0) + dragState.from : null;
100
+ const layout = useGridLayout({
101
+ columns,
102
+ rowCount,
103
+ rowHeightPx,
104
+ leadingColumnWidth,
105
+ trailingColumnWidth,
106
+ pinnedColumnCount,
107
+ initialColumnWidths,
108
+ onColumnWidthsChange,
109
+ containerRef,
110
+ retainedRowIndex: retainedRowIndex ?? dragRetainedRow,
111
+ retainedColumnIndex: retainedColumnIndex ?? dragRetainedColumn,
112
+ framedByHost
113
+ });
114
+ layoutRef.current = layout;
115
+ const { visibleColumns, widths, totalWidth } = layout;
116
+ const hasTrailing = trailingColumnWidth > 0;
117
+ const hasLeading = leadingColumnWidth > 0;
118
+ const hasGroupRow = columns.some((column)=>void 0 !== column.group) || void 0 !== trailingGroupCell;
119
+ const hostTopEdge = framedByHost && OMIT_BORDER_CLASS.top;
120
+ const headerRowCount = hasGroupRow ? 2 : 1;
121
+ const gridClipboard = useGridClipboard(clipboard, {
122
+ rowCount,
123
+ columnCount: columns.length
124
+ });
125
+ useImperativeHandle(ref, ()=>({
126
+ container: ()=>containerRef.current,
127
+ headerHeight,
128
+ columnLeading,
129
+ columnOffsets,
130
+ totalWidth: ()=>layoutRef.current?.totalWidth ?? 0,
131
+ scrollRowIntoView: (rowIndex)=>layoutRef.current?.scrollRowIntoView(rowIndex),
132
+ scrollColumnIntoView: (windowIndex)=>layoutRef.current?.scrollColumnIntoView(windowIndex),
133
+ startRowDrag,
134
+ startColumnDrag,
135
+ clipboard: gridClipboard.actions
136
+ }), [
137
+ headerHeight,
138
+ columnLeading,
139
+ columnOffsets,
140
+ startRowDrag,
141
+ startColumnDrag,
142
+ gridClipboard.actions
143
+ ]);
144
+ const focusWithinRef = useRef(false);
145
+ useEffect(()=>{
146
+ if (focusWithinRef.current && document.activeElement === document.body) containerRef.current?.focus();
147
+ });
148
+ const pinnedLeftPxOf = (flexIndex)=>{
149
+ if (flexIndex >= layout.pinnedColumnCount) return;
150
+ let offset = leadingColumnWidth;
151
+ for(let index = 0; index < flexIndex; index += 1)offset += widths[index] ?? 0;
152
+ return offset;
153
+ };
154
+ const renderResizeHandle = (column, width)=>{
155
+ if (!columnsResizable) return null;
156
+ if (column.id === columns[columns.length - 1]?.id) return null;
157
+ return /*#__PURE__*/ jsx("span", {
158
+ className: RESIZE_HANDLE_CLASS,
159
+ role: "separator",
160
+ "aria-orientation": "vertical",
161
+ "aria-valuenow": Math.round(width),
162
+ "aria-valuemin": MIN_COLUMN_WIDTH,
163
+ "aria-valuemax": Math.round(totalWidth),
164
+ tabIndex: 0,
165
+ "data-testid": `${dataTestId}-resize-${column.id}`,
166
+ "aria-label": labels.resizeColumn(column.name),
167
+ title: labels.resetColumnWidth,
168
+ onPointerDown: (event)=>layout.onResizeStart(column.id, event),
169
+ onKeyDown: (event)=>layout.onResizeKeyDown(column.id, event),
170
+ onDoubleClick: (event)=>{
171
+ event.stopPropagation();
172
+ layout.onResizeReset(column.id);
173
+ },
174
+ onClick: (event)=>event.stopPropagation()
175
+ });
176
+ };
177
+ const pinnedEdgePx = leadingColumnWidth + widths.slice(0, layout.pinnedColumnCount).reduce((sum, width)=>sum + width, 0);
178
+ const bodyColSpan = (hasLeading ? 1 : 0) + visibleColumns.length + (hasTrailing ? 1 : 0);
179
+ const { onFocus: consumerFocus, onBlur: consumerBlur, onKeyDown: consumerKeyDown, onCopy: consumerCopy, onCut: consumerCut, onPaste: consumerPaste, ...restContainerProps } = containerProps ?? {};
180
+ const composeClipboard = (mine, theirs)=>(event)=>{
181
+ mine?.(event);
182
+ if (!event.defaultPrevented) theirs?.(event);
183
+ };
184
+ const scrollContainer = /*#__PURE__*/ jsxs("div", {
185
+ className: framedByHost ? HOST_FRAMED_CONTAINER_CLASS : GRID_FRAME_CLASS,
186
+ ref: layout.attachContainer,
187
+ tabIndex: 0,
188
+ onFocus: (event)=>{
189
+ focusWithinRef.current = true;
190
+ consumerFocus?.(event);
191
+ },
192
+ onBlur: (event)=>{
193
+ if (!(event.relatedTarget instanceof Node) || !event.currentTarget.contains(event.relatedTarget)) focusWithinRef.current = false;
194
+ consumerBlur?.(event);
195
+ },
196
+ onKeyDown: (event)=>{
197
+ if (!gridClipboard.handleKeyDown(event)) consumerKeyDown?.(event);
198
+ },
199
+ "data-testid": dataTestId,
200
+ onCopy: composeClipboard(gridClipboard.containerProps.onCopy, consumerCopy),
201
+ onCut: composeClipboard(gridClipboard.containerProps.onCut, consumerCut),
202
+ onPaste: composeClipboard(gridClipboard.containerProps.onPaste, consumerPaste),
203
+ ...restContainerProps,
204
+ children: [
205
+ /*#__PURE__*/ jsxs("table", {
206
+ className: cn('table-fixed border-separate border-spacing-0 text-xs text-foreground', !framedByHost && [
207
+ TABLE_EDGE_CLASS,
208
+ TABLE_HUG_EDGE_CLASS
209
+ ]),
210
+ ref: layout.setTableElement,
211
+ style: {
212
+ width: totalWidth,
213
+ '--grid-row-height': `${rowHeightPx}px`,
214
+ '--grid-pinned-left': `${pinnedEdgePx}px`
215
+ },
216
+ "aria-label": tableAriaLabel,
217
+ "aria-rowcount": rowCount + headerRowCount + (renderFooterRow ? 1 : 0),
218
+ children: [
219
+ /*#__PURE__*/ jsxs("colgroup", {
220
+ children: [
221
+ hasLeading && /*#__PURE__*/ jsx("col", {
222
+ style: {
223
+ width: leadingColumnWidth
224
+ }
225
+ }),
226
+ visibleColumns.map((visible)=>{
227
+ if ('separator' === visible.type) return /*#__PURE__*/ jsx("col", {
228
+ style: {
229
+ width: visible.widthPx
230
+ }
231
+ }, `col-separator-${visible.beforeColumnId}`);
232
+ if ('spacer' === visible.type) return /*#__PURE__*/ jsx("col", {
233
+ ref: (element)=>layout.setSpacerElement(`colgroup-spacer-${visible.coveredIds[0]}`, visible.coveredIds, element, visible.separatorPx),
234
+ style: {
235
+ width: visible.widthPx
236
+ }
237
+ }, `col-spacer-${visible.coveredIds[0]}`);
238
+ return /*#__PURE__*/ jsx("col", {
239
+ ref: (element)=>layout.setColElement(visible.column.id, element),
240
+ style: {
241
+ width: widths[visible.flexIndex]
242
+ }
243
+ }, visible.column.id);
244
+ }),
245
+ hasTrailing && /*#__PURE__*/ jsx("col", {
246
+ style: {
247
+ width: trailingColumnWidth
248
+ }
249
+ })
250
+ ]
251
+ }),
252
+ /*#__PURE__*/ jsxs("thead", {
253
+ ref: layout.theadRef,
254
+ children: [
255
+ hasGroupRow && /*#__PURE__*/ jsxs("tr", {
256
+ "aria-rowindex": 1,
257
+ className: cn(framedByHost && '[&>*:last-child]:border-r-0'),
258
+ children: [
259
+ hasLeading && /*#__PURE__*/ jsx("td", {
260
+ "aria-hidden": "true",
261
+ className: cn(GROUP_GUTTER_CLASS, 'left-0 z-3', hostTopEdge)
262
+ }),
263
+ groupColumnRuns(visibleColumns, pinnedLeftPxOf).map((run)=>{
264
+ if ('spacer' === run.type) return /*#__PURE__*/ jsx("td", {
265
+ "aria-hidden": "true",
266
+ className: cn(GROUP_GUTTER_CLASS, hostTopEdge),
267
+ style: {
268
+ width: run.widthPx
269
+ }
270
+ }, `group-spacer-${run.firstCoveredId}`);
271
+ if ('separator' === run.type) return /*#__PURE__*/ jsx("td", {
272
+ "aria-hidden": "true",
273
+ "data-separator": "group",
274
+ className: cn(SEPARATOR_GROUP_CELL_CLASS, hostTopEdge),
275
+ style: {
276
+ width: run.widthPx
277
+ }
278
+ }, `group-separator-${run.beforeColumnId}`);
279
+ if ('gutter' === run.type) return /*#__PURE__*/ jsx("td", {
280
+ "aria-hidden": "true",
281
+ className: cn(GROUP_GUTTER_CLASS, void 0 !== run.pinnedLeftPx && 'z-3', hostTopEdge),
282
+ style: void 0 !== run.pinnedLeftPx ? {
283
+ left: run.pinnedLeftPx
284
+ } : void 0,
285
+ colSpan: run.count
286
+ }, `group-gutter-${run.firstFlexIndex}`);
287
+ const groupCellProps = run.group.cellProps?.(run.first, run.firstFlexIndex);
288
+ return /*#__PURE__*/ jsx("th", {
289
+ ...groupCellProps,
290
+ className: cn(GROUP_CELL_CLASS, run.group.toneClassName, groupCellProps?.className, void 0 !== run.pinnedLeftPx && 'z-3', hostTopEdge),
291
+ style: void 0 !== run.pinnedLeftPx ? {
292
+ left: run.pinnedLeftPx
293
+ } : void 0,
294
+ scope: "colgroup",
295
+ colSpan: run.count,
296
+ children: run.group.renderLabel ? run.group.renderLabel({
297
+ first: run.first,
298
+ firstFlexIndex: run.firstFlexIndex,
299
+ isFirstRunOfGroup: run.isFirstRunOfGroup,
300
+ label: run.group.label
301
+ }) : run.group.label
302
+ }, `group-${run.group.id}-${run.firstFlexIndex}`);
303
+ }),
304
+ hasTrailing && (trailingGroupCell ?? /*#__PURE__*/ jsx("td", {
305
+ "aria-hidden": "true",
306
+ className: cn(GROUP_GUTTER_CLASS, 'right-0 z-3')
307
+ }))
308
+ ]
309
+ }),
310
+ /*#__PURE__*/ jsxs("tr", {
311
+ "aria-rowindex": headerRowCount,
312
+ className: cn(framedByHost && '[&>*:last-child]:border-r-0'),
313
+ children: [
314
+ hasLeading && /*#__PURE__*/ jsx("th", {
315
+ className: cn(HEADER_CELL_CLASS, 'left-0 z-3 text-center align-middle'),
316
+ scope: "col",
317
+ children: labels.rowNumberHeader ?? '#'
318
+ }),
319
+ visibleColumns.map((visible)=>{
320
+ if ('separator' === visible.type) return /*#__PURE__*/ jsx("td", {
321
+ "aria-hidden": "true",
322
+ "data-separator": "header",
323
+ "data-testid": `${dataTestId}-separator-${visible.beforeColumnId}`,
324
+ className: SEPARATOR_HEADER_CELL_CLASS,
325
+ style: {
326
+ width: visible.widthPx
327
+ },
328
+ children: /*#__PURE__*/ jsx(ArrowRight, {
329
+ "aria-hidden": true,
330
+ className: "inline-block size-3.5"
331
+ })
332
+ }, `header-separator-${visible.beforeColumnId}`);
333
+ if ('spacer' === visible.type) return /*#__PURE__*/ jsx("td", {
334
+ "aria-hidden": "true",
335
+ className: HEADER_CELL_CLASS,
336
+ style: {
337
+ width: visible.widthPx
338
+ }
339
+ }, `header-spacer-${visible.coveredIds[0]}`);
340
+ const width = widths[visible.flexIndex] ?? visible.column.defaultWidth;
341
+ return /*#__PURE__*/ jsx(react.Fragment, {
342
+ children: renderHeaderCell(visible.column, {
343
+ resizeHandle: renderResizeHandle(visible.column, width),
344
+ pinnedLeftPx: pinnedLeftPxOf(visible.flexIndex)
345
+ })
346
+ }, visible.column.id);
347
+ }),
348
+ hasTrailing && trailingHeaderCell
349
+ ]
350
+ })
351
+ ]
352
+ }),
353
+ /*#__PURE__*/ jsxs("tbody", {
354
+ children: [
355
+ (()=>{
356
+ let nextRowIndex = 0;
357
+ return layout.rowSegments.flatMap((segment)=>{
358
+ if ('spacer' === segment.type) return /*#__PURE__*/ jsx("tr", {
359
+ role: "presentation",
360
+ "data-testid": `${dataTestId}-row-spacer`,
361
+ children: /*#__PURE__*/ jsx("td", {
362
+ colSpan: bodyColSpan,
363
+ style: {
364
+ padding: 0,
365
+ border: 'none',
366
+ height: segment.sizePx
367
+ }
368
+ })
369
+ }, `spacer-${nextRowIndex}`);
370
+ const rows = [];
371
+ for(let rowIndex = segment.from; rowIndex < segment.to; rowIndex++)rows.push(renderRow(rowIndex, visibleColumns));
372
+ nextRowIndex = segment.to;
373
+ return rows;
374
+ });
375
+ })(),
376
+ renderFooterRow?.(bodyColSpan)
377
+ ]
378
+ })
379
+ ]
380
+ }),
381
+ dragState && /*#__PURE__*/ jsx("div", {
382
+ className: "pointer-events-none absolute z-4 bg-primary",
383
+ "data-testid": `${dataTestId}-drop-indicator`,
384
+ style: 'row' === dragState.axis ? {
385
+ top: headerHeight() + dragState.boundary * rowHeightPx - 1,
386
+ left: 0,
387
+ width: totalWidth,
388
+ height: 2
389
+ } : {
390
+ left: columnLeading() + (layout.columnOffsets[(boundaries[dragState.groupIndex] ?? 0) + dragState.boundary] ?? 0) - 1,
391
+ top: 0,
392
+ width: 2,
393
+ height: headerHeight() + rowCount * rowHeightPx
394
+ }
395
+ }),
396
+ children
397
+ ]
398
+ });
399
+ if (framedByHost) return scrollContainer;
400
+ const consumerPointerDown = restContainerProps.onPointerDown;
401
+ return /*#__PURE__*/ jsx("div", {
402
+ className: GRID_PANE_CLASS,
403
+ onPointerDown: (event)=>{
404
+ if (event.target === event.currentTarget) consumerPointerDown?.(event);
405
+ },
406
+ children: scrollContainer
407
+ });
408
+ });
409
+ DecisionTable.displayName = 'DecisionTable';
410
+ export { DecisionTable };
@@ -0,0 +1,153 @@
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
+ renderRestingCellContent: ()=>renderRestingCellContent,
28
+ GridCell: ()=>GridCell
29
+ });
30
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
31
+ const apollo_wind_namespaceObject = require("@uipath/apollo-wind");
32
+ const external_react_namespaceObject = require("react");
33
+ const external_clippedTitle_cjs_namespaceObject = require("./clippedTitle.cjs");
34
+ const external_gridEvents_cjs_namespaceObject = require("./gridEvents.cjs");
35
+ const external_gridStyles_cjs_namespaceObject = require("./gridStyles.cjs");
36
+ const external_MarkGlyph_cjs_namespaceObject = require("./MarkGlyph.cjs");
37
+ const renderRestingCellContent = (value, placeholder)=>{
38
+ if (value) return value;
39
+ return placeholder ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
40
+ className: "text-foreground-de-emp italic",
41
+ children: placeholder
42
+ }) : null;
43
+ };
44
+ const GridCell = ({ value, restingValue, placeholder, mono, readOnly, pinnedLeft, row, col, selected, inRange, editing, openedByTyping, renderEditor, suffix, focusable, tabStop = true, className, mark, markGroup, omitBorders, dataTestId, ariaLabel, onSelect, onStartEdit, onCommit, onCancel, onDraftChange })=>{
45
+ const settledByKeyRef = (0, external_react_namespaceObject.useRef)(false);
46
+ const keyCommittedValueRef = (0, external_react_namespaceObject.useRef)(null);
47
+ const isEditing = editing && !readOnly;
48
+ const restingTabIndex = isEditing || !tabStop ? -1 : 0;
49
+ const cellRef = (0, external_react_namespaceObject.useRef)(null);
50
+ const wasEditingRef = (0, external_react_namespaceObject.useRef)(isEditing);
51
+ (0, external_react_namespaceObject.useLayoutEffect)(()=>{
52
+ if (focusable && wasEditingRef.current && !isEditing && settledByKeyRef.current) cellRef.current?.focus();
53
+ wasEditingRef.current = isEditing;
54
+ });
55
+ const handleEditorKeyDown = (event)=>{
56
+ if (event.nativeEvent.isComposing || 229 === event.nativeEvent.keyCode) return;
57
+ if ('Enter' === event.key || 'Tab' === event.key) {
58
+ event.preventDefault();
59
+ settledByKeyRef.current = true;
60
+ keyCommittedValueRef.current = event.currentTarget.value;
61
+ onCommit(event.currentTarget.value, (0, external_gridEvents_cjs_namespaceObject.commitMoveFor)(event));
62
+ return;
63
+ }
64
+ if ('Escape' === event.key) {
65
+ settledByKeyRef.current = true;
66
+ onCancel();
67
+ }
68
+ };
69
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("td", {
70
+ ref: cellRef,
71
+ className: (0, apollo_wind_namespaceObject.cn)(external_gridStyles_cjs_namespaceObject.BODY_CELL_CLASS, omitBorders?.map((edge)=>external_gridStyles_cjs_namespaceObject.OMIT_BORDER_CLASS[edge]), mono && 'font-mono', 'font-normal', selected && 'shadow-[inset_0_0_0_2px_var(--color-primary)]', isEditing && 'select-text', inRange && external_gridStyles_cjs_namespaceObject.IN_RANGE_CLASS, void 0 !== pinnedLeft && 'sticky z-1 bg-background', className, external_gridStyles_cjs_namespaceObject.CELL_MARK_CLASS),
72
+ style: void 0 !== pinnedLeft ? {
73
+ left: pinnedLeft
74
+ } : void 0,
75
+ "data-menu-target": "cell",
76
+ "data-row": row,
77
+ "data-col": col,
78
+ "data-testid": dataTestId,
79
+ "data-tone": mark?.tone,
80
+ "data-mark-title": isEditing ? void 0 : mark?.title,
81
+ "data-mark-group": markGroup,
82
+ "data-mark-matched": isEditing ? void 0 : mark?.matched,
83
+ "data-selected": selected ? 'true' : 'false',
84
+ "data-in-range": inRange ? 'true' : 'false',
85
+ "aria-label": ariaLabel,
86
+ onClick: (event)=>{
87
+ if (!isEditing) onSelect(event.shiftKey);
88
+ },
89
+ onDoubleClick: ()=>{
90
+ if (!readOnly) onStartEdit();
91
+ },
92
+ tabIndex: focusable ? restingTabIndex : void 0,
93
+ onKeyDown: focusable ? (event)=>{
94
+ if (editing || !selected || 'Enter' !== event.key && 'F2' !== event.key) return;
95
+ event.preventDefault();
96
+ onSelect(false);
97
+ if (!readOnly) onStartEdit();
98
+ } : void 0,
99
+ children: [
100
+ !isEditing && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
101
+ className: (0, apollo_wind_namespaceObject.cn)(external_gridStyles_cjs_namespaceObject.CELL_SURFACE_CLASS, 'flex items-center'),
102
+ children: [
103
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
104
+ className: "min-w-0 truncate",
105
+ onMouseEnter: external_clippedTitle_cjs_namespaceObject.showTitleIfClipped,
106
+ children: [
107
+ renderRestingCellContent(restingValue ?? value, placeholder),
108
+ suffix
109
+ ]
110
+ }),
111
+ mark?.glyph && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_MarkGlyph_cjs_namespaceObject.MarkGlyph, {
112
+ tone: mark.tone,
113
+ className: "ml-1"
114
+ })
115
+ ]
116
+ }),
117
+ isEditing && renderEditor?.({
118
+ value,
119
+ openedByTyping,
120
+ ariaLabel,
121
+ onCommit,
122
+ onCancel,
123
+ onDraftChange
124
+ }),
125
+ isEditing && !renderEditor && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("input", {
126
+ className: external_gridStyles_cjs_namespaceObject.CELL_EDITOR_CLASS,
127
+ "aria-label": ariaLabel,
128
+ "data-testid": `${dataTestId}-editor`,
129
+ autoFocus: true,
130
+ defaultValue: value,
131
+ onFocus: (event)=>{
132
+ settledByKeyRef.current = false;
133
+ keyCommittedValueRef.current = null;
134
+ event.currentTarget.select();
135
+ },
136
+ onChange: (event)=>onDraftChange?.(event.currentTarget.value),
137
+ onKeyDown: handleEditorKeyDown,
138
+ onBlur: (event)=>{
139
+ if (!settledByKeyRef.current || event.currentTarget.value !== keyCommittedValueRef.current) onCommit(event.currentTarget.value, 'none');
140
+ }
141
+ })
142
+ ]
143
+ });
144
+ };
145
+ exports.GridCell = __webpack_exports__.GridCell;
146
+ exports.renderRestingCellContent = __webpack_exports__.renderRestingCellContent;
147
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
148
+ "GridCell",
149
+ "renderRestingCellContent"
150
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
151
+ Object.defineProperty(exports, '__esModule', {
152
+ value: true
153
+ });
@@ -0,0 +1,43 @@
1
+ import type React from 'react';
2
+ import type { CellCommitMove, CellEdge } from './gridTypes';
3
+ import type { Mark } from './marks';
4
+ export interface GridCellEditorContext {
5
+ value: string;
6
+ openedByTyping?: boolean;
7
+ ariaLabel: string;
8
+ onCommit: (text: string, move: CellCommitMove) => void;
9
+ onCancel: () => void;
10
+ onDraftChange?: (text: string) => void;
11
+ }
12
+ export interface GridCellProps {
13
+ value: string;
14
+ restingValue?: string;
15
+ placeholder?: string;
16
+ mono?: boolean;
17
+ readOnly?: boolean;
18
+ pinnedLeft?: number;
19
+ row: number;
20
+ col: number;
21
+ selected: boolean;
22
+ inRange?: boolean;
23
+ editing: boolean;
24
+ openedByTyping?: boolean;
25
+ renderEditor?: (context: GridCellEditorContext) => React.ReactNode;
26
+ suffix?: React.ReactNode;
27
+ focusable?: boolean;
28
+ tabStop?: boolean;
29
+ className?: string;
30
+ mark?: Mark;
31
+ markGroup?: string;
32
+ omitBorders?: readonly CellEdge[];
33
+ dataTestId: string;
34
+ ariaLabel: string;
35
+ onSelect: (extend: boolean) => void;
36
+ onStartEdit: () => void;
37
+ onCommit: (text: string, move: CellCommitMove) => void;
38
+ onCancel: () => void;
39
+ onDraftChange?: (text: string) => void;
40
+ }
41
+ export declare const renderRestingCellContent: (value: string, placeholder: string | undefined) => React.ReactNode;
42
+ export declare const GridCell: React.FC<GridCellProps>;
43
+ //# sourceMappingURL=GridCell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GridCell.d.ts","sourceRoot":"","sources":["../../src/decision-table/GridCell.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAQpC,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IAEd,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IACvD,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IAEd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,OAAO,CAAC;IAElB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IAEjB,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,KAAK,CAAC,SAAS,CAAC;IAGnE,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEzB,SAAS,CAAC,EAAE,OAAO,CAAC;IAKpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,WAAW,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;IAElC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAElB,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IACvD,QAAQ,EAAE,MAAM,IAAI,CAAC;IAErB,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAGD,eAAO,MAAM,wBAAwB,GACnC,OAAO,MAAM,EACb,aAAa,MAAM,GAAG,SAAS,KAC9B,KAAK,CAAC,SAKR,CAAC;AAMF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAsL5C,CAAC"}