@liguelead/design-system 0.0.6 → 0.0.8
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.styles.ts +3 -3
- package/components/Button/Button.tsx +62 -56
- package/components/Button/Button.types.ts +2 -1
- package/components/Checkbox/Checkbox.styles.ts +66 -0
- package/components/Checkbox/Checkbox.tsx +40 -0
- package/components/Checkbox/Checkbox.types.ts +11 -0
- package/components/Checkbox/index.tsx +2 -0
- package/components/DatePicker/DatePicker.styles.ts +66 -0
- package/components/DatePicker/DatePicker.tsx +135 -0
- package/components/DatePicker/DatePicker.types.ts +29 -0
- package/components/DatePicker/index.ts +1 -0
- package/components/IconButton/IconButton.tsx +53 -50
- package/components/SegmentedButton/SegmentedButton.styles.ts +29 -0
- package/components/SegmentedButton/SegmentedButton.tsx +49 -0
- package/components/SegmentedButton/SegmentedButton.types.ts +20 -0
- package/components/SegmentedButton/index.ts +1 -0
- package/components/Select/Select.sizes.ts +56 -0
- package/components/Select/Select.states.tsx +69 -0
- package/components/Select/Select.styles.ts +148 -0
- package/components/Select/Select.tsx +144 -0
- package/components/Select/Select.types.ts +36 -0
- package/components/Select/index.ts +1 -0
- package/components/Text/Text.styles.ts +5 -5
- package/components/Text/Text.tsx +4 -42
- package/components/Text/Text.types.ts +42 -0
- package/components/TextField/TextField.tsx +7 -2
- package/components/TextField/TextField.types.ts +2 -1
- package/components/ThemeProvider/ThemeProvider.tsx +11 -20
- package/components/ThemeProvider/style.ts +781 -12
- package/components/index.ts +4 -0
- package/package.json +6 -3
- package/scripts/createTypes.js +32 -2
|
@@ -29,14 +29,14 @@ export const StyledButton = styled.button<StyledButtonProps>`
|
|
|
29
29
|
`
|
|
30
30
|
|
|
31
31
|
export const RippleContainer = styled.span<{
|
|
32
|
-
appearance: string
|
|
32
|
+
$appearance: string
|
|
33
33
|
}>`
|
|
34
34
|
position: absolute;
|
|
35
35
|
border-radius: 50%;
|
|
36
36
|
transform: scale(0);
|
|
37
37
|
animation: ripple 0.4s linear;
|
|
38
|
-
background-color: ${({ appearance }) =>
|
|
39
|
-
appearance === 'solid'
|
|
38
|
+
background-color: ${({ $appearance }) =>
|
|
39
|
+
$appearance === 'solid'
|
|
40
40
|
? 'rgba(255, 255, 255, 0.5)'
|
|
41
41
|
: 'rgba(0, 0, 0, 0.2)'};
|
|
42
42
|
pointer-events: none;
|
|
@@ -1,70 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
import { useState } from 'react';
|
|
1
|
+
import { useState } from 'react'
|
|
3
2
|
import { StyledButton, RippleContainer } from './Button.styles'
|
|
4
3
|
import { RippleInterface, ButtonProps } from './Button.types'
|
|
5
4
|
import { ButtonSizes } from './Button.sizes'
|
|
6
|
-
import { ButtonAppearance } from './Button.appearance'
|
|
5
|
+
import { ButtonAppearance } from './Button.appearance'
|
|
7
6
|
|
|
8
7
|
const Button: React.FC<ButtonProps> = ({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
appearance = 'solid',
|
|
9
|
+
children,
|
|
10
|
+
className,
|
|
11
|
+
color = 'primary',
|
|
12
|
+
disabled,
|
|
13
|
+
fluid = false,
|
|
14
|
+
size = 'md',
|
|
15
|
+
onClick,
|
|
16
|
+
type = 'button',
|
|
17
|
+
...rest
|
|
19
18
|
}) => {
|
|
19
|
+
const [ripples, setRipples] = useState<RippleInterface[]>([])
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const buttonSize = ButtonSizes(size)
|
|
22
|
+
const buttonAppearance = ButtonAppearance(color, appearance)
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
const removeRipple = (ripples: RippleInterface[], rippleId: string) => {
|
|
25
|
+
return ripples.filter(r => r.id !== rippleId)
|
|
26
|
+
}
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
29
|
+
const rect = e.currentTarget.getBoundingClientRect()
|
|
30
|
+
const x = e.clientX - rect.left
|
|
31
|
+
const y = e.clientY - rect.top
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
const newRipple: RippleInterface = {
|
|
34
|
+
id: `${Date.now()}-${Math.random()}`,
|
|
35
|
+
x,
|
|
36
|
+
y
|
|
37
|
+
}
|
|
38
|
+
setRipples(prev => [...prev, newRipple])
|
|
33
39
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
// Chama o onClick fornecido
|
|
41
|
+
if (onClick) {
|
|
42
|
+
onClick(e)
|
|
43
|
+
}
|
|
37
44
|
}
|
|
38
|
-
};
|
|
39
45
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
46
|
+
return (
|
|
47
|
+
<StyledButton
|
|
48
|
+
disabled={disabled}
|
|
49
|
+
className={className}
|
|
50
|
+
$fluid={fluid}
|
|
51
|
+
$appearance={buttonAppearance}
|
|
52
|
+
onClick={handleClick}
|
|
53
|
+
$buttonSize={buttonSize}
|
|
54
|
+
type={type}
|
|
55
|
+
{...rest}>
|
|
56
|
+
{children}
|
|
57
|
+
{ripples.map(ripple => (
|
|
58
|
+
<RippleContainer
|
|
59
|
+
$appearance={appearance}
|
|
60
|
+
key={ripple.id}
|
|
61
|
+
style={{
|
|
62
|
+
top: ripple.y - 10,
|
|
63
|
+
left: ripple.x - 10,
|
|
64
|
+
width: 20,
|
|
65
|
+
height: 20
|
|
66
|
+
}}
|
|
67
|
+
onAnimationEnd={() =>
|
|
68
|
+
setRipples(prev => removeRipple(prev, ripple.id))
|
|
69
|
+
}
|
|
70
|
+
/>
|
|
71
|
+
))}
|
|
72
|
+
</StyledButton>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
69
75
|
|
|
70
|
-
export default Button
|
|
76
|
+
export default Button
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {colorType} from 'types'
|
|
1
|
+
import { colorType } from 'types'
|
|
2
2
|
|
|
3
3
|
export type ButtonSizeTypes = 'xs' | 'sm' | 'md' | 'lg'
|
|
4
4
|
export type ButtonAppearanceTypes = 'solid' | 'outline' | 'ghost'
|
|
@@ -13,6 +13,7 @@ export interface ButtonProps {
|
|
|
13
13
|
color?: colorType
|
|
14
14
|
onClick?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void
|
|
15
15
|
type?: 'button' | 'submit' | 'reset'
|
|
16
|
+
style?: React.CSSProperties
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export interface RippleInterface {
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
`
|
|
@@ -0,0 +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
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +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
|
+
`
|
|
@@ -0,0 +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
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './DatePicker'
|
|
@@ -1,67 +1,70 @@
|
|
|
1
|
-
import { useState } from
|
|
2
|
-
import { ButtonProps, RippleInterface } from
|
|
3
|
-
import { ButtonAppearance } from
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { ButtonProps, RippleInterface } from '../Button/Button.types'
|
|
3
|
+
import { ButtonAppearance } from '../Button/Button.appearance'
|
|
4
4
|
import { IconButtonSizes } from './IconButton.sizes'
|
|
5
|
-
import { RippleContainer, StyledButton } from
|
|
5
|
+
import { RippleContainer, StyledButton } from '../Button/Button.styles'
|
|
6
6
|
|
|
7
|
-
const IconButton: React.FC<ButtonProps> = ({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const [ripples, setRipples] = useState<RippleInterface[]>([]);
|
|
7
|
+
const IconButton: React.FC<ButtonProps> = ({
|
|
8
|
+
appearance = 'solid',
|
|
9
|
+
children,
|
|
10
|
+
className,
|
|
11
|
+
color = 'primary',
|
|
12
|
+
disabled,
|
|
13
|
+
fluid = false,
|
|
14
|
+
size = 'md',
|
|
15
|
+
onClick,
|
|
16
|
+
...rest
|
|
17
|
+
}) => {
|
|
18
|
+
const [ripples, setRipples] = useState<RippleInterface[]>([])
|
|
20
19
|
|
|
21
20
|
const buttonSize = IconButtonSizes(size)
|
|
22
21
|
const buttonAppearance = ButtonAppearance(color, appearance)
|
|
23
|
-
|
|
22
|
+
|
|
24
23
|
const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
25
|
-
const rect = e.currentTarget.getBoundingClientRect()
|
|
26
|
-
const x = e.clientX - rect.left
|
|
27
|
-
const y = e.clientY - rect.top
|
|
28
|
-
|
|
29
|
-
const newRipple: RippleInterface = {
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
const rect = e.currentTarget.getBoundingClientRect()
|
|
25
|
+
const x = e.clientX - rect.left
|
|
26
|
+
const y = e.clientY - rect.top
|
|
27
|
+
|
|
28
|
+
const newRipple: RippleInterface = {
|
|
29
|
+
id: `${Date.now()}-${Math.random()}`,
|
|
30
|
+
x,
|
|
31
|
+
y
|
|
32
|
+
}
|
|
33
|
+
setRipples(prev => [...prev, newRipple])
|
|
34
|
+
|
|
32
35
|
// Chama o onClick fornecido
|
|
33
36
|
if (onClick) {
|
|
34
|
-
|
|
37
|
+
onClick(e)
|
|
35
38
|
}
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
}
|
|
40
|
+
|
|
38
41
|
return (
|
|
39
42
|
<StyledButton
|
|
40
43
|
disabled={disabled}
|
|
41
44
|
className={className}
|
|
42
45
|
$fluid={fluid}
|
|
43
|
-
$appearance={buttonAppearance}
|
|
44
|
-
onClick={handleClick}
|
|
46
|
+
$appearance={buttonAppearance}
|
|
47
|
+
onClick={handleClick}
|
|
45
48
|
$buttonSize={buttonSize}
|
|
46
|
-
{...rest}
|
|
47
|
-
>
|
|
49
|
+
{...rest}>
|
|
48
50
|
{children}
|
|
49
|
-
{ripples.map(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
51
|
+
{ripples.map(ripple => (
|
|
52
|
+
<RippleContainer
|
|
53
|
+
$appearance={appearance}
|
|
54
|
+
key={ripple.id}
|
|
55
|
+
style={{
|
|
56
|
+
top: ripple.y - 10,
|
|
57
|
+
left: ripple.x - 10,
|
|
58
|
+
width: 20,
|
|
59
|
+
height: 20
|
|
60
|
+
}}
|
|
61
|
+
onAnimationEnd={() =>
|
|
62
|
+
setRipples(prev => prev.filter(r => r.id !== ripple.id))
|
|
63
|
+
}
|
|
64
|
+
/>
|
|
65
|
+
))}
|
|
66
|
+
</StyledButton>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
66
69
|
|
|
67
|
-
export default IconButton
|
|
70
|
+
export default IconButton
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import styled from 'styled-components'
|
|
2
|
+
import Button from '../Button'
|
|
3
|
+
import { parseColor } from '../../utils'
|
|
4
|
+
|
|
5
|
+
export const WrapperSegmentedButton = styled.div`
|
|
6
|
+
display: flex;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
align-items: center;
|
|
9
|
+
border-radius: 8px;
|
|
10
|
+
width: fit-content;
|
|
11
|
+
`
|
|
12
|
+
|
|
13
|
+
export const LeftButton = styled(Button)`
|
|
14
|
+
border-radius: 4px 0 0 4px;
|
|
15
|
+
box-shadow: none;
|
|
16
|
+
border-right: none;
|
|
17
|
+
|
|
18
|
+
&:disabled {
|
|
19
|
+
border-color: ${({ theme }) => parseColor(theme.colors.neutral500)};
|
|
20
|
+
}
|
|
21
|
+
`
|
|
22
|
+
|
|
23
|
+
export const RightButton = styled(Button)`
|
|
24
|
+
border-radius: 0 4px 4px 0;
|
|
25
|
+
border-left: none;
|
|
26
|
+
&:focus {
|
|
27
|
+
box-shadow: none;
|
|
28
|
+
}
|
|
29
|
+
`
|