@studiometa/js-toolkit 2.0.0-alpha.1 → 2.0.0-alpha.10

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 (201) hide show
  1. package/Base/index.d.ts +29 -47
  2. package/Base/index.js +144 -171
  3. package/Base/managers/ChildrenManager.d.ts +6 -6
  4. package/Base/managers/ChildrenManager.js +95 -119
  5. package/Base/managers/EventsManager.d.ts +9 -9
  6. package/Base/managers/EventsManager.js +128 -161
  7. package/Base/managers/OptionsManager.d.ts +50 -5
  8. package/Base/managers/OptionsManager.js +115 -116
  9. package/Base/managers/RefsManager.js +62 -73
  10. package/Base/managers/ServicesManager.d.ts +14 -3
  11. package/Base/managers/ServicesManager.js +78 -77
  12. package/Base/utils.js +5 -8
  13. package/README.md +12 -70
  14. package/decorators/index.js +1 -2
  15. package/decorators/withBreakpointManager.d.ts +4 -4
  16. package/decorators/withBreakpointManager.js +37 -75
  17. package/decorators/withBreakpointObserver.d.ts +2 -2
  18. package/decorators/withBreakpointObserver.js +54 -77
  19. package/decorators/withDrag.d.ts +3 -3
  20. package/decorators/withDrag.js +17 -41
  21. package/decorators/withExtraConfig.d.ts +3 -3
  22. package/decorators/withExtraConfig.js +2 -24
  23. package/decorators/withIntersectionObserver.d.ts +2 -2
  24. package/decorators/withIntersectionObserver.js +17 -56
  25. package/decorators/withMountWhenInView.d.ts +3 -3
  26. package/decorators/withMountWhenInView.js +23 -51
  27. package/helpers/createApp.d.ts +3 -3
  28. package/helpers/createApp.js +10 -12
  29. package/helpers/importOnInteraction.d.ts +3 -3
  30. package/helpers/importOnInteraction.js +7 -8
  31. package/helpers/importWhenIdle.d.ts +3 -3
  32. package/helpers/importWhenIdle.js +7 -8
  33. package/helpers/importWhenVisible.d.ts +3 -3
  34. package/helpers/importWhenVisible.js +9 -16
  35. package/helpers/index.d.ts +1 -3
  36. package/helpers/index.js +1 -4
  37. package/helpers/utils.js +1 -2
  38. package/index.d.ts +14 -4
  39. package/index.js +4 -4
  40. package/index.modern.js +1 -2
  41. package/index.umd.js +1 -2
  42. package/package.json +4 -6
  43. package/services/Service.js +48 -67
  44. package/services/drag.js +143 -179
  45. package/services/index.js +1 -2
  46. package/services/key.js +55 -97
  47. package/services/load.d.ts +1 -1
  48. package/services/load.js +21 -50
  49. package/services/pointer.js +117 -156
  50. package/services/raf.js +36 -64
  51. package/services/resize.js +47 -86
  52. package/services/scroll.js +81 -120
  53. package/utils/collide/boundingRectToCircle.js +7 -6
  54. package/utils/collide/collideCircleCircle.js +1 -2
  55. package/utils/collide/collideCircleRect.js +1 -2
  56. package/utils/collide/collidePointCircle.js +1 -2
  57. package/utils/collide/collidePointRect.js +1 -2
  58. package/utils/collide/collideRectRect.js +1 -2
  59. package/utils/collide/index.js +1 -2
  60. package/utils/css/classes.js +2 -3
  61. package/utils/css/index.js +1 -2
  62. package/utils/css/matrix.js +1 -2
  63. package/utils/css/styles.js +3 -8
  64. package/utils/css/transition.js +67 -140
  65. package/utils/debounce.js +3 -4
  66. package/utils/focusTrap.js +4 -5
  67. package/utils/history.js +13 -20
  68. package/utils/index.d.ts +2 -1
  69. package/utils/index.js +2 -2
  70. package/utils/keyCodes.js +1 -2
  71. package/utils/math/clamp.js +1 -2
  72. package/utils/math/clamp01.js +1 -2
  73. package/utils/math/damp.js +1 -2
  74. package/utils/math/index.js +1 -2
  75. package/utils/math/inertiaFinalValue.js +1 -2
  76. package/utils/math/lerp.js +1 -2
  77. package/utils/math/map.js +1 -2
  78. package/utils/math/round.js +1 -2
  79. package/utils/memoize.d.ts +30 -0
  80. package/utils/memoize.js +30 -0
  81. package/utils/nextFrame.js +4 -9
  82. package/utils/object/autoBind.js +11 -19
  83. package/utils/object/getAllProperties.js +3 -11
  84. package/utils/object/index.js +1 -2
  85. package/utils/object/isObject.js +2 -4
  86. package/utils/string/index.js +1 -2
  87. package/utils/string/withLeadingCharacters.js +1 -2
  88. package/utils/string/withLeadingSlash.js +1 -2
  89. package/utils/string/withTrailingCharacters.js +1 -2
  90. package/utils/string/withTrailingSlash.js +1 -2
  91. package/utils/string/withoutLeadingCharacters.js +1 -2
  92. package/utils/string/withoutLeadingCharactersRecursive.js +1 -2
  93. package/utils/string/withoutLeadingSlash.js +1 -2
  94. package/utils/string/withoutTrailingCharacters.js +1 -2
  95. package/utils/string/withoutTrailingCharactersRecursive.js +1 -2
  96. package/utils/string/withoutTrailingSlash.js +1 -2
  97. package/utils/throttle.js +2 -3
  98. package/Base/index.js.map +0 -1
  99. package/Base/managers/ChildrenManager.js.map +0 -1
  100. package/Base/managers/EventsManager.js.map +0 -1
  101. package/Base/managers/OptionsManager.js.map +0 -1
  102. package/Base/managers/RefsManager.js.map +0 -1
  103. package/Base/managers/ServicesManager.js.map +0 -1
  104. package/Base/utils.js.map +0 -1
  105. package/components/Accordion/Accordion.d.ts +0 -83
  106. package/components/Accordion/Accordion.js +0 -121
  107. package/components/Accordion/Accordion.js.map +0 -1
  108. package/components/Accordion/AccordionItem.d.ts +0 -122
  109. package/components/Accordion/AccordionItem.js +0 -327
  110. package/components/Accordion/AccordionItem.js.map +0 -1
  111. package/components/Accordion/index.d.ts +0 -27
  112. package/components/Accordion/index.js +0 -39
  113. package/components/Accordion/index.js.map +0 -1
  114. package/components/Cursor.d.ts +0 -138
  115. package/components/Cursor.js +0 -167
  116. package/components/Cursor.js.map +0 -1
  117. package/components/Draggable.d.ts +0 -49
  118. package/components/Draggable.js +0 -77
  119. package/components/Draggable.js.map +0 -1
  120. package/components/Modal.d.ts +0 -158
  121. package/components/Modal.js +0 -270
  122. package/components/Modal.js.map +0 -1
  123. package/components/Tabs.d.ts +0 -108
  124. package/components/Tabs.js +0 -195
  125. package/components/Tabs.js.map +0 -1
  126. package/components/index.d.ts +0 -6
  127. package/components/index.js +0 -7
  128. package/components/index.js.map +0 -1
  129. package/decorators/index.js.map +0 -1
  130. package/decorators/withBreakpointManager.js.map +0 -1
  131. package/decorators/withBreakpointObserver.js.map +0 -1
  132. package/decorators/withDrag.js.map +0 -1
  133. package/decorators/withExtraConfig.js.map +0 -1
  134. package/decorators/withIntersectionObserver.js.map +0 -1
  135. package/decorators/withMountWhenInView.js.map +0 -1
  136. package/helpers/createApp.js.map +0 -1
  137. package/helpers/createBase.d.ts +0 -7
  138. package/helpers/createBase.js +0 -7
  139. package/helpers/createBase.js.map +0 -1
  140. package/helpers/defineComponent.d.ts +0 -11
  141. package/helpers/defineComponent.js +0 -68
  142. package/helpers/defineComponent.js.map +0 -1
  143. package/helpers/importOnInteraction.js.map +0 -1
  144. package/helpers/importWhenIdle.js.map +0 -1
  145. package/helpers/importWhenVisible.js.map +0 -1
  146. package/helpers/index.js.map +0 -1
  147. package/helpers/utils.js.map +0 -1
  148. package/index.js.map +0 -1
  149. package/index.modern.js.map +0 -1
  150. package/index.umd.js.map +0 -1
  151. package/services/Service.js.map +0 -1
  152. package/services/drag.js.map +0 -1
  153. package/services/index.js.map +0 -1
  154. package/services/key.js.map +0 -1
  155. package/services/load.js.map +0 -1
  156. package/services/pointer.js.map +0 -1
  157. package/services/raf.js.map +0 -1
  158. package/services/resize.js.map +0 -1
  159. package/services/scroll.js.map +0 -1
  160. package/utils/collide/boundingRectToCircle.js.map +0 -1
  161. package/utils/collide/collideCircleCircle.js.map +0 -1
  162. package/utils/collide/collideCircleRect.js.map +0 -1
  163. package/utils/collide/collidePointCircle.js.map +0 -1
  164. package/utils/collide/collidePointRect.js.map +0 -1
  165. package/utils/collide/collideRectRect.js.map +0 -1
  166. package/utils/collide/index.js.map +0 -1
  167. package/utils/css/classes.js.map +0 -1
  168. package/utils/css/index.js.map +0 -1
  169. package/utils/css/matrix.js.map +0 -1
  170. package/utils/css/styles.js.map +0 -1
  171. package/utils/css/transition.js.map +0 -1
  172. package/utils/debounce.js.map +0 -1
  173. package/utils/focusTrap.js.map +0 -1
  174. package/utils/history.js.map +0 -1
  175. package/utils/index.js.map +0 -1
  176. package/utils/keyCodes.js.map +0 -1
  177. package/utils/math/clamp.js.map +0 -1
  178. package/utils/math/clamp01.js.map +0 -1
  179. package/utils/math/damp.js.map +0 -1
  180. package/utils/math/index.js.map +0 -1
  181. package/utils/math/inertiaFinalValue.js.map +0 -1
  182. package/utils/math/lerp.js.map +0 -1
  183. package/utils/math/map.js.map +0 -1
  184. package/utils/math/round.js.map +0 -1
  185. package/utils/nextFrame.js.map +0 -1
  186. package/utils/object/autoBind.js.map +0 -1
  187. package/utils/object/getAllProperties.js.map +0 -1
  188. package/utils/object/index.js.map +0 -1
  189. package/utils/object/isObject.js.map +0 -1
  190. package/utils/string/index.js.map +0 -1
  191. package/utils/string/withLeadingCharacters.js.map +0 -1
  192. package/utils/string/withLeadingSlash.js.map +0 -1
  193. package/utils/string/withTrailingCharacters.js.map +0 -1
  194. package/utils/string/withTrailingSlash.js.map +0 -1
  195. package/utils/string/withoutLeadingCharacters.js.map +0 -1
  196. package/utils/string/withoutLeadingCharactersRecursive.js.map +0 -1
  197. package/utils/string/withoutLeadingSlash.js.map +0 -1
  198. package/utils/string/withoutTrailingCharacters.js.map +0 -1
  199. package/utils/string/withoutTrailingCharactersRecursive.js.map +0 -1
  200. package/utils/string/withoutTrailingSlash.js.map +0 -1
  201. package/utils/throttle.js.map +0 -1
