@domql/utils 2.5.164 → 2.5.168
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 +1 -1
- package/dist/cjs/component.js +1 -1
- package/dist/cjs/string.js +5 -4
- package/dist/esm/component.js +1 -1
- package/dist/esm/string.js +5 -4
- package/package.json +2 -2
- package/string.js +4 -3
package/component.js
CHANGED
|
@@ -200,7 +200,7 @@ export const getExtendsInElement = (obj) => {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
// Check if the key is "extend" and it's either a string or an array
|
|
203
|
-
if (key === 'extend') {
|
|
203
|
+
if (key === 'extend' || key === 'extends') {
|
|
204
204
|
// Add the value of the extend key to the result array
|
|
205
205
|
if (typeof o[key] === 'string') {
|
|
206
206
|
result.push(o[key])
|
package/dist/cjs/component.js
CHANGED
|
@@ -210,7 +210,7 @@ const getExtendsInElement = (obj) => {
|
|
|
210
210
|
if (checkIfKeyIsComponent(key)) {
|
|
211
211
|
result.push(key);
|
|
212
212
|
}
|
|
213
|
-
if (key === "extend") {
|
|
213
|
+
if (key === "extend" || key === "extends") {
|
|
214
214
|
if (typeof o[key] === "string") {
|
|
215
215
|
result.push(o[key]);
|
|
216
216
|
} else if (Array.isArray(o[key])) {
|
package/dist/cjs/string.js
CHANGED
|
@@ -46,14 +46,15 @@ const brackRegex = {
|
|
|
46
46
|
2: /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g,
|
|
47
47
|
3: /\{\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}\}/g
|
|
48
48
|
};
|
|
49
|
-
|
|
49
|
+
function replaceLiteralsWithObjectFields(str, options = {}, forcedState) {
|
|
50
50
|
if (!str.includes(options.bracketsLength === 3 ? "{{{" : "{{"))
|
|
51
51
|
return str;
|
|
52
52
|
const reg = brackRegex[options.bracketsLength || 2];
|
|
53
|
+
const obj = forcedState || this.state || {};
|
|
53
54
|
return str.replace(reg, (_, parentPath, variable) => {
|
|
54
55
|
if (parentPath) {
|
|
55
56
|
const parentLevels = parentPath.match(options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g).length;
|
|
56
|
-
let parentState =
|
|
57
|
+
let parentState = obj;
|
|
57
58
|
for (let i = 0; i < parentLevels; i++) {
|
|
58
59
|
parentState = parentState.parent;
|
|
59
60
|
if (!parentState) {
|
|
@@ -63,11 +64,11 @@ const replaceLiteralsWithObjectFields = (str, state, options = {}) => {
|
|
|
63
64
|
const value = parentState[variable.trim()];
|
|
64
65
|
return value !== void 0 ? `${value}` : "";
|
|
65
66
|
} else {
|
|
66
|
-
const value =
|
|
67
|
+
const value = obj[variable.trim()];
|
|
67
68
|
return value !== void 0 ? `${value}` : "";
|
|
68
69
|
}
|
|
69
70
|
});
|
|
70
|
-
}
|
|
71
|
+
}
|
|
71
72
|
const lowercaseFirstLetter = (inputString) => {
|
|
72
73
|
return `${inputString.charAt(0).toLowerCase()}${inputString.slice(1)}`;
|
|
73
74
|
};
|
package/dist/esm/component.js
CHANGED
|
@@ -199,7 +199,7 @@ const getExtendsInElement = (obj) => {
|
|
|
199
199
|
if (checkIfKeyIsComponent(key)) {
|
|
200
200
|
result.push(key);
|
|
201
201
|
}
|
|
202
|
-
if (key === "extend") {
|
|
202
|
+
if (key === "extend" || key === "extends") {
|
|
203
203
|
if (typeof o[key] === "string") {
|
|
204
204
|
result.push(o[key]);
|
|
205
205
|
} else if (Array.isArray(o[key])) {
|
package/dist/esm/string.js
CHANGED
|
@@ -14,14 +14,15 @@ const brackRegex = {
|
|
|
14
14
|
2: /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g,
|
|
15
15
|
3: /\{\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}\}/g
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
function replaceLiteralsWithObjectFields(str, options = {}, forcedState) {
|
|
18
18
|
if (!str.includes(options.bracketsLength === 3 ? "{{{" : "{{"))
|
|
19
19
|
return str;
|
|
20
20
|
const reg = brackRegex[options.bracketsLength || 2];
|
|
21
|
+
const obj = forcedState || this.state || {};
|
|
21
22
|
return str.replace(reg, (_, parentPath, variable) => {
|
|
22
23
|
if (parentPath) {
|
|
23
24
|
const parentLevels = parentPath.match(options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g).length;
|
|
24
|
-
let parentState =
|
|
25
|
+
let parentState = obj;
|
|
25
26
|
for (let i = 0; i < parentLevels; i++) {
|
|
26
27
|
parentState = parentState.parent;
|
|
27
28
|
if (!parentState) {
|
|
@@ -31,11 +32,11 @@ const replaceLiteralsWithObjectFields = (str, state, options = {}) => {
|
|
|
31
32
|
const value = parentState[variable.trim()];
|
|
32
33
|
return value !== void 0 ? `${value}` : "";
|
|
33
34
|
} else {
|
|
34
|
-
const value =
|
|
35
|
+
const value = obj[variable.trim()];
|
|
35
36
|
return value !== void 0 ? `${value}` : "";
|
|
36
37
|
}
|
|
37
38
|
});
|
|
38
|
-
}
|
|
39
|
+
}
|
|
39
40
|
const lowercaseFirstLetter = (inputString) => {
|
|
40
41
|
return `${inputString.charAt(0).toLowerCase()}${inputString.slice(1)}`;
|
|
41
42
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.168",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"build": "npm run build:cjs; npm run build:esm",
|
|
26
26
|
"prepublish": "rimraf -I dist; npm run build; npm run copy:package:cjs"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "6c935c3d1ff70096bb532e9c5426ffc5af0677dc",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@babel/core": "^7.12.0"
|
|
31
31
|
}
|
package/string.js
CHANGED
|
@@ -29,13 +29,14 @@ const brackRegex = {
|
|
|
29
29
|
3: /\{\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}\}/g
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export
|
|
32
|
+
export function replaceLiteralsWithObjectFields (str, options = {}, forcedState) {
|
|
33
33
|
if (!str.includes(options.bracketsLength === 3 ? '{{{' : '{{')) return str
|
|
34
34
|
const reg = brackRegex[options.bracketsLength || 2]
|
|
35
|
+
const obj = forcedState || this.state || {}
|
|
35
36
|
return str.replace(reg, (_, parentPath, variable) => {
|
|
36
37
|
if (parentPath) {
|
|
37
38
|
const parentLevels = parentPath.match(options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g).length
|
|
38
|
-
let parentState =
|
|
39
|
+
let parentState = obj
|
|
39
40
|
for (let i = 0; i < parentLevels; i++) {
|
|
40
41
|
parentState = parentState.parent
|
|
41
42
|
if (!parentState) {
|
|
@@ -45,7 +46,7 @@ export const replaceLiteralsWithObjectFields = (str, state, options = {}) => {
|
|
|
45
46
|
const value = parentState[variable.trim()]
|
|
46
47
|
return value !== undefined ? `${value}` : ''
|
|
47
48
|
} else {
|
|
48
|
-
const value =
|
|
49
|
+
const value = obj[variable.trim()]
|
|
49
50
|
return value !== undefined ? `${value}` : ''
|
|
50
51
|
}
|
|
51
52
|
})
|