@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spinner.js","names":["forwardRef","useState","useRef","SpinnerProvider","clamp","clampFunc","wrapEvent","assignMultipleRefs","Spinner","props","forwardedRef","as","Comp","minValue","maxValue","stepSize","value","onChange","onKeyDown","onBlur","onFocus","otherProps","spinnerHasFocus","setSpinnerHasFocus","ref","handleKeyDown","e","nextValue","key","current","focus","preventDefault","handleFocus","handleBlur"],"sources":["../../../src/Spinner/Spinner.tsx"],"sourcesContent":["import type {\
|
|
1
|
+
{"version":3,"file":"Spinner.js","names":["forwardRef","useState","useRef","SpinnerProvider","clamp","clampFunc","wrapEvent","assignMultipleRefs","Spinner","props","forwardedRef","as","Comp","minValue","maxValue","stepSize","value","onChange","onKeyDown","onBlur","onFocus","otherProps","spinnerHasFocus","setSpinnerHasFocus","ref","handleKeyDown","e","nextValue","key","current","focus","preventDefault","handleFocus","handleBlur"],"sources":["../../../src/Spinner/Spinner.tsx"],"sourcesContent":["import type {\n HTMLAttributes,\n ElementType,\n ReactNode,\n MouseEvent,\n KeyboardEvent,\n} from 'react';\nimport { forwardRef, useState, useRef } from 'react';\n\nimport { SpinnerProvider } from './context';\nimport { clamp as clampFunc } from '../utils/clamp';\nimport { wrapEvent, assignMultipleRefs } from '../utils';\n\nexport interface SpinnerProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n value?: number;\n minValue?: number;\n maxValue?: number;\n stepSize?: number;\n onChange?: (\n e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLDivElement>,\n value: number\n ) => void;\n}\n\nexport const Spinner = forwardRef<HTMLDivElement, SpinnerProps>(\n function Spinner(props, forwardedRef) {\n const {\n as: Comp = 'div',\n minValue = -1000,\n maxValue = 1000,\n stepSize = 10,\n value = 0,\n onChange,\n onKeyDown,\n onBlur,\n onFocus,\n ...otherProps\n } = props;\n const [spinnerHasFocus, setSpinnerHasFocus] = useState(false);\n const ref = useRef<HTMLDivElement>();\n\n const clamp = (value: number) => clampFunc(value, minValue, maxValue);\n\n const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n let nextValue = value;\n switch (e.key) {\n case 'ArrowUp':\n nextValue += 1;\n break;\n case 'ArrowDown':\n nextValue -= 1;\n break;\n case 'Home':\n nextValue = minValue;\n break;\n case 'End':\n nextValue = maxValue;\n break;\n case 'PageUp':\n nextValue += stepSize;\n break;\n case 'PageDown':\n nextValue -= stepSize;\n break;\n default:\n return;\n }\n\n ref.current && ref.current.focus();\n nextValue = clamp(nextValue);\n if (nextValue !== value) {\n e.preventDefault(); // prevent scrolling\n onChange && onChange(e, nextValue);\n }\n };\n\n const handleFocus = () => {\n setSpinnerHasFocus(true);\n };\n\n const handleBlur = () => {\n setSpinnerHasFocus(false);\n };\n\n return (\n <SpinnerProvider\n value={{\n minValue,\n value,\n maxValue,\n stepSize,\n onChange,\n clamp,\n spinnerHasFocus,\n }}\n >\n <Comp\n ref={assignMultipleRefs(forwardedRef, ref)}\n data-spinner-root=\"\"\n role=\"spinbutton\"\n aria-valuenow={value}\n aria-valuemin={minValue}\n aria-valuemax={maxValue}\n tabIndex={0}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n onFocus={wrapEvent(onFocus, handleFocus)}\n onBlur={wrapEvent(onBlur, handleBlur)}\n {...otherProps}\n />\n </SpinnerProvider>\n );\n }\n);\n"],"mappings":";;;;AAOA,SAASA,UAAT,EAAqBC,QAArB,EAA+BC,MAA/B,QAA6C,OAA7C;AAEA,SAASC,eAAT,QAAgC,WAAhC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,gBAAnC;AACA,SAASC,SAAT,EAAoBC,kBAApB,QAA8C,UAA9C;;AAiBA,OAAO,IAAMC,OAAO,gBAAGR,UAAU,CAC/B,SAASQ,OAAT,CAAiBC,KAAjB,EAAwBC,YAAxB,EAAsC;EACpC,gBAWID,KAXJ,CACEE,EADF;EAAA,IACMC,IADN,0BACa,KADb;EAAA,sBAWIH,KAXJ,CAEEI,QAFF;EAAA,IAEEA,QAFF,gCAEa,CAAC,IAFd;EAAA,sBAWIJ,KAXJ,CAGEK,QAHF;EAAA,IAGEA,QAHF,gCAGa,IAHb;EAAA,sBAWIL,KAXJ,CAIEM,QAJF;EAAA,IAIEA,QAJF,gCAIa,EAJb;EAAA,mBAWIN,KAXJ,CAKEO,KALF;EAAA,IAKEA,KALF,6BAKU,CALV;EAAA,IAMEC,QANF,GAWIR,KAXJ,CAMEQ,QANF;EAAA,IAOEC,SAPF,GAWIT,KAXJ,CAOES,SAPF;EAAA,IAQEC,MARF,GAWIV,KAXJ,CAQEU,MARF;EAAA,IASEC,OATF,GAWIX,KAXJ,CASEW,OATF;EAAA,IAUKC,UAVL,4BAWIZ,KAXJ;;EAYA,gBAA8CR,QAAQ,CAAC,KAAD,CAAtD;EAAA;EAAA,IAAOqB,eAAP;EAAA,IAAwBC,kBAAxB;;EACA,IAAMC,GAAG,GAAGtB,MAAM,EAAlB;;EAEA,IAAME,KAAK,GAAG,SAARA,KAAQ,CAACY,KAAD;IAAA,OAAmBX,SAAS,CAACW,KAAD,EAA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Aec,GAAf,CADzB;MAEE,qBAAkB,EAFpB;MAGE,IAAI,EAAC,YAHP;MAIE,iBAAeR,KAJjB;MAKE,iBAAeH,QALjB;MAME,iBAAeC,QANjB;MAOE,QAAQ,EAAE,CAPZ;MAQE,SAAS,EAAER,SAAS,CAACY,SAAD,EAAYO,aAAZ,CARtB;MASE,OAAO,EAAEnB,SAAS,CAACc,OAAD,EAAUY,WAAV,CATpB;MAUE,MAAM,EAAE1B,SAAS,CAACa,MAAD,EAASc,UAAT;IAVnB,GAWMZ,UAXN;EAXF,EADF;AA2BD,CAvF8B,CAA1B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ButtonHTMLAttributes, ElementType, ReactNode } from 'react';
|
|
2
|
-
export interface SpinnerButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
children?: ReactNode;
|
|
6
|
-
type: 'next' | 'previous';
|
|
7
|
-
}
|
|
8
|
-
export declare const SpinnerButton: import("react").ForwardRefExoticComponent<SpinnerButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
1
|
+
import type { ButtonHTMLAttributes, ElementType, ReactNode } from 'react';
|
|
2
|
+
export interface SpinnerButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
type: 'next' | 'previous';
|
|
7
|
+
}
|
|
8
|
+
export declare const SpinnerButton: import("react").ForwardRefExoticComponent<SpinnerButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpinnerButton.js","names":["forwardRef","useSpinnerContext","wrapEvent","SpinnerButton","props","forwardedRef","as","Comp","type","onClick","otherProps","spinnerContext","Error","handleClick","e","delta","onChange","value","disabled","maxValue","minValue","spinnerHasFocus","undefined"],"sources":["../../../src/Spinner/SpinnerButton.tsx"],"sourcesContent":["import type {\
|
|
1
|
+
{"version":3,"file":"SpinnerButton.js","names":["forwardRef","useSpinnerContext","wrapEvent","SpinnerButton","props","forwardedRef","as","Comp","type","onClick","otherProps","spinnerContext","Error","handleClick","e","delta","onChange","value","disabled","maxValue","minValue","spinnerHasFocus","undefined"],"sources":["../../../src/Spinner/SpinnerButton.tsx"],"sourcesContent":["import type {\n ButtonHTMLAttributes,\n ElementType,\n MouseEvent,\n ReactNode,\n} from 'react';\nimport { forwardRef } from 'react';\n\nimport { useSpinnerContext } from './context';\nimport { wrapEvent } from '../utils';\n\nexport interface SpinnerButtonProps\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n type: 'next' | 'previous';\n}\n\nexport const SpinnerButton = forwardRef<HTMLButtonElement, SpinnerButtonProps>(\n function SpinnerButton(props, forwardedRef) {\n const { as: Comp = 'button', type, onClick, ...otherProps } = props;\n const spinnerContext = useSpinnerContext();\n\n if (!spinnerContext) {\n throw new Error('Missing <Spinner /> in component tree');\n }\n\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n const delta = type === 'next' ? 1 : -1;\n\n spinnerContext.onChange &&\n spinnerContext.onChange(e, spinnerContext.value + delta);\n };\n\n const disabled =\n type === 'next'\n ? spinnerContext.value + 1 > spinnerContext.maxValue\n : spinnerContext.value - 1 < spinnerContext.minValue;\n\n return (\n <Comp\n {...otherProps}\n type=\"button\"\n ref={forwardedRef}\n tabIndex={-1}\n data-spinner-button=\"\"\n data-spinner-has-focus={spinnerContext.spinnerHasFocus ? '' : undefined}\n disabled={disabled}\n onClick={wrapEvent(onClick, handleClick)}\n />\n );\n }\n);\n"],"mappings":";;;AAMA,SAASA,UAAT,QAA2B,OAA3B;AAEA,SAASC,iBAAT,QAAkC,WAAlC;AACA,SAASC,SAAT,QAA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
|
1
|
-
import type { KeyboardEvent, MouseEvent } from 'react';
|
|
2
|
-
export interface SpinnerContextProps {
|
|
3
|
-
value: number;
|
|
4
|
-
minValue: number;
|
|
5
|
-
maxValue: number;
|
|
6
|
-
stepSize: number;
|
|
7
|
-
onChange?: (e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLDivElement>, value: number) => void;
|
|
8
|
-
clamp: (value: number) => number;
|
|
9
|
-
spinnerHasFocus: boolean;
|
|
10
|
-
}
|
|
11
|
-
export declare const SpinnerProvider: import("react").Provider<SpinnerContextProps | null>;
|
|
12
|
-
export declare const useSpinnerContext: () => SpinnerContextProps | null;
|
|
1
|
+
import type { KeyboardEvent, MouseEvent } from 'react';
|
|
2
|
+
export interface SpinnerContextProps {
|
|
3
|
+
value: number;
|
|
4
|
+
minValue: number;
|
|
5
|
+
maxValue: number;
|
|
6
|
+
stepSize: number;
|
|
7
|
+
onChange?: (e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLDivElement>, value: number) => void;
|
|
8
|
+
clamp: (value: number) => number;
|
|
9
|
+
spinnerHasFocus: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const SpinnerProvider: import("react").Provider<SpinnerContextProps | null>;
|
|
12
|
+
export declare const useSpinnerContext: () => SpinnerContextProps | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":["createContext","useContext","spinbuttonContext","SpinnerProvider","Provider","useSpinnerContext"],"sources":["../../../src/Spinner/context.ts"],"sourcesContent":["import type { KeyboardEvent, MouseEvent } from 'react';\
|
|
1
|
+
{"version":3,"file":"context.js","names":["createContext","useContext","spinbuttonContext","SpinnerProvider","Provider","useSpinnerContext"],"sources":["../../../src/Spinner/context.ts"],"sourcesContent":["import type { KeyboardEvent, MouseEvent } from 'react';\nimport { createContext, useContext } from 'react';\n\n// Spinner Component\nexport interface SpinnerContextProps {\n value: number;\n minValue: number;\n maxValue: number;\n stepSize: number;\n onChange?: (\n e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLDivElement>,\n value: number\n ) => void;\n clamp: (value: number) => number;\n spinnerHasFocus: boolean;\n}\n\nconst spinbuttonContext = createContext<SpinnerContextProps | null>(null);\nexport const { Provider: SpinnerProvider } = spinbuttonContext;\nexport const useSpinnerContext = () => useContext(spinbuttonContext);\n"],"mappings":"AACA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C,C,CAEA;;AAcA,IAAMC,iBAAiB,gBAAGF,aAAa,CAA6B,IAA7B,CAAvC;AACO,IAAkBG,eAAlB,GAAsCD,iBAAtC,CAAQE,QAAR;;AACP,OAAO,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB;EAAA,OAAMJ,UAAU,CAACC,iBAAD,CAAhB;AAAA,CAA1B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './Spinner';
|
|
2
|
-
export * from './SpinnerButton';
|
|
1
|
+
export * from './Spinner';
|
|
2
|
+
export * from './SpinnerButton';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/Spinner/index.ts"],"sourcesContent":["export * from './Spinner';\
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/Spinner/index.ts"],"sourcesContent":["export * from './Spinner';\nexport * from './SpinnerButton';\n"],"mappings":"AAAA,cAAc,WAAd;AACA,cAAc,iBAAd"}
|
package/build/esm/Tabs/Tab.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ButtonHTMLAttributes, ElementType, ReactNode } from 'react';
|
|
2
|
-
export interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
children?: ReactNode;
|
|
6
|
-
}
|
|
7
|
-
export declare const Tab: import("react").ForwardRefExoticComponent<TabProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
1
|
+
import type { ButtonHTMLAttributes, ElementType, ReactNode } from 'react';
|
|
2
|
+
export interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const Tab: import("react").ForwardRefExoticComponent<TabProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tab.js","names":["forwardRef","useRef","useTabsContext","useTabListContext","assignMultipleRefs","getCircularIndex","wrapEvent","scopeQuery","getNextIndex","desiredIndex","delta","allTabs","i","length","nextIndex","disabled","Tab","props","forwardedRef","as","Comp","onKeyDown","onClick","index","tabIndex","otherProps","tabContext","tabListContext","ref","undefined","Error","handleKeyDown","e","right","vertical","left","first","last","navigateIndex","isLast","key","tabsScope","current","queryAllNodes","currentIndex","indexOf","onChange","focus","manualActivation","handleClick","isSelected","tabListId"],"sources":["../../../src/Tabs/Tab.tsx"],"sourcesContent":["import type {\
|
|
1
|
+
{"version":3,"file":"Tab.js","names":["forwardRef","useRef","useTabsContext","useTabListContext","assignMultipleRefs","getCircularIndex","wrapEvent","scopeQuery","getNextIndex","desiredIndex","delta","allTabs","i","length","nextIndex","disabled","Tab","props","forwardedRef","as","Comp","onKeyDown","onClick","index","tabIndex","otherProps","tabContext","tabListContext","ref","undefined","Error","handleKeyDown","e","right","vertical","left","first","last","navigateIndex","isLast","key","tabsScope","current","queryAllNodes","currentIndex","indexOf","onChange","focus","manualActivation","handleClick","isSelected","tabListId"],"sources":["../../../src/Tabs/Tab.tsx"],"sourcesContent":["import type {\n ButtonHTMLAttributes,\n ElementType,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n} from 'react';\nimport { forwardRef, useRef } from 'react';\n\nimport { useTabsContext, useTabListContext } from './context';\nimport { assignMultipleRefs, getCircularIndex, wrapEvent } from '../utils';\nimport { scopeQuery } from './scopeQuery';\n\nfunction getNextIndex(\n desiredIndex: number,\n delta: number,\n allTabs: HTMLButtonElement[]\n) {\n for (let i = 0; i < allTabs.length; i++) {\n const nextIndex = getCircularIndex(\n desiredIndex + delta * i,\n allTabs.length\n );\n\n if (nextIndex !== null && !allTabs[nextIndex].disabled) {\n return nextIndex;\n }\n }\n\n return null;\n}\n\nexport interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport const Tab = forwardRef<HTMLButtonElement, TabProps>(function Tab(\n props,\n forwardedRef\n) {\n const {\n as: Comp = 'button',\n onKeyDown,\n onClick,\n index: tabIndex = -1,\n ...otherProps\n } = props as TabProps & { index: number };\n const tabContext = useTabsContext();\n const tabListContext = useTabListContext();\n\n const ref = useRef<HTMLButtonElement | undefined>(undefined);\n\n if (!tabContext || !tabListContext) {\n throw new Error('Missing <Tabs /> or <TabList /> in the component tree');\n }\n\n const handleKeyDown = (e: KeyboardEvent<HTMLButtonElement>) => {\n const right = tabListContext.vertical ? 'ArrowDown' : 'ArrowRight';\n const left = tabListContext.vertical ? 'ArrowUp' : 'ArrowLeft';\n const first = 'Home';\n const last = 'End';\n\n const navigateIndex = (desiredIndex: number, isLast: boolean) => {\n const delta = e.key === right || e.key === first ? 1 : -1;\n\n const allTabs =\n tabListContext.tabsScope.current.queryAllNodes(scopeQuery);\n const currentIndex = ref.current ? allTabs.indexOf(ref.current) : -1;\n\n const nextIndex = getNextIndex(\n isLast ? desiredIndex : currentIndex + desiredIndex,\n delta,\n allTabs as HTMLButtonElement[]\n );\n\n if (\n nextIndex !== null &&\n nextIndex !== currentIndex &&\n tabContext.onChange\n ) {\n allTabs[nextIndex].focus();\n !tabListContext.manualActivation && tabContext.onChange(e, nextIndex);\n }\n };\n\n switch (e.key) {\n case right:\n case left: {\n navigateIndex(e.key === right ? 1 : -1, false);\n break;\n }\n case first: // Home / End\n case last: {\n navigateIndex(e.key === first ? 0 : -1, true);\n break;\n }\n }\n };\n\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n const allTabs = tabListContext.tabsScope.current.queryAllNodes(scopeQuery);\n const currentIndex = ref.current ? allTabs.indexOf(ref.current) : -1;\n\n if (currentIndex >= 0) {\n tabContext.onChange && tabContext.onChange(e, currentIndex);\n }\n };\n\n const isSelected = tabIndex === tabContext.currentIndex;\n\n return (\n <Comp\n {...otherProps}\n ref={assignMultipleRefs(ref, forwardedRef)}\n data-tab=\"\"\n id={\n tabContext.tabListId !== null && tabIndex >= 0\n ? `tab-${tabContext.tabListId}-${tabIndex}`\n : undefined\n }\n aria-controls={\n tabContext.tabListId !== null && tabIndex >= 0\n ? `tabpanel-${tabContext.tabListId}-${tabIndex}`\n : undefined\n }\n role=\"tab\"\n tabIndex={isSelected ? 0 : -1}\n aria-selected={isSelected}\n selected={isSelected}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n onClick={wrapEvent(onClick, handleClick)}\n />\n );\n});\n"],"mappings":";;;AAOA,SAASA,UAAT,EAAqBC,MAArB,QAAmC,OAAnC;AAEA,SAASC,cAAT,EAAyBC,iBAAzB,QAAkD,WAAlD;AACA,SAASC,kBAAT,EAA6BC,gBAA7B,EAA+CC,SAA/C,QAAgE,UAAhE;AACA,SAASC,UAAT,QAA2B,cAA3B;;;AAEA,SAASC,YAAT,CACEC,YADF,EAEEC,KAFF,EAGEC,OAHF,EAIE;EACA,KAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,OAAO,CAACE,MAA5B,EAAoCD,CAAC,EAArC,EAAyC;IACvC,IAAME,SAAS,GAAGT,gBAAgB,CAChCI,YAAY,GAAGC,KAAK,GAAGE,CADS,EAEhCD,OAAO,CAACE,MAFwB,CAAlC;;IAKA,IAAIC,SAAS,KAAK,IAAd,IAAsB,CAACH,OAAO,CAACG,SAAD,CAAP,CAAmBC,QAA9C,EAAwD;MACtD,OAAOD,SAAP;IACD;EACF;;EAED,OAAO,IAAP;AACD;;AAQD,OA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D;;EASA,IAAMM,UAAU,GAAG1B,QAAQ,KAAKE,UAAU,CAACkB,YAA3C;EAEA,oBACE,KAAC,IAAD,wBACMnB,UADN;IAEE,GAAG,EAAErB,kBAAkB,CAACwB,GAAD,EAAMV,YAAN,CAFzB;IAGE,YAAS,EAHX;IAIE,EAAE,EACAQ,UAAU,CAACyB,SAAX,KAAyB,IAAzB,IAAiC3B,QAAQ,IAAI,CAA7C,iBACWE,UAAU,CAACyB,SADtB,cACmC3B,QADnC,IAEIK,SAPR;IASE,iBACEH,UAAU,CAACyB,SAAX,KAAyB,IAAzB,IAAiC3B,QAAQ,IAAI,CAA7C,sBACgBE,UAAU,CAACyB,SAD3B,cACwC3B,QADxC,IAEIK,SAZR;IAcE,IAAI,EAAC,KAdP;IAeE,QAAQ,EAAEqB,UAAU,GAAG,CAAH,GAAO,CAAC,CAf9B;IAgBE,iBAAeA,UAhBjB;IAiBE,QAAQ,EAAEA,UAjBZ;IAkBE,SAAS,EAAE5C,SAAS,CAACe,SAAD,EAAYU,aAAZ,CAlBtB;IAmBE,OAAO,EAAEzB,SAAS,CAACgB,OAAD,EAAU2B,WAAV;EAnBpB,GADF;AAuBD,CAjG4B,CAAtB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { HTMLAttributes, ElementType, ReactNode } from 'react';
|
|
2
|
-
export interface TabListProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
manualActivation?: boolean;
|
|
6
|
-
vertical?: boolean;
|
|
7
|
-
children?: ReactNode;
|
|
8
|
-
}
|
|
9
|
-
export declare const TabList: import("react").ForwardRefExoticComponent<TabListProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
1
|
+
import type { HTMLAttributes, ElementType, ReactNode } from 'react';
|
|
2
|
+
export interface TabListProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
manualActivation?: boolean;
|
|
6
|
+
vertical?: boolean;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare const TabList: import("react").ForwardRefExoticComponent<TabListProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabList.js","names":["forwardRef","useRef","useEffect","Children","cloneElement","useId","TabListProvider","useTabsContext","useScope","assignMultipleRefs","TabList","props","forwardedRef","as","Comp","manualActivation","vertical","childrenProps","children","otherProps","ref","tabsScope","tabsContext","id","Error","undefined","setTabListId","map","node","index"],"sources":["../../../src/Tabs/TabList.tsx"],"sourcesContent":["import type { HTMLAttributes, ElementType, ReactNode } from 'react';\
|
|
1
|
+
{"version":3,"file":"TabList.js","names":["forwardRef","useRef","useEffect","Children","cloneElement","useId","TabListProvider","useTabsContext","useScope","assignMultipleRefs","TabList","props","forwardedRef","as","Comp","manualActivation","vertical","childrenProps","children","otherProps","ref","tabsScope","tabsContext","id","Error","undefined","setTabListId","map","node","index"],"sources":["../../../src/Tabs/TabList.tsx"],"sourcesContent":["import type { HTMLAttributes, ElementType, ReactNode } from 'react';\nimport {\n forwardRef,\n useRef,\n useEffect,\n Children,\n cloneElement,\n useId,\n} from 'react';\n\nimport { TabListProvider, useTabsContext } from './context';\nimport { useScope } from '../hooks';\nimport { assignMultipleRefs } from '../utils';\n\nexport interface TabListProps extends HTMLAttributes<HTMLDivElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n manualActivation?: boolean;\n vertical?: boolean;\n children?: ReactNode;\n}\n\nexport const TabList = forwardRef<HTMLDivElement, TabListProps>(\n function TabList(props, forwardedRef) {\n const {\n as: Comp = 'div',\n manualActivation = false,\n vertical = false,\n children: childrenProps,\n ...otherProps\n } = props;\n\n const ref = useRef();\n const tabsScope = useScope(ref);\n const tabsContext = useTabsContext();\n const id = useId();\n\n if (!tabsContext) {\n throw new Error('Missing <Tabs /> in the component tree');\n }\n\n useEffect(() => {\n if (id !== undefined) {\n tabsContext.setTabListId(id);\n\n return () => {\n tabsContext.setTabListId(null);\n };\n }\n\n return;\n }, [id, tabsContext, tabsContext.setTabListId]);\n\n const children = Children.map(childrenProps, (node, index) =>\n cloneElement(node as any, { index })\n );\n\n return (\n <TabListProvider value={{ tabsScope, manualActivation, vertical }}>\n <Comp\n ref={assignMultipleRefs(forwardedRef, ref)}\n data-tab-list=\"\"\n role=\"tablist\"\n {...otherProps}\n >\n {children}\n </Comp>\n </TabListProvider>\n );\n }\n);\n"],"mappings":";;;AACA,SACEA,UADF,EAEEC,MAFF,EAGEC,SAHF,EAIEC,QAJF,EAKEC,YALF,EAMEC,KANF,QAOO,OAPP;AASA,SAASC,eAAT,EAA0BC,cAA1B,QAAgD,WAAhD;AACA,SAASC,QAAT,QAAyB,UAAzB;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAUA,OAAO,IAAMC,OAAO,gBAAGV,UAAU,CAC/B,SAASU,OAAT,CAAiBC,KAAjB,EAAwBC,YAAxB,EAAsC;EACpC,gBAMID,KANJ,CACEE,EADF;EAAA,IACMC,IADN,0BACa,KADb;EAAA,4BAMIH,KANJ,CAEEI,gBAFF;EAAA,IAEEA,gBAFF,sCAEqB,KAFrB;EAAA,sBAMIJ,KANJ,CAGEK,QAHF;EAAA,IAGEA,QAHF,gCAGa,KAHb;EAAA,IAIYC,aAJZ,GAMIN,KANJ,CAIEO,QAJF;EAAA,IAKKC,UALL,4BAMIR,KANJ;;EAQA,IAAMS,GAAG,GAAGnB,MAAM,EAAlB;EACA,IAAMoB,SAAS,GAAGb,QAAQ,CAACY,GAAD,CAA1B;EACA,IAAME,WAAW,GAAGf,cAAc,EAAlC;EACA,IAAMgB,EAAE,GAAGlB,KAAK,EAAhB;;EAEA,IAAI,CAACiB,WAAL,EAAkB;IAChB,MAAM,IAAIE,KAAJ,CAAU,wCAAV,CAAN;EACD;;EAEDtB,SAAS,CAAC,YAAM;IACd,IAAIqB,EAAE,KAAKE,SAAX,EAAsB;MACpBH,WAAW,CAACI,YAAZ,CAAyBH,EAAzB;MAEA,OAAO,YAAM;QACXD,WAAW,CAACI,YAAZ,CAAyB,IAAzB;MACD,CAFD;IAGD;;IAED;EACD,CAVQ,EAUN,CAACH,EAAD,EAAKD,WAAL,EAAkBA,WAAW,CAACI,YAA9B,CAVM,CAAT;EAYA,IAAMR,QAAQ,GAAGf,QAAQ,CAACwB,GAAT,CAAaV,aAAb,EAA4B,UAACW,IAAD,EAAOC,KAAP;IAAA,oBAC3CzB,YAAY,CAACwB,IAAD,EAAc;MAAEC,KAAK,EAALA;IAAF,CAAd,CAD+B;EAAA,CAA5B,CAAjB;EAIA,oBACE,KAAC,eAAD;IAAiB,KAAK,EAAE;MAAER,SAAS,EAATA,SAAF;MAAaN,gBAAgB,EAAhBA,gBAAb;MAA+BC,QAAQ,EAARA;IAA/B,CAAxB;IAAA,uBACE,KAAC,IAAD;MACE,GAAG,EAAEP,kBAAkB,CAACG,YAAD,EAAeQ,GAAf,CADzB;MAEE,iBAAc,EAFhB;MAGE,IAAI,EAAC;IAHP,GAIMD,UAJN;MAAA,UAMGD;IANH;EADF,EADF;AAYD,CA/C8B,CAA1B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ElementType, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
export interface TabPanelProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
children?: ReactNode;
|
|
6
|
-
lazy?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare const TabPanel: import("react").ForwardRefExoticComponent<TabPanelProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
1
|
+
import type { ElementType, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface TabPanelProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
lazy?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const TabPanel: import("react").ForwardRefExoticComponent<TabPanelProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabPanel.js","names":["forwardRef","useTabsContext","TabPanel","props","forwardedRef","as","Comp","index","lazy","children","otherProps","tabsContext","Error","isSelected","currentIndex","tabListId","undefined"],"sources":["../../../src/Tabs/TabPanel.tsx"],"sourcesContent":["import type { ElementType, HTMLAttributes, ReactNode } from 'react';\
|
|
1
|
+
{"version":3,"file":"TabPanel.js","names":["forwardRef","useTabsContext","TabPanel","props","forwardedRef","as","Comp","index","lazy","children","otherProps","tabsContext","Error","isSelected","currentIndex","tabListId","undefined"],"sources":["../../../src/Tabs/TabPanel.tsx"],"sourcesContent":["import type { ElementType, HTMLAttributes, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nimport { useTabsContext } from './context';\n\nexport interface TabPanelProps extends HTMLAttributes<HTMLDivElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n lazy?: boolean;\n}\n\nexport const TabPanel = forwardRef<HTMLDivElement, TabPanelProps>(\n function TabPanel(props, forwardedRef) {\n const {\n as: Comp = 'div',\n index,\n lazy = false,\n children,\n ...otherProps\n } = props as TabPanelProps & { index: number };\n const tabsContext = useTabsContext();\n\n if (!tabsContext) {\n throw new Error('Missing <Tabs /> in the component tree.');\n }\n\n const isSelected = tabsContext.currentIndex === index;\n\n return (\n <Comp\n ref={forwardedRef}\n data-tab-panel=\"\"\n role=\"tabpanel\"\n id={\n tabsContext.tabListId !== null\n ? `tabpanel-${tabsContext.tabListId}-${index}`\n : undefined\n }\n aria-labelledby={\n tabsContext.tabListId !== null\n ? `tab-${tabsContext.tabListId}-${index}`\n : undefined\n }\n hidden={isSelected ? undefined : 'hidden'}\n tabIndex={0}\n {...otherProps}\n >\n {(isSelected || !lazy) && children}\n </Comp>\n );\n }\n);\n"],"mappings":";;;AACA,SAASA,UAAT,QAA2B,OAA3B;AAEA,SAASC,cAAT,QAA+B,WAA/B;;AASA,OAAO,IAAMC,QAAQ,gBAAGF,UAAU,CAChC,SAASE,QAAT,CAAkBC,KAAlB,EAAyBC,YAAzB,EAAuC;EACrC,WAMID,KANJ;EAAA,mBACEE,EADF;EAAA,IACMC,IADN,wBACa,KADb;EAAA,IAEEC,KAFF,QAEEA,KAFF;EAAA,qBAGEC,IAHF;EAAA,IAGEA,IAHF,0BAGS,KAHT;EAAA,IAIEC,QAJF,QAIEA,QAJF;EAAA,IAKKC,UALL;;EAOA,IAAMC,WAAW,GAAGV,cAAc,EAAlC;;EAEA,IAAI,CAACU,WAAL,EAAkB;IAChB,MAAM,IAAIC,KAAJ,CAAU,yCAAV,CAAN;EACD;;EAED,IAAMC,UAAU,GAAGF,WAAW,CAACG,YAAZ,KAA6BP,KAAhD;EAEA,oBACE,KAAC,IAAD;IACE,GAAG,EAAEH,YADP;IAEE,kBAAe,EAFjB;IAGE,IAAI,EAAC,UAHP;IAIE,EAAE,EACAO,WAAW,CAACI,SAAZ,KAA0B,IAA1B,sBACgBJ,WAAW,CAACI,SAD5B,cACyCR,KADzC,IAEIS,SAPR;IASE,mBACEL,WAAW,CAACI,SAAZ,KAA0B,IAA1B,iBACWJ,WAAW,CAACI,SADvB,cACoCR,KADpC,IAEIS,SAZR;IAcE,MAAM,EAAEH,UAAU,GAAGG,SAAH,GAAe,QAdnC;IAeE,QAAQ,EAAE;EAfZ,GAgBMN,UAhBN;IAAA,UAkBG,CAACG,UAAU,IAAI,CAACL,IAAhB,KAAyBC;EAlB5B,GADF;AAsBD,CAvC+B,CAA3B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ElementType, ReactNode } from 'react';
|
|
2
|
-
export interface TabPanelsProps {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
lazy?: boolean;
|
|
6
|
-
children?: ReactNode;
|
|
7
|
-
}
|
|
8
|
-
export declare const TabPanels: import("react").ForwardRefExoticComponent<TabPanelsProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
1
|
+
import type { ElementType, ReactNode } from 'react';
|
|
2
|
+
export interface TabPanelsProps {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
lazy?: boolean;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const TabPanels: import("react").ForwardRefExoticComponent<TabPanelsProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabPanels.js","names":["forwardRef","Fragment","Children","cloneElement","TabPanels","props","forwardedRef","as","Comp","childrenProps","children","lazy","otherProps","map","node","index"],"sources":["../../../src/Tabs/TabPanels.tsx"],"sourcesContent":["import type { ElementType, ReactNode } from 'react';\
|
|
1
|
+
{"version":3,"file":"TabPanels.js","names":["forwardRef","Fragment","Children","cloneElement","TabPanels","props","forwardedRef","as","Comp","childrenProps","children","lazy","otherProps","map","node","index"],"sources":["../../../src/Tabs/TabPanels.tsx"],"sourcesContent":["import type { ElementType, ReactNode } from 'react';\nimport { forwardRef, Fragment, Children, cloneElement } from 'react';\n\nexport interface TabPanelsProps {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n lazy?: boolean;\n children?: ReactNode;\n}\n\nexport const TabPanels = forwardRef<HTMLDivElement, TabPanelsProps>(\n function TabPanels(props, forwardedRef) {\n const {\n as: Comp = Fragment,\n children: childrenProps,\n lazy,\n ...otherProps\n } = props;\n\n const children = Children.map(childrenProps, (node, index) =>\n cloneElement(node as any, { index, lazy })\n );\n\n return (\n <Comp ref={forwardedRef} {...otherProps}>\n {children}\n </Comp>\n );\n }\n);\n"],"mappings":";;;AACA,SAASA,UAAT,EAAqBC,QAArB,EAA+BC,QAA/B,EAAyCC,YAAzC,QAA6D,OAA7D;;AASA,OAAO,IAAMC,SAAS,gBAAGJ,UAAU,CACjC,SAASI,SAAT,CAAmBC,KAAnB,EAA0BC,YAA1B,EAAwC;EACtC,gBAKID,KALJ,CACEE,EADF;EAAA,IACMC,IADN,0BACaP,QADb;EAAA,IAEYQ,aAFZ,GAKIJ,KALJ,CAEEK,QAFF;EAAA,IAGEC,IAHF,GAKIN,KALJ,CAGEM,IAHF;EAAA,IAIKC,UAJL,4BAKIP,KALJ;;EAOA,IAAMK,QAAQ,GAAGR,QAAQ,CAACW,GAAT,CAAaJ,aAAb,EAA4B,UAACK,IAAD,EAAOC,KAAP;IAAA,oBAC3CZ,YAAY,CAACW,IAAD,EAAc;MAAEC,KAAK,EAALA,KAAF;MAASJ,IAAI,EAAJA;IAAT,CAAd,CAD+B;EAAA,CAA5B,CAAjB;EAIA,oBACE,KAAC,IAAD;IAAM,GAAG,EAAEL;EAAX,GAA6BM,UAA7B;IAAA,UACGF;EADH,GADF;AAKD,CAlBgC,CAA5B"}
|
package/build/esm/Tabs/Tabs.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ElementType, KeyboardEvent, MouseEvent, ReactNode } from 'react';
|
|
2
|
-
export interface TabsProps {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
children?: ReactNode;
|
|
6
|
-
onChange?: (e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>, value: number) => void;
|
|
7
|
-
index?: number;
|
|
8
|
-
defaultIndex?: number;
|
|
9
|
-
}
|
|
10
|
-
export declare const Tabs: import("react").ForwardRefExoticComponent<TabsProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
1
|
+
import type { ElementType, KeyboardEvent, MouseEvent, ReactNode } from 'react';
|
|
2
|
+
export interface TabsProps {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
onChange?: (e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>, value: number) => void;
|
|
7
|
+
index?: number;
|
|
8
|
+
defaultIndex?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const Tabs: import("react").ForwardRefExoticComponent<TabsProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.js","names":["forwardRef","Fragment","useState","TabsProvider","useControlledState","Tabs","props","forwardedRef","as","Comp","indexProp","index","onChangeProp","onChange","defaultIndex","otherProps","setState","e","idx","tabListId","setTabListId","currentIndex"],"sources":["../../../src/Tabs/Tabs.tsx"],"sourcesContent":["import type { ElementType, KeyboardEvent, MouseEvent, ReactNode } from 'react';\
|
|
1
|
+
{"version":3,"file":"Tabs.js","names":["forwardRef","Fragment","useState","TabsProvider","useControlledState","Tabs","props","forwardedRef","as","Comp","indexProp","index","onChangeProp","onChange","defaultIndex","otherProps","setState","e","idx","tabListId","setTabListId","currentIndex"],"sources":["../../../src/Tabs/Tabs.tsx"],"sourcesContent":["import type { ElementType, KeyboardEvent, MouseEvent, ReactNode } from 'react';\nimport { forwardRef, Fragment, useState } from 'react';\n\nimport { TabsProvider } from './context';\nimport { useControlledState } from '../hooks';\n\nexport interface TabsProps {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n onChange?: (\n e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>,\n value: number\n ) => void;\n index?: number;\n defaultIndex?: number;\n}\n\nexport const Tabs = forwardRef<HTMLDivElement, TabsProps>(function Tabs(\n props,\n forwardedRef\n) {\n const {\n as: Comp = Fragment,\n index: indexProp,\n onChange: onChangeProp,\n defaultIndex = 0,\n ...otherProps\n } = props;\n const [index, onChange] = useControlledState(\n indexProp,\n onChangeProp,\n defaultIndex,\n (setState) => (e, idx) => setState(idx)\n );\n\n const [tabListId, setTabListId] = useState<string | null>(null);\n\n return (\n <TabsProvider\n value={{ currentIndex: index || 0, onChange, tabListId, setTabListId }}\n >\n <Comp ref={forwardedRef} {...otherProps} />\n </TabsProvider>\n );\n});\n"],"mappings":";;;;AACA,SAASA,UAAT,EAAqBC,QAArB,EAA+BC,QAA/B,QAA+C,OAA/C;AAEA,SAASC,YAAT,QAA6B,WAA7B;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAcA,OAAO,IAAMC,IAAI,gBAAGL,UAAU,CAA4B,SAASK,IAAT,CACxDC,KADwD,EAExDC,YAFwD,EAGxD;EACA,gBAMID,KANJ,CACEE,EADF;EAAA,IACMC,IADN,0BACaR,QADb;EAAA,IAESS,SAFT,GAMIJ,KANJ,CAEEK,KAFF;EAAA,IAGYC,YAHZ,GAMIN,KANJ,CAGEO,QAHF;EAAA,0BAMIP,KANJ,CAIEQ,YAJF;EAAA,IAIEA,YAJF,oCAIiB,CAJjB;EAAA,IAKKC,UALL,4BAMIT,KANJ;;EAOA,0BAA0BF,kBAAkB,CAC1CM,SAD0C,EAE1CE,YAF0C,EAG1CE,YAH0C,EAI1C,UAACE,QAAD;IAAA,OAAc,UAACC,CAAD,EAAIC,GAAJ;MAAA,OAAYF,QAAQ,CAACE,GAAD,CAApB;IAAA,CAAd;EAAA,CAJ0C,CAA5C;EAAA;EAAA,IAAOP,KAAP;EAAA,IAAcE,QAAd;;EAOA,gBAAkCX,QAAQ,CAAgB,IAAhB,CAA1C;EAAA;EAAA,IAAOiB,SAAP;EAAA,IAAkBC,YAAlB;;EAEA,oBACE,KAAC,YAAD;IACE,KAAK,EAAE;MAAEC,YAAY,EAAEV,KAAK,IAAI,CAAzB;MAA4BE,QAAQ,EAARA,QAA5B;MAAsCM,SAAS,EAATA,SAAtC;MAAiDC,YAAY,EAAZA;IAAjD,CADT;IAAA,uBAGE,KAAC,IAAD;MAAM,GAAG,EAAEb;IAAX,GAA6BQ,UAA7B;EAHF,EADF;AAOD,CA3B6B,CAAvB"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type { KeyboardEvent, MouseEvent } from 'react';
|
|
2
|
-
import type { Scope } from '../hooks/useScope';
|
|
3
|
-
export interface TabsContextProps {
|
|
4
|
-
currentIndex: number;
|
|
5
|
-
onChange?: (e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>, value: number) => void;
|
|
6
|
-
tabListId: string | null;
|
|
7
|
-
setTabListId: (v: string | null) => void;
|
|
8
|
-
}
|
|
9
|
-
export declare const TabsProvider: import("react").Provider<TabsContextProps | null>;
|
|
10
|
-
export declare const useTabsContext: () => TabsContextProps | null;
|
|
11
|
-
export interface TabListContextProps {
|
|
12
|
-
tabsScope: Scope<HTMLElement>;
|
|
13
|
-
manualActivation: boolean;
|
|
14
|
-
vertical: boolean;
|
|
15
|
-
}
|
|
16
|
-
export declare const TabListProvider: import("react").Provider<TabListContextProps | null>;
|
|
17
|
-
export declare const useTabListContext: () => TabListContextProps | null;
|
|
1
|
+
import type { KeyboardEvent, MouseEvent } from 'react';
|
|
2
|
+
import type { Scope } from '../hooks/useScope';
|
|
3
|
+
export interface TabsContextProps {
|
|
4
|
+
currentIndex: number;
|
|
5
|
+
onChange?: (e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>, value: number) => void;
|
|
6
|
+
tabListId: string | null;
|
|
7
|
+
setTabListId: (v: string | null) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const TabsProvider: import("react").Provider<TabsContextProps | null>;
|
|
10
|
+
export declare const useTabsContext: () => TabsContextProps | null;
|
|
11
|
+
export interface TabListContextProps {
|
|
12
|
+
tabsScope: Scope<HTMLElement>;
|
|
13
|
+
manualActivation: boolean;
|
|
14
|
+
vertical: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare const TabListProvider: import("react").Provider<TabListContextProps | null>;
|
|
17
|
+
export declare const useTabListContext: () => TabListContextProps | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":["createContext","useContext","tabsContext","TabsProvider","Provider","useTabsContext","tablistContext","TabListProvider","useTabListContext"],"sources":["../../../src/Tabs/context.ts"],"sourcesContent":["import type { KeyboardEvent, MouseEvent } from 'react';\
|
|
1
|
+
{"version":3,"file":"context.js","names":["createContext","useContext","tabsContext","TabsProvider","Provider","useTabsContext","tablistContext","TabListProvider","useTabListContext"],"sources":["../../../src/Tabs/context.ts"],"sourcesContent":["import type { KeyboardEvent, MouseEvent } from 'react';\nimport { createContext, useContext } from 'react';\n\nimport type { Scope } from '../hooks/useScope';\n\n// Tabs Component\nexport interface TabsContextProps {\n currentIndex: number;\n onChange?: (\n e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>,\n value: number\n ) => void;\n tabListId: string | null;\n setTabListId: (v: string | null) => void;\n}\n\nconst tabsContext = createContext<TabsContextProps | null>(null);\nexport const { Provider: TabsProvider } = tabsContext;\nexport const useTabsContext = () => useContext(tabsContext);\n\n// TabList Component\nexport interface TabListContextProps {\n tabsScope: Scope<HTMLElement>;\n manualActivation: boolean;\n vertical: boolean;\n}\n\nconst tablistContext = createContext<TabListContextProps | null>(null);\nexport const { Provider: TabListProvider } = tablistContext;\nexport const useTabListContext = () => useContext(tablistContext);\n"],"mappings":"AACA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C;AAeA,IAAMC,WAAW,gBAAGF,aAAa,CAA0B,IAA1B,CAAjC;AACO,IAAkBG,YAAlB,GAAmCD,WAAnC,CAAQE,QAAR;;AACP,OAAO,IAAMC,cAAc,GAAG,SAAjBA,cAAiB;EAAA,OAAMJ,UAAU,CAACC,WAAD,CAAhB;AAAA,CAAvB,C,CAEP;;AAOA,IAAMI,cAAc,gBAAGN,aAAa,CAA6B,IAA7B,CAApC;AACO,IAAkBO,eAAlB,GAAsCD,cAAtC,CAAQF,QAAR;;AACP,OAAO,IAAMI,iBAAiB,GAAG,SAApBA,iBAAoB;EAAA,OAAMP,UAAU,CAACK,cAAD,CAAhB;AAAA,CAA1B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './Tabs';
|
|
2
|
-
export * from './Tab';
|
|
3
|
-
export * from './TabList';
|
|
4
|
-
export * from './TabPanels';
|
|
5
|
-
export * from './TabPanel';
|
|
1
|
+
export * from './Tabs';
|
|
2
|
+
export * from './Tab';
|
|
3
|
+
export * from './TabList';
|
|
4
|
+
export * from './TabPanels';
|
|
5
|
+
export * from './TabPanel';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/Tabs/index.tsx"],"sourcesContent":["export * from './Tabs';\
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/Tabs/index.tsx"],"sourcesContent":["export * from './Tabs';\nexport * from './Tab';\nexport * from './TabList';\nexport * from './TabPanels';\nexport * from './TabPanel';\n"],"mappings":"AAAA,cAAc,QAAd;AACA,cAAc,OAAd;AACA,cAAc,WAAd;AACA,cAAc,aAAd;AACA,cAAc,YAAd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function scopeQuery(nodeType: string, props: Record<string, unknown>): boolean;
|
|
1
|
+
export declare function scopeQuery(nodeType: string, props: Record<string, unknown>): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scopeQuery.js","names":["scopeQuery","nodeType","props"],"sources":["../../../src/Tabs/scopeQuery.ts"],"sourcesContent":["export function scopeQuery(\
|
|
1
|
+
{"version":3,"file":"scopeQuery.js","names":["scopeQuery","nodeType","props"],"sources":["../../../src/Tabs/scopeQuery.ts"],"sourcesContent":["export function scopeQuery(\n nodeType: string,\n props: Record<string, unknown>\n): boolean {\n return props['data-tab'] === '';\n}\n"],"mappings":"AAAA,OAAO,SAASA,UAAT,CACLC,QADK,EAELC,KAFK,EAGI;EACT,OAAOA,KAAK,CAAC,UAAD,CAAL,KAAsB,EAA7B;AACD"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ElementType, HTMLAttributes, ReactNode, RefAttributes } from 'react';
|
|
2
|
-
export type { InjectedTooltipProps } from './useTooltip';
|
|
3
|
-
export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
-
as?: ElementType<any>;
|
|
5
|
-
innerAs?: ElementType<any>;
|
|
6
|
-
children?: ReactNode;
|
|
7
|
-
label: ReactNode;
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare const Tooltip: import("react").ForwardRefExoticComponent<TooltipProps & RefAttributes<HTMLDivElement>>;
|
|
1
|
+
import type { ElementType, HTMLAttributes, ReactNode, RefAttributes } from 'react';
|
|
2
|
+
export type { InjectedTooltipProps } from './useTooltip';
|
|
3
|
+
export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
as?: ElementType<any>;
|
|
5
|
+
innerAs?: ElementType<any>;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
label: ReactNode;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const Tooltip: import("react").ForwardRefExoticComponent<TooltipProps & RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","names":["forwardRef","cloneElement","Children","useTooltip","Tooltip","props","forwardedRef","as","Comp","innerAs","children","disabled","otherProps","child","only","ref","childProps","visible","tooltipProps"],"sources":["../../../src/Tooltip/Tooltip.tsx"],"sourcesContent":["import type {\
|
|
1
|
+
{"version":3,"file":"Tooltip.js","names":["forwardRef","cloneElement","Children","useTooltip","Tooltip","props","forwardedRef","as","Comp","innerAs","children","disabled","otherProps","child","only","ref","childProps","visible","tooltipProps"],"sources":["../../../src/Tooltip/Tooltip.tsx"],"sourcesContent":["import type {\n ElementType,\n HTMLAttributes,\n ReactElement,\n ReactNode,\n RefAttributes,\n} from 'react';\nimport { forwardRef, cloneElement, Children } from 'react';\n\nimport { useTooltip } from './useTooltip';\nexport type { InjectedTooltipProps } from './useTooltip';\n\nexport interface TooltipProps extends HTMLAttributes<HTMLDivElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n label: ReactNode;\n disabled?: boolean;\n}\n\nexport const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(\n function Tooltip(props, forwardedRef) {\n const {\n as: Comp = 'div',\n innerAs,\n children,\n disabled = false,\n ...otherProps\n } = props;\n const child: ReactElement & RefAttributes<any> = Children.only(\n children\n ) as any;\n const [childProps, { visible, ...tooltipProps }] = useTooltip(\n child.props,\n child.ref,\n otherProps\n );\n\n if (disabled) {\n return <>{child}</>;\n }\n\n return (\n <>\n {cloneElement(child, childProps)}\n {visible && <Comp as={innerAs} ref={forwardedRef} {...tooltipProps} />}\n </>\n );\n }\n);\n"],"mappings":";;;;;AAOA,SAASA,UAAT,EAAqBC,YAArB,EAAmCC,QAAnC,QAAmD,OAAnD;AAEA,SAASC,UAAT,QAA2B,cAA3B;;;;AAWA,OAAO,IAAMC,OAAO,gBAAGJ,UAAU,CAC/B,SAASI,OAAT,CAAiBC,KAAjB,EAAwBC,YAAxB,EAAsC;EACpC,gBAMID,KANJ,CACEE,EADF;EAAA,IACMC,IADN,0BACa,KADb;EAAA,IAEEC,OAFF,GAMIJ,KANJ,CAEEI,OAFF;EAAA,IAGEC,QAHF,GAMIL,KANJ,CAGEK,QAHF;EAAA,sBAMIL,KANJ,CAIEM,QAJF;EAAA,IAIEA,QAJF,gCAIa,KAJb;EAAA,IAKKC,UALL,4BAMIP,KANJ;;EAOA,IAAMQ,KAAwC,GAAGX,QAAQ,CAACY,IAAT,CAC/CJ,QAD+C,CAAjD;;EAGA,kBAAmDP,UAAU,CAC3DU,KAAK,CAACR,KADqD,EAE3DQ,KAAK,CAACE,GAFqD,EAG3DH,UAH2D,CAA7D;EAAA;EAAA,IAAOI,UAAP;EAAA;EAAA,IAAqBC,OAArB,iBAAqBA,OAArB;EAAA,IAAiCC,YAAjC;;EAMA,IAAIP,QAAJ,EAAc;IACZ,oBAAO;MAAA,UAAGE;IAAH,EAAP;EACD;;EAED,oBACE;IAAA,wBACGZ,YAAY,CAACY,KAAD,EAAQG,UAAR,CADf,EAEGC,OAAO,iBAAI,KAAC,IAAD;MAAM,EAAE,EAAER,OAAV;MAAmB,GAAG,EAAEH;IAAxB,GAA0CY,YAA1C,EAFd;EAAA,EADF;AAMD,CA5B8B,CAA1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './Tooltip';
|
|
1
|
+
export * from './Tooltip';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/Tooltip/index.ts"],"sourcesContent":["export * from './Tooltip';\
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/Tooltip/index.ts"],"sourcesContent":["export * from './Tooltip';\n"],"mappings":"AAAA,cAAc,WAAd"}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
export declare type TooltipStates = 'IDLE' | 'FOCUSED' | 'VISIBLE' | 'LEAVING_VISIBLE' | 'DISMISSED';
|
|
2
|
-
export declare const Idle: "IDLE";
|
|
3
|
-
export declare const Focused: "FOCUSED";
|
|
4
|
-
export declare const Visible: "VISIBLE";
|
|
5
|
-
export declare const LeavingVisible: "LEAVING_VISIBLE";
|
|
6
|
-
export declare const Dismissed: "DISMISSED";
|
|
7
|
-
export declare type TooltipEventTypes = 'BLUR' | 'FOCUS' | 'GLOBAL_MOUSE_MOVE' | 'MOUSE_DOWN' | 'MOUSE_ENTER' | 'MOUSE_LEAVE' | 'MOUSE_MOVE' | 'REST' | 'SELECT_WITH_KEYBOARD' | 'TIME_COMPLETE';
|
|
8
|
-
export declare const Blur: "BLUR";
|
|
9
|
-
export declare const Focus: "FOCUS";
|
|
10
|
-
export declare const GlobalMouseMove: "GLOBAL_MOUSE_MOVE";
|
|
11
|
-
export declare const MouseDown: "MOUSE_DOWN";
|
|
12
|
-
export declare const MouseEnter: "MOUSE_ENTER";
|
|
13
|
-
export declare const MouseLeave: "MOUSE_LEAVE";
|
|
14
|
-
export declare const MouseMove: "MOUSE_MOVE";
|
|
15
|
-
export declare const Rest: "REST";
|
|
16
|
-
export declare const SelectWithKeyboard: "SELECT_WITH_KEYBOARD";
|
|
17
|
-
export declare const TimeComplete: "TIME_COMPLETE";
|
|
18
|
-
export declare const subscription: {
|
|
19
|
-
subscribe: (fn: () => void) => () => void;
|
|
20
|
-
notify: () => void;
|
|
21
|
-
};
|
|
22
|
-
export declare const state: {
|
|
23
|
-
current: {
|
|
24
|
-
state: TooltipStates;
|
|
25
|
-
id: string;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
export declare function send<T extends TooltipEventTypes>(event: T, payload?: Omit<typeof state['current'], 'state'>): void;
|
|
1
|
+
export declare type TooltipStates = 'IDLE' | 'FOCUSED' | 'VISIBLE' | 'LEAVING_VISIBLE' | 'DISMISSED';
|
|
2
|
+
export declare const Idle: "IDLE";
|
|
3
|
+
export declare const Focused: "FOCUSED";
|
|
4
|
+
export declare const Visible: "VISIBLE";
|
|
5
|
+
export declare const LeavingVisible: "LEAVING_VISIBLE";
|
|
6
|
+
export declare const Dismissed: "DISMISSED";
|
|
7
|
+
export declare type TooltipEventTypes = 'BLUR' | 'FOCUS' | 'GLOBAL_MOUSE_MOVE' | 'MOUSE_DOWN' | 'MOUSE_ENTER' | 'MOUSE_LEAVE' | 'MOUSE_MOVE' | 'REST' | 'SELECT_WITH_KEYBOARD' | 'TIME_COMPLETE';
|
|
8
|
+
export declare const Blur: "BLUR";
|
|
9
|
+
export declare const Focus: "FOCUS";
|
|
10
|
+
export declare const GlobalMouseMove: "GLOBAL_MOUSE_MOVE";
|
|
11
|
+
export declare const MouseDown: "MOUSE_DOWN";
|
|
12
|
+
export declare const MouseEnter: "MOUSE_ENTER";
|
|
13
|
+
export declare const MouseLeave: "MOUSE_LEAVE";
|
|
14
|
+
export declare const MouseMove: "MOUSE_MOVE";
|
|
15
|
+
export declare const Rest: "REST";
|
|
16
|
+
export declare const SelectWithKeyboard: "SELECT_WITH_KEYBOARD";
|
|
17
|
+
export declare const TimeComplete: "TIME_COMPLETE";
|
|
18
|
+
export declare const subscription: {
|
|
19
|
+
subscribe: (fn: () => void) => () => void;
|
|
20
|
+
notify: () => void;
|
|
21
|
+
};
|
|
22
|
+
export declare const state: {
|
|
23
|
+
current: {
|
|
24
|
+
state: TooltipStates;
|
|
25
|
+
id: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare function send<T extends TooltipEventTypes>(event: T, payload?: Omit<typeof state['current'], 'state'>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stateMachine.js","names":["createSubscription","restTimeout","startRestTimer","clearTimeout","setTimeout","send","Rest","undefined","clearRestTimer","leavingVisibleTimer","startLeavingVisibleTimer","TimeComplete","clearLeavingVisibleTimer","Idle","Focused","Visible","LeavingVisible","Dismissed","Blur","Focus","GlobalMouseMove","MouseDown","MouseEnter","MouseLeave","MouseMove","SelectWithKeyboard","subscription","state","current","id","clearContextId","chart","initial","states","enter","on","leave","transition","currentState","event","payload","currentStateValue","stateDef","nextState","nextStateValue","nextDef","notify"],"sources":["../../../src/Tooltip/stateMachine.ts"],"sourcesContent":["import { createSubscription } from '../utils/create-subscription';\
|
|
1
|
+
{"version":3,"file":"stateMachine.js","names":["createSubscription","restTimeout","startRestTimer","clearTimeout","setTimeout","send","Rest","undefined","clearRestTimer","leavingVisibleTimer","startLeavingVisibleTimer","TimeComplete","clearLeavingVisibleTimer","Idle","Focused","Visible","LeavingVisible","Dismissed","Blur","Focus","GlobalMouseMove","MouseDown","MouseEnter","MouseLeave","MouseMove","SelectWithKeyboard","subscription","state","current","id","clearContextId","chart","initial","states","enter","on","leave","transition","currentState","event","payload","currentStateValue","stateDef","nextState","nextStateValue","nextDef","notify"],"sources":["../../../src/Tooltip/stateMachine.ts"],"sourcesContent":["import { createSubscription } from '../utils/create-subscription';\nimport type { StateChart as GenericStateChart } from '../hooks/useReducerMachine';\n\n////////////////////////////////////////////////////////////////////////////////\n// Timeouts:\n\n// Manages when the user \"rests\" on an element. Keeps the interface from being\n// flashing tooltips all the time as the user moves the mouse around the screen.\nlet restTimeout: NodeJS.Timeout;\nfunction startRestTimer() {\n clearTimeout(restTimeout);\n restTimeout = setTimeout(() => {\n send(Rest, undefined);\n }, 200);\n}\n\nfunction clearRestTimer() {\n clearTimeout(restTimeout);\n}\n\n// Manages the delay to hide the tooltip after rest leaves.\nlet leavingVisibleTimer: NodeJS.Timeout;\nfunction startLeavingVisibleTimer() {\n clearTimeout(leavingVisibleTimer);\n leavingVisibleTimer = setTimeout(() => send(TimeComplete, undefined), 100);\n}\n\nfunction clearLeavingVisibleTimer() {\n clearTimeout(leavingVisibleTimer);\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// State machine\n\nexport type TooltipStates =\n | 'IDLE'\n | 'FOCUSED'\n | 'VISIBLE'\n | 'LEAVING_VISIBLE'\n | 'DISMISSED';\n\n// Nothing goin' on\nexport const Idle = 'IDLE' as const;\n// We're considering showing the tooltip, but we're gonna wait a sec\nexport const Focused = 'FOCUSED' as const;\n// It's on!\nexport const Visible = 'VISIBLE' as const;\n// Focus has left, but we want to keep it visible for a sec\nexport const LeavingVisible = 'LEAVING_VISIBLE' as const;\n// The user clicked the tool, so we want to hide the thing, we can't just use\n// IDLE because we need to ignore mousemove, etc.\nexport const Dismissed = 'DISMISSED' as const;\n\nexport type TooltipEventTypes =\n | 'BLUR'\n | 'FOCUS'\n | 'GLOBAL_MOUSE_MOVE'\n | 'MOUSE_DOWN'\n | 'MOUSE_ENTER'\n | 'MOUSE_LEAVE'\n | 'MOUSE_MOVE'\n | 'REST'\n | 'SELECT_WITH_KEYBOARD'\n | 'TIME_COMPLETE';\n\nexport const Blur = 'BLUR' as const;\nexport const Focus = 'FOCUS' as const;\nexport const GlobalMouseMove = 'GLOBAL_MOUSE_MOVE' as const;\nexport const MouseDown = 'MOUSE_DOWN' as const;\nexport const MouseEnter = 'MOUSE_ENTER' as const;\nexport const MouseLeave = 'MOUSE_LEAVE' as const;\nexport const MouseMove = 'MOUSE_MOVE' as const;\nexport const Rest = 'REST' as const;\nexport const SelectWithKeyboard = 'SELECT_WITH_KEYBOARD' as const;\nexport const TimeComplete = 'TIME_COMPLETE' as const;\n\nexport const subscription = createSubscription();\nexport const state = {\n current: {\n state: Idle as TooltipStates,\n id: '',\n },\n};\n\nfunction clearContextId() {\n state.current.id = '';\n}\n\nconst chart: GenericStateChart<TooltipStates, TooltipEventTypes> = {\n initial: Idle,\n states: {\n [Idle]: {\n enter: () => {\n clearContextId();\n },\n on: {\n [MouseEnter]: Focused,\n [Focus]: Visible,\n },\n },\n [Focused]: {\n enter: startRestTimer,\n leave: clearRestTimer,\n on: {\n [MouseMove]: Focused,\n [MouseLeave]: Idle,\n [MouseDown]: Dismissed,\n [Blur]: Idle,\n [Rest]: Visible,\n },\n },\n [Visible]: {\n on: {\n [Focus]: Focused,\n [MouseEnter]: Focused,\n [MouseLeave]: LeavingVisible,\n [Blur]: LeavingVisible,\n [MouseDown]: Dismissed,\n [SelectWithKeyboard]: Dismissed,\n [GlobalMouseMove]: LeavingVisible,\n },\n },\n [LeavingVisible]: {\n enter: () => {\n startLeavingVisibleTimer();\n },\n leave: () => {\n clearLeavingVisibleTimer();\n clearContextId();\n },\n on: {\n [MouseEnter]: Visible,\n [Focus]: Visible,\n [TimeComplete]: Idle,\n },\n },\n [Dismissed]: {\n leave: () => {\n clearContextId();\n },\n on: {\n [MouseLeave]: Idle,\n [Blur]: Idle,\n },\n },\n },\n};\n\nfunction transition(\n currentState: typeof state['current'],\n event: TooltipEventTypes,\n payload?: Omit<typeof state['current'], 'state'>\n): typeof state['current'] {\n const currentStateValue = currentState.state;\n const stateDef = chart.states[currentState.state];\n const nextState = stateDef?.on?.[event];\n\n // Really useful for debugging\n // console.log({\n // event,\n // state: state.current.state,\n // id: state.current.id,\n // nextState,\n // });\n\n if (!nextState) {\n return currentState;\n }\n\n if (stateDef && stateDef.leave) {\n stateDef.leave(currentStateValue, payload);\n }\n\n const nextStateValue = nextState;\n const nextDef = chart.states[nextStateValue];\n if (nextDef && nextDef.enter) {\n nextDef.enter(nextStateValue, payload);\n }\n\n return { ...currentState, ...payload, state: nextStateValue };\n}\n\nexport function send<T extends TooltipEventTypes>(\n event: T,\n payload?: Omit<typeof state['current'], 'state'>\n) {\n const nextState = transition(state.current, event, payload);\n if (state.current !== nextState) {\n state.current = nextState;\n subscription.notify();\n }\n}\n"],"mappings":";;;;;AAAA,SAASA,kBAAT,QAAmC,8BAAnC;AAGA;AACA;AAEA;AACA;AACA,IAAIC,WAAJ;;AACA,SAASC,cAAT,GAA0B;EACxBC,YAAY,CAACF,WAAD,CAAZ;EACAA,WAAW,GAAGG,UAAU,CAAC,YAAM;IAC7BC,IAAI,CAACC,IAAD,EAAOC,SAAP,CAAJ;EACD,CAFuB,EAErB,GAFqB,CAAxB;AAGD;;AAED,SAASC,cAAT,GAA0B;EACxBL,YAAY,CAACF,WAAD,CAAZ;AACD,C,CAED;;;AACA,IAAIQ,mBAAJ;;AACA,SAASC,wBAAT,GAAoC;EAClCP,YAAY,CAACM,mBAAD,CAAZ;EACAA,mBAAmB,GAAGL,UAAU,CAAC;IAAA,OAAMC,IAAI,CAACM,YAAD,EAAeJ,SAAf,CAAV;EAAA,CAAD,EAAsC,GAAtC,CAAhC;AACD;;AAED,SAASK,wBAAT,GAAoC;EAClCT,YAAY,CAACM,mBAAD,CAAZ;AACD,C,CAED;AACA;;;AASA;AACA,OAAO,IAAMI,IAAI,GAAG,MAAb,C,CACP;;AACA,OAAO,IAAMC,OAAO,GAAG,SAAhB,C,CACP;;AACA,OAAO,IAAMC,OAAO,GAAG,SAAhB,C,CACP;;AACA,OAAO,IAAMC,cAAc,GAAG,iBAAvB,C,CACP;AACA;;AACA,OAAO,IAAMC,SAAS,GAAG,WAAlB;AAcP,OAAO,IAAMC,IAAI,GAAG,MAAb;AACP,OAAO,IAAMC,KAAK,GAAG,OAAd;AACP,OAAO,IAAMC,eAAe,GAAG,mBA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