diff --git a/package.json b/package.json index 570a93c70c8..1ddbb6d63ae 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "start": "yarn build && concurrently --kill-others \"yarn watch\" \"yarn workspace @patternfly/react-docs develop\"", "start:cypress": "lerna run cypress:open", "start:demo-app": "lerna run start:demo-app --stream", - "test": "jest packages", + "test": "TZ=EST jest packages", "test:a11y": "lerna run test:a11y --stream", "test:integration": "yarn workspace @patternfly/react-integration test:integration", "uninstall": "find . -name node_modules -type d | xargs rm -rf", diff --git a/packages/react-catalog-view-extension/CHANGELOG.md b/packages/react-catalog-view-extension/CHANGELOG.md index 5f8f0c02d24..659370e5cc1 100644 --- a/packages/react-catalog-view-extension/CHANGELOG.md +++ b/packages/react-catalog-view-extension/CHANGELOG.md @@ -3,6 +3,78 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [4.92.35](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-catalog-view-extension@4.92.34...@patternfly/react-catalog-view-extension@4.92.35) (2022-10-13) + +**Note:** Version bump only for package @patternfly/react-catalog-view-extension + + + + + +## [4.92.34](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-catalog-view-extension@4.92.33...@patternfly/react-catalog-view-extension@4.92.34) (2022-10-13) + +**Note:** Version bump only for package @patternfly/react-catalog-view-extension + + + + + +## [4.92.33](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-catalog-view-extension@4.92.32...@patternfly/react-catalog-view-extension@4.92.33) (2022-10-13) + +**Note:** Version bump only for package @patternfly/react-catalog-view-extension + + + + + +## [4.92.32](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-catalog-view-extension@4.92.31...@patternfly/react-catalog-view-extension@4.92.32) (2022-10-12) + +**Note:** Version bump only for package @patternfly/react-catalog-view-extension + + + + + +## [4.92.31](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-catalog-view-extension@4.92.30...@patternfly/react-catalog-view-extension@4.92.31) (2022-10-12) + +**Note:** Version bump only for package @patternfly/react-catalog-view-extension + + + + + +## [4.92.30](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-catalog-view-extension@4.92.29...@patternfly/react-catalog-view-extension@4.92.30) (2022-10-12) + +**Note:** Version bump only for package @patternfly/react-catalog-view-extension + + + + + +## [4.92.29](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-catalog-view-extension@4.92.28...@patternfly/react-catalog-view-extension@4.92.29) (2022-10-12) + +**Note:** Version bump only for package @patternfly/react-catalog-view-extension + + + + + +## 4.92.28 (2022-10-12) + +**Note:** Version bump only for package @patternfly/react-catalog-view-extension + + + + + +## [4.92.27](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-catalog-view-extension@4.92.26...@patternfly/react-catalog-view-extension@4.92.27) (2022-10-10) + +**Note:** Version bump only for package @patternfly/react-catalog-view-extension + + + + + ## [4.92.26](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-catalog-view-extension@4.92.25...@patternfly/react-catalog-view-extension@4.92.26) (2022-10-05) **Note:** Version bump only for package @patternfly/react-catalog-view-extension diff --git a/packages/react-catalog-view-extension/package.json b/packages/react-catalog-view-extension/package.json index 4b5f1809a8f..7a38d791014 100644 --- a/packages/react-catalog-view-extension/package.json +++ b/packages/react-catalog-view-extension/package.json @@ -1,6 +1,6 @@ { "name": "@patternfly/react-catalog-view-extension", - "version": "4.92.26", + "version": "4.92.35", "description": "This library provides catalog view extensions for PatternFly 4 React.", "main": "dist/js/index.js", "module": "dist/esm/index.js", @@ -36,7 +36,7 @@ }, "dependencies": { "@patternfly/patternfly": "4.217.1", - "@patternfly/react-core": "^4.250.1", + "@patternfly/react-core": "^4.251.1", "@patternfly/react-styles": "^4.91.6" }, "devDependencies": { diff --git a/packages/react-code-editor/CHANGELOG.md b/packages/react-code-editor/CHANGELOG.md index b1d7c42277a..cdc28b695e2 100644 --- a/packages/react-code-editor/CHANGELOG.md +++ b/packages/react-code-editor/CHANGELOG.md @@ -3,6 +3,78 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [4.82.35](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@4.82.34...@patternfly/react-code-editor@4.82.35) (2022-10-13) + +**Note:** Version bump only for package @patternfly/react-code-editor + + + + + +## [4.82.34](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@4.82.33...@patternfly/react-code-editor@4.82.34) (2022-10-13) + +**Note:** Version bump only for package @patternfly/react-code-editor + + + + + +## [4.82.33](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@4.82.32...@patternfly/react-code-editor@4.82.33) (2022-10-13) + +**Note:** Version bump only for package @patternfly/react-code-editor + + + + + +## [4.82.32](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@4.82.31...@patternfly/react-code-editor@4.82.32) (2022-10-12) + +**Note:** Version bump only for package @patternfly/react-code-editor + + + + + +## [4.82.31](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@4.82.30...@patternfly/react-code-editor@4.82.31) (2022-10-12) + +**Note:** Version bump only for package @patternfly/react-code-editor + + + + + +## [4.82.30](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@4.82.29...@patternfly/react-code-editor@4.82.30) (2022-10-12) + +**Note:** Version bump only for package @patternfly/react-code-editor + + + + + +## [4.82.29](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@4.82.28...@patternfly/react-code-editor@4.82.29) (2022-10-12) + +**Note:** Version bump only for package @patternfly/react-code-editor + + + + + +## 4.82.28 (2022-10-12) + +**Note:** Version bump only for package @patternfly/react-code-editor + + + + + +## [4.82.27](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@4.82.26...@patternfly/react-code-editor@4.82.27) (2022-10-10) + +**Note:** Version bump only for package @patternfly/react-code-editor + + + + + ## [4.82.26](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-code-editor@4.82.25...@patternfly/react-code-editor@4.82.26) (2022-10-05) **Note:** Version bump only for package @patternfly/react-code-editor diff --git a/packages/react-code-editor/package.json b/packages/react-code-editor/package.json index 2f3bc4b925c..c6ee3639eff 100644 --- a/packages/react-code-editor/package.json +++ b/packages/react-code-editor/package.json @@ -1,6 +1,6 @@ { "name": "@patternfly/react-code-editor", - "version": "4.82.26", + "version": "4.82.35", "description": "This package provides a PatternFly wrapper for the Monaco code editor\n", "main": "dist/js/index.js", "module": "dist/esm/index.js", @@ -30,7 +30,7 @@ "clean": "rimraf dist" }, "dependencies": { - "@patternfly/react-core": "^4.250.1", + "@patternfly/react-core": "^4.251.1", "@patternfly/react-icons": "^4.92.6", "@patternfly/react-styles": "^4.91.6", "react-dropzone": "9.0.0", diff --git a/packages/react-console/CHANGELOG.md b/packages/react-console/CHANGELOG.md index 16577d1fa81..10dc2714f0b 100644 --- a/packages/react-console/CHANGELOG.md +++ b/packages/react-console/CHANGELOG.md @@ -3,6 +3,78 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [4.92.35](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-console@4.92.34...@patternfly/react-console@4.92.35) (2022-10-13) + +**Note:** Version bump only for package @patternfly/react-console + + + + + +## [4.92.34](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-console@4.92.33...@patternfly/react-console@4.92.34) (2022-10-13) + +**Note:** Version bump only for package @patternfly/react-console + + + + + +## [4.92.33](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-console@4.92.32...@patternfly/react-console@4.92.33) (2022-10-13) + +**Note:** Version bump only for package @patternfly/react-console + + + + + +## [4.92.32](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-console@4.92.31...@patternfly/react-console@4.92.32) (2022-10-12) + +**Note:** Version bump only for package @patternfly/react-console + + + + + +## [4.92.31](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-console@4.92.30...@patternfly/react-console@4.92.31) (2022-10-12) + +**Note:** Version bump only for package @patternfly/react-console + + + + + +## [4.92.30](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-console@4.92.29...@patternfly/react-console@4.92.30) (2022-10-12) + +**Note:** Version bump only for package @patternfly/react-console + + + + + +## [4.92.29](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-console@4.92.28...@patternfly/react-console@4.92.29) (2022-10-12) + +**Note:** Version bump only for package @patternfly/react-console + + + + + +## 4.92.28 (2022-10-12) + +**Note:** Version bump only for package @patternfly/react-console + + + + + +## [4.92.27](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-console@4.92.26...@patternfly/react-console@4.92.27) (2022-10-10) + +**Note:** Version bump only for package @patternfly/react-console + + + + + ## [4.92.26](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-console@4.92.25...@patternfly/react-console@4.92.26) (2022-10-05) **Note:** Version bump only for package @patternfly/react-console diff --git a/packages/react-console/package.json b/packages/react-console/package.json index cd2fad89b54..3e08c0f9045 100644 --- a/packages/react-console/package.json +++ b/packages/react-console/package.json @@ -1,6 +1,6 @@ { "name": "@patternfly/react-console", - "version": "4.92.26", + "version": "4.92.35", "description": "This package provides VncConsole, SerialConsole and DesktopViewer React components to be used alongside patternfly-react to access virtual machine or server consoles.", "main": "dist/js/index.js", "module": "dist/esm/index.js", @@ -34,7 +34,7 @@ "dependencies": { "@novnc/novnc": "^1.2.0", "@patternfly/patternfly": "4.217.1", - "@patternfly/react-core": "^4.250.1", + "@patternfly/react-core": "^4.251.1", "@spice-project/spice-html5": "^0.2.1", "@types/file-saver": "^2.0.1", "file-saver": "^1.3.8", diff --git a/packages/react-core/CHANGELOG.md b/packages/react-core/CHANGELOG.md index 33622f4969f..37b0c74c479 100644 --- a/packages/react-core/CHANGELOG.md +++ b/packages/react-core/CHANGELOG.md @@ -3,6 +3,90 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [4.251.1](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-core@4.251.0...@patternfly/react-core@4.251.1) (2022-10-13) + +**Note:** Version bump only for package @patternfly/react-core + + + + + +# [4.251.0](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-core@4.250.8...@patternfly/react-core@4.251.0) (2022-10-13) + + +### Features + +* **label+labelGroup:** update aria-labels to include label text ([#8192](https://github.com/patternfly/patternfly-react/issues/8192)) ([f99a34d](https://github.com/patternfly/patternfly-react/commit/f99a34d503699d169cc2376841ec48fc9eb66bad)) + + + + + +## [4.250.8](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-core@4.250.7...@patternfly/react-core@4.250.8) (2022-10-13) + + +### Bug Fixes + +* **Slider:** correct tab order when input is above thumb ([#8190](https://github.com/patternfly/patternfly-react/issues/8190)) ([3a8b500](https://github.com/patternfly/patternfly-react/commit/3a8b500ff1f68dab5b34721186afe01147c74637)) + + + + + +## [4.250.7](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-core@4.250.6...@patternfly/react-core@4.250.7) (2022-10-12) + +**Note:** Version bump only for package @patternfly/react-core + + + + + +## [4.250.6](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-core@4.250.5...@patternfly/react-core@4.250.6) (2022-10-12) + +**Note:** Version bump only for package @patternfly/react-core + + + + + +## [4.250.5](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-core@4.250.4...@patternfly/react-core@4.250.5) (2022-10-12) + + +### Bug Fixes + +* **Dropdown next:** Add support for forward ref and updated docs. ([#8142](https://github.com/patternfly/patternfly-react/issues/8142)) ([423dd67](https://github.com/patternfly/patternfly-react/commit/423dd67d0d81910e195722d07a3de3340eba4443)) + + + + + +## [4.250.4](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-core@4.250.3...@patternfly/react-core@4.250.4) (2022-10-12) + +**Note:** Version bump only for package @patternfly/react-core + + + + + +## 4.250.3 (2022-10-12) + +**Note:** Version bump only for package @patternfly/react-core + + + + + +## [4.250.2](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-core@4.250.1...@patternfly/react-core@4.250.2) (2022-10-10) + + +### Bug Fixes + +* **Menu:** fixed height issue with drilldown examples ([#8033](https://github.com/patternfly/patternfly-react/issues/8033)) ([c0583b5](https://github.com/patternfly/patternfly-react/commit/c0583b530310b3d89be222e58fe926ecc6dd8d99)) + + + + + ## [4.250.1](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-core@4.250.0...@patternfly/react-core@4.250.1) (2022-10-05) **Note:** Version bump only for package @patternfly/react-core diff --git a/packages/react-core/package.json b/packages/react-core/package.json index 816eb790a8e..653c54e678f 100644 --- a/packages/react-core/package.json +++ b/packages/react-core/package.json @@ -1,6 +1,6 @@ { "name": "@patternfly/react-core", - "version": "4.250.1", + "version": "4.251.1", "description": "This library provides a set of common React components for use with the PatternFly reference implementation.", "main": "dist/js/index.js", "module": "dist/esm/index.js", diff --git a/packages/react-core/src/components/Banner/__tests__/Banner.test.tsx b/packages/react-core/src/components/Banner/__tests__/Banner.test.tsx index 1a7f8c64a7d..1dc8d86b33e 100644 --- a/packages/react-core/src/components/Banner/__tests__/Banner.test.tsx +++ b/packages/react-core/src/components/Banner/__tests__/Banner.test.tsx @@ -1,27 +1,92 @@ +import * as React from 'react'; +import { render, screen } from '@testing-library/react'; import { Banner } from '../Banner'; -import React from 'react'; -import { render } from '@testing-library/react'; - -['default', 'info', 'success', 'warning', 'danger'].forEach((variant: string) => { - test(`${variant} banner`, () => { - const { asFragment } = render( - - {variant} Banner - - ); - expect(asFragment()).toMatchSnapshot(); - }); -}); - -test(`sticky banner`, () => { - const { asFragment } = render( - - Sticky Banner - + +test('Renders without children', () => { + render( +
+ +
); + expect(screen.getByTestId('banner').firstChild).toBeVisible(); +}); + +test('Renders children', () => { + render(Test); + expect(screen.getByText('Test')).toBeVisible(); +}); + +test('Renders with class name pf-c-banner', () => { + render(Test); + expect(screen.getByText('Test')).toHaveClass('pf-c-banner'); +}); + +test('Renders with custom class name when className prop is provided', () => { + render(Test); + expect(screen.getByText('Test')).toHaveClass('custom-class'); +}); + +test('Renders without any modifier class when variant prop is not passed', () => { + render(Test); + expect(screen.getByText('Test')).toHaveClass('pf-c-banner', { exact: true }); +}); + +test('Renders with class name pf-m-success when "success" is passed to variant prop', () => { + render(Test); + expect(screen.getByText('Test')).toHaveClass('pf-m-success'); +}); + +test('Renders with class name pf-m-danger when "danger" is passed to variant prop', () => { + render(Test); + expect(screen.getByText('Test')).toHaveClass('pf-m-danger'); +}); + +test('Renders with class name pf-m-warning when "warning" is passed to variant prop', () => { + render(Test); + expect(screen.getByText('Test')).toHaveClass('pf-m-warning'); +}); + +test('Renders with class name pf-m-info when "info" is passed to variant prop', () => { + render(Test); + expect(screen.getByText('Test')).toHaveClass('pf-m-info'); +}); + +test('Renders pf-u-screen-reader class by default for screenReaderText', () => { + render(Test); + expect(screen.getByText('default banner')).toHaveClass('pf-u-screen-reader', { exact: true }); +}); + +test('Renders screenReaderText as "default banner" by default', () => { + render(Test); + expect(screen.getByText('default banner')).toBeInTheDocument(); +}); + +test('Renders screenReaderText as "success banner" when variant="success"', () => { + render(Test); + expect(screen.getByText('success banner')).toBeInTheDocument(); +}); + +test('Renders custom screenReaderText passed via prop', () => { + render(Test); + expect(screen.getByText('Custom screen reader text')).toBeInTheDocument(); +}); + +test('Renders without pf-m-sticky by default', () => { + render(Test); + expect(screen.getByText('Test')).not.toHaveClass('pf-m-sticky'); +}); + +test('Renders with class name pf-m-sticky when isSticky prop is passed', () => { + render(Test); + expect(screen.getByText('Test')).toHaveClass('pf-m-sticky'); +}); + +test('Renders with inherited element props spread to the component', () => { + render(Test); + expect(screen.getByText('Test')).toHaveAccessibleName('Test label'); +}); + +test('Matches the snapshot', () => { + const { asFragment } = render(Test); expect(asFragment()).toMatchSnapshot(); }); diff --git a/packages/react-core/src/components/Banner/__tests__/__snapshots__/Banner.test.tsx.snap b/packages/react-core/src/components/Banner/__tests__/__snapshots__/Banner.test.tsx.snap index b55f80bace6..1d6551bd157 100644 --- a/packages/react-core/src/components/Banner/__tests__/__snapshots__/Banner.test.tsx.snap +++ b/packages/react-core/src/components/Banner/__tests__/__snapshots__/Banner.test.tsx.snap @@ -1,60 +1,11 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`danger banner 1`] = ` +exports[`Matches the snapshot 1`] = `
- danger Banner - - danger banner - -
-
-`; - -exports[`default banner 1`] = ` - -
- default Banner - - default banner - -
-
-`; - -exports[`info banner 1`] = ` - -
- info Banner - - info banner - -
-
-`; - -exports[`sticky banner 1`] = ` - -
- Sticky Banner + Test @@ -63,35 +14,3 @@ exports[`sticky banner 1`] = `
`; - -exports[`success banner 1`] = ` - -
- success Banner - - success banner - -
-
-`; - -exports[`warning banner 1`] = ` - -
- warning Banner - - warning banner - -
-
-`; diff --git a/packages/react-core/src/components/EmptyState/examples/EmptyState.md b/packages/react-core/src/components/EmptyState/examples/EmptyState.md index ead9b43b917..3608e5b3306 100644 --- a/packages/react-core/src/components/EmptyState/examples/EmptyState.md +++ b/packages/react-core/src/components/EmptyState/examples/EmptyState.md @@ -2,7 +2,7 @@ id: Empty state section: components cssPrefix: pf-c-empty-state -propComponents: ['EmptyState', 'EmptyStateBody', 'EmptyStateIcon', 'EmptyStateSecondaryActions'] +propComponents: ['EmptyState', 'EmptyStateBody', 'EmptyStateIcon', 'EmptyStatePrimary','EmptyStateSecondaryActions'] --- import CubesIcon from '@patternfly/react-icons/dist/esm/icons/cubes-icon'; import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon'; @@ -40,5 +40,7 @@ import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon'; ### No match found +`EmptyStatePrimary` is a container for primary actions. It can be used in lieu of using a primary button and will insure appropriate spacing of the buttons. + ```ts file="EmptyStateNoMatchFound.tsx" ``` diff --git a/packages/react-core/src/components/Label/examples/LabelEditable.tsx b/packages/react-core/src/components/Label/examples/LabelEditable.tsx index 6dbc76900b7..5b5e018bbf0 100644 --- a/packages/react-core/src/components/Label/examples/LabelEditable.tsx +++ b/packages/react-core/src/components/Label/examples/LabelEditable.tsx @@ -31,7 +31,7 @@ export const LabelEditable: React.FunctionComponent = () => { onEditComplete={onEditComplete} isEditable editableProps={{ - 'aria-label': 'Editable text', + 'aria-label': `Editable label with text ${labelText}`, id: 'editable-label' }} > @@ -46,7 +46,7 @@ export const LabelEditable: React.FunctionComponent = () => { onEditComplete={onCompactEditComplete} isEditable editableProps={{ - 'aria-label': 'Compact editable text', + 'aria-label': `Editable compact label with text ${compactLabelText}`, id: 'compact-editable-label' }} > diff --git a/packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableAdd.tsx b/packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableAdd.tsx index 377b4d01d37..e89cfa282ed 100644 --- a/packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableAdd.tsx +++ b/packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableAdd.tsx @@ -11,7 +11,7 @@ export const LabelGroupEditableAdd: React.FunctionComponent = () => { props: { isEditable: true, editableProps: { - 'aria-label': 'label editable text' + 'aria-label': 'Editable label with text Label 3' } }, id: 2 @@ -24,7 +24,12 @@ export const LabelGroupEditableAdd: React.FunctionComponent = () => { const onEdit = (nextText: string, index: number) => { const copy = [...labels]; - copy[index] = { name: nextText, props: labels[index].props, id: labels[index].id }; + const updatedProps = { + ...labels[index].props, + editableProps: { 'aria-label': `Editable label with text ${nextText}` } + }; + + copy[index] = { name: nextText, props: updatedProps, id: labels[index].id }; setLabels(copy); }; @@ -35,7 +40,7 @@ export const LabelGroupEditableAdd: React.FunctionComponent = () => { props: { isEditable: true, editableProps: { - 'aria-label': 'label editable text' + 'aria-label': `Editable label with text New Label` } }, id: idIndex diff --git a/packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableAddDropdown.tsx b/packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableAddDropdown.tsx index 0e4fbf286ad..2f6cfe1ecae 100644 --- a/packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableAddDropdown.tsx +++ b/packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableAddDropdown.tsx @@ -16,7 +16,7 @@ export const LabelGroupEditableAddDropdown: React.FunctionComponent = () => { props: { isEditable: true, editableProps: { - 'aria-label': 'label editable text' + 'aria-label': 'Editable label with text Label 3' } }, id: 2 @@ -29,7 +29,12 @@ export const LabelGroupEditableAddDropdown: React.FunctionComponent = () => { const onEdit = (nextText: string, index: number) => { const copy = [...labels]; - copy[index] = { name: nextText, props: labels[index].props, id: labels[index].id }; + const updatedProps = { + ...labels[index].props, + editableProps: { 'aria-label': `Editable label with text ${nextText}` } + }; + + copy[index] = { name: nextText, props: updatedProps, id: labels[index].id }; setLabels(copy); }; diff --git a/packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableAddModal.tsx b/packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableAddModal.tsx index 3a51ecfe8f2..05b5ebfcf8a 100644 --- a/packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableAddModal.tsx +++ b/packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableAddModal.tsx @@ -47,7 +47,7 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => { props: { isEditable: true, editableProps: { - 'aria-label': 'label editable text' + 'aria-label': 'Editable label with text Label 3' } }, id: 6 @@ -60,7 +60,12 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => { const onEdit = (nextText: string, index: number) => { const copy = [...labels]; - copy[index] = { name: nextText, props: labels[index].props, id: labels[index].id }; + const updatedProps = { + ...labels[index].props, + editableProps: { 'aria-label': `Editable label with text ${nextText}` } + }; + + copy[index] = { name: nextText, props: updatedProps, id: labels[index].id }; setLabels(copy); }; @@ -81,7 +86,7 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => { isEditable: isEditable !== undefined ? isEditable : true, ...(isEditable && { editableProps: { - 'aria-label': 'label editable text' + 'aria-label': `Editable label with text ${labelText || 'New Label'}` } }) }, diff --git a/packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableLabels.tsx b/packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableLabels.tsx index c9f59089869..ef65dd3dd92 100644 --- a/packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableLabels.tsx +++ b/packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableLabels.tsx @@ -15,7 +15,7 @@ export const LabelGroupEditableLabels: React.FunctionComponent = () => { onEditComplete={newText => setLabel1(newText)} isEditable editableProps={{ - 'aria-label': 'Editable text', + 'aria-label': `Editable label with text ${label1}`, id: 'editable-label-1' }} > @@ -29,7 +29,7 @@ export const LabelGroupEditableLabels: React.FunctionComponent = () => { onEditComplete={newText => setLabel2(newText)} isEditable editableProps={{ - 'aria-label': 'Editable text 2', + 'aria-label': `Editable label with text ${label2}`, id: 'editable-label-2' }} > @@ -42,7 +42,7 @@ export const LabelGroupEditableLabels: React.FunctionComponent = () => { onEditComplete={newText => setLabel3(newText)} isEditable editableProps={{ - 'aria-label': 'Editable text 3', + 'aria-label': `Editable label with text ${label3}`, id: 'editable-label-3' }} > diff --git a/packages/react-core/src/components/Menu/examples/MenuWithDrilldown.tsx b/packages/react-core/src/components/Menu/examples/MenuWithDrilldown.tsx index 0918400a12a..5825f42c4e9 100644 --- a/packages/react-core/src/components/Menu/examples/MenuWithDrilldown.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuWithDrilldown.tsx @@ -26,7 +26,7 @@ export const MenuWithDrilldown: React.FunctionComponent = () => { }; const setHeight = (menuId: string, height: number) => { - if (menuHeights[menuId] === undefined) { + if (menuHeights[menuId] === undefined || (menuId !== 'drilldown-rootMenu' && menuHeights[menuId] !== height)) { setMenuHeights({ ...menuHeights, [menuId]: height }); } }; diff --git a/packages/react-core/src/components/Menu/examples/MenuWithDrilldownBreadcrumbs.tsx b/packages/react-core/src/components/Menu/examples/MenuWithDrilldownBreadcrumbs.tsx index 61ed5fc80c4..528c33ba9c8 100644 --- a/packages/react-core/src/components/Menu/examples/MenuWithDrilldownBreadcrumbs.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuWithDrilldownBreadcrumbs.tsx @@ -55,11 +55,13 @@ export const MenuWithDrilldownBreadcrumbs: React.FunctionComponent = () => { setDrilldownPath(pathSansLast); setActiveMenu(toMenuId); }; + const setHeight = (menuId: string, height: number) => { - if (!menuHeights[menuId]) { + if (menuHeights[menuId] === undefined || (menuId !== 'breadcrumbs-rootMenu' && menuHeights[menuId] !== height)) { setMenuHeights({ ...menuHeights, [menuId]: height }); } }; + const drillIn = (fromMenuId: string, toMenuId: string, pathId: string) => { setMenuDrilledIn([...menuDrilledIn, fromMenuId]); setDrilldownPath([...drilldownPath, pathId]); diff --git a/packages/react-core/src/components/Menu/examples/MenuWithDrilldownSubmenuFunctions.tsx b/packages/react-core/src/components/Menu/examples/MenuWithDrilldownSubmenuFunctions.tsx index 9629b890d2a..54ba1a0fb6b 100644 --- a/packages/react-core/src/components/Menu/examples/MenuWithDrilldownSubmenuFunctions.tsx +++ b/packages/react-core/src/components/Menu/examples/MenuWithDrilldownSubmenuFunctions.tsx @@ -26,7 +26,7 @@ export const MenuWithDrilldownSubmenuFunctions: React.FunctionComponent = () => }; const setHeight = (menuId: string, height: number) => { - if (menuHeights[menuId] === undefined) { + if (menuHeights[menuId] === undefined || (menuId !== 'functions-rootMenu' && menuHeights[menuId] !== height)) { setMenuHeights({ ...menuHeights, [menuId]: height }); } }; diff --git a/packages/react-core/src/components/Select/Select.tsx b/packages/react-core/src/components/Select/Select.tsx index 0b5c17a9068..a4962d75a35 100644 --- a/packages/react-core/src/components/Select/Select.tsx +++ b/packages/react-core/src/components/Select/Select.tsx @@ -69,6 +69,8 @@ export interface SelectProps isDisabled?: boolean; /** Flag to indicate if the typeahead select allows new items */ isCreatable?: boolean; + /** Flag to indicate if create option should be at top of typeahead */ + isCreateOptionOnTop?: boolean; /** Flag indicating if placeholder styles should be applied */ hasPlaceholderStyle?: boolean; /** @beta Flag indicating if the creatable option should set its value as a SelectOptionObject */ @@ -226,6 +228,7 @@ export class Select extends React.Component ); + + if (isCreateOptionOnTop) { + typeaheadFilteredChildren.unshift(createSelectOption); + } else { + typeaheadFilteredChildren.push(createSelectOption); + } } } @@ -1020,6 +1030,7 @@ export class Select extends React.Component { + const user = userEvent.setup(); + + render( + + ); + + const input = screen.getByRole('textbox'); + await user.type(input, `m`); + + const createOption = screen.getAllByRole('option')[3]; + expect(createOption).toHaveTextContent('Create "m"'); +}); + +test('prepends create option to list of options if isCreateOptionOnTop flag is set', async () => { + const user = userEvent.setup(); + + render( + + ); + + const input = screen.getByRole('textbox'); + await user.type(input, `m`); + + const createOption = screen.getAllByRole('option')[0]; + expect(createOption).toHaveTextContent('Create "m"'); +}); \ No newline at end of file diff --git a/packages/react-core/src/components/Select/examples/Select.md b/packages/react-core/src/components/Select/examples/Select.md index dd1a871dff0..628fcf0a5f5 100644 --- a/packages/react-core/src/components/Select/examples/Select.md +++ b/packages/react-core/src/components/Select/examples/Select.md @@ -1209,6 +1209,7 @@ class TypeaheadSelectInput extends React.Component { selected: null, isDisabled: false, isCreatable: false, + isCreateOptionOnTop: false, isInputValuePersisted: false, isInputFilterPersisted: false, hasOnCreateOption: false, @@ -1258,6 +1259,12 @@ class TypeaheadSelectInput extends React.Component { }); }; + this.toggleCreateOptionOnTop = checked => { + this.setState({ + isCreateOptionOnTop: checked + }); + }; + this.toggleCreateNew = checked => { this.setState({ hasOnCreateOption: checked @@ -1289,6 +1296,7 @@ class TypeaheadSelectInput extends React.Component { selected, isDisabled, isCreatable, + isCreateOptionOnTop, hasOnCreateOption, isInputValuePersisted, isInputFilterPersisted, @@ -1315,6 +1323,7 @@ class TypeaheadSelectInput extends React.Component { placeholderText="Select a state" isDisabled={isDisabled} isCreatable={isCreatable} + isCreateOptionOnTop={isCreateOptionOnTop} onCreateOption={(hasOnCreateOption && this.onCreateOption) || undefined} shouldResetOnSelect={resetOnSelect} > @@ -1343,6 +1352,14 @@ class TypeaheadSelectInput extends React.Component { id="toggle-creatable-typeahead" name="toggle-creatable-typeahead" /> + - - Sidebar panel - - -

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse dapibus nulla id augue dictum commodo. Donec mollis arcu massa, sollicitudin venenatis est rutrum vitae. Integer pulvinar ligula at augue mollis, ac pulvinar arcu semper. Maecenas nisi lorem, malesuada ac lectus nec, porta pretium neque. Ut convallis libero sit amet metus mattis, vel facilisis lorem malesuada. Duis consectetur ante sit amet magna efficitur, a interdum leo vulputate.

