@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,66 +1,115 @@
1
- import { spacing } from '@liguelead/foundation'
2
- import { parseColor } from '../../utils'
3
- import styled from 'styled-components'
4
-
5
- export const CheckboxWrapper = styled.label`
6
- display: flex;
7
- align-items: center;
8
- cursor: pointer;
9
- position: relative;
10
- user-select: none;
11
- gap: 8px;
12
- font-size: 14px;
13
-
14
- input {
15
- position: absolute;
16
- opacity: 0;
17
- width: 0;
18
- height: 0;
19
- }
20
- `
21
-
22
- export const CustomCheckbox = styled.span<{
23
- checked: boolean
24
- disabled?: boolean
25
- }>`
26
- width: ${spacing.spacing20}px;
27
- height: ${spacing.spacing20}px;
28
- border: 2px solid ${({ theme }) => parseColor(theme.colors.primary)};
29
- border-radius: 2px;
30
- display: flex;
31
- align-items: center;
32
- justify-content: center;
33
- transition: all 0.2s ease-in-out;
34
- background-color: ${({ checked, theme }) =>
35
- checked ? parseColor(theme.colors.primary) : 'transparent'};
36
-
37
- ${({ disabled, theme }) =>
38
- disabled &&
39
- `
40
- border-color: ${parseColor(theme.colors.neutral300)};
41
- background-color: ${parseColor(theme.colors.neutral100)};
42
- cursor: not-allowed;
43
- `}
44
-
45
- &::after {
46
- content: '';
47
- width: 16px;
48
- height: 16px;
49
- display: ${({ checked }) => (checked ? 'block' : 'none')};
50
- background-color: white;
51
-
52
- mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M9 16.2l-4.2-4.2-1.4 1.4 5.6 5.6L21 7.8l-1.4-1.4z'/%3E%3C/svg%3E")
53
- no-repeat center / contain;
54
- -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M9 16.2l-4.2-4.2-1.4 1.4 5.6 5.6L21 7.8l-1.4-1.4z'/%3E%3C/svg%3E")
55
- no-repeat center / contain;
56
- }
57
- `
58
-
59
- export const Label = styled.span<{ disabled?: boolean }>`
60
- font-size: 14px;
61
- font-weight: 500;
62
- color: ${({ theme, disabled }) =>
63
- disabled
64
- ? parseColor(theme.colors.neutral500)
65
- : parseColor(theme.colors.neutral900)};
66
- `
1
+ import {
2
+ spacing,
3
+ fontSize,
4
+ fontWeight,
5
+ radius
6
+ } from '@liguelead/foundation'
7
+ import { parseColor } from '../../utils'
8
+ import styled, { css } from 'styled-components'
9
+ import Text from '../Text'
10
+
11
+ export const CheckboxWrapper = styled.label`
12
+ display: flex;
13
+ align-items: start;
14
+ cursor: pointer;
15
+ position: relative;
16
+ user-select: none;
17
+ gap: 8px;
18
+ font-size: ${fontSize.fontSize14}px;
19
+
20
+ input {
21
+ position: absolute;
22
+ opacity: 0;
23
+ width: 0;
24
+ height: 0;
25
+ }
26
+
27
+ input:focus + span {
28
+ box-shadow: 0 0 0 3px #A3A3A350}
29
+ }
30
+ `
31
+
32
+ export const CustomCheckbox = styled.span<{
33
+ checked: boolean
34
+ disabled?: boolean
35
+ }>`
36
+ ${({ checked, theme, disabled }) => css`
37
+ width: ${spacing.spacing16}px;
38
+ height: ${spacing.spacing16}px;
39
+ border: 1px solid ${checked
40
+ ? parseColor(theme.colors.primary)
41
+ : parseColor(theme.colors.neutral400)};
42
+ border-radius: ${radius.radius4}px;
43
+ display: flex;
44
+ top: 2px;
45
+ align-items: center;
46
+ justify-content: center;
47
+ transition: all 0.2s ease-in-out;
48
+ background-color: ${checked
49
+ ? parseColor(theme.colors.primary)
50
+ : 'transparent'};
51
+ position: relative;
52
+ overflow: hidden;
53
+
54
+ ${disabled &&
55
+ css`
56
+ background-color: transparent;
57
+ border-color: ${parseColor(theme.colors.neutral400)}70;
58
+ cursor: not-allowed;
59
+ `}
60
+
61
+ &::after {
62
+ content: '';
63
+ width: 16px;
64
+ height: 16px;
65
+ display: ${checked ? 'block' : 'none'};
66
+ background-color: white;
67
+ z-index: 1;
68
+
69
+ mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M9 16.2l-4.2-4.2-1.4 1.4 5.6 5.6L21 7.8l-1.4-1.4z'/%3E%3C/svg%3E")
70
+ no-repeat center / contain;
71
+ -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M9 16.2l-4.2-4.2-1.4 1.4 5.6 5.6L21 7.8l-1.4-1.4z'/%3E%3C/svg%3E")
72
+ no-repeat center / contain;
73
+ }
74
+
75
+ `}
76
+ `
77
+
78
+ export const RippleContainer = styled.span`
79
+ position: absolute;
80
+ border-radius: 50%;
81
+ transform: scale(0);
82
+ animation: ripple 0.4s linear;
83
+ background-color: rgba(255, 255, 255, 0.6);
84
+ pointer-events: none;
85
+ z-index: 0;
86
+
87
+ @keyframes ripple {
88
+ to {
89
+ transform: scale(3.5);
90
+ opacity: 0;
91
+ }
92
+ }
93
+ `
94
+
95
+ export const Label = styled.span<{ disabled?: boolean }>`
96
+ font-size: ${fontSize.fontSize14}px;
97
+ font-weight: ${fontWeight.fontWeight500};
98
+
99
+ color: ${({ theme, disabled }) =>
100
+ disabled
101
+ ? `${parseColor(theme.colors.neutral1100)}70`
102
+ : parseColor(theme.colors.neutral1100)};
103
+ `
104
+
105
+ export const CustomLabel = styled(Text)<{ disabled?: boolean }>`
106
+ font-size: ${fontSize.fontSize12}px;
107
+ font-weight: ${fontWeight.fontWeight400};
108
+ line-height: 8px;
109
+
110
+ color: ${({ theme, disabled }) =>
111
+ disabled
112
+ ? `${parseColor(theme.colors.textMedium)}70`
113
+ : parseColor(theme.colors.textMedium)};
114
+
115
+ `
@@ -1,40 +1,97 @@
1
- import React, { useState } from 'react'
2
- import { CheckboxProps } from './Checkbox.types'
3
- import { CheckboxWrapper, CustomCheckbox, Label } from './Checkbox.styles'
4
-
5
- const Checkbox: React.FC<CheckboxProps> = ({
6
- label,
7
- checked,
8
- onChange,
9
- disabled = false,
10
- register,
11
- className,
12
- ...rest
13
- }) => {
14
- // Estado interno para alternar caso `checked` não seja controlado externamente
15
- const [internalChecked, setInternalChecked] = useState<boolean>(
16
- checked || false
17
- )
18
-
19
- const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
20
- onChange?.(e)
21
- setInternalChecked(!internalChecked) // Alterna o estado internamente
22
- }
23
-
24
- return (
25
- <CheckboxWrapper className={className}>
26
- <input
27
- {...register}
28
- type="checkbox"
29
- checked={internalChecked}
30
- onChange={handleChange}
31
- disabled={disabled}
32
- {...rest}
33
- />
34
- <CustomCheckbox checked={internalChecked} disabled={disabled} />
35
- {label && <Label disabled={disabled}>{label}</Label>}
36
- </CheckboxWrapper>
37
- )
38
- }
39
-
40
- export default Checkbox
1
+ import React, { useState } from 'react'
2
+ import { CheckboxProps } from './Checkbox.types'
3
+ import {
4
+ CheckboxWrapper,
5
+ CustomCheckbox,
6
+ CustomLabel,
7
+ Label,
8
+ RippleContainer
9
+ } from './Checkbox.styles'
10
+
11
+ interface RippleInterface {
12
+ id: string
13
+ x: number
14
+ y: number
15
+ }
16
+
17
+ const Checkbox: React.FC<CheckboxProps> = ({
18
+ label,
19
+ checked,
20
+ onChange,
21
+ disabled = false,
22
+ register,
23
+ className,
24
+ description,
25
+ ...rest
26
+ }) => {
27
+ const [internalChecked, setInternalChecked] = useState<boolean>(
28
+ checked || false
29
+ )
30
+ const [ripples, setRipples] = useState<RippleInterface[]>([])
31
+
32
+ const removeRipple = (ripples: RippleInterface[], rippleId: string) => {
33
+ return ripples.filter(r => r.id !== rippleId)
34
+ }
35
+
36
+ const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
37
+ onChange?.(e)
38
+ setInternalChecked(!internalChecked)
39
+ }
40
+
41
+ const handleRipple = (e: React.MouseEvent<HTMLSpanElement>) => {
42
+ if (disabled) return
43
+ const rect = e.currentTarget.getBoundingClientRect()
44
+ const x = e.clientX - rect.left
45
+ const y = e.clientY - rect.top
46
+ const newRipple: RippleInterface = {
47
+ id: `${Date.now()}-${Math.random()}`,
48
+ x,
49
+ y
50
+ }
51
+ setRipples(prev => [...prev, newRipple])
52
+ }
53
+
54
+ return (
55
+ <CheckboxWrapper className={className}>
56
+ <input
57
+ {...register}
58
+ type="checkbox"
59
+ checked={internalChecked}
60
+ onChange={handleChange}
61
+ disabled={disabled}
62
+ {...rest}
63
+ />
64
+ <CustomCheckbox
65
+ checked={internalChecked}
66
+ disabled={disabled}
67
+ onClick={handleRipple}
68
+ >
69
+ {ripples.map(ripple => (
70
+ <RippleContainer
71
+ key={ripple.id}
72
+ style={{
73
+ top: ripple.y - 10,
74
+ left: ripple.x - 10,
75
+ width: 20,
76
+ height: 20
77
+ }}
78
+ onAnimationEnd={() =>
79
+ setRipples(prev => removeRipple(prev, ripple.id))
80
+ }
81
+ />
82
+ ))}
83
+ </CustomCheckbox>
84
+ <div>
85
+ {label && <Label disabled={disabled}>{label}</Label>}
86
+ <CustomLabel
87
+ disabled={disabled}
88
+ weight="fontWeight400"
89
+ >
90
+ {description}
91
+ </CustomLabel>
92
+ </div>
93
+ </CheckboxWrapper>
94
+ )
95
+ }
96
+
97
+ export default Checkbox
@@ -1,11 +1,12 @@
1
- import { UseFormRegisterReturn } from 'react-hook-form'
2
-
3
- export interface CheckboxProps {
4
- label?: string
5
- checked?: boolean
6
- onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void
7
- disabled?: boolean
8
- register?: UseFormRegisterReturn<string>
9
- value?: string
10
- className?: string
11
- }
1
+ import { UseFormRegisterReturn } from 'react-hook-form'
2
+
3
+ export interface CheckboxProps {
4
+ label?: string
5
+ checked?: boolean
6
+ description?: string
7
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void
8
+ disabled?: boolean
9
+ register?: UseFormRegisterReturn<string>
10
+ value?: string
11
+ className?: string
12
+ }
@@ -1,2 +1,2 @@
1
- export { default } from './Checkbox'
2
- export type { CheckboxProps } from './Checkbox.types'
1
+ export { default } from './Checkbox'
2
+ export type { CheckboxProps } from './Checkbox.types'
@@ -1,66 +1,66 @@
1
- import { parseColor } from '../../utils'
2
- import styled from 'styled-components'
3
- import { Content, Item } from '@radix-ui/react-dropdown-menu'
4
- import { spacing } from '@liguelead/foundation'
5
-
6
- export const ArrownDatePicker = styled.button.attrs(() => ({ type: 'button' }))`
7
- background-color: transparent;
8
- border: 0;
9
- outline: 0;
10
- padding: 0;
11
- cursor: pointer;
12
- height: 32px;
13
- width: 32px;
14
- border-radius: 4px;
15
- overflow: hidden;
16
- transition: 0.2s all linear;
17
- color: ${({ theme }) => parseColor(theme.colors.primaryDark)};
18
- &:hover {
19
- color: ${({ theme }) => parseColor(theme.colors.white)};
20
- background: ${({ theme }) => parseColor(theme.colors.primary)};
21
- }
22
- `
23
-
24
- export const ButtonDatePicker = styled.button.attrs(() => ({ type: 'button' }))`
25
- background-color: transparent;
26
- border: 0;
27
- outline: 0;
28
- padding: ${spacing.spacing4}px;
29
- cursor: pointer;
30
- border-radius: 4px;
31
- overflow: hidden;
32
- transition: 0.2s all linear;
33
- color: ${({ theme }) => parseColor(theme.colors.primaryDark)};
34
- &:hover {
35
- color: ${({ theme }) => parseColor(theme.colors.white)};
36
- background: ${({ theme }) => parseColor(theme.colors.primary)};
37
- }
38
- `
39
-
40
- export const HeaderSelectWrapper = styled.div`
41
- display: flex;
42
- justify-content: space-between;
43
- width: 100%;
44
- gap: 4px;
45
- padding: 0px 4px;
46
- `
47
-
48
- export const DropdownContent = styled(Content)`
49
- background-color: white;
50
- border-radius: 4px;
51
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
52
- padding: 4px;
53
- max-height: 300px;
54
- overflow-y: auto;
55
- z-index: 10;
56
- `
57
-
58
- export const DropdownItem = styled(Item)`
59
- padding: 8px 12px;
60
- font-size: 14px;
61
- cursor: pointer;
62
- &:hover {
63
- background-color: ${({ theme }) => parseColor(theme.colors.primary)};
64
- color: ${({ theme }) => parseColor(theme.colors.white)};
65
- }
66
- `
1
+ import { parseColor } from '../../utils'
2
+ import styled from 'styled-components'
3
+ import { Content, Item } from '@radix-ui/react-dropdown-menu'
4
+ import { spacing } from '@liguelead/foundation'
5
+
6
+ export const ArrownDatePicker = styled.button.attrs(() => ({ type: 'button' }))`
7
+ background-color: transparent;
8
+ border: 0;
9
+ outline: 0;
10
+ padding: 0;
11
+ cursor: pointer;
12
+ height: 32px;
13
+ width: 32px;
14
+ border-radius: 4px;
15
+ overflow: hidden;
16
+ transition: 0.2s all linear;
17
+ color: ${({ theme }) => parseColor(theme.colors.primaryDark)};
18
+ &:hover {
19
+ color: ${({ theme }) => parseColor(theme.colors.white)};
20
+ background: ${({ theme }) => parseColor(theme.colors.primary)};
21
+ }
22
+ `
23
+
24
+ export const ButtonDatePicker = styled.button.attrs(() => ({ type: 'button' }))`
25
+ background-color: transparent;
26
+ border: 0;
27
+ outline: 0;
28
+ padding: ${spacing.spacing4}px;
29
+ cursor: pointer;
30
+ border-radius: 4px;
31
+ overflow: hidden;
32
+ transition: 0.2s all linear;
33
+ color: ${({ theme }) => parseColor(theme.colors.primaryDark)};
34
+ &:hover {
35
+ color: ${({ theme }) => parseColor(theme.colors.white)};
36
+ background: ${({ theme }) => parseColor(theme.colors.primary)};
37
+ }
38
+ `
39
+
40
+ export const HeaderSelectWrapper = styled.div`
41
+ display: flex;
42
+ justify-content: space-between;
43
+ width: 100%;
44
+ gap: 4px;
45
+ padding: 0px 4px;
46
+ `
47
+
48
+ export const DropdownContent = styled(Content)`
49
+ background-color: white;
50
+ border-radius: 4px;
51
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
52
+ padding: 4px;
53
+ max-height: 300px;
54
+ overflow-y: auto;
55
+ z-index: 10;
56
+ `
57
+
58
+ export const DropdownItem = styled(Item)`
59
+ padding: 8px 12px;
60
+ font-size: 14px;
61
+ cursor: pointer;
62
+ &:hover {
63
+ background-color: ${({ theme }) => parseColor(theme.colors.primary)};
64
+ color: ${({ theme }) => parseColor(theme.colors.white)};
65
+ }
66
+ `