Skip to content

Commit 0bfb8bf

Browse files
committed
Merge branch 'typescript' into develop
2 parents 01e3f49 + ec483a5 commit 0bfb8bf

28 files changed

+9037
-17094
lines changed

.babelrc

Lines changed: 0 additions & 16 deletions
This file was deleted.

.eslintrc.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,16 @@
1111
"version": "detect"
1212
}
1313
},
14-
"parser": "@babel/eslint-parser",
14+
"parser": "@typescript-eslint/parser",
1515
"parserOptions": {
1616
"ecmaVersion": 12,
1717
"sourceType": "module",
1818
"ecmaFeatures": {
1919
"jsx": true
20-
},
21-
"requireConfigFile": false,
22-
"babelOptions": {
23-
"presets": ["@babel/preset-react"]
2420
}
2521
},
2622
"plugins": [
23+
"@typescript-eslint",
2724
"import",
2825
"react",
2926
"jest"
@@ -33,6 +30,7 @@
3330
"plugin:react/recommended",
3431
"plugin:jest/recommended",
3532
"plugin:eslint-comments/recommended",
33+
"plugin:@typescript-eslint/recommended",
3634
"plugin:prettier/recommended"
3735
],
3836
"rules": {

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Michael Dzjaparidze
3+
Copyright (c) 2021 Michael Dzjaparidze
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
# react-signature-pad-wrapper
1212
A React wrapper for [signature pad](https://github.com/szimek/signature_pad).
1313

14-
There are some other React packages that are based off the original *signature_pad* plugin (e.g. [react-signature-pad](https://github.com/blackjk3/react-signature-pad), [react-signature-canvas](https://github.com/agilgur5/react-signature-canvas)). This package is different in the sense that it relies on *signature_pad* as a dependency rather than an implementation that is based off of it (like the aforementioned packages).
15-
1614
## Installation
1715
This package is available through npm:
1816
```
@@ -40,7 +38,7 @@ or they can be set during runtime:
4038
```javascript
4139
...
4240
render() {
43-
return <SignaturePad ref={ref => this.signaturePad = ref} />;
41+
return <SignaturePad ref={this.signaturePadRef} />;
4442
}
4543
...
4644
```
@@ -80,7 +78,7 @@ If you'd like to keep what is currently drawn on the canvas you can pass a `redr
8078
```javascript
8179
...
8280
render() {
83-
return <SignaturePad redrawOnResize={true} />;
81+
return <SignaturePad redrawOnResize />;
8482
}
8583
...
8684
```

__tests__/SignaturePad.test.js renamed to __tests__/SignaturePad.test.tsx

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import * as React from 'react';
22
import { mount } from 'enzyme';
33

44
import './helpers/resizeWindow';
@@ -7,7 +7,7 @@ import SignaturePad from '../src/SignaturePad';
77

88
describe('Component', () => {
99
describe('SignaturePad', () => {
10-
const signaturePad = mount(<SignaturePad />);
10+
const signaturePad = mount<SignaturePad>(<SignaturePad />);
1111
const instance = signaturePad.instance();
1212

1313
it('renders the component', () => {
@@ -31,19 +31,5 @@ describe('Component', () => {
3131
instance.clear();
3232
expect(instance.isEmpty()).toBeTruthy();
3333
});
34-
35-
it('fails to assign an invalid value to the onBegin option', () => {
36-
// eslint-disable-next-line require-jsdoc
37-
const fn = () => (instance.onBegin = 100);
38-
39-
expect(fn).toThrow('Invalid argument passed to onBegin()');
40-
});
41-
42-
it('fails to assign an invalid value to the onEnd option', () => {
43-
// eslint-disable-next-line require-jsdoc
44-
const fn = () => (instance.onEnd = 'a');
45-
46-
expect(fn).toThrow('Invalid argument passed to onEnd()');
47-
});
4834
});
4935
});
File renamed without changes.

__tests__/helpers/resizeWindow.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

__tests__/helpers/resizeWindow.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { JSDOM } from 'jsdom';
2+
3+
export interface Global {
4+
document: Document;
5+
window: Window;
6+
}
7+
8+
declare const global: Global;
9+
10+
const dom = new JSDOM('<!DOCTYPE html><html><head></head><body></body></html>');
11+
12+
global.document = dom.window.document;
13+
if (global.document.defaultView) {
14+
global.window = global.document.defaultView;
15+
}
16+
17+
global.window.resizeTo = (width, height) => {
18+
global.window = Object.assign(window, { innerWidth: width || global.window.innerWidth });
19+
global.window = Object.assign({ innerHeight: height || global.window.innerHeight });
20+
global.window.dispatchEvent(new Event('resize'));
21+
};
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)