@domql/utils 2.5.167 → 2.5.169

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 CHANGED
@@ -79,6 +79,18 @@ export const extendizeByKey = (element, parent, key) => {
79
79
  tag,
80
80
  props: { ...element }
81
81
  })
82
+ if (newElem.props.data) {
83
+ newElem.data = newElem.props.data
84
+ delete newElem.props.data
85
+ }
86
+ if (newElem.props.state) {
87
+ newElem.state = newElem.props.state
88
+ delete newElem.props.state
89
+ }
90
+ if (newElem.props.attr) {
91
+ newElem.attr = newElem.props.attr
92
+ delete newElem.props.attr
93
+ }
82
94
  if (childExtends) newElem.childExtend = childExtends
83
95
  return newElem
84
96
  } else if (!extend || extend === true) {
@@ -100,6 +100,18 @@ const extendizeByKey = (element, parent, key) => {
100
100
  tag,
101
101
  props: { ...element }
102
102
  });
103
+ if (newElem.props.data) {
104
+ newElem.data = newElem.props.data;
105
+ delete newElem.props.data;
106
+ }
107
+ if (newElem.props.state) {
108
+ newElem.state = newElem.props.state;
109
+ delete newElem.props.state;
110
+ }
111
+ if (newElem.props.attr) {
112
+ newElem.attr = newElem.props.attr;
113
+ delete newElem.props.attr;
114
+ }
103
115
  if (childExtends)
104
116
  newElem.childExtend = childExtends;
105
117
  return newElem;
@@ -46,14 +46,15 @@ const brackRegex = {
46
46
  2: /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g,
47
47
  3: /\{\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}\}/g
48
48
  };
49
- const replaceLiteralsWithObjectFields = (str, state, options = {}) => {
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 = state;
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 = state[variable.trim()];
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
  };
@@ -90,6 +90,18 @@ const extendizeByKey = (element, parent, key) => {
90
90
  tag,
91
91
  props: __spreadValues({}, element)
92
92
  });
93
+ if (newElem.props.data) {
94
+ newElem.data = newElem.props.data;
95
+ delete newElem.props.data;
96
+ }
97
+ if (newElem.props.state) {
98
+ newElem.state = newElem.props.state;
99
+ delete newElem.props.state;
100
+ }
101
+ if (newElem.props.attr) {
102
+ newElem.attr = newElem.props.attr;
103
+ delete newElem.props.attr;
104
+ }
93
105
  if (childExtends)
94
106
  newElem.childExtend = childExtends;
95
107
  return newElem;
@@ -14,14 +14,15 @@ const brackRegex = {
14
14
  2: /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g,
15
15
  3: /\{\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}\}/g
16
16
  };
17
- const replaceLiteralsWithObjectFields = (str, state, options = {}) => {
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 = state;
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 = state[variable.trim()];
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.167",
3
+ "version": "2.5.169",
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": "3851b6d1029397dcf61c44682be5b9c234993e74",
28
+ "gitHead": "ae523f95551eac614ee00baf3c425cb6c4271a2c",
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 const replaceLiteralsWithObjectFields = (str, state, options = {}) => {
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 = state
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 = state[variable.trim()]
49
+ const value = obj[variable.trim()]
49
50
  return value !== undefined ? `${value}` : ''
50
51
  }
51
52
  })