@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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
-
import
|
|
5
|
+
import React__default, { useState, useCallback } from 'react';
|
|
6
6
|
import { LoadingIcon } from '../Icon/LoadingIcon.js';
|
|
7
7
|
|
|
8
8
|
const Button = ({ as, children, className, href, isDisabled = false, isFullWidth = false, isLoading = false, loadingText = "Loading", onClick, ref, size = "md", variant = "green", ...props }) => {
|
|
@@ -32,7 +32,7 @@ const Button = ({ as, children, className, href, isDisabled = false, isFullWidth
|
|
|
32
32
|
...props,
|
|
33
33
|
};
|
|
34
34
|
const finalChildren = isPending || isLoading ? (jsxs(Fragment, { children: [loadingText, jsx(LoadingIcon, {})] })) : (children);
|
|
35
|
-
return
|
|
35
|
+
return React__default.createElement(element, { ...componentProps, ref }, finalChildren);
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
export { Button, Button as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import
|
|
3
|
+
import React__default from 'react';
|
|
4
4
|
import { useSlots } from '../../hooks/useSlots.js';
|
|
5
5
|
import { ChevronRightIcon } from '../Icon/ChevronRightIcon.js';
|
|
6
6
|
import { Image } from '../Image/Image.js';
|
|
@@ -34,12 +34,12 @@ const Card = ({ chevron = false, children, className, href, hrefAs, imagePositio
|
|
|
34
34
|
...props,
|
|
35
35
|
};
|
|
36
36
|
if (href && slots.CardHeading) {
|
|
37
|
-
slots.CardHeading =
|
|
37
|
+
slots.CardHeading = React__default.createElement(linkElement, linkProps, slots.CardHeading);
|
|
38
38
|
}
|
|
39
|
-
return (jsxs("article", { ...componentProps, ref: ref, children: [slots.CardImage, slots.CardBadge,
|
|
39
|
+
return (jsxs("article", { ...componentProps, ref: ref, children: [slots.CardImage, slots.CardBadge, React__default.createElement(hasLinkWrapper ? linkElement : "div", hasLinkWrapper ? { href, ...innerProps } : innerProps, jsxs("div", { className: "coop-card--content", children: [slots.CardLabel, slots.CardHeading, slots.CardBody, slots.Children] }), chevron && (jsx("span", { "aria-hidden": "true", className: "coop-card--icon", role: "presentation", children: jsx(ChevronRightIcon, {}) })))] }));
|
|
40
40
|
};
|
|
41
41
|
const CardHeading = ({ as = "h3", children, className }) => {
|
|
42
|
-
return
|
|
42
|
+
return React__default.createElement(as, { className: clsx("coop-card--heading", className) }, children);
|
|
43
43
|
};
|
|
44
44
|
CardHeading.displayName = "Card.Heading";
|
|
45
45
|
const CardLabel = ({ children, className }) => {
|
|
@@ -16,5 +16,11 @@ export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement
|
|
|
16
16
|
/** **(Optional)** Specify the Checkbox size. */
|
|
17
17
|
size?: StandardSizes;
|
|
18
18
|
}
|
|
19
|
-
export declare const Checkbox:
|
|
19
|
+
export declare const Checkbox: {
|
|
20
|
+
({ className, disabled, error, id, name, ref, size, ...props }: CheckboxProps): JSX.Element;
|
|
21
|
+
config: {
|
|
22
|
+
isField: true;
|
|
23
|
+
isInline: true;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
20
26
|
export default Checkbox;
|
|
@@ -16,5 +16,9 @@ const Checkbox = ({ className, disabled, error = false, id, name, ref, size = "m
|
|
|
16
16
|
};
|
|
17
17
|
return jsx("input", { ...componentProps, ref: ref });
|
|
18
18
|
};
|
|
19
|
+
Checkbox.config = {
|
|
20
|
+
isField: true,
|
|
21
|
+
isInline: true,
|
|
22
|
+
};
|
|
19
23
|
|
|
20
24
|
export { Checkbox, Checkbox as default };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { InputHTMLAttributes, JSX, Ref } from "react";
|
|
2
|
+
import type { DayPickerProps, Mode } from "react-day-picker";
|
|
3
|
+
import type { ComponentConfig, StandardSizes } from "../../types";
|
|
4
|
+
import type { DateRange } from "./datepicker-utils";
|
|
5
|
+
type OnDateSelectHandler = (selected: string | string[] | {
|
|
6
|
+
from?: string;
|
|
7
|
+
to?: string;
|
|
8
|
+
} | undefined) => void;
|
|
9
|
+
export interface DatePickerProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "onSelect" | "onChange" | "onChangeCapture" | "size" | "type"> {
|
|
10
|
+
/** **(Optional)** Specify additional CSS classes to be applied to the wrapper. */
|
|
11
|
+
className?: string;
|
|
12
|
+
/** **(Optional)** Specify whether the picker should close when selecting a date. Has no effect in range mode. */
|
|
13
|
+
closeOnSelect?: boolean;
|
|
14
|
+
/** **(Optional)** Specify the date format. This affects the values displayed to users and the accepted format for manual inputs. */
|
|
15
|
+
dateFormat?: string;
|
|
16
|
+
/** **(Optional)** Specify whether the Date Picker should be disabled. Refer to Experience Library guidance on disabled form controls and accessibility. */
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/** **(Optional)** Specify dates to be disabled. Refer to react-daypicker docs for full configuration. */
|
|
19
|
+
disabledDates?: DayPickerProps["disabled"];
|
|
20
|
+
/** **(Optional)** Specify the upper bound for the picker.
|
|
21
|
+
*
|
|
22
|
+
* Default: today plus one year.
|
|
23
|
+
*/
|
|
24
|
+
endDate?: Date;
|
|
25
|
+
/** **(Optional)** Specify the Date Picker error state. */
|
|
26
|
+
error?: boolean;
|
|
27
|
+
/** **(Optional)** Specify the Date Picker id. Will be auto-generated if not set. */
|
|
28
|
+
id?: string;
|
|
29
|
+
/** **(Optional)** Specify the initial month view for the picker.
|
|
30
|
+
*
|
|
31
|
+
* Default: today.
|
|
32
|
+
*/
|
|
33
|
+
initialDate?: Date | DateRange;
|
|
34
|
+
initialSelected?: boolean;
|
|
35
|
+
/** **(Optional)** Specify the picker mode. */
|
|
36
|
+
mode?: Mode;
|
|
37
|
+
/** Specify the Datepicker name. */
|
|
38
|
+
name: string;
|
|
39
|
+
/** Provided only for compatibility with form libraries. Use `onSelect` instead. */
|
|
40
|
+
onChange?: OnDateSelectHandler;
|
|
41
|
+
/** **(Optional)** Callback to run when a date is selected and validated.
|
|
42
|
+
*
|
|
43
|
+
* Contains the selected value, which is either an ISO-8601 formatted date string, or an object with from and to values. */
|
|
44
|
+
onSelect?: OnDateSelectHandler;
|
|
45
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
46
|
+
ref?: Ref<HTMLInputElement>;
|
|
47
|
+
/** **(Optional)** Specify whether this is a required field. */
|
|
48
|
+
required?: boolean;
|
|
49
|
+
/** **(Optional)** Specify the DatePicker size. */
|
|
50
|
+
size?: StandardSizes;
|
|
51
|
+
/** **(Optional)** Specify the lower bound for the picker.
|
|
52
|
+
*
|
|
53
|
+
* Default: today minus one year.
|
|
54
|
+
*/
|
|
55
|
+
startDate?: Date;
|
|
56
|
+
}
|
|
57
|
+
export declare const DatePicker: {
|
|
58
|
+
({ className, closeOnSelect, dateFormat, disabled, disabledDates, endDate, error, id, initialDate, initialSelected, mode, name, onChange, onSelect, ref, required, size, startDate, ...props }: DatePickerProps): JSX.Element;
|
|
59
|
+
config: ComponentConfig;
|
|
60
|
+
};
|
|
61
|
+
export default DatePicker;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { useMemo, useReducer, useCallback } from 'react';
|
|
4
|
+
import { useId } from '../../hooks/useId.js';
|
|
5
|
+
import { Button } from '../Button/Button.js';
|
|
6
|
+
import { CloseIcon } from '../Icon/CloseIcon.js';
|
|
7
|
+
import { TickIcon } from '../Icon/TickIcon.js';
|
|
8
|
+
import { Popover } from '../Popover/Popover.js';
|
|
9
|
+
import { TextInput } from '../TextInput/TextInput.js';
|
|
10
|
+
import { getInitialDate, getStartDate, getEndDate, getDefaultMonth, getDateValues, shouldClose, shouldSkipParsing } from './datepicker-utils.js';
|
|
11
|
+
import { DayPicker } from '../../node_modules/react-day-picker/dist/esm/DayPicker.js';
|
|
12
|
+
|
|
13
|
+
const now = new Date();
|
|
14
|
+
const componentConfig = {
|
|
15
|
+
fieldSuffix: "_display",
|
|
16
|
+
isField: true,
|
|
17
|
+
};
|
|
18
|
+
const baseValueProps = {
|
|
19
|
+
readOnly: true,
|
|
20
|
+
type: "hidden",
|
|
21
|
+
};
|
|
22
|
+
const footerMessage = {
|
|
23
|
+
multiple: "Pick one or more dates.",
|
|
24
|
+
range: "Pick a date range.",
|
|
25
|
+
single: "Pick a date.",
|
|
26
|
+
};
|
|
27
|
+
const initialState = {
|
|
28
|
+
message: undefined,
|
|
29
|
+
validated: false,
|
|
30
|
+
};
|
|
31
|
+
const defaultFormatters = {
|
|
32
|
+
formatWeekdayName: (d) => d.toLocaleDateString("default", { weekday: "short" }).slice(0, 2),
|
|
33
|
+
};
|
|
34
|
+
const Calendar = ({ captionLayout = "label", className, disabled, endMonth, formatters, showOutsideDays = true, startMonth, ...props }) => {
|
|
35
|
+
return (jsx(DayPicker, { captionLayout: captionLayout, className: className, disabled: disabled, endMonth: endMonth, formatters: {
|
|
36
|
+
...defaultFormatters,
|
|
37
|
+
...formatters,
|
|
38
|
+
}, navLayout: "around", showOutsideDays: showOutsideDays, startMonth: startMonth, weekStartsOn: 1, ...props }));
|
|
39
|
+
};
|
|
40
|
+
const DatePicker = ({ className, closeOnSelect = true, dateFormat = "dd/MM/yyyy", disabled, disabledDates, endDate, error = false, id, initialDate = now, initialSelected = false, mode = "single", name, onChange, onSelect, ref, required = false, size = "md", startDate, ...props }) => {
|
|
41
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
42
|
+
const uid = useId(id);
|
|
43
|
+
initialDate = getInitialDate(mode, initialDate);
|
|
44
|
+
startDate = useMemo(() => startDate !== null && startDate !== void 0 ? startDate : getStartDate(initialDate), [initialDate, startDate]);
|
|
45
|
+
endDate = useMemo(() => endDate !== null && endDate !== void 0 ? endDate : getEndDate(initialDate), [initialDate, endDate]);
|
|
46
|
+
const defaultMonth = useMemo(() => getDefaultMonth(initialDate), [initialDate]);
|
|
47
|
+
let initialValues = {
|
|
48
|
+
state: undefined,
|
|
49
|
+
view: defaultMonth,
|
|
50
|
+
};
|
|
51
|
+
if (initialSelected) {
|
|
52
|
+
initialValues = (_a = getDateValues(mode, initialDate, dateFormat, now)) !== null && _a !== void 0 ? _a : {};
|
|
53
|
+
}
|
|
54
|
+
const [state, setState] = useReducer((stale, fresh) => ({ ...stale, ...fresh }), { ...initialState, [mode]: initialValues.state, open: false, view: initialValues.view });
|
|
55
|
+
const updateValues = useCallback((selected) => {
|
|
56
|
+
var _a;
|
|
57
|
+
const values = getDateValues(mode, selected, dateFormat, now);
|
|
58
|
+
if (values) {
|
|
59
|
+
setState({
|
|
60
|
+
message: values.message,
|
|
61
|
+
[mode]: values.state,
|
|
62
|
+
validated: values.validated,
|
|
63
|
+
view: values.view,
|
|
64
|
+
...(shouldClose(mode, (_a = values.state) === null || _a === void 0 ? void 0 : _a.value, closeOnSelect) && {
|
|
65
|
+
open: false,
|
|
66
|
+
}),
|
|
67
|
+
});
|
|
68
|
+
if (values.validated && values.state) {
|
|
69
|
+
typeof onChange === "function" && onChange(values.state.field);
|
|
70
|
+
typeof onSelect === "function" && onSelect(values.state.field);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}, [dateFormat, mode, onChange, onSelect, closeOnSelect]);
|
|
74
|
+
const updateFromInput = useCallback((e) => {
|
|
75
|
+
var _a;
|
|
76
|
+
if (shouldSkipParsing(e.currentTarget.value)) {
|
|
77
|
+
setState({
|
|
78
|
+
message: undefined,
|
|
79
|
+
[mode]: { input: e.currentTarget.value },
|
|
80
|
+
validated: false,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
updateValues((_a = e.currentTarget) === null || _a === void 0 ? void 0 : _a.value);
|
|
85
|
+
}
|
|
86
|
+
}, [updateValues, mode]);
|
|
87
|
+
const setOpen = useCallback((open) => setState({ open }), []);
|
|
88
|
+
const setView = useCallback((view) => setState({ view }), []);
|
|
89
|
+
const resetState = useCallback(() => setState({ ...initialState, [mode]: undefined }), [mode]);
|
|
90
|
+
const componentProps = {
|
|
91
|
+
className: clsx("coop-datepicker", className),
|
|
92
|
+
"data-error": error || undefined,
|
|
93
|
+
"data-mode": mode,
|
|
94
|
+
...props,
|
|
95
|
+
};
|
|
96
|
+
const calendarProps = {
|
|
97
|
+
multiple: { mode: "multiple", selected: (_b = state.multiple) === null || _b === void 0 ? void 0 : _b.value },
|
|
98
|
+
range: { mode: "range", selected: (_c = state.range) === null || _c === void 0 ? void 0 : _c.value },
|
|
99
|
+
single: { mode: "single", selected: (_d = state.single) === null || _d === void 0 ? void 0 : _d.value },
|
|
100
|
+
};
|
|
101
|
+
const valueProps = {
|
|
102
|
+
...baseValueProps,
|
|
103
|
+
id: uid,
|
|
104
|
+
name: name,
|
|
105
|
+
};
|
|
106
|
+
const getPlaceholder = () => {
|
|
107
|
+
const lowerCaseDateFormat = dateFormat.toLowerCase();
|
|
108
|
+
switch (mode) {
|
|
109
|
+
case "range":
|
|
110
|
+
return lowerCaseDateFormat + " - " + lowerCaseDateFormat;
|
|
111
|
+
case "multiple":
|
|
112
|
+
return lowerCaseDateFormat + ", " + lowerCaseDateFormat;
|
|
113
|
+
default:
|
|
114
|
+
return lowerCaseDateFormat;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
return (jsxs("div", { ...componentProps, children: [jsxs(Popover, { onOpenChange: setOpen, open: state.open, children: [jsxs(Popover.Anchor, { className: "coop-datepicker-inner", children: [jsx(TextInput, { autoComplete: "off", className: "coop-datepicker-input", disabled: disabled, id: uid + componentConfig.fieldSuffix,
|
|
118
|
+
//maxLength={dateFormat.length}
|
|
119
|
+
name: name + componentConfig.fieldSuffix, onChange: updateFromInput, placeholder: getPlaceholder(), ref: ref, required: required, size: size, value: (_f = (_e = state === null || state === void 0 ? void 0 : state[mode]) === null || _e === void 0 ? void 0 : _e.input) !== null && _f !== void 0 ? _f : "" }), jsx(Popover.Trigger, { asChild: true, children: jsx(Button, { className: "coop-datepicker-button", disabled: disabled, size: size, children: "Select" }) })] }), jsxs(Popover.Content, { "aria-label": "Date picker", className: "coop-datepicker-calendar", collisionPadding: 16, sideOffset: 4, children: [jsx(Calendar
|
|
120
|
+
// jsx-ally throws here because we set autoFocus, but this
|
|
121
|
+
// is not a standard element. Daypicker uses this value to
|
|
122
|
+
// focus the day rather than the nav when it renders.
|
|
123
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
124
|
+
, {
|
|
125
|
+
// jsx-ally throws here because we set autoFocus, but this
|
|
126
|
+
// is not a standard element. Daypicker uses this value to
|
|
127
|
+
// focus the day rather than the nav when it renders.
|
|
128
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
129
|
+
autoFocus: true, captionLayout: "dropdown",
|
|
130
|
+
//defaultMonth={defaultMonth}
|
|
131
|
+
disabled: disabledDates, endMonth: endDate, month: state.view, onMonthChange: setView, onSelect: updateValues, startMonth: startDate, ...calendarProps[mode] }), jsxs("div", { className: "coop-datepicker-actions", children: [jsxs(Button, { "aria-label": "Cancel", onClick: resetState, size: "sm", variant: "grey", children: ["Clear ", jsx(CloseIcon, { stroke: "black", strokeWidth: 1 })] }), jsx(Popover.Close, { asChild: true, children: jsxs(Button, { "aria-label": "Accept", size: "sm", children: ["OK ", jsx(TickIcon, { stroke: "white", strokeWidth: 1 })] }) })] })] })] }), jsx("div", { "aria-live": "assertive", className: "sr-only coop-datepicker-status", role: "status", children: (_g = state.message) !== null && _g !== void 0 ? _g : footerMessage[mode] }), mode === "single" && jsx("input", { ...valueProps, value: (_j = (_h = state.single) === null || _h === void 0 ? void 0 : _h.field) !== null && _j !== void 0 ? _j : "" }), mode === "multiple" && jsx("input", { ...valueProps, value: (_l = (_k = state.multiple) === null || _k === void 0 ? void 0 : _k.field) !== null && _l !== void 0 ? _l : "" }), mode === "range" && (jsxs(Fragment, { children: [jsx("input", { ...baseValueProps, id: `${uid}_start`, name: `${name}_start`, value: (_p = (_o = (_m = state.range) === null || _m === void 0 ? void 0 : _m.field) === null || _o === void 0 ? void 0 : _o.from) !== null && _p !== void 0 ? _p : "" }), jsx("input", { ...baseValueProps, id: `${uid}_end`, name: `${name}_end`, value: (_s = (_r = (_q = state.range) === null || _q === void 0 ? void 0 : _q.field) === null || _r === void 0 ? void 0 : _r.to) !== null && _s !== void 0 ? _s : "" })] }))] }));
|
|
132
|
+
};
|
|
133
|
+
DatePicker.config = componentConfig;
|
|
134
|
+
|
|
135
|
+
export { DatePicker, DatePicker as default };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Mode } from "react-day-picker";
|
|
2
|
+
interface DateRangeStr {
|
|
3
|
+
from?: string;
|
|
4
|
+
to?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface DateRange {
|
|
7
|
+
from: Date | undefined;
|
|
8
|
+
to?: Date | undefined;
|
|
9
|
+
}
|
|
10
|
+
interface DateReturn {
|
|
11
|
+
message?: string;
|
|
12
|
+
validated?: boolean;
|
|
13
|
+
view?: Date;
|
|
14
|
+
}
|
|
15
|
+
export type DateBase = string | undefined;
|
|
16
|
+
export type DateType = Date | Date[] | DateRange | string | undefined;
|
|
17
|
+
export interface TDateSingle {
|
|
18
|
+
event?: string;
|
|
19
|
+
field?: string;
|
|
20
|
+
input: string;
|
|
21
|
+
value?: Date;
|
|
22
|
+
}
|
|
23
|
+
export interface TDateMultiple {
|
|
24
|
+
event?: string[];
|
|
25
|
+
field?: string;
|
|
26
|
+
input: string;
|
|
27
|
+
value?: Date[];
|
|
28
|
+
}
|
|
29
|
+
export interface TDateRange {
|
|
30
|
+
event?: DateRangeStr;
|
|
31
|
+
field?: DateRangeStr;
|
|
32
|
+
input: string;
|
|
33
|
+
value?: DateRange;
|
|
34
|
+
}
|
|
35
|
+
type RDateSingle = DateReturn & {
|
|
36
|
+
state?: TDateSingle;
|
|
37
|
+
};
|
|
38
|
+
type RDateMultiple = DateReturn & {
|
|
39
|
+
state?: TDateMultiple;
|
|
40
|
+
};
|
|
41
|
+
type RDateRange = DateReturn & {
|
|
42
|
+
state?: TDateRange;
|
|
43
|
+
};
|
|
44
|
+
export declare function isValidDate(date: unknown): date is Date;
|
|
45
|
+
export declare function isValidRangeFrom(date: unknown): date is {
|
|
46
|
+
from: Date;
|
|
47
|
+
to?: Date;
|
|
48
|
+
};
|
|
49
|
+
export declare function isValidRangeTo(date: unknown): date is {
|
|
50
|
+
from?: Date;
|
|
51
|
+
to: Date;
|
|
52
|
+
};
|
|
53
|
+
export declare function getISODateString(date: Date): string;
|
|
54
|
+
export declare function getRangeFromString(input: string): DateRangeStr;
|
|
55
|
+
export declare const getStartDate: (date: Date | Partial<DateRange>) => Date | undefined;
|
|
56
|
+
export declare const getEndDate: (date: Date | Partial<DateRange>) => Date | undefined;
|
|
57
|
+
export declare const getDefaultMonth: (date: Date | DateRange) => Date | undefined;
|
|
58
|
+
export declare const getInitialDate: (mode: Mode, date: Date | DateRange) => Date | DateRange;
|
|
59
|
+
export declare function getSingleDate(date: Date | DateBase, df: string, now: Date): RDateSingle;
|
|
60
|
+
export declare function getMultipleDate(date: Date[] | DateBase, df: string, now: Date): RDateMultiple;
|
|
61
|
+
export declare function getRangeDate(date: DateRange | DateBase, df: string, now: Date): RDateRange;
|
|
62
|
+
export declare const getDateValues: (mode: Mode, selected: DateType, dateFormat: string, now: Date) => RDateSingle | RDateMultiple | RDateRange | undefined;
|
|
63
|
+
export declare const shouldSkipParsing: (value: string) => boolean;
|
|
64
|
+
export declare const shouldClose: (mode: Mode, value: DateType, closeOnSelect?: boolean) => boolean;
|
|
65
|
+
export declare const isSingle: (m: Mode, d: DateType) => d is Date & DateBase;
|
|
66
|
+
export declare const isMultiple: (m: Mode, d: DateType) => d is Date[] & DateBase;
|
|
67
|
+
export declare const isRange: (m: Mode, d: DateType) => d is DateRange & DateBase;
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { isValid } from '../../node_modules/date-fns/isValid.js';
|
|
2
|
+
import { parse } from '../../node_modules/date-fns/parse.js';
|
|
3
|
+
import { addYears } from '../../node_modules/date-fns/addYears.js';
|
|
4
|
+
import { formatDate as format } from '../../node_modules/date-fns/format.js';
|
|
5
|
+
import { isBefore } from '../../node_modules/date-fns/isBefore.js';
|
|
6
|
+
|
|
7
|
+
function isValidDate(date) {
|
|
8
|
+
return !!date && typeof date !== "string" && typeof date !== "number" && isValid(date);
|
|
9
|
+
}
|
|
10
|
+
function isValidRangeFrom(date) {
|
|
11
|
+
return !!date && typeof date === "object" && "from" in date && isValid(date.from);
|
|
12
|
+
}
|
|
13
|
+
function isValidRangeTo(date) {
|
|
14
|
+
return !!date && typeof date === "object" && "to" in date && isValid(date.to);
|
|
15
|
+
}
|
|
16
|
+
function getISODateString(date) {
|
|
17
|
+
return format(date, "yyyy-MM-dd");
|
|
18
|
+
}
|
|
19
|
+
function getRangeFromString(input) {
|
|
20
|
+
if (input.includes("-")) {
|
|
21
|
+
const [from, to] = input.split("-");
|
|
22
|
+
return { from: from.trim(), to: to.trim() };
|
|
23
|
+
}
|
|
24
|
+
return { from: undefined, to: undefined };
|
|
25
|
+
}
|
|
26
|
+
const getStartDate = (date) => {
|
|
27
|
+
if (isValidDate(date))
|
|
28
|
+
return addYears(date, -1);
|
|
29
|
+
else if (isValidRangeFrom(date))
|
|
30
|
+
return addYears(date.from, -1);
|
|
31
|
+
return undefined;
|
|
32
|
+
};
|
|
33
|
+
const getEndDate = (date) => {
|
|
34
|
+
if (isValidDate(date))
|
|
35
|
+
return addYears(date, 1);
|
|
36
|
+
else if (isValidRangeTo(date))
|
|
37
|
+
return addYears(date.to, 1);
|
|
38
|
+
return undefined;
|
|
39
|
+
};
|
|
40
|
+
const getDefaultMonth = (date) => {
|
|
41
|
+
if (isValid(date))
|
|
42
|
+
return date;
|
|
43
|
+
else if (isValidRangeFrom(date))
|
|
44
|
+
return date.from;
|
|
45
|
+
return undefined;
|
|
46
|
+
};
|
|
47
|
+
const getInitialDate = (mode, date) => {
|
|
48
|
+
var _a;
|
|
49
|
+
let initialDate = date;
|
|
50
|
+
if (mode === "range") {
|
|
51
|
+
let from, to;
|
|
52
|
+
if ("from" in date) {
|
|
53
|
+
from = date.from;
|
|
54
|
+
to = (_a = date.to) !== null && _a !== void 0 ? _a : date.from;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
from = to = date;
|
|
58
|
+
}
|
|
59
|
+
initialDate = { from, to };
|
|
60
|
+
}
|
|
61
|
+
return initialDate;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Each getter returns an object with the following shape:
|
|
65
|
+
*
|
|
66
|
+
* message ........... read out by screen readers in the picker live region
|
|
67
|
+
* state.event ....... attached to the onChange / onSelect event when it fires
|
|
68
|
+
* state.field ....... value(s) for the hidden input field(s)
|
|
69
|
+
* state.input ....... value for the visible input field
|
|
70
|
+
* state.value ....... parsed date object(s)
|
|
71
|
+
* validated ......... boolean indicating dates are valid
|
|
72
|
+
* view .............. date (month) to show in the picker window
|
|
73
|
+
*/
|
|
74
|
+
const initialState = {
|
|
75
|
+
state: { input: "" },
|
|
76
|
+
validated: false,
|
|
77
|
+
};
|
|
78
|
+
function getSingleDate(date, df, now) {
|
|
79
|
+
var _a;
|
|
80
|
+
if (!date)
|
|
81
|
+
return initialState;
|
|
82
|
+
let parsed;
|
|
83
|
+
let input = "";
|
|
84
|
+
if (typeof date === "string") {
|
|
85
|
+
input = (_a = date.toString()) !== null && _a !== void 0 ? _a : "";
|
|
86
|
+
parsed = parse(date, df, now);
|
|
87
|
+
}
|
|
88
|
+
else if (isValidDate(date)) {
|
|
89
|
+
input = format(date, df);
|
|
90
|
+
parsed = date;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
return initialState;
|
|
94
|
+
}
|
|
95
|
+
if (isValidDate(parsed)) {
|
|
96
|
+
const isoString = getISODateString(parsed);
|
|
97
|
+
return {
|
|
98
|
+
message: `Selected ${input}`,
|
|
99
|
+
state: { event: isoString, field: isoString, input, value: parsed },
|
|
100
|
+
validated: true,
|
|
101
|
+
view: parsed,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return { state: { input: date.toString() }, validated: false };
|
|
105
|
+
}
|
|
106
|
+
function getMultipleDate(date, df, now) {
|
|
107
|
+
if (!date)
|
|
108
|
+
return initialState;
|
|
109
|
+
let parsed = [];
|
|
110
|
+
let input = "";
|
|
111
|
+
if (typeof date === "string") {
|
|
112
|
+
parsed = date
|
|
113
|
+
.split(",")
|
|
114
|
+
.map((d) => parse(d.trim(), df, now))
|
|
115
|
+
.filter((d) => isValid(d));
|
|
116
|
+
input = date;
|
|
117
|
+
}
|
|
118
|
+
else if (Array.isArray(date)) {
|
|
119
|
+
parsed = date.filter((d) => isValid(d));
|
|
120
|
+
input = parsed.map((d) => format(d, df)).join(", ");
|
|
121
|
+
}
|
|
122
|
+
if (parsed.length > 0) {
|
|
123
|
+
const formattedArray = parsed.map((d) => format(d, df));
|
|
124
|
+
const isoString = parsed.map((d) => getISODateString(d));
|
|
125
|
+
return {
|
|
126
|
+
message: `Selected ${formattedArray.join(", ")}`,
|
|
127
|
+
state: {
|
|
128
|
+
event: isoString,
|
|
129
|
+
field: isoString.join(","),
|
|
130
|
+
input,
|
|
131
|
+
value: parsed,
|
|
132
|
+
},
|
|
133
|
+
validated: true,
|
|
134
|
+
view: parsed.at(-1),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return { state: { input }, validated: false };
|
|
138
|
+
}
|
|
139
|
+
function getRangeDate(date, df, now) {
|
|
140
|
+
if (!date)
|
|
141
|
+
return initialState;
|
|
142
|
+
const parsed = { from: undefined, to: undefined };
|
|
143
|
+
const formatted = {};
|
|
144
|
+
let input = "";
|
|
145
|
+
if (typeof date === "string") {
|
|
146
|
+
if (date.includes("-")) {
|
|
147
|
+
const { from, to } = getRangeFromString(date);
|
|
148
|
+
if (from && to) {
|
|
149
|
+
parsed.from = parse(from, df, now);
|
|
150
|
+
parsed.to = parse(to, df, now);
|
|
151
|
+
formatted.from = from;
|
|
152
|
+
formatted.to = to;
|
|
153
|
+
}
|
|
154
|
+
input = `${from} - ${to}`;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
input = date;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else if ((date === null || date === void 0 ? void 0 : date.from) && (date === null || date === void 0 ? void 0 : date.to) && isValid(date.from) && isValid(date.to)) {
|
|
161
|
+
parsed.from = date.from;
|
|
162
|
+
parsed.to = date.to;
|
|
163
|
+
formatted.from = format(parsed.from, df);
|
|
164
|
+
formatted.to = format(parsed.to, df);
|
|
165
|
+
input = `${formatted.from} - ${formatted.to}`;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
return initialState;
|
|
169
|
+
}
|
|
170
|
+
if (isValidDate(parsed.from) && isValidDate(parsed.to)) {
|
|
171
|
+
if (isBefore(parsed.to, parsed.from)) {
|
|
172
|
+
const { from: pf, to: pt } = parsed;
|
|
173
|
+
parsed.from = pt;
|
|
174
|
+
parsed.to = pf;
|
|
175
|
+
}
|
|
176
|
+
const isoString = {
|
|
177
|
+
from: getISODateString(parsed.from),
|
|
178
|
+
to: getISODateString(parsed.to),
|
|
179
|
+
};
|
|
180
|
+
return {
|
|
181
|
+
message: `Selected ${formatted.from} to ${formatted.to}`,
|
|
182
|
+
state: { event: isoString, field: isoString, input, value: parsed },
|
|
183
|
+
validated: true,
|
|
184
|
+
view: parsed.to,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
return { state: { input }, validated: false };
|
|
188
|
+
}
|
|
189
|
+
const getDateValues = (mode, selected, dateFormat, now) => {
|
|
190
|
+
if (isSingle(mode))
|
|
191
|
+
return getSingleDate(selected, dateFormat, now);
|
|
192
|
+
else if (isMultiple(mode))
|
|
193
|
+
return getMultipleDate(selected, dateFormat, now);
|
|
194
|
+
else if (isRange(mode))
|
|
195
|
+
return getRangeDate(selected, dateFormat, now);
|
|
196
|
+
};
|
|
197
|
+
const shouldSkipParsing = (value) => {
|
|
198
|
+
return typeof value !== "string" ? true : !!(value.length < 8 || value.split("/").length < 3);
|
|
199
|
+
};
|
|
200
|
+
const shouldClose = (mode, value, closeOnSelect) => {
|
|
201
|
+
var _a, _b;
|
|
202
|
+
if (!closeOnSelect || !value)
|
|
203
|
+
return false;
|
|
204
|
+
else if (isSingle(mode))
|
|
205
|
+
return true;
|
|
206
|
+
else if (isRange(mode) && ((_a = value === null || value === void 0 ? void 0 : value.to) === null || _a === void 0 ? void 0 : _a.getTime()) !== ((_b = value === null || value === void 0 ? void 0 : value.from) === null || _b === void 0 ? void 0 : _b.getTime()))
|
|
207
|
+
return true;
|
|
208
|
+
else
|
|
209
|
+
return false;
|
|
210
|
+
};
|
|
211
|
+
const isSingle = (m, d) => m === "single";
|
|
212
|
+
const isMultiple = (m, d) => m === "multiple";
|
|
213
|
+
const isRange = (m, d) => m === "range";
|
|
214
|
+
|
|
215
|
+
export { getDateValues, getDefaultMonth, getEndDate, getISODateString, getInitialDate, getMultipleDate, getRangeDate, getRangeFromString, getSingleDate, getStartDate, isMultiple, isRange, isSingle, isValidDate, isValidRangeFrom, isValidRangeTo, shouldClose, shouldSkipParsing };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import
|
|
3
|
+
import React__default from 'react';
|
|
4
4
|
import { useId } from '../../hooks/useId.js';
|
|
5
5
|
import { useSlots } from '../../hooks/useSlots.js';
|
|
6
6
|
import { Error } from '../FieldMarkers/Error.js';
|
|
@@ -8,52 +8,55 @@ import { Hint } from '../FieldMarkers/Hint.js';
|
|
|
8
8
|
import { Label } from '../FieldMarkers/Label.js';
|
|
9
9
|
|
|
10
10
|
const componentSlots = {
|
|
11
|
-
Checkbox: null,
|
|
12
11
|
Children: null,
|
|
13
12
|
Control: null,
|
|
14
13
|
FieldError: null,
|
|
15
14
|
FieldHint: null,
|
|
16
15
|
FieldLabel: null,
|
|
17
|
-
Radio: null,
|
|
18
|
-
Select: null,
|
|
19
|
-
Textarea: null,
|
|
20
|
-
TextInput: null,
|
|
21
16
|
};
|
|
22
|
-
const standardFields = ["Children", "FieldError", "FieldHint", "FieldLabel"];
|
|
23
|
-
const inlineFields = ["Checkbox", "Radio"];
|
|
24
17
|
const Root = ({ boxed = false, children, className, error = false, hideErrorBar = false, ref, ...props }) => {
|
|
25
|
-
var _a, _b, _c, _d, _e, _f;
|
|
18
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
26
19
|
const slots = { ...useSlots(componentSlots, children) };
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
const hasMarkers = !!((_b = (_a = slots.FieldLabel) !== null && _a !== void 0 ? _a : slots.FieldError) !== null && _b !== void 0 ? _b : slots.FieldHint);
|
|
21
|
+
let isInline = false;
|
|
22
|
+
let control;
|
|
23
|
+
let controlSuffix = "";
|
|
31
24
|
let controlId = useId();
|
|
32
25
|
let controlDisabled = false;
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
if (Array.isArray(slots.Children)) {
|
|
27
|
+
slots.Children = slots.Children.filter((child) => {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
if ((_b = (_a = child === null || child === void 0 ? void 0 : child.type) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.isField) {
|
|
30
|
+
control = child;
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
41
34
|
});
|
|
42
35
|
}
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
if (React__default.isValidElement(control)) {
|
|
37
|
+
const controlProps = control.props;
|
|
38
|
+
controlId = (_c = controlProps.id) !== null && _c !== void 0 ? _c : controlId;
|
|
39
|
+
controlDisabled = (_d = controlProps.disabled) !== null && _d !== void 0 ? _d : false;
|
|
40
|
+
controlSuffix = (_g = (_f = (_e = control === null || control === void 0 ? void 0 : control.type) === null || _e === void 0 ? void 0 : _e.config) === null || _f === void 0 ? void 0 : _f.fieldSuffix) !== null && _g !== void 0 ? _g : "";
|
|
41
|
+
isInline = (_k = (_j = (_h = control === null || control === void 0 ? void 0 : control.type) === null || _h === void 0 ? void 0 : _h.config) === null || _j === void 0 ? void 0 : _j.isInline) !== null && _k !== void 0 ? _k : false;
|
|
42
|
+
slots.Control = controlProps.id
|
|
43
|
+
? control
|
|
44
|
+
: React__default.cloneElement(control, { id: controlId });
|
|
45
|
+
}
|
|
46
|
+
if (React__default.isValidElement(slots.FieldLabel) && !slots.FieldLabel.props.htmlFor) {
|
|
47
|
+
slots.FieldLabel = React__default.cloneElement(slots.FieldLabel, {
|
|
48
|
+
htmlFor: controlId + controlSuffix,
|
|
46
49
|
});
|
|
47
50
|
}
|
|
48
51
|
const componentProps = {
|
|
49
52
|
...props,
|
|
50
53
|
"aria-disabled": controlDisabled || undefined,
|
|
51
|
-
className: clsx("coop-field",
|
|
54
|
+
className: clsx("coop-field", isInline && "coop-field-inline", className),
|
|
52
55
|
"data-boxed": boxed || undefined,
|
|
53
56
|
"data-error": error || undefined,
|
|
54
57
|
"data-hide-error": hideErrorBar || undefined,
|
|
55
58
|
};
|
|
56
|
-
return (jsxs("div", { ...componentProps, ref: ref, children: [!
|
|
59
|
+
return (jsxs("div", { ...componentProps, ref: ref, children: [!isInline && hasMarkers && (jsxs("div", { className: "coop-field-markers", children: [slots.FieldLabel, slots.FieldHint, slots.FieldError] })), slots.Control && (jsxs("div", { className: "coop-field-control", children: [slots.Control, isInline && hasMarkers && (jsxs("div", { className: "coop-field-markers", children: [slots.FieldLabel, slots.FieldHint, slots.FieldError] }))] })), slots.Children] }));
|
|
57
60
|
};
|
|
58
61
|
const FieldControl = ({ children, className, ...props }) => {
|
|
59
62
|
return (jsx("div", { className: clsx("coop-field-control ", className), ...props, children: children }));
|