@lets-events/react 12.3.10 → 12.4.1
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/.eslintrc.json +2 -2
- package/.turbo/turbo-build.log +19 -21
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +35 -3
- package/dist/index.d.ts +35 -3
- package/dist/index.js +562 -344
- package/dist/index.mjs +535 -319
- package/package.json +1 -1
- package/src/components/Alert.tsx +303 -303
- package/src/components/Avatar.tsx +55 -55
- package/src/components/Badge.tsx +125 -125
- package/src/components/Box.tsx +3 -3
- package/src/components/Button/index.tsx +45 -45
- package/src/components/Button/styledComponents.ts +313 -313
- package/src/components/ButtonGroup.tsx +484 -484
- package/src/components/Calendar/index.tsx +148 -148
- package/src/components/Calendar/styledComponents.ts +259 -250
- package/src/components/Card.tsx +67 -67
- package/src/components/CheckboxGroup.tsx +176 -176
- package/src/components/Container.tsx +39 -39
- package/src/components/Divider.tsx +7 -7
- package/src/components/DoubleCalendar/index.tsx +166 -0
- package/src/components/Drawer/index.tsx +98 -98
- package/src/components/Drawer/styledComponents.ts +103 -103
- package/src/components/Dropdown.tsx +302 -302
- package/src/components/Filter.tsx +164 -164
- package/src/components/Flex.tsx +118 -118
- package/src/components/FormFields/AddressFormFields/CityFormField.tsx +111 -111
- package/src/components/FormFields/AddressFormFields/CountryFormField.tsx +33 -33
- package/src/components/FormFields/AddressFormFields/PostalCodeFormField.tsx +39 -39
- package/src/components/FormFields/AddressFormFields/StateFormField.tsx +32 -32
- package/src/components/FormFields/AddressFormFields/index.tsx +141 -141
- package/src/components/FormFields/BirthDateFormField.tsx +84 -84
- package/src/components/FormFields/CNPJFormField.tsx +87 -87
- package/src/components/FormFields/CPFFormField.tsx +78 -78
- package/src/components/FormFields/CalendarFormField.tsx +95 -95
- package/src/components/FormFields/CheckboxGroupFormField.tsx +91 -91
- package/src/components/FormFields/DoubleCalendarFormField.tsx +90 -0
- package/src/components/FormFields/EmailFormField.tsx +27 -27
- package/src/components/FormFields/Form.tsx +39 -39
- package/src/components/FormFields/IdentityDocumentNumberFormField.tsx +32 -32
- package/src/components/FormFields/MultiSelectFormField.tsx +64 -64
- package/src/components/FormFields/PhoneFormField.tsx +40 -40
- package/src/components/FormFields/RadioGroupFormField.tsx +84 -84
- package/src/components/FormFields/RichEditorFormField.tsx +103 -103
- package/src/components/FormFields/SelectFormField.tsx +93 -93
- package/src/components/FormFields/SwitchFormField.tsx +46 -46
- package/src/components/FormFields/TextAreaFormField.tsx +59 -57
- package/src/components/FormFields/TextFormField.tsx +112 -112
- package/src/components/FormFields/TimePickerFormField.tsx +88 -88
- package/src/components/FormFields/subComponents/ErrorFormMessage.tsx +36 -36
- package/src/components/FormFields/subComponents/FormLabel.tsx +29 -29
- package/src/components/FormFields/utils/validation.ts +23 -23
- package/src/components/Grid.tsx +137 -137
- package/src/components/Icon.tsx +47 -47
- package/src/components/MenuDropdown/index.tsx +38 -38
- package/src/components/MenuDropdown/styledComponents.ts +31 -31
- package/src/components/Modal.tsx +110 -110
- package/src/components/MultiSelect/index.tsx +243 -243
- package/src/components/MultiSelect/styledComponents.ts +160 -160
- package/src/components/RadioGroup.tsx +210 -210
- package/src/components/RichEditor/QuillComponent.tsx +457 -457
- package/src/components/RichEditor/RichEditor.tsx +49 -49
- package/src/components/RichEditor/index.ts +2 -2
- package/src/components/RichEditor/styledComponents.ts +1151 -1151
- package/src/components/Section.tsx +33 -33
- package/src/components/Step.tsx +164 -164
- package/src/components/Switch.tsx +108 -108
- package/src/components/Text.tsx +38 -38
- package/src/components/TextField.tsx +372 -372
- package/src/components/TextareaField.tsx +138 -127
- package/src/components/TimePicker.tsx +328 -328
- package/src/components/Toast/components/ToastItem.tsx +41 -41
- package/src/components/Toast/components/ToastProvider.tsx +63 -63
- package/src/components/Toast/hooks/useToast.ts +12 -12
- package/src/components/Toast/index.tsx +5 -5
- package/src/components/Toast/styles/index.ts +135 -135
- package/src/components/Toast/types/index.ts +46 -46
- package/src/components/Tooltip/index.tsx +66 -66
- package/src/components/Tooltip/styles.ts +77 -77
- package/src/hooks/useCountries.ts +41 -41
- package/src/hooks/useImageUpload.ts +139 -139
- package/src/hooks/useOnClickOutside.tsx +42 -42
- package/src/index.tsx +71 -69
- package/src/styles/index.ts +41 -41
- package/src/types/typographyValues.ts +178 -178
- package/src/utils/getNestedValue.ts +3 -3
- package/src/utils/states.ts +29 -29
- package/src/utils/uploadService.ts +180 -180
- package/tsconfig.json +3 -3
- package/tsup.config.ts +38 -38
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { useState } from 'react'
|
|
2
|
-
import Icon from '../../Icon'
|
|
3
|
-
import { ToastComponentProps } from '../types'
|
|
4
|
-
import {
|
|
5
|
-
ToastRoot,
|
|
6
|
-
ToastClose,
|
|
7
|
-
} from '../styles'
|
|
8
|
-
import { Text } from '../../Text'
|
|
9
|
-
|
|
10
|
-
export default function ToastItem({
|
|
11
|
-
toast,
|
|
12
|
-
onRemove,
|
|
13
|
-
}:ToastComponentProps) {
|
|
14
|
-
const [open, setOpen] = useState(true)
|
|
15
|
-
|
|
16
|
-
const handleOpenChange = (open: boolean) => {
|
|
17
|
-
setOpen(open)
|
|
18
|
-
if (!open) {
|
|
19
|
-
onRemove(toast.id)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<ToastRoot
|
|
25
|
-
type={toast.type}
|
|
26
|
-
duration={toast.duration}
|
|
27
|
-
open={open}
|
|
28
|
-
onOpenChange={handleOpenChange}
|
|
29
|
-
>
|
|
30
|
-
{toast?.icon && <Icon name={toast.icon} size='xl'/>}
|
|
31
|
-
|
|
32
|
-
<div style={{ flex: 1 }}>
|
|
33
|
-
<Text typography={'bodyS'} fontWeight={'medium'}>{toast.message}</Text>
|
|
34
|
-
</div>
|
|
35
|
-
|
|
36
|
-
<ToastClose aria-label="Close">
|
|
37
|
-
<Icon name="xmark" size="md" />
|
|
38
|
-
</ToastClose>
|
|
39
|
-
</ToastRoot>
|
|
40
|
-
)
|
|
41
|
-
}
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import Icon from '../../Icon'
|
|
3
|
+
import { ToastComponentProps } from '../types'
|
|
4
|
+
import {
|
|
5
|
+
ToastRoot,
|
|
6
|
+
ToastClose,
|
|
7
|
+
} from '../styles'
|
|
8
|
+
import { Text } from '../../Text'
|
|
9
|
+
|
|
10
|
+
export default function ToastItem({
|
|
11
|
+
toast,
|
|
12
|
+
onRemove,
|
|
13
|
+
}:ToastComponentProps) {
|
|
14
|
+
const [open, setOpen] = useState(true)
|
|
15
|
+
|
|
16
|
+
const handleOpenChange = (open: boolean) => {
|
|
17
|
+
setOpen(open)
|
|
18
|
+
if (!open) {
|
|
19
|
+
onRemove(toast.id)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<ToastRoot
|
|
25
|
+
type={toast.type}
|
|
26
|
+
duration={toast.duration}
|
|
27
|
+
open={open}
|
|
28
|
+
onOpenChange={handleOpenChange}
|
|
29
|
+
>
|
|
30
|
+
{toast?.icon && <Icon name={toast.icon} size='xl'/>}
|
|
31
|
+
|
|
32
|
+
<div style={{ flex: 1 }}>
|
|
33
|
+
<Text typography={'bodyS'} fontWeight={'medium'}>{toast.message}</Text>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<ToastClose aria-label="Close">
|
|
37
|
+
<Icon name="xmark" size="md" />
|
|
38
|
+
</ToastClose>
|
|
39
|
+
</ToastRoot>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import { createContext, useState } from 'react'
|
|
2
|
-
import * as ToastPrimitive from '@radix-ui/react-toast'
|
|
3
|
-
import ToastItem from './ToastItem'
|
|
4
|
-
import { ToastViewport } from '../styles'
|
|
5
|
-
import { ToastProviderProps, ToastContextType, Toast } from '../types'
|
|
6
|
-
|
|
7
|
-
export const ToastContext = createContext<ToastContextType | null>(null)
|
|
8
|
-
|
|
9
|
-
export default function ToastProvider ({
|
|
10
|
-
children,
|
|
11
|
-
defaultDuration = 5000,
|
|
12
|
-
maxToasts = 5,
|
|
13
|
-
swipeDirection = 'right',
|
|
14
|
-
}:ToastProviderProps) {
|
|
15
|
-
const [toasts, setToasts] = useState<Toast[]>([])
|
|
16
|
-
|
|
17
|
-
const addToast = (toastData: Omit<Toast, 'id' | 'createdAt'>): string => {
|
|
18
|
-
const id = Math.random().toString(36).substr(2, 9)
|
|
19
|
-
const newToast: Toast = {
|
|
20
|
-
id,
|
|
21
|
-
...toastData,
|
|
22
|
-
type: toastData?.type || 'info',
|
|
23
|
-
duration: toastData?.duration || defaultDuration,
|
|
24
|
-
createdAt: Date.now(),
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
setToasts((prevToasts) => {
|
|
28
|
-
const updatedToasts = [...prevToasts, newToast]
|
|
29
|
-
return updatedToasts.slice(-maxToasts)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
return id
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const removeToast = (id: string): void => {
|
|
36
|
-
setToasts((prevToasts) => prevToasts.filter((toast) => toast.id !== id))
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const removeAllToasts = (): void => {
|
|
40
|
-
setToasts([])
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const contextValue: ToastContextType = {
|
|
44
|
-
toasts,
|
|
45
|
-
addToast,
|
|
46
|
-
removeToast,
|
|
47
|
-
removeAllToasts,
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<ToastContext.Provider value={contextValue}>
|
|
52
|
-
<ToastPrimitive.Provider swipeDirection={swipeDirection}>
|
|
53
|
-
{children}
|
|
54
|
-
|
|
55
|
-
{toasts.map((toast) => (
|
|
56
|
-
<ToastItem key={toast.id} toast={toast} onRemove={removeToast} />
|
|
57
|
-
))}
|
|
58
|
-
|
|
59
|
-
<ToastViewport />
|
|
60
|
-
</ToastPrimitive.Provider>
|
|
61
|
-
</ToastContext.Provider>
|
|
62
|
-
)
|
|
63
|
-
}
|
|
1
|
+
import { createContext, useState } from 'react'
|
|
2
|
+
import * as ToastPrimitive from '@radix-ui/react-toast'
|
|
3
|
+
import ToastItem from './ToastItem'
|
|
4
|
+
import { ToastViewport } from '../styles'
|
|
5
|
+
import { ToastProviderProps, ToastContextType, Toast } from '../types'
|
|
6
|
+
|
|
7
|
+
export const ToastContext = createContext<ToastContextType | null>(null)
|
|
8
|
+
|
|
9
|
+
export default function ToastProvider ({
|
|
10
|
+
children,
|
|
11
|
+
defaultDuration = 5000,
|
|
12
|
+
maxToasts = 5,
|
|
13
|
+
swipeDirection = 'right',
|
|
14
|
+
}:ToastProviderProps) {
|
|
15
|
+
const [toasts, setToasts] = useState<Toast[]>([])
|
|
16
|
+
|
|
17
|
+
const addToast = (toastData: Omit<Toast, 'id' | 'createdAt'>): string => {
|
|
18
|
+
const id = Math.random().toString(36).substr(2, 9)
|
|
19
|
+
const newToast: Toast = {
|
|
20
|
+
id,
|
|
21
|
+
...toastData,
|
|
22
|
+
type: toastData?.type || 'info',
|
|
23
|
+
duration: toastData?.duration || defaultDuration,
|
|
24
|
+
createdAt: Date.now(),
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
setToasts((prevToasts) => {
|
|
28
|
+
const updatedToasts = [...prevToasts, newToast]
|
|
29
|
+
return updatedToasts.slice(-maxToasts)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
return id
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const removeToast = (id: string): void => {
|
|
36
|
+
setToasts((prevToasts) => prevToasts.filter((toast) => toast.id !== id))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const removeAllToasts = (): void => {
|
|
40
|
+
setToasts([])
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const contextValue: ToastContextType = {
|
|
44
|
+
toasts,
|
|
45
|
+
addToast,
|
|
46
|
+
removeToast,
|
|
47
|
+
removeAllToasts,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<ToastContext.Provider value={contextValue}>
|
|
52
|
+
<ToastPrimitive.Provider swipeDirection={swipeDirection}>
|
|
53
|
+
{children}
|
|
54
|
+
|
|
55
|
+
{toasts.map((toast) => (
|
|
56
|
+
<ToastItem key={toast.id} toast={toast} onRemove={removeToast} />
|
|
57
|
+
))}
|
|
58
|
+
|
|
59
|
+
<ToastViewport />
|
|
60
|
+
</ToastPrimitive.Provider>
|
|
61
|
+
</ToastContext.Provider>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { useContext } from 'react'
|
|
2
|
-
import { ToastContextType } from '../types'
|
|
3
|
-
import { ToastContext } from '../components/ToastProvider'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const useToast = (): ToastContextType => {
|
|
7
|
-
const context = useContext(ToastContext)
|
|
8
|
-
if (!context) {
|
|
9
|
-
throw new Error('useToast deve ser usado dentro de um ToastProvider')
|
|
10
|
-
}
|
|
11
|
-
return context
|
|
12
|
-
}
|
|
1
|
+
import { useContext } from 'react'
|
|
2
|
+
import { ToastContextType } from '../types'
|
|
3
|
+
import { ToastContext } from '../components/ToastProvider'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const useToast = (): ToastContextType => {
|
|
7
|
+
const context = useContext(ToastContext)
|
|
8
|
+
if (!context) {
|
|
9
|
+
throw new Error('useToast deve ser usado dentro de um ToastProvider')
|
|
10
|
+
}
|
|
11
|
+
return context
|
|
12
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { default as ToastItem } from './components/ToastItem'
|
|
2
|
-
export { default as ToastProvider } from './components/ToastProvider'
|
|
3
|
-
export * from './hooks/useToast'
|
|
4
|
-
export * from './types'
|
|
5
|
-
|
|
1
|
+
export { default as ToastItem } from './components/ToastItem'
|
|
2
|
+
export { default as ToastProvider } from './components/ToastProvider'
|
|
3
|
+
export * from './hooks/useToast'
|
|
4
|
+
export * from './types'
|
|
5
|
+
|
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
import { keyframes } from '@stitches/react'
|
|
2
|
-
import * as ToastPrimitive from '@radix-ui/react-toast'
|
|
3
|
-
import { styled } from '../../../styles'
|
|
4
|
-
|
|
5
|
-
const slideIn = keyframes({
|
|
6
|
-
from: {
|
|
7
|
-
transform: 'translateX(calc(100% + 25px))',
|
|
8
|
-
opacity: 0,
|
|
9
|
-
},
|
|
10
|
-
to: {
|
|
11
|
-
transform: 'translateX(0)',
|
|
12
|
-
opacity: 1,
|
|
13
|
-
},
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
const slideOut = keyframes({
|
|
17
|
-
from: {
|
|
18
|
-
transform: 'translateX(0)',
|
|
19
|
-
opacity: 1,
|
|
20
|
-
},
|
|
21
|
-
to: {
|
|
22
|
-
transform: 'translateX(calc(100% + 25px))',
|
|
23
|
-
opacity: 0,
|
|
24
|
-
},
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
const swipeOut = keyframes({
|
|
28
|
-
from: {
|
|
29
|
-
transform: 'translateX(var(--radix-toast-swipe-end-x))',
|
|
30
|
-
opacity: 1,
|
|
31
|
-
},
|
|
32
|
-
to: {
|
|
33
|
-
transform: 'translateX(calc(100% + 25px))',
|
|
34
|
-
opacity: 0,
|
|
35
|
-
},
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
export const ToastViewport = styled(ToastPrimitive.Viewport, {
|
|
39
|
-
position: 'fixed',
|
|
40
|
-
top: 0,
|
|
41
|
-
right: 0,
|
|
42
|
-
display: 'flex',
|
|
43
|
-
flexDirection: 'column',
|
|
44
|
-
padding: 25,
|
|
45
|
-
gap: 10,
|
|
46
|
-
width: 390,
|
|
47
|
-
maxWidth: '100vw',
|
|
48
|
-
margin: 0,
|
|
49
|
-
listStyle: 'none',
|
|
50
|
-
zIndex: 2147483647,
|
|
51
|
-
outline: 'none',
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
export const ToastRoot = styled(ToastPrimitive.Root, {
|
|
55
|
-
backgroundColor: '$neutral50',
|
|
56
|
-
borderRadius: '$sm' ,
|
|
57
|
-
boxShadow:
|
|
58
|
-
'hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px',
|
|
59
|
-
padding: '$16',
|
|
60
|
-
gap: '$8',
|
|
61
|
-
display: 'flex',
|
|
62
|
-
alignItems: 'center',
|
|
63
|
-
border: '1px solid',
|
|
64
|
-
position: 'relative',
|
|
65
|
-
zIndex: 9999,
|
|
66
|
-
|
|
67
|
-
'&[data-state="open"]': {
|
|
68
|
-
animation: `${slideIn} 150ms cubic-bezier(0.16, 1, 0.3, 1)`,
|
|
69
|
-
},
|
|
70
|
-
'&[data-state="closed"]': {
|
|
71
|
-
animation: `${slideOut} 100ms ease-in`,
|
|
72
|
-
},
|
|
73
|
-
'&[data-swipe="move"]': {
|
|
74
|
-
transform: 'translateX(var(--radix-toast-swipe-move-x))',
|
|
75
|
-
},
|
|
76
|
-
'&[data-swipe="cancel"]': {
|
|
77
|
-
transform: 'translateX(0)',
|
|
78
|
-
transition: 'transform 200ms ease-out',
|
|
79
|
-
},
|
|
80
|
-
'&[data-swipe="end"]': {
|
|
81
|
-
animation: `${swipeOut} 100ms ease-out`,
|
|
82
|
-
},
|
|
83
|
-
$$toastColor: 'inherit',
|
|
84
|
-
color: '$$toastColor',
|
|
85
|
-
borderColor: '$$toastColor',
|
|
86
|
-
variants: {
|
|
87
|
-
type: {
|
|
88
|
-
success: {
|
|
89
|
-
$$toastColor: '$colors$success600',
|
|
90
|
-
backgroundColor: '$success50',
|
|
91
|
-
},
|
|
92
|
-
error: {
|
|
93
|
-
$$toastColor: '$colors$error600',
|
|
94
|
-
backgroundColor: '$error50',
|
|
95
|
-
},
|
|
96
|
-
warning: {
|
|
97
|
-
$$toastColor: '$colors$warning600',
|
|
98
|
-
backgroundColor: '$warning50',
|
|
99
|
-
},
|
|
100
|
-
info: {
|
|
101
|
-
$$toastColor: '$colors$info600',
|
|
102
|
-
backgroundColor: '$info50',
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
defaultVariants: {
|
|
108
|
-
type: 'info',
|
|
109
|
-
},
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
export const ToastClose = styled(ToastPrimitive.Close, {
|
|
114
|
-
border: 'none',
|
|
115
|
-
backgroundColor: 'transparent',
|
|
116
|
-
display: 'flex',
|
|
117
|
-
alignItems: 'center',
|
|
118
|
-
justifyContent: 'center',
|
|
119
|
-
color: 'inherit',
|
|
120
|
-
borderRadius: 4,
|
|
121
|
-
padding: 4,
|
|
122
|
-
cursor: 'pointer',
|
|
123
|
-
opacity: 0.7,
|
|
124
|
-
|
|
125
|
-
'&:hover': {
|
|
126
|
-
opacity: 1,
|
|
127
|
-
backgroundColor: 'rgba(0, 0, 0, 0.05)',
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
'&:focus': {
|
|
131
|
-
boxShadow: '0 0 0 2px currentColor',
|
|
132
|
-
opacity: 1,
|
|
133
|
-
},
|
|
134
|
-
})
|
|
135
|
-
|
|
1
|
+
import { keyframes } from '@stitches/react'
|
|
2
|
+
import * as ToastPrimitive from '@radix-ui/react-toast'
|
|
3
|
+
import { styled } from '../../../styles'
|
|
4
|
+
|
|
5
|
+
const slideIn = keyframes({
|
|
6
|
+
from: {
|
|
7
|
+
transform: 'translateX(calc(100% + 25px))',
|
|
8
|
+
opacity: 0,
|
|
9
|
+
},
|
|
10
|
+
to: {
|
|
11
|
+
transform: 'translateX(0)',
|
|
12
|
+
opacity: 1,
|
|
13
|
+
},
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const slideOut = keyframes({
|
|
17
|
+
from: {
|
|
18
|
+
transform: 'translateX(0)',
|
|
19
|
+
opacity: 1,
|
|
20
|
+
},
|
|
21
|
+
to: {
|
|
22
|
+
transform: 'translateX(calc(100% + 25px))',
|
|
23
|
+
opacity: 0,
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const swipeOut = keyframes({
|
|
28
|
+
from: {
|
|
29
|
+
transform: 'translateX(var(--radix-toast-swipe-end-x))',
|
|
30
|
+
opacity: 1,
|
|
31
|
+
},
|
|
32
|
+
to: {
|
|
33
|
+
transform: 'translateX(calc(100% + 25px))',
|
|
34
|
+
opacity: 0,
|
|
35
|
+
},
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
export const ToastViewport = styled(ToastPrimitive.Viewport, {
|
|
39
|
+
position: 'fixed',
|
|
40
|
+
top: 0,
|
|
41
|
+
right: 0,
|
|
42
|
+
display: 'flex',
|
|
43
|
+
flexDirection: 'column',
|
|
44
|
+
padding: 25,
|
|
45
|
+
gap: 10,
|
|
46
|
+
width: 390,
|
|
47
|
+
maxWidth: '100vw',
|
|
48
|
+
margin: 0,
|
|
49
|
+
listStyle: 'none',
|
|
50
|
+
zIndex: 2147483647,
|
|
51
|
+
outline: 'none',
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
export const ToastRoot = styled(ToastPrimitive.Root, {
|
|
55
|
+
backgroundColor: '$neutral50',
|
|
56
|
+
borderRadius: '$sm' ,
|
|
57
|
+
boxShadow:
|
|
58
|
+
'hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px',
|
|
59
|
+
padding: '$16',
|
|
60
|
+
gap: '$8',
|
|
61
|
+
display: 'flex',
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
border: '1px solid',
|
|
64
|
+
position: 'relative',
|
|
65
|
+
zIndex: 9999,
|
|
66
|
+
|
|
67
|
+
'&[data-state="open"]': {
|
|
68
|
+
animation: `${slideIn} 150ms cubic-bezier(0.16, 1, 0.3, 1)`,
|
|
69
|
+
},
|
|
70
|
+
'&[data-state="closed"]': {
|
|
71
|
+
animation: `${slideOut} 100ms ease-in`,
|
|
72
|
+
},
|
|
73
|
+
'&[data-swipe="move"]': {
|
|
74
|
+
transform: 'translateX(var(--radix-toast-swipe-move-x))',
|
|
75
|
+
},
|
|
76
|
+
'&[data-swipe="cancel"]': {
|
|
77
|
+
transform: 'translateX(0)',
|
|
78
|
+
transition: 'transform 200ms ease-out',
|
|
79
|
+
},
|
|
80
|
+
'&[data-swipe="end"]': {
|
|
81
|
+
animation: `${swipeOut} 100ms ease-out`,
|
|
82
|
+
},
|
|
83
|
+
$$toastColor: 'inherit',
|
|
84
|
+
color: '$$toastColor',
|
|
85
|
+
borderColor: '$$toastColor',
|
|
86
|
+
variants: {
|
|
87
|
+
type: {
|
|
88
|
+
success: {
|
|
89
|
+
$$toastColor: '$colors$success600',
|
|
90
|
+
backgroundColor: '$success50',
|
|
91
|
+
},
|
|
92
|
+
error: {
|
|
93
|
+
$$toastColor: '$colors$error600',
|
|
94
|
+
backgroundColor: '$error50',
|
|
95
|
+
},
|
|
96
|
+
warning: {
|
|
97
|
+
$$toastColor: '$colors$warning600',
|
|
98
|
+
backgroundColor: '$warning50',
|
|
99
|
+
},
|
|
100
|
+
info: {
|
|
101
|
+
$$toastColor: '$colors$info600',
|
|
102
|
+
backgroundColor: '$info50',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
defaultVariants: {
|
|
108
|
+
type: 'info',
|
|
109
|
+
},
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
export const ToastClose = styled(ToastPrimitive.Close, {
|
|
114
|
+
border: 'none',
|
|
115
|
+
backgroundColor: 'transparent',
|
|
116
|
+
display: 'flex',
|
|
117
|
+
alignItems: 'center',
|
|
118
|
+
justifyContent: 'center',
|
|
119
|
+
color: 'inherit',
|
|
120
|
+
borderRadius: 4,
|
|
121
|
+
padding: 4,
|
|
122
|
+
cursor: 'pointer',
|
|
123
|
+
opacity: 0.7,
|
|
124
|
+
|
|
125
|
+
'&:hover': {
|
|
126
|
+
opacity: 1,
|
|
127
|
+
backgroundColor: 'rgba(0, 0, 0, 0.05)',
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
'&:focus': {
|
|
131
|
+
boxShadow: '0 0 0 2px currentColor',
|
|
132
|
+
opacity: 1,
|
|
133
|
+
},
|
|
134
|
+
})
|
|
135
|
+
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { ReactNode } from 'react'
|
|
2
|
-
import { IconName } from '@fortawesome/fontawesome-svg-core'
|
|
3
|
-
|
|
4
|
-
export type ToastType = 'success' | 'error' | 'warning' | 'info'
|
|
5
|
-
|
|
6
|
-
export interface ToastConfig {
|
|
7
|
-
icon: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface ToastOptions {
|
|
11
|
-
type?: ToastType
|
|
12
|
-
title?: string
|
|
13
|
-
duration?: number
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface Toast {
|
|
17
|
-
id: string
|
|
18
|
-
message: string
|
|
19
|
-
icon?: IconName,
|
|
20
|
-
type?: ToastType
|
|
21
|
-
duration?: number
|
|
22
|
-
createdAt: number
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface ToastContextType {
|
|
26
|
-
toasts: Toast[]
|
|
27
|
-
addToast: (toast: Omit<Toast, 'id' | 'createdAt'>) => string
|
|
28
|
-
removeToast: (id: string) => void
|
|
29
|
-
removeAllToasts: () => void
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface ToastProviderProps {
|
|
33
|
-
children: ReactNode
|
|
34
|
-
defaultDuration?: number
|
|
35
|
-
maxToasts?: number
|
|
36
|
-
swipeDirection?: 'right' | 'left' | 'up' | 'down'
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface ToastComponentProps {
|
|
40
|
-
toast: Toast
|
|
41
|
-
onRemove: (id: string) => void
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface ToasterShowOptions extends ToastOptions {
|
|
45
|
-
onClose?: () => void
|
|
46
|
-
}
|
|
1
|
+
import { ReactNode } from 'react'
|
|
2
|
+
import { IconName } from '@fortawesome/fontawesome-svg-core'
|
|
3
|
+
|
|
4
|
+
export type ToastType = 'success' | 'error' | 'warning' | 'info'
|
|
5
|
+
|
|
6
|
+
export interface ToastConfig {
|
|
7
|
+
icon: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ToastOptions {
|
|
11
|
+
type?: ToastType
|
|
12
|
+
title?: string
|
|
13
|
+
duration?: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface Toast {
|
|
17
|
+
id: string
|
|
18
|
+
message: string
|
|
19
|
+
icon?: IconName,
|
|
20
|
+
type?: ToastType
|
|
21
|
+
duration?: number
|
|
22
|
+
createdAt: number
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ToastContextType {
|
|
26
|
+
toasts: Toast[]
|
|
27
|
+
addToast: (toast: Omit<Toast, 'id' | 'createdAt'>) => string
|
|
28
|
+
removeToast: (id: string) => void
|
|
29
|
+
removeAllToasts: () => void
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ToastProviderProps {
|
|
33
|
+
children: ReactNode
|
|
34
|
+
defaultDuration?: number
|
|
35
|
+
maxToasts?: number
|
|
36
|
+
swipeDirection?: 'right' | 'left' | 'up' | 'down'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ToastComponentProps {
|
|
40
|
+
toast: Toast
|
|
41
|
+
onRemove: (id: string) => void
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ToasterShowOptions extends ToastOptions {
|
|
45
|
+
onClose?: () => void
|
|
46
|
+
}
|