@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/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"), framerMotion = require("framer-motion"), getTheme_v2 = require("./_chunks-cjs/getTheme_v2.js");
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"), getTheme_v2 = require("./_chunks-cjs/getTheme_v2.js"), framerMotion = require("framer-motion");
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]), 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) => {
386
+ }, [listFocused]), content = 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: content2,
394
+ content,
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: 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]);
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 }), [content, 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$2), setShouldFocus(null);
711
+ setOpen(_temp$1), 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$2(v) {
813
+ function _temp$1(v) {
814
814
  return !v;
815
815
  }
816
816
  const keyframe = styledComponents.keyframes`
@@ -959,7 +959,55 @@ 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 LOADING_BAR_HEIGHT = 2, STATUS_CARD_TONE = {
962
+ const TextBox = styledComponents.styled(_visualEditing.Flex).withConfig({
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 = {
963
1011
  error: "critical",
964
1012
  warning: "caution",
965
1013
  success: "positive",
@@ -969,214 +1017,171 @@ const LOADING_BAR_HEIGHT = 2, STATUS_CARD_TONE = {
969
1017
  warning: "caution",
970
1018
  success: "positive",
971
1019
  info: "neutral"
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;will-change:opacity,transform;&[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;`, LoadingBarProgress = styledComponents.styled(_visualEditing.Card).withConfig({
982
- displayName: "LoadingBarProgress",
983
- componentId: "sc-1rr7rxo-3"
984
- })`display:block;height:100%;width:100%;transform-origin:0% 50%;background-color:${(props) => {
985
- const {
986
- color
987
- } = getTheme_v2.getTheme_v2(props.theme);
988
- return color.button.default[props.tone].enabled.bg;
989
- }};`, ROLES = {
1020
+ }, ROLES = {
990
1021
  error: "alert",
991
1022
  warning: "alert",
992
1023
  success: "alert",
993
1024
  info: "alert"
994
- };
1025
+ }, StyledToast = /* @__PURE__ */ styledComponents.styled(_visualEditing.Card).withConfig({
1026
+ displayName: "StyledToast",
1027
+ componentId: "sc-1icz8ea-0"
1028
+ })(rootStyles);
995
1029
  function Toast(props) {
996
- const {
1030
+ const $ = reactCompilerRuntime.c(30);
1031
+ let closable, description, duration, onClose, restProps, status, t0, title;
1032
+ $[0] !== props ? ({
997
1033
  closable,
998
1034
  description,
999
1035
  duration,
1000
1036
  onClose,
1001
- radius = 3,
1037
+ radius: t0,
1002
1038
  title,
1003
1039
  status,
1004
- updatedAt,
1005
1040
  ...restProps
1006
- } = props, cardTone = status ? STATUS_CARD_TONE[status] : "default", buttonTone = status ? BUTTON_TONE[status] : "default", role = status ? ROLES[status] : "status";
1007
- let visualDuration = _visualEditing.usePrefersReducedMotion() ? 0 : 0.26;
1008
- const transition = visualDuration ? {
1009
- type: "spring",
1010
- visualDuration,
1011
- bounce: 0.25
1012
- } : {
1013
- duration: 0
1014
- }, hasDuration = duration && isFinite(duration);
1015
- return /* @__PURE__ */ jsxRuntime.jsxs(MotionToast, { "data-ui": "Toast", role, ...restProps, "data-has-duration": hasDuration ? "" : void 0, custom: visualDuration, radius, shadow: 2, tone: cardTone, forwardedAs: "li", layout: "position", variants: container, initial: ["hidden", "initial"], animate: ["visible", "slideIn"], exit: ["hidden", "slideOut"], transition, children: [
1016
- /* @__PURE__ */ jsxRuntime.jsxs(MotionFlex, { align: "flex-start", variants: content, transition, children: [
1017
- /* @__PURE__ */ jsxRuntime.jsx(TextBox, { flex: 1, padding: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Stack, { space: 3, children: [
1018
- title && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { size: 1, weight: "medium", children: title }),
1019
- description && /* @__PURE__ */ jsxRuntime.jsx(MotionText, { muted: !0, size: 1, variants: content, transition, children: description })
1020
- ] }) }),
1021
- 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: {
1022
- verticalAlign: "top"
1023
- } }) })
1024
- ] }),
1025
- hasDuration && /* @__PURE__ */ jsxRuntime.jsxs(MotionLoadiongBar, { variants: content, transition, children: [
1026
- /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Card, { tone: cardTone, radius, style: {
1027
- position: "absolute",
1028
- right: -2,
1029
- left: -2,
1030
- top: 0,
1031
- bottom: 2,
1032
- zIndex: 1
1033
- } }),
1034
- /* @__PURE__ */ jsxRuntime.jsx(MotionLoadiongBarProgress, { tone: cardTone, initial: {
1035
- scaleX: 0
1036
- }, animate: {
1037
- scaleX: 1
1038
- }, transition: {
1039
- delay: visualDuration,
1040
- duration: duration / 1e3,
1041
- ease: "linear"
1042
- }, onAnimationComplete: onClose }, `${duration}-${updatedAt}`)
1043
- ] })
1044
- ] });
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";
1043
+ let t1;
1044
+ $[9] !== title ? (t1 = title && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { size: 1, weight: "medium", children: title }), $[9] = title, $[10] = t1) : t1 = $[10];
1045
+ let t2;
1046
+ $[11] !== description ? (t2 = description && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { muted: !0, size: 1, children: description }), $[11] = description, $[12] = t2) : t2 = $[12];
1047
+ let t3;
1048
+ $[13] !== t1 || $[14] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(TextBox, { flex: 1, padding: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Stack, { space: 3, children: [
1049
+ t1,
1050
+ t2
1051
+ ] }) }), $[13] = t1, $[14] = t2, $[15] = t3) : t3 = $[15];
1052
+ let t4;
1053
+ $[16] !== buttonTone || $[17] !== closable || $[18] !== onClose ? (t4 = 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: {
1054
+ verticalAlign: "top"
1055
+ } }) }), $[16] = buttonTone, $[17] = closable, $[18] = onClose, $[19] = t4) : t4 = $[19];
1056
+ let t5;
1057
+ $[20] !== t3 || $[21] !== t4 ? (t5 = /* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Flex, { align: "flex-start", children: [
1058
+ t3,
1059
+ t4
1060
+ ] }), $[20] = t3, $[21] = t4, $[22] = t5) : t5 = $[22];
1061
+ let t6;
1062
+ return $[23] !== cardTone || $[24] !== duration || $[25] !== radius || $[26] !== restProps || $[27] !== role || $[28] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(StyledToast, { "data-ui": "Toast", role, ...restProps, marginTop: 3, radius, shadow: 2, tone: cardTone, $duration: duration, children: t5 }), $[23] = cardTone, $[24] = duration, $[25] = radius, $[26] = restProps, $[27] = role, $[28] = t5, $[29] = t6) : t6 = $[29], t6;
1045
1063
  }
1046
1064
  Toast.displayName = "Toast";
1047
- const container = {
1048
- initial: {
1049
- y: 32,
1050
- scale: 0.5,
1051
- zIndex: 1
1052
- },
1053
- hidden: {
1054
- opacity: 0
1055
- },
1056
- visible: (visualDuration) => visualDuration ? {
1057
- opacity: 1,
1058
- transition: {
1059
- when: "beforeChildren",
1060
- staggerChildren: visualDuration / 3,
1061
- duration: visualDuration / 3
1062
- }
1063
- } : {
1064
- opacity: 1
1065
- },
1066
- slideIn: {
1067
- y: 0,
1068
- scale: 1
1069
- },
1070
- slideOut: {
1071
- zIndex: 0,
1072
- scale: 0.75
1073
- }
1074
- }, content = {
1075
- hidden: {
1076
- opacity: 0
1077
- },
1078
- visible: {
1079
- opacity: 1
1080
- }
1081
- }, MotionToast = framerMotion.motion.create(StyledToast), MotionFlex = framerMotion.motion.create(_visualEditing.Flex), MotionText = framerMotion.motion.create(_visualEditing.Text), MotionLoadiongBar = framerMotion.motion.create(LoadingBar), MotionLoadiongBarProgress = framerMotion.motion.create(LoadingBarProgress);
1082
1065
  function useMounted() {
1083
- return react.useSyncExternalStore(subscribe, _temp$1, _temp2);
1066
+ return react.useSyncExternalStore(subscribe, _temp, _temp2);
1084
1067
  }
1085
1068
  function _temp2() {
1086
1069
  return !1;
1087
1070
  }
1088
- function _temp$1() {
1071
+ function _temp() {
1089
1072
  return !0;
1090
1073
  }
1091
1074
  const subscribe = () => () => {
1092
1075
  }, ToastContext = _visualEditing.createGlobalScopedContext("@sanity/ui/context/toast", null);
1093
- function ToastLayer(props) {
1094
- const $ = reactCompilerRuntime.c(9), {
1095
- children,
1096
- padding: t0,
1097
- paddingX,
1098
- paddingY,
1099
- gap: t1
1100
- } = props, padding = t0 === void 0 ? 4 : t0, gap = t1 === void 0 ? 3 : t1, {
1101
- zIndex
1102
- } = _visualEditing.useLayer();
1103
- let t2;
1104
- $[0] !== zIndex ? (t2 = {
1105
- zIndex
1106
- }, $[0] = zIndex, $[1] = t2) : t2 = $[1];
1107
- let t3;
1108
- 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;
1109
- }
1110
- ToastLayer.displayName = "ToastLayer";
1111
- const StyledLayer = styledComponents.styled(_visualEditing.Grid).withConfig({
1112
- displayName: "StyledLayer",
1113
- componentId: "sc-1tbwn58-0"
1114
- })`box-sizing:border-box;position:fixed;right:0;bottom:0;list-style:none;pointer-events:none;max-width:420px;width:100%;`;
1115
1076
  let toastId = 0;
1116
1077
  function generateToastId() {
1117
1078
  return String(toastId++);
1118
1079
  }
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%;`;
1119
1087
  function ToastProvider(props) {
1120
- const $ = reactCompilerRuntime.c(13), {
1088
+ const $ = reactCompilerRuntime.c(22), {
1121
1089
  children,
1122
- padding,
1090
+ padding: t0,
1123
1091
  paddingX,
1124
1092
  paddingY,
1125
- gap,
1126
- zOffset: t0
1127
- } = props, zOffset = t0 === void 0 ? 1 : t0;
1093
+ zOffset
1094
+ } = props, padding = t0 === void 0 ? 4 : t0;
1128
1095
  let t1;
1129
1096
  $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[0] = t1) : t1 = $[0];
1130
- const [state, setState] = react.useState(t1), mounted = useMounted();
1131
- let t2, t3;
1132
- $[1] === Symbol.for("react.memo_cache_sentinel") ? (t3 = {
1097
+ const [state, _setState] = react.useState(t1);
1098
+ let t2;
1099
+ $[1] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {}, $[1] = t2) : t2 = $[1];
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 = {
1133
1131
  version: 0,
1134
1132
  push: (params) => {
1135
- const id = params.id || generateToastId(), duration = params.duration || 5e3;
1136
- return react.startTransition(() => {
1133
+ const setState = (state_0) => react.startTransition(() => _setState(state_0)), id = params.id || generateToastId(), duration = params.duration || 5e3, dismiss = () => {
1134
+ const timeoutId = toastsRef.current[id]?.timeoutId;
1137
1135
  setState((prevState) => {
1138
- const dismiss = () => {
1139
- react.startTransition(() => {
1140
- setState((prevState_0) => {
1141
- const idx = prevState_0.findIndex((t) => t.id === id);
1142
- if (idx > -1) {
1143
- const toasts = prevState_0.slice(0);
1144
- return toasts.splice(idx, 1), toasts;
1145
- }
1146
- return prevState_0;
1147
- });
1148
- });
1149
- };
1150
- return prevState.filter((t_0) => t_0.id !== id).concat([{
1151
- dismiss,
1152
- id,
1153
- updatedAt: Date.now(),
1154
- params: {
1155
- ...params,
1156
- duration
1157
- }
1158
- }]);
1159
- });
1160
- }), id;
1136
+ const idx = prevState.findIndex((t) => t.id === id);
1137
+ if (idx > -1) {
1138
+ const toasts = prevState.slice(0);
1139
+ return toasts.splice(idx, 1), toasts;
1140
+ }
1141
+ return prevState;
1142
+ }), timeoutId !== void 0 && (clearTimeout(timeoutId), delete toastsRef.current[id]);
1143
+ };
1144
+ return setState((prevState_0) => prevState_0.filter((t_0) => t_0.id !== id).concat([{
1145
+ dismiss,
1146
+ id,
1147
+ params: {
1148
+ ...params,
1149
+ duration
1150
+ }
1151
+ }])), toastsRef.current[id] && (clearTimeout(toastsRef.current[id].timeoutId), delete toastsRef.current[id]), toastsRef.current[id] = {
1152
+ timeoutId: setTimeout(dismiss, duration)
1153
+ }, id;
1161
1154
  }
1162
- }, $[1] = t3) : t3 = $[1], t2 = t3;
1163
- const value = t2;
1164
- let t4;
1165
- $[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];
1166
- let t5;
1167
- return $[10] !== children || $[11] !== t4 ? (t5 = /* @__PURE__ */ jsxRuntime.jsxs(ToastContext.Provider, { value, children: [
1155
+ }, $[7] = t10) : t10 = $[7], t9 = t10;
1156
+ const value = t9;
1157
+ let t11, t12;
1158
+ $[8] === Symbol.for("react.memo_cache_sentinel") ? (t11 = () => () => {
1159
+ for (const {
1160
+ timeoutId: timeoutId_0
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: [
1168
1182
  children,
1169
- t4
1170
- ] }), $[10] = children, $[11] = t4, $[12] = t5) : t5 = $[12], t5;
1171
- }
1172
- function _temp(t0) {
1173
- const {
1174
- dismiss: dismiss_0,
1175
- id: id_0,
1176
- params: params_0,
1177
- updatedAt
1178
- } = t0;
1179
- 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);
1183
+ t13
1184
+ ] }), $[19] = children, $[20] = t13, $[21] = t14) : t14 = $[21], t14;
1180
1185
  }
