@studiometa/js-toolkit 2.0.0-alpha.1 → 2.0.0-alpha.10

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 (201) hide show
  1. package/Base/index.d.ts +29 -47
  2. package/Base/index.js +144 -171
  3. package/Base/managers/ChildrenManager.d.ts +6 -6
  4. package/Base/managers/ChildrenManager.js +95 -119
  5. package/Base/managers/EventsManager.d.ts +9 -9
  6. package/Base/managers/EventsManager.js +128 -161
  7. package/Base/managers/OptionsManager.d.ts +50 -5
  8. package/Base/managers/OptionsManager.js +115 -116
  9. package/Base/managers/RefsManager.js +62 -73
  10. package/Base/managers/ServicesManager.d.ts +14 -3
  11. package/Base/managers/ServicesManager.js +78 -77
  12. package/Base/utils.js +5 -8
  13. package/README.md +12 -70
  14. package/decorators/index.js +1 -2
  15. package/decorators/withBreakpointManager.d.ts +4 -4
  16. package/decorators/withBreakpointManager.js +37 -75
  17. package/decorators/withBreakpointObserver.d.ts +2 -2
  18. package/decorators/withBreakpointObserver.js +54 -77
  19. package/decorators/withDrag.d.ts +3 -3
  20. package/decorators/withDrag.js +17 -41
  21. package/decorators/withExtraConfig.d.ts +3 -3
  22. package/decorators/withExtraConfig.js +2 -24
  23. package/decorators/withIntersectionObserver.d.ts +2 -2
  24. package/decorators/withIntersectionObserver.js +17 -56
  25. package/decorators/withMountWhenInView.d.ts +3 -3
  26. package/decorators/withMountWhenInView.js +23 -51
  27. package/helpers/createApp.d.ts +3 -3
  28. package/helpers/createApp.js +10 -12
  29. package/helpers/importOnInteraction.d.ts +3 -3
  30. package/helpers/importOnInteraction.js +7 -8
  31. package/helpers/importWhenIdle.d.ts +3 -3
  32. package/helpers/importWhenIdle.js +7 -8
  33. package/helpers/importWhenVisible.d.ts +3 -3
  34. package/helpers/importWhenVisible.js +9 -16
  35. package/helpers/index.d.ts +1 -3
  36. package/helpers/index.js +1 -4
  37. package/helpers/utils.js +1 -2
  38. package/index.d.ts +14 -4
  39. package/index.js +4 -4
  40. package/index.modern.js +1 -2
  41. package/index.umd.js +1 -2
  42. package/package.json +4 -6
  43. package/services/Service.js +48 -67
  44. package/services/drag.js +143 -179
  45. package/services/index.js +1 -2
  46. package/services/key.js +55 -97
  47. package/services/load.d.ts +1 -1
  48. package/services/load.js +21 -50
  49. package/services/pointer.js +117 -156
  50. package/services/raf.js +36 -64
  51. package/services/resize.js +47 -86
  52. package/services/scroll.js +81 -120
  53. package/utils/collide/boundingRectToCircle.js +7 -6
  54. package/utils/collide/collideCircleCircle.js +1 -2
  55. package/utils/collide/collideCircleRect.js +1 -2
  56. package/utils/collide/collidePointCircle.js +1 -2
  57. package/utils/collide/collidePointRect.js +1 -2
  58. package/utils/collide/collideRectRect.js +1 -2
  59. package/utils/collide/index.js +1 -2
  60. package/utils/css/classes.js +2 -3
  61. package/utils/css/index.js +1 -2
  62. package/utils/css/matrix.js +1 -2
  63. package/utils/css/styles.js +3 -8
  64. package/utils/css/transition.js +67 -140
  65. package/utils/debounce.js +3 -4
  66. package/utils/focusTrap.js +4 -5
  67. package/utils/history.js +13 -20
  68. package/utils/index.d.ts +2 -1
  69. package/utils/index.js +2 -2
  70. package/utils/keyCodes.js +1 -2
  71. package/utils/math/clamp.js +1 -2
  72. package/utils/math/clamp01.js +1 -2
  73. package/utils/math/damp.js +1 -2
  74. package/utils/math/index.js +1 -2
  75. package/utils/math/inertiaFinalValue.js +1 -2
  76. package/utils/math/lerp.js +1 -2
  77. package/utils/math/map.js +1 -2
  78. package/utils/math/round.js +1 -2
  79. package/utils/memoize.d.ts +30 -0
  80. package/utils/memoize.js +30 -0
  81. package/utils/nextFrame.js +4 -9
  82. package/utils/object/autoBind.js +11 -19
  83. package/utils/object/getAllProperties.js +3 -11
  84. package/utils/object/index.js +1 -2
  85. package/utils/object/isObject.js +2 -4
  86. package/utils/string/index.js +1 -2
  87. package/utils/string/withLeadingCharacters.js +1 -2
  88. package/utils/string/withLeadingSlash.js +1 -2
  89. package/utils/string/withTrailingCharacters.js +1 -2
  90. package/utils/string/withTrailingSlash.js +1 -2
  91. package/utils/string/withoutLeadingCharacters.js +1 -2
  92. package/utils/string/withoutLeadingCharactersRecursive.js +1 -2
  93. package/utils/string/withoutLeadingSlash.js +1 -2
  94. package/utils/string/withoutTrailingCharacters.js +1 -2
  95. package/utils/string/withoutTrailingCharactersRecursive.js +1 -2
  96. package/utils/string/withoutTrailingSlash.js +1 -2
  97. package/utils/throttle.js +2 -3
  98. package/Base/index.js.map +0 -1
  99. package/Base/managers/ChildrenManager.js.map +0 -1
  100. package/Base/managers/EventsManager.js.map +0 -1
  101. package/Base/managers/OptionsManager.js.map +0 -1
  102. package/Base/managers/RefsManager.js.map +0 -1
  103. package/Base/managers/ServicesManager.js.map +0 -1
  104. package/Base/utils.js.map +0 -1
  105. package/components/Accordion/Accordion.d.ts +0 -83
  106. package/components/Accordion/Accordion.js +0 -121
  107. package/components/Accordion/Accordion.js.map +0 -1
  108. package/components/Accordion/AccordionItem.d.ts +0 -122
  109. package/components/Accordion/AccordionItem.js +0 -327
  110. package/components/Accordion/AccordionItem.js.map +0 -1
  111. package/components/Accordion/index.d.ts +0 -27
  112. package/components/Accordion/index.js +0 -39
  113. package/components/Accordion/index.js.map +0 -1
  114. package/components/Cursor.d.ts +0 -138
  115. package/components/Cursor.js +0 -167
  116. package/components/Cursor.js.map +0 -1
  117. package/components/Draggable.d.ts +0 -49
  118. package/components/Draggable.js +0 -77
  119. package/components/Draggable.js.map +0 -1
  120. package/components/Modal.d.ts +0 -158
  121. package/components/Modal.js +0 -270
  122. package/components/Modal.js.map +0 -1
  123. package/components/Tabs.d.ts +0 -108
  124. package/components/Tabs.js +0 -195
  125. package/components/Tabs.js.map +0 -1
  126. package/components/index.d.ts +0 -6
  127. package/components/index.js +0 -7
  128. package/components/index.js.map +0 -1
  129. package/decorators/index.js.map +0 -1
  130. package/decorators/withBreakpointManager.js.map +0 -1
  131. package/decorators/withBreakpointObserver.js.map +0 -1
  132. package/decorators/withDrag.js.map +0 -1
  133. package/decorators/withExtraConfig.js.map +0 -1
  134. package/decorators/withIntersectionObserver.js.map +0 -1
  135. package/decorators/withMountWhenInView.js.map +0 -1
  136. package/helpers/createApp.js.map +0 -1
  137. package/helpers/createBase.d.ts +0 -7
  138. package/helpers/createBase.js +0 -7
  139. package/helpers/createBase.js.map +0 -1
  140. package/helpers/defineComponent.d.ts +0 -11
  141. package/helpers/defineComponent.js +0 -68
  142. package/helpers/defineComponent.js.map +0 -1
  143. package/helpers/importOnInteraction.js.map +0 -1
  144. package/helpers/importWhenIdle.js.map +0 -1
  145. package/helpers/importWhenVisible.js.map +0 -1
  146. package/helpers/index.js.map +0 -1
  147. package/helpers/utils.js.map +0 -1
  148. package/index.js.map +0 -1
  149. package/index.modern.js.map +0 -1
  150. package/index.umd.js.map +0 -1
  151. package/services/Service.js.map +0 -1
  152. package/services/drag.js.map +0 -1
  153. package/services/index.js.map +0 -1
  154. package/services/key.js.map +0 -1
  155. package/services/load.js.map +0 -1
  156. package/services/pointer.js.map +0 -1
  157. package/services/raf.js.map +0 -1
  158. package/services/resize.js.map +0 -1
  159. package/services/scroll.js.map +0 -1
  160. package/utils/collide/boundingRectToCircle.js.map +0 -1
  161. package/utils/collide/collideCircleCircle.js.map +0 -1
  162. package/utils/collide/collideCircleRect.js.map +0 -1
  163. package/utils/collide/collidePointCircle.js.map +0 -1
  164. package/utils/collide/collidePointRect.js.map +0 -1
  165. package/utils/collide/collideRectRect.js.map +0 -1
  166. package/utils/collide/index.js.map +0 -1
  167. package/utils/css/classes.js.map +0 -1
  168. package/utils/css/index.js.map +0 -1
  169. package/utils/css/matrix.js.map +0 -1
  170. package/utils/css/styles.js.map +0 -1
  171. package/utils/css/transition.js.map +0 -1
  172. package/utils/debounce.js.map +0 -1
  173. package/utils/focusTrap.js.map +0 -1
  174. package/utils/history.js.map +0 -1
  175. package/utils/index.js.map +0 -1
  176. package/utils/keyCodes.js.map +0 -1
  177. package/utils/math/clamp.js.map +0 -1
  178. package/utils/math/clamp01.js.map +0 -1
  179. package/utils/math/damp.js.map +0 -1
  180. package/utils/math/index.js.map +0 -1
  181. package/utils/math/inertiaFinalValue.js.map +0 -1
  182. package/utils/math/lerp.js.map +0 -1
  183. package/utils/math/map.js.map +0 -1
  184. package/utils/math/round.js.map +0 -1
  185. package/utils/nextFrame.js.map +0 -1
  186. package/utils/object/autoBind.js.map +0 -1
  187. package/utils/object/getAllProperties.js.map +0 -1
  188. package/utils/object/index.js.map +0 -1
  189. package/utils/object/isObject.js.map +0 -1
  190. package/utils/string/index.js.map +0 -1
  191. package/utils/string/withLeadingCharacters.js.map +0 -1
  192. package/utils/string/withLeadingSlash.js.map +0 -1
  193. package/utils/string/withTrailingCharacters.js.map +0 -1
  194. package/utils/string/withTrailingSlash.js.map +0 -1
  195. package/utils/string/withoutLeadingCharacters.js.map +0 -1
  196. package/utils/string/withoutLeadingCharactersRecursive.js.map +0 -1
  197. package/utils/string/withoutLeadingSlash.js.map +0 -1
  198. package/utils/string/withoutTrailingCharacters.js.map +0 -1
  199. package/utils/string/withoutTrailingCharactersRecursive.js.map +0 -1
  200. package/utils/string/withoutTrailingSlash.js.map +0 -1
  201. package/utils/throttle.js.map +0 -1
