@economic/taco 0.0.1-alpha.8 → 0.0.2-alpha.0
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/dist/components/Combobox/useCombobox.d.ts +3 -3
- package/dist/components/Listbox/Listbox.d.ts +0 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +3 -3
- package/dist/components/Select/Select.d.ts +0 -5
- package/dist/components/Select/useSelect.d.ts +5 -4
- package/dist/esm/index.css +6 -78
- package/dist/esm/src/components/Combobox/Combobox.js +28 -24
- package/dist/esm/src/components/Combobox/Combobox.js.map +1 -1
- package/dist/esm/src/components/Combobox/useCombobox.js +32 -38
- package/dist/esm/src/components/Combobox/useCombobox.js.map +1 -1
- package/dist/esm/src/components/Listbox/Listbox.js +21 -5
- package/dist/esm/src/components/Listbox/Listbox.js.map +1 -1
- package/dist/esm/src/components/Listbox/ScrollableList.js +6 -4
- package/dist/esm/src/components/Listbox/ScrollableList.js.map +1 -1
- package/dist/esm/src/components/RadioGroup/RadioGroup.js +17 -16
- package/dist/esm/src/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/esm/src/components/Select/Select.js +27 -26
- package/dist/esm/src/components/Select/Select.js.map +1 -1
- package/dist/esm/src/components/Select/useSelect.js +72 -39
- package/dist/esm/src/components/Select/useSelect.js.map +1 -1
- package/dist/index.css +6 -78
- package/dist/taco.cjs.development.js +211 -159
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/dist/utils/tailwind.d.ts +1 -1
- package/package.json +2 -3
- package/types.json +237 -250
@@ -1,5 +1,4 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import { PopoverHTMLProps, PopoverStateReturn } from 'reakit/Popover';
|
3
2
|
import { ComboboxProps } from './Combobox';
|
4
3
|
import { ScrollableListPropsWithRef } from '../Listbox/ScrollableList';
|
5
4
|
declare type useCombobox = React.HTMLAttributes<HTMLDivElement> & {
|
@@ -8,8 +7,9 @@ declare type useCombobox = React.HTMLAttributes<HTMLDivElement> & {
|
|
8
7
|
ref: React.RefObject<HTMLInputElement>;
|
9
8
|
};
|
10
9
|
list: ScrollableListPropsWithRef;
|
11
|
-
popover:
|
12
|
-
|
10
|
+
popover: {
|
11
|
+
open: boolean;
|
12
|
+
onOpenChange: (open: boolean) => void;
|
13
13
|
};
|
14
14
|
};
|
15
15
|
export declare const useCombobox: ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, data: unfilteredData, defaultValue, disabled, id: nativeId, inline, loading: __, onChange, onClick, onKeyDown, readOnly, value, ...props }: ComboboxProps, ref: React.Ref<HTMLInputElement>) => useCombobox;
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { ScrollableListItemValue, ScrollableListItem } from './ScrollableList';
|
3
|
-
import './Listbox.css';
|
4
3
|
import { State } from '../../types';
|
5
4
|
export declare type ListboxItem = ScrollableListItem;
|
6
5
|
export declare type ListboxValue = ScrollableListItemValue;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { Orientation } from '../../types';
|
3
|
-
export declare type RadioGroupItemValue = string | number | boolean |
|
3
|
+
export declare type RadioGroupItemValue = string | number | boolean | null;
|
4
4
|
export declare const getRadioGroupItemValueAsString: (value: RadioGroupItemValue) => string;
|
5
|
-
export declare const findByValue: (values: RadioGroupItemValue[], valueAsString: string) => RadioGroupItemValue
|
5
|
+
export declare const findByValue: (values: RadioGroupItemValue[], valueAsString: string) => RadioGroupItemValue;
|
6
6
|
export declare type RadioGroupItemProps<T = HTMLButtonElement> = Omit<React.ButtonHTMLAttributes<T>, 'children' | 'onSelect' | 'value'> & {
|
7
7
|
/** Label for the radio group item */
|
8
8
|
children: React.ReactNode;
|
@@ -33,7 +33,7 @@ interface ControlledRadioGroupProps extends RadioGroupBaseProps {
|
|
33
33
|
/** Handler called when the value changes */
|
34
34
|
onChange: (value: RadioGroupItemValue) => void;
|
35
35
|
/** The current value (controlled) */
|
36
|
-
value
|
36
|
+
value?: RadioGroupItemValue;
|
37
37
|
}
|
38
38
|
export declare type RadioGroupProps = UncontrolledRadioGroupProps | ControlledRadioGroupProps;
|
39
39
|
export declare type ForwardedRadioGroupWithStatics = React.ForwardRefExoticComponent<RadioGroupProps & React.RefAttributes<HTMLDivElement>> & {
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { ListboxProps } from '../Listbox/Listbox';
|
3
3
|
import { ComboboxProps } from '../Combobox/Combobox';
|
4
|
-
import './Select.css';
|
5
4
|
export declare type SelectTexts = {
|
6
5
|
/**
|
7
6
|
* The text displayed when all options are selected when multiselect mode in on.
|
@@ -14,8 +13,6 @@ export declare type BaseSelectProps = ListboxProps & Omit<ComboboxProps, 'inline
|
|
14
13
|
* All the selected values will be combined in a comma-seperated string as the value of the input.
|
15
14
|
*/
|
16
15
|
multiselect?: boolean;
|
17
|
-
/** Optionally shows the icon for the selected option */
|
18
|
-
showSelectedIcon?: boolean;
|
19
16
|
};
|
20
17
|
export declare type SelectProps = BaseSelectProps & {
|
21
18
|
/**
|
@@ -40,8 +37,6 @@ export declare const Select: React.ForwardRefExoticComponent<Pick<React.InputHTM
|
|
40
37
|
* All the selected values will be combined in a comma-seperated string as the value of the input.
|
41
38
|
*/
|
42
39
|
multiselect?: boolean | undefined;
|
43
|
-
/** Optionally shows the icon for the selected option */
|
44
|
-
showSelectedIcon?: boolean | undefined;
|
45
40
|
} & {
|
46
41
|
/**
|
47
42
|
* Creates an editable select.
|
@@ -1,15 +1,16 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { SelectProps } from './Select';
|
3
3
|
import { ListboxProps } from '../Listbox/Listbox';
|
4
|
-
import { PopoverStateReturn, PopoverHTMLProps } from 'reakit/Popover';
|
5
4
|
declare type useSelect = React.HtmlHTMLAttributes<HTMLDivElement> & {
|
6
5
|
button: React.ButtonHTMLAttributes<HTMLButtonElement>;
|
7
6
|
listbox: ListboxProps;
|
8
|
-
|
9
|
-
|
7
|
+
input: any;
|
8
|
+
popover: {
|
9
|
+
open: boolean;
|
10
|
+
onOpenChange: (open: boolean) => void;
|
10
11
|
};
|
11
12
|
text: string | JSX.Element;
|
12
13
|
more?: number;
|
13
14
|
};
|
14
|
-
export declare const useSelect: ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, data, disabled, emptyValue, id: nativeId, multiselect, onClick,
|
15
|
+
export declare const useSelect: ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, data, defaultValue, disabled, emptyValue, id: nativeId, multiselect, onClick, onChange, readOnly, value, ...otherProps }: SelectProps, ref: React.Ref<HTMLInputElement>) => useSelect;
|
15
16
|
export {};
|
package/dist/esm/index.css
CHANGED
@@ -357,20 +357,11 @@
|
|
357
357
|
@apply font-semibold;
|
358
358
|
}
|
359
359
|
|
360
|
-
[data-taco='scrollable-list'][disabled] {
|
361
|
-
@apply pointer-events-none;
|
362
|
-
}
|
363
|
-
|
364
|
-
[data-taco='scrollable-list'][disabled],
|
365
|
-
[data-taco='scrollable-list'][readonly] {
|
366
|
-
@apply cursor-not-allowed;
|
367
|
-
}
|
368
|
-
|
369
360
|
[data-taco='scrollable-list'].yt-list--multiselect li:first-child {
|
370
|
-
@apply
|
361
|
+
@apply border-grey-light border-b-2 pl-4; /* Listbox max-height is dependant on this border-bottom-width value! */
|
371
362
|
}
|
372
363
|
|
373
|
-
[data-taco='scrollable-list'] li [data-taco='icon'] {
|
364
|
+
[data-taco='scrollable-list'] li > [data-taco='icon'] {
|
374
365
|
@apply mr-2;
|
375
366
|
}
|
376
367
|
|
@@ -406,29 +397,19 @@
|
|
406
397
|
[data-taco='scrollable-list'] li.yt-list__empty,
|
407
398
|
[data-taco='scrollable-list'] li.yt-list__empty:hover,
|
408
399
|
[data-taco='scrollable-list'] li.yt-list__empty:focus {
|
409
|
-
@apply
|
400
|
+
@apply text-grey-darkest overflow-hidden bg-white italic;
|
410
401
|
}
|
411
402
|
|
412
403
|
[data-taco='scrollable-list'] li.yt-list__empty [data-taco='spinner'] {
|
413
404
|
@apply mr-2 mt-2 h-5 w-5 opacity-75;
|
414
405
|
}
|
415
406
|
|
416
|
-
|
417
|
-
@apply yt-transparent text-grey-darkest border-0 shadow-none;
|
418
|
-
}
|
419
|
-
|
420
|
-
.yt-combobox.yt-combobox--inline .yt-input__container > .yt-button:hover,
|
421
|
-
.yt-combobox.yt-combobox--inline .yt-input__container > .yt-button:active,
|
422
|
-
.yt-combobox.yt-combobox--inline .yt-input__container > .yt-button:focus {
|
423
|
-
@apply yt-transparent text-black;
|
424
|
-
}
|
425
|
-
|
426
|
-
.yt-combobox [role='dialog'] {
|
407
|
+
[data-taco='combobox'] [role='dialog'] {
|
427
408
|
@apply z-50;
|
428
409
|
}
|
429
410
|
|
430
|
-
|
431
|
-
|
411
|
+
[data-taco='combobox'] > [aria-expanded='true'] + [role='dialog'] > ul,
|
412
|
+
[data-taco='combobox'] > [aria-expanded='true'] + [role='dialog'] > ul:hover {
|
432
413
|
@apply border-blue;
|
433
414
|
}
|
434
415
|
|
@@ -453,22 +434,6 @@
|
|
453
434
|
min-height: 0;
|
454
435
|
}
|
455
436
|
|
456
|
-
.yt-listbox {
|
457
|
-
@apply relative inline-flex w-full bg-white;
|
458
|
-
}
|
459
|
-
|
460
|
-
.yt-listbox > input {
|
461
|
-
display: none;
|
462
|
-
}
|
463
|
-
|
464
|
-
.yt-listbox [data-taco='scrollable-list'] {
|
465
|
-
max-height: calc(12rem + 2px); /* (6 * option height) + listbox border */
|
466
|
-
}
|
467
|
-
|
468
|
-
.yt-listbox [data-taco='scrollable-list'].yt-list--multiselect {
|
469
|
-
max-height: calc(12rem + 2px + 2px); /* (6 * option height) + listbox border + ALL_OPTIONS bottom border */
|
470
|
-
}
|
471
|
-
|
472
437
|
.yt-navigation__item a,
|
473
438
|
.yt-navigation__item .yt-navigation__item__postfix {
|
474
439
|
@apply text-black;
|
@@ -508,43 +473,6 @@
|
|
508
473
|
@apply border-white text-white;
|
509
474
|
}
|
510
475
|
|
511
|
-
[data-taco='select'] > button.yt-input {
|
512
|
-
@apply relative inline-flex w-full items-center px-0;
|
513
|
-
}
|
514
|
-
|
515
|
-
[data-taco='select'] > button.yt-input > span:first-child {
|
516
|
-
@apply flex-grow truncate pl-2 text-left;
|
517
|
-
}
|
518
|
-
|
519
|
-
[data-taco='select'] > button.yt-input .yt-icon {
|
520
|
-
@apply pointer-events-none;
|
521
|
-
}
|
522
|
-
|
523
|
-
[data-taco='select'] > button.yt-input[disabled] .yt-icon {
|
524
|
-
@apply text-grey-dark;
|
525
|
-
}
|
526
|
-
|
527
|
-
[data-taco='select'][data-taco='select']--readonly > button.yt-input {
|
528
|
-
@apply cursor-not-allowed;
|
529
|
-
}
|
530
|
-
|
531
|
-
[data-taco='select'] > button.yt-input[aria-expanded='true'],
|
532
|
-
[data-taco='select'] > button.yt-input[aria-expanded='true']:hover {
|
533
|
-
@apply border-blue;
|
534
|
-
}
|
535
|
-
|
536
|
-
[data-taco='select'] > button.yt-input[aria-expanded='true'] + .yt-listbox {
|
537
|
-
@apply mt-1 flex;
|
538
|
-
}
|
539
|
-
|
540
|
-
[data-taco='select'] [role='dialog'] {
|
541
|
-
@apply z-50;
|
542
|
-
}
|
543
|
-
|
544
|
-
[data-taco='select'] .yt-list {
|
545
|
-
max-width: theme('spacing.96');
|
546
|
-
}
|
547
|
-
|
548
476
|
.yt-toast:hover [data-taco='progress-bar'] {
|
549
477
|
animation-play-state: paused;
|
550
478
|
}
|
@@ -1,15 +1,14 @@
|
|
1
1
|
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
2
2
|
import { forwardRef, useRef, createElement } from 'react';
|
3
3
|
import cn from 'classnames';
|
4
|
+
import { Root, Anchor, Content } from '@radix-ui/react-popover';
|
4
5
|
import { IconButton } from '../IconButton/IconButton.js';
|
5
|
-
import { PopoverDisclosure, Popover } from 'reakit/Popover';
|
6
6
|
import { Input } from '../Input/Input.js';
|
7
7
|
import { ScrollableList } from '../Listbox/ScrollableList.js';
|
8
8
|
import { useCombobox } from './useCombobox.js';
|
9
9
|
import { useBoundingClientRectListener } from '../../utils/hooks/useBoundingClientRectListener.js';
|
10
10
|
|
11
|
-
var _excluded = ["className", "style"]
|
12
|
-
_excluded2 = ["container"];
|
11
|
+
var _excluded = ["className", "style"];
|
13
12
|
var Combobox = /*#__PURE__*/forwardRef(function Combobox(props, ref) {
|
14
13
|
var externalClassName = props.className,
|
15
14
|
style = props.style,
|
@@ -21,9 +20,6 @@ var Combobox = /*#__PURE__*/forwardRef(function Combobox(props, ref) {
|
|
21
20
|
popover = _useCombobox.popover,
|
22
21
|
list = _useCombobox.list;
|
23
22
|
|
24
|
-
var container = popover.container,
|
25
|
-
base = _objectWithoutPropertiesLoose(popover, _excluded2);
|
26
|
-
|
27
23
|
var internalRef = useRef(null);
|
28
24
|
var selectDimensions = useBoundingClientRectListener(internalRef);
|
29
25
|
var className = cn('inline-flex relative', {
|
@@ -33,28 +29,36 @@ var Combobox = /*#__PURE__*/forwardRef(function Combobox(props, ref) {
|
|
33
29
|
className: className,
|
34
30
|
"data-taco": "combobox",
|
35
31
|
style: style
|
36
|
-
}, createElement(
|
32
|
+
}, createElement(Root, Object.assign({}, popover), createElement(Anchor, {
|
33
|
+
asChild: true,
|
37
34
|
ref: internalRef
|
38
|
-
}
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
}
|
50
|
-
|
51
|
-
|
52
|
-
|
35
|
+
}, createElement("div", Object.assign({}, combobox, {
|
36
|
+
className: "inline w-full",
|
37
|
+
ref: ref
|
38
|
+
}), createElement(Input, Object.assign({}, input, {
|
39
|
+
autoComplete: "off",
|
40
|
+
button: props.inline ? createElement(IconButton, {
|
41
|
+
appearance: "discrete",
|
42
|
+
className: "focus:!border-none focus:!shadow-none active:!border-none",
|
43
|
+
icon: popover.open ? 'chevron-up' : 'chevron-down',
|
44
|
+
onClick: function onClick() {
|
45
|
+
return popover.onOpenChange(true);
|
46
|
+
},
|
47
|
+
tabIndex: -1
|
48
|
+
}) : props.button
|
49
|
+
})))), createElement(Content, {
|
50
|
+
align: "start",
|
51
|
+
onOpenAutoFocus: function onOpenAutoFocus(event) {
|
52
|
+
event.preventDefault();
|
53
|
+
},
|
54
|
+
sideOffset: 4
|
55
|
+
}, createElement(ScrollableList, Object.assign({}, list, {
|
56
|
+
className: cn('border-blue max-h-[calc(12rem+2px)] w-auto max-w-[theme(spacing.96)]'),
|
53
57
|
style: {
|
54
58
|
minWidth: selectDimensions === null || selectDimensions === void 0 ? void 0 : selectDimensions.width
|
55
59
|
},
|
56
|
-
tabIndex: popover.
|
57
|
-
}))));
|
60
|
+
tabIndex: popover.open ? 0 : -1
|
61
|
+
})))));
|
58
62
|
});
|
59
63
|
|
60
64
|
export { Combobox };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Combobox.js","sources":["../../../../../src/components/Combobox/Combobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport
|
1
|
+
{"version":3,"file":"Combobox.js","sources":["../../../../../src/components/Combobox/Combobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { Input, InputProps } from '../Input/Input';\nimport { useCombobox } from './useCombobox';\nimport { ScrollableList, ScrollableListItem, ScrollableListItemValue } from '../Listbox/ScrollableList';\nimport { useBoundingClientRectListener } from '../../utils/hooks/useBoundingClientRectListener';\nimport { IconButton } from '../IconButton/IconButton';\nimport { State } from '../../types';\nimport './Combobox.css';\n\nexport type ComboboxItem = ScrollableListItem;\nexport type ComboboxValue = ScrollableListItemValue;\n\nexport type ComboboxProps = Omit<InputProps, 'defaultValue' | 'onChange' | 'value'> & {\n /** Array of options in combobox */\n data?: ComboboxItem[];\n /**\n * Initial value of the input in combobox.\n * This is used when combobox is mounted, if no value is provided.\n * *Note* that combobox is a controlled component, setting this will also trigger the `onChange` event\n */\n defaultValue?: ComboboxValue;\n /** Set what value should have an empty option in combobox */\n emptyValue?: ComboboxValue;\n /** Draws attention to the combobox by changing its style and making it visually prominent */\n highlighted?: boolean;\n /**\n * Combobox will display its data when input is clicked/focused, even if the input is empty.\n * *Note* that default combobox will display matching data only when user starts typing in input.\n */\n inline?: boolean; // Example 3 on https://www.w3.org/TR/wai-aria-practices/examples/combobox/aria1.1pattern/listbox-combo.html\n /** Displays loading state in listbox */\n loading?: boolean;\n /**\n * Handler called when user chooses an option from the provided suggestions.\n * Suggestions will be calculated based on the input value.\n * There are two ways to choose an option: either click on it, or navigate using keyboard and press `enter`\n */\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n /** State will change the style of the combobox **/\n state?: State;\n /** Value of the input in combobox */\n value?: ComboboxValue;\n};\n\nexport const Combobox = React.forwardRef(function Combobox(props: ComboboxProps, ref: React.Ref<HTMLInputElement>) {\n const { className: externalClassName, style, ...otherProps } = props;\n const { combobox, input, popover, list } = useCombobox(otherProps, ref);\n const internalRef = React.useRef<HTMLDivElement>(null);\n const selectDimensions = useBoundingClientRectListener(internalRef);\n const className = cn(\n 'inline-flex relative',\n {\n 'yt-combobox--inline': props.inline,\n },\n externalClassName\n );\n\n return (\n <span className={className} data-taco=\"combobox\" style={style}>\n <PopoverPrimitive.Root {...popover}>\n <PopoverPrimitive.Anchor asChild ref={internalRef}>\n <div {...combobox} className=\"inline w-full\" ref={ref}>\n <Input\n {...input}\n autoComplete=\"off\"\n button={\n props.inline ? (\n <IconButton\n appearance=\"discrete\"\n className=\"focus:!border-none focus:!shadow-none active:!border-none\"\n icon={popover.open ? 'chevron-up' : 'chevron-down'}\n onClick={() => popover.onOpenChange(true)}\n tabIndex={-1}\n />\n ) : (\n props.button\n )\n }\n />\n </div>\n </PopoverPrimitive.Anchor>\n <PopoverPrimitive.Content\n align=\"start\"\n onOpenAutoFocus={event => {\n event.preventDefault();\n }}\n sideOffset={4}\n >\n <ScrollableList\n {...list}\n className={cn('border-blue max-h-[calc(12rem+2px)] w-auto max-w-[theme(spacing.96)]')}\n style={{ minWidth: selectDimensions?.width }}\n tabIndex={popover.open ? 0 : -1}\n />\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Root>\n </span>\n );\n});\n"],"names":["Combobox","React","props","ref","externalClassName","className","style","otherProps","useCombobox","combobox","input","popover","list","internalRef","selectDimensions","useBoundingClientRectListener","cn","inline","PopoverPrimitive","asChild","Input","autoComplete","button","IconButton","appearance","icon","open","onClick","onOpenChange","tabIndex","align","onOpenAutoFocus","event","preventDefault","sideOffset","ScrollableList","minWidth","width"],"mappings":";;;;;;;;;;;IA8CaA,QAAQ,gBAAGC,UAAA,CAAiB,SAASD,QAAT,CAAkBE,KAAlB,EAAwCC,GAAxC;AACrC,MAAmBC,iBAAnB,GAA+DF,KAA/D,CAAQG,SAAR;AAAA,MAAsCC,KAAtC,GAA+DJ,KAA/D,CAAsCI,KAAtC;AAAA,MAAgDC,UAAhD,iCAA+DL,KAA/D;;AACA,qBAA2CM,WAAW,CAACD,UAAD,EAAaJ,GAAb,CAAtD;AAAA,MAAQM,QAAR,gBAAQA,QAAR;AAAA,MAAkBC,KAAlB,gBAAkBA,KAAlB;AAAA,MAAyBC,OAAzB,gBAAyBA,OAAzB;AAAA,MAAkCC,IAAlC,gBAAkCA,IAAlC;;AACA,MAAMC,WAAW,GAAGZ,MAAA,CAA6B,IAA7B,CAApB;AACA,MAAMa,gBAAgB,GAAGC,6BAA6B,CAACF,WAAD,CAAtD;AACA,MAAMR,SAAS,GAAGW,EAAE,CAChB,sBADgB,EAEhB;AACI,2BAAuBd,KAAK,CAACe;AADjC,GAFgB,EAKhBb,iBALgB,CAApB;AAQA,SACIH,aAAA,OAAA;AAAMI,IAAAA,SAAS,EAAEA;iBAAqB;AAAWC,IAAAA,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PropertiesLoose, extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
2
|
+
import { useRef, useState, useMemo, useEffect } from 'react';
|
3
3
|
import { v4 } from 'uuid';
|
4
4
|
import { useProxiedRef } from '../../utils/hooks/useProxiedRef.js';
|
5
|
-
import { usePopoverState } from 'reakit/Popover';
|
6
5
|
import keycode from 'keycode';
|
7
6
|
import { getId } from '../Listbox/ScrollableList.js';
|
8
7
|
import { createCustomKeyboardEvent } from '../../utils/input.js';
|
@@ -15,8 +14,7 @@ var convertToInputValue = function convertToInputValue(value) {
|
|
15
14
|
};
|
16
15
|
|
17
16
|
var useCombobox = function useCombobox(_ref, ref) {
|
18
|
-
var
|
19
|
-
ariaLabelledBy = _ref['aria-labelledby'],
|
17
|
+
var ariaLabelledBy = _ref['aria-labelledby'],
|
20
18
|
_ref$data = _ref.data,
|
21
19
|
unfilteredData = _ref$data === void 0 ? [] : _ref$data,
|
22
20
|
defaultValue = _ref.defaultValue,
|
@@ -31,17 +29,18 @@ var useCombobox = function useCombobox(_ref, ref) {
|
|
31
29
|
|
32
30
|
var inputRef = useProxiedRef(ref);
|
33
31
|
var listRef = useRef(null);
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
|
33
|
+
var _React$useState = useState(false),
|
34
|
+
open = _React$useState[0],
|
35
|
+
setOpen = _React$useState[1];
|
36
|
+
|
38
37
|
var listId = useMemo(function () {
|
39
38
|
return v4();
|
40
39
|
}, []);
|
41
40
|
|
42
|
-
var _React$
|
43
|
-
inputValue = _React$
|
44
|
-
setInputValue = _React$
|
41
|
+
var _React$useState2 = useState(convertToInputValue(value)),
|
42
|
+
inputValue = _React$useState2[0],
|
43
|
+
setInputValue = _React$useState2[1];
|
45
44
|
|
46
45
|
var shouldFilterData = !inline || inline && inputValue !== convertToInputValue(value);
|
47
46
|
var flattenedData = useFlattenedData(unfilteredData);
|
@@ -49,9 +48,9 @@ var useCombobox = function useCombobox(_ref, ref) {
|
|
49
48
|
return shouldFilterData ? filterData(flattenedData, inputValue) : flattenedData;
|
50
49
|
}, [shouldFilterData, inputValue, flattenedData]); // listbox/select change value _with_ the index, but combobox changes on select of an index (click/enter), so we need state
|
51
50
|
|
52
|
-
var _React$
|
53
|
-
currentIndex = _React$
|
54
|
-
setCurrentIndex = _React$
|
51
|
+
var _React$useState3 = useState(inputValue !== undefined ? getIndexFromValue(data, inputValue) : undefined),
|
52
|
+
currentIndex = _React$useState3[0],
|
53
|
+
setCurrentIndex = _React$useState3[1];
|
55
54
|
|
56
55
|
var setInputValueByIndex = function setInputValueByIndex(index) {
|
57
56
|
if (index !== undefined) {
|
@@ -99,20 +98,20 @@ var useCombobox = function useCombobox(_ref, ref) {
|
|
99
98
|
if (inputValue && data.length && !isCurrentValue) {
|
100
99
|
setCurrentIndex(0);
|
101
100
|
|
102
|
-
if (!
|
103
|
-
|
101
|
+
if (!open) {
|
102
|
+
setOpen(true);
|
104
103
|
}
|
105
104
|
} else {
|
106
|
-
|
105
|
+
setOpen(false);
|
107
106
|
}
|
108
107
|
}, [inputValue, data]);
|
109
108
|
useEffect(function () {
|
110
|
-
if (
|
109
|
+
if (open) {
|
111
110
|
setCurrentIndex(getIndexFromValue(data, inputValue) || 0);
|
112
111
|
} else {
|
113
112
|
setCurrentIndex(undefined);
|
114
113
|
}
|
115
|
-
}, [
|
114
|
+
}, [open]); // event handlers
|
116
115
|
|
117
116
|
var handleInputBlur = function handleInputBlur(event) {
|
118
117
|
event.persist();
|
@@ -144,8 +143,8 @@ var useCombobox = function useCombobox(_ref, ref) {
|
|
144
143
|
};
|
145
144
|
|
146
145
|
var handleInputClick = function handleInputClick(event) {
|
147
|
-
if (inline || !
|
148
|
-
|
146
|
+
if (inline || !open && inputValue && data.length) {
|
147
|
+
setOpen(true);
|
149
148
|
}
|
150
149
|
|
151
150
|
if (onClick) {
|
@@ -167,7 +166,7 @@ var useCombobox = function useCombobox(_ref, ref) {
|
|
167
166
|
{
|
168
167
|
event.preventDefault();
|
169
168
|
setInputValue(convertToInputValue(value));
|
170
|
-
|
169
|
+
setOpen(false);
|
171
170
|
return;
|
172
171
|
}
|
173
172
|
|
@@ -179,7 +178,7 @@ var useCombobox = function useCombobox(_ref, ref) {
|
|
179
178
|
}
|
180
179
|
|
181
180
|
setCurrentValue(currentIndex);
|
182
|
-
|
181
|
+
setOpen(false);
|
183
182
|
return;
|
184
183
|
}
|
185
184
|
|
@@ -188,7 +187,7 @@ var useCombobox = function useCombobox(_ref, ref) {
|
|
188
187
|
case keycode('home'):
|
189
188
|
case keycode('end'):
|
190
189
|
{
|
191
|
-
if (
|
190
|
+
if (open) {
|
192
191
|
event.preventDefault();
|
193
192
|
}
|
194
193
|
|
@@ -201,12 +200,12 @@ var useCombobox = function useCombobox(_ref, ref) {
|
|
201
200
|
listRef.current.dispatchEvent(createCustomKeyboardEvent(event));
|
202
201
|
}
|
203
202
|
|
204
|
-
if (inline && !
|
203
|
+
if (inline && !open) {
|
205
204
|
if (event.keyCode === keycode('up') || event.keyCode === keycode('down')) {
|
206
205
|
event.preventDefault();
|
207
206
|
var initialIndex = event.keyCode === keycode('up') ? data.length - 1 : 0;
|
208
207
|
setCurrentIndex(currentIndex !== undefined ? currentIndex : initialIndex);
|
209
|
-
|
208
|
+
setOpen(true);
|
210
209
|
}
|
211
210
|
}
|
212
211
|
|
@@ -223,11 +222,11 @@ var useCombobox = function useCombobox(_ref, ref) {
|
|
223
222
|
var handleListboxClick = function handleListboxClick(event, index) {
|
224
223
|
event.preventDefault();
|
225
224
|
setCurrentValue(index);
|
226
|
-
|
225
|
+
setOpen(false);
|
227
226
|
};
|
228
227
|
|
229
228
|
var combobox = {
|
230
|
-
'aria-expanded':
|
229
|
+
'aria-expanded': open,
|
231
230
|
'aria-owns': listId,
|
232
231
|
'aria-haspopup': 'listbox',
|
233
232
|
role: 'combobox'
|
@@ -268,15 +267,10 @@ var useCombobox = function useCombobox(_ref, ref) {
|
|
268
267
|
combobox: combobox,
|
269
268
|
input: input,
|
270
269
|
list: list,
|
271
|
-
popover:
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
'aria-label': ariaLabel,
|
276
|
-
'aria-labelledby': ariaLabelledBy,
|
277
|
-
unstable_initialFocusRef: inputRef
|
278
|
-
}
|
279
|
-
})
|
270
|
+
popover: {
|
271
|
+
open: open,
|
272
|
+
onOpenChange: setOpen
|
273
|
+
}
|
280
274
|
};
|
281
275
|
};
|
282
276
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useCombobox.js","sources":["../../../../../src/components/Combobox/useCombobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport keycode from 'keycode';\nimport { v4 as uuid } from 'uuid';\nimport { PopoverHTMLProps, PopoverStateReturn, usePopoverState } from 'reakit/Popover';\nimport { ComboboxProps } from './Combobox';\nimport {\n setInputValueByRef,\n getIndexFromValue,\n findByValue,\n useFlattenedData,\n sanitizeItem,\n getOptionParents,\n filterData,\n} from '../Listbox/util';\nimport { createCustomKeyboardEvent } from '../../utils/input';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\nimport { getId, ScrollableListItemValue, ScrollableListPropsWithRef } from '../Listbox/ScrollableList';\n\nconst convertToInputValue = (value: ScrollableListItemValue | undefined) => String(value ?? '');\n\ntype useCombobox = React.HTMLAttributes<HTMLDivElement> & {\n combobox: React.HTMLAttributes<HTMLSpanElement>;\n input: Omit<React.HTMLAttributes<HTMLInputElement>, 'defaultValue'> & { ref: React.RefObject<HTMLInputElement> };\n list: ScrollableListPropsWithRef;\n popover: PopoverStateReturn & { container: PopoverHTMLProps };\n};\n\nexport const useCombobox = (\n {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data: unfilteredData = [],\n defaultValue,\n disabled,\n id: nativeId,\n inline,\n loading: __,\n onChange,\n onClick,\n onKeyDown,\n readOnly,\n value,\n ...props\n }: ComboboxProps,\n ref: React.Ref<HTMLInputElement>\n): useCombobox => {\n const inputRef = useProxiedRef<HTMLInputElement>(ref);\n const listRef = React.useRef<HTMLUListElement>(null);\n const popover = usePopoverState({ gutter: 4, placement: 'bottom-start' });\n const listId = React.useMemo(() => uuid(), []);\n const [inputValue, setInputValue] = React.useState<string>(convertToInputValue(value));\n const shouldFilterData = !inline || (inline && inputValue !== convertToInputValue(value));\n const flattenedData = useFlattenedData(unfilteredData);\n const data = React.useMemo(\n () => (shouldFilterData ? filterData(flattenedData, inputValue) : flattenedData),\n [shouldFilterData, inputValue, flattenedData]\n );\n // listbox/select change value _with_ the index, but combobox changes on select of an index (click/enter), so we need state\n const [currentIndex, setCurrentIndex] = React.useState<number | undefined>(\n inputValue !== undefined ? getIndexFromValue(data, inputValue) : undefined\n );\n\n const setInputValueByIndex = (index: number | undefined): void => {\n if (index !== undefined) {\n const option = data[index];\n\n if (option && !option.disabled) {\n setInputValueByRef(inputRef.current, option.value, 'focusout');\n }\n }\n };\n\n const setCurrentValue = (index: number | undefined) => {\n if (index === undefined) {\n return;\n }\n\n const option = data[index];\n\n // if the selected option is not already selected, trigger blur event\n if (option.value !== value) {\n setInputValueByIndex(index);\n } else {\n // if the selected option is already selected, refill input with its value\n setInputValue(convertToInputValue(value));\n }\n };\n\n // ensure the external value is synced with the internal value when mounting, e.g. incase a default value was set\n React.useEffect(() => {\n if (defaultValue && !value) {\n setInputValueByIndex(getIndexFromValue(data, defaultValue));\n }\n }, [data]);\n\n // update input value if it changed 'externally', e.g. clicking/entering an item in the listbox, from a modal etc\n React.useEffect(() => {\n if (value !== undefined && value !== inputValue) {\n setInputValue(convertToInputValue(value));\n }\n }, [value]);\n\n // show listbox based on input value\n React.useEffect(() => {\n // don't show the popover if the internal (input) value already is the current value\n // this prevents the popover showing after selecting a value or pressing escape\n const isCurrentValue = value !== undefined && value !== null && inputValue === String(value);\n\n if (inputValue && data.length && !isCurrentValue) {\n setCurrentIndex(0);\n\n if (!popover.visible) {\n popover.show();\n }\n } else {\n popover.hide();\n }\n }, [inputValue, data]);\n\n React.useEffect(() => {\n if (popover.visible) {\n setCurrentIndex(getIndexFromValue(data, inputValue) || 0);\n } else {\n setCurrentIndex(undefined);\n }\n }, [popover.visible]);\n\n // event handlers\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (event.relatedTarget === listRef.current) {\n event.preventDefault();\n return;\n }\n\n if (onChange && event.target.value !== value) {\n const item = findByValue(flattenedData, event.target.value);\n (event as any).detail = sanitizeItem(item);\n\n const parents = getOptionParents(flattenedData, item?.path);\n\n if (parents !== null && parents.length > 0) {\n (event as any).detail.parents = parents;\n }\n\n onChange(event);\n }\n\n if (props.onBlur) {\n props.onBlur(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setInputValue(event.target.value);\n };\n\n const handleInputClick = (event: React.MouseEvent<HTMLInputElement>): void => {\n if (inline || (!popover.visible && inputValue && data.length)) {\n popover.show();\n }\n\n if (onClick) {\n event.persist();\n onClick(event);\n }\n };\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>): void => {\n event.persist();\n\n switch (event.keyCode) {\n case keycode('backspace'): {\n return;\n }\n\n case keycode('escape'): {\n event.preventDefault();\n setInputValue(convertToInputValue(value));\n popover.hide();\n return;\n }\n\n case keycode('tab'):\n case keycode('enter'): {\n if (event.keyCode !== keycode('tab')) {\n event.preventDefault();\n }\n\n setCurrentValue(currentIndex);\n popover.hide();\n return;\n }\n\n case keycode('up'):\n case keycode('down'):\n case keycode('home'):\n case keycode('end'): {\n if (popover.visible) {\n event.preventDefault();\n }\n break;\n }\n\n default:\n }\n\n // we aren't focused on the list, so manually forward the keydown event to it\n if (listRef.current) {\n listRef.current.dispatchEvent(createCustomKeyboardEvent(event));\n }\n\n if (inline && !popover.visible) {\n if (event.keyCode === keycode('up') || event.keyCode === keycode('down')) {\n event.preventDefault();\n const initialIndex = event.keyCode === keycode('up') ? data.length - 1 : 0;\n setCurrentIndex(currentIndex !== undefined ? currentIndex : initialIndex);\n popover.show();\n }\n }\n\n if (!event.isDefaultPrevented() && onKeyDown) {\n event.persist();\n onKeyDown(event);\n }\n };\n\n const handleListboxChange = (index: number): void => {\n setCurrentIndex(index);\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>, index: number): void => {\n event.preventDefault();\n setCurrentValue(index);\n popover.hide();\n };\n\n const combobox = {\n 'aria-expanded': popover.visible,\n 'aria-owns': listId,\n 'aria-haspopup': 'listbox' as const,\n role: 'combobox',\n };\n\n const input = {\n ...props,\n 'aria-controls': listId,\n // Indicates that the autocomplete behavior of the text input is to suggest a list of possible values in a popup and that the suggestions\n // are related to the string that is present in the textbox\n 'aria-autocomplete': 'list' as const,\n // Enables assistive technologies to know which element the application regards as focused while DOM focus remains on the input element\n 'aria-activedescendant':\n currentIndex !== undefined && data[currentIndex] ? getId(listId, String(data[currentIndex].value)) : undefined,\n 'aria-labelledby': ariaLabelledBy,\n disabled,\n onBlur: !disabled && !readOnly ? handleInputBlur : undefined,\n onChange: !disabled && !readOnly ? handleInputChange : undefined,\n onClick: !disabled && !readOnly ? handleInputClick : undefined,\n onKeyDown: !disabled && !readOnly ? handleInputKeyDown : undefined,\n readOnly,\n ref: inputRef,\n type: 'text',\n value: inputValue || '',\n };\n\n const list: ScrollableListPropsWithRef = {\n 'aria-labelledby': ariaLabelledBy,\n data,\n disabled,\n id: listId,\n onChange: handleListboxChange,\n onClick: handleListboxClick,\n ref: listRef,\n scrollOnFocus: false,\n tabIndex: -1,\n value: currentIndex,\n };\n\n return {\n combobox,\n input,\n list,\n popover: {\n ...popover,\n visible: !data.length ? false : popover.visible,\n container: {\n tabIndex: -1,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n unstable_initialFocusRef: inputRef,\n },\n },\n };\n};\n"],"names":["convertToInputValue","value","String","useCombobox","ref","ariaLabel","ariaLabelledBy","data","unfilteredData","defaultValue","disabled","inline","onChange","onClick","onKeyDown","readOnly","props","inputRef","useProxiedRef","listRef","React","popover","usePopoverState","gutter","placement","listId","uuid","inputValue","setInputValue","shouldFilterData","flattenedData","useFlattenedData","filterData","undefined","getIndexFromValue","currentIndex","setCurrentIndex","setInputValueByIndex","index","option","setInputValueByRef","current","setCurrentValue","isCurrentValue","length","visible","show","hide","handleInputBlur","event","persist","relatedTarget","preventDefault","target","item","findByValue","detail","sanitizeItem","parents","getOptionParents","path","onBlur","handleInputChange","handleInputClick","handleInputKeyDown","keyCode","keycode","dispatchEvent","createCustomKeyboardEvent","initialIndex","isDefaultPrevented","handleListboxChange","handleListboxClick","combobox","role","input","getId","type","list","id","scrollOnFocus","tabIndex","container","unstable_initialFocusRef"],"mappings":";;;;;;;;;;;;AAkBA,IAAMA,mBAAmB,GAAG,SAAtBA,mBAAsB,CAACC,KAAD;AAAA,SAAgDC,MAAM,CAACD,KAAD,aAACA,KAAD,cAACA,KAAD,GAAU,EAAV,CAAtD;AAAA,CAA5B;;IASaE,WAAW,GAAG,SAAdA,WAAc,OAiBvBC,GAjBuB;MAELC,iBAAd;MACmBC,sBAAnB;uBACAC;MAAMC,wCAAiB;MACvBC,oBAAAA;MACAC,gBAAAA;MAEAC,cAAAA;MAEAC,gBAAAA;MACAC,eAAAA;MACAC,iBAAAA;MACAC,gBAAAA;MACAd,aAAAA;MACGe;;AAIP,MAAMC,QAAQ,GAAGC,aAAa,CAAmBd,GAAnB,CAA9B;AACA,MAAMe,OAAO,GAAGC,MAAA,CAA+B,IAA/B,CAAhB;AACA,MAAMC,OAAO,GAAGC,eAAe,CAAC;AAAEC,IAAAA,MAAM,EAAE,CAAV;AAAaC,IAAAA,SAAS,EAAE;AAAxB,GAAD,CAA/B;AACA,MAAMC,MAAM,GAAGL,OAAA,CAAc;AAAA,WAAMM,EAAI,EAAV;AAAA,GAAd,EAA4B,EAA5B,CAAf;;AACA,wBAAoCN,QAAA,CAAuBpB,mBAAmB,CAACC,KAAD,CAA1C,CAApC;AAAA,MAAO0B,UAAP;AAAA,MAAmBC,aAAnB;;AACA,MAAMC,gBAAgB,GAAG,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P;AAGP,2BAAmBC,cAHZ;AAIP6E,QAAAA,wBAAwB,EAAElE;AAJnB;AAHR;AAJJ,GAAP;AAeH;;;;"}
|
1
|
+
{"version":3,"file":"useCombobox.js","sources":["../../../../../src/components/Combobox/useCombobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport keycode from 'keycode';\nimport { v4 as uuid } from 'uuid';\nimport { ComboboxProps } from './Combobox';\nimport {\n setInputValueByRef,\n getIndexFromValue,\n findByValue,\n useFlattenedData,\n sanitizeItem,\n getOptionParents,\n filterData,\n} from '../Listbox/util';\nimport { createCustomKeyboardEvent } from '../../utils/input';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\nimport { getId, ScrollableListItemValue, ScrollableListPropsWithRef } from '../Listbox/ScrollableList';\n\nconst convertToInputValue = (value: ScrollableListItemValue | undefined) => String(value ?? '');\n\ntype useCombobox = React.HTMLAttributes<HTMLDivElement> & {\n combobox: React.HTMLAttributes<HTMLSpanElement>;\n input: Omit<React.HTMLAttributes<HTMLInputElement>, 'defaultValue'> & { ref: React.RefObject<HTMLInputElement> };\n list: ScrollableListPropsWithRef;\n popover: { open: boolean; onOpenChange: (open: boolean) => void };\n};\n\nexport const useCombobox = (\n {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data: unfilteredData = [],\n defaultValue,\n disabled,\n id: nativeId,\n inline,\n loading: __,\n onChange,\n onClick,\n onKeyDown,\n readOnly,\n value,\n ...props\n }: ComboboxProps,\n ref: React.Ref<HTMLInputElement>\n): useCombobox => {\n const inputRef = useProxiedRef<HTMLInputElement>(ref);\n const listRef = React.useRef<HTMLUListElement>(null);\n const [open, setOpen] = React.useState(false);\n const listId = React.useMemo(() => uuid(), []);\n const [inputValue, setInputValue] = React.useState<string>(convertToInputValue(value));\n const shouldFilterData = !inline || (inline && inputValue !== convertToInputValue(value));\n const flattenedData = useFlattenedData(unfilteredData);\n const data = React.useMemo(\n () => (shouldFilterData ? filterData(flattenedData, inputValue) : flattenedData),\n [shouldFilterData, inputValue, flattenedData]\n );\n // listbox/select change value _with_ the index, but combobox changes on select of an index (click/enter), so we need state\n const [currentIndex, setCurrentIndex] = React.useState<number | undefined>(\n inputValue !== undefined ? getIndexFromValue(data, inputValue) : undefined\n );\n\n const setInputValueByIndex = (index: number | undefined): void => {\n if (index !== undefined) {\n const option = data[index];\n\n if (option && !option.disabled) {\n setInputValueByRef(inputRef.current, option.value, 'focusout');\n }\n }\n };\n\n const setCurrentValue = (index: number | undefined) => {\n if (index === undefined) {\n return;\n }\n\n const option = data[index];\n\n // if the selected option is not already selected, trigger blur event\n if (option.value !== value) {\n setInputValueByIndex(index);\n } else {\n // if the selected option is already selected, refill input with its value\n setInputValue(convertToInputValue(value));\n }\n };\n\n // ensure the external value is synced with the internal value when mounting, e.g. incase a default value was set\n React.useEffect(() => {\n if (defaultValue && !value) {\n setInputValueByIndex(getIndexFromValue(data, defaultValue));\n }\n }, [data]);\n\n // update input value if it changed 'externally', e.g. clicking/entering an item in the listbox, from a modal etc\n React.useEffect(() => {\n if (value !== undefined && value !== inputValue) {\n setInputValue(convertToInputValue(value));\n }\n }, [value]);\n\n // show listbox based on input value\n React.useEffect(() => {\n // don't show the popover if the internal (input) value already is the current value\n // this prevents the popover showing after selecting a value or pressing escape\n const isCurrentValue = value !== undefined && value !== null && inputValue === String(value);\n\n if (inputValue && data.length && !isCurrentValue) {\n setCurrentIndex(0);\n\n if (!open) {\n setOpen(true);\n }\n } else {\n setOpen(false);\n }\n }, [inputValue, data]);\n\n React.useEffect(() => {\n if (open) {\n setCurrentIndex(getIndexFromValue(data, inputValue) || 0);\n } else {\n setCurrentIndex(undefined);\n }\n }, [open]);\n\n // event handlers\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (event.relatedTarget === listRef.current) {\n event.preventDefault();\n return;\n }\n\n if (onChange && event.target.value !== value) {\n const item = findByValue(flattenedData, event.target.value);\n (event as any).detail = sanitizeItem(item);\n\n const parents = getOptionParents(flattenedData, item?.path);\n\n if (parents !== null && parents.length > 0) {\n (event as any).detail.parents = parents;\n }\n\n onChange(event);\n }\n\n if (props.onBlur) {\n props.onBlur(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setInputValue(event.target.value);\n };\n\n const handleInputClick = (event: React.MouseEvent<HTMLInputElement>): void => {\n if (inline || (!open && inputValue && data.length)) {\n setOpen(true);\n }\n\n if (onClick) {\n event.persist();\n onClick(event);\n }\n };\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>): void => {\n event.persist();\n\n switch (event.keyCode) {\n case keycode('backspace'): {\n return;\n }\n\n case keycode('escape'): {\n event.preventDefault();\n setInputValue(convertToInputValue(value));\n setOpen(false);\n return;\n }\n\n case keycode('tab'):\n case keycode('enter'): {\n if (event.keyCode !== keycode('tab')) {\n event.preventDefault();\n }\n\n setCurrentValue(currentIndex);\n setOpen(false);\n return;\n }\n\n case keycode('up'):\n case keycode('down'):\n case keycode('home'):\n case keycode('end'): {\n if (open) {\n event.preventDefault();\n }\n break;\n }\n\n default:\n }\n\n // we aren't focused on the list, so manually forward the keydown event to it\n if (listRef.current) {\n listRef.current.dispatchEvent(createCustomKeyboardEvent(event));\n }\n\n if (inline && !open) {\n if (event.keyCode === keycode('up') || event.keyCode === keycode('down')) {\n event.preventDefault();\n const initialIndex = event.keyCode === keycode('up') ? data.length - 1 : 0;\n setCurrentIndex(currentIndex !== undefined ? currentIndex : initialIndex);\n setOpen(true);\n }\n }\n\n if (!event.isDefaultPrevented() && onKeyDown) {\n event.persist();\n onKeyDown(event);\n }\n };\n\n const handleListboxChange = (index: number): void => {\n setCurrentIndex(index);\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>, index: number): void => {\n event.preventDefault();\n setCurrentValue(index);\n setOpen(false);\n };\n\n const combobox = {\n 'aria-expanded': open,\n 'aria-owns': listId,\n 'aria-haspopup': 'listbox' as const,\n role: 'combobox',\n };\n\n const input = {\n ...props,\n 'aria-controls': listId,\n // Indicates that the autocomplete behavior of the text input is to suggest a list of possible values in a popup and that the suggestions\n // are related to the string that is present in the textbox\n 'aria-autocomplete': 'list' as const,\n // Enables assistive technologies to know which element the application regards as focused while DOM focus remains on the input element\n 'aria-activedescendant':\n currentIndex !== undefined && data[currentIndex] ? getId(listId, String(data[currentIndex].value)) : undefined,\n 'aria-labelledby': ariaLabelledBy,\n disabled,\n onBlur: !disabled && !readOnly ? handleInputBlur : undefined,\n onChange: !disabled && !readOnly ? handleInputChange : undefined,\n onClick: !disabled && !readOnly ? handleInputClick : undefined,\n onKeyDown: !disabled && !readOnly ? handleInputKeyDown : undefined,\n readOnly,\n ref: inputRef,\n type: 'text',\n value: inputValue || '',\n };\n\n const list: ScrollableListPropsWithRef = {\n 'aria-labelledby': ariaLabelledBy,\n data,\n disabled,\n id: listId,\n onChange: handleListboxChange,\n onClick: handleListboxClick,\n ref: listRef,\n scrollOnFocus: false,\n tabIndex: -1,\n value: currentIndex,\n };\n\n return {\n combobox,\n input,\n list,\n popover: {\n open,\n onOpenChange: setOpen,\n //visible: !data.length ? false : open,\n },\n };\n};\n"],"names":["convertToInputValue","value","String","useCombobox","ref","ariaLabelledBy","data","unfilteredData","defaultValue","disabled","inline","onChange","onClick","onKeyDown","readOnly","props","inputRef","useProxiedRef","listRef","React","open","setOpen","listId","uuid","inputValue","setInputValue","shouldFilterData","flattenedData","useFlattenedData","filterData","undefined","getIndexFromValue","currentIndex","setCurrentIndex","setInputValueByIndex","index","option","setInputValueByRef","current","setCurrentValue","isCurrentValue","length","handleInputBlur","event","persist","relatedTarget","preventDefault","target","item","findByValue","detail","sanitizeItem","parents","getOptionParents","path","onBlur","handleInputChange","handleInputClick","handleInputKeyDown","keyCode","keycode","dispatchEvent","createCustomKeyboardEvent","initialIndex","isDefaultPrevented","handleListboxChange","handleListboxClick","combobox","role","input","getId","type","list","id","scrollOnFocus","tabIndex","popover","onOpenChange"],"mappings":";;;;;;;;;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