@studiometa/js-toolkit 1.7.2 → 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 (237) hide show
  1. package/Base/index.d.ts +217 -0
  2. package/Base/index.js +237 -0
  3. package/Base/managers/ChildrenManager.d.ts +108 -0
  4. package/Base/managers/ChildrenManager.js +124 -0
  5. package/Base/managers/EventsManager.d.ts +190 -0
  6. package/Base/managers/EventsManager.js +195 -0
  7. package/Base/managers/OptionsManager.d.ts +120 -0
  8. package/Base/managers/OptionsManager.js +180 -0
  9. package/Base/managers/RefsManager.d.ts +84 -0
  10. package/Base/managers/RefsManager.js +83 -0
  11. package/{abstracts/Base/classes/Services.d.ts → Base/managers/ServicesManager.d.ts} +22 -7
  12. package/Base/managers/ServicesManager.js +115 -0
  13. package/{abstracts/Base → Base}/utils.d.ts +0 -30
  14. package/Base/utils.js +43 -0
  15. package/README.md +12 -70
  16. package/decorators/index.js +1 -2
  17. package/decorators/withBreakpointManager.d.ts +5 -5
  18. package/decorators/withBreakpointManager.js +41 -79
  19. package/decorators/withBreakpointObserver.d.ts +4 -4
  20. package/decorators/withBreakpointObserver.js +54 -77
  21. package/decorators/withDrag.d.ts +6 -6
  22. package/decorators/withDrag.js +17 -41
  23. package/decorators/withExtraConfig.d.ts +6 -6
  24. package/decorators/withExtraConfig.js +2 -24
  25. package/decorators/withIntersectionObserver.d.ts +4 -4
  26. package/decorators/withIntersectionObserver.js +17 -60
  27. package/decorators/withMountWhenInView.d.ts +8 -8
  28. package/decorators/withMountWhenInView.js +23 -51
  29. package/helpers/createApp.d.ts +4 -4
  30. package/helpers/createApp.js +10 -12
  31. package/helpers/importOnInteraction.d.ts +6 -6
  32. package/helpers/importOnInteraction.js +7 -8
  33. package/helpers/importWhenIdle.d.ts +4 -4
  34. package/helpers/importWhenIdle.js +7 -8
  35. package/helpers/importWhenVisible.d.ts +6 -6
  36. package/helpers/importWhenVisible.js +9 -16
  37. package/helpers/index.d.ts +1 -3
  38. package/helpers/index.js +1 -4
  39. package/helpers/utils.js +2 -3
  40. package/index.d.ts +19 -5
  41. package/index.js +5 -6
  42. package/index.modern.js +1 -3230
  43. package/index.umd.js +1 -3586
  44. package/package.json +3 -6
  45. package/{abstracts → services}/Service.d.ts +0 -0
  46. package/services/Service.js +63 -0
  47. package/services/drag.js +144 -180
  48. package/services/index.js +1 -2
  49. package/services/key.js +56 -98
  50. package/services/load.d.ts +1 -1
  51. package/services/load.js +22 -51
  52. package/services/pointer.js +118 -157
  53. package/services/raf.js +37 -65
  54. package/services/resize.js +46 -98
  55. package/services/scroll.js +81 -120
  56. package/utils/collide/boundingRectToCircle.js +7 -6
  57. package/utils/collide/collideCircleCircle.js +1 -2
  58. package/utils/collide/collideCircleRect.js +1 -2
  59. package/utils/collide/collidePointCircle.js +1 -2
  60. package/utils/collide/collidePointRect.js +1 -2
  61. package/utils/collide/collideRectRect.js +1 -2
  62. package/utils/collide/index.js +1 -2
  63. package/utils/css/classes.js +2 -3
  64. package/utils/css/index.js +1 -2
  65. package/utils/css/matrix.js +1 -2
  66. package/utils/css/styles.js +3 -8
  67. package/utils/css/transition.js +67 -140
  68. package/utils/debounce.js +3 -4
  69. package/utils/focusTrap.js +4 -5
  70. package/utils/history.js +12 -19
  71. package/utils/index.d.ts +2 -1
  72. package/utils/index.js +2 -2
  73. package/utils/keyCodes.js +1 -2
  74. package/utils/math/clamp.js +1 -2
  75. package/utils/math/clamp01.js +1 -2
  76. package/utils/math/damp.js +1 -2
  77. package/utils/math/index.js +1 -2
  78. package/utils/math/inertiaFinalValue.js +1 -2
  79. package/utils/math/lerp.js +1 -2
  80. package/utils/math/map.js +1 -2
  81. package/utils/math/round.js +1 -2
  82. package/utils/memoize.d.ts +30 -0
  83. package/utils/memoize.js +30 -0
  84. package/utils/nextFrame.js +4 -9
  85. package/utils/object/autoBind.js +11 -19
  86. package/utils/object/getAllProperties.d.ts +6 -3
  87. package/utils/object/getAllProperties.js +10 -8
  88. package/utils/object/index.js +1 -2
  89. package/utils/object/isObject.js +2 -4
  90. package/utils/string/index.js +1 -2
  91. package/utils/string/withLeadingCharacters.js +1 -2
  92. package/utils/string/withLeadingSlash.js +1 -2
  93. package/utils/string/withTrailingCharacters.js +1 -2
  94. package/utils/string/withTrailingSlash.js +1 -2
  95. package/utils/string/withoutLeadingCharacters.js +1 -2
  96. package/utils/string/withoutLeadingCharactersRecursive.js +1 -2
  97. package/utils/string/withoutLeadingSlash.js +1 -2
  98. package/utils/string/withoutTrailingCharacters.js +1 -2
  99. package/utils/string/withoutTrailingCharactersRecursive.js +1 -2
  100. package/utils/string/withoutTrailingSlash.js +1 -2
  101. package/utils/throttle.js +2 -3
  102. package/abstracts/Base/children.d.ts +0 -16
  103. package/abstracts/Base/children.js +0 -66
  104. package/abstracts/Base/children.js.map +0 -1
  105. package/abstracts/Base/classes/Options.d.ts +0 -37
  106. package/abstracts/Base/classes/Options.js +0 -182
  107. package/abstracts/Base/classes/Options.js.map +0 -1
  108. package/abstracts/Base/classes/Services.js +0 -120
  109. package/abstracts/Base/classes/Services.js.map +0 -1
  110. package/abstracts/Base/components.d.ts +0 -22
  111. package/abstracts/Base/components.js +0 -67
  112. package/abstracts/Base/components.js.map +0 -1
  113. package/abstracts/Base/events.d.ts +0 -8
  114. package/abstracts/Base/events.js +0 -185
  115. package/abstracts/Base/events.js.map +0 -1
  116. package/abstracts/Base/index.d.ts +0 -176
  117. package/abstracts/Base/index.js +0 -215
  118. package/abstracts/Base/index.js.map +0 -1
  119. package/abstracts/Base/options.d.ts +0 -17
  120. package/abstracts/Base/options.js +0 -112
  121. package/abstracts/Base/options.js.map +0 -1
  122. package/abstracts/Base/refs.d.ts +0 -30
  123. package/abstracts/Base/refs.js +0 -60
  124. package/abstracts/Base/refs.js.map +0 -1
  125. package/abstracts/Base/utils.js +0 -102
  126. package/abstracts/Base/utils.js.map +0 -1
  127. package/abstracts/EventManager.d.ts +0 -41
  128. package/abstracts/EventManager.js +0 -88
  129. package/abstracts/EventManager.js.map +0 -1
  130. package/abstracts/Service.js +0 -82
  131. package/abstracts/Service.js.map +0 -1
  132. package/abstracts/index.d.ts +0 -4
  133. package/abstracts/index.js +0 -5
  134. package/abstracts/index.js.map +0 -1
  135. package/components/Accordion/Accordion.d.ts +0 -83
  136. package/components/Accordion/Accordion.js +0 -121
  137. package/components/Accordion/Accordion.js.map +0 -1
  138. package/components/Accordion/AccordionItem.d.ts +0 -122
  139. package/components/Accordion/AccordionItem.js +0 -327
  140. package/components/Accordion/AccordionItem.js.map +0 -1
  141. package/components/Accordion/index.d.ts +0 -27
  142. package/components/Accordion/index.js +0 -39
  143. package/components/Accordion/index.js.map +0 -1
  144. package/components/Cursor.d.ts +0 -138
  145. package/components/Cursor.js +0 -167
  146. package/components/Cursor.js.map +0 -1
  147. package/components/Draggable.d.ts +0 -49
  148. package/components/Draggable.js +0 -77
  149. package/components/Draggable.js.map +0 -1
  150. package/components/Modal.d.ts +0 -158
  151. package/components/Modal.js +0 -270
  152. package/components/Modal.js.map +0 -1
  153. package/components/Tabs.d.ts +0 -108
  154. package/components/Tabs.js +0 -195
  155. package/components/Tabs.js.map +0 -1
  156. package/components/index.d.ts +0 -6
  157. package/components/index.js +0 -7
  158. package/components/index.js.map +0 -1
  159. package/decorators/index.js.map +0 -1
  160. package/decorators/withBreakpointManager.js.map +0 -1
  161. package/decorators/withBreakpointObserver.js.map +0 -1
  162. package/decorators/withDrag.js.map +0 -1
  163. package/decorators/withExtraConfig.js.map +0 -1
  164. package/decorators/withIntersectionObserver.js.map +0 -1
  165. package/decorators/withMountWhenInView.js.map +0 -1
  166. package/full.d.ts +0 -10
  167. package/full.js +0 -12
  168. package/full.js.map +0 -1
  169. package/full.modern.js +0 -7523
  170. package/full.modern.js.map +0 -1
  171. package/full.umd.js +0 -8277
  172. package/full.umd.js.map +0 -1
  173. package/helpers/createApp.js.map +0 -1
  174. package/helpers/createBase.d.ts +0 -7
  175. package/helpers/createBase.js +0 -7
  176. package/helpers/createBase.js.map +0 -1
  177. package/helpers/defineComponent.d.ts +0 -11
  178. package/helpers/defineComponent.js +0 -68
  179. package/helpers/defineComponent.js.map +0 -1
  180. package/helpers/importOnInteraction.js.map +0 -1
  181. package/helpers/importWhenIdle.js.map +0 -1
  182. package/helpers/importWhenVisible.js.map +0 -1
  183. package/helpers/index.js.map +0 -1
  184. package/helpers/utils.js.map +0 -1
  185. package/index.js.map +0 -1
  186. package/index.modern.js.map +0 -1
  187. package/index.umd.js.map +0 -1
  188. package/services/drag.js.map +0 -1
  189. package/services/index.js.map +0 -1
  190. package/services/key.js.map +0 -1
  191. package/services/load.js.map +0 -1
  192. package/services/pointer.js.map +0 -1
  193. package/services/raf.js.map +0 -1
  194. package/services/resize.js.map +0 -1
  195. package/services/scroll.js.map +0 -1
  196. package/utils/collide/boundingRectToCircle.js.map +0 -1
  197. package/utils/collide/collideCircleCircle.js.map +0 -1
  198. package/utils/collide/collideCircleRect.js.map +0 -1
  199. package/utils/collide/collidePointCircle.js.map +0 -1
  200. package/utils/collide/collidePointRect.js.map +0 -1
  201. package/utils/collide/collideRectRect.js.map +0 -1
  202. package/utils/collide/index.js.map +0 -1
  203. package/utils/css/classes.js.map +0 -1
  204. package/utils/css/index.js.map +0 -1
  205. package/utils/css/matrix.js.map +0 -1
  206. package/utils/css/styles.js.map +0 -1
  207. package/utils/css/transition.js.map +0 -1
  208. package/utils/debounce.js.map +0 -1
  209. package/utils/focusTrap.js.map +0 -1
  210. package/utils/history.js.map +0 -1
  211. package/utils/index.js.map +0 -1
  212. package/utils/keyCodes.js.map +0 -1
  213. package/utils/math/clamp.js.map +0 -1
  214. package/utils/math/clamp01.js.map +0 -1
  215. package/utils/math/damp.js.map +0 -1
  216. package/utils/math/index.js.map +0 -1
  217. package/utils/math/inertiaFinalValue.js.map +0 -1
  218. package/utils/math/lerp.js.map +0 -1
  219. package/utils/math/map.js.map +0 -1
  220. package/utils/math/round.js.map +0 -1
  221. package/utils/nextFrame.js.map +0 -1
  222. package/utils/object/autoBind.js.map +0 -1
  223. package/utils/object/getAllProperties.js.map +0 -1
  224. package/utils/object/index.js.map +0 -1
  225. package/utils/object/isObject.js.map +0 -1
  226. package/utils/string/index.js.map +0 -1
  227. package/utils/string/withLeadingCharacters.js.map +0 -1
  228. package/utils/string/withLeadingSlash.js.map +0 -1
  229. package/utils/string/withTrailingCharacters.js.map +0 -1
  230. package/utils/string/withTrailingSlash.js.map +0 -1
  231. package/utils/string/withoutLeadingCharacters.js.map +0 -1
  232. package/utils/string/withoutLeadingCharactersRecursive.js.map +0 -1
  233. package/utils/string/withoutLeadingSlash.js.map +0 -1
  234. package/utils/string/withoutTrailingCharacters.js.map +0 -1
  235. package/utils/string/withoutTrailingCharactersRecursive.js.map +0 -1
  236. package/utils/string/withoutTrailingSlash.js.map +0 -1
  237. 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
  });
