@elliemae/ds-utilities 2.3.1 → 3.0.0-alpha.3
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/dist/cjs/capitalize.js +35 -0
- package/dist/cjs/capitalize.js.map +7 -0
- package/dist/cjs/compose.js +45 -0
- package/dist/cjs/compose.js.map +7 -0
- package/dist/cjs/getComponentFromProps.js +57 -0
- package/dist/cjs/getComponentFromProps.js.map +7 -0
- package/dist/cjs/hooks/index.js +73 -0
- package/dist/cjs/hooks/index.js.map +7 -0
- package/dist/cjs/hooks/useCancellableDelayedCallback.js +51 -0
- package/dist/cjs/hooks/useCancellableDelayedCallback.js.map +7 -0
- package/dist/cjs/hooks/useDerivedStateFromProps.js +67 -0
- package/dist/cjs/hooks/useDerivedStateFromProps.js.map +7 -0
- package/dist/cjs/hooks/useExecutionTimer.js +50 -0
- package/dist/cjs/hooks/useExecutionTimer.js.map +7 -0
- package/dist/cjs/hooks/useExpandState.js +137 -0
- package/dist/cjs/hooks/useExpandState.js.map +7 -0
- package/dist/cjs/hooks/useFocusTrap.js +49 -0
- package/dist/cjs/hooks/useFocusTrap.js.map +7 -0
- package/dist/cjs/hooks/useHotkeys.js +45 -0
- package/dist/cjs/hooks/useHotkeys.js.map +7 -0
- package/dist/cjs/hooks/useHoverHandlersDelay.js +58 -0
- package/dist/cjs/hooks/useHoverHandlersDelay.js.map +7 -0
- package/dist/cjs/hooks/useIsShowingEllipsis.js +58 -0
- package/dist/cjs/hooks/useIsShowingEllipsis.js.map +7 -0
- package/dist/cjs/hooks/useOnElementResize.js +55 -0
- package/dist/cjs/hooks/useOnElementResize.js.map +7 -0
- package/dist/cjs/hooks/useParentElement.js +43 -0
- package/dist/cjs/hooks/useParentElement.js.map +7 -0
- package/dist/cjs/hooks/usePrevious.js +44 -0
- package/dist/cjs/hooks/usePrevious.js.map +7 -0
- package/dist/cjs/hooks/useResizeObserver.js +60 -0
- package/dist/cjs/hooks/useResizeObserver.js.map +7 -0
- package/dist/cjs/hooks/useSetRef.js +42 -0
- package/dist/cjs/hooks/useSetRef.js.map +7 -0
- package/dist/cjs/hooks/useShouldRecalculate.js +44 -0
- package/dist/cjs/hooks/useShouldRecalculate.js.map +7 -0
- package/dist/cjs/hooks/useWindowScrollerList.js +83 -0
- package/dist/cjs/hooks/useWindowScrollerList.js.map +7 -0
- package/dist/cjs/hooks/useWindowSize.js +57 -0
- package/dist/cjs/hooks/useWindowSize.js.map +7 -0
- package/dist/cjs/index.js +146 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/onClickHandlerForNonInteractiveElements.js +49 -0
- package/dist/cjs/onClickHandlerForNonInteractiveElements.js.map +7 -0
- package/dist/cjs/operators.js +68 -0
- package/dist/cjs/operators.js.map +7 -0
- package/dist/cjs/platform.js +37 -0
- package/dist/cjs/platform.js.map +7 -0
- package/dist/cjs/reactTypesUtility.js +58 -0
- package/dist/cjs/reactTypesUtility.js.map +7 -0
- package/dist/cjs/scrollingTimer.js +46 -0
- package/dist/cjs/scrollingTimer.js.map +7 -0
- package/dist/cjs/system.js +60 -0
- package/dist/cjs/system.js.map +7 -0
- package/dist/cjs/timeUtils.js +43 -0
- package/dist/cjs/timeUtils.js.map +7 -0
- package/dist/cjs/utils.js +143 -0
- package/dist/cjs/utils.js.map +7 -0
- package/dist/cjs/validations.js +57 -0
- package/dist/cjs/validations.js.map +7 -0
- package/dist/esm/capitalize.js +6 -0
- package/dist/esm/capitalize.js.map +7 -0
- package/dist/esm/compose.js +16 -0
- package/dist/esm/compose.js.map +7 -0
- package/dist/esm/getComponentFromProps.js +30 -0
- package/dist/esm/getComponentFromProps.js.map +7 -0
- package/dist/esm/hooks/index.js +44 -0
- package/dist/esm/hooks/index.js.map +7 -0
- package/dist/esm/hooks/useCancellableDelayedCallback.js +22 -0
- package/dist/esm/hooks/useCancellableDelayedCallback.js.map +7 -0
- package/dist/esm/hooks/useDerivedStateFromProps.js +38 -0
- package/dist/esm/hooks/useDerivedStateFromProps.js.map +7 -0
- package/dist/esm/hooks/useExecutionTimer.js +21 -0
- package/dist/esm/hooks/useExecutionTimer.js.map +7 -0
- package/dist/esm/hooks/useExpandState.js +110 -0
- package/dist/esm/hooks/useExpandState.js.map +7 -0
- package/dist/esm/hooks/useFocusTrap.js +20 -0
- package/dist/esm/hooks/useFocusTrap.js.map +7 -0
- package/dist/esm/hooks/useHotkeys.js +16 -0
- package/dist/esm/hooks/useHotkeys.js.map +7 -0
- package/{esm → dist/esm}/hooks/useHoverHandlersDelay.js +15 -12
- package/dist/esm/hooks/useHoverHandlersDelay.js.map +7 -0
- package/{esm → dist/esm}/hooks/useIsShowingEllipsis.js +9 -12
- package/dist/esm/hooks/useIsShowingEllipsis.js.map +7 -0
- package/dist/esm/hooks/useOnElementResize.js +26 -0
- package/dist/esm/hooks/useOnElementResize.js.map +7 -0
- package/dist/esm/hooks/useParentElement.js +14 -0
- package/dist/esm/hooks/useParentElement.js.map +7 -0
- package/dist/esm/hooks/usePrevious.js +15 -0
- package/dist/esm/hooks/usePrevious.js.map +7 -0
- package/dist/esm/hooks/useResizeObserver.js +31 -0
- package/dist/esm/hooks/useResizeObserver.js.map +7 -0
- package/dist/esm/hooks/useSetRef.js +13 -0
- package/dist/esm/hooks/useSetRef.js.map +7 -0
- package/dist/esm/hooks/useShouldRecalculate.js +15 -0
- package/dist/esm/hooks/useShouldRecalculate.js.map +7 -0
- package/{esm → dist/esm}/hooks/useWindowScrollerList.js +20 -29
- package/dist/esm/hooks/useWindowScrollerList.js.map +7 -0
- package/dist/esm/hooks/useWindowSize.js +28 -0
- package/dist/esm/hooks/useWindowSize.js.map +7 -0
- package/dist/esm/index.js +206 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/onClickHandlerForNonInteractiveElements.js +20 -0
- package/dist/esm/onClickHandlerForNonInteractiveElements.js.map +7 -0
- package/dist/esm/operators.js +39 -0
- package/dist/esm/operators.js.map +7 -0
- package/dist/esm/platform.js +8 -0
- package/dist/esm/platform.js.map +7 -0
- package/dist/esm/reactTypesUtility.js +29 -0
- package/dist/esm/reactTypesUtility.js.map +7 -0
- package/dist/esm/scrollingTimer.js +17 -0
- package/dist/esm/scrollingTimer.js.map +7 -0
- package/dist/esm/system.js +31 -0
- package/dist/esm/system.js.map +7 -0
- package/dist/esm/timeUtils.js +14 -0
- package/dist/esm/timeUtils.js.map +7 -0
- package/dist/esm/utils.js +154 -0
- package/dist/esm/utils.js.map +7 -0
- package/dist/esm/validations.js +28 -0
- package/dist/esm/validations.js.map +7 -0
- package/package.json +80 -75
- package/cjs/capitalize.js +0 -7
- package/cjs/compose.js +0 -38
- package/cjs/getComponentFromProps.js +0 -30
- package/cjs/hooks/index.js +0 -65
- package/cjs/hooks/useCancellableDelayedCallback.js +0 -26
- package/cjs/hooks/useDerivedStateFromProps.js +0 -56
- package/cjs/hooks/useExecutionTimer.js +0 -31
- package/cjs/hooks/useExpandState.js +0 -133
- package/cjs/hooks/useFocusTrap.js +0 -31
- package/cjs/hooks/useHotkeys.js +0 -25
- package/cjs/hooks/useHoverHandlersDelay.js +0 -28
- package/cjs/hooks/useIsShowingEllipsis.js +0 -36
- package/cjs/hooks/useOnElementResize.js +0 -38
- package/cjs/hooks/useParentElement.js +0 -16
- package/cjs/hooks/usePrevious.js +0 -13
- package/cjs/hooks/useResizeObserver.js +0 -33
- package/cjs/hooks/useSetRef.js +0 -15
- package/cjs/hooks/useShouldRecalculate.js +0 -17
- package/cjs/hooks/useWindowScrollerList.js +0 -65
- package/cjs/hooks/useWindowSize.js +0 -27
- package/cjs/index.js +0 -270
- package/cjs/onClickHandlerForNonInteractiveElements.js +0 -22
- package/cjs/operators.js +0 -63
- package/cjs/platform.js +0 -9
- package/cjs/reactTypesUtility.js +0 -35
- package/cjs/scrollingTimer.js +0 -24
- package/cjs/system.js +0 -43
- package/cjs/timeUtils.js +0 -25
- package/cjs/utils.js +0 -263
- package/cjs/validations.js +0 -44
- package/esm/capitalize.js +0 -3
- package/esm/compose.js +0 -34
- package/esm/getComponentFromProps.js +0 -23
- package/esm/hooks/index.js +0 -20
- package/esm/hooks/useCancellableDelayedCallback.js +0 -24
- package/esm/hooks/useDerivedStateFromProps.js +0 -54
- package/esm/hooks/useExecutionTimer.js +0 -29
- package/esm/hooks/useExpandState.js +0 -127
- package/esm/hooks/useFocusTrap.js +0 -27
- package/esm/hooks/useHotkeys.js +0 -19
- package/esm/hooks/useOnElementResize.js +0 -34
- package/esm/hooks/useParentElement.js +0 -12
- package/esm/hooks/usePrevious.js +0 -11
- package/esm/hooks/useResizeObserver.js +0 -26
- package/esm/hooks/useSetRef.js +0 -11
- package/esm/hooks/useShouldRecalculate.js +0 -15
- package/esm/hooks/useWindowSize.js +0 -25
- package/esm/index.js +0 -33
- package/esm/onClickHandlerForNonInteractiveElements.js +0 -20
- package/esm/operators.js +0 -46
- package/esm/platform.js +0 -4
- package/esm/reactTypesUtility.js +0 -22
- package/esm/scrollingTimer.js +0 -20
- package/esm/system.js +0 -37
- package/esm/timeUtils.js +0 -20
- package/esm/utils.js +0 -99
- package/esm/validations.js +0 -38
- package/types/capitalize.d.ts +0 -1
- package/types/compose.d.ts +0 -11
- package/types/getComponentFromProps.d.ts +0 -2
- package/types/hooks/index.d.ts +0 -20
- package/types/hooks/useCancellableDelayedCallback.d.ts +0 -1
- package/types/hooks/useDerivedStateFromProps.d.ts +0 -1
- package/types/hooks/useExecutionTimer.d.ts +0 -1
- package/types/hooks/useExpandState.d.ts +0 -22
- package/types/hooks/useFocusTrap.d.ts +0 -8
- package/types/hooks/useHotkeys.d.ts +0 -5
- package/types/hooks/useHoverHandlersDelay.d.ts +0 -9
- package/types/hooks/useIsShowingEllipsis.d.ts +0 -5
- package/types/hooks/useOnElementResize.d.ts +0 -2
- package/types/hooks/useParentElement.d.ts +0 -1
- package/types/hooks/usePrevious.d.ts +0 -2
- package/types/hooks/useResizeObserver.d.ts +0 -2
- package/types/hooks/useSetRef.d.ts +0 -2
- package/types/hooks/useShouldRecalculate.d.ts +0 -1
- package/types/hooks/useWindowScrollerList.d.ts +0 -4
- package/types/hooks/useWindowSize.d.ts +0 -1
- package/types/index.d.ts +0 -13
- package/types/onClickHandlerForNonInteractiveElements.d.ts +0 -12
- package/types/operators.d.ts +0 -31
- package/types/platform.d.ts +0 -2
- package/types/reactTypesUtility.d.ts +0 -6
- package/types/scrollingTimer.d.ts +0 -1
- package/types/system.d.ts +0 -3
- package/types/timeUtils.d.ts +0 -7
- package/types/utils.d.ts +0 -23
- package/types/validations.d.ts +0 -23
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
3
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
4
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
6
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
7
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
8
|
-
import { useMemo } from 'react';
|
|
9
|
-
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
10
|
-
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
11
|
-
import { isFunction } from 'lodash';
|
|
12
|
-
import useDerivedStateFromProp from './useDerivedStateFromProps.js';
|
|
13
|
-
|
|
14
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
-
|
|
16
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
-
|
|
18
|
-
const toggleStateInObject = (obj, key, value) => {
|
|
19
|
-
const nextObj = _objectSpread({}, obj);
|
|
20
|
-
|
|
21
|
-
if (nextObj[key]) {
|
|
22
|
-
delete nextObj[key];
|
|
23
|
-
} else {
|
|
24
|
-
nextObj[key] = value;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return nextObj;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const noop = () => null;
|
|
31
|
-
|
|
32
|
-
function useExpandState(_ref) {
|
|
33
|
-
let {
|
|
34
|
-
items = [],
|
|
35
|
-
itemKey = 'id',
|
|
36
|
-
expanded: expandedProp = {},
|
|
37
|
-
onExpand,
|
|
38
|
-
onExpandChange = noop,
|
|
39
|
-
onExpandAll = noop,
|
|
40
|
-
onToggleExpand,
|
|
41
|
-
onCollapse
|
|
42
|
-
} = _ref;
|
|
43
|
-
const [expanded, setExpanded] = useDerivedStateFromProp(expandedProp);
|
|
44
|
-
const isExpandedAll = useMemo(() => Object.keys(expanded).length === items.length, [expanded, items]);
|
|
45
|
-
|
|
46
|
-
const toggleExpandAll = function () {
|
|
47
|
-
let stateData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
48
|
-
setExpanded(() => {
|
|
49
|
-
const nextState = {};
|
|
50
|
-
|
|
51
|
-
if (!isExpandedAll) {
|
|
52
|
-
items.forEach(item => {
|
|
53
|
-
nextState[item[itemKey]] = stateData;
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
onExpandChange(nextState);
|
|
58
|
-
onExpandAll(nextState);
|
|
59
|
-
return nextState;
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const expand = function (item) {
|
|
64
|
-
let stateData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
65
|
-
if (!item) return;
|
|
66
|
-
|
|
67
|
-
if (isFunction(onExpand)) {
|
|
68
|
-
onExpand(item);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
setExpanded(prevState => {
|
|
72
|
-
const key = item[itemKey];
|
|
73
|
-
|
|
74
|
-
const nextState = _objectSpread(_objectSpread({}, prevState), {}, {
|
|
75
|
-
[key]: stateData
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
onExpandChange(nextState, item);
|
|
79
|
-
return nextState;
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const toggleExpand = function (item) {
|
|
84
|
-
let stateData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
85
|
-
|
|
86
|
-
if (isFunction(onToggleExpand)) {
|
|
87
|
-
onToggleExpand(item);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
setExpanded(prevState => {
|
|
91
|
-
const key = item[itemKey];
|
|
92
|
-
const nextState = toggleStateInObject(prevState, key, stateData);
|
|
93
|
-
onExpandChange(nextState, item);
|
|
94
|
-
return nextState;
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const collapse = item => {
|
|
99
|
-
if (isFunction(onCollapse)) {
|
|
100
|
-
onCollapse(item);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
setExpanded(prevState => {
|
|
104
|
-
const nextState = _objectSpread({}, prevState);
|
|
105
|
-
|
|
106
|
-
delete nextState[item[itemKey]];
|
|
107
|
-
onExpandChange(nextState, item);
|
|
108
|
-
return nextState;
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
return {
|
|
113
|
-
state: {
|
|
114
|
-
expanded,
|
|
115
|
-
isExpandedAll
|
|
116
|
-
},
|
|
117
|
-
actions: {
|
|
118
|
-
expand,
|
|
119
|
-
toggleExpandAll,
|
|
120
|
-
toggleExpand,
|
|
121
|
-
collapse
|
|
122
|
-
},
|
|
123
|
-
setExpanded
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export { useExpandState as default };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
|
|
3
|
-
const useFocusTrap = _ref => {
|
|
4
|
-
let {
|
|
5
|
-
firstElementRef,
|
|
6
|
-
lastElementRef,
|
|
7
|
-
onKeyDown
|
|
8
|
-
} = _ref;
|
|
9
|
-
return useCallback(e => {
|
|
10
|
-
if (onKeyDown) onKeyDown(e); // we need to check all the condition before preventing default
|
|
11
|
-
// because we want last-element/first-element tab/shift-tab to keep working
|
|
12
|
-
|
|
13
|
-
if (e.key === 'Tab' && !e.shiftKey && e.target === lastElementRef.current && firstElementRef.current) {
|
|
14
|
-
e.preventDefault();
|
|
15
|
-
e.stopPropagation();
|
|
16
|
-
firstElementRef.current.focus();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (e.key === 'Tab' && e.shiftKey && e.target === firstElementRef.current && lastElementRef.current) {
|
|
20
|
-
e.preventDefault();
|
|
21
|
-
e.stopPropagation();
|
|
22
|
-
lastElementRef.current.focus();
|
|
23
|
-
}
|
|
24
|
-
}, [firstElementRef, lastElementRef, onKeyDown]);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export { useFocusTrap };
|
package/esm/hooks/useHotkeys.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
-
import hotkeys from 'hotkeys-js';
|
|
3
|
-
import { useCallback, useEffect } from 'react';
|
|
4
|
-
|
|
5
|
-
function useHotkeys(_ref) {
|
|
6
|
-
let {
|
|
7
|
-
keys,
|
|
8
|
-
handler,
|
|
9
|
-
options = {}
|
|
10
|
-
} = _ref;
|
|
11
|
-
let deps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
12
|
-
const memoizedCallback = useCallback(handler, deps);
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
hotkeys(keys, options, memoizedCallback);
|
|
15
|
-
return () => hotkeys.unbind(keys);
|
|
16
|
-
}, [memoizedCallback]);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { useHotkeys as default };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
-
import { useState, useRef, useEffect, useMemo } from 'react';
|
|
3
|
-
|
|
4
|
-
// Taken and modified from https://stackoverflow.com/a/60218754
|
|
5
|
-
|
|
6
|
-
const useOnElementResize = targetRef => {
|
|
7
|
-
var _targetRef$current$of, _targetRef$current, _targetRef$current$of2, _targetRef$current2;
|
|
8
|
-
|
|
9
|
-
const [width, setWidth] = useState((_targetRef$current$of = (_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : _targetRef$current.offsetWidth) !== null && _targetRef$current$of !== void 0 ? _targetRef$current$of : 0);
|
|
10
|
-
const [height, setHeight] = useState((_targetRef$current$of2 = (_targetRef$current2 = targetRef.current) === null || _targetRef$current2 === void 0 ? void 0 : _targetRef$current2.offsetHeight) !== null && _targetRef$current$of2 !== void 0 ? _targetRef$current$of2 : 0);
|
|
11
|
-
const observer = useRef();
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
function outputsize() {
|
|
14
|
-
var _targetRef$current$of3, _targetRef$current3, _targetRef$current$of4, _targetRef$current4;
|
|
15
|
-
|
|
16
|
-
setWidth((_targetRef$current$of3 = (_targetRef$current3 = targetRef.current) === null || _targetRef$current3 === void 0 ? void 0 : _targetRef$current3.offsetWidth) !== null && _targetRef$current$of3 !== void 0 ? _targetRef$current$of3 : 0);
|
|
17
|
-
setHeight((_targetRef$current$of4 = (_targetRef$current4 = targetRef.current) === null || _targetRef$current4 === void 0 ? void 0 : _targetRef$current4.offsetHeight) !== null && _targetRef$current$of4 !== void 0 ? _targetRef$current$of4 : 0);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
observer.current = new ResizeObserver(outputsize);
|
|
21
|
-
observer.current.observe(targetRef.current);
|
|
22
|
-
return () => {
|
|
23
|
-
var _observer$current;
|
|
24
|
-
|
|
25
|
-
(_observer$current = observer.current) === null || _observer$current === void 0 ? void 0 : _observer$current.disconnect();
|
|
26
|
-
};
|
|
27
|
-
}, [targetRef]);
|
|
28
|
-
return useMemo(() => ({
|
|
29
|
-
width,
|
|
30
|
-
height
|
|
31
|
-
}), [width, height]);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export { useOnElementResize };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
-
import { useState, useEffect } from 'react';
|
|
3
|
-
|
|
4
|
-
const useParentElement = ref => {
|
|
5
|
-
const [parent, setParent] = useState(ref.current);
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
if (ref.current) setParent(ref.current.parentNode);
|
|
8
|
-
});
|
|
9
|
-
return parent;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export { useParentElement };
|
package/esm/hooks/usePrevious.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
-
import { useState, useEffect } from 'react';
|
|
3
|
-
import raf from 'raf';
|
|
4
|
-
import ResizeObserver from 'resize-observer-polyfill';
|
|
5
|
-
|
|
6
|
-
function useResizeObserver(handler, el) {
|
|
7
|
-
const [node, setRef] = useState(el);
|
|
8
|
-
const resizeObserver = new ResizeObserver(entries => {
|
|
9
|
-
if (!Array.isArray(entries)) return;
|
|
10
|
-
if (!entries.length) return;
|
|
11
|
-
const entry = entries[0]; // execute on the next animation frame
|
|
12
|
-
|
|
13
|
-
raf(() => handler({
|
|
14
|
-
width: entry.target.offsetWidth,
|
|
15
|
-
height: entry.target.offsetHeight
|
|
16
|
-
}, entry.target));
|
|
17
|
-
});
|
|
18
|
-
const htmlEl = el || node;
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
if (htmlEl) resizeObserver.observe(htmlEl);
|
|
21
|
-
return () => htmlEl && resizeObserver.unobserve(htmlEl);
|
|
22
|
-
}, [htmlEl]);
|
|
23
|
-
return [setRef];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { useResizeObserver as default };
|
package/esm/hooks/useSetRef.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
function useShouldRecalculate(bool) {
|
|
4
|
-
const prevValueRef = useRef(0);
|
|
5
|
-
|
|
6
|
-
if (!bool) {
|
|
7
|
-
// If we need to recalculate, change the value we return
|
|
8
|
-
prevValueRef.current += 1;
|
|
9
|
-
} // else we return the same value as the previous render, which won't trigger a recalculation
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return prevValueRef.current;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { useShouldRecalculate as default };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
-
import { useState, useLayoutEffect } from 'react';
|
|
3
|
-
|
|
4
|
-
function useWindowSize() {
|
|
5
|
-
const [size, setSize] = useState([0, 0]);
|
|
6
|
-
useLayoutEffect(() => {
|
|
7
|
-
if (!window) return false;
|
|
8
|
-
|
|
9
|
-
function updateSize() {
|
|
10
|
-
setSize([window.innerWidth, window.innerHeight]);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
window.addEventListener('resize', updateSize);
|
|
14
|
-
window.addEventListener('orientationchange', updateSize);
|
|
15
|
-
updateSize();
|
|
16
|
-
return () => {
|
|
17
|
-
window.removeEventListener('resize', updateSize);
|
|
18
|
-
window.removeEventListener('orientationchange', updateSize);
|
|
19
|
-
};
|
|
20
|
-
}, []);
|
|
21
|
-
if (!window) return false;
|
|
22
|
-
return size;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { useWindowSize as default };
|
package/esm/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export { default as getComponentFromProps } from './getComponentFromProps.js';
|
|
2
|
-
export { default as onClickHandlerForNonInteractiveElements } from './onClickHandlerForNonInteractiveElements.js';
|
|
3
|
-
export { capitalize } from './capitalize.js';
|
|
4
|
-
export { checkEmpty, checkNotEmpty, contains, equal, greaterThan, greaterThanOrEquals, isIn, isNotIn, isNotNull, isNull, lessThanOrEquals, notEqual, startsWith, validDate } from './operators.js';
|
|
5
|
-
export { addOrRemove, arrayMove, cx, hashArray, removeUndefinedProperties, runAll, safeCall, toggleInArray, toggleInObject } from './utils.js';
|
|
6
|
-
export { logger, mergeRefs, setRef } from './system.js';
|
|
7
|
-
export { default as useMeasure } from 'use-measure';
|
|
8
|
-
export { default as useExecutionTimer } from './hooks/useExecutionTimer.js';
|
|
9
|
-
export { default as useExpandState } from './hooks/useExpandState.js';
|
|
10
|
-
export { default as useHotkeys } from './hooks/useHotkeys.js';
|
|
11
|
-
export { default as useHoverHandlersDelay } from './hooks/useHoverHandlersDelay.js';
|
|
12
|
-
export { default as useResizeObserver } from './hooks/useResizeObserver.js';
|
|
13
|
-
export { default as useShouldRecalculate } from './hooks/useShouldRecalculate.js';
|
|
14
|
-
export { default as useWindowScrollerList } from './hooks/useWindowScrollerList.js';
|
|
15
|
-
export { default as useWindowSize } from './hooks/useWindowSize.js';
|
|
16
|
-
export { default as useForceUpdate } from 'use-force-update';
|
|
17
|
-
export { default as useOnClickOutside } from 'use-onclickoutside';
|
|
18
|
-
export { useUncontrolled } from 'uncontrollable';
|
|
19
|
-
export { default as usePrevious } from './hooks/usePrevious.js';
|
|
20
|
-
export { default as useCancellableDelayedCallback } from './hooks/useCancellableDelayedCallback.js';
|
|
21
|
-
export { default as useDerivedStateFromProps } from './hooks/useDerivedStateFromProps.js';
|
|
22
|
-
export { useSetRef } from './hooks/useSetRef.js';
|
|
23
|
-
export { useParentElement } from './hooks/useParentElement.js';
|
|
24
|
-
export { useOnElementResize } from './hooks/useOnElementResize.js';
|
|
25
|
-
export { useIsShowingEllipsis } from './hooks/useIsShowingEllipsis.js';
|
|
26
|
-
export { useFocusTrap } from './hooks/useFocusTrap.js';
|
|
27
|
-
export { addLeadingZeros, getVisibleTimeByFormat } from './timeUtils.js';
|
|
28
|
-
export { compose } from './compose.js';
|
|
29
|
-
export { DOCUMENT, WINDOW } from './platform.js';
|
|
30
|
-
export { isClassComponent, isCompositeTypeElement, isDOMTypeElement, isElement, isFunctionComponent, isReactComponent } from './reactTypesUtility.js';
|
|
31
|
-
export { resetTimer } from './scrollingTimer.js';
|
|
32
|
-
export { isGreaterThan, isRequired, isValidDate } from './validations.js';
|
|
33
|
-
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';
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* onClickHandler: callback
|
|
3
|
-
*
|
|
4
|
-
* @param onClickHandler
|
|
5
|
-
*/
|
|
6
|
-
var onClickHandlerForNonInteractiveElements = (onClickHandler => ({
|
|
7
|
-
role: 'button',
|
|
8
|
-
tabIndex: '0',
|
|
9
|
-
onClick: onClickHandler,
|
|
10
|
-
onKeyPress: event => {
|
|
11
|
-
event.stopPropagation();
|
|
12
|
-
const {
|
|
13
|
-
keycode,
|
|
14
|
-
key
|
|
15
|
-
} = event;
|
|
16
|
-
if (key === 'Enter') onClickHandler(event);else if (keycode === 13) onClickHandler(event);
|
|
17
|
-
}
|
|
18
|
-
}));
|
|
19
|
-
|
|
20
|
-
export { onClickHandlerForNonInteractiveElements as default };
|
package/esm/operators.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
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';
|
|
4
|
-
import { isEmpty } from 'lodash';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Check if the value is null undefined ''
|
|
8
|
-
*
|
|
9
|
-
* @param value
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const checkNotEmpty = value => value === '' || value === undefined || value == [] || value === null || isEmpty(value);
|
|
13
|
-
const checkEmpty = value => !isEmpty(value);
|
|
14
|
-
/**
|
|
15
|
-
* @param value: number
|
|
16
|
-
* @param comparator: number
|
|
17
|
-
* @param value
|
|
18
|
-
* @param comparator
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
const greaterThan = (value, comparator) => value > comparator;
|
|
22
|
-
/**
|
|
23
|
-
* Check if a valid date with format MM/DD/YYYY
|
|
24
|
-
*
|
|
25
|
-
* @param {*} value: string
|
|
26
|
-
* @param value
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
const validDate = value => {
|
|
30
|
-
const dateValidationRegex = /^\d{1,2}\/\d{1,2}\/\d{4}$/;
|
|
31
|
-
if (!dateValidationRegex.test(value)) return false;
|
|
32
|
-
const [m, d, y] = value.split('/').map(n => Number(n));
|
|
33
|
-
return m === Number(new Date(y, m - 1, d).getMonth()) + 1 && d === Number(new Date(y, m - 1, d).getDate());
|
|
34
|
-
};
|
|
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);
|
|
45
|
-
|
|
46
|
-
export { checkEmpty, checkNotEmpty, contains, equal, greaterThan, greaterThanOrEquals, isIn, isNotIn, isNotNull, isNull, lessThanOrEquals, notEqual, startsWith, validDate };
|
package/esm/platform.js
DELETED
package/esm/reactTypesUtility.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
function isClassComponent(component) {
|
|
4
|
-
return !!(typeof component === 'function' && !!component.prototype.isReactComponent);
|
|
5
|
-
}
|
|
6
|
-
function isFunctionComponent(component) {
|
|
7
|
-
return typeof component === 'function' && String(component).includes('return React.createElement');
|
|
8
|
-
}
|
|
9
|
-
function isReactComponent(component) {
|
|
10
|
-
return !!(isClassComponent(component) || isFunctionComponent(component));
|
|
11
|
-
}
|
|
12
|
-
function isElement(element) {
|
|
13
|
-
return /*#__PURE__*/React.isValidElement(element);
|
|
14
|
-
}
|
|
15
|
-
function isDOMTypeElement(element) {
|
|
16
|
-
return isElement(element) && typeof element.type === 'string';
|
|
17
|
-
}
|
|
18
|
-
function isCompositeTypeElement(element) {
|
|
19
|
-
return isElement(element) && typeof element.type === 'function';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { isClassComponent, isCompositeTypeElement, isDOMTypeElement, isElement, isFunctionComponent, isReactComponent };
|
package/esm/scrollingTimer.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
function resetTimer(func) {
|
|
2
|
-
let timeout;
|
|
3
|
-
return function () {
|
|
4
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
5
|
-
args[_key] = arguments[_key];
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const context = this;
|
|
9
|
-
|
|
10
|
-
const lastCall = () => {
|
|
11
|
-
timeout = null;
|
|
12
|
-
func.apply(context, args);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
clearTimeout(timeout);
|
|
16
|
-
timeout = setTimeout(lastCall, 300);
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export { resetTimer };
|
package/esm/system.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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';
|
|
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';
|
|
10
|
-
import { isFunction } from 'lodash';
|
|
11
|
-
|
|
12
|
-
const setRef = (ref, value) => {
|
|
13
|
-
if (isFunction(ref)) {
|
|
14
|
-
ref(value);
|
|
15
|
-
} else if (ref) {
|
|
16
|
-
ref.current = value;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
function mergeRefs() {
|
|
20
|
-
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
21
|
-
refs[_key] = arguments[_key];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return node => {
|
|
25
|
-
if (!node) return;
|
|
26
|
-
refs.forEach(ref => {
|
|
27
|
-
if (isFunction(ref)) {
|
|
28
|
-
ref(node);
|
|
29
|
-
} else if (ref) {
|
|
30
|
-
ref.current = node;
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
function logger() {}
|
|
36
|
-
|
|
37
|
-
export { logger, mergeRefs, setRef };
|
package/esm/timeUtils.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
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';
|
|
10
|
-
import { padStart } from 'lodash';
|
|
11
|
-
|
|
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');
|
|
19
|
-
|
|
20
|
-
export { addLeadingZeros, getVisibleTimeByFormat };
|
package/esm/utils.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
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';
|
|
10
|
-
import { omit, cloneDeep, isFunction } from 'lodash';
|
|
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';
|
|
12
|
-
|
|
13
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
-
|
|
15
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
|
-
/**
|
|
17
|
-
* Concatenates classNames from arguments
|
|
18
|
-
*
|
|
19
|
-
* @param {...any} classnames
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
const cx = function () {
|
|
23
|
-
for (var _len = arguments.length, classnames = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
24
|
-
classnames[_key] = arguments[_key];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return classnames.reduce((result, cn) => "".concat(result, " ").concat(cn || ''), '');
|
|
28
|
-
}; // if entry exists, remove it, if not, add it
|
|
29
|
-
|
|
30
|
-
const toggleInObject = (obj, key, value) => obj[key] !== undefined ? omit(obj, [key]) : _objectSpread(_objectSpread({}, obj), {}, {
|
|
31
|
-
[key]: value
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const toggleInArray = (array, value) => array.indexOf(value) === -1 ? [value] : [];
|
|
35
|
-
|
|
36
|
-
const arrayMoveMutate = (array, from, to) => {
|
|
37
|
-
array.splice(to < 0 ? array.length + to : to, 0, array.splice(from, 1)[0]);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const arrayMove = (array, from, to) => {
|
|
41
|
-
array = array.slice();
|
|
42
|
-
arrayMoveMutate(array, from, to);
|
|
43
|
-
return array;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const accessorDefault = item => item;
|
|
47
|
-
|
|
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));
|
|
51
|
-
|
|
52
|
-
if (index !== -1) {
|
|
53
|
-
const nextArray = cloneDeep(array);
|
|
54
|
-
nextArray.splice(index, 1);
|
|
55
|
-
return nextArray;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return [...array, item];
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
function runAll() {
|
|
62
|
-
for (var _len2 = arguments.length, fns = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
63
|
-
fns[_key2] = arguments[_key2];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return function () {
|
|
67
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
68
|
-
args[_key3] = arguments[_key3];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return fns.forEach(fn => {
|
|
72
|
-
if (Array.isArray(fn)) runAll(fn);
|
|
73
|
-
if (isFunction(fn)) fn(...args);
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
function hashArray(arr, fieldName) {
|
|
78
|
-
return arr.reduce((result, item) => _objectSpread(_objectSpread({}, result), {}, {
|
|
79
|
-
[fieldName ? item[fieldName] : item]: true
|
|
80
|
-
}), {});
|
|
81
|
-
}
|
|
82
|
-
function safeCall(fun) {
|
|
83
|
-
if (isFunction(fun)) {
|
|
84
|
-
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
85
|
-
args[_key4 - 1] = arguments[_key4];
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
fun(...args);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
const removeUndefinedProperties = obj => {
|
|
92
|
-
const cleanObject = _objectSpread({}, obj);
|
|
93
|
-
|
|
94
|
-
Object.keys(obj).forEach(key => cleanObject[key] === undefined && delete cleanObject[key]);
|
|
95
|
-
return cleanObject;
|
|
96
|
-
};
|
|
97
|
-
var utils = {};
|
|
98
|
-
|
|
99
|
-
export { addOrRemove, arrayMove, cx, utils as default, hashArray, removeUndefinedProperties, runAll, safeCall, toggleInArray, toggleInObject };
|
package/esm/validations.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { checkNotEmpty, greaterThan, validDate } from './operators.js';
|
|
2
|
-
|
|
3
|
-
const isRequired = _ref => {
|
|
4
|
-
let {
|
|
5
|
-
value,
|
|
6
|
-
help = 'Field is Required'
|
|
7
|
-
} = _ref;
|
|
8
|
-
return {
|
|
9
|
-
payload: help,
|
|
10
|
-
error: checkNotEmpty(value)
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
const isGreaterThan = _ref2 => {
|
|
14
|
-
let {
|
|
15
|
-
value,
|
|
16
|
-
help,
|
|
17
|
-
comparator = 0
|
|
18
|
-
} = _ref2;
|
|
19
|
-
if (!help) help = "Max value ".concat(comparator);
|
|
20
|
-
return {
|
|
21
|
-
payload: help,
|
|
22
|
-
error: greaterThan(value, comparator)
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
const isValidDate = _ref3 => {
|
|
26
|
-
let {
|
|
27
|
-
value,
|
|
28
|
-
help,
|
|
29
|
-
format = 'MM/DD/AAA'
|
|
30
|
-
} = _ref3;
|
|
31
|
-
if (!help) help = "Valid Date is required ".concat(format);
|
|
32
|
-
return {
|
|
33
|
-
payload: help,
|
|
34
|
-
error: !validDate(value)
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export { isGreaterThan, isRequired, isValidDate };
|
package/types/capitalize.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const capitalize: (string: string) => string;
|