@liguelead/design-system 0.0.9 → 0.0.11

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 (76) hide show
  1. package/components/Button/Button.appearance.ts +66 -62
  2. package/components/Button/Button.sizes.ts +42 -41
  3. package/components/Button/Button.styles.ts +46 -50
  4. package/components/Button/Button.tsx +76 -76
  5. package/components/Button/Button.types.ts +23 -23
  6. package/components/Button/index.ts +1 -1
  7. package/components/Checkbox/Checkbox.styles.ts +115 -66
  8. package/components/Checkbox/Checkbox.tsx +97 -40
  9. package/components/Checkbox/Checkbox.types.ts +12 -11
  10. package/components/Checkbox/index.tsx +2 -2
  11. package/components/DatePicker/DatePicker.styles.ts +66 -66
  12. package/components/DatePicker/DatePicker.tsx +135 -135
  13. package/components/DatePicker/DatePicker.types.ts +29 -29
  14. package/components/DatePicker/index.ts +1 -1
  15. package/components/IconButton/IconButton.sizes.ts +34 -41
  16. package/components/IconButton/IconButton.tsx +70 -70
  17. package/components/IconButton/index.ts +1 -1
  18. package/components/InputOpt/InputOpt.styles.ts +75 -0
  19. package/components/InputOpt/InputOpt.tsx +153 -0
  20. package/components/InputOpt/InputOpt.types.ts +14 -0
  21. package/components/InputOpt/index.ts +1 -0
  22. package/components/InputOpt/utils/focusManagement.ts +31 -0
  23. package/components/InputOpt/utils/index.ts +2 -0
  24. package/components/InputOpt/utils/inputValidation.ts +14 -0
  25. package/components/LinkButton/LinkButton.size.ts +39 -0
  26. package/components/LinkButton/LinkButton.style.ts +45 -0
  27. package/components/LinkButton/LinkButton.tsx +75 -0
  28. package/components/LinkButton/LinkButton.types.ts +11 -0
  29. package/components/LinkButton/index.ts +1 -0
  30. package/components/PageWrapper/PageWrapper.tsx +31 -31
  31. package/components/PageWrapper/index.ts +1 -1
  32. package/components/RadioButton/RadioButton.inputVariants.ts +133 -0
  33. package/components/RadioButton/RadioButton.styles.ts +78 -0
  34. package/components/RadioButton/RadioButton.tsx +88 -0
  35. package/components/RadioButton/RadioButton.types.ts +33 -0
  36. package/components/RadioButton/RadioButton.variants.ts +67 -0
  37. package/components/RadioButton/index.ts +1 -0
  38. package/components/SegmentedButton/SegmentedButton.styles.ts +29 -29
  39. package/components/SegmentedButton/SegmentedButton.tsx +43 -49
  40. package/components/SegmentedButton/SegmentedButton.types.ts +20 -20
  41. package/components/SegmentedButton/index.ts +1 -1
  42. package/components/Select/Select.sizes.ts +55 -56
  43. package/components/Select/Select.states.tsx +40 -69
  44. package/components/Select/Select.styles.ts +162 -148
  45. package/components/Select/Select.tsx +152 -144
  46. package/components/Select/Select.types.ts +35 -36
  47. package/components/Select/index.ts +1 -1
  48. package/components/Text/Text.styles.ts +46 -43
  49. package/components/Text/Text.tsx +27 -27
  50. package/components/Text/Text.types.ts +44 -42
  51. package/components/Text/index.ts +1 -1
  52. package/components/TextField/TextField.sizes.ts +52 -58
  53. package/components/TextField/TextField.states.tsx +53 -76
  54. package/components/TextField/TextField.styles.ts +85 -98
  55. package/components/TextField/TextField.tsx +108 -108
  56. package/components/TextField/TextField.types.ts +22 -21
  57. package/components/TextField/index.ts +2 -2
  58. package/components/TextField/utils/getState.ts +7 -0
  59. package/components/ThemeProvider/ThemeProvider.tsx +21 -21
  60. package/components/ThemeProvider/index.ts +1 -1
  61. package/components/ThemeProvider/style.ts +969 -969
  62. package/components/Wizard/StepContent.tsx +28 -28
  63. package/components/Wizard/StepMenuItem.tsx +33 -33
  64. package/components/Wizard/Wizard.context.tsx +76 -76
  65. package/components/Wizard/Wizard.styles.ts +126 -126
  66. package/components/Wizard/Wizard.tsx +55 -55
  67. package/components/Wizard/index.ts +1 -1
  68. package/components/index.ts +14 -11
  69. package/package.json +41 -41
  70. package/scripts/createTypes.js +70 -70
  71. package/utils/colorDarken.ts +10 -10
  72. package/utils/colorLighten.ts +10 -10
  73. package/utils/darkenOrLighen.ts +19 -19
  74. package/utils/getTextColor.ts +12 -12
  75. package/utils/index.ts +5 -5
  76. package/utils/parseColor.ts +7 -7
