@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.mjs
CHANGED
|
@@ -454,6 +454,10 @@ function observeLayout(node, onChange) {
|
|
|
454
454
|
observer.observe(document.body);
|
|
455
455
|
return observer;
|
|
456
456
|
}
|
|
457
|
+
function isSameRect(a, b) {
|
|
458
|
+
if (a === null || b === null) return a === b;
|
|
459
|
+
return a.top === b.top && a.left === b.left && a.width === b.width && a.bottom === b.bottom;
|
|
460
|
+
}
|
|
457
461
|
function useAnchorTracking(containerRef, onOutOfView) {
|
|
458
462
|
const [rect, setRect] = useState(() => readAnchorRect(containerRef));
|
|
459
463
|
useLayoutEffect(() => {
|
|
@@ -465,7 +469,7 @@ function useAnchorTracking(containerRef, onOutOfView) {
|
|
|
465
469
|
frame = null;
|
|
466
470
|
if (isDisposed) return;
|
|
467
471
|
const next = readAnchorRect(containerRef);
|
|
468
|
-
setRect(next);
|
|
472
|
+
setRect((previous) => isSameRect(previous, next) ? previous : next);
|
|
469
473
|
const isHidden = next !== null && isAnchorHidden(next, readClipBounds(toDomNode(containerRef)), MIN_VISIBLE_PX);
|
|
470
474
|
if (hasMeasured && isHidden) onOutOfView();
|
|
471
475
|
hasMeasured = true;
|
|
@@ -576,6 +580,8 @@ var styles6 = StyleSheet.create({
|
|
|
576
580
|
// node (the `menuRef` outside-click / keyboard logic and the web portal target depend on it).
|
|
577
581
|
// `transformOrigin: 'top'` makes the scale grow downward FROM the anchor rather than the centre.
|
|
578
582
|
animated: { transformOrigin: "top" },
|
|
583
|
+
// Exit fade only: the dying popover must not receive the next click. See the file header.
|
|
584
|
+
inert: { pointerEvents: "none" },
|
|
579
585
|
// Bound the scroll viewport so a list longer than the popover scrolls (with a scrollbar) instead of
|
|
580
586
|
// overflowing the frame — the popover's own maxHeight cannot do this (see MENU_SCROLL_MAX_HEIGHT).
|
|
581
587
|
scroll: { maxHeight: MENU_SCROLL_MAX_HEIGHT }
|
|
@@ -602,12 +608,18 @@ var InlineMenu = ({
|
|
|
602
608
|
[options, value]
|
|
603
609
|
);
|
|
604
610
|
const [highlightedIndex, setHighlightedIndex] = useState(() => selectedIndex);
|
|
611
|
+
const handleSelect = useCallback(
|
|
612
|
+
(optionValue) => {
|
|
613
|
+
if (isOpen) onSelect(optionValue);
|
|
614
|
+
},
|
|
615
|
+
[isOpen, onSelect]
|
|
616
|
+
);
|
|
605
617
|
const selectAt = useCallback(
|
|
606
618
|
(index) => {
|
|
607
619
|
const option = options[index];
|
|
608
|
-
if (option !== void 0)
|
|
620
|
+
if (option !== void 0) handleSelect(option.value);
|
|
609
621
|
},
|
|
610
|
-
[options,
|
|
622
|
+
[options, handleSelect]
|
|
611
623
|
);
|
|
612
624
|
const selectHighlighted = useCallback(
|
|
613
625
|
() => {
|
|
@@ -640,20 +652,28 @@ var InlineMenu = ({
|
|
|
640
652
|
{
|
|
641
653
|
ref: menuRef,
|
|
642
654
|
accessibilityRole: "menu",
|
|
655
|
+
"aria-hidden": !isOpen,
|
|
643
656
|
"aria-label": accessibilityLabel,
|
|
644
657
|
style: popoverStyle,
|
|
645
658
|
testID: `${testID}-menu`,
|
|
646
|
-
children: /* @__PURE__ */ jsx(
|
|
647
|
-
|
|
659
|
+
children: /* @__PURE__ */ jsx(
|
|
660
|
+
Animated.View,
|
|
648
661
|
{
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
662
|
+
pointerEvents: isOpen ? "auto" : "none",
|
|
663
|
+
style: [styles6.animated, animatedStyle, isOpen ? null : styles6.inert],
|
|
664
|
+
children: /* @__PURE__ */ jsx(ScrollView, { style: styles6.scroll, keyboardShouldPersistTaps: "handled", children: options.map((option, index) => /* @__PURE__ */ jsx(
|
|
665
|
+
OptionRow,
|
|
666
|
+
{
|
|
667
|
+
isHighlighted: index === highlightedIndex,
|
|
668
|
+
isSelected: option.value === value,
|
|
669
|
+
label: option.label,
|
|
670
|
+
testID: optionTestID !== void 0 ? optionTestID(option.value) : `${testID}-option-${String(option.value)}`,
|
|
671
|
+
onSelect: () => handleSelect(option.value)
|
|
672
|
+
},
|
|
673
|
+
String(option.value)
|
|
674
|
+
)) })
|
|
675
|
+
}
|
|
676
|
+
)
|
|
657
677
|
}
|
|
658
678
|
);
|
|
659
679
|
if (IS_WEB2) return createPortal(menu, document.body);
|