@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.
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/chat/styles/tailwind.chat.css +1 -1
- package/dist/decision-table/DecisionTable.cjs +454 -0
- package/dist/decision-table/DecisionTable.d.ts +36 -0
- package/dist/decision-table/DecisionTable.d.ts.map +1 -0
- package/dist/decision-table/DecisionTable.js +410 -0
- package/dist/decision-table/GridCell.cjs +153 -0
- package/dist/decision-table/GridCell.d.ts +43 -0
- package/dist/decision-table/GridCell.d.ts.map +1 -0
- package/dist/decision-table/GridCell.js +116 -0
- package/dist/decision-table/GridMenu.cjs +135 -0
- package/dist/decision-table/GridMenu.d.ts +30 -0
- package/dist/decision-table/GridMenu.d.ts.map +1 -0
- package/dist/decision-table/GridMenu.js +101 -0
- package/dist/decision-table/MarkGlyph.cjs +51 -0
- package/dist/decision-table/MarkGlyph.d.ts +7 -0
- package/dist/decision-table/MarkGlyph.d.ts.map +1 -0
- package/dist/decision-table/MarkGlyph.js +17 -0
- package/dist/decision-table/clipboardCodec.cjs +123 -0
- package/dist/decision-table/clipboardCodec.d.ts +8 -0
- package/dist/decision-table/clipboardCodec.d.ts.map +1 -0
- package/dist/decision-table/clipboardCodec.js +80 -0
- package/dist/decision-table/clippedTitle.cjs +39 -0
- package/dist/decision-table/clippedTitle.d.ts +3 -0
- package/dist/decision-table/clippedTitle.d.ts.map +1 -0
- package/dist/decision-table/clippedTitle.js +5 -0
- package/dist/decision-table/columnSizing.cjs +92 -0
- package/dist/decision-table/columnSizing.d.ts +13 -0
- package/dist/decision-table/columnSizing.d.ts.map +1 -0
- package/dist/decision-table/columnSizing.js +52 -0
- package/dist/decision-table/constants.cjs +84 -0
- package/dist/decision-table/constants.d.ts +14 -0
- package/dist/decision-table/constants.d.ts.map +1 -0
- package/dist/decision-table/constants.js +14 -0
- package/dist/decision-table/gridClipboard.cjs +129 -0
- package/dist/decision-table/gridClipboard.d.ts +19 -0
- package/dist/decision-table/gridClipboard.d.ts.map +1 -0
- package/dist/decision-table/gridClipboard.js +89 -0
- package/dist/decision-table/gridEvents.cjs +72 -0
- package/dist/decision-table/gridEvents.d.ts +14 -0
- package/dist/decision-table/gridEvents.d.ts.map +1 -0
- package/dist/decision-table/gridEvents.js +23 -0
- package/dist/decision-table/gridStyles.cjs +196 -0
- package/dist/decision-table/gridStyles.d.ts +47 -0
- package/dist/decision-table/gridStyles.d.ts.map +1 -0
- package/dist/decision-table/gridStyles.js +54 -0
- package/dist/decision-table/gridTypes.cjs +18 -0
- package/dist/decision-table/gridTypes.d.ts +93 -0
- package/dist/decision-table/gridTypes.d.ts.map +1 -0
- package/dist/decision-table/gridTypes.js +0 -0
- package/dist/decision-table/index.cjs +271 -0
- package/dist/decision-table/index.d.ts +13 -0
- package/dist/decision-table/index.d.ts.map +1 -0
- package/dist/decision-table/index.js +12 -0
- package/dist/decision-table/marks.cjs +39 -0
- package/dist/decision-table/marks.d.ts +20 -0
- package/dist/decision-table/marks.d.ts.map +1 -0
- package/dist/decision-table/marks.js +5 -0
- package/dist/decision-table/styles/tailwind.decision-table.css +2 -0
- package/dist/decision-table/useColumnWidths.cjs +313 -0
- package/dist/decision-table/useColumnWidths.d.ts +21 -0
- package/dist/decision-table/useColumnWidths.d.ts.map +1 -0
- package/dist/decision-table/useColumnWidths.js +279 -0
- package/dist/decision-table/useDragReorder.cjs +229 -0
- package/dist/decision-table/useDragReorder.d.ts +31 -0
- package/dist/decision-table/useDragReorder.d.ts.map +1 -0
- package/dist/decision-table/useDragReorder.js +186 -0
- package/dist/decision-table/useDragSelection.cjs +75 -0
- package/dist/decision-table/useDragSelection.d.ts +18 -0
- package/dist/decision-table/useDragSelection.d.ts.map +1 -0
- package/dist/decision-table/useDragSelection.js +41 -0
- package/dist/decision-table/useGridClipboard.cjs +195 -0
- package/dist/decision-table/useGridClipboard.d.ts +13 -0
- package/dist/decision-table/useGridClipboard.d.ts.map +1 -0
- package/dist/decision-table/useGridClipboard.js +161 -0
- package/dist/decision-table/useGridLayout.cjs +248 -0
- package/dist/decision-table/useGridLayout.d.ts +50 -0
- package/dist/decision-table/useGridLayout.d.ts.map +1 -0
- package/dist/decision-table/useGridLayout.js +211 -0
- package/dist/decision-table/useGridNavigation.cjs +441 -0
- package/dist/decision-table/useGridNavigation.d.ts +67 -0
- package/dist/decision-table/useGridNavigation.d.ts.map +1 -0
- package/dist/decision-table/useGridNavigation.js +404 -0
- package/dist/decision-table/useVirtualizedAxis.cjs +256 -0
- package/dist/decision-table/useVirtualizedAxis.d.ts +34 -0
- package/dist/decision-table/useVirtualizedAxis.d.ts.map +1 -0
- package/dist/decision-table/useVirtualizedAxis.js +219 -0
- package/dist/test/setup.d.ts.map +1 -1
- package/package.json +20 -10
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "@uipath/apollo-wind";
|
|
3
|
+
import { useLayoutEffect, useRef } from "react";
|
|
4
|
+
import { showTitleIfClipped } from "./clippedTitle.js";
|
|
5
|
+
import { commitMoveFor } from "./gridEvents.js";
|
|
6
|
+
import { BODY_CELL_CLASS, CELL_EDITOR_CLASS, CELL_MARK_CLASS, CELL_SURFACE_CLASS, IN_RANGE_CLASS, OMIT_BORDER_CLASS } from "./gridStyles.js";
|
|
7
|
+
import { MarkGlyph } from "./MarkGlyph.js";
|
|
8
|
+
const renderRestingCellContent = (value, placeholder)=>{
|
|
9
|
+
if (value) return value;
|
|
10
|
+
return placeholder ? /*#__PURE__*/ jsx("span", {
|
|
11
|
+
className: "text-foreground-de-emp italic",
|
|
12
|
+
children: placeholder
|
|
13
|
+
}) : null;
|
|
14
|
+
};
|
|
15
|
+
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 })=>{
|
|
16
|
+
const settledByKeyRef = useRef(false);
|
|
17
|
+
const keyCommittedValueRef = useRef(null);
|
|
18
|
+
const isEditing = editing && !readOnly;
|
|
19
|
+
const restingTabIndex = isEditing || !tabStop ? -1 : 0;
|
|
20
|
+
const cellRef = useRef(null);
|
|
21
|
+
const wasEditingRef = useRef(isEditing);
|
|
22
|
+
useLayoutEffect(()=>{
|
|
23
|
+
if (focusable && wasEditingRef.current && !isEditing && settledByKeyRef.current) cellRef.current?.focus();
|
|
24
|
+
wasEditingRef.current = isEditing;
|
|
25
|
+
});
|
|
26
|
+
const handleEditorKeyDown = (event)=>{
|
|
27
|
+
if (event.nativeEvent.isComposing || 229 === event.nativeEvent.keyCode) return;
|
|
28
|
+
if ('Enter' === event.key || 'Tab' === event.key) {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
settledByKeyRef.current = true;
|
|
31
|
+
keyCommittedValueRef.current = event.currentTarget.value;
|
|
32
|
+
onCommit(event.currentTarget.value, commitMoveFor(event));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if ('Escape' === event.key) {
|
|
36
|
+
settledByKeyRef.current = true;
|
|
37
|
+
onCancel();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return /*#__PURE__*/ jsxs("td", {
|
|
41
|
+
ref: cellRef,
|
|
42
|
+
className: cn(BODY_CELL_CLASS, omitBorders?.map((edge)=>OMIT_BORDER_CLASS[edge]), mono && 'font-mono', 'font-normal', selected && 'shadow-[inset_0_0_0_2px_var(--color-primary)]', isEditing && 'select-text', inRange && IN_RANGE_CLASS, void 0 !== pinnedLeft && 'sticky z-1 bg-background', className, CELL_MARK_CLASS),
|
|
43
|
+
style: void 0 !== pinnedLeft ? {
|
|
44
|
+
left: pinnedLeft
|
|
45
|
+
} : void 0,
|
|
46
|
+
"data-menu-target": "cell",
|
|
47
|
+
"data-row": row,
|
|
48
|
+
"data-col": col,
|
|
49
|
+
"data-testid": dataTestId,
|
|
50
|
+
"data-tone": mark?.tone,
|
|
51
|
+
"data-mark-title": isEditing ? void 0 : mark?.title,
|
|
52
|
+
"data-mark-group": markGroup,
|
|
53
|
+
"data-mark-matched": isEditing ? void 0 : mark?.matched,
|
|
54
|
+
"data-selected": selected ? 'true' : 'false',
|
|
55
|
+
"data-in-range": inRange ? 'true' : 'false',
|
|
56
|
+
"aria-label": ariaLabel,
|
|
57
|
+
onClick: (event)=>{
|
|
58
|
+
if (!isEditing) onSelect(event.shiftKey);
|
|
59
|
+
},
|
|
60
|
+
onDoubleClick: ()=>{
|
|
61
|
+
if (!readOnly) onStartEdit();
|
|
62
|
+
},
|
|
63
|
+
tabIndex: focusable ? restingTabIndex : void 0,
|
|
64
|
+
onKeyDown: focusable ? (event)=>{
|
|
65
|
+
if (editing || !selected || 'Enter' !== event.key && 'F2' !== event.key) return;
|
|
66
|
+
event.preventDefault();
|
|
67
|
+
onSelect(false);
|
|
68
|
+
if (!readOnly) onStartEdit();
|
|
69
|
+
} : void 0,
|
|
70
|
+
children: [
|
|
71
|
+
!isEditing && /*#__PURE__*/ jsxs("div", {
|
|
72
|
+
className: cn(CELL_SURFACE_CLASS, 'flex items-center'),
|
|
73
|
+
children: [
|
|
74
|
+
/*#__PURE__*/ jsxs("span", {
|
|
75
|
+
className: "min-w-0 truncate",
|
|
76
|
+
onMouseEnter: showTitleIfClipped,
|
|
77
|
+
children: [
|
|
78
|
+
renderRestingCellContent(restingValue ?? value, placeholder),
|
|
79
|
+
suffix
|
|
80
|
+
]
|
|
81
|
+
}),
|
|
82
|
+
mark?.glyph && /*#__PURE__*/ jsx(MarkGlyph, {
|
|
83
|
+
tone: mark.tone,
|
|
84
|
+
className: "ml-1"
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
}),
|
|
88
|
+
isEditing && renderEditor?.({
|
|
89
|
+
value,
|
|
90
|
+
openedByTyping,
|
|
91
|
+
ariaLabel,
|
|
92
|
+
onCommit,
|
|
93
|
+
onCancel,
|
|
94
|
+
onDraftChange
|
|
95
|
+
}),
|
|
96
|
+
isEditing && !renderEditor && /*#__PURE__*/ jsx("input", {
|
|
97
|
+
className: CELL_EDITOR_CLASS,
|
|
98
|
+
"aria-label": ariaLabel,
|
|
99
|
+
"data-testid": `${dataTestId}-editor`,
|
|
100
|
+
autoFocus: true,
|
|
101
|
+
defaultValue: value,
|
|
102
|
+
onFocus: (event)=>{
|
|
103
|
+
settledByKeyRef.current = false;
|
|
104
|
+
keyCommittedValueRef.current = null;
|
|
105
|
+
event.currentTarget.select();
|
|
106
|
+
},
|
|
107
|
+
onChange: (event)=>onDraftChange?.(event.currentTarget.value),
|
|
108
|
+
onKeyDown: handleEditorKeyDown,
|
|
109
|
+
onBlur: (event)=>{
|
|
110
|
+
if (!settledByKeyRef.current || event.currentTarget.value !== keyCommittedValueRef.current) onCommit(event.currentTarget.value, 'none');
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
]
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
export { GridCell, renderRestingCellContent };
|
|
@@ -0,0 +1,135 @@
|
|
|
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
|
+
GridContextMenu: ()=>GridContextMenu
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const apollo_wind_namespaceObject = require("@uipath/apollo-wind");
|
|
31
|
+
const external_react_namespaceObject = require("react");
|
|
32
|
+
const isDivider = (entry)=>true === entry.divider;
|
|
33
|
+
const DESTRUCTIVE_ITEM_CLASS = 'text-destructive focus:bg-destructive/10 focus:text-destructive';
|
|
34
|
+
const useGridMenuItems = (entries, open, dataTestId)=>{
|
|
35
|
+
const deferredRef = (0, external_react_namespaceObject.useRef)(null);
|
|
36
|
+
const keepFocusRef = (0, external_react_namespaceObject.useRef)(false);
|
|
37
|
+
const items = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(jsx_runtime_namespaceObject.Fragment, {
|
|
38
|
+
children: entries.map((entry, index)=>isDivider(entry) ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.DropdownMenuSeparator, {}, `divider-${index}`) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(apollo_wind_namespaceObject.DropdownMenuItem, {
|
|
39
|
+
disabled: entry.disabled,
|
|
40
|
+
className: (0, apollo_wind_namespaceObject.cn)('flex-col items-start gap-0.5', entry.destructive && DESTRUCTIVE_ITEM_CLASS),
|
|
41
|
+
"aria-label": entry.disabled && entry.disabledReason ? `${entry.label}. ${entry.disabledReason}` : void 0,
|
|
42
|
+
onSelect: ()=>{
|
|
43
|
+
if (entry.focusesOwnSurface) {
|
|
44
|
+
deferredRef.current = entry.onClick;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
entry.onClick();
|
|
48
|
+
},
|
|
49
|
+
children: [
|
|
50
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
|
|
51
|
+
className: "flex w-full items-center justify-between gap-4",
|
|
52
|
+
children: [
|
|
53
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
|
|
54
|
+
className: "flex items-center gap-2",
|
|
55
|
+
children: [
|
|
56
|
+
entry.icon,
|
|
57
|
+
entry.label
|
|
58
|
+
]
|
|
59
|
+
}),
|
|
60
|
+
entry.shortcut && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.DropdownMenuShortcut, {
|
|
61
|
+
children: entry.shortcut
|
|
62
|
+
})
|
|
63
|
+
]
|
|
64
|
+
}),
|
|
65
|
+
entry.disabled && entry.disabledReason && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
66
|
+
className: "text-[11px] leading-4 text-foreground-de-emp",
|
|
67
|
+
"data-testid": `${dataTestId}-menu-disabled-reason`,
|
|
68
|
+
children: entry.disabledReason
|
|
69
|
+
})
|
|
70
|
+
]
|
|
71
|
+
}, `item-${index}`))
|
|
72
|
+
});
|
|
73
|
+
const onCloseAutoFocus = (event)=>{
|
|
74
|
+
if (!keepFocusRef.current) return;
|
|
75
|
+
keepFocusRef.current = false;
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
};
|
|
78
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
79
|
+
if (open) return;
|
|
80
|
+
const deferred = deferredRef.current;
|
|
81
|
+
if (!deferred) return;
|
|
82
|
+
deferredRef.current = null;
|
|
83
|
+
keepFocusRef.current = true;
|
|
84
|
+
deferred();
|
|
85
|
+
}, [
|
|
86
|
+
open
|
|
87
|
+
]);
|
|
88
|
+
return {
|
|
89
|
+
items,
|
|
90
|
+
onCloseAutoFocus
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
const GridContextMenu = ({ label, dataTestId, state, entries, onClose })=>{
|
|
94
|
+
const { items, onCloseAutoFocus } = useGridMenuItems(state ? entries() : [], !!state, dataTestId);
|
|
95
|
+
if (!state) return null;
|
|
96
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(apollo_wind_namespaceObject.DropdownMenu, {
|
|
97
|
+
open: true,
|
|
98
|
+
modal: false,
|
|
99
|
+
onOpenChange: (nextOpen)=>{
|
|
100
|
+
if (!nextOpen) onClose();
|
|
101
|
+
},
|
|
102
|
+
children: [
|
|
103
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.DropdownMenuTrigger, {
|
|
104
|
+
asChild: true,
|
|
105
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
106
|
+
"aria-hidden": true,
|
|
107
|
+
className: "pointer-events-none fixed size-0",
|
|
108
|
+
"data-testid": `${dataTestId}-context-menu-anchor`,
|
|
109
|
+
style: {
|
|
110
|
+
left: state.anchor.x,
|
|
111
|
+
top: state.anchor.y
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
}),
|
|
115
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.DropdownMenuContent, {
|
|
116
|
+
align: "start",
|
|
117
|
+
side: "bottom",
|
|
118
|
+
"aria-label": label,
|
|
119
|
+
className: "min-w-52",
|
|
120
|
+
"data-testid": `${dataTestId}-context-menu`,
|
|
121
|
+
onCloseAutoFocus: onCloseAutoFocus,
|
|
122
|
+
onClick: (event)=>event.stopPropagation(),
|
|
123
|
+
onKeyDown: (event)=>event.stopPropagation(),
|
|
124
|
+
children: items
|
|
125
|
+
})
|
|
126
|
+
]
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
exports.GridContextMenu = __webpack_exports__.GridContextMenu;
|
|
130
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
131
|
+
"GridContextMenu"
|
|
132
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
133
|
+
Object.defineProperty(exports, '__esModule', {
|
|
134
|
+
value: true
|
|
135
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export interface GridMenuItem {
|
|
3
|
+
label: string;
|
|
4
|
+
onClick: () => void;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
icon?: React.ReactNode;
|
|
7
|
+
divider?: never;
|
|
8
|
+
destructive?: boolean;
|
|
9
|
+
disabledReason?: string;
|
|
10
|
+
shortcut?: string;
|
|
11
|
+
focusesOwnSurface?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export type GridMenuEntry = GridMenuItem | {
|
|
14
|
+
divider: true;
|
|
15
|
+
};
|
|
16
|
+
export interface GridContextMenuState {
|
|
17
|
+
anchor: {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface GridContextMenuProps {
|
|
23
|
+
label: string;
|
|
24
|
+
dataTestId: string;
|
|
25
|
+
state: GridContextMenuState | null;
|
|
26
|
+
entries: () => GridMenuEntry[];
|
|
27
|
+
onClose: () => void;
|
|
28
|
+
}
|
|
29
|
+
export declare const GridContextMenu: React.FC<GridContextMenuProps>;
|
|
30
|
+
//# sourceMappingURL=GridMenu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GridMenu.d.ts","sourceRoot":"","sources":["../../src/decision-table/GridMenu.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAMvB,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAKlB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,CAAC;AAsF7D,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAClC;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IAEd,UAAU,EAAE,MAAM,CAAC;IAEnB,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACnC,OAAO,EAAE,MAAM,aAAa,EAAE,CAAC;IAC/B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAUD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA2C1D,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger, cn } from "@uipath/apollo-wind";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
const isDivider = (entry)=>true === entry.divider;
|
|
5
|
+
const DESTRUCTIVE_ITEM_CLASS = 'text-destructive focus:bg-destructive/10 focus:text-destructive';
|
|
6
|
+
const useGridMenuItems = (entries, open, dataTestId)=>{
|
|
7
|
+
const deferredRef = useRef(null);
|
|
8
|
+
const keepFocusRef = useRef(false);
|
|
9
|
+
const items = /*#__PURE__*/ jsx(Fragment, {
|
|
10
|
+
children: entries.map((entry, index)=>isDivider(entry) ? /*#__PURE__*/ jsx(DropdownMenuSeparator, {}, `divider-${index}`) : /*#__PURE__*/ jsxs(DropdownMenuItem, {
|
|
11
|
+
disabled: entry.disabled,
|
|
12
|
+
className: cn('flex-col items-start gap-0.5', entry.destructive && DESTRUCTIVE_ITEM_CLASS),
|
|
13
|
+
"aria-label": entry.disabled && entry.disabledReason ? `${entry.label}. ${entry.disabledReason}` : void 0,
|
|
14
|
+
onSelect: ()=>{
|
|
15
|
+
if (entry.focusesOwnSurface) {
|
|
16
|
+
deferredRef.current = entry.onClick;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
entry.onClick();
|
|
20
|
+
},
|
|
21
|
+
children: [
|
|
22
|
+
/*#__PURE__*/ jsxs("span", {
|
|
23
|
+
className: "flex w-full items-center justify-between gap-4",
|
|
24
|
+
children: [
|
|
25
|
+
/*#__PURE__*/ jsxs("span", {
|
|
26
|
+
className: "flex items-center gap-2",
|
|
27
|
+
children: [
|
|
28
|
+
entry.icon,
|
|
29
|
+
entry.label
|
|
30
|
+
]
|
|
31
|
+
}),
|
|
32
|
+
entry.shortcut && /*#__PURE__*/ jsx(DropdownMenuShortcut, {
|
|
33
|
+
children: entry.shortcut
|
|
34
|
+
})
|
|
35
|
+
]
|
|
36
|
+
}),
|
|
37
|
+
entry.disabled && entry.disabledReason && /*#__PURE__*/ jsx("span", {
|
|
38
|
+
className: "text-[11px] leading-4 text-foreground-de-emp",
|
|
39
|
+
"data-testid": `${dataTestId}-menu-disabled-reason`,
|
|
40
|
+
children: entry.disabledReason
|
|
41
|
+
})
|
|
42
|
+
]
|
|
43
|
+
}, `item-${index}`))
|
|
44
|
+
});
|
|
45
|
+
const onCloseAutoFocus = (event)=>{
|
|
46
|
+
if (!keepFocusRef.current) return;
|
|
47
|
+
keepFocusRef.current = false;
|
|
48
|
+
event.preventDefault();
|
|
49
|
+
};
|
|
50
|
+
useEffect(()=>{
|
|
51
|
+
if (open) return;
|
|
52
|
+
const deferred = deferredRef.current;
|
|
53
|
+
if (!deferred) return;
|
|
54
|
+
deferredRef.current = null;
|
|
55
|
+
keepFocusRef.current = true;
|
|
56
|
+
deferred();
|
|
57
|
+
}, [
|
|
58
|
+
open
|
|
59
|
+
]);
|
|
60
|
+
return {
|
|
61
|
+
items,
|
|
62
|
+
onCloseAutoFocus
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
const GridContextMenu = ({ label, dataTestId, state, entries, onClose })=>{
|
|
66
|
+
const { items, onCloseAutoFocus } = useGridMenuItems(state ? entries() : [], !!state, dataTestId);
|
|
67
|
+
if (!state) return null;
|
|
68
|
+
return /*#__PURE__*/ jsxs(DropdownMenu, {
|
|
69
|
+
open: true,
|
|
70
|
+
modal: false,
|
|
71
|
+
onOpenChange: (nextOpen)=>{
|
|
72
|
+
if (!nextOpen) onClose();
|
|
73
|
+
},
|
|
74
|
+
children: [
|
|
75
|
+
/*#__PURE__*/ jsx(DropdownMenuTrigger, {
|
|
76
|
+
asChild: true,
|
|
77
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
78
|
+
"aria-hidden": true,
|
|
79
|
+
className: "pointer-events-none fixed size-0",
|
|
80
|
+
"data-testid": `${dataTestId}-context-menu-anchor`,
|
|
81
|
+
style: {
|
|
82
|
+
left: state.anchor.x,
|
|
83
|
+
top: state.anchor.y
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
}),
|
|
87
|
+
/*#__PURE__*/ jsx(DropdownMenuContent, {
|
|
88
|
+
align: "start",
|
|
89
|
+
side: "bottom",
|
|
90
|
+
"aria-label": label,
|
|
91
|
+
className: "min-w-52",
|
|
92
|
+
"data-testid": `${dataTestId}-context-menu`,
|
|
93
|
+
onCloseAutoFocus: onCloseAutoFocus,
|
|
94
|
+
onClick: (event)=>event.stopPropagation(),
|
|
95
|
+
onKeyDown: (event)=>event.stopPropagation(),
|
|
96
|
+
children: items
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
export { GridContextMenu };
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
MarkGlyph: ()=>MarkGlyph
|
|
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 MarkGlyph = ({ tone, className })=>{
|
|
33
|
+
if ('error' === tone) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.CircleAlert, {
|
|
34
|
+
"aria-hidden": true,
|
|
35
|
+
"data-glyph": "error",
|
|
36
|
+
className: (0, apollo_wind_namespaceObject.cn)('size-3 shrink-0 text-error-icon', className)
|
|
37
|
+
});
|
|
38
|
+
if ('warning' === tone) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.TriangleAlert, {
|
|
39
|
+
"aria-hidden": true,
|
|
40
|
+
"data-glyph": "warning",
|
|
41
|
+
className: (0, apollo_wind_namespaceObject.cn)('size-3 shrink-0 text-warning-icon', className)
|
|
42
|
+
});
|
|
43
|
+
return null;
|
|
44
|
+
};
|
|
45
|
+
exports.MarkGlyph = __webpack_exports__.MarkGlyph;
|
|
46
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
47
|
+
"MarkGlyph"
|
|
48
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
49
|
+
Object.defineProperty(exports, '__esModule', {
|
|
50
|
+
value: true
|
|
51
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkGlyph.d.ts","sourceRoot":"","sources":["../../src/decision-table/MarkGlyph.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGxC,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,IAAI,CAAC,EAAE,QAAQ,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAqBvE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "@uipath/apollo-wind";
|
|
3
|
+
import { CircleAlert, TriangleAlert } from "lucide-react";
|
|
4
|
+
const MarkGlyph = ({ tone, className })=>{
|
|
5
|
+
if ('error' === tone) return /*#__PURE__*/ jsx(CircleAlert, {
|
|
6
|
+
"aria-hidden": true,
|
|
7
|
+
"data-glyph": "error",
|
|
8
|
+
className: cn('size-3 shrink-0 text-error-icon', className)
|
|
9
|
+
});
|
|
10
|
+
if ('warning' === tone) return /*#__PURE__*/ jsx(TriangleAlert, {
|
|
11
|
+
"aria-hidden": true,
|
|
12
|
+
"data-glyph": "warning",
|
|
13
|
+
className: cn('size-3 shrink-0 text-warning-icon', className)
|
|
14
|
+
});
|
|
15
|
+
return null;
|
|
16
|
+
};
|
|
17
|
+
export { MarkGlyph };
|
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
fromClipboardHtml: ()=>fromClipboardHtml,
|
|
28
|
+
parseTsv: ()=>parseTsv,
|
|
29
|
+
toClipboardHtml: ()=>toClipboardHtml,
|
|
30
|
+
toTsv: ()=>toTsv
|
|
31
|
+
});
|
|
32
|
+
const CLIPBOARD_PAYLOAD_ATTRIBUTE = 'data-uipath-brv2-payload';
|
|
33
|
+
const needsQuoting = (cell)=>cell.includes('\t') || cell.includes('\n') || cell.includes('\r') || cell.includes('"');
|
|
34
|
+
const quoteCell = (cell)=>needsQuoting(cell) ? `"${cell.replace(/"/g, '""')}"` : cell;
|
|
35
|
+
const toTsv = (matrix)=>matrix.map((row)=>row.map(quoteCell).join('\t')).join('\n');
|
|
36
|
+
const parseTsv = (text)=>{
|
|
37
|
+
const normalized = text.replace(/\r\n?/g, '\n');
|
|
38
|
+
const rows = [];
|
|
39
|
+
let row = [];
|
|
40
|
+
let cell = '';
|
|
41
|
+
let quoted = false;
|
|
42
|
+
let cellOpened = false;
|
|
43
|
+
let index = 0;
|
|
44
|
+
while(index < normalized.length){
|
|
45
|
+
const char = normalized[index];
|
|
46
|
+
if (quoted) {
|
|
47
|
+
if ('"' === char) {
|
|
48
|
+
if ('"' === normalized[index + 1]) {
|
|
49
|
+
cell += '"';
|
|
50
|
+
index += 2;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
quoted = false;
|
|
54
|
+
index += 1;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
cell += char;
|
|
58
|
+
index += 1;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if ('"' === char && '' === cell) {
|
|
62
|
+
quoted = true;
|
|
63
|
+
cellOpened = true;
|
|
64
|
+
index += 1;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if ('\t' === char) {
|
|
68
|
+
row.push(cell);
|
|
69
|
+
cell = '';
|
|
70
|
+
cellOpened = false;
|
|
71
|
+
index += 1;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if ('\n' === char) {
|
|
75
|
+
row.push(cell);
|
|
76
|
+
rows.push(row);
|
|
77
|
+
row = [];
|
|
78
|
+
cell = '';
|
|
79
|
+
cellOpened = false;
|
|
80
|
+
index += 1;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
cell += char;
|
|
84
|
+
index += 1;
|
|
85
|
+
}
|
|
86
|
+
if ('' !== cell || row.length > 0 || cellOpened) {
|
|
87
|
+
row.push(cell);
|
|
88
|
+
rows.push(row);
|
|
89
|
+
}
|
|
90
|
+
return rows;
|
|
91
|
+
};
|
|
92
|
+
const escapeHtml = (text)=>text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
93
|
+
const toClipboardHtml = (payload)=>{
|
|
94
|
+
const body = payload.matrix.map((row)=>`<tr>${row.map((cell)=>`<td>${escapeHtml(cell)}</td>`).join('')}</tr>`).join('');
|
|
95
|
+
return `<table ${CLIPBOARD_PAYLOAD_ATTRIBUTE}="${escapeHtml(JSON.stringify(payload))}"><tbody>${body}</tbody></table>`;
|
|
96
|
+
};
|
|
97
|
+
const fromClipboardHtml = (html)=>{
|
|
98
|
+
if (!html.includes(CLIPBOARD_PAYLOAD_ATTRIBUTE)) return null;
|
|
99
|
+
const parsed = new DOMParser().parseFromString(html, 'text/html');
|
|
100
|
+
const carrier = parsed.querySelector(`[${CLIPBOARD_PAYLOAD_ATTRIBUTE}]`);
|
|
101
|
+
const raw = carrier?.getAttribute(CLIPBOARD_PAYLOAD_ATTRIBUTE);
|
|
102
|
+
if (!raw) return null;
|
|
103
|
+
try {
|
|
104
|
+
const payload = JSON.parse(raw);
|
|
105
|
+
if (!Array.isArray(payload.matrix) || !payload.matrix.every((row)=>Array.isArray(row) && row.every((cell)=>'string' == typeof cell))) return null;
|
|
106
|
+
return payload;
|
|
107
|
+
} catch {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
exports.fromClipboardHtml = __webpack_exports__.fromClipboardHtml;
|
|
112
|
+
exports.parseTsv = __webpack_exports__.parseTsv;
|
|
113
|
+
exports.toClipboardHtml = __webpack_exports__.toClipboardHtml;
|
|
114
|
+
exports.toTsv = __webpack_exports__.toTsv;
|
|
115
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
116
|
+
"fromClipboardHtml",
|
|
117
|
+
"parseTsv",
|
|
118
|
+
"toClipboardHtml",
|
|
119
|
+
"toTsv"
|
|
120
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
121
|
+
Object.defineProperty(exports, '__esModule', {
|
|
122
|
+
value: true
|
|
123
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const toTsv: (matrix: string[][]) => string;
|
|
2
|
+
export declare const parseTsv: (text: string) => string[][];
|
|
3
|
+
export interface ClipboardPayload {
|
|
4
|
+
matrix: string[][];
|
|
5
|
+
}
|
|
6
|
+
export declare const toClipboardHtml: (payload: ClipboardPayload) => string;
|
|
7
|
+
export declare const fromClipboardHtml: (html: string) => ClipboardPayload | null;
|
|
8
|
+
//# sourceMappingURL=clipboardCodec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clipboardCodec.d.ts","sourceRoot":"","sources":["../../src/decision-table/clipboardCodec.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,KAAK,GAAI,QAAQ,MAAM,EAAE,EAAE,KAAG,MACoB,CAAC;AAQhE,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,KAAG,MAAM,EAAE,EA4D/C,CAAC;AAcF,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;CACpB;AAUD,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,MAK3D,CAAC;AAGF,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,KAAG,gBAAgB,GAAG,IA2BnE,CAAC"}
|