@studiometa/js-toolkit 2.0.0-rc.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Base/index.cjs +54 -18
- package/Base/index.d.ts +47 -26
- package/Base/index.js +54 -18
- package/Base/managers/AbstractManager.cjs +56 -0
- package/Base/managers/AbstractManager.d.ts +44 -0
- package/Base/managers/AbstractManager.js +35 -0
- package/Base/managers/ChildrenManager.cjs +79 -100
- package/Base/managers/ChildrenManager.d.ts +8 -83
- package/Base/managers/ChildrenManager.js +76 -100
- package/Base/managers/EventsManager.cjs +75 -99
- package/Base/managers/EventsManager.d.ts +37 -113
- package/Base/managers/EventsManager.js +75 -99
- package/Base/managers/OptionsManager.cjs +65 -79
- package/Base/managers/OptionsManager.d.ts +41 -80
- package/Base/managers/OptionsManager.js +66 -80
- package/Base/managers/RefsManager.cjs +44 -68
- package/Base/managers/RefsManager.d.ts +12 -66
- package/Base/managers/RefsManager.js +41 -69
- package/Base/managers/ResponsiveOptionsManager.cjs +62 -0
- package/Base/managers/ResponsiveOptionsManager.d.ts +26 -0
- package/Base/managers/ResponsiveOptionsManager.js +37 -0
- package/Base/managers/ServicesManager.cjs +7 -10
- package/Base/managers/ServicesManager.d.ts +16 -19
- package/Base/managers/ServicesManager.js +7 -10
- package/Base/utils.d.ts +4 -4
- package/decorators/index.cjs +2 -0
- package/decorators/index.d.ts +1 -0
- package/decorators/index.js +6 -4
- package/decorators/withBreakpointManager.cjs +0 -1
- package/decorators/withBreakpointManager.d.ts +2 -2
- package/decorators/withBreakpointManager.js +0 -1
- package/decorators/withBreakpointObserver.cjs +1 -2
- package/decorators/withBreakpointObserver.d.ts +1 -1
- package/decorators/withBreakpointObserver.js +1 -2
- package/decorators/withDrag.d.ts +1 -1
- package/decorators/withExtraConfig.d.ts +1 -1
- package/decorators/withFreezedOptions.cjs +12 -3
- package/decorators/withFreezedOptions.d.ts +1 -1
- package/decorators/withFreezedOptions.js +13 -3
- package/decorators/withIntersectionObserver.cjs +0 -1
- package/decorators/withIntersectionObserver.d.ts +1 -1
- package/decorators/withIntersectionObserver.js +0 -1
- package/decorators/withMountWhenInView.cjs +0 -1
- package/decorators/withMountWhenInView.d.ts +1 -1
- package/decorators/withMountWhenInView.js +0 -1
- package/decorators/withResponsiveOptions.cjs +39 -0
- package/decorators/withResponsiveOptions.d.ts +8 -0
- package/decorators/withResponsiveOptions.js +14 -0
- package/decorators/withScrolledInView.cjs +58 -23
- package/decorators/withScrolledInView.d.ts +5 -3
- package/decorators/withScrolledInView.js +59 -24
- package/helpers/createApp.d.ts +3 -26
- package/helpers/getInstanceFromElement.cjs +32 -0
- package/helpers/getInstanceFromElement.d.ts +14 -0
- package/helpers/getInstanceFromElement.js +10 -0
- package/helpers/importOnInteraction.d.ts +3 -5
- package/helpers/importWhenIdle.d.ts +3 -5
- package/helpers/importWhenVisible.d.ts +4 -6
- package/helpers/index.cjs +2 -0
- package/helpers/index.d.ts +1 -0
- package/helpers/index.js +8 -6
- package/helpers/utils.d.ts +3 -4
- package/package.json +2 -1
- package/services/Service.d.ts +9 -9
- package/services/drag.cjs +0 -1
- package/services/drag.d.ts +3 -3
- package/services/drag.js +0 -1
- package/services/key.d.ts +1 -1
- package/services/load.d.ts +1 -1
- package/services/pointer.d.ts +1 -1
- package/services/raf.d.ts +1 -1
- package/services/resize.cjs +2 -2
- package/services/resize.d.ts +1 -1
- package/services/resize.js +2 -2
- package/services/scroll.cjs +3 -1
- package/services/scroll.d.ts +1 -1
- package/services/scroll.js +3 -1
- package/utils/collide/boundingRectToCircle.d.ts +5 -5
- package/utils/collide/collideCircleCircle.d.ts +4 -4
- package/utils/collide/collideCircleRect.d.ts +8 -8
- package/utils/collide/collidePointCircle.d.ts +6 -6
- package/utils/collide/collidePointRect.d.ts +7 -7
- package/utils/collide/collideRectRect.d.ts +5 -5
- package/utils/css/animate.cjs +190 -0
- package/utils/css/animate.d.ts +57 -0
- package/utils/css/animate.js +165 -0
- package/utils/css/classes.cjs +3 -3
- package/utils/css/classes.d.ts +10 -10
- package/utils/css/classes.js +3 -3
- package/utils/css/getOffsetSizes.cjs +47 -0
- package/utils/css/getOffsetSizes.d.ts +15 -0
- package/utils/css/getOffsetSizes.js +25 -0
- package/utils/css/index.cjs +6 -0
- package/utils/css/index.d.ts +3 -0
- package/utils/css/index.js +9 -4
- package/utils/css/matrix.d.ts +14 -15
- package/utils/css/styles.d.ts +2 -2
- package/utils/css/transform.cjs +91 -0
- package/utils/css/transform.d.ts +43 -0
- package/utils/css/transform.js +66 -0
- package/utils/css/transition.cjs +2 -0
- package/utils/css/transition.d.ts +2 -2
- package/utils/css/transition.js +2 -0
- package/utils/debounce.d.ts +4 -4
- package/utils/focusTrap.cjs +1 -1
- package/utils/focusTrap.d.ts +1 -0
- package/utils/focusTrap.js +1 -1
- package/utils/history.d.ts +13 -11
- package/utils/index.cjs +4 -0
- package/utils/index.d.ts +2 -0
- package/utils/index.js +4 -0
- package/utils/isDefined.cjs +28 -0
- package/utils/isDefined.d.ts +7 -0
- package/utils/isDefined.js +6 -0
- package/utils/isFunction.cjs +28 -0
- package/utils/isFunction.d.ts +7 -0
- package/utils/isFunction.js +6 -0
- package/utils/math/clamp.d.ts +1 -1
- package/utils/math/clamp01.d.ts +1 -1
- package/utils/math/damp.d.ts +6 -6
- package/utils/math/ease.d.ts +7 -7
- package/utils/math/index.cjs +2 -0
- package/utils/math/index.d.ts +1 -0
- package/utils/math/index.js +2 -0
- package/utils/math/inertiaFinalValue.d.ts +5 -5
- package/utils/math/lerp.d.ts +4 -4
- package/utils/math/map.d.ts +6 -6
- package/utils/math/round.d.ts +4 -4
- package/utils/memoize.d.ts +1 -1
- package/utils/nextFrame.d.ts +3 -4
- package/utils/nextMicrotask.d.ts +1 -1
- package/utils/nextTick.d.ts +1 -1
- package/utils/object/autoBind.d.ts +3 -3
- package/utils/object/getAllProperties.d.ts +3 -3
- package/utils/object/isObject.d.ts +1 -1
- package/utils/scrollTo.cjs +1 -1
- package/utils/scrollTo.d.ts +1 -1
- package/utils/scrollTo.js +1 -1
- package/utils/string/withLeadingCharacters.d.ts +3 -2
- package/utils/string/withLeadingSlash.d.ts +1 -1
- package/utils/string/withTrailingCharacters.d.ts +3 -2
- package/utils/string/withTrailingSlash.d.ts +1 -1
- package/utils/string/withoutLeadingCharacters.d.ts +3 -2
- package/utils/string/withoutLeadingCharactersRecursive.d.ts +3 -2
- package/utils/string/withoutLeadingSlash.d.ts +1 -1
- package/utils/string/withoutTrailingCharacters.d.ts +3 -2
- package/utils/string/withoutTrailingCharactersRecursive.d.ts +3 -2
- package/utils/string/withoutTrailingSlash.d.ts +1 -1
- package/utils/throttle.cjs +1 -1
- package/utils/throttle.d.ts +3 -3
- package/utils/throttle.js +1 -1
package/utils/css/matrix.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Format a CSS transform matrix with the given values.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
11
|
-
* @
|
|
12
|
-
*
|
|
4
|
+
* @param {Object} transform
|
|
5
|
+
* @param {number} [transform.scaleX=1] The scale on the x axis.
|
|
6
|
+
* @param {number} [transform.scaleY=1] The scale on the y axis.
|
|
7
|
+
* @param {number} [transform.skewX=0] The skew on the x axis.
|
|
8
|
+
* @param {number} [transform.skewY=0] The skew on the y axis.
|
|
9
|
+
* @param {number} [transform.translateX=0] The translate on the x axis.
|
|
10
|
+
* @param {number} [transform.translateY=0] The translate on the y axis.
|
|
11
|
+
* @returns {string} A formatted CSS matrix transform.
|
|
13
12
|
* @example
|
|
14
13
|
* ```js
|
|
15
14
|
* matrix({ scaleX: 0.5, scaleY: 0.5 });
|
|
@@ -17,10 +16,10 @@
|
|
|
17
16
|
* ```
|
|
18
17
|
*/
|
|
19
18
|
export default function matrix(transform: {
|
|
20
|
-
scaleX?: number
|
|
21
|
-
scaleY?: number
|
|
22
|
-
skewX?: number
|
|
23
|
-
skewY?: number
|
|
24
|
-
translateX?: number
|
|
25
|
-
translateY?: number
|
|
19
|
+
scaleX?: number;
|
|
20
|
+
scaleY?: number;
|
|
21
|
+
skewX?: number;
|
|
22
|
+
skewY?: number;
|
|
23
|
+
translateX?: number;
|
|
24
|
+
translateY?: number;
|
|
26
25
|
}): string;
|
package/utils/css/styles.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {HTMLElement} element The element to update.
|
|
5
5
|
* @param {Partial<CSSStyleDeclaration>} styles A string of class names.
|
|
6
|
-
* @
|
|
6
|
+
* @returns {void}
|
|
7
7
|
*/
|
|
8
8
|
export function add(element: HTMLElement, styles: Partial<CSSStyleDeclaration>): void;
|
|
9
9
|
/**
|
|
@@ -11,6 +11,6 @@ export function add(element: HTMLElement, styles: Partial<CSSStyleDeclaration>):
|
|
|
11
11
|
*
|
|
12
12
|
* @param {HTMLElement} element The element to update.
|
|
13
13
|
* @param {Partial<CSSStyleDeclaration>} styles A string of class names.
|
|
14
|
-
* @
|
|
14
|
+
* @returns {void}
|
|
15
15
|
*/
|
|
16
16
|
export function remove(element: HTMLElement, styles: Partial<CSSStyleDeclaration>): void;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
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
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// packages/js-toolkit/utils/css/transform.js
|
|
23
|
+
var transform_exports = {};
|
|
24
|
+
__export(transform_exports, {
|
|
25
|
+
TRANSFORM_PROPS: () => TRANSFORM_PROPS,
|
|
26
|
+
default: () => transform
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(transform_exports);
|
|
29
|
+
var import_isDefined = __toESM(require("../isDefined.cjs"), 1);
|
|
30
|
+
var TRANSFORM_PROPS = [
|
|
31
|
+
"x",
|
|
32
|
+
"y",
|
|
33
|
+
"z",
|
|
34
|
+
"rotate",
|
|
35
|
+
"rotateX",
|
|
36
|
+
"rotateY",
|
|
37
|
+
"rotateZ",
|
|
38
|
+
"scale",
|
|
39
|
+
"scaleX",
|
|
40
|
+
"scaleY",
|
|
41
|
+
"scaleZ",
|
|
42
|
+
"skew",
|
|
43
|
+
"skewX",
|
|
44
|
+
"skewY"
|
|
45
|
+
];
|
|
46
|
+
function transform(element, props) {
|
|
47
|
+
var _a, _b, _c;
|
|
48
|
+
let value = "";
|
|
49
|
+
if ((0, import_isDefined.default)(props.x) || (0, import_isDefined.default)(props.y) || (0, import_isDefined.default)(props.z)) {
|
|
50
|
+
value += `translate3d(${(_a = props.x) != null ? _a : 0}px, ${(_b = props.y) != null ? _b : 0}px, ${(_c = props.z) != null ? _c : 0}px) `;
|
|
51
|
+
}
|
|
52
|
+
if ((0, import_isDefined.default)(props.rotate)) {
|
|
53
|
+
value += `rotate(${props.rotate}deg) `;
|
|
54
|
+
} else {
|
|
55
|
+
if ((0, import_isDefined.default)(props.rotateX)) {
|
|
56
|
+
value += `rotateX(${props.rotateX}deg) `;
|
|
57
|
+
}
|
|
58
|
+
if ((0, import_isDefined.default)(props.rotateY)) {
|
|
59
|
+
value += `rotateY(${props.rotateY}deg) `;
|
|
60
|
+
}
|
|
61
|
+
if ((0, import_isDefined.default)(props.rotateZ)) {
|
|
62
|
+
value += `rotateZ(${props.rotateZ}deg) `;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if ((0, import_isDefined.default)(props.scale)) {
|
|
66
|
+
value += `scale(${props.scale}) `;
|
|
67
|
+
} else {
|
|
68
|
+
if ((0, import_isDefined.default)(props.scaleX)) {
|
|
69
|
+
value += `scaleX(${props.scaleX}) `;
|
|
70
|
+
}
|
|
71
|
+
if ((0, import_isDefined.default)(props.scaleY)) {
|
|
72
|
+
value += `scaleY(${props.scaleY}) `;
|
|
73
|
+
}
|
|
74
|
+
if ((0, import_isDefined.default)(props.scaleZ)) {
|
|
75
|
+
value += `scaleZ(${props.scaleZ}) `;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if ((0, import_isDefined.default)(props.skew)) {
|
|
79
|
+
value += `skew(${props.skew}deg) `;
|
|
80
|
+
} else {
|
|
81
|
+
if ((0, import_isDefined.default)(props.skewX)) {
|
|
82
|
+
value += `skewX(${props.skewX}deg) `;
|
|
83
|
+
}
|
|
84
|
+
if ((0, import_isDefined.default)(props.skewY)) {
|
|
85
|
+
value += `skewY(${props.skewY}deg) `;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
element.style.transform = value;
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate a CSS transform.
|
|
3
|
+
*
|
|
4
|
+
* @param {HTMLElement} element
|
|
5
|
+
* @param {TransformProps} props
|
|
6
|
+
* @returns {string}
|
|
7
|
+
*/
|
|
8
|
+
export default function transform(element: HTMLElement, props: TransformProps): string;
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {Partial<{
|
|
11
|
+
* x: number;
|
|
12
|
+
* y: number;
|
|
13
|
+
* z: number;
|
|
14
|
+
* rotate: number;
|
|
15
|
+
* rotateX: number;
|
|
16
|
+
* rotateY: number;
|
|
17
|
+
* rotateZ: number;
|
|
18
|
+
* scale: number;
|
|
19
|
+
* scaleX: number;
|
|
20
|
+
* scaleY: number;
|
|
21
|
+
* scaleZ: number;
|
|
22
|
+
* skew: number;
|
|
23
|
+
* skewX: number;
|
|
24
|
+
* skewY: number;
|
|
25
|
+
* }>} TransformProps
|
|
26
|
+
*/
|
|
27
|
+
export const TRANSFORM_PROPS: string[];
|
|
28
|
+
export type TransformProps = Partial<{
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
z: number;
|
|
32
|
+
rotate: number;
|
|
33
|
+
rotateX: number;
|
|
34
|
+
rotateY: number;
|
|
35
|
+
rotateZ: number;
|
|
36
|
+
scale: number;
|
|
37
|
+
scaleX: number;
|
|
38
|
+
scaleY: number;
|
|
39
|
+
scaleZ: number;
|
|
40
|
+
skew: number;
|
|
41
|
+
skewX: number;
|
|
42
|
+
skewY: number;
|
|
43
|
+
}>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import isDefined from "../isDefined.js";
|
|
2
|
+
const TRANSFORM_PROPS = [
|
|
3
|
+
"x",
|
|
4
|
+
"y",
|
|
5
|
+
"z",
|
|
6
|
+
"rotate",
|
|
7
|
+
"rotateX",
|
|
8
|
+
"rotateY",
|
|
9
|
+
"rotateZ",
|
|
10
|
+
"scale",
|
|
11
|
+
"scaleX",
|
|
12
|
+
"scaleY",
|
|
13
|
+
"scaleZ",
|
|
14
|
+
"skew",
|
|
15
|
+
"skewX",
|
|
16
|
+
"skewY"
|
|
17
|
+
];
|
|
18
|
+
function transform(element, props) {
|
|
19
|
+
var _a, _b, _c;
|
|
20
|
+
let value = "";
|
|
21
|
+
if (isDefined(props.x) || isDefined(props.y) || isDefined(props.z)) {
|
|
22
|
+
value += `translate3d(${(_a = props.x) != null ? _a : 0}px, ${(_b = props.y) != null ? _b : 0}px, ${(_c = props.z) != null ? _c : 0}px) `;
|
|
23
|
+
}
|
|
24
|
+
if (isDefined(props.rotate)) {
|
|
25
|
+
value += `rotate(${props.rotate}deg) `;
|
|
26
|
+
} else {
|
|
27
|
+
if (isDefined(props.rotateX)) {
|
|
28
|
+
value += `rotateX(${props.rotateX}deg) `;
|
|
29
|
+
}
|
|
30
|
+
if (isDefined(props.rotateY)) {
|
|
31
|
+
value += `rotateY(${props.rotateY}deg) `;
|
|
32
|
+
}
|
|
33
|
+
if (isDefined(props.rotateZ)) {
|
|
34
|
+
value += `rotateZ(${props.rotateZ}deg) `;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (isDefined(props.scale)) {
|
|
38
|
+
value += `scale(${props.scale}) `;
|
|
39
|
+
} else {
|
|
40
|
+
if (isDefined(props.scaleX)) {
|
|
41
|
+
value += `scaleX(${props.scaleX}) `;
|
|
42
|
+
}
|
|
43
|
+
if (isDefined(props.scaleY)) {
|
|
44
|
+
value += `scaleY(${props.scaleY}) `;
|
|
45
|
+
}
|
|
46
|
+
if (isDefined(props.scaleZ)) {
|
|
47
|
+
value += `scaleZ(${props.scaleZ}) `;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (isDefined(props.skew)) {
|
|
51
|
+
value += `skew(${props.skew}deg) `;
|
|
52
|
+
} else {
|
|
53
|
+
if (isDefined(props.skewX)) {
|
|
54
|
+
value += `skewX(${props.skewX}deg) `;
|
|
55
|
+
}
|
|
56
|
+
if (isDefined(props.skewY)) {
|
|
57
|
+
value += `skewY(${props.skewY}deg) `;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
element.style.transform = value;
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
TRANSFORM_PROPS,
|
|
65
|
+
transform as default
|
|
66
|
+
};
|
package/utils/css/transition.cjs
CHANGED
|
@@ -68,8 +68,10 @@ async function start(element, classesOrStyles) {
|
|
|
68
68
|
trs.isTransitioning = true;
|
|
69
69
|
setClassesOrStyles(element, classesOrStyles.from);
|
|
70
70
|
await (0, import_nextFrame.default)();
|
|
71
|
+
await (0, import_nextFrame.default)();
|
|
71
72
|
setClassesOrStyles(element, classesOrStyles.active);
|
|
72
73
|
await (0, import_nextFrame.default)();
|
|
74
|
+
await (0, import_nextFrame.default)();
|
|
73
75
|
}
|
|
74
76
|
async function next(element, classesOrStyles) {
|
|
75
77
|
const hasTransition = testTransition(element);
|
|
@@ -14,8 +14,8 @@ export function setClassesOrStyles(element: HTMLElement, classesOrStyles: Classe
|
|
|
14
14
|
*
|
|
15
15
|
* @param {HTMLElement} element The target element.
|
|
16
16
|
* @param {string|TransitionStyles} name The name of the transition or an object with the hooks classesOrStyles.
|
|
17
|
-
* @param {
|
|
18
|
-
* @
|
|
17
|
+
* @param {string} endMode Whether to remove or keep the `to` classes/styles
|
|
18
|
+
* @returns {Promise<void>} A promise resolving at the end of the transition.
|
|
19
19
|
*/
|
|
20
20
|
export default function transition(element: HTMLElement, name: string | TransitionStyles, endMode?: string): Promise<void>;
|
|
21
21
|
export type ClassesOrStyles = string | string[] | Partial<CSSStyleDeclaration>;
|
package/utils/css/transition.js
CHANGED
|
@@ -41,8 +41,10 @@ async function start(element, classesOrStyles) {
|
|
|
41
41
|
trs.isTransitioning = true;
|
|
42
42
|
setClassesOrStyles(element, classesOrStyles.from);
|
|
43
43
|
await nextFrame();
|
|
44
|
+
await nextFrame();
|
|
44
45
|
setClassesOrStyles(element, classesOrStyles.active);
|
|
45
46
|
await nextFrame();
|
|
47
|
+
await nextFrame();
|
|
46
48
|
}
|
|
47
49
|
async function next(element, classesOrStyles) {
|
|
48
50
|
const hasTransition = testTransition(element);
|
package/utils/debounce.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* will not be triggered. The function will be called after it stops
|
|
4
4
|
* being called for N milliseconds.
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
* @
|
|
6
|
+
* @param {(...args:any[]) => void} fn The function to call.
|
|
7
|
+
* @param {number} [delay=300] The delay in ms to wait before calling the function.
|
|
8
|
+
* @returns {(...args:any[]) => void} The debounced function.
|
|
9
9
|
*/
|
|
10
|
-
export default function debounce(fn: (...args: any[]) => void, delay?: number
|
|
10
|
+
export default function debounce(fn: (...args: any[]) => void, delay?: number): (...args: any[]) => void;
|
package/utils/focusTrap.cjs
CHANGED
|
@@ -63,7 +63,7 @@ function trap(element, event) {
|
|
|
63
63
|
event.preventDefault();
|
|
64
64
|
}
|
|
65
65
|
if (event.shiftKey && focusedItemIndex === 0) {
|
|
66
|
-
focusableChildren
|
|
66
|
+
focusableChildren.at(-1).focus();
|
|
67
67
|
event.preventDefault();
|
|
68
68
|
} else if (!event.shiftKey && focusedItemIndex === focusableChildren.length - 1) {
|
|
69
69
|
focusableChildren[0].focus();
|
package/utils/focusTrap.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export function trap(element: HTMLElement, event: KeyboardEvent): void;
|
|
|
14
14
|
export function untrap(): void;
|
|
15
15
|
/**
|
|
16
16
|
* Use a trap/untrap tabs logic.
|
|
17
|
+
* @returns {{ trap: trap, untrap: untrap, saveActiveElement: saveActiveElement }}
|
|
17
18
|
*/
|
|
18
19
|
export default function useFocusTrap(): {
|
|
19
20
|
trap: typeof trap;
|
package/utils/focusTrap.js
CHANGED
|
@@ -33,7 +33,7 @@ function trap(element, event) {
|
|
|
33
33
|
event.preventDefault();
|
|
34
34
|
}
|
|
35
35
|
if (event.shiftKey && focusedItemIndex === 0) {
|
|
36
|
-
focusableChildren
|
|
36
|
+
focusableChildren.at(-1).focus();
|
|
37
37
|
event.preventDefault();
|
|
38
38
|
} else if (!event.shiftKey && focusedItemIndex === focusableChildren.length - 1) {
|
|
39
39
|
focusableChildren[0].focus();
|
package/utils/history.d.ts
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Transform an object to an URLSearchParams instance.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @
|
|
4
|
+
* @param {Object} obj The object to convert.
|
|
5
|
+
* @param {string} defaultSearch A string of defaults search params.
|
|
6
|
+
* @returns {URLSearchParams}
|
|
7
7
|
*/
|
|
8
8
|
export function objectToURLSearchParams(obj: any, defaultSearch?: string): URLSearchParams;
|
|
9
9
|
/**
|
|
10
10
|
* Push a new state.
|
|
11
11
|
*
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
12
|
+
* @param {HistoryOptions} options The new state.
|
|
13
|
+
* @param {Object} [data] The data for the new state.
|
|
14
|
+
* @param {string} [title] The title for the new state.
|
|
15
|
+
* @returns {void}
|
|
15
16
|
*/
|
|
16
17
|
export function push(options: HistoryOptions, data?: any, title?: string): void;
|
|
17
18
|
/**
|
|
18
19
|
* Replace a new state.
|
|
19
20
|
*
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
21
|
+
* @param {HistoryOptions} options The new state.
|
|
22
|
+
* @param {Object} [data] The data for the new state.
|
|
23
|
+
* @param {string} [title] The title for the new state.
|
|
24
|
+
* @returns {void}
|
|
23
25
|
*/
|
|
24
26
|
export function replace(options: HistoryOptions, data?: any, title?: string): void;
|
|
25
27
|
export type HistoryOptions = {
|
|
26
|
-
path?: string
|
|
28
|
+
path?: string;
|
|
27
29
|
search?: URLSearchParams | {
|
|
28
30
|
[key: string]: unknown;
|
|
29
31
|
};
|
|
30
|
-
hash?: string
|
|
32
|
+
hash?: string;
|
|
31
33
|
};
|
package/utils/index.cjs
CHANGED
|
@@ -27,6 +27,8 @@ __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,
|
|
30
32
|
keyCodes: () => import_keyCodes.default,
|
|
31
33
|
memoize: () => import_memoize.default,
|
|
32
34
|
nextFrame: () => import_nextFrame.default,
|
|
@@ -46,6 +48,8 @@ var import_nextTick = __toESM(require("./nextTick.cjs"), 1);
|
|
|
46
48
|
var import_nextMicrotask = __toESM(require("./nextMicrotask.cjs"), 1);
|
|
47
49
|
var import_throttle = __toESM(require("./throttle.cjs"), 1);
|
|
48
50
|
var import_scrollTo = __toESM(require("./scrollTo.cjs"), 1);
|
|
51
|
+
var import_isDefined = __toESM(require("./isDefined.cjs"), 1);
|
|
52
|
+
var import_isFunction = __toESM(require("./isFunction.cjs"), 1);
|
|
49
53
|
__reExport(utils_exports, require("./css/index.cjs"), module.exports);
|
|
50
54
|
var import_history = require("./history.cjs");
|
|
51
55
|
__reExport(utils_exports, require("./collide/index.cjs"), module.exports);
|
package/utils/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ 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 { default as isDefined } from "./isDefined.js";
|
|
11
|
+
export { default as isFunction } from "./isFunction.js";
|
|
10
12
|
export * from "./css/index.js";
|
|
11
13
|
export * from "./collide/index.js";
|
|
12
14
|
export * from "./math/index.js";
|
package/utils/index.js
CHANGED
|
@@ -7,6 +7,8 @@ import { default as default7 } from "./nextTick.js";
|
|
|
7
7
|
import { default as default8 } from "./nextMicrotask.js";
|
|
8
8
|
import { default as default9 } from "./throttle.js";
|
|
9
9
|
import { default as default10 } from "./scrollTo.js";
|
|
10
|
+
import { default as default11 } from "./isDefined.js";
|
|
11
|
+
import { default as default12 } from "./isFunction.js";
|
|
10
12
|
export * from "./css/index.js";
|
|
11
13
|
import {
|
|
12
14
|
objectToURLSearchParams,
|
|
@@ -21,6 +23,8 @@ export {
|
|
|
21
23
|
default3 as focusTrap,
|
|
22
24
|
push as historyPush,
|
|
23
25
|
replace as historyReplace,
|
|
26
|
+
default11 as isDefined,
|
|
27
|
+
default12 as isFunction,
|
|
24
28
|
default4 as keyCodes,
|
|
25
29
|
default5 as memoize,
|
|
26
30
|
default6 as nextFrame,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/js-toolkit/utils/isDefined.js
|
|
20
|
+
var isDefined_exports = {};
|
|
21
|
+
__export(isDefined_exports, {
|
|
22
|
+
default: () => isDefined
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(isDefined_exports);
|
|
25
|
+
function isDefined(value) {
|
|
26
|
+
return typeof value !== "undefined";
|
|
27
|
+
}
|
|
28
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/js-toolkit/utils/isFunction.js
|
|
20
|
+
var isFunction_exports = {};
|
|
21
|
+
__export(isFunction_exports, {
|
|
22
|
+
default: () => isFunction
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(isFunction_exports);
|
|
25
|
+
function isFunction(fn) {
|
|
26
|
+
return typeof fn === "function";
|
|
27
|
+
}
|
|
28
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/math/clamp.d.ts
CHANGED
package/utils/math/clamp01.d.ts
CHANGED
package/utils/math/damp.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Get the next damped value for a given factor.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
* @
|
|
4
|
+
* @param {number} targetValue The final value.
|
|
5
|
+
* @param {number} currentValue The current value.
|
|
6
|
+
* @param {number} [factor=0.5] The factor used to reach the target value.
|
|
7
|
+
* @param {number} [precision=0.01] The precision used to calculate the latest value.
|
|
8
|
+
* @returns {number} The next value.
|
|
9
9
|
*/
|
|
10
|
-
export default function damp(targetValue: number, currentValue: number, factor?: number
|
|
10
|
+
export default function damp(targetValue: number, currentValue: number, factor?: number, precision?: number): number;
|
package/utils/math/ease.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export function createEaseOut(easeIn: EasingFunction): EasingFunction;
|
|
|
12
12
|
* Create an in-out easing function.
|
|
13
13
|
*
|
|
14
14
|
* @param {EasingFunction} easeIn The ease in function.
|
|
15
|
-
* @
|
|
15
|
+
* @returns {EasingFunction} The in-out function.
|
|
16
16
|
*/
|
|
17
17
|
export function createEaseInOut(easeIn: EasingFunction): EasingFunction;
|
|
18
18
|
/**
|
|
@@ -23,42 +23,42 @@ export function easeInQuad(progress: number): number;
|
|
|
23
23
|
* Ease in cubic.
|
|
24
24
|
*
|
|
25
25
|
* @param {number} progress Progress value betwen 0 and 1.
|
|
26
|
-
* @
|
|
26
|
+
* @returns {number} Eased value between 0 and 1.
|
|
27
27
|
*/
|
|
28
28
|
export function easeInCubic(progress: number): number;
|
|
29
29
|
/**
|
|
30
30
|
* Ease in quart.
|
|
31
31
|
*
|
|
32
32
|
* @param {number} progress Progress value betwen 0 and 1.
|
|
33
|
-
* @
|
|
33
|
+
* @returns {number} Eased value between 0 and 1.
|
|
34
34
|
*/
|
|
35
35
|
export function easeInQuart(progress: number): number;
|
|
36
36
|
/**
|
|
37
37
|
* Ease in quint.
|
|
38
38
|
*
|
|
39
39
|
* @param {number} progress Progress value betwen 0 and 1.
|
|
40
|
-
* @
|
|
40
|
+
* @returns {number} Eased value between 0 and 1.
|
|
41
41
|
*/
|
|
42
42
|
export function easeInQuint(progress: number): number;
|
|
43
43
|
/**
|
|
44
44
|
* Ease in sine.
|
|
45
45
|
*
|
|
46
46
|
* @param {number} progress Progress value betwen 0 and 1.
|
|
47
|
-
* @
|
|
47
|
+
* @returns {number} Eased value between 0 and 1.
|
|
48
48
|
*/
|
|
49
49
|
export function easeInSine(progress: number): number;
|
|
50
50
|
/**
|
|
51
51
|
* Ease in circ.
|
|
52
52
|
*
|
|
53
53
|
* @param {number} progress Progress value betwen 0 and 1.
|
|
54
|
-
* @
|
|
54
|
+
* @returns {number} Eased value between 0 and 1.
|
|
55
55
|
*/
|
|
56
56
|
export function easeInCirc(progress: number): number;
|
|
57
57
|
/**
|
|
58
58
|
* Ease in exponential.
|
|
59
59
|
*
|
|
60
60
|
* @param {number} progress Progress value betwen 0 and 1.
|
|
61
|
-
* @
|
|
61
|
+
* @returns {number} Eased value between 0 and 1.
|
|
62
62
|
*/
|
|
63
63
|
export function easeInExpo(progress: number): number;
|
|
64
64
|
export function easeOutQuad(progress: number): number;
|
package/utils/math/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ __export(math_exports, {
|
|
|
26
26
|
clamp: () => import_clamp.default,
|
|
27
27
|
clamp01: () => import_clamp01.default,
|
|
28
28
|
damp: () => import_damp.default,
|
|
29
|
+
ease: () => ease,
|
|
29
30
|
inertiaFinalValue: () => import_inertiaFinalValue.default,
|
|
30
31
|
lerp: () => import_lerp.default,
|
|
31
32
|
map: () => import_map.default,
|
|
@@ -40,4 +41,5 @@ var import_lerp = __toESM(require("./lerp.cjs"), 1);
|
|
|
40
41
|
var import_map = __toESM(require("./map.cjs"), 1);
|
|
41
42
|
var import_round = __toESM(require("./round.cjs"), 1);
|
|
42
43
|
__reExport(math_exports, require("./ease.cjs"), module.exports);
|
|
44
|
+
var ease = __toESM(require("./ease.cjs"), 1);
|
|
43
45
|
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/math/index.d.ts
CHANGED
package/utils/math/index.js
CHANGED
|
@@ -6,10 +6,12 @@ import { default as default6 } from "./lerp.js";
|
|
|
6
6
|
import { default as default7 } from "./map.js";
|
|
7
7
|
import { default as default8 } from "./round.js";
|
|
8
8
|
export * from "./ease.js";
|
|
9
|
+
import * as ease from "./ease.js";
|
|
9
10
|
export {
|
|
10
11
|
default2 as clamp,
|
|
11
12
|
default3 as clamp01,
|
|
12
13
|
default4 as damp,
|
|
14
|
+
ease,
|
|
13
15
|
default5 as inertiaFinalValue,
|
|
14
16
|
default6 as lerp,
|
|
15
17
|
default7 as map,
|