@patternfly/react-core 6.0.0-alpha.22 → 6.0.0-alpha.24
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 +12 -0
- package/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/dynamic/components/AboutModal/package.json +1 -1
- package/dist/dynamic/components/Accordion/package.json +1 -1
- package/dist/dynamic/components/ActionList/package.json +1 -1
- package/dist/dynamic/components/Alert/package.json +1 -1
- package/dist/dynamic/components/Avatar/package.json +1 -1
- package/dist/dynamic/components/BackToTop/package.json +1 -1
- package/dist/dynamic/components/Backdrop/package.json +1 -1
- package/dist/dynamic/components/BackgroundImage/package.json +1 -1
- package/dist/dynamic/components/Badge/package.json +1 -1
- package/dist/dynamic/components/Banner/package.json +1 -1
- package/dist/dynamic/components/Brand/package.json +1 -1
- package/dist/dynamic/components/Breadcrumb/package.json +1 -1
- package/dist/dynamic/components/Button/package.json +1 -1
- package/dist/dynamic/components/CalendarMonth/package.json +1 -1
- package/dist/dynamic/components/Card/package.json +1 -1
- package/dist/dynamic/components/Checkbox/package.json +1 -1
- package/dist/dynamic/components/Chip/package.json +1 -1
- package/dist/dynamic/components/ClipboardCopy/package.json +1 -1
- package/dist/dynamic/components/CodeBlock/package.json +1 -1
- package/dist/dynamic/components/DataList/package.json +1 -1
- package/dist/dynamic/components/DatePicker/package.json +1 -1
- package/dist/dynamic/components/DescriptionList/package.json +1 -1
- package/dist/dynamic/components/Divider/package.json +1 -1
- package/dist/dynamic/components/DragDrop/package.json +1 -1
- package/dist/dynamic/components/Drawer/package.json +1 -1
- package/dist/dynamic/components/Dropdown/package.json +1 -1
- package/dist/dynamic/components/DualListSelector/package.json +1 -1
- package/dist/dynamic/components/EmptyState/package.json +1 -1
- package/dist/dynamic/components/ExpandableSection/package.json +1 -1
- package/dist/dynamic/components/FileUpload/package.json +1 -1
- package/dist/dynamic/components/Form/package.json +1 -1
- package/dist/dynamic/components/FormSelect/package.json +1 -1
- package/dist/dynamic/components/HelperText/package.json +1 -1
- package/dist/dynamic/components/Hint/package.json +1 -1
- package/dist/dynamic/components/Icon/package.json +1 -1
- package/dist/dynamic/components/InputGroup/package.json +1 -1
- package/dist/dynamic/components/JumpLinks/package.json +1 -1
- package/dist/dynamic/components/Label/package.json +1 -1
- package/dist/dynamic/components/List/package.json +1 -1
- package/dist/dynamic/components/LoginPage/package.json +1 -1
- package/dist/dynamic/components/Masthead/package.json +1 -1
- package/dist/dynamic/components/Menu/package.json +1 -1
- package/dist/dynamic/components/MenuToggle/package.json +1 -1
- package/dist/dynamic/components/Modal/package.json +1 -1
- package/dist/dynamic/components/MultipleFileUpload/package.json +1 -1
- package/dist/dynamic/components/Nav/package.json +1 -1
- package/dist/dynamic/components/NotificationBadge/package.json +1 -1
- package/dist/dynamic/components/NotificationDrawer/package.json +1 -1
- package/dist/dynamic/components/NumberInput/package.json +1 -1
- package/dist/dynamic/components/OverflowMenu/package.json +1 -1
- package/dist/dynamic/components/Page/package.json +1 -1
- package/dist/dynamic/components/Pagination/package.json +1 -1
- package/dist/dynamic/components/Panel/package.json +1 -1
- package/dist/dynamic/components/Popover/package.json +1 -1
- package/dist/dynamic/components/Progress/package.json +1 -1
- package/dist/dynamic/components/ProgressStepper/package.json +1 -1
- package/dist/dynamic/components/Radio/package.json +1 -1
- package/dist/dynamic/components/SearchInput/package.json +1 -1
- package/dist/dynamic/components/Select/package.json +1 -1
- package/dist/dynamic/components/Sidebar/package.json +1 -1
- package/dist/dynamic/components/SimpleList/package.json +1 -1
- package/dist/dynamic/components/Skeleton/package.json +1 -1
- package/dist/dynamic/components/SkipToContent/package.json +1 -1
- package/dist/dynamic/components/Slider/package.json +1 -1
- package/dist/dynamic/components/Spinner/package.json +1 -1
- package/dist/dynamic/components/Switch/package.json +1 -1
- package/dist/dynamic/components/Tabs/package.json +1 -1
- package/dist/dynamic/components/Text/package.json +1 -1
- package/dist/dynamic/components/TextArea/package.json +1 -1
- package/dist/dynamic/components/TextInput/package.json +1 -1
- package/dist/dynamic/components/TextInputGroup/package.json +1 -1
- package/dist/dynamic/components/Tile/package.json +1 -1
- package/dist/dynamic/components/TimePicker/package.json +1 -1
- package/dist/dynamic/components/Timestamp/package.json +1 -1
- package/dist/dynamic/components/Title/package.json +1 -1
- package/dist/dynamic/components/ToggleGroup/package.json +1 -1
- package/dist/dynamic/components/Toolbar/package.json +1 -1
- package/dist/dynamic/components/Tooltip/package.json +1 -1
- package/dist/dynamic/components/TreeView/package.json +1 -1
- package/dist/dynamic/components/Truncate/package.json +1 -1
- package/dist/dynamic/components/Wizard/hooks/package.json +1 -1
- package/dist/dynamic/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/ApplicationLauncher/package.json +1 -1
- package/dist/dynamic/deprecated/components/ContextSelector/package.json +1 -1
- package/dist/dynamic/deprecated/components/Dropdown/package.json +1 -1
- package/dist/dynamic/deprecated/components/OptionsMenu/package.json +1 -1
- package/dist/dynamic/deprecated/components/PageHeader/package.json +1 -1
- package/dist/dynamic/deprecated/components/Select/package.json +1 -1
- package/dist/dynamic/deprecated/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/package.json +1 -1
- package/dist/dynamic/helpers/FocusTrap/FocusTrap/package.json +1 -1
- package/dist/dynamic/helpers/GenerateId/GenerateId/package.json +1 -1
- package/dist/dynamic/helpers/KeyboardHandler/package.json +1 -1
- package/dist/dynamic/helpers/OUIA/ouia/package.json +1 -1
- package/dist/dynamic/helpers/Popper/Popper/package.json +1 -1
- package/dist/dynamic/helpers/constants/package.json +1 -1
- package/dist/dynamic/helpers/datetimeUtils/package.json +1 -1
- package/dist/dynamic/helpers/favorites/package.json +1 -1
- package/dist/dynamic/helpers/fileUtils/package.json +1 -1
- package/dist/dynamic/helpers/htmlConstants/package.json +1 -1
- package/dist/dynamic/helpers/package.json +1 -1
- package/dist/dynamic/helpers/resizeObserver/package.json +1 -1
- package/dist/dynamic/helpers/typeUtils/package.json +1 -1
- package/dist/dynamic/helpers/useInterval/package.json +1 -1
- package/dist/dynamic/helpers/useIsomorphicLayout/package.json +1 -1
- package/dist/dynamic/helpers/useUnmountEffect/package.json +1 -1
- package/dist/dynamic/helpers/util/package.json +1 -1
- package/dist/dynamic/layouts/Bullseye/package.json +1 -1
- package/dist/dynamic/layouts/Flex/package.json +1 -1
- package/dist/dynamic/layouts/Gallery/package.json +1 -1
- package/dist/dynamic/layouts/Grid/package.json +1 -1
- package/dist/dynamic/layouts/Level/package.json +1 -1
- package/dist/dynamic/layouts/Split/package.json +1 -1
- package/dist/dynamic/layouts/Stack/package.json +1 -1
- package/dist/dynamic/next/components/Modal/package.json +1 -1
- package/dist/dynamic/next/components/package.json +1 -1
- package/dist/dynamic/styles/package.json +1 -1
- package/dist/esm/components/FileUpload/FileUpload.d.ts +4 -0
- package/dist/esm/components/FileUpload/FileUpload.d.ts.map +1 -1
- package/dist/esm/components/FileUpload/FileUpload.js.map +1 -1
- package/dist/esm/components/FileUpload/FileUploadField.d.ts +4 -0
- package/dist/esm/components/FileUpload/FileUploadField.d.ts.map +1 -1
- package/dist/esm/components/FileUpload/FileUploadField.js +3 -3
- package/dist/esm/components/FileUpload/FileUploadField.js.map +1 -1
- package/dist/esm/components/FileUpload/FileUploadHelperText.d.ts +14 -0
- package/dist/esm/components/FileUpload/FileUploadHelperText.d.ts.map +1 -0
- package/dist/esm/components/FileUpload/FileUploadHelperText.js +10 -0
- package/dist/esm/components/FileUpload/FileUploadHelperText.js.map +1 -0
- package/dist/esm/components/FileUpload/index.d.ts +1 -0
- package/dist/esm/components/FileUpload/index.d.ts.map +1 -1
- package/dist/esm/components/FileUpload/index.js +1 -0
- package/dist/esm/components/FileUpload/index.js.map +1 -1
- package/dist/esm/components/Tabs/TabContent.d.ts.map +1 -1
- package/dist/esm/components/Tabs/TabContent.js +10 -9
- package/dist/esm/components/Tabs/TabContent.js.map +1 -1
- package/dist/esm/components/Tabs/TabTitleIcon.js +1 -1
- package/dist/esm/components/Tabs/TabTitleIcon.js.map +1 -1
- package/dist/esm/components/Tabs/Tabs.d.ts +3 -3
- package/dist/esm/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/esm/components/Tabs/Tabs.js +10 -9
- package/dist/esm/components/Tabs/Tabs.js.map +1 -1
- package/dist/esm/components/Tabs/TabsContext.d.ts +1 -1
- package/dist/esm/components/Tabs/TabsContext.d.ts.map +1 -1
- package/dist/js/components/FileUpload/FileUpload.d.ts +4 -0
- package/dist/js/components/FileUpload/FileUpload.d.ts.map +1 -1
- package/dist/js/components/FileUpload/FileUpload.js.map +1 -1
- package/dist/js/components/FileUpload/FileUploadField.d.ts +4 -0
- package/dist/js/components/FileUpload/FileUploadField.d.ts.map +1 -1
- package/dist/js/components/FileUpload/FileUploadField.js +3 -3
- package/dist/js/components/FileUpload/FileUploadField.js.map +1 -1
- package/dist/js/components/FileUpload/FileUploadHelperText.d.ts +14 -0
- package/dist/js/components/FileUpload/FileUploadHelperText.d.ts.map +1 -0
- package/dist/js/components/FileUpload/FileUploadHelperText.js +14 -0
- package/dist/js/components/FileUpload/FileUploadHelperText.js.map +1 -0
- package/dist/js/components/FileUpload/index.d.ts +1 -0
- package/dist/js/components/FileUpload/index.d.ts.map +1 -1
- package/dist/js/components/FileUpload/index.js +1 -0
- package/dist/js/components/FileUpload/index.js.map +1 -1
- package/dist/js/components/Tabs/TabContent.d.ts.map +1 -1
- package/dist/js/components/Tabs/TabContent.js +10 -9
- package/dist/js/components/Tabs/TabContent.js.map +1 -1
- package/dist/js/components/Tabs/TabTitleIcon.js +1 -1
- package/dist/js/components/Tabs/TabTitleIcon.js.map +1 -1
- package/dist/js/components/Tabs/Tabs.d.ts +3 -3
- package/dist/js/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/js/components/Tabs/Tabs.js +10 -9
- package/dist/js/components/Tabs/Tabs.js.map +1 -1
- package/dist/js/components/Tabs/TabsContext.d.ts +1 -1
- package/dist/js/components/Tabs/TabsContext.d.ts.map +1 -1
- package/dist/styles/base-no-reset.css +1 -0
- package/dist/styles/base.css +1 -0
- package/dist/umd/react-core.min.js +2 -2
- package/helpers/package.json +1 -1
- package/layouts/package.json +1 -1
- package/next/package.json +1 -1
- package/package.json +6 -6
- package/src/components/FileUpload/FileUpload.tsx +4 -0
- package/src/components/FileUpload/FileUploadField.tsx +6 -2
- package/src/components/FileUpload/FileUploadHelperText.tsx +27 -0
- package/src/components/FileUpload/__tests__/FileUploadField.test.tsx +17 -1
- package/src/components/FileUpload/__tests__/FileUploadHelperText.test.tsx +27 -0
- package/src/components/FileUpload/__tests__/__snapshots__/FileUpload.test.tsx.snap +0 -2
- package/src/components/FileUpload/__tests__/__snapshots__/FileUploadField.test.tsx.snap +0 -2
- package/src/components/FileUpload/__tests__/__snapshots__/FileUploadHelperText.test.tsx.snap +11 -0
- package/src/components/FileUpload/examples/FileUpload.md +10 -2
- package/src/components/FileUpload/examples/FileUploadCustomPreview.tsx +1 -2
- package/src/components/FileUpload/examples/FileUploadCustomUpload.tsx +21 -9
- package/src/components/FileUpload/examples/FileUploadTextWithRestrictions.tsx +23 -10
- package/src/components/FileUpload/examples/FileUploadWithHelperText.tsx +59 -0
- package/src/components/FileUpload/index.ts +1 -0
- package/src/components/Tabs/TabContent.tsx +28 -25
- package/src/components/Tabs/TabTitleIcon.tsx +1 -1
- package/src/components/Tabs/Tabs.tsx +30 -30
- package/src/components/Tabs/TabsContext.ts +1 -1
- package/src/components/Tabs/__tests__/Generated/__snapshots__/TabContent.test.tsx.snap +1 -1
- package/src/components/Tabs/__tests__/Tabs.test.tsx +16 -16
- package/src/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap +212 -212
- package/src/components/Tabs/examples/Tabs.md +10 -12
- package/src/components/Tabs/examples/{TabsBoxLight.tsx → TabsBoxSecondary.tsx} +8 -10
- package/src/components/Tabs/examples/{TabsNavSecondary.tsx → TabsNavSubtab.tsx} +2 -2
- package/src/components/Tabs/examples/TabsSubtabs.tsx +21 -21
package/helpers/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-helpers","main":"../dist/js/helpers/index.js","module":"../dist/esm/helpers/index.js","typings":"../dist/esm/helpers/index.d.ts","version":"6.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-core-helpers","main":"../dist/js/helpers/index.js","module":"../dist/esm/helpers/index.js","typings":"../dist/esm/helpers/index.d.ts","version":"6.0.0-alpha.23","private":true}
|
package/layouts/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-layouts","main":"../dist/js/layouts/index.js","module":"../dist/esm/layouts/index.js","typings":"../dist/esm/layouts/index.d.ts","version":"6.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-core-layouts","main":"../dist/js/layouts/index.js","module":"../dist/esm/layouts/index.js","typings":"../dist/esm/layouts/index.d.ts","version":"6.0.0-alpha.23","private":true}
|
package/next/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-next","main":"../dist/js/next/index.js","module":"../dist/esm/next/index.js","typings":"../dist/esm/next/index.d.ts","version":"6.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-core-next","main":"../dist/js/next/index.js","module":"../dist/esm/next/index.js","typings":"../dist/esm/next/index.d.ts","version":"6.0.0-alpha.23","private":true}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.24",
|
|
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",
|
|
@@ -46,15 +46,15 @@
|
|
|
46
46
|
"subpaths": "node ../../scripts/exportSubpaths.js --config subpaths.config.json"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@patternfly/react-icons": "^6.0.0-alpha.
|
|
50
|
-
"@patternfly/react-styles": "^6.0.0-alpha.
|
|
51
|
-
"@patternfly/react-tokens": "^6.0.0-alpha.
|
|
49
|
+
"@patternfly/react-icons": "^6.0.0-alpha.11",
|
|
50
|
+
"@patternfly/react-styles": "^6.0.0-alpha.11",
|
|
51
|
+
"@patternfly/react-tokens": "^6.0.0-alpha.11",
|
|
52
52
|
"focus-trap": "7.5.2",
|
|
53
53
|
"react-dropzone": "^14.2.3",
|
|
54
54
|
"tslib": "^2.5.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@patternfly/patternfly": "6.0.0-alpha.
|
|
57
|
+
"@patternfly/patternfly": "6.0.0-alpha.69",
|
|
58
58
|
"@rollup/plugin-commonjs": "^25.0.0",
|
|
59
59
|
"@rollup/plugin-node-resolve": "^15.0.2",
|
|
60
60
|
"@rollup/plugin-replace": "^5.0.2",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"react": "^17 || ^18",
|
|
74
74
|
"react-dom": "^17 || ^18"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "8ea069949f2c22f8122ffecab5451f278edfb8f7"
|
|
77
77
|
}
|
|
@@ -16,6 +16,10 @@ export interface FileUploadProps
|
|
|
16
16
|
'aria-label'?: string;
|
|
17
17
|
/** Text for the browse button. */
|
|
18
18
|
browseButtonText?: string;
|
|
19
|
+
/** ID or ID's of elements that describe the browse button. Typically this should refer
|
|
20
|
+
* to elements such as helper text when there are file restrictions.
|
|
21
|
+
*/
|
|
22
|
+
browseButtonAriaDescribedby?: string;
|
|
19
23
|
/** Additional children to render after (or instead of) the file preview. */
|
|
20
24
|
children?: React.ReactNode;
|
|
21
25
|
/** Additional classes added to the file upload container element. */
|
|
@@ -19,6 +19,10 @@ export interface FileUploadFieldProps extends Omit<React.HTMLProps<HTMLDivElemen
|
|
|
19
19
|
'aria-label'?: string;
|
|
20
20
|
/** Text for the browse button. */
|
|
21
21
|
browseButtonText?: string;
|
|
22
|
+
/** ID or ID's of elements that describe the browse button. Typically this should refer
|
|
23
|
+
* to elements such as helper text when there are file restrictions.
|
|
24
|
+
*/
|
|
25
|
+
browseButtonAriaDescribedby?: string;
|
|
22
26
|
/** Additional children to render after (or instead of) the file preview. */
|
|
23
27
|
children?: React.ReactNode;
|
|
24
28
|
/** Additional classes added to the file upload field container element. */
|
|
@@ -108,6 +112,7 @@ export const FileUploadField: React.FunctionComponent<FileUploadFieldProps> = ({
|
|
|
108
112
|
filenamePlaceholder = 'Drag a file here or browse to upload',
|
|
109
113
|
filenameAriaLabel = filename ? 'Read only filename' : filenamePlaceholder,
|
|
110
114
|
browseButtonText = 'Browse...',
|
|
115
|
+
browseButtonAriaDescribedby,
|
|
111
116
|
clearButtonText = 'Clear',
|
|
112
117
|
isClearButtonDisabled = !filename && !value,
|
|
113
118
|
containerRef = null as React.Ref<HTMLDivElement>,
|
|
@@ -141,16 +146,15 @@ export const FileUploadField: React.FunctionComponent<FileUploadFieldProps> = ({
|
|
|
141
146
|
name={name || `${id}-filename`}
|
|
142
147
|
aria-label={filenameAriaLabel}
|
|
143
148
|
placeholder={filenamePlaceholder}
|
|
144
|
-
aria-describedby={`${id}-browse-button`}
|
|
145
149
|
value={filename}
|
|
146
150
|
/>
|
|
147
151
|
</InputGroupItem>
|
|
148
152
|
<InputGroupItem>
|
|
149
153
|
<Button
|
|
150
|
-
id={`${id}-browse-button`}
|
|
151
154
|
variant={ButtonVariant.control}
|
|
152
155
|
onClick={onBrowseButtonClick}
|
|
153
156
|
isDisabled={isDisabled}
|
|
157
|
+
aria-describedby={browseButtonAriaDescribedby}
|
|
154
158
|
>
|
|
155
159
|
{browseButtonText}
|
|
156
160
|
</Button>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import styles from '@patternfly/react-styles/css/components/FileUpload/file-upload';
|
|
3
|
+
import { css } from '@patternfly/react-styles';
|
|
4
|
+
|
|
5
|
+
/** A container for helper text content. This sub-component should be passed as a child to
|
|
6
|
+
* the main file upload or file upload field component.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export interface FileUploadHelperTextProps extends React.HTMLProps<HTMLDivElement> {
|
|
10
|
+
/** Content to render inside the file upload helper text container. Typically this will be
|
|
11
|
+
* the helper text component.
|
|
12
|
+
*/
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
/** Additional classes added to the file upload helper text container element. */
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const FileUploadHelperText: React.FunctionComponent<FileUploadHelperTextProps> = ({
|
|
19
|
+
children,
|
|
20
|
+
className,
|
|
21
|
+
...props
|
|
22
|
+
}: FileUploadHelperTextProps) => (
|
|
23
|
+
<div className={css(`${styles.fileUpload}__helper-text`, className)} {...props}>
|
|
24
|
+
{children}
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
FileUploadHelperText.displayName = 'FileUploadHelperText';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FileUploadField } from '../FileUploadField';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { render } from '@testing-library/react';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
4
|
|
|
5
5
|
test('simple fileuploadfield', () => {
|
|
6
6
|
const browserBtnClickHandler = jest.fn();
|
|
@@ -25,3 +25,19 @@ test('simple fileuploadfield', () => {
|
|
|
25
25
|
);
|
|
26
26
|
expect(asFragment()).toMatchSnapshot();
|
|
27
27
|
});
|
|
28
|
+
|
|
29
|
+
test('Renders without aria-describedby on browse button by default', () => {
|
|
30
|
+
render(<FileUploadField id="file-upload-field" browseButtonText="Upload" />);
|
|
31
|
+
|
|
32
|
+
expect(screen.getByRole('button', { name: 'Upload' })).not.toHaveAccessibleDescription();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('Renders without aria-describedby on browse button by default', () => {
|
|
36
|
+
render(
|
|
37
|
+
<FileUploadField id="file-upload-field" browseButtonText="Upload" browseButtonAriaDescribedby="helper-text">
|
|
38
|
+
<div id="helper-text">Helper text</div>
|
|
39
|
+
</FileUploadField>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
expect(screen.getByRole('button', { name: 'Upload' })).toHaveAccessibleDescription('Helper text');
|
|
43
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { FileUploadHelperText } from '../FileUploadHelperText';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import styles from '@patternfly/react-styles/css/components/FileUpload/file-upload';
|
|
5
|
+
|
|
6
|
+
test(`Renders only with class ${styles.fileUpload}__helper-text by default`, () => {
|
|
7
|
+
render(<FileUploadHelperText>Content</FileUploadHelperText>);
|
|
8
|
+
|
|
9
|
+
expect(screen.getByText('Content')).toHaveClass(`${styles.fileUpload}__helper-text`, { exact: true });
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test(`Renders with custom class when className is passed in`, () => {
|
|
13
|
+
render(<FileUploadHelperText className="test">Content</FileUploadHelperText>);
|
|
14
|
+
|
|
15
|
+
expect(screen.getByText('Content')).toHaveClass('test');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test(`Spreads props when passed in`, () => {
|
|
19
|
+
render(<FileUploadHelperText id="test-id">Content</FileUploadHelperText>);
|
|
20
|
+
|
|
21
|
+
expect(screen.getByText('Content')).toHaveAttribute('id', 'test-id');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('Matches the snapshot', () => {
|
|
25
|
+
const { asFragment } = render(<FileUploadHelperText>Content</FileUploadHelperText>);
|
|
26
|
+
expect(asFragment()).toMatchSnapshot();
|
|
27
|
+
});
|
|
@@ -19,7 +19,6 @@ exports[`simple fileupload 1`] = `
|
|
|
19
19
|
class="pf-v5-c-form-control pf-m-readonly"
|
|
20
20
|
>
|
|
21
21
|
<input
|
|
22
|
-
aria-describedby="simple-text-file-browse-button"
|
|
23
22
|
aria-invalid="false"
|
|
24
23
|
aria-label="Drag a file here or browse to upload"
|
|
25
24
|
data-ouia-component-id="OUIA-Generated-TextInputBase-1"
|
|
@@ -43,7 +42,6 @@ exports[`simple fileupload 1`] = `
|
|
|
43
42
|
data-ouia-component-id="OUIA-Generated-Button-control-1"
|
|
44
43
|
data-ouia-component-type="PF5/Button"
|
|
45
44
|
data-ouia-safe="true"
|
|
46
|
-
id="simple-text-file-browse-button"
|
|
47
45
|
type="button"
|
|
48
46
|
>
|
|
49
47
|
Browse...
|
|
@@ -18,7 +18,6 @@ exports[`simple fileuploadfield 1`] = `
|
|
|
18
18
|
class="pf-v5-c-form-control pf-m-readonly"
|
|
19
19
|
>
|
|
20
20
|
<input
|
|
21
|
-
aria-describedby="custom-file-upload-browse-button"
|
|
22
21
|
aria-invalid="false"
|
|
23
22
|
aria-label="Do something custom with this!"
|
|
24
23
|
data-ouia-component-id="OUIA-Generated-TextInputBase-1"
|
|
@@ -42,7 +41,6 @@ exports[`simple fileuploadfield 1`] = `
|
|
|
42
41
|
data-ouia-component-id="OUIA-Generated-Button-control-1"
|
|
43
42
|
data-ouia-component-type="PF5/Button"
|
|
44
43
|
data-ouia-safe="true"
|
|
45
|
-
id="custom-file-upload-browse-button"
|
|
46
44
|
type="button"
|
|
47
45
|
>
|
|
48
46
|
Browse...
|
|
@@ -7,6 +7,7 @@ subsection: file-upload
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
import FileUploadIcon from '@patternfly/react-icons/dist/esm/icons/file-upload-icon';
|
|
10
|
+
import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
|
|
10
11
|
|
|
11
12
|
## Examples
|
|
12
13
|
|
|
@@ -22,11 +23,18 @@ Pressing _Clear_ button triggers `onClearClick` event.
|
|
|
22
23
|
```ts file="./FileUploadSimpleText.tsx"
|
|
23
24
|
```
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
### With helper text
|
|
27
|
+
|
|
28
|
+
You can pass in the `<FileUploadHelperText` sub-component via the `children` property to `<FileUpload>`.
|
|
29
|
+
|
|
30
|
+
```ts file="./FileUploadWithHelperText.tsx"
|
|
31
|
+
```
|
|
27
32
|
|
|
28
33
|
### Text file with edits allowed
|
|
29
34
|
|
|
35
|
+
A user can always type instead of selecting a file, but by default, once a user selects a text file from their disk they are not allowed to edit it (to prevent unintended changes to a format-sensitive file). This behavior can be changed with the `allowEditingUploadedText` prop.
|
|
36
|
+
Typing/pasting text in the box will call `onTextChange` with a string, and a string value is expected for the `value` prop. :
|
|
37
|
+
|
|
30
38
|
```ts file="./FileUploadTextWithEdits.tsx"
|
|
31
39
|
```
|
|
32
40
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FileUpload } from '@patternfly/react-core';
|
|
3
3
|
import FileUploadIcon from '@patternfly/react-icons/dist/esm/icons/file-upload-icon';
|
|
4
|
-
import spacing from '@patternfly/react-styles/css/utilities/Spacing/spacing';
|
|
5
4
|
|
|
6
5
|
export const CustomPreviewFileUpload: React.FunctionComponent = () => {
|
|
7
6
|
const [value, setValue] = React.useState<File>();
|
|
@@ -29,7 +28,7 @@ export const CustomPreviewFileUpload: React.FunctionComponent = () => {
|
|
|
29
28
|
browseButtonText="Upload"
|
|
30
29
|
>
|
|
31
30
|
{value && (
|
|
32
|
-
<div
|
|
31
|
+
<div>
|
|
33
32
|
<FileUploadIcon width="2em" height="2em" /> Custom preview here for your {value.size}-byte file named{' '}
|
|
34
33
|
{value.name}
|
|
35
34
|
</div>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { FileUploadField, Checkbox } from '@patternfly/react-core';
|
|
3
|
-
import spacing from '@patternfly/react-styles/css/utilities/Spacing/spacing';
|
|
2
|
+
import { FileUploadField, FileUploadHelperText, HelperText, HelperTextItem, Checkbox } from '@patternfly/react-core';
|
|
4
3
|
|
|
5
4
|
export const CustomPreviewFileUpload: React.FunctionComponent = () => {
|
|
6
5
|
const properties = [
|
|
@@ -9,7 +8,8 @@ export const CustomPreviewFileUpload: React.FunctionComponent = () => {
|
|
|
9
8
|
'isDragActive',
|
|
10
9
|
'isLoading',
|
|
11
10
|
'hideDefaultPreview',
|
|
12
|
-
'
|
|
11
|
+
'hasCustomFilePreview',
|
|
12
|
+
'hasHelperText',
|
|
13
13
|
'hasPlaceholderText'
|
|
14
14
|
];
|
|
15
15
|
|
|
@@ -19,7 +19,8 @@ export const CustomPreviewFileUpload: React.FunctionComponent = () => {
|
|
|
19
19
|
const [isLoading, setIsLoading] = React.useState(false);
|
|
20
20
|
const [isDragActive, setIsDragActive] = React.useState(false);
|
|
21
21
|
const [hideDefaultPreview, setHideDefaultPreview] = React.useState(false);
|
|
22
|
-
const [
|
|
22
|
+
const [hasCustomFilePreview, setHasCustomFilePreview] = React.useState(false);
|
|
23
|
+
const [hasHelperText, setHasHelperText] = React.useState(false);
|
|
23
24
|
const [hasPlaceholderText, setHasPlaceholderText] = React.useState(false);
|
|
24
25
|
const [checkedState, setCheckedState] = React.useState([
|
|
25
26
|
filename,
|
|
@@ -27,7 +28,8 @@ export const CustomPreviewFileUpload: React.FunctionComponent = () => {
|
|
|
27
28
|
isLoading,
|
|
28
29
|
isDragActive,
|
|
29
30
|
hideDefaultPreview,
|
|
30
|
-
|
|
31
|
+
hasCustomFilePreview,
|
|
32
|
+
hasHelperText,
|
|
31
33
|
hasPlaceholderText
|
|
32
34
|
]);
|
|
33
35
|
|
|
@@ -68,8 +70,12 @@ export const CustomPreviewFileUpload: React.FunctionComponent = () => {
|
|
|
68
70
|
}
|
|
69
71
|
break;
|
|
70
72
|
|
|
71
|
-
case '
|
|
72
|
-
checked ?
|
|
73
|
+
case 'hasCustomFilePreview':
|
|
74
|
+
checked ? setHasCustomFilePreview(true) : setHasCustomFilePreview(false);
|
|
75
|
+
break;
|
|
76
|
+
|
|
77
|
+
case 'hasHelperText':
|
|
78
|
+
checked ? setHasHelperText(true) : setHasHelperText(false);
|
|
73
79
|
break;
|
|
74
80
|
|
|
75
81
|
case 'hasPlaceholderText':
|
|
@@ -108,10 +114,16 @@ export const CustomPreviewFileUpload: React.FunctionComponent = () => {
|
|
|
108
114
|
isDragActive={isDragActive}
|
|
109
115
|
hideDefaultPreview={hideDefaultPreview}
|
|
110
116
|
browseButtonText="Upload"
|
|
117
|
+
browseButtonAriaDescribedby={hasHelperText ? 'custom-upload-helpText' : undefined}
|
|
111
118
|
textAreaPlaceholder={hasPlaceholderText ? 'File preview' : ''}
|
|
112
119
|
>
|
|
113
|
-
{
|
|
114
|
-
|
|
120
|
+
{hasCustomFilePreview && <div>(A custom preview of the uploaded file can be passed as children)</div>}
|
|
121
|
+
{hasHelperText && (
|
|
122
|
+
<FileUploadHelperText>
|
|
123
|
+
<HelperText>
|
|
124
|
+
<HelperTextItem id="custom-upload-helpText">Upload a CSV file</HelperTextItem>
|
|
125
|
+
</HelperText>
|
|
126
|
+
</FileUploadHelperText>
|
|
115
127
|
)}
|
|
116
128
|
</FileUploadField>
|
|
117
129
|
</div>
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import {
|
|
3
3
|
FileUpload,
|
|
4
|
+
FileUploadHelperText,
|
|
4
5
|
Form,
|
|
5
6
|
FormGroup,
|
|
6
|
-
FormHelperText,
|
|
7
7
|
HelperText,
|
|
8
8
|
HelperTextItem,
|
|
9
|
-
DropEvent
|
|
9
|
+
DropEvent,
|
|
10
|
+
Icon
|
|
10
11
|
} from '@patternfly/react-core';
|
|
12
|
+
import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
|
|
11
13
|
|
|
12
14
|
export const TextFileUploadWithRestrictions: React.FunctionComponent = () => {
|
|
13
15
|
const [value, setValue] = React.useState('');
|
|
@@ -68,14 +70,25 @@ export const TextFileUploadWithRestrictions: React.FunctionComponent = () => {
|
|
|
68
70
|
}}
|
|
69
71
|
validated={isRejected ? 'error' : 'default'}
|
|
70
72
|
browseButtonText="Upload"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<
|
|
74
|
-
<
|
|
75
|
-
{isRejected ? '
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
browseButtonAriaDescribedby="restricted-file-example-helpText"
|
|
74
|
+
>
|
|
75
|
+
<FileUploadHelperText>
|
|
76
|
+
<HelperText isLiveRegion>
|
|
77
|
+
<HelperTextItem id="restricted-file-example-helpText" variant={isRejected ? 'error' : 'default'}>
|
|
78
|
+
{isRejected ? (
|
|
79
|
+
<>
|
|
80
|
+
<Icon status="danger">
|
|
81
|
+
<ExclamationCircleIcon />
|
|
82
|
+
</Icon>
|
|
83
|
+
Must be a CSV file no larger than 1 KB
|
|
84
|
+
</>
|
|
85
|
+
) : (
|
|
86
|
+
'Upload a CSV file'
|
|
87
|
+
)}
|
|
88
|
+
</HelperTextItem>
|
|
89
|
+
</HelperText>
|
|
90
|
+
</FileUploadHelperText>
|
|
91
|
+
</FileUpload>
|
|
79
92
|
</FormGroup>
|
|
80
93
|
</Form>
|
|
81
94
|
);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FileUpload, FileUploadHelperText, HelperText, HelperTextItem, DropEvent } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const FileUploadWithHelperText: React.FunctionComponent = () => {
|
|
5
|
+
const [value, setValue] = React.useState('');
|
|
6
|
+
const [filename, setFilename] = React.useState('');
|
|
7
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
8
|
+
|
|
9
|
+
const handleFileInputChange = (_, file: File) => {
|
|
10
|
+
setFilename(file.name);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const handleTextChange = (_event: React.ChangeEvent<HTMLTextAreaElement>, value: string) => {
|
|
14
|
+
setValue(value);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const handleDataChange = (_event: DropEvent, value: string) => {
|
|
18
|
+
setValue(value);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const handleClear = (_event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
|
|
22
|
+
setFilename('');
|
|
23
|
+
setValue('');
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const handleFileReadStarted = (_event: DropEvent, _fileHandle: File) => {
|
|
27
|
+
setIsLoading(true);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const handleFileReadFinished = (_event: DropEvent, _fileHandle: File) => {
|
|
31
|
+
setIsLoading(false);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<FileUpload
|
|
36
|
+
id="file-upload-helper-text"
|
|
37
|
+
type="text"
|
|
38
|
+
value={value}
|
|
39
|
+
filename={filename}
|
|
40
|
+
filenamePlaceholder="Drag and drop a file or upload one"
|
|
41
|
+
onFileInputChange={handleFileInputChange}
|
|
42
|
+
onDataChange={handleDataChange}
|
|
43
|
+
onTextChange={handleTextChange}
|
|
44
|
+
onReadStarted={handleFileReadStarted}
|
|
45
|
+
onReadFinished={handleFileReadFinished}
|
|
46
|
+
onClearClick={handleClear}
|
|
47
|
+
isLoading={isLoading}
|
|
48
|
+
allowEditingUploadedText={false}
|
|
49
|
+
browseButtonText="Upload"
|
|
50
|
+
browseButtonAriaDescribedby="helper-text-example-helpText"
|
|
51
|
+
>
|
|
52
|
+
<FileUploadHelperText>
|
|
53
|
+
<HelperText>
|
|
54
|
+
<HelperTextItem id="helper-text-example-helpText">Upload a CSV file</HelperTextItem>
|
|
55
|
+
</HelperText>
|
|
56
|
+
</FileUploadHelperText>
|
|
57
|
+
</FileUpload>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
@@ -27,10 +27,10 @@ export interface TabContentProps extends Omit<React.HTMLProps<HTMLElement>, 'ref
|
|
|
27
27
|
ouiaSafe?: boolean;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const variantStyle = {
|
|
31
|
+
default: '',
|
|
32
|
+
secondary: styles.modifiers.secondary
|
|
33
|
+
};
|
|
34
34
|
|
|
35
35
|
const TabContentBase: React.FunctionComponent<TabContentProps> = ({
|
|
36
36
|
id,
|
|
@@ -56,27 +56,30 @@ const TabContentBase: React.FunctionComponent<TabContentProps> = ({
|
|
|
56
56
|
|
|
57
57
|
return (
|
|
58
58
|
<TabsContextConsumer>
|
|
59
|
-
{({ variant }: TabsContextProps) =>
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
children
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
59
|
+
{({ variant }: TabsContextProps) => {
|
|
60
|
+
const variantClass = variantStyle[variant];
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<section
|
|
64
|
+
ref={innerRef}
|
|
65
|
+
hidden={children ? null : child.props.eventKey !== activeKey}
|
|
66
|
+
className={
|
|
67
|
+
children
|
|
68
|
+
? css(styles.tabContent, className, variantClass)
|
|
69
|
+
: css(styles.tabContent, child.props.className, variantClass)
|
|
70
|
+
}
|
|
71
|
+
id={children ? id : `pf-tab-section-${child.props.eventKey}-${id}`}
|
|
72
|
+
aria-label={ariaLabel}
|
|
73
|
+
aria-labelledby={labelledBy}
|
|
74
|
+
role="tabpanel"
|
|
75
|
+
tabIndex={0}
|
|
76
|
+
{...getOUIAProps('TabContent', ouiaId, ouiaSafe)}
|
|
77
|
+
{...props}
|
|
78
|
+
>
|
|
79
|
+
{children || child.props.children}
|
|
80
|
+
</section>
|
|
81
|
+
);
|
|
82
|
+
}}
|
|
80
83
|
</TabsContextConsumer>
|
|
81
84
|
);
|
|
82
85
|
}
|
|
@@ -14,7 +14,7 @@ export const TabTitleIcon: React.FunctionComponent<TabTitleIconProps> = ({
|
|
|
14
14
|
className = '',
|
|
15
15
|
...props
|
|
16
16
|
}: TabTitleIconProps) => (
|
|
17
|
-
<span className={css(styles.
|
|
17
|
+
<span className={css(`${styles.tabs}__item-icon`, className)} {...props}>
|
|
18
18
|
{children}
|
|
19
19
|
</span>
|
|
20
20
|
);
|