@zimyo/ui 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +79 -80
- package/dist/_virtual/_rollupPluginBabelHelpers.js +0 -11
- package/dist/components/index.d.ts +0 -59
- package/dist/components/ui/accordion.d.ts +0 -9
- package/dist/components/ui/accordion.js +0 -53
- package/dist/components/ui/alert-dialog.d.ts +0 -16
- package/dist/components/ui/alert-dialog.js +0 -107
- package/dist/components/ui/alert.d.ts +0 -12
- package/dist/components/ui/alert.js +0 -53
- package/dist/components/ui/aspect-ratio.d.ts +0 -6
- package/dist/components/ui/aspect-ratio.js +0 -12
- package/dist/components/ui/avatar.d.ts +0 -8
- package/dist/components/ui/avatar.js +0 -38
- package/dist/components/ui/badge.d.ts +0 -12
- package/dist/components/ui/badge.js +0 -37
- package/dist/components/ui/breadcrumb.d.ts +0 -13
- package/dist/components/ui/breadcrumb.js +0 -90
- package/dist/components/ui/button.d.ts +0 -13
- package/dist/components/ui/button.js +0 -49
- package/dist/components/ui/calendar.d.ts +0 -12
- package/dist/components/ui/calendar.js +0 -134
- package/dist/components/ui/card.d.ts +0 -11
- package/dist/components/ui/card.js +0 -77
- package/dist/components/ui/carousel.d.ts +0 -24
- package/dist/components/ui/carousel.js +0 -163
- package/dist/components/ui/chart.d.ts +0 -43
- package/dist/components/ui/chart.js +0 -187
- package/dist/components/ui/checkbox.d.ts +0 -6
- package/dist/components/ui/checkbox.js +0 -24
- package/dist/components/ui/collapsible.d.ts +0 -8
- package/dist/components/ui/collapsible.js +0 -24
- package/dist/components/ui/command.d.ts +0 -21
- package/dist/components/ui/command.js +0 -110
- package/dist/components/ui/context-menu.d.ts +0 -27
- package/dist/components/ui/context-menu.js +0 -158
- package/dist/components/ui/dialog.d.ts +0 -17
- package/dist/components/ui/dialog.js +0 -102
- package/dist/components/ui/drawer.d.ts +0 -15
- package/dist/components/ui/drawer.js +0 -97
- package/dist/components/ui/dropdown-menu.d.ts +0 -27
- package/dist/components/ui/dropdown-menu.js +0 -160
- package/dist/components/ui/form.d.ts +0 -26
- package/dist/components/ui/form.js +0 -125
- package/dist/components/ui/hover-card.d.ts +0 -8
- package/dist/components/ui/hover-card.js +0 -36
- package/dist/components/ui/input-otp.d.ts +0 -13
- package/dist/components/ui/input-otp.js +0 -61
- package/dist/components/ui/input.d.ts +0 -5
- package/dist/components/ui/input.js +0 -19
- package/dist/components/ui/label.d.ts +0 -6
- package/dist/components/ui/label.js +0 -18
- package/dist/components/ui/menubar.d.ts +0 -28
- package/dist/components/ui/menubar.js +0 -178
- package/dist/components/ui/navigation-menu.d.ts +0 -17
- package/dist/components/ui/navigation-menu.js +0 -102
- package/dist/components/ui/pagination.d.ts +0 -17
- package/dist/components/ui/pagination.js +0 -95
- package/dist/components/ui/popover.d.ts +0 -9
- package/dist/components/ui/popover.js +0 -40
- package/dist/components/ui/progress.d.ts +0 -6
- package/dist/components/ui/progress.js +0 -25
- package/dist/components/ui/radio-group.d.ts +0 -7
- package/dist/components/ui/radio-group.js +0 -34
- package/dist/components/ui/resizable.d.ts +0 -10
- package/dist/components/ui/resizable.js +0 -40
- package/dist/components/ui/scroll-area.d.ts +0 -7
- package/dist/components/ui/scroll-area.js +0 -37
- package/dist/components/ui/select.d.ts +0 -17
- package/dist/components/ui/select.js +0 -118
- package/dist/components/ui/separator.d.ts +0 -6
- package/dist/components/ui/separator.js +0 -22
- package/dist/components/ui/sheet.d.ts +0 -15
- package/dist/components/ui/sheet.js +0 -101
- package/dist/components/ui/sidebar.d.ts +0 -73
- package/dist/components/ui/sidebar.js +0 -484
- package/dist/components/ui/skeleton.d.ts +0 -5
- package/dist/components/ui/skeleton.js +0 -16
- package/dist/components/ui/slider.d.ts +0 -6
- package/dist/components/ui/slider.js +0 -39
- package/dist/components/ui/sonner.d.ts +0 -6
- package/dist/components/ui/sonner.js +0 -18
- package/dist/components/ui/switch.d.ts +0 -6
- package/dist/components/ui/switch.js +0 -21
- package/dist/components/ui/table.d.ts +0 -12
- package/dist/components/ui/table.js +0 -90
- package/dist/components/ui/tabs.d.ts +0 -9
- package/dist/components/ui/tabs.js +0 -48
- package/dist/components/ui/textarea.d.ts +0 -5
- package/dist/components/ui/textarea.js +0 -17
- package/dist/components/ui/toggle-group.d.ts +0 -10
- package/dist/components/ui/toggle-group.js +0 -52
- package/dist/components/ui/toggle.d.ts +0 -12
- package/dist/components/ui/toggle.js +0 -42
- package/dist/components/ui/tooltip.d.ts +0 -9
- package/dist/components/ui/tooltip.js +0 -45
- package/dist/index.d.ts +0 -61
- package/dist/index.js +0 -47
- package/dist/lib/utils.d.ts +0 -5
- package/dist/lib/utils.js +0 -8
- package/dist/node_modules/@date-fns/tz/date/index.js +0 -101
- package/dist/node_modules/@date-fns/tz/date/mini.js +0 -207
- package/dist/node_modules/@date-fns/tz/tzOffset/index.js +0 -43
- package/dist/node_modules/@radix-ui/primitive/dist/index.js +0 -11
- package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.js +0 -39
- package/dist/node_modules/@radix-ui/react-context/dist/index.js +0 -79
- package/dist/node_modules/@radix-ui/react-dialog/dist/index.js +0 -321
- package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +0 -211
- package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.js +0 -29
- package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.js +0 -207
- package/dist/node_modules/@radix-ui/react-id/dist/index.js +0 -15
- package/dist/node_modules/@radix-ui/react-portal/dist/index.js +0 -17
- package/dist/node_modules/@radix-ui/react-presence/dist/index.js +0 -130
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.js +0 -43
- package/dist/node_modules/@radix-ui/react-slot/dist/index.js +0 -89
- package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +0 -12
- package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +0 -70
- package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +0 -18
- package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +0 -7
- package/dist/node_modules/aria-hidden/dist/es2015/index.js +0 -137
- package/dist/node_modules/class-variance-authority/dist/index.js +0 -44
- package/dist/node_modules/clsx/dist/clsx.js +0 -3
- package/dist/node_modules/cmdk/dist/chunk-NZJY6EH4.js +0 -3
- package/dist/node_modules/cmdk/dist/index.js +0 -10
- package/dist/node_modules/date-fns/_lib/addLeadingZeros.js +0 -7
- package/dist/node_modules/date-fns/_lib/defaultOptions.js +0 -7
- package/dist/node_modules/date-fns/_lib/format/formatters.js +0 -775
- package/dist/node_modules/date-fns/_lib/format/lightFormatters.js +0 -94
- package/dist/node_modules/date-fns/_lib/format/longFormatters.js +0 -66
- package/dist/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js +0 -31
- package/dist/node_modules/date-fns/_lib/normalizeDates.js +0 -11
- package/dist/node_modules/date-fns/_lib/normalizeInterval.js +0 -8
- package/dist/node_modules/date-fns/_lib/protectedTokens.js +0 -25
- package/dist/node_modules/date-fns/addDays.js +0 -41
- package/dist/node_modules/date-fns/addMonths.js +0 -75
- package/dist/node_modules/date-fns/addWeeks.js +0 -33
- package/dist/node_modules/date-fns/addYears.js +0 -33
- package/dist/node_modules/date-fns/constants.js +0 -46
- package/dist/node_modules/date-fns/constructFrom.js +0 -49
- package/dist/node_modules/date-fns/differenceInCalendarDays.js +0 -62
- package/dist/node_modules/date-fns/differenceInCalendarMonths.js +0 -42
- package/dist/node_modules/date-fns/eachMonthOfInterval.js +0 -65
- package/dist/node_modules/date-fns/endOfISOWeek.js +0 -35
- package/dist/node_modules/date-fns/endOfMonth.js +0 -37
- package/dist/node_modules/date-fns/endOfWeek.js +0 -53
- package/dist/node_modules/date-fns/endOfYear.js +0 -37
- package/dist/node_modules/date-fns/format.js +0 -423
- package/dist/node_modules/date-fns/getDayOfYear.js +0 -34
- package/dist/node_modules/date-fns/getDaysInMonth.js +0 -36
- package/dist/node_modules/date-fns/getISOWeek.js +0 -40
- package/dist/node_modules/date-fns/getISOWeekYear.js +0 -52
- package/dist/node_modules/date-fns/getMonth.js +0 -29
- package/dist/node_modules/date-fns/getWeek.js +0 -54
- package/dist/node_modules/date-fns/getWeekYear.js +0 -75
- package/dist/node_modules/date-fns/getYear.js +0 -29
- package/dist/node_modules/date-fns/isAfter.js +0 -25
- package/dist/node_modules/date-fns/isBefore.js +0 -25
- package/dist/node_modules/date-fns/isDate.js +0 -41
- package/dist/node_modules/date-fns/isSameDay.js +0 -46
- package/dist/node_modules/date-fns/isSameMonth.js +0 -43
- package/dist/node_modules/date-fns/isSameYear.js +0 -35
- package/dist/node_modules/date-fns/isValid.js +0 -39
- package/dist/node_modules/date-fns/locale/_lib/buildFormatLongFn.js +0 -10
- package/dist/node_modules/date-fns/locale/_lib/buildLocalizeFn.js +0 -64
- package/dist/node_modules/date-fns/locale/_lib/buildMatchFn.js +0 -59
- package/dist/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js +0 -22
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatDistance.js +0 -103
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatLong.js +0 -41
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatRelative.js +0 -13
- package/dist/node_modules/date-fns/locale/en-US/_lib/localize.js +0 -189
- package/dist/node_modules/date-fns/locale/en-US/_lib/match.js +0 -134
- package/dist/node_modules/date-fns/locale/en-US.js +0 -28
- package/dist/node_modules/date-fns/max.js +0 -49
- package/dist/node_modules/date-fns/min.js +0 -49
- package/dist/node_modules/date-fns/setMonth.js +0 -46
- package/dist/node_modules/date-fns/setYear.js +0 -40
- package/dist/node_modules/date-fns/startOfDay.js +0 -35
- package/dist/node_modules/date-fns/startOfISOWeek.js +0 -35
- package/dist/node_modules/date-fns/startOfISOWeekYear.js +0 -42
- package/dist/node_modules/date-fns/startOfMonth.js +0 -37
- package/dist/node_modules/date-fns/startOfWeek.js +0 -53
- package/dist/node_modules/date-fns/startOfWeekYear.js +0 -64
- package/dist/node_modules/date-fns/startOfYear.js +0 -36
- package/dist/node_modules/date-fns/toDate.js +0 -46
- package/dist/node_modules/embla-carousel/esm/embla-carousel.esm.js +0 -1669
- package/dist/node_modules/embla-carousel-react/esm/embla-carousel-react.esm.js +0 -37
- package/dist/node_modules/embla-carousel-reactive-utils/esm/embla-carousel-reactive-utils.esm.js +0 -38
- package/dist/node_modules/get-nonce/dist/es2015/index.js +0 -8
- package/dist/node_modules/input-otp/dist/index.js +0 -24
- package/dist/node_modules/react-day-picker/dist/esm/DayPicker.js +0 -285
- package/dist/node_modules/react-day-picker/dist/esm/UI.js +0 -122
- package/dist/node_modules/react-day-picker/dist/esm/classes/CalendarDay.js +0 -30
- package/dist/node_modules/react-day-picker/dist/esm/classes/CalendarMonth.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/classes/CalendarWeek.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/classes/DateLib.js +0 -522
- package/dist/node_modules/react-day-picker/dist/esm/components/Button.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/CaptionLabel.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Chevron.js +0 -18
- package/dist/node_modules/react-day-picker/dist/esm/components/Day.js +0 -18
- package/dist/node_modules/react-day-picker/dist/esm/components/DayButton.js +0 -19
- package/dist/node_modules/react-day-picker/dist/esm/components/Dropdown.js +0 -21
- package/dist/node_modules/react-day-picker/dist/esm/components/DropdownNav.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Footer.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Month.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/components/MonthCaption.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/components/MonthGrid.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Months.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/MonthsDropdown.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/components/Nav.js +0 -31
- package/dist/node_modules/react-day-picker/dist/esm/components/NextMonthButton.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/components/Option.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/PreviousMonthButton.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/components/Root.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/components/Select.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Week.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/components/WeekNumber.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/components/WeekNumberHeader.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Weekday.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/Weekdays.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/components/Weeks.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/components/YearsDropdown.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/components/custom-components.js +0 -26
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatCaption.js +0 -25
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatDay.js +0 -19
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatMonthDropdown.js +0 -18
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatWeekNumber.js +0 -21
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatWeekNumberHeader.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatWeekdayName.js +0 -19
- package/dist/node_modules/react-day-picker/dist/esm/formatters/formatYearDropdown.js +0 -23
- package/dist/node_modules/react-day-picker/dist/esm/formatters/index.js +0 -7
- package/dist/node_modules/react-day-picker/dist/esm/helpers/calculateFocusTarget.js +0 -73
- package/dist/node_modules/react-day-picker/dist/esm/helpers/createGetModifiers.js +0 -95
- package/dist/node_modules/react-day-picker/dist/esm/helpers/endOfBroadcastWeek.js +0 -22
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getBroadcastWeeksInMonth.js +0 -28
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getClassNamesForModifiers.js +0 -33
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getComponents.js +0 -20
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDataAttributes.js +0 -27
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDates.js +0 -51
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDays.js +0 -19
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDefaultClassNames.js +0 -33
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getDisplayMonths.js +0 -24
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getFocusableDate.js +0 -46
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getFormatters.js +0 -24
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getInitialMonth.js +0 -28
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getMonthOptions.js +0 -33
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getMonths.js +0 -69
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getNavMonth.js +0 -51
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getNextFocus.js +0 -39
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getNextMonth.js +0 -36
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getPreviousMonth.js +0 -37
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getStyleForModifiers.js +0 -27
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getWeekdays.js +0 -24
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getWeeks.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/helpers/getYearOptions.js +0 -38
- package/dist/node_modules/react-day-picker/dist/esm/helpers/startOfBroadcastWeek.js +0 -27
- package/dist/node_modules/react-day-picker/dist/esm/helpers/useControlledValue.js +0 -31
- package/dist/node_modules/react-day-picker/dist/esm/labels/index.js +0 -11
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelDayButton.js +0 -32
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelGrid.js +0 -24
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelGridcell.js +0 -22
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelMonthDropdown.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelNav.js +0 -13
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelNext.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelPrevious.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelWeekNumber.js +0 -15
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelWeekNumberHeader.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelWeekday.js +0 -18
- package/dist/node_modules/react-day-picker/dist/esm/labels/labelYearDropdown.js +0 -14
- package/dist/node_modules/react-day-picker/dist/esm/selection/useMulti.js +0 -57
- package/dist/node_modules/react-day-picker/dist/esm/selection/useRange.js +0 -45
- package/dist/node_modules/react-day-picker/dist/esm/selection/useSingle.js +0 -44
- package/dist/node_modules/react-day-picker/dist/esm/useAnimation.js +0 -175
- package/dist/node_modules/react-day-picker/dist/esm/useCalendar.js +0 -85
- package/dist/node_modules/react-day-picker/dist/esm/useDayPicker.js +0 -25
- package/dist/node_modules/react-day-picker/dist/esm/useFocus.js +0 -50
- package/dist/node_modules/react-day-picker/dist/esm/useSelection.js +0 -31
- package/dist/node_modules/react-day-picker/dist/esm/utils/addToRange.js +0 -92
- package/dist/node_modules/react-day-picker/dist/esm/utils/dateMatchModifiers.js +0 -62
- package/dist/node_modules/react-day-picker/dist/esm/utils/rangeContainsDayOfWeek.js +0 -30
- package/dist/node_modules/react-day-picker/dist/esm/utils/rangeContainsModifiers.js +0 -74
- package/dist/node_modules/react-day-picker/dist/esm/utils/rangeIncludesDate.js +0 -35
- package/dist/node_modules/react-day-picker/dist/esm/utils/rangeOverlaps.js +0 -21
- package/dist/node_modules/react-day-picker/dist/esm/utils/typeguards.js +0 -66
- package/dist/node_modules/react-hook-form/dist/index.esm.js +0 -507
- package/dist/node_modules/react-remove-scroll/dist/es2015/Combination.js +0 -9
- package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +0 -160
- package/dist/node_modules/react-remove-scroll/dist/es2015/UI.js +0 -38
- package/dist/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +0 -21
- package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +0 -110
- package/dist/node_modules/react-remove-scroll/dist/es2015/medium.js +0 -5
- package/dist/node_modules/react-remove-scroll/dist/es2015/sidecar.js +0 -7
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.js +0 -56
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +0 -10
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +0 -31
- package/dist/node_modules/react-resizable-panels/dist/react-resizable-panels.js +0 -2407
- package/dist/node_modules/react-style-singleton/dist/es2015/component.js +0 -19
- package/dist/node_modules/react-style-singleton/dist/es2015/hook.js +0 -25
- package/dist/node_modules/react-style-singleton/dist/es2015/singleton.js +0 -51
- package/dist/node_modules/sonner/dist/index.js +0 -1125
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +0 -2956
- package/dist/node_modules/tslib/tslib.es6.js +0 -56
- package/dist/node_modules/use-callback-ref/dist/es2015/assignRef.js +0 -24
- package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +0 -48
- package/dist/node_modules/use-callback-ref/dist/es2015/useRef.js +0 -42
- package/dist/node_modules/use-sidecar/dist/es2015/exports.js +0 -21
- package/dist/node_modules/use-sidecar/dist/es2015/medium.js +0 -77
- package/dist/node_modules/vaul/dist/index.js +0 -1627
- package/dist/styles.css +0 -1
|
@@ -1,507 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import React__default from 'react';
|
|
3
|
-
|
|
4
|
-
var isCheckBoxInput = (element) => element.type === 'checkbox';
|
|
5
|
-
|
|
6
|
-
var isDateObject = (value) => value instanceof Date;
|
|
7
|
-
|
|
8
|
-
var isNullOrUndefined = (value) => value == null;
|
|
9
|
-
|
|
10
|
-
const isObjectType = (value) => typeof value === 'object';
|
|
11
|
-
var isObject = (value) => !isNullOrUndefined(value) &&
|
|
12
|
-
!Array.isArray(value) &&
|
|
13
|
-
isObjectType(value) &&
|
|
14
|
-
!isDateObject(value);
|
|
15
|
-
|
|
16
|
-
var getEventValue = (event) => isObject(event) && event.target
|
|
17
|
-
? isCheckBoxInput(event.target)
|
|
18
|
-
? event.target.checked
|
|
19
|
-
: event.target.value
|
|
20
|
-
: event;
|
|
21
|
-
|
|
22
|
-
var getNodeParentName = (name) => name.substring(0, name.search(/\.\d+(\.|$)/)) || name;
|
|
23
|
-
|
|
24
|
-
var isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));
|
|
25
|
-
|
|
26
|
-
var isPlainObject = (tempObject) => {
|
|
27
|
-
const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
|
|
28
|
-
return (isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
var isWeb = typeof window !== 'undefined' &&
|
|
32
|
-
typeof window.HTMLElement !== 'undefined' &&
|
|
33
|
-
typeof document !== 'undefined';
|
|
34
|
-
|
|
35
|
-
function cloneObject(data) {
|
|
36
|
-
let copy;
|
|
37
|
-
const isArray = Array.isArray(data);
|
|
38
|
-
const isFileListInstance = typeof FileList !== 'undefined' ? data instanceof FileList : false;
|
|
39
|
-
if (data instanceof Date) {
|
|
40
|
-
copy = new Date(data);
|
|
41
|
-
}
|
|
42
|
-
else if (data instanceof Set) {
|
|
43
|
-
copy = new Set(data);
|
|
44
|
-
}
|
|
45
|
-
else if (!(isWeb && (data instanceof Blob || isFileListInstance)) &&
|
|
46
|
-
(isArray || isObject(data))) {
|
|
47
|
-
copy = isArray ? [] : {};
|
|
48
|
-
if (!isArray && !isPlainObject(data)) {
|
|
49
|
-
copy = data;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
for (const key in data) {
|
|
53
|
-
if (data.hasOwnProperty(key)) {
|
|
54
|
-
copy[key] = cloneObject(data[key]);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
return data;
|
|
61
|
-
}
|
|
62
|
-
return copy;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
var isKey = (value) => /^\w*$/.test(value);
|
|
66
|
-
|
|
67
|
-
var isUndefined = (val) => val === undefined;
|
|
68
|
-
|
|
69
|
-
var compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];
|
|
70
|
-
|
|
71
|
-
var stringToPath = (input) => compact(input.replace(/["|']|\]/g, '').split(/\.|\[/));
|
|
72
|
-
|
|
73
|
-
var get = (object, path, defaultValue) => {
|
|
74
|
-
if (!path || !isObject(object)) {
|
|
75
|
-
return defaultValue;
|
|
76
|
-
}
|
|
77
|
-
const result = (isKey(path) ? [path] : stringToPath(path)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], object);
|
|
78
|
-
return isUndefined(result) || result === object
|
|
79
|
-
? isUndefined(object[path])
|
|
80
|
-
? defaultValue
|
|
81
|
-
: object[path]
|
|
82
|
-
: result;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
var isBoolean = (value) => typeof value === 'boolean';
|
|
86
|
-
|
|
87
|
-
var set = (object, path, value) => {
|
|
88
|
-
let index = -1;
|
|
89
|
-
const tempPath = isKey(path) ? [path] : stringToPath(path);
|
|
90
|
-
const length = tempPath.length;
|
|
91
|
-
const lastIndex = length - 1;
|
|
92
|
-
while (++index < length) {
|
|
93
|
-
const key = tempPath[index];
|
|
94
|
-
let newValue = value;
|
|
95
|
-
if (index !== lastIndex) {
|
|
96
|
-
const objValue = object[key];
|
|
97
|
-
newValue =
|
|
98
|
-
isObject(objValue) || Array.isArray(objValue)
|
|
99
|
-
? objValue
|
|
100
|
-
: !isNaN(+tempPath[index + 1])
|
|
101
|
-
? []
|
|
102
|
-
: {};
|
|
103
|
-
}
|
|
104
|
-
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
object[key] = newValue;
|
|
108
|
-
object = object[key];
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const EVENTS = {
|
|
113
|
-
BLUR: 'blur',
|
|
114
|
-
CHANGE: 'change',
|
|
115
|
-
};
|
|
116
|
-
const VALIDATION_MODE = {
|
|
117
|
-
all: 'all',
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const HookFormContext = React__default.createContext(null);
|
|
121
|
-
HookFormContext.displayName = 'HookFormContext';
|
|
122
|
-
/**
|
|
123
|
-
* This custom hook allows you to access the form context. useFormContext is intended to be used in deeply nested structures, where it would become inconvenient to pass the context as a prop. To be used with {@link FormProvider}.
|
|
124
|
-
*
|
|
125
|
-
* @remarks
|
|
126
|
-
* [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
|
|
127
|
-
*
|
|
128
|
-
* @returns return all useForm methods
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
* ```tsx
|
|
132
|
-
* function App() {
|
|
133
|
-
* const methods = useForm();
|
|
134
|
-
* const onSubmit = data => console.log(data);
|
|
135
|
-
*
|
|
136
|
-
* return (
|
|
137
|
-
* <FormProvider {...methods} >
|
|
138
|
-
* <form onSubmit={methods.handleSubmit(onSubmit)}>
|
|
139
|
-
* <NestedInput />
|
|
140
|
-
* <input type="submit" />
|
|
141
|
-
* </form>
|
|
142
|
-
* </FormProvider>
|
|
143
|
-
* );
|
|
144
|
-
* }
|
|
145
|
-
*
|
|
146
|
-
* function NestedInput() {
|
|
147
|
-
* const { register } = useFormContext(); // retrieve all hook methods
|
|
148
|
-
* return <input {...register("test")} />;
|
|
149
|
-
* }
|
|
150
|
-
* ```
|
|
151
|
-
*/
|
|
152
|
-
const useFormContext = () => React__default.useContext(HookFormContext);
|
|
153
|
-
/**
|
|
154
|
-
* A provider component that propagates the `useForm` methods to all children components via [React Context](https://reactjs.org/docs/context.html) API. To be used with {@link useFormContext}.
|
|
155
|
-
*
|
|
156
|
-
* @remarks
|
|
157
|
-
* [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
|
|
158
|
-
*
|
|
159
|
-
* @param props - all useForm methods
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* ```tsx
|
|
163
|
-
* function App() {
|
|
164
|
-
* const methods = useForm();
|
|
165
|
-
* const onSubmit = data => console.log(data);
|
|
166
|
-
*
|
|
167
|
-
* return (
|
|
168
|
-
* <FormProvider {...methods} >
|
|
169
|
-
* <form onSubmit={methods.handleSubmit(onSubmit)}>
|
|
170
|
-
* <NestedInput />
|
|
171
|
-
* <input type="submit" />
|
|
172
|
-
* </form>
|
|
173
|
-
* </FormProvider>
|
|
174
|
-
* );
|
|
175
|
-
* }
|
|
176
|
-
*
|
|
177
|
-
* function NestedInput() {
|
|
178
|
-
* const { register } = useFormContext(); // retrieve all hook methods
|
|
179
|
-
* return <input {...register("test")} />;
|
|
180
|
-
* }
|
|
181
|
-
* ```
|
|
182
|
-
*/
|
|
183
|
-
const FormProvider = (props) => {
|
|
184
|
-
const { children, ...data } = props;
|
|
185
|
-
return (React__default.createElement(HookFormContext.Provider, { value: data }, children));
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
var getProxyFormState = (formState, control, localProxyFormState, isRoot = true) => {
|
|
189
|
-
const result = {
|
|
190
|
-
defaultValues: control._defaultValues,
|
|
191
|
-
};
|
|
192
|
-
for (const key in formState) {
|
|
193
|
-
Object.defineProperty(result, key, {
|
|
194
|
-
get: () => {
|
|
195
|
-
const _key = key;
|
|
196
|
-
if (control._proxyFormState[_key] !== VALIDATION_MODE.all) {
|
|
197
|
-
control._proxyFormState[_key] = !isRoot || VALIDATION_MODE.all;
|
|
198
|
-
}
|
|
199
|
-
localProxyFormState && (localProxyFormState[_key] = true);
|
|
200
|
-
return formState[_key];
|
|
201
|
-
},
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
return result;
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* This custom hook allows you to subscribe to each form state, and isolate the re-render at the custom hook level. It has its scope in terms of form state subscription, so it would not affect other useFormState and useForm. Using this hook can reduce the re-render impact on large and complex form application.
|
|
211
|
-
*
|
|
212
|
-
* @remarks
|
|
213
|
-
* [API](https://react-hook-form.com/docs/useformstate) • [Demo](https://codesandbox.io/s/useformstate-75xly)
|
|
214
|
-
*
|
|
215
|
-
* @param props - include options on specify fields to subscribe. {@link UseFormStateReturn}
|
|
216
|
-
*
|
|
217
|
-
* @example
|
|
218
|
-
* ```tsx
|
|
219
|
-
* function App() {
|
|
220
|
-
* const { register, handleSubmit, control } = useForm({
|
|
221
|
-
* defaultValues: {
|
|
222
|
-
* firstName: "firstName"
|
|
223
|
-
* }});
|
|
224
|
-
* const { dirtyFields } = useFormState({
|
|
225
|
-
* control
|
|
226
|
-
* });
|
|
227
|
-
* const onSubmit = (data) => console.log(data);
|
|
228
|
-
*
|
|
229
|
-
* return (
|
|
230
|
-
* <form onSubmit={handleSubmit(onSubmit)}>
|
|
231
|
-
* <input {...register("firstName")} placeholder="First Name" />
|
|
232
|
-
* {dirtyFields.firstName && <p>Field is dirty.</p>}
|
|
233
|
-
* <input type="submit" />
|
|
234
|
-
* </form>
|
|
235
|
-
* );
|
|
236
|
-
* }
|
|
237
|
-
* ```
|
|
238
|
-
*/
|
|
239
|
-
function useFormState(props) {
|
|
240
|
-
const methods = useFormContext();
|
|
241
|
-
const { control = methods.control, disabled, name, exact } = props || {};
|
|
242
|
-
const [formState, updateFormState] = React__default.useState(control._formState);
|
|
243
|
-
const _localProxyFormState = React__default.useRef({
|
|
244
|
-
isDirty: false,
|
|
245
|
-
isLoading: false,
|
|
246
|
-
dirtyFields: false,
|
|
247
|
-
touchedFields: false,
|
|
248
|
-
validatingFields: false,
|
|
249
|
-
isValidating: false,
|
|
250
|
-
isValid: false,
|
|
251
|
-
errors: false,
|
|
252
|
-
});
|
|
253
|
-
useIsomorphicLayoutEffect(() => control._subscribe({
|
|
254
|
-
name,
|
|
255
|
-
formState: _localProxyFormState.current,
|
|
256
|
-
exact,
|
|
257
|
-
callback: (formState) => {
|
|
258
|
-
!disabled &&
|
|
259
|
-
updateFormState({
|
|
260
|
-
...control._formState,
|
|
261
|
-
...formState,
|
|
262
|
-
});
|
|
263
|
-
},
|
|
264
|
-
}), [name, disabled, exact]);
|
|
265
|
-
React__default.useEffect(() => {
|
|
266
|
-
_localProxyFormState.current.isValid && control._setValid(true);
|
|
267
|
-
}, [control]);
|
|
268
|
-
return React__default.useMemo(() => getProxyFormState(formState, control, _localProxyFormState.current, false), [formState, control]);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
var isString = (value) => typeof value === 'string';
|
|
272
|
-
|
|
273
|
-
var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) => {
|
|
274
|
-
if (isString(names)) {
|
|
275
|
-
return get(formValues, names, defaultValue);
|
|
276
|
-
}
|
|
277
|
-
if (Array.isArray(names)) {
|
|
278
|
-
return names.map((fieldName) => (get(formValues, fieldName)));
|
|
279
|
-
}
|
|
280
|
-
return formValues;
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Custom hook to subscribe to field change and isolate re-rendering at the component level.
|
|
285
|
-
*
|
|
286
|
-
* @remarks
|
|
287
|
-
*
|
|
288
|
-
* [API](https://react-hook-form.com/docs/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)
|
|
289
|
-
*
|
|
290
|
-
* @example
|
|
291
|
-
* ```tsx
|
|
292
|
-
* const { control } = useForm();
|
|
293
|
-
* const values = useWatch({
|
|
294
|
-
* name: "fieldName"
|
|
295
|
-
* control,
|
|
296
|
-
* })
|
|
297
|
-
* ```
|
|
298
|
-
*/
|
|
299
|
-
function useWatch(props) {
|
|
300
|
-
const methods = useFormContext();
|
|
301
|
-
const { control = methods.control, name, defaultValue, disabled, exact, } = props || {};
|
|
302
|
-
const _defaultValue = React__default.useRef(defaultValue);
|
|
303
|
-
const [value, updateValue] = React__default.useState(control._getWatch(name, _defaultValue.current));
|
|
304
|
-
useIsomorphicLayoutEffect(() => control._subscribe({
|
|
305
|
-
name,
|
|
306
|
-
formState: {
|
|
307
|
-
values: true,
|
|
308
|
-
},
|
|
309
|
-
exact,
|
|
310
|
-
callback: (formState) => !disabled &&
|
|
311
|
-
updateValue(generateWatchOutput(name, control._names, formState.values || control._formValues, false, _defaultValue.current)),
|
|
312
|
-
}), [name, control, disabled, exact]);
|
|
313
|
-
React__default.useEffect(() => control._removeUnmounted());
|
|
314
|
-
return value;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Custom hook to work with controlled component, this function provide you with both form and field level state. Re-render is isolated at the hook level.
|
|
319
|
-
*
|
|
320
|
-
* @remarks
|
|
321
|
-
* [API](https://react-hook-form.com/docs/usecontroller) • [Demo](https://codesandbox.io/s/usecontroller-0o8px)
|
|
322
|
-
*
|
|
323
|
-
* @param props - the path name to the form field value, and validation rules.
|
|
324
|
-
*
|
|
325
|
-
* @returns field properties, field and form state. {@link UseControllerReturn}
|
|
326
|
-
*
|
|
327
|
-
* @example
|
|
328
|
-
* ```tsx
|
|
329
|
-
* function Input(props) {
|
|
330
|
-
* const { field, fieldState, formState } = useController(props);
|
|
331
|
-
* return (
|
|
332
|
-
* <div>
|
|
333
|
-
* <input {...field} placeholder={props.name} />
|
|
334
|
-
* <p>{fieldState.isTouched && "Touched"}</p>
|
|
335
|
-
* <p>{formState.isSubmitted ? "submitted" : ""}</p>
|
|
336
|
-
* </div>
|
|
337
|
-
* );
|
|
338
|
-
* }
|
|
339
|
-
* ```
|
|
340
|
-
*/
|
|
341
|
-
function useController(props) {
|
|
342
|
-
const methods = useFormContext();
|
|
343
|
-
const { name, disabled, control = methods.control, shouldUnregister } = props;
|
|
344
|
-
const isArrayField = isNameInFieldArray(control._names.array, name);
|
|
345
|
-
const value = useWatch({
|
|
346
|
-
control,
|
|
347
|
-
name,
|
|
348
|
-
defaultValue: get(control._formValues, name, get(control._defaultValues, name, props.defaultValue)),
|
|
349
|
-
exact: true,
|
|
350
|
-
});
|
|
351
|
-
const formState = useFormState({
|
|
352
|
-
control,
|
|
353
|
-
name,
|
|
354
|
-
exact: true,
|
|
355
|
-
});
|
|
356
|
-
const _props = React__default.useRef(props);
|
|
357
|
-
const _registerProps = React__default.useRef(control.register(name, {
|
|
358
|
-
...props.rules,
|
|
359
|
-
value,
|
|
360
|
-
...(isBoolean(props.disabled) ? { disabled: props.disabled } : {}),
|
|
361
|
-
}));
|
|
362
|
-
const fieldState = React__default.useMemo(() => Object.defineProperties({}, {
|
|
363
|
-
invalid: {
|
|
364
|
-
enumerable: true,
|
|
365
|
-
get: () => !!get(formState.errors, name),
|
|
366
|
-
},
|
|
367
|
-
isDirty: {
|
|
368
|
-
enumerable: true,
|
|
369
|
-
get: () => !!get(formState.dirtyFields, name),
|
|
370
|
-
},
|
|
371
|
-
isTouched: {
|
|
372
|
-
enumerable: true,
|
|
373
|
-
get: () => !!get(formState.touchedFields, name),
|
|
374
|
-
},
|
|
375
|
-
isValidating: {
|
|
376
|
-
enumerable: true,
|
|
377
|
-
get: () => !!get(formState.validatingFields, name),
|
|
378
|
-
},
|
|
379
|
-
error: {
|
|
380
|
-
enumerable: true,
|
|
381
|
-
get: () => get(formState.errors, name),
|
|
382
|
-
},
|
|
383
|
-
}), [formState, name]);
|
|
384
|
-
const onChange = React__default.useCallback((event) => _registerProps.current.onChange({
|
|
385
|
-
target: {
|
|
386
|
-
value: getEventValue(event),
|
|
387
|
-
name: name,
|
|
388
|
-
},
|
|
389
|
-
type: EVENTS.CHANGE,
|
|
390
|
-
}), [name]);
|
|
391
|
-
const onBlur = React__default.useCallback(() => _registerProps.current.onBlur({
|
|
392
|
-
target: {
|
|
393
|
-
value: get(control._formValues, name),
|
|
394
|
-
name: name,
|
|
395
|
-
},
|
|
396
|
-
type: EVENTS.BLUR,
|
|
397
|
-
}), [name, control._formValues]);
|
|
398
|
-
const ref = React__default.useCallback((elm) => {
|
|
399
|
-
const field = get(control._fields, name);
|
|
400
|
-
if (field && elm) {
|
|
401
|
-
field._f.ref = {
|
|
402
|
-
focus: () => elm.focus && elm.focus(),
|
|
403
|
-
select: () => elm.select && elm.select(),
|
|
404
|
-
setCustomValidity: (message) => elm.setCustomValidity(message),
|
|
405
|
-
reportValidity: () => elm.reportValidity(),
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
}, [control._fields, name]);
|
|
409
|
-
const field = React__default.useMemo(() => ({
|
|
410
|
-
name,
|
|
411
|
-
value,
|
|
412
|
-
...(isBoolean(disabled) || formState.disabled
|
|
413
|
-
? { disabled: formState.disabled || disabled }
|
|
414
|
-
: {}),
|
|
415
|
-
onChange,
|
|
416
|
-
onBlur,
|
|
417
|
-
ref,
|
|
418
|
-
}), [name, disabled, formState.disabled, onChange, onBlur, ref, value]);
|
|
419
|
-
React__default.useEffect(() => {
|
|
420
|
-
const _shouldUnregisterField = control._options.shouldUnregister || shouldUnregister;
|
|
421
|
-
control.register(name, {
|
|
422
|
-
..._props.current.rules,
|
|
423
|
-
...(isBoolean(_props.current.disabled)
|
|
424
|
-
? { disabled: _props.current.disabled }
|
|
425
|
-
: {}),
|
|
426
|
-
});
|
|
427
|
-
const updateMounted = (name, value) => {
|
|
428
|
-
const field = get(control._fields, name);
|
|
429
|
-
if (field && field._f) {
|
|
430
|
-
field._f.mount = value;
|
|
431
|
-
}
|
|
432
|
-
};
|
|
433
|
-
updateMounted(name, true);
|
|
434
|
-
if (_shouldUnregisterField) {
|
|
435
|
-
const value = cloneObject(get(control._options.defaultValues, name));
|
|
436
|
-
set(control._defaultValues, name, value);
|
|
437
|
-
if (isUndefined(get(control._formValues, name))) {
|
|
438
|
-
set(control._formValues, name, value);
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
!isArrayField && control.register(name);
|
|
442
|
-
return () => {
|
|
443
|
-
(isArrayField
|
|
444
|
-
? _shouldUnregisterField && !control._state.action
|
|
445
|
-
: _shouldUnregisterField)
|
|
446
|
-
? control.unregister(name)
|
|
447
|
-
: updateMounted(name, false);
|
|
448
|
-
};
|
|
449
|
-
}, [name, control, isArrayField, shouldUnregister]);
|
|
450
|
-
React__default.useEffect(() => {
|
|
451
|
-
control._setDisabledField({
|
|
452
|
-
disabled,
|
|
453
|
-
name,
|
|
454
|
-
});
|
|
455
|
-
}, [disabled, name, control]);
|
|
456
|
-
return React__default.useMemo(() => ({
|
|
457
|
-
field,
|
|
458
|
-
formState,
|
|
459
|
-
fieldState,
|
|
460
|
-
}), [field, formState, fieldState]);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
/**
|
|
464
|
-
* Component based on `useController` hook to work with controlled component.
|
|
465
|
-
*
|
|
466
|
-
* @remarks
|
|
467
|
-
* [API](https://react-hook-form.com/docs/usecontroller/controller) • [Demo](https://codesandbox.io/s/react-hook-form-v6-controller-ts-jwyzw) • [Video](https://www.youtube.com/watch?v=N2UNk_UCVyA)
|
|
468
|
-
*
|
|
469
|
-
* @param props - the path name to the form field value, and validation rules.
|
|
470
|
-
*
|
|
471
|
-
* @returns provide field handler functions, field and form state.
|
|
472
|
-
*
|
|
473
|
-
* @example
|
|
474
|
-
* ```tsx
|
|
475
|
-
* function App() {
|
|
476
|
-
* const { control } = useForm<FormValues>({
|
|
477
|
-
* defaultValues: {
|
|
478
|
-
* test: ""
|
|
479
|
-
* }
|
|
480
|
-
* });
|
|
481
|
-
*
|
|
482
|
-
* return (
|
|
483
|
-
* <form>
|
|
484
|
-
* <Controller
|
|
485
|
-
* control={control}
|
|
486
|
-
* name="test"
|
|
487
|
-
* render={({ field: { onChange, onBlur, value, ref }, formState, fieldState }) => (
|
|
488
|
-
* <>
|
|
489
|
-
* <input
|
|
490
|
-
* onChange={onChange} // send value to hook form
|
|
491
|
-
* onBlur={onBlur} // notify when input is touched
|
|
492
|
-
* value={value} // return updated value
|
|
493
|
-
* ref={ref} // set ref for focus management
|
|
494
|
-
* />
|
|
495
|
-
* <p>{formState.isSubmitted ? "submitted" : ""}</p>
|
|
496
|
-
* <p>{fieldState.isTouched ? "touched" : ""}</p>
|
|
497
|
-
* </>
|
|
498
|
-
* )}
|
|
499
|
-
* />
|
|
500
|
-
* </form>
|
|
501
|
-
* );
|
|
502
|
-
* }
|
|
503
|
-
* ```
|
|
504
|
-
*/
|
|
505
|
-
const Controller = (props) => props.render(useController(props));
|
|
506
|
-
|
|
507
|
-
export { Controller, FormProvider, get, set, useController, useFormContext, useFormState, useWatch };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { __assign } from '../../../tslib/tslib.es6.js';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { RemoveScroll } from './UI.js';
|
|
4
|
-
import SideCar from './sidecar.js';
|
|
5
|
-
|
|
6
|
-
var ReactRemoveScroll = React.forwardRef(function (props, ref) { return (React.createElement(RemoveScroll, __assign({}, props, { ref: ref, sideCar: SideCar }))); });
|
|
7
|
-
ReactRemoveScroll.classNames = RemoveScroll.classNames;
|
|
8
|
-
|
|
9
|
-
export { ReactRemoveScroll as default };
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { __spreadArray } from '../../../tslib/tslib.es6.js';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { RemoveScrollBar } from '../../../react-remove-scroll-bar/dist/es2015/component.js';
|
|
4
|
-
import { styleSingleton } from '../../../react-style-singleton/dist/es2015/component.js';
|
|
5
|
-
import { nonPassive } from './aggresiveCapture.js';
|
|
6
|
-
import { locationCouldBeScrolled, handleScroll } from './handleScroll.js';
|
|
7
|
-
|
|
8
|
-
var getTouchXY = function (event) {
|
|
9
|
-
return 'changedTouches' in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
|
|
10
|
-
};
|
|
11
|
-
var getDeltaXY = function (event) { return [event.deltaX, event.deltaY]; };
|
|
12
|
-
var extractRef = function (ref) {
|
|
13
|
-
return ref && 'current' in ref ? ref.current : ref;
|
|
14
|
-
};
|
|
15
|
-
var deltaCompare = function (x, y) { return x[0] === y[0] && x[1] === y[1]; };
|
|
16
|
-
var generateStyle = function (id) { return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n"); };
|
|
17
|
-
var idCounter = 0;
|
|
18
|
-
var lockStack = [];
|
|
19
|
-
function RemoveScrollSideCar(props) {
|
|
20
|
-
var shouldPreventQueue = React.useRef([]);
|
|
21
|
-
var touchStartRef = React.useRef([0, 0]);
|
|
22
|
-
var activeAxis = React.useRef();
|
|
23
|
-
var id = React.useState(idCounter++)[0];
|
|
24
|
-
var Style = React.useState(styleSingleton)[0];
|
|
25
|
-
var lastProps = React.useRef(props);
|
|
26
|
-
React.useEffect(function () {
|
|
27
|
-
lastProps.current = props;
|
|
28
|
-
}, [props]);
|
|
29
|
-
React.useEffect(function () {
|
|
30
|
-
if (props.inert) {
|
|
31
|
-
document.body.classList.add("block-interactivity-".concat(id));
|
|
32
|
-
var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean);
|
|
33
|
-
allow_1.forEach(function (el) { return el.classList.add("allow-interactivity-".concat(id)); });
|
|
34
|
-
return function () {
|
|
35
|
-
document.body.classList.remove("block-interactivity-".concat(id));
|
|
36
|
-
allow_1.forEach(function (el) { return el.classList.remove("allow-interactivity-".concat(id)); });
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
return;
|
|
40
|
-
}, [props.inert, props.lockRef.current, props.shards]);
|
|
41
|
-
var shouldCancelEvent = React.useCallback(function (event, parent) {
|
|
42
|
-
if (('touches' in event && event.touches.length === 2) || (event.type === 'wheel' && event.ctrlKey)) {
|
|
43
|
-
return !lastProps.current.allowPinchZoom;
|
|
44
|
-
}
|
|
45
|
-
var touch = getTouchXY(event);
|
|
46
|
-
var touchStart = touchStartRef.current;
|
|
47
|
-
var deltaX = 'deltaX' in event ? event.deltaX : touchStart[0] - touch[0];
|
|
48
|
-
var deltaY = 'deltaY' in event ? event.deltaY : touchStart[1] - touch[1];
|
|
49
|
-
var currentAxis;
|
|
50
|
-
var target = event.target;
|
|
51
|
-
var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? 'h' : 'v';
|
|
52
|
-
// allow horizontal touch move on Range inputs. They will not cause any scroll
|
|
53
|
-
if ('touches' in event && moveDirection === 'h' && target.type === 'range') {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
|
|
57
|
-
if (!canBeScrolledInMainDirection) {
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
if (canBeScrolledInMainDirection) {
|
|
61
|
-
currentAxis = moveDirection;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
currentAxis = moveDirection === 'v' ? 'h' : 'v';
|
|
65
|
-
canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
|
|
66
|
-
// other axis might be not scrollable
|
|
67
|
-
}
|
|
68
|
-
if (!canBeScrolledInMainDirection) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
if (!activeAxis.current && 'changedTouches' in event && (deltaX || deltaY)) {
|
|
72
|
-
activeAxis.current = currentAxis;
|
|
73
|
-
}
|
|
74
|
-
if (!currentAxis) {
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
var cancelingAxis = activeAxis.current || currentAxis;
|
|
78
|
-
return handleScroll(cancelingAxis, parent, event, cancelingAxis === 'h' ? deltaX : deltaY);
|
|
79
|
-
}, []);
|
|
80
|
-
var shouldPrevent = React.useCallback(function (_event) {
|
|
81
|
-
var event = _event;
|
|
82
|
-
if (!lockStack.length || lockStack[lockStack.length - 1] !== Style) {
|
|
83
|
-
// not the last active
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
var delta = 'deltaY' in event ? getDeltaXY(event) : getTouchXY(event);
|
|
87
|
-
var sourceEvent = shouldPreventQueue.current.filter(function (e) { return e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta); })[0];
|
|
88
|
-
// self event, and should be canceled
|
|
89
|
-
if (sourceEvent && sourceEvent.should) {
|
|
90
|
-
if (event.cancelable) {
|
|
91
|
-
event.preventDefault();
|
|
92
|
-
}
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
// outside or shard event
|
|
96
|
-
if (!sourceEvent) {
|
|
97
|
-
var shardNodes = (lastProps.current.shards || [])
|
|
98
|
-
.map(extractRef)
|
|
99
|
-
.filter(Boolean)
|
|
100
|
-
.filter(function (node) { return node.contains(event.target); });
|
|
101
|
-
var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
|
|
102
|
-
if (shouldStop) {
|
|
103
|
-
if (event.cancelable) {
|
|
104
|
-
event.preventDefault();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}, []);
|
|
109
|
-
var shouldCancel = React.useCallback(function (name, delta, target, should) {
|
|
110
|
-
var event = { name: name, delta: delta, target: target, should: should, shadowParent: getOutermostShadowParent(target) };
|
|
111
|
-
shouldPreventQueue.current.push(event);
|
|
112
|
-
setTimeout(function () {
|
|
113
|
-
shouldPreventQueue.current = shouldPreventQueue.current.filter(function (e) { return e !== event; });
|
|
114
|
-
}, 1);
|
|
115
|
-
}, []);
|
|
116
|
-
var scrollTouchStart = React.useCallback(function (event) {
|
|
117
|
-
touchStartRef.current = getTouchXY(event);
|
|
118
|
-
activeAxis.current = undefined;
|
|
119
|
-
}, []);
|
|
120
|
-
var scrollWheel = React.useCallback(function (event) {
|
|
121
|
-
shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
|
122
|
-
}, []);
|
|
123
|
-
var scrollTouchMove = React.useCallback(function (event) {
|
|
124
|
-
shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
|
125
|
-
}, []);
|
|
126
|
-
React.useEffect(function () {
|
|
127
|
-
lockStack.push(Style);
|
|
128
|
-
props.setCallbacks({
|
|
129
|
-
onScrollCapture: scrollWheel,
|
|
130
|
-
onWheelCapture: scrollWheel,
|
|
131
|
-
onTouchMoveCapture: scrollTouchMove,
|
|
132
|
-
});
|
|
133
|
-
document.addEventListener('wheel', shouldPrevent, nonPassive);
|
|
134
|
-
document.addEventListener('touchmove', shouldPrevent, nonPassive);
|
|
135
|
-
document.addEventListener('touchstart', scrollTouchStart, nonPassive);
|
|
136
|
-
return function () {
|
|
137
|
-
lockStack = lockStack.filter(function (inst) { return inst !== Style; });
|
|
138
|
-
document.removeEventListener('wheel', shouldPrevent, nonPassive);
|
|
139
|
-
document.removeEventListener('touchmove', shouldPrevent, nonPassive);
|
|
140
|
-
document.removeEventListener('touchstart', scrollTouchStart, nonPassive);
|
|
141
|
-
};
|
|
142
|
-
}, []);
|
|
143
|
-
var removeScrollBar = props.removeScrollBar, inert = props.inert;
|
|
144
|
-
return (React.createElement(React.Fragment, null,
|
|
145
|
-
inert ? React.createElement(Style, { styles: generateStyle(id) }) : null,
|
|
146
|
-
removeScrollBar ? React.createElement(RemoveScrollBar, { noRelative: props.noRelative, gapMode: props.gapMode }) : null));
|
|
147
|
-
}
|
|
148
|
-
function getOutermostShadowParent(node) {
|
|
149
|
-
var shadowParent = null;
|
|
150
|
-
while (node !== null) {
|
|
151
|
-
if (node instanceof ShadowRoot) {
|
|
152
|
-
shadowParent = node.host;
|
|
153
|
-
node = node.host;
|
|
154
|
-
}
|
|
155
|
-
node = node.parentNode;
|
|
156
|
-
}
|
|
157
|
-
return shadowParent;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export { RemoveScrollSideCar, getDeltaXY, getTouchXY };
|