@studiometa/js-toolkit 2.4.4-alpha.2 → 2.4.4-alpha.5
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 +2 -2
- package/Base/index.d.ts +76 -216
- package/Base/index.js +1 -1
- package/Base/managers/AbstractManager.d.ts +2 -2
- package/Base/managers/ChildrenManager.cjs +2 -4
- package/Base/managers/ChildrenManager.d.ts +2 -10
- package/Base/managers/ChildrenManager.js +1 -3
- package/Base/managers/EventsManager.cjs +3 -3
- package/Base/managers/EventsManager.d.ts +9 -15
- package/Base/managers/EventsManager.js +2 -2
- package/Base/managers/OptionsManager.d.ts +1 -1
- package/Base/managers/ServicesManager.d.ts +1 -1
- package/Base/utils.cjs +1 -1
- package/Base/utils.d.ts +5 -21
- package/decorators/index.cjs +4 -2
- package/decorators/index.d.ts +2 -1
- package/decorators/index.js +3 -2
- package/decorators/withBreakpointManager.cjs +3 -2
- package/decorators/withBreakpointManager.d.ts +2 -84
- package/decorators/withBreakpointManager.js +3 -2
- package/decorators/withBreakpointObserver.cjs +6 -4
- package/decorators/withBreakpointObserver.d.ts +76 -49
- package/decorators/withBreakpointObserver.js +6 -4
- package/decorators/withDrag.cjs +5 -4
- package/decorators/withDrag.d.ts +63 -49
- package/decorators/withDrag.js +5 -4
- package/decorators/withExtraConfig.cjs +4 -3
- package/decorators/withExtraConfig.d.ts +63 -48
- package/decorators/withExtraConfig.js +4 -3
- package/decorators/withFreezedOptions.cjs +3 -2
- package/decorators/withFreezedOptions.d.ts +71 -47
- package/decorators/withFreezedOptions.js +3 -2
- package/decorators/withIntersectionObserver.cjs +6 -4
- package/decorators/withIntersectionObserver.d.ts +67 -48
- package/decorators/withIntersectionObserver.js +6 -4
- package/decorators/withMountWhenInView.cjs +10 -5
- package/decorators/withMountWhenInView.d.ts +76 -49
- package/decorators/withMountWhenInView.js +10 -5
- package/decorators/withResponsiveOptions.cjs +3 -2
- package/decorators/withResponsiveOptions.d.ts +68 -48
- package/decorators/withResponsiveOptions.js +3 -2
- package/decorators/withScrolledInView.cjs +12 -7
- package/decorators/withScrolledInView.d.ts +224 -80
- package/decorators/withScrolledInView.js +12 -7
- package/decorators/withType.cjs +28 -0
- package/decorators/withType.d.ts +5 -0
- package/decorators/withType.js +6 -0
- package/decorators/withVue2.cjs +7 -4
- package/decorators/withVue2.d.ts +64 -48
- package/decorators/withVue2.js +7 -4
- package/helpers/createApp.cjs +1 -1
- package/helpers/createApp.d.ts +2 -10
- package/helpers/getDirectChildren.cjs +5 -5
- package/helpers/getDirectChildren.d.ts +3 -13
- package/helpers/getDirectChildren.js +4 -4
- package/helpers/getInstanceFromElement.cjs +3 -4
- package/helpers/getInstanceFromElement.d.ts +2 -11
- package/helpers/getInstanceFromElement.js +2 -3
- package/helpers/importOnInteraction.cjs +1 -1
- package/helpers/importOnInteraction.d.ts +4 -9
- package/helpers/importWhenIdle.cjs +3 -5
- package/helpers/importWhenIdle.d.ts +7 -10
- package/helpers/importWhenIdle.js +2 -4
- package/helpers/importWhenVisible.cjs +1 -1
- package/helpers/importWhenVisible.d.ts +2 -7
- package/helpers/index.cjs +1 -1
- package/helpers/index.d.ts +6 -6
- package/helpers/utils.cjs +1 -1
- package/helpers/utils.d.ts +1 -1
- package/index.cjs +2 -8
- package/index.d.ts +1 -1
- package/index.js +2 -2
- package/package.json +1 -1
package/decorators/withVue2.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type Vue from 'vue';
|
|
2
2
|
import type { ComponentOptions, VueConstructor } from 'vue';
|
|
3
|
-
import type { BaseConstructor, BaseTypeParameter } from '../Base/index.js';
|
|
3
|
+
import type { Base, BaseConstructor, BaseTypeParameter } from '../Base/index.js';
|
|
4
4
|
interface WithVue2Interface {
|
|
5
5
|
$refs: {
|
|
6
6
|
vue: HTMLElement;
|
|
@@ -9,52 +9,31 @@ interface WithVue2Interface {
|
|
|
9
9
|
/**
|
|
10
10
|
* withVue decorator.
|
|
11
11
|
*/
|
|
12
|
-
export default function withVue2<T extends BaseTypeParameter = BaseTypeParameter, VueTypeParameter extends Vue = Vue>(BaseClass:
|
|
13
|
-
new
|
|
12
|
+
export default function withVue2<S extends BaseConstructor<Base>, T extends BaseTypeParameter = BaseTypeParameter, VueTypeParameter extends Vue = Vue>(BaseClass: S, VueCtor: VueConstructor): {
|
|
13
|
+
new (...args: any[]): {
|
|
14
14
|
$vue: Vue;
|
|
15
|
-
$parent:
|
|
16
|
-
$el: HTMLElement;
|
|
17
|
-
$options: import("../Base/index.js").BaseOptions;
|
|
18
|
-
$refs: import("../Base/index.js").BaseRefs;
|
|
19
|
-
$children: {
|
|
20
|
-
[name: string]: import("../Base/index.js").default<any> | Promise<import("../Base/index.js").default<any>>;
|
|
21
|
-
};
|
|
22
|
-
}>;
|
|
15
|
+
$parent: Base<BaseTypeParameter>;
|
|
23
16
|
$id: string;
|
|
24
|
-
$el:
|
|
25
|
-
__base__?: WeakMap<
|
|
26
|
-
$el: HTMLElement;
|
|
27
|
-
$options: import("../Base/index.js").BaseOptions;
|
|
28
|
-
$refs: import("../Base/index.js").BaseRefs;
|
|
29
|
-
$children: {
|
|
30
|
-
[name: string]: import("../Base/index.js").default<any> | Promise<import("../Base/index.js").default<any>>;
|
|
31
|
-
};
|
|
32
|
-
}> | "terminated">;
|
|
17
|
+
$el: HTMLElement & {
|
|
18
|
+
__base__?: WeakMap<BaseConstructor<Base<BaseTypeParameter>>, Base<BaseTypeParameter> | "terminated">;
|
|
33
19
|
};
|
|
34
20
|
$isMounted: boolean;
|
|
35
21
|
__eventHandlers: Map<string, Set<EventListenerOrEventListenerObject>>;
|
|
36
|
-
readonly $root:
|
|
37
|
-
$el: HTMLElement;
|
|
38
|
-
$options: import("../Base/index.js").BaseOptions;
|
|
39
|
-
$refs: import("../Base/index.js").BaseRefs;
|
|
40
|
-
$children: {
|
|
41
|
-
[name: string]: import("../Base/index.js").default<any> | Promise<import("../Base/index.js").default<any>>;
|
|
42
|
-
};
|
|
43
|
-
}>;
|
|
22
|
+
readonly $root: Base<BaseTypeParameter>;
|
|
44
23
|
readonly __config: import("../Base/index.js").BaseConfig;
|
|
45
24
|
__services: import("../Base/managers/ServicesManager.js").default;
|
|
46
25
|
readonly $services: import("../Base/managers/ServicesManager.js").default;
|
|
47
|
-
__refs: import("../Base/managers/RefsManager.js").default &
|
|
48
|
-
readonly $refs: import("../Base/managers/RefsManager.js").default &
|
|
49
|
-
__options: import("../Base/managers/OptionsManager.js").default &
|
|
50
|
-
readonly $options: import("../Base/managers/OptionsManager.js").default &
|
|
51
|
-
__children: import("../Base/managers/ChildrenManager.js").default &
|
|
52
|
-
readonly $children: import("../Base/managers/ChildrenManager.js").default &
|
|
26
|
+
__refs: import("../Base/managers/RefsManager.js").default & import("../Base/index.js").BaseRefs;
|
|
27
|
+
readonly $refs: import("../Base/managers/RefsManager.js").default & import("../Base/index.js").BaseRefs;
|
|
28
|
+
__options: import("../Base/managers/OptionsManager.js").default & import("../Base/index.js").BaseOptions;
|
|
29
|
+
readonly $options: import("../Base/managers/OptionsManager.js").default & import("../Base/index.js").BaseOptions;
|
|
30
|
+
__children: import("../Base/managers/ChildrenManager.js").default & import("../Base/index.js").BaseChildren;
|
|
31
|
+
readonly $children: import("../Base/managers/ChildrenManager.js").default & import("../Base/index.js").BaseChildren;
|
|
53
32
|
__events: import("../Base/managers/EventsManager.js").default;
|
|
54
|
-
readonly $log: (...args:
|
|
55
|
-
readonly __debug: (...args:
|
|
33
|
+
readonly $log: (...args: unknown[]) => void;
|
|
34
|
+
readonly __debug: (...args: unknown[]) => void;
|
|
56
35
|
readonly __managers: import("../Base/index.js").Managers;
|
|
57
|
-
__callMethod(method: string, ...args:
|
|
36
|
+
__callMethod(method: string, ...args: unknown[]): unknown;
|
|
58
37
|
__hasEvent(event: string): boolean;
|
|
59
38
|
$mount(): any;
|
|
60
39
|
$update(): any;
|
|
@@ -62,10 +41,51 @@ export default function withVue2<T extends BaseTypeParameter = BaseTypeParameter
|
|
|
62
41
|
$terminate(): void;
|
|
63
42
|
__addEmits(event: string): void;
|
|
64
43
|
__removeEmits(event: string): void;
|
|
65
|
-
readonly __ctor:
|
|
44
|
+
readonly __ctor: BaseConstructor<Base<BaseTypeParameter>>;
|
|
66
45
|
$on(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): () => void;
|
|
67
46
|
$off(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
68
|
-
$emit(event: string, ...args:
|
|
47
|
+
$emit(event: string, ...args: unknown[]): void;
|
|
48
|
+
addEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
49
|
+
dispatchEvent(event: Event): boolean;
|
|
50
|
+
removeEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
51
|
+
};
|
|
52
|
+
prototype: Base<BaseTypeParameter>;
|
|
53
|
+
} & Pick<typeof Base, "prototype" | "$isBase" | "config" | "$factory"> & Pick<{
|
|
54
|
+
new (element: HTMLElement): {
|
|
55
|
+
$vue: Vue;
|
|
56
|
+
$parent: Base<BaseTypeParameter>;
|
|
57
|
+
$id: string;
|
|
58
|
+
$el: HTMLElement & {
|
|
59
|
+
__base__?: WeakMap<BaseConstructor<Base<BaseTypeParameter>>, Base<BaseTypeParameter> | "terminated">;
|
|
60
|
+
};
|
|
61
|
+
$isMounted: boolean;
|
|
62
|
+
__eventHandlers: Map<string, Set<EventListenerOrEventListenerObject>>;
|
|
63
|
+
readonly $root: Base<BaseTypeParameter>;
|
|
64
|
+
readonly __config: import("../Base/index.js").BaseConfig;
|
|
65
|
+
__services: import("../Base/managers/ServicesManager.js").default;
|
|
66
|
+
readonly $services: import("../Base/managers/ServicesManager.js").default;
|
|
67
|
+
__refs: import("../Base/managers/RefsManager.js").default & import("../Base/index.js").BaseRefs;
|
|
68
|
+
readonly $refs: import("../Base/managers/RefsManager.js").default & import("../Base/index.js").BaseRefs;
|
|
69
|
+
__options: import("../Base/managers/OptionsManager.js").default & import("../Base/index.js").BaseOptions;
|
|
70
|
+
readonly $options: import("../Base/managers/OptionsManager.js").default & import("../Base/index.js").BaseOptions;
|
|
71
|
+
__children: import("../Base/managers/ChildrenManager.js").default & import("../Base/index.js").BaseChildren;
|
|
72
|
+
readonly $children: import("../Base/managers/ChildrenManager.js").default & import("../Base/index.js").BaseChildren;
|
|
73
|
+
__events: import("../Base/managers/EventsManager.js").default;
|
|
74
|
+
readonly $log: (...args: unknown[]) => void;
|
|
75
|
+
readonly __debug: (...args: unknown[]) => void;
|
|
76
|
+
readonly __managers: import("../Base/index.js").Managers;
|
|
77
|
+
__callMethod(method: string, ...args: unknown[]): unknown;
|
|
78
|
+
__hasEvent(event: string): boolean;
|
|
79
|
+
$mount(): any;
|
|
80
|
+
$update(): any;
|
|
81
|
+
$destroy(): any;
|
|
82
|
+
$terminate(): void;
|
|
83
|
+
__addEmits(event: string): void;
|
|
84
|
+
__removeEmits(event: string): void;
|
|
85
|
+
readonly __ctor: BaseConstructor<Base<BaseTypeParameter>>;
|
|
86
|
+
$on(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): () => void;
|
|
87
|
+
$off(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
88
|
+
$emit(event: string, ...args: unknown[]): void;
|
|
69
89
|
addEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
70
90
|
dispatchEvent(event: Event): boolean;
|
|
71
91
|
removeEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
@@ -85,14 +105,10 @@ export default function withVue2<T extends BaseTypeParameter = BaseTypeParameter
|
|
|
85
105
|
vueConfig: ComponentOptions<VueTypeParameter, import("vue/types/options.js").DefaultData<VueTypeParameter>, import("vue/types/options.js").DefaultMethods<VueTypeParameter>, import("vue/types/options.js").DefaultComputed, import("vue/types/options.js").PropsDefinition<import("vue/types/options.js").DefaultProps>, import("vue/types/options.js").DefaultProps> & {
|
|
86
106
|
render: ComponentOptions<VueTypeParameter>['render'];
|
|
87
107
|
};
|
|
88
|
-
readonly $isBase:
|
|
89
|
-
$factory
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
$children: {
|
|
94
|
-
[name: string]: import("../Base/index.js").default<any> | Promise<import("../Base/index.js").default<any>>;
|
|
95
|
-
};
|
|
96
|
-
}>[];
|
|
108
|
+
readonly $isBase: true;
|
|
109
|
+
$factory: typeof Base.$factory;
|
|
110
|
+
} & S, "prototype" | "$isBase" | "config" | "$factory" | "vueConfig" | keyof S> & S & {
|
|
111
|
+
new (...args: any[]): Base<T & WithVue2Interface>;
|
|
112
|
+
prototype: Base<BaseTypeParameter>;
|
|
97
113
|
};
|
|
98
114
|
export {};
|
package/decorators/withVue2.js
CHANGED
|
@@ -6,8 +6,8 @@ var __publicField = (obj, key, value) => {
|
|
|
6
6
|
};
|
|
7
7
|
import { isDev, isFunction } from "../utils/index.js";
|
|
8
8
|
function withVue2(BaseClass, VueCtor) {
|
|
9
|
-
var _a, _b
|
|
10
|
-
|
|
9
|
+
var _a, _b;
|
|
10
|
+
class WithVue2 extends BaseClass {
|
|
11
11
|
constructor(element) {
|
|
12
12
|
var _a2;
|
|
13
13
|
super(element);
|
|
@@ -36,11 +36,14 @@ function withVue2(BaseClass, VueCtor) {
|
|
|
36
36
|
this.$vue.$destroy();
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
}
|
|
39
|
+
}
|
|
40
|
+
__publicField(WithVue2, "config", {
|
|
40
41
|
...BaseClass.config,
|
|
41
42
|
name: `${BaseClass.config.name}WithVue`,
|
|
42
43
|
refs: [...(_b = (_a = BaseClass.config) == null ? void 0 : _a.refs) != null ? _b : [], "vue"]
|
|
43
|
-
})
|
|
44
|
+
});
|
|
45
|
+
__publicField(WithVue2, "vueConfig");
|
|
46
|
+
return WithVue2;
|
|
44
47
|
}
|
|
45
48
|
export {
|
|
46
49
|
withVue2 as default
|
package/helpers/createApp.cjs
CHANGED
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// packages/js-toolkit/helpers/createApp.
|
|
19
|
+
// packages/js-toolkit/helpers/createApp.ts
|
|
20
20
|
var createApp_exports = {};
|
|
21
21
|
__export(createApp_exports, {
|
|
22
22
|
default: () => createApp
|
package/helpers/createApp.d.ts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
* @typedef {import('../Base/index.js').BaseConstructor} BaseConstructor
|
|
3
|
-
*/
|
|
1
|
+
import type { Base, BaseConstructor, BaseTypeParameter } from '../Base/index.js';
|
|
4
2
|
/**
|
|
5
3
|
* Instantiate and mount the given component on the given root element when the page has been loaded
|
|
6
4
|
* and return a function to use the app instance when it is ready.
|
|
7
|
-
*
|
|
8
|
-
* @template {BaseConstructor} T
|
|
9
|
-
* @param {T} App
|
|
10
|
-
* @param {HTMLElement} [rootElement]
|
|
11
|
-
* @returns {() => Promise<InstanceType<T>>}
|
|
12
5
|
*/
|
|
13
|
-
export default function createApp<T extends
|
|
14
|
-
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
|
6
|
+
export default function createApp<S extends BaseConstructor<Base>, T extends BaseTypeParameter = BaseTypeParameter>(App: S, rootElement?: HTMLElement): () => Promise<S & Base<T>>;
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// packages/js-toolkit/helpers/getDirectChildren.
|
|
19
|
+
// packages/js-toolkit/helpers/getDirectChildren.ts
|
|
20
20
|
var getDirectChildren_exports = {};
|
|
21
21
|
__export(getDirectChildren_exports, {
|
|
22
22
|
getDirectChildren: () => getDirectChildren,
|
|
@@ -33,12 +33,12 @@ function getDirectChildren(parentInstance, parentName, childrenName) {
|
|
|
33
33
|
if (!(0, import_utils.isArray)(nestedParents) || nestedParents.length <= 0) {
|
|
34
34
|
return children;
|
|
35
35
|
}
|
|
36
|
-
return children.filter(
|
|
37
|
-
|
|
36
|
+
return [...children].filter(
|
|
37
|
+
(child) => [...nestedParents].every((nestedParent) => {
|
|
38
38
|
const nestedChildren = nestedParent.$children[childrenName];
|
|
39
39
|
return (0, import_utils.isArray)(nestedChildren) ? !nestedChildren.includes(child) : true;
|
|
40
|
-
})
|
|
41
|
-
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
42
|
}
|
|
43
43
|
function isDirectChild(parentInstance, parentName, childrenName, childInstance) {
|
|
44
44
|
return getDirectChildren(parentInstance, parentName, childrenName).includes(childInstance);
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @typedef {import('../Base/index.js').default} Base
|
|
3
|
-
*/
|
|
1
|
+
import { Base } from '../Base/index.js';
|
|
4
2
|
/**
|
|
5
3
|
* Get direct children from a parent when working with nested components.
|
|
6
4
|
*
|
|
@@ -10,14 +8,7 @@
|
|
|
10
8
|
* @param {string} childrenName
|
|
11
9
|
* @returns {T[]}
|
|
12
10
|
*/
|
|
13
|
-
export function getDirectChildren<T extends
|
|
14
|
-
$el: HTMLElement;
|
|
15
|
-
$options: import("../Base/index.js").BaseOptions;
|
|
16
|
-
$refs: import("../Base/index.js").BaseRefs;
|
|
17
|
-
$children: {
|
|
18
|
-
[name: string]: import("../Base/index.js").default<any> | Promise<import("../Base/index.js").default<any>>;
|
|
19
|
-
};
|
|
20
|
-
}>>(parentInstance: Base, parentName: string, childrenName: string): T[];
|
|
11
|
+
export declare function getDirectChildren<T extends Base = Base>(parentInstance: Base, parentName: string, childrenName: string): T[];
|
|
21
12
|
/**
|
|
22
13
|
* Test if a component instance is a direct child from the given component.
|
|
23
14
|
*
|
|
@@ -27,5 +18,4 @@ export function getDirectChildren<T extends import("../Base/index.js").default<{
|
|
|
27
18
|
* @param {Base} childInstance
|
|
28
19
|
* @returns {boolean}
|
|
29
20
|
*/
|
|
30
|
-
export function isDirectChild(parentInstance:
|
|
31
|
-
export type Base = import('../Base/index.js').default;
|
|
21
|
+
export declare function isDirectChild(parentInstance: any, parentName: any, childrenName: any, childInstance: any): boolean;
|
|
@@ -8,12 +8,12 @@ function getDirectChildren(parentInstance, parentName, childrenName) {
|
|
|
8
8
|
if (!isArray(nestedParents) || nestedParents.length <= 0) {
|
|
9
9
|
return children;
|
|
10
10
|
}
|
|
11
|
-
return children.filter(
|
|
12
|
-
|
|
11
|
+
return [...children].filter(
|
|
12
|
+
(child) => [...nestedParents].every((nestedParent) => {
|
|
13
13
|
const nestedChildren = nestedParent.$children[childrenName];
|
|
14
14
|
return isArray(nestedChildren) ? !nestedChildren.includes(child) : true;
|
|
15
|
-
})
|
|
16
|
-
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
17
|
}
|
|
18
18
|
function isDirectChild(parentInstance, parentName, childrenName, childInstance) {
|
|
19
19
|
return getDirectChildren(parentInstance, parentName, childrenName).includes(childInstance);
|
|
@@ -16,17 +16,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// packages/js-toolkit/helpers/getInstanceFromElement.
|
|
19
|
+
// packages/js-toolkit/helpers/getInstanceFromElement.ts
|
|
20
20
|
var getInstanceFromElement_exports = {};
|
|
21
21
|
__export(getInstanceFromElement_exports, {
|
|
22
22
|
default: () => getInstanceFromElement
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(getInstanceFromElement_exports);
|
|
25
25
|
function getInstanceFromElement(element, Constructor) {
|
|
26
|
-
|
|
27
|
-
if (!element.__base__) {
|
|
26
|
+
if (!element.__base__ || !element.__base__.has(Constructor)) {
|
|
28
27
|
return null;
|
|
29
28
|
}
|
|
30
|
-
return
|
|
29
|
+
return element.__base__.get(Constructor);
|
|
31
30
|
}
|
|
32
31
|
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
* @typedef {import('../Base/index.js').BaseConstructor} BaseConstructor
|
|
3
|
-
*/
|
|
1
|
+
import type { BaseConstructor, BaseEl } from '../Base/index.js';
|
|
4
2
|
/**
|
|
5
3
|
* Get a component instance from a DOM element.
|
|
6
|
-
* @template {BaseConstructor} T
|
|
7
|
-
* @param {HTMLElement & { __base__?: WeakMap<T, InstanceType<T>> }} element
|
|
8
|
-
* @param {T} Constructor
|
|
9
|
-
* @returns {null|InstanceType<T>}
|
|
10
4
|
*/
|
|
11
|
-
export default function getInstanceFromElement<T extends
|
|
12
|
-
__base__?: WeakMap<T, InstanceType<T>>;
|
|
13
|
-
}, Constructor: T): InstanceType<T>;
|
|
14
|
-
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
|
5
|
+
export default function getInstanceFromElement<T extends BaseConstructor>(element: BaseEl, Constructor: T): InstanceType<T> | null;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
function getInstanceFromElement(element, Constructor) {
|
|
2
|
-
|
|
3
|
-
if (!element.__base__) {
|
|
2
|
+
if (!element.__base__ || !element.__base__.has(Constructor)) {
|
|
4
3
|
return null;
|
|
5
4
|
}
|
|
6
|
-
return
|
|
5
|
+
return element.__base__.get(Constructor);
|
|
7
6
|
}
|
|
8
7
|
export {
|
|
9
8
|
getInstanceFromElement as default
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// packages/js-toolkit/helpers/importOnInteraction.
|
|
19
|
+
// packages/js-toolkit/helpers/importOnInteraction.ts
|
|
20
20
|
var importOnInteraction_exports = {};
|
|
21
21
|
__export(importOnInteraction_exports, {
|
|
22
22
|
default: () => importOnInteraction
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
* @typedef {import('../Base/index.js').BaseConstructor} BaseConstructor
|
|
3
|
-
* @typedef {import('../Base/index.js').default} Base
|
|
4
|
-
*/
|
|
1
|
+
import type { Base, BaseConstructor } from '../Base/index.js';
|
|
5
2
|
/**
|
|
6
3
|
* Import a component on an interaction.
|
|
7
4
|
*
|
|
8
|
-
* @template {BaseConstructor} T
|
|
5
|
+
* @template {BaseConstructor} [T=BaseConstructor]
|
|
9
6
|
* @param {() => Promise<T|{default:T}>} fn
|
|
10
7
|
* The import function.
|
|
11
8
|
* @param {string|HTMLElement|HTMLElement[]} nameOrSelectorOrElement
|
|
@@ -14,10 +11,8 @@
|
|
|
14
11
|
* The events to listen to to trigger the import.
|
|
15
12
|
* @param {Base} [parent]
|
|
16
13
|
* The parent component.
|
|
17
|
-
* @returns {Promise<T
|
|
14
|
+
* @returns {Promise<InstanceType<T>>}
|
|
18
15
|
*/
|
|
19
|
-
export default function importOnInteraction<T extends
|
|
16
|
+
export default function importOnInteraction<T extends BaseConstructor = BaseConstructor>(fn: () => Promise<T | {
|
|
20
17
|
default: T;
|
|
21
18
|
}>, nameOrSelectorOrElement: string | HTMLElement | HTMLElement[], events: string | string[], parent?: Base): Promise<T>;
|
|
22
|
-
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
|
23
|
-
export type Base = import('../Base/index.js').default;
|
|
@@ -16,13 +16,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// packages/js-toolkit/helpers/importWhenIdle.
|
|
19
|
+
// packages/js-toolkit/helpers/importWhenIdle.ts
|
|
20
20
|
var importWhenIdle_exports = {};
|
|
21
21
|
__export(importWhenIdle_exports, {
|
|
22
22
|
default: () => importWhenIdle
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(importWhenIdle_exports);
|
|
25
|
-
function importWhenIdle(fn,
|
|
25
|
+
function importWhenIdle(fn, { timeout = 1 } = {}) {
|
|
26
26
|
let ResolvedClass;
|
|
27
27
|
const resolver = (resolve) => {
|
|
28
28
|
fn().then((module2) => {
|
|
@@ -31,8 +31,6 @@ function importWhenIdle(fn, options) {
|
|
|
31
31
|
});
|
|
32
32
|
};
|
|
33
33
|
return new Promise((resolve) => {
|
|
34
|
-
var _a;
|
|
35
|
-
const timeout = (_a = options == null ? void 0 : options.timeout) != null ? _a : 1;
|
|
36
34
|
if (!("requestIdleCallback" in window)) {
|
|
37
35
|
setTimeout(() => {
|
|
38
36
|
resolver(resolve);
|
|
@@ -44,7 +42,7 @@ function importWhenIdle(fn, options) {
|
|
|
44
42
|
resolver(resolve);
|
|
45
43
|
}, 0);
|
|
46
44
|
},
|
|
47
|
-
{ timeout
|
|
45
|
+
{ timeout }
|
|
48
46
|
);
|
|
49
47
|
}
|
|
50
48
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { BaseConstructor } from '../Base/index.js';
|
|
2
|
+
declare type ImportWhenIdleOptions = {
|
|
3
|
+
timeout?: number;
|
|
4
|
+
};
|
|
5
5
|
/**
|
|
6
6
|
* Import a component when user is idle.
|
|
7
7
|
*
|
|
@@ -12,10 +12,7 @@
|
|
|
12
12
|
* The time to wait before triggering the callback if never idle.
|
|
13
13
|
* @returns {Promise<T>}
|
|
14
14
|
*/
|
|
15
|
-
export default function importWhenIdle<T extends
|
|
15
|
+
export default function importWhenIdle<T extends BaseConstructor = BaseConstructor>(fn: () => Promise<T | {
|
|
16
16
|
default: T;
|
|
17
|
-
}>,
|
|
18
|
-
export
|
|
19
|
-
export type ImportWhenIdleOptions = {
|
|
20
|
-
timeout?: number;
|
|
21
|
-
};
|
|
17
|
+
}>, { timeout }?: ImportWhenIdleOptions): Promise<T>;
|
|
18
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function importWhenIdle(fn,
|
|
1
|
+
function importWhenIdle(fn, { timeout = 1 } = {}) {
|
|
2
2
|
let ResolvedClass;
|
|
3
3
|
const resolver = (resolve) => {
|
|
4
4
|
fn().then((module) => {
|
|
@@ -7,8 +7,6 @@ function importWhenIdle(fn, options) {
|
|
|
7
7
|
});
|
|
8
8
|
};
|
|
9
9
|
return new Promise((resolve) => {
|
|
10
|
-
var _a;
|
|
11
|
-
const timeout = (_a = options == null ? void 0 : options.timeout) != null ? _a : 1;
|
|
12
10
|
if (!("requestIdleCallback" in window)) {
|
|
13
11
|
setTimeout(() => {
|
|
14
12
|
resolver(resolve);
|
|
@@ -20,7 +18,7 @@ function importWhenIdle(fn, options) {
|
|
|
20
18
|
resolver(resolve);
|
|
21
19
|
}, 0);
|
|
22
20
|
},
|
|
23
|
-
{ timeout
|
|
21
|
+
{ timeout }
|
|
24
22
|
);
|
|
25
23
|
}
|
|
26
24
|
});
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// packages/js-toolkit/helpers/importWhenVisible.
|
|
19
|
+
// packages/js-toolkit/helpers/importWhenVisible.ts
|
|
20
20
|
var importWhenVisible_exports = {};
|
|
21
21
|
__export(importWhenVisible_exports, {
|
|
22
22
|
default: () => importWhenVisible
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @typedef {import('../Base/index.js').default} Base
|
|
3
|
-
* @typedef {import('../Base/index.js').BaseConstructor} BaseConstructor
|
|
4
|
-
*/
|
|
1
|
+
import type { Base, BaseConstructor } from '../Base/index.js';
|
|
5
2
|
/**
|
|
6
3
|
* Import a component when it is visible.
|
|
7
4
|
*
|
|
@@ -16,8 +13,6 @@
|
|
|
16
13
|
* Options for the `IntersectionObserver` instance.
|
|
17
14
|
* @returns {Promise<T>}
|
|
18
15
|
*/
|
|
19
|
-
export default function importWhenVisible<T extends
|
|
16
|
+
export default function importWhenVisible<T extends BaseConstructor = BaseConstructor>(fn: () => Promise<T | {
|
|
20
17
|
default: T;
|
|
21
18
|
}>, nameOrSelectorOrElement: string | HTMLElement | HTMLElement[], parent?: Base, observerOptions?: IntersectionObserverInit): Promise<T>;
|
|
22
|
-
export type Base = import('../Base/index.js').default;
|
|
23
|
-
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
package/helpers/index.cjs
CHANGED
|
@@ -23,7 +23,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
));
|
|
24
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
25
|
|
|
26
|
-
// packages/js-toolkit/helpers/index.
|
|
26
|
+
// packages/js-toolkit/helpers/index.ts
|
|
27
27
|
var helpers_exports = {};
|
|
28
28
|
__export(helpers_exports, {
|
|
29
29
|
createApp: () => import_createApp.default,
|
package/helpers/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { default as createApp } from
|
|
2
|
-
export * from
|
|
3
|
-
export { default as getInstanceFromElement } from
|
|
4
|
-
export { default as importOnInteraction } from
|
|
5
|
-
export { default as importWhenIdle } from
|
|
6
|
-
export { default as importWhenVisible } from
|
|
1
|
+
export { default as createApp } from './createApp.js';
|
|
2
|
+
export * from './getDirectChildren.js';
|
|
3
|
+
export { default as getInstanceFromElement } from './getInstanceFromElement.js';
|
|
4
|
+
export { default as importOnInteraction } from './importOnInteraction.js';
|
|
5
|
+
export { default as importWhenIdle } from './importWhenIdle.js';
|
|
6
|
+
export { default as importWhenVisible } from './importWhenVisible.js';
|
package/helpers/utils.cjs
CHANGED
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// packages/js-toolkit/helpers/utils.
|
|
19
|
+
// packages/js-toolkit/helpers/utils.ts
|
|
20
20
|
var utils_exports = {};
|
|
21
21
|
__export(utils_exports, {
|
|
22
22
|
getTargetElements: () => getTargetElements
|
package/helpers/utils.d.ts
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* The optional context to use to query for elements.
|
|
8
8
|
* @returns {HTMLElement[]} A normalized list of elements.
|
|
9
9
|
*/
|
|
10
|
-
export function getTargetElements(nameOrSelectorOrElement: string | HTMLElement | HTMLElement[], context
|
|
10
|
+
export declare function getTargetElements(nameOrSelectorOrElement: string | HTMLElement | HTMLElement[], context: HTMLElement): HTMLElement[];
|
package/index.cjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -17,19 +15,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
17
|
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
|
-
));
|
|
24
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
19
|
|
|
26
20
|
// packages/js-toolkit/index.ts
|
|
27
21
|
var js_toolkit_exports = {};
|
|
28
22
|
__export(js_toolkit_exports, {
|
|
29
|
-
Base: () => import_Base.
|
|
23
|
+
Base: () => import_Base.Base
|
|
30
24
|
});
|
|
31
25
|
module.exports = __toCommonJS(js_toolkit_exports);
|
|
32
|
-
var import_Base =
|
|
26
|
+
var import_Base = require("./Base/index.cjs");
|
|
33
27
|
__reExport(js_toolkit_exports, require("./decorators/index.cjs"), module.exports);
|
|
34
28
|
__reExport(js_toolkit_exports, require("./helpers/index.cjs"), module.exports);
|
|
35
29
|
__reExport(js_toolkit_exports, require("./services/index.cjs"), module.exports);
|
package/index.d.ts
CHANGED
package/index.js
CHANGED