@sanity/ui 2.14.4-canary.3 → 2.14.5

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,215 +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;&[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
- }, LONG_ENOUGH_BUT_NOT_TOO_LONG = 1e3 * 60 * 60 * 24 * 24;
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", visualDuration = _visualEditing.usePrefersReducedMotion() ? 0 : 0.26, transition = visualDuration ? {
1007
- type: "spring",
1008
- visualDuration,
1009
- bounce: 0.25
1010
- } : {
1011
- duration: 0
1012
- }, hasDuration = duration && isFinite(duration) && duration < LONG_ENOUGH_BUT_NOT_TOO_LONG;
1013
- 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: [
1014
- /* @__PURE__ */ jsxRuntime.jsxs(MotionFlex, { align: "flex-start", variants: content, transition, children: [
1015
- /* @__PURE__ */ jsxRuntime.jsx(TextBox, { flex: 1, padding: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Stack, { space: 3, children: [
1016
- title && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { size: 1, weight: "medium", children: title }),
1017
- description && /* @__PURE__ */ jsxRuntime.jsx(MotionText, { muted: !0, size: 1, variants: content, transition, children: description })
1018
- ] }) }),
1019
- 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: {
1020
- verticalAlign: "top"
1021
- } }) })
1022
- ] }),
1023
- hasDuration && /* @__PURE__ */ jsxRuntime.jsxs(MotionLoadiongBar, { variants: content, transition, children: [
1024
- /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Card, { tone: cardTone, radius, style: {
1025
- position: "absolute",
1026
- right: -2,
1027
- left: -2,
1028
- top: 0,
1029
- bottom: 2,
1030
- zIndex: 1
1031
- } }),
1032
- /* @__PURE__ */ jsxRuntime.jsx(MotionLoadiongBarProgress, { tone: cardTone, initial: {
1033
- scaleX: 0
1034
- }, animate: {
1035
- scaleX: 1
1036
- }, transition: {
1037
- delay: visualDuration,
1038
- duration: duration / 1e3,
1039
- ease: "linear"
1040
- }, onAnimationComplete: onClose }, `progress-${updatedAt}`)
1041
- ] })
1042
- ] });
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;
1043
1063
  }
1044
1064
  Toast.displayName = "Toast";
1045
- const container = {
1046
- initial: {
1047
- y: 32,
1048
- scale: 0.5,
1049
- zIndex: 1
1050
- },
1051
- hidden: {
1052
- opacity: 0
1053
- },
1054
- visible: (visualDuration) => visualDuration ? {
1055
- opacity: 1,
1056
- transition: {
1057
- when: "beforeChildren",
1058
- staggerChildren: visualDuration / 3,
1059
- duration: visualDuration / 3
1060
- }
1061
- } : {
1062
- opacity: 1
1063
- },
1064
- slideIn: {
1065
- y: 0,
1066
- scale: 1
1067
- },
1068
- slideOut: {
1069
- zIndex: 0,
1070
- scale: 0.75
1071
- }
1072
- }, content = {
1073
- initial: {
1074
- willChange: "transform"
1075
- },
1076
- hidden: {
1077
- opacity: 0
1078
- },
1079
- visible: {
1080
- opacity: 1
1081
- }
1082
- }, 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);
1083
1065
  function useMounted() {
1084
- return react.useSyncExternalStore(subscribe, _temp$1, _temp2);
1066
+ return react.useSyncExternalStore(subscribe, _temp, _temp2);
1085
1067
  }
1086
1068
  function _temp2() {
1087
1069
  return !1;
1088
1070
  }
