@patternfly/react-table 4.106.3 → 4.106.6

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.
@@ -1550,6 +1550,8 @@
1550
1550
  prefix: 'pf-random-id-'
1551
1551
  };
1552
1552
 
1553
+ const ASTERISK = '*';
1554
+
1553
1555
  let uid = 0;
1554
1556
  const ouiaPrefix = 'OUIA-Generated-';
1555
1557
  const ouiaIdByRoute = {};
@@ -4929,31 +4931,32 @@
4929
4931
  this.additionalRef = React__namespace.createRef();
4930
4932
  this.getInnerNode = (node) => (node && node.childNodes && node.childNodes.length ? node.childNodes[0] : node);
4931
4933
  this.onKeyDown = (event) => {
4934
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
4932
4935
  // Detected key press on this item, notify the menu parent so that the appropriate item can be focused
4933
4936
  const innerIndex = event.target === this.ref.current ? 0 : 1;
4934
4937
  if (!this.props.customChild) {
4935
4938
  event.preventDefault();
4936
4939
  }
4937
4940
  if (event.key === 'ArrowUp') {
4938
- this.props.context.keyHandler(this.props.index, innerIndex, KEYHANDLER_DIRECTION.UP);
4941
+ (_b = (_a = this.props.context) === null || _a === void 0 ? void 0 : _a.keyHandler) === null || _b === void 0 ? void 0 : _b.call(_a, this.props.index, innerIndex, KEYHANDLER_DIRECTION.UP);
4939
4942
  event.stopPropagation();
4940
4943
  }
4941
4944
  else if (event.key === 'ArrowDown') {
4942
- this.props.context.keyHandler(this.props.index, innerIndex, KEYHANDLER_DIRECTION.DOWN);
4945
+ (_d = (_c = this.props.context) === null || _c === void 0 ? void 0 : _c.keyHandler) === null || _d === void 0 ? void 0 : _d.call(_c, this.props.index, innerIndex, KEYHANDLER_DIRECTION.DOWN);
4943
4946
  event.stopPropagation();
4944
4947
  }
4945
4948
  else if (event.key === 'ArrowRight') {
4946
- this.props.context.keyHandler(this.props.index, innerIndex, KEYHANDLER_DIRECTION.RIGHT);
4949
+ (_f = (_e = this.props.context) === null || _e === void 0 ? void 0 : _e.keyHandler) === null || _f === void 0 ? void 0 : _f.call(_e, this.props.index, innerIndex, KEYHANDLER_DIRECTION.RIGHT);
4947
4950
  event.stopPropagation();
4948
4951
  }
4949
4952
  else if (event.key === 'ArrowLeft') {
4950
- this.props.context.keyHandler(this.props.index, innerIndex, KEYHANDLER_DIRECTION.LEFT);
4953
+ (_h = (_g = this.props.context) === null || _g === void 0 ? void 0 : _g.keyHandler) === null || _h === void 0 ? void 0 : _h.call(_g, this.props.index, innerIndex, KEYHANDLER_DIRECTION.LEFT);
4951
4954
  event.stopPropagation();
4952
4955
  }
4953
4956
  else if (event.key === 'Enter' || event.key === ' ') {
4954
4957
  event.target.click();
4955
4958
  this.props.enterTriggersArrowDown &&
4956
- this.props.context.keyHandler(this.props.index, innerIndex, KEYHANDLER_DIRECTION.DOWN);
4959
+ ((_k = (_j = this.props.context) === null || _j === void 0 ? void 0 : _j.keyHandler) === null || _k === void 0 ? void 0 : _k.call(_j, this.props.index, innerIndex, KEYHANDLER_DIRECTION.DOWN));
4957
4960
  }
4958
4961
  };
4959
4962
  this.componentRef = (element) => {
@@ -4971,15 +4974,17 @@
4971
4974
  };
4972
4975
  }
4973
4976
  componentDidMount() {
4977
+ var _a;
4974
4978
  const { context, index, isDisabled, role, customChild, autoFocus } = this.props;
4975
4979
  const customRef = customChild ? this.getInnerNode(this.ref.current) : this.ref.current;
4976
- context.sendRef(index, [customRef, customChild ? customRef : this.additionalRef.current], isDisabled, role === 'separator');
4980
+ (_a = context === null || context === void 0 ? void 0 : context.sendRef) === null || _a === void 0 ? void 0 : _a.call(context, index, [customRef, customChild ? customRef : this.additionalRef.current], isDisabled, role === 'separator');
4977
4981
  autoFocus && setTimeout(() => customRef.focus());
4978
4982
  }
4979
4983
  componentDidUpdate() {
4984
+ var _a;
4980
4985
  const { context, index, isDisabled, role, customChild } = this.props;
4981
4986
  const customRef = customChild ? this.getInnerNode(this.ref.current) : this.ref.current;
4982
- context.sendRef(index, [customRef, customChild ? customRef : this.additionalRef.current], isDisabled, role === 'separator');
4987
+ (_a = context === null || context === void 0 ? void 0 : context.sendRef) === null || _a === void 0 ? void 0 : _a.call(context, index, [customRef, customChild ? customRef : this.additionalRef.current], isDisabled, role === 'separator');
4983
4988
  }
