@patternfly/react-core 4.232.11 → 4.233.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/esm/components/ExpandableSection/ExpandableSection.d.ts +17 -3
  3. package/dist/esm/components/ExpandableSection/ExpandableSection.d.ts.map +1 -1
  4. package/dist/esm/components/ExpandableSection/ExpandableSection.js +39 -8
  5. package/dist/esm/components/ExpandableSection/ExpandableSection.js.map +1 -1
  6. package/dist/esm/components/ExpandableSection/ExpandableSectionToggle.d.ts +2 -0
  7. package/dist/esm/components/ExpandableSection/ExpandableSectionToggle.d.ts.map +1 -1
  8. package/dist/esm/components/ExpandableSection/ExpandableSectionToggle.js +4 -4
  9. package/dist/esm/components/ExpandableSection/ExpandableSectionToggle.js.map +1 -1
  10. package/dist/esm/components/InputGroup/InputGroup.d.ts.map +1 -1
  11. package/dist/esm/components/InputGroup/InputGroup.js +5 -3
  12. package/dist/esm/components/InputGroup/InputGroup.js.map +1 -1
  13. package/dist/esm/components/Label/Label.d.ts.map +1 -1
  14. package/dist/esm/components/Label/Label.js +3 -0
  15. package/dist/esm/components/Label/Label.js.map +1 -1
  16. package/dist/esm/components/LabelGroup/LabelGroup.d.ts +4 -4
  17. package/dist/esm/components/LabelGroup/LabelGroup.d.ts.map +1 -1
  18. package/dist/esm/components/NumberInput/NumberInput.d.ts +5 -0
  19. package/dist/esm/components/NumberInput/NumberInput.d.ts.map +1 -1
  20. package/dist/esm/components/NumberInput/NumberInput.js +5 -4
  21. package/dist/esm/components/NumberInput/NumberInput.js.map +1 -1
  22. package/dist/js/components/ExpandableSection/ExpandableSection.d.ts +17 -3
  23. package/dist/js/components/ExpandableSection/ExpandableSection.d.ts.map +1 -1
  24. package/dist/js/components/ExpandableSection/ExpandableSection.js +40 -9
  25. package/dist/js/components/ExpandableSection/ExpandableSection.js.map +1 -1
  26. package/dist/js/components/ExpandableSection/ExpandableSectionToggle.d.ts +2 -0
  27. package/dist/js/components/ExpandableSection/ExpandableSectionToggle.d.ts.map +1 -1
  28. package/dist/js/components/ExpandableSection/ExpandableSectionToggle.js +4 -4
  29. package/dist/js/components/ExpandableSection/ExpandableSectionToggle.js.map +1 -1
  30. package/dist/js/components/InputGroup/InputGroup.d.ts.map +1 -1
  31. package/dist/js/components/InputGroup/InputGroup.js +5 -3
  32. package/dist/js/components/InputGroup/InputGroup.js.map +1 -1
  33. package/dist/js/components/Label/Label.d.ts.map +1 -1
  34. package/dist/js/components/Label/Label.js +3 -0
  35. package/dist/js/components/Label/Label.js.map +1 -1
  36. package/dist/js/components/LabelGroup/LabelGroup.d.ts +4 -4
  37. package/dist/js/components/LabelGroup/LabelGroup.d.ts.map +1 -1
  38. package/dist/js/components/NumberInput/NumberInput.d.ts +5 -0
  39. package/dist/js/components/NumberInput/NumberInput.d.ts.map +1 -1
  40. package/dist/js/components/NumberInput/NumberInput.js +4 -3
  41. package/dist/js/components/NumberInput/NumberInput.js.map +1 -1
  42. package/dist/umd/react-core.css +69 -69
  43. package/dist/umd/react-core.js +59 -18
  44. package/dist/umd/react-core.min.css +756 -756
  45. package/dist/umd/react-core.min.js +5 -5
  46. package/package.json +6 -6
  47. package/src/components/ExpandableSection/ExpandableSection.tsx +73 -19
  48. package/src/components/ExpandableSection/ExpandableSectionToggle.tsx +15 -9
  49. package/src/components/ExpandableSection/__tests__/ExpandableSection.test.tsx +27 -1
  50. package/src/components/ExpandableSection/examples/ExpandableSection.md +7 -0
  51. package/src/components/ExpandableSection/examples/ExpandableSectionTruncateExpansion.tsx +27 -0
  52. package/src/components/InputGroup/InputGroup.tsx +5 -3
  53. package/src/components/InputGroup/__tests__/InputGroup.test.tsx +30 -0
  54. package/src/components/Label/Label.tsx +3 -1
  55. package/src/components/LabelGroup/LabelGroup.tsx +4 -4
  56. package/src/components/LabelGroup/examples/LabelGroup.md +1 -1
  57. package/src/components/LabelGroup/examples/LabelGroupEditableAdd.tsx +1 -1
  58. package/src/components/LabelGroup/examples/LabelGroupEditableAddDropdown.tsx +1 -1
  59. package/src/components/LabelGroup/examples/LabelGroupEditableAddModal.tsx +23 -21
  60. package/src/components/NumberInput/NumberInput.tsx +14 -8
  61. package/src/components/NumberInput/__tests__/NumberInput.test.tsx +16 -0
  62. package/src/components/NumberInput/__tests__/__snapshots__/NumberInput.test.tsx.snap +292 -18
  63. package/src/components/NumberInput/examples/NumberInput.md +5 -0
  64. package/src/components/NumberInput/examples/WithStatus.tsx +59 -0
