@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.esm.js +9 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +9 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/core/components/toast/styles.ts +0 -1
- package/src/core/components/toast/toast.tsx +10 -5
- package/src/core/components/toast/toastProvider.tsx +5 -0
package/package.json
CHANGED
|
@@ -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
|
-
|
|
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={
|
|
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([
|