@studiometa/js-toolkit 2.2.1 → 2.3.0

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.
Files changed (131) hide show
  1. package/Base/index.cjs +60 -69
  2. package/Base/index.d.ts +0 -8
  3. package/Base/index.js +67 -82
  4. package/Base/managers/AbstractManager.cjs +5 -10
  5. package/Base/managers/AbstractManager.js +5 -11
  6. package/Base/managers/ChildrenManager.cjs +2 -11
  7. package/Base/managers/ChildrenManager.js +2 -12
  8. package/Base/managers/EventsManager.cjs +61 -67
  9. package/Base/managers/EventsManager.js +61 -68
  10. package/Base/managers/OptionsManager.cjs +26 -27
  11. package/Base/managers/OptionsManager.js +26 -28
  12. package/Base/managers/RefsManager.cjs +9 -7
  13. package/Base/managers/RefsManager.js +9 -7
  14. package/Base/managers/ResponsiveOptionsManager.cjs +4 -1
  15. package/Base/managers/ResponsiveOptionsManager.js +4 -1
  16. package/Base/managers/ServicesManager.cjs +10 -16
  17. package/Base/managers/ServicesManager.js +10 -17
  18. package/Base/utils.cjs +22 -4
  19. package/Base/utils.d.ts +25 -8
  20. package/Base/utils.js +22 -4
  21. package/decorators/withBreakpointManager.cjs +15 -5
  22. package/decorators/withBreakpointManager.js +15 -5
  23. package/decorators/withBreakpointObserver.cjs +19 -18
  24. package/decorators/withBreakpointObserver.js +19 -19
  25. package/decorators/withDrag.cjs +6 -11
  26. package/decorators/withDrag.js +6 -12
  27. package/decorators/withExtraConfig.cjs +3 -8
  28. package/decorators/withExtraConfig.js +3 -9
  29. package/decorators/withFreezedOptions.cjs +1 -9
  30. package/decorators/withFreezedOptions.js +1 -10
  31. package/decorators/withIntersectionObserver.cjs +11 -16
  32. package/decorators/withIntersectionObserver.js +11 -17
  33. package/decorators/withMountWhenInView.cjs +12 -17
  34. package/decorators/withMountWhenInView.js +12 -18
  35. package/decorators/withScrolledInView.cjs +30 -35
  36. package/decorators/withScrolledInView.js +30 -36
  37. package/decorators/withVue2.cjs +20 -18
  38. package/decorators/withVue2.js +20 -19
  39. package/helpers/getInstanceFromElement.cjs +1 -2
  40. package/helpers/getInstanceFromElement.js +1 -2
  41. package/helpers/importOnInteraction.cjs +3 -2
  42. package/helpers/importOnInteraction.js +3 -2
  43. package/helpers/importWhenIdle.cjs +2 -3
  44. package/helpers/importWhenIdle.js +2 -3
  45. package/helpers/importWhenVisible.cjs +3 -2
  46. package/helpers/importWhenVisible.js +3 -2
  47. package/helpers/utils.cjs +3 -2
  48. package/helpers/utils.js +3 -2
  49. package/package.json +4 -1
  50. package/services/drag.cjs +126 -148
  51. package/services/drag.d.ts +10 -10
  52. package/services/drag.js +125 -148
  53. package/services/index.cjs +3 -1
  54. package/services/index.d.ts +1 -0
  55. package/services/index.js +3 -1
  56. package/services/key.cjs +48 -63
  57. package/services/key.d.ts +0 -8
  58. package/services/key.js +47 -63
  59. package/services/load.cjs +24 -40
  60. package/services/load.d.ts +0 -8
  61. package/services/load.js +23 -37
  62. package/services/pointer.cjs +72 -103
  63. package/services/pointer.d.ts +1 -9
  64. package/services/pointer.js +71 -100
  65. package/services/raf.cjs +38 -58
  66. package/services/raf.d.ts +0 -8
  67. package/services/raf.js +37 -55
  68. package/services/resize.cjs +59 -68
  69. package/services/resize.d.ts +0 -7
  70. package/services/resize.js +58 -68
  71. package/services/scroll.cjs +49 -71
  72. package/services/scroll.js +48 -71
  73. package/services/service.cjs +68 -0
  74. package/services/service.d.ts +18 -0
  75. package/services/service.js +46 -0
  76. package/utils/css/animate.cjs +33 -102
  77. package/utils/css/animate.d.ts +4 -13
  78. package/utils/css/animate.js +31 -100
  79. package/utils/css/classes.cjs +2 -1
  80. package/utils/css/classes.js +2 -1
  81. package/utils/css/matrix.cjs +1 -2
  82. package/utils/css/matrix.js +1 -2
  83. package/utils/css/styles.cjs +2 -5
  84. package/utils/css/styles.js +1 -1
  85. package/utils/css/transform.cjs +14 -18
  86. package/utils/css/transform.js +2 -3
  87. package/utils/css/transition.cjs +7 -10
  88. package/utils/css/transition.js +7 -11
  89. package/utils/focusTrap.cjs +2 -1
  90. package/utils/focusTrap.js +2 -1
  91. package/utils/{isFunction.cjs → has.cjs} +7 -7
  92. package/utils/has.d.ts +6 -0
  93. package/utils/has.js +6 -0
  94. package/utils/history.cjs +5 -7
  95. package/utils/history.js +4 -3
  96. package/utils/index.cjs +6 -5
  97. package/utils/index.d.ts +4 -2
  98. package/utils/index.js +6 -5
  99. package/utils/{object/isObject.cjs → is.cjs} +20 -8
  100. package/utils/is.d.ts +8 -0
  101. package/utils/is.js +18 -0
  102. package/utils/math/inertiaFinalValue.cjs +5 -3
  103. package/utils/math/inertiaFinalValue.js +2 -3
  104. package/utils/nextFrame.cjs +5 -3
  105. package/utils/nextFrame.js +5 -3
  106. package/utils/nextMicrotask.cjs +2 -1
  107. package/utils/nextMicrotask.js +2 -1
  108. package/utils/nextTick.cjs +2 -1
  109. package/utils/nextTick.js +2 -1
  110. package/utils/{isDefined.cjs → noop.cjs} +10 -7
  111. package/utils/noop.d.ts +12 -0
  112. package/utils/noop.js +9 -0
  113. package/utils/object/autoBind.cjs +3 -2
  114. package/utils/object/autoBind.js +3 -2
  115. package/utils/object/getAllProperties.cjs +2 -1
  116. package/utils/object/getAllProperties.js +2 -1
  117. package/utils/object/index.cjs +1 -3
  118. package/utils/object/index.d.ts +0 -1
  119. package/utils/object/index.js +1 -3
  120. package/utils/tween.cjs +113 -0
  121. package/utils/tween.d.ts +25 -0
  122. package/utils/tween.js +88 -0
  123. package/services/Service.cjs +0 -76
  124. package/services/Service.d.ts +0 -76
  125. package/services/Service.js +0 -55
  126. package/utils/isDefined.d.ts +0 -7
  127. package/utils/isDefined.js +0 -6
  128. package/utils/isFunction.d.ts +0 -7
  129. package/utils/isFunction.js +0 -6
  130. package/utils/object/isObject.d.ts +0 -7
  131. package/utils/object/isObject.js +0 -6
