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-console/src/components/AccessConsoles/__tests__/__snapshots__/AccessConsoles.test.tsx.snap b/packages/react-console/src/components/AccessConsoles/__tests__/__snapshots__/AccessConsoles.test.tsx.snap index 15c7a43efe1..e02c3e99649 100644 --- a/packages/react-console/src/components/AccessConsoles/__tests__/__snapshots__/AccessConsoles.test.tsx.snap +++ b/packages/react-console/src/components/AccessConsoles/__tests__/__snapshots__/AccessConsoles.test.tsx.snap @@ -129,22 +129,21 @@ exports[`AccessConsoles with preselected SerialConsole 1`] = `
- - - - - +
- - - - - + +
- - - - - +
{ Proin dictum imperdiet nibh, quis dapibus nulla. Integer sed tincidunt lectus, sit amet auctor eros. - diff --git a/packages/react-core/src/components/Backdrop/examples/BackdropSpinner.tsx b/packages/react-core/src/components/Backdrop/examples/BackdropSpinner.tsx index 9c395c1fe6e..65a0e67a584 100644 --- a/packages/react-core/src/components/Backdrop/examples/BackdropSpinner.tsx +++ b/packages/react-core/src/components/Backdrop/examples/BackdropSpinner.tsx @@ -4,7 +4,7 @@ import { Backdrop, Spinner, Bullseye } from '@patternfly/react-core'; export const BackdropSpinner: React.FunctionComponent = () => ( - + ); 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/Button/Button.tsx b/packages/react-core/src/components/Button/Button.tsx index e3013421b37..7cfdb8fe470 100644 --- a/packages/react-core/src/components/Button/Button.tsx +++ b/packages/react-core/src/components/Button/Button.tsx @@ -22,6 +22,12 @@ export enum ButtonType { reset = 'reset' } +export enum ButtonSize { + default = 'default', + sm = 'sm', + lg = 'lg' +} + export interface BadgeCountObject { /** Adds styling to the badge to indicate it has been read */ isRead?: boolean; @@ -31,7 +37,7 @@ export interface BadgeCountObject { className?: string; } -export interface ButtonProps extends Omit, 'ref'>, OUIAProps { +export interface ButtonProps extends Omit, 'ref' | 'size'>, OUIAProps { /** Content rendered inside the button */ children?: React.ReactNode; /** Additional classes added to the button */ @@ -58,6 +64,8 @@ export interface ButtonProps extends Omit, 'r inoperableEvents?: string[]; /** Adds inline styling to a link button */ isInline?: boolean; + /** Adds styling which affects the size of the button */ + size?: 'default' | 'sm' | 'lg'; /** Sets button type */ type?: 'button' | 'submit' | 'reset'; /** Adds button variant styles */ @@ -70,10 +78,6 @@ export interface ButtonProps extends Omit, 'r icon?: React.ReactNode | null; /** Sets the button tabindex. */ tabIndex?: number; - /** Adds small styling to the button */ - isSmall?: boolean; - /** Adds large styling to the button */ - isLarge?: boolean; /** Adds danger styling to secondary or link button variants */ isDanger?: boolean; /** Forwarded ref */ @@ -99,8 +103,7 @@ const ButtonBase: React.FunctionComponent = ({ spinnerAriaValueText, spinnerAriaLabelledBy, spinnerAriaLabel, - isSmall = false, - isLarge = false, + size = ButtonSize.default, inoperableEvents = ['onClick', 'onKeyPress'], isInline = false, type = ButtonType.button, @@ -157,8 +160,8 @@ const ButtonBase: React.FunctionComponent = ({ isDanger && (variant === ButtonVariant.secondary || variant === ButtonVariant.link) && styles.modifiers.danger, isLoading !== null && children !== null && styles.modifiers.progress, isLoading && styles.modifiers.inProgress, - isSmall && styles.modifiers.small, - isLarge && styles.modifiers.displayLg, + size === ButtonSize.sm && styles.modifiers.small, + size === ButtonSize.lg && styles.modifiers.displayLg, className )} disabled={isButtonElement ? isDisabled : null} diff --git a/packages/react-core/src/components/Button/__tests__/Button.test.tsx b/packages/react-core/src/components/Button/__tests__/Button.test.tsx index b8d19a3472e..7625dd1890c 100644 --- a/packages/react-core/src/components/Button/__tests__/Button.test.tsx +++ b/packages/react-core/src/components/Button/__tests__/Button.test.tsx @@ -84,13 +84,13 @@ describe('Button', () => { expect(asFragment()).toMatchSnapshot(); }); - test('isSmall', () => { - const { asFragment } = render(); + test('size small', () => { + const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); - test('isLarge', () => { - const { asFragment } = render(); + test('size large', () => { + const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); diff --git a/packages/react-core/src/components/Button/__tests__/__snapshots__/Button.test.tsx.snap b/packages/react-core/src/components/Button/__tests__/__snapshots__/Button.test.tsx.snap index 29332d1d569..38e9363506c 100644 --- a/packages/react-core/src/components/Button/__tests__/__snapshots__/Button.test.tsx.snap +++ b/packages/react-core/src/components/Button/__tests__/__snapshots__/Button.test.tsx.snap @@ -152,21 +152,6 @@ exports[`Button isInline 1`] = ` `; -exports[`Button isLarge 1`] = ` - - - -`; - exports[`Button isLoading 1`] = ` @@ -216,22 +200,21 @@ exports[`Button isLoading icon only 1`] = ` - - - - - +
ICON @@ -240,21 +223,6 @@ exports[`Button isLoading icon only 1`] = ` `; -exports[`Button isSmall 1`] = ` - - - -`; - exports[`Button link button 1`] = ` + +`; + +exports[`Button size small 1`] = ` + + + +`; + exports[`Button tertiary button 1`] = ` {' '} - {' '} - {' '} -
diff --git a/packages/react-core/src/components/Button/examples/ButtonSmall.tsx b/packages/react-core/src/components/Button/examples/ButtonSmall.tsx index 9e32fe99e65..b4a1d30c048 100644 --- a/packages/react-core/src/components/Button/examples/ButtonSmall.tsx +++ b/packages/react-core/src/components/Button/examples/ButtonSmall.tsx @@ -3,19 +3,19 @@ import { Button } from '@patternfly/react-core'; export const ButtonSmall: React.FunctionComponent = () => ( - {' '} - {' '} - {' '} - {' '} -
diff --git a/packages/react-core/src/components/Card/Card.tsx b/packages/react-core/src/components/Card/Card.tsx index 129cf1aee32..36746cb75ce 100644 --- a/packages/react-core/src/components/Card/Card.tsx +++ b/packages/react-core/src/components/Card/Card.tsx @@ -12,8 +12,6 @@ export interface CardProps extends React.HTMLProps, OUIAProps { className?: string; /** Sets the base component to render. defaults to article */ component?: keyof JSX.IntrinsicElements; - /** @deprecated to make a card hoverable, use isSelectable or isSelectableRaised. */ - isHoverable?: boolean; /** Modifies the card to include compact styling. Should not be used with isLarge. */ isCompact?: boolean; /** Modifies the card to include selectable styling */ @@ -70,7 +68,6 @@ export const Card: React.FunctionComponent = ({ id = '', className = '', component = 'article', - isHoverable = false, isCompact = false, isSelectable = false, isSelectableRaised = false, @@ -107,7 +104,7 @@ export const Card: React.FunctionComponent = ({ if (isSelectableRaised) { return css(styles.modifiers.selectableRaised, isSelected && styles.modifiers.selectedRaised); } - if (isSelectable || isHoverable) { + if (isSelectable) { return css(styles.modifiers.selectable, isSelected && styles.modifiers.selected); } return ''; diff --git a/packages/react-core/src/components/Card/__tests__/Card.test.tsx b/packages/react-core/src/components/Card/__tests__/Card.test.tsx index a3abc450479..70f47666b5e 100644 --- a/packages/react-core/src/components/Card/__tests__/Card.test.tsx +++ b/packages/react-core/src/components/Card/__tests__/Card.test.tsx @@ -37,11 +37,6 @@ describe('Card', () => { expect(screen.getByText('im a div')).toBeInTheDocument(); }); - test('card with isHoverable applied ', () => { - const { asFragment } = render(); - expect(asFragment()).toMatchSnapshot(); - }); - test('card with isCompact applied ', () => { const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); diff --git a/packages/react-core/src/components/Card/__tests__/__snapshots__/Card.test.tsx.snap b/packages/react-core/src/components/Card/__tests__/__snapshots__/Card.test.tsx.snap index d59d89794ef..6a3fadbff96 100644 --- a/packages/react-core/src/components/Card/__tests__/__snapshots__/Card.test.tsx.snap +++ b/packages/react-core/src/components/Card/__tests__/__snapshots__/Card.test.tsx.snap @@ -4,18 +4,6 @@ exports[`Card card with isCompact applied 1`] = `
- -`; - -exports[`Card card with isHoverable applied 1`] = ` - -
isBlock?: boolean; /** Adds Clipboard Copy variant styles. */ variant?: typeof ClipboardCopyVariant | 'inline' | 'expansion' | 'inline-compact'; - /** Copy button popover position. */ + /** Copy button tooltip position. */ position?: - | PopoverPosition | TooltipPosition | 'auto' | 'top' @@ -109,7 +107,7 @@ export class ClipboardCopy extends React.Component, HTMLButtonElement>, 'ref'> { @@ -25,7 +24,6 @@ export interface ClipboardCopyButtonProps /** Position of the copy button tooltip */ position?: | TooltipPosition - | PopoverPosition | 'auto' | 'top' | 'bottom' diff --git a/packages/react-core/src/components/Divider/Divider.tsx b/packages/react-core/src/components/Divider/Divider.tsx index e71bd83edd3..35ccaba4555 100644 --- a/packages/react-core/src/components/Divider/Divider.tsx +++ b/packages/react-core/src/components/Divider/Divider.tsx @@ -14,8 +14,6 @@ export interface DividerProps extends React.HTMLProps { className?: string; /** The component type to use */ component?: 'hr' | 'li' | 'div'; - /** @deprecated Use `orientation` instead. Flag to indicate the divider is vertical (must be in a flex layout) */ - isVertical?: boolean; /** Insets at various breakpoints. */ inset?: { default?: 'insetNone' | 'insetXs' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl' | 'inset3xl'; @@ -39,7 +37,6 @@ export interface DividerProps extends React.HTMLProps { export const Divider: React.FunctionComponent = ({ className, component = DividerVariant.hr, - isVertical = false, inset, orientation, ...props @@ -50,7 +47,6 @@ export const Divider: React.FunctionComponent = ({ { static defaultProps: DropdownMenuProps = { className: '', isOpen: true, - openedOnEnter: false, autoFocus: true, position: DropdownPosition.left, component: 'ul', @@ -179,8 +176,6 @@ export class DropdownMenu extends React.Component { component, isGrouped, setMenuComponentRef, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - openedOnEnter, alignments, ...props } = this.props; diff --git a/packages/react-core/src/components/Dropdown/DropdownToggle.tsx b/packages/react-core/src/components/Dropdown/DropdownToggle.tsx index cea80840736..2388f447807 100644 --- a/packages/react-core/src/components/Dropdown/DropdownToggle.tsx +++ b/packages/react-core/src/components/Dropdown/DropdownToggle.tsx @@ -29,8 +29,6 @@ export interface DropdownToggleProps extends React.HTMLProps, isText?: boolean; /** Whether or not the
has a disabled state */ isDisabled?: boolean; - /** @deprecated Use `toggleVariant` instead. Whether or not the dropdown toggle button should have primary button styling */ - isPrimary?: boolean; /** Alternate styles for the dropdown toggle button */ toggleVariant?: 'primary' | 'secondary' | 'default'; /** An image to display within the dropdown toggle, appearing before any component children */ @@ -65,7 +63,6 @@ export const DropdownToggle: React.FunctionComponent = ({ isDisabled = false, isPlain = false, isText = false, - isPrimary = false, toggleVariant = 'default', // eslint-disable-next-line @typescript-eslint/no-unused-vars isActive = false, @@ -97,7 +94,6 @@ export const DropdownToggle: React.FunctionComponent = ({ isDisabled={isDisabled} isPlain={isPlain} isText={isText} - isPrimary={isPrimary} toggleVariant={toggleVariant} onToggle={onToggle} aria-haspopup={ariaHasPopup} @@ -123,7 +119,7 @@ export const DropdownToggle: React.FunctionComponent = ({ styles.dropdownToggle, styles.modifiers.splitButton, splitButtonVariant === 'action' && styles.modifiers.action, - (toggleVariant === 'primary' || isPrimary) && splitButtonVariant === 'action' && styles.modifiers.primary, + toggleVariant === 'primary' && splitButtonVariant === 'action' && styles.modifiers.primary, toggleVariant === 'secondary' && splitButtonVariant === 'action' && styles.modifiers.secondary, isDisabled && styles.modifiers.disabled )} diff --git a/packages/react-core/src/components/Dropdown/Toggle.tsx b/packages/react-core/src/components/Dropdown/Toggle.tsx index 3b1d9175537..e5831f03ae1 100644 --- a/packages/react-core/src/components/Dropdown/Toggle.tsx +++ b/packages/react-core/src/components/Dropdown/Toggle.tsx @@ -35,8 +35,6 @@ export interface ToggleProps { isPlain?: boolean; /** Display the toggle in text only mode */ isText?: boolean; - /** @deprecated Use `toggleVariant` instead. Display the toggle with a primary button style */ - isPrimary?: boolean; /** Style the toggle as a child of a split button */ isSplitButton?: boolean; /** Alternate styles for the dropdown toggle button */ @@ -64,7 +62,6 @@ export class Toggle extends React.Component { isDisabled: false, isPlain: false, isText: false, - isPrimary: false, isSplitButton: false, onToggle: () => {}, onEnter: () => {}, @@ -138,7 +135,6 @@ export class Toggle extends React.Component { isDisabled, isPlain, isText, - isPrimary, isSplitButton, toggleVariant, onToggle, @@ -166,7 +162,6 @@ export class Toggle extends React.Component { isActive && styles.modifiers.active, isPlain && styles.modifiers.plain, isText && styles.modifiers.text, - isPrimary && styles.modifiers.primary, toggleVariant && buttonVariantStyles[toggleVariant], className )} 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/FileUpload/FileUpload.tsx b/packages/react-core/src/components/FileUpload/FileUpload.tsx index df2b34a5816..032bea86611 100644 --- a/packages/react-core/src/components/FileUpload/FileUpload.tsx +++ b/packages/react-core/src/components/FileUpload/FileUpload.tsx @@ -47,17 +47,6 @@ export interface FileUploadProps isReadOnly?: boolean; /** Flag to show if the field is required. */ isRequired?: boolean; - /** @deprecated A callback for when the file contents changes. Please instead use - * onFileInputChange, onTextChange, onDataChange, and onClearClick individually. - */ - onChange?: ( - value: string | File, - filename: string, - event: - | React.MouseEvent // Clear button was clicked - | React.DragEvent // User dragged/dropped a file - | React.ChangeEvent // User typed in the TextArea - ) => void; /** Callback for clicking on the file upload field text area. By default, prevents a click * in the text area from opening file dialog. */ @@ -66,7 +55,7 @@ export interface FileUploadProps onFileInputChange?: (event: React.ChangeEvent | React.DragEvent, file: File) => void; /** Aria-valuetext for the loading spinner. */ spinnerAriaValueText?: string; - /** What type of file. Determines what is passed to the onChange property and what is + /** What type of file. Determines whether 'onDataChange` is called and what is * expected by the value property (a string for 'text' and 'dataURL', or a File object otherwise. */ type?: 'text' | 'dataURL'; @@ -102,7 +91,6 @@ export const FileUpload: React.FunctionComponent = ({ value = type === fileReaderType.text || type === fileReaderType.dataURL ? '' : null, filename = '', children = null, - onChange = () => {}, onFileInputChange = null, onReadStarted = () => {}, onReadFinished = () => {}, @@ -121,31 +109,23 @@ export const FileUpload: React.FunctionComponent = ({ onFileInputChange?.(event, fileHandle); } if (type === fileReaderType.text || type === fileReaderType.dataURL) { - onChange('', fileHandle.name, event); // Show the filename while reading onReadStarted(fileHandle); readFile(fileHandle, type as fileReaderType) .then(data => { onReadFinished(fileHandle); - onChange(data as string, fileHandle.name, event); onDataChange?.(data as string); }) .catch((error: DOMException) => { onReadFailed(error, fileHandle); onReadFinished(fileHandle); - onChange('', '', event); // Clear the filename field on a failure onDataChange?.(''); }); - } else { - onChange(fileHandle, fileHandle.name, event); } } dropzoneProps.onDropAccepted && dropzoneProps.onDropAccepted(acceptedFiles, event); }; const onDropRejected: DropFileEventHandler = (rejectedFiles, event) => { - if (rejectedFiles.length > 0) { - onChange('', rejectedFiles[0].name, event); - } dropzoneProps.onDropRejected && dropzoneProps.onDropRejected(rejectedFiles, event); }; @@ -155,7 +135,6 @@ export const FileUpload: React.FunctionComponent = ({ }; const onClearButtonClick = (event: React.MouseEvent) => { - onChange('', '', event); onClearClick?.(event); setFileValue(null); }; @@ -187,7 +166,6 @@ export const FileUpload: React.FunctionComponent = ({ type={type} filename={filename} value={value} - onChange={onChange} isDragActive={isDragActive} onBrowseButtonClick={open} onClearButtonClick={onClearButtonClick} diff --git a/packages/react-core/src/components/FileUpload/FileUploadField.tsx b/packages/react-core/src/components/FileUpload/FileUploadField.tsx index 808dde920a6..fa5897e37db 100644 --- a/packages/react-core/src/components/FileUpload/FileUploadField.tsx +++ b/packages/react-core/src/components/FileUpload/FileUploadField.tsx @@ -12,7 +12,7 @@ import { fileReaderType } from '../../helpers/fileUtils'; * functionality is not built in by default. */ -export interface FileUploadFieldProps extends Omit, 'value' | 'onChange'> { +export interface FileUploadFieldProps extends Omit, 'value'> { /** Flag to allow editing of a text file's contents after it is selected from disk. */ allowEditingUploadedText?: boolean; /** Aria-label for the text area. */ @@ -47,14 +47,6 @@ export interface FileUploadFieldProps extends Omit // User typed in the TextArea - | React.MouseEvent // User clicked Clear button - ) => void; /** Aria-valuetext for the loading spinner. */ spinnerAriaValueText?: string; /** What type of file. Determines what is is expected by the value property (a string for @@ -95,7 +87,6 @@ export const FileUploadField: React.FunctionComponent = ({ type, value = '', filename = '', - onChange = () => {}, onBrowseButtonClick = () => {}, onClearButtonClick = () => {}, onTextAreaClick, @@ -123,8 +114,7 @@ export const FileUploadField: React.FunctionComponent = ({ ...props }: FileUploadFieldProps) => { - const onTextAreaChange = (newValue: string, event: React.ChangeEvent) => { - onChange(newValue, filename, event); + const onTextAreaChange = (newValue: string) => { onTextChange?.(newValue); }; return ( diff --git a/packages/react-core/src/components/FileUpload/__tests__/FileUpload.test.tsx b/packages/react-core/src/components/FileUpload/__tests__/FileUpload.test.tsx index 077e001ef15..369ab6c089b 100644 --- a/packages/react-core/src/components/FileUpload/__tests__/FileUpload.test.tsx +++ b/packages/react-core/src/components/FileUpload/__tests__/FileUpload.test.tsx @@ -3,7 +3,6 @@ import * as React from 'react'; import { render } from '@testing-library/react'; test('simple fileupload', () => { - const changeHandler = jest.fn(); const readStartedHandler = jest.fn(); const readFinishedHandler = jest.fn(); @@ -13,7 +12,6 @@ test('simple fileupload', () => { type="text" value={''} filename={''} - onChange={changeHandler} onReadStarted={readStartedHandler} onReadFinished={readFinishedHandler} isLoading={false} diff --git a/packages/react-core/src/components/FileUpload/__tests__/FileUploadField.test.tsx b/packages/react-core/src/components/FileUpload/__tests__/FileUploadField.test.tsx index 650da01bd8e..925394a559e 100644 --- a/packages/react-core/src/components/FileUpload/__tests__/FileUploadField.test.tsx +++ b/packages/react-core/src/components/FileUpload/__tests__/FileUploadField.test.tsx @@ -3,7 +3,6 @@ import * as React from 'react'; import { render } from '@testing-library/react'; test('simple fileuploadfield', () => { - const changeHandler = jest.fn(); const browserBtnClickHandler = jest.fn(); const clearBtnClickHandler = jest.fn(); @@ -13,7 +12,6 @@ test('simple fileuploadfield', () => { type="text" value={''} filename={''} - onChange={changeHandler} filenamePlaceholder="Do something custom with this!" onBrowseButtonClick={browserBtnClickHandler} onClearButtonClick={clearBtnClickHandler} 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/Page/Page.tsx b/packages/react-core/src/components/Page/Page.tsx index cffbc1135a1..b8ee99d36fa 100644 --- a/packages/react-core/src/components/Page/Page.tsx +++ b/packages/react-core/src/components/Page/Page.tsx @@ -101,7 +101,6 @@ export class Page extends React.Component { isManagedSidebar: false, isBreadcrumbWidthLimited: false, defaultManagedSidebarIsOpen: true, - onPageResize: (): void => null, mainTabIndex: -1, isNotificationDrawerExpanded: false, onNotificationDrawerExpand: () => null, diff --git a/packages/react-core/src/components/Page/PageBreadcrumb.tsx b/packages/react-core/src/components/Page/PageBreadcrumb.tsx index 527de45cb90..c8c8ad7e6cd 100644 --- a/packages/react-core/src/components/Page/PageBreadcrumb.tsx +++ b/packages/react-core/src/components/Page/PageBreadcrumb.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { css } from '@patternfly/react-styles'; import styles from '@patternfly/react-styles/css/components/Page/page'; -import { formatBreakpointMods } from '../../helpers/util'; +import { formatBreakpointMods, Mods } from '../../helpers/util'; import { PageContext } from './PageContext'; export interface PageBreadcrumbProps extends React.HTMLProps { @@ -11,8 +11,6 @@ export interface PageBreadcrumbProps extends React.HTMLProps { children?: React.ReactNode; /** Limits the width of the breadcrumb */ isWidthLimited?: boolean; - /** @deprecated Use the stickyOnBreakpoint prop instead - Modifier indicating if the PageBreadcrumb is sticky to the top or bottom */ - sticky?: 'top' | 'bottom'; /** Modifier indicating if the PageBreadcrumb is sticky to the top or bottom at various breakpoints */ stickyOnBreakpoint?: { default?: 'top' | 'bottom'; @@ -36,7 +34,6 @@ export const PageBreadcrumb = ({ className = '', children, isWidthLimited, - sticky, stickyOnBreakpoint, hasShadowTop = false, hasShadowBottom = false, @@ -57,10 +54,8 @@ export const PageBreadcrumb = ({
{ className?: string; /** Content rendered inside of the PageGroup */ children?: React.ReactNode; - /** @deprecated Use the stickyOnBreakpoint prop instead - Modifier indicating if the PageBreadcrumb is sticky to the top or bottom */ - sticky?: 'top' | 'bottom'; /** Modifier indicating if the PageBreadcrumb is sticky to the top or bottom at various breakpoints */ stickyOnBreakpoint?: { default?: 'top' | 'bottom'; @@ -32,7 +30,6 @@ export interface PageGroupProps extends React.HTMLProps { export const PageGroup = ({ className = '', children, - sticky, stickyOnBreakpoint, hasShadowTop = false, hasShadowBottom = false, @@ -55,8 +52,6 @@ export const PageGroup = ({ className={css( styles.pageMainGroup, formatBreakpointMods(stickyOnBreakpoint, styles, 'sticky-', getVerticalBreakpoint(height), true), - sticky === 'top' && styles.modifiers.stickyTop, - sticky === 'bottom' && styles.modifiers.stickyBottom, hasShadowTop && styles.modifiers.shadowTop, hasShadowBottom && styles.modifiers.shadowBottom, hasOverflowScroll && styles.modifiers.overflowScroll, diff --git a/packages/react-core/src/components/Page/PageHeader.tsx b/packages/react-core/src/components/Page/PageHeader.tsx index 0c5af921442..0cb2db3de90 100644 --- a/packages/react-core/src/components/Page/PageHeader.tsx +++ b/packages/react-core/src/components/Page/PageHeader.tsx @@ -25,8 +25,6 @@ export interface PageHeaderProps extends React.HTMLProps { navToggleId?: string; /** True if the side nav is shown */ isNavOpen?: boolean; - /** This prop is no longer managed through PageHeader but in the Page component. */ - isManagedSidebar?: boolean; /** Sets the value for role on the
element */ role?: string; /** Callback function to handle the side nav toggle button, managed by the Page component if the Page isManagedSidebar prop is set to true */ @@ -43,7 +41,6 @@ export const PageHeader: React.FunctionComponent = ({ headerTools = null as React.ReactNode, topNav = null as React.ReactNode, isNavOpen = true, - isManagedSidebar: deprecatedIsManagedSidebar = undefined, role = undefined as string, showNavToggle = false, navToggleId = 'nav-toggle', @@ -53,11 +50,6 @@ export const PageHeader: React.FunctionComponent = ({ ...props }: PageHeaderProps) => { const LogoComponent = logoComponent as any; - if ([false, true].includes(deprecatedIsManagedSidebar)) { - console.warn( - 'isManagedSidebar is deprecated in the PageHeader component. To make the sidebar toggle uncontrolled, pass this prop in the Page component' - ); - } return ( {({ isManagedSidebar, onNavToggle: managedOnNavToggle, isNavOpen: managedIsNavOpen }: PageContextProps) => { diff --git a/packages/react-core/src/components/Page/PageNavigation.tsx b/packages/react-core/src/components/Page/PageNavigation.tsx index 1a6ad1117bc..9024c1fe4d0 100644 --- a/packages/react-core/src/components/Page/PageNavigation.tsx +++ b/packages/react-core/src/components/Page/PageNavigation.tsx @@ -11,8 +11,6 @@ export interface PageNavigationProps extends React.HTMLProps { children?: React.ReactNode; /** Limits the width of the PageNavigation */ isWidthLimited?: boolean; - /** @deprecated Use the stickyOnBreakpoint prop instead - Modifier indicating if the PageBreadcrumb is sticky to the top or bottom */ - sticky?: 'top' | 'bottom'; /** Modifier indicating if the PageBreadcrumb is sticky to the top or bottom at various breakpoints */ stickyOnBreakpoint?: { default?: 'top' | 'bottom'; @@ -36,7 +34,6 @@ export const PageNavigation = ({ className = '', children, isWidthLimited, - sticky, stickyOnBreakpoint, hasShadowTop = false, hasShadowBottom = false, @@ -59,8 +56,6 @@ export const PageNavigation = ({ styles.pageMainNav, formatBreakpointMods(stickyOnBreakpoint, styles, 'sticky-', getVerticalBreakpoint(height), true), isWidthLimited && styles.modifiers.limitWidth, - sticky === 'top' && styles.modifiers.stickyTop, - sticky === 'bottom' && styles.modifiers.stickyBottom, hasShadowTop && styles.modifiers.shadowTop, hasShadowBottom && styles.modifiers.shadowBottom, hasOverflowScroll && styles.modifiers.overflowScroll, diff --git a/packages/react-core/src/components/Page/PageSection.tsx b/packages/react-core/src/components/Page/PageSection.tsx index 88343b2a26f..0793f85d83e 100644 --- a/packages/react-core/src/components/Page/PageSection.tsx +++ b/packages/react-core/src/components/Page/PageSection.tsx @@ -44,8 +44,6 @@ export interface PageSectionProps extends React.HTMLProps { xl?: 'padding' | 'noPadding'; '2xl'?: 'padding' | 'noPadding'; }; - /** @deprecated Use the stickyOnBreakpoint prop instead - Modifier indicating if the PageBreadcrumb is sticky to the top or bottom */ - sticky?: 'top' | 'bottom'; /** Modifier indicating if the PageBreadcrumb is sticky to the top or bottom at various breakpoints */ stickyOnBreakpoint?: { default?: 'top' | 'bottom'; @@ -94,7 +92,6 @@ export const PageSection: React.FunctionComponent = ({ isFilled, isWidthLimited = false, isCenterAligned = false, - sticky, stickyOnBreakpoint, hasShadowTop = false, hasShadowBottom = false, @@ -126,8 +123,6 @@ export const PageSection: React.FunctionComponent = ({ isFilled === true && styles.modifiers.fill, isWidthLimited && styles.modifiers.limitWidth, isWidthLimited && isCenterAligned && type !== PageSectionTypes.subNav && styles.modifiers.alignCenter, - sticky === 'top' && styles.modifiers.stickyTop, - sticky === 'bottom' && styles.modifiers.stickyBottom, hasShadowTop && styles.modifiers.shadowTop, hasShadowBottom && styles.modifiers.shadowBottom, hasOverflowScroll && styles.modifiers.overflowScroll, diff --git a/packages/react-core/src/components/Page/__tests__/PageBreadcrumb.test.tsx b/packages/react-core/src/components/Page/__tests__/PageBreadcrumb.test.tsx index 913838f7473..63742eb0de6 100644 --- a/packages/react-core/src/components/Page/__tests__/PageBreadcrumb.test.tsx +++ b/packages/react-core/src/components/Page/__tests__/PageBreadcrumb.test.tsx @@ -12,11 +12,11 @@ describe('page breadcrumb', () => { expect(asFragment()).toMatchSnapshot(); }); test('Verify top sticky', () => { - const { asFragment } = render(test); + const { asFragment } = render(test); expect(asFragment()).toMatchSnapshot(); }); test('Verify bottom sticky', () => { - const { asFragment } = render(test); + const { asFragment } = render(test); expect(asFragment()).toMatchSnapshot(); }); test('Verify top shadow', () => { diff --git a/packages/react-core/src/components/Page/__tests__/PageGroup.test.tsx b/packages/react-core/src/components/Page/__tests__/PageGroup.test.tsx index f4bb73fd370..8ac64dd01c2 100644 --- a/packages/react-core/src/components/Page/__tests__/PageGroup.test.tsx +++ b/packages/react-core/src/components/Page/__tests__/PageGroup.test.tsx @@ -8,11 +8,11 @@ describe('page group', () => { expect(asFragment()).toMatchSnapshot(); }); test('Verify top sticky', () => { - const { asFragment } = render(test); + const { asFragment } = render(test); expect(asFragment()).toMatchSnapshot(); }); test('Verify bottom sticky', () => { - const { asFragment } = render(test); + const { asFragment } = render(test); expect(asFragment()).toMatchSnapshot(); }); test('Verify top shadow', () => { diff --git a/packages/react-core/src/components/Page/__tests__/PageNavigation.test.tsx b/packages/react-core/src/components/Page/__tests__/PageNavigation.test.tsx index 80e3c6556d3..8577c1cc4d5 100644 --- a/packages/react-core/src/components/Page/__tests__/PageNavigation.test.tsx +++ b/packages/react-core/src/components/Page/__tests__/PageNavigation.test.tsx @@ -12,11 +12,11 @@ describe('page navigation', () => { expect(asFragment()).toMatchSnapshot(); }); test('Verify top sticky', () => { - const { asFragment } = render(test); + const { asFragment } = render(test); expect(asFragment()).toMatchSnapshot(); }); test('Verify bottom sticky', () => { - const { asFragment } = render(test); + const { asFragment } = render(test); expect(asFragment()).toMatchSnapshot(); }); test('Verify top shadow', () => { diff --git a/packages/react-core/src/components/Page/__tests__/PageSection.test.tsx b/packages/react-core/src/components/Page/__tests__/PageSection.test.tsx index 3bdf925f9b1..ceed384957f 100644 --- a/packages/react-core/src/components/Page/__tests__/PageSection.test.tsx +++ b/packages/react-core/src/components/Page/__tests__/PageSection.test.tsx @@ -65,12 +65,12 @@ test('Check page section with fill and no padding example against snapshot', () }); test('Verify page section top sticky', () => { - const { asFragment } = render(test); + const { asFragment } = render(test); expect(asFragment()).toMatchSnapshot(); }); test('Verify page section bottom sticky', () => { - const { asFragment } = render(test); + const { asFragment } = render(test); expect(asFragment()).toMatchSnapshot(); }); diff --git a/packages/react-core/src/components/Page/__tests__/__snapshots__/Page.test.tsx.snap b/packages/react-core/src/components/Page/__tests__/__snapshots__/Page.test.tsx.snap index 971d4c112bc..cc1f1c12d34 100644 --- a/packages/react-core/src/components/Page/__tests__/__snapshots__/Page.test.tsx.snap +++ b/packages/react-core/src/components/Page/__tests__/__snapshots__/Page.test.tsx.snap @@ -4,7 +4,7 @@ exports[`Page Check dark page against snapshot 1`] = `
@@ -1394,7 +1394,7 @@ exports[`Page Check page vertical layout example against snapshot 1`] = `
{ @@ -39,7 +39,7 @@ export interface OptionsToggleProps extends React.HTMLProps { showToggle?: boolean; /** This will be shown in pagination toggle span. You can use firstIndex, lastIndex, * itemCount, and/or itemsTitle props. */ - toggleTemplate?: ((props: ToggleTemplateProps) => React.ReactElement) | string; + toggleTemplate?: ((props: PaginationToggleTemplateProps) => React.ReactElement) | string; /** Id added to the title of the pagination options menu. */ widgetId?: string; } diff --git a/packages/react-core/src/components/Pagination/Pagination.tsx b/packages/react-core/src/components/Pagination/Pagination.tsx index 6fd8fe5cc44..9aec19883ad 100644 --- a/packages/react-core/src/components/Pagination/Pagination.tsx +++ b/packages/react-core/src/components/Pagination/Pagination.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { ToggleTemplate, ToggleTemplateProps } from './ToggleTemplate'; +import { ToggleTemplate, PaginationToggleTemplateProps } from './ToggleTemplate'; import styles from '@patternfly/react-styles/css/components/Pagination/pagination'; import { css } from '@patternfly/react-styles'; @@ -154,7 +154,7 @@ export interface PaginationProps extends React.HTMLProps, OUIAPr /** This will be shown in pagination toggle span. You can use firstIndex, lastIndex, * itemCount, itemsTitle, and/or ofWord props. */ - toggleTemplate?: ((props: ToggleTemplateProps) => React.ReactElement) | string; + toggleTemplate?: ((props: PaginationToggleTemplateProps) => React.ReactElement) | string; /** Position where pagination is rendered. */ variant?: 'top' | 'bottom' | PaginationVariant; /** Id to ideintify widget on page. */ @@ -306,7 +306,13 @@ export class Pagination extends React.Component {variant === PaginationVariant.top && (
- {toggleTemplate && typeof toggleTemplate === 'string' && fillTemplate(toggleTemplate, toggleTemplateProps)} + {toggleTemplate && + typeof toggleTemplate === 'string' && + fillTemplate(toggleTemplate, PaginationToggleTemplateProps)} {toggleTemplate && typeof toggleTemplate !== 'string' && - (toggleTemplate as (props: ToggleTemplateProps) => React.ReactElement)(toggleTemplateProps)} + (toggleTemplate as (props: PaginationToggleTemplateProps) => React.ReactElement)( + PaginationToggleTemplateProps + )} {!toggleTemplate && ( { @@ -45,7 +45,7 @@ export interface PaginationOptionsMenuProps extends React.HTMLProps React.ReactElement) | string; + toggleTemplate: ((props: PaginationToggleTemplateProps) => React.ReactElement) | string; /** Function called when user selects number of items per page. */ onPerPageSelect?: OnPerPageSelect; /** Label for the English word "of". */ diff --git a/packages/react-core/src/components/Pagination/ToggleTemplate.tsx b/packages/react-core/src/components/Pagination/ToggleTemplate.tsx index 71267b1055d..aa5e0f971f5 100644 --- a/packages/react-core/src/components/Pagination/ToggleTemplate.tsx +++ b/packages/react-core/src/components/Pagination/ToggleTemplate.tsx @@ -4,7 +4,7 @@ import * as React from 'react'; * should be passed into the pagination component's toggleTemplate property. */ -export interface ToggleTemplateProps { +export interface PaginationToggleTemplateProps { /** The first index of the items being paginated */ firstIndex?: number; /** The last index of the items being paginated */ @@ -17,13 +17,13 @@ export interface ToggleTemplateProps { ofWord?: React.ReactNode; } -export const ToggleTemplate: React.FunctionComponent = ({ +export const ToggleTemplate: React.FunctionComponent = ({ firstIndex = 0, lastIndex = 0, itemCount = 0, itemsTitle = 'items', ofWord = 'of' -}: ToggleTemplateProps) => ( +}: PaginationToggleTemplateProps) => ( {firstIndex} - {lastIndex} diff --git a/packages/react-core/src/components/Pagination/__tests__/Generated/PaginationOptionsMenu.test.tsx b/packages/react-core/src/components/Pagination/__tests__/Generated/PaginationOptionsMenu.test.tsx index 8fc3f26037a..12a757e6460 100644 --- a/packages/react-core/src/components/Pagination/__tests__/Generated/PaginationOptionsMenu.test.tsx +++ b/packages/react-core/src/components/Pagination/__tests__/Generated/PaginationOptionsMenu.test.tsx @@ -5,7 +5,7 @@ import * as React from 'react'; import { render } from '@testing-library/react'; import { PaginationOptionsMenu } from '../../PaginationOptionsMenu'; // any missing imports can usually be resolved by adding them here -import { ToggleTemplateProps } from '../..'; +import { PaginationToggleTemplateProps } from '../..'; it('PaginationOptionsMenu should match snapshot (auto-generated)', () => { const { asFragment } = render( @@ -26,7 +26,7 @@ it('PaginationOptionsMenu should match snapshot (auto-generated)', () => { defaultToFullPage={false} perPage={0} lastPage={42} - toggleTemplate={({ firstIndex, lastIndex, itemCount, itemsTitle }: ToggleTemplateProps) => ( + toggleTemplate={({ firstIndex, lastIndex, itemCount, itemsTitle }: PaginationToggleTemplateProps) => ( {firstIndex} - {lastIndex} diff --git a/packages/react-core/src/components/Pagination/examples/Pagination.md b/packages/react-core/src/components/Pagination/examples/Pagination.md index c11bd37a2e4..5a032df977d 100644 --- a/packages/react-core/src/components/Pagination/examples/Pagination.md +++ b/packages/react-core/src/components/Pagination/examples/Pagination.md @@ -2,7 +2,7 @@ id: Pagination section: components cssPrefix: null -propComponents: ['Pagination', PaginationTitles, PerPageOptions, ToggleTemplateProps] +propComponents: ['Pagination', PaginationTitles, PerPageOptions, PaginationToggleTemplateProps] ouia: true --- 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/SimpleList/SimpleListItem.tsx b/packages/react-core/src/components/SimpleList/SimpleListItem.tsx index 7caee0e0c9a..6792f9a54de 100644 --- a/packages/react-core/src/components/SimpleList/SimpleListItem.tsx +++ b/packages/react-core/src/components/SimpleList/SimpleListItem.tsx @@ -18,8 +18,6 @@ export interface SimpleListItemProps { componentProps?: any; /** Indicates if the link is current/highlighted */ isActive?: boolean; - /** @deprecated please use isActive instead */ - isCurrent?: boolean; /** OnClick callback for the SimpleList item */ onClick?: (event: React.MouseEvent | React.ChangeEvent) => void; /** Type of button SimpleList item */ @@ -35,7 +33,6 @@ export class SimpleListItem extends React.Component { children: null, className: '', isActive: false, - isCurrent: false, component: 'button', componentClassName: '', type: 'button', @@ -46,7 +43,6 @@ export class SimpleListItem extends React.Component { render() { const { children, - isCurrent, isActive, className, component: Component, @@ -64,7 +60,7 @@ export class SimpleListItem extends React.Component { {({ currentRef, updateCurrentRef, isControlled }) => { const isButton = Component === 'button'; const isCurrentItem = - this.ref && currentRef && isControlled ? currentRef.current === this.ref.current : isActive || isCurrent; + this.ref && currentRef && isControlled ? currentRef.current === this.ref.current : isActive; const additionalComponentProps = isButton ? { 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/Spinner/Spinner.tsx b/packages/react-core/src/components/Spinner/Spinner.tsx index bf1b9a80e4a..61932f3c393 100644 --- a/packages/react-core/src/components/Spinner/Spinner.tsx +++ b/packages/react-core/src/components/Spinner/Spinner.tsx @@ -31,7 +31,7 @@ export const Spinner: React.FunctionComponent = ({ className = '', size = 'xl', 'aria-valuetext': ariaValueText = 'Loading...', - isSVG = false, + isSVG = true, diameter, 'aria-label': ariaLabel, 'aria-labelledBy': ariaLabelledBy, diff --git a/packages/react-core/src/components/Spinner/__tests__/Spinner.test.tsx b/packages/react-core/src/components/Spinner/__tests__/Spinner.test.tsx index eb1402d7004..81b8eb78cf9 100644 --- a/packages/react-core/src/components/Spinner/__tests__/Spinner.test.tsx +++ b/packages/react-core/src/components/Spinner/__tests__/Spinner.test.tsx @@ -26,3 +26,9 @@ test('extra large spinner', () => { const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); + +test('non-SVG spinner', () => { + const { asFragment } = render() + + expect(asFragment()).toMatchSnapshot(); +}) diff --git a/packages/react-core/src/components/Spinner/__tests__/__snapshots__/Spinner.test.tsx.snap b/packages/react-core/src/components/Spinner/__tests__/__snapshots__/Spinner.test.tsx.snap index b7d35ca8adb..66ca1910fda 100644 --- a/packages/react-core/src/components/Spinner/__tests__/__snapshots__/Spinner.test.tsx.snap +++ b/packages/react-core/src/components/Spinner/__tests__/__snapshots__/Spinner.test.tsx.snap @@ -2,68 +2,65 @@ exports[`extra large spinner 1`] = ` - - - - - + `; exports[`large spinner 1`] = ` - - - - - + `; exports[`medium spinner 1`] = ` - - - - - + `; -exports[`simple spinner 1`] = ` +exports[`non-SVG spinner 1`] = ` `; +exports[`simple spinner 1`] = ` + + + + + +`; + exports[`small spinner 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/components/Toolbar/ToolbarContent.tsx b/packages/react-core/src/components/Toolbar/ToolbarContent.tsx index ec5f5c5acf6..a5003a378a2 100644 --- a/packages/react-core/src/components/Toolbar/ToolbarContent.tsx +++ b/packages/react-core/src/components/Toolbar/ToolbarContent.tsx @@ -17,14 +17,6 @@ export interface ToolbarContentProps extends React.HTMLProps { xl?: 'hidden' | 'visible'; '2xl'?: 'hidden' | 'visible'; }; - /** @deprecated prop misspelled */ - visiblity?: { - default?: 'hidden' | 'visible'; - md?: 'hidden' | 'visible'; - lg?: 'hidden' | 'visible'; - xl?: 'hidden' | 'visible'; - '2xl'?: 'hidden' | 'visible'; - }; /** Alignment at various breakpoints. */ alignment?: { default?: 'alignRight' | 'alignLeft'; @@ -65,7 +57,6 @@ export class ToolbarContent extends React.Component { isExpanded, toolbarId, visibility, - visiblity, alignment, clearAllFilters, showClearFiltersButton, @@ -73,21 +64,13 @@ export class ToolbarContent extends React.Component { ...props } = this.props; - if (visiblity !== undefined) { - // eslint-disable-next-line no-console - console.warn( - 'The ToolbarContent visiblity prop has been deprecated. ' + - 'Please use the correctly spelled visibility prop instead.' - ); - } - return ( {({ width, getBreakpoint }) => (
, xl?: 'hidden' | 'visible'; '2xl'?: 'hidden' | 'visible'; }; - /** @deprecated prop misspelled */ - visiblity?: { - default?: 'hidden' | 'visible'; - md?: 'hidden' | 'visible'; - lg?: 'hidden' | 'visible'; - xl?: 'hidden' | 'visible'; - '2xl'?: 'hidden' | 'visible'; - }; /** Alignment at various breakpoints. */ alignment?: { default?: 'alignRight' | 'alignLeft'; @@ -63,26 +55,7 @@ export interface ToolbarGroupProps extends Omit, class ToolbarGroupWithRef extends React.Component { render() { - const { - visibility, - visiblity, - alignment, - spacer, - spaceItems, - className, - variant, - children, - innerRef, - ...props - } = this.props; - - if (visiblity !== undefined) { - // eslint-disable-next-line no-console - console.warn( - 'The ToolbarGroup visiblity prop has been deprecated. ' + - 'Please use the correctly spelled visibility prop instead.' - ); - } + const { visibility, alignment, spacer, spaceItems, className, variant, children, innerRef, ...props } = this.props; return ( @@ -91,7 +64,7 @@ class ToolbarGroupWithRef extends React.Component { className={css( styles.toolbarGroup, variant && styles.modifiers[toCamel(variant) as 'filterGroup' | 'iconButtonGroup' | 'buttonGroup'], - formatBreakpointMods(visibility || visiblity, styles, '', getBreakpoint(width)), + formatBreakpointMods(visibility, styles, '', getBreakpoint(width)), formatBreakpointMods(alignment, styles, '', getBreakpoint(width)), formatBreakpointMods(spacer, styles, '', getBreakpoint(width)), formatBreakpointMods(spaceItems, styles, '', getBreakpoint(width)), diff --git a/packages/react-core/src/components/Toolbar/ToolbarItem.tsx b/packages/react-core/src/components/Toolbar/ToolbarItem.tsx index 492cf4db707..d74c3d561d0 100644 --- a/packages/react-core/src/components/Toolbar/ToolbarItem.tsx +++ b/packages/react-core/src/components/Toolbar/ToolbarItem.tsx @@ -39,14 +39,6 @@ export interface ToolbarItemProps extends React.HTMLProps { xl?: 'hidden' | 'visible'; '2xl'?: 'hidden' | 'visible'; }; - /** @deprecated prop misspelled */ - visiblity?: { - default?: 'hidden' | 'visible'; - md?: 'hidden' | 'visible'; - lg?: 'hidden' | 'visible'; - xl?: 'hidden' | 'visible'; - '2xl'?: 'hidden' | 'visible'; - }; /** Alignment at various breakpoints. */ alignment?: { default?: 'alignRight' | 'alignLeft'; @@ -84,7 +76,6 @@ export const ToolbarItem: React.FunctionComponent = ({ className, variant, visibility, - visiblity, alignment, spacer, widths, @@ -97,14 +88,6 @@ export const ToolbarItem: React.FunctionComponent = ({ return ; } - if (visiblity !== undefined) { - // eslint-disable-next-line no-console - console.warn( - 'The ToolbarItem visiblity prop has been deprecated. ' + - 'Please use the correctly spelled visibility prop instead.' - ); - } - const widthStyles: any = {}; if (widths) { Object.entries(widths || {}).map( @@ -130,7 +113,7 @@ export const ToolbarItem: React.FunctionComponent = ({ | 'chipGroup' ], isAllExpanded && styles.modifiers.expanded, - formatBreakpointMods(visibility || visiblity, styles, '', getBreakpoint(width)), + formatBreakpointMods(visibility, styles, '', getBreakpoint(width)), formatBreakpointMods(alignment, styles, '', getBreakpoint(width)), formatBreakpointMods(spacer, styles, '', getBreakpoint(width)), className diff --git a/packages/react-core/src/components/Toolbar/ToolbarToggleGroup.tsx b/packages/react-core/src/components/Toolbar/ToolbarToggleGroup.tsx index 65ad8d3f9c8..e5040aad334 100644 --- a/packages/react-core/src/components/Toolbar/ToolbarToggleGroup.tsx +++ b/packages/react-core/src/components/Toolbar/ToolbarToggleGroup.tsx @@ -22,14 +22,6 @@ export interface ToolbarToggleGroupProps extends ToolbarGroupProps { xl?: 'hidden' | 'visible'; '2xl'?: 'hidden' | 'visible'; }; - /** @deprecated prop misspelled */ - visiblity?: { - default?: 'hidden' | 'visible'; - md?: 'hidden' | 'visible'; - lg?: 'hidden' | 'visible'; - xl?: 'hidden' | 'visible'; - '2xl'?: 'hidden' | 'visible'; - }; /** Alignment at various breakpoints. */ alignment?: { default?: 'alignRight' | 'alignLeft'; @@ -69,7 +61,6 @@ export class ToolbarToggleGroup extends React.Component toggleIcon, variant, visibility, - visiblity, breakpoint, alignment, spacer, @@ -84,14 +75,6 @@ export class ToolbarToggleGroup extends React.Component console.error('ToolbarToggleGroup will not be visible without a breakpoint or toggleIcon.'); } - if (visiblity !== undefined) { - // eslint-disable-next-line no-console - console.warn( - 'The ToolbarToggleGroup visiblity prop has been deprecated. ' + - 'Please use the correctly spelled visibility prop instead.' - ); - } - return ( {({ width, getBreakpoint }) => ( @@ -123,7 +106,7 @@ export class ToolbarToggleGroup extends React.Component variant && styles.modifiers[toCamel(variant) as 'filterGroup' | 'iconButtonGroup' | 'buttonGroup'], formatBreakpointMods(breakpointMod, styles, '', getBreakpoint(width)), - formatBreakpointMods(visibility || visiblity, styles, '', getBreakpoint(width)), + formatBreakpointMods(visibility, styles, '', getBreakpoint(width)), formatBreakpointMods(alignment, styles, '', getBreakpoint(width)), formatBreakpointMods(spacer, styles, '', getBreakpoint(width)), formatBreakpointMods(spaceItems, styles, '', getBreakpoint(width)), diff --git a/packages/react-core/src/helpers/Popper/Popper.tsx b/packages/react-core/src/helpers/Popper/Popper.tsx index 0333f0431aa..3d45ebe4f44 100644 --- a/packages/react-core/src/helpers/Popper/Popper.tsx +++ b/packages/react-core/src/helpers/Popper/Popper.tsx @@ -181,7 +181,7 @@ export const Popper: React.FunctionComponent = ({ } }, [reference]); React.useEffect(() => { - // When the popperRef is defined or the popper visiblity changes, ensure the popper element is up to date + // When the popperRef is defined or the popper visibility changes, ensure the popper element is up to date if (popperRef) { if ((popperRef as React.RefObject).current) { setPopperElement((popperRef as React.RefObject).current); diff --git a/packages/react-core/src/helpers/constants.ts b/packages/react-core/src/helpers/constants.ts index c2af79bd2dc..28d65f13de3 100644 --- a/packages/react-core/src/helpers/constants.ts +++ b/packages/react-core/src/helpers/constants.ts @@ -10,8 +10,6 @@ import globalHeightBreakpointLg from '@patternfly/react-tokens/dist/esm/global_h import globalHeightBreakpointXl from '@patternfly/react-tokens/dist/esm/global_height_breakpoint_xl'; import globalHeightBreakpoint2xl from '@patternfly/react-tokens/dist/esm/global_height_breakpoint_2xl'; -export const KEY_CODES = { ARROW_UP: 38, ARROW_DOWN: 40, ESCAPE_KEY: 27, TAB: 9, ENTER: 13, SPACE: 32 }; - export const SIDE = { RIGHT: 'right', LEFT: 'left', BOTH: 'both', NONE: 'none' }; export const KEYHANDLER_DIRECTION = { UP: 'up', DOWN: 'down', RIGHT: 'right', LEFT: 'left' }; 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 ( { Aria-disabled with tooltip - -