@basic-ui/core 0.0.53 → 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/build/cjs/index.js +278 -505
- package/build/cjs/index.js.map +1 -1
- package/build/esm/Accordion/Accordion.js +20 -29
- package/build/esm/Accordion/Accordion.js.map +1 -1
- package/build/esm/Accordion/AccordionBody.js +18 -32
- package/build/esm/Accordion/AccordionBody.js.map +1 -1
- package/build/esm/Accordion/AccordionHeader.js +37 -74
- package/build/esm/Accordion/AccordionHeader.js.map +1 -1
- package/build/esm/Accordion/AccordionItem.js +19 -22
- package/build/esm/Accordion/AccordionItem.js.map +1 -1
- package/build/esm/Accordion/context.js +16 -13
- package/build/esm/Accordion/context.js.map +1 -1
- package/build/esm/Accordion/index.js.map +1 -1
- package/build/esm/Accordion/scopeQuery.js.map +1 -1
- package/build/esm/CheckBox/CheckBox.js +15 -25
- package/build/esm/CheckBox/CheckBox.js.map +1 -1
- package/build/esm/CheckBox/index.js.map +1 -1
- package/build/esm/ComboBox/Combobox.d.ts +7 -7
- package/build/esm/ComboBox/Combobox.js +52 -59
- package/build/esm/ComboBox/Combobox.js.map +1 -1
- package/build/esm/ComboBox/ComboboxButton.js +23 -28
- package/build/esm/ComboBox/ComboboxButton.js.map +1 -1
- package/build/esm/ComboBox/ComboboxInput.js +67 -70
- package/build/esm/ComboBox/ComboboxInput.js.map +1 -1
- package/build/esm/ComboBox/ComboboxLabel.js +15 -17
- package/build/esm/ComboBox/ComboboxLabel.js.map +1 -1
- package/build/esm/ComboBox/ComboboxList.js +19 -20
- package/build/esm/ComboBox/ComboboxList.js.map +1 -1
- package/build/esm/ComboBox/ComboboxOption.js +41 -45
- package/build/esm/ComboBox/ComboboxOption.js.map +1 -1
- package/build/esm/ComboBox/ComboboxPopover.js +22 -21
- package/build/esm/ComboBox/ComboboxPopover.js.map +1 -1
- package/build/esm/ComboBox/cities.js.map +1 -1
- package/build/esm/ComboBox/context.js +5 -6
- package/build/esm/ComboBox/context.js.map +1 -1
- package/build/esm/ComboBox/hooks.d.ts +2 -2
- package/build/esm/ComboBox/hooks.js +175 -148
- package/build/esm/ComboBox/hooks.js.map +1 -1
- package/build/esm/ComboBox/index.js.map +1 -1
- package/build/esm/ComboBox/makeHash.js +3 -6
- package/build/esm/ComboBox/makeHash.js.map +1 -1
- package/build/esm/ComboBox/scopeQuery.js.map +1 -1
- package/build/esm/FocusLock/FocusLock.js +26 -32
- package/build/esm/FocusLock/FocusLock.js.map +1 -1
- package/build/esm/FocusLock/index.js.map +1 -1
- package/build/esm/FocusLock/tabUtils.js +5 -7
- package/build/esm/FocusLock/tabUtils.js.map +1 -1
- package/build/esm/FocusLock/useFocusLock.js +14 -19
- package/build/esm/FocusLock/useFocusLock.js.map +1 -1
- package/build/esm/List/List.js +9 -11
- package/build/esm/List/List.js.map +1 -1
- package/build/esm/List/ListItem.js +9 -11
- package/build/esm/List/ListItem.js.map +1 -1
- package/build/esm/List/context.js +6 -6
- package/build/esm/List/context.js.map +1 -1
- package/build/esm/List/index.js.map +1 -1
- package/build/esm/Menu/ContextMenuTrigger.d.ts +4 -4
- package/build/esm/Menu/ContextMenuTrigger.js +32 -37
- package/build/esm/Menu/ContextMenuTrigger.js.map +1 -1
- package/build/esm/Menu/Menu.js +33 -49
- package/build/esm/Menu/Menu.js.map +1 -1
- package/build/esm/Menu/MenuButton.d.ts +4 -4
- package/build/esm/Menu/MenuButton.js +28 -44
- package/build/esm/Menu/MenuButton.js.map +1 -1
- package/build/esm/Menu/MenuItem.js +29 -38
- package/build/esm/Menu/MenuItem.js.map +1 -1
- package/build/esm/Menu/MenuList.js +61 -116
- package/build/esm/Menu/MenuList.js.map +1 -1
- package/build/esm/Menu/MenuPopover.js +16 -19
- package/build/esm/Menu/MenuPopover.js.map +1 -1
- package/build/esm/Menu/context.d.ts +1 -1
- package/build/esm/Menu/context.js +14 -12
- package/build/esm/Menu/context.js.map +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.js.map +1 -1
- package/build/esm/Menu/scope.js.map +1 -1
- package/build/esm/Modal/Modal.js +13 -18
- package/build/esm/Modal/Modal.js.map +1 -1
- package/build/esm/Modal/ModalBackdrop.js +24 -33
- package/build/esm/Modal/ModalBackdrop.js.map +1 -1
- package/build/esm/Modal/index.js.map +1 -1
- package/build/esm/Popper/Popper.d.ts +3 -3
- package/build/esm/Popper/Popper.js +44 -61
- package/build/esm/Popper/Popper.js.map +1 -1
- package/build/esm/Popper/PopperArrow.js +11 -16
- package/build/esm/Popper/PopperArrow.js.map +1 -1
- package/build/esm/Popper/context.js +3 -5
- package/build/esm/Popper/context.js.map +1 -1
- package/build/esm/Popper/index.js.map +1 -1
- package/build/esm/Portal/Portal.js +9 -11
- package/build/esm/Portal/Portal.js.map +1 -1
- package/build/esm/Portal/PortalSelectorProvider.d.ts +3 -3
- package/build/esm/Portal/PortalSelectorProvider.js +6 -4
- package/build/esm/Portal/PortalSelectorProvider.js.map +1 -1
- package/build/esm/Portal/index.js.map +1 -1
- package/build/esm/RadioButton/RadioButton.js +17 -23
- package/build/esm/RadioButton/RadioButton.js.map +1 -1
- package/build/esm/RadioButton/RadioGroup.js +19 -28
- package/build/esm/RadioButton/RadioGroup.js.map +1 -1
- package/build/esm/RadioButton/context.d.ts +1 -1
- package/build/esm/RadioButton/context.js +8 -6
- package/build/esm/RadioButton/context.js.map +1 -1
- package/build/esm/RadioButton/index.js.map +1 -1
- package/build/esm/SkipNav/SkipNav.js +9 -11
- package/build/esm/SkipNav/SkipNav.js.map +1 -1
- package/build/esm/SkipNav/index.js.map +1 -1
- package/build/esm/Slider/Slider.d.ts +7 -7
- package/build/esm/Slider/Slider.js +340 -407
- package/build/esm/Slider/Slider.js.map +1 -1
- package/build/esm/Slider/index.js.map +1 -1
- package/build/esm/Spinner/Spinner.js +31 -59
- package/build/esm/Spinner/Spinner.js.map +1 -1
- package/build/esm/Spinner/SpinnerButton.js +14 -19
- package/build/esm/Spinner/SpinnerButton.js.map +1 -1
- package/build/esm/Spinner/context.js +8 -7
- package/build/esm/Spinner/context.js.map +1 -1
- package/build/esm/Spinner/index.js.map +1 -1
- package/build/esm/Tabs/Tab.js +32 -50
- package/build/esm/Tabs/Tab.js.map +1 -1
- package/build/esm/Tabs/TabList.js +24 -34
- package/build/esm/Tabs/TabList.js.map +1 -1
- package/build/esm/Tabs/TabPanel.js +16 -23
- package/build/esm/Tabs/TabPanel.js.map +1 -1
- package/build/esm/Tabs/TabPanels.js +15 -20
- package/build/esm/Tabs/TabPanels.js.map +1 -1
- package/build/esm/Tabs/Tabs.js +17 -33
- package/build/esm/Tabs/Tabs.js.map +1 -1
- package/build/esm/Tabs/context.js +16 -13
- package/build/esm/Tabs/context.js.map +1 -1
- package/build/esm/Tabs/index.js.map +1 -1
- package/build/esm/Tabs/scopeQuery.js.map +1 -1
- package/build/esm/Tooltip/Tooltip.d.ts +2 -2
- package/build/esm/Tooltip/Tooltip.js +20 -30
- package/build/esm/Tooltip/Tooltip.js.map +1 -1
- package/build/esm/Tooltip/index.js.map +1 -1
- package/build/esm/Tooltip/stateMachine.d.ts +2 -2
- package/build/esm/Tooltip/stateMachine.js +95 -81
- package/build/esm/Tooltip/stateMachine.js.map +1 -1
- package/build/esm/Tooltip/useTooltip.d.ts +2 -2
- package/build/esm/Tooltip/useTooltip.js +38 -50
- package/build/esm/Tooltip/useTooltip.js.map +1 -1
- package/build/esm/hooks/index.js.map +1 -1
- package/build/esm/hooks/useAutoFocus.js +3 -3
- package/build/esm/hooks/useAutoFocus.js.map +1 -1
- package/build/esm/hooks/useChildrenCounter.js +6 -8
- package/build/esm/hooks/useChildrenCounter.js.map +1 -1
- package/build/esm/hooks/useControlledState.js +6 -16
- package/build/esm/hooks/useControlledState.js.map +1 -1
- package/build/esm/hooks/useFocusReturn.js +8 -12
- package/build/esm/hooks/useFocusReturn.js.map +1 -1
- package/build/esm/hooks/useFocusState.d.ts +2 -2
- package/build/esm/hooks/useFocusState.js +9 -15
- package/build/esm/hooks/useFocusState.js.map +1 -1
- package/build/esm/hooks/useGestureHandlers.d.ts +1 -1
- package/build/esm/hooks/useGestureHandlers.js +80 -100
- package/build/esm/hooks/useGestureHandlers.js.map +1 -1
- package/build/esm/hooks/useMeasure.js +7 -15
- package/build/esm/hooks/useMeasure.js.map +1 -1
- package/build/esm/hooks/useOnClickOutside.js +4 -6
- package/build/esm/hooks/useOnClickOutside.js.map +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 +1 -1
- package/build/esm/hooks/useReducerMachine.js +15 -26
- package/build/esm/hooks/useReducerMachine.js.map +1 -1
- package/build/esm/hooks/useRemoveBodyScroll.js +9 -14
- package/build/esm/hooks/useRemoveBodyScroll.js.map +1 -1
- package/build/esm/hooks/useScope.d.ts +2 -2
- package/build/esm/hooks/useScope.js +12 -14
- package/build/esm/hooks/useScope.js.map +1 -1
- package/build/esm/hooks/useThrottle.js +5 -10
- package/build/esm/hooks/useThrottle.js.map +1 -1
- 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.js +3 -5
- package/build/esm/utils/assign-ref.js.map +1 -1
- package/build/esm/utils/can-use-dom.js.map +1 -1
- package/build/esm/utils/clamp.js.map +1 -1
- package/build/esm/utils/context.d.ts +1 -1
- package/build/esm/utils/context.js +13 -20
- package/build/esm/utils/context.js.map +1 -1
- 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.js +0 -1
- package/build/esm/utils/get-circular-index.js.map +1 -1
- package/build/esm/utils/index.js.map +1 -1
- package/build/esm/utils/is-right-click.js.map +1 -1
- package/build/esm/utils/owner-document.js +1 -1
- package/build/esm/utils/owner-document.js.map +1 -1
- package/build/esm/utils/polymorphic.d.ts +10 -10
- package/build/esm/utils/polymorphic.js.map +1 -1
- 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.js +8 -10
- package/build/esm/utils/use-stable-callback.js.map +1 -1
- package/build/esm/utils/wrap-event.d.ts +1 -1
- 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.tsx +1 -1
- package/src/Accordion/AccordionBody.tsx +1 -1
- package/src/Accordion/AccordionHeader.tsx +1 -2
- package/src/ComboBox/Combobox.tsx +2 -2
- package/src/ComboBox/ComboboxList.tsx +1 -1
- package/src/ComboBox/ComboboxOption.tsx +0 -1
- package/src/ComboBox/hooks.tsx +0 -3
- package/src/FocusLock/useFocusLock.ts +0 -1
- package/src/Menu/Menu.tsx +2 -3
- package/src/Menu/MenuItem.tsx +1 -2
- package/src/Menu/MenuList.tsx +4 -4
- package/src/Modal/Modal.story.tsx +11 -7
- package/src/Modal/ModalBackdrop.tsx +1 -1
- package/src/Modal/NavDrawer.story.tsx +9 -6
- package/src/Popper/Popper.story.tsx +23 -7
- package/src/Popper/Popper.tsx +2 -2
- package/src/RadioButton/RadioButton.story.tsx +2 -1
- package/src/Slider/Slider.tsx +6 -11
- package/src/Spinner/Spinner.tsx +1 -1
- package/src/Tabs/TabList.tsx +1 -1
- package/src/Tooltip/Tooltip.tsx +8 -5
- package/src/Tooltip/useTooltip.ts +1 -1
- package/src/hooks/useControlledState.ts +1 -6
- package/src/hooks/useGestureHandlers.ts +0 -4
- package/src/hooks/useRemoveBodyScroll.ts +0 -1
- package/src/hooks/useScope.ts +1 -1
- package/src/styles.d.ts +1 -0
- package/src/utils/polymorphic.ts +14 -10
- package/src/utils/use-stable-callback.ts +0 -1
- package/build/esm/Carousel/Carousel.d.ts +0 -9
- package/build/esm/Carousel/Carousel.js +0 -38
- package/build/esm/Carousel/Carousel.js.map +0 -1
- package/build/esm/Carousel/Fader.d.ts +0 -14
- package/build/esm/Carousel/Fader.js +0 -76
- package/build/esm/Carousel/Fader.js.map +0 -1
- package/build/esm/Carousel/FaderItem.d.ts +0 -5
- package/build/esm/Carousel/FaderItem.js +0 -16
- package/build/esm/Carousel/FaderItem.js.map +0 -1
- package/build/esm/Carousel/Preloader.d.ts +0 -7
- package/build/esm/Carousel/Preloader.js +0 -70
- package/build/esm/Carousel/Preloader.js.map +0 -1
- package/build/esm/Carousel/Slider.d.ts +0 -14
- package/build/esm/Carousel/Slider.js +0 -212
- package/build/esm/Carousel/Slider.js.map +0 -1
- package/build/esm/Carousel/SliderItem.d.ts +0 -12
- package/build/esm/Carousel/SliderItem.js +0 -41
- package/build/esm/Carousel/SliderItem.js.map +0 -1
- package/build/esm/Carousel/context.d.ts +0 -10
- package/build/esm/Carousel/context.js +0 -8
- package/build/esm/Carousel/context.js.map +0 -1
- package/build/esm/Carousel/getSliderParams.d.ts +0 -9
- package/build/esm/Carousel/getSliderParams.js +0 -85
- package/build/esm/Carousel/getSliderParams.js.map +0 -1
- package/build/esm/Carousel/index.d.ts +0 -7
- package/build/esm/Carousel/index.js +0 -8
- package/build/esm/Carousel/index.js.map +0 -1
- package/build/esm/Carousel/useCarouselGestures.d.ts +0 -30
- package/build/esm/Carousel/useCarouselGestures.js +0 -33
- package/build/esm/Carousel/useCarouselGestures.js.map +0 -1
- package/build/esm/DatePicker/DatePicker.d.ts +0 -24
- package/build/esm/DatePicker/DatePicker.js +0 -101
- package/build/esm/DatePicker/DatePicker.js.map +0 -1
- package/build/esm/DatePicker/DatePickerSelect.d.ts +0 -8
- package/build/esm/DatePicker/DatePickerSelect.js +0 -201
- package/build/esm/DatePicker/DatePickerSelect.js.map +0 -1
- package/build/esm/DatePicker/RangeDatePicker.d.ts +0 -28
- package/build/esm/DatePicker/RangeDatePicker.js +0 -94
- package/build/esm/DatePicker/RangeDatePicker.js.map +0 -1
- package/build/esm/DatePicker/adjustDates.d.ts +0 -4
- package/build/esm/DatePicker/adjustDates.js +0 -18
- package/build/esm/DatePicker/adjustDates.js.map +0 -1
- package/build/esm/DatePicker/contexts.d.ts +0 -31
- package/build/esm/DatePicker/contexts.js +0 -15
- package/build/esm/DatePicker/contexts.js.map +0 -1
- package/build/esm/DatePicker/dateTypes.d.ts +0 -2
- package/build/esm/DatePicker/dateTypes.js +0 -2
- package/build/esm/DatePicker/dateTypes.js.map +0 -1
- package/build/esm/DatePicker/hooks.d.ts +0 -36
- package/build/esm/DatePicker/hooks.js +0 -98
- package/build/esm/DatePicker/hooks.js.map +0 -1
- package/build/esm/DatePicker/index.d.ts +0 -5
- package/build/esm/DatePicker/index.js +0 -6
- package/build/esm/DatePicker/index.js.map +0 -1
- package/build/esm/hooks/useId.d.ts +0 -1
- package/build/esm/hooks/useId.js +0 -25
- package/build/esm/hooks/useId.js.map +0 -1
- package/build/esm/utils/assignRef.d.ts +0 -3
- package/build/esm/utils/assignRef.js +0 -25
- package/build/esm/utils/assignRef.js.map +0 -1
- package/build/esm/utils/getCircularIndex.d.ts +0 -1
- package/build/esm/utils/getCircularIndex.js +0 -8
- package/build/esm/utils/getCircularIndex.js.map +0 -1
- package/build/esm/utils/rubberBandClamp.d.ts +0 -2
- package/build/esm/utils/rubberBandClamp.js +0 -20
- package/build/esm/utils/rubberBandClamp.js.map +0 -1
- package/build/esm/utils/wrapEvent.d.ts +0 -3
- package/build/esm/utils/wrapEvent.js +0 -16
- package/build/esm/utils/wrapEvent.js.map +0 -1
- package/build/tsconfig.tsbuildinfo +0 -7270
|
@@ -1,34 +1,24 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["as", "checked", "defaultChecked", "onChange"];
|
|
5
1
|
import { forwardRef } from 'react';
|
|
6
2
|
import { useControlledState } from '../hooks';
|
|
7
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
}),
|
|
22
|
-
_useControlledState2 = _slicedToArray(_useControlledState, 2),
|
|
23
|
-
checked = _useControlledState2[0],
|
|
24
|
-
onChange = _useControlledState2[1];
|
|
25
|
-
|
|
26
|
-
return /*#__PURE__*/_jsx(Comp, _extends({
|
|
4
|
+
export const CheckBox = /*#__PURE__*/forwardRef(function CheckBox(props, forwardedRef) {
|
|
5
|
+
const {
|
|
6
|
+
as: Comp = 'input',
|
|
7
|
+
checked: checkedProp,
|
|
8
|
+
defaultChecked = false,
|
|
9
|
+
onChange: onChangeProp,
|
|
10
|
+
...otherProps
|
|
11
|
+
} = props;
|
|
12
|
+
const [checked, onChange] = useControlledState(checkedProp, onChangeProp, defaultChecked, setValue => e => {
|
|
13
|
+
setValue(e.target.checked);
|
|
14
|
+
});
|
|
15
|
+
return /*#__PURE__*/_jsx(Comp, {
|
|
27
16
|
ref: forwardedRef,
|
|
28
17
|
type: "checkbox",
|
|
29
18
|
checked: checked,
|
|
30
19
|
"aria-checked": checked,
|
|
31
|
-
onChange: onChange
|
|
32
|
-
|
|
20
|
+
onChange: onChange,
|
|
21
|
+
...otherProps
|
|
22
|
+
});
|
|
33
23
|
});
|
|
34
24
|
//# sourceMappingURL=CheckBox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckBox.js","names":["forwardRef","useControlledState","CheckBox","props","forwardedRef","as","Comp","
|
|
1
|
+
{"version":3,"file":"CheckBox.js","names":["forwardRef","useControlledState","jsx","_jsx","CheckBox","props","forwardedRef","as","Comp","checked","checkedProp","defaultChecked","onChange","onChangeProp","otherProps","setValue","e","target","ref","type"],"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,UAAU,QAAQ,OAAO;AAElC,SAASC,kBAAkB,QAAQ,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAQ9C,OAAO,MAAMC,QAAQ,gBAAGJ,UAAU,CAChC,SAASI,QAAQA,CAACC,KAAK,EAAEC,YAAY,EAAE;EACrC,MAAM;IACJC,EAAE,EAAEC,IAAI,GAAG,OAAO;IAClBC,OAAO,EAAEC,WAAW;IACpBC,cAAc,GAAG,KAAK;IACtBC,QAAQ,EAAEC,YAAY;IACtB,GAAGC;EACL,CAAC,GAAGT,KAAK;EACT,MAAM,CAACI,OAAO,EAAEG,QAAQ,CAAC,GAAGX,kBAAkB,CAC5CS,WAAW,EACXG,YAAY,EACZF,cAAc,EACbI,QAAQ,IAAMC,CAAC,IAAK;IACnBD,QAAQ,CAACC,CAAC,CAACC,MAAM,CAACR,OAAO,CAAC;EAC5B,CACF,CAAC;EAED,oBACEN,IAAA,CAACK,IAAI;IACHU,GAAG,EAAEZ,YAAa;IAClBa,IAAI,EAAC,UAAU;IACfV,OAAO,EAAEA,OAAQ;IACjB,gBAAcA,OAAQ;IACtBG,QAAQ,EAAEA,QAAS;IAAA,GACfE;EAAU,CACf,CAAC;AAEN,CACF,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/CheckBox/index.ts"],"sourcesContent":["export * from './CheckBox';\n"],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/CheckBox/index.ts"],"sourcesContent":["export * from './CheckBox';\n"],"mappings":"AAAA,cAAc,YAAY","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HTMLAttributes, ReactNode, ElementType } from 'react';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type SelectEventHandler = (text: string, itemId: string, obj: any) => void;
|
|
3
|
+
export type ComboboxProps = Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> & {
|
|
4
4
|
onSelect?: SelectEventHandler;
|
|
5
5
|
openOnFocus?: boolean;
|
|
6
6
|
selectOnBlur?: boolean;
|
|
@@ -9,10 +9,10 @@ export declare type ComboboxProps = Omit<HTMLAttributes<HTMLDivElement>, 'onSele
|
|
|
9
9
|
innerAs?: ElementType<any>;
|
|
10
10
|
};
|
|
11
11
|
export declare const Combobox: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "onSelect"> & {
|
|
12
|
-
onSelect?: SelectEventHandler
|
|
13
|
-
openOnFocus?: boolean
|
|
14
|
-
selectOnBlur?: boolean
|
|
12
|
+
onSelect?: SelectEventHandler;
|
|
13
|
+
openOnFocus?: boolean;
|
|
14
|
+
selectOnBlur?: boolean;
|
|
15
15
|
children?: ReactNode;
|
|
16
|
-
as?: ElementType<any
|
|
17
|
-
innerAs?: ElementType<any
|
|
16
|
+
as?: ElementType<any>;
|
|
17
|
+
innerAs?: ElementType<any>;
|
|
18
18
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["onSelect", "openOnFocus", "selectOnBlur", "children", "as", "innerAs"];
|
|
5
1
|
import { forwardRef, useRef, useMemo, useId } from 'react';
|
|
6
2
|
import { stateChart, comboboxReducer, isVisible, INIT } from './hooks';
|
|
7
3
|
import { ComboBoxProvider } from './context';
|
|
8
4
|
import { useReducerMachine } from '../hooks/useReducerMachine';
|
|
9
5
|
import { getScope } from '../hooks';
|
|
10
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
export const Combobox = /*#__PURE__*/forwardRef(function Combobox(_ref, ref) {
|
|
8
|
+
let {
|
|
9
|
+
// Called whenever the user selects an item from the list
|
|
10
|
+
onSelect,
|
|
11
|
+
// opens the list when the input receives focused (but only if there are
|
|
12
|
+
// items in the list)
|
|
13
|
+
openOnFocus = false,
|
|
14
|
+
// if set to true, it will select an item after blurring
|
|
15
|
+
selectOnBlur = false,
|
|
16
|
+
children,
|
|
17
|
+
as: Comp = 'div',
|
|
18
|
+
innerAs,
|
|
19
|
+
...rest
|
|
20
|
+
} = _ref;
|
|
23
21
|
// We store the values of all the ComboboxOptions on this ref. This makes it
|
|
24
22
|
// possible to perform the keyboard navigation from the input on the list. We
|
|
25
23
|
// manipulate this array through context so that we don't have to enforce a
|
|
26
24
|
// parent/child relationship between ComboboxList and ComboboxOption.
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const optionsRef = useRef({});
|
|
26
|
+
const listScope = useRef(getScope({
|
|
29
27
|
current: null
|
|
30
|
-
}));
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
// Need this to focus it
|
|
31
|
+
const inputRef = useRef(null);
|
|
32
|
+
const popoverRef = useRef(null);
|
|
33
|
+
const buttonRef = useRef(null);
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
var popoverRef = useRef(null);
|
|
34
|
-
var buttonRef = useRef(null); // When <ComboboxInput autocomplete={false} /> we don't want cycle back to
|
|
35
|
+
// When <ComboboxInput autocomplete={false} /> we don't want cycle back to
|
|
35
36
|
// the user's value while navigating (because it's always the user's value),
|
|
36
37
|
// but we need to know this in useKeyDown which is far away from the prop
|
|
37
38
|
// here, so we do something sneaky and write it to this ref on context so we
|
|
38
39
|
// can use it anywhere else 😛. Another new trick for me and I'm excited
|
|
39
40
|
// about this one too!
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var defaultData = {
|
|
41
|
+
const autocompletePropRef = useRef(false);
|
|
42
|
+
const persistSelectionRef = useRef(false);
|
|
43
|
+
const clearOnEscapeRef = useRef(false);
|
|
44
|
+
const listboxIdRef = useRef(undefined);
|
|
45
|
+
const labelIdRef = useRef(undefined);
|
|
46
|
+
const defaultData = {
|
|
47
47
|
// initial state
|
|
48
48
|
state: stateChart.initial,
|
|
49
49
|
// the value the user has typed, we derived this also when the developer is
|
|
@@ -57,39 +57,32 @@ export var Combobox = /*#__PURE__*/forwardRef(function Combobox(_ref, ref) {
|
|
|
57
57
|
// the last submitted action
|
|
58
58
|
lastActionType: INIT
|
|
59
59
|
};
|
|
60
|
-
|
|
61
|
-
var _useReducerMachine = useReducerMachine(stateChart, comboboxReducer, defaultData),
|
|
62
|
-
_useReducerMachine2 = _slicedToArray(_useReducerMachine, 3),
|
|
63
|
-
state = _useReducerMachine2[0],
|
|
64
|
-
data = _useReducerMachine2[1],
|
|
65
|
-
transition = _useReducerMachine2[2];
|
|
66
|
-
|
|
60
|
+
const [state, data, transition] = useReducerMachine(stateChart, comboboxReducer, defaultData);
|
|
67
61
|
listboxIdRef.current = useId();
|
|
68
62
|
labelIdRef.current = useId();
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
89
|
-
}, [data, onSelect, listScope, state, transition, openOnFocus, selectOnBlur]);
|
|
63
|
+
const context = useMemo(() => ({
|
|
64
|
+
data,
|
|
65
|
+
inputRef,
|
|
66
|
+
popoverRef,
|
|
67
|
+
buttonRef,
|
|
68
|
+
onSelect,
|
|
69
|
+
optionsRef,
|
|
70
|
+
listScope,
|
|
71
|
+
state,
|
|
72
|
+
transition,
|
|
73
|
+
listboxIdRef,
|
|
74
|
+
labelIdRef,
|
|
75
|
+
autocompletePropRef,
|
|
76
|
+
persistSelectionRef,
|
|
77
|
+
clearOnEscapeRef,
|
|
78
|
+
isVisible: isVisible(state),
|
|
79
|
+
openOnFocus,
|
|
80
|
+
selectOnBlur
|
|
81
|
+
}), [data, onSelect, listScope, state, transition, openOnFocus, selectOnBlur]);
|
|
90
82
|
return /*#__PURE__*/_jsx(ComboBoxProvider, {
|
|
91
83
|
value: context,
|
|
92
|
-
children: /*#__PURE__*/_jsx(Comp,
|
|
84
|
+
children: /*#__PURE__*/_jsx(Comp, {
|
|
85
|
+
...rest,
|
|
93
86
|
as: innerAs,
|
|
94
87
|
"data-reach-combobox": "",
|
|
95
88
|
ref: ref,
|
|
@@ -98,7 +91,7 @@ export var Combobox = /*#__PURE__*/forwardRef(function Combobox(_ref, ref) {
|
|
|
98
91
|
"aria-owns": listboxIdRef.current,
|
|
99
92
|
"aria-expanded": context.isVisible,
|
|
100
93
|
children: children
|
|
101
|
-
})
|
|
94
|
+
})
|
|
102
95
|
});
|
|
103
96
|
});
|
|
104
97
|
//# sourceMappingURL=Combobox.js.map
|
|
@@ -1 +1 @@
|
|
|
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":"
|
|
1
|
+
{"version":3,"file":"Combobox.js","names":["forwardRef","useRef","useMemo","useId","stateChart","comboboxReducer","isVisible","INIT","ComboBoxProvider","useReducerMachine","getScope","jsx","_jsx","Combobox","_ref","ref","onSelect","openOnFocus","selectOnBlur","children","as","Comp","innerAs","rest","optionsRef","listScope","current","inputRef","popoverRef","buttonRef","autocompletePropRef","persistSelectionRef","clearOnEscapeRef","listboxIdRef","undefined","labelIdRef","defaultData","state","initial","text","item","navigationItem","lastActionType","data","transition","context","value","role"],"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>(undefined);\n\n const labelIdRef = useRef<string | undefined>(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":"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","ignoreList":[]}
|
|
@@ -1,43 +1,37 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["as", "innerAs", "onClick", "onKeyDown"];
|
|
4
1
|
import { forwardRef } from 'react';
|
|
5
2
|
import { useComboBoxContext } from './context';
|
|
6
3
|
import { useKeyDown, IDLE, OPEN_WITH_BUTTON, CLOSE_WITH_BUTTON } from './hooks';
|
|
7
4
|
import { wrapEvent } from '../utils/wrap-event';
|
|
8
5
|
import { assignMultipleRefs } from '../utils/assign-ref';
|
|
9
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var payload = {
|
|
7
|
+
export const ComboboxButton = /*#__PURE__*/forwardRef(function ComboboxButton(_ref, ref) {
|
|
8
|
+
let {
|
|
9
|
+
as: Comp = 'button',
|
|
10
|
+
innerAs,
|
|
11
|
+
onClick,
|
|
12
|
+
onKeyDown,
|
|
13
|
+
...props
|
|
14
|
+
} = _ref;
|
|
15
|
+
const {
|
|
16
|
+
transition,
|
|
17
|
+
data,
|
|
18
|
+
state,
|
|
19
|
+
buttonRef,
|
|
20
|
+
listboxIdRef,
|
|
21
|
+
isVisible
|
|
22
|
+
} = useComboBoxContext();
|
|
23
|
+
const handleKeyDown = useKeyDown();
|
|
24
|
+
const handleClick = () => {
|
|
25
|
+
const payload = {
|
|
30
26
|
item: data.navigationItem
|
|
31
27
|
};
|
|
32
|
-
|
|
33
28
|
if (state === IDLE) {
|
|
34
29
|
transition(OPEN_WITH_BUTTON, payload);
|
|
35
30
|
} else {
|
|
36
31
|
transition(CLOSE_WITH_BUTTON, payload);
|
|
37
32
|
}
|
|
38
33
|
};
|
|
39
|
-
|
|
40
|
-
return /*#__PURE__*/_jsx(Comp, _extends({
|
|
34
|
+
return /*#__PURE__*/_jsx(Comp, {
|
|
41
35
|
as: innerAs,
|
|
42
36
|
"data-reach-combobox-button": "",
|
|
43
37
|
"aria-controls": listboxIdRef.current,
|
|
@@ -45,7 +39,8 @@ export var ComboboxButton = /*#__PURE__*/forwardRef(function ComboboxButton(_ref
|
|
|
45
39
|
"aria-expanded": isVisible,
|
|
46
40
|
ref: assignMultipleRefs(ref, buttonRef),
|
|
47
41
|
onClick: wrapEvent(onClick, handleClick),
|
|
48
|
-
onKeyDown: wrapEvent(onKeyDown, handleKeyDown)
|
|
49
|
-
|
|
42
|
+
onKeyDown: wrapEvent(onKeyDown, handleKeyDown),
|
|
43
|
+
...props
|
|
44
|
+
});
|
|
50
45
|
});
|
|
51
46
|
//# sourceMappingURL=ComboboxButton.js.map
|
|
@@ -1 +1 @@
|
|
|
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, handleKeyDown)}\n {...props}\n />\n );\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ComboboxButton.js","names":["forwardRef","useComboBoxContext","useKeyDown","IDLE","OPEN_WITH_BUTTON","CLOSE_WITH_BUTTON","wrapEvent","assignMultipleRefs","jsx","_jsx","ComboboxButton","_ref","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, handleKeyDown)}\n {...props}\n />\n );\n});\n"],"mappings":"AAOA,SAASA,UAAU,QAAQ,OAAO;AAElC,SAASC,kBAAkB,QAAQ,WAAW;AAC9C,SAASC,UAAU,EAAEC,IAAI,EAAEC,gBAAgB,EAAEC,iBAAiB,QAAQ,SAAS;AAC/E,SAASC,SAAS,QAAQ,qBAAqB;AAC/C,SAASC,kBAAkB,QAAQ,qBAAqB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAWzD,OAAO,MAAMC,cAAc,gBAAGV,UAAU,CAGtC,SAASU,cAAcA,CAAAC,IAAA,EAEvBC,GAAG,EACH;EAAA,IAFA;IAAEC,EAAE,EAAEC,IAAI,GAAG,QAAQ;IAAEC,OAAO;IAAEC,OAAO;IAAEC,SAAS;IAAE,GAAGC;EAAM,CAAC,GAAAP,IAAA;EAG9D,MAAM;IAAEQ,UAAU;IAAEC,IAAI;IAAEC,KAAK;IAAEC,SAAS;IAAEC,YAAY;IAAEC;EAAU,CAAC,GACnEvB,kBAAkB,CAAC,CAAC;EAEtB,MAAMwB,aAAa,GAAGvB,UAAU,CAAC,CAAC;EAElC,MAAMwB,WAAW,GAAGA,CAAA,KAAM;IACxB,MAAMC,OAAO,GAAG;MACdC,IAAI,EAAER,IAAI,CAACS;IACb,CAAC;IAED,IAAIR,KAAK,KAAKlB,IAAI,EAAE;MAClBgB,UAAU,CAACf,gBAAgB,EAAEuB,OAAO,CAAC;IACvC,CAAC,MAAM;MACLR,UAAU,CAACd,iBAAiB,EAAEsB,OAAO,CAAC;IACxC;EACF,CAAC;EAED,oBACElB,IAAA,CAACK,IAAI;IACHD,EAAE,EAAEE,OAAQ;IACZ,8BAA2B,EAAE;IAC7B,iBAAeQ,YAAY,CAACO,OAAQ;IACpC,iBAAc,SAAS;IACvB,iBAAeN,SAAU;IACzBZ,GAAG,EAAEL,kBAAkB,CAACK,GAAG,EAAEU,SAAS,CAAE;IACxCN,OAAO,EAAEV,SAAS,CAACU,OAAO,EAAEU,WAAW,CAAE;IACzCT,SAAS,EAAEX,SAAS,CAACW,SAAS,EAAEQ,aAAa,CAAE;IAAA,GAC3CP;EAAK,CACV,CAAC;AAEN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -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
|