-

Praesent at odio nec sapien ultrices tincidunt in non mauris. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Duis consectetur nisl quis facilisis faucibus. Sed eu bibendum risus. Suspendisse porta euismod tortor, at elementum odio suscipit sed. Cras eget ultrices urna, ac feugiat lectus. Integer a pharetra velit, in imperdiet mi. Phasellus vel hendrerit velit. Vestibulum ut augue vitae erat vulputate bibendum a ut magna.

-
- +```ts file="./SidebarBasic.tsx" ``` ### Stack -```js -import React from 'react'; -import { Sidebar, SidebarContent, SidebarPanel } from '@patternfly/react-core'; - - - - Sidebar panel stacked on top - - -

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse dapibus nulla id augue dictum commodo. Donec mollis arcu massa, sollicitudin venenatis est rutrum vitae. Integer pulvinar ligula at augue mollis, ac pulvinar arcu semper. Maecenas nisi lorem, malesuada ac lectus nec, porta pretium neque. Ut convallis libero sit amet metus mattis, vel facilisis lorem malesuada. Duis consectetur ante sit amet magna efficitur, a interdum leo vulputate.

-

Praesent at odio nec sapien ultrices tincidunt in non mauris. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Duis consectetur nisl quis facilisis faucibus. Sed eu bibendum risus. Suspendisse porta euismod tortor, at elementum odio suscipit sed. Cras eget ultrices urna, ac feugiat lectus. Integer a pharetra velit, in imperdiet mi. Phasellus vel hendrerit velit. Vestibulum ut augue vitae erat vulputate bibendum a ut magna.

