@cloudlet/toast 1.4.0-rc.1 → 1.5.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.
Files changed (83) hide show
  1. package/CHANGELOG.md +181 -0
  2. package/README.md +30 -5
  3. package/dist/agent.d.ts.map +1 -1
  4. package/dist/agent.js +19 -15
  5. package/dist/agent.js.map +1 -1
  6. package/dist/center-react.d.ts +286 -0
  7. package/dist/center-react.d.ts.map +1 -0
  8. package/dist/center-react.js +2 -0
  9. package/dist/center.d.ts +3 -0
  10. package/dist/center.d.ts.map +1 -0
  11. package/dist/center.js +1 -0
  12. package/dist/core/agent-port.d.ts +2 -0
  13. package/dist/core/agent-port.d.ts.map +1 -1
  14. package/dist/core/agent-port.js +3 -0
  15. package/dist/core/agent-port.js.map +1 -1
  16. package/dist/react/card.d.ts +4 -0
  17. package/dist/react/card.d.ts.map +1 -1
  18. package/dist/react/card.js +3 -8
  19. package/dist/react/card.js.map +1 -1
  20. package/dist/react/center-backdrop.d.ts +69 -0
  21. package/dist/react/center-backdrop.d.ts.map +1 -0
  22. package/dist/react/center-backdrop.js +81 -0
  23. package/dist/react/center-backdrop.js.map +1 -0
  24. package/dist/react/center-clear.d.ts +16 -0
  25. package/dist/react/center-clear.d.ts.map +1 -0
  26. package/dist/react/center-clear.js +24 -0
  27. package/dist/react/center-clear.js.map +1 -0
  28. package/dist/react/center-gestures.d.ts +47 -0
  29. package/dist/react/center-gestures.d.ts.map +1 -0
  30. package/dist/react/center-gestures.js +74 -0
  31. package/dist/react/center-gestures.js.map +1 -0
  32. package/dist/react/center-motion.d.ts +174 -0
  33. package/dist/react/center-motion.d.ts.map +1 -0
  34. package/dist/react/center-motion.js +344 -0
  35. package/dist/react/center-motion.js.map +1 -0
  36. package/dist/react/center.d.ts +15 -0
  37. package/dist/react/center.d.ts.map +1 -0
  38. package/dist/react/center.js +1287 -0
  39. package/dist/react/center.js.map +1 -0
  40. package/dist/react/focus.d.ts +7 -0
  41. package/dist/react/focus.d.ts.map +1 -0
  42. package/dist/react/focus.js +14 -0
  43. package/dist/react/focus.js.map +1 -0
  44. package/dist/react/gestures.d.ts +33 -2
  45. package/dist/react/gestures.d.ts.map +1 -1
  46. package/dist/react/gestures.js +181 -149
  47. package/dist/react/gestures.js.map +1 -1
  48. package/dist/react/host.d.ts.map +1 -1
  49. package/dist/react/host.js +287 -283
  50. package/dist/react/host.js.map +1 -1
  51. package/dist/react/motion.d.ts +18 -11
  52. package/dist/react/motion.d.ts.map +1 -1
  53. package/dist/react/motion.js +6 -3
  54. package/dist/react/motion.js.map +1 -1
  55. package/dist/react/reduced.d.ts +24 -0
  56. package/dist/react/reduced.d.ts.map +1 -0
  57. package/dist/react/reduced.js +35 -0
  58. package/dist/react/reduced.js.map +1 -0
  59. package/dist/react/zoom.d.ts +12 -0
  60. package/dist/react/zoom.d.ts.map +1 -0
  61. package/dist/react/zoom.js +21 -0
  62. package/dist/react/zoom.js.map +1 -0
  63. package/dist/react.d.ts +4 -0
  64. package/dist/react.d.ts.map +1 -1
  65. package/dist/styles.css +1 -1
  66. package/package.json +3 -2
  67. package/src/agent.ts +11 -6
  68. package/src/center-react.ts +300 -0
  69. package/src/center.ts +27 -0
  70. package/src/core/agent-port.ts +3 -0
  71. package/src/react/card.tsx +5 -6
  72. package/src/react/center-backdrop.tsx +151 -0
  73. package/src/react/center-clear.ts +56 -0
  74. package/src/react/center-gestures.ts +143 -0
  75. package/src/react/center-motion.ts +504 -0
  76. package/src/react/center.tsx +1557 -0
  77. package/src/react/focus.ts +18 -0
  78. package/src/react/gestures.ts +127 -37
  79. package/src/react/host.tsx +17 -5
  80. package/src/react/motion.ts +16 -9
  81. package/src/react/reduced.ts +52 -0
  82. package/src/react/zoom.ts +26 -0
  83. package/src/react.ts +4 -0
package/dist/center.js ADDED
@@ -0,0 +1 @@
1
+ export { NotificationCenter, useNotificationCenter } from "./center-react.js";
@@ -79,6 +79,8 @@ export interface ToasterPort<Slot> {
79
79
  * events themselves only after its state listeners.
80
80
  */
81
81
  readonly subscribe: (listener: (commit: PortCommit<Slot>) => void) => () => void;
82
+ /** Hands an error of the reader's own listeners to the controller's diagnostics, one each. */
83
+ readonly report: (error: unknown) => void;
82
84
  /** Opens the Island on the top notification, unless a person is busy with the Toaster. */
83
85
  readonly open: () => Changed | Rejection<'disposed' | 'no-host' | 'empty' | 'busy'>;
84
86
  /** Collapses the Island, unless it holds a draft. */
@@ -1 +1 @@
1
- {"version":3,"file":"agent-port.d.ts","sourceRoot":"","sources":["../../src/core/agent-port.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,0BAA0B,CAAC;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAiE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAoB,MAAM,iBAAiB,CAAC;AAUvJ,+GAA+G;AAC/G,MAAM,WAAW,WAAW;IAC1B,yFAAyF;IACzF,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,wFAAwF;IACxF,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACnD,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc,CAAC,IAAI;IAClC,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC9C,qDAAqD;IACrD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,0FAA0F;IAC1F,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,+CA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E,SAAS,CAAA;KAAE,GAAG,SAAS,CAAC,YAAY,GAAG,cAAc,GAAG,eAAe,GAAG,iBAAiB,CAAC,CAAC;IAChK,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAClE,OAAO,GAAG,SAAS,CAAC,YAAY,GAAG,SAAS,GAAG,eAAe,GAAG,iBAAiB,GAAG,UAAU,GAAG,cAAc,CAAC,CAAC;IACvH;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,KACpF,OAAO,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC,YAAY,GAAG,YAAY,GAAG,iBAAiB,GAAG,OAAO,CAAC,CAAC;CACnG;AAID,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CA2E7E"}
@@ -38,6 +38,9 @@ function s(i) {
38
38
  closedBy: t.closedBy
39
39
  });
40
40
  }),
