@elliemae/ds-utilities 2.3.1-rc.2 → 3.0.0-alpha.2
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 +71 -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/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 +42 -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/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
package/cjs/hooks/useHotkeys.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
4
|
-
var hotkeys = require('hotkeys-js');
|
|
5
|
-
var React = require('react');
|
|
6
|
-
|
|
7
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
-
|
|
9
|
-
var hotkeys__default = /*#__PURE__*/_interopDefaultLegacy(hotkeys);
|
|
10
|
-
|
|
11
|
-
function useHotkeys(_ref) {
|
|
12
|
-
let {
|
|
13
|
-
keys,
|
|
14
|
-
handler,
|
|
15
|
-
options = {}
|
|
16
|
-
} = _ref;
|
|
17
|
-
let deps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
18
|
-
const memoizedCallback = React.useCallback(handler, deps);
|
|
19
|
-
React.useEffect(() => {
|
|
20
|
-
hotkeys__default["default"](keys, options, memoizedCallback);
|
|
21
|
-
return () => hotkeys__default["default"].unbind(keys);
|
|
22
|
-
}, [memoizedCallback]);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = useHotkeys;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
|
|
5
|
-
function useHoverHandlersDelay(_ref) {
|
|
6
|
-
let {
|
|
7
|
-
onMouseOver,
|
|
8
|
-
onMouseLeave,
|
|
9
|
-
hideDelay = 300,
|
|
10
|
-
showDelay = 300
|
|
11
|
-
} = _ref;
|
|
12
|
-
const hideTimer = React.useRef();
|
|
13
|
-
const showTimer = React.useRef();
|
|
14
|
-
const delayedHide = React.useCallback(() => {
|
|
15
|
-
clearTimeout(showTimer.current);
|
|
16
|
-
hideTimer.current = setTimeout(onMouseLeave, hideDelay);
|
|
17
|
-
}, []);
|
|
18
|
-
const delayedShow = React.useCallback(() => {
|
|
19
|
-
clearTimeout(hideTimer.current);
|
|
20
|
-
showTimer.current = setTimeout(onMouseOver, showDelay);
|
|
21
|
-
}, []);
|
|
22
|
-
return {
|
|
23
|
-
onMouseOver: delayedShow,
|
|
24
|
-
onMouseLeave: delayedHide
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = useHoverHandlersDelay;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
|
|
8
|
-
const useIsShowingEllipsis = () => {
|
|
9
|
-
const [element, setElement] = React.useState();
|
|
10
|
-
const [isShowingEllipsis, setIsShowingEllipsis] = React.useState(false);
|
|
11
|
-
const resizeObserver = React.useMemo(() => new ResizeObserver(entries => {
|
|
12
|
-
if (entries.length) {
|
|
13
|
-
const [textWrapperEntry] = entries;
|
|
14
|
-
const el = textWrapperEntry.target;
|
|
15
|
-
setIsShowingEllipsis((el === null || el === void 0 ? void 0 : el.scrollWidth) > (el === null || el === void 0 ? void 0 : el.clientWidth));
|
|
16
|
-
}
|
|
17
|
-
}), []);
|
|
18
|
-
React.useEffect(() => {
|
|
19
|
-
if (element) {
|
|
20
|
-
setIsShowingEllipsis(element.scrollWidth > element.clientWidth);
|
|
21
|
-
resizeObserver.observe(element);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return () => {
|
|
25
|
-
if (element) {
|
|
26
|
-
resizeObserver.unobserve(element);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
}, [resizeObserver, element]);
|
|
30
|
-
return {
|
|
31
|
-
setElement,
|
|
32
|
-
isShowingEllipsis
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
exports.useIsShowingEllipsis = useIsShowingEllipsis;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
|
|
8
|
-
// Taken and modified from https://stackoverflow.com/a/60218754
|
|
9
|
-
|
|
10
|
-
const useOnElementResize = targetRef => {
|
|
11
|
-
var _targetRef$current$of, _targetRef$current, _targetRef$current$of2, _targetRef$current2;
|
|
12
|
-
|
|
13
|
-
const [width, setWidth] = React.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);
|
|
14
|
-
const [height, setHeight] = React.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);
|
|
15
|
-
const observer = React.useRef();
|
|
16
|
-
React.useEffect(() => {
|
|
17
|
-
function outputsize() {
|
|
18
|
-
var _targetRef$current$of3, _targetRef$current3, _targetRef$current$of4, _targetRef$current4;
|
|
19
|
-
|
|
20
|
-
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);
|
|
21
|
-
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);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
observer.current = new ResizeObserver(outputsize);
|
|
25
|
-
observer.current.observe(targetRef.current);
|
|
26
|
-
return () => {
|
|
27
|
-
var _observer$current;
|
|
28
|
-
|
|
29
|
-
(_observer$current = observer.current) === null || _observer$current === void 0 ? void 0 : _observer$current.disconnect();
|
|
30
|
-
};
|
|
31
|
-
}, [targetRef]);
|
|
32
|
-
return React.useMemo(() => ({
|
|
33
|
-
width,
|
|
34
|
-
height
|
|
35
|
-
}), [width, height]);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
exports.useOnElementResize = useOnElementResize;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
|
|
8
|
-
const useParentElement = ref => {
|
|
9
|
-
const [parent, setParent] = React.useState(ref.current);
|
|
10
|
-
React.useEffect(() => {
|
|
11
|
-
if (ref.current) setParent(ref.current.parentNode);
|
|
12
|
-
});
|
|
13
|
-
return parent;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
exports.useParentElement = useParentElement;
|
package/cjs/hooks/usePrevious.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
4
|
-
var React = require('react');
|
|
5
|
-
var raf = require('raf');
|
|
6
|
-
var ResizeObserver = require('resize-observer-polyfill');
|
|
7
|
-
|
|
8
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
-
|
|
10
|
-
var raf__default = /*#__PURE__*/_interopDefaultLegacy(raf);
|
|
11
|
-
var ResizeObserver__default = /*#__PURE__*/_interopDefaultLegacy(ResizeObserver);
|
|
12
|
-
|
|
13
|
-
function useResizeObserver(handler, el) {
|
|
14
|
-
const [node, setRef] = React.useState(el);
|
|
15
|
-
const resizeObserver = new ResizeObserver__default["default"](entries => {
|
|
16
|
-
if (!Array.isArray(entries)) return;
|
|
17
|
-
if (!entries.length) return;
|
|
18
|
-
const entry = entries[0]; // execute on the next animation frame
|
|
19
|
-
|
|
20
|
-
raf__default["default"](() => handler({
|
|
21
|
-
width: entry.target.offsetWidth,
|
|
22
|
-
height: entry.target.offsetHeight
|
|
23
|
-
}, entry.target));
|
|
24
|
-
});
|
|
25
|
-
const htmlEl = el || node;
|
|
26
|
-
React.useEffect(() => {
|
|
27
|
-
if (htmlEl) resizeObserver.observe(htmlEl);
|
|
28
|
-
return () => htmlEl && resizeObserver.unobserve(htmlEl);
|
|
29
|
-
}, [htmlEl]);
|
|
30
|
-
return [setRef];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
module.exports = useResizeObserver;
|
package/cjs/hooks/useSetRef.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
|
|
7
|
-
const useSetRef = initial => {
|
|
8
|
-
const ref = React.useRef(initial);
|
|
9
|
-
const setRef = React.useCallback(node => {
|
|
10
|
-
ref.current = node;
|
|
11
|
-
}, []);
|
|
12
|
-
return [ref, setRef];
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
exports.useSetRef = useSetRef;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
|
|
5
|
-
function useShouldRecalculate(bool) {
|
|
6
|
-
const prevValueRef = React.useRef(0);
|
|
7
|
-
|
|
8
|
-
if (!bool) {
|
|
9
|
-
// If we need to recalculate, change the value we return
|
|
10
|
-
prevValueRef.current += 1;
|
|
11
|
-
} // else we return the same value as the previous render, which won't trigger a recalculation
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return prevValueRef.current;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
module.exports = useShouldRecalculate;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
|
|
5
|
-
function getScrollOffset() {
|
|
6
|
-
let element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
7
|
-
scrollTop: 0,
|
|
8
|
-
scrollLeft: 0
|
|
9
|
-
};
|
|
10
|
-
return {
|
|
11
|
-
top: element.scrollTop,
|
|
12
|
-
left: element.scrollLeft
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function getPositionOffset(listEl, scrollableEl) {
|
|
17
|
-
const scrollOffset = getScrollOffset(scrollableEl);
|
|
18
|
-
const elementRect = listEl.getBoundingClientRect();
|
|
19
|
-
const containerRect = scrollableEl.getBoundingClientRect();
|
|
20
|
-
return {
|
|
21
|
-
top: elementRect.top + scrollOffset.top - containerRect.top,
|
|
22
|
-
left: elementRect.left + scrollOffset.top - containerRect.left
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function isParent(parentNode, childNode) {
|
|
27
|
-
return childNode.parentNode === parentNode || childNode.parentNode && isParent(parentNode, childNode.parentNode);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function useWindowScrollerList(_ref) {
|
|
31
|
-
let {
|
|
32
|
-
listInstance,
|
|
33
|
-
outerListRef
|
|
34
|
-
} = _ref;
|
|
35
|
-
const scrollableParent = React.useRef();
|
|
36
|
-
const listOffset = React.useRef();
|
|
37
|
-
|
|
38
|
-
const getElementOffset = () => {
|
|
39
|
-
listOffset.current = getPositionOffset(outerListRef.current, scrollableParent.current);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const handleScroll = e => {
|
|
43
|
-
if (!scrollableParent.current) {
|
|
44
|
-
const containerTarget = e.target === document ? document.body : e.target;
|
|
45
|
-
scrollableParent.current = isParent(containerTarget, outerListRef.current) && containerTarget;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (!scrollableParent.current) return;
|
|
49
|
-
getElementOffset();
|
|
50
|
-
const scrollOffset = getScrollOffset(scrollableParent.current);
|
|
51
|
-
const scrollTop = Math.max(0, scrollOffset.top - listOffset.current.top);
|
|
52
|
-
if (listInstance.current) listInstance.current.scrollTo(scrollTop);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
React.useEffect(() => {
|
|
56
|
-
window.addEventListener('scroll', handleScroll, true);
|
|
57
|
-
window.addEventListener('resize', getElementOffset, true);
|
|
58
|
-
return () => {
|
|
59
|
-
window.removeEventListener('scroll', handleScroll, true);
|
|
60
|
-
window.removeEventListener('resize', getElementOffset, true);
|
|
61
|
-
};
|
|
62
|
-
}, []);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
module.exports = useWindowScrollerList;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
4
|
-
var React = require('react');
|
|
5
|
-
|
|
6
|
-
function useWindowSize() {
|
|
7
|
-
const [size, setSize] = React.useState([0, 0]);
|
|
8
|
-
React.useLayoutEffect(() => {
|
|
9
|
-
if (!window) return false;
|
|
10
|
-
|
|
11
|
-
function updateSize() {
|
|
12
|
-
setSize([window.innerWidth, window.innerHeight]);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
window.addEventListener('resize', updateSize);
|
|
16
|
-
window.addEventListener('orientationchange', updateSize);
|
|
17
|
-
updateSize();
|
|
18
|
-
return () => {
|
|
19
|
-
window.removeEventListener('resize', updateSize);
|
|
20
|
-
window.removeEventListener('orientationchange', updateSize);
|
|
21
|
-
};
|
|
22
|
-
}, []);
|
|
23
|
-
if (!window) return false;
|
|
24
|
-
return size;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
module.exports = useWindowSize;
|
package/cjs/index.js
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var getComponentFromProps = require('./getComponentFromProps.js');
|
|
6
|
-
var onClickHandlerForNonInteractiveElements = require('./onClickHandlerForNonInteractiveElements.js');
|
|
7
|
-
var capitalize = require('./capitalize.js');
|
|
8
|
-
var operators = require('./operators.js');
|
|
9
|
-
var utils = require('./utils.js');
|
|
10
|
-
var system = require('./system.js');
|
|
11
|
-
var useMeasure = require('use-measure');
|
|
12
|
-
var useExecutionTimer = require('./hooks/useExecutionTimer.js');
|
|
13
|
-
var useExpandState = require('./hooks/useExpandState.js');
|
|
14
|
-
var useHotkeys = require('./hooks/useHotkeys.js');
|
|
15
|
-
var useHoverHandlersDelay = require('./hooks/useHoverHandlersDelay.js');
|
|
16
|
-
var useResizeObserver = require('./hooks/useResizeObserver.js');
|
|
17
|
-
var useShouldRecalculate = require('./hooks/useShouldRecalculate.js');
|
|
18
|
-
var useWindowScrollerList = require('./hooks/useWindowScrollerList.js');
|
|
19
|
-
var useWindowSize = require('./hooks/useWindowSize.js');
|
|
20
|
-
var useForceUpdate = require('use-force-update');
|
|
21
|
-
var useOnclickoutside = require('use-onclickoutside');
|
|
22
|
-
var uncontrollable = require('uncontrollable');
|
|
23
|
-
var usePrevious = require('./hooks/usePrevious.js');
|
|
24
|
-
var useCancellableDelayedCallback = require('./hooks/useCancellableDelayedCallback.js');
|
|
25
|
-
var useDerivedStateFromProps = require('./hooks/useDerivedStateFromProps.js');
|
|
26
|
-
var useSetRef = require('./hooks/useSetRef.js');
|
|
27
|
-
var useParentElement = require('./hooks/useParentElement.js');
|
|
28
|
-
var useOnElementResize = require('./hooks/useOnElementResize.js');
|
|
29
|
-
var useIsShowingEllipsis = require('./hooks/useIsShowingEllipsis.js');
|
|
30
|
-
var useFocusTrap = require('./hooks/useFocusTrap.js');
|
|
31
|
-
var timeUtils = require('./timeUtils.js');
|
|
32
|
-
var compose = require('./compose.js');
|
|
33
|
-
var platform = require('./platform.js');
|
|
34
|
-
var reactTypesUtility = require('./reactTypesUtility.js');
|
|
35
|
-
var scrollingTimer = require('./scrollingTimer.js');
|
|
36
|
-
var validations = require('./validations.js');
|
|
37
|
-
var lodash = require('lodash');
|
|
38
|
-
|
|
39
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
40
|
-
|
|
41
|
-
var useMeasure__default = /*#__PURE__*/_interopDefaultLegacy(useMeasure);
|
|
42
|
-
var useForceUpdate__default = /*#__PURE__*/_interopDefaultLegacy(useForceUpdate);
|
|
43
|
-
var useOnclickoutside__default = /*#__PURE__*/_interopDefaultLegacy(useOnclickoutside);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
exports.getComponentFromProps = getComponentFromProps;
|
|
48
|
-
exports.onClickHandlerForNonInteractiveElements = onClickHandlerForNonInteractiveElements;
|
|
49
|
-
exports.capitalize = capitalize.capitalize;
|
|
50
|
-
exports.checkEmpty = operators.checkEmpty;
|
|
51
|
-
exports.checkNotEmpty = operators.checkNotEmpty;
|
|
52
|
-
exports.contains = operators.contains;
|
|
53
|
-
exports.equal = operators.equal;
|
|
54
|
-
exports.greaterThan = operators.greaterThan;
|
|
55
|
-
exports.greaterThanOrEquals = operators.greaterThanOrEquals;
|
|
56
|
-
exports.isIn = operators.isIn;
|
|
57
|
-
exports.isNotIn = operators.isNotIn;
|
|
58
|
-
exports.isNotNull = operators.isNotNull;
|
|
59
|
-
exports.isNull = operators.isNull;
|
|
60
|
-
exports.lessThanOrEquals = operators.lessThanOrEquals;
|
|
61
|
-
exports.notEqual = operators.notEqual;
|
|
62
|
-
exports.startsWith = operators.startsWith;
|
|
63
|
-
exports.validDate = operators.validDate;
|
|
64
|
-
exports.addOrRemove = utils.addOrRemove;
|
|
65
|
-
exports.arrayMove = utils.arrayMove;
|
|
66
|
-
exports.cx = utils.cx;
|
|
67
|
-
exports.hashArray = utils.hashArray;
|
|
68
|
-
exports.removeUndefinedProperties = utils.removeUndefinedProperties;
|
|
69
|
-
exports.runAll = utils.runAll;
|
|
70
|
-
exports.safeCall = utils.safeCall;
|
|
71
|
-
exports.toggleInArray = utils.toggleInArray;
|
|
72
|
-
exports.toggleInObject = utils.toggleInObject;
|
|
73
|
-
exports.logger = system.logger;
|
|
74
|
-
exports.mergeRefs = system.mergeRefs;
|
|
75
|
-
exports.setRef = system.setRef;
|
|
76
|
-
Object.defineProperty(exports, 'useMeasure', {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
get: function () { return useMeasure__default["default"]; }
|
|
79
|
-
});
|
|
80
|
-
exports.useExecutionTimer = useExecutionTimer;
|
|
81
|
-
exports.useExpandState = useExpandState;
|
|
82
|
-
exports.useHotkeys = useHotkeys;
|
|
83
|
-
exports.useHoverHandlersDelay = useHoverHandlersDelay;
|
|
84
|
-
exports.useResizeObserver = useResizeObserver;
|
|
85
|
-
exports.useShouldRecalculate = useShouldRecalculate;
|
|
86
|
-
exports.useWindowScrollerList = useWindowScrollerList;
|
|
87
|
-
exports.useWindowSize = useWindowSize;
|
|
88
|
-
Object.defineProperty(exports, 'useForceUpdate', {
|
|
89
|
-
enumerable: true,
|
|
90
|
-
get: function () { return useForceUpdate__default["default"]; }
|
|
91
|
-
});
|
|
92
|
-
Object.defineProperty(exports, 'useOnClickOutside', {
|
|
93
|
-
enumerable: true,
|
|
94
|
-
get: function () { return useOnclickoutside__default["default"]; }
|
|
95
|
-
});
|
|
96
|
-
Object.defineProperty(exports, 'useUncontrolled', {
|
|
97
|
-
enumerable: true,
|
|
98
|
-
get: function () { return uncontrollable.useUncontrolled; }
|
|
99
|
-
});
|
|
100
|
-
exports.usePrevious = usePrevious;
|
|
101
|
-
exports.useCancellableDelayedCallback = useCancellableDelayedCallback;
|
|
102
|
-
exports.useDerivedStateFromProps = useDerivedStateFromProps;
|
|
103
|
-
exports.useSetRef = useSetRef.useSetRef;
|
|
104
|
-
exports.useParentElement = useParentElement.useParentElement;
|
|
105
|
-
exports.useOnElementResize = useOnElementResize.useOnElementResize;
|
|
106
|
-
exports.useIsShowingEllipsis = useIsShowingEllipsis.useIsShowingEllipsis;
|
|
107
|
-
exports.useFocusTrap = useFocusTrap.useFocusTrap;
|
|
108
|
-
exports.addLeadingZeros = timeUtils.addLeadingZeros;
|
|
109
|
-
exports.getVisibleTimeByFormat = timeUtils.getVisibleTimeByFormat;
|
|
110
|
-
exports.compose = compose.compose;
|
|
111
|
-
exports.DOCUMENT = platform.DOCUMENT;
|
|
112
|
-
exports.WINDOW = platform.WINDOW;
|
|
113
|
-
exports.isClassComponent = reactTypesUtility.isClassComponent;
|
|
114
|
-
exports.isCompositeTypeElement = reactTypesUtility.isCompositeTypeElement;
|
|
115
|
-
exports.isDOMTypeElement = reactTypesUtility.isDOMTypeElement;
|
|
116
|
-
exports.isElement = reactTypesUtility.isElement;
|
|
117
|
-
exports.isFunctionComponent = reactTypesUtility.isFunctionComponent;
|
|
118
|
-
exports.isReactComponent = reactTypesUtility.isReactComponent;
|
|
119
|
-
exports.resetTimer = scrollingTimer.resetTimer;
|
|
120
|
-
exports.isGreaterThan = validations.isGreaterThan;
|
|
121
|
-
exports.isRequired = validations.isRequired;
|
|
122
|
-
exports.isValidDate = validations.isValidDate;
|
|
123
|
-
Object.defineProperty(exports, 'cloneDeep', {
|
|
124
|
-
enumerable: true,
|
|
125
|
-
get: function () { return lodash.cloneDeep; }
|
|
126
|
-
});
|
|
127
|
-
Object.defineProperty(exports, 'curry', {
|
|
128
|
-
enumerable: true,
|
|
129
|
-
get: function () { return lodash.curry; }
|
|
130
|
-
});
|
|
131
|
-
Object.defineProperty(exports, 'debounce', {
|
|
132
|
-
enumerable: true,
|
|
133
|
-
get: function () { return lodash.debounce; }
|
|
134
|
-
});
|
|
135
|
-
Object.defineProperty(exports, 'differenceBy', {
|
|
136
|
-
enumerable: true,
|
|
137
|
-
get: function () { return lodash.differenceBy; }
|
|
138
|
-
});
|
|
139
|
-
Object.defineProperty(exports, 'differenceWith', {
|
|
140
|
-
enumerable: true,
|
|
141
|
-
get: function () { return lodash.differenceWith; }
|
|
142
|
-
});
|
|
143
|
-
Object.defineProperty(exports, 'filter', {
|
|
144
|
-
enumerable: true,
|
|
145
|
-
get: function () { return lodash.filter; }
|
|
146
|
-
});
|
|
147
|
-
Object.defineProperty(exports, 'findIndex', {
|
|
148
|
-
enumerable: true,
|
|
149
|
-
get: function () { return lodash.findIndex; }
|
|
150
|
-
});
|
|
151
|
-
Object.defineProperty(exports, 'get', {
|
|
152
|
-
enumerable: true,
|
|
153
|
-
get: function () { return lodash.get; }
|
|
154
|
-
});
|
|
155
|
-
Object.defineProperty(exports, 'groupBy', {
|
|
156
|
-
enumerable: true,
|
|
157
|
-
get: function () { return lodash.groupBy; }
|
|
158
|
-
});
|
|
159
|
-
Object.defineProperty(exports, 'isBoolean', {
|
|
160
|
-
enumerable: true,
|
|
161
|
-
get: function () { return lodash.isBoolean; }
|
|
162
|
-
});
|
|
163
|
-
Object.defineProperty(exports, 'isEmpty', {
|
|
164
|
-
enumerable: true,
|
|
165
|
-
get: function () { return lodash.isEmpty; }
|
|
166
|
-
});
|
|
167
|
-
Object.defineProperty(exports, 'isEqual', {
|
|
168
|
-
enumerable: true,
|
|
169
|
-
get: function () { return lodash.isEqual; }
|
|
170
|
-
});
|
|
171
|
-
Object.defineProperty(exports, 'isEqualWith', {
|
|
172
|
-
enumerable: true,
|
|
173
|
-
get: function () { return lodash.isEqualWith; }
|
|
174
|
-
});
|
|
175
|
-
Object.defineProperty(exports, 'isFunction', {
|
|
176
|
-
enumerable: true,
|
|
177
|
-
get: function () { return lodash.isFunction; }
|
|
178
|
-
});
|
|
179
|
-
Object.defineProperty(exports, 'isNaN', {
|
|
180
|
-
enumerable: true,
|
|
181
|
-
get: function () { return lodash.isNaN; }
|
|
182
|
-
});
|
|
183
|
-
Object.defineProperty(exports, 'isObject', {
|
|
184
|
-
enumerable: true,
|
|
185
|
-
get: function () { return lodash.isObject; }
|
|
186
|
-
});
|
|
187
|
-
Object.defineProperty(exports, 'isString', {
|
|
188
|
-
enumerable: true,
|
|
189
|
-
get: function () { return lodash.isString; }
|
|
190
|
-
});
|
|
191
|
-
Object.defineProperty(exports, 'maxBy', {
|
|
192
|
-
enumerable: true,
|
|
193
|
-
get: function () { return lodash.maxBy; }
|
|
194
|
-
});
|
|
195
|
-
Object.defineProperty(exports, 'meanBy', {
|
|
196
|
-
enumerable: true,
|
|
197
|
-
get: function () { return lodash.meanBy; }
|
|
198
|
-
});
|
|
199
|
-
Object.defineProperty(exports, 'noop', {
|
|
200
|
-
enumerable: true,
|
|
201
|
-
get: function () { return lodash.noop; }
|
|
202
|
-
});
|
|
203
|
-
Object.defineProperty(exports, 'omit', {
|
|
204
|
-
enumerable: true,
|
|
205
|
-
get: function () { return lodash.omit; }
|
|
206
|
-
});
|
|
207
|
-
Object.defineProperty(exports, 'orderBy', {
|
|
208
|
-
enumerable: true,
|
|
209
|
-
get: function () { return lodash.orderBy; }
|
|
210
|
-
});
|
|
211
|
-
Object.defineProperty(exports, 'padStart', {
|
|
212
|
-
enumerable: true,
|
|
213
|
-
get: function () { return lodash.padStart; }
|
|
214
|
-
});
|
|
215
|
-
Object.defineProperty(exports, 'parseInt', {
|
|
216
|
-
enumerable: true,
|
|
217
|
-
get: function () { return lodash.parseInt; }
|
|
218
|
-
});
|
|
219
|
-
Object.defineProperty(exports, 'pick', {
|
|
220
|
-
enumerable: true,
|
|
221
|
-
get: function () { return lodash.pick; }
|
|
222
|
-
});
|
|
223
|
-
Object.defineProperty(exports, 'pickBy', {
|
|
224
|
-
enumerable: true,
|
|
225
|
-
get: function () { return lodash.pickBy; }
|
|
226
|
-
});
|
|
227
|
-
Object.defineProperty(exports, 'property', {
|
|
228
|
-
enumerable: true,
|
|
229
|
-
get: function () { return lodash.property; }
|
|
230
|
-
});
|
|
231
|
-
Object.defineProperty(exports, 'pull', {
|
|
232
|
-
enumerable: true,
|
|
233
|
-
get: function () { return lodash.pull; }
|
|
234
|
-
});
|
|
235
|
-
Object.defineProperty(exports, 'range', {
|
|
236
|
-
enumerable: true,
|
|
237
|
-
get: function () { return lodash.range; }
|
|
238
|
-
});
|
|
239
|
-
Object.defineProperty(exports, 'set', {
|
|
240
|
-
enumerable: true,
|
|
241
|
-
get: function () { return lodash.set; }
|
|
242
|
-
});
|
|
243
|
-
Object.defineProperty(exports, 'sortBy', {
|
|
244
|
-
enumerable: true,
|
|
245
|
-
get: function () { return lodash.sortBy; }
|
|
246
|
-
});
|
|
247
|
-
Object.defineProperty(exports, 'sumBy', {
|
|
248
|
-
enumerable: true,
|
|
249
|
-
get: function () { return lodash.sumBy; }
|
|
250
|
-
});
|
|
251
|
-
Object.defineProperty(exports, 'throttle', {
|
|
252
|
-
enumerable: true,
|
|
253
|
-
get: function () { return lodash.throttle; }
|
|
254
|
-
});
|
|
255
|
-
Object.defineProperty(exports, 'transform', {
|
|
256
|
-
enumerable: true,
|
|
257
|
-
get: function () { return lodash.transform; }
|
|
258
|
-
});
|
|
259
|
-
Object.defineProperty(exports, 'uniq', {
|
|
260
|
-
enumerable: true,
|
|
261
|
-
get: function () { return lodash.uniq; }
|
|
262
|
-
});
|
|
263
|
-
Object.defineProperty(exports, 'uniqBy', {
|
|
264
|
-
enumerable: true,
|
|
265
|
-
get: function () { return lodash.uniqBy; }
|
|
266
|
-
});
|
|
267
|
-
Object.defineProperty(exports, 'values', {
|
|
268
|
-
enumerable: true,
|
|
269
|
-
get: function () { return lodash.values; }
|
|
270
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* onClickHandler: callback
|
|
5
|
-
*
|
|
6
|
-
* @param onClickHandler
|
|
7
|
-
*/
|
|
8
|
-
var onClickHandlerForNonInteractiveElements = (onClickHandler => ({
|
|
9
|
-
role: 'button',
|
|
10
|
-
tabIndex: '0',
|
|
11
|
-
onClick: onClickHandler,
|
|
12
|
-
onKeyPress: event => {
|
|
13
|
-
event.stopPropagation();
|
|
14
|
-
const {
|
|
15
|
-
keycode,
|
|
16
|
-
key
|
|
17
|
-
} = event;
|
|
18
|
-
if (key === 'Enter') onClickHandler(event);else if (keycode === 13) onClickHandler(event);
|
|
19
|
-
}
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
module.exports = onClickHandlerForNonInteractiveElements;
|
package/cjs/operators.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
-
require('core-js/modules/esnext.async-iterator.map.js');
|
|
7
|
-
require('core-js/modules/esnext.iterator.map.js');
|
|
8
|
-
var lodash = require('lodash');
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Check if the value is null undefined ''
|
|
12
|
-
*
|
|
13
|
-
* @param value
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
const checkNotEmpty = value => value === '' || value === undefined || value == [] || value === null || lodash.isEmpty(value);
|
|
17
|
-
const checkEmpty = value => !lodash.isEmpty(value);
|
|
18
|
-
/**
|
|
19
|
-
* @param value: number
|
|
20
|
-
* @param comparator: number
|
|
21
|
-
* @param value
|
|
22
|
-
* @param comparator
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
const greaterThan = (value, comparator) => value > comparator;
|
|
26
|
-
/**
|
|
27
|
-
* Check if a valid date with format MM/DD/YYYY
|
|
28
|
-
*
|
|
29
|
-
* @param {*} value: string
|
|
30
|
-
* @param value
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
const validDate = value => {
|
|
34
|
-
const dateValidationRegex = /^\d{1,2}\/\d{1,2}\/\d{4}$/;
|
|
35
|
-
if (!dateValidationRegex.test(value)) return false;
|
|
36
|
-
const [m, d, y] = value.split('/').map(n => Number(n));
|
|
37
|
-
return m === Number(new Date(y, m - 1, d).getMonth()) + 1 && d === Number(new Date(y, m - 1, d).getDate());
|
|
38
|
-
};
|
|
39
|
-
const equal = (a, b) => a === b;
|
|
40
|
-
const notEqual = (a, b) => !equal(a, b);
|
|
41
|
-
const isNull = a => checkNotEmpty(a);
|
|
42
|
-
const isNotNull = a => !isNull(a);
|
|
43
|
-
const isIn = (a, b) => b.indexOf(a) > -1;
|
|
44
|
-
const isNotIn = (a, b) => !isIn(a, b);
|
|
45
|
-
const greaterThanOrEquals = (value, comparator) => value >= comparator;
|
|
46
|
-
const lessThanOrEquals = (value, comparator) => value <= comparator;
|
|
47
|
-
const startsWith = (value, comparator) => String(value).startsWith(comparator);
|
|
48
|
-
const contains = (value, comparator) => String(value).includes(comparator);
|
|
49
|
-
|
|
50
|
-
exports.checkEmpty = checkEmpty;
|
|
51
|
-
exports.checkNotEmpty = checkNotEmpty;
|
|
52
|
-
exports.contains = contains;
|
|
53
|
-
exports.equal = equal;
|
|
54
|
-
exports.greaterThan = greaterThan;
|
|
55
|
-
exports.greaterThanOrEquals = greaterThanOrEquals;
|
|
56
|
-
exports.isIn = isIn;
|
|
57
|
-
exports.isNotIn = isNotIn;
|
|
58
|
-
exports.isNotNull = isNotNull;
|
|
59
|
-
exports.isNull = isNull;
|
|
60
|
-
exports.lessThanOrEquals = lessThanOrEquals;
|
|
61
|
-
exports.notEqual = notEqual;
|
|
62
|
-
exports.startsWith = startsWith;
|
|
63
|
-
exports.validDate = validDate;
|