@dafaz-ui/react 4.0.19 → 6.0.5

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.
@@ -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.6rem',
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,100 @@
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
 
21
- width: '100%',
22
- margin: 0,
23
- padding: '$1 $1',
24
+ '&:disabled': {
25
+ cursor: 'not-allowed',
26
+ opacity: 0.5,
27
+ },
24
28
 
25
- '&:focus': {
26
- outline: 0,
29
+ '&:active': {
30
+ borderBottom: '2px solid $dafaz400',
31
+ },
32
+
33
+ '&:hover': {
27
34
  borderBottom: '2px solid $dafaz400',
28
35
  },
29
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
+
86
+ width: '100%',
87
+ maxWidth: '24.5rem',
88
+
89
+ margin: 0,
90
+ padding: '$1 $1',
91
+
30
92
  '&:disabled': {
31
93
  opacity: 0.5,
32
- cursor: 'not-allowed',
94
+ },
95
+
96
+ '&:focus': {
97
+ outline: 0,
33
98
  },
34
99
 
35
100
  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'
@@ -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
 
4
4
  export const TextAreaUI = styled('textarea', {
@@ -8,6 +8,7 @@ export const TextAreaUI = styled('textarea', {
8
8
  fontWeight: '$regular',
9
9
  resize: 'vertical',
10
10
 
11
+ boxShadow: '0 3px 2px -2px $colors$gray400',
11
12
  border: '0.7px solid $gray400',
12
13
 
13
14
  margin: 0,
@@ -19,9 +20,11 @@ export const TextAreaUI = styled('textarea', {
19
20
  alignItems: 'baseline',
20
21
  width: '100%',
21
22
  padding: '$1 $2',
23
+ transition: 'border 0.2s linear',
22
24
 
23
25
  '&:focus': {
24
26
  outline: 0,
27
+ borderBottom: '2px solid $dafaz400',
25
28
  },
26
29
 
27
30
  '&:disabled': {
@@ -37,4 +40,6 @@ export const TextAreaUI = styled('textarea', {
37
40
  },
38
41
  })
39
42
 
40
- export interface TextAreaUIProps extends ComponentProps<typeof TextAreaUI> {}
43
+ export interface TextAreaUIProps extends ComponentProps<typeof TextAreaUI> {
44
+ style?: CSSProperties
45
+ }
@@ -4,16 +4,20 @@ import {
4
4
  ComponentProps,
5
5
  ElementRef,
6
6
  type ChangeEvent,
7
+ type CSSProperties,
7
8
  } from 'react'
8
9
  import { InputContainer, InputUI, Sufix } from './styles'
10
+ import { Eye, EyeSlash } from '@phosphor-icons/react'
9
11
 
10
12
  export interface TextInputProps extends ComponentProps<typeof InputUI> {
13
+ size?: 'lg' | 'md' | 'sm'
11
14
  required?: boolean
12
15
  requiredText?: string
13
16
  withShadow?: boolean
14
17
  placeholder?: string
15
- type?: string
16
- id: string
18
+ type?: React.HTMLInputTypeAttribute | undefined
19
+ style?: CSSProperties
20
+ id?: string
17
21
  }
18
22
 
19
23
  export const TextInput = forwardRef<ElementRef<typeof InputUI>, TextInputProps>(
@@ -23,11 +27,14 @@ export const TextInput = forwardRef<ElementRef<typeof InputUI>, TextInputProps>(
23
27
  required = true,
24
28
  requiredText = 'Opcional',
25
29
  id,
30
+ type = 'text',
31
+ size,
26
32
  ...props
27
33
  }: TextInputProps,
28
34
  ref,
29
35
  ) => {
30
36
  const [hiddenOptional, setHiddenOptional] = useState(required)
37
+ const [isPasswordVisible, setIsPasswordVisible] = useState(false)
31
38
 
32
39
  function handleOnChange(event: ChangeEvent<HTMLInputElement>) {
33
40
  if (!required) {
@@ -40,13 +47,40 @@ export const TextInput = forwardRef<ElementRef<typeof InputUI>, TextInputProps>(
40
47
  }
41
48
 
42
49
  return (
43
- <InputContainer withShadow={withShadow}>
44
- <InputUI id={id} ref={ref} onChange={handleOnChange} {...props} />
50
+ <InputContainer size={size} withShadow={withShadow}>
51
+ <InputUI
52
+ id={id}
53
+ ref={ref}
54
+ size={size}
55
+ onChange={handleOnChange}
56
+ type={!isPasswordVisible ? type : 'text'}
57
+ {...props}
58
+ />
45
59
  {!hiddenOptional && (
46
60
  <Sufix style={{ marginLeft: `-${requiredText.length / 2}rem` }}>
47
61
  {requiredText}
48
62
  </Sufix>
49
63
  )}
64
+ {type === 'password' && isPasswordVisible && (
65
+ <button
66
+ type="button"
67
+ onClick={() => {
68
+ setIsPasswordVisible(false)
69
+ }}
70
+ >
71
+ <EyeSlash size={24} />
72
+ </button>
73
+ )}
74
+ {type === 'password' && !isPasswordVisible && (
75
+ <button
76
+ type="button"
77
+ onClick={() => {
78
+ setIsPasswordVisible(true)
79
+ }}
80
+ >
81
+ <Eye size={24} />
82
+ </button>
83
+ )}
50
84
  </InputContainer>
51
85
  )
52
86
  },