@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "2.14.4-canary.2",
3
+ "version": "2.14.4-canary.3",
4
4
  "keywords": [
5
5
  "sanity",
6
6
  "ui",
@@ -29,7 +29,6 @@ export const StyledToast = styled(Card)`
29
29
  position: relative;
30
30
  overflow: hidden;
31
31
  overflow: clip;
32
- will-change: opacity, transform;
33
32
 
34
33
  &[data-has-duration] {
35
34
  padding-bottom: calc(${LOADING_BAR_HEIGHT}px / 2);
@@ -33,6 +33,10 @@ const ROLES = {
33
33
  info: 'alert',
34
34
  } as const
35
35
 
36
+ // Support pattern used by Sanity Studio, that works around the lack of `duration: Infinity` support in older @sanity/ui versions
37
+ // https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#maximum_delay_value
38
+ const LONG_ENOUGH_BUT_NOT_TOO_LONG = 1000 * 60 * 60 * 24 * 24
39
+
36
40
  /**
37
41
  * The `Toast` component gives feedback to users when an action has taken place.
38
42
  *
@@ -71,12 +75,10 @@ export function Toast(
71
75
 
72
76
  const prefersReducedMotion = usePrefersReducedMotion()
73
77
 
74
- // eslint-disable-next-line prefer-const
75
- let visualDuration = prefersReducedMotion ? 0 : 0.26
76
- // visualDuration = 5
78
+ const visualDuration = prefersReducedMotion ? 0 : 0.26
77
79
  const transition = visualDuration ? {type: 'spring', visualDuration, bounce: 0.25} : {duration: 0}
78
80
 
79
- const hasDuration = duration && isFinite(duration)
81
+ const hasDuration = duration && isFinite(duration) && duration < LONG_ENOUGH_BUT_NOT_TOO_LONG
80
82
 
81
83
  return (
82
84
  <MotionToast
@@ -141,7 +143,7 @@ export function Toast(
141
143
  }}
142
144
  />
143
145
  <MotionLoadiongBarProgress
144
- key={`${duration}-${updatedAt}`}
146
+ key={`progress-${updatedAt}`}
145
147
  tone={cardTone}
146
148
  initial={{scaleX: 0}}
147
149
  animate={{scaleX: 1}}
@@ -183,6 +185,9 @@ const container = {
183
185
  type ContainerVariants = keyof typeof container
184
186
 
185
187
  const content = {
188
+ initial: {
189
+ willChange: 'transform',
190
+ },
186
191
  hidden: {
187
192
  opacity: 0,
188
193
  },
@@ -56,6 +56,11 @@ export function ToastProvider(props: ToastProviderProps): React.JSX.Element {
56
56
  })
57
57
  }
58
58
 
59
+ // BC legacy support
60
+ if (duration === 0.01) {
61
+ return prevState.filter((t) => t.id !== id)
62
+ }
63
+
59
64
  return prevState
60
65
  .filter((t) => t.id !== id)
61
66
  .concat([