@patternfly/react-core 4.191.3 → 4.192.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 (87) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/esm/components/DataList/DataListCheck.d.ts +1 -1
  3. package/dist/esm/components/DataList/DataListCheck.d.ts.map +1 -1
  4. package/dist/esm/components/Modal/ModalBoxCloseButton.d.ts +2 -1
  5. package/dist/esm/components/Modal/ModalBoxCloseButton.d.ts.map +1 -1
  6. package/dist/esm/components/Modal/ModalBoxCloseButton.js +2 -2
  7. package/dist/esm/components/Modal/ModalBoxCloseButton.js.map +1 -1
  8. package/dist/esm/components/Modal/ModalContent.js +1 -1
  9. package/dist/esm/components/Modal/ModalContent.js.map +1 -1
  10. package/dist/esm/components/TextInputGroup/TextInputGroupMain.d.ts +4 -0
  11. package/dist/esm/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -1
  12. package/dist/esm/components/TextInputGroup/TextInputGroupMain.js +2 -2
  13. package/dist/esm/components/TextInputGroup/TextInputGroupMain.js.map +1 -1
  14. package/dist/esm/components/Truncate/Truncate.d.ts +21 -0
  15. package/dist/esm/components/Truncate/Truncate.d.ts.map +1 -0
  16. package/dist/esm/components/Truncate/Truncate.js +34 -0
  17. package/dist/esm/components/Truncate/Truncate.js.map +1 -0
  18. package/dist/esm/components/Truncate/index.d.ts +2 -0
  19. package/dist/esm/components/Truncate/index.d.ts.map +1 -0
  20. package/dist/esm/components/Truncate/index.js +2 -0
  21. package/dist/esm/components/Truncate/index.js.map +1 -0
  22. package/dist/esm/components/index.d.ts +1 -0
  23. package/dist/esm/components/index.d.ts.map +1 -1
  24. package/dist/esm/components/index.js +1 -0
  25. package/dist/esm/components/index.js.map +1 -1
  26. package/dist/js/components/DataList/DataListCheck.d.ts +1 -1
  27. package/dist/js/components/DataList/DataListCheck.d.ts.map +1 -1
  28. package/dist/js/components/Modal/ModalBoxCloseButton.d.ts +2 -1
  29. package/dist/js/components/Modal/ModalBoxCloseButton.d.ts.map +1 -1
  30. package/dist/js/components/Modal/ModalBoxCloseButton.js +2 -2
  31. package/dist/js/components/Modal/ModalBoxCloseButton.js.map +1 -1
  32. package/dist/js/components/Modal/ModalContent.js +1 -1
  33. package/dist/js/components/Modal/ModalContent.js.map +1 -1
  34. package/dist/js/components/TextInputGroup/TextInputGroupMain.d.ts +4 -0
  35. package/dist/js/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -1
  36. package/dist/js/components/TextInputGroup/TextInputGroupMain.js +2 -2
  37. package/dist/js/components/TextInputGroup/TextInputGroupMain.js.map +1 -1
  38. package/dist/js/components/Truncate/Truncate.d.ts +21 -0
  39. package/dist/js/components/Truncate/Truncate.d.ts.map +1 -0
  40. package/dist/js/components/Truncate/Truncate.js +38 -0
  41. package/dist/js/components/Truncate/Truncate.js.map +1 -0
  42. package/dist/js/components/Truncate/index.d.ts +2 -0
  43. package/dist/js/components/Truncate/index.d.ts.map +1 -0
  44. package/dist/js/components/Truncate/index.js +5 -0
  45. package/dist/js/components/Truncate/index.js.map +1 -0
  46. package/dist/js/components/index.d.ts +1 -0
  47. package/dist/js/components/index.d.ts.map +1 -1
  48. package/dist/js/components/index.js +1 -0
  49. package/dist/js/components/index.js.map +1 -1
  50. package/dist/umd/react-core.css +119 -66
  51. package/dist/umd/react-core.js +943 -903
  52. package/dist/umd/react-core.min.css +59 -6
  53. package/dist/umd/react-core.min.js +1 -1
  54. package/package.json +6 -6
  55. package/src/components/BackToTop/examples/BackToTop.md +1 -1
  56. package/src/components/Button/examples/Button.md +13 -298
  57. package/src/components/Button/examples/ButtonAriaDisabled.tsx +43 -0
  58. package/src/components/Button/examples/ButtonAriaDisabledLinkTooltip.tsx +10 -0
  59. package/src/components/Button/examples/ButtonAriaDisabledTooltip.tsx +10 -0
  60. package/src/components/Button/examples/ButtonBlock.tsx +4 -0
  61. package/src/components/Button/examples/ButtonCallToAction.tsx +20 -0
  62. package/src/components/Button/examples/ButtonDisabled.tsx +43 -0
  63. package/src/components/Button/examples/ButtonInlineSpanLink.tsx +36 -0
  64. package/src/components/Button/examples/ButtonLinks.tsx +19 -0
  65. package/src/components/Button/examples/ButtonProgress.tsx +29 -0
  66. package/src/components/Button/examples/ButtonRouterLink.tsx +9 -0
  67. package/src/components/Button/examples/ButtonSmall.tsx +22 -0
  68. package/src/components/Button/examples/ButtonTypes.tsx +10 -0
  69. package/src/components/Button/examples/ButtonVariations.tsx +47 -0
  70. package/src/components/DataList/DataListCheck.tsx +1 -1
  71. package/src/components/Modal/ModalBoxCloseButton.tsx +11 -2
  72. package/src/components/Modal/ModalContent.tsx +1 -1
  73. package/src/components/Modal/examples/Modal.md +3 -200
  74. package/src/components/Modal/examples/ModalWithForm.tsx +209 -0
  75. package/src/components/TextInputGroup/TextInputGroupMain.tsx +7 -1
  76. package/src/components/TextInputGroup/__tests__/__snapshots__/TextInputGroup.test.tsx.snap +6 -0
  77. package/src/components/TextInputGroup/examples/TextInputGroupFilters.tsx +12 -7
  78. package/src/components/TextInputGroup/examples/TextInputGroupUtilitiesAndIcon.tsx +12 -7
  79. package/src/components/Truncate/Truncate.tsx +63 -0
  80. package/src/components/Truncate/__tests__/Truncate.test.tsx +18 -0
  81. package/src/components/Truncate/__tests__/__snapshots__/Truncate.test.tsx.snap +58 -0
  82. package/src/components/Truncate/examples/Truncate.md +59 -0
  83. package/src/components/Truncate/examples/TruncateExamples.css +9 -0
  84. package/src/components/Truncate/index.ts +1 -0
  85. package/src/components/index.ts +1 -0
  86. package/src/demos/examples/TextInputGroup/AttributeValueFiltering.tsx +13 -8
  87. package/src/demos/examples/TextInputGroup/AutoCompleteSearch.tsx +29 -15
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+ import { Button, Flex } from '@patternfly/react-core';
3
+ import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
4
+ import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
5
+ import ExternalLinkSquareAltIcon from '@patternfly/react-icons/dist/esm/icons/external-link-square-alt-icon';
6
+ import CopyIcon from '@patternfly/react-icons/dist/esm/icons/copy-icon';
7
+
8
+ export const ButtonVariations: React.FunctionComponent = () => (
9
+ <Flex direction={{ default: 'column' }} alignItems={{ default: 'alignItemsFlexStart' }}>
10
+ <Flex>
11
+ <Button variant="primary">Primary</Button>
12
+ <Button variant="secondary">Secondary</Button>
13
+ <Button variant="secondary" isDanger>
14
+ Danger Secondary
15
+ </Button>
16
+ <Button variant="tertiary">Tertiary</Button>
17
+ <Button variant="danger">Danger</Button>
18
+ <Button variant="warning">Warning</Button>
19
+ </Flex>
20
+
21
+ <Flex>
22
+ <Button variant="link" icon={<PlusCircleIcon />}>
23
+ Link
24
+ </Button>
25
+ <Button variant="link" icon={<ExternalLinkSquareAltIcon />} iconPosition="right">
26
+ Link
27
+ </Button>
28
+ <Button variant="link" isInline>
29
+ Inline link
30
+ </Button>
31
+ <Button variant="link" isDanger>
32
+ Danger link
33
+ </Button>
34
+ </Flex>
35
+
36
+ <Button variant="plain" aria-label="Action">
37
+ <TimesIcon />
38
+ </Button>
39
+
40
+ <Flex>
41
+ <Button variant="control">Control</Button>
42
+ <Button variant="control" aria-label="Copy">
43
+ <CopyIcon />
44
+ </Button>
45
+ </Flex>
46
+ </Flex>
47
+ );
@@ -11,7 +11,7 @@ export interface DataListCheckProps extends Omit<React.HTMLProps<HTMLInputElemen
11
11
  isDisabled?: boolean;