@@ -8576,9 +8576,11 @@
8576
8576
  const idItem = React__namespace.Children.toArray(children).find((child) => !formCtrls.includes(child.type.displayName) && child.props.id);
8577
8577
  const inputGroupRef = innerRef || React__namespace.useRef(null);
8578
8578
  return (React__namespace.createElement("div", Object.assign({ ref: inputGroupRef, className: css(styles$U.inputGroup, className) }, props), idItem
8579
- ? React__namespace.Children.map(children, (child) => formCtrls.includes(child.type.displayName)
8580
- ? React__namespace.cloneElement(child, { 'aria-describedby': idItem.props.id })
8581
- : child)
8579
+ ? React__namespace.Children.map(children, (child) => !formCtrls.includes(child.type.displayName) || child.props['aria-describedby']
8580
+ ? child
8581
+ : React__namespace.cloneElement(child, {
8582
+ 'aria-describedby': child.props['aria-describedby'] === '' ? undefined : idItem.props.id
8583
+ }))
8582
8584
  : children));
8583
8585
  };
8584
8586
  InputGroup.displayName = 'InputGroup';
@@ -11869,9 +11871,27 @@
11869
11871
  }
11870
11872
  };
11871
11873
 
11874
+ const c_expandable_section_m_truncate__content_LineClamp = {
11875
+ "name": "--pf-c-expandable-section--m-truncate__content--LineClamp",
11876
+ "value": "3",
11877
+ "var": "var(--pf-c-expandable-section--m-truncate__content--LineClamp)"
11878
+ };
11879
+
11880
+ exports.ExpandableSectionVariant = void 0;
11881
+ (function (ExpandableSectionVariant) {
11882
+ ExpandableSectionVariant["default"] = "default";
11883
+ ExpandableSectionVariant["truncate"] = "truncate";
11884
+ })(exports.ExpandableSectionVariant || (exports.ExpandableSectionVariant = {}));
11885
+ const setLineClamp = (lines, element) => {
11886
+ if (!element || lines < 1) {
11887
+ return;
11888
+ }
11889
+ element.style.setProperty(c_expandable_section_m_truncate__content_LineClamp.name, lines.toString());
11890
+ };
11872
11891
  class ExpandableSection extends React__namespace.Component {
11873
11892
  constructor(props) {
11874
11893
  super(props);
11894
+ this.expandableContentRef = React__namespace.createRef();
11875
11895
  this.state = {
11876
11896
  isExpanded: props.isExpanded
11877
11897
  };
@@ -11885,10 +11905,25 @@
11885
11905
  }
11886
11906
  return toggleText;
11887
11907
  }
