@cocreate/state 1.25.0 → 1.26.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/.github/workflows/automated.yml +23 -10
- package/.github/workflows/manual.yml +1 -2
- package/CHANGELOG.md +24 -0
- package/package.json +28 -17
- package/release.config.js +11 -3
- package/src/index.js +42 -27
|
@@ -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.0](https://github.com/CoCreate-app/CoCreate-state/compare/v1.25.2...v1.26.0) (2026-07-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* update automated workflow and release configuration for improved semantic release handling ([f7b1a38](https://github.com/CoCreate-app/CoCreate-state/commit/f7b1a388912d2a48db42a8a0578a1f8af08bbacb))
|
|
7
|
+
|
|
8
|
+
## [1.25.2](https://github.com/CoCreate-app/CoCreate-state/compare/v1.25.1...v1.25.2) (2026-07-11)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* bump package versions ([aabd567](https://github.com/CoCreate-app/CoCreate-state/commit/aabd5671ecd90e0bf4d3fa7232a471239e1711e2))
|
|
14
|
+
* improve state-id handling and support multiple state-to keys ([21a4f11](https://github.com/CoCreate-app/CoCreate-state/commit/21a4f11279f7cb12e811611f0ea28f186e67ff7a))
|
|
15
|
+
* removed post install and add add packages to apprved list ([7c4b3ce](https://github.com/CoCreate-app/CoCreate-state/commit/7c4b3cea12c1438018a0b3b144f177bf539380af))
|
|
16
|
+
* semantic version handling ([9ca5e3e](https://github.com/CoCreate-app/CoCreate-state/commit/9ca5e3e929a2a0c5a6d5881b6d777eda6ebeaca1))
|
|
17
|
+
|
|
18
|
+
## [1.25.1](https://github.com/CoCreate-app/CoCreate-state/compare/v1.25.0...v1.25.1) (2026-03-05)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* support adding classes via state attributes ([dfa50d2](https://github.com/CoCreate-app/CoCreate-state/commit/dfa50d29ac8b5c15ef384dfebd67dc8faad816f8))
|
|
24
|
+
|
|
1
25
|
# [1.25.0](https://github.com/CoCreate-app/CoCreate-state/compare/v1.24.9...v1.25.0) (2026-02-28)
|
|
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.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",
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"start": "npx webpack --config webpack.config.js",
|
|
20
20
|
"build": "npx webpack --mode=production --config webpack.config.js",
|
|
21
|
-
"dev": "npx webpack --config webpack.config.js --watch"
|
|
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); } }\""
|
|
21
|
+
"dev": "npx 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.21.4",
|
|
40
|
+
"@cocreate/crud-client": "^1.34.6",
|
|
41
|
+
"@cocreate/element-prototype": "^1.31.4",
|
|
42
|
+
"@cocreate/local-storage": "^1.16.5",
|
|
43
|
+
"@cocreate/observer": "^1.19.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.4.3"
|
|
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,7 +79,6 @@ 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
83
|
if (attribute == "value") {
|
|
85
84
|
if (element.value == "" || (element.value && isOverwrite))
|
|
@@ -89,6 +88,9 @@ async function _setAttributeValue(element, attribute, value, isOverwrite) {
|
|
|
89
88
|
(element.hasAttribute("value") && !(await element.getValue()))
|
|
90
89
|
)
|
|
91
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);
|
|
92
94
|
} else if (element.hasAttribute(attribute) && (value || value === "")) {
|
|
93
95
|
element.setAttribute(attribute, value);
|
|
94
96
|
} else if (attribute.startsWith("$")) {
|
|
@@ -114,10 +116,6 @@ async function stateAttributes(element) {
|
|
|
114
116
|
|
|
115
117
|
let elements = [];
|
|
116
118
|
|
|
117
|
-
// let form = element.closest("form");
|
|
118
|
-
// if (form) {
|
|
119
|
-
// elements = form.querySelectorAll("[state_to]");
|
|
120
|
-
// } else {
|
|
121
119
|
if (element.hasAttribute("state-to")) elements.push(element);
|
|
122
120
|
let nestedElements = element.querySelectorAll("[state-to]");
|
|
123
121
|
elements.push(...nestedElements);
|
|
@@ -128,7 +126,6 @@ async function stateAttributes(element) {
|
|
|
128
126
|
}
|
|
129
127
|
current = current.parentElement;
|
|
130
128
|
}
|
|
131
|
-
// }
|
|
132
129
|
|
|
133
130
|
let changeState = false;
|
|
134
131
|
let sessionChanged = false;
|
|
@@ -151,24 +148,35 @@ async function stateAttributes(element) {
|
|
|
151
148
|
}
|
|
152
149
|
|
|
153
150
|
let state_to = elements[i].getAttribute("state-to");
|
|
151
|
+
if (!state_to) continue;
|
|
154
152
|
|
|
155
153
|
let isLocal = triggerIsLocal || elements[i].hasAttribute("state-localstorage") || elements[i].hasAttribute("state-onstoragechange");
|
|
156
154
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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);
|
|
163
168
|
}
|
|
164
|
-
|
|
165
|
-
_getStateId(attrValues, state_to);
|
|
166
169
|
}
|
|
167
170
|
|
|
168
171
|
let href = element.closest("href");
|
|
169
172
|
if (!changeState && !href) {
|
|
170
|
-
//
|
|
171
|
-
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
|
+
}
|
|
172
180
|
|
|
173
181
|
history.pushState(
|
|
174
182
|
{ sessionState: JSON.stringify(sessionState), localState: JSON.stringify(localState), title, url: location.href },
|
|
@@ -207,9 +215,16 @@ async function _getAttributeValues(element) {
|
|
|
207
215
|
return attributeValues;
|
|
208
216
|
}
|
|
209
217
|
|
|
218
|
+
// Scans elements containing [state-id] and updates those matching the target key
|
|
210
219
|
function _getStateId(attrValues, state_to) {
|
|
211
|
-
const elements = document.querySelectorAll(
|
|
212
|
-
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
|
+
}
|
|
213
228
|
}
|
|
214
229
|
|
|
215
230
|
window.onload = function () {
|
|
@@ -244,11 +259,11 @@ window.addEventListener("popstate", function (event) {
|
|
|
244
259
|
|
|
245
260
|
if (event.state.url && event.state.url !== window.location.href) {
|
|
246
261
|
if (event.state.title)
|
|
247
|
-
sessionStorage.setItem("currentPageTitle", event.state.title);
|
|
262
|
+
sessionStorage.setItem("currentPageTitle", event.state.title);
|
|
248
263
|
|
|
249
|
-
location.href = event.state.url;
|
|
264
|
+
location.href = event.state.url;
|
|
250
265
|
} else if (event.state.title) {
|
|
251
|
-
document.title = event.state.title;
|
|
266
|
+
document.title = event.state.title;
|
|
252
267
|
}
|
|
253
268
|
}
|
|
254
269
|
});
|