@elliemae/ds-utilities 1.60.0 → 2.0.0-alpha.12
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/cjs/capitalize.js +7 -0
- package/cjs/compose.js +8 -8
- package/cjs/getComponentFromProps.js +13 -7
- package/cjs/hooks/index.js +33 -51
- package/cjs/hooks/useCancellableDelayedCallback.js +6 -8
- package/cjs/hooks/useDerivedStateFromProps.js +28 -35
- package/cjs/hooks/useExecutionTimer.js +7 -11
- package/cjs/hooks/useExpandState.js +53 -59
- package/cjs/hooks/useHotkeys.js +11 -12
- package/cjs/hooks/useHoverHandlersDelay.js +10 -11
- package/cjs/hooks/useOnElementResize.js +11 -26
- package/cjs/hooks/useParentElement.js +4 -13
- package/cjs/hooks/usePrevious.js +2 -3
- package/cjs/hooks/useResizeObserver.js +11 -21
- package/cjs/hooks/useSetRef.js +3 -4
- package/cjs/hooks/useShouldRecalculate.js +1 -2
- package/cjs/hooks/useWindowScrollerList.js +17 -16
- package/cjs/hooks/useWindowSize.js +4 -13
- package/cjs/index.js +73 -162
- package/cjs/onClickHandlerForNonInteractiveElements.js +13 -14
- package/cjs/operators.js +19 -56
- package/cjs/platform.js +2 -3
- package/cjs/reactTypesUtility.js +1 -2
- package/cjs/scrollingTimer.js +3 -4
- package/cjs/system.js +11 -5
- package/cjs/timeUtils.js +15 -15
- package/cjs/utils.js +70 -149
- package/cjs/validations.js +17 -17
- package/esm/capitalize.js +3 -0
- package/esm/compose.js +8 -8
- package/esm/getComponentFromProps.js +12 -5
- package/esm/hooks/index.js +1 -10
- package/esm/hooks/useCancellableDelayedCallback.js +6 -8
- package/esm/hooks/useDerivedStateFromProps.js +29 -32
- package/esm/hooks/useExecutionTimer.js +7 -11
- package/esm/hooks/useExpandState.js +51 -56
- package/esm/hooks/useHotkeys.js +10 -11
- package/esm/hooks/useHoverHandlersDelay.js +10 -11
- package/esm/hooks/useOnElementResize.js +11 -22
- package/esm/hooks/useParentElement.js +4 -9
- package/esm/hooks/usePrevious.js +2 -3
- package/esm/hooks/useResizeObserver.js +11 -20
- package/esm/hooks/useSetRef.js +3 -4
- package/esm/hooks/useShouldRecalculate.js +1 -2
- package/esm/hooks/useWindowScrollerList.js +18 -17
- package/esm/hooks/useWindowSize.js +4 -9
- package/esm/index.js +2 -9
- package/esm/onClickHandlerForNonInteractiveElements.js +13 -14
- package/esm/operators.js +19 -52
- package/esm/platform.js +2 -3
- package/esm/reactTypesUtility.js +0 -1
- package/esm/scrollingTimer.js +3 -4
- package/esm/system.js +11 -5
- package/esm/timeUtils.js +15 -15
- package/esm/utils.js +31 -35
- package/esm/validations.js +17 -17
- package/package.json +135 -10
- package/types/capitalize.d.ts +1 -0
- package/types/compose.d.ts +11 -0
- package/types/getComponentFromProps.d.ts +2 -0
- package/types/hooks/index.d.ts +18 -0
- package/types/hooks/useCancellableDelayedCallback.d.ts +1 -0
- package/types/hooks/useDerivedStateFromProps.d.ts +1 -0
- package/types/hooks/useExecutionTimer.d.ts +1 -0
- package/types/hooks/useExpandState.d.ts +22 -0
- package/types/hooks/useHotkeys.d.ts +5 -0
- package/types/hooks/useHoverHandlersDelay.d.ts +9 -0
- package/types/hooks/useOnElementResize.d.ts +2 -0
- package/types/hooks/useParentElement.d.ts +1 -0
- package/types/hooks/usePrevious.d.ts +2 -0
- package/types/hooks/useResizeObserver.d.ts +2 -0
- package/types/hooks/useSetRef.d.ts +2 -0
- package/types/hooks/useShouldRecalculate.d.ts +1 -0
- package/types/hooks/useWindowScrollerList.d.ts +4 -0
- package/types/hooks/useWindowSize.d.ts +1 -0
- package/types/index.d.ts +13 -0
- package/types/onClickHandlerForNonInteractiveElements.d.ts +12 -0
- package/types/operators.d.ts +31 -0
- package/types/platform.d.ts +2 -0
- package/types/reactTypesUtility.d.ts +6 -0
- package/types/scrollingTimer.d.ts +1 -0
- package/types/system.d.ts +3 -0
- package/types/timeUtils.d.ts +7 -0
- package/types/utils.d.ts +23 -0
- package/types/validations.d.ts +23 -0
- package/cjs/compose.js.map +0 -1
- package/cjs/getComponentFromProps.js.map +0 -1
- package/cjs/hooks/index.js.map +0 -1
- package/cjs/hooks/useCancellableDelayedCallback.js.map +0 -1
- package/cjs/hooks/useDerivedStateFromProps.js.map +0 -1
- package/cjs/hooks/useExecutionTimer.js.map +0 -1
- package/cjs/hooks/useExpandState.js.map +0 -1
- package/cjs/hooks/useHotkeys.js.map +0 -1
- package/cjs/hooks/useHoverHandlersDelay.js.map +0 -1
- package/cjs/hooks/useOnElementResize.js.map +0 -1
- package/cjs/hooks/useParentElement.js.map +0 -1
- package/cjs/hooks/usePrevious.js.map +0 -1
- package/cjs/hooks/useResizeObserver.js.map +0 -1
- package/cjs/hooks/useSetRef.js.map +0 -1
- package/cjs/hooks/useShouldRecalculate.js.map +0 -1
- package/cjs/hooks/useWindowScrollerList.js.map +0 -1
- package/cjs/hooks/useWindowSize.js.map +0 -1
- package/cjs/index.js.map +0 -1
- package/cjs/onClickHandlerForNonInteractiveElements.js.map +0 -1
- package/cjs/operators.js.map +0 -1
- package/cjs/platform.js.map +0 -1
- package/cjs/reactTypesUtility.js.map +0 -1
- package/cjs/scrollingTimer.js.map +0 -1
- package/cjs/system.js.map +0 -1
- package/cjs/timeUtils.js.map +0 -1
- package/cjs/utils.js.map +0 -1
- package/cjs/validations.js.map +0 -1
- package/compose/package.json +0 -10
- package/esm/compose.js.map +0 -1
- package/esm/getComponentFromProps.js.map +0 -1
- package/esm/hooks/index.js.map +0 -1
- package/esm/hooks/useCancellableDelayedCallback.js.map +0 -1
- package/esm/hooks/useDerivedStateFromProps.js.map +0 -1
- package/esm/hooks/useExecutionTimer.js.map +0 -1
- package/esm/hooks/useExpandState.js.map +0 -1
- package/esm/hooks/useHotkeys.js.map +0 -1
- package/esm/hooks/useHoverHandlersDelay.js.map +0 -1
- package/esm/hooks/useOnElementResize.js.map +0 -1
- package/esm/hooks/useParentElement.js.map +0 -1
- package/esm/hooks/usePrevious.js.map +0 -1
- package/esm/hooks/useResizeObserver.js.map +0 -1
- package/esm/hooks/useSetRef.js.map +0 -1
- package/esm/hooks/useShouldRecalculate.js.map +0 -1
- package/esm/hooks/useWindowScrollerList.js.map +0 -1
- package/esm/hooks/useWindowSize.js.map +0 -1
- package/esm/index.js.map +0 -1
- package/esm/onClickHandlerForNonInteractiveElements.js.map +0 -1
- package/esm/operators.js.map +0 -1
- package/esm/platform.js.map +0 -1
- package/esm/reactTypesUtility.js.map +0 -1
- package/esm/scrollingTimer.js.map +0 -1
- package/esm/system.js.map +0 -1
- package/esm/timeUtils.js.map +0 -1
- package/esm/utils.js.map +0 -1
- package/esm/validations.js.map +0 -1
- package/getComponentFromProps/package.json +0 -10
- package/hooks/package.json +0 -10
- package/hooks/useCancellableDelayedCallback/package.json +0 -10
- package/hooks/useDerivedStateFromProps/package.json +0 -10
- package/hooks/useExecutionTimer/package.json +0 -10
- package/hooks/useExpandState/package.json +0 -10
- package/hooks/useHotkeys/package.json +0 -10
- package/hooks/useHoverHandlersDelay/package.json +0 -10
- package/hooks/useOnElementResize/package.json +0 -10
- package/hooks/useParentElement/package.json +0 -10
- package/hooks/usePrevious/package.json +0 -10
- package/hooks/useResizeObserver/package.json +0 -10
- package/hooks/useSetRef/package.json +0 -10
- package/hooks/useShouldRecalculate/package.json +0 -10
- package/hooks/useWindowScrollerList/package.json +0 -10
- package/hooks/useWindowSize/package.json +0 -10
- package/onClickHandlerForNonInteractiveElements/package.json +0 -10
- package/operators/package.json +0 -10
- package/platform/package.json +0 -10
- package/reactTypesUtility/package.json +0 -10
- package/scrollingTimer/package.json +0 -10
- package/system/package.json +0 -10
- package/timeUtils/package.json +0 -10
- package/utils/package.json +0 -10
- package/validations/package.json +0 -10
package/esm/operators.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
2
4
|
import { isEmpty } from 'lodash';
|
|
3
5
|
|
|
4
6
|
/**
|
|
@@ -7,12 +9,8 @@ import { isEmpty } from 'lodash';
|
|
|
7
9
|
* @param value
|
|
8
10
|
*/
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
var checkEmpty = function checkEmpty(value) {
|
|
14
|
-
return !isEmpty(value);
|
|
15
|
-
};
|
|
12
|
+
const checkNotEmpty = value => value === '' || value === undefined || value == [] || value === null || isEmpty(value);
|
|
13
|
+
const checkEmpty = value => !isEmpty(value);
|
|
16
14
|
/**
|
|
17
15
|
* @param value: number
|
|
18
16
|
* @param comparator: number
|
|
@@ -20,9 +18,7 @@ var checkEmpty = function checkEmpty(value) {
|
|
|
20
18
|
* @param comparator
|
|
21
19
|
*/
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
return value > comparator;
|
|
25
|
-
};
|
|
21
|
+
const greaterThan = (value, comparator) => value > comparator;
|
|
26
22
|
/**
|
|
27
23
|
* Check if a valid date with format MM/DD/YYYY
|
|
28
24
|
*
|
|
@@ -30,50 +26,21 @@ var greaterThan = function greaterThan(value, comparator) {
|
|
|
30
26
|
* @param value
|
|
31
27
|
*/
|
|
32
28
|
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
const validDate = value => {
|
|
30
|
+
const dateValidationRegex = /^\d{1,2}\/\d{1,2}\/\d{4}$/;
|
|
35
31
|
if (!dateValidationRegex.test(value)) return false;
|
|
36
|
-
|
|
37
|
-
var _value$split$map = value.split('/').map(function (n) {
|
|
38
|
-
return Number(n);
|
|
39
|
-
}),
|
|
40
|
-
_value$split$map2 = _slicedToArray(_value$split$map, 3),
|
|
41
|
-
m = _value$split$map2[0],
|
|
42
|
-
d = _value$split$map2[1],
|
|
43
|
-
y = _value$split$map2[2];
|
|
44
|
-
|
|
32
|
+
const [m, d, y] = value.split('/').map(n => Number(n));
|
|
45
33
|
return m === Number(new Date(y, m - 1, d).getMonth()) + 1 && d === Number(new Date(y, m - 1, d).getDate());
|
|
46
34
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return !isNull(a);
|
|
58
|
-
};
|
|
59
|
-
var isIn = function isIn(a, b) {
|
|
60
|
-
return b.indexOf(a) > -1;
|
|
61
|
-
};
|
|
62
|
-
var isNotIn = function isNotIn(a, b) {
|
|
63
|
-
return !isIn(a, b);
|
|
64
|
-
};
|
|
65
|
-
var greaterThanOrEquals = function greaterThanOrEquals(value, comparator) {
|
|
66
|
-
return value >= comparator;
|
|
67
|
-
};
|
|
68
|
-
var lessThanOrEquals = function lessThanOrEquals(value, comparator) {
|
|
69
|
-
return value <= comparator;
|
|
70
|
-
};
|
|
71
|
-
var startsWith = function startsWith(value, comparator) {
|
|
72
|
-
return String(value).startsWith(comparator);
|
|
73
|
-
};
|
|
74
|
-
var contains = function contains(value, comparator) {
|
|
75
|
-
return String(value).includes(comparator);
|
|
76
|
-
};
|
|
35
|
+
const equal = (a, b) => a === b;
|
|
36
|
+
const notEqual = (a, b) => !equal(a, b);
|
|
37
|
+
const isNull = a => checkNotEmpty(a);
|
|
38
|
+
const isNotNull = a => !isNull(a);
|
|
39
|
+
const isIn = (a, b) => b.indexOf(a) > -1;
|
|
40
|
+
const isNotIn = (a, b) => !isIn(a, b);
|
|
41
|
+
const greaterThanOrEquals = (value, comparator) => value >= comparator;
|
|
42
|
+
const lessThanOrEquals = (value, comparator) => value <= comparator;
|
|
43
|
+
const startsWith = (value, comparator) => String(value).startsWith(comparator);
|
|
44
|
+
const contains = (value, comparator) => String(value).includes(comparator);
|
|
77
45
|
|
|
78
46
|
export { checkEmpty, checkNotEmpty, contains, equal, greaterThan, greaterThanOrEquals, isIn, isNotIn, isNotNull, isNull, lessThanOrEquals, notEqual, startsWith, validDate };
|
|
79
|
-
//# sourceMappingURL=operators.js.map
|
package/esm/platform.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const DOCUMENT = typeof document !== 'undefined' ? document : null;
|
|
2
|
+
const WINDOW = typeof window !== 'undefined' ? window : null;
|
|
3
3
|
|
|
4
4
|
export { DOCUMENT, WINDOW };
|
|
5
|
-
//# sourceMappingURL=platform.js.map
|
package/esm/reactTypesUtility.js
CHANGED
package/esm/scrollingTimer.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
function resetTimer(func) {
|
|
2
|
-
|
|
2
|
+
let timeout;
|
|
3
3
|
return function () {
|
|
4
4
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
5
5
|
args[_key] = arguments[_key];
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const context = this;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const lastCall = () => {
|
|
11
11
|
timeout = null;
|
|
12
12
|
func.apply(context, args);
|
|
13
13
|
};
|
|
@@ -18,4 +18,3 @@ function resetTimer(func) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export { resetTimer };
|
|
21
|
-
//# sourceMappingURL=scrollingTimer.js.map
|
package/esm/system.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
2
6
|
import '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
8
|
+
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
9
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
10
|
import { isFunction } from 'lodash';
|
|
4
11
|
|
|
5
|
-
|
|
12
|
+
const setRef = (ref, value) => {
|
|
6
13
|
if (isFunction(ref)) {
|
|
7
14
|
ref(value);
|
|
8
15
|
} else if (ref) {
|
|
@@ -14,9 +21,9 @@ function mergeRefs() {
|
|
|
14
21
|
refs[_key] = arguments[_key];
|
|
15
22
|
}
|
|
16
23
|
|
|
17
|
-
return
|
|
24
|
+
return node => {
|
|
18
25
|
if (!node) return;
|
|
19
|
-
refs.forEach(
|
|
26
|
+
refs.forEach(ref => {
|
|
20
27
|
if (isFunction(ref)) {
|
|
21
28
|
ref(node);
|
|
22
29
|
} else if (ref) {
|
|
@@ -28,4 +35,3 @@ function mergeRefs() {
|
|
|
28
35
|
function logger() {}
|
|
29
36
|
|
|
30
37
|
export { logger, mergeRefs, setRef };
|
|
31
|
-
//# sourceMappingURL=system.js.map
|
package/esm/timeUtils.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
2
3
|
import '@babel/runtime/helpers/esm/defineProperty';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
7
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
8
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
3
10
|
import { padStart } from 'lodash';
|
|
4
11
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
var addLeadingZeros = function addLeadingZeros(count) {
|
|
14
|
-
return function (number) {
|
|
15
|
-
return padStart(String(number), count, '0');
|
|
16
|
-
};
|
|
17
|
-
};
|
|
12
|
+
const getVisibleTimeByFormat = format => ({
|
|
13
|
+
showHours: format.indexOf('H') > -1 || format.indexOf('h') > -1 || format.indexOf('k') > -1,
|
|
14
|
+
showMinutes: format.indexOf('m') > -1,
|
|
15
|
+
showSeconds: format.indexOf('s') > -1,
|
|
16
|
+
use12Hours: format.indexOf('A') > -1 || format.indexOf('h') > -1 || format.indexOf('a') > -1
|
|
17
|
+
});
|
|
18
|
+
const addLeadingZeros = count => number => padStart(String(number), count, '0');
|
|
18
19
|
|
|
19
20
|
export { addLeadingZeros, getVisibleTimeByFormat };
|
|
20
|
-
//# sourceMappingURL=timeUtils.js.map
|
package/esm/utils.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
2
3
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
7
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
8
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
3
10
|
import { omit, cloneDeep, isFunction } from 'lodash';
|
|
4
11
|
export { cloneDeep, curry, debounce, differenceBy, differenceWith, filter, findIndex, get, groupBy, isBoolean, isEmpty, isEqual, isEqualWith, isFunction, isNaN, isObject, isString, maxBy, meanBy, noop, omit, orderBy, padStart, parseInt, pick, pickBy, property, pull, range, set, sortBy, sumBy, throttle, transform, uniq, uniqBy, values } from 'lodash';
|
|
5
12
|
|
|
@@ -12,51 +19,43 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
12
19
|
* @param {...any} classnames
|
|
13
20
|
*/
|
|
14
21
|
|
|
15
|
-
|
|
22
|
+
const cx = function () {
|
|
16
23
|
for (var _len = arguments.length, classnames = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
17
24
|
classnames[_key] = arguments[_key];
|
|
18
25
|
}
|
|
19
26
|
|
|
20
|
-
return classnames.reduce(
|
|
21
|
-
return "".concat(result, " ").concat(cn || '');
|
|
22
|
-
}, '');
|
|
27
|
+
return classnames.reduce((result, cn) => "".concat(result, " ").concat(cn || ''), '');
|
|
23
28
|
}; // if entry exists, remove it, if not, add it
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
30
|
+
const toggleInObject = (obj, key, value) => obj[key] !== undefined ? omit(obj, [key]) : _objectSpread(_objectSpread({}, obj), {}, {
|
|
31
|
+
[key]: value
|
|
32
|
+
});
|
|
28
33
|
|
|
29
|
-
|
|
30
|
-
return array.indexOf(value) === -1 ? [value] : [];
|
|
31
|
-
};
|
|
34
|
+
const toggleInArray = (array, value) => array.indexOf(value) === -1 ? [value] : [];
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
const arrayMoveMutate = (array, from, to) => {
|
|
34
37
|
array.splice(to < 0 ? array.length + to : to, 0, array.splice(from, 1)[0]);
|
|
35
38
|
};
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
const arrayMove = (array, from, to) => {
|
|
38
41
|
array = array.slice();
|
|
39
42
|
arrayMoveMutate(array, from, to);
|
|
40
43
|
return array;
|
|
41
44
|
};
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
return item;
|
|
45
|
-
};
|
|
46
|
+
const accessorDefault = item => item;
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return accessor(iItem) === accessor(item);
|
|
51
|
-
});
|
|
48
|
+
const addOrRemove = function (array, item) {
|
|
49
|
+
let accessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : accessorDefault;
|
|
50
|
+
const index = array.findIndex(iItem => accessor(iItem) === accessor(item));
|
|
52
51
|
|
|
53
52
|
if (index !== -1) {
|
|
54
|
-
|
|
53
|
+
const nextArray = cloneDeep(array);
|
|
55
54
|
nextArray.splice(index, 1);
|
|
56
55
|
return nextArray;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
return [
|
|
58
|
+
return [...array, item];
|
|
60
59
|
};
|
|
61
60
|
|
|
62
61
|
function runAll() {
|
|
@@ -69,16 +68,16 @@ function runAll() {
|
|
|
69
68
|
args[_key3] = arguments[_key3];
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
return fns.forEach(
|
|
71
|
+
return fns.forEach(fn => {
|
|
73
72
|
if (Array.isArray(fn)) runAll(fn);
|
|
74
|
-
if (isFunction(fn)) fn
|
|
73
|
+
if (isFunction(fn)) fn(...args);
|
|
75
74
|
});
|
|
76
75
|
};
|
|
77
76
|
}
|
|
78
77
|
function hashArray(arr, fieldName) {
|
|
79
|
-
return arr.reduce(
|
|
80
|
-
|
|
81
|
-
}, {});
|
|
78
|
+
return arr.reduce((result, item) => _objectSpread(_objectSpread({}, result), {}, {
|
|
79
|
+
[fieldName ? item[fieldName] : item]: true
|
|
80
|
+
}), {});
|
|
82
81
|
}
|
|
83
82
|
function safeCall(fun) {
|
|
84
83
|
if (isFunction(fun)) {
|
|
@@ -86,18 +85,15 @@ function safeCall(fun) {
|
|
|
86
85
|
args[_key4 - 1] = arguments[_key4];
|
|
87
86
|
}
|
|
88
87
|
|
|
89
|
-
fun
|
|
88
|
+
fun(...args);
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
const removeUndefinedProperties = obj => {
|
|
92
|
+
const cleanObject = _objectSpread({}, obj);
|
|
94
93
|
|
|
95
|
-
Object.keys(obj).forEach(
|
|
96
|
-
return cleanObject[key] === undefined && delete cleanObject[key];
|
|
97
|
-
});
|
|
94
|
+
Object.keys(obj).forEach(key => cleanObject[key] === undefined && delete cleanObject[key]);
|
|
98
95
|
return cleanObject;
|
|
99
96
|
};
|
|
100
97
|
var utils = {};
|
|
101
98
|
|
|
102
99
|
export { addOrRemove, arrayMove, cx, utils as default, hashArray, removeUndefinedProperties, runAll, safeCall, toggleInArray, toggleInObject };
|
|
103
|
-
//# sourceMappingURL=utils.js.map
|
package/esm/validations.js
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import { checkNotEmpty, greaterThan, validDate } from './operators.js';
|
|
2
|
-
import '@babel/runtime/helpers/esm/slicedToArray';
|
|
3
|
-
import 'lodash';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const isRequired = _ref => {
|
|
4
|
+
let {
|
|
5
|
+
value,
|
|
6
|
+
help = 'Field is Required'
|
|
7
|
+
} = _ref;
|
|
9
8
|
return {
|
|
10
9
|
payload: help,
|
|
11
10
|
error: checkNotEmpty(value)
|
|
12
11
|
};
|
|
13
12
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
const isGreaterThan = _ref2 => {
|
|
14
|
+
let {
|
|
15
|
+
value,
|
|
16
|
+
help,
|
|
17
|
+
comparator = 0
|
|
18
|
+
} = _ref2;
|
|
19
19
|
if (!help) help = "Max value ".concat(comparator);
|
|
20
20
|
return {
|
|
21
21
|
payload: help,
|
|
22
22
|
error: greaterThan(value, comparator)
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const isValidDate = _ref3 => {
|
|
26
|
+
let {
|
|
27
|
+
value,
|
|
28
|
+
help,
|
|
29
|
+
format = 'MM/DD/AAA'
|
|
30
|
+
} = _ref3;
|
|
30
31
|
if (!help) help = "Valid Date is required ".concat(format);
|
|
31
32
|
return {
|
|
32
33
|
payload: help,
|
|
@@ -35,4 +36,3 @@ var isValidDate = function isValidDate(_ref3) {
|
|
|
35
36
|
};
|
|
36
37
|
|
|
37
38
|
export { isGreaterThan, isRequired, isValidDate };
|
|
38
|
-
//# sourceMappingURL=validations.js.map
|
package/package.json
CHANGED
|
@@ -1,14 +1,138 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-utilities",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.12",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"description": "
|
|
6
|
-
"
|
|
7
|
-
"
|
|
5
|
+
"description": "ICE MT - Dimsum - Utilities",
|
|
6
|
+
"module": "./esm/index.js",
|
|
7
|
+
"main": "./cjs/index.js",
|
|
8
|
+
"types": "./types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./esm/index.js",
|
|
12
|
+
"require": "./cjs/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./validations": {
|
|
15
|
+
"import": "./esm/validations.js",
|
|
16
|
+
"require": "./cjs/validations.js"
|
|
17
|
+
},
|
|
18
|
+
"./utils": {
|
|
19
|
+
"import": "./esm/utils.js",
|
|
20
|
+
"require": "./cjs/utils.js"
|
|
21
|
+
},
|
|
22
|
+
"./timeUtils": {
|
|
23
|
+
"import": "./esm/timeUtils.js",
|
|
24
|
+
"require": "./cjs/timeUtils.js"
|
|
25
|
+
},
|
|
26
|
+
"./system": {
|
|
27
|
+
"import": "./esm/system.js",
|
|
28
|
+
"require": "./cjs/system.js"
|
|
29
|
+
},
|
|
30
|
+
"./scrollingTimer": {
|
|
31
|
+
"import": "./esm/scrollingTimer.js",
|
|
32
|
+
"require": "./cjs/scrollingTimer.js"
|
|
33
|
+
},
|
|
34
|
+
"./reactTypesUtility": {
|
|
35
|
+
"import": "./esm/reactTypesUtility.js",
|
|
36
|
+
"require": "./cjs/reactTypesUtility.js"
|
|
37
|
+
},
|
|
38
|
+
"./platform": {
|
|
39
|
+
"import": "./esm/platform.js",
|
|
40
|
+
"require": "./cjs/platform.js"
|
|
41
|
+
},
|
|
42
|
+
"./operators": {
|
|
43
|
+
"import": "./esm/operators.js",
|
|
44
|
+
"require": "./cjs/operators.js"
|
|
45
|
+
},
|
|
46
|
+
"./onClickHandlerForNonInteractiveElements": {
|
|
47
|
+
"import": "./esm/onClickHandlerForNonInteractiveElements.js",
|
|
48
|
+
"require": "./cjs/onClickHandlerForNonInteractiveElements.js"
|
|
49
|
+
},
|
|
50
|
+
"./hooks/useWindowSize": {
|
|
51
|
+
"import": "./esm/hooks/useWindowSize.js",
|
|
52
|
+
"require": "./cjs/hooks/useWindowSize.js"
|
|
53
|
+
},
|
|
54
|
+
"./hooks/useWindowScrollerList": {
|
|
55
|
+
"import": "./esm/hooks/useWindowScrollerList.js",
|
|
56
|
+
"require": "./cjs/hooks/useWindowScrollerList.js"
|
|
57
|
+
},
|
|
58
|
+
"./hooks/useShouldRecalculate": {
|
|
59
|
+
"import": "./esm/hooks/useShouldRecalculate.js",
|
|
60
|
+
"require": "./cjs/hooks/useShouldRecalculate.js"
|
|
61
|
+
},
|
|
62
|
+
"./hooks/useSetRef": {
|
|
63
|
+
"import": "./esm/hooks/useSetRef.js",
|
|
64
|
+
"require": "./cjs/hooks/useSetRef.js"
|
|
65
|
+
},
|
|
66
|
+
"./hooks/useResizeObserver": {
|
|
67
|
+
"import": "./esm/hooks/useResizeObserver.js",
|
|
68
|
+
"require": "./cjs/hooks/useResizeObserver.js"
|
|
69
|
+
},
|
|
70
|
+
"./hooks/usePrevious": {
|
|
71
|
+
"import": "./esm/hooks/usePrevious.js",
|
|
72
|
+
"require": "./cjs/hooks/usePrevious.js"
|
|
73
|
+
},
|
|
74
|
+
"./hooks/useParentElement": {
|
|
75
|
+
"import": "./esm/hooks/useParentElement.js",
|
|
76
|
+
"require": "./cjs/hooks/useParentElement.js"
|
|
77
|
+
},
|
|
78
|
+
"./hooks/useOnElementResize": {
|
|
79
|
+
"import": "./esm/hooks/useOnElementResize.js",
|
|
80
|
+
"require": "./cjs/hooks/useOnElementResize.js"
|
|
81
|
+
},
|
|
82
|
+
"./hooks/useHoverHandlersDelay": {
|
|
83
|
+
"import": "./esm/hooks/useHoverHandlersDelay.js",
|
|
84
|
+
"require": "./cjs/hooks/useHoverHandlersDelay.js"
|
|
85
|
+
},
|
|
86
|
+
"./hooks/useHotkeys": {
|
|
87
|
+
"import": "./esm/hooks/useHotkeys.js",
|
|
88
|
+
"require": "./cjs/hooks/useHotkeys.js"
|
|
89
|
+
},
|
|
90
|
+
"./hooks/useExpandState": {
|
|
91
|
+
"import": "./esm/hooks/useExpandState.js",
|
|
92
|
+
"require": "./cjs/hooks/useExpandState.js"
|
|
93
|
+
},
|
|
94
|
+
"./hooks/useExecutionTimer": {
|
|
95
|
+
"import": "./esm/hooks/useExecutionTimer.js",
|
|
96
|
+
"require": "./cjs/hooks/useExecutionTimer.js"
|
|
97
|
+
},
|
|
98
|
+
"./hooks/useDerivedStateFromProps": {
|
|
99
|
+
"import": "./esm/hooks/useDerivedStateFromProps.js",
|
|
100
|
+
"require": "./cjs/hooks/useDerivedStateFromProps.js"
|
|
101
|
+
},
|
|
102
|
+
"./hooks/useCancellableDelayedCallback": {
|
|
103
|
+
"import": "./esm/hooks/useCancellableDelayedCallback.js",
|
|
104
|
+
"require": "./cjs/hooks/useCancellableDelayedCallback.js"
|
|
105
|
+
},
|
|
106
|
+
"./hooks": {
|
|
107
|
+
"import": "./esm/hooks/index.js",
|
|
108
|
+
"require": "./cjs/hooks/index.js"
|
|
109
|
+
},
|
|
110
|
+
"./getComponentFromProps": {
|
|
111
|
+
"import": "./esm/getComponentFromProps.js",
|
|
112
|
+
"require": "./cjs/getComponentFromProps.js"
|
|
113
|
+
},
|
|
114
|
+
"./compose": {
|
|
115
|
+
"import": "./esm/compose.js",
|
|
116
|
+
"require": "./cjs/compose.js"
|
|
117
|
+
},
|
|
118
|
+
"./capitalize": {
|
|
119
|
+
"import": "./esm/capitalize.js",
|
|
120
|
+
"require": "./cjs/capitalize.js"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
8
123
|
"sideEffects": [
|
|
9
124
|
"*.css",
|
|
10
125
|
"*.scss"
|
|
11
126
|
],
|
|
127
|
+
"repository": {
|
|
128
|
+
"type": "git",
|
|
129
|
+
"url": "https://git.elliemae.io/platform-ui/dimsum.git"
|
|
130
|
+
},
|
|
131
|
+
"engines": {
|
|
132
|
+
"npm": ">=7",
|
|
133
|
+
"node": ">=14"
|
|
134
|
+
},
|
|
135
|
+
"author": "ICE MT",
|
|
12
136
|
"scripts": {
|
|
13
137
|
"prebuild": "exit 0",
|
|
14
138
|
"predev": "exit 0",
|
|
@@ -17,20 +141,21 @@
|
|
|
17
141
|
},
|
|
18
142
|
"publishConfig": {
|
|
19
143
|
"access": "public",
|
|
20
|
-
"directory": "dist"
|
|
144
|
+
"directory": "dist",
|
|
145
|
+
"generateSubmodules": true
|
|
21
146
|
},
|
|
22
147
|
"dependencies": {
|
|
23
|
-
"hotkeys-js": "~3.8.
|
|
148
|
+
"hotkeys-js": "~3.8.7",
|
|
24
149
|
"raf": "~3.4.1",
|
|
25
150
|
"resize-observer-polyfill": "~1.5.1",
|
|
26
151
|
"uncontrollable": "~6.2.3",
|
|
27
152
|
"use-force-update": "~1.0.7",
|
|
28
153
|
"use-measure": "~0.3.0",
|
|
29
|
-
"use-onclickoutside": "~0.3.
|
|
154
|
+
"use-onclickoutside": "~0.3.2"
|
|
30
155
|
},
|
|
31
156
|
"peerDependencies": {
|
|
32
|
-
"lodash": "^4.17.
|
|
33
|
-
"react": "~17.0.
|
|
34
|
-
"react-dom": "^17.0.
|
|
157
|
+
"lodash": "^4.17.21",
|
|
158
|
+
"react": "~17.0.2",
|
|
159
|
+
"react-dom": "^17.0.2"
|
|
35
160
|
}
|
|
36
161
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const capitalize: (string: string) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composes single-argument functions from right to left. The rightmost
|
|
3
|
+
* function can take multiple arguments as it provides the signature for
|
|
4
|
+
* the resulting composite function. [From redux v4.0.5]
|
|
5
|
+
*
|
|
6
|
+
* @param {...Function} funcs The functions to compose.
|
|
7
|
+
* @returns {Function} A function obtained by composing the argument functions
|
|
8
|
+
* from right to left. For example, compose(f, g, h) is identical to doing
|
|
9
|
+
* (...args) => f(g(h(...args))).
|
|
10
|
+
*/
|
|
11
|
+
export declare function compose(...funcs: any[]): any;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { default as useMeasure } from 'use-measure';
|
|
2
|
+
export { default as useExecutionTimer } from './useExecutionTimer';
|
|
3
|
+
export { default as useExpandState } from './useExpandState';
|
|
4
|
+
export { default as useHotkeys } from './useHotkeys';
|
|
5
|
+
export { default as useHoverHandlersDelay } from './useHoverHandlersDelay';
|
|
6
|
+
export { default as useResizeObserver } from './useResizeObserver';
|
|
7
|
+
export { default as useShouldRecalculate } from './useShouldRecalculate';
|
|
8
|
+
export { default as useWindowScrollerList } from './useWindowScrollerList';
|
|
9
|
+
export { default as useWindowSize } from './useWindowSize';
|
|
10
|
+
export { default as useForceUpdate } from 'use-force-update';
|
|
11
|
+
export { default as useOnClickOutside } from 'use-onclickoutside';
|
|
12
|
+
export { useUncontrolled } from 'uncontrollable';
|
|
13
|
+
export { default as usePrevious } from './usePrevious';
|
|
14
|
+
export { default as useCancellableDelayedCallback } from './useCancellableDelayedCallback';
|
|
15
|
+
export { default as useDerivedStateFromProps } from './useDerivedStateFromProps';
|
|
16
|
+
export * from './useSetRef';
|
|
17
|
+
export * from './useParentElement';
|
|
18
|
+
export * from './useOnElementResize';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useCancellableDelayedCallback(cb: any, delay: any): ((...args: any[]) => void)[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useDerivedStateFromProp(prop: any, options?: {}): any[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useExecutionDelay(startFn: any, cleanFn: any, delayTime: any): ((...args: any[]) => void)[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export default function useExpandState({ items, itemKey, expanded: expandedProp, onExpand, onExpandChange, onExpandAll, onToggleExpand, onCollapse, }: {
|
|
2
|
+
items?: never[] | undefined;
|
|
3
|
+
itemKey?: string | undefined;
|
|
4
|
+
expanded?: {} | undefined;
|
|
5
|
+
onExpand: any;
|
|
6
|
+
onExpandChange?: (() => null) | undefined;
|
|
7
|
+
onExpandAll?: (() => null) | undefined;
|
|
8
|
+
onToggleExpand: any;
|
|
9
|
+
onCollapse: any;
|
|
10
|
+
}): {
|
|
11
|
+
state: {
|
|
12
|
+
expanded: any;
|
|
13
|
+
isExpandedAll: boolean;
|
|
14
|
+
};
|
|
15
|
+
actions: {
|
|
16
|
+
expand: (item: any, stateData?: boolean) => void;
|
|
17
|
+
toggleExpandAll: (stateData?: boolean) => void;
|
|
18
|
+
toggleExpand: (item: any, stateData?: boolean) => void;
|
|
19
|
+
collapse: (item: any) => void;
|
|
20
|
+
};
|
|
21
|
+
setExpanded: any;
|
|
22
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default function useHoverHandlersDelay({ onMouseOver, onMouseLeave, hideDelay, showDelay, }: {
|
|
2
|
+
onMouseOver: any;
|
|
3
|
+
onMouseLeave: any;
|
|
4
|
+
hideDelay?: number | undefined;
|
|
5
|
+
showDelay?: number | undefined;
|
|
6
|
+
}): {
|
|
7
|
+
onMouseOver: () => void;
|
|
8
|
+
onMouseLeave: () => void;
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useParentElement: (ref: any) => any;
|