Skip to content

Commit

Permalink
[bot] migrate files
Browse files Browse the repository at this point in the history
  • Loading branch information
grit-app[bot] committed Nov 3, 2023
1 parent 515452c commit 5548a60
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 191 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import React, { PureComponent } from 'react';
import React from 'react';
import { isDefined } from '../utils';

function checkNumber(input: unknown): input is number {
Expand All @@ -38,36 +38,36 @@ type Props = {
width: number;
};

export default class ChartFrame extends PureComponent<Props, {}> {
static defaultProps = {
renderContent() {},
const ChartFrame = (inputProps: Props) => {
const props = {
renderContent: function () {},

Check failure on line 43 in superset-frontend/packages/superset-ui-core/src/chart-composition/ChartFrame.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

Expected method shorthand

Check failure on line 43 in superset-frontend/packages/superset-ui-core/src/chart-composition/ChartFrame.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

Expected method shorthand

Check failure on line 43 in superset-frontend/packages/superset-ui-core/src/chart-composition/ChartFrame.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

Expected method shorthand
...inputProps,
};

render() {
const { contentWidth, contentHeight, width, height, renderContent } =
this.props;
const { contentWidth, contentHeight, width, height, renderContent } = props;

const overflowX = checkNumber(contentWidth) && contentWidth > width;
const overflowY = checkNumber(contentHeight) && contentHeight > height;
const overflowX = checkNumber(contentWidth) && contentWidth > width;
const overflowY = checkNumber(contentHeight) && contentHeight > height;

if (overflowX || overflowY) {
return (
<div
style={{
height,
overflowX: overflowX ? 'auto' : 'hidden',
overflowY: overflowY ? 'auto' : 'hidden',
width,
}}
>
{renderContent({
height: Math.max(contentHeight ?? 0, height),
width: Math.max(contentWidth ?? 0, width),
})}
</div>
);
}

return renderContent({ height, width });
if (overflowX || overflowY) {
return (
<div
style={{
height,
overflowX: overflowX ? 'auto' : 'hidden',
overflowY: overflowY ? 'auto' : 'hidden',
width,
}}
>
{renderContent({
height: Math.max(contentHeight ?? 0, height),
width: Math.max(contentWidth ?? 0, width),
})}
</div>
);
}
}

return renderContent({ height, width });
};

export default ChartFrame;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import React, { PureComponent } from 'react';
import React from 'react';

const defaultProps = {
className: '',
Expand All @@ -30,18 +30,19 @@ type Props = {

const CONTAINER_STYLE = { padding: 8 };

class TooltipFrame extends PureComponent<Props, {}> {
static defaultProps = defaultProps;
const TooltipFrame = (inputProps: Props) => {
const props = {
...defaultProps,
...inputProps,
};

render() {
const { className, children } = this.props;
const { className, children } = props;

return (
<div className={className} style={CONTAINER_STYLE}>
{children}
</div>
);
}
}
return (
<div className={className} style={CONTAINER_STYLE}>
{children}
</div>
);
};

export default TooltipFrame;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import React, { CSSProperties, PureComponent, ReactNode } from 'react';
import { CSSProperties, ReactNode } from 'react';

interface TooltipRowData {
key: string | number;
Expand All @@ -39,31 +39,34 @@ type Props = {

const VALUE_CELL_STYLE: CSSProperties = { paddingLeft: 8, textAlign: 'right' };

export default class TooltipTable extends PureComponent<Props, {}> {
static defaultProps = defaultProps;
const TooltipTable = (inputProps: Props) => {
const props = {
...defaultProps,
...inputProps,
};

render() {
const { className, data } = this.props;
const { className, data } = props;

return (
<table className={className}>
<tbody>
{data.map(({ key, keyColumn, keyStyle, valueColumn, valueStyle }) => (
<tr key={key}>
<td style={keyStyle}>{keyColumn ?? key}</td>
<td
style={
valueStyle
? { ...VALUE_CELL_STYLE, ...valueStyle }
: VALUE_CELL_STYLE
}
>
{valueColumn}
</td>
</tr>
))}
</tbody>
</table>
);
}
}
return (
<table className={className}>

Check failure on line 51 in superset-frontend/packages/superset-ui-core/src/chart-composition/tooltip/TooltipTable.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

'React' must be in scope when using JSX

Check failure on line 51 in superset-frontend/packages/superset-ui-core/src/chart-composition/tooltip/TooltipTable.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

'React' must be in scope when using JSX

Check failure on line 51 in superset-frontend/packages/superset-ui-core/src/chart-composition/tooltip/TooltipTable.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

'React' must be in scope when using JSX
<tbody>

Check failure on line 52 in superset-frontend/packages/superset-ui-core/src/chart-composition/tooltip/TooltipTable.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

'React' must be in scope when using JSX

Check failure on line 52 in superset-frontend/packages/superset-ui-core/src/chart-composition/tooltip/TooltipTable.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

'React' must be in scope when using JSX

Check failure on line 52 in superset-frontend/packages/superset-ui-core/src/chart-composition/tooltip/TooltipTable.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

'React' must be in scope when using JSX
{data.map(({ key, keyColumn, keyStyle, valueColumn, valueStyle }) => (
<tr key={key}>

Check failure on line 54 in superset-frontend/packages/superset-ui-core/src/chart-composition/tooltip/TooltipTable.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

'React' must be in scope when using JSX

Check failure on line 54 in superset-frontend/packages/superset-ui-core/src/chart-composition/tooltip/TooltipTable.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

'React' must be in scope when using JSX

Check failure on line 54 in superset-frontend/packages/superset-ui-core/src/chart-composition/tooltip/TooltipTable.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

'React' must be in scope when using JSX
<td style={keyStyle}>{keyColumn ?? key}</td>

Check failure on line 55 in superset-frontend/packages/superset-ui-core/src/chart-composition/tooltip/TooltipTable.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

'React' must be in scope when using JSX

Check failure on line 55 in superset-frontend/packages/superset-ui-core/src/chart-composition/tooltip/TooltipTable.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

'React' must be in scope when using JSX

Check failure on line 55 in superset-frontend/packages/superset-ui-core/src/chart-composition/tooltip/TooltipTable.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

'React' must be in scope when using JSX
<td

Check failure on line 56 in superset-frontend/packages/superset-ui-core/src/chart-composition/tooltip/TooltipTable.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

'React' must be in scope when using JSX

Check failure on line 56 in superset-frontend/packages/superset-ui-core/src/chart-composition/tooltip/TooltipTable.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

'React' must be in scope when using JSX

Check failure on line 56 in superset-frontend/packages/superset-ui-core/src/chart-composition/tooltip/TooltipTable.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

'React' must be in scope when using JSX
style={
valueStyle
? { ...VALUE_CELL_STYLE, ...valueStyle }
: VALUE_CELL_STYLE
}
>
{valueColumn}
</td>
</tr>
))}
</tbody>
</table>
);
};

export default TooltipTable;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import React, { ReactNode } from 'react';
import React, { ReactNode, useState, useCallback } from 'react';

export type Props = {
children: ReactNode;
Expand All @@ -28,34 +28,29 @@ type State = {
open: boolean;
};

export default class Expandable extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = { open: false };
this.handleToggle = this.handleToggle.bind(this);
}

handleToggle() {
this.setState(({ open }) => ({ open: !open }));
}

render() {
const { open } = this.state;
const { children, expandableWhat } = this.props;

return (
<div>
<button
type="button"
className="btn btn-primary btn-sm"
onClick={this.handleToggle}
>
{`${open ? 'Hide' : 'Show'} ${expandableWhat}`}
</button>
<br />
<br />
{open ? children : null}
</div>
);
}
}
const Expandable = (props: Props) => {
const [open, setOpen] = useState(false);

const handleToggleHandler = useCallback(() => {
setOpen(open => !open);
}, [open]);

const { children, expandableWhat } = props;

return (
<div>
<button
type="button"
className="btn btn-primary btn-sm"
onClick={handleToggleHandler}
>
{`${open ? 'Hide' : 'Show'} ${expandableWhat}`}
</button>
<br />
<br />
{open ? children : null}
</div>
);
};

export default Expandable;
Loading

0 comments on commit 5548a60

Please sign in to comment.