@lets-events/react 10.0.0 → 10.1.0

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.
Files changed (47) hide show
  1. package/.eslintrc.json +2 -2
  2. package/.turbo/turbo-build.log +20 -18
  3. package/CHANGELOG.md +12 -0
  4. package/dist/index.d.mts +426 -1
  5. package/dist/index.d.ts +426 -1
  6. package/dist/index.js +289 -10
  7. package/dist/index.mjs +280 -9
  8. package/package.json +3 -1
  9. package/src/components/Alert.tsx +303 -303
  10. package/src/components/Avatar.tsx +55 -55
  11. package/src/components/Badge.tsx +128 -128
  12. package/src/components/Box.tsx +3 -3
  13. package/src/components/Button/index.tsx +12 -12
  14. package/src/components/Button/styledComponents.ts +250 -250
  15. package/src/components/ButtonGroup.tsx +484 -484
  16. package/src/components/Calendar/index.tsx +136 -136
  17. package/src/components/Calendar/styledComponents.ts +208 -208
  18. package/src/components/Card.tsx +69 -69
  19. package/src/components/CheckboxGroup.tsx +214 -214
  20. package/src/components/Container.tsx +39 -39
  21. package/src/components/Dropdown.tsx +167 -167
  22. package/src/components/Filter.tsx +164 -164
  23. package/src/components/Flex.tsx +118 -118
  24. package/src/components/Grid.tsx +137 -137
  25. package/src/components/Icon.tsx +47 -47
  26. package/src/components/Modal.tsx +90 -88
  27. package/src/components/RadioGroup.tsx +210 -210
  28. package/src/components/Section.tsx +33 -33
  29. package/src/components/Step.tsx +164 -164
  30. package/src/components/Switch.tsx +108 -108
  31. package/src/components/Text.tsx +30 -30
  32. package/src/components/TextField.tsx +299 -299
  33. package/src/components/TextareaField.tsx +101 -101
  34. package/src/components/TimePicker.tsx +239 -239
  35. package/src/components/Toast/components/ToastItem.tsx +41 -0
  36. package/src/components/Toast/components/ToastProvider.tsx +63 -0
  37. package/src/components/Toast/hooks/useToast.ts +12 -0
  38. package/src/components/Toast/index.tsx +5 -0
  39. package/src/components/Toast/styles/index.ts +135 -0
  40. package/src/components/Toast/types/index.ts +46 -0
  41. package/src/components/Tooltip/index.tsx +67 -0
  42. package/src/components/Tooltip/styles.ts +78 -0
  43. package/src/hooks/useOnClickOutside.tsx +20 -20
  44. package/src/index.tsx +33 -31
  45. package/src/styles/index.ts +38 -38
  46. package/src/types/typographyValues.ts +178 -178
  47. package/tsconfig.json +3 -3
