@studiometa/js-toolkit 2.2.3 → 2.4.1
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.cjs +29 -36
- package/Base/index.d.ts +0 -8
- package/Base/index.js +18 -25
- package/Base/managers/EventsManager.cjs +35 -36
- package/Base/managers/EventsManager.js +35 -36
- package/Base/managers/OptionsManager.cjs +19 -13
- package/Base/managers/OptionsManager.js +19 -13
- package/Base/managers/RefsManager.cjs +8 -5
- package/Base/managers/RefsManager.js +8 -5
- package/Base/managers/ResponsiveOptionsManager.cjs +4 -1
- package/Base/managers/ResponsiveOptionsManager.js +4 -1
- package/Base/managers/ServicesManager.cjs +5 -2
- package/Base/managers/ServicesManager.js +6 -3
- package/Base/utils.cjs +23 -1
- package/Base/utils.d.ts +25 -0
- package/Base/utils.js +23 -1
- package/README.md +3 -3
- package/decorators/withBreakpointManager.cjs +15 -5
- package/decorators/withBreakpointManager.js +15 -5
- package/decorators/withBreakpointObserver.cjs +8 -2
- package/decorators/withBreakpointObserver.js +8 -2
- package/decorators/withVue2.cjs +10 -3
- package/decorators/withVue2.js +10 -3
- package/helpers/getDirectChildren.cjs +46 -0
- package/helpers/getDirectChildren.d.ts +24 -0
- package/helpers/getDirectChildren.js +24 -0
- package/helpers/importOnInteraction.cjs +2 -1
- package/helpers/importOnInteraction.js +2 -1
- package/helpers/importWhenVisible.cjs +2 -1
- package/helpers/importWhenVisible.js +2 -1
- package/helpers/index.cjs +2 -0
- package/helpers/index.d.ts +1 -0
- package/helpers/index.js +1 -0
- package/helpers/utils.cjs +3 -2
- package/helpers/utils.js +3 -2
- package/package.json +4 -1
- package/services/raf.cjs +2 -5
- package/services/raf.js +1 -1
- package/utils/css/animate.cjs +31 -92
- package/utils/css/animate.d.ts +4 -16
- package/utils/css/animate.js +28 -89
- package/utils/css/classes.cjs +2 -1
- package/utils/css/classes.js +2 -1
- package/utils/css/styles.cjs +2 -5
- package/utils/css/styles.js +1 -1
- package/utils/css/transform.cjs +13 -16
- package/utils/css/transform.js +1 -1
- package/utils/css/transition.cjs +5 -3
- package/utils/css/transition.js +5 -3
- package/utils/focusTrap.cjs +2 -1
- package/utils/focusTrap.js +2 -1
- package/utils/{isFunction.cjs → has.cjs} +7 -7
- package/utils/has.d.ts +6 -0
- package/utils/has.js +6 -0
- package/utils/history.cjs +5 -7
- package/utils/history.js +4 -3
- package/utils/index.cjs +5 -5
- package/utils/index.d.ts +3 -2
- package/utils/index.js +5 -5
- package/utils/{isDefined.cjs → is.cjs} +20 -8
- package/utils/is.d.ts +8 -0
- package/utils/is.js +18 -0
- package/utils/math/inertiaFinalValue.cjs +5 -3
- package/utils/math/inertiaFinalValue.js +2 -3
- package/utils/nextFrame.cjs +5 -3
- package/utils/nextFrame.js +5 -3
- package/utils/nextMicrotask.cjs +2 -1
- package/utils/nextMicrotask.js +2 -1
- package/utils/nextTick.cjs +2 -1
- package/utils/nextTick.js +2 -1
- package/utils/object/autoBind.cjs +3 -2
- package/utils/object/autoBind.js +3 -2
- package/utils/object/getAllProperties.cjs +2 -1
- package/utils/object/getAllProperties.js +2 -1
- package/utils/object/index.cjs +1 -3
- package/utils/object/index.d.ts +0 -1
- package/utils/object/index.js +1 -3
- package/utils/tween.cjs +114 -0
- package/utils/tween.d.ts +25 -0
- package/utils/tween.js +89 -0
- package/utils/isDefined.d.ts +0 -7
- package/utils/isDefined.js +0 -6
- package/utils/isFunction.d.ts +0 -7
- package/utils/isFunction.js +0 -6
- package/utils/object/isObject.cjs +0 -28
- package/utils/object/isObject.d.ts +0 -7
- package/utils/object/isObject.js +0 -6
package/utils/css/animate.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import isDefined from "../isDefined.js";
|
|
1
|
+
import { lerp, map } from "../math/index.js";
|
|
2
|
+
import { isDefined, isFunction, isNumber } from "../is.js";
|
|
4
3
|
import transform, { TRANSFORM_PROPS } from "./transform.js";
|
|
5
|
-
import useRaf from "../../services/raf.js";
|
|
6
4
|
import { domScheduler as scheduler } from "../scheduler.js";
|
|
7
|
-
import {
|
|
5
|
+
import { tween, normalizeEase } from "../tween.js";
|
|
8
6
|
let id = 0;
|
|
9
7
|
const running = /* @__PURE__ */ new WeakMap();
|
|
10
|
-
const PROGRESS_PRECISION = 1e-4;
|
|
11
8
|
const CSSUnitConverter = {
|
|
12
9
|
"%": (value, getSizeRef) => value * getSizeRef() / 100,
|
|
13
10
|
vh: (value) => value * window.innerHeight / 100,
|
|
@@ -16,7 +13,7 @@ const CSSUnitConverter = {
|
|
|
16
13
|
vmax: (value) => value * Math.max(window.innerWidth, window.innerHeight) / 100
|
|
17
14
|
};
|
|
18
15
|
function getAnimationStepValue(val, getSizeRef) {
|
|
19
|
-
if (
|
|
16
|
+
if (isNumber(val)) {
|
|
20
17
|
return val;
|
|
21
18
|
}
|
|
22
19
|
if (!val[1] || !CSSUnitConverter[val[1]]) {
|
|
@@ -24,15 +21,6 @@ function getAnimationStepValue(val, getSizeRef) {
|
|
|
24
21
|
}
|
|
25
22
|
return CSSUnitConverter[val[1]](val[0], getSizeRef);
|
|
26
23
|
}
|
|
27
|
-
function normalizeEase(ease) {
|
|
28
|
-
if (!isDefined(ease)) {
|
|
29
|
-
return noopValue;
|
|
30
|
-
}
|
|
31
|
-
if (Array.isArray(ease)) {
|
|
32
|
-
return cubicBezier(...ease);
|
|
33
|
-
}
|
|
34
|
-
return ease;
|
|
35
|
-
}
|
|
36
24
|
const generateTranslateRenderStrategy = (sizeRef) => (element, fromValue, toValue, progress) => lerp(getAnimationStepValue(fromValue != null ? fromValue : 0, () => element[sizeRef]), getAnimationStepValue(toValue != null ? toValue : 0, () => element[sizeRef]), progress);
|
|
37
25
|
const widthBasedTranslateRenderStrategy = generateTranslateRenderStrategy("offsetWidth");
|
|
38
26
|
const heightBasedTranslateRenderStrategy = generateTranslateRenderStrategy("offsetHeight");
|
|
@@ -86,92 +74,43 @@ function render(element, from, to, progress) {
|
|
|
86
74
|
});
|
|
87
75
|
}
|
|
88
76
|
function animate(element, keyframes, options = {}) {
|
|
89
|
-
var _a;
|
|
90
|
-
const raf = useRaf();
|
|
91
|
-
let progressValue = 0;
|
|
92
|
-
let easedProgress = 0;
|
|
93
|
-
if (!running.has(element)) {
|
|
94
|
-
running.set(element, /* @__PURE__ */ new Map());
|
|
95
|
-
}
|
|
96
|
-
const ease = normalizeEase(options.easing);
|
|
97
|
-
let duration = (_a = options.duration) != null ? _a : 1;
|
|
98
|
-
duration *= 1e3;
|
|
99
|
-
let startTime = performance.now();
|
|
100
|
-
let endTime = startTime + duration;
|
|
101
|
-
const key = `animate-${id}`;
|
|
102
|
-
id += 1;
|
|
103
|
-
const { onProgress = noop, onFinish = noop } = options;
|
|
104
|
-
let isRunning = false;
|
|
105
77
|
const keyframesCount = keyframes.length - 1;
|
|
106
78
|
const normalizedKeyframes = keyframes.map((keyframe, index) => {
|
|
107
|
-
var
|
|
79
|
+
var _a;
|
|
108
80
|
return {
|
|
109
81
|
...keyframe,
|
|
110
|
-
offset: (
|
|
82
|
+
offset: (_a = keyframe.offset) != null ? _a : index / keyframesCount,
|
|
111
83
|
easing: normalizeEase(keyframe.easing)
|
|
112
84
|
};
|
|
113
85
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
raf.remove(key);
|
|
86
|
+
if (!running.has(element)) {
|
|
87
|
+
running.set(element, /* @__PURE__ */ new Map());
|
|
117
88
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
progressValue = newProgress;
|
|
123
|
-
if (Math.abs(1 - progressValue) < PROGRESS_PRECISION) {
|
|
124
|
-
progressValue = 1;
|
|
125
|
-
pause();
|
|
126
|
-
scheduler.afterWrite(() => onFinish(progressValue, easedProgress));
|
|
127
|
-
}
|
|
128
|
-
easedProgress = ease(progressValue);
|
|
89
|
+
const key = `animate-${id}`;
|
|
90
|
+
id += 1;
|
|
91
|
+
function callback(progress) {
|
|
129
92
|
let toIndex = 0;
|
|
130
|
-
while (normalizedKeyframes[toIndex] && normalizedKeyframes[toIndex].offset <=
|
|
93
|
+
while (normalizedKeyframes[toIndex] && normalizedKeyframes[toIndex].offset <= progress && normalizedKeyframes[toIndex].offset !== 1) {
|
|
131
94
|
toIndex += 1;
|
|
132
95
|
}
|
|
133
|
-
render(element, normalizedKeyframes[toIndex - 1], normalizedKeyframes[toIndex],
|
|
134
|
-
onProgress(progressValue, easedProgress);
|
|
135
|
-
return progressValue;
|
|
136
|
-
}
|
|
137
|
-
function tick(props) {
|
|
138
|
-
if (!isRunning) {
|
|
139
|
-
raf.remove(key);
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
progress(clamp01(map(props.time, startTime, endTime, 0, 1)));
|
|
96
|
+
render(element, normalizedKeyframes[toIndex - 1], normalizedKeyframes[toIndex], progress);
|
|
143
97
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
raf.add(key, tick);
|
|
158
|
-
}
|
|
159
|
-
function play() {
|
|
160
|
-
if (isRunning) {
|
|
161
|
-
return;
|
|
98
|
+
const controls = tween(callback, {
|
|
99
|
+
...options,
|
|
100
|
+
onStart() {
|
|
101
|
+
if (isFunction(options.onStart)) {
|
|
102
|
+
options.onStart();
|
|
103
|
+
}
|
|
104
|
+
const runningKeys = running.get(element);
|
|
105
|
+
runningKeys.forEach((runningPause, runningKey) => {
|
|
106
|
+
runningPause();
|
|
107
|
+
runningKeys.delete(runningKey);
|
|
108
|
+
});
|
|
109
|
+
runningKeys.set(key, controls.pause);
|
|
110
|
+
running.set(element, runningKeys);
|
|
162
111
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
isRunning = true;
|
|
166
|
-
raf.add(key, tick);
|
|
167
|
-
}
|
|
168
|
-
return {
|
|
169
|
-
start,
|
|
170
|
-
finish: () => progress(1),
|
|
171
|
-
pause,
|
|
172
|
-
play,
|
|
173
|
-
progress
|
|
174
|
-
};
|
|
112
|
+
});
|
|
113
|
+
return controls;
|
|
175
114
|
}
|
|
176
115
|
export {
|
|
177
116
|
animate
|
package/utils/css/classes.cjs
CHANGED
|
@@ -24,11 +24,12 @@ __export(classes_exports, {
|
|
|
24
24
|
toggle: () => toggle
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(classes_exports);
|
|
27
|
+
var import_is = require("../is.cjs");
|
|
27
28
|
function setClasses(element, classNames, method, forceToggle) {
|
|
28
29
|
if (!element || !classNames) {
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
31
|
-
const normalizedClassNames =
|
|
32
|
+
const normalizedClassNames = (0, import_is.isArray)(classNames) ? classNames : classNames.split(" ");
|
|
32
33
|
if (method !== "toggle") {
|
|
33
34
|
element.classList[method](...normalizedClassNames);
|
|
34
35
|
} else {
|
package/utils/css/classes.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { isArray } from "../is.js";
|
|
1
2
|
function setClasses(element, classNames, method, forceToggle) {
|
|
2
3
|
if (!element || !classNames) {
|
|
3
4
|
return;
|
|
4
5
|
}
|
|
5
|
-
const normalizedClassNames =
|
|
6
|
+
const normalizedClassNames = isArray(classNames) ? classNames : classNames.split(" ");
|
|
6
7
|
if (method !== "toggle") {
|
|
7
8
|
element.classList[method](...normalizedClassNames);
|
|
8
9
|
} else {
|
package/utils/css/styles.cjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,7 +14,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
18
|
|
|
22
19
|
// packages/js-toolkit/utils/css/styles.js
|
|
@@ -26,9 +23,9 @@ __export(styles_exports, {
|
|
|
26
23
|
remove: () => remove
|
|
27
24
|
});
|
|
28
25
|
module.exports = __toCommonJS(styles_exports);
|
|
29
|
-
var
|
|
26
|
+
var import_is = require("../is.cjs");
|
|
30
27
|
function setStyles(element, styles, method = "add") {
|
|
31
|
-
if (!element || !styles || !(0,
|
|
28
|
+
if (!element || !styles || !(0, import_is.isObject)(styles)) {
|
|
32
29
|
return;
|
|
33
30
|
}
|
|
34
31
|
Object.entries(styles).forEach(([prop, value]) => {
|
package/utils/css/styles.js
CHANGED
package/utils/css/transform.cjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,7 +14,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
18
|
|
|
22
19
|
// packages/js-toolkit/utils/css/transform.js
|
|
@@ -26,7 +23,7 @@ __export(transform_exports, {
|
|
|
26
23
|
default: () => transform
|
|
27
24
|
});
|
|
28
25
|
module.exports = __toCommonJS(transform_exports);
|
|
29
|
-
var
|
|
26
|
+
var import_is = require("../is.cjs");
|
|
30
27
|
var TRANSFORM_PROPS = [
|
|
31
28
|
"x",
|
|
32
29
|
"y",
|
|
@@ -46,42 +43,42 @@ var TRANSFORM_PROPS = [
|
|
|
46
43
|
function transform(element, props) {
|
|
47
44
|
var _a, _b, _c;
|
|
48
45
|
let value = "";
|
|
49
|
-
if ((0,
|
|
46
|
+
if ((0, import_is.isDefined)(props.x) || (0, import_is.isDefined)(props.y) || (0, import_is.isDefined)(props.z)) {
|
|
50
47
|
value += `translate3d(${(_a = props.x) != null ? _a : 0}px, ${(_b = props.y) != null ? _b : 0}px, ${(_c = props.z) != null ? _c : 0}px) `;
|
|
51
48
|
}
|
|
52
|
-
if ((0,
|
|
49
|
+
if ((0, import_is.isDefined)(props.rotate)) {
|
|
53
50
|
value += `rotate(${props.rotate}deg) `;
|
|
54
51
|
} else {
|
|
55
|
-
if ((0,
|
|
52
|
+
if ((0, import_is.isDefined)(props.rotateX)) {
|
|
56
53
|
value += `rotateX(${props.rotateX}deg) `;
|
|
57
54
|
}
|
|
58
|
-
if ((0,
|
|
55
|
+
if ((0, import_is.isDefined)(props.rotateY)) {
|
|
59
56
|
value += `rotateY(${props.rotateY}deg) `;
|
|
60
57
|
}
|
|
61
|
-
if ((0,
|
|
58
|
+
if ((0, import_is.isDefined)(props.rotateZ)) {
|
|
62
59
|
value += `rotateZ(${props.rotateZ}deg) `;
|
|
63
60
|
}
|
|
64
61
|
}
|
|
65
|
-
if ((0,
|
|
62
|
+
if ((0, import_is.isDefined)(props.scale)) {
|
|
66
63
|
value += `scale(${props.scale}) `;
|
|
67
64
|
} else {
|
|
68
|
-
if ((0,
|
|
65
|
+
if ((0, import_is.isDefined)(props.scaleX)) {
|
|
69
66
|
value += `scaleX(${props.scaleX}) `;
|
|
70
67
|
}
|
|
71
|
-
if ((0,
|
|
68
|
+
if ((0, import_is.isDefined)(props.scaleY)) {
|
|
72
69
|
value += `scaleY(${props.scaleY}) `;
|
|
73
70
|
}
|
|
74
|
-
if ((0,
|
|
71
|
+
if ((0, import_is.isDefined)(props.scaleZ)) {
|
|
75
72
|
value += `scaleZ(${props.scaleZ}) `;
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
|
-
if ((0,
|
|
75
|
+
if ((0, import_is.isDefined)(props.skew)) {
|
|
79
76
|
value += `skew(${props.skew}deg) `;
|
|
80
77
|
} else {
|
|
81
|
-
if ((0,
|
|
78
|
+
if ((0, import_is.isDefined)(props.skewX)) {
|
|
82
79
|
value += `skewX(${props.skewX}deg) `;
|
|
83
80
|
}
|
|
84
|
-
if ((0,
|
|
81
|
+
if ((0, import_is.isDefined)(props.skewY)) {
|
|
85
82
|
value += `skewY(${props.skewY}deg) `;
|
|
86
83
|
}
|
|
87
84
|
}
|
package/utils/css/transform.js
CHANGED
package/utils/css/transition.cjs
CHANGED
|
@@ -34,6 +34,8 @@ module.exports = __toCommonJS(transition_exports);
|
|
|
34
34
|
var import_nextFrame = require("../nextFrame.cjs");
|
|
35
35
|
var classes = __toESM(require("./classes.cjs"), 1);
|
|
36
36
|
var styles = __toESM(require("./styles.cjs"), 1);
|
|
37
|
+
var import_is = require("../is.cjs");
|
|
38
|
+
var import_has = require("../has.cjs");
|
|
37
39
|
var cache = /* @__PURE__ */ new WeakMap();
|
|
38
40
|
var Transition = class {
|
|
39
41
|
constructor(element) {
|
|
@@ -50,14 +52,14 @@ var Transition = class {
|
|
|
50
52
|
}
|
|
51
53
|
};
|
|
52
54
|
function setClassesOrStyles(element, classesOrStyles, method = "add") {
|
|
53
|
-
if (
|
|
55
|
+
if ((0, import_is.isString)(classesOrStyles) || (0, import_is.isArray)(classesOrStyles)) {
|
|
54
56
|
classes[method](element, classesOrStyles);
|
|
55
57
|
} else {
|
|
56
58
|
styles[method](element, classesOrStyles);
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
function testTransition(element) {
|
|
60
|
-
if (
|
|
62
|
+
if (!(0, import_has.hasWindow)()) {
|
|
61
63
|
return false;
|
|
62
64
|
}
|
|
63
65
|
const { transitionDuration } = window.getComputedStyle(element);
|
|
@@ -100,7 +102,7 @@ function end(element, classesOrStyles, mode = "remove") {
|
|
|
100
102
|
trs.transitionEndHandler = null;
|
|
101
103
|
}
|
|
102
104
|
async function transition(element, name, endMode = "remove") {
|
|
103
|
-
const classesOrStyles =
|
|
105
|
+
const classesOrStyles = (0, import_is.isString)(name) ? {
|
|
104
106
|
from: `${name}-from`,
|
|
105
107
|
active: `${name}-active`,
|
|
106
108
|
to: `${name}-to`
|
package/utils/css/transition.js
CHANGED
|
@@ -7,6 +7,8 @@ var __publicField = (obj, key, value) => {
|
|
|
7
7
|
import { nextFrame } from "../nextFrame.js";
|
|
8
8
|
import * as classes from "./classes.js";
|
|
9
9
|
import * as styles from "./styles.js";
|
|
10
|
+
import { isArray, isString } from "../is.js";
|
|
11
|
+
import { hasWindow } from "../has.js";
|
|
10
12
|
const cache = /* @__PURE__ */ new WeakMap();
|
|
11
13
|
class Transition {
|
|
12
14
|
constructor(element) {
|
|
@@ -23,14 +25,14 @@ class Transition {
|
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
function setClassesOrStyles(element, classesOrStyles, method = "add") {
|
|
26
|
-
if (
|
|
28
|
+
if (isString(classesOrStyles) || isArray(classesOrStyles)) {
|
|
27
29
|
classes[method](element, classesOrStyles);
|
|
28
30
|
} else {
|
|
29
31
|
styles[method](element, classesOrStyles);
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
function testTransition(element) {
|
|
33
|
-
if (
|
|
35
|
+
if (!hasWindow()) {
|
|
34
36
|
return false;
|
|
35
37
|
}
|
|
36
38
|
const { transitionDuration } = window.getComputedStyle(element);
|
|
@@ -73,7 +75,7 @@ function end(element, classesOrStyles, mode = "remove") {
|
|
|
73
75
|
trs.transitionEndHandler = null;
|
|
74
76
|
}
|
|
75
77
|
async function transition(element, name, endMode = "remove") {
|
|
76
|
-
const classesOrStyles =
|
|
78
|
+
const classesOrStyles = isString(name) ? {
|
|
77
79
|
from: `${name}-from`,
|
|
78
80
|
active: `${name}-active`,
|
|
79
81
|
to: `${name}-to`
|
package/utils/focusTrap.cjs
CHANGED
|
@@ -29,6 +29,7 @@ __export(focusTrap_exports, {
|
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(focusTrap_exports);
|
|
31
31
|
var import_keyCodes = __toESM(require("./keyCodes.cjs"), 1);
|
|
32
|
+
var import_is = require("./is.cjs");
|
|
32
33
|
var FOCUSABLE_ELEMENTS = [
|
|
33
34
|
'a[href]:not([tabindex^="-"]):not([inert])',
|
|
34
35
|
'area[href]:not([tabindex^="-"]):not([inert])',
|
|
@@ -71,7 +72,7 @@ function trap(element, event) {
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
function untrap() {
|
|
74
|
-
if (focusedBefore &&
|
|
75
|
+
if (focusedBefore && (0, import_is.isFunction)(focusedBefore.focus)) {
|
|
75
76
|
focusedBefore.focus();
|
|
76
77
|
focusedBefore = null;
|
|
77
78
|
}
|
package/utils/focusTrap.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import keyCodes from "./keyCodes.js";
|
|
2
|
+
import { isFunction } from "./is.js";
|
|
2
3
|
const FOCUSABLE_ELEMENTS = [
|
|
3
4
|
'a[href]:not([tabindex^="-"]):not([inert])',
|
|
4
5
|
'area[href]:not([tabindex^="-"]):not([inert])',
|
|
@@ -41,7 +42,7 @@ function trap(element, event) {
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
function untrap() {
|
|
44
|
-
if (focusedBefore &&
|
|
45
|
+
if (focusedBefore && isFunction(focusedBefore.focus)) {
|
|
45
46
|
focusedBefore.focus();
|
|
46
47
|
focusedBefore = null;
|
|
47
48
|
}
|
|
@@ -16,13 +16,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// packages/js-toolkit/utils/
|
|
20
|
-
var
|
|
21
|
-
__export(
|
|
22
|
-
|
|
19
|
+
// packages/js-toolkit/utils/has.js
|
|
20
|
+
var has_exports = {};
|
|
21
|
+
__export(has_exports, {
|
|
22
|
+
hasWindow: () => hasWindow
|
|
23
23
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
25
|
-
function
|
|
26
|
-
return typeof
|
|
24
|
+
module.exports = __toCommonJS(has_exports);
|
|
25
|
+
function hasWindow() {
|
|
26
|
+
return typeof window !== "undefined";
|
|
27
27
|
}
|
|
28
28
|
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/has.d.ts
ADDED
package/utils/has.js
ADDED
package/utils/history.cjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,7 +14,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
18
|
|
|
22
19
|
// packages/js-toolkit/utils/history.js
|
|
@@ -27,7 +24,8 @@ __export(history_exports, {
|
|
|
27
24
|
replace: () => replace
|
|
28
25
|
});
|
|
29
26
|
module.exports = __toCommonJS(history_exports);
|
|
30
|
-
var
|
|
27
|
+
var import_is = require("./is.cjs");
|
|
28
|
+
var import_has = require("./has.cjs");
|
|
31
29
|
function updateUrlSearchParam(params, name, value) {
|
|
32
30
|
if (value === "" || value === null || value === void 0) {
|
|
33
31
|
if (params.has(name)) {
|
|
@@ -35,14 +33,14 @@ function updateUrlSearchParam(params, name, value) {
|
|
|
35
33
|
}
|
|
36
34
|
return params;
|
|
37
35
|
}
|
|
38
|
-
if (
|
|
36
|
+
if ((0, import_is.isArray)(value)) {
|
|
39
37
|
value.forEach((val, index) => {
|
|
40
38
|
const arrayName = `${name}[${index}]`;
|
|
41
39
|
updateUrlSearchParam(params, arrayName, val);
|
|
42
40
|
});
|
|
43
41
|
return params;
|
|
44
42
|
}
|
|
45
|
-
if ((0,
|
|
43
|
+
if ((0, import_is.isObject)(value)) {
|
|
46
44
|
Object.entries(value).forEach(([key, val]) => {
|
|
47
45
|
const objectName = `${name}[${key}]`;
|
|
48
46
|
updateUrlSearchParam(params, objectName, val);
|
|
@@ -52,7 +50,7 @@ function updateUrlSearchParam(params, name, value) {
|
|
|
52
50
|
params.set(name, value);
|
|
53
51
|
return params;
|
|
54
52
|
}
|
|
55
|
-
function objectToURLSearchParams(obj, defaultSearch =
|
|
53
|
+
function objectToURLSearchParams(obj, defaultSearch = (0, import_has.hasWindow)() ? window.location.search : "") {
|
|
56
54
|
return Object.entries(obj).reduce((urlSearchParams, [name, value]) => updateUrlSearchParam(urlSearchParams, name, value), new URLSearchParams(defaultSearch));
|
|
57
55
|
}
|
|
58
56
|
function updateHistory(mode, options, data = {}, title = "") {
|
package/utils/history.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import isObject from "./
|
|
1
|
+
import { isArray, isObject } from "./is.js";
|
|
2
|
+
import { hasWindow } from "./has.js";
|
|
2
3
|
function updateUrlSearchParam(params, name, value) {
|
|
3
4
|
if (value === "" || value === null || value === void 0) {
|
|
4
5
|
if (params.has(name)) {
|
|
@@ -6,7 +7,7 @@ function updateUrlSearchParam(params, name, value) {
|
|
|
6
7
|
}
|
|
7
8
|
return params;
|
|
8
9
|
}
|
|
9
|
-
if (
|
|
10
|
+
if (isArray(value)) {
|
|
10
11
|
value.forEach((val, index) => {
|
|
11
12
|
const arrayName = `${name}[${index}]`;
|
|
12
13
|
updateUrlSearchParam(params, arrayName, val);
|
|
@@ -23,7 +24,7 @@ function updateUrlSearchParam(params, name, value) {
|
|
|
23
24
|
params.set(name, value);
|
|
24
25
|
return params;
|
|
25
26
|
}
|
|
26
|
-
function objectToURLSearchParams(obj, defaultSearch =
|
|
27
|
+
function objectToURLSearchParams(obj, defaultSearch = hasWindow() ? window.location.search : "") {
|
|
27
28
|
return Object.entries(obj).reduce((urlSearchParams, [name, value]) => updateUrlSearchParam(urlSearchParams, name, value), new URLSearchParams(defaultSearch));
|
|
28
29
|
}
|
|
29
30
|
function updateHistory(mode, options, data = {}, title = "") {
|
package/utils/index.cjs
CHANGED
|
@@ -27,8 +27,6 @@ __export(utils_exports, {
|
|
|
27
27
|
focusTrap: () => import_focusTrap.default,
|
|
28
28
|
historyPush: () => import_history.push,
|
|
29
29
|
historyReplace: () => import_history.replace,
|
|
30
|
-
isDefined: () => import_isDefined.default,
|
|
31
|
-
isFunction: () => import_isFunction.default,
|
|
32
30
|
keyCodes: () => import_keyCodes.default,
|
|
33
31
|
memoize: () => import_memoize.default,
|
|
34
32
|
nextFrame: () => import_nextFrame.nextFrame,
|
|
@@ -36,7 +34,8 @@ __export(utils_exports, {
|
|
|
36
34
|
nextTick: () => import_nextTick.default,
|
|
37
35
|
objectToURLSearchParams: () => import_history.objectToURLSearchParams,
|
|
38
36
|
scrollTo: () => import_scrollTo.default,
|
|
39
|
-
throttle: () => import_throttle.default
|
|
37
|
+
throttle: () => import_throttle.default,
|
|
38
|
+
tween: () => import_tween.tween
|
|
40
39
|
});
|
|
41
40
|
module.exports = __toCommonJS(utils_exports);
|
|
42
41
|
var import_debounce = __toESM(require("./debounce.cjs"), 1);
|
|
@@ -48,8 +47,8 @@ var import_nextTick = __toESM(require("./nextTick.cjs"), 1);
|
|
|
48
47
|
var import_nextMicrotask = __toESM(require("./nextMicrotask.cjs"), 1);
|
|
49
48
|
var import_throttle = __toESM(require("./throttle.cjs"), 1);
|
|
50
49
|
var import_scrollTo = __toESM(require("./scrollTo.cjs"), 1);
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
__reExport(utils_exports, require("./is.cjs"), module.exports);
|
|
51
|
+
__reExport(utils_exports, require("./has.cjs"), module.exports);
|
|
53
52
|
__reExport(utils_exports, require("./css/index.cjs"), module.exports);
|
|
54
53
|
var import_history = require("./history.cjs");
|
|
55
54
|
__reExport(utils_exports, require("./collide/index.cjs"), module.exports);
|
|
@@ -57,4 +56,5 @@ __reExport(utils_exports, require("./math/index.cjs"), module.exports);
|
|
|
57
56
|
__reExport(utils_exports, require("./string/index.cjs"), module.exports);
|
|
58
57
|
__reExport(utils_exports, require("./scheduler.cjs"), module.exports);
|
|
59
58
|
__reExport(utils_exports, require("./noop.cjs"), module.exports);
|
|
59
|
+
var import_tween = require("./tween.cjs");
|
|
60
60
|
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/index.d.ts
CHANGED
|
@@ -7,12 +7,13 @@ export { default as nextTick } from "./nextTick.js";
|
|
|
7
7
|
export { default as nextMicrotask } from "./nextMicrotask.js";
|
|
8
8
|
export { default as throttle } from "./throttle.js";
|
|
9
9
|
export { default as scrollTo } from "./scrollTo.js";
|
|
10
|
-
export
|
|
11
|
-
export
|
|
10
|
+
export * from "./is.js";
|
|
11
|
+
export * from "./has.js";
|
|
12
12
|
export * from "./css/index.js";
|
|
13
13
|
export * from "./collide/index.js";
|
|
14
14
|
export * from "./math/index.js";
|
|
15
15
|
export * from "./string/index.js";
|
|
16
16
|
export * from "./scheduler.js";
|
|
17
17
|
export * from "./noop.js";
|
|
18
|
+
export { tween } from "./tween.js";
|
|
18
19
|
export { objectToURLSearchParams, push as historyPush, replace as historyReplace } from "./history.js";
|
package/utils/index.js
CHANGED
|
@@ -7,8 +7,8 @@ import { default as default6 } from "./nextTick.js";
|
|
|
7
7
|
import { default as default7 } from "./nextMicrotask.js";
|
|
8
8
|
import { default as default8 } from "./throttle.js";
|
|
9
9
|
import { default as default9 } from "./scrollTo.js";
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
export * from "./is.js";
|
|
11
|
+
export * from "./has.js";
|
|
12
12
|
export * from "./css/index.js";
|
|
13
13
|
import {
|
|
14
14
|
objectToURLSearchParams,
|
|
@@ -20,13 +20,12 @@ export * from "./math/index.js";
|
|
|
20
20
|
export * from "./string/index.js";
|
|
21
21
|
export * from "./scheduler.js";
|
|
22
22
|
export * from "./noop.js";
|
|
23
|
+
import { tween } from "./tween.js";
|
|
23
24
|
export {
|
|
24
25
|
default2 as debounce,
|
|
25
26
|
default3 as focusTrap,
|
|
26
27
|
push as historyPush,
|
|
27
28
|
replace as historyReplace,
|
|
28
|
-
default10 as isDefined,
|
|
29
|
-
default11 as isFunction,
|
|
30
29
|
default4 as keyCodes,
|
|
31
30
|
default5 as memoize,
|
|
32
31
|
nextFrame,
|
|
@@ -34,5 +33,6 @@ export {
|
|
|
34
33
|
default6 as nextTick,
|
|
35
34
|
objectToURLSearchParams,
|
|
36
35
|
default9 as scrollTo,
|
|
37
|
-
default8 as throttle
|
|
36
|
+
default8 as throttle,
|
|
37
|
+
tween
|
|
38
38
|
};
|
|
@@ -16,13 +16,25 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// packages/js-toolkit/utils/
|
|
20
|
-
var
|
|
21
|
-
__export(
|
|
22
|
-
|
|
19
|
+
// packages/js-toolkit/utils/is.js
|
|
20
|
+
var is_exports = {};
|
|
21
|
+
__export(is_exports, {
|
|
22
|
+
isArray: () => isArray,
|
|
23
|
+
isBoolean: () => isBoolean,
|
|
24
|
+
isDefined: () => isDefined,
|
|
25
|
+
isDev: () => isDev,
|
|
26
|
+
isFunction: () => isFunction,
|
|
27
|
+
isNumber: () => isNumber,
|
|
28
|
+
isObject: () => isObject,
|
|
29
|
+
isString: () => isString
|
|
23
30
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
module.exports = __toCommonJS(is_exports);
|
|
32
|
+
var isDev = typeof __DEV__ !== "undefined" && __DEV__;
|
|
33
|
+
var isFunction = (value) => typeof value === "function";
|
|
34
|
+
var isDefined = (value) => typeof value !== "undefined";
|
|
35
|
+
var isString = (value) => typeof value === "string";
|
|
36
|
+
var isObject = (value) => typeof value === "object" && !!value && value.toString() === "[object Object]";
|
|
37
|
+
var isNumber = (value) => typeof value === "number";
|
|
38
|
+
var isBoolean = (value) => typeof value === "boolean";
|
|
39
|
+
var isArray = Array.isArray;
|
|
28
40
|
if (module.exports.default) module.exports = module.exports.default;
|