@domql/utils 2.5.150 → 2.5.151
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 +3 -6
- package/cookie.js +34 -0
- package/dist/cjs/component.js +3 -3
- package/dist/cjs/cookie.js +24 -1
- package/dist/cjs/object.js +3 -3
- package/object.js +1 -1
- package/package.json +2 -2
package/component.js
CHANGED
|
@@ -52,7 +52,7 @@ const checkIfSugar = (element, parent, key) => {
|
|
|
52
52
|
} = element
|
|
53
53
|
const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection
|
|
54
54
|
if (hasComponentAttrs && (childProps || extendProps || children || childrenExtends)) {
|
|
55
|
-
|
|
55
|
+
parent.error('Sugar component includes params for builtin components', { verbose: true })
|
|
56
56
|
}
|
|
57
57
|
return !hasComponentAttrs || childProps || extendProps || children || childrenExtends
|
|
58
58
|
}
|
|
@@ -60,7 +60,7 @@ const checkIfSugar = (element, parent, key) => {
|
|
|
60
60
|
export const extendizeByKey = (element, parent, key) => {
|
|
61
61
|
const { context } = parent
|
|
62
62
|
const { tag, extend, childrenExtends } = element
|
|
63
|
-
const isSugar = checkIfSugar(element)
|
|
63
|
+
const isSugar = checkIfSugar(element, parent, key)
|
|
64
64
|
|
|
65
65
|
const extendFromKey = key.includes('+')
|
|
66
66
|
? key.split('+') // get array of componentKeys
|
|
@@ -70,9 +70,6 @@ export const extendizeByKey = (element, parent, key) => {
|
|
|
70
70
|
? [key.split('.')[0]] // get component key split .
|
|
71
71
|
: [key]
|
|
72
72
|
|
|
73
|
-
// console.log(extendFromKey)
|
|
74
|
-
// console.log(context, context?.components)
|
|
75
|
-
// console.log(element)
|
|
76
73
|
const isExtendKeyComponent = context && context.components[extendFromKey]
|
|
77
74
|
if (element === isExtendKeyComponent) return element
|
|
78
75
|
else if (isSugar) {
|
|
@@ -115,7 +112,7 @@ export const addChildrenIfNotInOriginal = (element, parent, key) => {
|
|
|
115
112
|
if (newChild?.ignoreExtend) continue
|
|
116
113
|
if (!childElem) element[childKey] = deepCloneWithExtend(newChild)
|
|
117
114
|
else {
|
|
118
|
-
const isSugar = checkIfSugar(childElem)
|
|
115
|
+
const isSugar = checkIfSugar(childElem, parent, key)
|
|
119
116
|
if (!isSugar) continue
|
|
120
117
|
const inheritedChildElem = element[childKey].props
|
|
121
118
|
if (isObjectLike(newChild)) {
|
package/cookie.js
CHANGED
|
@@ -32,3 +32,37 @@ export const removeCookie = (cname) => {
|
|
|
32
32
|
if (isUndefined(document) || isUndefined(document.cookie)) return
|
|
33
33
|
document.cookie = cname + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;'
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Load item from the localStorage
|
|
38
|
+
*
|
|
39
|
+
* @param key -- string to identify the storage item
|
|
40
|
+
*/
|
|
41
|
+
export function getLocalStorage (key) {
|
|
42
|
+
let savedJSON
|
|
43
|
+
|
|
44
|
+
if (window.localStorage) {
|
|
45
|
+
try {
|
|
46
|
+
savedJSON = JSON.parse(window.localStorage.getItem(key))
|
|
47
|
+
} catch (e) {}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (typeof savedJSON !== 'undefined') {
|
|
51
|
+
return savedJSON
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Save the data to window.localStorage
|
|
56
|
+
*
|
|
57
|
+
* @param key - local storage key to save the data under
|
|
58
|
+
* @param data - the data to save
|
|
59
|
+
*/
|
|
60
|
+
export function setLocalStorage (key, data) {
|
|
61
|
+
if (data && window.localStorage) {
|
|
62
|
+
if (typeof data === 'object') {
|
|
63
|
+
window.localStorage.setItem(key, JSON.stringify(data))
|
|
64
|
+
} else {
|
|
65
|
+
window.localStorage.setItem(key, data)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
package/dist/cjs/component.js
CHANGED
|
@@ -73,14 +73,14 @@ const checkIfSugar = (element, parent, key) => {
|
|
|
73
73
|
} = element;
|
|
74
74
|
const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
|
|
75
75
|
if (hasComponentAttrs && (childProps || extendProps || children || childrenExtends)) {
|
|
76
|
-
|
|
76
|
+
parent.error("Sugar component includes params for builtin components", { verbose: true });
|
|
77
77
|
}
|
|
78
78
|
return !hasComponentAttrs || childProps || extendProps || children || childrenExtends;
|
|
79
79
|
};
|
|
80
80
|
const extendizeByKey = (element, parent, key) => {
|
|
81
81
|
const { context } = parent;
|
|
82
82
|
const { tag, extend, childrenExtends } = element;
|
|
83
|
-
const isSugar = checkIfSugar(element);
|
|
83
|
+
const isSugar = checkIfSugar(element, parent, key);
|
|
84
84
|
const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
|
|
85
85
|
const isExtendKeyComponent = context && context.components[extendFromKey];
|
|
86
86
|
if (element === isExtendKeyComponent)
|
|
@@ -126,7 +126,7 @@ const addChildrenIfNotInOriginal = (element, parent, key) => {
|
|
|
126
126
|
if (!childElem)
|
|
127
127
|
element[childKey] = (0, import__.deepCloneWithExtend)(newChild);
|
|
128
128
|
else {
|
|
129
|
-
const isSugar = checkIfSugar(childElem);
|
|
129
|
+
const isSugar = checkIfSugar(childElem, parent, key);
|
|
130
130
|
if (!isSugar)
|
|
131
131
|
continue;
|
|
132
132
|
const inheritedChildElem = element[childKey].props;
|
package/dist/cjs/cookie.js
CHANGED
|
@@ -19,9 +19,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var cookie_exports = {};
|
|
20
20
|
__export(cookie_exports, {
|
|
21
21
|
getCookie: () => getCookie,
|
|
22
|
+
getLocalStorage: () => getLocalStorage,
|
|
22
23
|
isMobile: () => isMobile,
|
|
23
24
|
removeCookie: () => removeCookie,
|
|
24
|
-
setCookie: () => setCookie
|
|
25
|
+
setCookie: () => setCookie,
|
|
26
|
+
setLocalStorage: () => setLocalStorage
|
|
25
27
|
});
|
|
26
28
|
module.exports = __toCommonJS(cookie_exports);
|
|
27
29
|
var import_types = require("./types");
|
|
@@ -55,3 +57,24 @@ const removeCookie = (cname) => {
|
|
|
55
57
|
return;
|
|
56
58
|
import_utils.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
|
57
59
|
};
|
|
60
|
+
function getLocalStorage(key) {
|
|
61
|
+
let savedJSON;
|
|
62
|
+
if (window.localStorage) {
|
|
63
|
+
try {
|
|
64
|
+
savedJSON = JSON.parse(window.localStorage.getItem(key));
|
|
65
|
+
} catch (e) {
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (typeof savedJSON !== "undefined") {
|
|
69
|
+
return savedJSON;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function setLocalStorage(key, data) {
|
|
73
|
+
if (data && window.localStorage) {
|
|
74
|
+
if (typeof data === "object") {
|
|
75
|
+
window.localStorage.setItem(key, JSON.stringify(data));
|
|
76
|
+
} else {
|
|
77
|
+
window.localStorage.setItem(key, data);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
package/dist/cjs/object.js
CHANGED
|
@@ -191,10 +191,10 @@ const deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}, visited
|
|
|
191
191
|
return o;
|
|
192
192
|
};
|
|
193
193
|
const deepStringify = (obj, stringified = {}) => {
|
|
194
|
-
var _a;
|
|
194
|
+
var _a, _b;
|
|
195
195
|
if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
|
|
196
|
-
|
|
197
|
-
obj = (
|
|
196
|
+
(obj.__element || ((_a = obj.parent) == null ? void 0 : _a.__element)).warn("Trying to clone element or state at", obj);
|
|
197
|
+
obj = (_b = obj.parse) == null ? void 0 : _b.call(obj);
|
|
198
198
|
}
|
|
199
199
|
for (const prop in obj) {
|
|
200
200
|
const objProp = obj[prop];
|
package/object.js
CHANGED
|
@@ -217,7 +217,7 @@ export const deepCloneWithExtend = (obj, excludeFrom = ['node'], options = {}, v
|
|
|
217
217
|
*/
|
|
218
218
|
export const deepStringify = (obj, stringified = {}) => {
|
|
219
219
|
if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
|
|
220
|
-
|
|
220
|
+
(obj.__element || obj.parent?.__element).warn('Trying to clone element or state at', obj)
|
|
221
221
|
obj = obj.parse?.()
|
|
222
222
|
}
|
|
223
223
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.151",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"build": "yarn build:cjs",
|
|
26
26
|
"prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "f37b51f84b8bca80b8bce7887e83d61ac25eb3d5",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@babel/core": "^7.12.0"
|
|
31
31
|
}
|