@domql/utils 2.5.162 → 2.5.167

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/array.js CHANGED
@@ -135,3 +135,8 @@ export const filterArraysFast = (sourceArr, excludeArr) => {
135
135
  const excludeSet = new Set(excludeArr)
136
136
  return sourceArr.filter(item => !excludeSet.has(item))
137
137
  }
138
+
139
+ export const checkIfStringIsInArray = (string, arr) => {
140
+ if (!string) return
141
+ return arr.filter(v => string.includes(v)).length
142
+ }
package/component.js CHANGED
@@ -56,19 +56,21 @@ export const checkIfSugar = (element, parent, key) => {
56
56
  return !hasComponentAttrs || childProps || extendProps || children || childExtends
57
57
  }
58
58
 
59
- export const extendizeByKey = (element, parent, key) => {
60
- const { context } = parent
61
- const { tag, extend, childExtends } = element
62
- const isSugar = checkIfSugar(element, parent, key)
63
-
64
- const extendFromKey = key.includes('+')
59
+ export const extractComponentKeyFromKey = (key) => {
60
+ return key.includes('+')
65
61
  ? key.split('+') // get array of componentKeys
66
62
  : key.includes('_')
67
63
  ? [key.split('_')[0]] // get component key split _
68
64
  : key.includes('.') && !checkIfKeyIsComponent(key.split('.')[1])
69
65
  ? [key.split('.')[0]] // get component key split .
70
66
  : [key]
67
+ }
71
68
 
69
+ export const extendizeByKey = (element, parent, key) => {
70
+ const { context } = parent
71
+ const { tag, extend, childExtends } = element
72
+ const isSugar = checkIfSugar(element, parent, key)
73
+ const extendFromKey = extractComponentKeyFromKey(key)
72
74
  const isExtendKeyComponent = context && context.components[extendFromKey]
73
75
  if (element === isExtendKeyComponent) return element
74
76
  else if (isSugar) {
@@ -198,7 +200,7 @@ export const getExtendsInElement = (obj) => {
198
200
  }
199
201
 
200
202
  // Check if the key is "extend" and it's either a string or an array
201
- if (key === 'extend') {
203
+ if (key === 'extend' || key === 'extends') {
202
204
  // Add the value of the extend key to the result array
203
205
  if (typeof o[key] === 'string') {
204
206
  result.push(o[key])
package/dist/cjs/array.js CHANGED
@@ -21,6 +21,7 @@ __export(array_exports, {
21
21
  addItemAfterEveryElement: () => addItemAfterEveryElement,
22
22
  arrayContainsOtherArray: () => arrayContainsOtherArray,
23
23
  arraysEqual: () => arraysEqual,
24
+ checkIfStringIsInArray: () => checkIfStringIsInArray,
24
25
  cutArrayAfterValue: () => cutArrayAfterValue,
25
26
  cutArrayBeforeValue: () => cutArrayBeforeValue,
26
27
  filterArrays: () => filterArrays,
@@ -140,3 +141,8 @@ const filterArraysFast = (sourceArr, excludeArr) => {
140
141
  const excludeSet = new Set(excludeArr);
141
142
  return sourceArr.filter((item) => !excludeSet.has(item));
142
143
  };
144
+ const checkIfStringIsInArray = (string, arr) => {
145
+ if (!string)
146
+ return;
147
+ return arr.filter((v) => string.includes(v)).length;
148
+ };
@@ -26,6 +26,7 @@ __export(component_exports, {
26
26
  checkIfKeyIsProperty: () => checkIfKeyIsProperty,
27
27
  checkIfSugar: () => checkIfSugar,
28
28
  extendizeByKey: () => extendizeByKey,
29
+ extractComponentKeyFromKey: () => extractComponentKeyFromKey,
29
30
  getCapitalCaseKeys: () => getCapitalCaseKeys,
30
31
  getChildrenComponentsByKey: () => getChildrenComponentsByKey,
31
32
  getExtendsInElement: () => getExtendsInElement,
@@ -82,11 +83,14 @@ const checkIfSugar = (element, parent, key) => {
82
83
  }
83
84
  return !hasComponentAttrs || childProps || extendProps || children || childExtends;
84
85
  };
86
+ const extractComponentKeyFromKey = (key) => {
87
+ return key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
88
+ };
85
89
  const extendizeByKey = (element, parent, key) => {
86
90
  const { context } = parent;
87
91
  const { tag, extend, childExtends } = element;
88
92
  const isSugar = checkIfSugar(element, parent, key);
89
- const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
93
+ const extendFromKey = extractComponentKeyFromKey(key);
90
94
  const isExtendKeyComponent = context && context.components[extendFromKey];
91
95
  if (element === isExtendKeyComponent)
92
96
  return element;
@@ -206,7 +210,7 @@ const getExtendsInElement = (obj) => {
206
210
  if (checkIfKeyIsComponent(key)) {
207
211
  result.push(key);
208
212
  }
209
- if (key === "extend") {
213
+ if (key === "extend" || key === "extends") {
210
214
  if (typeof o[key] === "string") {
211
215
  result.push(o[key]);
212
216
  } else if (Array.isArray(o[key])) {
package/dist/esm/array.js CHANGED
@@ -102,10 +102,16 @@ const filterArraysFast = (sourceArr, excludeArr) => {
102
102
  const excludeSet = new Set(excludeArr);
103
103
  return sourceArr.filter((item) => !excludeSet.has(item));
104
104
  };
105
+ const checkIfStringIsInArray = (string, arr) => {
106
+ if (!string)
107
+ return;
108
+ return arr.filter((v) => string.includes(v)).length;
109
+ };
105
110
  export {
106
111
  addItemAfterEveryElement,
107
112
  arrayContainsOtherArray,
108
113
  arraysEqual,
114
+ checkIfStringIsInArray,
109
115
  cutArrayAfterValue,
110
116
  cutArrayBeforeValue,
111
117
  filterArrays,
@@ -73,11 +73,14 @@ const checkIfSugar = (element, parent, key) => {
73
73
  }
74
74
  return !hasComponentAttrs || childProps || extendProps || children || childExtends;
75
75
  };
76
+ const extractComponentKeyFromKey = (key) => {
77
+ return key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
78
+ };
76
79
  const extendizeByKey = (element, parent, key) => {
77
80
  const { context } = parent;
78
81
  const { tag, extend, childExtends } = element;
79
82
  const isSugar = checkIfSugar(element, parent, key);
80
- const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
83
+ const extendFromKey = extractComponentKeyFromKey(key);
81
84
  const isExtendKeyComponent = context && context.components[extendFromKey];
82
85
  if (element === isExtendKeyComponent)
83
86
  return element;
@@ -196,7 +199,7 @@ const getExtendsInElement = (obj) => {
196
199
  if (checkIfKeyIsComponent(key)) {
197
200
  result.push(key);
198
201
  }
199
- if (key === "extend") {
202
+ if (key === "extend" || key === "extends") {
200
203
  if (typeof o[key] === "string") {
201
204
  result.push(o[key]);
202
205
  } else if (Array.isArray(o[key])) {
@@ -232,6 +235,7 @@ export {
232
235
  checkIfKeyIsProperty,
233
236
  checkIfSugar,
234
237
  extendizeByKey,
238
+ extractComponentKeyFromKey,
235
239
  getCapitalCaseKeys,
236
240
  getChildrenComponentsByKey,
237
241
  getExtendsInElement,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.5.162",
3
+ "version": "2.5.167",
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": "0aeb25f284d863a57821a0a74937c2b9babb7969",
28
+ "gitHead": "3851b6d1029397dcf61c44682be5b9c234993e74",
29
29
  "devDependencies": {
30
30
  "@babel/core": "^7.12.0"
31
31
  }