@sanity/ui 2.14.1 → 2.14.2
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/_chunks-cjs/_visual-editing.js +3 -4
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +3 -4
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/_legacy/_visual-editing.esm.js +3 -4
- package/dist/_legacy/_visual-editing.esm.js.map +1 -1
- package/dist/index.esm.js +85 -30
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +85 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +85 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -20
package/dist/index.js
CHANGED
|
@@ -7,9 +7,13 @@ function _getElements(element, elementsArg) {
|
|
|
7
7
|
Array.isArray(el) ? ret.push(...el) : ret.push(el);
|
|
8
8
|
return ret.filter(Boolean);
|
|
9
9
|
}
|
|
10
|
-
function useClickOutside(listener,
|
|
11
|
-
const
|
|
12
|
-
|
|
10
|
+
function useClickOutside(listener, t0, boundaryElement) {
|
|
11
|
+
const $ = reactCompilerRuntime.c(12), elementsArg = t0 === void 0 ? _visualEditing.EMPTY_ARRAY : t0, [element, setElement] = react.useState(null);
|
|
12
|
+
let t1;
|
|
13
|
+
$[0] !== element || $[1] !== elementsArg ? (t1 = () => _getElements(element, elementsArg), $[0] = element, $[1] = elementsArg, $[2] = t1) : t1 = $[2];
|
|
14
|
+
const [elements, setElements] = react.useState(t1), elementsRef = react.useRef(elements);
|
|
15
|
+
let t2, t3;
|
|
16
|
+
$[3] !== element || $[4] !== elementsArg ? (t2 = () => {
|
|
13
17
|
const prevElements = elementsRef.current, nextElements = _getElements(element, elementsArg);
|
|
14
18
|
if (prevElements.length !== nextElements.length) {
|
|
15
19
|
setElements(nextElements), elementsRef.current = nextElements;
|
|
@@ -25,8 +29,11 @@ function useClickOutside(listener, elementsArg = _visualEditing.EMPTY_ARRAY, bou
|
|
|
25
29
|
setElements(nextElements), elementsRef.current = nextElements;
|
|
26
30
|
return;
|
|
27
31
|
}
|
|
28
|
-
}, [element, elementsArg]), react.useEffect(
|
|
29
|
-
|
|
32
|
+
}, t3 = [element, elementsArg], $[3] = element, $[4] = elementsArg, $[5] = t2, $[6] = t3) : (t2 = $[5], t3 = $[6]), react.useEffect(t2, t3);
|
|
33
|
+
let t4, t5;
|
|
34
|
+
return $[7] !== boundaryElement || $[8] !== elements || $[9] !== listener ? (t4 = () => {
|
|
35
|
+
if (!listener)
|
|
36
|
+
return;
|
|
30
37
|
const handleWindowMouseDown = (evt) => {
|
|
31
38
|
const target = evt.target;
|
|
32
39
|
if (target instanceof Node && !(boundaryElement && !boundaryElement.contains(target))) {
|
|
@@ -39,7 +46,7 @@ function useClickOutside(listener, elementsArg = _visualEditing.EMPTY_ARRAY, bou
|
|
|
39
46
|
return window.addEventListener("mousedown", handleWindowMouseDown), () => {
|
|
40
47
|
window.removeEventListener("mousedown", handleWindowMouseDown);
|
|
41
48
|
};
|
|
42
|
-
}, [boundaryElement, listener, elements]), setElement;
|
|
49
|
+
}, t5 = [boundaryElement, listener, elements], $[7] = boundaryElement, $[8] = elements, $[9] = listener, $[10] = t4, $[11] = t5) : (t4 = $[10], t5 = $[11]), react.useEffect(t4, t5), setElement;
|
|
43
50
|
}
|
|
44
51
|
function useElementRect(element) {
|
|
45
52
|
return _visualEditing.useElementSize(element)?._contentRect || null;
|
|
@@ -669,8 +676,8 @@ function DialogProvider(props) {
|
|
|
669
676
|
}
|
|
670
677
|
DialogProvider.displayName = "DialogProvider";
|
|
671
678
|
const MenuButton = react.forwardRef(function(props, forwardedRef) {
|
|
672
|
-
const {
|
|
673
|
-
__unstable_disableRestoreFocusOnClose:
|
|
679
|
+
const $ = reactCompilerRuntime.c(62), {
|
|
680
|
+
__unstable_disableRestoreFocusOnClose: t0,
|
|
674
681
|
boundaryElement: deprecated_boundaryElement,
|
|
675
682
|
button: buttonProp,
|
|
676
683
|
id,
|
|
@@ -679,23 +686,38 @@ const MenuButton = react.forwardRef(function(props, forwardedRef) {
|
|
|
679
686
|
onOpen,
|
|
680
687
|
placement: deprecated_placement,
|
|
681
688
|
popoverScheme: deprecated_popoverScheme,
|
|
682
|
-
portal:
|
|
689
|
+
portal: t1,
|
|
683
690
|
popover,
|
|
684
691
|
popoverRadius: deprecated_popoverRadius,
|
|
685
692
|
preventOverflow: deprecated_preventOverflow
|
|
686
|
-
} = props, [open, setOpen] = react.useState(!1), [shouldFocus, setShouldFocus] = react.useState(null), [buttonElement, setButtonElement] = react.useState(null)
|
|
687
|
-
|
|
693
|
+
} = props, disableRestoreFocusOnClose = t0 === void 0 ? !1 : t0, deprecated_portal = t1 === void 0 ? !0 : t1, [open, setOpen] = react.useState(!1), [shouldFocus, setShouldFocus] = react.useState(null), [buttonElement, setButtonElement] = react.useState(null);
|
|
694
|
+
let t2;
|
|
695
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[0] = t2) : t2 = $[0];
|
|
696
|
+
const [menuElements, setChildMenuElements] = react.useState(t2), openRef = react.useRef(open);
|
|
697
|
+
let t3, t4;
|
|
698
|
+
$[1] !== onOpen || $[2] !== open ? (t3 = () => {
|
|
688
699
|
onOpen && open && !openRef.current && onOpen();
|
|
689
|
-
}, [onOpen, open]), react.useEffect(
|
|
700
|
+
}, t4 = [onOpen, open], $[1] = onOpen, $[2] = open, $[3] = t3, $[4] = t4) : (t3 = $[3], t4 = $[4]), react.useEffect(t3, t4);
|
|
701
|
+
let t5, t6;
|
|
702
|
+
$[5] !== onClose || $[6] !== open ? (t5 = () => {
|
|
690
703
|
onClose && !open && openRef.current && onClose();
|
|
691
|
-
}, [onClose, open]), react.useEffect(
|
|
704
|
+
}, t6 = [onClose, open], $[5] = onClose, $[6] = open, $[7] = t5, $[8] = t6) : (t5 = $[7], t6 = $[8]), react.useEffect(t5, t6);
|
|
705
|
+
let t7, t8;
|
|
706
|
+
$[9] !== open ? (t7 = () => {
|
|
692
707
|
openRef.current = open;
|
|
693
|
-
}, [open]);
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
708
|
+
}, t8 = [open], $[9] = open, $[10] = t7, $[11] = t8) : (t7 = $[10], t8 = $[11]), react.useEffect(t7, t8);
|
|
709
|
+
let t9;
|
|
710
|
+
$[12] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => {
|
|
711
|
+
setOpen(_temp$1), setShouldFocus(null);
|
|
712
|
+
}, $[12] = t9) : t9 = $[12];
|
|
713
|
+
const handleButtonClick = t9;
|
|
714
|
+
let t10;
|
|
715
|
+
$[13] !== open ? (t10 = (event) => {
|
|
697
716
|
open && event.preventDefault();
|
|
698
|
-
}, [open
|
|
717
|
+
}, $[13] = open, $[14] = t10) : t10 = $[14];
|
|
718
|
+
const handleMouseDown = t10;
|
|
719
|
+
let t11;
|
|
720
|
+
$[15] === Symbol.for("react.memo_cache_sentinel") ? (t11 = (event_0) => {
|
|
699
721
|
if (event_0.key === "ArrowDown" || event_0.key === "Enter" || event_0.key === " ") {
|
|
700
722
|
event_0.preventDefault(), setOpen(!0), setShouldFocus("first");
|
|
701
723
|
return;
|
|
@@ -704,7 +726,10 @@ const MenuButton = react.forwardRef(function(props, forwardedRef) {
|
|
|
704
726
|
event_0.preventDefault(), setOpen(!0), setShouldFocus("last");
|
|
705
727
|
return;
|
|
706
728
|
}
|
|
707
|
-
}, []
|
|
729
|
+
}, $[15] = t11) : t11 = $[15];
|
|
730
|
+
const handleButtonKeyDown = t11;
|
|
731
|
+
let t12;
|
|
732
|
+
$[16] !== buttonElement || $[17] !== menuElements ? (t12 = (event_1) => {
|
|
708
733
|
const target = event_1.target;
|
|
709
734
|
if (target instanceof Node && !(buttonElement && (target === buttonElement || buttonElement.contains(target)))) {
|
|
710
735
|
for (const el of menuElements)
|
|
@@ -712,9 +737,15 @@ const MenuButton = react.forwardRef(function(props, forwardedRef) {
|
|
|
712
737
|
return;
|
|
713
738
|
setOpen(!1);
|
|
714
739
|
}
|
|
715
|
-
}, [buttonElement, menuElements
|
|
740
|
+
}, $[16] = buttonElement, $[17] = menuElements, $[18] = t12) : t12 = $[18];
|
|
741
|
+
const handleMenuClickOutside = t12;
|
|
742
|
+
let t13;
|
|
743
|
+
$[19] !== buttonElement || $[20] !== disableRestoreFocusOnClose ? (t13 = () => {
|
|
716
744
|
setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus();
|
|
717
|
-
}, [buttonElement, disableRestoreFocusOnClose
|
|
745
|
+
}, $[19] = buttonElement, $[20] = disableRestoreFocusOnClose, $[21] = t13) : t13 = $[21];
|
|
746
|
+
const handleMenuEscape = t13;
|
|
747
|
+
let t14;
|
|
748
|
+
$[22] !== menuElements ? (t14 = (event_2) => {
|
|
718
749
|
const target_0 = event_2.relatedTarget;
|
|
719
750
|
if (target_0 instanceof Node) {
|
|
720
751
|
for (const el_0 of menuElements)
|
|
@@ -722,9 +753,18 @@ const MenuButton = react.forwardRef(function(props, forwardedRef) {
|
|
|
722
753
|
return;
|
|
723
754
|
setOpen(!1);
|
|
724
755
|
}
|
|
725
|
-
}, [menuElements
|
|
756
|
+
}, $[22] = menuElements, $[23] = t14) : t14 = $[23];
|
|
757
|
+
const handleBlur = t14;
|
|
758
|
+
let t15;
|
|
759
|
+
$[24] !== buttonElement || $[25] !== disableRestoreFocusOnClose ? (t15 = () => {
|
|
726
760
|
setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus();
|
|
727
|
-
}, [buttonElement,
|
|
761
|
+
}, $[24] = buttonElement, $[25] = disableRestoreFocusOnClose, $[26] = t15) : t15 = $[26];
|
|
762
|
+
const handleItemClick = t15;
|
|
763
|
+
let t16;
|
|
764
|
+
$[27] === Symbol.for("react.memo_cache_sentinel") ? (t16 = (el_1) => (setChildMenuElements((els) => els.concat([el_1])), () => setChildMenuElements((els_0) => els_0.filter((_el) => _el !== el_1))), $[27] = t16) : t16 = $[27];
|
|
765
|
+
const registerElement = t16;
|
|
766
|
+
let t17;
|
|
767
|
+
$[28] !== buttonElement || $[29] !== handleBlur || $[30] !== handleItemClick || $[31] !== handleMenuClickOutside || $[32] !== handleMenuEscape || $[33] !== id || $[34] !== menuProp || $[35] !== shouldFocus ? (t17 = menuProp && react.cloneElement(menuProp, {
|
|
728
768
|
"aria-labelledby": id,
|
|
729
769
|
onBlurCapture: handleBlur,
|
|
730
770
|
onClickOutside: handleMenuClickOutside,
|
|
@@ -733,7 +773,10 @@ const MenuButton = react.forwardRef(function(props, forwardedRef) {
|
|
|
733
773
|
originElement: buttonElement,
|
|
734
774
|
registerElement,
|
|
735
775
|
shouldFocus
|
|
736
|
-
}),
|
|
776
|
+
}), $[28] = buttonElement, $[29] = handleBlur, $[30] = handleItemClick, $[31] = handleMenuClickOutside, $[32] = handleMenuEscape, $[33] = id, $[34] = menuProp, $[35] = shouldFocus, $[36] = t17) : t17 = $[36];
|
|
777
|
+
const menu = t17;
|
|
778
|
+
let t18, t19;
|
|
779
|
+
$[37] !== buttonProp || $[38] !== handleMouseDown || $[39] !== id || $[40] !== open ? (t19 = buttonProp && react.cloneElement(buttonProp, {
|
|
737
780
|
"data-ui": "MenuButton",
|
|
738
781
|
id,
|
|
739
782
|
onClick: handleButtonClick,
|
|
@@ -743,9 +786,14 @@ const MenuButton = react.forwardRef(function(props, forwardedRef) {
|
|
|
743
786
|
"aria-expanded": open,
|
|
744
787
|
ref: setButtonElement,
|
|
745
788
|
selected: buttonProp.props.selected ?? open
|
|
746
|
-
}), [buttonProp,
|
|
747
|
-
|
|
748
|
-
|
|
789
|
+
}), $[37] = buttonProp, $[38] = handleMouseDown, $[39] = id, $[40] = open, $[41] = t19) : t19 = $[41], t18 = t19;
|
|
790
|
+
const button = t18;
|
|
791
|
+
let t20, t21;
|
|
792
|
+
$[42] !== buttonElement ? (t20 = () => buttonElement, t21 = [buttonElement], $[42] = buttonElement, $[43] = t20, $[44] = t21) : (t20 = $[43], t21 = $[44]), react.useImperativeHandle(forwardedRef, t20, t21);
|
|
793
|
+
let t22, t23;
|
|
794
|
+
$[45] !== popover ? (t23 = popover || {}, $[45] = popover, $[46] = t23) : t23 = $[46];
|
|
795
|
+
let t24;
|
|
796
|
+
$[47] !== deprecated_boundaryElement || $[48] !== deprecated_placement || $[49] !== deprecated_popoverRadius || $[50] !== deprecated_popoverScheme || $[51] !== deprecated_portal || $[52] !== deprecated_preventOverflow || $[53] !== t23 ? (t24 = {
|
|
749
797
|
boundaryElement: deprecated_boundaryElement,
|
|
750
798
|
overflow: "auto",
|
|
751
799
|
placement: deprecated_placement,
|
|
@@ -753,11 +801,18 @@ const MenuButton = react.forwardRef(function(props, forwardedRef) {
|
|
|
753
801
|
preventOverflow: deprecated_preventOverflow,
|
|
754
802
|
radius: deprecated_popoverRadius,
|
|
755
803
|
scheme: deprecated_popoverScheme,
|
|
756
|
-
...
|
|
757
|
-
}
|
|
758
|
-
|
|
804
|
+
...t23
|
|
805
|
+
}, $[47] = deprecated_boundaryElement, $[48] = deprecated_placement, $[49] = deprecated_popoverRadius, $[50] = deprecated_popoverScheme, $[51] = deprecated_portal, $[52] = deprecated_preventOverflow, $[53] = t23, $[54] = t24) : t24 = $[54], t22 = t24;
|
|
806
|
+
const popoverProps = t22;
|
|
807
|
+
let t25;
|
|
808
|
+
$[55] !== button ? (t25 = button || /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {}), $[55] = button, $[56] = t25) : t25 = $[56];
|
|
809
|
+
let t26;
|
|
810
|
+
return $[57] !== menu || $[58] !== open || $[59] !== popoverProps || $[60] !== t25 ? (t26 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Popover, { "data-ui": "MenuButton__popover", ...popoverProps, content: menu, open, children: t25 }), $[57] = menu, $[58] = open, $[59] = popoverProps, $[60] = t25, $[61] = t26) : t26 = $[61], t26;
|
|
759
811
|
});
|
|
760
812
|
MenuButton.displayName = "ForwardRef(MenuButton)";
|
|
813
|
+
function _temp$1(v) {
|
|
814
|
+
return !v;
|
|
815
|
+
}
|
|
761
816
|
const keyframe = styledComponents.keyframes`
|
|
762
817
|
0% {
|
|
763
818
|
background-position: 100%;
|