@domql/utils 2.5.126 → 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 +0 -51
- package/index.js +1 -0
- package/object.js +0 -61
- 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,
|
|
@@ -543,54 +540,6 @@ const createObjectWithoutPrototype = (obj) => {
|
|
|
543
540
|
}
|
|
544
541
|
return newObj;
|
|
545
542
|
};
|
|
546
|
-
const checkIfKeyIsComponent = (key) => {
|
|
547
|
-
const isFirstKeyString = (0, import_types.isString)(key);
|
|
548
|
-
if (!isFirstKeyString)
|
|
549
|
-
return;
|
|
550
|
-
const firstCharKey = key.slice(0, 1);
|
|
551
|
-
return /^[A-Z]*$/.test(firstCharKey);
|
|
552
|
-
};
|
|
553
|
-
const getChildrenComponentsByKey = (key, el) => {
|
|
554
|
-
if (key === el.key || el.__ref.__componentKey === key) {
|
|
555
|
-
return el;
|
|
556
|
-
}
|
|
557
|
-
if (el.extend) {
|
|
558
|
-
const foundString = (0, import_types.isString)(el.extend) && el.extend === key;
|
|
559
|
-
const foundInArray = (0, import_types.isArray)(el.extend) && el.extend.filter((v) => v === key).length;
|
|
560
|
-
if (foundString || foundInArray)
|
|
561
|
-
return el;
|
|
562
|
-
}
|
|
563
|
-
if (el.parent && el.parent.childExtend) {
|
|
564
|
-
const foundString = (0, import_types.isString)(el.parent.childExtend) && el.parent.childExtend === key;
|
|
565
|
-
const foundInArray = (0, import_types.isArray)(el.parent.childExtend) && el.parent.childExtend.filter((v) => v === key).length;
|
|
566
|
-
if (foundString || foundInArray)
|
|
567
|
-
return el;
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
const getExtendsInElement = (obj) => {
|
|
571
|
-
let result = [];
|
|
572
|
-
function traverse(o) {
|
|
573
|
-
for (const key in o) {
|
|
574
|
-
if (Object.hasOwnProperty.call(o, key)) {
|
|
575
|
-
if (checkIfKeyIsComponent(key)) {
|
|
576
|
-
result.push(key);
|
|
577
|
-
}
|
|
578
|
-
if (key === "extend") {
|
|
579
|
-
if (typeof o[key] === "string") {
|
|
580
|
-
result.push(o[key]);
|
|
581
|
-
} else if (Array.isArray(o[key])) {
|
|
582
|
-
result = result.concat(o[key]);
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
if (typeof o[key] === "object" && o[key] !== null) {
|
|
586
|
-
traverse(o[key]);
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
traverse(obj);
|
|
592
|
-
return result;
|
|
593
|
-
};
|
|
594
543
|
const createNestedObject = (arr, lastValue) => {
|
|
595
544
|
const nestedObject = {};
|
|
596
545
|
if (arr.length === 0) {
|
package/index.js
CHANGED
package/object.js
CHANGED
|
@@ -668,67 +668,6 @@ export const createObjectWithoutPrototype = (obj) => {
|
|
|
668
668
|
return newObj
|
|
669
669
|
}
|
|
670
670
|
|
|
671
|
-
export const checkIfKeyIsComponent = (key) => {
|
|
672
|
-
const isFirstKeyString = isString(key)
|
|
673
|
-
if (!isFirstKeyString) return
|
|
674
|
-
const firstCharKey = key.slice(0, 1)
|
|
675
|
-
return /^[A-Z]*$/.test(firstCharKey)
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
export const getChildrenComponentsByKey = (key, el) => {
|
|
679
|
-
if (key === el.key || el.__ref.__componentKey === key) {
|
|
680
|
-
return el
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
// Check if the prop is "extend" and it's either a string or an array
|
|
684
|
-
if (el.extend) {
|
|
685
|
-
// Add the value of the extend key to the result array
|
|
686
|
-
const foundString = isString(el.extend) && el.extend === key
|
|
687
|
-
const foundInArray = isArray(el.extend) && el.extend.filter(v => v === key).length
|
|
688
|
-
if (foundString || foundInArray) return el
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
if (el.parent && el.parent.childExtend) {
|
|
692
|
-
// Add the value of the extend key to the result array
|
|
693
|
-
const foundString = isString(el.parent.childExtend) && el.parent.childExtend === key
|
|
694
|
-
const foundInArray = isArray(el.parent.childExtend) && el.parent.childExtend.filter(v => v === key).length
|
|
695
|
-
if (foundString || foundInArray) return el
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
export const getExtendsInElement = (obj) => {
|
|
700
|
-
let result = []
|
|
701
|
-
|
|
702
|
-
function traverse (o) {
|
|
703
|
-
for (const key in o) {
|
|
704
|
-
if (Object.hasOwnProperty.call(o, key)) {
|
|
705
|
-
// Check if the key starts with a capital letter and exclude keys like @mobileL, $propsCollection
|
|
706
|
-
if (checkIfKeyIsComponent(key)) {
|
|
707
|
-
result.push(key)
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
// Check if the key is "extend" and it's either a string or an array
|
|
711
|
-
if (key === 'extend') {
|
|
712
|
-
// Add the value of the extend key to the result array
|
|
713
|
-
if (typeof o[key] === 'string') {
|
|
714
|
-
result.push(o[key])
|
|
715
|
-
} else if (Array.isArray(o[key])) {
|
|
716
|
-
result = result.concat(o[key])
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
// If the property is an object, traverse it
|
|
721
|
-
if (typeof o[key] === 'object' && o[key] !== null) {
|
|
722
|
-
traverse(o[key])
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
traverse(obj)
|
|
729
|
-
return result
|
|
730
|
-
}
|
|
731
|
-
|
|
732
671
|
export const createNestedObject = (arr, lastValue) => {
|
|
733
672
|
const nestedObject = {}
|
|
734
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
|
}
|