@cocreate/element-prototype 1.35.0 → 1.38.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/CONTRIBUTING.md +1 -1
- package/README.md +58 -0
- package/package.json +4 -4
- package/src/getValue.js +305 -550
- package/src/setValue.js +283 -252
- package/test/password-value.test.cjs +48 -0
- package/test/value-handler.test.cjs +275 -0
package/CONTRIBUTING.md
CHANGED
|
@@ -13,7 +13,7 @@ Fork the [project on Github](https://github.com/CoCreate-app/CoCreate-element-pr
|
|
|
13
13
|
```
|
|
14
14
|
git clone https://github.com/contributor/CoCreate-element-prototype.git
|
|
15
15
|
cd CoCreate-element-prototype
|
|
16
|
-
git remote add upstream https://
|
|
16
|
+
git remote add upstream https://gitlab.com/cocreatejs/CoCreate-element-prototype.git
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Create a Topic Branch
|
package/README.md
CHANGED
|
@@ -15,6 +15,44 @@ A simple element-prototype component in vanilla javascript. Easily configured us
|
|
|
15
15
|
|
|
16
16
|
For a complete guide and working demo refer to the [doumentation](https://cocreate.app/docs/element-prototype)
|
|
17
17
|
|
|
18
|
+
## Value transformations
|
|
19
|
+
|
|
20
|
+
Value transformations accept three attribute namespaces:
|
|
21
|
+
|
|
22
|
+
- `value-*` applies to both reads and writes.
|
|
23
|
+
- `get-value-*` applies to `getValue()` and `getValueAsync()`.
|
|
24
|
+
- `set-value-*` applies to `setValue()`.
|
|
25
|
+
|
|
26
|
+
Each direction-specific attribute overrides its corresponding shared attribute,
|
|
27
|
+
regardless of attribute order. Other options still fall back independently.
|
|
28
|
+
For example, `value-uppercase` with `set-value-uppercase="false"` uppercases
|
|
29
|
+
only reads. An empty scoped regex/encoding attribute disables that operation;
|
|
30
|
+
`"false"` also disables case, regex, and encoding/decoding transformations.
|
|
31
|
+
An empty case attribute enables case conversion.
|
|
32
|
+
|
|
33
|
+
Supported transformation suffixes include `lowercase`, `uppercase`, `replace`,
|
|
34
|
+
`replaceall`, `replacement`, `test`, `match`, `split`, `lastindex`, `search`,
|
|
35
|
+
`exec`, `encode`, and `decode`. The `type` suffix supports `boolean`, `object`,
|
|
36
|
+
`json`, `array`, `array.$keys`, `array.$values`, and `array.$entries`, as well as
|
|
37
|
+
existing element read/render types. `prefix` and `suffix` also honor scoped
|
|
38
|
+
overrides, retaining their existing add-on-read and strip-on-write behavior.
|
|
39
|
+
|
|
40
|
+
Setter transformations run in this order: case, regex operations (in effective
|
|
41
|
+
attribute order), encoding, decoding, and type conversion. They run before
|
|
42
|
+
component storage or element rendering. Components retain structured values;
|
|
43
|
+
textareas serialize objects and arrays as JSON.
|
|
44
|
+
|
|
45
|
+
```html
|
|
46
|
+
<textarea value-uppercase></textarea>
|
|
47
|
+
<textarea get-value-encode="base64" set-value-decode="base64"></textarea>
|
|
48
|
+
<div component set-value-type="object"></div>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Calling `setValue('{"enabled":true}')` on the component above stores an object;
|
|
52
|
+
its `getValue()` returns that object. Use scoped attributes for transformations
|
|
53
|
+
that should happen only once: unscoped replacements or encoding can run again
|
|
54
|
+
when reading a value that was previously written.
|
|
55
|
+
|
|
18
56
|
## CDN
|
|
19
57
|
|
|
20
58
|
```html
|
|
@@ -89,3 +127,23 @@ This software is dual-licensed under the GNU Affero General Public License versi
|
|
|
89
127
|
- **Commercial Use**: For-profit companies and individuals intending to use this software for commercial purposes must obtain a commercial license. The commercial license is available when you sign up for an API key on our [website](https://cocreate.app). This license permits proprietary use and modification of the software without the copyleft requirements of the AGPLv3. It is ideal for integrating this software into proprietary commercial products and applications.
|
|
90
128
|
|
|
91
129
|
If you have not purchased a commercial license and intend to use this software for commercial purposes, you are required to sign up for an API key on our website.
|
|
130
|
+
|
|
131
|
+
### Values on select options
|
|
132
|
+
|
|
133
|
+
Select getters process each selected option through the corresponding synchronous
|
|
134
|
+
or asynchronous value getter before applying the select's own transformations.
|
|
135
|
+
A single select returns one processed value; `multiple` returns an array.
|
|
136
|
+
|
|
137
|
+
```html
|
|
138
|
+
<select>
|
|
139
|
+
<option value="">Any state</option>
|
|
140
|
+
<option value="true" value-type="boolean">Enabled</option>
|
|
141
|
+
<option value="false" value-type="boolean">Disabled</option>
|
|
142
|
+
</select>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Here the values are `""`, `true`, and `false`. Types and transformations declared
|
|
146
|
+
on options affect only those options. Existing select-level types still apply
|
|
147
|
+
to the collected result; select-level prefixes and suffixes still apply to each
|
|
148
|
+
value in a multiple select. With no selected option, the result is `""` for a
|
|
149
|
+
single select or `[]` for a multiple select, before select-level transformations.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/element-prototype",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.38.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",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
|
-
"url": "git+https://
|
|
25
|
+
"url": "git+https://gitlab.com/cocreatejs/CoCreate-element-prototype.git"
|
|
26
26
|
},
|
|
27
27
|
"author": "CoCreate LLC",
|
|
28
28
|
"license": "AGPL-3.0",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
},
|
|
37
37
|
"main": "./src/index.js",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@cocreate/utils": "^1.
|
|
39
|
+
"@cocreate/utils": "^1.54.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@cocreate/webpack": "^1.
|
|
42
|
+
"@cocreate/webpack": "^1.9.0"
|
|
43
43
|
},
|
|
44
44
|
"allowScripts": {
|
|
45
45
|
"@cocreate/utils@1.42.2": true,
|