@patternfly/react-core 4.169.4 → 4.170.3
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/CHANGELOG.md +38 -0
- package/dist/esm/components/FileUpload/FileUpload.d.ts +11 -3
- package/dist/esm/components/FileUpload/FileUpload.d.ts.map +1 -1
- package/dist/esm/components/FileUpload/FileUpload.js +28 -5
- package/dist/esm/components/FileUpload/FileUpload.js.map +1 -1
- package/dist/esm/components/FileUpload/FileUploadField.d.ts +2 -0
- package/dist/esm/components/FileUpload/FileUploadField.d.ts.map +1 -1
- package/dist/esm/components/FileUpload/FileUploadField.js +2 -1
- package/dist/esm/components/FileUpload/FileUploadField.js.map +1 -1
- package/dist/esm/components/Menu/DrilldownMenu.js +1 -1
- package/dist/esm/components/Menu/DrilldownMenu.js.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroup.d.ts +3 -0
- package/dist/esm/components/TextInputGroup/TextInputGroup.d.ts.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroup.js +6 -2
- package/dist/esm/components/TextInputGroup/TextInputGroup.js.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.d.ts +8 -2
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.js +7 -3
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.js.map +1 -1
- package/dist/js/components/FileUpload/FileUpload.d.ts +11 -3
- package/dist/js/components/FileUpload/FileUpload.d.ts.map +1 -1
- package/dist/js/components/FileUpload/FileUpload.js +27 -4
- package/dist/js/components/FileUpload/FileUpload.js.map +1 -1
- package/dist/js/components/FileUpload/FileUploadField.d.ts +2 -0
- package/dist/js/components/FileUpload/FileUploadField.d.ts.map +1 -1
- package/dist/js/components/FileUpload/FileUploadField.js +2 -1
- package/dist/js/components/FileUpload/FileUploadField.js.map +1 -1
- package/dist/js/components/Menu/DrilldownMenu.js +1 -1
- package/dist/js/components/Menu/DrilldownMenu.js.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroup.d.ts +3 -0
- package/dist/js/components/TextInputGroup/TextInputGroup.d.ts.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroup.js +7 -3
- package/dist/js/components/TextInputGroup/TextInputGroup.js.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroupMain.d.ts +8 -2
- package/dist/js/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroupMain.js +7 -3
- package/dist/js/components/TextInputGroup/TextInputGroupMain.js.map +1 -1
- package/dist/umd/react-core.css +20 -9
- package/dist/umd/react-core.js +1582 -1299
- package/dist/umd/react-core.min.css +20 -9
- package/dist/umd/react-core.min.js +5 -6
- package/package.json +7 -7
- package/src/components/FileUpload/FileUpload.tsx +77 -30
- package/src/components/FileUpload/FileUploadField.tsx +5 -0
- package/src/components/FileUpload/__tests__/__snapshots__/FileUpload.test.tsx.snap +3 -7
- package/src/components/FileUpload/examples/FileUpload.md +54 -17
- package/src/components/Menu/DrilldownMenu.tsx +1 -1
- package/src/components/Modal/examples/Modal.md +203 -0
- package/src/components/TextInputGroup/TextInputGroup.tsx +12 -3
- package/src/components/TextInputGroup/TextInputGroupMain.tsx +51 -20
- package/src/components/TextInputGroup/__tests__/TextInputGroup.test.tsx +91 -3
- package/src/components/TextInputGroup/__tests__/__snapshots__/TextInputGroup.test.tsx.snap +19 -16
- package/src/components/TextInputGroup/examples/TextInputGroup.md +13 -0
|
@@ -863,3 +863,206 @@ class HelpModal extends React.Component {
|
|
|
863
863
|
}
|
|
864
864
|
}
|
|
865
865
|
```
|
|
866
|
+
|
|
867
|
+
### With form
|
|
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
|
+
```
|
|
@@ -7,16 +7,25 @@ export interface TextInputGroupProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
/** Additional classes applied to the text input group container */
|
|
9
9
|
className?: string;
|
|
10
|
+
/** Adds disabled styling and a disabled context value which text input group main hooks into for the input itself */
|
|
11
|
+
isDisabled?: boolean;
|
|
10
12
|
}
|
|
11
13
|
|
|
14
|
+
export const TextInputGroupContext = React.createContext<Partial<TextInputGroupProps>>({
|
|
15
|
+
isDisabled: false
|
|
16
|
+
});
|
|
17
|
+
|
|
12
18
|
export const TextInputGroup: React.FunctionComponent<TextInputGroupProps> = ({
|
|
13
19
|
children,
|
|
14
20
|
className,
|
|
21
|
+
isDisabled,
|
|
15
22
|
...props
|
|
16
23
|
}: TextInputGroupProps) => (
|
|
17
|
-
<
|
|
18
|
-
{
|
|
19
|
-
|
|
24
|
+
<TextInputGroupContext.Provider value={{ isDisabled }}>
|
|
25
|
+
<div className={css(styles.textInputGroup, isDisabled && styles.modifiers.disabled, className)} {...props}>
|
|
26
|
+
{children}
|
|
27
|
+
</div>
|
|
28
|
+
</TextInputGroupContext.Provider>
|
|
20
29
|
);
|
|
21
30
|
|
|
22
31
|
TextInputGroup.displayName = 'TextInputGroup';
|
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import styles from '@patternfly/react-styles/css/components/TextInputGroup/text-input-group';
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
|
+
import { TextInputGroupContext } from './TextInputGroup';
|
|
4
5
|
|
|
5
|
-
export interface TextInputGroupMainProps extends React.HTMLProps<HTMLDivElement> {
|
|
6
|
+
export interface TextInputGroupMainProps extends Omit<React.HTMLProps<HTMLDivElement>, 'onChange'> {
|
|
6
7
|
/** Content rendered inside the text input group main div */
|
|
7
8
|
children?: React.ReactNode;
|
|
8
9
|
/** Additional classes applied to the text input group main container */
|
|
9
10
|
className?: string;
|
|
10
11
|
/** Icon to be shown on the left side of the text input group main container */
|
|
11
12
|
icon?: React.ReactNode;
|
|
13
|
+
/** Type that the input accepts. */
|
|
14
|
+
type?:
|
|
15
|
+
| 'text'
|
|
16
|
+
| 'date'
|
|
17
|
+
| 'datetime-local'
|
|
18
|
+
| 'email'
|
|
19
|
+
| 'month'
|
|
20
|
+
| 'number'
|
|
21
|
+
| 'password'
|
|
22
|
+
| 'search'
|
|
23
|
+
| 'tel'
|
|
24
|
+
| 'time'
|
|
25
|
+
| 'url';
|
|
12
26
|
/** Callback for when there is a change in the input field*/
|
|
13
|
-
onChange?: () => void;
|
|
27
|
+
onChange?: (value: string, event: React.FormEvent<HTMLInputElement>) => void;
|
|
28
|
+
/** Callback for when the input field is focused*/
|
|
29
|
+
onFocus?: (event?: any) => void;
|
|
30
|
+
/** Callback for when focus is lost on the input field*/
|
|
31
|
+
onBlur?: (event?: any) => void;
|
|
14
32
|
/** Accessibility label for the input */
|
|
15
33
|
'aria-label'?: string;
|
|
16
34
|
}
|
|
@@ -19,25 +37,38 @@ export const TextInputGroupMain: React.FunctionComponent<TextInputGroupMainProps
|
|
|
19
37
|
children,
|
|
20
38
|
className,
|
|
21
39
|
icon,
|
|
22
|
-
|
|
23
|
-
|
|
40
|
+
type = 'text',
|
|
41
|
+
onChange = (): any => undefined,
|
|
42
|
+
onFocus,
|
|
43
|
+
onBlur,
|
|
44
|
+
'aria-label': ariaLabel = 'Type to filter',
|
|
24
45
|
value: inputValue,
|
|
25
46
|
...props
|
|
26
|
-
}: TextInputGroupMainProps) =>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
)
|
|
47
|
+
}: TextInputGroupMainProps) => {
|
|
48
|
+
const { isDisabled } = React.useContext(TextInputGroupContext);
|
|
49
|
+
|
|
50
|
+
const handleChange = (event: React.FormEvent<HTMLInputElement>) => {
|
|
51
|
+
onChange(event.currentTarget.value, event);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div className={css(styles.textInputGroupMain, icon && styles.modifiers.icon, className)} {...props}>
|
|
56
|
+
{children}
|
|
57
|
+
<span className={css(styles.textInputGroupText)}>
|
|
58
|
+
{icon && <span className={css(styles.textInputGroupIcon)}>{icon}</span>}
|
|
59
|
+
<input
|
|
60
|
+
type={type}
|
|
61
|
+
className={css(styles.textInputGroupTextInput)}
|
|
62
|
+
aria-label={ariaLabel}
|
|
63
|
+
disabled={isDisabled}
|
|
64
|
+
onChange={handleChange}
|
|
65
|
+
onFocus={onFocus}
|
|
66
|
+
onBlur={onBlur}
|
|
67
|
+
value={inputValue}
|
|
68
|
+
/>
|
|
69
|
+
</span>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
41
73
|
|
|
42
|
-
TextInputGroupMain.defaultProps = { 'aria-label': 'Type to filter' };
|
|
43
74
|
TextInputGroupMain.displayName = 'TextInputGroupMain';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { mount } from 'enzyme';
|
|
3
|
-
import { TextInputGroup } from '../TextInputGroup';
|
|
3
|
+
import { TextInputGroup, TextInputGroupContext } from '../TextInputGroup';
|
|
4
4
|
import { TextInputGroupMain } from '../TextInputGroupMain';
|
|
5
5
|
import { TextInputGroupUtilities } from '../TextInputGroupUtilities';
|
|
6
6
|
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
@@ -26,15 +26,45 @@ describe('TextInputGroup', () => {
|
|
|
26
26
|
expect(view).toMatchSnapshot();
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
test('renders with the proper stying
|
|
29
|
+
test('renders with the proper stying when disabled', () => {
|
|
30
30
|
const view = mount(
|
|
31
|
-
<TextInputGroup>
|
|
31
|
+
<TextInputGroup isDisabled>
|
|
32
32
|
<TextInputGroupMain>Foo</TextInputGroupMain>
|
|
33
33
|
<TextInputGroupUtilities />
|
|
34
34
|
</TextInputGroup>
|
|
35
35
|
);
|
|
36
36
|
expect(view).toMatchSnapshot();
|
|
37
37
|
});
|
|
38
|
+
|
|
39
|
+
test('passes isDisabled=false to children via a context when isDisabled prop is not passed', () => {
|
|
40
|
+
const TestComponent: React.FunctionComponent = () => {
|
|
41
|
+
const context = React.useContext(TextInputGroupContext);
|
|
42
|
+
|
|
43
|
+
return <div>{context.isDisabled ? 'is disabled' : 'not disabled'}</div>;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const view = mount(
|
|
47
|
+
<TextInputGroup>
|
|
48
|
+
<TestComponent />
|
|
49
|
+
</TextInputGroup>
|
|
50
|
+
);
|
|
51
|
+
expect(view.text()).toBe('not disabled');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('passes isDisabled=true to children via a context when isDisabled prop is passed', () => {
|
|
55
|
+
const TestComponent: React.FunctionComponent = () => {
|
|
56
|
+
const context = React.useContext(TextInputGroupContext);
|
|
57
|
+
|
|
58
|
+
return <div>{context.isDisabled ? 'is disabled' : 'not disabled'}</div>;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const view = mount(
|
|
62
|
+
<TextInputGroup isDisabled>
|
|
63
|
+
<TestComponent />
|
|
64
|
+
</TextInputGroup>
|
|
65
|
+
);
|
|
66
|
+
expect(view.text()).toBe('is disabled');
|
|
67
|
+
});
|
|
38
68
|
});
|
|
39
69
|
|
|
40
70
|
describe('TextInputGroupMain', () => {
|
|
@@ -67,6 +97,64 @@ describe('TextInputGroupMain', () => {
|
|
|
67
97
|
view.find('input').simulate('change', { target: { value: 'Foo' } });
|
|
68
98
|
expect(onChangeMock).toHaveBeenCalledTimes(1);
|
|
69
99
|
});
|
|
100
|
+
|
|
101
|
+
test('does not call onFocus callback when the input does not get focus', () => {
|
|
102
|
+
const onFocusMock = jest.fn();
|
|
103
|
+
|
|
104
|
+
const view = mount(<TextInputGroupMain onFocus={onFocusMock}>Foo</TextInputGroupMain>);
|
|
105
|
+
expect(onFocusMock).not.toHaveBeenCalled();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test('calls the onFocus callback when the input is focused', () => {
|
|
109
|
+
const onFocusMock = jest.fn();
|
|
110
|
+
|
|
111
|
+
const view = mount(<TextInputGroupMain onFocus={onFocusMock}>Foo</TextInputGroupMain>);
|
|
112
|
+
view.find('input').simulate('focus');
|
|
113
|
+
expect(onFocusMock).toHaveBeenCalledTimes(1);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('does not call onBlur callback when the input does not lose focus', () => {
|
|
117
|
+
const onBlurMock = jest.fn();
|
|
118
|
+
|
|
119
|
+
const view = mount(<TextInputGroupMain onBlur={onBlurMock}>Foo</TextInputGroupMain>);
|
|
120
|
+
expect(onBlurMock).not.toHaveBeenCalled();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('calls the onFocus callback when the input loses focus', () => {
|
|
124
|
+
const onBlurMock = jest.fn();
|
|
125
|
+
|
|
126
|
+
const view = mount(<TextInputGroupMain onBlur={onBlurMock}>Foo</TextInputGroupMain>);
|
|
127
|
+
view.find('input').simulate('blur');
|
|
128
|
+
expect(onBlurMock).toHaveBeenCalledTimes(1);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('input type defaults to text', () => {
|
|
132
|
+
const view = mount(<TextInputGroupMain>Foo</TextInputGroupMain>);
|
|
133
|
+
expect(view.find('input').props()['type']).toBe('text');
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test('input type is updated when a different type is passed', () => {
|
|
137
|
+
const view = mount(<TextInputGroupMain type="search">Foo</TextInputGroupMain>);
|
|
138
|
+
expect(view.find('input').props()['type']).toBe('search');
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test('input is not disabled when TextInputGroupContext isDisabled is false', () => {
|
|
142
|
+
const view = mount(
|
|
143
|
+
<TextInputGroupContext.Provider value={{ isDisabled: false }}>
|
|
144
|
+
<TextInputGroupMain />
|
|
145
|
+
</TextInputGroupContext.Provider>
|
|
146
|
+
);
|
|
147
|
+
expect(view.find('input').props()['disabled']).toBe(false);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test('input is disabled when TextInputGroupContext isDisabled is true', () => {
|
|
151
|
+
const view = mount(
|
|
152
|
+
<TextInputGroupContext.Provider value={{ isDisabled: true }}>
|
|
153
|
+
<TextInputGroupMain />
|
|
154
|
+
</TextInputGroupContext.Provider>
|
|
155
|
+
);
|
|
156
|
+
expect(view.find('input').props()['disabled']).toBe(true);
|
|
157
|
+
});
|
|
70
158
|
});
|
|
71
159
|
|
|
72
160
|
describe('TextInputGroupUtilities', () => {
|
|
@@ -9,9 +9,7 @@ exports[`TextInputGroup gets custom class and id 1`] = `
|
|
|
9
9
|
className="pf-c-text-input-group custom-class"
|
|
10
10
|
id="test-id"
|
|
11
11
|
>
|
|
12
|
-
<TextInputGroupMain
|
|
13
|
-
aria-label="Type to filter"
|
|
14
|
-
>
|
|
12
|
+
<TextInputGroupMain>
|
|
15
13
|
<div
|
|
16
14
|
className="pf-c-text-input-group__main"
|
|
17
15
|
>
|
|
@@ -22,6 +20,7 @@ exports[`TextInputGroup gets custom class and id 1`] = `
|
|
|
22
20
|
<input
|
|
23
21
|
aria-label="Type to filter"
|
|
24
22
|
className="pf-c-text-input-group__text-input"
|
|
23
|
+
onChange={[Function]}
|
|
25
24
|
type="text"
|
|
26
25
|
/>
|
|
27
26
|
</span>
|
|
@@ -41,9 +40,7 @@ exports[`TextInputGroup renders content 1`] = `
|
|
|
41
40
|
<div
|
|
42
41
|
className="pf-c-text-input-group"
|
|
43
42
|
>
|
|
44
|
-
<TextInputGroupMain
|
|
45
|
-
aria-label="Type to filter"
|
|
46
|
-
>
|
|
43
|
+
<TextInputGroupMain>
|
|
47
44
|
<div
|
|
48
45
|
className="pf-c-text-input-group__main"
|
|
49
46
|
>
|
|
@@ -54,6 +51,7 @@ exports[`TextInputGroup renders content 1`] = `
|
|
|
54
51
|
<input
|
|
55
52
|
aria-label="Type to filter"
|
|
56
53
|
className="pf-c-text-input-group__text-input"
|
|
54
|
+
onChange={[Function]}
|
|
57
55
|
type="text"
|
|
58
56
|
/>
|
|
59
57
|
</span>
|
|
@@ -68,14 +66,14 @@ exports[`TextInputGroup renders content 1`] = `
|
|
|
68
66
|
</TextInputGroup>
|
|
69
67
|
`;
|
|
70
68
|
|
|
71
|
-
exports[`TextInputGroup renders with the proper stying
|
|
72
|
-
<TextInputGroup
|
|
69
|
+
exports[`TextInputGroup renders with the proper stying when disabled 1`] = `
|
|
70
|
+
<TextInputGroup
|
|
71
|
+
isDisabled={true}
|
|
72
|
+
>
|
|
73
73
|
<div
|
|
74
|
-
className="pf-c-text-input-group"
|
|
74
|
+
className="pf-c-text-input-group pf-m-disabled"
|
|
75
75
|
>
|
|
76
|
-
<TextInputGroupMain
|
|
77
|
-
aria-label="Type to filter"
|
|
78
|
-
>
|
|
76
|
+
<TextInputGroupMain>
|
|
79
77
|
<div
|
|
80
78
|
className="pf-c-text-input-group__main"
|
|
81
79
|
>
|
|
@@ -86,6 +84,8 @@ exports[`TextInputGroup renders with the proper stying for an icon on the left s
|
|
|
86
84
|
<input
|
|
87
85
|
aria-label="Type to filter"
|
|
88
86
|
className="pf-c-text-input-group__text-input"
|
|
87
|
+
disabled={true}
|
|
88
|
+
onChange={[Function]}
|
|
89
89
|
type="text"
|
|
90
90
|
/>
|
|
91
91
|
</span>
|
|
@@ -101,9 +101,7 @@ exports[`TextInputGroup renders with the proper stying for an icon on the left s
|
|
|
101
101
|
`;
|
|
102
102
|
|
|
103
103
|
exports[`TextInputGroupMain renders content 1`] = `
|
|
104
|
-
<TextInputGroupMain
|
|
105
|
-
aria-label="Type to filter"
|
|
106
|
-
>
|
|
104
|
+
<TextInputGroupMain>
|
|
107
105
|
<div
|
|
108
106
|
className="pf-c-text-input-group__main"
|
|
109
107
|
>
|
|
@@ -114,6 +112,8 @@ exports[`TextInputGroupMain renders content 1`] = `
|
|
|
114
112
|
<input
|
|
115
113
|
aria-label="Type to filter"
|
|
116
114
|
className="pf-c-text-input-group__text-input"
|
|
115
|
+
disabled={false}
|
|
116
|
+
onChange={[Function]}
|
|
117
117
|
type="text"
|
|
118
118
|
/>
|
|
119
119
|
</span>
|
|
@@ -123,7 +123,6 @@ exports[`TextInputGroupMain renders content 1`] = `
|
|
|
123
123
|
|
|
124
124
|
exports[`TextInputGroupMain renders given input icon props 1`] = `
|
|
125
125
|
<TextInputGroupMain
|
|
126
|
-
aria-label="Type to filter"
|
|
127
126
|
icon={
|
|
128
127
|
<SearchIcon
|
|
129
128
|
color="currentColor"
|
|
@@ -170,6 +169,8 @@ exports[`TextInputGroupMain renders given input icon props 1`] = `
|
|
|
170
169
|
<input
|
|
171
170
|
aria-label="Type to filter"
|
|
172
171
|
className="pf-c-text-input-group__text-input"
|
|
172
|
+
disabled={false}
|
|
173
|
+
onChange={[Function]}
|
|
173
174
|
type="text"
|
|
174
175
|
/>
|
|
175
176
|
</span>
|
|
@@ -191,6 +192,8 @@ exports[`TextInputGroupMain renders the input with custom aria label when given
|
|
|
191
192
|
<input
|
|
192
193
|
aria-label="Foo"
|
|
193
194
|
className="pf-c-text-input-group__text-input"
|
|
195
|
+
disabled={false}
|
|
196
|
+
onChange={[Function]}
|
|
194
197
|
type="text"
|
|
195
198
|
/>
|
|
196
199
|
</span>
|
|
@@ -24,6 +24,19 @@ const BasicTextInputGroup = () => (
|
|
|
24
24
|
);
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
### Disabled
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
import React from 'react';
|
|
31
|
+
import { TextInputGroup, TextInputGroupMain } from '@patternfly/react-core';
|
|
32
|
+
|
|
33
|
+
const DisabledTextInputGroup = () => (
|
|
34
|
+
<TextInputGroup isDisabled>
|
|
35
|
+
<TextInputGroupMain value="Disabled" type="text" aria-label="Disabled text input group example input" />
|
|
36
|
+
</TextInputGroup>
|
|
37
|
+
);
|
|
38
|
+
```
|
|
39
|
+
|
|
27
40
|
### Utilities and icon
|
|
28
41
|
|
|
29
42
|
```js
|