@sanity/ui 2.14.3 → 2.14.4-canary.1
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 +86 -66
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +86 -66
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/_legacy/_visual-editing.esm.js +86 -66
- package/dist/_legacy/_visual-editing.esm.js.map +1 -1
- package/dist/index.d.mts +26 -6
- package/dist/index.d.ts +26 -6
- package/dist/index.esm.js +162 -174
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +159 -171
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +162 -174
- package/dist/index.mjs.map +1 -1
- package/package.json +43 -57
- package/src/core/components/toast/styles.ts +57 -53
- package/src/core/components/toast/toast.tsx +127 -34
- package/src/core/components/toast/toastLayer.tsx +50 -0
- package/src/core/components/toast/toastProvider.tsx +27 -124
- package/src/core/constants.ts +42 -29
- package/src/core/hooks/useDelayedState.ts +2 -1
- package/src/core/primitives/grid/grid.tsx +1 -0
- package/src/core/primitives/popover/popoverCard.tsx +20 -8
- package/src/core/primitives/tooltip/tooltip.tsx +24 -61
- package/src/core/primitives/tooltip/tooltipCard.tsx +7 -6
- package/src/core/utils/layer/layer.tsx +1 -1
|
@@ -4,33 +4,41 @@ function _interopDefaultCompat(e) {
|
|
|
4
4
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
5
5
|
}
|
|
6
6
|
var ReactIs__default = /* @__PURE__ */ _interopDefaultCompat(ReactIs);
|
|
7
|
-
const createColorTheme = theme.createColorTheme, hexToRgb = theme.hexToRgb, hslToRgb = theme.hslToRgb, multiply = theme.multiply, parseColor = theme.parseColor, rgbToHex = theme.rgbToHex, rgbToHsl = theme.rgbToHsl, rgba = theme.rgba, screen = theme.screen, studioTheme = theme.buildTheme(), EMPTY_ARRAY = [], EMPTY_RECORD = {},
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
const createColorTheme = theme.createColorTheme, hexToRgb = theme.hexToRgb, hslToRgb = theme.hslToRgb, multiply = theme.multiply, parseColor = theme.parseColor, rgbToHex = theme.rgbToHex, rgbToHsl = theme.rgbToHsl, rgba = theme.rgba, screen = theme.screen, studioTheme = theme.buildTheme(), EMPTY_ARRAY = [], EMPTY_RECORD = {}, POPOVER_MOTION_PROPS = {
|
|
8
|
+
outerVariants: {
|
|
9
|
+
initial: {
|
|
10
|
+
scale: 0.97,
|
|
11
|
+
willChange: "transform"
|
|
12
|
+
},
|
|
13
|
+
hidden: {
|
|
14
|
+
opacity: 0
|
|
15
|
+
},
|
|
16
|
+
visible: {
|
|
17
|
+
opacity: 1,
|
|
18
|
+
transition: {
|
|
19
|
+
when: "beforeChildren",
|
|
20
|
+
duration: 0.1
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
scaleIn: {
|
|
24
|
+
scale: 1
|
|
25
|
+
},
|
|
26
|
+
scaleOut: {
|
|
27
|
+
scale: 0.97
|
|
28
|
+
}
|
|
25
29
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
innerVariants: {
|
|
31
|
+
hidden: {
|
|
32
|
+
opacity: 0
|
|
33
|
+
},
|
|
34
|
+
visible: {
|
|
35
|
+
opacity: 1
|
|
36
|
+
}
|
|
30
37
|
},
|
|
31
38
|
transition: {
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
type: "spring",
|
|
40
|
+
visualDuration: 0.2,
|
|
41
|
+
bounce: 0.25
|
|
34
42
|
}
|
|
35
43
|
};
|
|
36
44
|
function _fillCSSObject(keys, value) {
|
|
@@ -3121,7 +3129,7 @@ const StyledLayer = /* @__PURE__ */ styledComponents.styled.div.withConfig({
|
|
|
3121
3129
|
zIndex
|
|
3122
3130
|
}, $[14] = style, $[15] = zIndex, $[16] = t5) : t5 = $[16];
|
|
3123
3131
|
let t6;
|
|
3124
|
-
return $[17] !== children || $[18] !== handleFocus || $[19] !== restProps || $[20] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(StyledLayer, {
|
|
3132
|
+
return $[17] !== children || $[18] !== handleFocus || $[19] !== restProps || $[20] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(StyledLayer, { "data-ui": "Layer", ...restProps, onFocus: handleFocus, ref, style: t5, children }), $[17] = children, $[18] = handleFocus, $[19] = restProps, $[20] = t5, $[21] = t6) : t6 = $[21], t6;
|
|
3125
3133
|
}), Layer = react.forwardRef(function(props, ref) {
|
|
3126
3134
|
const $ = reactCompilerRuntime.c(11);
|
|
3127
3135
|
let children, restProps, t0;
|
|
@@ -3417,8 +3425,11 @@ function calcMaxWidth(params) {
|
|
|
3417
3425
|
const MotionCard$1 = styledComponents.styled(framerMotion.motion.create(Card)).withConfig({
|
|
3418
3426
|
displayName: "MotionCard",
|
|
3419
3427
|
componentId: "sc-ihg31s-0"
|
|
3420
|
-
})`&:not([hidden]){display:flex;}flex-direction:column;width:max-content;min-width:min-content
|
|
3421
|
-
|
|
3428
|
+
})`&:not([hidden]){display:flex;}flex-direction:column;width:max-content;min-width:min-content;will-change:transform;`, MotionFlex = styledComponents.styled(framerMotion.motion.create(Flex)).withConfig({
|
|
3429
|
+
displayName: "MotionFlex",
|
|
3430
|
+
componentId: "sc-ihg31s-1"
|
|
3431
|
+
})`will-change:opacity;`, PopoverCard = react.memo(react.forwardRef(function(props, ref) {
|
|
3432
|
+
const $ = reactCompilerRuntime.c(66);
|
|
3422
3433
|
let animate, arrow, arrowRef, arrowX, arrowY, children, marginsProp, originX, originY, overflow, padding, placement, radius, restProps, scheme, shadow, strategy, style, tone, width, xProp, yProp;
|
|
3423
3434
|
$[0] !== props ? ({
|
|
3424
3435
|
__unstable_margins: marginsProp,
|
|
@@ -3476,18 +3487,22 @@ const MotionCard$1 = styledComponents.styled(framerMotion.motion.create(Card)).w
|
|
|
3476
3487
|
}, $[33] = t5, $[34] = t6, $[35] = t7) : t7 = $[35], t4 = t7;
|
|
3477
3488
|
const arrowStyle = t4, t8 = restProps;
|
|
3478
3489
|
let t9;
|
|
3479
|
-
$[36] !== animate ? (t9 = animate ?
|
|
3490
|
+
$[36] !== animate ? (t9 = animate ? ["hidden", "initial"] : void 0, $[36] = animate, $[37] = t9) : t9 = $[37];
|
|
3480
3491
|
let t10;
|
|
3481
|
-
$[38] !==
|
|
3492
|
+
$[38] !== animate ? (t10 = animate ? ["visible", "scaleIn"] : void 0, $[38] = animate, $[39] = t10) : t10 = $[39];
|
|
3482
3493
|
let t11;
|
|
3483
|
-
$[
|
|
3494
|
+
$[40] !== animate ? (t11 = animate ? ["hidden", "scaleOut"] : void 0, $[40] = animate, $[41] = t11) : t11 = $[41];
|
|
3484
3495
|
let t12;
|
|
3485
|
-
$[
|
|
3496
|
+
$[42] !== children || $[43] !== padding ? (t12 = /* @__PURE__ */ jsxRuntime.jsx(Flex, { direction: "column", flex: 1, padding, children }), $[42] = children, $[43] = padding, $[44] = t12) : t12 = $[44];
|
|
3486
3497
|
let t13;
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3498
|
+
$[45] !== overflow || $[46] !== t12 ? (t13 = /* @__PURE__ */ jsxRuntime.jsx(MotionFlex, { "data-ui": "Popover__wrapper", direction: "column", flex: 1, overflow, variants: POPOVER_MOTION_PROPS.innerVariants, transition: POPOVER_MOTION_PROPS.transition, children: t12 }), $[45] = overflow, $[46] = t12, $[47] = t13) : t13 = $[47];
|
|
3499
|
+
let t14;
|
|
3500
|
+
$[48] !== arrow || $[49] !== arrowRef || $[50] !== arrowStyle ? (t14 = arrow && /* @__PURE__ */ jsxRuntime.jsx(Arrow, { ref: arrowRef, style: arrowStyle, width: DEFAULT_POPOVER_ARROW_WIDTH, height: DEFAULT_POPOVER_ARROW_HEIGHT, radius: DEFAULT_POPOVER_ARROW_RADIUS }), $[48] = arrow, $[49] = arrowRef, $[50] = arrowStyle, $[51] = t14) : t14 = $[51];
|
|
3501
|
+
let t15;
|
|
3502
|
+
return $[52] !== placement || $[53] !== radius || $[54] !== ref || $[55] !== rootStyle2 || $[56] !== scheme || $[57] !== shadow || $[58] !== t10 || $[59] !== t11 || $[60] !== t13 || $[61] !== t14 || $[62] !== t8 || $[63] !== t9 || $[64] !== tone ? (t15 = /* @__PURE__ */ jsxRuntime.jsxs(MotionCard$1, { "data-ui": "Popover", ...t8, "data-placement": placement, radius, ref, scheme, shadow, sizing: "border", style: rootStyle2, tone, variants: POPOVER_MOTION_PROPS.outerVariants, transition: POPOVER_MOTION_PROPS.transition, initial: t9, animate: t10, exit: t11, children: [
|
|
3503
|
+
t13,
|
|
3504
|
+
t14
|
|
3505
|
+
] }), $[52] = placement, $[53] = radius, $[54] = ref, $[55] = rootStyle2, $[56] = scheme, $[57] = shadow, $[58] = t10, $[59] = t11, $[60] = t13, $[61] = t14, $[62] = t8, $[63] = t9, $[64] = tone, $[65] = t15) : t15 = $[65], t15;
|
|
3491
3506
|
}));
|
|
3492
3507
|
PopoverCard.displayName = "Memo(ForwardRef(PopoverCard))";
|
|
3493
3508
|
const ViewportOverlay = () => {
|
|
@@ -4392,9 +4407,9 @@ function useDelayedState(initialState) {
|
|
|
4392
4407
|
const action = () => {
|
|
4393
4408
|
setState(nextState);
|
|
4394
4409
|
};
|
|
4395
|
-
if (
|
|
4410
|
+
if (!delay)
|
|
4396
4411
|
return action();
|
|
4397
|
-
delayedAction.current = setTimeout(action, delay);
|
|
4412
|
+
delayedAction.current && (clearTimeout(delayedAction.current), delayedAction.current = void 0), delayedAction.current = setTimeout(action, delay);
|
|
4398
4413
|
}, $[0] = t0) : t0 = $[0];
|
|
4399
4414
|
const onStateChange = t0;
|
|
4400
4415
|
let t1;
|
|
@@ -4416,8 +4431,8 @@ const DEFAULT_TOOLTIP_ARROW_WIDTH = 15, DEFAULT_TOOLTIP_ARROW_HEIGHT = 6, DEFAUL
|
|
|
4416
4431
|
}, MotionCard = styledComponents.styled(framerMotion.motion.create(Card)).withConfig({
|
|
4417
4432
|
displayName: "MotionCard",
|
|
4418
4433
|
componentId: "sc-1xn138w-0"
|
|
4419
|
-
})
|
|
4420
|
-
const $ = reactCompilerRuntime.c(
|
|
4434
|
+
})`will-change:transform;`, TooltipCard = react.memo(react.forwardRef(function(props, ref) {
|
|
4435
|
+
const $ = reactCompilerRuntime.c(48);
|
|
4421
4436
|
let animate, arrow, arrowRef, arrowX, arrowY, children, originX, originY, padding, placement, radius, restProps, scheme, shadow, style;
|
|
4422
4437
|
$[0] !== props ? ({
|
|
4423
4438
|
animate,
|
|
@@ -4457,14 +4472,18 @@ const DEFAULT_TOOLTIP_ARROW_WIDTH = 15, DEFAULT_TOOLTIP_ARROW_HEIGHT = 6, DEFAUL
|
|
|
4457
4472
|
}, $[21] = t4, $[22] = t5, $[23] = t6) : t6 = $[23], t3 = t6;
|
|
4458
4473
|
const arrowStyle = t3, t7 = restProps;
|
|
4459
4474
|
let t8;
|
|
4460
|
-
$[24] !== animate ? (t8 = animate ?
|
|
4475
|
+
$[24] !== animate ? (t8 = animate ? ["hidden", "initial"] : void 0, $[24] = animate, $[25] = t8) : t8 = $[25];
|
|
4461
4476
|
let t9;
|
|
4462
|
-
$[26] !==
|
|
4477
|
+
$[26] !== animate ? (t9 = animate ? ["visible", "scaleIn"] : void 0, $[26] = animate, $[27] = t9) : t9 = $[27];
|
|
4463
4478
|
let t10;
|
|
4464
|
-
|
|
4479
|
+
$[28] !== animate ? (t10 = animate ? ["hidden", "scaleOut"] : void 0, $[28] = animate, $[29] = t10) : t10 = $[29];
|
|
4480
|
+
let t11;
|
|
4481
|
+
$[30] !== arrow || $[31] !== arrowRef || $[32] !== arrowStyle ? (t11 = arrow && /* @__PURE__ */ jsxRuntime.jsx(Arrow, { ref: arrowRef, style: arrowStyle, width: DEFAULT_TOOLTIP_ARROW_WIDTH, height: DEFAULT_TOOLTIP_ARROW_HEIGHT, radius: DEFAULT_TOOLTIP_ARROW_RADIUS }), $[30] = arrow, $[31] = arrowRef, $[32] = arrowStyle, $[33] = t11) : t11 = $[33];
|
|
4482
|
+
let t12;
|
|
4483
|
+
return $[34] !== children || $[35] !== padding || $[36] !== placement || $[37] !== radius || $[38] !== ref || $[39] !== rootStyle2 || $[40] !== scheme || $[41] !== shadow || $[42] !== t10 || $[43] !== t11 || $[44] !== t7 || $[45] !== t8 || $[46] !== t9 ? (t12 = /* @__PURE__ */ jsxRuntime.jsxs(MotionCard, { "data-ui": "Tooltip__card", ...t7, "data-placement": placement, padding, radius, ref, scheme, shadow, style: rootStyle2, variants: POPOVER_MOTION_PROPS.outerVariants, transition: POPOVER_MOTION_PROPS.transition, initial: t8, animate: t9, exit: t10, children: [
|
|
4465
4484
|
children,
|
|
4466
|
-
|
|
4467
|
-
] }), $[
|
|
4485
|
+
t11
|
|
4486
|
+
] }), $[34] = children, $[35] = padding, $[36] = placement, $[37] = radius, $[38] = ref, $[39] = rootStyle2, $[40] = scheme, $[41] = shadow, $[42] = t10, $[43] = t11, $[44] = t7, $[45] = t8, $[46] = t9, $[47] = t12) : t12 = $[47], t12;
|
|
4468
4487
|
}));
|
|
4469
4488
|
TooltipCard.displayName = "Memo(ForwardRef(TooltipCard))";
|
|
4470
4489
|
const TooltipDelayGroupContext = createGlobalScopedContext("@sanity/ui/context/tooltipDelayGroup", null);
|
|
@@ -4558,19 +4577,7 @@ const StyledTooltip = styledComponents.styled(Layer).withConfig({
|
|
|
4558
4577
|
}
|
|
4559
4578
|
else
|
|
4560
4579
|
setIsOpen(open, immediate ? 0 : open ? openDelay : closeDelay);
|
|
4561
|
-
}, [isInsideGroup, delayGroupContext, openDelay, tooltipId, closeDelay, setIsOpen])
|
|
4562
|
-
handleIsOpenChange(!1), childProp?.props?.onBlur?.(e);
|
|
4563
|
-
}, [childProp?.props, handleIsOpenChange]), handleClick = react.useCallback((e_0) => {
|
|
4564
|
-
handleIsOpenChange(!1, !0), childProp?.props.onClick?.(e_0);
|
|
4565
|
-
}, [childProp?.props, handleIsOpenChange]), handleContextMenu = react.useCallback((e_1) => {
|
|
4566
|
-
handleIsOpenChange(!1, !0), childProp?.props.onContextMenu?.(e_1);
|
|
4567
|
-
}, [childProp?.props, handleIsOpenChange]), handleFocus = react.useCallback((e_2) => {
|
|
4568
|
-
handleIsOpenChange(!0), childProp?.props?.onFocus?.(e_2);
|
|
4569
|
-
}, [childProp?.props, handleIsOpenChange]), handleMouseEnter = react.useCallback((e_3) => {
|
|
4570
|
-
handleIsOpenChange(!0), childProp?.props?.onMouseEnter?.(e_3);
|
|
4571
|
-
}, [childProp?.props, handleIsOpenChange]), handleMouseLeave = react.useCallback((e_4) => {
|
|
4572
|
-
handleIsOpenChange(!1), childProp?.props?.onMouseLeave?.(e_4);
|
|
4573
|
-
}, [childProp?.props, handleIsOpenChange]);
|
|
4580
|
+
}, [isInsideGroup, delayGroupContext, openDelay, tooltipId, closeDelay, setIsOpen]);
|
|
4574
4581
|
useCloseOnMouseLeave({
|
|
4575
4582
|
handleIsOpenChange,
|
|
4576
4583
|
referenceElement,
|
|
@@ -4587,7 +4594,27 @@ const StyledTooltip = styledComponents.styled(Layer).withConfig({
|
|
|
4587
4594
|
return window.addEventListener("keydown", handleWindowKeyDown), () => {
|
|
4588
4595
|
window.removeEventListener("keydown", handleWindowKeyDown);
|
|
4589
4596
|
};
|
|
4590
|
-
}, [handleIsOpenChange, showTooltip])
|
|
4597
|
+
}, [handleIsOpenChange, showTooltip]);
|
|
4598
|
+
const handleChildEvent = useEffectEvent.useEffectEvent((open_0, immediate_0) => handleIsOpenChange(open_0, immediate_0));
|
|
4599
|
+
react.useEffect(() => {
|
|
4600
|
+
if (!referenceElement) return;
|
|
4601
|
+
const controller = new AbortController(), {
|
|
4602
|
+
signal
|
|
4603
|
+
} = controller;
|
|
4604
|
+
return referenceElement.addEventListener("blur", () => handleChildEvent(!1), {
|
|
4605
|
+
signal
|
|
4606
|
+
}), referenceElement.addEventListener("focus", () => handleChildEvent(!0), {
|
|
4607
|
+
signal
|
|
4608
|
+
}), referenceElement.addEventListener("mouseenter", () => handleChildEvent(!0), {
|
|
4609
|
+
signal
|
|
4610
|
+
}), referenceElement.addEventListener("mouseleave", () => handleChildEvent(!1), {
|
|
4611
|
+
signal
|
|
4612
|
+
}), referenceElement.addEventListener("click", () => handleChildEvent(!1, !0), {
|
|
4613
|
+
signal
|
|
4614
|
+
}), referenceElement.addEventListener("contextmenu", () => handleChildEvent(!1, !0), {
|
|
4615
|
+
signal
|
|
4616
|
+
}), () => controller.abort();
|
|
4617
|
+
}, [referenceElement]), react.useLayoutEffect(() => {
|
|
4591
4618
|
const availableWidths = [...boundaryElement ? [boundaryElement.offsetWidth] : [], portalElement?.offsetWidth || document.body.offsetWidth];
|
|
4592
4619
|
setTooltipMaxWidth(Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2);
|
|
4593
4620
|
}, [boundaryElement, portalElement]);
|
|
@@ -4596,14 +4623,8 @@ const StyledTooltip = styledComponents.styled(Layer).withConfig({
|
|
|
4596
4623
|
}, [update]), setFloating = react.useCallback((node) => {
|
|
4597
4624
|
ref.current = node, refs.setFloating(node);
|
|
4598
4625
|
}, [refs]), child = react.useMemo(() => childProp ? react.cloneElement(childProp, {
|
|
4599
|
-
onBlur: handleBlur,
|
|
4600
|
-
onFocus: handleFocus,
|
|
4601
|
-
onMouseEnter: handleMouseEnter,
|
|
4602
|
-
onMouseLeave: handleMouseLeave,
|
|
4603
|
-
onClick: handleClick,
|
|
4604
|
-
onContextMenu: handleContextMenu,
|
|
4605
4626
|
ref: setReferenceElement
|
|
4606
|
-
}) : null, [childProp
|
|
4627
|
+
}) : null, [childProp]);
|
|
4607
4628
|
if (react.useImperativeHandle(childProp ? getElementRef(childProp) : null, () => referenceElement, [referenceElement]), !child) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
4608
4629
|
if (disabled) return child;
|
|
4609
4630
|
const tooltip = /* @__PURE__ */ jsxRuntime.jsx(StyledTooltip, { "data-ui": "Tooltip", ...restProps, ref: setFloating, style: {
|
|
@@ -5314,7 +5335,6 @@ exports.Menu = Menu;
|
|
|
5314
5335
|
exports.MenuDivider = MenuDivider;
|
|
5315
5336
|
exports.MenuGroup = MenuGroup;
|
|
5316
5337
|
exports.MenuItem = MenuItem;
|
|
5317
|
-
exports.POPOVER_MOTION_CONTENT_OPACITY_PROPERTY = POPOVER_MOTION_CONTENT_OPACITY_PROPERTY;
|
|
5318
5338
|
exports.Popover = Popover;
|
|
5319
5339
|
exports.Portal = Portal;
|
|
5320
5340
|
exports.PortalProvider = PortalProvider;
|