41
+ report: (e) => {
42
+ o.failure("listener-error", "subscribe", e);
43
+ },
41
44
  open() {
42
45
  if (o.disposed) return n("disposed");
43
46
  if (o.lease === null) return n("no-host");
@@ -1 +1 @@
1
- {"version":3,"file":"agent-port.js","names":["freeze","STRICTNESS","createToasterPort","k","getControllerKernel","controller","source","mounted","reading","read","next","lease","forms","form","filled","name","withRecord","commit","listener","delivery","reject","record","UNCHANGED","handle","result","fillFormValue","value","press","grant","signal","action","settled","token","finish","stopState","stopEvents","abort","resolve","outcome","event","state","started","invokeAction"],"sources":["../../src/core/agent-port.ts"],"sourcesContent":["import type { ChangeSource } from '../contracts/events.js';\nimport type { NotificationHandle } from '../contracts/identity.js';\nimport type { FormErrors, RendererSnapshot } from '../contracts/internal.js';\nimport type { CancellationSignal, CancelResult } from '../contracts/operations.js';\nimport type { ControllerSnapshot } from '../contracts/snapshots.js';\nimport { fillFormValue, invokeAction } from './actions.js';\nimport { UNCHANGED, getControllerKernel, reject, type ControllerKernel, type EventPayload, type FieldAuthor, type RecordState } from './controller.js';\n\n// The agent adapter's way into a controller. Only the `agent` entry imports it, so the root entry\n// and the renderer chunk never carry it. It hands out no lease: a step that needs a screen only\n// checks that a `Toaster` holds one, and no step asks for focus. Form values reach the adapter only\n// as \"holds text\" and who wrote them: `forms` is reduced here, and `controller` is typed as the\n// public snapshot, although at runtime it is the renderer's object with its form drafts.\n\nconst freeze = Object.freeze;\n\n/** What a reader may know about a form: which fields hold text, who wrote them, the last submit's messages. */\nexport interface FormReading {\n /** Names of the fields whose value has non-blank text, the same test `required` uses. */\n readonly filled: ReadonlySet<string>;\n /** Who wrote each field last; a field nobody wrote and without a default is missing. */\n readonly authors: ReadonlyMap<string, FieldAuthor>;\n readonly errors: FormErrors;\n}\n\nexport interface ToasterReading<Slot> {\n readonly controller: ControllerSnapshot<Slot>;\n /** A `Toaster` holds the controller's host lease. */\n readonly mounted: boolean;\n /** A person is on the Toaster: hover, focus, a gesture, or a draft in the open Island. */\n readonly busy: boolean;\n /** One entry per record with a form action. */\n readonly forms: ReadonlyMap<NotificationHandle, FormReading>;\n}\n\n/** An event as the commit queued it: its type, source and fields, before it is stamped and delivered. */\nexport type PortEvent = EventPayload;\n\n/**\n * One committed change: its events and the state it left. A listener of an earlier commit may have\n * committed again, so `read()` can be ahead of this state.\n */\nexport interface PortCommit<Slot> {\n readonly events: readonly PortEvent[];\n readonly controller: ControllerSnapshot<Slot>;\n /** Who wrote each field of each form last; never a value. */\n readonly authors: ReadonlyMap<NotificationHandle, ReadonlyMap<string, FieldAuthor>>;\n /** Who closed the Island last; null before the first close. */\n readonly closedBy: ChangeSource | null;\n}\n\n/** The grant a step was approved under; a marker stricter than it stops the step. */\nexport type StepGrant = 'allow' | 'confirm';\n\ntype Rejection<Reason extends string> = { readonly status: 'rejected'; readonly reason: Reason };\ntype HandleReason = 'disposed' | 'invalid-handle' | 'foreign-controller' | 'stale-handle';\ntype Changed = { readonly status: 'applied' | 'unchanged' };\n\n/** How a pressed command or a submitted form ended, as far as the step waited for it. */\nexport type PressOutcome =\n /** The action succeeded and closed its notification. */\n | { readonly status: 'done' }\n /** The action failed; `message` is what the person sees. */\n | { readonly status: 'failed'; readonly message: string }\n /** The form did not pass its checks and was not sent; the person sees the same messages. */\n | { readonly status: 'invalid'; readonly errors: FormErrors }\n /** The form's `validate` replaced the action it was checking; neither ran. */\n | { readonly status: 'replaced' }\n /** The step stopped waiting: the notification closed otherwise, the action was replaced, or the signal ended the wait. */\n | { readonly status: 'pending'; readonly gone: boolean };\n\nexport interface ToasterPort<Slot> {\n /** The same object until the controller publishes again. */\n readonly read: () => ToasterReading<Slot>;\n /**\n * Calls `listener` after every committed change with that commit's events and state, so a reader\n * learns what happened and who did it together with the new state. The controller delivers the\n * events themselves only after its state listeners.\n */\n readonly subscribe: (listener: (commit: PortCommit<Slot>) => void) => () => void;\n /** Opens the Island on the top notification, unless a person is busy with the Toaster. */\n readonly open: () => Changed | Rejection<'disposed' | 'no-host' | 'empty' | 'busy'>;\n /** Collapses the Island, unless it holds a draft. */\n readonly close: () => Changed | Rejection<'disposed' | 'busy'>;\n /** Opens the Island on the notification or moves the open one to it, unless a person is busy. */\n readonly show: (handle: NotificationHandle) => Changed | Rejection<HandleReason | 'no-host' | 'busy'>;\n /**\n * Brings the notification in front of the person for a step only they may take: opens the Island\n * on it now, or once they stop interacting (`waiting`). Never moves focus.\n */\n readonly summon: (handle: NotificationHandle) => { readonly status: 'shown' | 'waiting' | 'unchanged' } | Rejection<HandleReason | 'no-host'>;\n readonly dismiss: (handle: NotificationHandle) => Changed | Rejection<HandleReason>;\n readonly clear: () => { readonly status: 'cleared'; readonly count: number } | Rejection<'disposed'>;\n readonly acknowledge: () => Changed | Rejection<'disposed'>;\n readonly cancel: (handle: NotificationHandle) => CancelResult | Rejection<HandleReason | 'no-operation'>;\n readonly retry: (handle: NotificationHandle) => { readonly status: 'started' } | Rejection<HandleReason | 'no-operation' | 'not-retryable' | 'already-pending'>;\n /** Writes a form field as an agent, never over what the person typed. */\n readonly fill: (handle: NotificationHandle, name: string, value: string)\n => Changed | Rejection<HandleReason | 'no-form' | 'invalid-input' | 'already-pending' | 'too-long' | 'person-typed'>;\n /**\n * Starts the command or submits the form, and waits until it settles, its notification closes or\n * `signal` aborts.\n */\n readonly press: (handle: NotificationHandle, grant: StepGrant, signal: CancellationSignal)\n => Promise<PressOutcome> | Rejection<HandleReason | 'no-command' | 'already-pending' | 'stale'>;\n}\n\nconst STRICTNESS = { allow: 0, confirm: 1, deny: 2 } as const;\n\n/** Throws a TypeError for a controller this package instance did not create. */\nexport function createToasterPort<Slot>(controller: object): ToasterPort<Slot> {\n const k = getControllerKernel<Slot>(controller);\n let source: RendererSnapshot<Slot> | undefined;\n let mounted = false;\n let reading: ToasterReading<Slot> | undefined;\n\n const read = (): ToasterReading<Slot> => {\n // Every change of the lease or of what `interacting` reads publishes a new renderer snapshot.\n const next = k.rendererSnapshot;\n const lease = k.lease !== null;\n if (reading && next === source && lease === mounted) return reading;\n source = next;\n mounted = lease;\n const forms = new Map<NotificationHandle, FormReading>();\n for (const form of next.forms) {\n const filled = new Set(Object.keys(form.values).filter((name) => form.values[name]!.trim() !== ''));\n forms.set(form.handle, freeze({ filled, authors: new Map(Object.entries(form.authors)), errors: form.errors }));\n }\n reading = freeze({ controller: next, mounted, busy: k.interacting(), forms });\n return reading;\n };\n\n const withRecord = k.withRecord;\n\n return freeze<ToasterPort<Slot>>({\n read,\n subscribe: (listener) => k.subscribe(() => {\n const commit = k.announced;\n if (!commit) return;\n listener({\n events: commit.deliveries.filter((delivery): delivery is PortEvent => !('callback' in delivery)),\n controller: commit.snapshot,\n authors: new Map(commit.snapshot.forms.map((form) => [form.handle, new Map(Object.entries(form.authors))])),\n closedBy: commit.closedBy,\n });\n }),\n open() {\n if (k.disposed) return reject('disposed');\n if (k.lease === null) return reject('no-host');\n const record = k.newest();\n if (!record) return reject('empty');\n if (k.island) return UNCHANGED;\n if (k.interacting()) return reject('busy');\n return k.mutate(() => { k.island = { reason: 'attention', current: record, source: 'agent' }; });\n },\n close() {\n if (k.disposed) return reject('disposed');\n if (!k.island) return UNCHANGED;\n // A person's Escape collapses an Island with a draft; an agent is not that person.\n if (k.dirty(k.island.current)) return reject('busy');\n return k.mutate(() => { k.collapse('agent'); });\n },\n show: withRecord((record) => {\n if (k.lease === null) return reject('no-host');\n if (k.island?.current === record) return UNCHANGED;\n if (k.interacting()) return reject('busy');\n // Showing is navigation, as in the renderer: reaching the pending auto-open's record fulfils\n // it, and any other pending auto-open restarts its delay.\n return k.mutate(() => k.reach(record, 'agent'));\n }),\n summon: withRecord((record) => k.lease === null ? reject('no-host') : freeze({ status: k.summon(record) })),\n dismiss: (handle) => k.dismiss(handle, 'programmatic', 'agent'),\n clear: () => k.clear('clear', 'agent'),\n acknowledge: () => k.acknowledgeOverflow('agent'),\n // The current attempt's own capability: no token leaves the port.\n cancel: withRecord((record) => record.operation ? record.operation.cancel(undefined, 'agent') : reject('no-operation')),\n retry: withRecord((record) => {\n if (!record.operation) return reject('no-operation');\n const result = record.operation.retry('agent');\n return result.status === 'started' ? freeze({ status: 'started' as const }) : reject(result.reason);\n }),\n fill: withRecord((record, name: string, value: string) => fillFormValue(k, record, name, value)),\n press: withRecord((record, grant: StepGrant, signal: CancellationSignal) => press(k, record, grant, signal)),\n });\n}\n\nfunction press<Slot>(k: ControllerKernel<Slot>, record: RecordState<Slot>, grant: StepGrant, signal: CancellationSignal) {\n const action = record.content.action;\n if (!action || action.kind === 'link') return reject('no-command');\n // The marker is read from the record's content right before the action runs: one the app made\n // stricter after the step was approved stops it.\n if (STRICTNESS[action.agent ?? 'confirm'] > STRICTNESS[grant]) return reject('stale');\n if (record.action.status === 'pending') return reject('already-pending');\n // A wait that has already ended starts nothing.\n if (signal.aborted) return Promise.resolve<PressOutcome>(freeze({ status: 'pending', gone: false }));\n const handle = record.handle;\n return new Promise<PressOutcome>((resolve) => {\n let settled = false;\n let token: string | undefined;\n const finish = (outcome: PressOutcome): void => {\n if (settled) return;\n settled = true;\n stopState();\n stopEvents();\n signal.removeEventListener('abort', abort);\n resolve(freeze(outcome));\n };\n const abort = (): void => { finish({ status: 'pending', gone: k.records.get(handle.id) !== record }); };\n // Only the closing event says why the notification closed; state listeners run before it.\n const stopEvents = k.onEvent((event) => {\n if (event.type === 'closed' && event.handle === handle) {\n finish(event.reason === 'action-success' ? { status: 'done' } : { status: 'pending', gone: true });\n }\n });\n const stopState = k.subscribe(() => {\n if (token === undefined || k.records.get(handle.id) !== record) return;\n const state = record.action;\n if (state.status === 'failed' && state.token === token) finish({ status: 'failed', message: state.message });\n else if (state.status === 'idle' || state.token !== token) finish({ status: 'pending', gone: false });\n });\n signal.addEventListener('abort', abort, { once: true });\n // Listeners first: the command may close or replace its notification synchronously.\n const started = invokeAction(k, record, 'agent');\n if (started.status === 'invalid') { finish({ status: 'invalid', errors: started.errors }); return; }\n if (started.status !== 'started') {\n finish(started.reason === 'action-replaced' ? { status: 'replaced' } : { status: 'pending', gone: k.records.get(handle.id) !== record });\n return;\n }\n if (settled) return;\n // This press's own attempt: a listener of `action-started` may already have begun another one.\n token = started.token;\n const state = record.action;\n if (state.status === 'failed' && state.token === token) finish({ status: 'failed', message: state.message });\n else if (state.status === 'idle' || state.token !== token) finish({ status: 'pending', gone: false });\n else if (signal.aborted) abort();\n });\n}\n"],"mappings":";;;AAcA,IAAMA,IAAS,OAAO,QA6FhBC,IAAa;CAAE,OAAO;CAAG,SAAS;CAAG,MAAM;AAAE;AAGnD,SAAgBC,EAAwB,GAAuC;CAC7E,IAAMC,IAAIC,EAA0BC,CAAU,GAC1CC,GACAC,IAAU,IACVC,GAEEC,UAAmC;EAEvC,IAAMC,IAAOP,EAAE,kBACTQ,IAAQR,EAAE,UAAU;EAC1B,IAAIK,KAAWE,MAASJ,K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AAO,EAAE,MAAM,GAAK,CAAC;EAEtD,IAAMK,IAAUC,EAAavC,GAAGkB,GAAQ,OAAO;EAC/C,IAAIoB,EAAQ,WAAW,WAAW;GAAE,EAAO;IAAE,QAAQ;IAAW,QAAQA,EAAQ;GAAO,CAAC;GAAG;EAAQ;EACnG,IAAIA,EAAQ,WAAW,WAAW;GAChC,EAAOA,EAAQ,WAAW,oBAAoB,EAAE,QAAQ,WAAW,IAAI;IAAE,QAAQ;IAAW,MAAMtC,EAAE,QAAQ,IAAIoB,EAAO,EAAE,MAAMF;GAAO,CAAC;GACvI;EACF;EACA,IAAIU,GAAS;EAEb,IAAQU,EAAQ;EAChB,IAAMD,IAAQnB,EAAO;EACrB,AAAImB,EAAM,WAAW,YAAYA,EAAM,UAAUR,IAAOC,EAAO;GAAE,QAAQ;GAAU,SAASO,EAAM;EAAQ,CAAC,IAClGA,EAAM,WAAW,UAAUA,EAAM,UAAUR,IAAOC,EAAO;GAAE,QAAQ;GAAW,MAAM;EAAM,CAAC,IAC3FJ,EAAO,WAASO,EAAM;CACjC,CAAC;AACH"}
1
+ {"version":3,"file":"agent-port.js","names":["freeze","STRICTNESS","createToasterPort","k","getControllerKernel","controller","source","mounted","reading","read","next","lease","forms","form","filled","name","withRecord","commit","listener","delivery","error","reject","record","UNCHANGED","handle","result","fillFormValue","value","press","grant","signal","action","settled","token","finish","stopState","stopEvents","abort","resolve","outcome","event","state","started","invokeAction"],"sources":["../../src/core/agent-port.ts"],"sourcesContent":["import type { ChangeSource } from '../contracts/events.js';\nimport type { NotificationHandle } from '../contracts/identity.js';\nimport type { FormErrors, RendererSnapshot } from '../contracts/internal.js';\nimport type { CancellationSignal, CancelResult } from '../contracts/operations.js';\nimport type { ControllerSnapshot } from '../contracts/snapshots.js';\nimport { fillFormValue, invokeAction } from './actions.js';\nimport { UNCHANGED, getControllerKernel, reject, type ControllerKernel, type EventPayload, type FieldAuthor, type RecordState } from './controller.js';\n\n// The agent adapter's way into a controller. Only the `agent` entry imports it, so the root entry\n// and the renderer chunk never carry it. It hands out no lease: a step that needs a screen only\n// checks that a `Toaster` holds one, and no step asks for focus. Form values reach the adapter only\n// as \"holds text\" and who wrote them: `forms` is reduced here, and `controller` is typed as the\n// public snapshot, although at runtime it is the renderer's object with its form drafts.\n\nconst freeze = Object.freeze;\n\n/** What a reader may know about a form: which fields hold text, who wrote them, the last submit's messages. */\nexport interface FormReading {\n /** Names of the fields whose value has non-blank text, the same test `required` uses. */\n readonly filled: ReadonlySet<string>;\n /** Who wrote each field last; a field nobody wrote and without a default is missing. */\n readonly authors: ReadonlyMap<string, FieldAuthor>;\n readonly errors: FormErrors;\n}\n\nexport interface ToasterReading<Slot> {\n readonly controller: ControllerSnapshot<Slot>;\n /** A `Toaster` holds the controller's host lease. */\n readonly mounted: boolean;\n /** A person is on the Toaster: hover, focus, a gesture, or a draft in the open Island. */\n readonly busy: boolean;\n /** One entry per record with a form action. */\n readonly forms: ReadonlyMap<NotificationHandle, FormReading>;\n}\n\n/** An event as the commit queued it: its type, source and fields, before it is stamped and delivered. */\nexport type PortEvent = EventPayload;\n\n/**\n * One committed change: its events and the state it left. A listener of an earlier commit may have\n * committed again, so `read()` can be ahead of this state.\n */\nexport interface PortCommit<Slot> {\n readonly events: readonly PortEvent[];\n readonly controller: ControllerSnapshot<Slot>;\n /** Who wrote each field of each form last; never a value. */\n readonly authors: ReadonlyMap<NotificationHandle, ReadonlyMap<string, FieldAuthor>>;\n /** Who closed the Island last; null before the first close. */\n readonly closedBy: ChangeSource | null;\n}\n\n/** The grant a step was approved under; a marker stricter than it stops the step. */\nexport type StepGrant = 'allow' | 'confirm';\n\ntype Rejection<Reason extends string> = { readonly status: 'rejected'; readonly reason: Reason };\ntype HandleReason = 'disposed' | 'invalid-handle' | 'foreign-controller' | 'stale-handle';\ntype Changed = { readonly status: 'applied' | 'unchanged' };\n\n/** How a pressed command or a submitted form ended, as far as the step waited for it. */\nexport type PressOutcome =\n /** The action succeeded and closed its notification. */\n | { readonly status: 'done' }\n /** The action failed; `message` is what the person sees. */\n | { readonly status: 'failed'; readonly message: string }\n /** The form did not pass its checks and was not sent; the person sees the same messages. */\n | { readonly status: 'invalid'; readonly errors: FormErrors }\n /** The form's `validate` replaced the action it was checking; neither ran. */\n | { readonly status: 'replaced' }\n /** The step stopped waiting: the notification closed otherwise, the action was replaced, or the signal ended the wait. */\n | { readonly status: 'pending'; readonly gone: boolean };\n\nexport interface ToasterPort<Slot> {\n /** The same object until the controller publishes again. */\n readonly read: () => ToasterReading<Slot>;\n /**\n * Calls `listener` after every committed change with that commit's events and state, so a reader\n * learns what happened and who did it together with the new state. The controller delivers the\n * events themselves only after its state listeners.\n */\n readonly subscribe: (listener: (commit: PortCommit<Slot>) => void) => () => void;\n /** Hands an error of the reader's own listeners to the controller's diagnostics, one each. */\n readonly report: (error: unknown) => void;\n /** Opens the Island on the top notification, unless a person is busy with the Toaster. */\n readonly open: () => Changed | Rejection<'disposed' | 'no-host' | 'empty' | 'busy'>;\n /** Collapses the Island, unless it holds a draft. */\n readonly close: () => Changed | Rejection<'disposed' | 'busy'>;\n /** Opens the Island on the notification or moves the open one to it, unless a person is busy. */\n readonly show: (handle: NotificationHandle) => Changed | Rejection<HandleReason | 'no-host' | 'busy'>;\n /**\n * Brings the notification in front of the person for a step only they may take: opens the Island\n * on it now, or once they stop interacting (`waiting`). Never moves focus.\n */\n readonly summon: (handle: NotificationHandle) => { readonly status: 'shown' | 'waiting' | 'unchanged' } | Rejection<HandleReason | 'no-host'>;\n readonly dismiss: (handle: NotificationHandle) => Changed | Rejection<HandleReason>;\n readonly clear: () => { readonly status: 'cleared'; readonly count: number } | Rejection<'disposed'>;\n readonly acknowledge: () => Changed | Rejection<'disposed'>;\n readonly cancel: (handle: NotificationHandle) => CancelResult | Rejection<HandleReason | 'no-operation'>;\n readonly retry: (handle: NotificationHandle) => { readonly status: 'started' } | Rejection<HandleReason | 'no-operation' | 'not-retryable' | 'already-pending'>;\n /** Writes a form field as an agent, never over what the person typed. */\n readonly fill: (handle: NotificationHandle, name: string, value: string)\n => Changed | Rejection<HandleReason | 'no-form' | 'invalid-input' | 'already-pending' | 'too-long' | 'person-typed'>;\n /**\n * Starts the command or submits the form, and waits until it settles, its notification closes or\n * `signal` aborts.\n */\n readonly press: (handle: NotificationHandle, grant: StepGrant, signal: CancellationSignal)\n => Promise<PressOutcome> | Rejection<HandleReason | 'no-command' | 'already-pending' | 'stale'>;\n}\n\nconst STRICTNESS = { allow: 0, confirm: 1, deny: 2 } as const;\n\n/** Throws a TypeError for a controller this package instance did not create. */\nexport function createToasterPort<Slot>(controller: object): ToasterPort<Slot> {\n const k = getControllerKernel<Slot>(controller);\n let source: RendererSnapshot<Slot> | undefined;\n let mounted = false;\n let reading: ToasterReading<Slot> | undefined;\n\n const read = (): ToasterReading<Slot> => {\n // Every change of the lease or of what `interacting` reads publishes a new renderer snapshot.\n const next = k.rendererSnapshot;\n const lease = k.lease !== null;\n if (reading && next === source && lease === mounted) return reading;\n source = next;\n mounted = lease;\n const forms = new Map<NotificationHandle, FormReading>();\n for (const form of next.forms) {\n const filled = new Set(Object.keys(form.values).filter((name) => form.values[name]!.trim() !== ''));\n forms.set(form.handle, freeze({ filled, authors: new Map(Object.entries(form.authors)), errors: form.errors }));\n }\n reading = freeze({ controller: next, mounted, busy: k.interacting(), forms });\n return reading;\n };\n\n const withRecord = k.withRecord;\n\n return freeze<ToasterPort<Slot>>({\n read,\n subscribe: (listener) => k.subscribe(() => {\n const commit = k.announced;\n if (!commit) return;\n listener({\n events: commit.deliveries.filter((delivery): delivery is PortEvent => !('callback' in delivery)),\n controller: commit.snapshot,\n authors: new Map(commit.snapshot.forms.map((form) => [form.handle, new Map(Object.entries(form.authors))])),\n closedBy: commit.closedBy,\n });\n }),\n report: (error) => { k.failure('listener-error', 'subscribe', error); },\n open() {\n if (k.disposed) return reject('disposed');\n if (k.lease === null) return reject('no-host');\n const record = k.newest();\n if (!record) return reject('empty');\n if (k.island) return UNCHANGED;\n if (k.interacting()) return reject('busy');\n return k.mutate(() => { k.island = { reason: 'attention', current: record, source: 'agent' }; });\n },\n close() {\n if (k.disposed) return reject('disposed');\n if (!k.island) return UNCHANGED;\n // A person's Escape collapses an Island with a draft; an agent is not that person.\n if (k.dirty(k.island.current)) return reject('busy');\n return k.mutate(() => { k.collapse('agent'); });\n },\n show: withRecord((record) => {\n if (k.lease === null) return reject('no-host');\n if (k.island?.current === record) return UNCHANGED;\n if (k.interacting()) return reject('busy');\n // Showing is navigation, as in the renderer: reaching the pending auto-open's record fulfils\n // it, and any other pending auto-open restarts its delay.\n return k.mutate(() => k.reach(record, 'agent'));\n }),\n summon: withRecord((record) => k.lease === null ? reject('no-host') : freeze({ status: k.summon(record) })),\n dismiss: (handle) => k.dismiss(handle, 'programmatic', 'agent'),\n clear: () => k.clear('clear', 'agent'),\n acknowledge: () => k.acknowledgeOverflow('agent'),\n // The current attempt's own capability: no token leaves the port.\n cancel: withRecord((record) => record.operation ? record.operation.cancel(undefined, 'agent') : reject('no-operation')),\n retry: withRecord((record) => {\n if (!record.operation) return reject('no-operation');\n const result = record.operation.retry('agent');\n return result.status === 'started' ? freeze({ status: 'started' as const }) : reject(result.reason);\n }),\n fill: withRecord((record, name: string, value: string) => fillFormValue(k, record, name, value)),\n press: withRecord((record, grant: StepGrant, signal: CancellationSignal) => press(k, record, grant, signal)),\n });\n}\n\nfunction press<Slot>(k: ControllerKernel<Slot>, record: RecordState<Slot>, grant: StepGrant, signal: CancellationSignal) {\n const action = record.content.action;\n if (!action || action.kind === 'link') return reject('no-command');\n // The marker is read from the record's content right before the action runs: one the app made\n // stricter after the step was approved stops it.\n if (STRICTNESS[action.agent ?? 'confirm'] > STRICTNESS[grant]) return reject('stale');\n if (record.action.status === 'pending') return reject('already-pending');\n // A wait that has already ended starts nothing.\n if (signal.aborted) return Promise.resolve<PressOutcome>(freeze({ status: 'pending', gone: false }));\n const handle = record.handle;\n return new Promise<PressOutcome>((resolve) => {\n let settled = false;\n let token: string | undefined;\n const finish = (outcome: PressOutcome): void => {\n if (settled) return;\n settled = true;\n stopState();\n stopEvents();\n signal.removeEventListener('abort', abort);\n resolve(freeze(outcome));\n };\n const abort = (): void => { finish({ status: 'pending', gone: k.records.get(handle.id) !== record }); };\n // Only the closing event says why the notification closed; state listeners run before it.\n const stopEvents = k.onEvent((event) => {\n if (event.type === 'closed' && event.handle === handle) {\n finish(event.reason === 'action-success' ? { status: 'done' } : { status: 'pending', gone: true });\n }\n });\n const stopState = k.subscribe(() => {\n if (token === undefined || k.records.get(handle.id) !== record) return;\n const state = record.action;\n if (state.status === 'failed' && state.token === token) finish({ status: 'failed', message: state.message });\n else if (state.status === 'idle' || state.token !== token) finish({ status: 'pending', gone: false });\n });\n signal.addEventListener('abort', abort, { once: true });\n // Listeners first: the command may close or replace its notification synchronously.\n const started = invokeAction(k, record, 'agent');\n if (started.status === 'invalid') { finish({ status: 'invalid', errors: started.errors }); return; }\n if (started.status !== 'started') {\n finish(started.reason === 'action-replaced' ? { status: 'replaced' } : { status: 'pending', gone: k.records.get(handle.id) !== record });\n return;\n }\n if (settled) return;\n // This press's own attempt: a listener of `action-started` may already have begun another one.\n token = started.token;\n const state = record.action;\n if (state.status === 'failed' && state.token === token) finish({ status: 'failed', message: state.message });\n else if (state.status === 'idle' || state.token !== token) finish({ status: 'pending', gone: false });\n else if (signal.aborted) abort();\n });\n}\n"],"mappings":";;;AAcA,IAAMA,IAAS,OAAO,QA+FhBC,IAAa;CAAE,OAAO;CAAG,SAAS;CAAG,MAAM;AAAE;AAGnD,SAAgBC,EAAwB,GAAuC;CAC7E,IAAMC,IAAIC,EAA0BC,CAAU,GAC1CC,GACAC,IAAU,IACVC,GAEEC,UAAmC;EAEvC,IAAMC,IAAOP,EAAE,kBACTQ,IAAQR,EAAE,UAAU;EAC1B,IAAIK,KAAWE,MAASJ,KAAUK,MAAUJ,GAAS,OAAOC;EAE5D,AADA,IAASE,GACT,IAAUC;EACV,IAAMC,oBAAQ,IAAI,IAAq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AAC;EAEtD,IAAMK,IAAUC,EAAaxC,GAAGmB,GAAQ,OAAO;EAC/C,IAAIoB,EAAQ,WAAW,WAAW;GAAE,EAAO;IAAE,QAAQ;IAAW,QAAQA,EAAQ;GAAO,CAAC;GAAG;EAAQ;EACnG,IAAIA,EAAQ,WAAW,WAAW;GAChC,EAAOA,EAAQ,WAAW,oBAAoB,EAAE,QAAQ,WAAW,IAAI;IAAE,QAAQ;IAAW,MAAMvC,EAAE,QAAQ,IAAIqB,EAAO,EAAE,MAAMF;GAAO,CAAC;GACvI;EACF;EACA,IAAIU,GAAS;EAEb,IAAQU,EAAQ;EAChB,IAAMD,IAAQnB,EAAO;EACrB,AAAImB,EAAM,WAAW,YAAYA,EAAM,UAAUR,IAAOC,EAAO;GAAE,QAAQ;GAAU,SAASO,EAAM;EAAQ,CAAC,IAClGA,EAAM,WAAW,UAAUA,EAAM,UAAUR,IAAOC,EAAO;GAAE,QAAQ;GAAW,MAAM;EAAM,CAAC,IAC3FJ,EAAO,WAASO,EAAM;CACjC,CAAC;AACH"}
@@ -1,12 +1,16 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { FormDraft, HostLease, RendererBridge } from '../contracts/internal.js';
3
3
  import type { NotificationHandle } from '../contracts/identity.js';
4
+ import type { NotificationKind } from '../contracts/notifications.js';
4
5
  import type { NotificationSnapshot } from '../contracts/snapshots.js';
5
6
  import type { CloudletLabels, CloudletPart, ToasterProps } from '../react.js';
6
7
  export declare const defaultLabels: CloudletLabels;
8
+ export declare function glyph(path: string): import("react").JSX.Element;
7
9
  /** Adds the application's `classNames` part to an own `cloudlet-*` class, never replacing it. */
8
10
  export type PartClass = (part: CloudletPart, own: string) => string;
9
11
  export declare function partClasses(classNames: ToasterProps['classNames']): PartClass;
12
+ /** 16 px stroke glyphs drawn in the status colour. */
13
+ export declare const glyphs: Record<Exclude<NotificationKind, 'loading'>, string>;
10
14
  /**
11
15
  * The status icon: a 24 px tinted circle with a glyph, the loading spinner or the
12
16
  * notification's own icon, and the 2 px progress ring around it (pill and Island
@@ -1 +1 @@
1
- {"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../src/react/card.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA8D,SAAS,EAAE,MAAM,OAAO,CAAC;AACnG,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE9E,eAAO,MAAM,aAAa,EAAE,cAW3B,CAAC;AA4DF,iGAAiG;AACjG,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;AACpE,wBAAgB,WAAW,CAAC,UAAU,EAAE,YAAY,CAAC,YAAY,CAAC,GAAG,SAAS,CAK7E;AAUD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,OAAe,EAAE,EAAE;IACxE,YAAY,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAAC,IAAI,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,SAAS,CAAC;IAAC,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC1H,+BAoBA;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,EAC1G,eAAe,EAAE,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,WACxC,SAAS,iCACzB;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,EAAE,YAAY,EA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AAM,CAAC;CACjJ,+BAiCA;AAmFD,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,IAAI,+BAEvF"}
@@ -226,7 +226,7 @@ function b({ notification: e, labels: t, part: n }) {
226
226
  children: r.action.label
227
227
  }),
228
228
  y(i) && l(t.retry),
229
- i?.canCancel && l(i.cancelRequested ? t.cancellationRequested : t.cancel)
229
+ i?.canCancel && l(t.cancel)
230
230
  ]
231
231
  }),
232
232
  e.action.status === "failed" && /* @__PURE__ */ o("p", {
@@ -285,12 +285,7 @@ function x({ notification: e, form: t, bridge: n, lease: i, labels: a, navigate:
285
285
  children: S.label
286
286
  }),
287
287
  y(h) && d("retry", a.retry, () => n.retryOperation(i, p, h.token), { className: v }),
288
- h?.canCancel && d("cancel", h.cancelRequested ? a.cancellationRequested : a.cancel, () => {
289
- h.cancelRequested || n.cancelOperation(i, p, h.token);
290
- }, {
291
- className: v,
292
- "aria-disabled": h.cancelRequested
293
- })
288
+ h?.canCancel && d("cancel", a.cancel, () => n.cancelOperation(i, p, h.token), { className: v })
294
289
  ]
295
290
  }),
