@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,98 +1,85 @@
1
- import styled from 'styled-components'
2
- import {TextFieldSizeType} from './TextField.sizes'
3
- import {fontSize, fontWeight, lineHeight, spacing} from '@liguelead/foundation'
4
- import {StateInterface} from './TextField.states'
5
- import {parseColor} from '../../utils'
6
-
7
- interface StyledInputProps {
8
- size: TextFieldSizeType
9
- $themefication: StateInterface
10
- }
11
-
12
- export const InputWrapper = styled.div`
13
- position: relative;
14
- width: 100%;
15
- `
16
-
17
- export const FloatingLabel = styled.label`
18
- position: absolute;
19
- top: 50%;
20
- left: 12px;
21
- transform: translateY(-50%);
22
- font-weight: ${fontWeight.fontWeight600};
23
- transition: all 0.2s ease;
24
- pointer-events: none;
25
- background-color: white;
26
- padding: 0 4px;
27
- `
28
-
29
- export const HelperText = styled.span<{error?: boolean}>`
30
- font-size: ${fontSize.fontSize12}px;
31
- line-height: ${lineHeight.lineHeight12}px;
32
- padding-left: ${spacing.spacing16}px;
33
- `
34
-
35
- export const IconWrapper = styled.div<{$right?: boolean}>`
36
- display: flex;
37
- align-items: center;
38
- justify-content: space-between;
39
- position: absolute;
40
- top: 0px;
41
- height: 100%;
42
- cursor: pointer;
43
- ${({$right}) => ($right ? 'right: 0px;' : 'left: 0px;')}
44
- padding: 0px ${spacing.spacing16}px;
45
-
46
- & svg {
47
- width: 20px;
48
- height: 20px;
49
- fill: ${({theme}) => parseColor(theme.colors.neutral700)};
50
- transition: fill 0.2s ease;
51
- }
52
- `
53
-
54
- export const StyledInput = styled.input.withConfig({
55
- shouldForwardProp: prop => !['control', 'errors', 'rules'].includes(prop)
56
- })`
57
- width: 100%;
58
- border-radius: 4px;
59
- outline: none;
60
- transition: border-color 0.2s ease;
61
- background: transparent;
62
- `
63
-
64
- export const BorderWrapper = styled.div`
65
- position: absolute;
66
- top: 0;
67
- left: 0;
68
- right: 0;
69
- bottom: 0;
70
- pointer-events: none;
71
- border: 2px solid #ccc;
72
- border-radius: 4px;
73
- background-color: transparent;
74
- z-index: -1;
75
-
76
- ${StyledInput}:focus ~ & {
77
- border-color: ${({theme}) => theme.colors.primary};
78
- }
79
- `
80
-
81
- export const Wrapper = styled.div<StyledInputProps>`
82
- position: relative;
83
- width: 100%;
84
- ${({$themefication, size}) => `
85
- ${StyledInput} {
86
- ${$themefication.animation}
87
- ${$themefication.input}
88
- ${size.input}
89
- }
90
- ${FloatingLabel} {
91
- ${$themefication.label}
92
- ${size.label}
93
- }
94
- ${HelperText} {
95
- ${$themefication.label}
96
- }
97
- `}
98
- `
1
+ import styled from 'styled-components'
2
+ import { TextFieldSizeType } from './TextField.sizes'
3
+ import {
4
+ fontSize,
5
+ fontWeight,
6
+ lineHeight,
7
+ spacing
8
+ } from '@liguelead/foundation'
9
+ import { StateInterface } from './TextField.states'
10
+ import { parseColor } from '../../utils'
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 Label = styled.label`
23
+ display: block;
24
+ font-weight: ${fontWeight.fontWeight600};
25
+ margin-bottom: ${spacing.spacing4}px;
26
+ font-size: ${fontSize.fontSize14}px;
27
+ `
28
+
29
+ export const HelperText = styled.span<{ error?: boolean }>`
30
+ font-size: ${fontSize.fontSize12}px;
31
+ line-height: ${lineHeight.lineHeight16}px;
32
+ `
33
+
34
+ export const IconWrapper = styled.div<{ $right?: boolean }>`
35
+ display: flex;
36
+ align-items: center;
37
+ justify-content: space-between;
38
+ position: absolute;
39
+ top: 0px;
40
+ height: 100%;
41
+ cursor: pointer;
42
+ ${({ $right }) => ($right ? 'right: 0px;' : 'left: 0px;')}
43
+ padding: 0px ${spacing.spacing16}px;
44
+
45
+ & svg {
46
+ width: 20px;
47
+ height: 20px;
48
+ fill: ${({ theme }) => parseColor(theme.colors.neutral700)};
49
+ transition: fill 0.2s ease;
50
+ }
51
+ `
52
+
53
+ export const StyledInput = styled.input.withConfig({
54
+ shouldForwardProp: prop => !['control', 'errors', 'rules'].includes(prop)
55
+ })`
56
+ width: 100%;
57
+ border-radius: 4px;
58
+ outline: none;
59
+ border: 1px solid #CFCFD1;
60
+ transition: border-color 0.2s ease;
61
+ background: transparent;
62
+ `
63
+
64
+
65
+ export const Wrapper = styled.div<StyledInputProps>`
66
+ position: relative;
67
+ width: 100%;
68
+ ${({ $themefication, size }) => `
69
+ ${StyledInput} {
70
+ ${$themefication.input}
71
+ ${size.input}
72
+ }
73
+ ${Label} {
74
+ ${$themefication.label}
75
+ ${size.label}
76
+ }
77
+ ${HelperText} {
78
+ ${$themefication.label}
79
+ }
80
+ `}
81
+ `
82
+
83
+ export const RequiredAsterisk = styled.span`
84
+ color: ${({ theme }) => parseColor(theme.colors.primary)};
85
+ `
@@ -1,108 +1,108 @@
1
- import React, { forwardRef, useState } from 'react'
2
- import { TextFieldProps } from './TextField.types'
3
- import { StateInterface, TextFieldStates } from './TextField.states'
4
- import {
5
- FloatingLabel,
6
- HelperText,
7
- IconWrapper,
8
- InputWrapper,
9
- StyledInput,
10
- Wrapper
11
- } from './TextField.styles'
12
- import { textFieldSizes } from './TextField.sizes'
13
- import { Eye, EyeClosed } from '@phosphor-icons/react'
14
-
15
- export const getState = (disabled: boolean, error: boolean) => {
16
- if (disabled) return 'disabled'
17
- if (error) return 'error'
18
- return 'default'
19
- }
20
-
21
- const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
22
- (
23
- {
24
- className,
25
- disabled = false,
26
- error,
27
- handleLeftIcon,
28
- handleRightIcon,
29
- helperText,
30
- label,
31
- leftIcon,
32
- onChange,
33
- rightIcon,
34
- size = 'md',
35
- type = 'text',
36
- value,
37
- register,
38
- ...props
39
- },
40
- ref // A ref passada pelo componente pai
41
- ) => {
42
- const [passwordVisible, setPasswordVisible] = useState(
43
- type !== 'password'
44
- )
45
- const state = getState(disabled, !!error)
46
- const textFieldState: StateInterface = TextFieldStates(state)
47
- const textFieldSize = textFieldSizes(size, !!leftIcon, !!rightIcon)
48
-
49
- const togglePasswordVisibility = () => {
50
- setPasswordVisible(!passwordVisible)
51
- }
52
-
53
- const transformRightIcon = (
54
- type: string,
55
- rightIcon: React.ReactNode
56
- ) => {
57
- if (type === 'password') {
58
- return (
59
- <IconWrapper onClick={togglePasswordVisibility} $right>
60
- {passwordVisible ? <Eye /> : <EyeClosed />}
61
- </IconWrapper>
62
- )
63
- }
64
- return (
65
- <IconWrapper onClick={handleRightIcon} $right>
66
- {rightIcon}
67
- </IconWrapper>
68
- )
69
- }
70
-
71
- return (
72
- <Wrapper
73
- className={className}
74
- size={textFieldSize}
75
- $themefication={textFieldState}>
76
- <InputWrapper>
77
- {leftIcon && (
78
- <IconWrapper onClick={handleLeftIcon}>
79
- {leftIcon}
80
- </IconWrapper>
81
- )}
82
- {transformRightIcon(type, rightIcon)}
83
- <StyledInput
84
- ref={ref}
85
- type={passwordVisible ? 'text' : 'password'}
86
- value={value}
87
- placeholder=" "
88
- disabled={disabled}
89
- {...props}
90
- {...register}
91
- onChange={e => {
92
- register?.onChange(e)
93
- onChange?.(e)
94
- }}
95
- />
96
- <FloatingLabel>{label}</FloatingLabel>
97
- </InputWrapper>
98
- {(helperText || error) && (
99
- <HelperText>{error?.message || helperText}</HelperText>
100
- )}
101
- </Wrapper>
102
- )
103
- }
104
- )
105
-
106
- TextField.displayName = 'TextField'
107
-
108
- export default TextField
1
+ import React, { forwardRef, useState } from 'react'
2
+ import { TextFieldProps } from './TextField.types'
3
+ import { StateInterface, TextFieldStates } from './TextField.states'
4
+ import {
5
+ Label,
6
+ HelperText,
7
+ IconWrapper,
8
+ InputWrapper,
9
+ StyledInput,
10
+ Wrapper,
11
+ RequiredAsterisk
12
+ } from './TextField.styles'
13
+ import { textFieldSizes } from './TextField.sizes'
14
+ import { Eye, EyeClosed } from '@phosphor-icons/react'
15
+ import getState from './utils/getState'
16
+
17
+ const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
18
+ (
19
+ {
20
+ className,
21
+ disabled = false,
22
+ error,
23
+ handleLeftIcon,
24
+ handleRightIcon,
25
+ helperText,
26
+ label,
27
+ leftIcon,
28
+ onChange,
29
+ rightIcon,
30
+ size = 'md',
31
+ type = 'text',
32
+ value,
33
+ register,
34
+ placeholder,
35
+ ...props
36
+ },
37
+ ref
38
+ ) => {
39
+ const [passwordVisible, setPasswordVisible] = useState(
40
+ type !== 'password'
41
+ )
42
+ const state = getState(disabled, !!error)
43
+ const textFieldState: StateInterface = TextFieldStates(state)
44
+ const textFieldSize = textFieldSizes(size, !!leftIcon, !!rightIcon)
45
+
46
+ const togglePasswordVisibility = () => {
47
+ setPasswordVisible(!passwordVisible)
48
+ }
49
+
50
+ const transformRightIcon = (
51
+ type: string,
52
+ rightIcon: React.ReactNode
53
+ ) => {
54
+ if (type === 'password') {
55
+ return (
56
+ <IconWrapper onClick={togglePasswordVisibility} $right>
57
+ {passwordVisible ? <Eye /> : <EyeClosed />}
58
+ </IconWrapper>
59
+ )
60
+ }
61
+ return (
62
+ <IconWrapper onClick={handleRightIcon} $right>
63
+ {rightIcon}
64
+ </IconWrapper>
65
+ )
66
+ }
67
+
68
+ return (
69
+ <Wrapper
70
+ className={className}
71
+ size={textFieldSize}
72
+ $themefication={textFieldState}
73
+ >
74
+ <Label>
75
+ {label} {props.required && <RequiredAsterisk>*</RequiredAsterisk>}
76
+ </Label>
77
+ <InputWrapper>
78
+ {leftIcon && (
79
+ <IconWrapper onClick={handleLeftIcon}>
80
+ {leftIcon}
81
+ </IconWrapper>
82
+ )}
83
+ {transformRightIcon(type, rightIcon)}
84
+ <StyledInput
85
+ ref={ref}
86
+ type={passwordVisible ? 'text' : 'password'}
87
+ value={value}
88
+ disabled={disabled}
89
+ placeholder={placeholder}
90
+ {...props}
91
+ {...register}
92
+ onChange={e => {
93
+ register?.onChange(e)
94
+ onChange?.(e)
95
+ }}
96
+ />
97
+ </InputWrapper>
98
+ {(helperText || error) && (
99
+ <HelperText>{error?.message || helperText}</HelperText>
100
+ )}
101
+ </Wrapper>
102
+ )
103
+ }
104
+ )
105
+
106
+ TextField.displayName = 'TextField'
107
+
108
+ export default TextField
@@ -1,21 +1,22 @@
1
- import { FieldValues, UseFormRegisterReturn } from 'react-hook-form'
2
- import { TextFieldSize } from './TextField.sizes'
3
- import React from 'react'
4
-
5
- export interface TextFieldProps<TFieldValues extends FieldValues = FieldValues>
6
- extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'> {
7
- label: string
8
- value?: string
9
- onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void
10
- handleLeftIcon?: () => void
11
- handleRightIcon?: () => void
12
- helperText?: string
13
- size?: TextFieldSize
14
- className?: string
15
- disabled?: boolean
16
- leftIcon?: React.ReactNode
17
- rightIcon?: React.ReactNode
18
- error?: TFieldValues
19
- type?: 'text' | 'password' | 'email' | 'number'
20
- register?: UseFormRegisterReturn<string>
21
- }
1
+ import { FieldValues, UseFormRegisterReturn } from 'react-hook-form'
2
+ import { TextFieldSize } from './TextField.sizes'
3
+ import React from 'react'
4
+
5
+ export interface TextFieldProps<TFieldValues extends FieldValues = FieldValues>
6
+ extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'> {
7
+ label: string
8
+ value?: string
9
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void
10
+ handleLeftIcon?: () => void
11
+ handleRightIcon?: () => void
12
+ helperText?: string
13
+ size?: TextFieldSize
14
+ className?: string
15
+ placeholder?: string
16
+ disabled?: boolean
17
+ leftIcon?: React.ReactNode
18
+ rightIcon?: React.ReactNode
19
+ error?: TFieldValues
20
+ type?: 'text' | 'password' | 'email' | 'number'
21
+ register?: UseFormRegisterReturn<string>
22
+ }
@@ -1,2 +1,2 @@
1
- export { default } from './TextField'
2
- export type { TextFieldProps } from './TextField.types'
1
+ export { default } from './TextField'
2
+ export type { TextFieldProps } from './TextField.types'
@@ -0,0 +1,7 @@
1
+ const getState = (disabled: boolean, error: boolean) => {
2
+ if (disabled) return 'disabled'
3
+ if (error) return 'error'
4
+ return 'default'
5
+ }
6
+
7
+ export default getState
@@ -1,21 +1,21 @@
1
- import { ThemeProvider as StyledTheme } from 'styled-components'
2
- import { themes } from '@liguelead/foundation'
3
- import { globalStyle as Reset } from './style'
4
-
5
- interface ThemeProviderProps {
6
- children: React.ReactNode
7
- theme?: 'spa'
8
- }
9
-
10
- const ThemeProvider = ({ children, theme }: ThemeProviderProps) => {
11
- const appliedTheme = theme ? themes[theme] : themes['spa']
12
-
13
- return (
14
- <StyledTheme theme={appliedTheme}>
15
- <Reset />
16
- {children}
17
- </StyledTheme>
18
- )
19
- }
20
-
21
- export default ThemeProvider
1
+ import { ThemeProvider as StyledTheme } from 'styled-components'
2
+ import { themes } from '@liguelead/foundation'
3
+ import { globalStyle as Reset } from './style'
4
+
5
+ interface ThemeProviderProps {
6
+ children: React.ReactNode
7
+ theme?: 'spa'
8
+ }
9
+
10
+ const ThemeProvider = ({ children, theme }: ThemeProviderProps) => {
11
+ const appliedTheme = theme ? themes[theme] : themes['spa']
12
+
13
+ return (
14
+ <StyledTheme theme={appliedTheme}>
15
+ <Reset />
16
+ {children}
17
+ </StyledTheme>
18
+ )
19
+ }
20
+
21
+ export default ThemeProvider
@@ -1 +1 @@
1
- export { default } from './ThemeProvider'
1
+ export { default } from './ThemeProvider'