@uipath/apollo-react 7.30.0 → 7.31.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/ColumnPopover.cjs +1 -3
- package/dist/decision-table/ColumnPopover.d.ts +2 -2
- package/dist/decision-table/ColumnPopover.d.ts.map +1 -1
- package/dist/decision-table/ColumnPopover.js +1 -3
- package/dist/decision-table/DecisionGraphCard.cjs +112 -9
- package/dist/decision-table/DecisionGraphCard.d.ts +21 -0
- package/dist/decision-table/DecisionGraphCard.d.ts.map +1 -1
- package/dist/decision-table/DecisionGraphCard.js +115 -12
- package/dist/decision-table/DecisionGraphDialogs.cjs +223 -0
- package/dist/decision-table/DecisionGraphDialogs.d.ts +30 -0
- package/dist/decision-table/DecisionGraphDialogs.d.ts.map +1 -0
- package/dist/decision-table/DecisionGraphDialogs.js +183 -0
- package/dist/decision-table/DecisionGraphText.cjs +6 -338
- package/dist/decision-table/DecisionGraphText.d.ts +4 -15
- package/dist/decision-table/DecisionGraphText.d.ts.map +1 -1
- package/dist/decision-table/DecisionGraphText.js +7 -339
- package/dist/decision-table/DecisionGraphView.cjs +409 -0
- package/dist/decision-table/DecisionGraphView.d.ts +20 -0
- package/dist/decision-table/DecisionGraphView.d.ts.map +1 -0
- package/dist/decision-table/DecisionGraphView.js +375 -0
- package/dist/decision-table/DecisionTable.cjs +3 -1
- package/dist/decision-table/DecisionTable.d.ts.map +1 -1
- package/dist/decision-table/DecisionTable.js +3 -1
- package/dist/decision-table/DecisionText.cjs +2 -4
- package/dist/decision-table/DecisionText.d.ts.map +1 -1
- package/dist/decision-table/DecisionText.js +2 -4
- package/dist/decision-table/EditableDecisionGraphText.cjs +40 -0
- package/dist/decision-table/EditableDecisionGraphText.d.ts +5 -0
- package/dist/decision-table/EditableDecisionGraphText.d.ts.map +1 -0
- package/dist/decision-table/EditableDecisionGraphText.js +6 -0
- package/dist/decision-table/GridMenu.cjs +36 -2
- package/dist/decision-table/GridMenu.d.ts +8 -0
- package/dist/decision-table/GridMenu.d.ts.map +1 -1
- package/dist/decision-table/GridMenu.js +33 -2
- package/dist/decision-table/__fixtures__/graphActionsHost.d.ts +21 -0
- package/dist/decision-table/__fixtures__/graphActionsHost.d.ts.map +1 -0
- package/dist/decision-table/columnTypes.cjs +2 -8
- package/dist/decision-table/columnTypes.d.ts +4 -2
- package/dist/decision-table/columnTypes.d.ts.map +1 -1
- package/dist/decision-table/columnTypes.js +2 -8
- package/dist/decision-table/constants.cjs +7 -0
- package/dist/decision-table/constants.d.ts +1 -0
- package/dist/decision-table/constants.d.ts.map +1 -1
- package/dist/decision-table/constants.js +5 -1
- package/dist/decision-table/decisionGraphActionTypes.d.ts +88 -0
- package/dist/decision-table/decisionGraphActionTypes.d.ts.map +1 -0
- package/dist/decision-table/decisionGraphMenuEntries.cjs +247 -0
- package/dist/decision-table/decisionGraphMenuEntries.d.ts +46 -0
- package/dist/decision-table/decisionGraphMenuEntries.d.ts.map +1 -0
- package/dist/decision-table/decisionGraphMenuEntries.js +186 -0
- package/dist/decision-table/decisionGraphPositions.cjs +136 -0
- package/dist/decision-table/decisionGraphPositions.d.ts +26 -0
- package/dist/decision-table/decisionGraphPositions.d.ts.map +1 -0
- package/dist/decision-table/decisionGraphPositions.js +69 -0
- package/dist/decision-table/decisionGraphStyles.cjs +24 -16
- package/dist/decision-table/decisionGraphStyles.d.ts +3 -1
- package/dist/decision-table/decisionGraphStyles.d.ts.map +1 -1
- package/dist/decision-table/decisionGraphStyles.js +4 -2
- package/dist/decision-table/decisionTextTypes.d.ts +3 -1
- package/dist/decision-table/decisionTextTypes.d.ts.map +1 -1
- package/dist/decision-table/hitPolicyMenu.cjs +4 -10
- package/dist/decision-table/hitPolicyMenu.d.ts +5 -3
- package/dist/decision-table/hitPolicyMenu.d.ts.map +1 -1
- package/dist/decision-table/hitPolicyMenu.js +4 -10
- package/dist/decision-table/index.cjs +62 -54
- package/dist/decision-table/index.d.ts +2 -0
- package/dist/decision-table/index.d.ts.map +1 -1
- package/dist/decision-table/index.js +2 -1
- package/dist/decision-table/locales/de.cjs +1 -1
- package/dist/decision-table/locales/de.d.ts.map +1 -1
- package/dist/decision-table/locales/de.js +1 -1
- package/dist/decision-table/locales/en.cjs +1 -1
- package/dist/decision-table/locales/en.d.ts.map +1 -1
- package/dist/decision-table/locales/en.js +1 -1
- package/dist/decision-table/locales/es-MX.cjs +1 -1
- package/dist/decision-table/locales/es-MX.d.ts.map +1 -1
- package/dist/decision-table/locales/es-MX.js +1 -1
- package/dist/decision-table/locales/es.cjs +1 -1
- package/dist/decision-table/locales/es.d.ts.map +1 -1
- package/dist/decision-table/locales/es.js +1 -1
- package/dist/decision-table/locales/fr.cjs +1 -1
- package/dist/decision-table/locales/fr.d.ts.map +1 -1
- package/dist/decision-table/locales/fr.js +1 -1
- package/dist/decision-table/locales/ja.cjs +1 -1
- package/dist/decision-table/locales/ja.d.ts.map +1 -1
- package/dist/decision-table/locales/ja.js +1 -1
- package/dist/decision-table/locales/ko.cjs +1 -1
- package/dist/decision-table/locales/ko.d.ts.map +1 -1
- package/dist/decision-table/locales/ko.js +1 -1
- package/dist/decision-table/locales/pt-BR.cjs +1 -1
- package/dist/decision-table/locales/pt-BR.d.ts.map +1 -1
- package/dist/decision-table/locales/pt-BR.js +1 -1
- package/dist/decision-table/locales/pt.cjs +1 -1
- package/dist/decision-table/locales/pt.d.ts.map +1 -1
- package/dist/decision-table/locales/pt.js +1 -1
- package/dist/decision-table/locales/ro.cjs +1 -1
- package/dist/decision-table/locales/ro.d.ts.map +1 -1
- package/dist/decision-table/locales/ro.js +1 -1
- package/dist/decision-table/locales/ru.cjs +1 -1
- package/dist/decision-table/locales/ru.d.ts.map +1 -1
- package/dist/decision-table/locales/ru.js +1 -1
- package/dist/decision-table/locales/tr.cjs +1 -1
- package/dist/decision-table/locales/tr.d.ts.map +1 -1
- package/dist/decision-table/locales/tr.js +1 -1
- package/dist/decision-table/locales/zh-CN.cjs +1 -1
- package/dist/decision-table/locales/zh-CN.d.ts.map +1 -1
- package/dist/decision-table/locales/zh-CN.js +1 -1
- package/dist/decision-table/locales/zh-TW.cjs +1 -1
- package/dist/decision-table/locales/zh-TW.d.ts.map +1 -1
- package/dist/decision-table/locales/zh-TW.js +1 -1
- package/dist/decision-table/styles/tailwind.decision-table.css +1 -1
- package/dist/decision-table/useDecisionGraphActions.cjs +385 -0
- package/dist/decision-table/useDecisionGraphActions.d.ts +24 -0
- package/dist/decision-table/useDecisionGraphActions.d.ts.map +1 -0
- package/dist/decision-table/useDecisionGraphActions.js +351 -0
- package/dist/decision-table/useDecisionGraphStrings.cjs +138 -0
- package/dist/decision-table/useDecisionGraphStrings.d.ts +2 -1
- package/dist/decision-table/useDecisionGraphStrings.d.ts.map +1 -1
- package/dist/decision-table/useDecisionGraphStrings.js +138 -0
- package/dist/decision-table/useDecisionTextStrings.cjs +22 -0
- package/dist/decision-table/useDecisionTextStrings.d.ts.map +1 -1
- package/dist/decision-table/useDecisionTextStrings.js +22 -0
- package/dist/decision-table/useDragReorder.cjs +3 -2
- package/dist/decision-table/useDragReorder.d.ts.map +1 -1
- package/dist/decision-table/useDragReorder.js +3 -2
- package/dist/decision-table/useRuleWindow.cjs +3 -7
- package/dist/decision-table/useRuleWindow.d.ts.map +1 -1
- package/dist/decision-table/useRuleWindow.js +1 -5
- package/dist/decision-table/useTextAnnouncements.cjs +2 -9
- package/dist/decision-table/useTextAnnouncements.d.ts +4 -2
- package/dist/decision-table/useTextAnnouncements.d.ts.map +1 -1
- package/dist/decision-table/useTextAnnouncements.js +2 -9
- package/package.json +2 -2
- package/dist/decision-table/translate.d.ts +0 -3
- package/dist/decision-table/translate.d.ts.map +0 -1
- /package/dist/decision-table/{translate.cjs → decisionGraphActionTypes.cjs} +0 -0
- /package/dist/decision-table/{translate.js → decisionGraphActionTypes.js} +0 -0
|
@@ -0,0 +1,385 @@
|
|
|
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
|
+
useDecisionGraphActions: ()=>useDecisionGraphActions
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const external_react_namespaceObject = require("react");
|
|
31
|
+
const external_constants_cjs_namespaceObject = require("./constants.cjs");
|
|
32
|
+
const external_DecisionGraphDialogs_cjs_namespaceObject = require("./DecisionGraphDialogs.cjs");
|
|
33
|
+
const external_decisionGraphMenuEntries_cjs_namespaceObject = require("./decisionGraphMenuEntries.cjs");
|
|
34
|
+
const external_decisionGraphPositions_cjs_namespaceObject = require("./decisionGraphPositions.cjs");
|
|
35
|
+
const external_gridEvents_cjs_namespaceObject = require("./gridEvents.cjs");
|
|
36
|
+
const NONE = {
|
|
37
|
+
kind: 'none'
|
|
38
|
+
};
|
|
39
|
+
const kindOf = (surface)=>{
|
|
40
|
+
if ('links' === surface.kind) return surface.links;
|
|
41
|
+
return 'note' === surface.kind ? 'addNote' : surface.kind;
|
|
42
|
+
};
|
|
43
|
+
const MOVE_KEY_OF = {
|
|
44
|
+
ArrowUp: 'up',
|
|
45
|
+
ArrowDown: 'down',
|
|
46
|
+
ArrowRight: 'under',
|
|
47
|
+
ArrowLeft: 'out'
|
|
48
|
+
};
|
|
49
|
+
const onlyModifiers = (event, alt, shift)=>event.altKey === alt && event.shiftKey === shift && !event.ctrlKey && !event.metaKey;
|
|
50
|
+
const neighbourOf = (position)=>{
|
|
51
|
+
const next = position.siblings[position.index + 1] ?? position.siblings[position.index - 1];
|
|
52
|
+
if (next) return (0, external_decisionGraphMenuEntries_cjs_namespaceObject.focusOf)(next);
|
|
53
|
+
return 'under' === position.kind ? {
|
|
54
|
+
kind: 'decision',
|
|
55
|
+
decisionId: position.parent.id
|
|
56
|
+
} : null;
|
|
57
|
+
};
|
|
58
|
+
const useDecisionGraphActions = ({ mode, nodes, labels, openOf, cardOf, scroller, announce, dataTestId })=>{
|
|
59
|
+
const [surface, setSurface] = (0, external_react_namespaceObject.useState)(NONE);
|
|
60
|
+
const [, setRuns] = (0, external_react_namespaceObject.useState)(0);
|
|
61
|
+
const focusRef = (0, external_react_namespaceObject.useRef)(null);
|
|
62
|
+
const holdsFocusRef = (0, external_react_namespaceObject.useRef)(false);
|
|
63
|
+
const byKeyRef = (0, external_react_namespaceObject.useRef)(false);
|
|
64
|
+
const bodyRef = (0, external_react_namespaceObject.useRef)(null);
|
|
65
|
+
const lastDecisionRef = (0, external_react_namespaceObject.useRef)(null);
|
|
66
|
+
const deletedRef = (0, external_react_namespaceObject.useRef)(null);
|
|
67
|
+
const decisions = (0, external_react_namespaceObject.useMemo)(()=>(0, external_decisionGraphPositions_cjs_namespaceObject.decisionsOf)(nodes), [
|
|
68
|
+
nodes
|
|
69
|
+
]);
|
|
70
|
+
const users = (0, external_react_namespaceObject.useMemo)(()=>(0, external_decisionGraphPositions_cjs_namespaceObject.usersOf)(nodes), [
|
|
71
|
+
nodes
|
|
72
|
+
]);
|
|
73
|
+
const edit = 'edit' === mode.kind ? mode.edit : null;
|
|
74
|
+
const toggleOf = (decisionId)=>cardOf(decisionId)?.querySelector('[data-graph-toggle]') ?? null;
|
|
75
|
+
const elementOf = (focus)=>'decision' === focus.kind ? toggleOf(focus.decisionId) : scroller?.querySelector(`[data-graph-reference-link="${CSS.escape(focus.referenceId)}"]`) ?? toggleOf(focus.decisionId);
|
|
76
|
+
const land = (element)=>{
|
|
77
|
+
element.focus({
|
|
78
|
+
preventScroll: true
|
|
79
|
+
});
|
|
80
|
+
if (byKeyRef.current) element.scrollIntoView?.(external_constants_cjs_namespaceObject.NEAREST);
|
|
81
|
+
};
|
|
82
|
+
const focusOn = (focus)=>{
|
|
83
|
+
const element = focus && elementOf(focus);
|
|
84
|
+
if (element) land(element);
|
|
85
|
+
return null !== element;
|
|
86
|
+
};
|
|
87
|
+
const focusFallback = ()=>{
|
|
88
|
+
const add = scroller?.querySelector('[data-graph-add]');
|
|
89
|
+
if (add) return void land(add);
|
|
90
|
+
if (!scroller) return;
|
|
91
|
+
if (!scroller.hasAttribute('tabindex')) scroller.tabIndex = -1;
|
|
92
|
+
scroller.focus({
|
|
93
|
+
preventScroll: true
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
const recover = (fromBody)=>{
|
|
97
|
+
if (fromBody !== (bodyRef.current?.isConnected ?? false)) return;
|
|
98
|
+
if (!holdsFocusRef.current || null === scroller || !(0, external_gridEvents_cjs_namespaceObject.hasLostFocus)(scroller)) return;
|
|
99
|
+
const lost = lastDecisionRef.current;
|
|
100
|
+
const deleted = deletedRef.current;
|
|
101
|
+
const neighbour = null !== lost && deleted?.decisionId === lost ? deleted.neighbour : null;
|
|
102
|
+
const decision = null === lost ? null : {
|
|
103
|
+
kind: 'decision',
|
|
104
|
+
decisionId: lost
|
|
105
|
+
};
|
|
106
|
+
if (!focusOn(decision) && !focusOn(neighbour)) focusFallback();
|
|
107
|
+
};
|
|
108
|
+
(0, external_react_namespaceObject.useLayoutEffect)(()=>{
|
|
109
|
+
recover(false);
|
|
110
|
+
const focus = focusRef.current;
|
|
111
|
+
if (null === focus) return;
|
|
112
|
+
focusRef.current = null;
|
|
113
|
+
focusOn(focus);
|
|
114
|
+
});
|
|
115
|
+
(0, external_react_namespaceObject.useEffect)(()=>recover(true));
|
|
116
|
+
const focusWithin = {
|
|
117
|
+
onFocus: (event)=>{
|
|
118
|
+
holdsFocusRef.current = true;
|
|
119
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
120
|
+
const card = target?.closest('[data-graph-card]');
|
|
121
|
+
const nest = target?.closest('[data-graph-nest-of]');
|
|
122
|
+
bodyRef.current = target?.closest('[data-graph-body]') ?? null;
|
|
123
|
+
lastDecisionRef.current = card?.dataset.decisionId ?? nest?.dataset.graphNestOf ?? ('none' === surface.kind ? null : surface.decisionId);
|
|
124
|
+
},
|
|
125
|
+
onBlur: ()=>{
|
|
126
|
+
holdsFocusRef.current = false;
|
|
127
|
+
},
|
|
128
|
+
onKeyDownCapture: ()=>{
|
|
129
|
+
byKeyRef.current = true;
|
|
130
|
+
},
|
|
131
|
+
onPointerDownCapture: ()=>{
|
|
132
|
+
byKeyRef.current = false;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const open = decisions.find((decision)=>'none' !== surface.kind && decision.id === surface.decisionId);
|
|
136
|
+
if ('none' !== surface.kind && (!edit || !open || !(0, external_decisionGraphMenuEntries_cjs_namespaceObject.actionOf)(edit.actions, kindOf(surface)))) setSurface(NONE);
|
|
137
|
+
if (!edit) return {
|
|
138
|
+
cardOf: ()=>null,
|
|
139
|
+
referenceOf: ()=>null,
|
|
140
|
+
addTop: null,
|
|
141
|
+
dialogs: null,
|
|
142
|
+
focusWithin
|
|
143
|
+
};
|
|
144
|
+
const { actions, wordRefusal } = edit;
|
|
145
|
+
const tried = (refusal)=>void 0 === refusal ? null : wordRefusal(refusal);
|
|
146
|
+
const run = (call, focus)=>{
|
|
147
|
+
const refusal = tried(call());
|
|
148
|
+
focusRef.current = focus;
|
|
149
|
+
setRuns((runs)=>runs + 1);
|
|
150
|
+
if (null !== refusal) announce(refusal);
|
|
151
|
+
};
|
|
152
|
+
const closeFocusTo = (decisionId)=>(event)=>{
|
|
153
|
+
event.preventDefault();
|
|
154
|
+
focusOn({
|
|
155
|
+
kind: 'decision',
|
|
156
|
+
decisionId
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
const handlersOf = (node, position)=>{
|
|
160
|
+
const decisionId = (0, external_decisionGraphPositions_cjs_namespaceObject.decisionIdOf)(node);
|
|
161
|
+
return {
|
|
162
|
+
run,
|
|
163
|
+
open: openOf(decisionId),
|
|
164
|
+
startRename: ()=>setSurface({
|
|
165
|
+
kind: 'rename',
|
|
166
|
+
decisionId,
|
|
167
|
+
from: node.label,
|
|
168
|
+
draft: node.label,
|
|
169
|
+
refusal: null
|
|
170
|
+
}),
|
|
171
|
+
confirmDelete: ()=>setSurface({
|
|
172
|
+
kind: 'delete',
|
|
173
|
+
decisionId,
|
|
174
|
+
neighbour: neighbourOf(position),
|
|
175
|
+
refusal: null
|
|
176
|
+
}),
|
|
177
|
+
chooseLinks: (links)=>setSurface({
|
|
178
|
+
kind: 'links',
|
|
179
|
+
links,
|
|
180
|
+
decisionId,
|
|
181
|
+
refusal: null
|
|
182
|
+
}),
|
|
183
|
+
writeNote: ()=>setSurface({
|
|
184
|
+
kind: 'note',
|
|
185
|
+
decisionId,
|
|
186
|
+
refusal: null
|
|
187
|
+
}),
|
|
188
|
+
changeLogic: (0, external_decisionGraphMenuEntries_cjs_namespaceObject.actionOf)(actions, 'changeLogic')
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
const keysOf = (node, position)=>{
|
|
192
|
+
const move = (0, external_decisionGraphMenuEntries_cjs_namespaceObject.actionOf)(actions, 'move');
|
|
193
|
+
const moves = (0, external_decisionGraphMenuEntries_cjs_namespaceObject.movesOf)(node, position);
|
|
194
|
+
const handlers = handlersOf(node, position);
|
|
195
|
+
const isCard = 'decision' === node.kind;
|
|
196
|
+
const shortcuts = [
|
|
197
|
+
...isCard && (0, external_decisionGraphMenuEntries_cjs_namespaceObject.actionOf)(actions, 'rename') ? [
|
|
198
|
+
external_decisionGraphMenuEntries_cjs_namespaceObject.RENAME_KEY
|
|
199
|
+
] : [],
|
|
200
|
+
...isCard && (0, external_decisionGraphMenuEntries_cjs_namespaceObject.actionOf)(actions, 'delete') ? [
|
|
201
|
+
external_decisionGraphMenuEntries_cjs_namespaceObject.DELETE_KEY
|
|
202
|
+
] : [],
|
|
203
|
+
...move ? [
|
|
204
|
+
external_decisionGraphMenuEntries_cjs_namespaceObject.MOVE_KEYS.up,
|
|
205
|
+
external_decisionGraphMenuEntries_cjs_namespaceObject.MOVE_KEYS.down
|
|
206
|
+
] : [],
|
|
207
|
+
...move && isCard ? [
|
|
208
|
+
external_decisionGraphMenuEntries_cjs_namespaceObject.MOVE_KEYS.under,
|
|
209
|
+
external_decisionGraphMenuEntries_cjs_namespaceObject.MOVE_KEYS.out
|
|
210
|
+
] : []
|
|
211
|
+
];
|
|
212
|
+
const onKeyDown = (event)=>{
|
|
213
|
+
if (isCard && event.key === external_decisionGraphMenuEntries_cjs_namespaceObject.RENAME_KEY && onlyModifiers(event, false, false)) {
|
|
214
|
+
if (!(0, external_decisionGraphMenuEntries_cjs_namespaceObject.actionOf)(actions, 'rename')) return;
|
|
215
|
+
event.preventDefault();
|
|
216
|
+
handlers.startRename();
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (isCard && event.key === external_decisionGraphMenuEntries_cjs_namespaceObject.DELETE_KEY && onlyModifiers(event, false, false)) {
|
|
220
|
+
if (!(0, external_decisionGraphMenuEntries_cjs_namespaceObject.actionOf)(actions, 'delete')) return;
|
|
221
|
+
event.preventDefault();
|
|
222
|
+
handlers.confirmDelete();
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
const key = MOVE_KEY_OF[event.key];
|
|
226
|
+
if (!move || !key || !onlyModifiers(event, true, true)) return;
|
|
227
|
+
if (!isCard && ('under' === key || 'out' === key)) return;
|
|
228
|
+
event.preventDefault();
|
|
229
|
+
const proposed = moves[key];
|
|
230
|
+
if (proposed) run(()=>move.onMove(proposed), (0, external_decisionGraphMenuEntries_cjs_namespaceObject.focusOf)(node));
|
|
231
|
+
};
|
|
232
|
+
return {
|
|
233
|
+
shortcuts,
|
|
234
|
+
onKeyDown,
|
|
235
|
+
handlers
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
const cardActionsOf = (node, position)=>{
|
|
239
|
+
const { shortcuts, onKeyDown, handlers } = keysOf(node, position);
|
|
240
|
+
const entries = ()=>(0, external_decisionGraphMenuEntries_cjs_namespaceObject.decisionEntriesOf)(actions, labels, node, position, handlers);
|
|
241
|
+
if (!(0, external_decisionGraphMenuEntries_cjs_namespaceObject.hasDecisionEntries)(actions, node, position, handlers.open)) return null;
|
|
242
|
+
const rename = (0, external_decisionGraphMenuEntries_cjs_namespaceObject.actionOf)(actions, 'rename');
|
|
243
|
+
return {
|
|
244
|
+
menuLabel: labels.decisionActions(node.label),
|
|
245
|
+
entries,
|
|
246
|
+
onKeyDown,
|
|
247
|
+
keyShortcuts: shortcuts,
|
|
248
|
+
nameField: labels.nameField(node.label),
|
|
249
|
+
rename: rename && 'rename' === surface.kind && surface.decisionId === node.id ? {
|
|
250
|
+
from: surface.from,
|
|
251
|
+
draft: surface.draft,
|
|
252
|
+
onDraft: (draft)=>setSurface({
|
|
253
|
+
...surface,
|
|
254
|
+
draft
|
|
255
|
+
}),
|
|
256
|
+
refusal: surface.refusal?.text ?? null,
|
|
257
|
+
onCommit: (name, byKey)=>{
|
|
258
|
+
if (!byKey && surface.refusal?.name === name) return void setSurface(NONE);
|
|
259
|
+
const refusal = tried(rename.onRename(node.id, name));
|
|
260
|
+
if (null !== refusal && byKey) return void setSurface({
|
|
261
|
+
...surface,
|
|
262
|
+
draft: name,
|
|
263
|
+
refusal: {
|
|
264
|
+
name,
|
|
265
|
+
text: refusal
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
if (null !== refusal) announce(refusal);
|
|
269
|
+
setSurface(NONE);
|
|
270
|
+
if (byKey) focusRef.current = (0, external_decisionGraphMenuEntries_cjs_namespaceObject.focusOf)(node);
|
|
271
|
+
},
|
|
272
|
+
onCancel: (byKey)=>{
|
|
273
|
+
setSurface(NONE);
|
|
274
|
+
if (byKey) focusRef.current = (0, external_decisionGraphMenuEntries_cjs_namespaceObject.focusOf)(node);
|
|
275
|
+
}
|
|
276
|
+
} : null
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
const referenceActionsOf = (node, position)=>{
|
|
280
|
+
const { shortcuts, onKeyDown, handlers } = keysOf(node, position);
|
|
281
|
+
const entries = ()=>(0, external_decisionGraphMenuEntries_cjs_namespaceObject.referenceEntriesOf)(actions, labels, node, position, handlers);
|
|
282
|
+
if (!(0, external_decisionGraphMenuEntries_cjs_namespaceObject.hasReferenceEntries)(actions, node, position, handlers.open)) return null;
|
|
283
|
+
return {
|
|
284
|
+
menuLabel: labels.decisionActions(node.label),
|
|
285
|
+
entries,
|
|
286
|
+
onKeyDown,
|
|
287
|
+
keyShortcuts: shortcuts
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
const add = (0, external_decisionGraphMenuEntries_cjs_namespaceObject.actionOf)(actions, 'add');
|
|
291
|
+
const addTop = add ? ()=>{
|
|
292
|
+
const place = {
|
|
293
|
+
kind: 'top',
|
|
294
|
+
index: nodes.length
|
|
295
|
+
};
|
|
296
|
+
run(()=>add.onAdd(place), null);
|
|
297
|
+
} : null;
|
|
298
|
+
const dialogOf = ()=>{
|
|
299
|
+
if ('none' === surface.kind || 'rename' === surface.kind || !open) return null;
|
|
300
|
+
const { decisionId } = surface;
|
|
301
|
+
const close = ()=>setSurface(NONE);
|
|
302
|
+
const base = {
|
|
303
|
+
labels,
|
|
304
|
+
refusal: surface.refusal,
|
|
305
|
+
onClose: close,
|
|
306
|
+
onCloseAutoFocus: closeFocusTo(decisionId)
|
|
307
|
+
};
|
|
308
|
+
const refuse = (refusal)=>setSurface({
|
|
309
|
+
...surface,
|
|
310
|
+
refusal
|
|
311
|
+
});
|
|
312
|
+
if ('delete' === surface.kind) {
|
|
313
|
+
const remove = (0, external_decisionGraphMenuEntries_cjs_namespaceObject.actionOf)(actions, 'delete');
|
|
314
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_DecisionGraphDialogs_cjs_namespaceObject.DecisionGraphDeleteDialog, {
|
|
315
|
+
...base,
|
|
316
|
+
onCloseAutoFocus: (event)=>{
|
|
317
|
+
event.preventDefault();
|
|
318
|
+
if (focusOn({
|
|
319
|
+
kind: 'decision',
|
|
320
|
+
decisionId
|
|
321
|
+
}) || focusOn(surface.neighbour)) return;
|
|
322
|
+
focusFallback();
|
|
323
|
+
},
|
|
324
|
+
name: open.label,
|
|
325
|
+
usedBy: users.get(decisionId) ?? [],
|
|
326
|
+
onConfirm: ()=>{
|
|
327
|
+
if (!remove) return;
|
|
328
|
+
const refusal = tried(remove.onDelete(decisionId));
|
|
329
|
+
if (null === refusal) deletedRef.current = {
|
|
330
|
+
decisionId,
|
|
331
|
+
neighbour: surface.neighbour
|
|
332
|
+
};
|
|
333
|
+
if (null === refusal) close();
|
|
334
|
+
else refuse(refusal);
|
|
335
|
+
},
|
|
336
|
+
dataTestId: `${dataTestId}-delete-dialog`
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
if ('note' === surface.kind) {
|
|
340
|
+
const note = (0, external_decisionGraphMenuEntries_cjs_namespaceObject.actionOf)(actions, 'addNote');
|
|
341
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_DecisionGraphDialogs_cjs_namespaceObject.DecisionGraphNoteDialog, {
|
|
342
|
+
...base,
|
|
343
|
+
name: open.label,
|
|
344
|
+
onSave: (text)=>{
|
|
345
|
+
if (!note) return;
|
|
346
|
+
const refusal = tried(note.onAddNote(decisionId, text));
|
|
347
|
+
if (null === refusal) close();
|
|
348
|
+
else refuse(refusal);
|
|
349
|
+
},
|
|
350
|
+
dataTestId: `${dataTestId}-note-dialog`
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
const inputs = 'chooseInputs' === surface.links;
|
|
354
|
+
const linked = inputs ? (0, external_decisionGraphPositions_cjs_namespaceObject.inputIdsOf)(open) : (users.get(decisionId) ?? []).map((user)=>user.id);
|
|
355
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_DecisionGraphDialogs_cjs_namespaceObject.DecisionGraphLinksDialog, {
|
|
356
|
+
...base,
|
|
357
|
+
title: inputs ? labels.inputsTitle(open.label) : labels.usersTitle(open.label),
|
|
358
|
+
options: decisions.filter((decision)=>decision.id !== decisionId),
|
|
359
|
+
linked: linked,
|
|
360
|
+
onSave: (ids)=>{
|
|
361
|
+
if (ids.length === linked.length && ids.every((id, index)=>id === linked[index])) return void close();
|
|
362
|
+
const chooseInputs = (0, external_decisionGraphMenuEntries_cjs_namespaceObject.actionOf)(actions, 'chooseInputs');
|
|
363
|
+
const chooseUsers = (0, external_decisionGraphMenuEntries_cjs_namespaceObject.actionOf)(actions, 'chooseUsers');
|
|
364
|
+
const refusal = inputs ? chooseInputs && tried(chooseInputs.onChooseInputs(decisionId, ids)) : chooseUsers && tried(chooseUsers.onChooseUsers(decisionId, ids));
|
|
365
|
+
if ('string' == typeof refusal) refuse(refusal);
|
|
366
|
+
else close();
|
|
367
|
+
},
|
|
368
|
+
dataTestId: `${dataTestId}-links-dialog`
|
|
369
|
+
});
|
|
370
|
+
};
|
|
371
|
+
return {
|
|
372
|
+
cardOf: cardActionsOf,
|
|
373
|
+
referenceOf: referenceActionsOf,
|
|
374
|
+
addTop,
|
|
375
|
+
dialogs: dialogOf(),
|
|
376
|
+
focusWithin
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
exports.useDecisionGraphActions = __webpack_exports__.useDecisionGraphActions;
|
|
380
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
381
|
+
"useDecisionGraphActions"
|
|
382
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
383
|
+
Object.defineProperty(exports, '__esModule', {
|
|
384
|
+
value: true
|
|
385
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { DecisionGraphCardActions, DecisionGraphNodeActions } from './DecisionGraphCard';
|
|
3
|
+
import type { DecisionGraphActionLabels, DecisionGraphMode } from './decisionGraphActionTypes';
|
|
4
|
+
import { type DecisionGraphPosition } from './decisionGraphPositions';
|
|
5
|
+
import type { DecisionGraphDecisionNode, DecisionGraphNode, DecisionGraphReferenceNode } from './decisionGraphTypes';
|
|
6
|
+
export interface DecisionGraphActionsParams<Refusal, Logic> {
|
|
7
|
+
mode: DecisionGraphMode<Refusal, Logic>;
|
|
8
|
+
nodes: readonly DecisionGraphNode[];
|
|
9
|
+
labels: DecisionGraphActionLabels;
|
|
10
|
+
openOf: (decisionId: string) => (() => void) | undefined;
|
|
11
|
+
cardOf: (decisionId: string) => HTMLElement | undefined;
|
|
12
|
+
scroller: HTMLElement | null;
|
|
13
|
+
announce: (text: string) => void;
|
|
14
|
+
dataTestId: string;
|
|
15
|
+
}
|
|
16
|
+
export interface DecisionGraphActions {
|
|
17
|
+
cardOf: (node: DecisionGraphDecisionNode, position: DecisionGraphPosition) => DecisionGraphCardActions | null;
|
|
18
|
+
referenceOf: (node: DecisionGraphReferenceNode, position: DecisionGraphPosition) => DecisionGraphNodeActions | null;
|
|
19
|
+
addTop: (() => void) | null;
|
|
20
|
+
dialogs: React.ReactNode;
|
|
21
|
+
focusWithin: Pick<React.DOMAttributes<HTMLElement>, 'onFocus' | 'onBlur' | 'onKeyDownCapture' | 'onPointerDownCapture'>;
|
|
22
|
+
}
|
|
23
|
+
export declare const useDecisionGraphActions: <Refusal, Logic>({ mode, nodes, labels, openOf, cardOf, scroller, announce, dataTestId, }: DecisionGraphActionsParams<Refusal, Logic>) => DecisionGraphActions;
|
|
24
|
+
//# sourceMappingURL=useDecisionGraphActions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDecisionGraphActions.d.ts","sourceRoot":"","sources":["../../src/decision-table/useDecisionGraphActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAM9F,OAAO,KAAK,EAEV,yBAAyB,EAEzB,iBAAiB,EAElB,MAAM,4BAA4B,CAAC;AAepC,OAAO,EACL,KAAK,qBAAqB,EAK3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,yBAAyB,EACzB,iBAAiB,EACjB,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAmC9B,MAAM,WAAW,0BAA0B,CAAC,OAAO,EAAE,KAAK;IACxD,IAAI,EAAE,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACxC,KAAK,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACpC,MAAM,EAAE,yBAAyB,CAAC;IAClC,MAAM,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IAEzD,MAAM,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;IAExD,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,CACN,IAAI,EAAE,yBAAyB,EAC/B,QAAQ,EAAE,qBAAqB,KAC5B,wBAAwB,GAAG,IAAI,CAAC;IACrC,WAAW,EAAE,CACX,IAAI,EAAE,0BAA0B,EAChC,QAAQ,EAAE,qBAAqB,KAC5B,wBAAwB,GAAG,IAAI,CAAC;IAErC,MAAM,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;IAC5B,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;IAEzB,WAAW,EAAE,IAAI,CACf,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,EAChC,SAAS,GAAG,QAAQ,GAAG,kBAAkB,GAAG,sBAAsB,CACnE,CAAC;CACH;AAoBD,eAAO,MAAM,uBAAuB,GAAI,OAAO,EAAE,KAAK,EAAE,0EASrD,0BAA0B,CAAC,OAAO,EAAE,KAAK,CAAC,KAAG,oBAyU/C,CAAC"}
|