w-design-system 0.0.26 → 0.0.28
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/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +33 -19
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/DatePicker/index.d.ts +17 -0
- package/dist/components/DatePicker/index.d.ts.map +1 -0
- package/dist/components/DatePicker/index.js +22 -0
- package/dist/components/DatePicker/index.js.map +1 -0
- package/dist/components/DatePicker/stories.d.ts +8 -0
- package/dist/components/DatePicker/stories.d.ts.map +1 -0
- package/dist/components/DatePicker/stories.js +61 -0
- package/dist/components/DatePicker/stories.js.map +1 -0
- package/dist/components/DateRangePicker/index.d.ts +19 -0
- package/dist/components/DateRangePicker/index.d.ts.map +1 -0
- package/dist/components/DateRangePicker/index.js +159 -0
- package/dist/components/DateRangePicker/index.js.map +1 -0
- package/dist/components/DateRangePicker/stories.d.ts +8 -0
- package/dist/components/DateRangePicker/stories.d.ts.map +1 -0
- package/dist/components/DateRangePicker/stories.js +60 -0
- package/dist/components/DateRangePicker/stories.js.map +1 -0
- package/dist/components/DateRangePicker/styles.d.ts +18 -0
- package/dist/components/DateRangePicker/styles.d.ts.map +1 -0
- package/dist/components/DateRangePicker/styles.js +114 -0
- package/dist/components/DateRangePicker/styles.js.map +1 -0
- package/dist/components/Input/index.d.ts +3 -3
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js +3 -3
- package/dist/components/Paginate/index.d.ts +2 -2
- package/dist/components/Paginate/stories.d.ts +3 -3
- package/dist/components/Select/index.d.ts +20 -0
- package/dist/components/Select/index.d.ts.map +1 -0
- package/dist/components/Select/index.js +68 -0
- package/dist/components/Select/index.js.map +1 -0
- package/dist/components/Select/stories.d.ts +7 -0
- package/dist/components/Select/stories.d.ts.map +1 -0
- package/dist/components/Select/stories.js +48 -0
- package/dist/components/Select/stories.js.map +1 -0
- package/dist/components/Select/styles.d.ts +8 -0
- package/dist/components/Select/styles.d.ts.map +1 -0
- package/dist/components/Select/styles.js +47 -0
- package/dist/components/Select/styles.js.map +1 -0
- package/dist/components/Themes/index.d.ts +1 -0
- package/dist/components/Themes/index.d.ts.map +1 -1
- package/dist/components/Themes/index.js +5 -2
- package/dist/components/Themes/index.js.map +1 -1
- package/dist/components/Types/index.d.ts +6 -1
- package/dist/components/Types/index.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Button/index.tsx +34 -19
- package/src/components/{DateInput → DatePicker}/index.tsx +5 -5
- package/src/components/{DateInput → DatePicker}/stories.tsx +21 -9
- package/src/components/{RangeDateInput → DateRangePicker}/index.tsx +79 -117
- package/src/components/{RangeDateInput → DateRangePicker}/stories.tsx +12 -13
- package/src/components/{DateInput → DateRangePicker}/styles.ts +41 -55
- package/src/components/Input/index.tsx +7 -7
- package/src/components/Paginate/index.tsx +2 -2
- package/src/components/Paginate/stories.tsx +4 -4
- package/src/components/Select/index.tsx +123 -0
- package/src/components/Select/stories.tsx +51 -0
- package/src/components/Select/styles.ts +55 -0
- package/src/components/Themes/index.ts +5 -0
- package/src/components/Types/index.ts +8 -1
- package/src/index.tsx +3 -2
- package/src/components/RangeDateInput/styles.ts +0 -145
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import React, { HTMLAttributes,
|
|
1
|
+
import React, { HTMLAttributes, useEffect, useMemo, useRef, useState } from 'react'
|
|
2
|
+
import { calendarSVG, chevronLeftSVG, chevronRightSVG } from '../../assets/icon'
|
|
3
|
+
import { IconWrapper } from '../IconWrapper'
|
|
4
|
+
import { Select, SelectRef } from '../Select'
|
|
5
|
+
import { theme } from '../Themes'
|
|
2
6
|
import {
|
|
3
7
|
CalendarDay,
|
|
8
|
+
CalendarDaySelectedBackground,
|
|
9
|
+
CalendarDayValue,
|
|
4
10
|
CalendarGrid,
|
|
5
11
|
CalendarHeader,
|
|
6
12
|
CalendarWeekDayLabel,
|
|
7
|
-
Dropdown,
|
|
8
|
-
DropdownWrapper,
|
|
9
|
-
DefaultOptionButton,
|
|
10
|
-
InputDateWrapper,
|
|
11
|
-
CalendarDaySelectedBackground,
|
|
12
|
-
CalendarDayValue,
|
|
13
13
|
} from './styles'
|
|
14
|
-
import { calendarSVG, chevronDownSVG, chevronLeftSVG, chevronRightSVG } from '../../assets/icon'
|
|
15
|
-
import { IconWrapper } from '../IconWrapper'
|
|
16
|
-
import { Input } from '../Input'
|
|
17
|
-
import { theme } from '../Themes'
|
|
18
14
|
|
|
19
|
-
export interface
|
|
15
|
+
export interface DateRangePickerProps extends HTMLAttributes<HTMLDivElement> {
|
|
20
16
|
isRange?: boolean
|
|
21
17
|
placeholder?: string
|
|
22
|
-
label
|
|
23
|
-
|
|
18
|
+
label?: string
|
|
19
|
+
options?: { text: string; id: number }[]
|
|
24
20
|
selectedOption?: number | null
|
|
25
21
|
readonly?: boolean
|
|
26
22
|
disabled?: boolean
|
|
@@ -30,13 +26,6 @@ export interface RangeDateInputProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
30
26
|
onSelectedCustomRange: (start: Date | null, end: Date | null) => void
|
|
31
27
|
}
|
|
32
28
|
|
|
33
|
-
export interface Position {
|
|
34
|
-
x: number
|
|
35
|
-
y: number
|
|
36
|
-
width: number
|
|
37
|
-
height: number
|
|
38
|
-
}
|
|
39
|
-
|
|
40
29
|
interface EmptyDay {
|
|
41
30
|
type: 'empty'
|
|
42
31
|
key: string
|
|
@@ -48,6 +37,8 @@ interface Day {
|
|
|
48
37
|
today: boolean
|
|
49
38
|
selected: boolean
|
|
50
39
|
date: Date
|
|
40
|
+
isFirstSelected: boolean
|
|
41
|
+
isLastSelected: boolean
|
|
51
42
|
}
|
|
52
43
|
|
|
53
44
|
const monthNames = [
|
|
@@ -68,9 +59,9 @@ const monthNames = [
|
|
|
68
59
|
const weekDays = ['DOM', 'SEG', 'TER', 'QUA', 'QUI', 'SEX', 'SAB']
|
|
69
60
|
|
|
70
61
|
type DayType = EmptyDay | Day
|
|
71
|
-
export const
|
|
62
|
+
export const DateRangePicker: React.FC<DateRangePickerProps> = ({
|
|
72
63
|
label,
|
|
73
|
-
|
|
64
|
+
options,
|
|
74
65
|
selectedOption,
|
|
75
66
|
onSelectedOptionChange,
|
|
76
67
|
placeholder,
|
|
@@ -83,8 +74,7 @@ export const RangeDateInput: React.FC<RangeDateInputProps> = ({
|
|
|
83
74
|
const [currentYear, setCurrentYear] = useState(0)
|
|
84
75
|
const [currentMonth, setCurrentMonth] = useState(0)
|
|
85
76
|
const [currentMouseHoverDate, setCurrentMouseHoverDate] = useState<Date | null>(null)
|
|
86
|
-
const
|
|
87
|
-
const wrapperRef = useRef<HTMLDivElement>(null)
|
|
77
|
+
const selectRef = useRef<SelectRef>(null)
|
|
88
78
|
|
|
89
79
|
useEffect(() => {
|
|
90
80
|
const date = new Date()
|
|
@@ -104,7 +94,7 @@ export const RangeDateInput: React.FC<RangeDateInputProps> = ({
|
|
|
104
94
|
if (onSelectedOptionChange) {
|
|
105
95
|
onSelectedOptionChange(option)
|
|
106
96
|
if (onSelectedCustomRange) onSelectedCustomRange(null, null)
|
|
107
|
-
setOpen(false)
|
|
97
|
+
selectRef.current?.setOpen(false)
|
|
108
98
|
}
|
|
109
99
|
}
|
|
110
100
|
|
|
@@ -113,7 +103,7 @@ export const RangeDateInput: React.FC<RangeDateInputProps> = ({
|
|
|
113
103
|
if (!startCustomDate) {
|
|
114
104
|
onSelectedCustomRange && onSelectedCustomRange(date, null)
|
|
115
105
|
currentMouseHoverDate && setCurrentMouseHoverDate(date)
|
|
116
|
-
if (isRange === false) setOpen(false)
|
|
106
|
+
if (isRange === false) selectRef.current?.setOpen(false)
|
|
117
107
|
} else if (!endCustomDate) {
|
|
118
108
|
let firstDate = startCustomDate
|
|
119
109
|
let secondDate = date
|
|
@@ -123,9 +113,9 @@ export const RangeDateInput: React.FC<RangeDateInputProps> = ({
|
|
|
123
113
|
secondDate = temp
|
|
124
114
|
}
|
|
125
115
|
onSelectedCustomRange && onSelectedCustomRange(firstDate, secondDate)
|
|
126
|
-
setOpen(false)
|
|
116
|
+
selectRef.current?.setOpen(false)
|
|
127
117
|
} else {
|
|
128
|
-
if (isRange === false) setOpen(false)
|
|
118
|
+
if (isRange === false) selectRef.current?.setOpen(false)
|
|
129
119
|
onSelectedCustomRange && onSelectedCustomRange(date, null)
|
|
130
120
|
setCurrentMouseHoverDate(date)
|
|
131
121
|
}
|
|
@@ -161,12 +151,14 @@ export const RangeDateInput: React.FC<RangeDateInputProps> = ({
|
|
|
161
151
|
today: day.toDateString() === todayString,
|
|
162
152
|
selected: isSelected,
|
|
163
153
|
date: new Date(day),
|
|
154
|
+
isFirstSelected: (firstDate && firstDate.toDateString() === day.toDateString()) ?? false,
|
|
155
|
+
isLastSelected: (secondDate && secondDate.toDateString() === day.toDateString()) ?? false,
|
|
164
156
|
})
|
|
165
157
|
day.setDate(day.getDate() + 1)
|
|
166
158
|
}
|
|
167
159
|
|
|
168
160
|
const value = useMemo(() => {
|
|
169
|
-
if (selectedOption !== null) return
|
|
161
|
+
if (selectedOption !== null) return ''
|
|
170
162
|
if (!firstDate && !secondDate) return ''
|
|
171
163
|
if (firstDate && !secondDate) return firstDate.toLocaleDateString()
|
|
172
164
|
|
|
@@ -178,95 +170,65 @@ export const RangeDateInput: React.FC<RangeDateInputProps> = ({
|
|
|
178
170
|
return ''
|
|
179
171
|
}, [selectedOption, firstDate, secondDate])
|
|
180
172
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (element === wrapperRef.current) break
|
|
188
|
-
element = element.parentElement
|
|
189
|
-
}
|
|
190
|
-
if (element === document.body.parentElement) {
|
|
191
|
-
setOpen(false)
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
document.addEventListener('click', handler)
|
|
195
|
-
|
|
196
|
-
return () => {
|
|
197
|
-
document.removeEventListener('click', handler)
|
|
173
|
+
placeholder = placeholder ?? 'Selecione um período'
|
|
174
|
+
const { customOptionId, optionComputed } = useMemo(() => {
|
|
175
|
+
if (options && options.length > 0) {
|
|
176
|
+
const customOptionId = Math.max(...options.map(option => option.id ?? 0)) + 1
|
|
177
|
+
const optionComputed = [...options, { text: 'Período Personalizado', id: customOptionId }]
|
|
178
|
+
return { customOptionId, optionComputed }
|
|
198
179
|
}
|
|
199
|
-
|
|
180
|
+
return { customOptionId: 0, optionComputed: [] }
|
|
181
|
+
}, [selectedOption, options])
|
|
200
182
|
|
|
201
|
-
placeholder = placeholder ?? 'Selecione um período'
|
|
202
183
|
return (
|
|
203
|
-
<
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
<
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
<
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
{
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
return (
|
|
254
|
-
<CalendarDay
|
|
255
|
-
key={day.value}
|
|
256
|
-
today={day.today}
|
|
257
|
-
onClick={() => onDayClick(day.date)}
|
|
258
|
-
onMouseEnter={() => onMouseEnter(day.date)}
|
|
259
|
-
onMouseLeave={() => onMouseLeave(day.date)}
|
|
260
|
-
>
|
|
261
|
-
<CalendarDaySelectedBackground selected={day.selected} today={day.today} />
|
|
262
|
-
<CalendarDayValue>{day.value}</CalendarDayValue>
|
|
263
|
-
</CalendarDay>
|
|
264
|
-
)
|
|
265
|
-
})}
|
|
266
|
-
</CalendarGrid>
|
|
267
|
-
</Dropdown>
|
|
268
|
-
</DropdownWrapper>
|
|
269
|
-
)}
|
|
270
|
-
</InputDateWrapper>
|
|
184
|
+
<Select
|
|
185
|
+
ref={selectRef}
|
|
186
|
+
placeholder={placeholder}
|
|
187
|
+
label={label}
|
|
188
|
+
value={value}
|
|
189
|
+
leftIcon={
|
|
190
|
+
<IconWrapper className="icon" src={calendarSVG} width="20px" height="20px" color={theme.colors.shade30} />
|
|
191
|
+
}
|
|
192
|
+
options={optionComputed}
|
|
193
|
+
selectedOption={selectedOption ?? (firstDate ? customOptionId : null)}
|
|
194
|
+
onOptionChange={onSelectedOptionChangeHandler}
|
|
195
|
+
{...props}
|
|
196
|
+
>
|
|
197
|
+
<CalendarHeader>
|
|
198
|
+
<IconWrapper className="icon" src={chevronLeftSVG} width="14px" onClick={() => changeMonth(-1)} />
|
|
199
|
+
{monthNames[currentMonth]} {currentYear}
|
|
200
|
+
<IconWrapper className="icon" src={chevronRightSVG} width="14px" onClick={() => changeMonth(1)} />
|
|
201
|
+
</CalendarHeader>
|
|
202
|
+
|
|
203
|
+
<CalendarGrid>
|
|
204
|
+
{weekDays.map(weekDay => (
|
|
205
|
+
<CalendarWeekDayLabel key={weekDay}>{weekDay}</CalendarWeekDayLabel>
|
|
206
|
+
))}
|
|
207
|
+
{days.map(day => {
|
|
208
|
+
if (day.type === 'empty') {
|
|
209
|
+
return <div key={day.key}></div>
|
|
210
|
+
}
|
|
211
|
+
return (
|
|
212
|
+
<CalendarDay
|
|
213
|
+
isFirstSelected={day.isFirstSelected}
|
|
214
|
+
isLastSelected={day.isLastSelected}
|
|
215
|
+
key={day.value}
|
|
216
|
+
today={day.today}
|
|
217
|
+
onClick={() => onDayClick(day.date)}
|
|
218
|
+
onMouseEnter={() => onMouseEnter(day.date)}
|
|
219
|
+
onMouseLeave={() => onMouseLeave(day.date)}
|
|
220
|
+
>
|
|
221
|
+
<CalendarDaySelectedBackground
|
|
222
|
+
isFirstSelected={day.isFirstSelected}
|
|
223
|
+
isLastSelected={day.isLastSelected}
|
|
224
|
+
selected={day.selected}
|
|
225
|
+
today={day.today}
|
|
226
|
+
/>
|
|
227
|
+
<CalendarDayValue>{day.value}</CalendarDayValue>
|
|
228
|
+
</CalendarDay>
|
|
229
|
+
)
|
|
230
|
+
})}
|
|
231
|
+
</CalendarGrid>
|
|
232
|
+
</Select>
|
|
271
233
|
)
|
|
272
234
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react'
|
|
2
|
-
import { RangeDateInput } from './index'
|
|
3
|
-
import { VARIANTS_TYPES } from '../../utils/constanst'
|
|
4
2
|
import React from 'react'
|
|
3
|
+
import { DateRangePicker, DateRangePickerProps } from './index'
|
|
5
4
|
|
|
6
|
-
const meta: Meta<typeof
|
|
7
|
-
title: 'Components/
|
|
8
|
-
component:
|
|
5
|
+
const meta: Meta<typeof DateRangePicker> = {
|
|
6
|
+
title: 'Components/DateRangePicker',
|
|
7
|
+
component: DateRangePicker,
|
|
9
8
|
tags: ['autodocs'],
|
|
10
9
|
argTypes: {
|
|
11
10
|
placeholder: { control: 'text' },
|
|
@@ -18,18 +17,19 @@ const meta: Meta<typeof RangeDateInput> = {
|
|
|
18
17
|
onSelectedOptionChange: { action: 'selectedOptionChange' },
|
|
19
18
|
onSelectedCustomRange: { action: 'selectedCustomRange' },
|
|
20
19
|
},
|
|
21
|
-
} satisfies Meta<typeof
|
|
20
|
+
} satisfies Meta<typeof DateRangePicker>
|
|
22
21
|
|
|
23
22
|
export default meta
|
|
24
|
-
type Story = StoryObj<typeof
|
|
23
|
+
type Story = StoryObj<typeof DateRangePicker>
|
|
25
24
|
|
|
26
|
-
const ComponentWrapper = ({
|
|
25
|
+
const ComponentWrapper = ({ options, ...args }: Partial<DateRangePickerProps>) => {
|
|
27
26
|
const [selectedOption, setSelectOption] = React.useState<number | null>(null)
|
|
28
27
|
const [startDate, setStartDate] = React.useState<Date | null>(null)
|
|
29
28
|
const [endDate, setEndDate] = React.useState<Date | null>(null)
|
|
30
29
|
|
|
31
30
|
return (
|
|
32
|
-
<
|
|
31
|
+
<DateRangePicker
|
|
32
|
+
{...args}
|
|
33
33
|
selectedOption={selectedOption}
|
|
34
34
|
startCustomDate={startDate}
|
|
35
35
|
endCustomDate={endDate}
|
|
@@ -38,8 +38,8 @@ const ComponentWrapper = ({ defaultOptions, ...args }: any) => {
|
|
|
38
38
|
setEndDate(end)
|
|
39
39
|
}}
|
|
40
40
|
onSelectedOptionChange={option => setSelectOption(option)}
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
options={
|
|
42
|
+
options ?? [
|
|
43
43
|
{
|
|
44
44
|
text: 'Últimos 30 dias',
|
|
45
45
|
id: 30,
|
|
@@ -54,7 +54,6 @@ const ComponentWrapper = ({ defaultOptions, ...args }: any) => {
|
|
|
54
54
|
},
|
|
55
55
|
]
|
|
56
56
|
}
|
|
57
|
-
{...args}
|
|
58
57
|
/>
|
|
59
58
|
)
|
|
60
59
|
}
|
|
@@ -64,5 +63,5 @@ export const SelecionarIntervaloDeDatas: Story = {
|
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
export const SelecionarIntervaloDeDatasSimples: Story = {
|
|
67
|
-
render: args => <ComponentWrapper
|
|
66
|
+
render: args => <ComponentWrapper options={[]} />,
|
|
68
67
|
}
|
|
@@ -1,31 +1,6 @@
|
|
|
1
1
|
import styled from 'styled-components'
|
|
2
2
|
import { theme } from '../Themes'
|
|
3
3
|
|
|
4
|
-
export const InputDateWrapper = styled.div`
|
|
5
|
-
position: relative;
|
|
6
|
-
.icon {
|
|
7
|
-
transition: transform 0.3s;
|
|
8
|
-
}
|
|
9
|
-
.icon-rotate {
|
|
10
|
-
transform: rotate(180deg) translateY(5px);
|
|
11
|
-
}
|
|
12
|
-
`
|
|
13
|
-
|
|
14
|
-
export const Dropdown = styled.div`
|
|
15
|
-
position: absolute;
|
|
16
|
-
width: 252px;
|
|
17
|
-
padding: 16px;
|
|
18
|
-
z-index: 1;
|
|
19
|
-
border-radius: 4px;
|
|
20
|
-
border: 1px solid ${theme.colors.shade20};
|
|
21
|
-
margin-top: 7px;
|
|
22
|
-
box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.1);
|
|
23
|
-
`
|
|
24
|
-
|
|
25
|
-
export const DropdownWrapper = styled.div`
|
|
26
|
-
position: relative;
|
|
27
|
-
`
|
|
28
|
-
|
|
29
4
|
export const CalendarGrid = styled.div`
|
|
30
5
|
display: grid;
|
|
31
6
|
font-family: 'Nunito Sans', sans-serif;
|
|
@@ -47,33 +22,6 @@ export const CalendarWeekDayLabel = styled.div`
|
|
|
47
22
|
margin-bottom: 4px;
|
|
48
23
|
`
|
|
49
24
|
|
|
50
|
-
export interface DefaultOptionButtonProps {
|
|
51
|
-
selected: boolean
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export const DefaultOptionButton = styled.button<DefaultOptionButtonProps>`
|
|
55
|
-
background-color: transparent;
|
|
56
|
-
border: none;
|
|
57
|
-
font-size: ${theme.paragraph.medium};
|
|
58
|
-
font-family: 'Nunito Sans', sans-serif;
|
|
59
|
-
color: ${({ selected }) => (selected ? theme.colors.cyan30 : theme.colors.shade40)};
|
|
60
|
-
cursor: pointer;
|
|
61
|
-
padding: 0;
|
|
62
|
-
width: 100%;
|
|
63
|
-
text-align: left;
|
|
64
|
-
height: 46px;
|
|
65
|
-
display: flex;
|
|
66
|
-
align-items: center;
|
|
67
|
-
|
|
68
|
-
&:not(:last-child) {
|
|
69
|
-
border-bottom: 1px solid ${theme.colors.shade10};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
&:hover {
|
|
73
|
-
color: ${theme.colors.cyan30};
|
|
74
|
-
}
|
|
75
|
-
`
|
|
76
|
-
|
|
77
25
|
export const CalendarHeader = styled.div`
|
|
78
26
|
display: flex;
|
|
79
27
|
justify-content: space-between;
|
|
@@ -102,31 +50,68 @@ export const CalendarHeader = styled.div`
|
|
|
102
50
|
`
|
|
103
51
|
export interface CalendarDayProps {
|
|
104
52
|
today: boolean
|
|
53
|
+
isFirstSelected: boolean
|
|
54
|
+
isLastSelected: boolean
|
|
105
55
|
}
|
|
106
56
|
|
|
107
57
|
export const CalendarDay = styled.div<CalendarDayProps>`
|
|
108
58
|
position: relative;
|
|
109
59
|
cursor: pointer;
|
|
110
|
-
color: ${({ today }) => (today ? theme.colors.white : theme.colors.shade50)};
|
|
111
60
|
width: 36px;
|
|
112
61
|
height: 36px;
|
|
62
|
+
box-sizing: border-box;
|
|
63
|
+
color: ${({ isFirstSelected, isLastSelected }) =>
|
|
64
|
+
isFirstSelected || isLastSelected ? theme.colors.white : theme.colors.shade50};
|
|
65
|
+
|
|
66
|
+
&:before {
|
|
67
|
+
position: absolute;
|
|
68
|
+
content: '';
|
|
69
|
+
inset: 0;
|
|
70
|
+
border-radius: 50%;
|
|
71
|
+
pointer-events: none;
|
|
72
|
+
|
|
73
|
+
${({ today, isFirstSelected, isLastSelected }) =>
|
|
74
|
+
today && !(isFirstSelected || isLastSelected) ? `border: 1px solid ${theme.colors.cyan40}` : ''};
|
|
75
|
+
}
|
|
113
76
|
`
|
|
114
77
|
|
|
115
78
|
export interface CalendarDaySelectedBackgroundProps {
|
|
116
79
|
today: boolean
|
|
80
|
+
isFirstSelected: boolean
|
|
81
|
+
isLastSelected: boolean
|
|
117
82
|
selected: boolean
|
|
118
83
|
}
|
|
119
84
|
export const CalendarDaySelectedBackground = styled.div<CalendarDaySelectedBackgroundProps>`
|
|
120
85
|
position: absolute;
|
|
121
|
-
background-color: ${({ selected }) => selected &&
|
|
86
|
+
background-color: ${({ selected }) => selected && theme.colors.cyan30opacity16};
|
|
122
87
|
width: 100%;
|
|
123
88
|
height: 100%;
|
|
124
89
|
inset: 0;
|
|
90
|
+
|
|
91
|
+
border-radius: ${({ isFirstSelected, isLastSelected }) => {
|
|
92
|
+
if (isFirstSelected && isLastSelected) return '50%'
|
|
93
|
+
if (isFirstSelected) return '50% 0 0 50%'
|
|
94
|
+
if (isLastSelected) return '0 50% 50% 0'
|
|
95
|
+
return '0'
|
|
96
|
+
}};
|
|
97
|
+
|
|
98
|
+
&:hover {
|
|
99
|
+
border-radius: ${({ isFirstSelected, isLastSelected, selected }) => {
|
|
100
|
+
if (isFirstSelected && isLastSelected) return '50%'
|
|
101
|
+
if (isFirstSelected) return '50% 0 0 50%'
|
|
102
|
+
if (isLastSelected) return '0 50% 50% 0'
|
|
103
|
+
if (selected) return '0'
|
|
104
|
+
return '50%'
|
|
105
|
+
}};
|
|
106
|
+
background-color: ${theme.colors.cyan30opacity16};
|
|
107
|
+
}
|
|
108
|
+
|
|
125
109
|
&::before {
|
|
126
110
|
content: '';
|
|
127
111
|
border-radius: 50%;
|
|
112
|
+
background-color: ${({ isFirstSelected, isLastSelected }) =>
|
|
113
|
+
isFirstSelected || isLastSelected ? theme.colors.cyan40 : 'transparent'};
|
|
128
114
|
position: absolute;
|
|
129
|
-
background-color: ${({ today }) => (today ? theme.colors.cyan40 : 'transparent')};
|
|
130
115
|
inset: 0;
|
|
131
116
|
}
|
|
132
117
|
`
|
|
@@ -136,4 +121,5 @@ export const CalendarDayValue = styled.div`
|
|
|
136
121
|
display: flex;
|
|
137
122
|
align-items: center;
|
|
138
123
|
justify-content: center;
|
|
124
|
+
pointer-events: none;
|
|
139
125
|
`
|
|
@@ -3,8 +3,9 @@ import { InputWrapper, StyledInput, StyledInputBorder, StyledInputContent, Style
|
|
|
3
3
|
|
|
4
4
|
export interface InputProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
5
|
placeholder?: string
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
rightIcon?: ReactNode
|
|
7
|
+
leftIcon?: ReactNode
|
|
8
|
+
label?: string
|
|
8
9
|
value?: string
|
|
9
10
|
readonly?: boolean
|
|
10
11
|
disabled?: boolean
|
|
@@ -12,7 +13,6 @@ export interface InputProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
12
13
|
onInput?: (e: React.FormEvent<HTMLInputElement>) => void
|
|
13
14
|
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void
|
|
14
15
|
onKeyUp?: (e: React.KeyboardEvent<HTMLInputElement>) => void
|
|
15
|
-
iconRight?: ReactNode
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export interface Position {
|
|
@@ -31,8 +31,8 @@ export const Input: React.FC<InputProps> = ({
|
|
|
31
31
|
onKeyDown,
|
|
32
32
|
disabled,
|
|
33
33
|
onKeyUp,
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
leftIcon,
|
|
35
|
+
rightIcon,
|
|
36
36
|
...props
|
|
37
37
|
}) => {
|
|
38
38
|
const id = useId()
|
|
@@ -95,7 +95,7 @@ export const Input: React.FC<InputProps> = ({
|
|
|
95
95
|
<StyledLabel htmlFor={id} ref={labelRef}>
|
|
96
96
|
{label}
|
|
97
97
|
</StyledLabel>
|
|
98
|
-
{
|
|
98
|
+
{leftIcon}
|
|
99
99
|
<StyledInput
|
|
100
100
|
id={id}
|
|
101
101
|
disabled={disabled}
|
|
@@ -108,7 +108,7 @@ export const Input: React.FC<InputProps> = ({
|
|
|
108
108
|
onKeyUp={onKeyUp}
|
|
109
109
|
readOnly={readonly}
|
|
110
110
|
/>
|
|
111
|
-
{
|
|
111
|
+
{rightIcon}
|
|
112
112
|
</StyledInputContent>
|
|
113
113
|
</InputWrapper>
|
|
114
114
|
)
|
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
|
2
2
|
import { Container } from './styles'
|
|
3
3
|
import { IconWrapper } from '../IconWrapper'
|
|
4
4
|
import { chevronLeftSVG, chevronRightSVG } from '../../assets/icon'
|
|
5
|
-
export type
|
|
5
|
+
export type PaginateProps = {
|
|
6
6
|
currentPage: number
|
|
7
7
|
itemCount: number
|
|
8
8
|
itemsPerPage?: number
|
|
@@ -16,7 +16,7 @@ export const Paginate = ({
|
|
|
16
16
|
onChangePage,
|
|
17
17
|
itemsPerPage,
|
|
18
18
|
onChangeItemsPerPage,
|
|
19
|
-
}:
|
|
19
|
+
}: PaginateProps) => {
|
|
20
20
|
// Se itemsPerPage for undefined, o valor default e 20
|
|
21
21
|
let itemsPerPageValue = itemsPerPage || 20
|
|
22
22
|
|
|
@@ -3,9 +3,9 @@ import React, { useState } from 'react'
|
|
|
3
3
|
|
|
4
4
|
import { action } from '@storybook/addon-actions'
|
|
5
5
|
import { fn } from '@storybook/test'
|
|
6
|
-
import { Paginate,
|
|
6
|
+
import { Paginate, PaginateProps } from '.'
|
|
7
7
|
|
|
8
|
-
const meta: Meta<
|
|
8
|
+
const meta: Meta<PaginateProps> = {
|
|
9
9
|
title: 'Components/Paginate',
|
|
10
10
|
component: Paginate,
|
|
11
11
|
tags: ['autodocs'],
|
|
@@ -20,7 +20,7 @@ const meta: Meta<PropsPaginate> = {
|
|
|
20
20
|
|
|
21
21
|
export default meta
|
|
22
22
|
|
|
23
|
-
const NewPaginate = (args:
|
|
23
|
+
const NewPaginate = (args: PaginateProps) => {
|
|
24
24
|
const [currentPage, setCurrentPage] = useState(args.currentPage)
|
|
25
25
|
const [itemCount, setItemCount] = useState(args.itemCount)
|
|
26
26
|
const [itemsPerPage, setItemsPerPage] = useState(args.itemsPerPage)
|
|
@@ -46,7 +46,7 @@ const NewPaginate = (args: PropsPaginate) => {
|
|
|
46
46
|
)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export const Default: StoryObj<
|
|
49
|
+
export const Default: StoryObj<PaginateProps> = {
|
|
50
50
|
render: args => {
|
|
51
51
|
return <NewPaginate {...args} />
|
|
52
52
|
},
|