11908
+ componentDidMount() {
11909
+ if (this.props.variant === exports.ExpandableSectionVariant.truncate && this.props.truncateMaxLines) {
11910
+ const expandableContent = this.expandableContentRef.current;
11911
+ setLineClamp(this.props.truncateMaxLines, expandableContent);
11912
+ }
11913
+ }
11914
+ componentDidUpdate(prevProps) {
11915
+ if (this.props.variant === exports.ExpandableSectionVariant.truncate &&
11916
+ prevProps.truncateMaxLines !== this.props.truncateMaxLines) {
11917
+ const expandableContent = this.expandableContentRef.current;
11918
+ setLineClamp(this.props.truncateMaxLines, expandableContent);
11919
+ }
11920
+ }
11888
11921
  render() {
11889
11922
  const _a = this.props, { onToggle: onToggleProp,
11890
11923
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
11891
- isActive, className, toggleText, toggleTextExpanded, toggleTextCollapsed, toggleContent, children, isExpanded, isDetached, displaySize, isWidthLimited, isIndented, contentId } = _a, props = __rest$1(_a, ["onToggle", "isActive", "className", "toggleText", "toggleTextExpanded", "toggleTextCollapsed", "toggleContent", "children", "isExpanded", "isDetached", "displaySize", "isWidthLimited", "isIndented", "contentId"]);
11924
+ isActive, className, toggleText, toggleTextExpanded, toggleTextCollapsed, toggleContent, children, isExpanded, isDetached, displaySize, isWidthLimited, isIndented, contentId, variant,
11925
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
11926
+ truncateMaxLines } = _a, props = __rest$1(_a, ["onToggle", "isActive", "className", "toggleText", "toggleTextExpanded", "toggleTextCollapsed", "toggleContent", "children", "isExpanded", "isDetached", "displaySize", "isWidthLimited", "isIndented", "contentId", "variant", "truncateMaxLines"]);
11892
11927
  let onToggle = onToggleProp;
11893
11928
  let propOrStateIsExpanded = isExpanded;
11894
11929
  // uncontrolled
@@ -11899,12 +11934,14 @@
11899
11934
  };
11900
11935
  }
11901
11936
  const computedToggleText = this.calculateToggleText(toggleText, toggleTextExpanded, toggleTextCollapsed, propOrStateIsExpanded);
11902
- return (React__namespace.createElement("div", Object.assign({}, props, { className: css(styles$I.expandableSection, propOrStateIsExpanded && styles$I.modifiers.expanded, isActive && styles$I.modifiers.active, isDetached && styles$I.modifiers.detached, displaySize === 'large' && styles$I.modifiers.displayLg, isWidthLimited && styles$I.modifiers.limitWidth, isIndented && styles$I.modifiers.indented, className) }),
11903
- !isDetached && (React__namespace.createElement("button", { className: css(styles$I.expandableSectionToggle), type: "button", "aria-expanded": propOrStateIsExpanded, onClick: () => onToggle(!propOrStateIsExpanded) },
11904
- React__namespace.createElement("span", { className: css(styles$I.expandableSectionToggleIcon) },
11905
- React__namespace.createElement(AngleRightIcon, { "aria-hidden": true })),
11906
- React__namespace.createElement("span", { className: css(styles$I.expandableSectionToggleText) }, toggleContent || computedToggleText))),
11907
- React__namespace.createElement("div", { className: css(styles$I.expandableSectionContent), hidden: !propOrStateIsExpanded, id: contentId }, children)));
11937
+ const expandableToggle = !isDetached && (React__namespace.createElement("button", { className: css(styles$I.expandableSectionToggle), type: "button", "aria-expanded": propOrStateIsExpanded, onClick: () => onToggle(!propOrStateIsExpanded) },
11938
+ variant !== exports.ExpandableSectionVariant.truncate && (React__namespace.createElement("span", { className: css(styles$I.expandableSectionToggleIcon) },
11939
+ React__namespace.createElement(AngleRightIcon, { "aria-hidden": true }))),
11940
+ React__namespace.createElement("span", { className: css(styles$I.expandableSectionToggleText) }, toggleContent || computedToggleText)));
11941
+ return (React__namespace.createElement("div", Object.assign({ className: css(styles$I.expandableSection, propOrStateIsExpanded && styles$I.modifiers.expanded, isActive && styles$I.modifiers.active, isDetached && styles$I.modifiers.detached, displaySize === 'large' && styles$I.modifiers.displayLg, isWidthLimited && styles$I.modifiers.limitWidth, isIndented && styles$I.modifiers.indented, variant === exports.ExpandableSectionVariant.truncate && styles$I.modifiers.truncate, className) }, props),
11942
+ variant === exports.ExpandableSectionVariant.default && expandableToggle,
11943
+ React__namespace.createElement("div", { ref: this.expandableContentRef, className: css(styles$I.expandableSectionContent), hidden: variant !== exports.ExpandableSectionVariant.truncate && !propOrStateIsExpanded, id: contentId }, children),
11944
+ variant === exports.ExpandableSectionVariant.truncate && expandableToggle));
11908
11945
  }
