@dafaz-ui/react 4.0.19 → 7.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,146 @@
1
+ import { styled } from '../../styles'
2
+ import type { ComponentProps, CSSProperties } from 'react'
3
+
4
+ export const Button = styled('button', {
5
+ backgroundColor: 'transparent',
6
+ border: 'none',
7
+ display: 'flex',
8
+ alignItems: 'center',
9
+ justifyContent: 'center',
10
+ color: 'white',
11
+ marginBottom: '-3px',
12
+
13
+ cursor: 'pointer',
14
+
15
+ zIndex: 5,
16
+
17
+ variants: {
18
+ size: {
19
+ lg: {
20
+ height: '$10',
21
+ width: '$10',
22
+ },
23
+ md: {
24
+ height: '$8',
25
+ width: '$8',
26
+ },
27
+ sm: {
28
+ height: '$6',
29
+ width: '$6',
30
+ },
31
+ },
32
+ },
33
+ defaultVariants: {
34
+ size: 'lg',
35
+ },
36
+ })
37
+
38
+ export const SelectUI = styled('div', {
39
+ zIndex: 3,
40
+ width: '100%',
41
+ maxWidth: '24.5rem',
42
+
43
+ position: 'relative',
44
+ display: 'inline-block',
45
+
46
+ fontFamily: '$app',
47
+ color: '$white',
48
+ fontWeight: '$regular',
49
+ cursor: 'pointer',
50
+
51
+ margin: 0,
52
+ backgroundColor: 'transparent',
53
+ borderBottom: '2px solid $dafaz600',
54
+ borderRadius: '$md',
55
+ boxSizing: 'border-box',
56
+ transition: 'border 0.2s linear',
57
+
58
+ boxShadow: '0 3px 2px -2px $colors$gray400',
59
+
60
+ '&:hover': {
61
+ borderBottom: '2px solid $dafaz400',
62
+ },
63
+
64
+ '&.clicked': {
65
+ borderBottom: '2px solid $dafaz400',
66
+ },
67
+
68
+ variants: {
69
+ disabled: {
70
+ true: {
71
+ opacity: 0.5,
72
+ cursor: 'not-allowed',
73
+ },
74
+ },
75
+ size: {
76
+ lg: {
77
+ fontSize: '$xl',
78
+ svg: {
79
+ width: '$5',
80
+ height: '$5',
81
+ },
82
+ },
83
+ md: {
84
+ fontSize: '$lg',
85
+ svg: {
86
+ width: '$4',
87
+ height: '$4',
88
+ },
89
+ },
90
+ sm: {
91
+ fontSize: '$md',
92
+ svg: {
93
+ width: '$3',
94
+ height: '$3',
95
+ },
96
+ },
97
+ },
98
+ },
99
+ defaultVariants: {
100
+ disabled: false,
101
+ size: 'lg',
102
+ },
103
+ })
104
+
105
+ export interface SelectUIProps extends ComponentProps<typeof SelectUI> {
106
+ size?: 'sm' | 'md' | 'lg'
107
+ disabled?: boolean
108
+ style?: CSSProperties
109
+ }
110
+
111
+ export const SelectContainerUI = styled('div', {
112
+ padding: '$3 $2',
113
+ marginTop: '2px',
114
+
115
+ border: '1px solid $gray400',
116
+ boxSizing: 'border-box',
117
+ borderRadius: '$md',
118
+
119
+ position: 'absolute',
120
+ zIndex: 2,
121
+ minWidth: '100%',
122
+ maxWidth: '24.5rem',
123
+
124
+ background: '$gray800',
125
+
126
+ fontFamily: '$app',
127
+ color: '$white',
128
+ fontWeight: '$regular',
129
+ cursor: 'pointer',
130
+
131
+ '&.closed': {
132
+ display: 'none',
133
+ },
134
+
135
+ '&.opened': {
136
+ display: 'flex',
137
+ flexDirection: 'column',
138
+ gap: '$3',
139
+ },
140
+ })
141
+
142
+ export interface SelectContainerUIProps
143
+ extends ComponentProps<typeof SelectContainerUI> {
144
+ className?: string
145
+ style?: CSSProperties
146
+ }
@@ -6,6 +6,7 @@ import {
6
6
  RadioItemUI,
7
7
  type RadioItemUIProps,
8
8
  } from './styles'
