@basic-ui/core 0.0.54 → 0.0.56
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 +6 -6
- 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,117 +1,114 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["as", "innerAs", "selectOnClick", "autocomplete", "clearOnEscape", "onClick", "onChange", "onKeyDown", "onBlur", "onFocus", "id", "defaultValue", "value"];
|
|
4
1
|
import { forwardRef, useEffect, useRef } from 'react';
|
|
5
2
|
import { useBlur, CLEAR, CHANGE, useKeyDown, SELECT_WITH_CLICK, FOCUS, NAVIGATING, INIT, useFocusManagement } from './hooks';
|
|
6
3
|
import { assignMultipleRefs, wrapEvent } from '../utils';
|
|
7
4
|
import { useComboBoxContext } from './context';
|
|
8
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
6
|
+
export const ComboboxInput = /*#__PURE__*/forwardRef(function ComboboxInput(_ref, forwardedRef) {
|
|
7
|
+
let {
|
|
8
|
+
as: Comp = 'input',
|
|
9
|
+
innerAs,
|
|
10
|
+
selectOnClick = false,
|
|
11
|
+
autocomplete = true,
|
|
12
|
+
clearOnEscape = false,
|
|
13
|
+
// wrapped events
|
|
14
|
+
onClick,
|
|
15
|
+
onChange,
|
|
16
|
+
onKeyDown,
|
|
17
|
+
onBlur,
|
|
18
|
+
onFocus,
|
|
19
|
+
id: preferredId,
|
|
20
|
+
defaultValue = '',
|
|
21
|
+
// might be controlled
|
|
22
|
+
value: controlledValue,
|
|
23
|
+
...props
|
|
24
|
+
} = _ref;
|
|
25
|
+
const {
|
|
26
|
+
data: {
|
|
27
|
+
navigationItem,
|
|
28
|
+
text,
|
|
29
|
+
lastActionType
|
|
30
|
+
},
|
|
31
|
+
inputRef,
|
|
32
|
+
state,
|
|
33
|
+
transition,
|
|
34
|
+
listboxIdRef,
|
|
35
|
+
autocompletePropRef,
|
|
36
|
+
clearOnEscapeRef,
|
|
37
|
+
openOnFocus,
|
|
38
|
+
optionsRef,
|
|
39
|
+
labelIdRef
|
|
40
|
+
} = useComboBoxContext();
|
|
29
41
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
navigationItem = _useComboBoxContext$d.navigationItem,
|
|
33
|
-
text = _useComboBoxContext$d.text,
|
|
34
|
-
lastActionType = _useComboBoxContext$d.lastActionType,
|
|
35
|
-
inputRef = _useComboBoxContext.inputRef,
|
|
36
|
-
state = _useComboBoxContext.state,
|
|
37
|
-
transition = _useComboBoxContext.transition,
|
|
38
|
-
listboxIdRef = _useComboBoxContext.listboxIdRef,
|
|
39
|
-
autocompletePropRef = _useComboBoxContext.autocompletePropRef,
|
|
40
|
-
clearOnEscapeRef = _useComboBoxContext.clearOnEscapeRef,
|
|
41
|
-
openOnFocus = _useComboBoxContext.openOnFocus,
|
|
42
|
-
optionsRef = _useComboBoxContext.optionsRef,
|
|
43
|
-
labelIdRef = _useComboBoxContext.labelIdRef; // Keep focus on the input component
|
|
42
|
+
// Keep focus on the input component
|
|
43
|
+
useFocusManagement(lastActionType, inputRef);
|
|
44
44
|
|
|
45
|
+
// Keep using the defaultValue until the user started interacting
|
|
46
|
+
const hasStartedInteracting = useRef(false);
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
var hasStartedInteracting = useRef(false); // Because we close the List on blur, we need to track if the blur is
|
|
48
|
+
// Because we close the List on blur, we need to track if the blur is
|
|
49
49
|
// caused by clicking inside the list, and if so, don't close the List.
|
|
50
|
+
const selectOnClickRef = useRef(false);
|
|
51
|
+
const handleBlur = useBlur();
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
var handleBlur = useBlur(); // Update ref props
|
|
53
|
-
|
|
53
|
+
// Update ref props
|
|
54
54
|
autocompletePropRef.current = autocomplete;
|
|
55
55
|
clearOnEscapeRef.current = clearOnEscape;
|
|
56
|
-
listboxIdRef.current = preferredId || listboxIdRef.current;
|
|
56
|
+
listboxIdRef.current = preferredId || listboxIdRef.current;
|
|
57
|
+
|
|
58
|
+
// [*]... and when controlled, we don't trigger handleValueChange as the user
|
|
57
59
|
// types, instead the developer controls it with the normal input onChange
|
|
58
60
|
// prop
|
|
59
|
-
|
|
60
|
-
var handleChange = function handleChange(e) {
|
|
61
|
+
const handleChange = e => {
|
|
61
62
|
// After the user started typing, lets forget the defaultValue
|
|
62
63
|
hasStartedInteracting.current = true;
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
const text = e.target.value;
|
|
65
65
|
if (text.trim() === '') {
|
|
66
66
|
transition(CLEAR);
|
|
67
67
|
} else {
|
|
68
68
|
transition(CHANGE, {
|
|
69
|
-
text
|
|
69
|
+
text
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
var handleFocus = function handleFocus() {
|
|
73
|
+
const handleKeyDown = useKeyDown();
|
|
74
|
+
const handleFocus = () => {
|
|
77
75
|
if (selectOnClick) {
|
|
78
76
|
selectOnClickRef.current = true;
|
|
79
|
-
}
|
|
77
|
+
}
|
|
78
|
+
// If we select an option with click, useFocusManagement will focus the
|
|
80
79
|
// input, in those cases we don't want to cause the menu to open back up,
|
|
81
80
|
// so we guard behind these states
|
|
82
|
-
|
|
83
|
-
|
|
84
81
|
if (openOnFocus && lastActionType !== SELECT_WITH_CLICK) {
|
|
85
82
|
transition(FOCUS, {
|
|
86
83
|
item: navigationItem
|
|
87
84
|
});
|
|
88
85
|
}
|
|
89
86
|
};
|
|
90
|
-
|
|
91
|
-
var handleClick = function handleClick() {
|
|
87
|
+
const handleClick = () => {
|
|
92
88
|
if (selectOnClickRef.current) {
|
|
93
89
|
selectOnClickRef.current = false;
|
|
94
90
|
inputRef.current && inputRef.current.select();
|
|
95
91
|
}
|
|
96
92
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
93
|
+
const navigationText = navigationItem !== '' ? optionsRef.current[navigationItem].text : undefined;
|
|
94
|
+
const fallbackValue = hasStartedInteracting.current ? '' : defaultValue;
|
|
95
|
+
const inputStrings =
|
|
96
|
+
// When idle, we don't have a navigationText on ArrowUp/Down
|
|
101
97
|
autocomplete && state === NAVIGATING ? [navigationText, controlledValue, text, fallbackValue] : [controlledValue, text, fallbackValue];
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
98
|
+
const inputValue = inputStrings.find(str => str !== undefined);
|
|
99
|
+
|
|
100
|
+
// If they are controlling the value we still need to do our transitions, so
|
|
105
101
|
// we have this derived state to emulate onChange of the input as we receive
|
|
106
102
|
// new `value`s ...[*]
|
|
107
|
-
|
|
108
|
-
useEffect(function () {
|
|
103
|
+
useEffect(() => {
|
|
109
104
|
transition(INIT, {
|
|
110
105
|
text: inputValue,
|
|
111
106
|
item: ''
|
|
112
|
-
});
|
|
107
|
+
});
|
|
108
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
113
109
|
}, []);
|
|
114
|
-
return /*#__PURE__*/_jsx(Comp,
|
|
110
|
+
return /*#__PURE__*/_jsx(Comp, {
|
|
111
|
+
...props,
|
|
115
112
|
as: innerAs,
|
|
116
113
|
"data-reach-combobox-input": "",
|
|
117
114
|
ref: assignMultipleRefs(inputRef, forwardedRef),
|
|
@@ -126,6 +123,6 @@ export var ComboboxInput = /*#__PURE__*/forwardRef(function ComboboxInput(_ref,
|
|
|
126
123
|
"aria-autocomplete": "both",
|
|
127
124
|
"aria-activedescendant": navigationItem !== '' ? navigationItem : undefined,
|
|
128
125
|
autoComplete: "off"
|
|
129
|
-
})
|
|
126
|
+
});
|
|
130
127
|
});
|
|
131
128
|
//# sourceMappingURL=ComboboxInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboboxInput.js","names":["forwardRef","useEffect","useRef","useBlur","CLEAR","CHANGE","useKeyDown","SELECT_WITH_CLICK","FOCUS","NAVIGATING","INIT","useFocusManagement","assignMultipleRefs","wrapEvent","useComboBoxContext","ComboboxInput","forwardedRef","as","Comp","innerAs","selectOnClick","autocomplete","clearOnEscape","onClick","onChange","onKeyDown","onBlur","onFocus","preferredId","id","defaultValue","controlledValue","value","props","data","navigationItem","text","lastActionType","inputRef","state","transition","listboxIdRef","autocompletePropRef","clearOnEscapeRef","openOnFocus","optionsRef","labelIdRef","hasStartedInteracting","selectOnClickRef","handleBlur","current","handleChange","e","target","trim","handleKeyDown","handleFocus","item","handleClick","select","navigationText","undefined","fallbackValue","inputStrings","inputValue","find","str"],"sources":["../../../src/ComboBox/ComboboxInput.tsx"],"sourcesContent":["import type {\r\n ChangeEvent,\r\n ChangeEventHandler,\r\n ElementType,\r\n FocusEventHandler,\r\n InputHTMLAttributes,\r\n KeyboardEventHandler,\r\n MouseEventHandler,\r\n} from 'react';\r\nimport { forwardRef, useEffect, useRef } from 'react';\r\n\r\nimport {\r\n useBlur,\r\n CLEAR,\r\n CHANGE,\r\n useKeyDown,\r\n SELECT_WITH_CLICK,\r\n FOCUS,\r\n NAVIGATING,\r\n INIT,\r\n useFocusManagement,\r\n} from './hooks';\r\nimport { assignMultipleRefs, wrapEvent } from '../utils';\r\nimport { useComboBoxContext } from './context';\r\n\r\nexport interface ComboboxInputProps\r\n extends InputHTMLAttributes<HTMLInputElement> {\r\n // clear on ESC\r\n clearOnEscape?: boolean;\r\n // highlights all the text in the box on click when true\r\n selectOnClick?: boolean;\r\n // updates the value in the input when navigating w/ the keyboard\r\n autocomplete?: boolean;\r\n // initial value for uncontrolled mode\r\n defaultValue?: string;\r\n // value for controlled mode\r\n value?: string;\r\n onClick?: MouseEventHandler<HTMLInputElement>;\r\n onChange?: ChangeEventHandler<HTMLInputElement>;\r\n onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\r\n onBlur?: FocusEventHandler<HTMLInputElement>;\r\n onFocus?: FocusEventHandler<HTMLInputElement>;\r\n as?: ElementType<any>;\r\n innerAs?: ElementType<any>;\r\n id?: string;\r\n}\r\n\r\nexport const ComboboxInput = forwardRef<HTMLInputElement, ComboboxInputProps>(\r\n function ComboboxInput(\r\n {\r\n as: Comp = 'input',\r\n innerAs,\r\n selectOnClick = false,\r\n autocomplete = true,\r\n clearOnEscape = false,\r\n\r\n // wrapped events\r\n onClick,\r\n onChange,\r\n onKeyDown,\r\n onBlur,\r\n onFocus,\r\n\r\n id: preferredId,\r\n\r\n defaultValue = '',\r\n\r\n // might be controlled\r\n value: controlledValue,\r\n ...props\r\n },\r\n forwardedRef\r\n ) {\r\n const {\r\n data: { navigationItem, text, lastActionType },\r\n inputRef,\r\n state,\r\n transition,\r\n listboxIdRef,\r\n autocompletePropRef,\r\n clearOnEscapeRef,\r\n openOnFocus,\r\n optionsRef,\r\n labelIdRef,\r\n } = useComboBoxContext();\r\n\r\n // Keep focus on the input component\r\n useFocusManagement(lastActionType, inputRef);\r\n\r\n // Keep using the defaultValue until the user started interacting\r\n const hasStartedInteracting = useRef(false);\r\n\r\n // Because we close the List on blur, we need to track if the blur is\r\n // caused by clicking inside the list, and if so, don't close the List.\r\n const selectOnClickRef = useRef(false);\r\n\r\n const handleBlur = useBlur();\r\n\r\n // Update ref props\r\n autocompletePropRef.current = autocomplete;\r\n clearOnEscapeRef.current = clearOnEscape;\r\n listboxIdRef.current = preferredId || listboxIdRef.current;\r\n\r\n // [*]... and when controlled, we don't trigger handleValueChange as the user\r\n // types, instead the developer controls it with the normal input onChange\r\n // prop\r\n const handleChange = (e: ChangeEvent<HTMLInputElement>) => {\r\n // After the user started typing, lets forget the defaultValue\r\n hasStartedInteracting.current = true;\r\n\r\n const text = e.target.value;\r\n if (text.trim() === '') {\r\n transition(CLEAR);\r\n } else {\r\n transition(CHANGE, { text });\r\n }\r\n };\r\n\r\n const handleKeyDown = useKeyDown();\r\n\r\n const handleFocus = () => {\r\n if (selectOnClick) {\r\n selectOnClickRef.current = true;\r\n }\r\n // If we select an option with click, useFocusManagement will focus the\r\n // input, in those cases we don't want to cause the menu to open back up,\r\n // so we guard behind these states\r\n if (openOnFocus && lastActionType !== SELECT_WITH_CLICK) {\r\n transition(FOCUS, {\r\n item: navigationItem,\r\n });\r\n }\r\n };\r\n\r\n const handleClick = () => {\r\n if (selectOnClickRef.current) {\r\n selectOnClickRef.current = false;\r\n inputRef.current && inputRef.current.select();\r\n }\r\n };\r\n\r\n const navigationText =\r\n navigationItem !== ''\r\n ? optionsRef.current[navigationItem].text\r\n : undefined;\r\n\r\n const fallbackValue = hasStartedInteracting.current ? '' : defaultValue;\r\n\r\n const inputStrings =\r\n // When idle, we don't have a navigationText on ArrowUp/Down\r\n autocomplete && state === NAVIGATING\r\n ? [navigationText, controlledValue, text, fallbackValue]\r\n : [controlledValue, text, fallbackValue];\r\n\r\n const inputValue = inputStrings.find((str) => str !== undefined);\r\n\r\n // If they are controlling the value we still need to do our transitions, so\r\n // we have this derived state to emulate onChange of the input as we receive\r\n // new `value`s ...[*]\r\n useEffect(() => {\r\n transition(INIT, { text: inputValue, item: '' });\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, []);\r\n\r\n return (\r\n <Comp\r\n {...props}\r\n as={innerAs}\r\n data-reach-combobox-input=\"\"\r\n ref={assignMultipleRefs(inputRef, forwardedRef)}\r\n value={inputValue}\r\n onClick={wrapEvent(onClick, handleClick)}\r\n onBlur={wrapEvent(onBlur, handleBlur)}\r\n onFocus={wrapEvent(onFocus, handleFocus)}\r\n onChange={wrapEvent(onChange, handleChange)}\r\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\r\n aria-labelledby={labelIdRef.current}\r\n id={listboxIdRef.current}\r\n aria-autocomplete=\"both\"\r\n aria-activedescendant={\r\n navigationItem !== '' ? navigationItem : undefined\r\n }\r\n autoComplete=\"off\"\r\n />\r\n );\r\n }\r\n);\r\n"],"mappings":";;;AASA,SAASA,UAAT,EAAqBC,SAArB,EAAgCC,MAAhC,QAA8C,OAA9C;AAEA,SACEC,OADF,EAEEC,KAFF,EAGEC,MAHF,EAIEC,UAJF,EAKEC,iBALF,EAMEC,KANF,EAOEC,UAPF,EAQEC,IARF,EASEC,kBATF,QAUO,SAVP;AAWA,SAASC,kBAAT,EAA6BC,SAA7B,QAA8C,UAA9C;AACA,SAASC,kBAAT,QAAmC,WAAnC;;AAwBA,OAAO,IAAMC,aAAa,gBAAGf,UAAU,CACrC,SAASe,aAAT,OAuBEC,YAvBF,EAwBE;EAAA,mBAtBEC,EAsBF;EAAA,IAtBMC,IAsBN,wBAtBa,OAsBb;EAAA,IArBEC,OAqBF,QArBEA,OAqBF;EAAA,8BApBEC,aAoBF;EAAA,IApBEA,aAoBF,mCApBkB,KAoBlB;EAAA,6BAnBEC,YAmBF;EAAA,IAnBEA,YAmBF,kCAnBiB,IAmBjB;EAAA,8BAlBEC,aAkBF;EAAA,IAlBEA,aAkBF,mCAlBkB,KAkBlB;EAAA,IAfEC,OAeF,QAfEA,OAeF;EAAA,IAdEC,QAcF,QAdEA,QAcF;EAAA,IAbEC,SAaF,QAbEA,SAaF;EAAA,IAZEC,MAYF,QAZEA,MAYF;EAAA,IAXEC,OAWF,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CAAlB,CAAnB,CAlFA,CAoFA;EACA;EACA;;EACA5D,SAAS,CAAC,YAAM;IACduC,UAAU,CAAC9B,IAAD,EAAO;MAAE0B,IAAI,EAAE4B,UAAR;MAAoBP,IAAI,EAAE;IAA1B,CAAP,CAAV,CADc,CAEd;EACD,CAHQ,EAGN,EAHM,CAAT;EAKA,oBACE,KAAC,IAAD,wBACMxB,KADN;IAEE,EAAE,EAAEd,OAFN;IAGE,6BAA0B,EAH5B;IAIE,GAAG,EAAEP,kBAAkB,CAAC0B,QAAD,EAAWtB,YAAX,CAJzB;IAKE,KAAK,EAAEgD,UALT;IAME,OAAO,EAAEnD,SAAS,CAACU,OAAD,EAAUmC,WAAV,CANpB;IAOE,MAAM,EAAE7C,SAAS,CAACa,MAAD,EAASuB,UAAT,CAPnB;IAQE,OAAO,EAAEpC,SAAS,CAACc,OAAD,EAAU6B,WAAV,CARpB;IASE,QAAQ,EAAE3C,SAAS,CAACW,QAAD,EAAW2B,YAAX,CATrB;IAUE,SAAS,EAAEtC,SAAS,CAACY,SAAD,EAAY8B,aAAZ,CAVtB;IAWE,mBAAiBT,UAAU,CAACI,OAX9B;IAYE,EAAE,EAAET,YAAY,CAACS,OAZnB;IAaE,qBAAkB,MAbpB;IAcE,yBACEf,cAAc,KAAK,EAAnB,GAAwBA,cAAxB,GAAyC0B,SAf7C;IAiBE,YAAY,EAAC;EAjBf,GADF;AAqBD,CA1IoC,CAAhC"}
|
|
1
|
+
{"version":3,"file":"ComboboxInput.js","names":["forwardRef","useEffect","useRef","useBlur","CLEAR","CHANGE","useKeyDown","SELECT_WITH_CLICK","FOCUS","NAVIGATING","INIT","useFocusManagement","assignMultipleRefs","wrapEvent","useComboBoxContext","jsx","_jsx","ComboboxInput","_ref","forwardedRef","as","Comp","innerAs","selectOnClick","autocomplete","clearOnEscape","onClick","onChange","onKeyDown","onBlur","onFocus","id","preferredId","defaultValue","value","controlledValue","props","data","navigationItem","text","lastActionType","inputRef","state","transition","listboxIdRef","autocompletePropRef","clearOnEscapeRef","openOnFocus","optionsRef","labelIdRef","hasStartedInteracting","selectOnClickRef","handleBlur","current","handleChange","e","target","trim","handleKeyDown","handleFocus","item","handleClick","select","navigationText","undefined","fallbackValue","inputStrings","inputValue","find","str","ref","autoComplete"],"sources":["../../../src/ComboBox/ComboboxInput.tsx"],"sourcesContent":["import type {\n ChangeEvent,\n ChangeEventHandler,\n ElementType,\n FocusEventHandler,\n InputHTMLAttributes,\n KeyboardEventHandler,\n MouseEventHandler,\n} from 'react';\nimport { forwardRef, useEffect, useRef } from 'react';\n\nimport {\n useBlur,\n CLEAR,\n CHANGE,\n useKeyDown,\n SELECT_WITH_CLICK,\n FOCUS,\n NAVIGATING,\n INIT,\n useFocusManagement,\n} from './hooks';\nimport { assignMultipleRefs, wrapEvent } from '../utils';\nimport { useComboBoxContext } from './context';\n\nexport interface ComboboxInputProps\n extends InputHTMLAttributes<HTMLInputElement> {\n // clear on ESC\n clearOnEscape?: boolean;\n // highlights all the text in the box on click when true\n selectOnClick?: boolean;\n // updates the value in the input when navigating w/ the keyboard\n autocomplete?: boolean;\n // initial value for uncontrolled mode\n defaultValue?: string;\n // value for controlled mode\n value?: string;\n onClick?: MouseEventHandler<HTMLInputElement>;\n onChange?: ChangeEventHandler<HTMLInputElement>;\n onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\n onBlur?: FocusEventHandler<HTMLInputElement>;\n onFocus?: FocusEventHandler<HTMLInputElement>;\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n id?: string;\n}\n\nexport const ComboboxInput = forwardRef<HTMLInputElement, ComboboxInputProps>(\n function ComboboxInput(\n {\n as: Comp = 'input',\n innerAs,\n selectOnClick = false,\n autocomplete = true,\n clearOnEscape = false,\n\n // wrapped events\n onClick,\n onChange,\n onKeyDown,\n onBlur,\n onFocus,\n\n id: preferredId,\n\n defaultValue = '',\n\n // might be controlled\n value: controlledValue,\n ...props\n },\n forwardedRef\n ) {\n const {\n data: { navigationItem, text, lastActionType },\n inputRef,\n state,\n transition,\n listboxIdRef,\n autocompletePropRef,\n clearOnEscapeRef,\n openOnFocus,\n optionsRef,\n labelIdRef,\n } = useComboBoxContext();\n\n // Keep focus on the input component\n useFocusManagement(lastActionType, inputRef);\n\n // Keep using the defaultValue until the user started interacting\n const hasStartedInteracting = useRef(false);\n\n // Because we close the List on blur, we need to track if the blur is\n // caused by clicking inside the list, and if so, don't close the List.\n const selectOnClickRef = useRef(false);\n\n const handleBlur = useBlur();\n\n // Update ref props\n autocompletePropRef.current = autocomplete;\n clearOnEscapeRef.current = clearOnEscape;\n listboxIdRef.current = preferredId || listboxIdRef.current;\n\n // [*]... and when controlled, we don't trigger handleValueChange as the user\n // types, instead the developer controls it with the normal input onChange\n // prop\n const handleChange = (e: ChangeEvent<HTMLInputElement>) => {\n // After the user started typing, lets forget the defaultValue\n hasStartedInteracting.current = true;\n\n const text = e.target.value;\n if (text.trim() === '') {\n transition(CLEAR);\n } else {\n transition(CHANGE, { text });\n }\n };\n\n const handleKeyDown = useKeyDown();\n\n const handleFocus = () => {\n if (selectOnClick) {\n selectOnClickRef.current = true;\n }\n // If we select an option with click, useFocusManagement will focus the\n // input, in those cases we don't want to cause the menu to open back up,\n // so we guard behind these states\n if (openOnFocus && lastActionType !== SELECT_WITH_CLICK) {\n transition(FOCUS, {\n item: navigationItem,\n });\n }\n };\n\n const handleClick = () => {\n if (selectOnClickRef.current) {\n selectOnClickRef.current = false;\n inputRef.current && inputRef.current.select();\n }\n };\n\n const navigationText =\n navigationItem !== ''\n ? optionsRef.current[navigationItem].text\n : undefined;\n\n const fallbackValue = hasStartedInteracting.current ? '' : defaultValue;\n\n const inputStrings =\n // When idle, we don't have a navigationText on ArrowUp/Down\n autocomplete && state === NAVIGATING\n ? [navigationText, controlledValue, text, fallbackValue]\n : [controlledValue, text, fallbackValue];\n\n const inputValue = inputStrings.find((str) => str !== undefined);\n\n // If they are controlling the value we still need to do our transitions, so\n // we have this derived state to emulate onChange of the input as we receive\n // new `value`s ...[*]\n useEffect(() => {\n transition(INIT, { text: inputValue, item: '' });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <Comp\n {...props}\n as={innerAs}\n data-reach-combobox-input=\"\"\n ref={assignMultipleRefs(inputRef, forwardedRef)}\n value={inputValue}\n onClick={wrapEvent(onClick, handleClick)}\n onBlur={wrapEvent(onBlur, handleBlur)}\n onFocus={wrapEvent(onFocus, handleFocus)}\n onChange={wrapEvent(onChange, handleChange)}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n aria-labelledby={labelIdRef.current}\n id={listboxIdRef.current}\n aria-autocomplete=\"both\"\n aria-activedescendant={\n navigationItem !== '' ? navigationItem : undefined\n }\n autoComplete=\"off\"\n />\n );\n }\n);\n"],"mappings":"AASA,SAASA,UAAU,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAErD,SACEC,OAAO,EACPC,KAAK,EACLC,MAAM,EACNC,UAAU,EACVC,iBAAiB,EACjBC,KAAK,EACLC,UAAU,EACVC,IAAI,EACJC,kBAAkB,QACb,SAAS;AAChB,SAASC,kBAAkB,EAAEC,SAAS,QAAQ,UAAU;AACxD,SAASC,kBAAkB,QAAQ,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAwB/C,OAAO,MAAMC,aAAa,gBAAGjB,UAAU,CACrC,SAASiB,aAAaA,CAAAC,IAAA,EAuBpBC,YAAY,EACZ;EAAA,IAvBA;IACEC,EAAE,EAAEC,IAAI,GAAG,OAAO;IAClBC,OAAO;IACPC,aAAa,GAAG,KAAK;IACrBC,YAAY,GAAG,IAAI;IACnBC,aAAa,GAAG,KAAK;IAErB;IACAC,OAAO;IACPC,QAAQ;IACRC,SAAS;IACTC,MAAM;IACNC,OAAO;IAEPC,EAAE,EAAEC,WAAW;IAEfC,YAAY,GAAG,EAAE;IAEjB;IACAC,KAAK,EAAEC,eAAe;IACtB,GAAGC;EACL,CAAC,GAAAlB,IAAA;EAGD,MAAM;IACJmB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OAAO,EAAEjB,SAAS,CAACiB,OAAO,EAAE6B,WAAW,CAAE;IACzChC,QAAQ,EAAEd,SAAS,CAACc,QAAQ,EAAE2B,YAAY,CAAE;IAC5C1B,SAAS,EAAEf,SAAS,CAACe,SAAS,EAAE8B,aAAa,CAAE;IAC/C,mBAAiBT,UAAU,CAACI,OAAQ;IACpCtB,EAAE,EAAEa,YAAY,CAACS,OAAQ;IACzB,qBAAkB,MAAM;IACxB,yBACEf,cAAc,KAAK,EAAE,GAAGA,cAAc,GAAG0B,SAC1C;IACDO,YAAY,EAAC;EAAK,CACnB,CAAC;AAEN,CACF,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ElementType, LabelHTMLAttributes } from 'react';
|
|
2
|
-
export interface ComboboxLabelProps extends LabelHTMLAttributes<HTMLLabelElement> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
id?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const ComboboxLabel: import("react").ForwardRefExoticComponent<ComboboxLabelProps & import("react").RefAttributes<HTMLLabelElement>>;
|
|
1
|
+
import type { ElementType, LabelHTMLAttributes } from 'react';
|
|
2
|
+
export interface ComboboxLabelProps extends LabelHTMLAttributes<HTMLLabelElement> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
id?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const ComboboxLabel: import("react").ForwardRefExoticComponent<ComboboxLabelProps & import("react").RefAttributes<HTMLLabelElement>>;
|
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["as", "innerAs", "id"];
|
|
4
1
|
import { forwardRef } from 'react';
|
|
5
2
|
import { useComboBoxContext } from './context';
|
|
6
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
export const ComboboxLabel = /*#__PURE__*/forwardRef(function ComboboxButton(_ref, ref) {
|
|
5
|
+
let {
|
|
6
|
+
as: Comp = 'label',
|
|
7
|
+
innerAs,
|
|
8
|
+
id: preferredId,
|
|
9
|
+
...props
|
|
10
|
+
} = _ref;
|
|
11
|
+
const {
|
|
12
|
+
listboxIdRef,
|
|
13
|
+
labelIdRef
|
|
14
|
+
} = useComboBoxContext();
|
|
18
15
|
labelIdRef.current = preferredId || labelIdRef.current;
|
|
19
|
-
return /*#__PURE__*/_jsx(Comp,
|
|
16
|
+
return /*#__PURE__*/_jsx(Comp, {
|
|
20
17
|
as: innerAs,
|
|
21
18
|
"data-reach-combobox-label": "",
|
|
22
19
|
htmlFor: listboxIdRef.current,
|
|
23
20
|
id: labelIdRef.current,
|
|
24
|
-
ref: ref
|
|
25
|
-
|
|
21
|
+
ref: ref,
|
|
22
|
+
...props
|
|
23
|
+
});
|
|
26
24
|
});
|
|
27
25
|
//# sourceMappingURL=ComboboxLabel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboboxLabel.js","names":["forwardRef","useComboBoxContext","ComboboxLabel","ComboboxButton","ref","as","Comp","innerAs","
|
|
1
|
+
{"version":3,"file":"ComboboxLabel.js","names":["forwardRef","useComboBoxContext","jsx","_jsx","ComboboxLabel","ComboboxButton","_ref","ref","as","Comp","innerAs","id","preferredId","props","listboxIdRef","labelIdRef","current","htmlFor"],"sources":["../../../src/ComboBox/ComboboxLabel.tsx"],"sourcesContent":["import type { ElementType, LabelHTMLAttributes } from 'react';\nimport { forwardRef } from 'react';\n\nimport { useComboBoxContext } from './context';\n\nexport interface ComboboxLabelProps\n extends LabelHTMLAttributes<HTMLLabelElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n id?: string;\n}\n\nexport const ComboboxLabel = forwardRef<HTMLLabelElement, ComboboxLabelProps>(\n function ComboboxButton(\n { as: Comp = 'label', innerAs, id: preferredId, ...props },\n ref\n ) {\n const { listboxIdRef, labelIdRef } = useComboBoxContext();\n\n labelIdRef.current = preferredId || labelIdRef.current;\n\n return (\n <Comp\n as={innerAs}\n data-reach-combobox-label=\"\"\n htmlFor={listboxIdRef.current}\n id={labelIdRef.current}\n ref={ref}\n {...props}\n />\n );\n }\n);\n"],"mappings":"AACA,SAASA,UAAU,QAAQ,OAAO;AAElC,SAASC,kBAAkB,QAAQ,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAS/C,OAAO,MAAMC,aAAa,gBAAGJ,UAAU,CACrC,SAASK,cAAcA,CAAAC,IAAA,EAErBC,GAAG,EACH;EAAA,IAFA;IAAEC,EAAE,EAAEC,IAAI,GAAG,OAAO;IAAEC,OAAO;IAAEC,EAAE,EAAEC,WAAW;IAAE,GAAGC;EAAM,CAAC,GAAAP,IAAA;EAG1D,MAAM;IAAEQ,YAAY;IAAEC;EAAW,CAAC,GAAGd,kBAAkB,CAAC,CAAC;EAEzDc,UAAU,CAACC,OAAO,GAAGJ,WAAW,IAAIG,UAAU,CAACC,OAAO;EAEtD,oBACEb,IAAA,CAACM,IAAI;IACHD,EAAE,EAAEE,OAAQ;IACZ,6BAA0B,EAAE;IAC5BO,OAAO,EAAEH,YAAY,CAACE,OAAQ;IAC9BL,EAAE,EAAEI,UAAU,CAACC,OAAQ;IACvBT,GAAG,EAAEA,GAAI;IAAA,GACLM;EAAK,CACV,CAAC;AAEN,CACF,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { HTMLAttributes, ElementType, ReactNode } from 'react';
|
|
2
|
-
export interface ComboboxListProps extends HTMLAttributes<HTMLUListElement> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
persistSelection?: boolean;
|
|
6
|
-
children?: ReactNode;
|
|
7
|
-
}
|
|
8
|
-
export declare const ComboboxList: import("react").ForwardRefExoticComponent<ComboboxListProps & import("react").RefAttributes<HTMLUListElement>>;
|
|
1
|
+
import type { HTMLAttributes, ElementType, ReactNode } from 'react';
|
|
2
|
+
export interface ComboboxListProps extends HTMLAttributes<HTMLUListElement> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
persistSelection?: boolean;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const ComboboxList: import("react").ForwardRefExoticComponent<ComboboxListProps & import("react").RefAttributes<HTMLUListElement>>;
|
|
@@ -1,35 +1,34 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["persistSelection", "as", "innerAs"];
|
|
4
1
|
import { forwardRef, useRef, useEffect } from 'react';
|
|
5
2
|
import { useComboBoxContext } from './context';
|
|
6
3
|
import { getScope } from '../hooks';
|
|
7
4
|
import { assignMultipleRefs } from '../utils';
|
|
8
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
export const ComboboxList = /*#__PURE__*/forwardRef(function ComboboxList(_ref, ref) {
|
|
7
|
+
let {
|
|
8
|
+
// when true, and the list opens again, the option with a matching value will be
|
|
9
|
+
// automatically highleted.
|
|
10
|
+
persistSelection = false,
|
|
11
|
+
as: Comp = 'ul',
|
|
12
|
+
innerAs,
|
|
13
|
+
...props
|
|
14
|
+
} = _ref;
|
|
15
|
+
const {
|
|
16
|
+
persistSelectionRef,
|
|
17
|
+
labelIdRef,
|
|
18
|
+
listScope
|
|
19
|
+
} = useComboBoxContext();
|
|
20
|
+
const listRef = useRef(null);
|
|
21
|
+
useEffect(() => {
|
|
24
22
|
listScope.current = getScope(listRef);
|
|
25
23
|
}, [listScope]);
|
|
26
24
|
persistSelectionRef.current = persistSelection;
|
|
27
|
-
return /*#__PURE__*/_jsx(Comp,
|
|
25
|
+
return /*#__PURE__*/_jsx(Comp, {
|
|
26
|
+
...props,
|
|
28
27
|
as: innerAs,
|
|
29
28
|
ref: assignMultipleRefs(ref, listRef),
|
|
30
29
|
"data-reach-combobox-list": "",
|
|
31
30
|
role: "listbox",
|
|
32
31
|
"aria-labelledby": labelIdRef.current
|
|
33
|
-
})
|
|
32
|
+
});
|
|
34
33
|
});
|
|
35
34
|
//# sourceMappingURL=ComboboxList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboboxList.js","names":["forwardRef","useRef","useEffect","useComboBoxContext","getScope","assignMultipleRefs","ComboboxList","ref","persistSelection","as","Comp","innerAs","props","persistSelectionRef","labelIdRef","listScope","listRef","current"],"sources":["../../../src/ComboBox/ComboboxList.tsx"],"sourcesContent":["import type { HTMLAttributes, ElementType, ReactNode } from 'react';\
|
|
1
|
+
{"version":3,"file":"ComboboxList.js","names":["forwardRef","useRef","useEffect","useComboBoxContext","getScope","assignMultipleRefs","jsx","_jsx","ComboboxList","_ref","ref","persistSelection","as","Comp","innerAs","props","persistSelectionRef","labelIdRef","listScope","listRef","current","role"],"sources":["../../../src/ComboBox/ComboboxList.tsx"],"sourcesContent":["import type { HTMLAttributes, ElementType, ReactNode } from 'react';\nimport { forwardRef, useRef, useEffect } from 'react';\n\nimport { useComboBoxContext } from './context';\nimport { getScope } from '../hooks';\nimport { assignMultipleRefs } from '../utils';\n\nexport interface ComboboxListProps extends HTMLAttributes<HTMLUListElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n persistSelection?: boolean;\n children?: ReactNode;\n}\n\nexport const ComboboxList = forwardRef<HTMLUListElement, ComboboxListProps>(\n function ComboboxList(\n {\n // when true, and the list opens again, the option with a matching value will be\n // automatically highleted.\n persistSelection = false,\n as: Comp = 'ul',\n innerAs,\n ...props\n },\n ref\n ) {\n const { persistSelectionRef, labelIdRef, listScope } = useComboBoxContext();\n\n const listRef = useRef<HTMLUListElement | null>(null);\n useEffect(() => {\n listScope.current = getScope(listRef);\n }, [listScope]);\n\n persistSelectionRef.current = persistSelection;\n\n return (\n <Comp\n {...props}\n as={innerAs}\n ref={assignMultipleRefs(ref, listRef)}\n data-reach-combobox-list=\"\"\n role=\"listbox\"\n aria-labelledby={labelIdRef.current}\n />\n );\n }\n);\n"],"mappings":"AACA,SAASA,UAAU,EAAEC,MAAM,EAAEC,SAAS,QAAQ,OAAO;AAErD,SAASC,kBAAkB,QAAQ,WAAW;AAC9C,SAASC,QAAQ,QAAQ,UAAU;AACnC,SAASC,kBAAkB,QAAQ,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAS9C,OAAO,MAAMC,YAAY,gBAAGR,UAAU,CACpC,SAASQ,YAAYA,CAAAC,IAAA,EASnBC,GAAG,EACH;EAAA,IATA;IACE;IACA;IACAC,gBAAgB,GAAG,KAAK;IACxBC,EAAE,EAAEC,IAAI,GAAG,IAAI;IACfC,OAAO;IACP,GAAGC;EACL,CAAC,GAAAN,IAAA;EAGD,MAAM;IAAEO,mBAAmB;IAAEC,UAAU;IAAEC;EAAU,CAAC,GAAGf,kBAAkB,CAAC,CAAC;EAE3E,MAAMgB,OAAO,GAAGlB,MAAM,CAA0B,IAAI,CAAC;EACrDC,SAAS,CAAC,MAAM;IACdgB,SAAS,CAACE,OAAO,GAAGhB,QAAQ,CAACe,OAAO,CAAC;EACvC,CAAC,EAAE,CAACD,SAAS,CAAC,CAAC;EAEfF,mBAAmB,CAACI,OAAO,GAAGT,gBAAgB;EAE9C,oBACEJ,IAAA,CAACM,IAAI;IAAA,GACCE,KAAK;IACTH,EAAE,EAAEE,OAAQ;IACZJ,GAAG,EAAEL,kBAAkB,CAACK,GAAG,EAAES,OAAO,CAAE;IACtC,4BAAyB,EAAE;IAC3BE,IAAI,EAAC,SAAS;IACd,mBAAiBJ,UAAU,CAACG;EAAQ,CACrC,CAAC;AAEN,CACF,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { ElementType, LiHTMLAttributes, MouseEventHandler, ReactNode } from 'react';
|
|
2
|
-
export interface ComboboxOptionProps extends LiHTMLAttributes<HTMLLIElement> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
id: string;
|
|
6
|
-
value: any;
|
|
7
|
-
text?: string;
|
|
8
|
-
onClick?: MouseEventHandler<HTMLLIElement>;
|
|
9
|
-
children?: ReactNode;
|
|
10
|
-
}
|
|
11
|
-
export declare const ComboboxOption: import("react").ForwardRefExoticComponent<ComboboxOptionProps & import("react").RefAttributes<HTMLLIElement>>;
|
|
1
|
+
import type { ElementType, LiHTMLAttributes, MouseEventHandler, ReactNode } from 'react';
|
|
2
|
+
export interface ComboboxOptionProps extends LiHTMLAttributes<HTMLLIElement> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
id: string;
|
|
6
|
+
value: any;
|
|
7
|
+
text?: string;
|
|
8
|
+
onClick?: MouseEventHandler<HTMLLIElement>;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export declare const ComboboxOption: import("react").ForwardRefExoticComponent<ComboboxOptionProps & import("react").RefAttributes<HTMLLIElement>>;
|
|
@@ -1,36 +1,32 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["children", "id", "value", "text", "onClick", "as", "innerAs"];
|
|
4
|
-
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
6
1
|
import { forwardRef, useEffect, useRef } from 'react';
|
|
7
2
|
import { SELECT_WITH_CLICK, CLEAR_SELECTION } from './hooks';
|
|
8
3
|
import { wrapEvent } from '../utils/wrap-event';
|
|
9
4
|
import { useComboBoxContext } from './context';
|
|
10
5
|
import { makeHash } from './makeHash';
|
|
11
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
7
|
+
export const ComboboxOption = /*#__PURE__*/forwardRef(function ComboboxOption(_ref, ref) {
|
|
8
|
+
let {
|
|
9
|
+
children,
|
|
10
|
+
id: idProp,
|
|
11
|
+
value: valueProp,
|
|
12
|
+
text: textProp,
|
|
13
|
+
onClick,
|
|
14
|
+
as: Comp = 'li',
|
|
15
|
+
innerAs,
|
|
16
|
+
...props
|
|
17
|
+
} = _ref;
|
|
18
|
+
const {
|
|
19
|
+
onSelect,
|
|
20
|
+
data: {
|
|
21
|
+
navigationItem
|
|
22
|
+
},
|
|
23
|
+
transition,
|
|
24
|
+
optionsRef
|
|
25
|
+
} = useComboBoxContext();
|
|
26
|
+
const transitionCleanupRef = useRef(transition);
|
|
27
|
+
const isActiveRef = useRef(false);
|
|
28
|
+
const value = valueProp;
|
|
29
|
+
let text = textProp ? textProp : '';
|
|
34
30
|
if (text.length === 0) {
|
|
35
31
|
if (typeof valueProp === 'string' && valueProp.length > 0) {
|
|
36
32
|
text = valueProp;
|
|
@@ -38,25 +34,25 @@ export var ComboboxOption = /*#__PURE__*/forwardRef(function ComboboxOption(_ref
|
|
|
38
34
|
throw new Error('Missing text for <ComboboxOption />');
|
|
39
35
|
}
|
|
40
36
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var opts = optionsRef.current;
|
|
37
|
+
const id = String(makeHash(idProp));
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const opts = optionsRef.current;
|
|
45
40
|
opts[id] = {
|
|
46
|
-
value
|
|
47
|
-
text
|
|
41
|
+
value,
|
|
42
|
+
text
|
|
48
43
|
};
|
|
49
|
-
return
|
|
44
|
+
return () => {
|
|
50
45
|
delete opts[id];
|
|
51
46
|
};
|
|
52
|
-
}, [optionsRef, id, text, value]);
|
|
47
|
+
}, [optionsRef, id, text, value]);
|
|
48
|
+
|
|
49
|
+
// Keep updating this ref with the current
|
|
53
50
|
// function pointer for transition, so it can
|
|
54
51
|
// be used by the unmount effect below.
|
|
55
|
-
|
|
56
52
|
transitionCleanupRef.current = transition;
|
|
57
53
|
isActiveRef.current = navigationItem === id;
|
|
58
|
-
useEffect(
|
|
59
|
-
return
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
return () => {
|
|
60
56
|
if (isActiveRef.current === true) {
|
|
61
57
|
// clean up selections if this option is getting
|
|
62
58
|
// unmounted and it was the currently selected item
|
|
@@ -64,29 +60,29 @@ export var ComboboxOption = /*#__PURE__*/forwardRef(function ComboboxOption(_ref
|
|
|
64
60
|
}
|
|
65
61
|
};
|
|
66
62
|
}, []);
|
|
67
|
-
|
|
68
|
-
var handleClick = function handleClick() {
|
|
63
|
+
const handleClick = () => {
|
|
69
64
|
onSelect && onSelect(text, id, value);
|
|
70
65
|
transition(SELECT_WITH_CLICK, {
|
|
71
|
-
text
|
|
66
|
+
text,
|
|
72
67
|
item: id
|
|
73
68
|
});
|
|
74
69
|
};
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
return /*#__PURE__*/_jsx(Comp, {
|
|
71
|
+
...props,
|
|
77
72
|
as: innerAs,
|
|
78
73
|
"data-reach-combobox-option": "",
|
|
79
74
|
ref: ref,
|
|
80
75
|
id: id,
|
|
81
76
|
role: "option",
|
|
82
77
|
"aria-selected": isActiveRef.current,
|
|
83
|
-
"data-highlighted": isActiveRef.current ? '' : undefined
|
|
78
|
+
"data-highlighted": isActiveRef.current ? '' : undefined
|
|
79
|
+
// without this the menu will close from `onBlur`, but with it the
|
|
84
80
|
// element can be `document.activeElement` and then our focus checks in
|
|
85
81
|
// onBlur will work as intended
|
|
86
82
|
,
|
|
87
83
|
tabIndex: "-1",
|
|
88
84
|
onClick: wrapEvent(onClick, handleClick),
|
|
89
85
|
children: children || text
|
|
90
|
-
})
|
|
86
|
+
});
|
|
91
87
|
});
|
|
92
88
|
//# sourceMappingURL=ComboboxOption.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboboxOption.js","names":["forwardRef","useEffect","useRef","SELECT_WITH_CLICK","CLEAR_SELECTION","wrapEvent","useComboBoxContext","makeHash","ComboboxOption","
|
|
1
|
+
{"version":3,"file":"ComboboxOption.js","names":["forwardRef","useEffect","useRef","SELECT_WITH_CLICK","CLEAR_SELECTION","wrapEvent","useComboBoxContext","makeHash","jsx","_jsx","ComboboxOption","_ref","ref","children","id","idProp","value","valueProp","text","textProp","onClick","as","Comp","innerAs","props","onSelect","data","navigationItem","transition","optionsRef","transitionCleanupRef","isActiveRef","length","Error","String","opts","current","handleClick","item","role","undefined","tabIndex"],"sources":["../../../src/ComboBox/ComboboxOption.tsx"],"sourcesContent":["import type {\n ElementType,\n LiHTMLAttributes,\n MouseEventHandler,\n ReactNode,\n} from 'react';\nimport { forwardRef, useEffect, useRef } from 'react';\n\nimport { SELECT_WITH_CLICK, CLEAR_SELECTION } from './hooks';\nimport { wrapEvent } from '../utils/wrap-event';\nimport { useComboBoxContext } from './context';\nimport { makeHash } from './makeHash';\n\nexport interface ComboboxOptionProps extends LiHTMLAttributes<HTMLLIElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n id: string;\n value: any;\n text?: string;\n onClick?: MouseEventHandler<HTMLLIElement>;\n children?: ReactNode;\n}\n\nexport const ComboboxOption = forwardRef<HTMLLIElement, ComboboxOptionProps>(\n function ComboboxOption(\n {\n children,\n id: idProp,\n value: valueProp,\n text: textProp,\n onClick,\n as: Comp = 'li',\n innerAs,\n ...props\n },\n ref\n ) {\n const {\n onSelect,\n data: { navigationItem },\n transition,\n optionsRef,\n } = useComboBoxContext();\n const transitionCleanupRef = useRef(transition);\n const isActiveRef = useRef(false);\n\n const value: any = valueProp;\n let text: string = textProp ? textProp : '';\n\n if (text.length === 0) {\n if (typeof valueProp === 'string' && valueProp.length > 0) {\n text = valueProp;\n } else {\n throw new Error('Missing text for <ComboboxOption />');\n }\n }\n\n const id = String(makeHash(idProp));\n\n useEffect(() => {\n const opts = optionsRef.current;\n opts[id] = { value, text };\n\n return () => {\n delete opts[id];\n };\n }, [optionsRef, id, text, value]);\n\n // Keep updating this ref with the current\n // function pointer for transition, so it can\n // be used by the unmount effect below.\n transitionCleanupRef.current = transition;\n isActiveRef.current = navigationItem === id;\n\n useEffect(() => {\n return () => {\n if (isActiveRef.current === true) {\n // clean up selections if this option is getting\n // unmounted and it was the currently selected item\n transitionCleanupRef.current(CLEAR_SELECTION);\n }\n };\n }, []);\n\n const handleClick = () => {\n onSelect && onSelect(text, id, value);\n transition(SELECT_WITH_CLICK, { text, item: id });\n };\n\n return (\n <Comp\n {...props}\n as={innerAs}\n data-reach-combobox-option=\"\"\n ref={ref}\n id={id}\n role=\"option\"\n aria-selected={isActiveRef.current}\n data-highlighted={isActiveRef.current ? '' : undefined}\n // without this the menu will close from `onBlur`, but with it the\n // element can be `document.activeElement` and then our focus checks in\n // onBlur will work as intended\n tabIndex=\"-1\"\n onClick={wrapEvent(onClick, handleClick)}\n >\n {children || text}\n </Comp>\n );\n }\n);\n"],"mappings":"AAMA,SAASA,UAAU,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAErD,SAASC,iBAAiB,EAAE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