@patternfly/react-core 4.165.1 → 4.168.6
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 +145 -0
- package/README.md +1 -1
- package/dist/esm/components/Dropdown/DropdownToggle.d.ts +1 -1
- package/dist/esm/components/Dropdown/DropdownToggle.d.ts.map +1 -1
- package/dist/esm/components/Dropdown/KebabToggle.d.ts +1 -1
- package/dist/esm/components/Dropdown/KebabToggle.d.ts.map +1 -1
- package/dist/esm/components/DualListSelector/DualListSelector.d.ts +1 -0
- package/dist/esm/components/DualListSelector/DualListSelector.d.ts.map +1 -1
- package/dist/esm/components/DualListSelector/DualListSelector.js +23 -10
- package/dist/esm/components/DualListSelector/DualListSelector.js.map +1 -1
- package/dist/esm/components/Label/Label.d.ts +4 -4
- package/dist/esm/components/Label/Label.d.ts.map +1 -1
- package/dist/esm/components/LabelGroup/LabelGroup.d.ts +3 -3
- package/dist/esm/components/LabelGroup/LabelGroup.d.ts.map +1 -1
- package/dist/esm/components/Menu/Menu.d.ts +11 -11
- package/dist/esm/components/Menu/Menu.d.ts.map +1 -1
- package/dist/esm/components/Menu/MenuItem.d.ts +5 -5
- package/dist/esm/components/Menu/MenuItem.d.ts.map +1 -1
- package/dist/esm/components/Select/Select.d.ts +1 -1
- package/dist/esm/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/components/Select/SelectOption.d.ts +1 -1
- package/dist/esm/components/Select/SelectOption.d.ts.map +1 -1
- package/dist/esm/components/Tabs/TabContentBody.d.ts +11 -0
- package/dist/esm/components/Tabs/TabContentBody.d.ts.map +1 -0
- package/dist/esm/components/Tabs/TabContentBody.js +10 -0
- package/dist/esm/components/Tabs/TabContentBody.js.map +1 -0
- package/dist/esm/components/Tabs/index.d.ts +1 -0
- package/dist/esm/components/Tabs/index.d.ts.map +1 -1
- package/dist/esm/components/Tabs/index.js +1 -0
- package/dist/esm/components/Tabs/index.js.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroup.d.ts +9 -0
- package/dist/esm/components/TextInputGroup/TextInputGroup.d.ts.map +1 -0
- package/dist/esm/components/TextInputGroup/TextInputGroup.js +10 -0
- package/dist/esm/components/TextInputGroup/TextInputGroup.js.map +1 -0
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.d.ts +15 -0
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -0
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.js +15 -0
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.js.map +1 -0
- package/dist/esm/components/TextInputGroup/TextInputGroupUtilities.d.ts +9 -0
- package/dist/esm/components/TextInputGroup/TextInputGroupUtilities.d.ts.map +1 -0
- package/dist/esm/components/TextInputGroup/TextInputGroupUtilities.js +10 -0
- package/dist/esm/components/TextInputGroup/TextInputGroupUtilities.js.map +1 -0
- package/dist/esm/components/TextInputGroup/index.d.ts +4 -0
- package/dist/esm/components/TextInputGroup/index.d.ts.map +1 -0
- package/dist/esm/components/TextInputGroup/index.js +4 -0
- package/dist/esm/components/TextInputGroup/index.js.map +1 -0
- package/dist/esm/components/Toolbar/Toolbar.d.ts +2 -0
- package/dist/esm/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/Toolbar.js +2 -2
- package/dist/esm/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/js/components/Dropdown/DropdownToggle.d.ts +1 -1
- package/dist/js/components/Dropdown/DropdownToggle.d.ts.map +1 -1
- package/dist/js/components/Dropdown/KebabToggle.d.ts +1 -1
- package/dist/js/components/Dropdown/KebabToggle.d.ts.map +1 -1
- package/dist/js/components/DualListSelector/DualListSelector.d.ts +1 -0
- package/dist/js/components/DualListSelector/DualListSelector.d.ts.map +1 -1
- package/dist/js/components/DualListSelector/DualListSelector.js +23 -10
- package/dist/js/components/DualListSelector/DualListSelector.js.map +1 -1
- package/dist/js/components/Label/Label.d.ts +4 -4
- package/dist/js/components/Label/Label.d.ts.map +1 -1
- package/dist/js/components/LabelGroup/LabelGroup.d.ts +3 -3
- package/dist/js/components/LabelGroup/LabelGroup.d.ts.map +1 -1
- package/dist/js/components/Menu/Menu.d.ts +11 -11
- package/dist/js/components/Menu/Menu.d.ts.map +1 -1
- package/dist/js/components/Menu/MenuItem.d.ts +5 -5
- package/dist/js/components/Menu/MenuItem.d.ts.map +1 -1
- package/dist/js/components/Select/Select.d.ts +1 -1
- package/dist/js/components/Select/Select.d.ts.map +1 -1
- package/dist/js/components/Select/SelectOption.d.ts +1 -1
- package/dist/js/components/Select/SelectOption.d.ts.map +1 -1
- package/dist/js/components/Tabs/TabContentBody.d.ts +11 -0
- package/dist/js/components/Tabs/TabContentBody.d.ts.map +1 -0
- package/dist/js/components/Tabs/TabContentBody.js +14 -0
- package/dist/js/components/Tabs/TabContentBody.js.map +1 -0
- package/dist/js/components/Tabs/index.d.ts +1 -0
- package/dist/js/components/Tabs/index.d.ts.map +1 -1
- package/dist/js/components/Tabs/index.js +1 -0
- package/dist/js/components/Tabs/index.js.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroup.d.ts +9 -0
- package/dist/js/components/TextInputGroup/TextInputGroup.d.ts.map +1 -0
- package/dist/js/components/TextInputGroup/TextInputGroup.js +14 -0
- package/dist/js/components/TextInputGroup/TextInputGroup.js.map +1 -0
- package/dist/js/components/TextInputGroup/TextInputGroupMain.d.ts +15 -0
- package/dist/js/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -0
- package/dist/js/components/TextInputGroup/TextInputGroupMain.js +19 -0
- package/dist/js/components/TextInputGroup/TextInputGroupMain.js.map +1 -0
- package/dist/js/components/TextInputGroup/TextInputGroupUtilities.d.ts +9 -0
- package/dist/js/components/TextInputGroup/TextInputGroupUtilities.d.ts.map +1 -0
- package/dist/js/components/TextInputGroup/TextInputGroupUtilities.js +14 -0
- package/dist/js/components/TextInputGroup/TextInputGroupUtilities.js.map +1 -0
- package/dist/js/components/TextInputGroup/index.d.ts +4 -0
- package/dist/js/components/TextInputGroup/index.d.ts.map +1 -0
- package/dist/js/components/TextInputGroup/index.js +7 -0
- package/dist/js/components/TextInputGroup/index.js.map +1 -0
- package/dist/js/components/Toolbar/Toolbar.d.ts +2 -0
- package/dist/js/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/js/components/Toolbar/Toolbar.js +2 -2
- package/dist/js/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/js/components/index.d.ts +1 -0
- package/dist/js/components/index.d.ts.map +1 -1
- package/dist/js/components/index.js +1 -0
- package/dist/js/components/index.js.map +1 -1
- package/dist/styles/assets/pficon/pficon.woff +0 -0
- package/dist/styles/assets/pficon/pficon.woff2 +0 -0
- package/dist/umd/react-core.css +360 -17
- package/dist/umd/react-core.js +959 -884
- package/dist/umd/react-core.min.css +652 -309
- package/dist/umd/react-core.min.js +3 -3
- package/package.json +6 -6
- package/src/components/CodeBlock/examples/CodeBlock.md +0 -1
- package/src/components/DataList/examples/DataList.md +4 -3
- package/src/components/DragDrop/examples/DragDrop.md +1 -0
- package/src/components/Dropdown/DropdownToggle.tsx +1 -1
- package/src/components/Dropdown/KebabToggle.tsx +1 -1
- package/src/components/DualListSelector/DualListSelector.tsx +25 -23
- package/src/components/DualListSelector/examples/DualListSelector.md +3 -0
- package/src/components/HelperText/examples/HelperText.md +0 -1
- package/src/components/Label/Label.tsx +4 -4
- package/src/components/Label/examples/Label.md +1 -1
- package/src/components/LabelGroup/LabelGroup.tsx +3 -3
- package/src/components/LabelGroup/examples/LabelGroup.md +1 -1
- package/src/components/Menu/Menu.tsx +11 -11
- package/src/components/Menu/MenuItem.tsx +5 -5
- package/src/components/Menu/examples/Menu.md +2 -9
- package/src/components/Modal/__tests__/ModalBox.test.tsx +11 -21
- package/src/components/Modal/__tests__/ModalBoxDescription.test.tsx +12 -0
- package/src/components/Modal/__tests__/ModalBoxTitle.test.tsx +59 -0
- package/src/components/Modal/__tests__/ModalContent.test.tsx +15 -10
- package/src/components/Modal/__tests__/__snapshots__/ModalBox.test.tsx.snap +12 -30
- package/src/components/Modal/__tests__/__snapshots__/ModalBoxDescription.test.tsx.snap +10 -0
- package/src/components/Modal/__tests__/__snapshots__/ModalBoxTitle.test.tsx.snap +158 -0
- package/src/components/Modal/__tests__/__snapshots__/ModalContent.test.tsx.snap +53 -22
- package/src/components/Select/Select.tsx +1 -1
- package/src/components/Select/SelectOption.tsx +1 -1
- package/src/components/Select/examples/Select.md +4 -11
- package/src/components/Sidebar/examples/Sidebar.md +0 -1
- package/src/components/Tabs/TabContentBody.tsx +24 -0
- package/src/components/Tabs/__tests__/Tabs.test.tsx +4 -3
- package/src/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap +10 -2
- package/src/components/Tabs/examples/Tabs.md +40 -0
- package/src/components/Tabs/index.ts +1 -0
- package/src/components/TextInputGroup/TextInputGroup.tsx +22 -0
- package/src/components/TextInputGroup/TextInputGroupMain.tsx +43 -0
- package/src/components/TextInputGroup/TextInputGroupUtilities.tsx +22 -0
- package/src/components/TextInputGroup/__tests__/TextInputGroup.test.tsx +77 -0
- package/src/components/TextInputGroup/__tests__/__snapshots__/TextInputGroup.test.tsx.snap +211 -0
- package/src/components/TextInputGroup/examples/TextInputGroup.md +138 -0
- package/src/components/TextInputGroup/index.ts +3 -0
- package/src/components/Toolbar/Toolbar.tsx +4 -0
- package/src/components/Wizard/examples/Wizard.md +17 -1
- package/src/components/index.ts +1 -0
- package/src/demos/ComposableMenu.md +4 -13
- package/src/demos/DataListDemo.md +0 -2
- package/src/demos/DatePicker.md +1 -0
- package/src/demos/NotificationDrawer/NotificationDrawer.md +1 -0
- package/src/demos/ProgressDemo.md +82 -0
- package/src/demos/ProgressStepperDemo.md +1 -0
- package/src/demos/SearchInput/SearchInput.md +1 -0
- package/src/demos/Tabs.md +439 -0
- package/src/demos/examples/DashboardWrapper.js +16 -2
|
@@ -1049,6 +1049,46 @@ class SeparateTabContent extends React.Component {
|
|
|
1049
1049
|
}
|
|
1050
1050
|
```
|
|
1051
1051
|
|
|
1052
|
+
### Tab content with body and padding
|
|
1053
|
+
```js
|
|
1054
|
+
import React from 'react';
|
|
1055
|
+
import { Tabs, Tab, TabTitleText, TabContent, TabContentBody } from '@patternfly/react-core';
|
|
1056
|
+
|
|
1057
|
+
const TabContentWithBody = () => {
|
|
1058
|
+
const [activeTabKey, setActiveTabKey] = React.useState(0);
|
|
1059
|
+
|
|
1060
|
+
// Toggle currently active tab
|
|
1061
|
+
const handleTabClick = (event, tabIndex) => {
|
|
1062
|
+
setActiveTabKey(tabIndex);
|
|
1063
|
+
};
|
|
1064
|
+
|
|
1065
|
+
const contentRef1 = React.createRef();
|
|
1066
|
+
const contentRef2 = React.createRef();
|
|
1067
|
+
const contentRef3 = React.createRef();
|
|
1068
|
+
|
|
1069
|
+
return (
|
|
1070
|
+
<React.Fragment>
|
|
1071
|
+
<Tabs activeKey={activeTabKey} onSelect={handleTabClick}>
|
|
1072
|
+
<Tab eventKey={0} title={<TabTitleText>Tab item 1</TabTitleText>} tabContentId="refTab1Section" tabContentRef={contentRef1} />
|
|
1073
|
+
<Tab eventKey={1} title={<TabTitleText>Tab item 2</TabTitleText>}tabContentId="refTab2Section" tabContentRef={contentRef2} />
|
|
1074
|
+
<Tab eventKey={2} title={<TabTitleText>Tab item 3</TabTitleText>} tabContentId="refTab3Section" tabContentRef={contentRef3} />
|
|
1075
|
+
</Tabs>
|
|
1076
|
+
<div>
|
|
1077
|
+
<TabContent eventKey={0} id="refTab1Section" ref={contentRef1} aria-label="Tab item 1">
|
|
1078
|
+
<TabContentBody hasPadding> Tab 1 section </TabContentBody>
|
|
1079
|
+
</TabContent>
|
|
1080
|
+
<TabContent eventKey={1} id="refTab2Section" ref={contentRef2} aria-label="Tab item 2" hidden>
|
|
1081
|
+
<TabContentBody hasPadding> Tab 2 section </TabContentBody>
|
|
1082
|
+
</TabContent>
|
|
1083
|
+
<TabContent eventKey={2} id="refTab3Section" ref={contentRef3} aria-label="Tab item 3" hidden>
|
|
1084
|
+
<TabContentBody hasPadding> Tab 3 section </TabContentBody>
|
|
1085
|
+
</TabContent>
|
|
1086
|
+
</div>
|
|
1087
|
+
</React.Fragment>
|
|
1088
|
+
);
|
|
1089
|
+
}
|
|
1090
|
+
```
|
|
1091
|
+
|
|
1052
1092
|
### Children mounting on click
|
|
1053
1093
|
```js
|
|
1054
1094
|
import React from 'react';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import styles from '@patternfly/react-styles/css/components/TextInputGroup/text-input-group';
|
|
3
|
+
import { css } from '@patternfly/react-styles';
|
|
4
|
+
|
|
5
|
+
export interface TextInputGroupProps extends React.HTMLProps<HTMLDivElement> {
|
|
6
|
+
/** Content rendered inside the text input group */
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/** Additional classes applied to the text input group container */
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const TextInputGroup: React.FunctionComponent<TextInputGroupProps> = ({
|
|
13
|
+
children,
|
|
14
|
+
className,
|
|
15
|
+
...props
|
|
16
|
+
}: TextInputGroupProps) => (
|
|
17
|
+
<div className={css(styles.textInputGroup, className)} {...props}>
|
|
18
|
+
{children}
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
TextInputGroup.displayName = 'TextInputGroup';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import styles from '@patternfly/react-styles/css/components/TextInputGroup/text-input-group';
|
|
3
|
+
import { css } from '@patternfly/react-styles';
|
|
4
|
+
|
|
5
|
+
export interface TextInputGroupMainProps extends React.HTMLProps<HTMLDivElement> {
|
|
6
|
+
/** Content rendered inside the text input group main div */
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/** Additional classes applied to the text input group main container */
|
|
9
|
+
className?: string;
|
|
10
|
+
/** Icon to be shown on the left side of the text input group main container */
|
|
11
|
+
icon?: React.ReactNode;
|
|
12
|
+
/** Callback for when there is a change in the input field*/
|
|
13
|
+
onChange?: () => void;
|
|
14
|
+
/** Accessibility label for the input */
|
|
15
|
+
'aria-label'?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const TextInputGroupMain: React.FunctionComponent<TextInputGroupMainProps> = ({
|
|
19
|
+
children,
|
|
20
|
+
className,
|
|
21
|
+
icon,
|
|
22
|
+
onChange,
|
|
23
|
+
'aria-label': ariaLabel,
|
|
24
|
+
value: inputValue,
|
|
25
|
+
...props
|
|
26
|
+
}: TextInputGroupMainProps) => (
|
|
27
|
+
<div className={css(styles.textInputGroupMain, icon && styles.modifiers.icon, className)} {...props}>
|
|
28
|
+
{children}
|
|
29
|
+
<span className={css(styles.textInputGroupText)}>
|
|
30
|
+
{icon && <span className={css(styles.textInputGroupIcon)}>{icon}</span>}
|
|
31
|
+
<input
|
|
32
|
+
type="text"
|
|
33
|
+
className={css(styles.textInputGroupTextInput)}
|
|
34
|
+
aria-label={ariaLabel}
|
|
35
|
+
onChange={onChange}
|
|
36
|
+
value={inputValue}
|
|
37
|
+
/>
|
|
38
|
+
</span>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
TextInputGroupMain.defaultProps = { 'aria-label': 'Type to filter' };
|
|
43
|
+
TextInputGroupMain.displayName = 'TextInputGroupMain';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import styles from '@patternfly/react-styles/css/components/TextInputGroup/text-input-group';
|
|
3
|
+
import { css } from '@patternfly/react-styles';
|
|
4
|
+
|
|
5
|
+
export interface TextInputGroupUtilitiesProps extends React.HTMLProps<HTMLDivElement> {
|
|
6
|
+
/** Content rendered inside the text input group utilities div */
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/** Additional classes applied to the text input group utilities container */
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const TextInputGroupUtilities: React.FunctionComponent<TextInputGroupUtilitiesProps> = ({
|
|
13
|
+
children,
|
|
14
|
+
className,
|
|
15
|
+
...props
|
|
16
|
+
}: TextInputGroupUtilitiesProps) => (
|
|
17
|
+
<div className={css(styles.textInputGroupUtilities, className)} {...props}>
|
|
18
|
+
{children}
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
TextInputGroupUtilities.displayName = 'TextInputGroupUtilities';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mount } from 'enzyme';
|
|
3
|
+
import { TextInputGroup } from '../TextInputGroup';
|
|
4
|
+
import { TextInputGroupMain } from '../TextInputGroupMain';
|
|
5
|
+
import { TextInputGroupUtilities } from '../TextInputGroupUtilities';
|
|
6
|
+
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
7
|
+
|
|
8
|
+
describe('TextInputGroup', () => {
|
|
9
|
+
test('renders content', () => {
|
|
10
|
+
const view = mount(
|
|
11
|
+
<TextInputGroup>
|
|
12
|
+
<TextInputGroupMain>Foo</TextInputGroupMain>
|
|
13
|
+
<TextInputGroupUtilities />
|
|
14
|
+
</TextInputGroup>
|
|
15
|
+
);
|
|
16
|
+
expect(view).toMatchSnapshot();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('gets custom class and id', () => {
|
|
20
|
+
const view = mount(
|
|
21
|
+
<TextInputGroup className="custom-class" id="test-id">
|
|
22
|
+
<TextInputGroupMain>Foo</TextInputGroupMain>
|
|
23
|
+
<TextInputGroupUtilities />
|
|
24
|
+
</TextInputGroup>
|
|
25
|
+
);
|
|
26
|
+
expect(view).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('renders with the proper stying for an icon on the left side of the component', () => {
|
|
30
|
+
const view = mount(
|
|
31
|
+
<TextInputGroup>
|
|
32
|
+
<TextInputGroupMain>Foo</TextInputGroupMain>
|
|
33
|
+
<TextInputGroupUtilities />
|
|
34
|
+
</TextInputGroup>
|
|
35
|
+
);
|
|
36
|
+
expect(view).toMatchSnapshot();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('TextInputGroupMain', () => {
|
|
41
|
+
test('renders content', () => {
|
|
42
|
+
const view = mount(<TextInputGroupMain>Foo</TextInputGroupMain>);
|
|
43
|
+
expect(view).toMatchSnapshot();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('renders given input icon props', () => {
|
|
47
|
+
const view = mount(<TextInputGroupMain icon={<SearchIcon />}>Foo</TextInputGroupMain>);
|
|
48
|
+
expect(view).toMatchSnapshot();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('renders the input with custom aria label when given', () => {
|
|
52
|
+
const view = mount(<TextInputGroupMain aria-label="Foo">Foo</TextInputGroupMain>);
|
|
53
|
+
expect(view).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('does not call onChange callback when the input does not change', () => {
|
|
57
|
+
const onChangeMock = jest.fn();
|
|
58
|
+
|
|
59
|
+
const view = mount(<TextInputGroupMain onChange={onChangeMock}>Foo</TextInputGroupMain>);
|
|
60
|
+
expect(onChangeMock).not.toHaveBeenCalled();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('calls the onChange callback when the input changes', () => {
|
|
64
|
+
const onChangeMock = jest.fn();
|
|
65
|
+
|
|
66
|
+
const view = mount(<TextInputGroupMain onChange={onChangeMock}>Foo</TextInputGroupMain>);
|
|
67
|
+
view.find('input').simulate('change', { target: { value: 'Foo' } });
|
|
68
|
+
expect(onChangeMock).toHaveBeenCalledTimes(1);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe('TextInputGroupUtilities', () => {
|
|
73
|
+
test('renders the content', () => {
|
|
74
|
+
const view = mount(<TextInputGroupUtilities>{<button>Foo</button>}</TextInputGroupUtilities>);
|
|
75
|
+
expect(view).toMatchSnapshot();
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`TextInputGroup gets custom class and id 1`] = `
|
|
4
|
+
<TextInputGroup
|
|
5
|
+
className="custom-class"
|
|
6
|
+
id="test-id"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
className="pf-c-text-input-group custom-class"
|
|
10
|
+
id="test-id"
|
|
11
|
+
>
|
|
12
|
+
<TextInputGroupMain
|
|
13
|
+
aria-label="Type to filter"
|
|
14
|
+
>
|
|
15
|
+
<div
|
|
16
|
+
className="pf-c-text-input-group__main"
|
|
17
|
+
>
|
|
18
|
+
Foo
|
|
19
|
+
<span
|
|
20
|
+
className="pf-c-text-input-group__text"
|
|
21
|
+
>
|
|
22
|
+
<input
|
|
23
|
+
aria-label="Type to filter"
|
|
24
|
+
className="pf-c-text-input-group__text-input"
|
|
25
|
+
type="text"
|
|
26
|
+
/>
|
|
27
|
+
</span>
|
|
28
|
+
</div>
|
|
29
|
+
</TextInputGroupMain>
|
|
30
|
+
<TextInputGroupUtilities>
|
|
31
|
+
<div
|
|
32
|
+
className="pf-c-text-input-group__utilities"
|
|
33
|
+
/>
|
|
34
|
+
</TextInputGroupUtilities>
|
|
35
|
+
</div>
|
|
36
|
+
</TextInputGroup>
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
exports[`TextInputGroup renders content 1`] = `
|
|
40
|
+
<TextInputGroup>
|
|
41
|
+
<div
|
|
42
|
+
className="pf-c-text-input-group"
|
|
43
|
+
>
|
|
44
|
+
<TextInputGroupMain
|
|
45
|
+
aria-label="Type to filter"
|
|
46
|
+
>
|
|
47
|
+
<div
|
|
48
|
+
className="pf-c-text-input-group__main"
|
|
49
|
+
>
|
|
50
|
+
Foo
|
|
51
|
+
<span
|
|
52
|
+
className="pf-c-text-input-group__text"
|
|
53
|
+
>
|
|
54
|
+
<input
|
|
55
|
+
aria-label="Type to filter"
|
|
56
|
+
className="pf-c-text-input-group__text-input"
|
|
57
|
+
type="text"
|
|
58
|
+
/>
|
|
59
|
+
</span>
|
|
60
|
+
</div>
|
|
61
|
+
</TextInputGroupMain>
|
|
62
|
+
<TextInputGroupUtilities>
|
|
63
|
+
<div
|
|
64
|
+
className="pf-c-text-input-group__utilities"
|
|
65
|
+
/>
|
|
66
|
+
</TextInputGroupUtilities>
|
|
67
|
+
</div>
|
|
68
|
+
</TextInputGroup>
|
|
69
|
+
`;
|
|
70
|
+
|
|
71
|
+
exports[`TextInputGroup renders with the proper stying for an icon on the left side of the component 1`] = `
|
|
72
|
+
<TextInputGroup>
|
|
73
|
+
<div
|
|
74
|
+
className="pf-c-text-input-group"
|
|
75
|
+
>
|
|
76
|
+
<TextInputGroupMain
|
|
77
|
+
aria-label="Type to filter"
|
|
78
|
+
>
|
|
79
|
+
<div
|
|
80
|
+
className="pf-c-text-input-group__main"
|
|
81
|
+
>
|
|
82
|
+
Foo
|
|
83
|
+
<span
|
|
84
|
+
className="pf-c-text-input-group__text"
|
|
85
|
+
>
|
|
86
|
+
<input
|
|
87
|
+
aria-label="Type to filter"
|
|
88
|
+
className="pf-c-text-input-group__text-input"
|
|
89
|
+
type="text"
|
|
90
|
+
/>
|
|
91
|
+
</span>
|
|
92
|
+
</div>
|
|
93
|
+
</TextInputGroupMain>
|
|
94
|
+
<TextInputGroupUtilities>
|
|
95
|
+
<div
|
|
96
|
+
className="pf-c-text-input-group__utilities"
|
|
97
|
+
/>
|
|
98
|
+
</TextInputGroupUtilities>
|
|
99
|
+
</div>
|
|
100
|
+
</TextInputGroup>
|
|
101
|
+
`;
|
|
102
|
+
|
|
103
|
+
exports[`TextInputGroupMain renders content 1`] = `
|
|
104
|
+
<TextInputGroupMain
|
|
105
|
+
aria-label="Type to filter"
|
|
106
|
+
>
|
|
107
|
+
<div
|
|
108
|
+
className="pf-c-text-input-group__main"
|
|
109
|
+
>
|
|
110
|
+
Foo
|
|
111
|
+
<span
|
|
112
|
+
className="pf-c-text-input-group__text"
|
|
113
|
+
>
|
|
114
|
+
<input
|
|
115
|
+
aria-label="Type to filter"
|
|
116
|
+
className="pf-c-text-input-group__text-input"
|
|
117
|
+
type="text"
|
|
118
|
+
/>
|
|
119
|
+
</span>
|
|
120
|
+
</div>
|
|
121
|
+
</TextInputGroupMain>
|
|
122
|
+
`;
|
|
123
|
+
|
|
124
|
+
exports[`TextInputGroupMain renders given input icon props 1`] = `
|
|
125
|
+
<TextInputGroupMain
|
|
126
|
+
aria-label="Type to filter"
|
|
127
|
+
icon={
|
|
128
|
+
<SearchIcon
|
|
129
|
+
color="currentColor"
|
|
130
|
+
noVerticalAlign={false}
|
|
131
|
+
size="sm"
|
|
132
|
+
/>
|
|
133
|
+
}
|
|
134
|
+
>
|
|
135
|
+
<div
|
|
136
|
+
className="pf-c-text-input-group__main pf-m-icon"
|
|
137
|
+
>
|
|
138
|
+
Foo
|
|
139
|
+
<span
|
|
140
|
+
className="pf-c-text-input-group__text"
|
|
141
|
+
>
|
|
142
|
+
<span
|
|
143
|
+
className="pf-c-text-input-group__icon"
|
|
144
|
+
>
|
|
145
|
+
<SearchIcon
|
|
146
|
+
color="currentColor"
|
|
147
|
+
noVerticalAlign={false}
|
|
148
|
+
size="sm"
|
|
149
|
+
>
|
|
150
|
+
<svg
|
|
151
|
+
aria-hidden={true}
|
|
152
|
+
aria-labelledby={null}
|
|
153
|
+
fill="currentColor"
|
|
154
|
+
height="1em"
|
|
155
|
+
role="img"
|
|
156
|
+
style={
|
|
157
|
+
Object {
|
|
158
|
+
"verticalAlign": "-0.125em",
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
viewBox="0 0 512 512"
|
|
162
|
+
width="1em"
|
|
163
|
+
>
|
|
164
|
+
<path
|
|
165
|
+
d="M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"
|
|
166
|
+
/>
|
|
167
|
+
</svg>
|
|
168
|
+
</SearchIcon>
|
|
169
|
+
</span>
|
|
170
|
+
<input
|
|
171
|
+
aria-label="Type to filter"
|
|
172
|
+
className="pf-c-text-input-group__text-input"
|
|
173
|
+
type="text"
|
|
174
|
+
/>
|
|
175
|
+
</span>
|
|
176
|
+
</div>
|
|
177
|
+
</TextInputGroupMain>
|
|
178
|
+
`;
|
|
179
|
+
|
|
180
|
+
exports[`TextInputGroupMain renders the input with custom aria label when given 1`] = `
|
|
181
|
+
<TextInputGroupMain
|
|
182
|
+
aria-label="Foo"
|
|
183
|
+
>
|
|
184
|
+
<div
|
|
185
|
+
className="pf-c-text-input-group__main"
|
|
186
|
+
>
|
|
187
|
+
Foo
|
|
188
|
+
<span
|
|
189
|
+
className="pf-c-text-input-group__text"
|
|
190
|
+
>
|
|
191
|
+
<input
|
|
192
|
+
aria-label="Foo"
|
|
193
|
+
className="pf-c-text-input-group__text-input"
|
|
194
|
+
type="text"
|
|
195
|
+
/>
|
|
196
|
+
</span>
|
|
197
|
+
</div>
|
|
198
|
+
</TextInputGroupMain>
|
|
199
|
+
`;
|
|
200
|
+
|
|
201
|
+
exports[`TextInputGroupUtilities renders the content 1`] = `
|
|
202
|
+
<TextInputGroupUtilities>
|
|
203
|
+
<div
|
|
204
|
+
className="pf-c-text-input-group__utilities"
|
|
205
|
+
>
|
|
206
|
+
<button>
|
|
207
|
+
Foo
|
|
208
|
+
</button>
|
|
209
|
+
</div>
|
|
210
|
+
</TextInputGroupUtilities>
|
|
211
|
+
`;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Text input group
|
|
3
|
+
section: components
|
|
4
|
+
cssPrefix: pf-c-text-input-group
|
|
5
|
+
propComponents: ['TextInputGroup', 'TextInputGroupMain', 'TextInputGroupUtilities']
|
|
6
|
+
beta: true
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
10
|
+
import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
|
|
11
|
+
|
|
12
|
+
## Examples
|
|
13
|
+
|
|
14
|
+
### Basic
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import { TextInputGroup, TextInputGroupMain } from '@patternfly/react-core';
|
|
19
|
+
|
|
20
|
+
const BasicTextInputGroup = () => (
|
|
21
|
+
<TextInputGroup>
|
|
22
|
+
<TextInputGroupMain />
|
|
23
|
+
</TextInputGroup>
|
|
24
|
+
);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Utilities and icon
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
import React from 'react';
|
|
31
|
+
import { TextInputGroup, TextInputGroupMain, TextInputGroupUtilities, Button } from '@patternfly/react-core';
|
|
32
|
+
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
33
|
+
import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
|
|
34
|
+
|
|
35
|
+
const TextInputGroupWithIcons = () => {
|
|
36
|
+
const [inputValue, setInputValue] = React.useState('');
|
|
37
|
+
|
|
38
|
+
/** callback for updating the inputValue state in this component so that the input can be controlled */
|
|
39
|
+
const handleInputChange = event => {
|
|
40
|
+
setInputValue(event.target.value);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** show the input clearing button only when the input is not empty */
|
|
44
|
+
const showClearButton = inputValue;
|
|
45
|
+
|
|
46
|
+
/** callback for clearing the text input */
|
|
47
|
+
const clearInput = () => {
|
|
48
|
+
setInputValue('');
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<TextInputGroup>
|
|
53
|
+
<TextInputGroupMain icon={<SearchIcon />} value={inputValue} onChange={handleInputChange} />
|
|
54
|
+
<TextInputGroupUtilities>
|
|
55
|
+
{showClearButton && (
|
|
56
|
+
<Button variant="plain" onClick={clearInput} aria-label="Clear button and input">
|
|
57
|
+
<TimesIcon />
|
|
58
|
+
</Button>
|
|
59
|
+
)}
|
|
60
|
+
</TextInputGroupUtilities>
|
|
61
|
+
</TextInputGroup>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Filters
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
import React from 'react';
|
|
70
|
+
import { TextInputGroup, TextInputGroupMain, TextInputGroupUtilities, Button } from '@patternfly/react-core';
|
|
71
|
+
import { Chip, ChipGroup } from '@patternfly/react-core';
|
|
72
|
+
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
73
|
+
import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
|
|
74
|
+
|
|
75
|
+
const TextInputGroupWithChips = () => {
|
|
76
|
+
const [inputValue, setInputValue] = React.useState('');
|
|
77
|
+
const [currentChips, setCurrentChips] = React.useState([
|
|
78
|
+
'chip one',
|
|
79
|
+
'chip two',
|
|
80
|
+
'chip three',
|
|
81
|
+
'chip four',
|
|
82
|
+
'chip five',
|
|
83
|
+
'chip six',
|
|
84
|
+
'chip seven',
|
|
85
|
+
'chip eight',
|
|
86
|
+
'chip nine',
|
|
87
|
+
'chip ten',
|
|
88
|
+
'chip eleven',
|
|
89
|
+
'chip twelve',
|
|
90
|
+
'chip thirteen',
|
|
91
|
+
'chip fourteen'
|
|
92
|
+
]);
|
|
93
|
+
|
|
94
|
+
/** show the search icon only when there are no chips to prevent the chips from being displayed behind the icon */
|
|
95
|
+
const showSearchIcon = !currentChips.length;
|
|
96
|
+
|
|
97
|
+
/** callback for updating the inputValue state in this component so that the input can be controlled */
|
|
98
|
+
const handleInputChange = event => {
|
|
99
|
+
setInputValue(event.target.value);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/** callback for removing a chip from the chip selections */
|
|
103
|
+
const deleteChip = chipToDelete => {
|
|
104
|
+
const newChips = currentChips.filter(chip => !Object.is(chip, chipToDelete));
|
|
105
|
+
setCurrentChips(newChips);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/** show the input/chip clearing button only when either the text input or chip group are not empty */
|
|
109
|
+
const showClearButton = inputValue || !!currentChips.length;
|
|
110
|
+
|
|
111
|
+
/** callback for clearing all selected chips and the text input */
|
|
112
|
+
const clearChipsAndInput = () => {
|
|
113
|
+
setCurrentChips([]);
|
|
114
|
+
setInputValue('');
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<TextInputGroup>
|
|
119
|
+
<TextInputGroupMain icon={showSearchIcon && <SearchIcon />} value={inputValue} onChange={handleInputChange}>
|
|
120
|
+
<ChipGroup>
|
|
121
|
+
{currentChips.map(currentChip => (
|
|
122
|
+
<Chip key={currentChip} onClick={() => deleteChip(currentChip)}>
|
|
123
|
+
{currentChip}
|
|
124
|
+
</Chip>
|
|
125
|
+
))}
|
|
126
|
+
</ChipGroup>
|
|
127
|
+
</TextInputGroupMain>
|
|
128
|
+
<TextInputGroupUtilities>
|
|
129
|
+
{showClearButton && (
|
|
130
|
+
<Button variant="plain" onClick={clearChipsAndInput} aria-label="Clear button and input">
|
|
131
|
+
<TimesIcon />
|
|
132
|
+
</Button>
|
|
133
|
+
)}
|
|
134
|
+
</TextInputGroupUtilities>
|
|
135
|
+
</TextInputGroup>
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
```
|
|
@@ -30,6 +30,8 @@ export interface ToolbarProps extends React.HTMLProps<HTMLDivElement>, OUIAProps
|
|
|
30
30
|
isStatic?: boolean;
|
|
31
31
|
/** Flag indicating the toolbar should use the Page insets */
|
|
32
32
|
usePageInsets?: boolean;
|
|
33
|
+
/** Flag indicating the toolbar should stick to the top of its container */
|
|
34
|
+
isSticky?: boolean;
|
|
33
35
|
/** Insets at various breakpoints. */
|
|
34
36
|
inset?: {
|
|
35
37
|
default?: 'insetNone' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl';
|
|
@@ -121,6 +123,7 @@ export class Toolbar extends React.Component<ToolbarProps, ToolbarState> {
|
|
|
121
123
|
isStatic,
|
|
122
124
|
inset,
|
|
123
125
|
usePageInsets,
|
|
126
|
+
isSticky,
|
|
124
127
|
ouiaId,
|
|
125
128
|
...props
|
|
126
129
|
} = this.props;
|
|
@@ -139,6 +142,7 @@ export class Toolbar extends React.Component<ToolbarProps, ToolbarState> {
|
|
|
139
142
|
isFullHeight && styles.modifiers.fullHeight,
|
|
140
143
|
isStatic && styles.modifiers.static,
|
|
141
144
|
usePageInsets && styles.modifiers.pageInsets,
|
|
145
|
+
isSticky && styles.modifiers.sticky,
|
|
142
146
|
formatBreakpointMods(inset, styles),
|
|
143
147
|
className
|
|
144
148
|
)}
|
|
@@ -318,6 +318,22 @@ class ValidationWizard extends React.Component {
|
|
|
318
318
|
```
|
|
319
319
|
|
|
320
320
|
### Validate on button press
|
|
321
|
+
|
|
322
|
+
This example demonstrates how to use the `WizardContextConsumer` to consume the `WizardContext`. `WizardContext` can be used to imperatively move to a specific wizard step.
|
|
323
|
+
|
|
324
|
+
The definition of the `WizardContext` is as follows:
|
|
325
|
+
|
|
326
|
+
```
|
|
327
|
+
interface WizardContext {
|
|
328
|
+
goToStepById: (stepId: number | string) => void;
|
|
329
|
+
goToStepByName: (stepName: string) => void;
|
|
330
|
+
onNext: () => void;
|
|
331
|
+
onBack: () => void;
|
|
332
|
+
onClose: () => void;
|
|
333
|
+
activeStep: WizardStep;
|
|
334
|
+
}
|
|
335
|
+
```
|
|
336
|
+
|
|
321
337
|
```js
|
|
322
338
|
import React from 'react';
|
|
323
339
|
import { Button, Wizard, WizardFooter, WizardContextConsumer, Alert } from '@patternfly/react-core';
|
|
@@ -333,7 +349,7 @@ class ValidateButtonPressWizard extends React.Component {
|
|
|
333
349
|
|
|
334
350
|
this.closeWizard = () => {
|
|
335
351
|
console.log("close wizard");
|
|
336
|
-
}
|
|
352
|
+
};
|
|
337
353
|
|
|
338
354
|
this.validateLastStep = onNext => {
|
|
339
355
|
const { stepsValid } = this.state;
|
package/src/components/index.ts
CHANGED