@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.
Files changed (135) hide show
  1. package/cjs/capitalize.js +35 -7
  2. package/cjs/capitalize.js.map +7 -0
  3. package/cjs/compose.js +39 -32
  4. package/cjs/compose.js.map +7 -0
  5. package/cjs/getComponentFromProps.js +47 -29
  6. package/cjs/getComponentFromProps.js.map +7 -0
  7. package/cjs/hooks/index.js +70 -60
  8. package/cjs/hooks/index.js.map +7 -0
  9. package/cjs/hooks/useCancellableDelayedCallback.js +43 -18
  10. package/cjs/hooks/useCancellableDelayedCallback.js.map +7 -0
  11. package/cjs/hooks/useDerivedStateFromProps.js +47 -36
  12. package/cjs/hooks/useDerivedStateFromProps.js.map +7 -0
  13. package/cjs/hooks/useExecutionTimer.js +43 -24
  14. package/cjs/hooks/useExecutionTimer.js.map +7 -0
  15. package/cjs/hooks/useExpandState.js +69 -82
  16. package/cjs/hooks/useExpandState.js.map +7 -0
  17. package/cjs/hooks/useHotkeys.js +44 -24
  18. package/cjs/hooks/useHotkeys.js.map +7 -0
  19. package/cjs/hooks/useHoverHandlersDelay.js +48 -18
  20. package/cjs/hooks/useHoverHandlersDelay.js.map +7 -0
  21. package/cjs/hooks/useIsShowingEllipsis.js +58 -0
  22. package/cjs/hooks/useIsShowingEllipsis.js.map +7 -0
  23. package/cjs/hooks/useOnElementResize.js +44 -27
  24. package/cjs/hooks/useOnElementResize.js.map +7 -0
  25. package/cjs/hooks/useParentElement.js +40 -13
  26. package/cjs/hooks/useParentElement.js.map +7 -0
  27. package/cjs/hooks/usePrevious.js +41 -10
  28. package/cjs/hooks/usePrevious.js.map +7 -0
  29. package/cjs/hooks/useResizeObserver.js +52 -25
  30. package/cjs/hooks/useResizeObserver.js.map +7 -0
  31. package/cjs/hooks/useSetRef.js +38 -11
  32. package/cjs/hooks/useSetRef.js.map +7 -0
  33. package/cjs/hooks/useShouldRecalculate.js +41 -14
  34. package/cjs/hooks/useShouldRecalculate.js.map +7 -0
  35. package/cjs/hooks/useWindowScrollerList.js +51 -33
  36. package/cjs/hooks/useWindowScrollerList.js.map +7 -0
  37. package/cjs/hooks/useWindowSize.js +49 -19
  38. package/cjs/hooks/useWindowSize.js.map +7 -0
  39. package/cjs/index.js +146 -266
  40. package/cjs/index.js.map +7 -0
  41. package/cjs/onClickHandlerForNonInteractiveElements.js +46 -19
  42. package/cjs/onClickHandlerForNonInteractiveElements.js.map +7 -0
  43. package/cjs/operators.js +56 -51
  44. package/cjs/operators.js.map +7 -0
  45. package/cjs/platform.js +37 -9
  46. package/cjs/platform.js.map +7 -0
  47. package/cjs/reactTypesUtility.js +45 -22
  48. package/cjs/reactTypesUtility.js.map +7 -0
  49. package/cjs/scrollingTimer.js +37 -15
  50. package/cjs/scrollingTimer.js.map +7 -0
  51. package/cjs/system.js +47 -30
  52. package/cjs/system.js.map +7 -0
  53. package/cjs/timeUtils.js +42 -24
  54. package/cjs/timeUtils.js.map +7 -0
  55. package/cjs/utils.js +101 -237
  56. package/cjs/utils.js.map +7 -0
  57. package/cjs/validations.js +48 -35
  58. package/cjs/validations.js.map +7 -0
  59. package/esm/capitalize.js +6 -3
  60. package/esm/capitalize.js.map +7 -0
  61. package/esm/compose.js +11 -29
  62. package/esm/compose.js.map +7 -0
  63. package/esm/getComponentFromProps.js +18 -22
  64. package/esm/getComponentFromProps.js.map +7 -0
  65. package/esm/hooks/index.js +42 -18
  66. package/esm/hooks/index.js.map +7 -0
  67. package/esm/hooks/useCancellableDelayedCallback.js +12 -14
  68. package/esm/hooks/useCancellableDelayedCallback.js.map +7 -0
  69. package/esm/hooks/useDerivedStateFromProps.js +15 -31
  70. package/esm/hooks/useDerivedStateFromProps.js.map +7 -0
  71. package/esm/hooks/useExecutionTimer.js +12 -20
  72. package/esm/hooks/useExecutionTimer.js.map +7 -0
  73. package/esm/hooks/useExpandState.js +36 -72
  74. package/esm/hooks/useExpandState.js.map +7 -0
  75. package/esm/hooks/useHotkeys.js +11 -14
  76. package/esm/hooks/useHotkeys.js.map +7 -0
  77. package/esm/hooks/useHoverHandlersDelay.js +15 -12
  78. package/esm/hooks/useHoverHandlersDelay.js.map +7 -0
  79. package/esm/hooks/useIsShowingEllipsis.js +29 -0
  80. package/esm/hooks/useIsShowingEllipsis.js.map +7 -0
  81. package/esm/hooks/useOnElementResize.js +12 -20
  82. package/esm/hooks/useOnElementResize.js.map +7 -0
  83. package/esm/hooks/useParentElement.js +9 -7
  84. package/esm/hooks/useParentElement.js.map +7 -0
  85. package/esm/hooks/usePrevious.js +10 -6
  86. package/esm/hooks/usePrevious.js.map +7 -0
  87. package/esm/hooks/useResizeObserver.js +20 -15
  88. package/esm/hooks/useResizeObserver.js.map +7 -0
  89. package/esm/hooks/useSetRef.js +8 -6
  90. package/esm/hooks/useSetRef.js.map +7 -0
  91. package/esm/hooks/useShouldRecalculate.js +11 -11
  92. package/esm/hooks/useShouldRecalculate.js.map +7 -0
  93. package/esm/hooks/useWindowScrollerList.js +20 -29
  94. package/esm/hooks/useWindowScrollerList.js.map +7 -0
  95. package/esm/hooks/useWindowSize.js +18 -15
  96. package/esm/hooks/useWindowSize.js.map +7 -0
  97. package/esm/index.js +206 -31
  98. package/esm/index.js.map +7 -0
  99. package/esm/onClickHandlerForNonInteractiveElements.js +17 -17
  100. package/esm/onClickHandlerForNonInteractiveElements.js.map +7 -0
  101. package/esm/operators.js +27 -34
  102. package/esm/operators.js.map +7 -0
  103. package/esm/platform.js +8 -4
  104. package/esm/platform.js.map +7 -0
  105. package/esm/reactTypesUtility.js +16 -9
  106. package/esm/reactTypesUtility.js.map +7 -0
  107. package/esm/scrollingTimer.js +8 -11
  108. package/esm/scrollingTimer.js.map +7 -0
  109. package/esm/system.js +16 -22
  110. package/esm/system.js.map +7 -0
  111. package/esm/timeUtils.js +13 -19
  112. package/esm/timeUtils.js.map +7 -0
  113. package/esm/utils.js +109 -72
  114. package/esm/utils.js.map +7 -0
  115. package/esm/validations.js +18 -28
  116. package/esm/validations.js.map +7 -0
  117. package/package.json +5 -1
  118. package/types/compose.d.ts +2 -1
  119. package/types/getComponentFromProps.d.ts +2 -1
  120. package/types/hooks/index.d.ts +15 -14
  121. package/types/hooks/useCancellableDelayedCallback.d.ts +2 -1
  122. package/types/hooks/useDerivedStateFromProps.d.ts +2 -1
  123. package/types/hooks/useExecutionTimer.d.ts +2 -1
  124. package/types/hooks/useExpandState.d.ts +3 -2
  125. package/types/hooks/useHotkeys.d.ts +3 -2
  126. package/types/hooks/useHoverHandlersDelay.d.ts +3 -2
  127. package/types/hooks/useIsShowingEllipsis.d.ts +5 -0
  128. package/types/hooks/usePrevious.d.ts +1 -1
  129. package/types/hooks/useResizeObserver.d.ts +2 -1
  130. package/types/hooks/useShouldRecalculate.d.ts +2 -1
  131. package/types/hooks/useWindowScrollerList.d.ts +3 -2
  132. package/types/hooks/useWindowSize.d.ts +2 -1
  133. package/types/index.d.ts +11 -11
  134. package/types/onClickHandlerForNonInteractiveElements.d.ts +7 -7
  135. package/types/scrollingTimer.d.ts +1 -1