-
-
+```ts file="./SidebarStack.tsx" ``` ### Panel right with gutter -```js -import React from 'react'; -import { Sidebar, SidebarContent, SidebarPanel } from '@patternfly/react-core'; - - - - Sidebar panel on the right - - -

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse dapibus nulla id augue dictum commodo. Donec mollis arcu massa, sollicitudin venenatis est rutrum vitae. Integer pulvinar ligula at augue mollis, ac pulvinar arcu semper. Maecenas nisi lorem, malesuada ac lectus nec, porta pretium neque. Ut convallis libero sit amet metus mattis, vel facilisis lorem malesuada. Duis consectetur ante sit amet magna efficitur, a interdum leo vulputate.

-

Praesent at odio nec sapien ultrices tincidunt in non mauris. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Duis consectetur nisl quis facilisis faucibus. Sed eu bibendum risus. Suspendisse porta euismod tortor, at elementum odio suscipit sed. Cras eget ultrices urna, ac feugiat lectus. Integer a pharetra velit, in imperdiet mi. Phasellus vel hendrerit velit. Vestibulum ut augue vitae erat vulputate bibendum a ut magna.

-
-
+```ts file="./SidebarPanelRightGutter.tsx" ``` ### Sticky panel A `tabIndex` should be added to the `Sidebar` when there is scrollable content in order for the overflow content to be accessible by keyboard. -```js -import React from 'react'; -import { Sidebar, SidebarContent, SidebarPanel } from '@patternfly/react-core'; - - - - Sticky sidebar panel - - -

