@cloudlet/toast 1.1.2 → 1.2.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/CHANGELOG.md +25 -0
- package/dist/contracts/internal.d.ts +8 -0
- package/dist/contracts/internal.d.ts.map +1 -1
- package/dist/contracts/notifications.d.ts +1 -1
- package/dist/contracts/notifications.d.ts.map +1 -1
- package/dist/core/bridge.js +1 -0
- package/dist/core/bridge.js.map +1 -1
- package/dist/core/controller.d.ts +2 -1
- package/dist/core/controller.d.ts.map +1 -1
- package/dist/core/controller.js +45 -41
- package/dist/core/controller.js.map +1 -1
- package/dist/react/card.d.ts.map +1 -1
- package/dist/react/card.js +2 -0
- package/dist/react/card.js.map +1 -1
- package/dist/react/host.d.ts.map +1 -1
- package/dist/react/host.js +225 -194
- package/dist/react/host.js.map +1 -1
- package/dist/react.d.ts +7 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/contracts/internal.ts +4 -0
- package/src/contracts/notifications.ts +1 -0
- package/src/core/bridge.ts +2 -0
- package/src/core/controller.ts +23 -16
- package/src/react/card.tsx +2 -1
- package/src/react/host.tsx +41 -4
- package/src/react.ts +7 -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:#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}}
|
|
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-clear,.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-clear,.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-clear,.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-clear[data-armed=true]:hover{background:color-mix(in oklab, var(--cloudlet-error) 22%, transparent)}.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:none;grid-template-columns:1fr auto 1fr;align-items:center;column-gap:8px;padding:0 16px 6px;font-size:.75rem;display:grid}.cloudlet-host .cloudlet-indicator>:is(.cloudlet-dots,.cloudlet-page){grid-column:2}.cloudlet-host .cloudlet-dots{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 button.cloudlet-clear{overflow-wrap:normal;grid-column:3;justify-self:end;font-size:.75rem;display:grid}.cloudlet-host .cloudlet-clear>*{grid-area:1/1;transition:opacity .2s,visibility .2s}.cloudlet-host .cloudlet-clear[data-armed=true]>:first-child,.cloudlet-host .cloudlet-clear[data-armed=false]>:last-child{opacity:0;visibility:hidden}.cloudlet-host .cloudlet-clear[data-armed=true]{color:color-mix(in oklab, var(--cloudlet-error) 70%, var(--cloudlet-foreground));background:color-mix(in oklab, var(--cloudlet-error) 14%, transparent)}.cloudlet-host .cloudlet-overflow{flex-wrap:wrap;grid-column:1/-1;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}.cloudlet-host:not([data-reduced-motion=true]) .cloudlet-clear>*{transition:opacity .2s,filter .2s,visibility .2s}.cloudlet-host:not([data-reduced-motion=true]) .cloudlet-clear[data-armed=true]>:first-child,.cloudlet-host:not([data-reduced-motion=true]) .cloudlet-clear[data-armed=false]>:last-child{filter:blur(2px)}}@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-clear,.cloudlet-overflow button){border:1px solid buttontext}.cloudlet-host .cloudlet-clear[data-armed=true]{border-width:2px}.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
|
@@ -160,6 +160,10 @@ export interface RendererBridge<Slot = never> {
|
|
|
160
160
|
readonly acknowledgeOverflow: (lease: HostLease) => BridgeResult;
|
|
161
161
|
readonly acknowledgeAnnouncements: (lease: HostLease, acknowledgements: readonly AnnouncementAcknowledgement[]) => BridgeResult;
|
|
162
162
|
readonly dismiss: (lease: HostLease, handle: NotificationHandle, reason: RendererCloseReason) => MutationResult | { readonly status: 'rejected'; readonly reason: 'stale-lease' };
|
|
163
|
+
/** The open Island's clear button: removes every record (`reason: 'clear-button'`) and acknowledges the missed count. */
|
|
164
|
+
readonly clearAll: (lease: HostLease) =>
|
|
165
|
+
| { readonly status: 'cleared'; readonly count: number }
|
|
166
|
+
| { readonly status: 'rejected'; readonly reason: 'disposed' | 'stale-lease' | 'island-closed' };
|
|
163
167
|
/** Runs a command, or validates and submits a form. */
|
|
164
168
|
readonly invokeAction: (lease: HostLease, handle: NotificationHandle) => ActionResult;
|
|
165
169
|
readonly setFormValue: (lease: HostLease, handle: NotificationHandle, name: string, value: string) =>
|
package/src/core/bridge.ts
CHANGED
|
@@ -214,6 +214,8 @@ function createRendererBridge<Slot>(k: ControllerKernel<Slot>): RendererBridge<S
|
|
|
214
214
|
if (!['close-button', 'swipe', 'navigation'].includes(reason)) return reject('invalid-input');
|
|
215
215
|
return k.dismiss(handle, reason);
|
|
216
216
|
}),
|
|
217
|
+
// The button lives only in the open Island.
|
|
218
|
+
clearAll: withLease(() => k.island ? k.clear('clear-button') : reject('island-closed')),
|
|
217
219
|
invokeAction: withLease(k.withRecord((record) => {
|
|
218
220
|
const handle = record.handle;
|
|
219
221
|
const action = record.content.action;
|
package/src/core/controller.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CloudletController, ControllerOptions, FocusTarget } from '../contracts/controller.js';
|
|
1
|
+
import type { ClearResult, CloudletController, ControllerOptions, FocusTarget } from '../contracts/controller.js';
|
|
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 {
|
|
@@ -130,6 +130,7 @@ export interface ControllerKernel<Slot> {
|
|
|
130
130
|
readonly setHostAutoDismiss: (value: boolean | undefined) => void;
|
|
131
131
|
readonly dismiss: (handle: NotificationHandle, reason: CloseReason) => typeof APPLIED | Rejected<HandleRejection | 'disposed'>;
|
|
132
132
|
readonly acknowledgeOverflow: () => typeof APPLIED | typeof UNCHANGED | Rejected<'disposed'>;
|
|
133
|
+
readonly clear: (reason: 'clear' | 'clear-button') => ClearResult;
|
|
133
134
|
readonly reportRendererLoadError: (error: unknown) => void;
|
|
134
135
|
}
|
|
135
136
|
|
|
@@ -469,14 +470,28 @@ export function createCloudletCore<Slot = never, Signal extends CancellationSign
|
|
|
469
470
|
}
|
|
470
471
|
const dismiss = withRecord((record, reason: CloseReason) =>
|
|
471
472
|
mutate((deliveries) => remove(record, reason, deliveries)));
|
|
473
|
+
function forgetOverflow(deliveries: Delivery[]) {
|
|
474
|
+
deliveries.push({ type: 'overflow-acknowledged', count: overflow });
|
|
475
|
+
overflow = overflowAnnounced = 0;
|
|
476
|
+
if (focusRequest?.target.kind === 'overflow') focusRequest = null;
|
|
477
|
+
}
|
|
472
478
|
function acknowledgeOverflow() {
|
|
473
479
|
if (disposed) return reject('disposed');
|
|
474
480
|
if (!overflow) return UNCHANGED;
|
|
475
|
-
return mutate(
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
481
|
+
return mutate(forgetOverflow);
|
|
482
|
+
}
|
|
483
|
+
/** `clear()`, or the Island's clear button, which also acknowledges the missed count: nothing is left. */
|
|
484
|
+
function clear(reason: 'clear' | 'clear-button'): ClearResult {
|
|
485
|
+
if (disposed) return reject('disposed');
|
|
486
|
+
const count = records.size;
|
|
487
|
+
const acknowledge = reason === 'clear-button' && overflow > 0;
|
|
488
|
+
if (count || acknowledge) {
|
|
489
|
+
mutate((deliveries) => {
|
|
490
|
+
for (const record of records.values()) remove(record, reason, deliveries);
|
|
491
|
+
if (acknowledge) forgetOverflow(deliveries);
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
return { status: 'cleared', count };
|
|
480
495
|
}
|
|
481
496
|
function subscribe<T>(set: Set<T>, listener: T): Unsubscribe {
|
|
482
497
|
if (typeof listener !== 'function') throw new TypeError('Listener must be a function');
|
|
@@ -802,15 +817,7 @@ export function createCloudletCore<Slot = never, Signal extends CancellationSign
|
|
|
802
817
|
}),
|
|
803
818
|
getHandle: (id) => !disposed && typeof id === 'string' ? records.get(id)?.handle : undefined,
|
|
804
819
|
dismiss: (handle) => dismiss(handle, 'programmatic'),
|
|
805
|
-
clear()
|
|
806
|
-
if (disposed) return reject('disposed');
|
|
807
|
-
const count = records.size;
|
|
808
|
-
if (!count) return { status: 'cleared', count };
|
|
809
|
-
mutate((deliveries) => {
|
|
810
|
-
for (const record of records.values()) remove(record, 'clear', deliveries);
|
|
811
|
-
});
|
|
812
|
-
return { status: 'cleared', count };
|
|
813
|
-
},
|
|
820
|
+
clear: () => clear('clear'),
|
|
814
821
|
requestFocus(target: FocusTarget = { kind: 'anchor' }) {
|
|
815
822
|
if (disposed) return reject('disposed');
|
|
816
823
|
if (target?.kind === 'notification') {
|
|
@@ -876,7 +883,7 @@ export function createCloudletCore<Slot = never, Signal extends CancellationSign
|
|
|
876
883
|
get focused() { return focused; }, set focused(value) { focused = value; },
|
|
877
884
|
get overflowAnnounced() { return overflowAnnounced; }, set overflowAnnounced(value) { overflowAnnounced = value; },
|
|
878
885
|
token, diagnostic, failure, mutate, commit, settle, assign, newest, formOf, handleError, withRecord,
|
|
879
|
-
autoDismissing, setHostAutoDismiss, dismiss, acknowledgeOverflow,
|
|
886
|
+
autoDismissing, setHostAutoDismiss, dismiss, acknowledgeOverflow, clear,
|
|
880
887
|
reportRendererLoadError(error) {
|
|
881
888
|
if (!disposed) diagnostic({ code: 'renderer-load-error', source: 'Toaster', message: 'Toaster renderer failed to load', error });
|
|
882
889
|
},
|
package/src/react/card.tsx
CHANGED
|
@@ -10,7 +10,8 @@ export const defaultLabels: CloudletLabels = {
|
|
|
10
10
|
region: 'Notifications', island: 'Current notifications', carousel: 'carousel', slide: 'slide',
|
|
11
11
|
close: 'Close notification', retry: 'Retry',
|
|
12
12
|
cancel: 'Request cancellation', cancellationRequested: 'Cancellation requested',
|
|
13
|
-
acknowledgeOverflow: 'Acknowledge missed notifications',
|
|
13
|
+
acknowledgeOverflow: 'Acknowledge missed notifications', clearAll: 'Clear all', clearAllConfirm: count => `Clear ${count}`,
|
|
14
|
+
collapse: 'Press Escape to collapse',
|
|
14
15
|
stackSummary: (title, count, missed) => [title, ...(count > 1 ? [`${count} notifications`] : []),
|
|
15
16
|
...(missed > 0 ? [`${missed} missed`] : [])].join(', '),
|
|
16
17
|
page: (index, total) => `${index} of ${total}`,
|
package/src/react/host.tsx
CHANGED
|
@@ -91,6 +91,8 @@ const rulePaths = {
|
|
|
91
91
|
} as const;
|
|
92
92
|
type Rule = keyof typeof rulePaths;
|
|
93
93
|
|
|
94
|
+
/** Milliseconds the clear button waits for its second press. */
|
|
95
|
+
const CLEAR_CONFIRM = 3000;
|
|
94
96
|
const clamp01 = (value: number) => Math.max(0, Math.min(1, value));
|
|
95
97
|
/** Native `inert` without relying on React 19's boolean prop (React 18.2 is supported). */
|
|
96
98
|
const inertRef = (node: HTMLElement | null) => node?.setAttribute('inert', '');
|
|
@@ -168,6 +170,9 @@ function createHostRuntime(owner: Host) {
|
|
|
168
170
|
let gestureTarget: { readonly handle: NotificationHandle; readonly open: boolean } | null = null;
|
|
169
171
|
/** A committed swipe dismiss: its exit snapshot keeps flying from the release point. */
|
|
170
172
|
let fling: (Fling & { readonly handle: NotificationHandle }) | null = null;
|
|
173
|
+
/** The clear button's first press arms it; a second press within `CLEAR_CONFIRM` clears the stack. */
|
|
174
|
+
let armed = false;
|
|
175
|
+
let disarmTimer: number | undefined;
|
|
171
176
|
// Formatter failures found during render are reported after commit, once per function.
|
|
172
177
|
const failedFormatters = new WeakSet<object>();
|
|
173
178
|
const formatterErrors: unknown[] = [];
|
|
@@ -750,7 +755,8 @@ function createHostRuntime(owner: Host) {
|
|
|
750
755
|
const root = rootRef.current;
|
|
751
756
|
const active = doc.activeElement;
|
|
752
757
|
if (!root || !view || !(active instanceof view.HTMLElement) || active === root || !root.contains(active)
|
|
753
|
-
|
|
758
|
+
// `clearAll` turning false removes the clear button without a snapshot change.
|
|
759
|
+
|| (structure(previous.snapshot) === structure(owner.props.snapshot) && clearable(previous) === clearable(owner.props))) return pending;
|
|
754
760
|
// The commit may remove or hide the focused branch: park focus on the stable anchor
|
|
755
761
|
// (or outside after the last record) before React mutates the DOM.
|
|
756
762
|
focusedBefore = active;
|
|
@@ -771,6 +777,8 @@ function createHostRuntime(owner: Host) {
|
|
|
771
777
|
const target = primaryFocus() ?? rootRef.current?.querySelector<HTMLElement>('[data-cloudlet-overflow]') ?? null;
|
|
772
778
|
if (!restoreFocus(target)) rootRef.current?.focus({ preventScroll: true });
|
|
773
779
|
}
|
|
780
|
+
// The button left (collapse, the stack shrank, the prop): the next one starts unarmed.
|
|
781
|
+
if (armed && !clearable(owner.props)) disarm(false);
|
|
774
782
|
motion?.setTimeScale(owner.props.options.motion?.timeScale);
|
|
775
783
|
syncConstants();
|
|
776
784
|
// A swipe never continues on another record or state (arrival, programmatic dismiss, Escape).
|
|
@@ -788,6 +796,7 @@ function createHostRuntime(owner: Host) {
|
|
|
788
796
|
function componentWillUnmount() {
|
|
789
797
|
swipe?.dispose(); swipe = null;
|
|
790
798
|
peek = null; fling = null;
|
|
799
|
+
disarm(false);
|
|
791
800
|
announcer.dispose();
|
|
792
801
|
mounted = false;
|
|
793
802
|
cleanup?.(); cleanup = null;
|
|
@@ -805,6 +814,24 @@ function createHostRuntime(owner: Host) {
|
|
|
805
814
|
(active as HTMLElement | null)?.blur();
|
|
806
815
|
}
|
|
807
816
|
}
|
|
817
|
+
function disarm(update = true) {
|
|
818
|
+
view?.clearTimeout(disarmTimer);
|
|
819
|
+
disarmTimer = undefined;
|
|
820
|
+
if (!armed) return;
|
|
821
|
+
armed = false;
|
|
822
|
+
if (update && mounted) owner.forceUpdate();
|
|
823
|
+
}
|
|
824
|
+
function pressClear() {
|
|
825
|
+
if (armed) {
|
|
826
|
+
disarm();
|
|
827
|
+
bridge.clearAll(lease);
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
armed = true;
|
|
831
|
+
disarmTimer = view?.setTimeout(disarm, CLEAR_CONFIRM);
|
|
832
|
+
owner.forceUpdate();
|
|
833
|
+
}
|
|
834
|
+
const clearable = (props: HostProps) => props.options.clearAll !== false && shellView(props.snapshot).open && props.snapshot.stack.length > 1;
|
|
808
835
|
const navigate = (handle: NotificationHandle) => {
|
|
809
836
|
navigating = handle;
|
|
810
837
|
if (bridge.dismiss(lease, handle, 'navigation').status !== 'applied') navigating = null;
|
|
@@ -849,6 +876,7 @@ function createHostRuntime(owner: Host) {
|
|
|
849
876
|
const tails = Math.min(2, Math.max(current.depth, heldTails));
|
|
850
877
|
const slot = presented ? slotRenderer(bridge, lease, presented.handle, rejectSlotFocus) : null;
|
|
851
878
|
const page = format(labels.page, defaultLabels.page, index + 1, total);
|
|
879
|
+
const confirm = format(labels.clearAllConfirm, defaultLabels.clearAllConfirm, total);
|
|
852
880
|
const part = partClasses(options.classNames);
|
|
853
881
|
return <>
|
|
854
882
|
{options.offsets && <OffsetStyles key={options.nonce ?? ''} instance={instance} offsets={options.offsets} nonce={options.nonce} />}
|
|
@@ -871,7 +899,8 @@ function createHostRuntime(owner: Host) {
|
|
|
871
899
|
const target = (event.target as Element).closest('button');
|
|
872
900
|
// A double click must not fire a one-shot action twice; close, the pill and the dots are
|
|
873
901
|
// repeatable on purpose (each click dismisses or shows another record).
|
|
874
|
-
|
|
902
|
+
// The clear button counts too: a double click must not arm and confirm it at once.
|
|
903
|
+
const oneShot = !!target?.matches('[data-cloudlet-control="action"], [data-cloudlet-control="retry"], [data-cloudlet-control="cancel"], [data-cloudlet-control="clear"]');
|
|
875
904
|
if (target && (repeating || (oneShot && event.detail > 1) || (activation && activation !== target))) { event.preventDefault(); event.stopPropagation(); }
|
|
876
905
|
activation = null;
|
|
877
906
|
}}
|
|
@@ -908,11 +937,19 @@ function createHostRuntime(owner: Host) {
|
|
|
908
937
|
{presented && open && closeButton(labels, part, () => bridge.dismiss(lease, presented.handle, 'close-button'))}
|
|
909
938
|
{open && (total > 1 || missed > 0) && <div className={part('indicator', 'cloudlet-indicator')}>{total > 5
|
|
910
939
|
? <p className="cloudlet-page" aria-hidden="true"><span className="cloudlet-page-value">{page}</span><span className="cloudlet-page-out" /></p>
|
|
911
|
-
: total > 1 && snapshot.stack.map((handle, position) =>
|
|
940
|
+
: total > 1 && <div className="cloudlet-dots">{snapshot.stack.map((handle, position) =>
|
|
912
941
|
<button key={handle.generation} type="button" className="cloudlet-dot-button" aria-current={position === index ? 'true' : undefined}
|
|
913
942
|
aria-label={format(labels.page, defaultLabels.page, position + 1, total)} onClick={() => bridge.navigate(lease, handle)}>
|
|
914
943
|
<span className="cloudlet-dot" aria-hidden="true" />
|
|
915
|
-
</button>)}
|
|
944
|
+
</button>)}</div>}
|
|
945
|
+
{clearable(owner.props) && <>
|
|
946
|
+
{/* Both labels share one cell, so the button keeps its width when it arms. */}
|
|
947
|
+
<button type="button" className={part('clear', 'cloudlet-clear')} data-cloudlet-control="clear" data-armed={armed}
|
|
948
|
+
onClick={pressClear} onBlur={() => disarm()}>
|
|
949
|
+
<span aria-hidden={armed || undefined}>{labels.clearAll}</span><span aria-hidden={!armed || undefined}>{confirm}</span>
|
|
950
|
+
</button>
|
|
951
|
+
<span role="status" className="cloudlet-live">{armed ? confirm : ''}</span>
|
|
952
|
+
</>}
|
|
916
953
|
{missed > 0 && <div className={part('overflow', 'cloudlet-overflow')}>
|
|
917
954
|
<p>{format(labels.overflowCount, defaultLabels.overflowCount, missed)}</p>
|
|
918
955
|
<button type="button" data-cloudlet-overflow="" onClick={() => bridge.acknowledgeOverflow(lease)}>{labels.acknowledgeOverflow}</button>
|
package/src/react.ts
CHANGED
|
@@ -50,6 +50,10 @@ export interface CloudletLabels {
|
|
|
50
50
|
readonly cancel: string;
|
|
51
51
|
readonly cancellationRequested: string;
|
|
52
52
|
readonly acknowledgeOverflow: string;
|
|
53
|
+
/** The Island's clear button. */
|
|
54
|
+
readonly clearAll: string;
|
|
55
|
+
/** The clear button after the first press: a second press clears this many notifications. */
|
|
56
|
+
readonly clearAllConfirm: (count: number) => string;
|
|
53
57
|
/** Hidden hint that Escape collapses the Island. */
|
|
54
58
|
readonly collapse: string;
|
|
55
59
|
/** Name of the collapsed stack button: top title, records in the stack, missed notifications. */
|
|
@@ -160,7 +164,7 @@ export interface ToasterMotion {
|
|
|
160
164
|
|
|
161
165
|
/** Styling hooks of the renderer; see `ToasterProps.classNames`. */
|
|
162
166
|
export type CloudletPart = 'host' | 'stack' | 'pill' | 'tail' | 'badge' | 'island' | 'header' | 'icon' | 'title'
|
|
163
|
-
| 'close' | 'body' | 'description' | 'actions' | 'action' | 'indicator' | 'overflow' | 'form' | 'field' | 'field-error';
|
|
167
|
+
| 'close' | 'body' | 'description' | 'actions' | 'action' | 'indicator' | 'clear' | 'overflow' | 'form' | 'field' | 'field-error';
|
|
164
168
|
|
|
165
169
|
export interface ToasterProps {
|
|
166
170
|
readonly position?: 'auto' | 'top-center' | 'bottom-center';
|
|
@@ -176,6 +180,8 @@ export interface ToasterProps {
|
|
|
176
180
|
readonly attention?: ToasterAttention;
|
|
177
181
|
/** Overrides the controller's `autoDismiss` while defined; changes apply without remount. */
|
|
178
182
|
readonly autoDismiss?: boolean;
|
|
183
|
+
/** The clear button in the open Island with two or more notifications; default true. Read on every render. */
|
|
184
|
+
readonly clearAll?: boolean;
|
|
179
185
|
/** Read on every render. */
|
|
180
186
|
readonly motion?: ToasterMotion;
|
|
181
187
|
/** Extra classes per part, added to the own `cloudlet-*` classes (never replacing them). Read on every render. */
|