@lets-events/react 3.0.0 → 5.0.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.
@@ -0,0 +1,138 @@
1
+ import { ComponentProps, ElementType } from 'react';
2
+ import { styled } from '../styles'
3
+ import { Grid as GridRadix } from "@radix-ui/themes";
4
+ export const GridStyled = styled(GridRadix, {
5
+ display: 'grid',
6
+ variants: {
7
+ display: {
8
+ 'grid': { display: 'grid' },
9
+ 'inline-grid': { display: 'inline-grid' },
10
+ },
11
+ align: {
12
+ start: { alignItems: 'start' },
13
+ center: { alignItems: 'center' },
14
+ end: { alignItems: 'end' },
15
+ stretch: { alignItems: 'stretch' },
16
+ },
17
+ justify: {
18
+ start: { justifyContent: 'start' },
19
+ center: { justifyContent: 'center' },
20
+ end: { justifyContent: 'end' },
21
+ between: { justifyContent: 'space-between' },
22
+ },
23
+ flow: {
24
+ row: { gridAutoFlow: 'row' },
25
+ column: { gridAutoFlow: 'column' },
26
+ 'row-dense': { gridAutoFlow: 'row dense' },
27
+ 'column-dense': { gridAutoFlow: 'column dense' },
28
+ },
29
+ columns: {
30
+ 1: { gridTemplateColumns: 'repeat(1, 1fr)' },
31
+ 2: { gridTemplateColumns: 'repeat(2, 1fr)' },
32
+ 3: { gridTemplateColumns: 'repeat(3, 1fr)' },
33
+ 4: { gridTemplateColumns: 'repeat(4, 1fr)' },
34
+ 6: { gridTemplateColumns: 'repeat(6, 1fr)' },
35
+ 12: { gridTemplateColumns: 'repeat(12, 1fr)' },
36
+ },
37
+ rows: {
38
+ 1: { gridTemplateRows: 'repeat(1, 1fr)' },
39
+ 2: { gridTemplateRows: 'repeat(2, 1fr)' },
40
+ 3: { gridTemplateRows: 'repeat(3, 1fr)' },
41
+ 4: { gridTemplateRows: 'repeat(4, 1fr)' },
42
+ 5: { gridTemplateRows: 'repeat(5, 1fr)' },
43
+ 6: { gridTemplateRows: 'repeat(6, 1fr)' },
44
+ 7: { gridTemplateRows: 'repeat(7, 1fr)' },
45
+ 8: { gridTemplateRows: 'repeat(8, 1fr)' },
46
+ 9: { gridTemplateRows: 'repeat(9, 1fr)' },
47
+ 10: { gridTemplateRows: 'repeat(10, 1fr)' },
48
+ 11: { gridTemplateRows: 'repeat(11, 1fr)' },
49
+ 12: { gridTemplateRows: 'repeat(12, 1fr)' },
50
+ auto: { gridTemplateRows: 'auto' },
51
+ },
52
+ gap: {
53
+ 2: { gap: '$2' },
54
+ 4: { gap: '$4' },
55
+ 6: { gap: '$6' },
56
+ 8: { gap: '$8' },
57
+ 10: { gap: '$10' },
58
+ 12: { gap: '$12' },
59
+ 14: { gap: '$14' },
60
+ 16: { gap: '$16' },
61
+ 20: { gap: '$20' },
62
+ 22: { gap: '$22' },
63
+ 24: { gap: '$24' },
64
+ 32: { gap: '$32' },
65
+ 36: { gap: '$36' },
66
+ 40: { gap: '$40' },
67
+ 48: { gap: '$48' },
68
+ 56: { gap: '$56' },
69
+ 64: { gap: '$64' },
70
+ 72: { gap: '$72' },
71
+ 80: { gap: '$80' },
72
+ full: { gap: '$full' },
73
+ },
74
+ gapX: {
75
+ 2: { gap: '$2' },
76
+ 4: { gap: '$4' },
77
+ 6: { gap: '$6' },
78
+ 8: { gap: '$8' },
79
+ 10: { gap: '$10' },
80
+ 12: { gap: '$12' },
81
+ 14: { gap: '$14' },
82
+ 16: { gap: '$16' },
83
+ 20: { gap: '$20' },
84
+ 22: { gap: '$22' },
85
+ 24: { gap: '$24' },
86
+ 32: { gap: '$32' },
87
+ 36: { gap: '$36' },
88
+ 40: { gap: '$40' },
89
+ 48: { gap: '$48' },
90
+ 56: { gap: '$56' },
91
+ 64: { gap: '$64' },
92
+ 72: { gap: '$72' },
93
+ 80: { gap: '$80' },
94
+ full: { gap: '$full' },
95
+ },
96
+ gapY: {
97
+ 2: { gap: '$2' },
98
+ 4: { gap: '$4' },
99
+ 6: { gap: '$6' },
100
+ 8: { gap: '$8' },
101
+ 10: { gap: '$10' },
102
+ 12: { gap: '$12' },
103
+ 14: { gap: '$14' },
104
+ 16: { gap: '$16' },
105
+ 20: { gap: '$20' },
106
+ 22: { gap: '$22' },
107
+ 24: { gap: '$24' },
108
+ 32: { gap: '$32' },
109
+ 36: { gap: '$36' },
110
+ 40: { gap: '$40' },
111
+ 48: { gap: '$48' },
112
+ 56: { gap: '$56' },
113
+ 64: { gap: '$64' },
114
+ 72: { gap: '$72' },
115
+ 80: { gap: '$80' },
116
+ full: { gap: '$full' },
117
+ },
118
+ },
119
+ defaultVariants: {
120
+ gap: 10,
121
+ }
122
+
123
+ })
124
+
125
+ export type GridProps = ComponentProps<typeof GridStyled> & {
126
+ as?: ElementType
127
+ children: React.ReactNode,
128
+ areas?: string
129
+ }
130
+
131
+
132
+ export function Grid({ children, ...props }: GridProps) {
133
+ return (
134
+ <GridStyled {...props}>
135
+ {children}
136
+ </GridStyled>
137
+ )
138
+ }
@@ -9,23 +9,34 @@ import PropTypes from "prop-types";
9
9
 
