@uipath/apollo-react 7.17.1 → 7.17.3
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.
- package/dist/canvas/components/Toolbox/ListView.cjs +7 -4
- package/dist/canvas/components/Toolbox/ListView.d.ts +2 -0
- package/dist/canvas/components/Toolbox/ListView.d.ts.map +1 -1
- package/dist/canvas/components/Toolbox/ListView.js +7 -4
- package/dist/canvas/components/Toolbox/Toolbox.cjs +1 -0
- package/dist/canvas/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/canvas/components/Toolbox/Toolbox.js +1 -0
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/chat/styles/tailwind.chat.css +1 -1
- package/dist/decision-table/DecisionTable.cjs +232 -35
- package/dist/decision-table/DecisionTable.d.ts +6 -0
- package/dist/decision-table/DecisionTable.d.ts.map +1 -1
- package/dist/decision-table/DecisionTable.js +235 -38
- package/dist/decision-table/DragIndicator.cjs +47 -0
- package/dist/decision-table/DragIndicator.d.ts +6 -0
- package/dist/decision-table/DragIndicator.d.ts.map +1 -0
- package/dist/decision-table/DragIndicator.js +13 -0
- package/dist/decision-table/EdgeInsertButton.cjs +87 -0
- package/dist/decision-table/EdgeInsertButton.d.ts +11 -0
- package/dist/decision-table/EdgeInsertButton.d.ts.map +1 -0
- package/dist/decision-table/EdgeInsertButton.js +53 -0
- package/dist/decision-table/GridCell.cjs +2 -1
- package/dist/decision-table/GridCell.d.ts.map +1 -1
- package/dist/decision-table/GridCell.js +3 -2
- package/dist/decision-table/gridStyles.cjs +67 -23
- package/dist/decision-table/gridStyles.d.ts +14 -4
- package/dist/decision-table/gridStyles.d.ts.map +1 -1
- package/dist/decision-table/gridStyles.js +27 -13
- package/dist/decision-table/gridTypes.d.ts +9 -2
- package/dist/decision-table/gridTypes.d.ts.map +1 -1
- package/dist/decision-table/index.cjs +76 -68
- package/dist/decision-table/index.d.ts +4 -1
- package/dist/decision-table/index.d.ts.map +1 -1
- package/dist/decision-table/index.js +5 -2
- package/dist/decision-table/locales/de.cjs +36 -0
- package/dist/decision-table/locales/de.d.ts +3 -0
- package/dist/decision-table/locales/de.d.ts.map +1 -0
- package/dist/decision-table/locales/de.js +2 -0
- package/dist/decision-table/locales/en.cjs +36 -0
- package/dist/decision-table/locales/en.d.ts +3 -0
- package/dist/decision-table/locales/en.d.ts.map +1 -0
- package/dist/decision-table/locales/en.js +2 -0
- package/dist/decision-table/locales/es-MX.cjs +36 -0
- package/dist/decision-table/locales/es-MX.d.ts +3 -0
- package/dist/decision-table/locales/es-MX.d.ts.map +1 -0
- package/dist/decision-table/locales/es-MX.js +2 -0
- package/dist/decision-table/locales/es.cjs +36 -0
- package/dist/decision-table/locales/es.d.ts +3 -0
- package/dist/decision-table/locales/es.d.ts.map +1 -0
- package/dist/decision-table/locales/es.js +2 -0
- package/dist/decision-table/locales/fr.cjs +36 -0
- package/dist/decision-table/locales/fr.d.ts +3 -0
- package/dist/decision-table/locales/fr.d.ts.map +1 -0
- package/dist/decision-table/locales/fr.js +2 -0
- package/dist/decision-table/locales/ja.cjs +36 -0
- package/dist/decision-table/locales/ja.d.ts +3 -0
- package/dist/decision-table/locales/ja.d.ts.map +1 -0
- package/dist/decision-table/locales/ja.js +2 -0
- package/dist/decision-table/locales/ko.cjs +36 -0
- package/dist/decision-table/locales/ko.d.ts +3 -0
- package/dist/decision-table/locales/ko.d.ts.map +1 -0
- package/dist/decision-table/locales/ko.js +2 -0
- package/dist/decision-table/locales/pt-BR.cjs +36 -0
- package/dist/decision-table/locales/pt-BR.d.ts +3 -0
- package/dist/decision-table/locales/pt-BR.d.ts.map +1 -0
- package/dist/decision-table/locales/pt-BR.js +2 -0
- package/dist/decision-table/locales/pt.cjs +36 -0
- package/dist/decision-table/locales/pt.d.ts +3 -0
- package/dist/decision-table/locales/pt.d.ts.map +1 -0
- package/dist/decision-table/locales/pt.js +2 -0
- package/dist/decision-table/locales/ro.cjs +36 -0
- package/dist/decision-table/locales/ro.d.ts +3 -0
- package/dist/decision-table/locales/ro.d.ts.map +1 -0
- package/dist/decision-table/locales/ro.js +2 -0
- package/dist/decision-table/locales/ru.cjs +36 -0
- package/dist/decision-table/locales/ru.d.ts +3 -0
- package/dist/decision-table/locales/ru.d.ts.map +1 -0
- package/dist/decision-table/locales/ru.js +2 -0
- package/dist/decision-table/locales/tr.cjs +36 -0
- package/dist/decision-table/locales/tr.d.ts +3 -0
- package/dist/decision-table/locales/tr.d.ts.map +1 -0
- package/dist/decision-table/locales/tr.js +2 -0
- package/dist/decision-table/locales/zh-CN.cjs +36 -0
- package/dist/decision-table/locales/zh-CN.d.ts +3 -0
- package/dist/decision-table/locales/zh-CN.d.ts.map +1 -0
- package/dist/decision-table/locales/zh-CN.js +2 -0
- package/dist/decision-table/locales/zh-TW.cjs +36 -0
- package/dist/decision-table/locales/zh-TW.d.ts +3 -0
- package/dist/decision-table/locales/zh-TW.d.ts.map +1 -0
- package/dist/decision-table/locales/zh-TW.js +2 -0
- package/dist/decision-table/styles/tailwind.decision-table.css +1 -1
- package/dist/decision-table/useDragReorder.cjs +363 -52
- package/dist/decision-table/useDragReorder.d.ts +35 -5
- package/dist/decision-table/useDragReorder.d.ts.map +1 -1
- package/dist/decision-table/useDragReorder.js +342 -46
- package/dist/decision-table/useGridStrings.cjs +57 -0
- package/dist/decision-table/useGridStrings.d.ts +7 -0
- package/dist/decision-table/useGridStrings.d.ts.map +1 -0
- package/dist/decision-table/useGridStrings.js +23 -0
- package/dist/decision-table/useRowHover.cjs +89 -0
- package/dist/decision-table/useRowHover.d.ts +3 -0
- package/dist/decision-table/useRowHover.d.ts.map +1 -0
- package/dist/decision-table/useRowHover.js +55 -0
- package/dist/i18n/locale-registry.cjs +30 -0
- package/dist/i18n/locale-registry.d.ts.map +1 -1
- package/dist/i18n/locale-registry.js +32 -2
- package/package.json +4 -4
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "@uipath/apollo-wind";
|
|
3
3
|
import { ArrowRight } from "lucide-react";
|
|
4
|
-
import react, { forwardRef, useCallback, useEffect, useImperativeHandle, useRef } from "react";
|
|
4
|
+
import react, { forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useRef } from "react";
|
|
5
5
|
import { BODY_ROW_HEIGHT_PX, MIN_COLUMN_WIDTH } from "./constants.js";
|
|
6
|
-
import { FROZEN_RIGHT_GROUP_CELL_CLASS, GRID_FRAME_CLASS, GRID_PANE_CLASS, GROUP_CELL_CLASS, GROUP_GUTTER_CLASS, HEADER_CELL_CLASS, RESIZE_HANDLE_CLASS, SEPARATOR_GROUP_CELL_CLASS, SEPARATOR_HEADER_CELL_CLASS, TABLE_EDGE_CLASS, TABLE_HUG_EDGE_CLASS, TOP_LEFT_CORNER_CELL_CLASS } from "./gridStyles.js";
|
|
7
|
-
import {
|
|
6
|
+
import { DRAG_PREVIEW_CLASS, DRAG_SOURCE_CLASS, DROP_INDICATOR_Z_CLASS, FROZEN_RIGHT_GROUP_CELL_CLASS, GRID_FRAME_CLASS, GRID_PANE_CLASS, GROUP_CELL_CLASS, GROUP_GUTTER_CLASS, HEADER_CELL_CLASS, PINNED_HEADER_Z_CLASS, RESIZE_HANDLE_BELOW_INSERT_CLASS, RESIZE_HANDLE_CLASS, ROW_HOVER_OVERLAY_CLASS, SEPARATOR_GROUP_CELL_CLASS, SEPARATOR_HEADER_CELL_CLASS, TABLE_EDGE_CLASS, TABLE_HUG_EDGE_CLASS, TOP_LEFT_CORNER_CELL_CLASS } from "./gridStyles.js";
|
|
7
|
+
import { MarkGlyph } from "./MarkGlyph.js";
|
|
8
|
+
import { bandGeometry, buildColumnPreview, buildRowPreview, dragShiftPx, dropIndex, gapStartPx, useDragReorder } from "./useDragReorder.js";
|
|
8
9
|
import { useGridClipboard } from "./useGridClipboard.js";
|
|
9
10
|
import { useGridLayout } from "./useGridLayout.js";
|
|
11
|
+
import { useRowHover } from "./useRowHover.js";
|
|
12
|
+
const DRAG_SHIFT_TRANSITION = 'transform 150ms ease';
|
|
13
|
+
const visiblePositionOf = (visibleColumns, flexIndex)=>visibleColumns.findIndex((visible)=>'column' === visible.type && visible.flexIndex === flexIndex);
|
|
10
14
|
const groupBoundsOf = (columns)=>{
|
|
11
15
|
const bounds = new Map();
|
|
12
16
|
columns.forEach((column, flexIndex)=>{
|
|
@@ -81,44 +85,117 @@ const markGroupEdges = (groupBounds, runs)=>{
|
|
|
81
85
|
run.endsGroup = run.firstFlexIndex + run.count - 1 === bounds?.last;
|
|
82
86
|
}
|
|
83
87
|
};
|
|
84
|
-
const DecisionTable = /*#__PURE__*/ forwardRef(({ columns, rowCount, rowHeightPx = BODY_ROW_HEIGHT_PX, leadingColumnWidth = 0, trailingColumnWidth = 0, pinnedColumnCount = 0, initialColumnWidths = {}, onColumnWidthsChange, columnsResizable = false, columnGroupSizes, onRowMove, onColumnMove, retainedRowIndex = null, retainedColumnIndex = null, renderHeaderCell, renderRow, renderFooterRow, topLeftCorner = '#', trailingHeaderCell, trailingGroupCell, tableAriaLabel, clipboard, containerProps, dataTestId, labels, children }, ref)=>{
|
|
88
|
+
const DecisionTable = /*#__PURE__*/ forwardRef(({ columns, rowCount, rowHeightPx = BODY_ROW_HEIGHT_PX, leadingColumnWidth = 0, trailingColumnWidth = 0, pinnedColumnCount = 0, initialColumnWidths = {}, onColumnWidthsChange, columnsResizable = false, headerEdgeInserts = false, columnGroupSizes, onRowMove, onColumnMove, retainedRowIndex = null, retainedColumnIndex = null, renderHeaderCell, renderRow, renderFooterRow, topLeftCorner = '#', tableMark, trailingHeaderCell, trailingGroupCell, tableAriaLabel, clipboard, containerProps, dataTestId, labels, children }, ref)=>{
|
|
85
89
|
const containerRef = useRef(null);
|
|
86
90
|
const layoutRef = useRef(null);
|
|
87
91
|
const headerHeight = useCallback(()=>layoutRef.current?.headerHeight() ?? 0, []);
|
|
88
92
|
const columnLeading = useCallback(()=>layoutRef.current?.columnLeading() ?? 0, []);
|
|
89
93
|
const columnOffsets = useCallback(()=>layoutRef.current?.columnOffsets ?? [], []);
|
|
94
|
+
const columnWidth = useCallback((dataIndex)=>{
|
|
95
|
+
const flexIndex = (layoutRef.current?.pinnedColumnCount ?? 0) + dataIndex;
|
|
96
|
+
return layoutRef.current?.widths[flexIndex] ?? columns[flexIndex]?.defaultWidth ?? 0;
|
|
97
|
+
}, [
|
|
98
|
+
columns
|
|
99
|
+
]);
|
|
90
100
|
const onRowMoveRef = useRef(onRowMove);
|
|
91
101
|
onRowMoveRef.current = onRowMove;
|
|
92
102
|
const onColumnMoveRef = useRef(onColumnMove);
|
|
93
103
|
onColumnMoveRef.current = onColumnMove;
|
|
94
104
|
const sizesKey = (columnGroupSizes ?? []).join(',');
|
|
105
|
+
const windowedColumnCount = Math.max(0, columns.length - pinnedColumnCount);
|
|
95
106
|
const boundaries = react.useMemo(()=>{
|
|
96
107
|
const out = [
|
|
97
108
|
0
|
|
98
109
|
];
|
|
99
|
-
for (const size of columnGroupSizes ?? [])out.push(out[out.length - 1] + size);
|
|
110
|
+
for (const size of columnGroupSizes ?? [])out.push(Math.min(out[out.length - 1] + size, windowedColumnCount));
|
|
100
111
|
return out;
|
|
101
112
|
}, [
|
|
102
|
-
sizesKey
|
|
113
|
+
sizesKey,
|
|
114
|
+
windowedColumnCount
|
|
103
115
|
]);
|
|
104
|
-
const
|
|
116
|
+
const boundariesRef = useRef(boundaries);
|
|
117
|
+
boundariesRef.current = boundaries;
|
|
118
|
+
const previewHostRef = useRef(null);
|
|
119
|
+
const dropIndicatorRef = useRef(null);
|
|
120
|
+
const dragSourcesRef = useRef([]);
|
|
121
|
+
const clipColumnDrag = useCallback((axis)=>{
|
|
122
|
+
const container = containerRef.current;
|
|
123
|
+
const head = container?.querySelector(':scope > table')?.tHead;
|
|
124
|
+
const labelRow = head?.rows[head.rows.length - 1];
|
|
125
|
+
const clipPath = 'column' === axis && container ? `inset(${container.scrollTop + (labelRow?.offsetTop ?? 0)}px -32px -32px)` : '';
|
|
126
|
+
for (const layer of [
|
|
127
|
+
previewHostRef.current,
|
|
128
|
+
dropIndicatorRef.current
|
|
129
|
+
])if (layer) layer.style.clipPath = clipPath;
|
|
130
|
+
}, []);
|
|
131
|
+
const dragLayoutRef = useRef(null);
|
|
132
|
+
const shiftedRef = useRef(new Map());
|
|
133
|
+
const settledRef = useRef(false);
|
|
134
|
+
const snapDragShifts = useCallback(()=>{
|
|
135
|
+
for (const element of shiftedRef.current.keys()){
|
|
136
|
+
element.style.transition = '';
|
|
137
|
+
element.style.transform = '';
|
|
138
|
+
}
|
|
139
|
+
shiftedRef.current.clear();
|
|
140
|
+
settledRef.current = true;
|
|
141
|
+
}, []);
|
|
142
|
+
const fillPreview = useCallback((state)=>{
|
|
143
|
+
const host = previewHostRef.current;
|
|
144
|
+
const shape = dragLayoutRef.current;
|
|
145
|
+
if (!host || !shape) return false;
|
|
146
|
+
const dataIndex = 'column' === state.axis ? (boundariesRef.current[state.groupIndex] ?? 0) + state.from : 0;
|
|
147
|
+
const position = 'column' === state.axis ? visiblePositionOf(shape.visibleColumns, shape.pinnedCount + dataIndex) : 0;
|
|
148
|
+
const preview = 'row' === state.axis ? buildRowPreview(containerRef.current, state.from + shape.headerRowCount + 1) : position < 0 ? null : buildColumnPreview(containerRef.current, {
|
|
149
|
+
headerCellIndex: position + shape.headerLeading,
|
|
150
|
+
bodyCellIndex: position + shape.bodyLeading,
|
|
151
|
+
widthPx: columnWidth(dataIndex)
|
|
152
|
+
});
|
|
153
|
+
if (!preview) return false;
|
|
154
|
+
host.replaceChildren(preview.table);
|
|
155
|
+
for (const source of preview.sources)source.setAttribute('data-drag-source', '');
|
|
156
|
+
dragSourcesRef.current = preview.sources;
|
|
157
|
+
return true;
|
|
158
|
+
}, [
|
|
159
|
+
columnWidth
|
|
160
|
+
]);
|
|
161
|
+
const onDragMove = useCallback((state, px)=>{
|
|
162
|
+
const host = previewHostRef.current;
|
|
163
|
+
const shape = dragLayoutRef.current;
|
|
164
|
+
if (!host || !shape) return;
|
|
165
|
+
if (null === px) {
|
|
166
|
+
host.replaceChildren();
|
|
167
|
+
host.style.transform = '';
|
|
168
|
+
clipColumnDrag(null);
|
|
169
|
+
for (const source of dragSourcesRef.current)source.removeAttribute('data-drag-source');
|
|
170
|
+
dragSourcesRef.current = [];
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (!host.firstChild && !fillPreview(state)) return;
|
|
174
|
+
host.style.transform = 'row' === state.axis ? `translateY(${px}px)` : `translateX(${px}px)`;
|
|
175
|
+
clipColumnDrag(state.axis);
|
|
176
|
+
}, [
|
|
177
|
+
fillPreview,
|
|
178
|
+
clipColumnDrag
|
|
179
|
+
]);
|
|
180
|
+
const { dragState, startRowDrag, startColumnDrag } = useDragReorder({
|
|
105
181
|
containerRef,
|
|
106
182
|
headerHeight,
|
|
107
183
|
columnLeading,
|
|
108
184
|
columnOffsets,
|
|
185
|
+
columnWidth,
|
|
109
186
|
rowHeightPx,
|
|
110
187
|
rowCount,
|
|
111
188
|
columnGroupBoundaries: boundaries,
|
|
112
|
-
onDropRow: (from, to)=>
|
|
113
|
-
|
|
189
|
+
onDropRow: (from, to)=>{
|
|
190
|
+
snapDragShifts();
|
|
191
|
+
onRowMoveRef.current?.(from, to);
|
|
192
|
+
},
|
|
193
|
+
onDropColumn: (groupIndex, from, to)=>{
|
|
194
|
+
snapDragShifts();
|
|
195
|
+
onColumnMoveRef.current?.(groupIndex, from, to);
|
|
196
|
+
},
|
|
197
|
+
onDragMove
|
|
114
198
|
});
|
|
115
|
-
const boundariesRef = useRef(boundaries);
|
|
116
|
-
boundariesRef.current = boundaries;
|
|
117
|
-
const startColumnDrag = useCallback((groupIndex, indexInGroup, event)=>{
|
|
118
|
-
if (boundariesRef.current.length >= 2) beginColumnDrag(groupIndex, indexInGroup, event);
|
|
119
|
-
}, [
|
|
120
|
-
beginColumnDrag
|
|
121
|
-
]);
|
|
122
199
|
const dragRetainedRow = dragState?.axis === 'row' ? dragState.from : null;
|
|
123
200
|
const dragRetainedColumn = dragState?.axis === 'column' ? (boundaries[dragState.groupIndex] ?? 0) + dragState.from : null;
|
|
124
201
|
const layout = useGridLayout({
|
|
@@ -148,8 +225,112 @@ const DecisionTable = /*#__PURE__*/ forwardRef(({ columns, rowCount, rowHeightPx
|
|
|
148
225
|
className: TOP_LEFT_CORNER_CELL_CLASS,
|
|
149
226
|
scope: "col",
|
|
150
227
|
"data-testid": `${dataTestId}-top-left-corner`,
|
|
151
|
-
children:
|
|
228
|
+
children: tableMark ? /*#__PURE__*/ jsxs("div", {
|
|
229
|
+
className: "flex flex-col items-center justify-center gap-1",
|
|
230
|
+
children: [
|
|
231
|
+
topLeftCorner,
|
|
232
|
+
/*#__PURE__*/ jsx("span", {
|
|
233
|
+
role: "img",
|
|
234
|
+
className: "inline-flex size-5 items-center justify-center",
|
|
235
|
+
"aria-label": tableMark.title,
|
|
236
|
+
"data-mark-title": tableMark.title,
|
|
237
|
+
"data-tone": tableMark.tone,
|
|
238
|
+
"data-testid": `${dataTestId}-table-mark`,
|
|
239
|
+
children: /*#__PURE__*/ jsx(MarkGlyph, {
|
|
240
|
+
tone: tableMark.tone,
|
|
241
|
+
className: "size-3"
|
|
242
|
+
})
|
|
243
|
+
})
|
|
244
|
+
]
|
|
245
|
+
}) : topLeftCorner
|
|
152
246
|
});
|
|
247
|
+
const bodyLeading = hasLeading ? 1 : 0;
|
|
248
|
+
const headerLeading = hasLeading && !hasGroupRow ? 1 : 0;
|
|
249
|
+
dragLayoutRef.current = {
|
|
250
|
+
headerRowCount,
|
|
251
|
+
visibleColumns,
|
|
252
|
+
pinnedCount: layout.pinnedColumnCount,
|
|
253
|
+
bodyLeading,
|
|
254
|
+
headerLeading
|
|
255
|
+
};
|
|
256
|
+
useLayoutEffect(()=>{
|
|
257
|
+
const shifted = shiftedRef.current;
|
|
258
|
+
if (!dragState || settledRef.current) {
|
|
259
|
+
settledRef.current = null !== dragState;
|
|
260
|
+
for (const [element, shift] of shifted)if (0 !== shift) {
|
|
261
|
+
element.style.transition = DRAG_SHIFT_TRANSITION;
|
|
262
|
+
element.style.transform = '';
|
|
263
|
+
}
|
|
264
|
+
shifted.clear();
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (previewHostRef.current?.firstChild) fillPreview(dragState);
|
|
268
|
+
clipColumnDrag(dragState.axis);
|
|
269
|
+
const table = containerRef.current?.querySelector(':scope > table');
|
|
270
|
+
if (!(table instanceof HTMLTableElement)) return;
|
|
271
|
+
const to = dropIndex(dragState.from, dragState.boundary);
|
|
272
|
+
const placed = new Set();
|
|
273
|
+
const place = (element, shift, axis)=>{
|
|
274
|
+
placed.add(element);
|
|
275
|
+
const previous = shifted.get(element);
|
|
276
|
+
if (previous === shift) return;
|
|
277
|
+
element.style.transition = void 0 === previous ? '' : DRAG_SHIFT_TRANSITION;
|
|
278
|
+
element.style.transform = 0 === shift ? '' : `translate${axis}(${shift}px)`;
|
|
279
|
+
shifted.set(element, shift);
|
|
280
|
+
};
|
|
281
|
+
const bodyRows = Array.from(table.tBodies[0]?.rows ?? []).filter((row)=>row.hasAttribute('aria-rowindex'));
|
|
282
|
+
if ('row' === dragState.axis) {
|
|
283
|
+
const rowSize = ()=>rowHeightPx;
|
|
284
|
+
for (const row of bodyRows){
|
|
285
|
+
const index = Number(row.getAttribute('aria-rowindex')) - headerRowCount - 1;
|
|
286
|
+
if (index >= 0 && index < rowCount) place(row, dragShiftPx(index, dragState.from, to, rowSize), 'Y');
|
|
287
|
+
}
|
|
288
|
+
} else {
|
|
289
|
+
const start = boundaries[dragState.groupIndex] ?? 0;
|
|
290
|
+
const end = boundaries[dragState.groupIndex + 1] ?? start;
|
|
291
|
+
const { sizeAt } = bandGeometry(layout.columnOffsets, columnWidth, start);
|
|
292
|
+
const headerRow = table.tHead?.rows[table.tHead.rows.length - 1];
|
|
293
|
+
const cellRows = bodyRows.filter((row)=>row.cells.length > 1);
|
|
294
|
+
for(let index = 0; index < end - start; index++){
|
|
295
|
+
const position = visiblePositionOf(visibleColumns, layout.pinnedColumnCount + start + index);
|
|
296
|
+
if (position < 0) continue;
|
|
297
|
+
const shift = dragShiftPx(index, dragState.from, to, sizeAt);
|
|
298
|
+
const header = headerRow?.cells[position + headerLeading];
|
|
299
|
+
if (header) place(header, shift, 'X');
|
|
300
|
+
for (const row of cellRows){
|
|
301
|
+
const cell = row.cells[position + bodyLeading];
|
|
302
|
+
if (cell) place(cell, shift, 'X');
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
for (const element of shifted.keys())if (!placed.has(element)) {
|
|
307
|
+
element.style.transition = '';
|
|
308
|
+
element.style.transform = '';
|
|
309
|
+
shifted.delete(element);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
const gapFrame = {
|
|
313
|
+
top: 0,
|
|
314
|
+
left: 0,
|
|
315
|
+
transition: DRAG_SHIFT_TRANSITION
|
|
316
|
+
};
|
|
317
|
+
const dropGapStyle = (state)=>{
|
|
318
|
+
const to = dropIndex(state.from, state.boundary);
|
|
319
|
+
if ('row' === state.axis) return {
|
|
320
|
+
...gapFrame,
|
|
321
|
+
transform: `translateY(${headerHeight() + to * rowHeightPx - 1}px)`,
|
|
322
|
+
width: totalWidth,
|
|
323
|
+
height: rowHeightPx + 2
|
|
324
|
+
};
|
|
325
|
+
const band = bandGeometry(layout.columnOffsets, columnWidth, boundaries[state.groupIndex] ?? 0);
|
|
326
|
+
const left = columnLeading() + band.left + gapStartPx(state.from, to, band.offsetOf, band.sizeAt);
|
|
327
|
+
return {
|
|
328
|
+
...gapFrame,
|
|
329
|
+
transform: `translateX(${left - 1}px)`,
|
|
330
|
+
width: band.sizeAt(state.from) + 2,
|
|
331
|
+
height: headerHeight() + rowCount * rowHeightPx
|
|
332
|
+
};
|
|
333
|
+
};
|
|
153
334
|
const gridClipboard = useGridClipboard(clipboard, {
|
|
154
335
|
rowCount,
|
|
155
336
|
columnCount: columns.length
|
|
@@ -162,8 +343,8 @@ const DecisionTable = /*#__PURE__*/ forwardRef(({ columns, rowCount, rowHeightPx
|
|
|
162
343
|
totalWidth: ()=>layoutRef.current?.totalWidth ?? 0,
|
|
163
344
|
scrollRowIntoView: (rowIndex)=>layoutRef.current?.scrollRowIntoView(rowIndex),
|
|
164
345
|
scrollColumnIntoView: (windowIndex)=>layoutRef.current?.scrollColumnIntoView(windowIndex),
|
|
165
|
-
startRowDrag,
|
|
166
|
-
startColumnDrag,
|
|
346
|
+
startRowDrag: (rowIndex, event)=>void 0 !== onRowMoveRef.current && startRowDrag(rowIndex, event),
|
|
347
|
+
startColumnDrag: (groupIndex, indexInGroup, event)=>void 0 !== onColumnMoveRef.current && startColumnDrag(groupIndex, indexInGroup, event),
|
|
167
348
|
clipboard: gridClipboard.actions
|
|
168
349
|
}), [
|
|
169
350
|
headerHeight,
|
|
@@ -190,6 +371,12 @@ const DecisionTable = /*#__PURE__*/ forwardRef(({ columns, rowCount, rowHeightPx
|
|
|
190
371
|
});
|
|
191
372
|
return ()=>container.removeEventListener('scroll', markScrolled);
|
|
192
373
|
}, []);
|
|
374
|
+
const rowHoverRef = useRef(null);
|
|
375
|
+
const rowTopPx = useCallback((index)=>headerHeight() + index * rowHeightPx, [
|
|
376
|
+
headerHeight,
|
|
377
|
+
rowHeightPx
|
|
378
|
+
]);
|
|
379
|
+
useRowHover(containerRef, rowHoverRef, rowTopPx, null === dragState);
|
|
193
380
|
const pinnedLeftPxOf = (flexIndex)=>{
|
|
194
381
|
if (flexIndex >= layout.pinnedColumnCount) return;
|
|
195
382
|
let offset = leadingColumnWidth;
|
|
@@ -200,7 +387,7 @@ const DecisionTable = /*#__PURE__*/ forwardRef(({ columns, rowCount, rowHeightPx
|
|
|
200
387
|
if (!columnsResizable) return null;
|
|
201
388
|
if (column.id === columns[columns.length - 1]?.id) return null;
|
|
202
389
|
return /*#__PURE__*/ jsx("span", {
|
|
203
|
-
className: RESIZE_HANDLE_CLASS,
|
|
390
|
+
className: cn(RESIZE_HANDLE_CLASS, headerEdgeInserts && RESIZE_HANDLE_BELOW_INSERT_CLASS),
|
|
204
391
|
role: "separator",
|
|
205
392
|
"aria-orientation": "vertical",
|
|
206
393
|
"aria-valuenow": Math.round(width),
|
|
@@ -220,14 +407,14 @@ const DecisionTable = /*#__PURE__*/ forwardRef(({ columns, rowCount, rowHeightPx
|
|
|
220
407
|
});
|
|
221
408
|
};
|
|
222
409
|
const pinnedEdgePx = leadingColumnWidth + widths.slice(0, layout.pinnedColumnCount).reduce((sum, width)=>sum + width, 0);
|
|
223
|
-
const bodyColSpan =
|
|
410
|
+
const bodyColSpan = bodyLeading + visibleColumns.length + (hasTrailing ? 1 : 0);
|
|
224
411
|
const { onFocus: consumerFocus, onBlur: consumerBlur, onKeyDown: consumerKeyDown, onCopy: consumerCopy, onCut: consumerCut, onPaste: consumerPaste, ...restContainerProps } = containerProps ?? {};
|
|
225
412
|
const composeClipboard = (mine, theirs)=>(event)=>{
|
|
226
413
|
mine?.(event);
|
|
227
414
|
if (!event.defaultPrevented) theirs?.(event);
|
|
228
415
|
};
|
|
229
416
|
const scrollContainer = /*#__PURE__*/ jsxs("div", {
|
|
230
|
-
className: GRID_FRAME_CLASS,
|
|
417
|
+
className: cn(GRID_FRAME_CLASS, dragState && 'cursor-grabbing [&_*]:cursor-grabbing!'),
|
|
231
418
|
ref: layout.attachContainer,
|
|
232
419
|
tabIndex: 0,
|
|
233
420
|
onFocus: (event)=>{
|
|
@@ -249,7 +436,7 @@ const DecisionTable = /*#__PURE__*/ forwardRef(({ columns, rowCount, rowHeightPx
|
|
|
249
436
|
...restContainerProps,
|
|
250
437
|
children: [
|
|
251
438
|
/*#__PURE__*/ jsxs("table", {
|
|
252
|
-
className: cn('table-fixed border-separate border-spacing-0 text-xs text-foreground', TABLE_EDGE_CLASS, TABLE_HUG_EDGE_CLASS),
|
|
439
|
+
className: cn('table-fixed border-separate border-spacing-0 text-xs text-foreground', TABLE_EDGE_CLASS, TABLE_HUG_EDGE_CLASS, DRAG_SOURCE_CLASS),
|
|
253
440
|
ref: layout.setTableElement,
|
|
254
441
|
style: {
|
|
255
442
|
width: totalWidth,
|
|
@@ -317,7 +504,7 @@ const DecisionTable = /*#__PURE__*/ forwardRef(({ columns, rowCount, rowHeightPx
|
|
|
317
504
|
}, `group-separator-${run.beforeColumnId}`);
|
|
318
505
|
if ('gutter' === run.type) return /*#__PURE__*/ jsx("td", {
|
|
319
506
|
"aria-hidden": "true",
|
|
320
|
-
className: cn(GROUP_GUTTER_CLASS, void 0 !== run.pinnedLeftPx &&
|
|
507
|
+
className: cn(GROUP_GUTTER_CLASS, void 0 !== run.pinnedLeftPx && PINNED_HEADER_Z_CLASS),
|
|
321
508
|
style: void 0 !== run.pinnedLeftPx ? {
|
|
322
509
|
left: run.pinnedLeftPx
|
|
323
510
|
} : void 0,
|
|
@@ -333,7 +520,7 @@ const DecisionTable = /*#__PURE__*/ forwardRef(({ columns, rowCount, rowHeightPx
|
|
|
333
520
|
const groupCellProps = run.group.cellProps?.(groupRun);
|
|
334
521
|
return /*#__PURE__*/ jsx("th", {
|
|
335
522
|
...groupCellProps,
|
|
336
|
-
className: cn(GROUP_CELL_CLASS, run.group.toneClassName, groupCellProps?.className, void 0 !== run.pinnedLeftPx &&
|
|
523
|
+
className: cn(GROUP_CELL_CLASS, run.group.toneClassName, groupCellProps?.className, void 0 !== run.pinnedLeftPx && PINNED_HEADER_Z_CLASS),
|
|
337
524
|
style: void 0 !== run.pinnedLeftPx ? {
|
|
338
525
|
...groupCellProps?.style,
|
|
339
526
|
left: run.pinnedLeftPx
|
|
@@ -378,10 +565,12 @@ const DecisionTable = /*#__PURE__*/ forwardRef(({ columns, rowCount, rowHeightPx
|
|
|
378
565
|
}
|
|
379
566
|
}, `header-spacer-${visible.coveredIds[0]}`);
|
|
380
567
|
const width = widths[visible.flexIndex] ?? visible.column.defaultWidth;
|
|
568
|
+
const pinnedLeftPx = pinnedLeftPxOf(visible.flexIndex);
|
|
381
569
|
return /*#__PURE__*/ jsx(react.Fragment, {
|
|
382
570
|
children: renderHeaderCell(visible.column, {
|
|
383
571
|
resizeHandle: renderResizeHandle(visible.column, width),
|
|
384
|
-
pinnedLeftPx
|
|
572
|
+
pinnedLeftPx,
|
|
573
|
+
pinnedClassName: void 0 === pinnedLeftPx ? void 0 : PINNED_HEADER_Z_CLASS
|
|
385
574
|
})
|
|
386
575
|
}, visible.column.id);
|
|
387
576
|
}),
|
|
@@ -418,20 +607,28 @@ const DecisionTable = /*#__PURE__*/ forwardRef(({ columns, rowCount, rowHeightPx
|
|
|
418
607
|
})
|
|
419
608
|
]
|
|
420
609
|
}),
|
|
610
|
+
/*#__PURE__*/ jsx("div", {
|
|
611
|
+
ref: rowHoverRef,
|
|
612
|
+
"aria-hidden": "true",
|
|
613
|
+
className: ROW_HOVER_OVERLAY_CLASS,
|
|
614
|
+
style: {
|
|
615
|
+
display: 'none',
|
|
616
|
+
width: totalWidth,
|
|
617
|
+
height: rowHeightPx
|
|
618
|
+
},
|
|
619
|
+
"data-testid": `${dataTestId}-row-hover`
|
|
620
|
+
}),
|
|
621
|
+
/*#__PURE__*/ jsx("div", {
|
|
622
|
+
ref: previewHostRef,
|
|
623
|
+
"aria-hidden": "true",
|
|
624
|
+
className: DRAG_PREVIEW_CLASS,
|
|
625
|
+
"data-testid": `${dataTestId}-drag-preview`
|
|
626
|
+
}),
|
|
421
627
|
dragState && /*#__PURE__*/ jsx("div", {
|
|
422
|
-
|
|
628
|
+
ref: dropIndicatorRef,
|
|
629
|
+
className: cn('pointer-events-none absolute border-primary', 'row' === dragState.axis ? 'border-y-2' : 'border-x-2', DROP_INDICATOR_Z_CLASS),
|
|
423
630
|
"data-testid": `${dataTestId}-drop-indicator`,
|
|
424
|
-
style:
|
|
425
|
-
top: headerHeight() + dragState.boundary * rowHeightPx - 1,
|
|
426
|
-
left: 0,
|
|
427
|
-
width: totalWidth,
|
|
428
|
-
height: 2
|
|
429
|
-
} : {
|
|
430
|
-
left: columnLeading() + (layout.columnOffsets[(boundaries[dragState.groupIndex] ?? 0) + dragState.boundary] ?? 0) - 1,
|
|
431
|
-
top: 0,
|
|
432
|
-
width: 2,
|
|
433
|
-
height: headerHeight() + rowCount * rowHeightPx
|
|
434
|
-
}
|
|
631
|
+
style: dropGapStyle(dragState)
|
|
435
632
|
}),
|
|
436
633
|
children
|
|
437
634
|
]
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
DragIndicator: ()=>DragIndicator
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const external_gridStyles_cjs_namespaceObject = require("./gridStyles.cjs");
|
|
31
|
+
const external_useGridStrings_cjs_namespaceObject = require("./useGridStrings.cjs");
|
|
32
|
+
const DragIndicator = ({ axis, testId })=>{
|
|
33
|
+
const strings = (0, external_useGridStrings_cjs_namespaceObject.useGridStrings)();
|
|
34
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
35
|
+
"aria-hidden": true,
|
|
36
|
+
className: 'row' === axis ? external_gridStyles_cjs_namespaceObject.ROW_DRAG_INDICATOR_CLASS : external_gridStyles_cjs_namespaceObject.COLUMN_DRAG_INDICATOR_CLASS,
|
|
37
|
+
title: 'row' === axis ? strings.dragRow : strings.dragColumn,
|
|
38
|
+
"data-testid": testId
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
exports.DragIndicator = __webpack_exports__.DragIndicator;
|
|
42
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
43
|
+
"DragIndicator"
|
|
44
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
45
|
+
Object.defineProperty(exports, '__esModule', {
|
|
46
|
+
value: true
|
|
47
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DragIndicator.d.ts","sourceRoot":"","sources":["../../src/decision-table/DragIndicator.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,kBAAkB;IAKjC,IAAI,EAAE,KAAK,GAAG,QAAQ,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAGD,eAAO,MAAM,aAAa,GAAI,kBAAkB,kBAAkB,4CAUjE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { COLUMN_DRAG_INDICATOR_CLASS, ROW_DRAG_INDICATOR_CLASS } from "./gridStyles.js";
|
|
3
|
+
import { useGridStrings } from "./useGridStrings.js";
|
|
4
|
+
const DragIndicator = ({ axis, testId })=>{
|
|
5
|
+
const strings = useGridStrings();
|
|
6
|
+
return /*#__PURE__*/ jsx("span", {
|
|
7
|
+
"aria-hidden": true,
|
|
8
|
+
className: 'row' === axis ? ROW_DRAG_INDICATOR_CLASS : COLUMN_DRAG_INDICATOR_CLASS,
|
|
9
|
+
title: 'row' === axis ? strings.dragRow : strings.dragColumn,
|
|
10
|
+
"data-testid": testId
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
export { DragIndicator };
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
EdgeInsertButton: ()=>EdgeInsertButton
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const apollo_wind_namespaceObject = require("@uipath/apollo-wind");
|
|
31
|
+
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
32
|
+
const external_gridStyles_cjs_namespaceObject = require("./gridStyles.cjs");
|
|
33
|
+
const external_useGridStrings_cjs_namespaceObject = require("./useGridStrings.cjs");
|
|
34
|
+
const AXIS_CLASSES = {
|
|
35
|
+
row: {
|
|
36
|
+
zone: external_gridStyles_cjs_namespaceObject.INSERT_ROW_ZONE_CLASS,
|
|
37
|
+
line: external_gridStyles_cjs_namespaceObject.INSERT_ROW_LINE_CLASS,
|
|
38
|
+
button: external_gridStyles_cjs_namespaceObject.INSERT_ROW_CLASS
|
|
39
|
+
},
|
|
40
|
+
column: {
|
|
41
|
+
zone: external_gridStyles_cjs_namespaceObject.INSERT_COLUMN_ZONE_CLASS,
|
|
42
|
+
line: external_gridStyles_cjs_namespaceObject.INSERT_COLUMN_LINE_CLASS,
|
|
43
|
+
button: external_gridStyles_cjs_namespaceObject.INSERT_COLUMN_CLASS
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const EdgeInsertButton = ({ axis, testId, zoneTestId, onInsert, zoneClassName, buttonClassName, onHoverChange })=>{
|
|
47
|
+
const strings = (0, external_useGridStrings_cjs_namespaceObject.useGridStrings)();
|
|
48
|
+
const label = 'row' === axis ? strings.insertRowAbove : strings.insertColumnLeft;
|
|
49
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
|
|
50
|
+
className: (0, apollo_wind_namespaceObject.cn)(AXIS_CLASSES[axis].zone, zoneClassName),
|
|
51
|
+
"data-testid": zoneTestId,
|
|
52
|
+
children: [
|
|
53
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
54
|
+
"aria-hidden": true,
|
|
55
|
+
className: AXIS_CLASSES[axis].line
|
|
56
|
+
}),
|
|
57
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.Button, {
|
|
58
|
+
variant: "ghost",
|
|
59
|
+
size: "4xs",
|
|
60
|
+
icon: true,
|
|
61
|
+
className: (0, apollo_wind_namespaceObject.cn)(AXIS_CLASSES[axis].button, buttonClassName),
|
|
62
|
+
"aria-label": label,
|
|
63
|
+
title: label,
|
|
64
|
+
tabIndex: -1,
|
|
65
|
+
"data-testid": testId,
|
|
66
|
+
onPointerEnter: onHoverChange && (()=>onHoverChange(true)),
|
|
67
|
+
onPointerLeave: onHoverChange && (()=>onHoverChange(false)),
|
|
68
|
+
onPointerDown: (event)=>event.stopPropagation(),
|
|
69
|
+
onKeyDown: (event)=>event.stopPropagation(),
|
|
70
|
+
onClick: (event)=>{
|
|
71
|
+
event.stopPropagation();
|
|
72
|
+
onInsert();
|
|
73
|
+
},
|
|
74
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Plus, {
|
|
75
|
+
"aria-hidden": true
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
]
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
exports.EdgeInsertButton = __webpack_exports__.EdgeInsertButton;
|
|
82
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
83
|
+
"EdgeInsertButton"
|
|
84
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
85
|
+
Object.defineProperty(exports, '__esModule', {
|
|
86
|
+
value: true
|
|
87
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface EdgeInsertButtonProps {
|
|
2
|
+
axis: 'row' | 'column';
|
|
3
|
+
testId: string;
|
|
4
|
+
zoneTestId?: string;
|
|
5
|
+
onInsert: () => void;
|
|
6
|
+
zoneClassName?: string;
|
|
7
|
+
buttonClassName?: string;
|
|
8
|
+
onHoverChange?: (hovered: boolean) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const EdgeInsertButton: ({ axis, testId, zoneTestId, onInsert, zoneClassName, buttonClassName, onHoverChange, }: EdgeInsertButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=EdgeInsertButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EdgeInsertButton.d.ts","sourceRoot":"","sources":["../../src/decision-table/EdgeInsertButton.tsx"],"names":[],"mappings":"AAqBA,MAAM,WAAW,qBAAqB;IAKpC,IAAI,EAAE,KAAK,GAAG,QAAQ,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,IAAI,CAAC;IAErB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC5C;AAMD,eAAO,MAAM,gBAAgB,GAAI,wFAQ9B,qBAAqB,4CAiCvB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, cn } from "@uipath/apollo-wind";
|
|
3
|
+
import { Plus } from "lucide-react";
|
|
4
|
+
import { INSERT_COLUMN_CLASS, INSERT_COLUMN_LINE_CLASS, INSERT_COLUMN_ZONE_CLASS, INSERT_ROW_CLASS, INSERT_ROW_LINE_CLASS, INSERT_ROW_ZONE_CLASS } from "./gridStyles.js";
|
|
5
|
+
import { useGridStrings } from "./useGridStrings.js";
|
|
6
|
+
const AXIS_CLASSES = {
|
|
7
|
+
row: {
|
|
8
|
+
zone: INSERT_ROW_ZONE_CLASS,
|
|
9
|
+
line: INSERT_ROW_LINE_CLASS,
|
|
10
|
+
button: INSERT_ROW_CLASS
|
|
11
|
+
},
|
|
12
|
+
column: {
|
|
13
|
+
zone: INSERT_COLUMN_ZONE_CLASS,
|
|
14
|
+
line: INSERT_COLUMN_LINE_CLASS,
|
|
15
|
+
button: INSERT_COLUMN_CLASS
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const EdgeInsertButton = ({ axis, testId, zoneTestId, onInsert, zoneClassName, buttonClassName, onHoverChange })=>{
|
|
19
|
+
const strings = useGridStrings();
|
|
20
|
+
const label = 'row' === axis ? strings.insertRowAbove : strings.insertColumnLeft;
|
|
21
|
+
return /*#__PURE__*/ jsxs("span", {
|
|
22
|
+
className: cn(AXIS_CLASSES[axis].zone, zoneClassName),
|
|
23
|
+
"data-testid": zoneTestId,
|
|
24
|
+
children: [
|
|
25
|
+
/*#__PURE__*/ jsx("span", {
|
|
26
|
+
"aria-hidden": true,
|
|
27
|
+
className: AXIS_CLASSES[axis].line
|
|
28
|
+
}),
|
|
29
|
+
/*#__PURE__*/ jsx(Button, {
|
|
30
|
+
variant: "ghost",
|
|
31
|
+
size: "4xs",
|
|
32
|
+
icon: true,
|
|
33
|
+
className: cn(AXIS_CLASSES[axis].button, buttonClassName),
|
|
34
|
+
"aria-label": label,
|
|
35
|
+
title: label,
|
|
36
|
+
tabIndex: -1,
|
|
37
|
+
"data-testid": testId,
|
|
38
|
+
onPointerEnter: onHoverChange && (()=>onHoverChange(true)),
|
|
39
|
+
onPointerLeave: onHoverChange && (()=>onHoverChange(false)),
|
|
40
|
+
onPointerDown: (event)=>event.stopPropagation(),
|
|
41
|
+
onKeyDown: (event)=>event.stopPropagation(),
|
|
42
|
+
onClick: (event)=>{
|
|
43
|
+
event.stopPropagation();
|
|
44
|
+
onInsert();
|
|
45
|
+
},
|
|
46
|
+
children: /*#__PURE__*/ jsx(Plus, {
|
|
47
|
+
"aria-hidden": true
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
export { EdgeInsertButton };
|
|
@@ -68,7 +68,7 @@ const GridCell = ({ value, restingValue, placeholder, mono, readOnly, pinnedLeft
|
|
|
68
68
|
};
|
|
69
69
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("td", {
|
|
70
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 && external_gridStyles_cjs_namespaceObject.MONO_CELL_TEXT_CLASS, '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',
|
|
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 && external_gridStyles_cjs_namespaceObject.MONO_CELL_TEXT_CLASS, '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
72
|
style: void 0 !== pinnedLeft ? {
|
|
73
73
|
left: pinnedLeft
|
|
74
74
|
} : void 0,
|
|
@@ -82,6 +82,7 @@ const GridCell = ({ value, restingValue, placeholder, mono, readOnly, pinnedLeft
|
|
|
82
82
|
"data-mark-matched": isEditing ? void 0 : mark?.matched,
|
|
83
83
|
"data-selected": selected ? 'true' : 'false',
|
|
84
84
|
"data-in-range": inRange ? 'true' : 'false',
|
|
85
|
+
"data-editing": isEditing ? 'true' : void 0,
|
|
85
86
|
"aria-label": ariaLabel,
|
|
86
87
|
onClick: (event)=>{
|
|
87
88
|
if (!isEditing) onSelect(event.shiftKey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridCell.d.ts","sourceRoot":"","sources":["../../src/decision-table/GridCell.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"GridCell.d.ts","sourceRoot":"","sources":["../../src/decision-table/GridCell.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAa/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,CAwL5C,CAAC"}
|