4984
4989
  extendAdditionalChildRef() {
4985
4990
  const { additionalChild } = this.props;
@@ -5024,12 +5029,12 @@
5024
5029
  onKeyDown: this.onKeyDown
5025
5030
  });
5026
5031
  }
5027
- return (React__namespace.createElement("li", { className: listItemClassName || null, role: "none", onKeyDown: this.onKeyDown, onClick: (event) => {
5032
+ return (React__namespace.createElement("li", Object.assign({}, (listItemClassName && { className: listItemClassName }), { role: "none", onKeyDown: this.onKeyDown, onClick: (event) => {
5028
5033
  if (!isDisabled && !isAriaDisabled) {
5029
- onClick(event);
5030
- onSelect(event);
5034
+ onClick === null || onClick === void 0 ? void 0 : onClick(event);
5035
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect(event);
5031
5036
  }
5032
- }, id: id },
5037
+ }, id: id }),
5033
5038
  renderWithTooltip(React__namespace.isValidElement(component)
5034
5039
  ? renderClonedComponent(component)
5035
5040
  : renderDefaultComponent(component)),
@@ -5207,10 +5212,11 @@
5207
5212
  const clickedOnToggle = parentRef && parentRef.current && parentRef.current.contains(event.target);
5208
5213
  const clickedWithinMenu = menuRef && menuRef.contains && menuRef.contains(event.target);
5209
5214
  if (isOpen && !(clickedOnToggle || clickedWithinMenu)) {
5210
- onToggle(false, event);
5215
+ onToggle === null || onToggle === void 0 ? void 0 : onToggle(false, event);
5211
5216
  }
5212
5217
  };
5213
5218
  this.onEscPress = (event) => {
5219
+ var _a, _b, _c;
5214
5220
  const { parentRef, getMenuRef } = this.props;
5215
5221
  const menuRef = getMenuRef && getMenuRef();
5216
5222
  const escFromToggle = parentRef && parentRef.current && parentRef.current.contains(event.target);
@@ -5218,11 +5224,12 @@
5218
5224
  if (this.props.isOpen &&
5219
5225
  (event.key === KeyTypes.Escape || event.key === 'Tab') &&
5220
5226
  (escFromToggle || escFromWithinMenu)) {
5221
- this.props.onToggle(false, event);
5222
- this.buttonRef.current.focus();
5227
+ (_b = (_a = this.props).onToggle) === null || _b === void 0 ? void 0 : _b.call(_a, false, event);
5228
+ (_c = this.buttonRef.current) === null || _c === void 0 ? void 0 : _c.focus();
5223
5229
  }
5224
5230
  };
5225
5231
  this.onKeyDown = (event) => {
5232
+ var _a, _b, _c, _d, _e, _f;
5226
5233
  if (event.key === 'Tab' && !this.props.isOpen) {
5227
5234
  return;
5228
5235
  }
@@ -5231,15 +5238,15 @@
5231
5238
  event.stopPropagation();
5232
5239
  }
5233
5240
  event.preventDefault();
5234
- this.props.onToggle(!this.props.isOpen, event);
5241
+ (_b = (_a = this.props).onToggle) === null || _b === void 0 ? void 0 : _b.call(_a, !this.props.isOpen, event);
5235
5242
  }
5236
5243
  else if ((event.key === 'Enter' || event.key === ' ') && !this.props.isOpen) {
5237
5244
  if (!this.props.bubbleEvent) {
5238
5245
  event.stopPropagation();
5239
5246
  }
5240
5247
  event.preventDefault();
5241
- this.props.onToggle(!this.props.isOpen, event);
5242
- this.props.onEnter();
5248
+ (_d = (_c = this.props).onToggle) === null || _d === void 0 ? void 0 : _d.call(_c, !this.props.isOpen, event);
5249
+ (_f = (_e = this.props).onEnter) === null || _f === void 0 ? void 0 : _f.call(_e);
5243
5250
  }
5244
5251
  };
5245
5252
  }
@@ -5249,7 +5256,7 @@
5249
5256
  isActive, bubbleEvent, onEnter, parentRef, getMenuRef,
5250
5257
  /* eslint-enable @typescript-eslint/no-unused-vars */
5251
5258
  id, type } = _a, props = __rest$1(_a, ["className", "children", "isOpen", "isDisabled", "isPlain", "isText", "isPrimary", "isSplitButton", "toggleVariant", "onToggle", 'aria-haspopup', "isActive", "bubbleEvent", "onEnter", "parentRef", "getMenuRef", "id", "type"]);
