@studiometa/js-toolkit 2.4.4-alpha.0 → 2.4.4-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Base/index.cjs +1 -1
- package/Base/index.d.ts +198 -0
- package/Base/managers/AbstractManager.d.ts +44 -0
- package/Base/managers/ChildrenManager.d.ts +41 -0
- package/Base/managers/EventsManager.d.ts +112 -0
- package/Base/managers/OptionsManager.d.ts +87 -0
- package/Base/managers/RefsManager.d.ts +32 -0
- package/Base/managers/ResponsiveOptionsManager.cjs +1 -1
- package/Base/managers/ResponsiveOptionsManager.d.ts +22 -0
- package/Base/managers/ServicesManager.d.ts +109 -0
- package/Base/types.cjs +18 -0
- package/Base/types.d.ts +43 -0
- package/Base/types.js +0 -0
- package/Base/utils.d.ts +40 -0
- package/decorators/index.d.ts +10 -0
- package/decorators/withBreakpointManager.d.ts +59 -0
- package/decorators/withBreakpointObserver.d.ts +65 -0
- package/decorators/withDrag.d.ts +56 -0
- package/decorators/withExtraConfig.d.ts +57 -0
- package/decorators/withFreezedOptions.d.ts +56 -0
- package/decorators/withIntersectionObserver.d.ts +69 -0
- package/decorators/withMountWhenInView.d.ts +67 -0
- package/decorators/withResponsiveOptions.d.ts +53 -0
- package/decorators/withScrolledInView.d.ts +171 -0
- package/decorators/withVue2.cjs +2 -2
- package/decorators/withVue2.d.ts +70 -0
- package/decorators/withVue2.js +2 -2
- package/helpers/createApp.d.ts +14 -0
- package/helpers/getDirectChildren.d.ts +24 -0
- package/helpers/getInstanceFromElement.d.ts +14 -0
- package/helpers/importOnInteraction.d.ts +23 -0
- package/helpers/importWhenIdle.d.ts +21 -0
- package/helpers/importWhenVisible.d.ts +23 -0
- package/helpers/index.d.ts +6 -0
- package/helpers/utils.d.ts +10 -0
- package/index.d.ts +6 -0
- package/package.json +1 -1
- package/services/drag.d.ts +1 -1
- package/services/index.cjs +1 -1
- package/services/index.d.ts +33 -25
- package/services/key.d.ts +1 -1
- package/services/load.d.ts +1 -1
- package/services/pointer.d.ts +1 -1
- package/services/raf.d.ts +1 -1
- package/services/resize.d.ts +1 -1
- package/services/scroll.d.ts +1 -1
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type { BaseTypeParameter, BaseConstructor, BaseConfig } from '../Base/index.js';
|
|
2
|
+
declare type ScrollInViewProps = {
|
|
3
|
+
start: {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
};
|
|
7
|
+
end: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
};
|
|
11
|
+
current: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
};
|
|
15
|
+
dampedCurrent: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
};
|
|
19
|
+
progress: {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
};
|
|
23
|
+
dampedProgress: {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
declare type withScrolledInViewOptions = IntersectionObserverInit & {
|
|
29
|
+
useOffsetSizes?: boolean;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Add scrolled in view capabilities to a component.
|
|
33
|
+
*/
|
|
34
|
+
export default function withScrolledInView<T extends BaseTypeParameter = BaseTypeParameter>(BaseClass: BaseConstructor, options?: withScrolledInViewOptions): {
|
|
35
|
+
new <U extends BaseTypeParameter = BaseTypeParameter>(element: any): {
|
|
36
|
+
__props: ScrollInViewProps;
|
|
37
|
+
/**
|
|
38
|
+
* Factor used for the `dampedProgress` props.
|
|
39
|
+
*/
|
|
40
|
+
dampFactor: number;
|
|
41
|
+
/**
|
|
42
|
+
* Precision for the `dampedProgress` props.
|
|
43
|
+
*/
|
|
44
|
+
dampPrecision: number;
|
|
45
|
+
/**
|
|
46
|
+
* Mounted hook.
|
|
47
|
+
*
|
|
48
|
+
* @returns {void}
|
|
49
|
+
*/
|
|
50
|
+
mounted(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Resized hook.
|
|
53
|
+
*
|
|
54
|
+
* @param {import('../services/resize').ResizeServiceProps} props
|
|
55
|
+
* @returns {void}
|
|
56
|
+
*/
|
|
57
|
+
resized(props: any): void;
|
|
58
|
+
/**
|
|
59
|
+
* Scrolled hook.
|
|
60
|
+
*
|
|
61
|
+
* @param {import('../services/scroll').ScrollServiceProps} props
|
|
62
|
+
* @returns {void}
|
|
63
|
+
*/
|
|
64
|
+
scrolled(props: any): void;
|
|
65
|
+
/**
|
|
66
|
+
* Ticked hook.
|
|
67
|
+
*
|
|
68
|
+
* @param {import('../services/raf').RafServiceProps} props
|
|
69
|
+
* @returns {void}
|
|
70
|
+
*/
|
|
71
|
+
ticked(props: any): void;
|
|
72
|
+
/**
|
|
73
|
+
* Destroyed hook.
|
|
74
|
+
*
|
|
75
|
+
* @returns {void}
|
|
76
|
+
*/
|
|
77
|
+
destroyed(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Set the decorator props.
|
|
80
|
+
*
|
|
81
|
+
* @returns {void}
|
|
82
|
+
*/
|
|
83
|
+
__setProps(): void;
|
|
84
|
+
__isVisible: boolean;
|
|
85
|
+
__observer: IntersectionObserver;
|
|
86
|
+
$mount(): any;
|
|
87
|
+
$parent: import("../Base/index.js").default<BaseTypeParameter>;
|
|
88
|
+
$id: string;
|
|
89
|
+
$el: ({
|
|
90
|
+
$options: {
|
|
91
|
+
intersectionObserver: IntersectionObserverInit;
|
|
92
|
+
};
|
|
93
|
+
} & T & U)["$el"] & HTMLElement & {
|
|
94
|
+
__base__?: WeakMap<typeof import("../Base/index.js").default, import("../Base/index.js").default<BaseTypeParameter> | "terminated">;
|
|
95
|
+
};
|
|
96
|
+
$isMounted: boolean;
|
|
97
|
+
__eventHandlers: Map<string, Set<EventListenerOrEventListenerObject>>;
|
|
98
|
+
readonly $root: import("../Base/index.js").default<BaseTypeParameter>;
|
|
99
|
+
readonly __config: BaseConfig;
|
|
100
|
+
__services: import("../Base/managers/ServicesManager.js").default;
|
|
101
|
+
readonly $services: import("../Base/managers/ServicesManager.js").default;
|
|
102
|
+
__refs: import("../Base/managers/RefsManager.js").default & ({
|
|
103
|
+
$options: {
|
|
104
|
+
intersectionObserver: IntersectionObserverInit;
|
|
105
|
+
};
|
|
106
|
+
} & T & U)["$refs"] & import("../Base/index.js").BaseRefs;
|
|
107
|
+
readonly $refs: import("../Base/managers/RefsManager.js").default & ({
|
|
108
|
+
$options: {
|
|
109
|
+
intersectionObserver: IntersectionObserverInit;
|
|
110
|
+
};
|
|
111
|
+
} & T & U)["$refs"] & import("../Base/index.js").BaseRefs;
|
|
112
|
+
__options: import("../Base/managers/OptionsManager.js").default & ({
|
|
113
|
+
$options: {
|
|
114
|
+
intersectionObserver: IntersectionObserverInit;
|
|
115
|
+
};
|
|
116
|
+
} & T & U)["$options"] & import("../Base/index.js").BaseOptions;
|
|
117
|
+
readonly $options: import("../Base/managers/OptionsManager.js").default & ({
|
|
118
|
+
$options: {
|
|
119
|
+
intersectionObserver: IntersectionObserverInit;
|
|
120
|
+
};
|
|
121
|
+
} & T & U)["$options"] & import("../Base/index.js").BaseOptions;
|
|
122
|
+
__children: import("../Base/managers/ChildrenManager.js").default & (({
|
|
123
|
+
$options: {
|
|
124
|
+
intersectionObserver: IntersectionObserverInit;
|
|
125
|
+
};
|
|
126
|
+
} & T & U)["$children"] extends infer T_1 ? { [key in keyof T_1]: ({
|
|
127
|
+
$options: {
|
|
128
|
+
intersectionObserver: IntersectionObserverInit;
|
|
129
|
+
};
|
|
130
|
+
} & T & U)["$children"][key][]; } : never) & import("../Base/index.js").BaseChildren;
|
|
131
|
+
readonly $children: import("../Base/managers/ChildrenManager.js").default & (({
|
|
132
|
+
$options: {
|
|
133
|
+
intersectionObserver: IntersectionObserverInit;
|
|
134
|
+
};
|
|
135
|
+
} & T & U)["$children"] extends infer T_2 ? { [key_1 in keyof T_2]: ({
|
|
136
|
+
$options: {
|
|
137
|
+
intersectionObserver: IntersectionObserverInit;
|
|
138
|
+
};
|
|
139
|
+
} & T & U)["$children"][key_1][]; } : never) & import("../Base/index.js").BaseChildren;
|
|
140
|
+
__events: import("../Base/managers/EventsManager.js").default; /**
|
|
141
|
+
* Ticked hook.
|
|
142
|
+
*
|
|
143
|
+
* @param {import('../services/raf').RafServiceProps} props
|
|
144
|
+
* @returns {void}
|
|
145
|
+
*/
|
|
146
|
+
readonly $log: (...args: any) => void;
|
|
147
|
+
readonly __debug: (...args: any) => void;
|
|
148
|
+
readonly __managers: import("../Base/index.js").Managers;
|
|
149
|
+
__callMethod(method: string, ...args: unknown[]): unknown;
|
|
150
|
+
__hasEvent(event: string): boolean;
|
|
151
|
+
$update(): any;
|
|
152
|
+
$destroy(): any;
|
|
153
|
+
$terminate(): void;
|
|
154
|
+
__addEmits(event: string): void;
|
|
155
|
+
__removeEmits(event: string): void;
|
|
156
|
+
readonly __ctor: typeof import("../Base/index.js").default;
|
|
157
|
+
$on(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): () => void;
|
|
158
|
+
$off(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
159
|
+
$emit(event: string, ...args: unknown[]): void;
|
|
160
|
+
addEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
161
|
+
dispatchEvent(event: Event): boolean;
|
|
162
|
+
removeEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Config.
|
|
166
|
+
*/
|
|
167
|
+
config: BaseConfig;
|
|
168
|
+
readonly $isBase: true;
|
|
169
|
+
$factory(nameOrSelector: string): import("../Base/index.js").default<BaseTypeParameter>[];
|
|
170
|
+
};
|
|
171
|
+
export {};
|
package/decorators/withVue2.cjs
CHANGED
|
@@ -28,7 +28,7 @@ __export(withVue2_exports, {
|
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(withVue2_exports);
|
|
30
30
|
var import_utils = require("../utils/index.cjs");
|
|
31
|
-
function withVue2(BaseClass,
|
|
31
|
+
function withVue2(BaseClass, VueCtor) {
|
|
32
32
|
var _a, _b, _c;
|
|
33
33
|
return _c = class extends BaseClass {
|
|
34
34
|
constructor(element) {
|
|
@@ -48,7 +48,7 @@ function withVue2(BaseClass, Vue) {
|
|
|
48
48
|
}
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
|
-
this.$vue = new
|
|
51
|
+
this.$vue = new VueCtor(vueConfig);
|
|
52
52
|
this.$on("mounted", () => {
|
|
53
53
|
if (!(this.$refs.vue instanceof HTMLElement)) {
|
|
54
54
|
throw new Error("[withVue] The `vue` refs must be a single HTMLElement.");
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type Vue from 'vue';
|
|
2
|
+
import type { ComponentOptions, VueConstructor } from 'vue';
|
|
3
|
+
import type { BaseConstructor, BaseTypeParameter } from '../Base/index.js';
|
|
4
|
+
interface WithVue2Interface {
|
|
5
|
+
$refs: {
|
|
6
|
+
vue: HTMLElement;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* withVue decorator.
|
|
11
|
+
*/
|
|
12
|
+
export default function withVue2<T extends BaseTypeParameter = BaseTypeParameter, VueTypeParameter extends Vue = Vue>(BaseClass: BaseConstructor, VueCtor: VueConstructor): {
|
|
13
|
+
new <U extends BaseTypeParameter = BaseTypeParameter>(element: HTMLElement): {
|
|
14
|
+
$vue: Vue;
|
|
15
|
+
$parent: import("../Base/index.js").default<BaseTypeParameter>;
|
|
16
|
+
$id: string;
|
|
17
|
+
$el: (WithVue2Interface & T & U)["$el"] & HTMLElement & {
|
|
18
|
+
__base__?: WeakMap<typeof import("../Base/index.js").default, import("../Base/index.js").default<BaseTypeParameter> | "terminated">;
|
|
19
|
+
};
|
|
20
|
+
$isMounted: boolean;
|
|
21
|
+
__eventHandlers: Map<string, Set<EventListenerOrEventListenerObject>>;
|
|
22
|
+
readonly $root: import("../Base/index.js").default<BaseTypeParameter>;
|
|
23
|
+
readonly __config: import("../Base/index.js").BaseConfig;
|
|
24
|
+
__services: import("../Base/managers/ServicesManager.js").default;
|
|
25
|
+
readonly $services: import("../Base/managers/ServicesManager.js").default;
|
|
26
|
+
__refs: import("../Base/managers/RefsManager.js").default & (WithVue2Interface & T & U)["$refs"] & import("../Base/index.js").BaseRefs;
|
|
27
|
+
readonly $refs: import("../Base/managers/RefsManager.js").default & (WithVue2Interface & T & U)["$refs"] & import("../Base/index.js").BaseRefs;
|
|
28
|
+
__options: import("../Base/managers/OptionsManager.js").default & (WithVue2Interface & T & U)["$options"] & import("../Base/index.js").BaseOptions;
|
|
29
|
+
readonly $options: import("../Base/managers/OptionsManager.js").default & (WithVue2Interface & T & U)["$options"] & import("../Base/index.js").BaseOptions;
|
|
30
|
+
__children: import("../Base/managers/ChildrenManager.js").default & ((WithVue2Interface & T & U)["$children"] extends infer T_1 ? { [key in keyof T_1]: (WithVue2Interface & T & U)["$children"][key][]; } : never) & import("../Base/index.js").BaseChildren;
|
|
31
|
+
readonly $children: import("../Base/managers/ChildrenManager.js").default & ((WithVue2Interface & T & U)["$children"] extends infer T_2 ? { [key_1 in keyof T_2]: (WithVue2Interface & T & U)["$children"][key_1][]; } : never) & import("../Base/index.js").BaseChildren;
|
|
32
|
+
__events: import("../Base/managers/EventsManager.js").default;
|
|
33
|
+
readonly $log: (...args: any) => void;
|
|
34
|
+
readonly __debug: (...args: any) => void;
|
|
35
|
+
readonly __managers: import("../Base/index.js").Managers;
|
|
36
|
+
__callMethod(method: string, ...args: unknown[]): unknown;
|
|
37
|
+
__hasEvent(event: string): boolean;
|
|
38
|
+
$mount(): any;
|
|
39
|
+
$update(): any;
|
|
40
|
+
$destroy(): any;
|
|
41
|
+
$terminate(): void;
|
|
42
|
+
__addEmits(event: string): void;
|
|
43
|
+
__removeEmits(event: string): void;
|
|
44
|
+
readonly __ctor: typeof import("../Base/index.js").default;
|
|
45
|
+
$on(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): () => void;
|
|
46
|
+
$off(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
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
|
+
config: {
|
|
53
|
+
name: string;
|
|
54
|
+
refs: string[];
|
|
55
|
+
debug?: boolean;
|
|
56
|
+
log?: boolean;
|
|
57
|
+
emits?: string[];
|
|
58
|
+
components?: import("../Base/index.js").BaseConfigComponents;
|
|
59
|
+
options?: import("../Base/managers/OptionsManager.js").OptionsSchema;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Vue app configuration.
|
|
63
|
+
*/
|
|
64
|
+
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> & {
|
|
65
|
+
render: ComponentOptions<VueTypeParameter>['render'];
|
|
66
|
+
};
|
|
67
|
+
readonly $isBase: true;
|
|
68
|
+
$factory(nameOrSelector: string): import("../Base/index.js").default<BaseTypeParameter>[];
|
|
69
|
+
};
|
|
70
|
+
export {};
|
package/decorators/withVue2.js
CHANGED
|
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
7
|
import { isDev, isFunction } from "../utils/index.js";
|
|
8
|
-
function withVue2(BaseClass,
|
|
8
|
+
function withVue2(BaseClass, VueCtor) {
|
|
9
9
|
var _a, _b, _c;
|
|
10
10
|
return _c = class extends BaseClass {
|
|
11
11
|
constructor(element) {
|
|
@@ -25,7 +25,7 @@ function withVue2(BaseClass, Vue) {
|
|
|
25
25
|
}
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
this.$vue = new
|
|
28
|
+
this.$vue = new VueCtor(vueConfig);
|
|
29
29
|
this.$on("mounted", () => {
|
|
30
30
|
if (!(this.$refs.vue instanceof HTMLElement)) {
|
|
31
31
|
throw new Error("[withVue] The `vue` refs must be a single HTMLElement.");
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../Base/index.js').BaseConstructor} BaseConstructor
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Instantiate and mount the given component on the given root element when the page has been loaded
|
|
6
|
+
* 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
|
+
*/
|
|
13
|
+
export default function createApp<T extends typeof import("../Base/index.js").default>(App: T, rootElement?: HTMLElement): () => Promise<InstanceType<T>>;
|
|
14
|
+
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
|
@@ -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 {T[]}
|
|
12
|
+
*/
|
|
13
|
+
export function getDirectChildren<T extends import("../Base/index.js").default<import("../Base/index.js").BaseTypeParameter>>(parentInstance: Base, 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: Base, parentName: string, childrenName: string, childInstance: Base): boolean;
|
|
24
|
+
export type Base = import('../Base/index.js').default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../Base/index.js').BaseConstructor} BaseConstructor
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* 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
|
+
*/
|
|
11
|
+
export default function getInstanceFromElement<T extends typeof import("../Base/index.js").default>(element: HTMLElement & {
|
|
12
|
+
__base__?: WeakMap<T, InstanceType<T>>;
|
|
13
|
+
}, Constructor: T): InstanceType<T>;
|
|
14
|
+
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../Base/index.js').BaseConstructor} BaseConstructor
|
|
3
|
+
* @typedef {import('../Base/index.js').default} Base
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Import a component on an interaction.
|
|
7
|
+
*
|
|
8
|
+
* @template {BaseConstructor} T
|
|
9
|
+
* @param {() => Promise<T|{default:T}>} fn
|
|
10
|
+
* The import function.
|
|
11
|
+
* @param {string|HTMLElement|HTMLElement[]} nameOrSelectorOrElement
|
|
12
|
+
* The name or selector for the component.
|
|
13
|
+
* @param {string|string[]} events
|
|
14
|
+
* The events to listen to to trigger the import.
|
|
15
|
+
* @param {Base} [parent]
|
|
16
|
+
* The parent component.
|
|
17
|
+
* @returns {Promise<T>}
|
|
18
|
+
*/
|
|
19
|
+
export default function importOnInteraction<T extends typeof import("../Base/index.js").default>(fn: () => Promise<T | {
|
|
20
|
+
default: T;
|
|
21
|
+
}>, 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;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../Base/index.js').BaseConstructor} BaseConstructor
|
|
3
|
+
* @typedef {{ timeout?: number }} ImportWhenIdleOptions
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Import a component when user is idle.
|
|
7
|
+
*
|
|
8
|
+
* @template {BaseConstructor} T
|
|
9
|
+
* @param {() => Promise<T|{default:T}>} fn
|
|
10
|
+
* The import function.
|
|
11
|
+
* @param {ImportWhenIdleOptions} [options]
|
|
12
|
+
* The time to wait before triggering the callback if never idle.
|
|
13
|
+
* @returns {Promise<T>}
|
|
14
|
+
*/
|
|
15
|
+
export default function importWhenIdle<T extends typeof import("../Base/index.js").default>(fn: () => Promise<T | {
|
|
16
|
+
default: T;
|
|
17
|
+
}>, options?: ImportWhenIdleOptions): Promise<T>;
|
|
18
|
+
export type BaseConstructor = import('../Base/index.js').BaseConstructor;
|
|
19
|
+
export type ImportWhenIdleOptions = {
|
|
20
|
+
timeout?: number;
|
|
21
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../Base/index.js').default} Base
|
|
3
|
+
* @typedef {import('../Base/index.js').BaseConstructor} BaseConstructor
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Import a component when it is visible.
|
|
7
|
+
*
|
|
8
|
+
* @template {BaseConstructor} T
|
|
9
|
+
* @param {() => Promise<T|{default:T}>} fn
|
|
10
|
+
* The import function.
|
|
11
|
+
* @param {string|HTMLElement|HTMLElement[]} nameOrSelectorOrElement
|
|
12
|
+
* The name or selector for the component.
|
|
13
|
+
* @param {Base} [parent]
|
|
14
|
+
* The parent component.
|
|
15
|
+
* @param {IntersectionObserverInit} [observerOptions]
|
|
16
|
+
* Options for the `IntersectionObserver` instance.
|
|
17
|
+
* @returns {Promise<T>}
|
|
18
|
+
*/
|
|
19
|
+
export default function importWhenVisible<T extends typeof import("../Base/index.js").default>(fn: () => Promise<T | {
|
|
20
|
+
default: T;
|
|
21
|
+
}>, 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;
|
|
@@ -0,0 +1,6 @@
|
|
|
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";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the target elements for the lazy import helper functions.
|
|
3
|
+
*
|
|
4
|
+
* @param {string|HTMLElement|HTMLElement[]} nameOrSelectorOrElement
|
|
5
|
+
* The original selector or element, or list of elements.
|
|
6
|
+
* @param {HTMLElement} [context]
|
|
7
|
+
* The optional context to use to query for elements.
|
|
8
|
+
* @returns {HTMLElement[]} A normalized list of elements.
|
|
9
|
+
*/
|
|
10
|
+
export function getTargetElements(nameOrSelectorOrElement: string | HTMLElement | HTMLElement[], context?: HTMLElement): HTMLElement[];
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Base } from './Base/index.js';
|
|
2
|
+
export * from './decorators/index.js';
|
|
3
|
+
export * from './helpers/index.js';
|
|
4
|
+
export * from './services/index.js';
|
|
5
|
+
export type { BaseTypeParameter, BaseConstructor, BaseAsyncConstructor, BaseConfig, } from './Base/index.js';
|
|
6
|
+
export type { BaseInterface } from './Base/types.js';
|
package/package.json
CHANGED
package/services/drag.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* @param {DragServiceOptions} options
|
|
15
15
|
* @returns {DragService}
|
|
16
16
|
*/
|
|
17
|
-
export default function useDrag(target: HTMLElement, options: DragServiceOptions):
|
|
17
|
+
export default function useDrag(target: HTMLElement, options: DragServiceOptions): import("./index").ServiceInterface<DragServiceProps>;
|
|
18
18
|
export type DragService = import('./index').ServiceInterface<DragServiceProps>;
|
|
19
19
|
export type PointerServiceProps = import('./pointer.js').PointerServiceProps;
|
|
20
20
|
export type DragLifecycle = 'start' | 'drag' | 'drop' | 'inertia' | 'stop';
|
package/services/index.cjs
CHANGED
|
@@ -22,7 +22,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
));
|
|
23
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
24
|
|
|
25
|
-
// packages/js-toolkit/services/index.
|
|
25
|
+
// packages/js-toolkit/services/index.ts
|
|
26
26
|
var services_exports = {};
|
|
27
27
|
__export(services_exports, {
|
|
28
28
|
useDrag: () => import_drag.default,
|
package/services/index.d.ts
CHANGED
|
@@ -1,33 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
export type ServiceInterface<T> = {
|
|
1
|
+
import type { DragServiceProps } from './drag.js';
|
|
2
|
+
import type { KeyServiceProps } from './key.js';
|
|
3
|
+
import type { LoadServiceProps } from './load.js';
|
|
4
|
+
import type { PointerServiceProps } from './pointer.js';
|
|
5
|
+
import type { RafServiceProps } from './raf.js';
|
|
6
|
+
import type { ResizeServiceProps } from './resize.js';
|
|
7
|
+
import type { ScrollServiceProps } from './scroll.js';
|
|
8
|
+
export interface ServiceInterface<T> {
|
|
10
9
|
/**
|
|
11
|
-
*
|
|
10
|
+
* Remove a function from the resize service by its key.
|
|
12
11
|
*/
|
|
13
|
-
remove
|
|
12
|
+
remove(key: string): void;
|
|
14
13
|
/**
|
|
15
|
-
*
|
|
14
|
+
* Add a callback to the service. The callback will receive the current service props as parameter.
|
|
16
15
|
*/
|
|
17
|
-
add
|
|
16
|
+
add(key: string, callback: (props: T) => void): void;
|
|
18
17
|
/**
|
|
19
|
-
*
|
|
18
|
+
* Test if the service has alreaydy a callback for the given key.
|
|
20
19
|
*/
|
|
21
|
-
has
|
|
20
|
+
has(key: string): boolean;
|
|
22
21
|
/**
|
|
23
|
-
*
|
|
22
|
+
* Get the service's props.
|
|
24
23
|
*/
|
|
25
|
-
props
|
|
26
|
-
}
|
|
27
|
-
export type
|
|
28
|
-
export type
|
|
29
|
-
export type
|
|
30
|
-
export type
|
|
31
|
-
export type
|
|
32
|
-
export type
|
|
33
|
-
export type
|
|
24
|
+
props(): T;
|
|
25
|
+
}
|
|
26
|
+
export declare type DragServiceInterface = ServiceInterface<DragServiceProps>;
|
|
27
|
+
export declare type KeyServiceInterface = ServiceInterface<KeyServiceProps>;
|
|
28
|
+
export declare type LoadServiceInterface = ServiceInterface<LoadServiceProps>;
|
|
29
|
+
export declare type PointerServiceInterface = ServiceInterface<PointerServiceProps>;
|
|
30
|
+
export declare type RafServiceInterface = ServiceInterface<RafServiceProps>;
|
|
31
|
+
export declare type ResizeServiceInterface = ServiceInterface<ResizeServiceProps>;
|
|
32
|
+
export declare type ScrollServiceInterface = ServiceInterface<ScrollServiceProps>;
|
|
33
|
+
export type { DragServiceProps, KeyServiceProps, LoadServiceProps, PointerServiceProps, RafServiceProps, ResizeServiceProps, ScrollServiceProps, };
|
|
34
|
+
export { default as useDrag } from './drag.js';
|
|
35
|
+
export { default as useKey } from './key.js';
|
|
36
|
+
export { default as useLoad } from './load.js';
|
|
37
|
+
export { default as usePointer } from './pointer.js';
|
|
38
|
+
export { default as useRaf } from './raf.js';
|
|
39
|
+
export { default as useResize } from './resize.js';
|
|
40
|
+
export { default as useScroll } from './scroll.js';
|
|
41
|
+
export { useService } from './service.js';
|
package/services/key.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @returns {KeyService}
|
|
5
5
|
*/
|
|
6
|
-
export default function useKey():
|
|
6
|
+
export default function useKey(): import("./index").ServiceInterface<KeyServiceProps>;
|
|
7
7
|
export type KeyService = import('./index').ServiceInterface<KeyServiceProps>;
|
|
8
8
|
export type KeyServiceProps = {
|
|
9
9
|
event: KeyboardEvent;
|
package/services/load.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @returns {LoadService}
|
|
5
5
|
*/
|
|
6
|
-
export default function useLoad():
|
|
6
|
+
export default function useLoad(): import("./index").ServiceInterface<LoadServiceProps>;
|
|
7
7
|
export type LoadService = import('./index').ServiceInterface<LoadServiceProps>;
|
|
8
8
|
export type LoadServiceProps = {
|
|
9
9
|
time: DOMHighResTimeStamp;
|
package/services/pointer.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @todo Add element as parameter to get the pointer position relatively from.
|
|
5
5
|
* @returns {PointerService}
|
|
6
6
|
*/
|
|
7
|
-
export default function usePointer():
|
|
7
|
+
export default function usePointer(): import("./index").ServiceInterface<PointerServiceProps>;
|
|
8
8
|
export type PointerService = import('./index').ServiceInterface<PointerServiceProps>;
|
|
9
9
|
export type PointerServiceProps = {
|
|
10
10
|
event: MouseEvent | TouchEvent;
|
package/services/raf.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @returns {RafService}
|
|
5
5
|
*/
|
|
6
|
-
export default function useRaf():
|
|
6
|
+
export default function useRaf(): import("./index").ServiceInterface<RafServiceProps>;
|
|
7
7
|
export type RafService = import('./index').ServiceInterface<RafServiceProps>;
|
|
8
8
|
export type RafServiceProps = {
|
|
9
9
|
time: DOMHighResTimeStamp;
|
package/services/resize.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @returns {ResizeService}
|
|
5
5
|
*/
|
|
6
|
-
export default function useResize():
|
|
6
|
+
export default function useResize(): import("./index").ServiceInterface<ResizeServiceProps>;
|
|
7
7
|
export type ResizeService = import('./index').ServiceInterface<ResizeServiceProps>;
|
|
8
8
|
export type ResizeServiceProps = {
|
|
9
9
|
width: number;
|
package/services/scroll.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @returns {ScrollService}
|
|
13
13
|
*/
|
|
14
|
-
export default function useScroll():
|
|
14
|
+
export default function useScroll(): import("./index").ServiceInterface<ScrollServiceProps>;
|
|
15
15
|
export type ScrollService = import('./index').ServiceInterface<ScrollServiceProps>;
|
|
16
16
|
export type ScrollServiceProps = {
|
|
17
17
|
x: number;
|