Files
openmotion/packages/design-system/inline-feedback.ts
MasonJJ 35df3061ee fix: complete streamed onboarding in one installation turn (#430)
* fix: complete installation onboarding in the installing turn

* fix: avoid redundant browser steps before onboarding delivery

* fix: preload the template library before the final onboarding reveal

* fix: stream onboarding text and copy unsupported composer drafts

* docs: keep onboarding setup roots independent of supporting skills

* ci: retire the queued onboarding callback test entry

* fix: ship inline onboarding translation dependencies

---------

Co-authored-by: bone3deep1962-collab <bone3deep1962@gmail.com>
2026-11-16 15:47:48 +08:00

24 lines
1001 B
TypeScript

/** Floating action feedback for self-contained, non-React host documents. */
export function createInlineFeedback(root: HTMLElement) {
const doc = root.ownerDocument, win = doc.defaultView!;
const node = doc.createElement('div');
node.className = 'motion-inline-toast'; node.setAttribute('role', 'status');
node.setAttribute('aria-live', 'polite'); node.setAttribute('popover', 'manual'); node.hidden = true;
let timer: number | undefined;
function clear() {
win.clearTimeout(timer); timer = undefined;
try { node.hidePopover?.(); } catch { /* Hosts without a popover layer use fixed positioning. */ }
node.hidden = true;
}
return {
show(text: string) {
clear(); if (!node.isConnected) root.append(node);
node.textContent = text; node.hidden = false;
try { node.showPopover?.(); } catch { /* Keep the fixed-position fallback visible. */ }
timer = win.setTimeout(clear, 3000);
},
clear,
destroy() { clear(); node.remove(); },
};
}