@studiometa/js-toolkit 2.4.4-alpha.1 → 2.4.4-alpha.4
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 +78 -218
- 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/types.cjs +18 -0
- package/Base/types.d.ts +43 -0
- package/Base/types.js +0 -0
- package/Base/utils.cjs +1 -1
- package/Base/utils.d.ts +5 -21
- package/decorators/index.cjs +2 -0
- package/decorators/index.d.ts +1 -0
- package/decorators/index.js +4 -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 +5 -4
- package/decorators/withScrolledInView.d.ts +219 -79
- package/decorators/withScrolledInView.js +5 -4
- 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 +5 -10
- 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 +2 -1
- package/index.js +2 -2
- package/package.json +1 -1
package/Base/index.cjs
CHANGED
|
@@ -27,10 +27,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27
27
|
return value;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
// packages/js-toolkit/Base/index.
|
|
30
|
+
// packages/js-toolkit/Base/index.ts
|
|
31
31
|
var Base_exports = {};
|
|
32
32
|
__export(Base_exports, {
|
|
33
|
-
|
|
33
|
+
Base: () => Base
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(Base_exports);
|
|
36
36
|
var import_utils = require("./utils.cjs");
|
package/Base/index.d.ts
CHANGED
|
@@ -1,207 +1,141 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
import ChildrenManager from './managers/ChildrenManager.js';
|
|
2
|
+
import RefsManager from './managers/RefsManager.js';
|
|
3
|
+
import ServicesManager from './managers/ServicesManager.js';
|
|
4
|
+
import EventsManager from './managers/EventsManager.js';
|
|
5
|
+
import OptionsManager from './managers/OptionsManager.js';
|
|
6
|
+
export declare type BaseEl = HTMLElement & {
|
|
7
|
+
__base__?: WeakMap<BaseConstructor, Base | 'terminated'>;
|
|
8
|
+
};
|
|
9
|
+
export declare type BaseConstructor<T extends Base = Base> = {
|
|
10
|
+
new (...args: any[]): T;
|
|
11
|
+
prototype: Base;
|
|
12
|
+
} & Pick<typeof Base, keyof typeof Base>;
|
|
13
|
+
export declare type BaseAsyncConstructor<T extends Base = Base> = (Base: any) => Promise<BaseConstructor<T> | {
|
|
14
|
+
default: BaseConstructor<T>;
|
|
15
|
+
}>;
|
|
16
|
+
export declare type BaseOptions = {
|
|
17
|
+
[name: string]: unknown;
|
|
18
|
+
};
|
|
19
|
+
export declare type BaseRefs = {
|
|
20
|
+
[name: string]: HTMLElement | HTMLElement[];
|
|
21
|
+
};
|
|
22
|
+
export declare type BaseChildren = {
|
|
23
|
+
[nameOrSelector: string]: Base[] | Promise<Base>[];
|
|
24
|
+
};
|
|
25
|
+
export declare type BaseConfigComponents = {
|
|
26
|
+
[nameOrSelector: string]: BaseConstructor | BaseAsyncConstructor;
|
|
27
|
+
};
|
|
28
|
+
export declare type BaseConfig = {
|
|
29
|
+
name: string;
|
|
30
|
+
debug?: boolean;
|
|
31
|
+
log?: boolean;
|
|
32
|
+
refs?: string[];
|
|
33
|
+
emits?: string[];
|
|
34
|
+
components?: BaseConfigComponents;
|
|
35
|
+
options?: import('./managers/OptionsManager').OptionsSchema;
|
|
36
|
+
};
|
|
37
|
+
export declare type BaseTypeParameter = {
|
|
38
|
+
$el?: HTMLElement;
|
|
39
|
+
$options?: BaseOptions;
|
|
40
|
+
$refs?: BaseRefs;
|
|
41
|
+
$children?: BaseChildren;
|
|
42
|
+
};
|
|
43
|
+
export declare type Managers = {
|
|
44
|
+
ChildrenManager: typeof ChildrenManager;
|
|
45
|
+
EventsManager: typeof EventsManager;
|
|
46
|
+
OptionsManager: typeof OptionsManager;
|
|
47
|
+
RefsManager: typeof RefsManager;
|
|
48
|
+
ServicesManager: typeof ServicesManager;
|
|
49
|
+
};
|
|
37
50
|
/**
|
|
38
51
|
* Base class.
|
|
39
|
-
* @template {BaseTypeParameter} [BaseInterface={ $el: HTMLElement, $options: BaseOptions, $refs: BaseRefs, $children: { [name:string]: Base | Promise<Base> } }]
|
|
40
52
|
*/
|
|
41
|
-
export
|
|
42
|
-
$el: HTMLElement;
|
|
43
|
-
$options: BaseOptions;
|
|
44
|
-
$refs: BaseRefs;
|
|
45
|
-
$children: {
|
|
46
|
-
[name: string]: Base<any> | Promise<Base<any>>;
|
|
47
|
-
};
|
|
48
|
-
}> extends EventTarget {
|
|
53
|
+
export declare class Base<T extends BaseTypeParameter = BaseTypeParameter> extends EventTarget {
|
|
49
54
|
/**
|
|
50
55
|
* This is a Base instance.
|
|
51
|
-
* @type {boolean}
|
|
52
|
-
* @readonly
|
|
53
|
-
*/
|
|
54
|
-
static readonly $isBase: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* @type {BaseConfig}
|
|
57
|
-
*/
|
|
58
|
-
static config: BaseConfig;
|
|
59
|
-
/**
|
|
60
|
-
* Factory method to generate multiple instance of the class.
|
|
61
|
-
*
|
|
62
|
-
* @param {string} nameOrSelector The selector on which to mount each instance.
|
|
63
|
-
* @returns {Array<Base>} A list of the created instance.
|
|
64
|
-
*/
|
|
65
|
-
static $factory(nameOrSelector: string): Array<Base>;
|
|
66
|
-
/**
|
|
67
|
-
* Class constructor where all the magic takes place.
|
|
68
|
-
*
|
|
69
|
-
* @param {HTMLElement} element The component's root element dd.
|
|
70
56
|
*/
|
|
71
|
-
|
|
57
|
+
static readonly $isBase: true;
|
|
72
58
|
/**
|
|
73
59
|
* The instance parent.
|
|
74
|
-
* @type {Base}
|
|
75
60
|
*/
|
|
76
61
|
$parent: Base;
|
|
77
62
|
/**
|
|
78
63
|
* The instance id.
|
|
79
|
-
* @type {string}
|
|
80
64
|
*/
|
|
81
65
|
$id: string;
|
|
82
66
|
/**
|
|
83
67
|
* The root element.
|
|
84
|
-
* @type {BaseInterface['$el'] & HTMLElement & { __base__?: WeakMap<BaseConstructor, Base | 'terminated'> }}
|
|
85
68
|
*/
|
|
86
|
-
$el:
|
|
87
|
-
__base__?: WeakMap<BaseConstructor, Base | 'terminated'>;
|
|
88
|
-
};
|
|
69
|
+
$el: T['$el'] & BaseEl;
|
|
89
70
|
/**
|
|
90
71
|
* The state of the component.
|
|
91
|
-
* @type {boolean}
|
|
92
72
|
*/
|
|
93
73
|
$isMounted: boolean;
|
|
94
74
|
/**
|
|
95
75
|
* Store the event handlers.
|
|
96
|
-
*
|
|
97
|
-
* @type {Map<string, Set<EventListenerOrEventListenerObject>>}
|
|
98
76
|
*/
|
|
99
77
|
__eventHandlers: Map<string, Set<EventListenerOrEventListenerObject>>;
|
|
100
78
|
/**
|
|
101
79
|
* Get the root instance of the app.
|
|
102
|
-
* @returns {Base}
|
|
103
80
|
*/
|
|
104
|
-
get $root(): Base
|
|
105
|
-
$el: HTMLElement;
|
|
106
|
-
$options: BaseOptions;
|
|
107
|
-
$refs: BaseRefs;
|
|
108
|
-
$children: {
|
|
109
|
-
[name: string]: Base<any> | Promise<Base<any>>;
|
|
110
|
-
};
|
|
111
|
-
}>;
|
|
81
|
+
get $root(): Base;
|
|
112
82
|
/**
|
|
113
83
|
* Merge configuration with the parents' configurations.
|
|
114
|
-
*
|
|
115
|
-
* @returns {BaseConfig}
|
|
116
84
|
*/
|
|
117
85
|
get __config(): BaseConfig;
|
|
118
|
-
|
|
119
|
-
* @type {ServicesManager}
|
|
120
|
-
*/
|
|
86
|
+
static config: BaseConfig;
|
|
121
87
|
__services: ServicesManager;
|
|
122
|
-
/**
|
|
123
|
-
* @type {ServicesManager}
|
|
124
|
-
*/
|
|
125
88
|
get $services(): ServicesManager;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
*/
|
|
133
|
-
get $refs(): RefsManager & BaseInterface["$refs"] & BaseRefs;
|
|
134
|
-
/**
|
|
135
|
-
* @type {OptionsManager & BaseInterface['$options'] & BaseOptions}
|
|
136
|
-
*/
|
|
137
|
-
__options: OptionsManager & BaseInterface['$options'] & BaseOptions;
|
|
138
|
-
/**
|
|
139
|
-
* @returns {OptionsManager & BaseInterface['$options'] & BaseOptions}
|
|
140
|
-
*/
|
|
141
|
-
get $options(): OptionsManager & BaseInterface["$options"] & BaseOptions;
|
|
142
|
-
/**
|
|
143
|
-
* @type {ChildrenManager & { [key in keyof BaseInterface['$children']]: Array<BaseInterface['$children'][key]> } & BaseChildren}
|
|
144
|
-
*/
|
|
145
|
-
__children: ChildrenManager & (BaseInterface["$children"] extends infer T ? { [key in keyof T]: BaseInterface["$children"][key][]; } : never) & BaseChildren;
|
|
146
|
-
/**
|
|
147
|
-
* @returns {ChildrenManager & { [key in keyof BaseInterface['$children']]: Array<BaseInterface['$children'][key]> } & BaseChildren}
|
|
148
|
-
*/
|
|
149
|
-
get $children(): ChildrenManager & (BaseInterface["$children"] extends infer T_1 ? { [key_1 in keyof T_1]: BaseInterface["$children"][key_1][]; } : never) & BaseChildren;
|
|
150
|
-
/**
|
|
151
|
-
* @type {EventsManager}
|
|
152
|
-
*/
|
|
89
|
+
__refs: RefsManager & T['$refs'] & BaseRefs;
|
|
90
|
+
get $refs(): RefsManager & T['$refs'] & BaseRefs;
|
|
91
|
+
__options: OptionsManager & T['$options'] & BaseOptions;
|
|
92
|
+
get $options(): OptionsManager & T['$options'] & BaseOptions;
|
|
93
|
+
__children: ChildrenManager & T['$children'] & BaseChildren;
|
|
94
|
+
get $children(): ChildrenManager & T['$children'] & BaseChildren;
|
|
153
95
|
__events: EventsManager;
|
|
154
96
|
/**
|
|
155
97
|
* Small helper to log stuff.
|
|
156
|
-
*
|
|
157
|
-
* @returns {(...args: any) => void}
|
|
158
98
|
*/
|
|
159
|
-
get $log(): (...args:
|
|
99
|
+
get $log(): (...args: unknown[]) => void;
|
|
160
100
|
/**
|
|
161
101
|
* Small helper to debug information.
|
|
162
|
-
*
|
|
163
|
-
* @returns {(...args:any) => void}
|
|
164
102
|
*/
|
|
165
|
-
get __debug(): (...args:
|
|
103
|
+
get __debug(): (...args: unknown[]) => void;
|
|
166
104
|
/**
|
|
167
105
|
* Get manager constructors.
|
|
168
|
-
*
|
|
169
|
-
* @returns {Managers}
|
|
170
106
|
*/
|
|
171
107
|
get __managers(): Managers;
|
|
172
108
|
/**
|
|
173
109
|
* Call an instance method and emit corresponding events.
|
|
174
|
-
*
|
|
175
|
-
* @param {string} method
|
|
176
|
-
* @param {any[]} args
|
|
177
|
-
* @returns {any}
|
|
178
110
|
*/
|
|
179
|
-
__callMethod(method: string, ...args:
|
|
111
|
+
__callMethod(method: string, ...args: unknown[]): unknown;
|
|
180
112
|
/**
|
|
181
113
|
* Test if the given event has been bound to the instance.
|
|
182
114
|
*
|
|
183
|
-
* @param
|
|
115
|
+
* @param {string} event The event's name.
|
|
184
116
|
* @returns {boolean} Wether the given event has been bound or not.
|
|
185
117
|
*/
|
|
186
118
|
__hasEvent(event: string): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Class constructor where all the magic takes place.
|
|
121
|
+
*
|
|
122
|
+
* @param {HTMLElement} element The component's root element dd.
|
|
123
|
+
*/
|
|
124
|
+
constructor(element: HTMLElement);
|
|
187
125
|
/**
|
|
188
126
|
* Trigger the `mounted` callback.
|
|
189
|
-
* @returns {this}
|
|
190
127
|
*/
|
|
191
128
|
$mount(): this;
|
|
192
129
|
/**
|
|
193
130
|
* Update the instance children.
|
|
194
|
-
* @returns {this}
|
|
195
131
|
*/
|
|
196
132
|
$update(): this;
|
|
197
133
|
/**
|
|
198
134
|
* Trigger the `destroyed` callback.
|
|
199
|
-
* @returns {this}
|
|
200
135
|
*/
|
|
201
136
|
$destroy(): this;
|
|
202
137
|
/**
|
|
203
138
|
* Terminate a child instance when it is not needed anymore.
|
|
204
|
-
* @returns {void}
|
|
205
139
|
*/
|
|
206
140
|
$terminate(): void;
|
|
207
141
|
/**
|
|
@@ -220,10 +154,8 @@ export default class Base<BaseInterface extends BaseTypeParameter = {
|
|
|
220
154
|
__removeEmits(event: string): void;
|
|
221
155
|
/**
|
|
222
156
|
* Get the instance constructor.
|
|
223
|
-
*
|
|
224
|
-
* @returns {BaseConstructor}
|
|
225
157
|
*/
|
|
226
|
-
get __ctor():
|
|
158
|
+
get __ctor(): BaseConstructor;
|
|
227
159
|
/**
|
|
228
160
|
* Bind a listener function to an event.
|
|
229
161
|
*
|
|
@@ -252,85 +184,13 @@ export default class Base<BaseInterface extends BaseTypeParameter = {
|
|
|
252
184
|
/**
|
|
253
185
|
* Emits an event.
|
|
254
186
|
*
|
|
255
|
-
* @param {string} event
|
|
256
|
-
*
|
|
257
|
-
* @param {any[]} args The arguments to apply to the functions bound to this event.
|
|
187
|
+
* @param {string} event Name of the event.
|
|
188
|
+
* @param {any[]} args The arguments to apply to the functions bound to this event.
|
|
258
189
|
* @returns {void}
|
|
259
190
|
*/
|
|
260
|
-
$emit(event: string, ...args:
|
|
191
|
+
$emit(event: string, ...args: unknown[]): void;
|
|
192
|
+
/**
|
|
193
|
+
* Factory method to generate multiple instance of the class.
|
|
194
|
+
*/
|
|
195
|
+
static $factory(nameOrSelector: string): Base[];
|
|
261
196
|
}
|
|
262
|
-
export type BaseConstructor = typeof Base;
|
|
263
|
-
export type BaseAsyncConstructor = (Base: any) => Promise<BaseConstructor | {
|
|
264
|
-
default: BaseConstructor;
|
|
265
|
-
}>;
|
|
266
|
-
export type BaseOptions = {
|
|
267
|
-
[name: string]: any;
|
|
268
|
-
};
|
|
269
|
-
export type BaseRefs = {
|
|
270
|
-
[name: string]: HTMLElement | HTMLElement[];
|
|
271
|
-
};
|
|
272
|
-
export type BaseChildren = {
|
|
273
|
-
[nameOrSelector: string]: Base<{
|
|
274
|
-
$el: HTMLElement;
|
|
275
|
-
$options: BaseOptions;
|
|
276
|
-
$refs: BaseRefs;
|
|
277
|
-
$children: {
|
|
278
|
-
[name: string]: Base<any> | Promise<Base<any>>;
|
|
279
|
-
};
|
|
280
|
-
}>[] | Promise<Base<{
|
|
281
|
-
$el: HTMLElement;
|
|
282
|
-
$options: BaseOptions;
|
|
283
|
-
$refs: BaseRefs;
|
|
284
|
-
$children: {
|
|
285
|
-
[name: string]: Base<any> | Promise<Base<any>>;
|
|
286
|
-
};
|
|
287
|
-
}>>[];
|
|
288
|
-
};
|
|
289
|
-
export type BaseConfigComponents = {
|
|
290
|
-
[nameOrSelector: string]: typeof Base | BaseAsyncConstructor;
|
|
291
|
-
};
|
|
292
|
-
export type BaseConfigOptions = import('./managers/OptionsManager').OptionsSchema;
|
|
293
|
-
export type ServiceName = import('./managers/ServicesManager.js').ServiceName;
|
|
294
|
-
export type BaseConfig = {
|
|
295
|
-
name: string;
|
|
296
|
-
debug?: boolean;
|
|
297
|
-
log?: boolean;
|
|
298
|
-
refs?: string[];
|
|
299
|
-
emits?: string[];
|
|
300
|
-
components?: BaseConfigComponents;
|
|
301
|
-
options?: BaseConfigOptions;
|
|
302
|
-
};
|
|
303
|
-
export type BaseTypeParameter = {
|
|
304
|
-
$el?: HTMLElement;
|
|
305
|
-
$options?: BaseOptions;
|
|
306
|
-
$refs?: BaseRefs;
|
|
307
|
-
$children?: {
|
|
308
|
-
[name: string]: Base<{
|
|
309
|
-
$el: HTMLElement;
|
|
310
|
-
$options: BaseOptions;
|
|
311
|
-
$refs: BaseRefs;
|
|
312
|
-
$children: {
|
|
313
|
-
[name: string]: Base<any> | Promise<Base<any>>;
|
|
314
|
-
};
|
|
315
|
-
}> | Promise<Base<{
|
|
316
|
-
$el: HTMLElement;
|
|
317
|
-
$options: BaseOptions;
|
|
318
|
-
$refs: BaseRefs;
|
|
319
|
-
$children: {
|
|
320
|
-
[name: string]: Base<any> | Promise<Base<any>>;
|
|
321
|
-
};
|
|
322
|
-
}>>;
|
|
323
|
-
};
|
|
324
|
-
};
|
|
325
|
-
export type Managers = {
|
|
326
|
-
ChildrenManager: typeof ChildrenManager;
|
|
327
|
-
EventsManager: typeof EventsManager;
|
|
328
|
-
OptionsManager: typeof OptionsManager;
|
|
329
|
-
RefsManager: typeof RefsManager;
|
|
330
|
-
ServicesManager: typeof ServicesManager;
|
|
331
|
-
};
|
|
332
|
-
import ServicesManager from "./managers/ServicesManager.js";
|
|
333
|
-
import RefsManager from "./managers/RefsManager.js";
|
|
334
|
-
import OptionsManager from "./managers/OptionsManager.js";
|
|
335
|
-
import ChildrenManager from "./managers/ChildrenManager.js";
|
|
336
|
-
import EventsManager from "./managers/EventsManager.js";
|
package/Base/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../index.js').
|
|
2
|
+
* @typedef {import('../index.js').Base} Base
|
|
3
3
|
* @typedef {import('../index.js').BaseConfig} BaseConfig
|
|
4
4
|
* @typedef {import('./EventsManager.js').default} EventsManager
|
|
5
5
|
*/
|
|
@@ -39,6 +39,6 @@ export default class AbstractManager {
|
|
|
39
39
|
*/
|
|
40
40
|
__hideProperties(properties: string[]): void;
|
|
41
41
|
}
|
|
42
|
-
export type Base = import('../index.js').
|
|
42
|
+
export type Base = import('../index.js').Base;
|
|
43
43
|
export type BaseConfig = import('../index.js').BaseConfig;
|
|
44
44
|
export type EventsManager = import('./EventsManager.js').default;
|
|
@@ -27,7 +27,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27
27
|
return value;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
// packages/js-toolkit/Base/managers/ChildrenManager.
|
|
30
|
+
// packages/js-toolkit/Base/managers/ChildrenManager.ts
|
|
31
31
|
var ChildrenManager_exports = {};
|
|
32
32
|
__export(ChildrenManager_exports, {
|
|
33
33
|
default: () => ChildrenManager
|
|
@@ -36,9 +36,7 @@ module.exports = __toCommonJS(ChildrenManager_exports);
|
|
|
36
36
|
var import_AbstractManager = __toESM(require("./AbstractManager.cjs"), 1);
|
|
37
37
|
var import_utils = require("../utils.cjs");
|
|
38
38
|
function __getChild(that, el, ComponentClass, name) {
|
|
39
|
-
const asyncComponentPromise = that.__asyncComponentPromises.get(
|
|
40
|
-
ComponentClass
|
|
41
|
-
);
|
|
39
|
+
const asyncComponentPromise = that.__asyncComponentPromises.get(ComponentClass);
|
|
42
40
|
if ("$isBase" in ComponentClass || asyncComponentPromise && asyncComponentPromise.status === "resolved") {
|
|
43
41
|
let ctor = ComponentClass;
|
|
44
42
|
if (asyncComponentPromise) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { BaseConstructor, BaseAsyncConstructor } from '../index.js';
|
|
2
|
+
import AbstractManager from './AbstractManager.js';
|
|
1
3
|
/**
|
|
2
4
|
* Children manager.
|
|
3
5
|
*/
|
|
@@ -5,17 +7,12 @@ export default class ChildrenManager extends AbstractManager {
|
|
|
5
7
|
/**
|
|
6
8
|
* Store async component promises to avoid calling them multiple times and
|
|
7
9
|
* waiting for them when they are already resolved.
|
|
8
|
-
*
|
|
9
|
-
* @type {WeakMap<BaseAsyncConstructor, { promise: ReturnType<BaseAsyncConstructor>, status: 'pending'|'resolved', ctor?: BaseConstructor }>}
|
|
10
10
|
*/
|
|
11
11
|
__asyncComponentPromises: WeakMap<BaseAsyncConstructor, {
|
|
12
12
|
promise: ReturnType<BaseAsyncConstructor>;
|
|
13
13
|
status: 'pending' | 'resolved';
|
|
14
14
|
ctor?: BaseConstructor;
|
|
15
15
|
}>;
|
|
16
|
-
/**
|
|
17
|
-
* @returns {string[]}
|
|
18
|
-
*/
|
|
19
16
|
get registeredNames(): string[];
|
|
20
17
|
/**
|
|
21
18
|
* Register instances of all children components.
|
|
@@ -34,8 +31,3 @@ export default class ChildrenManager extends AbstractManager {
|
|
|
34
31
|
*/
|
|
35
32
|
destroyAll(): void;
|
|
36
33
|
}
|
|
37
|
-
export type Base = import('../index.js').default;
|
|
38
|
-
export type BaseConstructor = import('../index.js').BaseConstructor;
|
|
39
|
-
export type BaseAsyncConstructor = import('../index.js').BaseAsyncConstructor;
|
|
40
|
-
export type BaseConfigComponents = import('../index.js').BaseConfigComponents;
|
|
41
|
-
import AbstractManager from "./AbstractManager.js";
|
|
@@ -7,9 +7,7 @@ var __publicField = (obj, key, value) => {
|
|
|
7
7
|
import AbstractManager from "./AbstractManager.js";
|
|
8
8
|
import { getComponentElements } from "../utils.js";
|
|
9
9
|
function __getChild(that, el, ComponentClass, name) {
|
|
10
|
-
const asyncComponentPromise = that.__asyncComponentPromises.get(
|
|
11
|
-
ComponentClass
|
|
12
|
-
);
|
|
10
|
+
const asyncComponentPromise = that.__asyncComponentPromises.get(ComponentClass);
|
|
13
11
|
if ("$isBase" in ComponentClass || asyncComponentPromise && asyncComponentPromise.status === "resolved") {
|
|
14
12
|
let ctor = ComponentClass;
|
|
15
13
|
if (asyncComponentPromise) {
|
|
@@ -27,7 +27,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27
27
|
return value;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
// packages/js-toolkit/Base/managers/EventsManager.
|
|
30
|
+
// packages/js-toolkit/Base/managers/EventsManager.ts
|
|
31
31
|
var EventsManager_exports = {};
|
|
32
32
|
__export(EventsManager_exports, {
|
|
33
33
|
default: () => EventsManager,
|
|
@@ -143,14 +143,14 @@ var EventsManager = class extends import_AbstractManager.default {
|
|
|
143
143
|
const childrenManager = this.__base.$children;
|
|
144
144
|
const { name, child: resolvedChild } = childrenManager.registeredNames.map((childName) => ({
|
|
145
145
|
name: childName,
|
|
146
|
-
child: childrenManager[childName].find(
|
|
146
|
+
child: [...childrenManager[childName]].find(
|
|
147
147
|
(instance) => instance === event.currentTarget || instance.$el === event.currentTarget
|
|
148
148
|
)
|
|
149
149
|
})).find(({ child }) => child);
|
|
150
150
|
const normalizedChildName = normalizeName(name);
|
|
151
151
|
const normalizedEventName = normalizeName(event.type);
|
|
152
152
|
const method = `on${normalizedChildName}${normalizedEventName}`;
|
|
153
|
-
const index = childrenManager[name].indexOf(resolvedChild);
|
|
153
|
+
const index = [...childrenManager[name]].indexOf(resolvedChild);
|
|
154
154
|
const args = (0, import_utils.isArray)(event.detail) ? event.detail : [];
|
|
155
155
|
this.__base[method](...args, index, event);
|
|
156
156
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Base } from '../index.js';
|
|
2
|
+
import AbstractManager from './AbstractManager.js';
|
|
1
3
|
/**
|
|
2
4
|
* Normalize the given name to PascalCase, such as:
|
|
3
5
|
*
|
|
@@ -18,42 +20,37 @@
|
|
|
18
20
|
* @param {string} name
|
|
19
21
|
* @returns {string}
|
|
20
22
|
*/
|
|
21
|
-
export function normalizeName(name: string): string;
|
|
23
|
+
export declare function normalizeName(name: string): string;
|
|
22
24
|
/**
|
|
23
25
|
* Normalize the event names from PascalCase to kebab-case.
|
|
24
26
|
*
|
|
25
27
|
* @param {string} name
|
|
26
28
|
* @returns {string}
|
|
27
29
|
*/
|
|
28
|
-
export function normalizeEventName(name: string): string;
|
|
30
|
+
export declare function normalizeEventName(name: string): string;
|
|
29
31
|
/**
|
|
30
32
|
* Event management class.
|
|
31
33
|
* @todo Prevent binding of `onChildOrRefEvent` to the root element
|
|
32
34
|
* @todo Use event delegation?
|
|
33
35
|
*/
|
|
34
36
|
export default class EventsManager extends AbstractManager {
|
|
35
|
-
|
|
36
|
-
* @type {WeakMap}
|
|
37
|
-
*/
|
|
38
|
-
__methodsCache: WeakMap<any, any>;
|
|
37
|
+
__methodsCache: Map<string, string[]>;
|
|
39
38
|
/**
|
|
40
39
|
* Event listener object for the root element.
|
|
41
|
-
*
|
|
42
|
-
* @type {EventListenerObject}
|
|
43
40
|
*/
|
|
44
41
|
__rootElementHandler: EventListenerObject;
|
|
45
42
|
/**
|
|
46
43
|
* Event listener object for the refs.
|
|
47
|
-
*
|
|
48
|
-
* @type {EventListenerObject}
|
|
49
44
|
*/
|
|
50
45
|
__refsHandler: EventListenerObject;
|
|
51
46
|
/**
|
|
52
47
|
* Event listener object for the children.
|
|
53
|
-
*
|
|
54
|
-
* @type {EventListenerObject}
|
|
55
48
|
*/
|
|
56
49
|
__childrenHandler: EventListenerObject;
|
|
50
|
+
/**
|
|
51
|
+
* Class constructor.
|
|
52
|
+
*/
|
|
53
|
+
constructor(base: Base);
|
|
57
54
|
/**
|
|
58
55
|
* Bind event methods to the given ref elements.
|
|
59
56
|
*
|
|
@@ -107,6 +104,3 @@ export default class EventsManager extends AbstractManager {
|
|
|
107
104
|
*/
|
|
108
105
|
unbindRootElement(): void;
|
|
109
106
|
}
|
|
110
|
-
export type Base = import('../index.js').default;
|
|
111
|
-
export type ChildrenManager = import('./ChildrenManager.js').default;
|
|
112
|
-
import AbstractManager from "./AbstractManager.js";
|
|
@@ -112,14 +112,14 @@ class EventsManager extends AbstractManager {
|
|
|
112
112
|
const childrenManager = this.__base.$children;
|
|
113
113
|
const { name, child: resolvedChild } = childrenManager.registeredNames.map((childName) => ({
|
|
114
114
|
name: childName,
|
|
115
|
-
child: childrenManager[childName].find(
|
|
115
|
+
child: [...childrenManager[childName]].find(
|
|
116
116
|
(instance) => instance === event.currentTarget || instance.$el === event.currentTarget
|
|
117
117
|
)
|
|
118
118
|
})).find(({ child }) => child);
|
|
119
119
|
const normalizedChildName = normalizeName(name);
|
|
120
120
|
const normalizedEventName = normalizeName(event.type);
|
|
121
121
|
const method = `on${normalizedChildName}${normalizedEventName}`;
|
|
122
|
-
const index = childrenManager[name].indexOf(resolvedChild);
|
|
122
|
+
const index = [...childrenManager[name]].indexOf(resolvedChild);
|
|
123
123
|
const args = isArray(event.detail) ? event.detail : [];
|
|
124
124
|
this.__base[method](...args, index, event);
|
|
125
125
|
}
|
|
@@ -52,7 +52,7 @@ export default class OptionsManager extends AbstractManager {
|
|
|
52
52
|
set(name: string, value: any, config: OptionObject): void;
|
|
53
53
|
}
|
|
54
54
|
export type DeepmergeOptions = import('deepmerge').Options;
|
|
55
|
-
export type Base = import('../index.js').
|
|
55
|
+
export type Base = import('../index.js').Base;
|
|
56
56
|
export type BaseConfig = import('../index.js').BaseConfig;
|
|
57
57
|
export type OptionType = StringConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor | ObjectConstructor;
|
|
58
58
|
export type ArrayOption = {
|
|
@@ -79,7 +79,7 @@ export default class ServicesManager extends AbstractManager {
|
|
|
79
79
|
*/
|
|
80
80
|
unregister(name: string): void;
|
|
81
81
|
}
|
|
82
|
-
export type Base = import('../index').
|
|
82
|
+
export type Base = import('../index').Base;
|
|
83
83
|
export type BaseConstructor = import('../index').BaseConstructor;
|
|
84
84
|
export type ServiceInterface = import('../../services').ServiceInterface<any>;
|
|
85
85
|
export type Services = typeof SERVICES_MAP & Record<string, () => import("../../services").ServiceInterface<any>>;
|
package/Base/types.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// packages/js-toolkit/Base/types.ts
|
|
16
|
+
var types_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(types_exports);
|
|
18
|
+
if (module.exports.default) module.exports = module.exports.default;
|