Skip to content

Commit 76e4911

Browse files
chore(React19): Enable React 19 (#533)
1 parent 52dc5c8 commit 76e4911

File tree

172 files changed

+699
-743
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+699
-743
lines changed

.eslintrc.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"dot-notation": "error",
6363
"eqeqeq": ["error", "smart"],
6464
"guard-for-in": "error",
65-
"indent": ["error", 2, {"SwitchCase": 1}],
65+
"indent": ["error", 2, { "SwitchCase": 1 }],
6666
"max-classes-per-file": ["error", 1],
6767
"no-nested-ternary": "error",
6868
"no-bitwise": "error",
@@ -94,6 +94,7 @@
9494
"react-hooks/exhaustive-deps": "warn",
9595
"react/no-unescaped-entities": ["error", { "forbid": [">", "}"] }],
9696
"spaced-comment": "error",
97-
"use-isnan": "error"
97+
"use-isnan": "error",
98+
"react/react-in-jsx-scope": "off"
9899
}
99100
}

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# PatternFly ChatBot
2-
2+
33
This PatternFly extension library provides components based on PatternFly 6 that can be used to build chatbots.
44

55
---
@@ -30,7 +30,7 @@ import '@patternfly/chatbot/dist/css/main.css';
3030
#### Example component:
3131

3232
```
33-
import * as React from 'react';
33+
import type { FunctionComponent } from 'react';
3434
import { Text } from '@patternfly/react-core';
3535
3636
// do not forget to export your component's interface
@@ -40,7 +40,7 @@ export interface MyComponentProps {
4040
4141
4242
// do not use the named export of your component, just a default one
43-
const MyComponent: React.FunctionComponent<MyComponentProps> = () => {
43+
const MyComponent: FunctionComponent<MyComponentProps> = () => {
4444
4545
return (
4646
<Text>
@@ -83,7 +83,7 @@ export interface MyComponentProps extends ButtonProps {
8383
customLabel: Boolean
8484
};
8585
86-
export const MyComponent: React.FunctionComponent<MyComponentProps> = ({ customLabel, ...props }) => ( ... );
86+
export const MyComponent: FunctionComponent<MyComponentProps> = ({ customLabel, ...props }) => ( ... );
8787
```
8888

8989
#### Markdown file example:
@@ -115,9 +115,9 @@ MyComponent has been created to demo contributing to this repository.
115115
Note: You'll need to add any imports required here in the parent folder's markdown file as well.
116116

