@deque/cauldron-react 6.14.0 → 6.15.0-canary.05150a80

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.
@@ -1,7 +1,7 @@
1
- import React, { ButtonHTMLAttributes, Ref } from 'react';
1
+ import React, { type ButtonHTMLAttributes, type Ref } from 'react';
2
2
  export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
3
3
  buttonRef?: Ref<HTMLButtonElement>;
4
- variant?: 'primary' | 'secondary' | 'tertiary' | 'error' | 'link' | 'tag';
4
+ variant?: 'primary' | 'secondary' | 'tertiary' | 'error' | 'link' | 'tag' | 'badge';
5
5
  thin?: boolean;
6
6
  }
7
7
  declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { ContentNode } from '../../types';
3
2
  import ComboboxOption from './ComboboxOption';
3
+ import type { ContentNode } from '../../types';
4
4
  import type { ComboboxValue } from './ComboboxOption';
5
5
  import type { ListboxOption } from '../Listbox/ListboxContext';
6
6
  interface ComboboxOption {
@@ -9,24 +9,42 @@ interface ComboboxOption {
9
9
  value?: ComboboxValue;
10
10
  formValue?: ComboboxValue;
11
11
  description?: string;
12
+ removeOptionLabel?: string;
12
13
  }
13
- interface ComboboxProps extends React.InputHTMLAttributes<Omit<HTMLInputElement, 'value' | 'defaultValue'>> {
14
+ interface BaseComboboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultValue'> {
14
15
  label: ContentNode;
15
16
  options?: ComboboxOption[];
16
- value?: ComboboxValue;
17
- defaultValue?: ComboboxValue;
18
17
  requiredText?: React.ReactNode;
19
18
  error?: React.ReactNode;
20
19
  autocomplete?: 'none' | 'manual' | 'automatic';
21
- onSelectionChange?: <T extends HTMLElement = HTMLElement>({ target, value, previousValue }: {
22
- target: T;
23
- value: ComboboxValue;
24
- previousValue: ComboboxValue;
25
- }) => void;
26
20
  onActiveChange?: (option: ListboxOption) => void;
27
21
  renderNoResults?: (() => React.JSX.Element) | React.ReactElement;
28
22
  portal?: React.RefObject<HTMLElement> | HTMLElement;
29
23
  inputRef?: React.Ref<HTMLInputElement>;
30
24
  }
31
- declare const Combobox: React.ForwardRefExoticComponent<ComboboxProps & React.RefAttributes<HTMLDivElement>>;
25
+ interface SingleSelectComboboxProps extends BaseComboboxProps {
26
+ value?: ComboboxValue;
27
+ defaultValue?: ComboboxValue;
28
+ inputValue?: never;
29
+ defaultInputValue?: never;
30
+ onSelectionChange?: <T extends HTMLElement = HTMLElement>(props: {
31
+ target: T;
32
+ value: ComboboxValue;
33
+ previousValue: ComboboxValue;
34
+ }) => void;
35
+ multiselect?: false;
36
+ }
37
+ interface MultiSelectComboboxProps extends BaseComboboxProps {
38
+ value?: ComboboxValue[];
39
+ defaultValue?: ComboboxValue[];
40
+ inputValue?: ComboboxValue;
41
+ defaultInputValue?: ComboboxValue;
42
+ onSelectionChange?: <T extends HTMLElement = HTMLElement>(props: {
43
+ target: T;
44
+ value: ComboboxValue[];
45
+ previousValue: ComboboxValue[];
46
+ }) => void;
47
+ multiselect: true;
48
+ }
49
+ declare const Combobox: React.ForwardRefExoticComponent<(SingleSelectComboboxProps | MultiSelectComboboxProps) & React.RefAttributes<HTMLDivElement>>;
32
50
  export default Combobox;
@@ -3,22 +3,25 @@ import { ComboboxValue } from './ComboboxOption';
3
3
  type ComboboxContext = {
4
4
  autocomplete: 'none' | 'manual' | 'automatic';
5
5
  inputValue: ComboboxValue;
6
- formValue: ComboboxValue;
7
- selectedValue: ComboboxValue;
6
+ formValues: ComboboxValue[];
7
+ selectedValues: ComboboxValue[];
8
+ removeOptionLabels: string[];
9
+ setRemoveOptionLabels: React.Dispatch<React.SetStateAction<string[]>>;
8
10
  matchingOptions: Map<HTMLElement, ComboboxOptionState>;
9
11
  setMatchingOptions: React.Dispatch<React.SetStateAction<Map<HTMLElement, ComboboxOptionState>>>;
10
- setFormValue: React.Dispatch<React.SetStateAction<ComboboxValue>>;
12
+ setFormValues: React.Dispatch<React.SetStateAction<ComboboxValue[]>>;
11
13
  matches: (<T extends string = string>(value: T) => boolean) | boolean;
12
14
  };
13
15
  export type ComboboxOptionState = {
14
16
  selected: boolean;
15
17
  value: ComboboxValue;
18
+ displayValue: ComboboxValue;
16
19
  };
17
20
  type ComboboxProvider = {
18
21
  children: React.ReactNode;
19
22
  matches: ((inputValue: string, value: string) => boolean) | boolean;
20
23
  } & Omit<ComboboxContext, 'matches'>;
21
24
  declare const ComboboxContext: React.Context<ComboboxContext>;
22
- declare function ComboboxProvider({ autocomplete, inputValue, formValue, selectedValue, matches, matchingOptions, setMatchingOptions, setFormValue, children }: ComboboxProvider): React.JSX.Element;
25
+ declare function ComboboxProvider({ autocomplete, inputValue, formValues, selectedValues, removeOptionLabels, setRemoveOptionLabels, matches, matchingOptions, setMatchingOptions, setFormValues, children }: ComboboxProvider): React.JSX.Element;
23
26
  declare function useComboboxContext(): ComboboxContext;
24
27
  export { ComboboxProvider, useComboboxContext };
@@ -7,6 +7,7 @@ interface ComboboxOptionProps extends React.HTMLAttributes<HTMLLIElement> {
7
7
  value?: ComboboxValue;
8
8
  formValue?: ComboboxValue;
9
9
  description?: ContentNode;
10
+ removeOptionLabel?: string;
10
11
  children: string;
11
12
  }
12
13
  declare const ComboboxOption: React.ForwardRefExoticComponent<ComboboxOptionProps & React.RefAttributes<HTMLLIElement>>;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { ComboboxValue } from './ComboboxOption';
3
+ interface ComboboxPillProps extends React.HTMLAttributes<HTMLButtonElement> {
4
+ value: ComboboxValue;
5
+ removeOptionLabel?: string;
6
+ disabled?: boolean;
7
+ onClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
8
+ }
9
+ declare const ComboboxPill: React.ForwardRefExoticComponent<ComboboxPillProps & React.RefAttributes<HTMLButtonElement>>;
10
+ export default ComboboxPill;
@@ -5,6 +5,7 @@ import type { PolymorphicProps, PolymorphicComponent } from '../../utils/polymor
5
5
  interface BaseListboxProps extends PolymorphicProps<Omit<React.HTMLAttributes<HTMLElement>, 'onSelect' | 'defaultValue'>> {
6
6
  navigation?: 'cycle' | 'bound';
7
7
  onActiveChange?: (option: ListboxOption) => void;
8
+ disabled?: boolean;
8
9
  }
9
10
  interface SingleSelectListboxProps extends BaseListboxProps {
10
11
  multiselect?: false;
package/lib/index.js CHANGED
@@ -960,7 +960,9 @@ var OptionsMenuList = function (_a) {
960
960
  /* eslint-disable jsx-a11y/click-events-have-key-events */
961
961
  /* eslint-disable jsx-a11y/role-supports-aria-props */
962
962
  return (React__default["default"].createElement(ClickOutsideListener$1, { onClickOutside: handleClickOutside, mouseEvent: clickOutsideEventActive, touchEvent: clickOutsideEventActive },
963
- React__default["default"].createElement("ul", tslib.__assign({}, other, { className: classNames__default["default"]('OptionsMenu__list', className), "aria-expanded": show, role: "menu", onClick: handleClick, ref: function (el) {
963
+ React__default["default"].createElement("ul", tslib.__assign({}, other, { className: classNames__default["default"]('OptionsMenu__list', className, {
964
+ 'OptionsMenu--expanded': show
965
+ }), role: "menu", onClick: handleClick, ref: function (el) {
964
966
  menuRefInternal.current = el;
965
967
  if (menuRef) {
966
968
  setRef(menuRef, el);
@@ -1715,7 +1717,7 @@ var SkipLink = /** @class */ (function (_super) {
1715
1717
 
1716
1718
  var Button = React.forwardRef(function (_a, ref) {
1717
1719
  var _b = _a.variant, variant = _b === void 0 ? 'primary' : _b, thin = _a.thin, children = _a.children, className = _a.className, buttonRef = _a.buttonRef, other = tslib.__rest(_a, ["variant", "thin", "children", "className", "buttonRef"]);
1718
- return (React__default["default"].createElement("button", tslib.__assign({ type: 'button', className: classNames__default["default"](className, {
1720
+ return (React__default["default"].createElement("button", tslib.__assign({ type: "button", className: classNames__default["default"](className, {
1719
1721
  'Button--primary': variant === 'primary',
1720
1722
  'Button--secondary': variant === 'secondary',
1721
1723
  'Button--error': variant === 'error',
@@ -1723,7 +1725,8 @@ var Button = React.forwardRef(function (_a, ref) {
1723
1725
  Link: variant === 'link',
1724
1726
  Tag: variant === 'tag',
1725
1727
  'Button--tag': variant === 'tag',
1726
- 'Button--thin': thin
1728
+ 'Button--thin': thin,
1729
+ 'Button--badge': variant === 'badge'
1727
1730
  }), ref: ref || buttonRef }, other), children));
1728
1731
  });
1729
1732
  Button.displayName = 'Button';
@@ -2281,7 +2284,7 @@ var Select = React__default["default"].forwardRef(function (_a, ref) {
2281
2284
  'Field__label--has-error': !!error
2282
2285
  }) },
2283
2286
  React__default["default"].createElement("span", null, label),
2284
- required && (React__default["default"].createElement("span", { className: "Field__required-text" }, requiredText))),
2287
+ required && (React__default["default"].createElement("span", { className: "Field__required-text", "aria-hidden": "true" }, requiredText))),
2285
2288
  React__default["default"].createElement("div", { className: classNames__default["default"]('Field__select--wrapper', {
2286
2289
  'Field__select--disabled': disabled,
2287
2290
  'Field--has-error': !!error
@@ -2606,7 +2609,7 @@ var TextField = /** @class */ (function (_super) {
2606
2609
  'Field__label--has-error': error
2607
2610
  }), htmlFor: this.inputId },
2608
2611
  React__default["default"].createElement("span", null, label),
2609
- isRequired && (React__default["default"].createElement("span", { className: "Field__required-text" }, requiredText))),
2612
+ isRequired && (React__default["default"].createElement("span", { className: "Field__required-text", "aria-hidden": "true" }, requiredText))),
2610
2613
  React__default["default"].createElement(Field, tslib.__assign({ className: classNames__default["default"](className, {
2611
2614
  'Field__text-input': !multiline,
2612
2615
  Field__textarea: multiline,
@@ -3627,10 +3630,10 @@ var optionMatchesValue = function (option, value) {
3627
3630
  option.value === value;
3628
3631
  };
3629
3632
  var Listbox = React.forwardRef(function (_a, ref) {
3630
- var _b = _a.as, Component = _b === void 0 ? 'ul' : _b, children = _a.children, defaultValue = _a.defaultValue, value = _a.value, _c = _a.navigation, navigation = _c === void 0 ? 'bound' : _c, _d = _a.multiselect, multiselect = _d === void 0 ? false : _d, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onSelectionChange = _a.onSelectionChange, onActiveChange = _a.onActiveChange, props = tslib.__rest(_a, ["as", "children", "defaultValue", "value", "navigation", "multiselect", "onKeyDown", "onFocus", "onSelectionChange", "onActiveChange"]);
3631
- var _e = tslib.__read(React.useState([]), 2), options = _e[0], setOptions = _e[1];
3632
- var _f = tslib.__read(React.useState(null), 2), activeOption = _f[0], setActiveOption = _f[1];
3633
- var _g = tslib.__read(React.useState([]), 2), selectedOptions = _g[0], setSelectedOptions = _g[1];
3633
+ var _b = _a.as, Component = _b === void 0 ? 'ul' : _b, children = _a.children, defaultValue = _a.defaultValue, value = _a.value, _c = _a.navigation, navigation = _c === void 0 ? 'bound' : _c, _d = _a.multiselect, multiselect = _d === void 0 ? false : _d, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onSelectionChange = _a.onSelectionChange, onActiveChange = _a.onActiveChange, _e = _a.disabled, disabled = _e === void 0 ? false : _e, props = tslib.__rest(_a, ["as", "children", "defaultValue", "value", "navigation", "multiselect", "onKeyDown", "onFocus", "onSelectionChange", "onActiveChange", "disabled"]);
3634
+ var _f = tslib.__read(React.useState([]), 2), options = _f[0], setOptions = _f[1];
3635
+ var _g = tslib.__read(React.useState(null), 2), activeOption = _g[0], setActiveOption = _g[1];
3636
+ var _h = tslib.__read(React.useState([]), 2), selectedOptions = _h[0], setSelectedOptions = _h[1];
3634
3637
  var listboxRef = useSharedRef(ref);
3635
3638
  var isControlled = typeof value !== 'undefined';
3636
3639
  React.useLayoutEffect(function () {
@@ -3670,6 +3673,9 @@ var Listbox = React.forwardRef(function (_a, ref) {
3670
3673
  var handleSelect = React.useCallback(function (option) {
3671
3674
  var _a;
3672
3675
  setActiveOption(option);
3676
+ if (disabled) {
3677
+ return;
3678
+ }
3673
3679
  var optionIsSelected = selectedOptions.some(function (selected) { return selected.element === option.element; });
3674
3680
  var previousValues = selectedOptions.map(function (selected) { return selected.value; });
3675
3681
  // istanbul ignore else
@@ -3858,36 +3864,42 @@ ListboxGroup.displayName = 'ListboxGroup';
3858
3864
  var ComboboxContext = React.createContext({
3859
3865
  autocomplete: 'manual',
3860
3866
  inputValue: undefined,
3861
- formValue: undefined,
3862
- selectedValue: undefined,
3867
+ formValues: [],
3868
+ selectedValues: [],
3869
+ removeOptionLabels: [],
3870
+ setRemoveOptionLabels: function () { return null; },
3863
3871
  matches: true,
3864
3872
  matchingOptions: new Map(),
3865
3873
  setMatchingOptions: function () { return null; },
3866
- setFormValue: function () { return null; }
3874
+ setFormValues: function () { return null; }
3867
3875
  });
3868
3876
  function ComboboxProvider(_a) {
3869
- var autocomplete = _a.autocomplete, inputValue = _a.inputValue, formValue = _a.formValue, selectedValue = _a.selectedValue, matches = _a.matches, matchingOptions = _a.matchingOptions, setMatchingOptions = _a.setMatchingOptions, setFormValue = _a.setFormValue, children = _a.children;
3877
+ var autocomplete = _a.autocomplete, inputValue = _a.inputValue, formValues = _a.formValues, selectedValues = _a.selectedValues, removeOptionLabels = _a.removeOptionLabels, setRemoveOptionLabels = _a.setRemoveOptionLabels, matches = _a.matches, matchingOptions = _a.matchingOptions, setMatchingOptions = _a.setMatchingOptions, setFormValues = _a.setFormValues, children = _a.children;
3870
3878
  var Provider = ComboboxContext.Provider;
3871
3879
  var contextValue = React.useMemo(function () { return ({
3872
3880
  autocomplete: autocomplete,
3873
3881
  inputValue: inputValue,
3874
- formValue: formValue,
3875
- selectedValue: selectedValue,
3882
+ formValues: formValues,
3883
+ selectedValues: selectedValues,
3884
+ removeOptionLabels: removeOptionLabels,
3885
+ setRemoveOptionLabels: setRemoveOptionLabels,
3876
3886
  matches: typeof matches === 'function' && !!inputValue
3877
3887
  ? function (value) { return matches(inputValue, value); }
3878
3888
  : true,
3879
3889
  matchingOptions: matchingOptions,
3880
3890
  setMatchingOptions: setMatchingOptions,
3881
- setFormValue: setFormValue
3891
+ setFormValues: setFormValues
3882
3892
  }); }, [
3883
3893
  autocomplete,
3884
3894
  inputValue,
3885
- formValue,
3886
- selectedValue,
3895
+ formValues,
3896
+ selectedValues,
3897
+ removeOptionLabels,
3898
+ setRemoveOptionLabels,
3887
3899
  matches,
3888
3900
  matchingOptions,
3889
3901
  setMatchingOptions,
3890
- setFormValue
3902
+ setFormValues
3891
3903
  ]);
3892
3904
  return React__default["default"].createElement(Provider, { value: contextValue }, children);
3893
3905
  }
@@ -3960,11 +3972,10 @@ var ComboboxMatch = function (_a) {
3960
3972
  React__default["default"].createElement("span", null, matchAfter)));
3961
3973
  };
3962
3974
  var ComboboxOption = React.forwardRef(function (_a, ref) {
3963
- var _b;
3964
- var className = _a.className, children = _a.children, disabled = _a.disabled, propId = _a.id, description = _a.description, propValue = _a.value, formValue = _a.formValue, props = tslib.__rest(_a, ["className", "children", "disabled", "id", "description", "value", "formValue"]);
3965
- var _c = tslib.__read(propId ? [propId] : nextId.useId(1, 'combobox-option'), 1), id = _c[0];
3966
- var _d = useListboxContext(), selected = _d.selected, active = _d.active;
3967
- var _e = useComboboxContext(), selectedValue = _e.selectedValue, matches = _e.matches, setMatchingOptions = _e.setMatchingOptions, setFormValue = _e.setFormValue;
3975
+ var className = _a.className, children = _a.children, disabled = _a.disabled, propId = _a.id, description = _a.description, propValue = _a.value, formValue = _a.formValue, removeOptionLabel = _a.removeOptionLabel, props = tslib.__rest(_a, ["className", "children", "disabled", "id", "description", "value", "formValue", "removeOptionLabel"]);
3976
+ var _b = tslib.__read(propId ? [propId] : nextId.useId(1, 'combobox-option'), 1), id = _b[0];
3977
+ var _c = useListboxContext(), selected = _c.selected, active = _c.active;
3978
+ var _d = useComboboxContext(), selectedValues = _d.selectedValues, setRemoveOptionLabels = _d.setRemoveOptionLabels, matches = _d.matches, setMatchingOptions = _d.setMatchingOptions, setFormValues = _d.setFormValues;
3968
3979
  var comboboxOptionRef = useSharedRef(ref);
3969
3980
  var intersectionRef = useIntersectionRef(comboboxOptionRef, {
3970
3981
  root: null,
@@ -3972,8 +3983,10 @@ var ComboboxOption = React.forwardRef(function (_a, ref) {
3972
3983
  });
3973
3984
  var isActive = !!(active === null || active === void 0 ? void 0 : active.element) && active.element === comboboxOptionRef.current;
3974
3985
  var isSelected = !!(selected &&
3975
- !!((_b = selected[0]) === null || _b === void 0 ? void 0 : _b.element) &&
3976
- selected[0].element === comboboxOptionRef.current);
3986
+ selected.findIndex(function (_a) {
3987
+ var element = _a.element;
3988
+ return element === comboboxOptionRef.current;
3989
+ }) !== -1);
3977
3990
  var isMatching = (typeof matches === 'boolean' && matches) ||
3978
3991
  (typeof matches === 'function' && matches(children));
3979
3992
  // istanbul ignore next
@@ -3999,15 +4012,33 @@ var ComboboxOption = React.forwardRef(function (_a, ref) {
3999
4012
  var comboboxValue = typeof propValue !== 'undefined'
4000
4013
  ? propValue
4001
4014
  : (_a = comboboxOptionRef.current) === null || _a === void 0 ? void 0 : _a.innerText;
4002
- if (selectedValue === comboboxValue) {
4003
- setFormValue(typeof formValue === 'undefined' ? comboboxValue : formValue);
4004
- }
4005
- }, [selectedValue, formValue]);
4015
+ var value = typeof formValue === 'undefined' ? comboboxValue : formValue;
4016
+ setFormValues(function (prev) {
4017
+ var formValues = prev.filter(function (fv) { return fv !== value; });
4018
+ if (selectedValues.includes(comboboxValue)) {
4019
+ formValues.push(value);
4020
+ }
4021
+ return formValues;
4022
+ });
4023
+ setRemoveOptionLabels(function (prev) {
4024
+ if (!removeOptionLabel) {
4025
+ return prev;
4026
+ }
4027
+ return selectedValues.map(function (value, index) {
4028
+ return value === comboboxValue ? removeOptionLabel : prev[index];
4029
+ });
4030
+ });
4031
+ }, [selectedValues, formValue]);
4006
4032
  React.useEffect(function () {
4033
+ var _a;
4007
4034
  if (isMatching) {
4035
+ var comboboxValue_1 = typeof propValue !== 'undefined'
4036
+ ? propValue
4037
+ : (_a = comboboxOptionRef.current) === null || _a === void 0 ? void 0 : _a.innerText;
4008
4038
  setMatchingOptions(function (options) {
4009
4039
  return new Map(options.set(comboboxOptionRef.current, {
4010
- value: children,
4040
+ value: comboboxValue_1,
4041
+ displayValue: children,
4011
4042
  selected: isSelected
4012
4043
  }));
4013
4044
  });
@@ -4039,8 +4070,34 @@ var ComboboxOption = React.forwardRef(function (_a, ref) {
4039
4070
  });
4040
4071
  ComboboxOption.displayName = 'ComboboxOption';
4041
4072
 
4073
+ var ComboboxPill = React.forwardRef(function (_a, ref) {
4074
+ var value = _a.value, removeOptionLabel = _a.removeOptionLabel, _b = _a.disabled, disabled = _b === void 0 ? false : _b, rest = tslib.__rest(_a, ["value", "removeOptionLabel", "disabled"]);
4075
+ var commonProps = {
4076
+ ref: ref,
4077
+ 'aria-label': removeOptionLabel ? removeOptionLabel : "remove ".concat(value),
4078
+ className: 'ComboboxPill',
4079
+ tabIndex: -1
4080
+ };
4081
+ return !disabled ? (React__default["default"].createElement(TagButton, tslib.__assign({ label: value || '', value: "", icon: "close" }, commonProps, rest))) : (React__default["default"].createElement(Button, tslib.__assign({ variant: "tag", disabled: disabled }, commonProps, rest), value));
4082
+ });
4083
+ ComboboxPill.displayName = 'ComboboxPill';
4084
+
4042
4085
  // Event Keys
4043
- var _a = tslib.__read(['Enter', 'Escape', 'Home', 'End'], 4), Enter = _a[0], Escape = _a[1], Home = _a[2], End = _a[3];
4086
+ var _a = tslib.__read([
4087
+ 'Enter',
4088
+ 'Escape',
4089
+ 'Home',
4090
+ 'End',
4091
+ 'Backspace',
4092
+ 'Delete'
4093
+ ], 6), Enter = _a[0], Escape = _a[1], Home = _a[2], End = _a[3], Backspace = _a[4], Delete = _a[5];
4094
+ var _b = tslib.__read([
4095
+ 'ArrowDown',
4096
+ 'ArrowUp',
4097
+ 'ArrowLeft',
4098
+ 'ArrowRight'
4099
+ ], 4), ArrowDown = _b[0], ArrowUp = _b[1], ArrowLeft = _b[2], ArrowRight = _b[3];
4100
+ var PillKeys = [Backspace, Delete, ArrowLeft, ArrowRight];
4044
4101
  var defaultAutoCompleteMatches = function (inputValue, value) {
4045
4102
  // istanbul ignore if
4046
4103
  if (!value) {
@@ -4053,24 +4110,37 @@ var ComboboxNoResults = function (_a) {
4053
4110
  return (React__default["default"].createElement("div", { className: "ComboboxListbox__empty", role: "alert", "aria-live": "polite" }, children || 'No results found.'));
4054
4111
  };
4055
4112
  var Combobox = React.forwardRef(function (_a, ref) {
4056
- var propId = _a.id, className = _a.className, label = _a.label, children = _a.children, _b = _a.options, options = _b === void 0 ? [] : _b, propValue = _a.value, defaultValue = _a.defaultValue, _c = _a.requiredText, requiredText = _c === void 0 ? 'Required' : _c, error = _a.error, _d = _a.autocomplete, autocomplete = _d === void 0 ? 'manual' : _d, onSelectionChange = _a.onSelectionChange, onActiveChange = _a.onActiveChange, onChange = _a.onChange, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, name = _a.name, renderNoResults = _a.renderNoResults, portal = _a.portal, _e = _a.inputRef, propInputRef = _e === void 0 ? null : _e, ariaDescribedby = _a["aria-describedby"], props = tslib.__rest(_a, ["id", "className", "label", "children", "options", "value", "defaultValue", "requiredText", "error", "autocomplete", "onSelectionChange", "onActiveChange", "onChange", "onKeyDown", "onFocus", "onBlur", "name", "renderNoResults", "portal", "inputRef", 'aria-describedby']);
4057
- var _f = tslib.__read(React.useState(defaultValue || propValue || ''), 2), value = _f[0], setValue = _f[1];
4058
- var _g = tslib.__read(React.useState(new Map()), 2), matchingOptions = _g[0], setMatchingOptions = _g[1];
4059
- var _h = tslib.__read(React.useState(value || ''), 2), selectedValue = _h[0], setSelectedValue = _h[1];
4060
- var _j = tslib.__read(React.useState(''), 2), formValue = _j[0], setFormValue = _j[1];
4061
- var _k = tslib.__read(React.useState(false), 2), open = _k[0], setOpen = _k[1];
4062
- var _l = tslib.__read(React.useState(null), 2), activeDescendant = _l[0], setActiveDescendant = _l[1];
4063
- var _m = tslib.__read(propId ? [propId] : nextId.useId(1, 'combobox'), 1), id = _m[0];
4113
+ var propId = _a.id, className = _a.className, label = _a.label, children = _a.children, _b = _a.options, options = _b === void 0 ? [] : _b, propValue = _a.value, defaultValue = _a.defaultValue, propInputValue = _a.inputValue, defaultInputValue = _a.defaultInputValue, _c = _a.multiselect, multiselect = _c === void 0 ? false : _c, _d = _a.requiredText, requiredText = _d === void 0 ? 'Required' : _d, error = _a.error, _e = _a.autocomplete, autocomplete = _e === void 0 ? 'manual' : _e, onSelectionChange = _a.onSelectionChange, onActiveChange = _a.onActiveChange, onChange = _a.onChange, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, name = _a.name, renderNoResults = _a.renderNoResults, portal = _a.portal, _f = _a.inputRef, propInputRef = _f === void 0 ? null : _f, ariaDescribedby = _a["aria-describedby"], _g = _a.disabled, disabled = _g === void 0 ? false : _g, props = tslib.__rest(_a, ["id", "className", "label", "children", "options", "value", "defaultValue", "inputValue", "defaultInputValue", "multiselect", "requiredText", "error", "autocomplete", "onSelectionChange", "onActiveChange", "onChange", "onKeyDown", "onFocus", "onBlur", "name", "renderNoResults", "portal", "inputRef", 'aria-describedby', "disabled"]);
4114
+ var _h = tslib.__read(React.useState(new Map()), 2), matchingOptions = _h[0], setMatchingOptions = _h[1];
4115
+ var _j = tslib.__read(React.useState(function () {
4116
+ var value = defaultValue || propValue;
4117
+ var inputVal = defaultInputValue || propInputValue;
4118
+ return (Array.isArray(value) ? inputVal : value) || '';
4119
+ }), 2), inputValue = _j[0], setInputValue = _j[1];
4120
+ var _k = tslib.__read(React.useState(function () {
4121
+ var value = defaultValue || propValue;
4122
+ if (!value) {
4123
+ return [];
4124
+ }
4125
+ return Array.isArray(value) ? value : [value];
4126
+ }), 2), selectedValues = _k[0], setSelectedValues = _k[1];
4127
+ var _l = tslib.__read(React.useState([]), 2), removeOptionLabels = _l[0], setRemoveOptionLabels = _l[1];
4128
+ var _m = tslib.__read(React.useState([]), 2), formValues = _m[0], setFormValues = _m[1];
4129
+ var _o = tslib.__read(React.useState(false), 2), open = _o[0], setOpen = _o[1];
4130
+ var _p = tslib.__read(React.useState(null), 2), activeDescendant = _p[0], setActiveDescendant = _p[1];
4131
+ var _q = tslib.__read(propId ? [propId] : nextId.useId(1, 'combobox'), 1), id = _q[0];
4064
4132
  var comboboxRef = useSharedRef(ref);
4065
4133
  var inputRef = useSharedRef(propInputRef);
4066
4134
  var listboxRef = React.useRef(null);
4067
- var isControlled = typeof propValue !== 'undefined';
4135
+ var pillsRef = React.useRef([]);
4136
+ var isControlled = typeof propValue !== 'undefined' &&
4137
+ (multiselect ? typeof propInputValue !== 'undefined' : true);
4068
4138
  var isRequired = !!props.required;
4069
4139
  var isAutoComplete = autocomplete !== 'none';
4070
4140
  var hasError = !!error;
4071
4141
  var comboboxOptions = children ||
4072
- options.map(function (option, index) { return (React__default["default"].createElement(ComboboxOption, { key: option.key || index, id: "".concat(id, "-option-").concat(index + 1), description: option.description, value: option.value }, option.label)); });
4073
- var triggerListboxKeyDown = React__default["default"].useCallback(function (key) {
4142
+ options.map(function (option, index) { return (React__default["default"].createElement(ComboboxOption, { key: option.key || index, id: "".concat(id, "-option-").concat(index + 1), description: option.description, value: option.value, formValue: option.formValue, removeOptionLabel: option.removeOptionLabel }, option.label)); });
4143
+ var triggerListboxKeyDown = React.useCallback(function (key) {
4074
4144
  var _a;
4075
4145
  (_a = listboxRef.current) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new KeyboardEvent('keydown', {
4076
4146
  key: key,
@@ -4082,55 +4152,67 @@ var Combobox = React.forwardRef(function (_a, ref) {
4082
4152
  if (!isAutoComplete) {
4083
4153
  return;
4084
4154
  }
4085
- if (!open && selectedValue && value !== selectedValue) {
4086
- setValue(selectedValue);
4155
+ if (!open &&
4156
+ !multiselect &&
4157
+ selectedValues.length &&
4158
+ !selectedValues.includes(inputValue)) {
4159
+ setInputValue(selectedValues[selectedValues.length - 1] || '');
4087
4160
  }
4088
4161
  if (!open) {
4089
4162
  setActiveDescendant(null);
4090
4163
  }
4091
- if (open && autocomplete === 'automatic' && !selectedValue) {
4164
+ if (open && autocomplete === 'automatic' && !selectedValues.length) {
4092
4165
  // Fire a Home keydown event on listbox to ensure the first item is selected
4093
4166
  triggerListboxKeyDown(Home);
4094
4167
  }
4095
- }, [open]);
4168
+ }, [open, multiselect, autocomplete, selectedValues]);
4096
4169
  React.useEffect(function () {
4170
+ var lastSelectedValue = selectedValues.length !== 0
4171
+ ? selectedValues[selectedValues.length - 1]
4172
+ : undefined;
4097
4173
  var _a = tslib.__read(Array.from(matchingOptions.entries()).find(function (_a) {
4098
- var _b = tslib.__read(_a, 2), selected = _b[1].selected;
4099
- return selected;
4174
+ var _b = tslib.__read(_a, 2), value = _b[1].value;
4175
+ return value === lastSelectedValue;
4100
4176
  }) || [], 2), element = _a[0], option = _a[1];
4101
4177
  if (autocomplete === 'manual') {
4102
4178
  setActiveDescendant(!element ? null : tslib.__assign({ element: element }, option));
4103
4179
  }
4104
4180
  else if (autocomplete === 'automatic' &&
4105
4181
  matchingOptions.size &&
4106
- !selectedValue) {
4182
+ !selectedValues.length) {
4107
4183
  // Fire a home keydown event on listbox to ensure the first item is selected
4108
4184
  requestAnimationFrame(function () {
4109
4185
  triggerListboxKeyDown(Home);
4110
4186
  });
4111
4187
  }
4112
- }, [matchingOptions]);
4188
+ }, [selectedValues, matchingOptions]);
4113
4189
  var handleFocus = React.useCallback(function (event) {
4114
4190
  onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
4115
4191
  // istanbul ignore else
4116
4192
  if (!event.defaultPrevented) {
4117
4193
  setOpen(true);
4118
- if (selectedValue && value === selectedValue && isAutoComplete) {
4119
- setValue('');
4194
+ if (selectedValues.length &&
4195
+ selectedValues.includes(inputValue) &&
4196
+ isAutoComplete) {
4197
+ setInputValue('');
4120
4198
  }
4121
4199
  }
4122
- }, [onFocus, value, selectedValue]);
4200
+ }, [onFocus, inputValue, selectedValues]);
4123
4201
  var handleInputClick = React.useCallback(function (event) {
4124
4202
  var _a;
4125
- setOpen(true);
4126
- if (selectedValue && value === selectedValue && isAutoComplete) {
4127
- setValue('');
4203
+ if (!disabled) {
4204
+ setOpen(true);
4205
+ }
4206
+ if (selectedValues.length &&
4207
+ selectedValues.includes(inputValue) &&
4208
+ isAutoComplete) {
4209
+ setInputValue('');
4128
4210
  }
4129
4211
  if (event.target !== inputRef.current) {
4130
4212
  // ensure focus is set on the input field
4131
4213
  (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
4132
4214
  }
4133
- }, [value, selectedValue]);
4215
+ }, [disabled, inputValue, selectedValues]);
4134
4216
  var handleComboboxOptionMouseDown = React.useCallback(function (event) {
4135
4217
  // prevent blur from triggering when activating combobox options
4136
4218
  event.preventDefault();
@@ -4147,22 +4229,46 @@ var Combobox = React.forwardRef(function (_a, ref) {
4147
4229
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
4148
4230
  setOpen(false);
4149
4231
  if (autocomplete === 'automatic' && activeDescendant) {
4150
- var stringValue = ((_a = activeDescendant.value) === null || _a === void 0 ? void 0 : _a.toString()) ||
4232
+ var activeValue_1 = ((_a = activeDescendant.value) === null || _a === void 0 ? void 0 : _a.toString()) ||
4151
4233
  /* istanbul ignore next: default value */ '';
4152
- setValue(stringValue);
4153
- setSelectedValue(stringValue);
4154
- onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange({
4155
- target: activeDescendant.element,
4156
- value: stringValue,
4157
- previousValue: value
4158
- });
4234
+ setInputValue(activeValue_1);
4235
+ if (!multiselect) {
4236
+ setSelectedValues([activeValue_1]);
4237
+ onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange({
4238
+ target: activeDescendant.element,
4239
+ value: activeValue_1,
4240
+ previousValue: selectedValues[0]
4241
+ });
4242
+ }
4243
+ else {
4244
+ var activeValueIndex = selectedValues.indexOf(activeValue_1);
4245
+ var newSelectedValues = selectedValues.filter(function (v) { return v !== activeValue_1; });
4246
+ if (activeValueIndex === -1) {
4247
+ newSelectedValues.push(activeValue_1);
4248
+ }
4249
+ setSelectedValues(newSelectedValues);
4250
+ onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange({
4251
+ target: activeDescendant.element,
4252
+ value: newSelectedValues,
4253
+ previousValue: selectedValues
4254
+ });
4255
+ }
4159
4256
  }
4160
- }, [autocomplete, activeDescendant, onBlur]);
4257
+ }, [
4258
+ autocomplete,
4259
+ activeDescendant,
4260
+ onBlur,
4261
+ selectedValues,
4262
+ onSelectionChange
4263
+ ]);
4161
4264
  var handleKeyDown = React.useCallback(function (event) {
4265
+ var _a;
4162
4266
  onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
4163
4267
  var enterKeypress = event.key === Enter;
4164
4268
  var escKeypress = event.key === Escape;
4165
- var arrowKeypress = ['ArrowDown', 'ArrowUp'].includes(event.key);
4269
+ var deleteKeypress = event.key === Delete;
4270
+ var backspaceKeypress = event.key === Backspace;
4271
+ var listboxArrowKeypress = [ArrowUp, ArrowDown].includes(event.key);
4166
4272
  if (
4167
4273
  // prevent the page from scrolling and allow start/end option activation
4168
4274
  [Home, End].includes(event.key) ||
@@ -4180,10 +4286,18 @@ var Combobox = React.forwardRef(function (_a, ref) {
4180
4286
  return;
4181
4287
  }
4182
4288
  setOpen(true);
4183
- if (!open && arrowKeypress && selectedValue && isAutoComplete) {
4289
+ if (inputValue === '' &&
4290
+ (backspaceKeypress || deleteKeypress || event.key === ArrowLeft) &&
4291
+ pillsRef.current.length !== 0) {
4292
+ (_a = pillsRef.current[pillsRef.current.length - 1]) === null || _a === void 0 ? void 0 : _a.focus();
4293
+ }
4294
+ if (!open &&
4295
+ listboxArrowKeypress &&
4296
+ selectedValues.length &&
4297
+ isAutoComplete) {
4184
4298
  // If the user opens the combobox again with a selected value
4185
4299
  // just clear out the field to restore filtering capabilities
4186
- setValue('');
4300
+ setInputValue('');
4187
4301
  }
4188
4302
  // Space should not trigger selection since the user could be typing
4189
4303
  // a value for autocompletion. Additionally when not open and there's
@@ -4196,37 +4310,124 @@ var Combobox = React.forwardRef(function (_a, ref) {
4196
4310
  // forward input events to listbox
4197
4311
  triggerListboxKeyDown(event.key);
4198
4312
  // Close combobox with keyboard selections
4199
- if (enterKeypress && activeDescendant) {
4313
+ if (enterKeypress && activeDescendant && !multiselect) {
4200
4314
  setOpen(false);
4201
4315
  }
4202
- }, [onKeyDown, isAutoComplete, open, selectedValue, activeDescendant]);
4316
+ }, [
4317
+ onKeyDown,
4318
+ isAutoComplete,
4319
+ open,
4320
+ multiselect,
4321
+ selectedValues,
4322
+ activeDescendant
4323
+ ]);
4203
4324
  React.useEffect(function () {
4204
- if (typeof propValue !== 'undefined') {
4205
- setValue(propValue);
4325
+ if (isControlled) {
4326
+ if (!multiselect) {
4327
+ setInputValue(propValue || '');
4328
+ }
4329
+ else {
4330
+ setInputValue(propInputValue || '');
4331
+ }
4206
4332
  }
4207
- }, [propValue]);
4333
+ }, [multiselect, propValue, propInputValue]);
4208
4334
  var handleChange = React.useCallback(function (event) {
4335
+ if (disabled) {
4336
+ return;
4337
+ }
4209
4338
  onChange === null || onChange === void 0 ? void 0 : onChange(event);
4210
4339
  // istanbul ignore else
4211
4340
  if (!isControlled) {
4212
- setValue(event.target.value);
4341
+ setInputValue(event.target.value);
4213
4342
  }
4214
4343
  }, [isControlled, onChange]);
4215
- var handleSelectionChange = React.useCallback(function (_a) {
4216
- var target = _a.target, listboxValue = _a.value, previousValue = _a.previousValue;
4217
- var stringValue = (listboxValue === null || listboxValue === void 0 ? void 0 : listboxValue.toString()) || /* istanbul ignore next */ '';
4218
- // istanbul ignore else
4219
- if (!isControlled) {
4220
- setValue(stringValue);
4344
+ var handleRemovePill = React.useCallback(function (target, value) {
4345
+ if (disabled) {
4346
+ return;
4221
4347
  }
4222
- setSelectedValue(stringValue);
4348
+ var newSelectedValues = selectedValues.filter(function (v) { return v !== value; });
4349
+ setSelectedValues(newSelectedValues);
4223
4350
  onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange({
4224
4351
  target: target,
4225
- value: stringValue,
4226
- previousValue: previousValue === null || previousValue === void 0 ? void 0 : previousValue.toString()
4352
+ value: newSelectedValues,
4353
+ previousValue: selectedValues
4227
4354
  });
4228
- setOpen(false);
4229
- }, [isControlled, onSelectionChange]);
4355
+ }, [disabled, selectedValues, onSelectionChange]);
4356
+ var handlePillKeyDown = React.useCallback(function (event) {
4357
+ if (!PillKeys.includes(event.key)) {
4358
+ return;
4359
+ }
4360
+ event.preventDefault();
4361
+ var isDelete = event.key === Delete;
4362
+ var isBackspace = event.key === Backspace;
4363
+ var isArrowLeft = event.key === ArrowLeft;
4364
+ var isArrowRight = event.key === ArrowRight;
4365
+ var focusedIndex = pillsRef.current.findIndex(function (p) { return document.activeElement === p; });
4366
+ var pillsLength = pillsRef.current.length;
4367
+ if (isDelete || isBackspace) {
4368
+ if (disabled) {
4369
+ return;
4370
+ }
4371
+ handleRemovePill(pillsRef.current[focusedIndex], selectedValues[focusedIndex]);
4372
+ var nextIndex = focusedIndex + 1;
4373
+ if (nextIndex == pillsLength) {
4374
+ inputRef.current.focus();
4375
+ }
4376
+ else {
4377
+ pillsRef.current[nextIndex].focus();
4378
+ }
4379
+ }
4380
+ else if (isArrowLeft || isArrowRight) {
4381
+ var nextIndex = Math.max(focusedIndex + (isArrowLeft ? -1 : 1), 0);
4382
+ if (isArrowRight && nextIndex === pillsLength) {
4383
+ inputRef.current.focus();
4384
+ }
4385
+ else {
4386
+ pillsRef.current[nextIndex].focus();
4387
+ }
4388
+ }
4389
+ }, [disabled, pillsRef, handleRemovePill]);
4390
+ var handleSelectionChange = React.useCallback(function (_a) {
4391
+ var target = _a.target, value = _a.value, previousValue = _a.previousValue;
4392
+ if (!multiselect) {
4393
+ var listboxValue = (value === null || value === void 0 ? void 0 : value.toString()) || '';
4394
+ var listboxPreviousValue = (previousValue === null || previousValue === void 0 ? void 0 : previousValue.toString()) || '';
4395
+ // istanbul ignore else
4396
+ if (!isControlled) {
4397
+ setInputValue(listboxValue);
4398
+ }
4399
+ setSelectedValues([listboxValue]);
4400
+ onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange({
4401
+ target: target,
4402
+ value: listboxValue,
4403
+ previousValue: listboxPreviousValue
4404
+ });
4405
+ }
4406
+ else {
4407
+ var listboxPreviousValue = previousValue;
4408
+ var listboxValue = value;
4409
+ var previousValueSet_1 = new Set(listboxPreviousValue);
4410
+ var valueSet_1 = new Set(listboxValue);
4411
+ var removedValues_1 = new Set(listboxPreviousValue.filter(function (v) { return !valueSet_1.has(v); }));
4412
+ var addedValues = listboxValue.filter(function (v) { return !previousValueSet_1.has(v); });
4413
+ var newSelectedValues = selectedValues
4414
+ .filter(function (v) { return !removedValues_1.has(v); })
4415
+ .concat(addedValues);
4416
+ // istanbul ignore else
4417
+ if (!isControlled) {
4418
+ setInputValue('');
4419
+ }
4420
+ setSelectedValues(newSelectedValues);
4421
+ onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange({
4422
+ target: target,
4423
+ value: newSelectedValues,
4424
+ previousValue: selectedValues
4425
+ });
4426
+ }
4427
+ if (!multiselect) {
4428
+ setOpen(false);
4429
+ }
4430
+ }, [isControlled, multiselect, selectedValues, onSelectionChange]);
4230
4431
  var handleActiveChange = React.useCallback(function (option) {
4231
4432
  // istanbul ignore else
4232
4433
  if (option.element) {
@@ -4234,38 +4435,59 @@ var Combobox = React.forwardRef(function (_a, ref) {
4234
4435
  }
4235
4436
  onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(option);
4236
4437
  }, []);
4237
- var NoMatchingOptions = React__default["default"].useMemo(function () {
4438
+ var NoMatchingOptions = React.useMemo(function () {
4238
4439
  return React__default["default"].isValidElement(renderNoResults)
4239
4440
  ? function () { return React__default["default"].createElement(ComboboxNoResults, null, renderNoResults); }
4240
4441
  : typeof renderNoResults === 'function'
4241
4442
  ? function () { return React__default["default"].createElement(ComboboxNoResults, null, renderNoResults()); }
4242
4443
  : ComboboxNoResults;
4243
4444
  }, [renderNoResults]);
4244
- var noMatchingOptions = !!(value === null || value === void 0 ? void 0 : value.length) && !matchingOptions.size && (React__default["default"].createElement(NoMatchingOptions, null));
4245
- var comboboxListbox = (React__default["default"].createElement(Listbox, { className: classNames__default["default"]('Combobox__listbox', {
4445
+ var noMatchingOptions = !!inputValue && !matchingOptions.size && (React__default["default"].createElement(NoMatchingOptions, null));
4446
+ var comboboxListbox = (
4447
+ // eslint-disable-next-line
4448
+ // @ts-expect-error
4449
+ // multiselect & value props are passed to Listbox, but TS is unable to infer that
4450
+ // it's a correct mapping from Combobox's multiselect & value props
4451
+ React__default["default"].createElement(Listbox, { className: classNames__default["default"]('Combobox__listbox', {
4246
4452
  'Combobox__listbox--open': open
4247
- }), role: noMatchingOptions ? 'presentation' : 'listbox', "aria-labelledby": noMatchingOptions ? undefined : "".concat(id, "-label"), id: "".concat(id, "-listbox"), value: selectedValue, onMouseDown: handleComboboxOptionMouseDown, onClick: handleComboboxOptionClick, onSelectionChange: handleSelectionChange, onActiveChange: handleActiveChange, ref: listboxRef, tabIndex: undefined, "aria-activedescendant": undefined },
4453
+ }), role: noMatchingOptions ? 'presentation' : 'listbox', "aria-labelledby": noMatchingOptions ? undefined : "".concat(id, "-label"), id: "".concat(id, "-listbox"), value: multiselect ? selectedValues : selectedValues[0], onMouseDown: handleComboboxOptionMouseDown, onClick: handleComboboxOptionClick, onSelectionChange: handleSelectionChange, onActiveChange: handleActiveChange, ref: listboxRef, tabIndex: undefined, "aria-activedescendant": undefined, multiselect: multiselect, disabled: disabled },
4248
4454
  comboboxOptions,
4249
4455
  noMatchingOptions));
4250
4456
  var errorId = "".concat(id, "-error");
4251
4457
  var inputProps = tslib.__assign(tslib.__assign({}, props), { 'aria-describedby': error
4252
4458
  ? addIdRef(ariaDescribedby, errorId)
4253
4459
  : ariaDescribedby });
4254
- return (React__default["default"].createElement("div", { id: id, className: classNames__default["default"]('Combobox', className), ref: comboboxRef },
4255
- name && React__default["default"].createElement("input", { type: "hidden", name: name, value: formValue }),
4460
+ return (React__default["default"].createElement("div", { id: id, className: classNames__default["default"]('Combobox', { 'Combobox--multiselect': multiselect }, className), ref: comboboxRef },
4461
+ name &&
4462
+ formValues.map(function (formValue, index) { return (React__default["default"].createElement("input", { type: "hidden", key: index, name: name, value: formValue })); }),
4256
4463
  React__default["default"].createElement("label", { className: classNames__default["default"]('Field__label', {
4257
4464
  'Field__label--is-required': isRequired,
4258
4465
  'Field__label--has-error': hasError
4259
4466
  }), id: "".concat(id, "-label"), htmlFor: "".concat(id, "-input") },
4260
4467
  React__default["default"].createElement("span", null, label),
4261
- isRequired && (React__default["default"].createElement("span", { className: "Field__required-text" }, requiredText))),
4468
+ isRequired && (React__default["default"].createElement("span", { className: "Field__required-text", "aria-hidden": "true" }, requiredText))),
4262
4469
  React__default["default"].createElement(TextFieldWrapper, { className: classNames__default["default"]({ 'TextFieldWrapper--error': hasError }),
4263
4470
  // We're handling click here to open the listbox when the wrapping element is clicked,
4264
4471
  // there's already keyboard handlers to open the listbox on the input element
4265
4472
  onClick: handleInputClick },
4266
- React__default["default"].createElement("input", tslib.__assign({ type: "text", id: "".concat(id, "-input"), ref: inputRef, value: value, role: "combobox", "aria-autocomplete": !isAutoComplete ? 'none' : 'list', "aria-controls": "".concat(id, "-listbox"), "aria-expanded": open, "aria-haspopup": "listbox", "aria-activedescendant": open && activeDescendant ? activeDescendant.element.id : undefined }, inputProps, { onChange: handleChange, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: handleBlur })),
4473
+ multiselect &&
4474
+ selectedValues.map(function (value, index) {
4475
+ var refCallback = function (elem) {
4476
+ if (elem) {
4477
+ pillsRef.current[index] = elem;
4478
+ }
4479
+ else {
4480
+ pillsRef.current.splice(index, 1);
4481
+ }
4482
+ };
4483
+ var handleClick = function () {
4484
+ return handleRemovePill(pillsRef.current[index], value);
4485
+ };
4486
+ return (React__default["default"].createElement(ComboboxPill, { ref: refCallback, key: value, value: value, removeOptionLabel: removeOptionLabels[index], disabled: disabled, onClick: handleClick, onKeyDown: handlePillKeyDown }));
4487
+ }),
4488
+ React__default["default"].createElement("input", tslib.__assign({ type: "text", id: "".concat(id, "-input"), ref: inputRef, value: inputValue, role: "combobox", disabled: disabled, "aria-autocomplete": !isAutoComplete ? 'none' : 'list', "aria-controls": "".concat(id, "-listbox"), "aria-expanded": open, "aria-haspopup": "listbox", "aria-activedescendant": open && activeDescendant ? activeDescendant.element.id : undefined }, inputProps, { onChange: handleChange, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: handleBlur })),
4267
4489
  React__default["default"].createElement("span", { className: "Combobox__arrow" })),
4268
- React__default["default"].createElement(ComboboxProvider, { autocomplete: autocomplete, inputValue: value, formValue: formValue, selectedValue: selectedValue, matches: !isAutoComplete || defaultAutoCompleteMatches, matchingOptions: matchingOptions, setMatchingOptions: setMatchingOptions, setFormValue: setFormValue }, portal && typeof document !== 'undefined'
4490
+ React__default["default"].createElement(ComboboxProvider, { autocomplete: autocomplete, inputValue: inputValue, formValues: formValues, selectedValues: selectedValues, removeOptionLabels: removeOptionLabels, setRemoveOptionLabels: setRemoveOptionLabels, matches: !isAutoComplete || defaultAutoCompleteMatches, matchingOptions: matchingOptions, setMatchingOptions: setMatchingOptions, setFormValues: setFormValues }, portal && typeof document !== 'undefined'
4269
4491
  ? reactDom.createPortal(comboboxListbox,
4270
4492
  // eslint-disable-next-line ssr-friendly/no-dom-globals-in-react-fc
4271
4493
  portal instanceof HTMLElement
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deque/cauldron-react",
3
- "version": "6.14.0",
3
+ "version": "6.15.0-canary.05150a80",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Fully accessible react components library for Deque Cauldron",
6
6
  "homepage": "https://cauldron.dequelabs.com/",