@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
@@ -1,3 +1,11 @@
1
+ /**
2
+ * @typedef {import('../index.js').BaseConfig} BaseConfig
3
+ * @typedef {StringConstructor|NumberConstructor|BooleanConstructor|ArrayConstructor|ObjectConstructor} OptionType
4
+ * @typedef {{ type: OptionType, default: String|Number|Boolean|(() => Array|Object)}} OptionWithDefault
5
+ * @typedef {OptionType | OptionWithDefault} OptionValue
6
+ * @typedef {{ [name:string]: OptionValue }} OptionsSchema
7
+ * @typedef {{ [optionName:string]: any }} OptionsInterface
8
+ */
1
9
  /**
2
10
  * Class options to manage options as data attributes on an HTML element.
3
11
  * @augments {OptionsInterface}
@@ -9,6 +17,20 @@ export default class OptionsManager {
9
17
  * @private
10
18
  */
11
19
  private static types;
20
+ /**
21
+ * Property name cache.
22
+ * @type {Map}
23
+ * @private
24
+ */
25
+ private static __propertyNameCache;
26
+ /**
27
+ * Get a property name.
28
+ *
29
+ * @param {string} name
30
+ * @return {string}
31
+ * @private
32
+ */
33
+ private static __getPropertyName;
12
34
  /**
13
35
  * Class constructor.
14
36
  *
@@ -50,26 +72,49 @@ export default class OptionsManager {
50
72
  * @type {Boolean}
51
73
  */
52
74
  log: boolean;
75
+ /**
76
+ * Register an option.
77
+ *
78
+ * @param {string} name
79
+ * @param {OptionValue} config
80
+ * @return {void}
81
+ * @private
82
+ */
83
+ private __register;
53
84
  /**
54
85
  * Get an option value.
55
86
  *
56
87
  * @param {String} name The option name.
57
- * @param {ArrayConstructor|ObjectConstructor|StringConstructor|NumberConstructor|BooleanConstructor} type The option data's type.
88
+ * @param {OptionType} type The option data's type.
58
89
  * @param {any} defaultValue The default value for this option.
59
90
  */
60
- get(name: string, type: ArrayConstructor | ObjectConstructor | StringConstructor | NumberConstructor | BooleanConstructor, defaultValue: any): any;
91
+ get(name: string, type: OptionType, defaultValue: any): any;
61
92
  /**
62
93
  * Set an option value.
63
94
  *
64
95
  * @param {String} name The option name.
65
- * @param {ArrayConstructor|ObjectConstructor|StringConstructor|NumberConstructor|BooleanConstructor} type The option data's type.
96
+ * @param {OptionType} type The option data's type.
66
97
  * @param {any} value The new value for this option.
67
98
  */
68
- set(name: string, type: ArrayConstructor | ObjectConstructor | StringConstructor | NumberConstructor | BooleanConstructor, value: any, defaultValue: any): void;
99
+ set(name: string, type: OptionType, value: any, defaultValue: any): void;
100
+ /**
101
+ * Test if the element has a given property.
102
+ *
103
+ * @param {string} prop
104
+ * @return {boolean}
105
+ */
106
+ __hasProperty(prop: string): boolean;
69
107
  }
70
108
  export type BaseConfig = import('../index.js').BaseConfig;
71
109
  export type OptionType = StringConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor | ObjectConstructor;
72
- export type OptionsSchema = OptionsSchema;
110
+ export type OptionWithDefault = {
111
+ type: OptionType;
112
+ default: string | number | boolean | (() => any[] | any);
113
+ };
114
+ export type OptionValue = OptionType | OptionWithDefault;
115
+ export type OptionsSchema = {
116
+ [name: string]: OptionValue;
117
+ };
73
118
  export type OptionsInterface = {
74
119
  [optionName: string]: any;
75
120
  };
@@ -1,27 +1,9 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
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
  import deepmerge from 'deepmerge';
6
- import { noCase } from 'no-case';
7
- import mem from 'mem';
8
3
  import isObject from '../../utils/object/isObject.js';
