@uipath/apollo-react 7.18.0 → 7.19.1
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/headless/hooks/use-chat-messages.cjs +8 -0
- package/dist/chat/headless/hooks/use-chat-messages.d.ts.map +1 -1
- package/dist/chat/headless/hooks/use-chat-messages.js +8 -0
- package/dist/chat/styles/tailwind.chat.css +1 -1
- package/dist/decision-table/CellTextEditor.cjs +78 -0
- package/dist/decision-table/CellTextEditor.d.ts +8 -0
- package/dist/decision-table/CellTextEditor.d.ts.map +1 -0
- package/dist/decision-table/CellTextEditor.js +44 -0
- package/dist/decision-table/ConditionLine.cjs +5 -1
- package/dist/decision-table/ConditionLine.d.ts +3 -1
- package/dist/decision-table/ConditionLine.d.ts.map +1 -1
- package/dist/decision-table/ConditionLine.js +5 -1
- package/dist/decision-table/DecisionText.cjs +49 -3
- package/dist/decision-table/DecisionText.d.ts +20 -4
- package/dist/decision-table/DecisionText.d.ts.map +1 -1
- package/dist/decision-table/DecisionText.js +49 -3
- package/dist/decision-table/DecisionTextHeader.cjs +23 -3
- package/dist/decision-table/DecisionTextHeader.d.ts +6 -0
- package/dist/decision-table/DecisionTextHeader.d.ts.map +1 -1
- package/dist/decision-table/DecisionTextHeader.js +24 -4
- package/dist/decision-table/GridCell.cjs +11 -31
- package/dist/decision-table/GridCell.d.ts +1 -9
- package/dist/decision-table/GridCell.d.ts.map +1 -1
- package/dist/decision-table/GridCell.js +12 -32
- package/dist/decision-table/LineText.cjs +4 -3
- package/dist/decision-table/LineText.d.ts +2 -1
- package/dist/decision-table/LineText.d.ts.map +1 -1
- package/dist/decision-table/LineText.js +4 -3
- package/dist/decision-table/PolicyOptionItem.cjs +121 -0
- package/dist/decision-table/PolicyOptionItem.d.ts +16 -0
- package/dist/decision-table/PolicyOptionItem.d.ts.map +1 -0
- package/dist/decision-table/PolicyOptionItem.js +84 -0
- package/dist/decision-table/PolicyPicker.cjs +110 -0
- package/dist/decision-table/PolicyPicker.d.ts +17 -0
- package/dist/decision-table/PolicyPicker.d.ts.map +1 -0
- package/dist/decision-table/PolicyPicker.js +76 -0
- package/dist/decision-table/RemoveConditionButton.cjs +52 -0
- package/dist/decision-table/RemoveConditionButton.d.ts +7 -0
- package/dist/decision-table/RemoveConditionButton.d.ts.map +1 -0
- package/dist/decision-table/RemoveConditionButton.js +18 -0
- package/dist/decision-table/RuleActions.cjs +76 -0
- package/dist/decision-table/RuleActions.d.ts +15 -0
- package/dist/decision-table/RuleActions.d.ts.map +1 -0
- package/dist/decision-table/RuleActions.js +42 -0
- package/dist/decision-table/RuleCard.cjs +17 -3
- package/dist/decision-table/RuleCard.d.ts +7 -1
- package/dist/decision-table/RuleCard.d.ts.map +1 -1
- package/dist/decision-table/RuleCard.js +18 -4
- package/dist/decision-table/RuleLine.cjs +7 -2
- package/dist/decision-table/RuleLine.d.ts +4 -1
- package/dist/decision-table/RuleLine.d.ts.map +1 -1
- package/dist/decision-table/RuleLine.js +7 -2
- package/dist/decision-table/RuleList.cjs +4 -1
- package/dist/decision-table/RuleList.d.ts +8 -0
- package/dist/decision-table/RuleList.d.ts.map +1 -1
- package/dist/decision-table/RuleList.js +4 -1
- package/dist/decision-table/TokenChip.cjs +23 -3
- package/dist/decision-table/TokenChip.d.ts +7 -0
- package/dist/decision-table/TokenChip.d.ts.map +1 -1
- package/dist/decision-table/TokenChip.js +24 -4
- package/dist/decision-table/ValueEditorOverlay.cjs +71 -0
- package/dist/decision-table/ValueEditorOverlay.d.ts +11 -0
- package/dist/decision-table/ValueEditorOverlay.d.ts.map +1 -0
- package/dist/decision-table/ValueEditorOverlay.js +37 -0
- package/dist/decision-table/__fixtures__/editableSentences.fixtures.d.ts +37 -0
- package/dist/decision-table/__fixtures__/editableSentences.fixtures.d.ts.map +1 -0
- package/dist/decision-table/__fixtures__/sentences.fixtures.d.ts +19 -6
- package/dist/decision-table/__fixtures__/sentences.fixtures.d.ts.map +1 -1
- package/dist/decision-table/decisionTextTypes.cjs +18 -0
- package/dist/decision-table/decisionTextTypes.d.ts +21 -0
- package/dist/decision-table/decisionTextTypes.d.ts.map +1 -0
- package/dist/decision-table/decisionTextTypes.js +0 -0
- package/dist/decision-table/gridEvents.cjs +22 -2
- package/dist/decision-table/gridEvents.d.ts +1 -0
- package/dist/decision-table/gridEvents.d.ts.map +1 -1
- package/dist/decision-table/gridEvents.js +18 -1
- package/dist/decision-table/gridTypes.d.ts +8 -0
- package/dist/decision-table/gridTypes.d.ts.map +1 -1
- package/dist/decision-table/index.d.ts +7 -2
- package/dist/decision-table/index.d.ts.map +1 -1
- package/dist/decision-table/ruleCardModel.cjs +37 -4
- package/dist/decision-table/ruleCardModel.d.ts +18 -4
- package/dist/decision-table/ruleCardModel.d.ts.map +1 -1
- package/dist/decision-table/ruleCardModel.js +36 -6
- package/dist/decision-table/sentenceParts.cjs +38 -5
- package/dist/decision-table/sentenceParts.d.ts +6 -1
- package/dist/decision-table/sentenceParts.d.ts.map +1 -1
- package/dist/decision-table/sentenceParts.js +19 -1
- package/dist/decision-table/sentenceStyles.cjs +77 -4
- package/dist/decision-table/sentenceStyles.d.ts +18 -0
- package/dist/decision-table/sentenceStyles.d.ts.map +1 -1
- package/dist/decision-table/sentenceStyles.js +20 -1
- package/dist/decision-table/sentenceTargets.cjs +88 -4
- package/dist/decision-table/sentenceTargets.d.ts +24 -1
- package/dist/decision-table/sentenceTargets.d.ts.map +1 -1
- package/dist/decision-table/sentenceTargets.js +68 -5
- package/dist/decision-table/sentenceTypes.d.ts +13 -2
- package/dist/decision-table/sentenceTypes.d.ts.map +1 -1
- package/dist/decision-table/styles/tailwind.decision-table.css +1 -1
- package/dist/decision-table/useContainerHandlers.cjs +42 -8
- package/dist/decision-table/useContainerHandlers.d.ts +10 -5
- package/dist/decision-table/useContainerHandlers.d.ts.map +1 -1
- package/dist/decision-table/useContainerHandlers.js +44 -10
- package/dist/decision-table/useEditorPlacement.cjs +104 -0
- package/dist/decision-table/useEditorPlacement.d.ts +17 -0
- package/dist/decision-table/useEditorPlacement.d.ts.map +1 -0
- package/dist/decision-table/useEditorPlacement.js +70 -0
- package/dist/decision-table/useRuleMenus.cjs +149 -0
- package/dist/decision-table/useRuleMenus.d.ts +24 -0
- package/dist/decision-table/useRuleMenus.d.ts.map +1 -0
- package/dist/decision-table/useRuleMenus.js +115 -0
- package/dist/decision-table/useRuleWindow.cjs +6 -2
- package/dist/decision-table/useRuleWindow.d.ts +1 -1
- package/dist/decision-table/useRuleWindow.d.ts.map +1 -1
- package/dist/decision-table/useRuleWindow.js +6 -2
- package/dist/decision-table/useSentenceNavigation.cjs +41 -9
- package/dist/decision-table/useSentenceNavigation.d.ts +7 -2
- package/dist/decision-table/useSentenceNavigation.d.ts.map +1 -1
- package/dist/decision-table/useSentenceNavigation.js +39 -10
- package/dist/decision-table/useValueEditing.cjs +306 -0
- package/dist/decision-table/useValueEditing.d.ts +34 -0
- package/dist/decision-table/useValueEditing.d.ts.map +1 -0
- package/dist/decision-table/useValueEditing.js +272 -0
- package/dist/decision-table/valueTypes.cjs +18 -0
- package/dist/decision-table/valueTypes.d.ts +6 -0
- package/dist/decision-table/valueTypes.d.ts.map +1 -0
- package/dist/decision-table/valueTypes.js +0 -0
- package/package.json +3 -3
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
2
|
+
import { clickedAction } from "./sentenceTargets.js";
|
|
3
|
+
const menuLabel = (edit, state, position)=>{
|
|
4
|
+
if (!edit || !state) return '';
|
|
5
|
+
return 'rule' === state.menu ? edit.labels.ruleActions(position) : edit.labels.addCondition(position);
|
|
6
|
+
};
|
|
7
|
+
const anchorOf = (trigger)=>{
|
|
8
|
+
const { left, bottom } = trigger.getBoundingClientRect();
|
|
9
|
+
return {
|
|
10
|
+
x: left,
|
|
11
|
+
y: bottom
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
const movedAnchor = ({ trigger, anchor })=>{
|
|
15
|
+
const moved = anchorOf(trigger);
|
|
16
|
+
return moved.x === anchor.x && moved.y === anchor.y ? null : moved;
|
|
17
|
+
};
|
|
18
|
+
const renderedParentOf = (node)=>{
|
|
19
|
+
if (node instanceof ShadowRoot) return node.host;
|
|
20
|
+
return (node instanceof Element ? node.assignedSlot : null) ?? node.parentNode;
|
|
21
|
+
};
|
|
22
|
+
const holds = (ancestor, node)=>{
|
|
23
|
+
for(let at = node; at; at = renderedParentOf(at))if (at === ancestor) return true;
|
|
24
|
+
return false;
|
|
25
|
+
};
|
|
26
|
+
const scrollRootsOf = (node)=>{
|
|
27
|
+
const roots = new Set();
|
|
28
|
+
for(let at = node; at; at = renderedParentOf(at))roots.add(at.getRootNode());
|
|
29
|
+
return [
|
|
30
|
+
...roots
|
|
31
|
+
];
|
|
32
|
+
};
|
|
33
|
+
const useRuleMenus = ({ edit, rules, selectedRowId, refocus })=>{
|
|
34
|
+
const [state, setState] = useState(null);
|
|
35
|
+
const restoreFocusRef = useRef(null);
|
|
36
|
+
const position = state ? rules.findIndex((rule)=>rule.rowId === state.rowId) + 1 : 0;
|
|
37
|
+
const open = edit && position > 0 ? state : null;
|
|
38
|
+
const close = (scroll)=>{
|
|
39
|
+
restoreFocusRef.current = state && {
|
|
40
|
+
...state,
|
|
41
|
+
scroll
|
|
42
|
+
};
|
|
43
|
+
setState(null);
|
|
44
|
+
};
|
|
45
|
+
useLayoutEffect(()=>{
|
|
46
|
+
if (state && (!open || !state.trigger.isConnected)) return void close(false);
|
|
47
|
+
const anchor = state && movedAnchor(state);
|
|
48
|
+
if (state && anchor) return void setState({
|
|
49
|
+
...state,
|
|
50
|
+
anchor
|
|
51
|
+
});
|
|
52
|
+
const restore = restoreFocusRef.current;
|
|
53
|
+
if (!restore || state) return;
|
|
54
|
+
restoreFocusRef.current = null;
|
|
55
|
+
if (restore.trigger.isConnected && restore.openedOnRowId === selectedRowId) restore.trigger.focus({
|
|
56
|
+
preventScroll: true
|
|
57
|
+
});
|
|
58
|
+
else refocus(restore.scroll);
|
|
59
|
+
});
|
|
60
|
+
useEffect(()=>{
|
|
61
|
+
if (!state) return;
|
|
62
|
+
const close = ()=>{
|
|
63
|
+
restoreFocusRef.current = {
|
|
64
|
+
...state,
|
|
65
|
+
scroll: false
|
|
66
|
+
};
|
|
67
|
+
setState(null);
|
|
68
|
+
};
|
|
69
|
+
const closeOnScroll = (event)=>{
|
|
70
|
+
if (event.target instanceof Node && holds(event.target, state.trigger)) close();
|
|
71
|
+
};
|
|
72
|
+
const roots = scrollRootsOf(state.trigger);
|
|
73
|
+
for (const root of roots)root.addEventListener('scroll', closeOnScroll, {
|
|
74
|
+
capture: true,
|
|
75
|
+
passive: true
|
|
76
|
+
});
|
|
77
|
+
window.addEventListener('resize', close);
|
|
78
|
+
return ()=>{
|
|
79
|
+
for (const root of roots)root.removeEventListener('scroll', closeOnScroll, {
|
|
80
|
+
capture: true
|
|
81
|
+
});
|
|
82
|
+
window.removeEventListener('resize', close);
|
|
83
|
+
};
|
|
84
|
+
}, [
|
|
85
|
+
state
|
|
86
|
+
]);
|
|
87
|
+
const entries = ()=>{
|
|
88
|
+
if (!edit || !open) return [];
|
|
89
|
+
return 'rule' === open.menu ? edit.ruleEntries(open.rowId) : edit.conditionEntries(open.rowId);
|
|
90
|
+
};
|
|
91
|
+
const onClose = ()=>close(true);
|
|
92
|
+
const openFor = (action)=>{
|
|
93
|
+
if (!edit || action?.action !== 'conditions' && action?.action !== 'rule') return false;
|
|
94
|
+
const entriesOf = 'rule' === action.action ? edit.ruleEntries : edit.conditionEntries;
|
|
95
|
+
if (0 === entriesOf(action.rowId).length) return false;
|
|
96
|
+
setState({
|
|
97
|
+
menu: action.action,
|
|
98
|
+
rowId: action.rowId,
|
|
99
|
+
trigger: action.trigger,
|
|
100
|
+
openedOnRowId: selectedRowId,
|
|
101
|
+
anchor: anchorOf(action.trigger)
|
|
102
|
+
});
|
|
103
|
+
return true;
|
|
104
|
+
};
|
|
105
|
+
const onClick = (event)=>openFor(clickedAction(event.target));
|
|
106
|
+
return {
|
|
107
|
+
state: open,
|
|
108
|
+
label: menuLabel(edit, open, position),
|
|
109
|
+
entries,
|
|
110
|
+
onClose,
|
|
111
|
+
onClick,
|
|
112
|
+
openFor
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
export { useRuleMenus };
|
|
@@ -50,7 +50,7 @@ const measuredHeights = (current, entries)=>{
|
|
|
50
50
|
}
|
|
51
51
|
return next ?? current;
|
|
52
52
|
};
|
|
53
|
-
const useRuleWindow = (rules, selectedRowId)=>{
|
|
53
|
+
const useRuleWindow = (rules, selectedRowId, retainedRowId)=>{
|
|
54
54
|
const listRef = (0, external_react_namespaceObject.useRef)(null);
|
|
55
55
|
const headerRef = (0, external_react_namespaceObject.useRef)(null);
|
|
56
56
|
const sectionRef = (0, external_react_namespaceObject.useRef)(null);
|
|
@@ -65,7 +65,11 @@ const useRuleWindow = (rules, selectedRowId)=>{
|
|
|
65
65
|
rules,
|
|
66
66
|
selectedRowId
|
|
67
67
|
]);
|
|
68
|
-
const
|
|
68
|
+
const retainedRow = (0, external_react_namespaceObject.useMemo)(()=>rowIndexOf(rules, retainedRowId), [
|
|
69
|
+
rules,
|
|
70
|
+
retainedRowId
|
|
71
|
+
]);
|
|
72
|
+
const { segments, measureRef, scrollItemIntoView } = (0, external_useVirtualizedAxis_cjs_namespaceObject.useVirtualizedAxis)(rules.length, external_sentenceRuleHeights_cjs_namespaceObject.SENTENCE_MIN_RULE_HEIGHT_PX, retainedRow, {
|
|
69
73
|
axis: 'vertical',
|
|
70
74
|
overscanItems: SENTENCE_RULE_OVERSCAN,
|
|
71
75
|
fallbackViewportPx: external_constants_cjs_namespaceObject.FALLBACK_ROW_VIEWPORT_PX,
|
|
@@ -13,5 +13,5 @@ export interface RuleWindow {
|
|
|
13
13
|
firstVisibleRow: () => number;
|
|
14
14
|
scrollStopIntoView: (rowIndex: number, stop: HTMLElement) => void;
|
|
15
15
|
}
|
|
16
|
-
export declare const useRuleWindow: (rules: readonly SentenceRule[], selectedRowId: string | undefined) => RuleWindow;
|
|
16
|
+
export declare const useRuleWindow: (rules: readonly SentenceRule[], selectedRowId: string | undefined, retainedRowId: string | undefined) => RuleWindow;
|
|
17
17
|
//# sourceMappingURL=useRuleWindow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRuleWindow.d.ts","sourceRoot":"","sources":["../../src/decision-table/useRuleWindow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,KAAK,WAAW,EAAsB,MAAM,sBAAsB,CAAC;AAE5E,eAAO,MAAM,sBAAsB,KAAK,CAAC;AA0BzC,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAClD,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAClD,QAAQ,EAAE,WAAW,EAAE,CAAC;IAExB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,aAAa,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IAErD,SAAS,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;IAEpC,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAE9C,eAAe,EAAE,MAAM,MAAM,CAAC;IAE9B,kBAAkB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;CACnE;AAGD,eAAO,MAAM,aAAa,GACxB,OAAO,SAAS,YAAY,EAAE,EAC9B,eAAe,MAAM,GAAG,SAAS,KAChC,
|
|
1
|
+
{"version":3,"file":"useRuleWindow.d.ts","sourceRoot":"","sources":["../../src/decision-table/useRuleWindow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,KAAK,WAAW,EAAsB,MAAM,sBAAsB,CAAC;AAE5E,eAAO,MAAM,sBAAsB,KAAK,CAAC;AA0BzC,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAClD,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAClD,QAAQ,EAAE,WAAW,EAAE,CAAC;IAExB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,aAAa,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IAErD,SAAS,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;IAEpC,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAE9C,eAAe,EAAE,MAAM,MAAM,CAAC;IAE9B,kBAAkB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;CACnE;AAGD,eAAO,MAAM,aAAa,GACxB,OAAO,SAAS,YAAY,EAAE,EAC9B,eAAe,MAAM,GAAG,SAAS,EACjC,eAAe,MAAM,GAAG,SAAS,KAChC,UAsFF,CAAC"}
|
|
@@ -21,7 +21,7 @@ const measuredHeights = (current, entries)=>{
|
|
|
21
21
|
}
|
|
22
22
|
return next ?? current;
|
|
23
23
|
};
|
|
24
|
-
const useRuleWindow = (rules, selectedRowId)=>{
|
|
24
|
+
const useRuleWindow = (rules, selectedRowId, retainedRowId)=>{
|
|
25
25
|
const listRef = useRef(null);
|
|
26
26
|
const headerRef = useRef(null);
|
|
27
27
|
const sectionRef = useRef(null);
|
|
@@ -36,7 +36,11 @@ const useRuleWindow = (rules, selectedRowId)=>{
|
|
|
36
36
|
rules,
|
|
37
37
|
selectedRowId
|
|
38
38
|
]);
|
|
39
|
-
const
|
|
39
|
+
const retainedRow = useMemo(()=>rowIndexOf(rules, retainedRowId), [
|
|
40
|
+
rules,
|
|
41
|
+
retainedRowId
|
|
42
|
+
]);
|
|
43
|
+
const { segments, measureRef, scrollItemIntoView } = useVirtualizedAxis(rules.length, SENTENCE_MIN_RULE_HEIGHT_PX, retainedRow, {
|
|
40
44
|
axis: 'vertical',
|
|
41
45
|
overscanItems: SENTENCE_RULE_OVERSCAN,
|
|
42
46
|
fallbackViewportPx: FALLBACK_ROW_VIEWPORT_PX,
|
|
@@ -24,6 +24,7 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
isIgnoredKey: ()=>isIgnoredKey,
|
|
27
28
|
useSentenceNavigation: ()=>useSentenceNavigation
|
|
28
29
|
});
|
|
29
30
|
const external_react_namespaceObject = require("react");
|
|
@@ -69,6 +70,20 @@ const edgeMove = (end, meta, from, rowCount, stopsAt)=>{
|
|
|
69
70
|
stop: end ? stopsAt(row).length - 1 : 0
|
|
70
71
|
};
|
|
71
72
|
};
|
|
73
|
+
const tabMove = (back, from, stops)=>{
|
|
74
|
+
const stop = from.stop + (back ? -1 : 1);
|
|
75
|
+
return stop < 0 || stop >= stops.length ? void 0 : {
|
|
76
|
+
row: from.row,
|
|
77
|
+
stop
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
const stopAfterCommit = (move, from, rules)=>{
|
|
81
|
+
const stopsAt = (row)=>stopsOf(rules[row]);
|
|
82
|
+
if ('none' === move) return;
|
|
83
|
+
if ('down' === move) return verticalMove(1, false, from, rules.length, stopsAt, stopsAt(from.row)[from.stop]);
|
|
84
|
+
const next = tabMove('left' === move, from, stopsAt(from.row));
|
|
85
|
+
return next && next.stop > 0 ? next : from;
|
|
86
|
+
};
|
|
72
87
|
const stopAfterKey = (event, from, rules, rtl, columnId)=>{
|
|
73
88
|
const meta = event.metaKey || event.ctrlKey;
|
|
74
89
|
const stopsAt = (row)=>stopsOf(rules[row]);
|
|
@@ -76,7 +91,7 @@ const stopAfterKey = (event, from, rules, rtl, columnId)=>{
|
|
|
76
91
|
if (delta) return 0 === delta.row ? horizontalMove(rtl ? -delta.col : delta.col, meta, from, stopsAt(from.row)) : verticalMove(delta.row, meta, from, rules.length, stopsAt, columnId);
|
|
77
92
|
if ('Home' === event.key || 'End' === event.key) return edgeMove('End' === event.key, meta, from, rules.length, stopsAt);
|
|
78
93
|
};
|
|
79
|
-
const isOnStop = (event)=>event.target === event.currentTarget || event.target instanceof
|
|
94
|
+
const isOnStop = (event)=>event.target === event.currentTarget || event.target instanceof HTMLElement && null !== event.target.closest('li[data-row-id]') && (null === event.target.closest('[data-rule-action]') || 'true' === event.target.dataset.selected);
|
|
80
95
|
const isIgnoredKey = (event)=>event.defaultPrevented || event.nativeEvent.isComposing || !isOnStop(event) || (0, external_gridEvents_cjs_namespaceObject.isFromTextField)(event.target);
|
|
81
96
|
const stopOf = (container, selection)=>{
|
|
82
97
|
const card = (0, external_sentenceTargets_cjs_namespaceObject.cardOf)(container, selection.rowId);
|
|
@@ -102,13 +117,14 @@ const useSentenceNavigation = ({ rules, selected, selectedRow, onSelect, contain
|
|
|
102
117
|
const current = position && (selectionAt(rules, position) ?? null);
|
|
103
118
|
const selectedRule = null === selectedRow ? void 0 : rules[selectedRow];
|
|
104
119
|
const selectedColumnId = current?.columnId ?? null;
|
|
105
|
-
const focusCurrent = (scroll = true)=>{
|
|
120
|
+
const focusCurrent = (focus, scroll = true)=>{
|
|
106
121
|
const element = container();
|
|
107
122
|
if (!element) return;
|
|
108
123
|
if (!current || !position) return void element.focus({
|
|
109
124
|
preventScroll: true
|
|
110
125
|
});
|
|
111
|
-
const
|
|
126
|
+
const card = focus && (0, external_sentenceTargets_cjs_namespaceObject.cardOf)(element, current.rowId);
|
|
127
|
+
const stop = card ? focus?.(card) : stopOf(element, current);
|
|
112
128
|
if (stop) {
|
|
113
129
|
stop.focus({
|
|
114
130
|
preventScroll: true
|
|
@@ -130,27 +146,28 @@ const useSentenceNavigation = ({ rules, selected, selectedRow, onSelect, contain
|
|
|
130
146
|
const stayed = (0, external_gridEvents_cjs_namespaceObject.focusStays)(container(), pending?.from);
|
|
131
147
|
const applied = void 0 !== pending && sameSelection(pending.selection, current);
|
|
132
148
|
if (!stayed || applied) pendingFocusRef.current = void 0;
|
|
133
|
-
if (void 0 !== pending && applied && stayed) focusCurrent(pending.scroll);
|
|
149
|
+
if (void 0 !== pending && applied && stayed) focusCurrent(pending.focus, pending.scroll);
|
|
134
150
|
else if (moved && null !== selectedRow) {
|
|
135
151
|
const stop = movedStopOf(container(), current);
|
|
136
152
|
if (stop) scrollStopIntoView(selectedRow, stop);
|
|
137
153
|
else scrollRowIntoView(selectedRow);
|
|
138
154
|
}
|
|
139
155
|
});
|
|
140
|
-
const request = (selection, scroll = true)=>{
|
|
156
|
+
const request = (selection, focus, scroll = true)=>{
|
|
141
157
|
if (!onSelect) return;
|
|
142
|
-
if (sameSelection(selection, selected ?? null)) return void focusCurrent(scroll);
|
|
158
|
+
if (sameSelection(selection, selected ?? null)) return void focusCurrent(focus, scroll);
|
|
143
159
|
const view = container();
|
|
144
160
|
pendingFocusRef.current = {
|
|
145
161
|
selection,
|
|
162
|
+
focus,
|
|
146
163
|
scroll,
|
|
147
164
|
from: view && (0, external_gridEvents_cjs_namespaceObject.activeElementOf)(view)
|
|
148
165
|
};
|
|
149
166
|
onSelect(selection);
|
|
150
167
|
};
|
|
151
|
-
const select = (selection, scroll = true)=>{
|
|
168
|
+
const select = (selection, focus, scroll = true)=>{
|
|
152
169
|
wantedRef.current = void 0;
|
|
153
|
-
request(selection, scroll);
|
|
170
|
+
request(selection, focus, scroll);
|
|
154
171
|
};
|
|
155
172
|
const keyTarget = (event)=>{
|
|
156
173
|
if ('Escape' === event.key) return position ? null : void 0;
|
|
@@ -176,15 +193,30 @@ const useSentenceNavigation = ({ rules, selected, selectedRow, onSelect, contain
|
|
|
176
193
|
request(target);
|
|
177
194
|
return true;
|
|
178
195
|
};
|
|
196
|
+
const selectAfter = (from, move, before)=>{
|
|
197
|
+
const committedOn = stopsOf(before.find((rule)=>rule.rowId === from.rowId)).includes(from.columnId) ? before : rules;
|
|
198
|
+
const row = committedOn.findIndex((rule)=>rule.rowId === from.rowId);
|
|
199
|
+
if (row < 0) return;
|
|
200
|
+
const stop = Math.max(0, stopsOf(committedOn[row]).indexOf(from.columnId));
|
|
201
|
+
const next = stopAfterCommit(move, {
|
|
202
|
+
row,
|
|
203
|
+
stop
|
|
204
|
+
}, committedOn);
|
|
205
|
+
const target = next && selectionAt(committedOn, next);
|
|
206
|
+
if (target) select(target);
|
|
207
|
+
};
|
|
179
208
|
return {
|
|
180
209
|
selectedColumnId,
|
|
181
210
|
select,
|
|
182
211
|
onKeyDown,
|
|
183
|
-
|
|
212
|
+
selectAfter,
|
|
213
|
+
refocus: (scroll = true)=>focusCurrent(void 0, scroll)
|
|
184
214
|
};
|
|
185
215
|
};
|
|
216
|
+
exports.isIgnoredKey = __webpack_exports__.isIgnoredKey;
|
|
186
217
|
exports.useSentenceNavigation = __webpack_exports__.useSentenceNavigation;
|
|
187
218
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
219
|
+
"isIgnoredKey",
|
|
188
220
|
"useSentenceNavigation"
|
|
189
221
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
190
222
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CellCommitMove } from './gridTypes';
|
|
3
|
+
import type { SentenceCellId, SentenceRule, SentenceSelection } from './sentenceTypes';
|
|
3
4
|
import type { RuleWindow } from './useRuleWindow';
|
|
5
|
+
export declare const isIgnoredKey: (event: React.KeyboardEvent) => boolean;
|
|
4
6
|
export interface SentenceNavigationSource extends Pick<RuleWindow, 'selectedRow' | 'container' | 'firstVisibleRow' | 'scrollStopIntoView' | 'scrollRowIntoView'> {
|
|
5
7
|
rules: readonly SentenceRule[];
|
|
6
8
|
selected: SentenceSelection | null | undefined;
|
|
7
9
|
onSelect: ((selection: SentenceSelection | null) => void) | undefined;
|
|
8
10
|
}
|
|
11
|
+
type CardFocus = (card: HTMLElement) => HTMLElement | null;
|
|
9
12
|
export interface SentenceNavigation {
|
|
10
13
|
selectedColumnId: string | null;
|
|
11
|
-
select: (selection: SentenceSelection | null, scroll?: boolean) => void;
|
|
14
|
+
select: (selection: SentenceSelection | null, focus?: CardFocus, scroll?: boolean) => void;
|
|
12
15
|
onKeyDown: (event: React.KeyboardEvent<HTMLElement>) => boolean;
|
|
16
|
+
selectAfter: (from: SentenceCellId, move: CellCommitMove, before: readonly SentenceRule[]) => void;
|
|
13
17
|
refocus: (scroll?: boolean) => void;
|
|
14
18
|
}
|
|
15
19
|
export declare const useSentenceNavigation: ({ rules, selected, selectedRow, onSelect, container, firstVisibleRow, scrollStopIntoView, scrollRowIntoView, }: SentenceNavigationSource) => SentenceNavigation;
|
|
20
|
+
export {};
|
|
16
21
|
//# sourceMappingURL=useSentenceNavigation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSentenceNavigation.d.ts","sourceRoot":"","sources":["../../src/decision-table/useSentenceNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useSentenceNavigation.d.ts","sourceRoot":"","sources":["../../src/decision-table/useSentenceNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEvF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA+GlD,eAAO,MAAM,YAAY,GAAI,OAAO,KAAK,CAAC,aAAa,KAAG,OAI3B,CAAC;AAiBhC,MAAM,WAAW,wBACf,SAAQ,IAAI,CACV,UAAU,EACV,aAAa,GAAG,WAAW,GAAG,iBAAiB,GAAG,oBAAoB,GAAG,mBAAmB,CAC7F;IACD,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IAC/B,QAAQ,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/C,QAAQ,EAAE,CAAC,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACvE;AAGD,KAAK,SAAS,GAAG,CAAC,IAAI,EAAE,WAAW,KAAK,WAAW,GAAG,IAAI,CAAC;AAyB3D,MAAM,WAAW,kBAAkB;IAEjC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhC,MAAM,EAAE,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI,EAAE,KAAK,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAE3F,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,OAAO,CAAC;IAEhE,WAAW,EAAE,CACX,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,SAAS,YAAY,EAAE,KAC5B,IAAI,CAAC;IAEV,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC;AAGD,eAAO,MAAM,qBAAqB,GAAI,gHASnC,wBAAwB,KAAG,kBAuH7B,CAAC"}
|
|
@@ -41,6 +41,20 @@ const edgeMove = (end, meta, from, rowCount, stopsAt)=>{
|
|
|
41
41
|
stop: end ? stopsAt(row).length - 1 : 0
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
|
+
const tabMove = (back, from, stops)=>{
|
|
45
|
+
const stop = from.stop + (back ? -1 : 1);
|
|
46
|
+
return stop < 0 || stop >= stops.length ? void 0 : {
|
|
47
|
+
row: from.row,
|
|
48
|
+
stop
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
const stopAfterCommit = (move, from, rules)=>{
|
|
52
|
+
const stopsAt = (row)=>stopsOf(rules[row]);
|
|
53
|
+
if ('none' === move) return;
|
|
54
|
+
if ('down' === move) return verticalMove(1, false, from, rules.length, stopsAt, stopsAt(from.row)[from.stop]);
|
|
55
|
+
const next = tabMove('left' === move, from, stopsAt(from.row));
|
|
56
|
+
return next && next.stop > 0 ? next : from;
|
|
57
|
+
};
|
|
44
58
|
const stopAfterKey = (event, from, rules, rtl, columnId)=>{
|
|
45
59
|
const meta = event.metaKey || event.ctrlKey;
|
|
46
60
|
const stopsAt = (row)=>stopsOf(rules[row]);
|
|
@@ -48,7 +62,7 @@ const stopAfterKey = (event, from, rules, rtl, columnId)=>{
|
|
|
48
62
|
if (delta) return 0 === delta.row ? horizontalMove(rtl ? -delta.col : delta.col, meta, from, stopsAt(from.row)) : verticalMove(delta.row, meta, from, rules.length, stopsAt, columnId);
|
|
49
63
|
if ('Home' === event.key || 'End' === event.key) return edgeMove('End' === event.key, meta, from, rules.length, stopsAt);
|
|
50
64
|
};
|
|
51
|
-
const isOnStop = (event)=>event.target === event.currentTarget || event.target instanceof
|
|
65
|
+
const isOnStop = (event)=>event.target === event.currentTarget || event.target instanceof HTMLElement && null !== event.target.closest('li[data-row-id]') && (null === event.target.closest('[data-rule-action]') || 'true' === event.target.dataset.selected);
|
|
52
66
|
const isIgnoredKey = (event)=>event.defaultPrevented || event.nativeEvent.isComposing || !isOnStop(event) || isFromTextField(event.target);
|
|
53
67
|
const stopOf = (container, selection)=>{
|
|
54
68
|
const card = cardOf(container, selection.rowId);
|
|
@@ -74,13 +88,14 @@ const useSentenceNavigation = ({ rules, selected, selectedRow, onSelect, contain
|
|
|
74
88
|
const current = position && (selectionAt(rules, position) ?? null);
|
|
75
89
|
const selectedRule = null === selectedRow ? void 0 : rules[selectedRow];
|
|
76
90
|
const selectedColumnId = current?.columnId ?? null;
|
|
77
|
-
const focusCurrent = (scroll = true)=>{
|
|
91
|
+
const focusCurrent = (focus, scroll = true)=>{
|
|
78
92
|
const element = container();
|
|
79
93
|
if (!element) return;
|
|
80
94
|
if (!current || !position) return void element.focus({
|
|
81
95
|
preventScroll: true
|
|
82
96
|
});
|
|
83
|
-
const
|
|
97
|
+
const card = focus && cardOf(element, current.rowId);
|
|
98
|
+
const stop = card ? focus?.(card) : stopOf(element, current);
|
|
84
99
|
if (stop) {
|
|
85
100
|
stop.focus({
|
|
86
101
|
preventScroll: true
|
|
@@ -102,27 +117,28 @@ const useSentenceNavigation = ({ rules, selected, selectedRow, onSelect, contain
|
|
|
102
117
|
const stayed = focusStays(container(), pending?.from);
|
|
103
118
|
const applied = void 0 !== pending && sameSelection(pending.selection, current);
|
|
104
119
|
if (!stayed || applied) pendingFocusRef.current = void 0;
|
|
105
|
-
if (void 0 !== pending && applied && stayed) focusCurrent(pending.scroll);
|
|
120
|
+
if (void 0 !== pending && applied && stayed) focusCurrent(pending.focus, pending.scroll);
|
|
106
121
|
else if (moved && null !== selectedRow) {
|
|
107
122
|
const stop = movedStopOf(container(), current);
|
|
108
123
|
if (stop) scrollStopIntoView(selectedRow, stop);
|
|
109
124
|
else scrollRowIntoView(selectedRow);
|
|
110
125
|
}
|
|
111
126
|
});
|
|
112
|
-
const request = (selection, scroll = true)=>{
|
|
127
|
+
const request = (selection, focus, scroll = true)=>{
|
|
113
128
|
if (!onSelect) return;
|
|
114
|
-
if (sameSelection(selection, selected ?? null)) return void focusCurrent(scroll);
|
|
129
|
+
if (sameSelection(selection, selected ?? null)) return void focusCurrent(focus, scroll);
|
|
115
130
|
const view = container();
|
|
116
131
|
pendingFocusRef.current = {
|
|
117
132
|
selection,
|
|
133
|
+
focus,
|
|
118
134
|
scroll,
|
|
119
135
|
from: view && activeElementOf(view)
|
|
120
136
|
};
|
|
121
137
|
onSelect(selection);
|
|
122
138
|
};
|
|
123
|
-
const select = (selection, scroll = true)=>{
|
|
139
|
+
const select = (selection, focus, scroll = true)=>{
|
|
124
140
|
wantedRef.current = void 0;
|
|
125
|
-
request(selection, scroll);
|
|
141
|
+
request(selection, focus, scroll);
|
|
126
142
|
};
|
|
127
143
|
const keyTarget = (event)=>{
|
|
128
144
|
if ('Escape' === event.key) return position ? null : void 0;
|
|
@@ -148,11 +164,24 @@ const useSentenceNavigation = ({ rules, selected, selectedRow, onSelect, contain
|
|
|
148
164
|
request(target);
|
|
149
165
|
return true;
|
|
150
166
|
};
|
|
167
|
+
const selectAfter = (from, move, before)=>{
|
|
168
|
+
const committedOn = stopsOf(before.find((rule)=>rule.rowId === from.rowId)).includes(from.columnId) ? before : rules;
|
|
169
|
+
const row = committedOn.findIndex((rule)=>rule.rowId === from.rowId);
|
|
170
|
+
if (row < 0) return;
|
|
171
|
+
const stop = Math.max(0, stopsOf(committedOn[row]).indexOf(from.columnId));
|
|
172
|
+
const next = stopAfterCommit(move, {
|
|
173
|
+
row,
|
|
174
|
+
stop
|
|
175
|
+
}, committedOn);
|
|
176
|
+
const target = next && selectionAt(committedOn, next);
|
|
177
|
+
if (target) select(target);
|
|
178
|
+
};
|
|
151
179
|
return {
|
|
152
180
|
selectedColumnId,
|
|
153
181
|
select,
|
|
154
182
|
onKeyDown,
|
|
155
|
-
|
|
183
|
+
selectAfter,
|
|
184
|
+
refocus: (scroll = true)=>focusCurrent(void 0, scroll)
|
|
156
185
|
};
|
|
157
186
|
};
|
|
158
|
-
export { useSentenceNavigation };
|
|
187
|
+
export { isIgnoredKey, useSentenceNavigation };
|