@domql/element 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/README.md +1 -1
- package/__tests__/checkIfOnUpdate.test.js +103 -0
- package/__tests__/children.test.js +213 -0
- package/__tests__/define.test.js +75 -0
- package/__tests__/inheritStateUpdates.test.js +79 -0
- package/__tests__/renderElement.test.js +131 -0
- package/__tests__/resetElement.test.js +44 -0
- package/__tests__/set.test.js +316 -0
- package/__tests__/throughExecProps.test.js +86 -0
- package/__tests__/throughInitialDefine.test.js +104 -0
- package/__tests__/throughInitialExec.test.js +92 -0
- package/__tests__/throughUpdatedDefine.test.js +92 -0
- package/__tests__/throughUpdatedExec.test.js +110 -0
- package/__tests__/tree.test.js +15 -0
- package/__tests__/update.test.js +253 -0
- package/children.js +105 -0
- package/create.js +125 -252
- package/dist/cjs/__tests__/checkIfOnUpdate.test.js +73 -0
- package/dist/cjs/__tests__/children.test.js +177 -0
- package/dist/cjs/__tests__/define.test.js +75 -0
- package/dist/cjs/__tests__/inheritStateUpdates.test.js +62 -0
- package/dist/cjs/__tests__/renderElement.test.js +138 -0
- package/dist/cjs/__tests__/resetElement.test.js +35 -0
- package/dist/cjs/__tests__/set.test.js +256 -0
- package/dist/cjs/__tests__/throughExecProps.test.js +62 -0
- package/dist/cjs/__tests__/throughInitialDefine.test.js +79 -0
- package/dist/cjs/__tests__/throughInitialExec.test.js +73 -0
- package/dist/cjs/__tests__/throughUpdatedDefine.test.js +69 -0
- package/dist/cjs/__tests__/throughUpdatedExec.test.js +84 -0
- package/dist/cjs/__tests__/tree.test.js +11 -0
- package/dist/cjs/__tests__/update.test.js +219 -0
- package/dist/cjs/children.js +87 -0
- package/dist/cjs/create.js +79 -177
- package/dist/cjs/iterate.js +29 -13
- package/dist/cjs/methods/set.js +27 -25
- package/dist/cjs/methods/v2.js +1 -5
- package/dist/cjs/mixins/attr.js +7 -6
- package/dist/cjs/mixins/index.js +0 -4
- package/dist/cjs/mixins/registry.js +7 -67
- package/dist/cjs/mixins/scope.js +1 -1
- package/dist/cjs/mixins/state.js +3 -4
- package/dist/cjs/mixins/text.js +3 -3
- package/dist/cjs/node.js +32 -22
- package/dist/cjs/set.js +112 -40
- package/dist/cjs/update.js +119 -64
- package/dist/cjs/utils/applyParam.js +2 -2
- package/dist/cjs/utils/index.js +8 -4
- package/dist/cjs/utils/onlyResolveExtends.js +4 -7
- package/dist/esm/__tests__/checkIfOnUpdate.test.js +73 -0
- package/dist/esm/__tests__/children.test.js +177 -0
- package/dist/esm/__tests__/define.test.js +53 -0
- package/dist/esm/__tests__/inheritStateUpdates.test.js +62 -0
- package/dist/esm/__tests__/renderElement.test.js +116 -0
- package/dist/esm/__tests__/resetElement.test.js +35 -0
- package/dist/esm/__tests__/set.test.js +256 -0
- package/dist/esm/__tests__/throughExecProps.test.js +62 -0
- package/dist/esm/__tests__/throughInitialDefine.test.js +79 -0
- package/dist/esm/__tests__/throughInitialExec.test.js +73 -0
- package/dist/esm/__tests__/throughUpdatedDefine.test.js +69 -0
- package/dist/esm/__tests__/throughUpdatedExec.test.js +84 -0
- package/dist/esm/__tests__/tree.test.js +11 -0
- package/dist/esm/__tests__/update.test.js +219 -0
- package/dist/esm/children.js +81 -0
- package/dist/esm/create.js +85 -188
- package/dist/esm/iterate.js +33 -16
- package/dist/esm/methods/set.js +6 -4
- package/dist/esm/methods/v2.js +1 -5
- package/dist/esm/mixins/attr.js +8 -7
- package/dist/esm/mixins/data.js +1 -1
- package/dist/esm/mixins/index.js +0 -4
- package/dist/esm/mixins/registry.js +7 -67
- package/dist/esm/mixins/scope.js +1 -1
- package/dist/esm/mixins/state.js +4 -5
- package/dist/esm/mixins/text.js +4 -7
- package/dist/esm/node.js +23 -23
- package/dist/esm/set.js +112 -40
- package/dist/esm/update.js +122 -68
- package/dist/esm/utils/applyParam.js +2 -2
- package/dist/esm/utils/index.js +4 -3
- package/dist/esm/utils/onlyResolveExtends.js +12 -8
- package/iterate.js +44 -26
- package/methods/set.js +5 -4
- package/methods/v2.js +5 -4
- package/mixins/attr.js +13 -7
- package/mixins/classList.js +7 -2
- package/mixins/data.js +1 -1
- package/mixins/index.js +1 -6
- package/mixins/registry.js +6 -53
- package/mixins/scope.js +1 -1
- package/mixins/state.js +4 -5
- package/mixins/text.js +4 -7
- package/node.js +31 -28
- package/package.json +7 -6
- package/set.js +129 -41
- package/update.js +169 -89
- package/utils/applyParam.js +7 -4
- package/utils/index.js +1 -3
- package/utils/onlyResolveExtends.js +27 -16
- package/cache/index.js +0 -3
- package/cache/options.js +0 -4
- package/dist/cjs/cache/index.js +0 -24
- package/dist/cjs/cache/options.js +0 -26
- package/dist/cjs/extend.js +0 -81
- package/dist/cjs/methods/index.js +0 -320
- package/dist/cjs/mixins/content.js +0 -67
- package/dist/cjs/props/create.js +0 -92
- package/dist/cjs/props/ignore.js +0 -24
- package/dist/cjs/props/index.js +0 -21
- package/dist/cjs/props/inherit.js +0 -51
- package/dist/cjs/props/update.js +0 -34
- package/dist/cjs/utils/component.js +0 -74
- package/dist/cjs/utils/extendUtils.js +0 -133
- package/dist/cjs/utils/object.js +0 -171
- package/dist/cjs/utils/propEvents.js +0 -39
- package/dist/esm/cache/index.js +0 -4
- package/dist/esm/cache/options.js +0 -6
- package/dist/esm/extend.js +0 -67
- package/dist/esm/methods/index.js +0 -300
- package/dist/esm/mixins/content.js +0 -47
- package/dist/esm/props/create.js +0 -72
- package/dist/esm/props/ignore.js +0 -4
- package/dist/esm/props/index.js +0 -4
- package/dist/esm/props/inherit.js +0 -31
- package/dist/esm/props/update.js +0 -14
- package/dist/esm/utils/component.js +0 -62
- package/dist/esm/utils/extendUtils.js +0 -113
- package/dist/esm/utils/object.js +0 -151
- package/dist/esm/utils/propEvents.js +0 -19
- package/extend.js +0 -90
- package/methods/index.js +0 -317
- package/mixins/content.js +0 -55
- package/props/create.js +0 -87
- package/props/ignore.js +0 -3
- package/props/index.js +0 -6
- package/props/inherit.js +0 -35
- package/props/update.js +0 -17
- package/utils/component.js +0 -68
- package/utils/extendUtils.js +0 -134
- package/utils/object.js +0 -172
- package/utils/propEvents.js +0 -19
package/dist/cjs/extend.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
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/index.js");
|
|
26
|
-
const ENV = "development";
|
|
27
|
-
let mainExtend;
|
|
28
|
-
const applyExtend = (element, parent, options = {}) => {
|
|
29
|
-
if ((0, import_utils.isFunction)(element)) element = (0, import_utils.exec)(element, parent);
|
|
30
|
-
const { props, __ref } = element;
|
|
31
|
-
let extend = (props == null ? void 0 : props.extends) || element.extends || element.extend;
|
|
32
|
-
const variant = props == null ? void 0 : props.variant;
|
|
33
|
-
const context = element.context || parent.context;
|
|
34
|
-
extend = (0, import_utils2.fallbackStringExtend)(extend, context, options, variant);
|
|
35
|
-
const extendStack = (0, import_utils2.getExtendStack)(extend, context);
|
|
36
|
-
if (ENV !== "test" || ENV !== "development") delete element.extend;
|
|
37
|
-
let childExtendStack = [];
|
|
38
|
-
if (parent) {
|
|
39
|
-
element.parent = parent;
|
|
40
|
-
if (!options.ignoreChildExtend && !(props && props.ignoreChildExtend)) {
|
|
41
|
-
childExtendStack = (0, import_utils2.getExtendStack)(parent.childExtend, context);
|
|
42
|
-
const ignoreChildExtendRecursive = props && props.ignoreChildExtendRecursive;
|
|
43
|
-
if (parent.childExtendRecursive && !ignoreChildExtendRecursive) {
|
|
44
|
-
const canExtendRecursive = element.key !== "__text";
|
|
45
|
-
if (canExtendRecursive) {
|
|
46
|
-
const childExtendRecursiveStack = (0, import_utils2.getExtendStack)(parent.childExtendRecursive, context);
|
|
47
|
-
childExtendStack = childExtendStack.concat(childExtendRecursiveStack);
|
|
48
|
-
element.childExtendRecursive = parent.childExtendRecursive;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const extendLength = extendStack.length;
|
|
54
|
-
const childExtendLength = childExtendStack.length;
|
|
55
|
-
let stack = [];
|
|
56
|
-
if (extendLength && childExtendLength) {
|
|
57
|
-
stack = (0, import_utils2.jointStacks)(extendStack, childExtendStack);
|
|
58
|
-
} else if (extendLength) {
|
|
59
|
-
stack = extendStack;
|
|
60
|
-
} else if (childExtendLength) {
|
|
61
|
-
stack = childExtendStack;
|
|
62
|
-
} else if (!context.defaultExtends) return element;
|
|
63
|
-
if (context.defaultExtends) {
|
|
64
|
-
if (!mainExtend) {
|
|
65
|
-
const defaultOptionsExtend = (0, import_utils2.getExtendStack)(context.defaultExtends, context);
|
|
66
|
-
mainExtend = (0, import_utils2.cloneAndMergeArrayExtend)(defaultOptionsExtend);
|
|
67
|
-
delete mainExtend.extend;
|
|
68
|
-
}
|
|
69
|
-
stack = [].concat(stack, mainExtend);
|
|
70
|
-
}
|
|
71
|
-
if (__ref) __ref.__extend = stack;
|
|
72
|
-
let mergedExtend = (0, import_utils2.cloneAndMergeArrayExtend)(stack);
|
|
73
|
-
const COMPONENTS = context && context.components || options.components;
|
|
74
|
-
const component = (0, import_utils.exec)(element.component || mergedExtend.component, element);
|
|
75
|
-
if (component && COMPONENTS && COMPONENTS[component]) {
|
|
76
|
-
const componentExtend = (0, import_utils2.cloneAndMergeArrayExtend)((0, import_utils2.getExtendStack)(COMPONENTS[component]));
|
|
77
|
-
mergedExtend = (0, import_utils2.deepMergeExtend)(componentExtend, mergedExtend);
|
|
78
|
-
}
|
|
79
|
-
const merged = (0, import_utils2.deepMergeExtend)(element, mergedExtend);
|
|
80
|
-
return merged;
|
|
81
|
-
};
|
|
@@ -1,320 +0,0 @@
|
|
|
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 methods_exports = {};
|
|
20
|
-
__export(methods_exports, {
|
|
21
|
-
METHODS: () => METHODS,
|
|
22
|
-
call: () => call,
|
|
23
|
-
defineSetter: () => defineSetter,
|
|
24
|
-
error: () => error,
|
|
25
|
-
get: () => get,
|
|
26
|
-
getPath: () => getPath,
|
|
27
|
-
getRef: () => getRef,
|
|
28
|
-
isMethod: () => isMethod,
|
|
29
|
-
keys: () => keys,
|
|
30
|
-
log: () => log,
|
|
31
|
-
lookdown: () => lookdown,
|
|
32
|
-
lookdownAll: () => lookdownAll,
|
|
33
|
-
lookup: () => lookup,
|
|
34
|
-
nextElement: () => nextElement,
|
|
35
|
-
parse: () => parse,
|
|
36
|
-
parseDeep: () => parseDeep,
|
|
37
|
-
previousElement: () => previousElement,
|
|
38
|
-
remove: () => remove,
|
|
39
|
-
setNodeStyles: () => setNodeStyles,
|
|
40
|
-
setProps: () => setProps,
|
|
41
|
-
spotByPath: () => spotByPath,
|
|
42
|
-
variables: () => variables,
|
|
43
|
-
verbose: () => verbose,
|
|
44
|
-
warn: () => warn
|
|
45
|
-
});
|
|
46
|
-
module.exports = __toCommonJS(methods_exports);
|
|
47
|
-
var import_event = require("@domql/event");
|
|
48
|
-
var import_utils = require("@domql/utils");
|
|
49
|
-
var import_tree = require("../tree.js");
|
|
50
|
-
var import_mixins = require("../mixins/index.js");
|
|
51
|
-
const ENV = "development";
|
|
52
|
-
function spotByPath(path) {
|
|
53
|
-
const element = this;
|
|
54
|
-
const arr = [].concat(path);
|
|
55
|
-
let active = import_tree.TREE[arr[0]];
|
|
56
|
-
if (!arr || !arr.length) return console.log(arr, "on", element.key, "is undefined");
|
|
57
|
-
while (active.key === arr[0]) {
|
|
58
|
-
arr.shift();
|
|
59
|
-
if (!arr.length) break;
|
|
60
|
-
active = active[arr[0]];
|
|
61
|
-
if (!active) return;
|
|
62
|
-
}
|
|
63
|
-
return active;
|
|
64
|
-
}
|
|
65
|
-
function lookup(param) {
|
|
66
|
-
const el = this;
|
|
67
|
-
let { parent } = el;
|
|
68
|
-
if ((0, import_utils.isFunction)(param)) {
|
|
69
|
-
if (parent.state && param(parent, parent.state, parent.context)) return parent;
|
|
70
|
-
else if (parent.parent) return parent.lookup(param);
|
|
71
|
-
else return;
|
|
72
|
-
}
|
|
73
|
-
if (el[param]) return el[param];
|
|
74
|
-
while (parent.param !== param) {
|
|
75
|
-
if (parent[param]) return parent[param];
|
|
76
|
-
parent = parent.parent;
|
|
77
|
-
if (!parent) return;
|
|
78
|
-
}
|
|
79
|
-
return parent;
|
|
80
|
-
}
|
|
81
|
-
function lookdown(param) {
|
|
82
|
-
var _a;
|
|
83
|
-
const el = this;
|
|
84
|
-
const { __ref: ref } = el;
|
|
85
|
-
const children = ref.__children;
|
|
86
|
-
for (let i = 0; i < children.length; i++) {
|
|
87
|
-
const v = children[i];
|
|
88
|
-
const childElem = el[v];
|
|
89
|
-
if (v === param) return childElem;
|
|
90
|
-
else if ((0, import_utils.isFunction)(param)) {
|
|
91
|
-
const exec = param(childElem, childElem.state, childElem.context);
|
|
92
|
-
if (childElem.state && exec) {
|
|
93
|
-
return childElem;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
const lookdown2 = (_a = childElem == null ? void 0 : childElem.lookdown) == null ? void 0 : _a.call(childElem, param);
|
|
97
|
-
if (lookdown2) return lookdown2;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
function lookdownAll(param, results = []) {
|
|
101
|
-
var _a;
|
|
102
|
-
const el = this;
|
|
103
|
-
const { __ref: ref } = el;
|
|
104
|
-
const children = ref.__children;
|
|
105
|
-
for (let i = 0; i < children.length; i++) {
|
|
106
|
-
const v = children[i];
|
|
107
|
-
const childElem = el[v];
|
|
108
|
-
if (v === param) results.push(childElem);
|
|
109
|
-
else if ((0, import_utils.isFunction)(param)) {
|
|
110
|
-
const exec = param(childElem, childElem.state, childElem.context);
|
|
111
|
-
if (childElem.state && exec) results.push(childElem);
|
|
112
|
-
}
|
|
113
|
-
(_a = childElem == null ? void 0 : childElem.lookdownAll) == null ? void 0 : _a.call(childElem, param, results);
|
|
114
|
-
}
|
|
115
|
-
return results.length ? results : void 0;
|
|
116
|
-
}
|
|
117
|
-
function setNodeStyles(params = {}) {
|
|
118
|
-
var _a;
|
|
119
|
-
const el = this;
|
|
120
|
-
if (!((_a = el.node) == null ? void 0 : _a.style)) return;
|
|
121
|
-
for (const param in params) {
|
|
122
|
-
const value = params[param];
|
|
123
|
-
const childElem = el[param];
|
|
124
|
-
if ((0, import_utils.isObject)(value) && childElem) setNodeStyles.call(childElem, value);
|
|
125
|
-
else el.node.style[param] = value;
|
|
126
|
-
}
|
|
127
|
-
return el;
|
|
128
|
-
}
|
|
129
|
-
function remove(opts) {
|
|
130
|
-
const element = this;
|
|
131
|
-
const beforeRemoveReturns = (0, import_event.triggerEventOn)("beforeRemove", element, opts);
|
|
132
|
-
if (beforeRemoveReturns === false) return element;
|
|
133
|
-
if ((0, import_utils.isFunction)(element.node.remove)) element.node.remove();
|
|
134
|
-
else if (!(0, import_utils.isProduction)()) {
|
|
135
|
-
console.warn("This item cant be removed");
|
|
136
|
-
element.log();
|
|
137
|
-
}
|
|
138
|
-
delete element.parent[element.key];
|
|
139
|
-
if (element.parent.__ref) element.parent.__ref.__children = (0, import_utils.removeValueFromArray)(element.parent.__ref.__children, element.key);
|
|
140
|
-
(0, import_event.triggerEventOn)("remove", element, opts);
|
|
141
|
-
}
|
|
142
|
-
function get(param) {
|
|
143
|
-
const element = this;
|
|
144
|
-
return element[param];
|
|
145
|
-
}
|
|
146
|
-
function setProps(param, options) {
|
|
147
|
-
const element = this;
|
|
148
|
-
if (!param || !element.props) return;
|
|
149
|
-
element.update({ props: param }, options);
|
|
150
|
-
return element;
|
|
151
|
-
}
|
|
152
|
-
function getRef() {
|
|
153
|
-
return this.__ref;
|
|
154
|
-
}
|
|
155
|
-
function getPath() {
|
|
156
|
-
return this.getRef().path;
|
|
157
|
-
}
|
|
158
|
-
const defineSetter = (element, key, get2, set) => Object.defineProperty(element, key, { get: get2, set });
|
|
159
|
-
function keys() {
|
|
160
|
-
const element = this;
|
|
161
|
-
const keys2 = [];
|
|
162
|
-
for (const param in element) {
|
|
163
|
-
if (import_mixins.REGISTRY[param] && !import_mixins.parseFilters.elementKeys.includes(param) || !Object.hasOwnProperty.call(element, param)) {
|
|
164
|
-
continue;
|
|
165
|
-
}
|
|
166
|
-
keys2.push(param);
|
|
167
|
-
}
|
|
168
|
-
return keys2;
|
|
169
|
-
}
|
|
170
|
-
function parse(excl = []) {
|
|
171
|
-
const element = this;
|
|
172
|
-
const obj = {};
|
|
173
|
-
const keyList = keys.call(element);
|
|
174
|
-
keyList.forEach((v) => {
|
|
175
|
-
if (excl.includes(v)) return;
|
|
176
|
-
const val = element[v];
|
|
177
|
-
if (v === "state") {
|
|
178
|
-
if (element.__ref && !element.__ref.__hasRootState) return;
|
|
179
|
-
const parsedVal = (0, import_utils.isFunction)(val && val.parse) ? val.parse() : val;
|
|
180
|
-
obj[v] = (0, import_utils.isFunction)(parsedVal) ? parsedVal : JSON.parse(JSON.stringify(parsedVal || {}));
|
|
181
|
-
} else if (v === "scope") {
|
|
182
|
-
if (element.__ref && !element.__ref.__hasRootScope) return;
|
|
183
|
-
obj[v] = JSON.parse(JSON.stringify(val || {}));
|
|
184
|
-
} else if (v === "props") {
|
|
185
|
-
const { __element, update, ...props } = element[v];
|
|
186
|
-
obj[v] = props;
|
|
187
|
-
} else if ((0, import_utils.isDefined)(val) && Object.hasOwnProperty.call(element, v)) obj[v] = val;
|
|
188
|
-
});
|
|
189
|
-
return obj;
|
|
190
|
-
}
|
|
191
|
-
function parseDeep(excl = []) {
|
|
192
|
-
const element = this;
|
|
193
|
-
const obj = parse.call(element, excl);
|
|
194
|
-
for (const v in obj) {
|
|
195
|
-
if (excl.includes(v)) return;
|
|
196
|
-
if ((0, import_utils.isObjectLike)(obj[v])) {
|
|
197
|
-
obj[v] = parseDeep.call(obj[v], excl);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return obj;
|
|
201
|
-
}
|
|
202
|
-
function verbose(...args) {
|
|
203
|
-
if (ENV !== "test" && ENV !== "development") return;
|
|
204
|
-
const element = this;
|
|
205
|
-
const { __ref: ref } = element;
|
|
206
|
-
console.groupCollapsed(element.key);
|
|
207
|
-
if (args.length) {
|
|
208
|
-
args.forEach((v) => console.log(`%c${v}:
|
|
209
|
-
`, "font-weight: bold", element[v]));
|
|
210
|
-
} else {
|
|
211
|
-
console.log(ref.path);
|
|
212
|
-
const keys2 = element.keys();
|
|
213
|
-
keys2.forEach((v) => console.log(`%c${v}:`, "font-weight: bold", element[v]));
|
|
214
|
-
}
|
|
215
|
-
console.log(element);
|
|
216
|
-
console.groupEnd(element.key);
|
|
217
|
-
return element;
|
|
218
|
-
}
|
|
219
|
-
function log(...params) {
|
|
220
|
-
if (ENV === "test" || ENV === "development") {
|
|
221
|
-
console.log(...params);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
function warn(...params) {
|
|
225
|
-
if (ENV === "test" || ENV === "development") {
|
|
226
|
-
console.warn(...params);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
function error(...params) {
|
|
230
|
-
var _a, _b;
|
|
231
|
-
if (ENV === "test" || ENV === "development") {
|
|
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);
|
|
234
|
-
throw new Error(...params);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
function nextElement() {
|
|
238
|
-
const element = this;
|
|
239
|
-
const { key, parent } = element;
|
|
240
|
-
const { __children } = parent.__ref;
|
|
241
|
-
const currentIndex = __children.indexOf(key);
|
|
242
|
-
const nextChild = __children[currentIndex + 1];
|
|
243
|
-
return parent[nextChild];
|
|
244
|
-
}
|
|
245
|
-
function previousElement(el) {
|
|
246
|
-
const element = el || this;
|
|
247
|
-
const { key, parent } = element;
|
|
248
|
-
const { __children } = parent.__ref;
|
|
249
|
-
if (!__children) return;
|
|
250
|
-
const currentIndex = __children.indexOf(key);
|
|
251
|
-
return parent[__children[currentIndex - 1]];
|
|
252
|
-
}
|
|
253
|
-
function variables(obj = {}) {
|
|
254
|
-
const element = this;
|
|
255
|
-
if (!element.data) element.data = {};
|
|
256
|
-
if (!element.data.varCaches) element.data.varCaches = {};
|
|
257
|
-
const varCaches = element.data.varCaches;
|
|
258
|
-
const changes = {};
|
|
259
|
-
let changed;
|
|
260
|
-
for (const key in obj) {
|
|
261
|
-
if (obj[key] !== varCaches[key]) {
|
|
262
|
-
changed = true;
|
|
263
|
-
changes[key] = obj[key];
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
return {
|
|
267
|
-
changed: (cb) => {
|
|
268
|
-
if (!changed) return;
|
|
269
|
-
const returns = cb(changes, (0, import_utils.deepClone)(varCaches));
|
|
270
|
-
for (const key in changes) {
|
|
271
|
-
varCaches[key] = changes[key];
|
|
272
|
-
}
|
|
273
|
-
return returns;
|
|
274
|
-
},
|
|
275
|
-
timeout: (cb, timeout) => {
|
|
276
|
-
if (!changed) return;
|
|
277
|
-
const t = setTimeout(() => {
|
|
278
|
-
cb(changes);
|
|
279
|
-
clearTimeout(t);
|
|
280
|
-
}, timeout);
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
function call(fnKey, ...args) {
|
|
285
|
-
var _a;
|
|
286
|
-
const context = this.context;
|
|
287
|
-
return (_a = context.utils[fnKey] || context.functions[fnKey] || context.methods[fnKey] || context.snippets[fnKey]) == null ? void 0 : _a.call(this, ...args);
|
|
288
|
-
}
|
|
289
|
-
const METHODS = [
|
|
290
|
-
"set",
|
|
291
|
-
"reset",
|
|
292
|
-
"update",
|
|
293
|
-
"remove",
|
|
294
|
-
"updateContent",
|
|
295
|
-
"removeContent",
|
|
296
|
-
"lookup",
|
|
297
|
-
"lookdown",
|
|
298
|
-
"lookdownAll",
|
|
299
|
-
"getRef",
|
|
300
|
-
"getPath",
|
|
301
|
-
"setNodeStyles",
|
|
302
|
-
"spotByPath",
|
|
303
|
-
"keys",
|
|
304
|
-
"parse",
|
|
305
|
-
"setProps",
|
|
306
|
-
"parseDeep",
|
|
307
|
-
"variables",
|
|
308
|
-
"if",
|
|
309
|
-
"log",
|
|
310
|
-
"verbose",
|
|
311
|
-
"warn",
|
|
312
|
-
"error",
|
|
313
|
-
"call",
|
|
314
|
-
"nextElement",
|
|
315
|
-
"previousElement"
|
|
316
|
-
];
|
|
317
|
-
function isMethod(param, element) {
|
|
318
|
-
var _a, _b;
|
|
319
|
-
return METHODS.includes(param) || ((_b = (_a = element == null ? void 0 : element.context) == null ? void 0 : _a.methods) == null ? void 0 : _b[param]);
|
|
320
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
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 content_exports = {};
|
|
20
|
-
__export(content_exports, {
|
|
21
|
-
default: () => content_default,
|
|
22
|
-
removeContent: () => removeContent,
|
|
23
|
-
setContent: () => setContent,
|
|
24
|
-
updateContent: () => updateContent
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(content_exports);
|
|
27
|
-
var import_utils = require("@domql/utils");
|
|
28
|
-
var import_set = require("../set.js");
|
|
29
|
-
const updateContent = function(params, options) {
|
|
30
|
-
const element = this;
|
|
31
|
-
const ref = element.__ref;
|
|
32
|
-
const contentKey = ref.contentElementKey;
|
|
33
|
-
if (!element[contentKey]) return;
|
|
34
|
-
if (element[contentKey].update) element[contentKey].update(params, options);
|
|
35
|
-
};
|
|
36
|
-
const removeContent = function(el, opts = {}) {
|
|
37
|
-
const element = el || this;
|
|
38
|
-
const { __ref: ref } = element;
|
|
39
|
-
const contentElementKey = (0, import_utils.setContentKey)(element, opts);
|
|
40
|
-
if (opts.contentElementKey !== "content") opts.contentElementKey = "content";
|
|
41
|
-
if (element[contentElementKey]) {
|
|
42
|
-
if (element[contentElementKey].node && element.node) {
|
|
43
|
-
if (element[contentElementKey].tag === "fragment") element.node.innerHTML = "";
|
|
44
|
-
else {
|
|
45
|
-
const contentNode = element[contentElementKey].node;
|
|
46
|
-
if (contentNode.parentNode === element.node) element.node.removeChild(element[contentElementKey].node);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const { __cached } = ref;
|
|
50
|
-
if (__cached && __cached[contentElementKey]) {
|
|
51
|
-
if (__cached[contentElementKey].tag === "fragment") __cached[contentElementKey].parent.node.innerHTML = "";
|
|
52
|
-
else if (__cached[contentElementKey] && (0, import_utils.isFunction)(__cached[contentElementKey].remove)) __cached[contentElementKey].remove();
|
|
53
|
-
}
|
|
54
|
-
delete element[contentElementKey];
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
function setContent(param, element, node, opts) {
|
|
58
|
-
const contentElementKey = (0, import_utils.setContentKey)(element, opts);
|
|
59
|
-
if (param && element) {
|
|
60
|
-
if (element[contentElementKey].update) {
|
|
61
|
-
element[contentElementKey].update({}, opts);
|
|
62
|
-
} else {
|
|
63
|
-
import_set.set.call(element, param, opts);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
var content_default = setContent;
|
package/dist/cjs/props/create.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
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 create_exports = {};
|
|
20
|
-
__export(create_exports, {
|
|
21
|
-
createProps: () => createProps,
|
|
22
|
-
syncProps: () => syncProps
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(create_exports);
|
|
25
|
-
var import_utils = require("@domql/utils");
|
|
26
|
-
var import_ignore = require("./ignore.js");
|
|
27
|
-
var import_inherit = require("./inherit.js");
|
|
28
|
-
const createPropsStack = (element, parent) => {
|
|
29
|
-
const { props, __ref: ref } = element;
|
|
30
|
-
const propsStack = ref.__props = (0, import_inherit.inheritParentProps)(element, parent);
|
|
31
|
-
if ((0, import_utils.isObject)(props)) propsStack.push(props);
|
|
32
|
-
else if (props === "inherit" && parent.props) propsStack.push(parent.props);
|
|
33
|
-
else if (props) propsStack.push(props);
|
|
34
|
-
if ((0, import_utils.isArray)(ref.__extend)) {
|
|
35
|
-
ref.__extend.forEach((extend) => {
|
|
36
|
-
if (extend.props && extend.props !== props) propsStack.push(extend.props);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
ref.__props = propsStack;
|
|
40
|
-
return propsStack;
|
|
41
|
-
};
|
|
42
|
-
const syncProps = (props, element, opts) => {
|
|
43
|
-
element.props = {};
|
|
44
|
-
const mergedProps = {};
|
|
45
|
-
props.forEach((v) => {
|
|
46
|
-
if (import_ignore.IGNORE_PROPS_PARAMS.includes(v)) return;
|
|
47
|
-
let execProps;
|
|
48
|
-
try {
|
|
49
|
-
execProps = (0, import_utils.exec)(v, element);
|
|
50
|
-
} catch (e) {
|
|
51
|
-
element.error(e, opts);
|
|
52
|
-
}
|
|
53
|
-
element.props = (0, import_utils.deepMerge)(
|
|
54
|
-
mergedProps,
|
|
55
|
-
(0, import_utils.deepClone)(execProps, { ignore: import_ignore.IGNORE_PROPS_PARAMS }),
|
|
56
|
-
import_ignore.IGNORE_PROPS_PARAMS
|
|
57
|
-
);
|
|
58
|
-
});
|
|
59
|
-
element.props = mergedProps;
|
|
60
|
-
const methods = { update: update.bind(element.props), __element: element };
|
|
61
|
-
Object.setPrototypeOf(element.props, methods);
|
|
62
|
-
return element.props;
|
|
63
|
-
};
|
|
64
|
-
const createProps = function(element, parent, options) {
|
|
65
|
-
const { __ref: ref } = element;
|
|
66
|
-
const applyProps = () => {
|
|
67
|
-
const propsStack = options.cachedProps || createPropsStack(element, parent);
|
|
68
|
-
if (propsStack.length) {
|
|
69
|
-
ref.__props = propsStack;
|
|
70
|
-
syncProps(propsStack, element);
|
|
71
|
-
} else {
|
|
72
|
-
ref.__props = options.cachedProps || [];
|
|
73
|
-
element.props = {};
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
if (ref.__if) applyProps();
|
|
77
|
-
else {
|
|
78
|
-
try {
|
|
79
|
-
applyProps();
|
|
80
|
-
} catch {
|
|
81
|
-
element.props = {};
|
|
82
|
-
ref.__props = options.cachedProps || [];
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
const methods = { update: update.bind(element.props), __element: element };
|
|
86
|
-
Object.setPrototypeOf(element.props, methods);
|
|
87
|
-
return element;
|
|
88
|
-
};
|
|
89
|
-
function update(props, options) {
|
|
90
|
-
const element = this.__element;
|
|
91
|
-
element.update({ props }, options);
|
|
92
|
-
}
|
package/dist/cjs/props/ignore.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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 ignore_exports = {};
|
|
20
|
-
__export(ignore_exports, {
|
|
21
|
-
IGNORE_PROPS_PARAMS: () => IGNORE_PROPS_PARAMS
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(ignore_exports);
|
|
24
|
-
const IGNORE_PROPS_PARAMS = ["update", "__element"];
|
package/dist/cjs/props/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var props_exports = {};
|
|
17
|
-
module.exports = __toCommonJS(props_exports);
|
|
18
|
-
__reExport(props_exports, require("./ignore.js"), module.exports);
|
|
19
|
-
__reExport(props_exports, require("./create.js"), module.exports);
|
|
20
|
-
__reExport(props_exports, require("./inherit.js"), module.exports);
|
|
21
|
-
__reExport(props_exports, require("./update.js"), module.exports);
|
|
@@ -1,51 +0,0 @@
|
|
|
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 inherit_exports = {};
|
|
20
|
-
__export(inherit_exports, {
|
|
21
|
-
inheritParentProps: () => inheritParentProps
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(inherit_exports);
|
|
24
|
-
var import_utils = require("@domql/utils");
|
|
25
|
-
const objectizeStringProperty = (propValue) => {
|
|
26
|
-
if ((0, import_utils.is)(propValue)("string", "number")) {
|
|
27
|
-
return { inheritedString: propValue };
|
|
28
|
-
}
|
|
29
|
-
return propValue;
|
|
30
|
-
};
|
|
31
|
-
const inheritParentProps = (element, parent) => {
|
|
32
|
-
var _a;
|
|
33
|
-
let propsStack = [];
|
|
34
|
-
const parentProps = (0, import_utils.exec)(parent, parent.state).props;
|
|
35
|
-
const matchParent = parent.props && parentProps[element.key];
|
|
36
|
-
const matchParentIsString = (0, import_utils.isString)(matchParent);
|
|
37
|
-
const matchParentChildProps = parentProps && parentProps.childProps;
|
|
38
|
-
if (matchParent) {
|
|
39
|
-
if (matchParentIsString) {
|
|
40
|
-
const inheritedStringExists = propsStack.filter((v) => v.inheritedString)[0];
|
|
41
|
-
if (inheritedStringExists) inheritedStringExists.inheritedString = matchParent;
|
|
42
|
-
else {
|
|
43
|
-
propsStack = [].concat(objectizeStringProperty(matchParent), propsStack);
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
propsStack.push(objectizeStringProperty(matchParent));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (matchParentChildProps && !((_a = element == null ? void 0 : element.props) == null ? void 0 : _a.ignoreChildProps)) propsStack.push(matchParentChildProps);
|
|
50
|
-
return propsStack;
|
|
51
|
-
};
|
package/dist/cjs/props/update.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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 update_exports = {};
|
|
20
|
-
__export(update_exports, {
|
|
21
|
-
updateProps: () => updateProps
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(update_exports);
|
|
24
|
-
var import_create = require("./create.js");
|
|
25
|
-
var import_inherit = require("./inherit.js");
|
|
26
|
-
const updateProps = (newProps, element, parent) => {
|
|
27
|
-
const { __ref } = element;
|
|
28
|
-
let propsStack = __ref.__props;
|
|
29
|
-
const parentProps = (0, import_inherit.inheritParentProps)(element, parent);
|
|
30
|
-
if (parentProps.length) propsStack = __ref.__props = [].concat(parentProps, propsStack);
|
|
31
|
-
if (newProps) propsStack = __ref.__props = [].concat(newProps, propsStack);
|
|
32
|
-
if (propsStack) (0, import_create.syncProps)(propsStack, element);
|
|
33
|
-
return element;
|
|
34
|
-
};
|