@sanity/ui 2.14.4-canary.2 → 2.14.4-canary.3

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
@@ -975,7 +975,7 @@ const LOADING_BAR_HEIGHT = 2, STATUS_CARD_TONE = {
975
975
  })`overflow-x:auto;`, StyledToast = styledComponents.styled(_visualEditing.Card).withConfig({
976
976
  displayName: "StyledToast",
977
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({
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
979
  displayName: "LoadingBar",
980
980
  componentId: "sc-1rr7rxo-2"
981
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({
@@ -991,7 +991,7 @@ const LOADING_BAR_HEIGHT = 2, STATUS_CARD_TONE = {
991
991
  warning: "alert",
992
992
  success: "alert",
993
993
  info: "alert"
994
- };
994
+ }, LONG_ENOUGH_BUT_NOT_TOO_LONG = 1e3 * 60 * 60 * 24 * 24;
995
995
  function Toast(props) {
996
996
  const {
997
997
  closable,
@@ -1003,15 +1003,13 @@ function Toast(props) {
1003
1003
  status,
1004
1004
  updatedAt,
1005
1005
  ...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 ? {
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 ? {
1009
1007
  type: "spring",
1010
1008
  visualDuration,
1011
1009
  bounce: 0.25
1012
1010
  } : {
1013
1011
  duration: 0
1014
- }, hasDuration = duration && isFinite(duration);
1012
+ }, hasDuration = duration && isFinite(duration) && duration < LONG_ENOUGH_BUT_NOT_TOO_LONG;
1015
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: [
1016
1014
  /* @__PURE__ */ jsxRuntime.jsxs(MotionFlex, { align: "flex-start", variants: content, transition, children: [
1017
1015
  /* @__PURE__ */ jsxRuntime.jsx(TextBox, { flex: 1, padding: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Stack, { space: 3, children: [
@@ -1039,7 +1037,7 @@ function Toast(props) {
1039
1037
  delay: visualDuration,
1040
1038
  duration: duration / 1e3,
1041
1039
  ease: "linear"
1042
- }, onAnimationComplete: onClose }, `${duration}-${updatedAt}`)
1040
+ }, onAnimationComplete: onClose }, `progress-${updatedAt}`)
1043
1041
  ] })
1044
1042
  ] });
1045
1043
  }
@@ -1072,6 +1070,9 @@ const container = {
1072
1070
  scale: 0.75
1073
1071
  }
1074
1072
  }, content = {
1073
+ initial: {
1074
+ willChange: "transform"
1075
+ },
1075
1076
  hidden: {
1076
1077
  opacity: 0
1077
1078
  },
@@ -1147,7 +1148,7 @@ function ToastProvider(props) {
1147
1148
  });
1148
1149
  });
1149
1150
  };
1150
- return prevState.filter((t_0) => t_0.id !== id).concat([{
1151
+ return duration === 0.01 ? prevState.filter((t_0) => t_0.id !== id) : prevState.filter((t_1) => t_1.id !== id).concat([{
1151
1152
  dismiss,
1152
1153
  id,
1153
1154
  updatedAt: Date.now(),