about summary refs log tree commit diff
path: root/src/components/Toast/types.ts
blob: 463e6d66ca196fc34334e8901b3c8e4992eda880 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import {type toast as sonner} from 'sonner-native'

/**
 * This is not exported from `sonner-native` so just hacking it in here.
 */
export type ExternalToast = Exclude<
  Parameters<typeof sonner.custom>[1],
  undefined
>

export type ToastType = 'default' | 'success' | 'error' | 'warning' | 'info'

/**
 * Not all properties are available on all platforms, so we pick out only those
 * we support. Add more here as needed.
 */
export type BaseToastOptions = Pick<
  ExternalToast,
  'duration' | 'dismissible' | 'promiseOptions'
> & {
  type?: ToastType

  /**
   * These methods differ between web/native implementations
   */
  onDismiss?: () => void
  onPress?: () => void
  onAutoClose?: () => void
}