1181
1186
  ToastProvider.displayName = "ToastProvider";
1182
1187
  function useToast() {
@@ -1554,7 +1559,7 @@ const TreeGroup = react.memo(function(props) {
1554
1559
  if (rootRef.current)
1555
1560
  return registerItem(rootRef.current, itemPath.join("/"), expanded, selected);
1556
1561
  }, [expanded, itemPath, registerItem, selected]);
1557
- const content2 = /* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Flex, { padding, children: [
1562
+ const content = /* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Flex, { padding, children: [
1558
1563
  /* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Box, { marginRight: space, style: {
1559
1564
  visibility: IconComponent || children ? "visible" : "hidden",
1560
1565
  pointerEvents: "none"
@@ -1567,10 +1572,10 @@ const TreeGroup = react.memo(function(props) {
1567
1572
  /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { muted, size: fontSize, textOverflow: "ellipsis", weight, children: text }) })
1568
1573
  ] });
1569
1574
  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: [
1570
- /* @__PURE__ */ jsxRuntime.jsx(TreeItemBox, { $level: tree.level, "aria-expanded": expanded, as: linkAs, "data-ui": "TreeItem__box", href, ref: treeitemRef, role: "treeitem", tabIndex, children: content2 }),
1575
+ /* @__PURE__ */ jsxRuntime.jsx(TreeItemBox, { $level: tree.level, "aria-expanded": expanded, as: linkAs, "data-ui": "TreeItem__box", href, ref: treeitemRef, role: "treeitem", tabIndex, children: content }),
1571
1576
  /* @__PURE__ */ jsxRuntime.jsx(TreeContext.Provider, { value: contextValue, children: children && /* @__PURE__ */ jsxRuntime.jsx(TreeGroup, { hidden: !expanded, children }) })
1572
1577
  ] }) : /* @__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: [
1573
- /* @__PURE__ */ jsxRuntime.jsx(TreeItemBox, { $level: tree.level, as: "div", "data-ui": "TreeItem__box", children: content2 }),
1578
+ /* @__PURE__ */ jsxRuntime.jsx(TreeItemBox, { $level: tree.level, as: "div", "data-ui": "TreeItem__box", children: content }),
1574
1579
  /* @__PURE__ */ jsxRuntime.jsx(TreeContext.Provider, { value: contextValue, children: children && /* @__PURE__ */ jsxRuntime.jsx(TreeGroup, { expanded, children }) })
1575
1580
  ] });
1576
1581
  });