@@ -1,22 +1,17 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
3
 
6
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
7
5
 
8
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
9
7
 
10
- import _regeneratorRuntime from "@babel/runtime/regenerator";
11
8
  import nextFrame from '../nextFrame.js';
12
9
  import * as classes from './classes.js';
13
10
  import * as styles from './styles.js';
14
11
  var cache = new WeakMap();
15
12
 
16
- var Transition = function () {
17
- function Transition(element) {
18
- _classCallCheck(this, Transition);
19
-
13
+ class Transition {
14
+ constructor(element) {
20
15
  _defineProperty(this, "isTransitioning", false);
21
16
 
22
17
  _defineProperty(this, "transitionEndHandler", null);
@@ -24,21 +19,17 @@ var Transition = function () {
24
19
  cache.set(element, this);
25
20
  }
26
21
 
27
- _createClass(Transition, null, [{
28
- key: "getInstance",
29
- value: function getInstance(element) {
30
- var instance = cache.get(element);
31
-
32
- if (!instance) {
33
- instance = new this(element);
34
- }
22
+ static getInstance(element) {
23
+ var instance = cache.get(element);
35
24
 
36
- return instance;
25
+ if (!instance) {
26
+ instance = new this(element);
37
27
  }
38
- }]);
39
28
 
40
- return Transition;
41
- }();
29
+ return instance;
30
+ }
31
+
32
+ }
42
33
 
43
34
  export function setClassesOrStyles(element, classesOrStyles) {
44
35
  var method = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'add';
@@ -55,9 +46,9 @@ function testTransition(element) {
55
46
  return false;
56
47
  }
57
48
 
58
- var _window$getComputedSt = window.getComputedStyle(element),
59
- transitionDuration = _window$getComputedSt.transitionDuration;
60
-
49
+ var {
50
+ transitionDuration
51
+ } = window.getComputedStyle(element);
61
52
  return !!transitionDuration && transitionDuration !== '0s';
62
53
  }
63
54
 
@@ -66,30 +57,14 @@ function start(_x, _x2) {
66
57
  }
67
58
 
68
59
  function _start() {
69
- _start = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(element, classesOrStyles) {
70
- var trs;
71
- return _regeneratorRuntime.wrap(function _callee$(_context) {
72
- while (1) {
73
- switch (_context.prev = _context.next) {
74
- case 0:
75
- trs = Transition.getInstance(element);
76
- trs.isTransitioning = true;
77
- setClassesOrStyles(element, classesOrStyles.from);
78
- _context.next = 5;
79
- return nextFrame();
80
-
81
- case 5:
82
- setClassesOrStyles(element, classesOrStyles.active);
83
- _context.next = 8;
84
- return nextFrame();
85
-
86
- case 8:
87
- case "end":
88
- return _context.stop();
89
- }
90
- }
91
- }, _callee);
92
- }));
60
+ _start = _asyncToGenerator(function* (element, classesOrStyles) {
61
+ var trs = Transition.getInstance(element);
62
+ trs.isTransitioning = true;
63
+ setClassesOrStyles(element, classesOrStyles.from);
64
+ yield nextFrame();
65
+ setClassesOrStyles(element, classesOrStyles.active);
66
+ yield nextFrame();
67
+ });
93
68
  return _start.apply(this, arguments);
94
69
  }
95
70
 
@@ -98,56 +73,30 @@ function next(_x3, _x4) {
98
73
  }
99
74
 
100
75
  function _next() {
101
- _next = _asyncToGenerator(_regeneratorRuntime.mark(function _callee3(element, classesOrStyles) {
102
- var hasTransition;
103
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
104
- while (1) {
105
- switch (_context3.prev = _context3.next) {
106
- case 0:
107
- hasTransition = testTransition(element);
108
- return _context3.abrupt("return", new Promise(function () {
109
- var _ref = _asyncToGenerator(_regeneratorRuntime.mark(function _callee2(resolve) {
110
- var trs;
111
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
112
- while (1) {
113
- switch (_context2.prev = _context2.next) {
114
- case 0:
115
- if (hasTransition) {
116
- trs = Transition.getInstance(element);
117
- trs.transitionEndHandler = resolve;
118
- element.addEventListener('transitionend', trs.transitionEndHandler, false);
119
- }
120
-
121
- setClassesOrStyles(element, classesOrStyles.from, 'remove');
122
- setClassesOrStyles(element, classesOrStyles.to);
123
- _context2.next = 5;
124
- return nextFrame();
125
-
126
- case 5:
127
- if (!hasTransition) {
128
- resolve();
129
- }
130
-
131
- case 6:
132
- case "end":
133
- return _context2.stop();
134
- }
135
- }
136
- }, _callee2);
137
- }));
138
-
139
- return function (_x7) {
140
- return _ref.apply(this, arguments);
141
- };
142
- }()));
143
-
144
- case 2:
145
- case "end":
146
- return _context3.stop();
76
+ _next = _asyncToGenerator(function* (element, classesOrStyles) {
77
+ var hasTransition = testTransition(element);
78
+ return new Promise(function () {
79
+ var _ref = _asyncToGenerator(function* (resolve) {
80
+ if (hasTransition) {
81
+ var trs = Transition.getInstance(element);
82
+ trs.transitionEndHandler = resolve;
83
+ element.addEventListener('transitionend', trs.transitionEndHandler, false);
147
84
  }
148
- }
149
- }, _callee3);
150
- }));
85
+
86
+ setClassesOrStyles(element, classesOrStyles.from, 'remove');
87
+ setClassesOrStyles(element, classesOrStyles.to);
88
+ yield nextFrame();
89
+
90
+ if (!hasTransition) {
91
+ resolve();
92
+ }
93
+ });
94
+
95
+ return function (_x7) {
96
+ return _ref.apply(this, arguments);
97
+ };
98
+ }());
99
+ });
151
100
  return _next.apply(this, arguments);
