@cloudlet/toast 1.2.0 → 1.4.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +139 -0
- package/README.md +7 -3
- package/dist/agent.d.ts +334 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +494 -0
- package/dist/agent.js.map +1 -0
- package/dist/contracts/events.d.ts +14 -0
- package/dist/contracts/events.d.ts.map +1 -1
- package/dist/contracts/internal.d.ts +16 -2
- package/dist/contracts/internal.d.ts.map +1 -1
- package/dist/contracts/notifications.d.ts +16 -0
- package/dist/contracts/notifications.d.ts.map +1 -1
- package/dist/contracts/snapshots.d.ts +8 -0
- package/dist/contracts/snapshots.d.ts.map +1 -1
- package/dist/core/actions.d.ts +69 -0
- package/dist/core/actions.d.ts.map +1 -0
- package/dist/core/actions.js +160 -0
- package/dist/core/actions.js.map +1 -0
- package/dist/core/agent-port.d.ts +116 -0
- package/dist/core/agent-port.d.ts.map +1 -0
- package/dist/core/agent-port.js +138 -0
- package/dist/core/agent-port.js.map +1 -0
- package/dist/core/bridge.d.ts.map +1 -1
- package/dist/core/bridge.js +120 -231
- package/dist/core/bridge.js.map +1 -1
- package/dist/core/controller.d.ts +44 -9
- package/dist/core/controller.d.ts.map +1 -1
- package/dist/core/controller.js +367 -292
- package/dist/core/controller.js.map +1 -1
- package/dist/core/validation.d.ts.map +1 -1
- package/dist/core/validation.js +103 -94
- package/dist/core/validation.js.map +1 -1
- package/dist/react/card.d.ts.map +1 -1
- package/dist/react/card.js +3 -3
- package/dist/react/card.js.map +1 -1
- package/dist/react/gestures.d.ts +6 -0
- package/dist/react/gestures.d.ts.map +1 -1
- package/dist/react/gestures.js +28 -15
- package/dist/react/gestures.js.map +1 -1
- package/dist/react/host.d.ts.map +1 -1
- package/dist/react/host.js +290 -270
- package/dist/react/host.js.map +1 -1
- package/dist/react.d.ts +9 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +3 -2
- package/src/agent.ts +879 -0
- package/src/contracts/events.ts +15 -0
- package/src/contracts/internal.ts +14 -1
- package/src/contracts/notifications.ts +16 -0
- package/src/contracts/snapshots.ts +8 -0
- package/src/core/actions.ts +149 -0
- package/src/core/agent-port.ts +237 -0
- package/src/core/bridge.ts +19 -105
- package/src/core/controller.ts +183 -56
- package/src/core/validation.ts +6 -3
- package/src/react/card.tsx +4 -3
- package/src/react/gestures.ts +45 -8
- package/src/react/host.tsx +48 -12
- package/src/react.ts +9 -1
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 => result.errors.fields[field.name] !== undefined);\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 const error = draft.errors.fields[field.name];\n const props = {\n id: fieldId, name: field.name, className: part('field', 'cloudlet-field'), defaultValue: 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: ()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AAC;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\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,kBAAi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KAAQ,MAAK;KAAS,yBAAsB;KAAS,WAAWlD,EAAK,UAAU,iCAAiC;KACvH,cAAYmB,EAAO;KAAO,iBAAeoB;KAAS,aAAWA;KAC7D,oBAAkBC,IAASW,IAAgBV,IAAY,GAAGhB,EAAG,UAAU,KAAA;KACtE,UAAAc,IAAU,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"}
|
package/dist/react/gestures.d.ts
CHANGED
|
@@ -32,6 +32,12 @@ export interface SwipeCandidate {
|
|
|
32
32
|
interface SwipeOptions {
|
|
33
33
|
/** Null ignores the input; the candidate is released exactly once. */
|
|
34
34
|
readonly begin: (target: Element, input: 'pointer' | 'wheel') => SwipeCandidate | null;
|
|
35
|
+
/**
|
|
36
|
+
* The open Island under a wheel stream: until the stream's axis is decided, and for every
|
|
37
|
+
* mostly horizontal event after that, the browser gets no wheel event from it (no history swipe),
|
|
38
|
+
* even where no swipe can start (an end of the slider, reduced motion, outside the slides).
|
|
39
|
+
*/
|
|
40
|
+
readonly claimsWheel?: (target: Element) => boolean;
|
|
35
41
|
readonly now: () => number;
|
|
36
42
|
}
|
|
37
43
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gestures.d.ts","sourceRoot":"","sources":["../../src/react/gestures.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,GAAE,MAAyB,GAAG,MAAM,CAI5G;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAC/E,OAAO,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAQjF;AAED,MAAM,MAAM,SAAS,GAAG,GAAG,GAAG,GAAG,CAAC;AAElC,+EAA+E;AAC/E,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,2FAA2F;IAC3F,QAAQ,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,gFAAgF;IAChF,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,6FAA6F;AAC7F,MAAM,WAAW,cAAc;IAC7B,QAAQ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E,MAAM,IAAI,CAAC;CAC7B;AAED,6FAA6F;AAC7F,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,YAAY,GAAG,IAAI,CAAC;IACzD,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,UAAU,YAAY;IACpB,sEAAsE;IACtE,QAAQ,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,KAAK,cAAc,GAAG,IAAI,CAAC;IACvF;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC;IACpD,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAC;CAC5B;AAwCD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY;;;;EAiOnE"}
|
package/dist/react/gestures.js
CHANGED
|
@@ -175,22 +175,35 @@ function a(e, n) {
|
|
|
175
175
|
return;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
178
|
+
s ||= {
|
|
179
|
+
claimed: i.target instanceof a.Element && (n.claimsWheel?.(i.target) ?? !1),
|
|
180
|
+
axis: null,
|
|
181
|
+
travelX: 0,
|
|
182
|
+
travelY: 0,
|
|
183
|
+
candidate: null,
|
|
184
|
+
session: null,
|
|
185
|
+
spent: !1,
|
|
186
|
+
spentAt: 0,
|
|
187
|
+
lastDx: u,
|
|
188
|
+
offset: 0,
|
|
189
|
+
velocity: 0,
|
|
190
|
+
time: p,
|
|
191
|
+
timer: 0
|
|
192
|
+
};
|
|
192
193
|
let m = s;
|
|
193
|
-
if (a.clearTimeout(m.timer), m.timer = a.setTimeout(() => d(!0), t.wheelIdle), m.lastDx = u, !m.
|
|
194
|
+
if (a.clearTimeout(m.timer), m.timer = a.setTimeout(() => d(!0), t.wheelIdle), m.lastDx = u, !m.axis) {
|
|
195
|
+
m.travelX += u, m.travelY += f;
|
|
196
|
+
let e = Math.abs(m.travelX), r = Math.abs(m.travelY);
|
|
197
|
+
if (Math.max(e, r) >= t.intent) {
|
|
198
|
+
m.axis = e > r ? "x" : "y";
|
|
199
|
+
let t = i.target, o = m.axis === "x" && t instanceof a.Element ? n.begin(t, "wheel") : null, s = o?.x ? o.start("x") : null;
|
|
200
|
+
o && !s && o.release(), s && (m.candidate = o, m.session = s, m.offset = u - m.travelX);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (!m.session) {
|
|
204
|
+
m.claimed && (!m.axis || Math.abs(u) > Math.abs(f)) && i.preventDefault(), m.time = p;
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
194
207
|
i.preventDefault();
|
|
195
208
|
let h = p - m.time;
|
|
196
209
|
if (h > 0 && (m.velocity = -u / h), m.offset -= u, m.time = p, e.dataset.dragging = "x", m.session.move(m.offset), r(m.offset, m.velocity, e.clientWidth || 0, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gestures.js","names":["MOTION","rubberBand","swipe","offset","dimension","coefficient","decideRelease","sign","allowed","toward","velocity","distance","interactive","createSwipe","view","root","current","wheel","suppressUntil","disposed","finish","gesture","endWheel","stream","commit","cancel","secondPointer","event","down","target","control","candidate","options","sample","elapsed","axis","position","last","release","move","horizontal","vertical","session","selection","up","x","cancelled","lost","native","listeners","unit","dx","dy","time","previous","type","listener","capture"],"sources":["../../src/react/gestures.ts"],"sourcesContent":["import { MOTION } from './motion.js';\n\nconst { swipe } = MOTION;\n\n/**\n * Edge resistance (iOS-style rubber band): the result approaches `dimension`\n * asymptotically and keeps the sign of the raw finger travel.\n */\nexport function rubberBand(offset: number, dimension: number, coefficient: number = swipe.rubberBand): number {\n if (!Number.isFinite(offset) || !(dimension > 0)) return 0;\n const travel = Math.abs(offset);\n return Math.sign(offset) * (1 - 1 / (travel * coefficient / dimension + 1)) * dimension;\n}\n\n/**\n * Release decision along one axis. Returns the sign of the travel when the swipe\n * commits that way (distance past `MOTION.swipe.distance` of `dimension`, or a flick of\n * at least `minDistance` px faster than `velocity` px/ms), 0 when it springs back.\n * A direction without a destination never commits; a flick back always cancels.\n */\nexport function decideRelease(offset: number, velocity: number, dimension: number,\n allowed: { readonly negative: boolean; readonly positive: boolean }): -1 | 0 | 1 {\n const sign = offset > 0 ? 1 : offset < 0 ? -1 : 0;\n if (!sign || !(sign > 0 ? allowed.positive : allowed.negative)) return 0;\n const toward = Number.isFinite(velocity) ? velocity * sign : 0;\n if (toward < -swipe.velocity) return 0;\n const distance = Math.abs(offset);\n if (dimension > 0 && distance > dimension * swipe.distance) return sign;\n return distance >= swipe.minDistance && toward > swipe.velocity ? sign : 0;\n}\n\nexport type SwipeAxis = 'x' | 'y';\n\n/** A started swipe along one axis. Offsets are raw finger travel in CSS px. */\nexport interface SwipeSession {\n readonly move: (offset: number) => void;\n /** Velocity is CSS px/ms along the axis, positive in the direction of positive offsets. */\n readonly end: (offset: number, velocity: number) => void;\n /** Lost capture, a second pointer, orientation change or an external cancel. */\n readonly cancel: () => void;\n}\n\n/** What may start from one pointerdown or wheel stream; `release` ends the intent window. */\nexport interface SwipeCandidate {\n readonly x: boolean;\n readonly y: boolean;\n readonly start: (axis: SwipeAxis) => SwipeSession | null;\n readonly release: () => void;\n}\n\ninterface SwipeOptions {\n /** Null ignores the input; the candidate is released exactly once. */\n readonly begin: (target: Element, input: 'pointer' | 'wheel') => SwipeCandidate | null;\n readonly now: () => number;\n}\n\ninterface PointerSwipe {\n readonly pointer: number;\n readonly candidate: SwipeCandidate;\n readonly startX: number;\n readonly startY: number;\n session: SwipeSession | null;\n axis: SwipeAxis | null;\n captured: boolean;\n x: number;\n y: number;\n lastX: number;\n lastY: number;\n time: number;\n velocityX: number;\n velocityY: number;\n}\n\ninterface WheelSwipe {\n readonly candidate: SwipeCandidate | null;\n session: SwipeSession | null;\n /** Committed early: the rest of the stream (macOS momentum) is swallowed until it goes idle. */\n spent: boolean;\n spentAt: number;\n lastDx: number;\n offset: number;\n velocity: number;\n time: number;\n timer: number;\n}\n\nconst interactive = 'button,a,input,select,textarea,summary,label,[role=\"button\"],[role=\"link\"],[contenteditable]:not([contenteditable=\"false\"])';\n\n/**\n * Pointer and trackpad ownership for one host. The axis is decided by the first\n * `MOTION.swipe.intent` px; an axis the target does not own is given back to the\n * browser (native scroll) for the rest of the gesture. Buttons and links never start\n * a swipe, except the collapsed pill, which is itself the swipe surface. Layout,\n * physics and store commands stay with the caller.\n */\nexport function createSwipe(root: HTMLElement, options: SwipeOptions) {\n const view = root.ownerDocument.defaultView;\n let current: PointerSwipe | null = null;\n let wheel: WheelSwipe | null = null;\n let suppressUntil = 0;\n let disposed = false;\n if (!view) return { cancel() {}, dispose() {}, get active() { return false; } };\n\n function finish(): PointerSwipe | null {\n const gesture = current;\n if (!gesture) return null;\n // Lost capture, store updates and callbacks can be synchronous/reentrant:\n // clear ownership before releasing anything.\n current = null;\n delete root.dataset.dragging;\n if (gesture.captured && root.hasPointerCapture?.(gesture.pointer)) root.releasePointerCapture(gesture.pointer);\n gesture.candidate.release();\n return gesture;\n }\n function endWheel(commit: boolean) {\n const stream = wheel;\n if (!stream) return;\n wheel = null;\n view!.clearTimeout(stream.timer);\n if (stream.session) delete root.dataset.dragging;\n stream.candidate?.release();\n if (commit) stream.session?.end(stream.offset, stream.velocity);\n else stream.session?.cancel();\n }\n const cancel = () => {\n finish()?.session?.cancel();\n endWheel(false);\n };\n const secondPointer = (event: PointerEvent) => {\n if (current && event.pointerId !== current.pointer) cancel();\n };\n const down = (event: PointerEvent) => {\n // A new deliberate activation must work even if a previous browser did not\n // generate the compatibility click suppressed after an accepted drag.\n if (disposed || current || !event.isPrimary || event.button !== 0) return;\n suppressUntil = 0;\n const target = event.target;\n if (!(target instanceof view.Element)) return;\n const control = target.closest(interactive);\n if (control && root.contains(control) && !control.matches('[data-cloudlet-pill]')) return;\n endWheel(false);\n const candidate = options.begin(target, 'pointer');\n if (!candidate) return;\n current = {\n pointer: event.pointerId, candidate, startX: event.clientX, startY: event.clientY, session: null, axis: null,\n captured: false, x: 0, y: 0, lastX: event.clientX, lastY: event.clientY, time: event.timeStamp, velocityX: 0, velocityY: 0,\n };\n };\n function sample(gesture: PointerSwipe, event: PointerEvent, release = false) {\n const elapsed = event.timeStamp - gesture.time;\n for (const axis of ['X', 'Y'] as const) {\n const position = axis === 'X' ? event.clientX : event.clientY;\n const last = gesture[`last${axis}`];\n // A pause before lifting the finger is not a flick.\n if (elapsed > 0 && position !== last) gesture[`velocity${axis}`] = (position - last) / elapsed;\n else if (elapsed > 0 && (!release || elapsed > 80)) gesture[`velocity${axis}`] = 0;\n gesture[`last${axis}`] = position;\n }\n gesture.x = event.clientX - gesture.startX;\n gesture.y = event.clientY - gesture.startY;\n gesture.time = event.timeStamp;\n }\n const move = (event: PointerEvent) => {\n const gesture = current;\n if (!gesture || event.pointerId !== gesture.pointer) return;\n sample(gesture, event);\n if (!gesture.session) {\n const horizontal = Math.abs(gesture.x);\n const vertical = Math.abs(gesture.y);\n if (Math.max(horizontal, vertical) < swipe.intent) return;\n // The first directional intent wins; an axis the target does not own stays native.\n const axis: SwipeAxis = horizontal > vertical ? 'x' : 'y';\n const session = gesture.candidate[axis] ? gesture.candidate.start(axis) : null;\n if (!session || current !== gesture) { cancel(); return; }\n gesture.session = session;\n gesture.axis = axis;\n try {\n root.setPointerCapture(gesture.pointer);\n gesture.captured = true;\n } catch { cancel(); return; }\n root.dataset.dragging = axis;\n // A text selection left in the host would turn the next press into native drag and drop.\n const selection = view.getSelection();\n if (selection?.anchorNode && root.contains(selection.anchorNode)) selection.removeAllRanges();\n }\n suppressUntil = options.now() + swipe.suppressClick;\n if (event.cancelable) event.preventDefault();\n gesture.session.move(gesture.axis === 'x' ? gesture.x : gesture.y);\n };\n const up = (event: PointerEvent) => {\n const gesture = current;\n if (!gesture || event.pointerId !== gesture.pointer) return;\n sample(gesture, event, true);\n finish();\n const x = gesture.axis === 'x';\n gesture.session?.end(x ? gesture.x : gesture.y, x ? gesture.velocityX : gesture.velocityY);\n };\n const cancelled = (event: PointerEvent) => {\n if (current?.pointer === event.pointerId) cancel();\n };\n // Touch input is implicitly captured by the pressed element; moving the capture to\n // the host fires a bubbling lostpointercapture there. Only the host's own loss counts.\n const lost = (event: PointerEvent) => {\n if (event.target === root && current?.captured && current.pointer === event.pointerId) cancel();\n };\n // While the host owns a press, the browser must not start selecting or dragging content.\n const native = (event: Event) => { if (current && (event.type === 'dragstart' || current.session)) event.preventDefault(); };\n const click = (event: MouseEvent) => {\n // Keyboard/AT clicks have detail=0 and remain available during any return.\n if (event.detail === 0 || suppressUntil === 0 || options.now() > suppressUntil) return;\n suppressUntil = 0;\n event.preventDefault();\n event.stopImmediatePropagation();\n };\n const scroll = (event: WheelEvent) => {\n // Pinch zoom (ctrl+wheel) and a running pointer swipe stay untouched.\n if (disposed || current || event.ctrlKey) return;\n const unit = event.deltaMode === 1 ? 16 : event.deltaMode === 2 ? root.clientWidth || 1 : 1;\n const dx = event.deltaX * unit;\n const dy = event.deltaY * unit;\n const time = event.timeStamp;\n if (wheel?.spent) {\n // Momentum only decays. A new swipe accelerates or reverses and starts a fresh stream;\n // vertical scrolling stays native.\n const previous = wheel.lastDx;\n const renewed = time - wheel.spentAt > swipe.wheelLock\n && (Math.abs(dx) > Math.abs(previous) * 1.5 + 2 || (dx !== 0 && previous !== 0 && Math.sign(dx) !== Math.sign(previous)));\n if (renewed) endWheel(false);\n else {\n view.clearTimeout(wheel.timer);\n wheel.timer = view.setTimeout(() => endWheel(true), swipe.wheelIdle);\n wheel.lastDx = dx;\n if (Math.abs(dx) >= Math.abs(dy)) event.preventDefault();\n return;\n }\n }\n if (!wheel) {\n const target = event.target;\n const candidate = Math.abs(dx) > Math.abs(dy) && target instanceof view.Element ? options.begin(target, 'wheel') : null;\n const session = candidate?.x ? candidate.start('x') : null;\n if (candidate && !session) candidate.release();\n // A stream that started vertical stays native until it goes idle.\n wheel = { candidate: session ? candidate : null, session, spent: false, spentAt: 0, lastDx: dx, offset: 0, velocity: 0, time, timer: 0 };\n }\n const stream = wheel;\n view.clearTimeout(stream.timer);\n stream.timer = view.setTimeout(() => endWheel(true), swipe.wheelIdle);\n stream.lastDx = dx;\n if (!stream.session) return;\n event.preventDefault();\n // Fingers moving left scroll right (positive deltaX): the content follows the fingers.\n const elapsed = time - stream.time;\n if (elapsed > 0) stream.velocity = -dx / elapsed;\n stream.offset -= dx;\n stream.time = time;\n root.dataset.dragging = 'x';\n stream.session.move(stream.offset);\n // A trackpad swipe commits as soon as its release would: macOS momentum keeps\n // sending wheel events for a second or more, which otherwise holds the preview in place.\n if (decideRelease(stream.offset, stream.velocity, root.clientWidth || 0, { negative: true, positive: true })) {\n const session = stream.session;\n stream.session = null;\n stream.spent = true;\n stream.spentAt = time;\n delete root.dataset.dragging;\n stream.candidate?.release();\n session.end(stream.offset, stream.velocity);\n }\n };\n const listeners: [EventTarget, string, EventListener, boolean][] = [\n [view, 'pointerdown', secondPointer as EventListener, true],\n [root, 'pointerdown', down as EventListener, false],\n [view, 'pointermove', move as EventListener, true],\n [view, 'pointerup', up as EventListener, true],\n [view, 'pointercancel', cancelled as EventListener, true],\n [root, 'lostpointercapture', lost as EventListener, false],\n [root, 'click', click as EventListener, true],\n [root, 'dragstart', native, false],\n [root, 'selectstart', native, false],\n [root, 'wheel', scroll as EventListener, false],\n [view, 'orientationchange', cancel, false],\n ];\n if (view.screen?.orientation) listeners.push([view.screen.orientation, 'change', cancel, false]);\n for (const [target, type, listener, capture] of listeners) target.addEventListener(type, listener, { capture, passive: false });\n return {\n cancel,\n /** True while a pointer or trackpad swipe (or its intent window) owns the input. */\n get active() { return current !== null || wheel?.session != null; },\n dispose() {\n if (disposed) return;\n disposed = true;\n cancel();\n for (const [target, type, listener, capture] of listeners) target.removeEventListener(type, listener, capture);\n },\n };\n}\n"],"mappings":";;AAEA,IAAM,EAAE,aAAUA;AAMlB,SAAgBC,EAAW,GAAgB,GAAmB,IAAsBC,EAAM,YAAoB;CAG5G,OAFI,CAAC,OAAO,SAASC,CAAM,KAAK,EAAEC,IAAY,KAAW,IAElD,KAAK,KAAKD,CAAM,KAAK,IAAI,KADjB,KAAK,IAAIA,CACa,IAASE,IAAcD,IAAY,MAAMA;AAChF;AAQA,SAAgBE,EAAc,GAAgB,GAAkB,GAC9D,GAAiF;CACjF,IAAMC,IAAOJ,IAAS,IAAI,IAAIA,IAAS,IAAI,KAAK;CAChD,IAAI,CAACI,KAAQ,EAAEA,IAAO,IAAIC,EAAQ,WAAWA,EAAQ,WAAW,OAAO;CACvE,IAAMC,IAAS,OAAO,SAASC,CAAQ,IAAIA,IAAWH,IAAO;CAC7D,IAAIE,IAAS,CAACP,EAAM,UAAU,OAAO;CACrC,IAAMS,IAAW,KAAK,IAAIR,CAAM;CAEhC,OADIC,IAAY,KAAKO,IAAWP,IAAYF,EAAM,YAC3CS,KAAYT,EAAM,eAAeO,IAASP,EAAM,WADYK,IACM;AAC3E;AAyDA,IAAMK,IAAc;AASpB,SAAgBC,EAAY,GAAmB,GAAuB;CACpE,IAAMC,IAAOC,EAAK,cAAc,aAC5BC,IAA+B,MAC/BC,IAA2B,MAC3BC,IAAgB,GAChBC,IAAW;CACf,IAAI,CAACL,GAAM,OAAO;EAAE,SAAS,CAAC;EAAG,UAAU,CAAC;EAAG,IAAI,SAAS;GAAE,OAAO;EAAO;CAAE;CAE9E,SAASM,IAA8B;EACrC,IAAMC,IAAUL;EAQhB,OAPKK,KAGL,IAAU,MACV,OAAON,EAAK,QAAQ,U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dimension","coefficient","decideRelease","sign","allowed","toward","velocity","distance","interactive","createSwipe","view","root","current","wheel","suppressUntil","disposed","finish","gesture","endWheel","stream","commit","cancel","secondPointer","event","down","target","control","candidate","options","sample","elapsed","axis","position","last","release","move","horizontal","vertical","session","selection","up","x","cancelled","lost","native","listeners","unit","dx","dy","time","previous","type","listener","capture"],"sources":["../../src/react/gestures.ts"],"sourcesContent":["import { MOTION } from './motion.js';\n\nconst { swipe } = MOTION;\n\n/**\n * Edge resistance (iOS-style rubber band): the result approaches `dimension`\n * asymptotically and keeps the sign of the raw finger travel.\n */\nexport function rubberBand(offset: number, dimension: number, coefficient: number = swipe.rubberBand): number {\n if (!Number.isFinite(offset) || !(dimension > 0)) return 0;\n const travel = Math.abs(offset);\n return Math.sign(offset) * (1 - 1 / (travel * coefficient / dimension + 1)) * dimension;\n}\n\n/**\n * Release decision along one axis. Returns the sign of the travel when the swipe\n * commits that way (distance past `MOTION.swipe.distance` of `dimension`, or a flick of\n * at least `minDistance` px faster than `velocity` px/ms), 0 when it springs back.\n * A direction without a destination never commits; a flick back always cancels.\n */\nexport function decideRelease(offset: number, velocity: number, dimension: number,\n allowed: { readonly negative: boolean; readonly positive: boolean }): -1 | 0 | 1 {\n const sign = offset > 0 ? 1 : offset < 0 ? -1 : 0;\n if (!sign || !(sign > 0 ? allowed.positive : allowed.negative)) return 0;\n const toward = Number.isFinite(velocity) ? velocity * sign : 0;\n if (toward < -swipe.velocity) return 0;\n const distance = Math.abs(offset);\n if (dimension > 0 && distance > dimension * swipe.distance) return sign;\n return distance >= swipe.minDistance && toward > swipe.velocity ? sign : 0;\n}\n\nexport type SwipeAxis = 'x' | 'y';\n\n/** A started swipe along one axis. Offsets are raw finger travel in CSS px. */\nexport interface SwipeSession {\n readonly move: (offset: number) => void;\n /** Velocity is CSS px/ms along the axis, positive in the direction of positive offsets. */\n readonly end: (offset: number, velocity: number) => void;\n /** Lost capture, a second pointer, orientation change or an external cancel. */\n readonly cancel: () => void;\n}\n\n/** What may start from one pointerdown or wheel stream; `release` ends the intent window. */\nexport interface SwipeCandidate {\n readonly x: boolean;\n readonly y: boolean;\n readonly start: (axis: SwipeAxis) => SwipeSession | null;\n readonly release: () => void;\n}\n\ninterface SwipeOptions {\n /** Null ignores the input; the candidate is released exactly once. */\n readonly begin: (target: Element, input: 'pointer' | 'wheel') => SwipeCandidate | null;\n /**\n * The open Island under a wheel stream: until the stream's axis is decided, and for every\n * mostly horizontal event after that, the browser gets no wheel event from it (no history swipe),\n * even where no swipe can start (an end of the slider, reduced motion, outside the slides).\n */\n readonly claimsWheel?: (target: Element) => boolean;\n readonly now: () => number;\n}\n\ninterface PointerSwipe {\n readonly pointer: number;\n readonly candidate: SwipeCandidate;\n readonly startX: number;\n readonly startY: number;\n session: SwipeSession | null;\n axis: SwipeAxis | null;\n captured: boolean;\n x: number;\n y: number;\n lastX: number;\n lastY: number;\n time: number;\n velocityX: number;\n velocityY: number;\n}\n\ninterface WheelSwipe {\n /** Started over the open Island (`claimsWheel`). */\n readonly claimed: boolean;\n /** Decided after `MOTION.swipe.intent` px of summed travel, like a pointer. */\n axis: SwipeAxis | null;\n travelX: number;\n travelY: number;\n candidate: SwipeCandidate | null;\n session: SwipeSession | null;\n /** Committed early: the rest of the stream (macOS momentum) is swallowed until it goes idle. */\n spent: boolean;\n spentAt: number;\n lastDx: number;\n offset: number;\n velocity: number;\n time: number;\n timer: number;\n}\n\nconst interactive = 'button,a,input,select,textarea,summary,label,[role=\"button\"],[role=\"link\"],[contenteditable]:not([contenteditable=\"false\"])';\n\n/**\n * Pointer and trackpad ownership for one host. The axis is decided by the first\n * `MOTION.swipe.intent` px; an axis the target does not own is given back to the\n * browser (native scroll) for the rest of the gesture. Buttons and links never start\n * a swipe, except the collapsed pill, which is itself the swipe surface. Layout,\n * physics and store commands stay with the caller.\n */\nexport function createSwipe(root: HTMLElement, options: SwipeOptions) {\n const view = root.ownerDocument.defaultView;\n let current: PointerSwipe | null = null;\n let wheel: WheelSwipe | null = null;\n let suppressUntil = 0;\n let disposed = false;\n if (!view) return { cancel() {}, dispose() {}, get active() { return false; } };\n\n function finish(): PointerSwipe | null {\n const gesture = current;\n if (!gesture) return null;\n // Lost capture, store updates and callbacks can be synchronous/reentrant:\n // clear ownership before releasing anything.\n current = null;\n delete root.dataset.dragging;\n if (gesture.captured && root.hasPointerCapture?.(gesture.pointer)) root.releasePointerCapture(gesture.pointer);\n gesture.candidate.release();\n return gesture;\n }\n function endWheel(commit: boolean) {\n const stream = wheel;\n if (!stream) return;\n wheel = null;\n view!.clearTimeout(stream.timer);\n if (stream.session) delete root.dataset.dragging;\n stream.candidate?.release();\n if (commit) stream.session?.end(stream.offset, stream.velocity);\n else stream.session?.cancel();\n }\n const cancel = () => {\n finish()?.session?.cancel();\n endWheel(false);\n };\n const secondPointer = (event: PointerEvent) => {\n if (current && event.pointerId !== current.pointer) cancel();\n };\n const down = (event: PointerEvent) => {\n // A new deliberate activation must work even if a previous browser did not\n // generate the compatibility click suppressed after an accepted drag.\n if (disposed || current || !event.isPrimary || event.button !== 0) return;\n suppressUntil = 0;\n const target = event.target;\n if (!(target instanceof view.Element)) return;\n const control = target.closest(interactive);\n if (control && root.contains(control) && !control.matches('[data-cloudlet-pill]')) return;\n endWheel(false);\n const candidate = options.begin(target, 'pointer');\n if (!candidate) return;\n current = {\n pointer: event.pointerId, candidate, startX: event.clientX, startY: event.clientY, session: null, axis: null,\n captured: false, x: 0, y: 0, lastX: event.clientX, lastY: event.clientY, time: event.timeStamp, velocityX: 0, velocityY: 0,\n };\n };\n function sample(gesture: PointerSwipe, event: PointerEvent, release = false) {\n const elapsed = event.timeStamp - gesture.time;\n for (const axis of ['X', 'Y'] as const) {\n const position = axis === 'X' ? event.clientX : event.clientY;\n const last = gesture[`last${axis}`];\n // A pause before lifting the finger is not a flick.\n if (elapsed > 0 && position !== last) gesture[`velocity${axis}`] = (position - last) / elapsed;\n else if (elapsed > 0 && (!release || elapsed > 80)) gesture[`velocity${axis}`] = 0;\n gesture[`last${axis}`] = position;\n }\n gesture.x = event.clientX - gesture.startX;\n gesture.y = event.clientY - gesture.startY;\n gesture.time = event.timeStamp;\n }\n const move = (event: PointerEvent) => {\n const gesture = current;\n if (!gesture || event.pointerId !== gesture.pointer) return;\n sample(gesture, event);\n if (!gesture.session) {\n const horizontal = Math.abs(gesture.x);\n const vertical = Math.abs(gesture.y);\n if (Math.max(horizontal, vertical) < swipe.intent) return;\n // The first directional intent wins; an axis the target does not own stays native.\n const axis: SwipeAxis = horizontal > vertical ? 'x' : 'y';\n const session = gesture.candidate[axis] ? gesture.candidate.start(axis) : null;\n if (!session || current !== gesture) { cancel(); return; }\n gesture.session = session;\n gesture.axis = axis;\n try {\n root.setPointerCapture(gesture.pointer);\n gesture.captured = true;\n } catch { cancel(); return; }\n root.dataset.dragging = axis;\n // A text selection left in the host would turn the next press into native drag and drop.\n const selection = view.getSelection();\n if (selection?.anchorNode && root.contains(selection.anchorNode)) selection.removeAllRanges();\n }\n suppressUntil = options.now() + swipe.suppressClick;\n if (event.cancelable) event.preventDefault();\n gesture.session.move(gesture.axis === 'x' ? gesture.x : gesture.y);\n };\n const up = (event: PointerEvent) => {\n const gesture = current;\n if (!gesture || event.pointerId !== gesture.pointer) return;\n sample(gesture, event, true);\n finish();\n const x = gesture.axis === 'x';\n gesture.session?.end(x ? gesture.x : gesture.y, x ? gesture.velocityX : gesture.velocityY);\n };\n const cancelled = (event: PointerEvent) => {\n if (current?.pointer === event.pointerId) cancel();\n };\n // Touch input is implicitly captured by the pressed element; moving the capture to\n // the host fires a bubbling lostpointercapture there. Only the host's own loss counts.\n const lost = (event: PointerEvent) => {\n if (event.target === root && current?.captured && current.pointer === event.pointerId) cancel();\n };\n // While the host owns a press, the browser must not start selecting or dragging content.\n const native = (event: Event) => { if (current && (event.type === 'dragstart' || current.session)) event.preventDefault(); };\n const click = (event: MouseEvent) => {\n // Keyboard/AT clicks have detail=0 and remain available during any return.\n if (event.detail === 0 || suppressUntil === 0 || options.now() > suppressUntil) return;\n suppressUntil = 0;\n event.preventDefault();\n event.stopImmediatePropagation();\n };\n const scroll = (event: WheelEvent) => {\n // Pinch zoom (ctrl+wheel) and a running pointer swipe stay untouched.\n if (disposed || current || event.ctrlKey) return;\n const unit = event.deltaMode === 1 ? 16 : event.deltaMode === 2 ? root.clientWidth || 1 : 1;\n const dx = event.deltaX * unit;\n const dy = event.deltaY * unit;\n const time = event.timeStamp;\n if (wheel?.spent) {\n // Momentum only decays. A new swipe accelerates or reverses and starts a fresh stream;\n // vertical scrolling stays native.\n const previous = wheel.lastDx;\n const renewed = time - wheel.spentAt > swipe.wheelLock\n && (Math.abs(dx) > Math.abs(previous) * 1.5 + 2 || (dx !== 0 && previous !== 0 && Math.sign(dx) !== Math.sign(previous)));\n if (renewed) endWheel(false);\n else {\n view.clearTimeout(wheel.timer);\n wheel.timer = view.setTimeout(() => endWheel(true), swipe.wheelIdle);\n wheel.lastDx = dx;\n if (Math.abs(dx) >= Math.abs(dy)) event.preventDefault();\n return;\n }\n }\n if (!wheel) {\n const claimed = event.target instanceof view.Element && (options.claimsWheel?.(event.target) ?? false);\n wheel = {\n claimed, axis: null, travelX: 0, travelY: 0, candidate: null, session: null,\n spent: false, spentAt: 0, lastDx: dx, offset: 0, velocity: 0, time, timer: 0,\n };\n }\n const stream = wheel;\n view.clearTimeout(stream.timer);\n stream.timer = view.setTimeout(() => endWheel(true), swipe.wheelIdle);\n stream.lastDx = dx;\n if (!stream.axis) {\n // The first event alone does not decide: a trackpad swipe often lands diagonally (1, 2 px).\n stream.travelX += dx;\n stream.travelY += dy;\n const horizontal = Math.abs(stream.travelX);\n const vertical = Math.abs(stream.travelY);\n if (Math.max(horizontal, vertical) >= swipe.intent) {\n stream.axis = horizontal > vertical ? 'x' : 'y';\n const target = event.target;\n const candidate = stream.axis === 'x' && target instanceof view.Element ? options.begin(target, 'wheel') : null;\n const session = candidate?.x ? candidate.start('x') : null;\n if (candidate && !session) candidate.release();\n if (session) {\n stream.candidate = candidate;\n stream.session = session;\n // The travel of the intent window counts, as a pointer's does.\n stream.offset = dx - stream.travelX;\n }\n }\n }\n if (!stream.session) {\n // A stream that started vertical stays native until it goes idle; over the Island its\n // sideways events are still held back from the browser's back/forward swipe.\n if (stream.claimed && (!stream.axis || Math.abs(dx) > Math.abs(dy))) event.preventDefault();\n stream.time = time;\n return;\n }\n event.preventDefault();\n // Fingers moving left scroll right (positive deltaX): the content follows the fingers.\n const elapsed = time - stream.time;\n if (elapsed > 0) stream.velocity = -dx / elapsed;\n stream.offset -= dx;\n stream.time = time;\n root.dataset.dragging = 'x';\n stream.session.move(stream.offset);\n // A trackpad swipe commits as soon as its release would: macOS momentum keeps\n // sending wheel events for a second or more, which otherwise holds the preview in place.\n if (decideRelease(stream.offset, stream.velocity, root.clientWidth || 0, { negative: true, positive: true })) {\n const session = stream.session;\n stream.session = null;\n stream.spent = true;\n stream.spentAt = time;\n delete root.dataset.dragging;\n stream.candidate?.release();\n session.end(stream.offset, stream.velocity);\n }\n };\n const listeners: [EventTarget, string, EventListener, boolean][] = [\n [view, 'pointerdown', secondPointer as EventListener, true],\n [root, 'pointerdown', down as EventListener, false],\n [view, 'pointermove', move as EventListener, true],\n [view, 'pointerup', up as EventListener, true],\n [view, 'pointercancel', cancelled as EventListener, true],\n [root, 'lostpointercapture', lost as EventListener, false],\n [root, 'click', click as EventListener, true],\n [root, 'dragstart', native, false],\n [root, 'selectstart', native, false],\n [root, 'wheel', scroll as EventListener, false],\n [view, 'orientationchange', cancel, false],\n ];\n if (view.screen?.orientation) listeners.push([view.screen.orientation, 'change', cancel, false]);\n for (const [target, type, listener, capture] of listeners) target.addEventListener(type, listener, { capture, passive: false });\n return {\n cancel,\n /** True while a pointer or trackpad swipe (or its intent window) owns the input. */\n get active() { return current !== null || wheel?.session != null; },\n dispose() {\n if (disposed) return;\n disposed = true;\n cancel();\n for (const [target, type, listener, capture] of listeners) target.removeEventListener(type, listener, capture);\n },\n };\n}\n"],"mappings":";;AAEA,I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