@cloudlet/toast 1.0.0 → 1.1.1

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +57 -12
  2. package/README.md +20 -6
  3. package/dist/contracts/controller.d.ts +7 -2
  4. package/dist/contracts/controller.d.ts.map +1 -1
  5. package/dist/contracts/internal.d.ts +23 -0
  6. package/dist/contracts/internal.d.ts.map +1 -1
  7. package/dist/contracts/notifications.d.ts +38 -6
  8. package/dist/contracts/notifications.d.ts.map +1 -1
  9. package/dist/contracts/snapshots.d.ts +3 -1
  10. package/dist/contracts/snapshots.d.ts.map +1 -1
  11. package/dist/core/bridge.js +216 -148
  12. package/dist/core/bridge.js.map +1 -1
  13. package/dist/core/controller.d.ts +11 -2
  14. package/dist/core/controller.d.ts.map +1 -1
  15. package/dist/core/controller.js +310 -284
  16. package/dist/core/controller.js.map +1 -1
  17. package/dist/core/validation.d.ts.map +1 -1
  18. package/dist/core/validation.js +181 -89
  19. package/dist/core/validation.js.map +1 -1
  20. package/dist/react/card.d.ts +4 -2
  21. package/dist/react/card.d.ts.map +1 -1
  22. package/dist/react/card.js +146 -34
  23. package/dist/react/card.js.map +1 -1
  24. package/dist/react/host.d.ts.map +1 -1
  25. package/dist/react/host.js +8 -4
  26. package/dist/react/host.js.map +1 -1
  27. package/dist/react/plan.d.ts.map +1 -1
  28. package/dist/react/plan.js +1 -0
  29. package/dist/react/plan.js.map +1 -1
  30. package/dist/react.d.ts +3 -1
  31. package/dist/react.d.ts.map +1 -1
  32. package/dist/styles.css +1 -1
  33. package/package.json +1 -1
  34. package/src/contracts/controller.ts +7 -2
  35. package/src/contracts/internal.ts +20 -0
  36. package/src/contracts/notifications.ts +45 -6
  37. package/src/contracts/snapshots.ts +3 -0
  38. package/src/core/bridge.ts +62 -6
  39. package/src/core/controller.ts +37 -5
  40. package/src/core/validation.ts +49 -4
  41. package/src/react/card.tsx +89 -6
  42. package/src/react/host.tsx +12 -3
  43. package/src/react/plan.ts +2 -1
  44. package/src/react.ts +3 -1
