@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.
- package/Base/index.d.ts +217 -0
- package/Base/index.js +237 -0
- package/Base/managers/ChildrenManager.d.ts +108 -0
- package/Base/managers/ChildrenManager.js +124 -0
- package/Base/managers/EventsManager.d.ts +190 -0
- package/Base/managers/EventsManager.js +195 -0
- package/Base/managers/OptionsManager.d.ts +120 -0
- package/Base/managers/OptionsManager.js +180 -0
- package/Base/managers/RefsManager.d.ts +84 -0
- package/Base/managers/RefsManager.js +83 -0
- package/{abstracts/Base/classes/Services.d.ts → Base/managers/ServicesManager.d.ts} +22 -7
- package/Base/managers/ServicesManager.js +115 -0
- package/{abstracts/Base → Base}/utils.d.ts +0 -30
- package/Base/utils.js +43 -0
- package/README.md +12 -70
- package/decorators/index.js +1 -2
- package/decorators/withBreakpointManager.d.ts +5 -5
- package/decorators/withBreakpointManager.js +41 -79
- package/decorators/withBreakpointObserver.d.ts +4 -4
- package/decorators/withBreakpointObserver.js +54 -77
- package/decorators/withDrag.d.ts +6 -6
- package/decorators/withDrag.js +17 -41
- package/decorators/withExtraConfig.d.ts +6 -6
- package/decorators/withExtraConfig.js +2 -24
- package/decorators/withIntersectionObserver.d.ts +4 -4
- package/decorators/withIntersectionObserver.js +17 -60
- package/decorators/withMountWhenInView.d.ts +8 -8
- package/decorators/withMountWhenInView.js +23 -51
- package/helpers/createApp.d.ts +4 -4
- package/helpers/createApp.js +10 -12
- package/helpers/importOnInteraction.d.ts +6 -6
- package/helpers/importOnInteraction.js +7 -8
- package/helpers/importWhenIdle.d.ts +4 -4
- package/helpers/importWhenIdle.js +7 -8
- package/helpers/importWhenVisible.d.ts +6 -6
- package/helpers/importWhenVisible.js +9 -16
- package/helpers/index.d.ts +1 -3
- package/helpers/index.js +1 -4
- package/helpers/utils.js +2 -3
- package/index.d.ts +19 -5
- package/index.js +5 -6
- package/index.modern.js +1 -3230
- package/index.umd.js +1 -3586
- package/package.json +3 -6
- package/{abstracts → services}/Service.d.ts +0 -0
- package/services/Service.js +63 -0
- package/services/drag.js +144 -180
- package/services/index.js +1 -2
- package/services/key.js +56 -98
- package/services/load.d.ts +1 -1
- package/services/load.js +22 -51
- package/services/pointer.js +118 -157
- package/services/raf.js +37 -65
- package/services/resize.js +46 -98
- package/services/scroll.js +81 -120
- package/utils/collide/boundingRectToCircle.js +7 -6
- package/utils/collide/collideCircleCircle.js +1 -2
- package/utils/collide/collideCircleRect.js +1 -2
- package/utils/collide/collidePointCircle.js +1 -2
- package/utils/collide/collidePointRect.js +1 -2
- package/utils/collide/collideRectRect.js +1 -2
- package/utils/collide/index.js +1 -2
- package/utils/css/classes.js +2 -3
- package/utils/css/index.js +1 -2
- package/utils/css/matrix.js +1 -2
- package/utils/css/styles.js +3 -8
- package/utils/css/transition.js +67 -140
- package/utils/debounce.js +3 -4
- package/utils/focusTrap.js +4 -5
- package/utils/history.js +12 -19
- package/utils/index.d.ts +2 -1
- package/utils/index.js +2 -2
- package/utils/keyCodes.js +1 -2
- package/utils/math/clamp.js +1 -2
- package/utils/math/clamp01.js +1 -2
- package/utils/math/damp.js +1 -2
- package/utils/math/index.js +1 -2
- package/utils/math/inertiaFinalValue.js +1 -2
- package/utils/math/lerp.js +1 -2
- package/utils/math/map.js +1 -2
- package/utils/math/round.js +1 -2
- package/utils/memoize.d.ts +30 -0
- package/utils/memoize.js +30 -0
- package/utils/nextFrame.js +4 -9
- package/utils/object/autoBind.js +11 -19
- package/utils/object/getAllProperties.d.ts +6 -3
- package/utils/object/getAllProperties.js +10 -8
- package/utils/object/index.js +1 -2
- package/utils/object/isObject.js +2 -4
- package/utils/string/index.js +1 -2
- package/utils/string/withLeadingCharacters.js +1 -2
- package/utils/string/withLeadingSlash.js +1 -2
- package/utils/string/withTrailingCharacters.js +1 -2
- package/utils/string/withTrailingSlash.js +1 -2
- package/utils/string/withoutLeadingCharacters.js +1 -2
- package/utils/string/withoutLeadingCharactersRecursive.js +1 -2
- package/utils/string/withoutLeadingSlash.js +1 -2
- package/utils/string/withoutTrailingCharacters.js +1 -2
- package/utils/string/withoutTrailingCharactersRecursive.js +1 -2
- package/utils/string/withoutTrailingSlash.js +1 -2
- package/utils/throttle.js +2 -3
- package/abstracts/Base/children.d.ts +0 -16
- package/abstracts/Base/children.js +0 -66
- package/abstracts/Base/children.js.map +0 -1
- package/abstracts/Base/classes/Options.d.ts +0 -37
- package/abstracts/Base/classes/Options.js +0 -182
- package/abstracts/Base/classes/Options.js.map +0 -1
- package/abstracts/Base/classes/Services.js +0 -120
- package/abstracts/Base/classes/Services.js.map +0 -1
- package/abstracts/Base/components.d.ts +0 -22
- package/abstracts/Base/components.js +0 -67
- package/abstracts/Base/components.js.map +0 -1
- package/abstracts/Base/events.d.ts +0 -8
- package/abstracts/Base/events.js +0 -185
- package/abstracts/Base/events.js.map +0 -1
- package/abstracts/Base/index.d.ts +0 -176
- package/abstracts/Base/index.js +0 -215
- package/abstracts/Base/index.js.map +0 -1
- package/abstracts/Base/options.d.ts +0 -17
- package/abstracts/Base/options.js +0 -112
- package/abstracts/Base/options.js.map +0 -1
- package/abstracts/Base/refs.d.ts +0 -30
- package/abstracts/Base/refs.js +0 -60
- package/abstracts/Base/refs.js.map +0 -1
- package/abstracts/Base/utils.js +0 -102
- package/abstracts/Base/utils.js.map +0 -1
- package/abstracts/EventManager.d.ts +0 -41
- package/abstracts/EventManager.js +0 -88
- package/abstracts/EventManager.js.map +0 -1
- package/abstracts/Service.js +0 -82
- package/abstracts/Service.js.map +0 -1
- package/abstracts/index.d.ts +0 -4
- package/abstracts/index.js +0 -5
- package/abstracts/index.js.map +0 -1
- package/components/Accordion/Accordion.d.ts +0 -83
- package/components/Accordion/Accordion.js +0 -121
- package/components/Accordion/Accordion.js.map +0 -1
- package/components/Accordion/AccordionItem.d.ts +0 -122
- package/components/Accordion/AccordionItem.js +0 -327
- package/components/Accordion/AccordionItem.js.map +0 -1
- package/components/Accordion/index.d.ts +0 -27
- package/components/Accordion/index.js +0 -39
- package/components/Accordion/index.js.map +0 -1
- package/components/Cursor.d.ts +0 -138
- package/components/Cursor.js +0 -167
- package/components/Cursor.js.map +0 -1
- package/components/Draggable.d.ts +0 -49
- package/components/Draggable.js +0 -77
- package/components/Draggable.js.map +0 -1
- package/components/Modal.d.ts +0 -158
- package/components/Modal.js +0 -270
- package/components/Modal.js.map +0 -1
- package/components/Tabs.d.ts +0 -108
- package/components/Tabs.js +0 -195
- package/components/Tabs.js.map +0 -1
- package/components/index.d.ts +0 -6
- package/components/index.js +0 -7
- package/components/index.js.map +0 -1
- package/decorators/index.js.map +0 -1
- package/decorators/withBreakpointManager.js.map +0 -1
- package/decorators/withBreakpointObserver.js.map +0 -1
- package/decorators/withDrag.js.map +0 -1
- package/decorators/withExtraConfig.js.map +0 -1
- package/decorators/withIntersectionObserver.js.map +0 -1
- package/decorators/withMountWhenInView.js.map +0 -1
- package/full.d.ts +0 -10
- package/full.js +0 -12
- package/full.js.map +0 -1
- package/full.modern.js +0 -7523
- package/full.modern.js.map +0 -1
- package/full.umd.js +0 -8277
- package/full.umd.js.map +0 -1
- package/helpers/createApp.js.map +0 -1
- package/helpers/createBase.d.ts +0 -7
- package/helpers/createBase.js +0 -7
- package/helpers/createBase.js.map +0 -1
- package/helpers/defineComponent.d.ts +0 -11
- package/helpers/defineComponent.js +0 -68
- package/helpers/defineComponent.js.map +0 -1
- package/helpers/importOnInteraction.js.map +0 -1
- package/helpers/importWhenIdle.js.map +0 -1
- package/helpers/importWhenVisible.js.map +0 -1
- package/helpers/index.js.map +0 -1
- package/helpers/utils.js.map +0 -1
- package/index.js.map +0 -1
- package/index.modern.js.map +0 -1
- package/index.umd.js.map +0 -1
- package/services/drag.js.map +0 -1
- package/services/index.js.map +0 -1
- package/services/key.js.map +0 -1
- package/services/load.js.map +0 -1
- package/services/pointer.js.map +0 -1
- package/services/raf.js.map +0 -1
- package/services/resize.js.map +0 -1
- package/services/scroll.js.map +0 -1
- package/utils/collide/boundingRectToCircle.js.map +0 -1
- package/utils/collide/collideCircleCircle.js.map +0 -1
- package/utils/collide/collideCircleRect.js.map +0 -1
- package/utils/collide/collidePointCircle.js.map +0 -1
- package/utils/collide/collidePointRect.js.map +0 -1
- package/utils/collide/collideRectRect.js.map +0 -1
- package/utils/collide/index.js.map +0 -1
- package/utils/css/classes.js.map +0 -1
- package/utils/css/index.js.map +0 -1
- package/utils/css/matrix.js.map +0 -1
- package/utils/css/styles.js.map +0 -1
- package/utils/css/transition.js.map +0 -1
- package/utils/debounce.js.map +0 -1
- package/utils/focusTrap.js.map +0 -1
- package/utils/history.js.map +0 -1
- package/utils/index.js.map +0 -1
- package/utils/keyCodes.js.map +0 -1
- package/utils/math/clamp.js.map +0 -1
- package/utils/math/clamp01.js.map +0 -1
- package/utils/math/damp.js.map +0 -1
- package/utils/math/index.js.map +0 -1
- package/utils/math/inertiaFinalValue.js.map +0 -1
- package/utils/math/lerp.js.map +0 -1
- package/utils/math/map.js.map +0 -1
- package/utils/math/round.js.map +0 -1
- package/utils/nextFrame.js.map +0 -1
- package/utils/object/autoBind.js.map +0 -1
- package/utils/object/getAllProperties.js.map +0 -1
- package/utils/object/index.js.map +0 -1
- package/utils/object/isObject.js.map +0 -1
- package/utils/string/index.js.map +0 -1
- package/utils/string/withLeadingCharacters.js.map +0 -1
- package/utils/string/withLeadingSlash.js.map +0 -1
- package/utils/string/withTrailingCharacters.js.map +0 -1
- package/utils/string/withTrailingSlash.js.map +0 -1
- package/utils/string/withoutLeadingCharacters.js.map +0 -1
- package/utils/string/withoutLeadingCharactersRecursive.js.map +0 -1
- package/utils/string/withoutLeadingSlash.js.map +0 -1
- package/utils/string/withoutTrailingCharacters.js.map +0 -1
- package/utils/string/withoutTrailingCharactersRecursive.js.map +0 -1
- package/utils/string/withoutTrailingSlash.js.map +0 -1
- package/utils/throttle.js.map +0 -1
package/utils/css/transition.js
CHANGED
|
@@ -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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
28
|
-
|
|
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
|
-
|
|
25
|
+
if (!instance) {
|
|
26
|
+
instance = new this(element);
|
|
37
27
|
}
|
|
38
|
-
}]);
|
|
39
28
|
|
|
40
|
-
|
|
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
|
|
59
|
-
|
|
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(
|
|
70
|
-
var trs;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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(
|
|
102
|
-
var hasTransition;
|
|
103
|
-
return
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
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(
|
|
174
|
-
var endMode
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
package/utils/focusTrap.js
CHANGED
|
@@ -41,9 +41,8 @@ export function untrap() {
|
|
|
41
41
|
}
|
|
42
42
|
export default function useFocusTrap() {
|
|
43
43
|
return {
|
|
44
|
-
trap
|
|
45
|
-
untrap
|
|
46
|
-
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(
|
|
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(
|
|
29
|
-
var
|
|
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(
|
|
46
|
-
var
|
|
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
|
|
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
package/utils/math/clamp.js
CHANGED
package/utils/math/clamp01.js
CHANGED
package/utils/math/damp.js
CHANGED
|
@@ -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
|
+
}
|
package/utils/math/index.js
CHANGED
package/utils/math/lerp.js
CHANGED
package/utils/math/map.js
CHANGED
package/utils/math/round.js
CHANGED
|
@@ -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
|
+
};
|
package/utils/memoize.js
ADDED
|
@@ -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
|
+
}
|
package/utils/nextFrame.js
CHANGED
|
@@ -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] :
|
|
8
|
+
var fn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : () => {};
|
|
9
9
|
var raf = getRaf();
|
|
10
|
-
return new Promise(
|
|
11
|
-
raf(
|
|
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
|
+
}
|
package/utils/object/autoBind.js
CHANGED
|
@@ -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
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
var {
|
|
4
|
+
exclude,
|
|
5
|
+
include
|
|
6
|
+
} = options || {};
|
|
7
7
|
|
|
8
|
-
var filter =
|
|
9
|
-
var match =
|
|
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(
|
|
25
|
-
var
|
|
26
|
-
key = _ref3[0];
|
|
27
|
-
|
|
22
|
+
getAllProperties(instance).filter(_ref => {
|
|
23
|
+
var [key] = _ref;
|
|
28
24
|
return key !== 'constructor' && filter(key);
|
|
29
|
-
}).forEach(
|
|
30
|
-
var
|
|
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
|
|
5
|
-
*
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
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
|
+
}
|
package/utils/object/index.js
CHANGED
|
@@ -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 };
|
package/utils/object/isObject.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
1
|
export default function isObject(value) {
|
|
3
|
-
return
|
|
4
|
-
}
|
|
5
|
-
//# sourceMappingURL=isObject.js.map
|
|
2
|
+
return typeof value === 'object' && !!value && value.toString() === '[object Object]';
|
|
3
|
+
}
|
package/utils/string/index.js
CHANGED
|
@@ -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
|
+
}
|