@domql/element 2.3.154 → 2.4.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/LICENSE +21 -0
- package/cache/index.js +3 -0
- package/create.js +21 -35
- package/dist/cjs/applyParam.js +41 -0
- package/dist/cjs/create.js +262 -0
- package/dist/cjs/define.js +34 -0
- package/dist/cjs/extend.js +87 -0
- package/dist/cjs/index.js +44 -0
- package/dist/cjs/iterate.js +108 -0
- package/dist/cjs/node.js +85 -0
- package/dist/cjs/package.json +4 -0
- package/dist/cjs/set.js +58 -0
- package/dist/cjs/tree.js +31 -0
- package/dist/cjs/update.js +223 -0
- package/index.js +2 -12
- package/iterate.js +1 -1
- package/methods/index.js +165 -0
- package/methods/set.js +41 -0
- package/{methods.js → methods/v2.js} +1 -7
- package/mixins/attr.js +23 -0
- package/mixins/classList.js +48 -0
- package/{remove.js → mixins/content.js} +19 -2
- package/mixins/data.js +21 -0
- package/mixins/html.js +20 -0
- package/mixins/index.js +23 -0
- package/mixins/registry.js +66 -0
- package/mixins/state.js +20 -0
- package/mixins/style.js +14 -0
- package/mixins/text.js +41 -0
- package/node.js +2 -2
- package/package.json +14 -6
- package/props/create.js +60 -0
- package/props/ignore.js +3 -0
- package/props/index.js +6 -0
- package/props/inherit.js +34 -0
- package/props/update.js +17 -0
- package/set.js +4 -6
- package/test/create.test.js +61 -0
- package/test/set.test.js +13 -0
- package/test/update.test.js +13 -0
- package/tree.js +11 -0
- package/update.js +5 -7
- package/utils/component.js +112 -0
- package/utils/extendUtils.js +118 -0
- package/utils/index.js +5 -0
- package/utils/object.js +141 -0
- package/parse.js +0 -17
- /package/{options.js → cache/options.js} +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 symbo.ls
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/cache/index.js
ADDED
package/create.js
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { isObject, isFunction, isString, exec, is, isNode, isUndefined } from '@domql/utils'
|
|
4
|
-
import { ROOT } from '
|
|
5
|
-
import { createKey } from '@domql/key'
|
|
3
|
+
import { isObject, isFunction, isString, exec, is, isNode, isUndefined, createKey } from '@domql/utils'
|
|
4
|
+
import { ROOT } from './tree'
|
|
6
5
|
import { TAGS } from '@domql/registry'
|
|
7
6
|
import { triggerEventOn } from '@domql/event'
|
|
8
7
|
import { appendNode, assignNode } from '@domql/render'
|
|
9
|
-
import { isMethod, lookup, setProps, remove, spotByPath } from '@domql/methods'
|
|
10
8
|
import { assignClass } from '@domql/classlist'
|
|
11
9
|
import { cacheNode, detectTag } from '@domql/node'
|
|
12
10
|
import { createState } from '@domql/state'
|
|
13
|
-
|
|
11
|
+
|
|
12
|
+
import { isMethod } from './methods'
|
|
13
|
+
|
|
14
|
+
import { createProps } from './props'
|
|
14
15
|
|
|
15
16
|
import createNode from './node'
|
|
16
17
|
import { applyExtend } from './extend'
|
|
17
|
-
import set from './set'
|
|
18
|
-
import update from './update'
|
|
19
|
-
import { log, keys, parse, parseDeep, nextElement, previousElement } from './methods'
|
|
20
18
|
import { registry } from './mixins'
|
|
21
19
|
import { throughInitialExec } from './iterate'
|
|
22
|
-
import OPTIONS from './options'
|
|
20
|
+
import OPTIONS from './cache/options'
|
|
23
21
|
|
|
24
22
|
import {
|
|
25
23
|
applyComponentFromContext,
|
|
@@ -28,7 +26,7 @@ import {
|
|
|
28
26
|
checkIfKeyIsComponent,
|
|
29
27
|
isVariant
|
|
30
28
|
} from './utils/component'
|
|
31
|
-
import {
|
|
29
|
+
import { addMethods } from './methods/set'
|
|
32
30
|
|
|
33
31
|
const ENV = process.env.NODE_ENV
|
|
34
32
|
|
|
@@ -144,10 +142,22 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
|
|
|
144
142
|
// generate a CLASS name
|
|
145
143
|
assignClass(element)
|
|
146
144
|
|
|
145
|
+
renderElement(element, parent, options)
|
|
146
|
+
|
|
147
|
+
if (parent.__ref && parent.__ref.__children) parent.__ref.__children.push(element.key)
|
|
148
|
+
|
|
149
|
+
triggerEventOn('complete', element, options)
|
|
150
|
+
|
|
151
|
+
return element
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const renderElement = (element, parent, options) => {
|
|
155
|
+
const { __ref: ref, key } = element
|
|
156
|
+
|
|
147
157
|
// CREATE a real NODE
|
|
148
158
|
createNode(element, options)
|
|
149
159
|
|
|
150
|
-
if (!
|
|
160
|
+
if (!ref.__if) return element
|
|
151
161
|
|
|
152
162
|
// assign NODE
|
|
153
163
|
assignNode(element, parent, key)
|
|
@@ -157,10 +167,6 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
|
|
|
157
167
|
|
|
158
168
|
// run `on.render`
|
|
159
169
|
triggerEventOn('render', element, options)
|
|
160
|
-
|
|
161
|
-
if (parent.__ref && parent.__ref.__children) parent.__ref.__children.push(element.key)
|
|
162
|
-
|
|
163
|
-
return element
|
|
164
170
|
}
|
|
165
171
|
|
|
166
172
|
const checkIfPrimitive = (element) => {
|
|
@@ -177,26 +183,6 @@ const applyValueAsText = (element, parent, key) => {
|
|
|
177
183
|
}
|
|
178
184
|
}
|
|
179
185
|
|
|
180
|
-
const addMethods = (element, parent) => {
|
|
181
|
-
const proto = {
|
|
182
|
-
set: set.bind(element),
|
|
183
|
-
update: update.bind(element),
|
|
184
|
-
remove: remove.bind(element),
|
|
185
|
-
updateContent: updateContentElement.bind(element),
|
|
186
|
-
removeContent: removeContentElement.bind(element),
|
|
187
|
-
setProps: setProps.bind(element),
|
|
188
|
-
lookup: lookup.bind(element),
|
|
189
|
-
spotByPath: spotByPath.bind(element),
|
|
190
|
-
parse: parse.bind(element),
|
|
191
|
-
parseDeep: parseDeep.bind(element),
|
|
192
|
-
keys: keys.bind(element),
|
|
193
|
-
nextElement: nextElement.bind(element),
|
|
194
|
-
previousElement: previousElement.bind(element)
|
|
195
|
-
}
|
|
196
|
-
if (ENV === 'test' || ENV === 'development') proto.log = log.bind(element)
|
|
197
|
-
Object.setPrototypeOf(element, proto)
|
|
198
|
-
}
|
|
199
|
-
|
|
200
186
|
const applyContext = (element, parent, options) => {
|
|
201
187
|
if (options.context && !ROOT.context && !element.context) ROOT.context = options.context
|
|
202
188
|
if (!element.context) element.context = parent.context || options.context || ROOT.context
|
|
@@ -0,0 +1,41 @@
|
|
|
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 applyParam_exports = {};
|
|
20
|
+
__export(applyParam_exports, {
|
|
21
|
+
applyParam: () => applyParam
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(applyParam_exports);
|
|
24
|
+
var import_utils = require("@domql/utils");
|
|
25
|
+
var import_mixins = require("./mixins");
|
|
26
|
+
const applyParam = (param, element, options) => {
|
|
27
|
+
const { node, context } = element;
|
|
28
|
+
const prop = element[param];
|
|
29
|
+
const DOMQLProperty = import_mixins.registry[param];
|
|
30
|
+
const DOMQLPropertyFromContext = context && context.registry && context.registry[param];
|
|
31
|
+
const isGlobalTransformer = DOMQLPropertyFromContext || DOMQLProperty;
|
|
32
|
+
const hasDefine = element.define && element.define[param];
|
|
33
|
+
const hasContextDefine = context && context.define && context.define[param];
|
|
34
|
+
if (isGlobalTransformer && !hasContextDefine) {
|
|
35
|
+
if ((0, import_utils.isFunction)(isGlobalTransformer)) {
|
|
36
|
+
isGlobalTransformer(prop, element, node, options);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return { hasDefine, hasContextDefine };
|
|
41
|
+
};
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var create_exports = {};
|
|
30
|
+
__export(create_exports, {
|
|
31
|
+
default: () => create_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(create_exports);
|
|
34
|
+
var import_utils = require("@domql/utils");
|
|
35
|
+
var import_tree = require("./tree");
|
|
36
|
+
var import_registry = require("@domql/registry");
|
|
37
|
+
var import_event = require("@domql/event");
|
|
38
|
+
var import_render = require("@domql/render");
|
|
39
|
+
var import_classlist = require("@domql/classlist");
|
|
40
|
+
var import_node = require("@domql/node");
|
|
41
|
+
var import_state = require("@domql/state");
|
|
42
|
+
var import_methods = require("./methods");
|
|
43
|
+
var import_props = require("./props");
|
|
44
|
+
var import_node2 = __toESM(require("./node"), 1);
|
|
45
|
+
var import_extend = require("./extend");
|
|
46
|
+
var import_mixins = require("./mixins");
|
|
47
|
+
var import_iterate = require("./iterate");
|
|
48
|
+
var import_options = __toESM(require("./cache/options"), 1);
|
|
49
|
+
var import_component = require("./utils/component");
|
|
50
|
+
var import_set = require("./methods/set");
|
|
51
|
+
const ENV = "development";
|
|
52
|
+
const create = (element, parent, key, options = import_options.default.create || {}) => {
|
|
53
|
+
if (options && !import_options.default.create) {
|
|
54
|
+
import_options.default.create = options;
|
|
55
|
+
import_options.default.create.context = element.context || options.context;
|
|
56
|
+
}
|
|
57
|
+
if (element === void 0) {
|
|
58
|
+
if (ENV === "test" || ENV === "development") {
|
|
59
|
+
console.warn(key, "element is undefined in", parent && parent.__ref && parent.__ref.path);
|
|
60
|
+
}
|
|
61
|
+
element = {};
|
|
62
|
+
}
|
|
63
|
+
if ((0, import_utils.isString)(key) && key.slice(0, 2 === "__")) {
|
|
64
|
+
if (ENV === "test" || ENV === "development") {
|
|
65
|
+
console.warn(key, "seems like to be in __ref");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (element === null)
|
|
69
|
+
return;
|
|
70
|
+
if (element === true)
|
|
71
|
+
element = { text: true };
|
|
72
|
+
if (element.__hash) {
|
|
73
|
+
element = { extend: element };
|
|
74
|
+
}
|
|
75
|
+
if (!parent)
|
|
76
|
+
parent = import_tree.ROOT;
|
|
77
|
+
if ((0, import_utils.isNode)(parent)) {
|
|
78
|
+
parent = import_tree.ROOT[`${key}_parent`] = { key: ":root", node: parent };
|
|
79
|
+
}
|
|
80
|
+
if (checkIfPrimitive(element)) {
|
|
81
|
+
element = applyValueAsText(element, parent, key);
|
|
82
|
+
}
|
|
83
|
+
const assignedKey = (element.key || key || (0, import_utils.createKey)()).toString();
|
|
84
|
+
if ((0, import_component.checkIfKeyIsComponent)(assignedKey)) {
|
|
85
|
+
element = (0, import_component.applyKeyComponentAsExtend)(element, parent, assignedKey);
|
|
86
|
+
}
|
|
87
|
+
if (checkIfMedia(assignedKey)) {
|
|
88
|
+
element = applyMediaProps(element, parent, assignedKey);
|
|
89
|
+
}
|
|
90
|
+
if (element.__ref)
|
|
91
|
+
element.__ref.origin = element;
|
|
92
|
+
else
|
|
93
|
+
element.__ref = { origin: element };
|
|
94
|
+
const __ref = element.__ref;
|
|
95
|
+
applyContext(element, parent, options);
|
|
96
|
+
const { context } = element;
|
|
97
|
+
if (context && context.components) {
|
|
98
|
+
(0, import_component.applyComponentFromContext)(element, parent, options);
|
|
99
|
+
}
|
|
100
|
+
(0, import_extend.applyExtend)(element, parent, options);
|
|
101
|
+
element.key = assignedKey;
|
|
102
|
+
if (options.onlyResolveExtends) {
|
|
103
|
+
return resolveExtends(element, parent, options);
|
|
104
|
+
}
|
|
105
|
+
if (Object.keys(options).length) {
|
|
106
|
+
import_mixins.registry.defaultOptions = options;
|
|
107
|
+
if (options.ignoreChildExtend)
|
|
108
|
+
delete options.ignoreChildExtend;
|
|
109
|
+
}
|
|
110
|
+
addCaching(element, parent);
|
|
111
|
+
(0, import_set.addMethods)(element, parent);
|
|
112
|
+
element.state = (0, import_state.createState)(element, parent);
|
|
113
|
+
checkIf(element, parent);
|
|
114
|
+
if (element.node && __ref.__if) {
|
|
115
|
+
return (0, import_render.assignNode)(element, parent, assignedKey);
|
|
116
|
+
}
|
|
117
|
+
if (__ref.__if)
|
|
118
|
+
(0, import_props.createProps)(element, parent);
|
|
119
|
+
(0, import_component.applyVariant)(element, parent);
|
|
120
|
+
const initReturns = (0, import_event.triggerEventOn)("init", element, options);
|
|
121
|
+
if (initReturns === false)
|
|
122
|
+
return element;
|
|
123
|
+
(0, import_event.triggerEventOn)("beforeClassAssign", element, options);
|
|
124
|
+
(0, import_classlist.assignClass)(element);
|
|
125
|
+
renderElement(element, parent, options);
|
|
126
|
+
if (parent.__ref && parent.__ref.__children)
|
|
127
|
+
parent.__ref.__children.push(element.key);
|
|
128
|
+
(0, import_event.triggerEventOn)("complete", element, options);
|
|
129
|
+
return element;
|
|
130
|
+
};
|
|
131
|
+
const renderElement = (element, parent, options) => {
|
|
132
|
+
const { __ref: ref, key } = element;
|
|
133
|
+
(0, import_node2.default)(element, options);
|
|
134
|
+
if (!ref.__if)
|
|
135
|
+
return element;
|
|
136
|
+
(0, import_render.assignNode)(element, parent, key);
|
|
137
|
+
(0, import_event.triggerEventOn)("renderRouter", element, options);
|
|
138
|
+
(0, import_event.triggerEventOn)("render", element, options);
|
|
139
|
+
};
|
|
140
|
+
const checkIfPrimitive = (element) => {
|
|
141
|
+
return (0, import_utils.is)(element)("string", "number");
|
|
142
|
+
};
|
|
143
|
+
const applyValueAsText = (element, parent, key) => {
|
|
144
|
+
const extendTag = element.extend && element.extend.tag;
|
|
145
|
+
const childExtendTag = parent.childExtend && parent.childExtend.tag;
|
|
146
|
+
const isKeyValidHTMLTag = import_registry.TAGS.body.indexOf(key) > -1 && key;
|
|
147
|
+
return {
|
|
148
|
+
text: element,
|
|
149
|
+
tag: extendTag || childExtendTag || isKeyValidHTMLTag || "string"
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
const applyContext = (element, parent, options) => {
|
|
153
|
+
if (options.context && !import_tree.ROOT.context && !element.context)
|
|
154
|
+
import_tree.ROOT.context = options.context;
|
|
155
|
+
if (!element.context)
|
|
156
|
+
element.context = parent.context || options.context || import_tree.ROOT.context;
|
|
157
|
+
};
|
|
158
|
+
const checkIf = (element, parent) => {
|
|
159
|
+
const { __ref: ref } = element;
|
|
160
|
+
if ((0, import_utils.isFunction)(element.if)) {
|
|
161
|
+
const ifPassed = element.if(element, element.state);
|
|
162
|
+
if (!ifPassed) {
|
|
163
|
+
const ifFragment = (0, import_node.cacheNode)({ tag: "fragment" });
|
|
164
|
+
ref.__ifFragment = (0, import_render.appendNode)(ifFragment, parent.node);
|
|
165
|
+
delete ref.__if;
|
|
166
|
+
} else
|
|
167
|
+
ref.__if = true;
|
|
168
|
+
} else
|
|
169
|
+
ref.__if = true;
|
|
170
|
+
};
|
|
171
|
+
const addCaching = (element, parent) => {
|
|
172
|
+
const { __ref: ref } = element;
|
|
173
|
+
let { __ref: parentRef } = parent;
|
|
174
|
+
if (!element.transform)
|
|
175
|
+
element.transform = {};
|
|
176
|
+
if (!ref.__cached)
|
|
177
|
+
ref.__cached = {};
|
|
178
|
+
if (!ref.__defineCache)
|
|
179
|
+
ref.__defineCache = {};
|
|
180
|
+
if (!ref.__exec)
|
|
181
|
+
ref.__exec = {};
|
|
182
|
+
if (!ref.__class)
|
|
183
|
+
ref.__class = {};
|
|
184
|
+
if (!ref.__classNames)
|
|
185
|
+
ref.__classNames = {};
|
|
186
|
+
if (!ref.__attr)
|
|
187
|
+
ref.__attr = {};
|
|
188
|
+
if (!ref.__changes)
|
|
189
|
+
ref.__changes = [];
|
|
190
|
+
if (!ref.__children)
|
|
191
|
+
ref.__children = [];
|
|
192
|
+
const hasRoot = parent && parent.key === ":root";
|
|
193
|
+
if (!ref.__root)
|
|
194
|
+
ref.__root = hasRoot ? element : parentRef.__root;
|
|
195
|
+
if (ENV === "test" || ENV === "development") {
|
|
196
|
+
if (!parentRef)
|
|
197
|
+
parentRef = parent.ref = {};
|
|
198
|
+
if (!parentRef.__path)
|
|
199
|
+
parentRef.__path = [];
|
|
200
|
+
ref.__path = parentRef.__path.concat(element.key);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
const resolveExtends = (element, parent, options) => {
|
|
204
|
+
const { __ref } = element;
|
|
205
|
+
element.tag = (0, import_node.detectTag)(element);
|
|
206
|
+
if (!__ref.__exec)
|
|
207
|
+
__ref.__exec = {};
|
|
208
|
+
if (!__ref.__attr)
|
|
209
|
+
__ref.__attr = {};
|
|
210
|
+
if (!element.props)
|
|
211
|
+
element.props = {};
|
|
212
|
+
if (!element.state)
|
|
213
|
+
element.state = {};
|
|
214
|
+
(0, import_state.createState)(element, parent, { skipApplyMethods: true });
|
|
215
|
+
(0, import_props.createProps)(element, parent);
|
|
216
|
+
(0, import_component.applyVariant)(element, parent);
|
|
217
|
+
(0, import_iterate.throughInitialExec)(element, options.propsExcludedFromExec);
|
|
218
|
+
for (const param in element) {
|
|
219
|
+
const prop = element[param];
|
|
220
|
+
if ((0, import_utils.isUndefined)(prop) || (0, import_methods.isMethod)(param) || (0, import_utils.isObject)(import_mixins.registry[param]) || (0, import_component.isVariant)(param))
|
|
221
|
+
continue;
|
|
222
|
+
const hasDefined = element.define && element.define[param];
|
|
223
|
+
const ourParam = import_mixins.registry[param];
|
|
224
|
+
const hasOptionsDefine = options.define && options.define[param];
|
|
225
|
+
if (ourParam && !hasOptionsDefine)
|
|
226
|
+
continue;
|
|
227
|
+
else if (element[param] && !hasDefined && !hasOptionsDefine) {
|
|
228
|
+
create((0, import_utils.exec)(prop, element), element, param, options);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
delete element.parent;
|
|
232
|
+
delete element.update;
|
|
233
|
+
delete element.__element;
|
|
234
|
+
delete element.props.update;
|
|
235
|
+
delete element.props.__element;
|
|
236
|
+
delete element.state.__element;
|
|
237
|
+
delete element.state.__element;
|
|
238
|
+
if (!options.keepRef)
|
|
239
|
+
delete element.__ref;
|
|
240
|
+
return element;
|
|
241
|
+
};
|
|
242
|
+
const checkIfMedia = (key) => key.slice(0, 1) === "@";
|
|
243
|
+
const applyMediaProps = (element, parent, key) => {
|
|
244
|
+
const { props } = element;
|
|
245
|
+
if (props) {
|
|
246
|
+
props.display = "none";
|
|
247
|
+
if (props[key])
|
|
248
|
+
props[key].display = props.display;
|
|
249
|
+
else
|
|
250
|
+
props[key] = { display: props.display || "block" };
|
|
251
|
+
return element;
|
|
252
|
+
} else {
|
|
253
|
+
return {
|
|
254
|
+
...element,
|
|
255
|
+
props: {
|
|
256
|
+
display: "none",
|
|
257
|
+
[key]: { display: "block" }
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
var create_default = create;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 define_exports = {};
|
|
20
|
+
__export(define_exports, {
|
|
21
|
+
default: () => define_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(define_exports);
|
|
24
|
+
var import_report = require("@domql/report");
|
|
25
|
+
var import_mixins = require("./mixins");
|
|
26
|
+
var define_default = (params, options = {}) => {
|
|
27
|
+
const { overwrite } = options;
|
|
28
|
+
for (const param in params) {
|
|
29
|
+
if (import_mixins.registry[param] && !overwrite) {
|
|
30
|
+
(0, import_report.report)("OverwriteToBuiltin", param);
|
|
31
|
+
} else
|
|
32
|
+
import_mixins.registry[param] = params[param];
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
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 extend_exports = {};
|
|
20
|
+
__export(extend_exports, {
|
|
21
|
+
applyExtend: () => applyExtend
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(extend_exports);
|
|
24
|
+
var import_utils = require("@domql/utils");
|
|
25
|
+
var import_utils2 = require("./utils");
|
|
26
|
+
const ENV = "development";
|
|
27
|
+
const applyExtend = (element, parent, options = {}) => {
|
|
28
|
+
if ((0, import_utils.isFunction)(element))
|
|
29
|
+
element = (0, import_utils.exec)(element, parent);
|
|
30
|
+
let { extend, props, context, __ref } = element;
|
|
31
|
+
const COMPONENTS = context && context.components || options.components;
|
|
32
|
+
if ((0, import_utils.isString)(extend)) {
|
|
33
|
+
if (COMPONENTS && COMPONENTS[extend])
|
|
34
|
+
extend = COMPONENTS[extend];
|
|
35
|
+
else {
|
|
36
|
+
if (ENV !== "test" || ENV !== "development") {
|
|
37
|
+
console.warn("Extend is string but component was not found:", extend);
|
|
38
|
+
}
|
|
39
|
+
extend = {};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const extendStack = (0, import_utils2.getExtendStack)(extend);
|
|
43
|
+
if (ENV !== "test" || ENV !== "development")
|
|
44
|
+
delete element.extend;
|
|
45
|
+
let childExtendStack = [];
|
|
46
|
+
if (parent) {
|
|
47
|
+
element.parent = parent;
|
|
48
|
+
if (!options.ignoreChildExtend) {
|
|
49
|
+
if (props && props.ignoreChildExtend)
|
|
50
|
+
return;
|
|
51
|
+
childExtendStack = (0, import_utils2.getExtendStack)(parent.childExtend);
|
|
52
|
+
if (parent.childExtendRecursive) {
|
|
53
|
+
const canExtendRecursive = !(props == null ? void 0 : props.ignoreChildExtendRecursive) && element.key !== "__text";
|
|
54
|
+
if (canExtendRecursive) {
|
|
55
|
+
const childExtendRecursiveStack = (0, import_utils2.getExtendStack)(parent.childExtendRecursive);
|
|
56
|
+
childExtendStack = childExtendStack.concat(childExtendRecursiveStack);
|
|
57
|
+
element.childExtendRecursive = parent.childExtendRecursive;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const extendLength = extendStack.length;
|
|
63
|
+
const childExtendLength = childExtendStack.length;
|
|
64
|
+
let stack = [];
|
|
65
|
+
if (extendLength && childExtendLength) {
|
|
66
|
+
stack = (0, import_utils2.jointStacks)(extendStack, childExtendStack);
|
|
67
|
+
} else if (extendLength) {
|
|
68
|
+
stack = extendStack;
|
|
69
|
+
} else if (childExtendLength) {
|
|
70
|
+
stack = childExtendStack;
|
|
71
|
+
} else if (!options.extend)
|
|
72
|
+
return element;
|
|
73
|
+
if (options.extend) {
|
|
74
|
+
const defaultOptionsExtend = (0, import_utils2.getExtendStack)(options.extend);
|
|
75
|
+
stack = [].concat(stack, defaultOptionsExtend);
|
|
76
|
+
}
|
|
77
|
+
if (__ref)
|
|
78
|
+
__ref.__extend = stack;
|
|
79
|
+
const findAndReplaceStrings = (0, import_utils2.replaceStringsWithComponents)(stack, COMPONENTS);
|
|
80
|
+
let mergedExtend = (0, import_utils2.cloneAndMergeArrayExtend)(findAndReplaceStrings);
|
|
81
|
+
const component = (0, import_utils.exec)(element.component || mergedExtend.component, element);
|
|
82
|
+
if (component && COMPONENTS && COMPONENTS[component]) {
|
|
83
|
+
const componentExtend = (0, import_utils2.cloneAndMergeArrayExtend)((0, import_utils2.getExtendStack)(COMPONENTS[component]));
|
|
84
|
+
mergedExtend = (0, import_utils2.deepMergeExtend)(componentExtend, mergedExtend);
|
|
85
|
+
}
|
|
86
|
+
return (0, import_utils2.deepMergeExtend)(element, mergedExtend);
|
|
87
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var element_exports = {};
|
|
30
|
+
__export(element_exports, {
|
|
31
|
+
TREE: () => import_tree.TREE,
|
|
32
|
+
create: () => import_create.default,
|
|
33
|
+
createNode: () => import_node.default,
|
|
34
|
+
define: () => import_define.default,
|
|
35
|
+
set: () => import_set.default,
|
|
36
|
+
update: () => import_update.default
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(element_exports);
|
|
39
|
+
var import_tree = require("./tree");
|
|
40
|
+
var import_create = __toESM(require("./create"), 1);
|
|
41
|
+
var import_node = __toESM(require("./node"), 1);
|
|
42
|
+
var import_define = __toESM(require("./define"), 1);
|
|
43
|
+
var import_update = __toESM(require("./update"), 1);
|
|
44
|
+
var import_set = __toESM(require("./set"), 1);
|