@sanity/ui 2.14.4 → 2.15.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/_chunks-cjs/_visual-editing.js +60 -42
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +60 -42
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/_legacy/_visual-editing.esm.js +60 -42
- package/dist/_legacy/_visual-editing.esm.js.map +1 -1
- package/dist/index.d.mts +32 -6
- package/dist/index.d.ts +32 -6
- package/dist/index.esm.js +194 -180
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +192 -178
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +194 -180
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -21
- package/src/core/components/toast/styles.ts +64 -52
- package/src/core/components/toast/toast.tsx +123 -34
- package/src/core/components/toast/toastLayer.tsx +50 -0
- package/src/core/components/toast/toastProvider.tsx +56 -142
- package/src/core/components/toast/types.ts +6 -0
- package/src/core/constants.ts +42 -29
- package/src/core/primitives/popover/popoverCard.tsx +20 -8
- package/src/core/primitives/tooltip/tooltipCard.tsx +7 -6
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
var _visualEditing = require("./_chunks-cjs/_visual-editing.js"), jsxRuntime = require("react/jsx-runtime"), icons = require("@sanity/icons"), react = require("react"), styledComponents = require("styled-components"), reactCompilerRuntime = require("react-compiler-runtime"), theme = require("@sanity/ui/theme"),
|
|
3
|
+
var _visualEditing = require("./_chunks-cjs/_visual-editing.js"), jsxRuntime = require("react/jsx-runtime"), icons = require("@sanity/icons"), react = require("react"), styledComponents = require("styled-components"), reactCompilerRuntime = require("react-compiler-runtime"), theme = require("@sanity/ui/theme"), framerMotion = require("framer-motion"), getTheme_v2 = require("./_chunks-cjs/getTheme_v2.js");
|
|
4
4
|
function _getElements(element, elementsArg) {
|
|
5
5
|
const ret = [element];
|
|
6
6
|
for (const el of elementsArg)
|
|
@@ -383,7 +383,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
|
|
|
383
383
|
dispatchOpen(), openButtonProps.onClick && openButtonProps.onClick(event_4), _raf(() => inputElementRef.current?.focus());
|
|
384
384
|
}, [openButtonProps, dispatchOpen]), openButtonNode = react.useMemo(() => !disabled && !readOnly && openButton ? /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { "aria-hidden": expanded, padding: openButtonBoxPadding, children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Button, { "aria-label": "Open", disabled: expanded, fontSize, icon: icons.ChevronDownIcon, mode: "bleed", padding: openButtonPadding, ...openButtonProps, onClick: handleOpenClick }) }) : void 0, [disabled, expanded, fontSize, handleOpenClick, openButton, openButtonBoxPadding, openButtonPadding, openButtonProps, readOnly]), inputValue = react.useMemo(() => query === null ? value !== null ? renderValue(value, currentOption) : "" : query, [currentOption, query, renderValue, value]), input = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.TextInput, { ...restProps, "aria-activedescendant": activeItemId, "aria-autocomplete": "list", "aria-expanded": expanded, "aria-owns": listBoxId, autoCapitalize: "off", autoComplete: "off", autoCorrect: "off", border, clearButton, customValidity, disabled, fontSize, icon, iconRight: loading && AnimatedSpinnerIcon, id, inputMode: "search", onChange: handleInputChange, onClear: handleClearButtonClick, onFocus: handleInputFocus, padding, prefix, radius, readOnly, ref: inputElementRef, role: "combobox", spellCheck: !1, suffix: suffix || openButtonNode, value: inputValue }), handleListBoxKeyDown = react.useCallback((event_5) => {
|
|
385
385
|
event_5.key === "Tab" && listFocused && inputElementRef.current?.focus();
|
|
386
|
-
}, [listFocused]),
|
|
386
|
+
}, [listFocused]), content2 = react.useMemo(() => filteredOptions.length === 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(ListBox, { "data-ui": "AutoComplete__results", onKeyDown: handleListBoxKeyDown, padding: 1, ...listBox, tabIndex: -1, children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Stack, { as: "ul", "aria-multiselectable": !1, "data-ui": "AutoComplete__resultsList", id: listBoxId, ref: listBoxElementRef, role: "listbox", space: 1, children: filteredOptions.map((option_0) => {
|
|
387
387
|
const active = activeValue !== null ? option_0.value === activeValue : currentOption === option_0;
|
|
388
388
|
return /* @__PURE__ */ jsxRuntime.jsx(AutocompleteOption, { id: `${id}-option-${option_0.value}`, onSelect: handleOptionSelect, selected: active, value: option_0.value, children: react.cloneElement(renderOption(option_0), {
|
|
389
389
|
disabled: loading,
|
|
@@ -391,12 +391,12 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
|
|
|
391
391
|
tabIndex: listFocused && active ? 0 : -1
|
|
392
392
|
}) }, option_0.value);
|
|
393
393
|
}) }) }), [activeValue, currentOption, filteredOptions, handleOptionSelect, handleListBoxKeyDown, id, listBox, listBoxId, listFocused, loading, renderOption]), results = react.useMemo(() => renderPopover ? renderPopover({
|
|
394
|
-
content,
|
|
394
|
+
content: content2,
|
|
395
395
|
hidden: !expanded,
|
|
396
396
|
inputElement: inputElementRef.current,
|
|
397
397
|
onMouseEnter: handlePopoverMouseEnter,
|
|
398
398
|
onMouseLeave: handlePopoverMouseLeave
|
|
399
|
-
}, resultsPopoverElementRef) : filteredOptionsLen === 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Popover, { arrow: !1, constrainSize: !0, content, fallbackPlacements: AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS, matchReferenceWidth: !0, onMouseEnter: handlePopoverMouseEnter, onMouseLeave: handlePopoverMouseLeave, open: expanded, overflow: "auto", placement: AUTOCOMPLETE_POPOVER_PLACEMENT, portal: !0, radius, ref: resultsPopoverElementRef, referenceElement: inputElementRef.current, ...popover }), [
|
|
399
|
+
}, resultsPopoverElementRef) : filteredOptionsLen === 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Popover, { arrow: !1, constrainSize: !0, content: content2, fallbackPlacements: AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS, matchReferenceWidth: !0, onMouseEnter: handlePopoverMouseEnter, onMouseLeave: handlePopoverMouseLeave, open: expanded, overflow: "auto", placement: AUTOCOMPLETE_POPOVER_PLACEMENT, portal: !0, radius, ref: resultsPopoverElementRef, referenceElement: inputElementRef.current, ...popover }), [content2, expanded, filteredOptionsLen, handlePopoverMouseEnter, handlePopoverMouseLeave, popover, radius, renderPopover]);
|
|
400
400
|
return /* @__PURE__ */ jsxRuntime.jsxs(StyledAutocomplete, { "data-ui": "Autocomplete", onBlur: handleRootBlur, onFocus: handleRootFocus, onKeyDown: handleRootKeyDown, ref: rootElementRef, children: [
|
|
401
401
|
input,
|
|
402
402
|
results
|
|
@@ -708,7 +708,7 @@ const MenuButton = react.forwardRef(function(props, forwardedRef) {
|
|
|
708
708
|
}, t8 = [open], $[9] = open, $[10] = t7, $[11] = t8) : (t7 = $[10], t8 = $[11]), react.useEffect(t7, t8);
|
|
709
709
|
let t9;
|
|
710
710
|
$[12] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => {
|
|
711
|
-
setOpen(_temp$
|
|
711
|
+
setOpen(_temp$2), setShouldFocus(null);
|
|
712
712
|
}, $[12] = t9) : t9 = $[12];
|
|
713
713
|
const handleButtonClick = t9;
|
|
714
714
|
let t10;
|
|
@@ -810,7 +810,7 @@ const MenuButton = react.forwardRef(function(props, forwardedRef) {
|
|
|
810
810
|
return $[57] !== menu || $[58] !== open || $[59] !== popoverProps || $[60] !== t25 ? (t26 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Popover, { "data-ui": "MenuButton__popover", ...popoverProps, content: menu, open, children: t25 }), $[57] = menu, $[58] = open, $[59] = popoverProps, $[60] = t25, $[61] = t26) : t26 = $[61], t26;
|
|
811
811
|
});
|
|
812
812
|
MenuButton.displayName = "ForwardRef(MenuButton)";
|
|
813
|
-
function _temp$
|
|
813
|
+
function _temp$2(v) {
|
|
814
814
|
return !v;
|
|
815
815
|
}
|
|
816
816
|
const keyframe = styledComponents.keyframes`
|
|
@@ -959,55 +959,7 @@ const TabPanel = react.forwardRef(function(props, ref) {
|
|
|
959
959
|
return $[3] !== flex || $[4] !== props.children || $[5] !== ref || $[6] !== restProps || $[7] !== t0 ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { "data-ui": "TabPanel", ...restProps, flex, ref, role: "tabpanel", tabIndex: t0, children: props.children }), $[3] = flex, $[4] = props.children, $[5] = ref, $[6] = restProps, $[7] = t0, $[8] = t1) : t1 = $[8], t1;
|
|
960
960
|
});
|
|
961
961
|
TabPanel.displayName = "ForwardRef(TabPanel)";
|
|
962
|
-
const
|
|
963
|
-
displayName: "TextBox",
|
|
964
|
-
componentId: "sc-1rr7rxo-0"
|
|
965
|
-
})`overflow-x:auto;`, loadingAnimation = styledComponents.keyframes`
|
|
966
|
-
0% {
|
|
967
|
-
width: 0;
|
|
968
|
-
}
|
|
969
|
-
100% {
|
|
970
|
-
width: 100%;
|
|
971
|
-
}
|
|
972
|
-
`, LOADING_BAR_HEIGHT = 2;
|
|
973
|
-
function rootStyles(props) {
|
|
974
|
-
const {
|
|
975
|
-
color
|
|
976
|
-
} = getTheme_v2.getTheme_v2(props.theme), loadingBarColor = color.button.default[props.tone].enabled.bg;
|
|
977
|
-
return props.$duration ? styledComponents.css`
|
|
978
|
-
pointer-events: all;
|
|
979
|
-
width: 100%;
|
|
980
|
-
position: relative;
|
|
981
|
-
overflow: hidden;
|
|
982
|
-
overflow: clip;
|
|
983
|
-
padding-bottom: ${LOADING_BAR_HEIGHT}px;
|
|
984
|
-
&::before {
|
|
985
|
-
content: '';
|
|
986
|
-
position: absolute;
|
|
987
|
-
bottom: 0px;
|
|
988
|
-
height: ${LOADING_BAR_HEIGHT}px;
|
|
989
|
-
background: ${loadingBarColor};
|
|
990
|
-
animation-name: ${loadingAnimation};
|
|
991
|
-
animation-duration: ${props.$duration}ms;
|
|
992
|
-
animation-fill-mode: both;
|
|
993
|
-
animation-timing-function: linear;
|
|
994
|
-
opacity: var(${_visualEditing.POPOVER_MOTION_CONTENT_OPACITY_PROPERTY}, 1);
|
|
995
|
-
will-change: width;
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
& > * {
|
|
999
|
-
opacity: var(${_visualEditing.POPOVER_MOTION_CONTENT_OPACITY_PROPERTY}, 1);
|
|
1000
|
-
will-change: opacity;
|
|
1001
|
-
}
|
|
1002
|
-
` : styledComponents.css`
|
|
1003
|
-
pointer-events: all;
|
|
1004
|
-
& > * {
|
|
1005
|
-
opacity: var(${_visualEditing.POPOVER_MOTION_CONTENT_OPACITY_PROPERTY}, 1);
|
|
1006
|
-
will-change: opacity;
|
|
1007
|
-
}
|
|
1008
|
-
`;
|
|
1009
|
-
}
|
|
1010
|
-
const STATUS_CARD_TONE = {
|
|
962
|
+
const LOADING_BAR_HEIGHT = 2, STATUS_CARD_TONE = {
|
|
1011
963
|
error: "critical",
|
|
1012
964
|
warning: "caution",
|
|
1013
965
|
success: "positive",
|
|
@@ -1017,18 +969,35 @@ const STATUS_CARD_TONE = {
|
|
|
1017
969
|
warning: "caution",
|
|
1018
970
|
success: "positive",
|
|
1019
971
|
info: "neutral"
|
|
1020
|
-
},
|
|
972
|
+
}, TextBox = styledComponents.styled(_visualEditing.Flex).withConfig({
|
|
973
|
+
displayName: "TextBox",
|
|
974
|
+
componentId: "sc-1rr7rxo-0"
|
|
975
|
+
})`overflow-x:auto;`, StyledToast = styledComponents.styled(_visualEditing.Card).withConfig({
|
|
976
|
+
displayName: "StyledToast",
|
|
977
|
+
componentId: "sc-1rr7rxo-1"
|
|
978
|
+
})`pointer-events:all;width:100%;position:relative;overflow:hidden;overflow:clip;&[data-has-duration]{padding-bottom:calc(${LOADING_BAR_HEIGHT}px / 2);}`, LoadingBar = styledComponents.styled.div.withConfig({
|
|
979
|
+
displayName: "LoadingBar",
|
|
980
|
+
componentId: "sc-1rr7rxo-2"
|
|
981
|
+
})`display:flex;position:absolute;bottom:0px;top:0px;left:0px;right:0px;pointer-events:none;z-index:-1;overflow:hidden;overflow:clip;background:transparent;align-items:flex-end;will-change:opacity;`, LoadingBarMask = styledComponents.styled(_visualEditing.Card).withConfig({
|
|
982
|
+
displayName: "LoadingBarMask",
|
|
983
|
+
componentId: "sc-1rr7rxo-3"
|
|
984
|
+
})`position:absolute;top:0;left:-${LOADING_BAR_HEIGHT}px;right:-${LOADING_BAR_HEIGHT}px;bottom:${LOADING_BAR_HEIGHT}px;z-index:1;`, LoadingBarProgress = styledComponents.styled(_visualEditing.Card).withConfig({
|
|
985
|
+
displayName: "LoadingBarProgress",
|
|
986
|
+
componentId: "sc-1rr7rxo-4"
|
|
987
|
+
})`display:block;height:100%;width:100%;transform-origin:0% 50%;background-color:${(props) => {
|
|
988
|
+
const {
|
|
989
|
+
color
|
|
990
|
+
} = getTheme_v2.getTheme_v2(props.theme);
|
|
991
|
+
return color.button.default[props.tone].enabled.bg;
|
|
992
|
+
}};`, ROLES = {
|
|
1021
993
|
error: "alert",
|
|
1022
994
|
warning: "alert",
|
|
1023
995
|
success: "alert",
|
|
1024
996
|
info: "alert"
|
|
1025
|
-
},
|
|
1026
|
-
displayName: "StyledToast",
|
|
1027
|
-
componentId: "sc-1icz8ea-0"
|
|
1028
|
-
})(rootStyles);
|
|
997
|
+
}, LONG_ENOUGH_BUT_NOT_TOO_LONG = 1e3 * 60 * 60 * 24 * 24;
|
|
1029
998
|
function Toast(props) {
|
|
1030
|
-
const $ = reactCompilerRuntime.c(
|
|
1031
|
-
let closable, description, duration, onClose, restProps, status, t0, title;
|
|
999
|
+
const $ = reactCompilerRuntime.c(52);
|
|
1000
|
+
let closable, description, duration, onClose, restProps, status, t0, title, updatedAt;
|
|
1032
1001
|
$[0] !== props ? ({
|
|
1033
1002
|
closable,
|
|
1034
1003
|
description,
|
|
@@ -1037,151 +1006,196 @@ function Toast(props) {
|
|
|
1037
1006
|
radius: t0,
|
|
1038
1007
|
title,
|
|
1039
1008
|
status,
|
|
1009
|
+
updatedAt,
|
|
1040
1010
|
...restProps
|
|
1041
|
-
} = props, $[0] = props, $[1] = closable, $[2] = description, $[3] = duration, $[4] = onClose, $[5] = restProps, $[6] = status, $[7] = t0, $[8] = title) : (closable = $[1], description = $[2], duration = $[3], onClose = $[4], restProps = $[5], status = $[6], t0 = $[7], title = $[8]);
|
|
1042
|
-
const radius = t0 === void 0 ? 3 : t0, cardTone = status ? STATUS_CARD_TONE[status] : "default", buttonTone = status ? BUTTON_TONE[status] : "default", role = status ? ROLES[status] : "status";
|
|
1011
|
+
} = props, $[0] = props, $[1] = closable, $[2] = description, $[3] = duration, $[4] = onClose, $[5] = restProps, $[6] = status, $[7] = t0, $[8] = title, $[9] = updatedAt) : (closable = $[1], description = $[2], duration = $[3], onClose = $[4], restProps = $[5], status = $[6], t0 = $[7], title = $[8], updatedAt = $[9]);
|
|
1012
|
+
const radius = t0 === void 0 ? 3 : t0, cardTone = status ? STATUS_CARD_TONE[status] : "default", buttonTone = status ? BUTTON_TONE[status] : "default", role = status ? ROLES[status] : "status", visualDuration = _visualEditing.usePrefersReducedMotion() ? 0 : 0.26;
|
|
1043
1013
|
let t1;
|
|
1044
|
-
$[
|
|
1014
|
+
$[10] !== visualDuration ? (t1 = visualDuration ? {
|
|
1015
|
+
type: "spring",
|
|
1016
|
+
visualDuration,
|
|
1017
|
+
bounce: 0.25
|
|
1018
|
+
} : {
|
|
1019
|
+
duration: 0
|
|
1020
|
+
}, $[10] = visualDuration, $[11] = t1) : t1 = $[11];
|
|
1021
|
+
const transition = t1;
|
|
1045
1022
|
let t2;
|
|
1046
|
-
$[
|
|
1023
|
+
$[12] !== duration ? (t2 = duration && isFinite(duration) && duration < LONG_ENOUGH_BUT_NOT_TOO_LONG, $[12] = duration, $[13] = t2) : t2 = $[13];
|
|
1024
|
+
const hasDuration = t2;
|
|
1047
1025
|
let t3;
|
|
1048
|
-
$[
|
|
1049
|
-
|
|
1050
|
-
t2
|
|
1051
|
-
] }) }), $[13] = t1, $[14] = t2, $[15] = t3) : t3 = $[15];
|
|
1026
|
+
$[14] === Symbol.for("react.memo_cache_sentinel") ? (t3 = ["hidden", "initial"], $[14] = t3) : t3 = $[14];
|
|
1027
|
+
const initial = t3;
|
|
1052
1028
|
let t4;
|
|
1053
|
-
$[
|
|
1054
|
-
|
|
1055
|
-
} }) }), $[16] = buttonTone, $[17] = closable, $[18] = onClose, $[19] = t4) : t4 = $[19];
|
|
1029
|
+
$[15] === Symbol.for("react.memo_cache_sentinel") ? (t4 = ["visible", "slideIn"], $[15] = t4) : t4 = $[15];
|
|
1030
|
+
const animate = t4;
|
|
1056
1031
|
let t5;
|
|
1057
|
-
$[
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
let
|
|
1062
|
-
|
|
1032
|
+
$[16] === Symbol.for("react.memo_cache_sentinel") ? (t5 = ["hidden", "slideOut"], $[16] = t5) : t5 = $[16];
|
|
1033
|
+
const exit = t5, t6 = hasDuration ? "" : void 0;
|
|
1034
|
+
let t7;
|
|
1035
|
+
$[17] !== title ? (t7 = title && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { size: 1, weight: "medium", children: title }), $[17] = title, $[18] = t7) : t7 = $[18];
|
|
1036
|
+
let t8;
|
|
1037
|
+
$[19] !== description || $[20] !== transition ? (t8 = description && /* @__PURE__ */ jsxRuntime.jsx(MotionText, { muted: !0, size: 1, variants: content, transition, children: description }), $[19] = description, $[20] = transition, $[21] = t8) : t8 = $[21];
|
|
1038
|
+
let t9;
|
|
1039
|
+
$[22] !== t7 || $[23] !== t8 ? (t9 = /* @__PURE__ */ jsxRuntime.jsx(TextBox, { flex: 1, padding: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Stack, { space: 3, children: [
|
|
1040
|
+
t7,
|
|
1041
|
+
t8
|
|
1042
|
+
] }) }), $[22] = t7, $[23] = t8, $[24] = t9) : t9 = $[24];
|
|
1043
|
+
let t10;
|
|
1044
|
+
$[25] !== buttonTone || $[26] !== closable || $[27] !== onClose ? (t10 = closable && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { padding: 1, children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Button, { as: "button", icon: icons.CloseIcon, mode: "bleed", padding: 2, tone: buttonTone, onClick: onClose, style: {
|
|
1045
|
+
verticalAlign: "top"
|
|
1046
|
+
} }) }), $[25] = buttonTone, $[26] = closable, $[27] = onClose, $[28] = t10) : t10 = $[28];
|
|
1047
|
+
let t11;
|
|
1048
|
+
$[29] !== t10 || $[30] !== t9 || $[31] !== transition ? (t11 = /* @__PURE__ */ jsxRuntime.jsxs(MotionFlex, { align: "flex-start", variants: content, transition, children: [
|
|
1049
|
+
t9,
|
|
1050
|
+
t10
|
|
1051
|
+
] }), $[29] = t10, $[30] = t9, $[31] = transition, $[32] = t11) : t11 = $[32];
|
|
1052
|
+
let t12;
|
|
1053
|
+
$[33] !== cardTone || $[34] !== duration || $[35] !== hasDuration || $[36] !== onClose || $[37] !== radius || $[38] !== transition || $[39] !== updatedAt || $[40] !== visualDuration ? (t12 = hasDuration && /* @__PURE__ */ jsxRuntime.jsxs(MotionLoadingBar, { variants: content, transition, children: [
|
|
1054
|
+
/* @__PURE__ */ jsxRuntime.jsx(LoadingBarMask, { tone: cardTone, radius }),
|
|
1055
|
+
/* @__PURE__ */ jsxRuntime.jsx(MotionLoadingBarProgress, { tone: cardTone, initial: {
|
|
1056
|
+
scaleX: 0
|
|
1057
|
+
}, animate: {
|
|
1058
|
+
scaleX: 1
|
|
1059
|
+
}, transition: {
|
|
1060
|
+
delay: visualDuration,
|
|
1061
|
+
duration: duration / 1e3,
|
|
1062
|
+
ease: "linear"
|
|
1063
|
+
}, onAnimationComplete: onClose }, `progress-${updatedAt}`)
|
|
1064
|
+
] }), $[33] = cardTone, $[34] = duration, $[35] = hasDuration, $[36] = onClose, $[37] = radius, $[38] = transition, $[39] = updatedAt, $[40] = visualDuration, $[41] = t12) : t12 = $[41];
|
|
1065
|
+
let t13;
|
|
1066
|
+
return $[42] !== cardTone || $[43] !== radius || $[44] !== restProps || $[45] !== role || $[46] !== t11 || $[47] !== t12 || $[48] !== t6 || $[49] !== transition || $[50] !== visualDuration ? (t13 = /* @__PURE__ */ jsxRuntime.jsxs(MotionToast, { "data-ui": "Toast", role, ...restProps, "data-has-duration": t6, custom: visualDuration, radius, shadow: 2, tone: cardTone, forwardedAs: "li", layout: "position", variants: container, initial, animate, exit, transition, children: [
|
|
1067
|
+
t11,
|
|
1068
|
+
t12
|
|
1069
|
+
] }), $[42] = cardTone, $[43] = radius, $[44] = restProps, $[45] = role, $[46] = t11, $[47] = t12, $[48] = t6, $[49] = transition, $[50] = visualDuration, $[51] = t13) : t13 = $[51], t13;
|
|
1063
1070
|
}
|
|
1064
1071
|
Toast.displayName = "Toast";
|
|
1072
|
+
const container = {
|
|
1073
|
+
initial: {
|
|
1074
|
+
y: 32,
|
|
1075
|
+
scale: 0.5,
|
|
1076
|
+
zIndex: 1
|
|
1077
|
+
},
|
|
1078
|
+
hidden: {
|
|
1079
|
+
opacity: 0
|
|
1080
|
+
},
|
|
1081
|
+
visible: (visualDuration) => visualDuration ? {
|
|
1082
|
+
opacity: 1,
|
|
1083
|
+
transition: {
|
|
1084
|
+
when: "beforeChildren",
|
|
1085
|
+
staggerChildren: visualDuration / 3,
|
|
1086
|
+
duration: visualDuration / 3
|
|
1087
|
+
}
|
|
1088
|
+
} : {
|
|
1089
|
+
opacity: 1
|
|
1090
|
+
},
|
|
1091
|
+
slideIn: {
|
|
1092
|
+
y: 0,
|
|
1093
|
+
scale: 1
|
|
1094
|
+
},
|
|
1095
|
+
slideOut: {
|
|
1096
|
+
zIndex: 0,
|
|
1097
|
+
scale: 0.75
|
|
1098
|
+
}
|
|
1099
|
+
}, content = {
|
|
1100
|
+
initial: {
|
|
1101
|
+
willChange: "transform"
|
|
1102
|
+
},
|
|
1103
|
+
hidden: {
|
|
1104
|
+
opacity: 0
|
|
1105
|
+
},
|
|
1106
|
+
visible: {
|
|
1107
|
+
opacity: 1
|
|
1108
|
+
}
|
|
1109
|
+
}, MotionToast = framerMotion.motion.create(StyledToast), MotionFlex = framerMotion.motion.create(_visualEditing.Flex), MotionText = framerMotion.motion.create(_visualEditing.Text), MotionLoadingBar = framerMotion.motion.create(LoadingBar), MotionLoadingBarProgress = framerMotion.motion.create(LoadingBarProgress);
|
|
1065
1110
|
function useMounted() {
|
|
1066
|
-
return react.useSyncExternalStore(subscribe, _temp, _temp2);
|
|
1111
|
+
return react.useSyncExternalStore(subscribe, _temp$1, _temp2);
|
|
1067
1112
|
}
|
|
1068
1113
|
function _temp2() {
|
|
1069
1114
|
return !1;
|
|
1070
1115
|
}
|
|
1071
|
-
function _temp() {
|
|
1116
|
+
function _temp$1() {
|
|
1072
1117
|
return !0;
|
|
1073
1118
|
}
|
|
1074
1119
|
const subscribe = () => () => {
|
|
1075
1120
|
}, ToastContext = _visualEditing.createGlobalScopedContext("@sanity/ui/context/toast", null);
|
|
1121
|
+
function ToastLayer(props) {
|
|
1122
|
+
const $ = reactCompilerRuntime.c(9), {
|
|
1123
|
+
children,
|
|
1124
|
+
padding: t0,
|
|
1125
|
+
paddingX,
|
|
1126
|
+
paddingY,
|
|
1127
|
+
gap: t1
|
|
1128
|
+
} = props, padding = t0 === void 0 ? 4 : t0, gap = t1 === void 0 ? 3 : t1, {
|
|
1129
|
+
zIndex
|
|
1130
|
+
} = _visualEditing.useLayer();
|
|
1131
|
+
let t2;
|
|
1132
|
+
$[0] !== zIndex ? (t2 = {
|
|
1133
|
+
zIndex
|
|
1134
|
+
}, $[0] = zIndex, $[1] = t2) : t2 = $[1];
|
|
1135
|
+
let t3;
|
|
1136
|
+
return $[2] !== children || $[3] !== gap || $[4] !== padding || $[5] !== paddingX || $[6] !== paddingY || $[7] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(StyledLayer, { forwardedAs: "ul", "data-ui": "ToastProvider", padding, paddingX, paddingY, gap, columns: 1, style: t2, children }), $[2] = children, $[3] = gap, $[4] = padding, $[5] = paddingX, $[6] = paddingY, $[7] = t2, $[8] = t3) : t3 = $[8], t3;
|
|
1137
|
+
}
|
|
1138
|
+
ToastLayer.displayName = "ToastLayer";
|
|
1139
|
+
const StyledLayer = styledComponents.styled(_visualEditing.Grid).withConfig({
|
|
1140
|
+
displayName: "StyledLayer",
|
|
1141
|
+
componentId: "sc-1tbwn58-0"
|
|
1142
|
+
})`box-sizing:border-box;position:fixed;right:0;bottom:0;list-style:none;pointer-events:none;max-width:420px;width:100%;`;
|
|
1076
1143
|
let toastId = 0;
|
|
1077
1144
|
function generateToastId() {
|
|
1078
1145
|
return String(toastId++);
|
|
1079
1146
|
}
|
|
1080
|
-
const StyledToastProvider = styledComponents.styled(_visualEditing.Layer).withConfig({
|
|
1081
|
-
displayName: "StyledToastProvider",
|
|
1082
|
-
componentId: "sc-17mn6j-0"
|
|
1083
|
-
})`position:fixed;top:0;left:0;right:0;bottom:0;pointer-events:none;`, ToastContainer = styledComponents.styled.div.withConfig({
|
|
1084
|
-
displayName: "ToastContainer",
|
|
1085
|
-
componentId: "sc-17mn6j-1"
|
|
1086
|
-
})`box-sizing:border-box;position:absolute;right:0;bottom:0;max-width:420px;width:100%;`;
|
|
1087
1147
|
function ToastProvider(props) {
|
|
1088
|
-
const $ = reactCompilerRuntime.c(
|
|
1148
|
+
const $ = reactCompilerRuntime.c(13), {
|
|
1089
1149
|
children,
|
|
1090
|
-
padding
|
|
1150
|
+
padding,
|
|
1091
1151
|
paddingX,
|
|
1092
1152
|
paddingY,
|
|
1093
|
-
|
|
1094
|
-
|
|
1153
|
+
gap,
|
|
1154
|
+
zOffset: t0
|
|
1155
|
+
} = props, zOffset = t0 === void 0 ? 1 : t0;
|
|
1095
1156
|
let t1;
|
|
1096
1157
|
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[0] = t1) : t1 = $[0];
|
|
1097
|
-
const [state,
|
|
1098
|
-
let t2;
|
|
1099
|
-
$[1] === Symbol.for("react.memo_cache_sentinel") ? (
|
|
1100
|
-
const toastsRef = react.useRef(t2), mounted = useMounted(), prefersReducedMotion = _visualEditing.usePrefersReducedMotion();
|
|
1101
|
-
let t3, t4, t5, t6;
|
|
1102
|
-
$[2] === Symbol.for("react.memo_cache_sentinel") ? (t4 = {
|
|
1103
|
-
opacity: 0,
|
|
1104
|
-
[_visualEditing.POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: -1,
|
|
1105
|
-
y: 32,
|
|
1106
|
-
scale: 0.25,
|
|
1107
|
-
willChange: "transform"
|
|
1108
|
-
}, t5 = {
|
|
1109
|
-
opacity: 2,
|
|
1110
|
-
[_visualEditing.POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: 1,
|
|
1111
|
-
y: 0,
|
|
1112
|
-
scale: 1
|
|
1113
|
-
}, t6 = {
|
|
1114
|
-
opacity: 0,
|
|
1115
|
-
[_visualEditing.POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: -1,
|
|
1116
|
-
scale: 0.5
|
|
1117
|
-
}, $[2] = t4, $[3] = t5, $[4] = t6) : (t4 = $[2], t5 = $[3], t6 = $[4]);
|
|
1118
|
-
const t7 = prefersReducedMotion ? 0 : 0.2;
|
|
1119
|
-
let t8;
|
|
1120
|
-
$[5] !== t7 ? (t8 = {
|
|
1121
|
-
initial: t4,
|
|
1122
|
-
animate: t5,
|
|
1123
|
-
exit: t6,
|
|
1124
|
-
transition: {
|
|
1125
|
-
duration: t7
|
|
1126
|
-
}
|
|
1127
|
-
}, $[5] = t7, $[6] = t8) : t8 = $[6], t3 = t8;
|
|
1128
|
-
const variants = t3;
|
|
1129
|
-
let t9, t10;
|
|
1130
|
-
$[7] === Symbol.for("react.memo_cache_sentinel") ? (t10 = {
|
|
1158
|
+
const [state, setState] = react.useState(t1), mounted = useMounted();
|
|
1159
|
+
let t2, t3;
|
|
1160
|
+
$[1] === Symbol.for("react.memo_cache_sentinel") ? (t3 = {
|
|
1131
1161
|
version: 0,
|
|
1132
1162
|
push: (params) => {
|
|
1133
|
-
const
|
|
1134
|
-
|
|
1163
|
+
const id = params.id || generateToastId(), duration = params.duration || 5e3;
|
|
1164
|
+
return react.startTransition(() => {
|
|
1135
1165
|
setState((prevState) => {
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
}
|
|
1151
|
-
}])), toastsRef.current[id] && (clearTimeout(toastsRef.current[id].timeoutId), delete toastsRef.current[id]), toastsRef.current[id] = {
|
|
1152
|
-
timeoutId: setTimeout(dismiss, duration)
|
|
1153
|
-
}, id;
|
|
1166
|
+
if (duration === 0.01)
|
|
1167
|
+
return prevState.filter((toast) => toast.id !== id);
|
|
1168
|
+
const dismiss = () => react.startTransition(() => setState((currentState) => currentState.filter((toast_0) => toast_0.id !== id)));
|
|
1169
|
+
return [...prevState.filter((toast_1) => toast_1.id !== id), {
|
|
1170
|
+
dismiss,
|
|
1171
|
+
id,
|
|
1172
|
+
updatedAt: Date.now(),
|
|
1173
|
+
params: {
|
|
1174
|
+
...params,
|
|
1175
|
+
duration
|
|
1176
|
+
}
|
|
1177
|
+
}];
|
|
1178
|
+
});
|
|
1179
|
+
}), id;
|
|
1154
1180
|
}
|
|
1155
|
-
}, $[
|
|
1156
|
-
const value =
|
|
1157
|
-
let
|
|
1158
|
-
$[8]
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
} of Object.values(toastsRef.current))
|
|
1162
|
-
clearTimeout(timeoutId_0);
|
|
1163
|
-
toastsRef.current = {};
|
|
1164
|
-
}, t12 = [], $[8] = t11, $[9] = t12) : (t11 = $[8], t12 = $[9]), react.useEffect(t11, t12);
|
|
1165
|
-
let t13;
|
|
1166
|
-
$[10] !== mounted || $[11] !== padding || $[12] !== paddingX || $[13] !== paddingY || $[14] !== prefersReducedMotion || $[15] !== state || $[16] !== variants || $[17] !== zOffset ? (t13 = mounted && /* @__PURE__ */ jsxRuntime.jsx(StyledToastProvider, { "data-ui": "ToastProvider", zOffset, children: /* @__PURE__ */ jsxRuntime.jsx(ToastContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { padding, paddingX, paddingY, children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { initial: !1, children: state.map((t142) => {
|
|
1167
|
-
const {
|
|
1168
|
-
dismiss: dismiss_0,
|
|
1169
|
-
id: id_0,
|
|
1170
|
-
params: params_0
|
|
1171
|
-
} = t142;
|
|
1172
|
-
return /* @__PURE__ */ jsxRuntime.jsx(framerMotion.motion.div, { layout: "position", initial: "initial", animate: "animate", exit: "exit", variants, transition: prefersReducedMotion ? {
|
|
1173
|
-
duration: 0
|
|
1174
|
-
} : {
|
|
1175
|
-
type: "spring",
|
|
1176
|
-
damping: 30,
|
|
1177
|
-
stiffness: 400
|
|
1178
|
-
}, children: /* @__PURE__ */ jsxRuntime.jsx(Toast, { closable: params_0.closable, description: params_0.description, onClose: dismiss_0, status: params_0.status, title: params_0.title, duration: params_0.duration }) }, id_0);
|
|
1179
|
-
}) }) }) }) }), $[10] = mounted, $[11] = padding, $[12] = paddingX, $[13] = paddingY, $[14] = prefersReducedMotion, $[15] = state, $[16] = variants, $[17] = zOffset, $[18] = t13) : t13 = $[18];
|
|
1180
|
-
let t14;
|
|
1181
|
-
return $[19] !== children || $[20] !== t13 ? (t14 = /* @__PURE__ */ jsxRuntime.jsxs(ToastContext.Provider, { value, children: [
|
|
1181
|
+
}, $[1] = t3) : t3 = $[1], t2 = t3;
|
|
1182
|
+
const value = t2;
|
|
1183
|
+
let t4;
|
|
1184
|
+
$[2] !== gap || $[3] !== mounted || $[4] !== padding || $[5] !== paddingX || $[6] !== paddingY || $[7] !== state || $[8] !== zOffset ? (t4 = mounted && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.LayerProvider, { zOffset, children: /* @__PURE__ */ jsxRuntime.jsx(ToastLayer, { padding, paddingX, paddingY, gap, children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { initial: !1, mode: "popLayout", children: state.map(_temp) }) }) }), $[2] = gap, $[3] = mounted, $[4] = padding, $[5] = paddingX, $[6] = paddingY, $[7] = state, $[8] = zOffset, $[9] = t4) : t4 = $[9];
|
|
1185
|
+
let t5;
|
|
1186
|
+
return $[10] !== children || $[11] !== t4 ? (t5 = /* @__PURE__ */ jsxRuntime.jsxs(ToastContext.Provider, { value, children: [
|
|
1182
1187
|
children,
|
|
1183
|
-
|
|
1184
|
-
] }), $[
|
|
1188
|
+
t4
|
|
1189
|
+
] }), $[10] = children, $[11] = t4, $[12] = t5) : t5 = $[12], t5;
|
|
1190
|
+
}
|
|
1191
|
+
function _temp(t0) {
|
|
1192
|
+
const {
|
|
1193
|
+
dismiss: dismiss_0,
|
|
1194
|
+
id: id_0,
|
|
1195
|
+
params: params_0,
|
|
1196
|
+
updatedAt
|
|
1197
|
+
} = t0;
|
|
1198
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Toast, { closable: params_0.closable, description: params_0.description, onClose: dismiss_0, status: params_0.status, title: params_0.title, duration: params_0.duration, updatedAt }, id_0);
|
|
1185
1199
|
}
|
|
1186
1200
|
ToastProvider.displayName = "ToastProvider";
|
|
1187
1201
|
function useToast() {
|
|
@@ -1559,7 +1573,7 @@ const TreeGroup = react.memo(function(props) {
|
|
|
1559
1573
|
if (rootRef.current)
|
|
1560
1574
|
return registerItem(rootRef.current, itemPath.join("/"), expanded, selected);
|
|
1561
1575
|
}, [expanded, itemPath, registerItem, selected]);
|
|
1562
|
-
const
|
|
1576
|
+
const content2 = /* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Flex, { padding, children: [
|
|
1563
1577
|
/* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Box, { marginRight: space, style: {
|
|
1564
1578
|
visibility: IconComponent || children ? "visible" : "hidden",
|
|
1565
1579
|
pointerEvents: "none"
|
|
@@ -1572,10 +1586,10 @@ const TreeGroup = react.memo(function(props) {
|
|
|
1572
1586
|
/* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { muted, size: fontSize, textOverflow: "ellipsis", weight, children: text }) })
|
|
1573
1587
|
] });
|
|
1574
1588
|
return href ? /* @__PURE__ */ jsxRuntime.jsxs(StyledTreeItem, { "data-selected": selected ? "" : void 0, "data-tree-id": id, "data-tree-key": itemKey, "data-ui": "TreeItem", ...restProps, onClick: handleClick, ref: rootRef, role: "none", children: [
|
|
1575
|
-
/* @__PURE__ */ jsxRuntime.jsx(TreeItemBox, { $level: tree.level, "aria-expanded": expanded, as: linkAs, "data-ui": "TreeItem__box", href, ref: treeitemRef, role: "treeitem", tabIndex, children:
|
|
1589
|
+
/* @__PURE__ */ jsxRuntime.jsx(TreeItemBox, { $level: tree.level, "aria-expanded": expanded, as: linkAs, "data-ui": "TreeItem__box", href, ref: treeitemRef, role: "treeitem", tabIndex, children: content2 }),
|
|
1576
1590
|
/* @__PURE__ */ jsxRuntime.jsx(TreeContext.Provider, { value: contextValue, children: children && /* @__PURE__ */ jsxRuntime.jsx(TreeGroup, { hidden: !expanded, children }) })
|
|
1577
1591
|
] }) : /* @__PURE__ */ jsxRuntime.jsxs(StyledTreeItem, { "data-selected": selected ? "" : void 0, "data-ui": "TreeItem", "data-tree-id": id, "data-tree-key": itemKey, ...restProps, "aria-expanded": expanded, onClick: handleClick, onKeyDown: handleKeyDown, ref: rootRef, role: "treeitem", tabIndex, children: [
|
|
1578
|
-
/* @__PURE__ */ jsxRuntime.jsx(TreeItemBox, { $level: tree.level, as: "div", "data-ui": "TreeItem__box", children:
|
|
1592
|
+
/* @__PURE__ */ jsxRuntime.jsx(TreeItemBox, { $level: tree.level, as: "div", "data-ui": "TreeItem__box", children: content2 }),
|
|
1579
1593
|
/* @__PURE__ */ jsxRuntime.jsx(TreeContext.Provider, { value: contextValue, children: children && /* @__PURE__ */ jsxRuntime.jsx(TreeGroup, { expanded, children }) })
|
|
1580
1594
|
] });
|
|
1581
1595
|
});
|