@uipath/apollo-react 7.17.4 → 7.18.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/BaseNode.cjs +2 -1
- package/dist/canvas/components/BaseNode/BaseNode.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.js +3 -2
- package/dist/canvas/components/ButtonHandle/SmartHandle.cjs +3 -4
- package/dist/canvas/components/ButtonHandle/SmartHandle.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/SmartHandle.js +4 -5
- package/dist/canvas/components/ContainerNode/ContainerNode.hooks.cjs +3 -7
- package/dist/canvas/components/ContainerNode/ContainerNode.hooks.d.ts.map +1 -1
- package/dist/canvas/components/ContainerNode/ContainerNode.hooks.js +4 -8
- package/dist/canvas/hooks/useBatchedUpdateNodeInternals.cjs +59 -0
- package/dist/canvas/hooks/useBatchedUpdateNodeInternals.d.ts +2 -0
- package/dist/canvas/hooks/useBatchedUpdateNodeInternals.d.ts.map +1 -0
- package/dist/canvas/hooks/useBatchedUpdateNodeInternals.js +25 -0
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/chat/styles/tailwind.chat.css +1 -1
- package/dist/decision-table/AddRuleButton.cjs +49 -0
- package/dist/decision-table/AddRuleButton.d.ts +7 -0
- package/dist/decision-table/AddRuleButton.d.ts.map +1 -0
- package/dist/decision-table/AddRuleButton.js +15 -0
- package/dist/decision-table/AddRuleFooter.cjs +46 -0
- package/dist/decision-table/AddRuleFooter.d.ts +9 -0
- package/dist/decision-table/AddRuleFooter.d.ts.map +1 -0
- package/dist/decision-table/AddRuleFooter.js +12 -0
- package/dist/decision-table/BandColumn.cjs +66 -0
- package/dist/decision-table/BandColumn.d.ts +12 -0
- package/dist/decision-table/BandColumn.d.ts.map +1 -0
- package/dist/decision-table/BandColumn.js +32 -0
- package/dist/decision-table/BandList.cjs +54 -0
- package/dist/decision-table/BandList.d.ts +12 -0
- package/dist/decision-table/BandList.d.ts.map +1 -0
- package/dist/decision-table/BandList.js +20 -0
- package/dist/decision-table/ConditionLine.cjs +62 -0
- package/dist/decision-table/ConditionLine.d.ts +10 -0
- package/dist/decision-table/ConditionLine.d.ts.map +1 -0
- package/dist/decision-table/ConditionLine.js +28 -0
- package/dist/decision-table/DecisionText.cjs +122 -0
- package/dist/decision-table/DecisionText.d.ts +28 -0
- package/dist/decision-table/DecisionText.d.ts.map +1 -0
- package/dist/decision-table/DecisionText.js +88 -0
- package/dist/decision-table/DecisionTextHeader.cjs +53 -0
- package/dist/decision-table/DecisionTextHeader.d.ts +7 -0
- package/dist/decision-table/DecisionTextHeader.d.ts.map +1 -0
- package/dist/decision-table/DecisionTextHeader.js +19 -0
- package/dist/decision-table/EmptyRules.cjs +51 -0
- package/dist/decision-table/EmptyRules.d.ts +9 -0
- package/dist/decision-table/EmptyRules.d.ts.map +1 -0
- package/dist/decision-table/EmptyRules.js +17 -0
- package/dist/decision-table/LineLead.cjs +58 -0
- package/dist/decision-table/LineLead.d.ts +10 -0
- package/dist/decision-table/LineLead.d.ts.map +1 -0
- package/dist/decision-table/LineLead.js +24 -0
- package/dist/decision-table/LineText.cjs +108 -0
- package/dist/decision-table/LineText.d.ts +19 -0
- package/dist/decision-table/LineText.d.ts.map +1 -0
- package/dist/decision-table/LineText.js +74 -0
- package/dist/decision-table/MarkBadge.cjs +66 -0
- package/dist/decision-table/MarkBadge.d.ts +13 -0
- package/dist/decision-table/MarkBadge.d.ts.map +1 -0
- package/dist/decision-table/MarkBadge.js +29 -0
- package/dist/decision-table/RuleCard.cjs +109 -0
- package/dist/decision-table/RuleCard.d.ts +8 -0
- package/dist/decision-table/RuleCard.d.ts.map +1 -0
- package/dist/decision-table/RuleCard.js +75 -0
- package/dist/decision-table/RuleLine.cjs +51 -0
- package/dist/decision-table/RuleLine.d.ts +9 -0
- package/dist/decision-table/RuleLine.d.ts.map +1 -0
- package/dist/decision-table/RuleLine.js +17 -0
- package/dist/decision-table/RuleList.cjs +70 -0
- package/dist/decision-table/RuleList.d.ts +20 -0
- package/dist/decision-table/RuleList.d.ts.map +1 -0
- package/dist/decision-table/RuleList.js +36 -0
- package/dist/decision-table/SentenceBands.cjs +60 -0
- package/dist/decision-table/SentenceBands.d.ts +12 -0
- package/dist/decision-table/SentenceBands.d.ts.map +1 -0
- package/dist/decision-table/SentenceBands.js +26 -0
- package/dist/decision-table/StopLabels.cjs +43 -0
- package/dist/decision-table/StopLabels.d.ts +7 -0
- package/dist/decision-table/StopLabels.d.ts.map +1 -0
- package/dist/decision-table/StopLabels.js +9 -0
- package/dist/decision-table/TokenChip.cjs +67 -0
- package/dist/decision-table/TokenChip.d.ts +17 -0
- package/dist/decision-table/TokenChip.d.ts.map +1 -0
- package/dist/decision-table/TokenChip.js +33 -0
- package/dist/decision-table/__fixtures__/sentences.fixtures.d.ts +17 -0
- package/dist/decision-table/__fixtures__/sentences.fixtures.d.ts.map +1 -0
- package/dist/decision-table/gridEvents.cjs +24 -0
- package/dist/decision-table/gridEvents.d.ts +3 -0
- package/dist/decision-table/gridEvents.d.ts.map +1 -1
- package/dist/decision-table/gridEvents.js +16 -1
- package/dist/decision-table/index.cjs +63 -55
- package/dist/decision-table/index.d.ts +5 -0
- package/dist/decision-table/index.d.ts.map +1 -1
- package/dist/decision-table/index.js +2 -1
- package/dist/decision-table/ruleCardModel.cjs +138 -0
- package/dist/decision-table/ruleCardModel.d.ts +38 -0
- package/dist/decision-table/ruleCardModel.d.ts.map +1 -0
- package/dist/decision-table/ruleCardModel.js +101 -0
- package/dist/decision-table/sentenceMarks.cjs +89 -0
- package/dist/decision-table/sentenceMarks.d.ts +27 -0
- package/dist/decision-table/sentenceMarks.d.ts.map +1 -0
- package/dist/decision-table/sentenceMarks.js +43 -0
- package/dist/decision-table/sentenceParts.cjs +100 -0
- package/dist/decision-table/sentenceParts.d.ts +19 -0
- package/dist/decision-table/sentenceParts.d.ts.map +1 -0
- package/dist/decision-table/sentenceParts.js +48 -0
- package/dist/decision-table/sentenceRuleHeights.cjs +70 -0
- package/dist/decision-table/sentenceRuleHeights.d.ts +7 -0
- package/dist/decision-table/sentenceRuleHeights.d.ts.map +1 -0
- package/dist/decision-table/sentenceRuleHeights.js +30 -0
- package/dist/decision-table/sentenceStyles.cjs +166 -0
- package/dist/decision-table/sentenceStyles.d.ts +38 -0
- package/dist/decision-table/sentenceStyles.d.ts.map +1 -0
- package/dist/decision-table/sentenceStyles.js +45 -0
- package/dist/decision-table/sentenceTargets.cjs +74 -0
- package/dist/decision-table/sentenceTargets.d.ts +10 -0
- package/dist/decision-table/sentenceTargets.d.ts.map +1 -0
- package/dist/decision-table/sentenceTargets.js +31 -0
- package/dist/decision-table/sentenceTypes.cjs +18 -0
- package/dist/decision-table/sentenceTypes.d.ts +38 -0
- package/dist/decision-table/sentenceTypes.d.ts.map +1 -0
- package/dist/decision-table/sentenceTypes.js +0 -0
- package/dist/decision-table/styles/tailwind.decision-table.css +1 -1
- package/dist/decision-table/useAddRule.cjs +63 -0
- package/dist/decision-table/useAddRule.d.ts +8 -0
- package/dist/decision-table/useAddRule.d.ts.map +1 -0
- package/dist/decision-table/useAddRule.js +29 -0
- package/dist/decision-table/useCellHover.cjs +55 -0
- package/dist/decision-table/useCellHover.d.ts +4 -0
- package/dist/decision-table/useCellHover.d.ts.map +1 -0
- package/dist/decision-table/useCellHover.js +21 -0
- package/dist/decision-table/useContainerHandlers.cjs +106 -0
- package/dist/decision-table/useContainerHandlers.d.ts +294 -0
- package/dist/decision-table/useContainerHandlers.d.ts.map +1 -0
- package/dist/decision-table/useContainerHandlers.js +72 -0
- package/dist/decision-table/useGridLayout.d.ts +1 -8
- package/dist/decision-table/useGridLayout.d.ts.map +1 -1
- package/dist/decision-table/useGridNavigation.cjs +11 -2
- package/dist/decision-table/useGridNavigation.d.ts +3 -0
- package/dist/decision-table/useGridNavigation.d.ts.map +1 -1
- package/dist/decision-table/useGridNavigation.js +1 -1
- package/dist/decision-table/useHorizontalOverflow.cjs +65 -0
- package/dist/decision-table/useHorizontalOverflow.d.ts +5 -0
- package/dist/decision-table/useHorizontalOverflow.d.ts.map +1 -0
- package/dist/decision-table/useHorizontalOverflow.js +31 -0
- package/dist/decision-table/useRuleWindow.cjs +132 -0
- package/dist/decision-table/useRuleWindow.d.ts +17 -0
- package/dist/decision-table/useRuleWindow.d.ts.map +1 -0
- package/dist/decision-table/useRuleWindow.js +95 -0
- package/dist/decision-table/useSentenceNavigation.cjs +192 -0
- package/dist/decision-table/useSentenceNavigation.d.ts +16 -0
- package/dist/decision-table/useSentenceNavigation.d.ts.map +1 -0
- package/dist/decision-table/useSentenceNavigation.js +158 -0
- package/dist/decision-table/useVirtualizedAxis.cjs +34 -11
- package/dist/decision-table/useVirtualizedAxis.d.ts +1 -1
- package/dist/decision-table/useVirtualizedAxis.d.ts.map +1 -1
- package/dist/decision-table/useVirtualizedAxis.js +34 -11
- package/package.json +4 -4
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { hasLostFocus } from "./gridEvents.js";
|
|
3
|
+
import { clickedSelection, valueTokenAt } from "./sentenceTargets.js";
|
|
4
|
+
const isTabOnView = (event)=>'Tab' === event.key && !event.shiftKey && event.target === event.currentTarget;
|
|
5
|
+
const useContainerHandlers = ({ containerProps, hoverTo, navigation, container, stopTabbable })=>{
|
|
6
|
+
const focusWithinRef = useRef(false);
|
|
7
|
+
const pressedRef = useRef(false);
|
|
8
|
+
const [focusInside, setFocusInside] = useState(false);
|
|
9
|
+
useEffect(()=>{
|
|
10
|
+
const view = container();
|
|
11
|
+
if (focusWithinRef.current && view && hasLostFocus(view)) view.focus();
|
|
12
|
+
});
|
|
13
|
+
const { onPointerOver: consumerPointerOver, onPointerOut: consumerPointerOut, onKeyDown: consumerKeyDown, onFocus: consumerFocus, onBlur: consumerBlur, onClick: consumerClick, onPointerDown: consumerPointerDown, onPointerCancel: consumerPointerCancel, ...restContainerProps } = containerProps ?? {};
|
|
14
|
+
const onPointerOver = (event)=>{
|
|
15
|
+
hoverTo(valueTokenAt(event.target));
|
|
16
|
+
consumerPointerOver?.(event);
|
|
17
|
+
};
|
|
18
|
+
const onPointerDown = (event)=>{
|
|
19
|
+
pressedRef.current = true;
|
|
20
|
+
consumerPointerDown?.(event);
|
|
21
|
+
};
|
|
22
|
+
const onPointerCancel = (event)=>{
|
|
23
|
+
pressedRef.current = false;
|
|
24
|
+
consumerPointerCancel?.(event);
|
|
25
|
+
};
|
|
26
|
+
const onPointerOut = (event)=>{
|
|
27
|
+
const to = event.relatedTarget instanceof Node ? event.relatedTarget : null;
|
|
28
|
+
if (!event.currentTarget.contains(to)) hoverTo(null);
|
|
29
|
+
consumerPointerOut?.(event);
|
|
30
|
+
};
|
|
31
|
+
const onKeyDown = (event)=>{
|
|
32
|
+
if (stopTabbable && isTabOnView(event)) {
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
navigation.refocus();
|
|
35
|
+
} else if (navigation.onKeyDown(event)) return;
|
|
36
|
+
consumerKeyDown?.(event);
|
|
37
|
+
};
|
|
38
|
+
const onFocus = (event)=>{
|
|
39
|
+
const entered = !focusWithinRef.current && event.target === event.currentTarget;
|
|
40
|
+
focusWithinRef.current = true;
|
|
41
|
+
setFocusInside(true);
|
|
42
|
+
if (entered && stopTabbable && !pressedRef.current) navigation.refocus();
|
|
43
|
+
consumerFocus?.(event);
|
|
44
|
+
};
|
|
45
|
+
const onBlur = (event)=>{
|
|
46
|
+
if (!(event.relatedTarget instanceof Node) || !event.currentTarget.contains(event.relatedTarget)) {
|
|
47
|
+
focusWithinRef.current = false;
|
|
48
|
+
pressedRef.current = false;
|
|
49
|
+
setFocusInside(false);
|
|
50
|
+
}
|
|
51
|
+
consumerBlur?.(event);
|
|
52
|
+
};
|
|
53
|
+
const onClick = (event)=>{
|
|
54
|
+
pressedRef.current = false;
|
|
55
|
+
const selection = clickedSelection(event.target);
|
|
56
|
+
if (selection) navigation.select(selection, false);
|
|
57
|
+
consumerClick?.(event);
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
...restContainerProps,
|
|
61
|
+
tabIndex: stopTabbable && focusInside ? -1 : 0,
|
|
62
|
+
onPointerOver,
|
|
63
|
+
onPointerDown,
|
|
64
|
+
onPointerCancel,
|
|
65
|
+
onPointerOut,
|
|
66
|
+
onKeyDown,
|
|
67
|
+
onFocus,
|
|
68
|
+
onBlur,
|
|
69
|
+
onClick
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export { useContainerHandlers };
|
|
@@ -26,14 +26,7 @@ export declare const useGridLayout: ({ columns, rowCount, rowHeightPx, leadingCo
|
|
|
26
26
|
trailingColumnWidth: number;
|
|
27
27
|
containerRef: React.MutableRefObject<HTMLDivElement | null>;
|
|
28
28
|
visibleColumns: VisibleGridColumn[];
|
|
29
|
-
rowSegments: (
|
|
30
|
-
type: "items";
|
|
31
|
-
from: number;
|
|
32
|
-
to: number;
|
|
33
|
-
} | {
|
|
34
|
-
type: "spacer";
|
|
35
|
-
sizePx: number;
|
|
36
|
-
})[];
|
|
29
|
+
rowSegments: import("./useVirtualizedAxis").AxisSegment[];
|
|
37
30
|
theadRef: (element: HTMLTableSectionElement | null) => void;
|
|
38
31
|
attachContainer: (element: HTMLDivElement | null) => void;
|
|
39
32
|
setTableElement: (table: HTMLTableElement | null) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGridLayout.d.ts","sourceRoot":"","sources":["../../src/decision-table/useGridLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,KAAK,EAAY,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAI3E,UAAU,iBAAiB;IACzB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IAEjB,WAAW,EAAE,MAAM,CAAC;IAEpB,kBAAkB,EAAE,MAAM,CAAC;IAE3B,mBAAm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CAAC,CAAC,GAAG,IAAI,CAAC;IAErF,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;IAEhE,YAAY,EAAE,KAAK,CAAC,gBAAgB,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAE5D,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAWD,eAAO,MAAM,oBAAoB,GAAI,SAAS,UAAU,EAAE,EAAE,oBAAe,KAAG,GAAG,CAAC,MAAM,CASvF,CAAC;AA6BF,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AAa1D,eAAO,MAAM,aAAa,GAAI,iMAY3B,iBAAiB;;;;;;;;;;;;wBAwCqB,uBAAuB,GAAG,IAAI;+BAoJzD,cAAc,GAAG,IAAI;;;;kCAbpB,MAAM;wCAIH,MAAM;;;;CAwCvB,CAAC"}
|
|
@@ -24,8 +24,11 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
useGridNavigation: ()=>useGridNavigation,
|
|
28
|
+
clamp: ()=>clamp,
|
|
29
|
+
GRID_ENTRY_KEYS: ()=>GRID_ENTRY_KEYS,
|
|
30
|
+
ARROW_DELTAS: ()=>ARROW_DELTAS,
|
|
31
|
+
normalizedRect: ()=>normalizedRect
|
|
29
32
|
});
|
|
30
33
|
const external_react_namespaceObject = require("react");
|
|
31
34
|
const external_react_dom_namespaceObject = require("react-dom");
|
|
@@ -430,9 +433,15 @@ const useGridNavigation = ({ table, rowIds, colIds }, options = {})=>{
|
|
|
430
433
|
onKeyDown
|
|
431
434
|
};
|
|
432
435
|
};
|
|
436
|
+
exports.ARROW_DELTAS = __webpack_exports__.ARROW_DELTAS;
|
|
437
|
+
exports.GRID_ENTRY_KEYS = __webpack_exports__.GRID_ENTRY_KEYS;
|
|
438
|
+
exports.clamp = __webpack_exports__.clamp;
|
|
433
439
|
exports.normalizedRect = __webpack_exports__.normalizedRect;
|
|
434
440
|
exports.useGridNavigation = __webpack_exports__.useGridNavigation;
|
|
435
441
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
442
|
+
"ARROW_DELTAS",
|
|
443
|
+
"GRID_ENTRY_KEYS",
|
|
444
|
+
"clamp",
|
|
436
445
|
"normalizedRect",
|
|
437
446
|
"useGridNavigation"
|
|
438
447
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
@@ -47,6 +47,9 @@ export interface GridNavigation {
|
|
|
47
47
|
cancelEdit: () => void;
|
|
48
48
|
onKeyDown: (event: React.KeyboardEvent) => void;
|
|
49
49
|
}
|
|
50
|
+
export declare const clamp: (value: number, max: number) => number;
|
|
51
|
+
export declare const GRID_ENTRY_KEYS: readonly string[];
|
|
52
|
+
export declare const ARROW_DELTAS: Readonly<Record<string, GridPosition | undefined>>;
|
|
50
53
|
export interface GridNavigationOptions {
|
|
51
54
|
onSelectionReplaced?: (gesture: SelectionGesture) => void;
|
|
52
55
|
canEditAt?: (position: GridPosition, gesture: EditGesture) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGridNavigation.d.ts","sourceRoot":"","sources":["../../src/decision-table/useGridNavigation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE3E,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;AAOxC,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,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
@@ -0,0 +1,65 @@
|
|
|
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
|
+
useHorizontalOverflow: ()=>useHorizontalOverflow
|
|
28
|
+
});
|
|
29
|
+
const external_react_namespaceObject = require("react");
|
|
30
|
+
const useHorizontalOverflow = ()=>{
|
|
31
|
+
const ref = (0, external_react_namespaceObject.useRef)(null);
|
|
32
|
+
const [overflows, setOverflows] = (0, external_react_namespaceObject.useState)(false);
|
|
33
|
+
(0, external_react_namespaceObject.useLayoutEffect)(()=>{
|
|
34
|
+
const element = ref.current;
|
|
35
|
+
if (!element) return;
|
|
36
|
+
const measure = ()=>setOverflows(element.scrollWidth > element.clientWidth);
|
|
37
|
+
const resizes = new ResizeObserver(measure);
|
|
38
|
+
const observe = ()=>{
|
|
39
|
+
resizes.disconnect();
|
|
40
|
+
resizes.observe(element);
|
|
41
|
+
for (const child of element.children)resizes.observe(child);
|
|
42
|
+
measure();
|
|
43
|
+
};
|
|
44
|
+
const mutations = new MutationObserver(observe);
|
|
45
|
+
observe();
|
|
46
|
+
mutations.observe(element, {
|
|
47
|
+
childList: true
|
|
48
|
+
});
|
|
49
|
+
return ()=>{
|
|
50
|
+
mutations.disconnect();
|
|
51
|
+
resizes.disconnect();
|
|
52
|
+
};
|
|
53
|
+
}, []);
|
|
54
|
+
return {
|
|
55
|
+
ref,
|
|
56
|
+
overflows
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
exports.useHorizontalOverflow = __webpack_exports__.useHorizontalOverflow;
|
|
60
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
61
|
+
"useHorizontalOverflow"
|
|
62
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
63
|
+
Object.defineProperty(exports, '__esModule', {
|
|
64
|
+
value: true
|
|
65
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHorizontalOverflow.d.ts","sourceRoot":"","sources":["../../src/decision-table/useHorizontalOverflow.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,WAAW;;;CAuB1D,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
2
|
+
const useHorizontalOverflow = ()=>{
|
|
3
|
+
const ref = useRef(null);
|
|
4
|
+
const [overflows, setOverflows] = useState(false);
|
|
5
|
+
useLayoutEffect(()=>{
|
|
6
|
+
const element = ref.current;
|
|
7
|
+
if (!element) return;
|
|
8
|
+
const measure = ()=>setOverflows(element.scrollWidth > element.clientWidth);
|
|
9
|
+
const resizes = new ResizeObserver(measure);
|
|
10
|
+
const observe = ()=>{
|
|
11
|
+
resizes.disconnect();
|
|
12
|
+
resizes.observe(element);
|
|
13
|
+
for (const child of element.children)resizes.observe(child);
|
|
14
|
+
measure();
|
|
15
|
+
};
|
|
16
|
+
const mutations = new MutationObserver(observe);
|
|
17
|
+
observe();
|
|
18
|
+
mutations.observe(element, {
|
|
19
|
+
childList: true
|
|
20
|
+
});
|
|
21
|
+
return ()=>{
|
|
22
|
+
mutations.disconnect();
|
|
23
|
+
resizes.disconnect();
|
|
24
|
+
};
|
|
25
|
+
}, []);
|
|
26
|
+
return {
|
|
27
|
+
ref,
|
|
28
|
+
overflows
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export { useHorizontalOverflow };
|
|
@@ -0,0 +1,132 @@
|
|
|
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)=>{
|
|
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 { segments, measureRef, scrollItemIntoView } = (0, external_useVirtualizedAxis_cjs_namespaceObject.useVirtualizedAxis)(rules.length, external_sentenceRuleHeights_cjs_namespaceObject.SENTENCE_MIN_RULE_HEIGHT_PX, selectedRow, {
|
|
69
|
+
axis: 'vertical',
|
|
70
|
+
overscanItems: SENTENCE_RULE_OVERSCAN,
|
|
71
|
+
fallbackViewportPx: external_constants_cjs_namespaceObject.FALLBACK_ROW_VIEWPORT_PX,
|
|
72
|
+
leadingFixedPx: listStart,
|
|
73
|
+
stickyLeadingPx: headerHeight,
|
|
74
|
+
itemOffsetsPx: offsetsPx
|
|
75
|
+
});
|
|
76
|
+
const mountedRowIds = segments.flatMap((segment)=>'items' === segment.type ? rules.slice(segment.from, segment.to).map(({ rowId })=>rowId) : []).join('\n');
|
|
77
|
+
(0, external_react_namespaceObject.useLayoutEffect)(()=>{
|
|
78
|
+
const list = listRef.current;
|
|
79
|
+
if (!list || "u" < typeof ResizeObserver) return;
|
|
80
|
+
const observer = new ResizeObserver((entries)=>setMeasured((current)=>measuredHeights(current, entries)));
|
|
81
|
+
for (const card of list.querySelectorAll(':scope > li[data-row-id]'))observer.observe(card);
|
|
82
|
+
return ()=>observer.disconnect();
|
|
83
|
+
}, [
|
|
84
|
+
mountedRowIds
|
|
85
|
+
]);
|
|
86
|
+
const attachSection = (0, external_react_namespaceObject.useCallback)((element)=>{
|
|
87
|
+
sectionRef.current = element;
|
|
88
|
+
measureRef(element);
|
|
89
|
+
}, [
|
|
90
|
+
measureRef
|
|
91
|
+
]);
|
|
92
|
+
const container = (0, external_react_namespaceObject.useCallback)(()=>sectionRef.current, []);
|
|
93
|
+
const scrollRowIntoView = (0, external_react_namespaceObject.useCallback)((rowIndex)=>scrollItemIntoView(sectionRef.current, rowIndex), [
|
|
94
|
+
scrollItemIntoView
|
|
95
|
+
]);
|
|
96
|
+
const firstVisibleRow = ()=>{
|
|
97
|
+
const top = (sectionRef.current?.scrollTop ?? 0) + headerHeight() - listStart();
|
|
98
|
+
const end = offsetsPx.findIndex((offset)=>offset > top);
|
|
99
|
+
return end < 0 ? rules.length - 1 : Math.max(0, end - 1);
|
|
100
|
+
};
|
|
101
|
+
const scrollStopIntoView = (rowIndex, stop)=>{
|
|
102
|
+
const section = sectionRef.current;
|
|
103
|
+
if (!section) return;
|
|
104
|
+
const rowHeight = (offsetsPx[rowIndex + 1] ?? 0) - (offsetsPx[rowIndex] ?? 0);
|
|
105
|
+
if (rowHeight <= (section.clientHeight || external_constants_cjs_namespaceObject.FALLBACK_ROW_VIEWPORT_PX) - headerHeight()) scrollRowIntoView(rowIndex);
|
|
106
|
+
const top = section.getBoundingClientRect().top + headerHeight();
|
|
107
|
+
const bottom = section.getBoundingClientRect().top + section.clientHeight;
|
|
108
|
+
const { top: stopTop, bottom: stopBottom } = stop.getBoundingClientRect();
|
|
109
|
+
if (stopTop < top || stopBottom - stopTop > bottom - top) section.scrollTop -= top - stopTop;
|
|
110
|
+
else if (stopBottom > bottom) section.scrollTop += stopBottom - bottom;
|
|
111
|
+
};
|
|
112
|
+
return {
|
|
113
|
+
listRef,
|
|
114
|
+
headerRef,
|
|
115
|
+
segments,
|
|
116
|
+
selectedRow,
|
|
117
|
+
attachSection,
|
|
118
|
+
container,
|
|
119
|
+
scrollRowIntoView,
|
|
120
|
+
firstVisibleRow,
|
|
121
|
+
scrollStopIntoView
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
exports.SENTENCE_RULE_OVERSCAN = __webpack_exports__.SENTENCE_RULE_OVERSCAN;
|
|
125
|
+
exports.useRuleWindow = __webpack_exports__.useRuleWindow;
|
|
126
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
127
|
+
"SENTENCE_RULE_OVERSCAN",
|
|
128
|
+
"useRuleWindow"
|
|
129
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
130
|
+
Object.defineProperty(exports, '__esModule', {
|
|
131
|
+
value: true
|
|
132
|
+
});
|
|
@@ -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) => 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,KAChC,UAqFF,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
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)=>{
|
|
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 { segments, measureRef, scrollItemIntoView } = useVirtualizedAxis(rules.length, SENTENCE_MIN_RULE_HEIGHT_PX, selectedRow, {
|
|
40
|
+
axis: 'vertical',
|
|
41
|
+
overscanItems: SENTENCE_RULE_OVERSCAN,
|
|
42
|
+
fallbackViewportPx: FALLBACK_ROW_VIEWPORT_PX,
|
|
43
|
+
leadingFixedPx: listStart,
|
|
44
|
+
stickyLeadingPx: headerHeight,
|
|
45
|
+
itemOffsetsPx: offsetsPx
|
|
46
|
+
});
|
|
47
|
+
const mountedRowIds = segments.flatMap((segment)=>'items' === segment.type ? rules.slice(segment.from, segment.to).map(({ rowId })=>rowId) : []).join('\n');
|
|
48
|
+
useLayoutEffect(()=>{
|
|
49
|
+
const list = listRef.current;
|
|
50
|
+
if (!list || "u" < typeof ResizeObserver) return;
|
|
51
|
+
const observer = new ResizeObserver((entries)=>setMeasured((current)=>measuredHeights(current, entries)));
|
|
52
|
+
for (const card of list.querySelectorAll(':scope > li[data-row-id]'))observer.observe(card);
|
|
53
|
+
return ()=>observer.disconnect();
|
|
54
|
+
}, [
|
|
55
|
+
mountedRowIds
|
|
56
|
+
]);
|
|
57
|
+
const attachSection = useCallback((element)=>{
|
|
58
|
+
sectionRef.current = element;
|
|
59
|
+
measureRef(element);
|
|
60
|
+
}, [
|
|
61
|
+
measureRef
|
|
62
|
+
]);
|
|
63
|
+
const container = useCallback(()=>sectionRef.current, []);
|
|
64
|
+
const scrollRowIntoView = useCallback((rowIndex)=>scrollItemIntoView(sectionRef.current, rowIndex), [
|
|
65
|
+
scrollItemIntoView
|
|
66
|
+
]);
|
|
67
|
+
const firstVisibleRow = ()=>{
|
|
68
|
+
const top = (sectionRef.current?.scrollTop ?? 0) + headerHeight() - listStart();
|
|
69
|
+
const end = offsetsPx.findIndex((offset)=>offset > top);
|
|
70
|
+
return end < 0 ? rules.length - 1 : Math.max(0, end - 1);
|
|
71
|
+
};
|
|
72
|
+
const scrollStopIntoView = (rowIndex, stop)=>{
|
|
73
|
+
const section = sectionRef.current;
|
|
74
|
+
if (!section) return;
|
|
75
|
+
const rowHeight = (offsetsPx[rowIndex + 1] ?? 0) - (offsetsPx[rowIndex] ?? 0);
|
|
76
|
+
if (rowHeight <= (section.clientHeight || FALLBACK_ROW_VIEWPORT_PX) - headerHeight()) scrollRowIntoView(rowIndex);
|
|
77
|
+
const top = section.getBoundingClientRect().top + headerHeight();
|
|
78
|
+
const bottom = section.getBoundingClientRect().top + section.clientHeight;
|
|
79
|
+
const { top: stopTop, bottom: stopBottom } = stop.getBoundingClientRect();
|
|
80
|
+
if (stopTop < top || stopBottom - stopTop > bottom - top) section.scrollTop -= top - stopTop;
|
|
81
|
+
else if (stopBottom > bottom) section.scrollTop += stopBottom - bottom;
|
|
82
|
+
};
|
|
83
|
+
return {
|
|
84
|
+
listRef,
|
|
85
|
+
headerRef,
|
|
86
|
+
segments,
|
|
87
|
+
selectedRow,
|
|
88
|
+
attachSection,
|
|
89
|
+
container,
|
|
90
|
+
scrollRowIntoView,
|
|
91
|
+
firstVisibleRow,
|
|
92
|
+
scrollStopIntoView
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
export { SENTENCE_RULE_OVERSCAN, useRuleWindow };
|