@patternfly/react-core 4.202.8 → 4.202.11

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 (54) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/esm/components/Drawer/Drawer.d.ts +1 -0
  3. package/dist/esm/components/Drawer/Drawer.d.ts.map +1 -1
  4. package/dist/esm/components/Drawer/Drawer.js +3 -2
  5. package/dist/esm/components/Drawer/Drawer.js.map +1 -1
  6. package/dist/esm/components/Drawer/DrawerContent.d.ts.map +1 -1
  7. package/dist/esm/components/Drawer/DrawerContent.js +3 -2
  8. package/dist/esm/components/Drawer/DrawerContent.js.map +1 -1
  9. package/dist/esm/components/Drawer/DrawerPanelContent.d.ts +2 -2
  10. package/dist/esm/components/Drawer/DrawerPanelContent.d.ts.map +1 -1
  11. package/dist/esm/components/Drawer/DrawerPanelContent.js +65 -37
  12. package/dist/esm/components/Drawer/DrawerPanelContent.js.map +1 -1
  13. package/dist/esm/components/Select/Select.d.ts.map +1 -1
  14. package/dist/esm/components/Select/Select.js +21 -14
  15. package/dist/esm/components/Select/Select.js.map +1 -1
  16. package/dist/esm/components/Select/SelectMenu.d.ts.map +1 -1
  17. package/dist/esm/components/Select/SelectMenu.js +10 -1
  18. package/dist/esm/components/Select/SelectMenu.js.map +1 -1
  19. package/dist/esm/components/Select/SelectOption.js +1 -1
  20. package/dist/esm/components/Select/SelectOption.js.map +1 -1
  21. package/dist/js/components/Drawer/Drawer.d.ts +1 -0
  22. package/dist/js/components/Drawer/Drawer.d.ts.map +1 -1
  23. package/dist/js/components/Drawer/Drawer.js +3 -2
  24. package/dist/js/components/Drawer/Drawer.js.map +1 -1
  25. package/dist/js/components/Drawer/DrawerContent.d.ts.map +1 -1
  26. package/dist/js/components/Drawer/DrawerContent.js +3 -2
  27. package/dist/js/components/Drawer/DrawerContent.js.map +1 -1
  28. package/dist/js/components/Drawer/DrawerPanelContent.d.ts +2 -2
  29. package/dist/js/components/Drawer/DrawerPanelContent.d.ts.map +1 -1
  30. package/dist/js/components/Drawer/DrawerPanelContent.js +65 -37
  31. package/dist/js/components/Drawer/DrawerPanelContent.js.map +1 -1
  32. package/dist/js/components/Select/Select.d.ts.map +1 -1
  33. package/dist/js/components/Select/Select.js +21 -14
  34. package/dist/js/components/Select/Select.js.map +1 -1
  35. package/dist/js/components/Select/SelectMenu.d.ts.map +1 -1
  36. package/dist/js/components/Select/SelectMenu.js +10 -1
  37. package/dist/js/components/Select/SelectMenu.js.map +1 -1
  38. package/dist/js/components/Select/SelectOption.js +1 -1
  39. package/dist/js/components/Select/SelectOption.js.map +1 -1
  40. package/dist/umd/react-core.js +102 -57
  41. package/dist/umd/react-core.min.js +1 -1
  42. package/package.json +5 -5
  43. package/src/components/Card/examples/Card.md +1 -1
  44. package/src/components/Drawer/Drawer.tsx +4 -2
  45. package/src/components/Drawer/DrawerContent.tsx +19 -15
  46. package/src/components/Drawer/DrawerPanelContent.tsx +110 -75
  47. package/src/components/Drawer/__tests__/Generated/DrawerContent.test.tsx +2 -2
  48. package/src/components/Drawer/__tests__/Generated/__snapshots__/DrawerContent.test.tsx.snap +88 -9
  49. package/src/components/Drawer/__tests__/Generated/__snapshots__/DrawerPanelContent.test.tsx.snap +1 -0
  50. package/src/components/Drawer/__tests__/__snapshots__/Drawer.test.tsx.snap +15 -2
  51. package/src/components/Select/Select.tsx +23 -17
  52. package/src/components/Select/SelectMenu.tsx +9 -1
  53. package/src/components/Select/SelectOption.tsx +1 -1
  54. package/src/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +4 -4
