@patternfly/react-core 4.232.11 → 4.232.12

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.232.11",
3
+ "version": "4.232.12",
4
4
  "description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
5
5
  "main": "dist/js/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -50,9 +50,9 @@
50
50
  "generate": "node scripts/copyStyles.js"
51
51
  },
52
52
  "dependencies": {
53
- "@patternfly/react-icons": "^4.83.11",
54
- "@patternfly/react-styles": "^4.82.11",
55
- "@patternfly/react-tokens": "^4.84.11",
53
+ "@patternfly/react-icons": "^4.83.12",
54
+ "@patternfly/react-styles": "^4.82.12",
55
+ "@patternfly/react-tokens": "^4.84.12",
56
56
  "focus-trap": "6.9.2",
57
57
  "react-dropzone": "9.0.0",
58
58
  "tippy.js": "5.1.2",
@@ -76,5 +76,5 @@
76
76
  "react": "^16.8.0 || ^17.0.0",
77
77
  "react-dom": "^16.8.0 || ^17.0.0"
78
78
  },
79
- "gitHead": "3b4fe0a85d88aa9616d7a6768d187d6fc87abb32"
79
+ "gitHead": "f78c7a0fe58401bb6a9e3b380067a98af76cf523"
80
80
  }
@@ -104,7 +104,7 @@ export const Label: React.FunctionComponent<LabelProps> = ({
104
104
  render,
105
105
  ...props
106
106
  }: LabelProps) => {
107
- const [isEditableActive, setIsEditableActive] = useState(false);
107
+ const [isEditableActive, setIsEditableActive] = useState<boolean>(false);
108
108
  const [currValue, setCurrValue] = useState(children);
109
109
  const editableButtonRef = React.useRef<HTMLButtonElement>();
110
110
  const editableInputRef = React.useRef<HTMLInputElement>();
@@ -151,6 +151,7 @@ export const Label: React.FunctionComponent<LabelProps> = ({
151
151
  onEditComplete && onEditComplete(editableInputRef.current.value);
152
152
  }
153
153
  setIsEditableActive(false);
154
+ editableButtonRef?.current?.focus();
154
155
  }
155
156
  if (isEditableActive && key === 'Escape') {
156
157
  event.preventDefault();
@@ -161,6 +162,7 @@ export const Label: React.FunctionComponent<LabelProps> = ({
161
162
  onEditCancel && onEditCancel(children as string);
162
163
  }
163
164
  setIsEditableActive(false);
165
+ editableButtonRef?.current?.focus();
164
166
  }
165
167
  if (!isEditableActive && key === 'Enter') {
166
168
  event.preventDefault();
@@ -52,13 +52,13 @@ export interface LabelGroupProps extends React.HTMLProps<HTMLUListElement> {
52
52
  | 'right-end';
53
53
  /** Flag to implement a vertical layout */
54
54
  isVertical?: boolean;
55
- /** @beta Flag indicating contained labels are editable. Allows spacing for a text input after the labels. */
55
+ /** Flag indicating contained labels are editable. Allows spacing for a text input after the labels. */
56
56
  isEditable?: boolean;
57
- /** @beta Flag indicating the editable label group should be appended with a textarea. */
57
+ /** Flag indicating the editable label group should be appended with a textarea. */
58
58
  hasEditableTextArea?: boolean;
59
- /** @beta Additional props passed to the editable textarea. */
59
+ /** Additional props passed to the editable textarea. */
60
60
  editableTextAreaProps?: any;
61
- /** @beta Control for adding new labels */
61
+ /** Control for adding new labels */
62
62
  addLabelControl?: React.ReactNode;
63
63
  }
64
64
 
@@ -38,7 +38,7 @@ import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-i
38
38
 
39
39
  ### Editable labels
40
40
 
41
- ```ts file="LabelGroupEditableLabels.tsx" isBeta
41
+ ```ts file="LabelGroupEditableLabels.tsx"
42
42
  ```
43
43
 
44
44
  ### Editable labels with add button
@@ -58,7 +58,7 @@ export const LabelGroupEditableAdd: React.FunctionComponent = () => {
58
58
  >
59
59
  {labels.map((label, index) => (
60
60
  <Label
61
- key={`${label.name}-${index}`}
61
+ key={label.id}
62
62
  id={`${label.name}-${index}`}
63
63
  color="blue"
64
64
  onClose={() => onClose(label.id)}
@@ -121,7 +121,7 @@ export const LabelGroupEditableAddDropdown: React.FunctionComponent = () => {
121
121
  >
122
122
  {labels.map((label, index) => (
123
123
  <Label
124
- key={`${label.name}-${index}`}
124
+ key={label.id}
125
125
  id={`${label.name}-${index}`}
126
126
  color="blue"
127
127
  onClose={() => onClose(label.id)}
@@ -27,17 +27,17 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => {
27
27
  const [labelType, setLabelType] = React.useState<string>('filled');
28
28
  const [isClosable, setIsCloseable] = React.useState<boolean>(false);
29
29
  const [isEditable, setIsEditable] = React.useState<boolean>(false);
30
- const labelInputRef = React.useRef();
30
+ const labelInputRef = React.useRef(null);
31
31
 
32
32
  const [isColorOpen, setIsColorOpen] = React.useState<boolean>(false);
33
- const colorMenuRef = React.useRef<HTMLDivElement>();
34
- const colorContainerRef = React.useRef<HTMLDivElement>();
35
- const colorToggleRef = React.useRef<HTMLButtonElement>();
33
+ const colorMenuRef = React.useRef<HTMLDivElement>(null);
34
+ const colorContainerRef = React.useRef<HTMLDivElement>(null);
35
+ const colorToggleRef = React.useRef<HTMLButtonElement>(null);
36
36
 
37
37
  const [isIconOpen, setIsIconOpen] = React.useState<boolean>(false);
38
- const iconMenuRef = React.useRef<HTMLDivElement>();
39
- const iconContainerRef = React.useRef<HTMLDivElement>();
40
- const iconToggleRef = React.useRef<HTMLButtonElement>();
38
+ const iconMenuRef = React.useRef<HTMLDivElement>(null);
39
+ const iconContainerRef = React.useRef<HTMLDivElement>(null);
40
+ const iconToggleRef = React.useRef<HTMLButtonElement>(null);
41
41
 
42
42
  const [labels, setLabels] = React.useState<any>([
43
43
  { name: 'Label 1', id: 0 },
@@ -65,7 +65,7 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => {
65
65
  };
66
66
 
67
67
  const onAdd = () => {
68
- let labelIcon = null;
68
+ let labelIcon: any;
69
69
  if (icon === 'Info circle icon') {
70
70
  labelIcon = <InfoCircleIcon />;
71
71
  }
@@ -92,7 +92,7 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => {
92
92
  setModalOpen(!isModalOpen);
93
93
  setIdIndex(idIndex + 1);
94
94
  setLabelText('');
95
- setColor(null);
95
+ setColor('');
96
96
  setIcon(null);
97
97
  setLabelType('filled');
98
98
  setIsCloseable(false);
@@ -110,25 +110,25 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => {
110
110
  }, [isModalOpen]);
111
111
 
112
112
  const handleMenuKeys = (event: KeyboardEvent) => {
113
- if (isColorOpen && colorMenuRef.current.contains(event.target as Node)) {
113
+ if (isColorOpen && colorMenuRef?.current?.contains(event.target as Node)) {
114
114
  if (event.key === 'Escape' || event.key === 'Tab') {
115
115
  setIsColorOpen(!isColorOpen);
116
- colorToggleRef.current.focus();
116
+ colorToggleRef?.current?.focus();
117
117
  }
118
118
  }
119
- if (isIconOpen && iconMenuRef.current.contains(event.target as Node)) {
119
+ if (isIconOpen && iconMenuRef?.current?.contains(event.target as Node)) {
120
120
  if (event.key === 'Escape' || event.key === 'Tab') {
121
121
  setIsIconOpen(!isIconOpen);
122
- iconToggleRef.current.focus();
122
+ iconToggleRef?.current?.focus();
123
123
  }
124
124
  }
125
125
  };
126
126
 
127
127
  const handleClickOutside = (event: MouseEvent) => {
128
- if (isColorOpen && !colorMenuRef.current.contains(event.target as Node)) {
128
+ if (isColorOpen && !colorMenuRef?.current?.contains(event.target as Node)) {
129
129
  setIsColorOpen(false);
130
130
  }
131
- if (isIconOpen && !iconMenuRef.current.contains(event.target as Node)) {
131
+ if (isIconOpen && !iconMenuRef?.current?.contains(event.target as Node)) {
132
132
  setIsIconOpen(false);
133
133
  }
134
134
  };
@@ -164,7 +164,8 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => {
164
164
  ref={colorMenuRef}
165
165
  activeItemId={color}
166
166
  onSelect={(_ev, itemId) => {
167
- setColor(itemId.toString());
167
+ setColor(itemId?.toString());
168
+ colorToggleRef?.current?.focus();
168
169
  setIsColorOpen(false);
169
170
  }}
170
171
  selected={color}
@@ -205,7 +206,8 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => {
205
206
  ref={iconMenuRef}
206
207
  activeItemId={icon}
207
208
  onSelect={(_ev, itemId) => {
208
- setIcon(itemId.toString());
209
+ setIcon(itemId?.toString());
210
+ iconToggleRef?.current?.focus();
209
211
  setIsIconOpen(false);
210
212
  }}
211
213
  selected={icon}
@@ -234,9 +236,9 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => {
234
236
  </Label>
235
237
  }
236
238
  >
237
- {labels.map((label, index) => (
239
+ {labels.map((label: { name: string; id: string; props: any }, index: number) => (
238
240
  <Label
239
- key={`${label.name}-${index}`}
241
+ key={label.id}
240
242
  id={`${label.name}-${index}`}
241
243
  color="blue"
242
244
  onClose={() => onClose(label.id)}
@@ -278,7 +280,7 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => {
278
280
  <Popper
279
281
  trigger={colorToggle}
280
282
  popper={colorMenu}
281
- appendTo={colorContainerRef.current}
283
+ appendTo={colorContainerRef.current as HTMLElement}
282
284
  isVisible={isColorOpen}
283
285
  popperMatchesTriggerWidth={false}
284
286
  />
@@ -289,7 +291,7 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => {
289
291
  <Popper
290
292
  trigger={iconToggle}
291
293
  popper={iconMenu}
292
- appendTo={iconContainerRef.current}
294
+ appendTo={iconContainerRef.current as HTMLElement}
293
295
  isVisible={isIconOpen}
294
296
  popperMatchesTriggerWidth={false}
295
297
  />