@cocreate/state 1.20.0 → 1.21.0
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/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/index.js +20 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [1.21.0](https://github.com/CoCreate-app/CoCreate-state/compare/v1.20.1...v1.21.0) (2024-04-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* $back and $forward operators for history control ([ffdeb5d](https://github.com/CoCreate-app/CoCreate-state/commit/ffdeb5d8d5331e51cbcd97043369f5eef1331c35))
|
|
7
|
+
|
|
8
|
+
## [1.20.1](https://github.com/CoCreate-app/CoCreate-state/compare/v1.20.0...v1.20.1) (2024-02-20)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* state handling ([81461a7](https://github.com/CoCreate-app/CoCreate-state/commit/81461a74691b99e27d3eac47851fa31f3a1b49ba))
|
|
14
|
+
|
|
1
15
|
# [1.20.0](https://github.com/CoCreate-app/CoCreate-state/compare/v1.19.0...v1.20.0) (2023-11-25)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/state",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.0",
|
|
4
4
|
"description": "Data attributes which can be used for components in CoCreate framework combined as a group of attributes that dynamically change attributes & fetch custom data.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"state",
|
package/src/index.js
CHANGED
|
@@ -55,17 +55,23 @@ function _setAttributeValues(el, attrValues) {
|
|
|
55
55
|
delete attrValues['overwrite']
|
|
56
56
|
|
|
57
57
|
Object.keys(attrValues).forEach(key => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (key
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
if (attrValues[key] === '$back')
|
|
59
|
+
window.history.back()
|
|
60
|
+
else if (attrValues[key] === '$forward')
|
|
61
|
+
window.history.forward()
|
|
62
|
+
else {
|
|
63
|
+
_setAttributeValue(el, key, attrValues[key], isOverwrite);
|
|
64
|
+
_setAttributeValue(el, `state-${key}`, attrValues[key], isOverwrite);
|
|
65
|
+
if (key == 'array' || key == 'object' || key == 'name') {
|
|
66
|
+
_setAttributeValue(el, `fetch-${key}`, attrValues[key], isOverwrite);
|
|
67
|
+
_setAttributeValue(el, `state-fetch-${key}`, attrValues[key], isOverwrite);
|
|
68
|
+
}
|
|
69
|
+
if (key == 'template') {
|
|
70
|
+
_setAttributeValue(el, 'template_id', attrValues[key], isOverwrite);
|
|
71
|
+
}
|
|
72
|
+
if (key == 'template_id') {
|
|
73
|
+
_setAttributeValue(el, 'template', attrValues[key], isOverwrite);
|
|
74
|
+
}
|
|
69
75
|
}
|
|
70
76
|
});
|
|
71
77
|
}
|
|
@@ -103,14 +109,12 @@ async function stateAttributes(element) {
|
|
|
103
109
|
Object.assign(statedAttributes, { [`${state_to}`]: attrValues });
|
|
104
110
|
_getStateId(attrValues, state_to);
|
|
105
111
|
}
|
|
106
|
-
|
|
112
|
+
statedAttributes = JSON.stringify(statedAttributes)
|
|
107
113
|
if (!element.closest('href')) {
|
|
108
|
-
|
|
109
|
-
if (currentState)
|
|
110
|
-
history.pushState({ statedAttributes: currentState, title: '', url: '' }, '', location.href);
|
|
114
|
+
history.pushState({ statedAttributes, title: '', url: '' }, '', location.href);
|
|
111
115
|
}
|
|
112
116
|
|
|
113
|
-
localStorage.setItem('statedAttributes',
|
|
117
|
+
localStorage.setItem('statedAttributes', statedAttributes);
|
|
114
118
|
|
|
115
119
|
document.dispatchEvent(new CustomEvent('stateEnd', {
|
|
116
120
|
detail: {}
|