{
const originalChild = child as React.ReactElement;
if (originalChild && originalChild.type && originalChild.type === PropertyValuePair) {
- return React.cloneElement(originalChild, { singleColumn: true });
+ return React.cloneElement(originalChild as React.ReactElement<{singleColumn: boolean}>, { singleColumn: true });
}
return child;
})
diff --git a/src/components/PropertyValuePair/PropertyValuePair.tsx b/src/components/PropertyValuePair/PropertyValuePair.tsx
index d26f3493e..988880d9a 100644
--- a/src/components/PropertyValuePair/PropertyValuePair.tsx
+++ b/src/components/PropertyValuePair/PropertyValuePair.tsx
@@ -37,7 +37,7 @@ export const PropertyValuePair = ({
? React.Children.map(children, (child) => {
const originalChild = child as React.ReactElement;
if (originalChild.type && (originalChild.type === PropertyName || originalChild.type === PropertyValue)) {
- return React.cloneElement(originalChild, { nowrap: true });
+ return React.cloneElement(originalChild as React.ReactElement<{nowrap: boolean}>, { nowrap: true });
}
return child;
})
diff --git a/src/components/Skeleton/Skeleton.tsx b/src/components/Skeleton/Skeleton.tsx
index 0cb017bb7..a92147614 100644
--- a/src/components/Skeleton/Skeleton.tsx
+++ b/src/components/Skeleton/Skeleton.tsx
@@ -6,7 +6,7 @@ export interface SkeletonProps {
/**
* Element that need to displayed using the skeleton styles.
*/
- children: JSX.Element | JSX.Element[];
+ children: React.JSX.Element | React.JSX.Element[];
}
/**
@@ -15,7 +15,7 @@ export interface SkeletonProps {
*/
export function Skeleton({ children }: SkeletonProps) {
const alteredChildren = React.Children.map(children, (child) => {
- const originalChild = child as React.ReactElement;
+ const originalChild = child as React.ReactElement<{className: string, disabled: boolean, tabIndex: number}>;
if (originalChild.props) {
return React.cloneElement(originalChild, {
className: originalChild.props.className ? originalChild.props.className + " " + SKELETON : SKELETON,
diff --git a/src/components/Structure/TitleSubsection.tsx b/src/components/Structure/TitleSubsection.tsx
index baddb725e..b60b588ca 100644
--- a/src/components/Structure/TitleSubsection.tsx
+++ b/src/components/Structure/TitleSubsection.tsx
@@ -6,7 +6,7 @@ export interface TitleSubsectionProps extends React.HTMLAttributes
/**
* HTML tag to use for element. As default element `h3` is used for a string as children, otherwise `div`.
*/
- useHtmlElement?: keyof JSX.IntrinsicElements;
+ useHtmlElement?: keyof React.JSX.IntrinsicElements;
}
export const TitleSubsection = ({ children, className = "", useHtmlElement, ...restProps }: TitleSubsectionProps) => {
diff --git a/src/components/Table/Table.tsx b/src/components/Table/Table.tsx
index 0f2e9b828..4e1d11729 100644
--- a/src/components/Table/Table.tsx
+++ b/src/components/Table/Table.tsx
@@ -50,7 +50,7 @@ export function Table({
children,
...otherCarbonTableProps
}: TableProps) {
- let colLayout: boolean | JSX.Element = false;
+ let colLayout: boolean | React.JSX.Element = false;
if (!!columnWidths && columnWidths.length > 0) {
colLayout = (
diff --git a/src/components/Table/TableContainer.tsx b/src/components/Table/TableContainer.tsx
index 8e91322c1..aadc4ecfb 100644
--- a/src/components/Table/TableContainer.tsx
+++ b/src/components/Table/TableContainer.tsx
@@ -19,14 +19,14 @@ export interface TableDataContainerProps
>,
"size" | "overflowMenuOnHover" | "stickyHeader" | "useStaticWidth"
>,
- React.TableHTMLAttributes {
- children(signature: any): JSX.Element;
+ Omit, "children"> {
+ children(signature: any): React.JSX.Element;
size?: TableProps["size"];
}
export interface TableSimpleContainerProps
extends Omit,
React.HTMLAttributes {
- children?: JSX.Element;
+ children?: React.JSX.Element;
}
export type TableContainerProps = TableDataContainerProps | TableSimpleContainerProps;
@@ -46,7 +46,7 @@ export function TableContainer({ className = "", ...otherProps }: TableContainer
/>
) : (
-
+
);
}
diff --git a/src/components/Tabs/TabTitle.tsx b/src/components/Tabs/TabTitle.tsx
index 2088ec587..d1583c8d3 100644
--- a/src/components/Tabs/TabTitle.tsx
+++ b/src/components/Tabs/TabTitle.tsx
@@ -29,7 +29,7 @@ export interface TabTitleProps {
/**
* Add a tooltip to a tab, displayed when user hoveres over it.
*/
- tooltip?: string | JSX.Element;
+ tooltip?: string | React.JSX.Element;
/**
* Make the tab not usable, display is also narrowed.
*/
diff --git a/src/components/TextField/TextArea.tsx b/src/components/TextField/TextArea.tsx
index 52c463ca0..f7fcd7c66 100644
--- a/src/components/TextField/TextArea.tsx
+++ b/src/components/TextField/TextArea.tsx
@@ -32,7 +32,7 @@ export interface TextAreaProps extends Omit {
* Element to render on right side of text area. Should be not too large.
* This will update right padding on the text area.
*/
- rightElement?: JSX.Element;
+ rightElement?: React.JSX.Element;
/**
* Add HTML properties to the wrapper element.
* The element wraps `TextArea` in case of a given `wrapperDivProps`, `leftIcon` or `rightElement` property.
diff --git a/src/components/Tooltip/Tooltip.tsx b/src/components/Tooltip/Tooltip.tsx
index 7a3108f7e..8934f9d79 100644
--- a/src/components/Tooltip/Tooltip.tsx
+++ b/src/components/Tooltip/Tooltip.tsx
@@ -123,7 +123,7 @@ export const Tooltip = ({
return () => {};
}, [!!placeholderRef.current]);
- const refocus = React.useCallback((node) => {
+ const refocus = React.useCallback((node:any) => {
if (eventMemory.current && node) {
// we do not have a `targetRef` here, so we need to workaround it
// const target = node.targetRef.current.children[0];
diff --git a/src/extensions/codemirror/CodeMirror.tsx b/src/extensions/codemirror/CodeMirror.tsx
index 1fb523539..b74cc896c 100644
--- a/src/extensions/codemirror/CodeMirror.tsx
+++ b/src/extensions/codemirror/CodeMirror.tsx
@@ -227,7 +227,7 @@ export const CodeEditor = ({
}: CodeEditorProps) => {
const parent = useRef(undefined);
const [view, setView] = React.useState();
- const currentView = React.useRef()
+ const currentView = React.useRef(undefined)
currentView.current = view
const currentReadOnly = React.useRef(readOnly)
currentReadOnly.current = readOnly
@@ -461,7 +461,7 @@ export const CodeEditor = ({
const hasToolbarSupport = mode && ModeToolbarSupport.indexOf(mode) > -1 && useToolbar;
- const editorToolbar = (mode?: SupportedCodeEditorModes): JSX.Element => {
+ const editorToolbar = (mode?: SupportedCodeEditorModes): React.JSX.Element => {
switch (mode) {
case "markdown":
return (
diff --git a/src/extensions/react-flow/edges/EdgeLabel.tsx b/src/extensions/react-flow/edges/EdgeLabel.tsx
index 767146a21..41f4a2f8b 100644
--- a/src/extensions/react-flow/edges/EdgeLabel.tsx
+++ b/src/extensions/react-flow/edges/EdgeLabel.tsx
@@ -14,11 +14,11 @@ export interface EdgeLabelProps extends React.HTMLAttributes {
* Label of the edge.
* Cannot overflow the parent container.
*/
- text: string | JSX.Element;
+ text: string | React.JSX.Element;
/**
* One or multiple other elements displayed right from label.
*/
- actions?: JSX.Element | JSX.Element[];
+ actions?: React.JSX.Element | React.JSX.Element[];
/**
* The element is increased in its size.
*/
@@ -109,7 +109,7 @@ export interface EdgeLabelObjectProps extends React.SVGAttributes {
const containerCallback = React.useCallback(
- (containerRef) => {
+ (containerRef:any) => {
if (containerRef) labelSize(containerRef);
},
[edgeCenter]
diff --git a/src/extensions/react-flow/edges/EdgeTools.tsx b/src/extensions/react-flow/edges/EdgeTools.tsx
index f5544a887..31cbc4079 100644
--- a/src/extensions/react-flow/edges/EdgeTools.tsx
+++ b/src/extensions/react-flow/edges/EdgeTools.tsx
@@ -13,7 +13,7 @@ interface PosOffset {
export interface EdgeToolsProps extends Omit {
posOffset: PosOffset;
- children: string | JSX.Element | JSX.Element[];
+ children: string | React.JSX.Element | React.JSX.Element[];
}
export const EdgeTools = memo(({ posOffset, children, ...otherProps }: EdgeToolsProps) => {
diff --git a/src/extensions/react-flow/handles/HandleContent.tsx b/src/extensions/react-flow/handles/HandleContent.tsx
index f18f3cf3b..7738195b3 100644
--- a/src/extensions/react-flow/handles/HandleContent.tsx
+++ b/src/extensions/react-flow/handles/HandleContent.tsx
@@ -7,7 +7,7 @@ export interface HandleContentProps extends Omit,
TestableComponent {
- children: string | JSX.Element | JSX.Element[];
+ children: string | React.JSX.Element | React.JSX.Element[];
}
export const HandleTools = ({ children, ...otherContextOverlayProps }: HandleToolsProps) => {
diff --git a/src/extensions/react-flow/markers/ReactFlowMarkers.tsx b/src/extensions/react-flow/markers/ReactFlowMarkers.tsx
index 2f99a0c08..82cdd1137 100644
--- a/src/extensions/react-flow/markers/ReactFlowMarkers.tsx
+++ b/src/extensions/react-flow/markers/ReactFlowMarkers.tsx
@@ -47,7 +47,7 @@ const ReactFlowMarker = ({ className, appearance = "arrow-closed", intent, rever
refY="0"
orient={reverse ? "auto-start-reverse" : "auto"}
>
- {markerDisplay[appearance]}
+ {markerDisplay[appearance] as React.ReactNode}
);
};
diff --git a/src/extensions/react-flow/nodes/NodeContent.tsx b/src/extensions/react-flow/nodes/NodeContent.tsx
index ea7201808..67b6d712c 100644
--- a/src/extensions/react-flow/nodes/NodeContent.tsx
+++ b/src/extensions/react-flow/nodes/NodeContent.tsx
@@ -62,15 +62,15 @@ interface NodeContentData {
/**
* Any element that should be displayed as depiction before the node label.
*/
- leftElement?: JSX.Element;
+ leftElement?: React.JSX.Element;
/**
* Label that is displayed in the node header.
*/
- label: string | JSX.Element;
+ label: string | React.JSX.Element;
/**
* Element that is displayed as subline under the label in the header.
*/
- labelSubline?: JSX.Element;
+ labelSubline?: React.JSX.Element;
/**
* Content element, displayed in the node body.
*/
@@ -386,7 +386,7 @@ export function NodeContent>({
console.error(error);
}
const [adjustedContentProps, setAdjustedContentProps] = React.useState>({});
- const nodeContentRef = React.useRef();
+ const nodeContentRef = React.useRef(undefined);
const handleStack: Record = {
[Position.Top]: [],
@@ -735,7 +735,7 @@ export function NodeContent>({
return validatedHeight;
};
- const onResize = React.useCallback((_0, _1, _2, d) => {
+ const onResize = React.useCallback((_0:any, _1:any, _2:any, d:any) => {
if (nodeContentRef.current) {
const nextWidth = resizeDirections.right
? (width ?? originalSize.current.width ?? 0) + d.width
@@ -756,7 +756,7 @@ export function NodeContent>({
}
}, [resizeDirections, originalSize, width, height])
- const onResizeStop = React.useCallback((_0, _1, _2, d) => {
+ const onResizeStop = React.useCallback((_0:any, _1:any, _2:any, d:any) => {
const nextWidth = validateWidth((width ?? originalSize.current.width ?? 0) + d.width);
const nextHeight = validateHeight((height ?? originalSize.current.height ?? 0) + d.height);
setWidth(nextWidth);
diff --git a/src/extensions/react-flow/nodes/NodeTools.tsx b/src/extensions/react-flow/nodes/NodeTools.tsx
index 6db7cdbaf..970f3a0ca 100644
--- a/src/extensions/react-flow/nodes/NodeTools.tsx
+++ b/src/extensions/react-flow/nodes/NodeTools.tsx
@@ -14,8 +14,8 @@ export interface NodeToolsMenuFunctions {
}
export interface NodeToolsProps extends Omit {
- children: string | JSX.Element;
- togglerElement?: ValidIconName | JSX.Element;
+ children: string | React.JSX.Element;
+ togglerElement?: ValidIconName | React.JSX.Element;
togglerText?: string;
menuButtonDataTestId?: string;
/** If defined this function will be called with the menu API object to be used externally. */
diff --git a/src/legacy-replacements/Tabs/Tabs.tsx b/src/legacy-replacements/Tabs/Tabs.tsx
new file mode 100644
index 000000000..dd877862c
--- /dev/null
+++ b/src/legacy-replacements/Tabs/Tabs.tsx
@@ -0,0 +1,69 @@
+import React from "react";
+import { Tab, Tabs as BlueprintTabs, TabsProps as BlueprintTabsProps } from "@blueprintjs/core";
+
+import { CLASSPREFIX as eccgui } from "../../configuration/constants";
+
+// legacy interface
+interface LegacyTabsProps extends Omit {
+ activeTab: string;
+ tabs: DeprecatedTabProps[];
+ onTabClick?: ({ props }: any) => void;
+ prefixTabNames: string;
+ allowScrollbars?: boolean;
+ /**
+ * If controlled usage is enable then a `onTabClick` handler is ncessary to control tab panel content and `activeTab` updates.
+ */
+ controlled?: boolean;
+}
+
+/** @deprecated (v25) all legacy component support will be removed */
+export interface DeprecatedTabProps {
+ tabId: string;
+ tabTitle: React.ReactNode;
+ tabContent?: React.JSX.Element;
+ dontShrink?: boolean;
+ className?: string;
+}
+
+const createDeprecatedTab = ({
+ tabId,
+ tabTitle,
+ tabContent,
+ dontShrink = false,
+ ...otherTabProps
+}: DeprecatedTabProps) => {
+ const extraStyles = dontShrink ? { style: { flexShrink: 0 } } : {};
+ return ;
+};
+
+/** @deprecated (v25) all legacy component support will be removed, switch to `` */
+export function TabsReplacement({
+ activeTab,
+ tabs = [],
+ onTabClick,
+ controlled = false,
+ prefixTabNames,
+ className = "",
+ allowScrollbars,
+ ...restProps
+}: LegacyTabsProps) {
+ const usagetype = controlled ? { selectedTabId: activeTab } : { defaultSelectedTabId: activeTab };
+ return (
+
+ {tabs.map((tab) => {
+ return createDeprecatedTab({
+ className: `${prefixTabNames}-header-${tab.tabId}`,
+ ...tab,
+ });
+ })}
+
+ );
+}