@basic-ui/core 0.0.41 → 0.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.js +1312 -464
- package/build/cjs/index.js.map +1 -1
- package/build/esm/Accordion/Accordion.d.ts +0 -0
- package/build/esm/Accordion/Accordion.js +4 -3
- package/build/esm/Accordion/Accordion.js.map +1 -1
- package/build/esm/Accordion/AccordionBody.d.ts +0 -0
- package/build/esm/Accordion/AccordionBody.js +4 -3
- package/build/esm/Accordion/AccordionBody.js.map +1 -1
- package/build/esm/Accordion/AccordionHeader.d.ts +0 -0
- package/build/esm/Accordion/AccordionHeader.js +4 -3
- package/build/esm/Accordion/AccordionHeader.js.map +1 -1
- package/build/esm/Accordion/AccordionItem.d.ts +0 -0
- package/build/esm/Accordion/AccordionItem.js +2 -1
- package/build/esm/Accordion/AccordionItem.js.map +1 -1
- package/build/esm/Accordion/context.d.ts +0 -0
- package/build/esm/Accordion/context.js +0 -0
- package/build/esm/Accordion/context.js.map +1 -1
- package/build/esm/Accordion/index.d.ts +0 -0
- package/build/esm/Accordion/index.js +0 -0
- package/build/esm/Accordion/index.js.map +1 -1
- package/build/esm/Accordion/scopeQuery.d.ts +0 -0
- package/build/esm/Accordion/scopeQuery.js +0 -0
- package/build/esm/Accordion/scopeQuery.js.map +1 -1
- package/build/esm/CheckBox/CheckBox.d.ts +0 -0
- package/build/esm/CheckBox/CheckBox.js +2 -1
- package/build/esm/CheckBox/CheckBox.js.map +1 -1
- package/build/esm/CheckBox/index.d.ts +0 -0
- package/build/esm/CheckBox/index.js +0 -0
- package/build/esm/CheckBox/index.js.map +1 -1
- package/build/esm/ComboBox/Combobox.d.ts +0 -0
- package/build/esm/ComboBox/Combobox.js +3 -2
- package/build/esm/ComboBox/Combobox.js.map +1 -1
- package/build/esm/ComboBox/ComboboxButton.d.ts +0 -0
- package/build/esm/ComboBox/ComboboxButton.js +4 -3
- package/build/esm/ComboBox/ComboboxButton.js.map +1 -1
- package/build/esm/ComboBox/ComboboxInput.d.ts +0 -0
- package/build/esm/ComboBox/ComboboxInput.js +3 -2
- package/build/esm/ComboBox/ComboboxInput.js.map +1 -1
- package/build/esm/ComboBox/ComboboxLabel.d.ts +0 -0
- package/build/esm/ComboBox/ComboboxLabel.js +2 -1
- package/build/esm/ComboBox/ComboboxLabel.js.map +1 -1
- package/build/esm/ComboBox/ComboboxList.d.ts +0 -0
- package/build/esm/ComboBox/ComboboxList.js +3 -2
- package/build/esm/ComboBox/ComboboxList.js.map +1 -1
- package/build/esm/ComboBox/ComboboxOption.d.ts +0 -0
- package/build/esm/ComboBox/ComboboxOption.js +4 -3
- package/build/esm/ComboBox/ComboboxOption.js.map +1 -1
- package/build/esm/ComboBox/ComboboxPopover.d.ts +0 -0
- package/build/esm/ComboBox/ComboboxPopover.js +5 -4
- package/build/esm/ComboBox/ComboboxPopover.js.map +1 -1
- package/build/esm/ComboBox/cities.d.ts +0 -0
- package/build/esm/ComboBox/cities.js +0 -0
- package/build/esm/ComboBox/cities.js.map +1 -1
- package/build/esm/ComboBox/context.d.ts +0 -0
- package/build/esm/ComboBox/context.js +0 -0
- package/build/esm/ComboBox/context.js.map +1 -1
- package/build/esm/ComboBox/hooks.d.ts +0 -0
- package/build/esm/ComboBox/hooks.js +11 -11
- package/build/esm/ComboBox/hooks.js.map +1 -1
- package/build/esm/ComboBox/index.d.ts +0 -0
- package/build/esm/ComboBox/index.js +0 -0
- package/build/esm/ComboBox/index.js.map +1 -1
- package/build/esm/ComboBox/makeHash.d.ts +0 -0
- package/build/esm/ComboBox/makeHash.js +0 -0
- package/build/esm/ComboBox/makeHash.js.map +1 -1
- package/build/esm/ComboBox/scopeQuery.d.ts +0 -0
- package/build/esm/ComboBox/scopeQuery.js +0 -0
- package/build/esm/ComboBox/scopeQuery.js.map +1 -1
- package/build/esm/FocusLock/FocusLock.d.ts +0 -0
- package/build/esm/FocusLock/FocusLock.js +2 -1
- package/build/esm/FocusLock/FocusLock.js.map +1 -1
- package/build/esm/FocusLock/index.d.ts +0 -0
- package/build/esm/FocusLock/index.js +0 -0
- package/build/esm/FocusLock/index.js.map +1 -1
- package/build/esm/FocusLock/tabUtils.d.ts +0 -0
- package/build/esm/FocusLock/tabUtils.js +0 -0
- package/build/esm/FocusLock/tabUtils.js.map +1 -1
- package/build/esm/FocusLock/useFocusLock.d.ts +0 -0
- package/build/esm/FocusLock/useFocusLock.js +0 -0
- package/build/esm/FocusLock/useFocusLock.js.map +1 -1
- package/build/esm/List/List.d.ts +0 -0
- package/build/esm/List/List.js +2 -1
- package/build/esm/List/List.js.map +1 -1
- package/build/esm/List/ListItem.d.ts +0 -0
- package/build/esm/List/ListItem.js +2 -1
- package/build/esm/List/ListItem.js.map +1 -1
- package/build/esm/List/context.d.ts +0 -0
- package/build/esm/List/context.js +0 -0
- package/build/esm/List/context.js.map +1 -1
- package/build/esm/List/index.d.ts +0 -0
- package/build/esm/List/index.js +0 -0
- package/build/esm/List/index.js.map +1 -1
- package/build/esm/Menu/Menu.d.ts +0 -0
- package/build/esm/Menu/Menu.js +2 -1
- package/build/esm/Menu/Menu.js.map +1 -1
- package/build/esm/Menu/MenuButton.d.ts +0 -0
- package/build/esm/Menu/MenuButton.js +3 -2
- package/build/esm/Menu/MenuButton.js.map +1 -1
- package/build/esm/Menu/MenuItem.d.ts +0 -0
- package/build/esm/Menu/MenuItem.js +4 -3
- package/build/esm/Menu/MenuItem.js.map +1 -1
- package/build/esm/Menu/MenuList.d.ts +0 -0
- package/build/esm/Menu/MenuList.js +6 -5
- package/build/esm/Menu/MenuList.js.map +1 -1
- package/build/esm/Menu/MenuPopover.d.ts +0 -0
- package/build/esm/Menu/MenuPopover.js +2 -1
- package/build/esm/Menu/MenuPopover.js.map +1 -1
- package/build/esm/Menu/context.d.ts +0 -0
- package/build/esm/Menu/context.js +0 -0
- package/build/esm/Menu/context.js.map +1 -1
- package/build/esm/Menu/index.d.ts +0 -0
- package/build/esm/Menu/index.js +0 -0
- package/build/esm/Menu/index.js.map +1 -1
- package/build/esm/Menu/scope.d.ts +0 -0
- package/build/esm/Menu/scope.js +0 -0
- package/build/esm/Menu/scope.js.map +1 -1
- package/build/esm/Modal/Modal.d.ts +0 -0
- package/build/esm/Modal/Modal.js +5 -4
- package/build/esm/Modal/Modal.js.map +1 -1
- package/build/esm/Modal/ModalBackdrop.d.ts +0 -0
- package/build/esm/Modal/ModalBackdrop.js +6 -5
- package/build/esm/Modal/ModalBackdrop.js.map +1 -1
- package/build/esm/Modal/index.d.ts +0 -0
- package/build/esm/Modal/index.js +0 -0
- package/build/esm/Modal/index.js.map +1 -1
- package/build/esm/Popper/Popper.d.ts +0 -0
- package/build/esm/Popper/Popper.js +6 -5
- package/build/esm/Popper/Popper.js.map +1 -1
- package/build/esm/Popper/PopperArrow.d.ts +0 -0
- package/build/esm/Popper/PopperArrow.js +5 -5
- package/build/esm/Popper/PopperArrow.js.map +1 -1
- package/build/esm/Popper/context.d.ts +0 -0
- package/build/esm/Popper/context.js +0 -0
- package/build/esm/Popper/context.js.map +1 -1
- package/build/esm/Popper/index.d.ts +0 -0
- package/build/esm/Popper/index.js +0 -0
- package/build/esm/Popper/index.js.map +1 -1
- package/build/esm/Portal/Portal.d.ts +0 -0
- package/build/esm/Portal/Portal.js +0 -0
- package/build/esm/Portal/Portal.js.map +1 -1
- package/build/esm/Portal/index.d.ts +0 -0
- package/build/esm/Portal/index.js +0 -0
- package/build/esm/Portal/index.js.map +1 -1
- package/build/esm/RadioButton/RadioButton.d.ts +0 -0
- package/build/esm/RadioButton/RadioButton.js +5 -2
- package/build/esm/RadioButton/RadioButton.js.map +1 -1
- package/build/esm/RadioButton/RadioGroup.d.ts +0 -0
- package/build/esm/RadioButton/RadioGroup.js +2 -1
- package/build/esm/RadioButton/RadioGroup.js.map +1 -1
- package/build/esm/RadioButton/context.d.ts +0 -0
- package/build/esm/RadioButton/context.js +0 -0
- package/build/esm/RadioButton/context.js.map +1 -1
- package/build/esm/RadioButton/index.d.ts +0 -0
- package/build/esm/RadioButton/index.js +0 -0
- package/build/esm/RadioButton/index.js.map +1 -1
- package/build/esm/SkipNav/SkipNav.d.ts +0 -0
- package/build/esm/SkipNav/SkipNav.js +2 -1
- package/build/esm/SkipNav/SkipNav.js.map +1 -1
- package/build/esm/SkipNav/index.d.ts +0 -0
- package/build/esm/SkipNav/index.js +0 -0
- package/build/esm/SkipNav/index.js.map +1 -1
- package/build/esm/Slider/Slider.d.ts +218 -0
- package/build/esm/Slider/Slider.js +842 -0
- package/build/esm/Slider/Slider.js.map +1 -0
- package/build/esm/Slider/index.d.ts +1 -0
- package/build/esm/Slider/index.js +2 -0
- package/build/esm/Slider/index.js.map +1 -0
- package/build/esm/Spinner/Spinner.d.ts +0 -0
- package/build/esm/Spinner/Spinner.js +2 -1
- package/build/esm/Spinner/Spinner.js.map +1 -1
- package/build/esm/Spinner/SpinnerButton.d.ts +0 -0
- package/build/esm/Spinner/SpinnerButton.js +3 -2
- package/build/esm/Spinner/SpinnerButton.js.map +1 -1
- package/build/esm/Spinner/context.d.ts +0 -0
- package/build/esm/Spinner/context.js +0 -0
- package/build/esm/Spinner/context.js.map +1 -1
- package/build/esm/Spinner/index.d.ts +0 -0
- package/build/esm/Spinner/index.js +0 -0
- package/build/esm/Spinner/index.js.map +1 -1
- package/build/esm/Tabs/Tab.d.ts +0 -0
- package/build/esm/Tabs/Tab.js +3 -2
- package/build/esm/Tabs/Tab.js.map +1 -1
- package/build/esm/Tabs/TabList.d.ts +0 -0
- package/build/esm/Tabs/TabList.js +4 -3
- package/build/esm/Tabs/TabList.js.map +1 -1
- package/build/esm/Tabs/TabPanel.d.ts +0 -0
- package/build/esm/Tabs/TabPanel.js +4 -3
- package/build/esm/Tabs/TabPanel.js.map +1 -1
- package/build/esm/Tabs/TabPanels.d.ts +0 -0
- package/build/esm/Tabs/TabPanels.js +4 -3
- package/build/esm/Tabs/TabPanels.js.map +1 -1
- package/build/esm/Tabs/Tabs.d.ts +0 -0
- package/build/esm/Tabs/Tabs.js +2 -1
- package/build/esm/Tabs/Tabs.js.map +1 -1
- package/build/esm/Tabs/context.d.ts +0 -0
- package/build/esm/Tabs/context.js +0 -0
- package/build/esm/Tabs/context.js.map +1 -1
- package/build/esm/Tabs/index.d.ts +0 -0
- package/build/esm/Tabs/index.js +0 -0
- package/build/esm/Tabs/index.js.map +1 -1
- package/build/esm/Tabs/scopeQuery.d.ts +0 -0
- package/build/esm/Tabs/scopeQuery.js +0 -0
- package/build/esm/Tabs/scopeQuery.js.map +1 -1
- package/build/esm/Tooltip/Tooltip.d.ts +0 -0
- package/build/esm/Tooltip/Tooltip.js +4 -2
- package/build/esm/Tooltip/Tooltip.js.map +1 -1
- package/build/esm/Tooltip/index.d.ts +0 -0
- package/build/esm/Tooltip/index.js +0 -0
- package/build/esm/Tooltip/index.js.map +1 -1
- package/build/esm/Tooltip/stateMachine.d.ts +0 -0
- package/build/esm/Tooltip/stateMachine.js +9 -9
- package/build/esm/Tooltip/stateMachine.js.map +1 -1
- package/build/esm/Tooltip/useTooltip.d.ts +0 -0
- package/build/esm/Tooltip/useTooltip.js +6 -5
- package/build/esm/Tooltip/useTooltip.js.map +1 -1
- package/build/esm/hooks/index.d.ts +0 -0
- package/build/esm/hooks/index.js +0 -0
- package/build/esm/hooks/index.js.map +1 -1
- package/build/esm/hooks/useAutoFocus.d.ts +0 -0
- package/build/esm/hooks/useAutoFocus.js +0 -0
- package/build/esm/hooks/useAutoFocus.js.map +1 -1
- package/build/esm/hooks/useChildrenCounter.d.ts +0 -0
- package/build/esm/hooks/useChildrenCounter.js +0 -0
- package/build/esm/hooks/useChildrenCounter.js.map +1 -1
- package/build/esm/hooks/useControlledState.d.ts +1 -1
- package/build/esm/hooks/useControlledState.js +8 -7
- package/build/esm/hooks/useControlledState.js.map +1 -1
- package/build/esm/hooks/useFocusReturn.d.ts +0 -0
- package/build/esm/hooks/useFocusReturn.js +2 -2
- package/build/esm/hooks/useFocusReturn.js.map +1 -1
- package/build/esm/hooks/useFocusState.d.ts +2 -2
- package/build/esm/hooks/useFocusState.js +1 -1
- package/build/esm/hooks/useFocusState.js.map +1 -1
- package/build/esm/hooks/useGestureHandlers.d.ts +0 -0
- package/build/esm/hooks/useGestureHandlers.js +23 -15
- package/build/esm/hooks/useGestureHandlers.js.map +1 -1
- package/build/esm/hooks/useMeasure.d.ts +0 -0
- package/build/esm/hooks/useMeasure.js +0 -1
- package/build/esm/hooks/useMeasure.js.map +1 -1
- package/build/esm/hooks/useOnClickOutside.d.ts +0 -0
- package/build/esm/hooks/useOnClickOutside.js +0 -0
- package/build/esm/hooks/useOnClickOutside.js.map +1 -1
- package/build/esm/hooks/useOnKeyDown.d.ts +1 -1
- package/build/esm/hooks/useOnKeyDown.js +5 -5
- package/build/esm/hooks/useOnKeyDown.js.map +1 -1
- package/build/esm/hooks/useReducerMachine.d.ts +0 -0
- package/build/esm/hooks/useReducerMachine.js +2 -1
- package/build/esm/hooks/useReducerMachine.js.map +1 -1
- package/build/esm/hooks/useRemoveBodyScroll.d.ts +2 -1
- package/build/esm/hooks/useRemoveBodyScroll.js +12 -8
- package/build/esm/hooks/useRemoveBodyScroll.js.map +1 -1
- package/build/esm/hooks/useScope.d.ts +0 -0
- package/build/esm/hooks/useScope.js +0 -0
- package/build/esm/hooks/useScope.js.map +1 -1
- package/build/esm/hooks/useThrottle.d.ts +0 -0
- package/build/esm/hooks/useThrottle.js +0 -0
- package/build/esm/hooks/useThrottle.js.map +1 -1
- package/build/esm/index.d.ts +1 -0
- package/build/esm/index.js +1 -0
- package/build/esm/index.js.map +1 -1
- package/build/esm/utils/assign-ref.d.ts +3 -0
- package/build/esm/utils/{assignRef.js → assign-ref.js} +1 -1
- package/build/esm/utils/assign-ref.js.map +1 -0
- package/build/esm/utils/can-use-dom.d.ts +1 -0
- package/build/esm/utils/can-use-dom.js +4 -0
- package/build/esm/utils/can-use-dom.js.map +1 -0
- package/build/esm/utils/clamp.d.ts +0 -0
- package/build/esm/utils/clamp.js +0 -0
- package/build/esm/utils/clamp.js.map +1 -1
- package/build/esm/utils/context.d.ts +7 -0
- package/build/esm/utils/context.js +41 -0
- package/build/esm/utils/context.js.map +1 -0
- package/build/esm/utils/{createSubscription.d.ts → create-subscription.d.ts} +0 -0
- package/build/esm/utils/{createSubscription.js → create-subscription.js} +1 -1
- package/build/esm/utils/create-subscription.js.map +1 -0
- package/build/esm/utils/{getCircularIndex.d.ts → get-circular-index.d.ts} +0 -0
- package/build/esm/utils/{getCircularIndex.js → get-circular-index.js} +1 -1
- package/build/esm/utils/get-circular-index.js.map +1 -0
- package/build/esm/utils/index.d.ts +10 -4
- package/build/esm/utils/index.js +10 -4
- package/build/esm/utils/index.js.map +1 -1
- package/build/esm/utils/is-right-click.d.ts +6 -0
- package/build/esm/utils/is-right-click.js +9 -0
- package/build/esm/utils/is-right-click.js.map +1 -0
- package/build/esm/utils/owner-document.d.ts +7 -0
- package/build/esm/utils/owner-document.js +12 -0
- package/build/esm/utils/owner-document.js.map +1 -0
- package/build/esm/utils/polymorphic.d.ts +32 -0
- package/build/esm/utils/polymorphic.js +2 -0
- package/build/esm/utils/polymorphic.js.map +1 -0
- package/build/esm/utils/{rubberBandClamp.d.ts → rubber-band-clamp.d.ts} +0 -0
- package/build/esm/utils/{rubberBandClamp.js → rubber-band-clamp.js} +1 -1
- package/build/esm/utils/rubber-band-clamp.js.map +1 -0
- package/build/esm/utils/use-stable-callback.d.ts +16 -0
- package/build/esm/utils/use-stable-callback.js +43 -0
- package/build/esm/utils/use-stable-callback.js.map +1 -0
- package/build/esm/utils/wrap-event.d.ts +3 -0
- package/build/esm/utils/{wrapEvent.js → wrap-event.js} +1 -1
- package/build/esm/utils/wrap-event.js.map +1 -0
- package/build/tsconfig-build.tsbuildinfo +1 -1
- package/package.json +3 -4
- package/src/ComboBox/ComboboxButton.tsx +2 -2
- package/src/ComboBox/ComboboxOption.tsx +1 -1
- package/src/ComboBox/ComboboxPopover.tsx +2 -2
- package/src/ComboBox/hooks.tsx +1 -1
- package/src/Menu/MenuButton.tsx +1 -1
- package/src/Menu/MenuItem.tsx +1 -1
- package/src/Menu/MenuList.tsx +1 -1
- package/src/Modal/Modal.tsx +1 -1
- package/src/Modal/ModalBackdrop.tsx +2 -2
- package/src/Popper/Popper.tsx +1 -1
- package/src/Popper/PopperArrow.tsx +2 -4
- package/src/Slider/Slider.story.tsx +45 -0
- package/src/Slider/Slider.tsx +1106 -0
- package/src/Slider/index.ts +1 -0
- package/src/Slider/styles.css +131 -0
- package/src/Tooltip/Tooltip.story.tsx +2 -2
- package/src/Tooltip/stateMachine.ts +9 -13
- package/src/Tooltip/useTooltip.ts +2 -2
- package/src/hooks/useControlledState.ts +12 -9
- package/src/hooks/useFocusState.ts +1 -1
- package/src/hooks/useGestureHandlers.ts +22 -12
- package/src/hooks/useMeasure.ts +0 -1
- package/src/hooks/useOnKeyDown.ts +4 -3
- package/src/hooks/useRemoveBodyScroll.ts +18 -8
- package/src/index.ts +1 -0
- package/src/utils/{assignRef.ts → assign-ref.ts} +4 -4
- package/src/utils/can-use-dom.ts +7 -0
- package/src/utils/context.tsx +48 -0
- package/src/utils/{createSubscription.ts → create-subscription.ts} +0 -0
- package/src/utils/{getCircularIndex.ts → get-circular-index.ts} +0 -0
- package/src/utils/index.ts +10 -4
- package/src/utils/is-right-click.ts +14 -0
- package/src/utils/owner-document.ts +13 -0
- package/src/utils/polymorphic.ts +72 -0
- package/src/utils/{rubberBandClamp.ts → rubber-band-clamp.ts} +0 -0
- package/src/utils/use-stable-callback.ts +58 -0
- package/src/utils/wrap-event.ts +22 -0
- package/build/esm/hooks/useId.d.ts +0 -3
- package/build/esm/hooks/useId.js +0 -16
- package/build/esm/hooks/useId.js.map +0 -1
- package/build/esm/utils/assignRef.d.ts +0 -3
- package/build/esm/utils/assignRef.js.map +0 -1
- package/build/esm/utils/createSubscription.js.map +0 -1
- package/build/esm/utils/getCircularIndex.js.map +0 -1
- package/build/esm/utils/rubberBandClamp.js.map +0 -1
- package/build/esm/utils/wrapEvent.d.ts +0 -3
- package/build/esm/utils/wrapEvent.js.map +0 -1
- package/build/tsconfig.tsbuildinfo +0 -1
- package/src/utils/wrapEvent.ts +0 -19
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["as"];
|
|
4
5
|
import { forwardRef, useState, useEffect, useRef } from 'react';
|
|
5
6
|
import { useAccordionItemContext, useAccordionContext } from './context';
|
|
6
7
|
import { bodyScopeQuery as scopeQuery } from './scopeQuery';
|
|
@@ -9,7 +10,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
9
10
|
export var AccordionBody = /*#__PURE__*/forwardRef(function AccordionBody(props, forwardedRef) {
|
|
10
11
|
var _props$as = props.as,
|
|
11
12
|
Comp = _props$as === void 0 ? 'div' : _props$as,
|
|
12
|
-
otherProps = _objectWithoutProperties(props,
|
|
13
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
13
14
|
|
|
14
15
|
var accordionItemContext = useAccordionItemContext();
|
|
15
16
|
var accordionContext = useAccordionContext();
|
|
@@ -36,9 +37,9 @@ export var AccordionBody = /*#__PURE__*/forwardRef(function AccordionBody(props,
|
|
|
36
37
|
}
|
|
37
38
|
}, [accordionContext]);
|
|
38
39
|
var expanded = Boolean(accordionItemContext.expanded || accordionContext && accordionContext.expandedIndex === index);
|
|
39
|
-
return /*#__PURE__*/_jsx(Comp, _extends({
|
|
40
|
+
return /*#__PURE__*/_jsx(Comp, _extends(_extends({
|
|
40
41
|
ref: assignMultipleRefs(forwardedRef, ref)
|
|
41
|
-
}, otherProps, {
|
|
42
|
+
}, otherProps), {}, {
|
|
42
43
|
"aria-labelledby": accordionItemContext.headerId,
|
|
43
44
|
id: accordionItemContext.bodyId,
|
|
44
45
|
role: "region",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"AccordionBody.js","names":["forwardRef","useState","useEffect","useRef","useAccordionItemContext","useAccordionContext","bodyScopeQuery","scopeQuery","assignMultipleRefs","AccordionBody","props","forwardedRef","as","Comp","otherProps","accordionItemContext","accordionContext","ref","index","setIndex","Error","allHeaders","scope","current","queryAllNodes","findIndex","e","expanded","Boolean","expandedIndex","headerId","bodyId","undefined"],"sources":["../../../src/Accordion/AccordionBody.tsx"],"sourcesContent":["import type { HTMLAttributes, ElementType } from 'react';\nimport { forwardRef, useState, useEffect, useRef } from 'react';\n\nimport { useAccordionItemContext, useAccordionContext } from './context';\nimport { bodyScopeQuery as scopeQuery } from './scopeQuery';\nimport { assignMultipleRefs } from '../utils';\n\nexport interface AccordionBodyProps extends HTMLAttributes<HTMLDivElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n}\n\nexport const AccordionBody = forwardRef<HTMLDivElement, AccordionBodyProps>(\n function AccordionBody(props, forwardedRef) {\n const { as: Comp = 'div', ...otherProps } = props;\n const accordionItemContext = useAccordionItemContext();\n const accordionContext = useAccordionContext();\n const ref = useRef<HTMLDivElement>();\n const [index, setIndex] = useState<number>();\n\n if (!accordionItemContext) {\n throw new Error('Missing parent <Accordion /> component');\n }\n\n useEffect(() => {\n if (accordionContext) {\n const allHeaders =\n accordionContext.scope.current.queryAllNodes(scopeQuery);\n\n const index = allHeaders.findIndex((e) => e === ref.current);\n setIndex(index);\n }\n }, [accordionContext]);\n\n const expanded = Boolean(\n accordionItemContext.expanded ||\n (accordionContext && accordionContext.expandedIndex === index)\n );\n\n return (\n <Comp\n ref={assignMultipleRefs(forwardedRef, ref)}\n {...otherProps}\n aria-labelledby={accordionItemContext.headerId}\n id={accordionItemContext.bodyId}\n role=\"region\"\n data-accordion-body=\"\"\n hidden={expanded ? undefined : 'hidden'}\n />\n );\n }\n);\n"],"mappings":";;;;AACA,SAASA,UAAT,EAAqBC,QA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eM,GAAf;EADzB,GAEMH,UAFN;IAGE,mBAAiBC,oBAAoB,CAACe,QAHxC;IAIE,EAAE,EAAEf,oBAAoB,CAACgB,MAJ3B;IAKE,IAAI,EAAC,QALP;IAME,uBAAoB,EANtB;IAOE,MAAM,EAAEJ,QAAQ,GAAGK,SAAH,GAAe;EAPjC,GADF;AAWD,CAtCoC,CAAhC"}
|
|
File without changes
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["as", "onKeyDown", "onClick", "onFocus", "onBlur"];
|
|
4
5
|
import { forwardRef, useRef, useState, useEffect } from 'react';
|
|
5
6
|
import { wrapEvent, assignMultipleRefs, getCircularIndex } from '../utils';
|
|
6
7
|
import { useAccordionContext, useAccordionItemContext } from './context';
|
|
@@ -13,7 +14,7 @@ export var AccordionHeader = /*#__PURE__*/forwardRef(function AccordionHeader(pr
|
|
|
13
14
|
onClickProp = props.onClick,
|
|
14
15
|
onFocus = props.onFocus,
|
|
15
16
|
onBlur = props.onBlur,
|
|
16
|
-
otherProps = _objectWithoutProperties(props,
|
|
17
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
17
18
|
|
|
18
19
|
var accordionContext = useAccordionContext();
|
|
19
20
|
var accordionItemContext = useAccordionItemContext();
|
|
@@ -145,9 +146,9 @@ export var AccordionHeader = /*#__PURE__*/forwardRef(function AccordionHeader(pr
|
|
|
145
146
|
};
|
|
146
147
|
|
|
147
148
|
var expanded = Boolean(accordionItemContext.expanded || accordionContext && accordionContext.expandedIndex === index);
|
|
148
|
-
return /*#__PURE__*/_jsx(Comp, _extends({
|
|
149
|
+
return /*#__PURE__*/_jsx(Comp, _extends(_extends({
|
|
149
150
|
ref: assignMultipleRefs(ref, forwardedRef)
|
|
150
|
-
}, otherProps, {
|
|
151
|
+
}, otherProps), {}, {
|
|
151
152
|
id: accordionItemContext.headerId,
|
|
152
153
|
"aria-controls": accordionItemContext.bodyId,
|
|
153
154
|
role: "button",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Accordion/AccordionHeader.tsx"],"names":["forwardRef","useRef","useState","useEffect","wrapEvent","assignMultipleRefs","getCircularIndex","useAccordionContext","useAccordionItemContext","headerScopeQuery","scopeQuery","AccordionHeader","props","forwardedRef","as","Comp","onKeyDown","onClickProp","onClick","onFocus","onBlur","otherProps","accordionContext","accordionItemContext","ref","index","setIndex","Error","allHeaders","scope","current","queryAllNodes","findIndex","e","expanded","expandedIndex","onChange","handleKeyDown","key","preventDefault","length","nextIndex","focus","handleFocus","childrenHeaderHasFocus","setChildrenHeaderHasFocus","handleBlur","newFocusIsHeader","header","relatedTarget","Boolean","headerId","bodyId","String"],"mappings":";;;AAQA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,QAA7B,EAAuCC,SAAvC,QAAwD,OAAxD;AAEA,SAASC,SAAT,EAAoBC,kBAApB,EAAwCC,gBAAxC,QAAgE,UAAhE;AACA,SAASC,mBAAT,EAA8BC,uBAA9B,QAA6D,WAA7D;AACA,SAASC,gBAAgB,IAAIC,UAA7B,QAA+C,cAA/C;;AAQA,OAAO,IAAMC,eAAe,gBAAGX,UAAU,CACvC,SAASW,eAAT,CAAyBC,KAAzB,EAAgCC,YAAhC,EAA8C;AAAA,kBAQxCD,KARwC,CAE1CE,EAF0C;AAAA,MAEtCC,IAFsC,0BAE/B,KAF+B;AAAA,MAG1CC,SAH0C,GAQxCJ,KARwC,CAG1CI,SAH0C;AAAA,MAIjCC,WAJiC,GAQxCL,KARwC,CAI1CM,OAJ0C;AAAA,MAK1CC,OAL0C,GAQxCP,KARwC,CAK1CO,OAL0C;AAAA,MAM1CC,MAN0C,GAQxCR,KARwC,CAM1CQ,MAN0C;AAAA,MAOvCC,UAPuC,4BAQxCT,KARwC;;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AME,6BAAsB,EANxB;AAOE,IAAA,QAAQ,EAAC,GAPX;AAQE,IAAA,SAAS,EAAEhD,SAAS,CAACY,SAAD,EAAYqB,aAAZ,CARtB;AASE,IAAA,OAAO,EAAEjC,SAAS,CAACe,OAAD,EAAUwB,WAAV,CATpB;AAUE,IAAA,MAAM,EAAEvC,SAAS,CAACgB,MAAD,EAAS0B,UAAT,CAVnB;AAWE,IAAA,OAAO,EAAE5B,OAXX;AAYE,qBAAemC,MAAM,CAACnB,QAAD;AAZvB,KADF;AAgBD,CAjJsC,CAAlC","sourcesContent":["import type {\n HTMLAttributes,\n ElementType,\n ReactNode,\n MouseEvent,\n KeyboardEvent,\n FocusEvent,\n} from 'react';\nimport { forwardRef, useRef, useState, useEffect } from 'react';\n\nimport { wrapEvent, assignMultipleRefs, getCircularIndex } from '../utils';\nimport { useAccordionContext, useAccordionItemContext } from './context';\nimport { headerScopeQuery as scopeQuery } from './scopeQuery';\n\nexport interface AccordionHeaderProps extends HTMLAttributes<HTMLDivElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport const AccordionHeader = forwardRef<HTMLDivElement, AccordionHeaderProps>(\n function AccordionHeader(props, forwardedRef) {\n const {\n as: Comp = 'div',\n onKeyDown,\n onClick: onClickProp,\n onFocus,\n onBlur,\n ...otherProps\n } = props;\n const accordionContext = useAccordionContext();\n const accordionItemContext = useAccordionItemContext();\n const ref = useRef<HTMLDivElement>();\n const [index, setIndex] = useState<number | undefined>();\n\n if (!accordionItemContext) {\n throw new Error('Missing parent <Accordion /> component');\n }\n\n useEffect(() => {\n if (accordionContext) {\n const allHeaders =\n accordionContext.scope.current.queryAllNodes(scopeQuery) || [];\n\n const index = allHeaders.findIndex((e) => e === ref.current);\n setIndex(index);\n }\n }, [accordionContext]);\n\n const onClick = wrapEvent(onClickProp, (e: MouseEvent<HTMLDivElement>) => {\n let index = 0;\n if (accordionItemContext.expanded) {\n index = -1;\n } else if (accordionContext) {\n const allHeaders =\n accordionContext.scope.current.queryAllNodes(scopeQuery) || [];\n\n index = allHeaders.findIndex((e) => e === ref.current);\n if (index === accordionContext.expandedIndex) {\n index = -1;\n }\n accordionContext.onChange && accordionContext.onChange(e, index);\n }\n\n accordionItemContext.onChange &&\n accordionItemContext.onChange(e, index >= 0);\n });\n\n const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n switch (e.key) {\n case 'Enter':\n case ' ': {\n onClick(e as unknown as MouseEvent<HTMLDivElement>);\n e.preventDefault();\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n case 'Home':\n case 'End': {\n if (!accordionContext) {\n return;\n }\n const allHeaders =\n accordionContext.scope.current.queryAllNodes(scopeQuery);\n\n e.preventDefault();\n\n if (allHeaders.length === 0) {\n return;\n }\n\n let nextIndex = allHeaders.findIndex((e) => e === ref.current);\n switch (e.key) {\n case 'ArrowUp':\n nextIndex += -1;\n break;\n case 'ArrowDown':\n nextIndex += +1;\n break;\n case 'Home':\n nextIndex = 0;\n break;\n case 'End':\n nextIndex = -1;\n break;\n }\n\n // We're sure it will not be null, because we already checked for allHeaders.length > 0 above\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n nextIndex = getCircularIndex(nextIndex, allHeaders.length)!;\n allHeaders[nextIndex] && allHeaders[nextIndex].focus();\n break;\n }\n default:\n return;\n }\n };\n\n const handleFocus = () => {\n if (accordionContext) {\n if (!accordionContext.childrenHeaderHasFocus) {\n // this is needed to avoid rerendering the parent and\n // messing up with the internal count for children/parent count\n accordionContext.setChildrenHeaderHasFocus(true);\n }\n }\n };\n\n const handleBlur = (e: FocusEvent<HTMLDivElement>) => {\n if (accordionContext) {\n const allHeaders =\n accordionContext.scope.current.queryAllNodes(scopeQuery);\n const newFocusIsHeader =\n allHeaders.findIndex((header) => header === e.relatedTarget) >= 0;\n\n // only remove focus flag if the focus went to some element\n // that is not an accordion header\n if (!newFocusIsHeader) {\n accordionContext.setChildrenHeaderHasFocus(false);\n }\n }\n };\n\n const expanded = Boolean(\n accordionItemContext.expanded ||\n (accordionContext && accordionContext.expandedIndex === index)\n );\n\n return (\n <Comp\n ref={assignMultipleRefs(ref, forwardedRef)}\n {...otherProps}\n id={accordionItemContext.headerId}\n aria-controls={accordionItemContext.bodyId}\n role=\"button\"\n data-accordion-header=\"\"\n tabIndex=\"0\"\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n onFocus={wrapEvent(onFocus, handleFocus)}\n onBlur={wrapEvent(onBlur, handleBlur)}\n onClick={onClick}\n aria-expanded={String(expanded)}\n />\n );\n }\n);\n"],"file":"AccordionHeader.js"}
|
|
1
|
+
{"version":3,"file":"AccordionHeader.js","names":["forwardRef","useRef","useState","useEffect","wrapEvent","assignMultipleRefs","getCircularIndex","useAccordionContext","useAccordionItemContext","headerScopeQuery","scopeQuery","AccordionHeader","props","forwardedRef","as","Comp","onKeyDown","onClickProp","onClick","onFocus","onBlur","otherProps","accordionContext","accordionItemContext","ref","index","setIndex","Error","allHeaders","scope","current","queryAllNodes","findIndex","e","expanded","expandedIndex","onChange","handleKeyDown","key","preventDefault","length","nextIndex","focus","handleFocus","childrenHeaderHasFocus","setChildrenHeaderHasFocus","handleBlur","newFocusIsHeader","header","relatedTarget","Boolean","headerId","bodyId","String"],"sources":["../../../src/Accordion/AccordionHeader.tsx"],"sourcesContent":["import type {\n HTMLAttributes,\n ElementType,\n ReactNode,\n MouseEvent,\n KeyboardEvent,\n FocusEvent,\n} from 'react';\nimport { forwardRef, useRef, useState, useEffect } from 'react';\n\nimport { wrapEvent, assignMultipleRefs, getCircularIndex } from '../utils';\nimport { useAccordionContext, useAccordionItemContext } from './context';\nimport { headerScopeQuery as scopeQuery } from './scopeQuery';\n\nexport interface AccordionHeaderProps extends HTMLAttributes<HTMLDivElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport const AccordionHeader = forwardRef<HTMLDivElement, AccordionHeaderProps>(\n function AccordionHeader(props, forwardedRef) {\n const {\n as: Comp = 'div',\n onKeyDown,\n onClick: onClickProp,\n onFocus,\n onBlur,\n ...otherProps\n } = props;\n const accordionContext = useAccordionContext();\n const accordionItemContext = useAccordionItemContext();\n const ref = useRef<HTMLDivElement>();\n const [index, setIndex] = useState<number | undefined>();\n\n if (!accordionItemContext) {\n throw new Error('Missing parent <Accordion /> component');\n }\n\n useEffect(() => {\n if (accordionContext) {\n const allHeaders =\n accordionContext.scope.current.queryAllNodes(scopeQuery) || [];\n\n const index = allHeaders.findIndex((e) => e === ref.current);\n setIndex(index);\n }\n }, [accordionContext]);\n\n const onClick = wrapEvent(onClickProp, (e: MouseEvent<HTMLDivElement>) => {\n let index = 0;\n if (accordionItemContext.expanded) {\n index = -1;\n } else if (accordionContext) {\n const allHeaders =\n accordionContext.scope.current.queryAllNodes(scopeQuery) || [];\n\n index = allHeaders.findIndex((e) => e === ref.current);\n if (index === accordionContext.expandedIndex) {\n index = -1;\n }\n accordionContext.onChange && accordionContext.onChange(e, index);\n }\n\n accordionItemContext.onChange &&\n accordionItemContext.onChange(e, index >= 0);\n });\n\n const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n switch (e.key) {\n case 'Enter':\n case ' ': {\n onClick(e as unknown as MouseEvent<HTMLDivElement>);\n e.preventDefault();\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n case 'Home':\n case 'End': {\n if (!accordionContext) {\n return;\n }\n const allHeaders =\n accordionContext.scope.current.queryAllNodes(scopeQuery);\n\n e.preventDefault();\n\n if (allHeaders.length === 0) {\n return;\n }\n\n let nextIndex = allHeaders.findIndex((e) => e === ref.current);\n switch (e.key) {\n case 'ArrowUp':\n nextIndex += -1;\n break;\n case 'ArrowDown':\n nextIndex += +1;\n break;\n case 'Home':\n nextIndex = 0;\n break;\n case 'End':\n nextIndex = -1;\n break;\n }\n\n // We're sure it will not be null, because we already checked for allHeaders.length > 0 above\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n nextIndex = getCircularIndex(nextIndex, allHeaders.length)!;\n allHeaders[nextIndex] && allHeaders[nextIndex].focus();\n break;\n }\n default:\n return;\n }\n };\n\n const handleFocus = () => {\n if (accordionContext) {\n if (!accordionContext.childrenHeaderHasFocus) {\n // this is needed to avoid rerendering the parent and\n // messing up with the internal count for children/parent count\n accordionContext.setChildrenHeaderHasFocus(true);\n }\n }\n };\n\n const handleBlur = (e: FocusEvent<HTMLDivElement>) => {\n if (accordionContext) {\n const allHeaders =\n accordionContext.scope.current.queryAllNodes(scopeQuery);\n const newFocusIsHeader =\n allHeaders.findIndex((header) => header === e.relatedTarget) >= 0;\n\n // only remove focus flag if the focus went to some element\n // that is not an accordion header\n if (!newFocusIsHeader) {\n accordionContext.setChildrenHeaderHasFocus(false);\n }\n }\n };\n\n const expanded = Boolean(\n accordionItemContext.expanded ||\n (accordionContext && accordionContext.expandedIndex === index)\n );\n\n return (\n <Comp\n ref={assignMultipleRefs(ref, forwardedRef)}\n {...otherProps}\n id={accordionItemContext.headerId}\n aria-controls={accordionItemContext.bodyId}\n role=\"button\"\n data-accordion-header=\"\"\n tabIndex=\"0\"\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n onFocus={wrapEvent(onFocus, handleFocus)}\n onBlur={wrapEvent(onBlur, handleBlur)}\n onClick={onClick}\n aria-expanded={String(expanded)}\n />\n );\n }\n);\n"],"mappings":";;;;AAQA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,QAA7B,EAAuCC,SAAvC,QAAwD,OAAxD;AAEA,SAASC,SAAT,EAAoBC,kBAApB,EAAwCC,gBAAxC,QAAgE,UAAhE;AACA,SAASC,mBAAT,EAA8BC,uBAA9B,QAA6D,WAA7D;AACA,SAASC,gBAAgB,IAAIC,UAA7B,QAA+C,cAA/C;;AAQA,OAAO,IAAMC,eAAe,gBAAGX,UAAU,CACvC,SAASW,eAAT,CAAyBC,KAAzB,EAAgCC,YAAhC,EAA8C;EAC5C,gBAOID,KAPJ,CACEE,EADF;EAAA,IAC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AC4B,QAH3B;IAIE,iBAAe5B,oBAAoB,CAAC6B,MAJtC;IAKE,IAAI,EAAC,QALP;IAME,yBAAsB,EANxB;IAOE,QAAQ,EAAC,GAPX;IAQE,SAAS,EAAEhD,SAAS,CAACY,SAAD,EAAYqB,aAAZ,CARtB;IASE,OAAO,EAAEjC,SAAS,CAACe,OAAD,EAAUwB,WAAV,CATpB;IAUE,MAAM,EAAEvC,SAAS,CAACgB,MAAD,EAAS0B,UAAT,CAVnB;IAWE,OAAO,EAAE5B,OAXX;IAYE,iBAAemC,MAAM,CAACnB,QAAD;EAZvB,GADF;AAgBD,CAjJsC,CAAlC"}
|
|
File without changes
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["as", "expanded", "onChange"];
|
|
3
4
|
import { Fragment, forwardRef, useId } from 'react';
|
|
4
5
|
import { AccordionItemProvider } from './context';
|
|
5
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -9,7 +10,7 @@ export var AccordionItem = /*#__PURE__*/forwardRef(function AccordionItem(props,
|
|
|
9
10
|
_props$expanded = props.expanded,
|
|
10
11
|
expanded = _props$expanded === void 0 ? false : _props$expanded,
|
|
11
12
|
onChange = props.onChange,
|
|
12
|
-
otherProps = _objectWithoutProperties(props,
|
|
13
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
13
14
|
|
|
14
15
|
var id = useId();
|
|
15
16
|
var headerId = id ? "accordion-header-".concat(id) : undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"AccordionItem.js","names":["Fragment","forwardRef","useId","AccordionItemProvider","AccordionItem","props","forwardedRef","as","Comp","expanded","onChange","otherProps","id","headerId","undefined","bodyId","contextValue"],"sources":["../../../src/Accordion/AccordionItem.tsx"],"sourcesContent":["import type {\n HTMLAttributes,\n ElementType,\n ReactNode,\n KeyboardEvent,\n MouseEvent,\n} from 'react';\nimport { Fragment, forwardRef, useId } from 'react';\n\nimport type { AccordionItemContextProps } from './context';\nimport { AccordionItemProvider } from './context';\n\nexport interface AccordionItemProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n expanded?: boolean;\n onChange?: (\n e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>,\n value: boolean\n ) => void;\n}\n\nexport const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(\n function AccordionItem(props, forwardedRef) {\n const {\n as: Comp = Fragment,\n expanded = false,\n onChange,\n ...otherProps\n } = props;\n const id = useId();\n\n const headerId = id ? `accordion-header-${id}` : undefined;\n const bodyId = id ? `accordion-body-${id}` : undefined;\n const contextValue: AccordionItemContextProps = {\n headerId,\n bodyId,\n expanded,\n onChange,\n };\n\n return (\n <AccordionItemProvider value={contextValue}>\n <Comp ref={forwardedRef} {...otherProps} />\n </AccordionItemProvider>\n );\n }\n);\n"],"mappings":";;;AAOA,SAASA,QAAT,EAAmBC,UAAnB,EAA+BC,KAA/B,QAA4C,OAA5C;AAGA,SAASC,qBAAT,QAAsC,WAAtC;;AAcA,OAAO,IAAMC,aAAa,gBAAGH,UAAU,CACrC,SAASG,aAAT,CAAuBC,KAAvB,EAA8BC,YAA9B,EAA4C;EAC1C,gBAKID,KALJ,CACEE,EADF;EAAA,IACMC,IADN,0BACaR,QADb;EAAA,sBAKIK,KALJ,CAEEI,QAFF;EAAA,IAEEA,QAFF,gCAEa,KAFb;EAAA,IAGEC,QAHF,GAKIL,KALJ,CAGEK,QAHF;EAAA,IAIKC,UAJL,4BAKIN,KALJ;;EAMA,IAAMO,EAAE,GAAGV,KAAK,EAAhB;EAEA,IAAMW,QAAQ,GAAGD,EAAE,8BAAuBA,EAAvB,IAA8BE,SAAjD;EACA,IAAMC,MAAM,GAAGH,EAAE,4BAAqBA,EAArB,IAA4BE,SAA7C;EACA,IAAME,YAAuC,GAAG;IAC9CH,QAAQ,EAARA,QAD8C;IAE9CE,MAAM,EAANA,MAF8C;IAG9CN,QAAQ,EAARA,QAH8C;IAI9CC,QAAQ,EAARA;EAJ8C,CAAhD;EAOA,oBACE,KAAC,qBAAD;IAAuB,KAAK,EAAEM,YAA9B;IAAA,uBACE,KAAC,IAAD;MAAM,GAAG,EAAEV;IAAX,GAA6BK,UAA7B;EADF,EADF;AAKD,CAxBoC,CAAhC"}
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"context.js","names":["useContext","createContext","accordionContext","AccordionProvider","Provider","useAccordionContext","accordionItemContext","AccordionItemProvider","useAccordionItemContext"],"sources":["../../../src/Accordion/context.ts"],"sourcesContent":["import type { KeyboardEvent, MouseEvent } from 'react';\nimport { useContext, createContext } from 'react';\n\nimport type { Scope } from '../hooks/useScope';\n\n// AccordionGroup Component\nexport interface AccordionContextProps {\n childrenHeaderHasFocus: boolean;\n setChildrenHeaderHasFocus: (value: boolean) => void;\n scope: Scope<HTMLElement>;\n expandedIndex: number;\n onChange?: (\n e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>,\n index: number\n ) => void;\n}\n\nconst accordionContext = createContext<AccordionContextProps | null>(null);\nexport const { Provider: AccordionProvider } = accordionContext;\nexport const useAccordionContext = () => useContext(accordionContext);\n\n// Accordion Component\nexport interface AccordionItemContextProps {\n headerId: string | undefined;\n bodyId: string | undefined;\n expanded: boolean;\n onChange?: (\n e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>,\n value: boolean\n ) => void;\n}\n\nconst accordionItemContext = createContext<AccordionItemContextProps | null>(\n null\n);\nexport const { Provider: AccordionItemProvider } = accordionItemContext;\nexport const useAccordionItemContext = () => useContext(accordionItemContext);\n"],"mappings":"AACA,SAASA,UAAT,EAAqBC,aAArB,QAA0C,OAA1C;AAgBA,IAAMC,gBAAgB,gBAAGD,aAAa,CAA+B,IAA/B,CAAtC;AACO,IAAkBE,iBAAlB,GAAwCD,gBAAxC,CAAQE,QAAR;;AACP,OAAO,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAsB;EAAA,OAAML,UAAU,CAACE,gBAAD,CAAhB;AAAA,CAA5B,C,CAEP;;AAWA,IAAMI,oBAAoB,gBAAGL,aAAa,CACxC,IADwC,CAA1C;AAGO,IAAkBM,qBAAlB,GAA4CD,oBAA5C,CAAQF,QAAR;;AACP,OAAO,IAAMI,uBAAuB,GAAG,SAA1BA,uBAA0B;EAAA,OAAMR,UAAU,CAACM,oBAAD,CAAhB;AAAA,CAAhC"}
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/Accordion/index.ts"],"sourcesContent":["export * from './Accordion';\nexport * from './AccordionItem';\nexport * from './AccordionHeader';\nexport * from './AccordionBody';\n"],"mappings":"AAAA,cAAc,aAAd;AACA,cAAc,iBAAd;AACA,cAAc,mBAAd;AACA,cAAc,iBAAd"}
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"scopeQuery.js","names":["headerScopeQuery","type","props","bodyScopeQuery"],"sources":["../../../src/Accordion/scopeQuery.ts"],"sourcesContent":["export function headerScopeQuery(type: string, props: Record<string, unknown>) {\n return props['data-accordion-header'] === '';\n}\n\nexport function bodyScopeQuery(type: string, props: Record<string, unknown>) {\n return props['data-accordion-body'] === '';\n}\n"],"mappings":"AAAA,OAAO,SAASA,gBAAT,CAA0BC,IAA1B,EAAwCC,KAAxC,EAAwE;EAC7E,OAAOA,KAAK,CAAC,uBAAD,CAAL,KAAmC,EAA1C;AACD;AAED,OAAO,SAASC,cAAT,CAAwBF,IAAxB,EAAsCC,KAAtC,EAAsE;EAC3E,OAAOA,KAAK,CAAC,qBAAD,CAAL,KAAiC,EAAxC;AACD"}
|
|
File without changes
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["as", "checked", "defaultChecked", "onChange"];
|
|
4
5
|
import { forwardRef } from 'react';
|
|
5
6
|
import { useControlledState } from '../hooks';
|
|
6
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -11,7 +12,7 @@ export var CheckBox = /*#__PURE__*/forwardRef(function CheckBox(props, forwarded
|
|
|
11
12
|
_props$defaultChecked = props.defaultChecked,
|
|
12
13
|
defaultChecked = _props$defaultChecked === void 0 ? false : _props$defaultChecked,
|
|
13
14
|
onChangeProp = props.onChange,
|
|
14
|
-
otherProps = _objectWithoutProperties(props,
|
|
15
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
15
16
|
|
|
16
17
|
var _useControlledState = useControlledState(checkedProp, onChangeProp, defaultChecked, function (setValue) {
|
|
17
18
|
return function (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"CheckBox.js","names":["forwardRef","useControlledState","CheckBox","props","forwardedRef","as","Comp","checkedProp","checked","defaultChecked","onChangeProp","onChange","otherProps","setValue","e","target"],"sources":["../../../src/CheckBox/CheckBox.tsx"],"sourcesContent":["import type { ElementType, InputHTMLAttributes, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nimport { useControlledState } from '../hooks';\n\nexport interface CheckBoxProps extends InputHTMLAttributes<HTMLInputElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport const CheckBox = forwardRef<HTMLInputElement, CheckBoxProps>(\n function CheckBox(props, forwardedRef) {\n const {\n as: Comp = 'input',\n checked: checkedProp,\n defaultChecked = false,\n onChange: onChangeProp,\n ...otherProps\n } = props;\n const [checked, onChange] = useControlledState(\n checkedProp,\n onChangeProp,\n defaultChecked,\n (setValue) => (e) => {\n setValue(e.target.checked);\n }\n );\n\n return (\n <Comp\n ref={forwardedRef}\n type=\"checkbox\"\n checked={checked}\n aria-checked={checked}\n onChange={onChange}\n {...otherProps}\n />\n );\n }\n);\n"],"mappings":";;;;AACA,SAASA,UAAT,QAA2B,OAA3B;AAEA,SAASC,kBAAT,QAAmC,UAAnC;;AAQA,OAAO,IAAMC,QAAQ,gBAAGF,UAAU,CAChC,SAASE,QAAT,CAAkBC,KAAlB,EAAyBC,YAAzB,EAAuC;EACrC,gBAMID,KANJ,CACEE,EADF;EAAA,IACMC,IADN,0BACa,OADb;EAAA,IAEWC,WAFX,GAMIJ,KANJ,CAEEK,OAFF;EAAA,4BAMIL,KANJ,CAGEM,cAHF;EAAA,IAGEA,cAHF,sCAGmB,KAHnB;EAAA,IAIYC,YAJZ,GAMIP,KANJ,CAIEQ,QAJF;EAAA,IAKKC,UALL,4BAMIT,KANJ;;EAOA,0BAA4BF,kBAAkB,CAC5CM,WAD4C,EAE5CG,YAF4C,EAG5CD,cAH4C,EAI5C,UAACI,QAAD;IAAA,OAAc,UAACC,CAAD,EAAO;MACnBD,QAAQ,CAACC,CAAC,CAACC,MAAF,CAASP,OAAV,CAAR;IACD,CAFD;EAAA,CAJ4C,CAA9C;EAAA;EAAA,IAAOA,OAAP;EAAA,IAAgBG,QAAhB;;EASA,oBACE,KAAC,IAAD;IACE,GAAG,EAAEP,YADP;IAEE,IAAI,EAAC,UAFP;IAGE,OAAO,EAAEI,OAHX;IAIE,gBAAcA,OAJhB;IAKE,QAAQ,EAAEG;EALZ,GAMMC,UANN,EADF;AAUD,CA5B+B,CAA3B"}
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/CheckBox/index.ts"],"sourcesContent":["export * from './CheckBox';\n"],"mappings":"AAAA,cAAc,YAAd"}
|
|
File without changes
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["onSelect", "openOnFocus", "selectOnBlur", "children", "as", "innerAs"];
|
|
4
5
|
import { forwardRef, useRef, useMemo, useId } from 'react';
|
|
5
6
|
import { stateChart, comboboxReducer, isVisible, INIT } from './hooks';
|
|
6
7
|
import { ComboBoxProvider } from './context';
|
|
@@ -17,7 +18,7 @@ export var Combobox = /*#__PURE__*/forwardRef(function Combobox(_ref, ref) {
|
|
|
17
18
|
_ref$as = _ref.as,
|
|
18
19
|
Comp = _ref$as === void 0 ? 'div' : _ref$as,
|
|
19
20
|
innerAs = _ref.innerAs,
|
|
20
|
-
rest = _objectWithoutProperties(_ref,
|
|
21
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
21
22
|
|
|
22
23
|
// We store the values of all the ComboboxOptions on this ref. This makes it
|
|
23
24
|
// possible to perform the keyboard navigation from the input on the list. We
|
|
@@ -88,7 +89,7 @@ export var Combobox = /*#__PURE__*/forwardRef(function Combobox(_ref, ref) {
|
|
|
88
89
|
}, [data, onSelect, listScope, state, transition, openOnFocus, selectOnBlur]);
|
|
89
90
|
return /*#__PURE__*/_jsx(ComboBoxProvider, {
|
|
90
91
|
value: context,
|
|
91
|
-
children: /*#__PURE__*/_jsx(Comp, _extends({}, rest, {
|
|
92
|
+
children: /*#__PURE__*/_jsx(Comp, _extends(_extends({}, rest), {}, {
|
|
92
93
|
as: innerAs,
|
|
93
94
|
"data-reach-combobox": "",
|
|
94
95
|
ref: ref,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Combobox.js","names":["forwardRef","useRef","useMemo","useId","stateChart","comboboxReducer","isVisible","INIT","ComboBoxProvider","useReducerMachine","getScope","Combobox","ref","onSelect","openOnFocus","selectOnBlur","children","as","Comp","innerAs","rest","optionsRef","listScope","current","inputRef","popoverRef","buttonRef","autocompletePropRef","persistSelectionRef","clearOnEscapeRef","listboxIdRef","labelIdRef","defaultData","state","initial","text","item","navigationItem","lastActionType","data","transition","context"],"sources":["../../../src/ComboBox/Combobox.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode, ElementType } from 'react';\nimport { forwardRef, useRef, useMemo, useId } from 'react';\n\nimport type { ActionTypes } from './hooks';\nimport { stateChart, comboboxReducer, isVisible, INIT } from './hooks';\nimport type { ComboBoxContextProps } from './context';\nimport { ComboBoxProvider } from './context';\nimport { useReducerMachine } from '../hooks/useReducerMachine';\nimport type { Scope } from '../hooks';\nimport { getScope } from '../hooks';\n\nexport type SelectEventHandler = (\n text: string,\n itemId: string,\n obj: any\n) => void;\n\nexport type ComboboxProps = Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> & {\n onSelect?: SelectEventHandler;\n openOnFocus?: boolean;\n selectOnBlur?: boolean;\n children?: ReactNode;\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n};\n\nexport const Combobox = forwardRef<HTMLDivElement, ComboboxProps>(\n function Combobox(\n {\n // Called whenever the user selects an item from the list\n onSelect,\n\n // opens the list when the input receives focused (but only if there are\n // items in the list)\n openOnFocus = false,\n\n // if set to true, it will select an item after blurring\n selectOnBlur = false,\n\n children,\n as: Comp = 'div',\n innerAs,\n ...rest\n }: ComboboxProps,\n ref\n ) {\n // We store the values of all the ComboboxOptions on this ref. This makes it\n // possible to perform the keyboard navigation from the input on the list. We\n // manipulate this array through context so that we don't have to enforce a\n // parent/child relationship between ComboboxList and ComboboxOption.\n const optionsRef = useRef<{\n [itemId: string]: {\n value: string | unknown;\n text: string;\n };\n }>({});\n\n const listScope: Scope<HTMLElement> = useRef(getScope({ current: null }));\n\n // Need this to focus it\n const inputRef = useRef<HTMLInputElement>(null);\n\n const popoverRef = useRef<HTMLDivElement>(null);\n\n const buttonRef = useRef<HTMLButtonElement>(null);\n\n // When <ComboboxInput autocomplete={false} /> we don't want cycle back to\n // the user's value while navigating (because it's always the user's value),\n // but we need to know this in useKeyDown which is far away from the prop\n // here, so we do something sneaky and write it to this ref on context so we\n // can use it anywhere else 😛. Another new trick for me and I'm excited\n // about this one too!\n const autocompletePropRef = useRef<boolean>(false);\n\n const persistSelectionRef = useRef<boolean>(false);\n\n const clearOnEscapeRef = useRef<boolean>(false);\n\n const listboxIdRef = useRef<string | undefined>();\n\n const labelIdRef = useRef<string | undefined>();\n\n const defaultData = {\n // initial state\n state: stateChart.initial,\n // the value the user has typed, we derived this also when the developer is\n // controlling the value of ComboboxInput\n text: '',\n // the index the user has typed, we derived this also when the developer is\n // controlling the value of ComboboxInput\n item: '',\n // the hash of the currently navigated item\n navigationItem: '',\n // the last submitted action\n lastActionType: INIT as ActionTypes,\n };\n\n const [state, data, transition] = useReducerMachine(\n stateChart,\n comboboxReducer,\n defaultData\n );\n\n listboxIdRef.current = useId();\n\n labelIdRef.current = useId();\n\n const context = useMemo(\n (): ComboBoxContextProps => ({\n data,\n inputRef,\n popoverRef,\n buttonRef,\n onSelect,\n optionsRef,\n listScope,\n state,\n transition,\n listboxIdRef,\n labelIdRef,\n autocompletePropRef,\n persistSelectionRef,\n clearOnEscapeRef,\n isVisible: isVisible(state),\n openOnFocus,\n selectOnBlur,\n }),\n [data, onSelect, listScope, state, transition, openOnFocus, selectOnBlur]\n );\n\n return (\n <ComboBoxProvider value={context}>\n <Comp\n {...rest}\n as={innerAs}\n data-reach-combobox=\"\"\n ref={ref}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-owns={listboxIdRef.current}\n aria-expanded={context.isVisible}\n >\n {children}\n </Comp>\n </ComboBoxProvider>\n );\n }\n);\n"],"mappings":";;;;AACA,SAASA,UAAT,EAAqBC,MAArB,EAA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,OAAzB;IAAA,uBACE,KAAC,IAAD,wBACMrB,IADN;MAEE,EAAE,EAAED,OAFN;MAGE,uBAAoB,EAHtB;MAIE,GAAG,EAAEP,GAJP;MAKE,IAAI,EAAC,UALP;MAME,iBAAc,SANhB;MAOE,aAAWkB,YAAY,CAACP,OAP1B;MAQE,iBAAekB,OAAO,CAACnC,SARzB;MAAA,UAUGU;IAVH;EADF,EADF;AAgBD,CAxH+B,CAA3B"}
|
|
File without changes
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["as", "innerAs", "onClick", "onKeyDown"];
|
|
3
4
|
import { forwardRef } from 'react';
|
|
4
5
|
import { useComboBoxContext } from './context';
|
|
5
6
|
import { useKeyDown, IDLE, OPEN_WITH_BUTTON, CLOSE_WITH_BUTTON } from './hooks';
|
|
6
|
-
import { wrapEvent } from '../utils/
|
|
7
|
-
import { assignMultipleRefs } from '../utils/
|
|
7
|
+
import { wrapEvent } from '../utils/wrap-event';
|
|
8
|
+
import { assignMultipleRefs } from '../utils/assign-ref';
|
|
8
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
10
|
export var ComboboxButton = /*#__PURE__*/forwardRef(function ComboboxButton(_ref, ref) {
|
|
10
11
|
var _ref$as = _ref.as,
|
|
@@ -12,7 +13,7 @@ export var ComboboxButton = /*#__PURE__*/forwardRef(function ComboboxButton(_ref
|
|
|
12
13
|
innerAs = _ref.innerAs,
|
|
13
14
|
onClick = _ref.onClick,
|
|
14
15
|
onKeyDown = _ref.onKeyDown,
|
|
15
|
-
props = _objectWithoutProperties(_ref,
|
|
16
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
16
17
|
|
|
17
18
|
var _useComboBoxContext = useComboBoxContext(),
|
|
18
19
|
transition = _useComboBoxContext.transition,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"ComboboxButton.js","names":["forwardRef","useComboBoxContext","useKeyDown","IDLE","OPEN_WITH_BUTTON","CLOSE_WITH_BUTTON","wrapEvent","assignMultipleRefs","ComboboxButton","ref","as","Comp","innerAs","onClick","onKeyDown","props","transition","data","state","buttonRef","listboxIdRef","isVisible","handleKeyDown","handleClick","payload","item","navigationItem","current"],"sources":["../../../src/ComboBox/ComboboxButton.tsx"],"sourcesContent":["import type {\n ButtonHTMLAttributes,\n ElementType,\n KeyboardEventHandler,\n MouseEventHandler,\n ReactNode,\n} from 'react';\nimport { forwardRef } from 'react';\n\nimport { useComboBoxContext } from './context';\nimport { useKeyDown, IDLE, OPEN_WITH_BUTTON, CLOSE_WITH_BUTTON } from './hooks';\nimport { wrapEvent } from '../utils/wrap-event';\nimport { assignMultipleRefs } from '../utils/assign-ref';\n\nexport interface ComboboxButtonProps\n extends ButtonHTMLAttributes<HTMLButtonElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n onClick?: MouseEventHandler<HTMLButtonElement>;\n onKeyDown?: KeyboardEventHandler<HTMLButtonElement>;\n children?: ReactNode;\n}\n\nexport const ComboboxButton = forwardRef<\n HTMLButtonElement,\n ComboboxButtonProps\n>(function ComboboxButton(\n { as: Comp = 'button', innerAs, onClick, onKeyDown, ...props },\n ref\n) {\n const { transition, data, state, buttonRef, listboxIdRef, isVisible } =\n useComboBoxContext();\n\n const handleKeyDown = useKeyDown();\n\n const handleClick = () => {\n const payload = {\n item: data.navigationItem,\n };\n\n if (state === IDLE) {\n transition(OPEN_WITH_BUTTON, payload);\n } else {\n transition(CLOSE_WITH_BUTTON, payload);\n }\n };\n\n return (\n <Comp\n as={innerAs}\n data-reach-combobox-button=\"\"\n aria-controls={listboxIdRef.current}\n aria-haspopup=\"listbox\"\n aria-expanded={isVisible}\n ref={assignMultipleRefs(ref, buttonRef)}\n onClick={wrapEvent(onClick, handleClick)}\n onKeyDown={wrapEvent(onKeyDown, handle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BAAeN,SALjB;IAME,GAAG,EAAEd,kBAAkB,CAACE,GAAD,EAAMU,SAAN,CANzB;IAOE,OAAO,EAAEb,SAAS,CAACO,OAAD,EAAUU,WAAV,CAPpB;IAQE,SAAS,EAAEjB,SAAS,CAACQ,SAAD,EAAYQ,aAAZ;EARtB,GASMP,KATN,EADF;AAaD,CArCuC,CAAjC"}
|
|
File without changes
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["as", "innerAs", "selectOnClick", "autocomplete", "clearOnEscape", "onClick", "onChange", "onKeyDown", "onBlur", "onFocus", "id", "defaultValue", "value"];
|
|
3
4
|
import { forwardRef, useEffect, useRef } from 'react';
|
|
4
5
|
import { useBlur, CLEAR, CHANGE, useKeyDown, SELECT_WITH_CLICK, FOCUS, NAVIGATING, INIT, useFocusManagement } from './hooks';
|
|
5
6
|
import { assignMultipleRefs, wrapEvent } from '../utils';
|
|
@@ -24,7 +25,7 @@ export var ComboboxInput = /*#__PURE__*/forwardRef(function ComboboxInput(_ref,
|
|
|
24
25
|
_ref$defaultValue = _ref.defaultValue,
|
|
25
26
|
defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
|
|
26
27
|
controlledValue = _ref.value,
|
|
27
|
-
props = _objectWithoutProperties(_ref,
|
|
28
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
28
29
|
|
|
29
30
|
var _useComboBoxContext = useComboBoxContext(),
|
|
30
31
|
_useComboBoxContext$d = _useComboBoxContext.data,
|
|
@@ -110,7 +111,7 @@ export var ComboboxInput = /*#__PURE__*/forwardRef(function ComboboxInput(_ref,
|
|
|
110
111
|
item: ''
|
|
111
112
|
}); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
112
113
|
}, []);
|
|
113
|
-
return /*#__PURE__*/_jsx(Comp, _extends({}, props, {
|
|
114
|
+
return /*#__PURE__*/_jsx(Comp, _extends(_extends({}, props), {}, {
|
|
114
115
|
as: innerAs,
|
|
115
116
|
"data-reach-combobox-input": "",
|
|
116
117
|
ref: assignMultipleRefs(inputRef, forwardedRef),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ComboBox/ComboboxInput.tsx"],"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"],"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;AAAA,qBAtBEC,EAsBF;AAAA,MAtBMC,IAsBN,wBAtBa,OAsBb;AAAA,MArBEC,OAqBF,QArBEA,OAqBF;AAAA,gCApBEC,aAoBF;AAAA,MApBEA,aAoBF,mCApBkB,KAoBlB;AAAA,+BAnBEC,YAmBF;AAAA,MAnBEA,YAmBF,kC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AxB,GAAyC0B,SAf7C;AAiBE,IAAA,YAAY,EAAC;AAjBf,KADF;AAqBD,CA1IoC,CAAhC","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"],"file":"ComboboxInput.js"}
|
|
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 {\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,UAAT,EAAqBC,SAArB,EAAgCC,MAAhC,QAA8C,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E,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"}
|
|
File without changes
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["as", "innerAs", "id"];
|
|
3
4
|
import { forwardRef } from 'react';
|
|
4
5
|
import { useComboBoxContext } from './context';
|
|
5
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -8,7 +9,7 @@ export var ComboboxLabel = /*#__PURE__*/forwardRef(function ComboboxButton(_ref,
|
|
|
8
9
|
Comp = _ref$as === void 0 ? 'label' : _ref$as,
|
|
9
10
|
innerAs = _ref.innerAs,
|
|
10
11
|
preferredId = _ref.id,
|
|
11
|
-
props = _objectWithoutProperties(_ref,
|
|
12
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
12
13
|
|
|
13
14
|
var _useComboBoxContext = useComboBoxContext(),
|
|
14
15
|
listboxIdRef = _useComboBoxContext.listboxIdRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"ComboboxLabel.js","names":["forwardRef","useComboBoxContext","ComboboxLabel","ComboboxButton","ref","as","Comp","innerAs","preferredId","id","props","listboxIdRef","labelIdRef","current"],"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,UAAT,QAA2B,OAA3B;AAEA,SAASC,kBAAT,QAAmC,WAAnC;;AASA,OAAO,IAAMC,aAAa,gBAAGF,UAAU,CACrC,SAASG,cAAT,OAEEC,GAFF,EAGE;EAAA,mBAFEC,EAEF;EAAA,IAFMC,IAEN,wBAFa,OAEb;EAAA,IAFsBC,OAEtB,QAFsBA,OAEtB;EAAA,IAFmCC,WAEnC,QAF+BC,EAE/B;EAAA,IAFmDC,KAEnD;;EACA,0BAAqCT,kBAAkB,EAAvD;EAAA,IAAQU,YAAR,uBAAQA,YAAR;EAAA,IAAsBC,UAAtB,uBAAsBA,UAAtB;;EAEAA,UAAU,CAACC,OAAX,GAAqBL,WAAW,IAAII,UAAU,CAACC,OAA/C;EAEA,oBACE,KAAC,IAAD;IACE,EAAE,EAAEN,OADN;IAEE,6BAA0B,EAF5B;IAGE,OAAO,EAAEI,YAAY,CAACE,OAHxB;IAIE,EAAE,EAAED,UAAU,CAACC,OAJjB;IAKE,GAAG,EAAET;EALP,GAMMM,KANN,EADF;AAUD,CAnBoC,CAAhC"}
|
|
File without changes
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["persistSelection", "as", "innerAs"];
|
|
3
4
|
import { forwardRef, useRef, useEffect } from 'react';
|
|
4
5
|
import { useComboBoxContext } from './context';
|
|
5
6
|
import { getScope } from '../hooks';
|
|
@@ -11,7 +12,7 @@ export var ComboboxList = /*#__PURE__*/forwardRef(function ComboboxList(_ref, re
|
|
|
11
12
|
_ref$as = _ref.as,
|
|
12
13
|
Comp = _ref$as === void 0 ? 'ul' : _ref$as,
|
|
13
14
|
innerAs = _ref.innerAs,
|
|
14
|
-
props = _objectWithoutProperties(_ref,
|
|
15
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
15
16
|
|
|
16
17
|
var _useComboBoxContext = useComboBoxContext(),
|
|
17
18
|
persistSelectionRef = _useComboBoxContext.persistSelectionRef,
|
|
@@ -23,7 +24,7 @@ export var ComboboxList = /*#__PURE__*/forwardRef(function ComboboxList(_ref, re
|
|
|
23
24
|
listScope.current = getScope(listRef);
|
|
24
25
|
}, [listScope]);
|
|
25
26
|
persistSelectionRef.current = persistSelection;
|
|
26
|
-
return /*#__PURE__*/_jsx(Comp, _extends({}, props, {
|
|
27
|
+
return /*#__PURE__*/_jsx(Comp, _extends(_extends({}, props), {}, {
|
|
27
28
|
as: innerAs,
|
|
28
29
|
ref: assignMultipleRefs(ref, listRef),
|
|
29
30
|
"data-reach-combobox-list": "",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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';\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>();\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,UAAT,EAAqBC,MAArB,EAA6BC,SAA7B,QAA8C,OAA9C;AAEA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,QAAT,QAAyB,UAAzB;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AASA,OAAO,IAAMC,YAAY,gBAAGN,UAAU,CACpC,SAASM,YAAT,OASEC,GATF,EAUE;EAAA,iCANEC,gBAMF;EAAA,IANEA,gBAMF,sCANqB,KAMrB;EAAA,mBALEC,EAKF;EAAA,IALMC,IAKN,wBALa,IAKb;EAAA,IAJEC,OAIF,QAJEA,OAIF;EAAA,IAHKC,KAGL;;EACA,0BAAuDT,kBAAkB,EAAzE;EAAA,IAAQU,mBAAR,uBAAQA,mBAAR;EAAA,IAA6BC,UAA7B,uBAA6BA,UAA7B;EAAA,IAAyCC,SAAzC,uBAAyCA,SAAzC;;EAEA,IAAMC,OAAO,GAAGf,MAAM,EAAtB;EACAC,SAAS,CAAC,YAAM;IACda,SAAS,CAACE,OAAV,GAAoBb,QAAQ,CAACY,OAAD,CAA5B;EACD,CAFQ,EAEN,CAACD,SAAD,CAFM,CAAT;EAIAF,mBAAmB,CAACI,OAApB,GAA8BT,gBAA9B;EAEA,oBACE,KAAC,IAAD,wBACMI,KADN;IAEE,EAAE,EAAED,OAFN;IAGE,GAAG,EAAEN,kBAAkB,CAACE,GAAD,EAAMS,OAAN,CAHzB;IAIE,4BAAyB,EAJ3B;IAKE,IAAI,EAAC,SALP;IAME,mBAAiBF,UAAU,CAACG;EAN9B,GADF;AAUD,CA/BmC,CAA/B"}
|
|
File without changes
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["children", "id", "value", "text", "onClick", "as", "innerAs"];
|
|
3
4
|
|
|
4
5
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
5
6
|
import { forwardRef, useEffect, useRef } from 'react';
|
|
6
7
|
import { SELECT_WITH_CLICK, CLEAR_SELECTION } from './hooks';
|
|
7
|
-
import { wrapEvent } from '../utils/
|
|
8
|
+
import { wrapEvent } from '../utils/wrap-event';
|
|
8
9
|
import { useComboBoxContext } from './context';
|
|
9
10
|
import { makeHash } from './makeHash';
|
|
10
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -17,7 +18,7 @@ export var ComboboxOption = /*#__PURE__*/forwardRef(function ComboboxOption(_ref
|
|
|
17
18
|
_ref$as = _ref.as,
|
|
18
19
|
Comp = _ref$as === void 0 ? 'li' : _ref$as,
|
|
19
20
|
innerAs = _ref.innerAs,
|
|
20
|
-
props = _objectWithoutProperties(_ref,
|
|
21
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
21
22
|
|
|
22
23
|
var _useComboBoxContext = useComboBoxContext(),
|
|
23
24
|
onSelect = _useComboBoxContext.onSelect,
|
|
@@ -72,7 +73,7 @@ export var ComboboxOption = /*#__PURE__*/forwardRef(function ComboboxOption(_ref
|
|
|
72
73
|
});
|
|
73
74
|
};
|
|
74
75
|
|
|
75
|
-
return /*#__PURE__*/_jsx(Comp, _extends({}, props, {
|
|
76
|
+
return /*#__PURE__*/_jsx(Comp, _extends(_extends({}, props), {}, {
|
|
76
77
|
as: innerAs,
|
|
77
78
|
"data-reach-combobox-option": "",
|
|
78
79
|
ref: ref,
|