@basic-ui/core 0.0.40 → 0.0.43
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/build/cjs/index.js +1312 -464
- package/build/cjs/index.js.map +1 -1
- package/build/esm/Accordion/Accordion.d.ts +7 -7
- package/build/esm/Accordion/Accordion.js +4 -4
- package/build/esm/Accordion/Accordion.js.map +1 -1
- package/build/esm/Accordion/AccordionBody.d.ts +5 -5
- package/build/esm/Accordion/AccordionBody.js +4 -4
- package/build/esm/Accordion/AccordionBody.js.map +1 -1
- package/build/esm/Accordion/AccordionHeader.d.ts +6 -6
- package/build/esm/Accordion/AccordionHeader.js +4 -4
- package/build/esm/Accordion/AccordionHeader.js.map +1 -1
- package/build/esm/Accordion/AccordionItem.d.ts +7 -7
- package/build/esm/Accordion/AccordionItem.js +2 -2
- package/build/esm/Accordion/AccordionItem.js.map +1 -1
- package/build/esm/Accordion/context.d.ts +3 -3
- package/build/esm/Accordion/context.js.map +1 -1
- package/build/esm/Accordion/index.d.ts +0 -0
- package/build/esm/Accordion/index.js.map +1 -1
- package/build/esm/Accordion/scopeQuery.d.ts +0 -0
- package/build/esm/Accordion/scopeQuery.js.map +1 -1
- package/build/esm/CheckBox/CheckBox.d.ts +6 -6
- package/build/esm/CheckBox/CheckBox.js +2 -2
- package/build/esm/CheckBox/CheckBox.js.map +1 -1
- package/build/esm/CheckBox/index.d.ts +0 -0
- package/build/esm/CheckBox/index.js.map +1 -1
- package/build/esm/ComboBox/Combobox.d.ts +10 -10
- package/build/esm/ComboBox/Combobox.js +3 -3
- package/build/esm/ComboBox/Combobox.js.map +1 -1
- package/build/esm/ComboBox/ComboboxButton.d.ts +8 -8
- package/build/esm/ComboBox/ComboboxButton.js +4 -4
- package/build/esm/ComboBox/ComboboxButton.js.map +1 -1
- package/build/esm/ComboBox/ComboboxInput.d.ts +10 -10
- package/build/esm/ComboBox/ComboboxInput.js +3 -3
- package/build/esm/ComboBox/ComboboxInput.js.map +1 -1
- package/build/esm/ComboBox/ComboboxLabel.d.ts +5 -5
- package/build/esm/ComboBox/ComboboxLabel.js +2 -2
- package/build/esm/ComboBox/ComboboxLabel.js.map +1 -1
- package/build/esm/ComboBox/ComboboxList.d.ts +6 -6
- package/build/esm/ComboBox/ComboboxList.js +3 -3
- package/build/esm/ComboBox/ComboboxList.js.map +1 -1
- package/build/esm/ComboBox/ComboboxOption.d.ts +7 -7
- package/build/esm/ComboBox/ComboboxOption.js +4 -4
- package/build/esm/ComboBox/ComboboxOption.js.map +1 -1
- package/build/esm/ComboBox/ComboboxPopover.d.ts +8 -8
- package/build/esm/ComboBox/ComboboxPopover.js +5 -5
- package/build/esm/ComboBox/ComboboxPopover.js.map +1 -1
- package/build/esm/ComboBox/cities.d.ts +0 -0
- package/build/esm/ComboBox/cities.js.map +1 -1
- package/build/esm/ComboBox/context.d.ts +10 -10
- package/build/esm/ComboBox/context.js.map +1 -1
- package/build/esm/ComboBox/hooks.d.ts +3 -3
- package/build/esm/ComboBox/hooks.js +11 -11
- package/build/esm/ComboBox/hooks.js.map +1 -1
- package/build/esm/ComboBox/index.d.ts +0 -0
- package/build/esm/ComboBox/index.js.map +1 -1
- package/build/esm/ComboBox/makeHash.d.ts +0 -0
- package/build/esm/ComboBox/makeHash.js.map +1 -1
- package/build/esm/ComboBox/scopeQuery.d.ts +0 -0
- package/build/esm/ComboBox/scopeQuery.js.map +1 -1
- package/build/esm/FocusLock/FocusLock.d.ts +7 -7
- package/build/esm/FocusLock/FocusLock.js +2 -2
- package/build/esm/FocusLock/FocusLock.js.map +1 -1
- package/build/esm/FocusLock/index.d.ts +0 -0
- package/build/esm/FocusLock/index.js.map +1 -1
- package/build/esm/FocusLock/tabUtils.d.ts +0 -0
- package/build/esm/FocusLock/tabUtils.js.map +1 -1
- package/build/esm/FocusLock/useFocusLock.d.ts +4 -4
- package/build/esm/FocusLock/useFocusLock.js.map +1 -1
- package/build/esm/List/List.d.ts +6 -6
- package/build/esm/List/List.js +2 -2
- package/build/esm/List/List.js.map +1 -1
- package/build/esm/List/ListItem.d.ts +6 -6
- package/build/esm/List/ListItem.js +2 -2
- package/build/esm/List/ListItem.js.map +1 -1
- package/build/esm/List/context.d.ts +0 -0
- package/build/esm/List/context.js.map +1 -1
- package/build/esm/List/index.d.ts +0 -0
- package/build/esm/List/index.js.map +1 -1
- package/build/esm/Menu/Menu.d.ts +6 -6
- package/build/esm/Menu/Menu.js +2 -2
- package/build/esm/Menu/Menu.js.map +1 -1
- package/build/esm/Menu/MenuButton.d.ts +10 -10
- package/build/esm/Menu/MenuButton.js +3 -3
- package/build/esm/Menu/MenuButton.js.map +1 -1
- package/build/esm/Menu/MenuItem.d.ts +6 -6
- package/build/esm/Menu/MenuItem.js +4 -4
- package/build/esm/Menu/MenuItem.js.map +1 -1
- package/build/esm/Menu/MenuList.d.ts +5 -5
- package/build/esm/Menu/MenuList.js +6 -6
- package/build/esm/Menu/MenuList.js.map +1 -1
- package/build/esm/Menu/MenuPopover.d.ts +5 -5
- package/build/esm/Menu/MenuPopover.js +2 -2
- package/build/esm/Menu/MenuPopover.js.map +1 -1
- package/build/esm/Menu/context.d.ts +2 -2
- package/build/esm/Menu/context.js.map +1 -1
- package/build/esm/Menu/index.d.ts +0 -0
- package/build/esm/Menu/index.js.map +1 -1
- package/build/esm/Menu/scope.d.ts +0 -0
- package/build/esm/Menu/scope.js.map +1 -1
- package/build/esm/Modal/Modal.d.ts +6 -7
- package/build/esm/Modal/Modal.js +5 -5
- package/build/esm/Modal/Modal.js.map +1 -1
- package/build/esm/Modal/ModalBackdrop.d.ts +6 -6
- package/build/esm/Modal/ModalBackdrop.js +6 -6
- package/build/esm/Modal/ModalBackdrop.js.map +1 -1
- package/build/esm/Modal/index.d.ts +0 -0
- package/build/esm/Modal/index.js.map +1 -1
- package/build/esm/Popper/Popper.d.ts +7 -7
- package/build/esm/Popper/Popper.js +6 -6
- package/build/esm/Popper/Popper.js.map +1 -1
- package/build/esm/Popper/PopperArrow.d.ts +5 -5
- package/build/esm/Popper/PopperArrow.js +5 -6
- package/build/esm/Popper/PopperArrow.js.map +1 -1
- package/build/esm/Popper/context.d.ts +0 -0
- package/build/esm/Popper/context.js.map +1 -1
- package/build/esm/Popper/index.d.ts +0 -0
- package/build/esm/Popper/index.js.map +1 -1
- package/build/esm/Portal/Portal.d.ts +0 -0
- package/build/esm/Portal/Portal.js.map +1 -1
- package/build/esm/Portal/index.d.ts +0 -0
- package/build/esm/Portal/index.js.map +1 -1
- package/build/esm/RadioButton/RadioButton.d.ts +6 -6
- package/build/esm/RadioButton/RadioButton.js +5 -3
- package/build/esm/RadioButton/RadioButton.js.map +1 -1
- package/build/esm/RadioButton/RadioGroup.d.ts +7 -7
- package/build/esm/RadioButton/RadioGroup.js +2 -2
- package/build/esm/RadioButton/RadioGroup.js.map +1 -1
- package/build/esm/RadioButton/context.d.ts +2 -2
- package/build/esm/RadioButton/context.js.map +1 -1
- package/build/esm/RadioButton/index.d.ts +0 -0
- package/build/esm/RadioButton/index.js.map +1 -1
- package/build/esm/SkipNav/SkipNav.d.ts +6 -6
- package/build/esm/SkipNav/SkipNav.js +2 -2
- package/build/esm/SkipNav/SkipNav.js.map +1 -1
- package/build/esm/SkipNav/index.d.ts +0 -0
- package/build/esm/SkipNav/index.js.map +1 -1
- package/build/esm/Slider/Slider.d.ts +218 -0
- package/build/esm/Slider/Slider.js +842 -0
- package/build/esm/Slider/Slider.js.map +1 -0
- package/build/esm/Slider/index.d.ts +1 -0
- package/build/esm/Slider/index.js +2 -0
- package/build/esm/Slider/index.js.map +1 -0
- package/build/esm/Spinner/Spinner.d.ts +7 -7
- package/build/esm/Spinner/Spinner.js +2 -2
- package/build/esm/Spinner/Spinner.js.map +1 -1
- package/build/esm/Spinner/SpinnerButton.d.ts +6 -6
- package/build/esm/Spinner/SpinnerButton.js +3 -3
- package/build/esm/Spinner/SpinnerButton.js.map +1 -1
- package/build/esm/Spinner/context.d.ts +2 -2
- package/build/esm/Spinner/context.js.map +1 -1
- package/build/esm/Spinner/index.d.ts +0 -0
- package/build/esm/Spinner/index.js.map +1 -1
- package/build/esm/Tabs/Tab.d.ts +6 -6
- package/build/esm/Tabs/Tab.js +3 -3
- package/build/esm/Tabs/Tab.js.map +1 -1
- package/build/esm/Tabs/TabList.d.ts +6 -6
- package/build/esm/Tabs/TabList.js +4 -4
- package/build/esm/Tabs/TabList.js.map +1 -1
- package/build/esm/Tabs/TabPanel.d.ts +6 -6
- package/build/esm/Tabs/TabPanel.js +4 -4
- package/build/esm/Tabs/TabPanel.js.map +1 -1
- package/build/esm/Tabs/TabPanels.d.ts +5 -5
- package/build/esm/Tabs/TabPanels.js +4 -4
- package/build/esm/Tabs/TabPanels.js.map +1 -1
- package/build/esm/Tabs/Tabs.d.ts +6 -6
- package/build/esm/Tabs/Tabs.js +2 -2
- package/build/esm/Tabs/Tabs.js.map +1 -1
- package/build/esm/Tabs/context.d.ts +2 -2
- package/build/esm/Tabs/context.js.map +1 -1
- package/build/esm/Tabs/index.d.ts +0 -0
- package/build/esm/Tabs/index.js.map +1 -1
- package/build/esm/Tabs/scopeQuery.d.ts +0 -0
- package/build/esm/Tabs/scopeQuery.js.map +1 -1
- package/build/esm/Tooltip/Tooltip.d.ts +7 -8
- package/build/esm/Tooltip/Tooltip.js +5 -3
- package/build/esm/Tooltip/Tooltip.js.map +1 -1
- package/build/esm/Tooltip/index.d.ts +0 -0
- package/build/esm/Tooltip/index.js.map +1 -1
- package/build/esm/Tooltip/stateMachine.d.ts +0 -0
- package/build/esm/Tooltip/stateMachine.js +9 -9
- package/build/esm/Tooltip/stateMachine.js.map +1 -1
- package/build/esm/Tooltip/useTooltip.d.ts +7 -7
- package/build/esm/Tooltip/useTooltip.js +6 -5
- package/build/esm/Tooltip/useTooltip.js.map +1 -1
- package/build/esm/hooks/index.d.ts +0 -0
- 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 +0 -0
- package/build/esm/hooks/useChildrenCounter.js.map +1 -1
- package/build/esm/hooks/useControlledState.d.ts +2 -6
- package/build/esm/hooks/useControlledState.js +8 -7
- package/build/esm/hooks/useControlledState.js.map +1 -1
- package/build/esm/hooks/useFocusReturn.d.ts +0 -0
- package/build/esm/hooks/useFocusReturn.js +2 -2
- package/build/esm/hooks/useFocusReturn.js.map +1 -1
- package/build/esm/hooks/useFocusState.d.ts +5 -5
- package/build/esm/hooks/useFocusState.js +1 -1
- package/build/esm/hooks/useFocusState.js.map +1 -1
- package/build/esm/hooks/useGestureHandlers.d.ts +5 -5
- package/build/esm/hooks/useGestureHandlers.js +23 -15
- package/build/esm/hooks/useGestureHandlers.js.map +1 -1
- package/build/esm/hooks/useMeasure.d.ts +2 -2
- package/build/esm/hooks/useMeasure.js +0 -1
- 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 +5 -5
- package/build/esm/hooks/useOnKeyDown.js.map +1 -1
- package/build/esm/hooks/useReducerMachine.d.ts +0 -0
- package/build/esm/hooks/useReducerMachine.js +2 -1
- package/build/esm/hooks/useReducerMachine.js.map +1 -1
- package/build/esm/hooks/useRemoveBodyScroll.d.ts +2 -1
- package/build/esm/hooks/useRemoveBodyScroll.js +12 -8
- package/build/esm/hooks/useRemoveBodyScroll.js.map +1 -1
- package/build/esm/hooks/useScope.d.ts +0 -0
- package/build/esm/hooks/useScope.js.map +1 -1
- package/build/esm/hooks/useThrottle.d.ts +0 -0
- package/build/esm/hooks/useThrottle.js.map +1 -1
- package/build/esm/index.d.ts +1 -0
- package/build/esm/index.js +1 -0
- package/build/esm/index.js.map +1 -1
- package/build/esm/utils/assign-ref.d.ts +3 -0
- package/build/esm/utils/{assignRef.js → assign-ref.js} +1 -1
- package/build/esm/utils/assign-ref.js.map +1 -0
- package/build/esm/utils/can-use-dom.d.ts +1 -0
- package/build/esm/utils/can-use-dom.js +4 -0
- package/build/esm/utils/can-use-dom.js.map +1 -0
- package/build/esm/utils/clamp.d.ts +0 -0
- package/build/esm/utils/clamp.js.map +1 -1
- package/build/esm/utils/context.d.ts +7 -0
- package/build/esm/utils/context.js +41 -0
- package/build/esm/utils/context.js.map +1 -0
- package/build/esm/utils/{createSubscription.d.ts → create-subscription.d.ts} +0 -0
- package/build/esm/utils/{createSubscription.js → create-subscription.js} +1 -1
- package/build/esm/utils/create-subscription.js.map +1 -0
- package/build/esm/utils/{getCircularIndex.d.ts → get-circular-index.d.ts} +0 -0
- package/build/esm/utils/{getCircularIndex.js → get-circular-index.js} +1 -1
- package/build/esm/utils/get-circular-index.js.map +1 -0
- package/build/esm/utils/index.d.ts +10 -4
- package/build/esm/utils/index.js +10 -4
- package/build/esm/utils/index.js.map +1 -1
- package/build/esm/utils/is-right-click.d.ts +6 -0
- package/build/esm/utils/is-right-click.js +9 -0
- package/build/esm/utils/is-right-click.js.map +1 -0
- package/build/esm/utils/owner-document.d.ts +7 -0
- package/build/esm/utils/owner-document.js +12 -0
- package/build/esm/utils/owner-document.js.map +1 -0
- package/build/esm/utils/polymorphic.d.ts +32 -0
- package/build/esm/utils/polymorphic.js +2 -0
- package/build/esm/utils/polymorphic.js.map +1 -0
- package/build/esm/utils/{rubberBandClamp.d.ts → rubber-band-clamp.d.ts} +0 -0
- package/build/esm/utils/{rubberBandClamp.js → rubber-band-clamp.js} +1 -1
- package/build/esm/utils/rubber-band-clamp.js.map +1 -0
- package/build/esm/utils/use-stable-callback.d.ts +16 -0
- package/build/esm/utils/use-stable-callback.js +43 -0
- package/build/esm/utils/use-stable-callback.js.map +1 -0
- package/build/esm/utils/wrap-event.d.ts +3 -0
- package/build/esm/utils/{wrapEvent.js → wrap-event.js} +1 -1
- package/build/esm/utils/wrap-event.js.map +1 -0
- package/build/tsconfig-build.tsbuildinfo +1 -0
- package/package.json +5 -6
- package/src/Accordion/Accordion.tsx +12 -6
- package/src/Accordion/AccordionBody.tsx +4 -5
- package/src/Accordion/AccordionHeader.tsx +30 -27
- package/src/Accordion/AccordionItem.tsx +12 -6
- package/src/Accordion/context.ts +3 -2
- package/src/CheckBox/CheckBox.tsx +5 -6
- package/src/ComboBox/ComboBox.story.tsx +3 -3
- package/src/ComboBox/Combobox.tsx +5 -8
- package/src/ComboBox/ComboboxButton.tsx +15 -9
- package/src/ComboBox/ComboboxInput.tsx +18 -10
- package/src/ComboBox/ComboboxLabel.tsx +4 -4
- package/src/ComboBox/ComboboxList.tsx +5 -6
- package/src/ComboBox/ComboboxOption.tsx +12 -8
- package/src/ComboBox/ComboboxPopover.tsx +15 -10
- package/src/ComboBox/context.ts +10 -9
- package/src/ComboBox/hooks.tsx +4 -3
- package/src/FocusLock/FocusLock.tsx +13 -7
- package/src/FocusLock/useFocusLock.ts +4 -3
- package/src/List/List.tsx +5 -5
- package/src/List/ListItem.tsx +5 -5
- package/src/Menu/Menu.story.tsx +2 -2
- package/src/Menu/Menu.tsx +13 -7
- package/src/Menu/MenuButton.tsx +13 -10
- package/src/Menu/MenuItem.tsx +15 -11
- package/src/Menu/MenuList.tsx +6 -6
- package/src/Menu/MenuPopover.tsx +4 -4
- package/src/Menu/context.ts +9 -4
- package/src/Modal/Modal.tsx +11 -7
- package/src/Modal/ModalBackdrop.tsx +16 -11
- package/src/Popper/Popper.tsx +7 -7
- package/src/Popper/PopperArrow.tsx +6 -8
- package/src/RadioButton/RadioButton.tsx +11 -6
- package/src/RadioButton/RadioGroup.tsx +11 -9
- package/src/RadioButton/context.ts +2 -4
- package/src/SkipNav/SkipNav.tsx +5 -5
- package/src/Slider/Slider.story.tsx +45 -0
- package/src/Slider/Slider.tsx +1106 -0
- package/src/Slider/index.ts +1 -0
- package/src/Slider/styles.css +131 -0
- package/src/Spinner/Spinner.tsx +13 -9
- package/src/Spinner/SpinnerButton.tsx +11 -6
- package/src/Spinner/context.ts +2 -3
- package/src/Tabs/Tab.tsx +13 -8
- package/src/Tabs/TabList.tsx +5 -5
- package/src/Tabs/TabPanel.tsx +5 -5
- package/src/Tabs/TabPanels.tsx +4 -4
- package/src/Tabs/Tabs.tsx +5 -7
- package/src/Tabs/context.ts +2 -3
- package/src/Tooltip/Tooltip.story.tsx +3 -3
- package/src/Tooltip/Tooltip.tsx +13 -7
- package/src/Tooltip/stateMachine.ts +9 -13
- package/src/Tooltip/useTooltip.ts +17 -11
- package/src/hooks/useAutoFocus.ts +2 -1
- package/src/hooks/useControlledState.ts +14 -14
- package/src/hooks/useFocusState.ts +4 -3
- package/src/hooks/useGestureHandlers.ts +33 -19
- package/src/hooks/useMeasure.ts +2 -2
- package/src/hooks/useOnClickOutside.ts +2 -2
- package/src/hooks/useOnKeyDown.ts +4 -3
- package/src/hooks/useRemoveBodyScroll.ts +18 -8
- package/src/index.ts +1 -0
- package/src/utils/{assignRef.ts → assign-ref.ts} +4 -4
- package/src/utils/can-use-dom.ts +7 -0
- package/src/utils/context.tsx +48 -0
- package/src/utils/{createSubscription.ts → create-subscription.ts} +0 -0
- package/src/utils/{getCircularIndex.ts → get-circular-index.ts} +0 -0
- package/src/utils/index.ts +10 -4
- package/src/utils/is-right-click.ts +14 -0
- package/src/utils/owner-document.ts +13 -0
- package/src/utils/polymorphic.ts +72 -0
- package/src/utils/{rubberBandClamp.ts → rubber-band-clamp.ts} +0 -0
- package/src/utils/use-stable-callback.ts +58 -0
- package/src/utils/wrap-event.ts +22 -0
- package/build/esm/hooks/useId.d.ts +0 -3
- package/build/esm/hooks/useId.js +0 -16
- package/build/esm/hooks/useId.js.map +0 -1
- package/build/esm/utils/assignRef.d.ts +0 -3
- package/build/esm/utils/assignRef.js.map +0 -1
- package/build/esm/utils/createSubscription.js.map +0 -1
- package/build/esm/utils/getCircularIndex.js.map +0 -1
- package/build/esm/utils/rubberBandClamp.js.map +0 -1
- package/build/esm/utils/wrapEvent.d.ts +0 -3
- package/build/esm/utils/wrapEvent.js.map +0 -1
- package/build/tsconfig.tsbuildinfo +0 -1
- package/src/utils/wrapEvent.ts +0 -20
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["as", "children", "lazy"];
|
|
3
4
|
import { forwardRef, Fragment, Children, cloneElement } from 'react';
|
|
4
|
-
import * as React from 'react';
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
export var TabPanels = /*#__PURE__*/forwardRef(function TabPanels(props, forwardedRef) {
|
|
7
7
|
var _props$as = props.as,
|
|
8
8
|
Comp = _props$as === void 0 ? Fragment : _props$as,
|
|
9
9
|
childrenProps = props.children,
|
|
10
10
|
lazy = props.lazy,
|
|
11
|
-
otherProps = _objectWithoutProperties(props,
|
|
11
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
12
12
|
|
|
13
13
|
var children = Children.map(childrenProps, function (node, index) {
|
|
14
14
|
return /*#__PURE__*/cloneElement(node, {
|
|
@@ -16,9 +16,9 @@ export var TabPanels = /*#__PURE__*/forwardRef(function TabPanels(props, forward
|
|
|
16
16
|
lazy: lazy
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
|
-
return /*#__PURE__*/_jsx(Comp, _extends({
|
|
19
|
+
return /*#__PURE__*/_jsx(Comp, _extends(_extends({
|
|
20
20
|
ref: forwardedRef
|
|
21
|
-
}, otherProps, {
|
|
21
|
+
}, otherProps), {}, {
|
|
22
22
|
children: children
|
|
23
23
|
}));
|
|
24
24
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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
|
|
1
|
+
import type { ElementType, KeyboardEvent, MouseEvent, ReactNode } from 'react';
|
|
2
2
|
export interface TabsProps {
|
|
3
|
-
as?:
|
|
4
|
-
innerAs?:
|
|
5
|
-
children?:
|
|
6
|
-
onChange?: (e:
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
onChange?: (e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>, value: number) => void;
|
|
7
7
|
index?: number;
|
|
8
8
|
defaultIndex?: number;
|
|
9
9
|
}
|
|
10
|
-
export declare const Tabs:
|
|
10
|
+
export declare const Tabs: import("react").ForwardRefExoticComponent<TabsProps & import("react").RefAttributes<HTMLDivElement>>;
|
package/build/esm/Tabs/Tabs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["as", "index", "onChange", "defaultIndex"];
|
|
4
5
|
import { forwardRef, Fragment, useState } from 'react';
|
|
5
|
-
import * as React from 'react';
|
|
6
6
|
import { TabsProvider } from './context';
|
|
7
7
|
import { useControlledState } from '../hooks';
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -13,7 +13,7 @@ export var Tabs = /*#__PURE__*/forwardRef(function Tabs(props, forwardedRef) {
|
|
|
13
13
|
onChangeProp = props.onChange,
|
|
14
14
|
_props$defaultIndex = props.defaultIndex,
|
|
15
15
|
defaultIndex = _props$defaultIndex === void 0 ? 0 : _props$defaultIndex,
|
|
16
|
-
otherProps = _objectWithoutProperties(props,
|
|
16
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
17
17
|
|
|
18
18
|
var _useControlledState = useControlledState(indexProp, onChangeProp, defaultIndex, function (setState) {
|
|
19
19
|
return function (e, idx) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { KeyboardEvent, MouseEvent } from 'react';
|
|
2
2
|
import type { Scope } from '../hooks/useScope';
|
|
3
3
|
export interface TabsContextProps {
|
|
4
4
|
currentIndex: number;
|
|
5
|
-
onChange?: (e:
|
|
5
|
+
onChange?: (e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>, value: number) => void;
|
|
6
6
|
tabListId: string | null;
|
|
7
7
|
setTabListId: (v: string | null) => void;
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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,11 +1,10 @@
|
|
|
1
|
-
import type { RefAttributes } from 'react';
|
|
2
|
-
import React from 'react';
|
|
1
|
+
import type { ElementType, HTMLAttributes, ReactNode, RefAttributes } from 'react';
|
|
3
2
|
export type { InjectedTooltipProps } from './useTooltip';
|
|
4
|
-
export interface TooltipProps extends
|
|
5
|
-
as?:
|
|
6
|
-
innerAs?:
|
|
7
|
-
children?:
|
|
8
|
-
label:
|
|
3
|
+
export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
as?: ElementType<any>;
|
|
5
|
+
innerAs?: ElementType<any>;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
label: ReactNode;
|
|
9
8
|
disabled?: boolean;
|
|
10
9
|
}
|
|
11
|
-
export declare const Tooltip:
|
|
10
|
+
export declare const Tooltip: import("react").ForwardRefExoticComponent<TooltipProps & RefAttributes<HTMLDivElement>>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
|
|
4
|
+
var _excluded = ["as", "innerAs", "children", "disabled"],
|
|
5
|
+
_excluded2 = ["visible"];
|
|
6
|
+
import { forwardRef, cloneElement, Children } from 'react';
|
|
5
7
|
import { useTooltip } from './useTooltip';
|
|
6
8
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -13,7 +15,7 @@ export var Tooltip = /*#__PURE__*/forwardRef(function Tooltip(props, forwardedRe
|
|
|
13
15
|
children = props.children,
|
|
14
16
|
_props$disabled = props.disabled,
|
|
15
17
|
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
16
|
-
otherProps = _objectWithoutProperties(props,
|
|
18
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
17
19
|
|
|
18
20
|
var child = Children.only(children);
|
|
19
21
|
|
|
@@ -22,7 +24,7 @@ export var Tooltip = /*#__PURE__*/forwardRef(function Tooltip(props, forwardedRe
|
|
|
22
24
|
childProps = _useTooltip2[0],
|
|
23
25
|
_useTooltip2$ = _useTooltip2[1],
|
|
24
26
|
visible = _useTooltip2$.visible,
|
|
25
|
-
tooltipProps = _objectWithoutProperties(_useTooltip2$,
|
|
27
|
+
tooltipProps = _objectWithoutProperties(_useTooltip2$, _excluded2);
|
|
26
28
|
|
|
27
29
|
if (disabled) {
|
|
28
30
|
return /*#__PURE__*/_jsx(_Fragment, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/Tooltip/index.ts"],"sourcesContent":["export * from './Tooltip';\n"],"mappings":"AAAA,cAAc,WAAd"}
|
|
File without changes
|
|
@@ -3,7 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
|
|
4
4
|
var _on, _on2, _on3, _on4, _on5, _states;
|
|
5
5
|
|
|
6
|
-
import { createSubscription } from '../utils/
|
|
6
|
+
import { createSubscription } from '../utils/create-subscription';
|
|
7
7
|
////////////////////////////////////////////////////////////////////////////////
|
|
8
8
|
// Timeouts:
|
|
9
9
|
// Manages when the user "rests" on an element. Keeps the interface from being
|
|
@@ -11,28 +11,28 @@ import { createSubscription } from '../utils/createSubscription';
|
|
|
11
11
|
var restTimeout;
|
|
12
12
|
|
|
13
13
|
function startRestTimer() {
|
|
14
|
-
|
|
15
|
-
restTimeout =
|
|
14
|
+
clearTimeout(restTimeout);
|
|
15
|
+
restTimeout = setTimeout(function () {
|
|
16
16
|
send(Rest, undefined);
|
|
17
17
|
}, 200);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function clearRestTimer() {
|
|
21
|
-
|
|
21
|
+
clearTimeout(restTimeout);
|
|
22
22
|
} // Manages the delay to hide the tooltip after rest leaves.
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
var leavingVisibleTimer;
|
|
26
26
|
|
|
27
27
|
function startLeavingVisibleTimer() {
|
|
28
|
-
|
|
29
|
-
leavingVisibleTimer =
|
|
28
|
+
clearTimeout(leavingVisibleTimer);
|
|
29
|
+
leavingVisibleTimer = setTimeout(function () {
|
|
30
30
|
return send(TimeComplete, undefined);
|
|
31
31
|
}, 100);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function clearLeavingVisibleTimer() {
|
|
35
|
-
|
|
35
|
+
clearTimeout(leavingVisibleTimer);
|
|
36
36
|
} ////////////////////////////////////////////////////////////////////////////////
|
|
37
37
|
// State machine
|
|
38
38
|
|
|
@@ -105,7 +105,7 @@ function transition(currentState, event, payload) {
|
|
|
105
105
|
|
|
106
106
|
var currentStateValue = currentState.state;
|
|
107
107
|
var stateDef = chart.states[currentState.state];
|
|
108
|
-
var nextState = stateDef
|
|
108
|
+
var nextState = stateDef === null || stateDef === void 0 ? void 0 : (_stateDef$on = stateDef.on) === null || _stateDef$on === void 0 ? void 0 : _stateDef$on[event]; // Really useful for debugging
|
|
109
109
|
// console.log({
|
|
110
110
|
// event,
|
|
111
111
|
// state: state.current.state,
|
|
@@ -128,7 +128,7 @@ function transition(currentState, event, payload) {
|
|
|
128
128
|
nextDef.enter(nextStateValue, payload);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
return _extends({}, currentState, payload, {
|
|
131
|
+
return _extends(_extends(_extends({}, currentState), payload), {}, {
|
|
132
132
|
state: nextStateValue
|
|
133
133
|
});
|
|
134
134
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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,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EiB;EAA7C;AACD;;AAED,OAAO,SAASvC,IAAT,CACLkC,KADK,EAELC,OAFK,EAGL;EACA,IAAMG,SAAS,GAAGN,UAAU,CAACV,KAAK,CAACC,OAAP,EAAgBW,KAAhB,EAAuBC,OAAvB,CAA5B;;EACA,IAAIb,KAAK,CAACC,OAAN,KAAkBe,SAAtB,EAAiC;IAC/BhB,KAAK,CAACC,OAAN,GAAgBe,SAAhB;IACAjB,YAAY,CAACoB,MAAb;EACD;AACF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { RefAttributes } from 'react';
|
|
2
|
-
export declare type ChildProps =
|
|
3
|
-
export interface InjectedTooltipProps extends
|
|
4
|
-
anchorEl:
|
|
1
|
+
import type { HTMLAttributes, ReactNode, Ref, RefAttributes, RefObject } from 'react';
|
|
2
|
+
export declare type ChildProps = HTMLAttributes<HTMLElement> & RefAttributes<HTMLElement>;
|
|
3
|
+
export interface InjectedTooltipProps extends HTMLAttributes<HTMLElement> {
|
|
4
|
+
anchorEl: RefObject<HTMLElement>;
|
|
5
5
|
visible: boolean;
|
|
6
|
-
children?:
|
|
6
|
+
children?: ReactNode;
|
|
7
7
|
}
|
|
8
|
-
export declare function useTooltip(childProps: ChildProps, childRef:
|
|
9
|
-
label?:
|
|
8
|
+
export declare function useTooltip(childProps: ChildProps, childRef: Ref<HTMLElement> | undefined, tooltipProps: HTMLAttributes<HTMLElement> & {
|
|
9
|
+
label?: ReactNode;
|
|
10
10
|
}): [ChildProps, InjectedTooltipProps];
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
var _excluded = ["label", "onMouseEnter", "onMouseLeave", "onMouseMove"];
|
|
4
5
|
import { useRef, useEffect, useState, useId } from 'react';
|
|
5
|
-
import { assignMultipleRefs } from '../utils/
|
|
6
|
-
import { wrapEvent } from '../utils/
|
|
6
|
+
import { assignMultipleRefs } from '../utils/assign-ref';
|
|
7
|
+
import { wrapEvent } from '../utils/wrap-event';
|
|
7
8
|
import { send, state, subscription, Blur, Focus, LeavingVisible, MouseDown, MouseEnter, MouseLeave, MouseMove, SelectWithKeyboard, Visible } from './stateMachine';
|
|
8
9
|
export function useTooltip(childProps, childRef, tooltipProps) {
|
|
9
10
|
var onMouseEnter = childProps.onMouseEnter,
|
|
@@ -73,14 +74,14 @@ export function useTooltip(childProps, childRef, tooltipProps) {
|
|
|
73
74
|
tooltipOnMouseEnter = tooltipProps.onMouseEnter,
|
|
74
75
|
tooltipOnMouseLeave = tooltipProps.onMouseLeave,
|
|
75
76
|
tooltipOnMouseMove = tooltipProps.onMouseMove,
|
|
76
|
-
otherTooltipProps = _objectWithoutProperties(tooltipProps,
|
|
77
|
+
otherTooltipProps = _objectWithoutProperties(tooltipProps, _excluded);
|
|
77
78
|
|
|
78
79
|
var tooltipId = "tooltip-".concat(id);
|
|
79
|
-
return [_extends({}, childProps, {
|
|
80
|
+
return [_extends(_extends(_extends({}, childProps), {}, {
|
|
80
81
|
ref: assignMultipleRefs(childRef, anchorEl)
|
|
81
82
|
}, visible && !childProps['aria-label'] && {
|
|
82
83
|
'aria-describedby': tooltipId
|
|
83
|
-
}, {
|
|
84
|
+
}), {}, {
|
|
84
85
|
onMouseEnter: wrapEvent(onMouseEnter, handleMouseEnter),
|
|
85
86
|
onMouseLeave: wrapEvent(onMouseLeave, handleMouseLeave),
|
|
86
87
|
onMouseMove: wrapEvent(onMouseMove, handleMouseMove),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useTooltip.js","names":["useRef","useEffect","useState","useId","assignMultipleRefs","wrapEvent","send","state","subscription","Blur","Focus","LeavingVisible","MouseDown","MouseEnter","MouseLeave","MouseMove","SelectWithKeyboard","Visible","useTooltip","childProps","childRef","tooltipProps","onMouseEnter","onMouseLeave","onMouseMove","onMouseDown","onKeyDown","onFocus","onBlur","anchorEl","visible","setVisible","id","subscribe","current","handleMouseEnter","handleMouseMove","handleMouseLeave","handleMouseDown","handleFocus","handleBlur","undefined","handleKeyDown","event","key","children","label","tooltipOnMouseEnter","tooltipOnMouseLeave","tooltipOnMouseMove","otherTooltipProps","tooltipId","ref","role"],"sources":["../../../src/Tooltip/useTooltip.ts"],"sourcesContent":["import type {\n HTMLAttributes,\n KeyboardEvent,\n ReactNode,\n Ref,\n RefAttributes,\n RefObject,\n} from 'react';\nimport { useRef, useEffect, useState, useId } from 'react';\n\nimport { assignMultipleRefs } from '../utils/assign-ref';\nimport { wrapEvent } from '../utils/wrap-event';\nimport {\n send,\n state,\n subscription,\n Blur,\n Focus,\n LeavingVisible,\n MouseDown,\n MouseEnter,\n MouseLeave,\n MouseMove,\n SelectWithKeyboard,\n Visible,\n} from './stateMachine';\n\nexport type ChildProps = HTMLAttributes<HTMLElement> &\n RefAttributes<HTMLElement>;\n\nexport interface InjectedTooltipProps extends HTMLAttributes<HTMLElement> {\n anchorEl: RefObject<HTMLElement>;\n visible: boolean;\n children?: ReactNode;\n}\n\nexport function useTooltip(\n childProps: ChildProps,\n childRef: Ref<HTMLElement> | undefined,\n tooltipProps: HTMLAttributes<HTMLElement> & { label?: ReactNode }\n): [ChildProps, InjectedTooltipProps] {\n const {\n onMouseEnter,\n onMouseLeave,\n onMouseMove,\n onMouseDown,\n onKeyDown,\n onFocus,\n onBlur,\n } = childProps;\n const anchorEl = useRef<HTMLElement>(null);\n const [visible, setVisible] = useState(false);\n const id = useId();\n\n useEffect(() => {\n subscription.subscribe(() => {\n setVisible(\n (state.current.state === Visible ||\n state.current.state === LeavingVisible) &&\n state.current.id === id\n );\n });\n }, [id]);\n\n function handleMouseEnter() {\n send(MouseEnter, { id });\n }\n\n function handleMouseMove() {\n send(MouseMove, { id });\n }\n\n function handleMouseLeave() {\n send(MouseLeave);\n }\n\n function handleMouseDown() {\n // Allow quick click from one tool to another\n if (state.current.id === id) {\n send(MouseDown);\n }\n }\n\n function handleFocus() {\n send(Focus, { id });\n }\n\n function handleBlur() {\n // Allow quick click from one tool to another\n if (state.current.id === id) {\n send(Blur, undefined);\n }\n }\n\n function handleKeyDown(event: KeyboardEvent<HTMLElement>) {\n if (event.key === 'Enter' || event.key === ' ') {\n send(SelectWithKeyboard);\n }\n }\n\n const {\n label: children,\n onMouseEnter: tooltipOnMouseEnter,\n onMouseLeave: tooltipOnMouseLeave,\n onMouseMove: tooltipOnMouseMove,\n ...otherTooltipProps\n } = tooltipProps;\n\n const tooltipId = `tooltip-${id}`;\n return [\n {\n ...childProps,\n ref: assignMultipleRefs(childRef, anchorEl),\n ...(visible &&\n !childProps['aria-label'] && { 'aria-describedby': tooltipId }),\n onMouseEnter: wrapEvent(onMouseEnter, handleMouseEnter),\n onMouseLeave: wrapEvent(onMouseLeave, handleMouseLeave),\n onMouseMove: wrapEvent(onMouseMove, handleMouseMove),\n onMouseDown: wrapEvent(onMouseDown, handleMouseDown),\n onFocus: wrapEvent(onFocus, handleFocus),\n onBlur: wrapEvent(onBlur, handleBlur),\n onKeyDown: wrapEvent(onKeyDown, handleKeyDown),\n },\n {\n id: tooltipId,\n anchorEl,\n visible,\n children,\n onMouseEnter: wrapEvent(tooltipOnMouseEnter, handleMouseEnter),\n onMouseLeave: wrapEvent(tooltipOnMouseLeave, handleMouseLeave),\n onMouseMove: wrapEvent(tooltipOnMouseMove, handleMouseMove),\n role: 'tooltip',\n ...otherTooltipProps,\n },\n ];\n}\n"],"mappings":";;;;AAQA,SAASA,MAAT,EAAiBC,SAAjB,EAA4BC,QAA5B,EAAsCC,KAAtC,QAAmD,OAAnD;AAEA,SAASC,kBAAT,QAAmC,qBAAnC;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SACEC,IADF,EAEEC,KAFF,EAGEC,YAHF,EAIEC,IAJF,EAKEC,KALF,EAMEC,cANF,EAOEC,SAPF,EAQEC,UARF,EAS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AAS,CAACoB,WAAD,EAAca,eAAd,CATnB;IAUHX,OAAO,EAAEtB,SAAS,CAACsB,OAAD,EAAUY,WAAV,CAVf;IAWHX,MAAM,EAAEvB,SAAS,CAACuB,MAAD,EAASY,UAAT,CAXd;IAYHd,SAAS,EAAErB,SAAS,CAACqB,SAAD,EAAYgB,aAAZ;EAZjB;IAeHV,EAAE,EAAEmB,SAfD;IAgBHtB,QAAQ,EAARA,QAhBG;IAiBHC,OAAO,EAAPA,OAjBG;IAkBHe,QAAQ,EAARA,QAlBG;IAmBHvB,YAAY,EAAEjB,SAAS,CAAC0C,mBAAD,EAAsBZ,gBAAtB,CAnBpB;IAoBHZ,YAAY,EAAElB,SAAS,CAAC2C,mBAAD,EAAsBX,gBAAtB,CApBpB;IAqBHb,WAAW,EAAEnB,SAAS,CAAC4C,kBAAD,EAAqBb,eAArB,CArBnB;IAsBHiB,IAAI,EAAE;EAtBH,GAuBAH,iBAvBA,EAAP;AA0BD"}
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/index.ts"],"sourcesContent":["export * from './useAutoFocus';\nexport * from './useControlledState';\nexport * from './useChildrenCounter';\nexport * from './useFocusReturn';\nexport * from './useFocusState';\nexport * from './useOnClickOutside';\nexport * from './useOnKeyDown';\nexport * from './useReducerMachine';\nexport * from './useRemoveBodyScroll';\nexport * from './useThrottle';\nexport * from './useMeasure';\nexport * from './useGestureHandlers';\nexport * from './useScope';\n"],"mappings":"AAAA,cAAc,gBAAd;AACA,cAAc,sBAAd;AACA,cAAc,sBAAd;AACA,cAAc,kBAAd;AACA,cAAc,iBAAd;AACA,cAAc,qBAAd;AACA,cAAc,gBAAd;AACA,cAAc,qBAAd;AACA,cAAc,uBAAd;AACA,cAAc,eAAd;AACA,cAAc,cAAd;AACA,cAAc,sBAAd;AACA,cAAc,YAAd"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function useAutoFocus(open: boolean, elementRef:
|
|
1
|
+
import type { MutableRefObject } from 'react';
|
|
2
|
+
export declare function useAutoFocus(open: boolean, elementRef: MutableRefObject<HTMLElement | null>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useAutoFocus.js","names":["useEffect","focusOnChildNode","useAutoFocus","open","elementRef","current","contains","document","activeElement"],"sources":["../../../src/hooks/useAutoFocus.ts"],"sourcesContent":["import type { MutableRefObject } from 'react';\nimport { useEffect } from 'react';\n\nimport { focusOnChildNode } from '../FocusLock/tabUtils';\n\nexport function useAutoFocus(\n open: boolean,\n elementRef: MutableRefObject<HTMLElement | null>\n) {\n useEffect(() => {\n if (open) {\n // We will only autoFocus on the first child if the currently active element isn't already trapped inside the modal\n if (\n elementRef.current &&\n !elementRef.current.contains(document.activeElement)\n ) {\n focusOnChildNode(elementRef.current, 0);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n}\n"],"mappings":"AACA,SAASA,SAAT,QAA0B,OAA1B;AAEA,SAASC,gBAAT,QAAiC,uBAAjC;AAEA,OAAO,SAASC,YAAT,CACLC,IADK,EAELC,UAFK,EAGL;EACAJ,SAAS,CAAC,YAAM;IACd,IAAIG,IAAJ,EAAU;MACR;MACA,IACEC,UAAU,CAACC,OAAX,IACA,CAACD,UAAU,CAACC,OAAX,CAAmBC,QAAnB,CAA4BC,QAAQ,CAACC,aAArC,CAFH,EAGE;QACAP,gBAAgB,CAACG,UAAU,CAACC,OAAZ,EAAqB,CAArB,CAAhB;MACD;IACF,CATa,CAUd;;EACD,CAXQ,EAWN,CAACF,IAAD,CAXM,CAAT;AAYD"}
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useChildrenCounter.js","names":["useEffect","useChildrenCounterParent","itemsRef","current","isNewRender","useChildrenCounterChild","itemIndexRef","obj","disabled","length","Function","push"],"sources":["../../../src/hooks/useChildrenCounter.ts"],"sourcesContent":["import type { MutableRefObject } from 'react';\nimport { useEffect } from 'react';\n\nexport function useChildrenCounterParent<T>(\n itemsRef: MutableRefObject<T[] & { isNewRender?: boolean }>\n) {\n // Reset the options ref every render so that they are always\n // accurate and ready for keyboard navigation handlers. Using layout\n // effect to schedule this effect before the ComboboxOptions push into\n // the array\n itemsRef.current = [];\n itemsRef.current.isNewRender = true;\n\n useEffect(() => {\n // Rendering is finished. Meaning any children can now rerender,\n // and they should not push any new items to our array, because\n // it is not a new render\n itemsRef.current.isNewRender = false;\n });\n\n useEffect(() => {\n // When we are unmounting, it means there are no children anymore.\n // Clear out our items array\n return () => {\n itemsRef.current = [];\n };\n }, [itemsRef]);\n}\n\nexport function useChildrenCounterChild<T>(\n itemsRef: MutableRefObject<T[] & { isNewRender?: boolean }> | undefined,\n itemIndexRef: MutableRefObject<number>,\n obj: T | ((idx: number) => T),\n disabled = false\n) {\n if (itemsRef && itemsRef.current.isNewRender) {\n if (disabled) {\n itemIndexRef.current = -1;\n return;\n }\n\n // push this option to the optionsRef array\n itemIndexRef.current = itemsRef.current.length;\n\n if (obj instanceof Function) {\n itemsRef.current.push(obj(itemIndexRef.current));\n } else {\n itemsRef.current.push(obj);\n }\n }\n}\n"],"mappings":"AACA,SAASA,SAAT,QAA0B,OAA1B;AAEA,OAAO,SAASC,wBAAT,CACLC,QADK,EAEL;EACA;EACA;EACA;EACA;EACAA,QAAQ,CAACC,OAAT,GAAmB,EAAnB;EACAD,QAAQ,CAACC,OAAT,CAAiBC,WAAjB,GAA+B,IAA/B;EAEAJ,SAAS,CAAC,YAAM;IACd;IACA;IACA;IACAE,QAAQ,CAACC,OAAT,CAAiBC,WAAjB,GAA+B,KAA/B;EACD,CALQ,CAAT;EAOAJ,SAAS,CAAC,YAAM;IACd;IACA;IACA,OAAO,YAAM;MACXE,QAAQ,CAACC,OAAT,GAAmB,EAAnB;IACD,CAFD;EAGD,CANQ,EAMN,CAACD,QAAD,CANM,CAAT;AAOD;AAED,OAAO,SAASG,uBAAT,CACLH,QADK,EAELI,YAFK,EAGLC,GAHK,EAKL;EAAA,IADAC,QACA,uEADW,KACX;;EACA,IAAIN,QAAQ,IAAIA,QAAQ,CAACC,OAAT,CAAiBC,WAAjC,EAA8C;IAC5C,IAAII,QAAJ,EAAc;MACZF,YAAY,CAACH,OAAb,GAAuB,CAAC,CAAxB;MACA;IACD,CAJ2C,CAM5C;;;IACAG,YAAY,CAACH,OAAb,GAAuBD,QAAQ,CAACC,OAAT,CAAiBM,MAAxC;;IAEA,IAAIF,GAAG,YAAYG,QAAnB,EAA6B;MAC3BR,QAAQ,CAACC,OAAT,CAAiBQ,IAAjB,CAAsBJ,GAAG,CAACD,YAAY,CAACH,OAAd,CAAzB;IACD,CAFD,MAEO;MACLD,QAAQ,CAACC,OAAT,CAAiBQ,IAAjB,CAAsBJ,GAAtB;IACD;EACF;AACF"}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Dispatch, SetStateAction, SyntheticEvent } from 'react';
|
|
2
2
|
import type { CustomEventHandler } from '../utils';
|
|
3
|
-
export declare function useControlledState<V, E extends
|
|
4
|
-
V,
|
|
5
|
-
CustomEventHandler<E, H> | undefined,
|
|
6
|
-
React.Dispatch<React.SetStateAction<V>>
|
|
7
|
-
];
|
|
3
|
+
export declare function useControlledState<V, E extends SyntheticEvent<any> | Event, H extends unknown[]>(valueProp: V | undefined, onChangeProp: CustomEventHandler<E, H> | undefined, defaultValue: V | (() => V), defaultOnChange: (setValue: Dispatch<SetStateAction<V>>) => CustomEventHandler<E, H>): [V, CustomEventHandler<E, H>];
|
|
@@ -2,23 +2,24 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
2
2
|
import { useRef, useState } from 'react';
|
|
3
3
|
import { wrapEvent } from '../utils';
|
|
4
4
|
export function useControlledState(valueProp, onChangeProp, defaultValue, defaultOnChange) {
|
|
5
|
-
var isControlled =
|
|
5
|
+
var isControlled = valueProp !== undefined;
|
|
6
|
+
var wasControlled = useRef(isControlled);
|
|
6
7
|
|
|
7
8
|
var _useState = useState(defaultValue),
|
|
8
9
|
_useState2 = _slicedToArray(_useState, 2),
|
|
9
10
|
valueState = _useState2[0],
|
|
10
11
|
setValueState = _useState2[1];
|
|
11
12
|
|
|
12
|
-
if (isControlled
|
|
13
|
-
if (
|
|
13
|
+
if (isControlled) {
|
|
14
|
+
if (wasControlled.current && process.env.NODE_ENV !== 'production') {
|
|
14
15
|
console.warn('Trying to change from controlled to uncontrolled.');
|
|
15
|
-
}
|
|
16
|
+
}
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
return [// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
19
|
+
valueProp, wrapEvent(onChangeProp, defaultOnChange(setValueState))];
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
return [// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
22
|
-
valueState, wrapEvent(onChangeProp, defaultOnChange(setValueState))
|
|
23
|
+
valueState, wrapEvent(onChangeProp, defaultOnChange(setValueState))];
|
|
23
24
|
}
|
|
24
25
|
//# sourceMappingURL=useControlledState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useControlledState.js","names":["useRef","useState","wrapEvent","useControlledState","valueProp","onChangeProp","defaultValue","defaultOnChange","isControlled","undefined","wasControlled","valueState","setValueState","current","process","env","NODE_ENV","console","warn"],"sources":["../../../src/hooks/useControlledState.ts"],"sourcesContent":["import type { Dispatch, SetStateAction, SyntheticEvent } from 'react';\nimport { useRef, useState } from 'react';\n\nimport type { CustomEventHandler } from '../utils';\nimport { wrapEvent } from '../utils';\n\nexport function useControlledState<\n V,\n E extends SyntheticEvent<any> | Event,\n H extends unknown[]\n>(\n valueProp: V | undefined,\n onChangeProp: CustomEventHandler<E, H> | undefined,\n defaultValue: V | (() => V),\n defaultOnChange: (\n setValue: Dispatch<SetStateAction<V>>\n ) => CustomEventHandler<E, H>\n): [V, CustomEventHandler<E, H>] {\n const isControlled = valueProp !== undefined;\n const wasControlled = useRef(isControlled);\n const [valueState, setValueState] = useState<V>(defaultValue);\n\n if (isControlled) {\n if (wasControlled.current && process.env.NODE_ENV !== 'production') {\n console.warn('Trying to change from controlled to uncontrolled.');\n }\n return [\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n valueProp!,\n wrapEvent(onChangeProp, defaultOnChange(setValueState)),\n ];\n }\n\n return [\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n valueState!,\n wrapEvent(onChangeProp, defaultOnChange(setValueState)),\n ];\n}\n"],"mappings":";AACA,SAASA,MAAT,EAAiBC,QAAjB,QAAiC,OAAjC;AAGA,SAASC,SAAT,QAA0B,UAA1B;AAEA,OAAO,SAASC,kBAAT,CAKLC,SALK,EAMLC,YANK,EAOLC,YAPK,EAQLC,eARK,EAW0B;EAC/B,IAAMC,YAAY,GAAGJ,SAAS,KAAKK,SAAnC;EACA,IAAMC,aAAa,GAAGV,MAAM,CAACQ,YAAD,CAA5B;;EACA,gBAAoCP,QAAQ,CAAIK,YAAJ,CAA5C;EAAA;EAAA,IAAOK,UAAP;EAAA,IAAmBC,aAAnB;;EAEA,IAAIJ,YAAJ,EAAkB;IAChB,IAAIE,aAAa,CAACG,OAAd,IAAyBC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAAtD,EAAoE;MAClEC,OAAO,CAACC,IAAR,CAAa,mDAAb;IACD;;IACD,OAAO,CACL;IACAd,SAFK,EAGLF,SAAS,CAACG,YAAD,EAAeE,eAAe,CAACK,aAAD,CAA9B,CAHJ,CAAP;EAKD;;EAED,OAAO,CACL;EACAD,UAFK,EAGLT,SAAS,CAACG,YAAD,EAAeE,eAAe,CAACK,aAAD,CAA9B,CAHJ,CAAP;AAKD"}
|
|
File without changes
|
|
@@ -13,7 +13,7 @@ export function useFocusReturn(open, rootEl) {
|
|
|
13
13
|
|
|
14
14
|
// once opened, keep track of the element that triggered
|
|
15
15
|
// the Modal opening
|
|
16
|
-
if (!previousFocusRef.current && document.activeElement instanceof HTMLElement && !((_rootEl$current = rootEl.current)
|
|
16
|
+
if (!previousFocusRef.current && document.activeElement instanceof HTMLElement && !((_rootEl$current = rootEl.current) !== null && _rootEl$current !== void 0 && _rootEl$current.contains(document.activeElement))) {
|
|
17
17
|
previousFocusRef.current = document.activeElement;
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -21,7 +21,7 @@ export function useFocusReturn(open, rootEl) {
|
|
|
21
21
|
var previousElement = previousFocusRef.current;
|
|
22
22
|
return function () {
|
|
23
23
|
// on unmount, return focus to that element
|
|
24
|
-
if (previousElement && !(rootElement
|
|
24
|
+
if (previousElement && !(rootElement !== null && rootElement !== void 0 && rootElement.contains(document.activeElement))) {
|
|
25
25
|
previousElement.focus({
|
|
26
26
|
preventScroll: true
|
|
27
27
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useFocusReturn.js","names":["useEffect","useRef","useFocusReturn","open","rootEl","previousFocusRef","document","activeElement","HTMLElement","current","contains","rootElement","previousElement","focus","preventScroll"],"sources":["../../../src/hooks/useFocusReturn.ts"],"sourcesContent":["import type { MutableRefObject } from 'react';\nimport { useEffect, useRef } from 'react';\n\nexport function useFocusReturn(\n open: boolean,\n rootEl: MutableRefObject<HTMLElement | null>\n) {\n const previousFocusRef = useRef<HTMLElement | null>(\n (() => {\n if (\n open &&\n typeof document !== 'undefined' &&\n document.activeElement instanceof HTMLElement\n ) {\n return document.activeElement;\n }\n return null;\n })()\n );\n\n useEffect(() => {\n if (open) {\n // once opened, keep track of the element that triggered\n // the Modal opening\n if (\n !previousFocusRef.current &&\n document.activeElement instanceof HTMLElement &&\n !rootEl.current?.contains(document.activeElement)\n ) {\n previousFocusRef.current = document.activeElement;\n }\n\n const rootElement = rootEl.current;\n const previousElement = previousFocusRef.current;\n return () => {\n // on unmount, return focus to that element\n if (previousElement && !rootElement?.contains(document.activeElement)) {\n previousElement.focus({ preventScroll: true });\n }\n };\n }\n }, [open, rootEl]);\n}\n"],"mappings":"AACA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,OAAlC;AAEA,OAAO,SAASC,cAAT,CACLC,IADK,EAELC,MAFK,EAGL;EACA,IAAMC,gBAAgB,GAAGJ,MAAM,CAC5B,YAAM;IACL,IACEE,IAAI,IACJ,OAAOG,QAAP,KAAoB,WADpB,IAEAA,QAAQ,CAACC,aAAT,YAAkCC,WAHpC,EAIE;MACA,OAAOF,QAAQ,CAACC,aAAhB;IACD;;IACD,OAAO,IAAP;EACD,CATD,EAD6B,CAA/B;EAaAP,SAAS,CAAC,YAAM;IACd,IAAIG,IAAJ,EAAU;MAAA;;MACR;MACA;MACA,IACE,CAACE,gBAAgB,CAACI,OAAlB,IACAH,QAAQ,CAACC,aAAT,YAAkCC,WADlC,IAEA,qBAACJ,MAAM,CAACK,OAAR,4CAAC,gBAAgBC,QAAhB,CAAyBJ,QAAQ,CAACC,aAAlC,CAAD,CAHF,EAIE;QACAF,gBAAgB,CAACI,OAAjB,GAA2BH,QAAQ,CAACC,aAApC;MACD;;MAED,IAAMI,WAAW,GAAGP,MAAM,CAACK,OAA3B;MACA,IAAMG,eAAe,GAAGP,gBAAgB,CAACI,OAAzC;MACA,OAAO,YAAM;QACX;QACA,IAAIG,eAAe,IAAI,EAACD,WAAD,aAACA,WAAD,eAACA,WAAW,CAAED,QAAb,CAAsBJ,QAAQ,CAACC,aAA/B,CAAD,CAAvB,EAAuE;UACrEK,eAAe,CAACC,KAAhB,CAAsB;YAAEC,aAAa,EAAE;UAAjB,CAAtB;QACD;MACF,CALD;IAMD;EACF,CArBQ,EAqBN,CAACX,IAAD,EAAOC,MAAP,CArBM,CAAT;AAsBD"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import type { FocusEventHandler } from 'react';
|
|
2
2
|
export declare function useFocusState<T>(props?: {
|
|
3
|
-
onFocus?:
|
|
4
|
-
onBlur?:
|
|
3
|
+
onFocus?: FocusEventHandler<T>;
|
|
4
|
+
onBlur?: FocusEventHandler<T>;
|
|
5
5
|
}): {
|
|
6
6
|
bind: {
|
|
7
|
-
onFocus: import("../utils/
|
|
8
|
-
onBlur: import("../utils/
|
|
7
|
+
onFocus: import("../utils/wrap-event").CustomEventHandler<import("react").FocusEvent<T, Element>, []>;
|
|
8
|
+
onBlur: import("../utils/wrap-event").CustomEventHandler<import("react").FocusEvent<T, Element>, []>;
|
|
9
9
|
};
|
|
10
10
|
hasFocus: boolean;
|
|
11
11
|
};
|