@basic-ui/core 0.0.50 → 0.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/build/cjs/index.js +106 -92
- package/build/cjs/index.js.map +1 -1
- package/build/esm/Accordion/Accordion.d.ts +9 -9
- package/build/esm/Accordion/Accordion.js.map +1 -1
- package/build/esm/Accordion/AccordionBody.d.ts +6 -6
- package/build/esm/Accordion/AccordionBody.js.map +1 -1
- package/build/esm/Accordion/AccordionHeader.d.ts +7 -7
- package/build/esm/Accordion/AccordionHeader.js.map +1 -1
- package/build/esm/Accordion/AccordionItem.d.ts +9 -9
- package/build/esm/Accordion/AccordionItem.js.map +1 -1
- package/build/esm/Accordion/context.d.ts +19 -19
- package/build/esm/Accordion/context.js.map +1 -1
- package/build/esm/Accordion/index.d.ts +4 -4
- package/build/esm/Accordion/index.js.map +1 -1
- package/build/esm/Accordion/scopeQuery.d.ts +2 -2
- package/build/esm/Accordion/scopeQuery.js.map +1 -1
- package/build/esm/CheckBox/CheckBox.d.ts +7 -7
- package/build/esm/CheckBox/CheckBox.js.map +1 -1
- package/build/esm/CheckBox/index.d.ts +1 -1
- package/build/esm/CheckBox/index.js.map +1 -1
- package/build/esm/ComboBox/Combobox.d.ts +18 -18
- package/build/esm/ComboBox/Combobox.js.map +1 -1
- package/build/esm/ComboBox/ComboboxButton.d.ts +9 -9
- package/build/esm/ComboBox/ComboboxButton.js.map +1 -1
- package/build/esm/ComboBox/ComboboxInput.d.ts +17 -17
- package/build/esm/ComboBox/ComboboxInput.js.map +1 -1
- package/build/esm/ComboBox/ComboboxLabel.d.ts +7 -7
- package/build/esm/ComboBox/ComboboxLabel.js.map +1 -1
- package/build/esm/ComboBox/ComboboxList.d.ts +8 -8
- package/build/esm/ComboBox/ComboboxList.js.map +1 -1
- package/build/esm/ComboBox/ComboboxOption.d.ts +11 -11
- package/build/esm/ComboBox/ComboboxOption.js.map +1 -1
- package/build/esm/ComboBox/ComboboxPopover.d.ts +9 -9
- package/build/esm/ComboBox/ComboboxPopover.js.map +1 -1
- package/build/esm/ComboBox/cities.d.ts +5 -5
- package/build/esm/ComboBox/cities.js.map +1 -1
- package/build/esm/ComboBox/context.d.ts +30 -30
- package/build/esm/ComboBox/context.js.map +1 -1
- package/build/esm/ComboBox/hooks.d.ts +37 -37
- package/build/esm/ComboBox/hooks.js.map +1 -1
- package/build/esm/ComboBox/index.d.ts +8 -8
- package/build/esm/ComboBox/index.js.map +1 -1
- package/build/esm/ComboBox/makeHash.d.ts +1 -1
- package/build/esm/ComboBox/makeHash.js.map +1 -1
- package/build/esm/ComboBox/scopeQuery.d.ts +1 -1
- package/build/esm/ComboBox/scopeQuery.js.map +1 -1
- package/build/esm/FocusLock/FocusLock.d.ts +9 -9
- package/build/esm/FocusLock/FocusLock.js.map +1 -1
- package/build/esm/FocusLock/index.d.ts +1 -1
- package/build/esm/FocusLock/index.js.map +1 -1
- package/build/esm/FocusLock/tabUtils.d.ts +3 -3
- package/build/esm/FocusLock/tabUtils.js.map +1 -1
- package/build/esm/FocusLock/useFocusLock.d.ts +7 -7
- package/build/esm/FocusLock/useFocusLock.js.map +1 -1
- package/build/esm/List/List.d.ts +7 -7
- package/build/esm/List/List.js.map +1 -1
- package/build/esm/List/ListItem.d.ts +7 -7
- package/build/esm/List/ListItem.js.map +1 -1
- package/build/esm/List/context.d.ts +4 -4
- package/build/esm/List/context.js.map +1 -1
- package/build/esm/List/index.d.ts +2 -2
- package/build/esm/List/index.js.map +1 -1
- package/build/esm/Menu/ContextMenuTrigger.d.ts +11 -11
- package/build/esm/Menu/ContextMenuTrigger.js.map +1 -1
- package/build/esm/Menu/Menu.d.ts +10 -10
- package/build/esm/Menu/Menu.js.map +1 -1
- package/build/esm/Menu/MenuButton.d.ts +11 -11
- package/build/esm/Menu/MenuButton.js.map +1 -1
- package/build/esm/Menu/MenuItem.d.ts +8 -8
- package/build/esm/Menu/MenuItem.js +1 -0
- package/build/esm/Menu/MenuItem.js.map +1 -1
- package/build/esm/Menu/MenuList.d.ts +7 -7
- package/build/esm/Menu/MenuList.js +17 -4
- package/build/esm/Menu/MenuList.js.map +1 -1
- package/build/esm/Menu/MenuPopover.d.ts +8 -8
- package/build/esm/Menu/MenuPopover.js.map +1 -1
- package/build/esm/Menu/context.d.ts +25 -25
- package/build/esm/Menu/context.js.map +1 -1
- package/build/esm/Menu/fixtures/countryList.d.ts +1 -1
- package/build/esm/Menu/fixtures/countryList.js.map +1 -1
- package/build/esm/Menu/index.d.ts +6 -6
- package/build/esm/Menu/index.js.map +1 -1
- package/build/esm/Menu/scope.d.ts +1 -1
- package/build/esm/Menu/scope.js.map +1 -1
- package/build/esm/Modal/Modal.d.ts +9 -9
- package/build/esm/Modal/Modal.js.map +1 -1
- package/build/esm/Modal/ModalBackdrop.d.ts +10 -10
- package/build/esm/Modal/ModalBackdrop.js.map +1 -1
- package/build/esm/Modal/index.d.ts +2 -2
- package/build/esm/Modal/index.js.map +1 -1
- package/build/esm/Popper/Popper.d.ts +35 -35
- package/build/esm/Popper/Popper.js.map +1 -1
- package/build/esm/Popper/PopperArrow.d.ts +6 -6
- package/build/esm/Popper/PopperArrow.js.map +1 -1
- package/build/esm/Popper/context.d.ts +6 -6
- package/build/esm/Popper/context.js.map +1 -1
- package/build/esm/Popper/index.d.ts +3 -3
- package/build/esm/Popper/index.js.map +1 -1
- package/build/esm/Portal/Portal.d.ts +6 -6
- package/build/esm/Portal/Portal.js.map +1 -1
- package/build/esm/Portal/index.d.ts +1 -1
- package/build/esm/Portal/index.js.map +1 -1
- package/build/esm/RadioButton/RadioButton.d.ts +10 -10
- package/build/esm/RadioButton/RadioButton.js.map +1 -1
- package/build/esm/RadioButton/RadioGroup.d.ts +12 -12
- package/build/esm/RadioButton/RadioGroup.js.map +1 -1
- package/build/esm/RadioButton/context.d.ts +9 -9
- package/build/esm/RadioButton/context.js.map +1 -1
- package/build/esm/RadioButton/index.d.ts +2 -2
- package/build/esm/RadioButton/index.js.map +1 -1
- package/build/esm/SkipNav/SkipNav.d.ts +7 -7
- package/build/esm/SkipNav/SkipNav.js.map +1 -1
- package/build/esm/SkipNav/index.d.ts +1 -1
- package/build/esm/SkipNav/index.js.map +1 -1
- package/build/esm/Slider/Slider.d.ts +197 -197
- package/build/esm/Slider/Slider.js +82 -82
- package/build/esm/Slider/Slider.js.map +1 -1
- package/build/esm/Slider/index.d.ts +1 -1
- package/build/esm/Slider/index.js.map +1 -1
- package/build/esm/Spinner/Spinner.d.ts +12 -12
- package/build/esm/Spinner/Spinner.js.map +1 -1
- package/build/esm/Spinner/SpinnerButton.d.ts +8 -8
- package/build/esm/Spinner/SpinnerButton.js.map +1 -1
- package/build/esm/Spinner/context.d.ts +12 -12
- package/build/esm/Spinner/context.js.map +1 -1
- package/build/esm/Spinner/index.d.ts +2 -2
- package/build/esm/Spinner/index.js.map +1 -1
- package/build/esm/Tabs/Tab.d.ts +7 -7
- package/build/esm/Tabs/Tab.js.map +1 -1
- package/build/esm/Tabs/TabList.d.ts +9 -9
- package/build/esm/Tabs/TabList.js.map +1 -1
- package/build/esm/Tabs/TabPanel.d.ts +8 -8
- package/build/esm/Tabs/TabPanel.js.map +1 -1
- package/build/esm/Tabs/TabPanels.d.ts +8 -8
- package/build/esm/Tabs/TabPanels.js.map +1 -1
- package/build/esm/Tabs/Tabs.d.ts +10 -10
- package/build/esm/Tabs/Tabs.js.map +1 -1
- package/build/esm/Tabs/context.d.ts +17 -17
- package/build/esm/Tabs/context.js.map +1 -1
- package/build/esm/Tabs/index.d.ts +5 -5
- package/build/esm/Tabs/index.js.map +1 -1
- package/build/esm/Tabs/scopeQuery.d.ts +1 -1
- package/build/esm/Tabs/scopeQuery.js.map +1 -1
- package/build/esm/Tooltip/Tooltip.d.ts +10 -10
- package/build/esm/Tooltip/Tooltip.js.map +1 -1
- package/build/esm/Tooltip/index.d.ts +1 -1
- package/build/esm/Tooltip/index.js.map +1 -1
- package/build/esm/Tooltip/stateMachine.d.ts +28 -28
- package/build/esm/Tooltip/stateMachine.js.map +1 -1
- package/build/esm/Tooltip/useTooltip.d.ts +10 -10
- package/build/esm/Tooltip/useTooltip.js.map +1 -1
- package/build/esm/hooks/index.d.ts +13 -13
- package/build/esm/hooks/index.js.map +1 -1
- package/build/esm/hooks/useAutoFocus.d.ts +2 -2
- package/build/esm/hooks/useAutoFocus.js.map +1 -1
- package/build/esm/hooks/useChildrenCounter.d.ts +7 -7
- package/build/esm/hooks/useChildrenCounter.js.map +1 -1
- package/build/esm/hooks/useControlledState.d.ts +3 -3
- package/build/esm/hooks/useControlledState.js +1 -1
- package/build/esm/hooks/useControlledState.js.map +1 -1
- package/build/esm/hooks/useFocusReturn.d.ts +2 -2
- package/build/esm/hooks/useFocusReturn.js.map +1 -1
- package/build/esm/hooks/useFocusState.d.ts +11 -11
- package/build/esm/hooks/useFocusState.js.map +1 -1
- package/build/esm/hooks/useGestureHandlers.d.ts +52 -52
- package/build/esm/hooks/useGestureHandlers.js.map +1 -1
- package/build/esm/hooks/useMeasure.d.ts +7 -7
- package/build/esm/hooks/useMeasure.js.map +1 -1
- package/build/esm/hooks/useOnClickOutside.d.ts +2 -2
- package/build/esm/hooks/useOnClickOutside.js.map +1 -1
- package/build/esm/hooks/useOnKeyDown.d.ts +1 -1
- package/build/esm/hooks/useOnKeyDown.js.map +1 -1
- package/build/esm/hooks/useReducerMachine.d.ts +24 -24
- package/build/esm/hooks/useReducerMachine.js.map +1 -1
- package/build/esm/hooks/useRemoveBodyScroll.d.ts +2 -2
- package/build/esm/hooks/useRemoveBodyScroll.js.map +1 -1
- package/build/esm/hooks/useScope.d.ts +11 -11
- package/build/esm/hooks/useScope.js.map +1 -1
- package/build/esm/hooks/useThrottle.d.ts +1 -1
- package/build/esm/hooks/useThrottle.js.map +1 -1
- package/build/esm/index.d.ts +15 -15
- package/build/esm/index.js.map +1 -1
- package/build/esm/utils/assign-ref.d.ts +3 -3
- package/build/esm/utils/assign-ref.js.map +1 -1
- package/build/esm/utils/can-use-dom.d.ts +1 -1
- package/build/esm/utils/can-use-dom.js.map +1 -1
- package/build/esm/utils/clamp.d.ts +1 -1
- package/build/esm/utils/clamp.js.map +1 -1
- package/build/esm/utils/context.d.ts +7 -7
- package/build/esm/utils/context.js.map +1 -1
- package/build/esm/utils/create-subscription.d.ts +4 -4
- package/build/esm/utils/create-subscription.js.map +1 -1
- package/build/esm/utils/get-circular-index.d.ts +1 -1
- package/build/esm/utils/get-circular-index.js.map +1 -1
- package/build/esm/utils/index.d.ts +10 -10
- package/build/esm/utils/index.js.map +1 -1
- package/build/esm/utils/is-right-click.d.ts +6 -6
- package/build/esm/utils/is-right-click.js +4 -4
- package/build/esm/utils/is-right-click.js.map +1 -1
- package/build/esm/utils/owner-document.d.ts +7 -7
- package/build/esm/utils/owner-document.js +5 -5
- package/build/esm/utils/owner-document.js.map +1 -1
- package/build/esm/utils/polymorphic.d.ts +39 -39
- package/build/esm/utils/polymorphic.js.map +1 -1
- package/build/esm/utils/rubber-band-clamp.d.ts +2 -2
- package/build/esm/utils/rubber-band-clamp.js.map +1 -1
- package/build/esm/utils/use-stable-callback.d.ts +16 -16
- package/build/esm/utils/use-stable-callback.js +16 -16
- package/build/esm/utils/use-stable-callback.js.map +1 -1
- package/build/esm/utils/wrap-event.d.ts +3 -3
- package/build/esm/utils/wrap-event.js.map +1 -1
- package/build/tsconfig-build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/Accordion/Accordion.story.tsx +74 -74
- package/src/Accordion/Accordion.tsx +59 -59
- package/src/Accordion/AccordionBody.tsx +52 -52
- package/src/Accordion/AccordionHeader.tsx +167 -167
- package/src/Accordion/AccordionItem.tsx +50 -50
- package/src/Accordion/context.ts +37 -37
- package/src/Accordion/index.ts +4 -4
- package/src/Accordion/scopeQuery.ts +7 -7
- package/src/Accordion/styles.css +21 -21
- package/src/CheckBox/CheckBox.tsx +41 -41
- package/src/CheckBox/index.ts +1 -1
- package/src/ComboBox/ComboBox.story.tsx +120 -120
- package/src/ComboBox/Combobox.tsx +148 -148
- package/src/ComboBox/ComboboxButton.tsx +61 -61
- package/src/ComboBox/ComboboxInput.tsx +187 -187
- package/src/ComboBox/ComboboxLabel.tsx +33 -33
- package/src/ComboBox/ComboboxList.tsx +47 -47
- package/src/ComboBox/ComboboxOption.tsx +111 -111
- package/src/ComboBox/ComboboxPopover.tsx +64 -64
- package/src/ComboBox/cities.ts +23194 -23194
- package/src/ComboBox/context.ts +35 -35
- package/src/ComboBox/hooks.tsx +451 -451
- package/src/ComboBox/index.ts +8 -8
- package/src/ComboBox/makeHash.ts +19 -19
- package/src/ComboBox/scopeQuery.ts +6 -6
- package/src/ComboBox/styles.css +32 -32
- package/src/FocusLock/FocusLock.tsx +66 -66
- package/src/FocusLock/index.ts +1 -1
- package/src/FocusLock/tabUtils.ts +40 -40
- package/src/FocusLock/useFocusLock.ts +56 -56
- package/src/List/List.story.tsx +18 -18
- package/src/List/List.tsx +17 -17
- package/src/List/ListItem.tsx +23 -23
- package/src/List/context.ts +19 -19
- package/src/List/index.ts +2 -2
- package/src/Menu/ContextMenu.story.tsx +73 -73
- package/src/Menu/ContextMenuTrigger.tsx +76 -76
- package/src/Menu/Menu.story.tsx +160 -160
- package/src/Menu/Menu.tsx +83 -83
- package/src/Menu/MenuButton.tsx +83 -83
- package/src/Menu/MenuComplex.story.tsx +58 -58
- package/src/Menu/MenuItem.tsx +88 -87
- package/src/Menu/MenuList.tsx +254 -243
- package/src/Menu/MenuPopover.tsx +35 -35
- package/src/Menu/context.ts +44 -44
- package/src/Menu/fixtures/countryList.ts +198 -198
- package/src/Menu/index.ts +6 -6
- package/src/Menu/scope.ts +7 -7
- package/src/Menu/styles.css +42 -42
- package/src/Modal/Modal.story.tsx +258 -258
- package/src/Modal/Modal.tsx +48 -48
- package/src/Modal/ModalBackdrop.tsx +78 -78
- package/src/Modal/NavDrawer.story.tsx +158 -158
- package/src/Modal/index.ts +2 -2
- package/src/Modal/styles.css +46 -46
- package/src/Popper/Popper.story.tsx +263 -263
- package/src/Popper/Popper.tsx +154 -154
- package/src/Popper/PopperArrow.tsx +35 -35
- package/src/Popper/context.ts +10 -10
- package/src/Popper/index.ts +3 -3
- package/src/Popper/styles.css +60 -60
- package/src/Portal/Portal.tsx +20 -20
- package/src/Portal/index.ts +1 -1
- package/src/RadioButton/RadioButton.story.tsx +77 -77
- package/src/RadioButton/RadioButton.tsx +55 -55
- package/src/RadioButton/RadioGroup.tsx +60 -60
- package/src/RadioButton/context.ts +17 -17
- package/src/RadioButton/index.ts +2 -2
- package/src/SkipNav/SkipNav.tsx +16 -16
- package/src/SkipNav/index.tsx +1 -1
- package/src/Slider/Slider.story.tsx +45 -45
- package/src/Slider/Slider.tsx +1120 -1120
- package/src/Slider/index.ts +1 -1
- package/src/Slider/styles.css +131 -131
- package/src/Spinner/Spinner.story.tsx +31 -31
- package/src/Spinner/Spinner.tsx +117 -117
- package/src/Spinner/SpinnerButton.tsx +54 -54
- package/src/Spinner/context.ts +20 -20
- package/src/Spinner/index.ts +2 -2
- package/src/Spinner/styles.css +23 -23
- package/src/Tabs/Tab.story.tsx +80 -80
- package/src/Tabs/Tab.tsx +136 -136
- package/src/Tabs/TabList.tsx +71 -71
- package/src/Tabs/TabPanel.tsx +53 -53
- package/src/Tabs/TabPanels.tsx +30 -30
- package/src/Tabs/Tabs.tsx +46 -46
- package/src/Tabs/context.ts +30 -30
- package/src/Tabs/index.tsx +5 -5
- package/src/Tabs/scopeQuery.ts +6 -6
- package/src/Tooltip/Tooltip.story.tsx +61 -61
- package/src/Tooltip/Tooltip.tsx +50 -50
- package/src/Tooltip/index.ts +1 -1
- package/src/Tooltip/stateMachine.ts +192 -192
- package/src/Tooltip/styles.css +17 -17
- package/src/Tooltip/useTooltip.ts +136 -136
- package/src/hooks/index.ts +13 -13
- package/src/hooks/useAutoFocus.ts +22 -22
- package/src/hooks/useChildrenCounter.ts +51 -51
- package/src/hooks/useControlledState.ts +3 -3
- package/src/hooks/useFocusReturn.ts +43 -43
- package/src/hooks/useFocusState.ts +30 -30
- package/src/hooks/useGestureHandlers.ts +286 -286
- package/src/hooks/useMeasure.ts +33 -33
- package/src/hooks/useOnClickOutside.ts +32 -32
- package/src/hooks/useOnKeyDown.ts +19 -19
- package/src/hooks/useReducerMachine.ts +60 -60
- package/src/hooks/useRemoveBodyScroll.ts +39 -39
- package/src/hooks/useScope.ts +52 -52
- package/src/hooks/useThrottle.ts +19 -19
- package/src/index.ts +20 -20
- package/src/utils/assign-ref.ts +27 -27
- package/src/utils/can-use-dom.ts +7 -7
- package/src/utils/clamp.ts +3 -3
- package/src/utils/context.tsx +48 -48
- package/src/utils/create-subscription.ts +16 -16
- package/src/utils/get-circular-index.ts +7 -7
- package/src/utils/index.ts +10 -10
- package/src/utils/is-right-click.ts +14 -14
- package/src/utils/owner-document.ts +13 -13
- package/src/utils/polymorphic.ts +78 -78
- package/src/utils/rubber-band-clamp.ts +25 -25
- package/src/utils/use-stable-callback.ts +58 -58
- package/src/utils/wrap-event.ts +22 -22
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ElementType, HTMLAttributes, KeyboardEvent, MouseEvent, ReactNode } from 'react';
|
|
2
|
-
export interface AccordionProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
children?: ReactNode;
|
|
6
|
-
expandedIndex?: number;
|
|
7
|
-
onChange?: (e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>, index: number) => void;
|
|
8
|
-
}
|
|
9
|
-
export declare const Accordion: import("react").ForwardRefExoticComponent<AccordionProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
1
|
+
import type { ElementType, HTMLAttributes, KeyboardEvent, MouseEvent, ReactNode } from 'react';
|
|
2
|
+
export interface AccordionProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
expandedIndex?: number;
|
|
7
|
+
onChange?: (e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>, index: number) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const Accordion: import("react").ForwardRefExoticComponent<AccordionProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.js","names":["forwardRef","useRef","useState","AccordionProvider","useScope","assignMultipleRefs","Accordion","props","forwardedRef","as","Comp","expandedIndex","onChange","otherProps","childrenHeaderHasFocus","setChildrenHeaderHasFocus","ref","scope","contextValue"],"sources":["../../../src/Accordion/Accordion.tsx"],"sourcesContent":["import type {\n ElementType,\n HTMLAttributes,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n} from 'react';\nimport { forwardRef, useRef, useState } from 'react';\n\nimport type { AccordionContextProps } from './context';\nimport { AccordionProvider } from './context';\nimport { useScope } from '../hooks';\nimport { assignMultipleRefs } from '../utils';\n\nexport interface AccordionProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n expandedIndex?: number;\n onChange?: (\n e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>,\n index: number\n ) => void;\n}\n\nexport const Accordion = forwardRef<HTMLDivElement, AccordionProps>(\n function Accordion(props, forwardedRef) {\n const {\n as: Comp = 'div',\n expandedIndex = -1,\n onChange,\n ...otherProps\n } = props;\n const [childrenHeaderHasFocus, setChildrenHeaderHasFocus] = useState(false);\n const ref = useRef<HTMLDivElement>();\n\n const scope = useScope(ref);\n\n const contextValue: AccordionContextProps = {\n childrenHeaderHasFocus,\n setChildrenHeaderHasFocus,\n scope,\n expandedIndex,\n onChange,\n };\n\n return (\n <AccordionProvider value={contextValue}>\n <Comp\n ref={assignMultipleRefs(forwardedRef, ref)}\n {...otherProps}\n data-accordion-root=\"\"\n data-children-has-focus={childrenHeaderHasFocus}\n />\n </AccordionProvider>\n );\n }\n);\n"],"mappings":";;;;AAOA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,QAA7B,QAA6C,OAA7C;AAGA,SAASC,iBAAT,QAAkC,WAAlC;AACA,SAASC,QAAT,QAAyB,UAAzB;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAcA,OAAO,IAAMC,SAAS,gBAAGN,UAAU,CACjC,SAASM,SAAT,CAAmBC,KAAnB,EAA0BC,YAA1B,EAAwC;EACtC,gBAKID,KALJ,CACEE,EADF;EAAA,IACMC,IADN,0BACa,KADb;EAAA,2BAKIH,KALJ,CAEEI,aAFF;EAAA,IAEEA,aAFF,qCAEkB,CAAC,CAFnB;EAAA,IAGEC,QAHF,GAKIL,KALJ,CAGEK,QAHF;EAAA,IAIKC,UAJL,4BAKIN,KALJ;;EAMA,gBAA4DL,QAAQ,CAAC,KAAD,CAApE;EAAA;EAAA,IAAOY,sBAAP;EAAA,IAA+BC,yBAA/B;;EACA,IAAMC,GAAG,GAAGf,MAAM,EAAlB;EAEA,IAAMgB,KAAK,GAAGb,QAAQ,CAACY,GAAD,CAAtB;EAEA,IAAME,YAAmC,GAAG;IAC1CJ,sBAAsB,EAAtBA,sBAD0C;IAE1CC,yBAAyB,EAAzBA,yBAF0C;IAG1CE,KAAK,EAALA,KAH0C;IAI1CN,aAAa,EAAbA,aAJ0C;IAK1CC,QAAQ,EAARA;EAL0C,CAA5C;EAQA,oBACE,KAAC,iBAAD;IAAmB,KAAK,EAAEM,YAA1B;IAAA,uBACE,KAAC,IAAD;MACE,GAAG,EAAEb,kBAAkB,CAACG,YAAD,EAAeQ,GAAf;IADzB,GAEMH,UAFN;MAGE,uBAAoB,EAHtB;MAIE,2BAAyBC;IAJ3B;EADF,EADF;AAUD,CA/BgC,CAA5B"}
|
|
1
|
+
{"version":3,"file":"Accordion.js","names":["forwardRef","useRef","useState","AccordionProvider","useScope","assignMultipleRefs","Accordion","props","forwardedRef","as","Comp","expandedIndex","onChange","otherProps","childrenHeaderHasFocus","setChildrenHeaderHasFocus","ref","scope","contextValue"],"sources":["../../../src/Accordion/Accordion.tsx"],"sourcesContent":["import type {\r\n ElementType,\r\n HTMLAttributes,\r\n KeyboardEvent,\r\n MouseEvent,\r\n ReactNode,\r\n} from 'react';\r\nimport { forwardRef, useRef, useState } from 'react';\r\n\r\nimport type { AccordionContextProps } from './context';\r\nimport { AccordionProvider } from './context';\r\nimport { useScope } from '../hooks';\r\nimport { assignMultipleRefs } from '../utils';\r\n\r\nexport interface AccordionProps\r\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {\r\n as?: ElementType<any>;\r\n innerAs?: ElementType<any>;\r\n children?: ReactNode;\r\n expandedIndex?: number;\r\n onChange?: (\r\n e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>,\r\n index: number\r\n ) => void;\r\n}\r\n\r\nexport const Accordion = forwardRef<HTMLDivElement, AccordionProps>(\r\n function Accordion(props, forwardedRef) {\r\n const {\r\n as: Comp = 'div',\r\n expandedIndex = -1,\r\n onChange,\r\n ...otherProps\r\n } = props;\r\n const [childrenHeaderHasFocus, setChildrenHeaderHasFocus] = useState(false);\r\n const ref = useRef<HTMLDivElement>();\r\n\r\n const scope = useScope(ref);\r\n\r\n const contextValue: AccordionContextProps = {\r\n childrenHeaderHasFocus,\r\n setChildrenHeaderHasFocus,\r\n scope,\r\n expandedIndex,\r\n onChange,\r\n };\r\n\r\n return (\r\n <AccordionProvider value={contextValue}>\r\n <Comp\r\n ref={assignMultipleRefs(forwardedRef, ref)}\r\n {...otherProps}\r\n data-accordion-root=\"\"\r\n data-children-has-focus={childrenHeaderHasFocus}\r\n />\r\n </AccordionProvider>\r\n );\r\n }\r\n);\r\n"],"mappings":";;;;AAOA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,QAA7B,QAA6C,OAA7C;AAGA,SAASC,iBAAT,QAAkC,WAAlC;AACA,SAASC,QAAT,QAAyB,UAAzB;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAcA,OAAO,IAAMC,SAAS,gBAAGN,UAAU,CACjC,SAASM,SAAT,CAAmBC,KAAnB,EAA0BC,YAA1B,EAAwC;EACtC,gBAKID,KALJ,CACEE,EADF;EAAA,IACMC,IADN,0BACa,KADb;EAAA,2BAKIH,KALJ,CAEEI,aAFF;EAAA,IAEEA,aAFF,qCAEkB,CAAC,CAFnB;EAAA,IAGEC,QAHF,GAKIL,KALJ,CAGEK,QAHF;EAAA,IAIKC,UAJL,4BAKIN,KALJ;;EAMA,gBAA4DL,QAAQ,CAAC,KAAD,CAApE;EAAA;EAAA,IAAOY,sBAAP;EAAA,IAA+BC,yBAA/B;;EACA,IAAMC,GAAG,GAAGf,MAAM,EAAlB;EAEA,IAAMgB,KAAK,GAAGb,QAAQ,CAACY,GAAD,CAAtB;EAEA,IAAME,YAAmC,GAAG;IAC1CJ,sBAAsB,EAAtBA,sBAD0C;IAE1CC,yBAAyB,EAAzBA,yBAF0C;IAG1CE,KAAK,EAALA,KAH0C;IAI1CN,aAAa,EAAbA,aAJ0C;IAK1CC,QAAQ,EAARA;EAL0C,CAA5C;EAQA,oBACE,KAAC,iBAAD;IAAmB,KAAK,EAAEM,YAA1B;IAAA,uBACE,KAAC,IAAD;MACE,GAAG,EAAEb,kBAAkB,CAACG,YAAD,EAAeQ,GAAf;IADzB,GAEMH,UAFN;MAGE,uBAAoB,EAHtB;MAIE,2BAAyBC;IAJ3B;EADF,EADF;AAUD,CA/BgC,CAA5B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { HTMLAttributes, ElementType } from 'react';
|
|
2
|
-
export interface AccordionBodyProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
}
|
|
6
|
-
export declare const AccordionBody: import("react").ForwardRefExoticComponent<AccordionBodyProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
1
|
+
import type { HTMLAttributes, ElementType } from 'react';
|
|
2
|
+
export interface AccordionBodyProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
}
|
|
6
|
+
export declare const AccordionBody: import("react").ForwardRefExoticComponent<AccordionBodyProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1 @@
|
|
|
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,QAArB,EAA+BC,SAA/B,EAA0CC,MAA1C,QAAwD,OAAxD;AAEA,SAASC,uBAAT,EAAkCC,mBAAlC,QAA6D,WAA7D;AACA,SAASC,cAAc,IAAIC,UAA3B,QAA6C,cAA7C;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAOA,OAAO,IAAMC,aAAa,gBAAGT,UAAU,CACrC,SAASS,aAAT,CAAuBC,KAAvB,EAA8BC,YAA9B,EAA4C;EAC1C,gBAA4CD,KAA5C,CAAQE,EAAR;EAAA,IAAYC,IAAZ,0BAAmB,KAAnB;EAAA,IAA6BC,UAA7B,4BAA4CJ,KAA5C;;EACA,IAAMK,oBAAoB,GAAGX,uBAAuB,EAApD;EACA,IAAMY,gBAAgB,GAAGX,mBAAmB,EAA5C;EACA,IAAMY,GAAG,GAAGd,MAAM,EAAlB;;EACA,gBAA0BF,QAAQ,EAAlC;EAAA;EAAA,IAAOiB,KAAP;EAAA,IAAcC,QAAd;;EAEA,IAAI,CAACJ,oBAAL,EAA2B;IACzB,MAAM,IAAIK,KAAJ,CAAU,wCAAV,CAAN;EACD;;EAEDlB,SAAS,CAAC,YAAM;IACd,IAAIc,gBAAJ,EAAsB;MACpB,IAAMK,UAAU,GACdL,gBAAgB,CAACM,KAAjB,CAAuBC,OAAvB,CAA+BC,aAA/B,CAA6CjB,UAA7C,CADF;;MAGA,IAAMW,MAAK,GAAGG,UAAU,CAACI,SAAX,CAAqB,UAACC,CAAD;QAAA,OAAOA,CAAC,KAAKT,GAAG,CAACM,OAAjB;MAAA,CAArB,CAAd;;MACAJ,QAAQ,CAACD,MAAD,CAAR;IACD;EACF,CARQ,EAQN,CAACF,gBAAD,CARM,CAAT;EAUA,IAAMW,QAAQ,GAAGC,OAAO,CACtBb,oBAAoB,CAACY,QAArB,IACGX,gBAAgB,IAAIA,gBAAgB,CAACa,aAAjB,KAAmCX,KAFpC,CAAxB;EAKA,oBACE,KAAC,IAAD;IACE,GAAG,EAAEV,kBAAkB,CAACG,YAAD,EAAeM,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"}
|
|
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';\r\nimport { forwardRef, useState, useEffect, useRef } from 'react';\r\n\r\nimport { useAccordionItemContext, useAccordionContext } from './context';\r\nimport { bodyScopeQuery as scopeQuery } from './scopeQuery';\r\nimport { assignMultipleRefs } from '../utils';\r\n\r\nexport interface AccordionBodyProps extends HTMLAttributes<HTMLDivElement> {\r\n as?: ElementType<any>;\r\n innerAs?: ElementType<any>;\r\n}\r\n\r\nexport const AccordionBody = forwardRef<HTMLDivElement, AccordionBodyProps>(\r\n function AccordionBody(props, forwardedRef) {\r\n const { as: Comp = 'div', ...otherProps } = props;\r\n const accordionItemContext = useAccordionItemContext();\r\n const accordionContext = useAccordionContext();\r\n const ref = useRef<HTMLDivElement>();\r\n const [index, setIndex] = useState<number>();\r\n\r\n if (!accordionItemContext) {\r\n throw new Error('Missing parent <Accordion /> component');\r\n }\r\n\r\n useEffect(() => {\r\n if (accordionContext) {\r\n const allHeaders =\r\n accordionContext.scope.current.queryAllNodes(scopeQuery);\r\n\r\n const index = allHeaders.findIndex((e) => e === ref.current);\r\n setIndex(index);\r\n }\r\n }, [accordionContext]);\r\n\r\n const expanded = Boolean(\r\n accordionItemContext.expanded ||\r\n (accordionContext && accordionContext.expandedIndex === index)\r\n );\r\n\r\n return (\r\n <Comp\r\n ref={assignMultipleRefs(forwardedRef, ref)}\r\n {...otherProps}\r\n aria-labelledby={accordionItemContext.headerId}\r\n id={accordionItemContext.bodyId}\r\n role=\"region\"\r\n data-accordion-body=\"\"\r\n hidden={expanded ? undefined : 'hidden'}\r\n />\r\n );\r\n }\r\n);\r\n"],"mappings":";;;;AACA,SAASA,UAAT,EAAqBC,QAArB,EAA+BC,SAA/B,EAA0CC,MAA1C,QAAwD,OAAxD;AAEA,SAASC,uBAAT,EAAkCC,mBAAlC,QAA6D,WAA7D;AACA,SAASC,cAAc,IAAIC,UAA3B,QAA6C,cAA7C;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAOA,OAAO,IAAMC,aAAa,gBAAGT,UAAU,CACrC,SAASS,aAAT,CAAuBC,KAAvB,EAA8BC,YAA9B,EAA4C;EAC1C,gBAA4CD,KAA5C,CAAQE,EAAR;EAAA,IAAYC,IAAZ,0BAAmB,KAAnB;EAAA,IAA6BC,UAA7B,4BAA4CJ,KAA5C;;EACA,IAAMK,oBAAoB,GAAGX,uBAAuB,EAApD;EACA,IAAMY,gBAAgB,GAAGX,mBAAmB,EAA5C;EACA,IAAMY,GAAG,GAAGd,MAAM,EAAlB;;EACA,gBAA0BF,QAAQ,EAAlC;EAAA;EAAA,IAAOiB,KAAP;EAAA,IAAcC,QAAd;;EAEA,IAAI,CAACJ,oBAAL,EAA2B;IACzB,MAAM,IAAIK,KAAJ,CAAU,wCAAV,CAAN;EACD;;EAEDlB,SAAS,CAAC,YAAM;IACd,IAAIc,gBAAJ,EAAsB;MACpB,IAAMK,UAAU,GACdL,gBAAgB,CAACM,KAAjB,CAAuBC,OAAvB,CAA+BC,aAA/B,CAA6CjB,UAA7C,CADF;;MAGA,IAAMW,MAAK,GAAGG,UAAU,CAACI,SAAX,CAAqB,UAACC,CAAD;QAAA,OAAOA,CAAC,KAAKT,GAAG,CAACM,OAAjB;MAAA,CAArB,CAAd;;MACAJ,QAAQ,CAACD,MAAD,CAAR;IACD;EACF,CARQ,EAQN,CAACF,gBAAD,CARM,CAAT;EAUA,IAAMW,QAAQ,GAAGC,OAAO,CACtBb,oBAAoB,CAACY,QAArB,IACGX,gBAAgB,IAAIA,gBAAgB,CAACa,aAAjB,KAAmCX,KAFpC,CAAxB;EAKA,oBACE,KAAC,IAAD;IACE,GAAG,EAAEV,kBAAkB,CAACG,YAAD,EAAeM,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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { HTMLAttributes, ElementType, ReactNode } from 'react';
|
|
2
|
-
export interface AccordionHeaderProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
children?: ReactNode;
|
|
6
|
-
}
|
|
7
|
-
export declare const AccordionHeader: import("react").ForwardRefExoticComponent<AccordionHeaderProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
1
|
+
import type { HTMLAttributes, ElementType, ReactNode } from 'react';
|
|
2
|
+
export interface AccordionHeaderProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const AccordionHeader: import("react").ForwardRefExoticComponent<AccordionHeaderProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1 @@
|
|
|
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,IACMC,IADN,0BACa,KADb;EAAA,IAEEC,SAFF,GAOIJ,KAPJ,CAEEI,SAFF;EAAA,IAGWC,WAHX,GAOIL,KAPJ,CAGEM,OAHF;EAAA,IAIEC,OAJF,GAOIP,KAPJ,CAIEO,OAJF;EAAA,IAKEC,MALF,GAOIR,KAPJ,CAKEQ,MALF;EAAA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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"}
|
|
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 {\r\n HTMLAttributes,\r\n ElementType,\r\n ReactNode,\r\n MouseEvent,\r\n KeyboardEvent,\r\n FocusEvent,\r\n} from 'react';\r\nimport { forwardRef, useRef, useState, useEffect } from 'react';\r\n\r\nimport { wrapEvent, assignMultipleRefs, getCircularIndex } from '../utils';\r\nimport { useAccordionContext, useAccordionItemContext } from './context';\r\nimport { headerScopeQuery as scopeQuery } from './scopeQuery';\r\n\r\nexport interface AccordionHeaderProps extends HTMLAttributes<HTMLDivElement> {\r\n as?: ElementType<any>;\r\n innerAs?: ElementType<any>;\r\n children?: ReactNode;\r\n}\r\n\r\nexport const AccordionHeader = forwardRef<HTMLDivElement, AccordionHeaderProps>(\r\n function AccordionHeader(props, forwardedRef) {\r\n const {\r\n as: Comp = 'div',\r\n onKeyDown,\r\n onClick: onClickProp,\r\n onFocus,\r\n onBlur,\r\n ...otherProps\r\n } = props;\r\n const accordionContext = useAccordionContext();\r\n const accordionItemContext = useAccordionItemContext();\r\n const ref = useRef<HTMLDivElement>();\r\n const [index, setIndex] = useState<number | undefined>();\r\n\r\n if (!accordionItemContext) {\r\n throw new Error('Missing parent <Accordion /> component');\r\n }\r\n\r\n useEffect(() => {\r\n if (accordionContext) {\r\n const allHeaders =\r\n accordionContext.scope.current.queryAllNodes(scopeQuery) || [];\r\n\r\n const index = allHeaders.findIndex((e) => e === ref.current);\r\n setIndex(index);\r\n }\r\n }, [accordionContext]);\r\n\r\n const onClick = wrapEvent(onClickProp, (e: MouseEvent<HTMLDivElement>) => {\r\n let index = 0;\r\n if (accordionItemContext.expanded) {\r\n index = -1;\r\n } else if (accordionContext) {\r\n const allHeaders =\r\n accordionContext.scope.current.queryAllNodes(scopeQuery) || [];\r\n\r\n index = allHeaders.findIndex((e) => e === ref.current);\r\n if (index === accordionContext.expandedIndex) {\r\n index = -1;\r\n }\r\n accordionContext.onChange && accordionContext.onChange(e, index);\r\n }\r\n\r\n accordionItemContext.onChange &&\r\n accordionItemContext.onChange(e, index >= 0);\r\n });\r\n\r\n const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\r\n switch (e.key) {\r\n case 'Enter':\r\n case ' ': {\r\n onClick(e as unknown as MouseEvent<HTMLDivElement>);\r\n e.preventDefault();\r\n break;\r\n }\r\n case 'ArrowUp':\r\n case 'ArrowDown':\r\n case 'Home':\r\n case 'End': {\r\n if (!accordionContext) {\r\n return;\r\n }\r\n const allHeaders =\r\n accordionContext.scope.current.queryAllNodes(scopeQuery);\r\n\r\n e.preventDefault();\r\n\r\n if (allHeaders.length === 0) {\r\n return;\r\n }\r\n\r\n let nextIndex = allHeaders.findIndex((e) => e === ref.current);\r\n switch (e.key) {\r\n case 'ArrowUp':\r\n nextIndex += -1;\r\n break;\r\n case 'ArrowDown':\r\n nextIndex += +1;\r\n break;\r\n case 'Home':\r\n nextIndex = 0;\r\n break;\r\n case 'End':\r\n nextIndex = -1;\r\n break;\r\n }\r\n\r\n // We're sure it will not be null, because we already checked for allHeaders.length > 0 above\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n nextIndex = getCircularIndex(nextIndex, allHeaders.length)!;\r\n allHeaders[nextIndex] && allHeaders[nextIndex].focus();\r\n break;\r\n }\r\n default:\r\n return;\r\n }\r\n };\r\n\r\n const handleFocus = () => {\r\n if (accordionContext) {\r\n if (!accordionContext.childrenHeaderHasFocus) {\r\n // this is needed to avoid rerendering the parent and\r\n // messing up with the internal count for children/parent count\r\n accordionContext.setChildrenHeaderHasFocus(true);\r\n }\r\n }\r\n };\r\n\r\n const handleBlur = (e: FocusEvent<HTMLDivElement>) => {\r\n if (accordionContext) {\r\n const allHeaders =\r\n accordionContext.scope.current.queryAllNodes(scopeQuery);\r\n const newFocusIsHeader =\r\n allHeaders.findIndex((header) => header === e.relatedTarget) >= 0;\r\n\r\n // only remove focus flag if the focus went to some element\r\n // that is not an accordion header\r\n if (!newFocusIsHeader) {\r\n accordionContext.setChildrenHeaderHasFocus(false);\r\n }\r\n }\r\n };\r\n\r\n const expanded = Boolean(\r\n accordionItemContext.expanded ||\r\n (accordionContext && accordionContext.expandedIndex === index)\r\n );\r\n\r\n return (\r\n <Comp\r\n ref={assignMultipleRefs(ref, forwardedRef)}\r\n {...otherProps}\r\n id={accordionItemContext.headerId}\r\n aria-controls={accordionItemContext.bodyId}\r\n role=\"button\"\r\n data-accordion-header=\"\"\r\n tabIndex=\"0\"\r\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\r\n onFocus={wrapEvent(onFocus, handleFocus)}\r\n onBlur={wrapEvent(onBlur, handleBlur)}\r\n onClick={onClick}\r\n aria-expanded={String(expanded)}\r\n />\r\n );\r\n }\r\n);\r\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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QAArB,IACGZ,gBAAgB,IAAIA,gBAAgB,CAACa,aAAjB,KAAmCV,KAFpC,CAAxB;EAKA,oBACE,KAAC,IAAD;IACE,GAAG,EAAEpB,kBAAkB,CAACmB,GAAD,EAAMX,YAAN;EADzB,GAEMQ,UAFN;IAGE,EAAE,EAAEE,oBAAoB,CAAC4B,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"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { HTMLAttributes, ElementType, ReactNode, KeyboardEvent, MouseEvent } from 'react';
|
|
2
|
-
export interface AccordionItemProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
children?: ReactNode;
|
|
6
|
-
expanded?: boolean;
|
|
7
|
-
onChange?: (e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>, value: boolean) => void;
|
|
8
|
-
}
|
|
9
|
-
export declare const AccordionItem: import("react").ForwardRefExoticComponent<AccordionItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
1
|
+
import type { HTMLAttributes, ElementType, ReactNode, KeyboardEvent, MouseEvent } from 'react';
|
|
2
|
+
export interface AccordionItemProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
expanded?: boolean;
|
|
7
|
+
onChange?: (e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>, value: boolean) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const AccordionItem: import("react").ForwardRefExoticComponent<AccordionItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1 @@
|
|
|
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"}
|
|
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 {\r\n HTMLAttributes,\r\n ElementType,\r\n ReactNode,\r\n KeyboardEvent,\r\n MouseEvent,\r\n} from 'react';\r\nimport { Fragment, forwardRef, useId } from 'react';\r\n\r\nimport type { AccordionItemContextProps } from './context';\r\nimport { AccordionItemProvider } from './context';\r\n\r\nexport interface AccordionItemProps\r\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {\r\n as?: ElementType<any>;\r\n innerAs?: ElementType<any>;\r\n children?: ReactNode;\r\n expanded?: boolean;\r\n onChange?: (\r\n e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>,\r\n value: boolean\r\n ) => void;\r\n}\r\n\r\nexport const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(\r\n function AccordionItem(props, forwardedRef) {\r\n const {\r\n as: Comp = Fragment,\r\n expanded = false,\r\n onChange,\r\n ...otherProps\r\n } = props;\r\n const id = useId();\r\n\r\n const headerId = id ? `accordion-header-${id}` : undefined;\r\n const bodyId = id ? `accordion-body-${id}` : undefined;\r\n const contextValue: AccordionItemContextProps = {\r\n headerId,\r\n bodyId,\r\n expanded,\r\n onChange,\r\n };\r\n\r\n return (\r\n <AccordionItemProvider value={contextValue}>\r\n <Comp ref={forwardedRef} {...otherProps} />\r\n </AccordionItemProvider>\r\n );\r\n }\r\n);\r\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"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import type { KeyboardEvent, MouseEvent } from 'react';
|
|
2
|
-
import type { Scope } from '../hooks/useScope';
|
|
3
|
-
export interface AccordionContextProps {
|
|
4
|
-
childrenHeaderHasFocus: boolean;
|
|
5
|
-
setChildrenHeaderHasFocus: (value: boolean) => void;
|
|
6
|
-
scope: Scope<HTMLElement>;
|
|
7
|
-
expandedIndex: number;
|
|
8
|
-
onChange?: (e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>, index: number) => void;
|
|
9
|
-
}
|
|
10
|
-
export declare const AccordionProvider: import("react").Provider<AccordionContextProps | null>;
|
|
11
|
-
export declare const useAccordionContext: () => AccordionContextProps | null;
|
|
12
|
-
export interface AccordionItemContextProps {
|
|
13
|
-
headerId: string | undefined;
|
|
14
|
-
bodyId: string | undefined;
|
|
15
|
-
expanded: boolean;
|
|
16
|
-
onChange?: (e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>, value: boolean) => void;
|
|
17
|
-
}
|
|
18
|
-
export declare const AccordionItemProvider: import("react").Provider<AccordionItemContextProps | null>;
|
|
19
|
-
export declare const useAccordionItemContext: () => AccordionItemContextProps | null;
|
|
1
|
+
import type { KeyboardEvent, MouseEvent } from 'react';
|
|
2
|
+
import type { Scope } from '../hooks/useScope';
|
|
3
|
+
export interface AccordionContextProps {
|
|
4
|
+
childrenHeaderHasFocus: boolean;
|
|
5
|
+
setChildrenHeaderHasFocus: (value: boolean) => void;
|
|
6
|
+
scope: Scope<HTMLElement>;
|
|
7
|
+
expandedIndex: number;
|
|
8
|
+
onChange?: (e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>, index: number) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const AccordionProvider: import("react").Provider<AccordionContextProps | null>;
|
|
11
|
+
export declare const useAccordionContext: () => AccordionContextProps | null;
|
|
12
|
+
export interface AccordionItemContextProps {
|
|
13
|
+
headerId: string | undefined;
|
|
14
|
+
bodyId: string | undefined;
|
|
15
|
+
expanded: boolean;
|
|
16
|
+
onChange?: (e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>, value: boolean) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const AccordionItemProvider: import("react").Provider<AccordionItemContextProps | null>;
|
|
19
|
+
export declare const useAccordionItemContext: () => AccordionItemContextProps | null;
|
|
@@ -1 +1 @@
|
|
|
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"}
|
|
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';\r\nimport { useContext, createContext } from 'react';\r\n\r\nimport type { Scope } from '../hooks/useScope';\r\n\r\n// AccordionGroup Component\r\nexport interface AccordionContextProps {\r\n childrenHeaderHasFocus: boolean;\r\n setChildrenHeaderHasFocus: (value: boolean) => void;\r\n scope: Scope<HTMLElement>;\r\n expandedIndex: number;\r\n onChange?: (\r\n e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>,\r\n index: number\r\n ) => void;\r\n}\r\n\r\nconst accordionContext = createContext<AccordionContextProps | null>(null);\r\nexport const { Provider: AccordionProvider } = accordionContext;\r\nexport const useAccordionContext = () => useContext(accordionContext);\r\n\r\n// Accordion Component\r\nexport interface AccordionItemContextProps {\r\n headerId: string | undefined;\r\n bodyId: string | undefined;\r\n expanded: boolean;\r\n onChange?: (\r\n e: KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement>,\r\n value: boolean\r\n ) => void;\r\n}\r\n\r\nconst accordionItemContext = createContext<AccordionItemContextProps | null>(\r\n null\r\n);\r\nexport const { Provider: AccordionItemProvider } = accordionItemContext;\r\nexport const useAccordionItemContext = () => useContext(accordionItemContext);\r\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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './Accordion';
|
|
2
|
-
export * from './AccordionItem';
|
|
3
|
-
export * from './AccordionHeader';
|
|
4
|
-
export * from './AccordionBody';
|
|
1
|
+
export * from './Accordion';
|
|
2
|
+
export * from './AccordionItem';
|
|
3
|
+
export * from './AccordionHeader';
|
|
4
|
+
export * from './AccordionBody';
|
|
@@ -1 +1 @@
|
|
|
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"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/Accordion/index.ts"],"sourcesContent":["export * from './Accordion';\r\nexport * from './AccordionItem';\r\nexport * from './AccordionHeader';\r\nexport * from './AccordionBody';\r\n"],"mappings":"AAAA,cAAc,aAAd;AACA,cAAc,iBAAd;AACA,cAAc,mBAAd;AACA,cAAc,iBAAd"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function headerScopeQuery(type: string, props: Record<string, unknown>): boolean;
|
|
2
|
-
export declare function bodyScopeQuery(type: string, props: Record<string, unknown>): boolean;
|
|
1
|
+
export declare function headerScopeQuery(type: string, props: Record<string, unknown>): boolean;
|
|
2
|
+
export declare function bodyScopeQuery(type: string, props: Record<string, unknown>): boolean;
|
|
@@ -1 +1 @@
|
|
|
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"}
|
|
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>) {\r\n return props['data-accordion-header'] === '';\r\n}\r\n\r\nexport function bodyScopeQuery(type: string, props: Record<string, unknown>) {\r\n return props['data-accordion-body'] === '';\r\n}\r\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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ElementType, InputHTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
export interface CheckBoxProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
children?: ReactNode;
|
|
6
|
-
}
|
|
7
|
-
export declare const CheckBox: import("react").ForwardRefExoticComponent<CheckBoxProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
1
|
+
import type { ElementType, InputHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface CheckBoxProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const CheckBox: import("react").ForwardRefExoticComponent<CheckBoxProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -1 +1 @@
|
|
|
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"}
|
|
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';\r\nimport { forwardRef } from 'react';\r\n\r\nimport { useControlledState } from '../hooks';\r\n\r\nexport interface CheckBoxProps extends InputHTMLAttributes<HTMLInputElement> {\r\n as?: ElementType<any>;\r\n innerAs?: ElementType<any>;\r\n children?: ReactNode;\r\n}\r\n\r\nexport const CheckBox = forwardRef<HTMLInputElement, CheckBoxProps>(\r\n function CheckBox(props, forwardedRef) {\r\n const {\r\n as: Comp = 'input',\r\n checked: checkedProp,\r\n defaultChecked = false,\r\n onChange: onChangeProp,\r\n ...otherProps\r\n } = props;\r\n const [checked, onChange] = useControlledState(\r\n checkedProp,\r\n onChangeProp,\r\n defaultChecked,\r\n (setValue) => (e) => {\r\n setValue(e.target.checked);\r\n }\r\n );\r\n\r\n return (\r\n <Comp\r\n ref={forwardedRef}\r\n type=\"checkbox\"\r\n checked={checked}\r\n aria-checked={checked}\r\n onChange={onChange}\r\n {...otherProps}\r\n />\r\n );\r\n }\r\n);\r\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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './CheckBox';
|
|
1
|
+
export * from './CheckBox';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/CheckBox/index.ts"],"sourcesContent":["export * from './CheckBox';\n"],"mappings":"AAAA,cAAc,YAAd"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/CheckBox/index.ts"],"sourcesContent":["export * from './CheckBox';\r\n"],"mappings":"AAAA,cAAc,YAAd"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import type { HTMLAttributes, ReactNode, ElementType } from 'react';
|
|
2
|
-
export declare type SelectEventHandler = (text: string, itemId: string, obj: any) => void;
|
|
3
|
-
export declare type ComboboxProps = Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> & {
|
|
4
|
-
onSelect?: SelectEventHandler;
|
|
5
|
-
openOnFocus?: boolean;
|
|
6
|
-
selectOnBlur?: boolean;
|
|
7
|
-
children?: ReactNode;
|
|
8
|
-
as?: ElementType<any>;
|
|
9
|
-
innerAs?: ElementType<any>;
|
|
10
|
-
};
|
|
11
|
-
export declare const Combobox: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "onSelect"> & {
|
|
12
|
-
onSelect?: SelectEventHandler | undefined;
|
|
13
|
-
openOnFocus?: boolean | undefined;
|
|
14
|
-
selectOnBlur?: boolean | undefined;
|
|
15
|
-
children?: ReactNode;
|
|
16
|
-
as?: ElementType<any> | undefined;
|
|
17
|
-
innerAs?: ElementType<any> | undefined;
|
|
18
|
-
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
1
|
+
import type { HTMLAttributes, ReactNode, ElementType } from 'react';
|
|
2
|
+
export declare type SelectEventHandler = (text: string, itemId: string, obj: any) => void;
|
|
3
|
+
export declare type ComboboxProps = Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> & {
|
|
4
|
+
onSelect?: SelectEventHandler;
|
|
5
|
+
openOnFocus?: boolean;
|
|
6
|
+
selectOnBlur?: boolean;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
as?: ElementType<any>;
|
|
9
|
+
innerAs?: ElementType<any>;
|
|
10
|
+
};
|
|
11
|
+
export declare const Combobox: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "onSelect"> & {
|
|
12
|
+
onSelect?: SelectEventHandler | undefined;
|
|
13
|
+
openOnFocus?: boolean | undefined;
|
|
14
|
+
selectOnBlur?: boolean | undefined;
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
as?: ElementType<any> | undefined;
|
|
17
|
+
innerAs?: ElementType<any> | undefined;
|
|
18
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -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":";;;;AACA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,OAA7B,EAAsCC,KAAtC,QAAmD,OAAnD;AAGA,SAASC,UAAT,EAAqBC,eAArB,EAAsCC,SAAtC,EAAiDC,IAAjD,QAA6D,SAA7D;AAEA,SAASC,gBAAT,QAAiC,WAAjC;AACA,SAASC,iBAAT,QAAkC,4BAAlC;AAEA,SAASC,QAAT,QAAyB,UAAzB;;AAiBA,OAAO,IAAMC,QAAQ,gBAAGX,UAAU,CAChC,SAASW,QAAT,OAiBEC,GAjBF,EAkBE;EAAA,IAfEC,QAeF,QAfEA,QAeF;EAAA,4BAXEC,WAWF;EAAA,IAXEA,WAWF,iCAXgB,KAWhB;EAAA,6BAREC,YAQF;EAAA,IAREA,YAQF,kCARiB,KAQjB;EAAA,IANEC,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C,OAAO,GAAGvC,OAAO,CACrB;IAAA,OAA6B;MAC3BqC,IAAI,EAAJA,IAD2B;MAE3Bf,QAAQ,EAARA,QAF2B;MAG3BC,UAAU,EAAVA,UAH2B;MAI3BC,SAAS,EAATA,SAJ2B;MAK3Bb,QAAQ,EAARA,QAL2B;MAM3BQ,UAAU,EAAVA,UAN2B;MAO3BC,SAAS,EAATA,SAP2B;MAQ3BW,KAAK,EAALA,KAR2B;MAS3BO,UAAU,EAAVA,UAT2B;MAU3BV,YAAY,EAAZA,YAV2B;MAW3BC,UAAU,EAAVA,UAX2B;MAY3BJ,mBAAmB,EAAnBA,mBAZ2B;MAa3BC,mBAAmB,EAAnBA,mBAb2B;MAc3BC,gBAAgB,EAAhBA,gBAd2B;MAe3BvB,SAAS,EAAEA,SAAS,CAAC2B,KAAD,CAfO;MAgB3BnB,WAAW,EAAXA,WAhB2B;MAiB3BC,YAAY,EAAZA;IAjB2B,CAA7B;EAAA,CADqB,EAoBrB,CAACwB,IAAD,EAAO1B,QAAP,EAAiBS,SAAjB,EAA4BW,KAA5B,EAAmCO,UAAnC,EAA+C1B,WAA/C,EAA4DC,YAA5D,CApBqB,CAAvB;EAuBA,oBACE,KAAC,gBAAD;IAAkB,KAAK,EAAE0B,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"}
|
|
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';\r\nimport { forwardRef, useRef, useMemo, useId } from 'react';\r\n\r\nimport type { ActionTypes } from './hooks';\r\nimport { stateChart, comboboxReducer, isVisible, INIT } from './hooks';\r\nimport type { ComboBoxContextProps } from './context';\r\nimport { ComboBoxProvider } from './context';\r\nimport { useReducerMachine } from '../hooks/useReducerMachine';\r\nimport type { Scope } from '../hooks';\r\nimport { getScope } from '../hooks';\r\n\r\nexport type SelectEventHandler = (\r\n text: string,\r\n itemId: string,\r\n obj: any\r\n) => void;\r\n\r\nexport type ComboboxProps = Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> & {\r\n onSelect?: SelectEventHandler;\r\n openOnFocus?: boolean;\r\n selectOnBlur?: boolean;\r\n children?: ReactNode;\r\n as?: ElementType<any>;\r\n innerAs?: ElementType<any>;\r\n};\r\n\r\nexport const Combobox = forwardRef<HTMLDivElement, ComboboxProps>(\r\n function Combobox(\r\n {\r\n // Called whenever the user selects an item from the list\r\n onSelect,\r\n\r\n // opens the list when the input receives focused (but only if there are\r\n // items in the list)\r\n openOnFocus = false,\r\n\r\n // if set to true, it will select an item after blurring\r\n selectOnBlur = false,\r\n\r\n children,\r\n as: Comp = 'div',\r\n innerAs,\r\n ...rest\r\n }: ComboboxProps,\r\n ref\r\n ) {\r\n // We store the values of all the ComboboxOptions on this ref. This makes it\r\n // possible to perform the keyboard navigation from the input on the list. We\r\n // manipulate this array through context so that we don't have to enforce a\r\n // parent/child relationship between ComboboxList and ComboboxOption.\r\n const optionsRef = useRef<{\r\n [itemId: string]: {\r\n value: string | unknown;\r\n text: string;\r\n };\r\n }>({});\r\n\r\n const listScope: Scope<HTMLElement> = useRef(getScope({ current: null }));\r\n\r\n // Need this to focus it\r\n const inputRef = useRef<HTMLInputElement>(null);\r\n\r\n const popoverRef = useRef<HTMLDivElement>(null);\r\n\r\n const buttonRef = useRef<HTMLButtonElement>(null);\r\n\r\n // When <ComboboxInput autocomplete={false} /> we don't want cycle back to\r\n // the user's value while navigating (because it's always the user's value),\r\n // but we need to know this in useKeyDown which is far away from the prop\r\n // here, so we do something sneaky and write it to this ref on context so we\r\n // can use it anywhere else 😛. Another new trick for me and I'm excited\r\n // about this one too!\r\n const autocompletePropRef = useRef<boolean>(false);\r\n\r\n const persistSelectionRef = useRef<boolean>(false);\r\n\r\n const clearOnEscapeRef = useRef<boolean>(false);\r\n\r\n const listboxIdRef = useRef<string | undefined>();\r\n\r\n const labelIdRef = useRef<string | undefined>();\r\n\r\n const defaultData = {\r\n // initial state\r\n state: stateChart.initial,\r\n // the value the user has typed, we derived this also when the developer is\r\n // controlling the value of ComboboxInput\r\n text: '',\r\n // the index the user has typed, we derived this also when the developer is\r\n // controlling the value of ComboboxInput\r\n item: '',\r\n // the hash of the currently navigated item\r\n navigationItem: '',\r\n // the last submitted action\r\n lastActionType: INIT as ActionTypes,\r\n };\r\n\r\n const [state, data, transition] = useReducerMachine(\r\n stateChart,\r\n comboboxReducer,\r\n defaultData\r\n );\r\n\r\n listboxIdRef.current = useId();\r\n\r\n labelIdRef.current = useId();\r\n\r\n const context = useMemo(\r\n (): ComboBoxContextProps => ({\r\n data,\r\n inputRef,\r\n popoverRef,\r\n buttonRef,\r\n onSelect,\r\n optionsRef,\r\n listScope,\r\n state,\r\n transition,\r\n listboxIdRef,\r\n labelIdRef,\r\n autocompletePropRef,\r\n persistSelectionRef,\r\n clearOnEscapeRef,\r\n isVisible: isVisible(state),\r\n openOnFocus,\r\n selectOnBlur,\r\n }),\r\n [data, onSelect, listScope, state, transition, openOnFocus, selectOnBlur]\r\n );\r\n\r\n return (\r\n <ComboBoxProvider value={context}>\r\n <Comp\r\n {...rest}\r\n as={innerAs}\r\n data-reach-combobox=\"\"\r\n ref={ref}\r\n role=\"combobox\"\r\n aria-haspopup=\"listbox\"\r\n aria-owns={listboxIdRef.current}\r\n aria-expanded={context.isVisible}\r\n >\r\n {children}\r\n </Comp>\r\n </ComboBoxProvider>\r\n );\r\n }\r\n);\r\n"],"mappings":";;;;AACA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,OAA7B,EAAsCC,KAAtC,QAAmD,OAAnD;AAGA,SAASC,UAAT,EAAqBC,eAArB,EAAsCC,SAAtC,EAAiDC,IAAjD,QAA6D,SAA7D;AAEA,SAASC,gBAAT,QAAiC,WAAjC;AACA,SAASC,iBAAT,QAAkC,4BAAlC;AAEA,SAASC,QAAT,QAAyB,UAAzB;;AAiBA,OAAO,IAAMC,QAAQ,gBAAGX,UAAU,CAChC,SAASW,QAAT,OAiBEC,GAjBF,EAkBE;EAAA,IAfEC,QAeF,QAfEA,QAeF;EAAA,4BAXEC,WAWF;EAAA,IAXEA,WAWF,iCAXgB,KAWhB;EAAA,6BAREC,YAQF;EAAA,IAREA,YAQF,kCARiB,KAQjB;EAAA,IANEC,QAMF,QANEA,QAMF;EAAA,mBALEC,EAKF;EAAA,IALMC,IAKN,wBALa,KAKb;EAAA,IAJEC,OAIF,QAJEA,OAIF;EAAA,IAHKC,IAGL;;EACA;EACA;EACA;EACA;EACA,IAAMC,UAAU,GAAGpB,MAAM,CAKtB,EALsB,CAAzB;EAOA,IAAMqB,SAA6B,GAAGrB,MAAM,CAACS,QAAQ,CAAC;IAAEa,OAAO,EAAE;EAAX,CAAD,CAAT,CAA5C,CAZA,CAcA;;EACA,IAAMC,QAAQ,GAAGvB,MAAM,CAAmB,IAAnB,CAAvB;EAEA,IAAMwB,UAAU,GAAGxB,MAAM,CAAiB,IAAjB,CAAzB;EAEA,IAAMyB,SAAS,GAAGzB,MAAM,CAAoB,IAApB,CAAxB,CAnBA,CAqBA;EACA;EACA;EACA;EACA;EACA;;EACA,IAAM0B,mBAAmB,GAAG1B,MAAM,CAAU,KAAV,CAAlC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AZA;IAjB2B,CAA7B;EAAA,CADqB,EAoBrB,CAACwB,IAAD,EAAO1B,QAAP,EAAiBS,SAAjB,EAA4BW,KAA5B,EAAmCO,UAAnC,EAA+C1B,WAA/C,EAA4DC,YAA5D,CApBqB,CAAvB;EAuBA,oBACE,KAAC,gBAAD;IAAkB,KAAK,EAAE0B,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"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ButtonHTMLAttributes, ElementType, KeyboardEventHandler, MouseEventHandler, ReactNode } from 'react';
|
|
2
|
-
export interface ComboboxButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
6
|
-
onKeyDown?: KeyboardEventHandler<HTMLButtonElement>;
|
|
7
|
-
children?: ReactNode;
|
|
8
|
-
}
|
|
9
|
-
export declare const ComboboxButton: import("react").ForwardRefExoticComponent<ComboboxButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
1
|
+
import type { ButtonHTMLAttributes, ElementType, KeyboardEventHandler, MouseEventHandler, ReactNode } from 'react';
|
|
2
|
+
export interface ComboboxButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
6
|
+
onKeyDown?: KeyboardEventHandler<HTMLButtonElement>;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare const ComboboxButton: import("react").ForwardRefExoticComponent<ComboboxButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -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":";;;AAOA,SAASA,UAAT,QAA2B,OAA3B;AAEA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,UAAT,EAAqBC,IAArB,EAA2BC,gBAA3B,EAA6CC,iBAA7C,QAAsE,SAAtE;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,kBAAT,QAAmC,qBAAnC;;AAWA,OAAO,IAAMC,cAAc,gBAAGR,UAAU,CAGtC,SAASQ,cAAT,OAEAC,GAFA,EAGA;EAAA,mBAFEC,EAEF;EAAA,IAFMC,IAEN,wBAFa,QAEb;EAAA,IAFuBC,OAEvB,QAFuBA,OAEvB;EAAA,IAFgCC,OAEhC,QAFgCA,OAEhC;EAAA,IAFyCC,SAEzC,QAFyCA,SAEzC;EAAA,IAFuDC,KAEvD;;EACA,0BACEd,kBAAkB,EADpB;EAAA,IAAQe,UAAR,uBAAQA,UAAR;EAAA,IAAoBC,IAApB,uBAAoBA,IAApB;EAAA,IAA0BC,KAA1B,uBAA0BA,KAA1B;EAAA,IAAiCC,SAAjC,uBAAiCA,SAAjC;EAAA,IAA4CC,YAA5C,uBAA4CA,YAA5C;EAAA,IAA0DC,SAA1D,uBAA0DA,SAA1D;;EAGA,IAAMC,aAAa,GAAGpB,UAAU,EAAhC;;EAEA,IAAMqB,WAAW,GAAG,SAAdA,WAAc,GAAM;IACxB,IAAMC,OAAO,GAAG;MACdC,IAAI,EAAER,IAAI,CAACS;IADG,CAAhB;;IAIA,IAAIR,KAAK,KAAKf,IAAd,EAAoB;MAClBa,UAAU,CAACZ,gBAAD,EAAmBoB,OAAnB,CAAV;IACD,CAFD,MAEO;MACLR,UAAU,CAACX,iBAAD,EAAoBmB,OAApB,CAAV;IACD;EACF,CAVD;;EAYA,oBACE,KAAC,IAAD;IACE,EAAE,EAAEZ,OADN;IAEE,8BAA2B,EAF7B;IAGE,iBAAeQ,YAAY,CAACO,OAH9B;IAIE,iBAAc,SAJhB;IAKE,iBAAeN,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"}
|
|
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 {\r\n ButtonHTMLAttributes,\r\n ElementType,\r\n KeyboardEventHandler,\r\n MouseEventHandler,\r\n ReactNode,\r\n} from 'react';\r\nimport { forwardRef } from 'react';\r\n\r\nimport { useComboBoxContext } from './context';\r\nimport { useKeyDown, IDLE, OPEN_WITH_BUTTON, CLOSE_WITH_BUTTON } from './hooks';\r\nimport { wrapEvent } from '../utils/wrap-event';\r\nimport { assignMultipleRefs } from '../utils/assign-ref';\r\n\r\nexport interface ComboboxButtonProps\r\n extends ButtonHTMLAttributes<HTMLButtonElement> {\r\n as?: ElementType<any>;\r\n innerAs?: ElementType<any>;\r\n onClick?: MouseEventHandler<HTMLButtonElement>;\r\n onKeyDown?: KeyboardEventHandler<HTMLButtonElement>;\r\n children?: ReactNode;\r\n}\r\n\r\nexport const ComboboxButton = forwardRef<\r\n HTMLButtonElement,\r\n ComboboxButtonProps\r\n>(function ComboboxButton(\r\n { as: Comp = 'button', innerAs, onClick, onKeyDown, ...props },\r\n ref\r\n) {\r\n const { transition, data, state, buttonRef, listboxIdRef, isVisible } =\r\n useComboBoxContext();\r\n\r\n const handleKeyDown = useKeyDown();\r\n\r\n const handleClick = () => {\r\n const payload = {\r\n item: data.navigationItem,\r\n };\r\n\r\n if (state === IDLE) {\r\n transition(OPEN_WITH_BUTTON, payload);\r\n } else {\r\n transition(CLOSE_WITH_BUTTON, payload);\r\n }\r\n };\r\n\r\n return (\r\n <Comp\r\n as={innerAs}\r\n data-reach-combobox-button=\"\"\r\n aria-controls={listboxIdRef.current}\r\n aria-haspopup=\"listbox\"\r\n aria-expanded={isVisible}\r\n ref={assignMultipleRefs(ref, buttonRef)}\r\n onClick={wrapEvent(onClick, handleClick)}\r\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\r\n {...props}\r\n />\r\n );\r\n});\r\n"],"mappings":";;;AAOA,SAASA,UAAT,QAA2B,OAA3B;AAEA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,UAAT,EAAqBC,IAArB,EAA2BC,gBAA3B,EAA6CC,iBAA7C,QAAsE,SAAtE;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,kBAAT,QAAmC,qBAAnC;;AAWA,OAAO,IAAMC,cAAc,gBAAGR,UAAU,CAGtC,SAASQ,cAAT,OAEAC,GAFA,EAGA;EAAA,mBAFEC,EAEF;EAAA,IAFMC,IAEN,wBAFa,QAEb;EAAA,IAFuBC,OAEvB,QAFuBA,OAEvB;EAAA,IAFgCC,OAEhC,QAFgCA,OAEhC;EAAA,IAFyCC,SAEzC,QAFyCA,SAEzC;EAAA,IAFuDC,KAEvD;;EACA,0BACEd,kBAAkB,EADpB;EAAA,IAAQe,UAAR,uBAAQA,UAAR;EAAA,IAAoBC,IAApB,uBAAoBA,IAApB;EAAA,IAA0BC,KAA1B,uBAA0BA,KAA1B;EAAA,IAAiCC,SAAjC,uBAAiCA,SAAjC;EAAA,IAA4CC,YAA5C,uBAA4CA,YAA5C;EAAA,IAA0DC,SAA1D,uBAA0DA,SAA1D;;EAGA,IAAMC,aAAa,GAAGpB,UAAU,EAAhC;;EAEA,IAAMqB,WAAW,GAAG,SAAdA,WAAc,GAAM;IACxB,IAAMC,OAAO,GAAG;MACdC,IAAI,EAAER,IAAI,CAACS;IADG,CAAhB;;IAIA,IAAIR,KAAK,KAAKf,IAAd,EAAoB;MAClBa,UAAU,CAACZ,gBAAD,EAAmBoB,OAAnB,CAAV;IACD,CAFD,MAEO;MACLR,UAAU,CAACX,iBAAD,EAAoBmB,OAApB,CAAV;IACD;EACF,CAVD;;EAYA,oBACE,KAAC,IAAD;IACE,EAAE,EAAEZ,OADN;IAEE,8BAA2B,EAF7B;IAGE,iBAAeQ,YAAY,CAACO,OAH9B;IAIE,iBAAc,SAJhB;IAKE,iBAAeN,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"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type { ChangeEventHandler, ElementType, FocusEventHandler, InputHTMLAttributes, KeyboardEventHandler, MouseEventHandler } from 'react';
|
|
2
|
-
export interface ComboboxInputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
3
|
-
clearOnEscape?: boolean;
|
|
4
|
-
selectOnClick?: boolean;
|
|
5
|
-
autocomplete?: boolean;
|
|
6
|
-
defaultValue?: string;
|
|
7
|
-
value?: string;
|
|
8
|
-
onClick?: MouseEventHandler<HTMLInputElement>;
|
|
9
|
-
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
10
|
-
onKeyDown?: KeyboardEventHandler<HTMLInputElement>;
|
|
11
|
-
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
12
|
-
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
13
|
-
as?: ElementType<any>;
|
|
14
|
-
innerAs?: ElementType<any>;
|
|
15
|
-
id?: string;
|
|
16
|
-
}
|
|
17
|
-
export declare const ComboboxInput: import("react").ForwardRefExoticComponent<ComboboxInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
1
|
+
import type { ChangeEventHandler, ElementType, FocusEventHandler, InputHTMLAttributes, KeyboardEventHandler, MouseEventHandler } from 'react';
|
|
2
|
+
export interface ComboboxInputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
3
|
+
clearOnEscape?: boolean;
|
|
4
|
+
selectOnClick?: boolean;
|
|
5
|
+
autocomplete?: boolean;
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
value?: string;
|
|
8
|
+
onClick?: MouseEventHandler<HTMLInputElement>;
|
|
9
|
+
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
10
|
+
onKeyDown?: KeyboardEventHandler<HTMLInputElement>;
|
|
11
|
+
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
12
|
+
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
13
|
+
as?: ElementType<any>;
|
|
14
|
+
innerAs?: ElementType<any>;
|
|
15
|
+
id?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const ComboboxInput: import("react").ForwardRefExoticComponent<ComboboxInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboboxInput.js","names":["forwardRef","useEffect","useRef","useBlur","CLEAR","CHANGE","useKeyDown","SELECT_WITH_CLICK","FOCUS","NAVIGATING","INIT","useFocusManagement","assignMultipleRefs","wrapEvent","useComboBoxContext","ComboboxInput","forwardedRef","as","Comp","innerAs","selectOnClick","autocomplete","clearOnEscape","onClick","onChange","onKeyDown","onBlur","onFocus","preferredId","id","defaultValue","controlledValue","value","props","data","navigationItem","text","lastActionType","inputRef","state","transition","listboxIdRef","autocompletePropRef","clearOnEscapeRef","openOnFocus","optionsRef","labelIdRef","hasStartedInteracting","selectOnClickRef","handleBlur","current","handleChange","e","target","trim","handleKeyDown","handleFocus","item","handleClick","select","navigationText","undefined","fallbackValue","inputStrings","inputValue","find","str"],"sources":["../../../src/ComboBox/ComboboxInput.tsx"],"sourcesContent":["import type {\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,OAA9C;AAEA,SACEC,OADF,EAEEC,KAFF,EAGEC,MAHF,EAIEC,UAJF,EAKEC,iBALF,EAMEC,KANF,EAOEC,UAPF,EAQEC,IARF,EASEC,kBATF,QAUO,SAVP;AAWA,SAASC,kBAAT,EAA6BC,SAA7B,QAA8C,UAA9C;AACA,SAASC,kBAAT,QAAmC,WAAnC;;AAwBA,OAAO,IAAMC,aAAa,gBAAGf,UAAU,CACrC,SAASe,aAAT,OAuBEC,YAvBF,EAwBE;EAAA,mBAtBEC,EAsBF;EAAA,IAtBMC,IAsBN,wBAtBa,OAsBb;EAAA,IArBEC,OAqBF,QArBEA,OAqBF;EAAA,8BApBEC,aAoBF;EAAA,IApBEA,aAoBF,mCApBkB,KAoBlB;EAAA,6BAnBEC,YAmBF;EAAA,IAnBEA,YAmBF,kCAnBiB,IAmBjB;EAAA,8BAlBEC,aAkBF;EAAA,IAlBEA,aAkBF,mCAlBkB,KAkBlB;EAAA,IAfEC,OAeF,QAfEA,OAeF;EAAA,IAdEC,QAcF,QAdEA,QAcF;EAAA,IAbEC,SAaF,QAbEA,SAaF;EAAA,IAZEC,MAYF,QAZEA,MAYF;EAAA,IAXEC,OAWF,QAXEA,OA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AnB,CAlFA,CAoFA;EACA;EACA;;EACA5D,SAAS,CAAC,YAAM;IACduC,UAAU,CAAC9B,IAAD,EAAO;MAAE0B,IAAI,EAAE4B,UAAR;MAAoBP,IAAI,EAAE;IAA1B,CAAP,CAAV,CADc,CAEd;EACD,CAHQ,EAGN,EAHM,CAAT;EAKA,oBACE,KAAC,IAAD,wBACMxB,KADN;IAEE,EAAE,EAAEd,OAFN;IAGE,6BAA0B,EAH5B;IAIE,GAAG,EAAEP,kBAAkB,CAAC0B,QAAD,EAAWtB,YAAX,CAJzB;IAKE,KAAK,EAAEgD,UALT;IAME,OAAO,EAAEnD,SAAS,CAACU,OAAD,EAAUmC,WAAV,CANpB;IAOE,MAAM,EAAE7C,SAAS,CAACa,MAAD,EAASuB,UAAT,CAPnB;IAQE,OAAO,EAAEpC,SAAS,CAACc,OAAD,EAAU6B,WAAV,CARpB;IASE,QAAQ,EAAE3C,SAAS,CAACW,QAAD,EAAW2B,YAAX,CATrB;IAUE,SAAS,EAAEtC,SAAS,CAACY,SAAD,EAAY8B,aAAZ,CAVtB;IAWE,mBAAiBT,UAAU,CAACI,OAX9B;IAYE,EAAE,EAAET,YAAY,CAACS,OAZnB;IAaE,qBAAkB,MAbpB;IAcE,yBACEf,cAAc,KAAK,EAAnB,GAAwBA,cAAxB,GAAyC0B,SAf7C;IAiBE,YAAY,EAAC;EAjBf,GADF;AAqBD,CA1IoC,CAAhC"}
|
|
1
|
+
{"version":3,"file":"ComboboxInput.js","names":["forwardRef","useEffect","useRef","useBlur","CLEAR","CHANGE","useKeyDown","SELECT_WITH_CLICK","FOCUS","NAVIGATING","INIT","useFocusManagement","assignMultipleRefs","wrapEvent","useComboBoxContext","ComboboxInput","forwardedRef","as","Comp","innerAs","selectOnClick","autocomplete","clearOnEscape","onClick","onChange","onKeyDown","onBlur","onFocus","preferredId","id","defaultValue","controlledValue","value","props","data","navigationItem","text","lastActionType","inputRef","state","transition","listboxIdRef","autocompletePropRef","clearOnEscapeRef","openOnFocus","optionsRef","labelIdRef","hasStartedInteracting","selectOnClickRef","handleBlur","current","handleChange","e","target","trim","handleKeyDown","handleFocus","item","handleClick","select","navigationText","undefined","fallbackValue","inputStrings","inputValue","find","str"],"sources":["../../../src/ComboBox/ComboboxInput.tsx"],"sourcesContent":["import type {\r\n ChangeEvent,\r\n ChangeEventHandler,\r\n ElementType,\r\n FocusEventHandler,\r\n InputHTMLAttributes,\r\n KeyboardEventHandler,\r\n MouseEventHandler,\r\n} from 'react';\r\nimport { forwardRef, useEffect, useRef } from 'react';\r\n\r\nimport {\r\n useBlur,\r\n CLEAR,\r\n CHANGE,\r\n useKeyDown,\r\n SELECT_WITH_CLICK,\r\n FOCUS,\r\n NAVIGATING,\r\n INIT,\r\n useFocusManagement,\r\n} from './hooks';\r\nimport { assignMultipleRefs, wrapEvent } from '../utils';\r\nimport { useComboBoxContext } from './context';\r\n\r\nexport interface ComboboxInputProps\r\n extends InputHTMLAttributes<HTMLInputElement> {\r\n // clear on ESC\r\n clearOnEscape?: boolean;\r\n // highlights all the text in the box on click when true\r\n selectOnClick?: boolean;\r\n // updates the value in the input when navigating w/ the keyboard\r\n autocomplete?: boolean;\r\n // initial value for uncontrolled mode\r\n defaultValue?: string;\r\n // value for controlled mode\r\n value?: string;\r\n onClick?: MouseEventHandler<HTMLInputElement>;\r\n onChange?: ChangeEventHandler<HTMLInputElement>;\r\n onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\r\n onBlur?: FocusEventHandler<HTMLInputElement>;\r\n onFocus?: FocusEventHandler<HTMLInputElement>;\r\n as?: ElementType<any>;\r\n innerAs?: ElementType<any>;\r\n id?: string;\r\n}\r\n\r\nexport const ComboboxInput = forwardRef<HTMLInputElement, ComboboxInputProps>(\r\n function ComboboxInput(\r\n {\r\n as: Comp = 'input',\r\n innerAs,\r\n selectOnClick = false,\r\n autocomplete = true,\r\n clearOnEscape = false,\r\n\r\n // wrapped events\r\n onClick,\r\n onChange,\r\n onKeyDown,\r\n onBlur,\r\n onFocus,\r\n\r\n id: preferredId,\r\n\r\n defaultValue = '',\r\n\r\n // might be controlled\r\n value: controlledValue,\r\n ...props\r\n },\r\n forwardedRef\r\n ) {\r\n const {\r\n data: { navigationItem, text, lastActionType },\r\n inputRef,\r\n state,\r\n transition,\r\n listboxIdRef,\r\n autocompletePropRef,\r\n clearOnEscapeRef,\r\n openOnFocus,\r\n optionsRef,\r\n labelIdRef,\r\n } = useComboBoxContext();\r\n\r\n // Keep focus on the input component\r\n useFocusManagement(lastActionType, inputRef);\r\n\r\n // Keep using the defaultValue until the user started interacting\r\n const hasStartedInteracting = useRef(false);\r\n\r\n // Because we close the List on blur, we need to track if the blur is\r\n // caused by clicking inside the list, and if so, don't close the List.\r\n const selectOnClickRef = useRef(false);\r\n\r\n const handleBlur = useBlur();\r\n\r\n // Update ref props\r\n autocompletePropRef.current = autocomplete;\r\n clearOnEscapeRef.current = clearOnEscape;\r\n listboxIdRef.current = preferredId || listboxIdRef.current;\r\n\r\n // [*]... and when controlled, we don't trigger handleValueChange as the user\r\n // types, instead the developer controls it with the normal input onChange\r\n // prop\r\n const handleChange = (e: ChangeEvent<HTMLInputElement>) => {\r\n // After the user started typing, lets forget the defaultValue\r\n hasStartedInteracting.current = true;\r\n\r\n const text = e.target.value;\r\n if (text.trim() === '') {\r\n transition(CLEAR);\r\n } else {\r\n transition(CHANGE, { text });\r\n }\r\n };\r\n\r\n const handleKeyDown = useKeyDown();\r\n\r\n const handleFocus = () => {\r\n if (selectOnClick) {\r\n selectOnClickRef.current = true;\r\n }\r\n // If we select an option with click, useFocusManagement will focus the\r\n // input, in those cases we don't want to cause the menu to open back up,\r\n // so we guard behind these states\r\n if (openOnFocus && lastActionType !== SELECT_WITH_CLICK) {\r\n transition(FOCUS, {\r\n item: navigationItem,\r\n });\r\n }\r\n };\r\n\r\n const handleClick = () => {\r\n if (selectOnClickRef.current) {\r\n selectOnClickRef.current = false;\r\n inputRef.current && inputRef.current.select();\r\n }\r\n };\r\n\r\n const navigationText =\r\n navigationItem !== ''\r\n ? optionsRef.current[navigationItem].text\r\n : undefined;\r\n\r\n const fallbackValue = hasStartedInteracting.current ? '' : defaultValue;\r\n\r\n const inputStrings =\r\n // When idle, we don't have a navigationText on ArrowUp/Down\r\n autocomplete && state === NAVIGATING\r\n ? [navigationText, controlledValue, text, fallbackValue]\r\n : [controlledValue, text, fallbackValue];\r\n\r\n const inputValue = inputStrings.find((str) => str !== undefined);\r\n\r\n // If they are controlling the value we still need to do our transitions, so\r\n // we have this derived state to emulate onChange of the input as we receive\r\n // new `value`s ...[*]\r\n useEffect(() => {\r\n transition(INIT, { text: inputValue, item: '' });\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, []);\r\n\r\n return (\r\n <Comp\r\n {...props}\r\n as={innerAs}\r\n data-reach-combobox-input=\"\"\r\n ref={assignMultipleRefs(inputRef, forwardedRef)}\r\n value={inputValue}\r\n onClick={wrapEvent(onClick, handleClick)}\r\n onBlur={wrapEvent(onBlur, handleBlur)}\r\n onFocus={wrapEvent(onFocus, handleFocus)}\r\n onChange={wrapEvent(onChange, handleChange)}\r\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\r\n aria-labelledby={labelIdRef.current}\r\n id={listboxIdRef.current}\r\n aria-autocomplete=\"both\"\r\n aria-activedescendant={\r\n navigationItem !== '' ? navigationItem : undefined\r\n }\r\n autoComplete=\"off\"\r\n />\r\n );\r\n }\r\n);\r\n"],"mappings":";;;AASA,SAASA,UAAT,EAAqBC,SAArB,EAAgCC,MAAhC,QAA8C,OAA9C;AAEA,SACEC,OADF,EAEEC,KAFF,EAGEC,MAHF,EAIEC,UAJF,EAKEC,iBALF,EAMEC,KANF,EAOEC,UAPF,EAQEC,IARF,EASEC,kBATF,QAUO,SAVP;AAWA,SAASC,kBAAT,EAA6BC,SAA7B,QAA8C,UAA9C;AACA,SAASC,kBAAT,QAAmC,WAAnC;;AAwBA,OAAO,IAAMC,aAAa,gBAAGf,UAAU,CACrC,SAASe,a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yBACEf,cAAc,KAAK,EAAnB,GAAwBA,cAAxB,GAAyC0B,SAf7C;IAiBE,YAAY,EAAC;EAjBf,GADF;AAqBD,CA1IoC,CAAhC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ElementType, LabelHTMLAttributes } from 'react';
|
|
2
|
-
export interface ComboboxLabelProps extends LabelHTMLAttributes<HTMLLabelElement> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
id?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const ComboboxLabel: import("react").ForwardRefExoticComponent<ComboboxLabelProps & import("react").RefAttributes<HTMLLabelElement>>;
|
|
1
|
+
import type { ElementType, LabelHTMLAttributes } from 'react';
|
|
2
|
+
export interface ComboboxLabelProps extends LabelHTMLAttributes<HTMLLabelElement> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
id?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const ComboboxLabel: import("react").ForwardRefExoticComponent<ComboboxLabelProps & import("react").RefAttributes<HTMLLabelElement>>;
|
|
@@ -1 +1 @@
|
|
|
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"}
|
|
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';\r\nimport { forwardRef } from 'react';\r\n\r\nimport { useComboBoxContext } from './context';\r\n\r\nexport interface ComboboxLabelProps\r\n extends LabelHTMLAttributes<HTMLLabelElement> {\r\n as?: ElementType<any>;\r\n innerAs?: ElementType<any>;\r\n id?: string;\r\n}\r\n\r\nexport const ComboboxLabel = forwardRef<HTMLLabelElement, ComboboxLabelProps>(\r\n function ComboboxButton(\r\n { as: Comp = 'label', innerAs, id: preferredId, ...props },\r\n ref\r\n ) {\r\n const { listboxIdRef, labelIdRef } = useComboBoxContext();\r\n\r\n labelIdRef.current = preferredId || labelIdRef.current;\r\n\r\n return (\r\n <Comp\r\n as={innerAs}\r\n data-reach-combobox-label=\"\"\r\n htmlFor={listboxIdRef.current}\r\n id={labelIdRef.current}\r\n ref={ref}\r\n {...props}\r\n />\r\n );\r\n }\r\n);\r\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"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { HTMLAttributes, ElementType, ReactNode } from 'react';
|
|
2
|
-
export interface ComboboxListProps extends HTMLAttributes<HTMLUListElement> {
|
|
3
|
-
as?: ElementType<any>;
|
|
4
|
-
innerAs?: ElementType<any>;
|
|
5
|
-
persistSelection?: boolean;
|
|
6
|
-
children?: ReactNode;
|
|
7
|
-
}
|
|
8
|
-
export declare const ComboboxList: import("react").ForwardRefExoticComponent<ComboboxListProps & import("react").RefAttributes<HTMLUListElement>>;
|
|
1
|
+
import type { HTMLAttributes, ElementType, ReactNode } from 'react';
|
|
2
|
+
export interface ComboboxListProps extends HTMLAttributes<HTMLUListElement> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
persistSelection?: boolean;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const ComboboxList: import("react").ForwardRefExoticComponent<ComboboxListProps & import("react").RefAttributes<HTMLUListElement>>;
|