@elliemae/ds-utilities 2.3.0-next.3 → 3.0.0-alpha.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.
Files changed (215) hide show
  1. package/dist/cjs/capitalize.js +35 -0
  2. package/dist/cjs/capitalize.js.map +7 -0
  3. package/dist/cjs/compose.js +45 -0
  4. package/dist/cjs/compose.js.map +7 -0
  5. package/dist/cjs/getComponentFromProps.js +48 -0
  6. package/dist/cjs/getComponentFromProps.js.map +7 -0
  7. package/dist/cjs/hooks/index.js +71 -0
  8. package/dist/cjs/hooks/index.js.map +7 -0
  9. package/dist/cjs/hooks/useCancellableDelayedCallback.js +51 -0
  10. package/dist/cjs/hooks/useCancellableDelayedCallback.js.map +7 -0
  11. package/dist/cjs/hooks/useDerivedStateFromProps.js +67 -0
  12. package/dist/cjs/hooks/useDerivedStateFromProps.js.map +7 -0
  13. package/dist/cjs/hooks/useExecutionTimer.js +50 -0
  14. package/dist/cjs/hooks/useExecutionTimer.js.map +7 -0
  15. package/dist/cjs/hooks/useExpandState.js +120 -0
  16. package/dist/cjs/hooks/useExpandState.js.map +7 -0
  17. package/dist/cjs/hooks/useHotkeys.js +45 -0
  18. package/dist/cjs/hooks/useHotkeys.js.map +7 -0
  19. package/dist/cjs/hooks/useHoverHandlersDelay.js +58 -0
  20. package/dist/cjs/hooks/useHoverHandlersDelay.js.map +7 -0
  21. package/dist/cjs/hooks/useIsShowingEllipsis.js +58 -0
  22. package/dist/cjs/hooks/useIsShowingEllipsis.js.map +7 -0
  23. package/dist/cjs/hooks/useOnElementResize.js +54 -0
  24. package/dist/cjs/hooks/useOnElementResize.js.map +7 -0
  25. package/dist/cjs/hooks/useParentElement.js +43 -0
  26. package/dist/cjs/hooks/useParentElement.js.map +7 -0
  27. package/dist/cjs/hooks/usePrevious.js +44 -0
  28. package/dist/cjs/hooks/usePrevious.js.map +7 -0
  29. package/dist/cjs/hooks/useResizeObserver.js +60 -0
  30. package/dist/cjs/hooks/useResizeObserver.js.map +7 -0
  31. package/dist/cjs/hooks/useSetRef.js +42 -0
  32. package/dist/cjs/hooks/useSetRef.js.map +7 -0
  33. package/dist/cjs/hooks/useShouldRecalculate.js +44 -0
  34. package/dist/cjs/hooks/useShouldRecalculate.js.map +7 -0
  35. package/dist/cjs/hooks/useWindowScrollerList.js +83 -0
  36. package/dist/cjs/hooks/useWindowScrollerList.js.map +7 -0
  37. package/dist/cjs/hooks/useWindowSize.js +57 -0
  38. package/dist/cjs/hooks/useWindowSize.js.map +7 -0
  39. package/dist/cjs/index.js +146 -0
  40. package/dist/cjs/index.js.map +7 -0
  41. package/dist/cjs/onClickHandlerForNonInteractiveElements.js +49 -0
  42. package/dist/cjs/onClickHandlerForNonInteractiveElements.js.map +7 -0
  43. package/dist/cjs/operators.js +68 -0
  44. package/dist/cjs/operators.js.map +7 -0
  45. package/dist/cjs/platform.js +37 -0
  46. package/dist/cjs/platform.js.map +7 -0
  47. package/dist/cjs/reactTypesUtility.js +58 -0
  48. package/dist/cjs/reactTypesUtility.js.map +7 -0
  49. package/dist/cjs/scrollingTimer.js +46 -0
  50. package/dist/cjs/scrollingTimer.js.map +7 -0
  51. package/dist/cjs/system.js +60 -0
  52. package/dist/cjs/system.js.map +7 -0
  53. package/dist/cjs/timeUtils.js +43 -0
  54. package/dist/cjs/timeUtils.js.map +7 -0
  55. package/dist/cjs/utils.js +127 -0
  56. package/dist/cjs/utils.js.map +7 -0
  57. package/dist/cjs/validations.js +57 -0
  58. package/dist/cjs/validations.js.map +7 -0
  59. package/dist/esm/capitalize.js +6 -0
  60. package/dist/esm/capitalize.js.map +7 -0
  61. package/dist/esm/compose.js +16 -0
  62. package/dist/esm/compose.js.map +7 -0
  63. package/dist/esm/getComponentFromProps.js +19 -0
  64. package/dist/esm/getComponentFromProps.js.map +7 -0
  65. package/dist/esm/hooks/index.js +42 -0
  66. package/dist/esm/hooks/index.js.map +7 -0
  67. package/dist/esm/hooks/useCancellableDelayedCallback.js +22 -0
  68. package/dist/esm/hooks/useCancellableDelayedCallback.js.map +7 -0
  69. package/dist/esm/hooks/useDerivedStateFromProps.js +38 -0
  70. package/dist/esm/hooks/useDerivedStateFromProps.js.map +7 -0
  71. package/dist/esm/hooks/useExecutionTimer.js +21 -0
  72. package/dist/esm/hooks/useExecutionTimer.js.map +7 -0
  73. package/dist/esm/hooks/useExpandState.js +91 -0
  74. package/dist/esm/hooks/useExpandState.js.map +7 -0
  75. package/dist/esm/hooks/useHotkeys.js +16 -0
  76. package/dist/esm/hooks/useHotkeys.js.map +7 -0
  77. package/{esm → dist/esm}/hooks/useHoverHandlersDelay.js +15 -12
  78. package/dist/esm/hooks/useHoverHandlersDelay.js.map +7 -0
  79. package/{esm → dist/esm}/hooks/useIsShowingEllipsis.js +9 -12
  80. package/dist/esm/hooks/useIsShowingEllipsis.js.map +7 -0
  81. package/dist/esm/hooks/useOnElementResize.js +25 -0
  82. package/dist/esm/hooks/useOnElementResize.js.map +7 -0
  83. package/dist/esm/hooks/useParentElement.js +14 -0
  84. package/dist/esm/hooks/useParentElement.js.map +7 -0
  85. package/dist/esm/hooks/usePrevious.js +15 -0
  86. package/dist/esm/hooks/usePrevious.js.map +7 -0
  87. package/dist/esm/hooks/useResizeObserver.js +31 -0
  88. package/dist/esm/hooks/useResizeObserver.js.map +7 -0
  89. package/dist/esm/hooks/useSetRef.js +13 -0
  90. package/dist/esm/hooks/useSetRef.js.map +7 -0
  91. package/dist/esm/hooks/useShouldRecalculate.js +15 -0
  92. package/dist/esm/hooks/useShouldRecalculate.js.map +7 -0
  93. package/{esm → dist/esm}/hooks/useWindowScrollerList.js +20 -29
  94. package/dist/esm/hooks/useWindowScrollerList.js.map +7 -0
  95. package/dist/esm/hooks/useWindowSize.js +28 -0
  96. package/dist/esm/hooks/useWindowSize.js.map +7 -0
  97. package/dist/esm/index.js +206 -0
  98. package/dist/esm/index.js.map +7 -0
  99. package/dist/esm/onClickHandlerForNonInteractiveElements.js +20 -0
  100. package/dist/esm/onClickHandlerForNonInteractiveElements.js.map +7 -0
  101. package/dist/esm/operators.js +39 -0
  102. package/dist/esm/operators.js.map +7 -0
  103. package/dist/esm/platform.js +8 -0
  104. package/dist/esm/platform.js.map +7 -0
  105. package/dist/esm/reactTypesUtility.js +29 -0
  106. package/dist/esm/reactTypesUtility.js.map +7 -0
  107. package/dist/esm/scrollingTimer.js +17 -0
  108. package/dist/esm/scrollingTimer.js.map +7 -0
  109. package/dist/esm/system.js +31 -0
  110. package/dist/esm/system.js.map +7 -0
  111. package/dist/esm/timeUtils.js +14 -0
  112. package/dist/esm/timeUtils.js.map +7 -0
  113. package/dist/esm/utils.js +136 -0
  114. package/dist/esm/utils.js.map +7 -0
  115. package/dist/esm/validations.js +28 -0
  116. package/dist/esm/validations.js.map +7 -0
  117. package/{types → dist/types}/capitalize.d.ts +0 -0
  118. package/{types → dist/types}/compose.d.ts +2 -1
  119. package/dist/types/getComponentFromProps.d.ts +3 -0
  120. package/dist/types/hooks/index.d.ts +19 -0
  121. package/dist/types/hooks/useCancellableDelayedCallback.d.ts +2 -0
  122. package/dist/types/hooks/useDerivedStateFromProps.d.ts +2 -0
  123. package/dist/types/hooks/useExecutionTimer.d.ts +2 -0
  124. package/{types → dist/types}/hooks/useExpandState.d.ts +3 -2
  125. package/dist/types/hooks/useHotkeys.d.ts +6 -0
  126. package/{types → dist/types}/hooks/useHoverHandlersDelay.d.ts +3 -2
  127. package/{types → dist/types}/hooks/useIsShowingEllipsis.d.ts +0 -0
  128. package/dist/types/hooks/useOnElementResize.d.ts +2 -0
  129. package/{types → dist/types}/hooks/useParentElement.d.ts +0 -0
  130. package/dist/types/hooks/usePrevious.d.ts +2 -0
  131. package/dist/types/hooks/useResizeObserver.d.ts +3 -0
  132. package/{types → dist/types}/hooks/useSetRef.d.ts +0 -0
  133. package/dist/types/hooks/useShouldRecalculate.d.ts +2 -0
  134. package/dist/types/hooks/useWindowScrollerList.d.ts +5 -0
  135. package/dist/types/hooks/useWindowSize.d.ts +2 -0
  136. package/dist/types/index.d.ts +13 -0
  137. package/{types → dist/types}/onClickHandlerForNonInteractiveElements.d.ts +7 -7
  138. package/{types → dist/types}/operators.d.ts +0 -0
  139. package/{types → dist/types}/platform.d.ts +0 -0
  140. package/{types → dist/types}/reactTypesUtility.d.ts +0 -0
  141. package/dist/types/scrollingTimer.d.ts +1 -0
  142. package/{types → dist/types}/system.d.ts +0 -0
  143. package/{types → dist/types}/timeUtils.d.ts +0 -0
  144. package/{types → dist/types}/utils.d.ts +0 -0
  145. package/{types → dist/types}/validations.d.ts +0 -0
  146. package/package.json +79 -71
  147. package/cjs/capitalize.js +0 -7
  148. package/cjs/compose.js +0 -38
  149. package/cjs/getComponentFromProps.js +0 -30
  150. package/cjs/hooks/index.js +0 -63
  151. package/cjs/hooks/useCancellableDelayedCallback.js +0 -26
  152. package/cjs/hooks/useDerivedStateFromProps.js +0 -56
  153. package/cjs/hooks/useExecutionTimer.js +0 -31
  154. package/cjs/hooks/useExpandState.js +0 -133
  155. package/cjs/hooks/useHotkeys.js +0 -25
  156. package/cjs/hooks/useHoverHandlersDelay.js +0 -28
  157. package/cjs/hooks/useIsShowingEllipsis.js +0 -36
  158. package/cjs/hooks/useOnElementResize.js +0 -38
  159. package/cjs/hooks/useParentElement.js +0 -16
  160. package/cjs/hooks/usePrevious.js +0 -13
  161. package/cjs/hooks/useResizeObserver.js +0 -33
  162. package/cjs/hooks/useSetRef.js +0 -15
  163. package/cjs/hooks/useShouldRecalculate.js +0 -17
  164. package/cjs/hooks/useWindowScrollerList.js +0 -65
  165. package/cjs/hooks/useWindowSize.js +0 -27
  166. package/cjs/index.js +0 -268
  167. package/cjs/onClickHandlerForNonInteractiveElements.js +0 -22
  168. package/cjs/operators.js +0 -63
  169. package/cjs/platform.js +0 -9
  170. package/cjs/reactTypesUtility.js +0 -35
  171. package/cjs/scrollingTimer.js +0 -24
  172. package/cjs/system.js +0 -43
  173. package/cjs/timeUtils.js +0 -25
  174. package/cjs/utils.js +0 -263
  175. package/cjs/validations.js +0 -44
  176. package/esm/capitalize.js +0 -3
  177. package/esm/compose.js +0 -34
  178. package/esm/getComponentFromProps.js +0 -23
  179. package/esm/hooks/index.js +0 -19
  180. package/esm/hooks/useCancellableDelayedCallback.js +0 -24
  181. package/esm/hooks/useDerivedStateFromProps.js +0 -54
  182. package/esm/hooks/useExecutionTimer.js +0 -29
  183. package/esm/hooks/useExpandState.js +0 -127
  184. package/esm/hooks/useHotkeys.js +0 -19
  185. package/esm/hooks/useOnElementResize.js +0 -34
  186. package/esm/hooks/useParentElement.js +0 -12
  187. package/esm/hooks/usePrevious.js +0 -11
  188. package/esm/hooks/useResizeObserver.js +0 -26
  189. package/esm/hooks/useSetRef.js +0 -11
  190. package/esm/hooks/useShouldRecalculate.js +0 -15
  191. package/esm/hooks/useWindowSize.js +0 -25
  192. package/esm/index.js +0 -32
  193. package/esm/onClickHandlerForNonInteractiveElements.js +0 -20
  194. package/esm/operators.js +0 -46
  195. package/esm/platform.js +0 -4
  196. package/esm/reactTypesUtility.js +0 -22
  197. package/esm/scrollingTimer.js +0 -20
  198. package/esm/system.js +0 -37
  199. package/esm/timeUtils.js +0 -20
  200. package/esm/utils.js +0 -99
  201. package/esm/validations.js +0 -38
  202. package/types/getComponentFromProps.d.ts +0 -2
  203. package/types/hooks/index.d.ts +0 -19
  204. package/types/hooks/useCancellableDelayedCallback.d.ts +0 -1
  205. package/types/hooks/useDerivedStateFromProps.d.ts +0 -1
  206. package/types/hooks/useExecutionTimer.d.ts +0 -1
  207. package/types/hooks/useHotkeys.d.ts +0 -5
  208. package/types/hooks/useOnElementResize.d.ts +0 -2
  209. package/types/hooks/usePrevious.d.ts +0 -2
  210. package/types/hooks/useResizeObserver.d.ts +0 -2
  211. package/types/hooks/useShouldRecalculate.d.ts +0 -1
  212. package/types/hooks/useWindowScrollerList.d.ts +0 -4
  213. package/types/hooks/useWindowSize.d.ts +0 -1
  214. package/types/index.d.ts +0 -13
  215. package/types/scrollingTimer.d.ts +0 -1
