@domql/utils 2.5.138 → 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 +25 -4
- package/dist/cjs/component.js +28 -5
- 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
|
|
@@ -60,12 +61,13 @@ export const extendizeByKey = (element, parent, key) => {
|
|
|
60
61
|
|
|
61
62
|
if (element === isExtendKeyComponent) return element
|
|
62
63
|
else if (isSugar) {
|
|
63
|
-
|
|
64
|
+
const newElem = {
|
|
64
65
|
extend: extendFromKey,
|
|
65
|
-
childExtend: childrenExtends,
|
|
66
66
|
tag,
|
|
67
67
|
props: { ...element }
|
|
68
68
|
}
|
|
69
|
+
if (childrenExtends) newElem.childExtend = childrenExtends
|
|
70
|
+
return newElem
|
|
69
71
|
} else if (!extend || extend === true) {
|
|
70
72
|
return {
|
|
71
73
|
...element,
|
|
@@ -95,11 +97,20 @@ export const addChildrenIfNotInOriginal = (element, parent, key) => {
|
|
|
95
97
|
const childKey = childElems[i]
|
|
96
98
|
const childElem = element[childKey]
|
|
97
99
|
const newChild = element.props[childKey]
|
|
98
|
-
if (newChild
|
|
100
|
+
if (newChild?.ignoreExtend) continue
|
|
99
101
|
if (!childElem) element[childKey] = deepCloneWithExtend(newChild)
|
|
100
102
|
else {
|
|
101
103
|
const isSugar = checkIfSugar(childElem)
|
|
102
|
-
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
|
+
}
|
|
103
114
|
}
|
|
104
115
|
}
|
|
105
116
|
}
|
|
@@ -194,3 +205,13 @@ export const getExtendsInElement = (obj) => {
|
|
|
194
205
|
traverse(obj)
|
|
195
206
|
return result
|
|
196
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(".");
|
|
@@ -68,12 +69,14 @@ const extendizeByKey = (element, parent, key) => {
|
|
|
68
69
|
if (element === isExtendKeyComponent)
|
|
69
70
|
return element;
|
|
70
71
|
else if (isSugar) {
|
|
71
|
-
|
|
72
|
+
const newElem = {
|
|
72
73
|
extend: extendFromKey,
|
|
73
|
-
childExtend: childrenExtends,
|
|
74
74
|
tag,
|
|
75
75
|
props: { ...element }
|
|
76
76
|
};
|
|
77
|
+
if (childrenExtends)
|
|
78
|
+
newElem.childExtend = childrenExtends;
|
|
79
|
+
return newElem;
|
|
77
80
|
} else if (!extend || extend === true) {
|
|
78
81
|
return {
|
|
79
82
|
...element,
|
|
@@ -101,14 +104,23 @@ const addChildrenIfNotInOriginal = (element, parent, key) => {
|
|
|
101
104
|
const childKey = childElems[i];
|
|
102
105
|
const childElem = element[childKey];
|
|
103
106
|
const newChild = element.props[childKey];
|
|
104
|
-
if (newChild.ignoreExtend)
|
|
107
|
+
if (newChild == null ? void 0 : newChild.ignoreExtend)
|
|
105
108
|
continue;
|
|
106
109
|
if (!childElem)
|
|
107
110
|
element[childKey] = (0, import__.deepCloneWithExtend)(newChild);
|
|
108
111
|
else {
|
|
109
112
|
const isSugar = checkIfSugar(childElem);
|
|
110
113
|
if (!isSugar)
|
|
111
|
-
|
|
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
|
+
}
|
|
112
124
|
}
|
|
113
125
|
}
|
|
114
126
|
};
|
|
@@ -187,3 +199,14 @@ const getExtendsInElement = (obj) => {
|
|
|
187
199
|
traverse(obj);
|
|
188
200
|
return result;
|
|
189
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
|
}
|