@deque/cauldron-react 5.12.0 → 5.13.0-canary.d71c768d

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;
@@ -38,6 +38,7 @@ export default class Dialog extends React.Component<DialogProps, DialogState> {
38
38
  };
39
39
  private element;
40
40
  private heading;
41
+ private headingId;
41
42
  constructor(props: DialogProps);
42
43
  componentDidMount(): void;
43
44
  componentWillUnmount(): void;
package/lib/index.js CHANGED
@@ -1561,6 +1561,7 @@ var Dialog = /** @class */ (function (_super) {
1561
1561
  tslib.__extends(Dialog, _super);
1562
1562
  function Dialog(props) {
1563
1563
  var _this = _super.call(this, props) || this;
1564
+ _this.headingId = nextId__default["default"]('dialog-title-');
1564
1565
  _this.close = _this.close.bind(_this);
1565
1566
  _this.focusHeading = _this.focusHeading.bind(_this);
1566
1567
  _this.handleClickOutside = _this.handleClickOutside.bind(_this);
@@ -1617,10 +1618,10 @@ var Dialog = /** @class */ (function (_super) {
1617
1618
  return;
1618
1619
  }
1619
1620
  setRef(dialogRef, el);
1620
- } }, other),
1621
+ }, "aria-labelledby": this.headingId }, other),
1621
1622
  React__default["default"].createElement("div", { className: "Dialog__inner" },
1622
1623
  React__default["default"].createElement("div", { className: "Dialog__header" },
1623
- React__default["default"].createElement(Heading, { className: "Dialog__heading", ref: function (el) { return (_this.heading = el); }, tabIndex: -1 }, typeof heading === 'object' && 'text' in heading
1624
+ React__default["default"].createElement(Heading, { className: "Dialog__heading", ref: function (el) { return (_this.heading = el); }, tabIndex: -1, id: this.headingId }, typeof heading === 'object' && 'text' in heading
1624
1625
  ? heading.text
1625
1626
  : heading),
1626
1627
  close),
@@ -4382,16 +4383,16 @@ var ComboboxNoResults = function (_a) {
4382
4383
  return (React__default["default"].createElement("div", { className: "ComboboxListbox__empty", role: "alert", "aria-live": "polite" }, children || 'No results found.'));
4383
4384
  };
4384
4385
  var Combobox = React.forwardRef(function (_a, ref) {
4385
- 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"]);
4386
- var _e = tslib.__read(React.useState(defaultValue || propValue || ''), 2), value = _e[0], setValue = _e[1];
4387
- var _f = tslib.__read(React.useState(new Map()), 2), matchingOptions = _f[0], setMatchingOptions = _f[1];
4388
- var _g = tslib.__read(React.useState(value || ''), 2), selectedValue = _g[0], setSelectedValue = _g[1];
4389
- var _h = tslib.__read(React.useState(''), 2), formValue = _h[0], setFormValue = _h[1];
4390
- var _j = tslib.__read(React.useState(false), 2), open = _j[0], setOpen = _j[1];
4391
- var _k = tslib.__read(React.useState(null), 2), activeDescendant = _k[0], setActiveDescendant = _k[1];
4392
- 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];
4393
4394
  var comboboxRef = useSharedRef(ref);
4394
- var inputRef = React.useRef(null);
4395
+ var inputRef = useSharedRef(propInputRef);
4395
4396
  var listboxRef = React.useRef(null);
4396
4397
  var isControlled = typeof propValue !== 'undefined';
4397
4398
  var isRequired = !!props.required;
@@ -4562,6 +4563,10 @@ var Combobox = React.forwardRef(function (_a, ref) {
4562
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 },
4563
4564
  comboboxOptions,
4564
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 });
4565
4570
  return (React__default["default"].createElement("div", { id: id, className: classNames__default["default"]('Combobox', className), ref: comboboxRef },
4566
4571
  name && React__default["default"].createElement("input", { type: "hidden", name: name, value: formValue }),
4567
4572
  React__default["default"].createElement("label", { className: classNames__default["default"]('Field__label', {
@@ -4576,7 +4581,7 @@ var Combobox = React.forwardRef(function (_a, ref) {
4576
4581
  // We're handling click here to open the listbox when the wrapping element is clicked,
4577
4582
  // there's already keyboard handlers to open the listbox on the input element
4578
4583
  onClick: handleInputClick },
4579
- 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 })),
4580
4585
  React__default["default"].createElement("span", { className: "Combobox__arrow" })),
4581
4586
  React__default["default"].createElement(ComboboxProvider, { autocomplete: autocomplete, inputValue: value, formValue: formValue, selectedValue: selectedValue, matches: !isAutoComplete || defaultAutoCompleteMatches, matchingOptions: matchingOptions, setMatchingOptions: setMatchingOptions, setFormValue: setFormValue }, portal
4582
4587
  ? reactDom.createPortal(comboboxListbox, portal instanceof HTMLElement
@@ -4584,7 +4589,7 @@ var Combobox = React.forwardRef(function (_a, ref) {
4584
4589
  : portal.current ||
4585
4590
  /* istanbul ignore next: default fallback value */ document.body)
4586
4591
  : comboboxListbox),
4587
- 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))));
4588
4593
  });
4589
4594
  Combobox.displayName = 'Combobox';
4590
4595
 
@@ -4632,7 +4637,9 @@ var Popover = React.forwardRef(function (_a, ref) {
4632
4637
  var placement = (attributes.popper &&
4633
4638
  attributes.popper['data-popper-placement']) ||
4634
4639
  initialPlacement;
4635
- var additionalProps = variant === 'prompt' ? { 'aria-labelledby': "".concat(id, "-label") } : {};
4640
+ var additionalProps = variant === 'prompt' && !props['aria-label']
4641
+ ? { 'aria-labelledby': "".concat(id, "-label") }
4642
+ : {};
4636
4643
  // Keep targetElement in sync with target prop
4637
4644
  React.useEffect(function () {
4638
4645
  var targetElement = target && 'current' in target ? target.current : target;
@@ -4724,7 +4731,7 @@ var Popover = React.forwardRef(function (_a, ref) {
4724
4731
  React__default["default"].createElement("div", tslib.__assign({ id: id, className: classNames__default["default"]('Popover', "Popover--".concat(placement), className, {
4725
4732
  'Popover--hidden': !show,
4726
4733
  'Popover--prompt': variant === 'prompt'
4727
- }), ref: popoverRef, role: "dialog", style: styles.popper }, attributes.popper, props, additionalProps),
4734
+ }), ref: popoverRef, role: "dialog", style: styles.popper }, attributes.popper, additionalProps, props),
4728
4735
  React__default["default"].createElement("div", { className: "Popover__popoverArrow", ref: setArrowElement, style: styles.arrow }),
4729
4736
  React__default["default"].createElement("div", { className: "Popover__borderLeft" }),
4730
4737
  variant === 'prompt' ? (React__default["default"].createElement(PromptPopoverContent, { applyButtonText: applyButtonText, onApply: onApply, closeButtonText: closeButtonText, infoText: infoText || '', onClose: handleClosePopover, infoTextId: "".concat(id, "-label") })) : (children)))), (portal && 'current' in portal ? portal.current : portal) || document.body);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deque/cauldron-react",
3
- "version": "5.12.0",
3
+ "version": "5.13.0-canary.d71c768d",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Fully accessible react components library for Deque Cauldron",
6
6
  "homepage": "https://cauldron.dequelabs.com/",
@@ -57,7 +57,7 @@
57
57
  "enzyme": "^3.11.0",
58
58
  "enzyme-adapter-react-16": "^1.15.2",
59
59
  "jest": "^24.7.1",
60
- "jest-axe": "^3.4.0",
60
+ "jest-axe": "^8.0.0",
61
61
  "nyc": "^15.0.1",
62
62
  "postcss-cli": "^7.1.1",
63
63
  "postcss-import": "^12.0.1",