@zimyo/ui 1.0.2 → 1.1.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/package.json +78 -83
- package/dist/components/index.d.ts +0 -60
- package/dist/components/ui/accordion.d.ts +0 -10
- package/dist/components/ui/accordion.js +0 -58
- package/dist/components/ui/alert-dialog.d.ts +0 -17
- package/dist/components/ui/alert-dialog.js +0 -108
- package/dist/components/ui/alert.d.ts +0 -13
- package/dist/components/ui/alert.js +0 -52
- package/dist/components/ui/aspect-ratio.d.ts +0 -6
- package/dist/components/ui/aspect-ratio.js +0 -12
- package/dist/components/ui/avatar.d.ts +0 -9
- package/dist/components/ui/avatar.js +0 -37
- package/dist/components/ui/badge.d.ts +0 -13
- package/dist/components/ui/badge.js +0 -36
- package/dist/components/ui/breadcrumb.d.ts +0 -14
- package/dist/components/ui/breadcrumb.js +0 -94
- package/dist/components/ui/button.d.ts +0 -14
- package/dist/components/ui/button.js +0 -48
- package/dist/components/ui/calendar.d.ts +0 -13
- package/dist/components/ui/calendar.js +0 -137
- package/dist/components/ui/card.d.ts +0 -12
- package/dist/components/ui/card.js +0 -76
- package/dist/components/ui/carousel.d.ts +0 -25
- package/dist/components/ui/carousel.js +0 -173
- package/dist/components/ui/chart.d.ts +0 -44
- package/dist/components/ui/chart.js +0 -203
- package/dist/components/ui/checkbox.d.ts +0 -7
- package/dist/components/ui/checkbox.js +0 -26
- package/dist/components/ui/collapsible.d.ts +0 -8
- package/dist/components/ui/collapsible.js +0 -24
- package/dist/components/ui/command.d.ts +0 -22
- package/dist/components/ui/command.js +0 -119
- package/dist/components/ui/context-menu.d.ts +0 -28
- package/dist/components/ui/context-menu.js +0 -171
- package/dist/components/ui/dialog.d.ts +0 -18
- package/dist/components/ui/dialog.js +0 -106
- package/dist/components/ui/drawer.d.ts +0 -16
- package/dist/components/ui/drawer.js +0 -99
- package/dist/components/ui/dropdown-menu.d.ts +0 -28
- package/dist/components/ui/dropdown-menu.js +0 -173
- package/dist/components/ui/form.d.ts +0 -27
- package/dist/components/ui/form.js +0 -129
- package/dist/components/ui/hover-card.d.ts +0 -9
- package/dist/components/ui/hover-card.js +0 -36
- package/dist/components/ui/input-otp.d.ts +0 -14
- package/dist/components/ui/input-otp.js +0 -66
- package/dist/components/ui/input.d.ts +0 -6
- package/dist/components/ui/input.js +0 -18
- package/dist/components/ui/label.d.ts +0 -7
- package/dist/components/ui/label.js +0 -17
- package/dist/components/ui/menubar.d.ts +0 -29
- package/dist/components/ui/menubar.js +0 -191
- package/dist/components/ui/navigation-menu.d.ts +0 -18
- package/dist/components/ui/navigation-menu.js +0 -108
- package/dist/components/ui/pagination.d.ts +0 -18
- package/dist/components/ui/pagination.js +0 -103
- package/dist/components/ui/popover.d.ts +0 -10
- package/dist/components/ui/popover.js +0 -41
- package/dist/components/ui/progress.d.ts +0 -7
- package/dist/components/ui/progress.js +0 -26
- package/dist/components/ui/radio-group.d.ts +0 -8
- package/dist/components/ui/radio-group.js +0 -36
- package/dist/components/ui/resizable.d.ts +0 -11
- package/dist/components/ui/resizable.js +0 -42
- package/dist/components/ui/scroll-area.d.ts +0 -8
- package/dist/components/ui/scroll-area.js +0 -41
- package/dist/components/ui/select.d.ts +0 -18
- package/dist/components/ui/select.js +0 -136
- package/dist/components/ui/separator.d.ts +0 -7
- package/dist/components/ui/separator.js +0 -21
- package/dist/components/ui/sheet.d.ts +0 -16
- package/dist/components/ui/sheet.js +0 -106
- package/dist/components/ui/sidebar.d.ts +0 -74
- package/dist/components/ui/sidebar.js +0 -511
- package/dist/components/ui/skeleton.d.ts +0 -5
- package/dist/components/ui/skeleton.js +0 -16
- package/dist/components/ui/slider.d.ts +0 -7
- package/dist/components/ui/slider.js +0 -41
- package/dist/components/ui/sonner.d.ts +0 -6
- package/dist/components/ui/sonner.js +0 -18
- package/dist/components/ui/switch.d.ts +0 -7
- package/dist/components/ui/switch.js +0 -22
- package/dist/components/ui/table.d.ts +0 -13
- package/dist/components/ui/table.js +0 -90
- package/dist/components/ui/tabs.d.ts +0 -10
- package/dist/components/ui/tabs.js +0 -47
- package/dist/components/ui/textarea.d.ts +0 -6
- package/dist/components/ui/textarea.js +0 -16
- package/dist/components/ui/toggle-group.d.ts +0 -11
- package/dist/components/ui/toggle-group.js +0 -57
- package/dist/components/ui/toggle.d.ts +0 -13
- package/dist/components/ui/toggle.js +0 -41
- package/dist/components/ui/tooltip.d.ts +0 -10
- package/dist/components/ui/tooltip.js +0 -50
- package/dist/index.d.ts +0 -63
- package/dist/index.js +0 -48
- package/dist/lib/utils.d.ts +0 -5
- package/dist/lib/utils.js +0 -8
- package/dist/node_modules/@date-fns/tz/date/index.js +0 -101
- package/dist/node_modules/@date-fns/tz/date/mini.js +0 -207
- package/dist/node_modules/@date-fns/tz/tzOffset/index.js +0 -43
- package/dist/node_modules/@radix-ui/primitive/dist/index.js +0 -11
- package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.js +0 -39
- package/dist/node_modules/@radix-ui/react-context/dist/index.js +0 -79
- package/dist/node_modules/@radix-ui/react-dialog/dist/index.js +0 -321
- package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +0 -211
- package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.js +0 -29
- package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.js +0 -207
- package/dist/node_modules/@radix-ui/react-id/dist/index.js +0 -15
- package/dist/node_modules/@radix-ui/react-portal/dist/index.js +0 -17
- package/dist/node_modules/@radix-ui/react-presence/dist/index.js +0 -130
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.js +0 -43
- package/dist/node_modules/@radix-ui/react-slot/dist/index.js +0 -89
- package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +0 -12
- package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +0 -70
- package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +0 -18
- package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +0 -7
- package/dist/node_modules/aria-hidden/dist/es2015/index.js +0 -137
- package/dist/node_modules/class-variance-authority/dist/index.js +0 -44
- package/dist/node_modules/clsx/dist/clsx.js +0 -3
- package/dist/node_modules/cmdk/dist/chunk-NZJY6EH4.js +0 -3
- package/dist/node_modules/cmdk/dist/index.js +0 -10
- package/dist/node_modules/date-fns/_lib/addLeadingZeros.js +0 -7
- package/dist/node_modules/date-fns/_lib/defaultOptions.js +0 -7
- package/dist/node_modules/date-fns/_lib/format/formatters.js +0 -775
- package/dist/node_modules/date-fns/_lib/format/lightFormatters.js +0 -94
- package/dist/node_modules/date-fns/_lib/format/longFormatters.js +0 -66
- package/dist/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js +0 -31
- package/dist/node_modules/date-fns/_lib/normalizeDates.js +0 -11
- package/dist/node_modules/date-fns/_lib/normalizeInterval.js +0 -8
- package/dist/node_modules/date-fns/_lib/protectedTokens.js +0 -25
- package/dist/node_modules/date-fns/addDays.js +0 -41
- package/dist/node_modules/date-fns/addMonths.js +0 -75
- package/dist/node_modules/date-fns/addWeeks.js +0 -33
- package/dist/node_modules/date-fns/addYears.js +0 -33
- package/dist/node_modules/date-fns/constants.js +0 -46
- package/dist/node_modules/date-fns/constructFrom.js +0 -49
- package/dist/node_modules/date-fns/differenceInCalendarDays.js +0 -62
- package/dist/node_modules/date-fns/differenceInCalendarMonths.js +0 -42
- package/dist/node_modules/date-fns/eachMonthOfInterval.js +0 -65
- package/dist/node_modules/date-fns/endOfISOWeek.js +0 -35
- package/dist/node_modules/date-fns/endOfMonth.js +0 -37
- package/dist/node_modules/date-fns/endOfWeek.js +0 -53
- package/dist/node_modules/date-fns/endOfYear.js +0 -37
- package/dist/node_modules/date-fns/format.js +0 -423
- package/dist/node_modules/date-fns/getDayOfYear.js +0 -34
- package/dist/node_modules/date-fns/getDaysInMonth.js +0 -36
- package/dist/node_modules/date-fns/getISOWeek.js +0 -40
- package/dist/node_modules/date-fns/getISOWeekYear.js +0 -52
- package/dist/node_modules/date-fns/getMonth.js +0 -29
- package/dist/node_modules/date-fns/getWeek.js +0 -54
- package/dist/node_modules/date-fns/getWeekYear.js +0 -75
- package/dist/node_modules/date-fns/getYear.js +0 -29
- package/dist/node_modules/date-fns/isAfter.js +0 -25
- package/dist/node_modules/date-fns/isBefore.js +0 -25
- package/dist/node_modules/date-fns/isDate.js +0 -41
- package/dist/node_modules/date-fns/isSameDay.js +0 -46
- package/dist/node_modules/date-fns/isSameMonth.js +0 -43
- package/dist/node_modules/date-fns/isSameYear.js +0 -35
- package/dist/node_modules/date-fns/isValid.js +0 -39
- package/dist/node_modules/date-fns/locale/_lib/buildFormatLongFn.js +0 -10
- package/dist/node_modules/date-fns/locale/_lib/buildLocalizeFn.js +0 -64
- package/dist/node_modules/date-fns/locale/_lib/buildMatchFn.js +0 -59
- package/dist/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js +0 -22
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatDistance.js +0 -103
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatLong.js +0 -41
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatRelative.js +0 -13
- package/dist/node_modules/date-fns/locale/en-US/_lib/localize.js +0 -189
- package/dist/node_modules/date-fns/locale/en-US/_lib/match.js +0 -134
- package/dist/node_modules/date-fns/locale/en-US.js +0 -28
- package/dist/node_modules/date-fns/max.js +0 -49
- package/dist/node_modules/date-fns/min.js +0 -49
- package/dist/node_modules/date-fns/setMonth.js +0 -46
- package/dist/node_modules/date-fns/setYear.js +0 -40
- package/dist/node_modules/date-fns/startOfDay.js +0 -35
- package/dist/node_modules/date-fns/startOfISOWeek.js +0 -35
- package/dist/node_modules/date-fns/startOfISOWeekYear.js +0 -42
- package/dist/node_modules/date-fns/startOfMonth.js +0 -37
- package/dist/node_modules/date-fns/startOfWeek.js +0 -53
- package/dist/node_modules/date-fns/startOfWeekYear.js +0 -64
- package/dist/node_modules/date-fns/startOfYear.js +0 -36
- package/dist/node_modules/date-fns/toDate.js +0 -46
- package/dist/node_modules/embla-carousel/esm/embla-carousel.esm.js +0 -1669
- package/dist/node_modules/embla-carousel-react/esm/embla-carousel-react.esm.js +0 -37
- package/dist/node_modules/embla-carousel-reactive-utils/esm/embla-carousel-reactive-utils.esm.js +0 -38
- package/dist/node_modules/get-nonce/dist/es2015/index.js +0 -8
- package/dist/node_modules/input-otp/dist/index.js +0 -24
- package/dist/node_modules/react-day-picker/dist/esm/DayPicker.js +0 -285
- package/dist/node_modules/react-day-picker/dist/esm/UI.js +0 -122
- package/dist/node_modules/react-day-picker/dist/esm/classes/CalendarDay.js +0 -30
- package/dist/node_modules/react-day-picker/dist/esm/classes/CalendarMonth.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/classes/CalendarWeek.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/classes/DateLib.js +0 -522
- package/dist/node_modules/react-day-picker/dist/esm/components/Button.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/CaptionLabel.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Chevron.js +0 -18
- package/dist/node_modules/react-day-picker/dist/esm/components/Day.js +0 -18
- package/dist/node_modules/react-day-picker/dist/esm/components/DayButton.js +0 -19
- package/dist/node_modules/react-day-picker/dist/esm/components/Dropdown.js +0 -21
- package/dist/node_modules/react-day-picker/dist/esm/components/DropdownNav.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Footer.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Month.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/components/MonthCaption.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/components/MonthGrid.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Months.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/MonthsDropdown.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/components/Nav.js +0 -31
- package/dist/node_modules/react-day-picker/dist/esm/components/NextMonthButton.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/components/Option.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/PreviousMonthButton.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/components/Root.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/components/Select.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Week.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/components/WeekNumber.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/components/WeekNumberHeader.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Weekday.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Weekdays.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/components/Weeks.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/YearsDropdown.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/components/custom-components.js +0 -26
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatCaption.js +0 -25
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatDay.js +0 -19
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatMonthDropdown.js +0 -18
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatWeekNumber.js +0 -21
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatWeekNumberHeader.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatWeekdayName.js +0 -19
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatYearDropdown.js +0 -23
- package/dist/node_modules/react-day-picker/dist/esm/formatters/index.js +0 -7
- package/dist/node_modules/react-day-picker/dist/esm/helpers/calculateFocusTarget.js +0 -73
- package/dist/node_modules/react-day-picker/dist/esm/helpers/createGetModifiers.js +0 -95
- package/dist/node_modules/react-day-picker/dist/esm/helpers/endOfBroadcastWeek.js +0 -22
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getBroadcastWeeksInMonth.js +0 -28
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getClassNamesForModifiers.js +0 -33
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getComponents.js +0 -20
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDataAttributes.js +0 -27
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDates.js +0 -51
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDays.js +0 -19
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDefaultClassNames.js +0 -33
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDisplayMonths.js +0 -24
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getFocusableDate.js +0 -46
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getFormatters.js +0 -24
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getInitialMonth.js +0 -28
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getMonthOptions.js +0 -33
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getMonths.js +0 -69
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getNavMonth.js +0 -51
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getNextFocus.js +0 -39
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getNextMonth.js +0 -36
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getPreviousMonth.js +0 -37
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getStyleForModifiers.js +0 -27
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getWeekdays.js +0 -24
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getWeeks.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getYearOptions.js +0 -38
- package/dist/node_modules/react-day-picker/dist/esm/helpers/startOfBroadcastWeek.js +0 -27
- package/dist/node_modules/react-day-picker/dist/esm/helpers/useControlledValue.js +0 -31
- package/dist/node_modules/react-day-picker/dist/esm/labels/index.js +0 -11
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelDayButton.js +0 -32
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelGrid.js +0 -24
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelGridcell.js +0 -22
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelMonthDropdown.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelNav.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelNext.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelPrevious.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelWeekNumber.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelWeekNumberHeader.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelWeekday.js +0 -18
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelYearDropdown.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/selection/useMulti.js +0 -57
- package/dist/node_modules/react-day-picker/dist/esm/selection/useRange.js +0 -45
- package/dist/node_modules/react-day-picker/dist/esm/selection/useSingle.js +0 -44
- package/dist/node_modules/react-day-picker/dist/esm/useAnimation.js +0 -175
- package/dist/node_modules/react-day-picker/dist/esm/useCalendar.js +0 -85
- package/dist/node_modules/react-day-picker/dist/esm/useDayPicker.js +0 -25
- package/dist/node_modules/react-day-picker/dist/esm/useFocus.js +0 -50
- package/dist/node_modules/react-day-picker/dist/esm/useSelection.js +0 -31
- package/dist/node_modules/react-day-picker/dist/esm/utils/addToRange.js +0 -92
- package/dist/node_modules/react-day-picker/dist/esm/utils/dateMatchModifiers.js +0 -62
- package/dist/node_modules/react-day-picker/dist/esm/utils/rangeContainsDayOfWeek.js +0 -30
- package/dist/node_modules/react-day-picker/dist/esm/utils/rangeContainsModifiers.js +0 -74
- package/dist/node_modules/react-day-picker/dist/esm/utils/rangeIncludesDate.js +0 -35
- package/dist/node_modules/react-day-picker/dist/esm/utils/rangeOverlaps.js +0 -21
- package/dist/node_modules/react-day-picker/dist/esm/utils/typeguards.js +0 -66
- package/dist/node_modules/react-hook-form/dist/index.esm.js +0 -507
- package/dist/node_modules/react-remove-scroll/dist/es2015/Combination.js +0 -9
- package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +0 -160
- package/dist/node_modules/react-remove-scroll/dist/es2015/UI.js +0 -38
- package/dist/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +0 -21
- package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +0 -110
- package/dist/node_modules/react-remove-scroll/dist/es2015/medium.js +0 -5
- package/dist/node_modules/react-remove-scroll/dist/es2015/sidecar.js +0 -7
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.js +0 -56
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +0 -10
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +0 -31
- package/dist/node_modules/react-resizable-panels/dist/react-resizable-panels.js +0 -2407
- package/dist/node_modules/react-style-singleton/dist/es2015/component.js +0 -19
- package/dist/node_modules/react-style-singleton/dist/es2015/hook.js +0 -25
- package/dist/node_modules/react-style-singleton/dist/es2015/singleton.js +0 -51
- package/dist/node_modules/sonner/dist/index.js +0 -1125
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +0 -2956
- package/dist/node_modules/tslib/tslib.es6.js +0 -56
- package/dist/node_modules/use-callback-ref/dist/es2015/assignRef.js +0 -24
- package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +0 -48
- package/dist/node_modules/use-callback-ref/dist/es2015/useRef.js +0 -42
- package/dist/node_modules/use-sidecar/dist/es2015/exports.js +0 -21
- package/dist/node_modules/use-sidecar/dist/es2015/medium.js +0 -77
- package/dist/node_modules/vaul/dist/index.js +0 -1627
- package/dist/providers/ThemeProvider.d.ts +0 -12
- package/dist/providers/ThemeProvider.js +0 -27
- package/dist/providers/index.d.ts +0 -3
- package/dist/styles.css +0 -1
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns an array of calendar weeks from an array of calendar months.
|
|
3
|
-
*
|
|
4
|
-
* @param months The array of calendar months.
|
|
5
|
-
* @returns An array of calendar weeks.
|
|
6
|
-
*/
|
|
7
|
-
function getWeeks(months) {
|
|
8
|
-
const initialWeeks = [];
|
|
9
|
-
return months.reduce((weeks, month) => {
|
|
10
|
-
return [...weeks, ...month.weeks];
|
|
11
|
-
}, initialWeeks);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { getWeeks };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the years to display in the dropdown.
|
|
3
|
-
*
|
|
4
|
-
* This function generates a list of years between the navigation start and end
|
|
5
|
-
* dates, formatted using the provided formatter.
|
|
6
|
-
*
|
|
7
|
-
* @param navStart The start date for navigation.
|
|
8
|
-
* @param navEnd The end date for navigation.
|
|
9
|
-
* @param formatters The formatters to use for formatting the year labels.
|
|
10
|
-
* @param dateLib The date library to use for date manipulation.
|
|
11
|
-
* @returns An array of dropdown options representing the years, or `undefined`
|
|
12
|
-
* if `navStart` or `navEnd` is not provided.
|
|
13
|
-
*/
|
|
14
|
-
function getYearOptions(navStart, navEnd, formatters, dateLib) {
|
|
15
|
-
if (!navStart)
|
|
16
|
-
return undefined;
|
|
17
|
-
if (!navEnd)
|
|
18
|
-
return undefined;
|
|
19
|
-
const { startOfYear, endOfYear, addYears, getYear, isBefore, isSameYear } = dateLib;
|
|
20
|
-
const firstNavYear = startOfYear(navStart);
|
|
21
|
-
const lastNavYear = endOfYear(navEnd);
|
|
22
|
-
const years = [];
|
|
23
|
-
let year = firstNavYear;
|
|
24
|
-
while (isBefore(year, lastNavYear) || isSameYear(year, lastNavYear)) {
|
|
25
|
-
years.push(year);
|
|
26
|
-
year = addYears(year, 1);
|
|
27
|
-
}
|
|
28
|
-
return years.map((year) => {
|
|
29
|
-
const label = formatters.formatYearDropdown(year, dateLib);
|
|
30
|
-
return {
|
|
31
|
-
value: getYear(year),
|
|
32
|
-
label,
|
|
33
|
-
disabled: false
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export { getYearOptions };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the start date of the week in the broadcast calendar.
|
|
3
|
-
*
|
|
4
|
-
* The broadcast week starts on Monday. If the first day of the month is not a
|
|
5
|
-
* Monday, this function calculates the previous Monday as the start of the
|
|
6
|
-
* broadcast week.
|
|
7
|
-
*
|
|
8
|
-
* @since 9.4.0
|
|
9
|
-
* @param date The date for which to calculate the start of the broadcast week.
|
|
10
|
-
* @param dateLib The date library to use for date manipulation.
|
|
11
|
-
* @returns The start date of the broadcast week.
|
|
12
|
-
*/
|
|
13
|
-
function startOfBroadcastWeek(date, dateLib) {
|
|
14
|
-
const firstOfMonth = dateLib.startOfMonth(date);
|
|
15
|
-
const dayOfWeek = firstOfMonth.getDay();
|
|
16
|
-
if (dayOfWeek === 1) {
|
|
17
|
-
return firstOfMonth;
|
|
18
|
-
}
|
|
19
|
-
else if (dayOfWeek === 0) {
|
|
20
|
-
return dateLib.addDays(firstOfMonth, -1 * 6);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
return dateLib.addDays(firstOfMonth, -1 * (dayOfWeek - 1));
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { startOfBroadcastWeek };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A custom hook for managing both controlled and uncontrolled component states.
|
|
5
|
-
*
|
|
6
|
-
* This hook allows a component to support both controlled and uncontrolled
|
|
7
|
-
* states by determining whether the `controlledValue` is provided. If it is
|
|
8
|
-
* undefined, the hook falls back to using the internal state.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* // Uncontrolled usage
|
|
12
|
-
* const [value, setValue] = useControlledValue(0, undefined);
|
|
13
|
-
*
|
|
14
|
-
* // Controlled usage
|
|
15
|
-
* const [value, setValue] = useControlledValue(0, props.value);
|
|
16
|
-
*
|
|
17
|
-
* @template T - The type of the value.
|
|
18
|
-
* @param defaultValue The initial value for the uncontrolled state.
|
|
19
|
-
* @param controlledValue The value for the controlled state. If undefined, the
|
|
20
|
-
* component will use the uncontrolled state.
|
|
21
|
-
* @returns A tuple where the first element is the current value (either
|
|
22
|
-
* controlled or uncontrolled) and the second element is a setter function to
|
|
23
|
-
* update the value.
|
|
24
|
-
*/
|
|
25
|
-
function useControlledValue(defaultValue, controlledValue) {
|
|
26
|
-
const [uncontrolledValue, setValue] = useState(defaultValue);
|
|
27
|
-
const value = controlledValue === undefined ? uncontrolledValue : controlledValue;
|
|
28
|
-
return [value, setValue];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { useControlledValue };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { labelCaption, labelGrid } from './labelGrid.js';
|
|
2
|
-
export { labelGridcell } from './labelGridcell.js';
|
|
3
|
-
export { labelDay, labelDayButton } from './labelDayButton.js';
|
|
4
|
-
export { labelNav } from './labelNav.js';
|
|
5
|
-
export { labelMonthDropdown } from './labelMonthDropdown.js';
|
|
6
|
-
export { labelNext } from './labelNext.js';
|
|
7
|
-
export { labelPrevious } from './labelPrevious.js';
|
|
8
|
-
export { labelWeekday } from './labelWeekday.js';
|
|
9
|
-
export { labelWeekNumber } from './labelWeekNumber.js';
|
|
10
|
-
export { labelWeekNumberHeader } from './labelWeekNumberHeader.js';
|
|
11
|
-
export { labelYearDropdown } from './labelYearDropdown.js';
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { DateLib } from '../classes/DateLib.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Generates the ARIA label for a day button.
|
|
5
|
-
*
|
|
6
|
-
* Use the `modifiers` argument to provide additional context for the label,
|
|
7
|
-
* such as indicating if the day is "today" or "selected."
|
|
8
|
-
*
|
|
9
|
-
* @defaultValue The formatted date.
|
|
10
|
-
* @param date - The date to format.
|
|
11
|
-
* @param modifiers - The modifiers providing context for the day.
|
|
12
|
-
* @param options - Optional configuration for the date formatting library.
|
|
13
|
-
* @param dateLib - An optional instance of the date formatting library.
|
|
14
|
-
* @returns The ARIA label for the day button.
|
|
15
|
-
* @group Labels
|
|
16
|
-
* @see https://daypicker.dev/docs/translation#aria-labels
|
|
17
|
-
*/
|
|
18
|
-
function labelDayButton(date, modifiers, options, dateLib) {
|
|
19
|
-
let label = (dateLib ?? new DateLib(options)).format(date, "PPPP");
|
|
20
|
-
if (modifiers.today)
|
|
21
|
-
label = `Today, ${label}`;
|
|
22
|
-
if (modifiers.selected)
|
|
23
|
-
label = `${label}, selected`;
|
|
24
|
-
return label;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* @ignore
|
|
28
|
-
* @deprecated Use `labelDayButton` instead.
|
|
29
|
-
*/
|
|
30
|
-
const labelDay = labelDayButton;
|
|
31
|
-
|
|
32
|
-
export { labelDay, labelDayButton };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { DateLib } from '../classes/DateLib.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Generates the ARIA label for the month grid, which is announced when entering
|
|
5
|
-
* the grid.
|
|
6
|
-
*
|
|
7
|
-
* @defaultValue `LLLL y` (e.g., "November 2022").
|
|
8
|
-
* @param date - The date representing the month.
|
|
9
|
-
* @param options - Optional configuration for the date formatting library.
|
|
10
|
-
* @param dateLib - An optional instance of the date formatting library.
|
|
11
|
-
* @returns The ARIA label for the month grid.
|
|
12
|
-
* @group Labels
|
|
13
|
-
* @see https://daypicker.dev/docs/translation#aria-labels
|
|
14
|
-
*/
|
|
15
|
-
function labelGrid(date, options, dateLib) {
|
|
16
|
-
return (dateLib ?? new DateLib(options)).format(date, "LLLL y");
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* @ignore
|
|
20
|
-
* @deprecated Use {@link labelGrid} instead.
|
|
21
|
-
*/
|
|
22
|
-
const labelCaption = labelGrid;
|
|
23
|
-
|
|
24
|
-
export { labelCaption, labelGrid };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { DateLib } from '../classes/DateLib.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Generates the label for a day grid cell when the calendar is not interactive.
|
|
5
|
-
*
|
|
6
|
-
* @param date - The date to format.
|
|
7
|
-
* @param modifiers - Optional modifiers providing context for the day.
|
|
8
|
-
* @param options - Optional configuration for the date formatting library.
|
|
9
|
-
* @param dateLib - An optional instance of the date formatting library.
|
|
10
|
-
* @returns The label for the day grid cell.
|
|
11
|
-
* @group Labels
|
|
12
|
-
* @see https://daypicker.dev/docs/translation#aria-labels
|
|
13
|
-
*/
|
|
14
|
-
function labelGridcell(date, modifiers, options, dateLib) {
|
|
15
|
-
let label = (dateLib ?? new DateLib(options)).format(date, "PPPP");
|
|
16
|
-
if (modifiers?.today) {
|
|
17
|
-
label = `Today, ${label}`;
|
|
18
|
-
}
|
|
19
|
-
return label;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { labelGridcell };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates the ARIA label for the months dropdown.
|
|
3
|
-
*
|
|
4
|
-
* @defaultValue `"Choose the Month"`
|
|
5
|
-
* @param options - Optional configuration for the date formatting library.
|
|
6
|
-
* @returns The ARIA label for the months dropdown.
|
|
7
|
-
* @group Labels
|
|
8
|
-
* @see https://daypicker.dev/docs/translation#aria-labels
|
|
9
|
-
*/
|
|
10
|
-
function labelMonthDropdown(options) {
|
|
11
|
-
return "Choose the Month";
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { labelMonthDropdown };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates the ARIA label for the navigation toolbar.
|
|
3
|
-
*
|
|
4
|
-
* @defaultValue `""`
|
|
5
|
-
* @returns The ARIA label for the navigation toolbar.
|
|
6
|
-
* @group Labels
|
|
7
|
-
* @see https://daypicker.dev/docs/translation#aria-labels
|
|
8
|
-
*/
|
|
9
|
-
function labelNav() {
|
|
10
|
-
return "";
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { labelNav };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates the ARIA label for the "next month" button.
|
|
3
|
-
*
|
|
4
|
-
* @defaultValue `"Go to the Next Month"`
|
|
5
|
-
* @param month - The date representing the next month, or `undefined` if there
|
|
6
|
-
* is no next month.
|
|
7
|
-
* @returns The ARIA label for the "next month" button.
|
|
8
|
-
* @group Labels
|
|
9
|
-
* @see https://daypicker.dev/docs/translation#aria-labels
|
|
10
|
-
*/
|
|
11
|
-
function labelNext(month) {
|
|
12
|
-
return "Go to the Next Month";
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { labelNext };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates the ARIA label for the "previous month" button.
|
|
3
|
-
*
|
|
4
|
-
* @defaultValue `"Go to the Previous Month"`
|
|
5
|
-
* @param month - The date representing the previous month, or `undefined` if
|
|
6
|
-
* there is no previous month.
|
|
7
|
-
* @returns The ARIA label for the "previous month" button.
|
|
8
|
-
* @group Labels
|
|
9
|
-
* @see https://daypicker.dev/docs/translation#aria-labels
|
|
10
|
-
*/
|
|
11
|
-
function labelPrevious(month) {
|
|
12
|
-
return "Go to the Previous Month";
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { labelPrevious };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates the ARIA label for the week number cell (the first cell in a row).
|
|
3
|
-
*
|
|
4
|
-
* @defaultValue `Week ${weekNumber}`
|
|
5
|
-
* @param weekNumber - The number of the week.
|
|
6
|
-
* @param options - Optional configuration for the date formatting library.
|
|
7
|
-
* @returns The ARIA label for the week number cell.
|
|
8
|
-
* @group Labels
|
|
9
|
-
* @see https://daypicker.dev/docs/translation#aria-labels
|
|
10
|
-
*/
|
|
11
|
-
function labelWeekNumber(weekNumber, options) {
|
|
12
|
-
return `Week ${weekNumber}`;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { labelWeekNumber };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates the ARIA label for the week number header element.
|
|
3
|
-
*
|
|
4
|
-
* @defaultValue `"Week Number"`
|
|
5
|
-
* @param options - Optional configuration for the date formatting library.
|
|
6
|
-
* @returns The ARIA label for the week number header.
|
|
7
|
-
* @group Labels
|
|
8
|
-
* @see https://daypicker.dev/docs/translation#aria-labels
|
|
9
|
-
*/
|
|
10
|
-
function labelWeekNumberHeader(options) {
|
|
11
|
-
return "Week Number";
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { labelWeekNumberHeader };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { DateLib } from '../classes/DateLib.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Generates the ARIA label for a weekday column header.
|
|
5
|
-
*
|
|
6
|
-
* @defaultValue `"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"`
|
|
7
|
-
* @param date - The date representing the weekday.
|
|
8
|
-
* @param options - Optional configuration for the date formatting library.
|
|
9
|
-
* @param dateLib - An optional instance of the date formatting library.
|
|
10
|
-
* @returns The ARIA label for the weekday column header.
|
|
11
|
-
* @group Labels
|
|
12
|
-
* @see https://daypicker.dev/docs/translation#aria-labels
|
|
13
|
-
*/
|
|
14
|
-
function labelWeekday(date, options, dateLib) {
|
|
15
|
-
return (dateLib ?? new DateLib(options)).format(date, "cccc");
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { labelWeekday };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates the ARIA label for the years dropdown.
|
|
3
|
-
*
|
|
4
|
-
* @defaultValue `"Choose the Year"`
|
|
5
|
-
* @param options - Optional configuration for the date formatting library.
|
|
6
|
-
* @returns The ARIA label for the years dropdown.
|
|
7
|
-
* @group Labels
|
|
8
|
-
* @see https://daypicker.dev/docs/translation#aria-labels
|
|
9
|
-
*/
|
|
10
|
-
function labelYearDropdown(options) {
|
|
11
|
-
return "Choose the Year";
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { labelYearDropdown };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { useControlledValue } from '../helpers/useControlledValue.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Hook to manage multiple-date selection in the DayPicker component.
|
|
5
|
-
*
|
|
6
|
-
* @template T - The type of DayPicker props.
|
|
7
|
-
* @param props - The DayPicker props.
|
|
8
|
-
* @param dateLib - The date utility library instance.
|
|
9
|
-
* @returns An object containing the selected dates, a function to select dates,
|
|
10
|
-
* and a function to check if a date is selected.
|
|
11
|
-
*/
|
|
12
|
-
function useMulti(props, dateLib) {
|
|
13
|
-
const { selected: initiallySelected, required, onSelect } = props;
|
|
14
|
-
const [internallySelected, setSelected] = useControlledValue(initiallySelected, onSelect ? initiallySelected : undefined);
|
|
15
|
-
const selected = !onSelect ? internallySelected : initiallySelected;
|
|
16
|
-
const { isSameDay } = dateLib;
|
|
17
|
-
const isSelected = (date) => {
|
|
18
|
-
return selected?.some((d) => isSameDay(d, date)) ?? false;
|
|
19
|
-
};
|
|
20
|
-
const { min, max } = props;
|
|
21
|
-
const select = (triggerDate, modifiers, e) => {
|
|
22
|
-
let newDates = [...(selected ?? [])];
|
|
23
|
-
if (isSelected(triggerDate)) {
|
|
24
|
-
if (selected?.length === min) {
|
|
25
|
-
// Min value reached, do nothing
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (required && selected?.length === 1) {
|
|
29
|
-
// Required value already selected do nothing
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
newDates = selected?.filter((d) => !isSameDay(d, triggerDate));
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
if (selected?.length === max) {
|
|
36
|
-
// Max value reached, reset the selection to date
|
|
37
|
-
newDates = [triggerDate];
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
// Add the date to the selection
|
|
41
|
-
newDates = [...newDates, triggerDate];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (!onSelect) {
|
|
45
|
-
setSelected(newDates);
|
|
46
|
-
}
|
|
47
|
-
onSelect?.(newDates, triggerDate, modifiers, e);
|
|
48
|
-
return newDates;
|
|
49
|
-
};
|
|
50
|
-
return {
|
|
51
|
-
selected,
|
|
52
|
-
select,
|
|
53
|
-
isSelected
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export { useMulti };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { useControlledValue } from '../helpers/useControlledValue.js';
|
|
2
|
-
import { rangeIncludesDate } from '../utils/rangeIncludesDate.js';
|
|
3
|
-
import { addToRange } from '../utils/addToRange.js';
|
|
4
|
-
import { rangeContainsModifiers } from '../utils/rangeContainsModifiers.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Hook to manage range selection in the DayPicker component.
|
|
8
|
-
*
|
|
9
|
-
* @template T - The type of DayPicker props.
|
|
10
|
-
* @param props - The DayPicker props.
|
|
11
|
-
* @param dateLib - The date utility library instance.
|
|
12
|
-
* @returns An object containing the selected range, a function to select a
|
|
13
|
-
* range, and a function to check if a date is within the range.
|
|
14
|
-
*/
|
|
15
|
-
function useRange(props, dateLib) {
|
|
16
|
-
const { disabled, excludeDisabled, selected: initiallySelected, required, onSelect } = props;
|
|
17
|
-
const [internallySelected, setSelected] = useControlledValue(initiallySelected, onSelect ? initiallySelected : undefined);
|
|
18
|
-
const selected = !onSelect ? internallySelected : initiallySelected;
|
|
19
|
-
const isSelected = (date) => selected && rangeIncludesDate(selected, date, false, dateLib);
|
|
20
|
-
const select = (triggerDate, modifiers, e) => {
|
|
21
|
-
const { min, max } = props;
|
|
22
|
-
const newRange = triggerDate
|
|
23
|
-
? addToRange(triggerDate, selected, min, max, required, dateLib)
|
|
24
|
-
: undefined;
|
|
25
|
-
if (excludeDisabled && disabled && newRange?.from && newRange.to) {
|
|
26
|
-
if (rangeContainsModifiers({ from: newRange.from, to: newRange.to }, disabled, dateLib)) {
|
|
27
|
-
// if a disabled days is found, the range is reset
|
|
28
|
-
newRange.from = triggerDate;
|
|
29
|
-
newRange.to = undefined;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (!onSelect) {
|
|
33
|
-
setSelected(newRange);
|
|
34
|
-
}
|
|
35
|
-
onSelect?.(newRange, triggerDate, modifiers, e);
|
|
36
|
-
return newRange;
|
|
37
|
-
};
|
|
38
|
-
return {
|
|
39
|
-
selected,
|
|
40
|
-
select,
|
|
41
|
-
isSelected
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export { useRange };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { useControlledValue } from '../helpers/useControlledValue.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Hook to manage single-date selection in the DayPicker component.
|
|
5
|
-
*
|
|
6
|
-
* @template T - The type of DayPicker props.
|
|
7
|
-
* @param props - The DayPicker props.
|
|
8
|
-
* @param dateLib - The date utility library instance.
|
|
9
|
-
* @returns An object containing the selected date, a function to select a date,
|
|
10
|
-
* and a function to check if a date is selected.
|
|
11
|
-
*/
|
|
12
|
-
function useSingle(props, dateLib) {
|
|
13
|
-
const { selected: initiallySelected, required, onSelect } = props;
|
|
14
|
-
const [internallySelected, setSelected] = useControlledValue(initiallySelected, onSelect ? initiallySelected : undefined);
|
|
15
|
-
const selected = !onSelect ? internallySelected : initiallySelected;
|
|
16
|
-
const { isSameDay } = dateLib;
|
|
17
|
-
const isSelected = (compareDate) => {
|
|
18
|
-
return selected ? isSameDay(selected, compareDate) : false;
|
|
19
|
-
};
|
|
20
|
-
const select = (triggerDate, modifiers, e) => {
|
|
21
|
-
let newDate = triggerDate;
|
|
22
|
-
if (!required && selected && selected && isSameDay(triggerDate, selected)) {
|
|
23
|
-
// If the date is the same, clear the selection.
|
|
24
|
-
newDate = undefined;
|
|
25
|
-
}
|
|
26
|
-
if (!onSelect) {
|
|
27
|
-
setSelected(newDate);
|
|
28
|
-
}
|
|
29
|
-
if (required) {
|
|
30
|
-
onSelect?.(newDate, triggerDate, modifiers, e);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
onSelect?.(newDate, triggerDate, modifiers, e);
|
|
34
|
-
}
|
|
35
|
-
return newDate;
|
|
36
|
-
};
|
|
37
|
-
return {
|
|
38
|
-
selected,
|
|
39
|
-
select,
|
|
40
|
-
isSelected
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { useSingle };
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { useRef, useLayoutEffect } from 'react';
|
|
2
|
-
import { Animation } from './UI.js';
|
|
3
|
-
|
|
4
|
-
const asHtmlElement = (element) => {
|
|
5
|
-
if (element instanceof HTMLElement)
|
|
6
|
-
return element;
|
|
7
|
-
return null;
|
|
8
|
-
};
|
|
9
|
-
const queryMonthEls = (element) => [
|
|
10
|
-
...(element.querySelectorAll("[data-animated-month]") ?? [])
|
|
11
|
-
];
|
|
12
|
-
const queryMonthEl = (element) => asHtmlElement(element.querySelector("[data-animated-month]"));
|
|
13
|
-
const queryCaptionEl = (element) => asHtmlElement(element.querySelector("[data-animated-caption]"));
|
|
14
|
-
const queryWeeksEl = (element) => asHtmlElement(element.querySelector("[data-animated-weeks]"));
|
|
15
|
-
const queryNavEl = (element) => asHtmlElement(element.querySelector("[data-animated-nav]"));
|
|
16
|
-
const queryWeekdaysEl = (element) => asHtmlElement(element.querySelector("[data-animated-weekdays]"));
|
|
17
|
-
/**
|
|
18
|
-
* Handles animations for transitioning between months in the DayPicker
|
|
19
|
-
* component.
|
|
20
|
-
*
|
|
21
|
-
* @private
|
|
22
|
-
* @param rootElRef - A reference to the root element of the DayPicker
|
|
23
|
-
* component.
|
|
24
|
-
* @param enabled - Whether animations are enabled.
|
|
25
|
-
* @param options - Configuration options for the animation, including class
|
|
26
|
-
* names, months, focused day, and the date utility library.
|
|
27
|
-
*/
|
|
28
|
-
function useAnimation(rootElRef, enabled, { classNames, months, focused, dateLib }) {
|
|
29
|
-
const previousRootElSnapshotRef = useRef(null);
|
|
30
|
-
const previousMonthsRef = useRef(months);
|
|
31
|
-
const animatingRef = useRef(false);
|
|
32
|
-
useLayoutEffect(() => {
|
|
33
|
-
// get previous months before updating the previous months ref
|
|
34
|
-
const previousMonths = previousMonthsRef.current;
|
|
35
|
-
// update previous months ref for next effect trigger
|
|
36
|
-
previousMonthsRef.current = months;
|
|
37
|
-
if (!enabled ||
|
|
38
|
-
!rootElRef.current ||
|
|
39
|
-
// safety check because the ref can be set to anything by consumers
|
|
40
|
-
!(rootElRef.current instanceof HTMLElement) ||
|
|
41
|
-
// validation required for the animation to work as expected
|
|
42
|
-
months.length === 0 ||
|
|
43
|
-
previousMonths.length === 0 ||
|
|
44
|
-
months.length !== previousMonths.length) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const isSameMonth = dateLib.isSameMonth(months[0].date, previousMonths[0].date);
|
|
48
|
-
const isAfterPreviousMonth = dateLib.isAfter(months[0].date, previousMonths[0].date);
|
|
49
|
-
const captionAnimationClass = isAfterPreviousMonth
|
|
50
|
-
? classNames[Animation.caption_after_enter]
|
|
51
|
-
: classNames[Animation.caption_before_enter];
|
|
52
|
-
const weeksAnimationClass = isAfterPreviousMonth
|
|
53
|
-
? classNames[Animation.weeks_after_enter]
|
|
54
|
-
: classNames[Animation.weeks_before_enter];
|
|
55
|
-
// get previous root element snapshot before updating the snapshot ref
|
|
56
|
-
const previousRootElSnapshot = previousRootElSnapshotRef.current;
|
|
57
|
-
// update snapshot for next effect trigger
|
|
58
|
-
const rootElSnapshot = rootElRef.current.cloneNode(true);
|
|
59
|
-
if (rootElSnapshot instanceof HTMLElement) {
|
|
60
|
-
// if this effect is triggered while animating, we need to clean up the new root snapshot
|
|
61
|
-
// to put it in the same state as when not animating, to correctly animate the next month change
|
|
62
|
-
const currentMonthElsSnapshot = queryMonthEls(rootElSnapshot);
|
|
63
|
-
currentMonthElsSnapshot.forEach((currentMonthElSnapshot) => {
|
|
64
|
-
if (!(currentMonthElSnapshot instanceof HTMLElement))
|
|
65
|
-
return;
|
|
66
|
-
// remove the old month snapshots from the new root snapshot
|
|
67
|
-
const previousMonthElSnapshot = queryMonthEl(currentMonthElSnapshot);
|
|
68
|
-
if (previousMonthElSnapshot &&
|
|
69
|
-
currentMonthElSnapshot.contains(previousMonthElSnapshot)) {
|
|
70
|
-
currentMonthElSnapshot.removeChild(previousMonthElSnapshot);
|
|
71
|
-
}
|
|
72
|
-
// remove animation classes from the new month snapshots
|
|
73
|
-
const captionEl = queryCaptionEl(currentMonthElSnapshot);
|
|
74
|
-
if (captionEl) {
|
|
75
|
-
captionEl.classList.remove(captionAnimationClass);
|
|
76
|
-
}
|
|
77
|
-
const weeksEl = queryWeeksEl(currentMonthElSnapshot);
|
|
78
|
-
if (weeksEl) {
|
|
79
|
-
weeksEl.classList.remove(weeksAnimationClass);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
previousRootElSnapshotRef.current = rootElSnapshot;
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
previousRootElSnapshotRef.current = null;
|
|
86
|
-
}
|
|
87
|
-
if (animatingRef.current ||
|
|
88
|
-
isSameMonth ||
|
|
89
|
-
// skip animation if a day is focused because it can cause issues to the animation and is better for a11y
|
|
90
|
-
focused) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const previousMonthEls = previousRootElSnapshot instanceof HTMLElement
|
|
94
|
-
? queryMonthEls(previousRootElSnapshot)
|
|
95
|
-
: [];
|
|
96
|
-
const currentMonthEls = queryMonthEls(rootElRef.current);
|
|
97
|
-
if (currentMonthEls &&
|
|
98
|
-
currentMonthEls.every((el) => el instanceof HTMLElement) &&
|
|
99
|
-
previousMonthEls &&
|
|
100
|
-
previousMonthEls.every((el) => el instanceof HTMLElement)) {
|
|
101
|
-
animatingRef.current = true;
|
|
102
|
-
// set isolation to isolate to isolate the stacking context during animation
|
|
103
|
-
rootElRef.current.style.isolation = "isolate";
|
|
104
|
-
// set z-index to 1 to ensure the nav is clickable over the other elements being animated
|
|
105
|
-
const navEl = queryNavEl(rootElRef.current);
|
|
106
|
-
if (navEl) {
|
|
107
|
-
navEl.style.zIndex = "1";
|
|
108
|
-
}
|
|
109
|
-
currentMonthEls.forEach((currentMonthEl, index) => {
|
|
110
|
-
const previousMonthEl = previousMonthEls[index];
|
|
111
|
-
if (!previousMonthEl) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
// animate new displayed month
|
|
115
|
-
currentMonthEl.style.position = "relative";
|
|
116
|
-
currentMonthEl.style.overflow = "hidden";
|
|
117
|
-
const captionEl = queryCaptionEl(currentMonthEl);
|
|
118
|
-
if (captionEl) {
|
|
119
|
-
captionEl.classList.add(captionAnimationClass);
|
|
120
|
-
}
|
|
121
|
-
const weeksEl = queryWeeksEl(currentMonthEl);
|
|
122
|
-
if (weeksEl) {
|
|
123
|
-
weeksEl.classList.add(weeksAnimationClass);
|
|
124
|
-
}
|
|
125
|
-
// animate new displayed month end
|
|
126
|
-
const cleanUp = () => {
|
|
127
|
-
animatingRef.current = false;
|
|
128
|
-
if (rootElRef.current) {
|
|
129
|
-
rootElRef.current.style.isolation = "";
|
|
130
|
-
}
|
|
131
|
-
if (navEl) {
|
|
132
|
-
navEl.style.zIndex = "";
|
|
133
|
-
}
|
|
134
|
-
if (captionEl) {
|
|
135
|
-
captionEl.classList.remove(captionAnimationClass);
|
|
136
|
-
}
|
|
137
|
-
if (weeksEl) {
|
|
138
|
-
weeksEl.classList.remove(weeksAnimationClass);
|
|
139
|
-
}
|
|
140
|
-
currentMonthEl.style.position = "";
|
|
141
|
-
currentMonthEl.style.overflow = "";
|
|
142
|
-
if (currentMonthEl.contains(previousMonthEl)) {
|
|
143
|
-
currentMonthEl.removeChild(previousMonthEl);
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
// animate old displayed month
|
|
147
|
-
previousMonthEl.style.pointerEvents = "none";
|
|
148
|
-
previousMonthEl.style.position = "absolute";
|
|
149
|
-
previousMonthEl.style.overflow = "hidden";
|
|
150
|
-
previousMonthEl.setAttribute("aria-hidden", "true");
|
|
151
|
-
// hide the weekdays container of the old month and only the new one
|
|
152
|
-
const previousWeekdaysEl = queryWeekdaysEl(previousMonthEl);
|
|
153
|
-
if (previousWeekdaysEl) {
|
|
154
|
-
previousWeekdaysEl.style.opacity = "0";
|
|
155
|
-
}
|
|
156
|
-
const previousCaptionEl = queryCaptionEl(previousMonthEl);
|
|
157
|
-
if (previousCaptionEl) {
|
|
158
|
-
previousCaptionEl.classList.add(isAfterPreviousMonth
|
|
159
|
-
? classNames[Animation.caption_before_exit]
|
|
160
|
-
: classNames[Animation.caption_after_exit]);
|
|
161
|
-
previousCaptionEl.addEventListener("animationend", cleanUp);
|
|
162
|
-
}
|
|
163
|
-
const previousWeeksEl = queryWeeksEl(previousMonthEl);
|
|
164
|
-
if (previousWeeksEl) {
|
|
165
|
-
previousWeeksEl.classList.add(isAfterPreviousMonth
|
|
166
|
-
? classNames[Animation.weeks_before_exit]
|
|
167
|
-
: classNames[Animation.weeks_after_exit]);
|
|
168
|
-
}
|
|
169
|
-
currentMonthEl.insertBefore(previousMonthEl, currentMonthEl.firstChild);
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
export { useAnimation };
|