11909
11946
  }
11910
11947
  ExpandableSection.displayName = 'ExpandableSection';
@@ -11920,15 +11957,16 @@
11920
11957
  displaySize: 'default',
11921
11958
  isWidthLimited: false,
11922
11959
  isIndented: false,
11923
- contentId: ''
11960
+ contentId: '',
11961
+ variant: 'default'
11924
11962
  };
11925
11963
 
11926
11964
  const ExpandableSectionToggle = (_a) => {
11927
- var { children, className = '', isExpanded = false, onToggle, contentId, direction = 'down' } = _a, props = __rest$1(_a, ["children", "className", "isExpanded", "onToggle", "contentId", "direction"]);
11928
- return (React__namespace.createElement("div", Object.assign({}, props, { className: css(styles$I.expandableSection, isExpanded && styles$I.modifiers.expanded, styles$I.modifiers.detached, className) }),
11965
+ var { children, className = '', isExpanded = false, onToggle, contentId, direction = 'down', hasTruncatedContent = false } = _a, props = __rest$1(_a, ["children", "className", "isExpanded", "onToggle", "contentId", "direction", "hasTruncatedContent"]);
11966
+ return (React__namespace.createElement("div", Object.assign({ className: css(styles$I.expandableSection, isExpanded && styles$I.modifiers.expanded, styles$I.modifiers.detached, hasTruncatedContent && styles$I.modifiers.truncate, className) }, props),
11929
11967
  React__namespace.createElement("button", { className: css(styles$I.expandableSectionToggle), type: "button", "aria-expanded": isExpanded, "aria-controls": contentId, onClick: () => onToggle(!isExpanded) },
11930
- React__namespace.createElement("span", { className: css(styles$I.expandableSectionToggleIcon, isExpanded && direction === 'up' && styles$I.modifiers.expandTop) },
11931
- React__namespace.createElement(AngleRightIcon, { "aria-hidden": true })),
11968
+ !hasTruncatedContent && (React__namespace.createElement("span", { className: css(styles$I.expandableSectionToggleIcon, isExpanded && direction === 'up' && styles$I.modifiers.expandTop) },
11969
+ React__namespace.createElement(AngleRightIcon, { "aria-hidden": true }))),
11932
11970
  React__namespace.createElement("span", { className: css(styles$I.expandableSectionToggleText) }, children))));
11933
11971
  };
11934
11972
  ExpandableSectionToggle.displayName = 'ExpandableSectionToggle';
@@ -14664,6 +14702,7 @@
14664
14702
  }
14665
14703
  };
