Skip to content

Commit 48d8cb2

Browse files
fix(signature-web): update react imports and fix eslint warnings
1 parent 8c8a059 commit 48d8cb2

File tree

7 files changed

+15
-17
lines changed

7 files changed

+15
-17
lines changed
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import { createElement, FC, PropsWithChildren } from "react";
1+
import { FC, PropsWithChildren } from "react";
22
import classNames from "classnames";
33

44
export interface AlertProps extends PropsWithChildren {
55
bootstrapStyle?: "default" | "primary" | "success" | "info" | "warning" | "danger";
66
className?: string;
77
}
88

9-
export const Alert: FC<AlertProps> = ({ bootstrapStyle, className, children }) =>
9+
export const Alert: FC<AlertProps> = ({ bootstrapStyle = "danger", className, children }) =>
1010
children ? <div className={classNames(`alert alert-${bootstrapStyle}`, className)}>{children}</div> : null;
1111

1212
Alert.displayName = "Alert";
13-
Alert.defaultProps = { bootstrapStyle: "danger" };

packages/customWidgets/signature-web/src/components/Grid.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createElement, FC } from "react";
1+
import { FC } from "react";
22

33
export interface GridBackgroundProps {
44
gridCellWidth: number;
@@ -12,7 +12,7 @@ export const Grid: FC<GridBackgroundProps> = ({
1212
gridCellHeight,
1313
gridBorderColor,
1414
gridBorderWidth,
15-
showGrid
15+
showGrid = true
1616
}) => {
1717
const id = `grid${Math.floor(Math.random() * 1000000)}`;
1818
return showGrid ? (
@@ -43,4 +43,3 @@ export const Grid: FC<GridBackgroundProps> = ({
4343
};
4444

4545
Grid.displayName = "Grid";
46-
Grid.defaultProps = { showGrid: true };

packages/customWidgets/signature-web/src/components/Signature.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { createElement, PureComponent, ReactNode } from "react";
1+
import { PureComponent, ReactNode } from "react";
22

3-
// @ts-ignore
3+
// @ts-expect-error signature_pad has no types
44
import SignaturePad, { IOptions } from "signature_pad";
55
import classNames from "classnames";
66
import ReactResizeDetector from "react-resize-detector";
@@ -31,7 +31,7 @@ export type penOptions = "fountain" | "ballpoint" | "marker";
3131

3232
export class Signature extends PureComponent<SignatureProps> {
3333
private canvasNode: HTMLCanvasElement | null = null;
34-
// @ts-expect-error
34+
// @ts-expect-error signature_pad has no types
3535
private signaturePad: SignaturePad;
3636

3737
render(): ReactNode {
@@ -48,7 +48,9 @@ export class Signature extends PureComponent<SignatureProps> {
4848
<Grid {...this.props} />
4949
<canvas
5050
className="widget-signature-canvas"
51-
ref={(node: HTMLCanvasElement) => (this.canvasNode = node)}
51+
ref={(node: HTMLCanvasElement | null): void => {
52+
this.canvasNode = node;
53+
}}
5254
/>
5355
<ReactResizeDetector handleWidth handleHeight onResize={this.onResize} />
5456
</SizeContainer>

packages/customWidgets/signature-web/src/components/SizeContainer.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const SizeContainer: FC<SizeProps> = ({
2828
height,
2929
children,
3030
style,
31-
readOnly
31+
readOnly = false
3232
}) => {
3333
const styleWidth = widthUnit === "percentage" ? `${width}%` : `${width}px`;
3434
return createElement(
@@ -62,7 +62,6 @@ export const SizeContainer: FC<SizeProps> = ({
6262
};
6363

6464
SizeContainer.displayName = "SizeContainer";
65-
SizeContainer.defaultProps = { readOnly: false };
6665

6766
const getHeight = (
6867
heightUnit: HeightUnitType,

packages/customWidgets/signature-web/src/components/__tests__/Alert.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { shallow, ShallowWrapper } from "enzyme";
2-
import { createElement, ReactChild } from "react";
2+
import { createElement, ReactNode } from "react";
33

44
import { Alert, AlertProps } from "../Alert";
55

66
describe("Alert", () => {
7-
const renderAlert = (props: AlertProps, message: ReactChild): ShallowWrapper<AlertProps, any> =>
7+
const renderAlert = (props: AlertProps, message: ReactNode): ShallowWrapper<AlertProps, any> =>
88
shallow(createElement(Alert, props, message));
99
const alertMessage = "This is an error";
1010

packages/customWidgets/signature-web/src/components/__tests__/Signature.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe("Signature", () => {
4141
});
4242
const canvasInstance: any = canvas.instance();
4343
canvasInstance.canvasNode = document.createElement("canvas");
44-
const signaturePadOptions = spyOn(canvasInstance, "signaturePadOptions").and.callThrough();
44+
const signaturePadOptions = jest.spyOn(canvasInstance, "signaturePadOptions");
4545
canvasInstance.componentDidMount();
4646
expect(signaturePadOptions).toHaveBeenCalled();
4747
});

packages/customWidgets/signature-web/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
"noUnusedParameters": true,
2121
"allowSyntheticDefaultImports": true,
2222
"esModuleInterop": true,
23-
"jsx": "react",
24-
"jsxFactory": "createElement"
23+
"jsx": "react-jsx"
2524
},
2625
"files": ["./node_modules/mendix-client/index.d.ts"],
2726
"include": ["./src", "./typings"],

0 commit comments

Comments
 (0)