Scroll me!

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse dapibus nulla id augue dictum commodo. Donec mollis arcu massa, sollicitudin venenatis est rutrum vitae. Integer pulvinar ligula at augue mollis, ac pulvinar arcu semper. Maecenas nisi lorem, malesuada ac lectus nec, porta pretium neque. Ut convallis libero sit amet metus mattis, vel facilisis lorem malesuada. Duis consectetur ante sit amet magna efficitur, a interdum leo vulputate.

-

Praesent at odio nec sapien ultrices tincidunt in non mauris. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Duis consectetur nisl quis facilisis faucibus. Sed eu bibendum risus. Suspendisse porta euismod tortor, at elementum odio suscipit sed. Cras eget ultrices urna, ac feugiat lectus. Integer a pharetra velit, in imperdiet mi. Phasellus vel hendrerit velit. Vestibulum ut augue vitae erat vulputate bibendum a ut magna.

-
-
+```ts file="./SidebarStickyPanel.tsx" ``` ### Static panel A `tabIndex` should be added to the `Sidebar` when there is scrollable content in order for the overflow content to be accessible by keyboard. -```js -import React from 'react'; -import { Sidebar, SidebarContent, SidebarPanel } from '@patternfly/react-core'; - - - - Static sidebar panel - - -

Scroll me!

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse dapibus nulla id augue dictum commodo. Donec mollis arcu massa, sollicitudin venenatis est rutrum vitae. Integer pulvinar ligula at augue mollis, ac pulvinar arcu semper. Maecenas nisi lorem, malesuada ac lectus nec, porta pretium neque. Ut convallis libero sit amet metus mattis, vel facilisis lorem malesuada. Duis consectetur ante sit amet magna efficitur, a interdum leo vulputate.

-

Praesent at odio nec sapien ultrices tincidunt in non mauris. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Duis consectetur nisl quis facilisis faucibus. Sed eu bibendum risus. Suspendisse porta euismod tortor, at elementum odio suscipit sed. Cras eget ultrices urna, ac feugiat lectus. Integer a pharetra velit, in imperdiet mi. Phasellus vel hendrerit velit. Vestibulum ut augue vitae erat vulputate bibendum a ut magna.

-
-
+```ts file="./SidebarStaticPanel.tsx" ``` ### Responsive panel width A `tabIndex` should be added to the `Sidebar` when there is scrollable content in order for the overflow content to be accessible by keyboard. -```js -import React from 'react'; -import { Sidebar, SidebarContent, SidebarPanel } from '@patternfly/react-core'; - - - - Sidebar panel - - -

Resize me!

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse dapibus nulla id augue dictum commodo. Donec mollis arcu massa, sollicitudin venenatis est rutrum vitae. Integer pulvinar ligula at augue mollis, ac pulvinar arcu semper. Maecenas nisi lorem, malesuada ac lectus nec, porta pretium neque. Ut convallis libero sit amet metus mattis, vel facilisis lorem malesuada. Duis consectetur ante sit amet magna efficitur, a interdum leo vulputate.

-

Praesent at odio nec sapien ultrices tincidunt in non mauris. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Duis consectetur nisl quis facilisis faucibus. Sed eu bibendum risus. Suspendisse porta euismod tortor, at elementum odio suscipit sed. Cras eget ultrices urna, ac feugiat lectus. Integer a pharetra velit, in imperdiet mi. Phasellus vel hendrerit velit. Vestibulum ut augue vitae erat vulputate bibendum a ut magna.

