@cloudlet/toast 1.4.0 → 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.
- package/CHANGELOG.md +165 -0
- package/README.md +3 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +19 -15
- package/dist/agent.js.map +1 -1
- package/dist/center-react.d.ts +286 -0
- package/dist/center-react.d.ts.map +1 -0
- package/dist/center-react.js +2 -0
- package/dist/center.d.ts +3 -0
- package/dist/center.d.ts.map +1 -0
- package/dist/center.js +1 -0
- package/dist/core/agent-port.d.ts +2 -0
- package/dist/core/agent-port.d.ts.map +1 -1
- package/dist/core/agent-port.js +3 -0
- package/dist/core/agent-port.js.map +1 -1
- package/dist/react/card.d.ts +4 -0
- package/dist/react/card.d.ts.map +1 -1
- package/dist/react/card.js +3 -8
- package/dist/react/card.js.map +1 -1
- package/dist/react/center-backdrop.d.ts +69 -0
- package/dist/react/center-backdrop.d.ts.map +1 -0
- package/dist/react/center-backdrop.js +81 -0
- package/dist/react/center-backdrop.js.map +1 -0
- package/dist/react/center-clear.d.ts +16 -0
- package/dist/react/center-clear.d.ts.map +1 -0
- package/dist/react/center-clear.js +24 -0
- package/dist/react/center-clear.js.map +1 -0
- package/dist/react/center-gestures.d.ts +47 -0
- package/dist/react/center-gestures.d.ts.map +1 -0
- package/dist/react/center-gestures.js +74 -0
- package/dist/react/center-gestures.js.map +1 -0
- package/dist/react/center-motion.d.ts +174 -0
- package/dist/react/center-motion.d.ts.map +1 -0
- package/dist/react/center-motion.js +344 -0
- package/dist/react/center-motion.js.map +1 -0
- package/dist/react/center.d.ts +15 -0
- package/dist/react/center.d.ts.map +1 -0
- package/dist/react/center.js +1287 -0
- package/dist/react/center.js.map +1 -0
- package/dist/react/focus.d.ts +7 -0
- package/dist/react/focus.d.ts.map +1 -0
- package/dist/react/focus.js +14 -0
- package/dist/react/focus.js.map +1 -0
- package/dist/react/gestures.d.ts +33 -2
- package/dist/react/gestures.d.ts.map +1 -1
- package/dist/react/gestures.js +181 -149
- package/dist/react/gestures.js.map +1 -1
- package/dist/react/host.d.ts.map +1 -1
- package/dist/react/host.js +287 -283
- package/dist/react/host.js.map +1 -1
- package/dist/react/motion.d.ts +18 -11
- package/dist/react/motion.d.ts.map +1 -1
- package/dist/react/motion.js +6 -3
- package/dist/react/motion.js.map +1 -1
- package/dist/react/reduced.d.ts +24 -0
- package/dist/react/reduced.d.ts.map +1 -0
- package/dist/react/reduced.js +35 -0
- package/dist/react/reduced.js.map +1 -0
- package/dist/react/zoom.d.ts +12 -0
- package/dist/react/zoom.d.ts.map +1 -0
- package/dist/react/zoom.js +21 -0
- package/dist/react/zoom.js.map +1 -0
- package/dist/react.d.ts +4 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -1
- package/src/agent.ts +11 -6
- package/src/center-react.ts +300 -0
- package/src/center.ts +27 -0
- package/src/core/agent-port.ts +3 -0
- package/src/react/card.tsx +5 -6
- package/src/react/center-backdrop.tsx +151 -0
- package/src/react/center-clear.ts +56 -0
- package/src/react/center-gestures.ts +143 -0
- package/src/react/center-motion.ts +504 -0
- package/src/react/center.tsx +1557 -0
- package/src/react/focus.ts +18 -0
- package/src/react/gestures.ts +127 -37
- package/src/react/host.tsx +17 -5
- package/src/react/motion.ts +16 -9
- package/src/react/reduced.ts +52 -0
- package/src/react/zoom.ts +26 -0
- package/src/react.ts +4 -0
package/dist/react/card.js.map
CHANGED
|
@@ -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;CAAE,CAAC,CAAC,KAAK,IAAI;CACxD,OAAO,GAAO,MAAU,GAAGC,EAAM,MAAMC;CACvC,gBAAe,MAAS,GAAGJ,EAAM;CACjC,OAA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E;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;CAC9D,OAAO,2BAA2B;EAAE,OAAO,EAAE,QAAQ,GAAK;CAAG;CAC7D,OAAO,yBAAyB,GAAkB,GAA+B;EAC/E,OAAOC,E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,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,GAAG,CAACD,CAAO,CAAC,GACLP;AACT;AAOA,IAAaU,IAAuD;CAAE,QAAQ;CAAG,YAAY;AAAM;AASnG,SAAgBC,IAAuB;CACrC,IAAMC,IAAS,OAAO,YAAc,MAAc,KAAA,IAAY,UAAU;CACxE,OAAO,OAAOA,KAAW,YAAYA,EAAO,WAA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ClD;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"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { CenterMotion } from './center-motion.js';
|
|
2
|
+
/** What the center's swipes read from the panel at the moment they need it. */
|
|
3
|
+
interface CenterGestureOptions {
|
|
4
|
+
readonly motion: CenterMotion;
|
|
5
|
+
/** The column's width (CSS px): the drawer's threshold and, with `travel`, its full way. */
|
|
6
|
+
readonly width: () => number;
|
|
7
|
+
/** How far past its own width a closed card lies (`CENTER_MOTION.travel`). */
|
|
8
|
+
readonly travel: () => number;
|
|
9
|
+
/** The physical edge the drawer sits at: +1 right, -1 left (also in RTL). */
|
|
10
|
+
readonly edge: () => 1 | -1;
|
|
11
|
+
readonly open: () => boolean;
|
|
12
|
+
/** Asks the app to close the center (its `setOpen(false)`). */
|
|
13
|
+
readonly close: () => void;
|
|
14
|
+
/** The listed notification a card's motion key stands for, if it is still listed and can be dismissed. */
|
|
15
|
+
readonly idOf: (key: string) => string | null;
|
|
16
|
+
/** Asks the app to dismiss a notification (`onDismiss`). */
|
|
17
|
+
readonly dismiss: (id: string) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Hands the release speed (px per second) and the side the card was swiped to (+1 right, -1 left)
|
|
20
|
+
* to the copy that leaves for a swiped card, should it leave.
|
|
21
|
+
*/
|
|
22
|
+
readonly fling: (key: string, velocity: number, direction: 1 | -1) => void;
|
|
23
|
+
readonly now: () => number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The notification center's swipes, on the Toaster's `createSwipe` and its thresholds
|
|
27
|
+
* (`MOTION.swipe`): sideways only, vertical stays the list's native scrolling.
|
|
28
|
+
*
|
|
29
|
+
* Towards the drawer's edge, anywhere on the column, the drawer follows the fingers (resisting
|
|
30
|
+
* outwards past open); let go past the threshold it asks the app to close and keeps the release
|
|
31
|
+
* speed for the closing spring, short of it it springs back open. Away from the edge on a card that
|
|
32
|
+
* can be dismissed, the card follows and fades; past the threshold the app is asked to dismiss it and
|
|
33
|
+
* springs back while the app decides; its copy flies on with the release speed when the app takes it
|
|
34
|
+
* out soon after, even from its place (a card the app keeps stays); a card of an expanded group
|
|
35
|
+
* swipes on its own. Away from the edge elsewhere, a
|
|
36
|
+
* collapsed stack included, nothing happens. A sideways trackpad stream over the
|
|
37
|
+
* panel never reaches the browser's back and forward swipe, and the rest of a committed stream is
|
|
38
|
+
* swallowed until it goes idle, even once the closing panel is inert. Reduced motion turns the
|
|
39
|
+
* swipes off; the buttons stay.
|
|
40
|
+
*/
|
|
41
|
+
export declare function attachCenterGestures(root: HTMLElement, options: CenterGestureOptions): {
|
|
42
|
+
/** Ends a running swipe; the swallowed rest of a committed trackpad stream goes on to its end. */
|
|
43
|
+
cancel(): void;
|
|
44
|
+
dispose: () => void;
|
|
45
|
+
};
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=center-gestures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"center-gestures.d.ts","sourceRoot":"","sources":["../../src/react/center-gestures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKvD,+EAA+E;AAC/E,UAAU,oBAAoB;IAC5B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,4FAA4F;IAC5F,QAAQ,CAAC,KAAK,EAAE,MAAM,MAAM,CAAC;IAC7B,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC;IAC9B,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;IAC3B,0GAA0G;IAC1G,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IAC9C,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC;IAC3E,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAC;CAC5B;AAWD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,oBAAoB;IAoFjF,kGAAkG;IAClG,MAAM;IACN,OAAO;EAEV"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { MOTION as e } from "./motion.js";
|
|
2
|
+
import { createSwipe as t, decideRelease as n, rubberBand as r } from "./gestures.js";
|
|
3
|
+
//#region src/react/center-gestures.ts
|
|
4
|
+
var i = {
|
|
5
|
+
negative: !1,
|
|
6
|
+
positive: !0
|
|
7
|
+
}, a = 2, o = (e) => Number.isFinite(e) ? Math.max(-2, Math.min(a, e)) : 0;
|
|
8
|
+
function s(a, s) {
|
|
9
|
+
let { motion: c } = s, l = () => a.querySelector(".cloudlet-center-column");
|
|
10
|
+
function u() {
|
|
11
|
+
let t = s.edge(), a = () => Math.max(1, s.width() + s.travel());
|
|
12
|
+
c.grab();
|
|
13
|
+
let l = Math.min(1, c.value("p")), u = (e, r) => n(e * t, r * t, s.width(), i) !== 0;
|
|
14
|
+
return {
|
|
15
|
+
move(n) {
|
|
16
|
+
if (!s.open()) return;
|
|
17
|
+
let i = l - n * t / a();
|
|
18
|
+
c.drag(i <= 1 ? i : 1 + r((i - 1) * a(), e.swipe.resist) / a());
|
|
19
|
+
},
|
|
20
|
+
decide: u,
|
|
21
|
+
end(e, n) {
|
|
22
|
+
if (!s.open()) return;
|
|
23
|
+
let r = (e) => -e * t * 1e3 / a();
|
|
24
|
+
u(e, n) ? (c.release(r(n)), s.close()) : c.release(r(o(n)));
|
|
25
|
+
},
|
|
26
|
+
cancel() {
|
|
27
|
+
s.open() && c.release(0);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function d(t) {
|
|
32
|
+
let a = t.dataset.cloudletMotionKey, l = a ? s.idOf(a) : null;
|
|
33
|
+
if (!a || l === null) return null;
|
|
34
|
+
let u = s.edge() > 0 ? -1 : 1, d = t.offsetWidth || s.width(), f = () => s.open() && t.isConnected, p = (e, t) => n(e * u, t * u, d, i) !== 0;
|
|
35
|
+
return {
|
|
36
|
+
move(t) {
|
|
37
|
+
f() && c.dragCard(a, t * u >= 0 ? t : r(t, e.swipe.resist));
|
|
38
|
+
},
|
|
39
|
+
decide: p,
|
|
40
|
+
end(e, t) {
|
|
41
|
+
f() && (p(e, t) && (s.fling(a, t * 1e3, u), s.dismiss(l)), c.releaseCard(a, o(t) * 1e3));
|
|
42
|
+
},
|
|
43
|
+
cancel() {
|
|
44
|
+
f() && c.releaseCard(a, 0);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function f(e) {
|
|
49
|
+
if (c.reduced || !s.open() || !l()?.contains(e)) return null;
|
|
50
|
+
let t = e.closest(".cloudlet-center-list .cloudlet-card[data-cloudlet-motion-key]:not([data-cloudlet-place])");
|
|
51
|
+
return {
|
|
52
|
+
x: !0,
|
|
53
|
+
y: !1,
|
|
54
|
+
start: (e, n) => n === s.edge() ? u() : t ? d(t) : null,
|
|
55
|
+
release() {}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
let p = t(a, {
|
|
59
|
+
begin: f,
|
|
60
|
+
claimsWheel: (e) => s.open() && a.contains(e),
|
|
61
|
+
holdsStream: !0,
|
|
62
|
+
now: s.now
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
cancel() {
|
|
66
|
+
p.active && p.cancel();
|
|
67
|
+
},
|
|
68
|
+
dispose: p.dispose
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { s as attachCenterGestures };
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=center-gestures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"center-gestures.js","names":["towards","RETURN_SPEED","returnSpeed","velocity","attachCenterGestures","options","column","root","drawerSession","sign","range","from","motion","commits","decideRelease","offset","p","rubberBand","MOTION","speed","value","cardSession","key","card","id","width","live","begin","target","direction","swipe","createSwipe"],"sources":["../../src/react/center-gestures.ts"],"sourcesContent":["import type { CenterMotion } from './center-motion.js';\nimport { createSwipe, decideRelease, rubberBand } from './gestures.js';\nimport type { SwipeCandidate, SwipeSession } from './gestures.js';\nimport { MOTION } from './motion.js';\n\n/** What the center's swipes read from the panel at the moment they need it. */\ninterface CenterGestureOptions {\n readonly motion: CenterMotion;\n /** The column's width (CSS px): the drawer's threshold and, with `travel`, its full way. */\n readonly width: () => number;\n /** How far past its own width a closed card lies (`CENTER_MOTION.travel`). */\n readonly travel: () => number;\n /** The physical edge the drawer sits at: +1 right, -1 left (also in RTL). */\n readonly edge: () => 1 | -1;\n readonly open: () => boolean;\n /** Asks the app to close the center (its `setOpen(false)`). */\n readonly close: () => void;\n /** The listed notification a card's motion key stands for, if it is still listed and can be dismissed. */\n readonly idOf: (key: string) => string | null;\n /** Asks the app to dismiss a notification (`onDismiss`). */\n readonly dismiss: (id: string) => void;\n /**\n * Hands the release speed (px per second) and the side the card was swiped to (+1 right, -1 left)\n * to the copy that leaves for a swiped card, should it leave.\n */\n readonly fling: (key: string, velocity: number, direction: 1 | -1) => void;\n readonly now: () => number;\n}\n\nconst towards = { negative: false, positive: true } as const;\n\n/**\n * The most speed (px/ms) a release short of its threshold springs back with: the drawer springs\n * back open without passing closed on the way, whatever the swipe's own speed.\n */\nconst RETURN_SPEED = 2;\nconst returnSpeed = (velocity: number) => Number.isFinite(velocity) ? Math.max(-RETURN_SPEED, Math.min(RETURN_SPEED, velocity)) : 0;\n\n/**\n * The notification center's swipes, on the Toaster's `createSwipe` and its thresholds\n * (`MOTION.swipe`): sideways only, vertical stays the list's native scrolling.\n *\n * Towards the drawer's edge, anywhere on the column, the drawer follows the fingers (resisting\n * outwards past open); let go past the threshold it asks the app to close and keeps the release\n * speed for the closing spring, short of it it springs back open. Away from the edge on a card that\n * can be dismissed, the card follows and fades; past the threshold the app is asked to dismiss it and\n * springs back while the app decides; its copy flies on with the release speed when the app takes it\n * out soon after, even from its place (a card the app keeps stays); a card of an expanded group\n * swipes on its own. Away from the edge elsewhere, a\n * collapsed stack included, nothing happens. A sideways trackpad stream over the\n * panel never reaches the browser's back and forward swipe, and the rest of a committed stream is\n * swallowed until it goes idle, even once the closing panel is inert. Reduced motion turns the\n * swipes off; the buttons stay.\n */\nexport function attachCenterGestures(root: HTMLElement, options: CenterGestureOptions) {\n const { motion } = options;\n const column = () => root.querySelector('.cloudlet-center-column');\n\n function drawerSession(): SwipeSession {\n const sign = options.edge();\n const range = () => Math.max(1, options.width() + options.travel());\n // The finger takes the drawer where it is, also in the middle of its spring.\n motion.grab();\n const from = Math.min(1, motion.value('p'));\n const commits = (offset: number, velocity: number) => decideRelease(offset * sign, velocity * sign, options.width(), towards) !== 0;\n return {\n move(offset) {\n if (!options.open()) return;\n const p = from - offset * sign / range();\n // Outwards past open the drawer resists.\n motion.drag(p <= 1 ? p : 1 + rubberBand((p - 1) * range(), MOTION.swipe.resist) / range());\n },\n decide: commits,\n end(offset, velocity) {\n if (!options.open()) return;\n // px/ms towards the edge → the position's speed in p per second.\n const speed = (value: number) => -value * sign * 1000 / range();\n // Released towards open with the swipe's own speed: when the app closes the center the spring\n // turns from there, keeping it; when the app keeps it open the drawer settles back.\n if (commits(offset, velocity)) {\n motion.release(speed(velocity));\n options.close();\n return;\n }\n motion.release(speed(returnSpeed(velocity)));\n },\n cancel() { if (options.open()) motion.release(0); },\n };\n }\n\n function cardSession(card: HTMLElement): SwipeSession | null {\n const key = card.dataset.cloudletMotionKey;\n const id = key ? options.idOf(key) : null;\n if (!key || id === null) return null;\n const sign = (options.edge() > 0 ? -1 : 1) as 1 | -1;\n const width = card.offsetWidth || options.width();\n const live = () => options.open() && card.isConnected;\n const commits = (offset: number, velocity: number) => decideRelease(offset * sign, velocity * sign, width, towards) !== 0;\n return {\n move(offset) {\n if (!live()) return;\n // Towards the edge a card barely gives.\n motion.dragCard(key, offset * sign >= 0 ? offset : rubberBand(offset, MOTION.swipe.resist));\n },\n decide: commits,\n end(offset, velocity) {\n if (!live()) return;\n if (commits(offset, velocity)) {\n options.fling(key, velocity * 1000, sign);\n options.dismiss(id);\n }\n // The card springs back while the app decides; taken out soon after (the panel's fling\n // window), it flies on from wherever the spring has taken it, with the swipe's speed.\n motion.releaseCard(key, returnSpeed(velocity) * 1000);\n },\n cancel() { if (live()) motion.releaseCard(key, 0); },\n };\n }\n\n function begin(target: Element): SwipeCandidate | null {\n if (motion.reduced || !options.open() || !column()?.contains(target)) return null;\n // A card of the list or of an expanded group; a collapsed stack is no card (it hides others).\n const card = target.closest<HTMLElement>('.cloudlet-center-list .cloudlet-card[data-cloudlet-motion-key]:not([data-cloudlet-place])');\n return {\n x: true, y: false,\n start: (_axis, direction) => direction === options.edge() ? drawerSession() : card ? cardSession(card) : null,\n release() {},\n };\n }\n\n const swipe = createSwipe(root, {\n begin,\n // Sideways streams over the open panel never turn into the browser's history swipe.\n claimsWheel: target => options.open() && root.contains(target),\n holdsStream: true,\n now: options.now,\n });\n return {\n /** Ends a running swipe; the swallowed rest of a committed trackpad stream goes on to its end. */\n cancel() { if (swipe.active) swipe.cancel(); },\n dispose: swipe.dispose,\n };\n}\n"],"mappings":";;;AA6BA,IAAMA,IAAU;CAAE,UAAU;CAAO,UAAU;AAAK,GAM5CC,IAAe,GACfC,KAAe,MAAqB,OAAO,SAASC,CAAQ,IAAI,KAAK,IAAI,IAAe,KAAK,IAAIF,GAAcE,CAAQ,CAAC,IAAI;AAkBlI,SAAgBC,EAAqB,GAAmB,GAA+B;CACrF,IAAM,EAAE,cAAWC,GACbC,UAAeC,EAAK,cAAc,yBAAyB;CAEjE,SAASC,IAA8B;EACrC,IAAMC,IAAOJ,EAAQ,KAAK,GACpBK,UAAc,KAAK,IAAI,GAAGL,EAAQ,MAAM,IAAIA,EAAQ,OAAO,CAAC;EAElE,EAAO,KAAK;EACZ,IAAMM,IAAO,KAAK,IAAI,GAAGC,EAAO,MAAM,GAAG,CAAC,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