117117
```
118-
import React from 'react';
118+
import type { FunctionComponent } from 'react';
119119
120-
const MyComponentExample: React.FunctionComponent = () => (
120+
const MyComponentExample: FunctionComponent = () => (
121121
<MyComponent customLabel="My label">
122122
);
123123

package-lock.json

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

packages/module/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,15 @@
4848
"path-browserify": "^1.0.1"
4949
},
5050
"peerDependencies": {
51-
"react": "^17 || ^18",
52-
"react-dom": "^17 || ^18"
51+
"react": "^17 || ^18 || ^19",
52+
"react-dom": "^17 || ^18 || ^19"
5353
},
5454
"devDependencies": {
5555
"@patternfly/documentation-framework": "6.8.2",
5656
"@patternfly/patternfly": "^6.1.0",
5757
"@patternfly/patternfly-a11y": "^5.0.0",
5858
"@types/dom-speech-recognition": "^0.0.4",
5959
"@types/react": "^18.2.61",
60-
"react": "^18.2.0",
61-
"react-dom": "^18.2.0",
6260
"rimraf": "^2.7.1",
6361
"typescript": "^5.3.3",
6462
"@octokit/rest": "^18.0.0",

packages/module/patternfly-docs/content/extensions/chatbot/examples/Messages/AttachMenu.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import { useState, isValidElement, cloneElement, Children, FunctionComponent, ReactNode } from 'react';
22
import AttachMenu from '@patternfly/chatbot/dist/dynamic/AttachMenu';
33
import SourceDetailsMenuItem from '@patternfly/chatbot/dist/dynamic/SourceDetailsMenuItem';
44
import { Button, Divider, DropdownGroup, DropdownItem, DropdownList } from '@patternfly/react-core';
@@ -63,27 +63,27 @@ const uploadMenuItems = [
6363
</DropdownList>
6464
];
6565

66-
export const AttachmentMenuExample: React.FunctionComponent = () => {
67-
const [isOpen, setIsOpen] = React.useState<boolean>(false);
68-
const [userFacingMenuItems, setUserFacingMenuItems] = React.useState<React.ReactNode>([]);
66+
export const AttachmentMenuExample: FunctionComponent = () => {
67+
const [isOpen, setIsOpen] = useState<boolean>(false);
68+
const [userFacingMenuItems, setUserFacingMenuItems] = useState<ReactNode>([]);
6969

7070
const onToggleClick = () => {
7171
setIsOpen(!isOpen);
7272
setUserFacingMenuItems(initialMenuItems.concat(uploadMenuItems));
7373
};
7474

75-
const findMatchingElements = (elements: React.ReactNode[], targetValue: string) => {
76-
let matchingElements = [] as React.ReactNode[];
75+
const findMatchingElements = (elements: ReactNode[], targetValue: string) => {
76+
let matchingElements = [] as ReactNode[];
7777

7878
elements.forEach((element) => {
79-
if (React.isValidElement(element)) {
79+
if (isValidElement(element)) {
8080
// Check if the element's value matches the targetValue
8181
if (element.props.value && element.props.value.toLowerCase().includes(targetValue.toLowerCase())) {
82-
matchingElements.push(React.cloneElement(element, { key: element.props.value }));
82+
matchingElements.push(cloneElement(element, { key: element.props.value }));
8383
}
8484

8585
// Recursively check the element's children
86-
const children = React.Children.toArray(element.props.children);
86+
const children = Children.toArray(element.props.children);
8787
matchingElements = matchingElements.concat(findMatchingElements(children, targetValue));
8888
}
8989
});

packages/module/patternfly-docs/content/extensions/chatbot/examples/Messages/AttachmentEdit.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import React from 'react';
1+
import { FunctionComponent, MouseEvent as ReactMouseEvent, useState } from 'react';
22
import { Button, Checkbox } from '@patternfly/react-core';
33
import { AttachmentEdit } from '@patternfly/chatbot/dist/dynamic/AttachmentEdit';
44

5-
export const AttachmentEditModalExample: React.FunctionComponent = () => {
6-
const [isModalOpen, setIsModalOpen] = React.useState(false);
7-
const [isCompact, setIsCompact] = React.useState(false);
5+
export const AttachmentEditModalExample: FunctionComponent = () => {
6+
const [isModalOpen, setIsModalOpen] = useState(false);
7+
const [isCompact, setIsCompact] = useState(false);
88

9-
const handleModalToggle = (_event: React.MouseEvent | MouseEvent | KeyboardEvent) => {
9+
const handleModalToggle = (_event: ReactMouseEvent | MouseEvent | KeyboardEvent) => {
1010
setIsModalOpen(!isModalOpen);
1111
};
1212

packages/module/patternfly-docs/content/extensions/chatbot/examples/Messages/AttachmentError.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React from 'react';
1+
import { FunctionComponent } from 'react';
22
import ChatbotAlert from '@patternfly/chatbot/dist/dynamic/ChatbotAlert';
33

4-
export const AttachmentErrorExample: React.FunctionComponent = () => (
4+
export const AttachmentErrorExample: FunctionComponent = () => (
55
<ChatbotAlert
66
variant="danger"
77
// eslint-disable-next-line no-console

packages/module/patternfly-docs/content/extensions/chatbot/examples/Messages/BotMessage.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import { CSSProperties, useState, Fragment, FunctionComponent, MouseEvent, Ref } from 'react';
22
import Message from '@patternfly/chatbot/dist/dynamic/Message';
33
import patternflyAvatar from './patternfly_avatar.jpg';
44
import squareImg from './PF-social-color-square.svg';
@@ -11,10 +11,10 @@ import {
1111
SelectOption
1212
} from '@patternfly/react-core';
1313

14-
export const BotMessageExample: React.FunctionComponent = () => {
15-
const [variant, setVariant] = React.useState<string>('Code');
16-
const [isOpen, setIsOpen] = React.useState(false);
17-
const [selected, setSelected] = React.useState<string>('Message content type');
14+
export const BotMessageExample: FunctionComponent = () => {
15+
const [variant, setVariant] = useState<string>('Code');
16+
const [isOpen, setIsOpen] = useState(false);
17+
const [selected, setSelected] = useState<string>('Message content type');
1818

1919
/* eslint-disable indent */
2020
const renderContent = () => {
@@ -63,8 +63,6 @@ spec:
6363
Here is some JavaScript code:
6464
6565
~~~js
66-
import React from 'react';
67-
6866
const MessageLoading = () => (
6967
<div className="pf-chatbot__message-loading">
7068
<span className="pf-chatbot__message-loading-dots">
@@ -153,18 +151,18 @@ _Italic text, formatted with single underscores_
153151
title: 'Could not load chat',
154152
children: 'Wait a few minutes and check your network settings. If the issue persists: ',
155153
actionLinks: (
156-
<React.Fragment>
154+
<Fragment>
157155
<AlertActionLink component="a" href="#">
158156
Start a new chat
159157
</AlertActionLink>
160158
<AlertActionLink component="a" href="#">
161159
Contact support
162160
</AlertActionLink>
163-
</React.Fragment>
161+
</Fragment>
164162
)
165163
};
166164

167-
const onSelect = (_event: React.MouseEvent<Element, MouseEvent> | undefined, value: string | number | undefined) => {
165+
const onSelect = (_event: MouseEvent<Element, MouseEvent> | undefined, value: string | number | undefined) => {
168166
setVariant(value);
169167
setSelected(value as string);
170168
setIsOpen(false);
@@ -174,7 +172,7 @@ _Italic text, formatted with single underscores_
174172
setIsOpen(!isOpen);
175173
};
176174

177-
const toggle = (toggleRef: React.Ref<MenuToggleElement>) => (
175+
const toggle = (toggleRef: Ref<MenuToggleElement>) => (
178176
<MenuToggle
179177
className="pf-v6-u-mb-md"
180178
ref={toggleRef}
@@ -183,7 +181,7 @@ _Italic text, formatted with single underscores_
183181
style={
184182
{
185183
width: '200px'
186-
} as React.CSSProperties
184+
} as CSSProperties
187185
}
188186
>
189187
{selected}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import { FunctionComponent } from 'react';
22
import FileDetails from '@patternfly/chatbot/dist/dynamic/FileDetails';
33

4-
export const FileDetailsExample: React.FunctionComponent = () => <FileDetails fileName="test.yml" />;
4+
export const FileDetailsExample: FunctionComponent = () => <FileDetails fileName="test.yml" />;

packages/module/patternfly-docs/content/extensions/chatbot/examples/Messages/FileDetailsLabel.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import React from 'react';
1+
import { useState, FunctionComponent, MouseEvent, Ref, CSSProperties } from 'react';
22
import FileDetailsLabel from '@patternfly/chatbot/dist/dynamic/FileDetailsLabel';
33
import { Stack, MenuToggle, MenuToggleElement, Select, SelectList, SelectOption } from '@patternfly/react-core';
44

5-
export const FileDetailsLabelExample: React.FunctionComponent = () => {
6-
const [variant, setVariant] = React.useState<string>('plain');
7-
const [isOpen, setIsOpen] = React.useState<boolean>(false);
8-
const [selected, setSelected] = React.useState<string>('Variant');
5+
export const FileDetailsLabelExample: FunctionComponent = () => {
6+
const [variant, setVariant] = useState<string>('plain');
7+
const [isOpen, setIsOpen] = useState<boolean>(false);
8+
const [selected, setSelected] = useState<string>('Variant');
99

10-
const onSelect = (_event: React.MouseEvent<Element, MouseEvent> | undefined, value: string | number | undefined) => {
11-
setVariant(value);
10+
const onSelect = (_event: MouseEvent<Element, MouseEvent> | undefined, value: string | number | undefined) => {
11+
setVariant(value as string);
1212
setSelected(value as string);
1313
setIsOpen(false);
1414
};
@@ -17,15 +17,15 @@ export const FileDetailsLabelExample: React.FunctionComponent = () => {
1717
setIsOpen(!isOpen);
1818
};
1919

20-
const toggle = (toggleRef: React.Ref<MenuToggleElement>) => (
20+
const toggle = (toggleRef: Ref<MenuToggleElement>) => (
2121
<MenuToggle
2222
ref={toggleRef}
2323
onClick={onToggleClick}
2424
isExpanded={isOpen}
2525
style={
2626
{
2727
width: '200px'
28-
} as React.CSSProperties
28+
} as CSSProperties
2929
}
3030
>
3131
{selected}

0 commit comments

Comments
 (0)