10
10
  library.add(fas, far, fab);
11
11
 
12
- interface IconProps extends Omit<FontAwesomeIconProps, "icon"> {
12
+ interface IconProps extends Omit<FontAwesomeIconProps, "icon" | "size"> {
13
13
  name: IconName;
14
+ size?: 'xs' | 'sm' | 'md' | 'xl';
14
15
  prefix?: IconPrefix;
15
16
  }
16
17
 
17
- export const Icon = ({ name, prefix = "fas", size = "1x", color = "currentColor", className = "", ...props }: IconProps) => {
18
+ export const Icon = ({ name, prefix = "fas", size = "sm", color = "currentColor", className = "", ...props }: IconProps) => {
19
+ const sizeMap = {
20
+
21
+ 'xs': { width: '0.625rem', height: '0.625rem', fontSize: '0.625rem' },
22
+ 'sm': { width: '0.625rem', height: '0.625rem', fontSize: '0.625rem' },
23
+ 'md': { width: '0.75rem', height: '0.75rem', fontSize: '0.75rem' },
24
+ 'xl': { width: '1rem', height: '1rem', fontSize: '1rem' },
25
+ undefined: { width: '0.75rem', height: '0.75rem', fontSize: '0.75rem' },
26
+ } as const;
27
+
18
28
  return (
19
29
  <FontAwesomeIcon
20
30
  icon={[prefix, name]}
21
- size={size}
31
+ style={sizeMap[size]}
22
32
  color={color}
23
33
  className={className}
24
34
  {...props}
35
+ width={sizeMap[size]?.width}
36
+ height={sizeMap[size]?.height}
25
37
  />
26
38
  );
27
39
  };
28
-
29
40
  Icon.propTypes = {
30
41
  name: PropTypes.string.isRequired,
31
42
  prefix: PropTypes.string,
@@ -0,0 +1,109 @@
1
+ import { ComponentProps } from 'react'
2
+ import { styled } from '../styles'
3
+ import { Dialog as ModalRadix } from "@radix-ui/themes";
4
+ import { Button } from './Button';
5
+ import Icon from './Icon';
6
+ import { Box } from './Box';
7
+ import { Flex } from './Flex';
8
+ export const ModalStyled = styled('div', {
9
+ fontFamily: '$default',
10
+ lineHeight: '$base',
11
+ fontSize: '$13',
12
+ borderRadius: '$sm',
13
+ })
14
+
15
+ export const ModalContentStyled = styled(ModalRadix.Content, {
16
+ fontFamily: '$default',
17
+ lineHeight: '$base',
18
+ fontSize: '$13',
19
+ maxWidth: '502px',
20
+ width: '100%',
21
+ border: '1px solid $neutral',
22
+ borderRadius: '$2xl',
23
+ boxShadow: '0px 4px 4px 0px rgba(35, 53, 67, 0.08), 0px 2px 4px 0px rgba(35, 53, 67, 0.16)',
24
+ })
25
+ const ModalHeaderStyled = styled('div', {
26
+ borderBottom: '1px solid $neutral300',
27
+ padding: '$16 $24',
28
+ textAlign: 'center',
29
+ position: 'relative',
30
+ display: 'flex',
31
+ alignItems: 'center',
32
+ justifyContent: 'center',
33
+ })
34
+
35
+ const ModalIconClose = styled(Icon, {
36
+ position: 'absolute',
37
+ right: '$24',
38
+ cursor: 'pointer'
39
+ })
40
+
41
+ const ModalFooterStyled = styled('div', {
42
+ borderTop: '1px solid $neutral300',
43
+ padding: '$16 $24',
44
+
45
+ '.modal-footer-flex': {
46
+ justifyContent: 'flex-end'
47
+ }
48
+ })
49
+
50
+ export const ModalTitleStyled = styled(ModalRadix.Title, {
51
+ fontFamily: '$default',
52
+ lineHeight: '$base',
53
+ fontSize: '$18',
54
+ fontWeight: 'medium',
55
+ fontStyle: 'normal',
56
+ textTransform: 'uppercase'
57
+ })
58
+
59
+ export type ModalProps = ComponentProps<typeof ModalStyled> & {
60
+ trigger: React.ReactNode,
61
+ title?: string
62
+ children: React.ReactNode,
63
+ cancel?: boolean
64
+ cancelText?: string,
65
+ action?: boolean
66
+ actionText?: string;
67
+ onAction?: () => void;
68
+ }
69
+ export function Modal({ children, title, trigger, cancel, cancelText, action, actionText, onAction, ...props }: ModalProps) {
70
+ return (
71
+ <ModalRadix.Root>
72
+ <ModalStyled {...props}>
73
+ <ModalRadix.Trigger>
74
+ {trigger}
75
+ </ModalRadix.Trigger>
76
+
77
+ <ModalContentStyled>
78
+ <ModalHeaderStyled>
79
+ {title && <ModalTitleStyled>{title}</ModalTitleStyled>}
80
+ <ModalRadix.Close>
81
+ <ModalIconClose name='close' size='xl' />
82
+ </ModalRadix.Close>
83
+ </ModalHeaderStyled>
84
+ <Box>
85
+ {children}
86
+ </Box>
87
+ {cancel || action ? (
88
+ <ModalFooterStyled>
89
+ <Flex gap="10" justify="end" width={'100%'} className='modal-footer-flex'>
90
+
91
+ {action && onAction && (
92
+ <ModalRadix.Close>
93
+ <Button variant='contained' color='brand' onClick={onAction}>{actionText ? actionText : 'Salvar'}</Button>
94
+ </ModalRadix.Close>
95
+ )}
96
+ {cancel && (
97
+ <ModalRadix.Close>
98
+ <Button variant="outlined" color="neutral">
99
+ {cancelText ? cancelText : 'cancelar'}
100
+ </Button>
101
+ </ModalRadix.Close>
102
+ )}
103
+ </Flex>
104
+ </ModalFooterStyled>) : null}
105
+ </ModalContentStyled>
106
+ </ModalStyled>
107
+ </ModalRadix.Root>
108
+ )
109
+ }
@@ -50,8 +50,8 @@ export const RadioGroupStyled = styled(RadioGroupRadix.Root, {
50
50
  },
51
51
 
52
52
  variants: {
53
- isValid: {
54
- true: {
53
+ color: {
54
+ success: {
55
55
  'label': {
56
56
  '&:focus button, &:hover button': {
57
57
  boxShadow: '0px 0px 0px 4px rgba(38, 167, 67, 0.50)',
@@ -65,7 +65,8 @@ export const RadioGroupStyled = styled(RadioGroupRadix.Root, {
65
65
  backgroundColor: '$green500',
66
66
  },
67
67
  },
68
- false: {
68
+ blue: {},
69
+ error: {
69
70
  'label': {
70
71
  '&:focus button, &:hover button': {
71
72
  boxShadow: '0px 0px 0px 4px rgba(225, 86, 98, 0.50)'
@@ -98,9 +99,8 @@ export const RadioGroupStyled = styled(RadioGroupRadix.Root, {
98
99
  },
99
100
 
100
101
  compoundVariants: [
101
-
102
102
  {
103
- isValid: undefined,
103
+ color: 'blue',
104
104
  disabled: false,
105
105
  css: {
106
106
  'label': {
@@ -118,7 +118,7 @@ export const RadioGroupStyled = styled(RadioGroupRadix.Root, {
118
118
  },
119
119
 
120
120
  {
121
- isValid: undefined,
121
+ color: 'blue',
122
122
  disabled: true,
123
123
  css: {
124
124
  'label button': {
@@ -132,7 +132,7 @@ export const RadioGroupStyled = styled(RadioGroupRadix.Root, {
132
132
  },
133
133
 
134
134
  {
135
- isValid: true,
135
+ color: 'success',
136
136
  disabled: true,
137
137
  css: {
138
138
  'label button': {
@@ -146,7 +146,7 @@ export const RadioGroupStyled = styled(RadioGroupRadix.Root, {
146
146
  },
147
147
 
148
148
  {
149
- isValid: false,
149
+ color: 'error',
150
150
  disabled: true,
151
151
  css: {
152
152
  'label button': {
@@ -158,13 +158,17 @@ export const RadioGroupStyled = styled(RadioGroupRadix.Root, {
158
158
  }
159
159
  }
160
160
  }
161
- ]
161
+ ],
162
+ defaultVariants: {
163
+ color: 'blue',
164
+ disabled: false
165
+ }
162
166
  })
163
167
 
164
168
  export type RadioGroupProps = ComponentProps<typeof RadioGroupStyled> & {
165
169
  placeholder?: string
166
170
  children?: React.ReactNode
167
- isValid?: boolean
171
+ color?: string
168
172
  disabled?: boolean
169
173
  }
170
174
 
@@ -175,14 +179,12 @@ export type RadioItemProps = {
175
179
 
176
180
  export function RadioGroup({
177
181
  children,
178
- isValid,
179
182
  disabled,
180
183
  ...props
181
184
  }: RadioGroupProps) {
182
185
  return (
183
186
  <RadioGroupStyled
184
187
  disabled={disabled}
185
- isValid={isValid}
186
188
  {...props}
187
189
  >
188
190
  {children}
@@ -0,0 +1,34 @@
1
+ import { ComponentProps, ElementType } from 'react';
2
+ import { styled } from '../styles';
3
+ import { Section as SectionRadix } from '@radix-ui/themes';
4
+
5
+ export const SectionStyled = styled(SectionRadix, {
6
+ variants: {
7
+ size: {
8
+ xs: { maxWidth: '576px' },
9
+ sm: { minWidth: '577px', maxWidth: '767px' },
10
+ md: { mixWidth: '768px', maxWidth: '991px' },
11
+ lg: { mixWidth: '992px', maxWidth: '1199px' },
12
+ xl: { mixWidth: '1200px', maxWidth: '1399px' },
13
+ xxl: { mixWidth: '1400px' },
14
+ responsive: { width: '100%', maxWidth: '100%', minWidth: '100%' }
15
+ },
16
+ display: {
17
+ none: { display: 'none' },
18
+ initial: { display: 'initial' },
19
+ },
20
+ },
21
+ defaultVariants: {
22
+ size: 'md',
23
+ display: 'initial'
24
+ },
25
+ });
26
+
27
+ export type SectionProps = ComponentProps<typeof SectionStyled> & {
28
+ as?: ElementType;
29
+ children: React.ReactNode;
30
+ };
31
+
32
+ export function Section({ children, ...props }: SectionProps) {
33
+ return <SectionStyled {...props}>{children}</SectionStyled>;
34
+ }
@@ -0,0 +1,148 @@
1
+ import React, { ComponentProps, ElementType } from 'react'
2
+ import { styled } from '../styles'
3
+ import { Box, Tabs as StepRadix } from "@radix-ui/themes";
4
+
5
+ export const StepStyled = styled('div', {
6
+ fontFamily: '$default',
7
+ color: '$gray100',
8
+ letterSpacing: '0px',
9
+
10
+ })
11
+
12
+ const StepTriggerStyled = styled(StepRadix.Trigger, {
13
+ all: 'unset',
14
+ position: 'relative',
15
+ display: 'flex',
16
+ alignItems: 'center',
17
+ justifyContent: 'center',
18
+ fontSize: '$16',
19
+ fontWeight: '$medium',
20
+
21
+
22
+ minWidth: '32px',
23
+ minHeight: '32px',
24
+ marginRight: '40px',
25
+
26
+
27
+ '&:last-of-type': {
28
+ marginRight: 0,
29
+ },
30
+
31
+
32
+ '& > span:first-of-type': {
33
+ width: '32px',
34
+ height: '32px',
35
+ borderRadius: '$full',
36
+ backgroundColor: '$neutral50',
37
+ border: '1px solid $neutral200',
38
+ color: '$gray700',
39
+ display: 'flex',
40
+ alignItems: 'center',
41
+ justifyContent: 'center',
42
+ zIndex: 1,
43
+ position: 'relative',
44
+
45
+ },
46
+
47
+
48
+ '&[data-state="active"] > span:first-of-type': {
49
+ backgroundColor: '$blue500',
50
+ borderColor: '$blue500',
51
+ color: 'white',
52
+ },
53
+
54
+
55
+ '& > span:last-of-type': {
56
+ display: 'none',
57
+ },
58
+
59
+
60
+ '&:not(:first-of-type)::before': {
61
+ content: '""',
62
+ position: 'absolute',
63
+ top: '50%',
64
+ right: 'calc(100% + 4px)',
65
+ transform: 'translateY(-50%)',
66
+ width: '32px',
67
+ height: '8px',
68
+ borderRadius: '$sm',
69
+ backgroundColor: '$neutral50',
70
+ zIndex: 0,
71
+ },
72
+
73
+
74
+ '&[data-state="active"]::before': {
75
+ backgroundColor: '$blue500',
76
+ },
77
+
78
+ '&[data-filled="true"] > span:first-of-type': {
79
+ backgroundColor: '$blue500',
80
+ borderColor: '$blue500',
81
+ color: 'white',
82
+ },
83
+
84
+ '&[data-filled="true"]::before': {
85
+ backgroundColor: '$blue500',
86
+ },
87
+ });
88
+
89
+ const StepListStyled = styled(StepRadix.List, {
90
+ display: 'flex',
91
+ alignItems: 'center',
92
+ justifyContent: 'flex-start',
93
+ gap: '$4',
94
+
95
+ });
96
+
97
+ export type StepProps = ComponentProps<typeof StepStyled> & {
98
+ children: React.ReactNode,
99
+ defaultValue: number
100
+
101
+ }
102
+ export function Step({ children, defaultValue, ...props }: StepProps) {
103
+ return (
104
+ <StepRadix.Root defaultValue={String(defaultValue)}>
105
+ <StepStyled {...props}>
106
+ {children}
107
+ </StepStyled>
108
+ </StepRadix.Root>
109
+
110
+ )
111
+ }
112
+
113
+ export function StepTrigger({ value, children, currentStep, ...props }: { value: number, children: React.ReactNode | string, currentStep?: number, onClick: () => void }) {
114
+ const isActiveOrPrevious = currentStep !== undefined && value <= currentStep
115
+ console.log(isActiveOrPrevious, 'isActiveOrPrevius', currentStep)
116
+ return (
117
+ <StepTriggerStyled data-filled={isActiveOrPrevious} value={String(value)} {...props}>{children}</StepTriggerStyled>
118
+ )
119
+ }
120
+
121
+ export function StepContent({ value, children, ...props }: { value: number, children: React.ReactNode }) {
122
+ return (
123
+ <StepRadix.Content value={String(value)} {...props}>
124
+ {children}
125
+ </StepRadix.Content>
126
+ )
127
+ }
128
+
129
+ export function StepList({ children, currentStep, ...props }: { children: React.ReactNode, currentStep: number }) {
130
+ return (
131
+ <StepListStyled {...props}>
132
+ {React.Children.map(children, (child) => {
133
+ if (React.isValidElement(child) && child.type === StepTrigger) {
134
+ return React.cloneElement(child, { currentStep } as any)
135
+ }
136
+ return child
137
+ })}
138
+ </StepListStyled>
139
+ )
140
+ }
141
+
142
+ export function StepWrapper({ children, ...props }: { children: React.ReactNode }) {
143
+ return (
144
+ <Box {...props}>
145
+ {children}
146
+ </Box>
147
+ )
148
+ }
@@ -0,0 +1,109 @@
1
+ import { Switch as RadixSwitch } from '@radix-ui/themes'
2
+ import type { ComponentProps } from 'react'
3
+ import { styled } from '../styles'
4
+
5
+ export const SwitchStyled = styled(RadixSwitch, {
6
+ all: 'unset',
7
+ borderRadius: '$full',
8
+ position: 'relative',
9
+ display: 'flex',
10
+ alignItems: 'center',
11
+ justifyContent: 'center',
12
+ transition: 'all 0.3s',
13
+ cursor: 'pointer',
14
+
15
+ '&::before': {
16
+ content: '""',
17
+ position: 'absolute',
18
+ borderRadius: '$full',
19
+ pointerEvents: 'none',
20
+ cursor: 'pointer',
21
+ },
22
+ 'span': {
23
+ position: 'absolute',
24
+ top: '50%',
25
+ left: 0,
26
+ transform: 'translate(0, -50%)',
27
+ borderRadius: '50%',
28
+ transition: 'all 0.3s',
29
+ cursor: 'pointer',
30
+ borderWidth: '1px',
31
+ borderStyle: 'solid',
32
+ boxShadow: '0px 0px 4px 0px rgba(0, 0, 0, 0.24)',
33
+ },
34
+
35
+ '&[data-state="checked"] span': {
36
+ left: 'auto',
37
+ transform: 'translate(50%, -50%)',
38
+ },
39
+
40
+ variants: {
41
+ color: {
42
+ brand: {
43
+ '&::before': {
44
+ backgroundColor: '$brand50',
45
+ },
46
+ 'span': {
47
+ backgroundColor: '$dark50',
48
+ borderColor: '$neutral300',
49
+ },
50
+ '&[data-state="checked"] span': {
51
+ backgroundColor: '$brand500',
52
+ borderColor: '$brand500',
53
+ },
54
+ }
55
+ },
56
+ size: {
57
+ sm: {
58
+ width: '32px',
59
+ height: '20px',
60
+ '&::before': {
61
+ width: '$32',
62
+ height: '$12',
63
+ },
64
+
65
+ 'span': {
66
+ width: '$20',
67
+ height: '$20',
68
+ },
69
+ },
70
+ md: {
71
+ width: '40px',
72
+ height: '20px',
73
+ '&::before': {
74
+ width: '40px',
75
+ height: '16px',
76
+ },
77
+ 'span': {
78
+ width: '24px',
79
+ height: '24px',
80
+ },
81
+ },
82
+ lg: {
83
+ width: '56px',
84
+ height: '32px',
85
+ '&::before': {
86
+ width: '56px',
87
+ height: '24px',
88
+ },
89
+ 'span': {
90
+ width: '32px',
91
+ height: '32px',
92
+ },
93
+ },
94
+ },
95
+ },
96
+ defaultVariants: {
97
+ size: 'md',
98
+ color: 'brand',
99
+ },
100
+
101
+ })
102
+ export type SwitchProps = ComponentProps<typeof RadixSwitch> & {
103
+ color?: 'brand'
104
+ size?: 'sm' | 'md' | 'lg'
105
+ }
106
+
107
+ export function Switch(props: SwitchProps) {
108
+ return <SwitchStyled color="brand" defaultChecked {...props} />
109
+ }