@cocreate/element-prototype 1.31.4 → 1.33.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 +22 -0
- package/package.json +9 -12
- package/release.config.js +11 -3
- package/src/getValue.js +46 -22
- package/src/index.js +4 -4
- package/src/setValue.js +4 -1
|
@@ -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,25 @@
|
|
|
1
|
+
# [1.33.0](https://github.com/CoCreate-app/CoCreate-element-prototype/compare/v1.32.0...v1.33.0) (2026-07-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* update automated workflow and release configuration for improved semantic release handling ([66b108a](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/66b108a75c3f4e8404dbc24db6e7fdd03ecdd180))
|
|
7
|
+
|
|
8
|
+
# [1.32.0](https://github.com/CoCreate-app/CoCreate-element-prototype/compare/v1.31.4...v1.32.0) (2026-07-11)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* bump package versions ([1512280](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/1512280ec19444bb884ab814b23ffded58f87ef0))
|
|
14
|
+
* removed post install and add add packages to apprved list ([d658bca](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/d658bca975bec9d38a09ebd050ff0c4ce7ba33ed))
|
|
15
|
+
* semantic version handling ([b38cdb1](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/b38cdb193434cbc542f01959f2864cc14ebce0a8))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* Add getValue and setValue support for SVG elements; Update dashboard and health journal components with new structure and CoCreateJS integration. ([d2c6263](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/d2c6263e5c948df92ce7f5cdca9443c525751c8a))
|
|
21
|
+
* Enhance handleDateTime function to support 'now' attribute and add timeTo functionality for detailed time calculations ([0613076](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/0613076199fa6b581d206cf2cb9089c504366898))
|
|
22
|
+
|
|
1
23
|
## [1.31.4](https://github.com/CoCreate-app/CoCreate-element-prototype/compare/v1.31.3...v1.31.4) (2026-03-01)
|
|
2
24
|
|
|
3
25
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/element-prototype",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.33.0",
|
|
4
4
|
"description": "A simple element-prototype component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"element-prototype",
|
|
@@ -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,16 +35,14 @@
|
|
|
36
35
|
"url": "https://github.com/sponsors/CoCreate-app"
|
|
37
36
|
},
|
|
38
37
|
"main": "./src/index.js",
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@cocreate/utils": "^1.42.2"
|
|
40
|
+
},
|
|
39
41
|
"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"
|
|
42
|
+
"@cocreate/webpack": "^1.4.3"
|
|
47
43
|
},
|
|
48
|
-
"
|
|
49
|
-
"@cocreate/utils
|
|
44
|
+
"allowScripts": {
|
|
45
|
+
"@cocreate/utils@1.42.2": true,
|
|
46
|
+
"@cocreate/webpack@1.4.3": true
|
|
50
47
|
}
|
|
51
48
|
}
|
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/getValue.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { processOperators } from "@cocreate/utils";
|
|
1
|
+
import { processOperators } from "@cocreate/utils";
|
|
2
2
|
|
|
3
3
|
const storage = new Map();
|
|
4
4
|
|
|
@@ -6,6 +6,10 @@ HTMLElement.prototype.getValue = function () {
|
|
|
6
6
|
let value = getValue(this);
|
|
7
7
|
return value;
|
|
8
8
|
};
|
|
9
|
+
SVGElement.prototype.getValue = function () {
|
|
10
|
+
let value = getValue(this);
|
|
11
|
+
return value;
|
|
12
|
+
};
|
|
9
13
|
|
|
10
14
|
// TODO: return blobs for element.src and for link.href (Not addressed)
|
|
11
15
|
|
|
@@ -206,7 +210,8 @@ const handleCheckbox = (element, prefix = "", suffix = "") => {
|
|
|
206
210
|
const handleDateTime = (element, value, valueType) => {
|
|
207
211
|
const inputType = (element.getAttribute("type") || element.type || "").toLowerCase();
|
|
208
212
|
let date;
|
|
209
|
-
|
|
213
|
+
|
|
214
|
+
if (value === "$now" || element.hasAttribute("now")) {
|
|
210
215
|
date = new Date();
|
|
211
216
|
} else if (value instanceof Date) {
|
|
212
217
|
// If it's already a date object, clone it to avoid mutating references
|
|
@@ -309,30 +314,15 @@ const handleDateTime = (element, value, valueType) => {
|
|
|
309
314
|
switch (valueType) {
|
|
310
315
|
case "getDayName":
|
|
311
316
|
const days = [
|
|
312
|
-
"Sunday",
|
|
313
|
-
"
|
|
314
|
-
"Tuesday",
|
|
315
|
-
"Wednesday",
|
|
316
|
-
"Thursday",
|
|
317
|
-
"Friday",
|
|
318
|
-
"Saturday",
|
|
317
|
+
"Sunday", "Monday", "Tuesday", "Wednesday",
|
|
318
|
+
"Thursday", "Friday", "Saturday",
|
|
319
319
|
];
|
|
320
320
|
return days[date.getDay()];
|
|
321
321
|
|
|
322
322
|
case "getMonthName":
|
|
323
323
|
const months = [
|
|
324
|
-
"January",
|
|
325
|
-
"
|
|
326
|
-
"March",
|
|
327
|
-
"April",
|
|
328
|
-
"May",
|
|
329
|
-
"June",
|
|
330
|
-
"July",
|
|
331
|
-
"August",
|
|
332
|
-
"September",
|
|
333
|
-
"October",
|
|
334
|
-
"November",
|
|
335
|
-
"December",
|
|
324
|
+
"January", "February", "March", "April", "May", "June",
|
|
325
|
+
"July", "August", "September", "October", "November", "December",
|
|
336
326
|
];
|
|
337
327
|
return months[date.getMonth()];
|
|
338
328
|
|
|
@@ -347,6 +337,41 @@ const handleDateTime = (element, value, valueType) => {
|
|
|
347
337
|
hours = hours % 12 || 12; // Convert 0 to 12 for midnight
|
|
348
338
|
return `${hours}:${minutes} ${ampm}`;
|
|
349
339
|
|
|
340
|
+
case "timeTo": {
|
|
341
|
+
const diffMs = date.getTime() - Date.now();
|
|
342
|
+
let totalSeconds = Math.floor(Math.abs(diffMs) / 1000);
|
|
343
|
+
|
|
344
|
+
// Fetch requested units, defaulting to all if attribute isn't present
|
|
345
|
+
const unitsAttr = element.getAttribute("time-to-units") || "years,months,days,hours,minutes,seconds";
|
|
346
|
+
const requestedUnits = unitsAttr.split(',').map(u => u.trim().toLowerCase());
|
|
347
|
+
|
|
348
|
+
const result = {};
|
|
349
|
+
|
|
350
|
+
// Using the exact same time approximations as your timeAgo feature
|
|
351
|
+
const unitValues = {
|
|
352
|
+
years: 31536000,
|
|
353
|
+
months: 2592000,
|
|
354
|
+
weeks: 604800,
|
|
355
|
+
days: 86400,
|
|
356
|
+
hours: 3600,
|
|
357
|
+
minutes: 60,
|
|
358
|
+
seconds: 1
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
// The order matters here (largest to smallest) so we "consume" time properly
|
|
362
|
+
const order = ["years", "months", "weeks", "days", "hours", "minutes", "seconds"];
|
|
363
|
+
|
|
364
|
+
for (const unit of order) {
|
|
365
|
+
if (requestedUnits.includes(unit)) {
|
|
366
|
+
const val = Math.floor(totalSeconds / unitValues[unit]);
|
|
367
|
+
result[unit] = val;
|
|
368
|
+
totalSeconds -= val * unitValues[unit]; // subtract the accounted time
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
return result;
|
|
373
|
+
}
|
|
374
|
+
|
|
350
375
|
case "timeAgo": {
|
|
351
376
|
const diffMs = Date.now() - date.getTime();
|
|
352
377
|
const absSecs = Math.floor(Math.abs(diffMs) / 1000);
|
|
@@ -419,7 +444,6 @@ const handleDateTime = (element, value, valueType) => {
|
|
|
419
444
|
}
|
|
420
445
|
}
|
|
421
446
|
};
|
|
422
|
-
|
|
423
447
|
/**
|
|
424
448
|
* Processes a <select> HTML element with the "multiple" attribute to retrieve an array of selected option values.
|
|
425
449
|
* Each selected value can have a prefix or suffix added to it if specified.
|
package/src/index.js
CHANGED
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
// you must obtain a commercial license from CoCreate LLC.
|
|
21
21
|
// For details, visit <https://cocreate.app/licenses/> or contact us at sales@cocreate.app.
|
|
22
22
|
|
|
23
|
-
import { getAttribute } from "./getAttribute";
|
|
24
|
-
import { setValue } from "./setValue";
|
|
25
|
-
import { getValue } from "./getValue";
|
|
26
|
-
import { queryElements } from "./queryElements";
|
|
23
|
+
import { getAttribute } from "./getAttribute.js";
|
|
24
|
+
import { setValue } from "./setValue.js";
|
|
25
|
+
import { getValue } from "./getValue.js";
|
|
26
|
+
import { queryElements } from "./queryElements.js";
|
|
27
27
|
|
|
28
28
|
export default {
|
|
29
29
|
getAttribute,
|
package/src/setValue.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { storage } from "./getValue";
|
|
1
|
+
import { storage } from "./getValue.js";
|
|
2
2
|
|
|
3
3
|
HTMLElement.prototype.setValue = function (value, dispatch) {
|
|
4
4
|
setValue(this, value, dispatch);
|
|
5
5
|
};
|
|
6
|
+
SVGElement.prototype.setValue = function (value, dispatch) {
|
|
7
|
+
setValue(this, value, dispatch);
|
|
8
|
+
};
|
|
6
9
|
|
|
7
10
|
// TODO: check if using a a switch case will provide better performance
|
|
8
11
|
const setValue = (el, value, dispatch) => {
|