package/Base/index.cjs CHANGED
@@ -36,10 +36,8 @@ var import_RefsManager = __toESM(require("./managers/RefsManager.cjs"), 1);
36
36
  var import_ServicesManager = __toESM(require("./managers/ServicesManager.cjs"), 1);
37
37
  var import_EventsManager = __toESM(require("./managers/EventsManager.cjs"), 1);
38
38
  var import_OptionsManager = __toESM(require("./managers/OptionsManager.cjs"), 1);
39
+ var import_utils2 = require("../utils/index.cjs");
39
40
  var id = 0;
40
- var isDev = typeof __DEV__ !== "undefined" && __DEV__;
41
- function noop() {
42
- }
43
41
  function createAndTestManagers(instance) {
44
42
  [
45
43
  {
@@ -69,43 +67,17 @@ function createAndTestManagers(instance) {
69
67
  }
70
68
  ].forEach(({ prop, constructorName, constructor }) => {
71
69
  instance[prop] = new instance.__managers[constructorName](instance);
72
- if (!(instance[prop] instanceof constructor)) {
70
+ if (import_utils2.isDev && !(instance[prop] instanceof constructor)) {
73
71
  throw new Error(`The \`$managers.${constructorName}\` must extend the \`${constructorName}\` class.`);
74
72
  }
75
73
  });
76
74
  }
77
75
  var Base = class extends EventTarget {
78
- constructor(element) {
79
- super();
80
- __publicField(this, "$parent", null);
81
- __publicField(this, "$id");
82
- __publicField(this, "$el");
83
- __publicField(this, "$isMounted", false);
84
- __publicField(this, "__eventHandlers", /* @__PURE__ */ new Map());
85
- __publicField(this, "__services");
86
- __publicField(this, "__refs");
87
- __publicField(this, "__options");
88
- __publicField(this, "__children");
89
- __publicField(this, "__events");
90
- if (!element) {
91
- throw new Error("The root element must be defined.");
92
- }
93
- const { __config } = this;
94
- if (__config.name === "Base") {
95
- throw new Error("The `config.name` property is required.");
96
- }
97
- this.$id = `${__config.name}-${id}`;
98
- id += 1;
99
- this.$el = element;
100
- if (!this.$el.__base__) {
101
- this.$el.__base__ = /* @__PURE__ */ new WeakMap();
102
- }
103
- this.$el.__base__.set(this.__ctor, this);
104
- createAndTestManagers(this);
105
- if (isDev) {
106
- this.__debug("constructor", this);
107
- }
108
- }
76
+ $parent = null;
77
+ $id;
78
+ $el;
79
+ $isMounted = false;
80
+ __eventHandlers = /* @__PURE__ */ new Map();
109
81
  get $root() {
110
82
  if (!this.$parent) {
111
83
  return this;
@@ -121,7 +93,6 @@ var Base = class extends EventTarget {
121
93
  return root;
122
94
  }
123
95
  get __config() {
124
- var _a, _b, _c;
125
96
  let proto = Object.getPrototypeOf(this);
126
97
  let { config } = proto.constructor;
127
98
  while (proto.constructor.config && proto.constructor.$isBase) {
@@ -134,28 +105,33 @@ var Base = class extends EventTarget {
134
105
  }
135
106
  proto = Object.getPrototypeOf(proto);
136
107
  }
137
- config.options = (_a = config.options) != null ? _a : {};
138
- config.refs = (_b = config.refs) != null ? _b : [];
139
- config.components = (_c = config.components) != null ? _c : {};
108
+ config.options = config.options ?? {};
109
+ config.refs = config.refs ?? [];
110
+ config.components = config.components ?? {};
140
111
  return config;
141
112
  }
113
+ __services;
142
114
  get $services() {
143
115
  return this.__services;
144
116
  }
117
+ __refs;
145
118
  get $refs() {
146
119
  return this.__refs;
147
120
  }
121
+ __options;
148
122
  get $options() {
149
123
  return this.__options;
150
124
  }
125
+ __children;
151
126
  get $children() {
152
127
  return this.__children;
153
128
  }
129
+ __events;
154
130
  get $log() {
155
- return this.__options.log ? window.console.log.bind(window, `[${this.__config.name}]`) : noop;
131
+ return this.__options.log ? window.console.log.bind(window, `[${this.__config.name}]`) : import_utils2.noop;
156
132
  }
157
133
  get __debug() {
158
- return isDev && this.__options.debug ? window.console.log.bind(window, `[debug] [${this.$id}]`) : noop;
134
+ return import_utils2.isDev && this.__options.debug ? window.console.log.bind(window, `[debug] [${this.$id}]`) : import_utils2.noop;
159
135
  }
160
136
  get __managers() {
161
137
  return {
@@ -167,14 +143,14 @@ var Base = class extends EventTarget {
167
143
  };
168
144
  }
169
145
  __callMethod(method, ...args) {
170
- if (isDev) {
146
+ if (import_utils2.isDev) {
171
147
  this.__debug("callMethod", method, ...args);
172
148
  }
173
149
  this.$emit(method, ...args);
174
- if (typeof this[method] !== "function") {
150
+ if (!(0, import_utils2.isFunction)(this[method])) {
175
151
  return null;
176
152
  }
177
- if (isDev) {
153
+ if (import_utils2.isDev) {
178
154
  this.__debug(method, this, ...args);
179
155
  }
180
156
  return this[method].call(this, ...args);
@@ -183,13 +159,40 @@ var Base = class extends EventTarget {
183
159
  const eventHandlers = this.__eventHandlers.get(event);
184
160
  return eventHandlers && eventHandlers.size > 0;
185
161
  }
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
+ }
186
189
  $mount() {
187
190
  if (this.$isMounted) {
188
191
  return this;
189
192
  }
190
193
  this.$emit("before-mounted");
191
194
  this.$isMounted = true;
192
- if (isDev) {
195
+ if (import_utils2.isDev) {
193
196
  this.__debug("$mount");
194
197
  }
195
198
  this.$children.registerAll();
@@ -201,7 +204,7 @@ var Base = class extends EventTarget {
201
204
  return this;
202
205
  }
203
206
  $update() {
204
- if (isDev) {
207
+ if (import_utils2.isDev) {
205
208
  this.__debug("$update");
206
209
  }
207
210
  this.$refs.unregisterAll();
@@ -218,7 +221,7 @@ var Base = class extends EventTarget {
218
221
  return this;
219
222
  }
220
223
  this.$isMounted = false;
221
- if (isDev) {
224
+ if (import_utils2.isDev) {
222
225
  this.__debug("$destroy");
223
226
  }
224
227
  this.__events.unbindRootElement();
@@ -229,21 +232,16 @@ var Base = class extends EventTarget {
229
232
  return this;
230
233
  }
231
234
  $terminate() {
232
- if (isDev) {
235
+ if (import_utils2.isDev) {
233
236
  this.__debug("$terminate");
234
237
  }
235
238
  this.$destroy();
236
239
  this.__callMethod("terminated");
237
240
  this.$el.__base__.set(this.__ctor, "terminated");
238
241
  }
239
- __testEventIsDefined(event) {
240
- if (!(Array.isArray(this.__config.emits) && this.__config.emits.includes(event))) {
241
- console.warn(`[${this.__config.name}]`, `The "${event}" event is missing from the configuration.`);
242
- }
243
- }
244
242
  __addEmits(event) {
245
243
  const ctor = this.__ctor;
246
- if (Array.isArray(ctor.config.emits)) {
244
+ if ((0, import_utils2.isArray)(ctor.config.emits)) {
247
245
  ctor.config.emits.push(event);
248
246
  } else {
249
247
  ctor.config.emits = [event];
@@ -258,44 +256,37 @@ var Base = class extends EventTarget {
258
256
  return this.constructor;
259
257
  }
260
258
  $on(event, listener, options) {
261
- if (isDev) {
259
+ if (import_utils2.isDev) {
262
260
  this.__debug("$on", event, listener, options);
263
261
  }
264
- if (isDev) {
265
- this.__testEventIsDefined(event);
266
- }
267
262
  let set = this.__eventHandlers.get(event);
268
263
  if (!set) {
269
264
  set = /* @__PURE__ */ new Set();
270
265
  this.__eventHandlers.set(event, set);
271
266
  }
272
267
  set.add(listener);
273
- this.addEventListener(event, listener, options);
268
+ const target = (0, import_utils.getEventTarget)(this, event, this.__config);
269
+ target.addEventListener(event, listener, options);
274
270
  return () => {
275
271
  this.$off(event, listener, options);
276
272
  };
277
273
  }
278
274
  $off(event, listener, options) {
279
- if (isDev) {
275
+ if (import_utils2.isDev) {
280
276
  this.__debug("$off", event, listener);
281
277
  }
282
- if (isDev) {
283
- this.__testEventIsDefined(event);
284
- }
285
278
  this.__eventHandlers.get(event).delete(listener);
286
- this.removeEventListener(event, listener, options);
279
+ const target = (0, import_utils.getEventTarget)(this, event, this.__config);
280
+ target.removeEventListener(event, listener, options);
287
281
  }
288
282
  $emit(event, ...args) {
289
- if (isDev) {
283
+ if (import_utils2.isDev) {
290
284
  this.__debug("$emit", event, args);
291
285
  }
292
- if (isDev) {
293
- this.__testEventIsDefined(event);
294
- }
295
286
  this.dispatchEvent(new CustomEvent(event, { detail: args }));
296
287
  }
297
288
  static $factory(nameOrSelector) {
298
- if (!nameOrSelector) {
289
+ if (import_utils2.isDev && !nameOrSelector) {
299
290
  throw new Error("The $factory method requires a component\u2019s name or selector to be specified.");
300
291
  }
301
292
  return (0, import_utils.getComponentElements)(nameOrSelector).map((el) => new this(el).$mount());
package/Base/index.d.ts CHANGED
@@ -191,14 +191,6 @@ export default class Base extends EventTarget {
191
191
  * @returns {void}
192
192
  */
193
193
  $terminate(): void;
194
- /**
195
- * Test if the given event is configured and warn otherwise.
196
- *
197
- * @private
198
- * @param {string} event The event name.
199
- * @returns {void}
200
- */
201
- private __testEventIsDefined;
202
194
  /**
203
195
  * Add an emitted event.
204
196
  *
package/Base/index.js CHANGED
@@ -1,19 +1,11 @@
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
- };
7
- import { getComponentElements } from "./utils.js";
1
+ import { getComponentElements, getEventTarget } from "./utils.js";
8
2
  import ChildrenManager from "./managers/ChildrenManager.js";
9
3
  import RefsManager from "./managers/RefsManager.js";
10
4
  import ServicesManager from "./managers/ServicesManager.js";
11
5
  import EventsManager from "./managers/EventsManager.js";
12
6
  import OptionsManager from "./managers/OptionsManager.js";
7
+ import { noop, isDev, isFunction, isArray } from "../utils/index.js";
13
8
  let id = 0;
14
- const isDev = typeof __DEV__ !== "undefined" && __DEV__;
15
- function noop() {
16
- }
17
9
  function createAndTestManagers(instance) {
18
10
  [
19
11
  {
@@ -43,43 +35,18 @@ function createAndTestManagers(instance) {
43
35
  }
44
36
  ].forEach(({ prop, constructorName, constructor }) => {
45
37
  instance[prop] = new instance.__managers[constructorName](instance);
46
- if (!(instance[prop] instanceof constructor)) {
38
+ if (isDev && !(instance[prop] instanceof constructor)) {
47
39
  throw new Error(`The \`$managers.${constructorName}\` must extend the \`${constructorName}\` class.`);
48
40
  }
49
41
  });
50
42
  }
51
43
  class Base extends EventTarget {
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
- throw new Error("The root element must be defined.");
66
- }
67
- const { __config } = this;
68
- if (__config.name === "Base") {
69
- throw new Error("The `config.name` property is required.");
70
- }
71
- this.$id = `${__config.name}-${id}`;
72
- id += 1;
73
- this.$el = element;
74
- if (!this.$el.__base__) {
75
- this.$el.__base__ = /* @__PURE__ */ new WeakMap();
76
- }
77
- this.$el.__base__.set(this.__ctor, this);
78
- createAndTestManagers(this);
79
- if (isDev) {
80
- this.__debug("constructor", this);
81
- }
82
- }
44
+ static $isBase = true;
45
+ $parent = null;
46
+ $id;
47
+ $el;
48
+ $isMounted = false;
49
+ __eventHandlers = /* @__PURE__ */ new Map();
83
50
  get $root() {
84
51
  if (!this.$parent) {
85
52
  return this;
@@ -95,7 +62,6 @@ class Base extends EventTarget {
95
62
  return root;
96
63
  }
97
64
  get __config() {
98
- var _a, _b, _c;
99
65
  let proto = Object.getPrototypeOf(this);
100
66
  let { config } = proto.constructor;
101
67
  while (proto.constructor.config && proto.constructor.$isBase) {
@@ -108,23 +74,44 @@ class Base extends EventTarget {
108
74
  }
109
75
  proto = Object.getPrototypeOf(proto);
110
76
  }
111
- config.options = (_a = config.options) != null ? _a : {};
112
- config.refs = (_b = config.refs) != null ? _b : [];
113
- config.components = (_c = config.components) != null ? _c : {};
77
+ config.options = config.options ?? {};
78
+ config.refs = config.refs ?? [];
79
+ config.components = config.components ?? {};
114
80
  return config;
115
81
  }
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;
116
99
  get $services() {
117
100
  return this.__services;
118
101
  }
102
+ __refs;
119
103
  get $refs() {
120
104
  return this.__refs;
121
105
  }
106
+ __options;
122
107
  get $options() {
123
108
  return this.__options;
124
109
  }
110
+ __children;
125
111
  get $children() {
126
112
  return this.__children;
127
113
  }
114
+ __events;
128
115
  get $log() {
129
116
  return this.__options.log ? window.console.log.bind(window, `[${this.__config.name}]`) : noop;
130
117
  }
@@ -145,7 +132,7 @@ class Base extends EventTarget {
145
132
  this.__debug("callMethod", method, ...args);
146
133
  }
147
134
  this.$emit(method, ...args);
148
- if (typeof this[method] !== "function") {
135
+ if (!isFunction(this[method])) {
149
136
  return null;
150
137
  }
151
138
  if (isDev) {
@@ -157,6 +144,33 @@ class Base extends EventTarget {
157
144
  const eventHandlers = this.__eventHandlers.get(event);
158
145
  return eventHandlers && eventHandlers.size > 0;
159
146
  }
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
+ }
160
174
  $mount() {
161
175
  if (this.$isMounted) {
162
176
  return this;
@@ -210,14 +224,9 @@ class Base extends EventTarget {
210
224
  this.__callMethod("terminated");
211
225
  this.$el.__base__.set(this.__ctor, "terminated");
212
226
  }
213
- __testEventIsDefined(event) {
214
- if (!(Array.isArray(this.__config.emits) && this.__config.emits.includes(event))) {
215
- console.warn(`[${this.__config.name}]`, `The "${event}" event is missing from the configuration.`);
216
- }
217
- }
218
227
  __addEmits(event) {
219
228
  const ctor = this.__ctor;
220
- if (Array.isArray(ctor.config.emits)) {
229
+ if (isArray(ctor.config.emits)) {
221
230
  ctor.config.emits.push(event);
222
231
  } else {
223
232
  ctor.config.emits = [event];
@@ -235,16 +244,14 @@ class Base extends EventTarget {
235
244
  if (isDev) {
236
245
  this.__debug("$on", event, listener, options);
237
246
  }
238
- if (isDev) {
239
- this.__testEventIsDefined(event);
240
- }
241
247
  let set = this.__eventHandlers.get(event);
242
248
  if (!set) {
243
249
  set = /* @__PURE__ */ new Set();
244
250
  this.__eventHandlers.set(event, set);
245
251
  }
246
252
  set.add(listener);
247
- this.addEventListener(event, listener, options);
253
+ const target = getEventTarget(this, event, this.__config);
254
+ target.addEventListener(event, listener, options);
248
255
  return () => {
249
256
  this.$off(event, listener, options);
250
257
  };
@@ -253,45 +260,23 @@ class Base extends EventTarget {
253
260
  if (isDev) {
254
261
  this.__debug("$off", event, listener);
255
262
  }
256
- if (isDev) {
257
- this.__testEventIsDefined(event);
258
- }
259
263
  this.__eventHandlers.get(event).delete(listener);
260
- this.removeEventListener(event, listener, options);
264
+ const target = getEventTarget(this, event, this.__config);
265
+ target.removeEventListener(event, listener, options);
261
266
  }
262
267
  $emit(event, ...args) {
263
268
  if (isDev) {
264
269
  this.__debug("$emit", event, args);
265
270
  }
266
- if (isDev) {
267
- this.__testEventIsDefined(event);
268
- }
269
271
  this.dispatchEvent(new CustomEvent(event, { detail: args }));
270
272
  }
271
273
  static $factory(nameOrSelector) {
272
- if (!nameOrSelector) {
274
+ if (isDev && !nameOrSelector) {
273
275
  throw new Error("The $factory method requires a component\u2019s name or selector to be specified.");
274
276
  }
275
277
  return getComponentElements(nameOrSelector).map((el) => new this(el).$mount());
276
278
  }
277
279
  }
278
- __publicField(Base, "$isBase", true);
279
- __publicField(Base, "config", {
280
- name: "Base",
281
- emits: [
282
- "before-mounted",
283
- "mounted",
284
- "updated",
285
- "destroyed",
286
- "terminated",
287
- "ticked",
288
- "scrolled",
289
- "resized",
290
- "moved",
291
- "loaded",
292
- "keyed"
293
- ]
294
- });
295
280
  export {
296
281
  Base as default
297
282
  };
@@ -2,7 +2,6 @@ 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;
6
5
  var __export = (target, all) => {
7
6
  for (var name in all)
8
7
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -16,10 +15,6 @@ var __copyProps = (to, from, except, desc) => {
16
15
  return to;
17
16
  };
18
17
  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
- };
23
18
 
24
19
  // packages/js-toolkit/Base/managers/AbstractManager.js
25
20
  var AbstractManager_exports = {};
@@ -28,11 +23,7 @@ __export(AbstractManager_exports, {
28
23
  });
29
24
  module.exports = __toCommonJS(AbstractManager_exports);
30
25
  var AbstractManager = class {
31
- constructor(base) {
32
- __publicField(this, "__base");
33
- this.__base = base;
34
- this.__hideProperties(["__base"]);
35
- }
26
+ __base;
36
27
  get __element() {
37
28
  return this.__base.$el;
38
29
  }
@@ -42,6 +33,10 @@ var AbstractManager = class {
42
33
  get __eventsManager() {
43
34
  return this.__base.__events;
44
35
  }
36
+ constructor(base) {
37
+ this.__base = base;
38
+ this.__hideProperties(["__base"]);
39
+ }
45
40
  __hideProperties(properties) {
46
41
  Object.defineProperties(this, Object.fromEntries(properties.map((property) => [
47
42
  property,
@@ -1,15 +1,5 @@
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
- };
7
1
  class AbstractManager {
8
- constructor(base) {
9
- __publicField(this, "__base");
10
- this.__base = base;
11
- this.__hideProperties(["__base"]);
12
- }
2
+ __base;
13
3
  get __element() {
14
4
  return this.__base.$el;
15
5
  }
@@ -19,6 +9,10 @@ class AbstractManager {
19
9
  get __eventsManager() {
20
10
  return this.__base.__events;
21
11
  }
12
+ constructor(base) {
13
+ this.__base = base;
14
+ this.__hideProperties(["__base"]);
15
+ }
22
16
  __hideProperties(properties) {
23
17
  Object.defineProperties(this, Object.fromEntries(properties.map((property) => [
24
18
  property,
@@ -4,7 +4,6 @@ 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;
8
7
  var __export = (target, all) => {
9
8
  for (var name in all)
10
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -19,10 +18,6 @@ var __copyProps = (to, from, except, desc) => {
19
18
  };
20
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
21
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
- var __publicField = (obj, key, value) => {
23
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
24
- return value;
25
- };
26
21
 
27
22
  // packages/js-toolkit/Base/managers/ChildrenManager.js
28
23
  var ChildrenManager_exports = {};
@@ -55,8 +50,7 @@ function __getChild(that, el, ComponentClass, name) {
55
50
  });
56
51
  }
57
52
  return promise.then((module2) => {
58
- var _a;
59
- const ctor = (_a = module2.default) != null ? _a : module2;
53
+ const ctor = module2.default ?? module2;
60
54
  that.__asyncComponentPromises.set(ComponentClass, {
61
55
  promise,
62
56
  status: "resolved",
@@ -102,10 +96,7 @@ function __triggerHookForAll(that, hook) {
102
96
  });
103
97
  }
104
98
  var ChildrenManager = class extends import_AbstractManager.default {
105
- constructor() {
106
- super(...arguments);
107
- __publicField(this, "__asyncComponentPromises", /* @__PURE__ */ new WeakMap());
108
- }
99
+ __asyncComponentPromises = /* @__PURE__ */ new WeakMap();
109
100
  get registeredNames() {
110
101
  return Object.keys(this).filter((key) => !key.startsWith("__"));
111
102
  }
@@ -1,9 +1,3 @@
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
- };
7
1
  import AbstractManager from "./AbstractManager.js";
8
2
  import { getComponentElements } from "../utils.js";
9
3
  function __getChild(that, el, ComponentClass, name) {
@@ -29,8 +23,7 @@ function __getChild(that, el, ComponentClass, name) {
29
23
  });
30
24
  }
31
25
  return promise.then((module) => {
32
- var _a;
33
- const ctor = (_a = module.default) != null ? _a : module;
26
+ const ctor = module.default ?? module;
34
27
  that.__asyncComponentPromises.set(ComponentClass, {
35
28
  promise,
36
29
  status: "resolved",
@@ -76,10 +69,7 @@ function __triggerHookForAll(that, hook) {
76
69
  });
77
70
  }
78
71
  class ChildrenManager extends AbstractManager {
79
- constructor() {
80
- super(...arguments);
81
- __publicField(this, "__asyncComponentPromises", /* @__PURE__ */ new WeakMap());
82
- }
72
+ __asyncComponentPromises = /* @__PURE__ */ new WeakMap();
83
73
  get registeredNames() {
84
74
  return Object.keys(this).filter((key) => !key.startsWith("__"));
85
75
  }