@elliemae/ds-utilities 2.2.0-alpha.3 → 3.0.0-next.0
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 -35
- package/cjs/compose.js +32 -39
- package/cjs/getComponentFromProps.js +29 -47
- package/cjs/hooks/index.js +60 -68
- package/cjs/hooks/useCancellableDelayedCallback.js +18 -43
- package/cjs/hooks/useDerivedStateFromProps.js +36 -47
- package/cjs/hooks/useExecutionTimer.js +24 -43
- package/cjs/hooks/useExpandState.js +82 -69
- package/cjs/hooks/useHotkeys.js +24 -44
- package/cjs/hooks/useHoverHandlersDelay.js +18 -48
- package/cjs/hooks/useOnElementResize.js +27 -44
- package/cjs/hooks/useParentElement.js +13 -40
- package/cjs/hooks/usePrevious.js +10 -41
- package/cjs/hooks/useResizeObserver.js +25 -52
- package/cjs/hooks/useSetRef.js +11 -38
- package/cjs/hooks/useShouldRecalculate.js +14 -41
- package/cjs/hooks/useWindowScrollerList.js +33 -51
- package/cjs/hooks/useWindowSize.js +19 -49
- package/cjs/index.js +266 -145
- package/cjs/onClickHandlerForNonInteractiveElements.js +19 -46
- package/cjs/operators.js +51 -56
- package/cjs/platform.js +9 -37
- package/cjs/reactTypesUtility.js +22 -45
- package/cjs/scrollingTimer.js +15 -37
- package/cjs/system.js +30 -47
- package/cjs/timeUtils.js +24 -42
- package/cjs/utils.js +237 -101
- package/cjs/validations.js +35 -48
- package/esm/capitalize.js +3 -6
- package/esm/compose.js +29 -11
- package/esm/getComponentFromProps.js +22 -18
- package/esm/hooks/index.js +18 -40
- package/esm/hooks/useCancellableDelayedCallback.js +14 -12
- package/esm/hooks/useDerivedStateFromProps.js +31 -15
- package/esm/hooks/useExecutionTimer.js +20 -12
- package/esm/hooks/useExpandState.js +72 -36
- package/esm/hooks/useHotkeys.js +14 -11
- package/esm/hooks/useHoverHandlersDelay.js +12 -15
- package/esm/hooks/useOnElementResize.js +20 -12
- package/esm/hooks/useParentElement.js +7 -9
- package/esm/hooks/usePrevious.js +6 -10
- package/esm/hooks/useResizeObserver.js +15 -20
- package/esm/hooks/useSetRef.js +6 -8
- package/esm/hooks/useShouldRecalculate.js +11 -11
- package/esm/hooks/useWindowScrollerList.js +29 -20
- package/esm/hooks/useWindowSize.js +15 -18
- package/esm/index.js +31 -204
- package/esm/onClickHandlerForNonInteractiveElements.js +17 -17
- package/esm/operators.js +34 -27
- package/esm/platform.js +4 -8
- package/esm/reactTypesUtility.js +9 -16
- package/esm/scrollingTimer.js +11 -8
- package/esm/system.js +22 -16
- package/esm/timeUtils.js +19 -13
- package/esm/utils.js +72 -109
- package/esm/validations.js +28 -18
- package/package.json +1 -1
- package/types/compose.d.ts +1 -2
- package/types/getComponentFromProps.d.ts +1 -2
- package/types/hooks/index.d.ts +14 -14
- package/types/hooks/useCancellableDelayedCallback.d.ts +1 -2
- package/types/hooks/useDerivedStateFromProps.d.ts +1 -2
- package/types/hooks/useExecutionTimer.d.ts +1 -2
- package/types/hooks/useExpandState.d.ts +2 -3
- package/types/hooks/useHotkeys.d.ts +2 -3
- package/types/hooks/useHoverHandlersDelay.d.ts +2 -3
- package/types/hooks/usePrevious.d.ts +1 -1
- package/types/hooks/useResizeObserver.d.ts +1 -2
- package/types/hooks/useShouldRecalculate.d.ts +1 -2
- package/types/hooks/useWindowScrollerList.d.ts +2 -3
- package/types/hooks/useWindowSize.d.ts +1 -2
- package/types/index.d.ts +11 -11
- package/types/onClickHandlerForNonInteractiveElements.d.ts +7 -7
- package/types/scrollingTimer.d.ts +1 -1
- package/cjs/capitalize.js.map +0 -7
- package/cjs/compose.js.map +0 -7
- package/cjs/getComponentFromProps.js.map +0 -7
- package/cjs/hooks/index.js.map +0 -7
- package/cjs/hooks/useCancellableDelayedCallback.js.map +0 -7
- package/cjs/hooks/useDerivedStateFromProps.js.map +0 -7
- package/cjs/hooks/useExecutionTimer.js.map +0 -7
- package/cjs/hooks/useExpandState.js.map +0 -7
- package/cjs/hooks/useHotkeys.js.map +0 -7
- package/cjs/hooks/useHoverHandlersDelay.js.map +0 -7
- package/cjs/hooks/useOnElementResize.js.map +0 -7
- package/cjs/hooks/useParentElement.js.map +0 -7
- package/cjs/hooks/usePrevious.js.map +0 -7
- package/cjs/hooks/useResizeObserver.js.map +0 -7
- package/cjs/hooks/useSetRef.js.map +0 -7
- package/cjs/hooks/useShouldRecalculate.js.map +0 -7
- package/cjs/hooks/useWindowScrollerList.js.map +0 -7
- package/cjs/hooks/useWindowSize.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/onClickHandlerForNonInteractiveElements.js.map +0 -7
- package/cjs/operators.js.map +0 -7
- package/cjs/platform.js.map +0 -7
- package/cjs/reactTypesUtility.js.map +0 -7
- package/cjs/scrollingTimer.js.map +0 -7
- package/cjs/system.js.map +0 -7
- package/cjs/timeUtils.js.map +0 -7
- package/cjs/utils.js.map +0 -7
- package/cjs/validations.js.map +0 -7
- package/esm/capitalize.js.map +0 -7
- package/esm/compose.js.map +0 -7
- package/esm/getComponentFromProps.js.map +0 -7
- package/esm/hooks/index.js.map +0 -7
- package/esm/hooks/useCancellableDelayedCallback.js.map +0 -7
- package/esm/hooks/useDerivedStateFromProps.js.map +0 -7
- package/esm/hooks/useExecutionTimer.js.map +0 -7
- package/esm/hooks/useExpandState.js.map +0 -7
- package/esm/hooks/useHotkeys.js.map +0 -7
- package/esm/hooks/useHoverHandlersDelay.js.map +0 -7
- package/esm/hooks/useOnElementResize.js.map +0 -7
- package/esm/hooks/useParentElement.js.map +0 -7
- package/esm/hooks/usePrevious.js.map +0 -7
- package/esm/hooks/useResizeObserver.js.map +0 -7
- package/esm/hooks/useSetRef.js.map +0 -7
- package/esm/hooks/useShouldRecalculate.js.map +0 -7
- package/esm/hooks/useWindowScrollerList.js.map +0 -7
- package/esm/hooks/useWindowSize.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/onClickHandlerForNonInteractiveElements.js.map +0 -7
- package/esm/operators.js.map +0 -7
- package/esm/platform.js.map +0 -7
- package/esm/reactTypesUtility.js.map +0 -7
- package/esm/scrollingTimer.js.map +0 -7
- package/esm/system.js.map +0 -7
- package/esm/timeUtils.js.map +0 -7
- package/esm/utils.js.map +0 -7
- package/esm/validations.js.map +0 -7
package/cjs/hooks/useSetRef.js
CHANGED
|
@@ -1,42 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var useSetRef_exports = {};
|
|
29
|
-
__export(useSetRef_exports, {
|
|
30
|
-
useSetRef: () => useSetRef
|
|
31
|
-
});
|
|
32
|
-
var React = __toESM(require("react"));
|
|
33
|
-
var import_react = __toESM(require("react"));
|
|
34
|
-
const useSetRef = (initial) => {
|
|
35
|
-
const ref = (0, import_react.useRef)(initial);
|
|
36
|
-
const setRef = (0, import_react.useCallback)((node) => {
|
|
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 => {
|
|
37
10
|
ref.current = node;
|
|
38
11
|
}, []);
|
|
39
12
|
return [ref, setRef];
|
|
40
13
|
};
|
|
41
|
-
|
|
42
|
-
|
|
14
|
+
|
|
15
|
+
exports.useSetRef = useSetRef;
|
|
@@ -1,44 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var useShouldRecalculate_exports = {};
|
|
29
|
-
__export(useShouldRecalculate_exports, {
|
|
30
|
-
default: () => useShouldRecalculate_default,
|
|
31
|
-
useShouldRecalculate: () => useShouldRecalculate
|
|
32
|
-
});
|
|
33
|
-
var React = __toESM(require("react"));
|
|
34
|
-
var import_react = __toESM(require("react"));
|
|
35
|
-
const useShouldRecalculate = (bool) => {
|
|
36
|
-
const prevValueRef = (0, import_react.useRef)(0);
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
function useShouldRecalculate(bool) {
|
|
6
|
+
const prevValueRef = React.useRef(0);
|
|
7
|
+
|
|
37
8
|
if (!bool) {
|
|
9
|
+
// If we need to recalculate, change the value we return
|
|
38
10
|
prevValueRef.current += 1;
|
|
39
|
-
}
|
|
11
|
+
} // else we return the same value as the previous render, which won't trigger a recalculation
|
|
12
|
+
|
|
13
|
+
|
|
40
14
|
return prevValueRef.current;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
module.exports =
|
|
44
|
-
//# sourceMappingURL=useShouldRecalculate.js.map
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = useShouldRecalculate;
|
|
@@ -1,43 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
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
|
|
26
9
|
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var useWindowScrollerList_exports = {};
|
|
29
|
-
__export(useWindowScrollerList_exports, {
|
|
30
|
-
default: () => useWindowScrollerList_default,
|
|
31
|
-
useWindowScrollerList: () => useWindowScrollerList
|
|
32
|
-
});
|
|
33
|
-
var React = __toESM(require("react"));
|
|
34
|
-
var import_react = __toESM(require("react"));
|
|
35
|
-
function getScrollOffset(element = { scrollTop: 0, scrollLeft: 0 }) {
|
|
36
10
|
return {
|
|
37
11
|
top: element.scrollTop,
|
|
38
12
|
left: element.scrollLeft
|
|
39
13
|
};
|
|
40
14
|
}
|
|
15
|
+
|
|
41
16
|
function getPositionOffset(listEl, scrollableEl) {
|
|
42
17
|
const scrollOffset = getScrollOffset(scrollableEl);
|
|
43
18
|
const elementRect = listEl.getBoundingClientRect();
|
|
@@ -47,37 +22,44 @@ function getPositionOffset(listEl, scrollableEl) {
|
|
|
47
22
|
left: elementRect.left + scrollOffset.top - containerRect.left
|
|
48
23
|
};
|
|
49
24
|
}
|
|
25
|
+
|
|
50
26
|
function isParent(parentNode, childNode) {
|
|
51
27
|
return childNode.parentNode === parentNode || childNode.parentNode && isParent(parentNode, childNode.parentNode);
|
|
52
28
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
29
|
+
|
|
30
|
+
function useWindowScrollerList(_ref) {
|
|
31
|
+
let {
|
|
32
|
+
listInstance,
|
|
33
|
+
outerListRef
|
|
34
|
+
} = _ref;
|
|
35
|
+
const scrollableParent = React.useRef();
|
|
36
|
+
const listOffset = React.useRef();
|
|
37
|
+
|
|
56
38
|
const getElementOffset = () => {
|
|
57
39
|
listOffset.current = getPositionOffset(outerListRef.current, scrollableParent.current);
|
|
58
40
|
};
|
|
59
|
-
|
|
41
|
+
|
|
42
|
+
const handleScroll = e => {
|
|
60
43
|
if (!scrollableParent.current) {
|
|
61
44
|
const containerTarget = e.target === document ? document.body : e.target;
|
|
62
45
|
scrollableParent.current = isParent(containerTarget, outerListRef.current) && containerTarget;
|
|
63
46
|
}
|
|
64
|
-
|
|
65
|
-
|
|
47
|
+
|
|
48
|
+
if (!scrollableParent.current) return;
|
|
66
49
|
getElementOffset();
|
|
67
50
|
const scrollOffset = getScrollOffset(scrollableParent.current);
|
|
68
51
|
const scrollTop = Math.max(0, scrollOffset.top - listOffset.current.top);
|
|
69
|
-
if (listInstance.current)
|
|
70
|
-
listInstance.current.scrollTo(scrollTop);
|
|
52
|
+
if (listInstance.current) listInstance.current.scrollTo(scrollTop);
|
|
71
53
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
window.addEventListener(
|
|
54
|
+
|
|
55
|
+
React.useEffect(() => {
|
|
56
|
+
window.addEventListener('scroll', handleScroll, true);
|
|
57
|
+
window.addEventListener('resize', getElementOffset, true);
|
|
75
58
|
return () => {
|
|
76
|
-
window.removeEventListener(
|
|
77
|
-
window.removeEventListener(
|
|
59
|
+
window.removeEventListener('scroll', handleScroll, true);
|
|
60
|
+
window.removeEventListener('resize', getElementOffset, true);
|
|
78
61
|
};
|
|
79
62
|
}, []);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
module.exports =
|
|
83
|
-
//# sourceMappingURL=useWindowScrollerList.js.map
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
module.exports = useWindowScrollerList;
|
|
@@ -1,57 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var useWindowSize_exports = {};
|
|
29
|
-
__export(useWindowSize_exports, {
|
|
30
|
-
default: () => useWindowSize_default,
|
|
31
|
-
useWindowSize: () => useWindowSize
|
|
32
|
-
});
|
|
33
|
-
var React = __toESM(require("react"));
|
|
34
|
-
var import_react = __toESM(require("react"));
|
|
35
|
-
const useWindowSize = () => {
|
|
36
|
-
const [size, setSize] = (0, import_react.useState)([0, 0]);
|
|
37
|
-
(0, import_react.useLayoutEffect)(() => {
|
|
38
|
-
if (!window)
|
|
39
|
-
return false;
|
|
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
|
+
|
|
40
11
|
function updateSize() {
|
|
41
12
|
setSize([window.innerWidth, window.innerHeight]);
|
|
42
13
|
}
|
|
43
|
-
|
|
44
|
-
window.addEventListener(
|
|
14
|
+
|
|
15
|
+
window.addEventListener('resize', updateSize);
|
|
16
|
+
window.addEventListener('orientationchange', updateSize);
|
|
45
17
|
updateSize();
|
|
46
18
|
return () => {
|
|
47
|
-
window.removeEventListener(
|
|
48
|
-
window.removeEventListener(
|
|
19
|
+
window.removeEventListener('resize', updateSize);
|
|
20
|
+
window.removeEventListener('orientationchange', updateSize);
|
|
49
21
|
};
|
|
50
22
|
}, []);
|
|
51
|
-
if (!window)
|
|
52
|
-
return false;
|
|
23
|
+
if (!window) return false;
|
|
53
24
|
return size;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
module.exports =
|
|
57
|
-
//# sourceMappingURL=useWindowSize.js.map
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = useWindowSize;
|