@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.cjs.mjs
CHANGED
|
@@ -36,7 +36,6 @@ export const MenuDivider = cjs.MenuDivider;
|
|
|
36
36
|
export const MenuGroup = cjs.MenuGroup;
|
|
37
37
|
export const MenuItem = cjs.MenuItem;
|
|
38
38
|
export const Popover = cjs.Popover;
|
|
39
|
-
export const PopoverProvider = cjs.PopoverProvider;
|
|
40
39
|
export const Portal = cjs.Portal;
|
|
41
40
|
export const PortalProvider = cjs.PortalProvider;
|
|
42
41
|
export const Radio = cjs.Radio;
|
|
@@ -110,7 +109,6 @@ export const useForwardedRef = cjs.useForwardedRef;
|
|
|
110
109
|
export const useGlobalKeyDown = cjs.useGlobalKeyDown;
|
|
111
110
|
export const useLayer = cjs.useLayer;
|
|
112
111
|
export const useMediaIndex = cjs.useMediaIndex;
|
|
113
|
-
export const usePopover = cjs.usePopover;
|
|
114
112
|
export const usePortal = cjs.usePortal;
|
|
115
113
|
export const usePrefersDark = cjs.usePrefersDark;
|
|
116
114
|
export const usePrefersReducedMotion = cjs.usePrefersReducedMotion;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ import {HTMLProps} from 'react'
|
|
|
8
8
|
import {MemoExoticComponent} from 'react'
|
|
9
9
|
import {NamedExoticComponent} from 'react'
|
|
10
10
|
import {PropsWithChildren} from 'react'
|
|
11
|
-
import {default as React_2} from 'react'
|
|
12
11
|
import {ReactElement} from 'react'
|
|
13
12
|
import {ReactNode} from 'react'
|
|
14
13
|
import {Ref} from 'react'
|
|
@@ -1198,6 +1197,7 @@ export declare interface MenuButtonProps {
|
|
|
1198
1197
|
id: string
|
|
1199
1198
|
menu?: React.ReactElement
|
|
1200
1199
|
onClose?: () => void
|
|
1200
|
+
onOpen?: () => void
|
|
1201
1201
|
/**
|
|
1202
1202
|
* @deprecated Use `popover={{placement: 'top'}}` instead.
|
|
1203
1203
|
*/
|
|
@@ -1344,15 +1344,6 @@ export declare const Popover: MemoExoticComponent<
|
|
|
1344
1344
|
>
|
|
1345
1345
|
>
|
|
1346
1346
|
|
|
1347
|
-
/**
|
|
1348
|
-
* @public
|
|
1349
|
-
*/
|
|
1350
|
-
export declare interface PopoverContextValue {
|
|
1351
|
-
version: number
|
|
1352
|
-
forceUpdate: () => void
|
|
1353
|
-
lastUpdateId: string | null
|
|
1354
|
-
}
|
|
1355
|
-
|
|
1356
1347
|
/**
|
|
1357
1348
|
* @beta
|
|
1358
1349
|
*/
|
|
@@ -1389,18 +1380,6 @@ export declare interface PopoverProps
|
|
|
1389
1380
|
tone?: CardTone
|
|
1390
1381
|
}
|
|
1391
1382
|
|
|
1392
|
-
/**
|
|
1393
|
-
* @public
|
|
1394
|
-
*/
|
|
1395
|
-
export declare const PopoverProvider: ({children}: PopoverProviderProps) => React_2.ReactElement
|
|
1396
|
-
|
|
1397
|
-
/**
|
|
1398
|
-
* @public
|
|
1399
|
-
*/
|
|
1400
|
-
export declare interface PopoverProviderProps {
|
|
1401
|
-
children?: React_2.ReactNode
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
1383
|
/**
|
|
1405
1384
|
* @public
|
|
1406
1385
|
*/
|
|
@@ -2828,11 +2807,6 @@ export declare function useLayer(): LayerContextValue
|
|
|
2828
2807
|
*/
|
|
2829
2808
|
export declare function useMediaIndex(): number
|
|
2830
2809
|
|
|
2831
|
-
/**
|
|
2832
|
-
* @public
|
|
2833
|
-
*/
|
|
2834
|
-
export declare function usePopover(): PopoverContextValue
|
|
2835
|
-
|
|
2836
2810
|
/**
|
|
2837
2811
|
* @public
|
|
2838
2812
|
*/
|
package/dist/index.esm.js
CHANGED
|
@@ -3063,9 +3063,9 @@ function getGlobalScope() {
|
|
|
3063
3063
|
throw new Error("@sanity/ui: could not locate global scope");
|
|
3064
3064
|
}
|
|
3065
3065
|
const globalScope = getGlobalScope();
|
|
3066
|
-
const key$
|
|
3067
|
-
globalScope[key$
|
|
3068
|
-
const ThemeContext = globalScope[key$
|
|
3066
|
+
const key$7 = Symbol.for("@sanity/ui/context/theme");
|
|
3067
|
+
globalScope[key$7] = globalScope[key$7] || createContext(null);
|
|
3068
|
+
const ThemeContext = globalScope[key$7];
|
|
3069
3069
|
function ThemeProvider(props) {
|
|
3070
3070
|
const parentTheme = useContext(ThemeContext);
|
|
3071
3071
|
const {
|
|
@@ -5155,9 +5155,9 @@ const KBD = forwardRef(function KBD2(props, ref) {
|
|
|
5155
5155
|
})
|
|
5156
5156
|
});
|
|
5157
5157
|
});
|
|
5158
|
-
const key$
|
|
5159
|
-
globalScope[key$
|
|
5160
|
-
const BoundaryElementContext = globalScope[key$
|
|
5158
|
+
const key$6 = Symbol.for("@sanity/ui/context/boundaryElement");
|
|
5159
|
+
globalScope[key$6] = globalScope[key$6] || createContext(null);
|
|
5160
|
+
const BoundaryElementContext = globalScope[key$6];
|
|
5161
5161
|
function BoundaryElementProvider(props) {
|
|
5162
5162
|
const {
|
|
5163
5163
|
children,
|
|
@@ -5275,9 +5275,9 @@ function getLayerContext(contextValue) {
|
|
|
5275
5275
|
}
|
|
5276
5276
|
throw new Error("could not get layer context");
|
|
5277
5277
|
}
|
|
5278
|
-
const key$
|
|
5279
|
-
globalScope[key$
|
|
5280
|
-
const LayerContext = globalScope[key$
|
|
5278
|
+
const key$5 = Symbol.for("@sanity/ui/context/layer");
|
|
5279
|
+
globalScope[key$5] = globalScope[key$5] || createContext(null);
|
|
5280
|
+
const LayerContext = globalScope[key$5];
|
|
5281
5281
|
function useLayer() {
|
|
5282
5282
|
const value = useContext(LayerContext);
|
|
5283
5283
|
if (!value) {
|
|
@@ -5514,7 +5514,7 @@ const Layer = forwardRef(function Layer2(props, ref) {
|
|
|
5514
5514
|
})
|
|
5515
5515
|
});
|
|
5516
5516
|
});
|
|
5517
|
-
const key$
|
|
5517
|
+
const key$4 = Symbol.for("@sanity/ui/context/portal");
|
|
5518
5518
|
const elementKey = Symbol.for("@sanity/ui/context/portal/element");
|
|
5519
5519
|
globalScope[elementKey] = null;
|
|
5520
5520
|
const defaultContextValue = {
|
|
@@ -5533,8 +5533,8 @@ const defaultContextValue = {
|
|
|
5533
5533
|
return globalScope[elementKey];
|
|
5534
5534
|
}
|
|
5535
5535
|
};
|
|
5536
|
-
globalScope[key$
|
|
5537
|
-
const PortalContext = globalScope[key$
|
|
5536
|
+
globalScope[key$4] = globalScope[key$4] || createContext(defaultContextValue);
|
|
5537
|
+
const PortalContext = globalScope[key$4];
|
|
5538
5538
|
function usePortal() {
|
|
5539
5539
|
const value = useContext(PortalContext);
|
|
5540
5540
|
if (!value) {
|
|
@@ -5914,17 +5914,6 @@ const PopoverCard = memo(forwardRef(function PopoverCard2(props, ref) {
|
|
|
5914
5914
|
});
|
|
5915
5915
|
}));
|
|
5916
5916
|
PopoverCard.displayName = "PopoverCard";
|
|
5917
|
-
const key$4 = Symbol.for("@sanity/ui/context/popover");
|
|
5918
|
-
globalScope[key$4] = globalScope[key$4] || createContext(null);
|
|
5919
|
-
const PopoverContext = globalScope[key$4];
|
|
5920
|
-
const useOnForcedUpdate = eventHandler => {
|
|
5921
|
-
const contextValue = useContext(PopoverContext);
|
|
5922
|
-
useEffect(() => {
|
|
5923
|
-
if ((contextValue == null ? void 0 : contextValue.lastUpdateId) !== null) {
|
|
5924
|
-
eventHandler == null ? void 0 : eventHandler();
|
|
5925
|
-
}
|
|
5926
|
-
}, [contextValue == null ? void 0 : contextValue.lastUpdateId]);
|
|
5927
|
-
};
|
|
5928
5917
|
const Popover = memo(forwardRef(function Popover2(props, ref) {
|
|
5929
5918
|
var _a, _b, _c, _d, _e;
|
|
5930
5919
|
const theme = useTheme();
|
|
@@ -6031,13 +6020,9 @@ const Popover = memo(forwardRef(function Popover2(props, ref) {
|
|
|
6031
6020
|
placement,
|
|
6032
6021
|
reference: referenceRef,
|
|
6033
6022
|
floating: floatingRef,
|
|
6034
|
-
update: floatingUpdate,
|
|
6035
6023
|
middlewareData,
|
|
6036
6024
|
strategy
|
|
6037
6025
|
} = useFloating(floatingProps);
|
|
6038
|
-
const handleForcedUpdate = useCallback(() => {
|
|
6039
|
-
floatingUpdate();
|
|
6040
|
-
}, [floatingUpdate]);
|
|
6041
6026
|
const referenceHidden = (_c = middlewareData.hide) == null ? void 0 : _c.referenceHidden;
|
|
6042
6027
|
const arrowX = (_d = middlewareData.arrow) == null ? void 0 : _d.x;
|
|
6043
6028
|
const arrowY = (_e = middlewareData.arrow) == null ? void 0 : _e.y;
|
|
@@ -6066,7 +6051,6 @@ const Popover = memo(forwardRef(function Popover2(props, ref) {
|
|
|
6066
6051
|
useEffect(() => {
|
|
6067
6052
|
referenceRef(referenceElement || null);
|
|
6068
6053
|
}, [referenceRef, referenceElement]);
|
|
6069
|
-
useOnForcedUpdate(handleForcedUpdate);
|
|
6070
6054
|
if (disabled) {
|
|
6071
6055
|
return childProp || /* @__PURE__ */jsx(Fragment, {});
|
|
6072
6056
|
}
|
|
@@ -6106,35 +6090,6 @@ const Popover = memo(forwardRef(function Popover2(props, ref) {
|
|
|
6106
6090
|
});
|
|
6107
6091
|
}));
|
|
6108
6092
|
Popover.displayName = "Popover";
|
|
6109
|
-
const PopoverProvider = _ref22 => {
|
|
6110
|
-
let {
|
|
6111
|
-
children
|
|
6112
|
-
} = _ref22;
|
|
6113
|
-
const [lastUpdateId, setUpdateId] = useState(null);
|
|
6114
|
-
const forceUpdate = useCallback(() => {
|
|
6115
|
-
const newId = Math.random().toString(36).substr(2, 9);
|
|
6116
|
-
setUpdateId(newId);
|
|
6117
|
-
}, []);
|
|
6118
|
-
const value = useMemo(() => ({
|
|
6119
|
-
version: 0,
|
|
6120
|
-
lastUpdateId,
|
|
6121
|
-
forceUpdate
|
|
6122
|
-
}), [lastUpdateId, forceUpdate]);
|
|
6123
|
-
return /* @__PURE__ */jsx(PopoverContext.Provider, {
|
|
6124
|
-
value,
|
|
6125
|
-
children
|
|
6126
|
-
});
|
|
6127
|
-
};
|
|
6128
|
-
function usePopover() {
|
|
6129
|
-
const value = useContext(PopoverContext);
|
|
6130
|
-
if (!value) {
|
|
6131
|
-
throw new Error("usePopover(): missing context value");
|
|
6132
|
-
}
|
|
6133
|
-
if (!isRecord(value) || value.version !== 0) {
|
|
6134
|
-
throw new Error("usePopover(): the context value is not compatible");
|
|
6135
|
-
}
|
|
6136
|
-
return value;
|
|
6137
|
-
}
|
|
6138
6093
|
function radioBaseStyle() {
|
|
6139
6094
|
return 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 "])));
|
|
6140
6095
|
}
|
|
@@ -6966,10 +6921,10 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete2(props, ref) {
|
|
|
6966
6921
|
query,
|
|
6967
6922
|
value
|
|
6968
6923
|
} = state;
|
|
6969
|
-
const defaultRenderOption = useCallback(
|
|
6924
|
+
const defaultRenderOption = useCallback(_ref22 => {
|
|
6970
6925
|
let {
|
|
6971
6926
|
value: value2
|
|
6972
|
-
} =
|
|
6927
|
+
} = _ref22;
|
|
6973
6928
|
return /* @__PURE__ */jsx(Card, {
|
|
6974
6929
|
"data-as": "button",
|
|
6975
6930
|
padding: paddingProp,
|
|
@@ -7416,10 +7371,10 @@ const Breadcrumbs = forwardRef(function Breadcrumbs2(props, ref) {
|
|
|
7416
7371
|
}, itemIndex))
|
|
7417
7372
|
});
|
|
7418
7373
|
});
|
|
7419
|
-
function dialogStyle(
|
|
7374
|
+
function dialogStyle(_ref23) {
|
|
7420
7375
|
let {
|
|
7421
7376
|
theme
|
|
7422
|
-
} =
|
|
7377
|
+
} = _ref23;
|
|
7423
7378
|
const color = theme.sanity.color.base;
|
|
7424
7379
|
return {
|
|
7425
7380
|
"&:not([hidden])": {
|
|
@@ -8029,6 +7984,7 @@ const MenuButton = forwardRef(function MenuButton2(props, ref) {
|
|
|
8029
7984
|
id,
|
|
8030
7985
|
menu: menuProp,
|
|
8031
7986
|
onClose,
|
|
7987
|
+
onOpen,
|
|
8032
7988
|
placement: deprecated_placement,
|
|
8033
7989
|
popoverScheme: deprecated_popoverScheme,
|
|
8034
7990
|
portal: deprecated_portal = true,
|
|
@@ -8041,6 +7997,11 @@ const MenuButton = forwardRef(function MenuButton2(props, ref) {
|
|
|
8041
7997
|
const [buttonElement, setButtonElement] = useState(null);
|
|
8042
7998
|
const [menuElements, setChildMenuElements] = useState([]);
|
|
8043
7999
|
const openRef = useRef(open);
|
|
8000
|
+
useEffect(() => {
|
|
8001
|
+
if (onOpen && open && !openRef.current) {
|
|
8002
|
+
onOpen();
|
|
8003
|
+
}
|
|
8004
|
+
}, [onOpen, open]);
|
|
8044
8005
|
useEffect(() => {
|
|
8045
8006
|
if (onClose && !open && openRef.current) {
|
|
8046
8007
|
onClose();
|
|
@@ -8439,15 +8400,15 @@ const MenuItem = forwardRef(function MenuItem2(props, forwardedRef) {
|
|
|
8439
8400
|
});
|
|
8440
8401
|
const keyframe = keyframes(_templateObject78 || (_templateObject78 = _taggedTemplateLiteral(["\n 0% {\n background-position: 100%;\n }\n 100% {\n background-position: -100%;\n }\n"])));
|
|
8441
8402
|
const animation = 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);
|
|
8442
|
-
const skeletonStyle = 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"])),
|
|
8403
|
+
const skeletonStyle = 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 => {
|
|
8443
8404
|
let {
|
|
8444
8405
|
$visible
|
|
8445
|
-
} =
|
|
8406
|
+
} = _ref24;
|
|
8446
8407
|
return $visible ? 1 : 0;
|
|
8447
|
-
},
|
|
8408
|
+
}, _ref25 => {
|
|
8448
8409
|
let {
|
|
8449
8410
|
$animated
|
|
8450
|
-
} =
|
|
8411
|
+
} = _ref25;
|
|
8451
8412
|
return $animated ? animation : css(_templateObject81 || (_templateObject81 = _taggedTemplateLiteral(["\n background-color: var(--card-skeleton-color-from);\n "])));
|
|
8452
8413
|
});
|
|
8453
8414
|
const Root$4 = styled(Box)(responsiveRadiusStyle, skeletonStyle);
|
|
@@ -8478,12 +8439,12 @@ const Skeleton = forwardRef(function Skeleton2(props, ref) {
|
|
|
8478
8439
|
ref
|
|
8479
8440
|
});
|
|
8480
8441
|
});
|
|
8481
|
-
const Root$3 = styled(Skeleton)(
|
|
8442
|
+
const Root$3 = styled(Skeleton)(_ref26 => {
|
|
8482
8443
|
let {
|
|
8483
8444
|
$size,
|
|
8484
8445
|
$style,
|
|
8485
8446
|
theme
|
|
8486
|
-
} =
|
|
8447
|
+
} = _ref26;
|
|
8487
8448
|
const {
|
|
8488
8449
|
media
|
|
8489
8450
|
} = theme.sanity;
|
|
@@ -8804,12 +8765,12 @@ function ToastProvider(props) {
|
|
|
8804
8765
|
paddingY,
|
|
8805
8766
|
children: /* @__PURE__ */jsx(AnimatePresence, {
|
|
8806
8767
|
initial: false,
|
|
8807
|
-
children: state.map(
|
|
8768
|
+
children: state.map(_ref27 => {
|
|
8808
8769
|
let {
|
|
8809
8770
|
dismiss,
|
|
8810
8771
|
id,
|
|
8811
8772
|
params
|
|
8812
|
-
} =
|
|
8773
|
+
} = _ref27;
|
|
8813
8774
|
return /* @__PURE__ */jsx(motion.div, {
|
|
8814
8775
|
animate: {
|
|
8815
8776
|
opacity: 1,
|
|
@@ -9289,5 +9250,5 @@ const TreeItem = memo(function TreeItem2(props) {
|
|
|
9289
9250
|
})]
|
|
9290
9251
|
});
|
|
9291
9252
|
});
|
|
9292
|
-
export { Autocomplete, Avatar, AvatarCounter, AvatarStack, Badge, BoundaryElementProvider, Box, Breadcrumbs, Button, Card, Checkbox, Code, CodeSkeleton, Container, Dialog, DialogContext, DialogProvider, ElementQuery, ErrorBoundary, Flex, Grid, Heading, HeadingSkeleton, Hotkeys, Inline, KBD, Label, LabelSkeleton, Layer, LayerProvider, Menu, MenuButton, MenuDivider, MenuGroup, MenuItem, Popover,
|
|
9253
|
+
export { Autocomplete, Avatar, AvatarCounter, AvatarStack, Badge, BoundaryElementProvider, Box, Breadcrumbs, Button, Card, Checkbox, Code, CodeSkeleton, Container, Dialog, DialogContext, DialogProvider, ElementQuery, ErrorBoundary, Flex, Grid, Heading, HeadingSkeleton, Hotkeys, Inline, KBD, Label, LabelSkeleton, Layer, LayerProvider, Menu, MenuButton, MenuDivider, MenuGroup, MenuItem, Popover, Portal, PortalProvider, Radio, Select, Skeleton, Spinner, SrOnly, Stack, Switch, Tab, TabList, TabPanel, Text, TextArea, TextInput, TextSkeleton, ThemeColorProvider, ThemeProvider, Toast, ToastProvider, Tooltip, Tree, TreeItem, VirtualList, _ResizeObserver, _elementSizeObserver, _fillCSSObject, _getArrayProp, _getResponsiveSpace, _hasFocus, _isEnterToClickElement, _isScrollable, _raf, _raf2, _responsive, attemptFocus, containsOrEqualsElement, createColorTheme, focusFirstDescendant, focusLastDescendant, hexToRgb, hslToRgb, isFocusable, isHTMLAnchorElement, isHTMLButtonElement, isHTMLElement, isHTMLInputElement, isHTMLSelectElement, isHTMLTextAreaElement, multiply$1 as multiply, parseColor, rem, responsiveCodeFontStyle, responsiveHeadingFont, responsiveLabelFont, responsiveTextAlignStyle, responsiveTextFont, rgbToHex, rgbToHsl, rgba, screen$1 as screen, studioTheme, useArrayProp, useBoundaryElement, useClickOutside, useCustomValidity, useDialog, useElementRect, useElementSize, useForwardedRef, useGlobalKeyDown, useLayer, useMediaIndex, usePortal, usePrefersDark, usePrefersReducedMotion, useRootTheme, useTheme, useToast, useTree };
|
|
9293
9254
|
//# sourceMappingURL=index.esm.js.map
|