12
12
  /** Flag to show if the DataList checkbox is checked */
13
13
  isChecked?: boolean;
14
- /** Alternate Flag to show if the DataList checkbox is checked */
14
+ /** Flag to set default value of DataList checkbox when it is uncontrolled by React state */
15
15
  checked?: boolean;
16
16
  /** A callback for when the DataList checkbox selection changes */
17
17
  onChange?: (checked: boolean, event: React.FormEvent<HTMLInputElement>) => void;
@@ -1,8 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { Button } from '../Button';
3
3
  import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
4
+ import { OUIAProps } from '../../helpers';
4
5
 
5
- export interface ModalBoxCloseButtonProps {
6
+ export interface ModalBoxCloseButtonProps extends OUIAProps {
6
7
  /** Additional classes added to the close button */
7
8
  className?: string;
8
9
  /** A callback for when the close button is clicked */
@@ -12,9 +13,17 @@ export interface ModalBoxCloseButtonProps {
12
13
  export const ModalBoxCloseButton: React.FunctionComponent<ModalBoxCloseButtonProps> = ({
13
14
  className = '',
14
15
  onClose = () => undefined as any,
16
+ ouiaId,
15
17
  ...props
16
18
  }: ModalBoxCloseButtonProps) => (
17
- <Button className={className} variant="plain" onClick={onClose} aria-label="Close" {...props}>
19
+ <Button
20
+ className={className}
21
+ variant="plain"
22
+ onClick={onClose}
23
+ aria-label="Close"
24
+ {...(ouiaId && { ouiaId: `${ouiaId}-${ModalBoxCloseButton.displayName}` })}
25
+ {...props}
26
+ >
18
27
  <TimesIcon />
19
28
  </Button>
20
29
  );
@@ -162,7 +162,7 @@ export const ModalContent: React.FunctionComponent<ModalContentProps> = ({
162
162
  aria-describedby={ariaDescribedby || (hasNoBodyWrapper ? null : descriptorId)}
163
163
  {...getOUIAProps(ModalContent.displayName, ouiaId, ouiaSafe)}
164
164
  >
165
- {showClose && <ModalBoxCloseButton onClose={onClose} />}
165
+ {showClose && <ModalBoxCloseButton onClose={onClose} ouiaId={ouiaId} />}
166
166
  {modalBoxHeader}
167
167
  {modalBody}
168
168
  {modalBoxFooter}
@@ -866,203 +866,6 @@ class HelpModal extends React.Component {
866
866
 
867
867
  ### With form
868
868
 
869
- ```js
870
- import React from 'react';
871
- import { Modal, ModalVariant, Button, Form, FormGroup, HelpIcon, Popover, TextInput } from '@patternfly/react-core';
872
-
873
- FormModal = () => {
874
- const [isModalOpen, setModalOpen] = React.useState(false);
875
- const [nameValue, setNameValue] = React.useState("");
876
- const [emailValue, setEmailValue] = React.useState("");
877
- const [addressValue, setAddressValue] = React.useState("");
878
-
879
- handleModalToggle = () => {
880
- setModalOpen(!isModalOpen);
881
- };
882
-
883
- handleNameInputChange = value => {
884
- setNameValue(value);
885
- };
886
-
887
- handleEmailInputChange = value => {
888
- setEmailValue(value);
889
- };
890
- handleAddressInputChange = value => {
891
- setAddressValue(value);
892
- };
893
-
894
-
895
- return (
896
- <React.Fragment>
897
- <Button variant="primary" onClick={handleModalToggle}>
898
- Show modal
899
- </Button>
900
- <Modal
901
- variant={ModalVariant.small}
902
- title="Create account"
903
- description="Enter your personal information below to create an account."
904
- isOpen={isModalOpen}
905
- onClose={handleModalToggle}
906
- actions={[
907
- <Button key="create" variant="primary" form="modal-with-form-form" onClick={this.handleModalToggle}>
908
- Confirm
909
- </Button>,
910
- <Button key="cancel" variant="link" onClick={this.handleModalToggle}>
911
- Cancel
912
- </Button>
913
- ]}
914
- >
915
- <Form id="modal-with-form-form">
916
- <FormGroup
917
- label="Name"
918
- labelIcon={
919
- <Popover
920
- headerContent={
921
- <div>
922
- The
923
- <a href="https://schema.org/name" target="_blank">
924
- name
925
- </a>
926
- of a
927
- <a href="https://schema.org/Person" target="_blank">
928
- Person
929
- </a>
930
- </div>
931
- }
932
- bodyContent={
933
- <div>
934
- Often composed of
935
- <a href="https://schema.org/givenName" target="_blank">
936
- givenName
937
- </a>
938
- and
939
- <a href="https://schema.org/familyName" target="_blank">
940
- familyName
941
- </a>
942
- .
943
- </div>
944
- }
945
- >
946
- <button
947
- type="button"
948
- aria-label="More info for name field"
949
- onClick={e => e.preventDefault()}
950
- aria-describedby="modal-with-form-form-name"
951
- className="pf-c-form__group-label-help"
952
- >
953
- <HelpIcon noVerticalAlign />
954
- </button>
955
- </Popover>
956
- }
957
- isRequired
958
- fieldId="modal-with-form-form-name">
959
- <TextInput
960
- isRequired
961
- type="email"
962
- id="modal-with-form-form-name"
963
- name="modal-with-form-form-name"
964
- value={nameValue}
965
- onChange={handleNameInputChange}
966
- />
967
- </FormGroup>
968
- <FormGroup
969
- label="E-mail"
970
- labelIcon={
971
- <Popover
972
- headerContent={
973
- <div>
974
- The
975
- <a href="https://schema.org/email" target="_blank">
976
- e-mail
977
- </a>
978
- of a
979
- <a href="https://schema.org/Person" target="_blank">
980
- person
981
- </a>
982
- </div>
983
- }
984
- bodyContent={
985
- <div>
986
- Valid
987
- <a href="https://schema.org/email" target="_blank">
988
- e-mail
989
- </a>
990
- address.
991
- </div>
992
- }
993
- >
994
- <button
995
- type="button"
996
- aria-label="More info for e-mail field"
997
- onClick={e => e.preventDefault()}
998
- aria-describedby="modal-with-form-form-email"
999
- className="pf-c-form__group-label-help"
1000
- >
1001
- <HelpIcon noVerticalAlign />
1002
- </button>
1003
- </Popover>
1004
- }
1005
- isRequired
1006
- fieldId="modal-with-form-form-email">
1007
- <TextInput
1008
- isRequired
1009
- type="email"
1010
- id="modal-with-form-form-email"
1011
- name="modal-with-form-form-email"
1012
- value={emailValue}
1013
- onChange={handleEmailInputChange}
1014
- />
1015
- </FormGroup>
1016
- <FormGroup
1017
- label="Address"
1018
- labelIcon={
1019
- <Popover
1020
- headerContent={
1021
- <div>
1022
- The
1023
- <a href="https://schema.org/address" target="_blank">
1024
- adress
1025
- </a>
1026
- of a
1027
- <a href="https://schema.org/Person" target="_blank">
1028
- person
1029
- </a>
1030
- </div>
1031
- }
1032
- bodyContent={
1033
- <div>
1034
- Valid
1035
- <a href="https://schema.org/PostalAddress" target="_blank">
1036
- postal address.
1037
- </a>
1038
- </div>
1039
- }
1040
- >
1041
- <button
1042
- type="button"
1043
- aria-label="More info for address field"
1044
- onClick={e => e.preventDefault()}
1045
- aria-describedby="modal-with-form-form-address"
1046
- className="pf-c-form__group-label-help"
1047
- >
1048
- <HelpIcon noVerticalAlign />
1049
- </button>
1050
- </Popover>
1051
- }
1052
- isRequired
1053
- fieldId="modal-with-form-form-address">
1054
- <TextInput
1055
- isRequired
1056
- type="email"
1057
- id="modal-with-form-form-address"
1058
- name="modal-with-form-form-address"
1059
- value={addressValue}
1060
- onChange={handleAddressInputChange}
1061
- />
1062
- </FormGroup>
1063
- </Form>
1064
- </Modal>
1065
- </React.Fragment>
1066
- );
1067
- };
1068
- ```
869
+ ```ts file="ModalWithForm.tsx"
870
+
871
+ ```
@@ -0,0 +1,209 @@
1
+ import React from 'react';
2
+ import { Modal, ModalVariant, Button, Form, FormGroup, Popover, TextInput } from '@patternfly/react-core';
3
+ import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
4
+
5
+ export const ModalWithForm: React.FunctionComponent = () => {
6
+ const [isModalOpen, setModalOpen] = React.useState(false);
7
+ const [nameValue, setNameValue] = React.useState('');
8
+ const [emailValue, setEmailValue] = React.useState('');
9
+ const [addressValue, setAddressValue] = React.useState('');
10
+ const nameInputRef = React.useRef();
11
+
12
+ const handleModalToggle = () => {
13
+ setModalOpen(!isModalOpen);
14
+ };
15
+
16
+ const handleNameInputChange = value => {
17
+ setNameValue(value);
18
+ };
19
+
20
+ const handleEmailInputChange = value => {
21
+ setEmailValue(value);
22
+ };
23
+ const handleAddressInputChange = value => {
24
+ setAddressValue(value);
25
+ };
26
+
27
+ React.useEffect(() => {
28
+ if (isModalOpen && nameInputRef && nameInputRef.current) {
29
+ (nameInputRef.current as HTMLInputElement).focus();
30
+ }
31
+ }, [isModalOpen]);
32
+
33
+ return (
34
+ <React.Fragment>
35
+ <Button variant="primary" onClick={handleModalToggle}>
36
+ Show modal
37
+ </Button>
38
+ <Modal
39
+ variant={ModalVariant.small}
40
+ title="Create account"
41
+ description="Enter your personal information below to create an account."
42
+ isOpen={isModalOpen}
43
+ onClose={handleModalToggle}
44
+ actions={[
45
+ <Button key="create" variant="primary" form="modal-with-form-form" onClick={handleModalToggle}>
46
+ Confirm
47
+ </Button>,
48
+ <Button key="cancel" variant="link" onClick={handleModalToggle}>
49
+ Cancel
50
+ </Button>
51
+ ]}
52
+ >
53
+ <Form id="modal-with-form-form">
54
+ <FormGroup
55
+ label="Name"
56
+ labelIcon={
57
+ <Popover
58
+ headerContent={
59
+ <div>
60
+ The
61
+ <a href="https://schema.org/name" target="_blank" rel="noopener noreferrer">
62
+ name
63
+ </a>
64
+ of a
65
+ <a href="https://schema.org/Person" target="_blank" rel="noopener noreferrer">
66
+ Person
67
+ </a>
68
+ </div>
69
+ }
70
+ bodyContent={
71
+ <div>
72
+ Often composed of
73
+ <a href="https://schema.org/givenName" target="_blank" rel="noopener noreferrer">
74
+ givenName
75
+ </a>
76
+ and
77
+ <a href="https://schema.org/familyName" target="_blank" rel="noopener noreferrer">
78
+ familyName
79
+ </a>
80
+ .
81
+ </div>
82
+ }
83
+ >
84
+ <button
85
+ type="button"
86
+ aria-label="More info for name field"
87
+ onClick={e => e.preventDefault()}
88
+ aria-describedby="modal-with-form-form-name"
89
+ className="pf-c-form__group-label-help"
90
+ >
91
+ <HelpIcon noVerticalAlign />
92
+ </button>
93
+ </Popover>
94
+ }
95
+ isRequired
96
+ fieldId="modal-with-form-form-name"
97
+ >
98
+ <TextInput
99
+ isRequired
100
+ type="email"
101
+ id="modal-with-form-form-name"
102
+ name="modal-with-form-form-name"
103
+ value={nameValue}
104
+ onChange={handleNameInputChange}
105
+ ref={nameInputRef}
106
+ />
107
+ </FormGroup>
108
+ <FormGroup
109
+ label="E-mail"
110
+ labelIcon={
111
+ <Popover
112
+ headerContent={
113
+ <div>
114
+ The
115
+ <a href="https://schema.org/email" target="_blank" rel="noopener noreferrer">
116
+ e-mail
117
+ </a>
118
+ of a
119
+ <a href="https://schema.org/Person" target="_blank" rel="noopener noreferrer">
120
+ person
121
+ </a>
122
+ </div>
123
+ }
124
+ bodyContent={
125
+ <div>
126
+ Valid
127
+ <a href="https://schema.org/email" target="_blank" rel="noopener noreferrer">
128
+ e-mail
129
+ </a>
130
+ address.
131
+ </div>
132
+ }
133
+ >
134
+ <button
135
+ type="button"
136
+ aria-label="More info for e-mail field"
137
+ onClick={e => e.preventDefault()}
138
+ aria-describedby="modal-with-form-form-email"
139
+ className="pf-c-form__group-label-help"
140
+ >
141
+ <HelpIcon noVerticalAlign />
142
+ </button>
143
+ </Popover>
144
+ }
145
+ isRequired
146
+ fieldId="modal-with-form-form-email"
147
+ >
148
+ <TextInput
149
+ isRequired
150
+ type="email"
151
+ id="modal-with-form-form-email"
152
+ name="modal-with-form-form-email"
153
+ value={emailValue}
154
+ onChange={handleEmailInputChange}
155
+ />
156
+ </FormGroup>
157
+ <FormGroup
158
+ label="Address"
159
+ labelIcon={
160
+ <Popover
161
+ headerContent={
162
+ <div>
163
+ The
164
+ <a href="https://schema.org/address" target="_blank" rel="noopener noreferrer">
165
+ adress
166
+ </a>
167
+ of a
168
+ <a href="https://schema.org/Person" target="_blank" rel="noopener noreferrer">
169
+ person
170
+ </a>
171
+ </div>
172
+ }
173
+ bodyContent={
174
+ <div>
175
+ Valid
176
+ <a href="https://schema.org/PostalAddress" target="_blank" rel="noopener noreferrer">
177
+ postal address.
178
+ </a>
179
+ </div>
180
+ }
181
+ >
182
+ <button
183
+ type="button"
184
+ aria-label="More info for address field"
185
+ onClick={e => e.preventDefault()}
186
+ aria-describedby="modal-with-form-form-address"
187
+ className="pf-c-form__group-label-help"
188
+ >
189
+ <HelpIcon noVerticalAlign />
190
+ </button>
191
+ </Popover>
192
+ }
193
+ isRequired
194
+ fieldId="modal-with-form-form-address"
195
+ >
196
+ <TextInput
197
+ isRequired
198
+ type="email"
199
+ id="modal-with-form-form-address"
200
+ name="modal-with-form-form-address"
201
+ value={addressValue}
202
+ onChange={handleAddressInputChange}
203
+ />
204
+ </FormGroup>
205
+ </Form>
206
+ </Modal>
207
+ </React.Fragment>
208
+ );
209
+ };
@@ -31,6 +31,10 @@ export interface TextInputGroupMainProps extends Omit<React.HTMLProps<HTMLDivEle
31
31
  onBlur?: (event?: any) => void;
32
32
  /** Accessibility label for the input */
33
33
  'aria-label'?: string;
34
+ /** Value for the input */
35
+ value?: string | number;
36
+ /** Placeholder value for the input */
37
+ placeholder?: string;
34
38
  }
35
39
 
36
40
  export const TextInputGroupMain: React.FunctionComponent<TextInputGroupMainProps> = ({
@@ -43,6 +47,7 @@ export const TextInputGroupMain: React.FunctionComponent<TextInputGroupMainProps
43
47
  onBlur,
44
48
  'aria-label': ariaLabel = 'Type to filter',
45
49
  value: inputValue,
50
+ placeholder: inputPlaceHolder,
46
51
  ...props
47
52
  }: TextInputGroupMainProps) => {
48
53
  const { isDisabled } = React.useContext(TextInputGroupContext);
@@ -64,7 +69,8 @@ export const TextInputGroupMain: React.FunctionComponent<TextInputGroupMainProps
64
69
  onChange={handleChange}
65
70
  onFocus={onFocus}
66
71
  onBlur={onBlur}
67
- value={inputValue}
72
+ value={inputValue || ''}
73
+ placeholder={inputPlaceHolder}
68
74
  />
69
75
  </span>
70
76
  </div>
@@ -22,6 +22,7 @@ exports[`TextInputGroup gets custom class and id 1`] = `
22
22
  className="pf-c-text-input-group__text-input"
23
23
  onChange={[Function]}
24
24
  type="text"
25
+ value=""
25
26
  />
26
27
  </span>
27
28
  </div>
@@ -53,6 +54,7 @@ exports[`TextInputGroup renders content 1`] = `
53
54
  className="pf-c-text-input-group__text-input"
54
55
  onChange={[Function]}
55
56
  type="text"
57
+ value=""
56
58
  />
57
59
  </span>
58
60
  </div>
@@ -87,6 +89,7 @@ exports[`TextInputGroup renders with the proper stying when disabled 1`] = `
87
89
  disabled={true}
88
90
  onChange={[Function]}
89
91
  type="text"
92
+ value=""
90
93
  />
91
94
  </span>
92
95
  </div>
@@ -115,6 +118,7 @@ exports[`TextInputGroupMain renders content 1`] = `
115
118
  disabled={false}
116
119
  onChange={[Function]}
117
120
  type="text"
121
+ value=""
118
122
  />
119
123
  </span>
120
124
  </div>
@@ -172,6 +176,7 @@ exports[`TextInputGroupMain renders given input icon props 1`] = `
172
176
  disabled={false}
173
177
  onChange={[Function]}
174
178
  type="text"
179
+ value=""
175
180
  />
176
181
  </span>
177
182
  </div>
@@ -195,6 +200,7 @@ exports[`TextInputGroupMain renders the input with custom aria label when given
195
200
  disabled={false}
196
201
  onChange={[Function]}
197
202
  type="text"
203
+ value=""
198
204
  />
199
205
  </span>
200
206
  </div>
@@ -40,6 +40,9 @@ export const TextInputGroupFilters: React.FunctionComponent = () => {
40
40
  /** show the input/chip clearing button only when either the text input or chip group are not empty */
41
41
  const showClearButton = !!inputValue || !!currentChips.length;
42
42
 
43
+ /** render the utilities component only when a component it contains is being rendered */
44
+ const showUtilities = showClearButton;
45
+
43
46
  /** callback for clearing all selected chips and the text input */
44
47
  const clearChipsAndInput = () => {
45
48
  setCurrentChips([]);
@@ -57,13 +60,15 @@ export const TextInputGroupFilters: React.FunctionComponent = () => {
57
60
  ))}
58
61
  </ChipGroup>
59
62
  </TextInputGroupMain>
60
- <TextInputGroupUtilities>
61
- {showClearButton && (
62
- <Button variant="plain" onClick={clearChipsAndInput} aria-label="Clear button and input">
63
- <TimesIcon />
64
- </Button>
65
- )}
66
- </TextInputGroupUtilities>
63
+ {showUtilities && (
64
+ <TextInputGroupUtilities>
65
+ {showClearButton && (
66
+ <Button variant="plain" onClick={clearChipsAndInput} aria-label="Clear button and input">
67
+ <TimesIcon />
68
+ </Button>
69
+ )}
70
+ </TextInputGroupUtilities>
71
+ )}
67
72
  </TextInputGroup>
68
73
  );
69
74
  };
@@ -14,6 +14,9 @@ export const TextInputGroupUtilitiesAndIcon: React.FunctionComponent = () => {
14
14
  /** show the input clearing button only when the input is not empty */
15
15
  const showClearButton = !!inputValue;
16
16
 
17
+ /** render the utilities component only when a component it contains is being rendered */
18
+ const showUtilities = showClearButton;
19
+
17
20
  /** callback for clearing the text input */
18
21
  const clearInput = () => {
19
22
  setInputValue('');
@@ -22,13 +25,15 @@ export const TextInputGroupUtilitiesAndIcon: React.FunctionComponent = () => {
22
25
  return (
23
26
  <TextInputGroup>
24
27
  <TextInputGroupMain icon={<SearchIcon />} value={inputValue} onChange={handleInputChange} />
25
- <TextInputGroupUtilities>
26
- {showClearButton && (
27
- <Button variant="plain" onClick={clearInput} aria-label="Clear button and input">
28
- <TimesIcon />
29
- </Button>
30
- )}
31
- </TextInputGroupUtilities>
28
+ {showUtilities && (
29
+ <TextInputGroupUtilities>
30
+ {showClearButton && (
31
+ <Button variant="plain" onClick={clearInput} aria-label="Clear button and input">
32
+ <TimesIcon />
33
+ </Button>
34
+ )}
35
+ </TextInputGroupUtilities>
36
+ )}
32
37
  </TextInputGroup>
33
38
  );
34
39
  };