@xjur-ui/react 2.1.1 → 2.2.0

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 (108) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/components/steps/index.js +1 -1
  3. package/package.json +7 -4
  4. package/.turbo/turbo-build.log +0 -419
  5. package/eslint.config.js +0 -10
  6. package/postcss.config.js +0 -5
  7. package/prettier.config.js +0 -7
  8. package/src/components/avatar-group.tsx +0 -76
  9. package/src/components/avatar.tsx +0 -54
  10. package/src/components/badge.tsx +0 -40
  11. package/src/components/breadcrumb.tsx +0 -119
  12. package/src/components/chip.tsx +0 -117
  13. package/src/components/collapsible.tsx +0 -35
  14. package/src/components/controls/button.tsx +0 -107
  15. package/src/components/controls/calendar.tsx +0 -124
  16. package/src/components/controls/checkbox.tsx +0 -57
  17. package/src/components/controls/context/field.context.ts +0 -27
  18. package/src/components/controls/date-picker.tsx +0 -199
  19. package/src/components/controls/floating-label.tsx +0 -60
  20. package/src/components/controls/input.tsx +0 -237
  21. package/src/components/controls/otp-input.tsx +0 -45
  22. package/src/components/controls/radio.tsx +0 -74
  23. package/src/components/controls/rich-editor.tsx +0 -372
  24. package/src/components/controls/search-input.tsx +0 -154
  25. package/src/components/controls/search-selector.tsx +0 -98
  26. package/src/components/controls/select.tsx +0 -274
  27. package/src/components/controls/switch.tsx +0 -31
  28. package/src/components/custom/pessoa/index.ts +0 -9
  29. package/src/components/custom/pessoa/pessoa-add-button.tsx +0 -35
  30. package/src/components/custom/pessoa/pessoa-body.tsx +0 -22
  31. package/src/components/custom/pessoa/pessoa-close-button.tsx +0 -13
  32. package/src/components/custom/pessoa/pessoa-content.tsx +0 -25
  33. package/src/components/custom/pessoa/pessoa-footer.tsx +0 -15
  34. package/src/components/custom/pessoa/pessoa-header.tsx +0 -35
  35. package/src/components/custom/pessoa/pessoa-trigger.tsx +0 -25
  36. package/src/components/custom/pessoa/pessoa.context.tsx +0 -73
  37. package/src/components/custom/pessoa/pessoa.tsx +0 -35
  38. package/src/components/dialog.tsx +0 -242
  39. package/src/components/divider.tsx +0 -24
  40. package/src/components/drag-and-drop/drag-handle.tsx +0 -46
  41. package/src/components/drag-and-drop/drag-list-item.tsx +0 -91
  42. package/src/components/drag-and-drop/drag-list.tsx +0 -47
  43. package/src/components/drag-and-drop/drag-root.tsx +0 -30
  44. package/src/components/drag-and-drop/index.ts +0 -39
  45. package/src/components/drag-and-drop/types/drag-item.ts +0 -7
  46. package/src/components/dropdown-menu.tsx +0 -101
  47. package/src/components/full-calendar/calendar-add-event.tsx +0 -15
  48. package/src/components/full-calendar/calendar-body.tsx +0 -12
  49. package/src/components/full-calendar/calendar-cell.tsx +0 -120
  50. package/src/components/full-calendar/calendar-day-view.tsx +0 -76
  51. package/src/components/full-calendar/calendar-event.tsx +0 -178
  52. package/src/components/full-calendar/calendar-header.tsx +0 -14
  53. package/src/components/full-calendar/calendar-month-view.tsx +0 -69
  54. package/src/components/full-calendar/calendar-more-events-dropdown.tsx +0 -39
  55. package/src/components/full-calendar/calendar-navigator.tsx +0 -86
  56. package/src/components/full-calendar/calendar-root.tsx +0 -165
  57. package/src/components/full-calendar/calendar-today-button.tsx +0 -21
  58. package/src/components/full-calendar/calendar-toggle-view.tsx +0 -61
  59. package/src/components/full-calendar/calendar-view-renderer.tsx +0 -19
  60. package/src/components/full-calendar/calendar-week-day.tsx +0 -49
  61. package/src/components/full-calendar/calendar-week-view.tsx +0 -88
  62. package/src/components/full-calendar/helpers/calendar.ts +0 -158
  63. package/src/components/full-calendar/index.ts +0 -16
  64. package/src/components/full-calendar/types/calendar-cell.ts +0 -4
  65. package/src/components/full-calendar/types/calendar-event.ts +0 -7
  66. package/src/components/full-calendar/types/calendar-view.ts +0 -1
  67. package/src/components/full-calendar/types/calendar-week-hour.ts +0 -4
  68. package/src/components/horizontal-scroll.tsx +0 -159
  69. package/src/components/icon.tsx +0 -29
  70. package/src/components/list.tsx +0 -111
  71. package/src/components/logo.tsx +0 -44
  72. package/src/components/selection-bar.tsx +0 -273
  73. package/src/components/sheet.tsx +0 -150
  74. package/src/components/skeleton.tsx +0 -12
  75. package/src/components/status.tsx +0 -43
  76. package/src/components/steps/index.ts +0 -6
  77. package/src/components/steps/step.tsx +0 -23
  78. package/src/components/steps/steps-action.tsx +0 -65
  79. package/src/components/steps/steps-content.tsx +0 -12
  80. package/src/components/steps/steps-context.tsx +0 -121
  81. package/src/components/steps/steps-navigation.tsx +0 -80
  82. package/src/components/steps/steps-root.tsx +0 -9
  83. package/src/components/table/index.ts +0 -8
  84. package/src/components/table/table-body.tsx +0 -17
  85. package/src/components/table/table-cell.tsx +0 -14
  86. package/src/components/table/table-footer.tsx +0 -17
  87. package/src/components/table/table-head.tsx +0 -31
  88. package/src/components/table/table-header.tsx +0 -17
  89. package/src/components/table/table-row.tsx +0 -21
  90. package/src/components/table/table-sort.tsx +0 -34
  91. package/src/components/table/table.tsx +0 -16
  92. package/src/components/tabs.tsx +0 -72
  93. package/src/components/tag.tsx +0 -99
  94. package/src/components/tooltip.tsx +0 -63
  95. package/src/components/typography.tsx +0 -85
  96. package/src/components/upload.tsx +0 -647
  97. package/src/hooks/index.ts +0 -1
  98. package/src/hooks/use-os.ts +0 -32
  99. package/src/index.css +0 -5
  100. package/src/resources/icons.ts +0 -154
  101. package/src/resources/input-mask.ts +0 -91
  102. package/src/resources/logo/horizontal.tsx +0 -70
  103. package/src/resources/logo/icon.tsx +0 -54
  104. package/src/resources/logo/index.tsx +0 -33
  105. package/src/resources/logo/vertical.tsx +0 -70
  106. package/src/types.d.ts +0 -4
  107. package/tsconfig.json +0 -4
  108. package/tsup.config.ts +0 -30
