@deque/cauldron-react 5.12.0-canary.ec511885 → 5.13.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.
@@ -26,6 +26,7 @@ interface ComboboxProps extends React.InputHTMLAttributes<Omit<HTMLInputElement,
26
26
  onActiveChange?: (option: ListboxOption) => void;
27
27
  renderNoResults?: (() => JSX.Element) | React.ReactElement;
28
28
  portal?: React.RefObject<HTMLElement> | HTMLElement;
29
+ inputRef?: React.Ref<HTMLInputElement>;
29
30
  }
30
31
  declare const Combobox: React.ForwardRefExoticComponent<ComboboxProps & React.RefAttributes<HTMLInputElement>>;
31
32
  export default Combobox;
package/lib/index.js CHANGED
@@ -4383,16 +4383,16 @@ var ComboboxNoResults = function (_a) {
4383
4383
  return (React__default["default"].createElement("div", { className: "ComboboxListbox__empty", role: "alert", "aria-live": "polite" }, children || 'No results found.'));
4384
4384
  };
4385
4385
  var Combobox = React.forwardRef(function (_a, ref) {
4386
- 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, props = tslib.__rest(_a, ["id", "className", "label", "children", "options", "value", "defaultValue", "requiredText", "error", "autocomplete", "onSelectionChange", "onActiveChange", "onChange", "onKeyDown", "onFocus", "onBlur", "name", "renderNoResults", "portal"]);
4387
- var _e = tslib.__read(React.useState(defaultValue || propValue || ''), 2), value = _e[0], setValue = _e[1];
4388
- var _f = tslib.__read(React.useState(new Map()), 2), matchingOptions = _f[0], setMatchingOptions = _f[1];
4389
- var _g = tslib.__read(React.useState(value || ''), 2), selectedValue = _g[0], setSelectedValue = _g[1];
4390
- var _h = tslib.__read(React.useState(''), 2), formValue = _h[0], setFormValue = _h[1];
4391
- var _j = tslib.__read(React.useState(false), 2), open = _j[0], setOpen = _j[1];
4392
- var _k = tslib.__read(React.useState(null), 2), activeDescendant = _k[0], setActiveDescendant = _k[1];
4393
- var _l = tslib.__read(propId ? [propId] : nextId.useId(1, 'combobox'), 1), id = _l[0];
4386
+ 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']);
4387
+ var _f = tslib.__read(React.useState(defaultValue || propValue || ''), 2), value = _f[0], setValue = _f[1];
4388
+ var _g = tslib.__read(React.useState(new Map()), 2), matchingOptions = _g[0], setMatchingOptions = _g[1];
4389
+ var _h = tslib.__read(React.useState(value || ''), 2), selectedValue = _h[0], setSelectedValue = _h[1];
4390
+ var _j = tslib.__read(React.useState(''), 2), formValue = _j[0], setFormValue = _j[1];
4391
+ var _k = tslib.__read(React.useState(false), 2), open = _k[0], setOpen = _k[1];
4392
+ var _l = tslib.__read(React.useState(null), 2), activeDescendant = _l[0], setActiveDescendant = _l[1];
4393
+ var _m = tslib.__read(propId ? [propId] : nextId.useId(1, 'combobox'), 1), id = _m[0];
4394
4394
  var comboboxRef = useSharedRef(ref);
4395
- var inputRef = React.useRef(null);
4395
+ var inputRef = useSharedRef(propInputRef);
4396
4396
  var listboxRef = React.useRef(null);
4397
4397
  var isControlled = typeof propValue !== 'undefined';
4398
4398
  var isRequired = !!props.required;
@@ -4563,6 +4563,10 @@ var Combobox = React.forwardRef(function (_a, ref) {
4563
4563
  }), role: "listbox", "aria-labelledby": "".concat(id, "-label"), id: "".concat(id, "-listbox"), value: selectedValue, onMouseDown: handleComboboxOptionMouseDown, onClick: handleComboboxOptionClick, onSelectionChange: handleSelectionChange, onActiveChange: handleActiveChange, ref: listboxRef, tabIndex: undefined, "aria-activedescendant": undefined },
4564
4564
  comboboxOptions,
4565
4565
  noMatchingOptions));
4566
+ var errorId = "".concat(id, "-error");
4567
+ var inputProps = tslib.__assign(tslib.__assign({}, props), { 'aria-describedby': error
4568
+ ? tokenList(errorId, ariaDescribedby)
4569
+ : ariaDescribedby });
4566
4570
  return (React__default["default"].createElement("div", { id: id, className: classNames__default["default"]('Combobox', className), ref: comboboxRef },
4567
4571
  name && React__default["default"].createElement("input", { type: "hidden", name: name, value: formValue }),
4568
4572
  React__default["default"].createElement("label", { className: classNames__default["default"]('Field__label', {
@@ -4577,7 +4581,7 @@ var Combobox = React.forwardRef(function (_a, ref) {
4577
4581
  // We're handling click here to open the listbox when the wrapping element is clicked,
4578
4582
  // there's already keyboard handlers to open the listbox on the input element
4579
4583
  onClick: handleInputClick },
4580
- 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 }, props, { onChange: handleChange, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: handleBlur })),
4584
+ 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 })),
4581
4585
  React__default["default"].createElement("span", { className: "Combobox__arrow" })),
4582
4586
  React__default["default"].createElement(ComboboxProvider, { autocomplete: autocomplete, inputValue: value, formValue: formValue, selectedValue: selectedValue, matches: !isAutoComplete || defaultAutoCompleteMatches, matchingOptions: matchingOptions, setMatchingOptions: setMatchingOptions, setFormValue: setFormValue }, portal
4583
4587
  ? reactDom.createPortal(comboboxListbox, portal instanceof HTMLElement
@@ -4585,7 +4589,7 @@ var Combobox = React.forwardRef(function (_a, ref) {
4585
4589
  : portal.current ||
4586
4590
  /* istanbul ignore next: default fallback value */ document.body)
4587
4591
  : comboboxListbox),
4588
- hasError && (React__default["default"].createElement("div", { className: "Error", id: "".concat(id, "-error") }, error))));
4592
+ hasError && (React__default["default"].createElement("div", { className: "Error", id: errorId }, error))));
4589
4593
  });
4590
4594
  Combobox.displayName = 'Combobox';
4591
4595
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deque/cauldron-react",
3
- "version": "5.12.0-canary.ec511885",
3
+ "version": "5.13.0",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Fully accessible react components library for Deque Cauldron",
6
6
  "homepage": "https://cauldron.dequelabs.com/",