152
101
  }
153
102
 
@@ -170,49 +119,27 @@ export default function transition(_x5, _x6) {
170
119
  }
171
120
 
172
121
  function _transition() {
173
- _transition = _asyncToGenerator(_regeneratorRuntime.mark(function _callee4(element, name) {
174
- var endMode,
175
- classesOrStyles,
176
- trs,
177
- _args4 = arguments;
178
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
179
- while (1) {
180
- switch (_context4.prev = _context4.next) {
181
- case 0:
182
- endMode = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : 'remove';
183
- classesOrStyles = typeof name === 'string' ? {
184
- from: "".concat(name, "-from"),
185
- active: "".concat(name, "-active"),
186
- to: "".concat(name, "-to")
187
- } : _objectSpread({
188
- from: '',
189
- active: '',
190
- to: ''
191
- }, name);
192
- trs = Transition.getInstance(element);
193
-
194
- if (trs.isTransitioning) {
195
- end(element, classesOrStyles);
196
- }
197
-
198
- _context4.next = 6;
199
- return start(element, classesOrStyles);
200
-
201
- case 6:
202
- _context4.next = 8;
203
- return next(element, classesOrStyles);
204
-
205
- case 8:
206
- end(element, classesOrStyles, endMode);
207
- return _context4.abrupt("return", Promise.resolve());
208
-
209
- case 10:
210
- case "end":
211
- return _context4.stop();
212
- }
213
- }
214
- }, _callee4);
215
- }));
122
+ _transition = _asyncToGenerator(function* (element, name) {
123
+ var endMode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'remove';
124
+ var classesOrStyles = typeof name === 'string' ? {
125
+ from: "".concat(name, "-from"),
126
+ active: "".concat(name, "-active"),
127
+ to: "".concat(name, "-to")
128
+ } : _objectSpread({
129
+ from: '',
130
+ active: '',
131
+ to: ''
132
+ }, name);
133
+ var trs = Transition.getInstance(element);
134
+
135
+ if (trs.isTransitioning) {
136
+ end(element, classesOrStyles);
137
+ }
138
+
139
+ yield start(element, classesOrStyles);
140
+ yield next(element, classesOrStyles);
141
+ end(element, classesOrStyles, endMode);
142
+ return Promise.resolve();
143
+ });
216
144
  return _transition.apply(this, arguments);
