@sanity/ui 2.14.4-canary.2 → 2.14.4
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 +64 -84
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +64 -84
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/_legacy/_visual-editing.esm.js +64 -84
- package/dist/_legacy/_visual-editing.esm.js.map +1 -1
- package/dist/index.d.mts +6 -26
- package/dist/index.d.ts +6 -26
- package/dist/index.esm.js +187 -182
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +185 -180
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +187 -182
- package/dist/index.mjs.map +1 -1
- package/package.json +41 -27
- package/src/core/components/toast/styles.ts +53 -57
- package/src/core/components/toast/toast.tsx +34 -127
- package/src/core/components/toast/toastProvider.tsx +142 -49
- package/src/core/constants.ts +29 -42
- package/src/core/primitives/grid/grid.tsx +0 -1
- package/src/core/primitives/popover/popoverCard.tsx +8 -20
- package/src/core/primitives/tooltip/tooltip.tsx +61 -24
- package/src/core/primitives/tooltip/tooltipCard.tsx +6 -7
- package/src/core/utils/layer/layer.tsx +1 -1
- package/src/core/components/toast/toastLayer.tsx +0 -50
|
@@ -10,41 +10,33 @@ import { motion, AnimatePresence } from "framer-motion";
|
|
|
10
10
|
import { ResizeObserver } from "@juggle/resize-observer";
|
|
11
11
|
import { createPortal } from "react-dom";
|
|
12
12
|
import { useEffectEvent } from "use-effect-event";
|
|
13
|
-
const createColorTheme = createColorTheme$1, hexToRgb = hexToRgb$1, hslToRgb = hslToRgb$1, multiply = multiply$1, parseColor = parseColor$1, rgbToHex = rgbToHex$1, rgbToHsl = rgbToHsl$1, rgba = rgba$1, screen = screen$1, studioTheme = buildTheme(), EMPTY_ARRAY = [], EMPTY_RECORD = {}, POPOVER_MOTION_PROPS = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
duration: 0.1
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
scaleIn: {
|
|
30
|
-
scale: 1
|
|
31
|
-
},
|
|
32
|
-
scaleOut: {
|
|
33
|
-
scale: 0.97
|
|
34
|
-
}
|
|
13
|
+
const createColorTheme = createColorTheme$1, hexToRgb = hexToRgb$1, hslToRgb = hslToRgb$1, multiply = multiply$1, parseColor = parseColor$1, rgbToHex = rgbToHex$1, rgbToHsl = rgbToHsl$1, rgba = rgba$1, screen = screen$1, studioTheme = buildTheme(), EMPTY_ARRAY = [], EMPTY_RECORD = {}, POPOVER_MOTION_CONTENT_OPACITY_PROPERTY = "--motion-content-opacity", POPOVER_MOTION_PROPS = {
|
|
14
|
+
/**
|
|
15
|
+
* These variants makes use of special timing, by using a negative opacity as a starting position,
|
|
16
|
+
* as well as double opacity as the end position.
|
|
17
|
+
* The purpose of this is to make the tooltip/popover container appear before the content, and when exiting
|
|
18
|
+
* we want the content to disappear faster than the container.
|
|
19
|
+
*/
|
|
20
|
+
initial: {
|
|
21
|
+
opacity: 0.5,
|
|
22
|
+
// the nagative opacity here, as well as the double opacity further down, are to make the content appear after the backgdrop, and when exiting the content should disappear first.
|
|
23
|
+
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: -1,
|
|
24
|
+
scale: 0.97,
|
|
25
|
+
willChange: "transform"
|
|
35
26
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
27
|
+
animate: {
|
|
28
|
+
opacity: 2,
|
|
29
|
+
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: 1,
|
|
30
|
+
scale: 1
|
|
31
|
+
},
|
|
32
|
+
exit: {
|
|
33
|
+
opacity: 0,
|
|
34
|
+
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: -1,
|
|
35
|
+
scale: 0.97
|
|
43
36
|
},
|
|
44
37
|
transition: {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
bounce: 0.25
|
|
38
|
+
duration: 0.4,
|
|
39
|
+
type: "spring"
|
|
48
40
|
}
|
|
49
41
|
};
|
|
50
42
|
function _fillCSSObject(keys, value) {
|
|
@@ -3133,7 +3125,7 @@ const StyledLayer = /* @__PURE__ */ styled.div.withConfig({
|
|
|
3133
3125
|
zIndex
|
|
3134
3126
|
}, $[14] = style, $[15] = zIndex, $[16] = t5) : t5 = $[16];
|
|
3135
3127
|
let t6;
|
|
3136
|
-
return $[17] !== children || $[18] !== handleFocus || $[19] !== restProps || $[20] !== t5 ? (t6 = /* @__PURE__ */ jsx(StyledLayer, { "data-ui": "Layer",
|
|
3128
|
+
return $[17] !== children || $[18] !== handleFocus || $[19] !== restProps || $[20] !== t5 ? (t6 = /* @__PURE__ */ jsx(StyledLayer, { ...restProps, "data-ui": "Layer", onFocus: handleFocus, ref, style: t5, children }), $[17] = children, $[18] = handleFocus, $[19] = restProps, $[20] = t5, $[21] = t6) : t6 = $[21], t6;
|
|
3137
3129
|
}), Layer = forwardRef(function(props, ref) {
|
|
3138
3130
|
const $ = c(11);
|
|
3139
3131
|
let children, restProps, t0;
|
|
@@ -3429,11 +3421,8 @@ function calcMaxWidth(params) {
|
|
|
3429
3421
|
const MotionCard$1 = styled(motion.create(Card)).withConfig({
|
|
3430
3422
|
displayName: "MotionCard",
|
|
3431
3423
|
componentId: "sc-ihg31s-0"
|
|
3432
|
-
})`&:not([hidden]){display:flex;}flex-direction:column;width:max-content;min-width:min-content;will-change:
|
|
3433
|
-
|
|
3434
|
-
componentId: "sc-ihg31s-1"
|
|
3435
|
-
})`will-change:opacity;`, PopoverCard = memo(forwardRef(function(props, ref) {
|
|
3436
|
-
const $ = c(66);
|
|
3424
|
+
})`&:not([hidden]){display:flex;}flex-direction:column;width:max-content;min-width:min-content;& > *{opacity:var(${POPOVER_MOTION_CONTENT_OPACITY_PROPERTY},1);will-change:opacity;}`, PopoverCard = memo(forwardRef(function(props, ref) {
|
|
3425
|
+
const $ = c(60);
|
|
3437
3426
|
let animate, arrow2, arrowRef, arrowX, arrowY, children, marginsProp, originX, originY, overflow, padding, placement, radius, restProps, scheme, shadow, strategy, style, tone, width, xProp, yProp;
|
|
3438
3427
|
$[0] !== props ? ({
|
|
3439
3428
|
__unstable_margins: marginsProp,
|
|
@@ -3491,22 +3480,18 @@ const MotionCard$1 = styled(motion.create(Card)).withConfig({
|
|
|
3491
3480
|
}, $[33] = t5, $[34] = t6, $[35] = t7) : t7 = $[35], t4 = t7;
|
|
3492
3481
|
const arrowStyle = t4, t8 = restProps;
|
|
3493
3482
|
let t9;
|
|
3494
|
-
$[36] !== animate ? (t9 = animate ?
|
|
3483
|
+
$[36] !== animate ? (t9 = animate ? POPOVER_MOTION_PROPS : {}, $[36] = animate, $[37] = t9) : t9 = $[37];
|
|
3495
3484
|
let t10;
|
|
3496
|
-
$[38] !==
|
|
3485
|
+
$[38] !== children || $[39] !== padding ? (t10 = /* @__PURE__ */ jsx(Flex, { direction: "column", flex: 1, padding, children }), $[38] = children, $[39] = padding, $[40] = t10) : t10 = $[40];
|
|
3497
3486
|
let t11;
|
|
3498
|
-
$[
|
|
3487
|
+
$[41] !== overflow || $[42] !== t10 ? (t11 = /* @__PURE__ */ jsx(Flex, { "data-ui": "Popover__wrapper", direction: "column", flex: 1, overflow, children: t10 }), $[41] = overflow, $[42] = t10, $[43] = t11) : t11 = $[43];
|
|
3499
3488
|
let t12;
|
|
3500
|
-
$[
|
|
3489
|
+
$[44] !== arrow2 || $[45] !== arrowRef || $[46] !== arrowStyle ? (t12 = arrow2 && /* @__PURE__ */ jsx(Arrow, { ref: arrowRef, style: arrowStyle, width: DEFAULT_POPOVER_ARROW_WIDTH, height: DEFAULT_POPOVER_ARROW_HEIGHT, radius: DEFAULT_POPOVER_ARROW_RADIUS }), $[44] = arrow2, $[45] = arrowRef, $[46] = arrowStyle, $[47] = t12) : t12 = $[47];
|
|
3501
3490
|
let t13;
|
|
3502
|
-
$[
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
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__ */ 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: [
|
|
3507
|
-
t13,
|
|
3508
|
-
t14
|
|
3509
|
-
] }), $[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
|
+
return $[48] !== placement || $[49] !== radius || $[50] !== ref || $[51] !== rootStyle2 || $[52] !== scheme || $[53] !== shadow || $[54] !== t11 || $[55] !== t12 || $[56] !== t8 || $[57] !== t9 || $[58] !== tone ? (t13 = /* @__PURE__ */ jsxs(MotionCard$1, { "data-ui": "Popover", ...t8, "data-placement": placement, radius, ref, scheme, shadow, sizing: "border", style: rootStyle2, tone, ...t9, children: [
|
|
3492
|
+
t11,
|
|
3493
|
+
t12
|
|
3494
|
+
] }), $[48] = placement, $[49] = radius, $[50] = ref, $[51] = rootStyle2, $[52] = scheme, $[53] = shadow, $[54] = t11, $[55] = t12, $[56] = t8, $[57] = t9, $[58] = tone, $[59] = t13) : t13 = $[59], t13;
|
|
3510
3495
|
}));
|
|
3511
3496
|
PopoverCard.displayName = "Memo(ForwardRef(PopoverCard))";
|
|
3512
3497
|
const ViewportOverlay = () => {
|
|
@@ -4435,8 +4420,8 @@ const DEFAULT_TOOLTIP_ARROW_WIDTH = 15, DEFAULT_TOOLTIP_ARROW_HEIGHT = 6, DEFAUL
|
|
|
4435
4420
|
}, MotionCard = styled(motion.create(Card)).withConfig({
|
|
4436
4421
|
displayName: "MotionCard",
|
|
4437
4422
|
componentId: "sc-1xn138w-0"
|
|
4438
|
-
})
|
|
4439
|
-
const $ = c(
|
|
4423
|
+
})`& > *{opacity:var(${POPOVER_MOTION_CONTENT_OPACITY_PROPERTY},1);will-change:opacity;}`, TooltipCard = memo(forwardRef(function(props, ref) {
|
|
4424
|
+
const $ = c(42);
|
|
4440
4425
|
let animate, arrow2, arrowRef, arrowX, arrowY, children, originX, originY, padding, placement, radius, restProps, scheme, shadow, style;
|
|
4441
4426
|
$[0] !== props ? ({
|
|
4442
4427
|
animate,
|
|
@@ -4476,18 +4461,14 @@ const DEFAULT_TOOLTIP_ARROW_WIDTH = 15, DEFAULT_TOOLTIP_ARROW_HEIGHT = 6, DEFAUL
|
|
|
4476
4461
|
}, $[21] = t4, $[22] = t5, $[23] = t6) : t6 = $[23], t3 = t6;
|
|
4477
4462
|
const arrowStyle = t3, t7 = restProps;
|
|
4478
4463
|
let t8;
|
|
4479
|
-
$[24] !== animate ? (t8 = animate ?
|
|
4464
|
+
$[24] !== animate ? (t8 = animate ? POPOVER_MOTION_PROPS : {}, $[24] = animate, $[25] = t8) : t8 = $[25];
|
|
4480
4465
|
let t9;
|
|
4481
|
-
$[26] !==
|
|
4466
|
+
$[26] !== arrow2 || $[27] !== arrowRef || $[28] !== arrowStyle ? (t9 = arrow2 && /* @__PURE__ */ jsx(Arrow, { ref: arrowRef, style: arrowStyle, width: DEFAULT_TOOLTIP_ARROW_WIDTH, height: DEFAULT_TOOLTIP_ARROW_HEIGHT, radius: DEFAULT_TOOLTIP_ARROW_RADIUS }), $[26] = arrow2, $[27] = arrowRef, $[28] = arrowStyle, $[29] = t9) : t9 = $[29];
|
|
4482
4467
|
let t10;
|
|
4483
|
-
$[
|
|
4484
|
-
let t11;
|
|
4485
|
-
$[30] !== arrow2 || $[31] !== arrowRef || $[32] !== arrowStyle ? (t11 = arrow2 && /* @__PURE__ */ jsx(Arrow, { ref: arrowRef, style: arrowStyle, width: DEFAULT_TOOLTIP_ARROW_WIDTH, height: DEFAULT_TOOLTIP_ARROW_HEIGHT, radius: DEFAULT_TOOLTIP_ARROW_RADIUS }), $[30] = arrow2, $[31] = arrowRef, $[32] = arrowStyle, $[33] = t11) : t11 = $[33];
|
|
4486
|
-
let t12;
|
|
4487
|
-
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__ */ 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: [
|
|
4468
|
+
return $[30] !== children || $[31] !== padding || $[32] !== placement || $[33] !== radius || $[34] !== ref || $[35] !== rootStyle2 || $[36] !== scheme || $[37] !== shadow || $[38] !== t7 || $[39] !== t8 || $[40] !== t9 ? (t10 = /* @__PURE__ */ jsxs(MotionCard, { "data-ui": "Tooltip__card", ...t7, "data-placement": placement, padding, radius, ref, scheme, shadow, style: rootStyle2, ...t8, children: [
|
|
4488
4469
|
children,
|
|
4489
|
-
|
|
4490
|
-
] }), $[
|
|
4470
|
+
t9
|
|
4471
|
+
] }), $[30] = children, $[31] = padding, $[32] = placement, $[33] = radius, $[34] = ref, $[35] = rootStyle2, $[36] = scheme, $[37] = shadow, $[38] = t7, $[39] = t8, $[40] = t9, $[41] = t10) : t10 = $[41], t10;
|
|
4491
4472
|
}));
|
|
4492
4473
|
TooltipCard.displayName = "Memo(ForwardRef(TooltipCard))";
|
|
4493
4474
|
const TooltipDelayGroupContext = createGlobalScopedContext("@sanity/ui/context/tooltipDelayGroup", null);
|
|
@@ -4581,7 +4562,19 @@ const StyledTooltip = styled(Layer).withConfig({
|
|
|
4581
4562
|
}
|
|
4582
4563
|
else
|
|
4583
4564
|
setIsOpen(open, immediate ? 0 : open ? openDelay : closeDelay);
|
|
4584
|
-
}, [isInsideGroup, delayGroupContext, openDelay, tooltipId, closeDelay, setIsOpen])
|
|
4565
|
+
}, [isInsideGroup, delayGroupContext, openDelay, tooltipId, closeDelay, setIsOpen]), handleBlur = useCallback((e) => {
|
|
4566
|
+
handleIsOpenChange(!1), childProp?.props?.onBlur?.(e);
|
|
4567
|
+
}, [childProp?.props, handleIsOpenChange]), handleClick = useCallback((e_0) => {
|
|
4568
|
+
handleIsOpenChange(!1, !0), childProp?.props.onClick?.(e_0);
|
|
4569
|
+
}, [childProp?.props, handleIsOpenChange]), handleContextMenu = useCallback((e_1) => {
|
|
4570
|
+
handleIsOpenChange(!1, !0), childProp?.props.onContextMenu?.(e_1);
|
|
4571
|
+
}, [childProp?.props, handleIsOpenChange]), handleFocus = useCallback((e_2) => {
|
|
4572
|
+
handleIsOpenChange(!0), childProp?.props?.onFocus?.(e_2);
|
|
4573
|
+
}, [childProp?.props, handleIsOpenChange]), handleMouseEnter = useCallback((e_3) => {
|
|
4574
|
+
handleIsOpenChange(!0), childProp?.props?.onMouseEnter?.(e_3);
|
|
4575
|
+
}, [childProp?.props, handleIsOpenChange]), handleMouseLeave = useCallback((e_4) => {
|
|
4576
|
+
handleIsOpenChange(!1), childProp?.props?.onMouseLeave?.(e_4);
|
|
4577
|
+
}, [childProp?.props, handleIsOpenChange]);
|
|
4585
4578
|
useCloseOnMouseLeave({
|
|
4586
4579
|
handleIsOpenChange,
|
|
4587
4580
|
referenceElement,
|
|
@@ -4598,27 +4591,7 @@ const StyledTooltip = styled(Layer).withConfig({
|
|
|
4598
4591
|
return window.addEventListener("keydown", handleWindowKeyDown), () => {
|
|
4599
4592
|
window.removeEventListener("keydown", handleWindowKeyDown);
|
|
4600
4593
|
};
|
|
4601
|
-
}, [handleIsOpenChange, showTooltip])
|
|
4602
|
-
const handleChildEvent = useEffectEvent((open_0, immediate_0) => handleIsOpenChange(open_0, immediate_0));
|
|
4603
|
-
useEffect(() => {
|
|
4604
|
-
if (!referenceElement) return;
|
|
4605
|
-
const controller = new AbortController(), {
|
|
4606
|
-
signal
|
|
4607
|
-
} = controller;
|
|
4608
|
-
return referenceElement.addEventListener("blur", () => handleChildEvent(!1), {
|
|
4609
|
-
signal
|
|
4610
|
-
}), referenceElement.addEventListener("focus", () => handleChildEvent(!0), {
|
|
4611
|
-
signal
|
|
4612
|
-
}), referenceElement.addEventListener("mouseenter", () => handleChildEvent(!0), {
|
|
4613
|
-
signal
|
|
4614
|
-
}), referenceElement.addEventListener("mouseleave", () => handleChildEvent(!1), {
|
|
4615
|
-
signal
|
|
4616
|
-
}), referenceElement.addEventListener("click", () => handleChildEvent(!1, !0), {
|
|
4617
|
-
signal
|
|
4618
|
-
}), referenceElement.addEventListener("contextmenu", () => handleChildEvent(!1, !0), {
|
|
4619
|
-
signal
|
|
4620
|
-
}), () => controller.abort();
|
|
4621
|
-
}, [referenceElement]), useLayoutEffect(() => {
|
|
4594
|
+
}, [handleIsOpenChange, showTooltip]), useLayoutEffect(() => {
|
|
4622
4595
|
const availableWidths = [...boundaryElement ? [boundaryElement.offsetWidth] : [], portalElement?.offsetWidth || document.body.offsetWidth];
|
|
4623
4596
|
setTooltipMaxWidth(Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2);
|
|
4624
4597
|
}, [boundaryElement, portalElement]);
|
|
@@ -4627,8 +4600,14 @@ const StyledTooltip = styled(Layer).withConfig({
|
|
|
4627
4600
|
}, [update]), setFloating = useCallback((node) => {
|
|
4628
4601
|
ref.current = node, refs.setFloating(node);
|
|
4629
4602
|
}, [refs]), child = useMemo(() => childProp ? cloneElement(childProp, {
|
|
4603
|
+
onBlur: handleBlur,
|
|
4604
|
+
onFocus: handleFocus,
|
|
4605
|
+
onMouseEnter: handleMouseEnter,
|
|
4606
|
+
onMouseLeave: handleMouseLeave,
|
|
4607
|
+
onClick: handleClick,
|
|
4608
|
+
onContextMenu: handleContextMenu,
|
|
4630
4609
|
ref: setReferenceElement
|
|
4631
|
-
}) : null, [childProp]);
|
|
4610
|
+
}) : null, [childProp, handleBlur, handleClick, handleContextMenu, handleFocus, handleMouseEnter, handleMouseLeave]);
|
|
4632
4611
|
if (useImperativeHandle(childProp ? getElementRef(childProp) : null, () => referenceElement, [referenceElement]), !child) return /* @__PURE__ */ jsx(Fragment, {});
|
|
4633
4612
|
if (disabled) return child;
|
|
4634
4613
|
const tooltip = /* @__PURE__ */ jsx(StyledTooltip, { "data-ui": "Tooltip", ...restProps, ref: setFloating, style: {
|
|
@@ -5340,6 +5319,7 @@ export {
|
|
|
5340
5319
|
MenuDivider,
|
|
5341
5320
|
MenuGroup,
|
|
5342
5321
|
MenuItem,
|
|
5322
|
+
POPOVER_MOTION_CONTENT_OPACITY_PROPERTY,
|
|
5343
5323
|
Popover,
|
|
5344
5324
|
Portal,
|
|
5345
5325
|
PortalProvider,
|