9
-
10
- function getAttributeName(name) {
11
- return "data-option-".concat(noCase(name, {
12
- delimiter: '-'
13
- }));
14
- }
15
-
16
- var memoizedGetAttributeName = mem(getAttributeName);
17
-
18
- var OptionsManager = function () {
19
- function OptionsManager(element, schema, baseConfig) {
20
- var _baseConfig$debug,
21
- _baseConfig$log,
22
- _this = this;
23
-
24
- _classCallCheck(this, OptionsManager);
4
+ export default class OptionsManager {
5
+ constructor(element, schema, baseConfig) {
6
+ var _baseConfig$debug, _baseConfig$log;
25
7
 
26
8
  _defineProperty(this, "__element", void 0);
27
9
 
@@ -31,12 +13,8 @@ var OptionsManager = function () {
31
13
  String: '',
32
14
  Number: 0,
33
15
  Boolean: false,
34
- Array: function Array() {
35
- return [];
36
- },
37
- Object: function Object() {
38
- return {};
39
- }
16
+ Array: () => [],
17
+ Object: () => ({})
40
18
  });
41
19
 
42
20
  _defineProperty(this, "name", 'Base');
@@ -45,7 +23,23 @@ var OptionsManager = function () {
45
23
 
46
24
  _defineProperty(this, "log", false);
47
25
 
48
- this.__element = element;
26
+ Object.defineProperties(this, {
27
+ __element: {
28
+ enumerable: false,
29
+ writable: false,
30
+ value: element
31
+ },
32
+ __values: {
33
+ enumerable: false,
34
+ writable: false,
35
+ value: this.__values
36
+ },
37
+ __defaultValues: {
38
+ enumerable: false,
39
+ writable: false,
40
+ value: this.__defaultValues
41
+ }
42
+ });
49
43
  this.name = baseConfig.name;
50
44
  schema.debug = {
51
45
  type: Boolean,
@@ -55,127 +49,132 @@ var OptionsManager = function () {
55
49
  type: Boolean,
56
50
  default: (_baseConfig$log = baseConfig.log) !== null && _baseConfig$log !== void 0 ? _baseConfig$log : false
57
51
  };
58
- Object.entries(schema).forEach(function (_ref) {
59
- var _ref2 = _slicedToArray(_ref, 2),
60
- name = _ref2[0],
61
- config = _ref2[1];
52
+ Object.entries(schema).forEach(_ref => {
53
+ var [name, config] = _ref;
62
54
 
63
- var isObjectConfig = !OptionsManager.types.includes(config);
64
- var type = isObjectConfig ? config.type : config;
55
+ this.__register(name, config);
56
+ });
57
+ return this;
58
+ }
65
59
 
66
- if (!OptionsManager.types.includes(type)) {
67
- throw new Error("The \"".concat(name, "\" option has an invalid type. The allowed types are: String, Number, Boolean, Array and Object."));
68
- }
60
+ __register(name, config) {
61
+ var hasDefaultValue = !OptionsManager.types.includes(config);
62
+ var type = hasDefaultValue ? config.type : config;
69
63
 
70
- var defaultValue = isObjectConfig ? config.default : _this.__defaultValues[type.name];
64
+ if (!OptionsManager.types.includes(type)) {
65
+ throw new Error("The \"".concat(name, "\" option has an invalid type. The allowed types are: String, Number, Boolean, Array and Object."));
66
+ }
71
67
 
72
- if ((type === Array || type === Object) && typeof defaultValue !== 'function') {
73
- throw new Error("The default value for options of type \"".concat(type.name, "\" must be returned by a function."));
74
- }
68
+ var defaultValue = hasDefaultValue ? config.default : this.__defaultValues[type.name];
75
69
 
76
- Object.defineProperty(_this, name, {
77
- get: function get() {
78
- return _this.get(name, type, defaultValue);
79
- },
80
- set: function set(value) {
81
- _this.set(name, type, value, defaultValue);
82
- },
83
- enumerable: true
84
- });
70
+ if ((type === Array || type === Object) && typeof defaultValue !== 'function') {
71
+ throw new Error("The default value for options of type \"".concat(type.name, "\" must be returned by a function."));
72
+ }
73
+
74
+ Object.defineProperty(this, name, {
75
+ get: () => {
76
+ return this.get(name, type, defaultValue);
77
+ },
78
+ set: value => {
79
+ this.set(name, type, value, defaultValue);
80
+ },
81
+ enumerable: true
85
82
  });
86
- return this;
87
83
  }
88
84
 
89
- _createClass(OptionsManager, [{
90
- key: "get",
91
- value: function get(name, type, defaultValue) {
92
- var _this2 = this;
85
+ get(name, type, defaultValue) {
86
+ var propertyName = OptionsManager.__getPropertyName(name);
93
87
 
94
- var attributeName = memoizedGetAttributeName(name);
88
+ var hasProperty = this.__hasProperty(propertyName);
95
89
 
96
- var hasAttribute = this.__element.hasAttribute(attributeName);
90
+ if (type === Boolean) {
91
+ if (defaultValue) {
92
+ var negatedPropertyName = OptionsManager.__getPropertyName(name, 'No');
97
93
 
98
- if (type === Boolean) {
99
- if (defaultValue) {
100
- var negatedAttributeName = memoizedGetAttributeName("no-".concat(name));
94
+ var hasNegatedProperty = this.__hasProperty(negatedPropertyName);
101
95
 
102
- var hasNegatedAttribute = this.__element.hasAttribute(negatedAttributeName);
96
+ return !hasNegatedProperty;
97
+ }
103
98
 
104
- return !hasNegatedAttribute;
105
- }
99
+ return hasProperty || defaultValue;
100
+ }
106
101
 
107
- return hasAttribute || defaultValue;
108
- }
102
+ var value = this.__element.dataset[propertyName];
103
+
104
+ if (type === Number) {
105
+ return hasProperty ? Number(value) : defaultValue;
106
+ }
109
107
 
110
- var value = this.__element.getAttribute(attributeName);
108
+ if (type === Array || type === Object) {
109
+ var val = deepmerge(defaultValue(), hasProperty ? JSON.parse(value) : this.__defaultValues[type.name]());
111
110
 
112
- if (type === Number) {
113
- return hasAttribute ? Number(value) : defaultValue;
111
+ if (!this.__values[name]) {
112
+ this.__values[name] = val;
114
113
  }
115
114
 
116
- if (type === Array || type === Object) {
117
- var val = deepmerge(defaultValue(), hasAttribute ? JSON.parse(value) : this.__defaultValues[type.name]());
115
+ return this.__values[name];
116
+ }
118
117
 
119
- if (!this.__values[name]) {
120
- this.__values[name] = val;
121
- } else if (val !== this.__values[name]) {
122
- setTimeout(function () {
123
- _this2.__element.setAttribute(attributeName, JSON.stringify(_this2.__values[name]));
124
- }, 0);
125
- }
118
+ return hasProperty ? value : defaultValue;
119
+ }
126
120
 
127
- return this.__values[name];
128
- }
121
+ set(name, type, value, defaultValue) {
122
+ var propertyName = OptionsManager.__getPropertyName(name);
129
123
 
130
- return hasAttribute ? value : defaultValue;
124
+ if (value.constructor.name !== type.name) {
125
+ var val = Array.isArray(value) || isObject(value) ? JSON.stringify(value) : value;
126
+ throw new TypeError("The \"".concat(val, "\" value for the \"").concat(name, "\" option must be of type \"").concat(type.name, "\""));
131
127
  }
132
- }, {
133
- key: "set",
134
- value: function set(name, type, value, defaultValue) {
135
- var attributeName = memoizedGetAttributeName(name);
136
-
137
- if (value.constructor.name !== type.name) {
138
- var val = Array.isArray(value) || isObject(value) ? JSON.stringify(value) : value;
139
- throw new TypeError("The \"".concat(val, "\" value for the \"").concat(name, "\" option must be of type \"").concat(type.name, "\""));
140
- }
141
128
 
142
- switch (type) {
143
- case Boolean:
144
- if (defaultValue) {
145
- var negatedAttributeName = memoizedGetAttributeName("no-".concat(name));
146
-
147
- if (value) {
148
- this.__element.removeAttribute(negatedAttributeName);
149
- } else {
150
- this.__element.setAttribute(negatedAttributeName, '');
151
- }
152
- } else if (value) {
153
- this.__element.setAttribute(attributeName, '');
129
+ switch (type) {
130
+ case Boolean:
131
+ if (defaultValue) {
132
+ var negatedPropertyName = OptionsManager.__getPropertyName(name, 'No');
133
+
134
+ if (value) {
135
+ delete this.__element.dataset[negatedPropertyName];
154
136
  } else {
155
- this.__element.removeAttribute(attributeName);
137
+ this.__element.dataset[negatedPropertyName] = '';
156
138
  }
139
+ } else if (value) {
140
+ this.__element.dataset[propertyName] = '';
141
+ } else {
142
+ delete this.__element.dataset[propertyName];
143
+ }
157
144
 
158
- break;
145
+ break;
159
146
 
160
- case Array:
161
- case Object:
162
- this.__values[name] = value;
147
+ case Array:
148
+ case Object:
149
+ this.__values[name] = value;
150
+ break;
163
151
 
164
- this.__element.setAttribute(attributeName, JSON.stringify(value));
152
+ default:
153
+ this.__element.dataset[propertyName] = value;
154
+ }
155
+ }
165
156
 
166
- break;
157
+ __hasProperty(prop) {
158
+ return typeof this.__element.dataset[prop] !== 'undefined';
159
+ }
167
160
 
168
- default:
169
- this.__element.setAttribute(attributeName, value);
161
+ static __getPropertyName(name) {
162
+ var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
163
+ var key = name + prefix;
170
164
 
171
- }
165
+ if (OptionsManager.__propertyNameCache.has(key)) {
166
+ return OptionsManager.__propertyNameCache.get(key);
172
167
  }
173
- }]);
174
168
 
175
- return OptionsManager;
176
- }();
169
+ var propertyName = "option".concat(prefix).concat(name.replace(/^\w/, c => c.toUpperCase()));
170
+
171
+ OptionsManager.__propertyNameCache.set(key, propertyName);
172
+
173
+ return propertyName;
174
+ }
175
+
176
+ }
177
177
 
178
178
  _defineProperty(OptionsManager, "types", [String, Number, Boolean, Array, Object]);
179
179
 
180
- export { OptionsManager as default };
181
- //# sourceMappingURL=OptionsManager.js.map
180
+ _defineProperty(OptionsManager, "__propertyNameCache", new Map());
@@ -1,11 +1,6 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
-
5
- var RefsManager = function () {
6
- function RefsManager(base, element, refs, eventsManager) {
7
- _classCallCheck(this, RefsManager);
8
-
2
+ export default class RefsManager {
3
+ constructor(base, element, refs, eventsManager) {
9
4
  _defineProperty(this, "__element", void 0);
10
5
 
11
6
  _defineProperty(this, "__refs", void 0);
@@ -14,81 +9,75 @@ var RefsManager = function () {
14
9
 
15
10
  _defineProperty(this, "__eventsManager", void 0);
16
11
 
17
- this.__element = element;
18
- this.__refs = refs;
19
- this.__base = base;
20
- this.__eventsManager = eventsManager;
12
+ Object.defineProperties(this, {
13
+ __element: {
14
+ enumerable: false,
15
+ writable: false,
16
+ value: element
17
+ },
18
+ __refs: {
19
+ enumerable: false,
20
+ writable: false,
21
+ value: refs
22
+ },
23
+ __base: {
24
+ enumerable: false,
25
+ writable: false,
26
+ value: base
27
+ },
28
+ __eventsManager: {
29
+ enumerable: false,
30
+ writable: false,
31
+ value: eventsManager
32
+ }
33
+ });
21
34
  }
22
35
 
23
- _createClass(RefsManager, [{
24
- key: "registerAll",
25
- value: function registerAll() {
26
- var _this = this;
36
+ registerAll() {
37
+ this.__refs.forEach(refName => this.__register(refName));
38
+ }
27
39
 
28
- this.__refs.forEach(function (refName) {
29
- return _this.__register(refName);
30
- });
31
- }
32
- }, {
33
- key: "unregisterAll",
34
- value: function unregisterAll() {
35
- var _this2 = this;
36
-
37
- this.__refs.forEach(function (refName) {
38
- return _this2.__unregister(refName);
39
- });
40
- }
41
- }, {
42
- key: "__register",
43
- value: function __register(refName) {
44
- var _this3 = this;
45
-
46
- var isMultiple = refName.endsWith('[]');
47
- var propName = RefsManager.normalizeRefName(refName);
48
- var refs = Array.from(this.__element.querySelectorAll("[data-ref=\"".concat(refName, "\"]"))).filter(function (ref) {
49
- return _this3.__filterRefsBelongingToInstance(ref);
50
- });
51
-
52
- if (!isMultiple && refs.length > 1) {
53
- console.warn("[".concat(this.__base.$options.name, "]"), "The \"".concat(refName, "\" ref has been found multiple times."), 'Did you forgot to add the `[]` suffix to its name?');
54
- }
40
+ unregisterAll() {
41
+ this.__refs.forEach(refName => this.__unregister(refName));
42
+ }
55
43
 
56
- this.__eventsManager.bindRef(refName, refs);
44
+ __register(refName) {
45
+ var isMultiple = refName.endsWith('[]');
46
+ var propName = RefsManager.normalizeRefName(refName);
47
+ var refs = Array.from(this.__element.querySelectorAll("[data-ref=\"".concat(refName, "\"]"))).filter(ref => this.__filterRefsBelongingToInstance(ref));
57
48
 
58
- Object.defineProperty(this, propName, {
59
- value: isMultiple || refs.length > 1 ? refs : refs[0],
60
- enumerable: true,
61
- configurable: true
62
- });
49
+ if (!isMultiple && refs.length > 1) {
50
+ console.warn("[".concat(this.__base.$options.name, "]"), "The \"".concat(refName, "\" ref has been found multiple times."), 'Did you forgot to add the `[]` suffix to its name?');
63
51
  }
64
- }, {
65
- key: "__unregister",
66
- value: function __unregister(refName) {
67
- var propName = RefsManager.normalizeRefName(refName);
68
- var refs = Array.isArray(this[propName]) ? this[propName] : [this[propName]];
69
52
 
70
- this.__eventsManager.unbindRef(refName, refs);
71
- }
72
- }, {
73
- key: "__filterRefsBelongingToInstance",
74
- value: function __filterRefsBelongingToInstance(ref) {
75
- var ancestor = ref.parentElement;
53
+ this.__eventsManager.bindRef(refName, refs);
76
54
 
77
- while (ancestor && ancestor.dataset.component === undefined) {
78
- ancestor = ancestor.parentElement;
79
- }
55
+ Object.defineProperty(this, propName, {
56
+ value: isMultiple || refs.length > 1 ? refs : refs[0],
57
+ enumerable: true,
58
+ configurable: true
59
+ });
60
+ }
80
61
 
81
- return ancestor === null || ancestor === this.__element;
82
- }
83
- }], [{
84
- key: "normalizeRefName",
85
- value: function normalizeRefName(name) {
86
- return name.endsWith('[]') ? name.replace(/\[\]$/, '') : name;
62
+ __unregister(refName) {
63
+ var propName = RefsManager.normalizeRefName(refName);
64
+ var refs = Array.isArray(this[propName]) ? this[propName] : [this[propName]];
65
+
66
+ this.__eventsManager.unbindRef(refName, refs);
67
+ }
68
+
69
+ static normalizeRefName(name) {
70
+ return name.endsWith('[]') ? name.replace(/\[\]$/, '') : name;
71
+ }
72
+
73
+ __filterRefsBelongingToInstance(ref) {
74
+ var ancestor = ref.parentElement;
75
+
76
+ while (ancestor && ancestor.dataset.component === undefined) {
77
+ ancestor = ancestor.parentElement;
87
78
  }
88
- }]);
89
79
 
90
- return RefsManager;
91
- }();
80
+ return ancestor === null || ancestor === this.__element;
81
+ }
92
82
 
93
- export { RefsManager as default };
94
- //# sourceMappingURL=RefsManager.js.map
83
+ }
@@ -15,6 +15,14 @@ export default class ServicesManager {
15
15
  * @private
16
16
  */
17
17
  private __base;
18
+ /**
19
+ * @type {Record<string, () => ServiceInterface>}
20
+ */
21
+ __customServices: Record<string, () => ServiceInterface>;
22
+ /**
23
+ * @return {Record<string, () => ServiceInterface>}
24
+ */
25
+ get __services(): Record<string, () => ServiceInterface>;
18
26
  /**
19
27
  * Test if the given service is registered.
20
28
  *
@@ -51,14 +59,17 @@ export default class ServicesManager {
51
59
  /**
52
60
  * Register a new service to be enabled/disabled.
53
61
  *
54
- * @param {string} name The name of the service hook.
55
- * @param {() => ServiceInterface} useFunction The `use...` function for the service.
62
+ * @param {string} name
63
+ * The name of the service hook.
64
+ * @param {() => ServiceInterface} useFunction
65
+ * The `use...` function for the service.
56
66
  */
57
67
  register(name: string, useFunction: () => ServiceInterface): void;
58
68
  /**
59
69
  * Unregister a new service to be enabled disabled.
60
70
  *
61
- * @param {string} name The name of the service hooK
71
+ * @param {string} name
72
+ * The name of the service hook.
62
73
  */
63
74
  unregister(name: string): void;
64
75
  }