package/Base/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * @typedef {typeof Base} BaseComponent
3
- * @typedef {(Base) => Promise<BaseComponent | { default: BaseComponent }>} BaseAsyncComponent
2
+ * @typedef {typeof Base} BaseConstructor
3
+ * @typedef {(Base) => Promise<BaseConstructor | { default: BaseConstructor }>} BaseAsyncConstructor
4
4
  * @typedef {OptionsManager & { [name:string]: any }} BaseOptions
5
5
  * @typedef {{ [name:string]: HTMLElement | HTMLElement[] }} BaseRefs
6
6
  * @typedef {{ [nameOrSelector:string]: Base[] | Promise<Base>[] }} BaseChildren
7
- * @typedef {{ [nameOrSelector:string]: BaseComponent | BaseAsyncComponent }} BaseConfigComponents
7
+ * @typedef {{ [nameOrSelector:string]: BaseConstructor | BaseAsyncConstructor }} BaseConfigComponents
8
8
  * @typedef {import('./managers/OptionsManager').OptionsSchema} BaseConfigOptions
9
9
  * @typedef {import('./managers/ServicesManager.js').ServiceName} ServiceName
10
10
  */
@@ -18,39 +18,15 @@
18
18
  * @property {BaseConfigOptions} [options]
19
19
  */
