@elliemae/ds-utilities 2.2.0 → 2.3.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/cjs/capitalize.js +35 -7
- package/cjs/capitalize.js.map +7 -0
- package/cjs/compose.js +39 -32
- package/cjs/compose.js.map +7 -0
- package/cjs/getComponentFromProps.js +47 -29
- package/cjs/getComponentFromProps.js.map +7 -0
- package/cjs/hooks/index.js +70 -60
- package/cjs/hooks/index.js.map +7 -0
- package/cjs/hooks/useCancellableDelayedCallback.js +43 -18
- package/cjs/hooks/useCancellableDelayedCallback.js.map +7 -0
- package/cjs/hooks/useDerivedStateFromProps.js +47 -36
- package/cjs/hooks/useDerivedStateFromProps.js.map +7 -0
- package/cjs/hooks/useExecutionTimer.js +43 -24
- package/cjs/hooks/useExecutionTimer.js.map +7 -0
- package/cjs/hooks/useExpandState.js +69 -82
- package/cjs/hooks/useExpandState.js.map +7 -0
- package/cjs/hooks/useHotkeys.js +44 -24
- package/cjs/hooks/useHotkeys.js.map +7 -0
- package/cjs/hooks/useHoverHandlersDelay.js +48 -18
- package/cjs/hooks/useHoverHandlersDelay.js.map +7 -0
- package/cjs/hooks/useIsShowingEllipsis.js +58 -0
- package/cjs/hooks/useIsShowingEllipsis.js.map +7 -0
- package/cjs/hooks/useOnElementResize.js +44 -27
- package/cjs/hooks/useOnElementResize.js.map +7 -0
- package/cjs/hooks/useParentElement.js +40 -13
- package/cjs/hooks/useParentElement.js.map +7 -0
- package/cjs/hooks/usePrevious.js +41 -10
- package/cjs/hooks/usePrevious.js.map +7 -0
- package/cjs/hooks/useResizeObserver.js +52 -25
- package/cjs/hooks/useResizeObserver.js.map +7 -0
- package/cjs/hooks/useSetRef.js +38 -11
- package/cjs/hooks/useSetRef.js.map +7 -0
- package/cjs/hooks/useShouldRecalculate.js +41 -14
- package/cjs/hooks/useShouldRecalculate.js.map +7 -0
- package/cjs/hooks/useWindowScrollerList.js +51 -33
- package/cjs/hooks/useWindowScrollerList.js.map +7 -0
- package/cjs/hooks/useWindowSize.js +49 -19
- package/cjs/hooks/useWindowSize.js.map +7 -0
- package/cjs/index.js +146 -266
- package/cjs/index.js.map +7 -0
- package/cjs/onClickHandlerForNonInteractiveElements.js +46 -19
- package/cjs/onClickHandlerForNonInteractiveElements.js.map +7 -0
- package/cjs/operators.js +56 -51
- package/cjs/operators.js.map +7 -0
- package/cjs/platform.js +37 -9
- package/cjs/platform.js.map +7 -0
- package/cjs/reactTypesUtility.js +45 -22
- package/cjs/reactTypesUtility.js.map +7 -0
- package/cjs/scrollingTimer.js +37 -15
- package/cjs/scrollingTimer.js.map +7 -0
- package/cjs/system.js +47 -30
- package/cjs/system.js.map +7 -0
- package/cjs/timeUtils.js +42 -24
- package/cjs/timeUtils.js.map +7 -0
- package/cjs/utils.js +101 -237
- package/cjs/utils.js.map +7 -0
- package/cjs/validations.js +48 -35
- package/cjs/validations.js.map +7 -0
- package/esm/capitalize.js +6 -3
- package/esm/capitalize.js.map +7 -0
- package/esm/compose.js +11 -29
- package/esm/compose.js.map +7 -0
- package/esm/getComponentFromProps.js +18 -22
- package/esm/getComponentFromProps.js.map +7 -0
- package/esm/hooks/index.js +42 -18
- package/esm/hooks/index.js.map +7 -0
- package/esm/hooks/useCancellableDelayedCallback.js +12 -14
- package/esm/hooks/useCancellableDelayedCallback.js.map +7 -0
- package/esm/hooks/useDerivedStateFromProps.js +15 -31
- package/esm/hooks/useDerivedStateFromProps.js.map +7 -0
- package/esm/hooks/useExecutionTimer.js +12 -20
- package/esm/hooks/useExecutionTimer.js.map +7 -0
- package/esm/hooks/useExpandState.js +36 -72
- package/esm/hooks/useExpandState.js.map +7 -0
- package/esm/hooks/useHotkeys.js +11 -14
- package/esm/hooks/useHotkeys.js.map +7 -0
- package/esm/hooks/useHoverHandlersDelay.js +15 -12
- package/esm/hooks/useHoverHandlersDelay.js.map +7 -0
- package/esm/hooks/useIsShowingEllipsis.js +29 -0
- package/esm/hooks/useIsShowingEllipsis.js.map +7 -0
- package/esm/hooks/useOnElementResize.js +12 -20
- package/esm/hooks/useOnElementResize.js.map +7 -0
- package/esm/hooks/useParentElement.js +9 -7
- package/esm/hooks/useParentElement.js.map +7 -0
- package/esm/hooks/usePrevious.js +10 -6
- package/esm/hooks/usePrevious.js.map +7 -0
- package/esm/hooks/useResizeObserver.js +20 -15
- package/esm/hooks/useResizeObserver.js.map +7 -0
- package/esm/hooks/useSetRef.js +8 -6
- package/esm/hooks/useSetRef.js.map +7 -0
- package/esm/hooks/useShouldRecalculate.js +11 -11
- package/esm/hooks/useShouldRecalculate.js.map +7 -0
- package/esm/hooks/useWindowScrollerList.js +20 -29
- package/esm/hooks/useWindowScrollerList.js.map +7 -0
- package/esm/hooks/useWindowSize.js +18 -15
- package/esm/hooks/useWindowSize.js.map +7 -0
- package/esm/index.js +206 -31
- package/esm/index.js.map +7 -0
- package/esm/onClickHandlerForNonInteractiveElements.js +17 -17
- package/esm/onClickHandlerForNonInteractiveElements.js.map +7 -0
- package/esm/operators.js +27 -34
- package/esm/operators.js.map +7 -0
- package/esm/platform.js +8 -4
- package/esm/platform.js.map +7 -0
- package/esm/reactTypesUtility.js +16 -9
- package/esm/reactTypesUtility.js.map +7 -0
- package/esm/scrollingTimer.js +8 -11
- package/esm/scrollingTimer.js.map +7 -0
- package/esm/system.js +16 -22
- package/esm/system.js.map +7 -0
- package/esm/timeUtils.js +13 -19
- package/esm/timeUtils.js.map +7 -0
- package/esm/utils.js +109 -72
- package/esm/utils.js.map +7 -0
- package/esm/validations.js +18 -28
- package/esm/validations.js.map +7 -0
- package/package.json +5 -1
- package/types/compose.d.ts +2 -1
- package/types/getComponentFromProps.d.ts +2 -1
- package/types/hooks/index.d.ts +15 -14
- package/types/hooks/useCancellableDelayedCallback.d.ts +2 -1
- package/types/hooks/useDerivedStateFromProps.d.ts +2 -1
- package/types/hooks/useExecutionTimer.d.ts +2 -1
- package/types/hooks/useExpandState.d.ts +3 -2
- package/types/hooks/useHotkeys.d.ts +3 -2
- package/types/hooks/useHoverHandlersDelay.d.ts +3 -2
- package/types/hooks/useIsShowingEllipsis.d.ts +5 -0
- package/types/hooks/usePrevious.d.ts +1 -1
- package/types/hooks/useResizeObserver.d.ts +2 -1
- package/types/hooks/useShouldRecalculate.d.ts +2 -1
- package/types/hooks/useWindowScrollerList.d.ts +3 -2
- package/types/hooks/useWindowSize.d.ts +2 -1
- package/types/index.d.ts +11 -11
- package/types/onClickHandlerForNonInteractiveElements.d.ts +7 -7
- package/types/scrollingTimer.d.ts +1 -1
|
@@ -1,31 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
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 useExecutionTimer_exports = {};
|
|
29
|
+
__export(useExecutionTimer_exports, {
|
|
30
|
+
default: () => useExecutionTimer_default,
|
|
31
|
+
useExecutionTimer: () => useExecutionTimer
|
|
32
|
+
});
|
|
33
|
+
var React = __toESM(require("react"));
|
|
34
|
+
var import_react = require("react");
|
|
35
|
+
const useExecutionTimer = (startFn, cleanFn, delayTime) => {
|
|
36
|
+
const startTimer = (0, import_react.useRef)();
|
|
37
|
+
const closeTimer = (0, import_react.useRef)();
|
|
38
|
+
const startFunction = (...args) => {
|
|
15
39
|
clearTimeout(closeTimer.current);
|
|
16
40
|
startTimer.current = setTimeout(() => startFn(...args), delayTime);
|
|
17
41
|
};
|
|
18
|
-
|
|
19
|
-
const cleanFunction = function () {
|
|
20
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
21
|
-
args[_key2] = arguments[_key2];
|
|
22
|
-
}
|
|
23
|
-
|
|
42
|
+
const cleanFunction = (...args) => {
|
|
24
43
|
clearTimeout(startTimer.current);
|
|
25
44
|
closeTimer.current = setTimeout(() => cleanFn(...args), 30);
|
|
26
45
|
};
|
|
27
|
-
|
|
28
46
|
return [startFunction, cleanFunction];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
module.exports =
|
|
47
|
+
};
|
|
48
|
+
var useExecutionTimer_default = useExecutionTimer;
|
|
49
|
+
module.exports = __toCommonJS(useExecutionTimer_exports);
|
|
50
|
+
//# sourceMappingURL=useExecutionTimer.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useExecutionTimer.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { useRef } from 'react';\n\nexport const useExecutionTimer = (startFn, cleanFn, delayTime) => {\n const startTimer = useRef();\n const closeTimer = useRef();\n\n const startFunction = (...args) => {\n clearTimeout(closeTimer.current);\n startTimer.current = setTimeout(() => startFn(...args), delayTime);\n };\n\n const cleanFunction = (...args) => {\n clearTimeout(startTimer.current);\n closeTimer.current = setTimeout(() => cleanFn(...args), 30);\n };\n return [startFunction, cleanFunction];\n};\n\nexport default useExecutionTimer;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAuB;AAEhB,MAAM,oBAAoB,CAAC,SAAS,SAAS,cAAc;AAChE,QAAM,aAAa;AACnB,QAAM,aAAa;AAEnB,QAAM,gBAAgB,IAAI,SAAS;AACjC,iBAAa,WAAW;AACxB,eAAW,UAAU,WAAW,MAAM,QAAQ,GAAG,OAAO;AAAA;AAG1D,QAAM,gBAAgB,IAAI,SAAS;AACjC,iBAAa,WAAW;AACxB,eAAW,UAAU,WAAW,MAAM,QAAQ,GAAG,OAAO;AAAA;AAE1D,SAAO,CAAC,eAAe;AAAA;AAGzB,IAAO,4BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,125 +1,111 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
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 useExpandState_exports = {};
|
|
29
|
+
__export(useExpandState_exports, {
|
|
30
|
+
default: () => useExpandState_default,
|
|
31
|
+
useExpandState: () => useExpandState
|
|
32
|
+
});
|
|
33
|
+
var React = __toESM(require("react"));
|
|
34
|
+
var import_react = require("react");
|
|
35
|
+
var import_utils = require("../utils");
|
|
36
|
+
var import_useDerivedStateFromProps = require("./useDerivedStateFromProps");
|
|
24
37
|
const toggleStateInObject = (obj, key, value) => {
|
|
25
|
-
const nextObj =
|
|
26
|
-
|
|
38
|
+
const nextObj = { ...obj };
|
|
27
39
|
if (nextObj[key]) {
|
|
28
40
|
delete nextObj[key];
|
|
29
41
|
} else {
|
|
30
42
|
nextObj[key] = value;
|
|
31
43
|
}
|
|
32
|
-
|
|
33
44
|
return nextObj;
|
|
34
45
|
};
|
|
35
|
-
|
|
36
46
|
const noop = () => null;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
const isExpandedAll = React.useMemo(() => Object.keys(expanded).length === items.length, [expanded, items]);
|
|
51
|
-
|
|
52
|
-
const toggleExpandAll = function () {
|
|
53
|
-
let stateData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
47
|
+
const useExpandState = ({
|
|
48
|
+
items = [],
|
|
49
|
+
itemKey = "id",
|
|
50
|
+
expanded: expandedProp = {},
|
|
51
|
+
onExpand,
|
|
52
|
+
onExpandChange = noop,
|
|
53
|
+
onExpandAll = noop,
|
|
54
|
+
onToggleExpand,
|
|
55
|
+
onCollapse
|
|
56
|
+
}) => {
|
|
57
|
+
const [expanded, setExpanded] = (0, import_useDerivedStateFromProps.useDerivedStateFromProps)(expandedProp);
|
|
58
|
+
const isExpandedAll = (0, import_react.useMemo)(() => Object.keys(expanded).length === items.length, [expanded, items]);
|
|
59
|
+
const toggleExpandAll = (stateData = true) => {
|
|
54
60
|
setExpanded(() => {
|
|
55
61
|
const nextState = {};
|
|
56
|
-
|
|
57
62
|
if (!isExpandedAll) {
|
|
58
|
-
items.forEach(item => {
|
|
63
|
+
items.forEach((item) => {
|
|
59
64
|
nextState[item[itemKey]] = stateData;
|
|
60
65
|
});
|
|
61
66
|
}
|
|
62
|
-
|
|
63
67
|
onExpandChange(nextState);
|
|
64
68
|
onExpandAll(nextState);
|
|
65
69
|
return nextState;
|
|
66
70
|
});
|
|
67
71
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
if (lodash.isFunction(onExpand)) {
|
|
72
|
+
const expand = (item, stateData = true) => {
|
|
73
|
+
if (!item)
|
|
74
|
+
return;
|
|
75
|
+
if ((0, import_utils.isFunction)(onExpand)) {
|
|
74
76
|
onExpand(item);
|
|
75
77
|
}
|
|
76
|
-
|
|
77
|
-
setExpanded(prevState => {
|
|
78
|
+
setExpanded((prevState) => {
|
|
78
79
|
const key = item[itemKey];
|
|
79
|
-
|
|
80
|
-
const nextState = _objectSpread(_objectSpread({}, prevState), {}, {
|
|
81
|
-
[key]: stateData
|
|
82
|
-
});
|
|
83
|
-
|
|
80
|
+
const nextState = { ...prevState, [key]: stateData };
|
|
84
81
|
onExpandChange(nextState, item);
|
|
85
82
|
return nextState;
|
|
86
83
|
});
|
|
87
84
|
};
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
let stateData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
91
|
-
|
|
92
|
-
if (lodash.isFunction(onToggleExpand)) {
|
|
85
|
+
const toggleExpand = (item, stateData = true) => {
|
|
86
|
+
if ((0, import_utils.isFunction)(onToggleExpand)) {
|
|
93
87
|
onToggleExpand(item);
|
|
94
88
|
}
|
|
95
|
-
|
|
96
|
-
setExpanded(prevState => {
|
|
89
|
+
setExpanded((prevState) => {
|
|
97
90
|
const key = item[itemKey];
|
|
98
91
|
const nextState = toggleStateInObject(prevState, key, stateData);
|
|
99
92
|
onExpandChange(nextState, item);
|
|
100
93
|
return nextState;
|
|
101
94
|
});
|
|
102
95
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (lodash.isFunction(onCollapse)) {
|
|
96
|
+
const collapse = (item) => {
|
|
97
|
+
if ((0, import_utils.isFunction)(onCollapse)) {
|
|
106
98
|
onCollapse(item);
|
|
107
99
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const nextState = _objectSpread({}, prevState);
|
|
111
|
-
|
|
100
|
+
setExpanded((prevState) => {
|
|
101
|
+
const nextState = { ...prevState };
|
|
112
102
|
delete nextState[item[itemKey]];
|
|
113
103
|
onExpandChange(nextState, item);
|
|
114
104
|
return nextState;
|
|
115
105
|
});
|
|
116
106
|
};
|
|
117
|
-
|
|
118
107
|
return {
|
|
119
|
-
state: {
|
|
120
|
-
expanded,
|
|
121
|
-
isExpandedAll
|
|
122
|
-
},
|
|
108
|
+
state: { expanded, isExpandedAll },
|
|
123
109
|
actions: {
|
|
124
110
|
expand,
|
|
125
111
|
toggleExpandAll,
|
|
@@ -128,6 +114,7 @@ function useExpandState(_ref) {
|
|
|
128
114
|
},
|
|
129
115
|
setExpanded
|
|
130
116
|
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
module.exports =
|
|
117
|
+
};
|
|
118
|
+
var useExpandState_default = useExpandState;
|
|
119
|
+
module.exports = __toCommonJS(useExpandState_exports);
|
|
120
|
+
//# sourceMappingURL=useExpandState.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useExpandState.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { useMemo } from 'react';\nimport { isFunction } from '../utils';\nimport { useDerivedStateFromProps } from './useDerivedStateFromProps';\n\nconst toggleStateInObject = (obj, key, value) => {\n const nextObj = { ...obj };\n if (nextObj[key]) {\n delete nextObj[key];\n } else {\n nextObj[key] = value;\n }\n return nextObj;\n};\n\nconst noop = () => null;\n\nexport const useExpandState = ({\n items = [],\n itemKey = 'id',\n expanded: expandedProp = {},\n onExpand,\n onExpandChange = noop,\n onExpandAll = noop,\n onToggleExpand,\n onCollapse,\n}) => {\n const [expanded, setExpanded] = useDerivedStateFromProps(expandedProp);\n\n const isExpandedAll = useMemo(\n () => Object.keys(expanded).length === items.length,\n [expanded, items],\n );\n\n const toggleExpandAll = (stateData = true) => {\n setExpanded(() => {\n const nextState = {};\n if (!isExpandedAll) {\n items.forEach(item => {\n nextState[item[itemKey]] = stateData;\n });\n }\n onExpandChange(nextState);\n onExpandAll(nextState);\n return nextState;\n });\n };\n\n const expand = (item, stateData = true) => {\n if (!item) return;\n if (isFunction(onExpand)) {\n onExpand(item);\n }\n setExpanded(prevState => {\n const key = item[itemKey];\n const nextState = { ...prevState, [key]: stateData };\n onExpandChange(nextState, item);\n return nextState;\n });\n };\n\n const toggleExpand = (item, stateData = true) => {\n if (isFunction(onToggleExpand)) {\n onToggleExpand(item);\n }\n setExpanded(prevState => {\n const key = item[itemKey];\n const nextState = toggleStateInObject(prevState, key, stateData);\n onExpandChange(nextState, item);\n return nextState;\n });\n };\n\n const collapse = item => {\n if (isFunction(onCollapse)) {\n onCollapse(item);\n }\n setExpanded(prevState => {\n const nextState = { ...prevState };\n delete nextState[item[itemKey]];\n onExpandChange(nextState, item);\n return nextState;\n });\n };\n\n return {\n state: { expanded, isExpandedAll },\n actions: {\n expand,\n toggleExpandAll,\n toggleExpand,\n collapse,\n },\n setExpanded,\n };\n};\n\nexport default useExpandState;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAwB;AACxB,mBAA2B;AAC3B,sCAAyC;AAEzC,MAAM,sBAAsB,CAAC,KAAK,KAAK,UAAU;AAC/C,QAAM,UAAU,KAAK;AACrB,MAAI,QAAQ,MAAM;AAChB,WAAO,QAAQ;AAAA,SACV;AACL,YAAQ,OAAO;AAAA;AAEjB,SAAO;AAAA;AAGT,MAAM,OAAO,MAAM;AAEZ,MAAM,iBAAiB,CAAC;AAAA,EAC7B,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,UAAU,eAAe;AAAA,EACzB;AAAA,EACA,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd;AAAA,EACA;AAAA,MACI;AACJ,QAAM,CAAC,UAAU,eAAe,8DAAyB;AAEzD,QAAM,gBAAgB,0BACpB,MAAM,OAAO,KAAK,UAAU,WAAW,MAAM,QAC7C,CAAC,UAAU;AAGb,QAAM,kBAAkB,CAAC,YAAY,SAAS;AAC5C,gBAAY,MAAM;AAChB,YAAM,YAAY;AAClB,UAAI,CAAC,eAAe;AAClB,cAAM,QAAQ,UAAQ;AACpB,oBAAU,KAAK,YAAY;AAAA;AAAA;AAG/B,qBAAe;AACf,kBAAY;AACZ,aAAO;AAAA;AAAA;AAIX,QAAM,SAAS,CAAC,MAAM,YAAY,SAAS;AACzC,QAAI,CAAC;AAAM;AACX,QAAI,6BAAW,WAAW;AACxB,eAAS;AAAA;AAEX,gBAAY,eAAa;AACvB,YAAM,MAAM,KAAK;AACjB,YAAM,YAAY,KAAK,YAAY,MAAM;AACzC,qBAAe,WAAW;AAC1B,aAAO;AAAA;AAAA;AAIX,QAAM,eAAe,CAAC,MAAM,YAAY,SAAS;AAC/C,QAAI,6BAAW,iBAAiB;AAC9B,qBAAe;AAAA;AAEjB,gBAAY,eAAa;AACvB,YAAM,MAAM,KAAK;AACjB,YAAM,YAAY,oBAAoB,WAAW,KAAK;AACtD,qBAAe,WAAW;AAC1B,aAAO;AAAA;AAAA;AAIX,QAAM,WAAW,UAAQ;AACvB,QAAI,6BAAW,aAAa;AAC1B,iBAAW;AAAA;AAEb,gBAAY,eAAa;AACvB,YAAM,YAAY,KAAK;AACvB,aAAO,UAAU,KAAK;AACtB,qBAAe,WAAW;AAC1B,aAAO;AAAA;AAAA;AAIX,SAAO;AAAA,IACL,OAAO,EAAE,UAAU;AAAA,IACnB,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,IAEF;AAAA;AAAA;AAIJ,IAAO,yBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/cjs/hooks/useHotkeys.js
CHANGED
|
@@ -1,25 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
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 useHotkeys_exports = {};
|
|
29
|
+
__export(useHotkeys_exports, {
|
|
30
|
+
default: () => useHotkeys_default,
|
|
31
|
+
useHotkeys: () => useHotkeys
|
|
32
|
+
});
|
|
33
|
+
var React = __toESM(require("react"));
|
|
34
|
+
var import_hotkeys_js = __toESM(require("hotkeys-js"));
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
const useHotkeys = ({ keys, handler, options = {} }, deps = []) => {
|
|
37
|
+
const memoizedCallback = (0, import_react.useCallback)(handler, deps);
|
|
38
|
+
(0, import_react.useEffect)(() => {
|
|
39
|
+
(0, import_hotkeys_js.default)(keys, options, memoizedCallback);
|
|
40
|
+
return () => import_hotkeys_js.default.unbind(keys);
|
|
22
41
|
}, [memoizedCallback]);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports =
|
|
42
|
+
};
|
|
43
|
+
var useHotkeys_default = useHotkeys;
|
|
44
|
+
module.exports = __toCommonJS(useHotkeys_exports);
|
|
45
|
+
//# sourceMappingURL=useHotkeys.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useHotkeys.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import hotkeys from 'hotkeys-js';\nimport { useCallback, useEffect } from 'react';\n\nexport const useHotkeys = ({ keys, handler, options = {} }, deps = []) => {\n const memoizedCallback = useCallback(handler, deps);\n\n useEffect(() => {\n hotkeys(keys, options, memoizedCallback);\n\n return () => hotkeys.unbind(keys);\n }, [memoizedCallback]);\n};\n\nexport default useHotkeys;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAAoB;AACpB,mBAAuC;AAEhC,MAAM,aAAa,CAAC,EAAE,MAAM,SAAS,UAAU,MAAM,OAAO,OAAO;AACxE,QAAM,mBAAmB,8BAAY,SAAS;AAE9C,8BAAU,MAAM;AACd,mCAAQ,MAAM,SAAS;AAEvB,WAAO,MAAM,0BAAQ,OAAO;AAAA,KAC3B,CAAC;AAAA;AAGN,IAAO,qBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,21 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
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 useHoverHandlersDelay_exports = {};
|
|
29
|
+
__export(useHoverHandlersDelay_exports, {
|
|
30
|
+
default: () => useHoverHandlersDelay_default,
|
|
31
|
+
useHoverHandlersDelay: () => useHoverHandlersDelay
|
|
32
|
+
});
|
|
33
|
+
var React = __toESM(require("react"));
|
|
34
|
+
var import_react = require("react");
|
|
35
|
+
const useHoverHandlersDelay = ({
|
|
36
|
+
onMouseOver,
|
|
37
|
+
onMouseLeave,
|
|
38
|
+
hideDelay = 300,
|
|
39
|
+
showDelay = 300
|
|
40
|
+
}) => {
|
|
41
|
+
const hideTimer = (0, import_react.useRef)();
|
|
42
|
+
const showTimer = (0, import_react.useRef)();
|
|
43
|
+
const delayedHide = (0, import_react.useCallback)(() => {
|
|
15
44
|
clearTimeout(showTimer.current);
|
|
16
45
|
hideTimer.current = setTimeout(onMouseLeave, hideDelay);
|
|
17
46
|
}, []);
|
|
18
|
-
const delayedShow =
|
|
47
|
+
const delayedShow = (0, import_react.useCallback)(() => {
|
|
19
48
|
clearTimeout(hideTimer.current);
|
|
20
49
|
showTimer.current = setTimeout(onMouseOver, showDelay);
|
|
21
50
|
}, []);
|
|
@@ -23,6 +52,7 @@ function useHoverHandlersDelay(_ref) {
|
|
|
23
52
|
onMouseOver: delayedShow,
|
|
24
53
|
onMouseLeave: delayedHide
|
|
25
54
|
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports =
|
|
55
|
+
};
|
|
56
|
+
var useHoverHandlersDelay_default = useHoverHandlersDelay;
|
|
57
|
+
module.exports = __toCommonJS(useHoverHandlersDelay_exports);
|
|
58
|
+
//# sourceMappingURL=useHoverHandlersDelay.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useHoverHandlersDelay.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { useCallback, useRef } from 'react';\n\nexport const useHoverHandlersDelay = ({\n onMouseOver,\n onMouseLeave,\n hideDelay = 300,\n showDelay = 300,\n}) => {\n const hideTimer = useRef();\n const showTimer = useRef();\n\n const delayedHide = useCallback(() => {\n clearTimeout(showTimer.current);\n hideTimer.current = setTimeout(onMouseLeave, hideDelay);\n }, []);\n\n const delayedShow = useCallback(() => {\n clearTimeout(hideTimer.current);\n showTimer.current = setTimeout(onMouseOver, showDelay);\n }, []);\n\n return {\n onMouseOver: delayedShow,\n onMouseLeave: delayedHide,\n };\n};\n\nexport default useHoverHandlersDelay;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAoC;AAE7B,MAAM,wBAAwB,CAAC;AAAA,EACpC;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,YAAY;AAAA,MACR;AACJ,QAAM,YAAY;AAClB,QAAM,YAAY;AAElB,QAAM,cAAc,8BAAY,MAAM;AACpC,iBAAa,UAAU;AACvB,cAAU,UAAU,WAAW,cAAc;AAAA,KAC5C;AAEH,QAAM,cAAc,8BAAY,MAAM;AACpC,iBAAa,UAAU;AACvB,cAAU,UAAU,WAAW,aAAa;AAAA,KAC3C;AAEH,SAAO;AAAA,IACL,aAAa;AAAA,IACb,cAAc;AAAA;AAAA;AAIlB,IAAO,gCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
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 useIsShowingEllipsis_exports = {};
|
|
29
|
+
__export(useIsShowingEllipsis_exports, {
|
|
30
|
+
useIsShowingEllipsis: () => useIsShowingEllipsis
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
var import_react = require("react");
|
|
34
|
+
const useIsShowingEllipsis = () => {
|
|
35
|
+
const [element, setElement] = (0, import_react.useState)();
|
|
36
|
+
const [isShowingEllipsis, setIsShowingEllipsis] = (0, import_react.useState)(false);
|
|
37
|
+
const resizeObserver = (0, import_react.useMemo)(() => new ResizeObserver((entries) => {
|
|
38
|
+
if (entries.length) {
|
|
39
|
+
const [textWrapperEntry] = entries;
|
|
40
|
+
const el = textWrapperEntry.target;
|
|
41
|
+
setIsShowingEllipsis(el?.scrollWidth > el?.clientWidth);
|
|
42
|
+
}
|
|
43
|
+
}), []);
|
|
44
|
+
(0, import_react.useEffect)(() => {
|
|
45
|
+
if (element) {
|
|
46
|
+
setIsShowingEllipsis(element.scrollWidth > element.clientWidth);
|
|
47
|
+
resizeObserver.observe(element);
|
|
48
|
+
}
|
|
49
|
+
return () => {
|
|
50
|
+
if (element) {
|
|
51
|
+
resizeObserver.unobserve(element);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}, [resizeObserver, element]);
|
|
55
|
+
return { setElement, isShowingEllipsis };
|
|
56
|
+
};
|
|
57
|
+
module.exports = __toCommonJS(useIsShowingEllipsis_exports);
|
|
58
|
+
//# sourceMappingURL=useIsShowingEllipsis.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useIsShowingEllipsis.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { useEffect, useState, useMemo } from 'react';\n\nexport const useIsShowingEllipsis = <T extends HTMLElement = HTMLSpanElement>() => {\n const [element, setElement] = useState<T>();\n\n const [isShowingEllipsis, setIsShowingEllipsis] = useState(false);\n\n const resizeObserver = useMemo(\n () =>\n new ResizeObserver((entries) => {\n if (entries.length) {\n const [textWrapperEntry] = entries;\n const el = textWrapperEntry.target;\n setIsShowingEllipsis(el?.scrollWidth > el?.clientWidth);\n }\n }),\n [],\n );\n\n useEffect(() => {\n if (element) {\n setIsShowingEllipsis(element.scrollWidth > element.clientWidth);\n resizeObserver.observe(element);\n }\n return () => {\n if (element) {\n resizeObserver.unobserve(element);\n }\n };\n }, [resizeObserver, element]);\n\n return { setElement, isShowingEllipsis };\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA6C;AAEtC,MAAM,uBAAuB,MAA+C;AACjF,QAAM,CAAC,SAAS,cAAc;AAE9B,QAAM,CAAC,mBAAmB,wBAAwB,2BAAS;AAE3D,QAAM,iBAAiB,0BACrB,MACE,IAAI,eAAe,CAAC,YAAY;AAC9B,QAAI,QAAQ,QAAQ;AAClB,YAAM,CAAC,oBAAoB;AAC3B,YAAM,KAAK,iBAAiB;AAC5B,2BAAqB,IAAI,cAAc,IAAI;AAAA;AAAA,MAGjD;AAGF,8BAAU,MAAM;AACd,QAAI,SAAS;AACX,2BAAqB,QAAQ,cAAc,QAAQ;AACnD,qBAAe,QAAQ;AAAA;AAEzB,WAAO,MAAM;AACX,UAAI,SAAS;AACX,uBAAe,UAAU;AAAA;AAAA;AAAA,KAG5B,CAAC,gBAAgB;AAEpB,SAAO,EAAE,YAAY;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,37 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
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 useOnElementResize_exports = {};
|
|
29
|
+
__export(useOnElementResize_exports, {
|
|
30
|
+
useOnElementResize: () => useOnElementResize
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
var import_react = require("react");
|
|
34
|
+
const useOnElementResize = (targetRef) => {
|
|
35
|
+
const [width, setWidth] = (0, import_react.useState)(targetRef.current ? targetRef.current?.offsetWidth : 0);
|
|
36
|
+
const [height, setHeight] = (0, import_react.useState)(targetRef.current ? targetRef.current?.offsetWidth : 0);
|
|
37
|
+
const observer = (0, import_react.useRef)(null);
|
|
38
|
+
(0, import_react.useEffect)(() => {
|
|
17
39
|
function outputsize() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
setWidth((_targetRef$current3 = targetRef.current) === null || _targetRef$current3 === void 0 ? void 0 : _targetRef$current3.offsetWidth);
|
|
21
|
-
setHeight((_targetRef$current4 = targetRef.current) === null || _targetRef$current4 === void 0 ? void 0 : _targetRef$current4.offsetHeight);
|
|
40
|
+
setWidth(targetRef.current?.offsetWidth);
|
|
41
|
+
setHeight(targetRef.current?.offsetHeight);
|
|
22
42
|
}
|
|
23
|
-
|
|
24
43
|
observer.current = new ResizeObserver(outputsize).observe(targetRef.current);
|
|
25
44
|
return () => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
(_observer$current = observer.current) === null || _observer$current === void 0 ? void 0 : _observer$current.disconnect();
|
|
45
|
+
observer.current?.disconnect();
|
|
29
46
|
};
|
|
30
47
|
}, [targetRef]);
|
|
31
|
-
return
|
|
48
|
+
return (0, import_react.useMemo)(() => ({
|
|
32
49
|
width,
|
|
33
50
|
height
|
|
34
51
|
}), [width, height]);
|
|
35
52
|
};
|
|
36
|
-
|
|
37
|
-
|
|
53
|
+
module.exports = __toCommonJS(useOnElementResize_exports);
|
|
54
|
+
//# sourceMappingURL=useOnElementResize.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useOnElementResize.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React, { useState, useEffect, useRef, useMemo } from 'react';\n\n// Custom hook to track dimension of a component\n// Taken and modified from https://stackoverflow.com/a/60218754\nexport const useOnElementResize = (targetRef: React.RefObject<HTMLDivElement>): Record<'width' | 'height', number> => {\n const [width, setWidth] = useState(targetRef.current ? targetRef.current?.offsetWidth : 0);\n const [height, setHeight] = useState(targetRef.current ? targetRef.current?.offsetWidth : 0);\n const observer = useRef(null);\n\n useEffect(() => {\n function outputsize() {\n setWidth(targetRef.current?.offsetWidth);\n setHeight(targetRef.current?.offsetHeight);\n }\n\n observer.current = new ResizeObserver(outputsize).observe(targetRef.current);\n\n return () => {\n observer.current?.disconnect();\n };\n }, [targetRef]);\n\n return useMemo(\n () => ({\n width,\n height,\n }),\n [width, height],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA4D;AAIrD,MAAM,qBAAqB,CAAC,cAAmF;AACpH,QAAM,CAAC,OAAO,YAAY,2BAAS,UAAU,UAAU,UAAU,SAAS,cAAc;AACxF,QAAM,CAAC,QAAQ,aAAa,2BAAS,UAAU,UAAU,UAAU,SAAS,cAAc;AAC1F,QAAM,WAAW,yBAAO;AAExB,8BAAU,MAAM;AACd,0BAAsB;AACpB,eAAS,UAAU,SAAS;AAC5B,gBAAU,UAAU,SAAS;AAAA;AAG/B,aAAS,UAAU,IAAI,eAAe,YAAY,QAAQ,UAAU;AAEpE,WAAO,MAAM;AACX,eAAS,SAAS;AAAA;AAAA,KAEnB,CAAC;AAEJ,SAAO,0BACL,MAAO;AAAA,IACL;AAAA,IACA;AAAA,MAEF,CAAC,OAAO;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|