5252
- return (React__namespace.createElement(DropdownContext.Consumer, null, ({ toggleClass }) => (React__namespace.createElement("button", Object.assign({}, props, { id: id, ref: this.buttonRef, className: css(isSplitButton ? styles$8.dropdownToggleButton : toggleClass || styles$8.dropdownToggle, isActive && styles$8.modifiers.active, isPlain && styles$8.modifiers.plain, isText && styles$8.modifiers.text, isPrimary && styles$8.modifiers.primary, buttonVariantStyles[toggleVariant], className), type: type || 'button', onClick: event => onToggle(!isOpen, event), "aria-expanded": isOpen, "aria-haspopup": ariaHasPopup, onKeyDown: event => this.onKeyDown(event), disabled: isDisabled }), children))));
5259
+ return (React__namespace.createElement(DropdownContext.Consumer, null, ({ toggleClass }) => (React__namespace.createElement("button", Object.assign({}, props, { id: id, ref: this.buttonRef, className: css(isSplitButton ? styles$8.dropdownToggleButton : toggleClass || styles$8.dropdownToggle, isActive && styles$8.modifiers.active, isPlain && styles$8.modifiers.plain, isText && styles$8.modifiers.text, isPrimary && styles$8.modifiers.primary, toggleVariant && buttonVariantStyles[toggleVariant], className), type: type || 'button', onClick: event => onToggle === null || onToggle === void 0 ? void 0 : onToggle(!isOpen, event), "aria-expanded": isOpen, "aria-haspopup": ariaHasPopup, onKeyDown: event => this.onKeyDown(event), disabled: isDisabled }), children))));
5253
5260
  }
5254
5261
  }
5255
5262
  Toggle.displayName = 'Toggle';
@@ -7275,7 +7282,7 @@
7275
7282
  };
7276
7283
  }
7277
7284
  render() {
7278
- const _a = this.props, { 'aria-label': ariaLabel, className, onChange, isValid, isDisabled, isChecked, label, checked, defaultChecked, description, body, ouiaId, ouiaSafe, component: Component } = _a, props = __rest$1(_a, ['aria-label', "className", "onChange", "isValid", "isDisabled", "isChecked", "label", "checked", "defaultChecked", "description", "body", "ouiaId", "ouiaSafe", "component"]);
7285
+ const _a = this.props, { 'aria-label': ariaLabel, className, onChange, isValid, isDisabled, isRequired, isChecked, label, checked, defaultChecked, description, body, ouiaId, ouiaSafe, component: Component } = _a, props = __rest$1(_a, ['aria-label', "className", "onChange", "isValid", "isDisabled", "isRequired", "isChecked", "label", "checked", "defaultChecked", "description", "body", "ouiaId", "ouiaSafe", "component"]);
7279
7286
  if (!props.id) {
7280
7287
  // eslint-disable-next-line no-console
7281
7288
  console.error('Checkbox:', 'id is required to make input accessible');
@@ -7292,8 +7299,10 @@
7292
7299
  }
7293
7300
  checkedProps.checked = checkedProps.checked === null ? false : checkedProps.checked;
7294
7301
  return (React__namespace.createElement(Component, { className: css(checkStyles.check, !label && checkStyles.modifiers.standalone, className) },
7295
- React__namespace.createElement("input", Object.assign({}, props, { className: css(checkStyles.checkInput), type: "checkbox", onChange: this.handleChange, "aria-invalid": !isValid, "aria-label": ariaLabel, disabled: isDisabled, ref: elem => elem && (elem.indeterminate = isChecked === null) }, checkedProps, getOUIAProps(Checkbox.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId, ouiaSafe))),
7296
- label && (React__namespace.createElement("label", { className: css(checkStyles.checkLabel, isDisabled && checkStyles.modifiers.disabled), htmlFor: props.id }, label)),
7302
+ React__namespace.createElement("input", Object.assign({}, props, { className: css(checkStyles.checkInput), type: "checkbox", onChange: this.handleChange, "aria-invalid": !isValid, "aria-label": ariaLabel, disabled: isDisabled, required: isRequired, ref: elem => elem && (elem.indeterminate = isChecked === null) }, checkedProps, getOUIAProps(Checkbox.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId, ouiaSafe))),
7303
+ label && (React__namespace.createElement("label", { className: css(checkStyles.checkLabel, isDisabled && checkStyles.modifiers.disabled), htmlFor: props.id },
7304
+ label,
7305
+ isRequired && (React__namespace.createElement("span", { className: css(checkStyles.checkLabelRequired), "aria-hidden": "true" }, ASTERISK)))),
7297
7306
  description && React__namespace.createElement("span", { className: css(checkStyles.checkDescription) }, description),
7298
7307
  body && React__namespace.createElement("span", { className: css(checkStyles.checkBody) }, body)));
7299
7308
  }
@@ -7303,6 +7312,7 @@
7303
7312
  className: '',
7304
7313
  isValid: true,
7305
7314
  isDisabled: false,
7315
+ isRequired: false,
7306
7316
  isChecked: false,
7307
7317
  onChange: defaultOnChange,
7308
7318
  ouiaSafe: true,