9
+ import { useId } from 'react'
9
10
 
10
11
  interface RadioItemProps {
11
12
  label: string
@@ -13,19 +14,20 @@ interface RadioItemProps {
13
14
 
14
15
  export function RadioItem({
15
16
  label,
16
- id,
17
17
  size,
18
18
  disabled = false,
19
19
  ...props
20
20
  }: RadioItemProps & RadioItemUIProps) {
21
+ const htmlId = useId()
22
+
21
23
  return (
22
- <RadioItemContainer key={id}>
23
- <RadioItemUI disabled={disabled} id={id} {...props} size={size}>
24
+ <RadioItemContainer>
25
+ <RadioItemUI disabled={disabled} id={htmlId} {...props} size={size}>
24
26
  <RadioIndicator asChild size={size}>
25
27
  <Check weight="bold" />
26
28
  </RadioIndicator>
27
29
  </RadioItemUI>
28
- <Label disabled={disabled} htmlFor={id} size={size}>
30
+ <Label disabled={disabled} htmlFor={htmlId} size={size}>
29
31
  {label}
30
32
  </Label>
31
33
  </RadioItemContainer>
@@ -1,4 +1,4 @@
1
- import type { ComponentProps } from 'react'
1
+ import type { ComponentProps, CSSProperties } from 'react'
2
2
  import { keyframes, styled } from '../../../styles'
3
3
  import * as RadioGroup from '@radix-ui/react-radio-group'
4
4
 
@@ -18,6 +18,8 @@ export const RadioItemUI = styled(RadioGroup.Item, {
18
18
  display: 'flex',
19
19
  justifyContent: 'center',
20
20
  alignItems: 'center',
21
+
22
+ boxShadow: '1.3px 1.3px 4px -1px $colors$dafaz600',
21
23
  transition: 'border 0.2s linear',
22
24
 
23
25
  '&:disabled': {
@@ -138,4 +140,5 @@ export const Label = styled('label', {
138
140
 
139
141
  export interface RadioItemUIProps extends ComponentProps<typeof RadioItemUI> {
140
142
  size?: 'sm' | 'md' | 'lg'
143
+ style?: CSSProperties
141
144
  }
@@ -1,5 +1,6 @@
1
1
  import { RadioUI, RadioUIProps } from './styles'
2
2
  import { RadioItem } from './RadioItem'
3
+ import { forwardRef, type ElementRef } from 'react'
3
4
 
4
5
  interface Item {
5
6
  id: string
@@ -9,30 +10,44 @@ interface Item {
9
10
 
10
11
  interface RadioGroupProps extends RadioUIProps {
11
12
  items: Item[]
13
+ value?: string | undefined
14
+ onValueChange?: ((value: string) => void) | undefined
12
15
  }
13
16
 
14
- export function Radio({
15
- items,
16
- size,
17
- disabled = false,
18
- ...props
19
- }: RadioGroupProps) {
20
- return (
21
- <RadioUI disabled={disabled} {...props}>
22
- {items.map((item) => {
23
- return (
24
- <RadioItem
25
- key={item.id}
26
- id={item.id}
27
- label={item.label}
28
- value={item.value}
29
- size={size}
30
- disabled={disabled}
31
- />
32
- )
33
- })}
34
- </RadioUI>
35
- )
36
- }
17
+ export const Radio = forwardRef<ElementRef<typeof RadioUI>, RadioGroupProps>(
18
+ (
19
+ {
20
+ items,
21
+ size,
22
+ disabled = false,
23
+ onValueChange,
24
+ value,
25
+ ...props
26
+ }: RadioGroupProps,
27
+ ref,
28
+ ) => {
29
+ return (
30
+ <RadioUI
31
+ ref={ref}
32
+ disabled={disabled}
33
+ {...props}
34
+ onValueChange={onValueChange}
35
+ value={value}
36
+ >
37
+ {items.map((item) => {
38
+ return (
39
+ <RadioItem
40
+ key={item.id}
41
+ label={item.label}
42
+ value={item.value}
43
+ size={size}
44
+ disabled={disabled}
45
+ />
46
+ )
47
+ })}
48
+ </RadioUI>
49
+ )
50
+ },
51
+ )
37
52
 
38
53
  Radio.displayName = 'Radio'
@@ -1,4 +1,4 @@
1
- import type { ComponentProps } from 'react'
1
+ import type { ComponentProps, CSSProperties } from 'react'
2
2
  import { styled } from '../../styles'
3
3
  import * as RadioGroup from '@radix-ui/react-radio-group'
4
4
 
@@ -27,4 +27,5 @@ export const RadioUI = styled(RadioGroup.Root, {
27
27
 
28
28
  export interface RadioUIProps extends ComponentProps<typeof RadioUI> {
29
29
  size?: 'sm' | 'md' | 'lg'
30
+ style?: CSSProperties
30
31
  }
@@ -1,6 +1,7 @@
1
- import { SelectUI, SelectUIProps, OptionUI } from './styles'
1
+ import { CaretDown } from '@phosphor-icons/react'
2
+ import { SelectUI, SelectUIProps, OptionUI, SelectContainer } from './styles'
2
3
 
3
- import { ChangeEvent, useState } from 'react'
4
+ import { forwardRef, ChangeEvent, useState, type ElementRef } from 'react'
4
5
 
5
6
  interface Item {
6
7
  id: string
@@ -8,45 +9,58 @@ interface Item {
8
9
  value: string
9
10
  }
10
11
 
11
- interface SelectProps {
12
+ interface SelectProps extends SelectUIProps {
13
+ id: string
12
14
  items: Item[]
13
15
  placeholder?: string
14
16
  }
15
17
 
16
- export function Select({
17
- size,
18
- placeholder,
19
- items,
20
- ...props
21
- }: SelectUIProps & SelectProps) {
22
- const [value, setValue] = useState('')
18
+ export const Select = forwardRef<ElementRef<typeof SelectUI>, SelectProps>(
19
+ ({ id, size, placeholder, items, ...props }: SelectProps, ref) => {
20
+ const [value, setValue] = useState('')
23
21
 
24
- function handleSelect(event: ChangeEvent<HTMLSelectElement>) {
25
- setValue(() => {
26
- return event.target.value
27
- })
28
- }
22
+ function handleSelect(event: ChangeEvent<HTMLSelectElement>) {
23
+ setValue(() => {
24
+ return event.target.value
25
+ })
26
+ }
29
27
 
30
- return (
31
- <SelectUI
32
- size={size}
33
- {...props}
34
- value={value}
35
- onChange={handleSelect}
36
- style={{ opacity: value != '' ? 1 : 0.75 }}
37
- >
38
- <OptionUI className="placeholder" value="">
39
- {placeholder}
40
- </OptionUI>
41
- {items.map((item) => {
42
- return (
43
- <OptionUI key={item.id} value={item.value}>
44
- {item.label}
28
+ return (
29
+ <SelectContainer size={size}>
30
+ <SelectUI
31
+ id={id}
32
+ ref={ref}
33
+ size={size}
34
+ {...props}
35
+ value={value}
36
+ onChange={handleSelect}
37
+ style={{ opacity: value != '' ? 1 : 0.75 }}
38
+ >
39
+ <OptionUI className="placeholder" value="">
40
+ {placeholder}
45
41
  </OptionUI>
46
- )
47
- })}
48
- </SelectUI>
49
- )
50
- }
42
+ {items.map((item) => {
43
+ return (
44
+ <OptionUI key={item.id} value={item.value}>
45
+ {item.label}
46
+ </OptionUI>
47
+ )
48
+ })}
49
+ </SelectUI>
50
+ <span
51
+ style={{
52
+ display: 'flex',
53
+ alignItems: 'center',
54
+ paddingLeft: '1rem',
55
+ marginRight: '0.7rem',
56
+ marginLeft: '-3rem',
57
+ }}
58
+ >
59
+ <CaretDown size={24} weight="bold" />
60
+ </span>
61
+ </SelectContainer>
62
+ )
63
+ },
64
+ )
51
65
 
52
66
  Select.displayName = 'Select'
@@ -1,35 +1,102 @@
1
1
  import type { ComponentProps } from 'react'
2
2
  import { styled } from '../../styles'
3
3
 
4
- export const SelectUI = styled('select', {
5
- gap: '$2',
6
- overflow: 'hidden',
7
-
8
- background: 'transparent',
9
- border: 'none',
4
+ export const SelectContainer = styled('div', {
5
+ display: 'flex',
6
+ alignItems: 'center',
7
+ justifyContent: 'space-between',
10
8
 
11
9
  fontFamily: '$app',
12
10
  color: '$white',
13
- fontWeight: '$regular',
11
+
14
12
  cursor: 'pointer',
15
13
 
14
+ width: '100%',
15
+ maxWidth: '24.5rem',
16
+
16
17
  boxSizing: 'border-box',
17
18
  borderRadius: '$md',
18
19
  borderBottom: '2px solid $dafaz600',
20
+ boxShadow: '0 3px 2px -2px $colors$gray400',
21
+
19
22
  transition: 'border 0.2s linear',
20
23
 
24
+ '&:disabled': {
25
+ cursor: 'not-allowed',
26
+ opacity: 0.5,
27
+ },
28
+
29
+ '&:active': {
30
+ borderBottom: '2px solid $dafaz400',
31
+ },
32
+
33
+ '&:hover': {
34
+ borderBottom: '2px solid $dafaz400',
35
+ },
36
+
37
+ variants: {
38
+ size: {
39
+ lg: {
40
+ fontSize: '$xl',
41
+ svg: {
42
+ width: '$5',
43
+ height: '$5',
44
+ },
45
+ },
46
+ md: {
47
+ fontSize: '$lg',
48
+ svg: {
49
+ width: '$4',
50
+ height: '$4',
51
+ },
52
+ },
53
+ sm: {
54
+ fontSize: '$sm',
55
+ svg: {
56
+ width: '$3',
57
+ height: '$3',
58
+ },
59
+ },
60
+ },
61
+ },
62
+ defaultVariants: {
63
+ size: 'lg',
64
+ },
65
+ })
66
+
67
+ interface SelectContainer extends ComponentProps<typeof SelectContainer> {
68
+ size?: 'sm' | 'md' | 'lg'
69
+ }
70
+
71
+ export const SelectUI = styled('select', {
72
+ zIndex: 1,
73
+ '-moz-appearance': 'none',
74
+ '-webkit-appearance': 'none',
75
+ appearance: 'none',
76
+
77
+ overflow: 'hidden',
78
+ background: 'transparent',
79
+ border: 'none',
80
+
81
+ fontFamily: '$app',
82
+ color: '$white',
83
+ fontWeight: '$regular',
84
+ cursor: 'pointer',
85
+
21
86
  width: '100%',
87
+ maxWidth: '24.5rem',
88
+
22
89
  margin: 0,
23
90
  padding: '$1 $1',
24
91
 
25
- '&:focus': {
26
- outline: 0,
27
- borderBottom: '2px solid $dafaz400',
28
- },
92
+ marginLeft: '$1',
29
93
 
30
94
  '&:disabled': {
31
95
  opacity: 0.5,
32
- cursor: 'not-allowed',
96
+ },
97
+
98
+ '&:focus': {
99
+ outline: 0,
33
100
  },
34
101
 
35
102
  variants: {
@@ -0,0 +1,7 @@
1
+ import { SeparatorUI, SeparatorUIProps } from './styles'
2
+
3
+ export function Separator({ size, color, style, ...props }: SeparatorUIProps) {
4
+ return <SeparatorUI size={size} color={color} style={style} {...props} />
5
+ }
6
+
7
+ Separator.displayName = 'Separator'
@@ -0,0 +1,51 @@
1
+ import type { ComponentProps, CSSProperties } from 'react'
2
+ import { styled } from '../../styles'
3
+
4
+ export const SeparatorUI = styled('hr', {
5
+ width: '100%',
6
+ borderStyle: 'solid',
7
+
8
+ variants: {
9
+ color: {
10
+ primary: {
11
+ borderColor: '$dafaz400',
12
+ },
13
+ lightGray: {
14
+ borderColor: '$gray100',
15
+ },
16
+ darkGray: {
17
+ borderColor: '$gray800',
18
+ },
19
+ white: {
20
+ borderColor: '$white',
21
+ },
22
+ black: {
23
+ borderColor: '$black',
24
+ },
25
+ },
26
+ size: {
27
+ lg: {
28
+ borderWidth: '2px',
29
+ },
30
+ md: {
31
+ borderWidth: '1px',
32
+ },
33
+ sm: {
34
+ borderWidth: '0.75px',
35
+ },
36
+ xs: {
37
+ borderWidth: '0.5px',
38
+ },
39
+ },
40
+ },
41
+ defaultVariants: {
42
+ color: 'primary',
43
+ size: 'lg',
44
+ },
45
+ })
46
+
47
+ export interface SeparatorUIProps extends ComponentProps<typeof SeparatorUI> {
48
+ size?: 'xs' | 'md' | 'sm' | 'lg'
49
+ color?: 'primary' | 'lightGray' | 'darkGray' | 'white' | 'black'
50
+ style?: CSSProperties
51
+ }
@@ -7,11 +7,12 @@ interface TextProps {
7
7
 
8
8
  export function Text({
9
9
  children,
10
- size = 'md',
10
+ size,
11
+ color,
11
12
  ...props
12
13
  }: TextUIProps & TextProps) {
13
14
  return (
14
- <TextUI size={size} {...props}>
15
+ <TextUI size={size} color={color} {...props}>
15
16
  {children}
16
17
  </TextUI>
17
18
  )
@@ -1,11 +1,10 @@
1
- import { ComponentProps, ElementType } from 'react'
1
+ import { ComponentProps, ElementType, type CSSProperties } from 'react'
2
2
  import { styled } from '../../styles'
3
3
 
4
4
  export const TextUI = styled('p', {
5
5
  fontFamily: '$web',
6
6
  lineHeight: '$base',
7
7
  margin: 0,
8
- color: '$white',
9
8
 
10
9
  variants: {
11
10
  size: {
@@ -16,15 +15,37 @@ export const TextUI = styled('p', {
16
15
  lg: { fontSize: '$lg' },
17
16
  xl: { fontSize: '$xl' },
18
17
  '2xl': { fontSize: '$2xl' },
18
+ '3xl': { fontSize: '$3xl' },
19
+ '4xl': { fontSize: '$4xl' },
20
+ },
21
+ color: {
22
+ white: {
23
+ color: '$white',
24
+ },
25
+ black: {
26
+ color: 'black',
27
+ },
28
+ primary: {
29
+ color: '$dafaz400',
30
+ },
31
+ lightGray: {
32
+ color: '$gray400',
33
+ },
34
+ darkGray: {
35
+ color: '$gray800',
36
+ },
19
37
  },
20
38
  },
21
39
 
22
40
  defaultVariants: {
23
41
  size: 'md',
42
+ color: 'white',
24
43
  },
25
44
  })
26
45
 
27
46
  export interface TextUIProps extends ComponentProps<typeof TextUI> {
28
47
  as?: ElementType
29
- size?: 'xxs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'
48
+ size?: 'xxs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl'
49
+ color?: 'white' | 'black' | 'primary' | 'lightGray' | 'darkGray'
50
+ style?: CSSProperties
30
51
  }
@@ -1,21 +1,29 @@
1
- import type { ReactNode } from 'react'
1
+ import { forwardRef, ElementRef, type ReactNode } from 'react'
2
2
  import { TextAreaUI, type TextAreaUIProps } from './styles'
3
3
 
4
- interface TextAreaProps {
5
- children?: ReactNode
4
+ interface TextAreaProps extends TextAreaUIProps {
5
+ id: string
6
6
  placeholder?: string
7
7
  disabled?: boolean
8
+ children?: ReactNode
8
9
  }
9
10
 
10
- export function TextArea({
11
- children,
12
- ...props
13
- }: TextAreaUIProps & TextAreaProps) {
11
+ export const TextArea = forwardRef<
12
+ ElementRef<typeof TextAreaUI>,
13
+ TextAreaProps
14
+ >(({ id, disabled, placeholder, children, ...props }: TextAreaProps, ref) => {
14
15
  return (
15
- <TextAreaUI rows={3} {...props}>
16
+ <TextAreaUI
17
+ ref={ref}
18
+ rows={3}
19
+ id={id}
20
+ placeholder={placeholder}
21
+ disabled={disabled}
22
+ {...props}
23
+ >
16
24
  {children}
17
25
  </TextAreaUI>
18
26
  )
19
- }
27
+ })
20
28
 
21
29
  TextArea.displayName = 'TextArea'