@almadar/skills 2.0.4 → 2.0.5
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/dist/index.js +56 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -419,6 +419,62 @@ Every pattern object in render-ui MUST include a \`"type"\` field. This applies
|
|
|
419
419
|
// CORRECT:
|
|
420
420
|
{ "type": "stack", "children": [{ "type": "typography", "text": "Hello" }] }
|
|
421
421
|
\`\`\`
|
|
422
|
+
|
|
423
|
+
### 9. Form Actions on Non-Form Patterns (CIRCUIT_ACTION_COMPONENT_MISMATCH)
|
|
424
|
+
|
|
425
|
+
**CANCEL, SAVE, SUBMIT, RESET are FORM actions.** They are ONLY valid in states that render form patterns (\`form-section\`, \`form\`).
|
|
426
|
+
|
|
427
|
+
Delete confirmation dialogs use \`alert\` or \`confirmation\` patterns, NOT \`form-section\`. So they must NOT use \`CANCEL\` as an action event.
|
|
428
|
+
|
|
429
|
+
\`\`\`json
|
|
430
|
+
// WRONG - CANCEL is a form action, but alert is NOT a form pattern:
|
|
431
|
+
{ "from": "Browsing", "to": "Deleting", "event": "DELETE",
|
|
432
|
+
"effects": [["render-ui", "modal", {
|
|
433
|
+
"type": "alert", "variant": "danger", "title": "Delete?",
|
|
434
|
+
"actions": [
|
|
435
|
+
{ "label": "Cancel", "event": "CANCEL" },
|
|
436
|
+
{ "label": "Delete", "event": "CONFIRM_DELETE" }
|
|
437
|
+
]
|
|
438
|
+
}]] }
|
|
439
|
+
|
|
440
|
+
// CORRECT - use CLOSE (not CANCEL) to dismiss non-form modals:
|
|
441
|
+
{ "from": "Browsing", "to": "Deleting", "event": "DELETE",
|
|
442
|
+
"effects": [["render-ui", "modal", {
|
|
443
|
+
"type": "alert", "variant": "danger", "title": "Delete?",
|
|
444
|
+
"actions": [
|
|
445
|
+
{ "label": "Cancel", "event": "CLOSE" },
|
|
446
|
+
{ "label": "Delete", "event": "CONFIRM_DELETE" }
|
|
447
|
+
]
|
|
448
|
+
}]] }
|
|
449
|
+
\`\`\`
|
|
450
|
+
|
|
451
|
+
**Rule:** In non-form modal states (alert, confirmation, detail-panel), use \`CLOSE\` to dismiss. Reserve \`CANCEL\` for \`form-section\` states only.
|
|
452
|
+
|
|
453
|
+
### 10. Dead Handler: Action Fires Event With No Transition From Current State (CIRCUIT_DEAD_HANDLER)
|
|
454
|
+
|
|
455
|
+
If a render-ui pattern in state X has an action that fires event E, there MUST be a transition \`from: X, event: E\`. A transition handling E from a DIFFERENT state does not count.
|
|
456
|
+
|
|
457
|
+
\`\`\`json
|
|
458
|
+
// WRONG - detail-panel in "Viewing" has Edit action firing EDIT,
|
|
459
|
+
// but only Browsing handles EDIT:
|
|
460
|
+
{ "from": "Browsing", "to": "Viewing", "event": "VIEW",
|
|
461
|
+
"effects": [["render-ui", "drawer", {
|
|
462
|
+
"type": "detail-panel", "entity": "Todo",
|
|
463
|
+
"actions": [{ "label": "Edit", "event": "EDIT" }]
|
|
464
|
+
}]] }
|
|
465
|
+
{ "from": "Browsing", "to": "Editing", "event": "EDIT", ... }
|
|
466
|
+
// No transition from: "Viewing", event: "EDIT" -> CIRCUIT_DEAD_HANDLER!
|
|
467
|
+
|
|
468
|
+
// CORRECT - add transition from Viewing state:
|
|
469
|
+
{ "from": "Viewing", "to": "Editing", "event": "EDIT",
|
|
470
|
+
"effects": [
|
|
471
|
+
["render-ui", "drawer", null],
|
|
472
|
+
["fetch", "Todo", "@payload.id"],
|
|
473
|
+
["render-ui", "modal", { "type": "form-section", "entity": "Todo", "submitEvent": "SAVE", "cancelEvent": "CANCEL" }]
|
|
474
|
+
] }
|
|
475
|
+
\`\`\`
|
|
476
|
+
|
|
477
|
+
**Rule:** For every action \`{ "event": "X" }\` in a render-ui effect of state S, verify there is a transition \`from: S, event: X\`.
|
|
422
478
|
`;
|
|
423
479
|
}
|
|
424
480
|
function getEdgeCaseErrors() {
|