@@ -1,18 +1,42 @@
1
- export { default as useMeasure } from 'use-measure';
2
- export { default as useExecutionTimer } from './useExecutionTimer.js';
3
- export { default as useExpandState } from './useExpandState.js';
4
- export { default as useHotkeys } from './useHotkeys.js';
5
- export { default as useHoverHandlersDelay } from './useHoverHandlersDelay.js';
6
- export { default as useResizeObserver } from './useResizeObserver.js';
7
- export { default as useShouldRecalculate } from './useShouldRecalculate.js';
8
- export { default as useWindowScrollerList } from './useWindowScrollerList.js';
9
- export { default as useWindowSize } from './useWindowSize.js';
10
- export { default as useForceUpdate } from 'use-force-update';
11
- export { default as useOnClickOutside } from 'use-onclickoutside';
12
- export { useUncontrolled } from 'uncontrollable';
13
- export { default as usePrevious } from './usePrevious.js';
14
- export { default as useCancellableDelayedCallback } from './useCancellableDelayedCallback.js';
15
- export { default as useDerivedStateFromProps } from './useDerivedStateFromProps.js';
16
- export { useSetRef } from './useSetRef.js';
17
- export { useParentElement } from './useParentElement.js';
18
- export { useOnElementResize } from './useOnElementResize.js';
1
+ import * as React from "react";
2
+ import { default as default2 } from "use-measure";
3
+ import { default as default3 } from "use-force-update";
4
+ import { default as default4 } from "use-onclickoutside";
5
+ import { useUncontrolled } from "uncontrollable";
6
+ import { useExecutionTimer } from "./useExecutionTimer";
7
+ import { useExpandState } from "./useExpandState";
8
+ import { useHotkeys } from "./useHotkeys";
9
+ import { useHoverHandlersDelay } from "./useHoverHandlersDelay";
10
+ import { useResizeObserver } from "./useResizeObserver";
11
+ import { useShouldRecalculate } from "./useShouldRecalculate";
12
+ import { useWindowScrollerList } from "./useWindowScrollerList";
13
+ import { useWindowSize } from "./useWindowSize";
14
+ import { usePrevious } from "./usePrevious";
15
+ import { useCancellableDelayedCallback } from "./useCancellableDelayedCallback";
16
+ import { useDerivedStateFromProps } from "./useDerivedStateFromProps";
17
+ import { useSetRef } from "./useSetRef";
18
+ import { useParentElement } from "./useParentElement";
19
+ import { useOnElementResize } from "./useOnElementResize";
20
+ import { useIsShowingEllipsis } from "./useIsShowingEllipsis";
21
+ export {
22
+ useCancellableDelayedCallback,
23
+ useDerivedStateFromProps,
24
+ useExecutionTimer,
25
+ useExpandState,
26
+ default3 as useForceUpdate,
27
+ useHotkeys,
28
+ useHoverHandlersDelay,
29
+ useIsShowingEllipsis,
30
+ default2 as useMeasure,
31
+ default4 as useOnClickOutside,
32
+ useOnElementResize,
33
+ useParentElement,
34
+ usePrevious,
35
+ useResizeObserver,
36
+ useSetRef,
37
+ useShouldRecalculate,
38
+ useUncontrolled,
39
+ useWindowScrollerList,
40
+ useWindowSize
41
+ };
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/index.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { default as useMeasure } from 'use-measure';\nexport { default as useForceUpdate } from 'use-force-update';\nexport { default as useOnClickOutside } from 'use-onclickoutside';\nexport { useUncontrolled } from 'uncontrollable';\nexport { useExecutionTimer } from './useExecutionTimer';\nexport { useExpandState } from './useExpandState';\nexport { useHotkeys } from './useHotkeys';\nexport { useHoverHandlersDelay } from './useHoverHandlersDelay';\nexport { useResizeObserver } from './useResizeObserver';\nexport { useShouldRecalculate } from './useShouldRecalculate';\nexport { useWindowScrollerList } from './useWindowScrollerList';\nexport { useWindowSize } from './useWindowSize';\nexport { usePrevious } from './usePrevious';\nexport { useCancellableDelayedCallback } from './useCancellableDelayedCallback';\nexport { useDerivedStateFromProps } from './useDerivedStateFromProps';\nexport { useSetRef } from './useSetRef';\nexport { useParentElement } from './useParentElement';\nexport { useOnElementResize } from './useOnElementResize';\nexport { useIsShowingEllipsis } from './useIsShowingEllipsis';\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;",
6
+ "names": []
7
+ }
@@ -1,24 +1,22 @@
1
- import 'core-js/modules/web.dom-collections.iterator.js';
2
- import { useRef, useCallback } from 'react';
3
-
4
- function useCancellableDelayedCallback(cb, delay) {
1
+ import * as React from "react";
2
+ import { useCallback, useRef } from "react";
3
+ const useCancellableDelayedCallback = (cb, delay) => {
5
4
  const timeoutRef = useRef();
6
5
  const cancel = useCallback(() => {
7
6
  const timeoutId = timeoutRef.current;
8
-
9
7
  if (timeoutId) {
10
- timeoutRef.current = undefined;
8
+ timeoutRef.current = void 0;
11
9
  clearTimeout(timeoutId);
12
10
  }
13
11
  }, [timeoutRef]);
14
- const delayedCb = useCallback(function () {
15
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
16
- args[_key] = arguments[_key];
17
- }
18
-
12
+ const delayedCb = useCallback((...args) => {
19
13
  timeoutRef.current = setTimeout(() => cb(...args), delay);
20
14
  }, [cb, delay]);
21
15
  return [delayedCb, cancel];
22
- }
23
-
24
- export { useCancellableDelayedCallback as default };
16
+ };
17
+ var useCancellableDelayedCallback_default = useCancellableDelayedCallback;
18
+ export {
19
+ useCancellableDelayedCallback_default as default,
20
+ useCancellableDelayedCallback
21
+ };
22
+ //# sourceMappingURL=useCancellableDelayedCallback.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useCancellableDelayedCallback.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useCallback, useRef } from 'react';\n\nexport const useCancellableDelayedCallback = (cb, delay) => {\n const timeoutRef = useRef();\n const cancel = useCallback(() => {\n const timeoutId = timeoutRef.current;\n if (timeoutId) {\n timeoutRef.current = undefined;\n clearTimeout(timeoutId);\n }\n }, [timeoutRef]);\n const delayedCb = useCallback(\n (...args) => {\n timeoutRef.current = setTimeout(() => cb(...args), delay);\n },\n [cb, delay],\n );\n\n return [delayedCb, cancel];\n};\n\nexport default useCancellableDelayedCallback;\n"],
5
+ "mappings": "AAAA;ACAA;AAEO,MAAM,gCAAgC,CAAC,IAAI,UAAU;AAC1D,QAAM,aAAa;AACnB,QAAM,SAAS,YAAY,MAAM;AAC/B,UAAM,YAAY,WAAW;AAC7B,QAAI,WAAW;AACb,iBAAW,UAAU;AACrB,mBAAa;AAAA;AAAA,KAEd,CAAC;AACJ,QAAM,YAAY,YAChB,IAAI,SAAS;AACX,eAAW,UAAU,WAAW,MAAM,GAAG,GAAG,OAAO;AAAA,KAErD,CAAC,IAAI;AAGP,SAAO,CAAC,WAAW;AAAA;AAGrB,IAAO,wCAAQ;",
6
+ "names": []
7
+ }
@@ -1,34 +1,16 @@
1
- import 'core-js/modules/web.dom-collections.iterator.js';
2
- import { useState, useRef } from 'react';
3
- import 'core-js/modules/esnext.async-iterator.filter.js';
4
- import 'core-js/modules/esnext.iterator.filter.js';
5
- import '@babel/runtime/helpers/esm/defineProperty';
6
- import 'core-js/modules/esnext.async-iterator.reduce.js';
7
- import 'core-js/modules/esnext.iterator.constructor.js';
8
- import 'core-js/modules/esnext.iterator.reduce.js';
9
- import 'core-js/modules/esnext.async-iterator.for-each.js';
10
- import 'core-js/modules/esnext.iterator.for-each.js';
11
- import { isFunction, isEqual } from 'lodash';
12
-
13
- const defaultPropUpdateOnChange = prop => prop;
14
-
15
- function defaultShouldUpdate(_ref) {
16
- let {
17
- prop,
18
- prevProp,
19
- stateValue
20
- } = _ref;
1
+ import * as React from "react";
2
+ import { useRef, useState } from "react";
3
+ import { isEqual, isFunction } from "../utils";
4
+ const defaultPropUpdateOnChange = (prop) => prop;
5
+ function defaultShouldUpdate({ prop, prevProp, stateValue }) {
21
6
  return !isEqual(prop, prevProp) && !isEqual(prop, stateValue);
22
7
  }
23
-
24
8
  function setStateWithUpdate(onUpdate, setState) {
25
- return state => {
26
- setState(prevState => onUpdate(isFunction(state) ? state(prevState) : state, prevState));
9
+ return (state) => {
10
+ setState((prevState) => onUpdate(isFunction(state) ? state(prevState) : state, prevState));
27
11
  };
28
12
  }
29
-
30
- function useDerivedStateFromProp(prop) {
31
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
13
+ const useDerivedStateFromProps = (prop, options = {}) => {
32
14
  const {
33
15
  onUpdate = defaultPropUpdateOnChange,
34
16
  shouldUpdate = defaultShouldUpdate,
@@ -37,7 +19,6 @@ function useDerivedStateFromProp(prop) {
37
19
  const [stateValue, setState] = useState(onUpdate(prop, {}));
38
20
  const handleSetState = updateOnStateChange ? setStateWithUpdate(onUpdate, setState) : setState;
39
21
  const prevProp = useRef(prop);
40
-
41
22
  if (shouldUpdate({
42
23
  prop,
43
24
  prevProp: prevProp.current,
@@ -46,9 +27,12 @@ function useDerivedStateFromProp(prop) {
46
27
  const nextProp = onUpdate(prop, prevProp.current);
47
28
  setState(nextProp);
48
29
  }
49
-
50
30
  prevProp.current = prop;
51
31
  return [stateValue, handleSetState];
52
- }
53
-
54
- export { useDerivedStateFromProp as default };
32
+ };
33
+ var useDerivedStateFromProps_default = useDerivedStateFromProps;
34
+ export {
35
+ useDerivedStateFromProps_default as default,
36
+ useDerivedStateFromProps
37
+ };
38
+ //# sourceMappingURL=useDerivedStateFromProps.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useDerivedStateFromProps.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useRef, useState } from 'react';\nimport { isEqual, isFunction } from '../utils';\n\nconst defaultPropUpdateOnChange = prop => prop;\n\nfunction defaultShouldUpdate({ prop, prevProp, stateValue }) {\n return !isEqual(prop, prevProp) && !isEqual(prop, stateValue);\n}\n\nfunction setStateWithUpdate(onUpdate, setState) {\n return state => {\n setState(prevState =>\n onUpdate(isFunction(state) ? state(prevState) : state, prevState),\n );\n };\n}\n\nexport const useDerivedStateFromProps = (prop, options = {}) => {\n const {\n onUpdate = defaultPropUpdateOnChange,\n shouldUpdate = defaultShouldUpdate,\n updateOnStateChange = false,\n } = options;\n\n const [stateValue, setState] = useState(onUpdate(prop, {}));\n const handleSetState = updateOnStateChange\n ? setStateWithUpdate(onUpdate, setState)\n : setState;\n const prevProp = useRef(prop);\n\n if (\n shouldUpdate({\n prop,\n prevProp: prevProp.current,\n stateValue,\n })\n ) {\n const nextProp = onUpdate(prop, prevProp.current);\n setState(nextProp);\n }\n prevProp.current = prop;\n return [stateValue, handleSetState];\n};\n\nexport default useDerivedStateFromProps;\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AAEA,MAAM,4BAA4B,UAAQ;AAE1C,6BAA6B,EAAE,MAAM,UAAU,cAAc;AAC3D,SAAO,CAAC,QAAQ,MAAM,aAAa,CAAC,QAAQ,MAAM;AAAA;AAGpD,4BAA4B,UAAU,UAAU;AAC9C,SAAO,WAAS;AACd,aAAS,eACP,SAAS,WAAW,SAAS,MAAM,aAAa,OAAO;AAAA;AAAA;AAKtD,MAAM,2BAA2B,CAAC,MAAM,UAAU,OAAO;AAC9D,QAAM;AAAA,IACJ,WAAW;AAAA,IACX,eAAe;AAAA,IACf,sBAAsB;AAAA,MACpB;AAEJ,QAAM,CAAC,YAAY,YAAY,SAAS,SAAS,MAAM;AACvD,QAAM,iBAAiB,sBACnB,mBAAmB,UAAU,YAC7B;AACJ,QAAM,WAAW,OAAO;AAExB,MACE,aAAa;AAAA,IACX;AAAA,IACA,UAAU,SAAS;AAAA,IACnB;AAAA,MAEF;AACA,UAAM,WAAW,SAAS,MAAM,SAAS;AACzC,aAAS;AAAA;AAEX,WAAS,UAAU;AACnB,SAAO,CAAC,YAAY;AAAA;AAGtB,IAAO,mCAAQ;",
6
+ "names": []
7
+ }
@@ -1,29 +1,21 @@
1
- import 'core-js/modules/web.dom-collections.iterator.js';
2
- import { useRef } from 'react';
3
-
4
- function useExecutionDelay(startFn, cleanFn, delayTime) {
1
+ import * as React from "react";
2
+ import { useRef } from "react";
3
+ const useExecutionTimer = (startFn, cleanFn, delayTime) => {
5
4
  const startTimer = useRef();
6
5
  const closeTimer = useRef();
7
-
8
- const startFunction = function () {
9
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
10
- args[_key] = arguments[_key];
11
- }
12
-
6
+ const startFunction = (...args) => {
13
7
  clearTimeout(closeTimer.current);
14
8
  startTimer.current = setTimeout(() => startFn(...args), delayTime);
15
9
  };
16
-
17
- const cleanFunction = function () {
18
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
19
- args[_key2] = arguments[_key2];
20
- }
21
-
10
+ const cleanFunction = (...args) => {
22
11
  clearTimeout(startTimer.current);
23
12
  closeTimer.current = setTimeout(() => cleanFn(...args), 30);
24
13
  };
25
-
26
14
  return [startFunction, cleanFunction];
27
- }
28
-
29
- export { useExecutionDelay as default };
15
+ };
16
+ var useExecutionTimer_default = useExecutionTimer;
17
+ export {
18
+ useExecutionTimer_default as default,
19
+ useExecutionTimer
20
+ };
21
+ //# sourceMappingURL=useExecutionTimer.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useExecutionTimer.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
5
+ "mappings": "AAAA;ACAA;AAEO,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,119 +1,79 @@
1
- import 'core-js/modules/esnext.async-iterator.filter.js';
2
- import 'core-js/modules/esnext.iterator.filter.js';
3
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
4
- import 'core-js/modules/web.dom-collections.iterator.js';
5
- import 'core-js/modules/esnext.async-iterator.for-each.js';
6
- import 'core-js/modules/esnext.iterator.constructor.js';
7
- import 'core-js/modules/esnext.iterator.for-each.js';
8
- import { useMemo } from 'react';
9
- import 'core-js/modules/esnext.async-iterator.reduce.js';
10
- import 'core-js/modules/esnext.iterator.reduce.js';
11
- import { isFunction } from 'lodash';
12
- import useDerivedStateFromProp from './useDerivedStateFromProps.js';
13
-
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
-
1
+ import * as React from "react";
2
+ import { useMemo } from "react";
3
+ import { isFunction } from "../utils";
4
+ import { useDerivedStateFromProps } from "./useDerivedStateFromProps";
18
5
  const toggleStateInObject = (obj, key, value) => {
19
- const nextObj = _objectSpread({}, obj);
20
-
6
+ const nextObj = { ...obj };
21
7
  if (nextObj[key]) {
22
8
  delete nextObj[key];
23
9
  } else {
24
10
  nextObj[key] = value;
25
11
  }
26
-
27
12
  return nextObj;
28
13
  };
29
-
30
14
  const noop = () => null;
31
-
32
- function useExpandState(_ref) {
33
- let {
34
- items = [],
35
- itemKey = 'id',
36
- expanded: expandedProp = {},
37
- onExpand,
38
- onExpandChange = noop,
39
- onExpandAll = noop,
40
- onToggleExpand,
41
- onCollapse
42
- } = _ref;
43
- const [expanded, setExpanded] = useDerivedStateFromProp(expandedProp);
15
+ const useExpandState = ({
16
+ items = [],
17
+ itemKey = "id",
18
+ expanded: expandedProp = {},
19
+ onExpand,
20
+ onExpandChange = noop,
21
+ onExpandAll = noop,
22
+ onToggleExpand,
23
+ onCollapse
24
+ }) => {
25
+ const [expanded, setExpanded] = useDerivedStateFromProps(expandedProp);
44
26
  const isExpandedAll = useMemo(() => Object.keys(expanded).length === items.length, [expanded, items]);
45
-
46
- const toggleExpandAll = function () {
47
- let stateData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
27
+ const toggleExpandAll = (stateData = true) => {
48
28
  setExpanded(() => {
49
29
  const nextState = {};
50
-
51
30
  if (!isExpandedAll) {
52
- items.forEach(item => {
31
+ items.forEach((item) => {
53
32
  nextState[item[itemKey]] = stateData;
54
33
  });
55
34
  }
56
-
57
35
  onExpandChange(nextState);
58
36
  onExpandAll(nextState);
59
37
  return nextState;
60
38
  });
61
39
  };
62
-
63
- const expand = function (item) {
64
- let stateData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
65
- if (!item) return;
66
-
40
+ const expand = (item, stateData = true) => {
41
+ if (!item)
42
+ return;
67
43
  if (isFunction(onExpand)) {
68
44
  onExpand(item);
69
45
  }
70
-
71
- setExpanded(prevState => {
46
+ setExpanded((prevState) => {
72
47
  const key = item[itemKey];
73
-
74
- const nextState = _objectSpread(_objectSpread({}, prevState), {}, {
75
- [key]: stateData
76
- });
77
-
48
+ const nextState = { ...prevState, [key]: stateData };
78
49
  onExpandChange(nextState, item);
79
50
  return nextState;
80
51
  });
81
52
  };
82
-
83
- const toggleExpand = function (item) {
84
- let stateData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
85
-
53
+ const toggleExpand = (item, stateData = true) => {
86
54
  if (isFunction(onToggleExpand)) {
87
55
  onToggleExpand(item);
88
56
  }
89
-
90
- setExpanded(prevState => {
57
+ setExpanded((prevState) => {
91
58
  const key = item[itemKey];
92
59
  const nextState = toggleStateInObject(prevState, key, stateData);
93
60
  onExpandChange(nextState, item);
94
61
  return nextState;
95
62
  });
96
63
  };
97
-
98
- const collapse = item => {
64
+ const collapse = (item) => {
99
65
  if (isFunction(onCollapse)) {
100
66
  onCollapse(item);
101
67
  }
102
-
103
- setExpanded(prevState => {
104
- const nextState = _objectSpread({}, prevState);
105
-
68
+ setExpanded((prevState) => {
69
+ const nextState = { ...prevState };
106
70
  delete nextState[item[itemKey]];
107
71
  onExpandChange(nextState, item);
108
72
  return nextState;
109
73
  });
110
74
  };
111
-
112
75
  return {
113
- state: {
114
- expanded,
115
- isExpandedAll
116
- },
76
+ state: { expanded, isExpandedAll },
117
77
  actions: {
118
78
  expand,
119
79
  toggleExpandAll,
@@ -122,6 +82,10 @@ function useExpandState(_ref) {
122
82
  },
123
83
  setExpanded
124
84
  };
125
- }
126
-
127
- export { useExpandState as default };
85
+ };
86
+ var useExpandState_default = useExpandState;
87
+ export {
88
+ useExpandState_default as default,
89
+ useExpandState
90
+ };
91
+ //# sourceMappingURL=useExpandState.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useExpandState.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
5
+ "mappings": "AAAA;ACAA;AACA;AACA;AAEA,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,yBAAyB;AAEzD,QAAM,gBAAgB,QACpB,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,WAAW,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,WAAW,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,WAAW,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
+ }
@@ -1,19 +1,16 @@
1
- import 'core-js/modules/web.dom-collections.iterator.js';
2
- import hotkeys from 'hotkeys-js';
3
- import { useCallback, useEffect } from 'react';
4
-
5
- function useHotkeys(_ref) {
6
- let {
7
- keys,
8
- handler,
9
- options = {}
10
- } = _ref;
11
- let deps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
1
+ import * as React from "react";
2
+ import hotkeys from "hotkeys-js";
3
+ import { useCallback, useEffect } from "react";
4
+ const useHotkeys = ({ keys, handler, options = {} }, deps = []) => {
12
5
  const memoizedCallback = useCallback(handler, deps);
13
6
  useEffect(() => {
14
7
  hotkeys(keys, options, memoizedCallback);
15
8
  return () => hotkeys.unbind(keys);
16
9
  }, [memoizedCallback]);
17
- }
18
-
19
- export { useHotkeys as default };
10
+ };
11
+ var useHotkeys_default = useHotkeys;
12
+ export {
13
+ useHotkeys_default as default,
14
+ useHotkeys
15
+ };
16
+ //# sourceMappingURL=useHotkeys.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useHotkeys.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
5
+ "mappings": "AAAA;ACAA;AACA;AAEO,MAAM,aAAa,CAAC,EAAE,MAAM,SAAS,UAAU,MAAM,OAAO,OAAO;AACxE,QAAM,mBAAmB,YAAY,SAAS;AAE9C,YAAU,MAAM;AACd,YAAQ,MAAM,SAAS;AAEvB,WAAO,MAAM,QAAQ,OAAO;AAAA,KAC3B,CAAC;AAAA;AAGN,IAAO,qBAAQ;",
6
+ "names": []
7
+ }
@@ -1,12 +1,11 @@
1
- import { useRef, useCallback } from 'react';
2
-
3
- function useHoverHandlersDelay(_ref) {
4
- let {
5
- onMouseOver,
6
- onMouseLeave,
7
- hideDelay = 300,
8
- showDelay = 300
9
- } = _ref;
1
+ import * as React from "react";
2
+ import { useCallback, useRef } from "react";
3
+ const useHoverHandlersDelay = ({
4
+ onMouseOver,
5
+ onMouseLeave,
6
+ hideDelay = 300,
7
+ showDelay = 300
8
+ }) => {
10
9
  const hideTimer = useRef();
11
10
  const showTimer = useRef();
12
11
  const delayedHide = useCallback(() => {
@@ -21,6 +20,10 @@ function useHoverHandlersDelay(_ref) {
21
20
  onMouseOver: delayedShow,
22
21
  onMouseLeave: delayedHide
23
22
  };
24
- }
25
-
26
- export { useHoverHandlersDelay as default };
23
+ };
24
+ var useHoverHandlersDelay_default = useHoverHandlersDelay;
25
+ export {
26
+ useHoverHandlersDelay_default as default,
27
+ useHoverHandlersDelay
28
+ };
29
+ //# sourceMappingURL=useHoverHandlersDelay.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useHoverHandlersDelay.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
5
+ "mappings": "AAAA;ACAA;AAEO,MAAM,wBAAwB,CAAC;AAAA,EACpC;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,YAAY;AAAA,MACR;AACJ,QAAM,YAAY;AAClB,QAAM,YAAY;AAElB,QAAM,cAAc,YAAY,MAAM;AACpC,iBAAa,UAAU;AACvB,cAAU,UAAU,WAAW,cAAc;AAAA,KAC5C;AAEH,QAAM,cAAc,YAAY,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,29 @@
1
+ import * as React from "react";
2
+ import { useEffect, useState, useMemo } from "react";
3
+ const useIsShowingEllipsis = () => {
4
+ const [element, setElement] = useState();
5
+ const [isShowingEllipsis, setIsShowingEllipsis] = useState(false);
6
+ const resizeObserver = useMemo(() => new ResizeObserver((entries) => {
7
+ if (entries.length) {
8
+ const [textWrapperEntry] = entries;
9
+ const el = textWrapperEntry.target;
10
+ setIsShowingEllipsis(el?.scrollWidth > el?.clientWidth);
11
+ }
12
+ }), []);
13
+ useEffect(() => {
14
+ if (element) {
15
+ setIsShowingEllipsis(element.scrollWidth > element.clientWidth);
16
+ resizeObserver.observe(element);
17
+ }
18
+ return () => {
19
+ if (element) {
20
+ resizeObserver.unobserve(element);
21
+ }
22
+ };
23
+ }, [resizeObserver, element]);
24
+ return { setElement, isShowingEllipsis };
25
+ };
26
+ export {
27
+ useIsShowingEllipsis
28
+ };
29
+ //# sourceMappingURL=useIsShowingEllipsis.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useIsShowingEllipsis.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
5
+ "mappings": "AAAA;ACAA;AAEO,MAAM,uBAAuB,MAA+C;AACjF,QAAM,CAAC,SAAS,cAAc;AAE9B,QAAM,CAAC,mBAAmB,wBAAwB,SAAS;AAE3D,QAAM,iBAAiB,QACrB,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,YAAU,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,27 +1,17 @@
1
- import 'core-js/modules/web.dom-collections.iterator.js';
2
- import { useState, useRef, useEffect, useMemo } from 'react';
3
-
4
- // Taken and modified from https://stackoverflow.com/a/60218754
5
-
6
- const useOnElementResize = targetRef => {
7
- var _targetRef$current, _targetRef$current2;
8
-
9
- const [width, setWidth] = useState(targetRef.current ? (_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : _targetRef$current.offsetWidth : 0);
10
- const [height, setHeight] = useState(targetRef.current ? (_targetRef$current2 = targetRef.current) === null || _targetRef$current2 === void 0 ? void 0 : _targetRef$current2.offsetWidth : 0);
1
+ import * as React from "react";
2
+ import { useState, useEffect, useRef, useMemo } from "react";
3
+ const useOnElementResize = (targetRef) => {
4
+ const [width, setWidth] = useState(targetRef.current ? targetRef.current?.offsetWidth : 0);
5
+ const [height, setHeight] = useState(targetRef.current ? targetRef.current?.offsetWidth : 0);
11
6
  const observer = useRef(null);
12
7
  useEffect(() => {
13
8
  function outputsize() {
14
- var _targetRef$current3, _targetRef$current4;
15
-
16
- setWidth((_targetRef$current3 = targetRef.current) === null || _targetRef$current3 === void 0 ? void 0 : _targetRef$current3.offsetWidth);
17
- setHeight((_targetRef$current4 = targetRef.current) === null || _targetRef$current4 === void 0 ? void 0 : _targetRef$current4.offsetHeight);
9
+ setWidth(targetRef.current?.offsetWidth);
10
+ setHeight(targetRef.current?.offsetHeight);
18
11
  }
19
-
20
12
  observer.current = new ResizeObserver(outputsize).observe(targetRef.current);
21
13
  return () => {
22
- var _observer$current;
23
-
24
- (_observer$current = observer.current) === null || _observer$current === void 0 ? void 0 : _observer$current.disconnect();
14
+ observer.current?.disconnect();
25
15
  };
26
16
  }, [targetRef]);
27
17
  return useMemo(() => ({
@@ -29,5 +19,7 @@ const useOnElementResize = targetRef => {
29
19
  height
30
20
  }), [width, height]);
31
21
  };
32
-
33
- export { useOnElementResize };
22
+ export {
23
+ useOnElementResize
24
+ };
25
+ //# sourceMappingURL=useOnElementResize.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useOnElementResize.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
5
+ "mappings": "AAAA;ACAA;AAIO,MAAM,qBAAqB,CAAC,cAAmF;AACpH,QAAM,CAAC,OAAO,YAAY,SAAS,UAAU,UAAU,UAAU,SAAS,cAAc;AACxF,QAAM,CAAC,QAAQ,aAAa,SAAS,UAAU,UAAU,UAAU,SAAS,cAAc;AAC1F,QAAM,WAAW,OAAO;AAExB,YAAU,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,QACL,MAAO;AAAA,IACL;AAAA,IACA;AAAA,MAEF,CAAC,OAAO;AAAA;",
6
+ "names": []
7
+ }
@@ -1,12 +1,14 @@
1
- import 'core-js/modules/web.dom-collections.iterator.js';
2
- import { useState, useEffect } from 'react';
3
-
4
- const useParentElement = ref => {
1
+ import * as React from "react";
2
+ import { useEffect, useState } from "react";
3
+ const useParentElement = (ref) => {
5
4
  const [parent, setParent] = useState(ref.current);
6
5
  useEffect(() => {
7
- if (ref.current) setParent(ref.current.parentNode);
6
+ if (ref.current)
7
+ setParent(ref.current.parentNode);
8
8
  });
9
9
  return parent;
10
10
  };
11
-
12
- export { useParentElement };
11
+ export {
12
+ useParentElement
13
+ };
14
+ //# sourceMappingURL=useParentElement.js.map