@@ -0,0 +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
+
@@ -0,0 +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
+ }
@@ -0,0 +1,67 @@
1
+ import * as React from 'react'
2
+ import * as TooltipPrimitive from '@radix-ui/react-tooltip'
3
+ import { styled } from '../../styles'
4
+ import { Text } from '../Text'
5
+
6
+ const TooltipProvider = TooltipPrimitive.Provider
7
+ const TooltipRoot = TooltipPrimitive.Root
8
+ const TooltipTrigger = TooltipPrimitive.Trigger
9
+
10
+ const TooltipContent = styled(TooltipPrimitive.Content, {
11
+ backgroundColor: '$dark800',
12
+ color: '$neutral50',
13
+ borderRadius: '4px',
14
+ padding: '10px 15px',
15
+ fontSize: '14px',
16
+ lineHeight: 1,
17
+ zIndex: 100,
18
+ boxShadow: '0 2px 10px rgba(0, 0, 0, 0.1)',
19
+ userSelect: 'none',
20
+ animationDuration: '400ms',
21
+ animationTimingFunction: 'cubic-bezier(0.16, 1, 0.3, 1)',
22
+ willChange: 'transform, opacity',
23
+ '&[data-state="delayed-open"][data-side="top"]': {
24
+ animationName: 'slideDownAndFade',
25
+ },
26
+ '&[data-state="delayed-open"][data-side="right"]': {
27
+ animationName: 'slideLeftAndFade',
28
+ },
29
+ '&[data-state="delayed-open"][data-side="bottom"]': {
30
+ animationName: 'slideUpAndFade',
31
+ },
32
+ '&[data-state="delayed-open"][data-side="left"]': {
33
+ animationName: 'slideRightAndFade',
34
+ },
35
+ })
36
+
37
+ const TooltipArrow = styled(TooltipPrimitive.Arrow, {
38
+ fill: '$dark800',
39
+ })
40
+
41
+ export interface TooltipProps {
42
+ children: React.ReactNode
43
+ content: React.ReactNode
44
+ delayDuration?: number
45
+ side?: 'top' | 'right' | 'bottom' | 'left'
46
+ }
47
+
48
+ export function Tooltip({
49
+ children,
50
+ content,
51
+ delayDuration = 200,
52
+ side = 'top',
53
+ }: TooltipProps) {
54
+ return (
55
+ <TooltipProvider>
56
+ <TooltipRoot delayDuration={delayDuration}>
57
+ <TooltipTrigger asChild>{children}</TooltipTrigger>
58
+ <TooltipContent side={side} sideOffset={5}>
59
+ {typeof content === 'string' ? <Text typography={'tooltip'}>{content}</Text>:(content)}
60
+ <TooltipArrow />
61
+ </TooltipContent>
62
+ </TooltipRoot>
63
+ </TooltipProvider>
64
+ )
65
+ }
66
+
67
+ export { TooltipProvider, TooltipRoot, TooltipTrigger, TooltipContent }
@@ -0,0 +1,78 @@
1
+ import { keyframes } from '@stitches/react'
2
+ import { styled } from '../../styles'
3
+
4
+ const slideUpAndFade = keyframes({
5
+ from: {
6
+ opacity: 0,
7
+ transform: 'translateY(2px)',
8
+ },
9
+ to: {
10
+ opacity: 1,
11
+ transform: 'translateY(0)',
12
+ },
13
+ })
14
+
15
+ const slideRightAndFade = keyframes({
16
+ from: {
17
+ opacity: 0,
18
+ transform: 'translateX(-2px)',
19
+ },
20
+ to: {
21
+ opacity: 1,
22
+ transform: 'translateX(0)',
23
+ },
24
+ })
25
+
26
+ const slideDownAndFade = keyframes({
27
+ from: {
28
+ opacity: 0,
29
+ transform: 'translateY(-2px)',
30
+ },
31
+ to: {
32
+ opacity: 1,
33
+ transform: 'translateY(0)',
34
+ },
35
+ })
36
+
37
+ const slideLeftAndFade = keyframes({
38
+ from: {
39
+ opacity: 0,
40
+ transform: 'translateX(2px)',
41
+ },
42
+ to: {
43
+ opacity: 1,
44
+ transform: 'translateX(0)',
45
+ },
46
+ })
47
+
48
+ export const TooltipContentStyled = styled('div', {
49
+ fontFamily: '$default',
50
+ backgroundColor: '$dark700',
51
+ color: '$dark50',
52
+ borderRadius: '$sm',
53
+ padding: '$10 $14',
54
+ fontSize: '$13',
55
+ lineHeight: '$base',
56
+ boxShadow: '0px 4px 4px 0px rgba(35, 53, 67, 0.08)',
57
+ userSelect: 'none',
58
+ animationDuration: '400ms',
59
+ animationTimingFunction: 'cubic-bezier(0.16, 1, 0.3, 1)',
60
+ willChange: 'transform, opacity',
61
+
62
+ '&[data-state="delayed-open"][data-side="top"]': {
63
+ animationName: `${slideDownAndFade}`,
64
+ },
65
+ '&[data-state="delayed-open"][data-side="right"]': {
66
+ animationName: `${slideLeftAndFade}`,
67
+ },
68
+ '&[data-state="delayed-open"][data-side="bottom"]': {
69
+ animationName: `${slideUpAndFade}`,
70
+ },
71
+ '&[data-state="delayed-open"][data-side="left"]': {
72
+ animationName: `${slideRightAndFade}`,
73
+ },
74
+ })
75
+
76
+ export const TooltipArrow = styled('div', {
77
+ fill: '$dark700',
78
+ })
@@ -1,20 +1,20 @@
1
- import { useEffect } from "react";
2
-
3
- export function useOnClickOutside(ref: any, handler: () => void) {
4
- useEffect(() => {
5
- const listener = (event: MouseEvent | TouchEvent) => {
6
- if (!ref.current || ref.current.contains(event.target)) {
7
- return;
8
- }
9
- handler();
10
- };
11
-
12
- document.addEventListener("mousedown", listener);
13
- document.addEventListener("touchstart", listener);
14
-
15
- return () => {
16
- document.removeEventListener("mousedown", listener);
17
- document.removeEventListener("touchstart", listener);
18
- };
19
- }, [ref, handler]);
20
- }
1
+ import { useEffect } from "react";
2
+
3
+ export function useOnClickOutside(ref: any, handler: () => void) {
4
+ useEffect(() => {
5
+ const listener = (event: MouseEvent | TouchEvent) => {
6
+ if (!ref.current || ref.current.contains(event.target)) {
7
+ return;
8
+ }
9
+ handler();
10
+ };
11
+
12
+ document.addEventListener("mousedown", listener);
13
+ document.addEventListener("touchstart", listener);
14
+
15
+ return () => {
16
+ document.removeEventListener("mousedown", listener);
17
+ document.removeEventListener("touchstart", listener);
18
+ };
19
+ }, [ref, handler]);
20
+ }
package/src/index.tsx CHANGED
@@ -1,31 +1,33 @@
1
- // Icon
2
- export * from './components/Icon'
3
-
4
- // Text
5
- export * from './components/Text'
6
-
7
- // Components
8
- export * from './components/Button'
9
- export * from './components/ButtonGroup'
10
- export * from './components/Avatar'
11
- export * from './components/TextField'
12
- export * from './components/RadioGroup'
13
- export * from './components/CheckboxGroup'
14
- export * from './components/Filter'
15
- export * from './components/Dropdown'
16
- export * from './components/Badge'
17
- export * from './components/Modal'
18
- export * from './components/Calendar'
19
- export * from './components/TimePicker'
20
- export * from './components/Alert'
21
- export * from './components/Switch'
22
- export * from './components/Step'
23
- export * from './components/Card'
24
- export * from './components/TextareaField'
25
-
26
- // Layouts
27
- export * from './components/Flex'
28
- export * from './components/Box'
29
- export * from './components/Grid'
30
- export * from './components/Container'
31
- export * from './components/Section'
1
+ // Icon
2
+ export * from './components/Icon'
3
+
4
+ // Text
5
+ export * from './components/Text'
6
+
7
+ // Components
8
+ export * from './components/Button'
9
+ export * from './components/ButtonGroup'
10
+ export * from './components/Avatar'
11
+ export * from './components/TextField'
12
+ export * from './components/RadioGroup'
13
+ export * from './components/CheckboxGroup'
14
+ export * from './components/Filter'
15
+ export * from './components/Dropdown'
16
+ export * from './components/Badge'
17
+ export * from './components/Modal'
18
+ export * from './components/Calendar'
19
+ export * from './components/TimePicker'
20
+ export * from './components/Alert'
21
+ export * from './components/Switch'
22
+ export * from './components/Step'
23
+ export * from './components/Card'
24
+ export * from './components/TextareaField'
25
+ export * from './components/Toast'
26
+ export * from './components/Tooltip'
27
+
28
+ // Layouts
29
+ export * from './components/Flex'
30
+ export * from './components/Box'
31
+ export * from './components/Grid'
32
+ export * from './components/Container'
33
+ export * from './components/Section'
@@ -1,38 +1,38 @@
1
- import {
2
- colors,
3
- fontSizes,
4
- fontWeights,
5
- fonts,
6
- lineHeights,
7
- radii,
8
- space,
9
- } from '@lets-events/tokens'
10
-
11
- import { createStitches, defaultThemeMap } from '@stitches/react'
12
-
13
- export const {
14
- styled,
15
- css,
16
- globalCss,
17
- keyframes,
18
- getCssText,
19
- theme,
20
- createTheme,
21
- config,
22
- } = createStitches({
23
- themeMap: {
24
- ...defaultThemeMap,
25
- height: 'space',
26
- width: 'space',
27
- gap: 'space'
28
- },
29
- theme: {
30
- colors,
31
- fontSizes,
32
- fonts,
33
- fontWeights,
34
- lineHeights,
35
- radii,
36
- space,
37
- },
38
- })
1
+ import {
2
+ colors,
3
+ fontSizes,
4
+ fontWeights,
5
+ fonts,
6
+ lineHeights,
7
+ radii,
8
+ space,
9
+ } from '@lets-events/tokens'
10
+
11
+ import { createStitches, defaultThemeMap } from '@stitches/react'
12
+
13
+ export const {
14
+ styled,
15
+ css,
16
+ globalCss,
17
+ keyframes,
18
+ getCssText,
19
+ theme,
20
+ createTheme,
21
+ config,
22
+ } = createStitches({
23
+ themeMap: {
24
+ ...defaultThemeMap,
25
+ height: 'space',
26
+ width: 'space',
27
+ gap: 'space'
28
+ },
29
+ theme: {
30
+ colors,
31
+ fontSizes,
32
+ fonts,
33
+ fontWeights,
34
+ lineHeights,
35
+ radii,
36
+ space,
37
+ },
38
+ })