@@ -6202,7 +6202,7 @@
6202
6202
  }, ref: this.ref, type: "button" }), children || value.toString())));
6203
6203
  }
6204
6204
  else if (variant !== exports.SelectVariant.checkbox) {
6205
- return (React__namespace.createElement("li", { id: generatedId, role: "presentation", className: css(isLoading && _default$13.selectListItem, !isLoad && !isLoading && _default$13.selectMenuWrapper, isFavorite && _default$13.modifiers.favorite, isFocused && _default$13.modifiers.focus, isLoading && _default$13.modifiers.loading), ref: this.liRef },
6205
+ return (React__namespace.createElement("li", { id: generatedId, role: "presentation", className: css(isLoading && _default$13.selectListItem, !isLoading && _default$13.selectMenuWrapper, isFavorite && _default$13.modifiers.favorite, isFocused && _default$13.modifiers.focus, isLoading && _default$13.modifiers.loading), ref: this.liRef },
6206
6206
  isLoading && children,
6207
6207
  isLoad && !isGrouped && (React__namespace.createElement("button", Object.assign({}, props, { className: css(_default$13.selectMenuItem, _default$13.modifiers.load, className), onClick: (event) => {
6208
6208
  onViewMoreClick(event);
@@ -6359,9 +6359,18 @@
6359
6359
  let index = hasInlineFilter ? 1 : 0;
6360
6360
  if (isGrouped) {
6361
6361
  return React__namespace.Children.map(children, (group) => {
6362
- if (group.type === SelectOption || group.type === Divider) {
6362
+ if (group.type === Divider) {
6363
6363
  return group;
6364
6364
  }
6365
+ else if (group.type === SelectOption) {
6366
+ return React__namespace.cloneElement(group, {
6367
+ isChecked: this.checkForValue(group.props.value, checked),
6368
+ sendRef,
6369
+ keyHandler,
6370
+ index: index++,
6371
+ isLastOptionBeforeFooter
6372
+ });
6373
+ }
6365
6374
  return React__namespace.cloneElement(group, {
6366
6375
  titleId: group.props.label && group.props.label.replace(/\W/g, '-'),
6367
6376
  children: group.props.children ? (React__namespace.createElement("fieldset", { "aria-labelledby": group.props.label && group.props.label.replace(/\W/g, '-'), className: css(_default$13.selectMenuFieldset) }, React__namespace.Children.map(group.props.children, (option) => option.type === Divider
@@ -6829,7 +6838,9 @@
6829
6838
  this.state.viewMoreNextIndex !== -1 &&
6830
6839
  this.refCollection.length > this.state.viewMoreNextIndex &&
6831
6840
  this.props.loadingVariant !== 'spinner' &&
6832
- this.refCollection[this.state.viewMoreNextIndex][0]) {
6841
+ this.refCollection[this.state.viewMoreNextIndex][0] &&
6842
+ this.props.variant !== 'typeahead' && // do not hard focus newly added items for typeahead variants
6843
+ this.props.variant !== 'typeaheadmulti') {
6833
6844
  this.refCollection[this.state.viewMoreNextIndex][0].focus();
6834
6845
  }
6835
6846
  const hasUpdatedChildren = prevProps.children.length !== this.props.children.length ||
@@ -7031,6 +7042,7 @@
7031
7042
  this.moveFocus = (nextIndex, updateCurrentIndex = true) => {
7032
7043
  const { isCreatable, createText } = this.props;
7033
7044
  const hasDescriptionElm = Boolean(this.refCollection[nextIndex][0] && this.refCollection[nextIndex][0].classList.contains('pf-m-description'));
7045
+ const isLoad = Boolean(this.refCollection[nextIndex][0] && this.refCollection[nextIndex][0].classList.contains('pf-m-load'));
7034
7046
  const optionTextElm = hasDescriptionElm
7035
7047
  ? this.refCollection[nextIndex][0].firstElementChild
7036
7048
  : this.refCollection[nextIndex][0];
@@ -7038,7 +7050,8 @@
7038
7050
  if (isCreatable && optionTextElm.innerText.includes(createText)) {
7039
7051
  typeaheadInputValue = this.state.creatableValue;
7040
7052
  }
7041
- else if (optionTextElm) {
7053
+ else if (optionTextElm && !isLoad) {
7054
+ // !isLoad prevents the view more button text from appearing the typeahead input
7042
7055
  typeaheadInputValue = optionTextElm.innerText;
7043
7056
  }
7044
7057
  this.setState(prevState => ({
@@ -7084,15 +7097,17 @@
7084
7097
  if (typeaheadCurrIndex !== -1 && // do not allow selection without moving to an initial option
7085
7098
  (typeaheadActiveChild || (this.refCollection[0] && this.refCollection[0][0]))) {
7086
7099
  if (typeaheadActiveChild) {
7087
- const hasDescriptionElm = typeaheadActiveChild.childElementCount > 1;
7088
- const typeaheadActiveChildText = hasDescriptionElm
7089
- ? typeaheadActiveChild.firstChild.innerText
7090
- : typeaheadActiveChild.innerText;
7091
- this.setState({
7092
- typeaheadInputValue: typeaheadActiveChildText
7093
- });
7100
+ if (!typeaheadActiveChild.classList.contains('pf-m-load')) {
7101
+ const hasDescriptionElm = typeaheadActiveChild.childElementCount > 1;
7102
+ const typeaheadActiveChildText = hasDescriptionElm
7103
+ ? typeaheadActiveChild.firstChild.innerText
7104
+ : typeaheadActiveChild.innerText;
7105
+ this.setState({
7106
+ typeaheadInputValue: typeaheadActiveChildText
7107
+ });
7108
+ }
7094
7109
  }
7095
- else {
7110
+ else if (this.refCollection[0] && this.refCollection[0][0]) {
7096
7111
  this.setState({
7097
7112
  typeaheadInputValue: this.refCollection[0][0].innerText
7098
7113
  });
@@ -7371,15 +7386,16 @@
7371
7386
  }
7372
7387
  });
7373
7388
  }
7374
- return typeaheadChildren.map((child) => {
7389
+ return typeaheadChildren.map((child, index) => {
7375
7390
  const childElement = child;
7376
7391
  return childElement.type.displayName === 'Divider'
7377
7392
  ? child
7378
7393
  : React__namespace.cloneElement(child, {
7379
- isFocused: typeaheadActiveChild &&
7380
- (typeaheadActiveChild.innerText === child.props.value.toString() ||
7394
+ isFocused: typeaheadActiveChild
7395
+ ? typeaheadActiveChild.innerText === child.props.value.toString() ||
7381
7396
  (this.props.isCreatable &&
7382
- typeaheadActiveChild.innerText === `{createText} "${child.props.value}"`))
7397
+ typeaheadActiveChild.innerText === `{createText} "${child.props.value}"`)
7398
+ : index === typeaheadCurrIndex // fallback for view more + typeahead use cases, when the new expanded list is loaded and refCollection hasn't be updated yet
7383
7399
  });
7384
7400
  });
7385
7401
  }
@@ -9790,12 +9806,13 @@
9790
9806
  isStatic: false,
9791
9807
  onExpand: () => { },
9792
9808
  position: 'right',
9793
- drawerRef: null
9809
+ drawerRef: null,
9810
+ isInline: false
9794
9811
  });
9795
9812
  const Drawer = (_a) => {
9796
9813
  var { className = '', children, isExpanded = false, isInline = false, isStatic = false, position = 'right', onExpand = () => { } } = _a, props = __rest$1(_a, ["className", "children", "isExpanded", "isInline", "isStatic", "position", "onExpand"]);
9797
9814
  const drawerRef = React__namespace.useRef();
9798
- return (React__namespace.createElement(DrawerContext.Provider, { value: { isExpanded, isStatic, onExpand, position, drawerRef } },
9815
+ return (React__namespace.createElement(DrawerContext.Provider, { value: { isExpanded, isStatic, onExpand, position, drawerRef, isInline } },
9799
9816
  React__namespace.createElement("div", Object.assign({ className: css(_default$P.drawer, isExpanded && _default$P.modifiers.expanded, isInline && _default$P.modifiers.inline, isStatic && _default$P.modifiers.static, position === 'left' && _default$P.modifiers.panelLeft, position === 'bottom' && _default$P.modifiers.panelBottom, className), ref: drawerRef }, props), children)));
9800
9817
  };
9801
9818
  Drawer.displayName = 'Drawer';
@@ -9830,9 +9847,10 @@
9830
9847
  var {
9831
9848
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
9832
9849
  className = '', children, panelContent, colorVariant = exports.DrawerColorVariant.default } = _a, props = __rest$1(_a, ["className", "children", "panelContent", "colorVariant"]);
9850
+ const drawerContentRef = React__namespace.useRef();
9833
9851
  return (React__namespace.createElement(DrawerMain, null,
9834
- React__namespace.createElement("div", Object.assign({ className: css(_default$P.drawerContent, colorVariant === exports.DrawerColorVariant.light200 && _default$P.modifiers.light_200, className) }, props), children),
9835
- panelContent));
9852
+ React__namespace.createElement("div", Object.assign({ className: css(_default$P.drawerContent, colorVariant === exports.DrawerColorVariant.light200 && _default$P.modifiers.light_200, className), ref: drawerContentRef }, props), children),
9853
+ React__namespace.cloneElement(panelContent, { drawerContentRef })));
9836
9854
  };
9837
9855
  DrawerContent.displayName = 'DrawerContent';
9838
9856
 
@@ -9864,9 +9882,11 @@
9864
9882
  let isResizing = null;
9865
9883
  let newSize = 0;
9866
9884
  const DrawerPanelContent = (_a) => {
9867
- var { className = '', id, children, hasNoBorder = false, isResizable = false, onResize, minSize, defaultSize, maxSize, increment = 5, resizeAriaLabel = 'Resize', resizeAriaDescribedBy = 'Press space to begin resizing, and use the arrow keys to grow or shrink the panel. Press enter or escape to finish resizing.', widths, colorVariant = exports.DrawerColorVariant.default } = _a, props = __rest$1(_a, ["className", "id", "children", "hasNoBorder", "isResizable", "onResize", "minSize", "defaultSize", "maxSize", "increment", "resizeAriaLabel", "resizeAriaDescribedBy", "widths", "colorVariant"]);
9885
+ var { className = '', id, children, hasNoBorder = false, isResizable = false, onResize, minSize, defaultSize, maxSize, increment = 5, resizeAriaLabel = 'Resize', widths, colorVariant = exports.DrawerColorVariant.default, drawerContentRef } = _a, props = __rest$1(_a, ["className", "id", "children", "hasNoBorder", "isResizable", "onResize", "minSize", "defaultSize", "maxSize", "increment", "resizeAriaLabel", "widths", "colorVariant", "drawerContentRef"]);
9868
9886
  const panel = React__namespace.useRef();
9869
- const { position, isExpanded, isStatic, onExpand, drawerRef } = React__namespace.useContext(DrawerContext);
9887
+ const splitterRef = React__namespace.useRef();
9888
+ const [separatorValue, setSeparatorValue] = React__namespace.useState(0);
9889
+ const { position, isExpanded, isStatic, onExpand, drawerRef, isInline } = React__namespace.useContext(DrawerContext);
9870
9890
  const hidden = isStatic ? false : !isExpanded;
9871
9891
  const [isExpandedInternal, setIsExpandedInternal] = React__namespace.useState(!hidden);
9872
9892
  let currWidth = 0;
@@ -9880,6 +9900,38 @@
9880
9900
  setIsExpandedInternal(isExpanded);
9881
9901
  }
9882
9902
  }, [isStatic, isExpanded]);
9903
+ const calcValueNow = () => {
9904
+ let splitterPos;
9905
+ let drawerSize;
9906
+ if (isInline && position === 'right') {
9907
+ splitterPos = panel.current.getBoundingClientRect().right - splitterRef.current.getBoundingClientRect().left;
9908
+ drawerSize = drawerRef.current.getBoundingClientRect().right - drawerRef.current.getBoundingClientRect().left;
9909
+ }
9910
+ else if (isInline && position === 'left') {
9911
+ splitterPos = splitterRef.current.getBoundingClientRect().right - panel.current.getBoundingClientRect().left;
9912
+ drawerSize = drawerRef.current.getBoundingClientRect().right - drawerRef.current.getBoundingClientRect().left;
9913
+ }
9914
+ else if (position === 'right') {
9915
+ splitterPos =
9916
+ drawerContentRef.current.getBoundingClientRect().right - splitterRef.current.getBoundingClientRect().left;
9917
+ drawerSize =
9918
+ drawerContentRef.current.getBoundingClientRect().right - drawerContentRef.current.getBoundingClientRect().left;
9919
+ }
9920
+ else if (position === 'left') {
9921
+ splitterPos =
9922
+ splitterRef.current.getBoundingClientRect().right - drawerContentRef.current.getBoundingClientRect().left;
9923
+ drawerSize =
9924
+ drawerContentRef.current.getBoundingClientRect().right - drawerContentRef.current.getBoundingClientRect().left;
9925
+ }
9926
+ else if (position === 'bottom') {
9927
+ splitterPos =
9928
+ drawerContentRef.current.getBoundingClientRect().bottom - splitterRef.current.getBoundingClientRect().top;
9929
+ drawerSize =
9930
+ drawerContentRef.current.getBoundingClientRect().bottom - drawerContentRef.current.getBoundingClientRect().top;
9931
+ }
9932
+ const newSplitterPos = (splitterPos / drawerSize) * 100;
9933
+ return Math.round((newSplitterPos + Number.EPSILON) * 100) / 100;
9934
+ };
9883
9935
  const handleTouchStart = (e) => {
9884
9936
  e.stopPropagation();
9885
9937
  document.addEventListener('touchmove', callbackTouchMove, { passive: false });
@@ -9933,6 +9985,7 @@
9933
9985
  }
9934
9986
  panel.current.style.setProperty('--pf-c-drawer__panel--md--FlexBasis', newSize + 'px');
9935
9987
  currWidth = newSize;
9988
+ setSeparatorValue(calcValueNow());
9936
9989
  };
9937
9990
  const handleMouseup = () => {
9938
9991
  if (!isResizing) {
@@ -9961,8 +10014,7 @@
9961
10014
  const callbackMouseUp = React__namespace.useCallback(handleMouseup, []);
9962
10015
  const handleKeys = (e) => {
9963
10016
  const key = e.key;
9964
- if (key !== ' ' &&
9965
- key !== 'Escape' &&
10017
+ if (key !== 'Escape' &&
9966
10018
  key !== 'Enter' &&
9967
10019
  key !== 'ArrowUp' &&
9968
10020
  key !== 'ArrowDown' &&
@@ -9974,38 +10026,31 @@
9974
10026
  return;
9975
10027
  }
9976
10028
  e.preventDefault();
9977
- if (key === ' ' || key === 'Escape' || key === 'Enter') {
9978
- if (key === ' ') {
9979
- isResizing = true;
9980
- }
9981
- else {
9982
- isResizing = false;
9983
- onResize && onResize(currWidth, id);
9984
- }
9985
- const panelRect = panel.current.getBoundingClientRect();
9986
- newSize = position === 'bottom' ? panelRect.height : panelRect.width;
10029
+ if (key === 'Escape' || key === 'Enter') {
10030
+ onResize && onResize(currWidth, id);
9987
10031
  }
9988
- if (isResizing) {
9989
- let delta = 0;
9990
- if (key === 'ArrowRight') {
9991
- delta = position === 'left' ? increment : -increment;
9992
- }
9993
- else if (key === 'ArrowLeft') {
9994
- delta = position === 'left' ? -increment : increment;
9995
- }
9996
- else if (key === 'ArrowUp') {
9997
- delta = increment;
9998
- }
9999
- else if (key === 'ArrowDown') {
10000
- delta = -increment;
10001
- }
10002
- newSize = newSize + delta;
10003
- if (position === 'bottom') {
10004
- panel.current.style.overflowAnchor = 'none';
10005
- }
10006
- panel.current.style.setProperty('--pf-c-drawer__panel--md--FlexBasis', newSize + 'px');
10007
- currWidth = newSize;
10032
+ const panelRect = panel.current.getBoundingClientRect();
10033
+ newSize = position === 'bottom' ? panelRect.height : panelRect.width;
10034
+ let delta = 0;
10035
+ if (key === 'ArrowRight') {
10036
+ delta = position === 'left' ? increment : -increment;
10037
+ }
10038
+ else if (key === 'ArrowLeft') {
10039
+ delta = position === 'left' ? -increment : increment;
10008
10040
  }
10041
+ else if (key === 'ArrowUp') {
10042
+ delta = increment;
10043
+ }
10044
+ else if (key === 'ArrowDown') {
10045
+ delta = -increment;
10046
+ }
10047
+ newSize = newSize + delta;
10048
+ if (position === 'bottom') {
10049
+ panel.current.style.overflowAnchor = 'none';
10050
+ }
10051
+ panel.current.style.setProperty('--pf-c-drawer__panel--md--FlexBasis', newSize + 'px');
10052
+ currWidth = newSize;
10053
+ setSeparatorValue(calcValueNow());
10009
10054
  };
10010
10055
  const boundaryCssVars = {};
10011
10056
  if (defaultSize) {
@@ -10017,7 +10062,7 @@
10017
10062
  if (maxSize) {
10018
10063
  boundaryCssVars['--pf-c-drawer__panel--md--FlexBasis--max'] = maxSize;
10019
10064
  }
10020
- return (React__namespace.createElement("div", Object.assign({ id: id, className: css(_default$P.drawerPanel, isResizable && _default$P.modifiers.resizable, hasNoBorder && _default$P.modifiers.noBorder, formatBreakpointMods(widths, _default$P), colorVariant === exports.DrawerColorVariant.light200 && _default$P.modifiers.light_200, className), ref: panel, onTransitionEnd: ev => {
10065
+ return (React__namespace.createElement(GenerateId, { prefix: "pf-drawer-panel-" }, panelId => (React__namespace.createElement("div", Object.assign({ id: id || panelId, className: css(_default$P.drawerPanel, isResizable && _default$P.modifiers.resizable, hasNoBorder && _default$P.modifiers.noBorder, formatBreakpointMods(widths, _default$P), colorVariant === exports.DrawerColorVariant.light200 && _default$P.modifiers.light_200, className), ref: panel, onTransitionEnd: ev => {
10021
10066
  if (!hidden && ev.nativeEvent.propertyName === 'transform') {
10022
10067
  onExpand();
10023
10068
  }
@@ -10026,10 +10071,10 @@
10026
10071
  style: boundaryCssVars
10027
10072
  }), props), isExpandedInternal && (React__namespace.createElement(React__namespace.Fragment, null,
10028
10073
  isResizable && (React__namespace.createElement(React__namespace.Fragment, null,
10029
- React__namespace.createElement("div", { className: css(_default$P.drawerSplitter, position !== 'bottom' && _default$P.modifiers.vertical), role: "separator", tabIndex: 0, "aria-orientation": position === 'bottom' ? 'horizontal' : 'vertical', "aria-label": resizeAriaLabel, "aria-describedby": resizeAriaDescribedBy, onMouseDown: handleMousedown, onKeyDown: handleKeys, onTouchStart: handleTouchStart },
10074
+ React__namespace.createElement("div", { className: css(_default$P.drawerSplitter, position !== 'bottom' && _default$P.modifiers.vertical), role: "separator", tabIndex: 0, "aria-orientation": position === 'bottom' ? 'horizontal' : 'vertical', "aria-label": resizeAriaLabel, "aria-valuenow": separatorValue, "aria-valuemin": 0, "aria-valuemax": 100, "aria-controls": id || panelId, onMouseDown: handleMousedown, onKeyDown: handleKeys, onTouchStart: handleTouchStart, ref: splitterRef },
10030
10075
  React__namespace.createElement("div", { className: css(_default$P.drawerSplitterHandle), "aria-hidden": true })),
10031
10076
  React__namespace.createElement("div", { className: css(_default$P.drawerPanelMain) }, children))),
10032
- !isResizable && children))));
10077
+ !isResizable && children))))));
10033
10078
  };
10034
10079
  DrawerPanelContent.displayName = 'DrawerPanelContent';
10035
10080