@studiometa/js-toolkit 2.0.0-rc.2 → 2.0.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 +1 -2
- package/Base/index.d.ts +25 -26
- package/Base/index.js +1 -2
- package/Base/managers/ChildrenManager.d.ts +2 -2
- package/Base/managers/EventsManager.d.ts +13 -20
- package/Base/managers/OptionsManager.cjs +0 -1
- package/Base/managers/OptionsManager.d.ts +13 -10
- package/Base/managers/OptionsManager.js +0 -1
- package/Base/managers/RefsManager.d.ts +4 -4
- package/Base/managers/ServicesManager.cjs +3 -0
- package/Base/managers/ServicesManager.d.ts +14 -8
- package/Base/managers/ServicesManager.js +3 -0
- package/Base/utils.d.ts +4 -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.d.ts +1 -1
- 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/withScrolledInView.d.ts +1 -1
- 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 +1 -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.d.ts +1 -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/classes.cjs +3 -3
- package/utils/css/classes.d.ts +10 -10
- package/utils/css/classes.js +3 -3
- package/utils/css/matrix.d.ts +14 -15
- package/utils/css/styles.d.ts +2 -2
- package/utils/css/transition.d.ts +2 -2
- 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/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/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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {Object} Rect
|
|
3
|
-
* @property {
|
|
4
|
-
* @property {
|
|
5
|
-
* @property {
|
|
6
|
-
* @property {
|
|
3
|
+
* @property {number} x Rectangle's x position
|
|
4
|
+
* @property {number} y Rectangle's y position
|
|
5
|
+
* @property {number} width Rectangle's width
|
|
6
|
+
* @property {number} height Rectangle's height
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
9
|
* Test if a rectangle collides with another rectangle.
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @param {Rect} rect1 Rectangle 1
|
|
13
13
|
* @param {Rect} rect2 Rectangle 2
|
|
14
|
-
* @
|
|
14
|
+
* @returns {boolean} Are the sides of one rectangle touching the other ?
|
|
15
15
|
*/
|
|
16
16
|
export default function collideRectRect(rect1: Rect, rect2: Rect): boolean;
|
|
17
17
|
export type Rect = {
|
package/utils/css/classes.cjs
CHANGED
|
@@ -24,7 +24,7 @@ __export(classes_exports, {
|
|
|
24
24
|
toggle: () => toggle
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(classes_exports);
|
|
27
|
-
function setClasses(element, classNames, method
|
|
27
|
+
function setClasses(element, classNames, method, forceToggle) {
|
|
28
28
|
if (!element || !classNames) {
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
@@ -36,12 +36,12 @@ function setClasses(element, classNames, method = "add", forceToggle = void 0) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
function add(element, classNames) {
|
|
39
|
-
setClasses(element, classNames);
|
|
39
|
+
setClasses(element, classNames, "add");
|
|
40
40
|
}
|
|
41
41
|
function remove(element, classNames) {
|
|
42
42
|
setClasses(element, classNames, "remove");
|
|
43
43
|
}
|
|
44
|
-
function toggle(element, classNames, force
|
|
44
|
+
function toggle(element, classNames, force) {
|
|
45
45
|
setClasses(element, classNames, "toggle", force);
|
|
46
46
|
}
|
|
47
47
|
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/css/classes.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Add class names to an element.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @
|
|
4
|
+
* @param {HTMLElement} element The element to update.
|
|
5
|
+
* @param {string|string[]} classNames A string of class names.
|
|
6
|
+
* @returns {void}
|
|
7
7
|
*/
|
|
8
8
|
export function add(element: HTMLElement, classNames: string | string[]): void;
|
|
9
9
|
/**
|
|
10
10
|
* Remove class names from an element.
|
|
11
11
|
*
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
14
|
-
* @
|
|
12
|
+
* @param {HTMLElement} element The element to update.
|
|
13
|
+
* @param {string|string[]} classNames A string of class names.
|
|
14
|
+
* @returns {void}
|
|
15
15
|
*/
|
|
16
16
|
export function remove(element: HTMLElement, classNames: string | string[]): void;
|
|
17
17
|
/**
|
|
18
18
|
* Toggle class names from an element.
|
|
19
19
|
*
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
23
|
-
* @
|
|
20
|
+
* @param {HTMLElement} element The element to update.
|
|
21
|
+
* @param {string|string[]} classNames A string of class names.
|
|
22
|
+
* @param {boolean} [force] Force toggle?
|
|
23
|
+
* @returns {void}
|
|
24
24
|
*/
|
|
25
25
|
export function toggle(element: HTMLElement, classNames: string | string[], force?: boolean): void;
|
package/utils/css/classes.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function setClasses(element, classNames, method
|
|
1
|
+
function setClasses(element, classNames, method, forceToggle) {
|
|
2
2
|
if (!element || !classNames) {
|
|
3
3
|
return;
|
|
4
4
|
}
|
|
@@ -10,12 +10,12 @@ function setClasses(element, classNames, method = "add", forceToggle = void 0) {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
function add(element, classNames) {
|
|
13
|
-
setClasses(element, classNames);
|
|
13
|
+
setClasses(element, classNames, "add");
|
|
14
14
|
}
|
|
15
15
|
function remove(element, classNames) {
|
|
16
16
|
setClasses(element, classNames, "remove");
|
|
17
17
|
}
|
|
18
|
-
function toggle(element, classNames, force
|
|
18
|
+
function toggle(element, classNames, force) {
|
|
19
19
|
setClasses(element, classNames, "toggle", force);
|
|
20
20
|
}
|
|
21
21
|
export {
|
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;
|
|
@@ -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/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/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;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Get the final damped value for a given factor.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @
|
|
4
|
+
* @param {number} initialValue The final value.
|
|
5
|
+
* @param {number} initialDelta The current value.
|
|
6
|
+
* @param {number} [dampFactor=0.85] The speed to reach the target value.
|
|
7
|
+
* @returns {number} The next value.
|
|
8
8
|
*/
|
|
9
|
-
export default function inertiaFinalValue(initialValue: number, initialDelta: number, dampFactor?: number
|
|
9
|
+
export default function inertiaFinalValue(initialValue: number, initialDelta: number, dampFactor?: number): number;
|
package/utils/math/lerp.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Interpolate the ratio between a given interval.
|
|
3
3
|
*
|
|
4
|
-
* @param {
|
|
5
|
-
* @param {
|
|
6
|
-
* @param {
|
|
7
|
-
* @
|
|
4
|
+
* @param {number} min The interval minimum value.
|
|
5
|
+
* @param {number} max The inverval maximum value.
|
|
6
|
+
* @param {number} ratio The ratio to get.
|
|
7
|
+
* @returns {number} The value between min and max corresponding to ratio.
|
|
8
8
|
*/
|
|
9
9
|
export default function lerp(min: number, max: number, ratio: number): number;
|
package/utils/math/map.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Maps the value from one range of [inputMin..inputMax] to another range of [outputMin..outputMax].
|
|
3
3
|
*
|
|
4
|
-
* @param {
|
|
5
|
-
* @param {
|
|
6
|
-
* @param {
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {
|
|
9
|
-
* @
|
|
4
|
+
* @param {number} value The value to map.
|
|
5
|
+
* @param {number} inputMin The input's minimum value.
|
|
6
|
+
* @param {number} inputMax The input's maximum value.
|
|
7
|
+
* @param {number} outputMin The output's minimum value.
|
|
8
|
+
* @param {number} outputMax The output's maximum value.
|
|
9
|
+
* @returns {number} The input value mapped to the output range.
|
|
10
10
|
*/
|
|
11
11
|
export default function map(value: number, inputMin: number, inputMax: number, outputMin: number, outputMax: number): number;
|
package/utils/math/round.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Round a value with a given number of decimals.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @
|
|
4
|
+
* @param {number} value The number to round.
|
|
5
|
+
* @param {number} [decimals=0] The number of decimals to keep.
|
|
6
|
+
* @returns {number} A rounded number to the given decimals length.
|
|
7
7
|
*/
|
|
8
|
-
export default function round(value: number, decimals?: number
|
|
8
|
+
export default function round(value: number, decimals?: number): number;
|
package/utils/memoize.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* @template {(...args:any) => any} T
|
|
16
16
|
* @param {T} fn
|
|
17
17
|
* @param {MemorizeOptions} options
|
|
18
|
-
* @
|
|
18
|
+
* @returns {(...args:Parameters<T>) => ReturnType<T>}
|
|
19
19
|
*/
|
|
20
20
|
export default function memoize<T extends (...args: any) => any>(fn: T, { maxAge, cacheKey, cache }?: MemorizeOptions): (...args: Parameters<T>) => ReturnType<T>;
|
|
21
21
|
export type MemorizeCache = {
|
package/utils/nextFrame.d.ts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* RequestAnimation frame polyfill.
|
|
3
3
|
* @see https://github.com/vuejs/vue/blob/ec78fc8b6d03e59da669be1adf4b4b5abf670a34/dist/vue.runtime.esm.js#L7355
|
|
4
|
-
* @
|
|
4
|
+
* @returns {(handler: Function) => number}
|
|
5
5
|
*/
|
|
6
6
|
export function getRaf(): (handler: Function) => number;
|
|
7
7
|
/**
|
|
8
8
|
* Get a function to cancel the method returned by `getRaf()`.
|
|
9
9
|
*
|
|
10
|
-
* @
|
|
10
|
+
* @returns {(id:number) => void}
|
|
11
11
|
*/
|
|
12
12
|
export function getCancelRaf(): (id: number) => void;
|
|
13
13
|
/**
|
|
14
14
|
* Wait for the next frame to execute a function.
|
|
15
15
|
*
|
|
16
16
|
* @template {() => any} T
|
|
17
|
-
* @param {T
|
|
17
|
+
* @param {T} [fn] The callback function to execute.
|
|
18
18
|
* @returns {Promise<T extends Function ? ReturnType<T> : undefined>} A Promise resolving when the next frame is reached.
|
|
19
|
-
*
|
|
20
19
|
* @example
|
|
21
20
|
* ```js
|
|
22
21
|
* nextFrame(() => console.log('hello world'));
|
package/utils/nextMicrotask.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Wait for the next microtask.
|
|
3
3
|
*
|
|
4
4
|
* @template {() => any} T
|
|
5
|
-
* @param {T
|
|
5
|
+
* @param {T} [fn]
|
|
6
6
|
* @returns {Promise<T extends Function ? ReturnType<T> : undefined>}
|
|
7
7
|
*/
|
|
8
8
|
export default function nextMicrotask<T extends () => any>(fn?: T): Promise<T extends Function ? ReturnType<T> : undefined>;
|
package/utils/nextTick.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Wait for the next tick.
|
|
3
3
|
*
|
|
4
4
|
* @template {() => any} T
|
|
5
|
-
* @param {T
|
|
5
|
+
* @param {T} [fn]
|
|
6
6
|
* @returns {Promise<T extends Function ? ReturnType<T> : undefined>}
|
|
7
7
|
*/
|
|
8
8
|
export default function nextTick<T extends () => any>(fn?: T): Promise<T extends Function ? ReturnType<T> : undefined>;
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {Object} instance The instance.
|
|
5
5
|
* @param {Object} options Define specific methods to include or exlude.
|
|
6
|
-
* @param {Array<
|
|
7
|
-
* @param {Array<
|
|
8
|
-
* @
|
|
6
|
+
* @param {Array<string | RegExp>} [options.include] Methods to include.
|
|
7
|
+
* @param {Array<string | RegExp>} [options.exclude] Methods to exclude.
|
|
8
|
+
* @returns {Object} The instance.
|
|
9
9
|
*/
|
|
10
10
|
export default function autoBind(instance: any, options: {
|
|
11
11
|
include?: Array<string | RegExp>;
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {Object} object
|
|
5
5
|
* The object to get the propeties from.
|
|
6
|
-
* @param {Array
|
|
6
|
+
* @param {Array} [props=[]]
|
|
7
7
|
* The already existing properties.
|
|
8
8
|
* @param {(name:string, proto:any) => boolean} testFn
|
|
9
|
-
* @
|
|
9
|
+
* @returns {Array<[string, Object]>} An array of properties and the prototype they belong to.
|
|
10
10
|
*/
|
|
11
|
-
export default function getAllProperties(object: any, props?: any[]
|
|
11
|
+
export default function getAllProperties(object: any, props?: any[], testFn?: (name: string, proto: any) => boolean): Array<[string, any]>;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Test if the given value is an object.
|
|
3
3
|
*
|
|
4
4
|
* @param {*} value The value to test.
|
|
5
|
-
* @
|
|
5
|
+
* @returns {boolean} Whether or not the value is an object.
|
|
6
6
|
*/
|
|
7
7
|
export default function isObject(value: any): boolean;
|
package/utils/scrollTo.cjs
CHANGED
|
@@ -39,7 +39,7 @@ function scrollTo(selectorElement, { offset = 0, dampFactor = 0.2 } = {}) {
|
|
|
39
39
|
const sizes = targetElement.getBoundingClientRect();
|
|
40
40
|
const scrollMargin = getComputedStyle(targetElement).scrollMarginTop || "0";
|
|
41
41
|
const max = document.documentElement.scrollHeight - window.innerHeight;
|
|
42
|
-
let scrollTarget = sizes.top + window.pageYOffset - parseInt(scrollMargin, 10) - offset;
|
|
42
|
+
let scrollTarget = sizes.top + window.pageYOffset - Number.parseInt(scrollMargin, 10) - offset;
|
|
43
43
|
if (scrollTarget > max) {
|
|
44
44
|
scrollTarget = max;
|
|
45
45
|
}
|
package/utils/scrollTo.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {HTMLElement|string} selectorElement The target element.
|
|
5
5
|
* @param {{ offset?: number, dampFactor?: number }} [options] Options for the scroll.
|
|
6
|
-
* @
|
|
6
|
+
* @returns {Promise<number>} A promising resolving with the target scroll position.
|
|
7
7
|
*/
|
|
8
8
|
export default function scrollTo(selectorElement: HTMLElement | string, { offset, dampFactor }?: {
|
|
9
9
|
offset?: number;
|
package/utils/scrollTo.js
CHANGED
|
@@ -12,7 +12,7 @@ function scrollTo(selectorElement, { offset = 0, dampFactor = 0.2 } = {}) {
|
|
|
12
12
|
const sizes = targetElement.getBoundingClientRect();
|
|
13
13
|
const scrollMargin = getComputedStyle(targetElement).scrollMarginTop || "0";
|
|
14
14
|
const max = document.documentElement.scrollHeight - window.innerHeight;
|
|
15
|
-
let scrollTarget = sizes.top + window.pageYOffset - parseInt(scrollMargin, 10) - offset;
|
|
15
|
+
let scrollTarget = sizes.top + window.pageYOffset - Number.parseInt(scrollMargin, 10) - offset;
|
|
16
16
|
if (scrollTarget > max) {
|
|
17
17
|
scrollTarget = max;
|
|
18
18
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Add the given characters to the start of the given string.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
4
|
+
* @param {string} string The string to modify.
|
|
5
|
+
* @param {string} characters The characters to add to the start.
|
|
6
|
+
* @returns {string}
|
|
6
7
|
*/
|
|
7
8
|
export default function withLeadingCharacters(string: string, characters: string): string;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Add a leading slash to a string.
|
|
3
3
|
*
|
|
4
4
|
* @param {string} string The string to modify.
|
|
5
|
-
* @
|
|
5
|
+
* @returns {string} The string with a leading slash.
|
|
6
6
|
*/
|
|
7
7
|
export default function withLeadingSlash(string: string): string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Add the given characters to the end of the given string.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
4
|
+
* @param {string} string The string to modify.
|
|
5
|
+
* @param {string} characters The characters to add to the end.
|
|
6
|
+
* @returns {string}
|
|
6
7
|
*/
|
|
7
8
|
export default function withTrailingCharacters(string: string, characters: string): string;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Add a trailing slash to a string.
|
|
3
3
|
*
|
|
4
4
|
* @param {string} string The string to modify.
|
|
5
|
-
* @
|
|
5
|
+
* @returns {string} The string with a trailing slash.
|
|
6
6
|
*/
|
|
7
7
|
export default function withTrailingSlash(string: string): string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Remove the given characters from the start of the given string.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
4
|
+
* @param {string} string The string to modify.
|
|
5
|
+
* @param {string} characters The characters to remove from the start.
|
|
6
|
+
* @returns {string}
|
|
6
7
|
*/
|
|
7
8
|
export default function withoutLeadingCharacters(string: string, characters: string): string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Remove the given characters to the start of the given string recursively.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
4
|
+
* @param {string} string The string to modify.
|
|
5
|
+
* @param {string} characters The characters to add to the start.
|
|
6
|
+
* @returns {string}
|
|
6
7
|
*/
|
|
7
8
|
export default function withoutLeadingCharactersRecursive(string: string, characters: string): string;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Remove the leading slash from a string.
|
|
3
3
|
*
|
|
4
4
|
* @param {string} string The string to modify.
|
|
5
|
-
* @
|
|
5
|
+
* @returns {string} The string without leading slash.
|
|
6
6
|
*/
|
|
7
7
|
export default function withoutLeadingSlash(string: string): string;
|