@zimyo/ui 1.0.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/_virtual/_rollupPluginBabelHelpers.js +11 -0
- package/dist/components/index.d.ts +59 -0
- package/dist/components/ui/accordion.d.ts +9 -0
- package/dist/components/ui/accordion.js +53 -0
- package/dist/components/ui/alert-dialog.d.ts +16 -0
- package/dist/components/ui/alert-dialog.js +107 -0
- package/dist/components/ui/alert.d.ts +12 -0
- package/dist/components/ui/alert.js +53 -0
- package/dist/components/ui/aspect-ratio.d.ts +6 -0
- package/dist/components/ui/aspect-ratio.js +12 -0
- package/dist/components/ui/avatar.d.ts +8 -0
- package/dist/components/ui/avatar.js +38 -0
- package/dist/components/ui/badge.d.ts +12 -0
- package/dist/components/ui/badge.js +37 -0
- package/dist/components/ui/breadcrumb.d.ts +13 -0
- package/dist/components/ui/breadcrumb.js +90 -0
- package/dist/components/ui/button.d.ts +13 -0
- package/dist/components/ui/button.js +49 -0
- package/dist/components/ui/calendar.d.ts +12 -0
- package/dist/components/ui/calendar.js +134 -0
- package/dist/components/ui/card.d.ts +11 -0
- package/dist/components/ui/card.js +77 -0
- package/dist/components/ui/carousel.d.ts +24 -0
- package/dist/components/ui/carousel.js +163 -0
- package/dist/components/ui/chart.d.ts +43 -0
- package/dist/components/ui/chart.js +187 -0
- package/dist/components/ui/checkbox.d.ts +6 -0
- package/dist/components/ui/checkbox.js +24 -0
- package/dist/components/ui/collapsible.d.ts +8 -0
- package/dist/components/ui/collapsible.js +24 -0
- package/dist/components/ui/command.d.ts +21 -0
- package/dist/components/ui/command.js +110 -0
- package/dist/components/ui/context-menu.d.ts +27 -0
- package/dist/components/ui/context-menu.js +158 -0
- package/dist/components/ui/dialog.d.ts +17 -0
- package/dist/components/ui/dialog.js +102 -0
- package/dist/components/ui/drawer.d.ts +15 -0
- package/dist/components/ui/drawer.js +97 -0
- package/dist/components/ui/dropdown-menu.d.ts +27 -0
- package/dist/components/ui/dropdown-menu.js +160 -0
- package/dist/components/ui/form.d.ts +26 -0
- package/dist/components/ui/form.js +125 -0
- package/dist/components/ui/hover-card.d.ts +8 -0
- package/dist/components/ui/hover-card.js +36 -0
- package/dist/components/ui/input-otp.d.ts +13 -0
- package/dist/components/ui/input-otp.js +61 -0
- package/dist/components/ui/input.d.ts +5 -0
- package/dist/components/ui/input.js +19 -0
- package/dist/components/ui/label.d.ts +6 -0
- package/dist/components/ui/label.js +18 -0
- package/dist/components/ui/menubar.d.ts +28 -0
- package/dist/components/ui/menubar.js +178 -0
- package/dist/components/ui/navigation-menu.d.ts +17 -0
- package/dist/components/ui/navigation-menu.js +102 -0
- package/dist/components/ui/pagination.d.ts +17 -0
- package/dist/components/ui/pagination.js +95 -0
- package/dist/components/ui/popover.d.ts +9 -0
- package/dist/components/ui/popover.js +40 -0
- package/dist/components/ui/progress.d.ts +6 -0
- package/dist/components/ui/progress.js +25 -0
- package/dist/components/ui/radio-group.d.ts +7 -0
- package/dist/components/ui/radio-group.js +34 -0
- package/dist/components/ui/resizable.d.ts +10 -0
- package/dist/components/ui/resizable.js +40 -0
- package/dist/components/ui/scroll-area.d.ts +7 -0
- package/dist/components/ui/scroll-area.js +37 -0
- package/dist/components/ui/select.d.ts +17 -0
- package/dist/components/ui/select.js +118 -0
- package/dist/components/ui/separator.d.ts +6 -0
- package/dist/components/ui/separator.js +22 -0
- package/dist/components/ui/sheet.d.ts +15 -0
- package/dist/components/ui/sheet.js +101 -0
- package/dist/components/ui/sidebar.d.ts +73 -0
- package/dist/components/ui/sidebar.js +484 -0
- package/dist/components/ui/skeleton.d.ts +5 -0
- package/dist/components/ui/skeleton.js +16 -0
- package/dist/components/ui/slider.d.ts +6 -0
- package/dist/components/ui/slider.js +39 -0
- package/dist/components/ui/sonner.d.ts +6 -0
- package/dist/components/ui/sonner.js +18 -0
- package/dist/components/ui/switch.d.ts +6 -0
- package/dist/components/ui/switch.js +21 -0
- package/dist/components/ui/table.d.ts +12 -0
- package/dist/components/ui/table.js +90 -0
- package/dist/components/ui/tabs.d.ts +9 -0
- package/dist/components/ui/tabs.js +48 -0
- package/dist/components/ui/textarea.d.ts +5 -0
- package/dist/components/ui/textarea.js +17 -0
- package/dist/components/ui/toggle-group.d.ts +10 -0
- package/dist/components/ui/toggle-group.js +52 -0
- package/dist/components/ui/toggle.d.ts +12 -0
- package/dist/components/ui/toggle.js +42 -0
- package/dist/components/ui/tooltip.d.ts +9 -0
- package/dist/components/ui/tooltip.js +45 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +47 -0
- package/dist/lib/utils.d.ts +5 -0
- package/dist/lib/utils.js +8 -0
- package/dist/node_modules/@date-fns/tz/date/index.js +101 -0
- package/dist/node_modules/@date-fns/tz/date/mini.js +207 -0
- package/dist/node_modules/@date-fns/tz/tzOffset/index.js +43 -0
- package/dist/node_modules/@radix-ui/primitive/dist/index.js +11 -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 +79 -0
- package/dist/node_modules/@radix-ui/react-dialog/dist/index.js +321 -0
- package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +211 -0
- package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.js +29 -0
- package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.js +207 -0
- package/dist/node_modules/@radix-ui/react-id/dist/index.js +15 -0
- package/dist/node_modules/@radix-ui/react-portal/dist/index.js +17 -0
- package/dist/node_modules/@radix-ui/react-presence/dist/index.js +130 -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/aria-hidden/dist/es2015/index.js +137 -0
- package/dist/node_modules/class-variance-authority/dist/index.js +44 -0
- package/dist/node_modules/clsx/dist/clsx.js +3 -0
- package/dist/node_modules/cmdk/dist/chunk-NZJY6EH4.js +3 -0
- package/dist/node_modules/cmdk/dist/index.js +10 -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 +46 -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/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/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/setMonth.js +46 -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/embla-carousel/esm/embla-carousel.esm.js +1669 -0
- package/dist/node_modules/embla-carousel-react/esm/embla-carousel-react.esm.js +37 -0
- package/dist/node_modules/embla-carousel-reactive-utils/esm/embla-carousel-reactive-utils.esm.js +38 -0
- package/dist/node_modules/get-nonce/dist/es2015/index.js +8 -0
- package/dist/node_modules/input-otp/dist/index.js +24 -0
- package/dist/node_modules/react-day-picker/dist/esm/DayPicker.js +285 -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 +30 -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 +522 -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 +18 -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 +25 -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 +51 -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 +28 -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 +39 -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 +24 -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 +38 -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 +24 -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 +15 -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/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 +175 -0
- package/dist/node_modules/react-day-picker/dist/esm/useCalendar.js +85 -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 +50 -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 +92 -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/typeguards.js +66 -0
- package/dist/node_modules/react-hook-form/dist/index.esm.js +507 -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 +160 -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-resizable-panels/dist/react-resizable-panels.js +2407 -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/sonner/dist/index.js +1125 -0
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +2956 -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/node_modules/vaul/dist/index.js +1627 -0
- package/dist/styles.css +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { composeEventHandlers } from '../../primitive/dist/index.js';
|
|
3
|
+
import { useComposedRefs } from '../../react-compose-refs/dist/index.js';
|
|
4
|
+
import { createContextScope, createContext as createContext2 } from '../../react-context/dist/index.js';
|
|
5
|
+
import { useId } from '../../react-id/dist/index.js';
|
|
6
|
+
import { useControllableState } from '../../react-use-controllable-state/dist/index.js';
|
|
7
|
+
import { DismissableLayer } from '../../react-dismissable-layer/dist/index.js';
|
|
8
|
+
import { FocusScope } from '../../react-focus-scope/dist/index.js';
|
|
9
|
+
import { Portal as Portal$1 } from '../../react-portal/dist/index.js';
|
|
10
|
+
import { Presence } from '../../react-presence/dist/index.js';
|
|
11
|
+
import { Primitive } from '../../react-primitive/dist/index.js';
|
|
12
|
+
import { useFocusGuards } from '../../react-focus-guards/dist/index.js';
|
|
13
|
+
import ReactRemoveScroll from '../../../react-remove-scroll/dist/es2015/Combination.js';
|
|
14
|
+
import { hideOthers } from '../../../aria-hidden/dist/es2015/index.js';
|
|
15
|
+
import { createSlot } from '../../react-slot/dist/index.js';
|
|
16
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
17
|
+
|
|
18
|
+
var DIALOG_NAME = "Dialog";
|
|
19
|
+
var [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);
|
|
20
|
+
var [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME);
|
|
21
|
+
var Dialog = (props) => {
|
|
22
|
+
const {
|
|
23
|
+
__scopeDialog,
|
|
24
|
+
children,
|
|
25
|
+
open: openProp,
|
|
26
|
+
defaultOpen,
|
|
27
|
+
onOpenChange,
|
|
28
|
+
modal = true
|
|
29
|
+
} = props;
|
|
30
|
+
const triggerRef = React.useRef(null);
|
|
31
|
+
const contentRef = React.useRef(null);
|
|
32
|
+
const [open, setOpen] = useControllableState({
|
|
33
|
+
prop: openProp,
|
|
34
|
+
defaultProp: defaultOpen ?? false,
|
|
35
|
+
onChange: onOpenChange,
|
|
36
|
+
caller: DIALOG_NAME
|
|
37
|
+
});
|
|
38
|
+
return /* @__PURE__ */ jsx(
|
|
39
|
+
DialogProvider,
|
|
40
|
+
{
|
|
41
|
+
scope: __scopeDialog,
|
|
42
|
+
triggerRef,
|
|
43
|
+
contentRef,
|
|
44
|
+
contentId: useId(),
|
|
45
|
+
titleId: useId(),
|
|
46
|
+
descriptionId: useId(),
|
|
47
|
+
open,
|
|
48
|
+
onOpenChange: setOpen,
|
|
49
|
+
onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
50
|
+
modal,
|
|
51
|
+
children
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
Dialog.displayName = DIALOG_NAME;
|
|
56
|
+
var TRIGGER_NAME = "DialogTrigger";
|
|
57
|
+
var DialogTrigger = React.forwardRef(
|
|
58
|
+
(props, forwardedRef) => {
|
|
59
|
+
const { __scopeDialog, ...triggerProps } = props;
|
|
60
|
+
const context = useDialogContext(TRIGGER_NAME, __scopeDialog);
|
|
61
|
+
const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
|
|
62
|
+
return /* @__PURE__ */ jsx(
|
|
63
|
+
Primitive.button,
|
|
64
|
+
{
|
|
65
|
+
type: "button",
|
|
66
|
+
"aria-haspopup": "dialog",
|
|
67
|
+
"aria-expanded": context.open,
|
|
68
|
+
"aria-controls": context.contentId,
|
|
69
|
+
"data-state": getState(context.open),
|
|
70
|
+
...triggerProps,
|
|
71
|
+
ref: composedTriggerRef,
|
|
72
|
+
onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
DialogTrigger.displayName = TRIGGER_NAME;
|
|
78
|
+
var PORTAL_NAME = "DialogPortal";
|
|
79
|
+
var [PortalProvider, usePortalContext] = createDialogContext(PORTAL_NAME, {
|
|
80
|
+
forceMount: void 0
|
|
81
|
+
});
|
|
82
|
+
var DialogPortal = (props) => {
|
|
83
|
+
const { __scopeDialog, forceMount, children, container } = props;
|
|
84
|
+
const context = useDialogContext(PORTAL_NAME, __scopeDialog);
|
|
85
|
+
return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopeDialog, forceMount, children: React.Children.map(children, (child) => /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Portal$1, { asChild: true, container, children: child }) })) });
|
|
86
|
+
};
|
|
87
|
+
DialogPortal.displayName = PORTAL_NAME;
|
|
88
|
+
var OVERLAY_NAME = "DialogOverlay";
|
|
89
|
+
var DialogOverlay = React.forwardRef(
|
|
90
|
+
(props, forwardedRef) => {
|
|
91
|
+
const portalContext = usePortalContext(OVERLAY_NAME, props.__scopeDialog);
|
|
92
|
+
const { forceMount = portalContext.forceMount, ...overlayProps } = props;
|
|
93
|
+
const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);
|
|
94
|
+
return context.modal ? /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(DialogOverlayImpl, { ...overlayProps, ref: forwardedRef }) }) : null;
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
DialogOverlay.displayName = OVERLAY_NAME;
|
|
98
|
+
var Slot = createSlot("DialogOverlay.RemoveScroll");
|
|
99
|
+
var DialogOverlayImpl = React.forwardRef(
|
|
100
|
+
(props, forwardedRef) => {
|
|
101
|
+
const { __scopeDialog, ...overlayProps } = props;
|
|
102
|
+
const context = useDialogContext(OVERLAY_NAME, __scopeDialog);
|
|
103
|
+
return (
|
|
104
|
+
// Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
|
|
105
|
+
// ie. when `Overlay` and `Content` are siblings
|
|
106
|
+
/* @__PURE__ */ jsx(ReactRemoveScroll, { as: Slot, allowPinchZoom: true, shards: [context.contentRef], children: /* @__PURE__ */ jsx(
|
|
107
|
+
Primitive.div,
|
|
108
|
+
{
|
|
109
|
+
"data-state": getState(context.open),
|
|
110
|
+
...overlayProps,
|
|
111
|
+
ref: forwardedRef,
|
|
112
|
+
style: { pointerEvents: "auto", ...overlayProps.style }
|
|
113
|
+
}
|
|
114
|
+
) })
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
var CONTENT_NAME = "DialogContent";
|
|
119
|
+
var DialogContent = React.forwardRef(
|
|
120
|
+
(props, forwardedRef) => {
|
|
121
|
+
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeDialog);
|
|
122
|
+
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
|
123
|
+
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
124
|
+
return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ jsx(DialogContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(DialogContentNonModal, { ...contentProps, ref: forwardedRef }) });
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
DialogContent.displayName = CONTENT_NAME;
|
|
128
|
+
var DialogContentModal = React.forwardRef(
|
|
129
|
+
(props, forwardedRef) => {
|
|
130
|
+
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
131
|
+
const contentRef = React.useRef(null);
|
|
132
|
+
const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);
|
|
133
|
+
React.useEffect(() => {
|
|
134
|
+
const content = contentRef.current;
|
|
135
|
+
if (content) return hideOthers(content);
|
|
136
|
+
}, []);
|
|
137
|
+
return /* @__PURE__ */ jsx(
|
|
138
|
+
DialogContentImpl,
|
|
139
|
+
{
|
|
140
|
+
...props,
|
|
141
|
+
ref: composedRefs,
|
|
142
|
+
trapFocus: context.open,
|
|
143
|
+
disableOutsidePointerEvents: true,
|
|
144
|
+
onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
|
|
145
|
+
event.preventDefault();
|
|
146
|
+
context.triggerRef.current?.focus();
|
|
147
|
+
}),
|
|
148
|
+
onPointerDownOutside: composeEventHandlers(props.onPointerDownOutside, (event) => {
|
|
149
|
+
const originalEvent = event.detail.originalEvent;
|
|
150
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
151
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
152
|
+
if (isRightClick) event.preventDefault();
|
|
153
|
+
}),
|
|
154
|
+
onFocusOutside: composeEventHandlers(
|
|
155
|
+
props.onFocusOutside,
|
|
156
|
+
(event) => event.preventDefault()
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
var DialogContentNonModal = React.forwardRef(
|
|
163
|
+
(props, forwardedRef) => {
|
|
164
|
+
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
165
|
+
const hasInteractedOutsideRef = React.useRef(false);
|
|
166
|
+
const hasPointerDownOutsideRef = React.useRef(false);
|
|
167
|
+
return /* @__PURE__ */ jsx(
|
|
168
|
+
DialogContentImpl,
|
|
169
|
+
{
|
|
170
|
+
...props,
|
|
171
|
+
ref: forwardedRef,
|
|
172
|
+
trapFocus: false,
|
|
173
|
+
disableOutsidePointerEvents: false,
|
|
174
|
+
onCloseAutoFocus: (event) => {
|
|
175
|
+
props.onCloseAutoFocus?.(event);
|
|
176
|
+
if (!event.defaultPrevented) {
|
|
177
|
+
if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
}
|
|
180
|
+
hasInteractedOutsideRef.current = false;
|
|
181
|
+
hasPointerDownOutsideRef.current = false;
|
|
182
|
+
},
|
|
183
|
+
onInteractOutside: (event) => {
|
|
184
|
+
props.onInteractOutside?.(event);
|
|
185
|
+
if (!event.defaultPrevented) {
|
|
186
|
+
hasInteractedOutsideRef.current = true;
|
|
187
|
+
if (event.detail.originalEvent.type === "pointerdown") {
|
|
188
|
+
hasPointerDownOutsideRef.current = true;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const target = event.target;
|
|
192
|
+
const targetIsTrigger = context.triggerRef.current?.contains(target);
|
|
193
|
+
if (targetIsTrigger) event.preventDefault();
|
|
194
|
+
if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
|
|
195
|
+
event.preventDefault();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
var DialogContentImpl = React.forwardRef(
|
|
203
|
+
(props, forwardedRef) => {
|
|
204
|
+
const { __scopeDialog, trapFocus, onOpenAutoFocus, onCloseAutoFocus, ...contentProps } = props;
|
|
205
|
+
const context = useDialogContext(CONTENT_NAME, __scopeDialog);
|
|
206
|
+
const contentRef = React.useRef(null);
|
|
207
|
+
const composedRefs = useComposedRefs(forwardedRef, contentRef);
|
|
208
|
+
useFocusGuards();
|
|
209
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
210
|
+
/* @__PURE__ */ jsx(
|
|
211
|
+
FocusScope,
|
|
212
|
+
{
|
|
213
|
+
asChild: true,
|
|
214
|
+
loop: true,
|
|
215
|
+
trapped: trapFocus,
|
|
216
|
+
onMountAutoFocus: onOpenAutoFocus,
|
|
217
|
+
onUnmountAutoFocus: onCloseAutoFocus,
|
|
218
|
+
children: /* @__PURE__ */ jsx(
|
|
219
|
+
DismissableLayer,
|
|
220
|
+
{
|
|
221
|
+
role: "dialog",
|
|
222
|
+
id: context.contentId,
|
|
223
|
+
"aria-describedby": context.descriptionId,
|
|
224
|
+
"aria-labelledby": context.titleId,
|
|
225
|
+
"data-state": getState(context.open),
|
|
226
|
+
...contentProps,
|
|
227
|
+
ref: composedRefs,
|
|
228
|
+
onDismiss: () => context.onOpenChange(false)
|
|
229
|
+
}
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
),
|
|
233
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
234
|
+
/* @__PURE__ */ jsx(TitleWarning, { titleId: context.titleId }),
|
|
235
|
+
/* @__PURE__ */ jsx(DescriptionWarning, { contentRef, descriptionId: context.descriptionId })
|
|
236
|
+
] })
|
|
237
|
+
] });
|
|
238
|
+
}
|
|
239
|
+
);
|
|
240
|
+
var TITLE_NAME = "DialogTitle";
|
|
241
|
+
var DialogTitle = React.forwardRef(
|
|
242
|
+
(props, forwardedRef) => {
|
|
243
|
+
const { __scopeDialog, ...titleProps } = props;
|
|
244
|
+
const context = useDialogContext(TITLE_NAME, __scopeDialog);
|
|
245
|
+
return /* @__PURE__ */ jsx(Primitive.h2, { id: context.titleId, ...titleProps, ref: forwardedRef });
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
DialogTitle.displayName = TITLE_NAME;
|
|
249
|
+
var DESCRIPTION_NAME = "DialogDescription";
|
|
250
|
+
var DialogDescription = React.forwardRef(
|
|
251
|
+
(props, forwardedRef) => {
|
|
252
|
+
const { __scopeDialog, ...descriptionProps } = props;
|
|
253
|
+
const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
|
|
254
|
+
return /* @__PURE__ */ jsx(Primitive.p, { id: context.descriptionId, ...descriptionProps, ref: forwardedRef });
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
DialogDescription.displayName = DESCRIPTION_NAME;
|
|
258
|
+
var CLOSE_NAME = "DialogClose";
|
|
259
|
+
var DialogClose = React.forwardRef(
|
|
260
|
+
(props, forwardedRef) => {
|
|
261
|
+
const { __scopeDialog, ...closeProps } = props;
|
|
262
|
+
const context = useDialogContext(CLOSE_NAME, __scopeDialog);
|
|
263
|
+
return /* @__PURE__ */ jsx(
|
|
264
|
+
Primitive.button,
|
|
265
|
+
{
|
|
266
|
+
type: "button",
|
|
267
|
+
...closeProps,
|
|
268
|
+
ref: forwardedRef,
|
|
269
|
+
onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false))
|
|
270
|
+
}
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
);
|
|
274
|
+
DialogClose.displayName = CLOSE_NAME;
|
|
275
|
+
function getState(open) {
|
|
276
|
+
return open ? "open" : "closed";
|
|
277
|
+
}
|
|
278
|
+
var TITLE_WARNING_NAME = "DialogTitleWarning";
|
|
279
|
+
var [WarningProvider, useWarningContext] = createContext2(TITLE_WARNING_NAME, {
|
|
280
|
+
contentName: CONTENT_NAME,
|
|
281
|
+
titleName: TITLE_NAME,
|
|
282
|
+
docsSlug: "dialog"
|
|
283
|
+
});
|
|
284
|
+
var TitleWarning = ({ titleId }) => {
|
|
285
|
+
const titleWarningContext = useWarningContext(TITLE_WARNING_NAME);
|
|
286
|
+
const MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users.
|
|
287
|
+
|
|
288
|
+
If you want to hide the \`${titleWarningContext.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
289
|
+
|
|
290
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${titleWarningContext.docsSlug}`;
|
|
291
|
+
React.useEffect(() => {
|
|
292
|
+
if (titleId) {
|
|
293
|
+
const hasTitle = document.getElementById(titleId);
|
|
294
|
+
if (!hasTitle) console.error(MESSAGE);
|
|
295
|
+
}
|
|
296
|
+
}, [MESSAGE, titleId]);
|
|
297
|
+
return null;
|
|
298
|
+
};
|
|
299
|
+
var DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning";
|
|
300
|
+
var DescriptionWarning = ({ contentRef, descriptionId }) => {
|
|
301
|
+
const descriptionWarningContext = useWarningContext(DESCRIPTION_WARNING_NAME);
|
|
302
|
+
const MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${descriptionWarningContext.contentName}}.`;
|
|
303
|
+
React.useEffect(() => {
|
|
304
|
+
const describedById = contentRef.current?.getAttribute("aria-describedby");
|
|
305
|
+
if (descriptionId && describedById) {
|
|
306
|
+
const hasDescription = document.getElementById(descriptionId);
|
|
307
|
+
if (!hasDescription) console.warn(MESSAGE);
|
|
308
|
+
}
|
|
309
|
+
}, [MESSAGE, contentRef, descriptionId]);
|
|
310
|
+
return null;
|
|
311
|
+
};
|
|
312
|
+
var Root = Dialog;
|
|
313
|
+
var Trigger = DialogTrigger;
|
|
314
|
+
var Portal = DialogPortal;
|
|
315
|
+
var Overlay = DialogOverlay;
|
|
316
|
+
var Content = DialogContent;
|
|
317
|
+
var Title = DialogTitle;
|
|
318
|
+
var Description = DialogDescription;
|
|
319
|
+
var Close = DialogClose;
|
|
320
|
+
|
|
321
|
+
export { Close, Content, Description, Dialog, DialogClose, DialogContent, DialogDescription, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Overlay, Portal, Root, Title, Trigger, WarningProvider, createDialogScope };
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { composeEventHandlers } from '../../primitive/dist/index.js';
|
|
3
|
+
import { Primitive, dispatchDiscreteCustomEvent } from '../../react-primitive/dist/index.js';
|
|
4
|
+
import { useComposedRefs } from '../../react-compose-refs/dist/index.js';
|
|
5
|
+
import { useCallbackRef } from '../../react-use-callback-ref/dist/index.js';
|
|
6
|
+
import { useEscapeKeydown } from '../../react-use-escape-keydown/dist/index.js';
|
|
7
|
+
import { jsx } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
var DISMISSABLE_LAYER_NAME = "DismissableLayer";
|
|
10
|
+
var CONTEXT_UPDATE = "dismissableLayer.update";
|
|
11
|
+
var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
|
|
12
|
+
var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
|
|
13
|
+
var originalBodyPointerEvents;
|
|
14
|
+
var DismissableLayerContext = React.createContext({
|
|
15
|
+
layers: /* @__PURE__ */ new Set(),
|
|
16
|
+
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
|
|
17
|
+
branches: /* @__PURE__ */ new Set()
|
|
18
|
+
});
|
|
19
|
+
var DismissableLayer = React.forwardRef(
|
|
20
|
+
(props, forwardedRef) => {
|
|
21
|
+
const {
|
|
22
|
+
disableOutsidePointerEvents = false,
|
|
23
|
+
onEscapeKeyDown,
|
|
24
|
+
onPointerDownOutside,
|
|
25
|
+
onFocusOutside,
|
|
26
|
+
onInteractOutside,
|
|
27
|
+
onDismiss,
|
|
28
|
+
...layerProps
|
|
29
|
+
} = props;
|
|
30
|
+
const context = React.useContext(DismissableLayerContext);
|
|
31
|
+
const [node, setNode] = React.useState(null);
|
|
32
|
+
const ownerDocument = node?.ownerDocument ?? globalThis?.document;
|
|
33
|
+
const [, force] = React.useState({});
|
|
34
|
+
const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
|
|
35
|
+
const layers = Array.from(context.layers);
|
|
36
|
+
const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
|
|
37
|
+
const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
|
|
38
|
+
const index = node ? layers.indexOf(node) : -1;
|
|
39
|
+
const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
|
|
40
|
+
const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
|
|
41
|
+
const pointerDownOutside = usePointerDownOutside((event) => {
|
|
42
|
+
const target = event.target;
|
|
43
|
+
const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
|
|
44
|
+
if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
|
|
45
|
+
onPointerDownOutside?.(event);
|
|
46
|
+
onInteractOutside?.(event);
|
|
47
|
+
if (!event.defaultPrevented) onDismiss?.();
|
|
48
|
+
}, ownerDocument);
|
|
49
|
+
const focusOutside = useFocusOutside((event) => {
|
|
50
|
+
const target = event.target;
|
|
51
|
+
const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
|
|
52
|
+
if (isFocusInBranch) return;
|
|
53
|
+
onFocusOutside?.(event);
|
|
54
|
+
onInteractOutside?.(event);
|
|
55
|
+
if (!event.defaultPrevented) onDismiss?.();
|
|
56
|
+
}, ownerDocument);
|
|
57
|
+
useEscapeKeydown((event) => {
|
|
58
|
+
const isHighestLayer = index === context.layers.size - 1;
|
|
59
|
+
if (!isHighestLayer) return;
|
|
60
|
+
onEscapeKeyDown?.(event);
|
|
61
|
+
if (!event.defaultPrevented && onDismiss) {
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
onDismiss();
|
|
64
|
+
}
|
|
65
|
+
}, ownerDocument);
|
|
66
|
+
React.useEffect(() => {
|
|
67
|
+
if (!node) return;
|
|
68
|
+
if (disableOutsidePointerEvents) {
|
|
69
|
+
if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
|
|
70
|
+
originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
|
|
71
|
+
ownerDocument.body.style.pointerEvents = "none";
|
|
72
|
+
}
|
|
73
|
+
context.layersWithOutsidePointerEventsDisabled.add(node);
|
|
74
|
+
}
|
|
75
|
+
context.layers.add(node);
|
|
76
|
+
dispatchUpdate();
|
|
77
|
+
return () => {
|
|
78
|
+
if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
|
|
79
|
+
ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}, [node, ownerDocument, disableOutsidePointerEvents, context]);
|
|
83
|
+
React.useEffect(() => {
|
|
84
|
+
return () => {
|
|
85
|
+
if (!node) return;
|
|
86
|
+
context.layers.delete(node);
|
|
87
|
+
context.layersWithOutsidePointerEventsDisabled.delete(node);
|
|
88
|
+
dispatchUpdate();
|
|
89
|
+
};
|
|
90
|
+
}, [node, context]);
|
|
91
|
+
React.useEffect(() => {
|
|
92
|
+
const handleUpdate = () => force({});
|
|
93
|
+
document.addEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
94
|
+
return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
95
|
+
}, []);
|
|
96
|
+
return /* @__PURE__ */ jsx(
|
|
97
|
+
Primitive.div,
|
|
98
|
+
{
|
|
99
|
+
...layerProps,
|
|
100
|
+
ref: composedRefs,
|
|
101
|
+
style: {
|
|
102
|
+
pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
|
|
103
|
+
...props.style
|
|
104
|
+
},
|
|
105
|
+
onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
|
|
106
|
+
onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
|
|
107
|
+
onPointerDownCapture: composeEventHandlers(
|
|
108
|
+
props.onPointerDownCapture,
|
|
109
|
+
pointerDownOutside.onPointerDownCapture
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
|
|
116
|
+
var BRANCH_NAME = "DismissableLayerBranch";
|
|
117
|
+
var DismissableLayerBranch = React.forwardRef((props, forwardedRef) => {
|
|
118
|
+
const context = React.useContext(DismissableLayerContext);
|
|
119
|
+
const ref = React.useRef(null);
|
|
120
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
121
|
+
React.useEffect(() => {
|
|
122
|
+
const node = ref.current;
|
|
123
|
+
if (node) {
|
|
124
|
+
context.branches.add(node);
|
|
125
|
+
return () => {
|
|
126
|
+
context.branches.delete(node);
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}, [context.branches]);
|
|
130
|
+
return /* @__PURE__ */ jsx(Primitive.div, { ...props, ref: composedRefs });
|
|
131
|
+
});
|
|
132
|
+
DismissableLayerBranch.displayName = BRANCH_NAME;
|
|
133
|
+
function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) {
|
|
134
|
+
const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);
|
|
135
|
+
const isPointerInsideReactTreeRef = React.useRef(false);
|
|
136
|
+
const handleClickRef = React.useRef(() => {
|
|
137
|
+
});
|
|
138
|
+
React.useEffect(() => {
|
|
139
|
+
const handlePointerDown = (event) => {
|
|
140
|
+
if (event.target && !isPointerInsideReactTreeRef.current) {
|
|
141
|
+
let handleAndDispatchPointerDownOutsideEvent2 = function() {
|
|
142
|
+
handleAndDispatchCustomEvent(
|
|
143
|
+
POINTER_DOWN_OUTSIDE,
|
|
144
|
+
handlePointerDownOutside,
|
|
145
|
+
eventDetail,
|
|
146
|
+
{ discrete: true }
|
|
147
|
+
);
|
|
148
|
+
};
|
|
149
|
+
const eventDetail = { originalEvent: event };
|
|
150
|
+
if (event.pointerType === "touch") {
|
|
151
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
152
|
+
handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
|
|
153
|
+
ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
|
|
154
|
+
} else {
|
|
155
|
+
handleAndDispatchPointerDownOutsideEvent2();
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
159
|
+
}
|
|
160
|
+
isPointerInsideReactTreeRef.current = false;
|
|
161
|
+
};
|
|
162
|
+
const timerId = window.setTimeout(() => {
|
|
163
|
+
ownerDocument.addEventListener("pointerdown", handlePointerDown);
|
|
164
|
+
}, 0);
|
|
165
|
+
return () => {
|
|
166
|
+
window.clearTimeout(timerId);
|
|
167
|
+
ownerDocument.removeEventListener("pointerdown", handlePointerDown);
|
|
168
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
169
|
+
};
|
|
170
|
+
}, [ownerDocument, handlePointerDownOutside]);
|
|
171
|
+
return {
|
|
172
|
+
// ensures we check React component tree (not just DOM tree)
|
|
173
|
+
onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {
|
|
177
|
+
const handleFocusOutside = useCallbackRef(onFocusOutside);
|
|
178
|
+
const isFocusInsideReactTreeRef = React.useRef(false);
|
|
179
|
+
React.useEffect(() => {
|
|
180
|
+
const handleFocus = (event) => {
|
|
181
|
+
if (event.target && !isFocusInsideReactTreeRef.current) {
|
|
182
|
+
const eventDetail = { originalEvent: event };
|
|
183
|
+
handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
|
|
184
|
+
discrete: false
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
ownerDocument.addEventListener("focusin", handleFocus);
|
|
189
|
+
return () => ownerDocument.removeEventListener("focusin", handleFocus);
|
|
190
|
+
}, [ownerDocument, handleFocusOutside]);
|
|
191
|
+
return {
|
|
192
|
+
onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
|
|
193
|
+
onBlurCapture: () => isFocusInsideReactTreeRef.current = false
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function dispatchUpdate() {
|
|
197
|
+
const event = new CustomEvent(CONTEXT_UPDATE);
|
|
198
|
+
document.dispatchEvent(event);
|
|
199
|
+
}
|
|
200
|
+
function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
201
|
+
const target = detail.originalEvent.target;
|
|
202
|
+
const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
|
|
203
|
+
if (handler) target.addEventListener(name, handler, { once: true });
|
|
204
|
+
if (discrete) {
|
|
205
|
+
dispatchDiscreteCustomEvent(target, event);
|
|
206
|
+
} else {
|
|
207
|
+
target.dispatchEvent(event);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export { DismissableLayer, DismissableLayerBranch };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
var count = 0;
|
|
4
|
+
function useFocusGuards() {
|
|
5
|
+
React.useEffect(() => {
|
|
6
|
+
const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]");
|
|
7
|
+
document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard());
|
|
8
|
+
document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard());
|
|
9
|
+
count++;
|
|
10
|
+
return () => {
|
|
11
|
+
if (count === 1) {
|
|
12
|
+
document.querySelectorAll("[data-radix-focus-guard]").forEach((node) => node.remove());
|
|
13
|
+
}
|
|
14
|
+
count--;
|
|
15
|
+
};
|
|
16
|
+
}, []);
|
|
17
|
+
}
|
|
18
|
+
function createFocusGuard() {
|
|
19
|
+
const element = document.createElement("span");
|
|
20
|
+
element.setAttribute("data-radix-focus-guard", "");
|
|
21
|
+
element.tabIndex = 0;
|
|
22
|
+
element.style.outline = "none";
|
|
23
|
+
element.style.opacity = "0";
|
|
24
|
+
element.style.position = "fixed";
|
|
25
|
+
element.style.pointerEvents = "none";
|
|
26
|
+
return element;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { useFocusGuards };
|