296
291
  g.status === "failed" && /* @__PURE__ */ o("p", {
@@ -409,6 +404,6 @@ function O(e, t, n) {
409
404
  });
410
405
  }
411
406
  //#endregion
412
- export { x as Body, _ as Heading, b as SlidePreview, h as StatusIcon, O as closeButton, c as defaultLabels, p as partClasses, v as previewSlot, g as slotRenderer };
407
+ export { x as Body, _ as Heading, b as SlidePreview, h as StatusIcon, O as closeButton, c as defaultLabels, f as glyph, m as glyphs, p as partClasses, v as previewSlot, g as slotRenderer };
413
408
 
414
409
  //# sourceMappingURL=card.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"card.js","names":["defaultLabels","count","title","missed","index","total","SlotBoundary","Component","props","state","Suspense","CheckedSlot","ref","useRef","invalidContent","setInvalidContent","useState","invalid","content","useEffect","element","reported","check","bridge","lease","Observer","observer","handle","rejectFocus","event","control","name","glyph","path","partClasses","extra","classNames","part","own","glyphs","StatusIcon","notification","determinate","progress","kind","preview","slot","slotRenderer","value","rejectSlotFocus","Heading","titleId","previewSlot","retryable","operation","SlidePreview","action","lookalike","primary","labels","Body","neutral","id","useId","command","activateLink","navigate","form","Form","formKey","formKeys","nextFormKey","key","TEXTAREA_ROWS","fitRows","fields","pending","failed","formError","draft","submit","result","first","field","fieldId","error","change","last","actionErrorId","item","closeButton","onClick"],"sources":["../../src/react/card.tsx"],"sourcesContent":["import { Component, Suspense, useEffect, useId, useRef, useState } from 'react';\nimport type { ComponentPropsWithRef, KeyboardEvent as ReactKeyboardEvent, ReactNode } from 'react';\nimport type { FormDraft, HostLease, RendererBridge } from '../contracts/internal.js';\nimport type { NotificationHandle } from '../contracts/identity.js';\nimport type { FormAction, FormField, NotificationKind } from '../contracts/notifications.js';\nimport type { NotificationSnapshot } from '../contracts/snapshots.js';\nimport type { CloudletLabels, CloudletPart, ToasterProps } from '../react.js';\n\nexport const defaultLabels: CloudletLabels = {\n region: 'Notifications', island: 'Current notifications', carousel: 'carousel', slide: 'slide',\n close: 'Close notification', retry: 'Retry',\n cancel: 'Request cancellation', cancellationRequested: 'Cancellation requested',\n acknowledgeOverflow: 'Acknowledge missed notifications', clearAll: 'Clear all', clearAllConfirm: count => `Clear ${count}`,\n collapse: 'Press Escape to collapse',\n stackSummary: (title, count, missed) => [title, ...(count > 1 ? [`${count} notifications`] : []),\n ...(missed > 0 ? [`${missed} missed`] : [])].join(', '),\n page: (index, total) => `${index} of ${total}`,\n overflowCount: count => `${count} missed notifications`,\n draft: 'Draft',\n};\n\ninterface SlotProps {\n readonly content: ReactNode;\n readonly bridge: RendererBridge<ReactNode>;\n readonly lease: HostLease;\n readonly handle: NotificationHandle;\n readonly rejectFocus: (previous: EventTarget | null) => void;\n}\n\nclass SlotBoundary extends Component<SlotProps, { failed: boolean; content: ReactNode }> {\n override state = { failed: false, content: this.props.content };\n static getDerivedStateFromError() { return { failed: true }; }\n static getDerivedStateFromProps(props: SlotProps, state: { content: ReactNode }) {\n return props.content === state.content ? null : { failed: false, content: props.content };\n }\n override componentDidCatch(error: unknown) {\n this.props.bridge.reportDiagnostic(this.props.lease, { code: 'slot-error', source: 'Toaster.slot',\n message: 'A rich slot could not be rendered', handle: this.props.handle, error });\n }\n override render() {\n return this.state.failed ? this.props.bridge.renderError\n : <Suspense fallback={this.props.bridge.renderError}><CheckedSlot {...this.props} /></Suspense>;\n }\n}\n\nfunction CheckedSlot({ content, bridge, lease, handle, rejectFocus }: SlotProps) {\n const ref = useRef<HTMLDivElement>(null);\n const [invalidContent, setInvalidContent] = useState<{ content: ReactNode } | null>(null);\n const invalid = invalidContent?.content === content;\n useEffect(() => {\n const element = ref.current;\n if (!element) return;\n let reported = false;\n const check = () => {\n if (reported || !element.querySelector('a[href],button,input,select,textarea,summary,iframe,[tabindex],[contenteditable]:not([contenteditable=\"false\"]),audio[controls],video[controls]')) return;\n reported = true;\n setInvalidContent({ content });\n bridge.reportDiagnostic(lease, { code: 'slot-error', source: 'Toaster.slot',\n message: 'Rich slots must be non-interactive; use the notification action', handle });\n };\n check();\n const Observer = element.ownerDocument.defaultView?.MutationObserver;\n const observer = Observer ? new Observer(check) : null;\n observer?.observe(element, { childList: true, subtree: true, attributes: true });\n return () => observer?.disconnect();\n }, [content, bridge, lease, handle]);\n return <div ref={ref} className=\"cloudlet-slot\" onFocusCapture={event => rejectFocus(event.relatedTarget)}>\n {invalid ? bridge.renderError : content}\n </div>;\n}\n\nfunction control(name: string, children: ReactNode, onClick: () => void, props?: ComponentPropsWithRef<'button'>) {\n return <button type=\"button\" data-cloudlet-control={name} {...props} onClick={onClick}>{children}</button>;\n}\n\nfunction glyph(path: string) {\n return <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\"><path d={path} /></svg>;\n}\n\n/** Adds the application's `classNames` part to an own `cloudlet-*` class, never replacing it. */\nexport type PartClass = (part: CloudletPart, own: string) => string;\nexport function partClasses(classNames: ToasterProps['classNames']): PartClass {\n return (part, own) => {\n const extra = classNames?.[part];\n return typeof extra === 'string' && extra.trim() ? `${own} ${extra.trim()}` : own;\n };\n}\n\n/** 16 px stroke glyphs drawn in the status colour. */\nconst glyphs: Record<Exclude<NotificationKind, 'loading'>, string> = {\n success: 'M4.5 8.5 7 11l4.5-5.5',\n error: 'm5.5 5.5 5 5m0-5-5 5',\n info: 'M8 7.5V11M8 5h.01',\n warning: 'M8 4.75V8.5M8 11.25h.01',\n};\n\n/**\n * The status icon: a 24 px tinted circle with a glyph, the loading spinner or the\n * notification's own icon, and the 2 px progress ring around it (pill and Island\n * share these nodes). With progress the icon is the accessible progressbar. The\n * determinate arc is owned by the host sampler (one RAF per host, 240 ms tween);\n * `preview` draws the value statically for the inert swipe neighbour.\n */\nexport function StatusIcon({ notification, slot, part, preview = false }: {\n notification: NotificationSnapshot<ReactNode>; slot: (value: ReactNode) => ReactNode; part: PartClass; preview?: boolean;\n}) {\n const { content, kind } = notification;\n const { progress } = content;\n const determinate = progress?.kind === 'determinate';\n return <div className={part('icon', 'cloudlet-icon')} data-kind={kind}\n {...(progress && !preview ? { role: 'progressbar', 'aria-valuemin': 0, 'aria-valuemax': 100,\n 'aria-valuenow': determinate ? Math.round(progress.value * 100) : undefined, 'aria-label': progress.label ?? content.title }\n : { 'aria-hidden': 'true' })}>\n {content.icon !== undefined\n ? <span className=\"cloudlet-glyph\" aria-hidden=\"true\">{slot(content.icon)}</span>\n // With progress the ring is the activity indicator of a loading record.\n : kind === 'loading' ? !progress && <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" className=\"cloudlet-glyph cloudlet-spinner\">\n <circle cx=\"8\" cy=\"8\" r=\"5.5\" strokeDasharray=\"22 13\" /></svg>\n : <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" className=\"cloudlet-glyph\"><path d={glyphs[kind]} /></svg>}\n {progress && <svg aria-hidden=\"true\" viewBox=\"0 0 32 32\" className=\"cloudlet-ring\" data-progress={progress.kind}>\n <circle className=\"cloudlet-ring-track\" cx=\"16\" cy=\"16\" r=\"15\" />\n <circle className=\"cloudlet-progress-fill\" cx=\"16\" cy=\"16\" r=\"15\" pathLength=\"100\" transform=\"rotate(-90 16 16)\"\n strokeDasharray={!determinate ? '25 75' : preview ? `${Math.round(progress.value * 10000) / 100} 100` : '0 100'} />\n </svg>}\n </div>;\n}\n\nexport function slotRenderer(bridge: RendererBridge<ReactNode>, lease: HostLease, handle: NotificationHandle,\n rejectSlotFocus: (previous: EventTarget | null) => void) {\n return (value: ReactNode) => <SlotBoundary content={value} bridge={bridge} lease={lease} handle={handle} rejectFocus={rejectSlotFocus} />;\n}\n\n/**\n * Status icon and title: the same DOM nodes in the pill and in the Island header,\n * so opening never re-creates them and the title can receive focus in place.\n */\nexport function Heading({ notification, slot, part, titleId }: {\n notification: NotificationSnapshot<ReactNode>; slot: (value: ReactNode) => ReactNode; part: PartClass;\n /** Omitted for the inert neighbour preview: no id, focus target, data hook or live progress. */\n titleId?: string;\n}) {\n const title = part('title', 'cloudlet-title');\n return <div className=\"cloudlet-heading\">\n <StatusIcon notification={notification} slot={slot} part={part} preview={titleId === undefined} />\n {titleId === undefined ? <h2 className={title}>{notification.content.title}</h2>\n : <h2 id={titleId} tabIndex={-1} data-cloudlet-title=\"\" className={title}>{notification.content.title}</h2>}\n </div>;\n}\n\n/** Rich content of the inert neighbour preview: rendered as is, never checked or reported twice. */\nexport const previewSlot = (value: ReactNode) => <div className=\"cloudlet-slot\">{value}</div>;\n\n/** A settled factory can always retry through the API; only an unsuccessful attempt offers the button. */\ntype Operation = NotificationSnapshot<ReactNode>['operation'];\nconst retryable = (operation: Operation): operation is NonNullable<Operation> => !!operation?.canRetry && operation.status !== 'fulfilled';\n\n/**\n * The neighbour shown only while a finger drags the Island content:\n * the same layout as a live slide, but every control is a lookalike without\n * handlers, ids, links or tab stops. The caller puts it in an `inert` container.\n */\nexport function SlidePreview({ notification, labels, part }: { notification: NotificationSnapshot<ReactNode>; labels: CloudletLabels; part: PartClass }) {\n const { content, operation, kind } = notification;\n const action = part('action', 'cloudlet-action');\n const lookalike = (children: ReactNode, primary = false) =>\n <button type=\"button\" tabIndex={-1} className={primary ? `${action} cloudlet-primary` : action}>{children}</button>;\n // Only the body slides: the preview shows the neighbour's body under the live heading.\n return <div className=\"cloudlet-slide\" data-kind={kind}>\n <div className={part('body', 'cloudlet-body')} data-kind={kind}>\n {content.description && <div className={part('description', 'cloudlet-description')}>\n {content.description.kind === 'text' ? <p>{content.description.text}</p> : previewSlot(content.description.content)}\n </div>}\n <div className={part('actions', 'cloudlet-actions')}>\n {content.action?.kind === 'command' && lookalike(content.action.label, true)}\n {content.action?.kind === 'link' && <a className={`${action} cloudlet-primary`}>{content.action.label}</a>}\n {retryable(operation) && lookalike(labels.retry)}\n {operation?.canCancel && lookalike(operation.cancelRequested ? labels.cancellationRequested : labels.cancel)}\n </div>\n {notification.action.status === 'failed' && <p className=\"cloudlet-action-error\">{notification.action.message}</p>}\n </div>\n </div>;\n}\n\n/** Island slide body: description, progress, actions and the action error. */\nexport function Body({ notification, form, bridge, lease, labels, navigate, slot, part, titleId }: {\n notification: NotificationSnapshot<ReactNode>; form: FormDraft | undefined; bridge: RendererBridge<ReactNode>; lease: HostLease;\n labels: CloudletLabels; navigate: (handle: NotificationHandle) => void; slot: (value: ReactNode) => ReactNode; part: PartClass; titleId: string;\n}) {\n const { handle, content, operation, action, kind } = notification;\n // The primary action is tinted with the status; retry and cancel stay neutral.\n const neutral = part('action', 'cloudlet-action');\n const primary = `${neutral} cloudlet-primary`;\n const id = useId();\n const command = content.action;\n const activateLink = (event: MouseEvent) => {\n // Observe cancellation after portal/application ancestors have handled activation.\n queueMicrotask(() => { if (!event.defaultPrevented) navigate(handle); });\n };\n return <div className={part('body', 'cloudlet-body')} data-kind={kind}>\n {content.description && <div className={part('description', 'cloudlet-description')}>\n {content.description.kind === 'text' && <p>{content.description.text}</p>}\n {content.description.kind === 'rich' && slot(content.description.content)}\n </div>}\n {command?.kind === 'form' && form && <Form key={formKey(command)} action={command} draft={form} notification={notification}\n bridge={bridge} lease={lease} part={part} titleId={titleId} actionErrorId={`${id}-action-error`} />}\n <div className={part('actions', 'cloudlet-actions')}>\n {command?.kind === 'command' && control('action', command.label, () => {\n if (action.status !== 'pending') bridge.invokeAction(lease, handle);\n }, { className: primary, 'aria-disabled': action.status === 'pending', 'aria-busy': action.status === 'pending',\n 'aria-describedby': action.status === 'failed' ? `${id}-action-error` : undefined })}\n {command?.kind === 'link' && <a data-cloudlet-control=\"action\" className={primary} href={command.href} target={command.target}\n rel={command.target === '_blank' ? [...new Set(`${command.rel ?? ''} noopener`.trim().split(/\\s+/u))].join(' ') : command.rel}\n onClick={event => activateLink(event.nativeEvent)}\n onAuxClick={event => { if (event.button === 1) activateLink(event.nativeEvent); }}>{command.label}</a>}\n {retryable(operation) && control('retry', labels.retry, () => bridge.retryOperation(lease, handle, operation.token), { className: neutral })}\n {operation?.canCancel && control('cancel', operation.cancelRequested ? labels.cancellationRequested : labels.cancel, () => {\n if (!operation.cancelRequested) bridge.cancelOperation(lease, handle, operation.token);\n }, { className: neutral, 'aria-disabled': operation.cancelRequested })}\n </div>\n {action.status === 'failed' && <p id={`${id}-action-error`} className=\"cloudlet-action-error\">{action.message}</p>}\n </div>;\n}\n\n// A new form action object starts a new draft in the controller, so its fields remount with the new defaults.\nconst formKeys = new WeakMap<FormAction, number>();\nlet nextFormKey = 0;\nfunction formKey(action: FormAction): number {\n let key = formKeys.get(action);\n if (key === undefined) formKeys.set(action, key = ++nextFormKey);\n return key;\n}\n\nconst TEXTAREA_ROWS = [3, 6] as const;\n\n/** Rows instead of a height: a strict CSP forbids style attributes, and rows grow with the text. */\nfunction fitRows(element: HTMLTextAreaElement): void {\n element.rows = TEXTAREA_ROWS[0];\n while (element.scrollHeight > element.clientHeight && element.rows < TEXTAREA_ROWS[1]) element.rows += 1;\n}\n\n/**\n * Look A: each field is a filled pill; the round submit button sits beside the last one. The fields\n * are uncontrolled: their text lives in the controller's draft and seeds them on mount, so typing\n * never waits for a snapshot round trip.\n */\nfunction Form({ action, draft, notification, bridge, lease, part, titleId, actionErrorId }: {\n action: FormAction; draft: FormDraft; notification: NotificationSnapshot<ReactNode>; bridge: RendererBridge<ReactNode>;\n lease: HostLease; part: PartClass; titleId: string; actionErrorId: string;\n}) {\n const id = useId();\n const fields = useRef(new Map<string, HTMLInputElement | HTMLTextAreaElement>());\n const pending = notification.action.status === 'pending';\n const failed = notification.action.status === 'failed';\n const formError = draft.errors.form;\n const submit = () => {\n if (pending) return;\n const result = bridge.invokeAction(lease, notification.handle);\n if (result.status !== 'invalid') return;\n const first = action.fields.find(field => Object.hasOwn(result.errors.fields, field.name));\n if (first) fields.current.get(first.name)?.focus();\n };\n const field = (field: FormField, index: number, last: boolean) => {\n const fieldId = `${id}-${index}`;\n // Own keys only: a field named `constructor` must not read `Object.prototype`.\n const error = Object.hasOwn(draft.errors.fields, field.name) ? draft.errors.fields[field.name] : undefined;\n const props = {\n id: fieldId, name: field.name, className: part('field', 'cloudlet-field'), defaultValue: Object.hasOwn(draft.values, field.name) ? draft.values[field.name] : '',\n placeholder: field.placeholder ?? field.label, required: field.required, maxLength: field.maxLength,\n autoComplete: field.autoComplete, inputMode: field.inputMode, readOnly: pending,\n 'aria-invalid': error === undefined ? undefined : true, 'aria-describedby': error === undefined ? undefined : `${fieldId}-error`,\n };\n const change = (element: HTMLInputElement | HTMLTextAreaElement) => bridge.setFormValue(lease, notification.handle, field.name, element.value);\n return <div key={field.name} className=\"cloudlet-form-row\">\n <label htmlFor={fieldId} className=\"cloudlet-live\">{field.label}</label>\n {field.kind === 'text'\n ? <input type=\"text\" {...props} ref={element => { if (element) fields.current.set(field.name, element); }}\n onChange={event => change(event.currentTarget)} />\n : <textarea {...props} rows={TEXTAREA_ROWS[0]} ref={element => {\n if (!element) return;\n fields.current.set(field.name, element);\n fitRows(element);\n }} onChange={event => { change(event.currentTarget); fitRows(event.currentTarget); }}\n onKeyDown={(event: ReactKeyboardEvent<HTMLTextAreaElement>) => {\n // Enter starts a new line in a textarea; ⌘ or Ctrl with Enter sends.\n if (event.key !== 'Enter' || !(event.metaKey || event.ctrlKey) || event.nativeEvent.isComposing) return;\n event.preventDefault();\n submit();\n }} />}\n {last && <button type=\"submit\" data-cloudlet-control=\"action\" className={part('action', 'cloudlet-action cloudlet-submit')}\n aria-label={action.label} aria-disabled={pending} aria-busy={pending}\n aria-describedby={failed ? actionErrorId : formError ? `${id}-error` : undefined}>\n {pending ? <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" className=\"cloudlet-spinner\"><circle cx=\"8\" cy=\"8\" r=\"5.5\" strokeDasharray=\"22 13\" /></svg>\n : glyph('M8 13V3m0 0L3.5 7.5M8 3l4.5 4.5')}\n </button>}\n {error !== undefined && <p id={`${fieldId}-error`} className={part('field-error', 'cloudlet-field-error')}>{error}</p>}\n </div>;\n };\n return <form className={part('form', 'cloudlet-form')} noValidate aria-labelledby={titleId}\n onSubmit={event => { event.preventDefault(); submit(); }}>\n {action.fields.map((item, index) => field(item, index, index === action.fields.length - 1))}\n {formError && <p id={`${id}-error`} className=\"cloudlet-action-error\">{formError}</p>}\n </form>;\n}\n\nexport function closeButton(labels: CloudletLabels, part: PartClass, onClick: () => void) {\n return control('close', glyph('m4.5 4.5 7 7m0-7-7 7'), onClick, { 'aria-label': labels.close, className: part('close', 'cloudlet-close') });\n}\n"],"mappings":";;;AAQA,IAAaA,IAAgC;CAC3C,QAAQ;CAAiB,QAAQ;CAAyB,UAAU;CAAY,OAAO;CACvF,OAAO;CAAsB,OAAO;CACpC,QAAQ;CAAwB,uBAAuB;CACvD,qBAAqB;CAAoC,UAAU;CAAa,kBAAiB,MAAS,SAASC;CACnH,UAAU;CACV,eAAe,GAAO,GAAO,MAAW;EAACC;EAAO,GAAID,IAAQ,IAAI,CAAC,GAAGA,EAAM,eAAe,IAAI,CAAC;EAC5F,GAAIE,IAAS,IAAI,CAAC,GAAGA,EAAO,QAAQ,IAAI,CAAC;C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AAU,kBAAC,OAAD;MAAK,eAAY;MAAO,SAAQ;MAAY,WAAU;MAAmB,UAAA,kBAAC,UAAD;OAAQ,IAAG;OAAI,IAAG;OAAI,GAAE;OAAM,iBAAgB;MAAS,CAAA;KAAM,CAAA,IAC7I5C,EAAM,iCAAiC;IACrC,CAAA;IACPqD,MAAU,KAAA,KAAa,kBAAC,KAAD;KAAG,IAAI,GAAGD,EAAQ;KAAS,WAAW/C,EAAK,eAAe,sBAAsB;KAAI,UAAAgD;IAAS,CAAA;GAClH;EAvBY,GAAAF,EAAM,IAuBlB;CACP;CACA,OAAO,kBAAC,QAAD;EAAM,WAAW9C,EAAK,QAAQ,eAAe;EAAG,YAAA;EAAW,mBAAiBc;EACjF,WAAU,MAAS;GAA0B,AAAxBtB,EAAM,eAAe,GAAGmD,EAAO;EAAG;EADlD,UAAA,CAEJxB,EAAO,OAAO,KAAK,GAAM,MAAU2B,EAAMM,GAAMrF,GAAOA,MAAUoD,EAAO,OAAO,SAAS,CAAC,CAAC,GACzFsB,KAAa,kBAAC,KAAD;GAAG,IAAI,GAAGhB,EAAG;GAAS,WAAU;GAAyB,UAAAgB;EAAa,CAAA,CAChF;;AACR;AAEA,SAAgBY,EAAY,GAAwB,GAAiB,GAAqB;CACxF,OAAO5D,EAAQ,SAASE,EAAM,sBAAsB,GAAG2D,GAAS;EAAE,cAAchC,EAAO;EAAO,WAAWtB,EAAK,SAAS,gBAAgB;CAAE,CAAC;AAC5I"}
