@dloizides/ui-layout 1.26.1 → 1.26.3
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/CHANGELOG.md +631 -605
- package/dist/index.js +33 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -460,6 +460,10 @@ function observeLayout(node, onChange) {
|
|
|
460
460
|
observer.observe(document.body);
|
|
461
461
|
return observer;
|
|
462
462
|
}
|
|
463
|
+
function isSameRect(a, b) {
|
|
464
|
+
if (a === null || b === null) return a === b;
|
|
465
|
+
return a.top === b.top && a.left === b.left && a.width === b.width && a.bottom === b.bottom;
|
|
466
|
+
}
|
|
463
467
|
function useAnchorTracking(containerRef, onOutOfView) {
|
|
464
468
|
const [rect, setRect] = React10.useState(() => readAnchorRect(containerRef));
|
|
465
469
|
React10.useLayoutEffect(() => {
|
|
@@ -471,7 +475,7 @@ function useAnchorTracking(containerRef, onOutOfView) {
|
|
|
471
475
|
frame = null;
|
|
472
476
|
if (isDisposed) return;
|
|
473
477
|
const next = readAnchorRect(containerRef);
|
|
474
|
-
setRect(next);
|
|
478
|
+
setRect((previous) => isSameRect(previous, next) ? previous : next);
|
|
475
479
|
const isHidden = next !== null && isAnchorHidden(next, readClipBounds(toDomNode(containerRef)), MIN_VISIBLE_PX);
|
|
476
480
|
if (hasMeasured && isHidden) onOutOfView();
|
|
477
481
|
hasMeasured = true;
|
|
@@ -582,6 +586,8 @@ var styles6 = reactNative.StyleSheet.create({
|
|
|
582
586
|
// node (the `menuRef` outside-click / keyboard logic and the web portal target depend on it).
|
|
583
587
|
// `transformOrigin: 'top'` makes the scale grow downward FROM the anchor rather than the centre.
|
|
584
588
|
animated: { transformOrigin: "top" },
|
|
589
|
+
// Exit fade only: the dying popover must not receive the next click. See the file header.
|
|
590
|
+
inert: { pointerEvents: "none" },
|
|
585
591
|
// Bound the scroll viewport so a list longer than the popover scrolls (with a scrollbar) instead of
|
|
586
592
|
// overflowing the frame — the popover's own maxHeight cannot do this (see MENU_SCROLL_MAX_HEIGHT).
|
|
587
593
|
scroll: { maxHeight: MENU_SCROLL_MAX_HEIGHT }
|
|
@@ -608,12 +614,18 @@ var InlineMenu = ({
|
|
|
608
614
|
[options, value]
|
|
609
615
|
);
|
|
610
616
|
const [highlightedIndex, setHighlightedIndex] = React10.useState(() => selectedIndex);
|
|
617
|
+
const handleSelect = React10.useCallback(
|
|
618
|
+
(optionValue) => {
|
|
619
|
+
if (isOpen) onSelect(optionValue);
|
|
620
|
+
},
|
|
621
|
+
[isOpen, onSelect]
|
|
622
|
+
);
|
|
611
623
|
const selectAt = React10.useCallback(
|
|
612
624
|
(index) => {
|
|
613
625
|
const option = options[index];
|
|
614
|
-
if (option !== void 0)
|
|
626
|
+
if (option !== void 0) handleSelect(option.value);
|
|
615
627
|
},
|
|
616
|
-
[options,
|
|
628
|
+
[options, handleSelect]
|
|
617
629
|
);
|
|
618
630
|
const selectHighlighted = React10.useCallback(
|
|
619
631
|
() => {
|
|
@@ -646,20 +658,28 @@ var InlineMenu = ({
|
|
|
646
658
|
{
|
|
647
659
|
ref: menuRef,
|
|
648
660
|
accessibilityRole: "menu",
|
|
661
|
+
"aria-hidden": !isOpen,
|
|
649
662
|
"aria-label": accessibilityLabel,
|
|
650
663
|
style: popoverStyle,
|
|
651
664
|
testID: `${testID}-menu`,
|
|
652
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
653
|
-
|
|
665
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
666
|
+
reactNative.Animated.View,
|
|
654
667
|
{
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
668
|
+
pointerEvents: isOpen ? "auto" : "none",
|
|
669
|
+
style: [styles6.animated, animatedStyle, isOpen ? null : styles6.inert],
|
|
670
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { style: styles6.scroll, keyboardShouldPersistTaps: "handled", children: options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
671
|
+
OptionRow,
|
|
672
|
+
{
|
|
673
|
+
isHighlighted: index === highlightedIndex,
|
|
674
|
+
isSelected: option.value === value,
|
|
675
|
+
label: option.label,
|
|
676
|
+
testID: optionTestID !== void 0 ? optionTestID(option.value) : `${testID}-option-${String(option.value)}`,
|
|
677
|
+
onSelect: () => handleSelect(option.value)
|
|
678
|
+
},
|
|
679
|
+
String(option.value)
|
|
680
|
+
)) })
|
|
681
|
+
}
|
|
682
|
+
)
|
|
663
683
|
}
|
|
664
684
|
);
|
|
665
685
|
if (IS_WEB2) return reactDom.createPortal(menu, document.body);
|