@cocreate/state 1.25.1 → 1.26.1
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/.github/workflows/automated.yml +23 -10
- package/.github/workflows/manual.yml +1 -2
- package/CHANGELOG.md +24 -0
- package/package.json +30 -19
- package/release.config.js +11 -3
- package/src/index.js +54 -42
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
name: Automated Workflow
|
|
2
|
+
|
|
2
3
|
on:
|
|
3
4
|
push:
|
|
4
5
|
branches:
|
|
5
6
|
- master
|
|
7
|
+
|
|
6
8
|
jobs:
|
|
7
9
|
about:
|
|
8
10
|
runs-on: ubuntu-latest
|
|
@@ -18,26 +20,37 @@ jobs:
|
|
|
18
20
|
with:
|
|
19
21
|
direction: overwrite-github
|
|
20
22
|
githubToken: "${{ secrets.GITHUB }}"
|
|
23
|
+
|
|
21
24
|
release:
|
|
22
25
|
runs-on: ubuntu-latest
|
|
23
26
|
steps:
|
|
24
27
|
- name: Checkout
|
|
25
28
|
uses: actions/checkout@v4
|
|
29
|
+
with:
|
|
30
|
+
fetch-depth: 0 # Required so semantic-release can trace git tags/history
|
|
31
|
+
|
|
26
32
|
- name: Setup Node.js
|
|
27
33
|
uses: actions/setup-node@v4
|
|
28
34
|
with:
|
|
29
|
-
node-version: 22
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
@semantic-release/changelog
|
|
35
|
+
node-version: 22
|
|
36
|
+
|
|
37
|
+
- name: Install Semantic Release & Plugins
|
|
38
|
+
# Installs semantic-release and its plugins on the runner
|
|
39
|
+
run: |
|
|
40
|
+
npm install -g semantic-release \
|
|
41
|
+
@semantic-release/changelog \
|
|
42
|
+
@semantic-release/npm \
|
|
43
|
+
@semantic-release/github \
|
|
36
44
|
@semantic-release/git
|
|
37
|
-
|
|
45
|
+
|
|
46
|
+
- name: Run Semantic Release (Native)
|
|
47
|
+
id: semantic
|
|
48
|
+
# This will automatically pick up your export default config file in the repository root
|
|
49
|
+
run: npx semantic-release
|
|
38
50
|
env:
|
|
39
|
-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
51
|
+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
40
52
|
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
|
|
53
|
+
|
|
41
54
|
outputs:
|
|
42
55
|
new_release_published: "${{ steps.semantic.outputs.new_release_published }}"
|
|
43
|
-
new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
|
|
56
|
+
new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
## [1.26.1](https://github.com/CoCreate-app/CoCreate-state/compare/v1.26.0...v1.26.1) (2026-07-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* bump dependencies ([f474f83](https://github.com/CoCreate-app/CoCreate-state/commit/f474f8398f5597cd9dca6cf0a45d4fdc8ad4d061))
|
|
7
|
+
|
|
8
|
+
# [1.26.0](https://github.com/CoCreate-app/CoCreate-state/compare/v1.25.2...v1.26.0) (2026-07-17)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* update automated workflow and release configuration for improved semantic release handling ([f7b1a38](https://github.com/CoCreate-app/CoCreate-state/commit/f7b1a388912d2a48db42a8a0578a1f8af08bbacb))
|
|
14
|
+
|
|
15
|
+
## [1.25.2](https://github.com/CoCreate-app/CoCreate-state/compare/v1.25.1...v1.25.2) (2026-07-11)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* bump package versions ([aabd567](https://github.com/CoCreate-app/CoCreate-state/commit/aabd5671ecd90e0bf4d3fa7232a471239e1711e2))
|
|
21
|
+
* improve state-id handling and support multiple state-to keys ([21a4f11](https://github.com/CoCreate-app/CoCreate-state/commit/21a4f11279f7cb12e811611f0ea28f186e67ff7a))
|
|
22
|
+
* removed post install and add add packages to apprved list ([7c4b3ce](https://github.com/CoCreate-app/CoCreate-state/commit/7c4b3cea12c1438018a0b3b144f177bf539380af))
|
|
23
|
+
* semantic version handling ([9ca5e3e](https://github.com/CoCreate-app/CoCreate-state/commit/9ca5e3e929a2a0c5a6d5881b6d777eda6ebeaca1))
|
|
24
|
+
|
|
1
25
|
## [1.25.1](https://github.com/CoCreate-app/CoCreate-state/compare/v1.25.0...v1.25.1) (2026-03-05)
|
|
2
26
|
|
|
3
27
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/state",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.1",
|
|
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",
|
|
@@ -16,10 +16,9 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
|
-
"start": "
|
|
20
|
-
"build": "
|
|
21
|
-
"dev": "
|
|
22
|
-
"postinstall": "node -e \"const { execSync } = require('child_process'); try { execSync('coc --version', { stdio: 'ignore' }); } catch (error) { try { execSync('npm install -g @cocreate/cli', { stdio: 'inherit' }); console.log('Installed \"@cocreate/cli\" globally.'); } catch (error) { console.error('Failed to install \"@cocreate/cli\" globally:', error); } }\""
|
|
19
|
+
"start": "webpack --config webpack.config.js",
|
|
20
|
+
"build": "webpack --mode=production --config webpack.config.js",
|
|
21
|
+
"dev": "webpack --config webpack.config.js --watch"
|
|
23
22
|
},
|
|
24
23
|
"repository": {
|
|
25
24
|
"type": "git",
|
|
@@ -36,21 +35,33 @@
|
|
|
36
35
|
"url": "https://github.com/sponsors/CoCreate-app"
|
|
37
36
|
},
|
|
38
37
|
"main": "./src/index.js",
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@cocreate/actions": "^1.22.1",
|
|
40
|
+
"@cocreate/crud-client": "^1.35.0",
|
|
41
|
+
"@cocreate/element-prototype": "^1.33.0",
|
|
42
|
+
"@cocreate/local-storage": "^1.17.0",
|
|
43
|
+
"@cocreate/observer": "^1.20.0",
|
|
44
|
+
"@cocreate/uuid": "^1.12.4"
|
|
45
|
+
},
|
|
39
46
|
"devDependencies": {
|
|
40
|
-
"
|
|
41
|
-
"esbuild": "^0.25.2",
|
|
42
|
-
"esbuild-loader": "^4.3.0",
|
|
43
|
-
"mini-css-extract-plugin": "^1.5.0",
|
|
44
|
-
"webpack": "^5.24.4",
|
|
45
|
-
"webpack-cli": "^4.5.0",
|
|
46
|
-
"webpack-log": "^3.0.1"
|
|
47
|
+
"@cocreate/webpack": "^1.6.0"
|
|
47
48
|
},
|
|
48
|
-
"
|
|
49
|
-
"@cocreate/actions
|
|
50
|
-
"@cocreate/
|
|
51
|
-
"@cocreate/
|
|
52
|
-
"@cocreate/
|
|
53
|
-
"@cocreate/
|
|
54
|
-
"@cocreate/
|
|
49
|
+
"allowScripts": {
|
|
50
|
+
"@cocreate/actions@1.21.4": true,
|
|
51
|
+
"@cocreate/api@1.22.5": true,
|
|
52
|
+
"@cocreate/config@1.13.4": true,
|
|
53
|
+
"@cocreate/crud-client@1.34.6": true,
|
|
54
|
+
"@cocreate/element-prototype@1.31.4": true,
|
|
55
|
+
"@cocreate/elements@1.42.9": true,
|
|
56
|
+
"@cocreate/filter@1.33.6": true,
|
|
57
|
+
"@cocreate/indexeddb@1.23.4": true,
|
|
58
|
+
"@cocreate/local-storage@1.16.5": true,
|
|
59
|
+
"@cocreate/observer@1.19.0": true,
|
|
60
|
+
"@cocreate/organizations@1.30.1": true,
|
|
61
|
+
"@cocreate/render@1.46.1": true,
|
|
62
|
+
"@cocreate/socket-client@1.40.5": true,
|
|
63
|
+
"@cocreate/utils@1.42.2": true,
|
|
64
|
+
"@cocreate/uuid@1.12.4": true,
|
|
65
|
+
"@cocreate/webpack@1.4.3": true
|
|
55
66
|
}
|
|
56
67
|
}
|
package/release.config.js
CHANGED
|
@@ -10,12 +10,20 @@ module.exports = {
|
|
|
10
10
|
changelogFile: "CHANGELOG.md",
|
|
11
11
|
},
|
|
12
12
|
],
|
|
13
|
-
"@semantic-release/npm",
|
|
14
|
-
"@semantic-release/github",
|
|
13
|
+
"@semantic-release/npm",
|
|
15
14
|
[
|
|
16
|
-
"@semantic-release/
|
|
15
|
+
"@semantic-release/github",
|
|
17
16
|
{
|
|
17
|
+
successComment: false,
|
|
18
|
+
failTitle: false,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
[
|
|
22
|
+
"@semantic-release/git",
|
|
23
|
+
{
|
|
24
|
+
// Only stage and commit the changelog and package.json
|
|
18
25
|
assets: ["CHANGELOG.md", "package.json"],
|
|
26
|
+
message: "chore(release): ${nextRelease.version} [skip ci]",
|
|
19
27
|
},
|
|
20
28
|
],
|
|
21
29
|
],
|
package/src/index.js
CHANGED
|
@@ -51,13 +51,13 @@ function initElement(element) {
|
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
// Split state-id string into an array of trimmed individual IDs
|
|
55
|
+
const idArray = state_id.split(',').map(id => id.trim()).filter(Boolean);
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (!attrValues) continue; // Use continue to ensure other IDs in the array still process
|
|
57
|
+
// Apply values stored under each ID listed in the array
|
|
58
|
+
for (let id of idArray) {
|
|
59
|
+
let attrValues = statedAttributes[id];
|
|
60
|
+
if (!attrValues) continue; // Continue to ensure other IDs in the array still process
|
|
61
61
|
_setAttributeValues(element, attrValues);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -79,22 +79,21 @@ function _setAttributeValues(el, attrValues) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
async function _setAttributeValue(element, attribute, value, isOverwrite) {
|
|
82
|
-
// TODO: if (value !== undefined)???
|
|
83
82
|
if (!element.getAttribute(attribute) || isOverwrite) {
|
|
84
|
-
if (attribute == "value") {
|
|
85
|
-
if (element.value == "" || (element.value && isOverwrite))
|
|
86
|
-
element.value = value;
|
|
87
|
-
else if (
|
|
88
|
-
isOverwrite ||
|
|
89
|
-
(element.hasAttribute("value") && !(await element.getValue()))
|
|
90
|
-
)
|
|
91
|
-
element.setValue(value);
|
|
92
|
-
} else if (attribute === "class" && value) {
|
|
93
|
-
const classes = String(value).split(/\s+/).filter(Boolean);
|
|
94
|
-
if (classes.length) element.classList.add(...classes);
|
|
95
|
-
} else if (element.hasAttribute(attribute) && (value || value === "")) {
|
|
96
|
-
element.setAttribute(attribute, value);
|
|
97
|
-
} else if (attribute.startsWith("$")) {
|
|
83
|
+
if (attribute == "value") {
|
|
84
|
+
if (element.value == "" || (element.value && isOverwrite))
|
|
85
|
+
element.value = value;
|
|
86
|
+
else if (
|
|
87
|
+
isOverwrite ||
|
|
88
|
+
(element.hasAttribute("value") && !(await element.getValue()))
|
|
89
|
+
)
|
|
90
|
+
element.setValue(value);
|
|
91
|
+
} else if (attribute === "class" && value) {
|
|
92
|
+
const classes = String(value).split(/\s+/).filter(Boolean);
|
|
93
|
+
if (classes.length) element.classList.add(...classes);
|
|
94
|
+
} else if (element.hasAttribute(attribute) && (value || value === "")) {
|
|
95
|
+
element.setAttribute(attribute, value);
|
|
96
|
+
} else if (attribute.startsWith("$")) {
|
|
98
97
|
// Handle using operators.js
|
|
99
98
|
const prop = attribute.substring(1);
|
|
100
99
|
if (element[prop]) {
|
|
@@ -117,10 +116,6 @@ async function stateAttributes(element) {
|
|
|
117
116
|
|
|
118
117
|
let elements = [];
|
|
119
118
|
|
|
120
|
-
// let form = element.closest("form");
|
|
121
|
-
// if (form) {
|
|
122
|
-
// elements = form.querySelectorAll("[state_to]");
|
|
123
|
-
// } else {
|
|
124
119
|
if (element.hasAttribute("state-to")) elements.push(element);
|
|
125
120
|
let nestedElements = element.querySelectorAll("[state-to]");
|
|
126
121
|
elements.push(...nestedElements);
|
|
@@ -131,7 +126,6 @@ async function stateAttributes(element) {
|
|
|
131
126
|
}
|
|
132
127
|
current = current.parentElement;
|
|
133
128
|
}
|
|
134
|
-
// }
|
|
135
129
|
|
|
136
130
|
let changeState = false;
|
|
137
131
|
let sessionChanged = false;
|
|
@@ -154,24 +148,35 @@ async function stateAttributes(element) {
|
|
|
154
148
|
}
|
|
155
149
|
|
|
156
150
|
let state_to = elements[i].getAttribute("state-to");
|
|
151
|
+
if (!state_to) continue;
|
|
157
152
|
|
|
158
153
|
let isLocal = triggerIsLocal || elements[i].hasAttribute("state-localstorage") || elements[i].hasAttribute("state-onstoragechange");
|
|
159
154
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
155
|
+
// Parse state-to string into an array of trimmed individual target keys
|
|
156
|
+
let stateToKeys = state_to.split(',').map(s => s.trim()).filter(Boolean);
|
|
157
|
+
|
|
158
|
+
for (let toKey of stateToKeys) {
|
|
159
|
+
if (isLocal) {
|
|
160
|
+
Object.assign(localState, { [`${toKey}`]: attrValues });
|
|
161
|
+
localChanged = true;
|
|
162
|
+
} else {
|
|
163
|
+
Object.assign(sessionState, { [`${toKey}`]: attrValues });
|
|
164
|
+
sessionChanged = true;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
_getStateId(attrValues, toKey);
|
|
166
168
|
}
|
|
167
|
-
|
|
168
|
-
_getStateId(attrValues, state_to);
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
let href = element.closest("href");
|
|
172
172
|
if (!changeState && !href) {
|
|
173
|
-
//
|
|
174
|
-
let title = element.getAttribute("title") || document.title || "";
|
|
173
|
+
// --- IMPROVEMENT: Explicitly support [state-title] only, with document.title fallback (No native 'title' fallback) ---
|
|
174
|
+
let title = element.getAttribute("state-title") || document.title || "";
|
|
175
|
+
|
|
176
|
+
// --- IMPROVEMENT: Update document.title immediately on click/action ---
|
|
177
|
+
if (title) {
|
|
178
|
+
document.title = title;
|
|
179
|
+
}
|
|
175
180
|
|
|
176
181
|
history.pushState(
|
|
177
182
|
{ sessionState: JSON.stringify(sessionState), localState: JSON.stringify(localState), title, url: location.href },
|
|
@@ -210,9 +215,16 @@ async function _getAttributeValues(element) {
|
|
|
210
215
|
return attributeValues;
|
|
211
216
|
}
|
|
212
217
|
|
|
218
|
+
// Scans elements containing [state-id] and updates those matching the target key
|
|
213
219
|
function _getStateId(attrValues, state_to) {
|
|
214
|
-
const elements = document.querySelectorAll(
|
|
215
|
-
for (let element of elements)
|
|
220
|
+
const elements = document.querySelectorAll('[state-id]');
|
|
221
|
+
for (let element of elements) {
|
|
222
|
+
let state_id_attr = element.getAttribute("state-id") || "";
|
|
223
|
+
let idArray = state_id_attr.split(',').map(id => id.trim()).filter(Boolean);
|
|
224
|
+
if (idArray.includes(state_to)) {
|
|
225
|
+
_setAttributeValues(element, attrValues);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
216
228
|
}
|
|
217
229
|
|
|
218
230
|
window.onload = function () {
|
|
@@ -247,11 +259,11 @@ window.addEventListener("popstate", function (event) {
|
|
|
247
259
|
|
|
248
260
|
if (event.state.url && event.state.url !== window.location.href) {
|
|
249
261
|
if (event.state.title)
|
|
250
|
-
sessionStorage.setItem("currentPageTitle", event.state.title);
|
|
262
|
+
sessionStorage.setItem("currentPageTitle", event.state.title);
|
|
251
263
|
|
|
252
|
-
location.href = event.state.url;
|
|
264
|
+
location.href = event.state.url;
|
|
253
265
|
} else if (event.state.title) {
|
|
254
|
-
document.title = event.state.title;
|
|
266
|
+
document.title = event.state.title;
|
|
255
267
|
}
|
|
256
268
|
}
|
|
257
269
|
});
|
|
@@ -275,4 +287,4 @@ Action.init({
|
|
|
275
287
|
|
|
276
288
|
init();
|
|
277
289
|
|
|
278
|
-
export default { initElements, initElement, stateAttributes };
|
|
290
|
+
export default { initElements, initElement, stateAttributes };
|