@studiometa/js-toolkit 2.4.1 → 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.
Files changed (87) hide show
  1. package/Base/index.cjs +10 -3
  2. package/Base/index.d.ts +23 -18
  3. package/Base/index.js +6 -2
  4. package/Base/managers/AbstractManager.cjs +13 -8
  5. package/Base/managers/AbstractManager.d.ts +3 -3
  6. package/Base/managers/AbstractManager.js +13 -8
  7. package/Base/managers/ChildrenManager.cjs +10 -3
  8. package/Base/managers/ChildrenManager.d.ts +1 -1
  9. package/Base/managers/ChildrenManager.js +6 -2
  10. package/Base/managers/EventsManager.cjs +17 -4
  11. package/Base/managers/EventsManager.d.ts +3 -3
  12. package/Base/managers/EventsManager.js +13 -3
  13. package/Base/managers/OptionsManager.cjs +18 -5
  14. package/Base/managers/OptionsManager.d.ts +2 -2
  15. package/Base/managers/OptionsManager.js +14 -4
  16. package/Base/managers/RefsManager.cjs +17 -4
  17. package/Base/managers/RefsManager.js +13 -3
  18. package/Base/managers/ResponsiveOptionsManager.cjs +4 -1
  19. package/Base/managers/ServicesManager.cjs +12 -5
  20. package/Base/managers/ServicesManager.d.ts +1 -1
  21. package/Base/managers/ServicesManager.js +8 -4
  22. package/Base/utils.cjs +5 -1
  23. package/Base/utils.d.ts +2 -2
  24. package/Base/utils.js +5 -1
  25. package/decorators/index.cjs +4 -1
  26. package/decorators/withBreakpointManager.cjs +4 -1
  27. package/decorators/withBreakpointManager.d.ts +1 -1
  28. package/decorators/withBreakpointObserver.cjs +10 -3
  29. package/decorators/withBreakpointObserver.d.ts +1 -1
  30. package/decorators/withBreakpointObserver.js +6 -2
  31. package/decorators/withDrag.cjs +8 -2
  32. package/decorators/withDrag.d.ts +2 -4
  33. package/decorators/withDrag.js +4 -1
  34. package/decorators/withExtraConfig.cjs +4 -1
  35. package/decorators/withIntersectionObserver.cjs +9 -6
  36. package/decorators/withIntersectionObserver.d.ts +1 -1
  37. package/decorators/withIntersectionObserver.js +9 -6
  38. package/decorators/withMountWhenInView.cjs +13 -10
  39. package/decorators/withMountWhenInView.d.ts +1 -1
  40. package/decorators/withMountWhenInView.js +13 -10
  41. package/decorators/withResponsiveOptions.cjs +4 -1
  42. package/decorators/withScrolledInView.cjs +64 -18
  43. package/decorators/withScrolledInView.d.ts +27 -6
  44. package/decorators/withScrolledInView.js +60 -17
  45. package/decorators/withVue2.d.ts +1 -1
  46. package/helpers/getDirectChildren.d.ts +3 -3
  47. package/helpers/importOnInteraction.d.ts +2 -2
  48. package/helpers/importWhenIdle.cjs +8 -5
  49. package/helpers/importWhenIdle.js +8 -5
  50. package/helpers/importWhenVisible.d.ts +2 -2
  51. package/helpers/index.cjs +4 -1
  52. package/index.cjs +4 -1
  53. package/package.json +2 -2
  54. package/services/drag.cjs +4 -1
  55. package/services/index.cjs +4 -1
  56. package/services/index.d.ts +7 -0
  57. package/services/key.cjs +4 -1
  58. package/services/resize.cjs +4 -1
  59. package/services/scroll.cjs +4 -1
  60. package/utils/collide/index.cjs +4 -1
  61. package/utils/css/animate.cjs +24 -13
  62. package/utils/css/animate.js +20 -12
  63. package/utils/css/index.cjs +4 -1
  64. package/utils/css/transition.cjs +4 -4
  65. package/utils/css/transition.js +0 -3
  66. package/utils/focusTrap.cjs +4 -1
  67. package/utils/history.cjs +4 -1
  68. package/utils/history.js +4 -1
  69. package/utils/index.cjs +4 -1
  70. package/utils/math/clamp01.cjs +4 -1
  71. package/utils/math/index.cjs +4 -1
  72. package/utils/math/inertiaFinalValue.cjs +4 -1
  73. package/utils/nextTick.cjs +5 -3
  74. package/utils/nextTick.js +5 -3
  75. package/utils/object/autoBind.cjs +4 -1
  76. package/utils/object/index.cjs +4 -1
  77. package/utils/scrollTo.cjs +4 -1
  78. package/utils/string/index.cjs +4 -1
  79. package/utils/string/withLeadingCharacters.cjs +4 -1
  80. package/utils/string/withLeadingSlash.cjs +4 -1
  81. package/utils/string/withTrailingCharacters.cjs +4 -1
  82. package/utils/string/withTrailingSlash.cjs +4 -1
  83. package/utils/string/withoutLeadingCharactersRecursive.cjs +4 -1
  84. package/utils/string/withoutLeadingSlash.cjs +4 -1
  85. package/utils/string/withoutTrailingCharactersRecursive.cjs +4 -1
  86. package/utils/string/withoutTrailingSlash.cjs +4 -1
  87. 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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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(`The \`$managers.${constructorName}\` must extend the \`${constructorName}\` class.`);
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("The $factory method requires a component\u2019s name or selector to be specified.");
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
@@ -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 EventTarget {
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(): BaseOptions;
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
@@ -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(`The \`$managers.${constructorName}\` must extend the \`${constructorName}\` class.`);
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("The $factory method requires a component\u2019s name or selector to be specified.");
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(this, Object.fromEntries(properties.map((property) => [
47
- property,
48
- {
49
- enumerable: false,
50
- writable: false,
51
- value: this[property]
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;
@@ -12,11 +12,11 @@ export default class AbstractManager {
12
12
  *
13
13
  * @param {Base} base
14
14
  */
15
- constructor(base: Base);
15
+ constructor(base: import("../index.js").default<any>);
16
16
  /**
17
17
  * @type {Base}
18
18
  */
19
- __base: 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('../index.js').default;
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;
@@ -20,14 +20,19 @@ class AbstractManager {
20
20
  return this.__base.__events;
21
21
  }
22
22
  __hideProperties(properties) {
23
- Object.defineProperties(this, Object.fromEntries(properties.map((property) => [
24
- property,
25
- {
26
- enumerable: false,
27
- writable: false,
28
- value: this[property]
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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(ComponentClass);
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(([name, component]) => __register(this, name, component));
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");
@@ -34,7 +34,7 @@ export default class ChildrenManager extends AbstractManager {
34
34
  */
35
35
  destroyAll(): void;
36
36
  }
37
- export type Base = import('../index.js').default;
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;
@@ -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(ComponentClass);
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(([name, component]) => __register(this, name, component));
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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(name, 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());
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((0, import_getAllProperties.default)(that.__base, [], (method) => regex.test(method)).reduce((set, [method]) => set.add(method), /* @__PURE__ */ new Set()));
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((instance) => instance === event.currentTarget || instance.$el === event.currentTarget)
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);
@@ -83,7 +83,7 @@ export default class EventsManager extends AbstractManager {
83
83
  * A base instance.
84
84
  * @returns {void}
85
85
  */
86
- bindChild(name: string, instance: Base): void;
86
+ bindChild(name: string, instance: import("../index.js").default<any>): void;
87
87
  /**
88
88
  * Unbind event methods to the given child instance.
89
89
  *
@@ -93,7 +93,7 @@ export default class EventsManager extends AbstractManager {
93
93
  * A base instance.
94
94
  * @returns {void}
95
95
  */
96
- unbindChild(name: string, instance: Base): void;
96
+ unbindChild(name: string, instance: import("../index.js").default<any>): void;
97
97
  /**
98
98
  * Bind event methods on the root element.
99
99
  *
@@ -107,6 +107,6 @@ export default class EventsManager extends AbstractManager {
107
107
  */
108
108
  unbindRootElement(): void;
109
109
  }
110
- export type Base = import('../index.js').default;
110
+ export type Base = import("../index.js").default<any>;
111
111
  export type ChildrenManager = import('./ChildrenManager.js').default;
112
112
  import AbstractManager from "./AbstractManager.js";
@@ -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(name, 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());
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(getAllProperties(that.__base, [], (method) => regex.test(method)).reduce((set, [method]) => set.add(method), /* @__PURE__ */ new Set()));
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((instance) => instance === event.currentTarget || instance.$el === event.currentTarget)
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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(`The "${name}" option has an invalid type. The allowed types are: String, Number, Boolean, Array and Object.`);
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(`The default value for options of type "${config.type.name}" must be returned by a function.`);
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(this, name, types.has(config) ? { type: config } : config);
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(`The "${val}" value for the "${name}" option must be of type "${type.name}"`);
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
  }
@@ -52,7 +52,7 @@ export default class OptionsManager extends AbstractManager {
52
52
  set(name: string, value: any, config: OptionObject): void;
53
53
  }
54
54
  export type DeepmergeOptions = import('deepmerge').Options;
55
- export type Base = import('../index.js').default;
55
+ export type Base = import("../index.js").default<any>;
56
56
  export type BaseConfig = import('../index.js').BaseConfig;
57
57
  export type OptionType = StringConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor | ObjectConstructor;
58
58
  export type ArrayOption = {
@@ -79,7 +79,7 @@ export type BooleanOption = {
79
79
  };
80
80
  export type OptionObject = ArrayOption | ObjectOption | StringOption | NumberOption | BooleanOption;
81
81
  export type OptionsSchema = {
82
- [name: string]: OptionType | OptionObject;
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(`The "${name}" option has an invalid type. The allowed types are: String, Number, Boolean, Array and Object.`);
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(`The default value for options of type "${config.type.name}" must be returned by a function.`);
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(this, name, types.has(config) ? { type: config } : config);
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(`The "${val}" value for the "${name}" option must be of type "${type.name}"`);
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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((ref) => __filterRefsBelongingToInstance(that, ref));
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(`[${that.__base.$options.name}]`, `The "${refName}" ref has been found multiple times.`, "Did you forgot to add the `[]` suffix to its name?");
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(`[${that.__base.$options.name}]`, `The "${refName}" ref is missing.`, `Is there an \`[data-ref="${refName}"]\` element in the component's scope?`);
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((ref) => __filterRefsBelongingToInstance(that, ref));
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(`[${that.__base.$options.name}]`, `The "${refName}" ref has been found multiple times.`, "Did you forgot to add the `[]` suffix to its name?");
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(`[${that.__base.$options.name}]`, `The "${refName}" ref is missing.`, `Is there an \`[data-ref="${refName}"]\` element in the component's scope?`);
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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