@studiometa/js-toolkit 2.0.0-beta.7 → 2.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Base/index.cjs +285 -0
- package/Base/index.d.ts +13 -4
- package/Base/index.js +114 -197
- package/Base/managers/ChildrenManager.cjs +146 -0
- package/Base/managers/ChildrenManager.d.ts +9 -1
- package/Base/managers/ChildrenManager.js +60 -59
- package/Base/managers/EventsManager.cjs +183 -0
- package/Base/managers/EventsManager.js +72 -112
- package/Base/managers/OptionsManager.cjs +174 -0
- package/Base/managers/OptionsManager.d.ts +9 -5
- package/Base/managers/OptionsManager.js +60 -90
- package/Base/managers/RefsManager.cjs +99 -0
- package/Base/managers/RefsManager.js +30 -35
- package/Base/managers/ServicesManager.cjs +131 -0
- package/Base/managers/ServicesManager.js +39 -67
- package/Base/utils.cjs +41 -0
- package/Base/utils.js +12 -11
- package/README.md +13 -70
- package/decorators/index.cjs +45 -0
- package/decorators/index.d.ts +9 -9
- package/decorators/index.js +20 -9
- package/decorators/withBreakpointManager.cjs +85 -0
- package/decorators/withBreakpointManager.js +18 -39
- package/decorators/withBreakpointObserver.cjs +115 -0
- package/decorators/withBreakpointObserver.js +44 -86
- package/decorators/withDrag.cjs +53 -0
- package/decorators/withDrag.js +24 -26
- package/decorators/withExtraConfig.cjs +43 -0
- package/decorators/withExtraConfig.js +17 -12
- package/decorators/withFreezedOptions.cjs +36 -0
- package/decorators/withFreezedOptions.d.ts +14 -0
- package/decorators/withFreezedOptions.js +14 -0
- package/decorators/withIntersectionObserver.cjs +62 -0
- package/decorators/withIntersectionObserver.js +29 -32
- package/decorators/withMountWhenInView.cjs +69 -0
- package/decorators/withMountWhenInView.js +31 -52
- package/decorators/withScrolledInView.cjs +114 -0
- package/decorators/withScrolledInView.d.ts +2 -1
- package/decorators/withScrolledInView.js +35 -39
- package/decorators/withVue2.cjs +60 -0
- package/decorators/withVue2.js +26 -32
- package/helpers/createApp.cjs +52 -0
- package/helpers/createApp.d.ts +2 -2
- package/helpers/createApp.js +12 -12
- package/helpers/importOnInteraction.cjs +52 -0
- package/helpers/importOnInteraction.js +17 -18
- package/helpers/importWhenIdle.cjs +49 -0
- package/helpers/importWhenIdle.js +14 -17
- package/helpers/importWhenVisible.cjs +50 -0
- package/helpers/importWhenVisible.js +16 -18
- package/helpers/index.cjs +35 -0
- package/helpers/index.d.ts +4 -5
- package/helpers/index.js +10 -5
- package/helpers/utils.cjs +35 -0
- package/helpers/utils.js +7 -6
- package/index.cjs +33 -0
- package/index.d.ts +4 -21
- package/index.js +7 -5
- package/package.json +14 -4
- package/services/Service.cjs +76 -0
- package/services/Service.js +19 -32
- package/services/drag.cjs +213 -0
- package/services/drag.d.ts +1 -0
- package/services/drag.js +64 -68
- package/services/index.cjs +41 -0
- package/services/index.d.ts +7 -8
- package/services/index.js +16 -8
- package/services/key.cjs +104 -0
- package/services/key.js +28 -36
- package/services/load.cjs +72 -0
- package/services/load.js +17 -19
- package/services/pointer.cjs +162 -0
- package/services/pointer.js +43 -60
- package/services/raf.cjs +83 -0
- package/services/raf.js +20 -28
- package/services/resize.cjs +108 -0
- package/services/resize.js +33 -42
- package/services/scroll.cjs +131 -0
- package/services/scroll.js +26 -35
- package/utils/collide/boundingRectToCircle.cjs +34 -0
- package/utils/collide/boundingRectToCircle.d.ts +1 -1
- package/utils/collide/boundingRectToCircle.js +7 -10
- package/utils/collide/collideCircleCircle.cjs +34 -0
- package/utils/collide/collideCircleCircle.js +8 -7
- package/utils/collide/collideCircleRect.cjs +46 -0
- package/utils/collide/collideCircleRect.js +10 -12
- package/utils/collide/collidePointCircle.cjs +31 -0
- package/utils/collide/collidePointCircle.js +8 -5
- package/utils/collide/collidePointRect.cjs +28 -0
- package/utils/collide/collidePointRect.js +5 -2
- package/utils/collide/collideRectRect.cjs +28 -0
- package/utils/collide/collideRectRect.js +5 -2
- package/utils/collide/index.cjs +39 -0
- package/utils/collide/index.d.ts +6 -7
- package/utils/collide/index.js +14 -7
- package/utils/css/classes.cjs +47 -0
- package/utils/css/classes.d.ts +10 -9
- package/utils/css/classes.js +18 -14
- package/utils/css/index.cjs +38 -0
- package/utils/css/index.d.ts +4 -5
- package/utils/css/index.js +13 -5
- package/utils/css/matrix.cjs +30 -0
- package/utils/css/matrix.js +7 -5
- package/utils/css/styles.cjs +44 -0
- package/utils/css/styles.d.ts +6 -18
- package/utils/css/styles.js +12 -12
- package/utils/css/transition.cjs +120 -0
- package/utils/css/transition.d.ts +15 -9
- package/utils/css/transition.js +70 -119
- package/utils/debounce.cjs +34 -0
- package/utils/debounce.js +7 -9
- package/utils/focusTrap.cjs +82 -0
- package/utils/focusTrap.js +30 -21
- package/utils/history.cjs +89 -0
- package/utils/history.js +28 -57
- package/utils/index.cjs +54 -0
- package/utils/index.d.ts +14 -35
- package/utils/index.js +32 -17
- package/utils/keyCodes.cjs +35 -0
- package/utils/keyCodes.js +5 -2
- package/utils/math/clamp.cjs +28 -0
- package/utils/math/clamp.js +5 -2
- package/utils/math/clamp01.cjs +32 -0
- package/utils/math/clamp01.js +6 -3
- package/utils/math/damp.cjs +28 -0
- package/utils/math/damp.js +5 -4
- package/utils/math/ease.cjs +88 -0
- package/utils/math/ease.d.ts +78 -0
- package/utils/math/ease.js +66 -0
- package/utils/math/index.cjs +43 -0
- package/utils/math/index.d.ts +8 -8
- package/utils/math/index.js +17 -8
- package/utils/math/inertiaFinalValue.cjs +37 -0
- package/utils/math/inertiaFinalValue.js +8 -10
- package/utils/math/lerp.cjs +28 -0
- package/utils/math/lerp.js +5 -2
- package/utils/math/map.cjs +28 -0
- package/utils/math/map.js +5 -2
- package/utils/math/round.cjs +28 -0
- package/utils/math/round.js +5 -3
- package/utils/memoize.cjs +43 -0
- package/utils/memoize.js +10 -19
- package/utils/nextFrame.cjs +38 -0
- package/utils/nextFrame.d.ts +4 -3
- package/utils/nextFrame.js +13 -10
- package/utils/nextMicrotask.cjs +28 -0
- package/utils/nextMicrotask.d.ts +8 -0
- package/utils/nextMicrotask.js +6 -0
- package/utils/nextTick.cjs +30 -0
- package/utils/nextTick.d.ts +8 -0
- package/utils/nextTick.js +8 -0
- package/utils/object/autoBind.cjs +49 -0
- package/utils/object/autoBind.js +12 -22
- package/utils/object/getAllProperties.cjs +37 -0
- package/utils/object/getAllProperties.js +10 -13
- package/utils/object/index.cjs +33 -0
- package/utils/object/index.d.ts +3 -4
- package/utils/object/index.js +8 -4
- package/utils/object/isObject.cjs +28 -0
- package/utils/object/isObject.js +6 -3
- package/utils/scrollTo.cjs +80 -0
- package/utils/scrollTo.js +20 -40
- package/utils/string/index.cjs +47 -0
- package/utils/string/index.d.ts +10 -11
- package/utils/string/index.js +22 -11
- package/utils/string/withLeadingCharacters.cjs +32 -0
- package/utils/string/withLeadingCharacters.js +7 -4
- package/utils/string/withLeadingSlash.cjs +32 -0
- package/utils/string/withLeadingSlash.js +7 -4
- package/utils/string/withTrailingCharacters.cjs +32 -0
- package/utils/string/withTrailingCharacters.js +7 -4
- package/utils/string/withTrailingSlash.cjs +32 -0
- package/utils/string/withTrailingSlash.js +7 -4
- package/utils/string/withoutLeadingCharacters.cjs +28 -0
- package/utils/string/withoutLeadingCharacters.js +6 -3
- package/utils/string/withoutLeadingCharactersRecursive.cjs +37 -0
- package/utils/string/withoutLeadingCharactersRecursive.js +8 -7
- package/utils/string/withoutLeadingSlash.cjs +32 -0
- package/utils/string/withoutLeadingSlash.js +7 -4
- package/utils/string/withoutTrailingCharacters.cjs +28 -0
- package/utils/string/withoutTrailingCharacters.js +6 -3
- package/utils/string/withoutTrailingCharactersRecursive.cjs +37 -0
- package/utils/string/withoutTrailingCharactersRecursive.js +8 -7
- package/utils/string/withoutTrailingSlash.cjs +32 -0
- package/utils/string/withoutTrailingSlash.js +7 -4
- package/utils/throttle.cjs +36 -0
- package/utils/throttle.js +9 -9
- package/index.modern.js +0 -1
- package/index.umd.js +0 -1
package/decorators/withVue2.js
CHANGED
|
@@ -1,45 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
return _temp = _class = class WithVue2 extends BaseClass {
|
|
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
|
+
};
|
|
7
|
+
var withVue2_default = (BaseClass, Vue) => {
|
|
8
|
+
var _a, _b, _c;
|
|
9
|
+
return _c = class extends BaseClass {
|
|
11
10
|
constructor(element) {
|
|
12
11
|
super(element);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var {
|
|
17
|
-
vueConfig
|
|
18
|
-
} = this.constructor;
|
|
19
|
-
|
|
12
|
+
__publicField(this, "$vue");
|
|
13
|
+
const { vueConfig } = this.constructor;
|
|
20
14
|
if (!vueConfig) {
|
|
21
|
-
throw new Error(
|
|
15
|
+
throw new Error("[withVue] You must define a `vueConfig` object.");
|
|
22
16
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
throw new Error('[withVue] You must define a `render` function in vueConfig.');
|
|
17
|
+
if (typeof vueConfig.render !== "function") {
|
|
18
|
+
throw new Error("[withVue] You must define a `render` function in vueConfig.");
|
|
26
19
|
}
|
|
27
|
-
|
|
28
20
|
this.$vue = new Vue(vueConfig);
|
|
29
|
-
this.$on(
|
|
21
|
+
this.$on("mounted", () => {
|
|
30
22
|
if (!(this.$refs.vue instanceof HTMLElement)) {
|
|
31
|
-
throw new Error(
|
|
23
|
+
throw new Error("[withVue] The `vue` refs must be a single HTMLElement.");
|
|
32
24
|
}
|
|
33
|
-
|
|
34
25
|
this.$vue.$mount(this.$refs.vue);
|
|
35
26
|
});
|
|
36
|
-
this.$on(
|
|
27
|
+
this.$on("destroyed", () => {
|
|
37
28
|
this.$vue.$destroy();
|
|
38
29
|
});
|
|
39
30
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
name:
|
|
43
|
-
refs: [...(
|
|
44
|
-
})
|
|
45
|
-
}
|
|
31
|
+
}, __publicField(_c, "config", {
|
|
32
|
+
...BaseClass.config,
|
|
33
|
+
name: `${BaseClass.config.name}WithVue`,
|
|
34
|
+
refs: [...(_b = (_a = BaseClass.config) == null ? void 0 : _a.refs) != null ? _b : [], "vue"]
|
|
35
|
+
}), __publicField(_c, "vueConfig"), _c;
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
withVue2_default as default
|
|
39
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
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/createApp.js
|
|
20
|
+
var createApp_exports = {};
|
|
21
|
+
__export(createApp_exports, {
|
|
22
|
+
default: () => createApp
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(createApp_exports);
|
|
25
|
+
function createApp(App, rootElement = document.body) {
|
|
26
|
+
let isLoaded = document.readyState === "complete";
|
|
27
|
+
let app;
|
|
28
|
+
if (!isLoaded) {
|
|
29
|
+
document.addEventListener("readystatechange", () => {
|
|
30
|
+
if (document.readyState === "complete") {
|
|
31
|
+
app = new App(rootElement).$mount();
|
|
32
|
+
isLoaded = true;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
} else {
|
|
36
|
+
app = new App(rootElement).$mount();
|
|
37
|
+
}
|
|
38
|
+
const promise = new Promise((resolve) => {
|
|
39
|
+
document.addEventListener("readystatechange", () => {
|
|
40
|
+
if (document.readyState === "complete") {
|
|
41
|
+
setTimeout(() => resolve(app), 0);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
return function useApp() {
|
|
46
|
+
if (isLoaded) {
|
|
47
|
+
return Promise.resolve(app);
|
|
48
|
+
}
|
|
49
|
+
return promise;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/helpers/createApp.d.ts
CHANGED
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
*
|
|
29
29
|
* @template {BaseConstructor} T
|
|
30
30
|
* @param {T} App
|
|
31
|
-
* @param {HTMLElement} rootElement
|
|
31
|
+
* @param {HTMLElement=} [rootElement]
|
|
32
32
|
*
|
|
33
33
|
* @return {() => Promise<InstanceType<T>>}
|
|
34
34
|
*
|
|
35
35
|
*/
|
|
36
|
-
export default function createApp<T extends typeof import("../Base/index.js").default>(App: T, rootElement
|
|
36
|
+
export default function createApp<T extends typeof import("../Base/index.js").default>(App: T, rootElement?: HTMLElement | undefined): () => Promise<InstanceType<T>>;
|
|
37
37
|
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
package/helpers/createApp.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
function createApp(App, rootElement = document.body) {
|
|
2
|
+
let isLoaded = document.readyState === "complete";
|
|
3
|
+
let app;
|
|
5
4
|
if (!isLoaded) {
|
|
6
|
-
document.addEventListener(
|
|
7
|
-
if (document.readyState ===
|
|
5
|
+
document.addEventListener("readystatechange", () => {
|
|
6
|
+
if (document.readyState === "complete") {
|
|
8
7
|
app = new App(rootElement).$mount();
|
|
9
8
|
isLoaded = true;
|
|
10
9
|
}
|
|
@@ -12,10 +11,9 @@ export default function createApp(App, rootElement) {
|
|
|
12
11
|
} else {
|
|
13
12
|
app = new App(rootElement).$mount();
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (document.readyState === 'complete') {
|
|
14
|
+
const promise = new Promise((resolve) => {
|
|
15
|
+
document.addEventListener("readystatechange", () => {
|
|
16
|
+
if (document.readyState === "complete") {
|
|
19
17
|
setTimeout(() => resolve(app), 0);
|
|
20
18
|
}
|
|
21
19
|
});
|
|
@@ -24,7 +22,9 @@ export default function createApp(App, rootElement) {
|
|
|
24
22
|
if (isLoaded) {
|
|
25
23
|
return Promise.resolve(app);
|
|
26
24
|
}
|
|
27
|
-
|
|
28
25
|
return promise;
|
|
29
26
|
};
|
|
30
|
-
}
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
createApp as default
|
|
30
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
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/importOnInteraction.js
|
|
20
|
+
var importOnInteraction_exports = {};
|
|
21
|
+
__export(importOnInteraction_exports, {
|
|
22
|
+
default: () => importOnInteraction
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(importOnInteraction_exports);
|
|
25
|
+
var import_utils = require("./utils.cjs");
|
|
26
|
+
function importOnInteraction(fn, nameOrSelectorOrElement, events, parent) {
|
|
27
|
+
const normalizedEvents = typeof events === "string" ? [events] : events;
|
|
28
|
+
let ResolvedClass;
|
|
29
|
+
const resolver = (resolve) => {
|
|
30
|
+
fn().then((module2) => {
|
|
31
|
+
ResolvedClass = "default" in module2 ? module2.default : module2;
|
|
32
|
+
resolve(ResolvedClass);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
return new Promise((resolve) => {
|
|
36
|
+
const elements = (0, import_utils.getTargetElements)(nameOrSelectorOrElement, parent == null ? void 0 : parent.$el);
|
|
37
|
+
const eventListenerOptions = {
|
|
38
|
+
capture: true,
|
|
39
|
+
passive: true,
|
|
40
|
+
once: true
|
|
41
|
+
};
|
|
42
|
+
const handler = () => {
|
|
43
|
+
resolver(resolve);
|
|
44
|
+
};
|
|
45
|
+
elements.forEach((element) => {
|
|
46
|
+
normalizedEvents.forEach((event) => {
|
|
47
|
+
element.addEventListener(event, handler, eventListenerOptions);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
import { getTargetElements } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
ResolvedClass = 'default' in module ? module.default : module;
|
|
1
|
+
import { getTargetElements } from "./utils.js";
|
|
2
|
+
function importOnInteraction(fn, nameOrSelectorOrElement, events, parent) {
|
|
3
|
+
const normalizedEvents = typeof events === "string" ? [events] : events;
|
|
4
|
+
let ResolvedClass;
|
|
5
|
+
const resolver = (resolve) => {
|
|
6
|
+
fn().then((module) => {
|
|
7
|
+
ResolvedClass = "default" in module ? module.default : module;
|
|
9
8
|
resolve(ResolvedClass);
|
|
10
9
|
});
|
|
11
10
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var eventListenerOptions = {
|
|
11
|
+
return new Promise((resolve) => {
|
|
12
|
+
const elements = getTargetElements(nameOrSelectorOrElement, parent == null ? void 0 : parent.$el);
|
|
13
|
+
const eventListenerOptions = {
|
|
16
14
|
capture: true,
|
|
17
15
|
passive: true,
|
|
18
16
|
once: true
|
|
19
17
|
};
|
|
20
|
-
|
|
21
|
-
var handler = () => {
|
|
18
|
+
const handler = () => {
|
|
22
19
|
resolver(resolve);
|
|
23
20
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
normalizedEvents.forEach(event => {
|
|
21
|
+
elements.forEach((element) => {
|
|
22
|
+
normalizedEvents.forEach((event) => {
|
|
27
23
|
element.addEventListener(event, handler, eventListenerOptions);
|
|
28
24
|
});
|
|
29
25
|
});
|
|
30
26
|
});
|
|
31
|
-
}
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
importOnInteraction as default
|
|
30
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
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/importWhenIdle.js
|
|
20
|
+
var importWhenIdle_exports = {};
|
|
21
|
+
__export(importWhenIdle_exports, {
|
|
22
|
+
default: () => importWhenIdle
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(importWhenIdle_exports);
|
|
25
|
+
function importWhenIdle(fn, options) {
|
|
26
|
+
let ResolvedClass;
|
|
27
|
+
const resolver = (resolve) => {
|
|
28
|
+
fn().then((module2) => {
|
|
29
|
+
ResolvedClass = "default" in module2 ? module2.default : module2;
|
|
30
|
+
resolve(ResolvedClass);
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
return new Promise((resolve) => {
|
|
34
|
+
var _a;
|
|
35
|
+
const timeout = (_a = options == null ? void 0 : options.timeout) != null ? _a : 1;
|
|
36
|
+
if (!("requestIdleCallback" in window)) {
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
resolver(resolve);
|
|
39
|
+
}, timeout);
|
|
40
|
+
} else {
|
|
41
|
+
window.requestIdleCallback(() => {
|
|
42
|
+
setTimeout(() => {
|
|
43
|
+
resolver(resolve);
|
|
44
|
+
}, 0);
|
|
45
|
+
}, { timeout: options == null ? void 0 : options.timeout });
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
ResolvedClass = 'default' in module ? module.default : module;
|
|
1
|
+
function importWhenIdle(fn, options) {
|
|
2
|
+
let ResolvedClass;
|
|
3
|
+
const resolver = (resolve) => {
|
|
4
|
+
fn().then((module) => {
|
|
5
|
+
ResolvedClass = "default" in module ? module.default : module;
|
|
7
6
|
resolve(ResolvedClass);
|
|
8
7
|
});
|
|
9
8
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var timeout = (_options$timeout = options === null || options === void 0 ? void 0 : options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : 1;
|
|
15
|
-
|
|
16
|
-
if (!('requestIdleCallback' in window)) {
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const timeout = (_a = options == null ? void 0 : options.timeout) != null ? _a : 1;
|
|
12
|
+
if (!("requestIdleCallback" in window)) {
|
|
17
13
|
setTimeout(() => {
|
|
18
14
|
resolver(resolve);
|
|
19
15
|
}, timeout);
|
|
@@ -22,9 +18,10 @@ export default function importWhenIdle(fn, options) {
|
|
|
22
18
|
setTimeout(() => {
|
|
23
19
|
resolver(resolve);
|
|
24
20
|
}, 0);
|
|
25
|
-
}, {
|
|
26
|
-
timeout: options === null || options === void 0 ? void 0 : options.timeout
|
|
27
|
-
});
|
|
21
|
+
}, { timeout: options == null ? void 0 : options.timeout });
|
|
28
22
|
}
|
|
29
23
|
});
|
|
30
|
-
}
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
importWhenIdle as default
|
|
27
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
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/importWhenVisible.js
|
|
20
|
+
var importWhenVisible_exports = {};
|
|
21
|
+
__export(importWhenVisible_exports, {
|
|
22
|
+
default: () => importWhenVisible
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(importWhenVisible_exports);
|
|
25
|
+
var import_utils = require("./utils.cjs");
|
|
26
|
+
function importWhenVisible(fn, nameOrSelectorOrElement, parent, observerOptions = {}) {
|
|
27
|
+
let ResolvedClass;
|
|
28
|
+
const resolver = (resolve, cb) => {
|
|
29
|
+
fn().then((module2) => {
|
|
30
|
+
ResolvedClass = "default" in module2 ? module2.default : module2;
|
|
31
|
+
resolve(ResolvedClass);
|
|
32
|
+
if (typeof cb === "function") {
|
|
33
|
+
cb();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
return new Promise((resolve) => {
|
|
38
|
+
const observer = new IntersectionObserver((entries) => {
|
|
39
|
+
const someEntriesAreVisible = entries.some((entry) => entry.isIntersecting);
|
|
40
|
+
if (someEntriesAreVisible) {
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
resolver(resolve, () => observer.disconnect());
|
|
43
|
+
}, 0);
|
|
44
|
+
}
|
|
45
|
+
}, observerOptions);
|
|
46
|
+
const elements = (0, import_utils.getTargetElements)(nameOrSelectorOrElement, parent == null ? void 0 : parent.$el);
|
|
47
|
+
elements.forEach((element) => observer.observe(element));
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,30 +1,28 @@
|
|
|
1
|
-
import { getTargetElements } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
fn().then(module => {
|
|
8
|
-
ResolvedClass = 'default' in module ? module.default : module;
|
|
1
|
+
import { getTargetElements } from "./utils.js";
|
|
2
|
+
function importWhenVisible(fn, nameOrSelectorOrElement, parent, observerOptions = {}) {
|
|
3
|
+
let ResolvedClass;
|
|
4
|
+
const resolver = (resolve, cb) => {
|
|
5
|
+
fn().then((module) => {
|
|
6
|
+
ResolvedClass = "default" in module ? module.default : module;
|
|
9
7
|
resolve(ResolvedClass);
|
|
10
|
-
|
|
11
|
-
if (typeof cb === 'function') {
|
|
8
|
+
if (typeof cb === "function") {
|
|
12
9
|
cb();
|
|
13
10
|
}
|
|
14
11
|
});
|
|
15
12
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var someEntriesAreVisible = entries.some(entry => entry.isIntersecting);
|
|
20
|
-
|
|
13
|
+
return new Promise((resolve) => {
|
|
14
|
+
const observer = new IntersectionObserver((entries) => {
|
|
15
|
+
const someEntriesAreVisible = entries.some((entry) => entry.isIntersecting);
|
|
21
16
|
if (someEntriesAreVisible) {
|
|
22
17
|
setTimeout(() => {
|
|
23
18
|
resolver(resolve, () => observer.disconnect());
|
|
24
19
|
}, 0);
|
|
25
20
|
}
|
|
26
21
|
}, observerOptions);
|
|
27
|
-
|
|
28
|
-
elements.forEach(element => observer.observe(element));
|
|
22
|
+
const elements = getTargetElements(nameOrSelectorOrElement, parent == null ? void 0 : parent.$el);
|
|
23
|
+
elements.forEach((element) => observer.observe(element));
|
|
29
24
|
});
|
|
30
|
-
}
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
importWhenVisible as default
|
|
28
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
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/helpers/index.js
|
|
23
|
+
var helpers_exports = {};
|
|
24
|
+
__export(helpers_exports, {
|
|
25
|
+
createApp: () => import_createApp.default,
|
|
26
|
+
importOnInteraction: () => import_importOnInteraction.default,
|
|
27
|
+
importWhenIdle: () => import_importWhenIdle.default,
|
|
28
|
+
importWhenVisible: () => import_importWhenVisible.default
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(helpers_exports);
|
|
31
|
+
var import_createApp = __toESM(require("./createApp.cjs"), 1);
|
|
32
|
+
var import_importOnInteraction = __toESM(require("./importOnInteraction.cjs"), 1);
|
|
33
|
+
var import_importWhenIdle = __toESM(require("./importWhenIdle.cjs"), 1);
|
|
34
|
+
var import_importWhenVisible = __toESM(require("./importWhenVisible.cjs"), 1);
|
|
35
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/helpers/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export { createApp, importOnInteraction, importWhenIdle, importWhenVisible };
|
|
1
|
+
export { default as createApp } from "./createApp.js";
|
|
2
|
+
export { default as importOnInteraction } from "./importOnInteraction.js";
|
|
3
|
+
export { default as importWhenIdle } from "./importWhenIdle.js";
|
|
4
|
+
export { default as importWhenVisible } from "./importWhenVisible.js";
|
package/helpers/index.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
export {
|
|
1
|
+
import { default as default2 } from "./createApp.js";
|
|
2
|
+
import { default as default3 } from "./importOnInteraction.js";
|
|
3
|
+
import { default as default4 } from "./importWhenIdle.js";
|
|
4
|
+
import { default as default5 } from "./importWhenVisible.js";
|
|
5
|
+
export {
|
|
6
|
+
default2 as createApp,
|
|
7
|
+
default3 as importOnInteraction,
|
|
8
|
+
default4 as importWhenIdle,
|
|
9
|
+
default5 as importWhenVisible
|
|
10
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
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/utils.js
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
getTargetElements: () => getTargetElements
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(utils_exports);
|
|
25
|
+
var import_utils = require("../Base/utils.cjs");
|
|
26
|
+
function getTargetElements(nameOrSelectorOrElement, context) {
|
|
27
|
+
if (typeof nameOrSelectorOrElement === "string") {
|
|
28
|
+
return (0, import_utils.getComponentElements)(nameOrSelectorOrElement, context);
|
|
29
|
+
}
|
|
30
|
+
if (!Array.isArray(nameOrSelectorOrElement)) {
|
|
31
|
+
return [nameOrSelectorOrElement];
|
|
32
|
+
}
|
|
33
|
+
return nameOrSelectorOrElement;
|
|
34
|
+
}
|
|
35
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/helpers/utils.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { getComponentElements } from
|
|
2
|
-
|
|
3
|
-
if (typeof nameOrSelectorOrElement ===
|
|
1
|
+
import { getComponentElements } from "../Base/utils.js";
|
|
2
|
+
function getTargetElements(nameOrSelectorOrElement, context) {
|
|
3
|
+
if (typeof nameOrSelectorOrElement === "string") {
|
|
4
4
|
return getComponentElements(nameOrSelectorOrElement, context);
|
|
5
5
|
}
|
|
6
|
-
|
|
7
6
|
if (!Array.isArray(nameOrSelectorOrElement)) {
|
|
8
7
|
return [nameOrSelectorOrElement];
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
return nameOrSelectorOrElement;
|
|
12
|
-
}
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
getTargetElements
|
|
13
|
+
};
|
package/index.cjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
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 __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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
|
|
23
|
+
// packages/js-toolkit/index.js
|
|
24
|
+
var js_toolkit_exports = {};
|
|
25
|
+
__export(js_toolkit_exports, {
|
|
26
|
+
Base: () => import_Base.default
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(js_toolkit_exports);
|
|
29
|
+
var import_Base = __toESM(require("./Base/index.cjs"), 1);
|
|
30
|
+
__reExport(js_toolkit_exports, require("./decorators/index.cjs"), module.exports);
|
|
31
|
+
__reExport(js_toolkit_exports, require("./helpers/index.cjs"), module.exports);
|
|
32
|
+
__reExport(js_toolkit_exports, require("./services/index.cjs"), module.exports);
|
|
33
|
+
if (module.exports.default) module.exports = module.exports.default;
|