@@ -1,120 +0,0 @@
1
- import { Fragment, useMemo } from 'react'
2
- import { useDroppable } from '@dnd-kit/core'
3
- import { cx, tv } from '@xjur-ui/util'
4
- import { isPast } from 'date-fns'
5
- import { Typography } from '../typography'
6
- import { Button } from '../controls/button'
7
- import { Icon } from '../icon'
8
- import { isToday } from './helpers/calendar'
9
- import { useFullCalendar } from './calendar-root'
10
- import type { ICalendarCell } from './types/calendar-cell'
11
- import type { ICalendarEvent } from './types/calendar-event'
12
- import { CalendarMoreEventsDropdown } from './calendar-more-events-dropdown'
13
-
14
- interface CalendarCellProps {
15
- events: ICalendarEvent[]
16
- cell: ICalendarCell
17
- }
18
-
19
- const calendarCellVariants = tv({
20
- base: 'group/calendar-cell p-small flex flex-col gap-small-1x w-full bg-layer-2-idle ',
21
- variants: {
22
- type: {
23
- month: 'h-[212px]',
24
- week: 'min-h-[64px] max-h-[212px]',
25
- day: 'min-h-[64px] max-h-[212px]'
26
- }
27
- }
28
- })
29
-
30
- export function CalendarCell({ cell, events }: CalendarCellProps) {
31
- const { date, type } = cell
32
-
33
- const { renderEvent, activeEventId, onAddEvent, disableEventCreationInPast } =
34
- useFullCalendar()
35
- const eventsToShow = useMemo(() => events.slice(0, 2), [events])
36
- const hasMore = events.length >= 3
37
-
38
- const { isOver, setNodeRef } = useDroppable({
39
- id: `calendar-cell-${type}-${date.toISOString()}`,
40
- data: {
41
- date,
42
- type
43
- }
44
- })
45
-
46
- const isDraggingInCell = useMemo(() => {
47
- const cellEvent = events.find(event => event.id === activeEventId)
48
-
49
- if (!cellEvent) return false
50
-
51
- const formatDate = (date: Date) => {
52
- return date.toLocaleDateString('pt-BR', {
53
- year: 'numeric',
54
- month: '2-digit',
55
- day: '2-digit'
56
- })
57
- }
58
-
59
- const cellDate = formatDate(date)
60
- const cellEventDate = formatDate(cellEvent.eventDate)
61
-
62
- return cellDate === cellEventDate
63
- }, [activeEventId, date, events])
64
-
65
- const calendarCellClassNames = calendarCellVariants({ type })
66
-
67
- const disableEventCreation = useMemo(
68
- () => disableEventCreationInPast && isPast(date) && !isToday(date),
69
- [disableEventCreationInPast, date]
70
- )
71
-
72
- return (
73
- <div
74
- className={calendarCellClassNames}
75
- data-slot="calendar-cell"
76
- ref={setNodeRef}
77
- >
78
- {type === 'month' && (
79
- <div className="flex items-center justify-center">
80
- <div
81
- className={cx(
82
- 'size-large-2x rounded-circle bg-layer-2-idle flex items-center justify-center',
83
- isToday(date) && 'bg-primary-idle text-neutral-label'
84
- )}
85
- >
86
- <Typography size="sm" variant="label" weight="medium">
87
- {cell.date.getDate()}
88
- </Typography>
89
- </div>
90
- </div>
91
- )}
92
-
93
- <div className="gap-small-1x flex flex-col">
94
- {eventsToShow.map(event => (
95
- <Fragment key={event.id}>{renderEvent(event)}</Fragment>
96
- ))}
97
-
98
- {isOver && eventsToShow.length < 2 && !isDraggingInCell && (
99
- <div className="border-border-layer-4 rounded-small-2x h-[68px] w-full border border-dashed" />
100
- )}
101
- </div>
102
-
103
- <div className="mt-auto flex items-center justify-between">
104
- {hasMore && <CalendarMoreEventsDropdown events={events.slice(2)} />}
105
-
106
- {onAddEvent && !disableEventCreation && (
107
- <div className="invisible ml-auto transition-opacity duration-100 ease-in-out group-hover/calendar-cell:visible">
108
- <Button
109
- size="icon_sm"
110
- variant="outlined"
111
- onClick={() => onAddEvent(date)}
112
- >
113
- <Icon className="text-icon-neutral-3" name="add" />
114
- </Button>
115
- </div>
116
- )}
117
- </div>
118
- </div>
119
- )
120
- }
@@ -1,76 +0,0 @@
1
- import { useCallback } from 'react'
2
- import { cx } from '@xjur-ui/util'
3
- import { setHours } from 'date-fns'
4
- import { Typography } from '../typography'
5
- import { WEEK_HOURS, getEventsForDayAndHour } from './helpers/calendar'
6
- import { useFullCalendar } from './calendar-root'
7
- import { CalendarWeekDay } from './calendar-week-day'
8
- import { CalendarCell } from './calendar-cell'
9
- import type { ICalendarCell } from './types/calendar-cell'
10
-
11
- export function CalendarDayView() {
12
- const { selectedDate, events } = useFullCalendar()
13
-
14
- const getEventsForDayAndHourCallback = useCallback(
15
- (date: Date, hour: number) => {
16
- return getEventsForDayAndHour(events, date, hour)
17
- },
18
- [events]
19
- )
20
-
21
- const cellsWithHour = useCallback((cell: ICalendarCell, hour: number) => {
22
- return {
23
- ...cell,
24
- date: setHours(cell.date, hour)
25
- }
26
- }, [])
27
-
28
- return (
29
- <div className="bg-layer-2-hover rounded-small-1x border-border-layer-2 scrollbar-hide h-full w-full border">
30
- <div className="flex flex-1 flex-col">
31
- <div
32
- className="bg-layer-2-hover sticky top-0 z-10 flex w-full"
33
- data-slot="week-header"
34
- >
35
- <div className="w-[64px]" />
36
- <CalendarWeekDay
37
- className="border-border-layer-2 items-start border-l"
38
- date={selectedDate}
39
- />
40
- </div>
41
-
42
- <div className="overflow-hidden">
43
- {WEEK_HOURS.map(({ hour, label }) => (
44
- <div className="flex items-start" key={hour}>
45
- <div className="px-small flex h-full w-[64px] items-start justify-end">
46
- <Typography size="sm-1x" variant="label" weight="medium">
47
- {label}
48
- </Typography>
49
- </div>
50
-
51
- <div
52
- className={cx(
53
- 'flex flex-1',
54
- '[&>*]:border-border-layer-2',
55
- '[&>*]:border-t',
56
- '[&>*]:border-l'
57
- )}
58
- >
59
- <CalendarCell
60
- cell={cellsWithHour(
61
- {
62
- date: selectedDate,
63
- type: 'day'
64
- },
65
- hour
66
- )}
67
- events={getEventsForDayAndHourCallback(selectedDate, hour)}
68
- />
69
- </div>
70
- </div>
71
- ))}
72
- </div>
73
- </div>
74
- </div>
75
- )
76
- }
@@ -1,178 +0,0 @@
1
- import { cx, tv } from '@xjur-ui/util'
2
- import type { ComponentProps } from 'react'
3
- import { useDraggable } from '@dnd-kit/core'
4
- import { Typography } from '../typography'
5
- import { Tooltip, TooltipContent, TooltipTrigger } from '../tooltip'
6
- import type {
7
- ICalendarEvent,
8
- ICalendarEventStatus
9
- } from './types/calendar-event'
10
- import { useFullCalendar } from './calendar-root'
11
-
12
- const eventVariants = tv({
13
- base: 'py-small_1x-alt pr-small pl-medium rounded-small-2x transition-colors duration-100 ease-out',
14
- variants: {
15
- status: {
16
- pending:
17
- 'bg-layer-2-hover border-l-2 border-border-layer-4 hover:bg-layer-2-pressed active:bg-layer-2-active',
18
- completed:
19
- 'bg-success-alt-idle border-l-2 border-success-idle hover:bg-success-alt-hover active:bg-success-alt-pressed',
20
- cancelled:
21
- 'bg-danger-alt-idle border-l-2 border-danger-idle hover:bg-danger-alt-hover active:bg-danger-alt-pressed'
22
- }
23
- },
24
- defaultVariants: {
25
- status: 'pending'
26
- }
27
- })
28
-
29
- interface CalendarEventProps extends ComponentProps<'div'> {
30
- event: ICalendarEvent
31
- disabled?: boolean
32
- status?: ICalendarEventStatus
33
- }
34
-
35
- export function CalendarEvent({
36
- event,
37
- disabled = false,
38
- status = 'pending',
39
- className,
40
- children,
41
- ...props
42
- }: CalendarEventProps) {
43
- const { onEventMove } = useFullCalendar()
44
- const isDraggingDisabled = disabled || !onEventMove
45
-
46
- const { attributes, listeners, setNodeRef, transform, isDragging } =
47
- useDraggable({
48
- id: event.id,
49
- disabled: isDraggingDisabled,
50
- data: {
51
- event,
52
- type: 'calendar-event'
53
- }
54
- })
55
-
56
- const style = transform
57
- ? {
58
- transform: `translate3d(${transform.x}px, ${transform.y}px, 0)`
59
- }
60
- : undefined
61
-
62
- return (
63
- <div
64
- className={cx(
65
- disabled && 'pointer-events-none',
66
- 'cursor-pointer active:cursor-grabbing',
67
- isDragging && 'z-1000 -rotate-2',
68
- eventVariants({ status }),
69
- className
70
- )}
71
- data-draggable-event-id={event.id}
72
- data-slot="calendar-event"
73
- ref={setNodeRef}
74
- style={style}
75
- {...listeners}
76
- {...attributes}
77
- {...props}
78
- >
79
- {children}
80
- </div>
81
- )
82
- }
83
-
84
- export function CalendarEventTitle({
85
- size = 'sm',
86
- variant = 'label',
87
- weight = 'medium',
88
- className,
89
- ...props
90
- }: ComponentProps<typeof Typography>) {
91
- const { activeEventId } = useFullCalendar()
92
-
93
- if (activeEventId !== null) {
94
- return (
95
- <Typography
96
- className={cx(className, 'text-title-neutral truncate')}
97
- size={size}
98
- variant={variant}
99
- weight={weight}
100
- {...props}
101
- />
102
- )
103
- }
104
-
105
- return (
106
- <Tooltip delayDuration={500}>
107
- <TooltipTrigger asChild={true}>
108
- <Typography
109
- className={cx(className, 'text-title-neutral truncate')}
110
- size={size}
111
- variant={variant}
112
- weight={weight}
113
- {...props}
114
- />
115
- </TooltipTrigger>
116
- <TooltipContent className="max-w-[320px]">
117
- {props.children}
118
- </TooltipContent>
119
- </Tooltip>
120
- )
121
- }
122
-
123
- export function CalendarEventDescription({
124
- size = 'sm-1x',
125
- variant = 'body',
126
- weight = 'normal',
127
- className,
128
- ...props
129
- }: ComponentProps<typeof Typography>) {
130
- const { activeEventId } = useFullCalendar()
131
-
132
- if (activeEventId !== null) {
133
- return (
134
- <Typography
135
- className={cx(className, 'truncate')}
136
- size={size}
137
- variant={variant}
138
- weight={weight}
139
- {...props}
140
- />
141
- )
142
- }
143
-
144
- return (
145
- <Tooltip delayDuration={500}>
146
- <TooltipTrigger asChild={true}>
147
- <Typography
148
- className={cx(className, 'truncate')}
149
- size={size}
150
- variant={variant}
151
- weight={weight}
152
- {...props}
153
- />
154
- </TooltipTrigger>
155
- <TooltipContent className="max-w-[320px]">
156
- {props.children}
157
- </TooltipContent>
158
- </Tooltip>
159
- )
160
- }
161
-
162
- export function CalendarEventStatus({
163
- variant = 'body',
164
- size = 'sm-1x',
165
- weight = 'normal',
166
- className,
167
- ...props
168
- }: ComponentProps<typeof Typography>) {
169
- return (
170
- <Typography
171
- className={cx(className, 'truncate')}
172
- size={size}
173
- variant={variant}
174
- weight={weight}
175
- {...props}
176
- />
177
- )
178
- }
@@ -1,14 +0,0 @@
1
- import { cx } from '@xjur-ui/util'
2
- import type { ComponentProps } from 'react'
3
-
4
- export function CalendarHeader({ className, ...props }: ComponentProps<'div'>) {
5
- return (
6
- <div
7
- {...props}
8
- className={cx(
9
- className,
10
- 'gap-medium h-large-4x flex w-full items-center'
11
- )}
12
- />
13
- )
14
- }
@@ -1,69 +0,0 @@
1
- import { useCallback, useMemo } from 'react'
2
- import { cx } from '@xjur-ui/util'
3
- import { Typography } from '../typography'
4
- import { getDaysInMonth, getEventsForDay, WEEKDAYS } from './helpers/calendar'
5
- import { useFullCalendar } from './calendar-root'
6
- import { CalendarCell } from './calendar-cell'
7
- import type { ICalendarCell } from './types/calendar-cell'
8
-
9
- export function CalendarMonthView() {
10
- const { selectedDate, events } = useFullCalendar()
11
-
12
- const monthDaysCells = useMemo(
13
- () => getDaysInMonth(selectedDate),
14
- [selectedDate]
15
- )
16
-
17
- const getEventsForDayCell = useCallback(
18
- (cell: ICalendarCell) => {
19
- return getEventsForDay(events, cell.date)
20
- },
21
- [events]
22
- )
23
-
24
- return (
25
- <div className="rounded-small-1x scrollbar-hide border-border-layer-2 h-full w-full border">
26
- <div
27
- className="bg-layer-2-hover h-large-4x rounded-t-small-1x sticky top-0 grid grid-cols-7"
28
- data-slot="month-header"
29
- >
30
- {WEEKDAYS.map(weekday => (
31
- <div
32
- className={cx(
33
- 'p-small b border-border-layer-2 flex items-center justify-center border-r last:border-r-0'
34
- )}
35
- data-slot="month-header-weekday"
36
- key={weekday}
37
- >
38
- <Typography size="sm" variant="label" weight="medium">
39
- {weekday}
40
- </Typography>
41
- </div>
42
- ))}
43
- </div>
44
-
45
- <div
46
- className="grid h-full grid-cols-7 overflow-hidden"
47
- data-slot="month-day-cells"
48
- >
49
- {monthDaysCells.map((cell, index) => {
50
- const isLastColumn = (index + 1) % 7 === 0
51
- const isFirstColumn = (index + 1) % 7 === 1
52
-
53
- return (
54
- <div
55
- className={cx(
56
- 'border-border-layer-2 border-t border-r',
57
- isLastColumn && 'pr-small-2x border-r-0',
58
- isFirstColumn && 'pl-small-2x'
59
- )}
60
- key={`${cell.date.toISOString()}-${index}`}
61
- >
62
- <CalendarCell cell={cell} events={getEventsForDayCell(cell)} />
63
- </div>
64
- )
65
- })}
66
- </div>
67
- </div>
68
- )
69
- }
@@ -1,39 +0,0 @@
1
- import { Fragment } from 'react/jsx-runtime'
2
- import { Button } from '../controls/button'
3
- import {
4
- DropdownMenuRoot,
5
- DropdownMenuList,
6
- DropdownMenuTrigger,
7
- DropdownMenuContent
8
- } from '../dropdown-menu'
9
- import { useFullCalendar } from './calendar-root'
10
- import type { ICalendarEvent } from './types/calendar-event'
11
-
12
- interface CalendarMoreEventsDropdownProps {
13
- events: ICalendarEvent[]
14
- }
15
-
16
- export function CalendarMoreEventsDropdown({
17
- events
18
- }: CalendarMoreEventsDropdownProps) {
19
- const { renderEvent } = useFullCalendar()
20
- return (
21
- <DropdownMenuRoot>
22
- <DropdownMenuTrigger asChild={true}>
23
- <Button size="sm" variant="outlined">
24
- Mais {events.length}
25
- </Button>
26
- </DropdownMenuTrigger>
27
-
28
- <DropdownMenuContent className="w-[240px]">
29
- <DropdownMenuList>
30
- {events.map(event => (
31
- <Fragment key={event.eventDate.toISOString()}>
32
- {renderEvent?.(event)}
33
- </Fragment>
34
- ))}
35
- </DropdownMenuList>
36
- </DropdownMenuContent>
37
- </DropdownMenuRoot>
38
- )
39
- }
@@ -1,86 +0,0 @@
1
- import { useCallback, useMemo } from 'react'
2
- import {
3
- addDays,
4
- addMonths,
5
- addWeeks,
6
- format,
7
- startOfWeek,
8
- subDays,
9
- subMonths,
10
- subWeeks
11
- } from 'date-fns'
12
- import { ptBR } from 'date-fns/locale'
13
- import { capitalize } from '@xjur-ui/util'
14
- import { Typography } from '../typography'
15
- import { Button } from '../controls/button'
16
- import { Icon } from '../icon'
17
- import { useFullCalendar } from './calendar-root'
18
- import { getStartAndEndDateOfWeek } from './helpers/calendar'
19
-
20
- export function CalendarNavigator() {
21
- const { selectedDate, calendarView, setSelectedDate } = useFullCalendar()
22
-
23
- const viewLabel = useMemo(() => {
24
- if (calendarView === 'month') {
25
- return capitalize(
26
- format(selectedDate, "MMMM 'de' yyyy", { locale: ptBR })
27
- )
28
- }
29
-
30
- if (calendarView === 'week') {
31
- const { start, end } = getStartAndEndDateOfWeek(selectedDate)
32
- const month = format(end, 'MMMM', { locale: ptBR })
33
- const year = format(end, 'yyyy', { locale: ptBR })
34
- return `${start.getDate()} - ${end.getDate()} de ${month} de ${year}`
35
- }
36
-
37
- return format(selectedDate, "dd 'de' MMMM 'de' yyyy", { locale: ptBR })
38
- }, [selectedDate, calendarView])
39
-
40
- const handleNextDate = useCallback(() => {
41
- if (calendarView === 'month') {
42
- setSelectedDate(addMonths(selectedDate, 1))
43
- return
44
- }
45
-
46
- if (calendarView === 'week') {
47
- const nextWeek = startOfWeek(addWeeks(selectedDate, 1))
48
- setSelectedDate(nextWeek)
49
- return
50
- }
51
-
52
- const nextDay = addDays(selectedDate, 1)
53
- setSelectedDate(nextDay)
54
- }, [selectedDate, setSelectedDate, calendarView])
55
-
56
- const handlePreviousDate = useCallback(() => {
57
- if (calendarView === 'month') {
58
- setSelectedDate(subMonths(selectedDate, 1))
59
- return
60
- }
61
-
62
- if (calendarView === 'week') {
63
- setSelectedDate(subWeeks(selectedDate, 1))
64
- }
65
-
66
- setSelectedDate(subDays(selectedDate, 1))
67
- }, [selectedDate, setSelectedDate, calendarView])
68
-
69
- return (
70
- <div className="gap-large flex items-center">
71
- <Typography className="text-title-neutral" size="lg" variant="title">
72
- {viewLabel}
73
- </Typography>
74
-
75
- <div className="gap-small flex items-center">
76
- <Button size="icon_md" variant="tertiary" onClick={handlePreviousDate}>
77
- <Icon className="text-icon-neutral-3" name="chevron_left" />
78
- </Button>
79
-
80
- <Button size="icon_md" variant="tertiary" onClick={handleNextDate}>
81
- <Icon className="text-icon-neutral-3" name="chevron_right" />
82
- </Button>
83
- </div>
84
- </div>
85
- )
86
- }