-
-
+```ts file="./SidebarResponsivePanel.tsx" ``` - - diff --git a/packages/react-core/src/components/Sidebar/examples/SidebarBasic.tsx b/packages/react-core/src/components/Sidebar/examples/SidebarBasic.tsx new file mode 100644 index 00000000000..4f1dd5477cd --- /dev/null +++ b/packages/react-core/src/components/Sidebar/examples/SidebarBasic.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import { Sidebar, SidebarContent, SidebarPanel } from '@patternfly/react-core'; + +export const SidebarBasic: React.FunctionComponent = () => ( + + Sidebar panel + +

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse dapibus nulla id augue dictum commodo. + Donec mollis arcu massa, sollicitudin venenatis est rutrum vitae. Integer pulvinar ligula at augue mollis, ac + pulvinar arcu semper. Maecenas nisi lorem, malesuada ac lectus nec, porta pretium neque. Ut convallis libero sit + amet metus mattis, vel facilisis lorem malesuada. Duis consectetur ante sit amet magna efficitur, a interdum leo + vulputate. +

+

+ Praesent at odio nec sapien ultrices tincidunt in non mauris. Orci varius natoque penatibus et magnis dis + parturient montes, nascetur ridiculus mus. Duis consectetur nisl quis facilisis faucibus. Sed eu bibendum risus. + Suspendisse porta euismod tortor, at elementum odio suscipit sed. Cras eget ultrices urna, ac feugiat lectus. + Integer a pharetra velit, in imperdiet mi. Phasellus vel hendrerit velit. Vestibulum ut augue vitae erat + vulputate bibendum a ut magna. +

+
+
+); diff --git a/packages/react-core/src/components/Sidebar/examples/SidebarPanelRightGutter.tsx b/packages/react-core/src/components/Sidebar/examples/SidebarPanelRightGutter.tsx new file mode 100644 index 00000000000..d7036a6ab2c --- /dev/null +++ b/packages/react-core/src/components/Sidebar/examples/SidebarPanelRightGutter.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import { Sidebar, SidebarContent, SidebarPanel } from '@patternfly/react-core'; + +export const SidebarPanelRightGutter: React.FunctionComponent = () => ( + + Sidebar panel on the right + +

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse dapibus nulla id augue dictum commodo. + Donec mollis arcu massa, sollicitudin venenatis est rutrum vitae. Integer pulvinar ligula at augue mollis, ac + pulvinar arcu semper. Maecenas nisi lorem, malesuada ac lectus nec, porta pretium neque. Ut convallis libero sit + amet metus mattis, vel facilisis lorem malesuada. Duis consectetur ante sit amet magna efficitur, a interdum leo + vulputate. +

+

+ Praesent at odio nec sapien ultrices tincidunt in non mauris. Orci varius natoque penatibus et magnis dis + parturient montes, nascetur ridiculus mus. Duis consectetur nisl quis facilisis faucibus. Sed eu bibendum risus. + Suspendisse porta euismod tortor, at elementum odio suscipit sed. Cras eget ultrices urna, ac feugiat lectus. + Integer a pharetra velit, in imperdiet mi. Phasellus vel hendrerit velit. Vestibulum ut augue vitae erat + vulputate bibendum a ut magna. +

+
+
+); diff --git a/packages/react-core/src/components/Sidebar/examples/SidebarResponsivePanel.tsx b/packages/react-core/src/components/Sidebar/examples/SidebarResponsivePanel.tsx new file mode 100644 index 00000000000..1030d8564b0 --- /dev/null +++ b/packages/react-core/src/components/Sidebar/examples/SidebarResponsivePanel.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { Sidebar, SidebarContent, SidebarPanel } from '@patternfly/react-core'; + +export const SidebarResponsivePanel: React.FunctionComponent = () => ( + + Sidebar panel + +

Resize me!

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse dapibus nulla id augue dictum commodo. + Donec mollis arcu massa, sollicitudin venenatis est rutrum vitae. Integer pulvinar ligula at augue mollis, ac + pulvinar arcu semper. Maecenas nisi lorem, malesuada ac lectus nec, porta pretium neque. Ut convallis libero sit + amet metus mattis, vel facilisis lorem malesuada. Duis consectetur ante sit amet magna efficitur, a interdum leo + vulputate. +

+

+ Praesent at odio nec sapien ultrices tincidunt in non mauris. Orci varius natoque penatibus et magnis dis + parturient montes, nascetur ridiculus mus. Duis consectetur nisl quis facilisis faucibus. Sed eu bibendum risus. + Suspendisse porta euismod tortor, at elementum odio suscipit sed. Cras eget ultrices urna, ac feugiat lectus. + Integer a pharetra velit, in imperdiet mi. Phasellus vel hendrerit velit. Vestibulum ut augue vitae erat + vulputate bibendum a ut magna. +

+
+
+); diff --git a/packages/react-core/src/components/Sidebar/examples/SidebarStack.tsx b/packages/react-core/src/components/Sidebar/examples/SidebarStack.tsx new file mode 100644 index 00000000000..9a6ddfa6e10 --- /dev/null +++ b/packages/react-core/src/components/Sidebar/examples/SidebarStack.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import { Sidebar, SidebarContent, SidebarPanel } from '@patternfly/react-core'; + +export const SidebarStack: React.FunctionComponent = () => ( + + Sidebar panel stacked on top + +

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse dapibus nulla id augue dictum commodo. + Donec mollis arcu massa, sollicitudin venenatis est rutrum vitae. Integer pulvinar ligula at augue mollis, ac + pulvinar arcu semper. Maecenas nisi lorem, malesuada ac lectus nec, porta pretium neque. Ut convallis libero sit + amet metus mattis, vel facilisis lorem malesuada. Duis consectetur ante sit amet magna efficitur, a interdum leo + vulputate. +

+

+ Praesent at odio nec sapien ultrices tincidunt in non mauris. Orci varius natoque penatibus et magnis dis + parturient montes, nascetur ridiculus mus. Duis consectetur nisl quis facilisis faucibus. Sed eu bibendum risus. + Suspendisse porta euismod tortor, at elementum odio suscipit sed. Cras eget ultrices urna, ac feugiat lectus. + Integer a pharetra velit, in imperdiet mi. Phasellus vel hendrerit velit. Vestibulum ut augue vitae erat + vulputate bibendum a ut magna. +

+
+
+); diff --git a/packages/react-core/src/components/Sidebar/examples/SidebarStaticPanel.tsx b/packages/react-core/src/components/Sidebar/examples/SidebarStaticPanel.tsx new file mode 100644 index 00000000000..202af282e76 --- /dev/null +++ b/packages/react-core/src/components/Sidebar/examples/SidebarStaticPanel.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { Sidebar, SidebarContent, SidebarPanel } from '@patternfly/react-core'; + +export const SidebarStaticPanel: React.FunctionComponent = () => ( + + Static sidebar panel + +

Scroll me!

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse dapibus nulla id augue dictum commodo. + Donec mollis arcu massa, sollicitudin venenatis est rutrum vitae. Integer pulvinar ligula at augue mollis, ac + pulvinar arcu semper. Maecenas nisi lorem, malesuada ac lectus nec, porta pretium neque. Ut convallis libero sit + amet metus mattis, vel facilisis lorem malesuada. Duis consectetur ante sit amet magna efficitur, a interdum leo + vulputate. +

+

+ Praesent at odio nec sapien ultrices tincidunt in non mauris. Orci varius natoque penatibus et magnis dis + parturient montes, nascetur ridiculus mus. Duis consectetur nisl quis facilisis faucibus. Sed eu bibendum risus. + Suspendisse porta euismod tortor, at elementum odio suscipit sed. Cras eget ultrices urna, ac feugiat lectus. + Integer a pharetra velit, in imperdiet mi. Phasellus vel hendrerit velit. Vestibulum ut augue vitae erat + vulputate bibendum a ut magna. +

+
+
+); diff --git a/packages/react-core/src/components/Sidebar/examples/SidebarStickyPanel.tsx b/packages/react-core/src/components/Sidebar/examples/SidebarStickyPanel.tsx new file mode 100644 index 00000000000..a6f4b5e24fd --- /dev/null +++ b/packages/react-core/src/components/Sidebar/examples/SidebarStickyPanel.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { Sidebar, SidebarContent, SidebarPanel } from '@patternfly/react-core'; + +export const SidebarStickyPanel: React.FunctionComponent = () => ( + + Sticky sidebar panel + +

Scroll me!

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse dapibus nulla id augue dictum commodo. + Donec mollis arcu massa, sollicitudin venenatis est rutrum vitae. Integer pulvinar ligula at augue mollis, ac + pulvinar arcu semper. Maecenas nisi lorem, malesuada ac lectus nec, porta pretium neque. Ut convallis libero sit + amet metus mattis, vel facilisis lorem malesuada. Duis consectetur ante sit amet magna efficitur, a interdum leo + vulputate. +

+

+ Praesent at odio nec sapien ultrices tincidunt in non mauris. Orci varius natoque penatibus et magnis dis + parturient montes, nascetur ridiculus mus. Duis consectetur nisl quis facilisis faucibus. Sed eu bibendum risus. + Suspendisse porta euismod tortor, at elementum odio suscipit sed. Cras eget ultrices urna, ac feugiat lectus. + Integer a pharetra velit, in imperdiet mi. Phasellus vel hendrerit velit. Vestibulum ut augue vitae erat + vulputate bibendum a ut magna. +

+
+
+); diff --git a/packages/react-core/src/components/SkipToContent/examples/SkipToContent.md b/packages/react-core/src/components/SkipToContent/examples/SkipToContent.md index 49252f8fbe0..a212e1587e5 100644 --- a/packages/react-core/src/components/SkipToContent/examples/SkipToContent.md +++ b/packages/react-core/src/components/SkipToContent/examples/SkipToContent.md @@ -7,107 +7,5 @@ propComponents: ['SkipToContent'] ## Examples ### Basic -```js isFullscreen -import React from 'react'; -import { SkipToContent } from '@patternfly/react-core'; - -class SimpleSkipToContent extends React.Component { - render() { - return ( - - Skip to content -

Press tab to skip to content at the bottom of the page.

-
-

Main content

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla accumsan, metus ultrices eleifend gravida, nulla nunc varius - lectus, nec rutrum justo nibh eu lectus. Ut vulputate semper dui. Fusce erat odio, sollicitudin vel erat vel, interdum - mattis neque. Sub works as well!

-

Second level

-

Curabitur accumsan turpis pharetra - augue tincidunt blandit. Quisque condimentum maximus mi, sit amet commodo arcu rutrum id. Proin pretium urna vel - cursus venenatis. Suspendisse potenti. Etiam mattis sem rhoncus lacus dapibus facilisis. Donec at dignissim dui. Ut et - neque nisl.

-
    -
  • In fermentum leo eu lectus mollis, quis dictum mi aliquet.
  • -
  • Morbi eu nulla lobortis, lobortis est in, fringilla felis.
  • -
  • Aliquam nec felis in sapien venenatis viverra fermentum nec lectus. -
      -
    • In fermentum leo eu lectus mollis, quis dictum mi aliquet.
    • -
    • Morbi eu nulla lobortis, lobortis est in, fringilla felis.
    • -
    • Ut venenatis, nisl scelerisque. -
        -
      1. Donec blandit a lorem id convallis.
      2. -
      3. Cras gravida arcu at diam gravida gravida.
      4. -
      5. Integer in volutpat libero.
      6. -
      -
    • -
    -
  • -
  • Ut non enim metus.
  • -
-

Third level

-

Quisque ante lacus, malesuada ac auctor vitae, congue - non ante. Phasellus lacus ex, semper ac tortor nec, fringilla condimentum orci. Fusce eu rutrum tellus.

-
    -
  1. Donec blandit a lorem id convallis.
  2. -
  3. Cras gravida arcu at diam gravida gravida.
  4. -
  5. Integer in volutpat libero.
  6. -
  7. Donec a diam tellus.
  8. -
  9. Etiam auctor nisl et. -
      -
    • Donec blandit a lorem id convallis.
    • -
    • Cras gravida arcu at diam gravida gravida.
    • -
    • Integer in volutpat libero. -
        -
      1. Donec blandit a lorem id convallis.
      2. -
      3. Cras gravida arcu at diam gravida gravida.
      4. -
      -
    • -
    -
  10. -
  11. Aenean nec tortor orci.
  12. -
  13. Quisque aliquam cursus urna, non bibendum massa viverra eget.
  14. -
  15. Vivamus maximus ultricies pulvinar.
  16. -
-
Ut venenatis, nisl scelerisque sollicitudin fermentum, quam libero hendrerit ipsum, ut blandit est tellus sit amet turpis.
-

Quisque at semper enim, eu hendrerit odio. Etiam auctor nisl et - justo sodales elementum. Maecenas ultrices lacus quis neque consectetur, et lobortis nisi molestie.

-
-

Sed sagittis enim ac tortor maximus rutrum. Nulla facilisi. Donec mattis vulputate risus in luctus. Maecenas vestibulum interdum - commodo. -

-
-
Web
-
The part of the internet that contains websites and web pages
-
HTML
-
A markup language for creating web pages
-
CSS
-
A technology to make HTML look better
-
-

Suspendisse egestas sapien non felis placerat elementum. Morbi tortor nisl, suscipit sed mi sit amet, mollis malesuada nulla. - Nulla facilisi. Nullam ac erat ante.

-

Fourth level

-

Nulla efficitur eleifend nisi, sit amet bibendum sapien fringilla ac. Mauris euismod metus a tellus laoreet, at elementum - ex efficitur.

-

