Skip to content

Commit c891a29

Browse files
committed
feat(React19): Add support for React19
1 parent 0c71d4d commit c891a29

File tree

17 files changed

+79
-77
lines changed

17 files changed

+79
-77
lines changed

packages/module/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
"tslib": "^2.5.2"
4848
},
4949
"peerDependencies": {
50-
"react": "^17 || ^18",
51-
"react-dom": "^17 || ^18"
50+
"react": "^17 || ^18 || ^19",
51+
"react-dom": "^17 || ^18 || ^19"
5252
},
5353
"devDependencies": {
5454
"@patternfly/documentation-framework": "^6.0.0-alpha.109",

packages/module/patternfly-docs/content/examples/Actions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-console */
2-
import React from 'react';
2+
import { FunctionComponent } from 'react';
33
import {
44
ActionsColumn,
55
Caption,
@@ -14,7 +14,7 @@ import {
1414
import { CellMeasurerCache, CellMeasurer } from 'react-virtualized';
1515
import { AutoSizer, VirtualTableBody } from '@patternfly/react-virtualized-extension';
1616

17-
export const ActionsExample: React.FunctionComponent = () => {
17+
export const ActionsExample: FunctionComponent = () => {
1818
interface RowType {
1919
disableActions: boolean;
2020
id: string;

packages/module/patternfly-docs/content/examples/Basic.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React from 'react';
1+
import { FunctionComponent } from 'react';
22
import { Caption, Table, TableGridBreakpoint, Td, Th, Thead, Tr } from '@patternfly/react-table';
33
import { CellMeasurerCache, CellMeasurer } from 'react-virtualized';
44
import { AutoSizer, VirtualTableBody } from '@patternfly/react-virtualized-extension';
55

6-
export const VirtualizedExample: React.FunctionComponent = () => {
6+
export const VirtualizedExample: FunctionComponent = () => {
77
// this StringArray type is just needed because something in our documentation framework crashes when it encounters
88
// a string[][] type
99
type StringArray = string[];

packages/module/patternfly-docs/content/examples/FilterableWithWindowScroller.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { CellMeasurerCache, CellMeasurer } from 'react-virtualized';
32
import { AutoSizer, VirtualTableBody, WindowScroller } from '@patternfly/react-virtualized-extension';
43
import { Table, Thead, Tr, Th, Td, TableGridBreakpoint, ActionsColumn, Tbody } from '@patternfly/react-table';
@@ -25,10 +24,11 @@ import {
2524
Bullseye
2625
} from '@patternfly/react-core';
2726
import { FilterIcon, SearchIcon } from '@patternfly/react-icons';
27+
import { Fragment, useEffect, useState, CSSProperties, Ref, MouseEvent as ReactMouseEvent, SyntheticEvent, KeyboardEvent as ReactKeyboardEvent } from 'react';
2828

2929
export const ComposableTableWindowScroller = () => {
30-
const [scrollableElement, setScrollableElement] = React.useState<HTMLElement>();
31-
React.useEffect(() => {
30+
const [scrollableElement, setScrollableElement] = useState<HTMLElement>();
31+
useEffect(() => {
3232
const scrollableElement = document.getElementById('content-scrollable-2') as HTMLElement;
3333
setScrollableElement(scrollableElement);
3434
}, []);
@@ -86,11 +86,11 @@ export const ComposableTableWindowScroller = () => {
8686
const columns = ['Servers', 'Threads', 'Applications', 'Status', 'Location'];
8787
const scrollToIndex = -1; // can be used to programmatically set current index
8888

89-
const [isCategoryDropdownOpen, setIsCategoryDropdownOpen] = React.useState(false);
90-
const [isFilterDropdownOpen, setIsFilterDropdownOpen] = React.useState(false);
91-
const [currentCategory, setCurrentCategory] = React.useState('Name');
92-
const [filters, setFilters] = React.useState<Record<string, string[]>>({ location: [], name: [], status: [] });
93-
const [inputValue, setInputValue] = React.useState('');
89+
const [isCategoryDropdownOpen, setIsCategoryDropdownOpen] = useState(false);
90+
const [isFilterDropdownOpen, setIsFilterDropdownOpen] = useState(false);
91+
const [currentCategory, setCurrentCategory] = useState('Name');
92+
const [filters, setFilters] = useState<Record<string, string[]>>({ location: [], name: [], status: [] });
93+
const [inputValue, setInputValue] = useState('');
9494

9595
const onDelete = (type: string | ToolbarLabelGroup, id: string) => {
9696
if (type === 'Location') {
@@ -130,7 +130,7 @@ export const ComposableTableWindowScroller = () => {
130130
setInputValue(newValue);
131131
};
132132

133-
const onStatusSelect = (event: React.MouseEvent<Element, MouseEvent> | undefined, selection: string | number | undefined) => {
133+
const onStatusSelect = (event: ReactMouseEvent<Element, MouseEvent> | undefined, selection: string | number | undefined) => {
134134
const checked = (event?.target as HTMLInputElement).checked;
135135
setFilters({
136136
...filters,
@@ -139,9 +139,9 @@ export const ComposableTableWindowScroller = () => {
139139
setIsFilterDropdownOpen(false);
140140
};
141141

142-
const onNameInput = (event: React.SyntheticEvent<HTMLButtonElement> | React.KeyboardEvent) => {
142+
const onNameInput = (event: SyntheticEvent<HTMLButtonElement> | ReactKeyboardEvent) => {
143143
setIsCategoryDropdownOpen(false);
144-
const pressedKey = (event as React.KeyboardEvent).key;
144+
const pressedKey = (event as ReactKeyboardEvent).key;
145145
if (pressedKey && pressedKey !== 'Enter') {
146146
return;
147147
}
@@ -155,7 +155,7 @@ export const ComposableTableWindowScroller = () => {
155155
setIsCategoryDropdownOpen(false);
156156
};
157157

158-
const onLocationSelect = (_event: React.MouseEvent<Element, MouseEvent> | undefined, selection: string | number | undefined) => {
158+
const onLocationSelect = (_event: ReactMouseEvent<Element, MouseEvent> | undefined, selection: string | number | undefined) => {
159159
setFilters({ ...filters, location: [`${selection}`] });
160160

161161
setIsFilterDropdownOpen(false);
@@ -180,7 +180,7 @@ export const ComposableTableWindowScroller = () => {
180180
<Select
181181
onSelect={onCategorySelect}
182182
selected={currentCategory}
183-
toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
183+
toggle={(toggleRef: Ref<MenuToggleElement>) => (
184184
<MenuToggle
185185
ref={toggleRef}
186186
onClick={onCategoryToggle}
@@ -190,7 +190,7 @@ export const ComposableTableWindowScroller = () => {
190190
{
191191
width: '100%',
192192
verticalAlign: 'text-bottom'
193-
} as React.CSSProperties
193+
} as CSSProperties
194194
}
195195
>
196196
{currentCategory}
@@ -247,7 +247,7 @@ export const ComposableTableWindowScroller = () => {
247247
];
248248

249249
return (
250-
<React.Fragment>
250+
<Fragment>
251251
<ToolbarFilter
252252
labels={filters.location}
253253
deleteLabel={(category, chip) => onDelete(category, chip as string)}
@@ -260,7 +260,7 @@ export const ComposableTableWindowScroller = () => {
260260
selected={filters.location[0]}
261261
isOpen={isFilterDropdownOpen}
262262
popperProps={{ minWidth: '100px' }}
263-
toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
263+
toggle={(toggleRef: Ref<MenuToggleElement>) => (
264264
<MenuToggle
265265
ref={toggleRef}
266266
onClick={onFilterToggle}
@@ -269,7 +269,7 @@ export const ComposableTableWindowScroller = () => {
269269
{
270270
width: '100%',
271271
verticalAlign: 'text-bottom'
272-
} as React.CSSProperties
272+
} as CSSProperties
273273
}
274274
>
275275
{filters.location[0] || `Any`}
@@ -308,7 +308,7 @@ export const ComposableTableWindowScroller = () => {
308308
popperProps={{ minWidth: '100px' }}
309309
onSelect={onStatusSelect}
310310
selected={filters.status}
311-
toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
311+
toggle={(toggleRef: Ref<MenuToggleElement>) => (
312312
<MenuToggle
313313
ref={toggleRef}
314314
onClick={onFilterToggle}
@@ -317,7 +317,7 @@ export const ComposableTableWindowScroller = () => {
317317
{
318318
width: '100%',
319319
verticalAlign: 'text-bottom'
320-
} as React.CSSProperties
320+
} as CSSProperties
321321
}
322322
>
323323
Filter by status
@@ -328,7 +328,7 @@ export const ComposableTableWindowScroller = () => {
328328
{statusMenuItems}
329329
</Select>
330330
</ToolbarFilter>
331-
</React.Fragment>
331+
</Fragment>
332332
);
333333
};
334334

packages/module/patternfly-docs/content/examples/Selectable.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import React from 'react';
1+
import { FunctionComponent } from 'react';
2+
import { useState } from 'react';
23

34
import { CellMeasurerCache, CellMeasurer } from 'react-virtualized';
45
import { AutoSizer, VirtualTableBody } from '@patternfly/react-virtualized-extension';
56
import { Table, Thead, Tr, Th, Td, Caption, TableGridBreakpoint } from '@patternfly/react-table';
67

7-
export const SelectableTableVirtualized: React.FunctionComponent = () => {
8+
export const SelectableTableVirtualized: FunctionComponent = () => {
89
// this StringArray type is just needed because something in our documentation framework crashes when it encounters
910
// a string[][] type
1011
type StringArray = string[];
@@ -16,7 +17,7 @@ export const SelectableTableVirtualized: React.FunctionComponent = () => {
1617

1718
const selectableRepos = rows;
1819

19-
const [selectedRepoNames, setSelectedRepoNames] = React.useState<string[]>([]);
20+
const [selectedRepoNames, setSelectedRepoNames] = useState<string[]>([]);
2021

2122
const setRepoSelected = (repo: string, isSelecting = true) =>
2223
setSelectedRepoNames((prevSelected) => {
@@ -31,7 +32,7 @@ export const SelectableTableVirtualized: React.FunctionComponent = () => {
3132
const areAllReposSelected = selectedRepoNames.length === selectableRepos.length;
3233
const isRepoSelected = (repo: string) => selectedRepoNames.includes(repo);
3334

34-
const [recentSelectedRowIndex, setRecentSelectedRowIndex] = React.useState<number | null>(null);
35+
const [recentSelectedRowIndex, setRecentSelectedRowIndex] = useState<number | null>(null);
3536

3637
const onSelectRepo = (repo: string, rowIndex: number, isSelecting: boolean) => {
3738
if (recentSelectedRowIndex !== null) {

packages/module/patternfly-docs/content/examples/Sortable.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import React from 'react';
1+
import type { FunctionComponent } from 'react';
2+
import { useState } from 'react';
23
import { Caption, Table, Td, Th, Thead, ThProps, Tr } from '@patternfly/react-table';
34
import { CellMeasurerCache, CellMeasurer } from 'react-virtualized';
45
import { AutoSizer, VirtualTableBody } from '@patternfly/react-virtualized-extension';
56

6-
export const SortableExample: React.FunctionComponent = () => {
7+
export const SortableExample: FunctionComponent = () => {
78
const rows: { id: string; cells: string[] }[] = [];
89
for (let i = 0; i < 100; i++) {
910
rows.push({
@@ -14,10 +15,10 @@ export const SortableExample: React.FunctionComponent = () => {
1415

1516
const columns = ['Repositories', 'Branches', 'Pull requests', 'Workspaces', 'Last Commit'];
1617

17-
const [activeSortIndex, setActiveSortIndex] = React.useState<number>(-1);
18+
const [activeSortIndex, setActiveSortIndex] = useState<number>(-1);
1819

1920
// Sort direction of the currently sorted column
20-
const [activeSortDirection, setActiveSortDirection] = React.useState<'asc' | 'desc' | undefined>();
21+
const [activeSortDirection, setActiveSortDirection] = useState<'asc' | 'desc' | undefined>();
2122

2223
const getRowIndex = (str: string) => Number(str?.split('-')[1]);
2324

packages/module/patternfly-docs/content/examples/WindowScroller.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React from 'react';
1+
import { useState, useEffect } from 'react';
22
import { CellMeasurerCache, CellMeasurer } from 'react-virtualized';
33
import { AutoSizer, VirtualTableBody, WindowScroller } from '@patternfly/react-virtualized-extension';
44
import { Table, Thead, Tr, Th, Td, Caption, TableGridBreakpoint } from '@patternfly/react-table';
55

66
export const WindowScrollerExample = () => {
7-
const [scrollableElement, setScrollableElement] = React.useState<HTMLElement>();
8-
React.useEffect(() => {
7+
const [scrollableElement, setScrollableElement] = useState<HTMLElement>();
8+
useEffect(() => {
99
const scrollableElement = document.getElementById('content-scrollable-2') as HTMLElement;
1010
setScrollableElement(scrollableElement);
1111
}, []);

packages/module/patternfly-docs/generated/extensions/virtual-scroll-table/react.js

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/module/patternfly-docs/generated/extensions/virtual-scroll-window-scroller/react.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import { createElement, Fragment } from 'react';
22
import { AutoLinkHeader, Example, Link as PatternflyThemeLink } from '@patternfly/documentation-framework/components';
33
import { CellMeasurerCache, CellMeasurer } from 'react-virtualized';
44
import { AutoSizer, VirtualTableBody, WindowScroller } from '@patternfly/react-virtualized-extension';
@@ -185,7 +185,7 @@ pageData.examples = {
185185
};
186186

187187
const Component = () => (
188-
<React.Fragment>
188+
<Fragment>
189189
<p {...{"className":"pf-v6-c-content--p pf-m-editorial ws-p "}}>
190190
{`Note: React Virtualized Extension lives in its own package at `}
191191
<PatternflyThemeLink {...{"to":"https://www.npmjs.com/package/@patternfly/react-virtualized-extension","className":""}}>
@@ -207,8 +207,8 @@ This package is currently an extension. Extension components do not undergo the
207207
<AutoLinkHeader {...{"id":"examples","headingLevel":"h2","className":"ws-title ws-h2"}}>
208208
{`Examples`}
209209
</AutoLinkHeader>
210-
{React.createElement(pageData.examples["Window scroller"])}
211-
</React.Fragment>
210+
{createElement(pageData.examples["Window scroller"])}
211+
</Fragment>
212212
);
213213
Component.displayName = 'ExtensionsVirtualScrollWindowScrollerReactDocs';
214214
Component.pageData = pageData;

packages/module/patternfly-docs/generated/react.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import { createElement, Fragment } from 'react';
22
import { AutoLinkHeader, Example, Link as PatternflyThemeLink } from '@patternfly/documentation-framework/components';
33
import { ExtendedButton } from "@patternfly/react-virtualized-extension";
44
const pageData = {
@@ -45,13 +45,13 @@ pageData.examples = {
4545
};
4646

4747
const Component = () => (
48-
<React.Fragment>
48+
<Fragment>
4949
<AutoLinkHeader {...{"id":"basic-usage","size":"h2","className":"ws-title ws-h2"}}>
5050
{`Basic usage`}
5151
</AutoLinkHeader>
52-
{React.createElement(pageData.examples["Example"])}
53-
{React.createElement(pageData.examples["Fullscreen example"])}
54-
</React.Fragment>
52+
{createElement(pageData.examples["Example"])}
53+
{createElement(pageData.examples["Fullscreen example"])}
54+
</Fragment>
5555
);
5656
Component.displayName = 'ExtensionsPatternflyExtensionSeedReactDocs';
5757
Component.pageData = pageData;

0 commit comments

Comments
 (0)