create-kerf-component 5.0.0-beta.50 → 5.0.0-beta.52
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/README.md +7 -0
- package/catalog.js +26 -0
- package/component-catalog-v2.schema.json +33 -1
- package/component-metadata.schema.json +33 -1
- package/package.json +1 -1
- package/template/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,6 +47,13 @@ A ready-to-publish component package that encodes the rules from the kerf docs
|
|
|
47
47
|
string/template/regular-expression literals cannot masquerade as public
|
|
48
48
|
exports. The scaffold already declares TypeScript; run `npm install` before
|
|
49
49
|
invoking its copied local checker in a fresh offline directory.
|
|
50
|
+
A component whose wiring helper writes runtime `data-*` state onto its DOM
|
|
51
|
+
can declare it under `composition.wiring.stateAttributes` — each item is
|
|
52
|
+
`{ name, on, helper, meaning }`, where `name` is a `data-*` name, `on` is the
|
|
53
|
+
element that carries it, and `helper` is one of `wiring.helpers`. Apps must
|
|
54
|
+
not render, remove, or treat those attributes as their own state. The field
|
|
55
|
+
is optional; names must be unique per component, and the checker rejects a
|
|
56
|
+
helper that is not listed in `wiring.helpers`.
|
|
50
57
|
|
|
51
58
|
## Layout produced
|
|
52
59
|
|
package/catalog.js
CHANGED
|
@@ -400,6 +400,32 @@ function validateComposition(component, at, diagnostics) {
|
|
|
400
400
|
`${at}.composition.wiring.obligations`,
|
|
401
401
|
diagnostics,
|
|
402
402
|
);
|
|
403
|
+
const stateAttributes = composition.wiring?.stateAttributes;
|
|
404
|
+
if (stateAttributes !== undefined && !Array.isArray(stateAttributes))
|
|
405
|
+
diagnostics.push(
|
|
406
|
+
`${at}.composition.wiring.stateAttributes: expected an array`,
|
|
407
|
+
);
|
|
408
|
+
const stateAttributeNames = new Set();
|
|
409
|
+
for (const attribute of Array.isArray(stateAttributes)
|
|
410
|
+
? stateAttributes
|
|
411
|
+
: []) {
|
|
412
|
+
const name = attribute?.name;
|
|
413
|
+
const attributeAt = `${at}.composition.wiring.stateAttributes.${name}`;
|
|
414
|
+
if (typeof name !== 'string' || !/^data-[a-z0-9]+(-[a-z0-9]+)*$/.test(name))
|
|
415
|
+
diagnostics.push(`${attributeAt}.name: expected a data-* attribute name`);
|
|
416
|
+
if (stateAttributeNames.has(name))
|
|
417
|
+
diagnostics.push(`${attributeAt}.name: declared more than once`);
|
|
418
|
+
stateAttributeNames.add(name);
|
|
419
|
+
for (const field of ['on', 'meaning'])
|
|
420
|
+
if (typeof attribute?.[field] !== 'string' || !attribute[field])
|
|
421
|
+
diagnostics.push(
|
|
422
|
+
`${attributeAt}.${field}: expected a non-empty string`,
|
|
423
|
+
);
|
|
424
|
+
if (!composition.wiring.helpers?.includes(attribute?.helper))
|
|
425
|
+
diagnostics.push(
|
|
426
|
+
`${attributeAt}.helper: ${attribute?.helper} is not listed in composition.wiring.helpers`,
|
|
427
|
+
);
|
|
428
|
+
}
|
|
403
429
|
if (
|
|
404
430
|
!['application', 'component', 'shared', 'not-applicable'].includes(
|
|
405
431
|
composition.responsive?.owner,
|
|
@@ -21,6 +21,33 @@
|
|
|
21
21
|
},
|
|
22
22
|
"additionalProperties": false,
|
|
23
23
|
"$defs": {
|
|
24
|
+
"stateAttribute": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"required": ["name", "on", "helper", "meaning"],
|
|
27
|
+
"properties": {
|
|
28
|
+
"name": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"minLength": 1,
|
|
31
|
+
"pattern": "^data-[a-z0-9]+(-[a-z0-9]+)*$"
|
|
32
|
+
},
|
|
33
|
+
"on": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"minLength": 1,
|
|
36
|
+
"description": "The element that carries it: a public class, or the element passed to the helper."
|
|
37
|
+
},
|
|
38
|
+
"helper": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"minLength": 1,
|
|
41
|
+
"description": "The helper, one of wiring.helpers, that writes it."
|
|
42
|
+
},
|
|
43
|
+
"meaning": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"minLength": 1,
|
|
46
|
+
"description": "What its presence or value means."
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"additionalProperties": false
|
|
50
|
+
},
|
|
24
51
|
"stringList": {
|
|
25
52
|
"type": "array",
|
|
26
53
|
"items": { "type": "string", "minLength": 1 },
|
|
@@ -152,7 +179,12 @@
|
|
|
152
179
|
"properties": {
|
|
153
180
|
"required": { "type": "boolean" },
|
|
154
181
|
"helpers": { "$ref": "#/$defs/stringList" },
|
|
155
|
-
"obligations": { "$ref": "#/$defs/stringList" }
|
|
182
|
+
"obligations": { "$ref": "#/$defs/stringList" },
|
|
183
|
+
"stateAttributes": {
|
|
184
|
+
"description": "Wiring-owned state attributes: data-* attributes a wiring helper writes at runtime, which the application must not render, remove, or treat as its own state. Optional for extension catalogs; first-party entries always list it, empty when their helpers write none.",
|
|
185
|
+
"type": "array",
|
|
186
|
+
"items": { "$ref": "#/$defs/stateAttribute" }
|
|
187
|
+
}
|
|
156
188
|
},
|
|
157
189
|
"additionalProperties": false
|
|
158
190
|
},
|
|
@@ -15,6 +15,33 @@
|
|
|
15
15
|
},
|
|
16
16
|
"additionalProperties": false,
|
|
17
17
|
"$defs": {
|
|
18
|
+
"stateAttribute": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"required": ["name", "on", "helper", "meaning"],
|
|
21
|
+
"properties": {
|
|
22
|
+
"name": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"minLength": 1,
|
|
25
|
+
"pattern": "^data-[a-z0-9]+(-[a-z0-9]+)*$"
|
|
26
|
+
},
|
|
27
|
+
"on": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"minLength": 1,
|
|
30
|
+
"description": "The element that carries it: a public class, or the element passed to the helper."
|
|
31
|
+
},
|
|
32
|
+
"helper": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"minLength": 1,
|
|
35
|
+
"description": "The helper, one of wiring.helpers, that writes it."
|
|
36
|
+
},
|
|
37
|
+
"meaning": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"minLength": 1,
|
|
40
|
+
"description": "What its presence or value means."
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"additionalProperties": false
|
|
44
|
+
},
|
|
18
45
|
"stringList": {
|
|
19
46
|
"type": "array",
|
|
20
47
|
"items": { "type": "string", "minLength": 1 },
|
|
@@ -185,7 +212,12 @@
|
|
|
185
212
|
"properties": {
|
|
186
213
|
"required": { "type": "boolean" },
|
|
187
214
|
"helpers": { "$ref": "#/$defs/stringList" },
|
|
188
|
-
"obligations": { "$ref": "#/$defs/stringList" }
|
|
215
|
+
"obligations": { "$ref": "#/$defs/stringList" },
|
|
216
|
+
"stateAttributes": {
|
|
217
|
+
"description": "Optional wiring-owned state attributes: data-* attributes a wiring helper writes at runtime, which the application must not render, remove, or treat as its own state.",
|
|
218
|
+
"type": "array",
|
|
219
|
+
"items": { "$ref": "#/$defs/stateAttribute" }
|
|
220
|
+
}
|
|
189
221
|
},
|
|
190
222
|
"additionalProperties": false
|
|
191
223
|
},
|
package/package.json
CHANGED