1
+ {"version":3,"file":"card.js","names":["defaultLabels","count","title","missed","index","total","SlotBoundary","Component","props","state","Suspense","CheckedSlot","ref","useRef","invalidContent","setInvalidContent","useState","invalid","content","useEffect","element","reported","check","bridge","lease","Observer","observer","handle","rejectFocus","event","control","name","glyph","path","partClasses","extra","classNames","part","own","glyphs","StatusIcon","notification","determinate","progress","kind","preview","slot","slotRenderer","value","rejectSlotFocus","Heading","titleId","previewSlot","retryable","operation","SlidePreview","action","lookalike","primary","labels","Body","neutral","id","useId","command","activateLink","navigate","form","Form","formKey","formKeys","nextFormKey","key","TEXTAREA_ROWS","fitRows","fields","pending","failed","formError","draft","submit","result","first","field","fieldId","error","change","last","actionErrorId","item","closeButton","onClick"],"sources":["../../src/react/card.tsx"],"sourcesContent":["import { Component, Suspense, useEffect, useId, useRef, useState } from 'react';\nimport type { ComponentPropsWithRef, KeyboardEvent as ReactKeyboardEvent, ReactNode } from 'react';\nimport type { FormDraft, HostLease, RendererBridge } from '../contracts/internal.js';\nimport type { NotificationHandle } from '../contracts/identity.js';\nimport type { FormAction, FormField, NotificationKind } from '../contracts/notifications.js';\nimport type { NotificationSnapshot } from '../contracts/snapshots.js';\nimport type { CloudletLabels, CloudletPart, ToasterProps } from '../react.js';\n\nexport const defaultLabels: CloudletLabels = {\n region: 'Notifications', island: 'Current notifications', carousel: 'carousel', slide: 'slide',\n close: 'Close notification', retry: 'Retry',\n cancel: 'Request cancellation', cancellationRequested: 'Cancellation requested',\n acknowledgeOverflow: 'Acknowledge missed notifications', clearAll: 'Clear all', clearAllConfirm: count => `Clear ${count}`,\n collapse: 'Press Escape to collapse',\n stackSummary: (title, count, missed) => [title, ...(count > 1 ? [`${count} notifications`] : []),\n ...(missed > 0 ? [`${missed} missed`] : [])].join(', '),\n page: (index, total) => `${index} of ${total}`,\n overflowCount: count => `${count} missed notifications`,\n draft: 'Draft',\n};\n\ninterface SlotProps {\n readonly content: ReactNode;\n readonly bridge: RendererBridge<ReactNode>;\n readonly lease: HostLease;\n readonly handle: NotificationHandle;\n readonly rejectFocus: (previous: EventTarget | null) => void;\n}\n\nclass SlotBoundary extends Component<SlotProps, { failed: boolean; content: ReactNode }> {\n override state = { failed: false, content: this.props.content };\n static getDerivedStateFromError() { return { failed: true }; }\n static getDerivedStateFromProps(props: SlotProps, state: { content: ReactNode }) {\n return props.content === state.content ? null : { failed: false, content: props.content };\n }\n override componentDidCatch(error: unknown) {\n this.props.bridge.reportDiagnostic(this.props.lease, { code: 'slot-error', source: 'Toaster.slot',\n message: 'A rich slot could not be rendered', handle: this.props.handle, error });\n }\n override render() {\n return this.state.failed ? this.props.bridge.renderError\n : <Suspense fallback={this.props.bridge.renderError}><CheckedSlot {...this.props} /></Suspense>;\n }\n}\n\nfunction CheckedSlot({ content, bridge, lease, handle, rejectFocus }: SlotProps) {\n const ref = useRef<HTMLDivElement>(null);\n const [invalidContent, setInvalidContent] = useState<{ content: ReactNode } | null>(null);\n const invalid = invalidContent?.content === content;\n useEffect(() => {\n const element = ref.current;\n if (!element) return;\n let reported = false;\n const check = () => {\n if (reported || !element.querySelector('a[href],button,input,select,textarea,summary,iframe,[tabindex],[contenteditable]:not([contenteditable=\"false\"]),audio[controls],video[controls]')) return;\n reported = true;\n setInvalidContent({ content });\n bridge.reportDiagnostic(lease, { code: 'slot-error', source: 'Toaster.slot',\n message: 'Rich slots must be non-interactive; use the notification action', handle });\n };\n check();\n const Observer = element.ownerDocument.defaultView?.MutationObserver;\n const observer = Observer ? new Observer(check) : null;\n observer?.observe(element, { childList: true, subtree: true, attributes: true });\n return () => observer?.disconnect();\n }, [content, bridge, lease, handle]);\n return <div ref={ref} className=\"cloudlet-slot\" onFocusCapture={event => rejectFocus(event.relatedTarget)}>\n {invalid ? bridge.renderError : content}\n </div>;\n}\n\nfunction control(name: string, children: ReactNode, onClick: () => void, props?: ComponentPropsWithRef<'button'>) {\n return <button type=\"button\" data-cloudlet-control={name} {...props} onClick={onClick}>{children}</button>;\n}\n\nexport function glyph(path: string) {\n return <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\"><path d={path} /></svg>;\n}\n\n/** Adds the application's `classNames` part to an own `cloudlet-*` class, never replacing it. */\nexport type PartClass = (part: CloudletPart, own: string) => string;\nexport function partClasses(classNames: ToasterProps['classNames']): PartClass {\n return (part, own) => {\n const extra = classNames?.[part];\n return typeof extra === 'string' && extra.trim() ? `${own} ${extra.trim()}` : own;\n };\n}\n\n/** 16 px stroke glyphs drawn in the status colour. */\nexport const glyphs: Record<Exclude<NotificationKind, 'loading'>, string> = {\n success: 'M4.5 8.5 7 11l4.5-5.5',\n error: 'm5.5 5.5 5 5m0-5-5 5',\n info: 'M8 7.5V11M8 5h.01',\n warning: 'M8 4.75V8.5M8 11.25h.01',\n};\n\n/**\n * The status icon: a 24 px tinted circle with a glyph, the loading spinner or the\n * notification's own icon, and the 2 px progress ring around it (pill and Island\n * share these nodes). With progress the icon is the accessible progressbar. The\n * determinate arc is owned by the host sampler (one RAF per host, 240 ms tween);\n * `preview` draws the value statically for the inert swipe neighbour.\n */\nexport function StatusIcon({ notification, slot, part, preview = false }: {\n notification: NotificationSnapshot<ReactNode>; slot: (value: ReactNode) => ReactNode; part: PartClass; preview?: boolean;\n}) {\n const { content, kind } = notification;\n const { progress } = content;\n const determinate = progress?.kind === 'determinate';\n return <div className={part('icon', 'cloudlet-icon')} data-kind={kind}\n {...(progress && !preview ? { role: 'progressbar', 'aria-valuemin': 0, 'aria-valuemax': 100,\n 'aria-valuenow': determinate ? Math.round(progress.value * 100) : undefined, 'aria-label': progress.label ?? content.title }\n : { 'aria-hidden': 'true' })}>\n {content.icon !== undefined\n ? <span className=\"cloudlet-glyph\" aria-hidden=\"true\">{slot(content.icon)}</span>\n // With progress the ring is the activity indicator of a loading record.\n : kind === 'loading' ? !progress && <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" className=\"cloudlet-glyph cloudlet-spinner\">\n <circle cx=\"8\" cy=\"8\" r=\"5.5\" strokeDasharray=\"22 13\" /></svg>\n : <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" className=\"cloudlet-glyph\"><path d={glyphs[kind]} /></svg>}\n {progress && <svg aria-hidden=\"true\" viewBox=\"0 0 32 32\" className=\"cloudlet-ring\" data-progress={progress.kind}>\n <circle className=\"cloudlet-ring-track\" cx=\"16\" cy=\"16\" r=\"15\" />\n <circle className=\"cloudlet-progress-fill\" cx=\"16\" cy=\"16\" r=\"15\" pathLength=\"100\" transform=\"rotate(-90 16 16)\"\n strokeDasharray={!determinate ? '25 75' : preview ? `${Math.round(progress.value * 10000) / 100} 100` : '0 100'} />\n </svg>}\n </div>;\n}\n\nexport function slotRenderer(bridge: RendererBridge<ReactNode>, lease: HostLease, handle: NotificationHandle,\n rejectSlotFocus: (previous: EventTarget | null) => void) {\n return (value: ReactNode) => <SlotBoundary content={value} bridge={bridge} lease={lease} handle={handle} rejectFocus={rejectSlotFocus} />;\n}\n\n/**\n * Status icon and title: the same DOM nodes in the pill and in the Island header,\n * so opening never re-creates them and the title can receive focus in place.\n */\nexport function Heading({ notification, slot, part, titleId }: {\n notification: NotificationSnapshot<ReactNode>; slot: (value: ReactNode) => ReactNode; part: PartClass;\n /** Omitted for the inert neighbour preview: no id, focus target, data hook or live progress. */\n titleId?: string;\n}) {\n const title = part('title', 'cloudlet-title');\n return <div className=\"cloudlet-heading\">\n <StatusIcon notification={notification} slot={slot} part={part} preview={titleId === undefined} />\n {titleId === undefined ? <h2 className={title}>{notification.content.title}</h2>\n : <h2 id={titleId} tabIndex={-1} data-cloudlet-title=\"\" className={title}>{notification.content.title}</h2>}\n </div>;\n}\n\n/** Rich content of the inert neighbour preview: rendered as is, never checked or reported twice. */\nexport const previewSlot = (value: ReactNode) => <div className=\"cloudlet-slot\">{value}</div>;\n\n/** A settled factory can always retry through the API; only an unsuccessful attempt offers the button. */\ntype Operation = NotificationSnapshot<ReactNode>['operation'];\nconst retryable = (operation: Operation): operation is NonNullable<Operation> => !!operation?.canRetry && operation.status !== 'fulfilled';\n\n/**\n * The neighbour shown only while a finger drags the Island content:\n * the same layout as a live slide, but every control is a lookalike without\n * handlers, ids, links or tab stops. The caller puts it in an `inert` container.\n */\nexport function SlidePreview({ notification, labels, part }: { notification: NotificationSnapshot<ReactNode>; labels: CloudletLabels; part: PartClass }) {\n const { content, operation, kind } = notification;\n const action = part('action', 'cloudlet-action');\n const lookalike = (children: ReactNode, primary = false) =>\n <button type=\"button\" tabIndex={-1} className={primary ? `${action} cloudlet-primary` : action}>{children}</button>;\n // Only the body slides: the preview shows the neighbour's body under the live heading.\n return <div className=\"cloudlet-slide\" data-kind={kind}>\n <div className={part('body', 'cloudlet-body')} data-kind={kind}>\n {content.description && <div className={part('description', 'cloudlet-description')}>\n {content.description.kind === 'text' ? <p>{content.description.text}</p> : previewSlot(content.description.content)}\n </div>}\n <div className={part('actions', 'cloudlet-actions')}>\n {content.action?.kind === 'command' && lookalike(content.action.label, true)}\n {content.action?.kind === 'link' && <a className={`${action} cloudlet-primary`}>{content.action.label}</a>}\n {retryable(operation) && lookalike(labels.retry)}\n {operation?.canCancel && lookalike(labels.cancel)}\n </div>\n {notification.action.status === 'failed' && <p className=\"cloudlet-action-error\">{notification.action.message}</p>}\n </div>\n </div>;\n}\n\n/** Island slide body: description, progress, actions and the action error. */\nexport function Body({ notification, form, bridge, lease, labels, navigate, slot, part, titleId }: {\n notification: NotificationSnapshot<ReactNode>; form: FormDraft | undefined; bridge: RendererBridge<ReactNode>; lease: HostLease;\n labels: CloudletLabels; navigate: (handle: NotificationHandle) => void; slot: (value: ReactNode) => ReactNode; part: PartClass; titleId: string;\n}) {\n const { handle, content, operation, action, kind } = notification;\n // The primary action is tinted with the status; retry and cancel stay neutral.\n const neutral = part('action', 'cloudlet-action');\n const primary = `${neutral} cloudlet-primary`;\n const id = useId();\n const command = content.action;\n const activateLink = (event: MouseEvent) => {\n // Observe cancellation after portal/application ancestors have handled activation.\n queueMicrotask(() => { if (!event.defaultPrevented) navigate(handle); });\n };\n return <div className={part('body', 'cloudlet-body')} data-kind={kind}>\n {content.description && <div className={part('description', 'cloudlet-description')}>\n {content.description.kind === 'text' && <p>{content.description.text}</p>}\n {content.description.kind === 'rich' && slot(content.description.content)}\n </div>}\n {command?.kind === 'form' && form && <Form key={formKey(command)} action={command} draft={form} notification={notification}\n bridge={bridge} lease={lease} part={part} titleId={titleId} actionErrorId={`${id}-action-error`} />}\n <div className={part('actions', 'cloudlet-actions')}>\n {command?.kind === 'command' && control('action', command.label, () => {\n if (action.status !== 'pending') bridge.invokeAction(lease, handle);\n }, { className: primary, 'aria-disabled': action.status === 'pending', 'aria-busy': action.status === 'pending',\n 'aria-describedby': action.status === 'failed' ? `${id}-action-error` : undefined })}\n {command?.kind === 'link' && <a data-cloudlet-control=\"action\" className={primary} href={command.href} target={command.target}\n rel={command.target === '_blank' ? [...new Set(`${command.rel ?? ''} noopener`.trim().split(/\\s+/u))].join(' ') : command.rel}\n onClick={event => activateLink(event.nativeEvent)}\n onAuxClick={event => { if (event.button === 1) activateLink(event.nativeEvent); }}>{command.label}</a>}\n {retryable(operation) && control('retry', labels.retry, () => bridge.retryOperation(lease, handle, operation.token), { className: neutral })}\n {/* `canCancel` turns false once cancellation is requested: the button leaves and the title says so. */}\n {operation?.canCancel && control('cancel', labels.cancel, () => bridge.cancelOperation(lease, handle, operation.token), { className: neutral })}\n </div>\n {action.status === 'failed' && <p id={`${id}-action-error`} className=\"cloudlet-action-error\">{action.message}</p>}\n </div>;\n}\n\n// A new form action object starts a new draft in the controller, so its fields remount with the new defaults.\nconst formKeys = new WeakMap<FormAction, number>();\nlet nextFormKey = 0;\nfunction formKey(action: FormAction): number {\n let key = formKeys.get(action);\n if (key === undefined) formKeys.set(action, key = ++nextFormKey);\n return key;\n}\n\nconst TEXTAREA_ROWS = [3, 6] as const;\n\n/** Rows instead of a height: a strict CSP forbids style attributes, and rows grow with the text. */\nfunction fitRows(element: HTMLTextAreaElement): void {\n element.rows = TEXTAREA_ROWS[0];\n while (element.scrollHeight > element.clientHeight && element.rows < TEXTAREA_ROWS[1]) element.rows += 1;\n}\n\n/**\n * Look A: each field is a filled pill; the round submit button sits beside the last one. The fields\n * are uncontrolled: their text lives in the controller's draft and seeds them on mount, so typing\n * never waits for a snapshot round trip.\n */\nfunction Form({ action, draft, notification, bridge, lease, part, titleId, actionErrorId }: {\n action: FormAction; draft: FormDraft; notification: NotificationSnapshot<ReactNode>; bridge: RendererBridge<ReactNode>;\n lease: HostLease; part: PartClass; titleId: string; actionErrorId: string;\n}) {\n const id = useId();\n const fields = useRef(new Map<string, HTMLInputElement | HTMLTextAreaElement>());\n const pending = notification.action.status === 'pending';\n const failed = notification.action.status === 'failed';\n const formError = draft.errors.form;\n const submit = () => {\n if (pending) return;\n const result = bridge.invokeAction(lease, notification.handle);\n if (result.status !== 'invalid') return;\n const first = action.fields.find(field => Object.hasOwn(result.errors.fields, field.name));\n if (first) fields.current.get(first.name)?.focus();\n };\n const field = (field: FormField, index: number, last: boolean) => {\n const fieldId = `${id}-${index}`;\n // Own keys only: a field named `constructor` must not read `Object.prototype`.\n const error = Object.hasOwn(draft.errors.fields, field.name) ? draft.errors.fields[field.name] : undefined;\n const props = {\n id: fieldId, name: field.name, className: part('field', 'cloudlet-field'), defaultValue: Object.hasOwn(draft.values, field.name) ? draft.values[field.name] : '',\n placeholder: field.placeholder ?? field.label, required: field.required, maxLength: field.maxLength,\n autoComplete: field.autoComplete, inputMode: field.inputMode, readOnly: pending,\n 'aria-invalid': error === undefined ? undefined : true, 'aria-describedby': error === undefined ? undefined : `${fieldId}-error`,\n };\n const change = (element: HTMLInputElement | HTMLTextAreaElement) => bridge.setFormValue(lease, notification.handle, field.name, element.value);\n return <div key={field.name} className=\"cloudlet-form-row\">\n <label htmlFor={fieldId} className=\"cloudlet-live\">{field.label}</label>\n {field.kind === 'text'\n ? <input type=\"text\" {...props} ref={element => { if (element) fields.current.set(field.name, element); }}\n onChange={event => change(event.currentTarget)} />\n : <textarea {...props} rows={TEXTAREA_ROWS[0]} ref={element => {\n if (!element) return;\n fields.current.set(field.name, element);\n fitRows(element);\n }} onChange={event => { change(event.currentTarget); fitRows(event.currentTarget); }}\n onKeyDown={(event: ReactKeyboardEvent<HTMLTextAreaElement>) => {\n // Enter starts a new line in a textarea; ⌘ or Ctrl with Enter sends.\n if (event.key !== 'Enter' || !(event.metaKey || event.ctrlKey) || event.nativeEvent.isComposing) return;\n event.preventDefault();\n submit();\n }} />}\n {last && <button type=\"submit\" data-cloudlet-control=\"action\" className={part('action', 'cloudlet-action cloudlet-submit')}\n aria-label={action.label} aria-disabled={pending} aria-busy={pending}\n aria-describedby={failed ? actionErrorId : formError ? `${id}-error` : undefined}>\n {pending ? <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" className=\"cloudlet-spinner\"><circle cx=\"8\" cy=\"8\" r=\"5.5\" strokeDasharray=\"22 13\" /></svg>\n : glyph('M8 13V3m0 0L3.5 7.5M8 3l4.5 4.5')}\n </button>}\n {error !== undefined && <p id={`${fieldId}-error`} className={part('field-error', 'cloudlet-field-error')}>{error}</p>}\n </div>;\n };\n return <form className={part('form', 'cloudlet-form')} noValidate aria-labelledby={titleId}\n onSubmit={event => { event.preventDefault(); submit(); }}>\n {action.fields.map((item, index) => field(item, index, index === action.fields.length - 1))}\n {formError && <p id={`${id}-error`} className=\"cloudlet-action-error\">{formError}</p>}\n </form>;\n}\n\nexport function closeButton(labels: CloudletLabels, part: PartClass, onClick: () => void) {\n return control('close', glyph('m4.5 4.5 7 7m0-7-7 7'), onClick, { 'aria-label': labels.close, className: part('close', 'cloudlet-close') });\n}\n"],"mappings":";;;AAQA,IAAaA,IAAgC;CAC3C,QAAQ;CAAiB,QAAQ;CAAyB,UAAU;CAAY,OAAO;CACvF,OAAO;CAAsB,OAAO;CACpC,QAAQ;CAAwB,uBAAuB;CACvD,qBAAqB;CAAoC,UAAU;CAAa,kBAAiB,MAAS,SAASC;CACnH,UAAU;CACV,eAAe,GAAO,GAAO,MAAW;EAACC;EAAO,GAAID,IAAQ,IAAI,CAAC,GAAGA,EAAM,eAAe,IAAI,CAAC;EAC5F,GAAIE,IAAS,IAAI,CAAC,GAAGA,EAAO,QAAQ,IAAI,CAAC;CAAE,CAAC,CAAC,KAAK,IAAI;CACxD,OAAO,GAAO,MAAU,GAAGC,EAAM,MAAMC;CACvC,gBAAe,MAAS,GAAGJ,EAAM;CACjC,OAAO;AACT,GAUMK,IAAN,cAA2BC,EAA8D;CACvF,QAAiB;EAAE,QAAQ;EAAO,SAAS,KAAK,MAAM;CAAQ;C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;EAvBY,GAAAF,EAAM,IAuBlB;CACP;CACA,OAAO,kBAAC,QAAD;EAAM,WAAW9C,EAAK,QAAQ,eAAe;EAAG,YAAA;EAAW,mBAAiBc;EACjF,WAAU,MAAS;GAA0B,AAAxBtB,EAAM,eAAe,GAAGmD,EAAO;EAAG;EADlD,UAAA,CAEJxB,EAAO,OAAO,KAAK,GAAM,MAAU2B,EAAMM,GAAMrF,GAAOA,MAAUoD,EAAO,OAAO,SAAS,CAAC,CAAC,GACzFsB,KAAa,kBAAC,KAAD;GAAG,IAAI,GAAGhB,EAAG;GAAS,WAAU;GAAyB,UAAAgB;EAAa,CAAA,CAChF;;AACR;AAEA,SAAgBY,EAAY,GAAwB,GAAiB,GAAqB;CACxF,OAAO5D,EAAQ,SAASE,EAAM,sBAAsB,GAAG2D,GAAS;EAAE,cAAchC,EAAO;EAAO,WAAWtB,EAAK,SAAS,gBAAgB;CAAE,CAAC;AAC5I"}
@@ -0,0 +1,69 @@
1
+ import type { ReactElement, RefObject } from 'react';
2
+ import type { NotificationCenterBackdropConstants } from '../center-react.js';
3
+ /** The backdrop the app asks for: anything but `tint` and `none` is `blur`, the default. */
4
+ export type CenterBackdrop = 'blur' | 'tint' | 'none';
5
+ /**
6
+ * The `backdrop` prop as the panel uses it: `tint` and `none` as given, anything else `blur`; with
7
+ * the app's reduced transparency (`reduced`), `tint` in place of `blur`.
8
+ */
9
+ export declare function resolveBackdrop(value: unknown, reduced?: boolean): CenterBackdrop;
10
+ /** The ancestor attribute by which an app asks for reduced transparency, by presence. */
11
+ export declare const REDUCED_TRANSPARENCY = "data-reduced-transparency";
12
+ /**
13
+ * Whether an ancestor of the panel's root has `data-reduced-transparency`, live. The panel is
14
+ * portalled into `document.body`, so its first render reads from there and draws no blur layers it
15
+ * would drop at once; the root's own ancestors are watched once it is in the document.
16
+ */
17
+ export declare function useReducedTransparency(rootRef: RefObject<HTMLElement | null>): boolean;
18
+ /**
19
+ * The backdrop's constants, the one place to change them: four blur layers (one if the frame budget
20
+ * asks for it) and the blur kept while the page scrolls under the center (`scrollTint: true` shows
21
+ * the tone alone then, see `BACKDROP_SCROLL`).
22
+ */
23
+ export declare const CENTER_BACKDROP: NotificationCenterBackdropConstants;
24
+ /** The most blur layers the styles place (each has its rule, see styles.css). */
25
+ export declare const MAX_BACKDROP_LAYERS = 8;
26
+ /**
27
+ * True in an Apple engine (Safari on macOS, every browser on iOS and iPadOS): a stack of masked
28
+ * blur layers there shows a stale picture of the page, so it gets one layer.
29
+ */
30
+ export declare function appleEngine(): boolean;
31
+ /**
32
+ * Resolves `NotificationCenterMotion.overrides.backdrop` (a debugging channel) onto the constants
33
+ * with the motion's contract: `layers` an integer from 1 to `MAX_BACKDROP_LAYERS`, `scrollTint` a
34
+ * boolean, anything else keeps its default; unknown keys are ignored. Without a valid `layers`, an
35
+ * Apple engine (`apple`) gets one layer.
36
+ */
37
+ export declare function resolveCenterBackdrop(overrides: unknown, apple: boolean): NotificationCenterBackdropConstants;
38
+ /** The CSSOM selector, under the panel's root, of every layer the drawer's position fades. */
39
+ export declare const BACKDROP_LAYERS = " > .cloudlet-center-backdrop > *";
40
+ /** The CSSOM selector, under the panel's root, of the blur layers alone (the scroll tint fades them). */
41
+ export declare const BACKDROP_BLURS = " > .cloudlet-center-backdrop > .cloudlet-center-blur";
42
+ /**
43
+ * The scroll tint's numbers (`scrollTint`): the blur layers fade out over `fade` ms when the page
44
+ * starts to scroll under the open center and back in over `fade` ms once it has not scrolled for
45
+ * `idle` ms; the tone stays.
46
+ */
47
+ export declare const BACKDROP_SCROLL: {
48
+ readonly fade: 120;
49
+ readonly idle: 150;
50
+ };
51
+ /**
52
+ * The scroll tint: while the center is `open` and `enabled` (blur layers and `scrollTint`), a scroll
53
+ * anywhere in the document but inside the panel (its own list) hides the blur layers through
54
+ * `setBlur` and shows them again after `BACKDROP_SCROLL.idle` ms without one. No listener and no
55
+ * timer otherwise.
56
+ * A center that closes keeps its blur layers hidden while it leaves; one that opens again, or turns
57
+ * the tint off while open, shows them.
58
+ */
59
+ export declare function useScrollTint(open: boolean, enabled: boolean, rootRef: RefObject<HTMLElement | null>, setBlur: (shown: boolean) => void): void;
60
+ /**
61
+ * The backdrop's container and its layers; nothing for `none`. Hidden from assistive technology and
62
+ * the pointer. With `blur`, `layers` blur layers come first, the weakest (nearest the column's inner
63
+ * side) first and the strongest, at the edge, last: `data-cloudlet-layer` counts from the edge (0).
64
+ */
65
+ export declare function CenterBackdropLayers({ backdrop, layers }: {
66
+ readonly backdrop: CenterBackdrop;
67
+ readonly layers: number;
68
+ }): ReactElement | null;
69
+ //# sourceMappingURL=center-backdrop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"center-backdrop.d.ts","sourceRoot":"","sources":["../../src/react/center-backdrop.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oBAAoB,CAAC;AAqB9E,4FAA4F;AAC5F,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEtD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,UAAQ,GAAG,cAAc,CAG/E;AAED,yFAAyF;AACzF,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAEhE;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,OAAO,CAUtF;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,mCAAsE,CAAC;AAErG,iFAAiF;AACjF,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC;;;GAGG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAGrC;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,mCAAmC,CAU7G;AAED,8FAA8F;AAC9F,eAAO,MAAM,eAAe,qCAAqC,CAAC;AAClE,yGAAyG;AACzG,eAAO,MAAM,cAAc,yDAAyD,CAAC;AAErF;;;;GAIG;AACH,eAAO,MAAM,eAAe;aAAK,IAAI,EAAE,GAAG;aAAE,IAAI,EAAE,GAAG;CAAW,CAAC;AAEjE;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAwB9I;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,YAAY,GAAG,IAAI,CAO9I"}
@@ -0,0 +1,81 @@
1
+ import { watchAncestorAttribute as e } from "./reduced.js";
2
+ import { useEffect as t, useLayoutEffect as n, useRef as r, useState as i } from "react";
3
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
4
+ //#region src/react/center-backdrop.tsx
5
+ function s(e, t = !1) {
6
+ return e === "tint" || e === "none" ? e : t ? "tint" : "blur";
7
+ }
8
+ var c = "data-reduced-transparency";
9
+ function l(t) {
10
+ let [r, a] = i(() => typeof document < "u" && !!document.body?.closest("[data-reduced-transparency]"));
11
+ return n(() => {
12
+ let n = t.current;
13
+ if (!n) return;
14
+ let r = e(n, c, () => a(r.present()));
15
+ return a(r.present()), () => r.dispose();
16
+ }, [t]), r;
17
+ }
18
+ var u = {
19
+ layers: 4,
20
+ scrollTint: !1
21
+ };
22
+ function d() {
23
+ let e = typeof navigator > "u" ? void 0 : navigator.vendor;
24
+ return typeof e == "string" && e.startsWith("Apple");
25
+ }
26
+ function f(e, t) {
27
+ let n = e && typeof e == "object" ? e : {}, r = n.layers, i = n.scrollTint;
28
+ return {
29
+ layers: Number.isInteger(r) && r >= 1 && r <= 8 ? r : t ? 1 : u.layers,
30
+ scrollTint: typeof i == "boolean" ? i : u.scrollTint
31
+ };
32
+ }
33
+ var p = " > .cloudlet-center-backdrop > *", m = " > .cloudlet-center-backdrop > .cloudlet-center-blur", h = {
34
+ fade: 120,
35
+ idle: 150
36
+ };
37
+ function g(e, n, i, a) {
38
+ let o = r(!1);
39
+ t(() => {
40
+ let t = () => {
41
+ o.current && (o.current = !1, a(!0));
42
+ };
43
+ if (!e) return;
44
+ t();
45
+ let r = i.current;
46
+ if (!n || !r) return;
47
+ let s = r.ownerDocument, c = s.defaultView, l, u = (e) => {
48
+ let n = e.target;
49
+ n instanceof c.Node && r.contains(n) || (o.current || (o.current = !0, a(!1)), l !== void 0 && c.clearTimeout(l), l = c.setTimeout(() => {
50
+ l = void 0, t();
51
+ }, h.idle));
52
+ };
53
+ return s.addEventListener("scroll", u, {
54
+ capture: !0,
55
+ passive: !0
56
+ }), () => {
57
+ s.removeEventListener("scroll", u, { capture: !0 }), l !== void 0 && c.clearTimeout(l);
58
+ };
59
+ }, [
60
+ e,
61
+ n,
62
+ i,
63
+ a
64
+ ]);
65
+ }
66
+ function _({ backdrop: e, layers: t }) {
67
+ if (e === "none") return null;
68
+ let n = e === "blur" ? Array.from({ length: t }, (e, n) => t - 1 - n) : [];
69
+ return /* @__PURE__ */ o("div", {
70
+ className: "cloudlet-center-backdrop",
71
+ "aria-hidden": "true",
72
+ children: [n.map((e) => /* @__PURE__ */ a("div", {
73
+ className: "cloudlet-center-blur",
74
+ "data-cloudlet-layer": e
75
+ }, e)), /* @__PURE__ */ a("div", { className: "cloudlet-center-tone" })]
76
+ });
77
+ }
78
+ //#endregion
79
+ export { m as BACKDROP_BLURS, p as BACKDROP_LAYERS, h as BACKDROP_SCROLL, u as CENTER_BACKDROP, _ as CenterBackdropLayers, c as REDUCED_TRANSPARENCY, d as appleEngine, s as resolveBackdrop, f as resolveCenterBackdrop, l as useReducedTransparency, g as useScrollTint };
80
+
81
+ //# sourceMappingURL=center-backdrop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"center-backdrop.js","names":["resolveBackdrop","value","reduced","REDUCED_TRANSPARENCY","useReducedTransparency","setReduced","useState","useLayoutEffect","root","rootRef","ancestors","watchAncestorAttribute","CENTER_BACKDROP","appleEngine","vendor","resolveCenterBackdrop","source","overrides","layers","scrollTint","apple","BACKDROP_LAYERS","BACKDROP_BLURS","BACKDROP_SCROLL","useScrollTint","hidden","useRef","show","setBlur","open","enabled","doc","view","timer","onScroll","target","event","CenterBackdropLayers","backdrop","blur","index","level"],"sources":["../../src/react/center-backdrop.tsx"],"sourcesContent":["import { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport type { ReactElement, RefObject } from 'react';\nimport type { NotificationCenterBackdropConstants } from '../center-react.js';\nimport { watchAncestorAttribute } from './reduced.js';\n\n// The notification center's backdrop: what lies under its column and a band past it, at the panel's\n// edge. One container, the root's first drawn child, holds the backdrop's layers, the tone last; it\n// stands at the edge for the panel's whole height and does not travel with the drawer. The layers\n// fade in and out with the drawer's position, each on its own (the panel's motion writes one CSSOM\n// rule for the container's children): the container itself never takes `opacity`, `filter`,\n// `mask`, `clip-path` or `will-change`, nor does the root, since any of them would cut a blur in\n// the container off from the page under it.\n//\n// `blur` draws blur layers under the tone; `tint` draws the tone; `none` draws nothing. The layers'\n// boxes, radii and masks are CSS (styles.css) on the tokens of `.cloudlet-host`, so an app restyles\n// the backdrop without JavaScript; the markup only says how many layers there are and which is\n// which. A window narrower than 48rem and a browser without `backdrop-filter` hide the layers by\n// CSS and keep the tone.\n//\n// Reduced transparency turns the blur into the tone, never the other way: the app's way is `tint`\n// or `data-reduced-transparency` on any ancestor of the root (Safari does not tell the page the\n// system's setting); the system's `prefers-reduced-transparency: reduce` is CSS.\n\n/** The backdrop the app asks for: anything but `tint` and `none` is `blur`, the default. */\nexport type CenterBackdrop = 'blur' | 'tint' | 'none';\n\n/**\n * The `backdrop` prop as the panel uses it: `tint` and `none` as given, anything else `blur`; with\n * the app's reduced transparency (`reduced`), `tint` in place of `blur`.\n */\nexport function resolveBackdrop(value: unknown, reduced = false): CenterBackdrop {\n if (value === 'tint' || value === 'none') return value;\n return reduced ? 'tint' : 'blur';\n}\n\n/** The ancestor attribute by which an app asks for reduced transparency, by presence. */\nexport const REDUCED_TRANSPARENCY = 'data-reduced-transparency';\n\n/**\n * Whether an ancestor of the panel's root has `data-reduced-transparency`, live. The panel is\n * portalled into `document.body`, so its first render reads from there and draws no blur layers it\n * would drop at once; the root's own ancestors are watched once it is in the document.\n */\nexport function useReducedTransparency(rootRef: RefObject<HTMLElement | null>): boolean {\n const [reduced, setReduced] = useState(() => typeof document !== 'undefined' && !!document.body?.closest(`[${REDUCED_TRANSPARENCY}]`));\n useLayoutEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n const ancestors = watchAncestorAttribute(root, REDUCED_TRANSPARENCY, () => setReduced(ancestors.present()));\n setReduced(ancestors.present());\n return () => ancestors.dispose();\n }, [rootRef]);\n return reduced;\n}\n\n/**\n * The backdrop's constants, the one place to change them: four blur layers (one if the frame budget\n * asks for it) and the blur kept while the page scrolls under the center (`scrollTint: true` shows\n * the tone alone then, see `BACKDROP_SCROLL`).\n */\nexport const CENTER_BACKDROP: NotificationCenterBackdropConstants = { layers: 4, scrollTint: false };\n\n/** The most blur layers the styles place (each has its rule, see styles.css). */\nexport const MAX_BACKDROP_LAYERS = 8;\n\n/**\n * True in an Apple engine (Safari on macOS, every browser on iOS and iPadOS): a stack of masked\n * blur layers there shows a stale picture of the page, so it gets one layer.\n */\nexport function appleEngine(): boolean {\n const vendor = typeof navigator === 'undefined' ? undefined : navigator.vendor;\n return typeof vendor === 'string' && vendor.startsWith('Apple');\n}\n\n/**\n * Resolves `NotificationCenterMotion.overrides.backdrop` (a debugging channel) onto the constants\n * with the motion's contract: `layers` an integer from 1 to `MAX_BACKDROP_LAYERS`, `scrollTint` a\n * boolean, anything else keeps its default; unknown keys are ignored. Without a valid `layers`, an\n * Apple engine (`apple`) gets one layer.\n */\nexport function resolveCenterBackdrop(overrides: unknown, apple: boolean): NotificationCenterBackdropConstants {\n const source = overrides && typeof overrides === 'object' ? overrides as Record<string, unknown> : {};\n const layers = source.layers;\n const scrollTint = source.scrollTint;\n return {\n layers: Number.isInteger(layers) && (layers as number) >= 1 && (layers as number) <= MAX_BACKDROP_LAYERS\n ? layers as number\n : apple ? 1 : CENTER_BACKDROP.layers,\n scrollTint: typeof scrollTint === 'boolean' ? scrollTint : CENTER_BACKDROP.scrollTint,\n };\n}\n\n/** The CSSOM selector, under the panel's root, of every layer the drawer's position fades. */\nexport const BACKDROP_LAYERS = ' > .cloudlet-center-backdrop > *';\n/** The CSSOM selector, under the panel's root, of the blur layers alone (the scroll tint fades them). */\nexport const BACKDROP_BLURS = ' > .cloudlet-center-backdrop > .cloudlet-center-blur';\n\n/**\n * The scroll tint's numbers (`scrollTint`): the blur layers fade out over `fade` ms when the page\n * starts to scroll under the open center and back in over `fade` ms once it has not scrolled for\n * `idle` ms; the tone stays.\n */\nexport const BACKDROP_SCROLL = { fade: 120, idle: 150 } as const;\n\n/**\n * The scroll tint: while the center is `open` and `enabled` (blur layers and `scrollTint`), a scroll\n * anywhere in the document but inside the panel (its own list) hides the blur layers through\n * `setBlur` and shows them again after `BACKDROP_SCROLL.idle` ms without one. No listener and no\n * timer otherwise.\n * A center that closes keeps its blur layers hidden while it leaves; one that opens again, or turns\n * the tint off while open, shows them.\n */\nexport function useScrollTint(open: boolean, enabled: boolean, rootRef: RefObject<HTMLElement | null>, setBlur: (shown: boolean) => void): void {\n const hidden = useRef(false);\n useEffect(() => {\n const show = () => { if (hidden.current) { hidden.current = false; setBlur(true); } };\n if (!open) return;\n show();\n const root = rootRef.current;\n if (!enabled || !root) return;\n const doc = root.ownerDocument;\n const view = doc.defaultView!;\n let timer: number | undefined;\n const onScroll = (event: Event) => {\n const target = event.target;\n if (target instanceof view.Node && root.contains(target)) return;\n if (!hidden.current) { hidden.current = true; setBlur(false); }\n if (timer !== undefined) view.clearTimeout(timer);\n timer = view.setTimeout(() => { timer = undefined; show(); }, BACKDROP_SCROLL.idle);\n };\n doc.addEventListener('scroll', onScroll, { capture: true, passive: true });\n return () => {\n doc.removeEventListener('scroll', onScroll, { capture: true });\n if (timer !== undefined) view.clearTimeout(timer);\n };\n }, [open, enabled, rootRef, setBlur]);\n}\n\n/**\n * The backdrop's container and its layers; nothing for `none`. Hidden from assistive technology and\n * the pointer. With `blur`, `layers` blur layers come first, the weakest (nearest the column's inner\n * side) first and the strongest, at the edge, last: `data-cloudlet-layer` counts from the edge (0).\n */\nexport function CenterBackdropLayers({ backdrop, layers }: { readonly backdrop: CenterBackdrop; readonly layers: number }): ReactElement | null {\n if (backdrop === 'none') return null;\n const blur = backdrop === 'blur' ? Array.from({ length: layers }, (_, index) => layers - 1 - index) : [];\n return <div className=\"cloudlet-center-backdrop\" aria-hidden=\"true\">\n {blur.map(level => <div key={level} className=\"cloudlet-center-blur\" data-cloudlet-layer={level} />)}\n <div className=\"cloudlet-center-tone\" />\n </div>;\n}\n"],"mappings":";;;;AA8BA,SAAgBA,EAAgB,GAAgB,IAAU,IAAuB;CAE/E,OADIC,MAAU,UAAUA,MAAU,SAAeA,IAC1CC,IAAU,SAAS;AAC5B;AAGA,IAAaC,IAAuB;AAOpC,SAAgBC,EAAuB,GAAiD;CACtF,IAAM,CAACF,GAASG,KAAcC,QAAe,OAAO,WAAa,OAAe,CAAC,CAAC,SAAS,MAAM,QAAQ,6BAA2B,CAAC;CAQrI,OAPAC,QAAsB;EACpB,IAAMC,IAAOC,EAAQ;EACrB,IAAI,CAACD,GAAM;EACX,IAAME,IAAYC,EAAuBH,GAAML,SAA4BE,EAAWK,EAAU,QAAQ,CAAC,CAAC;EAE1G,OADAL,EAAWK,EAAU,QAAQ,CAAC,SACjBA,EAAU,QAAQ;CACjC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AAI;EACpF;EAEA,OADAQ,EAAI,iBAAiB,UAAUG,GAAU;GAAE,SAAS;GAAM,SAAS;EAAK,CAAC,SAC5D;GAEX,AADAH,EAAI,oBAAoB,UAAUG,GAAU,EAAE,SAAS,GAAK,CAAC,GACzDD,MAAU,KAAA,KAAWD,EAAK,aAAaC,CAAK;EAClD;CACF,GAAG;EAACJ;EAAMC;EAASrB;EAASmB;CAAO,CAAC;AACtC;AAOA,SAAgBS,EAAqB,EAAE,aAAU,aAA+F;CAC9I,IAAIC,MAAa,QAAQ,OAAO;CAChC,IAAMC,IAAOD,MAAa,SAAS,MAAM,KAAK,EAAE,QAAQpB,EAAO,IAAI,GAAG,MAAUA,IAAS,IAAIsB,CAAK,IAAI,CAAC;CACvG,OAAO,kBAAC,OAAD;EAAK,WAAU;EAA2B,eAAY;EAAtD,UAAA,CACJD,EAAK,KAAI,MAAS,kBAAC,OAAD;GAAiB,WAAU;GAAuB,uBAAqBE;EAAQ,GAArEA,CAAqE,CAAC,GACnG,kBAAC,OAAD,EAAK,WAAU,uBAAwB,CAAA,CACpC;;AACP"}
@@ -0,0 +1,16 @@
1
+ /** How long an armed button waits for its second press, as the Island's Clear all. */
2
+ export declare const CLEAR_CONFIRM = 3000;
3
+ export interface TwoStepClear {
4
+ /** The id of the armed button, if any. */
5
+ readonly armed: string | null;
6
+ /** A press of the button `id`: arms it, or runs `clear` when it is armed already. */
7
+ readonly press: (id: string, clear: () => void) => void;
8
+ /** Disarms the button `id` (focus left it), or whichever is armed without an id. */
9
+ readonly disarm: (id?: string) => void;
10
+ }
11
+ /**
12
+ * The armed state of the panel's two-step buttons. `present` names the buttons the panel shows in
13
+ * this render; `active` is false while the center is closed (or closing).
14
+ */
15
+ export declare function useTwoStepClear(present: readonly string[], active: boolean): TwoStepClear;
16
+ //# sourceMappingURL=center-clear.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"center-clear.d.ts","sourceRoot":"","sources":["../../src/react/center-clear.ts"],"names":[],"mappings":"AASA,sFAAsF;AACtF,eAAO,MAAM,aAAa,OAAO,CAAC;AAElC,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,qFAAqF;IACrF,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IACxD,oFAAoF;IACpF,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,EAAE,OAAO,GAAG,YAAY,CA8BzF"}
@@ -0,0 +1,24 @@
1
+ import { useCallback as e, useEffect as t, useLayoutEffect as n, useRef as r, useState as i } from "react";
2
+ //#region src/react/center-clear.ts
3
+ var a = 3e3;
4
+ function o(o, s) {
5
+ let [c, l] = i(null), u = r(null), d = r(void 0), f = e((e) => {
6
+ clearTimeout(d.current), d.current = void 0, u.current = e, l(e);
7
+ }, []), p = e((e) => {
8
+ u.current === null || e !== void 0 && u.current !== e || f(null);
9
+ }, [f]), m = e((e, t) => {
10
+ u.current === e ? (f(null), t()) : (f(e), d.current = setTimeout(() => p(e), a));
11
+ }, [f, p]);
12
+ return n(() => {
13
+ let e = u.current;
14
+ e !== null && (!s || !o.includes(e)) && f(null);
15
+ }), t(() => () => clearTimeout(d.current), []), {
16
+ armed: c,
17
+ press: m,
18
+ disarm: p
19
+ };
20
+ }
21
+ //#endregion
22
+ export { a as CLEAR_CONFIRM, o as useTwoStepClear };
23
+
24
+ //# sourceMappingURL=center-clear.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"center-clear.js","names":["CLEAR_CONFIRM","useTwoStepClear","armed","setArmed","useState","current","useRef","timer","set","useCallback","id","disarm","press","clear","useLayoutEffect","active","present","useEffect"],"sources":["../../src/react/center-clear.ts"],"sourcesContent":["import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';\n\n// The notification center's two-step clear buttons: \"Clear all\" in the panel's header, \"Clear\" in\n// an expanded group's heading row and the clear button of a collapsed stack. The first press arms a\n// button and shows what the second one clears; a second press within `CLEAR_CONFIRM` clears. A\n// button disarms when its time runs out, when focus leaves it and when it leaves the panel (the group\n// collapsed or expanded, shrank to one card, the center to one notification, the center closed).\n// One button is armed at a time: arming another disarms the first.\n\n/** How long an armed button waits for its second press, as the Island's Clear all. */\nexport const CLEAR_CONFIRM = 3000;\n\nexport interface TwoStepClear {\n /** The id of the armed button, if any. */\n readonly armed: string | null;\n /** A press of the button `id`: arms it, or runs `clear` when it is armed already. */\n readonly press: (id: string, clear: () => void) => void;\n /** Disarms the button `id` (focus left it), or whichever is armed without an id. */\n readonly disarm: (id?: string) => void;\n}\n\n/**\n * The armed state of the panel's two-step buttons. `present` names the buttons the panel shows in\n * this render; `active` is false while the center is closed (or closing).\n */\nexport function useTwoStepClear(present: readonly string[], active: boolean): TwoStepClear {\n const [armed, setArmed] = useState<string | null>(null);\n const current = useRef<string | null>(null);\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const set = useCallback((id: string | null) => {\n clearTimeout(timer.current);\n timer.current = undefined;\n current.current = id;\n setArmed(id);\n }, []);\n const disarm = useCallback((id?: string) => {\n if (current.current === null || (id !== undefined && current.current !== id)) return;\n set(null);\n }, [set]);\n const press = useCallback((id: string, clear: () => void) => {\n if (current.current === id) {\n set(null);\n clear();\n return;\n }\n set(id);\n timer.current = setTimeout(() => disarm(id), CLEAR_CONFIRM);\n }, [set, disarm]);\n // The armed button left with this commit: the next one starts unarmed.\n useLayoutEffect(() => {\n const id = current.current;\n if (id !== null && (!active || !present.includes(id))) set(null);\n });\n useEffect(() => () => clearTimeout(timer.current), []);\n return { armed, press, disarm };\n}\n"],"mappings":";;AAUA,IAAaA,IAAgB;AAe7B,SAAgBC,EAAgB,GAA4B,GAA+B;CACzF,IAAM,CAACC,GAAOC,KAAYC,EAAwB,IAAI,GAChDC,IAAUC,EAAsB,IAAI,GACpCC,IAAQD,EAAkD,KAAA,CAAS,GACnEE,IAAMC,GAAa,MAAsB;EAI7C,AAHA,aAAaF,EAAM,OAAO,GAC1B,EAAM,UAAU,KAAA,GAChB,EAAQ,UAAUG,GAClBP,EAASO,CAAE;CACb,GAAG,CAAC,CAAC,GACCC,IAASF,GAAa,MAAgB;EAC1C,AAAIJ,EAAQ,YAAY,QAASK,MAAO,KAAA,KAAaL,EAAQ,YAAYK,KACzEF,EAAI,IAAI;CACV,GAAG,CAACA,CAAG,CAAC,GACFI,IAAQH,GAAa,GAAY,MAAsB;EAC3D,AAAIJ,EAAQ,YAAYK,KACtBF,EAAI,IAAI,GACRK,EAAM,MAGRL,EAAIE,CAAE,GACN,EAAM,UAAU,iBAAiBC,EAAOD,CAAE,GAAGV,CAAa;CAC5D,GAAG,CAACQ,GAAKG,CAAM,CAAC;CAOhB,OALAG,QAAsB;EACpB,IAAMJ,IAAKL,EAAQ;EACnB,AAAIK,MAAO,SAAS,CAACK,KAAU,CAACC,EAAQ,SAASN,CAAE,MAAIF,EAAI,IAAI;CACjE,CAAC,GACDS,cAAsB,aAAaV,EAAM,OAAO,GAAG,CAAC,CAAC,GAC9C;EAAE;EAAO;EAAO;CAAO;AAChC"}