diff --git a/package.json b/package.json index 5e21c3fb1..65bfde6e9 100644 --- a/package.json +++ b/package.json @@ -92,8 +92,8 @@ "lodash": "^4.17.21", "n3": "^1.26.0", "re-resizable": "^6.10.3", - "react": "^16.13.1", - "react-dom": "^16.14.0", + "react": "^18.2.0", + "react-dom": "^18.2.0", "react-flow-renderer": "9.7.4", "react-inlinesvg": "^3.0.3", "react-is": "^16.13.1", @@ -132,7 +132,7 @@ "@storybook/react-webpack5": "^8.6.14", "@storybook/test": "^8.6.14", "@testing-library/jest-dom": "^6.9.1", - "@testing-library/react": "^12.1.5", + "@testing-library/react": "^14.3.1", "@types/color": "^3.0.6", "@types/he": "^1.2.3", "@types/jest": "^30.0.0", @@ -179,7 +179,7 @@ "react": ">=16" }, "resolutions": { - "**/@types/react": "^17.0.90", + "**/@types/react": "^18.2.0", "node-sass-package-importer/**/postcss": "^8.5.6", "string-width": "^4.2.3", "wrap-ansi": "^7.0.0", diff --git a/src/cmem/ActivityControl/ActivityControlWidget.tsx b/src/cmem/ActivityControl/ActivityControlWidget.tsx index efda5060f..69d893652 100644 --- a/src/cmem/ActivityControl/ActivityControlWidget.tsx +++ b/src/cmem/ActivityControl/ActivityControlWidget.tsx @@ -27,16 +27,16 @@ export interface ActivityControlWidgetProps extends TestableComponent { /** * The label to be shown */ - label?: string | JSX.Element; + label?: string | React.JSX.Element; /** * Element that wraps around the label. * Default: `` */ - labelWrapper?: JSX.Element; + labelWrapper?: React.JSX.Element; /** * To add tags in addition to the widget status description */ - tags?: JSX.Element; + tags?: React.JSX.Element; /** * The progress bar parameters if it should be show by a progres bar */ @@ -80,7 +80,7 @@ export interface ActivityControlWidgetProps extends TestableComponent { /** * execution timer messages for waiting and running times. */ - timerExecutionMsg?: JSX.Element | null; + timerExecutionMsg?: React.JSX.Element | null; /** * additional actions that can serve as a complex component, positioned between the default actions and the context menu */ @@ -146,7 +146,7 @@ export function ActivityControlWidget(props: ActivityControlWidgetProps) { keepColors > {progressSpinnerFinishedIcon ? ( - React.cloneElement(progressSpinnerFinishedIcon as JSX.Element, { small, large: !small }) + React.cloneElement(progressSpinnerFinishedIcon as React.JSX.Element, { small, large: !small }) ) : ( any; // The error report - report: JSX.Element; + report: React.JSX.Element; // Value of the download button downloadButtonValue: string; // Value of the close button diff --git a/src/cmem/ActivityControl/SilkActivityControl.tsx b/src/cmem/ActivityControl/SilkActivityControl.tsx index 3997fe4e2..d4acac0e7 100644 --- a/src/cmem/ActivityControl/SilkActivityControl.tsx +++ b/src/cmem/ActivityControl/SilkActivityControl.tsx @@ -15,11 +15,11 @@ const progressBreakpointAnimation = 99; export interface SilkActivityControlProps extends TestableComponent { // The label of this activity - label: string | JSX.Element; + label: string | React.JSX.Element; /** * To add tags in addition to the widget status description */ - tags?: JSX.Element; + tags?: React.JSX.Element; // Initial state initialStatus?: SilkActivityStatusProps; // Register a function in order to receive callbacks @@ -80,7 +80,7 @@ export interface SilkActivityControlLayoutProps { // what type of progrss display should be uses, horizontal progress bar, circular spinner, or none of that visualization?: "none" | "progressbar" | "spinner"; // wrapper around label - labelWrapper?: JSX.Element; + labelWrapper?: React.JSX.Element; } const defaultLayout: SilkActivityControlLayoutProps = { @@ -94,7 +94,7 @@ interface IErrorReportAction { // The title of the error report modal title?: string; // The element that will be rendered in the modal, either as Markdown or object - renderReport: (report: string | SilkActivityExecutionReportProps) => JSX.Element; + renderReport: (report: string | SilkActivityExecutionReportProps) => React.JSX.Element; // What version of the report should be handed to the renderReport function, if false SilkActivityExecutionReportProps, if true the Markdown string renderMarkdown: boolean; // The function to fetch the error report. It returns undefined if something went wrong. diff --git a/src/cmem/ContentBlobToggler/StringPreviewContentBlobToggler.tsx b/src/cmem/ContentBlobToggler/StringPreviewContentBlobToggler.tsx index 374bb6529..e5ec7a796 100644 --- a/src/cmem/ContentBlobToggler/StringPreviewContentBlobToggler.tsx +++ b/src/cmem/ContentBlobToggler/StringPreviewContentBlobToggler.tsx @@ -31,7 +31,7 @@ export interface StringPreviewContentBlobTogglerProps * Allows to add non-string elements at the end of the content if the full description is shown, i.e. no toggler is necessary. * This allows to add non-string elements to both the full-view content and the pure string content. */ - noTogglerContentSuffix?: JSX.Element; + noTogglerContentSuffix?: React.JSX.Element; /** * If only the first non-empty line should be shown in the preview. * This will in addition also be shortened according to `previewMaxLength`. diff --git a/src/cmem/react-flow/configuration/graph.ts b/src/cmem/react-flow/configuration/graph.ts index e7abf6028..73489798d 100644 --- a/src/cmem/react-flow/configuration/graph.ts +++ b/src/cmem/react-flow/configuration/graph.ts @@ -1,8 +1,7 @@ +import { NodeProps } from "react-flow-renderer"; import { EdgeBezier } from "./../../../extensions/react-flow/edges/EdgeBezier"; import { NodeDefault } from "./../../../extensions/react-flow/nodes/NodeDefault"; import { GRAPH_NODE_TYPES } from "./typing"; -//import {ComponentType} from "react"; -//import {NodeProps} from "react-flow-renderer-lts"; const edgeTypes = { default: EdgeBezier, @@ -16,7 +15,7 @@ const edgeTypes = { danger: EdgeBezier, }; -const nodeTypes: Record*/> = { +const nodeTypes: Record> = { default: NodeDefault, graph: NodeDefault, class: NodeDefault, diff --git a/src/cmem/react-flow/configuration/linking.ts b/src/cmem/react-flow/configuration/linking.ts index 4a8326a78..f7bd55d74 100644 --- a/src/cmem/react-flow/configuration/linking.ts +++ b/src/cmem/react-flow/configuration/linking.ts @@ -2,8 +2,7 @@ import { EdgeStep } from "./../../../extensions/react-flow/edges/EdgeStep"; import { NodeDefault } from "./../../../extensions/react-flow/nodes/NodeDefault"; import { StickyNoteNode } from "./../nodes/StickyNoteNode"; import { LINKING_NODE_TYPES } from "./typing"; -//import {ComponentType} from "react"; -//import {NodeProps} from "react-flow-renderer-lts"; +import {NodeProps} from "react-flow-renderer"; const edgeTypes = { default: EdgeStep, @@ -14,7 +13,7 @@ const edgeTypes = { danger: EdgeStep, }; -const nodeTypes: Record*/> = { +const nodeTypes: Record /*& ComponentType*/> = { default: NodeDefault, sourcepath: NodeDefault, targetpath: NodeDefault, diff --git a/src/cmem/react-flow/configuration/workflow.ts b/src/cmem/react-flow/configuration/workflow.ts index 5a8621a89..508e64076 100644 --- a/src/cmem/react-flow/configuration/workflow.ts +++ b/src/cmem/react-flow/configuration/workflow.ts @@ -2,8 +2,7 @@ import { EdgeStep } from "./../../../extensions/react-flow/edges/EdgeStep"; import { NodeDefault } from "./../../../extensions/react-flow/nodes/NodeDefault"; import { StickyNoteNode } from "./../nodes/StickyNoteNode"; import { WORKFLOW_NODE_TYPES } from "./typing"; -//import {ComponentType} from "react"; -//import {NodeProps} from "react-flow-renderer-lts"; +import {NodeProps} from "react-flow-renderer"; const edgeTypes = { default: EdgeStep, @@ -12,7 +11,7 @@ const edgeTypes = { danger: EdgeStep, }; -const nodeTypes: Record*/> = { +const nodeTypes: Record> = { default: NodeDefault, dataset: NodeDefault, linking: NodeDefault, diff --git a/src/components/Accordion/AccordionItem.tsx b/src/components/Accordion/AccordionItem.tsx index 1c3b18a11..c63d6c6d7 100644 --- a/src/components/Accordion/AccordionItem.tsx +++ b/src/components/Accordion/AccordionItem.tsx @@ -18,7 +18,7 @@ export interface AccordionItemProps /** * header of accordion item */ - label: string | JSX.Element; + label: string | React.JSX.Element; /** * use full available width for content */ diff --git a/src/components/Application/ApplicationSidebarNavigation.tsx b/src/components/Application/ApplicationSidebarNavigation.tsx index c4c5e977d..0116eadf4 100644 --- a/src/components/Application/ApplicationSidebarNavigation.tsx +++ b/src/components/Application/ApplicationSidebarNavigation.tsx @@ -4,14 +4,18 @@ import { SideNav as CarbonSideNav, SideNavProps as CarbonSideNavProps } from "@c import { CLASSPREFIX as eccgui } from "../../configuration/constants"; export interface ApplicationSidebarNavigationProps - extends Omit, - React.HTMLAttributes {} + extends Omit { + children: React.ReactNode; + className?: string; + onToggle?: any //todo change later + } export const ApplicationSidebarNavigation = ({ children, className = "", ...otherCarbonSideNavProps }: ApplicationSidebarNavigationProps) => { + return ( {!!depiction && ( <> - {depiction} + + {React.isValidElement(depiction) + ? depiction + : depiction instanceof HTMLElement + ? <>{depiction.outerHTML} + : depiction} + )} {!!prefix && ( diff --git a/src/components/Application/stories/ColorPalettes.stories.tsx b/src/components/Application/stories/ColorPalettes.stories.tsx index ecee1e8df..e31d98d8b 100644 --- a/src/components/Application/stories/ColorPalettes.stories.tsx +++ b/src/components/Application/stories/ColorPalettes.stories.tsx @@ -1,8 +1,8 @@ import React from "react"; -import { render } from "react-dom"; import { loremIpsum } from "react-lorem-ipsum"; import { Meta, StoryFn } from "@storybook/react"; import Color from "color"; +import { createRoot } from 'react-dom/client'; import CssCustomProperties from "./../../../common/utils/CssCustomProperties"; import { @@ -194,10 +194,11 @@ const ColorPaletteConfigurator = ({ }, 0 as number); const warningsTarget = document.getElementById("sumWarnings"); if (warningsTarget) { + const warningsRoot = createRoot(warningsTarget) if (warnings > 0) { - render({warnings}, warningsTarget); + warningsRoot.render({warnings}); } else { - render(<>, warningsTarget); + warningsRoot.render(<>); } } } diff --git a/src/components/AutoSuggestion/AutoSuggestion.tsx b/src/components/AutoSuggestion/AutoSuggestion.tsx index 057164e29..9e956692b 100644 --- a/src/components/AutoSuggestion/AutoSuggestion.tsx +++ b/src/components/AutoSuggestion/AutoSuggestion.tsx @@ -124,10 +124,10 @@ export interface CodeAutocompleteFieldProps { */ useTabForCompletions?: boolean; /** An additional element that is put to the left side of the input field */ - leftElement?: JSX.Element | null; + leftElement?: React.JSX.Element | null; /** An additional element that is put to the right side of the input field */ - rightElement?: JSX.Element | null; + rightElement?: React.JSX.Element | null; /** Placeholder tobe shown when no text has been entered, yet. */ placeholder?: string; /** If the horizontal scrollbars should be shown. */ @@ -214,7 +214,7 @@ export const CodeAutocompleteField = ({ CodeAutocompleteFieldSuggestionWithReplacementInfo | undefined >(undefined); const [cm, setCM] = React.useState(); - const currentCm = React.useRef(); + const currentCm = React.useRef(undefined); currentCm.current = cm; const isFocused = React.useRef(false); const autoSuggestionDivRef = React.useRef(null); @@ -361,7 +361,7 @@ export const CodeAutocompleteField = ({ return { fromOffset, toOffset }; }; - const inputActionsDisplayed = React.useCallback((node) => { + const inputActionsDisplayed = React.useCallback((node:any) => { if (!node) return; const width = node.offsetWidth; const slCodeEditor = node.parentElement.getElementsByClassName(`${eccgui}-singlelinecodeeditor`); diff --git a/src/components/AutoSuggestion/AutoSuggestionList.tsx b/src/components/AutoSuggestion/AutoSuggestionList.tsx index ff524fad3..eb6889cb9 100644 --- a/src/components/AutoSuggestion/AutoSuggestionList.tsx +++ b/src/components/AutoSuggestion/AutoSuggestionList.tsx @@ -88,7 +88,7 @@ export const AutoSuggestionList = ({ }: AutoSuggestionListProps) => { const [hoveredItem, setHoveredItem] = React.useState(undefined); // Refs of list items - const [refs] = React.useState[]>([]); + const [refs] = React.useState[]>([]); const dropdownRef = React.useRef(null); const generateRef = (index: number) => { if (!refs[index]) { diff --git a/src/components/AutocompleteField/AutoCompleteField.tsx b/src/components/AutocompleteField/AutoCompleteField.tsx index 02f6a5613..8b64610e2 100644 --- a/src/components/AutocompleteField/AutoCompleteField.tsx +++ b/src/components/AutocompleteField/AutoCompleteField.tsx @@ -64,7 +64,7 @@ export interface SuggestFieldProps { query: string, modifiers: SuggestFieldItemRendererModifierProps, handleClick: () => any - ): string | JSX.Element; + ): string | React.JSX.Element; /** Renders the string that should be displayed in the input field after the item has been selected. */ @@ -122,7 +122,7 @@ export interface SuggestFieldProps { query: string, modifiers: SuggestFieldItemRendererModifierProps, handleClick: React.MouseEventHandler - ) => JSX.Element | undefined; + ) => React.JSX.Element | undefined; /** If the new item option will always be shown as the first entry in the suggestion list, else it will be the last entry. * @default false @@ -160,19 +160,10 @@ export interface SuggestFieldProps { loadMoreResults?: () => Promise; } -SuggestField.defaultProps = { - autoFocus: false, - disabled: false, - onlyDropdownWithQuery: false, // FIXME: this should be `true` by default, otherwise similarity to `