package/dist/styles.css CHANGED
@@ -1 +1 @@
1
- .cloudlet-host{--cloudlet-pill-height:44px;--cloudlet-pill-radius:9999px;--cloudlet-pill-max-width:22rem;--cloudlet-island-radius:24px;--cloudlet-island-max-width:26rem;--cloudlet-tail-offset:4px;--cloudlet-tail-scale:.9;--cloudlet-control-min-size:44px;--cloudlet-viewport-gutter:16px;--cloudlet-font-family:system-ui, sans-serif;--cloudlet-font-size:.875rem;--cloudlet-background:#fff;--cloudlet-foreground:#111113;--cloudlet-muted:#6e6e76;--cloudlet-border:color-mix(in oklab, var(--cloudlet-foreground) 10%, transparent);--cloudlet-action-background:color-mix(in oklab, var(--cloudlet-foreground) 8%, transparent);--cloudlet-shadow:0 10px 30px -12px #00000040, 0 1px 2px #00000014;--cloudlet-tail-background:var(--cloudlet-background);--cloudlet-tail-border:var(--cloudlet-border);--cloudlet-focus:#245cdb;--cloudlet-success:oklch(72.3% .219 142.136);--cloudlet-error:oklch(63.7% .237 25.331);--cloudlet-info:oklch(68.5% .169 237.323);--cloudlet-warning:oklch(79.5% .184 86.047);--cloudlet-loading:oklch(55.6% 0 0);--cloudlet-badge:#ff3b30;--cloudlet-badge-foreground:#fff;--cloudlet-z-index:1000;--cloudlet-safe-top:env(safe-area-inset-top,0px);--cloudlet-safe-right:env(safe-area-inset-right,0px);--cloudlet-safe-bottom:env(safe-area-inset-bottom,0px);--cloudlet-safe-left:env(safe-area-inset-left,0px);--cloudlet-top:calc(var(--cloudlet-safe-top) + var(--cloudlet-gutter-top,var(--cloudlet-viewport-gutter)) + var(--cloudlet-obstruction-top,0px));--cloudlet-bottom:calc(var(--cloudlet-safe-bottom) + var(--cloudlet-gutter-bottom,var(--cloudlet-viewport-gutter)) + var(--cloudlet-obstruction-bottom,0px));--cloudlet-left:calc(var(--cloudlet-safe-left) + var(--cloudlet-gutter-left,var(--cloudlet-viewport-gutter)) + var(--cloudlet-obstruction-left,0px));--cloudlet-right:calc(var(--cloudlet-safe-right) + var(--cloudlet-gutter-right,var(--cloudlet-viewport-gutter)) + var(--cloudlet-obstruction-right,0px));--cloudlet-host-height:max(0px, calc(var(--cloudlet-viewport-height,100dvh) - var(--cloudlet-top) - var(--cloudlet-bottom)));--cloudlet-available-height:max(0px, calc(var(--cloudlet-host-height) - var(--cloudlet-reserved-height,0px)));z-index:var(--cloudlet-z-index);left:calc(var(--cloudlet-viewport-left,0px) + var(--cloudlet-left));right:calc(var(--cloudlet-viewport-right,0px) + var(--cloudlet-right));bottom:calc(var(--cloudlet-viewport-bottom,0px) + var(--cloudlet-bottom));max-width:var(--cloudlet-island-max-width);max-height:var(--cloudlet-host-height);color:var(--cloudlet-foreground);font:400 var(--cloudlet-font-size)/1.43 var(--cloudlet-font-family);text-align:start;--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;pointer-events:none;isolation:isolate;--cloudlet-status:var(--cloudlet-loading);flex-direction:column;margin-inline:auto;display:flex;position:fixed}.cloudlet-host,.cloudlet-host *,.cloudlet-host :before,.cloudlet-host :after{box-sizing:border-box}.cloudlet-host :where(h2,p,ol,li){margin:0;padding:0}.cloudlet-host :where(button,a){font:inherit;color:inherit;line-height:inherit;letter-spacing:inherit;text-transform:none;min-width:var(--cloudlet-control-min-size);min-height:var(--cloudlet-control-min-size);touch-action:manipulation}.cloudlet-host button{appearance:none;cursor:pointer;background:0 0;border:0;border-radius:24px;justify-content:center;align-items:center;margin:0;padding:10px;display:inline-flex}.cloudlet-host button[aria-disabled=true]{color:var(--cloudlet-muted);cursor:progress}.cloudlet-host a{border-radius:24px;align-items:center;padding:10px 16px;text-decoration:underline;display:inline-flex}.cloudlet-host :focus-visible{outline:2px solid var(--cloudlet-focus);outline-offset:2px}.cloudlet-host:focus-visible{outline:2px solid var(--cloudlet-focus);outline-offset:-2px}.cloudlet-host [hidden]{display:none!important}.cloudlet-host [data-kind=success]{--cloudlet-status:var(--cloudlet-success)}.cloudlet-host [data-kind=error]{--cloudlet-status:var(--cloudlet-error)}.cloudlet-host [data-kind=info]{--cloudlet-status:var(--cloudlet-info)}.cloudlet-host [data-kind=warning]{--cloudlet-status:var(--cloudlet-warning)}.cloudlet-host [data-kind=loading]{--cloudlet-status:var(--cloudlet-loading)}.cloudlet-host .cloudlet-stack{flex:none;align-self:center;width:fit-content;max-width:100%;position:relative}.cloudlet-host[data-state=island] .cloudlet-stack{width:100%}.cloudlet-host .cloudlet-shell{transform-origin:50% 0;z-index:1;position:relative}.cloudlet-host[data-edge=bottom] .cloudlet-shell{transform-origin:50% 100%}.cloudlet-host .cloudlet-bg{pointer-events:none;box-shadow:var(--cloudlet-shadow);position:absolute;top:0;left:50%;overflow:visible;transform:translate(-50%)}.cloudlet-host .cloudlet-bg path{fill:var(--cloudlet-background);stroke:var(--cloudlet-border);stroke-width:1px}.cloudlet-host :is(.cloudlet-tail,.cloudlet-exit){pointer-events:none;position:absolute;top:0;left:50%}.cloudlet-host .cloudlet-tail{z-index:0;border-radius:var(--cloudlet-pill-radius);background:var(--cloudlet-tail-background);border:1px solid var(--cloudlet-tail-border);box-shadow:var(--cloudlet-shadow);transform-origin:50% 100%;opacity:0}.cloudlet-host .cloudlet-tail[data-cloudlet-tail="2"]{z-index:-1;background:color-mix(in oklab, var(--cloudlet-tail-background) 60%, var(--cloudlet-background))}.cloudlet-host .cloudlet-exit{z-index:2;transform-origin:50% 0}.cloudlet-host[data-edge=bottom] :is(.cloudlet-bg,.cloudlet-tail,.cloudlet-exit,.cloudlet-badge){top:auto;bottom:0}.cloudlet-host[data-edge=bottom] .cloudlet-tail{transform-origin:50% 0}.cloudlet-host[data-edge=bottom] .cloudlet-exit{transform-origin:50% 100%}.cloudlet-host .cloudlet-exit:empty{display:none}.cloudlet-host .cloudlet-clip{pointer-events:auto;color:var(--cloudlet-foreground);overflow-wrap:anywhere;width:fit-content;min-width:0;max-width:min(100%, var(--cloudlet-pill-max-width));min-height:var(--cloudlet-pill-height);border-radius:var(--cloudlet-pill-radius);flex-direction:column;display:flex;position:relative}.cloudlet-host .cloudlet-shell[data-state=island]>.cloudlet-clip{width:100%;max-width:100%;max-height:var(--cloudlet-available-height);border-radius:var(--cloudlet-island-radius)}.cloudlet-host :is(.cloudlet-slide-out,.cloudlet-chrome-out){pointer-events:none;position:absolute;top:0;left:0}.cloudlet-host :is(.cloudlet-slide-out,.cloudlet-chrome-out):empty{display:none}.cloudlet-host .cloudlet-chrome-out .cloudlet-clip{width:100%;max-width:none}.cloudlet-host .cloudlet-ghost{visibility:hidden}.cloudlet-host .cloudlet-slide{flex-direction:column;flex:0 auto;min-height:0;display:flex;position:relative}.cloudlet-host .cloudlet-header{flex:none;min-width:0;display:flex;position:relative}.cloudlet-host .cloudlet-heading{min-width:0;min-height:var(--cloudlet-pill-height);flex:1;align-items:center;gap:10px;padding-block:6px;padding-inline:10px 16px;display:flex}.cloudlet-host .cloudlet-shell[data-state=island] .cloudlet-heading{padding-block:10px 6px;padding-inline:14px 52px}.cloudlet-host .cloudlet-heading-out{pointer-events:none;display:flex;position:absolute;inset:0}.cloudlet-host .cloudlet-heading-out:empty{display:none}.cloudlet-host .cloudlet-title{font:inherit;text-transform:none;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;font-weight:500;overflow:hidden}.cloudlet-host .cloudlet-shell[data-state=island] .cloudlet-title{white-space:normal;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box}.cloudlet-host .cloudlet-title:focus{outline:none}.cloudlet-host .cloudlet-title:focus-visible{outline:2px solid var(--cloudlet-focus);outline-offset:2px;border-radius:4px}.cloudlet-host .cloudlet-pill{z-index:1;pointer-events:auto;border-radius:var(--cloudlet-pill-radius);width:100%;height:100%;padding:0;position:absolute;inset:0}.cloudlet-host .cloudlet-pill,.cloudlet-host .cloudlet-shell[data-state=island]>.cloudlet-clip,.cloudlet-host .cloudlet-shell[data-state=island] .cloudlet-body{touch-action:pan-y}.cloudlet-host .cloudlet-shell[data-state=island]>.cloudlet-clip>.cloudlet-slide>.cloudlet-header{touch-action:none}.cloudlet-host[data-dragging]{-webkit-user-select:none;user-select:none}.cloudlet-host .cloudlet-peek{pointer-events:none;position:absolute;top:0;left:0}.cloudlet-host .cloudlet-badge{z-index:2;background:var(--cloudlet-badge);min-width:20px;height:20px;color:var(--cloudlet-badge-foreground);box-shadow:0 0 0 2px var(--cloudlet-background);font:600 .6875rem/20px var(--cloudlet-font-family);font-variant-numeric:tabular-nums;text-align:center;pointer-events:none;opacity:0;border-radius:9999px;padding-inline:6px;display:grid;position:absolute;top:0;left:50%}.cloudlet-host .cloudlet-badge>*{grid-area:1/1}.cloudlet-host .cloudlet-icon{width:24px;height:24px;color:var(--cloudlet-status);background:color-mix(in oklab, var(--cloudlet-status) 18%, transparent);border-radius:50%;flex:none;place-items:center;display:grid;position:relative}.cloudlet-host .cloudlet-glyph{place-items:center;width:16px;height:16px;display:grid;overflow:hidden}.cloudlet-host .cloudlet-glyph>.cloudlet-slot{place-items:center;width:100%;height:100%;display:grid}.cloudlet-host .cloudlet-glyph :is(svg,img){max-width:100%;max-height:100%;display:block}.cloudlet-host :is(svg.cloudlet-glyph,button>svg){fill:none;stroke:currentColor;stroke-width:1.75px;stroke-linecap:round;stroke-linejoin:round;display:block}.cloudlet-host .cloudlet-ring{fill:none;stroke-width:2px;width:32px;height:32px;position:absolute;inset:-4px;overflow:visible}.cloudlet-host .cloudlet-ring-track{stroke:color-mix(in oklab, var(--cloudlet-status) 18%, transparent)}.cloudlet-host .cloudlet-progress-fill{stroke:color-mix(in oklab, var(--cloudlet-status) 75%, var(--cloudlet-foreground));stroke-linecap:round}.cloudlet-host .cloudlet-close{top:8px;z-index:1;width:32px;min-width:0;height:32px;min-height:0;color:var(--cloudlet-muted);background:var(--cloudlet-action-background);border-radius:50%;padding:0;position:absolute;inset-inline-end:8px}.cloudlet-host .cloudlet-close>svg{width:16px;height:16px}.cloudlet-host :is(.cloudlet-close,.cloudlet-action,.cloudlet-overflow button):before{content:"";inset-block:calc((var(--cloudlet-control-min-size) - 32px) / -2);position:absolute;inset-inline:0}.cloudlet-host button.cloudlet-close:before{inset-inline:calc((var(--cloudlet-control-min-size) - 32px) / -2);border-radius:50%}.cloudlet-host .cloudlet-body{overscroll-behavior:contain;min-height:0;max-height:min(calc(var(--cloudlet-available-height) * .6), 24rem);flex-direction:column;padding-block:0 10px;padding-inline:48px 16px;display:flex;position:relative;overflow:auto}.cloudlet-host .cloudlet-body:not(:has(>:not(.cloudlet-actions:empty))){padding-bottom:4px}.cloudlet-host .cloudlet-body-out{pointer-events:none;position:absolute;left:0;right:0}.cloudlet-host .cloudlet-body-out:empty{display:none}.cloudlet-host .cloudlet-description{color:var(--cloudlet-muted);padding-block:0 4px;font-size:.8125rem;line-height:1.45}.cloudlet-host .cloudlet-actions{flex-wrap:wrap;flex:none;gap:12px 8px;display:flex}.cloudlet-host .cloudlet-actions:empty{display:none}.cloudlet-host .cloudlet-actions:not(:empty){margin-block:8px 2px}.cloudlet-host :is(.cloudlet-action,.cloudlet-overflow button){overflow-wrap:anywhere;min-width:0;max-width:100%;min-height:32px;color:var(--cloudlet-foreground);background:var(--cloudlet-action-background);border-radius:9999px;padding:6px 14px;font-size:.8125rem;font-weight:500;line-height:1.5;text-decoration:none;position:relative}.cloudlet-host .cloudlet-action.cloudlet-primary{color:color-mix(in oklab, var(--cloudlet-status) 55%, var(--cloudlet-foreground));background:color-mix(in oklab, var(--cloudlet-status) 12%, transparent)}.cloudlet-host :is(.cloudlet-action,.cloudlet-overflow button)[aria-disabled=true]{color:var(--cloudlet-muted)}@media (hover:hover){.cloudlet-host :is(.cloudlet-close,.cloudlet-action,.cloudlet-overflow button):hover{background:color-mix(in oklab, var(--cloudlet-foreground) 13%, transparent)}.cloudlet-host .cloudlet-close:hover{color:var(--cloudlet-foreground)}.cloudlet-host .cloudlet-action.cloudlet-primary:hover{background:color-mix(in oklab, var(--cloudlet-status) 20%, transparent)}}.cloudlet-host .cloudlet-action-error{color:var(--cloudlet-muted);padding-block:4px;font-size:.8125rem}.cloudlet-host .cloudlet-indicator{color:var(--cloudlet-muted);flex-wrap:wrap;flex:none;justify-content:center;align-items:center;column-gap:8px;padding-bottom:6px;font-size:.75rem;display:flex}.cloudlet-host .cloudlet-indicator .cloudlet-dot-button{min-width:24px;min-height:24px;padding:8px}.cloudlet-host .cloudlet-dot{background:color-mix(in oklab, var(--cloudlet-foreground) 25%, transparent);border-radius:50%;width:6px;height:6px;display:block}.cloudlet-host .cloudlet-indicator [aria-current=true] .cloudlet-dot{background:var(--cloudlet-foreground)}.cloudlet-host .cloudlet-page{font-variant-numeric:tabular-nums;padding:8px;display:grid}.cloudlet-host .cloudlet-page>*{grid-area:1/1}.cloudlet-host .cloudlet-overflow{flex-wrap:wrap;justify-content:center;align-items:center;gap:4px 8px;min-width:0;display:flex}.cloudlet-host .cloudlet-overflow button{font-size:.75rem}.cloudlet-host .cloudlet-live{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.cloudlet-announcer{clip-path:inset(50%);white-space:nowrap;pointer-events:none;border:0;width:1px;height:1px;margin:-1px;padding:0;position:fixed;top:0;left:0;overflow:hidden}.cloudlet-host[data-position=top-center]{top:calc(var(--cloudlet-viewport-top,0px) + var(--cloudlet-top));bottom:auto}@media (width>=48rem){.cloudlet-host[data-position=auto]{top:calc(var(--cloudlet-viewport-top,0px) + var(--cloudlet-top));bottom:auto}}.cloudlet-host[data-theme=dark]{--cloudlet-background:#1c1c1e;--cloudlet-foreground:#f5f5f7;--cloudlet-muted:#a1a1aa;--cloudlet-focus:#93b4ff;--cloudlet-shadow:0 12px 32px -12px #0009;--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--cloudlet-tail-background:color-mix(in oklab, var(--cloudlet-foreground) 14%, var(--cloudlet-background));--cloudlet-tail-border:color-mix(in oklab, var(--cloudlet-foreground) 18%, transparent)}@media (prefers-color-scheme:dark){.cloudlet-host[data-theme=system]{--cloudlet-background:#1c1c1e;--cloudlet-foreground:#f5f5f7;--cloudlet-muted:#a1a1aa;--cloudlet-focus:#93b4ff;--cloudlet-shadow:0 12px 32px -12px #0009;--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--cloudlet-tail-background:color-mix(in oklab, var(--cloudlet-foreground) 14%, var(--cloudlet-background));--cloudlet-tail-border:color-mix(in oklab, var(--cloudlet-foreground) 18%, transparent)}}@keyframes cloudlet-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:no-preference){.cloudlet-host .cloudlet-spinner{animation:.8s linear infinite cloudlet-spin}.cloudlet-host .cloudlet-ring[data-progress=indeterminate]{animation:1s linear infinite cloudlet-spin}.cloudlet-host[data-reduced-motion=true] :is(.cloudlet-spinner,.cloudlet-ring){animation:none}}@media (forced-colors:active){.cloudlet-host[data-theme]{--cloudlet-background:Canvas;--cloudlet-foreground:CanvasText;--cloudlet-muted:CanvasText;--cloudlet-border:CanvasText;--cloudlet-focus:Highlight;--cloudlet-action-background:Canvas;--cloudlet-status:CanvasText;--cloudlet-success:CanvasText;--cloudlet-error:CanvasText;--cloudlet-info:CanvasText;--cloudlet-warning:CanvasText;--cloudlet-loading:CanvasText;--cloudlet-badge:Highlight;--cloudlet-badge-foreground:HighlightText}.cloudlet-host :is(.cloudlet-bg,.cloudlet-icon,.cloudlet-badge,.cloudlet-dot){forced-color-adjust:none}.cloudlet-host .cloudlet-icon{outline-offset:-1px;background:canvas;outline:1px solid canvastext}.cloudlet-host .cloudlet-ring-track{stroke:graytext}.cloudlet-host .cloudlet-dot{background:canvas;outline:1px solid canvastext}.cloudlet-host .cloudlet-indicator [aria-current=true] .cloudlet-dot{background:canvastext}.cloudlet-host :is(.cloudlet-close,.cloudlet-action,.cloudlet-overflow button){border:1px solid buttontext}}
1
+ .cloudlet-host{--cloudlet-pill-height:44px;--cloudlet-pill-radius:9999px;--cloudlet-pill-max-width:22rem;--cloudlet-island-radius:24px;--cloudlet-island-max-width:26rem;--cloudlet-tail-offset:4px;--cloudlet-tail-scale:.9;--cloudlet-control-min-size:44px;--cloudlet-viewport-gutter:16px;--cloudlet-font-family:system-ui, sans-serif;--cloudlet-font-size:.875rem;--cloudlet-background:#fff;--cloudlet-foreground:#111113;--cloudlet-muted:#6e6e76;--cloudlet-border:color-mix(in oklab, var(--cloudlet-foreground) 10%, transparent);--cloudlet-action-background:color-mix(in oklab, var(--cloudlet-foreground) 8%, transparent);--cloudlet-shadow:0 10px 30px -12px #00000040, 0 1px 2px #00000014;--cloudlet-tail-background:var(--cloudlet-background);--cloudlet-tail-border:var(--cloudlet-border);--cloudlet-focus:#245cdb;--cloudlet-success:oklch(72.3% .219 142.136);--cloudlet-error:oklch(63.7% .237 25.331);--cloudlet-info:oklch(68.5% .169 237.323);--cloudlet-warning:oklch(79.5% .184 86.047);--cloudlet-loading:oklch(55.6% 0 0);--cloudlet-badge:#d70015;--cloudlet-badge-foreground:#fff;--cloudlet-field-background:var(--cloudlet-action-background);--cloudlet-field-border:transparent;--cloudlet-placeholder:color-mix(in oklab, var(--cloudlet-muted) 85%, var(--cloudlet-foreground));--cloudlet-z-index:1000;--cloudlet-safe-top:env(safe-area-inset-top,0px);--cloudlet-safe-right:env(safe-area-inset-right,0px);--cloudlet-safe-bottom:env(safe-area-inset-bottom,0px);--cloudlet-safe-left:env(safe-area-inset-left,0px);--cloudlet-top:calc(var(--cloudlet-safe-top) + var(--cloudlet-gutter-top,var(--cloudlet-viewport-gutter)) + var(--cloudlet-obstruction-top,0px));--cloudlet-bottom:calc(var(--cloudlet-safe-bottom) + var(--cloudlet-gutter-bottom,var(--cloudlet-viewport-gutter)) + var(--cloudlet-obstruction-bottom,0px));--cloudlet-left:calc(var(--cloudlet-safe-left) + var(--cloudlet-gutter-left,var(--cloudlet-viewport-gutter)) + var(--cloudlet-obstruction-left,0px));--cloudlet-right:calc(var(--cloudlet-safe-right) + var(--cloudlet-gutter-right,var(--cloudlet-viewport-gutter)) + var(--cloudlet-obstruction-right,0px));--cloudlet-host-height:max(0px, calc(var(--cloudlet-viewport-height,100dvh) - var(--cloudlet-top) - var(--cloudlet-bottom)));--cloudlet-available-height:max(0px, calc(var(--cloudlet-host-height) - var(--cloudlet-reserved-height,0px)));z-index:var(--cloudlet-z-index);left:calc(var(--cloudlet-viewport-left,0px) + var(--cloudlet-left));right:calc(var(--cloudlet-viewport-right,0px) + var(--cloudlet-right));bottom:calc(var(--cloudlet-viewport-bottom,0px) + var(--cloudlet-bottom));max-width:var(--cloudlet-island-max-width);max-height:var(--cloudlet-host-height);color:var(--cloudlet-foreground);font:400 var(--cloudlet-font-size)/1.43 var(--cloudlet-font-family);text-align:start;--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;pointer-events:none;isolation:isolate;--cloudlet-status:var(--cloudlet-loading);flex-direction:column;margin-inline:auto;display:flex;position:fixed}.cloudlet-host,.cloudlet-host *,.cloudlet-host :before,.cloudlet-host :after{box-sizing:border-box}.cloudlet-host :where(h2,p,ol,li){margin:0;padding:0}.cloudlet-host :where(button,a){font:inherit;color:inherit;line-height:inherit;letter-spacing:inherit;text-transform:none;min-width:var(--cloudlet-control-min-size);min-height:var(--cloudlet-control-min-size);touch-action:manipulation}.cloudlet-host button{appearance:none;cursor:pointer;background:0 0;border:0;border-radius:24px;justify-content:center;align-items:center;margin:0;padding:10px;display:inline-flex}.cloudlet-host button[aria-disabled=true]{color:var(--cloudlet-muted);cursor:progress}.cloudlet-host a{border-radius:24px;align-items:center;padding:10px 16px;text-decoration:underline;display:inline-flex}.cloudlet-host :focus-visible{outline:2px solid var(--cloudlet-focus);outline-offset:2px}.cloudlet-host:focus-visible{outline:2px solid var(--cloudlet-focus);outline-offset:-2px}.cloudlet-host [hidden]{display:none!important}.cloudlet-host [data-kind=success]{--cloudlet-status:var(--cloudlet-success)}.cloudlet-host [data-kind=error]{--cloudlet-status:var(--cloudlet-error)}.cloudlet-host [data-kind=info]{--cloudlet-status:var(--cloudlet-info)}.cloudlet-host [data-kind=warning]{--cloudlet-status:var(--cloudlet-warning)}.cloudlet-host [data-kind=loading]{--cloudlet-status:var(--cloudlet-loading)}.cloudlet-host .cloudlet-stack{flex:none;align-self:center;width:fit-content;max-width:100%;position:relative}.cloudlet-host[data-state=island] .cloudlet-stack{width:100%}.cloudlet-host .cloudlet-shell{transform-origin:50% 0;z-index:1;position:relative}.cloudlet-host[data-edge=bottom] .cloudlet-shell{transform-origin:50% 100%}.cloudlet-host .cloudlet-bg{pointer-events:none;box-shadow:var(--cloudlet-shadow);position:absolute;top:0;left:50%;overflow:visible;transform:translate(-50%)}.cloudlet-host .cloudlet-bg path{fill:var(--cloudlet-background);stroke:var(--cloudlet-border);stroke-width:1px}.cloudlet-host :is(.cloudlet-tail,.cloudlet-exit){pointer-events:none;position:absolute;top:0;left:50%}.cloudlet-host .cloudlet-tail{z-index:0;border-radius:var(--cloudlet-pill-radius);background:var(--cloudlet-tail-background);border:1px solid var(--cloudlet-tail-border);box-shadow:var(--cloudlet-shadow);transform-origin:50% 100%;opacity:0}.cloudlet-host .cloudlet-tail[data-cloudlet-tail="2"]{z-index:-1;background:color-mix(in oklab, var(--cloudlet-tail-background) 60%, var(--cloudlet-background))}.cloudlet-host .cloudlet-exit{z-index:2;transform-origin:50% 0}.cloudlet-host[data-edge=bottom] :is(.cloudlet-bg,.cloudlet-tail,.cloudlet-exit,.cloudlet-badge){top:auto;bottom:0}.cloudlet-host[data-edge=bottom] .cloudlet-tail{transform-origin:50% 0}.cloudlet-host[data-edge=bottom] .cloudlet-exit{transform-origin:50% 100%}.cloudlet-host .cloudlet-exit:empty{display:none}.cloudlet-host .cloudlet-clip{pointer-events:auto;color:var(--cloudlet-foreground);overflow-wrap:anywhere;width:fit-content;min-width:0;max-width:min(100%, var(--cloudlet-pill-max-width));min-height:var(--cloudlet-pill-height);border-radius:var(--cloudlet-pill-radius);flex-direction:column;display:flex;position:relative}.cloudlet-host .cloudlet-shell[data-state=island]>.cloudlet-clip{width:100%;max-width:100%;max-height:var(--cloudlet-available-height);border-radius:var(--cloudlet-island-radius)}.cloudlet-host :is(.cloudlet-slide-out,.cloudlet-chrome-out){pointer-events:none;position:absolute;top:0;left:0}.cloudlet-host :is(.cloudlet-slide-out,.cloudlet-chrome-out):empty{display:none}.cloudlet-host .cloudlet-chrome-out .cloudlet-clip{width:100%;max-width:none}.cloudlet-host .cloudlet-ghost{visibility:hidden}.cloudlet-host .cloudlet-slide{flex-direction:column;flex:0 auto;min-height:0;display:flex;position:relative}.cloudlet-host .cloudlet-header{flex:none;min-width:0;display:flex;position:relative}.cloudlet-host .cloudlet-heading{min-width:0;min-height:var(--cloudlet-pill-height);flex:1;align-items:center;gap:10px;padding-block:6px;padding-inline:10px 16px;display:flex}.cloudlet-host .cloudlet-shell[data-state=island] .cloudlet-heading{padding-block:10px 6px;padding-inline:14px 52px}.cloudlet-host .cloudlet-heading-out{pointer-events:none;display:flex;position:absolute;inset:0}.cloudlet-host .cloudlet-heading-out:empty{display:none}.cloudlet-host .cloudlet-title{font:inherit;text-transform:none;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;font-weight:500;overflow:hidden}.cloudlet-host .cloudlet-shell[data-state=island] .cloudlet-title{white-space:normal;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box}.cloudlet-host .cloudlet-title:focus{outline:none}.cloudlet-host .cloudlet-title:focus-visible{outline:2px solid var(--cloudlet-focus);outline-offset:2px;border-radius:4px}.cloudlet-host .cloudlet-pill{z-index:1;pointer-events:auto;border-radius:var(--cloudlet-pill-radius);width:100%;height:100%;padding:0;position:absolute;inset:0}.cloudlet-host .cloudlet-pill,.cloudlet-host .cloudlet-shell[data-state=island]>.cloudlet-clip,.cloudlet-host .cloudlet-shell[data-state=island] .cloudlet-body{touch-action:pan-y}.cloudlet-host .cloudlet-shell[data-state=island]>.cloudlet-clip>.cloudlet-slide>.cloudlet-header{touch-action:none}.cloudlet-host[data-dragging]{-webkit-user-select:none;user-select:none}.cloudlet-host .cloudlet-peek{pointer-events:none;position:absolute;top:0;left:0}.cloudlet-host .cloudlet-badge{z-index:2;background:var(--cloudlet-badge);min-width:20px;height:20px;color:var(--cloudlet-badge-foreground);box-shadow:0 0 0 2px var(--cloudlet-background);font:600 .6875rem/20px var(--cloudlet-font-family);font-variant-numeric:tabular-nums;text-align:center;pointer-events:none;opacity:0;border-radius:9999px;padding-inline:6px;display:grid;position:absolute;top:0;left:50%}.cloudlet-host .cloudlet-badge>*{grid-area:1/1}.cloudlet-host .cloudlet-icon{width:24px;height:24px;color:var(--cloudlet-status);background:color-mix(in oklab, var(--cloudlet-status) 18%, transparent);border-radius:50%;flex:none;place-items:center;display:grid;position:relative}.cloudlet-host .cloudlet-glyph{place-items:center;width:16px;height:16px;display:grid;overflow:hidden}.cloudlet-host .cloudlet-glyph>.cloudlet-slot{place-items:center;width:100%;height:100%;display:grid}.cloudlet-host .cloudlet-glyph :is(svg,img){max-width:100%;max-height:100%;display:block}.cloudlet-host :is(svg.cloudlet-glyph,button>svg){fill:none;stroke:currentColor;stroke-width:1.75px;stroke-linecap:round;stroke-linejoin:round;display:block}.cloudlet-host .cloudlet-ring{fill:none;stroke-width:2px;width:32px;height:32px;position:absolute;inset:-4px;overflow:visible}.cloudlet-host .cloudlet-ring-track{stroke:color-mix(in oklab, var(--cloudlet-status) 18%, transparent)}.cloudlet-host .cloudlet-progress-fill{stroke:color-mix(in oklab, var(--cloudlet-status) 75%, var(--cloudlet-foreground));stroke-linecap:round}.cloudlet-host .cloudlet-close{top:8px;z-index:1;width:32px;min-width:0;height:32px;min-height:0;color:var(--cloudlet-muted);background:var(--cloudlet-action-background);border-radius:50%;padding:0;position:absolute;inset-inline-end:8px}.cloudlet-host .cloudlet-close>svg{width:16px;height:16px}.cloudlet-host :is(.cloudlet-close,.cloudlet-action,.cloudlet-overflow button):before{content:"";inset-block:calc((var(--cloudlet-control-min-size) - 32px) / -2);position:absolute;inset-inline:0}.cloudlet-host button.cloudlet-close:before{inset-inline:calc((var(--cloudlet-control-min-size) - 32px) / -2);border-radius:50%}.cloudlet-host .cloudlet-body{overscroll-behavior:contain;min-height:0;max-height:min(calc(var(--cloudlet-available-height) * .6), 24rem);flex-direction:column;padding-block:0 10px;padding-inline:48px 16px;display:flex;position:relative;overflow:auto}.cloudlet-host .cloudlet-body:not(:has(>:not(.cloudlet-actions:empty))){padding-bottom:4px}.cloudlet-host .cloudlet-body-out{pointer-events:none;position:absolute;left:0;right:0}.cloudlet-host .cloudlet-body-out:empty{display:none}.cloudlet-host .cloudlet-description{color:var(--cloudlet-muted);padding-block:0 4px;font-size:.8125rem;line-height:1.45}.cloudlet-host .cloudlet-actions{flex-wrap:wrap;flex:none;gap:12px 8px;display:flex}.cloudlet-host .cloudlet-actions:empty{display:none}.cloudlet-host .cloudlet-actions:not(:empty){margin-block:8px 2px}.cloudlet-host :is(.cloudlet-action,.cloudlet-overflow button){overflow-wrap:anywhere;min-width:0;max-width:100%;min-height:32px;color:var(--cloudlet-foreground);background:var(--cloudlet-action-background);border-radius:9999px;padding:6px 14px;font-size:.8125rem;font-weight:500;line-height:1.5;text-decoration:none;position:relative}.cloudlet-host .cloudlet-action.cloudlet-primary{color:color-mix(in oklab, var(--cloudlet-status) 55%, var(--cloudlet-foreground));background:color-mix(in oklab, var(--cloudlet-status) 12%, transparent)}.cloudlet-host :is(.cloudlet-action,.cloudlet-overflow button)[aria-disabled=true]{color:var(--cloudlet-muted)}@media (hover:hover){.cloudlet-host :is(.cloudlet-close,.cloudlet-action,.cloudlet-overflow button):hover{background:color-mix(in oklab, var(--cloudlet-foreground) 13%, transparent)}.cloudlet-host .cloudlet-close:hover{color:var(--cloudlet-foreground)}.cloudlet-host .cloudlet-action.cloudlet-primary:hover{background:color-mix(in oklab, var(--cloudlet-status) 20%, transparent)}.cloudlet-host .cloudlet-action.cloudlet-submit:hover{background:color-mix(in oklab, var(--cloudlet-status) 70%, #000)}}.cloudlet-host .cloudlet-action-error{color:var(--cloudlet-muted);padding-block:4px;font-size:.8125rem}.cloudlet-host .cloudlet-form{flex-direction:column;gap:8px;margin-block:4px 2px;display:flex}.cloudlet-host .cloudlet-form-row{grid-template-columns:minmax(0,1fr) auto;align-items:end;gap:4px 8px;display:grid}.cloudlet-host .cloudlet-field{border:1px solid var(--cloudlet-field-border);width:100%;min-width:0;min-height:36px;color:var(--cloudlet-foreground);background:var(--cloudlet-field-background);font:inherit;resize:none;overflow-wrap:anywhere;border-radius:18px;grid-column:1;margin:0;padding:7px 13px;line-height:20px}.cloudlet-host .cloudlet-field::placeholder{color:var(--cloudlet-placeholder);opacity:1}.cloudlet-host .cloudlet-field:focus-visible{outline-offset:1px}.cloudlet-host .cloudlet-field[aria-invalid=true]{border-color:var(--cloudlet-error)}.cloudlet-host .cloudlet-field[aria-invalid=true]:focus-visible{outline-color:var(--cloudlet-error);border-color:#0000}.cloudlet-host .cloudlet-field[readonly]{color:var(--cloudlet-muted)}.cloudlet-host :is(.cloudlet-form>.cloudlet-action-error,.cloudlet-form~.cloudlet-action-error){padding-inline:14px}.cloudlet-host .cloudlet-field-error{color:color-mix(in oklab, var(--cloudlet-error) 70%, var(--cloudlet-foreground));grid-column:1/-1;padding-inline:14px;font-size:.8125rem}.cloudlet-host .cloudlet-action.cloudlet-submit{color:#fff;background:color-mix(in oklab, var(--cloudlet-status) 80%, #000);border-radius:50%;grid-column:2;place-items:center;width:36px;min-width:0;height:36px;min-height:0;padding:0;display:grid}.cloudlet-host .cloudlet-submit>svg{stroke-width:2px;width:16px;height:16px}.cloudlet-host button.cloudlet-submit:before{inset:calc((var(--cloudlet-control-min-size) - 36px) / -2);border-radius:50%}.cloudlet-host .cloudlet-indicator{color:var(--cloudlet-muted);flex-wrap:wrap;flex:none;justify-content:center;align-items:center;column-gap:8px;padding-bottom:6px;font-size:.75rem;display:flex}.cloudlet-host .cloudlet-indicator .cloudlet-dot-button{min-width:24px;min-height:24px;padding:8px}.cloudlet-host .cloudlet-dot{background:color-mix(in oklab, var(--cloudlet-foreground) 25%, transparent);border-radius:50%;width:6px;height:6px;display:block}.cloudlet-host .cloudlet-indicator [aria-current=true] .cloudlet-dot{background:var(--cloudlet-foreground)}.cloudlet-host .cloudlet-page{font-variant-numeric:tabular-nums;padding:8px;display:grid}.cloudlet-host .cloudlet-page>*{grid-area:1/1}.cloudlet-host .cloudlet-overflow{flex-wrap:wrap;justify-content:center;align-items:center;gap:4px 8px;min-width:0;display:flex}.cloudlet-host .cloudlet-overflow button{font-size:.75rem}.cloudlet-host .cloudlet-live{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.cloudlet-announcer{clip-path:inset(50%);white-space:nowrap;pointer-events:none;border:0;width:1px;height:1px;margin:-1px;padding:0;position:fixed;top:0;left:0;overflow:hidden}.cloudlet-host[data-position=top-center]{top:calc(var(--cloudlet-viewport-top,0px) + var(--cloudlet-top));bottom:auto}@media (width>=48rem){.cloudlet-host[data-position=auto]{top:calc(var(--cloudlet-viewport-top,0px) + var(--cloudlet-top));bottom:auto}}.cloudlet-host[data-theme=dark]{--cloudlet-background:#1c1c1e;--cloudlet-foreground:#f5f5f7;--cloudlet-muted:#a1a1aa;--cloudlet-focus:#93b4ff;--cloudlet-shadow:0 12px 32px -12px #0009;--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--cloudlet-tail-background:color-mix(in oklab, var(--cloudlet-foreground) 14%, var(--cloudlet-background));--cloudlet-tail-border:color-mix(in oklab, var(--cloudlet-foreground) 18%, transparent)}@media (prefers-color-scheme:dark){.cloudlet-host[data-theme=system]{--cloudlet-background:#1c1c1e;--cloudlet-foreground:#f5f5f7;--cloudlet-muted:#a1a1aa;--cloudlet-focus:#93b4ff;--cloudlet-shadow:0 12px 32px -12px #0009;--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--cloudlet-tail-background:color-mix(in oklab, var(--cloudlet-foreground) 14%, var(--cloudlet-background));--cloudlet-tail-border:color-mix(in oklab, var(--cloudlet-foreground) 18%, transparent)}}@keyframes cloudlet-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:no-preference){.cloudlet-host .cloudlet-spinner{animation:.8s linear infinite cloudlet-spin}.cloudlet-host .cloudlet-ring[data-progress=indeterminate]{animation:1s linear infinite cloudlet-spin}.cloudlet-host[data-reduced-motion=true] :is(.cloudlet-spinner,.cloudlet-ring){animation:none}}@media (forced-colors:active){.cloudlet-host[data-theme]{--cloudlet-background:Canvas;--cloudlet-foreground:CanvasText;--cloudlet-muted:CanvasText;--cloudlet-border:CanvasText;--cloudlet-focus:Highlight;--cloudlet-action-background:Canvas;--cloudlet-status:CanvasText;--cloudlet-success:CanvasText;--cloudlet-error:CanvasText;--cloudlet-info:CanvasText;--cloudlet-warning:CanvasText;--cloudlet-loading:CanvasText;--cloudlet-badge:Highlight;--cloudlet-badge-foreground:HighlightText}.cloudlet-host :is(.cloudlet-bg,.cloudlet-icon,.cloudlet-badge,.cloudlet-dot){forced-color-adjust:none}.cloudlet-host .cloudlet-icon{outline-offset:-1px;background:canvas;outline:1px solid canvastext}.cloudlet-host .cloudlet-ring-track{stroke:graytext}.cloudlet-host .cloudlet-dot{background:canvas;outline:1px solid canvastext}.cloudlet-host .cloudlet-indicator [aria-current=true] .cloudlet-dot{background:canvastext}.cloudlet-host :is(.cloudlet-close,.cloudlet-action,.cloudlet-overflow button){border:1px solid buttontext}.cloudlet-host .cloudlet-field{color:fieldtext;background:field;border-color:canvastext}.cloudlet-host .cloudlet-field[aria-invalid=true]{border-width:2px}.cloudlet-host .cloudlet-action.cloudlet-submit{forced-color-adjust:none;color:highlighttext;background:highlight;border-color:highlight}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudlet/toast",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "Cloudlet notifications and async operations with an SSR-safe React renderer",
5
5
  "license": "MIT",
6
6
  "homepage": "https://cloudlet.dev/toaster",
@@ -11,6 +11,10 @@ export interface FallbackMessages {
11
11
  readonly cancellationRequested: string;
12
12
  readonly actionError: string;
13
13
  readonly renderError: string;
14
+ /** A required form field is empty. */
15
+ readonly fieldRequired: string;
16
+ /** A form field is longer than its `maxLength`. */
17
+ readonly fieldTooLong: string;
14
18
  }
15
19
 
16
20
  export interface ControllerOptions {
@@ -42,8 +46,9 @@ export type ClearResult =
42
46
  | { readonly status: 'rejected'; readonly reason: 'disposed' };
43
47
 
44
48
  export interface CloudletController<Slot = never, Signal extends CancellationSignal = CancellationSignal> {
45
- readonly show: (spec: NotificationSpec<Slot>) => AdmissionResult;
46
- readonly update: (handle: NotificationHandle, patch: NotificationPatch<Slot>) => MutationResult;
49
+ /** `Name` is inferred from the field names of a form action. */
50
+ readonly show: <Name extends string = string>(spec: NotificationSpec<Slot, Name>) => AdmissionResult;
51
+ readonly update: <Name extends string = string>(handle: NotificationHandle, patch: NotificationPatch<Slot, Name>) => MutationResult;
47
52
  readonly getHandle: (id: string) => NotificationHandle | undefined;
48
53
  readonly track: <T>(source: OperationSource<T, Signal>, options: TrackOptions<T, Slot, Signal>) => OperationHandle<T>;
49
54
  readonly dismiss: (handle: NotificationHandle) => MutationResult;
@@ -80,10 +80,25 @@ export type AnnouncementAcknowledgement =
80
80
  | { readonly kind: 'operation'; readonly handle: NotificationHandle; readonly token: OperationAttemptToken; readonly phase: OperationAnnouncementPhase }
81
81
  | { readonly kind: 'overflow'; readonly count: number };
82
82
 
83
+ /** Messages from the last submit: `form` under the form, `fields` under each field. */
84
+ export interface FormErrors {
85
+ readonly form: string | null;
86
+ readonly fields: Readonly<Record<string, string>>;
87
+ }
88
+
89
+ /** The values a form action holds for one record; only the renderer sees them. */
90
+ export interface FormDraft {
91
+ readonly handle: NotificationHandle;
92
+ readonly values: Readonly<Record<string, string>>;
93
+ readonly errors: FormErrors;
94
+ }
95
+
83
96
  export interface RendererSnapshot<Slot = never> extends ControllerSnapshot<Slot> {
84
97
  readonly presentation: RendererPresentation | null;
85
98
  readonly focusRequest: FocusRequest | null;
86
99
  readonly announcements: AnnouncementLedgerSnapshot;
100
+ /** One entry per record with a form action, in notification order. */
101
+ readonly forms: readonly FormDraft[];
87
102
  }
88
103
 
89
104
  export type AttachResult =
@@ -105,6 +120,8 @@ export type RendererCloseReason = Extract<CloseReason, 'close-button' | 'swipe'
105
120
 
106
121
  export type ActionResult =
107
122
  | { readonly status: 'started' }
123
+ /** A form failed `required`, `maxLength` or `validate`; the messages are in the record's draft. */
124
+ | { readonly status: 'invalid'; readonly errors: FormErrors }
108
125
  | { readonly status: 'rejected'; readonly reason: BridgeRejection | 'no-command' | 'already-pending' };
109
126
 
110
127
  export type RetryOperationResult =
@@ -143,7 +160,10 @@ export interface RendererBridge<Slot = never> {
143
160
  readonly acknowledgeOverflow: (lease: HostLease) => BridgeResult;
144
161
  readonly acknowledgeAnnouncements: (lease: HostLease, acknowledgements: readonly AnnouncementAcknowledgement[]) => BridgeResult;
145
162
  readonly dismiss: (lease: HostLease, handle: NotificationHandle, reason: RendererCloseReason) => MutationResult | { readonly status: 'rejected'; readonly reason: 'stale-lease' };
163
+ /** Runs a command, or validates and submits a form. */
146
164
  readonly invokeAction: (lease: HostLease, handle: NotificationHandle) => ActionResult;
165
+ readonly setFormValue: (lease: HostLease, handle: NotificationHandle, name: string, value: string) =>
166
+ BridgeResult | { readonly status: 'rejected'; readonly reason: 'no-form' | 'already-pending' };
147
167
  readonly retryOperation: (lease: HostLease, handle: NotificationHandle, expected: OperationAttemptToken) => RetryOperationResult;
148
168
  readonly cancelOperation: (lease: HostLease, handle: NotificationHandle, expected: OperationAttemptToken, reason?: unknown) => CancelOperationResult;
149
169
  readonly reportDiagnostic: (lease: HostLease, diagnostic: Diagnostic) => BridgeResult;
@@ -36,14 +36,53 @@ export interface NavigationAction {
36
36
  readonly rel?: string;
37
37
  }
38
38
 
39
- export type PrimaryAction = CommandAction | NavigationAction;
39
+ export type FormFieldKind = 'text' | 'textarea';
40
+ export type FormInputMode = 'text' | 'email' | 'numeric' | 'decimal' | 'tel' | 'url' | 'search';
40
41
 
41
- export interface NotificationContent<Slot = never> {
42
+ /** One field of a form action. `label` is read by screen readers; the placeholder falls back to it. */
43
+ export interface FormField<Name extends string = string> {
44
+ readonly name: Name;
45
+ readonly kind: FormFieldKind;
46
+ readonly label: string;
47
+ readonly placeholder?: string;
48
+ readonly defaultValue?: string;
49
+ readonly required?: boolean;
50
+ readonly maxLength?: number;
51
+ readonly autoComplete?: string;
52
+ readonly inputMode?: FormInputMode;
53
+ }
54
+
55
+ /** Field values as typed, without trimming. */
56
+ export type FormValues<Name extends string = string> = Readonly<Record<Name, string>>;
57
+
58
+ export interface FormContext<Name extends string = string> extends ActionContext {
59
+ readonly values: FormValues<Name>;
60
+ }
61
+
62
+ /** `true` accepts; a string is a message under the form; an object holds messages under fields. */
63
+ export type FormValidation<Name extends string = string> = true | string | Readonly<Partial<Record<Name, string>>>;
64
+
65
+ /** A form in the Island: one to three fields and a submit button with command semantics. */
66
+ export interface FormAction<Name extends string = string> {
67
+ readonly kind: 'form';
68
+ readonly fields: readonly FormField<Name>[];
69
+ /** The submit button's accessible name, like the label of a command. */
70
+ readonly label: string;
71
+ // Methods, not function properties: a form typed with its field names stays assignable to `FormAction`.
72
+ run(context: FormContext<Name>): unknown;
73
+ errorMessage?(error: unknown): string;
74
+ /** Runs on submit after `required` and `maxLength`. */
75
+ validate?(values: FormValues<Name>): FormValidation<Name>;
76
+ }
77
+
78
+ export type PrimaryAction<Name extends string = string> = CommandAction | NavigationAction | FormAction<Name>;
79
+
80
+ export interface NotificationContent<Slot = never, Name extends string = string> {
42
81
  readonly title: string;
43
82
  readonly description?: Description<Slot>;
44
83
  readonly icon?: Slot;
45
84
  readonly progress?: Progress;
46
- readonly action?: PrimaryAction;
85
+ readonly action?: PrimaryAction<Name>;
47
86
  readonly announcementPriority?: AnnouncementPriority;
48
87
  /** Omitted = policy default; null = persistent; number = readable milliseconds. */
49
88
  readonly duration?: Duration;
@@ -66,7 +105,7 @@ export interface CloseNotice {
66
105
  readonly reason: CloseReason;
67
106
  }
68
107
 
69
- export interface NotificationSpec<Slot = never> extends NotificationContent<Slot> {
108
+ export interface NotificationSpec<Slot = never, Name extends string = string> extends NotificationContent<Slot, Name> {
70
109
  readonly id?: string;
71
110
  readonly kind?: NotificationKind;
72
111
  readonly priority?: Priority;
@@ -75,13 +114,13 @@ export interface NotificationSpec<Slot = never> extends NotificationContent<Slot
75
114
  }
76
115
 
77
116
  /** Omitted preserves; null removes optional content. IDs/dedupe keys are immutable. */
78
- export interface NotificationPatch<Slot = never> {
117
+ export interface NotificationPatch<Slot = never, Name extends string = string> {
79
118
  readonly title?: string;
80
119
  readonly kind?: NotificationKind;
81
120
  readonly description?: Description<Slot> | null;
82
121
  readonly icon?: Slot | null;
83
122
  readonly progress?: Progress | null;
84
- readonly action?: PrimaryAction | null;
123
+ readonly action?: PrimaryAction<Name> | null;
85
124
  readonly priority?: Priority;
86
125
  readonly announcementPriority?: AnnouncementPriority;
87
126
  readonly duration?: Duration;
@@ -12,6 +12,7 @@ export type PauseReason =
12
12
  | 'action-pending'
13
13
  | 'content-transition'
14
14
  | 'island'
15
+ | 'draft'
15
16
  | 'document-hidden'
16
17
  | 'window-blur';
17
18
 
@@ -34,6 +35,8 @@ export interface NotificationSnapshot<Slot = never> {
34
35
  readonly pauseReasons: readonly PauseReason[];
35
36
  readonly operation: OperationSnapshot | null;
36
37
  readonly action: ActionSnapshot;
38
+ /** A form action whose values differ from their defaults. The values stay inside Cloudlet. */
39
+ readonly draft: boolean;
37
40
  }
38
41
 
39
42
  export type IslandReason = 'user' | 'attention';
@@ -1,15 +1,15 @@
1
1
  import type { Diagnostic } from '../contracts/events.js';
2
2
  import type { ActionAttemptToken, NotificationHandle, OperationAttemptToken } from '../contracts/identity.js';
3
3
  import type {
4
- AnnouncementAcknowledgement, BridgeRejection, BridgeResult, FocusRequestToken, HostLease, HostOptions, PauseChange,
4
+ AnnouncementAcknowledgement, BridgeRejection, BridgeResult, FocusRequestToken, FormErrors, HostLease, HostOptions, PauseChange,
5
5
  PresentationToken, RendererBridge,
6
6
  } from '../contracts/internal.js';
7
7
  import type { CancellationSignal } from '../contracts/operations.js';
8
8
  import type { CloudletController } from '../contracts/controller.js';
9
9
  import type { IslandReason, PauseReason } from '../contracts/snapshots.js';
10
10
  import {
11
- APPLIED, ATTENTION_DELAY, RENDERER_SERVER, UNCHANGED, getControllerKernel, reject,
12
- type ControllerKernel, type OperationBinding, type RecordState,
11
+ APPLIED, ATTENTION_DELAY, NO_FORM_ERRORS, RENDERER_SERVER, UNCHANGED, getControllerKernel, reject,
12
+ type ControllerKernel, type FormState, type OperationBinding, type RecordState,
13
13
  } from './controller.js';
14
14
  import { validDelay } from './validation.js';
15
15
 
@@ -54,6 +54,35 @@ function createRendererBridge<Slot>(k: ControllerKernel<Slot>): RendererBridge<S
54
54
  return error ? reject(error) : action(...args);
55
55
  };
56
56
  }
57
+ /** `required` and `maxLength` first, then the form's own `validate`; null lets the submit run. */
58
+ function checkForm(form: FormState, handle: NotificationHandle): FormErrors | null {
59
+ const messages = k.options.messages;
60
+ const fields: Record<string, string> = {};
61
+ for (const field of form.action.fields) {
62
+ const value = form.values[field.name] ?? '';
63
+ if (field.required && !value.trim()) fields[field.name] = messages?.fieldRequired ?? 'This field is required';
64
+ else if (field.maxLength !== undefined && value.length > field.maxLength) fields[field.name] = messages?.fieldTooLong ?? 'This text is too long';
65
+ }
66
+ if (Object.keys(fields).length) return freeze({ form: null, fields: freeze(fields) });
67
+ if (!form.action.validate) return null;
68
+ let result: unknown;
69
+ try {
70
+ result = form.action.validate(form.values);
71
+ } catch (error) {
72
+ k.failure('callback-error', 'action.validate', error, handle);
73
+ return freeze({ form: messages?.actionError ?? 'Action failed', fields: freeze({}) });
74
+ }
75
+ if (result === true) return null;
76
+ if (typeof result === 'string' && result.trim()) return freeze({ form: result, fields: freeze({}) });
77
+ const names = form.action.fields.map((field) => field.name);
78
+ if (result !== null && typeof result === 'object' && Object.getPrototypeOf(result) === Object.prototype &&
79
+ Object.entries(result).every(([name, message]) => names.includes(name) && typeof message === 'string' && message.trim())) {
80
+ return Object.keys(result).length ? freeze({ form: null, fields: freeze({ ...result as Record<string, string> }) }) : null;
81
+ }
82
+ k.diagnostic({ code: 'callback-error', source: 'action.validate', handle,
83
+ message: 'validate must return true, a message, or messages keyed by field name' });
84
+ return freeze({ form: messages?.actionError ?? 'Action failed', fields: freeze({}) });
85
+ }
57
86
  const bridge = freeze<RendererBridge<Slot>>({
58
87
  renderError: k.options.messages?.renderError ?? 'Content unavailable',
59
88
  reportInvalidContainer(message, error) {
@@ -188,18 +217,27 @@ function createRendererBridge<Slot>(k: ControllerKernel<Slot>): RendererBridge<S
188
217
  invokeAction: withLease(k.withRecord((record) => {
189
218
  const handle = record.handle;
190
219
  const action = record.content.action;
191
- if (!action || action.kind !== 'command') return reject('no-command');
220
+ if (!action || action.kind === 'link') return reject('no-command');
192
221
  if (record.action.status === 'pending') return reject('already-pending');
222
+ const form = k.formOf(record);
223
+ if (form) {
224
+ const errors = checkForm(form, handle);
225
+ if (errors) {
226
+ k.mutate(() => { form.errors = errors; });
227
+ return { status: 'invalid' as const, errors };
228
+ }
229
+ }
193
230
  const actionToken = k.token() as ActionAttemptToken;
194
231
  const live = () => !k.disposed && k.records.get(handle.id) === record &&
195
232
  record.action.status === 'pending' && record.action.token === actionToken;
196
233
  const now = k.settle();
197
234
  record.action = freeze({ status: 'pending', token: actionToken });
235
+ if (form) form.errors = NO_FORM_ERRORS;
198
236
  k.commit([{ type: 'action-started', handle, token: actionToken }], now);
199
237
  function failed(reason: unknown): void {
200
238
  if (!live()) return;
201
239
  let message = k.options.messages?.actionError ?? 'Action failed';
202
- if (action?.kind === 'command' && action.errorMessage) {
240
+ if (action && action.kind !== 'link' && action.errorMessage) {
203
241
  try {
204
242
  const mapped = action.errorMessage(reason);
205
243
  if (typeof mapped !== 'string' || !mapped.trim()) throw new TypeError('Invalid action error message');
@@ -214,7 +252,10 @@ function createRendererBridge<Slot>(k: ControllerKernel<Slot>): RendererBridge<S
214
252
  k.commit([{ type: 'action-failed', handle, token: actionToken, message }], now);
215
253
  }
216
254
  let result: Promise<unknown>;
217
- try { result = Promise.resolve(action.run(freeze({ handle, token: actionToken }))); }
255
+ try {
256
+ result = Promise.resolve(form ? form.action.run(freeze({ handle, token: actionToken, values: form.values }))
257
+ : action.kind === 'command' ? action.run(freeze({ handle, token: actionToken })) : undefined);
258
+ }
218
259
  catch (error) { result = Promise.reject(error); }
219
260
  void result.then(() => {
220
261
  if (live()) k.dismiss(handle, 'action-success');
@@ -223,6 +264,21 @@ function createRendererBridge<Slot>(k: ControllerKernel<Slot>): RendererBridge<S
223
264
  });
224
265
  return { status: 'started' as const };
225
266
  })),
267
+ setFormValue: withLease(k.withRecord((record, name: string, value: string) => {
268
+ const form = k.formOf(record);
269
+ if (!form) return reject('no-form');
270
+ if (typeof value !== 'string' || !form.action.fields.some((field) => field.name === name)) return reject('invalid-input');
271
+ if (record.action.status === 'pending') return reject('already-pending');
272
+ if (form.values[name] === value) return UNCHANGED;
273
+ return k.mutate(() => {
274
+ form.values = freeze({ ...form.values, [name]: value });
275
+ // Editing a field clears its own message; the rest wait for the next submit.
276
+ if (form.errors.fields[name] !== undefined) {
277
+ const { [name]: _, ...fields } = form.errors.fields;
278
+ form.errors = freeze({ form: form.errors.form, fields: freeze(fields) });
279
+ }
280
+ });
281
+ })),
226
282
  retryOperation: withLease(withOperation((operation) => {
227
283
  const result = operation.retry();
228
284
  return result.status === 'started' ? { status: 'started' as const, token: result.attempt.token } : result;
@@ -2,10 +2,10 @@ import type { CloudletController, ControllerOptions, FocusTarget } from '../cont
2
2
  import type { Diagnostic, EventBase, SemanticEvent } from '../contracts/events.js';
3
3
  import type { ActionAttemptToken, ControllerIdentity, Generation, HandleRejection, NotificationHandle, OperationAttemptToken, Unsubscribe } from '../contracts/identity.js';
4
4
  import type {
5
- FocusRequest, FocusRequestToken, ControllerDependencies, HostLease, OperationAnnouncementPhase, PresentationToken,
5
+ FocusRequest, FocusRequestToken, ControllerDependencies, FormErrors, HostLease, OperationAnnouncementPhase, PresentationToken,
6
6
  RendererSnapshot,
7
7
  } from '../contracts/internal.js';
8
- import type { AdmissionResult, CloseReason, NotificationContent, NotificationKind, NotificationPatch, NotificationSpec, OperationAdmissionResult, Priority } from '../contracts/notifications.js';
8
+ import type { AdmissionResult, CloseReason, FormAction, NotificationContent, NotificationKind, NotificationPatch, NotificationSpec, OperationAdmissionResult, Priority } from '../contracts/notifications.js';
9
9
  import type { AttemptStartResult, CancellationSignal, CancelResult, OperationAttempt, OperationContext, OperationHandle, OperationSnapshot, OperationSource, OperationStatus, TrackOptions } from '../contracts/operations.js';
10
10
  import type { ActionSnapshot, ControllerSnapshot, IslandReason, IslandSnapshot, PauseReason } from '../contracts/snapshots.js';
11
11
  import { copyContent, patchContent, validateContent, validateOptions, validatePatch, validateSpec, validateTrackOptions } from './validation.js';
@@ -41,6 +41,14 @@ export interface RecordState<Slot> {
41
41
  readonly operationAnnounced: Set<OperationAnnouncementPhase>;
42
42
  action: ActionSnapshot;
43
43
  actionAnnounced?: { readonly token: ActionAttemptToken; readonly status: 'pending' | 'failed' };
44
+ /** Values of the form action the record holds; a new action object starts from its defaults. */
45
+ form: FormState | null;
46
+ }
47
+
48
+ export interface FormState {
49
+ readonly action: FormAction;
50
+ values: Readonly<Record<string, string>>;
51
+ errors: FormErrors;
44
52
  }
45
53
 
46
54
  /** Open Island state; `null` is the collapsed stack. */
@@ -71,10 +79,11 @@ const SERVER: ControllerSnapshot<never> = freeze({
71
79
  island: COLLAPSED, overflow: freeze({ count: 0, pending: false }),
72
80
  });
73
81
  export const RENDERER_SERVER: RendererSnapshot<never> = freeze({
74
- ...SERVER, presentation: null, focusRequest: null,
82
+ ...SERVER, presentation: null, focusRequest: null, forms: EMPTY,
75
83
  announcements: freeze({ notifications: EMPTY, overflowCount: 0 }),
76
84
  });
77
85
  const IDLE = freeze({ status: 'idle' as const });
86
+ export const NO_FORM_ERRORS: FormErrors = freeze({ form: null, fields: freeze({}) });
78
87
  export const APPLIED = freeze({ status: 'applied' as const });
79
88
  export const UNCHANGED = freeze({ status: 'unchanged' as const });
80
89
  export const reject = <Reason extends string>(reason: Reason) => ({ status: 'rejected' as const, reason });
@@ -113,6 +122,7 @@ export interface ControllerKernel<Slot> {
113
122
  readonly settle: () => number;
114
123
  readonly assign: (record: RecordState<Slot>) => void;
115
124
  readonly newest: () => RecordState<Slot> | null;
125
+ readonly formOf: (record: RecordState<Slot>) => FormState | null;
116
126
  readonly handleError: (handle: NotificationHandle) => HandleRejection | 'disposed' | undefined;
117
127
  readonly withRecord: <Args extends unknown[], Result>(action: (record: RecordState<Slot>, ...args: Args) => Result)
118
128
  => (handle: NotificationHandle, ...args: Args) => Result | Rejected<HandleRejection | 'disposed'>;
@@ -189,8 +199,23 @@ export function createCloudletCore<Slot = never, Signal extends CancellationSign
189
199
  const rule = record.content.attention ?? 'auto';
190
200
  return rule === 'open' || (rule === 'auto' && (requiresAction(record) || !!record.content.description));
191
201
  };
202
+ /** The record's form state, started from the field defaults whenever its form action object changes. */
203
+ const formOf = (record: RecordState<Slot>): FormState | null => {
204
+ const action = record.content.action;
205
+ if (action?.kind !== 'form') return record.form = null;
206
+ if (record.form?.action !== action) {
207
+ record.form = { action, errors: NO_FORM_ERRORS,
208
+ values: freeze(Object.fromEntries(action.fields.map((field) => [field.name, field.defaultValue ?? '']))) };
209
+ }
210
+ return record.form;
211
+ };
212
+ const dirty = (record: RecordState<Slot>) => {
213
+ const form = formOf(record);
214
+ return !!form && form.action.fields.some((field) => form.values[field.name] !== (field.defaultValue ?? ''));
215
+ };
216
+ // A draft in the open Island holds it like a hand on it: attention never switches it away.
192
217
  const interacting = () => globalPauses.has('hover') || globalPauses.has('focus')
193
- || [...records.values()].some((record) => record.pauses.has('gesture'));
218
+ || [...records.values()].some((record) => record.pauses.has('gesture')) || (!!island && dirty(island.current));
194
219
  const pauses = (record: RecordState<Slot>): PauseReason[] => {
195
220
  const current = record === presented;
196
221
  return [
@@ -200,6 +225,7 @@ export function createCloudletCore<Slot = never, Signal extends CancellationSign
200
225
  // An Island opened by the user, or a slide that asks for action, keeps its time.
201
226
  ...(current && island && (island.reason === 'user' || requiresAction(record)) ? ['island' as const] : []),
202
227
  ...(record.action.status === 'pending' ? ['action-pending' as const] : []),
228
+ ...(dirty(record) ? ['draft' as const] : []),
203
229
  ...globalPauses, ...record.pauses,
204
230
  ];
205
231
  };
@@ -313,6 +339,7 @@ export function createCloudletCore<Slot = never, Signal extends CancellationSign
313
339
  handle: record.handle, kind: record.kind, content: record.content, priority: record.priority,
314
340
  occurrences: record.occurrences, location: record === presented ? 'current' as const : 'stack' as const,
315
341
  remainingMs: record.remaining, pauseReasons: freeze(pauses(record)), operation: record.operation?.getSnapshot() ?? null, action: record.action,
342
+ draft: dirty(record),
316
343
  })));
317
344
  snapshot = freeze({ controller: identity, revision, disposed, notifications,
318
345
  stack: freeze(stackOrder().map((record) => record.handle)),
@@ -322,6 +349,10 @@ export function createCloudletCore<Slot = never, Signal extends CancellationSign
322
349
  rendererSnapshot = freeze({ ...snapshot,
323
350
  presentation: presented ? freeze({ handle: presented.handle, token: presented.presentation, readable: presented.readable }) : null,
324
351
  focusRequest,
352
+ forms: freeze(current.flatMap((record) => {
353
+ const form = formOf(record);
354
+ return form ? [freeze({ handle: record.handle, values: form.values, errors: form.errors })] : [];
355
+ })),
325
356
  announcements: freeze({ overflowCount: overflowAnnounced,
326
357
  notifications: freeze(current.map((record) => freeze({
327
358
  handle: record.handle, queued: record.queuedAnnounced, firstPresentation: record.firstAnnounced,
@@ -507,6 +538,7 @@ export function createCloudletCore<Slot = never, Signal extends CancellationSign
507
538
  operation: null,
508
539
  operationAnnounced: new Set(),
509
540
  action: IDLE,
541
+ form: null,
510
542
  };
511
543
  record.remaining = budget(record);
512
544
  records.set(id, record);
@@ -843,7 +875,7 @@ export function createCloudletCore<Slot = never, Signal extends CancellationSign
843
875
  get focusRequest() { return focusRequest; }, set focusRequest(value) { focusRequest = value; },
844
876
  get focused() { return focused; }, set focused(value) { focused = value; },
845
877
  get overflowAnnounced() { return overflowAnnounced; }, set overflowAnnounced(value) { overflowAnnounced = value; },
846
- token, diagnostic, failure, mutate, commit, settle, assign, newest, handleError, withRecord,
878
+ token, diagnostic, failure, mutate, commit, settle, assign, newest, formOf, handleError, withRecord,
847
879
  autoDismissing, setHostAutoDismiss, dismiss, acknowledgeOverflow,
848
880
  reportRendererLoadError(error) {
849
881
  if (!disposed) diagnostic({ code: 'renderer-load-error', source: 'Toaster', message: 'Toaster renderer failed to load', error });
@@ -13,7 +13,10 @@ const patchKeys = [...contentKeys, 'kind', 'priority'];
13
13
  const specKeys = [...patchKeys, 'id', 'dedupeKey', 'onClose'];
14
14
  const messageKeys = [
15
15
  'operationSuccess', 'operationError', 'operationCancelled', 'cancellationRequested', 'actionError', 'renderError',
16
+ 'fieldRequired', 'fieldTooLong',
16
17
  ] as const;
18
+ const fieldKeys = ['name', 'kind', 'label', 'placeholder', 'defaultValue', 'required', 'maxLength', 'autoComplete', 'inputMode'];
19
+ const inputModes = ['text', 'email', 'numeric', 'decimal', 'tel', 'url', 'search'];
17
20
  const noIssues: readonly InputIssue[] = Object.freeze([]);
18
21
  const owns = Object.hasOwn;
19
22
  const at = (path: string, key: PropertyKey): string => path ? `${path}.${String(key)}` : String(key);
@@ -108,10 +111,43 @@ function safeHref(value: string): boolean {
108
111
  return ['http', 'https', 'mailto', 'tel'].includes(scheme);
109
112
  }
110
113
 
114
+ function formFields(value: unknown, issues: InputIssue[]): void {
115
+ if (!Array.isArray(value) || value.length < 1 || value.length > 3) {
116
+ issue(issues, 'action.fields', 'Expected an array of one to three fields');
117
+ return;
118
+ }
119
+ const names = new Set<unknown>();
120
+ value.forEach((item: unknown, index) => {
121
+ const path = `action.fields.${index}`;
122
+ const data = record(item, path, fieldKeys, issues);
123
+ if (!data) return;
124
+ fields(data, issues, path, [
125
+ ['name', 'nonempty string', true], ['kind', ['text', 'textarea'], true], ['label', 'nonempty string', true],
126
+ ['placeholder', 'string'], ['defaultValue', 'string'], ['required', 'boolean'], ['autoComplete', 'string'],
127
+ ['inputMode', inputModes],
128
+ ]);
129
+ if (names.has(data.name)) issue(issues, `${path}.name`, 'Field names must be unique');
130
+ names.add(data.name);
131
+ if (owns(data, 'maxLength') && data.maxLength !== undefined &&
132
+ (typeof data.maxLength !== 'number' || !Number.isInteger(data.maxLength) || data.maxLength < 1)) {
133
+ issue(issues, `${path}.maxLength`, 'Expected a positive integer');
134
+ } else if (typeof data.maxLength === 'number' && typeof data.defaultValue === 'string' && data.defaultValue.length > data.maxLength) {
135
+ issue(issues, `${path}.defaultValue`, 'Longer than maxLength');
136
+ }
137
+ });
138
+ }
139
+
111
140
  function action(value: unknown, issues: InputIssue[]): void {
112
- const data = record(value, 'action', ['kind', 'label', 'run', 'errorMessage', 'href', 'target', 'rel'], issues);
141
+ const data = record(value, 'action', ['kind', 'label', 'run', 'errorMessage', 'href', 'target', 'rel', 'fields', 'validate'], issues);
113
142
  if (!data) return;
114
143
  fields(data, issues, 'action', [['label', 'nonempty string', true]]);
144
+ if (data.kind === 'form') {
145
+ forbidden(data, issues, 'action', ['href', 'target', 'rel'], 'a form action');
146
+ fields(data, issues, 'action', [['run', 'function', true], ['errorMessage', 'function'], ['validate', 'function']]);
147
+ formFields(data.fields, issues);
148
+ return;
149
+ }
150
+ forbidden(data, issues, 'action', ['fields', 'validate'], `a ${data.kind === 'link' ? 'link' : 'command'} action`);
115
151
  if (data.kind === 'command') {
116
152
  forbidden(data, issues, 'action', ['href', 'target', 'rel'], 'a command action');
117
153
  fields(data, issues, 'action', [['run', 'function', true], ['errorMessage', 'function']]);
@@ -120,7 +156,7 @@ function action(value: unknown, issues: InputIssue[]): void {
120
156
  fields(data, issues, 'action', [['href', 'nonempty string', true]]);
121
157
  if (typeof data.href === 'string' && !safeHref(data.href)) issue(issues, 'action.href', 'Unsupported or unsafe URL');
122
158
  fields(data, issues, 'action', [['target', ['_self', '_blank', '_parent', '_top']], ['rel', 'string']]);
123
- } else fields(data, issues, 'action', [['kind', ['command', 'link'], true]]);
159
+ } else fields(data, issues, 'action', [['kind', ['command', 'link', 'form'], true]]);
124
160
  }
125
161
 
126
162
  function common(data: Record<string, unknown>, issues: InputIssue[], patch: boolean): void {
@@ -241,9 +277,18 @@ function copyProgress(value: Progress): Progress {
241
277
  return value.kind === 'indeterminate' ? copyFields(value, ['kind'], ['label']) : copyFields(value, ['kind', 'value'], ['label']);
242
278
  }
243
279
 
280
+ // A patch that keeps the action passes its existing copy back; keeping that identity keeps a form's draft.
281
+ const copiedActions = new WeakSet<PrimaryAction>();
282
+
244
283
  function copyAction(value: PrimaryAction): PrimaryAction {
245
- return value.kind === 'command' ? copyFields(value, ['kind', 'label', 'run'], ['errorMessage'])
246
- : copyFields(value, ['kind', 'label', 'href'], ['target', 'rel']);
284
+ if (copiedActions.has(value)) return value;
285
+ const copy = value.kind === 'command' ? copyFields(value, ['kind', 'label', 'run'], ['errorMessage'])
286
+ : value.kind === 'link' ? copyFields(value, ['kind', 'label', 'href'], ['target', 'rel'])
287
+ : copyFields({ ...value, fields: Object.freeze(value.fields.map((field) => copyFields(field, ['name', 'kind', 'label'],
288
+ ['placeholder', 'defaultValue', 'required', 'maxLength', 'autoComplete', 'inputMode']))) },
289
+ ['kind', 'fields', 'label', 'run'], ['errorMessage', 'validate']);
290
+ copiedActions.add(copy);
291
+ return copy;
247
292
  }
248
293
 
249
294
  type MutableContent<Slot> = { -readonly [Key in keyof NotificationContent<Slot>]: NotificationContent<Slot>[Key] };