@domql/utils 2.5.125 → 2.5.130
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 +159 -0
- package/dist/cjs/component.js +160 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/object.js +1 -53
- package/index.js +1 -0
- package/object.js +1 -63
- package/package.json +5 -3
package/component.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { exec, isArray, isFunction, isObject, isString, joinArrays } from '.'
|
|
4
|
+
const ENV = process.env.NODE_ENV
|
|
5
|
+
|
|
6
|
+
export const checkIfKeyIsComponent = (key) => {
|
|
7
|
+
const isFirstKeyString = isString(key)
|
|
8
|
+
if (!isFirstKeyString) return
|
|
9
|
+
const firstCharKey = key.slice(0, 1)
|
|
10
|
+
return /^[A-Z]*$/.test(firstCharKey)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const checkIfKeyIsProperty = (key) => {
|
|
14
|
+
const isFirstKeyString = isString(key)
|
|
15
|
+
if (!isFirstKeyString) return
|
|
16
|
+
const firstCharKey = key.slice(0, 1)
|
|
17
|
+
return /^[a-z]*$/.test(firstCharKey)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const addAdditionalExtend = (newExtend, element) => {
|
|
21
|
+
const { extend: elementExtend } = element
|
|
22
|
+
const originalArray = isArray(elementExtend) ? elementExtend : [elementExtend]
|
|
23
|
+
const receivedArray = isArray(newExtend) ? newExtend : [newExtend]
|
|
24
|
+
const extend = joinArrays(receivedArray, originalArray)
|
|
25
|
+
return { ...element, extend }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const extendizeByKey = (element, parent, key) => {
|
|
29
|
+
const { context } = parent
|
|
30
|
+
const { tag, extend, props, attr, state, childExtend, childProps, on, if: condition, data } = element
|
|
31
|
+
const hasComponentAttrs = extend || childExtend || props || state || on || condition || attr || data
|
|
32
|
+
|
|
33
|
+
const extendFromKey = key.includes('+')
|
|
34
|
+
? key.split('+') // get array of componentKeys
|
|
35
|
+
: key.includes('_')
|
|
36
|
+
? [key.split('_')[0]] // get component key split _
|
|
37
|
+
: key.includes('.') && !checkIfKeyIsComponent(key.split('.')[1])
|
|
38
|
+
? [key.split('.')[0]] // get component key split .
|
|
39
|
+
: [key]
|
|
40
|
+
|
|
41
|
+
// console.log(extendFromKey)
|
|
42
|
+
// console.log(context, context?.components)
|
|
43
|
+
// console.log(element)
|
|
44
|
+
const isExtendKeyComponent = context && context.components[extendFromKey]
|
|
45
|
+
|
|
46
|
+
if (element === isExtendKeyComponent) return element
|
|
47
|
+
else if (!hasComponentAttrs || childProps) {
|
|
48
|
+
return {
|
|
49
|
+
extend: extendFromKey,
|
|
50
|
+
tag,
|
|
51
|
+
props: { ...element }
|
|
52
|
+
}
|
|
53
|
+
} else if (!extend || extend === true) {
|
|
54
|
+
return {
|
|
55
|
+
...element,
|
|
56
|
+
tag,
|
|
57
|
+
extend: extendFromKey
|
|
58
|
+
}
|
|
59
|
+
} else if (extend) {
|
|
60
|
+
return addAdditionalExtend(extendFromKey, element)
|
|
61
|
+
} else if (isFunction(element)) {
|
|
62
|
+
return {
|
|
63
|
+
extend: extendFromKey,
|
|
64
|
+
tag,
|
|
65
|
+
props: { ...exec(element, parent) }
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const applyKeyComponentAsExtend = (element, parent, key) => {
|
|
71
|
+
return extendizeByKey(element, parent, key) || element
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const applyComponentFromContext = (element, parent, options) => {
|
|
75
|
+
const { context } = element
|
|
76
|
+
|
|
77
|
+
if (!context || !context.components) return
|
|
78
|
+
|
|
79
|
+
const { components } = context
|
|
80
|
+
const { extend } = element
|
|
81
|
+
const execExtend = exec(extend, element)
|
|
82
|
+
if (isString(execExtend)) {
|
|
83
|
+
const componentExists = components[execExtend] || components['smbls.' + execExtend]
|
|
84
|
+
if (componentExists) element.extend = componentExists
|
|
85
|
+
else {
|
|
86
|
+
if ((ENV === 'test' || ENV === 'development') && options.verbose) {
|
|
87
|
+
console.warn(execExtend, 'is not in library', components, element)
|
|
88
|
+
console.warn('replacing with ', {})
|
|
89
|
+
}
|
|
90
|
+
element.extend = {}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const isVariant = (param) => {
|
|
96
|
+
if (!isString(param)) return
|
|
97
|
+
const firstCharKey = param.slice(0, 1)
|
|
98
|
+
// return (firstCharKey === '.' || firstCharKey === '$')
|
|
99
|
+
return (firstCharKey === '.')
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const hasVariantProp = (element) => {
|
|
103
|
+
const { props } = element
|
|
104
|
+
if (isObject(props) && isString(props.variant)) return true
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export const getChildrenComponentsByKey = (key, el) => {
|
|
108
|
+
if (key === el.key || el.__ref.__componentKey === key) {
|
|
109
|
+
return el
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Check if the prop is "extend" and it's either a string or an array
|
|
113
|
+
if (el.extend) {
|
|
114
|
+
// Add the value of the extend key to the result array
|
|
115
|
+
const foundString = isString(el.extend) && el.extend === key
|
|
116
|
+
const foundInArray = isArray(el.extend) && el.extend.filter(v => v === key).length
|
|
117
|
+
if (foundString || foundInArray) return el
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (el.parent && el.parent.childExtend) {
|
|
121
|
+
// Add the value of the extend key to the result array
|
|
122
|
+
const foundString = isString(el.parent.childExtend) && el.parent.childExtend === key
|
|
123
|
+
const foundInArray = isArray(el.parent.childExtend) && el.parent.childExtend.filter(v => v === key).length
|
|
124
|
+
if (foundString || foundInArray) return el
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export const getExtendsInElement = (obj) => {
|
|
129
|
+
let result = []
|
|
130
|
+
|
|
131
|
+
function traverse (o) {
|
|
132
|
+
for (const key in o) {
|
|
133
|
+
if (Object.hasOwnProperty.call(o, key)) {
|
|
134
|
+
// Check if the key starts with a capital letter and exclude keys like @mobileL, $propsCollection
|
|
135
|
+
if (checkIfKeyIsComponent(key)) {
|
|
136
|
+
result.push(key)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Check if the key is "extend" and it's either a string or an array
|
|
140
|
+
if (key === 'extend') {
|
|
141
|
+
// Add the value of the extend key to the result array
|
|
142
|
+
if (typeof o[key] === 'string') {
|
|
143
|
+
result.push(o[key])
|
|
144
|
+
} else if (Array.isArray(o[key])) {
|
|
145
|
+
result = result.concat(o[key])
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// If the property is an object, traverse it
|
|
150
|
+
if (typeof o[key] === 'object' && o[key] !== null) {
|
|
151
|
+
traverse(o[key])
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
traverse(obj)
|
|
158
|
+
return result
|
|
159
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var component_exports = {};
|
|
20
|
+
__export(component_exports, {
|
|
21
|
+
addAdditionalExtend: () => addAdditionalExtend,
|
|
22
|
+
applyComponentFromContext: () => applyComponentFromContext,
|
|
23
|
+
applyKeyComponentAsExtend: () => applyKeyComponentAsExtend,
|
|
24
|
+
checkIfKeyIsComponent: () => checkIfKeyIsComponent,
|
|
25
|
+
checkIfKeyIsProperty: () => checkIfKeyIsProperty,
|
|
26
|
+
extendizeByKey: () => extendizeByKey,
|
|
27
|
+
getChildrenComponentsByKey: () => getChildrenComponentsByKey,
|
|
28
|
+
getExtendsInElement: () => getExtendsInElement,
|
|
29
|
+
hasVariantProp: () => hasVariantProp,
|
|
30
|
+
isVariant: () => isVariant
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(component_exports);
|
|
33
|
+
var import__ = require(".");
|
|
34
|
+
const ENV = "development";
|
|
35
|
+
const checkIfKeyIsComponent = (key) => {
|
|
36
|
+
const isFirstKeyString = (0, import__.isString)(key);
|
|
37
|
+
if (!isFirstKeyString)
|
|
38
|
+
return;
|
|
39
|
+
const firstCharKey = key.slice(0, 1);
|
|
40
|
+
return /^[A-Z]*$/.test(firstCharKey);
|
|
41
|
+
};
|
|
42
|
+
const checkIfKeyIsProperty = (key) => {
|
|
43
|
+
const isFirstKeyString = (0, import__.isString)(key);
|
|
44
|
+
if (!isFirstKeyString)
|
|
45
|
+
return;
|
|
46
|
+
const firstCharKey = key.slice(0, 1);
|
|
47
|
+
return /^[a-z]*$/.test(firstCharKey);
|
|
48
|
+
};
|
|
49
|
+
const addAdditionalExtend = (newExtend, element) => {
|
|
50
|
+
const { extend: elementExtend } = element;
|
|
51
|
+
const originalArray = (0, import__.isArray)(elementExtend) ? elementExtend : [elementExtend];
|
|
52
|
+
const receivedArray = (0, import__.isArray)(newExtend) ? newExtend : [newExtend];
|
|
53
|
+
const extend = (0, import__.joinArrays)(receivedArray, originalArray);
|
|
54
|
+
return { ...element, extend };
|
|
55
|
+
};
|
|
56
|
+
const extendizeByKey = (element, parent, key) => {
|
|
57
|
+
const { context } = parent;
|
|
58
|
+
const { tag, extend, props, attr, state, childExtend, childProps, on, if: condition, data } = element;
|
|
59
|
+
const hasComponentAttrs = extend || childExtend || props || state || on || condition || attr || data;
|
|
60
|
+
const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
|
|
61
|
+
const isExtendKeyComponent = context && context.components[extendFromKey];
|
|
62
|
+
if (element === isExtendKeyComponent)
|
|
63
|
+
return element;
|
|
64
|
+
else if (!hasComponentAttrs || childProps) {
|
|
65
|
+
return {
|
|
66
|
+
extend: extendFromKey,
|
|
67
|
+
tag,
|
|
68
|
+
props: { ...element }
|
|
69
|
+
};
|
|
70
|
+
} else if (!extend || extend === true) {
|
|
71
|
+
return {
|
|
72
|
+
...element,
|
|
73
|
+
tag,
|
|
74
|
+
extend: extendFromKey
|
|
75
|
+
};
|
|
76
|
+
} else if (extend) {
|
|
77
|
+
return addAdditionalExtend(extendFromKey, element);
|
|
78
|
+
} else if ((0, import__.isFunction)(element)) {
|
|
79
|
+
return {
|
|
80
|
+
extend: extendFromKey,
|
|
81
|
+
tag,
|
|
82
|
+
props: { ...(0, import__.exec)(element, parent) }
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const applyKeyComponentAsExtend = (element, parent, key) => {
|
|
87
|
+
return extendizeByKey(element, parent, key) || element;
|
|
88
|
+
};
|
|
89
|
+
const applyComponentFromContext = (element, parent, options) => {
|
|
90
|
+
const { context } = element;
|
|
91
|
+
if (!context || !context.components)
|
|
92
|
+
return;
|
|
93
|
+
const { components } = context;
|
|
94
|
+
const { extend } = element;
|
|
95
|
+
const execExtend = (0, import__.exec)(extend, element);
|
|
96
|
+
if ((0, import__.isString)(execExtend)) {
|
|
97
|
+
const componentExists = components[execExtend] || components["smbls." + execExtend];
|
|
98
|
+
if (componentExists)
|
|
99
|
+
element.extend = componentExists;
|
|
100
|
+
else {
|
|
101
|
+
if ((ENV === "test" || ENV === "development") && options.verbose) {
|
|
102
|
+
console.warn(execExtend, "is not in library", components, element);
|
|
103
|
+
console.warn("replacing with ", {});
|
|
104
|
+
}
|
|
105
|
+
element.extend = {};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const isVariant = (param) => {
|
|
110
|
+
if (!(0, import__.isString)(param))
|
|
111
|
+
return;
|
|
112
|
+
const firstCharKey = param.slice(0, 1);
|
|
113
|
+
return firstCharKey === ".";
|
|
114
|
+
};
|
|
115
|
+
const hasVariantProp = (element) => {
|
|
116
|
+
const { props } = element;
|
|
117
|
+
if ((0, import__.isObject)(props) && (0, import__.isString)(props.variant))
|
|
118
|
+
return true;
|
|
119
|
+
};
|
|
120
|
+
const getChildrenComponentsByKey = (key, el) => {
|
|
121
|
+
if (key === el.key || el.__ref.__componentKey === key) {
|
|
122
|
+
return el;
|
|
123
|
+
}
|
|
124
|
+
if (el.extend) {
|
|
125
|
+
const foundString = (0, import__.isString)(el.extend) && el.extend === key;
|
|
126
|
+
const foundInArray = (0, import__.isArray)(el.extend) && el.extend.filter((v) => v === key).length;
|
|
127
|
+
if (foundString || foundInArray)
|
|
128
|
+
return el;
|
|
129
|
+
}
|
|
130
|
+
if (el.parent && el.parent.childExtend) {
|
|
131
|
+
const foundString = (0, import__.isString)(el.parent.childExtend) && el.parent.childExtend === key;
|
|
132
|
+
const foundInArray = (0, import__.isArray)(el.parent.childExtend) && el.parent.childExtend.filter((v) => v === key).length;
|
|
133
|
+
if (foundString || foundInArray)
|
|
134
|
+
return el;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const getExtendsInElement = (obj) => {
|
|
138
|
+
let result = [];
|
|
139
|
+
function traverse(o) {
|
|
140
|
+
for (const key in o) {
|
|
141
|
+
if (Object.hasOwnProperty.call(o, key)) {
|
|
142
|
+
if (checkIfKeyIsComponent(key)) {
|
|
143
|
+
result.push(key);
|
|
144
|
+
}
|
|
145
|
+
if (key === "extend") {
|
|
146
|
+
if (typeof o[key] === "string") {
|
|
147
|
+
result.push(o[key]);
|
|
148
|
+
} else if (Array.isArray(o[key])) {
|
|
149
|
+
result = result.concat(o[key]);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (typeof o[key] === "object" && o[key] !== null) {
|
|
153
|
+
traverse(o[key]);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
traverse(obj);
|
|
159
|
+
return result;
|
|
160
|
+
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -27,3 +27,4 @@ __reExport(utils_exports, require("./string.js"), module.exports);
|
|
|
27
27
|
__reExport(utils_exports, require("./globals.js"), module.exports);
|
|
28
28
|
__reExport(utils_exports, require("./cookie.js"), module.exports);
|
|
29
29
|
__reExport(utils_exports, require("./tags.js"), module.exports);
|
|
30
|
+
__reExport(utils_exports, require("./component.js"), module.exports);
|
package/dist/cjs/object.js
CHANGED
|
@@ -18,7 +18,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var object_exports = {};
|
|
20
20
|
__export(object_exports, {
|
|
21
|
-
checkIfKeyIsComponent: () => checkIfKeyIsComponent,
|
|
22
21
|
clone: () => clone,
|
|
23
22
|
createNestedObject: () => createNestedObject,
|
|
24
23
|
createObjectWithoutPrototype: () => createObjectWithoutPrototype,
|
|
@@ -37,8 +36,6 @@ __export(object_exports, {
|
|
|
37
36
|
diffObjects: () => diffObjects,
|
|
38
37
|
exec: () => exec,
|
|
39
38
|
flattenRecursive: () => flattenRecursive,
|
|
40
|
-
getChildrenComponentsByKey: () => getChildrenComponentsByKey,
|
|
41
|
-
getExtendsInElement: () => getExtendsInElement,
|
|
42
39
|
hasOwnProperty: () => hasOwnProperty,
|
|
43
40
|
isEmpty: () => isEmpty,
|
|
44
41
|
isEmptyObject: () => isEmptyObject,
|
|
@@ -62,7 +59,6 @@ var import_types = require("./types.js");
|
|
|
62
59
|
var import_array = require("./array.js");
|
|
63
60
|
var import_string = require("./string.js");
|
|
64
61
|
var import_node = require("./node.js");
|
|
65
|
-
var import_function = require("./function.js");
|
|
66
62
|
const ENV = "development";
|
|
67
63
|
const exec = (param, element, state, context) => {
|
|
68
64
|
if ((0, import_types.isFunction)(param)) {
|
|
@@ -176,7 +172,7 @@ const deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}) => {
|
|
|
176
172
|
if ((0, import_types.isObjectLike)(objProp)) {
|
|
177
173
|
o[prop] = deepCloneWithExtend(objProp, excludeFrom, options);
|
|
178
174
|
} else if ((0, import_types.isFunction)(objProp) && options.window) {
|
|
179
|
-
o[prop] = (
|
|
175
|
+
o[prop] = (options.window || import_globals.window).eval("(" + objProp.toString() + ")");
|
|
180
176
|
} else
|
|
181
177
|
o[prop] = objProp;
|
|
182
178
|
}
|
|
@@ -544,54 +540,6 @@ const createObjectWithoutPrototype = (obj) => {
|
|
|
544
540
|
}
|
|
545
541
|
return newObj;
|
|
546
542
|
};
|
|
547
|
-
const checkIfKeyIsComponent = (key) => {
|
|
548
|
-
const isFirstKeyString = (0, import_types.isString)(key);
|
|
549
|
-
if (!isFirstKeyString)
|
|
550
|
-
return;
|
|
551
|
-
const firstCharKey = key.slice(0, 1);
|
|
552
|
-
return /^[A-Z]*$/.test(firstCharKey);
|
|
553
|
-
};
|
|
554
|
-
const getChildrenComponentsByKey = (key, el) => {
|
|
555
|
-
if (key === el.key || el.__ref.__componentKey === key) {
|
|
556
|
-
return el;
|
|
557
|
-
}
|
|
558
|
-
if (el.extend) {
|
|
559
|
-
const foundString = (0, import_types.isString)(el.extend) && el.extend === key;
|
|
560
|
-
const foundInArray = (0, import_types.isArray)(el.extend) && el.extend.filter((v) => v === key).length;
|
|
561
|
-
if (foundString || foundInArray)
|
|
562
|
-
return el;
|
|
563
|
-
}
|
|
564
|
-
if (el.parent && el.parent.childExtend) {
|
|
565
|
-
const foundString = (0, import_types.isString)(el.parent.childExtend) && el.parent.childExtend === key;
|
|
566
|
-
const foundInArray = (0, import_types.isArray)(el.parent.childExtend) && el.parent.childExtend.filter((v) => v === key).length;
|
|
567
|
-
if (foundString || foundInArray)
|
|
568
|
-
return el;
|
|
569
|
-
}
|
|
570
|
-
};
|
|
571
|
-
const getExtendsInElement = (obj) => {
|
|
572
|
-
let result = [];
|
|
573
|
-
function traverse(o) {
|
|
574
|
-
for (const key in o) {
|
|
575
|
-
if (Object.hasOwnProperty.call(o, key)) {
|
|
576
|
-
if (checkIfKeyIsComponent(key)) {
|
|
577
|
-
result.push(key);
|
|
578
|
-
}
|
|
579
|
-
if (key === "extend") {
|
|
580
|
-
if (typeof o[key] === "string") {
|
|
581
|
-
result.push(o[key]);
|
|
582
|
-
} else if (Array.isArray(o[key])) {
|
|
583
|
-
result = result.concat(o[key]);
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
if (typeof o[key] === "object" && o[key] !== null) {
|
|
587
|
-
traverse(o[key]);
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
traverse(obj);
|
|
593
|
-
return result;
|
|
594
|
-
};
|
|
595
543
|
const createNestedObject = (arr, lastValue) => {
|
|
596
544
|
const nestedObject = {};
|
|
597
545
|
if (arr.length === 0) {
|
package/index.js
CHANGED
package/object.js
CHANGED
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
import { mergeAndCloneIfArray, mergeArray } from './array.js'
|
|
16
16
|
import { stringIncludesAny } from './string.js'
|
|
17
17
|
import { isDOMNode } from './node.js'
|
|
18
|
-
import { cloneFunction } from './function.js'
|
|
19
18
|
|
|
20
19
|
const ENV = process.env.NODE_ENV
|
|
21
20
|
|
|
@@ -190,7 +189,7 @@ export const deepCloneWithExtend = (obj, excludeFrom = ['node'], options = {}) =
|
|
|
190
189
|
o[prop] = deepCloneWithExtend(objProp, excludeFrom, options)
|
|
191
190
|
// })
|
|
192
191
|
} else if (isFunction(objProp) && options.window) {
|
|
193
|
-
o[prop] =
|
|
192
|
+
o[prop] = (options.window || window).eval('(' + objProp.toString() + ')')
|
|
194
193
|
} else o[prop] = objProp
|
|
195
194
|
}
|
|
196
195
|
return o
|
|
@@ -669,67 +668,6 @@ export const createObjectWithoutPrototype = (obj) => {
|
|
|
669
668
|
return newObj
|
|
670
669
|
}
|
|
671
670
|
|
|
672
|
-
export const checkIfKeyIsComponent = (key) => {
|
|
673
|
-
const isFirstKeyString = isString(key)
|
|
674
|
-
if (!isFirstKeyString) return
|
|
675
|
-
const firstCharKey = key.slice(0, 1)
|
|
676
|
-
return /^[A-Z]*$/.test(firstCharKey)
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
export const getChildrenComponentsByKey = (key, el) => {
|
|
680
|
-
if (key === el.key || el.__ref.__componentKey === key) {
|
|
681
|
-
return el
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
// Check if the prop is "extend" and it's either a string or an array
|
|
685
|
-
if (el.extend) {
|
|
686
|
-
// Add the value of the extend key to the result array
|
|
687
|
-
const foundString = isString(el.extend) && el.extend === key
|
|
688
|
-
const foundInArray = isArray(el.extend) && el.extend.filter(v => v === key).length
|
|
689
|
-
if (foundString || foundInArray) return el
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
if (el.parent && el.parent.childExtend) {
|
|
693
|
-
// Add the value of the extend key to the result array
|
|
694
|
-
const foundString = isString(el.parent.childExtend) && el.parent.childExtend === key
|
|
695
|
-
const foundInArray = isArray(el.parent.childExtend) && el.parent.childExtend.filter(v => v === key).length
|
|
696
|
-
if (foundString || foundInArray) return el
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
export const getExtendsInElement = (obj) => {
|
|
701
|
-
let result = []
|
|
702
|
-
|
|
703
|
-
function traverse (o) {
|
|
704
|
-
for (const key in o) {
|
|
705
|
-
if (Object.hasOwnProperty.call(o, key)) {
|
|
706
|
-
// Check if the key starts with a capital letter and exclude keys like @mobileL, $propsCollection
|
|
707
|
-
if (checkIfKeyIsComponent(key)) {
|
|
708
|
-
result.push(key)
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
// Check if the key is "extend" and it's either a string or an array
|
|
712
|
-
if (key === 'extend') {
|
|
713
|
-
// Add the value of the extend key to the result array
|
|
714
|
-
if (typeof o[key] === 'string') {
|
|
715
|
-
result.push(o[key])
|
|
716
|
-
} else if (Array.isArray(o[key])) {
|
|
717
|
-
result = result.concat(o[key])
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
// If the property is an object, traverse it
|
|
722
|
-
if (typeof o[key] === 'object' && o[key] !== null) {
|
|
723
|
-
traverse(o[key])
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
traverse(obj)
|
|
730
|
-
return result
|
|
731
|
-
}
|
|
732
|
-
|
|
733
671
|
export const createNestedObject = (arr, lastValue) => {
|
|
734
672
|
const nestedObject = {}
|
|
735
673
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.130",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"kalduna": "./index.js",
|
|
11
|
-
"default": "./dist/cjs/index.js"
|
|
11
|
+
"default": "./dist/cjs/index.js",
|
|
12
|
+
"import": "./index.js",
|
|
13
|
+
"require": "./dist/cjs/index.js"
|
|
12
14
|
}
|
|
13
15
|
},
|
|
14
16
|
"source": "index.js",
|
|
@@ -23,7 +25,7 @@
|
|
|
23
25
|
"build": "yarn build:cjs",
|
|
24
26
|
"prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
|
|
25
27
|
},
|
|
26
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "88815c621b7aeb9458c779643934c0d2e5305cd2",
|
|
27
29
|
"devDependencies": {
|
|
28
30
|
"@babel/core": "^7.12.0"
|
|
29
31
|
}
|