Skip to content

Commit 7ea4458

Browse files
committed
fix: move type checking to external package
1 parent 0599041 commit 7ea4458

9 files changed

+11
-44
lines changed

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"eslint-plugin-react": "^7.20.3",
3838
"eslint-plugin-react-hooks": "^4.0.8",
3939
"jest": "^26.1.0",
40+
"js-var-type": "^0.2.1",
4041
"lodash-es": "^4.17.15",
4142
"prettier": "^2.0.5",
4243
"react": "^16.13.1",
@@ -50,6 +51,7 @@
5051
"webpack-dev-server": "^3.11.0"
5152
},
5253
"peerDependencies": {
54+
"js-var-type": "^0.2.1",
5355
"react": "^16.13.1",
5456
"react-dom": "^16.13.1"
5557
}

rollup.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ export default {
1515
exclude: 'node_modules/**', // only transpile our source code
1616
}),
1717
],
18-
external: ['react', 'prop-types', 'react-modal', 'react-dom'],
18+
external: ['react', 'prop-types', 'react-modal', 'react-dom', 'js-var-types'],
1919
};

src/forms/FormActions.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import { isFunction } from '../utils/types';
3+
import { isFunction } from 'js-var-type';
44

55
export function FormActions({ submitLabel, cancelLabel, onCancel, isSubmiting, customActions }) {
66
if (customActions) {

src/forms/FormAutocomplete.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React, { useState, useRef, useCallback, useEffect, useMemo } from 'react';
22
import PropTypes from 'prop-types';
3+
import { isEmptyLike } from 'js-var-type';
34

45
import { handleInputChange, normalizeOptions, booleanOrFunction } from './helpers/form-helpers';
56
import { Dropdown } from '../mixed/Dropdown';
67
import { useOpenState } from '../utils/useOpenState';
78
import { formatClasses } from '../utils/attributes';
89
import { useFormControl } from './helpers/useFormControl';
9-
import { isEmpty } from '../utils/types';
1010

1111
export function FormAutocomplete({
1212
onSearch,
@@ -44,7 +44,7 @@ export function FormAutocomplete({
4444
}, [controlFeedback]);
4545

4646
const clearSearchValue = useCallback(() => {
47-
if (isEmpty(value) && !isFocused) {
47+
if (isEmptyLike(value) && !isFocused) {
4848
setSearchValue('');
4949
setSelectedItem(null);
5050
}
@@ -80,7 +80,7 @@ export function FormAutocomplete({
8080
}, [open, openOnFocus]);
8181

8282
const onSearchInputBlur = useCallback(() => {
83-
if (isEmpty(searchValue) && value) {
83+
if (isEmptyLike(searchValue) && value) {
8484
setValue('');
8585
setSelectedItem(null);
8686
updateSearchInputValidation();

src/forms/helpers/form-helpers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
2+
import { isFunction, isUndefined } from 'js-var-type';
23
import { getValueByPath } from '../../utils/getters-setters';
3-
import { isFunction, isUndefined } from '../../utils/types';
44

55
export const FormContext = React.createContext(null);
66

src/forms/helpers/useFormControl.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useContext, useCallback } from 'react';
2+
import { isNull } from 'js-var-type';
23
import { FormContext } from './form-helpers';
34
import { toDatetimeLocal, fromDatetimeLocal } from '../../utils/formatters';
4-
import { isNull } from '../../utils/types';
55

66
export function useFormControl(name, type) {
77
const formState = useContext(FormContext);

src/table/TableActions.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3+
import { isFunction } from 'js-var-type';
34

45
import { safeClick, stopPropagation } from '../utils/event-handlers';
5-
import { isFunction } from '../utils/types';
66

77
export function TableActions({ doc, docIndex, actions }) {
88
if (!actions) {

src/utils/formatters.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isISOString, isDate } from './types';
1+
import { isISOString, isDate } from 'js-var-type';
22

33
export function toDatetimeLocal(value) {
44
let date = value;

src/utils/types.js

-35
This file was deleted.

0 commit comments

Comments
 (0)