@liguelead/design-system 0.0.8 → 0.0.10
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.
- package/components/Button/Button.appearance.ts +62 -62
- package/components/Button/Button.sizes.ts +41 -41
- package/components/Button/Button.styles.ts +50 -50
- package/components/Button/Button.tsx +76 -76
- package/components/Button/Button.types.ts +23 -23
- package/components/Button/index.ts +1 -1
- package/components/Checkbox/Checkbox.styles.ts +66 -66
- package/components/Checkbox/Checkbox.tsx +40 -40
- package/components/Checkbox/Checkbox.types.ts +11 -11
- package/components/Checkbox/index.tsx +2 -2
- package/components/DatePicker/DatePicker.styles.ts +66 -66
- package/components/DatePicker/DatePicker.tsx +135 -135
- package/components/DatePicker/DatePicker.types.ts +29 -29
- package/components/DatePicker/index.ts +1 -1
- package/components/IconButton/IconButton.sizes.ts +41 -41
- package/components/IconButton/IconButton.tsx +70 -70
- package/components/IconButton/index.ts +1 -1
- package/components/PageWrapper/PageWrapper.tsx +31 -31
- package/components/PageWrapper/index.ts +1 -1
- package/components/SegmentedButton/SegmentedButton.styles.ts +29 -29
- package/components/SegmentedButton/SegmentedButton.tsx +49 -49
- package/components/SegmentedButton/SegmentedButton.types.ts +20 -20
- package/components/SegmentedButton/index.ts +1 -1
- package/components/Select/Select.sizes.ts +56 -56
- package/components/Select/Select.states.tsx +69 -69
- package/components/Select/Select.styles.ts +148 -148
- package/components/Select/Select.tsx +145 -144
- package/components/Select/Select.types.ts +36 -36
- package/components/Select/index.ts +1 -1
- package/components/Text/Text.styles.ts +43 -43
- package/components/Text/Text.tsx +27 -27
- package/components/Text/Text.types.ts +42 -42
- package/components/Text/index.ts +1 -1
- package/components/TextField/TextField.sizes.ts +58 -58
- package/components/TextField/TextField.states.tsx +53 -76
- package/components/TextField/TextField.styles.ts +81 -98
- package/components/TextField/TextField.tsx +105 -108
- package/components/TextField/TextField.types.ts +22 -21
- package/components/TextField/index.ts +2 -2
- package/components/TextField/utils/getState.ts +7 -0
- package/components/ThemeProvider/ThemeProvider.tsx +21 -21
- package/components/ThemeProvider/index.ts +1 -1
- package/components/ThemeProvider/style.ts +969 -969
- package/components/Wizard/StepContent.tsx +28 -28
- package/components/Wizard/StepMenuItem.tsx +33 -33
- package/components/Wizard/Wizard.context.tsx +76 -76
- package/components/Wizard/Wizard.styles.ts +126 -126
- package/components/Wizard/Wizard.tsx +55 -55
- package/components/Wizard/index.ts +1 -1
- package/components/index.ts +11 -11
- package/package.json +41 -39
- package/scripts/createTypes.js +70 -70
- package/utils/colorDarken.ts +10 -10
- package/utils/colorLighten.ts +10 -10
- package/utils/darkenOrLighen.ts +19 -19
- package/utils/getTextColor.ts +12 -12
- package/utils/index.ts +5 -5
- package/utils/parseColor.ts +7 -7
|
@@ -1,40 +1,40 @@
|
|
|
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 { 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,11 +1,11 @@
|
|
|
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
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void
|
|
7
|
+
disabled?: boolean
|
|
8
|
+
register?: UseFormRegisterReturn<string>
|
|
9
|
+
value?: string
|
|
10
|
+
className?: string
|
|
11
|
+
}
|
|
@@ -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
|
+
`
|
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
import * as DropdownMenu from '@radix-ui/react-dropdown-menu'
|
|
2
|
-
import {
|
|
3
|
-
Calendar,
|
|
4
|
-
CaretLeft,
|
|
5
|
-
CaretRight,
|
|
6
|
-
CaretDown
|
|
7
|
-
} from '@phosphor-icons/react'
|
|
8
|
-
import { getYear, getMonth } from 'date-fns'
|
|
9
|
-
import { range } from 'lodash'
|
|
10
|
-
import { ptBR } from 'date-fns/locale'
|
|
11
|
-
import { forwardRef, useState } from 'react'
|
|
12
|
-
import TextField from '../TextField'
|
|
13
|
-
import { DatePickerProps, Months } from './DatePicker.types'
|
|
14
|
-
import {
|
|
15
|
-
ButtonDatePicker,
|
|
16
|
-
HeaderSelectWrapper,
|
|
17
|
-
DropdownContent,
|
|
18
|
-
DropdownItem,
|
|
19
|
-
ArrownDatePicker
|
|
20
|
-
} from './DatePicker.styles'
|
|
21
|
-
import DatePicker from 'react-datepicker'
|
|
22
|
-
|
|
23
|
-
const DatePickerCustom = forwardRef<HTMLInputElement, DatePickerProps>(
|
|
24
|
-
(
|
|
25
|
-
{
|
|
26
|
-
label,
|
|
27
|
-
error,
|
|
28
|
-
startYear = 1990,
|
|
29
|
-
endYear = 0,
|
|
30
|
-
startDate = new Date(),
|
|
31
|
-
icon = false,
|
|
32
|
-
onChange,
|
|
33
|
-
size = 'md',
|
|
34
|
-
register,
|
|
35
|
-
...rest
|
|
36
|
-
}: DatePickerProps,
|
|
37
|
-
ref
|
|
38
|
-
) => {
|
|
39
|
-
const [pickerStartDate, setPickerStartDate] = useState<Date | null>(
|
|
40
|
-
startDate
|
|
41
|
-
)
|
|
42
|
-
const lastYear =
|
|
43
|
-
endYear > startYear ? endYear + 1 : getYear(new Date()) + 1
|
|
44
|
-
const years = range(startYear, lastYear, 1)
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<DatePicker
|
|
48
|
-
{...register}
|
|
49
|
-
{...rest}
|
|
50
|
-
locale={ptBR}
|
|
51
|
-
renderCustomHeader={({
|
|
52
|
-
date,
|
|
53
|
-
changeYear,
|
|
54
|
-
changeMonth,
|
|
55
|
-
decreaseMonth,
|
|
56
|
-
increaseMonth,
|
|
57
|
-
prevMonthButtonDisabled,
|
|
58
|
-
nextMonthButtonDisabled
|
|
59
|
-
}) => (
|
|
60
|
-
<HeaderSelectWrapper>
|
|
61
|
-
<ArrownDatePicker
|
|
62
|
-
onClick={decreaseMonth}
|
|
63
|
-
disabled={prevMonthButtonDisabled}>
|
|
64
|
-
<CaretLeft size={24} weight="bold" />
|
|
65
|
-
</ArrownDatePicker>
|
|
66
|
-
<DropdownMenu.Root modal={false}>
|
|
67
|
-
<DropdownMenu.Trigger asChild>
|
|
68
|
-
<ButtonDatePicker>
|
|
69
|
-
{getYear(date)} <CaretDown size={16} />
|
|
70
|
-
</ButtonDatePicker>
|
|
71
|
-
</DropdownMenu.Trigger>
|
|
72
|
-
<DropdownContent>
|
|
73
|
-
{years.map(option => (
|
|
74
|
-
<DropdownItem
|
|
75
|
-
key={option}
|
|
76
|
-
onSelect={() => {
|
|
77
|
-
changeYear(option)
|
|
78
|
-
}}>
|
|
79
|
-
{option}
|
|
80
|
-
</DropdownItem>
|
|
81
|
-
))}
|
|
82
|
-
</DropdownContent>
|
|
83
|
-
</DropdownMenu.Root>
|
|
84
|
-
<DropdownMenu.Root modal={false}>
|
|
85
|
-
<DropdownMenu.Trigger asChild>
|
|
86
|
-
<ButtonDatePicker>
|
|
87
|
-
{Months[getMonth(date)]}{' '}
|
|
88
|
-
<CaretDown size={16} />
|
|
89
|
-
</ButtonDatePicker>
|
|
90
|
-
</DropdownMenu.Trigger>
|
|
91
|
-
<DropdownContent>
|
|
92
|
-
{Months.map((month, index) => (
|
|
93
|
-
<DropdownItem
|
|
94
|
-
key={month}
|
|
95
|
-
onSelect={() => {
|
|
96
|
-
changeMonth(index)
|
|
97
|
-
}}>
|
|
98
|
-
{month}
|
|
99
|
-
</DropdownItem>
|
|
100
|
-
))}
|
|
101
|
-
</DropdownContent>
|
|
102
|
-
</DropdownMenu.Root>
|
|
103
|
-
|
|
104
|
-
<ArrownDatePicker
|
|
105
|
-
onClick={increaseMonth}
|
|
106
|
-
disabled={nextMonthButtonDisabled}>
|
|
107
|
-
<CaretRight size={24} weight="bold" />
|
|
108
|
-
</ArrownDatePicker>
|
|
109
|
-
</HeaderSelectWrapper>
|
|
110
|
-
)}
|
|
111
|
-
dateFormat="dd/MM/yyyy"
|
|
112
|
-
selected={pickerStartDate}
|
|
113
|
-
onChange={(date: Date | null) => {
|
|
114
|
-
if (!date) {
|
|
115
|
-
return
|
|
116
|
-
}
|
|
117
|
-
setPickerStartDate(date)
|
|
118
|
-
onChange?.(date)
|
|
119
|
-
}}
|
|
120
|
-
customInput={
|
|
121
|
-
<TextField
|
|
122
|
-
error={error}
|
|
123
|
-
size={size}
|
|
124
|
-
ref={ref}
|
|
125
|
-
leftIcon={icon && <Calendar size={22} weight="bold" />}
|
|
126
|
-
label={label}
|
|
127
|
-
className="example-custom-input"
|
|
128
|
-
/>
|
|
129
|
-
}
|
|
130
|
-
/>
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
export default DatePickerCustom
|
|
1
|
+
import * as DropdownMenu from '@radix-ui/react-dropdown-menu'
|
|
2
|
+
import {
|
|
3
|
+
Calendar,
|
|
4
|
+
CaretLeft,
|
|
5
|
+
CaretRight,
|
|
6
|
+
CaretDown
|
|
7
|
+
} from '@phosphor-icons/react'
|
|
8
|
+
import { getYear, getMonth } from 'date-fns'
|
|
9
|
+
import { range } from 'lodash'
|
|
10
|
+
import { ptBR } from 'date-fns/locale'
|
|
11
|
+
import { forwardRef, useState } from 'react'
|
|
12
|
+
import TextField from '../TextField'
|
|
13
|
+
import { DatePickerProps, Months } from './DatePicker.types'
|
|
14
|
+
import {
|
|
15
|
+
ButtonDatePicker,
|
|
16
|
+
HeaderSelectWrapper,
|
|
17
|
+
DropdownContent,
|
|
18
|
+
DropdownItem,
|
|
19
|
+
ArrownDatePicker
|
|
20
|
+
} from './DatePicker.styles'
|
|
21
|
+
import DatePicker from 'react-datepicker'
|
|
22
|
+
|
|
23
|
+
const DatePickerCustom = forwardRef<HTMLInputElement, DatePickerProps>(
|
|
24
|
+
(
|
|
25
|
+
{
|
|
26
|
+
label,
|
|
27
|
+
error,
|
|
28
|
+
startYear = 1990,
|
|
29
|
+
endYear = 0,
|
|
30
|
+
startDate = new Date(),
|
|
31
|
+
icon = false,
|
|
32
|
+
onChange,
|
|
33
|
+
size = 'md',
|
|
34
|
+
register,
|
|
35
|
+
...rest
|
|
36
|
+
}: DatePickerProps,
|
|
37
|
+
ref
|
|
38
|
+
) => {
|
|
39
|
+
const [pickerStartDate, setPickerStartDate] = useState<Date | null>(
|
|
40
|
+
startDate
|
|
41
|
+
)
|
|
42
|
+
const lastYear =
|
|
43
|
+
endYear > startYear ? endYear + 1 : getYear(new Date()) + 1
|
|
44
|
+
const years = range(startYear, lastYear, 1)
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<DatePicker
|
|
48
|
+
{...register}
|
|
49
|
+
{...rest}
|
|
50
|
+
locale={ptBR}
|
|
51
|
+
renderCustomHeader={({
|
|
52
|
+
date,
|
|
53
|
+
changeYear,
|
|
54
|
+
changeMonth,
|
|
55
|
+
decreaseMonth,
|
|
56
|
+
increaseMonth,
|
|
57
|
+
prevMonthButtonDisabled,
|
|
58
|
+
nextMonthButtonDisabled
|
|
59
|
+
}) => (
|
|
60
|
+
<HeaderSelectWrapper>
|
|
61
|
+
<ArrownDatePicker
|
|
62
|
+
onClick={decreaseMonth}
|
|
63
|
+
disabled={prevMonthButtonDisabled}>
|
|
64
|
+
<CaretLeft size={24} weight="bold" />
|
|
65
|
+
</ArrownDatePicker>
|
|
66
|
+
<DropdownMenu.Root modal={false}>
|
|
67
|
+
<DropdownMenu.Trigger asChild>
|
|
68
|
+
<ButtonDatePicker>
|
|
69
|
+
{getYear(date)} <CaretDown size={16} />
|
|
70
|
+
</ButtonDatePicker>
|
|
71
|
+
</DropdownMenu.Trigger>
|
|
72
|
+
<DropdownContent>
|
|
73
|
+
{years.map(option => (
|
|
74
|
+
<DropdownItem
|
|
75
|
+
key={option}
|
|
76
|
+
onSelect={() => {
|
|
77
|
+
changeYear(option)
|
|
78
|
+
}}>
|
|
79
|
+
{option}
|
|
80
|
+
</DropdownItem>
|
|
81
|
+
))}
|
|
82
|
+
</DropdownContent>
|
|
83
|
+
</DropdownMenu.Root>
|
|
84
|
+
<DropdownMenu.Root modal={false}>
|
|
85
|
+
<DropdownMenu.Trigger asChild>
|
|
86
|
+
<ButtonDatePicker>
|
|
87
|
+
{Months[getMonth(date)]}{' '}
|
|
88
|
+
<CaretDown size={16} />
|
|
89
|
+
</ButtonDatePicker>
|
|
90
|
+
</DropdownMenu.Trigger>
|
|
91
|
+
<DropdownContent>
|
|
92
|
+
{Months.map((month, index) => (
|
|
93
|
+
<DropdownItem
|
|
94
|
+
key={month}
|
|
95
|
+
onSelect={() => {
|
|
96
|
+
changeMonth(index)
|
|
97
|
+
}}>
|
|
98
|
+
{month}
|
|
99
|
+
</DropdownItem>
|
|
100
|
+
))}
|
|
101
|
+
</DropdownContent>
|
|
102
|
+
</DropdownMenu.Root>
|
|
103
|
+
|
|
104
|
+
<ArrownDatePicker
|
|
105
|
+
onClick={increaseMonth}
|
|
106
|
+
disabled={nextMonthButtonDisabled}>
|
|
107
|
+
<CaretRight size={24} weight="bold" />
|
|
108
|
+
</ArrownDatePicker>
|
|
109
|
+
</HeaderSelectWrapper>
|
|
110
|
+
)}
|
|
111
|
+
dateFormat="dd/MM/yyyy"
|
|
112
|
+
selected={pickerStartDate}
|
|
113
|
+
onChange={(date: Date | null) => {
|
|
114
|
+
if (!date) {
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
setPickerStartDate(date)
|
|
118
|
+
onChange?.(date)
|
|
119
|
+
}}
|
|
120
|
+
customInput={
|
|
121
|
+
<TextField
|
|
122
|
+
error={error}
|
|
123
|
+
size={size}
|
|
124
|
+
ref={ref}
|
|
125
|
+
leftIcon={icon && <Calendar size={22} weight="bold" />}
|
|
126
|
+
label={label}
|
|
127
|
+
className="example-custom-input"
|
|
128
|
+
/>
|
|
129
|
+
}
|
|
130
|
+
/>
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
export default DatePickerCustom
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { FieldValues, UseFormRegister } from 'react-hook-form'
|
|
2
|
-
|
|
3
|
-
export const Months = [
|
|
4
|
-
'Janeiro',
|
|
5
|
-
'Fevereiro',
|
|
6
|
-
'Março',
|
|
7
|
-
'Abril',
|
|
8
|
-
'Maio',
|
|
9
|
-
'Junho',
|
|
10
|
-
'Julho',
|
|
11
|
-
'Agosto',
|
|
12
|
-
'Setembro',
|
|
13
|
-
'Outubro',
|
|
14
|
-
'Novembro',
|
|
15
|
-
'Dezembro'
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
export type DatePickerProps = {
|
|
19
|
-
endYear?: number
|
|
20
|
-
label: string
|
|
21
|
-
startYear?: number
|
|
22
|
-
onChange?: (date: Date) => void
|
|
23
|
-
error?: FieldValues
|
|
24
|
-
startDate?: Date
|
|
25
|
-
className?: string
|
|
26
|
-
icon?: boolean
|
|
27
|
-
size?: 'sm' | 'md' | 'lg'
|
|
28
|
-
register?: UseFormRegister<Date>
|
|
29
|
-
}
|
|
1
|
+
import { FieldValues, UseFormRegister } from 'react-hook-form'
|
|
2
|
+
|
|
3
|
+
export const Months = [
|
|
4
|
+
'Janeiro',
|
|
5
|
+
'Fevereiro',
|
|
6
|
+
'Março',
|
|
7
|
+
'Abril',
|
|
8
|
+
'Maio',
|
|
9
|
+
'Junho',
|
|
10
|
+
'Julho',
|
|
11
|
+
'Agosto',
|
|
12
|
+
'Setembro',
|
|
13
|
+
'Outubro',
|
|
14
|
+
'Novembro',
|
|
15
|
+
'Dezembro'
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
export type DatePickerProps = {
|
|
19
|
+
endYear?: number
|
|
20
|
+
label: string
|
|
21
|
+
startYear?: number
|
|
22
|
+
onChange?: (date: Date) => void
|
|
23
|
+
error?: FieldValues
|
|
24
|
+
startDate?: Date
|
|
25
|
+
className?: string
|
|
26
|
+
icon?: boolean
|
|
27
|
+
size?: 'sm' | 'md' | 'lg'
|
|
28
|
+
register?: UseFormRegister<Date>
|
|
29
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './DatePicker'
|
|
1
|
+
export { default } from './DatePicker'
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { spacing } from '@liguelead/foundation'
|
|
2
|
-
import { ButtonSizeTypes } from '../Button/Button.types'
|
|
3
|
-
|
|
4
|
-
export const IconButtonSizes = (size: ButtonSizeTypes) => {
|
|
5
|
-
const sizes = {
|
|
6
|
-
xs: `
|
|
7
|
-
padding: ${spacing.spacing8}px ${spacing.spacing8}px;
|
|
8
|
-
border-radius: ${spacing.spacing4}px;
|
|
9
|
-
& svg {
|
|
10
|
-
width: ${spacing.spacing12}px !important;
|
|
11
|
-
height: ${spacing.spacing12}px;
|
|
12
|
-
}
|
|
13
|
-
`,
|
|
14
|
-
sm: `
|
|
15
|
-
padding: ${spacing.spacing12}px ${spacing.spacing12}px;
|
|
16
|
-
border-radius: ${spacing.spacing4}px;
|
|
17
|
-
& svg {
|
|
18
|
-
width: ${spacing.spacing16}px !important;
|
|
19
|
-
height: ${spacing.spacing16}px;
|
|
20
|
-
}
|
|
21
|
-
`,
|
|
22
|
-
md: `
|
|
23
|
-
padding: ${spacing.spacing12}px ${spacing.spacing12}px;
|
|
24
|
-
border-radius: ${spacing.spacing4}px;
|
|
25
|
-
& svg {
|
|
26
|
-
width: ${spacing.spacing20}px;
|
|
27
|
-
height: ${spacing.spacing20}px;
|
|
28
|
-
}
|
|
29
|
-
`,
|
|
30
|
-
lg: `
|
|
31
|
-
padding: ${spacing.spacing12}px ${spacing.spacing12}px;
|
|
32
|
-
border-radius: ${spacing.spacing4}px;
|
|
33
|
-
& svg {
|
|
34
|
-
width: ${spacing.spacing32}px;
|
|
35
|
-
height: ${spacing.spacing32}px;
|
|
36
|
-
}
|
|
37
|
-
`
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return sizes[size]
|
|
41
|
-
}
|
|
1
|
+
import { spacing } from '@liguelead/foundation'
|
|
2
|
+
import { ButtonSizeTypes } from '../Button/Button.types'
|
|
3
|
+
|
|
4
|
+
export const IconButtonSizes = (size: ButtonSizeTypes) => {
|
|
5
|
+
const sizes = {
|
|
6
|
+
xs: `
|
|
7
|
+
padding: ${spacing.spacing8}px ${spacing.spacing8}px;
|
|
8
|
+
border-radius: ${spacing.spacing4}px;
|
|
9
|
+
& svg {
|
|
10
|
+
width: ${spacing.spacing12}px !important;
|
|
11
|
+
height: ${spacing.spacing12}px;
|
|
12
|
+
}
|
|
13
|
+
`,
|
|
14
|
+
sm: `
|
|
15
|
+
padding: ${spacing.spacing12}px ${spacing.spacing12}px;
|
|
16
|
+
border-radius: ${spacing.spacing4}px;
|
|
17
|
+
& svg {
|
|
18
|
+
width: ${spacing.spacing16}px !important;
|
|
19
|
+
height: ${spacing.spacing16}px;
|
|
20
|
+
}
|
|
21
|
+
`,
|
|
22
|
+
md: `
|
|
23
|
+
padding: ${spacing.spacing12}px ${spacing.spacing12}px;
|
|
24
|
+
border-radius: ${spacing.spacing4}px;
|
|
25
|
+
& svg {
|
|
26
|
+
width: ${spacing.spacing20}px;
|
|
27
|
+
height: ${spacing.spacing20}px;
|
|
28
|
+
}
|
|
29
|
+
`,
|
|
30
|
+
lg: `
|
|
31
|
+
padding: ${spacing.spacing12}px ${spacing.spacing12}px;
|
|
32
|
+
border-radius: ${spacing.spacing4}px;
|
|
33
|
+
& svg {
|
|
34
|
+
width: ${spacing.spacing32}px;
|
|
35
|
+
height: ${spacing.spacing32}px;
|
|
36
|
+
}
|
|
37
|
+
`
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return sizes[size]
|
|
41
|
+
}
|