@xjur-ui/react 2.1.0 → 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.
- package/CHANGELOG.md +18 -0
- package/dist/{chunk-IRHU7PDO.js → chunk-2JQVYVAT.js} +2 -2
- package/dist/chunk-2JQVYVAT.js.map +1 -0
- package/dist/chunk-2JU3PFV2.js +2 -0
- package/dist/chunk-2JU3PFV2.js.map +1 -0
- package/dist/chunk-3H75F4Y2.js +2 -0
- package/dist/chunk-3H75F4Y2.js.map +1 -0
- package/dist/{chunk-Z47R2CIM.js → chunk-3L772WC6.js} +2 -2
- package/dist/chunk-3L772WC6.js.map +1 -0
- package/dist/chunk-43DUEHUA.js +2 -0
- package/dist/chunk-43DUEHUA.js.map +1 -0
- package/dist/chunk-4BGAERSD.js +2 -0
- package/dist/chunk-4BGAERSD.js.map +1 -0
- package/dist/{chunk-5WLIDYZH.js → chunk-4PTFZTVU.js} +2 -2
- package/dist/{chunk-5WLIDYZH.js.map → chunk-4PTFZTVU.js.map} +1 -1
- package/dist/chunk-6PHXO2YA.js +2 -0
- package/dist/{chunk-RWMV7APX.js.map → chunk-6PHXO2YA.js.map} +1 -1
- package/dist/{chunk-2CTBH6VI.js → chunk-7HG6Y3VV.js} +2 -2
- package/dist/{chunk-2CTBH6VI.js.map → chunk-7HG6Y3VV.js.map} +1 -1
- package/dist/chunk-7HMMMRDA.js +2 -0
- package/dist/chunk-7HMMMRDA.js.map +1 -0
- package/dist/chunk-7QGN6XFA.js +2 -0
- package/dist/chunk-7QGN6XFA.js.map +1 -0
- package/dist/chunk-AKR2BJRB.js +2 -0
- package/dist/chunk-AKR2BJRB.js.map +1 -0
- package/dist/{chunk-BK6FP63A.js → chunk-ASZAHSU5.js} +2 -2
- package/dist/{chunk-BK6FP63A.js.map → chunk-ASZAHSU5.js.map} +1 -1
- package/dist/chunk-DOC3XTYC.js +2 -0
- package/dist/chunk-DOC3XTYC.js.map +1 -0
- package/dist/{chunk-IKL6PSXU.js → chunk-DT44JTXB.js} +2 -2
- package/dist/{chunk-IKL6PSXU.js.map → chunk-DT44JTXB.js.map} +1 -1
- package/dist/chunk-DVDHTP4C.js +2 -0
- package/dist/chunk-DVDHTP4C.js.map +1 -0
- package/dist/chunk-EITO7GZX.js +2 -0
- package/dist/chunk-EITO7GZX.js.map +1 -0
- package/dist/chunk-F7ANJ4HD.js +2 -0
- package/dist/chunk-F7ANJ4HD.js.map +1 -0
- package/dist/chunk-FQTUN47L.js +2 -0
- package/dist/chunk-FQTUN47L.js.map +1 -0
- package/dist/chunk-FUHASFGU.js +2 -0
- package/dist/chunk-FUHASFGU.js.map +1 -0
- package/dist/{chunk-CI3ZXWEX.js → chunk-G6NSC3FL.js} +2 -2
- package/dist/{chunk-CI3ZXWEX.js.map → chunk-G6NSC3FL.js.map} +1 -1
- package/dist/{chunk-6AD6O6II.js → chunk-GKILN5HI.js} +2 -2
- package/dist/chunk-GKILN5HI.js.map +1 -0
- package/dist/chunk-GVKH2BG2.js +2 -0
- package/dist/chunk-GVKH2BG2.js.map +1 -0
- package/dist/chunk-JF7JKJES.js +2 -0
- package/dist/chunk-JF7JKJES.js.map +1 -0
- package/dist/{chunk-TSVURBUY.js → chunk-JGPHBUVM.js} +2 -2
- package/dist/chunk-JGPHBUVM.js.map +1 -0
- package/dist/{chunk-PKCW37CJ.js → chunk-M6ZI7M3R.js} +2 -2
- package/dist/chunk-M6ZI7M3R.js.map +1 -0
- package/dist/{chunk-UXIVZWLB.js → chunk-MQ7YTZBI.js} +2 -2
- package/dist/{chunk-UXIVZWLB.js.map → chunk-MQ7YTZBI.js.map} +1 -1
- package/dist/chunk-O3JK6QF6.js +2 -0
- package/dist/chunk-O3JK6QF6.js.map +1 -0
- package/dist/{chunk-L4ET6GIZ.js → chunk-OKSGVAQQ.js} +2 -2
- package/dist/chunk-OKSGVAQQ.js.map +1 -0
- package/dist/chunk-OLWYBKQR.js +2 -0
- package/dist/chunk-OLWYBKQR.js.map +1 -0
- package/dist/chunk-PBR7SFWY.js +2 -0
- package/dist/chunk-PBR7SFWY.js.map +1 -0
- package/dist/chunk-Q2BZSHS2.js +2 -0
- package/dist/chunk-Q2BZSHS2.js.map +1 -0
- package/dist/{chunk-OS53BV63.js → chunk-RGKXZJJS.js} +3 -3
- package/dist/{chunk-OS53BV63.js.map → chunk-RGKXZJJS.js.map} +1 -1
- package/dist/chunk-SSTXFHNX.js +2 -0
- package/dist/chunk-SSTXFHNX.js.map +1 -0
- package/dist/chunk-TORICLEW.js +2 -0
- package/dist/chunk-TORICLEW.js.map +1 -0
- package/dist/chunk-TYWCS7GS.js +2 -0
- package/dist/chunk-TYWCS7GS.js.map +1 -0
- package/dist/chunk-URDL5OKH.js +2 -0
- package/dist/chunk-URDL5OKH.js.map +1 -0
- package/dist/chunk-V2FCP4FA.js +2 -0
- package/dist/chunk-V2FCP4FA.js.map +1 -0
- package/dist/chunk-VCNKCHFF.js +2 -0
- package/dist/chunk-VCNKCHFF.js.map +1 -0
- package/dist/chunk-WEGFAS5P.js +2 -0
- package/dist/chunk-WEGFAS5P.js.map +1 -0
- package/dist/chunk-X6SOSTUN.js +2 -0
- package/dist/chunk-X6SOSTUN.js.map +1 -0
- package/dist/chunk-XGPKBYDY.js +2 -0
- package/dist/chunk-XGPKBYDY.js.map +1 -0
- package/dist/chunk-YOLTIAFT.js +2 -0
- package/dist/{chunk-KIFR5VIE.js.map → chunk-YOLTIAFT.js.map} +1 -1
- package/dist/chunk-ZPQPJJQJ.js +2 -0
- package/dist/chunk-ZPQPJJQJ.js.map +1 -0
- package/dist/components/breadcrumb.js +1 -1
- package/dist/components/chip.d.ts +1 -1
- package/dist/components/chip.js +1 -1
- package/dist/components/controls/button.js +2 -0
- package/dist/components/{form → controls}/calendar.js +1 -1
- package/dist/components/controls/calendar.js.map +1 -0
- package/dist/components/{form → controls}/checkbox.js +1 -1
- package/dist/components/controls/checkbox.js.map +1 -0
- package/dist/components/{form → controls}/context/field.context.d.ts +1 -2
- package/dist/components/controls/context/field.context.js +2 -0
- package/dist/components/{form → controls}/date-picker.d.ts +2 -1
- package/dist/components/{form → controls}/date-picker.js +1 -1
- package/dist/components/controls/date-picker.js.map +1 -0
- package/dist/components/controls/floating-label.js +2 -0
- package/dist/components/{form → controls}/input.d.ts +3 -2
- package/dist/components/controls/input.js +2 -0
- package/dist/components/controls/otp-input.js.map +1 -0
- package/dist/components/controls/radio.js.map +1 -0
- package/dist/components/{form → controls}/rich-editor.js +1 -1
- package/dist/components/controls/rich-editor.js.map +1 -0
- package/dist/components/{form → controls}/search-input.d.ts +9 -1
- package/dist/components/controls/search-input.js +2 -0
- package/dist/components/controls/search-input.js.map +1 -0
- package/dist/components/controls/search-selector.d.ts +19 -0
- package/dist/components/controls/search-selector.js +2 -0
- package/dist/components/controls/search-selector.js.map +1 -0
- package/dist/components/{form → controls}/select.d.ts +2 -1
- package/dist/components/{form → controls}/select.js +1 -1
- package/dist/components/controls/switch.js +2 -0
- package/dist/components/custom/pessoa/index.d.ts +16 -0
- package/dist/components/custom/pessoa/index.js +2 -0
- package/dist/components/custom/pessoa/index.js.map +1 -0
- package/dist/components/custom/pessoa/pessoa-add-button.d.ts +9 -0
- package/dist/components/custom/pessoa/pessoa-add-button.js +2 -0
- package/dist/components/custom/pessoa/pessoa-add-button.js.map +1 -0
- package/dist/components/custom/pessoa/pessoa-body.d.ts +8 -0
- package/dist/components/custom/pessoa/pessoa-body.js +2 -0
- package/dist/components/custom/pessoa/pessoa-body.js.map +1 -0
- package/dist/components/custom/pessoa/pessoa-close-button.d.ts +8 -0
- package/dist/components/custom/pessoa/pessoa-close-button.js +2 -0
- package/dist/components/custom/pessoa/pessoa-close-button.js.map +1 -0
- package/dist/components/custom/pessoa/pessoa-content.d.ts +8 -0
- package/dist/components/custom/pessoa/pessoa-content.js +2 -0
- package/dist/components/custom/pessoa/pessoa-content.js.map +1 -0
- package/dist/components/custom/pessoa/pessoa-footer.d.ts +8 -0
- package/dist/components/custom/pessoa/pessoa-footer.js +2 -0
- package/dist/components/custom/pessoa/pessoa-footer.js.map +1 -0
- package/dist/components/custom/pessoa/pessoa-header.d.ts +10 -0
- package/dist/components/custom/pessoa/pessoa-header.js +2 -0
- package/dist/components/custom/pessoa/pessoa-header.js.map +1 -0
- package/dist/components/custom/pessoa/pessoa-trigger.d.ts +8 -0
- package/dist/components/custom/pessoa/pessoa-trigger.js +2 -0
- package/dist/components/custom/pessoa/pessoa-trigger.js.map +1 -0
- package/dist/components/custom/pessoa/pessoa.context.d.ts +25 -0
- package/dist/components/custom/pessoa/pessoa.context.js +2 -0
- package/dist/components/custom/pessoa/pessoa.context.js.map +1 -0
- package/dist/components/custom/pessoa/pessoa.d.ts +11 -0
- package/dist/components/custom/pessoa/pessoa.js +2 -0
- package/dist/components/custom/pessoa/pessoa.js.map +1 -0
- package/dist/components/dialog.js +1 -1
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/drag-and-drop/index.js +1 -1
- package/dist/components/dropdown-menu.js +1 -1
- package/dist/components/full-calendar/calendar-add-event.js +1 -1
- package/dist/components/full-calendar/calendar-add-event.js.map +1 -1
- package/dist/components/full-calendar/calendar-cell.js +1 -1
- package/dist/components/full-calendar/calendar-day-view.js +1 -1
- package/dist/components/full-calendar/calendar-month-view.js +1 -1
- package/dist/components/full-calendar/calendar-more-events-dropdown.js +1 -1
- package/dist/components/full-calendar/calendar-navigator.js +1 -1
- package/dist/components/full-calendar/calendar-today-button.d.ts +1 -1
- package/dist/components/full-calendar/calendar-today-button.js +1 -1
- package/dist/components/full-calendar/calendar-toggle-view.js +1 -1
- package/dist/components/full-calendar/calendar-view-renderer.js +1 -1
- package/dist/components/full-calendar/calendar-week-view.js +1 -1
- package/dist/components/full-calendar/index.d.ts +1 -1
- package/dist/components/full-calendar/index.js +1 -1
- package/dist/components/horizontal-scroll.js +1 -1
- package/dist/components/horizontal-scroll.js.map +1 -1
- package/dist/components/icon.d.ts +2 -2
- package/dist/components/icon.js +1 -1
- package/dist/components/list.js +1 -1
- package/dist/components/selection-bar.d.ts +1 -1
- package/dist/components/selection-bar.js +1 -1
- package/dist/components/selection-bar.js.map +1 -1
- package/dist/components/sheet.js +1 -1
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/steps/index.d.ts +11 -0
- package/dist/components/steps/index.js +2 -0
- package/dist/components/steps/index.js.map +1 -0
- package/dist/components/steps/step.d.ts +8 -0
- package/dist/components/steps/step.js +2 -0
- package/dist/components/steps/step.js.map +1 -0
- package/dist/components/steps/steps-action.d.ts +12 -0
- package/dist/components/steps/steps-action.js +2 -0
- package/dist/components/steps/steps-action.js.map +1 -0
- package/dist/components/steps/steps-content.d.ts +6 -0
- package/dist/components/steps/steps-content.js +2 -0
- package/dist/components/steps/steps-content.js.map +1 -0
- package/dist/components/steps/steps-context.d.ts +22 -0
- package/dist/components/steps/steps-context.js +2 -0
- package/dist/components/steps/steps-context.js.map +1 -0
- package/dist/components/steps/steps-navigation.d.ts +6 -0
- package/dist/components/steps/steps-navigation.js +2 -0
- package/dist/components/steps/steps-navigation.js.map +1 -0
- package/dist/components/steps/steps-root.d.ts +7 -0
- package/dist/components/steps/steps-root.js +2 -0
- package/dist/components/steps/steps-root.js.map +1 -0
- package/dist/components/table/index.d.ts +9 -0
- package/dist/components/table/index.js +2 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/table/table-body.d.ts +5 -0
- package/dist/components/table/table-body.js +2 -0
- package/dist/components/table/table-body.js.map +1 -0
- package/dist/components/table/table-cell.d.ts +5 -0
- package/dist/components/table/table-cell.js +2 -0
- package/dist/components/table/table-cell.js.map +1 -0
- package/dist/components/table/table-footer.d.ts +5 -0
- package/dist/components/table/table-footer.js +2 -0
- package/dist/components/table/table-footer.js.map +1 -0
- package/dist/components/table/table-head.d.ts +6 -0
- package/dist/components/table/table-head.js +2 -0
- package/dist/components/table/table-head.js.map +1 -0
- package/dist/components/table/table-header.d.ts +5 -0
- package/dist/components/table/table-header.js +2 -0
- package/dist/components/table/table-header.js.map +1 -0
- package/dist/components/table/table-row.d.ts +7 -0
- package/dist/components/table/table-row.js +2 -0
- package/dist/components/table/table-row.js.map +1 -0
- package/dist/components/table/table-sort.d.ts +7 -0
- package/dist/components/table/table-sort.js +2 -0
- package/dist/components/table/table-sort.js.map +1 -0
- package/dist/components/table/table.d.ts +5 -0
- package/dist/components/table/table.js +2 -0
- package/dist/components/table/table.js.map +1 -0
- package/dist/components/tag.d.ts +1 -1
- package/dist/components/tag.js +1 -1
- package/dist/components/upload.js +1 -1
- package/dist/components/upload.js.map +1 -1
- package/dist/icons-C-hGI45d.d.ts +4 -0
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/input-mask-DhbtCxF7.d.ts +3 -0
- package/package.json +22 -16
- package/.turbo/turbo-build.log +0 -288
- package/dist/chunk-2CM3SFOY.js +0 -2
- package/dist/chunk-2CM3SFOY.js.map +0 -1
- package/dist/chunk-6AD6O6II.js.map +0 -1
- package/dist/chunk-AA6V5YEC.js +0 -2
- package/dist/chunk-AA6V5YEC.js.map +0 -1
- package/dist/chunk-IRHU7PDO.js.map +0 -1
- package/dist/chunk-KIFR5VIE.js +0 -2
- package/dist/chunk-L4ET6GIZ.js.map +0 -1
- package/dist/chunk-PKCW37CJ.js.map +0 -1
- package/dist/chunk-RWMV7APX.js +0 -2
- package/dist/chunk-TSVURBUY.js.map +0 -1
- package/dist/chunk-WV7QV2PU.js +0 -2
- package/dist/chunk-WV7QV2PU.js.map +0 -1
- package/dist/chunk-Z47R2CIM.js.map +0 -1
- package/dist/components/form/button.js +0 -2
- package/dist/components/form/calendar.js.map +0 -1
- package/dist/components/form/checkbox.js.map +0 -1
- package/dist/components/form/context/field.context.js +0 -2
- package/dist/components/form/date-picker.js.map +0 -1
- package/dist/components/form/floating-label.js +0 -2
- package/dist/components/form/input.js +0 -2
- package/dist/components/form/otp-input.js.map +0 -1
- package/dist/components/form/radio.js.map +0 -1
- package/dist/components/form/rich-editor.js.map +0 -1
- package/dist/components/form/search-input.js +0 -2
- package/dist/components/form/search-input.js.map +0 -1
- package/dist/components/form/switch.js +0 -2
- package/dist/components/table.d.ts +0 -17
- package/dist/components/table.js +0 -2
- package/dist/components/table.js.map +0 -1
- package/dist/icons-CmDuL0gZ.d.ts +0 -4
- package/eslint.config.js +0 -10
- package/postcss.config.js +0 -5
- package/prettier.config.js +0 -7
- package/src/components/avatar-group.tsx +0 -76
- package/src/components/avatar.tsx +0 -54
- package/src/components/badge.tsx +0 -40
- package/src/components/breadcrumb.tsx +0 -119
- package/src/components/chip.tsx +0 -117
- package/src/components/collapsible.tsx +0 -35
- package/src/components/dialog.tsx +0 -242
- package/src/components/divider.tsx +0 -24
- package/src/components/drag-and-drop/drag-handle.tsx +0 -46
- package/src/components/drag-and-drop/drag-list-item.tsx +0 -91
- package/src/components/drag-and-drop/drag-list.tsx +0 -47
- package/src/components/drag-and-drop/drag-root.tsx +0 -30
- package/src/components/drag-and-drop/index.ts +0 -39
- package/src/components/drag-and-drop/types/drag-item.ts +0 -7
- package/src/components/dropdown-menu.tsx +0 -101
- package/src/components/form/button.tsx +0 -107
- package/src/components/form/calendar.tsx +0 -124
- package/src/components/form/checkbox.tsx +0 -57
- package/src/components/form/context/field.context.ts +0 -27
- package/src/components/form/date-picker.tsx +0 -199
- package/src/components/form/floating-label.tsx +0 -60
- package/src/components/form/input.tsx +0 -235
- package/src/components/form/otp-input.tsx +0 -45
- package/src/components/form/radio.tsx +0 -74
- package/src/components/form/rich-editor.tsx +0 -372
- package/src/components/form/search-input.tsx +0 -111
- package/src/components/form/select.tsx +0 -274
- package/src/components/form/switch.tsx +0 -31
- package/src/components/full-calendar/calendar-add-event.tsx +0 -15
- package/src/components/full-calendar/calendar-body.tsx +0 -12
- package/src/components/full-calendar/calendar-cell.tsx +0 -120
- package/src/components/full-calendar/calendar-day-view.tsx +0 -76
- package/src/components/full-calendar/calendar-event.tsx +0 -178
- package/src/components/full-calendar/calendar-header.tsx +0 -14
- package/src/components/full-calendar/calendar-month-view.tsx +0 -69
- package/src/components/full-calendar/calendar-more-events-dropdown.tsx +0 -39
- package/src/components/full-calendar/calendar-navigator.tsx +0 -86
- package/src/components/full-calendar/calendar-root.tsx +0 -165
- package/src/components/full-calendar/calendar-today-button.tsx +0 -21
- package/src/components/full-calendar/calendar-toggle-view.tsx +0 -61
- package/src/components/full-calendar/calendar-view-renderer.tsx +0 -19
- package/src/components/full-calendar/calendar-week-day.tsx +0 -49
- package/src/components/full-calendar/calendar-week-view.tsx +0 -88
- package/src/components/full-calendar/helpers/calendar.ts +0 -158
- package/src/components/full-calendar/index.ts +0 -16
- package/src/components/full-calendar/types/calendar-cell.ts +0 -4
- package/src/components/full-calendar/types/calendar-event.ts +0 -7
- package/src/components/full-calendar/types/calendar-view.ts +0 -1
- package/src/components/full-calendar/types/calendar-week-hour.ts +0 -4
- package/src/components/horizontal-scroll.tsx +0 -159
- package/src/components/icon.tsx +0 -29
- package/src/components/list.tsx +0 -111
- package/src/components/logo.tsx +0 -44
- package/src/components/selection-bar.tsx +0 -273
- package/src/components/sheet.tsx +0 -141
- package/src/components/skeleton.tsx +0 -12
- package/src/components/status.tsx +0 -43
- package/src/components/table.tsx +0 -160
- package/src/components/tabs.tsx +0 -72
- package/src/components/tag.tsx +0 -99
- package/src/components/tooltip.tsx +0 -63
- package/src/components/typography.tsx +0 -85
- package/src/components/upload.tsx +0 -647
- package/src/hooks/index.ts +0 -1
- package/src/hooks/use-os.ts +0 -32
- package/src/index.css +0 -5
- package/src/resources/icons.ts +0 -153
- package/src/resources/input-mask.ts +0 -91
- package/src/resources/logo/horizontal.tsx +0 -70
- package/src/resources/logo/icon.tsx +0 -54
- package/src/resources/logo/index.tsx +0 -33
- package/src/resources/logo/vertical.tsx +0 -70
- package/src/types.d.ts +0 -4
- package/tsconfig.json +0 -4
- package/tsup.config.ts +0 -30
- /package/dist/components/{form → controls}/button.d.ts +0 -0
- /package/dist/components/{form → controls}/button.js.map +0 -0
- /package/dist/components/{form → controls}/calendar.d.ts +0 -0
- /package/dist/components/{form → controls}/checkbox.d.ts +0 -0
- /package/dist/components/{form → controls}/context/field.context.js.map +0 -0
- /package/dist/components/{form → controls}/floating-label.d.ts +0 -0
- /package/dist/components/{form → controls}/floating-label.js.map +0 -0
- /package/dist/components/{form → controls}/input.js.map +0 -0
- /package/dist/components/{form → controls}/otp-input.d.ts +0 -0
- /package/dist/components/{form → controls}/otp-input.js +0 -0
- /package/dist/components/{form → controls}/radio.d.ts +0 -0
- /package/dist/components/{form → controls}/radio.js +0 -0
- /package/dist/components/{form → controls}/rich-editor.d.ts +0 -0
- /package/dist/components/{form → controls}/select.js.map +0 -0
- /package/dist/components/{form → controls}/switch.d.ts +0 -0
- /package/dist/components/{form → controls}/switch.js.map +0 -0
|
@@ -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 '../form/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 '../form/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
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
createContext,
|
|
3
|
-
use,
|
|
4
|
-
useCallback,
|
|
5
|
-
useMemo,
|
|
6
|
-
useState
|
|
7
|
-
} from 'react'
|
|
8
|
-
import {
|
|
9
|
-
DndContext,
|
|
10
|
-
closestCenter,
|
|
11
|
-
useSensor,
|
|
12
|
-
useSensors,
|
|
13
|
-
PointerSensor,
|
|
14
|
-
KeyboardSensor,
|
|
15
|
-
type DragEndEvent,
|
|
16
|
-
type DragStartEvent,
|
|
17
|
-
MouseSensor
|
|
18
|
-
} from '@dnd-kit/core'
|
|
19
|
-
import { sortableKeyboardCoordinates } from '@dnd-kit/sortable'
|
|
20
|
-
import type { ICalendarEvent } from './types/calendar-event'
|
|
21
|
-
import type { CalendarView } from './types/calendar-view'
|
|
22
|
-
|
|
23
|
-
interface CalendarContextType {
|
|
24
|
-
events: ICalendarEvent[]
|
|
25
|
-
selectedDate: Date
|
|
26
|
-
calendarView?: CalendarView
|
|
27
|
-
activeEventId: string | null
|
|
28
|
-
disableEventCreationInPast?: boolean
|
|
29
|
-
renderEvent: (event: ICalendarEvent) => React.ReactNode
|
|
30
|
-
handleChangeView: (view: CalendarView) => void
|
|
31
|
-
setSelectedDate: React.Dispatch<React.SetStateAction<Date>>
|
|
32
|
-
onEventMove?: (eventId: string, newDate: Date) => void
|
|
33
|
-
onAddEvent?: (date: Date) => void
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const CalendarContext = createContext<CalendarContextType>({
|
|
37
|
-
events: [],
|
|
38
|
-
calendarView: 'month',
|
|
39
|
-
selectedDate: new Date(),
|
|
40
|
-
activeEventId: null,
|
|
41
|
-
disableEventCreationInPast: true,
|
|
42
|
-
renderEvent: () => null,
|
|
43
|
-
setSelectedDate: () => {},
|
|
44
|
-
handleChangeView: () => {},
|
|
45
|
-
onEventMove: () => {},
|
|
46
|
-
onAddEvent: () => {}
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
export function CalendarRoot({
|
|
50
|
-
children,
|
|
51
|
-
events,
|
|
52
|
-
calendarView: calendarViewProp = 'month',
|
|
53
|
-
selectedDate: selectedDateProp = new Date(),
|
|
54
|
-
disableEventCreationInPast = true,
|
|
55
|
-
renderEvent,
|
|
56
|
-
onEventMove,
|
|
57
|
-
onAddEvent
|
|
58
|
-
}: {
|
|
59
|
-
children: React.ReactNode
|
|
60
|
-
events: ICalendarEvent[]
|
|
61
|
-
selectedDate?: Date
|
|
62
|
-
calendarView?: CalendarView
|
|
63
|
-
disableEventCreationInPast?: boolean
|
|
64
|
-
renderEvent: (event: ICalendarEvent) => React.ReactNode
|
|
65
|
-
onEventMove?: (eventId: string, newDate: Date) => void
|
|
66
|
-
onAddEvent?: (date: Date) => void
|
|
67
|
-
}) {
|
|
68
|
-
const [selectedDate, setSelectedDate] = useState(selectedDateProp)
|
|
69
|
-
const [calendarView, setCalendarView] = useState(calendarViewProp)
|
|
70
|
-
const [activeEventId, setActiveEventId] = useState<string | null>(null)
|
|
71
|
-
|
|
72
|
-
const handleChangeView = useCallback((view: CalendarView) => {
|
|
73
|
-
setSelectedDate(new Date())
|
|
74
|
-
setCalendarView(view)
|
|
75
|
-
}, [])
|
|
76
|
-
|
|
77
|
-
const sensors = useSensors(
|
|
78
|
-
useSensor(PointerSensor, {
|
|
79
|
-
activationConstraint: {
|
|
80
|
-
distance: 8
|
|
81
|
-
}
|
|
82
|
-
}),
|
|
83
|
-
useSensor(KeyboardSensor, {
|
|
84
|
-
coordinateGetter: sortableKeyboardCoordinates
|
|
85
|
-
}),
|
|
86
|
-
useSensor(MouseSensor, {
|
|
87
|
-
activationConstraint: {
|
|
88
|
-
distance: 5,
|
|
89
|
-
delay: 250
|
|
90
|
-
}
|
|
91
|
-
})
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
const handleDragStart = useCallback((event: DragStartEvent) => {
|
|
95
|
-
const eventId = event.active.id.toString()
|
|
96
|
-
setActiveEventId(eventId)
|
|
97
|
-
}, [])
|
|
98
|
-
|
|
99
|
-
const handleDragEnd = useCallback(
|
|
100
|
-
(event: DragEndEvent) => {
|
|
101
|
-
const { active, over } = event
|
|
102
|
-
setActiveEventId(null)
|
|
103
|
-
|
|
104
|
-
if (!active || !over || !onEventMove) return
|
|
105
|
-
|
|
106
|
-
const eventId = active.id.toString()
|
|
107
|
-
const cellDate = over.data.current?.date as Date
|
|
108
|
-
|
|
109
|
-
console.log(cellDate)
|
|
110
|
-
|
|
111
|
-
if (cellDate) {
|
|
112
|
-
onEventMove(eventId, cellDate)
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
[onEventMove]
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
const providerValue = useMemo(
|
|
119
|
-
() => ({
|
|
120
|
-
events,
|
|
121
|
-
renderEvent,
|
|
122
|
-
activeEventId,
|
|
123
|
-
disableEventCreationInPast,
|
|
124
|
-
selectedDate,
|
|
125
|
-
setSelectedDate,
|
|
126
|
-
|
|
127
|
-
calendarView,
|
|
128
|
-
handleChangeView,
|
|
129
|
-
onEventMove,
|
|
130
|
-
onAddEvent
|
|
131
|
-
}),
|
|
132
|
-
[
|
|
133
|
-
events,
|
|
134
|
-
renderEvent,
|
|
135
|
-
activeEventId,
|
|
136
|
-
disableEventCreationInPast,
|
|
137
|
-
selectedDate,
|
|
138
|
-
calendarView,
|
|
139
|
-
handleChangeView,
|
|
140
|
-
onEventMove,
|
|
141
|
-
onAddEvent
|
|
142
|
-
]
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
return (
|
|
146
|
-
<CalendarContext.Provider value={providerValue}>
|
|
147
|
-
<DndContext
|
|
148
|
-
collisionDetection={closestCenter}
|
|
149
|
-
sensors={sensors}
|
|
150
|
-
onDragEnd={handleDragEnd}
|
|
151
|
-
onDragStart={handleDragStart}
|
|
152
|
-
>
|
|
153
|
-
{children}
|
|
154
|
-
</DndContext>
|
|
155
|
-
</CalendarContext.Provider>
|
|
156
|
-
)
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export function useFullCalendar() {
|
|
160
|
-
const context = use(CalendarContext)
|
|
161
|
-
if (!context) {
|
|
162
|
-
throw new Error('useFullCalendar must be used within a CalendarRoot')
|
|
163
|
-
}
|
|
164
|
-
return context
|
|
165
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { useCallback } from 'react'
|
|
2
|
-
import { Button, type ButtonProps } from '../form/button'
|
|
3
|
-
import { useFullCalendar } from './calendar-root'
|
|
4
|
-
|
|
5
|
-
export function CalendarTodayButton({
|
|
6
|
-
children = 'Hoje',
|
|
7
|
-
variant = 'tertiary',
|
|
8
|
-
...props
|
|
9
|
-
}: ButtonProps) {
|
|
10
|
-
const { setSelectedDate } = useFullCalendar()
|
|
11
|
-
|
|
12
|
-
const handleToday = useCallback(() => {
|
|
13
|
-
setSelectedDate(new Date())
|
|
14
|
-
}, [setSelectedDate])
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<Button variant={variant} onClick={handleToday} {...props}>
|
|
18
|
-
{children}
|
|
19
|
-
</Button>
|
|
20
|
-
)
|
|
21
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
SelectContent,
|
|
4
|
-
SelectOption,
|
|
5
|
-
SelectRoot,
|
|
6
|
-
SelectTrigger,
|
|
7
|
-
SelectValue,
|
|
8
|
-
SelectOptions,
|
|
9
|
-
SelectOptionText,
|
|
10
|
-
SelectIcon
|
|
11
|
-
} from '../form/select'
|
|
12
|
-
import type { CalendarView } from './types/calendar-view'
|
|
13
|
-
import { useFullCalendar } from './calendar-root'
|
|
14
|
-
|
|
15
|
-
const views: Array<{ name: string; value: CalendarView }> = [
|
|
16
|
-
{ name: 'Mês', value: 'month' },
|
|
17
|
-
{ name: 'Semana', value: 'week' },
|
|
18
|
-
{ name: 'Dia', value: 'day' }
|
|
19
|
-
]
|
|
20
|
-
|
|
21
|
-
export function CalendarToggleView() {
|
|
22
|
-
const { calendarView, handleChangeView } = useFullCalendar()
|
|
23
|
-
|
|
24
|
-
const displayValue = useMemo(
|
|
25
|
-
() => views.find(view => view.value === calendarView)?.name,
|
|
26
|
-
[calendarView]
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<div className="w-[94px]">
|
|
31
|
-
<SelectRoot>
|
|
32
|
-
<SelectTrigger>
|
|
33
|
-
<SelectValue
|
|
34
|
-
displayValue={displayValue}
|
|
35
|
-
name="calendar-toggle-view"
|
|
36
|
-
value={calendarView}
|
|
37
|
-
/>
|
|
38
|
-
<SelectIcon
|
|
39
|
-
className="text-icon-neutral-3"
|
|
40
|
-
name="keyboard_arrow_down"
|
|
41
|
-
/>
|
|
42
|
-
</SelectTrigger>
|
|
43
|
-
|
|
44
|
-
<SelectContent>
|
|
45
|
-
<SelectOptions>
|
|
46
|
-
{views.map(view => (
|
|
47
|
-
<SelectOption
|
|
48
|
-
isActive={calendarView === view.value}
|
|
49
|
-
key={view.value}
|
|
50
|
-
value={view.value}
|
|
51
|
-
onClick={() => handleChangeView(view.value)}
|
|
52
|
-
>
|
|
53
|
-
<SelectOptionText>{view.name}</SelectOptionText>
|
|
54
|
-
</SelectOption>
|
|
55
|
-
))}
|
|
56
|
-
</SelectOptions>
|
|
57
|
-
</SelectContent>
|
|
58
|
-
</SelectRoot>
|
|
59
|
-
</div>
|
|
60
|
-
)
|
|
61
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { useFullCalendar } from './calendar-root'
|
|
2
|
-
import { CalendarMonthView } from './calendar-month-view'
|
|
3
|
-
import { CalendarWeekView } from './calendar-week-view'
|
|
4
|
-
import { CalendarDayView } from './calendar-day-view'
|
|
5
|
-
|
|
6
|
-
export function CalendarViewRenderer() {
|
|
7
|
-
const { calendarView } = useFullCalendar()
|
|
8
|
-
|
|
9
|
-
switch (calendarView) {
|
|
10
|
-
case 'month':
|
|
11
|
-
return <CalendarMonthView />
|
|
12
|
-
case 'week':
|
|
13
|
-
return <CalendarWeekView />
|
|
14
|
-
case 'day':
|
|
15
|
-
return <CalendarDayView />
|
|
16
|
-
default:
|
|
17
|
-
return <CalendarMonthView />
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { cx } from '@xjur-ui/util'
|
|
2
|
-
import type { ComponentProps } from 'react'
|
|
3
|
-
import { Typography } from '../typography'
|
|
4
|
-
import { isToday, WEEKDAYS } from './helpers/calendar'
|
|
5
|
-
|
|
6
|
-
interface CalendarWeekDayProps extends ComponentProps<'div'> {
|
|
7
|
-
date: Date
|
|
8
|
-
className?: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function CalendarWeekDay({
|
|
12
|
-
date,
|
|
13
|
-
className,
|
|
14
|
-
...props
|
|
15
|
-
}: CalendarWeekDayProps) {
|
|
16
|
-
const isCurrentDay = isToday(date)
|
|
17
|
-
const dayNumber = date.getDate()
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<div
|
|
21
|
-
className={cx(
|
|
22
|
-
'p-small gap-small-1x flex w-full flex-1 flex-col items-center',
|
|
23
|
-
className
|
|
24
|
-
)}
|
|
25
|
-
data-slot="week-day"
|
|
26
|
-
key={date.toISOString()}
|
|
27
|
-
{...props}
|
|
28
|
-
>
|
|
29
|
-
<Typography size="sm" variant="label" weight="medium">
|
|
30
|
-
{WEEKDAYS[date.getDay()]}
|
|
31
|
-
</Typography>
|
|
32
|
-
<div
|
|
33
|
-
className={cx(
|
|
34
|
-
'size-large-2x rounded-circle flex items-center justify-center',
|
|
35
|
-
isCurrentDay && 'bg-primary-idle'
|
|
36
|
-
)}
|
|
37
|
-
>
|
|
38
|
-
<Typography
|
|
39
|
-
className={cx(isCurrentDay && 'text-neutral-label')}
|
|
40
|
-
size="sm-1x"
|
|
41
|
-
variant="label"
|
|
42
|
-
weight="medium"
|
|
43
|
-
>
|
|
44
|
-
{dayNumber}
|
|
45
|
-
</Typography>
|
|
46
|
-
</div>
|
|
47
|
-
</div>
|
|
48
|
-
)
|
|
49
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { useCallback, useMemo } from 'react'
|
|
2
|
-
import { cx } from '@xjur-ui/util'
|
|
3
|
-
import { setHours } from 'date-fns'
|
|
4
|
-
import { Typography } from '../typography'
|
|
5
|
-
import {
|
|
6
|
-
WEEK_HOURS,
|
|
7
|
-
getWeekDaysInMonth,
|
|
8
|
-
getEventsForDayAndHour
|
|
9
|
-
} from './helpers/calendar'
|
|
10
|
-
import { useFullCalendar } from './calendar-root'
|
|
11
|
-
import { CalendarWeekDay } from './calendar-week-day'
|
|
12
|
-
import { CalendarCell } from './calendar-cell'
|
|
13
|
-
import type { ICalendarCell } from './types/calendar-cell'
|
|
14
|
-
|
|
15
|
-
export function CalendarWeekView() {
|
|
16
|
-
const { selectedDate, events } = useFullCalendar()
|
|
17
|
-
|
|
18
|
-
const monthWeekDaysCells = useMemo(
|
|
19
|
-
() => getWeekDaysInMonth(selectedDate),
|
|
20
|
-
[selectedDate]
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
const getEventsForDayAndHourCallback = useCallback(
|
|
24
|
-
(date: Date, hour: number) => {
|
|
25
|
-
return getEventsForDayAndHour(events, date, hour)
|
|
26
|
-
},
|
|
27
|
-
[events]
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
const cellsWithHour = useCallback((cell: ICalendarCell, hour: number) => {
|
|
31
|
-
return {
|
|
32
|
-
...cell,
|
|
33
|
-
date: setHours(cell.date, hour)
|
|
34
|
-
}
|
|
35
|
-
}, [])
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<div className="bg-layer-2-hover rounded-small-1x border-border-layer-2 scrollbar-hide h-full w-full border">
|
|
39
|
-
<div className="flex flex-1 flex-col">
|
|
40
|
-
<div
|
|
41
|
-
className={cx(
|
|
42
|
-
'bg-layer-2-hover sticky top-0 grid [grid-template-columns:64px_repeat(7,1fr)]',
|
|
43
|
-
'[&>*]:border-border-layer-2',
|
|
44
|
-
'[&>*]:border-l'
|
|
45
|
-
)}
|
|
46
|
-
data-slot="week-header"
|
|
47
|
-
>
|
|
48
|
-
{monthWeekDaysCells.map((cell, index) => (
|
|
49
|
-
<CalendarWeekDay
|
|
50
|
-
date={cell.date}
|
|
51
|
-
key={cell.date.getDay()}
|
|
52
|
-
style={{ gridColumnStart: index + 2 }}
|
|
53
|
-
/>
|
|
54
|
-
))}
|
|
55
|
-
</div>
|
|
56
|
-
|
|
57
|
-
<div className="overflow-hidden">
|
|
58
|
-
{WEEK_HOURS.map(({ hour, label }) => (
|
|
59
|
-
<div className="flex items-start" key={hour}>
|
|
60
|
-
<div className="px-small flex h-full w-[64px] items-start justify-end">
|
|
61
|
-
<Typography size="sm-1x" variant="label" weight="medium">
|
|
62
|
-
{label}
|
|
63
|
-
</Typography>
|
|
64
|
-
</div>
|
|
65
|
-
|
|
66
|
-
<div
|
|
67
|
-
className={cx(
|
|
68
|
-
'grid flex-1 grid-cols-7',
|
|
69
|
-
'[&>*]:border-border-layer-2',
|
|
70
|
-
'[&>*]:border-t',
|
|
71
|
-
'[&>*]:border-l'
|
|
72
|
-
)}
|
|
73
|
-
>
|
|
74
|
-
{monthWeekDaysCells.map(cell => (
|
|
75
|
-
<CalendarCell
|
|
76
|
-
cell={cellsWithHour(cell, hour)}
|
|
77
|
-
events={getEventsForDayAndHourCallback(cell.date, hour)}
|
|
78
|
-
key={cell.date.toISOString()}
|
|
79
|
-
/>
|
|
80
|
-
))}
|
|
81
|
-
</div>
|
|
82
|
-
</div>
|
|
83
|
-
))}
|
|
84
|
-
</div>
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
)
|
|
88
|
-
}
|