@coopdigital/react 0.49.0 → 0.50.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 +17 -13
- 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,110 @@
|
|
|
1
|
+
var alwaysContainsScroll = function (node) {
|
|
2
|
+
// textarea will always _contain_ scroll inside self. It only can be hidden
|
|
3
|
+
return node.tagName === 'TEXTAREA';
|
|
4
|
+
};
|
|
5
|
+
var elementCanBeScrolled = function (node, overflow) {
|
|
6
|
+
if (!(node instanceof Element)) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
var styles = window.getComputedStyle(node);
|
|
10
|
+
return (
|
|
11
|
+
// not-not-scrollable
|
|
12
|
+
styles[overflow] !== 'hidden' &&
|
|
13
|
+
// contains scroll inside self
|
|
14
|
+
!(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === 'visible'));
|
|
15
|
+
};
|
|
16
|
+
var elementCouldBeVScrolled = function (node) { return elementCanBeScrolled(node, 'overflowY'); };
|
|
17
|
+
var elementCouldBeHScrolled = function (node) { return elementCanBeScrolled(node, 'overflowX'); };
|
|
18
|
+
var locationCouldBeScrolled = function (axis, node) {
|
|
19
|
+
var ownerDocument = node.ownerDocument;
|
|
20
|
+
var current = node;
|
|
21
|
+
do {
|
|
22
|
+
// Skip over shadow root
|
|
23
|
+
if (typeof ShadowRoot !== 'undefined' && current instanceof ShadowRoot) {
|
|
24
|
+
current = current.host;
|
|
25
|
+
}
|
|
26
|
+
var isScrollable = elementCouldBeScrolled(axis, current);
|
|
27
|
+
if (isScrollable) {
|
|
28
|
+
var _a = getScrollVariables(axis, current), scrollHeight = _a[1], clientHeight = _a[2];
|
|
29
|
+
if (scrollHeight > clientHeight) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
current = current.parentNode;
|
|
34
|
+
} while (current && current !== ownerDocument.body);
|
|
35
|
+
return false;
|
|
36
|
+
};
|
|
37
|
+
var getVScrollVariables = function (_a) {
|
|
38
|
+
var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
|
|
39
|
+
return [
|
|
40
|
+
scrollTop,
|
|
41
|
+
scrollHeight,
|
|
42
|
+
clientHeight,
|
|
43
|
+
];
|
|
44
|
+
};
|
|
45
|
+
var getHScrollVariables = function (_a) {
|
|
46
|
+
var scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
|
|
47
|
+
return [
|
|
48
|
+
scrollLeft,
|
|
49
|
+
scrollWidth,
|
|
50
|
+
clientWidth,
|
|
51
|
+
];
|
|
52
|
+
};
|
|
53
|
+
var elementCouldBeScrolled = function (axis, node) {
|
|
54
|
+
return axis === 'v' ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
|
|
55
|
+
};
|
|
56
|
+
var getScrollVariables = function (axis, node) {
|
|
57
|
+
return axis === 'v' ? getVScrollVariables(node) : getHScrollVariables(node);
|
|
58
|
+
};
|
|
59
|
+
var getDirectionFactor = function (axis, direction) {
|
|
60
|
+
/**
|
|
61
|
+
* If the element's direction is rtl (right-to-left), then scrollLeft is 0 when the scrollbar is at its rightmost position,
|
|
62
|
+
* and then increasingly negative as you scroll towards the end of the content.
|
|
63
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft
|
|
64
|
+
*/
|
|
65
|
+
return axis === 'h' && direction === 'rtl' ? -1 : 1;
|
|
66
|
+
};
|
|
67
|
+
var handleScroll = function (axis, endTarget, event, sourceDelta, noOverscroll) {
|
|
68
|
+
var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction);
|
|
69
|
+
var delta = directionFactor * sourceDelta;
|
|
70
|
+
// find scrollable target
|
|
71
|
+
var target = event.target;
|
|
72
|
+
var targetInLock = endTarget.contains(target);
|
|
73
|
+
var shouldCancelScroll = false;
|
|
74
|
+
var isDeltaPositive = delta > 0;
|
|
75
|
+
var availableScroll = 0;
|
|
76
|
+
var availableScrollTop = 0;
|
|
77
|
+
do {
|
|
78
|
+
if (!target) {
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2];
|
|
82
|
+
var elementScroll = scroll_1 - capacity - directionFactor * position;
|
|
83
|
+
if (position || elementScroll) {
|
|
84
|
+
if (elementCouldBeScrolled(axis, target)) {
|
|
85
|
+
availableScroll += elementScroll;
|
|
86
|
+
availableScrollTop += position;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
var parent_1 = target.parentNode;
|
|
90
|
+
// we will "bubble" from ShadowDom in case we are, or just to the parent in normal case
|
|
91
|
+
// this is the same logic used in focus-lock
|
|
92
|
+
target = (parent_1 && parent_1.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? parent_1.host : parent_1);
|
|
93
|
+
} while (
|
|
94
|
+
// portaled content
|
|
95
|
+
(!targetInLock && target !== document.body) ||
|
|
96
|
+
// self content
|
|
97
|
+
(targetInLock && (endTarget.contains(target) || endTarget === target)));
|
|
98
|
+
// handle epsilon around 0 (non standard zoom levels)
|
|
99
|
+
if (isDeltaPositive &&
|
|
100
|
+
((Math.abs(availableScroll) < 1) || (false))) {
|
|
101
|
+
shouldCancelScroll = true;
|
|
102
|
+
}
|
|
103
|
+
else if (!isDeltaPositive &&
|
|
104
|
+
((Math.abs(availableScrollTop) < 1) || (false))) {
|
|
105
|
+
shouldCancelScroll = true;
|
|
106
|
+
}
|
|
107
|
+
return shouldCancelScroll;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export { handleScroll, locationCouldBeScrolled };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RemoveScrollSideCar } from './SideEffect.js';
|
|
2
|
+
import { effectCar } from './medium.js';
|
|
3
|
+
import { exportSidecar } from '../../../use-sidecar/dist/es2015/exports.js';
|
|
4
|
+
|
|
5
|
+
var SideCar = exportSidecar(effectCar, RemoveScrollSideCar);
|
|
6
|
+
|
|
7
|
+
export { SideCar as default };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { styleSingleton } from '../../../react-style-singleton/dist/es2015/component.js';
|
|
3
|
+
import { noScrollbarsClassName, zeroRightClassName, fullWidthClassName, removedBarSizeVariable } from './constants.js';
|
|
4
|
+
import { getGapWidth } from './utils.js';
|
|
5
|
+
|
|
6
|
+
var Style = styleSingleton();
|
|
7
|
+
var lockAttribute = 'data-scroll-locked';
|
|
8
|
+
// important tip - once we measure scrollBar width and remove them
|
|
9
|
+
// we could not repeat this operation
|
|
10
|
+
// thus we are using style-singleton - only the first "yet correct" style will be applied.
|
|
11
|
+
var getStyles = function (_a, allowRelative, gapMode, important) {
|
|
12
|
+
var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap;
|
|
13
|
+
if (gapMode === void 0) { gapMode = 'margin'; }
|
|
14
|
+
return "\n .".concat(noScrollbarsClassName, " {\n overflow: hidden ").concat(important, ";\n padding-right: ").concat(gap, "px ").concat(important, ";\n }\n body[").concat(lockAttribute, "] {\n overflow: hidden ").concat(important, ";\n overscroll-behavior: contain;\n ").concat([
|
|
15
|
+
allowRelative && "position: relative ".concat(important, ";"),
|
|
16
|
+
gapMode === 'margin' &&
|
|
17
|
+
"\n padding-left: ".concat(left, "px;\n padding-top: ").concat(top, "px;\n padding-right: ").concat(right, "px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(gap, "px ").concat(important, ";\n "),
|
|
18
|
+
gapMode === 'padding' && "padding-right: ".concat(gap, "px ").concat(important, ";"),
|
|
19
|
+
]
|
|
20
|
+
.filter(Boolean)
|
|
21
|
+
.join(''), "\n }\n \n .").concat(zeroRightClassName, " {\n right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " {\n margin-right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(zeroRightClassName, " .").concat(zeroRightClassName, " {\n right: 0 ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " .").concat(fullWidthClassName, " {\n margin-right: 0 ").concat(important, ";\n }\n \n body[").concat(lockAttribute, "] {\n ").concat(removedBarSizeVariable, ": ").concat(gap, "px;\n }\n");
|
|
22
|
+
};
|
|
23
|
+
var getCurrentUseCounter = function () {
|
|
24
|
+
var counter = parseInt(document.body.getAttribute(lockAttribute) || '0', 10);
|
|
25
|
+
return isFinite(counter) ? counter : 0;
|
|
26
|
+
};
|
|
27
|
+
var useLockAttribute = function () {
|
|
28
|
+
React.useEffect(function () {
|
|
29
|
+
document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString());
|
|
30
|
+
return function () {
|
|
31
|
+
var newCounter = getCurrentUseCounter() - 1;
|
|
32
|
+
if (newCounter <= 0) {
|
|
33
|
+
document.body.removeAttribute(lockAttribute);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
document.body.setAttribute(lockAttribute, newCounter.toString());
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}, []);
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Removes page scrollbar and blocks page scroll when mounted
|
|
43
|
+
*/
|
|
44
|
+
var RemoveScrollBar = function (_a) {
|
|
45
|
+
var noRelative = _a.noRelative, noImportant = _a.noImportant, _b = _a.gapMode, gapMode = _b === void 0 ? 'margin' : _b;
|
|
46
|
+
useLockAttribute();
|
|
47
|
+
/*
|
|
48
|
+
gap will be measured on every component mount
|
|
49
|
+
however it will be used only by the "first" invocation
|
|
50
|
+
due to singleton nature of <Style
|
|
51
|
+
*/
|
|
52
|
+
var gap = React.useMemo(function () { return getGapWidth(gapMode); }, [gapMode]);
|
|
53
|
+
return React.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? '!important' : '') });
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export { RemoveScrollBar, lockAttribute, useLockAttribute };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var zeroRightClassName = 'right-scroll-bar-position';
|
|
2
|
+
var fullWidthClassName = 'width-before-scroll-bar';
|
|
3
|
+
var noScrollbarsClassName = 'with-scroll-bars-hidden';
|
|
4
|
+
/**
|
|
5
|
+
* Name of a CSS variable containing the amount of "hidden" scrollbar
|
|
6
|
+
* ! might be undefined ! use will fallback!
|
|
7
|
+
*/
|
|
8
|
+
var removedBarSizeVariable = '--removed-body-scroll-bar-size';
|
|
9
|
+
|
|
10
|
+
export { fullWidthClassName, noScrollbarsClassName, removedBarSizeVariable, zeroRightClassName };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var zeroGap = {
|
|
2
|
+
left: 0,
|
|
3
|
+
top: 0,
|
|
4
|
+
right: 0,
|
|
5
|
+
gap: 0,
|
|
6
|
+
};
|
|
7
|
+
var parse = function (x) { return parseInt(x || '', 10) || 0; };
|
|
8
|
+
var getOffset = function (gapMode) {
|
|
9
|
+
var cs = window.getComputedStyle(document.body);
|
|
10
|
+
var left = cs[gapMode === 'padding' ? 'paddingLeft' : 'marginLeft'];
|
|
11
|
+
var top = cs[gapMode === 'padding' ? 'paddingTop' : 'marginTop'];
|
|
12
|
+
var right = cs[gapMode === 'padding' ? 'paddingRight' : 'marginRight'];
|
|
13
|
+
return [parse(left), parse(top), parse(right)];
|
|
14
|
+
};
|
|
15
|
+
var getGapWidth = function (gapMode) {
|
|
16
|
+
if (gapMode === void 0) { gapMode = 'margin'; }
|
|
17
|
+
if (typeof window === 'undefined') {
|
|
18
|
+
return zeroGap;
|
|
19
|
+
}
|
|
20
|
+
var offsets = getOffset(gapMode);
|
|
21
|
+
var documentWidth = document.documentElement.clientWidth;
|
|
22
|
+
var windowWidth = window.innerWidth;
|
|
23
|
+
return {
|
|
24
|
+
left: offsets[0],
|
|
25
|
+
top: offsets[1],
|
|
26
|
+
right: offsets[2],
|
|
27
|
+
gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0]),
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { getGapWidth, zeroGap };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { styleHookSingleton } from './hook.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* create a Component to add styles on demand
|
|
5
|
+
* - styles are added when first instance is mounted
|
|
6
|
+
* - styles are removed when the last instance is unmounted
|
|
7
|
+
* - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
|
|
8
|
+
*/
|
|
9
|
+
var styleSingleton = function () {
|
|
10
|
+
var useStyle = styleHookSingleton();
|
|
11
|
+
var Sheet = function (_a) {
|
|
12
|
+
var styles = _a.styles, dynamic = _a.dynamic;
|
|
13
|
+
useStyle(styles, dynamic);
|
|
14
|
+
return null;
|
|
15
|
+
};
|
|
16
|
+
return Sheet;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { styleSingleton };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { stylesheetSingleton } from './singleton.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* creates a hook to control style singleton
|
|
6
|
+
* @see {@link styleSingleton} for a safer component version
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* const useStyle = styleHookSingleton();
|
|
10
|
+
* ///
|
|
11
|
+
* useStyle('body { overflow: hidden}');
|
|
12
|
+
*/
|
|
13
|
+
var styleHookSingleton = function () {
|
|
14
|
+
var sheet = stylesheetSingleton();
|
|
15
|
+
return function (styles, isDynamic) {
|
|
16
|
+
React.useEffect(function () {
|
|
17
|
+
sheet.add(styles);
|
|
18
|
+
return function () {
|
|
19
|
+
sheet.remove();
|
|
20
|
+
};
|
|
21
|
+
}, [styles && isDynamic]);
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { styleHookSingleton };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { getNonce } from '../../../get-nonce/dist/es2015/index.js';
|
|
2
|
+
|
|
3
|
+
function makeStyleTag() {
|
|
4
|
+
if (!document)
|
|
5
|
+
return null;
|
|
6
|
+
var tag = document.createElement('style');
|
|
7
|
+
tag.type = 'text/css';
|
|
8
|
+
var nonce = getNonce();
|
|
9
|
+
if (nonce) {
|
|
10
|
+
tag.setAttribute('nonce', nonce);
|
|
11
|
+
}
|
|
12
|
+
return tag;
|
|
13
|
+
}
|
|
14
|
+
function injectStyles(tag, css) {
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
if (tag.styleSheet) {
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
tag.styleSheet.cssText = css;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
tag.appendChild(document.createTextNode(css));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function insertStyleTag(tag) {
|
|
25
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
26
|
+
head.appendChild(tag);
|
|
27
|
+
}
|
|
28
|
+
var stylesheetSingleton = function () {
|
|
29
|
+
var counter = 0;
|
|
30
|
+
var stylesheet = null;
|
|
31
|
+
return {
|
|
32
|
+
add: function (style) {
|
|
33
|
+
if (counter == 0) {
|
|
34
|
+
if ((stylesheet = makeStyleTag())) {
|
|
35
|
+
injectStyles(stylesheet, style);
|
|
36
|
+
insertStyleTag(stylesheet);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
counter++;
|
|
40
|
+
},
|
|
41
|
+
remove: function () {
|
|
42
|
+
counter--;
|
|
43
|
+
if (!counter && stylesheet) {
|
|
44
|
+
stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
|
|
45
|
+
stylesheet = null;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { stylesheetSingleton };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */
|
|
15
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
var __assign = function() {
|
|
19
|
+
__assign = Object.assign || function __assign(t) {
|
|
20
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
21
|
+
s = arguments[i];
|
|
22
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function __rest(s, e) {
|
|
30
|
+
var t = {};
|
|
31
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
32
|
+
t[p] = s[p];
|
|
33
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
34
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
35
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
36
|
+
t[p[i]] = s[p[i]];
|
|
37
|
+
}
|
|
38
|
+
return t;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function __spreadArray(to, from, pack) {
|
|
42
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
43
|
+
if (ar || !(i in from)) {
|
|
44
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
45
|
+
ar[i] = from[i];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
52
|
+
var e = new Error(message);
|
|
53
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export { __assign, __rest, __spreadArray };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assigns a value for a given ref, no matter of the ref format
|
|
3
|
+
* @param {RefObject} ref - a callback function or ref object
|
|
4
|
+
* @param value - a new value
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/theKashey/use-callback-ref#assignref
|
|
7
|
+
* @example
|
|
8
|
+
* const refObject = useRef();
|
|
9
|
+
* const refFn = (ref) => {....}
|
|
10
|
+
*
|
|
11
|
+
* assignRef(refObject, "refValue");
|
|
12
|
+
* assignRef(refFn, "refValue");
|
|
13
|
+
*/
|
|
14
|
+
function assignRef(ref, value) {
|
|
15
|
+
if (typeof ref === 'function') {
|
|
16
|
+
ref(value);
|
|
17
|
+
}
|
|
18
|
+
else if (ref) {
|
|
19
|
+
ref.current = value;
|
|
20
|
+
}
|
|
21
|
+
return ref;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { assignRef };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { assignRef } from './assignRef.js';
|
|
3
|
+
import { useCallbackRef } from './useRef.js';
|
|
4
|
+
|
|
5
|
+
var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
6
|
+
var currentValues = new WeakMap();
|
|
7
|
+
/**
|
|
8
|
+
* Merges two or more refs together providing a single interface to set their value
|
|
9
|
+
* @param {RefObject|Ref} refs
|
|
10
|
+
* @returns {MutableRefObject} - a new ref, which translates all changes to {refs}
|
|
11
|
+
*
|
|
12
|
+
* @see {@link mergeRefs} a version without buit-in memoization
|
|
13
|
+
* @see https://github.com/theKashey/use-callback-ref#usemergerefs
|
|
14
|
+
* @example
|
|
15
|
+
* const Component = React.forwardRef((props, ref) => {
|
|
16
|
+
* const ownRef = useRef();
|
|
17
|
+
* const domRef = useMergeRefs([ref, ownRef]); // 👈 merge together
|
|
18
|
+
* return <div ref={domRef}>...</div>
|
|
19
|
+
* }
|
|
20
|
+
*/
|
|
21
|
+
function useMergeRefs(refs, defaultValue) {
|
|
22
|
+
var callbackRef = useCallbackRef(null, function (newValue) {
|
|
23
|
+
return refs.forEach(function (ref) { return assignRef(ref, newValue); });
|
|
24
|
+
});
|
|
25
|
+
// handle refs changes - added or removed
|
|
26
|
+
useIsomorphicLayoutEffect(function () {
|
|
27
|
+
var oldValue = currentValues.get(callbackRef);
|
|
28
|
+
if (oldValue) {
|
|
29
|
+
var prevRefs_1 = new Set(oldValue);
|
|
30
|
+
var nextRefs_1 = new Set(refs);
|
|
31
|
+
var current_1 = callbackRef.current;
|
|
32
|
+
prevRefs_1.forEach(function (ref) {
|
|
33
|
+
if (!nextRefs_1.has(ref)) {
|
|
34
|
+
assignRef(ref, null);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
nextRefs_1.forEach(function (ref) {
|
|
38
|
+
if (!prevRefs_1.has(ref)) {
|
|
39
|
+
assignRef(ref, current_1);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
currentValues.set(callbackRef, refs);
|
|
44
|
+
}, [refs]);
|
|
45
|
+
return callbackRef;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { useMergeRefs };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* creates a MutableRef with ref change callback
|
|
5
|
+
* @param initialValue - initial ref value
|
|
6
|
+
* @param {Function} callback - a callback to run when value changes
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);
|
|
10
|
+
* ref.current = 1;
|
|
11
|
+
* // prints 0 -> 1
|
|
12
|
+
*
|
|
13
|
+
* @see https://reactjs.org/docs/hooks-reference.html#useref
|
|
14
|
+
* @see https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref
|
|
15
|
+
* @returns {MutableRefObject}
|
|
16
|
+
*/
|
|
17
|
+
function useCallbackRef(initialValue, callback) {
|
|
18
|
+
var ref = useState(function () { return ({
|
|
19
|
+
// value
|
|
20
|
+
value: initialValue,
|
|
21
|
+
// last callback
|
|
22
|
+
callback: callback,
|
|
23
|
+
// "memoized" public interface
|
|
24
|
+
facade: {
|
|
25
|
+
get current() {
|
|
26
|
+
return ref.value;
|
|
27
|
+
},
|
|
28
|
+
set current(value) {
|
|
29
|
+
var last = ref.value;
|
|
30
|
+
if (last !== value) {
|
|
31
|
+
ref.value = value;
|
|
32
|
+
ref.callback(value, last);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
}); })[0];
|
|
37
|
+
// update callback
|
|
38
|
+
ref.callback = callback;
|
|
39
|
+
return ref.facade;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { useCallbackRef };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { __rest, __assign } from '../../../tslib/tslib.es6.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
var SideCar = function (_a) {
|
|
5
|
+
var sideCar = _a.sideCar, rest = __rest(_a, ["sideCar"]);
|
|
6
|
+
if (!sideCar) {
|
|
7
|
+
throw new Error('Sidecar: please provide `sideCar` property to import the right car');
|
|
8
|
+
}
|
|
9
|
+
var Target = sideCar.read();
|
|
10
|
+
if (!Target) {
|
|
11
|
+
throw new Error('Sidecar medium not found');
|
|
12
|
+
}
|
|
13
|
+
return React.createElement(Target, __assign({}, rest));
|
|
14
|
+
};
|
|
15
|
+
SideCar.isSideCarExport = true;
|
|
16
|
+
function exportSidecar(medium, exported) {
|
|
17
|
+
medium.useMedium(exported);
|
|
18
|
+
return SideCar;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { exportSidecar };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { __assign } from '../../../tslib/tslib.es6.js';
|
|
2
|
+
|
|
3
|
+
function ItoI(a) {
|
|
4
|
+
return a;
|
|
5
|
+
}
|
|
6
|
+
function innerCreateMedium(defaults, middleware) {
|
|
7
|
+
if (middleware === void 0) { middleware = ItoI; }
|
|
8
|
+
var buffer = [];
|
|
9
|
+
var assigned = false;
|
|
10
|
+
var medium = {
|
|
11
|
+
read: function () {
|
|
12
|
+
if (assigned) {
|
|
13
|
+
throw new Error('Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.');
|
|
14
|
+
}
|
|
15
|
+
if (buffer.length) {
|
|
16
|
+
return buffer[buffer.length - 1];
|
|
17
|
+
}
|
|
18
|
+
return defaults;
|
|
19
|
+
},
|
|
20
|
+
useMedium: function (data) {
|
|
21
|
+
var item = middleware(data, assigned);
|
|
22
|
+
buffer.push(item);
|
|
23
|
+
return function () {
|
|
24
|
+
buffer = buffer.filter(function (x) { return x !== item; });
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
assignSyncMedium: function (cb) {
|
|
28
|
+
assigned = true;
|
|
29
|
+
while (buffer.length) {
|
|
30
|
+
var cbs = buffer;
|
|
31
|
+
buffer = [];
|
|
32
|
+
cbs.forEach(cb);
|
|
33
|
+
}
|
|
34
|
+
buffer = {
|
|
35
|
+
push: function (x) { return cb(x); },
|
|
36
|
+
filter: function () { return buffer; },
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
assignMedium: function (cb) {
|
|
40
|
+
assigned = true;
|
|
41
|
+
var pendingQueue = [];
|
|
42
|
+
if (buffer.length) {
|
|
43
|
+
var cbs = buffer;
|
|
44
|
+
buffer = [];
|
|
45
|
+
cbs.forEach(cb);
|
|
46
|
+
pendingQueue = buffer;
|
|
47
|
+
}
|
|
48
|
+
var executeQueue = function () {
|
|
49
|
+
var cbs = pendingQueue;
|
|
50
|
+
pendingQueue = [];
|
|
51
|
+
cbs.forEach(cb);
|
|
52
|
+
};
|
|
53
|
+
var cycle = function () { return Promise.resolve().then(executeQueue); };
|
|
54
|
+
cycle();
|
|
55
|
+
buffer = {
|
|
56
|
+
push: function (x) {
|
|
57
|
+
pendingQueue.push(x);
|
|
58
|
+
cycle();
|
|
59
|
+
},
|
|
60
|
+
filter: function (filter) {
|
|
61
|
+
pendingQueue = pendingQueue.filter(filter);
|
|
62
|
+
return buffer;
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
return medium;
|
|
68
|
+
}
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
70
|
+
function createSidecarMedium(options) {
|
|
71
|
+
if (options === void 0) { options = {}; }
|
|
72
|
+
var medium = innerCreateMedium(null);
|
|
73
|
+
medium.options = __assign({ async: true, ssr: false }, options);
|
|
74
|
+
return medium;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { createSidecarMedium };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,3 +3,13 @@ export type FormFieldError = {
|
|
|
3
3
|
message?: string;
|
|
4
4
|
type?: string;
|
|
5
5
|
} | boolean | null | undefined;
|
|
6
|
+
export type ReactNodeWithConfig = (React.ReactNode & {
|
|
7
|
+
type?: {
|
|
8
|
+
config?: ComponentConfig;
|
|
9
|
+
};
|
|
10
|
+
}) | undefined | null;
|
|
11
|
+
export interface ComponentConfig {
|
|
12
|
+
fieldSuffix?: string;
|
|
13
|
+
isField?: boolean;
|
|
14
|
+
isInline?: boolean;
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coopdigital/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.50.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -53,22 +53,24 @@
|
|
|
53
53
|
},
|
|
54
54
|
"author": "",
|
|
55
55
|
"license": "MIT",
|
|
56
|
-
"description": "",
|
|
56
|
+
"description": "React components for the Experience Library design system",
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@axe-core/playwright": "^4.11.0",
|
|
59
59
|
"@playwright/test": "^1.57.0",
|
|
60
|
-
"@storybook/addon-a11y": "^10.1.
|
|
61
|
-
"@storybook/addon-docs": "^10.1.
|
|
62
|
-
"@storybook/addon-onboarding": "^10.1.
|
|
63
|
-
"@storybook/react-vite": "^10.1.
|
|
60
|
+
"@storybook/addon-a11y": "^10.1.11",
|
|
61
|
+
"@storybook/addon-docs": "^10.1.11",
|
|
62
|
+
"@storybook/addon-onboarding": "^10.1.11",
|
|
63
|
+
"@storybook/react-vite": "^10.1.11",
|
|
64
64
|
"@testing-library/jest-dom": "^6.9.1",
|
|
65
|
-
"@testing-library/react": "^16.3.
|
|
65
|
+
"@testing-library/react": "^16.3.1",
|
|
66
66
|
"@types/react": "^19.2.7",
|
|
67
67
|
"@types/react-dom": "^19.2.3",
|
|
68
|
-
"react": "^19.2.
|
|
69
|
-
"react-dom": "^19.2.
|
|
68
|
+
"react": "^19.2.3",
|
|
69
|
+
"react-dom": "^19.2.3",
|
|
70
|
+
"resize-observer-polyfill": "^1.5.1",
|
|
70
71
|
"serve": "^14.2.5",
|
|
71
|
-
"storybook": "^10.1.
|
|
72
|
+
"storybook": "^10.1.11",
|
|
73
|
+
"storybook-addon-tag-badges": "^3.0.4"
|
|
72
74
|
},
|
|
73
75
|
"peerDependencies": {
|
|
74
76
|
"react": "^19.1.0",
|
|
@@ -78,8 +80,10 @@
|
|
|
78
80
|
"storybook": "$storybook"
|
|
79
81
|
},
|
|
80
82
|
"dependencies": {
|
|
81
|
-
"@coopdigital/styles": "^0.42.
|
|
82
|
-
"
|
|
83
|
+
"@coopdigital/styles": "^0.42.2",
|
|
84
|
+
"@radix-ui/react-popover": "^1.1.15",
|
|
85
|
+
"clsx": "^2.1.1",
|
|
86
|
+
"react-day-picker": "^9.12.0"
|
|
83
87
|
},
|
|
84
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "65ad05bec304ca62f94470c7d1058056e4b57fd6"
|
|
85
89
|
}
|