@studiometa/js-toolkit 2.3.0 → 2.4.2
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 +51 -43
- package/Base/index.d.ts +23 -18
- package/Base/index.js +70 -59
- package/Base/managers/AbstractManager.cjs +23 -13
- package/Base/managers/AbstractManager.d.ts +3 -3
- package/Base/managers/AbstractManager.js +24 -13
- package/Base/managers/ChildrenManager.cjs +21 -5
- package/Base/managers/ChildrenManager.d.ts +1 -1
- package/Base/managers/ChildrenManager.js +18 -4
- package/Base/managers/EventsManager.cjs +62 -44
- package/Base/managers/EventsManager.d.ts +3 -3
- package/Base/managers/EventsManager.js +59 -43
- package/Base/managers/OptionsManager.cjs +32 -12
- package/Base/managers/OptionsManager.d.ts +2 -2
- package/Base/managers/OptionsManager.js +29 -11
- package/Base/managers/RefsManager.cjs +19 -5
- package/Base/managers/RefsManager.js +15 -4
- package/Base/managers/ResponsiveOptionsManager.cjs +4 -1
- package/Base/managers/ServicesManager.cjs +21 -6
- package/Base/managers/ServicesManager.d.ts +1 -1
- package/Base/managers/ServicesManager.js +18 -5
- package/Base/utils.cjs +5 -1
- package/Base/utils.d.ts +2 -2
- package/Base/utils.js +5 -1
- package/README.md +3 -3
- package/decorators/index.cjs +4 -1
- package/decorators/withBreakpointManager.cjs +4 -1
- package/decorators/withBreakpointManager.d.ts +1 -1
- package/decorators/withBreakpointObserver.cjs +26 -14
- package/decorators/withBreakpointObserver.d.ts +1 -1
- package/decorators/withBreakpointObserver.js +23 -13
- package/decorators/withDrag.cjs +19 -8
- package/decorators/withDrag.d.ts +2 -4
- package/decorators/withDrag.js +16 -7
- package/decorators/withExtraConfig.cjs +12 -4
- package/decorators/withExtraConfig.js +9 -3
- package/decorators/withFreezedOptions.cjs +9 -1
- package/decorators/withFreezedOptions.js +10 -1
- package/decorators/withIntersectionObserver.cjs +25 -17
- package/decorators/withIntersectionObserver.d.ts +1 -1
- package/decorators/withIntersectionObserver.js +26 -17
- package/decorators/withMountWhenInView.cjs +30 -22
- package/decorators/withMountWhenInView.d.ts +1 -1
- package/decorators/withMountWhenInView.js +31 -22
- package/decorators/withResponsiveOptions.cjs +4 -1
- package/decorators/withScrolledInView.cjs +99 -48
- package/decorators/withScrolledInView.d.ts +27 -6
- package/decorators/withScrolledInView.js +96 -47
- package/decorators/withVue2.cjs +15 -10
- package/decorators/withVue2.d.ts +1 -1
- package/decorators/withVue2.js +16 -10
- package/helpers/getDirectChildren.cjs +46 -0
- package/helpers/getDirectChildren.d.ts +24 -0
- package/helpers/getDirectChildren.js +24 -0
- package/helpers/getInstanceFromElement.cjs +2 -1
- package/helpers/getInstanceFromElement.js +2 -1
- package/helpers/importOnInteraction.cjs +1 -1
- package/helpers/importOnInteraction.d.ts +2 -2
- package/helpers/importOnInteraction.js +1 -1
- package/helpers/importWhenIdle.cjs +10 -6
- package/helpers/importWhenIdle.js +10 -6
- package/helpers/importWhenVisible.cjs +1 -1
- package/helpers/importWhenVisible.d.ts +2 -2
- package/helpers/importWhenVisible.js +1 -1
- package/helpers/index.cjs +6 -1
- package/helpers/index.d.ts +1 -0
- package/helpers/index.js +1 -0
- package/index.cjs +4 -1
- package/package.json +2 -2
- package/services/drag.cjs +4 -1
- package/services/index.cjs +4 -1
- package/services/index.d.ts +7 -0
- package/services/key.cjs +5 -2
- package/services/key.js +1 -1
- package/services/pointer.cjs +3 -2
- package/services/pointer.js +3 -2
- package/services/resize.cjs +4 -1
- package/services/scroll.cjs +4 -1
- package/utils/collide/index.cjs +4 -1
- package/utils/css/animate.cjs +27 -12
- package/utils/css/animate.js +23 -11
- package/utils/css/index.cjs +4 -1
- package/utils/css/matrix.cjs +2 -1
- package/utils/css/matrix.js +2 -1
- package/utils/css/transform.cjs +2 -1
- package/utils/css/transform.js +2 -1
- package/utils/css/transition.cjs +11 -6
- package/utils/css/transition.js +8 -5
- package/utils/focusTrap.cjs +4 -1
- package/utils/history.cjs +4 -1
- package/utils/history.js +4 -1
- package/utils/index.cjs +4 -1
- package/utils/math/clamp01.cjs +4 -1
- package/utils/math/index.cjs +4 -1
- package/utils/math/inertiaFinalValue.cjs +4 -1
- package/utils/nextTick.cjs +5 -3
- package/utils/nextTick.js +5 -3
- package/utils/object/autoBind.cjs +4 -1
- package/utils/object/index.cjs +4 -1
- package/utils/scrollTo.cjs +4 -1
- package/utils/string/index.cjs +4 -1
- package/utils/string/withLeadingCharacters.cjs +4 -1
- package/utils/string/withLeadingSlash.cjs +4 -1
- package/utils/string/withTrailingCharacters.cjs +4 -1
- package/utils/string/withTrailingSlash.cjs +4 -1
- package/utils/string/withoutLeadingCharactersRecursive.cjs +4 -1
- package/utils/string/withoutLeadingSlash.cjs +4 -1
- package/utils/string/withoutTrailingCharactersRecursive.cjs +4 -1
- package/utils/string/withoutTrailingSlash.cjs +4 -1
- package/utils/tween.cjs +6 -2
- package/utils/tween.js +2 -1
package/decorators/withVue2.cjs
CHANGED
|
@@ -2,6 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
6
|
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -15,6 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
16
|
return to;
|
|
16
17
|
};
|
|
17
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __publicField = (obj, key, value) => {
|
|
20
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
18
23
|
|
|
19
24
|
// packages/js-toolkit/decorators/withVue2.js
|
|
20
25
|
var withVue2_exports = {};
|
|
@@ -24,17 +29,13 @@ __export(withVue2_exports, {
|
|
|
24
29
|
module.exports = __toCommonJS(withVue2_exports);
|
|
25
30
|
var import_utils = require("../utils/index.cjs");
|
|
26
31
|
var withVue2_default = (BaseClass, Vue) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
...BaseClass.config,
|
|
30
|
-
name: `${BaseClass.config.name}WithVue`,
|
|
31
|
-
refs: [...BaseClass.config?.refs ?? [], "vue"]
|
|
32
|
-
};
|
|
33
|
-
$vue;
|
|
34
|
-
static vueConfig;
|
|
32
|
+
var _a, _b, _c;
|
|
33
|
+
return _c = class extends BaseClass {
|
|
35
34
|
constructor(element) {
|
|
35
|
+
var _a2;
|
|
36
36
|
super(element);
|
|
37
|
-
|
|
37
|
+
__publicField(this, "$vue");
|
|
38
|
+
const vueConfig = (_a2 = this.vueConfig) != null ? _a2 : this.constructor.vueConfig;
|
|
38
39
|
if (!vueConfig) {
|
|
39
40
|
if (import_utils.isDev) {
|
|
40
41
|
throw new Error("[withVue] You must define a `vueConfig` object.");
|
|
@@ -58,6 +59,10 @@ var withVue2_default = (BaseClass, Vue) => {
|
|
|
58
59
|
this.$vue.$destroy();
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
|
-
}
|
|
62
|
+
}, __publicField(_c, "config", {
|
|
63
|
+
...BaseClass.config,
|
|
64
|
+
name: `${BaseClass.config.name}WithVue`,
|
|
65
|
+
refs: [...(_b = (_a = BaseClass.config) == null ? void 0 : _a.refs) != null ? _b : [], "vue"]
|
|
66
|
+
}), __publicField(_c, "vueConfig"), _c;
|
|
62
67
|
};
|
|
63
68
|
if (module.exports.default) module.exports = module.exports.default;
|
package/decorators/withVue2.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare function _default<T extends typeof import("../Base").default>(BaseClass: T, Vue: import('vue').VueConstructor): T;
|
|
2
2
|
export default _default;
|
|
3
|
-
export type Base = import(
|
|
3
|
+
export type Base = import("../Base").default<any>;
|
|
4
4
|
export type BaseConstructor = import('../Base').BaseConstructor;
|
|
5
5
|
export type WithVue2Refs = {
|
|
6
6
|
vue: HTMLElement;
|
package/decorators/withVue2.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
1
7
|
import { isDev, isFunction } from "../utils/index.js";
|
|
2
8
|
var withVue2_default = (BaseClass, Vue) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
...BaseClass.config,
|
|
6
|
-
name: `${BaseClass.config.name}WithVue`,
|
|
7
|
-
refs: [...BaseClass.config?.refs ?? [], "vue"]
|
|
8
|
-
};
|
|
9
|
-
$vue;
|
|
10
|
-
static vueConfig;
|
|
9
|
+
var _a, _b, _c;
|
|
10
|
+
return _c = class extends BaseClass {
|
|
11
11
|
constructor(element) {
|
|
12
|
+
var _a2;
|
|
12
13
|
super(element);
|
|
13
|
-
|
|
14
|
+
__publicField(this, "$vue");
|
|
15
|
+
const vueConfig = (_a2 = this.vueConfig) != null ? _a2 : this.constructor.vueConfig;
|
|
14
16
|
if (!vueConfig) {
|
|
15
17
|
if (isDev) {
|
|
16
18
|
throw new Error("[withVue] You must define a `vueConfig` object.");
|
|
@@ -34,7 +36,11 @@ var withVue2_default = (BaseClass, Vue) => {
|
|
|
34
36
|
this.$vue.$destroy();
|
|
35
37
|
});
|
|
36
38
|
}
|
|
37
|
-
}
|
|
39
|
+
}, __publicField(_c, "config", {
|
|
40
|
+
...BaseClass.config,
|
|
41
|
+
name: `${BaseClass.config.name}WithVue`,
|
|
42
|
+
refs: [...(_b = (_a = BaseClass.config) == null ? void 0 : _a.refs) != null ? _b : [], "vue"]
|
|
43
|
+
}), __publicField(_c, "vueConfig"), _c;
|
|
38
44
|
};
|
|
39
45
|
export {
|
|
40
46
|
withVue2_default as default
|
|
@@ -0,0 +1,46 @@
|
|
|
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/helpers/getDirectChildren.js
|
|
20
|
+
var getDirectChildren_exports = {};
|
|
21
|
+
__export(getDirectChildren_exports, {
|
|
22
|
+
getDirectChildren: () => getDirectChildren,
|
|
23
|
+
isDirectChild: () => isDirectChild
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(getDirectChildren_exports);
|
|
26
|
+
var import_utils = require("../utils/index.cjs");
|
|
27
|
+
function getDirectChildren(parentInstance, parentName, childrenName) {
|
|
28
|
+
const children = parentInstance.$children[childrenName];
|
|
29
|
+
const nestedParents = parentInstance.$children[parentName];
|
|
30
|
+
if (!(0, import_utils.isArray)(children)) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
if (!(0, import_utils.isArray)(nestedParents) || nestedParents.length <= 0) {
|
|
34
|
+
return children;
|
|
35
|
+
}
|
|
36
|
+
return children.filter((child) => {
|
|
37
|
+
return nestedParents.every((nestedParent) => {
|
|
38
|
+
const nestedChildren = nestedParent.$children[childrenName];
|
|
39
|
+
return (0, import_utils.isArray)(nestedChildren) ? !nestedChildren.includes(child) : true;
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function isDirectChild(parentInstance, parentName, childrenName, childInstance) {
|
|
44
|
+
return getDirectChildren(parentInstance, parentName, childrenName).includes(childInstance);
|
|
45
|
+
}
|
|
46
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../Base/index.js').default} Base
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Get direct children from a parent when working with nested components.
|
|
6
|
+
*
|
|
7
|
+
* @template {Base} T
|
|
8
|
+
* @param {Base} parentInstance
|
|
9
|
+
* @param {string} parentName
|
|
10
|
+
* @param {string} childrenName
|
|
11
|
+
* @returns {Array<T>}
|
|
12
|
+
*/
|
|
13
|
+
export function getDirectChildren<T extends import("../Base/index.js").default<any>>(parentInstance: import("../Base/index.js").default<any>, parentName: string, childrenName: string): T[];
|
|
14
|
+
/**
|
|
15
|
+
* Test if a component instance is a direct child from the given component.
|
|
16
|
+
*
|
|
17
|
+
* @param {Base} parentInstance
|
|
18
|
+
* @param {string} parentName
|
|
19
|
+
* @param {string} childrenName
|
|
20
|
+
* @param {Base} childInstance
|
|
21
|
+
* @returns {boolean}
|
|
22
|
+
*/
|
|
23
|
+
export function isDirectChild(parentInstance: import("../Base/index.js").default<any>, parentName: string, childrenName: string, childInstance: import("../Base/index.js").default<any>): boolean;
|
|
24
|
+
export type Base = import("../Base/index.js").default<any>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isArray } from "../utils/index.js";
|
|
2
|
+
function getDirectChildren(parentInstance, parentName, childrenName) {
|
|
3
|
+
const children = parentInstance.$children[childrenName];
|
|
4
|
+
const nestedParents = parentInstance.$children[parentName];
|
|
5
|
+
if (!isArray(children)) {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
if (!isArray(nestedParents) || nestedParents.length <= 0) {
|
|
9
|
+
return children;
|
|
10
|
+
}
|
|
11
|
+
return children.filter((child) => {
|
|
12
|
+
return nestedParents.every((nestedParent) => {
|
|
13
|
+
const nestedChildren = nestedParent.$children[childrenName];
|
|
14
|
+
return isArray(nestedChildren) ? !nestedChildren.includes(child) : true;
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function isDirectChild(parentInstance, parentName, childrenName, childInstance) {
|
|
19
|
+
return getDirectChildren(parentInstance, parentName, childrenName).includes(childInstance);
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
getDirectChildren,
|
|
23
|
+
isDirectChild
|
|
24
|
+
};
|
|
@@ -23,9 +23,10 @@ __export(getInstanceFromElement_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(getInstanceFromElement_exports);
|
|
25
25
|
function getInstanceFromElement(element, Constructor) {
|
|
26
|
+
var _a;
|
|
26
27
|
if (!element.__base__) {
|
|
27
28
|
return null;
|
|
28
29
|
}
|
|
29
|
-
return element.__base__.get(Constructor)
|
|
30
|
+
return (_a = element.__base__.get(Constructor)) != null ? _a : null;
|
|
30
31
|
}
|
|
31
32
|
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
function getInstanceFromElement(element, Constructor) {
|
|
2
|
+
var _a;
|
|
2
3
|
if (!element.__base__) {
|
|
3
4
|
return null;
|
|
4
5
|
}
|
|
5
|
-
return element.__base__.get(Constructor)
|
|
6
|
+
return (_a = element.__base__.get(Constructor)) != null ? _a : null;
|
|
6
7
|
}
|
|
7
8
|
export {
|
|
8
9
|
getInstanceFromElement as default
|
|
@@ -34,7 +34,7 @@ function importOnInteraction(fn, nameOrSelectorOrElement, events, parent) {
|
|
|
34
34
|
});
|
|
35
35
|
};
|
|
36
36
|
return new Promise((resolve) => {
|
|
37
|
-
const elements = (0, import_utils.getTargetElements)(nameOrSelectorOrElement, parent
|
|
37
|
+
const elements = (0, import_utils.getTargetElements)(nameOrSelectorOrElement, parent == null ? void 0 : parent.$el);
|
|
38
38
|
const eventListenerOptions = {
|
|
39
39
|
capture: true,
|
|
40
40
|
passive: true,
|
|
@@ -18,6 +18,6 @@
|
|
|
18
18
|
*/
|
|
19
19
|
export default function importOnInteraction<T extends typeof import("../Base/index.js").default>(fn: () => Promise<T | {
|
|
20
20
|
default: T;
|
|
21
|
-
}>, nameOrSelectorOrElement: string | HTMLElement | HTMLElement[], events: string | string[], parent?: Base): Promise<T>;
|
|
21
|
+
}>, nameOrSelectorOrElement: string | HTMLElement | HTMLElement[], events: string | string[], parent?: import("../Base/index.js").default<any>): Promise<T>;
|
|
22
22
|
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
|
23
|
-
export type Base = import(
|
|
23
|
+
export type Base = import("../Base/index.js").default<any>;
|
|
@@ -10,7 +10,7 @@ function importOnInteraction(fn, nameOrSelectorOrElement, events, parent) {
|
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
12
|
return new Promise((resolve) => {
|
|
13
|
-
const elements = getTargetElements(nameOrSelectorOrElement, parent
|
|
13
|
+
const elements = getTargetElements(nameOrSelectorOrElement, parent == null ? void 0 : parent.$el);
|
|
14
14
|
const eventListenerOptions = {
|
|
15
15
|
capture: true,
|
|
16
16
|
passive: true,
|
|
@@ -31,17 +31,21 @@ function importWhenIdle(fn, options) {
|
|
|
31
31
|
});
|
|
32
32
|
};
|
|
33
33
|
return new Promise((resolve) => {
|
|
34
|
-
|
|
34
|
+
var _a;
|
|
35
|
+
const timeout = (_a = options == null ? void 0 : options.timeout) != null ? _a : 1;
|
|
35
36
|
if (!("requestIdleCallback" in window)) {
|
|
36
37
|
setTimeout(() => {
|
|
37
38
|
resolver(resolve);
|
|
38
39
|
}, timeout);
|
|
39
40
|
} else {
|
|
40
|
-
window.requestIdleCallback(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
window.requestIdleCallback(
|
|
42
|
+
() => {
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
resolver(resolve);
|
|
45
|
+
}, 0);
|
|
46
|
+
},
|
|
47
|
+
{ timeout: options == null ? void 0 : options.timeout }
|
|
48
|
+
);
|
|
45
49
|
}
|
|
46
50
|
});
|
|
47
51
|
}
|
|
@@ -7,17 +7,21 @@ function importWhenIdle(fn, options) {
|
|
|
7
7
|
});
|
|
8
8
|
};
|
|
9
9
|
return new Promise((resolve) => {
|
|
10
|
-
|
|
10
|
+
var _a;
|
|
11
|
+
const timeout = (_a = options == null ? void 0 : options.timeout) != null ? _a : 1;
|
|
11
12
|
if (!("requestIdleCallback" in window)) {
|
|
12
13
|
setTimeout(() => {
|
|
13
14
|
resolver(resolve);
|
|
14
15
|
}, timeout);
|
|
15
16
|
} else {
|
|
16
|
-
window.requestIdleCallback(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
window.requestIdleCallback(
|
|
18
|
+
() => {
|
|
19
|
+
setTimeout(() => {
|
|
20
|
+
resolver(resolve);
|
|
21
|
+
}, 0);
|
|
22
|
+
},
|
|
23
|
+
{ timeout: options == null ? void 0 : options.timeout }
|
|
24
|
+
);
|
|
21
25
|
}
|
|
22
26
|
});
|
|
23
27
|
}
|
|
@@ -44,7 +44,7 @@ function importWhenVisible(fn, nameOrSelectorOrElement, parent, observerOptions
|
|
|
44
44
|
}, 0);
|
|
45
45
|
}
|
|
46
46
|
}, observerOptions);
|
|
47
|
-
const elements = (0, import_utils.getTargetElements)(nameOrSelectorOrElement, parent
|
|
47
|
+
const elements = (0, import_utils.getTargetElements)(nameOrSelectorOrElement, parent == null ? void 0 : parent.$el);
|
|
48
48
|
elements.forEach((element) => observer.observe(element));
|
|
49
49
|
});
|
|
50
50
|
}
|
|
@@ -18,6 +18,6 @@
|
|
|
18
18
|
*/
|
|
19
19
|
export default function importWhenVisible<T extends typeof import("../Base/index.js").default>(fn: () => Promise<T | {
|
|
20
20
|
default: T;
|
|
21
|
-
}>, nameOrSelectorOrElement: string | HTMLElement | HTMLElement[], parent?: Base
|
|
22
|
-
export type Base = import(
|
|
21
|
+
}>, nameOrSelectorOrElement: string | HTMLElement | HTMLElement[], parent?: import("../Base/index.js").default<any>, observerOptions?: IntersectionObserverInit): Promise<T>;
|
|
22
|
+
export type Base = import("../Base/index.js").default<any>;
|
|
23
23
|
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
|
@@ -20,7 +20,7 @@ function importWhenVisible(fn, nameOrSelectorOrElement, parent, observerOptions
|
|
|
20
20
|
}, 0);
|
|
21
21
|
}
|
|
22
22
|
}, observerOptions);
|
|
23
|
-
const elements = getTargetElements(nameOrSelectorOrElement, parent
|
|
23
|
+
const elements = getTargetElements(nameOrSelectorOrElement, parent == null ? void 0 : parent.$el);
|
|
24
24
|
elements.forEach((element) => observer.observe(element));
|
|
25
25
|
});
|
|
26
26
|
}
|
package/helpers/index.cjs
CHANGED
|
@@ -16,7 +16,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var
|
|
19
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
20
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
25
|
|
|
22
26
|
// packages/js-toolkit/helpers/index.js
|
|
@@ -30,6 +34,7 @@ __export(helpers_exports, {
|
|
|
30
34
|
});
|
|
31
35
|
module.exports = __toCommonJS(helpers_exports);
|
|
32
36
|
var import_createApp = __toESM(require("./createApp.cjs"), 1);
|
|
37
|
+
__reExport(helpers_exports, require("./getDirectChildren.cjs"), module.exports);
|
|
33
38
|
var import_getInstanceFromElement = __toESM(require("./getInstanceFromElement.cjs"), 1);
|
|
34
39
|
var import_importOnInteraction = __toESM(require("./importOnInteraction.cjs"), 1);
|
|
35
40
|
var import_importWhenIdle = __toESM(require("./importWhenIdle.cjs"), 1);
|
package/helpers/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as createApp } from "./createApp.js";
|
|
2
|
+
export * from "./getDirectChildren.js";
|
|
2
3
|
export { default as getInstanceFromElement } from "./getInstanceFromElement.js";
|
|
3
4
|
export { default as importOnInteraction } from "./importOnInteraction.js";
|
|
4
5
|
export { default as importWhenIdle } from "./importWhenIdle.js";
|
package/helpers/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as default2 } from "./createApp.js";
|
|
2
|
+
export * from "./getDirectChildren.js";
|
|
2
3
|
import { default as default3 } from "./getInstanceFromElement.js";
|
|
3
4
|
import { default as default4 } from "./importOnInteraction.js";
|
|
4
5
|
import { default as default5 } from "./importWhenIdle.js";
|
package/index.cjs
CHANGED
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
|
|
23
26
|
// packages/js-toolkit/index.js
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiometa/js-toolkit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"description": "A set of useful little bits of JavaScript to boost your project! 🚀",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"toolkit"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@motionone/easing": "^10.
|
|
42
|
+
"@motionone/easing": "^10.14.0",
|
|
43
43
|
"deepmerge": "^4.2.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
package/services/drag.cjs
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// packages/js-toolkit/services/drag.js
|
package/services/index.cjs
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// packages/js-toolkit/services/index.js
|
package/services/index.d.ts
CHANGED
|
@@ -24,3 +24,10 @@ export type ServiceInterface<T> = {
|
|
|
24
24
|
*/
|
|
25
25
|
props: () => T;
|
|
26
26
|
};
|
|
27
|
+
export type DragServiceProps = import('./drag').DragServiceProps;
|
|
28
|
+
export type KeyServiceProps = import('./key').KeyServiceProps;
|
|
29
|
+
export type LoadServiceProps = import('./load').LoadServiceProps;
|
|
30
|
+
export type PointerServiceProps = import('./pointer').PointerServiceProps;
|
|
31
|
+
export type RafServiceProps = import('./raf').RafServiceProps;
|
|
32
|
+
export type ResizeServiceProps = import('./resize').ResizeServiceProps;
|
|
33
|
+
export type ScrollServiceProps = import('./scroll').ScrollServiceProps;
|
package/services/key.cjs
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// packages/js-toolkit/services/key.js
|
|
@@ -40,7 +43,7 @@ function createKeyService() {
|
|
|
40
43
|
if (!previousEvent) {
|
|
41
44
|
props.triggered = 0;
|
|
42
45
|
}
|
|
43
|
-
if (props.event.type === "keydown" && previousEvent
|
|
46
|
+
if (props.event.type === "keydown" && (previousEvent == null ? void 0 : previousEvent.type) === "keydown") {
|
|
44
47
|
props.triggered += 1;
|
|
45
48
|
} else {
|
|
46
49
|
props.triggered = 1;
|
package/services/key.js
CHANGED
|
@@ -13,7 +13,7 @@ function createKeyService() {
|
|
|
13
13
|
if (!previousEvent) {
|
|
14
14
|
props.triggered = 0;
|
|
15
15
|
}
|
|
16
|
-
if (props.event.type === "keydown" && previousEvent
|
|
16
|
+
if (props.event.type === "keydown" && (previousEvent == null ? void 0 : previousEvent.type) === "keydown") {
|
|
17
17
|
props.triggered += 1;
|
|
18
18
|
} else {
|
|
19
19
|
props.triggered = 1;
|
package/services/pointer.cjs
CHANGED
|
@@ -29,14 +29,15 @@ function isTouchEvent(event) {
|
|
|
29
29
|
var events = ["mousemove", "touchmove", "mousedown", "touchstart", "mouseup", "touchend"];
|
|
30
30
|
function createPointerService() {
|
|
31
31
|
function updateProps(event) {
|
|
32
|
+
var _a, _b;
|
|
32
33
|
props.event = event;
|
|
33
34
|
const yLast = props.y;
|
|
34
35
|
const xLast = props.x;
|
|
35
|
-
const y = isTouchEvent(event) ? event.touches[0]
|
|
36
|
+
const y = isTouchEvent(event) ? (_a = event.touches[0]) == null ? void 0 : _a.clientY : event.clientY;
|
|
36
37
|
if (y !== props.y) {
|
|
37
38
|
props.y = y;
|
|
38
39
|
}
|
|
39
|
-
const x = isTouchEvent(event) ? event.touches[0]
|
|
40
|
+
const x = isTouchEvent(event) ? (_b = event.touches[0]) == null ? void 0 : _b.clientX : event.clientX;
|
|
40
41
|
if (x !== props.x) {
|
|
41
42
|
props.x = x;
|
|
42
43
|
}
|
package/services/pointer.js
CHANGED
|
@@ -5,14 +5,15 @@ function isTouchEvent(event) {
|
|
|
5
5
|
const events = ["mousemove", "touchmove", "mousedown", "touchstart", "mouseup", "touchend"];
|
|
6
6
|
function createPointerService() {
|
|
7
7
|
function updateProps(event) {
|
|
8
|
+
var _a, _b;
|
|
8
9
|
props.event = event;
|
|
9
10
|
const yLast = props.y;
|
|
10
11
|
const xLast = props.x;
|
|
11
|
-
const y = isTouchEvent(event) ? event.touches[0]
|
|
12
|
+
const y = isTouchEvent(event) ? (_a = event.touches[0]) == null ? void 0 : _a.clientY : event.clientY;
|
|
12
13
|
if (y !== props.y) {
|
|
13
14
|
props.y = y;
|
|
14
15
|
}
|
|
15
|
-
const x = isTouchEvent(event) ? event.touches[0]
|
|
16
|
+
const x = isTouchEvent(event) ? (_b = event.touches[0]) == null ? void 0 : _b.clientX : event.clientX;
|
|
16
17
|
if (x !== props.x) {
|
|
17
18
|
props.x = x;
|
|
18
19
|
}
|
package/services/resize.cjs
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// packages/js-toolkit/services/resize.js
|
package/services/scroll.cjs
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// packages/js-toolkit/services/scroll.js
|
package/utils/collide/index.cjs
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// packages/js-toolkit/utils/collide/index.js
|
package/utils/css/animate.cjs
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// packages/js-toolkit/utils/css/animate.js
|
|
@@ -48,10 +51,14 @@ function getAnimationStepValue(val, getSizeRef) {
|
|
|
48
51
|
}
|
|
49
52
|
return CSSUnitConverter[val[1]](val[0], getSizeRef);
|
|
50
53
|
}
|
|
51
|
-
var generateTranslateRenderStrategy = (sizeRef) => (element, fromValue, toValue, progress) => (0, import_math.lerp)(
|
|
54
|
+
var generateTranslateRenderStrategy = (sizeRef) => (element, fromValue, toValue, progress) => (0, import_math.lerp)(
|
|
55
|
+
getAnimationStepValue(fromValue != null ? fromValue : 0, () => element[sizeRef]),
|
|
56
|
+
getAnimationStepValue(toValue != null ? toValue : 0, () => element[sizeRef]),
|
|
57
|
+
progress
|
|
58
|
+
);
|
|
52
59
|
var widthBasedTranslateRenderStrategy = generateTranslateRenderStrategy("offsetWidth");
|
|
53
60
|
var heightBasedTranslateRenderStrategy = generateTranslateRenderStrategy("offsetHeight");
|
|
54
|
-
var generateLerpRenderStrategy = (defaultValue) => (element, fromValue, toValue, progress) => (0, import_math.lerp)(fromValue
|
|
61
|
+
var generateLerpRenderStrategy = (defaultValue) => (element, fromValue, toValue, progress) => (0, import_math.lerp)(fromValue != null ? fromValue : defaultValue, toValue != null ? toValue : defaultValue, progress);
|
|
55
62
|
var scaleRenderStrategy = generateLerpRenderStrategy(1);
|
|
56
63
|
var degreesRenderStrategy = generateLerpRenderStrategy(0);
|
|
57
64
|
var transformRenderStrategies = {
|
|
@@ -73,9 +80,10 @@ var transformRenderStrategies = {
|
|
|
73
80
|
function render(element, from, to, progress) {
|
|
74
81
|
const stepProgress = to.easing((0, import_math.map)(progress, from.offset, to.offset, 0, 1));
|
|
75
82
|
import_scheduler.domScheduler.read(function renderRead() {
|
|
83
|
+
var _a, _b;
|
|
76
84
|
let opacity = false;
|
|
77
85
|
if ((0, import_is.isDefined)(from.opacity) || (0, import_is.isDefined)(to.opacity)) {
|
|
78
|
-
opacity = (0, import_math.map)(stepProgress, 0, 1, from.opacity
|
|
86
|
+
opacity = (0, import_math.map)(stepProgress, 0, 1, (_a = from.opacity) != null ? _a : 1, (_b = to.opacity) != null ? _b : 1);
|
|
79
87
|
} else if (element.style.opacity) {
|
|
80
88
|
opacity = "";
|
|
81
89
|
}
|
|
@@ -85,9 +93,11 @@ function render(element, from, to, progress) {
|
|
|
85
93
|
} else if (element.style.transformOrigin) {
|
|
86
94
|
transformOrigin = "";
|
|
87
95
|
}
|
|
88
|
-
const props = Object.fromEntries(
|
|
89
|
-
|
|
90
|
-
|
|
96
|
+
const props = Object.fromEntries(
|
|
97
|
+
import_transform.TRANSFORM_PROPS.filter((name) => (0, import_is.isDefined)(from[name]) || (0, import_is.isDefined)(to[name])).map((name) => {
|
|
98
|
+
return [name, transformRenderStrategies[name](element, from[name], to[name], stepProgress)];
|
|
99
|
+
})
|
|
100
|
+
);
|
|
91
101
|
import_scheduler.domScheduler.write(function renderWrite() {
|
|
92
102
|
if (opacity !== false) {
|
|
93
103
|
element.style.opacity = opacity;
|
|
@@ -101,11 +111,16 @@ function render(element, from, to, progress) {
|
|
|
101
111
|
}
|
|
102
112
|
function animate(element, keyframes, options = {}) {
|
|
103
113
|
const keyframesCount = keyframes.length - 1;
|
|
104
|
-
const normalizedKeyframes = keyframes.map(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
114
|
+
const normalizedKeyframes = keyframes.map(
|
|
115
|
+
(keyframe, index) => {
|
|
116
|
+
var _a;
|
|
117
|
+
return {
|
|
118
|
+
...keyframe,
|
|
119
|
+
offset: (_a = keyframe.offset) != null ? _a : index / keyframesCount,
|
|
120
|
+
easing: (0, import_tween.normalizeEase)(keyframe.easing)
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
);
|
|
109
124
|
if (!running.has(element)) {
|
|
110
125
|
running.set(element, /* @__PURE__ */ new Map());
|
|
111
126
|
}
|