@@ -42,11 +38,8 @@ function updateUrlSearchParam(params, name, value) {
42
38
 
43
39
  export function objectToURLSearchParams(obj) {
44
40
  var defaultSearch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : typeof window === 'undefined' ? '' : 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
-
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,8 +1,11 @@
1
1
  /**
2
2
  * Gets all non-builtin properties up the prototype chain.
3
3
  *
4
- * @param {Object} object The object to get the propeties from.
5
- * @param {Array=} [props=[]] The already existing properties.
4
+ * @param {Object} object
5
+ * The object to get the propeties from.
6
+ * @param {Array=} [props=[]]
7
+ * The already existing properties.
8
+ * @param {(name:string, proto:any) => boolean} testFn
6
9
  * @return {Array<[String, Object]>} An array of properties and the prototype they belong to.
7
10
  */
8
- export default function getAllProperties(object: any, props?: any[] | undefined): Array<[string, any]>;
11
+ export default function getAllProperties(object: any, props?: any[] | undefined, testFn?: (name: string, proto: any) => boolean): Array<[string, any]>;
@@ -1,16 +1,18 @@
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] : [];
3
+ var testFn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
4
4
  var proto = Object.getPrototypeOf(object);
5
5
 
6
6
  if (proto === Object.prototype) {
7
7
  return props;
8
8
  }
9
9
 
10
- return getAllProperties(proto, Object.getOwnPropertyNames(proto).map(function (name) {
11
- return [name, proto];
12
- }).reduce(function (acc, val) {
13
- return [].concat(_toConsumableArray(acc), [val]);
14
- }, props));
15
- }
16
- //# sourceMappingURL=getAllProperties.js.map
10
+ var foundProps = Object.getOwnPropertyNames(proto);
11
+
12
+ if (typeof testFn === 'function') {
13
+ foundProps = foundProps.filter(name => testFn(name, proto));
14
+ }
15
+
16
+ foundProps = foundProps.map(name => [name, proto]).reduce((acc, val) => [...acc, val], props);
17
+ return getAllProperties(proto, foundProps, testFn);
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
+ }