@coopdigital/react 0.49.1 → 0.51.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/dist/components/Button/Button.js +2 -2
- package/dist/components/Button/index.js +5 -0
- package/dist/components/Card/Card.js +4 -4
- package/dist/components/Checkbox/Checkbox.d.ts +7 -1
- package/dist/components/Checkbox/Checkbox.js +4 -0
- package/dist/components/DatePicker/DatePicker.d.ts +61 -0
- package/dist/components/DatePicker/DatePicker.js +135 -0
- package/dist/components/DatePicker/datepicker-utils.d.ts +68 -0
- package/dist/components/DatePicker/datepicker-utils.js +215 -0
- package/dist/components/DatePicker/index.d.ts +4 -0
- package/dist/components/Field/Field.js +29 -26
- package/dist/components/Field/index.js +6 -0
- package/dist/components/Pill/Pill.js +2 -2
- package/dist/components/Popover/Popover.d.ts +74 -0
- package/dist/components/Popover/Popover.js +75 -0
- package/dist/components/Popover/index.d.ts +4 -0
- package/dist/components/Popover/index.js +5 -0
- package/dist/components/Radio/Radio.d.ts +7 -1
- package/dist/components/Radio/Radio.js +4 -0
- package/dist/components/Searchbox/Searchbox.js +4 -3
- package/dist/components/Select/Select.d.ts +3 -0
- package/dist/components/Select/Select.js +4 -1
- package/dist/components/Signpost/Signpost.js +2 -2
- package/dist/components/Tag/Tag.js +2 -2
- package/dist/components/TextInput/TextInput.d.ts +6 -1
- package/dist/components/TextInput/TextInput.js +3 -0
- package/dist/components/Textarea/Textarea.d.ts +8 -5
- package/dist/components/Textarea/Textarea.js +5 -4
- package/dist/hooks/useSlots.js +3 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/node_modules/@date-fns/tz/date/index.js +83 -0
- package/dist/node_modules/@date-fns/tz/date/mini.js +235 -0
- package/dist/node_modules/@date-fns/tz/tzName/index.js +39 -0
- package/dist/node_modules/@date-fns/tz/tzOffset/index.js +44 -0
- package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +814 -0
- package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +751 -0
- package/dist/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +350 -0
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +161 -0
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +137 -0
- package/dist/node_modules/@radix-ui/primitive/dist/index.js +11 -0
- package/dist/node_modules/@radix-ui/react-arrow/dist/index.js +25 -0
- package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.js +39 -0
- package/dist/node_modules/@radix-ui/react-context/dist/index.js +63 -0
- package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +213 -0
- package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.js +31 -0
- package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.js +209 -0
- package/dist/node_modules/@radix-ui/react-id/dist/index.js +15 -0
- package/dist/node_modules/@radix-ui/react-popover/dist/index.js +303 -0
- package/dist/node_modules/@radix-ui/react-popper/dist/index.js +285 -0
- package/dist/node_modules/@radix-ui/react-portal/dist/index.js +19 -0
- package/dist/node_modules/@radix-ui/react-presence/dist/index.js +132 -0
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.js +43 -0
- package/dist/node_modules/@radix-ui/react-slot/dist/index.js +89 -0
- package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +12 -0
- package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +70 -0
- package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +18 -0
- package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +7 -0
- package/dist/node_modules/@radix-ui/react-use-size/dist/index.js +40 -0
- package/dist/node_modules/aria-hidden/dist/es2015/index.js +137 -0
- package/dist/node_modules/date-fns/_lib/addLeadingZeros.js +7 -0
- package/dist/node_modules/date-fns/_lib/defaultOptions.js +7 -0
- package/dist/node_modules/date-fns/_lib/format/formatters.js +775 -0
- package/dist/node_modules/date-fns/_lib/format/lightFormatters.js +94 -0
- package/dist/node_modules/date-fns/_lib/format/longFormatters.js +66 -0
- package/dist/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js +31 -0
- package/dist/node_modules/date-fns/_lib/normalizeDates.js +11 -0
- package/dist/node_modules/date-fns/_lib/normalizeInterval.js +8 -0
- package/dist/node_modules/date-fns/_lib/protectedTokens.js +25 -0
- package/dist/node_modules/date-fns/addDays.js +41 -0
- package/dist/node_modules/date-fns/addMonths.js +75 -0
- package/dist/node_modules/date-fns/addWeeks.js +33 -0
- package/dist/node_modules/date-fns/addYears.js +33 -0
- package/dist/node_modules/date-fns/constants.js +67 -0
- package/dist/node_modules/date-fns/constructFrom.js +49 -0
- package/dist/node_modules/date-fns/differenceInCalendarDays.js +62 -0
- package/dist/node_modules/date-fns/differenceInCalendarMonths.js +42 -0
- package/dist/node_modules/date-fns/eachMonthOfInterval.js +65 -0
- package/dist/node_modules/date-fns/eachYearOfInterval.js +65 -0
- package/dist/node_modules/date-fns/endOfISOWeek.js +35 -0
- package/dist/node_modules/date-fns/endOfMonth.js +37 -0
- package/dist/node_modules/date-fns/endOfWeek.js +53 -0
- package/dist/node_modules/date-fns/endOfYear.js +37 -0
- package/dist/node_modules/date-fns/format.js +423 -0
- package/dist/node_modules/date-fns/getDayOfYear.js +34 -0
- package/dist/node_modules/date-fns/getDaysInMonth.js +36 -0
- package/dist/node_modules/date-fns/getDefaultOptions.js +31 -0
- package/dist/node_modules/date-fns/getISODay.js +33 -0
- package/dist/node_modules/date-fns/getISOWeek.js +40 -0
- package/dist/node_modules/date-fns/getISOWeekYear.js +52 -0
- package/dist/node_modules/date-fns/getMonth.js +29 -0
- package/dist/node_modules/date-fns/getWeek.js +54 -0
- package/dist/node_modules/date-fns/getWeekYear.js +75 -0
- package/dist/node_modules/date-fns/getYear.js +29 -0
- package/dist/node_modules/date-fns/isAfter.js +25 -0
- package/dist/node_modules/date-fns/isBefore.js +25 -0
- package/dist/node_modules/date-fns/isDate.js +41 -0
- package/dist/node_modules/date-fns/isSameDay.js +46 -0
- package/dist/node_modules/date-fns/isSameMonth.js +43 -0
- package/dist/node_modules/date-fns/isSameYear.js +35 -0
- package/dist/node_modules/date-fns/isValid.js +39 -0
- package/dist/node_modules/date-fns/locale/_lib/buildFormatLongFn.js +10 -0
- package/dist/node_modules/date-fns/locale/_lib/buildLocalizeFn.js +64 -0
- package/dist/node_modules/date-fns/locale/_lib/buildMatchFn.js +59 -0
- package/dist/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js +22 -0
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatDistance.js +103 -0
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatLong.js +41 -0
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatRelative.js +13 -0
- package/dist/node_modules/date-fns/locale/en-US/_lib/localize.js +189 -0
- package/dist/node_modules/date-fns/locale/en-US/_lib/match.js +134 -0
- package/dist/node_modules/date-fns/locale/en-US.js +28 -0
- package/dist/node_modules/date-fns/max.js +49 -0
- package/dist/node_modules/date-fns/min.js +49 -0
- package/dist/node_modules/date-fns/parse/_lib/Parser.js +27 -0
- package/dist/node_modules/date-fns/parse/_lib/Setter.js +59 -0
- package/dist/node_modules/date-fns/parse/_lib/constants.js +33 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/AMPMMidnightParser.js +55 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/AMPMParser.js +55 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/DateParser.js +59 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/DayOfYearParser.js +57 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/DayParser.js +64 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/DayPeriodParser.js +56 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/EraParser.js +41 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/ExtendedYearParser.js +24 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/FractionOfSecondParser.js +21 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/Hour0To11Parser.js +36 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/Hour0to23Parser.js +31 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/Hour1To24Parser.js +32 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/Hour1to12Parser.js +38 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/ISODayParser.js +118 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/ISOTimezoneParser.js +47 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/ISOTimezoneWithZParser.js +47 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/ISOWeekParser.js +48 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/ISOWeekYearParser.js +44 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/LocalDayParser.js +96 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/LocalWeekParser.js +47 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/LocalWeekYearParser.js +76 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/MinuteParser.js +31 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/MonthParser.js +86 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/QuarterParser.js +83 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/SecondParser.js +31 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/StandAloneLocalDayParser.js +97 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/StandAloneMonthParser.js +86 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/StandAloneQuarterParser.js +83 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/TimestampMillisecondsParser.js +19 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/TimestampSecondsParser.js +19 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers/YearParser.js +62 -0
- package/dist/node_modules/date-fns/parse/_lib/parsers.js +110 -0
- package/dist/node_modules/date-fns/parse/_lib/utils.js +135 -0
- package/dist/node_modules/date-fns/parse.js +497 -0
- package/dist/node_modules/date-fns/setDay.js +59 -0
- package/dist/node_modules/date-fns/setISODay.js +40 -0
- package/dist/node_modules/date-fns/setISOWeek.js +39 -0
- package/dist/node_modules/date-fns/setMonth.js +46 -0
- package/dist/node_modules/date-fns/setWeek.js +53 -0
- package/dist/node_modules/date-fns/setYear.js +40 -0
- package/dist/node_modules/date-fns/startOfDay.js +35 -0
- package/dist/node_modules/date-fns/startOfISOWeek.js +35 -0
- package/dist/node_modules/date-fns/startOfISOWeekYear.js +42 -0
- package/dist/node_modules/date-fns/startOfMonth.js +37 -0
- package/dist/node_modules/date-fns/startOfWeek.js +53 -0
- package/dist/node_modules/date-fns/startOfWeekYear.js +64 -0
- package/dist/node_modules/date-fns/startOfYear.js +36 -0
- package/dist/node_modules/date-fns/toDate.js +46 -0
- package/dist/node_modules/date-fns/transpose.js +52 -0
- package/dist/node_modules/get-nonce/dist/es2015/index.js +8 -0
- package/dist/node_modules/react-day-picker/dist/esm/DayPicker.js +320 -0
- package/dist/node_modules/react-day-picker/dist/esm/UI.js +122 -0
- package/dist/node_modules/react-day-picker/dist/esm/classes/CalendarDay.js +33 -0
- package/dist/node_modules/react-day-picker/dist/esm/classes/CalendarMonth.js +14 -0
- package/dist/node_modules/react-day-picker/dist/esm/classes/CalendarWeek.js +13 -0
- package/dist/node_modules/react-day-picker/dist/esm/classes/DateLib.js +604 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/Button.js +13 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/CaptionLabel.js +13 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/Chevron.js +20 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/Day.js +18 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/DayButton.js +19 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/Dropdown.js +21 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/DropdownNav.js +13 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/Footer.js +13 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/Month.js +15 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/MonthCaption.js +14 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/MonthGrid.js +13 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/Months.js +13 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/MonthsDropdown.js +15 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/Nav.js +31 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/NextMonthButton.js +15 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/Option.js +13 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/PreviousMonthButton.js +15 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/Root.js +14 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/Select.js +13 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/Week.js +14 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/WeekNumber.js +14 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/WeekNumberHeader.js +13 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/Weekday.js +13 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/Weekdays.js +14 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/Weeks.js +13 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/YearsDropdown.js +15 -0
- package/dist/node_modules/react-day-picker/dist/esm/components/custom-components.js +26 -0
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatCaption.js +26 -0
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatDay.js +19 -0
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatMonthDropdown.js +18 -0
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatWeekNumber.js +21 -0
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatWeekNumberHeader.js +13 -0
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatWeekdayName.js +19 -0
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatYearDropdown.js +23 -0
- package/dist/node_modules/react-day-picker/dist/esm/formatters/index.js +7 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/calculateFocusTarget.js +73 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/createGetModifiers.js +95 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/endOfBroadcastWeek.js +22 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getBroadcastWeeksInMonth.js +28 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getClassNamesForModifiers.js +33 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getComponents.js +20 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDataAttributes.js +27 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDates.js +59 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDays.js +19 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDefaultClassNames.js +33 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDisplayMonths.js +24 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getFocusableDate.js +46 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getFormatters.js +24 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getInitialMonth.js +27 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getLabels.js +53 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getMonthOptions.js +33 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getMonths.js +69 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getNavMonth.js +51 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getNextFocus.js +40 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getNextMonth.js +36 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getPreviousMonth.js +37 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getStyleForModifiers.js +27 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getWeekdays.js +26 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getWeeks.js +14 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getYearOptions.js +36 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/startOfBroadcastWeek.js +27 -0
- package/dist/node_modules/react-day-picker/dist/esm/helpers/useControlledValue.js +31 -0
- package/dist/node_modules/react-day-picker/dist/esm/labels/index.js +11 -0
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelDayButton.js +32 -0
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelGrid.js +25 -0
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelGridcell.js +22 -0
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelMonthDropdown.js +14 -0
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelNav.js +13 -0
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelNext.js +16 -0
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelPrevious.js +15 -0
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelWeekNumber.js +15 -0
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelWeekNumberHeader.js +14 -0
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelWeekday.js +18 -0
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelYearDropdown.js +14 -0
- package/dist/node_modules/react-day-picker/dist/esm/locale/en-US.js +67 -0
- package/dist/node_modules/react-day-picker/dist/esm/selection/useMulti.js +57 -0
- package/dist/node_modules/react-day-picker/dist/esm/selection/useRange.js +45 -0
- package/dist/node_modules/react-day-picker/dist/esm/selection/useSingle.js +44 -0
- package/dist/node_modules/react-day-picker/dist/esm/useAnimation.js +174 -0
- package/dist/node_modules/react-day-picker/dist/esm/useCalendar.js +113 -0
- package/dist/node_modules/react-day-picker/dist/esm/useDayPicker.js +25 -0
- package/dist/node_modules/react-day-picker/dist/esm/useFocus.js +56 -0
- package/dist/node_modules/react-day-picker/dist/esm/useSelection.js +31 -0
- package/dist/node_modules/react-day-picker/dist/esm/utils/addToRange.js +95 -0
- package/dist/node_modules/react-day-picker/dist/esm/utils/convertMatchersToTimeZone.js +57 -0
- package/dist/node_modules/react-day-picker/dist/esm/utils/dateMatchModifiers.js +62 -0
- package/dist/node_modules/react-day-picker/dist/esm/utils/rangeContainsDayOfWeek.js +30 -0
- package/dist/node_modules/react-day-picker/dist/esm/utils/rangeContainsModifiers.js +74 -0
- package/dist/node_modules/react-day-picker/dist/esm/utils/rangeIncludesDate.js +35 -0
- package/dist/node_modules/react-day-picker/dist/esm/utils/rangeOverlaps.js +21 -0
- package/dist/node_modules/react-day-picker/dist/esm/utils/toTimeZone.js +16 -0
- package/dist/node_modules/react-day-picker/dist/esm/utils/typeguards.js +66 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/Combination.js +9 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +167 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/UI.js +38 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +21 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +110 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/medium.js +5 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/sidecar.js +7 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.js +56 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +10 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +31 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/component.js +19 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/hook.js +25 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/singleton.js +51 -0
- package/dist/node_modules/tslib/tslib.es6.js +56 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/assignRef.js +24 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +48 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/useRef.js +42 -0
- package/dist/node_modules/use-sidecar/dist/es2015/exports.js +21 -0
- package/dist/node_modules/use-sidecar/dist/es2015/medium.js +77 -0
- package/dist/types/index.d.ts +10 -0
- package/package.json +11 -7
- package/src/components/Checkbox/Checkbox.tsx +6 -1
- package/src/components/DatePicker/DatePicker.tsx +372 -0
- package/src/components/DatePicker/datepicker-utils.ts +269 -0
- package/src/components/DatePicker/index.ts +5 -0
- package/src/components/Field/Field.tsx +30 -28
- package/src/components/Popover/Popover.tsx +198 -0
- package/src/components/Popover/index.ts +5 -0
- package/src/components/Radio/Radio.tsx +6 -1
- package/src/components/Searchbox/Searchbox.tsx +4 -1
- package/src/components/Select/Select.tsx +7 -2
- package/src/components/TextInput/TextInput.tsx +5 -1
- package/src/components/Textarea/Textarea.tsx +9 -13
- package/src/index.ts +2 -0
- package/src/types/index.ts +15 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { getDefaultOptions } from './_lib/defaultOptions.js';
|
|
2
|
+
import { addDays } from './addDays.js';
|
|
3
|
+
import { toDate } from './toDate.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The {@link setDay} function options.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @name setDay
|
|
11
|
+
* @category Weekday Helpers
|
|
12
|
+
* @summary Set the day of the week to the given date.
|
|
13
|
+
*
|
|
14
|
+
* @description
|
|
15
|
+
* Set the day of the week to the given date.
|
|
16
|
+
*
|
|
17
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
18
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
19
|
+
*
|
|
20
|
+
* @param date - The date to be changed
|
|
21
|
+
* @param day - The day of the week of the new date
|
|
22
|
+
* @param options - An object with options.
|
|
23
|
+
*
|
|
24
|
+
* @returns The new date with the day of the week set
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Set week day to Sunday, with the default weekStartsOn of Sunday:
|
|
28
|
+
* const result = setDay(new Date(2014, 8, 1), 0)
|
|
29
|
+
* //=> Sun Aug 31 2014 00:00:00
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Set week day to Sunday, with a weekStartsOn of Monday:
|
|
33
|
+
* const result = setDay(new Date(2014, 8, 1), 0, { weekStartsOn: 1 })
|
|
34
|
+
* //=> Sun Sep 07 2014 00:00:00
|
|
35
|
+
*/
|
|
36
|
+
function setDay(date, day, options) {
|
|
37
|
+
const defaultOptions = getDefaultOptions();
|
|
38
|
+
const weekStartsOn =
|
|
39
|
+
options?.weekStartsOn ??
|
|
40
|
+
options?.locale?.options?.weekStartsOn ??
|
|
41
|
+
defaultOptions.weekStartsOn ??
|
|
42
|
+
defaultOptions.locale?.options?.weekStartsOn ??
|
|
43
|
+
0;
|
|
44
|
+
|
|
45
|
+
const date_ = toDate(date, options?.in);
|
|
46
|
+
const currentDay = date_.getDay();
|
|
47
|
+
|
|
48
|
+
const remainder = day % 7;
|
|
49
|
+
const dayIndex = (remainder + 7) % 7;
|
|
50
|
+
|
|
51
|
+
const delta = 7 - weekStartsOn;
|
|
52
|
+
const diff =
|
|
53
|
+
day < 0 || day > 6
|
|
54
|
+
? day - ((currentDay + delta) % 7)
|
|
55
|
+
: ((dayIndex + delta) % 7) - ((currentDay + delta) % 7);
|
|
56
|
+
return addDays(date_, diff, options);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { setDay as default, setDay };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { addDays } from './addDays.js';
|
|
2
|
+
import { getISODay } from './getISODay.js';
|
|
3
|
+
import { toDate } from './toDate.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The {@link setISODay} function options.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @name setISODay
|
|
11
|
+
* @category Weekday Helpers
|
|
12
|
+
* @summary Set the day of the ISO week to the given date.
|
|
13
|
+
*
|
|
14
|
+
* @description
|
|
15
|
+
* Set the day of the ISO week to the given date.
|
|
16
|
+
* ISO week starts with Monday.
|
|
17
|
+
* 7 is the index of Sunday, 1 is the index of Monday, etc.
|
|
18
|
+
*
|
|
19
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
20
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
21
|
+
*
|
|
22
|
+
* @param date - The date to be changed
|
|
23
|
+
* @param day - The day of the ISO week of the new date
|
|
24
|
+
* @param options - An object with options
|
|
25
|
+
*
|
|
26
|
+
* @returns The new date with the day of the ISO week set
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Set Sunday to 1 September 2014:
|
|
30
|
+
* const result = setISODay(new Date(2014, 8, 1), 7)
|
|
31
|
+
* //=> Sun Sep 07 2014 00:00:00
|
|
32
|
+
*/
|
|
33
|
+
function setISODay(date, day, options) {
|
|
34
|
+
const date_ = toDate(date, options?.in);
|
|
35
|
+
const currentDay = getISODay(date_, options);
|
|
36
|
+
const diff = day - currentDay;
|
|
37
|
+
return addDays(date_, diff, options);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { setISODay as default, setISODay };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { getISOWeek } from './getISOWeek.js';
|
|
2
|
+
import { toDate } from './toDate.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The {@link setISOWeek} function options.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @name setISOWeek
|
|
10
|
+
* @category ISO Week Helpers
|
|
11
|
+
* @summary Set the ISO week to the given date.
|
|
12
|
+
*
|
|
13
|
+
* @description
|
|
14
|
+
* Set the ISO week to the given date, saving the weekday number.
|
|
15
|
+
*
|
|
16
|
+
* ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
|
|
17
|
+
*
|
|
18
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
19
|
+
* @typeParam ResultDate - The `Date` type of the context function.
|
|
20
|
+
*
|
|
21
|
+
* @param date - The date to be changed
|
|
22
|
+
* @param week - The ISO week of the new date
|
|
23
|
+
* @param options - An object with options
|
|
24
|
+
*
|
|
25
|
+
* @returns The new date with the ISO week set
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Set the 53rd ISO week to 7 August 2004:
|
|
29
|
+
* const result = setISOWeek(new Date(2004, 7, 7), 53)
|
|
30
|
+
* //=> Sat Jan 01 2005 00:00:00
|
|
31
|
+
*/
|
|
32
|
+
function setISOWeek(date, week, options) {
|
|
33
|
+
const _date = toDate(date, options?.in);
|
|
34
|
+
const diff = getISOWeek(_date, options) - week;
|
|
35
|
+
_date.setDate(_date.getDate() - diff * 7);
|
|
36
|
+
return _date;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { setISOWeek as default, setISOWeek };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { constructFrom } from './constructFrom.js';
|
|
2
|
+
import { getDaysInMonth } from './getDaysInMonth.js';
|
|
3
|
+
import { toDate } from './toDate.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The {@link setMonth} function options.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @name setMonth
|
|
11
|
+
* @category Month Helpers
|
|
12
|
+
* @summary Set the month to the given date.
|
|
13
|
+
*
|
|
14
|
+
* @description
|
|
15
|
+
* Set the month to the given date.
|
|
16
|
+
*
|
|
17
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
18
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
19
|
+
*
|
|
20
|
+
* @param date - The date to be changed
|
|
21
|
+
* @param month - The month index to set (0-11)
|
|
22
|
+
* @param options - The options
|
|
23
|
+
*
|
|
24
|
+
* @returns The new date with the month set
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Set February to 1 September 2014:
|
|
28
|
+
* const result = setMonth(new Date(2014, 8, 1), 1)
|
|
29
|
+
* //=> Sat Feb 01 2014 00:00:00
|
|
30
|
+
*/
|
|
31
|
+
function setMonth(date, month, options) {
|
|
32
|
+
const _date = toDate(date, options?.in);
|
|
33
|
+
const year = _date.getFullYear();
|
|
34
|
+
const day = _date.getDate();
|
|
35
|
+
|
|
36
|
+
const midMonth = constructFrom(date, 0);
|
|
37
|
+
midMonth.setFullYear(year, month, 15);
|
|
38
|
+
midMonth.setHours(0, 0, 0, 0);
|
|
39
|
+
const daysInMonth = getDaysInMonth(midMonth);
|
|
40
|
+
|
|
41
|
+
// Set the earlier date, allows to wrap Jan 31 to Feb 28
|
|
42
|
+
_date.setMonth(month, Math.min(day, daysInMonth));
|
|
43
|
+
return _date;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { setMonth as default, setMonth };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { getWeek } from './getWeek.js';
|
|
2
|
+
import { toDate } from './toDate.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The {@link setWeek} function options.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @name setWeek
|
|
10
|
+
* @category Week Helpers
|
|
11
|
+
* @summary Set the local week to the given date.
|
|
12
|
+
*
|
|
13
|
+
* @description
|
|
14
|
+
* Set the local week to the given date, saving the weekday number.
|
|
15
|
+
* The exact calculation depends on the values of
|
|
16
|
+
* `options.weekStartsOn` (which is the index of the first day of the week)
|
|
17
|
+
* and `options.firstWeekContainsDate` (which is the day of January, which is always in
|
|
18
|
+
* the first week of the week-numbering year)
|
|
19
|
+
*
|
|
20
|
+
* Week numbering: https://en.wikipedia.org/wiki/Week#The_ISO_week_date_system
|
|
21
|
+
*
|
|
22
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
23
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
24
|
+
*
|
|
25
|
+
* @param date - The date to be changed
|
|
26
|
+
* @param week - The week of the new date
|
|
27
|
+
* @param options - An object with options
|
|
28
|
+
*
|
|
29
|
+
* @returns The new date with the local week set
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Set the 1st week to 2 January 2005 with default options:
|
|
33
|
+
* const result = setWeek(new Date(2005, 0, 2), 1)
|
|
34
|
+
* //=> Sun Dec 26 2004 00:00:00
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Set the 1st week to 2 January 2005,
|
|
38
|
+
* // if Monday is the first day of the week,
|
|
39
|
+
* // and the first week of the year always contains 4 January:
|
|
40
|
+
* const result = setWeek(new Date(2005, 0, 2), 1, {
|
|
41
|
+
* weekStartsOn: 1,
|
|
42
|
+
* firstWeekContainsDate: 4
|
|
43
|
+
* })
|
|
44
|
+
* //=> Sun Jan 4 2004 00:00:00
|
|
45
|
+
*/
|
|
46
|
+
function setWeek(date, week, options) {
|
|
47
|
+
const date_ = toDate(date, options?.in);
|
|
48
|
+
const diff = getWeek(date_, options) - week;
|
|
49
|
+
date_.setDate(date_.getDate() - diff * 7);
|
|
50
|
+
return toDate(date_, options?.in);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { setWeek as default, setWeek };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { constructFrom } from './constructFrom.js';
|
|
2
|
+
import { toDate } from './toDate.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The {@link setYear} function options.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @name setYear
|
|
10
|
+
* @category Year Helpers
|
|
11
|
+
* @summary Set the year to the given date.
|
|
12
|
+
*
|
|
13
|
+
* @description
|
|
14
|
+
* Set the year to the given date.
|
|
15
|
+
*
|
|
16
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
17
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
18
|
+
*
|
|
19
|
+
* @param date - The date to be changed
|
|
20
|
+
* @param year - The year of the new date
|
|
21
|
+
* @param options - An object with options.
|
|
22
|
+
*
|
|
23
|
+
* @returns The new date with the year set
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Set year 2013 to 1 September 2014:
|
|
27
|
+
* const result = setYear(new Date(2014, 8, 1), 2013)
|
|
28
|
+
* //=> Sun Sep 01 2013 00:00:00
|
|
29
|
+
*/
|
|
30
|
+
function setYear(date, year, options) {
|
|
31
|
+
const date_ = toDate(date, options?.in);
|
|
32
|
+
|
|
33
|
+
// Check if date is Invalid Date because Date.prototype.setFullYear ignores the value of Invalid Date
|
|
34
|
+
if (isNaN(+date_)) return constructFrom(date, NaN);
|
|
35
|
+
|
|
36
|
+
date_.setFullYear(year);
|
|
37
|
+
return date_;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { setYear as default, setYear };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { toDate } from './toDate.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The {@link startOfDay} function options.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @name startOfDay
|
|
9
|
+
* @category Day Helpers
|
|
10
|
+
* @summary Return the start of a day for the given date.
|
|
11
|
+
*
|
|
12
|
+
* @description
|
|
13
|
+
* Return the start of a day for the given date.
|
|
14
|
+
* The result will be in the local timezone.
|
|
15
|
+
*
|
|
16
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
17
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
18
|
+
*
|
|
19
|
+
* @param date - The original date
|
|
20
|
+
* @param options - The options
|
|
21
|
+
*
|
|
22
|
+
* @returns The start of a day
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // The start of a day for 2 September 2014 11:55:00:
|
|
26
|
+
* const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
|
|
27
|
+
* //=> Tue Sep 02 2014 00:00:00
|
|
28
|
+
*/
|
|
29
|
+
function startOfDay(date, options) {
|
|
30
|
+
const _date = toDate(date, options?.in);
|
|
31
|
+
_date.setHours(0, 0, 0, 0);
|
|
32
|
+
return _date;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { startOfDay as default, startOfDay };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { startOfWeek } from './startOfWeek.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The {@link startOfISOWeek} function options.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @name startOfISOWeek
|
|
9
|
+
* @category ISO Week Helpers
|
|
10
|
+
* @summary Return the start of an ISO week for the given date.
|
|
11
|
+
*
|
|
12
|
+
* @description
|
|
13
|
+
* Return the start of an ISO week for the given date.
|
|
14
|
+
* The result will be in the local timezone.
|
|
15
|
+
*
|
|
16
|
+
* ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
|
|
17
|
+
*
|
|
18
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
19
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
20
|
+
*
|
|
21
|
+
* @param date - The original date
|
|
22
|
+
* @param options - An object with options
|
|
23
|
+
*
|
|
24
|
+
* @returns The start of an ISO week
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // The start of an ISO week for 2 September 2014 11:55:00:
|
|
28
|
+
* const result = startOfISOWeek(new Date(2014, 8, 2, 11, 55, 0))
|
|
29
|
+
* //=> Mon Sep 01 2014 00:00:00
|
|
30
|
+
*/
|
|
31
|
+
function startOfISOWeek(date, options) {
|
|
32
|
+
return startOfWeek(date, { ...options, weekStartsOn: 1 });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { startOfISOWeek as default, startOfISOWeek };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { constructFrom } from './constructFrom.js';
|
|
2
|
+
import { getISOWeekYear } from './getISOWeekYear.js';
|
|
3
|
+
import { startOfISOWeek } from './startOfISOWeek.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The {@link startOfISOWeekYear} function options.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @name startOfISOWeekYear
|
|
11
|
+
* @category ISO Week-Numbering Year Helpers
|
|
12
|
+
* @summary Return the start of an ISO week-numbering year for the given date.
|
|
13
|
+
*
|
|
14
|
+
* @description
|
|
15
|
+
* Return the start of an ISO week-numbering year,
|
|
16
|
+
* which always starts 3 days before the year's first Thursday.
|
|
17
|
+
* The result will be in the local timezone.
|
|
18
|
+
*
|
|
19
|
+
* ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
|
|
20
|
+
*
|
|
21
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
22
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
23
|
+
*
|
|
24
|
+
* @param date - The original date
|
|
25
|
+
* @param options - An object with options
|
|
26
|
+
*
|
|
27
|
+
* @returns The start of an ISO week-numbering year
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // The start of an ISO week-numbering year for 2 July 2005:
|
|
31
|
+
* const result = startOfISOWeekYear(new Date(2005, 6, 2))
|
|
32
|
+
* //=> Mon Jan 03 2005 00:00:00
|
|
33
|
+
*/
|
|
34
|
+
function startOfISOWeekYear(date, options) {
|
|
35
|
+
const year = getISOWeekYear(date, options);
|
|
36
|
+
const fourthOfJanuary = constructFrom(date, 0);
|
|
37
|
+
fourthOfJanuary.setFullYear(year, 0, 4);
|
|
38
|
+
fourthOfJanuary.setHours(0, 0, 0, 0);
|
|
39
|
+
return startOfISOWeek(fourthOfJanuary);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { startOfISOWeekYear as default, startOfISOWeekYear };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { toDate } from './toDate.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The {@link startOfMonth} function options.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @name startOfMonth
|
|
9
|
+
* @category Month Helpers
|
|
10
|
+
* @summary Return the start of a month for the given date.
|
|
11
|
+
*
|
|
12
|
+
* @description
|
|
13
|
+
* Return the start of a month for the given date. The result will be in the local timezone.
|
|
14
|
+
*
|
|
15
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments.
|
|
16
|
+
* Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
17
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed,
|
|
18
|
+
* or inferred from the arguments.
|
|
19
|
+
*
|
|
20
|
+
* @param date - The original date
|
|
21
|
+
* @param options - An object with options
|
|
22
|
+
*
|
|
23
|
+
* @returns The start of a month
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // The start of a month for 2 September 2014 11:55:00:
|
|
27
|
+
* const result = startOfMonth(new Date(2014, 8, 2, 11, 55, 0))
|
|
28
|
+
* //=> Mon Sep 01 2014 00:00:00
|
|
29
|
+
*/
|
|
30
|
+
function startOfMonth(date, options) {
|
|
31
|
+
const _date = toDate(date, options?.in);
|
|
32
|
+
_date.setDate(1);
|
|
33
|
+
_date.setHours(0, 0, 0, 0);
|
|
34
|
+
return _date;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { startOfMonth as default, startOfMonth };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { getDefaultOptions } from './_lib/defaultOptions.js';
|
|
2
|
+
import { toDate } from './toDate.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The {@link startOfWeek} function options.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @name startOfWeek
|
|
10
|
+
* @category Week Helpers
|
|
11
|
+
* @summary Return the start of a week for the given date.
|
|
12
|
+
*
|
|
13
|
+
* @description
|
|
14
|
+
* Return the start of a week for the given date.
|
|
15
|
+
* The result will be in the local timezone.
|
|
16
|
+
*
|
|
17
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
18
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
19
|
+
*
|
|
20
|
+
* @param date - The original date
|
|
21
|
+
* @param options - An object with options
|
|
22
|
+
*
|
|
23
|
+
* @returns The start of a week
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // The start of a week for 2 September 2014 11:55:00:
|
|
27
|
+
* const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0))
|
|
28
|
+
* //=> Sun Aug 31 2014 00:00:00
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // If the week starts on Monday, the start of the week for 2 September 2014 11:55:00:
|
|
32
|
+
* const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
|
|
33
|
+
* //=> Mon Sep 01 2014 00:00:00
|
|
34
|
+
*/
|
|
35
|
+
function startOfWeek(date, options) {
|
|
36
|
+
const defaultOptions = getDefaultOptions();
|
|
37
|
+
const weekStartsOn =
|
|
38
|
+
options?.weekStartsOn ??
|
|
39
|
+
options?.locale?.options?.weekStartsOn ??
|
|
40
|
+
defaultOptions.weekStartsOn ??
|
|
41
|
+
defaultOptions.locale?.options?.weekStartsOn ??
|
|
42
|
+
0;
|
|
43
|
+
|
|
44
|
+
const _date = toDate(date, options?.in);
|
|
45
|
+
const day = _date.getDay();
|
|
46
|
+
const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
|
|
47
|
+
|
|
48
|
+
_date.setDate(_date.getDate() - diff);
|
|
49
|
+
_date.setHours(0, 0, 0, 0);
|
|
50
|
+
return _date;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { startOfWeek as default, startOfWeek };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { getDefaultOptions } from './_lib/defaultOptions.js';
|
|
2
|
+
import { constructFrom } from './constructFrom.js';
|
|
3
|
+
import { getWeekYear } from './getWeekYear.js';
|
|
4
|
+
import { startOfWeek } from './startOfWeek.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The {@link startOfWeekYear} function options.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @name startOfWeekYear
|
|
12
|
+
* @category Week-Numbering Year Helpers
|
|
13
|
+
* @summary Return the start of a local week-numbering year for the given date.
|
|
14
|
+
*
|
|
15
|
+
* @description
|
|
16
|
+
* Return the start of a local week-numbering year.
|
|
17
|
+
* The exact calculation depends on the values of
|
|
18
|
+
* `options.weekStartsOn` (which is the index of the first day of the week)
|
|
19
|
+
* and `options.firstWeekContainsDate` (which is the day of January, which is always in
|
|
20
|
+
* the first week of the week-numbering year)
|
|
21
|
+
*
|
|
22
|
+
* Week numbering: https://en.wikipedia.org/wiki/Week#The_ISO_week_date_system
|
|
23
|
+
*
|
|
24
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
25
|
+
* @typeParam ResultDate - The result `Date` type.
|
|
26
|
+
*
|
|
27
|
+
* @param date - The original date
|
|
28
|
+
* @param options - An object with options
|
|
29
|
+
*
|
|
30
|
+
* @returns The start of a week-numbering year
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* // The start of an a week-numbering year for 2 July 2005 with default settings:
|
|
34
|
+
* const result = startOfWeekYear(new Date(2005, 6, 2))
|
|
35
|
+
* //=> Sun Dec 26 2004 00:00:00
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // The start of a week-numbering year for 2 July 2005
|
|
39
|
+
* // if Monday is the first day of week
|
|
40
|
+
* // and 4 January is always in the first week of the year:
|
|
41
|
+
* const result = startOfWeekYear(new Date(2005, 6, 2), {
|
|
42
|
+
* weekStartsOn: 1,
|
|
43
|
+
* firstWeekContainsDate: 4
|
|
44
|
+
* })
|
|
45
|
+
* //=> Mon Jan 03 2005 00:00:00
|
|
46
|
+
*/
|
|
47
|
+
function startOfWeekYear(date, options) {
|
|
48
|
+
const defaultOptions = getDefaultOptions();
|
|
49
|
+
const firstWeekContainsDate =
|
|
50
|
+
options?.firstWeekContainsDate ??
|
|
51
|
+
options?.locale?.options?.firstWeekContainsDate ??
|
|
52
|
+
defaultOptions.firstWeekContainsDate ??
|
|
53
|
+
defaultOptions.locale?.options?.firstWeekContainsDate ??
|
|
54
|
+
1;
|
|
55
|
+
|
|
56
|
+
const year = getWeekYear(date, options);
|
|
57
|
+
const firstWeek = constructFrom(options?.in || date, 0);
|
|
58
|
+
firstWeek.setFullYear(year, 0, firstWeekContainsDate);
|
|
59
|
+
firstWeek.setHours(0, 0, 0, 0);
|
|
60
|
+
const _date = startOfWeek(firstWeek, options);
|
|
61
|
+
return _date;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { startOfWeekYear as default, startOfWeekYear };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { toDate } from './toDate.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The {@link startOfYear} function options.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @name startOfYear
|
|
9
|
+
* @category Year Helpers
|
|
10
|
+
* @summary Return the start of a year for the given date.
|
|
11
|
+
*
|
|
12
|
+
* @description
|
|
13
|
+
* Return the start of a year for the given date.
|
|
14
|
+
* The result will be in the local timezone.
|
|
15
|
+
*
|
|
16
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
17
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
18
|
+
*
|
|
19
|
+
* @param date - The original date
|
|
20
|
+
* @param options - The options
|
|
21
|
+
*
|
|
22
|
+
* @returns The start of a year
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // The start of a year for 2 September 2014 11:55:00:
|
|
26
|
+
* const result = startOfYear(new Date(2014, 8, 2, 11, 55, 00))
|
|
27
|
+
* //=> Wed Jan 01 2014 00:00:00
|
|
28
|
+
*/
|
|
29
|
+
function startOfYear(date, options) {
|
|
30
|
+
const date_ = toDate(date, options?.in);
|
|
31
|
+
date_.setFullYear(date_.getFullYear(), 0, 1);
|
|
32
|
+
date_.setHours(0, 0, 0, 0);
|
|
33
|
+
return date_;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { startOfYear as default, startOfYear };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { constructFrom } from './constructFrom.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @name toDate
|
|
5
|
+
* @category Common Helpers
|
|
6
|
+
* @summary Convert the given argument to an instance of Date.
|
|
7
|
+
*
|
|
8
|
+
* @description
|
|
9
|
+
* Convert the given argument to an instance of Date.
|
|
10
|
+
*
|
|
11
|
+
* If the argument is an instance of Date, the function returns its clone.
|
|
12
|
+
*
|
|
13
|
+
* If the argument is a number, it is treated as a timestamp.
|
|
14
|
+
*
|
|
15
|
+
* If the argument is none of the above, the function returns Invalid Date.
|
|
16
|
+
*
|
|
17
|
+
* Starting from v3.7.0, it clones a date using `[Symbol.for("constructDateFrom")]`
|
|
18
|
+
* enabling to transfer extra properties from the reference date to the new date.
|
|
19
|
+
* It's useful for extensions like [`TZDate`](https://github.com/date-fns/tz)
|
|
20
|
+
* that accept a time zone as a constructor argument.
|
|
21
|
+
*
|
|
22
|
+
* **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
|
|
23
|
+
*
|
|
24
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
25
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
26
|
+
*
|
|
27
|
+
* @param argument - The value to convert
|
|
28
|
+
*
|
|
29
|
+
* @returns The parsed date in the local time zone
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Clone the date:
|
|
33
|
+
* const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
|
|
34
|
+
* //=> Tue Feb 11 2014 11:30:30
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Convert the timestamp to date:
|
|
38
|
+
* const result = toDate(1392098430000)
|
|
39
|
+
* //=> Tue Feb 11 2014 11:30:30
|
|
40
|
+
*/
|
|
41
|
+
function toDate(argument, context) {
|
|
42
|
+
// [TODO] Get rid of `toDate` or `constructFrom`?
|
|
43
|
+
return constructFrom(context || argument, argument);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { toDate as default, toDate };
|