@domql/element 2.5.197 → 2.5.200
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/dist/cjs/create.js +43 -85
- package/dist/cjs/define.js +1 -2
- package/dist/cjs/extend.js +4 -8
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/iterate.js +9 -18
- package/dist/cjs/methods/index.js +33 -66
- package/dist/cjs/methods/set.js +1 -2
- package/dist/cjs/methods/v2.js +6 -12
- package/dist/cjs/mixins/attr.js +4 -8
- package/dist/cjs/mixins/classList.js +8 -16
- package/dist/cjs/mixins/content.js +7 -14
- package/dist/cjs/mixins/data.js +2 -4
- package/dist/cjs/mixins/html.js +2 -4
- package/dist/cjs/mixins/scope.js +1 -2
- package/dist/cjs/mixins/state.js +2 -4
- package/dist/cjs/mixins/style.js +2 -4
- package/dist/cjs/mixins/text.js +3 -6
- package/dist/cjs/node.js +6 -12
- package/dist/cjs/props/create.js +6 -12
- package/dist/cjs/props/inherit.js +2 -4
- package/dist/cjs/props/update.js +3 -6
- package/dist/cjs/set.js +7 -14
- package/dist/cjs/update.js +24 -48
- package/dist/cjs/utils/applyParam.js +1 -2
- package/dist/cjs/utils/component.js +3 -6
- package/dist/cjs/utils/extendUtils.js +9 -18
- package/dist/cjs/utils/object.js +8 -16
- package/dist/cjs/utils/onlyResolveExtends.js +13 -26
- package/dist/cjs/utils/propEvents.js +2 -4
- package/dist/esm/create.js +43 -85
- package/dist/esm/define.js +1 -2
- package/dist/esm/extend.js +4 -8
- package/dist/esm/iterate.js +9 -18
- package/dist/esm/methods/index.js +33 -66
- package/dist/esm/methods/set.js +1 -2
- package/dist/esm/methods/v2.js +6 -12
- package/dist/esm/mixins/attr.js +4 -8
- package/dist/esm/mixins/classList.js +8 -16
- package/dist/esm/mixins/content.js +7 -14
- package/dist/esm/mixins/data.js +2 -4
- package/dist/esm/mixins/html.js +2 -4
- package/dist/esm/mixins/scope.js +1 -2
- package/dist/esm/mixins/state.js +2 -4
- package/dist/esm/mixins/style.js +2 -4
- package/dist/esm/mixins/text.js +3 -6
- package/dist/esm/node.js +6 -12
- package/dist/esm/props/create.js +6 -12
- package/dist/esm/props/inherit.js +2 -4
- package/dist/esm/props/update.js +3 -6
- package/dist/esm/set.js +7 -14
- package/dist/esm/update.js +24 -48
- package/dist/esm/utils/applyParam.js +1 -2
- package/dist/esm/utils/component.js +3 -6
- package/dist/esm/utils/extendUtils.js +9 -18
- package/dist/esm/utils/object.js +8 -16
- package/dist/esm/utils/onlyResolveExtends.js +13 -26
- package/dist/esm/utils/propEvents.js +2 -4
- package/package.json +6 -6
package/dist/cjs/create.js
CHANGED
|
@@ -63,20 +63,17 @@ const create = async (element, parent, key, options = import_options.OPTIONS.cre
|
|
|
63
63
|
(0, import_set.addMethods)(element, parent, options);
|
|
64
64
|
createScope(element, parent);
|
|
65
65
|
await (0, import_state.createState)(element, parent);
|
|
66
|
-
if (element.scope === "state")
|
|
67
|
-
element.scope = element.state;
|
|
66
|
+
if (element.scope === "state") element.scope = element.state;
|
|
68
67
|
createIfConditionFlag(element, parent);
|
|
69
68
|
(0, import_props.createProps)(element, parent, options);
|
|
70
|
-
if (element.scope === "props" || element.scope === true)
|
|
71
|
-
element.scope = element.props;
|
|
69
|
+
if (element.scope === "props" || element.scope === true) element.scope = element.props;
|
|
72
70
|
createIfConditionFlag(element, parent);
|
|
73
71
|
if (element.node && ref.__if) {
|
|
74
72
|
return (0, import_render.assignNode)(element, parent, key, attachOptions);
|
|
75
73
|
}
|
|
76
74
|
(0, import_component.applyVariant)(element, parent);
|
|
77
75
|
const onInit = await (0, import_event.triggerEventOn)("init", element, options);
|
|
78
|
-
if (onInit === false)
|
|
79
|
-
return element;
|
|
76
|
+
if (onInit === false) return element;
|
|
80
77
|
(0, import_event.triggerEventOn)("beforeClassAssign", element, options);
|
|
81
78
|
(0, import_classList.assignKeyAsClassname)(element);
|
|
82
79
|
(0, import_utils.addChildrenIfNotInOriginal)(element, parent, key);
|
|
@@ -92,15 +89,13 @@ const createBasedOnType = (element, parent, key, options) => {
|
|
|
92
89
|
}
|
|
93
90
|
return {};
|
|
94
91
|
}
|
|
95
|
-
if ((0, import_utils.isString)(key) && key.slice(0,
|
|
92
|
+
if ((0, import_utils.isString)(key) && key.slice(0, false)) {
|
|
96
93
|
if (ENV === "test" || ENV === "development") {
|
|
97
94
|
console.warn(key, "seems like to be in __ref");
|
|
98
95
|
}
|
|
99
96
|
}
|
|
100
|
-
if (element === null)
|
|
101
|
-
|
|
102
|
-
if (element === true)
|
|
103
|
-
return { text: true };
|
|
97
|
+
if (element === null) return;
|
|
98
|
+
if (element === true) return { text: true };
|
|
104
99
|
if (element.__hash) {
|
|
105
100
|
return { extend: element };
|
|
106
101
|
}
|
|
@@ -109,10 +104,8 @@ const createBasedOnType = (element, parent, key, options) => {
|
|
|
109
104
|
const redefineElement = (element, parent, key, options) => {
|
|
110
105
|
const elementWrapper = createBasedOnType(element, parent, key, options);
|
|
111
106
|
if (options.syntaxv3 || element.props && element.props.syntaxv3 || parent && parent.props && parent.props.syntaxv3) {
|
|
112
|
-
if (element.props)
|
|
113
|
-
|
|
114
|
-
else
|
|
115
|
-
element.syntaxv3 = true;
|
|
107
|
+
if (element.props) element.props.syntaxv3 = true;
|
|
108
|
+
else element.syntaxv3 = true;
|
|
116
109
|
return (0, import_component.createValidDomqlObjectFromSugar)(element, parent, key, options);
|
|
117
110
|
} else if ((0, import_utils.checkIfKeyIsComponent)(key)) {
|
|
118
111
|
return (0, import_utils.applyKeyComponentAsExtend)(elementWrapper, parent, key);
|
|
@@ -123,8 +116,7 @@ const redefineElement = (element, parent, key, options) => {
|
|
|
123
116
|
return elementWrapper;
|
|
124
117
|
};
|
|
125
118
|
const redefineParent = (element, parent, key, options) => {
|
|
126
|
-
if (!parent)
|
|
127
|
-
return import_tree.ROOT;
|
|
119
|
+
if (!parent) return import_tree.ROOT;
|
|
128
120
|
if ((0, import_utils.isNode)(parent)) {
|
|
129
121
|
const parentNodeWrapper = { key: ":root", node: parent };
|
|
130
122
|
import_tree.ROOT[`${key}_parent`] = parentNodeWrapper;
|
|
@@ -142,36 +134,30 @@ const createKey = (element, parent, key) => {
|
|
|
142
134
|
return ((0, import_utils.exec)(key, element) || key || element.key || (0, import_utils.generateKey)()).toString();
|
|
143
135
|
};
|
|
144
136
|
const addRef = (element, parent) => {
|
|
145
|
-
if (element.__ref)
|
|
146
|
-
|
|
147
|
-
else
|
|
148
|
-
element.__ref = { origin: element };
|
|
137
|
+
if (element.__ref) element.__ref.origin = element;
|
|
138
|
+
else element.__ref = { origin: element };
|
|
149
139
|
return element.__ref;
|
|
150
140
|
};
|
|
151
141
|
const switchDefaultOptions = (element, parent, options) => {
|
|
152
142
|
if (Object.keys(options).length) {
|
|
153
143
|
import_mixins.registry.defaultOptions = options;
|
|
154
|
-
if (options.ignoreChildExtend)
|
|
155
|
-
delete options.ignoreChildExtend;
|
|
144
|
+
if (options.ignoreChildExtend) delete options.ignoreChildExtend;
|
|
156
145
|
}
|
|
157
146
|
};
|
|
158
147
|
const addElementIntoParentChildren = (element, parent) => {
|
|
159
|
-
if (parent.__ref && parent.__ref.__children)
|
|
160
|
-
parent.__ref.__children.push(element.key);
|
|
148
|
+
if (parent.__ref && parent.__ref.__children) parent.__ref.__children.push(element.key);
|
|
161
149
|
};
|
|
162
150
|
const visitedElements = /* @__PURE__ */ new WeakMap();
|
|
163
151
|
const renderElement = async (element, parent, options, attachOptions) => {
|
|
164
152
|
var _a, _b, _c, _d;
|
|
165
153
|
if (visitedElements.has(element)) {
|
|
166
|
-
if (ENV === "test" || ENV === "development")
|
|
167
|
-
console.warn("Cyclic rendering detected:", element.__ref.path);
|
|
154
|
+
if (ENV === "test" || ENV === "development") console.warn("Cyclic rendering detected:", element.__ref.path);
|
|
168
155
|
}
|
|
169
156
|
visitedElements.set(element, true);
|
|
170
157
|
const { __ref: ref, key } = element;
|
|
171
158
|
const createNestedChild = async () => {
|
|
172
159
|
const isInfiniteLoopDetected = (0, import_utils.detectInfiniteLoop)(ref.path);
|
|
173
|
-
if (ref.__uniqId || isInfiniteLoopDetected)
|
|
174
|
-
return;
|
|
160
|
+
if (ref.__uniqId || isInfiniteLoopDetected) return;
|
|
175
161
|
await (0, import_node.createNode)(element, options);
|
|
176
162
|
ref.__uniqId = Math.random();
|
|
177
163
|
};
|
|
@@ -182,18 +168,14 @@ const renderElement = async (element, parent, options, attachOptions) => {
|
|
|
182
168
|
await createNestedChild();
|
|
183
169
|
} catch (e) {
|
|
184
170
|
const path = ref.path;
|
|
185
|
-
if (path.includes("ComponentsGrid"))
|
|
186
|
-
|
|
187
|
-
if (path.includes("demoComponent"))
|
|
188
|
-
path.splice(0, path.indexOf("demoComponent") + 1);
|
|
171
|
+
if (path.includes("ComponentsGrid")) path.splice(0, path.indexOf("ComponentsGrid") + 2);
|
|
172
|
+
if (path.includes("demoComponent")) path.splice(0, path.indexOf("demoComponent") + 1);
|
|
189
173
|
const isDemoComponent = (_b = (_a = element.lookup((el) => el.state.key)) == null ? void 0 : _a.state) == null ? void 0 : _b.key;
|
|
190
174
|
element.warn("Error happened in:", isDemoComponent ? isDemoComponent + " " : "" + path.join("."));
|
|
191
175
|
element.verbose();
|
|
192
176
|
element.error(e, options);
|
|
193
|
-
if ((_c = element.on) == null ? void 0 : _c.error)
|
|
194
|
-
|
|
195
|
-
if ((_d = element.props) == null ? void 0 : _d.onError)
|
|
196
|
-
element.props.onError(e, element, element.state, element.context, options);
|
|
177
|
+
if ((_c = element.on) == null ? void 0 : _c.error) element.on.error(e, element, element.state, element.context, options);
|
|
178
|
+
if ((_d = element.props) == null ? void 0 : _d.onError) element.props.onError(e, element, element.state, element.context, options);
|
|
197
179
|
}
|
|
198
180
|
}
|
|
199
181
|
if (!ref.__if) {
|
|
@@ -220,55 +202,37 @@ const applyValueAsText = (element, parent, key) => {
|
|
|
220
202
|
};
|
|
221
203
|
const applyContext = (element, parent, options) => {
|
|
222
204
|
const forcedOptionsContext = options.context && !import_tree.ROOT.context && !element.context;
|
|
223
|
-
if (forcedOptionsContext)
|
|
224
|
-
|
|
225
|
-
if (!element.context)
|
|
226
|
-
element.context = parent.context || options.context || import_tree.ROOT.context;
|
|
205
|
+
if (forcedOptionsContext) import_tree.ROOT.context = options.context;
|
|
206
|
+
if (!element.context) element.context = parent.context || options.context || import_tree.ROOT.context;
|
|
227
207
|
};
|
|
228
208
|
const createScope = (element, parent) => {
|
|
229
209
|
const { __ref: ref } = element;
|
|
230
|
-
if (!element.scope)
|
|
231
|
-
element.scope = parent.scope || ref.root.scope || {};
|
|
210
|
+
if (!element.scope) element.scope = parent.scope || ref.root.scope || {};
|
|
232
211
|
};
|
|
233
212
|
const createIfConditionFlag = (element, parent) => {
|
|
234
213
|
const { __ref: ref } = element;
|
|
235
214
|
if ((0, import_utils.isFunction)(element.if) && !element.if(element, element.state, element.context)) {
|
|
236
215
|
delete ref.__if;
|
|
237
|
-
} else
|
|
238
|
-
ref.__if = true;
|
|
216
|
+
} else ref.__if = true;
|
|
239
217
|
};
|
|
240
218
|
const addCaching = (element, parent) => {
|
|
241
219
|
const { __ref: ref, key } = element;
|
|
242
220
|
let { __ref: parentRef } = parent;
|
|
243
|
-
if (!element.transform)
|
|
244
|
-
|
|
245
|
-
if (!ref.
|
|
246
|
-
|
|
247
|
-
if (!ref.
|
|
248
|
-
|
|
249
|
-
if (!ref.
|
|
250
|
-
|
|
251
|
-
if (!ref.
|
|
252
|
-
|
|
253
|
-
if (
|
|
254
|
-
ref.__class = {};
|
|
255
|
-
if (!ref.__classNames)
|
|
256
|
-
ref.__classNames = {};
|
|
257
|
-
if (!ref.__attr)
|
|
258
|
-
ref.__attr = {};
|
|
259
|
-
if (!ref.__changes)
|
|
260
|
-
ref.__changes = [];
|
|
261
|
-
if (!ref.__children)
|
|
262
|
-
ref.__children = [];
|
|
263
|
-
if ((0, import_utils.checkIfKeyIsComponent)(key))
|
|
264
|
-
ref.__componentKey = key.split("_")[0].split(".")[0].split("+")[0];
|
|
221
|
+
if (!element.transform) element.transform = {};
|
|
222
|
+
if (!ref.__cached) ref.__cached = {};
|
|
223
|
+
if (!ref.__defineCache) ref.__defineCache = {};
|
|
224
|
+
if (!ref.__exec) ref.__exec = {};
|
|
225
|
+
if (!ref.__execProps) ref.__execProps = {};
|
|
226
|
+
if (!ref.__class) ref.__class = {};
|
|
227
|
+
if (!ref.__classNames) ref.__classNames = {};
|
|
228
|
+
if (!ref.__attr) ref.__attr = {};
|
|
229
|
+
if (!ref.__changes) ref.__changes = [];
|
|
230
|
+
if (!ref.__children) ref.__children = [];
|
|
231
|
+
if ((0, import_utils.checkIfKeyIsComponent)(key)) ref.__componentKey = key.split("_")[0].split(".")[0].split("+")[0];
|
|
265
232
|
const hasRoot = parent && parent.key === ":root";
|
|
266
|
-
if (!ref.root)
|
|
267
|
-
|
|
268
|
-
if (!parentRef)
|
|
269
|
-
parentRef = parent.ref = {};
|
|
270
|
-
if (!parentRef.path)
|
|
271
|
-
parentRef.path = [];
|
|
233
|
+
if (!ref.root) ref.root = hasRoot ? element : parentRef.root;
|
|
234
|
+
if (!parentRef) parentRef = parent.ref = {};
|
|
235
|
+
if (!parentRef.path) parentRef.path = [];
|
|
272
236
|
ref.path = parentRef.path.concat(element.key);
|
|
273
237
|
};
|
|
274
238
|
const onlyResolveExtends = (element, parent, key, options) => {
|
|
@@ -278,17 +242,14 @@ const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
278
242
|
(0, import_set.addMethods)(element, parent, options);
|
|
279
243
|
createScope(element, parent);
|
|
280
244
|
(0, import_state.createState)(element, parent);
|
|
281
|
-
if (element.scope === "state")
|
|
282
|
-
element.scope = element.state;
|
|
245
|
+
if (element.scope === "state") element.scope = element.state;
|
|
283
246
|
createIfConditionFlag(element, parent);
|
|
284
247
|
(0, import_props.createProps)(element, parent, options);
|
|
285
|
-
if (element.scope === "props" || element.scope === true)
|
|
286
|
-
element.scope = element.props;
|
|
248
|
+
if (element.scope === "props" || element.scope === true) element.scope = element.props;
|
|
287
249
|
if (element.node && ref.__if) {
|
|
288
250
|
parent[key || element.key] = element;
|
|
289
251
|
}
|
|
290
|
-
if (!element.props)
|
|
291
|
-
element.props = {};
|
|
252
|
+
if (!element.props) element.props = {};
|
|
292
253
|
(0, import_component.applyVariant)(element, parent);
|
|
293
254
|
addElementIntoParentChildren(element, parent);
|
|
294
255
|
}
|
|
@@ -296,8 +257,7 @@ const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
296
257
|
(0, import_iterate.throughInitialDefine)(element);
|
|
297
258
|
(0, import_iterate.throughInitialExec)(element);
|
|
298
259
|
for (const k in element) {
|
|
299
|
-
if ((0, import_utils.isUndefined)(element[k]) || (0, import_methods.isMethod)(k, element) || (0, import_utils.isObject)((import_mixins.registry.default || import_mixins.registry)[k]) || (0, import_utils.isVariant)(k))
|
|
300
|
-
continue;
|
|
260
|
+
if ((0, import_utils.isUndefined)(element[k]) || (0, import_methods.isMethod)(k, element) || (0, import_utils.isObject)((import_mixins.registry.default || import_mixins.registry)[k]) || (0, import_utils.isVariant)(k)) continue;
|
|
301
261
|
const hasDefine = element.define && element.define[k];
|
|
302
262
|
const contextHasDefine = element.context && element.context.define && element.context.define[k];
|
|
303
263
|
const optionsHasDefine = options.define && options.define[k];
|
|
@@ -322,10 +282,8 @@ const applyMediaProps = (element, parent, key) => {
|
|
|
322
282
|
const { props } = element;
|
|
323
283
|
if (props) {
|
|
324
284
|
props.display = "none";
|
|
325
|
-
if (props[key])
|
|
326
|
-
|
|
327
|
-
else
|
|
328
|
-
props[key] = { display: props.display || "block" };
|
|
285
|
+
if (props[key]) props[key].display = props.display;
|
|
286
|
+
else props[key] = { display: props.display || "block" };
|
|
329
287
|
return element;
|
|
330
288
|
} else {
|
|
331
289
|
return {
|
package/dist/cjs/define.js
CHANGED
|
@@ -28,7 +28,6 @@ var define_default = (params, options = {}) => {
|
|
|
28
28
|
for (const param in params) {
|
|
29
29
|
if (import_mixins.REGISTRY[param] && !overwrite) {
|
|
30
30
|
(0, import_report.report)("OverwriteToBuiltin", param);
|
|
31
|
-
} else
|
|
32
|
-
import_mixins.REGISTRY[param] = params[param];
|
|
31
|
+
} else import_mixins.REGISTRY[param] = params[param];
|
|
33
32
|
}
|
|
34
33
|
};
|
package/dist/cjs/extend.js
CHANGED
|
@@ -26,16 +26,14 @@ var import_utils2 = require("./utils/index.js");
|
|
|
26
26
|
const ENV = "development";
|
|
27
27
|
let mainExtend;
|
|
28
28
|
const applyExtend = (element, parent, options = {}) => {
|
|
29
|
-
if ((0, import_utils.isFunction)(element))
|
|
30
|
-
element = (0, import_utils.exec)(element, parent);
|
|
29
|
+
if ((0, import_utils.isFunction)(element)) element = (0, import_utils.exec)(element, parent);
|
|
31
30
|
const { props, __ref } = element;
|
|
32
31
|
let extend = (props == null ? void 0 : props.extends) || element.extends || element.extend;
|
|
33
32
|
const variant = props == null ? void 0 : props.variant;
|
|
34
33
|
const context = element.context || parent.context;
|
|
35
34
|
extend = (0, import_utils2.fallbackStringExtend)(extend, context, options, variant);
|
|
36
35
|
const extendStack = (0, import_utils2.getExtendStack)(extend, context);
|
|
37
|
-
if (ENV !== "test" || ENV !== "development")
|
|
38
|
-
delete element.extend;
|
|
36
|
+
if (ENV !== "test" || ENV !== "development") delete element.extend;
|
|
39
37
|
let childExtendStack = [];
|
|
40
38
|
if (parent) {
|
|
41
39
|
element.parent = parent;
|
|
@@ -61,8 +59,7 @@ const applyExtend = (element, parent, options = {}) => {
|
|
|
61
59
|
stack = extendStack;
|
|
62
60
|
} else if (childExtendLength) {
|
|
63
61
|
stack = childExtendStack;
|
|
64
|
-
} else if (!context.defaultExtends)
|
|
65
|
-
return element;
|
|
62
|
+
} else if (!context.defaultExtends) return element;
|
|
66
63
|
if (context.defaultExtends) {
|
|
67
64
|
if (!mainExtend) {
|
|
68
65
|
const defaultOptionsExtend = (0, import_utils2.getExtendStack)(context.defaultExtends, context);
|
|
@@ -71,8 +68,7 @@ const applyExtend = (element, parent, options = {}) => {
|
|
|
71
68
|
}
|
|
72
69
|
stack = [].concat(stack, mainExtend);
|
|
73
70
|
}
|
|
74
|
-
if (__ref)
|
|
75
|
-
__ref.__extend = stack;
|
|
71
|
+
if (__ref) __ref.__extend = stack;
|
|
76
72
|
let mergedExtend = (0, import_utils2.cloneAndMergeArrayExtend)(stack);
|
|
77
73
|
const COMPONENTS = context && context.components || options.components;
|
|
78
74
|
const component = (0, import_utils.exec)(element.component || mergedExtend.component, element);
|
package/dist/cjs/index.js
CHANGED
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var index_exports = {};
|
|
30
|
+
__export(index_exports, {
|
|
31
31
|
TREE: () => import_tree.TREE,
|
|
32
32
|
create: () => import_create.default,
|
|
33
33
|
createNode: () => import_node.default,
|
|
@@ -35,7 +35,7 @@ __export(element_exports, {
|
|
|
35
35
|
set: () => import_set.default,
|
|
36
36
|
update: () => import_update.default
|
|
37
37
|
});
|
|
38
|
-
module.exports = __toCommonJS(
|
|
38
|
+
module.exports = __toCommonJS(index_exports);
|
|
39
39
|
var import_tree = require("./tree");
|
|
40
40
|
var import_create = __toESM(require("./create"), 1);
|
|
41
41
|
var import_node = __toESM(require("./node"), 1);
|
package/dist/cjs/iterate.js
CHANGED
|
@@ -31,8 +31,7 @@ var import_methods = require("./methods/index.js");
|
|
|
31
31
|
const throughInitialExec = (element, exclude = {}) => {
|
|
32
32
|
const { __ref: ref } = element;
|
|
33
33
|
for (const param in element) {
|
|
34
|
-
if (exclude[param])
|
|
35
|
-
continue;
|
|
34
|
+
if (exclude[param]) continue;
|
|
36
35
|
const prop = element[param];
|
|
37
36
|
if ((0, import_utils.isFunction)(prop) && !(0, import_methods.isMethod)(param, element) && !(0, import_utils.isVariant)(param)) {
|
|
38
37
|
ref.__exec[param] = prop;
|
|
@@ -46,8 +45,7 @@ const throughUpdatedExec = (element, options = { excludes: import_utils2.METHODS
|
|
|
46
45
|
for (const param in ref.__exec) {
|
|
47
46
|
const prop = element[param];
|
|
48
47
|
const isDefinedParam = ref.__defineCache[param];
|
|
49
|
-
if (isDefinedParam)
|
|
50
|
-
continue;
|
|
48
|
+
if (isDefinedParam) continue;
|
|
51
49
|
const newExec = ref.__exec[param](element, element.state, element.context);
|
|
52
50
|
const execReturnsString = (0, import_utils.isString)(newExec) || (0, import_utils.isNumber)(newExec);
|
|
53
51
|
if (prop && prop.node && execReturnsString) {
|
|
@@ -82,10 +80,8 @@ const throughInitialDefine = (element) => {
|
|
|
82
80
|
const { define, context, __ref: ref } = element;
|
|
83
81
|
let defineObj = {};
|
|
84
82
|
const hasGlobalDefine = context && (0, import_utils.isObject)(context.define);
|
|
85
|
-
if ((0, import_utils.isObject)(define))
|
|
86
|
-
|
|
87
|
-
if (hasGlobalDefine)
|
|
88
|
-
defineObj = { ...defineObj, ...context.define };
|
|
83
|
+
if ((0, import_utils.isObject)(define)) defineObj = { ...define };
|
|
84
|
+
if (hasGlobalDefine) defineObj = { ...defineObj, ...context.define };
|
|
89
85
|
for (const param in defineObj) {
|
|
90
86
|
let elementProp = element[param];
|
|
91
87
|
if ((0, import_utils.isFunction)(elementProp) && !(0, import_methods.isMethod)(param, element) && !(0, import_utils.isVariant)(param)) {
|
|
@@ -97,8 +93,7 @@ const throughInitialDefine = (element) => {
|
|
|
97
93
|
}
|
|
98
94
|
}
|
|
99
95
|
const execParam = defineObj[param](elementProp, element, element.state, element.context);
|
|
100
|
-
if (execParam)
|
|
101
|
-
element[param] = execParam;
|
|
96
|
+
if (execParam) element[param] = execParam;
|
|
102
97
|
}
|
|
103
98
|
return element;
|
|
104
99
|
};
|
|
@@ -106,18 +101,14 @@ const throughUpdatedDefine = (element) => {
|
|
|
106
101
|
const { context, define, __ref: ref } = element;
|
|
107
102
|
const changes = {};
|
|
108
103
|
let obj = {};
|
|
109
|
-
if ((0, import_utils.isObject)(define))
|
|
110
|
-
|
|
111
|
-
if ((0, import_utils.isObject)(context && context.define))
|
|
112
|
-
obj = { ...obj, ...context.define };
|
|
104
|
+
if ((0, import_utils.isObject)(define)) obj = { ...define };
|
|
105
|
+
if ((0, import_utils.isObject)(context && context.define)) obj = { ...obj, ...context.define };
|
|
113
106
|
for (const param in obj) {
|
|
114
107
|
const execParam = ref.__exec[param];
|
|
115
|
-
if (execParam)
|
|
116
|
-
ref.__defineCache[param] = execParam(element, element.state, element.context);
|
|
108
|
+
if (execParam) ref.__defineCache[param] = execParam(element, element.state, element.context);
|
|
117
109
|
const cached = (0, import_utils.exec)(ref.__defineCache[param], element);
|
|
118
110
|
const newExecParam = obj[param](cached, element, element.state, element.context);
|
|
119
|
-
if (newExecParam)
|
|
120
|
-
element[param] = newExecParam;
|
|
111
|
+
if (newExecParam) element[param] = newExecParam;
|
|
121
112
|
}
|
|
122
113
|
return changes;
|
|
123
114
|
};
|
|
@@ -53,15 +53,12 @@ function spotByPath(path) {
|
|
|
53
53
|
const element = this;
|
|
54
54
|
const arr = [].concat(path);
|
|
55
55
|
let active = import_tree.TREE[arr[0]];
|
|
56
|
-
if (!arr || !arr.length)
|
|
57
|
-
return console.log(arr, "on", element.key, "is undefined");
|
|
56
|
+
if (!arr || !arr.length) return console.log(arr, "on", element.key, "is undefined");
|
|
58
57
|
while (active.key === arr[0]) {
|
|
59
58
|
arr.shift();
|
|
60
|
-
if (!arr.length)
|
|
61
|
-
break;
|
|
59
|
+
if (!arr.length) break;
|
|
62
60
|
active = active[arr[0]];
|
|
63
|
-
if (!active)
|
|
64
|
-
return;
|
|
61
|
+
if (!active) return;
|
|
65
62
|
}
|
|
66
63
|
return active;
|
|
67
64
|
}
|
|
@@ -69,21 +66,15 @@ function lookup(param) {
|
|
|
69
66
|
const el = this;
|
|
70
67
|
let { parent } = el;
|
|
71
68
|
if ((0, import_utils.isFunction)(param)) {
|
|
72
|
-
if (parent.state && param(parent, parent.state, parent.context))
|
|
73
|
-
|
|
74
|
-
else
|
|
75
|
-
return parent.lookup(param);
|
|
76
|
-
else
|
|
77
|
-
return;
|
|
69
|
+
if (parent.state && param(parent, parent.state, parent.context)) return parent;
|
|
70
|
+
else if (parent.parent) return parent.lookup(param);
|
|
71
|
+
else return;
|
|
78
72
|
}
|
|
79
|
-
if (el[param])
|
|
80
|
-
return el[param];
|
|
73
|
+
if (el[param]) return el[param];
|
|
81
74
|
while (parent.param !== param) {
|
|
82
|
-
if (parent[param])
|
|
83
|
-
return parent[param];
|
|
75
|
+
if (parent[param]) return parent[param];
|
|
84
76
|
parent = parent.parent;
|
|
85
|
-
if (!parent)
|
|
86
|
-
return;
|
|
77
|
+
if (!parent) return;
|
|
87
78
|
}
|
|
88
79
|
return parent;
|
|
89
80
|
}
|
|
@@ -95,8 +86,7 @@ function lookdown(param) {
|
|
|
95
86
|
for (let i = 0; i < children.length; i++) {
|
|
96
87
|
const v = children[i];
|
|
97
88
|
const childElem = el[v];
|
|
98
|
-
if (v === param)
|
|
99
|
-
return childElem;
|
|
89
|
+
if (v === param) return childElem;
|
|
100
90
|
else if ((0, import_utils.isFunction)(param)) {
|
|
101
91
|
const exec = param(childElem, childElem.state, childElem.context);
|
|
102
92
|
if (childElem.state && exec) {
|
|
@@ -104,8 +94,7 @@ function lookdown(param) {
|
|
|
104
94
|
}
|
|
105
95
|
}
|
|
106
96
|
const lookdown2 = (_a = childElem == null ? void 0 : childElem.lookdown) == null ? void 0 : _a.call(childElem, param);
|
|
107
|
-
if (lookdown2)
|
|
108
|
-
return lookdown2;
|
|
97
|
+
if (lookdown2) return lookdown2;
|
|
109
98
|
}
|
|
110
99
|
}
|
|
111
100
|
function lookdownAll(param, results = []) {
|
|
@@ -116,12 +105,10 @@ function lookdownAll(param, results = []) {
|
|
|
116
105
|
for (let i = 0; i < children.length; i++) {
|
|
117
106
|
const v = children[i];
|
|
118
107
|
const childElem = el[v];
|
|
119
|
-
if (v === param)
|
|
120
|
-
results.push(childElem);
|
|
108
|
+
if (v === param) results.push(childElem);
|
|
121
109
|
else if ((0, import_utils.isFunction)(param)) {
|
|
122
110
|
const exec = param(childElem, childElem.state, childElem.context);
|
|
123
|
-
if (childElem.state && exec)
|
|
124
|
-
results.push(childElem);
|
|
111
|
+
if (childElem.state && exec) results.push(childElem);
|
|
125
112
|
}
|
|
126
113
|
(_a = childElem == null ? void 0 : childElem.lookdownAll) == null ? void 0 : _a.call(childElem, param, results);
|
|
127
114
|
}
|
|
@@ -130,32 +117,26 @@ function lookdownAll(param, results = []) {
|
|
|
130
117
|
function setNodeStyles(params = {}) {
|
|
131
118
|
var _a;
|
|
132
119
|
const el = this;
|
|
133
|
-
if (!((_a = el.node) == null ? void 0 : _a.style))
|
|
134
|
-
return;
|
|
120
|
+
if (!((_a = el.node) == null ? void 0 : _a.style)) return;
|
|
135
121
|
for (const param in params) {
|
|
136
122
|
const value = params[param];
|
|
137
123
|
const childElem = el[param];
|
|
138
|
-
if ((0, import_utils.isObject)(value) && childElem)
|
|
139
|
-
|
|
140
|
-
else
|
|
141
|
-
el.node.style[param] = value;
|
|
124
|
+
if ((0, import_utils.isObject)(value) && childElem) setNodeStyles.call(childElem, value);
|
|
125
|
+
else el.node.style[param] = value;
|
|
142
126
|
}
|
|
143
127
|
return el;
|
|
144
128
|
}
|
|
145
129
|
function remove(opts) {
|
|
146
130
|
const element = this;
|
|
147
131
|
const beforeRemoveReturns = (0, import_event.triggerEventOn)("beforeRemove", element, opts);
|
|
148
|
-
if (beforeRemoveReturns === false)
|
|
149
|
-
|
|
150
|
-
if ((0, import_utils.isFunction)(element.node.remove))
|
|
151
|
-
element.node.remove();
|
|
132
|
+
if (beforeRemoveReturns === false) return element;
|
|
133
|
+
if ((0, import_utils.isFunction)(element.node.remove)) element.node.remove();
|
|
152
134
|
else if (!(0, import_utils.isProduction)()) {
|
|
153
135
|
console.warn("This item cant be removed");
|
|
154
136
|
element.log();
|
|
155
137
|
}
|
|
156
138
|
delete element.parent[element.key];
|
|
157
|
-
if (element.parent.__ref)
|
|
158
|
-
element.parent.__ref.__children = (0, import_utils.removeValueFromArray)(element.parent.__ref.__children, element.key);
|
|
139
|
+
if (element.parent.__ref) element.parent.__ref.__children = (0, import_utils.removeValueFromArray)(element.parent.__ref.__children, element.key);
|
|
159
140
|
(0, import_event.triggerEventOn)("remove", element, opts);
|
|
160
141
|
}
|
|
161
142
|
function get(param) {
|
|
@@ -164,8 +145,7 @@ function get(param) {
|
|
|
164
145
|
}
|
|
165
146
|
function setProps(param, options) {
|
|
166
147
|
const element = this;
|
|
167
|
-
if (!param || !element.props)
|
|
168
|
-
return;
|
|
148
|
+
if (!param || !element.props) return;
|
|
169
149
|
element.update({ props: param }, options);
|
|
170
150
|
return element;
|
|
171
151
|
}
|
|
@@ -192,23 +172,19 @@ function parse(excl = []) {
|
|
|
192
172
|
const obj = {};
|
|
193
173
|
const keyList = keys.call(element);
|
|
194
174
|
keyList.forEach((v) => {
|
|
195
|
-
if (excl.includes(v))
|
|
196
|
-
return;
|
|
175
|
+
if (excl.includes(v)) return;
|
|
197
176
|
const val = element[v];
|
|
198
177
|
if (v === "state") {
|
|
199
|
-
if (element.__ref && !element.__ref.__hasRootState)
|
|
200
|
-
return;
|
|
178
|
+
if (element.__ref && !element.__ref.__hasRootState) return;
|
|
201
179
|
const parsedVal = (0, import_utils.isFunction)(val && val.parse) ? val.parse() : val;
|
|
202
180
|
obj[v] = (0, import_utils.isFunction)(parsedVal) ? parsedVal : JSON.parse(JSON.stringify(parsedVal || {}));
|
|
203
181
|
} else if (v === "scope") {
|
|
204
|
-
if (element.__ref && !element.__ref.__hasRootScope)
|
|
205
|
-
return;
|
|
182
|
+
if (element.__ref && !element.__ref.__hasRootScope) return;
|
|
206
183
|
obj[v] = JSON.parse(JSON.stringify(val || {}));
|
|
207
184
|
} else if (v === "props") {
|
|
208
185
|
const { __element, update, ...props } = element[v];
|
|
209
186
|
obj[v] = props;
|
|
210
|
-
} else if ((0, import_utils.isDefined)(val) && Object.hasOwnProperty.call(element, v))
|
|
211
|
-
obj[v] = val;
|
|
187
|
+
} else if ((0, import_utils.isDefined)(val) && Object.hasOwnProperty.call(element, v)) obj[v] = val;
|
|
212
188
|
});
|
|
213
189
|
return obj;
|
|
214
190
|
}
|
|
@@ -216,8 +192,7 @@ function parseDeep(excl = []) {
|
|
|
216
192
|
const element = this;
|
|
217
193
|
const obj = parse.call(element, excl);
|
|
218
194
|
for (const v in obj) {
|
|
219
|
-
if (excl.includes(v))
|
|
220
|
-
return;
|
|
195
|
+
if (excl.includes(v)) return;
|
|
221
196
|
if ((0, import_utils.isObjectLike)(obj[v])) {
|
|
222
197
|
obj[v] = parseDeep.call(obj[v], excl);
|
|
223
198
|
}
|
|
@@ -225,8 +200,7 @@ function parseDeep(excl = []) {
|
|
|
225
200
|
return obj;
|
|
226
201
|
}
|
|
227
202
|
function verbose(...args) {
|
|
228
|
-
if (ENV !== "test" && ENV !== "development")
|
|
229
|
-
return;
|
|
203
|
+
if (ENV !== "test" && ENV !== "development") return;
|
|
230
204
|
const element = this;
|
|
231
205
|
const { __ref: ref } = element;
|
|
232
206
|
console.groupCollapsed(element.key);
|
|
@@ -255,10 +229,8 @@ function warn(...params) {
|
|
|
255
229
|
function error(...params) {
|
|
256
230
|
var _a, _b;
|
|
257
231
|
if (ENV === "test" || ENV === "development") {
|
|
258
|
-
if ((_a = params[params.length - 1]) == null ? void 0 : _a.debugger)
|
|
259
|
-
|
|
260
|
-
if ((_b = params[params.length - 1]) == null ? void 0 : _b.verbose)
|
|
261
|
-
verbose.call(this);
|
|
232
|
+
if ((_a = params[params.length - 1]) == null ? void 0 : _a.debugger) debugger;
|
|
233
|
+
if ((_b = params[params.length - 1]) == null ? void 0 : _b.verbose) verbose.call(this);
|
|
262
234
|
throw new Error(...params);
|
|
263
235
|
}
|
|
264
236
|
}
|
|
@@ -274,17 +246,14 @@ function previousElement(el) {
|
|
|
274
246
|
const element = el || this;
|
|
275
247
|
const { key, parent } = element;
|
|
276
248
|
const { __children } = parent.__ref;
|
|
277
|
-
if (!__children)
|
|
278
|
-
return;
|
|
249
|
+
if (!__children) return;
|
|
279
250
|
const currentIndex = __children.indexOf(key);
|
|
280
251
|
return parent[__children[currentIndex - 1]];
|
|
281
252
|
}
|
|
282
253
|
function variables(obj = {}) {
|
|
283
254
|
const element = this;
|
|
284
|
-
if (!element.data)
|
|
285
|
-
|
|
286
|
-
if (!element.data.varCaches)
|
|
287
|
-
element.data.varCaches = {};
|
|
255
|
+
if (!element.data) element.data = {};
|
|
256
|
+
if (!element.data.varCaches) element.data.varCaches = {};
|
|
288
257
|
const varCaches = element.data.varCaches;
|
|
289
258
|
const changes = {};
|
|
290
259
|
let changed;
|
|
@@ -296,8 +265,7 @@ function variables(obj = {}) {
|
|
|
296
265
|
}
|
|
297
266
|
return {
|
|
298
267
|
changed: (cb) => {
|
|
299
|
-
if (!changed)
|
|
300
|
-
return;
|
|
268
|
+
if (!changed) return;
|
|
301
269
|
const returns = cb(changes, (0, import_utils.deepClone)(varCaches));
|
|
302
270
|
for (const key in changes) {
|
|
303
271
|
varCaches[key] = changes[key];
|
|
@@ -305,8 +273,7 @@ function variables(obj = {}) {
|
|
|
305
273
|
return returns;
|
|
306
274
|
},
|
|
307
275
|
timeout: (cb, timeout) => {
|
|
308
|
-
if (!changed)
|
|
309
|
-
return;
|
|
276
|
+
if (!changed) return;
|
|
310
277
|
const t = setTimeout(() => {
|
|
311
278
|
cb(changes);
|
|
312
279
|
clearTimeout(t);
|
package/dist/cjs/methods/set.js
CHANGED
|
@@ -54,7 +54,6 @@ const addMethods = (element, parent, options = {}) => {
|
|
|
54
54
|
error: import_index.error,
|
|
55
55
|
call: import_index.call
|
|
56
56
|
};
|
|
57
|
-
if (element.context.methods)
|
|
58
|
-
(options.strict ? import_utils.merge : import_utils.overwrite)(proto, element.context.methods);
|
|
57
|
+
if (element.context.methods) (options.strict ? import_utils.merge : import_utils.overwrite)(proto, element.context.methods);
|
|
59
58
|
Object.setPrototypeOf(element, proto);
|
|
60
59
|
};
|
package/dist/cjs/methods/v2.js
CHANGED
|
@@ -46,19 +46,15 @@ const parse = function(excl = []) {
|
|
|
46
46
|
const obj = {};
|
|
47
47
|
const keyList = keys.call(element);
|
|
48
48
|
keyList.forEach((v) => {
|
|
49
|
-
if (excl.includes(v))
|
|
50
|
-
return;
|
|
49
|
+
if (excl.includes(v)) return;
|
|
51
50
|
let val = element[v];
|
|
52
51
|
if (v === "state") {
|
|
53
|
-
if (element.__ref && element.__ref.__hasRootState)
|
|
54
|
-
|
|
55
|
-
if ((0, import_utils.isFunction)(val && val.parse))
|
|
56
|
-
val = val.parse();
|
|
52
|
+
if (element.__ref && element.__ref.__hasRootState) return;
|
|
53
|
+
if ((0, import_utils.isFunction)(val && val.parse)) val = val.parse();
|
|
57
54
|
} else if (v === "props") {
|
|
58
55
|
const { __element, update, ...props } = element[v];
|
|
59
56
|
obj[v] = props;
|
|
60
|
-
} else if ((0, import_utils.isDefined)(val))
|
|
61
|
-
obj[v] = val;
|
|
57
|
+
} else if ((0, import_utils.isDefined)(val)) obj[v] = val;
|
|
62
58
|
});
|
|
63
59
|
return obj;
|
|
64
60
|
};
|
|
@@ -66,8 +62,7 @@ const parseDeep = function(excl = []) {
|
|
|
66
62
|
const element = this;
|
|
67
63
|
const obj = parse.call(element, excl);
|
|
68
64
|
for (const v in obj) {
|
|
69
|
-
if (excl.includes(v))
|
|
70
|
-
return;
|
|
65
|
+
if (excl.includes(v)) return;
|
|
71
66
|
if ((0, import_utils.isObjectLike)(obj[v])) {
|
|
72
67
|
obj[v] = parseDeep.call(obj[v], excl);
|
|
73
68
|
}
|
|
@@ -102,8 +97,7 @@ const previousElement = function(el) {
|
|
|
102
97
|
const element = el || this;
|
|
103
98
|
const { key, parent } = element;
|
|
104
99
|
const { __children } = parent.__ref;
|
|
105
|
-
if (!__children)
|
|
106
|
-
return;
|
|
100
|
+
if (!__children) return;
|
|
107
101
|
const currentIndex = __children.indexOf(key);
|
|
108
102
|
return parent[__children[currentIndex - 1]];
|
|
109
103
|
};
|