@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,207 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useComposedRefs } from '../../react-compose-refs/dist/index.js';
|
|
3
|
+
import { Primitive } from '../../react-primitive/dist/index.js';
|
|
4
|
+
import { useCallbackRef } from '../../react-use-callback-ref/dist/index.js';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount";
|
|
8
|
+
var AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount";
|
|
9
|
+
var EVENT_OPTIONS = { bubbles: false, cancelable: true };
|
|
10
|
+
var FOCUS_SCOPE_NAME = "FocusScope";
|
|
11
|
+
var FocusScope = React.forwardRef((props, forwardedRef) => {
|
|
12
|
+
const {
|
|
13
|
+
loop = false,
|
|
14
|
+
trapped = false,
|
|
15
|
+
onMountAutoFocus: onMountAutoFocusProp,
|
|
16
|
+
onUnmountAutoFocus: onUnmountAutoFocusProp,
|
|
17
|
+
...scopeProps
|
|
18
|
+
} = props;
|
|
19
|
+
const [container, setContainer] = React.useState(null);
|
|
20
|
+
const onMountAutoFocus = useCallbackRef(onMountAutoFocusProp);
|
|
21
|
+
const onUnmountAutoFocus = useCallbackRef(onUnmountAutoFocusProp);
|
|
22
|
+
const lastFocusedElementRef = React.useRef(null);
|
|
23
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node));
|
|
24
|
+
const focusScope = React.useRef({
|
|
25
|
+
paused: false,
|
|
26
|
+
pause() {
|
|
27
|
+
this.paused = true;
|
|
28
|
+
},
|
|
29
|
+
resume() {
|
|
30
|
+
this.paused = false;
|
|
31
|
+
}
|
|
32
|
+
}).current;
|
|
33
|
+
React.useEffect(() => {
|
|
34
|
+
if (trapped) {
|
|
35
|
+
let handleFocusIn2 = function(event) {
|
|
36
|
+
if (focusScope.paused || !container) return;
|
|
37
|
+
const target = event.target;
|
|
38
|
+
if (container.contains(target)) {
|
|
39
|
+
lastFocusedElementRef.current = target;
|
|
40
|
+
} else {
|
|
41
|
+
focus(lastFocusedElementRef.current, { select: true });
|
|
42
|
+
}
|
|
43
|
+
}, handleFocusOut2 = function(event) {
|
|
44
|
+
if (focusScope.paused || !container) return;
|
|
45
|
+
const relatedTarget = event.relatedTarget;
|
|
46
|
+
if (relatedTarget === null) return;
|
|
47
|
+
if (!container.contains(relatedTarget)) {
|
|
48
|
+
focus(lastFocusedElementRef.current, { select: true });
|
|
49
|
+
}
|
|
50
|
+
}, handleMutations2 = function(mutations) {
|
|
51
|
+
const focusedElement = document.activeElement;
|
|
52
|
+
if (focusedElement !== document.body) return;
|
|
53
|
+
for (const mutation of mutations) {
|
|
54
|
+
if (mutation.removedNodes.length > 0) focus(container);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
document.addEventListener("focusin", handleFocusIn2);
|
|
58
|
+
document.addEventListener("focusout", handleFocusOut2);
|
|
59
|
+
const mutationObserver = new MutationObserver(handleMutations2);
|
|
60
|
+
if (container) mutationObserver.observe(container, { childList: true, subtree: true });
|
|
61
|
+
return () => {
|
|
62
|
+
document.removeEventListener("focusin", handleFocusIn2);
|
|
63
|
+
document.removeEventListener("focusout", handleFocusOut2);
|
|
64
|
+
mutationObserver.disconnect();
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}, [trapped, container, focusScope.paused]);
|
|
68
|
+
React.useEffect(() => {
|
|
69
|
+
if (container) {
|
|
70
|
+
focusScopesStack.add(focusScope);
|
|
71
|
+
const previouslyFocusedElement = document.activeElement;
|
|
72
|
+
const hasFocusedCandidate = container.contains(previouslyFocusedElement);
|
|
73
|
+
if (!hasFocusedCandidate) {
|
|
74
|
+
const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
|
|
75
|
+
container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
76
|
+
container.dispatchEvent(mountEvent);
|
|
77
|
+
if (!mountEvent.defaultPrevented) {
|
|
78
|
+
focusFirst(removeLinks(getTabbableCandidates(container)), { select: true });
|
|
79
|
+
if (document.activeElement === previouslyFocusedElement) {
|
|
80
|
+
focus(container);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return () => {
|
|
85
|
+
container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
86
|
+
setTimeout(() => {
|
|
87
|
+
const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
|
|
88
|
+
container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
89
|
+
container.dispatchEvent(unmountEvent);
|
|
90
|
+
if (!unmountEvent.defaultPrevented) {
|
|
91
|
+
focus(previouslyFocusedElement ?? document.body, { select: true });
|
|
92
|
+
}
|
|
93
|
+
container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
94
|
+
focusScopesStack.remove(focusScope);
|
|
95
|
+
}, 0);
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}, [container, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
|
|
99
|
+
const handleKeyDown = React.useCallback(
|
|
100
|
+
(event) => {
|
|
101
|
+
if (!loop && !trapped) return;
|
|
102
|
+
if (focusScope.paused) return;
|
|
103
|
+
const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
104
|
+
const focusedElement = document.activeElement;
|
|
105
|
+
if (isTabKey && focusedElement) {
|
|
106
|
+
const container2 = event.currentTarget;
|
|
107
|
+
const [first, last] = getTabbableEdges(container2);
|
|
108
|
+
const hasTabbableElementsInside = first && last;
|
|
109
|
+
if (!hasTabbableElementsInside) {
|
|
110
|
+
if (focusedElement === container2) event.preventDefault();
|
|
111
|
+
} else {
|
|
112
|
+
if (!event.shiftKey && focusedElement === last) {
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
if (loop) focus(first, { select: true });
|
|
115
|
+
} else if (event.shiftKey && focusedElement === first) {
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
if (loop) focus(last, { select: true });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
[loop, trapped, focusScope.paused]
|
|
123
|
+
);
|
|
124
|
+
return /* @__PURE__ */ jsx(Primitive.div, { tabIndex: -1, ...scopeProps, ref: composedRefs, onKeyDown: handleKeyDown });
|
|
125
|
+
});
|
|
126
|
+
FocusScope.displayName = FOCUS_SCOPE_NAME;
|
|
127
|
+
function focusFirst(candidates, { select = false } = {}) {
|
|
128
|
+
const previouslyFocusedElement = document.activeElement;
|
|
129
|
+
for (const candidate of candidates) {
|
|
130
|
+
focus(candidate, { select });
|
|
131
|
+
if (document.activeElement !== previouslyFocusedElement) return;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function getTabbableEdges(container) {
|
|
135
|
+
const candidates = getTabbableCandidates(container);
|
|
136
|
+
const first = findVisible(candidates, container);
|
|
137
|
+
const last = findVisible(candidates.reverse(), container);
|
|
138
|
+
return [first, last];
|
|
139
|
+
}
|
|
140
|
+
function getTabbableCandidates(container) {
|
|
141
|
+
const nodes = [];
|
|
142
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
143
|
+
acceptNode: (node) => {
|
|
144
|
+
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
145
|
+
if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
|
|
146
|
+
return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
while (walker.nextNode()) nodes.push(walker.currentNode);
|
|
150
|
+
return nodes;
|
|
151
|
+
}
|
|
152
|
+
function findVisible(elements, container) {
|
|
153
|
+
for (const element of elements) {
|
|
154
|
+
if (!isHidden(element, { upTo: container })) return element;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function isHidden(node, { upTo }) {
|
|
158
|
+
if (getComputedStyle(node).visibility === "hidden") return true;
|
|
159
|
+
while (node) {
|
|
160
|
+
if (upTo !== void 0 && node === upTo) return false;
|
|
161
|
+
if (getComputedStyle(node).display === "none") return true;
|
|
162
|
+
node = node.parentElement;
|
|
163
|
+
}
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
function isSelectableInput(element) {
|
|
167
|
+
return element instanceof HTMLInputElement && "select" in element;
|
|
168
|
+
}
|
|
169
|
+
function focus(element, { select = false } = {}) {
|
|
170
|
+
if (element && element.focus) {
|
|
171
|
+
const previouslyFocusedElement = document.activeElement;
|
|
172
|
+
element.focus({ preventScroll: true });
|
|
173
|
+
if (element !== previouslyFocusedElement && isSelectableInput(element) && select)
|
|
174
|
+
element.select();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
var focusScopesStack = createFocusScopesStack();
|
|
178
|
+
function createFocusScopesStack() {
|
|
179
|
+
let stack = [];
|
|
180
|
+
return {
|
|
181
|
+
add(focusScope) {
|
|
182
|
+
const activeFocusScope = stack[0];
|
|
183
|
+
if (focusScope !== activeFocusScope) {
|
|
184
|
+
activeFocusScope?.pause();
|
|
185
|
+
}
|
|
186
|
+
stack = arrayRemove(stack, focusScope);
|
|
187
|
+
stack.unshift(focusScope);
|
|
188
|
+
},
|
|
189
|
+
remove(focusScope) {
|
|
190
|
+
stack = arrayRemove(stack, focusScope);
|
|
191
|
+
stack[0]?.resume();
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function arrayRemove(array, item) {
|
|
196
|
+
const updatedArray = [...array];
|
|
197
|
+
const index = updatedArray.indexOf(item);
|
|
198
|
+
if (index !== -1) {
|
|
199
|
+
updatedArray.splice(index, 1);
|
|
200
|
+
}
|
|
201
|
+
return updatedArray;
|
|
202
|
+
}
|
|
203
|
+
function removeLinks(items) {
|
|
204
|
+
return items.filter((item) => item.tagName !== "A");
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export { FocusScope };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useLayoutEffect as useLayoutEffect2 } from '../../react-use-layout-effect/dist/index.js';
|
|
3
|
+
|
|
4
|
+
// packages/react/id/src/id.tsx
|
|
5
|
+
var useReactId = React[" useId ".trim().toString()] || (() => void 0);
|
|
6
|
+
var count = 0;
|
|
7
|
+
function useId(deterministicId) {
|
|
8
|
+
const [id, setId] = React.useState(useReactId());
|
|
9
|
+
useLayoutEffect2(() => {
|
|
10
|
+
setId((reactId) => reactId ?? String(count++));
|
|
11
|
+
}, [deterministicId]);
|
|
12
|
+
return (id ? `radix-${id}` : "");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { useId };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import ReactDOM__default from 'react-dom';
|
|
3
|
+
import { Primitive } from '../../react-primitive/dist/index.js';
|
|
4
|
+
import { useLayoutEffect as useLayoutEffect2 } from '../../react-use-layout-effect/dist/index.js';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var PORTAL_NAME = "Portal";
|
|
8
|
+
var Portal = React.forwardRef((props, forwardedRef) => {
|
|
9
|
+
const { container: containerProp, ...portalProps } = props;
|
|
10
|
+
const [mounted, setMounted] = React.useState(false);
|
|
11
|
+
useLayoutEffect2(() => setMounted(true), []);
|
|
12
|
+
const container = containerProp || mounted && globalThis?.document?.body;
|
|
13
|
+
return container ? ReactDOM__default.createPortal(/* @__PURE__ */ jsx(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
|
|
14
|
+
});
|
|
15
|
+
Portal.displayName = PORTAL_NAME;
|
|
16
|
+
|
|
17
|
+
export { Portal };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useComposedRefs } from '../../react-compose-refs/dist/index.js';
|
|
3
|
+
import { useLayoutEffect as useLayoutEffect2 } from '../../react-use-layout-effect/dist/index.js';
|
|
4
|
+
|
|
5
|
+
function useStateMachine(initialState, machine) {
|
|
6
|
+
return React.useReducer((state, event) => {
|
|
7
|
+
const nextState = machine[state][event];
|
|
8
|
+
return nextState ?? state;
|
|
9
|
+
}, initialState);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// src/presence.tsx
|
|
13
|
+
var Presence = (props) => {
|
|
14
|
+
const { present, children } = props;
|
|
15
|
+
const presence = usePresence(present);
|
|
16
|
+
const child = typeof children === "function" ? children({ present: presence.isPresent }) : React.Children.only(children);
|
|
17
|
+
const ref = useComposedRefs(presence.ref, getElementRef(child));
|
|
18
|
+
const forceMount = typeof children === "function";
|
|
19
|
+
return forceMount || presence.isPresent ? React.cloneElement(child, { ref }) : null;
|
|
20
|
+
};
|
|
21
|
+
Presence.displayName = "Presence";
|
|
22
|
+
function usePresence(present) {
|
|
23
|
+
const [node, setNode] = React.useState();
|
|
24
|
+
const stylesRef = React.useRef(null);
|
|
25
|
+
const prevPresentRef = React.useRef(present);
|
|
26
|
+
const prevAnimationNameRef = React.useRef("none");
|
|
27
|
+
const initialState = present ? "mounted" : "unmounted";
|
|
28
|
+
const [state, send] = useStateMachine(initialState, {
|
|
29
|
+
mounted: {
|
|
30
|
+
UNMOUNT: "unmounted",
|
|
31
|
+
ANIMATION_OUT: "unmountSuspended"
|
|
32
|
+
},
|
|
33
|
+
unmountSuspended: {
|
|
34
|
+
MOUNT: "mounted",
|
|
35
|
+
ANIMATION_END: "unmounted"
|
|
36
|
+
},
|
|
37
|
+
unmounted: {
|
|
38
|
+
MOUNT: "mounted"
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
43
|
+
prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
|
|
44
|
+
}, [state]);
|
|
45
|
+
useLayoutEffect2(() => {
|
|
46
|
+
const styles = stylesRef.current;
|
|
47
|
+
const wasPresent = prevPresentRef.current;
|
|
48
|
+
const hasPresentChanged = wasPresent !== present;
|
|
49
|
+
if (hasPresentChanged) {
|
|
50
|
+
const prevAnimationName = prevAnimationNameRef.current;
|
|
51
|
+
const currentAnimationName = getAnimationName(styles);
|
|
52
|
+
if (present) {
|
|
53
|
+
send("MOUNT");
|
|
54
|
+
} else if (currentAnimationName === "none" || styles?.display === "none") {
|
|
55
|
+
send("UNMOUNT");
|
|
56
|
+
} else {
|
|
57
|
+
const isAnimating = prevAnimationName !== currentAnimationName;
|
|
58
|
+
if (wasPresent && isAnimating) {
|
|
59
|
+
send("ANIMATION_OUT");
|
|
60
|
+
} else {
|
|
61
|
+
send("UNMOUNT");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
prevPresentRef.current = present;
|
|
65
|
+
}
|
|
66
|
+
}, [present, send]);
|
|
67
|
+
useLayoutEffect2(() => {
|
|
68
|
+
if (node) {
|
|
69
|
+
let timeoutId;
|
|
70
|
+
const ownerWindow = node.ownerDocument.defaultView ?? window;
|
|
71
|
+
const handleAnimationEnd = (event) => {
|
|
72
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
73
|
+
const isCurrentAnimation = currentAnimationName.includes(event.animationName);
|
|
74
|
+
if (event.target === node && isCurrentAnimation) {
|
|
75
|
+
send("ANIMATION_END");
|
|
76
|
+
if (!prevPresentRef.current) {
|
|
77
|
+
const currentFillMode = node.style.animationFillMode;
|
|
78
|
+
node.style.animationFillMode = "forwards";
|
|
79
|
+
timeoutId = ownerWindow.setTimeout(() => {
|
|
80
|
+
if (node.style.animationFillMode === "forwards") {
|
|
81
|
+
node.style.animationFillMode = currentFillMode;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const handleAnimationStart = (event) => {
|
|
88
|
+
if (event.target === node) {
|
|
89
|
+
prevAnimationNameRef.current = getAnimationName(stylesRef.current);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
node.addEventListener("animationstart", handleAnimationStart);
|
|
93
|
+
node.addEventListener("animationcancel", handleAnimationEnd);
|
|
94
|
+
node.addEventListener("animationend", handleAnimationEnd);
|
|
95
|
+
return () => {
|
|
96
|
+
ownerWindow.clearTimeout(timeoutId);
|
|
97
|
+
node.removeEventListener("animationstart", handleAnimationStart);
|
|
98
|
+
node.removeEventListener("animationcancel", handleAnimationEnd);
|
|
99
|
+
node.removeEventListener("animationend", handleAnimationEnd);
|
|
100
|
+
};
|
|
101
|
+
} else {
|
|
102
|
+
send("ANIMATION_END");
|
|
103
|
+
}
|
|
104
|
+
}, [node, send]);
|
|
105
|
+
return {
|
|
106
|
+
isPresent: ["mounted", "unmountSuspended"].includes(state),
|
|
107
|
+
ref: React.useCallback((node2) => {
|
|
108
|
+
stylesRef.current = node2 ? getComputedStyle(node2) : null;
|
|
109
|
+
setNode(node2);
|
|
110
|
+
}, [])
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function getAnimationName(styles) {
|
|
114
|
+
return styles?.animationName || "none";
|
|
115
|
+
}
|
|
116
|
+
function getElementRef(element) {
|
|
117
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
118
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
119
|
+
if (mayWarn) {
|
|
120
|
+
return element.ref;
|
|
121
|
+
}
|
|
122
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
123
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
124
|
+
if (mayWarn) {
|
|
125
|
+
return element.props.ref;
|
|
126
|
+
}
|
|
127
|
+
return element.props.ref || element.ref;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export { Presence };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as ReactDOM from 'react-dom';
|
|
3
|
+
import { createSlot } from '../../react-slot/dist/index.js';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
// src/primitive.tsx
|
|
7
|
+
var NODES = [
|
|
8
|
+
"a",
|
|
9
|
+
"button",
|
|
10
|
+
"div",
|
|
11
|
+
"form",
|
|
12
|
+
"h2",
|
|
13
|
+
"h3",
|
|
14
|
+
"img",
|
|
15
|
+
"input",
|
|
16
|
+
"label",
|
|
17
|
+
"li",
|
|
18
|
+
"nav",
|
|
19
|
+
"ol",
|
|
20
|
+
"p",
|
|
21
|
+
"select",
|
|
22
|
+
"span",
|
|
23
|
+
"svg",
|
|
24
|
+
"ul"
|
|
25
|
+
];
|
|
26
|
+
var Primitive = NODES.reduce((primitive, node) => {
|
|
27
|
+
const Slot = createSlot(`Primitive.${node}`);
|
|
28
|
+
const Node = React.forwardRef((props, forwardedRef) => {
|
|
29
|
+
const { asChild, ...primitiveProps } = props;
|
|
30
|
+
const Comp = asChild ? Slot : node;
|
|
31
|
+
if (typeof window !== "undefined") {
|
|
32
|
+
window[Symbol.for("radix-ui")] = true;
|
|
33
|
+
}
|
|
34
|
+
return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });
|
|
35
|
+
});
|
|
36
|
+
Node.displayName = `Primitive.${node}`;
|
|
37
|
+
return { ...primitive, [node]: Node };
|
|
38
|
+
}, {});
|
|
39
|
+
function dispatchDiscreteCustomEvent(target, event) {
|
|
40
|
+
if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { Primitive, dispatchDiscreteCustomEvent };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { composeRefs } from '../../react-compose-refs/dist/index.js';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
// src/slot.tsx
|
|
6
|
+
// @__NO_SIDE_EFFECTS__
|
|
7
|
+
function createSlot(ownerName) {
|
|
8
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
9
|
+
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
10
|
+
const { children, ...slotProps } = props;
|
|
11
|
+
const childrenArray = React.Children.toArray(children);
|
|
12
|
+
const slottable = childrenArray.find(isSlottable);
|
|
13
|
+
if (slottable) {
|
|
14
|
+
const newElement = slottable.props.children;
|
|
15
|
+
const newChildren = childrenArray.map((child) => {
|
|
16
|
+
if (child === slottable) {
|
|
17
|
+
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
18
|
+
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
19
|
+
} else {
|
|
20
|
+
return child;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
24
|
+
}
|
|
25
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
26
|
+
});
|
|
27
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
28
|
+
return Slot2;
|
|
29
|
+
}
|
|
30
|
+
// @__NO_SIDE_EFFECTS__
|
|
31
|
+
function createSlotClone(ownerName) {
|
|
32
|
+
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
33
|
+
const { children, ...slotProps } = props;
|
|
34
|
+
if (React.isValidElement(children)) {
|
|
35
|
+
const childrenRef = getElementRef(children);
|
|
36
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
37
|
+
if (children.type !== React.Fragment) {
|
|
38
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
39
|
+
}
|
|
40
|
+
return React.cloneElement(children, props2);
|
|
41
|
+
}
|
|
42
|
+
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
43
|
+
});
|
|
44
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
45
|
+
return SlotClone;
|
|
46
|
+
}
|
|
47
|
+
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
48
|
+
function isSlottable(child) {
|
|
49
|
+
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
50
|
+
}
|
|
51
|
+
function mergeProps(slotProps, childProps) {
|
|
52
|
+
const overrideProps = { ...childProps };
|
|
53
|
+
for (const propName in childProps) {
|
|
54
|
+
const slotPropValue = slotProps[propName];
|
|
55
|
+
const childPropValue = childProps[propName];
|
|
56
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
57
|
+
if (isHandler) {
|
|
58
|
+
if (slotPropValue && childPropValue) {
|
|
59
|
+
overrideProps[propName] = (...args) => {
|
|
60
|
+
const result = childPropValue(...args);
|
|
61
|
+
slotPropValue(...args);
|
|
62
|
+
return result;
|
|
63
|
+
};
|
|
64
|
+
} else if (slotPropValue) {
|
|
65
|
+
overrideProps[propName] = slotPropValue;
|
|
66
|
+
}
|
|
67
|
+
} else if (propName === "style") {
|
|
68
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
69
|
+
} else if (propName === "className") {
|
|
70
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return { ...slotProps, ...overrideProps };
|
|
74
|
+
}
|
|
75
|
+
function getElementRef(element) {
|
|
76
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
77
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
78
|
+
if (mayWarn) {
|
|
79
|
+
return element.ref;
|
|
80
|
+
}
|
|
81
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
82
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
83
|
+
if (mayWarn) {
|
|
84
|
+
return element.props.ref;
|
|
85
|
+
}
|
|
86
|
+
return element.props.ref || element.ref;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { createSlot };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
// packages/react/use-callback-ref/src/use-callback-ref.tsx
|
|
4
|
+
function useCallbackRef(callback) {
|
|
5
|
+
const callbackRef = React.useRef(callback);
|
|
6
|
+
React.useEffect(() => {
|
|
7
|
+
callbackRef.current = callback;
|
|
8
|
+
});
|
|
9
|
+
return React.useMemo(() => (...args) => callbackRef.current?.(...args), []);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { useCallbackRef };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useLayoutEffect as useLayoutEffect2 } from '../../react-use-layout-effect/dist/index.js';
|
|
3
|
+
|
|
4
|
+
// src/use-controllable-state.tsx
|
|
5
|
+
var useInsertionEffect = React[" useInsertionEffect ".trim().toString()] || useLayoutEffect2;
|
|
6
|
+
function useControllableState({
|
|
7
|
+
prop,
|
|
8
|
+
defaultProp,
|
|
9
|
+
onChange = () => {
|
|
10
|
+
},
|
|
11
|
+
caller
|
|
12
|
+
}) {
|
|
13
|
+
const [uncontrolledProp, setUncontrolledProp, onChangeRef] = useUncontrolledState({
|
|
14
|
+
defaultProp,
|
|
15
|
+
onChange
|
|
16
|
+
});
|
|
17
|
+
const isControlled = prop !== void 0;
|
|
18
|
+
const value = isControlled ? prop : uncontrolledProp;
|
|
19
|
+
{
|
|
20
|
+
const isControlledRef = React.useRef(prop !== void 0);
|
|
21
|
+
React.useEffect(() => {
|
|
22
|
+
const wasControlled = isControlledRef.current;
|
|
23
|
+
if (wasControlled !== isControlled) {
|
|
24
|
+
const from = wasControlled ? "controlled" : "uncontrolled";
|
|
25
|
+
const to = isControlled ? "controlled" : "uncontrolled";
|
|
26
|
+
console.warn(
|
|
27
|
+
`${caller} is changing from ${from} to ${to}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
isControlledRef.current = isControlled;
|
|
31
|
+
}, [isControlled, caller]);
|
|
32
|
+
}
|
|
33
|
+
const setValue = React.useCallback(
|
|
34
|
+
(nextValue) => {
|
|
35
|
+
if (isControlled) {
|
|
36
|
+
const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
|
|
37
|
+
if (value2 !== prop) {
|
|
38
|
+
onChangeRef.current?.(value2);
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
setUncontrolledProp(nextValue);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
[isControlled, prop, setUncontrolledProp, onChangeRef]
|
|
45
|
+
);
|
|
46
|
+
return [value, setValue];
|
|
47
|
+
}
|
|
48
|
+
function useUncontrolledState({
|
|
49
|
+
defaultProp,
|
|
50
|
+
onChange
|
|
51
|
+
}) {
|
|
52
|
+
const [value, setValue] = React.useState(defaultProp);
|
|
53
|
+
const prevValueRef = React.useRef(value);
|
|
54
|
+
const onChangeRef = React.useRef(onChange);
|
|
55
|
+
useInsertionEffect(() => {
|
|
56
|
+
onChangeRef.current = onChange;
|
|
57
|
+
}, [onChange]);
|
|
58
|
+
React.useEffect(() => {
|
|
59
|
+
if (prevValueRef.current !== value) {
|
|
60
|
+
onChangeRef.current?.(value);
|
|
61
|
+
prevValueRef.current = value;
|
|
62
|
+
}
|
|
63
|
+
}, [value, prevValueRef]);
|
|
64
|
+
return [value, setValue, onChangeRef];
|
|
65
|
+
}
|
|
66
|
+
function isFunction(value) {
|
|
67
|
+
return typeof value === "function";
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { useControllableState };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useCallbackRef } from '../../react-use-callback-ref/dist/index.js';
|
|
3
|
+
|
|
4
|
+
// packages/react/use-escape-keydown/src/use-escape-keydown.tsx
|
|
5
|
+
function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {
|
|
6
|
+
const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);
|
|
7
|
+
React.useEffect(() => {
|
|
8
|
+
const handleKeyDown = (event) => {
|
|
9
|
+
if (event.key === "Escape") {
|
|
10
|
+
onEscapeKeyDown(event);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
14
|
+
return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
15
|
+
}, [onEscapeKeyDown, ownerDocument]);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { useEscapeKeydown };
|