@basic-ui/core 0.0.54 → 0.0.57
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 +364 -591
- package/build/cjs/index.js.map +1 -1
- package/build/esm/Accordion/Accordion.d.ts +9 -9
- package/build/esm/Accordion/Accordion.js +20 -29
- package/build/esm/Accordion/Accordion.js.map +1 -1
- package/build/esm/Accordion/AccordionBody.d.ts +6 -6
- package/build/esm/Accordion/AccordionBody.js +18 -32
- package/build/esm/Accordion/AccordionBody.js.map +1 -1
- package/build/esm/Accordion/AccordionHeader.d.ts +7 -7
- package/build/esm/Accordion/AccordionHeader.js +37 -74
- package/build/esm/Accordion/AccordionHeader.js.map +1 -1
- package/build/esm/Accordion/AccordionItem.d.ts +9 -9
- package/build/esm/Accordion/AccordionItem.js +19 -22
- package/build/esm/Accordion/AccordionItem.js.map +1 -1
- package/build/esm/Accordion/context.d.ts +19 -19
- package/build/esm/Accordion/context.js +16 -13
- 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/CheckBox/CheckBox.d.ts +7 -7
- package/build/esm/CheckBox/CheckBox.js +15 -25
- 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 +52 -59
- package/build/esm/ComboBox/Combobox.js.map +1 -1
- package/build/esm/ComboBox/ComboboxButton.d.ts +9 -9
- package/build/esm/ComboBox/ComboboxButton.js +23 -28
- package/build/esm/ComboBox/ComboboxButton.js.map +1 -1
- package/build/esm/ComboBox/ComboboxInput.d.ts +17 -17
- package/build/esm/ComboBox/ComboboxInput.js +67 -70
- package/build/esm/ComboBox/ComboboxInput.js.map +1 -1
- package/build/esm/ComboBox/ComboboxLabel.d.ts +7 -7
- package/build/esm/ComboBox/ComboboxLabel.js +15 -17
- package/build/esm/ComboBox/ComboboxLabel.js.map +1 -1
- package/build/esm/ComboBox/ComboboxList.d.ts +8 -8
- package/build/esm/ComboBox/ComboboxList.js +19 -20
- package/build/esm/ComboBox/ComboboxList.js.map +1 -1
- package/build/esm/ComboBox/ComboboxOption.d.ts +11 -11
- package/build/esm/ComboBox/ComboboxOption.js +41 -45
- package/build/esm/ComboBox/ComboboxOption.js.map +1 -1
- package/build/esm/ComboBox/ComboboxPopover.d.ts +9 -9
- package/build/esm/ComboBox/ComboboxPopover.js +22 -21
- 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 +5 -6
- package/build/esm/ComboBox/context.js.map +1 -1
- package/build/esm/ComboBox/hooks.d.ts +37 -37
- package/build/esm/ComboBox/hooks.js +175 -148
- 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 +3 -6
- 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/FocusLock/FocusLock.d.ts +9 -9
- package/build/esm/FocusLock/FocusLock.js +26 -32
- 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 +5 -7
- package/build/esm/FocusLock/tabUtils.js.map +1 -1
- package/build/esm/FocusLock/useFocusLock.d.ts +7 -7
- package/build/esm/FocusLock/useFocusLock.js +14 -19
- package/build/esm/FocusLock/useFocusLock.js.map +1 -1
- package/build/esm/List/List.d.ts +7 -7
- package/build/esm/List/List.js +9 -11
- package/build/esm/List/List.js.map +1 -1
- package/build/esm/List/ListItem.d.ts +7 -7
- package/build/esm/List/ListItem.js +9 -11
- package/build/esm/List/ListItem.js.map +1 -1
- package/build/esm/List/context.d.ts +4 -4
- package/build/esm/List/context.js +6 -6
- 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 +32 -37
- package/build/esm/Menu/ContextMenuTrigger.js.map +1 -1
- package/build/esm/Menu/Menu.d.ts +10 -10
- package/build/esm/Menu/Menu.js +33 -49
- package/build/esm/Menu/Menu.js.map +1 -1
- package/build/esm/Menu/MenuButton.d.ts +11 -11
- package/build/esm/Menu/MenuButton.js +28 -44
- package/build/esm/Menu/MenuButton.js.map +1 -1
- package/build/esm/Menu/MenuItem.d.ts +8 -8
- package/build/esm/Menu/MenuItem.js +29 -38
- package/build/esm/Menu/MenuItem.js.map +1 -1
- package/build/esm/Menu/MenuList.d.ts +7 -7
- package/build/esm/Menu/MenuList.js +61 -116
- package/build/esm/Menu/MenuList.js.map +1 -1
- package/build/esm/Menu/MenuPopover.d.ts +8 -8
- package/build/esm/Menu/MenuPopover.js +16 -19
- package/build/esm/Menu/MenuPopover.js.map +1 -1
- package/build/esm/Menu/context.d.ts +25 -25
- package/build/esm/Menu/context.js +14 -12
- 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 +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 +13 -18
- package/build/esm/Modal/Modal.js.map +1 -1
- package/build/esm/Modal/ModalBackdrop.d.ts +10 -10
- package/build/esm/Modal/ModalBackdrop.js +24 -33
- 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 +44 -60
- package/build/esm/Popper/Popper.js.map +1 -1
- package/build/esm/Popper/PopperArrow.d.ts +6 -6
- package/build/esm/Popper/PopperArrow.js +11 -16
- package/build/esm/Popper/PopperArrow.js.map +1 -1
- package/build/esm/Popper/context.d.ts +6 -6
- package/build/esm/Popper/context.js +3 -5
- 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 -7
- package/build/esm/Portal/Portal.js +9 -11
- package/build/esm/Portal/Portal.js.map +1 -1
- package/build/esm/Portal/PortalSelectorProvider.d.ts +8 -8
- package/build/esm/Portal/PortalSelectorProvider.js +6 -4
- package/build/esm/Portal/PortalSelectorProvider.js.map +1 -1
- package/build/esm/Portal/index.d.ts +2 -2
- package/build/esm/Portal/index.js.map +1 -1
- package/build/esm/RadioButton/RadioButton.d.ts +10 -10
- package/build/esm/RadioButton/RadioButton.js +17 -23
- package/build/esm/RadioButton/RadioButton.js.map +1 -1
- package/build/esm/RadioButton/RadioGroup.d.ts +12 -12
- package/build/esm/RadioButton/RadioGroup.js +19 -28
- package/build/esm/RadioButton/RadioGroup.js.map +1 -1
- package/build/esm/RadioButton/context.d.ts +9 -9
- package/build/esm/RadioButton/context.js +8 -6
- 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 +9 -11
- 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 +422 -489
- 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 +31 -59
- package/build/esm/Spinner/Spinner.js.map +1 -1
- package/build/esm/Spinner/SpinnerButton.d.ts +8 -8
- package/build/esm/Spinner/SpinnerButton.js +14 -19
- package/build/esm/Spinner/SpinnerButton.js.map +1 -1
- package/build/esm/Spinner/context.d.ts +12 -12
- package/build/esm/Spinner/context.js +8 -7
- 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 +32 -50
- package/build/esm/Tabs/Tab.js.map +1 -1
- package/build/esm/Tabs/TabList.d.ts +9 -9
- package/build/esm/Tabs/TabList.js +24 -34
- package/build/esm/Tabs/TabList.js.map +1 -1
- package/build/esm/Tabs/TabPanel.d.ts +8 -8
- package/build/esm/Tabs/TabPanel.js +16 -23
- package/build/esm/Tabs/TabPanel.js.map +1 -1
- package/build/esm/Tabs/TabPanels.d.ts +8 -8
- package/build/esm/Tabs/TabPanels.js +15 -20
- package/build/esm/Tabs/TabPanels.js.map +1 -1
- package/build/esm/Tabs/Tabs.d.ts +10 -10
- package/build/esm/Tabs/Tabs.js +17 -33
- package/build/esm/Tabs/Tabs.js.map +1 -1
- package/build/esm/Tabs/context.d.ts +17 -17
- package/build/esm/Tabs/context.js +16 -13
- 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 +20 -30
- 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 +95 -81
- package/build/esm/Tooltip/stateMachine.js.map +1 -1
- package/build/esm/Tooltip/useTooltip.d.ts +10 -10
- package/build/esm/Tooltip/useTooltip.js +38 -50
- 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 +3 -3
- package/build/esm/hooks/useAutoFocus.js.map +1 -1
- package/build/esm/hooks/useChildrenCounter.d.ts +7 -7
- package/build/esm/hooks/useChildrenCounter.js +6 -8
- package/build/esm/hooks/useChildrenCounter.js.map +1 -1
- package/build/esm/hooks/useControlledState.d.ts +3 -3
- package/build/esm/hooks/useControlledState.js +6 -16
- package/build/esm/hooks/useControlledState.js.map +1 -1
- package/build/esm/hooks/useFocusReturn.d.ts +2 -2
- package/build/esm/hooks/useFocusReturn.js +8 -12
- package/build/esm/hooks/useFocusReturn.js.map +1 -1
- package/build/esm/hooks/useFocusState.d.ts +11 -11
- package/build/esm/hooks/useFocusState.js +9 -15
- package/build/esm/hooks/useFocusState.js.map +1 -1
- package/build/esm/hooks/useGestureHandlers.d.ts +52 -52
- package/build/esm/hooks/useGestureHandlers.js +80 -100
- package/build/esm/hooks/useGestureHandlers.js.map +1 -1
- package/build/esm/hooks/useMeasure.d.ts +7 -7
- package/build/esm/hooks/useMeasure.js +7 -15
- package/build/esm/hooks/useMeasure.js.map +1 -1
- package/build/esm/hooks/useOnClickOutside.d.ts +2 -2
- package/build/esm/hooks/useOnClickOutside.js +4 -6
- package/build/esm/hooks/useOnClickOutside.js.map +1 -1
- package/build/esm/hooks/useOnKeyDown.d.ts +1 -1
- package/build/esm/hooks/useOnKeyDown.js +3 -4
- package/build/esm/hooks/useOnKeyDown.js.map +1 -1
- package/build/esm/hooks/useReducerMachine.d.ts +24 -24
- package/build/esm/hooks/useReducerMachine.js +15 -26
- package/build/esm/hooks/useReducerMachine.js.map +1 -1
- package/build/esm/hooks/useRemoveBodyScroll.d.ts +2 -2
- package/build/esm/hooks/useRemoveBodyScroll.js +9 -14
- package/build/esm/hooks/useRemoveBodyScroll.js.map +1 -1
- package/build/esm/hooks/useScope.d.ts +11 -11
- package/build/esm/hooks/useScope.js +12 -14
- package/build/esm/hooks/useScope.js.map +1 -1
- package/build/esm/hooks/useThrottle.d.ts +1 -1
- package/build/esm/hooks/useThrottle.js +5 -10
- package/build/esm/hooks/useThrottle.js.map +1 -1
- package/build/esm/index.d.ts +15 -15
- package/build/esm/index.js +4 -2
- package/build/esm/index.js.map +1 -1
- package/build/esm/styles.d.js +2 -0
- package/build/esm/styles.d.js.map +1 -0
- package/build/esm/utils/assign-ref.d.ts +3 -3
- package/build/esm/utils/assign-ref.js +3 -5
- package/build/esm/utils/assign-ref.js.map +1 -1
- 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 +13 -20
- 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 +5 -10
- 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 +0 -1
- package/build/esm/utils/get-circular-index.js.map +1 -1
- 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 +6 -6
- 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 +2 -5
- package/build/esm/utils/rubber-band-clamp.js.map +1 -1
- package/build/esm/utils/use-stable-callback.d.ts +16 -16
- package/build/esm/utils/use-stable-callback.js +24 -26
- 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 +2 -5
- package/build/esm/utils/wrap-event.js.map +1 -1
- package/build/tsconfig-build.tsbuildinfo +1 -1
- package/package.json +7 -11
- 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 +166 -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 +110 -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 +448 -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 +55 -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 +82 -83
- package/src/Menu/MenuButton.tsx +83 -83
- package/src/Menu/MenuComplex.story.tsx +58 -58
- package/src/Menu/MenuItem.tsx +87 -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 +262 -258
- package/src/Modal/Modal.tsx +48 -48
- package/src/Modal/ModalBackdrop.tsx +78 -78
- package/src/Modal/NavDrawer.story.tsx +161 -158
- package/src/Modal/index.ts +2 -2
- package/src/Modal/styles.css +46 -46
- package/src/Popper/Popper.story.tsx +279 -263
- package/src/Popper/Popper.tsx +1 -1
- 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/RadioButton/RadioButton.story.tsx +78 -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 +1115 -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 +53 -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/useControlledState.ts +1 -6
- package/src/hooks/useFocusReturn.ts +43 -43
- package/src/hooks/useFocusState.ts +30 -30
- package/src/hooks/useGestureHandlers.ts +282 -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 +38 -39
- package/src/hooks/useScope.ts +52 -52
- package/src/hooks/useThrottle.ts +19 -19
- package/src/index.ts +20 -20
- package/src/styles.d.ts +1 -0
- 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 +82 -78
- package/src/utils/rubber-band-clamp.ts +25 -25
- package/src/utils/use-stable-callback.ts +57 -58
- package/src/utils/wrap-event.ts +22 -22
|
@@ -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":"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","ignoreList":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { HTMLAttributes, ReactNode, Ref, RefAttributes, RefObject } from 'react';
|
|
2
|
-
export
|
|
3
|
-
export interface InjectedTooltipProps extends HTMLAttributes<HTMLElement> {
|
|
4
|
-
anchorEl: RefObject<HTMLElement>;
|
|
5
|
-
visible: boolean;
|
|
6
|
-
children?: ReactNode;
|
|
7
|
-
}
|
|
8
|
-
export declare function useTooltip(childProps: ChildProps, childRef: Ref<HTMLElement> | undefined, tooltipProps: HTMLAttributes<HTMLElement> & {
|
|
9
|
-
label?: ReactNode;
|
|
10
|
-
}): [ChildProps, InjectedTooltipProps];
|
|
1
|
+
import type { HTMLAttributes, ReactNode, Ref, RefAttributes, RefObject } from 'react';
|
|
2
|
+
export type ChildProps = HTMLAttributes<HTMLElement> & RefAttributes<HTMLElement>;
|
|
3
|
+
export interface InjectedTooltipProps extends HTMLAttributes<HTMLElement> {
|
|
4
|
+
anchorEl: RefObject<HTMLElement | null>;
|
|
5
|
+
visible: boolean;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare function useTooltip(childProps: ChildProps, childRef: Ref<HTMLElement> | undefined, tooltipProps: HTMLAttributes<HTMLElement> & {
|
|
9
|
+
label?: ReactNode;
|
|
10
|
+
}): [ChildProps, InjectedTooltipProps];
|
|
@@ -1,87 +1,74 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
-
var _excluded = ["label", "onMouseEnter", "onMouseLeave", "onMouseMove"];
|
|
5
1
|
import { useRef, useEffect, useState, useId } from 'react';
|
|
6
2
|
import { assignMultipleRefs } from '../utils/assign-ref';
|
|
7
3
|
import { wrapEvent } from '../utils/wrap-event';
|
|
8
4
|
import { send, state, subscription, Blur, Focus, LeavingVisible, MouseDown, MouseEnter, MouseLeave, MouseMove, SelectWithKeyboard, Visible } from './stateMachine';
|
|
9
5
|
export function useTooltip(childProps, childRef, tooltipProps) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var id = useId();
|
|
25
|
-
useEffect(function () {
|
|
26
|
-
subscription.subscribe(function () {
|
|
6
|
+
const {
|
|
7
|
+
onMouseEnter,
|
|
8
|
+
onMouseLeave,
|
|
9
|
+
onMouseMove,
|
|
10
|
+
onMouseDown,
|
|
11
|
+
onKeyDown,
|
|
12
|
+
onFocus,
|
|
13
|
+
onBlur
|
|
14
|
+
} = childProps;
|
|
15
|
+
const anchorEl = useRef(null);
|
|
16
|
+
const [visible, setVisible] = useState(false);
|
|
17
|
+
const id = useId();
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
subscription.subscribe(() => {
|
|
27
20
|
setVisible((state.current.state === Visible || state.current.state === LeavingVisible) && state.current.id === id);
|
|
28
21
|
});
|
|
29
22
|
}, [id]);
|
|
30
|
-
|
|
31
23
|
function handleMouseEnter() {
|
|
32
24
|
send(MouseEnter, {
|
|
33
|
-
id
|
|
25
|
+
id
|
|
34
26
|
});
|
|
35
27
|
}
|
|
36
|
-
|
|
37
28
|
function handleMouseMove() {
|
|
38
29
|
send(MouseMove, {
|
|
39
|
-
id
|
|
30
|
+
id
|
|
40
31
|
});
|
|
41
32
|
}
|
|
42
|
-
|
|
43
33
|
function handleMouseLeave() {
|
|
44
34
|
send(MouseLeave);
|
|
45
35
|
}
|
|
46
|
-
|
|
47
36
|
function handleMouseDown() {
|
|
48
37
|
// Allow quick click from one tool to another
|
|
49
38
|
if (state.current.id === id) {
|
|
50
39
|
send(MouseDown);
|
|
51
40
|
}
|
|
52
41
|
}
|
|
53
|
-
|
|
54
42
|
function handleFocus() {
|
|
55
43
|
send(Focus, {
|
|
56
|
-
id
|
|
44
|
+
id
|
|
57
45
|
});
|
|
58
46
|
}
|
|
59
|
-
|
|
60
47
|
function handleBlur() {
|
|
61
48
|
// Allow quick click from one tool to another
|
|
62
49
|
if (state.current.id === id) {
|
|
63
50
|
send(Blur, undefined);
|
|
64
51
|
}
|
|
65
52
|
}
|
|
66
|
-
|
|
67
53
|
function handleKeyDown(event) {
|
|
68
54
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
69
55
|
send(SelectWithKeyboard);
|
|
70
56
|
}
|
|
71
57
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return [
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
'aria-
|
|
84
|
-
|
|
58
|
+
const {
|
|
59
|
+
label: children,
|
|
60
|
+
onMouseEnter: tooltipOnMouseEnter,
|
|
61
|
+
onMouseLeave: tooltipOnMouseLeave,
|
|
62
|
+
onMouseMove: tooltipOnMouseMove,
|
|
63
|
+
...otherTooltipProps
|
|
64
|
+
} = tooltipProps;
|
|
65
|
+
const tooltipId = `tooltip-${id}`;
|
|
66
|
+
return [{
|
|
67
|
+
...childProps,
|
|
68
|
+
ref: assignMultipleRefs(childRef, anchorEl),
|
|
69
|
+
...(visible && !childProps['aria-label'] && {
|
|
70
|
+
'aria-describedby': tooltipId
|
|
71
|
+
}),
|
|
85
72
|
onMouseEnter: wrapEvent(onMouseEnter, handleMouseEnter),
|
|
86
73
|
onMouseLeave: wrapEvent(onMouseLeave, handleMouseLeave),
|
|
87
74
|
onMouseMove: wrapEvent(onMouseMove, handleMouseMove),
|
|
@@ -89,15 +76,16 @@ export function useTooltip(childProps, childRef, tooltipProps) {
|
|
|
89
76
|
onFocus: wrapEvent(onFocus, handleFocus),
|
|
90
77
|
onBlur: wrapEvent(onBlur, handleBlur),
|
|
91
78
|
onKeyDown: wrapEvent(onKeyDown, handleKeyDown)
|
|
92
|
-
}
|
|
79
|
+
}, {
|
|
93
80
|
id: tooltipId,
|
|
94
|
-
anchorEl
|
|
95
|
-
visible
|
|
96
|
-
children
|
|
81
|
+
anchorEl,
|
|
82
|
+
visible,
|
|
83
|
+
children,
|
|
97
84
|
onMouseEnter: wrapEvent(tooltipOnMouseEnter, handleMouseEnter),
|
|
98
85
|
onMouseLeave: wrapEvent(tooltipOnMouseLeave, handleMouseLeave),
|
|
99
86
|
onMouseMove: wrapEvent(tooltipOnMouseMove, handleMouseMove),
|
|
100
|
-
role: 'tooltip'
|
|
101
|
-
|
|
87
|
+
role: 'tooltip',
|
|
88
|
+
...otherTooltipProps
|
|
89
|
+
}];
|
|
102
90
|
}
|
|
103
91
|
//# sourceMappingURL=useTooltip.js.map
|
|
@@ -1 +1 @@
|
|
|
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","
|
|
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","label","children","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 | null>;\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":"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","ignoreList":[]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export * from './useAutoFocus';
|
|
2
|
-
export * from './useControlledState';
|
|
3
|
-
export * from './useChildrenCounter';
|
|
4
|
-
export * from './useFocusReturn';
|
|
5
|
-
export * from './useFocusState';
|
|
6
|
-
export * from './useOnClickOutside';
|
|
7
|
-
export * from './useOnKeyDown';
|
|
8
|
-
export * from './useReducerMachine';
|
|
9
|
-
export * from './useRemoveBodyScroll';
|
|
10
|
-
export * from './useThrottle';
|
|
11
|
-
export * from './useMeasure';
|
|
12
|
-
export * from './useGestureHandlers';
|
|
13
|
-
export * from './useScope';
|
|
1
|
+
export * from './useAutoFocus';
|
|
2
|
+
export * from './useControlledState';
|
|
3
|
+
export * from './useChildrenCounter';
|
|
4
|
+
export * from './useFocusReturn';
|
|
5
|
+
export * from './useFocusState';
|
|
6
|
+
export * from './useOnClickOutside';
|
|
7
|
+
export * from './useOnKeyDown';
|
|
8
|
+
export * from './useReducerMachine';
|
|
9
|
+
export * from './useRemoveBodyScroll';
|
|
10
|
+
export * from './useThrottle';
|
|
11
|
+
export * from './useMeasure';
|
|
12
|
+
export * from './useGestureHandlers';
|
|
13
|
+
export * from './useScope';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/index.ts"],"sourcesContent":["export * from './useAutoFocus';\
|
|
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,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,kBAAkB;AAChC,cAAc,iBAAiB;AAC/B,cAAc,qBAAqB;AACnC,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB;AACnC,cAAc,uBAAuB;AACrC,cAAc,eAAe;AAC7B,cAAc,cAAc;AAC5B,cAAc,sBAAsB;AACpC,cAAc,YAAY","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { MutableRefObject } from 'react';
|
|
2
|
-
export declare function useAutoFocus(open: boolean, elementRef: MutableRefObject<HTMLElement | null>): void;
|
|
1
|
+
import type { MutableRefObject } from 'react';
|
|
2
|
+
export declare function useAutoFocus(open: boolean, elementRef: MutableRefObject<HTMLElement | null>): void;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { focusOnChildNode } from '../FocusLock/tabUtils';
|
|
3
3
|
export function useAutoFocus(open, elementRef) {
|
|
4
|
-
useEffect(
|
|
4
|
+
useEffect(() => {
|
|
5
5
|
if (open) {
|
|
6
6
|
// We will only autoFocus on the first child if the currently active element isn't already trapped inside the modal
|
|
7
7
|
if (elementRef.current && !elementRef.current.contains(document.activeElement)) {
|
|
8
8
|
focusOnChildNode(elementRef.current, 0);
|
|
9
9
|
}
|
|
10
|
-
}
|
|
11
|
-
|
|
10
|
+
}
|
|
11
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
12
12
|
}, [open]);
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=useAutoFocus.js.map
|
|
@@ -1 +1 @@
|
|
|
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';\
|
|
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,SAAS,QAAQ,OAAO;AAEjC,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,OAAO,SAASC,YAAYA,CAC1BC,IAAa,EACbC,UAAgD,EAChD;EACAJ,SAAS,CAAC,MAAM;IACd,IAAIG,IAAI,EAAE;MACR;MACA,IACEC,UAAU,CAACC,OAAO,IAClB,CAACD,UAAU,CAACC,OAAO,CAACC,QAAQ,CAACC,QAAQ,CAACC,aAAa,CAAC,EACpD;QACAP,gBAAgB,CAACG,UAAU,CAACC,OAAO,EAAE,CAAC,CAAC;MACzC;IACF;IACA;EACF,CAAC,EAAE,CAACF,IAAI,CAAC,CAAC;AACZ","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { MutableRefObject } from 'react';
|
|
2
|
-
export declare function useChildrenCounterParent<T>(itemsRef: MutableRefObject<T[] & {
|
|
3
|
-
isNewRender?: boolean;
|
|
4
|
-
}>): void;
|
|
5
|
-
export declare function useChildrenCounterChild<T>(itemsRef: MutableRefObject<T[] & {
|
|
6
|
-
isNewRender?: boolean;
|
|
7
|
-
}> | undefined, itemIndexRef: MutableRefObject<number>, obj: T | ((idx: number) => T), disabled?: boolean): void;
|
|
1
|
+
import type { MutableRefObject } from 'react';
|
|
2
|
+
export declare function useChildrenCounterParent<T>(itemsRef: MutableRefObject<T[] & {
|
|
3
|
+
isNewRender?: boolean;
|
|
4
|
+
}>): void;
|
|
5
|
+
export declare function useChildrenCounterChild<T>(itemsRef: MutableRefObject<T[] & {
|
|
6
|
+
isNewRender?: boolean;
|
|
7
|
+
}> | undefined, itemIndexRef: MutableRefObject<number>, obj: T | ((idx: number) => T), disabled?: boolean): void;
|
|
@@ -6,32 +6,30 @@ export function useChildrenCounterParent(itemsRef) {
|
|
|
6
6
|
// the array
|
|
7
7
|
itemsRef.current = [];
|
|
8
8
|
itemsRef.current.isNewRender = true;
|
|
9
|
-
useEffect(
|
|
9
|
+
useEffect(() => {
|
|
10
10
|
// Rendering is finished. Meaning any children can now rerender,
|
|
11
11
|
// and they should not push any new items to our array, because
|
|
12
12
|
// it is not a new render
|
|
13
13
|
itemsRef.current.isNewRender = false;
|
|
14
14
|
});
|
|
15
|
-
useEffect(
|
|
15
|
+
useEffect(() => {
|
|
16
16
|
// When we are unmounting, it means there are no children anymore.
|
|
17
17
|
// Clear out our items array
|
|
18
|
-
return
|
|
18
|
+
return () => {
|
|
19
19
|
itemsRef.current = [];
|
|
20
20
|
};
|
|
21
21
|
}, [itemsRef]);
|
|
22
22
|
}
|
|
23
23
|
export function useChildrenCounterChild(itemsRef, itemIndexRef, obj) {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
let disabled = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
26
25
|
if (itemsRef && itemsRef.current.isNewRender) {
|
|
27
26
|
if (disabled) {
|
|
28
27
|
itemIndexRef.current = -1;
|
|
29
28
|
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
29
|
+
}
|
|
32
30
|
|
|
31
|
+
// push this option to the optionsRef array
|
|
33
32
|
itemIndexRef.current = itemsRef.current.length;
|
|
34
|
-
|
|
35
33
|
if (obj instanceof Function) {
|
|
36
34
|
itemsRef.current.push(obj(itemIndexRef.current));
|
|
37
35
|
} else {
|
|
@@ -1 +1 @@
|
|
|
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';\
|
|
1
|
+
{"version":3,"file":"useChildrenCounter.js","names":["useEffect","useChildrenCounterParent","itemsRef","current","isNewRender","useChildrenCounterChild","itemIndexRef","obj","disabled","arguments","length","undefined","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,SAAS,QAAQ,OAAO;AAEjC,OAAO,SAASC,wBAAwBA,CACtCC,QAA2D,EAC3D;EACA;EACA;EACA;EACA;EACAA,QAAQ,CAACC,OAAO,GAAG,EAAE;EACrBD,QAAQ,CAACC,OAAO,CAACC,WAAW,GAAG,IAAI;EAEnCJ,SAAS,CAAC,MAAM;IACd;IACA;IACA;IACAE,QAAQ,CAACC,OAAO,CAACC,WAAW,GAAG,KAAK;EACtC,CAAC,CAAC;EAEFJ,SAAS,CAAC,MAAM;IACd;IACA;IACA,OAAO,MAAM;MACXE,QAAQ,CAACC,OAAO,GAAG,EAAE;IACvB,CAAC;EACH,CAAC,EAAE,CAACD,QAAQ,CAAC,CAAC;AAChB;AAEA,OAAO,SAASG,uBAAuBA,CACrCH,QAAuE,EACvEI,YAAsC,EACtCC,GAA6B,EAE7B;EAAA,IADAC,QAAQ,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAEhB,IAAIP,QAAQ,IAAIA,QAAQ,CAACC,OAAO,CAACC,WAAW,EAAE;IAC5C,IAAII,QAAQ,EAAE;MACZF,YAAY,CAACH,OAAO,GAAG,CAAC,CAAC;MACzB;IACF;;IAEA;IACAG,YAAY,CAACH,OAAO,GAAGD,QAAQ,CAACC,OAAO,CAACO,MAAM;IAE9C,IAAIH,GAAG,YAAYK,QAAQ,EAAE;MAC3BV,QAAQ,CAACC,OAAO,CAACU,IAAI,CAACN,GAAG,CAACD,YAAY,CAACH,OAAO,CAAC,CAAC;IAClD,CAAC,MAAM;MACLD,QAAQ,CAACC,OAAO,CAACU,IAAI,CAACN,GAAG,CAAC;IAC5B;EACF;AACF","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Dispatch, SetStateAction, SyntheticEvent } from 'react';
|
|
2
|
-
import type { CustomEventHandler } from '../utils';
|
|
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>];
|
|
1
|
+
import type { Dispatch, SetStateAction, SyntheticEvent } from 'react';
|
|
2
|
+
import type { CustomEventHandler } from '../utils';
|
|
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>];
|
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
1
|
import { useRef, useState } from 'react';
|
|
3
2
|
import { wrapEvent } from '../utils';
|
|
4
3
|
export function useControlledState(valueProp, onChangeProp, defaultValue, defaultOnChange) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _useState = useState(defaultValue),
|
|
10
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
11
|
-
valueState = _useState2[0],
|
|
12
|
-
setValueState = _useState2[1];
|
|
13
|
-
|
|
4
|
+
const isControlled = valueProp !== undefined;
|
|
5
|
+
const wasControlled = useRef(isControlled);
|
|
6
|
+
const hasWarned = useRef(false);
|
|
7
|
+
const [valueState, setValueState] = useState(defaultValue);
|
|
14
8
|
if (isControlled) {
|
|
15
9
|
if (!wasControlled.current && !hasWarned.current && process.env.NODE_ENV !== 'production') {
|
|
16
10
|
console.warn('Trying to change from controlled to uncontrolled.');
|
|
17
11
|
hasWarned.current = true;
|
|
18
12
|
}
|
|
19
|
-
|
|
20
|
-
return [// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
21
|
-
valueProp, wrapEvent(onChangeProp, defaultOnChange(setValueState))];
|
|
13
|
+
return [valueProp, wrapEvent(onChangeProp, defaultOnChange(setValueState))];
|
|
22
14
|
}
|
|
23
|
-
|
|
24
|
-
return [// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
25
|
-
valueState, wrapEvent(onChangeProp, defaultOnChange(setValueState))];
|
|
15
|
+
return [valueState, wrapEvent(onChangeProp, defaultOnChange(setValueState))];
|
|
26
16
|
}
|
|
27
17
|
//# sourceMappingURL=useControlledState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useControlledState.js","names":["useRef","useState","wrapEvent","useControlledState","valueProp","onChangeProp","defaultValue","defaultOnChange","isControlled","undefined","wasControlled","hasWarned","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 hasWarned = useRef(false);\n const [valueState, setValueState] = useState<V>(defaultValue);\n\n if (isControlled) {\n if (\n !wasControlled.current &&\n !hasWarned.current &&\n process.env.NODE_ENV !== 'production'\n ) {\n console.warn('Trying to change from controlled to uncontrolled.');\n hasWarned.current = true;\n }\n return [\n
|
|
1
|
+
{"version":3,"file":"useControlledState.js","names":["useRef","useState","wrapEvent","useControlledState","valueProp","onChangeProp","defaultValue","defaultOnChange","isControlled","undefined","wasControlled","hasWarned","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 hasWarned = useRef(false);\n const [valueState, setValueState] = useState<V>(defaultValue);\n\n if (isControlled) {\n if (\n !wasControlled.current &&\n !hasWarned.current &&\n process.env.NODE_ENV !== 'production'\n ) {\n console.warn('Trying to change from controlled to uncontrolled.');\n hasWarned.current = true;\n }\n return [\n valueProp!,\n wrapEvent(onChangeProp, defaultOnChange(setValueState)),\n ];\n }\n\n return [valueState!, wrapEvent(onChangeProp, defaultOnChange(setValueState))];\n}\n"],"mappings":"AACA,SAASA,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAGxC,SAASC,SAAS,QAAQ,UAAU;AAEpC,OAAO,SAASC,kBAAkBA,CAKhCC,SAAwB,EACxBC,YAAkD,EAClDC,YAA2B,EAC3BC,eAE6B,EACE;EAC/B,MAAMC,YAAY,GAAGJ,SAAS,KAAKK,SAAS;EAC5C,MAAMC,aAAa,GAAGV,MAAM,CAACQ,YAAY,CAAC;EAC1C,MAAMG,SAAS,GAAGX,MAAM,CAAC,KAAK,CAAC;EAC/B,MAAM,CAACY,UAAU,EAAEC,aAAa,CAAC,GAAGZ,QAAQ,CAAIK,YAAY,CAAC;EAE7D,IAAIE,YAAY,EAAE;IAChB,IACE,CAACE,aAAa,CAACI,OAAO,IACtB,CAACH,SAAS,CAACG,OAAO,IAClBC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EACrC;MACAC,OAAO,CAACC,IAAI,CAAC,mDAAmD,CAAC;MACjER,SAAS,CAACG,OAAO,GAAG,IAAI;IAC1B;IACA,OAAO,CACLV,SAAS,EACTF,SAAS,CAACG,YAAY,EAAEE,eAAe,CAACM,aAAa,CAAC,CAAC,CACxD;EACH;EAEA,OAAO,CAACD,UAAU,EAAGV,SAAS,CAACG,YAAY,EAAEE,eAAe,CAACM,aAAa,CAAC,CAAC,CAAC;AAC/E","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { MutableRefObject } from 'react';
|
|
2
|
-
export declare function useFocusReturn(open: boolean, rootEl: MutableRefObject<HTMLElement | null>): void;
|
|
1
|
+
import type { MutableRefObject } from 'react';
|
|
2
|
+
export declare function useFocusReturn(open: boolean, rootEl: MutableRefObject<HTMLElement | null>): void;
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
2
|
export function useFocusReturn(open, rootEl) {
|
|
3
|
-
|
|
3
|
+
const previousFocusRef = useRef((() => {
|
|
4
4
|
if (open && typeof document !== 'undefined' && document.activeElement instanceof HTMLElement) {
|
|
5
5
|
return document.activeElement;
|
|
6
6
|
}
|
|
7
|
-
|
|
8
7
|
return null;
|
|
9
|
-
}());
|
|
10
|
-
useEffect(
|
|
8
|
+
})());
|
|
9
|
+
useEffect(() => {
|
|
11
10
|
if (open) {
|
|
12
|
-
var _rootEl$current;
|
|
13
|
-
|
|
14
11
|
// once opened, keep track of the element that triggered
|
|
15
12
|
// the Modal opening
|
|
16
|
-
if (!previousFocusRef.current && document.activeElement instanceof HTMLElement && !
|
|
13
|
+
if (!previousFocusRef.current && document.activeElement instanceof HTMLElement && !rootEl.current?.contains(document.activeElement)) {
|
|
17
14
|
previousFocusRef.current = document.activeElement;
|
|
18
15
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return function () {
|
|
16
|
+
const rootElement = rootEl.current;
|
|
17
|
+
const previousElement = previousFocusRef.current;
|
|
18
|
+
return () => {
|
|
23
19
|
// on unmount, return focus to that element
|
|
24
|
-
if (previousElement && !
|
|
20
|
+
if (previousElement && !rootElement?.contains(document.activeElement)) {
|
|
25
21
|
previousElement.focus({
|
|
26
22
|
preventScroll: true
|
|
27
23
|
});
|
|
@@ -1 +1 @@
|
|
|
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';\
|
|
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,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAEzC,OAAO,SAASC,cAAcA,CAC5BC,IAAa,EACbC,MAA4C,EAC5C;EACA,MAAMC,gBAAgB,GAAGJ,MAAM,CAC7B,CAAC,MAAM;IACL,IACEE,IAAI,IACJ,OAAOG,QAAQ,KAAK,WAAW,IAC/BA,QAAQ,CAACC,aAAa,YAAYC,WAAW,EAC7C;MACA,OAAOF,QAAQ,CAACC,aAAa;IAC/B;IACA,OAAO,IAAI;EACb,CAAC,EAAE,CACL,CAAC;EAEDP,SAAS,CAAC,MAAM;IACd,IAAIG,IAAI,EAAE;MACR;MACA;MACA,IACE,CAACE,gBAAgB,CAACI,OAAO,IACzBH,QAAQ,CAACC,aAAa,YAAYC,WAAW,IAC7C,CAACJ,MAAM,CAACK,OAAO,EAAEC,QAAQ,CAACJ,QAAQ,CAACC,aAAa,CAAC,EACjD;QACAF,gBAAgB,CAACI,OAAO,GAAGH,QAAQ,CAACC,aAAa;MACnD;MAEA,MAAMI,WAAW,GAAGP,MAAM,CAACK,OAAO;MAClC,MAAMG,eAAe,GAAGP,gBAAgB,CAACI,OAAO;MAChD,OAAO,MAAM;QACX;QACA,IAAIG,eAAe,IAAI,CAACD,WAAW,EAAED,QAAQ,CAACJ,QAAQ,CAACC,aAAa,CAAC,EAAE;UACrEK,eAAe,CAACC,KAAK,CAAC;YAAEC,aAAa,EAAE;UAAK,CAAC,CAAC;QAChD;MACF,CAAC;IACH;EACF,CAAC,EAAE,CAACX,IAAI,EAAEC,MAAM,CAAC,CAAC;AACpB","ignoreList":[]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { FocusEventHandler } from 'react';
|
|
2
|
-
export declare function useFocusState<T>(props?: {
|
|
3
|
-
onFocus?: FocusEventHandler<T>;
|
|
4
|
-
onBlur?: FocusEventHandler<T>;
|
|
5
|
-
}): {
|
|
6
|
-
bind: {
|
|
7
|
-
onFocus: import("
|
|
8
|
-
onBlur: import("
|
|
9
|
-
};
|
|
10
|
-
hasFocus: boolean;
|
|
11
|
-
};
|
|
1
|
+
import type { FocusEventHandler } from 'react';
|
|
2
|
+
export declare function useFocusState<T>(props?: {
|
|
3
|
+
onFocus?: FocusEventHandler<T>;
|
|
4
|
+
onBlur?: FocusEventHandler<T>;
|
|
5
|
+
}): {
|
|
6
|
+
bind: {
|
|
7
|
+
onFocus: import("..").CustomEventHandler<import("react").FocusEvent<T, Element>, []>;
|
|
8
|
+
onBlur: import("..").CustomEventHandler<import("react").FocusEvent<T, Element>, []>;
|
|
9
|
+
};
|
|
10
|
+
hasFocus: boolean;
|
|
11
|
+
};
|