@sanity/ui 1.4.0 → 1.5.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/index.cjs.mjs +0 -2
- package/dist/index.d.ts +1 -27
- package/dist/index.esm.js +31 -70
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +30 -71
- package/dist/index.js.map +1 -1
- package/package.json +38 -38
- package/src/components/menu/__workshop__/menuButton.tsx +2 -0
- package/src/components/menu/menuButton.tsx +10 -0
- package/src/primitives/popover/__workshop__/index.ts +0 -5
- package/src/primitives/popover/index.ts +0 -3
- package/src/primitives/popover/popover.tsx +0 -8
- package/src/primitives/popover/__workshop__/PositionStory.tsx +0 -103
- package/src/primitives/popover/popover.test.tsx +0 -164
- package/src/primitives/popover/popoverContext.tsx +0 -9
- package/src/primitives/popover/popoverProvider.tsx +0 -29
- package/src/primitives/popover/types.ts +0 -8
- package/src/primitives/popover/useOnForcedUpdate.ts +0 -15
- package/src/primitives/popover/usePopover.ts +0 -24
package/dist/index.js
CHANGED
|
@@ -3076,9 +3076,9 @@ function getGlobalScope() {
|
|
|
3076
3076
|
throw new Error("@sanity/ui: could not locate global scope");
|
|
3077
3077
|
}
|
|
3078
3078
|
const globalScope = getGlobalScope();
|
|
3079
|
-
const key$
|
|
3080
|
-
globalScope[key$
|
|
3081
|
-
const ThemeContext = globalScope[key$
|
|
3079
|
+
const key$7 = Symbol.for("@sanity/ui/context/theme");
|
|
3080
|
+
globalScope[key$7] = globalScope[key$7] || react.createContext(null);
|
|
3081
|
+
const ThemeContext = globalScope[key$7];
|
|
3082
3082
|
function ThemeProvider(props) {
|
|
3083
3083
|
const parentTheme = react.useContext(ThemeContext);
|
|
3084
3084
|
const {
|
|
@@ -5168,9 +5168,9 @@ const KBD = react.forwardRef(function KBD2(props, ref) {
|
|
|
5168
5168
|
})
|
|
5169
5169
|
});
|
|
5170
5170
|
});
|
|
5171
|
-
const key$
|
|
5172
|
-
globalScope[key$
|
|
5173
|
-
const BoundaryElementContext = globalScope[key$
|
|
5171
|
+
const key$6 = Symbol.for("@sanity/ui/context/boundaryElement");
|
|
5172
|
+
globalScope[key$6] = globalScope[key$6] || react.createContext(null);
|
|
5173
|
+
const BoundaryElementContext = globalScope[key$6];
|
|
5174
5174
|
function BoundaryElementProvider(props) {
|
|
5175
5175
|
const {
|
|
5176
5176
|
children,
|
|
@@ -5288,9 +5288,9 @@ function getLayerContext(contextValue) {
|
|
|
5288
5288
|
}
|
|
5289
5289
|
throw new Error("could not get layer context");
|
|
5290
5290
|
}
|
|
5291
|
-
const key$
|
|
5292
|
-
globalScope[key$
|
|
5293
|
-
const LayerContext = globalScope[key$
|
|
5291
|
+
const key$5 = Symbol.for("@sanity/ui/context/layer");
|
|
5292
|
+
globalScope[key$5] = globalScope[key$5] || react.createContext(null);
|
|
5293
|
+
const LayerContext = globalScope[key$5];
|
|
5294
5294
|
function useLayer() {
|
|
5295
5295
|
const value = react.useContext(LayerContext);
|
|
5296
5296
|
if (!value) {
|
|
@@ -5527,7 +5527,7 @@ const Layer = react.forwardRef(function Layer2(props, ref) {
|
|
|
5527
5527
|
})
|
|
5528
5528
|
});
|
|
5529
5529
|
});
|
|
5530
|
-
const key$
|
|
5530
|
+
const key$4 = Symbol.for("@sanity/ui/context/portal");
|
|
5531
5531
|
const elementKey = Symbol.for("@sanity/ui/context/portal/element");
|
|
5532
5532
|
globalScope[elementKey] = null;
|
|
5533
5533
|
const defaultContextValue = {
|
|
@@ -5546,8 +5546,8 @@ const defaultContextValue = {
|
|
|
5546
5546
|
return globalScope[elementKey];
|
|
5547
5547
|
}
|
|
5548
5548
|
};
|
|
5549
|
-
globalScope[key$
|
|
5550
|
-
const PortalContext = globalScope[key$
|
|
5549
|
+
globalScope[key$4] = globalScope[key$4] || react.createContext(defaultContextValue);
|
|
5550
|
+
const PortalContext = globalScope[key$4];
|
|
5551
5551
|
function usePortal() {
|
|
5552
5552
|
const value = react.useContext(PortalContext);
|
|
5553
5553
|
if (!value) {
|
|
@@ -5927,17 +5927,6 @@ const PopoverCard = react.memo(react.forwardRef(function PopoverCard2(props, ref
|
|
|
5927
5927
|
});
|
|
5928
5928
|
}));
|
|
5929
5929
|
PopoverCard.displayName = "PopoverCard";
|
|
5930
|
-
const key$4 = Symbol.for("@sanity/ui/context/popover");
|
|
5931
|
-
globalScope[key$4] = globalScope[key$4] || react.createContext(null);
|
|
5932
|
-
const PopoverContext = globalScope[key$4];
|
|
5933
|
-
const useOnForcedUpdate = eventHandler => {
|
|
5934
|
-
const contextValue = react.useContext(PopoverContext);
|
|
5935
|
-
react.useEffect(() => {
|
|
5936
|
-
if ((contextValue == null ? void 0 : contextValue.lastUpdateId) !== null) {
|
|
5937
|
-
eventHandler == null ? void 0 : eventHandler();
|
|
5938
|
-
}
|
|
5939
|
-
}, [contextValue == null ? void 0 : contextValue.lastUpdateId]);
|
|
5940
|
-
};
|
|
5941
5930
|
const Popover = react.memo(react.forwardRef(function Popover2(props, ref) {
|
|
5942
5931
|
var _a, _b, _c, _d, _e;
|
|
5943
5932
|
const theme = useTheme();
|
|
@@ -6044,13 +6033,9 @@ const Popover = react.memo(react.forwardRef(function Popover2(props, ref) {
|
|
|
6044
6033
|
placement,
|
|
6045
6034
|
reference: referenceRef,
|
|
6046
6035
|
floating: floatingRef,
|
|
6047
|
-
update: floatingUpdate,
|
|
6048
6036
|
middlewareData,
|
|
6049
6037
|
strategy
|
|
6050
6038
|
} = reactDom$1.useFloating(floatingProps);
|
|
6051
|
-
const handleForcedUpdate = react.useCallback(() => {
|
|
6052
|
-
floatingUpdate();
|
|
6053
|
-
}, [floatingUpdate]);
|
|
6054
6039
|
const referenceHidden = (_c = middlewareData.hide) == null ? void 0 : _c.referenceHidden;
|
|
6055
6040
|
const arrowX = (_d = middlewareData.arrow) == null ? void 0 : _d.x;
|
|
6056
6041
|
const arrowY = (_e = middlewareData.arrow) == null ? void 0 : _e.y;
|
|
@@ -6079,7 +6064,6 @@ const Popover = react.memo(react.forwardRef(function Popover2(props, ref) {
|
|
|
6079
6064
|
react.useEffect(() => {
|
|
6080
6065
|
referenceRef(referenceElement || null);
|
|
6081
6066
|
}, [referenceRef, referenceElement]);
|
|
6082
|
-
useOnForcedUpdate(handleForcedUpdate);
|
|
6083
6067
|
if (disabled) {
|
|
6084
6068
|
return childProp || /* @__PURE__ */jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
6085
6069
|
}
|
|
@@ -6119,35 +6103,6 @@ const Popover = react.memo(react.forwardRef(function Popover2(props, ref) {
|
|
|
6119
6103
|
});
|
|
6120
6104
|
}));
|
|
6121
6105
|
Popover.displayName = "Popover";
|
|
6122
|
-
const PopoverProvider = _ref22 => {
|
|
6123
|
-
let {
|
|
6124
|
-
children
|
|
6125
|
-
} = _ref22;
|
|
6126
|
-
const [lastUpdateId, setUpdateId] = react.useState(null);
|
|
6127
|
-
const forceUpdate = react.useCallback(() => {
|
|
6128
|
-
const newId = Math.random().toString(36).substr(2, 9);
|
|
6129
|
-
setUpdateId(newId);
|
|
6130
|
-
}, []);
|
|
6131
|
-
const value = react.useMemo(() => ({
|
|
6132
|
-
version: 0,
|
|
6133
|
-
lastUpdateId,
|
|
6134
|
-
forceUpdate
|
|
6135
|
-
}), [lastUpdateId, forceUpdate]);
|
|
6136
|
-
return /* @__PURE__ */jsxRuntime.jsx(PopoverContext.Provider, {
|
|
6137
|
-
value,
|
|
6138
|
-
children
|
|
6139
|
-
});
|
|
6140
|
-
};
|
|
6141
|
-
function usePopover() {
|
|
6142
|
-
const value = react.useContext(PopoverContext);
|
|
6143
|
-
if (!value) {
|
|
6144
|
-
throw new Error("usePopover(): missing context value");
|
|
6145
|
-
}
|
|
6146
|
-
if (!isRecord(value) || value.version !== 0) {
|
|
6147
|
-
throw new Error("usePopover(): the context value is not compatible");
|
|
6148
|
-
}
|
|
6149
|
-
return value;
|
|
6150
|
-
}
|
|
6151
6106
|
function radioBaseStyle() {
|
|
6152
6107
|
return styled.css(_templateObject36 || (_templateObject36 = _taggedTemplateLiteral(["\n position: relative;\n\n &:not([hidden]) {\n display: inline-block;\n }\n\n &[data-read-only] {\n outline: 1px solid red;\n }\n "])));
|
|
6153
6108
|
}
|
|
@@ -6979,10 +6934,10 @@ const InnerAutocomplete = react.forwardRef(function InnerAutocomplete2(props, re
|
|
|
6979
6934
|
query,
|
|
6980
6935
|
value
|
|
6981
6936
|
} = state;
|
|
6982
|
-
const defaultRenderOption = react.useCallback(
|
|
6937
|
+
const defaultRenderOption = react.useCallback(_ref22 => {
|
|
6983
6938
|
let {
|
|
6984
6939
|
value: value2
|
|
6985
|
-
} =
|
|
6940
|
+
} = _ref22;
|
|
6986
6941
|
return /* @__PURE__ */jsxRuntime.jsx(Card, {
|
|
6987
6942
|
"data-as": "button",
|
|
6988
6943
|
padding: paddingProp,
|
|
@@ -7429,10 +7384,10 @@ const Breadcrumbs = react.forwardRef(function Breadcrumbs2(props, ref) {
|
|
|
7429
7384
|
}, itemIndex))
|
|
7430
7385
|
});
|
|
7431
7386
|
});
|
|
7432
|
-
function dialogStyle(
|
|
7387
|
+
function dialogStyle(_ref23) {
|
|
7433
7388
|
let {
|
|
7434
7389
|
theme
|
|
7435
|
-
} =
|
|
7390
|
+
} = _ref23;
|
|
7436
7391
|
const color = theme.sanity.color.base;
|
|
7437
7392
|
return {
|
|
7438
7393
|
"&:not([hidden])": {
|
|
@@ -8042,6 +7997,7 @@ const MenuButton = react.forwardRef(function MenuButton2(props, ref) {
|
|
|
8042
7997
|
id,
|
|
8043
7998
|
menu: menuProp,
|
|
8044
7999
|
onClose,
|
|
8000
|
+
onOpen,
|
|
8045
8001
|
placement: deprecated_placement,
|
|
8046
8002
|
popoverScheme: deprecated_popoverScheme,
|
|
8047
8003
|
portal: deprecated_portal = true,
|
|
@@ -8054,6 +8010,11 @@ const MenuButton = react.forwardRef(function MenuButton2(props, ref) {
|
|
|
8054
8010
|
const [buttonElement, setButtonElement] = react.useState(null);
|
|
8055
8011
|
const [menuElements, setChildMenuElements] = react.useState([]);
|
|
8056
8012
|
const openRef = react.useRef(open);
|
|
8013
|
+
react.useEffect(() => {
|
|
8014
|
+
if (onOpen && open && !openRef.current) {
|
|
8015
|
+
onOpen();
|
|
8016
|
+
}
|
|
8017
|
+
}, [onOpen, open]);
|
|
8057
8018
|
react.useEffect(() => {
|
|
8058
8019
|
if (onClose && !open && openRef.current) {
|
|
8059
8020
|
onClose();
|
|
@@ -8452,15 +8413,15 @@ const MenuItem = react.forwardRef(function MenuItem2(props, forwardedRef) {
|
|
|
8452
8413
|
});
|
|
8453
8414
|
const keyframe = styled.keyframes(_templateObject78 || (_templateObject78 = _taggedTemplateLiteral(["\n 0% {\n background-position: 100%;\n }\n 100% {\n background-position: -100%;\n }\n"])));
|
|
8454
8415
|
const animation = styled.css(_templateObject79 || (_templateObject79 = _taggedTemplateLiteral(["\n background-image: linear-gradient(\n to right,\n var(--card-skeleton-color-from),\n var(--card-skeleton-color-to),\n var(--card-skeleton-color-from),\n var(--card-skeleton-color-from),\n var(--card-skeleton-color-from)\n );\n background-position: 100%;\n background-size: 200% 100%;\n background-attachment: fixed;\n animation-name: ", ";\n animation-timing-function: ease-in-out;\n animation-iteration-count: infinite;\n animation-duration: 2000ms;\n"])), keyframe);
|
|
8455
|
-
const skeletonStyle = styled.css(_templateObject80 || (_templateObject80 = _taggedTemplateLiteral(["\n opacity: ", ";\n transition: opacity 200ms ease-in;\n\n @media screen and (prefers-reduced-motion: no-preference) {\n ", "\n }\n\n @media screen and (prefers-reduced-motion: reduce) {\n background-color: var(--card-skeleton-color-from);\n }\n"])),
|
|
8416
|
+
const skeletonStyle = styled.css(_templateObject80 || (_templateObject80 = _taggedTemplateLiteral(["\n opacity: ", ";\n transition: opacity 200ms ease-in;\n\n @media screen and (prefers-reduced-motion: no-preference) {\n ", "\n }\n\n @media screen and (prefers-reduced-motion: reduce) {\n background-color: var(--card-skeleton-color-from);\n }\n"])), _ref24 => {
|
|
8456
8417
|
let {
|
|
8457
8418
|
$visible
|
|
8458
|
-
} =
|
|
8419
|
+
} = _ref24;
|
|
8459
8420
|
return $visible ? 1 : 0;
|
|
8460
|
-
},
|
|
8421
|
+
}, _ref25 => {
|
|
8461
8422
|
let {
|
|
8462
8423
|
$animated
|
|
8463
|
-
} =
|
|
8424
|
+
} = _ref25;
|
|
8464
8425
|
return $animated ? animation : styled.css(_templateObject81 || (_templateObject81 = _taggedTemplateLiteral(["\n background-color: var(--card-skeleton-color-from);\n "])));
|
|
8465
8426
|
});
|
|
8466
8427
|
const Root$4 = styled__default.default(Box)(responsiveRadiusStyle, skeletonStyle);
|
|
@@ -8491,12 +8452,12 @@ const Skeleton = react.forwardRef(function Skeleton2(props, ref) {
|
|
|
8491
8452
|
ref
|
|
8492
8453
|
});
|
|
8493
8454
|
});
|
|
8494
|
-
const Root$3 = styled__default.default(Skeleton)(
|
|
8455
|
+
const Root$3 = styled__default.default(Skeleton)(_ref26 => {
|
|
8495
8456
|
let {
|
|
8496
8457
|
$size,
|
|
8497
8458
|
$style,
|
|
8498
8459
|
theme
|
|
8499
|
-
} =
|
|
8460
|
+
} = _ref26;
|
|
8500
8461
|
const {
|
|
8501
8462
|
media
|
|
8502
8463
|
} = theme.sanity;
|
|
@@ -8817,12 +8778,12 @@ function ToastProvider(props) {
|
|
|
8817
8778
|
paddingY,
|
|
8818
8779
|
children: /* @__PURE__ */jsxRuntime.jsx(framerMotion.AnimatePresence, {
|
|
8819
8780
|
initial: false,
|
|
8820
|
-
children: state.map(
|
|
8781
|
+
children: state.map(_ref27 => {
|
|
8821
8782
|
let {
|
|
8822
8783
|
dismiss,
|
|
8823
8784
|
id,
|
|
8824
8785
|
params
|
|
8825
|
-
} =
|
|
8786
|
+
} = _ref27;
|
|
8826
8787
|
return /* @__PURE__ */jsxRuntime.jsx(framerMotion.motion.div, {
|
|
8827
8788
|
animate: {
|
|
8828
8789
|
opacity: 1,
|
|
@@ -9338,7 +9299,6 @@ exports.MenuDivider = MenuDivider;
|
|
|
9338
9299
|
exports.MenuGroup = MenuGroup;
|
|
9339
9300
|
exports.MenuItem = MenuItem;
|
|
9340
9301
|
exports.Popover = Popover;
|
|
9341
|
-
exports.PopoverProvider = PopoverProvider;
|
|
9342
9302
|
exports.Portal = Portal;
|
|
9343
9303
|
exports.PortalProvider = PortalProvider;
|
|
9344
9304
|
exports.Radio = Radio;
|
|
@@ -9412,7 +9372,6 @@ exports.useForwardedRef = useForwardedRef;
|
|
|
9412
9372
|
exports.useGlobalKeyDown = useGlobalKeyDown;
|
|
9413
9373
|
exports.useLayer = useLayer;
|
|
9414
9374
|
exports.useMediaIndex = useMediaIndex;
|
|
9415
|
-
exports.usePopover = usePopover;
|
|
9416
9375
|
exports.usePortal = usePortal;
|
|
9417
9376
|
exports.usePrefersDark = usePrefersDark;
|
|
9418
9377
|
exports.usePrefersReducedMotion = usePrefersReducedMotion;
|