217
- }
218
- //# sourceMappingURL=transition.js.map
145
+ }
package/utils/debounce.js CHANGED
@@ -7,9 +7,8 @@ export default function debounce(fn) {
7
7
  }
8
8
 
9
9
  clearTimeout(timeout);
10
- timeout = setTimeout(function () {
11
- fn.apply(void 0, args);
10
+ timeout = setTimeout(() => {
11
+ fn(...args);
12
12
  }, delay);
13
13
  };
14
- }
15
- //# sourceMappingURL=debounce.js.map
14
+ }
@@ -41,9 +41,8 @@ export function untrap() {
41
41
  }
42
42
  export default function useFocusTrap() {
43
43
  return {
44
- trap: trap,
45
- untrap: untrap,
46
- saveActiveElement: saveActiveElement
44
+ trap,
45
+ untrap,
46
+ saveActiveElement
47
47
  };
48
- }
49
- //# sourceMappingURL=focusTrap.js.map
48
+ }
package/utils/history.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
2
 
4
3
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
5
4
 
@@ -17,7 +16,7 @@ function updateUrlSearchParam(params, name, value) {
17
16
  }
18
17
 
19
18
  if (Array.isArray(value)) {
20
- value.forEach(function (val, index) {
19
+ value.forEach((val, index) => {
21
20
  var arrayName = "".concat(name, "[").concat(index, "]");
22
21
  updateUrlSearchParam(params, arrayName, val);
23
22
  });
@@ -25,11 +24,8 @@ function updateUrlSearchParam(params, name, value) {
25
24
  }
26
25
 
27
26
  if (isObject(value)) {
28
- Object.entries(value).forEach(function (_ref) {
29
- var _ref2 = _slicedToArray(_ref, 2),
30
- key = _ref2[0],
31
- val = _ref2[1];
32
-
27
+ Object.entries(value).forEach(_ref => {
28
+ var [key, val] = _ref;
33
29
  var objectName = "".concat(name, "[").concat(key, "]");
34
30
  updateUrlSearchParam(params, objectName, val);
35
31
  });
@@ -41,12 +37,9 @@ function updateUrlSearchParam(params, name, value) {
41
37
  }
42
38
 
43
39
  export function objectToURLSearchParams(obj) {
44
- var defaultSearch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.location.search;
45
- return Object.entries(obj).reduce(function (urlSearchParams, _ref3) {
46
- var _ref4 = _slicedToArray(_ref3, 2),
47
- name = _ref4[0],
48
- value = _ref4[1];
49
-
40
+ var defaultSearch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : typeof window === 'undefined' ? '' : window.location.search;
41
+ return Object.entries(obj).reduce((urlSearchParams, _ref2) => {
42
+ var [name, value] = _ref2;
50
43
  return updateUrlSearchParam(urlSearchParams, name, value);
51
44
  }, new URLSearchParams(defaultSearch));
52
45
  }
@@ -59,14 +52,15 @@ function updateHistory(mode, options) {
59
52
  return;
60
53
  }
61
54
 
62
- var _path$search$hash$opt = _objectSpread({
55
+ var {
56
+ path,
57
+ search,
58
+ hash
59
+ } = _objectSpread({
63
60
  path: window.location.pathname,
64
61
  search: new URLSearchParams(window.location.search),
65
62
  hash: window.location.hash
66
- }, options),
67
- path = _path$search$hash$opt.path,
68
- search = _path$search$hash$opt.search,
69
- hash = _path$search$hash$opt.hash;
63
+ }, options);
70
64
 
71
65
  var url = path;
72
66
  var mergedSearch = search instanceof URLSearchParams ? search : objectToURLSearchParams(search);
@@ -92,5 +86,4 @@ export function push(options, data, title) {
92
86
  }
93
87
  export function replace(options, data, title) {
94
88
  updateHistory('replace', options, data, title);
95
- }
96
- //# sourceMappingURL=history.js.map
89
+ }
package/utils/index.d.ts CHANGED
@@ -5,8 +5,9 @@ import focusTrap from "./focusTrap.js";
5
5
  import * as history from "./history.js";
6
6
  import keyCodes from "./keyCodes.js";
7
7
  import * as math from "./math/index.js";
8
+ import memoize from "./memoize.js";
8
9
  import nextFrame from "./nextFrame.js";
9
10
  import * as object from "./object/index.js";
10
11
  import * as string from "./string/index.js";
11
12
  import throttle from "./throttle.js";
12
- export { collide, css, debounce, focusTrap, history, keyCodes, math, nextFrame, object, string, throttle };
13
+ export { collide, css, debounce, focusTrap, history, keyCodes, math, memoize, nextFrame, object, string, throttle };
package/utils/index.js CHANGED
@@ -7,7 +7,7 @@ import * as string from './string/index.js';
7
7
  import debounce from './debounce.js';
8
8
  import focusTrap from './focusTrap.js';
9
9
  import keyCodes from './keyCodes.js';
10
+ import memoize from './memoize.js';
10
11
  import nextFrame from './nextFrame.js';
11
12
  import throttle from './throttle.js';
12
- export { collide, css, debounce, focusTrap, history, keyCodes, math, nextFrame, object, string, throttle };
13
- //# sourceMappingURL=index.js.map
13
+ export { collide, css, debounce, focusTrap, history, keyCodes, math, memoize, nextFrame, object, string, throttle };
package/utils/keyCodes.js CHANGED
@@ -7,5 +7,4 @@ export default {
7
7
  UP: 38,
8
8
  RIGHT: 39,
9
9
  DOWN: 40
10
- };
11
- //# sourceMappingURL=keyCodes.js.map
10
+ };
@@ -1,4 +1,3 @@
1
1
  export default function clamp(value, min, max) {
2
2
  return min < max ? value < min ? min : value > max ? max : value : value < max ? max : value > min ? min : value;
3
- }
4
- //# sourceMappingURL=clamp.js.map
3
+ }
@@ -1,5 +1,4 @@
1
1
  import clamp from './clamp.js';
2
2
  export default function clamp01(value) {
3
3
  return clamp(value, 0, 1);
4
- }
5
- //# sourceMappingURL=clamp01.js.map
4
+ }
@@ -1,5 +1,4 @@
1
1
  export default function damp(targetValue, currentValue) {
2
2
  var factor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.5;
3
3
  return Math.abs(targetValue - currentValue) < 0.001 ? targetValue : currentValue + (targetValue - currentValue) * factor;
4
- }
5
- //# sourceMappingURL=damp.js.map
4
+ }
@@ -4,5 +4,4 @@ import damp from './damp.js';
4
4
  import lerp from './lerp.js';
5
5
  import map from './map.js';
6
6
  import round from './round.js';
7
- export { clamp, clamp01, damp, lerp, map, round };
8
- //# sourceMappingURL=index.js.map
7
+ export { clamp, clamp01, damp, lerp, map, round };
@@ -14,5 +14,4 @@ export default function inertiaFinalValue(initialValue, initialDelta) {
14
14
  }
15
15
 
16
16
  return finalValue;
17
- }
18
- //# sourceMappingURL=inertiaFinalValue.js.map
17
+ }
@@ -1,4 +1,3 @@
1
1
  export default function lerp(min, max, ratio) {
2
2
  return (1 - ratio) * min + ratio * max;
3
- }
4
- //# sourceMappingURL=lerp.js.map
3
+ }
package/utils/math/map.js CHANGED
@@ -1,4 +1,3 @@
1
1
  export default function map(value, inputMin, inputMax, outputMin, outputMax) {
2
2
  return (value - inputMin) * (outputMax - outputMin) / (inputMax - inputMin) + outputMin;
3
- }
4
- //# sourceMappingURL=map.js.map
3
+ }
@@ -1,5 +1,4 @@
1
1
  export default function round(value) {
2
2
  var decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
3
3
  return Number(value.toFixed(decimals));
4
- }
5
- //# sourceMappingURL=round.js.map
4
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @typedef {Object} MemorizeCache
3
+ * @property {(key:any) => boolean} has
4
+ * @property {(key:any, value:any) => MemorizeCache} set
5
+ * @property {(key:any) => any} get
6
+ */
7
+ /**
8
+ * @typedef {Object} MemorizeOptions
9
+ * @property {number} [maxAge]
10
+ * @property {(...args:any) => any} [cacheKey]
11
+ * @property {MemorizeCache} [cache]
12
+ */
13
+ /**
14
+ * Memorize the output of a function.
15
+ * @template {(...args:any) => any} T
16
+ * @param {T} fn
17
+ * @param {MemorizeOptions} options
18
+ * @return {(...args:Parameters<T>) => ReturnType<T>}
19
+ */
20
+ export default function memoize<T extends (...args: any) => any>(fn: T, { maxAge, cacheKey, cache }?: MemorizeOptions): (...args: Parameters<T>) => ReturnType<T>;
21
+ export type MemorizeCache = {
22
+ has: (key: any) => boolean;
23
+ set: (key: any, value: any) => MemorizeCache;
24
+ get: (key: any) => any;
25
+ };
26
+ export type MemorizeOptions = {
27
+ maxAge?: number;
28
+ cacheKey?: (...args: any) => any;
29
+ cache?: MemorizeCache;
30
+ };
@@ -0,0 +1,30 @@
1
+ export default function memoize(fn) {
2
+ var {
3
+ maxAge = Number.POSITIVE_INFINITY,
4
+ cacheKey = JSON.stringify,
5
+ cache = new Map()
6
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7
+ return function memoized() {
8
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
9
+ args[_key] = arguments[_key];
10
+ }
11
+
12
+ var key = cacheKey(args);
13
+ var date = Date.now();
14
+
15
+ if (cache.has(key)) {
16
+ var cached = cache.get(key);
17
+
18
+ if (date - cached.date < maxAge) {
19
+ return cached.data;
20
+ }
21
+ }
22
+
23
+ var data = fn(...args);
24
+ cache.set(key, {
25
+ data,
26
+ date: Date.now()
27
+ });
28
+ return data;
29
+ };
30
+ }
@@ -5,14 +5,9 @@ export function getCancelRaf() {
5
5
  return typeof window !== 'undefined' && window.cancelAnimationFrame ? window.cancelAnimationFrame.bind(window) : clearTimeout;
6
6
  }