14666
14704
  const onKeyDown = (event) => {
14705
+ var _a, _b;
14667
14706
  const key = event.key;
14668
14707
  if ((!isEditableActive &&
14669
14708
  (!editableButtonRef ||
@@ -14680,6 +14719,7 @@
14680
14719
  onEditComplete && onEditComplete(editableInputRef.current.value);
14681
14720
  }
14682
14721
  setIsEditableActive(false);
14722
+ (_a = editableButtonRef === null || editableButtonRef === void 0 ? void 0 : editableButtonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
14683
14723
  }
14684
14724
  if (isEditableActive && key === 'Escape') {
14685
14725
  event.preventDefault();
@@ -14690,6 +14730,7 @@
14690
14730
  onEditCancel && onEditCancel(children);
14691
14731
  }
14692
14732
  setIsEditableActive(false);
14733
+ (_b = editableButtonRef === null || editableButtonRef === void 0 ? void 0 : editableButtonRef.current) === null || _b === void 0 ? void 0 : _b.focus();
14693
14734
  }
14694
14735
  if (!isEditableActive && key === 'Enter') {
14695
14736
  event.preventDefault();
@@ -20707,7 +20748,7 @@
20707
20748
  }
20708
20749
  };
20709
20750
  const NumberInput = (_a) => {
20710
- var { value = 0, className, widthChars, isDisabled = false, onMinus = () => { }, onChange, onBlur, onPlus = () => { }, unit, unitPosition = 'after', min, max, inputName, inputAriaLabel = 'Input', minusBtnAriaLabel = 'Minus', plusBtnAriaLabel = 'Plus', inputProps, minusBtnProps, plusBtnProps } = _a, props = __rest$1(_a, ["value", "className", "widthChars", "isDisabled", "onMinus", "onChange", "onBlur", "onPlus", "unit", "unitPosition", "min", "max", "inputName", "inputAriaLabel", "minusBtnAriaLabel", "plusBtnAriaLabel", "inputProps", "minusBtnProps", "plusBtnProps"]);
20751
+ var { value = 0, className, widthChars, isDisabled = false, validated = exports.ValidatedOptions.default, onMinus = () => { }, onChange, onBlur, onPlus = () => { }, unit, unitPosition = 'after', min, max, inputName, inputAriaLabel = 'Input', minusBtnAriaLabel = 'Minus', plusBtnAriaLabel = 'Plus', inputProps, minusBtnProps, plusBtnProps } = _a, props = __rest$1(_a, ["value", "className", "widthChars", "isDisabled", "validated", "onMinus", "onChange", "onBlur", "onPlus", "unit", "unitPosition", "min", "max", "inputName", "inputAriaLabel", "minusBtnAriaLabel", "plusBtnAriaLabel", "inputProps", "minusBtnProps", "plusBtnProps"]);
20711
20752
  const numberInputUnit = React__namespace.createElement("div", { className: css(styles$a.numberInputUnit) }, unit);
20712
20753
  const keyDownHandler = inputProps && inputProps.onKeyDown ? inputProps.onKeyDown : defaultKeyDownHandler({ inputName, onMinus, onPlus });
20713
20754
  const handleBlur = (event) => {
@@ -20719,7 +20760,7 @@
20719
20760
  onBlur(event);
20720
20761
  }
20721
20762
  };
20722
- return (React__namespace.createElement("div", Object.assign({ className: css(styles$a.numberInput, className) }, (widthChars && {
20763
+ return (React__namespace.createElement("div", Object.assign({ className: css(styles$a.numberInput, validated !== 'default' && styles$a.modifiers.status, className) }, (widthChars && {
20723
20764
  style: Object.assign({ '--pf-c-number-input--c-form-control--width-chars': widthChars }, props.style)
20724
20765
  }), props),
20725
20766
  unit && unitPosition === 'before' && numberInputUnit,
@@ -20727,7 +20768,7 @@
20727
20768
  React__namespace.createElement(Button, Object.assign({ variant: "control", "aria-label": minusBtnAriaLabel, isDisabled: isDisabled || value <= min, onClick: evt => onMinus(evt, inputName) }, minusBtnProps),
20728
20769
  React__namespace.createElement("span", { className: css(styles$a.numberInputIcon) },
20729
20770
  React__namespace.createElement(MinusIcon, { "aria-hidden": "true" }))),
20730
- React__namespace.createElement("input", Object.assign({ className: css(styles$a.formControl), type: "number", value: value, name: inputName, "aria-label": inputAriaLabel }, (isDisabled && { disabled: isDisabled }), (onChange && { onChange }), { onBlur: handleBlur }, (!onChange && { readOnly: true }), inputProps, { onKeyDown: keyDownHandler })),
20771
+ React__namespace.createElement(TextInput, Object.assign({ type: "number", value: value, name: inputName, "aria-label": inputAriaLabel }, (isDisabled && { isDisabled }), (onChange && { onChange: (value, event) => onChange(event) }), { onBlur: handleBlur }, (!onChange && { isReadOnly: true }), { onKeyDown: keyDownHandler, validated: validated }, inputProps)),
20731
20772
  React__namespace.createElement(Button, Object.assign({ variant: "control", "aria-label": plusBtnAriaLabel, isDisabled: isDisabled || value >= max, onClick: evt => onPlus(evt, inputName) }, plusBtnProps),
20732
20773
  React__namespace.createElement("span", { className: css(styles$a.numberInputIcon) },
20733
20774
  React__namespace.createElement(PlusIcon, { "aria-hidden": "true" })))),