@performant-software/shared-components 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/index.js +1 -2
- package/src/services/BaseService.js +10 -1
- package/src/utils/Browser.js +5 -1
- package/src/utils/Object.js +7 -3
- package/src/utils/Utility.js +0 -14
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@performant-software/shared-components",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "A package of shared, framework agnostic, components.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./build/index.js",
|
|
7
|
-
"style": "./build/
|
|
7
|
+
"style": "./build/main.css",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "webpack --mode production && flow-copy-source -v src types"
|
|
10
10
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"react-dom": ">= 16.13.1 < 18.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@performant-software/webpack-config": "^0.5.
|
|
31
|
+
"@performant-software/webpack-config": "^0.5.5",
|
|
32
32
|
"react": "^17.0.2",
|
|
33
33
|
"react-dom": "^17.0.2"
|
|
34
34
|
}
|
package/src/index.js
CHANGED
|
@@ -22,7 +22,7 @@ export { default as FormDataTransform } from './transforms/FormDataTransform';
|
|
|
22
22
|
export { default as NestedAttributesTransform } from './transforms/NestedAttributesTransform';
|
|
23
23
|
|
|
24
24
|
// Utils
|
|
25
|
-
export
|
|
25
|
+
export { default as Browser } from './utils/Browser';
|
|
26
26
|
export { default as Calendar } from './utils/Calendar';
|
|
27
27
|
export { default as Date } from './utils/Date';
|
|
28
28
|
export { default as useDragDrop } from './utils/DragDrop';
|
|
@@ -31,7 +31,6 @@ export { default as Map } from './utils/Map';
|
|
|
31
31
|
export { default as Object } from './utils/Object';
|
|
32
32
|
export { default as String } from './utils/String';
|
|
33
33
|
export { default as Timer } from './utils/Timer';
|
|
34
|
-
export { default as Utility } from './utils/Utility'; // TODO: Rename me
|
|
35
34
|
|
|
36
35
|
// Types
|
|
37
36
|
export type { EditContainerProps as EditModalProps } from './components/EditContainer'; // Backwards compatability
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
|
|
3
|
-
import axios, { type AxiosResponse } from 'axios';
|
|
3
|
+
import axios, { type AxiosResponse, type AxiosStatic } from 'axios';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Base class for making API calls. This class uses Axios under the hood and a customizable transform class for
|
|
@@ -102,6 +102,15 @@ class BaseService {
|
|
|
102
102
|
|
|
103
103
|
// protected
|
|
104
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Returns the axios instance.
|
|
107
|
+
*
|
|
108
|
+
* @returns {AxiosStatic}
|
|
109
|
+
*/
|
|
110
|
+
getAxios(): AxiosStatic {
|
|
111
|
+
return axios;
|
|
112
|
+
}
|
|
113
|
+
|
|
105
114
|
/**
|
|
106
115
|
* Returns the API base URL string.
|
|
107
116
|
*/
|
package/src/utils/Browser.js
CHANGED
package/src/utils/Object.js
CHANGED
|
@@ -31,7 +31,7 @@ const WHITESPACE_REGEX = /\s\s+/g;
|
|
|
31
31
|
*
|
|
32
32
|
* @returns {boolean|*}
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
const isEmpty = (value: any) => {
|
|
35
35
|
// If the value is an object or array, use underscore's isEmpty check.
|
|
36
36
|
if (_.isObject(value) || _.isArray(value)) {
|
|
37
37
|
return _.isEmpty(value);
|
|
@@ -49,7 +49,7 @@ export const isEmpty = (value: any) => {
|
|
|
49
49
|
*
|
|
50
50
|
* @returns {boolean}
|
|
51
51
|
*/
|
|
52
|
-
|
|
52
|
+
const isEqual = (a: any, b: any, userOptions: OptionsProps = {}) => {
|
|
53
53
|
const options = _.defaults(userOptions, DEFAULT_OPTIONS);
|
|
54
54
|
|
|
55
55
|
// Check equality, consider empty strings and "null" values as equal
|
|
@@ -109,6 +109,10 @@ export const isEqual = (a: any, b: any, userOptions: OptionsProps = {}) => {
|
|
|
109
109
|
return false;
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
const isPromise = (value: any) => !!value && typeof value === 'object' && typeof value.then === 'function';
|
|
113
113
|
|
|
114
|
+
export default {
|
|
115
|
+
isEmpty,
|
|
116
|
+
isEqual,
|
|
117
|
+
isPromise
|
|
114
118
|
};
|
package/src/utils/Utility.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns true if passed value is a promise (i.e, has a .then method)
|
|
5
|
-
*
|
|
6
|
-
* @param *
|
|
7
|
-
*
|
|
8
|
-
* @returns {boolean}
|
|
9
|
-
*/
|
|
10
|
-
const isPromise = (value: any) => !!value && typeof value === 'object' && typeof value.then === 'function';
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
isPromise
|
|
14
|
-
};
|