@sanity/ui 2.8.3 → 2.8.5
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/index.esm.js +11 -19
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +10 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/core/components/dialog/__workshop__/nested.tsx +12 -2
- package/src/core/components/dialog/dialog.tsx +14 -18
- package/src/core/hooks/useClickOutsideEvent.ts +3 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buildTheme, createColorTheme as createColorTheme$1, hexToRgb as hexToRgb$1, hslToRgb as hslToRgb$1, multiply as multiply$1, parseColor as parseColor$1, rgbToHex as rgbToHex$1, rgbToHsl as rgbToHsl$1, rgba as rgba$1, screen as screen$1, getTheme_v2, getScopedTheme } from "@sanity/ui/theme";
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useMemo, useState, useRef, useEffect,
|
|
3
|
+
import { useMemo, useState, useRef, useEffect, useDebugValue, useImperativeHandle, useSyncExternalStore, createContext, useContext, forwardRef, useId, useCallback, Children, isValidElement, cloneElement, Component, memo, useLayoutEffect, useReducer, Fragment as Fragment$1, startTransition } from "react";
|
|
4
4
|
import ReactIs, { isValidElementType } from "react-is";
|
|
5
5
|
import { ThemeProvider as ThemeProvider$1, useTheme as useTheme$1, css, styled, keyframes } from "styled-components";
|
|
6
6
|
import { SpinnerIcon, CheckmarkIcon, RemoveIcon, ChevronDownIcon, CloseIcon, ChevronRightIcon, ToggleArrowRightIcon } from "@sanity/icons";
|
|
@@ -193,7 +193,7 @@ function useClickOutsideEvent(listener, elementsArg = () => EMPTY_ARRAY, boundar
|
|
|
193
193
|
return document.addEventListener("mousedown", handleEvent), () => {
|
|
194
194
|
document.removeEventListener("mousedown", handleEvent);
|
|
195
195
|
};
|
|
196
|
-
}, [hasListener, onEvent]);
|
|
196
|
+
}, [hasListener, onEvent]), useDebugValue(listener ? "MouseDown On" : "MouseDown Off");
|
|
197
197
|
}
|
|
198
198
|
function useCustomValidity(ref, customValidity) {
|
|
199
199
|
useEffect(() => {
|
|
@@ -5132,8 +5132,8 @@ const Root$7 = styled(Layer)(responsivePaddingStyle, dialogStyle, responsiveDial
|
|
|
5132
5132
|
scheme,
|
|
5133
5133
|
shadow: shadowProp,
|
|
5134
5134
|
width: widthProp
|
|
5135
|
-
} = props, portal = usePortal(), portalElement = portalProp ? ((_a = portal.elements) == null ? void 0 : _a[portalProp]) || null : portal.element, boundaryElement = useBoundaryElement().element, radius = useArrayProp(radiusProp), shadow = useArrayProp(shadowProp), width = useArrayProp(widthProp), ref = useRef(null),
|
|
5136
|
-
useImperativeHandle(forwardedRef, () => ref.current), useImperativeHandle(
|
|
5135
|
+
} = props, portal = usePortal(), portalElement = portalProp ? ((_a = portal.elements) == null ? void 0 : _a[portalProp]) || null : portal.element, boundaryElement = useBoundaryElement().element, radius = useArrayProp(radiusProp), shadow = useArrayProp(shadowProp), width = useArrayProp(widthProp), ref = useRef(null), contentRef = useRef(null), layer = useLayer(), { isTopLayer } = layer, labelId = `${id}_label`, showCloseButton = !!onClose && hideCloseButton === !1, showHeader = !!header || showCloseButton;
|
|
5136
|
+
return useImperativeHandle(forwardedRef, () => ref.current), useImperativeHandle(
|
|
5137
5137
|
forwardedContentRef,
|
|
5138
5138
|
() => contentRef.current
|
|
5139
5139
|
), useEffect(() => {
|
|
@@ -5147,21 +5147,13 @@ const Root$7 = styled(Layer)(responsivePaddingStyle, dialogStyle, responsiveDial
|
|
|
5147
5147
|
},
|
|
5148
5148
|
[boundaryElement, isTopLayer, onClose, portalElement]
|
|
5149
5149
|
)
|
|
5150
|
-
),
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
[boundaryElement, isTopLayer, onClickOutside, portalElement]
|
|
5158
|
-
),
|
|
5159
|
-
[rootElement]
|
|
5160
|
-
);
|
|
5161
|
-
const setRef = useCallback((el) => {
|
|
5162
|
-
setRootElement(el), ref.current = el;
|
|
5163
|
-
}, []);
|
|
5164
|
-
return /* @__PURE__ */ jsx(DialogContainer, { "data-ui": "DialogCard", width, children: /* @__PURE__ */ jsx(DialogCardRoot, { radius, ref: setRef, scheme, shadow, children: /* @__PURE__ */ jsxs(DialogLayout, { direction: "column", children: [
|
|
5150
|
+
), useClickOutsideEvent(
|
|
5151
|
+
isTopLayer && onClickOutside && ((event) => {
|
|
5152
|
+
const target = event.target;
|
|
5153
|
+
target && !isTargetWithinScope(boundaryElement, portalElement, target) || onClickOutside();
|
|
5154
|
+
}),
|
|
5155
|
+
() => [ref.current]
|
|
5156
|
+
), /* @__PURE__ */ jsx(DialogContainer, { "data-ui": "DialogCard", width, children: /* @__PURE__ */ jsx(DialogCardRoot, { radius, ref, scheme, shadow, children: /* @__PURE__ */ jsxs(DialogLayout, { direction: "column", children: [
|
|
5165
5157
|
showHeader && /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(Flex, { align: "center", padding: 3, children: [
|
|
5166
5158
|
/* @__PURE__ */ jsx(Box, { flex: 1, padding: 2, children: header && /* @__PURE__ */ jsx(Text, { id: labelId, size: 1, weight: "semibold", children: header }) }),
|
|
5167
5159
|
showCloseButton && /* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsx(
|