@studiometa/js-toolkit 2.3.0 → 2.4.2
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 +51 -43
- package/Base/index.d.ts +23 -18
- package/Base/index.js +70 -59
- package/Base/managers/AbstractManager.cjs +23 -13
- package/Base/managers/AbstractManager.d.ts +3 -3
- package/Base/managers/AbstractManager.js +24 -13
- package/Base/managers/ChildrenManager.cjs +21 -5
- package/Base/managers/ChildrenManager.d.ts +1 -1
- package/Base/managers/ChildrenManager.js +18 -4
- package/Base/managers/EventsManager.cjs +62 -44
- package/Base/managers/EventsManager.d.ts +3 -3
- package/Base/managers/EventsManager.js +59 -43
- package/Base/managers/OptionsManager.cjs +32 -12
- package/Base/managers/OptionsManager.d.ts +2 -2
- package/Base/managers/OptionsManager.js +29 -11
- package/Base/managers/RefsManager.cjs +19 -5
- package/Base/managers/RefsManager.js +15 -4
- package/Base/managers/ResponsiveOptionsManager.cjs +4 -1
- package/Base/managers/ServicesManager.cjs +21 -6
- package/Base/managers/ServicesManager.d.ts +1 -1
- package/Base/managers/ServicesManager.js +18 -5
- package/Base/utils.cjs +5 -1
- package/Base/utils.d.ts +2 -2
- package/Base/utils.js +5 -1
- package/README.md +3 -3
- package/decorators/index.cjs +4 -1
- package/decorators/withBreakpointManager.cjs +4 -1
- package/decorators/withBreakpointManager.d.ts +1 -1
- package/decorators/withBreakpointObserver.cjs +26 -14
- package/decorators/withBreakpointObserver.d.ts +1 -1
- package/decorators/withBreakpointObserver.js +23 -13
- package/decorators/withDrag.cjs +19 -8
- package/decorators/withDrag.d.ts +2 -4
- package/decorators/withDrag.js +16 -7
- package/decorators/withExtraConfig.cjs +12 -4
- package/decorators/withExtraConfig.js +9 -3
- package/decorators/withFreezedOptions.cjs +9 -1
- package/decorators/withFreezedOptions.js +10 -1
- package/decorators/withIntersectionObserver.cjs +25 -17
- package/decorators/withIntersectionObserver.d.ts +1 -1
- package/decorators/withIntersectionObserver.js +26 -17
- package/decorators/withMountWhenInView.cjs +30 -22
- package/decorators/withMountWhenInView.d.ts +1 -1
- package/decorators/withMountWhenInView.js +31 -22
- package/decorators/withResponsiveOptions.cjs +4 -1
- package/decorators/withScrolledInView.cjs +99 -48
- package/decorators/withScrolledInView.d.ts +27 -6
- package/decorators/withScrolledInView.js +96 -47
- package/decorators/withVue2.cjs +15 -10
- package/decorators/withVue2.d.ts +1 -1
- package/decorators/withVue2.js +16 -10
- package/helpers/getDirectChildren.cjs +46 -0
- package/helpers/getDirectChildren.d.ts +24 -0
- package/helpers/getDirectChildren.js +24 -0
- package/helpers/getInstanceFromElement.cjs +2 -1
- package/helpers/getInstanceFromElement.js +2 -1
- package/helpers/importOnInteraction.cjs +1 -1
- package/helpers/importOnInteraction.d.ts +2 -2
- package/helpers/importOnInteraction.js +1 -1
- package/helpers/importWhenIdle.cjs +10 -6
- package/helpers/importWhenIdle.js +10 -6
- package/helpers/importWhenVisible.cjs +1 -1
- package/helpers/importWhenVisible.d.ts +2 -2
- package/helpers/importWhenVisible.js +1 -1
- package/helpers/index.cjs +6 -1
- package/helpers/index.d.ts +1 -0
- package/helpers/index.js +1 -0
- package/index.cjs +4 -1
- 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 +5 -2
- package/services/key.js +1 -1
- package/services/pointer.cjs +3 -2
- package/services/pointer.js +3 -2
- package/services/resize.cjs +4 -1
- package/services/scroll.cjs +4 -1
- package/utils/collide/index.cjs +4 -1
- package/utils/css/animate.cjs +27 -12
- package/utils/css/animate.js +23 -11
- package/utils/css/index.cjs +4 -1
- package/utils/css/matrix.cjs +2 -1
- package/utils/css/matrix.js +2 -1
- package/utils/css/transform.cjs +2 -1
- package/utils/css/transform.js +2 -1
- package/utils/css/transition.cjs +11 -6
- package/utils/css/transition.js +8 -5
- 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 +6 -2
- package/utils/tween.js +2 -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,16 +71,50 @@ 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
|
}
|
|
75
80
|
var Base = class extends EventTarget {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
constructor(element) {
|
|
82
|
+
super();
|
|
83
|
+
__publicField(this, "$parent", null);
|
|
84
|
+
__publicField(this, "$id");
|
|
85
|
+
__publicField(this, "$el");
|
|
86
|
+
__publicField(this, "$isMounted", false);
|
|
87
|
+
__publicField(this, "__eventHandlers", /* @__PURE__ */ new Map());
|
|
88
|
+
__publicField(this, "__services");
|
|
89
|
+
__publicField(this, "__refs");
|
|
90
|
+
__publicField(this, "__options");
|
|
91
|
+
__publicField(this, "__children");
|
|
92
|
+
__publicField(this, "__events");
|
|
93
|
+
if (!element) {
|
|
94
|
+
if (import_utils2.isDev) {
|
|
95
|
+
throw new Error("The root element must be defined.");
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const { __config } = this;
|
|
100
|
+
if (__config.name === "Base") {
|
|
101
|
+
if (import_utils2.isDev) {
|
|
102
|
+
throw new Error("The `config.name` property is required.");
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
this.$id = `${__config.name}-${id}`;
|
|
107
|
+
id += 1;
|
|
108
|
+
this.$el = element;
|
|
109
|
+
if (!this.$el.__base__) {
|
|
110
|
+
this.$el.__base__ = /* @__PURE__ */ new WeakMap();
|
|
111
|
+
}
|
|
112
|
+
this.$el.__base__.set(this.__ctor, this);
|
|
113
|
+
createAndTestManagers(this);
|
|
114
|
+
if (import_utils2.isDev) {
|
|
115
|
+
this.__debug("constructor", this);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
81
118
|
get $root() {
|
|
82
119
|
if (!this.$parent) {
|
|
83
120
|
return this;
|
|
@@ -93,6 +130,7 @@ var Base = class extends EventTarget {
|
|
|
93
130
|
return root;
|
|
94
131
|
}
|
|
95
132
|
get __config() {
|
|
133
|
+
var _a, _b, _c;
|
|
96
134
|
let proto = Object.getPrototypeOf(this);
|
|
97
135
|
let { config } = proto.constructor;
|
|
98
136
|
while (proto.constructor.config && proto.constructor.$isBase) {
|
|
@@ -105,28 +143,23 @@ var Base = class extends EventTarget {
|
|
|
105
143
|
}
|
|
106
144
|
proto = Object.getPrototypeOf(proto);
|
|
107
145
|
}
|
|
108
|
-
config.options = config.options
|
|
109
|
-
config.refs = config.refs
|
|
110
|
-
config.components = config.components
|
|
146
|
+
config.options = (_a = config.options) != null ? _a : {};
|
|
147
|
+
config.refs = (_b = config.refs) != null ? _b : [];
|
|
148
|
+
config.components = (_c = config.components) != null ? _c : {};
|
|
111
149
|
return config;
|
|
112
150
|
}
|
|
113
|
-
__services;
|
|
114
151
|
get $services() {
|
|
115
152
|
return this.__services;
|
|
116
153
|
}
|
|
117
|
-
__refs;
|
|
118
154
|
get $refs() {
|
|
119
155
|
return this.__refs;
|
|
120
156
|
}
|
|
121
|
-
__options;
|
|
122
157
|
get $options() {
|
|
123
158
|
return this.__options;
|
|
124
159
|
}
|
|
125
|
-
__children;
|
|
126
160
|
get $children() {
|
|
127
161
|
return this.__children;
|
|
128
162
|
}
|
|
129
|
-
__events;
|
|
130
163
|
get $log() {
|
|
131
164
|
return this.__options.log ? window.console.log.bind(window, `[${this.__config.name}]`) : import_utils2.noop;
|
|
132
165
|
}
|
|
@@ -159,33 +192,6 @@ var Base = class extends EventTarget {
|
|
|
159
192
|
const eventHandlers = this.__eventHandlers.get(event);
|
|
160
193
|
return eventHandlers && eventHandlers.size > 0;
|
|
161
194
|
}
|
|
162
|
-
constructor(element) {
|
|
163
|
-
super();
|
|
164
|
-
if (!element) {
|
|
165
|
-
if (import_utils2.isDev) {
|
|
166
|
-
throw new Error("The root element must be defined.");
|
|
167
|
-
}
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
const { __config } = this;
|
|
171
|
-
if (__config.name === "Base") {
|
|
172
|
-
if (import_utils2.isDev) {
|
|
173
|
-
throw new Error("The `config.name` property is required.");
|
|
174
|
-
}
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
this.$id = `${__config.name}-${id}`;
|
|
178
|
-
id += 1;
|
|
179
|
-
this.$el = element;
|
|
180
|
-
if (!this.$el.__base__) {
|
|
181
|
-
this.$el.__base__ = /* @__PURE__ */ new WeakMap();
|
|
182
|
-
}
|
|
183
|
-
this.$el.__base__.set(this.__ctor, this);
|
|
184
|
-
createAndTestManagers(this);
|
|
185
|
-
if (import_utils2.isDev) {
|
|
186
|
-
this.__debug("constructor", this);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
195
|
$mount() {
|
|
190
196
|
if (this.$isMounted) {
|
|
191
197
|
return this;
|
|
@@ -287,7 +293,9 @@ var Base = class extends EventTarget {
|
|
|
287
293
|
}
|
|
288
294
|
static $factory(nameOrSelector) {
|
|
289
295
|
if (import_utils2.isDev && !nameOrSelector) {
|
|
290
|
-
throw new Error(
|
|
296
|
+
throw new Error(
|
|
297
|
+
"The $factory method requires a component\u2019s name or selector to be specified."
|
|
298
|
+
);
|
|
291
299
|
}
|
|
292
300
|
return (0, import_utils.getComponentElements)(nameOrSelector).map((el) => new this(el).$mount());
|
|
293
301
|
}
|
package/Base/index.d.ts
CHANGED
|
@@ -28,8 +28,13 @@
|
|
|
28
28
|
*/
|
|
29
29
|
/**
|
|
30
30
|
* Base class.
|
|
31
|
+
* @template {{ $options: BaseOptions, $refs: BaseRefs, $children: BaseChildren }} BaseInterface
|
|
31
32
|
*/
|
|
32
|
-
export default class Base extends
|
|
33
|
+
export default class Base<BaseInterface extends {
|
|
34
|
+
$options: BaseOptions;
|
|
35
|
+
$refs: BaseRefs;
|
|
36
|
+
$children: BaseChildren;
|
|
37
|
+
}> extends EventTarget {
|
|
33
38
|
/**
|
|
34
39
|
* This is a Base instance.
|
|
35
40
|
* @type {boolean}
|
|
@@ -46,7 +51,7 @@ export default class Base extends EventTarget {
|
|
|
46
51
|
* @param {string} nameOrSelector The selector on which to mount each instance.
|
|
47
52
|
* @returns {Array<Base>} A list of the created instance.
|
|
48
53
|
*/
|
|
49
|
-
static $factory(nameOrSelector: string): Array<Base
|
|
54
|
+
static $factory(nameOrSelector: string): Array<Base<any>>;
|
|
50
55
|
/**
|
|
51
56
|
* Class constructor where all the magic takes place.
|
|
52
57
|
*
|
|
@@ -57,7 +62,7 @@ export default class Base extends EventTarget {
|
|
|
57
62
|
* The instance parent.
|
|
58
63
|
* @type {Base}
|
|
59
64
|
*/
|
|
60
|
-
$parent: Base
|
|
65
|
+
$parent: Base<any>;
|
|
61
66
|
/**
|
|
62
67
|
* The instance id.
|
|
63
68
|
* @type {string}
|
|
@@ -68,7 +73,7 @@ export default class Base extends EventTarget {
|
|
|
68
73
|
* @type {HTMLElement & { __base__?: WeakMap<BaseConstructor, Base | 'terminated'> }}
|
|
69
74
|
*/
|
|
70
75
|
$el: HTMLElement & {
|
|
71
|
-
__base__?: WeakMap<BaseConstructor, Base | 'terminated'>;
|
|
76
|
+
__base__?: WeakMap<BaseConstructor, Base<any> | 'terminated'>;
|
|
72
77
|
};
|
|
73
78
|
/**
|
|
74
79
|
* The state of the component.
|
|
@@ -86,7 +91,7 @@ export default class Base extends EventTarget {
|
|
|
86
91
|
* Get the root instance of the app.
|
|
87
92
|
* @returns {Base}
|
|
88
93
|
*/
|
|
89
|
-
get $root(): Base
|
|
94
|
+
get $root(): Base<any>;
|
|
90
95
|
/**
|
|
91
96
|
* Merge configuration with the parents' configurations.
|
|
92
97
|
*
|
|
@@ -104,32 +109,34 @@ export default class Base extends EventTarget {
|
|
|
104
109
|
*/
|
|
105
110
|
get $services(): ServicesManager;
|
|
106
111
|
/**
|
|
107
|
-
* @type {RefsManager}
|
|
112
|
+
* @type {RefsManager & { [key in keyof BaseInterface['$refs']]: BaseInterface['$refs'][key] }}
|
|
108
113
|
* @private
|
|
109
114
|
*/
|
|
110
115
|
private __refs;
|
|
111
116
|
/**
|
|
112
|
-
* @returns {RefsManager}
|
|
117
|
+
* @returns {RefsManager & { [key in keyof BaseInterface['$refs']]: BaseInterface['$refs'][key] }}
|
|
113
118
|
*/
|
|
114
|
-
get $refs(): RefsManager;
|
|
119
|
+
get $refs(): RefsManager & (BaseInterface["$refs"] extends infer T ? { [key in keyof T]: BaseInterface["$refs"][key]; } : never);
|
|
115
120
|
/**
|
|
116
|
-
* @type {BaseOptions}
|
|
121
|
+
* @type {BaseOptions & { [key in keyof BaseInterface['$options']]: BaseInterface['$options'][key] }}
|
|
117
122
|
* @private
|
|
118
123
|
*/
|
|
119
124
|
private __options;
|
|
120
125
|
/**
|
|
121
|
-
* @returns {BaseOptions}
|
|
126
|
+
* @returns {BaseOptions & { [key in keyof BaseInterface['$options']]: BaseInterface['$options'][key] }}
|
|
122
127
|
*/
|
|
123
|
-
get $options():
|
|
128
|
+
get $options(): OptionsManager & {
|
|
129
|
+
[name: string]: any;
|
|
130
|
+
} & (BaseInterface["$options"] extends infer T_1 ? { [key_1 in keyof T_1]: BaseInterface["$options"][key_1]; } : never);
|
|
124
131
|
/**
|
|
125
|
-
* @type {ChildrenManager}
|
|
132
|
+
* @type {ChildrenManager & { [key in keyof BaseInterface['$children']]: Array<BaseInterface['$children'][key]> }}
|
|
126
133
|
* @private
|
|
127
134
|
*/
|
|
128
135
|
private __children;
|
|
129
136
|
/**
|
|
130
|
-
* @returns {ChildrenManager}
|
|
137
|
+
* @returns {ChildrenManager & { [key in keyof BaseInterface['$children']]: Array<BaseInterface['$children'][key]> }}
|
|
131
138
|
*/
|
|
132
|
-
get $children(): ChildrenManager;
|
|
139
|
+
get $children(): ChildrenManager & (BaseInterface["$children"] extends infer T_2 ? { [key_2 in keyof T_2]: BaseInterface["$children"][key_2][]; } : never);
|
|
133
140
|
/**
|
|
134
141
|
* @type {EventsManager}
|
|
135
142
|
* @private
|
|
@@ -259,9 +266,7 @@ export type BaseOptions = OptionsManager & {
|
|
|
259
266
|
export type BaseRefs = {
|
|
260
267
|
[name: string]: HTMLElement | HTMLElement[];
|
|
261
268
|
};
|
|
262
|
-
export type BaseChildren =
|
|
263
|
-
[nameOrSelector: string]: Base[] | Promise<Base>[];
|
|
264
|
-
};
|
|
269
|
+
export type BaseChildren = BaseChildren;
|
|
265
270
|
export type BaseConfigComponents = {
|
|
266
271
|
[nameOrSelector: string]: typeof Base | BaseAsyncConstructor;
|
|
267
272
|
};
|
|
@@ -285,6 +290,6 @@ export type Managers = {
|
|
|
285
290
|
};
|
|
286
291
|
import ServicesManager from "./managers/ServicesManager.js";
|
|
287
292
|
import RefsManager from "./managers/RefsManager.js";
|
|
288
|
-
import ChildrenManager from "./managers/ChildrenManager.js";
|
|
289
293
|
import OptionsManager from "./managers/OptionsManager.js";
|
|
294
|
+
import ChildrenManager from "./managers/ChildrenManager.js";
|
|
290
295
|
import EventsManager from "./managers/EventsManager.js";
|
package/Base/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
1
7
|
import { getComponentElements, getEventTarget } from "./utils.js";
|
|
2
8
|
import ChildrenManager from "./managers/ChildrenManager.js";
|
|
3
9
|
import RefsManager from "./managers/RefsManager.js";
|
|
@@ -36,17 +42,50 @@ function createAndTestManagers(instance) {
|
|
|
36
42
|
].forEach(({ prop, constructorName, constructor }) => {
|
|
37
43
|
instance[prop] = new instance.__managers[constructorName](instance);
|
|
38
44
|
if (isDev && !(instance[prop] instanceof constructor)) {
|
|
39
|
-
throw new Error(
|
|
45
|
+
throw new Error(
|
|
46
|
+
`The \`$managers.${constructorName}\` must extend the \`${constructorName}\` class.`
|
|
47
|
+
);
|
|
40
48
|
}
|
|
41
49
|
});
|
|
42
50
|
}
|
|
43
51
|
class Base extends EventTarget {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
constructor(element) {
|
|
53
|
+
super();
|
|
54
|
+
__publicField(this, "$parent", null);
|
|
55
|
+
__publicField(this, "$id");
|
|
56
|
+
__publicField(this, "$el");
|
|
57
|
+
__publicField(this, "$isMounted", false);
|
|
58
|
+
__publicField(this, "__eventHandlers", /* @__PURE__ */ new Map());
|
|
59
|
+
__publicField(this, "__services");
|
|
60
|
+
__publicField(this, "__refs");
|
|
61
|
+
__publicField(this, "__options");
|
|
62
|
+
__publicField(this, "__children");
|
|
63
|
+
__publicField(this, "__events");
|
|
64
|
+
if (!element) {
|
|
65
|
+
if (isDev) {
|
|
66
|
+
throw new Error("The root element must be defined.");
|
|
67
|
+
}
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const { __config } = this;
|
|
71
|
+
if (__config.name === "Base") {
|
|
72
|
+
if (isDev) {
|
|
73
|
+
throw new Error("The `config.name` property is required.");
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.$id = `${__config.name}-${id}`;
|
|
78
|
+
id += 1;
|
|
79
|
+
this.$el = element;
|
|
80
|
+
if (!this.$el.__base__) {
|
|
81
|
+
this.$el.__base__ = /* @__PURE__ */ new WeakMap();
|
|
82
|
+
}
|
|
83
|
+
this.$el.__base__.set(this.__ctor, this);
|
|
84
|
+
createAndTestManagers(this);
|
|
85
|
+
if (isDev) {
|
|
86
|
+
this.__debug("constructor", this);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
50
89
|
get $root() {
|
|
51
90
|
if (!this.$parent) {
|
|
52
91
|
return this;
|
|
@@ -62,6 +101,7 @@ class Base extends EventTarget {
|
|
|
62
101
|
return root;
|
|
63
102
|
}
|
|
64
103
|
get __config() {
|
|
104
|
+
var _a, _b, _c;
|
|
65
105
|
let proto = Object.getPrototypeOf(this);
|
|
66
106
|
let { config } = proto.constructor;
|
|
67
107
|
while (proto.constructor.config && proto.constructor.$isBase) {
|
|
@@ -74,44 +114,23 @@ class Base extends EventTarget {
|
|
|
74
114
|
}
|
|
75
115
|
proto = Object.getPrototypeOf(proto);
|
|
76
116
|
}
|
|
77
|
-
config.options = config.options
|
|
78
|
-
config.refs = config.refs
|
|
79
|
-
config.components = config.components
|
|
117
|
+
config.options = (_a = config.options) != null ? _a : {};
|
|
118
|
+
config.refs = (_b = config.refs) != null ? _b : [];
|
|
119
|
+
config.components = (_c = config.components) != null ? _c : {};
|
|
80
120
|
return config;
|
|
81
121
|
}
|
|
82
|
-
static config = {
|
|
83
|
-
name: "Base",
|
|
84
|
-
emits: [
|
|
85
|
-
"before-mounted",
|
|
86
|
-
"mounted",
|
|
87
|
-
"updated",
|
|
88
|
-
"destroyed",
|
|
89
|
-
"terminated",
|
|
90
|
-
"ticked",
|
|
91
|
-
"scrolled",
|
|
92
|
-
"resized",
|
|
93
|
-
"moved",
|
|
94
|
-
"loaded",
|
|
95
|
-
"keyed"
|
|
96
|
-
]
|
|
97
|
-
};
|
|
98
|
-
__services;
|
|
99
122
|
get $services() {
|
|
100
123
|
return this.__services;
|
|
101
124
|
}
|
|
102
|
-
__refs;
|
|
103
125
|
get $refs() {
|
|
104
126
|
return this.__refs;
|
|
105
127
|
}
|
|
106
|
-
__options;
|
|
107
128
|
get $options() {
|
|
108
129
|
return this.__options;
|
|
109
130
|
}
|
|
110
|
-
__children;
|
|
111
131
|
get $children() {
|
|
112
132
|
return this.__children;
|
|
113
133
|
}
|
|
114
|
-
__events;
|
|
115
134
|
get $log() {
|
|
116
135
|
return this.__options.log ? window.console.log.bind(window, `[${this.__config.name}]`) : noop;
|
|
117
136
|
}
|
|
@@ -144,33 +163,6 @@ class Base extends EventTarget {
|
|
|
144
163
|
const eventHandlers = this.__eventHandlers.get(event);
|
|
145
164
|
return eventHandlers && eventHandlers.size > 0;
|
|
146
165
|
}
|
|
147
|
-
constructor(element) {
|
|
148
|
-
super();
|
|
149
|
-
if (!element) {
|
|
150
|
-
if (isDev) {
|
|
151
|
-
throw new Error("The root element must be defined.");
|
|
152
|
-
}
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
const { __config } = this;
|
|
156
|
-
if (__config.name === "Base") {
|
|
157
|
-
if (isDev) {
|
|
158
|
-
throw new Error("The `config.name` property is required.");
|
|
159
|
-
}
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
this.$id = `${__config.name}-${id}`;
|
|
163
|
-
id += 1;
|
|
164
|
-
this.$el = element;
|
|
165
|
-
if (!this.$el.__base__) {
|
|
166
|
-
this.$el.__base__ = /* @__PURE__ */ new WeakMap();
|
|
167
|
-
}
|
|
168
|
-
this.$el.__base__.set(this.__ctor, this);
|
|
169
|
-
createAndTestManagers(this);
|
|
170
|
-
if (isDev) {
|
|
171
|
-
this.__debug("constructor", this);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
166
|
$mount() {
|
|
175
167
|
if (this.$isMounted) {
|
|
176
168
|
return this;
|
|
@@ -272,11 +264,30 @@ class Base extends EventTarget {
|
|
|
272
264
|
}
|
|
273
265
|
static $factory(nameOrSelector) {
|
|
274
266
|
if (isDev && !nameOrSelector) {
|
|
275
|
-
throw new Error(
|
|
267
|
+
throw new Error(
|
|
268
|
+
"The $factory method requires a component\u2019s name or selector to be specified."
|
|
269
|
+
);
|
|
276
270
|
}
|
|
277
271
|
return getComponentElements(nameOrSelector).map((el) => new this(el).$mount());
|
|
278
272
|
}
|
|
279
273
|
}
|
|
274
|
+
__publicField(Base, "$isBase", true);
|
|
275
|
+
__publicField(Base, "config", {
|
|
276
|
+
name: "Base",
|
|
277
|
+
emits: [
|
|
278
|
+
"before-mounted",
|
|
279
|
+
"mounted",
|
|
280
|
+
"updated",
|
|
281
|
+
"destroyed",
|
|
282
|
+
"terminated",
|
|
283
|
+
"ticked",
|
|
284
|
+
"scrolled",
|
|
285
|
+
"resized",
|
|
286
|
+
"moved",
|
|
287
|
+
"loaded",
|
|
288
|
+
"keyed"
|
|
289
|
+
]
|
|
290
|
+
});
|
|
280
291
|
export {
|
|
281
292
|
Base as default
|
|
282
293
|
};
|
|
@@ -2,6 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
6
|
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -15,6 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
16
|
return to;
|
|
16
17
|
};
|
|
17
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __publicField = (obj, key, value) => {
|
|
20
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
18
23
|
|
|
19
24
|
// packages/js-toolkit/Base/managers/AbstractManager.js
|
|
20
25
|
var AbstractManager_exports = {};
|
|
@@ -23,7 +28,11 @@ __export(AbstractManager_exports, {
|
|
|
23
28
|
});
|
|
24
29
|
module.exports = __toCommonJS(AbstractManager_exports);
|
|
25
30
|
var AbstractManager = class {
|
|
26
|
-
|
|
31
|
+
constructor(base) {
|
|
32
|
+
__publicField(this, "__base");
|
|
33
|
+
this.__base = base;
|
|
34
|
+
this.__hideProperties(["__base"]);
|
|
35
|
+
}
|
|
27
36
|
get __element() {
|
|
28
37
|
return this.__base.$el;
|
|
29
38
|
}
|
|
@@ -33,19 +42,20 @@ var AbstractManager = class {
|
|
|
33
42
|
get __eventsManager() {
|
|
34
43
|
return this.__base.__events;
|
|
35
44
|
}
|
|
36
|
-
constructor(base) {
|
|
37
|
-
this.__base = base;
|
|
38
|
-
this.__hideProperties(["__base"]);
|
|
39
|
-
}
|
|
40
45
|
__hideProperties(properties) {
|
|
41
|
-
Object.defineProperties(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
+
);
|
|
49
59
|
}
|
|
50
60
|
};
|
|
51
61
|
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -12,11 +12,11 @@ export default class AbstractManager {
|
|
|
12
12
|
*
|
|
13
13
|
* @param {Base} base
|
|
14
14
|
*/
|
|
15
|
-
constructor(base:
|
|
15
|
+
constructor(base: import("../index.js").default<any>);
|
|
16
16
|
/**
|
|
17
17
|
* @type {Base}
|
|
18
18
|
*/
|
|
19
|
-
__base:
|
|
19
|
+
__base: import("../index.js").default<any>;
|
|
20
20
|
/**
|
|
21
21
|
* Get the base instance root element.
|
|
22
22
|
* @returns {HTMLElement}
|
|
@@ -39,6 +39,6 @@ export default class AbstractManager {
|
|
|
39
39
|
*/
|
|
40
40
|
__hideProperties(properties: string[]): void;
|
|
41
41
|
}
|
|
42
|
-
export type Base = import(
|
|
42
|
+
export type Base = import("../index.js").default<any>;
|
|
43
43
|
export type BaseConfig = import('../index.js').BaseConfig;
|
|
44
44
|
export type EventsManager = import('./EventsManager.js').default;
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
1
7
|
class AbstractManager {
|
|
2
|
-
|
|
8
|
+
constructor(base) {
|
|
9
|
+
__publicField(this, "__base");
|
|
10
|
+
this.__base = base;
|
|
11
|
+
this.__hideProperties(["__base"]);
|
|
12
|
+
}
|
|
3
13
|
get __element() {
|
|
4
14
|
return this.__base.$el;
|
|
5
15
|
}
|
|
@@ -9,19 +19,20 @@ class AbstractManager {
|
|
|
9
19
|
get __eventsManager() {
|
|
10
20
|
return this.__base.__events;
|
|
11
21
|
}
|
|
12
|
-
constructor(base) {
|
|
13
|
-
this.__base = base;
|
|
14
|
-
this.__hideProperties(["__base"]);
|
|
15
|
-
}
|
|
16
22
|
__hideProperties(properties) {
|
|
17
|
-
Object.defineProperties(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
+
);
|
|
25
36
|
}
|
|
26
37
|
}
|
|
27
38
|
export {
|
|
@@ -4,6 +4,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
9
|
for (var name in all)
|
|
9
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -16,8 +17,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
17
|
}
|
|
17
18
|
return to;
|
|
18
19
|
};
|
|
19
|
-
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
|
+
));
|
|
20
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var __publicField = (obj, key, value) => {
|
|
26
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
27
|
+
return value;
|
|
28
|
+
};
|
|
21
29
|
|
|
22
30
|
// packages/js-toolkit/Base/managers/ChildrenManager.js
|
|
23
31
|
var ChildrenManager_exports = {};
|
|
@@ -28,7 +36,9 @@ module.exports = __toCommonJS(ChildrenManager_exports);
|
|
|
28
36
|
var import_AbstractManager = __toESM(require("./AbstractManager.cjs"), 1);
|
|
29
37
|
var import_utils = require("../utils.cjs");
|
|
30
38
|
function __getChild(that, el, ComponentClass, name) {
|
|
31
|
-
const asyncComponentPromise = that.__asyncComponentPromises.get(
|
|
39
|
+
const asyncComponentPromise = that.__asyncComponentPromises.get(
|
|
40
|
+
ComponentClass
|
|
41
|
+
);
|
|
32
42
|
if ("$isBase" in ComponentClass || asyncComponentPromise && asyncComponentPromise.status === "resolved") {
|
|
33
43
|
let ctor = ComponentClass;
|
|
34
44
|
if (asyncComponentPromise) {
|
|
@@ -50,7 +60,8 @@ function __getChild(that, el, ComponentClass, name) {
|
|
|
50
60
|
});
|
|
51
61
|
}
|
|
52
62
|
return promise.then((module2) => {
|
|
53
|
-
|
|
63
|
+
var _a;
|
|
64
|
+
const ctor = (_a = module2.default) != null ? _a : module2;
|
|
54
65
|
that.__asyncComponentPromises.set(ComponentClass, {
|
|
55
66
|
promise,
|
|
56
67
|
status: "resolved",
|
|
@@ -96,12 +107,17 @@ function __triggerHookForAll(that, hook) {
|
|
|
96
107
|
});
|
|
97
108
|
}
|
|
98
109
|
var ChildrenManager = class extends import_AbstractManager.default {
|
|
99
|
-
|
|
110
|
+
constructor() {
|
|
111
|
+
super(...arguments);
|
|
112
|
+
__publicField(this, "__asyncComponentPromises", /* @__PURE__ */ new WeakMap());
|
|
113
|
+
}
|
|
100
114
|
get registeredNames() {
|
|
101
115
|
return Object.keys(this).filter((key) => !key.startsWith("__"));
|
|
102
116
|
}
|
|
103
117
|
registerAll() {
|
|
104
|
-
Object.entries(this.__config.components).forEach(
|
|
118
|
+
Object.entries(this.__config.components).forEach(
|
|
119
|
+
([name, component]) => __register(this, name, component)
|
|
120
|
+
);
|
|
105
121
|
}
|
|
106
122
|
mountAll() {
|
|
107
123
|
__triggerHookForAll(this, "$mount");
|
|
@@ -34,7 +34,7 @@ export default class ChildrenManager extends AbstractManager {
|
|
|
34
34
|
*/
|
|
35
35
|
destroyAll(): void;
|
|
36
36
|
}
|
|
37
|
-
export type Base = import(
|
|
37
|
+
export type Base = import("../index.js").default<any>;
|
|
38
38
|
export type BaseConstructor = import('../index.js').BaseConstructor;
|
|
39
39
|
export type BaseAsyncConstructor = import('../index.js').BaseAsyncConstructor;
|
|
40
40
|
export type BaseConfigComponents = import('../index.js').BaseConfigComponents;
|