1089
- function _temp$1() {
1071
+ function _temp() {
1090
1072
  return !0;
1091
1073
  }
1092
1074
  const subscribe = () => () => {
1093
1075
  }, ToastContext = _visualEditing.createGlobalScopedContext("@sanity/ui/context/toast", null);
1094
- function ToastLayer(props) {
1095
- const $ = reactCompilerRuntime.c(9), {
1096
- children,
1097
- padding: t0,
1098
- paddingX,
1099
- paddingY,
1100
- gap: t1
1101
- } = props, padding = t0 === void 0 ? 4 : t0, gap = t1 === void 0 ? 3 : t1, {
1102
- zIndex
1103
- } = _visualEditing.useLayer();
1104
- let t2;
1105
- $[0] !== zIndex ? (t2 = {
1106
- zIndex
1107
- }, $[0] = zIndex, $[1] = t2) : t2 = $[1];
1108
- let t3;
1109
- 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;
1110
- }
1111
- ToastLayer.displayName = "ToastLayer";
1112
- const StyledLayer = styledComponents.styled(_visualEditing.Grid).withConfig({
1113
- displayName: "StyledLayer",
1114
- componentId: "sc-1tbwn58-0"
1115
- })`box-sizing:border-box;position:fixed;right:0;bottom:0;list-style:none;pointer-events:none;max-width:420px;width:100%;`;
1116
1076
  let toastId = 0;
1117
1077
  function generateToastId() {
1118
1078
  return String(toastId++);
1119
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%;`;
1120
1087
  function ToastProvider(props) {
1121
- const $ = reactCompilerRuntime.c(13), {
1088
+ const $ = reactCompilerRuntime.c(22), {
1122
1089
  children,
1123
- padding,
1090
+ padding: t0,
1124
1091
  paddingX,
1125
1092
  paddingY,
1126
- gap,
1127
- zOffset: t0
1128
- } = props, zOffset = t0 === void 0 ? 1 : t0;
1093
+ zOffset
1094
+ } = props, padding = t0 === void 0 ? 4 : t0;
1129
1095
  let t1;
1130
1096
  $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[0] = t1) : t1 = $[0];
1131
- const [state, setState] = react.useState(t1), mounted = useMounted();
1132
- let t2, t3;
1133
- $[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 = {
1134
1131
  version: 0,
1135
1132
  push: (params) => {
1136
- const id = params.id || generateToastId(), duration = params.duration || 5e3;
1137
- 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;
1138
1135
  setState((prevState) => {
1139
- const dismiss = () => {
1140
- react.startTransition(() => {
1141
- setState((prevState_0) => {
1142
- const idx = prevState_0.findIndex((t) => t.id === id);
1143
- if (idx > -1) {
1144
- const toasts = prevState_0.slice(0);
1145
- return toasts.splice(idx, 1), toasts;
1146
- }
1147
- return prevState_0;
1148
- });
1149
- });
1150
- };
1151
- return duration === 0.01 ? prevState.filter((t_0) => t_0.id !== id) : prevState.filter((t_1) => t_1.id !== id).concat([{
1152
- dismiss,
1153
- id,
1154
- updatedAt: Date.now(),
1155
- params: {
1156
- ...params,
1157
- duration
1158
- }
1159
- }]);
1160
- });
1161
- }), 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;
1162
1154
  }
1163
- }, $[1] = t3) : t3 = $[1], t2 = t3;
1164
- const value = t2;
1165
- let t4;
1166
- $[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];
1167
- let t5;
1168
- 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: [
1169
1182
  children,
1170
- t4
1171
- ] }), $[10] = children, $[11] = t4, $[12] = t5) : t5 = $[12], t5;
1172
- }
1173
- function _temp(t0) {
1174
- const {
1175
- dismiss: dismiss_0,
1176
- id: id_0,
1177
- params: params_0,
1178
- updatedAt
1179
- } = t0;
1180
- 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;
1181
1185
  }
1182
1186
  ToastProvider.displayName = "ToastProvider";
1183
1187
  function useToast() {
@@ -1555,7 +1559,7 @@ const TreeGroup = react.memo(function(props) {
1555
1559
  if (rootRef.current)
1556
1560
  return registerItem(rootRef.current, itemPath.join("/"), expanded, selected);
1557
1561
  }, [expanded, itemPath, registerItem, selected]);
1558
- const content2 = /* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Flex, { padding, children: [
1562
+ const content = /* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Flex, { padding, children: [
1559
1563
  /* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Box, { marginRight: space, style: {
1560
1564
  visibility: IconComponent || children ? "visible" : "hidden",
1561
1565
  pointerEvents: "none"
@@ -1568,10 +1572,10 @@ const TreeGroup = react.memo(function(props) {
1568
1572
  /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { muted, size: fontSize, textOverflow: "ellipsis", weight, children: text }) })
1569
1573
  ] });
1570
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: [
1571
- /* @__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 }),
1572
1576
  /* @__PURE__ */ jsxRuntime.jsx(TreeContext.Provider, { value: contextValue, children: children && /* @__PURE__ */ jsxRuntime.jsx(TreeGroup, { hidden: !expanded, children }) })
1573
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: [
1574
- /* @__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 }),
1575
1579
  /* @__PURE__ */ jsxRuntime.jsx(TreeContext.Provider, { value: contextValue, children: children && /* @__PURE__ */ jsxRuntime.jsx(TreeGroup, { expanded, children }) })
1576
1580
  ] });
1577
1581
  });