Maecenas eleifend sollicitudin dui, faucibus sollicitudin augue cursus non. Ut finibus eleifend arcu ut vehicula. Mauris - eu est maximus est porta condimentum in eu justo. Nulla id iaculis sapien.

- Sometimes you need small text to display things like date created -

Phasellus porttitor enim id metus volutpat ultricies. Ut nisi nunc, blandit sed dapibus at, vestibulum in felis. Etiam iaculis - lorem ac nibh bibendum rhoncus. Nam interdum efficitur ligula sit amet ullamcorper. Etiam tristique, leo vitae porta faucibus, - mi lacus laoreet metus, at cursus leo est vel tellus. Sed ac posuere est. Nunc ultricies nunc neque, vitae ultricies ex - sodales quis. Aliquam eu nibh in libero accumsan pulvinar. Nullam nec nisl placerat, pretium metus vel, euismod ipsum. - Proin tempor cursus nisl vel condimentum. Nam pharetra varius metus non pellentesque.

-
Fifth level
-

Aliquam sagittis rhoncus vulputate. Cras non luctus sem, sed tincidunt ligula. Vestibulum at nunc elit. Praesent aliquet - ligula mi, in luctus elit volutpat porta. Phasellus molestie diam vel nisi sodales, a eleifend augue laoreet. Sed nec eleifend - justo. Nam et sollicitudin odio.

-
Sixth level
-

Cras in nibh lacinia, venenatis nisi et, auctor urna. Donec pulvinar lacus sed diam dignissim, ut eleifend eros accumsan. - Phasellus non tortor eros. Ut sed rutrum lacus. Etiam purus nunc, scelerisque quis enim vitae, malesuada ultrices turpis. - Nunc vitae maximus purus, nec consectetur dui. Suspendisse euismod, elit vel rutrum commodo, ipsum tortor maximus dui, - sed varius sapien odio vitae est. Etiam at cursus metus.