@@ -1,148 +1,162 @@
1
- import styled from 'styled-components'
2
- import { TextFieldSizeType, StateInterface } from './Select.types'
3
- import {
4
- fontSize,
5
- fontWeight,
6
- lineHeight,
7
- spacing
8
- } from '@liguelead/foundation'
9
- import { parseColor } from '../../utils'
10
- import { Content, Item } from '@radix-ui/react-select'
11
-
12
- interface StyledInputProps {
13
- size: TextFieldSizeType
14
- $themefication: StateInterface
15
- }
16
-
17
- export const InputWrapper = styled.div`
18
- position: relative;
19
- width: 100%;
20
- `
21
-
22
- export const FloatingLabel = styled.label`
23
- position: absolute;
24
- top: 50%;
25
- left: 12px;
26
- transform: translateY(-50%);
27
- font-weight: ${fontWeight.fontWeight600};
28
- transition: all 0.2s ease;
29
- pointer-events: none;
30
- background-color: white;
31
- padding: 0 4px;
32
- &.is-open {
33
- color: ${({ theme }) => parseColor(theme.colors.primary)} !important;
34
- }
35
- `
36
-
37
- export const HelperText = styled.span<{ error?: boolean }>`
38
- font-size: ${fontSize.fontSize12}px;
39
- line-height: ${lineHeight.lineHeight12}px;
40
- padding-left: ${spacing.spacing16}px;
41
- `
42
-
43
- export const IconWrapper = styled.div<{ $right?: boolean; $error?: boolean }>`
44
- display: flex;
45
- align-items: center;
46
- justify-content: space-between;
47
- position: absolute;
48
- top: 0px;
49
- height: 100%;
50
- cursor: pointer;
51
- ${({ $right }) => ($right ? 'right: 0px;' : 'left: 0px;')}
52
- padding: 0px ${spacing.spacing16}px;
53
-
54
- & svg {
55
- width: 20px;
56
- height: 20px;
57
- fill: ${({ theme, $error }) =>
58
- $error
59
- ? parseColor(theme.colors.danger100)
60
- : parseColor(theme.colors.neutral700)};
61
- transition: fill 0.2s ease;
62
- }
63
- `
64
-
65
- export const StyledContent = styled(Content)`
66
- padding: 0px;
67
- background-color: #fff;
68
- min-width: var(--radix-select-trigger-width, auto);
69
- width: 100%;
70
- box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
71
- border: 1px solid ${({ theme }) => parseColor(theme.colors.neutral500)};
72
- border-top: 0px;
73
- max-height: var(--radix-select-content-height, 314px);
74
- overflow-y: scroll !important;
75
- z-index: 10;
76
- & .RadixSelectViewport {
77
- max-height: 200px; /* Limite de altura do dropdown */
78
- overflow-y: auto; /* Adiciona o scroll quando necessário */
79
- scrollbar-width: thin; /* Personaliza a largura do scroll (opcional) */
80
- }
81
- `
82
-
83
- export const StyledItem = styled(Item)`
84
- padding: ${spacing.spacing12}px ${spacing.spacing20}px;
85
- display: flex;
86
- align-items: center;
87
- gap: 8px;
88
- transition: all 0.2s ease;
89
- cursor: pointer;
90
- &:hover {
91
- background-color: ${({ theme }) => parseColor(theme.colors.neutral200)};
92
- }
93
- &[data-state='checked'] {
94
- background-color: ${({ theme }) =>
95
- parseColor(theme.colors.primaryLight)};
96
- }
97
- `
98
-
99
- export const StyledInput = styled.input.withConfig({
100
- shouldForwardProp: prop => !['control', 'errors', 'rules'].includes(prop)
101
- })`
102
- width: 100%;
103
- border-radius: 4px;
104
- outline: none;
105
- transition: border-color 0.2s ease;
106
- background: transparent;
107
- &.is-open {
108
- border-color: ${({ theme }) =>
109
- parseColor(theme.colors.primary)} !important;
110
- }
111
- `
112
-
113
- export const BorderWrapper = styled.div`
114
- position: absolute;
115
- top: 0;
116
- left: 0;
117
- right: 0;
118
- bottom: 0;
119
- pointer-events: none;
120
- border: 2px solid #ccc;
121
- border-radius: 4px;
122
- background-color: transparent;
123
- z-index: -1;
124
-
125
- ${StyledInput}:focus ~ & {
126
- border-color: ${({ theme }) => theme.colors.primary};
127
- }
128
- `
129
-
130
- export const Wrapper = styled.div<StyledInputProps>`
131
- position: relative;
132
- width: 100%;
133
- cursor: pointer;
134
- ${({ $themefication, size }) => `
135
- ${StyledInput} {
136
- ${$themefication.animation}
137
- ${$themefication.input}
138
- ${size.input}
139
- }
140
- ${FloatingLabel} {
141
- ${$themefication.label}
142
- ${size.label}
143
- }
144
- ${HelperText} {
145
- ${$themefication.label}
146
- }
147
- `}
148
- `
1
+ import styled from 'styled-components'
2
+ import { TextFieldSizeType, StateInterface } from './Select.types'
3
+ import {
4
+ fontSize,
5
+ fontWeight,
6
+ lineHeight,
7
+ spacing,
8
+ shadow
9
+ } from '@liguelead/foundation'
10
+ import { parseColor } from '../../utils'
11
+ import { Content, Item } from '@radix-ui/react-select'
12
+
13
+ interface StyledInputProps {
14
+ size: TextFieldSizeType
15
+ $themefication: StateInterface
16
+ }
17
+
18
+ export const InputWrapper = styled.div`
19
+ position: relative;
20
+ width: 100%;
21
+ `
22
+
23
+ export const Label = styled.label`
24
+ display: block;
25
+ font-weight: ${fontWeight.fontWeight600};
26
+ margin-bottom: ${spacing.spacing4}px;
27
+ font-size: ${fontSize.fontSize14}px;
28
+ `
29
+
30
+ export const HelperText = styled.span<{ error?: boolean }>`
31
+ font-size: ${fontSize.fontSize12}px;
32
+ line-height: ${lineHeight.lineHeight12}px;
33
+ `
34
+
35
+ export const IconWrapper = styled.div<{
36
+ $right?: boolean;
37
+ $error?: boolean;
38
+ $disabled?: boolean;
39
+ }>` ${({theme, $error, $disabled, $right }) =>`
40
+ display: flex;
41
+ align-items: center;
42
+ justify-content: space-between;
43
+ position: absolute;
44
+ top: 0px;
45
+ height: 100%;
46
+ cursor: pointer;
47
+ ${$right ? 'right: 0px;' : 'left: 0px;'}
48
+ padding: 0px ${spacing.spacing16}px;
49
+
50
+ & svg {
51
+ width: 16px;
52
+ height: 16px;
53
+ fill: ${$error
54
+ ? parseColor(theme.colors.danger200)
55
+ : $disabled
56
+ ? parseColor(theme.colors.neutral400)
57
+ : parseColor(theme.colors.neutral800)};
58
+ transition: fill 0.2s ease;
59
+ cursor: ${$disabled ? 'not-allowed' : 'pointer'};
60
+ }
61
+ `}
62
+ `
63
+
64
+ export const StyledContent = styled(Content)`
65
+ padding: 0px;
66
+ background-color: #fff;
67
+ min-width: var(--radix-select-trigger-width, auto);
68
+ width: 100%;
69
+ box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
70
+ border: 1px solid ${({ theme }) => parseColor(theme.colors.neutral500)};
71
+ border-top: 0px;
72
+ max-height: var(--radix-select-content-height, 314px);
73
+ overflow-y: scroll !important;
74
+ z-index: 10;
75
+
76
+ & .RadixSelectViewport {
77
+ max-height: 200px; /* Limite de altura do dropdown */
78
+ overflow-y: auto; /* Adiciona o scroll quando necessário */
79
+ scrollbar-width: thin; /* Personaliza a largura do scroll (opcional) */
80
+ }
81
+ `
82
+
83
+ export const StyledItem = styled(Item)`
84
+ padding: ${spacing.spacing12}px ${spacing.spacing20}px;
85
+ display: flex;
86
+ align-items: center;
87
+ justify-content: space-between;
88
+ gap: 8px; /* mantém espaçamento interno caso adicionemos ícones à esquerda futuramente */
89
+ transition: all 0.2s ease;
90
+ cursor: pointer;
91
+
92
+ &:hover {
93
+ background-color: ${({ theme }) => parseColor(theme.colors.primaryLight)};
94
+ }
95
+
96
+ &[data-state='checked'] {
97
+ background-color: ${({ theme }) =>
98
+ parseColor(theme.colors.primary)};
99
+ color: ${({ theme }) => parseColor(theme.colors.white)};
100
+ }
101
+ `
102
+
103
+ export const StyledInput = styled.input.withConfig({
104
+ shouldForwardProp: prop => !['control', 'errors', 'rules'].includes(prop)
105
+ })`
106
+ width: 100%;
107
+ border-radius: 4px;
108
+ outline: none;
109
+ transition: border-color 0.2s ease;
110
+ background: transparent;
111
+ cursor: pointer;
112
+
113
+ &:focus {
114
+ box-shadow: ${shadow.focusShadow}
115
+ }
116
+
117
+ &.is-open {
118
+ border-color: ${({ theme }) =>
119
+ parseColor(theme.colors.neutral800)} !important;
120
+ box-shadow: ${shadow.focusShadow}
121
+ }
122
+
123
+ &:disabled {
124
+ cursor: not-allowed;
125
+ }
126
+ `
127
+
128
+ export const BorderWrapper = styled.div`
129
+ position: absolute;
130
+ top: 0;
131
+ left: 0;
132
+ right: 0;
133
+ bottom: 0;
134
+ pointer-events: none;
135
+ border: 2px solid #ccc;
136
+ border-radius: 4px;
137
+ background-color: transparent;
138
+ z-index: -1;
139
+
140
+ ${StyledInput}:focus ~ & {
141
+ border-color: ${({ theme }) => theme.colors.primary};
142
+ }
143
+ `
144
+
145
+ export const Wrapper = styled.div<StyledInputProps>`
146
+ position: relative;
147
+ width: 100%;
148
+ cursor: pointer;
149
+ ${({ $themefication, size }) => `
150
+ ${StyledInput} {
151
+ ${$themefication.input}
152
+ ${size.input}
153
+ }
154
+ ${HelperText} {
155
+ ${$themefication.helperText}
156
+ }
157
+ ${Label} {
158
+ ${$themefication.label}
159
+ ${size.label}
160
+ }
161
+ `}
162
+ `
@@ -1,144 +1,152 @@
1
- import { forwardRef, useState } from 'react'
2
- import * as RadixSelect from '@radix-ui/react-select'
3
- import { CaretDown, Plus } from '@phosphor-icons/react'
4
- import {
5
- FloatingLabel,
6
- HelperText,
7
- IconWrapper,
8
- InputWrapper,
9
- StyledContent,
10
- StyledInput,
11
- StyledItem,
12
- Wrapper
13
- } from './Select.styles'
14
- import { SelectStates } from './Select.states'
15
- import { textFieldSizes } from './Select.sizes'
16
- import TextField, { getState } from '../TextField/TextField'
17
- import { SelectProps, StateInterface } from './Select.types'
18
-
19
- const Select = forwardRef<HTMLInputElement, SelectProps>(
20
- (
21
- {
22
- label,
23
- defaultValue,
24
- error,
25
- helperText,
26
- leftIcon,
27
- size = 'md',
28
- options,
29
- className,
30
- disabled = false,
31
- handleLeftIcon,
32
- register
33
- },
34
- ref
35
- ) => {
36
- const [selectValue, setSelectValue] = useState(
37
- defaultValue ?? options[0]?.value
38
- )
39
- const [open, setOpen] = useState(false)
40
-
41
- const handleOnChange = (value: string) => {
42
- if (value) {
43
- setSelectValue(value)
44
- register?.onChange({
45
- target: {
46
- name: register.name,
47
- value
48
- }
49
- })
50
- }
51
- }
52
-
53
- const state = getState(disabled, !!error)
54
- const textFieldState: StateInterface = SelectStates(state)
55
- const textFieldSize = textFieldSizes(size, !!leftIcon, false)
56
- const selectedLabel =
57
- options.find(option => option.value === selectValue)?.label ?? ''
58
-
59
- return (
60
- <Wrapper
61
- className={className}
62
- size={textFieldSize}
63
- $themefication={textFieldState}>
64
- <input
65
- type="hidden"
66
- value={selectValue}
67
- ref={instance => {
68
- if (typeof ref === 'function') {
69
- ref(instance)
70
- } else if (ref) {
71
- ref.current = instance
72
- }
73
- register?.ref(instance)
74
- }}
75
- onChange={register?.onChange}
76
- onBlur={register?.onBlur}
77
- />
78
- {!disabled ? (
79
- <RadixSelect.Root
80
- value={selectValue}
81
- onOpenChange={open => setOpen(open)}
82
- defaultValue={defaultValue}
83
- onValueChange={(value: string) =>
84
- handleOnChange(value)
85
- }>
86
- <RadixSelect.Trigger asChild>
87
- <InputWrapper>
88
- {leftIcon && (
89
- <IconWrapper onClick={handleLeftIcon}>
90
- {leftIcon}
91
- </IconWrapper>
92
- )}
93
- <IconWrapper $right $error={!!error}>
94
- <CaretDown weight="fill" size={14} />
95
- </IconWrapper>
96
- <StyledInput
97
- readOnly
98
- style={{ cursor: 'pointer !important' }}
99
- value={selectedLabel}
100
- placeholder=" "
101
- className={open ? 'is-open' : ''}
102
- />
103
- <FloatingLabel
104
- className={open ? 'is-open' : ''}>
105
- {label}
106
- </FloatingLabel>
107
- </InputWrapper>
108
- </RadixSelect.Trigger>
109
- <StyledContent
110
- asChild
111
- sideOffset={0}
112
- position="popper"
113
- align="start"
114
- className="RadixSelectContent">
115
- <RadixSelect.Viewport className="RadixSelectViewport">
116
- {options.map(option => (
117
- <StyledItem
118
- key={option.value}
119
- value={option.value}>
120
- <Plus width={20} />
121
- {option.label}
122
- </StyledItem>
123
- ))}
124
- </RadixSelect.Viewport>
125
- </StyledContent>
126
- </RadixSelect.Root>
127
- ) : (
128
- <TextField
129
- leftIcon={leftIcon}
130
- rightIcon={<CaretDown weight="fill" size={14} />}
131
- label={label}
132
- size={size}
133
- disabled
134
- />
135
- )}
136
- {(helperText || error) && (
137
- <HelperText>{error?.message || helperText}</HelperText>
138
- )}
139
- </Wrapper>
140
- )
141
- }
142
- )
143
-
144
- export default Select
1
+ import { forwardRef, useState } from 'react'
2
+ import * as RadixSelect from '@radix-ui/react-select'
3
+ import { CaretDownIcon, CheckIcon } from '@phosphor-icons/react'
4
+ import {
5
+ HelperText,
6
+ IconWrapper,
7
+ InputWrapper,
8
+ StyledContent,
9
+ StyledInput,
10
+ StyledItem,
11
+ Wrapper,
12
+ Label
13
+ } from './Select.styles'
14
+ import { SelectStates } from './Select.states'
15
+ import { textFieldSizes } from './Select.sizes'
16
+ import { SelectProps, StateInterface } from './Select.types'
17
+ import getState from '../TextField/utils/getState'
18
+
19
+ const Select = forwardRef<HTMLInputElement, SelectProps>(
20
+ (
21
+ {
22
+ label,
23
+ defaultValue,
24
+ error,
25
+ helperText,
26
+ leftIcon,
27
+ size = 'md',
28
+ options,
29
+ className,
30
+ disabled = false,
31
+ handleLeftIcon,
32
+ register
33
+ },
34
+ ref
35
+ ) => {
36
+ const [selectValue, setSelectValue] = useState(
37
+ defaultValue ?? options[0]?.value
38
+ )
39
+ const [open, setOpen] = useState(false)
40
+
41
+ const handleOnChange = (value: string) => {
42
+ if (value) {
43
+ setSelectValue(value)
44
+ register?.onChange({
45
+ target: {
46
+ name: register.name,
47
+ value
48
+ }
49
+ })
50
+ }
51
+ }
52
+
53
+ const state = getState(disabled, !!error)
54
+ const textFieldState: StateInterface = SelectStates(state)
55
+ const textFieldSize = textFieldSizes(size, !!leftIcon, false)
56
+ const selectedLabel =
57
+ options.find(option => option.value === selectValue)?.label ?? ''
58
+
59
+ return (
60
+ <Wrapper
61
+ className={className}
62
+ size={textFieldSize}
63
+ $themefication={textFieldState}>
64
+ <input
65
+ type="hidden"
66
+ value={selectValue}
67
+ ref={instance => {
68
+ if (typeof ref === 'function') {
69
+ ref(instance)
70
+ } else if (ref) {
71
+ ref.current = instance
72
+ }
73
+ register?.ref(instance)
74
+ }}
75
+ onChange={register?.onChange}
76
+ onBlur={register?.onBlur}
77
+ />
78
+ <Label>{label}</Label>
79
+ {disabled ? (
80
+ <InputWrapper className="is-disabled">
81
+ {leftIcon && (
82
+ <IconWrapper onClick={handleLeftIcon} $disabled={disabled}>
83
+ {leftIcon}
84
+ </IconWrapper>
85
+ )}
86
+ <IconWrapper $right $error={!!error} $disabled={disabled}>
87
+ <CaretDownIcon weight="fill" size={14} />
88
+ </IconWrapper>
89
+ <StyledInput
90
+ disabled
91
+ readOnly
92
+ value={selectedLabel}
93
+ className="is-disabled"
94
+ />
95
+ </InputWrapper>
96
+ ) : (
97
+ <RadixSelect.Root
98
+ value={selectValue}
99
+ onOpenChange={open => setOpen(open)}
100
+ defaultValue={defaultValue}
101
+ onValueChange={(value: string) =>
102
+ handleOnChange(value)
103
+ }>
104
+ <RadixSelect.Trigger asChild disabled={disabled}>
105
+ <InputWrapper>
106
+ {leftIcon && (
107
+ <IconWrapper onClick={handleLeftIcon}>
108
+ {leftIcon}
109
+ </IconWrapper>
110
+ )}
111
+ <IconWrapper $right $error={!!error}>
112
+ <CaretDownIcon weight="fill" size={14} />
113
+ </IconWrapper>
114
+ <StyledInput
115
+ readOnly
116
+ style={{ cursor: 'pointer !important' }}
117
+ value={selectedLabel}
118
+ className={open ? 'is-open' : ''}
119
+ />
120
+ </InputWrapper>
121
+ </RadixSelect.Trigger>
122
+ <StyledContent
123
+ asChild
124
+ sideOffset={0}
125
+ position="popper"
126
+ align="start"
127
+ className="RadixSelectContent">
128
+ <RadixSelect.Viewport className="RadixSelectViewport">
129
+ {options.map(option => (
130
+ <StyledItem
131
+ key={option.value}
132
+ value={option.value}
133
+ >
134
+ <span>{option.label}</span>
135
+ {option.value === selectValue && (
136
+ <CheckIcon weight="bold" />
137
+ )}
138
+ </StyledItem>
139
+ ))}
140
+ </RadixSelect.Viewport>
141
+ </StyledContent>
142
+ </RadixSelect.Root>
143
+ )}
144
+ {(helperText || error) && (
145
+ <HelperText>{error?.message || helperText}</HelperText>
146
+ )}
147
+ </Wrapper>
148
+ )
149
+ }
150
+ )
151
+
152
+ export default Select