@uipath/apollo-react 7.17.4 → 7.19.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.
Files changed (209) hide show
  1. package/dist/canvas/components/BaseNode/BaseNode.cjs +2 -1
  2. package/dist/canvas/components/BaseNode/BaseNode.d.ts.map +1 -1
  3. package/dist/canvas/components/BaseNode/BaseNode.js +3 -2
  4. package/dist/canvas/components/ButtonHandle/SmartHandle.cjs +3 -4
  5. package/dist/canvas/components/ButtonHandle/SmartHandle.d.ts.map +1 -1
  6. package/dist/canvas/components/ButtonHandle/SmartHandle.js +4 -5
  7. package/dist/canvas/components/ContainerNode/ContainerNode.hooks.cjs +3 -7
  8. package/dist/canvas/components/ContainerNode/ContainerNode.hooks.d.ts.map +1 -1
  9. package/dist/canvas/components/ContainerNode/ContainerNode.hooks.js +4 -8
  10. package/dist/canvas/hooks/useBatchedUpdateNodeInternals.cjs +59 -0
  11. package/dist/canvas/hooks/useBatchedUpdateNodeInternals.d.ts +2 -0
  12. package/dist/canvas/hooks/useBatchedUpdateNodeInternals.d.ts.map +1 -0
  13. package/dist/canvas/hooks/useBatchedUpdateNodeInternals.js +25 -0
  14. package/dist/canvas/styles/tailwind.canvas.css +1 -1
  15. package/dist/chat/styles/tailwind.chat.css +1 -1
  16. package/dist/decision-table/AddRuleButton.cjs +49 -0
  17. package/dist/decision-table/AddRuleButton.d.ts +7 -0
  18. package/dist/decision-table/AddRuleButton.d.ts.map +1 -0
  19. package/dist/decision-table/AddRuleButton.js +15 -0
  20. package/dist/decision-table/AddRuleFooter.cjs +46 -0
  21. package/dist/decision-table/AddRuleFooter.d.ts +9 -0
  22. package/dist/decision-table/AddRuleFooter.d.ts.map +1 -0
  23. package/dist/decision-table/AddRuleFooter.js +12 -0
  24. package/dist/decision-table/BandColumn.cjs +66 -0
  25. package/dist/decision-table/BandColumn.d.ts +12 -0
  26. package/dist/decision-table/BandColumn.d.ts.map +1 -0
  27. package/dist/decision-table/BandColumn.js +32 -0
  28. package/dist/decision-table/BandList.cjs +54 -0
  29. package/dist/decision-table/BandList.d.ts +12 -0
  30. package/dist/decision-table/BandList.d.ts.map +1 -0
  31. package/dist/decision-table/BandList.js +20 -0
  32. package/dist/decision-table/CellTextEditor.cjs +78 -0
  33. package/dist/decision-table/CellTextEditor.d.ts +8 -0
  34. package/dist/decision-table/CellTextEditor.d.ts.map +1 -0
  35. package/dist/decision-table/CellTextEditor.js +44 -0
  36. package/dist/decision-table/ConditionLine.cjs +66 -0
  37. package/dist/decision-table/ConditionLine.d.ts +12 -0
  38. package/dist/decision-table/ConditionLine.d.ts.map +1 -0
  39. package/dist/decision-table/ConditionLine.js +32 -0
  40. package/dist/decision-table/DecisionText.cjs +168 -0
  41. package/dist/decision-table/DecisionText.d.ts +44 -0
  42. package/dist/decision-table/DecisionText.d.ts.map +1 -0
  43. package/dist/decision-table/DecisionText.js +134 -0
  44. package/dist/decision-table/DecisionTextHeader.cjs +73 -0
  45. package/dist/decision-table/DecisionTextHeader.d.ts +13 -0
  46. package/dist/decision-table/DecisionTextHeader.d.ts.map +1 -0
  47. package/dist/decision-table/DecisionTextHeader.js +39 -0
  48. package/dist/decision-table/EmptyRules.cjs +51 -0
  49. package/dist/decision-table/EmptyRules.d.ts +9 -0
  50. package/dist/decision-table/EmptyRules.d.ts.map +1 -0
  51. package/dist/decision-table/EmptyRules.js +17 -0
  52. package/dist/decision-table/GridCell.cjs +11 -31
  53. package/dist/decision-table/GridCell.d.ts +1 -9
  54. package/dist/decision-table/GridCell.d.ts.map +1 -1
  55. package/dist/decision-table/GridCell.js +12 -32
  56. package/dist/decision-table/LineLead.cjs +58 -0
  57. package/dist/decision-table/LineLead.d.ts +10 -0
  58. package/dist/decision-table/LineLead.d.ts.map +1 -0
  59. package/dist/decision-table/LineLead.js +24 -0
  60. package/dist/decision-table/LineText.cjs +109 -0
  61. package/dist/decision-table/LineText.d.ts +20 -0
  62. package/dist/decision-table/LineText.d.ts.map +1 -0
  63. package/dist/decision-table/LineText.js +75 -0
  64. package/dist/decision-table/MarkBadge.cjs +66 -0
  65. package/dist/decision-table/MarkBadge.d.ts +13 -0
  66. package/dist/decision-table/MarkBadge.d.ts.map +1 -0
  67. package/dist/decision-table/MarkBadge.js +29 -0
  68. package/dist/decision-table/PolicyOptionItem.cjs +121 -0
  69. package/dist/decision-table/PolicyOptionItem.d.ts +16 -0
  70. package/dist/decision-table/PolicyOptionItem.d.ts.map +1 -0
  71. package/dist/decision-table/PolicyOptionItem.js +84 -0
  72. package/dist/decision-table/PolicyPicker.cjs +110 -0
  73. package/dist/decision-table/PolicyPicker.d.ts +17 -0
  74. package/dist/decision-table/PolicyPicker.d.ts.map +1 -0
  75. package/dist/decision-table/PolicyPicker.js +76 -0
  76. package/dist/decision-table/RemoveConditionButton.cjs +52 -0
  77. package/dist/decision-table/RemoveConditionButton.d.ts +7 -0
  78. package/dist/decision-table/RemoveConditionButton.d.ts.map +1 -0
  79. package/dist/decision-table/RemoveConditionButton.js +18 -0
  80. package/dist/decision-table/RuleActions.cjs +76 -0
  81. package/dist/decision-table/RuleActions.d.ts +15 -0
  82. package/dist/decision-table/RuleActions.d.ts.map +1 -0
  83. package/dist/decision-table/RuleActions.js +42 -0
  84. package/dist/decision-table/RuleCard.cjs +123 -0
  85. package/dist/decision-table/RuleCard.d.ts +14 -0
  86. package/dist/decision-table/RuleCard.d.ts.map +1 -0
  87. package/dist/decision-table/RuleCard.js +89 -0
  88. package/dist/decision-table/RuleLine.cjs +56 -0
  89. package/dist/decision-table/RuleLine.d.ts +12 -0
  90. package/dist/decision-table/RuleLine.d.ts.map +1 -0
  91. package/dist/decision-table/RuleLine.js +22 -0
  92. package/dist/decision-table/RuleList.cjs +73 -0
  93. package/dist/decision-table/RuleList.d.ts +28 -0
  94. package/dist/decision-table/RuleList.d.ts.map +1 -0
  95. package/dist/decision-table/RuleList.js +39 -0
  96. package/dist/decision-table/SentenceBands.cjs +60 -0
  97. package/dist/decision-table/SentenceBands.d.ts +12 -0
  98. package/dist/decision-table/SentenceBands.d.ts.map +1 -0
  99. package/dist/decision-table/SentenceBands.js +26 -0
  100. package/dist/decision-table/StopLabels.cjs +43 -0
  101. package/dist/decision-table/StopLabels.d.ts +7 -0
  102. package/dist/decision-table/StopLabels.d.ts.map +1 -0
  103. package/dist/decision-table/StopLabels.js +9 -0
  104. package/dist/decision-table/TokenChip.cjs +87 -0
  105. package/dist/decision-table/TokenChip.d.ts +24 -0
  106. package/dist/decision-table/TokenChip.d.ts.map +1 -0
  107. package/dist/decision-table/TokenChip.js +53 -0
  108. package/dist/decision-table/ValueEditorOverlay.cjs +71 -0
  109. package/dist/decision-table/ValueEditorOverlay.d.ts +11 -0
  110. package/dist/decision-table/ValueEditorOverlay.d.ts.map +1 -0
  111. package/dist/decision-table/ValueEditorOverlay.js +37 -0
  112. package/dist/decision-table/__fixtures__/editableSentences.fixtures.d.ts +37 -0
  113. package/dist/decision-table/__fixtures__/editableSentences.fixtures.d.ts.map +1 -0
  114. package/dist/decision-table/__fixtures__/sentences.fixtures.d.ts +30 -0
  115. package/dist/decision-table/__fixtures__/sentences.fixtures.d.ts.map +1 -0
  116. package/dist/decision-table/decisionTextTypes.cjs +18 -0
  117. package/dist/decision-table/decisionTextTypes.d.ts +21 -0
  118. package/dist/decision-table/decisionTextTypes.d.ts.map +1 -0
  119. package/dist/decision-table/decisionTextTypes.js +0 -0
  120. package/dist/decision-table/gridEvents.cjs +46 -2
  121. package/dist/decision-table/gridEvents.d.ts +4 -0
  122. package/dist/decision-table/gridEvents.d.ts.map +1 -1
  123. package/dist/decision-table/gridEvents.js +33 -1
  124. package/dist/decision-table/gridTypes.d.ts +8 -0
  125. package/dist/decision-table/gridTypes.d.ts.map +1 -1
  126. package/dist/decision-table/index.cjs +63 -55
  127. package/dist/decision-table/index.d.ts +11 -1
  128. package/dist/decision-table/index.d.ts.map +1 -1
  129. package/dist/decision-table/index.js +2 -1
  130. package/dist/decision-table/ruleCardModel.cjs +171 -0
  131. package/dist/decision-table/ruleCardModel.d.ts +52 -0
  132. package/dist/decision-table/ruleCardModel.d.ts.map +1 -0
  133. package/dist/decision-table/ruleCardModel.js +131 -0
  134. package/dist/decision-table/sentenceMarks.cjs +89 -0
  135. package/dist/decision-table/sentenceMarks.d.ts +27 -0
  136. package/dist/decision-table/sentenceMarks.d.ts.map +1 -0
  137. package/dist/decision-table/sentenceMarks.js +43 -0
  138. package/dist/decision-table/sentenceParts.cjs +133 -0
  139. package/dist/decision-table/sentenceParts.d.ts +24 -0
  140. package/dist/decision-table/sentenceParts.d.ts.map +1 -0
  141. package/dist/decision-table/sentenceParts.js +66 -0
  142. package/dist/decision-table/sentenceRuleHeights.cjs +70 -0
  143. package/dist/decision-table/sentenceRuleHeights.d.ts +7 -0
  144. package/dist/decision-table/sentenceRuleHeights.d.ts.map +1 -0
  145. package/dist/decision-table/sentenceRuleHeights.js +30 -0
  146. package/dist/decision-table/sentenceStyles.cjs +239 -0
  147. package/dist/decision-table/sentenceStyles.d.ts +56 -0
  148. package/dist/decision-table/sentenceStyles.d.ts.map +1 -0
  149. package/dist/decision-table/sentenceStyles.js +64 -0
  150. package/dist/decision-table/sentenceTargets.cjs +158 -0
  151. package/dist/decision-table/sentenceTargets.d.ts +33 -0
  152. package/dist/decision-table/sentenceTargets.d.ts.map +1 -0
  153. package/dist/decision-table/sentenceTargets.js +94 -0
  154. package/dist/decision-table/sentenceTypes.cjs +18 -0
  155. package/dist/decision-table/sentenceTypes.d.ts +49 -0
  156. package/dist/decision-table/sentenceTypes.d.ts.map +1 -0
  157. package/dist/decision-table/sentenceTypes.js +0 -0
  158. package/dist/decision-table/styles/tailwind.decision-table.css +1 -1
  159. package/dist/decision-table/useAddRule.cjs +63 -0
  160. package/dist/decision-table/useAddRule.d.ts +8 -0
  161. package/dist/decision-table/useAddRule.d.ts.map +1 -0
  162. package/dist/decision-table/useAddRule.js +29 -0
  163. package/dist/decision-table/useCellHover.cjs +55 -0
  164. package/dist/decision-table/useCellHover.d.ts +4 -0
  165. package/dist/decision-table/useCellHover.d.ts.map +1 -0
  166. package/dist/decision-table/useCellHover.js +21 -0
  167. package/dist/decision-table/useContainerHandlers.cjs +140 -0
  168. package/dist/decision-table/useContainerHandlers.d.ts +299 -0
  169. package/dist/decision-table/useContainerHandlers.d.ts.map +1 -0
  170. package/dist/decision-table/useContainerHandlers.js +106 -0
  171. package/dist/decision-table/useEditorPlacement.cjs +104 -0
  172. package/dist/decision-table/useEditorPlacement.d.ts +17 -0
  173. package/dist/decision-table/useEditorPlacement.d.ts.map +1 -0
  174. package/dist/decision-table/useEditorPlacement.js +70 -0
  175. package/dist/decision-table/useGridLayout.d.ts +1 -8
  176. package/dist/decision-table/useGridLayout.d.ts.map +1 -1
  177. package/dist/decision-table/useGridNavigation.cjs +11 -2
  178. package/dist/decision-table/useGridNavigation.d.ts +3 -0
  179. package/dist/decision-table/useGridNavigation.d.ts.map +1 -1
  180. package/dist/decision-table/useGridNavigation.js +1 -1
  181. package/dist/decision-table/useHorizontalOverflow.cjs +65 -0
  182. package/dist/decision-table/useHorizontalOverflow.d.ts +5 -0
  183. package/dist/decision-table/useHorizontalOverflow.d.ts.map +1 -0
  184. package/dist/decision-table/useHorizontalOverflow.js +31 -0
  185. package/dist/decision-table/useRuleMenus.cjs +149 -0
  186. package/dist/decision-table/useRuleMenus.d.ts +24 -0
  187. package/dist/decision-table/useRuleMenus.d.ts.map +1 -0
  188. package/dist/decision-table/useRuleMenus.js +115 -0
  189. package/dist/decision-table/useRuleWindow.cjs +136 -0
  190. package/dist/decision-table/useRuleWindow.d.ts +17 -0
  191. package/dist/decision-table/useRuleWindow.d.ts.map +1 -0
  192. package/dist/decision-table/useRuleWindow.js +99 -0
  193. package/dist/decision-table/useSentenceNavigation.cjs +224 -0
  194. package/dist/decision-table/useSentenceNavigation.d.ts +21 -0
  195. package/dist/decision-table/useSentenceNavigation.d.ts.map +1 -0
  196. package/dist/decision-table/useSentenceNavigation.js +187 -0
  197. package/dist/decision-table/useValueEditing.cjs +306 -0
  198. package/dist/decision-table/useValueEditing.d.ts +34 -0
  199. package/dist/decision-table/useValueEditing.d.ts.map +1 -0
  200. package/dist/decision-table/useValueEditing.js +272 -0
  201. package/dist/decision-table/useVirtualizedAxis.cjs +34 -11
  202. package/dist/decision-table/useVirtualizedAxis.d.ts +1 -1
  203. package/dist/decision-table/useVirtualizedAxis.d.ts.map +1 -1
  204. package/dist/decision-table/useVirtualizedAxis.js +34 -11
  205. package/dist/decision-table/valueTypes.cjs +18 -0
  206. package/dist/decision-table/valueTypes.d.ts +6 -0
  207. package/dist/decision-table/valueTypes.d.ts.map +1 -0
  208. package/dist/decision-table/valueTypes.js +0 -0
  209. package/package.json +4 -4