-
- ); - } -} +```ts isFullscreen file="./SkipToContentBasic.tsx" ``` diff --git a/packages/react-core/src/components/SkipToContent/examples/SkipToContentBasic.tsx b/packages/react-core/src/components/SkipToContent/examples/SkipToContentBasic.tsx new file mode 100644 index 00000000000..7c1b79a846e --- /dev/null +++ b/packages/react-core/src/components/SkipToContent/examples/SkipToContentBasic.tsx @@ -0,0 +1,128 @@ +import React from 'react'; +import { SkipToContent } from '@patternfly/react-core'; + +export const SkipToContentBasic: React.FunctionComponent = () => ( + + Skip to content +

Press tab to skip to content at the bottom of the page.

+
+

Main content

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla accumsan, metus ultrices eleifend gravida, nulla + nunc varius lectus, nec rutrum justo nibh eu lectus. Ut vulputate semper dui. Fusce erat odio, sollicitudin vel + erat vel, interdum mattis neque. Sub works as well! +

+

Second level

+

+ Curabitur accumsan turpis pharetra + augue tincidunt blandit. Quisque condimentum maximus mi, sit amet commodo arcu rutrum id. Proin + pretium urna vel cursus venenatis. Suspendisse potenti. Etiam mattis sem rhoncus lacus dapibus facilisis. Donec at + dignissim dui. Ut et neque nisl. +

+
    +
  • In fermentum leo eu lectus mollis, quis dictum mi aliquet.
  • +
  • Morbi eu nulla lobortis, lobortis est in, fringilla felis.
  • +
  • + Aliquam nec felis in sapien venenatis viverra fermentum nec lectus. +
      +
    • In fermentum leo eu lectus mollis, quis dictum mi aliquet.
    • +
    • Morbi eu nulla lobortis, lobortis est in, fringilla felis.
    • +
    • + Ut venenatis, nisl scelerisque. +
        +
      1. Donec blandit a lorem id convallis.
      2. +
      3. Cras gravida arcu at diam gravida gravida.
      4. +
      5. Integer in volutpat libero.
      6. +
      +
    • +
    +
  • +
  • Ut non enim metus.
  • +
+

Third level

+

+ Quisque ante lacus, malesuada ac auctor vitae, congue + non ante. Phasellus lacus ex, semper ac tortor nec, fringilla condimentum orci. Fusce eu rutrum + tellus. +

+
    +
  1. Donec blandit a lorem id convallis.
  2. +
  3. Cras gravida arcu at diam gravida gravida.
  4. +
  5. Integer in volutpat libero.
  6. +
  7. Donec a diam tellus.
  8. +
  9. + Etiam auctor nisl et. +
      +
    • Donec blandit a lorem id convallis.
    • +
    • Cras gravida arcu at diam gravida gravida.
    • +
    • + Integer in volutpat libero. +
        +
      1. Donec blandit a lorem id convallis.
      2. +
      3. Cras gravida arcu at diam gravida gravida.
      4. +
      +
    • +
    +
  10. +
  11. Aenean nec tortor orci.
  12. +
  13. Quisque aliquam cursus urna, non bibendum massa viverra eget.
  14. +
  15. Vivamus maximus ultricies pulvinar.
  16. +
+
+ Ut venenatis, nisl scelerisque sollicitudin fermentum, quam libero hendrerit ipsum, ut blandit est tellus sit amet + turpis. +
+

+ Quisque at semper enim, eu hendrerit odio. Etiam auctor nisl et + justo sodales elementum. Maecenas ultrices lacus quis neque consectetur, et lobortis nisi molestie. +

+
+

+ Sed sagittis enim ac tortor maximus rutrum. Nulla facilisi. Donec mattis vulputate risus in luctus. Maecenas + vestibulum interdum commodo. +

+
+
Web
+
The part of the internet that contains websites and web pages
+
HTML
+
A markup language for creating web pages
+
CSS
+
A technology to make HTML look better
+
+

+ Suspendisse egestas sapien non felis placerat elementum. Morbi tortor nisl, suscipit sed mi sit amet, mollis + malesuada nulla. Nulla facilisi. Nullam ac erat ante. +

+

Fourth level

+

+ Nulla efficitur eleifend nisi, sit amet bibendum sapien fringilla ac. Mauris euismod metus a tellus laoreet, at + elementum ex efficitur. +

+

+ Maecenas eleifend sollicitudin dui, faucibus sollicitudin augue cursus non. Ut finibus eleifend arcu ut vehicula. + Mauris eu est maximus est porta condimentum in eu justo. Nulla id iaculis sapien. +

+ Sometimes you need small text to display things like date created +

+ Phasellus porttitor enim id metus volutpat ultricies. Ut nisi nunc, blandit sed dapibus at, vestibulum in felis. + Etiam iaculis lorem ac nibh bibendum rhoncus. Nam interdum efficitur ligula sit amet ullamcorper. Etiam tristique, + leo vitae porta faucibus, mi lacus laoreet metus, at cursus leo est vel tellus. Sed ac posuere est. Nunc ultricies + nunc neque, vitae ultricies ex sodales quis. Aliquam eu nibh in libero accumsan pulvinar. Nullam nec nisl + placerat, pretium metus vel, euismod ipsum. Proin tempor cursus nisl vel condimentum. Nam pharetra varius metus + non pellentesque. +

+
Fifth level
+

+ Aliquam sagittis rhoncus vulputate. Cras non luctus sem, sed tincidunt ligula. Vestibulum at nunc elit. Praesent + aliquet ligula mi, in luctus elit volutpat porta. Phasellus molestie diam vel nisi sodales, a eleifend augue + laoreet. Sed nec eleifend justo. Nam et sollicitudin odio. +

+
Sixth level
+

+ Cras in nibh lacinia, venenatis nisi et, auctor urna. Donec pulvinar lacus sed diam dignissim, ut eleifend eros + accumsan. Phasellus non tortor eros. Ut sed rutrum lacus. Etiam purus nunc, scelerisque quis enim vitae, malesuada + ultrices turpis. Nunc vitae maximus purus, nec consectetur dui. Suspendisse euismod, elit vel rutrum commodo, + ipsum tortor maximus dui, sed varius sapien odio vitae est. Etiam at cursus metus. +

+
+); diff --git a/packages/react-core/src/components/Slider/Slider.tsx b/packages/react-core/src/components/Slider/Slider.tsx index ff0e97f8787..1c78edf5335 100644 --- a/packages/react-core/src/components/Slider/Slider.tsx +++ b/packages/react-core/src/components/Slider/Slider.tsx @@ -416,6 +416,9 @@ export const Slider: React.FunctionComponent = ({ {buildSteps()} )} + {isInputVisible && inputPosition === 'aboveThumb' && ( +
{displayInput()}
+ )} {hasTooltipOverThumb ? ( {thumbComponent} @@ -423,9 +426,6 @@ export const Slider: React.FunctionComponent = ({ ) : ( thumbComponent )} - {isInputVisible && inputPosition === 'aboveThumb' && ( -
{displayInput()}
- )} {isInputVisible && inputPosition === 'right' &&
{displayInput()}
} {rightActions &&
{rightActions}
} diff --git a/packages/react-core/src/components/Slider/_tests_/__snapshots__/Slider.test.tsx.snap b/packages/react-core/src/components/Slider/_tests_/__snapshots__/Slider.test.tsx.snap index 92bb864cc01..ee3e42150d9 100644 --- a/packages/react-core/src/components/Slider/_tests_/__snapshots__/Slider.test.tsx.snap +++ b/packages/react-core/src/components/Slider/_tests_/__snapshots__/Slider.test.tsx.snap @@ -475,17 +475,6 @@ exports[`slider renders slider with input above thumb 1`] = ` -
@@ -509,6 +498,17 @@ exports[`slider renders slider with input above thumb 1`] = `
+
diff --git a/packages/react-core/src/components/TextInput/examples/TextInput.md b/packages/react-core/src/components/TextInput/examples/TextInput.md index 8618439b399..6702d09ce38 100644 --- a/packages/react-core/src/components/TextInput/examples/TextInput.md +++ b/packages/react-core/src/components/TextInput/examples/TextInput.md @@ -9,265 +9,42 @@ propComponents: ['TextInput'] ### Basic -```js -import React from 'react'; -import { TextInput } from '@patternfly/react-core'; - -class SimpleTextInput extends React.Component { - constructor(props) { - super(props); - this.state = { - value: '' - }; - this.handleTextInputChange = value => { - this.setState({ value }); - }; - } - - render() { - const { value } = this.state; - - return ( - - ); - } -} +```ts file="./TextInputBasic.tsx" ``` ### Disabled -```js -import React from 'react'; -import { TextInput } from '@patternfly/react-core'; - -; +```ts file="./TextInputDisabled.tsx" ``` ### Truncated on Left -```js -import React from 'react'; -import { TextInput } from '@patternfly/react-core'; - -class LeftTruncatedTextInput extends React.Component { - -constructor(props) { - super(props); - this.state = { - value: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' - }; - this.handleTextInputChange = value => { - this.setState({ value }); - }; - } - - render() { - const { value } = this.state; - return ( - - ); - } -} +```ts file="./TextInputLeftTruncated.tsx" ``` ### Read only -```js -import React from 'react'; -import { Checkbox, TextInput } from '@patternfly/react-core'; - -const ReadOnlyTextArea = () => { - const [isPlainChecked, setIsPlainChecked] = React.useState(false); - - return ( - -
- setIsPlainChecked(checked)} - /> -
- -
- ); -}; +```ts file="./TextInputReadOnly.tsx" ``` ### Invalid -```js -import React from 'react'; -import { TextInput, ValidatedOptions } from '@patternfly/react-core'; - -class InvalidTextInput extends React.Component { - constructor(props) { - super(props); - this.state = { - value: '' - }; - this.handleInvalidTextInputChange = value => { - this.setState({ value }); - }; - } - - render() { - const { value } = this.state; - - return ( - - ); - } -} +```ts file="./TextInputInvalid.tsx" ``` ### Select text using ref -```js -import React from 'react'; -import { TextInput } from '@patternfly/react-core'; - -TextInputSelectAll = () => { - const [value, setValue] = React.useState('select all on click'); - const ref = React.useRef(null); - return ( - ref && ref.current && ref.current.select()} - onChange={value => setValue(value)} - aria-label="select-all" - /> - ); -}; +```ts file="./TextInputSelectUsingRef.tsx" ``` ### Icon variants -```js -import React from 'react'; -import { TextInput } from '@patternfly/react-core'; - -SimpleTextInput = () => { - const [calendar, setCalendar] = React.useState(''); - const [clock, setClock] = React.useState(''); - const [custom, setCustom] = React.useState(''); - - return ( - <> - setCalendar(value)} - aria-label="text input example" - /> -
-
- setClock(value)} - aria-label="text input example" - /> -
-
- setCustom(value)} - aria-label="text input example" - /> - - ); -}; +```ts file="./TextInputIcon.tsx" ``` ### Icon sprite variants **Note:** The icons for the success, invalid, calendar, etc. variations in form control elements are applied as background images to the form element. By default, the image URLs for these icons are data URIs. However, there may be cases where data URIs are not ideal, such as in an application with a content security policy that disallows data URIs for security reasons. The `isIconSprite` variation changes the icon source to an external SVG file that serves as a sprite for all of the supported icons. -```js isBeta -import React from 'react'; -import { TextInput } from '@patternfly/react-core'; - -IconSpriteTextInputs = () => { - const [success, setSuccess] = React.useState(''); - const [warning, setWarning] = React.useState(''); - const [error, setError] = React.useState(''); - const [calendar, setCalendar] = React.useState(''); - const [clock, setClock] = React.useState(''); - - return ( - <> - setSuccess(value)} - aria-label="success icon sprite text input example" - /> -
-
- setWarning(value)} - aria-label="warning icon sprite text input example" - /> -
-
- setError(value)} - aria-label="error icon sprite text input example" - /> -
-
- setCalendar(value)} - aria-label="calendar icon sprite text input example" - /> -
-
- setClock(value)} - aria-label="clock icon sprite text input example" - /> - - ); -}; +```ts isBeta file="./TextInputIconSprite.tsx" ``` diff --git a/packages/react-core/src/components/TextInput/examples/TextInputBasic.tsx b/packages/react-core/src/components/TextInput/examples/TextInputBasic.tsx new file mode 100644 index 00000000000..5fdefea7b9d --- /dev/null +++ b/packages/react-core/src/components/TextInput/examples/TextInputBasic.tsx @@ -0,0 +1,7 @@ +import React from 'react'; +import { TextInput } from '@patternfly/react-core'; + +export const TextInputBasic: React.FunctionComponent = () => { + const [value, setValue] = React.useState(''); + return setValue(value)} aria-label="text input example" />; +}; diff --git a/packages/react-core/src/components/TextInput/examples/TextInputDisabled.tsx b/packages/react-core/src/components/TextInput/examples/TextInputDisabled.tsx new file mode 100644 index 00000000000..52580a22062 --- /dev/null +++ b/packages/react-core/src/components/TextInput/examples/TextInputDisabled.tsx @@ -0,0 +1,6 @@ +import React from 'react'; +import { TextInput } from '@patternfly/react-core'; + +export const TextInputBasic: React.FunctionComponent = () => ( + +); diff --git a/packages/react-core/src/components/TextInput/examples/TextInputIcon.tsx b/packages/react-core/src/components/TextInput/examples/TextInputIcon.tsx new file mode 100644 index 00000000000..4ac710553fe --- /dev/null +++ b/packages/react-core/src/components/TextInput/examples/TextInputIcon.tsx @@ -0,0 +1,39 @@ +import React from 'react'; +import { TextInput } from '@patternfly/react-core'; + +export const TextInputIcon: React.FunctionComponent = () => { + const [calendar, setCalendar] = React.useState(''); + const [clock, setClock] = React.useState(''); + const [custom, setCustom] = React.useState(''); + + return ( + <> + setCalendar(value)} + aria-label="text input example" + /> +
+
+ setClock(value)} + aria-label="text input example" + /> +
+
+ setCustom(value)} + aria-label="text input example" + /> + + ); +}; diff --git a/packages/react-core/src/components/TextInput/examples/TextInputIconSprite.tsx b/packages/react-core/src/components/TextInput/examples/TextInputIconSprite.tsx new file mode 100644 index 00000000000..89b39fc6406 --- /dev/null +++ b/packages/react-core/src/components/TextInput/examples/TextInputIconSprite.tsx @@ -0,0 +1,63 @@ +import React from 'react'; +import { TextInput } from '@patternfly/react-core'; + +export const TextInputIconSprite: React.FunctionComponent = () => { + const [calendar, setCalendar] = React.useState(''); + const [clock, setClock] = React.useState(''); + const [success, setSuccess] = React.useState(''); + const [warning, setWarning] = React.useState(''); + const [error, setError] = React.useState(''); + + return ( + <> + setSuccess(value)} + aria-label="success icon sprite text input example" + /> +
+
+ setWarning(value)} + aria-label="warning icon sprite text input example" + /> +
+
+ setError(value)} + aria-label="error icon sprite text input example" + /> +
+
+ setCalendar(value)} + aria-label="calendar icon sprite text input example" + /> +
+
+ setClock(value)} + aria-label="clock icon sprite text input example" + /> + + ); +}; diff --git a/packages/react-core/src/components/TextInput/examples/TextInputInvalid.tsx b/packages/react-core/src/components/TextInput/examples/TextInputInvalid.tsx new file mode 100644 index 00000000000..b76a0e78463 --- /dev/null +++ b/packages/react-core/src/components/TextInput/examples/TextInputInvalid.tsx @@ -0,0 +1,16 @@ +import React from 'react'; +import { TextInput, ValidatedOptions } from '@patternfly/react-core'; + +export const TextInputInvalid: React.FunctionComponent = () => { + const [value, setValue] = React.useState(''); + return ( + setValue(value)} + isRequired + validated={ValidatedOptions.error} + type="text" + aria-label="invalid text input example" + /> + ); +}; diff --git a/packages/react-core/src/components/TextInput/examples/TextInputLeftTruncated.tsx b/packages/react-core/src/components/TextInput/examples/TextInputLeftTruncated.tsx new file mode 100644 index 00000000000..e1c9ab72b99 --- /dev/null +++ b/packages/react-core/src/components/TextInput/examples/TextInputLeftTruncated.tsx @@ -0,0 +1,17 @@ +import React from 'react'; +import { TextInput } from '@patternfly/react-core'; + +export const LeftTruncatedTextInput: React.FunctionComponent = () => { + const [value, setValue] = React.useState( + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' + ); + return ( + setValue(value)} + aria-label="left-truncated text input example" + /> + ); +}; diff --git a/packages/react-core/src/components/TextInput/examples/TextInputReadOnly.tsx b/packages/react-core/src/components/TextInput/examples/TextInputReadOnly.tsx new file mode 100644 index 00000000000..f951f984214 --- /dev/null +++ b/packages/react-core/src/components/TextInput/examples/TextInputReadOnly.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { Checkbox, TextInput } from '@patternfly/react-core'; + +export const TextInputReadOnly: React.FunctionComponent = () => { + const [isPlainChecked, setIsPlainChecked] = React.useState(false); + return ( + <> +
+ setIsPlainChecked(checked)} + /> +
+ + + ); +}; diff --git a/packages/react-core/src/components/TextInput/examples/TextInputSelectUsingRef.tsx b/packages/react-core/src/components/TextInput/examples/TextInputSelectUsingRef.tsx new file mode 100644 index 00000000000..b5bf30d7aa3 --- /dev/null +++ b/packages/react-core/src/components/TextInput/examples/TextInputSelectUsingRef.tsx @@ -0,0 +1,16 @@ +import React from 'react'; +import { TextInput } from '@patternfly/react-core'; + +export const TextInputSelectUsingRef: React.FunctionComponent = () => { + const [value, setValue] = React.useState('select all on click'); + const ref = React.useRef(null); + return ( + ref?.current?.select()} + onChange={value => setValue(value)} + aria-label="select-all" + /> + ); +}; diff --git a/packages/react-core/src/components/Title/__tests__/Title.test.tsx b/packages/react-core/src/components/Title/__tests__/Title.test.tsx index 4e6160c52f1..ea2ca674758 100644 --- a/packages/react-core/src/components/Title/__tests__/Title.test.tsx +++ b/packages/react-core/src/components/Title/__tests__/Title.test.tsx @@ -1,25 +1,159 @@ import * as React from 'react'; import { render, screen } from '@testing-library/react'; -import { Title, TitleSizes } from '..'; - -describe('Title', () => { - Object.values(TitleSizes).forEach(size => { - test(`${size} Title`, () => { - const { asFragment } = render( - - {size} Title - - ); - expect(asFragment()).toMatchSnapshot(); - }); - }); - - test('Heading level can be set using a string value', () => { - render( - - H3 Heading - - ); - expect(screen.getByRole('heading').parentElement.querySelector('h3')).toBeInTheDocument(); - }); +import { Title } from '../Title'; + +test('Renders without children', () => { + render( +
+ + </div> + ); + expect(screen.getByTestId('title').firstChild).toBeVisible(); +}); + +test('Renders children', () => { + render(<Title headingLevel="h1">Test); + expect(screen.getByText('Test')).toBeVisible(); +}); + +test('Renders with the pf-c-title', () => { + render(Test); + expect(screen.getByRole('heading')).toHaveClass('pf-c-title'); +}); + +test('Renders with only the class pf-c-title and the heading level modifier class pf-m-2xl by default', () => { + render(Test); + expect(screen.getByRole('heading')).toHaveClass('pf-c-title pf-m-2xl', { exact: true }); +}); + +test('Renders with custom class name when className prop is passed', () => { + render( + + Test + + ); + expect(screen.getByRole('heading')).toHaveClass('test-class'); +}); + +test('Renders with class name pf-m-2xl by default when "h1" is passed as heading level', () => { + render(Test); + expect(screen.getByRole('heading')).toHaveClass('pf-m-2xl'); +}); + +test('Renders with class name pf-m-xl by default when "h2" is passed as heading level', () => { + render(Test); + expect(screen.getByRole('heading')).toHaveClass('pf-m-xl'); +}); + +test('Renders with class name pf-m-lg by default when "h3" is passed as heading level', () => { + render(Test); + expect(screen.getByRole('heading')).toHaveClass('pf-m-lg'); +}); + +test('Renders with class name pf-m-md by default when "h4" is passed as heading level', () => { + render(Test); + expect(screen.getByRole('heading')).toHaveClass('pf-m-md'); +}); + +test('Renders with class name pf-m-md by default when "h5" is passed as heading level', () => { + render(Test); + expect(screen.getByRole('heading')).toHaveClass('pf-m-md'); +}); + +test('Renders with class name pf-m-md by default when "h6" is passed as heading level', () => { + render(Test); + expect(screen.getByRole('heading')).toHaveClass('pf-m-md'); +}); + +test('Renders with class name pf-m-md when "md" is passed as title size', () => { + render( + + Test + + ); + expect(screen.getByRole('heading')).toHaveClass('pf-m-md'); +}); + +test('Renders with class name pf-m-lg when "lg" is passed as title size', () => { + render( + + Test + + ); + expect(screen.getByRole('heading')).toHaveClass('pf-m-lg'); +}); + +test('Renders with class name pf-m-xl when "xl" is passed as title size', () => { + render( + + Test + + ); + expect(screen.getByRole('heading')).toHaveClass('pf-m-xl'); +}); + +test('Renders with class name pf-m-2xl when "2xl" is passed as title size', () => { + render( + + Test + + ); + expect(screen.getByRole('heading')).toHaveClass('pf-m-2xl'); +}); + +test('Renders with class name pf-m-3xl when "3xl" is passed as title size', () => { + render( + + Test + + ); + expect(screen.getByRole('heading')).toHaveClass('pf-m-3xl'); +}); + +test('Renders with class name pf-m-4xl when "4xl" is passed as title size', () => { + render( + + Test + + ); + expect(screen.getByRole('heading')).toHaveClass('pf-m-4xl'); +}); + +test('Renders with tag name "h1" when "h1" is passed as heading level', () => { + render(Test); + expect(screen.getByRole('heading', { level: 1 })).toBeVisible(); +}); + +test('Renders with tag name "h2" when "h2" is passed as heading level', () => { + render(Test); + expect(screen.getByRole('heading', { level: 2 })).toBeVisible(); +}); + +test('Renders with tag name "h3" when "h3" is passed as heading level', () => { + render(Test); + expect(screen.getByRole('heading', { level: 3 })).toBeVisible(); +}); + +test('Renders with tag name "h4" when "h4" is passed as heading level', () => { + render(Test); + expect(screen.getByRole('heading', { level: 4 })).toBeVisible(); +}); + +test('Renders with tag name "h5" when "h5" is passed as heading level', () => { + render(Test); + expect(screen.getByRole('heading', { level: 5 })).toBeVisible(); +}); + +test('Renders with tag name "h6" when "h6" is passed as heading level', () => { + render(Test); + expect(screen.getByRole('heading', { level: 6 })).toBeVisible(); +}); + +test('Matches the snapshot', () => { + const { asFragment } = render( + + Test + + ); + expect(asFragment()).toMatchSnapshot(); }); diff --git a/packages/react-core/src/components/Title/__tests__/__snapshots__/Title.test.tsx.snap b/packages/react-core/src/components/Title/__tests__/__snapshots__/Title.test.tsx.snap index 22d6b37c393..8f68dec74c5 100644 --- a/packages/react-core/src/components/Title/__tests__/__snapshots__/Title.test.tsx.snap +++ b/packages/react-core/src/components/Title/__tests__/__snapshots__/Title.test.tsx.snap @@ -1,79 +1,14 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Title 2xl Title 1`] = ` +exports[`Matches the snapshot 1`] = `

- 2xl Title + Test

-`; - -exports[`Title 3xl Title 1`] = ` - -

- 3xl Title -

-
-`; - -exports[`Title 4xl Title 1`] = ` - -

- 4xl Title -

-
-`; - -exports[`Title lg Title 1`] = ` - -

- lg Title -

-
-`; - -exports[`Title md Title 1`] = ` - -

- md Title -

-
-`; - -exports[`Title xl Title 1`] = ` - -

- xl Title -

-
-`; +`; \ No newline at end of file diff --git a/packages/react-core/src/next/components/Dropdown/Dropdown.tsx b/packages/react-core/src/next/components/Dropdown/Dropdown.tsx index f61e9c66672..7b26cfb63fb 100644 --- a/packages/react-core/src/next/components/Dropdown/Dropdown.tsx +++ b/packages/react-core/src/next/components/Dropdown/Dropdown.tsx @@ -23,9 +23,11 @@ export interface DropdownProps extends MenuProps { isScrollable?: boolean; /** Min width of the menu. */ minWidth?: string; + /** @hide Forwarded ref */ + innerRef?: React.Ref; } -export const Dropdown: React.FunctionComponent = ({ +const DropdownBase: React.FunctionComponent = ({ children, className, onSelect, @@ -35,13 +37,14 @@ export const Dropdown: React.FunctionComponent = ({ isPlain, isScrollable, minWidth, + innerRef, ...props }: DropdownProps) => { const localMenuRef = React.useRef(); const toggleRef = React.useRef(); const containerRef = React.useRef(); - const menuRef = (props.innerRef as React.RefObject) || localMenuRef; + const menuRef = (innerRef as React.RefObject) || localMenuRef; React.useEffect(() => { const handleMenuKeys = (event: KeyboardEvent) => { if (!isOpen && toggleRef.current?.contains(event.target as Node)) { @@ -112,4 +115,8 @@ export const Dropdown: React.FunctionComponent = ({
); }; + +export const Dropdown = React.forwardRef((props: DropdownProps, ref: React.Ref) => ( + +)); Dropdown.displayName = 'Dropdown'; diff --git a/packages/react-core/src/next/components/Dropdown/examples/DropdownBasic.tsx b/packages/react-core/src/next/components/Dropdown/examples/DropdownBasic.tsx index 4627344197f..d0dac9e1567 100644 --- a/packages/react-core/src/next/components/Dropdown/examples/DropdownBasic.tsx +++ b/packages/react-core/src/next/components/Dropdown/examples/DropdownBasic.tsx @@ -4,7 +4,6 @@ import { Divider, MenuToggle } from '@patternfly/react-core'; export const DropdownBasic: React.FunctionComponent = () => { const [isOpen, setIsOpen] = React.useState(false); - const menuRef = React.useRef(null); const onToggleClick = () => { setIsOpen(!isOpen); @@ -18,7 +17,6 @@ export const DropdownBasic: React.FunctionComponent = () => { return ( setIsOpen(isOpen)} diff --git a/packages/react-core/src/next/components/Dropdown/examples/DropdownWithDescriptions.tsx b/packages/react-core/src/next/components/Dropdown/examples/DropdownWithDescriptions.tsx index e675975046b..801381081eb 100644 --- a/packages/react-core/src/next/components/Dropdown/examples/DropdownWithDescriptions.tsx +++ b/packages/react-core/src/next/components/Dropdown/examples/DropdownWithDescriptions.tsx @@ -4,7 +4,6 @@ import { MenuToggle } from '@patternfly/react-core'; export const DropdownWithDescriptions: React.FunctionComponent = () => { const [isOpen, setIsOpen] = React.useState(false); - const menuRef = React.useRef(null); const onToggleClick = () => { setIsOpen(!isOpen); @@ -18,7 +17,6 @@ export const DropdownWithDescriptions: React.FunctionComponent = () => { return ( { const [isOpen, setIsOpen] = React.useState(false); - const menuRef = React.useRef(null); const onToggleClick = () => { setIsOpen(!isOpen); @@ -18,7 +17,6 @@ export const DropdownWithGroups: React.FunctionComponent = () => { return ( setIsOpen(isOpen)} diff --git a/packages/react-core/src/next/components/Dropdown/examples/DropdownWithKebabToggle.tsx b/packages/react-core/src/next/components/Dropdown/examples/DropdownWithKebabToggle.tsx index 22f0d584b40..153b3e706ec 100644 --- a/packages/react-core/src/next/components/Dropdown/examples/DropdownWithKebabToggle.tsx +++ b/packages/react-core/src/next/components/Dropdown/examples/DropdownWithKebabToggle.tsx @@ -5,7 +5,6 @@ import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-ico export const DropdownWithKebab: React.FunctionComponent = () => { const [isOpen, setIsOpen] = React.useState(false); - const menuRef = React.useRef(null); const onToggleClick = () => { setIsOpen(!isOpen); @@ -19,7 +18,6 @@ export const DropdownWithKebab: React.FunctionComponent = () => { return (