@studiometa/js-toolkit 2.0.0-beta.11 → 2.0.0-beta.15
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 +295 -0
- package/Base/index.js +114 -194
- package/Base/managers/ChildrenManager.cjs +131 -0
- package/Base/managers/ChildrenManager.js +38 -57
- package/Base/managers/EventsManager.cjs +190 -0
- package/Base/managers/EventsManager.js +72 -112
- package/Base/managers/OptionsManager.cjs +177 -0
- package/Base/managers/OptionsManager.js +54 -88
- package/Base/managers/RefsManager.cjs +104 -0
- package/Base/managers/RefsManager.js +28 -38
- package/Base/managers/ServicesManager.cjs +138 -0
- package/Base/managers/ServicesManager.js +39 -67
- package/Base/utils.cjs +46 -0
- package/Base/utils.js +12 -11
- package/decorators/index.cjs +50 -0
- package/decorators/index.js +18 -8
- package/decorators/withBreakpointManager.cjs +92 -0
- package/decorators/withBreakpointManager.js +18 -39
- package/decorators/withBreakpointObserver.cjs +122 -0
- package/decorators/withBreakpointObserver.js +44 -86
- package/decorators/withDrag.cjs +60 -0
- package/decorators/withDrag.js +24 -26
- package/decorators/withExtraConfig.cjs +50 -0
- package/decorators/withExtraConfig.js +17 -12
- package/decorators/withIntersectionObserver.cjs +67 -0
- package/decorators/withIntersectionObserver.js +29 -32
- package/decorators/withMountWhenInView.cjs +74 -0
- package/decorators/withMountWhenInView.js +31 -52
- package/decorators/withScrolledInView.cjs +121 -0
- package/decorators/withScrolledInView.js +35 -39
- package/decorators/withVue2.cjs +65 -0
- package/decorators/withVue2.js +26 -32
- package/helpers/createApp.cjs +57 -0
- package/helpers/createApp.js +12 -12
- package/helpers/importOnInteraction.cjs +57 -0
- package/helpers/importOnInteraction.js +17 -18
- package/helpers/importWhenIdle.cjs +54 -0
- package/helpers/importWhenIdle.js +14 -17
- package/helpers/importWhenVisible.cjs +55 -0
- package/helpers/importWhenVisible.js +16 -18
- package/helpers/index.cjs +42 -0
- package/helpers/index.js +10 -4
- package/helpers/utils.cjs +40 -0
- package/helpers/utils.js +7 -6
- package/index.cjs +39 -0
- package/index.js +7 -4
- package/package.json +14 -4
- package/services/Service.cjs +81 -0
- package/services/Service.js +19 -32
- package/services/drag.cjs +200 -0
- package/services/drag.js +42 -66
- package/services/index.cjs +48 -0
- package/services/index.js +16 -7
- package/services/key.cjs +111 -0
- package/services/key.js +28 -36
- package/services/load.cjs +79 -0
- package/services/load.js +17 -19
- package/services/pointer.cjs +169 -0
- package/services/pointer.js +43 -60
- package/services/raf.cjs +90 -0
- package/services/raf.js +20 -28
- package/services/resize.cjs +115 -0
- package/services/resize.js +33 -42
- package/services/scroll.cjs +138 -0
- package/services/scroll.js +26 -35
- package/utils/collide/boundingRectToCircle.cjs +39 -0
- package/utils/collide/boundingRectToCircle.d.ts +1 -1
- package/utils/collide/boundingRectToCircle.js +7 -10
- package/utils/collide/collideCircleCircle.cjs +39 -0
- package/utils/collide/collideCircleCircle.js +8 -7
- package/utils/collide/collideCircleRect.cjs +51 -0
- package/utils/collide/collideCircleRect.js +10 -12
- package/utils/collide/collidePointCircle.cjs +36 -0
- package/utils/collide/collidePointCircle.js +8 -5
- package/utils/collide/collidePointRect.cjs +33 -0
- package/utils/collide/collidePointRect.js +5 -2
- package/utils/collide/collideRectRect.cjs +33 -0
- package/utils/collide/collideRectRect.js +5 -2
- package/utils/collide/index.cjs +46 -0
- package/utils/collide/index.js +14 -6
- package/utils/css/classes.cjs +49 -0
- package/utils/css/classes.js +13 -12
- package/utils/css/index.cjs +42 -0
- package/utils/css/index.js +10 -6
- package/utils/css/matrix.cjs +35 -0
- package/utils/css/matrix.js +7 -5
- package/utils/css/styles.cjs +52 -0
- package/utils/css/styles.js +13 -12
- package/utils/css/transition.cjs +127 -0
- package/utils/css/transition.js +68 -117
- package/utils/debounce.cjs +39 -0
- package/utils/debounce.js +7 -9
- package/utils/focusTrap.cjs +89 -0
- package/utils/focusTrap.js +30 -21
- package/utils/history.cjs +96 -0
- package/utils/history.js +28 -57
- package/utils/index.cjs +58 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +30 -11
- package/utils/keyCodes.cjs +40 -0
- package/utils/keyCodes.js +5 -2
- package/utils/math/clamp.cjs +33 -0
- package/utils/math/clamp.js +5 -2
- package/utils/math/clamp01.cjs +39 -0
- package/utils/math/clamp01.js +6 -3
- package/utils/math/damp.cjs +33 -0
- package/utils/math/damp.js +5 -4
- package/utils/math/ease.cjs +93 -0
- package/utils/math/ease.js +50 -25
- package/utils/math/index.cjs +49 -0
- package/utils/math/index.js +17 -8
- package/utils/math/inertiaFinalValue.cjs +42 -0
- package/utils/math/inertiaFinalValue.js +8 -10
- package/utils/math/lerp.cjs +33 -0
- package/utils/math/lerp.js +5 -2
- package/utils/math/map.cjs +33 -0
- package/utils/math/map.js +5 -2
- package/utils/math/round.cjs +33 -0
- package/utils/math/round.js +5 -3
- package/utils/memoize.cjs +48 -0
- package/utils/memoize.js +10 -19
- package/utils/nextFrame.cjs +45 -0
- package/utils/nextFrame.js +14 -9
- package/utils/object/autoBind.cjs +56 -0
- package/utils/object/autoBind.js +12 -22
- package/utils/object/getAllProperties.cjs +42 -0
- package/utils/object/getAllProperties.js +10 -13
- package/utils/object/index.cjs +40 -0
- package/utils/object/index.js +8 -3
- package/utils/object/isObject.cjs +33 -0
- package/utils/object/isObject.js +6 -3
- package/utils/scrollTo.cjs +87 -0
- package/utils/scrollTo.js +20 -40
- package/utils/string/index.cjs +54 -0
- package/utils/string/index.js +22 -10
- package/utils/string/withLeadingCharacters.cjs +39 -0
- package/utils/string/withLeadingCharacters.js +7 -4
- package/utils/string/withLeadingSlash.cjs +39 -0
- package/utils/string/withLeadingSlash.js +7 -4
- package/utils/string/withTrailingCharacters.cjs +39 -0
- package/utils/string/withTrailingCharacters.js +7 -4
- package/utils/string/withTrailingSlash.cjs +39 -0
- package/utils/string/withTrailingSlash.js +7 -4
- package/utils/string/withoutLeadingCharacters.cjs +33 -0
- package/utils/string/withoutLeadingCharacters.js +6 -3
- package/utils/string/withoutLeadingCharactersRecursive.cjs +44 -0
- package/utils/string/withoutLeadingCharactersRecursive.js +8 -7
- package/utils/string/withoutLeadingSlash.cjs +39 -0
- package/utils/string/withoutLeadingSlash.js +7 -4
- package/utils/string/withoutTrailingCharacters.cjs +33 -0
- package/utils/string/withoutTrailingCharacters.js +6 -3
- package/utils/string/withoutTrailingCharactersRecursive.cjs +44 -0
- package/utils/string/withoutTrailingCharactersRecursive.js +8 -7
- package/utils/string/withoutTrailingSlash.cjs +39 -0
- package/utils/string/withoutTrailingSlash.js +7 -4
- package/utils/throttle.cjs +41 -0
- package/utils/throttle.js +9 -9
- package/index.modern.js +0 -1
- package/index.umd.js +0 -1
package/Base/index.js
CHANGED
|
@@ -1,344 +1,264 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { getComponentElements } from
|
|
8
|
-
import ChildrenManager from
|
|
9
|
-
import RefsManager from
|
|
10
|
-
import ServicesManager from
|
|
11
|
-
import EventsManager from
|
|
12
|
-
import OptionsManager from
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import { getComponentElements } from "./utils.js";
|
|
8
|
+
import ChildrenManager from "./managers/ChildrenManager.js";
|
|
9
|
+
import RefsManager from "./managers/RefsManager.js";
|
|
10
|
+
import ServicesManager from "./managers/ServicesManager.js";
|
|
11
|
+
import EventsManager from "./managers/EventsManager.js";
|
|
12
|
+
import OptionsManager from "./managers/OptionsManager.js";
|
|
13
|
+
let id = 0;
|
|
14
|
+
const isDev = typeof __DEV__ !== "undefined" && __DEV__;
|
|
15
|
+
function noop() {
|
|
16
|
+
}
|
|
17
|
+
class Base extends EventTarget {
|
|
18
|
+
constructor(element) {
|
|
19
|
+
super();
|
|
20
|
+
__publicField(this, "$parent", null);
|
|
21
|
+
__publicField(this, "$id");
|
|
22
|
+
__publicField(this, "$el");
|
|
23
|
+
__publicField(this, "$isMounted", false);
|
|
24
|
+
__publicField(this, "__eventHandlers", /* @__PURE__ */ new Map());
|
|
25
|
+
__publicField(this, "__services");
|
|
26
|
+
__publicField(this, "__refs");
|
|
27
|
+
__publicField(this, "__options");
|
|
28
|
+
__publicField(this, "__children");
|
|
29
|
+
__publicField(this, "__events");
|
|
30
|
+
if (!element) {
|
|
31
|
+
throw new Error("The root element must be defined.");
|
|
32
|
+
}
|
|
33
|
+
const { __config } = this;
|
|
34
|
+
if (__config.name === "Base") {
|
|
35
|
+
throw new Error("The `config.name` property is required.");
|
|
36
|
+
}
|
|
37
|
+
this.$id = `${__config.name}-${id}`;
|
|
38
|
+
id += 1;
|
|
39
|
+
this.$el = element;
|
|
40
|
+
if (!("__base__" in this.$el)) {
|
|
41
|
+
Object.defineProperty(this.$el, "__base__", {
|
|
42
|
+
get: () => this,
|
|
43
|
+
configurable: true
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
this.__options = new OptionsManager(element, __config.options || {}, __config);
|
|
47
|
+
this.__services = new ServicesManager(this);
|
|
48
|
+
this.__events = new EventsManager(element, this);
|
|
49
|
+
this.__children = new ChildrenManager(this, element, __config.components || {}, this.__events);
|
|
50
|
+
this.__refs = new RefsManager(this, element, __config.refs || [], this.__events);
|
|
51
|
+
if (isDev) {
|
|
52
|
+
this.__debug("constructor", this);
|
|
53
|
+
}
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
19
56
|
get $root() {
|
|
20
57
|
if (!this.$parent) {
|
|
21
58
|
return this;
|
|
22
59
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var root = this.$parent;
|
|
26
|
-
|
|
60
|
+
let parent = this.$parent;
|
|
61
|
+
let root = this.$parent;
|
|
27
62
|
while (parent) {
|
|
28
63
|
if (!parent.$parent) {
|
|
29
64
|
root = parent;
|
|
30
65
|
}
|
|
31
|
-
|
|
32
66
|
parent = parent.$parent;
|
|
33
67
|
}
|
|
34
|
-
|
|
35
68
|
return root;
|
|
36
69
|
}
|
|
37
|
-
|
|
38
70
|
get __config() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
config
|
|
42
|
-
} = proto.constructor;
|
|
43
|
-
|
|
71
|
+
let proto = Object.getPrototypeOf(this);
|
|
72
|
+
let { config } = proto.constructor;
|
|
44
73
|
while (proto.constructor.config && proto.constructor.$isBase) {
|
|
45
|
-
config =
|
|
46
|
-
|
|
74
|
+
config = {
|
|
75
|
+
...proto.constructor.config,
|
|
76
|
+
...config
|
|
77
|
+
};
|
|
47
78
|
if (proto.constructor.config.options) {
|
|
48
|
-
config.options =
|
|
79
|
+
config.options = {
|
|
80
|
+
...proto.constructor.config.options,
|
|
81
|
+
...config.options
|
|
82
|
+
};
|
|
49
83
|
}
|
|
50
|
-
|
|
51
84
|
if (proto.constructor.config.emits && config.emits) {
|
|
52
85
|
config.emits = [...proto.constructor.config.emits, ...config.emits];
|
|
53
86
|
}
|
|
54
|
-
|
|
55
87
|
proto = Object.getPrototypeOf(proto);
|
|
56
88
|
}
|
|
57
|
-
|
|
58
89
|
return config;
|
|
59
90
|
}
|
|
60
|
-
|
|
61
91
|
get $services() {
|
|
62
92
|
return this.__services;
|
|
63
93
|
}
|
|
64
|
-
|
|
65
94
|
get $refs() {
|
|
66
95
|
return this.__refs;
|
|
67
96
|
}
|
|
68
|
-
|
|
69
97
|
get $options() {
|
|
70
98
|
return this.__options;
|
|
71
99
|
}
|
|
72
|
-
|
|
73
100
|
get $children() {
|
|
74
101
|
return this.__children;
|
|
75
102
|
}
|
|
76
|
-
|
|
77
103
|
get $log() {
|
|
78
|
-
return this.__options.log ? window.console.log.bind(window,
|
|
104
|
+
return this.__options.log ? window.console.log.bind(window, `[${this.__config.name}]`) : noop;
|
|
79
105
|
}
|
|
80
|
-
|
|
81
106
|
get __debug() {
|
|
82
|
-
return isDev && this.__options.debug ? window.console.log.bind(window,
|
|
107
|
+
return isDev && this.__options.debug ? window.console.log.bind(window, `[debug] [${this.$id}]`) : noop;
|
|
83
108
|
}
|
|
84
|
-
|
|
85
|
-
__callMethod(method) {
|
|
86
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
87
|
-
args[_key - 1] = arguments[_key];
|
|
88
|
-
}
|
|
89
|
-
|
|
109
|
+
__callMethod(method, ...args) {
|
|
90
110
|
if (isDev) {
|
|
91
|
-
this.__debug(
|
|
111
|
+
this.__debug("callMethod", method, ...args);
|
|
92
112
|
}
|
|
93
|
-
|
|
94
113
|
this.$emit(method, ...args);
|
|
95
|
-
|
|
96
|
-
if (typeof this[method] !== 'function') {
|
|
114
|
+
if (typeof this[method] !== "function") {
|
|
97
115
|
return;
|
|
98
116
|
}
|
|
99
|
-
|
|
100
117
|
this[method].call(this, ...args);
|
|
101
|
-
|
|
102
118
|
if (isDev) {
|
|
103
119
|
this.__debug(method, this, ...args);
|
|
104
120
|
}
|
|
105
121
|
}
|
|
106
|
-
|
|
107
122
|
__hasEvent(event) {
|
|
108
|
-
|
|
109
|
-
|
|
123
|
+
const eventHandlers = this.__eventHandlers.get(event);
|
|
110
124
|
return eventHandlers && eventHandlers.size > 0;
|
|
111
125
|
}
|
|
112
|
-
|
|
113
|
-
constructor(element) {
|
|
114
|
-
super();
|
|
115
|
-
|
|
116
|
-
_defineProperty(this, "$parent", null);
|
|
117
|
-
|
|
118
|
-
_defineProperty(this, "$id", void 0);
|
|
119
|
-
|
|
120
|
-
_defineProperty(this, "$el", void 0);
|
|
121
|
-
|
|
122
|
-
_defineProperty(this, "$isMounted", false);
|
|
123
|
-
|
|
124
|
-
_defineProperty(this, "__eventHandlers", new Map());
|
|
125
|
-
|
|
126
|
-
_defineProperty(this, "__services", void 0);
|
|
127
|
-
|
|
128
|
-
_defineProperty(this, "__refs", void 0);
|
|
129
|
-
|
|
130
|
-
_defineProperty(this, "__options", void 0);
|
|
131
|
-
|
|
132
|
-
_defineProperty(this, "__children", void 0);
|
|
133
|
-
|
|
134
|
-
_defineProperty(this, "__events", void 0);
|
|
135
|
-
|
|
136
|
-
if (!element) {
|
|
137
|
-
throw new Error('The root element must be defined.');
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
var {
|
|
141
|
-
__config
|
|
142
|
-
} = this;
|
|
143
|
-
|
|
144
|
-
if (__config.name === 'Base') {
|
|
145
|
-
throw new Error('The `config.name` property is required.');
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
this.$id = "".concat(__config.name, "-").concat(id);
|
|
149
|
-
id += 1;
|
|
150
|
-
this.$el = element;
|
|
151
|
-
|
|
152
|
-
if (!('__base__' in this.$el)) {
|
|
153
|
-
Object.defineProperty(this.$el, '__base__', {
|
|
154
|
-
get: () => this,
|
|
155
|
-
configurable: true
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
this.__options = new OptionsManager(element, __config.options || {}, __config);
|
|
160
|
-
this.__services = new ServicesManager(this);
|
|
161
|
-
this.__events = new EventsManager(element, this);
|
|
162
|
-
this.__children = new ChildrenManager(this, element, __config.components || {}, this.__events);
|
|
163
|
-
this.__refs = new RefsManager(this, element, __config.refs || [], this.__events);
|
|
164
|
-
|
|
165
|
-
if (isDev) {
|
|
166
|
-
this.__debug('constructor', this);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return this;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
126
|
$mount() {
|
|
173
127
|
if (this.$isMounted) {
|
|
174
128
|
return this;
|
|
175
129
|
}
|
|
176
|
-
|
|
177
130
|
this.$isMounted = true;
|
|
178
|
-
|
|
179
131
|
if (isDev) {
|
|
180
|
-
this.__debug(
|
|
132
|
+
this.__debug("$mount");
|
|
181
133
|
}
|
|
182
|
-
|
|
183
134
|
this.$children.registerAll();
|
|
184
135
|
this.$refs.registerAll();
|
|
185
|
-
|
|
186
136
|
this.__events.bindRootElement();
|
|
187
|
-
|
|
188
137
|
this.$services.enableAll();
|
|
189
138
|
this.$children.mountAll();
|
|
190
|
-
|
|
191
|
-
this.__callMethod('mounted');
|
|
192
|
-
|
|
139
|
+
this.__callMethod("mounted");
|
|
193
140
|
return this;
|
|
194
141
|
}
|
|
195
|
-
|
|
196
142
|
$update() {
|
|
197
143
|
if (isDev) {
|
|
198
|
-
this.__debug(
|
|
144
|
+
this.__debug("$update");
|
|
199
145
|
}
|
|
200
|
-
|
|
201
146
|
this.$refs.unregisterAll();
|
|
202
147
|
this.$services.disableAll();
|
|
203
148
|
this.$children.registerAll();
|
|
204
149
|
this.$refs.registerAll();
|
|
205
150
|
this.$services.enableAll();
|
|
206
151
|
this.$children.updateAll();
|
|
207
|
-
|
|
208
|
-
this.__callMethod('updated');
|
|
209
|
-
|
|
152
|
+
this.__callMethod("updated");
|
|
210
153
|
return this;
|
|
211
154
|
}
|
|
212
|
-
|
|
213
155
|
$destroy() {
|
|
214
156
|
if (!this.$isMounted) {
|
|
215
157
|
return this;
|
|
216
158
|
}
|
|
217
|
-
|
|
218
159
|
this.$isMounted = false;
|
|
219
|
-
|
|
220
160
|
if (isDev) {
|
|
221
|
-
this.__debug(
|
|
161
|
+
this.__debug("$destroy");
|
|
222
162
|
}
|
|
223
|
-
|
|
224
163
|
this.__events.unbindRootElement();
|
|
225
|
-
|
|
226
164
|
this.$refs.unregisterAll();
|
|
227
165
|
this.$services.disableAll();
|
|
228
166
|
this.$children.destroyAll();
|
|
229
|
-
|
|
230
|
-
this.__callMethod('destroyed');
|
|
231
|
-
|
|
167
|
+
this.__callMethod("destroyed");
|
|
232
168
|
return this;
|
|
233
169
|
}
|
|
234
|
-
|
|
235
170
|
$terminate() {
|
|
236
171
|
if (isDev) {
|
|
237
|
-
this.__debug(
|
|
172
|
+
this.__debug("$terminate");
|
|
238
173
|
}
|
|
239
|
-
|
|
240
174
|
this.$destroy();
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
Object.defineProperty(this.$el, '__base__', {
|
|
245
|
-
value: 'terminated',
|
|
175
|
+
this.__callMethod("terminated");
|
|
176
|
+
Object.defineProperty(this.$el, "__base__", {
|
|
177
|
+
value: "terminated",
|
|
246
178
|
configurable: false,
|
|
247
179
|
writable: false
|
|
248
180
|
});
|
|
249
181
|
}
|
|
250
|
-
|
|
251
182
|
__testEventIsDefined(event) {
|
|
252
183
|
if (!(Array.isArray(this.__config.emits) && this.__config.emits.includes(event))) {
|
|
253
|
-
console.warn(
|
|
184
|
+
console.warn(`[${this.__config.name}]`, `The "${event}" event is missing from the configuration.`);
|
|
254
185
|
}
|
|
255
186
|
}
|
|
256
|
-
|
|
257
187
|
__addEmits(event) {
|
|
258
|
-
|
|
259
|
-
|
|
188
|
+
const ctor = this.constructor;
|
|
260
189
|
if (Array.isArray(ctor.config.emits)) {
|
|
261
190
|
ctor.config.emits.push(event);
|
|
262
191
|
} else {
|
|
263
192
|
ctor.config.emits = [event];
|
|
264
193
|
}
|
|
265
194
|
}
|
|
266
|
-
|
|
267
195
|
__removeEmits(event) {
|
|
268
|
-
|
|
269
|
-
|
|
196
|
+
const ctor = this.constructor;
|
|
197
|
+
const index = ctor.config.emits.findIndex((value) => value === event);
|
|
270
198
|
ctor.config.emits.splice(index, 1);
|
|
271
199
|
}
|
|
272
|
-
|
|
273
200
|
$on(event, listener, options) {
|
|
274
201
|
if (isDev) {
|
|
275
|
-
this.__debug(
|
|
202
|
+
this.__debug("$on", event, listener, options);
|
|
276
203
|
}
|
|
277
|
-
|
|
278
204
|
if (isDev) {
|
|
279
205
|
this.__testEventIsDefined(event);
|
|
280
206
|
}
|
|
281
|
-
|
|
282
|
-
var set = this.__eventHandlers.get(event);
|
|
283
|
-
|
|
207
|
+
let set = this.__eventHandlers.get(event);
|
|
284
208
|
if (!set) {
|
|
285
|
-
set = new Set();
|
|
286
|
-
|
|
209
|
+
set = /* @__PURE__ */ new Set();
|
|
287
210
|
this.__eventHandlers.set(event, set);
|
|
288
211
|
}
|
|
289
|
-
|
|
290
212
|
set.add(listener);
|
|
291
213
|
this.addEventListener(event, listener, options);
|
|
292
214
|
return () => {
|
|
293
215
|
this.$off(event, listener, options);
|
|
294
216
|
};
|
|
295
217
|
}
|
|
296
|
-
|
|
297
218
|
$off(event, listener, options) {
|
|
298
219
|
if (isDev) {
|
|
299
|
-
this.__debug(
|
|
220
|
+
this.__debug("$off", event, listener);
|
|
300
221
|
}
|
|
301
|
-
|
|
302
222
|
if (isDev) {
|
|
303
223
|
this.__testEventIsDefined(event);
|
|
304
224
|
}
|
|
305
|
-
|
|
306
225
|
this.__eventHandlers.get(event).delete(listener);
|
|
307
|
-
|
|
308
226
|
this.removeEventListener(event, listener, options);
|
|
309
227
|
}
|
|
310
|
-
|
|
311
|
-
$emit(event) {
|
|
312
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
313
|
-
args[_key2 - 1] = arguments[_key2];
|
|
314
|
-
}
|
|
315
|
-
|
|
228
|
+
$emit(event, ...args) {
|
|
316
229
|
if (isDev) {
|
|
317
|
-
this.__debug(
|
|
230
|
+
this.__debug("$emit", event, args);
|
|
318
231
|
}
|
|
319
|
-
|
|
320
232
|
if (isDev) {
|
|
321
233
|
this.__testEventIsDefined(event);
|
|
322
234
|
}
|
|
323
|
-
|
|
324
235
|
this.dispatchEvent(new CustomEvent(event, {
|
|
325
236
|
detail: args
|
|
326
237
|
}));
|
|
327
238
|
}
|
|
328
|
-
|
|
329
239
|
static $factory(nameOrSelector) {
|
|
330
240
|
if (!nameOrSelector) {
|
|
331
|
-
throw new Error(
|
|
241
|
+
throw new Error("The $factory method requires a component\u2019s name or selector to be specified.");
|
|
332
242
|
}
|
|
333
|
-
|
|
334
|
-
return getComponentElements(nameOrSelector).map(el => new this(el).$mount());
|
|
243
|
+
return getComponentElements(nameOrSelector).map((el) => new this(el).$mount());
|
|
335
244
|
}
|
|
336
|
-
|
|
337
245
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
246
|
+
__publicField(Base, "$isBase", true);
|
|
247
|
+
__publicField(Base, "config", {
|
|
248
|
+
name: "Base",
|
|
249
|
+
emits: [
|
|
250
|
+
"mounted",
|
|
251
|
+
"updated",
|
|
252
|
+
"destroyed",
|
|
253
|
+
"terminated",
|
|
254
|
+
"ticked",
|
|
255
|
+
"scrolled",
|
|
256
|
+
"resized",
|
|
257
|
+
"moved",
|
|
258
|
+
"loaded",
|
|
259
|
+
"keyed"
|
|
260
|
+
]
|
|
261
|
+
});
|
|
262
|
+
export {
|
|
263
|
+
Base as default
|
|
264
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
12
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(module2))
|
|
14
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
15
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return target;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
20
|
+
return (module2, temp) => {
|
|
21
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
22
|
+
};
|
|
23
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
24
|
+
var __publicField = (obj, key, value) => {
|
|
25
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// packages/js-toolkit/Base/managers/ChildrenManager.js
|
|
30
|
+
var ChildrenManager_exports = {};
|
|
31
|
+
__export(ChildrenManager_exports, {
|
|
32
|
+
default: () => ChildrenManager
|
|
33
|
+
});
|
|
34
|
+
var import_utils = require("../utils.cjs");
|
|
35
|
+
var ChildrenManager = class {
|
|
36
|
+
constructor(base, element, components, eventsManager) {
|
|
37
|
+
__publicField(this, "__base");
|
|
38
|
+
__publicField(this, "__element");
|
|
39
|
+
__publicField(this, "__components");
|
|
40
|
+
__publicField(this, "__eventsManager");
|
|
41
|
+
Object.defineProperties(this, {
|
|
42
|
+
__base: {
|
|
43
|
+
enumerable: false,
|
|
44
|
+
writable: false,
|
|
45
|
+
value: base
|
|
46
|
+
},
|
|
47
|
+
__element: {
|
|
48
|
+
enumerable: false,
|
|
49
|
+
writable: false,
|
|
50
|
+
value: element
|
|
51
|
+
},
|
|
52
|
+
__components: {
|
|
53
|
+
enumerable: false,
|
|
54
|
+
writable: false,
|
|
55
|
+
value: components
|
|
56
|
+
},
|
|
57
|
+
__eventsManager: {
|
|
58
|
+
enumerable: false,
|
|
59
|
+
writable: false,
|
|
60
|
+
value: eventsManager
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
get registeredNames() {
|
|
65
|
+
return Object.keys(this).filter((key) => !key.startsWith("__"));
|
|
66
|
+
}
|
|
67
|
+
registerAll() {
|
|
68
|
+
Object.entries(this.__components).forEach(([name, component]) => this.__register(name, component));
|
|
69
|
+
}
|
|
70
|
+
__register(name, component) {
|
|
71
|
+
Object.defineProperty(this, name, {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
configurable: true,
|
|
74
|
+
get: () => {
|
|
75
|
+
const elements = (0, import_utils.getComponentElements)(name, this.__element);
|
|
76
|
+
if (elements.length === 0) {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
return elements.map((element) => this.__getChild(element, component, name)).filter((instance) => instance !== "terminated");
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
__getChild(el, ComponentClass, name) {
|
|
84
|
+
if (el.__base__) {
|
|
85
|
+
return el.__base__;
|
|
86
|
+
}
|
|
87
|
+
if ("$isBase" in ComponentClass) {
|
|
88
|
+
const child = new ComponentClass(el);
|
|
89
|
+
Object.defineProperty(child, "$parent", { get: () => this.__base });
|
|
90
|
+
return child;
|
|
91
|
+
}
|
|
92
|
+
return ComponentClass(this.__base).then((module2) => {
|
|
93
|
+
var _a;
|
|
94
|
+
return this.__getChild(el, (_a = module2.default) != null ? _a : module2, name);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
mountAll() {
|
|
98
|
+
this.__triggerHookForAll("$mount");
|
|
99
|
+
}
|
|
100
|
+
updateAll() {
|
|
101
|
+
this.__triggerHookForAll("$update");
|
|
102
|
+
}
|
|
103
|
+
destroyAll() {
|
|
104
|
+
this.__triggerHookForAll("$destroy");
|
|
105
|
+
}
|
|
106
|
+
__triggerHookForAll(hook) {
|
|
107
|
+
this.registeredNames.forEach((name) => {
|
|
108
|
+
this[name].forEach((instance) => {
|
|
109
|
+
if (instance instanceof Promise) {
|
|
110
|
+
instance.then((resolvedInstance) => this.__triggerHook(hook, resolvedInstance, name));
|
|
111
|
+
} else {
|
|
112
|
+
this.__triggerHook(hook, instance, name);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
__triggerHook(hook, instance, name) {
|
|
118
|
+
if (hook === "$update" && !instance.$isMounted) {
|
|
119
|
+
hook = "$mount";
|
|
120
|
+
}
|
|
121
|
+
if (hook === "$update" || hook === "$destroy") {
|
|
122
|
+
this.__eventsManager.unbindChild(name, instance);
|
|
123
|
+
}
|
|
124
|
+
if (hook === "$update" || hook === "$mount") {
|
|
125
|
+
this.__eventsManager.bindChild(name, instance);
|
|
126
|
+
}
|
|
127
|
+
instance[hook]();
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
module.exports = __toCommonJS(ChildrenManager_exports);
|
|
131
|
+
if (module.exports.default) module.exports = module.exports.default;
|