@studiometa/js-toolkit 2.0.0-rc.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Base/index.cjs +1 -2
- package/Base/index.d.ts +25 -26
- package/Base/index.js +1 -2
- package/Base/managers/ChildrenManager.d.ts +2 -2
- package/Base/managers/EventsManager.d.ts +13 -20
- package/Base/managers/OptionsManager.cjs +0 -1
- package/Base/managers/OptionsManager.d.ts +13 -10
- package/Base/managers/OptionsManager.js +0 -1
- package/Base/managers/RefsManager.d.ts +4 -4
- package/Base/managers/ServicesManager.cjs +3 -0
- package/Base/managers/ServicesManager.d.ts +14 -8
- package/Base/managers/ServicesManager.js +3 -0
- package/Base/utils.d.ts +4 -4
- package/decorators/withBreakpointManager.cjs +0 -1
- package/decorators/withBreakpointManager.d.ts +2 -2
- package/decorators/withBreakpointManager.js +0 -1
- package/decorators/withBreakpointObserver.cjs +1 -2
- package/decorators/withBreakpointObserver.d.ts +1 -1
- package/decorators/withBreakpointObserver.js +1 -2
- package/decorators/withDrag.d.ts +1 -1
- package/decorators/withExtraConfig.d.ts +1 -1
- package/decorators/withFreezedOptions.cjs +13 -3
- package/decorators/withFreezedOptions.d.ts +1 -1
- package/decorators/withFreezedOptions.js +14 -3
- package/decorators/withIntersectionObserver.cjs +0 -1
- package/decorators/withIntersectionObserver.d.ts +1 -1
- package/decorators/withIntersectionObserver.js +0 -1
- package/decorators/withMountWhenInView.cjs +0 -1
- package/decorators/withMountWhenInView.d.ts +1 -1
- package/decorators/withMountWhenInView.js +0 -1
- package/decorators/withScrolledInView.d.ts +1 -1
- package/decorators/withVue2.cjs +2 -1
- package/decorators/withVue2.js +2 -1
- package/helpers/createApp.d.ts +3 -26
- package/helpers/getInstanceFromElement.cjs +32 -0
- package/helpers/getInstanceFromElement.d.ts +14 -0
- package/helpers/getInstanceFromElement.js +10 -0
- package/helpers/importOnInteraction.d.ts +3 -5
- package/helpers/importWhenIdle.d.ts +3 -5
- package/helpers/importWhenVisible.d.ts +4 -6
- package/helpers/index.cjs +2 -0
- package/helpers/index.d.ts +1 -0
- package/helpers/index.js +8 -6
- package/helpers/utils.d.ts +3 -4
- package/package.json +1 -1
- package/services/Service.d.ts +9 -9
- package/services/drag.cjs +0 -1
- package/services/drag.d.ts +3 -3
- package/services/drag.js +0 -1
- package/services/key.d.ts +1 -1
- package/services/load.d.ts +1 -1
- package/services/pointer.d.ts +1 -1
- package/services/raf.d.ts +1 -1
- package/services/resize.cjs +2 -2
- package/services/resize.d.ts +1 -1
- package/services/resize.js +2 -2
- package/services/scroll.cjs +3 -1
- package/services/scroll.d.ts +1 -1
- package/services/scroll.js +3 -1
- package/utils/collide/boundingRectToCircle.d.ts +5 -5
- package/utils/collide/collideCircleCircle.d.ts +4 -4
- package/utils/collide/collideCircleRect.d.ts +8 -8
- package/utils/collide/collidePointCircle.d.ts +6 -6
- package/utils/collide/collidePointRect.d.ts +7 -7
- package/utils/collide/collideRectRect.d.ts +5 -5
- package/utils/css/classes.cjs +3 -3
- package/utils/css/classes.d.ts +10 -10
- package/utils/css/classes.js +3 -3
- package/utils/css/matrix.d.ts +14 -15
- package/utils/css/styles.d.ts +2 -2
- package/utils/css/transition.cjs +2 -0
- package/utils/css/transition.d.ts +2 -2
- package/utils/css/transition.js +2 -0
- package/utils/debounce.d.ts +4 -4
- package/utils/focusTrap.cjs +1 -1
- package/utils/focusTrap.d.ts +1 -0
- package/utils/focusTrap.js +1 -1
- package/utils/history.d.ts +13 -11
- package/utils/math/clamp.d.ts +1 -1
- package/utils/math/clamp01.d.ts +1 -1
- package/utils/math/damp.d.ts +6 -6
- package/utils/math/ease.d.ts +7 -7
- package/utils/math/inertiaFinalValue.d.ts +5 -5
- package/utils/math/lerp.d.ts +4 -4
- package/utils/math/map.d.ts +6 -6
- package/utils/math/round.d.ts +4 -4
- package/utils/memoize.d.ts +1 -1
- package/utils/nextFrame.d.ts +3 -4
- package/utils/nextMicrotask.d.ts +1 -1
- package/utils/nextTick.d.ts +1 -1
- package/utils/object/autoBind.d.ts +3 -3
- package/utils/object/getAllProperties.d.ts +3 -3
- package/utils/object/isObject.d.ts +1 -1
- package/utils/scrollTo.cjs +1 -1
- package/utils/scrollTo.d.ts +1 -1
- package/utils/scrollTo.js +1 -1
- package/utils/string/withLeadingCharacters.d.ts +3 -2
- package/utils/string/withLeadingSlash.d.ts +1 -1
- package/utils/string/withTrailingCharacters.d.ts +3 -2
- package/utils/string/withTrailingSlash.d.ts +1 -1
- package/utils/string/withoutLeadingCharacters.d.ts +3 -2
- package/utils/string/withoutLeadingCharactersRecursive.d.ts +3 -2
- package/utils/string/withoutLeadingSlash.d.ts +1 -1
- package/utils/string/withoutTrailingCharacters.d.ts +3 -2
- package/utils/string/withoutTrailingCharactersRecursive.d.ts +3 -2
- package/utils/string/withoutTrailingSlash.d.ts +1 -1
- package/utils/throttle.cjs +1 -1
- package/utils/throttle.d.ts +3 -3
- package/utils/throttle.js +1 -1
package/Base/index.cjs
CHANGED
|
@@ -75,7 +75,6 @@ var Base = class extends EventTarget {
|
|
|
75
75
|
if (isDev) {
|
|
76
76
|
this.__debug("constructor", this);
|
|
77
77
|
}
|
|
78
|
-
return this;
|
|
79
78
|
}
|
|
80
79
|
get $root() {
|
|
81
80
|
if (!this.$parent) {
|
|
@@ -214,7 +213,7 @@ var Base = class extends EventTarget {
|
|
|
214
213
|
}
|
|
215
214
|
__removeEmits(event) {
|
|
216
215
|
const ctor = this.__ctor;
|
|
217
|
-
const index = ctor.config.emits.
|
|
216
|
+
const index = ctor.config.emits.indexOf(event);
|
|
218
217
|
ctor.config.emits.splice(index, 1);
|
|
219
218
|
}
|
|
220
219
|
get __ctor() {
|
package/Base/index.d.ts
CHANGED
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
*/
|
|
11
11
|
/**
|
|
12
12
|
* @typedef {Object} BaseConfig
|
|
13
|
-
* @property {
|
|
14
|
-
* @property {
|
|
15
|
-
* @property {
|
|
16
|
-
* @property {
|
|
17
|
-
* @property {
|
|
13
|
+
* @property {string} name
|
|
14
|
+
* @property {boolean} [debug]
|
|
15
|
+
* @property {boolean} [log]
|
|
16
|
+
* @property {string[]} [refs]
|
|
17
|
+
* @property {string[]} [emits]
|
|
18
18
|
* @property {BaseConfigComponents} [components]
|
|
19
19
|
* @property {BaseConfigOptions} [options]
|
|
20
20
|
*/
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
export default class Base extends EventTarget {
|
|
25
25
|
/**
|
|
26
26
|
* This is a Base instance.
|
|
27
|
-
* @type {
|
|
27
|
+
* @type {boolean}
|
|
28
28
|
* @readonly
|
|
29
29
|
*/
|
|
30
30
|
static readonly $isBase: boolean;
|
|
@@ -35,8 +35,8 @@ export default class Base extends EventTarget {
|
|
|
35
35
|
/**
|
|
36
36
|
* Factory method to generate multiple instance of the class.
|
|
37
37
|
*
|
|
38
|
-
* @param {
|
|
39
|
-
* @
|
|
38
|
+
* @param {string} nameOrSelector The selector on which to mount each instance.
|
|
39
|
+
* @returns {Array<Base>} A list of the created instance.
|
|
40
40
|
*/
|
|
41
41
|
static $factory(nameOrSelector: string): Array<Base>;
|
|
42
42
|
/**
|
|
@@ -64,7 +64,7 @@ export default class Base extends EventTarget {
|
|
|
64
64
|
};
|
|
65
65
|
/**
|
|
66
66
|
* The state of the component.
|
|
67
|
-
* @type {
|
|
67
|
+
* @type {boolean}
|
|
68
68
|
*/
|
|
69
69
|
$isMounted: boolean;
|
|
70
70
|
/**
|
|
@@ -76,13 +76,13 @@ export default class Base extends EventTarget {
|
|
|
76
76
|
private __eventHandlers;
|
|
77
77
|
/**
|
|
78
78
|
* Get the root instance of the app.
|
|
79
|
-
* @
|
|
79
|
+
* @returns {Base}
|
|
80
80
|
*/
|
|
81
81
|
get $root(): Base;
|
|
82
82
|
/**
|
|
83
83
|
* Merge configuration with the parents' configurations.
|
|
84
84
|
*
|
|
85
|
-
* @
|
|
85
|
+
* @returns {BaseConfig}
|
|
86
86
|
* @private
|
|
87
87
|
*/
|
|
88
88
|
private get __config();
|
|
@@ -101,7 +101,7 @@ export default class Base extends EventTarget {
|
|
|
101
101
|
*/
|
|
102
102
|
private __refs;
|
|
103
103
|
/**
|
|
104
|
-
* @
|
|
104
|
+
* @returns {RefsManager}
|
|
105
105
|
*/
|
|
106
106
|
get $refs(): RefsManager;
|
|
107
107
|
/**
|
|
@@ -110,7 +110,7 @@ export default class Base extends EventTarget {
|
|
|
110
110
|
*/
|
|
111
111
|
private __options;
|
|
112
112
|
/**
|
|
113
|
-
* @
|
|
113
|
+
* @returns {BaseOptions}
|
|
114
114
|
*/
|
|
115
115
|
get $options(): BaseOptions;
|
|
116
116
|
/**
|
|
@@ -119,7 +119,7 @@ export default class Base extends EventTarget {
|
|
|
119
119
|
*/
|
|
120
120
|
private __children;
|
|
121
121
|
/**
|
|
122
|
-
* @
|
|
122
|
+
* @returns {ChildrenManager}
|
|
123
123
|
*/
|
|
124
124
|
get $children(): ChildrenManager;
|
|
125
125
|
/**
|
|
@@ -130,14 +130,14 @@ export default class Base extends EventTarget {
|
|
|
130
130
|
/**
|
|
131
131
|
* Small helper to log stuff.
|
|
132
132
|
*
|
|
133
|
-
* @
|
|
133
|
+
* @returns {(...args: any) => void}
|
|
134
134
|
*/
|
|
135
135
|
get $log(): (...args: any) => void;
|
|
136
136
|
/**
|
|
137
137
|
* Small helper to debug information.
|
|
138
138
|
*
|
|
139
139
|
* @private
|
|
140
|
-
* @
|
|
140
|
+
* @returns {(...args:any) => void}
|
|
141
141
|
*/
|
|
142
142
|
private get __debug();
|
|
143
143
|
/**
|
|
@@ -146,7 +146,7 @@ export default class Base extends EventTarget {
|
|
|
146
146
|
* @private
|
|
147
147
|
* @param {string} method
|
|
148
148
|
* @param {any[]} args
|
|
149
|
-
* @
|
|
149
|
+
* @returns {void}
|
|
150
150
|
*/
|
|
151
151
|
private __callMethod;
|
|
152
152
|
/**
|
|
@@ -154,27 +154,27 @@ export default class Base extends EventTarget {
|
|
|
154
154
|
*
|
|
155
155
|
* @private
|
|
156
156
|
* @param {string} event The event's name.
|
|
157
|
-
* @
|
|
157
|
+
* @returns {boolean} Wether the given event has been bound or not.
|
|
158
158
|
*/
|
|
159
159
|
private __hasEvent;
|
|
160
160
|
/**
|
|
161
161
|
* Trigger the `mounted` callback.
|
|
162
|
-
* @
|
|
162
|
+
* @returns {this}
|
|
163
163
|
*/
|
|
164
164
|
$mount(): this;
|
|
165
165
|
/**
|
|
166
166
|
* Update the instance children.
|
|
167
|
-
* @
|
|
167
|
+
* @returns {this}
|
|
168
168
|
*/
|
|
169
169
|
$update(): this;
|
|
170
170
|
/**
|
|
171
171
|
* Trigger the `destroyed` callback.
|
|
172
|
-
* @
|
|
172
|
+
* @returns {this}
|
|
173
173
|
*/
|
|
174
174
|
$destroy(): this;
|
|
175
175
|
/**
|
|
176
176
|
* Terminate a child instance when it is not needed anymore.
|
|
177
|
-
* @
|
|
177
|
+
* @returns {void}
|
|
178
178
|
*/
|
|
179
179
|
$terminate(): void;
|
|
180
180
|
/**
|
|
@@ -217,7 +217,7 @@ export default class Base extends EventTarget {
|
|
|
217
217
|
* Function to be called.
|
|
218
218
|
* @param {boolean|AddEventListenerOptions} [options]
|
|
219
219
|
* Options for the `removeEventListener` method.
|
|
220
|
-
* @
|
|
220
|
+
* @returns {() => void}
|
|
221
221
|
* A function to unbind the listener.
|
|
222
222
|
*/
|
|
223
223
|
$on(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): () => void;
|
|
@@ -230,8 +230,7 @@ export default class Base extends EventTarget {
|
|
|
230
230
|
* Function to be removed.
|
|
231
231
|
* @param {boolean|EventListenerOptions} [options]
|
|
232
232
|
* Options for the `removeEventListener` method.
|
|
233
|
-
*
|
|
234
|
-
* @return {void}
|
|
233
|
+
* @returns {void}
|
|
235
234
|
*/
|
|
236
235
|
$off(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
237
236
|
/**
|
|
@@ -240,7 +239,7 @@ export default class Base extends EventTarget {
|
|
|
240
239
|
* @param {string} event
|
|
241
240
|
* Name of the event.
|
|
242
241
|
* @param {any[]} args The arguments to apply to the functions bound to this event.
|
|
243
|
-
* @
|
|
242
|
+
* @returns {void}
|
|
244
243
|
*/
|
|
245
244
|
$emit(event: string, ...args: any[]): void;
|
|
246
245
|
}
|
package/Base/index.js
CHANGED
|
@@ -49,7 +49,6 @@ class Base extends EventTarget {
|
|
|
49
49
|
if (isDev) {
|
|
50
50
|
this.__debug("constructor", this);
|
|
51
51
|
}
|
|
52
|
-
return this;
|
|
53
52
|
}
|
|
54
53
|
get $root() {
|
|
55
54
|
if (!this.$parent) {
|
|
@@ -188,7 +187,7 @@ class Base extends EventTarget {
|
|
|
188
187
|
}
|
|
189
188
|
__removeEmits(event) {
|
|
190
189
|
const ctor = this.__ctor;
|
|
191
|
-
const index = ctor.config.emits.
|
|
190
|
+
const index = ctor.config.emits.indexOf(event);
|
|
192
191
|
ctor.config.emits.splice(index, 1);
|
|
193
192
|
}
|
|
194
193
|
get __ctor() {
|
|
@@ -49,7 +49,7 @@ export default class ChildrenManager {
|
|
|
49
49
|
*/
|
|
50
50
|
private __asyncComponentPromises;
|
|
51
51
|
/**
|
|
52
|
-
* @
|
|
52
|
+
* @returns {string[]}
|
|
53
53
|
*/
|
|
54
54
|
get registeredNames(): string[];
|
|
55
55
|
/**
|
|
@@ -75,7 +75,7 @@ export default class ChildrenManager {
|
|
|
75
75
|
* A Base class or a Promise for async components.
|
|
76
76
|
* @param {string} name
|
|
77
77
|
* The name of the child component.
|
|
78
|
-
* @
|
|
78
|
+
* @returns {Base|Promise|'terminated'}
|
|
79
79
|
* A Base instance or a Promise resolving to a Base instance.
|
|
80
80
|
* @private
|
|
81
81
|
*/
|
|
@@ -26,14 +26,14 @@ export default class EventsManager {
|
|
|
26
26
|
* ```
|
|
27
27
|
*
|
|
28
28
|
* @param {string} name
|
|
29
|
-
* @
|
|
29
|
+
* @returns {string}
|
|
30
30
|
*/
|
|
31
31
|
static normalizeName(name: string): string;
|
|
32
32
|
/**
|
|
33
33
|
* Normalize the event names from PascalCase to kebab-case.
|
|
34
34
|
*
|
|
35
35
|
* @param {string} name
|
|
36
|
-
* @
|
|
36
|
+
* @returns {string}
|
|
37
37
|
*/
|
|
38
38
|
static normalizeEventName(name: string): string;
|
|
39
39
|
/**
|
|
@@ -85,8 +85,7 @@ export default class EventsManager {
|
|
|
85
85
|
* The elements of the ref.
|
|
86
86
|
* @param {'add'|'remove'} [mode]
|
|
87
87
|
* The action to perform: add or remove the event listeners.
|
|
88
|
-
*
|
|
89
|
-
* @return {void}
|
|
88
|
+
* @returns {void}
|
|
90
89
|
* @private
|
|
91
90
|
*/
|
|
92
91
|
private __manageRef;
|
|
@@ -97,8 +96,7 @@ export default class EventsManager {
|
|
|
97
96
|
* The name of the ref.
|
|
98
97
|
* @param {HTMLElement[]} elements
|
|
99
98
|
* The elements of the ref.
|
|
100
|
-
*
|
|
101
|
-
* @return {void}
|
|
99
|
+
* @returns {void}
|
|
102
100
|
*/
|
|
103
101
|
bindRef(name: string, elements: HTMLElement[]): void;
|
|
104
102
|
/**
|
|
@@ -108,8 +106,7 @@ export default class EventsManager {
|
|
|
108
106
|
* The name of the ref.
|
|
109
107
|
* @param {HTMLElement[]} elements
|
|
110
108
|
* The elements of the ref.
|
|
111
|
-
*
|
|
112
|
-
* @return {void}
|
|
109
|
+
* @returns {void}
|
|
113
110
|
*/
|
|
114
111
|
unbindRef(name: string, elements: HTMLElement[]): void;
|
|
115
112
|
/**
|
|
@@ -121,8 +118,7 @@ export default class EventsManager {
|
|
|
121
118
|
* A base instance.
|
|
122
119
|
* @param {'add'|'remove'} [mode]
|
|
123
120
|
* The action to perform: add or remove the event listeners.
|
|
124
|
-
*
|
|
125
|
-
* @return {void}
|
|
121
|
+
* @returns {void}
|
|
126
122
|
* @private
|
|
127
123
|
*/
|
|
128
124
|
private __manageChild;
|
|
@@ -133,8 +129,7 @@ export default class EventsManager {
|
|
|
133
129
|
* The name of the ref.
|
|
134
130
|
* @param {Base} instance
|
|
135
131
|
* A base instance.
|
|
136
|
-
*
|
|
137
|
-
* @return {void}
|
|
132
|
+
* @returns {void}
|
|
138
133
|
*/
|
|
139
134
|
bindChild(name: string, instance: Base): void;
|
|
140
135
|
/**
|
|
@@ -144,8 +139,7 @@ export default class EventsManager {
|
|
|
144
139
|
* The name of the ref.
|
|
145
140
|
* @param {Base} instance
|
|
146
141
|
* A base instance.
|
|
147
|
-
*
|
|
148
|
-
* @return {void}
|
|
142
|
+
* @returns {void}
|
|
149
143
|
*/
|
|
150
144
|
unbindChild(name: string, instance: Base): void;
|
|
151
145
|
/**
|
|
@@ -153,21 +147,20 @@ export default class EventsManager {
|
|
|
153
147
|
*
|
|
154
148
|
* @param {'add'|'remove'} [mode]
|
|
155
149
|
* The action to perform: add or remove the event listeners, defaults to 'add'.
|
|
156
|
-
*
|
|
157
|
-
* @return {void}
|
|
150
|
+
* @returns {void}
|
|
158
151
|
* @private
|
|
159
152
|
*/
|
|
160
153
|
private __manageRootElement;
|
|
161
154
|
/**
|
|
162
155
|
* Bind event methods on the root element.
|
|
163
156
|
*
|
|
164
|
-
* @
|
|
157
|
+
* @returns {void}
|
|
165
158
|
*/
|
|
166
159
|
bindRootElement(): void;
|
|
167
160
|
/**
|
|
168
161
|
* Unbind event method from the root element.
|
|
169
162
|
*
|
|
170
|
-
* @
|
|
163
|
+
* @returns {void}
|
|
171
164
|
*/
|
|
172
165
|
unbindRootElement(): void;
|
|
173
166
|
/**
|
|
@@ -175,7 +168,7 @@ export default class EventsManager {
|
|
|
175
168
|
*
|
|
176
169
|
* @param {string} method
|
|
177
170
|
* @param {string} name
|
|
178
|
-
* @
|
|
171
|
+
* @returns {string}
|
|
179
172
|
* @private
|
|
180
173
|
*/
|
|
181
174
|
private __getEventNameByMethod;
|
|
@@ -183,7 +176,7 @@ export default class EventsManager {
|
|
|
183
176
|
* Get the base instance methods matching the `onSomething` pattern.
|
|
184
177
|
*
|
|
185
178
|
* @param {string} [name]
|
|
186
|
-
* @
|
|
179
|
+
* @returns {string[]}
|
|
187
180
|
* @private
|
|
188
181
|
*/
|
|
189
182
|
private __getEventMethodsByName;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @typedef {import('deepmerge').Options} DeepmergeOptions
|
|
3
3
|
* @typedef {import('../index.js').BaseConfig} BaseConfig
|
|
4
4
|
* @typedef {StringConstructor|NumberConstructor|BooleanConstructor|ArrayConstructor|ObjectConstructor} OptionType
|
|
5
|
-
* @typedef {{
|
|
5
|
+
* @typedef {{type: OptionType, default: string | number | boolean | (() => Array | Object), merge?: boolean | DeepmergeOptions}} OptionObject
|
|
6
6
|
* @typedef {OptionType | OptionObject} OptionValue
|
|
7
7
|
* @typedef {{ [name:string]: OptionValue }} OptionsSchema
|
|
8
8
|
* @typedef {{ [optionName:string]: any }} OptionsInterface
|
|
@@ -30,7 +30,8 @@ export default class OptionsManager {
|
|
|
30
30
|
* Get a property name.
|
|
31
31
|
*
|
|
32
32
|
* @param {string} name
|
|
33
|
-
* @
|
|
33
|
+
* @param {string} [prefix]
|
|
34
|
+
* @returns {string}
|
|
34
35
|
* @private
|
|
35
36
|
*/
|
|
36
37
|
private static __getPropertyName;
|
|
@@ -72,7 +73,7 @@ export default class OptionsManager {
|
|
|
72
73
|
debug: boolean;
|
|
73
74
|
/**
|
|
74
75
|
* Default value for the log property.
|
|
75
|
-
* @type {
|
|
76
|
+
* @type {boolean}
|
|
76
77
|
*/
|
|
77
78
|
log: boolean;
|
|
78
79
|
/**
|
|
@@ -80,32 +81,34 @@ export default class OptionsManager {
|
|
|
80
81
|
*
|
|
81
82
|
* @param {string} name
|
|
82
83
|
* @param {OptionValue} config
|
|
83
|
-
* @
|
|
84
|
+
* @returns {void}
|
|
84
85
|
* @private
|
|
85
86
|
*/
|
|
86
87
|
private __register;
|
|
87
88
|
/**
|
|
88
89
|
* Get an option value.
|
|
89
90
|
*
|
|
90
|
-
* @param
|
|
91
|
-
* @param
|
|
92
|
-
* @param
|
|
93
|
-
* @param
|
|
91
|
+
* @param {string} name The option name.
|
|
92
|
+
* @param {OptionType} type The option data's type.
|
|
93
|
+
* @param {any} defaultValue The default value for this option.
|
|
94
|
+
* @param {boolean|DeepmergeOptions} [merge] Wether to merge the value with the default or not.
|
|
95
|
+
* @returns {any}
|
|
94
96
|
*/
|
|
95
97
|
get(name: string, type: OptionType, defaultValue: any, merge?: boolean | DeepmergeOptions): any;
|
|
96
98
|
/**
|
|
97
99
|
* Set an option value.
|
|
98
100
|
*
|
|
99
|
-
* @param {
|
|
101
|
+
* @param {string} name The option name.
|
|
100
102
|
* @param {OptionType} type The option data's type.
|
|
101
103
|
* @param {any} value The new value for this option.
|
|
104
|
+
* @param {any} defaultValue The default value for this option.
|
|
102
105
|
*/
|
|
103
106
|
set(name: string, type: OptionType, value: any, defaultValue: any): void;
|
|
104
107
|
/**
|
|
105
108
|
* Test if the element has a given property.
|
|
106
109
|
*
|
|
107
110
|
* @param {string} prop
|
|
108
|
-
* @
|
|
111
|
+
* @returns {boolean}
|
|
109
112
|
*/
|
|
110
113
|
__hasProperty(prop: string): boolean;
|
|
111
114
|
}
|
|
@@ -12,7 +12,7 @@ export default class RefsManager {
|
|
|
12
12
|
* Normalize the name of ref.
|
|
13
13
|
*
|
|
14
14
|
* @param {string} name The original name.
|
|
15
|
-
* @
|
|
15
|
+
* @returns {string} The normalized name.
|
|
16
16
|
*/
|
|
17
17
|
static normalizeRefName(name: string): string;
|
|
18
18
|
/**
|
|
@@ -50,13 +50,13 @@ export default class RefsManager {
|
|
|
50
50
|
/**
|
|
51
51
|
* Register all refs.
|
|
52
52
|
*
|
|
53
|
-
* @
|
|
53
|
+
* @returns {void}
|
|
54
54
|
*/
|
|
55
55
|
registerAll(): void;
|
|
56
56
|
/**
|
|
57
57
|
* Unregister all refs.
|
|
58
58
|
*
|
|
59
|
-
* @
|
|
59
|
+
* @returns {void}
|
|
60
60
|
*/
|
|
61
61
|
unregisterAll(): void;
|
|
62
62
|
/**
|
|
@@ -77,7 +77,7 @@ export default class RefsManager {
|
|
|
77
77
|
* Filter refs belonging to the related Base instance.
|
|
78
78
|
*
|
|
79
79
|
* @param {HTMLElement} ref The ref to test.
|
|
80
|
-
* @
|
|
80
|
+
* @returns {boolean}
|
|
81
81
|
* @private
|
|
82
82
|
*/
|
|
83
83
|
private __filterRefsBelongingToInstance;
|
|
@@ -71,6 +71,9 @@ var ServicesManager = class {
|
|
|
71
71
|
const { has } = this.__services[service]();
|
|
72
72
|
return has(this.__base.$id);
|
|
73
73
|
}
|
|
74
|
+
get(service) {
|
|
75
|
+
return this.__services[service]().props();
|
|
76
|
+
}
|
|
74
77
|
enable(service) {
|
|
75
78
|
if (this.has(service)) {
|
|
76
79
|
return this.disable.bind(this, service);
|
|
@@ -23,47 +23,53 @@ export default class ServicesManager {
|
|
|
23
23
|
*/
|
|
24
24
|
__customServices: Record<string, () => ServiceInterface>;
|
|
25
25
|
/**
|
|
26
|
-
* @
|
|
26
|
+
* @returns {Record<string, () => ServiceInterface>}
|
|
27
27
|
*/
|
|
28
28
|
get __services(): Record<string, () => ServiceInterface>;
|
|
29
29
|
/**
|
|
30
30
|
* Test if the given service is registered.
|
|
31
31
|
*
|
|
32
32
|
* @param {ServiceName} service The name of the service.
|
|
33
|
-
* @
|
|
33
|
+
* @returns {boolean}
|
|
34
34
|
*/
|
|
35
35
|
has(service: ServiceName): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Get a service props by name.
|
|
38
|
+
* @param {ServiceName} service The name of the service.
|
|
39
|
+
* @returns {ReturnType<ServiceInterface['props']>}
|
|
40
|
+
*/
|
|
41
|
+
get(service: ServiceName): ReturnType<ServiceInterface['props']>;
|
|
36
42
|
/**
|
|
37
43
|
* Init the given service and bind it to the given instance.
|
|
38
44
|
*
|
|
39
45
|
* @param {ServiceName} service The name of the service.
|
|
40
|
-
* @
|
|
46
|
+
* @returns {() => void} A function to unbind the service.
|
|
41
47
|
*/
|
|
42
48
|
enable(service: ServiceName): () => void;
|
|
43
49
|
/**
|
|
44
50
|
* Enable all services and return methods to disable them.
|
|
45
51
|
*
|
|
46
|
-
* @
|
|
52
|
+
* @returns {Function[]}
|
|
47
53
|
*/
|
|
48
54
|
enableAll(): Function[];
|
|
49
55
|
/**
|
|
50
56
|
* Disable all services.
|
|
51
57
|
*
|
|
52
|
-
* @
|
|
58
|
+
* @returns {void}
|
|
53
59
|
*/
|
|
54
60
|
disableAll(): void;
|
|
55
61
|
/**
|
|
56
62
|
* Disable a service.
|
|
57
63
|
*
|
|
58
|
-
* @param {
|
|
59
|
-
* @
|
|
64
|
+
* @param {string} service The name of the service.
|
|
65
|
+
* @returns {void}
|
|
60
66
|
*/
|
|
61
67
|
disable(service: string): void;
|
|
62
68
|
/**
|
|
63
69
|
* Toggle a service.
|
|
64
70
|
* @param {string} service The name of the service.
|
|
65
71
|
* @param {boolean} [force] The state to force.
|
|
66
|
-
* @
|
|
72
|
+
* @returns {void}
|
|
67
73
|
*/
|
|
68
74
|
toggle(service: string, force?: boolean): void;
|
|
69
75
|
/**
|
|
@@ -45,6 +45,9 @@ class ServicesManager {
|
|
|
45
45
|
const { has } = this.__services[service]();
|
|
46
46
|
return has(this.__base.$id);
|
|
47
47
|
}
|
|
48
|
+
get(service) {
|
|
49
|
+
return this.__services[service]().props();
|
|
50
|
+
}
|
|
48
51
|
enable(service) {
|
|
49
52
|
if (this.has(service)) {
|
|
50
53
|
return this.disable.bind(this, service);
|
package/Base/utils.d.ts
CHANGED
|
@@ -5,18 +5,18 @@
|
|
|
5
5
|
* Test if an object has a method.
|
|
6
6
|
*
|
|
7
7
|
* @param {Object} obj The object to test
|
|
8
|
-
* @param {
|
|
9
|
-
* @
|
|
8
|
+
* @param {string} name The method's name
|
|
9
|
+
* @returns {boolean}
|
|
10
10
|
*/
|
|
11
11
|
export function hasMethod(obj: any, name: string): boolean;
|
|
12
12
|
/**
|
|
13
13
|
* Get a list of elements based on the name of a component.
|
|
14
14
|
*
|
|
15
|
-
* @param {
|
|
15
|
+
* @param {string} nameOrSelector
|
|
16
16
|
* The name or selector to used for this component.
|
|
17
17
|
* @param {HTMLElement|Document} element
|
|
18
18
|
* The root element on which to query the selector, defaults to `document`.
|
|
19
|
-
* @
|
|
19
|
+
* @returns {Array<HTMLElement>}
|
|
20
20
|
* A list of elements on which the component should be mounted.
|
|
21
21
|
*/
|
|
22
22
|
export function getComponentElements(nameOrSelector: string, element?: HTMLElement | Document): Array<HTMLElement>;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* BreakpointManager class.
|
|
3
3
|
* @template {BaseConstructor} T
|
|
4
4
|
* @param {T} BaseClass
|
|
5
|
-
* @param {Array<[
|
|
6
|
-
* @
|
|
5
|
+
* @param {Array<[string, BaseConstructor]>} breakpoints
|
|
6
|
+
* @returns {T}
|
|
7
7
|
*/
|
|
8
8
|
export default function withBreakpointManager<T extends typeof import("../Base").default>(BaseClass: T, breakpoints: Array<[string, BaseConstructor]>): T;
|
|
9
9
|
export type Base = import('../Base').default;
|
|
@@ -87,10 +87,9 @@ function withBreakpointObserver(BaseClass) {
|
|
|
87
87
|
});
|
|
88
88
|
mutationObserver.observe(this.$el, { attributes: true });
|
|
89
89
|
if (!hasBreakpointConfiguration(this)) {
|
|
90
|
-
return
|
|
90
|
+
return;
|
|
91
91
|
}
|
|
92
92
|
addToResize(key, this);
|
|
93
|
-
return this;
|
|
94
93
|
}
|
|
95
94
|
$mount() {
|
|
96
95
|
if (!hasBreakpointConfiguration(this)) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @template {BaseConstructor} T
|
|
5
5
|
* @param {T} BaseClass The Base class to extend from.
|
|
6
|
-
* @
|
|
6
|
+
* @returns {T}
|
|
7
7
|
*/
|
|
8
8
|
export default function withBreakpointObserver<T extends typeof import("../Base").default>(BaseClass: T): T;
|
|
9
9
|
export type Base = import('../Base').default;
|
|
@@ -61,10 +61,9 @@ function withBreakpointObserver(BaseClass) {
|
|
|
61
61
|
});
|
|
62
62
|
mutationObserver.observe(this.$el, { attributes: true });
|
|
63
63
|
if (!hasBreakpointConfiguration(this)) {
|
|
64
|
-
return
|
|
64
|
+
return;
|
|
65
65
|
}
|
|
66
66
|
addToResize(key, this);
|
|
67
|
-
return this;
|
|
68
67
|
}
|
|
69
68
|
$mount() {
|
|
70
69
|
if (!hasBreakpointConfiguration(this)) {
|
package/decorators/withDrag.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* @template {BaseConstructor} T
|
|
13
13
|
* @param {T} BaseClass
|
|
14
14
|
* @param {DragDecoratorOptions} options
|
|
15
|
-
* @
|
|
15
|
+
* @returns {T}
|
|
16
16
|
*/
|
|
17
17
|
export default function withDrag<T extends typeof import("../Base").default>(BaseClass: T, { target, ...options }?: DragDecoratorOptions): T;
|
|
18
18
|
export type Base = import('../Base').default;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @param {T} BaseClass The Base class to extend.
|
|
11
11
|
* @param {Partial<BaseConfig>} config Extra configuration to merge.
|
|
12
12
|
* @param {DeepmergeOptions} options Options for the `deepmerge` function. {@link https://github.com/TehShrike/deepmerge#options}
|
|
13
|
-
* @
|
|
13
|
+
* @returns {T}
|
|
14
14
|
*/
|
|
15
15
|
export default function withExtraConfig<T extends typeof import("../Base").default>(BaseClass: T, config: Partial<BaseConfig>, options?: DeepmergeOptions): T;
|
|
16
16
|
export type DeepmergeOptions = import('deepmerge').Options;
|