@@ -0,0 +1,24 @@
1
+ import type React from 'react';
2
+ import type { DecisionTextEdit } from './decisionTextTypes';
3
+ import type { GridContextMenuProps, GridContextMenuState } from './GridMenu';
4
+ import type { OpenRuleMenu } from './RuleList';
5
+ import { type RuleAction } from './sentenceTargets';
6
+ import type { SentenceRule } from './sentenceTypes';
7
+ export interface RuleMenusParams {
8
+ edit: DecisionTextEdit | undefined;
9
+ rules: readonly SentenceRule[];
10
+ selectedRowId: string | undefined;
11
+ refocus: (scroll: boolean) => void;
12
+ }
13
+ interface RuleMenuState extends GridContextMenuState, OpenRuleMenu {
14
+ trigger: HTMLElement;
15
+ openedOnRowId: string | undefined;
16
+ }
17
+ export interface RuleMenus extends Pick<GridContextMenuProps, 'label' | 'entries' | 'onClose'> {
18
+ state: RuleMenuState | null;
19
+ onClick: (event: React.MouseEvent<HTMLElement>) => boolean;
20
+ openFor: (action: RuleAction) => boolean;
21
+ }
22
+ export declare const useRuleMenus: ({ edit, rules, selectedRowId, refocus, }: RuleMenusParams) => RuleMenus;
23
+ export {};
24
+ //# sourceMappingURL=useRuleMenus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRuleMenus.d.ts","sourceRoot":"","sources":["../../src/decision-table/useRuleMenus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAiB,MAAM,YAAY,CAAC;AAC5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IAE/B,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAElC,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC;AAGD,UAAU,aAAc,SAAQ,oBAAoB,EAAE,YAAY;IAChE,OAAO,EAAE,WAAW,CAAC;IAErB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;AAKD,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,oBAAoB,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;IAC5F,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAE5B,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,OAAO,CAAC;IAE3D,OAAO,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC;CAC1C;AA+CD,eAAO,MAAM,YAAY,GAAI,0CAK1B,eAAe,KAAG,SAmFpB,CAAC"}
@@ -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 };
@@ -0,0 +1,136 @@
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
+ SENTENCE_RULE_OVERSCAN: ()=>SENTENCE_RULE_OVERSCAN,
28
+ useRuleWindow: ()=>useRuleWindow
29
+ });
30
+ const external_react_namespaceObject = require("react");
31
+ const external_constants_cjs_namespaceObject = require("./constants.cjs");
32
+ const external_sentenceRuleHeights_cjs_namespaceObject = require("./sentenceRuleHeights.cjs");
33
+ const external_useVirtualizedAxis_cjs_namespaceObject = require("./useVirtualizedAxis.cjs");
34
+ const SENTENCE_RULE_OVERSCAN = 10;
35
+ const rowIndexOf = (rules, rowId)=>{
36
+ const index = rules.findIndex((rule)=>rule.rowId === rowId);
37
+ return index < 0 ? null : index;
38
+ };
39
+ const NO_HEIGHTS = new Map();
40
+ const measuredHeights = (current, entries)=>{
41
+ let next;
42
+ for (const { target } of entries){
43
+ if (!(target instanceof HTMLElement)) continue;
44
+ const rowId = target.dataset.rowId;
45
+ const height = target.offsetHeight;
46
+ if (void 0 !== rowId && 0 !== height && current.get(rowId) !== height) {
47
+ next ??= new Map(current);
48
+ next.set(rowId, height);
49
+ }
50
+ }
51
+ return next ?? current;
52
+ };
53
+ const useRuleWindow = (rules, selectedRowId, retainedRowId)=>{
54
+ const listRef = (0, external_react_namespaceObject.useRef)(null);
55
+ const headerRef = (0, external_react_namespaceObject.useRef)(null);
56
+ const sectionRef = (0, external_react_namespaceObject.useRef)(null);
57
+ const listStart = (0, external_react_namespaceObject.useCallback)(()=>listRef.current?.offsetTop ?? 0, []);
58
+ const headerHeight = (0, external_react_namespaceObject.useCallback)(()=>headerRef.current?.offsetHeight ?? 0, []);
59
+ const [measured, setMeasured] = (0, external_react_namespaceObject.useState)(NO_HEIGHTS);
60
+ const offsetsPx = (0, external_react_namespaceObject.useMemo)(()=>(0, external_sentenceRuleHeights_cjs_namespaceObject.sentenceRuleOffsets)(rules, measured), [
61
+ rules,
62
+ measured
63
+ ]);
64
+ const selectedRow = (0, external_react_namespaceObject.useMemo)(()=>rowIndexOf(rules, selectedRowId), [
65
+ rules,
66
+ selectedRowId
67
+ ]);
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, {
73
+ axis: 'vertical',
74
+ overscanItems: SENTENCE_RULE_OVERSCAN,
75
+ fallbackViewportPx: external_constants_cjs_namespaceObject.FALLBACK_ROW_VIEWPORT_PX,
76
+ leadingFixedPx: listStart,
77
+ stickyLeadingPx: headerHeight,
78
+ itemOffsetsPx: offsetsPx
79
+ });
80
+ const mountedRowIds = segments.flatMap((segment)=>'items' === segment.type ? rules.slice(segment.from, segment.to).map(({ rowId })=>rowId) : []).join('\n');
81
+ (0, external_react_namespaceObject.useLayoutEffect)(()=>{
82
+ const list = listRef.current;
83
+ if (!list || "u" < typeof ResizeObserver) return;
84
+ const observer = new ResizeObserver((entries)=>setMeasured((current)=>measuredHeights(current, entries)));
85
+ for (const card of list.querySelectorAll(':scope > li[data-row-id]'))observer.observe(card);
86
+ return ()=>observer.disconnect();
87
+ }, [
88
+ mountedRowIds
89
+ ]);
90
+ const attachSection = (0, external_react_namespaceObject.useCallback)((element)=>{
91
+ sectionRef.current = element;
92
+ measureRef(element);
93
+ }, [
94
+ measureRef
95
+ ]);
96
+ const container = (0, external_react_namespaceObject.useCallback)(()=>sectionRef.current, []);
97
+ const scrollRowIntoView = (0, external_react_namespaceObject.useCallback)((rowIndex)=>scrollItemIntoView(sectionRef.current, rowIndex), [
98
+ scrollItemIntoView
99
+ ]);
100
+ const firstVisibleRow = ()=>{
101
+ const top = (sectionRef.current?.scrollTop ?? 0) + headerHeight() - listStart();
102
+ const end = offsetsPx.findIndex((offset)=>offset > top);
103
+ return end < 0 ? rules.length - 1 : Math.max(0, end - 1);
104
+ };
105
+ const scrollStopIntoView = (rowIndex, stop)=>{
106
+ const section = sectionRef.current;
107
+ if (!section) return;
108
+ const rowHeight = (offsetsPx[rowIndex + 1] ?? 0) - (offsetsPx[rowIndex] ?? 0);
109
+ if (rowHeight <= (section.clientHeight || external_constants_cjs_namespaceObject.FALLBACK_ROW_VIEWPORT_PX) - headerHeight()) scrollRowIntoView(rowIndex);
110
+ const top = section.getBoundingClientRect().top + headerHeight();
111
+ const bottom = section.getBoundingClientRect().top + section.clientHeight;
112
+ const { top: stopTop, bottom: stopBottom } = stop.getBoundingClientRect();
113
+ if (stopTop < top || stopBottom - stopTop > bottom - top) section.scrollTop -= top - stopTop;
114
+ else if (stopBottom > bottom) section.scrollTop += stopBottom - bottom;
115
+ };
116
+ return {
117
+ listRef,
118
+ headerRef,
119
+ segments,
120
+ selectedRow,
121
+ attachSection,
122
+ container,
123
+ scrollRowIntoView,
124
+ firstVisibleRow,
125
+ scrollStopIntoView
126
+ };
127
+ };
128
+ exports.SENTENCE_RULE_OVERSCAN = __webpack_exports__.SENTENCE_RULE_OVERSCAN;
129
+ exports.useRuleWindow = __webpack_exports__.useRuleWindow;
130
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
131
+ "SENTENCE_RULE_OVERSCAN",
132
+ "useRuleWindow"
133
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
134
+ Object.defineProperty(exports, '__esModule', {
135
+ value: true
136
+ });
@@ -0,0 +1,17 @@
1
+ import type React from 'react';
2
+ import type { SentenceRule } from './sentenceTypes';
3
+ import { type AxisSegment } from './useVirtualizedAxis';
4
+ export declare const SENTENCE_RULE_OVERSCAN = 10;
5
+ export interface RuleWindow {
6
+ listRef: React.RefObject<HTMLUListElement | null>;
7
+ headerRef: React.RefObject<HTMLDivElement | null>;
8
+ segments: AxisSegment[];
9
+ selectedRow: number | null;
10
+ attachSection: (element: HTMLElement | null) => void;
11
+ container: () => HTMLElement | null;
12
+ scrollRowIntoView: (rowIndex: number) => void;
13
+ firstVisibleRow: () => number;
14
+ scrollStopIntoView: (rowIndex: number, stop: HTMLElement) => void;
15
+ }
16
+ export declare const useRuleWindow: (rules: readonly SentenceRule[], selectedRowId: string | undefined, retainedRowId: string | undefined) => RuleWindow;
17
+ //# sourceMappingURL=useRuleWindow.d.ts.map
@@ -0,0 +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,EACjC,eAAe,MAAM,GAAG,SAAS,KAChC,UAsFF,CAAC"}
@@ -0,0 +1,99 @@
1
+ import { useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
2
+ import { FALLBACK_ROW_VIEWPORT_PX } from "./constants.js";
3
+ import { SENTENCE_MIN_RULE_HEIGHT_PX, sentenceRuleOffsets } from "./sentenceRuleHeights.js";
4
+ import { useVirtualizedAxis } from "./useVirtualizedAxis.js";
5
+ const SENTENCE_RULE_OVERSCAN = 10;
6
+ const rowIndexOf = (rules, rowId)=>{
7
+ const index = rules.findIndex((rule)=>rule.rowId === rowId);
8
+ return index < 0 ? null : index;
9
+ };
10
+ const NO_HEIGHTS = new Map();
11
+ const measuredHeights = (current, entries)=>{
12
+ let next;
13
+ for (const { target } of entries){
14
+ if (!(target instanceof HTMLElement)) continue;
15
+ const rowId = target.dataset.rowId;
16
+ const height = target.offsetHeight;
17
+ if (void 0 !== rowId && 0 !== height && current.get(rowId) !== height) {
18
+ next ??= new Map(current);
19
+ next.set(rowId, height);
20
+ }
21
+ }
22
+ return next ?? current;
23
+ };
24
+ const useRuleWindow = (rules, selectedRowId, retainedRowId)=>{
25
+ const listRef = useRef(null);
26
+ const headerRef = useRef(null);
27
+ const sectionRef = useRef(null);
28
+ const listStart = useCallback(()=>listRef.current?.offsetTop ?? 0, []);
29
+ const headerHeight = useCallback(()=>headerRef.current?.offsetHeight ?? 0, []);
30
+ const [measured, setMeasured] = useState(NO_HEIGHTS);
31
+ const offsetsPx = useMemo(()=>sentenceRuleOffsets(rules, measured), [
32
+ rules,
33
+ measured
34
+ ]);
35
+ const selectedRow = useMemo(()=>rowIndexOf(rules, selectedRowId), [
36
+ rules,
37
+ selectedRowId
38
+ ]);
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, {
44
+ axis: 'vertical',
45
+ overscanItems: SENTENCE_RULE_OVERSCAN,
46
+ fallbackViewportPx: FALLBACK_ROW_VIEWPORT_PX,
47
+ leadingFixedPx: listStart,
48
+ stickyLeadingPx: headerHeight,
49
+ itemOffsetsPx: offsetsPx
50
+ });
51
+ const mountedRowIds = segments.flatMap((segment)=>'items' === segment.type ? rules.slice(segment.from, segment.to).map(({ rowId })=>rowId) : []).join('\n');
52
+ useLayoutEffect(()=>{
53
+ const list = listRef.current;
54
+ if (!list || "u" < typeof ResizeObserver) return;
55
+ const observer = new ResizeObserver((entries)=>setMeasured((current)=>measuredHeights(current, entries)));
56
+ for (const card of list.querySelectorAll(':scope > li[data-row-id]'))observer.observe(card);
57
+ return ()=>observer.disconnect();
58
+ }, [
59
+ mountedRowIds
60
+ ]);
61
+ const attachSection = useCallback((element)=>{
62
+ sectionRef.current = element;
63
+ measureRef(element);
64
+ }, [
65
+ measureRef
66
+ ]);
67
+ const container = useCallback(()=>sectionRef.current, []);
68
+ const scrollRowIntoView = useCallback((rowIndex)=>scrollItemIntoView(sectionRef.current, rowIndex), [
69
+ scrollItemIntoView
70
+ ]);
71
+ const firstVisibleRow = ()=>{
72
+ const top = (sectionRef.current?.scrollTop ?? 0) + headerHeight() - listStart();
73
+ const end = offsetsPx.findIndex((offset)=>offset > top);
74
+ return end < 0 ? rules.length - 1 : Math.max(0, end - 1);
75
+ };
76
+ const scrollStopIntoView = (rowIndex, stop)=>{
77
+ const section = sectionRef.current;
78
+ if (!section) return;
79
+ const rowHeight = (offsetsPx[rowIndex + 1] ?? 0) - (offsetsPx[rowIndex] ?? 0);
80
+ if (rowHeight <= (section.clientHeight || FALLBACK_ROW_VIEWPORT_PX) - headerHeight()) scrollRowIntoView(rowIndex);
81
+ const top = section.getBoundingClientRect().top + headerHeight();
82
+ const bottom = section.getBoundingClientRect().top + section.clientHeight;
83
+ const { top: stopTop, bottom: stopBottom } = stop.getBoundingClientRect();
84
+ if (stopTop < top || stopBottom - stopTop > bottom - top) section.scrollTop -= top - stopTop;
85
+ else if (stopBottom > bottom) section.scrollTop += stopBottom - bottom;
86
+ };
87
+ return {
88
+ listRef,
89
+ headerRef,
90
+ segments,
91
+ selectedRow,
92
+ attachSection,
93
+ container,
94
+ scrollRowIntoView,
95
+ firstVisibleRow,
96
+ scrollStopIntoView
97
+ };
98
+ };
99
+ export { SENTENCE_RULE_OVERSCAN, useRuleWindow };
@@ -0,0 +1,224 @@
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
+ isIgnoredKey: ()=>isIgnoredKey,
28
+ useSentenceNavigation: ()=>useSentenceNavigation
29
+ });
30
+ const external_react_namespaceObject = require("react");
31
+ const external_gridEvents_cjs_namespaceObject = require("./gridEvents.cjs");
32
+ const external_ruleCardModel_cjs_namespaceObject = require("./ruleCardModel.cjs");
33
+ const external_sentenceTargets_cjs_namespaceObject = require("./sentenceTargets.cjs");
34
+ const external_useGridNavigation_cjs_namespaceObject = require("./useGridNavigation.cjs");
35
+ const stopsOf = (rule)=>[
36
+ void 0,
37
+ ...rule ? (0, external_ruleCardModel_cjs_namespaceObject.firstValuesOf)(rule).keys() : []
38
+ ];
39
+ const selectionAt = (rules, { row, stop })=>{
40
+ const target = rules[row];
41
+ if (!target) return;
42
+ const columnId = stopsOf(target)[stop];
43
+ return void 0 === columnId ? {
44
+ rowId: target.rowId
45
+ } : {
46
+ rowId: target.rowId,
47
+ columnId
48
+ };
49
+ };
50
+ const sameSelection = (left, right)=>left?.rowId === right?.rowId && left?.columnId === right?.columnId;
51
+ const verticalMove = (delta, meta, from, rowCount, stopsAt, columnId)=>{
52
+ const last = rowCount - 1;
53
+ const row = meta ? delta < 0 ? 0 : last : (0, external_useGridNavigation_cjs_namespaceObject.clamp)(from.row + delta, last);
54
+ return {
55
+ row,
56
+ stop: Math.max(0, stopsAt(row).indexOf(columnId))
57
+ };
58
+ };
59
+ const horizontalMove = (delta, meta, from, stops)=>{
60
+ const last = stops.length - 1;
61
+ return {
62
+ row: from.row,
63
+ stop: meta ? delta < 0 ? 0 : last : (0, external_useGridNavigation_cjs_namespaceObject.clamp)(from.stop + delta, last)
64
+ };
65
+ };
66
+ const edgeMove = (end, meta, from, rowCount, stopsAt)=>{
67
+ const row = meta ? end ? rowCount - 1 : 0 : from.row;
68
+ return {
69
+ row,
70
+ stop: end ? stopsAt(row).length - 1 : 0
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
+ };
87
+ const stopAfterKey = (event, from, rules, rtl, columnId)=>{
88
+ const meta = event.metaKey || event.ctrlKey;
89
+ const stopsAt = (row)=>stopsOf(rules[row]);
90
+ const delta = external_useGridNavigation_cjs_namespaceObject.ARROW_DELTAS[event.key];
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);
92
+ if ('Home' === event.key || 'End' === event.key) return edgeMove('End' === event.key, meta, from, rules.length, stopsAt);
93
+ };
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);
95
+ const isIgnoredKey = (event)=>event.defaultPrevented || event.nativeEvent.isComposing || !isOnStop(event) || (0, external_gridEvents_cjs_namespaceObject.isFromTextField)(event.target);
96
+ const stopOf = (container, selection)=>{
97
+ const card = (0, external_sentenceTargets_cjs_namespaceObject.cardOf)(container, selection.rowId);
98
+ return card && void 0 !== selection.columnId ? (0, external_sentenceTargets_cjs_namespaceObject.cellOf)(card, selection.columnId) : card;
99
+ };
100
+ const movedStopOf = (element, current)=>{
101
+ const cell = element && current?.columnId !== void 0 ? stopOf(element, current) : void 0;
102
+ const addRule = element?.querySelector('[data-add-rule]');
103
+ const focusedAddRule = addRule?.contains((0, external_gridEvents_cjs_namespaceObject.activeElementOf)(addRule)) ? addRule : void 0;
104
+ return focusedAddRule ?? cell;
105
+ };
106
+ const keptColumnOf = (wanted, current)=>wanted && sameSelection(wanted.at, current) ? wanted.columnId : current?.columnId;
107
+ const isVerticalKey = (key)=>(external_useGridNavigation_cjs_namespaceObject.ARROW_DELTAS[key]?.row ?? 0) !== 0;
108
+ const useSentenceNavigation = ({ rules, selected, selectedRow, onSelect, container, firstVisibleRow, scrollStopIntoView, scrollRowIntoView })=>{
109
+ const stops = (0, external_react_namespaceObject.useMemo)(()=>stopsOf(null === selectedRow ? void 0 : rules[selectedRow]), [
110
+ rules,
111
+ selectedRow
112
+ ]);
113
+ const position = null === selectedRow ? null : {
114
+ row: selectedRow,
115
+ stop: Math.max(0, stops.indexOf(selected?.columnId))
116
+ };
117
+ const current = position && (selectionAt(rules, position) ?? null);
118
+ const selectedRule = null === selectedRow ? void 0 : rules[selectedRow];
119
+ const selectedColumnId = current?.columnId ?? null;
120
+ const focusCurrent = (focus, scroll = true)=>{
121
+ const element = container();
122
+ if (!element) return;
123
+ if (!current || !position) return void element.focus({
124
+ preventScroll: true
125
+ });
126
+ const card = focus && (0, external_sentenceTargets_cjs_namespaceObject.cardOf)(element, current.rowId);
127
+ const stop = card ? focus?.(card) : stopOf(element, current);
128
+ if (stop) {
129
+ stop.focus({
130
+ preventScroll: true
131
+ });
132
+ if (scroll) scrollStopIntoView(position.row, stop);
133
+ }
134
+ };
135
+ const pendingFocusRef = (0, external_react_namespaceObject.useRef)(void 0);
136
+ const wantedRef = (0, external_react_namespaceObject.useRef)(void 0);
137
+ const shownRowIdRef = (0, external_react_namespaceObject.useRef)(selectedRule?.rowId);
138
+ const shownSelectionRef = (0, external_react_namespaceObject.useRef)(current);
139
+ (0, external_react_namespaceObject.useLayoutEffect)(()=>{
140
+ const changed = !sameSelection(shownSelectionRef.current, current);
141
+ shownSelectionRef.current = current;
142
+ if (changed && !sameSelection(wantedRef.current?.at ?? null, current)) wantedRef.current = void 0;
143
+ const pending = pendingFocusRef.current;
144
+ const moved = selectedRule?.rowId !== shownRowIdRef.current;
145
+ shownRowIdRef.current = selectedRule?.rowId;
146
+ const stayed = (0, external_gridEvents_cjs_namespaceObject.focusStays)(container(), pending?.from);
147
+ const applied = void 0 !== pending && sameSelection(pending.selection, current);
148
+ if (!stayed || applied) pendingFocusRef.current = void 0;
149
+ if (void 0 !== pending && applied && stayed) focusCurrent(pending.focus, pending.scroll);
150
+ else if (moved && null !== selectedRow) {
151
+ const stop = movedStopOf(container(), current);
152
+ if (stop) scrollStopIntoView(selectedRow, stop);
153
+ else scrollRowIntoView(selectedRow);
154
+ }
155
+ });
156
+ const request = (selection, focus, scroll = true)=>{
157
+ if (!onSelect) return;
158
+ if (sameSelection(selection, selected ?? null)) return void focusCurrent(focus, scroll);
159
+ const view = container();
160
+ pendingFocusRef.current = {
161
+ selection,
162
+ focus,
163
+ scroll,
164
+ from: view && (0, external_gridEvents_cjs_namespaceObject.activeElementOf)(view)
165
+ };
166
+ onSelect(selection);
167
+ };
168
+ const select = (selection, focus, scroll = true)=>{
169
+ wantedRef.current = void 0;
170
+ request(selection, focus, scroll);
171
+ };
172
+ const keyTarget = (event)=>{
173
+ if ('Escape' === event.key) return position ? null : void 0;
174
+ if (!position) return external_useGridNavigation_cjs_namespaceObject.GRID_ENTRY_KEYS.includes(event.key) ? selectionAt(rules, {
175
+ row: firstVisibleRow(),
176
+ stop: 0
177
+ }) : void 0;
178
+ const rtl = 'rtl' === getComputedStyle(event.currentTarget).direction;
179
+ const wanted = keptColumnOf(wantedRef.current, current);
180
+ const next = stopAfterKey(event, position, rules, rtl, wanted);
181
+ const target = next && selectionAt(rules, next);
182
+ wantedRef.current = target && isVerticalKey(event.key) ? {
183
+ columnId: wanted,
184
+ at: target
185
+ } : void 0;
186
+ return target;
187
+ };
188
+ const onKeyDown = (event)=>{
189
+ if (!onSelect || isIgnoredKey(event)) return false;
190
+ const target = keyTarget(event);
191
+ if (void 0 === target) return false;
192
+ event.preventDefault();
193
+ request(target);
194
+ return true;
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
+ };
208
+ return {
209
+ selectedColumnId,
210
+ select,
211
+ onKeyDown,
212
+ selectAfter,
213
+ refocus: (scroll = true)=>focusCurrent(void 0, scroll)
214
+ };
215
+ };
216
+ exports.isIgnoredKey = __webpack_exports__.isIgnoredKey;
217
+ exports.useSentenceNavigation = __webpack_exports__.useSentenceNavigation;
218
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
219
+ "isIgnoredKey",
220
+ "useSentenceNavigation"
221
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
222
+ Object.defineProperty(exports, '__esModule', {
223
+ value: true
224
+ });
@@ -0,0 +1,21 @@
1
+ import type React from 'react';
2
+ import type { CellCommitMove } from './gridTypes';
3
+ import type { SentenceCellId, SentenceRule, SentenceSelection } from './sentenceTypes';
4
+ import type { RuleWindow } from './useRuleWindow';
5
+ export declare const isIgnoredKey: (event: React.KeyboardEvent) => boolean;
6
+ export interface SentenceNavigationSource extends Pick<RuleWindow, 'selectedRow' | 'container' | 'firstVisibleRow' | 'scrollStopIntoView' | 'scrollRowIntoView'> {
7
+ rules: readonly SentenceRule[];
8
+ selected: SentenceSelection | null | undefined;
9
+ onSelect: ((selection: SentenceSelection | null) => void) | undefined;
10
+ }
11
+ type CardFocus = (card: HTMLElement) => HTMLElement | null;
12
+ export interface SentenceNavigation {
13
+ selectedColumnId: string | null;
14
+ select: (selection: SentenceSelection | null, focus?: CardFocus, scroll?: boolean) => void;
15
+ onKeyDown: (event: React.KeyboardEvent<HTMLElement>) => boolean;
16
+ selectAfter: (from: SentenceCellId, move: CellCommitMove, before: readonly SentenceRule[]) => void;
17
+ refocus: (scroll?: boolean) => void;
18
+ }
19
+ export declare const useSentenceNavigation: ({ rules, selected, selectedRow, onSelect, container, firstVisibleRow, scrollStopIntoView, scrollRowIntoView, }: SentenceNavigationSource) => SentenceNavigation;
20
+ export {};
21
+ //# sourceMappingURL=useSentenceNavigation.d.ts.map
@@ -0,0 +1 @@
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"}