@domql/utils 2.5.139 → 2.5.140
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/component.js +22 -2
- package/dist/cjs/component.js +24 -3
- package/package.json +2 -2
package/component.js
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
isArray,
|
|
7
7
|
isFunction,
|
|
8
8
|
isObject,
|
|
9
|
+
isObjectLike,
|
|
9
10
|
isString,
|
|
10
11
|
joinArrays,
|
|
11
12
|
overwriteDeep
|
|
@@ -96,11 +97,20 @@ export const addChildrenIfNotInOriginal = (element, parent, key) => {
|
|
|
96
97
|
const childKey = childElems[i]
|
|
97
98
|
const childElem = element[childKey]
|
|
98
99
|
const newChild = element.props[childKey]
|
|
99
|
-
if (newChild
|
|
100
|
+
if (newChild?.ignoreExtend) continue
|
|
100
101
|
if (!childElem) element[childKey] = deepCloneWithExtend(newChild)
|
|
101
102
|
else {
|
|
102
103
|
const isSugar = checkIfSugar(childElem)
|
|
103
|
-
if (!isSugar)
|
|
104
|
+
if (!isSugar) continue
|
|
105
|
+
const inheritedChildElem = element[childKey].props
|
|
106
|
+
if (isObjectLike(newChild)) {
|
|
107
|
+
overwriteDeep(inheritedChildElem, newChild)
|
|
108
|
+
} else if (isFunction(newChild)) {
|
|
109
|
+
element[childKey] = {
|
|
110
|
+
extend: element[childKey],
|
|
111
|
+
props: newChild
|
|
112
|
+
}
|
|
113
|
+
}
|
|
104
114
|
}
|
|
105
115
|
}
|
|
106
116
|
}
|
|
@@ -195,3 +205,13 @@ export const getExtendsInElement = (obj) => {
|
|
|
195
205
|
traverse(obj)
|
|
196
206
|
return result
|
|
197
207
|
}
|
|
208
|
+
|
|
209
|
+
export const setContentKey = (el, opts = {}) => {
|
|
210
|
+
const { __ref: ref } = el
|
|
211
|
+
const contentElementKey = opts.contentElementKey
|
|
212
|
+
if ((contentElementKey !== 'content' && contentElementKey !== ref.contentElementKey) || !ref.contentElementKey) {
|
|
213
|
+
ref.contentElementKey = contentElementKey || 'content'
|
|
214
|
+
} else ref.contentElementKey = 'content'
|
|
215
|
+
if (contentElementKey !== 'content') opts.contentElementKey = 'content'
|
|
216
|
+
return ref.contentElementKey
|
|
217
|
+
}
|
package/dist/cjs/component.js
CHANGED
|
@@ -28,7 +28,8 @@ __export(component_exports, {
|
|
|
28
28
|
getChildrenComponentsByKey: () => getChildrenComponentsByKey,
|
|
29
29
|
getExtendsInElement: () => getExtendsInElement,
|
|
30
30
|
hasVariantProp: () => hasVariantProp,
|
|
31
|
-
isVariant: () => isVariant
|
|
31
|
+
isVariant: () => isVariant,
|
|
32
|
+
setContentKey: () => setContentKey
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(component_exports);
|
|
34
35
|
var import__ = require(".");
|
|
@@ -103,14 +104,23 @@ const addChildrenIfNotInOriginal = (element, parent, key) => {
|
|
|
103
104
|
const childKey = childElems[i];
|
|
104
105
|
const childElem = element[childKey];
|
|
105
106
|
const newChild = element.props[childKey];
|
|
106
|
-
if (newChild.ignoreExtend)
|
|
107
|
+
if (newChild == null ? void 0 : newChild.ignoreExtend)
|
|
107
108
|
continue;
|
|
108
109
|
if (!childElem)
|
|
109
110
|
element[childKey] = (0, import__.deepCloneWithExtend)(newChild);
|
|
110
111
|
else {
|
|
111
112
|
const isSugar = checkIfSugar(childElem);
|
|
112
113
|
if (!isSugar)
|
|
113
|
-
|
|
114
|
+
continue;
|
|
115
|
+
const inheritedChildElem = element[childKey].props;
|
|
116
|
+
if ((0, import__.isObjectLike)(newChild)) {
|
|
117
|
+
(0, import__.overwriteDeep)(inheritedChildElem, newChild);
|
|
118
|
+
} else if ((0, import__.isFunction)(newChild)) {
|
|
119
|
+
element[childKey] = {
|
|
120
|
+
extend: element[childKey],
|
|
121
|
+
props: newChild
|
|
122
|
+
};
|
|
123
|
+
}
|
|
114
124
|
}
|
|
115
125
|
}
|
|
116
126
|
};
|
|
@@ -189,3 +199,14 @@ const getExtendsInElement = (obj) => {
|
|
|
189
199
|
traverse(obj);
|
|
190
200
|
return result;
|
|
191
201
|
};
|
|
202
|
+
const setContentKey = (el, opts = {}) => {
|
|
203
|
+
const { __ref: ref } = el;
|
|
204
|
+
const contentElementKey = opts.contentElementKey;
|
|
205
|
+
if (contentElementKey !== "content" && contentElementKey !== ref.contentElementKey || !ref.contentElementKey) {
|
|
206
|
+
ref.contentElementKey = contentElementKey || "content";
|
|
207
|
+
} else
|
|
208
|
+
ref.contentElementKey = "content";
|
|
209
|
+
if (contentElementKey !== "content")
|
|
210
|
+
opts.contentElementKey = "content";
|
|
211
|
+
return ref.contentElementKey;
|
|
212
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.140",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"build": "yarn build:cjs",
|
|
26
26
|
"prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "2fc2e5d07523014581b0747b4201cc6afea32860",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@babel/core": "^7.12.0"
|
|
31
31
|
}
|