@domql/utils 2.5.200 → 3.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/array.js +26 -13
- package/cache.js +4 -0
- package/component.js +10 -227
- package/cookie.js +27 -24
- package/dist/cjs/array.js +27 -10
- package/dist/cjs/cache.js +26 -0
- package/dist/cjs/component.js +15 -206
- package/dist/cjs/cookie.js +14 -14
- package/dist/cjs/element.js +136 -0
- package/dist/cjs/events.js +37 -0
- package/dist/cjs/extends.js +351 -0
- package/dist/cjs/if.js +30 -0
- package/dist/cjs/index.js +10 -0
- package/dist/cjs/key.js +5 -0
- package/dist/cjs/keys.js +178 -0
- package/dist/cjs/methods.js +305 -0
- package/dist/cjs/object.js +78 -191
- package/dist/cjs/props.js +220 -0
- package/dist/cjs/scope.js +28 -0
- package/dist/cjs/state.js +175 -0
- package/dist/cjs/string.js +27 -15
- package/dist/cjs/update.js +42 -0
- package/dist/esm/array.js +27 -10
- package/dist/esm/cache.js +6 -0
- package/dist/esm/component.js +16 -225
- package/dist/esm/cookie.js +14 -14
- package/dist/esm/element.js +134 -0
- package/dist/esm/events.js +17 -0
- package/dist/esm/extends.js +349 -0
- package/dist/esm/if.js +10 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/key.js +5 -0
- package/dist/esm/keys.js +158 -0
- package/dist/esm/methods.js +285 -0
- package/dist/esm/object.js +79 -193
- package/dist/esm/props.js +216 -0
- package/dist/esm/scope.js +8 -0
- package/dist/esm/state.js +185 -0
- package/dist/esm/string.js +27 -15
- package/dist/esm/update.js +22 -0
- package/element.js +148 -0
- package/env.js +5 -2
- package/events.js +17 -0
- package/extends.js +425 -0
- package/if.js +14 -0
- package/index.js +10 -0
- package/key.js +6 -0
- package/keys.js +157 -0
- package/log.js +4 -1
- package/methods.js +315 -0
- package/node.js +21 -13
- package/object.js +122 -236
- package/package.json +3 -3
- package/props.js +249 -0
- package/scope.js +8 -0
- package/state.js +208 -0
- package/string.js +66 -30
- package/update.js +27 -0
package/dist/cjs/component.js
CHANGED
|
@@ -18,221 +18,30 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var component_exports = {};
|
|
20
20
|
__export(component_exports, {
|
|
21
|
-
addAdditionalExtend: () => addAdditionalExtend,
|
|
22
|
-
addChildrenIfNotInOriginal: () => addChildrenIfNotInOriginal,
|
|
23
|
-
applyComponentFromContext: () => applyComponentFromContext,
|
|
24
|
-
applyKeyComponentAsExtend: () => applyKeyComponentAsExtend,
|
|
25
|
-
checkIfKeyIsComponent: () => checkIfKeyIsComponent,
|
|
26
|
-
checkIfKeyIsProperty: () => checkIfKeyIsProperty,
|
|
27
|
-
checkIfSugar: () => checkIfSugar,
|
|
28
|
-
extendizeByKey: () => extendizeByKey,
|
|
29
|
-
extractComponentKeyFromKey: () => extractComponentKeyFromKey,
|
|
30
21
|
getCapitalCaseKeys: () => getCapitalCaseKeys,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
isVariant: () => isVariant,
|
|
35
|
-
setContentKey: () => setContentKey
|
|
22
|
+
getSpreadChildren: () => getSpreadChildren,
|
|
23
|
+
isContextComponent: () => isContextComponent,
|
|
24
|
+
matchesComponentNaming: () => matchesComponentNaming
|
|
36
25
|
});
|
|
37
26
|
module.exports = __toCommonJS(component_exports);
|
|
38
|
-
var
|
|
39
|
-
var import_object = require("./object.js");
|
|
27
|
+
var import_extends = require("./extends.js");
|
|
40
28
|
var import_types = require("./types.js");
|
|
41
|
-
const
|
|
42
|
-
const checkIfKeyIsComponent = (key) => {
|
|
29
|
+
const matchesComponentNaming = (key) => {
|
|
43
30
|
const isFirstKeyString = (0, import_types.isString)(key);
|
|
44
31
|
if (!isFirstKeyString) return;
|
|
45
32
|
const firstCharKey = key.slice(0, 1);
|
|
46
33
|
return /^[A-Z]*$/.test(firstCharKey);
|
|
47
34
|
};
|
|
48
|
-
const checkIfKeyIsProperty = (key) => {
|
|
49
|
-
const isFirstKeyString = (0, import_types.isString)(key);
|
|
50
|
-
if (!isFirstKeyString) return;
|
|
51
|
-
const firstCharKey = key.slice(0, 1);
|
|
52
|
-
return /^[a-z]*$/.test(firstCharKey);
|
|
53
|
-
};
|
|
54
|
-
const addAdditionalExtend = (newExtend, element) => {
|
|
55
|
-
if (!newExtend) return element;
|
|
56
|
-
const { extend: elementExtend } = element;
|
|
57
|
-
const originalArray = (0, import_types.isArray)(elementExtend) ? elementExtend : [elementExtend];
|
|
58
|
-
const receivedArray = (0, import_types.isArray)(newExtend) ? newExtend : [newExtend];
|
|
59
|
-
const extend = (0, import_array.joinArrays)(receivedArray, originalArray);
|
|
60
|
-
return { ...element, extend };
|
|
61
|
-
};
|
|
62
|
-
const checkIfSugar = (element, parent, key) => {
|
|
63
|
-
var _a;
|
|
64
|
-
const {
|
|
65
|
-
extend,
|
|
66
|
-
props,
|
|
67
|
-
childExtend,
|
|
68
|
-
extends: extendProps,
|
|
69
|
-
childExtends,
|
|
70
|
-
childProps,
|
|
71
|
-
children,
|
|
72
|
-
on,
|
|
73
|
-
$collection,
|
|
74
|
-
$stateCollection,
|
|
75
|
-
$propsCollection
|
|
76
|
-
} = element;
|
|
77
|
-
const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
|
|
78
|
-
if (hasComponentAttrs && (childProps || extendProps || children || childExtends)) {
|
|
79
|
-
const logErr = (_a = parent || element) == null ? void 0 : _a.error;
|
|
80
|
-
if (logErr) logErr.call(element, "Sugar component includes params for builtin components", { verbose: true });
|
|
81
|
-
}
|
|
82
|
-
return !hasComponentAttrs || childProps || extendProps || children || childExtends;
|
|
83
|
-
};
|
|
84
|
-
const extractComponentKeyFromKey = (key) => {
|
|
85
|
-
return key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
|
|
86
|
-
};
|
|
87
|
-
const extendizeByKey = (element, parent, key) => {
|
|
88
|
-
const { context } = parent;
|
|
89
|
-
const { tag, extend, childExtends } = element;
|
|
90
|
-
const isSugar = checkIfSugar(element, parent, key);
|
|
91
|
-
const extendFromKey = extractComponentKeyFromKey(key);
|
|
92
|
-
const isExtendKeyComponent = context && context.components[extendFromKey];
|
|
93
|
-
if (element === isExtendKeyComponent) return element;
|
|
94
|
-
else if (isSugar) {
|
|
95
|
-
const newElem = addAdditionalExtend(element.extends, {
|
|
96
|
-
extend: extendFromKey,
|
|
97
|
-
tag,
|
|
98
|
-
props: { ...element }
|
|
99
|
-
});
|
|
100
|
-
if (newElem.props.data) {
|
|
101
|
-
newElem.data = newElem.props.data;
|
|
102
|
-
delete newElem.props.data;
|
|
103
|
-
}
|
|
104
|
-
if (newElem.props.state) {
|
|
105
|
-
newElem.state = newElem.props.state;
|
|
106
|
-
delete newElem.props.state;
|
|
107
|
-
}
|
|
108
|
-
if (newElem.props.attr) {
|
|
109
|
-
newElem.attr = newElem.props.attr;
|
|
110
|
-
delete newElem.props.attr;
|
|
111
|
-
}
|
|
112
|
-
if (newElem.props.if) {
|
|
113
|
-
newElem.if = newElem.props.if;
|
|
114
|
-
delete newElem.props.if;
|
|
115
|
-
}
|
|
116
|
-
if (childExtends) newElem.childExtend = childExtends;
|
|
117
|
-
return newElem;
|
|
118
|
-
} else if (!extend || extend === true) {
|
|
119
|
-
return {
|
|
120
|
-
...element,
|
|
121
|
-
tag,
|
|
122
|
-
extend: extendFromKey
|
|
123
|
-
};
|
|
124
|
-
} else if (extend) {
|
|
125
|
-
return addAdditionalExtend(extendFromKey, element);
|
|
126
|
-
} else if ((0, import_types.isFunction)(element)) {
|
|
127
|
-
return {
|
|
128
|
-
extend: extendFromKey,
|
|
129
|
-
tag,
|
|
130
|
-
props: { ...(0, import_object.exec)(element, parent) }
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
35
|
function getCapitalCaseKeys(obj) {
|
|
135
36
|
return Object.keys(obj).filter((key) => /^[A-Z]/.test(key));
|
|
136
37
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
};
|
|
148
|
-
if (newChild == null ? void 0 : newChild.ignoreExtend) continue;
|
|
149
|
-
if (newChild === null) assignChild(null);
|
|
150
|
-
else if (!childElem) assignChild((0, import_object.deepClone)(newChild));
|
|
151
|
-
else {
|
|
152
|
-
const isSugarChildElem = checkIfSugar(childElem, parent, key);
|
|
153
|
-
if (isSugarChildElem) continue;
|
|
154
|
-
assignChild({
|
|
155
|
-
extend: element[childKey],
|
|
156
|
-
props: newChild
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
const applyKeyComponentAsExtend = (element, parent, key) => {
|
|
162
|
-
return extendizeByKey(element, parent, key) || element;
|
|
163
|
-
};
|
|
164
|
-
const applyComponentFromContext = (element, parent, options) => {
|
|
165
|
-
const { context } = element;
|
|
166
|
-
if (!context || !context.components) return;
|
|
167
|
-
const { components } = context;
|
|
168
|
-
const { extend } = element;
|
|
169
|
-
const execExtend = (0, import_object.exec)(extend, element);
|
|
170
|
-
if ((0, import_types.isString)(execExtend)) {
|
|
171
|
-
const componentExists = components[execExtend] || components["smbls." + execExtend];
|
|
172
|
-
if (componentExists) element.extend = componentExists;
|
|
173
|
-
else {
|
|
174
|
-
if ((ENV === "test" || ENV === "development") && options.verbose) {
|
|
175
|
-
console.warn(execExtend, "is not in library", components, element);
|
|
176
|
-
console.warn("replacing with ", {});
|
|
177
|
-
}
|
|
178
|
-
element.extend = {};
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
const isVariant = (param) => {
|
|
183
|
-
if (!(0, import_types.isString)(param)) return;
|
|
184
|
-
const firstCharKey = param.slice(0, 1);
|
|
185
|
-
return firstCharKey === ".";
|
|
186
|
-
};
|
|
187
|
-
const hasVariantProp = (element) => {
|
|
188
|
-
const { props } = element;
|
|
189
|
-
if ((0, import_types.isObject)(props) && (0, import_types.isString)(props.variant)) return true;
|
|
190
|
-
};
|
|
191
|
-
const getChildrenComponentsByKey = (key, el) => {
|
|
192
|
-
if (key === el.key || el.__ref.__componentKey === key) {
|
|
193
|
-
return el;
|
|
194
|
-
}
|
|
195
|
-
if (el.extend) {
|
|
196
|
-
const foundString = (0, import_types.isString)(el.extend) && el.extend === key;
|
|
197
|
-
const foundInArray = (0, import_types.isArray)(el.extend) && el.extend.filter((v) => v === key).length;
|
|
198
|
-
if (foundString || foundInArray) return el;
|
|
199
|
-
}
|
|
200
|
-
if (el.parent && el.parent.childExtend) {
|
|
201
|
-
const foundString = (0, import_types.isString)(el.parent.childExtend) && el.parent.childExtend === key;
|
|
202
|
-
const foundInArray = (0, import_types.isArray)(el.parent.childExtend) && el.parent.childExtend.filter((v) => v === key).length;
|
|
203
|
-
if (foundString || foundInArray) return el;
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
const getExtendsInElement = (obj) => {
|
|
207
|
-
let result = [];
|
|
208
|
-
function traverse(o) {
|
|
209
|
-
for (const key in o) {
|
|
210
|
-
if (Object.hasOwnProperty.call(o, key)) {
|
|
211
|
-
if (checkIfKeyIsComponent(key)) {
|
|
212
|
-
result.push(key);
|
|
213
|
-
}
|
|
214
|
-
if (key === "extend" || key === "extends") {
|
|
215
|
-
if (typeof o[key] === "string") {
|
|
216
|
-
result.push(o[key]);
|
|
217
|
-
} else if (Array.isArray(o[key])) {
|
|
218
|
-
result = result.concat(o[key]);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
if (typeof o[key] === "object" && o[key] !== null) {
|
|
222
|
-
traverse(o[key]);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
traverse(obj);
|
|
228
|
-
return result;
|
|
229
|
-
};
|
|
230
|
-
const setContentKey = (el, opts = {}) => {
|
|
231
|
-
const { __ref: ref } = el;
|
|
232
|
-
const contentElementKey = opts.contentElementKey;
|
|
233
|
-
if (contentElementKey !== "content" && contentElementKey !== ref.contentElementKey || !ref.contentElementKey) {
|
|
234
|
-
ref.contentElementKey = contentElementKey || "content";
|
|
235
|
-
} else ref.contentElementKey = "content";
|
|
236
|
-
if (contentElementKey !== "content") opts.contentElementKey = "content";
|
|
237
|
-
return ref.contentElementKey;
|
|
238
|
-
};
|
|
38
|
+
function getSpreadChildren(obj) {
|
|
39
|
+
return Object.keys(obj).filter((key) => /^\d+$/.test(key));
|
|
40
|
+
}
|
|
41
|
+
function isContextComponent(element, parent, passedKey) {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
const { context } = parent || {};
|
|
44
|
+
const [extendsKey] = (0, import_extends.createExtendsFromKeys)(passedKey);
|
|
45
|
+
const key = passedKey || extendsKey;
|
|
46
|
+
return ((_a = context == null ? void 0 : context.components) == null ? void 0 : _a[key]) || ((_b = context == null ? void 0 : context.pages) == null ? void 0 : _b[key]);
|
|
47
|
+
}
|
package/dist/cjs/cookie.js
CHANGED
|
@@ -53,23 +53,23 @@ const removeCookie = (cname) => {
|
|
|
53
53
|
import_globals.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
|
54
54
|
};
|
|
55
55
|
function getLocalStorage(key) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
savedJSON = JSON.parse(window.localStorage.getItem(key));
|
|
60
|
-
} catch (e) {
|
|
61
|
-
}
|
|
56
|
+
if (!window.localStorage) {
|
|
57
|
+
return void 0;
|
|
62
58
|
}
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
const item = window.localStorage.getItem(key);
|
|
60
|
+
if (item === null) {
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
return JSON.parse(item);
|
|
65
|
+
} catch (e) {
|
|
66
|
+
return void 0;
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
function setLocalStorage(key, data) {
|
|
68
|
-
if (data
|
|
69
|
-
|
|
70
|
-
window.localStorage.setItem(key, JSON.stringify(data));
|
|
71
|
-
} else {
|
|
72
|
-
window.localStorage.setItem(key, data);
|
|
73
|
-
}
|
|
70
|
+
if (!window.localStorage || data === void 0 || data === null) {
|
|
71
|
+
return;
|
|
74
72
|
}
|
|
73
|
+
const value = typeof data === "object" ? JSON.stringify(data) : data;
|
|
74
|
+
window.localStorage.setItem(key, value);
|
|
75
75
|
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var element_exports = {};
|
|
20
|
+
__export(element_exports, {
|
|
21
|
+
addCaching: () => addCaching,
|
|
22
|
+
addContext: () => addContext,
|
|
23
|
+
addRef: () => addRef,
|
|
24
|
+
createBasedOnType: () => createBasedOnType,
|
|
25
|
+
createElement: () => createElement,
|
|
26
|
+
createParent: () => createParent,
|
|
27
|
+
createPath: () => createPath,
|
|
28
|
+
createRoot: () => createRoot,
|
|
29
|
+
returnValueAsText: () => returnValueAsText
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(element_exports);
|
|
32
|
+
var import_extends = require("./extends.js");
|
|
33
|
+
var import_key = require("./key.js");
|
|
34
|
+
var import_node = require("./node.js");
|
|
35
|
+
var import_props = require("./props.js");
|
|
36
|
+
var import_tags = require("./tags.js");
|
|
37
|
+
var import_types = require("./types.js");
|
|
38
|
+
const ENV = "development";
|
|
39
|
+
const returnValueAsText = (element, parent, key) => {
|
|
40
|
+
const childExtendsTag = parent.childExtends && parent.childExtends.tag;
|
|
41
|
+
const childPropsTag = parent.props.childProps && parent.props.childProps.tag;
|
|
42
|
+
const isKeyValidHTMLTag = import_tags.HTML_TAGS.body.indexOf(key) > -1 && key;
|
|
43
|
+
return {
|
|
44
|
+
text: element,
|
|
45
|
+
tag: childExtendsTag || childPropsTag || isKeyValidHTMLTag || "string"
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
const createBasedOnType = (element, parent, key) => {
|
|
49
|
+
if (element === void 0) {
|
|
50
|
+
if (ENV === "test" || ENV === "development") {
|
|
51
|
+
console.warn(
|
|
52
|
+
key,
|
|
53
|
+
"element is undefined in",
|
|
54
|
+
parent && parent.__ref && parent.__ref.path
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
return {};
|
|
58
|
+
}
|
|
59
|
+
if (element === null) return;
|
|
60
|
+
if (element === true) return {};
|
|
61
|
+
if ((0, import_types.is)(element)("string", "number")) {
|
|
62
|
+
return returnValueAsText(element, parent, key);
|
|
63
|
+
}
|
|
64
|
+
if ((0, import_types.isFunction)(element)) {
|
|
65
|
+
return { props: element };
|
|
66
|
+
}
|
|
67
|
+
return element;
|
|
68
|
+
};
|
|
69
|
+
const addRef = (element, parent) => {
|
|
70
|
+
const ref = {};
|
|
71
|
+
ref.origin = element;
|
|
72
|
+
ref.parent = parent;
|
|
73
|
+
return ref;
|
|
74
|
+
};
|
|
75
|
+
const createParent = (element, parent, key, options, root) => {
|
|
76
|
+
if (!parent) return root;
|
|
77
|
+
if ((0, import_node.isNode)(parent)) {
|
|
78
|
+
const parentNodeWrapper = { key: ":root", node: parent };
|
|
79
|
+
root[`${key}_parent`] = parentNodeWrapper;
|
|
80
|
+
return parentNodeWrapper;
|
|
81
|
+
}
|
|
82
|
+
return parent;
|
|
83
|
+
};
|
|
84
|
+
const createRoot = (element, parent) => {
|
|
85
|
+
const { __ref: ref } = element;
|
|
86
|
+
const { __ref: parentRef } = parent;
|
|
87
|
+
const hasRoot = parent && parent.key === ":root";
|
|
88
|
+
if (!(ref == null ? void 0 : ref.root)) {
|
|
89
|
+
ref.root = hasRoot ? element : parentRef == null ? void 0 : parentRef.root;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const createPath = (element, parent, key) => {
|
|
93
|
+
let { __ref: parentRef } = parent;
|
|
94
|
+
if (!parentRef) parentRef = parent.ref = {};
|
|
95
|
+
if (!parentRef.path) parentRef.path = [];
|
|
96
|
+
return parentRef.path.concat(key);
|
|
97
|
+
};
|
|
98
|
+
const addContext = (element, parent, key, options, root) => {
|
|
99
|
+
const forcedOptionsContext = options.context && !root.context && !element.context;
|
|
100
|
+
if (forcedOptionsContext) root.context = options.context;
|
|
101
|
+
return options.context || parent.context || root.context || element.context;
|
|
102
|
+
};
|
|
103
|
+
const addCaching = (element, parent, key) => {
|
|
104
|
+
const ref = addRef(element, parent);
|
|
105
|
+
element.__ref = ref;
|
|
106
|
+
if (!ref.__defineCache) ref.__defineCache = {};
|
|
107
|
+
if (!ref.__exec) ref.__exec = {};
|
|
108
|
+
if (!ref.__execProps) ref.__execProps = {};
|
|
109
|
+
if (!ref.__class) ref.__class = {};
|
|
110
|
+
if (!ref.__classNames) ref.__classNames = {};
|
|
111
|
+
if (!ref.__attr) ref.__attr = {};
|
|
112
|
+
if (!ref.__changes) ref.__changes = [];
|
|
113
|
+
if (!ref.__children) ref.__children = [];
|
|
114
|
+
ref.__extends = (0, import_extends.createExtends)(element, parent, key);
|
|
115
|
+
ref.path = createPath(element, parent, key);
|
|
116
|
+
return ref;
|
|
117
|
+
};
|
|
118
|
+
const createElement = (passedProps, parentEl, passedKey, opts, root) => {
|
|
119
|
+
const hashed = passedProps == null ? void 0 : passedProps.__hash;
|
|
120
|
+
const element = hashed ? { extends: [passedProps] } : createBasedOnType(passedProps, parentEl, passedKey);
|
|
121
|
+
if (!element) return;
|
|
122
|
+
const parent = createParent(element, parentEl, passedKey, opts, root);
|
|
123
|
+
const key = (0, import_key.createKey)(element, parent, passedKey);
|
|
124
|
+
addCaching(element, parent, key);
|
|
125
|
+
const props = (0, import_props.createProps)(element, parent, key);
|
|
126
|
+
const context = addContext(element, parent, key, opts, root);
|
|
127
|
+
const on = element.on || {};
|
|
128
|
+
return {
|
|
129
|
+
...element,
|
|
130
|
+
key,
|
|
131
|
+
props,
|
|
132
|
+
parent,
|
|
133
|
+
context,
|
|
134
|
+
on
|
|
135
|
+
};
|
|
136
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var events_exports = {};
|
|
20
|
+
__export(events_exports, {
|
|
21
|
+
addEventFromProps: () => addEventFromProps
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(events_exports);
|
|
24
|
+
var import_string = require("./string.js");
|
|
25
|
+
var import_types = require("./types.js");
|
|
26
|
+
const addEventFromProps = (key, element) => {
|
|
27
|
+
const { props, on } = element;
|
|
28
|
+
const eventName = (0, import_string.lowercaseFirstLetter)(key.split("on")[1]);
|
|
29
|
+
const origEvent = on[eventName];
|
|
30
|
+
const funcFromProps = props[key];
|
|
31
|
+
if ((0, import_types.isFunction)(origEvent)) {
|
|
32
|
+
on[eventName] = (...args) => {
|
|
33
|
+
const originalEventRetunrs = origEvent(...args);
|
|
34
|
+
if (originalEventRetunrs !== false) funcFromProps(...args);
|
|
35
|
+
};
|
|
36
|
+
} else on[eventName] = funcFromProps;
|
|
37
|
+
};
|