@domql/element 2.5.37 → 2.5.40
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/dist/cjs/utils/component.js +19 -18
- package/dist/cjs/utils/extendUtils.js +0 -1
- package/package.json +2 -2
- package/utils/component.js +27 -21
- package/utils/extendUtils.js +0 -1
|
@@ -40,21 +40,22 @@ const checkIfKeyIsComponent = (key) => {
|
|
|
40
40
|
return /^[A-Z]*$/.test(firstCharKey);
|
|
41
41
|
};
|
|
42
42
|
const addAdditionalExtend = (newExtend, element) => {
|
|
43
|
-
const { extend } = element;
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
};
|
|
43
|
+
const { extend: elementExtend } = element;
|
|
44
|
+
const originalArray = (0, import_utils.isArray)(elementExtend) ? elementExtend : [elementExtend];
|
|
45
|
+
const receivedArray = (0, import_utils.isArray)(newExtend) ? newExtend : [newExtend];
|
|
46
|
+
const extend = (0, import_utils.joinArrays)(receivedArray, originalArray);
|
|
47
|
+
return { ...element, extend };
|
|
49
48
|
};
|
|
50
49
|
const extendizeByKey = (element, parent, key) => {
|
|
51
|
-
const { tag, extend, props, state, childExtend, childProps, on, if: condition } = element;
|
|
52
|
-
const hasComponentAttrs = extend || childExtend || props || state || on || condition;
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
50
|
+
const { context, tag, extend, props, attr, state, childExtend, childProps, on, if: condition } = element;
|
|
51
|
+
const hasComponentAttrs = extend || childExtend || props || state || on || condition || attr;
|
|
52
|
+
const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? key.split("_")[0] : key.includes(".") ? key.split(".")[0] : key;
|
|
53
|
+
const isExtendKeyComponent = context == null ? void 0 : context.components[extendFromKey];
|
|
54
|
+
if (element === isExtendKeyComponent)
|
|
55
|
+
return element;
|
|
56
|
+
else if (!hasComponentAttrs || childProps) {
|
|
56
57
|
return {
|
|
57
|
-
extend:
|
|
58
|
+
extend: extendFromKey,
|
|
58
59
|
tag,
|
|
59
60
|
props: { ...element }
|
|
60
61
|
};
|
|
@@ -62,14 +63,13 @@ const extendizeByKey = (element, parent, key) => {
|
|
|
62
63
|
return {
|
|
63
64
|
...element,
|
|
64
65
|
tag,
|
|
65
|
-
extend:
|
|
66
|
+
extend: extendFromKey
|
|
66
67
|
};
|
|
67
68
|
} else if (extend) {
|
|
68
|
-
addAdditionalExtend(
|
|
69
|
+
return addAdditionalExtend(extendFromKey, element);
|
|
69
70
|
} else if ((0, import_utils.isFunction)(element)) {
|
|
70
|
-
console.log(element);
|
|
71
71
|
return {
|
|
72
|
-
extend:
|
|
72
|
+
extend: extendFromKey,
|
|
73
73
|
tag,
|
|
74
74
|
props: { ...(0, import_utils.exec)(element, parent) }
|
|
75
75
|
};
|
|
@@ -86,8 +86,9 @@ const applyComponentFromContext = (element, parent, options) => {
|
|
|
86
86
|
const { extend } = element;
|
|
87
87
|
const execExtend = (0, import_utils.exec)(extend, element);
|
|
88
88
|
if ((0, import_utils.isString)(execExtend)) {
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
const componentExists = components[execExtend] || components["smbls." + execExtend];
|
|
90
|
+
if (componentExists)
|
|
91
|
+
element.extend = componentExists;
|
|
91
92
|
else {
|
|
92
93
|
if ((ENV === "test" || ENV === "development") && options.verbose) {
|
|
93
94
|
console.warn(execExtend, "is not in library", components, element);
|
|
@@ -126,7 +126,6 @@ const fallbackStringExtend = (extend, context, options = {}) => {
|
|
|
126
126
|
const COMPONENTS = context && context.components || options.components;
|
|
127
127
|
if ((0, import_utils.isString)(extend)) {
|
|
128
128
|
const componentExists = COMPONENTS[extend] || COMPONENTS["smbls." + extend];
|
|
129
|
-
console.log(extend, componentExists);
|
|
130
129
|
if (COMPONENTS && componentExists) {
|
|
131
130
|
return componentExists;
|
|
132
131
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/element",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.40",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@domql/state": "latest",
|
|
32
32
|
"@domql/utils": "latest"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "536a661204a0377cb6dbb415eba1081ac156048d",
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@babel/core": "^7.12.0"
|
|
37
37
|
}
|
package/utils/component.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { exec, isArray, isFunction, isObject, isString, overwriteDeep } from '@domql/utils'
|
|
3
|
+
import { exec, isArray, isFunction, isObject, isString, joinArrays, overwriteDeep } from '@domql/utils'
|
|
4
4
|
import { applyExtend } from '../extend'
|
|
5
5
|
const ENV = process.env.NODE_ENV
|
|
6
6
|
|
|
@@ -12,25 +12,31 @@ export const checkIfKeyIsComponent = (key) => {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const addAdditionalExtend = (newExtend, element) => {
|
|
15
|
-
const { extend } = element
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
15
|
+
const { extend: elementExtend } = element
|
|
16
|
+
const originalArray = isArray(elementExtend) ? elementExtend : [elementExtend]
|
|
17
|
+
const receivedArray = isArray(newExtend) ? newExtend : [newExtend]
|
|
18
|
+
const extend = joinArrays(receivedArray, originalArray)
|
|
19
|
+
return { ...element, extend }
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
export const extendizeByKey = (element, parent, key) => {
|
|
24
|
-
const { tag, extend, props, state, childExtend, childProps, on, if: condition } = element
|
|
25
|
-
const hasComponentAttrs = extend || childExtend || props || state || on || condition
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
const { context, tag, extend, props, attr, state, childExtend, childProps, on, if: condition } = element
|
|
24
|
+
const hasComponentAttrs = extend || childExtend || props || state || on || condition || attr
|
|
25
|
+
|
|
26
|
+
const extendFromKey = key.includes('+')
|
|
27
|
+
? key.split('+')
|
|
28
|
+
: key.includes('_')
|
|
29
|
+
? key.split('_')[0]
|
|
30
|
+
: key.includes('.')
|
|
31
|
+
? key.split('.')[0]
|
|
32
|
+
: key
|
|
33
|
+
|
|
34
|
+
const isExtendKeyComponent = context?.components[extendFromKey]
|
|
35
|
+
|
|
36
|
+
if (element === isExtendKeyComponent) return element
|
|
37
|
+
else if (!hasComponentAttrs || childProps) {
|
|
32
38
|
return {
|
|
33
|
-
extend:
|
|
39
|
+
extend: extendFromKey,
|
|
34
40
|
tag,
|
|
35
41
|
props: { ...element }
|
|
36
42
|
}
|
|
@@ -38,14 +44,13 @@ export const extendizeByKey = (element, parent, key) => {
|
|
|
38
44
|
return {
|
|
39
45
|
...element,
|
|
40
46
|
tag,
|
|
41
|
-
extend:
|
|
47
|
+
extend: extendFromKey
|
|
42
48
|
}
|
|
43
49
|
} else if (extend) {
|
|
44
|
-
addAdditionalExtend(
|
|
50
|
+
return addAdditionalExtend(extendFromKey, element)
|
|
45
51
|
} else if (isFunction(element)) {
|
|
46
|
-
console.log(element)
|
|
47
52
|
return {
|
|
48
|
-
extend:
|
|
53
|
+
extend: extendFromKey,
|
|
49
54
|
tag,
|
|
50
55
|
props: { ...exec(element, parent) }
|
|
51
56
|
}
|
|
@@ -65,7 +70,8 @@ export const applyComponentFromContext = (element, parent, options) => {
|
|
|
65
70
|
const { extend } = element
|
|
66
71
|
const execExtend = exec(extend, element)
|
|
67
72
|
if (isString(execExtend)) {
|
|
68
|
-
|
|
73
|
+
const componentExists = components[execExtend] || components['smbls.' + execExtend]
|
|
74
|
+
if (componentExists) element.extend = componentExists
|
|
69
75
|
else {
|
|
70
76
|
if ((ENV === 'test' || ENV === 'development') && options.verbose) {
|
|
71
77
|
console.warn(execExtend, 'is not in library', components, element)
|
package/utils/extendUtils.js
CHANGED
|
@@ -94,7 +94,6 @@ export const fallbackStringExtend = (extend, context, options = {}) => {
|
|
|
94
94
|
const COMPONENTS = (context && context.components) || options.components
|
|
95
95
|
if (isString(extend)) {
|
|
96
96
|
const componentExists = COMPONENTS[extend] || COMPONENTS['smbls.' + extend]
|
|
97
|
-
console.log(extend, componentExists)
|
|
98
97
|
if (COMPONENTS && componentExists) {
|
|
99
98
|
return componentExists
|
|
100
99
|
} else {
|