@basic-ui/core 0.0.52 → 0.0.53
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/README.md +3 -3
- package/build/cjs/index.js +105 -89
- package/build/cjs/index.js.map +1 -1
- package/build/esm/Accordion/Accordion.d.ts +9 -9
- package/build/esm/Accordion/Accordion.js.map +1 -1
- package/build/esm/Accordion/AccordionBody.d.ts +6 -6
- package/build/esm/Accordion/AccordionBody.js.map +1 -1
- package/build/esm/Accordion/AccordionHeader.d.ts +7 -7
- package/build/esm/Accordion/AccordionHeader.js.map +1 -1
- package/build/esm/Accordion/AccordionItem.d.ts +9 -9
- package/build/esm/Accordion/AccordionItem.js.map +1 -1
- package/build/esm/Accordion/context.d.ts +19 -19
- package/build/esm/Accordion/context.js.map +1 -1
- package/build/esm/Accordion/index.d.ts +4 -4
- package/build/esm/Accordion/index.js.map +1 -1
- package/build/esm/Accordion/scopeQuery.d.ts +2 -2
- package/build/esm/Accordion/scopeQuery.js.map +1 -1
- package/build/esm/Carousel/Carousel.d.ts +9 -0
- package/build/esm/Carousel/Carousel.js +38 -0
- package/build/esm/Carousel/Carousel.js.map +1 -0
- package/build/esm/Carousel/Fader.d.ts +14 -0
- package/build/esm/Carousel/Fader.js +76 -0
- package/build/esm/Carousel/Fader.js.map +1 -0
- package/build/esm/Carousel/FaderItem.d.ts +5 -0
- package/build/esm/Carousel/FaderItem.js +16 -0
- package/build/esm/Carousel/FaderItem.js.map +1 -0
- package/build/esm/Carousel/Preloader.d.ts +7 -0
- package/build/esm/Carousel/Preloader.js +70 -0
- package/build/esm/Carousel/Preloader.js.map +1 -0
- package/build/esm/Carousel/Slider.d.ts +14 -0
- package/build/esm/Carousel/Slider.js +212 -0
- package/build/esm/Carousel/Slider.js.map +1 -0
- package/build/esm/Carousel/SliderItem.d.ts +12 -0
- package/build/esm/Carousel/SliderItem.js +41 -0
- package/build/esm/Carousel/SliderItem.js.map +1 -0
- package/build/esm/Carousel/context.d.ts +10 -0
- package/build/esm/Carousel/context.js +8 -0
- package/build/esm/Carousel/context.js.map +1 -0
- package/build/esm/Carousel/getSliderParams.d.ts +9 -0
- package/build/esm/Carousel/getSliderParams.js +85 -0
- package/build/esm/Carousel/getSliderParams.js.map +1 -0
- package/build/esm/Carousel/index.d.ts +7 -0
- package/build/esm/Carousel/index.js +8 -0
- package/build/esm/Carousel/index.js.map +1 -0
- package/build/esm/Carousel/useCarouselGestures.d.ts +30 -0
- package/build/esm/Carousel/useCarouselGestures.js +33 -0
- package/build/esm/Carousel/useCarouselGestures.js.map +1 -0
- package/build/esm/CheckBox/CheckBox.d.ts +7 -7
- package/build/esm/CheckBox/CheckBox.js.map +1 -1
- package/build/esm/CheckBox/index.d.ts +1 -1
- package/build/esm/CheckBox/index.js.map +1 -1
- package/build/esm/ComboBox/Combobox.d.ts +18 -18
- package/build/esm/ComboBox/Combobox.js.map +1 -1
- package/build/esm/ComboBox/ComboboxButton.d.ts +9 -9
- package/build/esm/ComboBox/ComboboxButton.js.map +1 -1
- package/build/esm/ComboBox/ComboboxInput.d.ts +17 -17
- package/build/esm/ComboBox/ComboboxInput.js.map +1 -1
- package/build/esm/ComboBox/ComboboxLabel.d.ts +7 -7
- package/build/esm/ComboBox/ComboboxLabel.js.map +1 -1
- package/build/esm/ComboBox/ComboboxList.d.ts +8 -8
- package/build/esm/ComboBox/ComboboxList.js.map +1 -1
- package/build/esm/ComboBox/ComboboxOption.d.ts +11 -11
- package/build/esm/ComboBox/ComboboxOption.js.map +1 -1
- package/build/esm/ComboBox/ComboboxPopover.d.ts +9 -9
- package/build/esm/ComboBox/ComboboxPopover.js.map +1 -1
- package/build/esm/ComboBox/cities.d.ts +5 -5
- package/build/esm/ComboBox/cities.js.map +1 -1
- package/build/esm/ComboBox/context.d.ts +30 -30
- package/build/esm/ComboBox/context.js.map +1 -1
- package/build/esm/ComboBox/hooks.d.ts +37 -37
- package/build/esm/ComboBox/hooks.js.map +1 -1
- package/build/esm/ComboBox/index.d.ts +8 -8
- package/build/esm/ComboBox/index.js.map +1 -1
- package/build/esm/ComboBox/makeHash.d.ts +1 -1
- package/build/esm/ComboBox/makeHash.js.map +1 -1
- package/build/esm/ComboBox/scopeQuery.d.ts +1 -1
- package/build/esm/ComboBox/scopeQuery.js.map +1 -1
- package/build/esm/DatePicker/DatePicker.d.ts +24 -0
- package/build/esm/DatePicker/DatePicker.js +101 -0
- package/build/esm/DatePicker/DatePicker.js.map +1 -0
- package/build/esm/DatePicker/DatePickerSelect.d.ts +8 -0
- package/build/esm/DatePicker/DatePickerSelect.js +201 -0
- package/build/esm/DatePicker/DatePickerSelect.js.map +1 -0
- package/build/esm/DatePicker/RangeDatePicker.d.ts +28 -0
- package/build/esm/DatePicker/RangeDatePicker.js +94 -0
- package/build/esm/DatePicker/RangeDatePicker.js.map +1 -0
- package/build/esm/DatePicker/adjustDates.d.ts +4 -0
- package/build/esm/DatePicker/adjustDates.js +18 -0
- package/build/esm/DatePicker/adjustDates.js.map +1 -0
- package/build/esm/DatePicker/contexts.d.ts +31 -0
- package/build/esm/DatePicker/contexts.js +15 -0
- package/build/esm/DatePicker/contexts.js.map +1 -0
- package/build/esm/DatePicker/dateTypes.d.ts +2 -0
- package/build/esm/DatePicker/dateTypes.js +2 -0
- package/build/esm/DatePicker/dateTypes.js.map +1 -0
- package/build/esm/DatePicker/hooks.d.ts +36 -0
- package/build/esm/DatePicker/hooks.js +98 -0
- package/build/esm/DatePicker/hooks.js.map +1 -0
- package/build/esm/DatePicker/index.d.ts +5 -0
- package/build/esm/DatePicker/index.js +6 -0
- package/build/esm/DatePicker/index.js.map +1 -0
- package/build/esm/FocusLock/FocusLock.d.ts +9 -9
- package/build/esm/FocusLock/FocusLock.js.map +1 -1
- package/build/esm/FocusLock/index.d.ts +1 -1
- package/build/esm/FocusLock/index.js.map +1 -1
- package/build/esm/FocusLock/tabUtils.d.ts +3 -3
- package/build/esm/FocusLock/tabUtils.js.map +1 -1
- package/build/esm/FocusLock/useFocusLock.d.ts +7 -7
- package/build/esm/FocusLock/useFocusLock.js.map +1 -1
- package/build/esm/List/List.d.ts +7 -7
- package/build/esm/List/List.js.map +1 -1
- package/build/esm/List/ListItem.d.ts +7 -7
- package/build/esm/List/ListItem.js.map +1 -1
- package/build/esm/List/context.d.ts +4 -4
- package/build/esm/List/context.js.map +1 -1
- package/build/esm/List/index.d.ts +2 -2
- package/build/esm/List/index.js.map +1 -1
- package/build/esm/Menu/ContextMenuTrigger.d.ts +11 -11
- package/build/esm/Menu/ContextMenuTrigger.js.map +1 -1
- package/build/esm/Menu/Menu.d.ts +10 -10
- package/build/esm/Menu/Menu.js.map +1 -1
- package/build/esm/Menu/MenuButton.d.ts +11 -11
- package/build/esm/Menu/MenuButton.js.map +1 -1
- package/build/esm/Menu/MenuItem.d.ts +8 -8
- package/build/esm/Menu/MenuItem.js.map +1 -1
- package/build/esm/Menu/MenuList.d.ts +7 -7
- package/build/esm/Menu/MenuList.js.map +1 -1
- package/build/esm/Menu/MenuPopover.d.ts +8 -8
- package/build/esm/Menu/MenuPopover.js.map +1 -1
- package/build/esm/Menu/context.d.ts +25 -25
- package/build/esm/Menu/context.js.map +1 -1
- package/build/esm/Menu/fixtures/countryList.d.ts +1 -1
- package/build/esm/Menu/fixtures/countryList.js.map +1 -1
- package/build/esm/Menu/index.d.ts +6 -6
- package/build/esm/Menu/index.js.map +1 -1
- package/build/esm/Menu/scope.d.ts +1 -1
- package/build/esm/Menu/scope.js.map +1 -1
- package/build/esm/Modal/Modal.d.ts +9 -9
- package/build/esm/Modal/Modal.js.map +1 -1
- package/build/esm/Modal/ModalBackdrop.d.ts +10 -10
- package/build/esm/Modal/ModalBackdrop.js.map +1 -1
- package/build/esm/Modal/index.d.ts +2 -2
- package/build/esm/Modal/index.js.map +1 -1
- package/build/esm/Popper/Popper.d.ts +35 -35
- package/build/esm/Popper/Popper.js.map +1 -1
- package/build/esm/Popper/PopperArrow.d.ts +6 -6
- package/build/esm/Popper/PopperArrow.js.map +1 -1
- package/build/esm/Popper/context.d.ts +6 -6
- package/build/esm/Popper/context.js.map +1 -1
- package/build/esm/Popper/index.d.ts +3 -3
- package/build/esm/Popper/index.js.map +1 -1
- package/build/esm/Portal/Portal.d.ts +7 -6
- package/build/esm/Portal/Portal.js +6 -3
- package/build/esm/Portal/Portal.js.map +1 -1
- package/build/esm/Portal/PortalSelectorProvider.d.ts +8 -0
- package/build/esm/Portal/PortalSelectorProvider.js +13 -0
- package/build/esm/Portal/PortalSelectorProvider.js.map +1 -0
- package/build/esm/Portal/index.d.ts +2 -1
- package/build/esm/Portal/index.js +1 -0
- package/build/esm/Portal/index.js.map +1 -1
- package/build/esm/RadioButton/RadioButton.d.ts +10 -10
- package/build/esm/RadioButton/RadioButton.js.map +1 -1
- package/build/esm/RadioButton/RadioGroup.d.ts +12 -12
- package/build/esm/RadioButton/RadioGroup.js.map +1 -1
- package/build/esm/RadioButton/context.d.ts +9 -9
- package/build/esm/RadioButton/context.js.map +1 -1
- package/build/esm/RadioButton/index.d.ts +2 -2
- package/build/esm/RadioButton/index.js.map +1 -1
- package/build/esm/SkipNav/SkipNav.d.ts +7 -7
- package/build/esm/SkipNav/SkipNav.js.map +1 -1
- package/build/esm/SkipNav/index.d.ts +1 -1
- package/build/esm/SkipNav/index.js.map +1 -1
- package/build/esm/Slider/Slider.d.ts +197 -197
- package/build/esm/Slider/Slider.js +82 -82
- package/build/esm/Slider/Slider.js.map +1 -1
- package/build/esm/Slider/index.d.ts +1 -1
- package/build/esm/Slider/index.js.map +1 -1
- package/build/esm/Spinner/Spinner.d.ts +12 -12
- package/build/esm/Spinner/Spinner.js.map +1 -1
- package/build/esm/Spinner/SpinnerButton.d.ts +8 -8
- package/build/esm/Spinner/SpinnerButton.js.map +1 -1
- package/build/esm/Spinner/context.d.ts +12 -12
- package/build/esm/Spinner/context.js.map +1 -1
- package/build/esm/Spinner/index.d.ts +2 -2
- package/build/esm/Spinner/index.js.map +1 -1
- package/build/esm/Tabs/Tab.d.ts +7 -7
- package/build/esm/Tabs/Tab.js.map +1 -1
- package/build/esm/Tabs/TabList.d.ts +9 -9
- package/build/esm/Tabs/TabList.js.map +1 -1
- package/build/esm/Tabs/TabPanel.d.ts +8 -8
- package/build/esm/Tabs/TabPanel.js.map +1 -1
- package/build/esm/Tabs/TabPanels.d.ts +8 -8
- package/build/esm/Tabs/TabPanels.js.map +1 -1
- package/build/esm/Tabs/Tabs.d.ts +10 -10
- package/build/esm/Tabs/Tabs.js.map +1 -1
- package/build/esm/Tabs/context.d.ts +17 -17
- package/build/esm/Tabs/context.js.map +1 -1
- package/build/esm/Tabs/index.d.ts +5 -5
- package/build/esm/Tabs/index.js.map +1 -1
- package/build/esm/Tabs/scopeQuery.d.ts +1 -1
- package/build/esm/Tabs/scopeQuery.js.map +1 -1
- package/build/esm/Tooltip/Tooltip.d.ts +10 -10
- package/build/esm/Tooltip/Tooltip.js.map +1 -1
- package/build/esm/Tooltip/index.d.ts +1 -1
- package/build/esm/Tooltip/index.js.map +1 -1
- package/build/esm/Tooltip/stateMachine.d.ts +28 -28
- package/build/esm/Tooltip/stateMachine.js.map +1 -1
- package/build/esm/Tooltip/useTooltip.d.ts +10 -10
- package/build/esm/Tooltip/useTooltip.js.map +1 -1
- package/build/esm/hooks/index.d.ts +13 -13
- package/build/esm/hooks/index.js.map +1 -1
- package/build/esm/hooks/useAutoFocus.d.ts +2 -2
- package/build/esm/hooks/useAutoFocus.js.map +1 -1
- package/build/esm/hooks/useChildrenCounter.d.ts +7 -7
- package/build/esm/hooks/useChildrenCounter.js.map +1 -1
- package/build/esm/hooks/useControlledState.d.ts +3 -3
- package/build/esm/hooks/useFocusReturn.d.ts +2 -2
- package/build/esm/hooks/useFocusReturn.js.map +1 -1
- package/build/esm/hooks/useFocusState.d.ts +11 -11
- package/build/esm/hooks/useFocusState.js.map +1 -1
- package/build/esm/hooks/useGestureHandlers.d.ts +52 -52
- package/build/esm/hooks/useGestureHandlers.js.map +1 -1
- package/build/esm/hooks/useId.d.ts +1 -0
- package/build/esm/hooks/useId.js +25 -0
- package/build/esm/hooks/useId.js.map +1 -0
- package/build/esm/hooks/useMeasure.d.ts +7 -7
- package/build/esm/hooks/useMeasure.js.map +1 -1
- package/build/esm/hooks/useOnClickOutside.d.ts +2 -2
- package/build/esm/hooks/useOnClickOutside.js.map +1 -1
- package/build/esm/hooks/useOnKeyDown.d.ts +1 -1
- package/build/esm/hooks/useOnKeyDown.js.map +1 -1
- package/build/esm/hooks/useReducerMachine.d.ts +24 -24
- package/build/esm/hooks/useReducerMachine.js.map +1 -1
- package/build/esm/hooks/useRemoveBodyScroll.d.ts +2 -2
- package/build/esm/hooks/useRemoveBodyScroll.js.map +1 -1
- package/build/esm/hooks/useScope.d.ts +11 -11
- package/build/esm/hooks/useScope.js.map +1 -1
- package/build/esm/hooks/useThrottle.d.ts +1 -1
- package/build/esm/hooks/useThrottle.js.map +1 -1
- package/build/esm/index.d.ts +15 -15
- package/build/esm/index.js.map +1 -1
- package/build/esm/utils/assign-ref.d.ts +3 -3
- package/build/esm/utils/assign-ref.js.map +1 -1
- package/build/esm/utils/assignRef.d.ts +3 -0
- package/build/esm/utils/assignRef.js +25 -0
- package/build/esm/utils/assignRef.js.map +1 -0
- package/build/esm/utils/can-use-dom.d.ts +1 -1
- package/build/esm/utils/can-use-dom.js.map +1 -1
- package/build/esm/utils/clamp.d.ts +1 -1
- package/build/esm/utils/clamp.js.map +1 -1
- package/build/esm/utils/context.d.ts +7 -7
- package/build/esm/utils/context.js.map +1 -1
- package/build/esm/utils/create-subscription.d.ts +4 -4
- package/build/esm/utils/create-subscription.js.map +1 -1
- package/build/esm/utils/get-circular-index.d.ts +1 -1
- package/build/esm/utils/get-circular-index.js.map +1 -1
- package/build/esm/utils/getCircularIndex.d.ts +1 -0
- package/build/esm/utils/getCircularIndex.js +8 -0
- package/build/esm/utils/getCircularIndex.js.map +1 -0
- package/build/esm/utils/index.d.ts +10 -10
- package/build/esm/utils/index.js.map +1 -1
- package/build/esm/utils/is-right-click.d.ts +6 -6
- package/build/esm/utils/is-right-click.js +4 -4
- package/build/esm/utils/is-right-click.js.map +1 -1
- package/build/esm/utils/owner-document.d.ts +7 -7
- package/build/esm/utils/owner-document.js +5 -5
- package/build/esm/utils/owner-document.js.map +1 -1
- package/build/esm/utils/polymorphic.d.ts +39 -39
- package/build/esm/utils/polymorphic.js.map +1 -1
- package/build/esm/utils/rubber-band-clamp.d.ts +2 -2
- package/build/esm/utils/rubber-band-clamp.js.map +1 -1
- package/build/esm/utils/rubberBandClamp.d.ts +2 -0
- package/build/esm/utils/rubberBandClamp.js +20 -0
- package/build/esm/utils/rubberBandClamp.js.map +1 -0
- package/build/esm/utils/use-stable-callback.d.ts +16 -16
- package/build/esm/utils/use-stable-callback.js +16 -16
- package/build/esm/utils/use-stable-callback.js.map +1 -1
- package/build/esm/utils/wrap-event.d.ts +3 -3
- package/build/esm/utils/wrap-event.js.map +1 -1
- package/build/esm/utils/wrapEvent.d.ts +3 -0
- package/build/esm/utils/wrapEvent.js +16 -0
- package/build/esm/utils/wrapEvent.js.map +1 -0
- package/build/tsconfig-build.tsbuildinfo +1 -1
- package/build/tsconfig.tsbuildinfo +7270 -0
- package/package.json +2 -2
- package/src/Accordion/Accordion.story.tsx +74 -74
- package/src/Accordion/Accordion.tsx +59 -59
- package/src/Accordion/AccordionBody.tsx +52 -52
- package/src/Accordion/AccordionHeader.tsx +167 -167
- package/src/Accordion/AccordionItem.tsx +50 -50
- package/src/Accordion/context.ts +37 -37
- package/src/Accordion/index.ts +4 -4
- package/src/Accordion/scopeQuery.ts +7 -7
- package/src/Accordion/styles.css +21 -21
- package/src/CheckBox/CheckBox.tsx +41 -41
- package/src/CheckBox/index.ts +1 -1
- package/src/ComboBox/ComboBox.story.tsx +120 -120
- package/src/ComboBox/Combobox.tsx +148 -148
- package/src/ComboBox/ComboboxButton.tsx +61 -61
- package/src/ComboBox/ComboboxInput.tsx +187 -187
- package/src/ComboBox/ComboboxLabel.tsx +33 -33
- package/src/ComboBox/ComboboxList.tsx +47 -47
- package/src/ComboBox/ComboboxOption.tsx +111 -111
- package/src/ComboBox/ComboboxPopover.tsx +64 -64
- package/src/ComboBox/cities.ts +23194 -23194
- package/src/ComboBox/context.ts +35 -35
- package/src/ComboBox/hooks.tsx +451 -451
- package/src/ComboBox/index.ts +8 -8
- package/src/ComboBox/makeHash.ts +19 -19
- package/src/ComboBox/scopeQuery.ts +6 -6
- package/src/ComboBox/styles.css +32 -32
- package/src/FocusLock/FocusLock.tsx +66 -66
- package/src/FocusLock/index.ts +1 -1
- package/src/FocusLock/tabUtils.ts +40 -40
- package/src/FocusLock/useFocusLock.ts +56 -56
- package/src/List/List.story.tsx +18 -18
- package/src/List/List.tsx +17 -17
- package/src/List/ListItem.tsx +23 -23
- package/src/List/context.ts +19 -19
- package/src/List/index.ts +2 -2
- package/src/Menu/ContextMenu.story.tsx +73 -73
- package/src/Menu/ContextMenuTrigger.tsx +76 -76
- package/src/Menu/Menu.story.tsx +160 -160
- package/src/Menu/Menu.tsx +83 -83
- package/src/Menu/MenuButton.tsx +83 -83
- package/src/Menu/MenuComplex.story.tsx +58 -58
- package/src/Menu/MenuItem.tsx +88 -88
- package/src/Menu/MenuList.tsx +254 -254
- package/src/Menu/MenuPopover.tsx +35 -35
- package/src/Menu/context.ts +44 -44
- package/src/Menu/fixtures/countryList.ts +198 -198
- package/src/Menu/index.ts +6 -6
- package/src/Menu/scope.ts +7 -7
- package/src/Menu/styles.css +42 -42
- package/src/Modal/Modal.story.tsx +258 -258
- package/src/Modal/Modal.tsx +48 -48
- package/src/Modal/ModalBackdrop.tsx +78 -78
- package/src/Modal/NavDrawer.story.tsx +158 -158
- package/src/Modal/index.ts +2 -2
- package/src/Modal/styles.css +46 -46
- package/src/Popper/Popper.story.tsx +263 -263
- package/src/Popper/Popper.tsx +154 -154
- package/src/Popper/PopperArrow.tsx +35 -35
- package/src/Popper/context.ts +10 -10
- package/src/Popper/index.ts +3 -3
- package/src/Popper/styles.css +60 -60
- package/src/Portal/Portal.tsx +31 -20
- package/src/Portal/PortalSelectorProvider.tsx +24 -0
- package/src/Portal/index.ts +6 -1
- package/src/RadioButton/RadioButton.story.tsx +77 -77
- package/src/RadioButton/RadioButton.tsx +55 -55
- package/src/RadioButton/RadioGroup.tsx +60 -60
- package/src/RadioButton/context.ts +17 -17
- package/src/RadioButton/index.ts +2 -2
- package/src/SkipNav/SkipNav.tsx +16 -16
- package/src/SkipNav/index.tsx +1 -1
- package/src/Slider/Slider.story.tsx +45 -45
- package/src/Slider/Slider.tsx +1120 -1120
- package/src/Slider/index.ts +1 -1
- package/src/Slider/styles.css +131 -131
- package/src/Spinner/Spinner.story.tsx +31 -31
- package/src/Spinner/Spinner.tsx +117 -117
- package/src/Spinner/SpinnerButton.tsx +54 -54
- package/src/Spinner/context.ts +20 -20
- package/src/Spinner/index.ts +2 -2
- package/src/Spinner/styles.css +23 -23
- package/src/Tabs/Tab.story.tsx +80 -80
- package/src/Tabs/Tab.tsx +136 -136
- package/src/Tabs/TabList.tsx +71 -71
- package/src/Tabs/TabPanel.tsx +53 -53
- package/src/Tabs/TabPanels.tsx +30 -30
- package/src/Tabs/Tabs.tsx +46 -46
- package/src/Tabs/context.ts +30 -30
- package/src/Tabs/index.tsx +5 -5
- package/src/Tabs/scopeQuery.ts +6 -6
- package/src/Tooltip/Tooltip.story.tsx +61 -61
- package/src/Tooltip/Tooltip.tsx +50 -50
- package/src/Tooltip/index.ts +1 -1
- package/src/Tooltip/stateMachine.ts +192 -192
- package/src/Tooltip/styles.css +17 -17
- package/src/Tooltip/useTooltip.ts +136 -136
- package/src/hooks/index.ts +13 -13
- package/src/hooks/useAutoFocus.ts +22 -22
- package/src/hooks/useChildrenCounter.ts +51 -51
- package/src/hooks/useFocusReturn.ts +43 -43
- package/src/hooks/useFocusState.ts +30 -30
- package/src/hooks/useGestureHandlers.ts +286 -286
- package/src/hooks/useMeasure.ts +33 -33
- package/src/hooks/useOnClickOutside.ts +32 -32
- package/src/hooks/useOnKeyDown.ts +19 -19
- package/src/hooks/useReducerMachine.ts +60 -60
- package/src/hooks/useRemoveBodyScroll.ts +39 -39
- package/src/hooks/useScope.ts +52 -52
- package/src/hooks/useThrottle.ts +19 -19
- package/src/index.ts +20 -20
- package/src/utils/assign-ref.ts +27 -27
- package/src/utils/can-use-dom.ts +7 -7
- package/src/utils/clamp.ts +3 -3
- package/src/utils/context.tsx +48 -48
- package/src/utils/create-subscription.ts +16 -16
- package/src/utils/get-circular-index.ts +7 -7
- package/src/utils/index.ts +10 -10
- package/src/utils/is-right-click.ts +14 -14
- package/src/utils/owner-document.ts +13 -13
- package/src/utils/polymorphic.ts +78 -78
- package/src/utils/rubber-band-clamp.ts +25 -25
- package/src/utils/use-stable-callback.ts +58 -58
- package/src/utils/wrap-event.ts +22 -22
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/DatePicker/index.tsx"],"names":[],"mappings":"AAAA,cAAc,cAAd;AACA,cAAc,mBAAd;AACA,cAAc,oBAAd;AACA,cAAc,aAAd;AACA,cAAc,YAAd","sourcesContent":["export * from './DatePicker';\nexport * from './RangeDatePicker';\nexport * from './DatePickerSelect';\nexport * from './dateTypes';\nexport * from './contexts';\n"],"file":"index.js"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ElementType, FC, HTMLAttributes, MutableRefObject, ReactNode } from 'react';
|
|
2
|
-
export interface FocusLockProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
children?: ReactNode;
|
|
6
|
-
childRef: MutableRefObject<HTMLElement | null>;
|
|
7
|
-
enabled?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare const FocusLock: FC<FocusLockProps>;
|
|
1
|
+
import type { ElementType, FC, HTMLAttributes, MutableRefObject, ReactNode } from 'react';
|
|
2
|
+
export interface FocusLockProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
childRef: MutableRefObject<HTMLElement | null>;
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const FocusLock: FC<FocusLockProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FocusLock.js","names":["useRef","useFocusLock","FocusLock","props","as","Comp","childRef","enabled","style","children","otherProps","lockStartRef","lockEndRef","lockStyle","width","height","padding","overflow","position","top","left"],"sources":["../../../src/FocusLock/FocusLock.tsx"],"sourcesContent":["import type {\
|
|
1
|
+
{"version":3,"file":"FocusLock.js","names":["useRef","useFocusLock","FocusLock","props","as","Comp","childRef","enabled","style","children","otherProps","lockStartRef","lockEndRef","lockStyle","width","height","padding","overflow","position","top","left"],"sources":["../../../src/FocusLock/FocusLock.tsx"],"sourcesContent":["import type {\n ElementType,\n FC,\n HTMLAttributes,\n MutableRefObject,\n ReactNode,\n} from 'react';\nimport { useRef } from 'react';\n\nimport { useFocusLock } from './useFocusLock';\n\nexport interface FocusLockProps extends HTMLAttributes<HTMLDivElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n childRef: MutableRefObject<HTMLElement | null>;\n enabled?: boolean;\n}\n\nexport const FocusLock: FC<FocusLockProps> = function FocusLock(props) {\n const {\n as: Comp = 'div',\n childRef,\n enabled = false,\n style = {},\n children,\n ...otherProps\n } = props;\n const lockStartRef = useRef<HTMLElement>(null);\n const lockEndRef = useRef<HTMLElement>(null);\n\n useFocusLock(childRef, { enabled, lockStartRef, lockEndRef });\n\n const lockStyle = {\n width: 1,\n height: 0,\n padding: 0,\n overflow: 'hidden',\n position: 'fixed',\n top: 1,\n left: 1,\n ...style,\n };\n\n return (\n <>\n <Comp\n ref={lockStartRef}\n data-focus-lock-start=\"\"\n aria-hidden={true}\n tabIndex={0}\n style={lockStyle}\n {...otherProps}\n />\n {children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,EAAEG,UADP;MAEE,uBAAoB,EAFtB;MAGE,eAAa,IAHf;MAIE,QAAQ,EAAE,CAJZ;MAKE,KAAK,EAAEC;IALT,GAMMH,UANN,EAVF;EAAA,EADF;AAqBD,CA9CM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './FocusLock';
|
|
1
|
+
export * from './FocusLock';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/FocusLock/index.ts"],"sourcesContent":["export * from './FocusLock';\
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/FocusLock/index.ts"],"sourcesContent":["export * from './FocusLock';\n"],"mappings":"AAAA,cAAc,aAAd"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const tabblable: string;
|
|
2
|
-
export declare const getTabblableNodes: (parentNode: HTMLElement | null) => HTMLElement[];
|
|
3
|
-
export declare function focusOnChildNode(parentNode: HTMLElement, itemIndex: 0 | -1): void;
|
|
1
|
+
export declare const tabblable: string;
|
|
2
|
+
export declare const getTabblableNodes: (parentNode: HTMLElement | null) => HTMLElement[];
|
|
3
|
+
export declare function focusOnChildNode(parentNode: HTMLElement, itemIndex: 0 | -1): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabUtils.js","names":["tabblable","join","getTabblableNodes","parentNode","Array","from","querySelectorAll","focusOnChildNode","itemIndex","elements","length","focus","currentTabIndex","tabIndex"],"sources":["../../../src/FocusLock/tabUtils.ts"],"sourcesContent":["export const tabblable = [\
|
|
1
|
+
{"version":3,"file":"tabUtils.js","names":["tabblable","join","getTabblableNodes","parentNode","Array","from","querySelectorAll","focusOnChildNode","itemIndex","elements","length","focus","currentTabIndex","tabIndex"],"sources":["../../../src/FocusLock/tabUtils.ts"],"sourcesContent":["export const tabblable = [\n 'button:enabled:not([readonly])',\n 'select:enabled:not([readonly])',\n 'textarea:enabled:not([readonly])',\n 'input:enabled:not([readonly])',\n\n 'a[href]',\n 'area[href]',\n\n 'iframe',\n 'object',\n 'embed',\n\n '[tabindex]',\n '[contenteditable]',\n '[autofocus]',\n].join(',');\n\n/* This is naive and will not consider tabIndex */\nexport const getTabblableNodes = (\n parentNode: HTMLElement | null\n): HTMLElement[] => {\n if (!parentNode) {\n return [];\n }\n\n return Array.from(parentNode.querySelectorAll(tabblable));\n};\n\nexport function focusOnChildNode(parentNode: HTMLElement, itemIndex: 0 | -1) {\n const elements = getTabblableNodes(parentNode);\n if (elements.length > 0) {\n elements[itemIndex === -1 ? elements.length - 1 : 0].focus();\n } else {\n const currentTabIndex = parentNode.tabIndex;\n parentNode.tabIndex = 0;\n parentNode.focus();\n parentNode.tabIndex = currentTabIndex;\n }\n}\n"],"mappings":"AAAA,OAAO,IAAMA,SAAS,GAAG,CACvB,gCADuB,EAEvB,gCAFuB,EAGvB,kCAHuB,EAIvB,+BAJuB,EAMvB,SANuB,EAOvB,YAPuB,EASvB,QATuB,EAUvB,QAVuB,EAWvB,OAXuB,EAavB,YAbuB,EAcvB,mBAduB,EAevB,aAfuB,EAgBvBC,IAhBuB,CAgBlB,GAhBkB,CAAlB;AAkBP;;AACA,OAAO,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAC/BC,UAD+B,EAEb;EAClB,IAAI,CAACA,UAAL,EAAiB;IACf,OAAO,EAAP;EACD;;EAED,OAAOC,KAAK,CAACC,IAAN,CAAWF,UAAU,CAACG,gBAAX,CAA4BN,SAA5B,CAAX,CAAP;AACD,CARM;AAUP,OAAO,SAASO,gBAAT,CAA0BJ,UAA1B,EAAmDK,SAAnD,EAAsE;EAC3E,IAAMC,QAAQ,GAAGP,iBAAiB,CAACC,UAAD,CAAlC;;EACA,IAAIM,QAAQ,CAACC,MAAT,GAAkB,CAAtB,EAAyB;IACvBD,QAAQ,CAACD,SAAS,KAAK,CAAC,CAAf,GAAmBC,QAAQ,CAACC,MAAT,GAAkB,CAArC,GAAyC,CAA1C,CAAR,CAAqDC,KAArD;EACD,CAFD,MAEO;IACL,IAAMC,eAAe,GAAGT,UAAU,CAACU,QAAnC;IACAV,UAAU,CAACU,QAAX,GAAsB,CAAtB;IACAV,UAAU,CAACQ,KAAX;IACAR,UAAU,CAACU,QAAX,GAAsBD,eAAtB;EACD;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { MutableRefObject } from 'react';
|
|
2
|
-
export interface FocusLockOptions {
|
|
3
|
-
enabled: boolean;
|
|
4
|
-
lockStartRef: MutableRefObject<HTMLElement | null>;
|
|
5
|
-
lockEndRef: MutableRefObject<HTMLElement | null>;
|
|
6
|
-
}
|
|
7
|
-
export declare function useFocusLock(ref: MutableRefObject<HTMLElement | null>, opts: FocusLockOptions): void;
|
|
1
|
+
import type { MutableRefObject } from 'react';
|
|
2
|
+
export interface FocusLockOptions {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
lockStartRef: MutableRefObject<HTMLElement | null>;
|
|
5
|
+
lockEndRef: MutableRefObject<HTMLElement | null>;
|
|
6
|
+
}
|
|
7
|
+
export declare function useFocusLock(ref: MutableRefObject<HTMLElement | null>, opts: FocusLockOptions): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFocusLock.js","names":["useEffect","focusOnChildNode","focusLockStack","useFocusLock","ref","opts","enabled","lockStartRef","lockEndRef","rootEl","current","push","listener","event","isActiveFocusLock","length","target","document","contains","preventDefault","addEventListener","removeEventListener","pop"],"sources":["../../../src/FocusLock/useFocusLock.ts"],"sourcesContent":["import type { MutableRefObject } from 'react';\
|
|
1
|
+
{"version":3,"file":"useFocusLock.js","names":["useEffect","focusOnChildNode","focusLockStack","useFocusLock","ref","opts","enabled","lockStartRef","lockEndRef","rootEl","current","push","listener","event","isActiveFocusLock","length","target","document","contains","preventDefault","addEventListener","removeEventListener","pop"],"sources":["../../../src/FocusLock/useFocusLock.ts"],"sourcesContent":["import type { MutableRefObject } from 'react';\nimport { useEffect } from 'react';\n\nimport { focusOnChildNode } from './tabUtils';\n\nexport interface FocusLockOptions {\n enabled: boolean;\n lockStartRef: MutableRefObject<HTMLElement | null>;\n lockEndRef: MutableRefObject<HTMLElement | null>;\n}\n\nconst focusLockStack: HTMLElement[] = [];\nexport function useFocusLock(\n ref: MutableRefObject<HTMLElement | null>,\n opts: FocusLockOptions\n) {\n const { enabled = true, lockStartRef, lockEndRef } = opts;\n\n useEffect(() => {\n const rootEl = ref.current;\n if (enabled && rootEl) {\n focusLockStack.push(rootEl);\n\n const listener = (event: FocusEvent) => {\n const isActiveFocusLock =\n focusLockStack[focusLockStack.length - 1] === rootEl;\n if (!isActiveFocusLock) {\n // Not the currently focused lock. Forget about it.\n return;\n }\n\n if (event.target === lockEndRef.current) {\n focusOnChildNode(rootEl, 0);\n } else if (event.target === lockStartRef.current) {\n focusOnChildNode(rootEl, -1);\n } else if (\n document !== event.target &&\n rootEl !== event.target &&\n !rootEl.contains(event.target as any)\n ) {\n event.preventDefault();\n focusOnChildNode(rootEl, 0);\n }\n };\n\n document.addEventListener('focusin', listener);\n return () => {\n document.removeEventListener('focusin', listener);\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n focusLockStack.pop();\n };\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [enabled]);\n}\n"],"mappings":"AACA,SAASA,SAAT,QAA0B,OAA1B;AAEA,SAASC,gBAAT,QAAiC,YAAjC;AAQA,IAAMC,cAA6B,GAAG,EAAtC;AACA,OAAO,SAASC,YAAT,CACLC,GADK,EAELC,IAFK,EAGL;EACA,oBAAqDA,IAArD,CAAQC,OAAR;EAAA,IAAQA,OAAR,8BAAkB,IAAlB;EAAA,IAAwBC,YAAxB,GAAqDF,IAArD,CAAwBE,YAAxB;EAAA,IAAsCC,UAAtC,GAAqDH,IAArD,CAAsCG,UAAtC;EAEAR,SAAS,CAAC,YAAM;IACd,IAAMS,MAAM,GAAGL,GAAG,CAACM,OAAnB;;IACA,IAAIJ,OAAO,IAAIG,MAAf,EAAuB;MACrBP,cAAc,CAACS,IAAf,CAAoBF,MAApB;;MAEA,IAAMG,QAAQ,GAAG,SAAXA,QAAW,CAACC,KAAD,EAAuB;QACtC,IAAMC,iBAAiB,GACrBZ,cAAc,CAACA,cAAc,CAACa,MAAf,GAAwB,CAAzB,CAAd,KAA8CN,MADhD;;QAEA,IAAI,CAACK,iBAAL,EAAwB;UACtB;UACA;QACD;;QAED,IAAID,KAAK,CAACG,MAAN,KAAiBR,UAAU,CAACE,OAAhC,EAAyC;UACvCT,gBAAgB,CAACQ,MAAD,EAAS,CAAT,CAAhB;QACD,CAFD,MAEO,IAAII,KAAK,CAACG,MAAN,KAAiBT,YAAY,CAACG,OAAlC,EAA2C;UAChDT,gBAAgB,CAACQ,MAAD,EAAS,CAAC,CAAV,CAAhB;QACD,CAFM,MAEA,IACLQ,QAAQ,KAAKJ,KAAK,CAACG,MAAnB,IACAP,MAAM,KAAKI,KAAK,CAACG,MADjB,IAEA,CAACP,MAAM,CAACS,QAAP,CAAgBL,KAAK,CAACG,MAAtB,CAHI,EAIL;UACAH,KAAK,CAACM,cAAN;UACAlB,gBAAgB,CAACQ,MAAD,EAAS,CAAT,CAAhB;QACD;MACF,CApBD;;MAsBAQ,QAAQ,CAACG,gBAAT,CAA0B,SAA1B,EAAqCR,QAArC;MACA,OAAO,YAAM;QACXK,QAAQ,CAACI,mBAAT,CAA6B,SAA7B,EAAwCT,QAAxC,EADW,CAGX;;QACAV,cAAc,CAACoB,GAAf;MACD,CALD;IAMD,CAlCa,CAmCd;;EACD,CApCQ,EAoCN,CAAChB,OAAD,CApCM,CAAT;AAqCD"}
|
package/build/esm/List/List.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ElementType, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
export interface ListProps extends HTMLAttributes<HTMLUListElement> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
children?: ReactNode;
|
|
6
|
-
}
|
|
7
|
-
export declare const List: import("react").ForwardRefExoticComponent<ListProps & import("react").RefAttributes<HTMLUListElement>>;
|
|
1
|
+
import type { ElementType, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface ListProps extends HTMLAttributes<HTMLUListElement> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const List: import("react").ForwardRefExoticComponent<ListProps & import("react").RefAttributes<HTMLUListElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","names":["forwardRef","List","props","forwardedRef","as","Comp","otherProps"],"sources":["../../../src/List/List.tsx"],"sourcesContent":["import type { ElementType, HTMLAttributes, ReactNode } from 'react';\
|
|
1
|
+
{"version":3,"file":"List.js","names":["forwardRef","List","props","forwardedRef","as","Comp","otherProps"],"sources":["../../../src/List/List.tsx"],"sourcesContent":["import type { ElementType, HTMLAttributes, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nexport interface ListProps extends HTMLAttributes<HTMLUListElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport const List = forwardRef<HTMLUListElement, ListProps>(function List(\n props,\n forwardedRef\n) {\n const { as: Comp = 'ul', ...otherProps } = props;\n\n return <Comp ref={forwardedRef} {...otherProps} />;\n});\n"],"mappings":";;;AACA,SAASA,UAAT,QAA2B,OAA3B;;AAQA,OAAO,IAAMC,IAAI,gBAAGD,UAAU,CAA8B,SAASC,IAAT,CAC1DC,KAD0D,EAE1DC,YAF0D,EAG1D;EACA,gBAA2CD,KAA3C,CAAQE,EAAR;EAAA,IAAYC,IAAZ,0BAAmB,IAAnB;EAAA,IAA4BC,UAA5B,4BAA2CJ,KAA3C;;EAEA,oBAAO,KAAC,IAAD;IAAM,GAAG,EAAEC;EAAX,GAA6BG,UAA7B,EAAP;AACD,CAP6B,CAAvB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ElementType, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
export interface ListItemProps extends HTMLAttributes<HTMLLIElement> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
children?: ReactNode;
|
|
6
|
-
}
|
|
7
|
-
export declare const ListItem: import("react").ForwardRefExoticComponent<ListItemProps & import("react").RefAttributes<HTMLLIElement>>;
|
|
1
|
+
import type { ElementType, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface ListItemProps extends HTMLAttributes<HTMLLIElement> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const ListItem: import("react").ForwardRefExoticComponent<ListItemProps & import("react").RefAttributes<HTMLLIElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.js","names":["forwardRef","ListItem","props","forwardedRef","as","Comp","otherProps"],"sources":["../../../src/List/ListItem.tsx"],"sourcesContent":["import type { ElementType, HTMLAttributes, ReactNode } from 'react';\
|
|
1
|
+
{"version":3,"file":"ListItem.js","names":["forwardRef","ListItem","props","forwardedRef","as","Comp","otherProps"],"sources":["../../../src/List/ListItem.tsx"],"sourcesContent":["import type { ElementType, HTMLAttributes, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nexport interface ListItemProps extends HTMLAttributes<HTMLLIElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport const ListItem = forwardRef<HTMLLIElement, ListItemProps>(\n function ListItem(props, forwardedRef) {\n const { as: Comp = 'li', ...otherProps } = props;\n\n return (\n <Comp\n tabIndex={-1}\n data-list-item=\"\"\n ref={forwardedRef}\n {...otherProps}\n />\n );\n }\n);\n"],"mappings":";;;AACA,SAASA,UAAT,QAA2B,OAA3B;;AAQA,OAAO,IAAMC,QAAQ,gBAAGD,UAAU,CAChC,SAASC,QAAT,CAAkBC,KAAlB,EAAyBC,YAAzB,EAAuC;EACrC,gBAA2CD,KAA3C,CAAQE,EAAR;EAAA,IAAYC,IAAZ,0BAAmB,IAAnB;EAAA,IAA4BC,UAA5B,4BAA2CJ,KAA3C;;EAEA,oBACE,KAAC,IAAD;IACE,QAAQ,EAAE,CAAC,CADb;IAEE,kBAAe,EAFjB;IAGE,GAAG,EAAEC;EAHP,GAIMG,UAJN,EADF;AAQD,CAZ+B,CAA3B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface ListContextProps {
|
|
2
|
-
id: string | undefined;
|
|
3
|
-
}
|
|
4
|
-
export declare const useListContext: () => ListContextProps;
|
|
1
|
+
export interface ListContextProps {
|
|
2
|
+
id: string | undefined;
|
|
3
|
+
}
|
|
4
|
+
export declare const useListContext: () => ListContextProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":["createContext","useContext","ListContext","displayName","useListContext","ctx","Error"],"sources":["../../../src/List/context.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\
|
|
1
|
+
{"version":3,"file":"context.js","names":["createContext","useContext","ListContext","displayName","useListContext","ctx","Error"],"sources":["../../../src/List/context.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\n// List Component\nexport interface ListContextProps {\n id: string | undefined;\n}\n\nconst ListContext = createContext<ListContextProps | null>(null);\nListContext.displayName = 'ListContext';\n\nexport const useListContext = (): ListContextProps => {\n const ctx = useContext(ListContext);\n if (!ctx) {\n throw new Error(\n 'useListContext must be used within a ListContext.Provider'\n );\n }\n return ctx;\n};\n"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C,C,CAEA;;AAKA,IAAMC,WAAW,gBAAGF,aAAa,CAA0B,IAA1B,CAAjC;AACAE,WAAW,CAACC,WAAZ,GAA0B,aAA1B;AAEA,OAAO,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,GAAwB;EACpD,IAAMC,GAAG,GAAGJ,UAAU,CAACC,WAAD,CAAtB;;EACA,IAAI,CAACG,GAAL,EAAU;IACR,MAAM,IAAIC,KAAJ,CACJ,2DADI,CAAN;EAGD;;EACD,OAAOD,GAAP;AACD,CARM"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './List';
|
|
2
|
-
export * from './ListItem';
|
|
1
|
+
export * from './List';
|
|
2
|
+
export * from './ListItem';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/List/index.ts"],"sourcesContent":["export * from './List';\
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/List/index.ts"],"sourcesContent":["export * from './List';\nexport * from './ListItem';\n"],"mappings":"AAAA,cAAc,QAAd;AACA,cAAc,YAAd"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { ElementType, HTMLAttributes } from 'react';
|
|
2
|
-
export declare type ContextMenuTriggerProps = HTMLAttributes<HTMLElement> & {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare const ContextMenuTrigger: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLElement> & {
|
|
8
|
-
as?: ElementType<any> | undefined;
|
|
9
|
-
innerAs?: ElementType<any> | undefined;
|
|
10
|
-
disabled?: boolean | undefined;
|
|
11
|
-
} & import("react").RefAttributes<HTMLElement>>;
|
|
1
|
+
import type { ElementType, HTMLAttributes } from 'react';
|
|
2
|
+
export declare type ContextMenuTriggerProps = HTMLAttributes<HTMLElement> & {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const ContextMenuTrigger: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLElement> & {
|
|
8
|
+
as?: ElementType<any> | undefined;
|
|
9
|
+
innerAs?: ElementType<any> | undefined;
|
|
10
|
+
disabled?: boolean | undefined;
|
|
11
|
+
} & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenuTrigger.js","names":["forwardRef","useId","useMenuContext","wrapEvent","ContextMenuTrigger","props","forwardedRef","as","Comp","innerAs","preferredId","id","onContextMenu","disabled","otherProps","menuListIdRef","open","buttonRef","onChange","setOffsetFn","isContextMenu","idGenerated","handleContextMenu","e","rect","currentTarget","getBoundingClientRect","current","mouseX","nativeEvent","x","mouseY","y","reference","height","preventDefault","undefined"],"sources":["../../../src/Menu/ContextMenuTrigger.tsx"],"sourcesContent":["import type {\
|
|
1
|
+
{"version":3,"file":"ContextMenuTrigger.js","names":["forwardRef","useId","useMenuContext","wrapEvent","ContextMenuTrigger","props","forwardedRef","as","Comp","innerAs","preferredId","id","onContextMenu","disabled","otherProps","menuListIdRef","open","buttonRef","onChange","setOffsetFn","isContextMenu","idGenerated","handleContextMenu","e","rect","currentTarget","getBoundingClientRect","current","mouseX","nativeEvent","x","mouseY","y","reference","height","preventDefault","undefined"],"sources":["../../../src/Menu/ContextMenuTrigger.tsx"],"sourcesContent":["import type {\n ElementType,\n HTMLAttributes,\n MouseEvent as ReactMouseEvent,\n} from 'react';\nimport { forwardRef, useId } from 'react';\n\nimport { useMenuContext } from './context';\nimport { wrapEvent } from '../utils/wrap-event';\nimport type { OffsetsFunction } from '../Popper';\n\nexport type ContextMenuTriggerProps = HTMLAttributes<HTMLElement> & {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n disabled?: boolean;\n};\n\nexport const ContextMenuTrigger = forwardRef<\n HTMLElement,\n ContextMenuTriggerProps\n>(function ContextMenuTrigger(props, forwardedRef) {\n const {\n as: Comp = 'div',\n innerAs,\n id: preferredId,\n onContextMenu,\n disabled,\n ...otherProps\n } = props;\n const {\n menuListIdRef,\n open,\n buttonRef,\n onChange,\n setOffsetFn,\n isContextMenu,\n } = useMenuContext();\n\n const idGenerated = useId();\n const id = preferredId || idGenerated;\n\n const handleContextMenu = (e: ReactMouseEvent<HTMLElement>) => {\n if (disabled) {\n return;\n }\n const rect = e.currentTarget.getBoundingClientRect();\n isContextMenu.current = true;\n\n buttonRef.current = e.currentTarget;\n onChange(e, true);\n\n const mouseX = e.nativeEvent.x;\n const mouseY = e.nativeEvent.y;\n setOffsetFn(\n (): OffsetsFunction =>\n ({ reference }) =>\n [mouseX - rect.x, mouseY - rect.y - reference.height]\n );\n e.preventDefault();\n };\n\n return (\n <Comp\n ref={forwardedRef}\n as={innerAs}\n id={id}\n aria-haspopup={true}\n aria-controls={menuListIdRef.current}\n aria-expanded={open ? true : undefined}\n data-menu-trigger=\"\"\n onContextMenu={wrapEvent(onContextMenu, handleContextMenu)}\n disabled={disabled}\n {...otherProps}\n />\n );\n});\n"],"mappings":";;;AAKA,SAASA,UAAT,EAAqBC,KAArB,QAAkC,OAAlC;AAEA,SAASC,cAAT,QAA+B,WAA/B;AACA,SAASC,SAAT,QAA0B,qBAA1B;;AASA,OAAO,IAAMC,kBAAkB,gBAAGJ,UAAU,CAG1C,SAASI,kBAAT,CAA4BC,KAA5B,EAAmCC,YAAnC,EAAiD;EACjD,gBAOID,KAPJ,CACEE,EADF;EAAA,IACMC,IADN,0BACa,KADb;EAAA,IAEEC,OAFF,GAOIJ,KAPJ,CAEEI,OAFF;EAAA,IAGMC,WAHN,GAOIL,KAPJ,CAGEM,EAHF;EAAA,IAIEC,aAJF,GAOIP,KAPJ,CAIEO,aAJF;EAAA,IAKEC,QALF,GAOIR,KAPJ,CAKEQ,QALF;EAAA,IAMKC,UANL,4BAOIT,KAPJ;;EAQA,sBAOIH,cAAc,EAPlB;EAAA,IACEa,aADF,mBACEA,aADF;EAAA,IAEEC,IAFF,mBAEEA,IAFF;EAAA,IAGEC,SAHF,mBAGEA,SAHF;EAAA,IAIEC,QAJF,mBAIEA,QAJF;EAAA,IAKEC,WALF,mBAKEA,WALF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ent, PointerEvent, ReactNode, ElementType } from 'react';
|
|
2
|
-
export interface MenuProps {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
children?: ReactNode;
|
|
6
|
-
onChange?: (e: KeyboardEvent<HTMLElement> | MouseEvent<HTMLElement> | PointerEvent<HTMLElement>, isOpen: boolean) => void;
|
|
7
|
-
open?: boolean;
|
|
8
|
-
defaultOpen?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare const Menu: import("react").ForwardRefExoticComponent<MenuProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
1
|
+
import type { KeyboardEvent, MouseEvent, PointerEvent, ReactNode, ElementType } from 'react';
|
|
2
|
+
export interface MenuProps {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
onChange?: (e: KeyboardEvent<HTMLElement> | MouseEvent<HTMLElement> | PointerEvent<HTMLElement>, isOpen: boolean) => void;
|
|
7
|
+
open?: boolean;
|
|
8
|
+
defaultOpen?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const Menu: import("react").ForwardRefExoticComponent<MenuProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.js","names":["useState","forwardRef","useRef","Fragment","useId","MenuProvider","useControlledState","Menu","props","forwardedRef","as","Comp","innerAs","openProp","open","defaultOpen","onChangeProp","onChange","otherProps","menuListIdRef","openWithArrowKeyRef","buttonRef","setState","e","isOpen","undefined","offsetFn","setOffsetFn","current","isContextMenu","value"],"sources":["../../../src/Menu/Menu.tsx"],"sourcesContent":["import type {\
|
|
1
|
+
{"version":3,"file":"Menu.js","names":["useState","forwardRef","useRef","Fragment","useId","MenuProvider","useControlledState","Menu","props","forwardedRef","as","Comp","innerAs","openProp","open","defaultOpen","onChangeProp","onChange","otherProps","menuListIdRef","openWithArrowKeyRef","buttonRef","setState","e","isOpen","undefined","offsetFn","setOffsetFn","current","isContextMenu","value"],"sources":["../../../src/Menu/Menu.tsx"],"sourcesContent":["import type {\n KeyboardEvent,\n MouseEvent,\n PointerEvent,\n ReactNode,\n ElementType,\n} from 'react';\nimport { useState, forwardRef, useRef, Fragment, useId } from 'react';\n\nimport type { MenuContextProps } from './context';\nimport { MenuProvider } from './context';\nimport { useControlledState } from '../hooks';\nimport type { OffsetsFunction } from '../Popper';\n\nexport interface MenuProps {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n onChange?: (\n e:\n | KeyboardEvent<HTMLElement>\n | MouseEvent<HTMLElement>\n | PointerEvent<HTMLElement>,\n isOpen: boolean\n ) => void;\n open?: boolean;\n defaultOpen?: boolean;\n}\n\nexport const Menu = forwardRef<HTMLDivElement, MenuProps>(function Menu(\n props,\n forwardedRef\n) {\n const {\n as: Comp = Fragment,\n innerAs,\n open: openProp,\n defaultOpen = false,\n onChange: onChangeProp,\n ...otherProps\n } = props;\n const menuListIdRef = useRef<string>();\n const openWithArrowKeyRef = useRef<'ArrowUp' | 'ArrowDown' | null>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const [open, onChange] = useControlledState(\n openProp,\n onChangeProp,\n defaultOpen,\n (setState) => (e, isOpen) => {\n setState(isOpen);\n }\n );\n const [offsetFn, setOffsetFn] = useState<OffsetsFunction | undefined>(\n undefined\n );\n menuListIdRef.current = useId();\n const isContextMenu = useRef(false);\n\n if (!open && offsetFn) {\n setOffsetFn(undefined);\n }\n\n const value: MenuContextProps = {\n menuListIdRef,\n openWithArrowKeyRef,\n open,\n onChange,\n buttonRef,\n offsetFn,\n setOffsetFn,\n isContextMenu,\n };\n\n return (\n <MenuProvider value={value}>\n <Comp\n {...(Comp !== Fragment ? { as: innerAs } : {})}\n ref={forwardedRef}\n {...otherProps}\n />\n </MenuProvider>\n );\n});\n"],"mappings":";;;;AAOA,SAASA,QAAT,EAAmBC,UAAnB,EAA+BC,MAA/B,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8B;IAE9BC,mBAAmB,EAAnBA,mBAF8B;IAG9BN,IAAI,EAAJA,IAH8B;IAI9BG,QAAQ,EAARA,QAJ8B;IAK9BI,SAAS,EAATA,SAL8B;IAM9BK,QAAQ,EAARA,QAN8B;IAO9BC,WAAW,EAAXA,WAP8B;IAQ9BE,aAAa,EAAbA;EAR8B,CAAhC;EAWA,oBACE,KAAC,YAAD;IAAc,KAAK,EAAEC,KAArB;IAAA,uBACE,KAAC,IAAD,wBACOnB,IAAI,KAAKR,QAAT,GAAoB;MAAEO,EAAE,EAAEE;IAAN,CAApB,GAAsC,EAD7C;MAEE,GAAG,EAAEH;IAFP,GAGMS,UAHN;EADF,EADF;AASD,CArD6B,CAAvB"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { ButtonHTMLAttributes, ElementType, KeyboardEvent, MouseEvent } from 'react';
|
|
2
|
-
export declare type MenuButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
onClick?: (e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>) => void;
|
|
6
|
-
};
|
|
7
|
-
export declare const MenuButton: import("react").ForwardRefExoticComponent<ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
8
|
-
as?: ElementType<any> | undefined;
|
|
9
|
-
innerAs?: ElementType<any> | undefined;
|
|
10
|
-
onClick?: ((e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>) => void) | undefined;
|
|
11
|
-
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
1
|
+
import type { ButtonHTMLAttributes, ElementType, KeyboardEvent, MouseEvent } from 'react';
|
|
2
|
+
export declare type MenuButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
onClick?: (e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const MenuButton: import("react").ForwardRefExoticComponent<ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
8
|
+
as?: ElementType<any> | undefined;
|
|
9
|
+
innerAs?: ElementType<any> | undefined;
|
|
10
|
+
onClick?: ((e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>) => void) | undefined;
|
|
11
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuButton.js","names":["forwardRef","useId","useMenuContext","wrapEvent","MenuButton","props","forwardedRef","as","Comp","innerAs","preferredId","id","onClick","onKeyDown","disabled","otherProps","menuListIdRef","openWithArrowKeyRef","open","buttonRef","onChange","buttonIdGenerated","buttonId","handleKeyDown","e","current","currentTarget","isArrowKey","includes","key","isEnterKey","openedWithArrow","preventDefault","handleClick","undefined"],"sources":["../../../src/Menu/MenuButton.tsx"],"sourcesContent":["import type {\
|
|
1
|
+
{"version":3,"file":"MenuButton.js","names":["forwardRef","useId","useMenuContext","wrapEvent","MenuButton","props","forwardedRef","as","Comp","innerAs","preferredId","id","onClick","onKeyDown","disabled","otherProps","menuListIdRef","openWithArrowKeyRef","open","buttonRef","onChange","buttonIdGenerated","buttonId","handleKeyDown","e","current","currentTarget","isArrowKey","includes","key","isEnterKey","openedWithArrow","preventDefault","handleClick","undefined"],"sources":["../../../src/Menu/MenuButton.tsx"],"sourcesContent":["import type {\n ButtonHTMLAttributes,\n ElementType,\n KeyboardEvent,\n MouseEvent,\n} from 'react';\nimport { forwardRef, useId } from 'react';\n\nimport { useMenuContext } from './context';\nimport { wrapEvent } from '../utils/wrap-event';\n\nexport type MenuButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n onClick?: (\n e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>\n ) => void;\n};\n\nexport const MenuButton = forwardRef<HTMLButtonElement, MenuButtonProps>(\n function MenuButton(props, forwardedRef) {\n const {\n as: Comp = 'button',\n innerAs,\n id: preferredId,\n onClick,\n onKeyDown,\n disabled,\n ...otherProps\n } = props;\n const { menuListIdRef, openWithArrowKeyRef, open, buttonRef, onChange } =\n useMenuContext();\n\n const buttonIdGenerated = useId();\n const buttonId = preferredId || buttonIdGenerated;\n\n const handleKeyDown = (e: KeyboardEvent<HTMLButtonElement>) => {\n if (disabled) {\n return;\n }\n buttonRef.current = e.currentTarget;\n\n const isArrowKey = () => ['ArrowUp', 'ArrowDown'].includes(e.key);\n const isEnterKey = () => [' ', 'Enter'].includes(e.key);\n\n const openedWithArrow = isArrowKey();\n if (openedWithArrow || isEnterKey()) {\n if (openedWithArrow) {\n // Used to make it open at the end or begining of the list\n openWithArrowKeyRef.current = e.key;\n }\n onChange(e, true);\n e.preventDefault();\n }\n };\n\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n if (disabled) {\n return;\n }\n buttonRef.current = e.currentTarget;\n onChange(e, !open);\n };\n\n return (\n <Comp\n ref={forwardedRef}\n as={innerAs}\n id={buttonId}\n role=\"button\"\n type=\"button\"\n aria-haspopup={true}\n aria-controls={menuListIdRef.current}\n aria-expanded={open ? true : undefined}\n data-menu-button=\"\"\n onClick={wrapEvent(onClick, handleClick)}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n disabled={disabled}\n {...otherProps}\n />\n );\n }\n);\n"],"mappings":";;;AAMA,SAASA,UAAT,EAAqBC,KAArB,QAAkC,OAAlC;AAEA,SAASC,cAAT,QAA+B,WAA/B;AACA,SAASC,SAAT,QAA0B,qBAA1B;;AAUA,OAAO,IAAMC,UAAU,gBAAGJ,UAAU,CAClC,SAASI,UAAT,CAAoBC,KAApB,EAA2BC,YAA3B,EAAyC;EACvC,gBAQID,KARJ,CACEE,EADF;EAAA,IACMC,IADN,0BACa,QADb;EAAA,IAEEC,OAFF,GAQIJ,KARJ,CAEEI,OAFF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,WAAW,GAAG,SAAdA,WAAc,CAACT,CAAD,EAAsC;IACxD,IAAIV,QAAJ,EAAc;MACZ;IACD;;IACDK,SAAS,CAACM,OAAV,GAAoBD,CAAC,CAACE,aAAtB;IACAN,QAAQ,CAACI,CAAD,EAAI,CAACN,IAAL,CAAR;EACD,CAND;;EAQA,oBACE,KAAC,IAAD;IACE,GAAG,EAAEZ,YADP;IAEE,EAAE,EAAEG,OAFN;IAGE,EAAE,EAAEa,QAHN;IAIE,IAAI,EAAC,QAJP;IAKE,IAAI,EAAC,QALP;IAME,iBAAe,IANjB;IAOE,iBAAeN,aAAa,CAACS,OAP/B;IAQE,iBAAeP,IAAI,GAAG,IAAH,GAAUgB,SAR/B;IASE,oBAAiB,EATnB;IAUE,OAAO,EAAE/B,SAAS,CAACS,OAAD,EAAUqB,WAAV,CAVpB;IAWE,SAAS,EAAE9B,SAAS,CAACU,SAAD,EAAYU,aAAZ,CAXtB;IAYE,QAAQ,EAAET;EAZZ,GAaMC,UAbN,EADF;AAiBD,CA9DiC,CAA7B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { LiHTMLAttributes, ElementType, MouseEvent, KeyboardEvent } from 'react';
|
|
2
|
-
export interface MenuItemProps extends LiHTMLAttributes<HTMLLIElement> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
onSelect?: (e: MouseEvent<HTMLLIElement> | KeyboardEvent<HTMLLIElement>) => void;
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare const MenuItem: import("react").ForwardRefExoticComponent<MenuItemProps & import("react").RefAttributes<any>>;
|
|
1
|
+
import type { LiHTMLAttributes, ElementType, MouseEvent, KeyboardEvent } from 'react';
|
|
2
|
+
export interface MenuItemProps extends LiHTMLAttributes<HTMLLIElement> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
onSelect?: (e: MouseEvent<HTMLLIElement> | KeyboardEvent<HTMLLIElement>) => void;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const MenuItem: import("react").ForwardRefExoticComponent<MenuItemProps & import("react").RefAttributes<any>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuItem.js","names":["forwardRef","useRef","useId","useMenuContext","useMenuListContext","assignMultipleRefs","wrapEvent","MenuItem","props","forwardedRef","as","Comp","innerAs","disabled","onSelect","onClick","onKeyDown","otherProps","onChange","buttonRef","navigationItem","onNavigate","ref","itemId","isActive","current","handleSelect","e","focus","preventDefault","handleClick","handleKeyDown","key","undefined"],"sources":["../../../src/Menu/MenuItem.tsx"],"sourcesContent":["import type {\
|
|
1
|
+
{"version":3,"file":"MenuItem.js","names":["forwardRef","useRef","useId","useMenuContext","useMenuListContext","assignMultipleRefs","wrapEvent","MenuItem","props","forwardedRef","as","Comp","innerAs","disabled","onSelect","onClick","onKeyDown","otherProps","onChange","buttonRef","navigationItem","onNavigate","ref","itemId","isActive","current","handleSelect","e","focus","preventDefault","handleClick","handleKeyDown","key","undefined"],"sources":["../../../src/Menu/MenuItem.tsx"],"sourcesContent":["import type {\n LiHTMLAttributes,\n ElementType,\n MouseEvent,\n KeyboardEvent,\n KeyboardEventHandler,\n} from 'react';\nimport { forwardRef, useRef, useId } from 'react';\n\nimport { useMenuContext, useMenuListContext } from './context';\nimport { assignMultipleRefs } from '../utils/assign-ref';\nimport { wrapEvent } from '../utils';\n\nexport interface MenuItemProps extends LiHTMLAttributes<HTMLLIElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n onSelect?: (\n e: MouseEvent<HTMLLIElement> | KeyboardEvent<HTMLLIElement>\n ) => void;\n disabled?: boolean;\n}\n\nexport const MenuItem = forwardRef<any, MenuItemProps>(function MenuItem(\n props,\n forwardedRef\n) {\n const {\n as: Comp = 'li',\n innerAs,\n disabled,\n onSelect,\n onClick,\n onKeyDown,\n ...otherProps\n } = props;\n const { onChange, buttonRef } = useMenuContext();\n const { navigationItem, onNavigate } = useMenuListContext();\n const ref = useRef<HTMLLIElement>();\n const itemId = useId();\n\n const isActive = ref.current && ref.current === navigationItem;\n\n const handleSelect = wrapEvent(\n onSelect,\n (e: KeyboardEvent<HTMLLIElement> | MouseEvent<HTMLLIElement>) => {\n onChange(e, false);\n buttonRef.current?.focus();\n e.preventDefault();\n }\n );\n\n const handleClick = (e: MouseEvent<HTMLLIElement>) => {\n if (!disabled) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n onNavigate && onNavigate(ref.current!);\n handleSelect(e);\n }\n };\n\n const handleKeyDown: KeyboardEventHandler<HTMLLIElement> = (e) => {\n switch (e.key) {\n case ' ':\n case 'Enter':\n if (!disabled) {\n handleSelect(e);\n }\n break;\n }\n };\n\n return (\n <Comp\n ref={assignMultipleRefs(ref, forwardedRef)}\n as={innerAs}\n id={disabled ? undefined : itemId}\n data-menu-item=\"\"\n data-highlighted={isActive ? '' : undefined}\n role=\"menuitem\"\n onClick={wrapEvent(onClick, handleClick)}\n tabIndex={disabled ? -1 : 0}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n data-disabled={disabled ? '' : undefined}\n aria-disabled={disabled ? '' : undefined}\n disabled={disabled}\n {...otherProps}\n />\n );\n});\n"],"mappings":";;;AAOA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,KAA7B,QAA0C,OAA1C;AAEA,SAASC,cAAT,EAAyBC,kBAAzB,QAAmD,WAAnD;AACA,SAASC,kBAAT,QAAmC,qBAAnC;AACA,SAASC,SAAT,QAA0B,UAA1B;;AAWA,OAAO,IAAMC,QAAQ,gBAAGP,UAAU,CAAqB,SAASO,QAAT,CACrDC,KADqD,EAErDC,YAFqD,EAGrD;EACA,gBAQID,KARJ,CACEE,EADF;EAAA,IACMC,IADN,0BACa,IADb;EAAA,IAEEC,OAFF,GAQIJ,KARJ,CAEEI,OAFF;EAAA,IAGEC,QAHF,GAQIL,KAR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AEtB,kBAAkB,CAACiB,GAAD,EAAMb,YAAN,CADzB;IAEE,EAAE,EAAEG,OAFN;IAGE,EAAE,EAAEC,QAAQ,GAAGoB,SAAH,GAAeV,MAH7B;IAIE,kBAAe,EAJjB;IAKE,oBAAkBC,QAAQ,GAAG,EAAH,GAAQS,SALpC;IAME,IAAI,EAAC,UANP;IAOE,OAAO,EAAE3B,SAAS,CAACS,OAAD,EAAUe,WAAV,CAPpB;IAQE,QAAQ,EAAEjB,QAAQ,GAAG,CAAC,CAAJ,GAAQ,CAR5B;IASE,SAAS,EAAEP,SAAS,CAACU,SAAD,EAAYe,aAAZ,CATtB;IAUE,iBAAelB,QAAQ,GAAG,EAAH,GAAQoB,SAVjC;IAWE,iBAAepB,QAAQ,GAAG,EAAH,GAAQoB,SAXjC;IAYE,QAAQ,EAAEpB;EAZZ,GAaMI,UAbN,EADF;AAiBD,CAjEiC,CAA3B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { HTMLAttributes, ElementType } from 'react';
|
|
2
|
-
export interface MenuListProps extends HTMLAttributes<HTMLUListElement> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
defaultActiveItemValue?: string | string[];
|
|
6
|
-
}
|
|
7
|
-
export declare const MenuList: import("react").ForwardRefExoticComponent<MenuListProps & import("react").RefAttributes<HTMLUListElement>>;
|
|
1
|
+
import type { HTMLAttributes, ElementType } from 'react';
|
|
2
|
+
export interface MenuListProps extends HTMLAttributes<HTMLUListElement> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
defaultActiveItemValue?: string | string[];
|
|
6
|
+
}
|
|
7
|
+
export declare const MenuList: import("react").ForwardRefExoticComponent<MenuListProps & import("react").RefAttributes<HTMLUListElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuList.js","names":["useCallback","forwardRef","useEffect","useRef","useState","useLayoutEffect","useMenuContext","MenuListProvider","assignMultipleRefs","useOnClickOutside","useScope","queryScope","getCircularIndex","wrapEvent","useEnhancedEffect","window","MenuList","props","forwardedRef","as","Comp","innerAs","onKeyDown","preferredId","id","defaultActiveItemValue","otherProps","interactedOutside","itemSearchStr","itemSearchClearTimeout","menuListIdRef","buttonRef","onChange","openWithArrowKeyRef","open","isContextMenu","navigationItem","setNavigationItem","mounted","setMounted","menuListRef","scope","onNavigate","el","focus","current","allItems","queryAllNodes","index","length","i","dataset","value","Array","isArray","set","Set","val","has","handleClickOutside","e","pointerType","button","target","HTMLElement","contains","preventDefault","handleKeyDown","key","currentIndex","findIndex","nextIndex","ctrlKey","altKey","slice","clearTimeout","setTimeout","searchStr","idx","dom","domText","innerText","toLowerCase","startsWith"],"sources":["../../../src/Menu/MenuList.tsx"],"sourcesContent":["import type { HTMLAttributes, ElementType, KeyboardEvent } from 'react';\r\nimport {\r\n useCallback,\r\n forwardRef,\r\n useEffect,\r\n useRef,\r\n useState,\r\n useLayoutEffect,\r\n} from 'react';\r\n\r\nimport { useMenuContext, MenuListProvider } from './context';\r\nimport { assignMultipleRefs } from '../utils/assign-ref';\r\nimport { useOnClickOutside } from '../hooks/useOnClickOutside';\r\nimport { useScope } from '../hooks';\r\nimport { queryScope } from './scope';\r\nimport { getCircularIndex, wrapEvent } from '../utils';\r\n\r\nconst useEnhancedEffect =\r\n typeof window !== 'undefined' ? useLayoutEffect : useEffect;\r\n\r\nexport interface MenuListProps extends HTMLAttributes<HTMLUListElement> {\r\n as?: ElementType<any>;\r\n innerAs?: ElementType<any>;\r\n defaultActiveItemValue?: string | string[];\r\n}\r\n\r\nexport const MenuList = forwardRef<HTMLUListElement, MenuListProps>(\r\n function MenuList(props, forwardedRef) {\r\n const {\r\n as: Comp = 'ul',\r\n innerAs,\r\n onKeyDown,\r\n id: preferredId,\r\n defaultActiveItemValue,\r\n ...otherProps\r\n } = props;\r\n\r\n const interactedOutside = useRef(false);\r\n const itemSearchStr = useRef('');\r\n const itemSearchClearTimeout = useRef<ReturnType<typeof setTimeout>>();\r\n\r\n const {\r\n menuListIdRef,\r\n buttonRef,\r\n onChange,\r\n openWithArrowKeyRef,\r\n open,\r\n isContextMenu,\r\n } = useMenuContext();\r\n\r\n const [navigationItem, setNavigationItem] = useState<\r\n HTMLElement | undefined\r\n >();\r\n\r\n const [mounted, setMounted] = useState(false);\r\n\r\n const menuListRef = useRef<HTMLUListElement>();\r\n\r\n const scope = useScope<HTMLLIElement, HTMLUListElement>(menuListRef);\r\n\r\n const onNavigate = (el: HTMLElement) => {\r\n el.focus();\r\n setNavigationItem(el);\r\n };\r\n\r\n menuListIdRef.current = preferredId || menuListIdRef.current;\r\n\r\n useEnhancedEffect(() => {\r\n if (!mounted) {\r\n const allItems = scope.current.queryAllNodes(queryScope);\r\n let index = getCircularIndex(\r\n openWithArrowKeyRef.current === 'ArrowUp' ? -1 : 0,\r\n allItems.length\r\n );\r\n\r\n if (defaultActiveItemValue) {\r\n if (typeof defaultActiveItemValue === 'string') {\r\n for (let i = 0; i < allItems.length; i++) {\r\n if (allItems[i].dataset.value === defaultActiveItemValue) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n } else if (Array.isArray(defaultActiveItemValue)) {\r\n const set = new Set(defaultActiveItemValue);\r\n for (let i = 0; i < allItems.length; i++) {\r\n const val = allItems[i].dataset.value;\r\n if (val && set.has(val)) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (index !== null) {\r\n onNavigate && onNavigate(allItems[index]);\r\n }\r\n }\r\n\r\n openWithArrowKeyRef.current = null;\r\n setMounted(true);\r\n }, [\r\n mounted,\r\n navigationItem,\r\n onNavigate,\r\n openWithArrowKeyRef,\r\n scope,\r\n defaultActiveItemValue,\r\n ]);\r\n\r\n const handleClickOutside = useCallback(\r\n (e: PointerEvent) => {\r\n if (isContextMenu.current) {\r\n if (!interactedOutside.current && e.pointerType === 'touch') {\r\n // First interaction should be ignored, because\r\n // this is what triggered the context menu to open\r\n interactedOutside.current = true;\r\n return;\r\n }\r\n\r\n if (e.button === 0) {\r\n onChange(e as any, false);\r\n }\r\n } else {\r\n if (\r\n e.target instanceof HTMLElement &&\r\n e.target !== buttonRef.current &&\r\n !buttonRef.current?.contains(e.target)\r\n ) {\r\n onChange(e as any, false);\r\n }\r\n }\r\n e.preventDefault();\r\n },\r\n [buttonRef, isContextMenu, onChange]\r\n );\r\n\r\n useOnClickOutside(menuListRef, handleClickOutside, open);\r\n\r\n function handleKeyDown(e: KeyboardEvent<HTMLUListElement>) {\r\n switch (e.key) {\r\n case 'Escape':\r\n case 'Tab': {\r\n onChange(e, false);\r\n e.preventDefault(); // prevents focusing on next element, because we will be handling it\r\n itemSearchStr.current = '';\r\n buttonRef.current?.focus();\r\n break;\r\n }\r\n case 'Home':\r\n case 'End':\r\n case 'ArrowDown':\r\n case 'ArrowUp':\r\n e.preventDefault();\r\n itemSearchStr.current = '';\r\n const allItems = scope ? scope.current.queryAllNodes(queryScope) : [];\r\n const currentIndex = allItems.findIndex((e) => e === navigationItem);\r\n if (allItems.length === 0) {\r\n return;\r\n }\r\n let nextIndex: number = currentIndex;\r\n switch (e.key) {\r\n case 'ArrowUp':\r\n nextIndex += -1;\r\n break;\r\n case 'ArrowDown':\r\n nextIndex += 1;\r\n break;\r\n case 'Home':\r\n nextIndex = 0;\r\n break;\r\n case 'End':\r\n nextIndex = -1;\r\n break;\r\n }\r\n // We already checked if allItems.length = 0 above\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n nextIndex = getCircularIndex(nextIndex, allItems.length)!;\r\n onNavigate && onNavigate(allItems[nextIndex]);\r\n break;\r\n default: {\r\n if (e.key.length === 1 && !e.ctrlKey && !e.altKey) {\r\n // A-Z\r\n e.preventDefault();\r\n\r\n if (\r\n itemSearchStr.current.length === 0 ||\r\n itemSearchStr.current.slice(-1) !== e.key\r\n ) {\r\n itemSearchStr.current = itemSearchStr.current + e.key;\r\n }\r\n clearTimeout(itemSearchClearTimeout.current as any);\r\n itemSearchClearTimeout.current = setTimeout(() => {\r\n itemSearchStr.current = '';\r\n }, 500);\r\n\r\n const allItems = scope\r\n ? scope.current.queryAllNodes(queryScope)\r\n : [];\r\n const currentIndex = allItems.findIndex(\r\n (e) => e === navigationItem\r\n );\r\n const searchStr = itemSearchStr.current;\r\n let nextIndex = -1;\r\n for (\r\n let i = searchStr.length === 1 ? 1 : 0;\r\n i < allItems.length;\r\n i++\r\n ) {\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n const idx = getCircularIndex(currentIndex + i, allItems.length)!;\r\n const dom = allItems[idx];\r\n const domText = dom.innerText.toLowerCase();\r\n if (domText.length > 0 && domText.startsWith(searchStr)) {\r\n nextIndex = idx;\r\n break;\r\n }\r\n }\r\n if (nextIndex >= 0 && nextIndex < allItems.length) {\r\n onNavigate && onNavigate(allItems[nextIndex]);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (!open) {\r\n interactedOutside.current = false;\r\n return null;\r\n }\r\n\r\n return (\r\n <MenuListProvider\r\n value={{\r\n navigationItem,\r\n onNavigate,\r\n }}\r\n >\r\n <Comp\r\n ref={assignMultipleRefs(forwardedRef, menuListRef)}\r\n as={innerAs}\r\n id={menuListIdRef.current}\r\n role=\"menu\"\r\n aria-labelledby={buttonRef.current?.id}\r\n data-menu-list=\"\"\r\n tabIndex=\"-1\"\r\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\r\n {...otherProps}\r\n />\r\n </MenuListProvider>\r\n );\r\n }\r\n);\r\n"],"mappings":";;;;AACA,SACEA,WADF,EAEEC,UAFF,EAGEC,SAHF,EAIEC,MAJF,EAKEC,QALF,EAMEC,eANF,QAOO,OAPP;AASA,SAASC,cAAT,EAAyBC,gBAAzB,QAAiD,WAAjD;AACA,SAASC,kBAAT,QAAmC,qBAAnC;AACA,SAASC,iBAAT,QAAkC,4BAAlC;AACA,SAASC,QAAT,QAAyB,UAAzB;AACA,SAASC,UAAT,QAA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,CAA1B,EAAyD;gBACvDN,UAAS,GAAGO,GAAZ;gBACA;cACD;YACF;;YACD,IAAIP,UAAS,IAAI,CAAb,IAAkBA,UAAS,GAAGzB,SAAQ,CAACG,MAA3C,EAAmD;cACjDP,UAAU,IAAIA,UAAU,CAACI,SAAQ,CAACyB,UAAD,CAAT,CAAxB;YACD;UACF;QACF;IAlFH;EAoFD;;EAED,IAAI,CAACrC,IAAL,EAAW;IACTP,iBAAiB,CAACkB,OAAlB,GAA4B,KAA5B;IACA,OAAO,IAAP;EACD;;EAED,oBACE,KAAC,gBAAD;IACE,KAAK,EAAE;MACLT,cAAc,EAAdA,cADK;MAELM,UAAU,EAAVA;IAFK,CADT;IAAA,uBAME,KAAC,IAAD;MACE,GAAG,EAAElC,kBAAkB,CAACU,YAAD,EAAesB,WAAf,CADzB;MAEE,EAAE,EAAEnB,OAFN;MAGE,EAAE,EAAES,aAAa,CAACe,OAHpB;MAIE,IAAI,EAAC,MAJP;MAKE,0CAAiBd,SAAS,CAACc,OAA3B,wDAAiB,oBAAmBrB,EALtC;MAME,kBAAe,EANjB;MAOE,QAAQ,EAAC,IAPX;MAQE,SAAS,EAAEX,SAAS,CAACS,SAAD,EAAY6C,aAAZ;IARtB,GASMzC,UATN;EANF,EADF;AAoBD,CAlO+B,CAA3B"}
|
|
1
|
+
{"version":3,"file":"MenuList.js","names":["useCallback","forwardRef","useEffect","useRef","useState","useLayoutEffect","useMenuContext","MenuListProvider","assignMultipleRefs","useOnClickOutside","useScope","queryScope","getCircularIndex","wrapEvent","useEnhancedEffect","window","MenuList","props","forwardedRef","as","Comp","innerAs","onKeyDown","preferredId","id","defaultActiveItemValue","otherProps","interactedOutside","itemSearchStr","itemSearchClearTimeout","menuListIdRef","buttonRef","onChange","openWithArrowKeyRef","open","isContextMenu","navigationItem","setNavigationItem","mounted","setMounted","menuListRef","scope","onNavigate","el","focus","current","allItems","queryAllNodes","index","length","i","dataset","value","Array","isArray","set","Set","val","has","handleClickOutside","e","pointerType","button","target","HTMLElement","contains","preventDefault","handleKeyDown","key","currentIndex","findIndex","nextIndex","ctrlKey","altKey","slice","clearTimeout","setTimeout","searchStr","idx","dom","domText","innerText","toLowerCase","startsWith"],"sources":["../../../src/Menu/MenuList.tsx"],"sourcesContent":["import type { HTMLAttributes, ElementType, KeyboardEvent } from 'react';\nimport {\n useCallback,\n forwardRef,\n useEffect,\n useRef,\n useState,\n useLayoutEffect,\n} from 'react';\n\nimport { useMenuContext, MenuListProvider } from './context';\nimport { assignMultipleRefs } from '../utils/assign-ref';\nimport { useOnClickOutside } from '../hooks/useOnClickOutside';\nimport { useScope } from '../hooks';\nimport { queryScope } from './scope';\nimport { getCircularIndex, wrapEvent } from '../utils';\n\nconst useEnhancedEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n\nexport interface MenuListProps extends HTMLAttributes<HTMLUListElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n defaultActiveItemValue?: string | string[];\n}\n\nexport const MenuList = forwardRef<HTMLUListElement, MenuListProps>(\n function MenuList(props, forwardedRef) {\n const {\n as: Comp = 'ul',\n innerAs,\n onKeyDown,\n id: preferredId,\n defaultActiveItemValue,\n ...otherProps\n } = props;\n\n const interactedOutside = useRef(false);\n const itemSearchStr = useRef('');\n const itemSearchClearTimeout = useRef<ReturnType<typeof setTimeout>>();\n\n const {\n menuListIdRef,\n buttonRef,\n onChange,\n openWithArrowKeyRef,\n open,\n isContextMenu,\n } = useMenuContext();\n\n const [navigationItem, setNavigationItem] = useState<\n HTMLElement | undefined\n >();\n\n const [mounted, setMounted] = useState(false);\n\n const menuListRef = useRef<HTMLUListElement>();\n\n const scope = useScope<HTMLLIElement, HTMLUListElement>(menuListRef);\n\n const onNavigate = (el: HTMLElement) => {\n el.focus();\n setNavigationItem(el);\n };\n\n menuListIdRef.current = preferredId || menuListIdRef.current;\n\n useEnhancedEffect(() => {\n if (!mounted) {\n const allItems = scope.current.queryAllNodes(queryScope);\n let index = getCircularIndex(\n openWithArrowKeyRef.current === 'ArrowUp' ? -1 : 0,\n allItems.length\n );\n\n if (defaultActiveItemValue) {\n if (typeof defaultActiveItemValue === 'string') {\n for (let i = 0; i < allItems.length; i++) {\n if (allItems[i].dataset.value === defaultActiveItemValue) {\n index = i;\n break;\n }\n }\n } else if (Array.isArray(defaultActiveItemValue)) {\n const set = new Set(defaultActiveItemValue);\n for (let i = 0; i < allItems.length; i++) {\n const val = allItems[i].dataset.value;\n if (val && set.has(val)) {\n index = i;\n break;\n }\n }\n }\n }\n\n if (index !== null) {\n onNavigate && onNavigate(allItems[index]);\n }\n }\n\n openWithArrowKeyRef.current = null;\n setMounted(true);\n }, [\n mounted,\n navigationItem,\n onNavigate,\n openWithArrowKeyRef,\n scope,\n defaultActiveItemValue,\n ]);\n\n const handleClickOutside = useCallback(\n (e: PointerEvent) => {\n if (isContextMenu.current) {\n if (!interactedOutside.current && e.pointerType === 'touch') {\n // First interaction should be ignored, because\n // this is what triggered the context menu to open\n interactedOutside.current = true;\n return;\n }\n\n if (e.button === 0) {\n onChange(e as any, false);\n }\n } else {\n if (\n e.target instanceof HTMLElement &&\n e.target !== buttonRef.current &&\n !buttonRef.current?.contains(e.target)\n ) {\n onChange(e as any, false);\n }\n }\n e.preventDefault();\n },\n [buttonRef, isContextMenu, onChange]\n );\n\n useOnClickOutside(menuListRef, handleClickOutside, open);\n\n function handleKeyDown(e: KeyboardEvent<HTMLUListElement>) {\n switch (e.key) {\n case 'Escape':\n case 'Tab': {\n onChange(e, false);\n e.preventDefault(); // prevents focusing on next element, because we will be handling it\n itemSearchStr.current = '';\n buttonRef.current?.focus();\n break;\n }\n case 'Home':\n case 'End':\n case 'ArrowDown':\n case 'ArrowUp':\n e.preventDefault();\n itemSearchStr.current = '';\n const allItems = scope ? scope.current.queryAllNodes(queryScope) : [];\n const currentIndex = allItems.findIndex((e) => e === navigationItem);\n if (allItems.length === 0) {\n return;\n }\n let nextIndex: number = currentIndex;\n switch (e.key) {\n case 'ArrowUp':\n nextIndex += -1;\n break;\n case 'ArrowDown':\n nextIndex += 1;\n break;\n case 'Home':\n nextIndex = 0;\n break;\n case 'End':\n nextIndex = -1;\n break;\n }\n // We already checked if allItems.length = 0 above\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n nextIndex = getCircularIndex(nextIndex, allItems.length)!;\n onNavigate && onNavigate(allItems[nextIndex]);\n break;\n default: {\n if (e.key.length === 1 && !e.ctrlKey && !e.altKey) {\n // A-Z\n e.preventDefault();\n\n if (\n itemSearchStr.current.length === 0 ||\n itemSearchStr.current.slice(-1) !== e.key\n ) {\n itemSearchStr.current = itemSearchStr.current + e.key;\n }\n clearTimeout(itemSearchClearTimeout.current as any);\n itemSearchClearTimeout.current = setTimeout(() => {\n itemSearchStr.current = '';\n }, 500);\n\n const allItems = scope\n ? scope.current.queryAllNodes(queryScope)\n : [];\n const currentIndex = allItems.findIndex(\n (e) => e === navigationItem\n );\n const searchStr = itemSearchStr.current;\n let nextIndex = -1;\n for (\n let i = searchStr.length === 1 ? 1 : 0;\n i < allItems.length;\n i++\n ) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const idx = getCircularIndex(currentIndex + i, allItems.length)!;\n const dom = allItems[idx];\n const domText = dom.innerText.toLowerCase();\n if (domText.length > 0 && domText.startsWith(searchStr)) {\n nextIndex = idx;\n break;\n }\n }\n if (nextIndex >= 0 && nextIndex < allItems.length) {\n onNavigate && onNavigate(allItems[nextIndex]);\n }\n }\n }\n }\n }\n\n if (!open) {\n interactedOutside.current = false;\n return null;\n }\n\n return (\n <MenuListProvider\n value={{\n navigationItem,\n onNavigate,\n }}\n >\n <Comp\n ref={assignMultipleRefs(forwardedRef, menuListRef)}\n as={innerAs}\n id={menuListIdRef.current}\n role=\"menu\"\n aria-labelledby={buttonRef.current?.id}\n data-menu-list=\"\"\n tabIndex=\"-1\"\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n {...otherProps}\n />\n </MenuListProvider>\n );\n }\n);\n"],"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,aAAY,GAAGnB,CAAhB,EAAmBJ,SAAQ,CAACG,MAA5B,CAA5B;cACA,IAAM8B,GAAG,GAAGjC,SAAQ,CAACgC,GAAD,CAApB;cACA,IAAME,OAAO,GAAGD,GAAG,CAACE,SAAJ,CAAcC,WAAd,EAAhB;;cACA,IAAIF,OAAO,CAAC/B,MAAR,GAAiB,CAAjB,IAAsB+B,OAAO,CAACG,UAAR,CAAmBN,SAAnB,CAA1B,EAAyD;gBACvDN,UAAS,GAAGO,GAAZ;gBACA;cACD;YACF;;YACD,IAAIP,UAAS,IAAI,CAAb,IAAkBA,UAAS,GAAGzB,SAAQ,CAACG,MAA3C,EAAmD;cACjDP,UAAU,IAAIA,UAAU,CAACI,SAAQ,CAACyB,UAAD,CAAT,CAAxB;YACD;UACF;QACF;IAlFH;EAoFD;;EAED,IAAI,CAACrC,IAAL,EAAW;IACTP,iBAAiB,CAACkB,OAAlB,GAA4B,KAA5B;IACA,OAAO,IAAP;EACD;;EAED,oBACE,KAAC,gBAAD;IACE,KAAK,EAAE;MACLT,cAAc,EAAdA,cADK;MAELM,UAAU,EAAVA;IAFK,CADT;IAAA,uBAME,KAAC,IAAD;MACE,GAAG,EAAElC,kBAAkB,CAACU,YAAD,EAAesB,WAAf,CADzB;MAEE,EAAE,EAAEnB,OAFN;MAGE,EAAE,EAAES,aAAa,CAACe,OAHpB;MAIE,IAAI,EAAC,MAJP;MAKE,0CAAiBd,SAAS,CAACc,OAA3B,wDAAiB,oBAAmBrB,EALtC;MAME,kBAAe,EANjB;MAOE,QAAQ,EAAC,IAPX;MAQE,SAAS,EAAEX,SAAS,CAACS,SAAD,EAAY6C,aAAZ;IARtB,GASMzC,UATN;EANF,EADF;AAoBD,CAlO+B,CAA3B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ElementType, ReactNode } from 'react';
|
|
2
|
-
import type { PopperProps } from '../Popper';
|
|
3
|
-
export interface MenuPopoverProps extends Omit<PopperProps, 'anchorEl'> {
|
|
4
|
-
as?: ElementType<any>;
|
|
5
|
-
innerAs?: ElementType<any>;
|
|
6
|
-
children?: ReactNode;
|
|
7
|
-
}
|
|
8
|
-
export declare const MenuPopover: import("react").ForwardRefExoticComponent<MenuPopoverProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
1
|
+
import type { ElementType, ReactNode } from 'react';
|
|
2
|
+
import type { PopperProps } from '../Popper';
|
|
3
|
+
export interface MenuPopoverProps extends Omit<PopperProps, 'anchorEl'> {
|
|
4
|
+
as?: ElementType<any>;
|
|
5
|
+
innerAs?: ElementType<any>;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const MenuPopover: import("react").ForwardRefExoticComponent<MenuPopoverProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuPopover.js","names":["forwardRef","Popper","useMenuContext","MenuPopover","props","forwardedRef","as","innerAs","otherProps","buttonRef","open","offsetFn","isContextMenu","current","undefined"],"sources":["../../../src/Menu/MenuPopover.tsx"],"sourcesContent":["import type { ElementType, ReactNode } from 'react';\
|
|
1
|
+
{"version":3,"file":"MenuPopover.js","names":["forwardRef","Popper","useMenuContext","MenuPopover","props","forwardedRef","as","innerAs","otherProps","buttonRef","open","offsetFn","isContextMenu","current","undefined"],"sources":["../../../src/Menu/MenuPopover.tsx"],"sourcesContent":["import type { ElementType, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nimport type { PopperProps } from '../Popper';\nimport { Popper } from '../Popper';\nimport { useMenuContext } from './context';\n\nexport interface MenuPopoverProps extends Omit<PopperProps, 'anchorEl'> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport const MenuPopover = forwardRef<HTMLDivElement, MenuPopoverProps>(\n function MenuPopover(props, forwardedRef) {\n const { as = 'div', innerAs, ...otherProps } = props;\n const { buttonRef, open, offsetFn, isContextMenu } = useMenuContext();\n\n if (!open) {\n return null;\n }\n\n return (\n <Popper\n as={as}\n innerAs={innerAs}\n ref={forwardedRef}\n anchorEl={buttonRef}\n offsetFn={offsetFn}\n placement={isContextMenu.current ? 'bottom-start' : undefined}\n {...otherProps}\n />\n );\n }\n);\n"],"mappings":";;;AACA,SAASA,UAAT,QAA2B,OAA3B;AAGA,SAASC,MAAT,QAAuB,WAAvB;AACA,SAASC,cAAT,QAA+B,WAA/B;;AAQA,OAAO,IAAMC,WAAW,gBAAGH,UAAU,CACnC,SAASG,WAAT,CAAqBC,KAArB,EAA4BC,YAA5B,EAA0C;EACxC,gBAA+CD,KAA/C,CAAQE,EAAR;EAAA,IAAQA,EAAR,0BAAa,KAAb;EAAA,IAAoBC,OAApB,GAA+CH,KAA/C,CAAoBG,OAApB;EAAA,IAAgCC,UAAhC,4BAA+CJ,KAA/C;;EACA,sBAAqDF,cAAc,EAAnE;EAAA,IAAQO,SAAR,mBAAQA,SAAR;EAAA,IAAmBC,IAAnB,mBAAmBA,IAAnB;EAAA,IAAyBC,QAAzB,mBAAyBA,QAAzB;EAAA,IAAmCC,aAAnC,mBAAmCA,aAAnC;;EAEA,IAAI,CAACF,IAAL,EAAW;IACT,OAAO,IAAP;EACD;;EAED,oBACE,KAAC,MAAD;IACE,EAAE,EAAEJ,EADN;IAEE,OAAO,EAAEC,OAFX;IAGE,GAAG,EAAEF,YAHP;IAIE,QAAQ,EAAEI,SAJZ;IAKE,QAAQ,EAAEE,QALZ;IAME,SAAS,EAAEC,aAAa,CAACC,OAAd,GAAwB,cAAxB,GAAyCC;EANtD,GAOMN,UAPN,EADF;AAWD,CApBkC,CAA9B"}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import type { OffsetsFunction } from '@popperjs/core/lib/modifiers/offset';
|
|
2
|
-
import type { Dispatch, KeyboardEvent, MouseEvent, MutableRefObject, PointerEvent, SetStateAction } from 'react';
|
|
3
|
-
export declare type ItemObject = {
|
|
4
|
-
text: string;
|
|
5
|
-
value: any;
|
|
6
|
-
id: string | undefined;
|
|
7
|
-
};
|
|
8
|
-
export interface MenuContextProps {
|
|
9
|
-
buttonRef: MutableRefObject<HTMLElement | null>;
|
|
10
|
-
menuListIdRef: MutableRefObject<undefined | string>;
|
|
11
|
-
openWithArrowKeyRef: MutableRefObject<string | null>;
|
|
12
|
-
onChange: (e: KeyboardEvent<HTMLElement> | MouseEvent<HTMLElement> | PointerEvent<HTMLElement>, isOpen: boolean) => void;
|
|
13
|
-
open: boolean;
|
|
14
|
-
offsetFn: OffsetsFunction | undefined;
|
|
15
|
-
setOffsetFn: Dispatch<SetStateAction<OffsetsFunction | undefined>>;
|
|
16
|
-
isContextMenu: MutableRefObject<boolean>;
|
|
17
|
-
}
|
|
18
|
-
export declare const MenuProvider: import("react").Provider<MenuContextProps>;
|
|
19
|
-
export declare const useMenuContext: () => MenuContextProps;
|
|
20
|
-
export interface MenuListContextProps {
|
|
21
|
-
navigationItem: HTMLElement | undefined;
|
|
22
|
-
onNavigate: undefined | ((idx: HTMLElement) => void);
|
|
23
|
-
}
|
|
24
|
-
export declare const MenuListProvider: import("react").Provider<MenuListContextProps>;
|
|
25
|
-
export declare const useMenuListContext: () => MenuListContextProps;
|
|
1
|
+
import type { OffsetsFunction } from '@popperjs/core/lib/modifiers/offset';
|
|
2
|
+
import type { Dispatch, KeyboardEvent, MouseEvent, MutableRefObject, PointerEvent, SetStateAction } from 'react';
|
|
3
|
+
export declare type ItemObject = {
|
|
4
|
+
text: string;
|
|
5
|
+
value: any;
|
|
6
|
+
id: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
export interface MenuContextProps {
|
|
9
|
+
buttonRef: MutableRefObject<HTMLElement | null>;
|
|
10
|
+
menuListIdRef: MutableRefObject<undefined | string>;
|
|
11
|
+
openWithArrowKeyRef: MutableRefObject<string | null>;
|
|
12
|
+
onChange: (e: KeyboardEvent<HTMLElement> | MouseEvent<HTMLElement> | PointerEvent<HTMLElement>, isOpen: boolean) => void;
|
|
13
|
+
open: boolean;
|
|
14
|
+
offsetFn: OffsetsFunction | undefined;
|
|
15
|
+
setOffsetFn: Dispatch<SetStateAction<OffsetsFunction | undefined>>;
|
|
16
|
+
isContextMenu: MutableRefObject<boolean>;
|
|
17
|
+
}
|
|
18
|
+
export declare const MenuProvider: import("react").Provider<MenuContextProps>;
|
|
19
|
+
export declare const useMenuContext: () => MenuContextProps;
|
|
20
|
+
export interface MenuListContextProps {
|
|
21
|
+
navigationItem: HTMLElement | undefined;
|
|
22
|
+
onNavigate: undefined | ((idx: HTMLElement) => void);
|
|
23
|
+
}
|
|
24
|
+
export declare const MenuListProvider: import("react").Provider<MenuListContextProps>;
|
|
25
|
+
export declare const useMenuListContext: () => MenuListContextProps;
|