@uipath/apollo-react 7.35.0 → 7.36.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/components/BaseNode/BaseNodeContainer.cjs +4 -4
- package/dist/canvas/components/BaseNode/BaseNodeContainer.js +4 -4
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/chat/styles/tailwind.chat.css +1 -1
- package/dist/decision-table/DecisionGraphText.cjs +398 -6
- package/dist/decision-table/DecisionGraphText.d.ts +15 -5
- package/dist/decision-table/DecisionGraphText.d.ts.map +1 -1
- package/dist/decision-table/DecisionGraphText.js +399 -7
- package/dist/decision-table/DecisionText.cjs +5 -1
- package/dist/decision-table/DecisionText.d.ts +3 -3
- package/dist/decision-table/DecisionText.d.ts.map +1 -1
- package/dist/decision-table/DecisionText.js +5 -1
- package/dist/decision-table/__fixtures__/textMode.d.ts +3 -3
- package/dist/decision-table/__fixtures__/textMode.d.ts.map +1 -1
- package/dist/decision-table/__fixtures__/useStoryHistory.d.ts +7 -0
- package/dist/decision-table/__fixtures__/useStoryHistory.d.ts.map +1 -0
- package/dist/decision-table/decisionGraphActionTypes.d.ts +8 -0
- package/dist/decision-table/decisionGraphActionTypes.d.ts.map +1 -1
- package/dist/decision-table/index.cjs +54 -62
- package/dist/decision-table/index.d.ts +0 -1
- package/dist/decision-table/index.d.ts.map +1 -1
- package/dist/decision-table/index.js +1 -2
- package/dist/decision-table/styles/tailwind.decision-table.css +1 -1
- package/dist/decision-table/useContainerHandlers.cjs +13 -2
- package/dist/decision-table/useContainerHandlers.d.ts +6 -1
- package/dist/decision-table/useContainerHandlers.d.ts.map +1 -1
- package/dist/decision-table/useContainerHandlers.js +14 -3
- package/package.json +2 -2
- package/dist/decision-table/DecisionGraphView.cjs +0 -435
- package/dist/decision-table/DecisionGraphView.d.ts +0 -19
- package/dist/decision-table/DecisionGraphView.d.ts.map +0 -1
- package/dist/decision-table/DecisionGraphView.js +0 -401
- package/dist/decision-table/EditableDecisionGraphText.cjs +0 -40
- package/dist/decision-table/EditableDecisionGraphText.d.ts +0 -5
- package/dist/decision-table/EditableDecisionGraphText.d.ts.map +0 -1
- package/dist/decision-table/EditableDecisionGraphText.js +0 -6
|
@@ -31,7 +31,7 @@ const external_gridEvents_cjs_namespaceObject = require("./gridEvents.cjs");
|
|
|
31
31
|
const external_sentenceTargets_cjs_namespaceObject = require("./sentenceTargets.cjs");
|
|
32
32
|
const external_useSentenceNavigation_cjs_namespaceObject = require("./useSentenceNavigation.cjs");
|
|
33
33
|
const isTabOnView = (event)=>'Tab' === event.key && !event.shiftKey && event.target === event.currentTarget;
|
|
34
|
-
const useContainerHandlers = ({ containerProps, hoverTo, navigation, valueEditing, ruleMenus, onOpenDecision, container, stopTabbable, focusRow })=>{
|
|
34
|
+
const useContainerHandlers = ({ containerProps, hoverTo, navigation, valueEditing, ruleMenus, onOpenDecision, container, stopTabbable, focusRow, history })=>{
|
|
35
35
|
const focusWithinRef = (0, external_react_namespaceObject.useRef)(false);
|
|
36
36
|
const pressedRef = (0, external_react_namespaceObject.useRef)(false);
|
|
37
37
|
const stopPressRef = (0, external_react_namespaceObject.useRef)(null);
|
|
@@ -73,11 +73,22 @@ const useContainerHandlers = ({ containerProps, hoverTo, navigation, valueEditin
|
|
|
73
73
|
return true;
|
|
74
74
|
};
|
|
75
75
|
const openStopDecision = (event)=>'Enter' === event.key && event.altKey && !(0, external_useSentenceNavigation_cjs_namespaceObject.isIgnoredKey)(event) && openDecision(event, (0, external_sentenceTargets_cjs_namespaceObject.stopDecisionOf)(event.target), true);
|
|
76
|
+
const stepHistory = (event)=>{
|
|
77
|
+
const { target } = event;
|
|
78
|
+
if (!history || event.defaultPrevented || (0, external_gridEvents_cjs_namespaceObject.isComposing)(event) || (0, external_gridEvents_cjs_namespaceObject.isFromTextField)(target)) return false;
|
|
79
|
+
const dialog = target instanceof Element ? target.closest('dialog') : null;
|
|
80
|
+
if (dialog !== event.currentTarget.closest('dialog')) return false;
|
|
81
|
+
const step = (0, external_gridEvents_cjs_namespaceObject.isRedoKey)(event) ? history.onRedo : (0, external_gridEvents_cjs_namespaceObject.isUndoKey)(event) ? history.onUndo : null;
|
|
82
|
+
if (!step) return false;
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
step();
|
|
85
|
+
return true;
|
|
86
|
+
};
|
|
76
87
|
const onKeyDown = (event)=>{
|
|
77
88
|
if (stopTabbable && isTabOnView(event)) {
|
|
78
89
|
event.preventDefault();
|
|
79
90
|
navigation.refocus();
|
|
80
|
-
} else if (openStopDecision(event) || valueEditing.onKeyDown(event) || navigation.onKeyDown(event)) return;
|
|
91
|
+
} else if (openStopDecision(event) || valueEditing.onKeyDown(event) || navigation.onKeyDown(event) || stepHistory(event)) return;
|
|
81
92
|
consumerKeyDown?.(event);
|
|
82
93
|
};
|
|
83
94
|
const onFocus = (event)=>{
|
|
@@ -5,6 +5,10 @@ import type { RuleWindow } from './useRuleWindow';
|
|
|
5
5
|
import { type SentenceNavigation } from './useSentenceNavigation';
|
|
6
6
|
import type { ValueEditing } from './useValueEditing';
|
|
7
7
|
export type DecisionTextContainerProps = Omit<React.HTMLAttributes<HTMLElement>, 'aria-label' | 'tabIndex'> & Record<`data-${string}`, string | undefined>;
|
|
8
|
+
export interface TextHistory {
|
|
9
|
+
onUndo: () => void;
|
|
10
|
+
onRedo: () => void;
|
|
11
|
+
}
|
|
8
12
|
export interface ContainerHandlersParams {
|
|
9
13
|
containerProps: DecisionTextContainerProps | undefined;
|
|
10
14
|
hoverTo: ReturnType<typeof useCellHover>;
|
|
@@ -15,8 +19,9 @@ export interface ContainerHandlersParams {
|
|
|
15
19
|
container: RuleWindow['container'];
|
|
16
20
|
stopTabbable: boolean;
|
|
17
21
|
focusRow: (rowId: string | undefined) => void;
|
|
22
|
+
history: TextHistory | null;
|
|
18
23
|
}
|
|
19
|
-
export declare const useContainerHandlers: ({ containerProps, hoverTo, navigation, valueEditing, ruleMenus, onOpenDecision, container, stopTabbable, focusRow, }: ContainerHandlersParams) => {
|
|
24
|
+
export declare const useContainerHandlers: ({ containerProps, hoverTo, navigation, valueEditing, ruleMenus, onOpenDecision, container, stopTabbable, focusRow, history, }: ContainerHandlersParams) => {
|
|
20
25
|
tabIndex: number;
|
|
21
26
|
onPointerOver: (event: React.PointerEvent<HTMLElement>) => void;
|
|
22
27
|
onPointerDown: (event: React.PointerEvent<HTMLElement>) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContainerHandlers.d.ts","sourceRoot":"","sources":["../../src/decision-table/useContainerHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useContainerHandlers.d.ts","sourceRoot":"","sources":["../../src/decision-table/useContainerHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAiB/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC3C,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,EACjC,YAAY,GAAG,UAAU,CAC1B,GACC,MAAM,CAAC,QAAQ,MAAM,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAG/C,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,uBAAuB;IACtC,cAAc,EAAE,0BAA0B,GAAG,SAAS,CAAC;IACvD,OAAO,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IACzC,UAAU,EAAE,kBAAkB,CAAC;IAC/B,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,SAAS,CAAC;IAErB,cAAc,EAAE,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC3E,SAAS,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IAEnC,YAAY,EAAE,OAAO,CAAC;IAEtB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAE9C,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;CAC7B;AAOD,eAAO,MAAM,oBAAoB,GAAI,+HAWlC,uBAAuB;;2BA6BM,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC;2BAI/B,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC;6BAM7B,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC;0BAIlC,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC;uBAmClC,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC;qBAclC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC;oBAQ9B,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC;qBAY5B,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwBtD,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
import { hasLostFocus, onNextGesture } from "./gridEvents.js";
|
|
2
|
+
import { hasLostFocus, isComposing, isFromTextField, isRedoKey, isUndoKey, onNextGesture } from "./gridEvents.js";
|
|
3
3
|
import { clickedDecision, clickedSelection, rowIdOf, stopDecisionOf, valueTokenAt } from "./sentenceTargets.js";
|
|
4
4
|
import { isIgnoredKey } from "./useSentenceNavigation.js";
|
|
5
5
|
const isTabOnView = (event)=>'Tab' === event.key && !event.shiftKey && event.target === event.currentTarget;
|
|
6
|
-
const useContainerHandlers = ({ containerProps, hoverTo, navigation, valueEditing, ruleMenus, onOpenDecision, container, stopTabbable, focusRow })=>{
|
|
6
|
+
const useContainerHandlers = ({ containerProps, hoverTo, navigation, valueEditing, ruleMenus, onOpenDecision, container, stopTabbable, focusRow, history })=>{
|
|
7
7
|
const focusWithinRef = useRef(false);
|
|
8
8
|
const pressedRef = useRef(false);
|
|
9
9
|
const stopPressRef = useRef(null);
|
|
@@ -45,11 +45,22 @@ const useContainerHandlers = ({ containerProps, hoverTo, navigation, valueEditin
|
|
|
45
45
|
return true;
|
|
46
46
|
};
|
|
47
47
|
const openStopDecision = (event)=>'Enter' === event.key && event.altKey && !isIgnoredKey(event) && openDecision(event, stopDecisionOf(event.target), true);
|
|
48
|
+
const stepHistory = (event)=>{
|
|
49
|
+
const { target } = event;
|
|
50
|
+
if (!history || event.defaultPrevented || isComposing(event) || isFromTextField(target)) return false;
|
|
51
|
+
const dialog = target instanceof Element ? target.closest('dialog') : null;
|
|
52
|
+
if (dialog !== event.currentTarget.closest('dialog')) return false;
|
|
53
|
+
const step = isRedoKey(event) ? history.onRedo : isUndoKey(event) ? history.onUndo : null;
|
|
54
|
+
if (!step) return false;
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
step();
|
|
57
|
+
return true;
|
|
58
|
+
};
|
|
48
59
|
const onKeyDown = (event)=>{
|
|
49
60
|
if (stopTabbable && isTabOnView(event)) {
|
|
50
61
|
event.preventDefault();
|
|
51
62
|
navigation.refocus();
|
|
52
|
-
} else if (openStopDecision(event) || valueEditing.onKeyDown(event) || navigation.onKeyDown(event)) return;
|
|
63
|
+
} else if (openStopDecision(event) || valueEditing.onKeyDown(event) || navigation.onKeyDown(event) || stepHistory(event)) return;
|
|
53
64
|
consumerKeyDown?.(event);
|
|
54
65
|
};
|
|
55
66
|
const onFocus = (event)=>{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/apollo-react",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.36.0",
|
|
4
4
|
"description": "Apollo Design System - React component library with Material UI theming",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -254,7 +254,7 @@
|
|
|
254
254
|
"@uipath/apollo-core": "5.15.3",
|
|
255
255
|
"@uipath/apollo-ui-icons": "1.2.1",
|
|
256
256
|
"@uipath/apollo-ui-icons-react": "1.1.0",
|
|
257
|
-
"@uipath/apollo-wind": "2.95.
|
|
257
|
+
"@uipath/apollo-wind": "2.95.1"
|
|
258
258
|
},
|
|
259
259
|
"devDependencies": {
|
|
260
260
|
"@lingui/cli": "^5.6.1",
|
|
@@ -1,435 +0,0 @@
|
|
|
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
|
-
DecisionGraphView: ()=>DecisionGraphView
|
|
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_react_namespaceObject = require("react");
|
|
33
|
-
const external_DecisionGraphCard_cjs_namespaceObject = require("./DecisionGraphCard.cjs");
|
|
34
|
-
const external_DecisionGraphMinimapSlot_cjs_namespaceObject = require("./DecisionGraphMinimapSlot.cjs");
|
|
35
|
-
const external_decisionGraphPositions_cjs_namespaceObject = require("./decisionGraphPositions.cjs");
|
|
36
|
-
const external_decisionGraphStyles_cjs_namespaceObject = require("./decisionGraphStyles.cjs");
|
|
37
|
-
const external_revealIn_cjs_namespaceObject = require("./revealIn.cjs");
|
|
38
|
-
const external_sentenceRuleHeights_cjs_namespaceObject = require("./sentenceRuleHeights.cjs");
|
|
39
|
-
const external_useDecisionGraphActions_cjs_namespaceObject = require("./useDecisionGraphActions.cjs");
|
|
40
|
-
const external_useDecisionGraphStrings_cjs_namespaceObject = require("./useDecisionGraphStrings.cjs");
|
|
41
|
-
const external_useDecisionTextStrings_cjs_namespaceObject = require("./useDecisionTextStrings.cjs");
|
|
42
|
-
const external_useTextAnnouncements_cjs_namespaceObject = require("./useTextAnnouncements.cjs");
|
|
43
|
-
const NO_EXPANDED = new Set();
|
|
44
|
-
const markTargetOf = ({ id, mark })=>mark?.kind === 'rule' ? {
|
|
45
|
-
kind: 'rule',
|
|
46
|
-
decisionId: id,
|
|
47
|
-
rowId: mark.rowId
|
|
48
|
-
} : {
|
|
49
|
-
kind: 'decision',
|
|
50
|
-
decisionId: id
|
|
51
|
-
};
|
|
52
|
-
const focuses = (mode)=>'navigate' === mode.kind && mode.focus;
|
|
53
|
-
const flashes = (mode)=>'inPlace' === mode.kind || mode.flash;
|
|
54
|
-
const prefersReducedMotion = ()=>'function' == typeof matchMedia && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
55
|
-
const flash = (element)=>{
|
|
56
|
-
if (prefersReducedMotion()) return;
|
|
57
|
-
element.animate?.([
|
|
58
|
-
{
|
|
59
|
-
boxShadow: '0 0 0 4px color-mix(in srgb, var(--color-primary) 40%, transparent)'
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
boxShadow: '0 0 0 0 transparent'
|
|
63
|
-
}
|
|
64
|
-
], {
|
|
65
|
-
duration: 1400,
|
|
66
|
-
easing: 'ease-out'
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
const NEAR_MARGIN = '100% 0px';
|
|
70
|
-
const nearAfter = (current, entries)=>{
|
|
71
|
-
let next;
|
|
72
|
-
for (const { target, isIntersecting } of entries){
|
|
73
|
-
const decisionId = target instanceof HTMLElement ? target.dataset.decisionId : void 0;
|
|
74
|
-
if (void 0 !== decisionId && (next ?? current).has(decisionId) !== isIntersecting) {
|
|
75
|
-
next ??= new Set(current);
|
|
76
|
-
if (isIntersecting) next.add(decisionId);
|
|
77
|
-
else next.delete(decisionId);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return next ?? current;
|
|
81
|
-
};
|
|
82
|
-
const bodyHeightOf = (card)=>{
|
|
83
|
-
const body = card.querySelector(':scope > [data-graph-body]');
|
|
84
|
-
if (!body || body.querySelector(':scope > [data-graph-placeholder]')) return null;
|
|
85
|
-
return body.offsetHeight || null;
|
|
86
|
-
};
|
|
87
|
-
const ruleCountsOf = (nodes)=>{
|
|
88
|
-
const counts = new Map();
|
|
89
|
-
const visit = (node)=>{
|
|
90
|
-
if ('decision' !== node.kind) return;
|
|
91
|
-
if ('table' === node.logic.kind) counts.set(node.id, node.logic.ruleCount);
|
|
92
|
-
for (const child of node.children)visit(child);
|
|
93
|
-
};
|
|
94
|
-
for (const node of nodes)visit(node);
|
|
95
|
-
return counts;
|
|
96
|
-
};
|
|
97
|
-
const perRuleHeightOf = (heights, ruleCounts)=>{
|
|
98
|
-
let height = 0;
|
|
99
|
-
let rules = 0;
|
|
100
|
-
for (const [decisionId, measured] of heights){
|
|
101
|
-
const count = ruleCounts.get(decisionId) ?? 0;
|
|
102
|
-
if (0 !== count) {
|
|
103
|
-
height += measured;
|
|
104
|
-
rules += count;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return 0 === rules ? external_sentenceRuleHeights_cjs_namespaceObject.SENTENCE_MIN_RULE_HEIGHT_PX : height / rules;
|
|
108
|
-
};
|
|
109
|
-
const DecisionGraphView = ({ nodes, mode, renderBody, expansion, onFold, selected = null, onReveal, onOpenDecision, rules, dataTestId })=>{
|
|
110
|
-
const labels = (0, external_useDecisionGraphStrings_cjs_namespaceObject.useDecisionGraphLabels)();
|
|
111
|
-
const { announce, region } = (0, external_useTextAnnouncements_cjs_namespaceObject.useTextAnnouncements)((0, external_useDecisionTextStrings_cjs_namespaceObject.useDecisionTextLabels)(), dataTestId);
|
|
112
|
-
const idPrefix = (0, external_react_namespaceObject.useId)();
|
|
113
|
-
const [ownExpanded, setOwnExpanded] = (0, external_react_namespaceObject.useState)(NO_EXPANDED);
|
|
114
|
-
const expanded = expansion?.expanded ?? ownExpanded;
|
|
115
|
-
const users = (0, external_react_namespaceObject.useMemo)(()=>(0, external_decisionGraphPositions_cjs_namespaceObject.usersOf)(nodes), [
|
|
116
|
-
nodes
|
|
117
|
-
]);
|
|
118
|
-
const drawn = (0, external_react_namespaceObject.useMemo)(()=>new Set((0, external_decisionGraphPositions_cjs_namespaceObject.decisionsOf)(nodes).map(({ id })=>id)), [
|
|
119
|
-
nodes
|
|
120
|
-
]);
|
|
121
|
-
const [scroller, setScroller] = (0, external_react_namespaceObject.useState)(null);
|
|
122
|
-
const [launcherEnd, setLauncherEnd] = (0, external_react_namespaceObject.useState)(0);
|
|
123
|
-
const cardsRef = (0, external_react_namespaceObject.useRef)(new Map());
|
|
124
|
-
const [pending, setPending] = (0, external_react_namespaceObject.useState)(null);
|
|
125
|
-
const [near, setNear] = (0, external_react_namespaceObject.useState)(()=>"u" < typeof IntersectionObserver ? null : NO_EXPANDED);
|
|
126
|
-
const [revealed, setRevealed] = (0, external_react_namespaceObject.useState)(null);
|
|
127
|
-
const [focused, setFocused] = (0, external_react_namespaceObject.useState)(null);
|
|
128
|
-
const heightsRef = (0, external_react_namespaceObject.useRef)(new Map());
|
|
129
|
-
const observersRef = (0, external_react_namespaceObject.useRef)(null);
|
|
130
|
-
const ruleCounts = (0, external_react_namespaceObject.useMemo)(()=>ruleCountsOf(nodes), [
|
|
131
|
-
nodes
|
|
132
|
-
]);
|
|
133
|
-
const setExpanded = (next)=>{
|
|
134
|
-
if (expansion) expansion.onChange(next);
|
|
135
|
-
else setOwnExpanded(next);
|
|
136
|
-
};
|
|
137
|
-
const toggle = (decisionId)=>{
|
|
138
|
-
const next = new Set(expanded);
|
|
139
|
-
const folds = next.delete(decisionId);
|
|
140
|
-
if (!folds) next.add(decisionId);
|
|
141
|
-
setExpanded(next);
|
|
142
|
-
if (folds) onFold?.(decisionId);
|
|
143
|
-
};
|
|
144
|
-
const reveal = (target)=>{
|
|
145
|
-
if (!expanded.has(target.decisionId)) setExpanded(new Set([
|
|
146
|
-
...expanded,
|
|
147
|
-
target.decisionId
|
|
148
|
-
]));
|
|
149
|
-
setPending(target);
|
|
150
|
-
setRevealed(target.decisionId);
|
|
151
|
-
if ('navigate' === target.mode.kind) onReveal?.('rule' === target.kind ? {
|
|
152
|
-
kind: 'rule',
|
|
153
|
-
decisionId: target.decisionId,
|
|
154
|
-
rowId: target.rowId
|
|
155
|
-
} : {
|
|
156
|
-
kind: 'decision',
|
|
157
|
-
decisionId: target.decisionId
|
|
158
|
-
});
|
|
159
|
-
};
|
|
160
|
-
const bodyContext = {
|
|
161
|
-
revealDecision: (decisionId, byKey)=>{
|
|
162
|
-
if (!drawn.has(decisionId)) return void onOpenDecision?.(decisionId);
|
|
163
|
-
reveal({
|
|
164
|
-
kind: 'decision',
|
|
165
|
-
decisionId,
|
|
166
|
-
mode: {
|
|
167
|
-
kind: 'navigate',
|
|
168
|
-
focus: byKey,
|
|
169
|
-
flash: true
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
const openOf = (decisionId)=>onOpenDecision && (()=>onOpenDecision(decisionId));
|
|
175
|
-
const actions = (0, external_useDecisionGraphActions_cjs_namespaceObject.useDecisionGraphActions)({
|
|
176
|
-
mode,
|
|
177
|
-
nodes,
|
|
178
|
-
labels,
|
|
179
|
-
openOf,
|
|
180
|
-
cardOf: (decisionId)=>cardsRef.current.get(decisionId),
|
|
181
|
-
scroller,
|
|
182
|
-
announce,
|
|
183
|
-
dataTestId
|
|
184
|
-
});
|
|
185
|
-
const cardRefsRef = (0, external_react_namespaceObject.useRef)(new Map());
|
|
186
|
-
const cardRef = (0, external_react_namespaceObject.useCallback)((decisionId)=>{
|
|
187
|
-
const cached = cardRefsRef.current.get(decisionId);
|
|
188
|
-
if (cached) return cached;
|
|
189
|
-
const attach = (element)=>{
|
|
190
|
-
const observers = observersRef.current;
|
|
191
|
-
const previous = cardsRef.current.get(decisionId);
|
|
192
|
-
if (previous && previous !== element) {
|
|
193
|
-
observers?.near.unobserve(previous);
|
|
194
|
-
observers?.size?.unobserve(previous);
|
|
195
|
-
}
|
|
196
|
-
if (!element) return void cardsRef.current.delete(decisionId);
|
|
197
|
-
cardsRef.current.set(decisionId, element);
|
|
198
|
-
observers?.near.observe(element);
|
|
199
|
-
observers?.size?.observe(element);
|
|
200
|
-
};
|
|
201
|
-
cardRefsRef.current.set(decisionId, attach);
|
|
202
|
-
return attach;
|
|
203
|
-
}, []);
|
|
204
|
-
(0, external_react_namespaceObject.useLayoutEffect)(()=>{
|
|
205
|
-
if (!scroller || "u" < typeof IntersectionObserver) return;
|
|
206
|
-
const remember = (card)=>{
|
|
207
|
-
if (!(card instanceof HTMLElement)) return;
|
|
208
|
-
const decisionId = card.dataset.decisionId;
|
|
209
|
-
const height = bodyHeightOf(card);
|
|
210
|
-
if (void 0 !== decisionId && null !== height) heightsRef.current.set(decisionId, height);
|
|
211
|
-
};
|
|
212
|
-
const nearObserver = new IntersectionObserver((entries)=>{
|
|
213
|
-
for (const { target } of entries)remember(target);
|
|
214
|
-
setNear((current)=>nearAfter(current ?? NO_EXPANDED, entries));
|
|
215
|
-
}, {
|
|
216
|
-
root: scroller,
|
|
217
|
-
rootMargin: NEAR_MARGIN
|
|
218
|
-
});
|
|
219
|
-
const sizeObserver = "u" < typeof ResizeObserver ? null : new ResizeObserver((entries)=>{
|
|
220
|
-
for (const { target } of entries)remember(target);
|
|
221
|
-
});
|
|
222
|
-
observersRef.current = {
|
|
223
|
-
near: nearObserver,
|
|
224
|
-
size: sizeObserver
|
|
225
|
-
};
|
|
226
|
-
for (const card of cardsRef.current.values()){
|
|
227
|
-
nearObserver.observe(card);
|
|
228
|
-
sizeObserver?.observe(card);
|
|
229
|
-
}
|
|
230
|
-
return ()=>{
|
|
231
|
-
nearObserver.disconnect();
|
|
232
|
-
sizeObserver?.disconnect();
|
|
233
|
-
observersRef.current = null;
|
|
234
|
-
};
|
|
235
|
-
}, [
|
|
236
|
-
scroller
|
|
237
|
-
]);
|
|
238
|
-
const perRuleHeight = perRuleHeightOf(heightsRef.current, ruleCounts);
|
|
239
|
-
const bodyOf = (decisionId, scrollContainer)=>{
|
|
240
|
-
const mounted = null === near || near.has(decisionId) || decisionId === selected || decisionId === revealed || decisionId === focused;
|
|
241
|
-
if (mounted) return renderBody(decisionId, {
|
|
242
|
-
container: scrollContainer
|
|
243
|
-
}, bodyContext);
|
|
244
|
-
const height = heightsRef.current.get(decisionId) ?? Math.max(1, ruleCounts.get(decisionId) ?? 1) * perRuleHeight;
|
|
245
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
246
|
-
"aria-hidden": true,
|
|
247
|
-
"data-graph-placeholder": true,
|
|
248
|
-
style: {
|
|
249
|
-
height
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
};
|
|
253
|
-
const onFocus = (event)=>{
|
|
254
|
-
const card = event.target instanceof Element ? event.target.closest('[data-graph-card]') : null;
|
|
255
|
-
const decisionId = card instanceof HTMLElement ? card.dataset.decisionId : void 0;
|
|
256
|
-
if (void 0 !== decisionId) setFocused(decisionId);
|
|
257
|
-
};
|
|
258
|
-
(0, external_react_namespaceObject.useLayoutEffect)(()=>{
|
|
259
|
-
if (!pending) return;
|
|
260
|
-
const apply = ()=>{
|
|
261
|
-
const card = cardsRef.current.get(pending.decisionId);
|
|
262
|
-
if (!scroller || !card) return false;
|
|
263
|
-
if ('decision' === pending.kind) {
|
|
264
|
-
const heading = card.querySelector('[data-graph-toggle]');
|
|
265
|
-
if ('navigate' === pending.mode.kind) (0, external_revealIn_cjs_namespaceObject.revealIn)(scroller, {
|
|
266
|
-
vertical: card,
|
|
267
|
-
horizontal: heading ?? card,
|
|
268
|
-
block: 'start'
|
|
269
|
-
});
|
|
270
|
-
if (focuses(pending.mode)) heading?.focus({
|
|
271
|
-
preventScroll: true
|
|
272
|
-
});
|
|
273
|
-
if (flashes(pending.mode)) flash(card);
|
|
274
|
-
return true;
|
|
275
|
-
}
|
|
276
|
-
const rule = card.querySelector(`li[data-row-id="${CSS.escape(pending.rowId)}"]`);
|
|
277
|
-
if (!rule) return false;
|
|
278
|
-
if ('navigate' === pending.mode.kind) (0, external_revealIn_cjs_namespaceObject.revealIn)(scroller, {
|
|
279
|
-
vertical: rule,
|
|
280
|
-
horizontal: rule,
|
|
281
|
-
block: 'center'
|
|
282
|
-
});
|
|
283
|
-
if (focuses(pending.mode)) {
|
|
284
|
-
if (!rule.hasAttribute('tabindex')) rule.tabIndex = -1;
|
|
285
|
-
rule.focus({
|
|
286
|
-
preventScroll: true
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
if (flashes(pending.mode)) flash(rule);
|
|
290
|
-
return true;
|
|
291
|
-
};
|
|
292
|
-
if (apply()) return void setPending(null);
|
|
293
|
-
const frame = requestAnimationFrame(()=>{
|
|
294
|
-
const card = cardsRef.current.get(pending.decisionId);
|
|
295
|
-
if (!apply() && flashes(pending.mode) && card) flash(card);
|
|
296
|
-
setPending(null);
|
|
297
|
-
});
|
|
298
|
-
return ()=>cancelAnimationFrame(frame);
|
|
299
|
-
});
|
|
300
|
-
const branch = (node, depth, position)=>{
|
|
301
|
-
if ('reference' === node.kind) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_DecisionGraphCard_cjs_namespaceObject.DecisionGraphReference, {
|
|
302
|
-
node: node,
|
|
303
|
-
labels: labels,
|
|
304
|
-
actions: actions.referenceOf(node, position),
|
|
305
|
-
onReveal: ()=>reveal({
|
|
306
|
-
kind: 'decision',
|
|
307
|
-
decisionId: node.targetId,
|
|
308
|
-
mode: {
|
|
309
|
-
kind: 'navigate',
|
|
310
|
-
focus: false,
|
|
311
|
-
flash: false
|
|
312
|
-
}
|
|
313
|
-
}),
|
|
314
|
-
onOpen: openOf(node.targetId),
|
|
315
|
-
dataTestId: dataTestId
|
|
316
|
-
});
|
|
317
|
-
const open = expanded.has(node.id);
|
|
318
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
319
|
-
children: [
|
|
320
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_DecisionGraphCard_cjs_namespaceObject.DecisionGraphCard, {
|
|
321
|
-
node: node,
|
|
322
|
-
depth: depth,
|
|
323
|
-
open: open,
|
|
324
|
-
active: selected === node.id,
|
|
325
|
-
usedBy: (users.get(node.id) ?? []).map((user)=>user.label),
|
|
326
|
-
bodyId: `${idPrefix}-${encodeURIComponent(node.id)}`,
|
|
327
|
-
body: open && scroller ? bodyOf(node.id, scroller) : null,
|
|
328
|
-
labels: labels,
|
|
329
|
-
onToggle: ()=>toggle(node.id),
|
|
330
|
-
onShowProblem: (byKey)=>reveal({
|
|
331
|
-
...markTargetOf(node),
|
|
332
|
-
mode: byKey ? {
|
|
333
|
-
kind: 'navigate',
|
|
334
|
-
focus: true,
|
|
335
|
-
flash: true
|
|
336
|
-
} : {
|
|
337
|
-
kind: 'inPlace'
|
|
338
|
-
}
|
|
339
|
-
}),
|
|
340
|
-
onOpen: openOf(node.id),
|
|
341
|
-
actions: actions.cardOf(node, position),
|
|
342
|
-
cardRef: cardRef(node.id),
|
|
343
|
-
dataTestId: dataTestId
|
|
344
|
-
}),
|
|
345
|
-
node.children.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
346
|
-
className: external_decisionGraphStyles_cjs_namespaceObject.GRAPH_NEST_CLASS,
|
|
347
|
-
"data-graph-nest-of": node.id,
|
|
348
|
-
children: (0, external_decisionGraphPositions_cjs_namespaceObject.childPositionsOf)(node, position).map((childPosition)=>{
|
|
349
|
-
const child = node.children[childPosition.index];
|
|
350
|
-
return child && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
351
|
-
className: external_decisionGraphStyles_cjs_namespaceObject.GRAPH_BRANCH_CLASS,
|
|
352
|
-
children: branch(child, depth + 1, childPosition)
|
|
353
|
-
}, child.id);
|
|
354
|
-
})
|
|
355
|
-
})
|
|
356
|
-
]
|
|
357
|
-
});
|
|
358
|
-
};
|
|
359
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
360
|
-
className: (0, apollo_wind_namespaceObject.cn)(external_decisionGraphStyles_cjs_namespaceObject.GRAPH_FRAME_CLASS, external_decisionGraphStyles_cjs_namespaceObject.GRAPH_OUTPUT_HUE_CLASS),
|
|
361
|
-
"data-testid": dataTestId,
|
|
362
|
-
...actions.focusWithin,
|
|
363
|
-
children: [
|
|
364
|
-
nodes.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_DecisionGraphMinimapSlot_cjs_namespaceObject.DecisionGraphMinimapSlot, {
|
|
365
|
-
nodes: nodes,
|
|
366
|
-
rules: rules,
|
|
367
|
-
selected: selected,
|
|
368
|
-
onPick: (target)=>reveal({
|
|
369
|
-
...target,
|
|
370
|
-
mode: {
|
|
371
|
-
kind: 'navigate',
|
|
372
|
-
focus: true,
|
|
373
|
-
flash: true
|
|
374
|
-
}
|
|
375
|
-
}),
|
|
376
|
-
onLauncherEnd: setLauncherEnd,
|
|
377
|
-
labels: labels,
|
|
378
|
-
dataTestId: `${dataTestId}-minimap`
|
|
379
|
-
}),
|
|
380
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("section", {
|
|
381
|
-
ref: setScroller,
|
|
382
|
-
"aria-label": labels.graph,
|
|
383
|
-
className: external_decisionGraphStyles_cjs_namespaceObject.GRAPH_SCROLLER_CLASS,
|
|
384
|
-
style: {
|
|
385
|
-
scrollPaddingInlineStart: launcherEnd + external_decisionGraphStyles_cjs_namespaceObject.GRAPH_MINIMAP_GAP_PX
|
|
386
|
-
},
|
|
387
|
-
"data-testid": `${dataTestId}-scroller`,
|
|
388
|
-
children: [
|
|
389
|
-
0 === nodes.length && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
|
|
390
|
-
className: external_decisionGraphStyles_cjs_namespaceObject.GRAPH_EMPTY_CLASS,
|
|
391
|
-
"data-testid": `${dataTestId}-empty`,
|
|
392
|
-
children: labels.empty
|
|
393
|
-
}),
|
|
394
|
-
(nodes.length > 0 || actions.addTop) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
395
|
-
className: external_decisionGraphStyles_cjs_namespaceObject.GRAPH_COLUMN_CLASS,
|
|
396
|
-
style: {
|
|
397
|
-
paddingLeft: (0, external_decisionGraphStyles_cjs_namespaceObject.graphColumnInsetOf)(launcherEnd)
|
|
398
|
-
},
|
|
399
|
-
onFocus: onFocus,
|
|
400
|
-
children: [
|
|
401
|
-
(0, external_decisionGraphPositions_cjs_namespaceObject.topPositionsOf)(nodes).map((position)=>{
|
|
402
|
-
const node = nodes[position.index];
|
|
403
|
-
return node && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
404
|
-
children: branch(node, 0, position)
|
|
405
|
-
}, node.id);
|
|
406
|
-
}),
|
|
407
|
-
actions.addTop && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("button", {
|
|
408
|
-
type: "button",
|
|
409
|
-
className: external_decisionGraphStyles_cjs_namespaceObject.GRAPH_ADD_DECISION_CLASS,
|
|
410
|
-
onClick: actions.addTop,
|
|
411
|
-
"data-graph-add": true,
|
|
412
|
-
"data-testid": `${dataTestId}-add-decision`,
|
|
413
|
-
children: [
|
|
414
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Plus, {
|
|
415
|
-
"aria-hidden": true
|
|
416
|
-
}),
|
|
417
|
-
labels.addDecision
|
|
418
|
-
]
|
|
419
|
-
})
|
|
420
|
-
]
|
|
421
|
-
})
|
|
422
|
-
]
|
|
423
|
-
}),
|
|
424
|
-
actions.dialogs,
|
|
425
|
-
region
|
|
426
|
-
]
|
|
427
|
-
});
|
|
428
|
-
};
|
|
429
|
-
exports.DecisionGraphView = __webpack_exports__.DecisionGraphView;
|
|
430
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
431
|
-
"DecisionGraphView"
|
|
432
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
433
|
-
Object.defineProperty(exports, '__esModule', {
|
|
434
|
-
value: true
|
|
435
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
import { type DecisionGraphMinimapSlotProps } from './DecisionGraphMinimapSlot';
|
|
3
|
-
import type { DecisionGraphMode } from './decisionGraphActionTypes';
|
|
4
|
-
import type { DecisionGraphBodyContext, DecisionGraphExpansion, DecisionGraphNode, DecisionGraphTarget } from './decisionGraphTypes';
|
|
5
|
-
import type { DecisionTextScroll } from './useRuleWindow';
|
|
6
|
-
export interface DecisionGraphViewProps<Refusal, Logic> {
|
|
7
|
-
nodes: readonly DecisionGraphNode[];
|
|
8
|
-
mode: DecisionGraphMode<Refusal, Logic>;
|
|
9
|
-
renderBody: (decisionId: string, scroll: Exclude<DecisionTextScroll, 'self'>, context: DecisionGraphBodyContext) => React.ReactNode;
|
|
10
|
-
onFold?: (decisionId: string) => void;
|
|
11
|
-
expansion?: DecisionGraphExpansion;
|
|
12
|
-
selected?: string | null;
|
|
13
|
-
onReveal?: (target: DecisionGraphTarget) => void;
|
|
14
|
-
onOpenDecision?: (decisionId: string) => void;
|
|
15
|
-
rules?: DecisionGraphMinimapSlotProps['rules'];
|
|
16
|
-
dataTestId: string;
|
|
17
|
-
}
|
|
18
|
-
export declare const DecisionGraphView: <Refusal, Logic>({ nodes, mode, renderBody, expansion, onFold, selected, onReveal, onOpenDecision, rules, dataTestId, }: DecisionGraphViewProps<Refusal, Logic>) => React.ReactElement;
|
|
19
|
-
//# sourceMappingURL=DecisionGraphView.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DecisionGraphView.d.ts","sourceRoot":"","sources":["../../src/decision-table/DecisionGraphView.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAoBpE,OAAO,KAAK,EACV,wBAAwB,EAExB,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAM9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAG1D,MAAM,WAAW,sBAAsB,CAAC,OAAO,EAAE,KAAK;IAEpD,KAAK,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAEpC,IAAI,EAAE,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAExC,UAAU,EAAE,CACV,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,OAAO,CAAC,kBAAkB,EAAE,MAAM,CAAC,EAC3C,OAAO,EAAE,wBAAwB,KAC9B,KAAK,CAAC,SAAS,CAAC;IAErB,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAEtC,SAAS,CAAC,EAAE,sBAAsB,CAAC;IAEnC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAEjD,cAAc,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAE9C,KAAK,CAAC,EAAE,6BAA6B,CAAC,OAAO,CAAC,CAAC;IAE/C,UAAU,EAAE,MAAM,CAAC;CACpB;AAsFD,eAAO,MAAM,iBAAiB,GAAI,OAAO,EAAE,KAAK,EAAE,wGAW/C,sBAAsB,CAAC,OAAO,EAAE,KAAK,CAAC,KAAG,KAAK,CAAC,YAyTjD,CAAC"}
|