@studiometa/js-toolkit 2.4.0 → 2.4.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 +10 -3
- package/Base/index.d.ts +76 -17
- package/Base/index.js +6 -2
- package/Base/managers/AbstractManager.cjs +13 -8
- package/Base/managers/AbstractManager.js +13 -8
- package/Base/managers/ChildrenManager.cjs +10 -3
- package/Base/managers/ChildrenManager.js +6 -2
- package/Base/managers/EventsManager.cjs +17 -4
- package/Base/managers/EventsManager.js +13 -3
- package/Base/managers/OptionsManager.cjs +18 -5
- package/Base/managers/OptionsManager.d.ts +1 -1
- package/Base/managers/OptionsManager.js +14 -4
- package/Base/managers/RefsManager.cjs +17 -4
- package/Base/managers/RefsManager.js +13 -3
- package/Base/managers/ResponsiveOptionsManager.cjs +4 -1
- package/Base/managers/ServicesManager.cjs +12 -5
- package/Base/managers/ServicesManager.js +8 -4
- package/Base/utils.cjs +5 -1
- package/Base/utils.js +5 -1
- package/decorators/index.cjs +4 -1
- package/decorators/withBreakpointManager.cjs +4 -1
- package/decorators/withBreakpointObserver.cjs +10 -3
- package/decorators/withBreakpointObserver.js +6 -2
- package/decorators/withDrag.cjs +8 -2
- package/decorators/withDrag.d.ts +8 -1
- package/decorators/withDrag.js +4 -1
- package/decorators/withExtraConfig.cjs +4 -1
- package/decorators/withIntersectionObserver.cjs +9 -6
- package/decorators/withIntersectionObserver.js +9 -6
- package/decorators/withMountWhenInView.cjs +13 -10
- package/decorators/withMountWhenInView.js +13 -10
- package/decorators/withResponsiveOptions.cjs +4 -1
- package/decorators/withScrolledInView.cjs +64 -18
- package/decorators/withScrolledInView.d.ts +26 -5
- package/decorators/withScrolledInView.js +60 -17
- package/helpers/getDirectChildren.d.ts +9 -2
- package/helpers/importWhenIdle.cjs +8 -5
- package/helpers/importWhenIdle.js +8 -5
- package/helpers/index.cjs +4 -1
- package/index.cjs +4 -1
- package/index.d.ts +1 -0
- package/package.json +2 -2
- package/services/drag.cjs +4 -1
- package/services/index.cjs +4 -1
- package/services/index.d.ts +7 -0
- package/services/key.cjs +4 -1
- package/services/resize.cjs +4 -1
- package/services/scroll.cjs +4 -1
- package/utils/collide/index.cjs +4 -1
- package/utils/css/animate.cjs +24 -13
- package/utils/css/animate.js +20 -12
- package/utils/css/index.cjs +4 -1
- package/utils/css/transition.cjs +4 -4
- package/utils/css/transition.js +0 -3
- package/utils/focusTrap.cjs +4 -1
- package/utils/history.cjs +4 -1
- package/utils/history.js +4 -1
- package/utils/index.cjs +4 -1
- package/utils/math/clamp01.cjs +4 -1
- package/utils/math/index.cjs +4 -1
- package/utils/math/inertiaFinalValue.cjs +4 -1
- package/utils/nextTick.cjs +5 -3
- package/utils/nextTick.js +5 -3
- package/utils/object/autoBind.cjs +4 -1
- package/utils/object/index.cjs +4 -1
- package/utils/scrollTo.cjs +4 -1
- package/utils/string/index.cjs +4 -1
- package/utils/string/withLeadingCharacters.cjs +4 -1
- package/utils/string/withLeadingSlash.cjs +4 -1
- package/utils/string/withTrailingCharacters.cjs +4 -1
- package/utils/string/withTrailingSlash.cjs +4 -1
- package/utils/string/withoutLeadingCharactersRecursive.cjs +4 -1
- package/utils/string/withoutLeadingSlash.cjs +4 -1
- package/utils/string/withoutTrailingCharactersRecursive.cjs +4 -1
- package/utils/string/withoutTrailingSlash.cjs +4 -1
- package/utils/tween.cjs +4 -1
package/Base/index.cjs
CHANGED
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
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
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
var __publicField = (obj, key, value) => {
|
|
23
26
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -68,7 +71,9 @@ function createAndTestManagers(instance) {
|
|
|
68
71
|
].forEach(({ prop, constructorName, constructor }) => {
|
|
69
72
|
instance[prop] = new instance.__managers[constructorName](instance);
|
|
70
73
|
if (import_utils2.isDev && !(instance[prop] instanceof constructor)) {
|
|
71
|
-
throw new Error(
|
|
74
|
+
throw new Error(
|
|
75
|
+
`The \`$managers.${constructorName}\` must extend the \`${constructorName}\` class.`
|
|
76
|
+
);
|
|
72
77
|
}
|
|
73
78
|
});
|
|
74
79
|
}
|
|
@@ -288,7 +293,9 @@ var Base = class extends EventTarget {
|
|
|
288
293
|
}
|
|
289
294
|
static $factory(nameOrSelector) {
|
|
290
295
|
if (import_utils2.isDev && !nameOrSelector) {
|
|
291
|
-
throw new Error(
|
|
296
|
+
throw new Error(
|
|
297
|
+
"The $factory method requires a component\u2019s name or selector to be specified."
|
|
298
|
+
);
|
|
292
299
|
}
|
|
293
300
|
return (0, import_utils.getComponentElements)(nameOrSelector).map((el) => new this(el).$mount());
|
|
294
301
|
}
|
package/Base/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {typeof Base} BaseConstructor
|
|
3
3
|
* @typedef {(Base) => Promise<BaseConstructor | { default: BaseConstructor }>} BaseAsyncConstructor
|
|
4
|
-
* @typedef {
|
|
4
|
+
* @typedef {{ [name:string]: any }} BaseOptions
|
|
5
5
|
* @typedef {{ [name:string]: HTMLElement | HTMLElement[] }} BaseRefs
|
|
6
6
|
* @typedef {{ [nameOrSelector:string]: Base[] | Promise<Base>[] }} BaseChildren
|
|
7
7
|
* @typedef {{ [nameOrSelector:string]: BaseConstructor | BaseAsyncConstructor }} BaseConfigComponents
|
|
@@ -18,6 +18,14 @@
|
|
|
18
18
|
* @property {BaseConfigComponents} [components]
|
|
19
19
|
* @property {BaseConfigOptions} [options]
|
|
20
20
|
*/
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {{
|
|
23
|
+
* $el?: HTMLElement,
|
|
24
|
+
* $options?: BaseOptions,
|
|
25
|
+
* $refs?: BaseRefs,
|
|
26
|
+
* $children?: { [name:string]: Base | Promise<Base> },
|
|
27
|
+
* }} BaseTypeParameter
|
|
28
|
+
*/
|
|
21
29
|
/**
|
|
22
30
|
* @typedef {Object} Managers
|
|
23
31
|
* @property {typeof ChildrenManager} ChildrenManager
|
|
@@ -28,8 +36,16 @@
|
|
|
28
36
|
*/
|
|
29
37
|
/**
|
|
30
38
|
* Base class.
|
|
39
|
+
* @template {BaseTypeParameter} [BaseInterface={ $el: HTMLElement, $options: BaseOptions, $refs: BaseRefs, $children: { [name:string]: Base | Promise<Base> } }]
|
|
31
40
|
*/
|
|
32
|
-
export default class Base extends
|
|
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 {
|
|
33
49
|
/**
|
|
34
50
|
* This is a Base instance.
|
|
35
51
|
* @type {boolean}
|
|
@@ -65,9 +81,9 @@ export default class Base extends EventTarget {
|
|
|
65
81
|
$id: string;
|
|
66
82
|
/**
|
|
67
83
|
* The root element.
|
|
68
|
-
* @type {HTMLElement & { __base__?: WeakMap<BaseConstructor, Base | 'terminated'> }}
|
|
84
|
+
* @type {BaseInterface['$el'] & HTMLElement & { __base__?: WeakMap<BaseConstructor, Base | 'terminated'> }}
|
|
69
85
|
*/
|
|
70
|
-
$el: HTMLElement & {
|
|
86
|
+
$el: BaseInterface['$el'] & HTMLElement & {
|
|
71
87
|
__base__?: WeakMap<BaseConstructor, Base | 'terminated'>;
|
|
72
88
|
};
|
|
73
89
|
/**
|
|
@@ -86,7 +102,14 @@ export default class Base extends EventTarget {
|
|
|
86
102
|
* Get the root instance of the app.
|
|
87
103
|
* @returns {Base}
|
|
88
104
|
*/
|
|
89
|
-
get $root(): Base
|
|
105
|
+
get $root(): Base<{
|
|
106
|
+
$el: HTMLElement;
|
|
107
|
+
$options: BaseOptions;
|
|
108
|
+
$refs: BaseRefs;
|
|
109
|
+
$children: {
|
|
110
|
+
[name: string]: Base<any> | Promise<Base<any>>;
|
|
111
|
+
};
|
|
112
|
+
}>;
|
|
90
113
|
/**
|
|
91
114
|
* Merge configuration with the parents' configurations.
|
|
92
115
|
*
|
|
@@ -104,32 +127,32 @@ export default class Base extends EventTarget {
|
|
|
104
127
|
*/
|
|
105
128
|
get $services(): ServicesManager;
|
|
106
129
|
/**
|
|
107
|
-
* @type {RefsManager}
|
|
130
|
+
* @type {RefsManager & { [key in keyof BaseInterface['$refs']]: BaseInterface['$refs'][key] } & BaseRefs}
|
|
108
131
|
* @private
|
|
109
132
|
*/
|
|
110
133
|
private __refs;
|
|
111
134
|
/**
|
|
112
|
-
* @returns {RefsManager}
|
|
135
|
+
* @returns {RefsManager & { [key in keyof BaseInterface['$refs']]: BaseInterface['$refs'][key] } & BaseRefs}
|
|
113
136
|
*/
|
|
114
|
-
get $refs(): RefsManager;
|
|
137
|
+
get $refs(): RefsManager & (BaseInterface["$refs"] extends infer T ? { [key in keyof T]: BaseInterface["$refs"][key]; } : never) & BaseRefs;
|
|
115
138
|
/**
|
|
116
|
-
* @type {BaseOptions}
|
|
139
|
+
* @type {OptionsManager & { [key in keyof BaseInterface['$options']]: BaseInterface['$options'][key] } & BaseOptions}
|
|
117
140
|
* @private
|
|
118
141
|
*/
|
|
119
142
|
private __options;
|
|
120
143
|
/**
|
|
121
|
-
* @returns {BaseOptions}
|
|
144
|
+
* @returns {OptionsManager & { [key in keyof BaseInterface['$options']]: BaseInterface['$options'][key] } & BaseOptions}
|
|
122
145
|
*/
|
|
123
|
-
get $options(): BaseOptions;
|
|
146
|
+
get $options(): OptionsManager & (BaseInterface["$options"] extends infer T_1 ? { [key_1 in keyof T_1]: BaseInterface["$options"][key_1]; } : never) & BaseOptions;
|
|
124
147
|
/**
|
|
125
|
-
* @type {ChildrenManager}
|
|
148
|
+
* @type {ChildrenManager & { [key in keyof BaseInterface['$children']]: Array<BaseInterface['$children'][key]> } & BaseChildren}
|
|
126
149
|
* @private
|
|
127
150
|
*/
|
|
128
151
|
private __children;
|
|
129
152
|
/**
|
|
130
|
-
* @returns {ChildrenManager}
|
|
153
|
+
* @returns {ChildrenManager & { [key in keyof BaseInterface['$children']]: Array<BaseInterface['$children'][key]> } & BaseChildren}
|
|
131
154
|
*/
|
|
132
|
-
get $children(): ChildrenManager;
|
|
155
|
+
get $children(): ChildrenManager & (BaseInterface["$children"] extends infer T_2 ? { [key_2 in keyof T_2]: BaseInterface["$children"][key_2][]; } : never) & BaseChildren;
|
|
133
156
|
/**
|
|
134
157
|
* @type {EventsManager}
|
|
135
158
|
* @private
|
|
@@ -253,14 +276,28 @@ export type BaseConstructor = typeof Base;
|
|
|
253
276
|
export type BaseAsyncConstructor = (Base: any) => Promise<BaseConstructor | {
|
|
254
277
|
default: BaseConstructor;
|
|
255
278
|
}>;
|
|
256
|
-
export type BaseOptions =
|
|
279
|
+
export type BaseOptions = {
|
|
257
280
|
[name: string]: any;
|
|
258
281
|
};
|
|
259
282
|
export type BaseRefs = {
|
|
260
283
|
[name: string]: HTMLElement | HTMLElement[];
|
|
261
284
|
};
|
|
262
285
|
export type BaseChildren = {
|
|
263
|
-
[nameOrSelector: string]: Base
|
|
286
|
+
[nameOrSelector: string]: Base<{
|
|
287
|
+
$el: HTMLElement;
|
|
288
|
+
$options: BaseOptions;
|
|
289
|
+
$refs: BaseRefs;
|
|
290
|
+
$children: {
|
|
291
|
+
[name: string]: Base<any> | Promise<Base<any>>;
|
|
292
|
+
};
|
|
293
|
+
}>[] | Promise<Base<{
|
|
294
|
+
$el: HTMLElement;
|
|
295
|
+
$options: BaseOptions;
|
|
296
|
+
$refs: BaseRefs;
|
|
297
|
+
$children: {
|
|
298
|
+
[name: string]: Base<any> | Promise<Base<any>>;
|
|
299
|
+
};
|
|
300
|
+
}>>[];
|
|
264
301
|
};
|
|
265
302
|
export type BaseConfigComponents = {
|
|
266
303
|
[nameOrSelector: string]: typeof Base | BaseAsyncConstructor;
|
|
@@ -276,6 +313,28 @@ export type BaseConfig = {
|
|
|
276
313
|
components?: BaseConfigComponents;
|
|
277
314
|
options?: BaseConfigOptions;
|
|
278
315
|
};
|
|
316
|
+
export type BaseTypeParameter = {
|
|
317
|
+
$el?: HTMLElement;
|
|
318
|
+
$options?: BaseOptions;
|
|
319
|
+
$refs?: BaseRefs;
|
|
320
|
+
$children?: {
|
|
321
|
+
[name: string]: Base<{
|
|
322
|
+
$el: HTMLElement;
|
|
323
|
+
$options: BaseOptions;
|
|
324
|
+
$refs: BaseRefs;
|
|
325
|
+
$children: {
|
|
326
|
+
[name: string]: Base<any> | Promise<Base<any>>;
|
|
327
|
+
};
|
|
328
|
+
}> | Promise<Base<{
|
|
329
|
+
$el: HTMLElement;
|
|
330
|
+
$options: BaseOptions;
|
|
331
|
+
$refs: BaseRefs;
|
|
332
|
+
$children: {
|
|
333
|
+
[name: string]: Base<any> | Promise<Base<any>>;
|
|
334
|
+
};
|
|
335
|
+
}>>;
|
|
336
|
+
};
|
|
337
|
+
};
|
|
279
338
|
export type Managers = {
|
|
280
339
|
ChildrenManager: typeof ChildrenManager;
|
|
281
340
|
EventsManager: typeof EventsManager;
|
|
@@ -285,6 +344,6 @@ export type Managers = {
|
|
|
285
344
|
};
|
|
286
345
|
import ServicesManager from "./managers/ServicesManager.js";
|
|
287
346
|
import RefsManager from "./managers/RefsManager.js";
|
|
288
|
-
import ChildrenManager from "./managers/ChildrenManager.js";
|
|
289
347
|
import OptionsManager from "./managers/OptionsManager.js";
|
|
348
|
+
import ChildrenManager from "./managers/ChildrenManager.js";
|
|
290
349
|
import EventsManager from "./managers/EventsManager.js";
|
package/Base/index.js
CHANGED
|
@@ -42,7 +42,9 @@ function createAndTestManagers(instance) {
|
|
|
42
42
|
].forEach(({ prop, constructorName, constructor }) => {
|
|
43
43
|
instance[prop] = new instance.__managers[constructorName](instance);
|
|
44
44
|
if (isDev && !(instance[prop] instanceof constructor)) {
|
|
45
|
-
throw new Error(
|
|
45
|
+
throw new Error(
|
|
46
|
+
`The \`$managers.${constructorName}\` must extend the \`${constructorName}\` class.`
|
|
47
|
+
);
|
|
46
48
|
}
|
|
47
49
|
});
|
|
48
50
|
}
|
|
@@ -262,7 +264,9 @@ class Base extends EventTarget {
|
|
|
262
264
|
}
|
|
263
265
|
static $factory(nameOrSelector) {
|
|
264
266
|
if (isDev && !nameOrSelector) {
|
|
265
|
-
throw new Error(
|
|
267
|
+
throw new Error(
|
|
268
|
+
"The $factory method requires a component\u2019s name or selector to be specified."
|
|
269
|
+
);
|
|
266
270
|
}
|
|
267
271
|
return getComponentElements(nameOrSelector).map((el) => new this(el).$mount());
|
|
268
272
|
}
|
|
@@ -43,14 +43,19 @@ var AbstractManager = class {
|
|
|
43
43
|
return this.__base.__events;
|
|
44
44
|
}
|
|
45
45
|
__hideProperties(properties) {
|
|
46
|
-
Object.defineProperties(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
Object.defineProperties(
|
|
47
|
+
this,
|
|
48
|
+
Object.fromEntries(
|
|
49
|
+
properties.map((property) => [
|
|
50
|
+
property,
|
|
51
|
+
{
|
|
52
|
+
enumerable: false,
|
|
53
|
+
writable: false,
|
|
54
|
+
value: this[property]
|
|
55
|
+
}
|
|
56
|
+
])
|
|
57
|
+
)
|
|
58
|
+
);
|
|
54
59
|
}
|
|
55
60
|
};
|
|
56
61
|
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -20,14 +20,19 @@ class AbstractManager {
|
|
|
20
20
|
return this.__base.__events;
|
|
21
21
|
}
|
|
22
22
|
__hideProperties(properties) {
|
|
23
|
-
Object.defineProperties(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
Object.defineProperties(
|
|
24
|
+
this,
|
|
25
|
+
Object.fromEntries(
|
|
26
|
+
properties.map((property) => [
|
|
27
|
+
property,
|
|
28
|
+
{
|
|
29
|
+
enumerable: false,
|
|
30
|
+
writable: false,
|
|
31
|
+
value: this[property]
|
|
32
|
+
}
|
|
33
|
+
])
|
|
34
|
+
)
|
|
35
|
+
);
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
38
|
export {
|
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
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
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
var __publicField = (obj, key, value) => {
|
|
23
26
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -33,7 +36,9 @@ module.exports = __toCommonJS(ChildrenManager_exports);
|
|
|
33
36
|
var import_AbstractManager = __toESM(require("./AbstractManager.cjs"), 1);
|
|
34
37
|
var import_utils = require("../utils.cjs");
|
|
35
38
|
function __getChild(that, el, ComponentClass, name) {
|
|
36
|
-
const asyncComponentPromise = that.__asyncComponentPromises.get(
|
|
39
|
+
const asyncComponentPromise = that.__asyncComponentPromises.get(
|
|
40
|
+
ComponentClass
|
|
41
|
+
);
|
|
37
42
|
if ("$isBase" in ComponentClass || asyncComponentPromise && asyncComponentPromise.status === "resolved") {
|
|
38
43
|
let ctor = ComponentClass;
|
|
39
44
|
if (asyncComponentPromise) {
|
|
@@ -110,7 +115,9 @@ var ChildrenManager = class extends import_AbstractManager.default {
|
|
|
110
115
|
return Object.keys(this).filter((key) => !key.startsWith("__"));
|
|
111
116
|
}
|
|
112
117
|
registerAll() {
|
|
113
|
-
Object.entries(this.__config.components).forEach(
|
|
118
|
+
Object.entries(this.__config.components).forEach(
|
|
119
|
+
([name, component]) => __register(this, name, component)
|
|
120
|
+
);
|
|
114
121
|
}
|
|
115
122
|
mountAll() {
|
|
116
123
|
__triggerHookForAll(this, "$mount");
|
|
@@ -7,7 +7,9 @@ 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(
|
|
10
|
+
const asyncComponentPromise = that.__asyncComponentPromises.get(
|
|
11
|
+
ComponentClass
|
|
12
|
+
);
|
|
11
13
|
if ("$isBase" in ComponentClass || asyncComponentPromise && asyncComponentPromise.status === "resolved") {
|
|
12
14
|
let ctor = ComponentClass;
|
|
13
15
|
if (asyncComponentPromise) {
|
|
@@ -84,7 +86,9 @@ class ChildrenManager extends AbstractManager {
|
|
|
84
86
|
return Object.keys(this).filter((key) => !key.startsWith("__"));
|
|
85
87
|
}
|
|
86
88
|
registerAll() {
|
|
87
|
-
Object.entries(this.__config.components).forEach(
|
|
89
|
+
Object.entries(this.__config.components).forEach(
|
|
90
|
+
([name, component]) => __register(this, name, component)
|
|
91
|
+
);
|
|
88
92
|
}
|
|
89
93
|
mountAll() {
|
|
90
94
|
__triggerHookForAll(this, "$mount");
|
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
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
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
var __publicField = (obj, key, value) => {
|
|
23
26
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -40,7 +43,10 @@ var import_RefsManager = require("./RefsManager.cjs");
|
|
|
40
43
|
var names = /* @__PURE__ */ new Map();
|
|
41
44
|
function normalizeName(name) {
|
|
42
45
|
if (!names.has(name)) {
|
|
43
|
-
names.set(
|
|
46
|
+
names.set(
|
|
47
|
+
name,
|
|
48
|
+
name.replace(/[A-Z]([A-Z].*)/g, (c) => c.toLowerCase()).replace(/[^a-zA-Z\d\s:]/g, " ").replace(/(^\w|\s+\w)/g, (c) => c.trim().toUpperCase()).trim()
|
|
49
|
+
);
|
|
44
50
|
}
|
|
45
51
|
return names.get(name);
|
|
46
52
|
}
|
|
@@ -68,7 +74,12 @@ function getEventMethodsByName(that, name = "") {
|
|
|
68
74
|
const key = regex.toString();
|
|
69
75
|
let methods = that.__methodsCache.get(key);
|
|
70
76
|
if (!methods) {
|
|
71
|
-
methods = Array.from(
|
|
77
|
+
methods = Array.from(
|
|
78
|
+
(0, import_getAllProperties.default)(that.__base, [], (method) => regex.test(method)).reduce(
|
|
79
|
+
(set, [method]) => set.add(method),
|
|
80
|
+
/* @__PURE__ */ new Set()
|
|
81
|
+
)
|
|
82
|
+
);
|
|
72
83
|
that.__methodsCache.set(key, methods);
|
|
73
84
|
}
|
|
74
85
|
return methods;
|
|
@@ -132,7 +143,9 @@ var EventsManager = class extends import_AbstractManager.default {
|
|
|
132
143
|
const childrenManager = this.__base.$children;
|
|
133
144
|
const { name, child: resolvedChild } = childrenManager.registeredNames.map((childName) => ({
|
|
134
145
|
name: childName,
|
|
135
|
-
child: childrenManager[childName].find(
|
|
146
|
+
child: childrenManager[childName].find(
|
|
147
|
+
(instance) => instance === event.currentTarget || instance.$el === event.currentTarget
|
|
148
|
+
)
|
|
136
149
|
})).find(({ child }) => child);
|
|
137
150
|
const normalizedChildName = normalizeName(name);
|
|
138
151
|
const normalizedEventName = normalizeName(event.type);
|
|
@@ -12,7 +12,10 @@ import { normalizeRefName } from "./RefsManager.js";
|
|
|
12
12
|
const names = /* @__PURE__ */ new Map();
|
|
13
13
|
function normalizeName(name) {
|
|
14
14
|
if (!names.has(name)) {
|
|
15
|
-
names.set(
|
|
15
|
+
names.set(
|
|
16
|
+
name,
|
|
17
|
+
name.replace(/[A-Z]([A-Z].*)/g, (c) => c.toLowerCase()).replace(/[^a-zA-Z\d\s:]/g, " ").replace(/(^\w|\s+\w)/g, (c) => c.trim().toUpperCase()).trim()
|
|
18
|
+
);
|
|
16
19
|
}
|
|
17
20
|
return names.get(name);
|
|
18
21
|
}
|
|
@@ -40,7 +43,12 @@ function getEventMethodsByName(that, name = "") {
|
|
|
40
43
|
const key = regex.toString();
|
|
41
44
|
let methods = that.__methodsCache.get(key);
|
|
42
45
|
if (!methods) {
|
|
43
|
-
methods = Array.from(
|
|
46
|
+
methods = Array.from(
|
|
47
|
+
getAllProperties(that.__base, [], (method) => regex.test(method)).reduce(
|
|
48
|
+
(set, [method]) => set.add(method),
|
|
49
|
+
/* @__PURE__ */ new Set()
|
|
50
|
+
)
|
|
51
|
+
);
|
|
44
52
|
that.__methodsCache.set(key, methods);
|
|
45
53
|
}
|
|
46
54
|
return methods;
|
|
@@ -104,7 +112,9 @@ class EventsManager extends AbstractManager {
|
|
|
104
112
|
const childrenManager = this.__base.$children;
|
|
105
113
|
const { name, child: resolvedChild } = childrenManager.registeredNames.map((childName) => ({
|
|
106
114
|
name: childName,
|
|
107
|
-
child: childrenManager[childName].find(
|
|
115
|
+
child: childrenManager[childName].find(
|
|
116
|
+
(instance) => instance === event.currentTarget || instance.$el === event.currentTarget
|
|
117
|
+
)
|
|
108
118
|
})).find(({ child }) => child);
|
|
109
119
|
const normalizedChildName = normalizeName(name);
|
|
110
120
|
const normalizedEventName = normalizeName(event.type);
|
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
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
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
var __publicField = (obj, key, value) => {
|
|
23
26
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -56,14 +59,18 @@ function __register(that, name, config) {
|
|
|
56
59
|
var _a;
|
|
57
60
|
if (!types.has(config.type)) {
|
|
58
61
|
if (import_utils.isDev) {
|
|
59
|
-
throw new Error(
|
|
62
|
+
throw new Error(
|
|
63
|
+
`The "${name}" option has an invalid type. The allowed types are: String, Number, Boolean, Array and Object.`
|
|
64
|
+
);
|
|
60
65
|
}
|
|
61
66
|
return;
|
|
62
67
|
}
|
|
63
68
|
config.default = (_a = config.default) != null ? _a : __defaultValues[config.type.name];
|
|
64
69
|
if ((config.type === Array || config.type === Object) && !(0, import_utils.isFunction)(config.default)) {
|
|
65
70
|
if (import_utils.isDev) {
|
|
66
|
-
throw new Error(
|
|
71
|
+
throw new Error(
|
|
72
|
+
`The default value for options of type "${config.type.name}" must be returned by a function.`
|
|
73
|
+
);
|
|
67
74
|
}
|
|
68
75
|
return;
|
|
69
76
|
}
|
|
@@ -97,7 +104,11 @@ var OptionsManager = class extends import_AbstractManager.default {
|
|
|
97
104
|
default: (_b = this.__config.log) != null ? _b : false
|
|
98
105
|
};
|
|
99
106
|
Object.entries(schema).forEach(([name, config]) => {
|
|
100
|
-
__register(
|
|
107
|
+
__register(
|
|
108
|
+
this,
|
|
109
|
+
name,
|
|
110
|
+
types.has(config) ? { type: config } : config
|
|
111
|
+
);
|
|
101
112
|
});
|
|
102
113
|
}
|
|
103
114
|
get(name, config) {
|
|
@@ -135,7 +146,9 @@ var OptionsManager = class extends import_AbstractManager.default {
|
|
|
135
146
|
if (value.constructor.name !== type.name) {
|
|
136
147
|
if (import_utils.isDev) {
|
|
137
148
|
const val = (0, import_utils.isArray)(value) || (0, import_utils.isObject)(value) ? JSON.stringify(value) : value;
|
|
138
|
-
throw new TypeError(
|
|
149
|
+
throw new TypeError(
|
|
150
|
+
`The "${val}" value for the "${name}" option must be of type "${type.name}"`
|
|
151
|
+
);
|
|
139
152
|
}
|
|
140
153
|
return;
|
|
141
154
|
}
|
|
@@ -79,7 +79,7 @@ export type BooleanOption = {
|
|
|
79
79
|
};
|
|
80
80
|
export type OptionObject = ArrayOption | ObjectOption | StringOption | NumberOption | BooleanOption;
|
|
81
81
|
export type OptionsSchema = {
|
|
82
|
-
[name: string]:
|
|
82
|
+
[name: string]: OptionObject | OptionType;
|
|
83
83
|
};
|
|
84
84
|
export type OptionsInterface = {
|
|
85
85
|
[optionName: string]: any;
|
|
@@ -29,14 +29,18 @@ function __register(that, name, config) {
|
|
|
29
29
|
var _a;
|
|
30
30
|
if (!types.has(config.type)) {
|
|
31
31
|
if (isDev) {
|
|
32
|
-
throw new Error(
|
|
32
|
+
throw new Error(
|
|
33
|
+
`The "${name}" option has an invalid type. The allowed types are: String, Number, Boolean, Array and Object.`
|
|
34
|
+
);
|
|
33
35
|
}
|
|
34
36
|
return;
|
|
35
37
|
}
|
|
36
38
|
config.default = (_a = config.default) != null ? _a : __defaultValues[config.type.name];
|
|
37
39
|
if ((config.type === Array || config.type === Object) && !isFunction(config.default)) {
|
|
38
40
|
if (isDev) {
|
|
39
|
-
throw new Error(
|
|
41
|
+
throw new Error(
|
|
42
|
+
`The default value for options of type "${config.type.name}" must be returned by a function.`
|
|
43
|
+
);
|
|
40
44
|
}
|
|
41
45
|
return;
|
|
42
46
|
}
|
|
@@ -70,7 +74,11 @@ class OptionsManager extends AbstractManager {
|
|
|
70
74
|
default: (_b = this.__config.log) != null ? _b : false
|
|
71
75
|
};
|
|
72
76
|
Object.entries(schema).forEach(([name, config]) => {
|
|
73
|
-
__register(
|
|
77
|
+
__register(
|
|
78
|
+
this,
|
|
79
|
+
name,
|
|
80
|
+
types.has(config) ? { type: config } : config
|
|
81
|
+
);
|
|
74
82
|
});
|
|
75
83
|
}
|
|
76
84
|
get(name, config) {
|
|
@@ -108,7 +116,9 @@ class OptionsManager extends AbstractManager {
|
|
|
108
116
|
if (value.constructor.name !== type.name) {
|
|
109
117
|
if (isDev) {
|
|
110
118
|
const val = isArray(value) || isObject(value) ? JSON.stringify(value) : value;
|
|
111
|
-
throw new TypeError(
|
|
119
|
+
throw new TypeError(
|
|
120
|
+
`The "${val}" value for the "${name}" option must be of type "${type.name}"`
|
|
121
|
+
);
|
|
112
122
|
}
|
|
113
123
|
return;
|
|
114
124
|
}
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// packages/js-toolkit/Base/managers/RefsManager.js
|
|
@@ -41,13 +44,23 @@ function __filterRefsBelongingToInstance(that, ref) {
|
|
|
41
44
|
function __register(that, refName) {
|
|
42
45
|
const isMultiple = refName.endsWith("[]");
|
|
43
46
|
const propName = normalizeRefName(refName);
|
|
44
|
-
const refs = Array.from(that.__element.querySelectorAll(`[data-ref="${refName}"]`)).filter(
|
|
47
|
+
const refs = Array.from(that.__element.querySelectorAll(`[data-ref="${refName}"]`)).filter(
|
|
48
|
+
(ref) => __filterRefsBelongingToInstance(that, ref)
|
|
49
|
+
);
|
|
45
50
|
if (import_utils.isDev && !isMultiple && refs.length > 1) {
|
|
46
|
-
console.warn(
|
|
51
|
+
console.warn(
|
|
52
|
+
`[${that.__base.$options.name}]`,
|
|
53
|
+
`The "${refName}" ref has been found multiple times.`,
|
|
54
|
+
"Did you forgot to add the `[]` suffix to its name?"
|
|
55
|
+
);
|
|
47
56
|
}
|
|
48
57
|
if (!isMultiple && refs.length <= 1 && !(0, import_utils.isDefined)(refs[0])) {
|
|
49
58
|
if (import_utils.isDev) {
|
|
50
|
-
console.warn(
|
|
59
|
+
console.warn(
|
|
60
|
+
`[${that.__base.$options.name}]`,
|
|
61
|
+
`The "${refName}" ref is missing.`,
|
|
62
|
+
`Is there an \`[data-ref="${refName}"]\` element in the component's scope?`
|
|
63
|
+
);
|
|
51
64
|
}
|
|
52
65
|
return;
|
|
53
66
|
}
|
|
@@ -13,13 +13,23 @@ function __filterRefsBelongingToInstance(that, ref) {
|
|
|
13
13
|
function __register(that, refName) {
|
|
14
14
|
const isMultiple = refName.endsWith("[]");
|
|
15
15
|
const propName = normalizeRefName(refName);
|
|
16
|
-
const refs = Array.from(that.__element.querySelectorAll(`[data-ref="${refName}"]`)).filter(
|
|
16
|
+
const refs = Array.from(that.__element.querySelectorAll(`[data-ref="${refName}"]`)).filter(
|
|
17
|
+
(ref) => __filterRefsBelongingToInstance(that, ref)
|
|
18
|
+
);
|
|
17
19
|
if (isDev && !isMultiple && refs.length > 1) {
|
|
18
|
-
console.warn(
|
|
20
|
+
console.warn(
|
|
21
|
+
`[${that.__base.$options.name}]`,
|
|
22
|
+
`The "${refName}" ref has been found multiple times.`,
|
|
23
|
+
"Did you forgot to add the `[]` suffix to its name?"
|
|
24
|
+
);
|
|
19
25
|
}
|
|
20
26
|
if (!isMultiple && refs.length <= 1 && !isDefined(refs[0])) {
|
|
21
27
|
if (isDev) {
|
|
22
|
-
console.warn(
|
|
28
|
+
console.warn(
|
|
29
|
+
`[${that.__base.$options.name}]`,
|
|
30
|
+
`The "${refName}" ref is missing.`,
|
|
31
|
+
`Is there an \`[data-ref="${refName}"]\` element in the component's scope?`
|
|
32
|
+
);
|
|
23
33
|
}
|
|
24
34
|
return;
|
|
25
35
|
}
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// packages/js-toolkit/Base/managers/ResponsiveOptionsManager.js
|
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
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
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
var __publicField = (obj, key, value) => {
|
|
23
26
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -84,12 +87,16 @@ var ServicesManager = class extends import_AbstractManager.default {
|
|
|
84
87
|
return this.disable.bind(this, service);
|
|
85
88
|
}
|
|
86
89
|
enableAll() {
|
|
87
|
-
return Object.keys(this.__services).map(
|
|
90
|
+
return Object.keys(this.__services).map(
|
|
91
|
+
(serviceName) => this.enable(serviceName)
|
|
92
|
+
);
|
|
88
93
|
}
|
|
89
94
|
disableAll() {
|
|
90
|
-
Object.keys(this.__services).forEach(
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
Object.keys(this.__services).forEach(
|
|
96
|
+
(serviceName) => {
|
|
97
|
+
this.disable(serviceName);
|
|
98
|
+
}
|
|
99
|
+
);
|
|
93
100
|
}
|
|
94
101
|
disable(service) {
|
|
95
102
|
if (!this.__services[service]) {
|