7
7
  export default function nextFrame() {
8
- var fn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {};
8
+ var fn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : () => {};
9
9
  var raf = getRaf();
10
- return new Promise(function (resolve) {
11
- raf(function () {
12
- return raf(function () {
13
- return resolve(fn());
14
- });
15
- });
10
+ return new Promise(resolve => {
11
+ raf(() => raf(() => resolve(fn())));
16
12
  });
17
- }
18
- //# sourceMappingURL=nextFrame.js.map
13
+ }
@@ -1,14 +1,12 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
1
  import getAllProperties from './getAllProperties.js';
3
2
  export default function autoBind(instance, options) {
4
- var _ref = options || {},
5
- exclude = _ref.exclude,
6
- include = _ref.include;
3
+ var {
4
+ exclude,
5
+ include
6
+ } = options || {};
7
7
 
8
- var filter = function filter(key) {
9
- var match = function match(pattern) {
10
- return typeof pattern === 'string' ? key === pattern : pattern.test(key);
11
- };
8
+ var filter = key => {
9
+ var match = pattern => typeof pattern === 'string' ? key === pattern : pattern.test(key);
12
10
 
13
11
  if (include) {
14
12
  return include.some(match);
@@ -21,16 +19,11 @@ export default function autoBind(instance, options) {
21
19
  return true;
22
20
  };
23
21
 
24
- getAllProperties(instance).filter(function (_ref2) {
25
- var _ref3 = _slicedToArray(_ref2, 1),
26
- key = _ref3[0];
27
-
22
+ getAllProperties(instance).filter(_ref => {
23
+ var [key] = _ref;
28
24
  return key !== 'constructor' && filter(key);
29
- }).forEach(function (_ref4) {
30
- var _ref5 = _slicedToArray(_ref4, 2),
31
- key = _ref5[0],
32
- object = _ref5[1];
33
-
25
+ }).forEach(_ref2 => {
26
+ var [key, object] = _ref2;
34
27
  var descriptor = Object.getOwnPropertyDescriptor(object, key);
35
28
 
36
29
  if (descriptor && typeof descriptor.value === 'function') {
@@ -38,5 +31,4 @@ export default function autoBind(instance, options) {
38
31
  }
39
32
  });
40
33
  return instance;
41
- }
42
- //# sourceMappingURL=autoBind.js.map
34
+ }
@@ -1,4 +1,3 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
1
  export default function getAllProperties(object) {
3
2
  var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
4
3
  var testFn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
@@ -11,16 +10,9 @@ export default function getAllProperties(object) {
11
10
  var foundProps = Object.getOwnPropertyNames(proto);
12
11
 
13
12
  if (typeof testFn === 'function') {
14
- foundProps = foundProps.filter(function (name) {
15
- return testFn(name, proto);
16
- });
13
+ foundProps = foundProps.filter(name => testFn(name, proto));
17
14
  }
18
15
 
19
- foundProps = foundProps.map(function (name) {
20
- return [name, proto];
21
- }).reduce(function (acc, val) {
22
- return [].concat(_toConsumableArray(acc), [val]);
23
- }, props);
16
+ foundProps = foundProps.map(name => [name, proto]).reduce((acc, val) => [...acc, val], props);
24
17
  return getAllProperties(proto, foundProps, testFn);
25
- }
26
- //# sourceMappingURL=getAllProperties.js.map
18
+ }
@@ -1,5 +1,4 @@
1
1
  import autoBind from './autoBind.js';
2
2
  import getAllProperties from './getAllProperties.js';
3
3
  import isObject from './isObject.js';
4
- export { autoBind, getAllProperties, isObject };
5
- //# sourceMappingURL=index.js.map
4
+ export { autoBind, getAllProperties, isObject };
@@ -1,5 +1,3 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
2
1
  export default function isObject(value) {
3
- return _typeof(value) === 'object' && !!value && value.toString() === '[object Object]';
4
- }
5
- //# sourceMappingURL=isObject.js.map
2
+ return typeof value === 'object' && !!value && value.toString() === '[object Object]';
3
+ }
@@ -8,5 +8,4 @@ import withoutTrailingCharactersRecursive from './withoutTrailingCharactersRecur
8
8
  import withoutTrailingSlash from './withoutTrailingSlash.js';
9
9
  import withTrailingCharacters from './withTrailingCharacters.js';
10
10
  import withTrailingSlash from './withTrailingSlash.js';
11
- export { withLeadingCharacters, withLeadingSlash, withoutLeadingCharacters, withoutLeadingCharactersRecursive, withoutLeadingSlash, withoutTrailingCharacters, withoutTrailingCharactersRecursive, withoutTrailingSlash, withTrailingCharacters, withTrailingSlash };
12
- //# sourceMappingURL=index.js.map
11
+ export { withLeadingCharacters, withLeadingSlash, withoutLeadingCharacters, withoutLeadingCharactersRecursive, withoutLeadingSlash, withoutTrailingCharacters, withoutTrailingCharactersRecursive, withoutTrailingSlash, withTrailingCharacters, withTrailingSlash };
@@ -1,5 +1,4 @@
1
1
  import withoutLeadingCharacters from './withoutLeadingCharacters.js';
2
2
  export default function withLeadingCharacters(string, characters) {
3
3
  return "".concat(characters).concat(withoutLeadingCharacters(string, characters));
4
- }
5
- //# sourceMappingURL=withLeadingCharacters.js.map
4
+ }
@@ -1,5 +1,4 @@
1
1
  import withLeadingCharacters from './withLeadingCharacters.js';
2
2
  export default function withLeadingSlash(string) {
3
3
  return withLeadingCharacters(string, '/');
4
- }
5
- //# sourceMappingURL=withLeadingSlash.js.map
4
+ }
@@ -1,5 +1,4 @@
1
1
  import withoutTrailingCharacters from './withoutTrailingCharacters.js';
2
2
  export default function withTrailingCharacters(string, characters) {
3
3
  return "".concat(withoutTrailingCharacters(string, characters)).concat(characters);
4
- }
5
- //# sourceMappingURL=withTrailingCharacters.js.map
4
+ }