@studiometa/js-toolkit 2.4.4-alpha.0 → 2.4.4-alpha.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.d.ts +336 -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/utils.d.ts +40 -0
- package/decorators/index.d.ts +10 -0
- package/decorators/withBreakpointManager.d.ts +87 -0
- package/decorators/withBreakpointObserver.d.ts +93 -0
- package/decorators/withDrag.d.ts +84 -0
- package/decorators/withExtraConfig.d.ts +85 -0
- package/decorators/withFreezedOptions.d.ts +84 -0
- package/decorators/withIntersectionObserver.d.ts +97 -0
- package/decorators/withMountWhenInView.d.ts +95 -0
- package/decorators/withResponsiveOptions.d.ts +81 -0
- package/decorators/withScrolledInView.d.ts +198 -0
- package/decorators/withVue2.cjs +2 -2
- package/decorators/withVue2.d.ts +98 -0
- package/decorators/withVue2.js +2 -2
- package/helpers/createApp.d.ts +14 -0
- package/helpers/getDirectChildren.d.ts +31 -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 +5 -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
package/Base/index.d.ts
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {typeof Base} BaseConstructor
|
|
3
|
+
* @typedef {(Base) => Promise<BaseConstructor | { default: BaseConstructor }>} BaseAsyncConstructor
|
|
4
|
+
* @typedef {{ [name:string]: any }} BaseOptions
|
|
5
|
+
* @typedef {{ [name:string]: HTMLElement | HTMLElement[] }} BaseRefs
|
|
6
|
+
* @typedef {{ [nameOrSelector:string]: Base[] | Promise<Base>[] }} BaseChildren
|
|
7
|
+
* @typedef {{ [nameOrSelector:string]: BaseConstructor | BaseAsyncConstructor }} BaseConfigComponents
|
|
8
|
+
* @typedef {import('./managers/OptionsManager').OptionsSchema} BaseConfigOptions
|
|
9
|
+
* @typedef {import('./managers/ServicesManager.js').ServiceName} ServiceName
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {Object} BaseConfig
|
|
13
|
+
* @property {string} name
|
|
14
|
+
* @property {boolean} [debug]
|
|
15
|
+
* @property {boolean} [log]
|
|
16
|
+
* @property {string[]} [refs]
|
|
17
|
+
* @property {string[]} [emits]
|
|
18
|
+
* @property {BaseConfigComponents} [components]
|
|
19
|
+
* @property {BaseConfigOptions} [options]
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {{
|
|
23
|
+
* $el?: HTMLElement,
|
|
24
|
+
* $options?: BaseOptions,
|
|
25
|
+
* $refs?: BaseRefs,
|
|
26
|
+
* $children?: { [name:string]: Base | Promise<Base> },
|
|
27
|
+
* }} BaseTypeParameter
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {Object} Managers
|
|
31
|
+
* @property {typeof ChildrenManager} ChildrenManager
|
|
32
|
+
* @property {typeof EventsManager} EventsManager
|
|
33
|
+
* @property {typeof OptionsManager} OptionsManager
|
|
34
|
+
* @property {typeof RefsManager} RefsManager
|
|
35
|
+
* @property {typeof ServicesManager} ServicesManager
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* Base class.
|
|
39
|
+
* @template {BaseTypeParameter} [BaseInterface={ $el: HTMLElement, $options: BaseOptions, $refs: BaseRefs, $children: { [name:string]: Base | Promise<Base> } }]
|
|
40
|
+
*/
|
|
41
|
+
export default class Base<BaseInterface extends BaseTypeParameter = {
|
|
42
|
+
$el: HTMLElement;
|
|
43
|
+
$options: BaseOptions;
|
|
44
|
+
$refs: BaseRefs;
|
|
45
|
+
$children: {
|
|
46
|
+
[name: string]: Base<any> | Promise<Base<any>>;
|
|
47
|
+
};
|
|
48
|
+
}> extends EventTarget {
|
|
49
|
+
/**
|
|
50
|
+
* 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
|
+
*/
|
|
71
|
+
constructor(element: HTMLElement);
|
|
72
|
+
/**
|
|
73
|
+
* The instance parent.
|
|
74
|
+
* @type {Base}
|
|
75
|
+
*/
|
|
76
|
+
$parent: Base;
|
|
77
|
+
/**
|
|
78
|
+
* The instance id.
|
|
79
|
+
* @type {string}
|
|
80
|
+
*/
|
|
81
|
+
$id: string;
|
|
82
|
+
/**
|
|
83
|
+
* The root element.
|
|
84
|
+
* @type {BaseInterface['$el'] & HTMLElement & { __base__?: WeakMap<BaseConstructor, Base | 'terminated'> }}
|
|
85
|
+
*/
|
|
86
|
+
$el: BaseInterface['$el'] & HTMLElement & {
|
|
87
|
+
__base__?: WeakMap<BaseConstructor, Base | 'terminated'>;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* The state of the component.
|
|
91
|
+
* @type {boolean}
|
|
92
|
+
*/
|
|
93
|
+
$isMounted: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Store the event handlers.
|
|
96
|
+
*
|
|
97
|
+
* @type {Map<string, Set<EventListenerOrEventListenerObject>>}
|
|
98
|
+
*/
|
|
99
|
+
__eventHandlers: Map<string, Set<EventListenerOrEventListenerObject>>;
|
|
100
|
+
/**
|
|
101
|
+
* Get the root instance of the app.
|
|
102
|
+
* @returns {Base}
|
|
103
|
+
*/
|
|
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
|
+
}>;
|
|
112
|
+
/**
|
|
113
|
+
* Merge configuration with the parents' configurations.
|
|
114
|
+
*
|
|
115
|
+
* @returns {BaseConfig}
|
|
116
|
+
*/
|
|
117
|
+
get __config(): BaseConfig;
|
|
118
|
+
/**
|
|
119
|
+
* @type {ServicesManager}
|
|
120
|
+
*/
|
|
121
|
+
__services: ServicesManager;
|
|
122
|
+
/**
|
|
123
|
+
* @type {ServicesManager}
|
|
124
|
+
*/
|
|
125
|
+
get $services(): ServicesManager;
|
|
126
|
+
/**
|
|
127
|
+
* @type {RefsManager & BaseInterface['$refs'] & BaseRefs}
|
|
128
|
+
*/
|
|
129
|
+
__refs: RefsManager & BaseInterface['$refs'] & BaseRefs;
|
|
130
|
+
/**
|
|
131
|
+
* @returns {RefsManager & BaseInterface['$refs'] & BaseRefs}
|
|
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
|
+
*/
|
|
153
|
+
__events: EventsManager;
|
|
154
|
+
/**
|
|
155
|
+
* Small helper to log stuff.
|
|
156
|
+
*
|
|
157
|
+
* @returns {(...args: any) => void}
|
|
158
|
+
*/
|
|
159
|
+
get $log(): (...args: any) => void;
|
|
160
|
+
/**
|
|
161
|
+
* Small helper to debug information.
|
|
162
|
+
*
|
|
163
|
+
* @returns {(...args:any) => void}
|
|
164
|
+
*/
|
|
165
|
+
get __debug(): (...args: any) => void;
|
|
166
|
+
/**
|
|
167
|
+
* Get manager constructors.
|
|
168
|
+
*
|
|
169
|
+
* @returns {Managers}
|
|
170
|
+
*/
|
|
171
|
+
get __managers(): Managers;
|
|
172
|
+
/**
|
|
173
|
+
* Call an instance method and emit corresponding events.
|
|
174
|
+
*
|
|
175
|
+
* @param {string} method
|
|
176
|
+
* @param {any[]} args
|
|
177
|
+
* @returns {any}
|
|
178
|
+
*/
|
|
179
|
+
__callMethod(method: string, ...args: any[]): any;
|
|
180
|
+
/**
|
|
181
|
+
* Test if the given event has been bound to the instance.
|
|
182
|
+
*
|
|
183
|
+
* @param {string} event The event's name.
|
|
184
|
+
* @returns {boolean} Wether the given event has been bound or not.
|
|
185
|
+
*/
|
|
186
|
+
__hasEvent(event: string): boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Trigger the `mounted` callback.
|
|
189
|
+
* @returns {this}
|
|
190
|
+
*/
|
|
191
|
+
$mount(): this;
|
|
192
|
+
/**
|
|
193
|
+
* Update the instance children.
|
|
194
|
+
* @returns {this}
|
|
195
|
+
*/
|
|
196
|
+
$update(): this;
|
|
197
|
+
/**
|
|
198
|
+
* Trigger the `destroyed` callback.
|
|
199
|
+
* @returns {this}
|
|
200
|
+
*/
|
|
201
|
+
$destroy(): this;
|
|
202
|
+
/**
|
|
203
|
+
* Terminate a child instance when it is not needed anymore.
|
|
204
|
+
* @returns {void}
|
|
205
|
+
*/
|
|
206
|
+
$terminate(): void;
|
|
207
|
+
/**
|
|
208
|
+
* Add an emitted event.
|
|
209
|
+
*
|
|
210
|
+
* @param {string} event The event name.
|
|
211
|
+
* @returns {void}
|
|
212
|
+
*/
|
|
213
|
+
__addEmits(event: string): void;
|
|
214
|
+
/**
|
|
215
|
+
* Remove an emitted event.
|
|
216
|
+
*
|
|
217
|
+
* @param {string} event The event name.
|
|
218
|
+
* @returns {void}
|
|
219
|
+
*/
|
|
220
|
+
__removeEmits(event: string): void;
|
|
221
|
+
/**
|
|
222
|
+
* Get the instance constructor.
|
|
223
|
+
*
|
|
224
|
+
* @returns {BaseConstructor}
|
|
225
|
+
*/
|
|
226
|
+
get __ctor(): typeof Base;
|
|
227
|
+
/**
|
|
228
|
+
* Bind a listener function to an event.
|
|
229
|
+
*
|
|
230
|
+
* @param {string} event
|
|
231
|
+
* Name of the event.
|
|
232
|
+
* @param {EventListenerOrEventListenerObject} listener
|
|
233
|
+
* Function to be called.
|
|
234
|
+
* @param {boolean|AddEventListenerOptions} [options]
|
|
235
|
+
* Options for the `removeEventListener` method.
|
|
236
|
+
* @returns {() => void}
|
|
237
|
+
* A function to unbind the listener.
|
|
238
|
+
*/
|
|
239
|
+
$on(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): () => void;
|
|
240
|
+
/**
|
|
241
|
+
* Unbind a listener function from an event.
|
|
242
|
+
*
|
|
243
|
+
* @param {string} event
|
|
244
|
+
* Name of the event.
|
|
245
|
+
* @param {EventListenerOrEventListenerObject} listener
|
|
246
|
+
* Function to be removed.
|
|
247
|
+
* @param {boolean|EventListenerOptions} [options]
|
|
248
|
+
* Options for the `removeEventListener` method.
|
|
249
|
+
* @returns {void}
|
|
250
|
+
*/
|
|
251
|
+
$off(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
252
|
+
/**
|
|
253
|
+
* Emits an event.
|
|
254
|
+
*
|
|
255
|
+
* @param {string} event
|
|
256
|
+
* Name of the event.
|
|
257
|
+
* @param {any[]} args The arguments to apply to the functions bound to this event.
|
|
258
|
+
* @returns {void}
|
|
259
|
+
*/
|
|
260
|
+
$emit(event: string, ...args: any[]): void;
|
|
261
|
+
}
|
|
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";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../index.js').default} Base
|
|
3
|
+
* @typedef {import('../index.js').BaseConfig} BaseConfig
|
|
4
|
+
* @typedef {import('./EventsManager.js').default} EventsManager
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* AbstractManager class.
|
|
8
|
+
*/
|
|
9
|
+
export default class AbstractManager {
|
|
10
|
+
/**
|
|
11
|
+
* Class constructor.
|
|
12
|
+
*
|
|
13
|
+
* @param {Base} base
|
|
14
|
+
*/
|
|
15
|
+
constructor(base: Base);
|
|
16
|
+
/**
|
|
17
|
+
* @type {Base}
|
|
18
|
+
*/
|
|
19
|
+
__base: Base;
|
|
20
|
+
/**
|
|
21
|
+
* Get the base instance root element.
|
|
22
|
+
* @returns {HTMLElement}
|
|
23
|
+
*/
|
|
24
|
+
get __element(): HTMLElement;
|
|
25
|
+
/**
|
|
26
|
+
* Get the base instance config.
|
|
27
|
+
* @returns {BaseConfig}
|
|
28
|
+
*/
|
|
29
|
+
get __config(): import("../index.js").BaseConfig;
|
|
30
|
+
/**
|
|
31
|
+
* Get the events manager.
|
|
32
|
+
* @returns {EventsManager}
|
|
33
|
+
*/
|
|
34
|
+
get __eventsManager(): import("./EventsManager.js").default;
|
|
35
|
+
/**
|
|
36
|
+
* Prevent a list of properties from being enumerable and writable.
|
|
37
|
+
* @param {string[]} properties
|
|
38
|
+
* @returns {void}
|
|
39
|
+
*/
|
|
40
|
+
__hideProperties(properties: string[]): void;
|
|
41
|
+
}
|
|
42
|
+
export type Base = import('../index.js').default;
|
|
43
|
+
export type BaseConfig = import('../index.js').BaseConfig;
|
|
44
|
+
export type EventsManager = import('./EventsManager.js').default;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Children manager.
|
|
3
|
+
*/
|
|
4
|
+
export default class ChildrenManager extends AbstractManager {
|
|
5
|
+
/**
|
|
6
|
+
* Store async component promises to avoid calling them multiple times and
|
|
7
|
+
* waiting for them when they are already resolved.
|
|
8
|
+
*
|
|
9
|
+
* @type {WeakMap<BaseAsyncConstructor, { promise: ReturnType<BaseAsyncConstructor>, status: 'pending'|'resolved', ctor?: BaseConstructor }>}
|
|
10
|
+
*/
|
|
11
|
+
__asyncComponentPromises: WeakMap<BaseAsyncConstructor, {
|
|
12
|
+
promise: ReturnType<BaseAsyncConstructor>;
|
|
13
|
+
status: 'pending' | 'resolved';
|
|
14
|
+
ctor?: BaseConstructor;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* @returns {string[]}
|
|
18
|
+
*/
|
|
19
|
+
get registeredNames(): string[];
|
|
20
|
+
/**
|
|
21
|
+
* Register instances of all children components.
|
|
22
|
+
*/
|
|
23
|
+
registerAll(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Mount all child component instances.
|
|
26
|
+
*/
|
|
27
|
+
mountAll(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Update all child component instances.
|
|
30
|
+
*/
|
|
31
|
+
updateAll(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Destroy all child component instances.
|
|
34
|
+
*/
|
|
35
|
+
destroyAll(): void;
|
|
36
|
+
}
|
|
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";
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize the given name to PascalCase, such as:
|
|
3
|
+
*
|
|
4
|
+
* ```
|
|
5
|
+
* sentence case => SentenceCase
|
|
6
|
+
* lowercase => Lowercase
|
|
7
|
+
* UPPERCASE => Uppercase
|
|
8
|
+
* kebab-case => KebabCase
|
|
9
|
+
* snake_case => SnakeCase
|
|
10
|
+
* camelCase => CamelCase
|
|
11
|
+
* PascalCase => PascalCase
|
|
12
|
+
* .class-selector => ClassSelector
|
|
13
|
+
* .bem__selector => BemSelector
|
|
14
|
+
* __id-selector => IdSelector
|
|
15
|
+
* .complex[class^ ="__"] => ComplexClass
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param {string} name
|
|
19
|
+
* @returns {string}
|
|
20
|
+
*/
|
|
21
|
+
export function normalizeName(name: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Normalize the event names from PascalCase to kebab-case.
|
|
24
|
+
*
|
|
25
|
+
* @param {string} name
|
|
26
|
+
* @returns {string}
|
|
27
|
+
*/
|
|
28
|
+
export function normalizeEventName(name: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Event management class.
|
|
31
|
+
* @todo Prevent binding of `onChildOrRefEvent` to the root element
|
|
32
|
+
* @todo Use event delegation?
|
|
33
|
+
*/
|
|
34
|
+
export default class EventsManager extends AbstractManager {
|
|
35
|
+
/**
|
|
36
|
+
* @type {WeakMap}
|
|
37
|
+
*/
|
|
38
|
+
__methodsCache: WeakMap<any, any>;
|
|
39
|
+
/**
|
|
40
|
+
* Event listener object for the root element.
|
|
41
|
+
*
|
|
42
|
+
* @type {EventListenerObject}
|
|
43
|
+
*/
|
|
44
|
+
__rootElementHandler: EventListenerObject;
|
|
45
|
+
/**
|
|
46
|
+
* Event listener object for the refs.
|
|
47
|
+
*
|
|
48
|
+
* @type {EventListenerObject}
|
|
49
|
+
*/
|
|
50
|
+
__refsHandler: EventListenerObject;
|
|
51
|
+
/**
|
|
52
|
+
* Event listener object for the children.
|
|
53
|
+
*
|
|
54
|
+
* @type {EventListenerObject}
|
|
55
|
+
*/
|
|
56
|
+
__childrenHandler: EventListenerObject;
|
|
57
|
+
/**
|
|
58
|
+
* Bind event methods to the given ref elements.
|
|
59
|
+
*
|
|
60
|
+
* @param {string} name
|
|
61
|
+
* The name of the ref.
|
|
62
|
+
* @param {HTMLElement[]} elements
|
|
63
|
+
* The elements of the ref.
|
|
64
|
+
* @returns {void}
|
|
65
|
+
*/
|
|
66
|
+
bindRef(name: string, elements: HTMLElement[]): void;
|
|
67
|
+
/**
|
|
68
|
+
* Bind event methods to the given ref elements.
|
|
69
|
+
*
|
|
70
|
+
* @param {string} name
|
|
71
|
+
* The name of the ref.
|
|
72
|
+
* @param {HTMLElement[]} elements
|
|
73
|
+
* The elements of the ref.
|
|
74
|
+
* @returns {void}
|
|
75
|
+
*/
|
|
76
|
+
unbindRef(name: string, elements: HTMLElement[]): void;
|
|
77
|
+
/**
|
|
78
|
+
* Bind event methods to the given child instance.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} name
|
|
81
|
+
* The name of the ref.
|
|
82
|
+
* @param {Base} instance
|
|
83
|
+
* A base instance.
|
|
84
|
+
* @returns {void}
|
|
85
|
+
*/
|
|
86
|
+
bindChild(name: string, instance: Base): void;
|
|
87
|
+
/**
|
|
88
|
+
* Unbind event methods to the given child instance.
|
|
89
|
+
*
|
|
90
|
+
* @param {string} name
|
|
91
|
+
* The name of the ref.
|
|
92
|
+
* @param {Base} instance
|
|
93
|
+
* A base instance.
|
|
94
|
+
* @returns {void}
|
|
95
|
+
*/
|
|
96
|
+
unbindChild(name: string, instance: Base): void;
|
|
97
|
+
/**
|
|
98
|
+
* Bind event methods on the root element.
|
|
99
|
+
*
|
|
100
|
+
* @returns {void}
|
|
101
|
+
*/
|
|
102
|
+
bindRootElement(): void;
|
|
103
|
+
/**
|
|
104
|
+
* Unbind event method from the root element.
|
|
105
|
+
*
|
|
106
|
+
* @returns {void}
|
|
107
|
+
*/
|
|
108
|
+
unbindRootElement(): void;
|
|
109
|
+
}
|
|
110
|
+
export type Base = import('../index.js').default;
|
|
111
|
+
export type ChildrenManager = import('./ChildrenManager.js').default;
|
|
112
|
+
import AbstractManager from "./AbstractManager.js";
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get a property name.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} name
|
|
5
|
+
* @param {string} [prefix]
|
|
6
|
+
* @returns {string}
|
|
7
|
+
* @protected
|
|
8
|
+
*/
|
|
9
|
+
export function __getPropertyName(name: string, prefix?: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Class options to manage options as data attributes on an HTML element.
|
|
12
|
+
*
|
|
13
|
+
* @todo Use `MutationObserver` to update values? Might be more performant.
|
|
14
|
+
*/
|
|
15
|
+
export default class OptionsManager extends AbstractManager {
|
|
16
|
+
/**
|
|
17
|
+
* An object to store Array and Object values for reference.
|
|
18
|
+
* @type {Object}
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
private __values;
|
|
22
|
+
/**
|
|
23
|
+
* Default value for the name property.
|
|
24
|
+
* @type {string}
|
|
25
|
+
*/
|
|
26
|
+
name: string;
|
|
27
|
+
/**
|
|
28
|
+
* Default value for the debug property.
|
|
29
|
+
* @type {boolean}
|
|
30
|
+
*/
|
|
31
|
+
debug: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Default value for the log property.
|
|
34
|
+
* @type {boolean}
|
|
35
|
+
*/
|
|
36
|
+
log: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Get an option value.
|
|
39
|
+
*
|
|
40
|
+
* @param {string} name The option name.
|
|
41
|
+
* @param {OptionObject} config The option config.
|
|
42
|
+
* @returns {any}
|
|
43
|
+
*/
|
|
44
|
+
get(name: string, config: OptionObject): any;
|
|
45
|
+
/**
|
|
46
|
+
* Set an option value.
|
|
47
|
+
*
|
|
48
|
+
* @param {string} name The option name.
|
|
49
|
+
* @param {any} value The new value for this option.
|
|
50
|
+
* @param {OptionObject} config The option config.
|
|
51
|
+
*/
|
|
52
|
+
set(name: string, value: any, config: OptionObject): void;
|
|
53
|
+
}
|
|
54
|
+
export type DeepmergeOptions = import('deepmerge').Options;
|
|
55
|
+
export type Base = import('../index.js').default;
|
|
56
|
+
export type BaseConfig = import('../index.js').BaseConfig;
|
|
57
|
+
export type OptionType = StringConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor | ObjectConstructor;
|
|
58
|
+
export type ArrayOption = {
|
|
59
|
+
type: ArrayConstructor;
|
|
60
|
+
default?: () => any[];
|
|
61
|
+
merge?: boolean;
|
|
62
|
+
};
|
|
63
|
+
export type ObjectOption = {
|
|
64
|
+
type: ObjectConstructor;
|
|
65
|
+
default?: () => any;
|
|
66
|
+
merge?: boolean;
|
|
67
|
+
};
|
|
68
|
+
export type StringOption = {
|
|
69
|
+
type: StringConstructor;
|
|
70
|
+
default?: string;
|
|
71
|
+
};
|
|
72
|
+
export type NumberOption = {
|
|
73
|
+
type: NumberConstructor;
|
|
74
|
+
default?: number;
|
|
75
|
+
};
|
|
76
|
+
export type BooleanOption = {
|
|
77
|
+
type: BooleanConstructor;
|
|
78
|
+
default?: boolean;
|
|
79
|
+
};
|
|
80
|
+
export type OptionObject = ArrayOption | ObjectOption | StringOption | NumberOption | BooleanOption;
|
|
81
|
+
export type OptionsSchema = {
|
|
82
|
+
[name: string]: OptionObject | OptionType;
|
|
83
|
+
};
|
|
84
|
+
export type OptionsInterface = {
|
|
85
|
+
[optionName: string]: any;
|
|
86
|
+
};
|
|
87
|
+
import AbstractManager from "./AbstractManager.js";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize the name of ref.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} name The original name.
|
|
5
|
+
* @returns {string} The normalized name.
|
|
6
|
+
*/
|
|
7
|
+
export function normalizeRefName(name: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Refs Manager
|
|
10
|
+
*
|
|
11
|
+
* @todo Use `MutationObserver` to automatically update refs?
|
|
12
|
+
*/
|
|
13
|
+
export default class RefsManager extends AbstractManager {
|
|
14
|
+
/**
|
|
15
|
+
* Get refs configuration.
|
|
16
|
+
* @returns {string[]}
|
|
17
|
+
*/
|
|
18
|
+
get __refs(): string[];
|
|
19
|
+
/**
|
|
20
|
+
* Register all refs.
|
|
21
|
+
*
|
|
22
|
+
* @returns {void}
|
|
23
|
+
*/
|
|
24
|
+
registerAll(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Unregister all refs.
|
|
27
|
+
*
|
|
28
|
+
* @returns {void}
|
|
29
|
+
*/
|
|
30
|
+
unregisterAll(): void;
|
|
31
|
+
}
|
|
32
|
+
import AbstractManager from "./AbstractManager.js";
|
|
@@ -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/Base/managers/ResponsiveOptionsManager.
|
|
25
|
+
// packages/js-toolkit/Base/managers/ResponsiveOptionsManager.ts
|
|
26
26
|
var ResponsiveOptionsManager_exports = {};
|
|
27
27
|
__export(ResponsiveOptionsManager_exports, {
|
|
28
28
|
default: () => ResponsiveOptionsManager
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import OptionsManager from './OptionsManager.js';
|
|
2
|
+
/**
|
|
3
|
+
* Class options to manage options as data attributes on an HTML element.
|
|
4
|
+
*/
|
|
5
|
+
export default class ResponsiveOptionsManager extends OptionsManager {
|
|
6
|
+
/**
|
|
7
|
+
* Get an option value.
|
|
8
|
+
*
|
|
9
|
+
* @param {string} name The option name.
|
|
10
|
+
* @param {ResponsiveOptionObject} config The option configuration.
|
|
11
|
+
* @returns {any}
|
|
12
|
+
*/
|
|
13
|
+
get(name: any, config: any): any;
|
|
14
|
+
/**
|
|
15
|
+
* Set an option value.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} name The option name.
|
|
18
|
+
* @param {any} value The new value.
|
|
19
|
+
* @param {ResponsiveOptionObject} config The option configuration.
|
|
20
|
+
*/
|
|
21
|
+
set(name: any, value: any, config: any): void;
|
|
22
|
+
}
|