@@ -1,127 +0,0 @@
1
- import 'core-js/modules/esnext.async-iterator.filter.js';
2
- import 'core-js/modules/esnext.iterator.filter.js';
3
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
4
- import 'core-js/modules/web.dom-collections.iterator.js';
5
- import 'core-js/modules/esnext.async-iterator.for-each.js';
6
- import 'core-js/modules/esnext.iterator.constructor.js';
7
- import 'core-js/modules/esnext.iterator.for-each.js';
8
- import { useMemo } from 'react';
9
- import 'core-js/modules/esnext.async-iterator.reduce.js';
10
- import 'core-js/modules/esnext.iterator.reduce.js';
11
- import { isFunction } from 'lodash';
12
- import useDerivedStateFromProp from './useDerivedStateFromProps.js';
13
-
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
-
18
- const toggleStateInObject = (obj, key, value) => {
19
- const nextObj = _objectSpread({}, obj);
20
-
21
- if (nextObj[key]) {
22
- delete nextObj[key];
23
- } else {
24
- nextObj[key] = value;
25
- }
26
-
27
- return nextObj;
28
- };
29
-
30
- const noop = () => null;
31
-
32
- function useExpandState(_ref) {
33
- let {
34
- items = [],
35
- itemKey = 'id',
36
- expanded: expandedProp = {},
37
- onExpand,
38
- onExpandChange = noop,
39
- onExpandAll = noop,
40
- onToggleExpand,
41
- onCollapse
42
- } = _ref;
43
- const [expanded, setExpanded] = useDerivedStateFromProp(expandedProp);
44
- const isExpandedAll = useMemo(() => Object.keys(expanded).length === items.length, [expanded, items]);
45
-
46
- const toggleExpandAll = function () {
47
- let stateData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
48
- setExpanded(() => {
49
- const nextState = {};
50
-
51
- if (!isExpandedAll) {
52
- items.forEach(item => {
53
- nextState[item[itemKey]] = stateData;
54
- });
55
- }
56
-
57
- onExpandChange(nextState);
58
- onExpandAll(nextState);
59
- return nextState;
60
- });
61
- };
62
-
63
- const expand = function (item) {
64
- let stateData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
65
- if (!item) return;
66
-
67
- if (isFunction(onExpand)) {
68
- onExpand(item);
69
- }
70
-
71
- setExpanded(prevState => {
72
- const key = item[itemKey];
73
-
74
- const nextState = _objectSpread(_objectSpread({}, prevState), {}, {
75
- [key]: stateData
76
- });
77
-
78
- onExpandChange(nextState, item);
79
- return nextState;
80
- });
81
- };
82
-
83
- const toggleExpand = function (item) {
84
- let stateData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
85
-
86
- if (isFunction(onToggleExpand)) {
87
- onToggleExpand(item);
88
- }
89
-
90
- setExpanded(prevState => {
91
- const key = item[itemKey];
92
- const nextState = toggleStateInObject(prevState, key, stateData);
93
- onExpandChange(nextState, item);
94
- return nextState;
95
- });
96
- };
97
-
98
- const collapse = item => {
99
- if (isFunction(onCollapse)) {
100
- onCollapse(item);
101
- }
102
-
103
- setExpanded(prevState => {
104
- const nextState = _objectSpread({}, prevState);
105
-
106
- delete nextState[item[itemKey]];
107
- onExpandChange(nextState, item);
108
- return nextState;
109
- });
110
- };
111
-
112
- return {
113
- state: {
114
- expanded,
115
- isExpandedAll
116
- },
117
- actions: {
118
- expand,
119
- toggleExpandAll,
120
- toggleExpand,
121
- collapse
122
- },
123
- setExpanded
124
- };
125
- }
126
-
127
- export { useExpandState as default };
@@ -1,19 +0,0 @@
1
- import 'core-js/modules/web.dom-collections.iterator.js';
2
- import hotkeys from 'hotkeys-js';
3
- import { useCallback, useEffect } from 'react';
4
-
5
- function useHotkeys(_ref) {
6
- let {
7
- keys,
8
- handler,
9
- options = {}
10
- } = _ref;
11
- let deps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
12
- const memoizedCallback = useCallback(handler, deps);
13
- useEffect(() => {
14
- hotkeys(keys, options, memoizedCallback);
15
- return () => hotkeys.unbind(keys);
16
- }, [memoizedCallback]);
17
- }
18
-
19
- export { useHotkeys as default };
@@ -1,34 +0,0 @@
1
- import 'core-js/modules/web.dom-collections.iterator.js';
2
- import { useState, useRef, useEffect, useMemo } from 'react';
3
-
4
- // Taken and modified from https://stackoverflow.com/a/60218754
5
-
6
- const useOnElementResize = targetRef => {
7
- var _targetRef$current$of, _targetRef$current, _targetRef$current$of2, _targetRef$current2;
8
-
9
- const [width, setWidth] = useState((_targetRef$current$of = (_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : _targetRef$current.offsetWidth) !== null && _targetRef$current$of !== void 0 ? _targetRef$current$of : 0);
10
- const [height, setHeight] = useState((_targetRef$current$of2 = (_targetRef$current2 = targetRef.current) === null || _targetRef$current2 === void 0 ? void 0 : _targetRef$current2.offsetHeight) !== null && _targetRef$current$of2 !== void 0 ? _targetRef$current$of2 : 0);
11
- const observer = useRef();
12
- useEffect(() => {
13
- function outputsize() {
14
- var _targetRef$current$of3, _targetRef$current3, _targetRef$current$of4, _targetRef$current4;
15
-
16
- setWidth((_targetRef$current$of3 = (_targetRef$current3 = targetRef.current) === null || _targetRef$current3 === void 0 ? void 0 : _targetRef$current3.offsetWidth) !== null && _targetRef$current$of3 !== void 0 ? _targetRef$current$of3 : 0);
17
- setHeight((_targetRef$current$of4 = (_targetRef$current4 = targetRef.current) === null || _targetRef$current4 === void 0 ? void 0 : _targetRef$current4.offsetHeight) !== null && _targetRef$current$of4 !== void 0 ? _targetRef$current$of4 : 0);
18
- }
19
-
20
- observer.current = new ResizeObserver(outputsize);
21
- observer.current.observe(targetRef.current);
22
- return () => {
23
- var _observer$current;
24
-
25
- (_observer$current = observer.current) === null || _observer$current === void 0 ? void 0 : _observer$current.disconnect();
26
- };
27
- }, [targetRef]);
28
- return useMemo(() => ({
29
- width,
30
- height
31
- }), [width, height]);
32
- };
33
-
34
- export { useOnElementResize };
@@ -1,12 +0,0 @@
1
- import 'core-js/modules/web.dom-collections.iterator.js';
2
- import { useState, useEffect } from 'react';
3
-
4
- const useParentElement = ref => {
5
- const [parent, setParent] = useState(ref.current);
6
- useEffect(() => {
7
- if (ref.current) setParent(ref.current.parentNode);
8
- });
9
- return parent;
10
- };
11
-
12
- export { useParentElement };
@@ -1,11 +0,0 @@
1
- import { useRef, useEffect } from 'react';
2
-
3
- function usePrevious(value) {
4
- const ref = useRef();
5
- useEffect(() => {
6
- ref.current = value;
7
- }, [value]);
8
- return ref.current;
9
- }
10
-
11
- export { usePrevious as default };
@@ -1,26 +0,0 @@
1
- import 'core-js/modules/web.dom-collections.iterator.js';
2
- import { useState, useEffect } from 'react';
3
- import raf from 'raf';
4
- import ResizeObserver from 'resize-observer-polyfill';
5
-
6
- function useResizeObserver(handler, el) {
7
- const [node, setRef] = useState(el);
8
- const resizeObserver = new ResizeObserver(entries => {
9
- if (!Array.isArray(entries)) return;
10
- if (!entries.length) return;
11
- const entry = entries[0]; // execute on the next animation frame
12
-
13
- raf(() => handler({
14
- width: entry.target.offsetWidth,
15
- height: entry.target.offsetHeight
16
- }, entry.target));
17
- });
18
- const htmlEl = el || node;
19
- useEffect(() => {
20
- if (htmlEl) resizeObserver.observe(htmlEl);
21
- return () => htmlEl && resizeObserver.unobserve(htmlEl);
22
- }, [htmlEl]);
23
- return [setRef];
24
- }
25
-
26
- export { useResizeObserver as default };
@@ -1,11 +0,0 @@
1
- import { useRef, useCallback } from 'react';
2
-
3
- const useSetRef = initial => {
4
- const ref = useRef(initial);
5
- const setRef = useCallback(node => {
6
- ref.current = node;
7
- }, []);
8
- return [ref, setRef];
9
- };
10
-
11
- export { useSetRef };
@@ -1,15 +0,0 @@
1
- import { useRef } from 'react';
2
-
3
- function useShouldRecalculate(bool) {
4
- const prevValueRef = useRef(0);
5
-
6
- if (!bool) {
7
- // If we need to recalculate, change the value we return
8
- prevValueRef.current += 1;
9
- } // else we return the same value as the previous render, which won't trigger a recalculation
10
-
11
-
12
- return prevValueRef.current;
13
- }
14
-
15
- export { useShouldRecalculate as default };
@@ -1,25 +0,0 @@
1
- import 'core-js/modules/web.dom-collections.iterator.js';
2
- import { useState, useLayoutEffect } from 'react';
3
-
4
- function useWindowSize() {
5
- const [size, setSize] = useState([0, 0]);
6
- useLayoutEffect(() => {
7
- if (!window) return false;
8
-
9
- function updateSize() {
10
- setSize([window.innerWidth, window.innerHeight]);
11
- }
12
-
13
- window.addEventListener('resize', updateSize);
14
- window.addEventListener('orientationchange', updateSize);
15
- updateSize();
16
- return () => {
17
- window.removeEventListener('resize', updateSize);
18
- window.removeEventListener('orientationchange', updateSize);
19
- };
20
- }, []);
21
- if (!window) return false;
22
- return size;
23
- }
24
-
25
- export { useWindowSize as default };
package/esm/index.js DELETED
@@ -1,32 +0,0 @@
1
- export { default as getComponentFromProps } from './getComponentFromProps.js';
2
- export { default as onClickHandlerForNonInteractiveElements } from './onClickHandlerForNonInteractiveElements.js';
3
- export { capitalize } from './capitalize.js';
4
- export { checkEmpty, checkNotEmpty, contains, equal, greaterThan, greaterThanOrEquals, isIn, isNotIn, isNotNull, isNull, lessThanOrEquals, notEqual, startsWith, validDate } from './operators.js';
5
- export { addOrRemove, arrayMove, cx, hashArray, removeUndefinedProperties, runAll, safeCall, toggleInArray, toggleInObject } from './utils.js';
6
- export { logger, mergeRefs, setRef } from './system.js';
7
- export { default as useMeasure } from 'use-measure';
8
- export { default as useExecutionTimer } from './hooks/useExecutionTimer.js';
9
- export { default as useExpandState } from './hooks/useExpandState.js';
10
- export { default as useHotkeys } from './hooks/useHotkeys.js';
11
- export { default as useHoverHandlersDelay } from './hooks/useHoverHandlersDelay.js';
12
- export { default as useResizeObserver } from './hooks/useResizeObserver.js';
13
- export { default as useShouldRecalculate } from './hooks/useShouldRecalculate.js';
14
- export { default as useWindowScrollerList } from './hooks/useWindowScrollerList.js';
15
- export { default as useWindowSize } from './hooks/useWindowSize.js';
16
- export { default as useForceUpdate } from 'use-force-update';
17
- export { default as useOnClickOutside } from 'use-onclickoutside';
18
- export { useUncontrolled } from 'uncontrollable';
19
- export { default as usePrevious } from './hooks/usePrevious.js';
20
- export { default as useCancellableDelayedCallback } from './hooks/useCancellableDelayedCallback.js';
21
- export { default as useDerivedStateFromProps } from './hooks/useDerivedStateFromProps.js';
22
- export { useSetRef } from './hooks/useSetRef.js';
23
- export { useParentElement } from './hooks/useParentElement.js';
24
- export { useOnElementResize } from './hooks/useOnElementResize.js';
25
- export { useIsShowingEllipsis } from './hooks/useIsShowingEllipsis.js';
26
- export { addLeadingZeros, getVisibleTimeByFormat } from './timeUtils.js';
27
- export { compose } from './compose.js';
28
- export { DOCUMENT, WINDOW } from './platform.js';
29
- export { isClassComponent, isCompositeTypeElement, isDOMTypeElement, isElement, isFunctionComponent, isReactComponent } from './reactTypesUtility.js';
30
- export { resetTimer } from './scrollingTimer.js';
31
- export { isGreaterThan, isRequired, isValidDate } from './validations.js';
32
- export { cloneDeep, curry, debounce, differenceBy, differenceWith, filter, findIndex, get, groupBy, isBoolean, isEmpty, isEqual, isEqualWith, isFunction, isNaN, isObject, isString, maxBy, meanBy, noop, omit, orderBy, padStart, parseInt, pick, pickBy, property, pull, range, set, sortBy, sumBy, throttle, transform, uniq, uniqBy, values } from 'lodash';
@@ -1,20 +0,0 @@
1
- /**
2
- * onClickHandler: callback
3
- *
4
- * @param onClickHandler
5
- */
6
- var onClickHandlerForNonInteractiveElements = (onClickHandler => ({
7
- role: 'button',
8
- tabIndex: '0',
9
- onClick: onClickHandler,
10
- onKeyPress: event => {
11
- event.stopPropagation();
12
- const {
13
- keycode,
14
- key
15
- } = event;
16
- if (key === 'Enter') onClickHandler(event);else if (keycode === 13) onClickHandler(event);
17
- }
18
- }));
19
-
20
- export { onClickHandlerForNonInteractiveElements as default };
package/esm/operators.js DELETED
@@ -1,46 +0,0 @@
1
- import 'core-js/modules/web.dom-collections.iterator.js';
2
- import 'core-js/modules/esnext.async-iterator.map.js';
3
- import 'core-js/modules/esnext.iterator.map.js';
4
- import { isEmpty } from 'lodash';
5
-
6
- /**
7
- * Check if the value is null undefined ''
8
- *
9
- * @param value
10
- */
11
-
12
- const checkNotEmpty = value => value === '' || value === undefined || value == [] || value === null || isEmpty(value);
13
- const checkEmpty = value => !isEmpty(value);
14
- /**
15
- * @param value: number
16
- * @param comparator: number
17
- * @param value
18
- * @param comparator
19
- */
20
-
21
- const greaterThan = (value, comparator) => value > comparator;
22
- /**
23
- * Check if a valid date with format MM/DD/YYYY
24
- *
25
- * @param {*} value: string
26
- * @param value
27
- */
28
-
29
- const validDate = value => {
30
- const dateValidationRegex = /^\d{1,2}\/\d{1,2}\/\d{4}$/;
31
- if (!dateValidationRegex.test(value)) return false;
32
- const [m, d, y] = value.split('/').map(n => Number(n));
33
- return m === Number(new Date(y, m - 1, d).getMonth()) + 1 && d === Number(new Date(y, m - 1, d).getDate());
34
- };
35
- const equal = (a, b) => a === b;
36
- const notEqual = (a, b) => !equal(a, b);
37
- const isNull = a => checkNotEmpty(a);
38
- const isNotNull = a => !isNull(a);
39
- const isIn = (a, b) => b.indexOf(a) > -1;
40
- const isNotIn = (a, b) => !isIn(a, b);
41
- const greaterThanOrEquals = (value, comparator) => value >= comparator;
42
- const lessThanOrEquals = (value, comparator) => value <= comparator;
43
- const startsWith = (value, comparator) => String(value).startsWith(comparator);
44
- const contains = (value, comparator) => String(value).includes(comparator);
45
-
46
- export { checkEmpty, checkNotEmpty, contains, equal, greaterThan, greaterThanOrEquals, isIn, isNotIn, isNotNull, isNull, lessThanOrEquals, notEqual, startsWith, validDate };
package/esm/platform.js DELETED
@@ -1,4 +0,0 @@
1
- const DOCUMENT = typeof document !== 'undefined' ? document : null;
2
- const WINDOW = typeof window !== 'undefined' ? window : null;
3
-
4
- export { DOCUMENT, WINDOW };
@@ -1,22 +0,0 @@
1
- import React from 'react';
2
-
3
- function isClassComponent(component) {
4
- return !!(typeof component === 'function' && !!component.prototype.isReactComponent);
5
- }
6
- function isFunctionComponent(component) {
7
- return typeof component === 'function' && String(component).includes('return React.createElement');
8
- }
9
- function isReactComponent(component) {
10
- return !!(isClassComponent(component) || isFunctionComponent(component));
11
- }
12
- function isElement(element) {
13
- return /*#__PURE__*/React.isValidElement(element);
14
- }
15
- function isDOMTypeElement(element) {
16
- return isElement(element) && typeof element.type === 'string';
17
- }
18
- function isCompositeTypeElement(element) {
19
- return isElement(element) && typeof element.type === 'function';
20
- }
21
-
22
- export { isClassComponent, isCompositeTypeElement, isDOMTypeElement, isElement, isFunctionComponent, isReactComponent };
@@ -1,20 +0,0 @@
1
- function resetTimer(func) {
2
- let timeout;
3
- return function () {
4
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5
- args[_key] = arguments[_key];
6
- }
7
-
8
- const context = this;
9
-
10
- const lastCall = () => {
11
- timeout = null;
12
- func.apply(context, args);
13
- };
14
-
15
- clearTimeout(timeout);
16
- timeout = setTimeout(lastCall, 300);
17
- };
18
- }
19
-
20
- export { resetTimer };
package/esm/system.js DELETED
@@ -1,37 +0,0 @@
1
- import 'core-js/modules/esnext.async-iterator.for-each.js';
2
- import 'core-js/modules/esnext.iterator.constructor.js';
3
- import 'core-js/modules/esnext.iterator.for-each.js';
4
- import 'core-js/modules/esnext.async-iterator.filter.js';
5
- import 'core-js/modules/esnext.iterator.filter.js';
6
- import '@babel/runtime/helpers/esm/defineProperty';
7
- import 'core-js/modules/esnext.async-iterator.reduce.js';
8
- import 'core-js/modules/esnext.iterator.reduce.js';
9
- import 'core-js/modules/web.dom-collections.iterator.js';
10
- import { isFunction } from 'lodash';
11
-
12
- const setRef = (ref, value) => {
13
- if (isFunction(ref)) {
14
- ref(value);
15
- } else if (ref) {
16
- ref.current = value;
17
- }
18
- };
19
- function mergeRefs() {
20
- for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
21
- refs[_key] = arguments[_key];
22
- }
23
-
24
- return node => {
25
- if (!node) return;
26
- refs.forEach(ref => {
27
- if (isFunction(ref)) {
28
- ref(node);
29
- } else if (ref) {
30
- ref.current = node;
31
- }
32
- });
33
- };
34
- }
35
- function logger() {}
36
-
37
- export { logger, mergeRefs, setRef };
package/esm/timeUtils.js DELETED
@@ -1,20 +0,0 @@
1
- import 'core-js/modules/esnext.async-iterator.filter.js';
2
- import 'core-js/modules/esnext.iterator.filter.js';
3
- import '@babel/runtime/helpers/esm/defineProperty';
4
- import 'core-js/modules/esnext.async-iterator.reduce.js';
5
- import 'core-js/modules/esnext.iterator.constructor.js';
6
- import 'core-js/modules/esnext.iterator.reduce.js';
7
- import 'core-js/modules/web.dom-collections.iterator.js';
8
- import 'core-js/modules/esnext.async-iterator.for-each.js';
9
- import 'core-js/modules/esnext.iterator.for-each.js';
10
- import { padStart } from 'lodash';
11
-
12
- const getVisibleTimeByFormat = format => ({
13
- showHours: format.indexOf('H') > -1 || format.indexOf('h') > -1 || format.indexOf('k') > -1,
14
- showMinutes: format.indexOf('m') > -1,
15
- showSeconds: format.indexOf('s') > -1,
16
- use12Hours: format.indexOf('A') > -1 || format.indexOf('h') > -1 || format.indexOf('a') > -1
17
- });
18
- const addLeadingZeros = count => number => padStart(String(number), count, '0');
19
-
20
- export { addLeadingZeros, getVisibleTimeByFormat };
package/esm/utils.js DELETED
@@ -1,99 +0,0 @@
1
- import 'core-js/modules/esnext.async-iterator.filter.js';
2
- import 'core-js/modules/esnext.iterator.filter.js';
3
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
4
- import 'core-js/modules/esnext.async-iterator.reduce.js';
5
- import 'core-js/modules/esnext.iterator.constructor.js';
6
- import 'core-js/modules/esnext.iterator.reduce.js';
7
- import 'core-js/modules/web.dom-collections.iterator.js';
8
- import 'core-js/modules/esnext.async-iterator.for-each.js';
9
- import 'core-js/modules/esnext.iterator.for-each.js';
10
- import { omit, cloneDeep, isFunction } from 'lodash';
11
- export { cloneDeep, curry, debounce, differenceBy, differenceWith, filter, findIndex, get, groupBy, isBoolean, isEmpty, isEqual, isEqualWith, isFunction, isNaN, isObject, isString, maxBy, meanBy, noop, omit, orderBy, padStart, parseInt, pick, pickBy, property, pull, range, set, sortBy, sumBy, throttle, transform, uniq, uniqBy, values } from 'lodash';
12
-
13
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
-
15
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16
- /**
17
- * Concatenates classNames from arguments
18
- *
19
- * @param {...any} classnames
20
- */
21
-
22
- const cx = function () {
23
- for (var _len = arguments.length, classnames = new Array(_len), _key = 0; _key < _len; _key++) {
24
- classnames[_key] = arguments[_key];
25
- }
26
-
27
- return classnames.reduce((result, cn) => "".concat(result, " ").concat(cn || ''), '');
28
- }; // if entry exists, remove it, if not, add it
29
-
30
- const toggleInObject = (obj, key, value) => obj[key] !== undefined ? omit(obj, [key]) : _objectSpread(_objectSpread({}, obj), {}, {
31
- [key]: value
32
- });
33
-
34
- const toggleInArray = (array, value) => array.indexOf(value) === -1 ? [value] : [];
35
-
36
- const arrayMoveMutate = (array, from, to) => {
37
- array.splice(to < 0 ? array.length + to : to, 0, array.splice(from, 1)[0]);
38
- };
39
-
40
- const arrayMove = (array, from, to) => {
41
- array = array.slice();
42
- arrayMoveMutate(array, from, to);
43
- return array;
44
- };
45
-
46
- const accessorDefault = item => item;
47
-
48
- const addOrRemove = function (array, item) {
49
- let accessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : accessorDefault;
50
- const index = array.findIndex(iItem => accessor(iItem) === accessor(item));
51
-
52
- if (index !== -1) {
53
- const nextArray = cloneDeep(array);
54
- nextArray.splice(index, 1);
55
- return nextArray;
56
- }
57
-
58
- return [...array, item];
59
- };
60
-
61
- function runAll() {
62
- for (var _len2 = arguments.length, fns = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
63
- fns[_key2] = arguments[_key2];
64
- }
65
-
66
- return function () {
67
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
68
- args[_key3] = arguments[_key3];
69
- }
70
-
71
- return fns.forEach(fn => {
72
- if (Array.isArray(fn)) runAll(fn);
73
- if (isFunction(fn)) fn(...args);
74
- });
75
- };
76
- }
77
- function hashArray(arr, fieldName) {
78
- return arr.reduce((result, item) => _objectSpread(_objectSpread({}, result), {}, {
79
- [fieldName ? item[fieldName] : item]: true
80
- }), {});
81
- }
82
- function safeCall(fun) {
83
- if (isFunction(fun)) {
84
- for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
85
- args[_key4 - 1] = arguments[_key4];
86
- }
87
-
88
- fun(...args);
89
- }
90
- }
91
- const removeUndefinedProperties = obj => {
92
- const cleanObject = _objectSpread({}, obj);
93
-
94
- Object.keys(obj).forEach(key => cleanObject[key] === undefined && delete cleanObject[key]);
95
- return cleanObject;
96
- };
97
- var utils = {};
98
-
99
- export { addOrRemove, arrayMove, cx, utils as default, hashArray, removeUndefinedProperties, runAll, safeCall, toggleInArray, toggleInObject };
@@ -1,38 +0,0 @@
1
- import { checkNotEmpty, greaterThan, validDate } from './operators.js';
2
-
3
- const isRequired = _ref => {
4
- let {
5
- value,
6
- help = 'Field is Required'
7
- } = _ref;
8
- return {
9
- payload: help,
10
- error: checkNotEmpty(value)
11
- };
12
- };
13
- const isGreaterThan = _ref2 => {
14
- let {
15
- value,
16
- help,
17
- comparator = 0
18
- } = _ref2;
19
- if (!help) help = "Max value ".concat(comparator);
20
- return {
21
- payload: help,
22
- error: greaterThan(value, comparator)
23
- };
24
- };
25
- const isValidDate = _ref3 => {
26
- let {
27
- value,
28
- help,
29
- format = 'MM/DD/AAA'
30
- } = _ref3;
31
- if (!help) help = "Valid Date is required ".concat(format);
32
- return {
33
- payload: help,
34
- error: !validDate(value)
35
- };
36
- };
37
-
38
- export { isGreaterThan, isRequired, isValidDate };
@@ -1,2 +0,0 @@
1
- /// <reference types="react" />
2
- export default function getComponentFromProps(Component: any, props: any, children?: never[]): JSX.Element | null;
@@ -1,19 +0,0 @@
1
- export { default as useMeasure } from 'use-measure';
2
- export { default as useExecutionTimer } from './useExecutionTimer';
3
- export { default as useExpandState } from './useExpandState';
4
- export { default as useHotkeys } from './useHotkeys';
5
- export { default as useHoverHandlersDelay } from './useHoverHandlersDelay';
6
- export { default as useResizeObserver } from './useResizeObserver';
7
- export { default as useShouldRecalculate } from './useShouldRecalculate';
8
- export { default as useWindowScrollerList } from './useWindowScrollerList';
9
- export { default as useWindowSize } from './useWindowSize';
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';
14
- export { default as useCancellableDelayedCallback } from './useCancellableDelayedCallback';
15
- export { default as useDerivedStateFromProps } from './useDerivedStateFromProps';
16
- export * from './useSetRef';
17
- export * from './useParentElement';
18
- export * from './useOnElementResize';
19
- export * from './useIsShowingEllipsis';
@@ -1 +0,0 @@
1
- export default function useCancellableDelayedCallback(cb: any, delay: any): ((...args: any[]) => void)[];