@domql/utils 2.5.151 → 2.5.153
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 +24 -23
- package/dist/cjs/component.js +26 -20
- package/package.json +2 -2
package/component.js
CHANGED
|
@@ -6,10 +6,8 @@ import {
|
|
|
6
6
|
isArray,
|
|
7
7
|
isFunction,
|
|
8
8
|
isObject,
|
|
9
|
-
isObjectLike,
|
|
10
9
|
isString,
|
|
11
|
-
joinArrays
|
|
12
|
-
overwriteDeep
|
|
10
|
+
joinArrays
|
|
13
11
|
} from '.'
|
|
14
12
|
const ENV = process.env.NODE_ENV
|
|
15
13
|
|
|
@@ -36,13 +34,13 @@ export const addAdditionalExtend = (newExtend, element) => {
|
|
|
36
34
|
return { ...element, extend }
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
const checkIfSugar = (element, parent, key) => {
|
|
37
|
+
export const checkIfSugar = (element, parent, key) => {
|
|
40
38
|
const {
|
|
41
39
|
extend,
|
|
42
40
|
props,
|
|
43
41
|
childExtend,
|
|
44
42
|
extends: extendProps,
|
|
45
|
-
|
|
43
|
+
childExtends,
|
|
46
44
|
childProps,
|
|
47
45
|
children,
|
|
48
46
|
on,
|
|
@@ -51,15 +49,16 @@ const checkIfSugar = (element, parent, key) => {
|
|
|
51
49
|
$propsCollection
|
|
52
50
|
} = element
|
|
53
51
|
const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection
|
|
54
|
-
if (hasComponentAttrs && (childProps || extendProps || children ||
|
|
55
|
-
|
|
52
|
+
if (hasComponentAttrs && (childProps || extendProps || children || childExtends)) {
|
|
53
|
+
const logErr = (parent || element)?.error
|
|
54
|
+
if (logErr) logErr('Sugar component includes params for builtin components', { verbose: true })
|
|
56
55
|
}
|
|
57
|
-
return !hasComponentAttrs || childProps || extendProps || children ||
|
|
56
|
+
return !hasComponentAttrs || childProps || extendProps || children || childExtends
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
export const extendizeByKey = (element, parent, key) => {
|
|
61
60
|
const { context } = parent
|
|
62
|
-
const { tag, extend,
|
|
61
|
+
const { tag, extend, childExtends } = element
|
|
63
62
|
const isSugar = checkIfSugar(element, parent, key)
|
|
64
63
|
|
|
65
64
|
const extendFromKey = key.includes('+')
|
|
@@ -78,7 +77,7 @@ export const extendizeByKey = (element, parent, key) => {
|
|
|
78
77
|
tag,
|
|
79
78
|
props: { ...element }
|
|
80
79
|
})
|
|
81
|
-
if (
|
|
80
|
+
if (childExtends) newElem.childExtend = childExtends
|
|
82
81
|
return newElem
|
|
83
82
|
} else if (!extend || extend === true) {
|
|
84
83
|
return {
|
|
@@ -97,7 +96,7 @@ export const extendizeByKey = (element, parent, key) => {
|
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
|
|
100
|
-
function getCapitalCaseKeys (obj) {
|
|
99
|
+
export function getCapitalCaseKeys (obj) {
|
|
101
100
|
return Object.keys(obj).filter(key => /^[A-Z]/.test(key))
|
|
102
101
|
}
|
|
103
102
|
|
|
@@ -109,20 +108,22 @@ export const addChildrenIfNotInOriginal = (element, parent, key) => {
|
|
|
109
108
|
const childKey = childElems[i]
|
|
110
109
|
const childElem = element[childKey]
|
|
111
110
|
const newChild = element.props[childKey]
|
|
111
|
+
|
|
112
|
+
const assignChild = (val) => {
|
|
113
|
+
element[childKey] = val
|
|
114
|
+
delete element.props[childKey]
|
|
115
|
+
}
|
|
116
|
+
|
|
112
117
|
if (newChild?.ignoreExtend) continue
|
|
113
|
-
if (
|
|
118
|
+
if (newChild === null) assignChild(null)
|
|
119
|
+
else if (!childElem) assignChild(deepCloneWithExtend(newChild))
|
|
114
120
|
else {
|
|
115
|
-
const
|
|
116
|
-
if (
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
element[childKey] = {
|
|
122
|
-
extend: element[childKey],
|
|
123
|
-
props: newChild
|
|
124
|
-
}
|
|
125
|
-
}
|
|
121
|
+
const isSugarChildElem = checkIfSugar(childElem, parent, key)
|
|
122
|
+
if (isSugarChildElem) continue
|
|
123
|
+
assignChild({
|
|
124
|
+
extend: element[childKey],
|
|
125
|
+
props: newChild
|
|
126
|
+
})
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
}
|
package/dist/cjs/component.js
CHANGED
|
@@ -24,7 +24,9 @@ __export(component_exports, {
|
|
|
24
24
|
applyKeyComponentAsExtend: () => applyKeyComponentAsExtend,
|
|
25
25
|
checkIfKeyIsComponent: () => checkIfKeyIsComponent,
|
|
26
26
|
checkIfKeyIsProperty: () => checkIfKeyIsProperty,
|
|
27
|
+
checkIfSugar: () => checkIfSugar,
|
|
27
28
|
extendizeByKey: () => extendizeByKey,
|
|
29
|
+
getCapitalCaseKeys: () => getCapitalCaseKeys,
|
|
28
30
|
getChildrenComponentsByKey: () => getChildrenComponentsByKey,
|
|
29
31
|
getExtendsInElement: () => getExtendsInElement,
|
|
30
32
|
hasVariantProp: () => hasVariantProp,
|
|
@@ -58,12 +60,13 @@ const addAdditionalExtend = (newExtend, element) => {
|
|
|
58
60
|
return { ...element, extend };
|
|
59
61
|
};
|
|
60
62
|
const checkIfSugar = (element, parent, key) => {
|
|
63
|
+
var _a;
|
|
61
64
|
const {
|
|
62
65
|
extend,
|
|
63
66
|
props,
|
|
64
67
|
childExtend,
|
|
65
68
|
extends: extendProps,
|
|
66
|
-
|
|
69
|
+
childExtends,
|
|
67
70
|
childProps,
|
|
68
71
|
children,
|
|
69
72
|
on,
|
|
@@ -72,14 +75,16 @@ const checkIfSugar = (element, parent, key) => {
|
|
|
72
75
|
$propsCollection
|
|
73
76
|
} = element;
|
|
74
77
|
const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
|
|
75
|
-
if (hasComponentAttrs && (childProps || extendProps || children ||
|
|
76
|
-
|
|
78
|
+
if (hasComponentAttrs && (childProps || extendProps || children || childExtends)) {
|
|
79
|
+
const logErr = (_a = parent || element) == null ? void 0 : _a.error;
|
|
80
|
+
if (logErr)
|
|
81
|
+
logErr("Sugar component includes params for builtin components", { verbose: true });
|
|
77
82
|
}
|
|
78
|
-
return !hasComponentAttrs || childProps || extendProps || children ||
|
|
83
|
+
return !hasComponentAttrs || childProps || extendProps || children || childExtends;
|
|
79
84
|
};
|
|
80
85
|
const extendizeByKey = (element, parent, key) => {
|
|
81
86
|
const { context } = parent;
|
|
82
|
-
const { tag, extend,
|
|
87
|
+
const { tag, extend, childExtends } = element;
|
|
83
88
|
const isSugar = checkIfSugar(element, parent, key);
|
|
84
89
|
const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
|
|
85
90
|
const isExtendKeyComponent = context && context.components[extendFromKey];
|
|
@@ -91,8 +96,8 @@ const extendizeByKey = (element, parent, key) => {
|
|
|
91
96
|
tag,
|
|
92
97
|
props: { ...element }
|
|
93
98
|
});
|
|
94
|
-
if (
|
|
95
|
-
newElem.childExtend =
|
|
99
|
+
if (childExtends)
|
|
100
|
+
newElem.childExtend = childExtends;
|
|
96
101
|
return newElem;
|
|
97
102
|
} else if (!extend || extend === true) {
|
|
98
103
|
return {
|
|
@@ -121,23 +126,24 @@ const addChildrenIfNotInOriginal = (element, parent, key) => {
|
|
|
121
126
|
const childKey = childElems[i];
|
|
122
127
|
const childElem = element[childKey];
|
|
123
128
|
const newChild = element.props[childKey];
|
|
129
|
+
const assignChild = (val) => {
|
|
130
|
+
element[childKey] = val;
|
|
131
|
+
delete element.props[childKey];
|
|
132
|
+
};
|
|
124
133
|
if (newChild == null ? void 0 : newChild.ignoreExtend)
|
|
125
134
|
continue;
|
|
126
|
-
if (
|
|
127
|
-
|
|
135
|
+
if (newChild === null)
|
|
136
|
+
assignChild(null);
|
|
137
|
+
else if (!childElem)
|
|
138
|
+
assignChild((0, import__.deepCloneWithExtend)(newChild));
|
|
128
139
|
else {
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
140
|
+
const isSugarChildElem = checkIfSugar(childElem, parent, key);
|
|
141
|
+
if (isSugarChildElem)
|
|
131
142
|
continue;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
element[childKey] = {
|
|
137
|
-
extend: element[childKey],
|
|
138
|
-
props: newChild
|
|
139
|
-
};
|
|
140
|
-
}
|
|
143
|
+
assignChild({
|
|
144
|
+
extend: element[childKey],
|
|
145
|
+
props: newChild
|
|
146
|
+
});
|
|
141
147
|
}
|
|
142
148
|
}
|
|
143
149
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.153",
|
|
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": "ebf5debf658fdae4ec5a99b541b2518c7767e6a8",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@babel/core": "^7.12.0"
|
|
31
31
|
}
|