20
20
  /**
21
- * Base class to easily create components.
22
- *
23
- * @example
24
- * ```js
25
- * class Component extends Base {
26
- * static config = {
27
- * name: 'Component',
28
- * log: true,
29
- * };
30
- *
31
- * mounted() {
32
- * this.$log('Component is mounted!');
33
- * }
34
- * }
35
- *
36
- * class App extends Base {
37
- * static config = {
38
- * name: 'App',
39
- * components: {
40
- * Component,
41
- * },
42
- * };
43
- * }
44
- *
45
- * new App(document.body).$mount();
46
- * ```
21
+ * Base class.
47
22
  */
48
23
  export default class Base {
49
24
  /**
50
25
  * This is a Base instance.
51
26
  * @type {Boolean}
27
+ * @readonly
52
28
  */
53
- static $isBase: boolean;
29
+ static readonly $isBase: boolean;
54
30
  /**
55
31
  * @type {BaseConfig}
56
32
  */
@@ -89,10 +65,10 @@ export default class Base {
89
65
  */
90
66
  $isMounted: boolean;
91
67
  /**
92
- * Get properties to exclude from the autobind call.
93
- * @return {Array<String|RegExp>}
68
+ * Get the root instance of the app.
69
+ * @return {Base}
94
70
  */
95
- get __excludeFromAutoBind(): (string | RegExp)[];
71
+ get $root(): Base;
96
72
  /**
97
73
  * Merge configuration with the parents' configurations.
98
74
  *
@@ -102,41 +78,45 @@ export default class Base {
102
78
  private get __config();
103
79
  /**
104
80
  * @type {ServicesManager}
81
+ * @private
105
82
  */
106
- __services: ServicesManager;
83
+ private __services;
107
84
  /**
108
- * The instance services.
109
85
  * @type {ServicesManager}
110
86
  */
111
87
  get $services(): ServicesManager;
112
88
  /**
113
89
  * @type {RefsManager}
90
+ * @private
114
91
  */
115
- __refs: RefsManager;
92
+ private __refs;
116
93
  /**
117
94
  * @return {RefsManager}
118
95
  */
119
96
  get $refs(): RefsManager;
120
97
  /**
121
98
  * @type {BaseOptions}
99
+ * @private
122
100
  */
123
- __options: BaseOptions;
101
+ private __options;
124
102
  /**
125
103
  * @return {BaseOptions}
126
104
  */
127
105
  get $options(): BaseOptions;
128
106
  /**
129
107
  * @type {ChildrenManager}
108
+ * @private
130
109
  */
131
- __children: ChildrenManager;
110
+ private __children;
132
111
  /**
133
112
  * @return {ChildrenManager}
134
113
  */
135
114
  get $children(): ChildrenManager;
136
115
  /**
137
116
  * @type {EventsManager}
117
+ * @private
138
118
  */
139
- __events: EventsManager;
119
+ private __events;
140
120
  /**
141
121
  * Small helper to log stuff.
142
122
  *
@@ -151,16 +131,19 @@ export default class Base {
151
131
  get __debug(): (...args: any) => void;
152
132
  /**
153
133
  * Trigger the `mounted` callback.
134
+ * @return {this}
154
135
  */
155
- $mount(): Base;
136
+ $mount(): this;
156
137
  /**
157
138
  * Update the instance children.
139
+ * @return {this}
158
140
  */
159
- $update(): Base;
141
+ $update(): this;
160
142
  /**
161
143
  * Trigger the `destroyed` callback.
144
+ * @return {this}
162
145
  */
163
- $destroy(): Base;
146
+ $destroy(): this;
164
147
  /**
165
148
  * Terminate a child instance when it is not needed anymore.
166
149
  * @return {void}
@@ -202,9 +185,9 @@ export default class Base {
202
185
  */
203
186
  $emit(event: string, ...args: any[]): void;
204
187
  }
205
- export type BaseComponent = typeof Base;
206
- export type BaseAsyncComponent = (Base: any) => Promise<BaseComponent | {
207
- default: BaseComponent;
188
+ export type BaseConstructor = typeof Base;
189
+ export type BaseAsyncConstructor = (Base: any) => Promise<BaseConstructor | {
190
+ default: BaseConstructor;
208
191
  }>;
209
192
  export type BaseOptions = OptionsManager & {
210
193
  [name: string]: any;
@@ -216,7 +199,7 @@ export type BaseChildren = {
216
199
  [nameOrSelector: string]: Base[] | Promise<Base>[];
217
200
  };
218
201
  export type BaseConfigComponents = {
219
- [nameOrSelector: string]: typeof Base | BaseAsyncComponent;
202
+ [nameOrSelector: string]: typeof Base | BaseAsyncConstructor;
220
203
  };
221
204
  export type BaseConfigOptions = import('./managers/OptionsManager').OptionsSchema;
222
205
  export type ServiceName = import('./managers/ServicesManager.js').ServiceName;
@@ -231,5 +214,4 @@ export type BaseConfig = {
231
214
  import ServicesManager from "./managers/ServicesManager.js";
232
215
  import RefsManager from "./managers/RefsManager.js";
233
216
  import ChildrenManager from "./managers/ChildrenManager.js";
234
- import EventsManager from "./managers/EventsManager.js";
235
217
  import OptionsManager from "./managers/OptionsManager.js";
package/Base/index.js CHANGED
@@ -1,13 +1,9 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
2
 
6
3
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
7
4
 
8
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
9
6
 
10
- import autoBind from '../utils/object/autoBind.js';
11
7
  import { callMethod, getComponentElements } from './utils.js';
12
8
  import ChildrenManager from './managers/ChildrenManager.js';
13
9
  import RefsManager from './managers/RefsManager.js';
@@ -16,14 +12,80 @@ import EventsManager from './managers/EventsManager.js';
16
12
  import OptionsManager from './managers/OptionsManager.js';
17
13
  var id = 0;
18
14
 
19
- var noop = function noop() {};
15
+ function noop() {}
20
16
 
21
- var Base = function () {
22
- function Base(element) {
23
- var _this = this;
17
+ export default class Base {
18
+ get $root() {
19
+ if (!this.$parent) {
20
+ return this;
21
+ }
22
+
23
+ var parent = this.$parent;
24
+ var root = this.$parent;
25
+
26
+ while (parent) {
27
+ if (!parent.$parent) {
28
+ root = parent;
29
+ }
30
+
31
+ parent = parent.$parent;
32
+ }
33
+
34
+ return root;
35
+ }
24
36
 
25
- _classCallCheck(this, Base);
37
+ get __config() {
38
+ var proto = Object.getPrototypeOf(this);
39
+ var {
40
+ config
41
+ } = proto.constructor;
26
42
 
43
+ while (proto.constructor.config && proto.constructor.$isBase) {
44
+ config = _objectSpread(_objectSpread({}, proto.constructor.config), config);
45
+
46
+ if (proto.constructor.config.options) {
47
+ config.options = _objectSpread(_objectSpread({}, proto.constructor.config.options), config.options);
48
+ }
49
+
50
+ proto = Object.getPrototypeOf(proto);
51
+ }
52
+
53
+ return config;
54
+ }
55
+
56
+ get $services() {
57
+ var services = this.__services;
58
+ this.$emit('get:services', services);
59
+ return services;
60
+ }
61
+
62
+ get $refs() {
63
+ var refs = this.__refs;
64
+ this.$emit('get:refs', refs);
65
+ return refs;
66
+ }
67
+
68
+ get $options() {
69
+ var options = this.__options;
70
+ this.$emit('get:options', options);
71
+ return options;
72
+ }
73
+
74
+ get $children() {
75
+ var children = this.__children;
76
+ this.$emit('get:children', children);
77
+ return children;
78
+ }
79
+
80
+ get $log() {
81
+ return this.__options.log ? window.console.log.bind(window, "[".concat(this.__config.name, "]")) : noop;
82
+ }
83
+
84
+ get __debug() {
85
+ return this.__options.debug && typeof window.__DEV__ !== 'undefined' && window.__DEV__ ? window.console.log.bind(window, "[debug] [".concat(this.$id, "]")) : noop;
86
+ }
87
+
88
+ constructor(element) {
27
89
  _defineProperty(this, "$parent", null);
28
90
 
29
91
  _defineProperty(this, "$id", void 0);
@@ -46,7 +108,9 @@ var Base = function () {
46
108
  throw new Error('The root element must be defined.');
47
109
  }
48
110
 
49
- var __config = this.__config;
111
+ var {
112
+ __config
113
+ } = this;
50
114
 
51
115
  if (!__config) {
52
116
  throw new Error('The `config` static property must be defined.');
@@ -62,9 +126,7 @@ var Base = function () {
62
126
 
63
127
  if (!('__base__' in this.$el)) {
64
128
  Object.defineProperty(this.$el, '__base__', {
65
- get: function get() {
66
- return _this;
67
- },
129
+ get: () => this,
68
130
  configurable: true
69
131
  });
70
132
  }
@@ -74,191 +136,102 @@ var Base = function () {
74
136
  this.__events = new EventsManager(element, this);
75
137
  this.__children = new ChildrenManager(this, element, __config.components || {}, this.__events);
76
138
  this.__refs = new RefsManager(this, element, __config.refs || [], this.__events);
77
- autoBind(this, {
78
- exclude: _toConsumableArray(this.__excludeFromAutoBind)
79
- });
80
139
 
81
140
  this.__debug('constructor', this);
82
141
 
83
142
  return this;
84
143
  }
85
144
 
86
- _createClass(Base, [{
87
- key: "__excludeFromAutoBind",
88
- get: function get() {
89
- return ['$mount', '$update', '$destroy', '$terminate', '$log', '$on', '$once', '$off', '$emit', 'mounted', 'loaded', 'ticked', 'resized', 'moved', 'keyed', 'scrolled', 'destroyed', 'terminated'];
90
- }
91
- }, {
92
- key: "__config",
93
- get: function get() {
94
- var proto = Object.getPrototypeOf(this);
95
- var config = proto.constructor.config;
145
+ $mount() {
146
+ this.__debug('$mount');
96
147
 
97
- while (proto.constructor.config && proto.constructor.$isBase) {
98
- config = _objectSpread(_objectSpread({}, proto.constructor.config), config);
148
+ this.$children.registerAll();
149
+ this.$refs.registerAll();
99
150
 
100
- if (proto.constructor.config.options) {
101
- config.options = _objectSpread(_objectSpread({}, proto.constructor.config.options), config.options);
102
- }
151
+ this.__events.bindRootElement();
103
152
 
104
- proto = Object.getPrototypeOf(proto);
105
- }
153
+ this.$services.enableAll();
154
+ this.$children.mountAll();
155
+ callMethod(this, 'mounted');
156
+ this.$isMounted = true;
157
+ return this;
158
+ }
106
159
 
107
- return config;
108
- }
109
- }, {
110
- key: "$services",
111
- get: function get() {
112
- var services = this.__services;
113
- this.$emit('get:services', services);
114
- return services;
115
- }
116
- }, {
117
- key: "$refs",
118
- get: function get() {
119
- var refs = this.__refs;
120
- this.$emit('get:refs', refs);
121
- return refs;
122
- }
123
- }, {
124
- key: "$options",
125
- get: function get() {
126
- var options = this.__options;
127
- this.$emit('get:options', options);
128
- return options;
129
- }
130
- }, {
131
- key: "$children",
132
- get: function get() {
133
- this.__debug('before:getChildren', this.$el, this.__config.components);
160
+ $update() {
161
+ this.__debug('$update');
134
162
 
135
- var children = this.__children;
136
- this.$emit('get:children', children);
163
+ this.$refs.unregisterAll();
164
+ this.$services.disableAll();
165
+ this.$children.registerAll();
166
+ this.$refs.registerAll();
167
+ this.$services.enableAll();
168
+ this.$children.updateAll();
169
+ callMethod(this, 'updated');
170
+ return this;
171
+ }
137
172
 
138
- this.__debug(this, 'after:getChildren', children);
173
+ $destroy() {
174
+ this.__debug('$destroy');
139
175
 
140
- return children;
141
- }
142
- }, {
143
- key: "$log",
144
- get: function get() {
145
- return this.__options.log ? window.console.log.bind(window, "[".concat(this.__config.name, "]")) : noop;
146
- }
147
- }, {
148
- key: "__debug",
149
- get: function get() {
150
- return this.__options.debug && typeof window.__DEV__ !== 'undefined' && window.__DEV__ ? window.console.log.bind(window, "[debug] [".concat(this.$id, "]")) : noop;
151
- }
152
- }, {
153
- key: "$mount",
154
- value: function $mount() {
155
- this.__debug('$mount');
176
+ this.__events.unbindRootElement();
156
177
 
157
- this.$children.registerAll();
158
- this.$refs.registerAll();
178
+ this.$refs.unregisterAll();
179
+ this.$services.disableAll();
180
+ this.$children.destroyAll();
181
+ callMethod(this, 'destroyed');
182
+ this.$isMounted = false;
183
+ return this;
184
+ }
159
185
 
160
- this.__events.bindRootElement();
186
+ $terminate() {
187
+ this.__debug('$terminate');
161
188
 
162
- this.$services.enableAll();
163
- this.$children.mountAll();
164
- callMethod(this, 'mounted');
165
- this.$isMounted = true;
166
- return this;
167
- }
168
- }, {
169
- key: "$update",
170
- value: function $update() {
171
- this.__debug('$update');
172
-
173
- this.$refs.unregisterAll();
174
- this.$services.disableAll();
175
- this.$children.registerAll();
176
- this.$refs.registerAll();
177
- this.$services.enableAll();
178
- this.$children.updateAll();
179
- callMethod(this, 'updated');
180
- return this;
181
- }
182
- }, {
183
- key: "$destroy",
184
- value: function $destroy() {
185
- this.__debug('$destroy');
186
-
187
- this.__events.unbindRootElement();
188
-
189
- this.$refs.unregisterAll();
190
- this.$services.disableAll();
191
- this.$children.destroyAll();
192
- callMethod(this, 'destroyed');
193
- this.$isMounted = false;
194
- return this;
195
- }
196
- }, {
197
- key: "$terminate",
198
- value: function $terminate() {
199
- this.__debug('$terminate');
189
+ this.$destroy();
190
+ callMethod(this, 'terminated');
191
+ Object.defineProperty(this.$el, '__base__', {
192
+ value: 'terminated',
193
+ configurable: false,
194
+ writable: false
195
+ });
196
+ }
200
197
 
201
- this.$destroy();
202
- callMethod(this, 'terminated');
203
- Object.defineProperty(this.$el, '__base__', {
204
- value: 'terminated',
205
- configurable: false,
206
- writable: false
207
- });
198
+ static $factory(nameOrSelector) {
199
+ if (!nameOrSelector) {
200
+ throw new Error('The $factory method requires a component’s name or selector to be specified.');
208
201
  }
209
- }, {
210
- key: "$on",
211
- value: function $on(event, listener, options) {
212
- var _this2 = this;
213
202
 
214
- this.__debug('$on', event, listener, options);
203
+ return getComponentElements(nameOrSelector).map(el => new this(el).$mount());
204
+ }
215
205
 
216
- this.$el.addEventListener(event, listener, options);
217
- return function () {
218
- _this2.$off(event, listener, options);
219
- };
220
- }
221
- }, {
222
- key: "$off",
223
- value: function $off(event, listener, options) {
224
- this.__debug('$off', event, listener);
206
+ $on(event, listener, options) {
207
+ this.__debug('$on', event, listener, options);
225
208
 
226
- this.$el.removeEventListener(event, listener, options);
227
- }
228
- }, {
229
- key: "$emit",
230
- value: function $emit(event) {
231
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
232
- args[_key - 1] = arguments[_key];
233
- }
209
+ this.$el.addEventListener(event, listener, options);
210
+ return () => {
211
+ this.$off(event, listener, options);
212
+ };
213
+ }
214
+
215
+ $off(event, listener, options) {
216
+ this.__debug('$off', event, listener);
234
217
 
235
- this.__debug('$emit', event, args);
218
+ this.$el.removeEventListener(event, listener, options);
219
+ }
236
220
 
237
- this.$el.dispatchEvent(new CustomEvent(event, {
238
- detail: args
239
- }));
221
+ $emit(event) {
222
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
223
+ args[_key - 1] = arguments[_key];
240
224
  }
241
- }], [{
242
- key: "$factory",
243
- value: function $factory(nameOrSelector) {
244
- var _this3 = this;
245
225
 
246
- if (!nameOrSelector) {
247
- throw new Error('The $factory method requires a component’s name or selector to be specified.');
248
- }
226
+ this.__debug('$emit', event, args);
249
227
 
250
- return getComponentElements(nameOrSelector).map(function (el) {
251
- return new _this3(el).$mount();
252
- });
253
- }
254
- }]);
228
+ this.$el.dispatchEvent(new CustomEvent(event, {
229
+ detail: args
230
+ }));
231
+ }
255
232
 
256
- return Base;
257
- }();
233
+ }
258
234
 
259
235
  _defineProperty(Base, "$isBase", true);
260
236
 
261
- _defineProperty(Base, "config", void 0);
262
-
263
- export { Base as default };
264
- //# sourceMappingURL=index.js.map
237
+ _defineProperty(Base, "config", void 0);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @typedef {import('../index.js').default} Base
3
- * @typedef {import('../index.js').BaseComponent} BaseComponent
4
- * @typedef {import('../index.js').BaseAsyncComponent} BaseAsyncComponent
3
+ * @typedef {import('../index.js').BaseConstructor} BaseConstructor
4
+ * @typedef {import('../index.js').BaseAsyncConstructor} BaseAsyncConstructor
5
5
  * @typedef {import('../index.js').BaseConfigComponents} BaseConfigComponents
6
6
  * @typedef {import('./EventsManager.js').default} EventsManager
7
7
  */
@@ -53,7 +53,7 @@ export default class ChildrenManager {
53
53
  *
54
54
  * @param {string} name
55
55
  * The name of the child component.
56
- * @param {BaseComponent|BaseAsyncComponent} component
56
+ * @param {BaseConstructor|BaseAsyncConstructor} component
57
57
  * A Base class or a Promise for async components.
58
58
  * @private
59
59
  */
@@ -63,7 +63,7 @@ export default class ChildrenManager {
63
63
  *
64
64
  * @param {HTMLElement & { __base__?: Base | 'terminated' }} el
65
65
  * The root element of the child component.
66
- * @param {BaseComponent|BaseAsyncComponent} ComponentClass
66
+ * @param {BaseConstructor|BaseAsyncConstructor} ComponentClass
67
67
  * A Base class or a Promise for async components.
68
68
  * @param {string} name
69
69
  * The name of the child component.
@@ -102,7 +102,7 @@ export default class ChildrenManager {
102
102
  private __triggerHook;
103
103
  }
104
104
  export type Base = import('../index.js').default;
105
- export type BaseComponent = import('../index.js').BaseComponent;
106
- export type BaseAsyncComponent = import('../index.js').BaseAsyncComponent;
105
+ export type BaseConstructor = import('../index.js').BaseConstructor;
106
+ export type BaseAsyncConstructor = import('../index.js').BaseAsyncConstructor;
107
107
  export type BaseConfigComponents = import('../index.js').BaseConfigComponents;
108
108
  export type EventsManager = import('./EventsManager.js').default;