react-smart-copy 1.24.0 → 1.24.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.
Files changed (148) hide show
  1. package/README.md +130 -1834
  2. package/dist/capture.cjs +3 -3
  3. package/dist/capture.d.cts +1 -1
  4. package/dist/capture.d.ts +1 -1
  5. package/dist/capture.js +3 -3
  6. package/dist/chunks/{clipboard-adapter-CtH4VELE.d.cts → clipboard-adapter-CfaIbZpv.d.cts} +2 -2
  7. package/dist/chunks/{clipboard-adapter-Ds0irroN.d.ts → clipboard-adapter-Chm6zq60.d.ts} +2 -2
  8. package/dist/chunks/{clipboard-adapter-DEXkXxwV.js → clipboard-adapter-CmKDTFdO.js} +3 -3
  9. package/dist/chunks/{clipboard-adapter-DEXkXxwV.js.map → clipboard-adapter-CmKDTFdO.js.map} +1 -1
  10. package/dist/chunks/{clipboard-adapter-Cfz-rzw3.cjs → clipboard-adapter-UIFc_Qso.cjs} +3 -3
  11. package/dist/chunks/{clipboard-adapter-Cfz-rzw3.cjs.map → clipboard-adapter-UIFc_Qso.cjs.map} +1 -1
  12. package/dist/chunks/{contrast-C6CVklEI.cjs → contrast-C9d8QuaF.cjs} +2 -2
  13. package/dist/chunks/{contrast-C6CVklEI.cjs.map → contrast-C9d8QuaF.cjs.map} +1 -1
  14. package/dist/chunks/{contrast-DpK2JIVu.js → contrast-DUaZq5SA.js} +2 -2
  15. package/dist/chunks/{contrast-DpK2JIVu.js.map → contrast-DUaZq5SA.js.map} +1 -1
  16. package/dist/chunks/{copy-interceptor-CZWzGOkL.d.cts → copy-interceptor-BClcHS_P.d.cts} +2 -2
  17. package/dist/chunks/{copy-interceptor-C6NABy1l.d.ts → copy-interceptor-D8c9EDnO.d.ts} +2 -2
  18. package/dist/chunks/{core-Cp2HSpaz.js → core-BH2uIumi.js} +5 -5
  19. package/dist/chunks/{core-Cp2HSpaz.js.map → core-BH2uIumi.js.map} +1 -1
  20. package/dist/chunks/{core-DYf_Lhbe.cjs → core-DmncxMt3.cjs} +5 -5
  21. package/dist/chunks/{core-DYf_Lhbe.cjs.map → core-DmncxMt3.cjs.map} +1 -1
  22. package/dist/chunks/{deadline-C29AlS_Q.js → deadline-CbwnZ3Oq.js} +2 -2
  23. package/dist/chunks/{deadline-C29AlS_Q.js.map → deadline-CbwnZ3Oq.js.map} +1 -1
  24. package/dist/chunks/{deadline-DkiB8ZHE.cjs → deadline-j2hD7JKz.cjs} +2 -2
  25. package/dist/chunks/{deadline-DkiB8ZHE.cjs.map → deadline-j2hD7JKz.cjs.map} +1 -1
  26. package/dist/chunks/{errors-9h8sdFFX.js → errors-CT-FfUtU.js} +2 -2
  27. package/dist/chunks/errors-CT-FfUtU.js.map +1 -0
  28. package/dist/chunks/{errors-BwOF6T_M.cjs → errors-DFmEAC4E.cjs} +2 -2
  29. package/dist/chunks/errors-DFmEAC4E.cjs.map +1 -0
  30. package/dist/chunks/{field-BHo5y-t_.js → field-CK3NxfkM.js} +43 -14
  31. package/dist/chunks/field-CK3NxfkM.js.map +1 -0
  32. package/dist/chunks/{field-Bytz2WfN.cjs → field-CNEcZqa9.cjs} +43 -14
  33. package/dist/chunks/field-CNEcZqa9.cjs.map +1 -0
  34. package/dist/chunks/{index-vz0iW5V2.d.cts → index-CqYzvxSN.d.cts} +4 -4
  35. package/dist/chunks/{index-mr7sSAgP.d.ts → index-Q_QeSwGr.d.ts} +4 -4
  36. package/dist/chunks/{paste-adapter--SPL4PRE.d.cts → paste-adapter-B6eucH3E.d.cts} +2 -2
  37. package/dist/chunks/{paste-adapter-uahXnTYk.d.ts → paste-adapter-CfIDT3mp.d.ts} +2 -2
  38. package/dist/chunks/{paste-reader-Bo01IMC_.cjs → paste-reader-BWQaYNaV.cjs} +2 -2
  39. package/dist/chunks/paste-reader-BWQaYNaV.cjs.map +1 -0
  40. package/dist/chunks/{paste-reader-D9i7yMXF.js → paste-reader-D6uOTDBM.js} +2 -2
  41. package/dist/chunks/paste-reader-D6uOTDBM.js.map +1 -0
  42. package/dist/chunks/{payload-DI5AorDz.js → payload-BWQ6sPtS.js} +3 -3
  43. package/dist/chunks/{payload-DI5AorDz.js.map → payload-BWQ6sPtS.js.map} +1 -1
  44. package/dist/chunks/{payload-DGw-JOo7.js → payload-BrQWGwyx.js} +2 -2
  45. package/dist/chunks/{payload-DGw-JOo7.js.map → payload-BrQWGwyx.js.map} +1 -1
  46. package/dist/chunks/{payload-Cl_8hCI5.d.ts → payload-CcvSx_Hq.d.ts} +4 -2
  47. package/dist/chunks/{payload-CcwKJ_bU.d.cts → payload-qkAWVXWA.d.cts} +4 -2
  48. package/dist/chunks/{payload-CUymxwim.cjs → payload-sBxkG7jH.cjs} +2 -2
  49. package/dist/chunks/{payload-CUymxwim.cjs.map → payload-sBxkG7jH.cjs.map} +1 -1
  50. package/dist/chunks/{payload-J6GjHuh3.cjs → payload-tTK6REua.cjs} +3 -3
  51. package/dist/chunks/{payload-J6GjHuh3.cjs.map → payload-tTK6REua.cjs.map} +1 -1
  52. package/dist/chunks/{share-Bop47Znn.js → share-CU91L4EK.js} +6 -6
  53. package/dist/chunks/{share-Bop47Znn.js.map → share-CU91L4EK.js.map} +1 -1
  54. package/dist/chunks/{share-e7FenIr2.d.ts → share-DVR_DhHc.d.ts} +3 -3
  55. package/dist/chunks/{share-C0esXvRK.d.cts → share-hIwth7Dh.d.cts} +3 -3
  56. package/dist/chunks/{share-ayDz974N.cjs → share-nx7M4Z0t.cjs} +6 -6
  57. package/dist/chunks/{share-ayDz974N.cjs.map → share-nx7M4Z0t.cjs.map} +1 -1
  58. package/dist/chunks/{url-D4PGsRm8.cjs → url-BrhVUwn7.cjs} +2 -2
  59. package/dist/chunks/{url-D4PGsRm8.cjs.map → url-BrhVUwn7.cjs.map} +1 -1
  60. package/dist/chunks/{url-BcMYVCXQ.js → url-COID0BLY.js} +2 -2
  61. package/dist/chunks/{url-BcMYVCXQ.js.map → url-COID0BLY.js.map} +1 -1
  62. package/dist/code.cjs +1 -1
  63. package/dist/code.cjs.map +1 -1
  64. package/dist/code.d.cts +1 -1
  65. package/dist/code.d.ts +1 -1
  66. package/dist/code.js +1 -1
  67. package/dist/code.js.map +1 -1
  68. package/dist/color.cjs +2 -2
  69. package/dist/color.d.cts +1 -1
  70. package/dist/color.d.ts +1 -1
  71. package/dist/color.js +2 -2
  72. package/dist/core.cjs +5 -5
  73. package/dist/core.d.cts +5 -5
  74. package/dist/core.d.ts +5 -5
  75. package/dist/core.js +5 -5
  76. package/dist/email.cjs +1 -1
  77. package/dist/email.cjs.map +1 -1
  78. package/dist/email.d.cts +1 -1
  79. package/dist/email.d.ts +1 -1
  80. package/dist/email.js +1 -1
  81. package/dist/email.js.map +1 -1
  82. package/dist/files.cjs +1 -1
  83. package/dist/files.cjs.map +1 -1
  84. package/dist/files.d.cts +3 -59
  85. package/dist/files.d.ts +3 -59
  86. package/dist/files.js +1 -1
  87. package/dist/files.js.map +1 -1
  88. package/dist/image.cjs +2 -2
  89. package/dist/image.cjs.map +1 -1
  90. package/dist/image.js +2 -2
  91. package/dist/image.js.map +1 -1
  92. package/dist/index.cjs +7 -7
  93. package/dist/index.cjs.map +1 -1
  94. package/dist/index.d.cts +43 -19
  95. package/dist/index.d.ts +43 -19
  96. package/dist/index.js +7 -7
  97. package/dist/index.js.map +1 -1
  98. package/dist/link.cjs +3 -3
  99. package/dist/link.d.cts +1 -1
  100. package/dist/link.d.ts +1 -1
  101. package/dist/link.js +3 -3
  102. package/dist/markdown.cjs +1 -1
  103. package/dist/markdown.cjs.map +1 -1
  104. package/dist/markdown.js +1 -1
  105. package/dist/markdown.js.map +1 -1
  106. package/dist/number.cjs +1 -1
  107. package/dist/number.d.cts +1 -1
  108. package/dist/number.d.ts +1 -1
  109. package/dist/number.js +1 -1
  110. package/dist/otp.cjs +1 -1
  111. package/dist/otp.js +1 -1
  112. package/dist/rich.cjs +3 -3
  113. package/dist/rich.cjs.map +1 -1
  114. package/dist/rich.d.cts +2 -2
  115. package/dist/rich.d.ts +2 -2
  116. package/dist/rich.js +3 -3
  117. package/dist/rich.js.map +1 -1
  118. package/dist/secrets.cjs +1 -1
  119. package/dist/secrets.cjs.map +1 -1
  120. package/dist/secrets.d.cts +1 -1
  121. package/dist/secrets.d.ts +1 -1
  122. package/dist/secrets.js +1 -1
  123. package/dist/secrets.js.map +1 -1
  124. package/dist/share.cjs +1 -1
  125. package/dist/share.d.cts +1 -1
  126. package/dist/share.d.ts +1 -1
  127. package/dist/share.js +1 -1
  128. package/dist/structured.cjs +2 -2
  129. package/dist/structured.cjs.map +1 -1
  130. package/dist/structured.js +2 -2
  131. package/dist/structured.js.map +1 -1
  132. package/dist/table.cjs +1 -1
  133. package/dist/table.cjs.map +1 -1
  134. package/dist/table.d.cts +1 -1
  135. package/dist/table.d.ts +1 -1
  136. package/dist/table.js +1 -1
  137. package/dist/table.js.map +1 -1
  138. package/dist/testing.cjs +2 -2
  139. package/dist/testing.d.cts +3 -3
  140. package/dist/testing.d.ts +3 -3
  141. package/dist/testing.js +2 -2
  142. package/package.json +6 -4
  143. package/dist/chunks/errors-9h8sdFFX.js.map +0 -1
  144. package/dist/chunks/errors-BwOF6T_M.cjs.map +0 -1
  145. package/dist/chunks/field-BHo5y-t_.js.map +0 -1
  146. package/dist/chunks/field-Bytz2WfN.cjs.map +0 -1
  147. package/dist/chunks/paste-reader-Bo01IMC_.cjs.map +0 -1
  148. package/dist/chunks/paste-reader-D9i7yMXF.js.map +0 -1
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["getServerSnapshot","getServerSnapshot","Root","Label","DEFAULT_TRIGGER_TEXT","Trigger"],"sources":["../src/react/CopyGroup.tsx","../src/react/utils.ts","../src/react/useCopy.ts","../src/react/useCopyInterceptor.ts","../src/react/useMediaQuery.ts","../src/react/useRevealOnInteraction.ts","../src/react/useDisplayStatus.ts","../src/react/LiveRegion.tsx","../src/react/TriggerLabel.tsx","../src/react/CopyField.tsx","../src/react/usePaste.ts","../src/react/usePasteDisplayStatus.ts","../src/react/PasteField.tsx","../src/react/useDragCopy.ts","../src/react/useShare.ts","../src/react/useOtpField.ts"],"sourcesContent":["import { createContext, useContext, useState, type ReactNode } from 'react';\nimport { createCopyCoordinator, type CopyCoordinator } from '../core/copy-coordinator';\n\nconst CopyGroupContext = /* @__PURE__ */ createContext<CopyCoordinator | null>(null);\n\nexport interface CopyGroupProps {\n readonly children?: ReactNode;\n /**\n * Share a coordinator with code outside this tree (another root, a vanilla\n * `createCopyMachine`). Defaults to one owned by this group.\n */\n readonly coordinator?: CopyCoordinator;\n}\n\n/**\n * Every `useCopy` / `<CopyField.Root>` inside behaves like one clipboard:\n * a new successful copy returns the previously \"Copied\" one to idle.\n * Opt a single field out with `copyOptions={{ coordinator: null }}`. Groups nest; the nearest wins.\n */\nexport function CopyGroup({ children, coordinator }: CopyGroupProps) {\n const [owned] = useState(createCopyCoordinator);\n return <CopyGroupContext.Provider value={coordinator ?? owned}>{children}</CopyGroupContext.Provider>;\n}\n\n/** The nearest `<CopyGroup>`'s coordinator, or `null` outside any group. */\nexport function useCopyGroup(): CopyCoordinator | null {\n return useContext(CopyGroupContext);\n}\n","import { useEffect, useLayoutEffect, type Ref, type RefCallback } from 'react';\n\n/** `useLayoutEffect` in the browser, `useEffect` on the server (no SSR warning). */\nexport const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\nexport function mergeRefs<T>(...refs: ReadonlyArray<Ref<T> | undefined>): RefCallback<T> {\n return (node) => {\n for (const ref of refs) {\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as { current: T | null }).current = node;\n }\n };\n}\n\n/** Runs the consumer's handler first; ours is skipped if they call `preventDefault()`. */\nexport function composeEventHandlers<E extends { readonly defaultPrevented: boolean }>(\n theirs: ((event: E) => void) | undefined,\n ours: (event: E) => void,\n): (event: E) => void {\n return (event) => {\n theirs?.(event);\n if (!event.defaultPrevented) ours(event);\n };\n}\n","import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';\nimport {\n IDLE_STATE,\n canRetryState,\n createCopyMachine,\n type CopyMachine,\n type CopyMachineOptions,\n type CopyState,\n type CopyStatus,\n} from '../core/copy-machine';\nimport type { CopyCoordinator } from '../core/copy-coordinator';\nimport type { CopyError } from '../core/errors';\nimport { useCopyGroup } from './CopyGroup';\nimport { useIsomorphicLayoutEffect } from './utils';\n\nexport type UseCopyOptions = CopyMachineOptions;\n\nexport interface UseCopyResult {\n /** Full discriminated state; narrow on `state.status`. */\n readonly state: CopyState;\n readonly status: CopyStatus;\n readonly error: CopyError | null;\n /** Whether `retry()` can do anything right now. */\n readonly canRetry: boolean;\n /** Stable identity. Never rejects; resolves to a `CopyOutcome`. */\n readonly copy: CopyMachine['copy'];\n /** Stable identity. Re-attempts the last failed payload, up to `maxRetries`. */\n readonly retry: CopyMachine['retry'];\n /** Stable identity. Back to `idle`, discarding and aborting any in-flight copy. */\n readonly reset: CopyMachine['reset'];\n}\n\nconst getServerSnapshot = (): CopyState => IDLE_STATE;\n\n/** An explicit `coordinator` (including `null`) wins over the surrounding `<CopyGroup>`. */\nfunction withGroup(options: UseCopyOptions, group: CopyCoordinator | null): UseCopyOptions {\n return options.coordinator !== undefined || group === null ? options : { ...options, coordinator: group };\n}\n\n/**\n * Copy state machine bound to a component. Options may change on every render\n * (inline callbacks are fine); the latest ones are always used.\n */\nexport function useCopy(options: UseCopyOptions = {}): UseCopyResult {\n const effective = withGroup(options, useCopyGroup());\n const optionsRef = useRef(effective);\n useIsomorphicLayoutEffect(() => {\n optionsRef.current = effective;\n });\n\n const [machine] = useState(() => createCopyMachine(() => optionsRef.current));\n useEffect(() => machine.connect(), [machine]);\n\n const state = useSyncExternalStore(machine.subscribe, machine.getSnapshot, getServerSnapshot);\n const canRetry = canRetryState(state, effective.maxRetries);\n\n return useMemo(\n () => ({\n state,\n status: state.status,\n error: state.status === 'error' ? state.error : null,\n canRetry,\n copy: machine.copy,\n retry: machine.retry,\n reset: machine.reset,\n }),\n [state, canRetry, machine],\n );\n}\n","import { useEffect, useRef, useState, type RefCallback } from 'react';\nimport { registerCopyInterceptor, type CopyInterceptorOptions } from '../core/copy-interceptor';\nimport { useIsomorphicLayoutEffect } from './utils';\n\nexport interface UseCopyInterceptorOptions extends CopyInterceptorOptions {\n /** Set `false` to stop intercepting without unmounting. Default `true`. */\n readonly enabled?: boolean;\n}\n\nexport interface UseCopyInterceptorResult<T extends Element> {\n /** Attach to the element whose content you want to control. */\n readonly ref: RefCallback<T>;\n}\n\n/**\n * Rewrites, redacts or blocks native copies (Ctrl/Cmd+C, context menu) and\n * cuts whose selection touches the referenced element.\n *\n * ```tsx\n * const { ref } = useCopyInterceptor<HTMLElement>({\n * transform: ({ text }) => `${text}\\n\\nSource: ${location.href}`,\n * });\n * return <article ref={ref}>…</article>;\n * ```\n *\n * The transform runs synchronously inside the event and always sees the\n * latest props; changing it never re-subscribes. SSR-safe.\n */\nexport function useCopyInterceptor<T extends Element = HTMLElement>(\n options: UseCopyInterceptorOptions,\n): UseCopyInterceptorResult<T> {\n const optionsRef = useRef(options);\n useIsomorphicLayoutEffect(() => {\n optionsRef.current = options;\n });\n\n const [node, setNode] = useState<T | null>(null);\n const enabled = options.enabled !== false;\n\n useEffect(() => {\n if (!node || !enabled) return undefined;\n return registerCopyInterceptor(node, () => optionsRef.current);\n }, [node, enabled]);\n\n return { ref: setNode };\n}\n","import { useCallback, useRef, useSyncExternalStore } from 'react';\n\nconst getServerSnapshot = (): boolean => false;\n\n/** SSR-safe media query subscription. Server and hydration render `false`. */\nexport function useMediaQuery(query: string): boolean {\n // Cache the MediaQueryList so `subscribe` always attaches to the same\n // object. We call `matchMedia()` once per query string (per mount / query\n // change) and hold the reference for the duration. The `.matches` accessor\n // on the real MediaQueryList is live, so `getSnapshot` reads the current\n // value without re-calling `matchMedia()` on every render.\n const listRef = useRef<MediaQueryList | null>(null);\n const queryRef = useRef<string>('');\n\n const getList = useCallback((): MediaQueryList | null => {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return null;\n // Invalidate the cache when the query string changes.\n if (listRef.current === null || queryRef.current !== query) {\n listRef.current = window.matchMedia(query);\n queryRef.current = query;\n }\n return listRef.current;\n }, [query]);\n\n const subscribe = useCallback(\n (onChange: () => void) => {\n const list = getList();\n if (!list) return () => undefined;\n list.addEventListener('change', onChange);\n return () => {\n list.removeEventListener('change', onChange);\n };\n },\n [getList],\n );\n\n const getSnapshot = useCallback(() => getList()?.matches ?? false, [getList]);\n\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n","import {\n useEffect,\n useMemo,\n useRef,\n useState,\n type FocusEventHandler,\n type PointerEventHandler,\n type RefCallback,\n} from 'react';\nimport { useMediaQuery } from './useMediaQuery';\n\n/** Why the target is currently revealed, in priority order. */\nexport type RevealReason = 'forced' | 'focus' | 'hover' | 'touch' | 'no-hover-device';\n\nexport interface UseRevealOnInteractionOptions {\n /** Always reveal (e.g. a \"show actions\" user setting). */\n readonly alwaysVisible?: boolean;\n}\n\nexport interface RevealTargetProps<T extends HTMLElement> {\n readonly ref: RefCallback<T>;\n readonly onPointerEnter: PointerEventHandler<T>;\n readonly onPointerLeave: PointerEventHandler<T>;\n readonly onPointerDown: PointerEventHandler<T>;\n readonly onFocus: FocusEventHandler<T>;\n readonly onBlur: FocusEventHandler<T>;\n}\n\nexport interface UseRevealOnInteractionResult<T extends HTMLElement> {\n readonly visible: boolean;\n readonly reason: RevealReason | null;\n /** Spread onto the container that owns the hidden actions. */\n readonly targetProps: RevealTargetProps<T>;\n}\n\nfunction isFocusVisible(element: EventTarget): boolean {\n if (!(element instanceof Element)) return true;\n try {\n return element.matches(':focus-visible');\n } catch {\n return true; // Engines without :focus-visible: reveal on any focus, the accessible default.\n }\n}\n\n/**\n * Reveals secondary actions on hover, keyboard focus and touch, and always on\n * devices that cannot hover. Hover and focus are tracked independently, so a\n * touchscreen laptop never gets stuck in a \"touch only\" mode.\n *\n * Keep the actions in the DOM and in the tab order; hide them visually with\n * CSS keyed off `visible` (or `data-revealed`), never with `display: none`.\n */\nexport function useRevealOnInteraction<T extends HTMLElement = HTMLElement>(\n options: UseRevealOnInteractionOptions = {},\n): UseRevealOnInteractionResult<T> {\n const [hovered, setHovered] = useState(false);\n const [focused, setFocused] = useState(false);\n const [touched, setTouched] = useState(false);\n const cannotHover = useMediaQuery('(hover: none)');\n const nodeRef = useRef<T | null>(null);\n\n // A touch reveal lasts until the user touches somewhere else.\n useEffect(() => {\n if (!touched) return undefined;\n const dismiss = (event: PointerEvent): void => {\n const node = nodeRef.current;\n if (node && event.target instanceof Node && node.contains(event.target)) return;\n setTouched(false);\n };\n document.addEventListener('pointerdown', dismiss, true);\n return () => {\n document.removeEventListener('pointerdown', dismiss, true);\n };\n }, [touched]);\n\n const targetProps = useMemo<RevealTargetProps<T>>(\n () => ({\n ref: (node) => {\n nodeRef.current = node;\n },\n onPointerEnter: (event) => {\n if (event.pointerType !== 'touch') setHovered(true);\n },\n onPointerLeave: (event) => {\n if (event.pointerType !== 'touch') setHovered(false);\n },\n onPointerDown: (event) => {\n if (event.pointerType === 'touch') setTouched(true);\n },\n onFocus: (event) => {\n // Mouse clicks focus buttons too; only keyboard-style focus should pin the reveal.\n setFocused(isFocusVisible(event.target));\n },\n onBlur: (event) => {\n const next = event.relatedTarget;\n if (next instanceof Node && event.currentTarget.contains(next)) return;\n setFocused(false);\n },\n }),\n [],\n );\n\n const reason: RevealReason | null = options.alwaysVisible\n ? 'forced'\n : focused\n ? 'focus'\n : hovered\n ? 'hover'\n : touched\n ? 'touch'\n : cannotHover\n ? 'no-hover-device'\n : null;\n\n return { visible: reason !== null, reason, targetProps };\n}\n","import { useEffect, useState } from 'react';\nimport type { CopyStatus } from '../core/copy-machine';\nimport { useIsomorphicLayoutEffect } from './utils';\n\nexport const DEFAULT_PENDING_DELAY_MS = 150;\nexport const DEFAULT_MIN_PENDING_MS = 400;\n\nexport interface UseDisplayStatusOptions {\n /** Only show `copying` if the copy takes longer than this. Default 150 ms. */\n readonly pendingDelayMs?: number;\n /** Once `copying` is shown, keep it visible at least this long. Default 400 ms. */\n readonly minPendingMs?: number;\n}\n\ntype SettledStatus = Exclude<CopyStatus, 'copying'>;\n\n/**\n * Presentation-only view of a copy status that never flickers.\n *\n * The real `status` is honest and can be `copying` for a single frame (text\n * copies take ~1-5 ms). Rendering that directly flashes a \"Copying…\" label.\n * This hook keeps showing the previous state during fast copies, and when a\n * copy is genuinely slow it shows `copying` for a minimum time instead of a blink.\n *\n * It never changes the state machine: use `status` for logic, this for pixels.\n */\nexport function useDisplayStatus(status: CopyStatus, options: UseDisplayStatusOptions = {}): CopyStatus {\n const pendingDelayMs = Math.max(0, options.pendingDelayMs ?? DEFAULT_PENDING_DELAY_MS);\n const minPendingMs = Math.max(0, options.minPendingMs ?? DEFAULT_MIN_PENDING_MS);\n\n // Last non-copying status, shown while a fast copy is in flight. It is only read\n // while `copying`, so it is synced in a layout effect: never with a render-phase\n // setState, which on React 18 corrupts `useSyncExternalStore`'s snapshot tracking\n // and left CopyField stuck on \"Copied\" after a fast copy.\n const [settled, setSettled] = useState<SettledStatus>(status === 'copying' ? 'idle' : status);\n useIsomorphicLayoutEffect(() => {\n if (status !== 'copying') setSettled(status);\n }, [status]);\n\n // When the pending indicator became visible, or null while it is hidden.\n const [pendingShownAt, setPendingShownAt] = useState<number | null>(null);\n\n useEffect(() => {\n if (status !== 'copying') return undefined;\n const timer = setTimeout(() => {\n setPendingShownAt(Date.now());\n }, pendingDelayMs);\n return () => {\n clearTimeout(timer);\n };\n }, [status, pendingDelayMs]);\n\n useEffect(() => {\n if (status === 'copying' || pendingShownAt === null) return undefined;\n const remaining = Math.max(0, minPendingMs - (Date.now() - pendingShownAt));\n const timer = setTimeout(() => {\n setPendingShownAt(null);\n }, remaining);\n return () => {\n clearTimeout(timer);\n };\n }, [status, pendingShownAt, minPendingMs]);\n\n if (pendingShownAt !== null) return 'copying';\n return status === 'copying' ? settled : status;\n}\n","import { useEffect, useRef, type CSSProperties, type HTMLAttributes } from 'react';\n\n/** Hides content visually while keeping it available to assistive technology. */\nexport const visuallyHiddenStyle: CSSProperties = {\n position: 'absolute',\n width: 1,\n height: 1,\n padding: 0,\n margin: -1,\n overflow: 'hidden',\n clip: 'rect(0, 0, 0, 0)',\n whiteSpace: 'nowrap',\n border: 0,\n};\n\nexport interface LiveRegionProps\n extends Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'role' | 'aria-live' | 'aria-atomic'> {\n /** Changing this text is what triggers the announcement. Empty string = silent. */\n readonly message: string;\n readonly politeness?: 'polite' | 'assertive';\n readonly visuallyHidden?: boolean;\n}\n\n/**\n * Always-mounted announcer. Screen readers ignore regions that are inserted\n * together with their content, so this must render before the first message.\n *\n * **Mount safety**: the live region is intentionally empty on mount. We write\n * the message into the DOM imperatively (via a ref) only after the element has\n * been live for at least one browser paint. This prevents SSR hydration and\n * strict-mode double-mount from producing a spurious announcement on some\n * screen readers (JAWS / NVDA observe the initial DOM during hydration and\n * re-read regions that already have text content).\n *\n * **WCAG 4.1.3 / ARIA spec**: we use `role=\"status\"` with explicit `aria-live`\n * rather than `role=\"alert\"`. `role=\"alert\"` interrupts any sentence being\n * spoken even in polite mode, which is inappropriate for copy feedback.\n * `role=\"status\"` + `aria-live` is correct for both politeness levels.\n */\nexport function LiveRegion({\n message,\n politeness = 'polite',\n visuallyHidden = true,\n style,\n ...rest\n}: LiveRegionProps) {\n const spanRef = useRef<HTMLSpanElement>(null);\n const mountedRef = useRef(false);\n\n useEffect(() => {\n mountedRef.current = true;\n }, []);\n\n useEffect(() => {\n const span = spanRef.current;\n /* c8 ignore next -- spanRef.current is always set by mount; guard for unmounted edge case */\n if (!span) return;\n // Delay the first write by one tick so the live region is registered with\n // the AT before any content lands in it. Subsequent updates are immediate.\n /* c8 ignore next -- jsdom effects run synchronously so mountedRef.current is always true here; this guard only fires in real browsers during the initial paint */\n if (!mountedRef.current) return;\n span.textContent = message;\n }, [message]);\n\n return (\n <span\n {...rest}\n ref={spanRef}\n role=\"status\"\n aria-live={politeness}\n aria-atomic=\"true\"\n style={visuallyHidden ? { ...visuallyHiddenStyle, ...style } : style}\n />\n );\n}\n","import { useMediaQuery } from './useMediaQuery';\n\n/**\n * Default trigger label shared by `CopyField` and `PasteField`: every state's\n * text is stacked in one grid cell, so the button is always as wide as its\n * longest label and never resizes (no layout shift). Only the active label is\n * visible and exposed to assistive tech; the crossfade is skipped when the\n * user prefers reduced motion.\n */\nexport function TriggerLabel<S extends string>({\n status,\n labels,\n}: {\n readonly status: S;\n readonly labels: Readonly<Record<S, string>>;\n}) {\n const reduceMotion = useMediaQuery('(prefers-reduced-motion: reduce)');\n return (\n <span style={{ display: 'inline-grid' }}>\n {(Object.keys(labels) as S[]).map((candidate) => {\n const active = candidate === status;\n return (\n <span\n key={candidate}\n data-trigger-label={candidate}\n data-active={active ? '' : undefined}\n aria-hidden={!active || undefined}\n style={{\n gridArea: '1 / 1',\n opacity: active ? 1 : 0,\n visibility: active ? 'visible' : 'hidden',\n ...(reduceMotion ? {} : { transition: 'opacity 150ms ease, visibility 150ms' }),\n }}\n >\n {labels[candidate]}\n </span>\n );\n })}\n </span>\n );\n}\n","import {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useId,\n useMemo,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport type { CopyOutcome, CopyState, CopyStatus } from '../core/copy-machine';\nimport { describeCopyError, type CopyError } from '../core/errors';\nimport type { CopySource } from '../core/payload';\nimport { LiveRegion } from './LiveRegion';\nimport { TriggerLabel } from './TriggerLabel';\nimport { useDisplayStatus, type UseDisplayStatusOptions } from './useDisplayStatus';\nimport { useCopy, type UseCopyOptions, type UseCopyResult } from './useCopy';\nimport { useRevealOnInteraction, type RevealReason } from './useRevealOnInteraction';\nimport { composeEventHandlers, mergeRefs } from './utils';\n\nexport interface CopyFieldMessages {\n /** Announced to screen readers on success. */\n readonly copied: string;\n /** Announced on failure. Defaults to {@link describeCopyError}. */\n readonly error: (error: CopyError) => string;\n /**\n * Accessible name of the trigger button. Receives the field's `label` prop.\n * The returned string must not be empty.\n */\n readonly triggerLabel: (label: string) => string;\n}\n\nexport const defaultCopyFieldMessages: CopyFieldMessages = {\n copied: 'Copied to clipboard',\n error: describeCopyError,\n triggerLabel: (label) => `Copy ${label}`,\n};\n\nexport interface CopyFieldContextValue extends UseCopyResult {\n readonly label: string;\n readonly labelId: string;\n readonly valueId: string;\n readonly revealed: boolean;\n readonly revealReason: RevealReason | null;\n readonly messages: CopyFieldMessages;\n /** Text shown by `<CopyField.Value>` when the value is plain text; otherwise `null`. */\n readonly displayValue: string | null;\n /** Flicker-free status for rendering. Use `status` for logic, this for pixels. */\n readonly displayStatus: CopyStatus;\n /** Copies the field's current value. */\n readonly copyValue: () => Promise<CopyOutcome>;\n}\n\nconst CopyFieldContext = /* @__PURE__ */ createContext<CopyFieldContextValue | null>(null);\n\n/** Access field state to build custom parts. Must be used inside `<CopyField.Root>`. */\nexport function useCopyField(): CopyFieldContextValue {\n const context = useContext(CopyFieldContext);\n if (!context) throw new Error('useCopyField() must be used inside <CopyField.Root>.');\n return context;\n}\n\n/** Maps non-text payload kinds to a human-readable description for screen readers. */\nconst KIND_LABELS: Readonly<Record<string, string>> = /* @__PURE__ */ Object.freeze(\n Object.assign(Object.create(null) as Record<string, string>, {\n html: 'Rich text',\n image: 'Image',\n json: 'JSON data',\n multi: 'Mixed content',\n }),\n);\n\n/**\n * Returns the value's text representation when it is plain text, or a\n * descriptive fallback for non-text payloads so screen-reader users understand\n * what will be copied (A1: `CopyField.Value` must never be silent).\n */\nfunction getDisplayValue(value: CopySource): string | null {\n if (typeof value === 'string') return value;\n if (typeof value === 'function') return null; // dynamic: no stable preview\n if (value.kind === 'text') return value.value;\n return KIND_LABELS[value.kind] ?? null;\n}\n\n/* ------------------------------------------------------------------ Root */\n\nexport interface CopyFieldRootProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onCopy' | 'onError'>,\n UseDisplayStatusOptions {\n /** What to copy. Pass a function to read the latest value at click time. */\n readonly value: CopySource;\n /** Human label, used for the trigger's accessible name (\"Copy Email\"). */\n readonly label: string;\n readonly copyOptions?: UseCopyOptions;\n readonly messages?: Partial<CopyFieldMessages>;\n /** Skip hover/focus reveal and always show the trigger. */\n readonly alwaysVisible?: boolean;\n /** Render the built-in live region. Disable if your app has a global announcer. Default `true`. */\n readonly announce?: boolean;\n}\n\nconst Root = /* @__PURE__ */ forwardRef<HTMLDivElement, CopyFieldRootProps>(function CopyFieldRoot(\n {\n value,\n label,\n copyOptions,\n messages: messageOverrides,\n alwaysVisible = false,\n announce = true,\n pendingDelayMs,\n minPendingMs,\n children,\n onPointerEnter,\n onPointerLeave,\n onPointerDown,\n onFocus,\n onBlur,\n ...rest\n },\n forwardedRef,\n) {\n const copyState = useCopy(copyOptions);\n const displayStatus = useDisplayStatus(copyState.status, {\n ...(pendingDelayMs === undefined ? {} : { pendingDelayMs }),\n ...(minPendingMs === undefined ? {} : { minPendingMs }),\n });\n const reveal = useRevealOnInteraction<HTMLDivElement>({ alwaysVisible });\n const baseId = useId();\n const labelId = `${baseId}-label`;\n const valueId = `${baseId}-value`;\n\n const messages = useMemo<CopyFieldMessages>(\n () => ({ ...defaultCopyFieldMessages, ...messageOverrides }),\n [messageOverrides],\n );\n\n const { copy } = copyState;\n const copyValue = useCallback(() => copy(value), [copy, value]);\n const { targetProps } = reveal;\n const ref = useMemo(() => mergeRefs(targetProps.ref, forwardedRef), [targetProps.ref, forwardedRef]);\n\n const context = useMemo<CopyFieldContextValue>(\n () => ({\n ...copyState,\n label,\n labelId,\n valueId,\n revealed: reveal.visible,\n revealReason: reveal.reason,\n messages,\n displayValue: getDisplayValue(value),\n displayStatus,\n copyValue,\n }),\n [copyState, label, labelId, valueId, reveal.visible, reveal.reason, messages, value, displayStatus, copyValue],\n );\n\n const { state } = copyState;\n const announcement =\n state.status === 'copied' ? messages.copied : state.status === 'error' ? messages.error(state.error) : '';\n\n return (\n <CopyFieldContext.Provider value={context}>\n <div\n {...rest}\n ref={ref}\n data-state={state.status}\n data-display-state={displayStatus}\n data-revealed={reveal.visible ? '' : undefined}\n onPointerEnter={composeEventHandlers(onPointerEnter, targetProps.onPointerEnter)}\n onPointerLeave={composeEventHandlers(onPointerLeave, targetProps.onPointerLeave)}\n onPointerDown={composeEventHandlers(onPointerDown, targetProps.onPointerDown)}\n onFocus={composeEventHandlers(onFocus, targetProps.onFocus)}\n onBlur={composeEventHandlers(onBlur, targetProps.onBlur)}\n >\n {children}\n {announce ? <LiveRegion message={announcement} /> : null}\n </div>\n </CopyFieldContext.Provider>\n );\n});\n\n/* ----------------------------------------------------------- Label/Value */\n\nexport type CopyFieldLabelProps = HTMLAttributes<HTMLSpanElement>;\n\nconst Label = /* @__PURE__ */ forwardRef<HTMLSpanElement, CopyFieldLabelProps>(function CopyFieldLabel(\n { children, ...rest },\n ref,\n) {\n const field = useCopyField();\n return (\n <span {...rest} ref={ref} id={field.labelId}>\n {children ?? field.label}\n </span>\n );\n});\n\nexport type CopyFieldValueProps = HTMLAttributes<HTMLSpanElement>;\n\nconst Value = /* @__PURE__ */ forwardRef<HTMLSpanElement, CopyFieldValueProps>(function CopyFieldValue(\n { children, ...rest },\n ref,\n) {\n const field = useCopyField();\n return (\n <span {...rest} ref={ref} id={field.valueId}>\n {children ?? field.displayValue}\n </span>\n );\n});\n\n/* --------------------------------------------------------------- Trigger */\n\nexport interface CopyFieldTriggerRenderProps {\n /** The real state. Use for logic. */\n readonly status: CopyStatus;\n /** Flicker-free state. Use for what you render. */\n readonly displayStatus: CopyStatus;\n readonly state: CopyState;\n readonly revealed: boolean;\n readonly canRetry: boolean;\n}\n\nexport interface CopyFieldTriggerProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'type'> {\n /** Static content, or a render function receiving the live state (icons, labels, spinners). */\n readonly children?: ReactNode | ((props: CopyFieldTriggerRenderProps) => ReactNode);\n}\n\nconst DEFAULT_TRIGGER_TEXT: Readonly<Record<CopyStatus, string>> = {\n idle: 'Copy',\n copying: 'Copying…',\n copied: 'Copied',\n error: 'Retry',\n};\n\nconst Trigger = /* @__PURE__ */ forwardRef<HTMLButtonElement, CopyFieldTriggerProps>(function CopyFieldTrigger(\n { children, onClick, 'aria-label': ariaLabel, ...rest },\n ref,\n) {\n const field = useCopyField();\n const renderProps: CopyFieldTriggerRenderProps = {\n status: field.status,\n displayStatus: field.displayStatus,\n state: field.state,\n revealed: field.revealed,\n canRetry: field.canRetry,\n };\n\n // Guard: `triggerLabel` must return a non-empty string; \"Copy undefined\" is\n // not a valid accessible name (happens when the consumer omits `label`).\n const safeAriaLabel =\n (ariaLabel ?? field.messages.triggerLabel(field.label)) || defaultCopyFieldMessages.triggerLabel(field.label);\n\n return (\n <button\n {...rest}\n ref={ref}\n // Never `disabled` while copying: disabling a focused button drops keyboard focus.\n type=\"button\"\n aria-label={safeAriaLabel}\n aria-busy={field.status === 'copying' ? true : undefined}\n data-state={field.status}\n data-display-state={field.displayStatus}\n data-revealed={field.revealed ? '' : undefined}\n onClick={composeEventHandlers(onClick, () => {\n void field.copyValue();\n })}\n >\n {typeof children === 'function'\n ? children(renderProps)\n : (children ?? <TriggerLabel status={field.displayStatus} labels={DEFAULT_TRIGGER_TEXT} />)}\n </button>\n );\n});\n\n/**\n * Headless compound component for a labelled, copyable value.\n *\n * Styling hooks on Root and Trigger:\n * - `data-display-state=\"idle|copying|copied|error\"`: flicker-free, style with this\n * - `data-state`: the real, instantaneous state, for logic and tests\n * - `data-revealed`: present while the trigger should be visible\n */\nexport const CopyField = { Root, Label, Value, Trigger } as const;\n","import {\n useEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n type ClipboardEventHandler,\n type DragEventHandler,\n} from 'react';\nimport type { CopyError } from '../core/errors';\nimport {\n PASTE_IDLE_STATE,\n canRetryPasteState,\n createPasteMachine,\n type PasteMachine,\n type PasteMachineOptions,\n type PasteState,\n type PasteStatus,\n} from '../core/paste-machine';\nimport { canAcceptDrag, resolvePasteReadOptions, type DataTransferLike, type PasteResult } from '../core/paste-reader';\nimport { useIsomorphicLayoutEffect } from './utils';\n\nexport interface UsePasteOptions extends PasteMachineOptions {\n /**\n * Also handle Ctrl/⌘+V anywhere on the page (chat-style \"paste a screenshot\").\n * Events an element already handled (`defaultPrevented`) are skipped. Default `false`.\n */\n readonly listenOnDocument?: boolean;\n}\n\nexport interface PasteTargetProps<T extends Element> {\n readonly onPaste: ClipboardEventHandler<T>;\n}\n\nexport interface PasteDropTargetProps<T extends Element> {\n readonly onDragEnter: DragEventHandler<T>;\n readonly onDragOver: DragEventHandler<T>;\n readonly onDragLeave: DragEventHandler<T>;\n readonly onDrop: DragEventHandler<T>;\n}\n\nexport interface UsePasteResult<T extends Element = HTMLElement> {\n /** Full discriminated state; narrow on `state.status`. */\n readonly state: PasteState;\n readonly status: PasteStatus;\n /** The latest result while `status === 'read'`, otherwise `null`. */\n readonly result: PasteResult | null;\n readonly error: CopyError | null;\n /** Whether `retry()` can do anything right now. */\n readonly canRetry: boolean;\n /** Stable identity. Reads the clipboard from a user gesture. Never rejects. */\n readonly paste: PasteMachine['paste'];\n /** Stable identity. Handles a paste event you received yourself. Never rejects. */\n readonly pasteEvent: PasteMachine['pasteEvent'];\n /** Stable identity. Handles a drop event you received yourself. Never rejects. */\n readonly dropEvent: PasteMachine['dropEvent'];\n /** Stable identity. Re-reads the clipboard after a retryable failure, up to `maxRetries`. */\n readonly retry: PasteMachine['retry'];\n /** Stable identity. Back to `idle`, discarding and aborting any in-flight read. */\n readonly reset: PasteMachine['reset'];\n /** Spread onto an element (drop zone, textarea, editor) to accept Ctrl/⌘+V there. */\n readonly targetProps: PasteTargetProps<T>;\n /**\n * Spread onto one element to accept drag-and-drop there, through the same\n * `accept` and limits as paste. Only drags carrying accepted types show the\n * drop cursor. Separate from `targetProps` so text fields keep native drops.\n */\n readonly dropTargetProps: PasteDropTargetProps<T>;\n /** An accepted drag is over the `dropTargetProps` element. Style the drop zone with it. */\n readonly isDragOver: boolean;\n}\n\nconst getServerSnapshot = (): PasteState => PASTE_IDLE_STATE;\n\nconst DRAG_END_EVENTS = ['drop', 'dragend'] as const;\n\n/** A text field or editable region nested inside the drop target, which should keep its native drop. */\nconst isNestedEditable = (event: { readonly target: EventTarget; readonly currentTarget: EventTarget }): boolean => {\n const { target, currentTarget } = event;\n if (target === currentTarget || !(target instanceof HTMLElement)) return false;\n if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') return true;\n // Inside an editable drop target every child is editable too: those drops are still ours to check.\n return target.isContentEditable && !(currentTarget instanceof HTMLElement && currentTarget.isContentEditable);\n};\n\n/** The drop effect the drag source allows, preferring copy: an effect it disallows cancels the drop. */\nconst dropEffectFor = (allowed: string): DataTransfer['dropEffect'] =>\n /^(all|uninitialized|copy)/.test(allowed) ? 'copy' : /move/i.test(allowed) ? 'move' : allowed === 'link' ? 'link' : 'none';\n\n/**\n * Paste state machine bound to a component. Supports a \"Paste\" button\n * (`paste()`, may prompt for permission), keyboard paste (`targetProps` or\n * `listenOnDocument`, no prompt) and drag-and-drop (`dropTargetProps`).\n * Options may change on every render.\n *\n * Everything in the result is untrusted user input.\n */\nexport function usePaste<T extends Element = HTMLElement>(options: UsePasteOptions = {}): UsePasteResult<T> {\n const optionsRef = useRef(options);\n useIsomorphicLayoutEffect(() => {\n optionsRef.current = options;\n });\n\n const [machine] = useState(() => createPasteMachine(() => optionsRef.current));\n useEffect(() => machine.connect(), [machine]);\n\n const listenOnDocument = options.listenOnDocument === true;\n useEffect(() => {\n if (!listenOnDocument) return undefined;\n const onPaste = (event: ClipboardEvent): void => {\n if (!event.defaultPrevented) void machine.pasteEvent(event);\n };\n document.addEventListener('paste', onPaste);\n return () => {\n document.removeEventListener('paste', onPaste);\n };\n }, [listenOnDocument, machine]);\n\n const state = useSyncExternalStore(machine.subscribe, machine.getSnapshot, getServerSnapshot);\n const canRetry = canRetryPasteState(state, options.maxRetries);\n\n const targetProps = useMemo<PasteTargetProps<T>>(\n () => ({\n onPaste: (event) => {\n void machine.pasteEvent(event);\n },\n }),\n [machine],\n );\n\n const [isDragOver, setIsDragOver] = useState(false);\n // dragenter/dragleave also fire for every child crossed; count them so moving inside doesn't flicker.\n const dragDepth = useRef(0);\n const [endDrag] = useState(() => (): void => {\n dragDepth.current = 0;\n setIsDragOver(false);\n });\n const dropTargetProps = useMemo<PasteDropTargetProps<T>>(() => {\n const accepts = (data: DataTransferLike): boolean => {\n try {\n return canAcceptDrag(data, resolvePasteReadOptions(optionsRef.current));\n } catch {\n return true; // Invalid options: let the drop through so it reports `invalid-payload`.\n }\n };\n return {\n onDragEnter: (event) => {\n dragDepth.current += 1;\n if (accepts(event.dataTransfer)) setIsDragOver(true);\n },\n onDragOver: (event) => {\n if (isNestedEditable(event)) return; // A field inside the target keeps its native drop.\n // Always claimed: otherwise a rejected file would be opened in place of the page.\n // `dropEffect: 'none'` then cancels the drop instead.\n event.preventDefault();\n event.dataTransfer.dropEffect = accepts(event.dataTransfer)\n ? dropEffectFor(event.dataTransfer.effectAllowed)\n : 'none';\n },\n onDragLeave: (event) => {\n const next = event.relatedTarget;\n dragDepth.current -= 1;\n // `relatedTarget` (where supported) catches a count left high by a child removed mid-drag.\n if (dragDepth.current <= 0 || (next instanceof Node && !event.currentTarget.contains(next))) endDrag();\n },\n onDrop: (event) => {\n endDrag();\n if (!isNestedEditable(event)) void machine.dropEvent(event);\n },\n };\n }, [machine, endDrag]);\n\n // A drop handled elsewhere (a consumer `onDrop` that took over, a child that\n // stopped propagation) or a cancelled drag never reaches `onDrop` / `onDragLeave`.\n useEffect(() => {\n if (!isDragOver) return undefined;\n for (const type of DRAG_END_EVENTS) window.addEventListener(type, endDrag, true);\n return () => {\n for (const type of DRAG_END_EVENTS) window.removeEventListener(type, endDrag, true);\n };\n }, [isDragOver, endDrag]);\n\n return useMemo(\n () => ({\n state,\n status: state.status,\n result: state.status === 'read' ? state.result : null,\n error: state.status === 'error' ? state.error : null,\n canRetry,\n paste: machine.paste,\n pasteEvent: machine.pasteEvent,\n dropEvent: machine.dropEvent,\n retry: machine.retry,\n reset: machine.reset,\n targetProps,\n dropTargetProps,\n isDragOver,\n }),\n [state, canRetry, machine, targetProps, dropTargetProps, isDragOver],\n );\n}\n","import { useEffect, useState } from 'react';\nimport type { PasteStatus } from '../core/paste-machine';\nimport { useIsomorphicLayoutEffect } from './utils';\n\nexport const DEFAULT_PASTE_PENDING_DELAY_MS = 150;\nexport const DEFAULT_PASTE_MIN_PENDING_MS = 400;\n\nexport interface UsePasteDisplayStatusOptions {\n /** Only show `reading` if the paste takes longer than this. Default 150 ms. */\n readonly pendingDelayMs?: number;\n /** Once `reading` is shown, keep it visible at least this long. Default 400 ms. */\n readonly minPendingMs?: number;\n}\n\ntype SettledPasteStatus = Exclude<PasteStatus, 'reading'>;\n\n/**\n * Presentation-only view of a paste status that never flickers.\n *\n * The real `status` is honest and can be `reading` for a single render frame\n * (plain-text reads take ~1-5 ms). Rendering that directly flashes a \"Reading…\"\n * label. This hook keeps showing the previous settled status during fast pastes,\n * and when a paste is genuinely slow it shows `reading` for a minimum time\n * instead of a blink.\n *\n * It never changes the state machine: use `status` for logic, this for pixels.\n */\nexport function usePasteDisplayStatus(status: PasteStatus, options: UsePasteDisplayStatusOptions = {}): PasteStatus {\n const pendingDelayMs = Math.max(0, options.pendingDelayMs ?? DEFAULT_PASTE_PENDING_DELAY_MS);\n const minPendingMs = Math.max(0, options.minPendingMs ?? DEFAULT_PASTE_MIN_PENDING_MS);\n\n // Last non-reading status, shown while a fast paste is in flight. Only read\n // while `reading`, so synced in a layout effect to avoid useSyncExternalStore\n // snapshot-tracking corruption on React 18.\n const [settled, setSettled] = useState<SettledPasteStatus>(status === 'reading' ? 'idle' : status);\n useIsomorphicLayoutEffect(() => {\n if (status !== 'reading') setSettled(status);\n }, [status]);\n\n // When the pending indicator became visible, or null while it is hidden.\n const [pendingShownAt, setPendingShownAt] = useState<number | null>(null);\n\n useEffect(() => {\n if (status !== 'reading') return undefined;\n const timer = setTimeout(() => {\n setPendingShownAt(Date.now());\n }, pendingDelayMs);\n return () => {\n clearTimeout(timer);\n };\n }, [status, pendingDelayMs]);\n\n useEffect(() => {\n if (status === 'reading' || pendingShownAt === null) return undefined;\n const remaining = Math.max(0, minPendingMs - (Date.now() - pendingShownAt));\n const timer = setTimeout(() => {\n setPendingShownAt(null);\n }, remaining);\n return () => {\n clearTimeout(timer);\n };\n }, [status, pendingShownAt, minPendingMs]);\n\n if (pendingShownAt !== null) return 'reading';\n return status === 'reading' ? settled : status;\n}\n","import {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useState,\n type ButtonHTMLAttributes,\n type DragEventHandler,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport type { PasteOutcome, PasteState, PasteStatus } from '../core/paste-machine';\nimport { describePasteError, type CopyError } from '../core/errors';\nimport type { PasteResult, PasteSource } from '../core/paste-reader';\nimport { LiveRegion } from './LiveRegion';\nimport { TriggerLabel } from './TriggerLabel';\nimport { usePasteDisplayStatus, type UsePasteDisplayStatusOptions } from './usePasteDisplayStatus';\nimport { usePaste, type PasteDropTargetProps, type UsePasteOptions, type UsePasteResult } from './usePaste';\nimport { useRevealOnInteraction, type RevealReason } from './useRevealOnInteraction';\nimport { composeEventHandlers, mergeRefs } from './utils';\n\n/* ---------------------------------------------------------------- Messages */\n\nexport interface PasteFieldMessages {\n /** Announced to screen readers on successful paste. */\n readonly pasted: string | ((result: PasteResult) => string);\n /**\n * Announced to screen readers when content is dropped onto the zone. When\n * you override `pasted` but not this, your `pasted` message is used for drops too.\n */\n readonly dropped?: string | ((result: PasteResult) => string);\n /** Announced on failure. Defaults to {@link describePasteError}. `source` tells drops from pastes. */\n readonly error: (error: CopyError, source?: PasteSource) => string;\n /**\n * Accessible name of the trigger button. Receives the field's `label` prop.\n * The returned string must not be empty.\n */\n readonly triggerLabel: (label: string) => string;\n /**\n * Accessible name of the drop zone / paste target area.\n * Receives the field's `label` prop.\n */\n readonly zoneLabel: (label: string) => string;\n}\n\nexport const defaultPasteFieldMessages: PasteFieldMessages = {\n pasted: 'Pasted from clipboard',\n dropped: 'Dropped content added',\n error: describePasteError,\n triggerLabel: (label) => `Paste ${label}`,\n zoneLabel: (label) => `Paste area for ${label}`,\n};\n\n/* ----------------------------------------------------------------- Context */\n\nexport interface PasteFieldContextValue extends UsePasteResult {\n readonly label: string;\n readonly labelId: string;\n readonly zoneId: string;\n readonly revealed: boolean;\n readonly revealReason: RevealReason | null;\n readonly messages: PasteFieldMessages;\n /** Flicker-free status for rendering. Use `status` for logic, this for pixels. */\n readonly displayStatus: PasteStatus;\n /** Triggers a programmatic paste (via Clipboard API, may prompt for permission). */\n readonly doPaste: () => Promise<PasteOutcome>;\n}\n\nconst PasteFieldContext = /* @__PURE__ */ createContext<PasteFieldContextValue | null>(null);\n\n/** Access field state to build custom parts. Must be used inside `<PasteField.Root>`. */\nexport function usePasteField(): PasteFieldContextValue {\n const context = useContext(PasteFieldContext);\n if (!context) throw new Error('usePasteField() must be used inside <PasteField.Root>.');\n return context;\n}\n\n/* -------------------------------------------------------------------- Root */\n\nexport interface PasteFieldRootProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onPaste' | 'onError'>,\n UsePasteDisplayStatusOptions {\n /** Human label — used for the trigger's and zone's accessible names. */\n readonly label: string;\n readonly pasteOptions?: UsePasteOptions;\n readonly messages?: Partial<PasteFieldMessages>;\n /** Skip hover/focus reveal and always show the trigger. */\n readonly alwaysVisible?: boolean;\n /** Render the built-in live region. Disable if your app has a global announcer. Default `true`. */\n readonly announce?: boolean;\n}\n\nconst Root = /* @__PURE__ */ forwardRef<HTMLDivElement, PasteFieldRootProps>(function PasteFieldRoot(\n {\n label,\n pasteOptions,\n messages: messageOverrides,\n alwaysVisible = false,\n announce = true,\n pendingDelayMs,\n minPendingMs,\n children,\n onPointerEnter,\n onPointerLeave,\n onPointerDown,\n onFocus,\n onBlur,\n ...rest\n },\n forwardedRef,\n) {\n const pasteState = usePaste(pasteOptions);\n const displayStatus = usePasteDisplayStatus(pasteState.status, {\n ...(pendingDelayMs === undefined ? {} : { pendingDelayMs }),\n ...(minPendingMs === undefined ? {} : { minPendingMs }),\n });\n const reveal = useRevealOnInteraction<HTMLDivElement>({ alwaysVisible });\n const baseId = useId();\n const labelId = `${baseId}-label`;\n const zoneId = `${baseId}-zone`;\n\n const messages = useMemo<PasteFieldMessages>(\n () => ({\n ...defaultPasteFieldMessages,\n // A translated `pasted` beats the English default `dropped`.\n ...(messageOverrides?.pasted === undefined ? {} : { dropped: messageOverrides.pasted }),\n ...messageOverrides,\n }),\n [messageOverrides],\n );\n\n const { paste: machinePaste } = pasteState;\n const doPaste = useCallback(() => machinePaste(), [machinePaste]);\n const { targetProps } = reveal;\n const ref = useMemo(() => mergeRefs(targetProps.ref, forwardedRef), [targetProps.ref, forwardedRef]);\n\n const context = useMemo<PasteFieldContextValue>(\n () => ({\n ...pasteState,\n label,\n labelId,\n zoneId,\n revealed: reveal.visible,\n revealReason: reveal.reason,\n messages,\n displayStatus,\n doPaste,\n }),\n [pasteState, label, labelId, zoneId, reveal.visible, reveal.reason, messages, displayStatus, doPaste],\n );\n\n const { state } = pasteState;\n\n let announcement = '';\n if (state.status === 'read') {\n const message = (state.result.source === 'drop' ? messages.dropped : undefined) ?? messages.pasted;\n announcement = typeof message === 'function' ? message(state.result) : message;\n } else if (state.status === 'error') {\n announcement = messages.error(state.error, state.source);\n }\n\n return (\n <PasteFieldContext.Provider value={context}>\n <div\n {...rest}\n ref={ref}\n data-state={state.status}\n data-display-state={displayStatus}\n data-revealed={reveal.visible ? '' : undefined}\n onPointerEnter={composeEventHandlers(onPointerEnter, targetProps.onPointerEnter)}\n onPointerLeave={composeEventHandlers(onPointerLeave, targetProps.onPointerLeave)}\n onPointerDown={composeEventHandlers(onPointerDown, targetProps.onPointerDown)}\n onFocus={composeEventHandlers(onFocus, targetProps.onFocus)}\n onBlur={composeEventHandlers(onBlur, targetProps.onBlur)}\n >\n {children}\n {announce ? <LiveRegion message={announcement} /> : null}\n </div>\n </PasteFieldContext.Provider>\n );\n});\n\n/* ------------------------------------------------------------ Label/Status */\n\nexport type PasteFieldLabelProps = HTMLAttributes<HTMLSpanElement>;\n\nconst Label = /* @__PURE__ */ forwardRef<HTMLSpanElement, PasteFieldLabelProps>(function PasteFieldLabel(\n { children, ...rest },\n ref,\n) {\n const field = usePasteField();\n return (\n <span {...rest} ref={ref} id={field.labelId}>\n {children ?? field.label}\n </span>\n );\n});\n\nexport interface PasteFieldStatusProps extends HTMLAttributes<HTMLSpanElement> {\n /** Map each paste status to a label. Defaults to English strings. */\n readonly labels?: Partial<Readonly<Record<PasteStatus, string>>>;\n}\n\nconst DEFAULT_STATUS_LABELS: Readonly<Record<PasteStatus, string>> = {\n idle: 'Ready',\n reading: 'Reading…',\n read: 'Pasted',\n error: 'Error',\n};\n\nconst Status = /* @__PURE__ */ forwardRef<HTMLSpanElement, PasteFieldStatusProps>(function PasteFieldStatus(\n { children, labels, ...rest },\n ref,\n) {\n const field = usePasteField();\n const resolved = labels ? { ...DEFAULT_STATUS_LABELS, ...labels } : DEFAULT_STATUS_LABELS;\n return (\n <span {...rest} ref={ref} data-state={field.status} data-display-state={field.displayStatus}>\n {children ?? resolved[field.displayStatus]}\n </span>\n );\n});\n\n/* ------------------------------------------------------------------- Zone */\n\nexport interface PasteFieldZoneProps extends HTMLAttributes<HTMLDivElement> {\n /** When true, the zone is always focusable (tabIndex=0). Default true. */\n readonly focusable?: boolean;\n /**\n * Accept drag-and-drop, through the same `accept` and limits as paste.\n * `data-drag-over` is present while an accepted drag is over the zone. Default true.\n */\n readonly droppable?: boolean;\n}\n\n/**\n * A focusable paste target. Accepts keyboard paste (Ctrl/⌘+V) without a\n * permission prompt and, unless `droppable={false}`, drag-and-drop. Renders\n * `data-zone` and `data-drag-over` for styling.\n *\n * Accessible name: `aria-label` prop, else `messages.zoneLabel(label)`\n * (\"Paste area for Notes\"). Pass `aria-labelledby` explicitly to name it from\n * another element instead.\n */\nconst Zone = /* @__PURE__ */ forwardRef<HTMLDivElement, PasteFieldZoneProps>(function PasteFieldZone(\n {\n children,\n focusable = true,\n droppable = true,\n onPaste,\n onDragEnter,\n onDragOver,\n onDragLeave,\n onDrop,\n 'aria-label': ariaLabel,\n tabIndex,\n ...rest\n },\n ref,\n) {\n const field = usePasteField();\n const { targetProps, dropTargetProps } = field;\n const drop: Record<keyof PasteDropTargetProps<HTMLDivElement>, DragEventHandler<HTMLDivElement> | undefined> = {\n onDragEnter,\n onDragOver,\n onDragLeave,\n onDrop,\n };\n if (droppable) {\n for (const key of Object.keys(dropTargetProps) as (keyof typeof dropTargetProps)[]) {\n drop[key] = composeEventHandlers(drop[key], dropTargetProps[key]);\n }\n }\n\n // Guard: a custom `zoneLabel` returning '' must not leave the region unnamed.\n const safeAriaLabel =\n (ariaLabel ?? field.messages.zoneLabel(field.label)) || defaultPasteFieldMessages.zoneLabel(field.label);\n\n return (\n <div\n // Default shortcut hint; a consumer value in `rest` overrides it.\n aria-keyshortcuts=\"Control+V Meta+V\"\n {...rest}\n ref={ref}\n id={field.zoneId}\n role=\"region\"\n aria-label={safeAriaLabel}\n data-zone=\"\"\n data-state={field.status}\n data-display-state={field.displayStatus}\n data-drag-over={droppable && field.isDragOver ? '' : undefined}\n tabIndex={tabIndex ?? (focusable ? 0 : undefined)}\n onPaste={composeEventHandlers(onPaste, targetProps.onPaste)}\n {...drop}\n >\n {children}\n </div>\n );\n});\n\n/* ----------------------------------------------------------------- Trigger */\n\nexport interface PasteFieldTriggerRenderProps {\n /** The real state. Use for logic. */\n readonly status: PasteStatus;\n /** Flicker-free state. Use for what you render. */\n readonly displayStatus: PasteStatus;\n readonly state: PasteState;\n readonly revealed: boolean;\n /** Whether `retry()` could help after the current error. */\n readonly canRetry: boolean;\n}\n\nexport interface PasteFieldTriggerProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'type'> {\n /** Static content, or a render function receiving the live state. */\n readonly children?: ReactNode | ((props: PasteFieldTriggerRenderProps) => ReactNode);\n}\n\nconst DEFAULT_TRIGGER_TEXT: Readonly<Record<PasteStatus, string>> = {\n idle: 'Paste',\n reading: 'Pasting…',\n read: 'Pasted',\n error: 'Retry',\n};\n\nconst Trigger = /* @__PURE__ */ forwardRef<HTMLButtonElement, PasteFieldTriggerProps>(function PasteFieldTrigger(\n { children, onClick, 'aria-label': ariaLabel, ...rest },\n ref,\n) {\n const field = usePasteField();\n const renderProps: PasteFieldTriggerRenderProps = {\n status: field.status,\n displayStatus: field.displayStatus,\n state: field.state,\n revealed: field.revealed,\n canRetry: field.canRetry,\n };\n\n const safeAriaLabel =\n (ariaLabel ?? field.messages.triggerLabel(field.label)) || defaultPasteFieldMessages.triggerLabel(field.label);\n\n return (\n <button\n {...rest}\n ref={ref}\n type=\"button\"\n aria-label={safeAriaLabel}\n aria-busy={field.status === 'reading' ? true : undefined}\n data-state={field.status}\n data-display-state={field.displayStatus}\n data-revealed={field.revealed ? '' : undefined}\n onClick={composeEventHandlers(onClick, () => {\n void field.doPaste();\n })}\n >\n {typeof children === 'function'\n ? children(renderProps)\n : (children ?? <TriggerLabel status={field.displayStatus} labels={DEFAULT_TRIGGER_TEXT} />)}\n </button>\n );\n});\n\n/* ----------------------------------------------------------------- Preview */\n\nexport interface PasteFieldPreviewRenderProps {\n readonly result: PasteResult;\n /**\n * Object URLs for `result.images`, in order, revoked automatically. Empty on\n * the server and for the first render after a paste, until they are created.\n */\n readonly imageUrls: readonly string[];\n}\n\nexport interface PasteFieldPreviewProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {\n /** Custom rendering of the latest result. Replaces the default text / image / file preview. */\n readonly children?: (props: PasteFieldPreviewRenderProps) => ReactNode;\n /** Shown while there is no pasted result (idle, reading, error). */\n readonly placeholder?: ReactNode;\n /** Pasted text longer than this is cut and ends with \"…\". Default 2000. */\n readonly maxTextLength?: number;\n /** Alt text for each pasted image. Default \"Pasted image 1 of 2\". */\n readonly imageAlt?: (index: number, total: number) => string;\n}\n\nconst NO_URLS: readonly string[] = [];\n\n/**\n * Object URLs for blobs, revoked when the blobs change or the component\n * unmounts. URLs are only returned for the blobs they were made from, so they\n * never pair with the wrong result.\n */\nfunction useObjectUrls(blobs: readonly Blob[] | undefined): readonly string[] {\n const [entry, setEntry] = useState<{ readonly blobs?: readonly Blob[]; readonly urls: readonly string[] }>({\n urls: NO_URLS,\n });\n useEffect(() => {\n if (!blobs?.length || typeof URL.createObjectURL !== 'function') return undefined;\n const urls = blobs.map((blob) => URL.createObjectURL(blob));\n setEntry({ blobs, urls });\n return () => {\n for (const url of urls) URL.revokeObjectURL(url);\n };\n }, [blobs]);\n return entry.blobs === blobs ? entry.urls : NO_URLS;\n}\n\nconst defaultImageAlt = (index: number, total: number): string => `Pasted image ${String(index + 1)} of ${String(total)}`;\n\n/**\n * Shows what was pasted: text (never HTML, which is untrusted), image\n * thumbnails and file names. Renders `placeholder` until there is a result.\n * Pass a function child to render the result yourself.\n */\nconst Preview = /* @__PURE__ */ forwardRef<HTMLDivElement, PasteFieldPreviewProps>(function PasteFieldPreview(\n { children, placeholder = null, maxTextLength = 2000, imageAlt = defaultImageAlt, ...rest },\n ref,\n) {\n const { result, status } = usePasteField();\n const imageUrls = useObjectUrls(result?.images);\n\n let content: ReactNode = placeholder;\n if (result) {\n if (children) {\n content = children({ result, imageUrls });\n } else {\n const { text } = result;\n const files = result.files.filter((file) => !file.type.startsWith('image/'));\n content = (\n <>\n {text ? (\n <pre data-preview-text=\"\">{text.length > maxTextLength ? `${text.slice(0, maxTextLength)}…` : text}</pre>\n ) : null}\n {imageUrls.map((url, index) => (\n <img key={url} data-preview-image=\"\" src={url} alt={imageAlt(index, imageUrls.length)} />\n ))}\n {files.length > 0 ? (\n <ul data-preview-files=\"\">\n {files.map((file, index) => (\n <li key={`${String(index)}-${file.name}`}>{file.name}</li>\n ))}\n </ul>\n ) : null}\n </>\n );\n }\n }\n\n return (\n <div {...rest} ref={ref} data-preview=\"\" data-state={status} data-empty={result ? undefined : ''}>\n {content}\n </div>\n );\n});\n\n/**\n * Headless compound component for a labelled, paste-ready field.\n *\n * Styling hooks on Root, Zone and Trigger:\n * - `data-display-state=\"idle|reading|read|error\"`: flicker-free, style with this\n * - `data-state`: the real, instantaneous state, for logic and tests\n * - `data-revealed`: present while the trigger should be visible\n *\n * @example\n * ```tsx\n * <PasteField.Root label=\"Notes\">\n * <PasteField.Label />\n * <PasteField.Zone />\n * <PasteField.Trigger />\n * <PasteField.Preview placeholder=\"Nothing pasted yet\" />\n * </PasteField.Root>\n * ```\n */\nexport const PasteField = { Root, Label, Status, Zone, Trigger, Preview } as const;\n","import { useCallback, useEffect, useRef, useState, type RefCallback } from 'react';\nimport {\n applyDragCopy,\n type DragCopyOptions,\n type DragCopyOutcome,\n type DragCopyState,\n type DragCopyStatus,\n type DragStartEventLike,\n} from '../core/drag-copy';\nimport { useIsomorphicLayoutEffect } from './utils';\nimport { invoke } from '../core/machine-shared';\n\nexport interface UseDragCopyOptions extends Omit<DragCopyOptions, 'onDrag'> {\n /**\n * Set `false` to disable drag without unmounting. Removes the `draggable`\n * attribute and listener while `false`. Default `true`.\n */\n readonly enabled?: boolean;\n /** Called each time a drag starts or ends. */\n readonly onDrag?: (state: DragCopyState) => void;\n}\n\nexport interface UseDragCopyResult<T extends HTMLElement = HTMLElement> {\n /**\n * Attach to any element you want to make draggable. The hook sets\n * `draggable=\"true\"` automatically while `enabled` is `true`.\n */\n readonly ref: RefCallback<T>;\n /** `'idle' | 'dragging' | 'done'` — the current drag status. */\n readonly status: DragCopyStatus;\n /** The last `dragstart` outcome; `null` before the first drag. */\n readonly outcome: DragCopyOutcome | null;\n /**\n * For use in React's `onDragStart` prop if you need to wire it imperatively\n * (e.g. inside a render-prop component). The `ref` alone is sufficient for\n * native HTML elements: the hook attaches its own listener.\n */\n readonly onDragStart: (event: DragStartEventLike) => void;\n}\n\n/**\n * Makes an element draggable and populates its `DataTransfer` with your data.\n *\n * ```tsx\n * const { ref } = useDragCopy({\n * source: () => ({ kind: 'html', html: '<b>Hello</b>', text: 'Hello' }),\n * });\n * return <div ref={ref}>Drag me</div>;\n * ```\n *\n * - No Clipboard API needed — works in every browser supporting HTML5 drag-and-drop.\n * - The `source` callback always reads the latest props/state, never stale closures.\n * - `enabled={false}` removes `draggable` and the listener without unmounting.\n * - SSR-safe: no DOM access during server rendering.\n */\nexport function useDragCopy<T extends HTMLElement = HTMLElement>(\n options: UseDragCopyOptions,\n): UseDragCopyResult<T> {\n const optionsRef = useRef(options);\n useIsomorphicLayoutEffect(() => {\n optionsRef.current = options;\n });\n\n const [node, setNode] = useState<HTMLElement | null>(null);\n const [state, setState] = useState<DragCopyState>({ status: 'idle', outcome: null });\n\n const enabled = options.enabled !== false;\n\n // Stable handler for the React onDragStart prop path.\n const onDragStart = useCallback((event: DragStartEventLike): void => {\n const { onDrag, onError, source, effectAllowed } = optionsRef.current;\n const coreOpts: DragCopyOptions = effectAllowed !== undefined\n ? { source, effectAllowed }\n : { source };\n const outcome = applyDragCopy(event, coreOpts);\n const next: DragCopyState = { status: 'dragging', outcome };\n setState(next);\n if (outcome.status === 'failed') invoke(onError, outcome.error);\n invoke(onDrag, next);\n }, []);\n\n useEffect(() => {\n if (!node || !enabled) return undefined;\n\n node.setAttribute('draggable', 'true');\n\n function handleDragStart(raw: Event): void {\n const event = raw as DragEvent;\n const { onDrag, onError, source, effectAllowed } = optionsRef.current;\n const coreOpts: DragCopyOptions = effectAllowed !== undefined\n ? { source, effectAllowed }\n : { source };\n const outcome = applyDragCopy(\n {\n type: event.type,\n dataTransfer: event.dataTransfer,\n get defaultPrevented() {\n return event.defaultPrevented;\n },\n preventDefault: () => { event.preventDefault(); },\n },\n coreOpts,\n );\n const next: DragCopyState = { status: 'dragging', outcome };\n setState(next);\n if (outcome.status === 'failed') invoke(onError, outcome.error);\n invoke(onDrag, next);\n }\n\n function handleDragEnd(): void {\n const opts = optionsRef.current;\n setState((prev) => {\n const next: DragCopyState = { status: 'done', outcome: prev.outcome };\n invoke(opts.onDrag, next);\n return next;\n });\n }\n\n node.addEventListener('dragstart', handleDragStart);\n node.addEventListener('dragend', handleDragEnd);\n\n return () => {\n node.removeEventListener('dragstart', handleDragStart);\n node.removeEventListener('dragend', handleDragEnd);\n node.removeAttribute('draggable');\n };\n }, [node, enabled]);\n\n // Reset to idle when disabled so status accurately reflects the element's state.\n useEffect(() => {\n if (!enabled) setState({ status: 'idle', outcome: null });\n }, [enabled]);\n\n return {\n ref: setNode,\n status: state.status,\n outcome: state.outcome,\n onDragStart,\n };\n}\n","import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';\nimport { DEFAULT_RESET_AFTER_MS } from '../core/copy-machine';\nimport type { CopyError } from '../core/errors';\nimport { useIsomorphicLayoutEffect } from './utils';\nimport { shareMethod, shareOrCopy, TOUCH_FIRST, type ShareContent, type ShareMethod, type ShareOptions, type ShareOutcome } from '../share/share';\n\n/** `sharing` lasts while the share sheet is open or the copy is being written. */\nexport type ShareStatus = 'idle' | 'sharing' | 'shared' | 'copied' | 'error';\n\nexport interface UseShareOptions extends ShareOptions {\n /** Time in `shared` or `copied` before returning to `idle`. `false` keeps it. Default 2000. */\n readonly resetAfterMs?: number | false;\n /** Called with every settled outcome, including `cancelled`. */\n readonly onShare?: (outcome: ShareOutcome) => void;\n}\n\n/** What `share()` resolves to: the outcome, or `ignored` while a share is already open. */\nexport type UseShareOutcome = ShareOutcome | { readonly status: 'ignored'; readonly reason: 'in-flight' };\n\nexport interface UseShareResult {\n readonly status: ShareStatus;\n readonly error: CopyError | null;\n /** The last settled outcome; `null` before the first and after `reset()`. */\n readonly outcome: ShareOutcome | null;\n /**\n * How `share()` will share: `\"native\"` (the share sheet) or `\"copy\"`. Label the\n * button with it (\"Share…\" or \"Copy link\"). `\"copy\"` during server rendering\n * and hydration, then updated in the browser, also when the device changes.\n */\n readonly method: ShareMethod;\n /** Stable identity. Call it in a click handler. Never rejects. */\n readonly share: (content: ShareContent) => Promise<UseShareOutcome>;\n /** Stable identity. Back to `idle`; the result of a share still open is ignored. */\n readonly reset: () => void;\n}\n\ninterface State {\n readonly status: ShareStatus;\n readonly outcome: ShareOutcome | null;\n}\n\nconst IDLE: State = { status: 'idle', outcome: null };\nconst IGNORED: UseShareOutcome = /* @__PURE__ */ Object.freeze({ status: 'ignored', reason: 'in-flight' });\n\nfunction resetDelay(value: number | false | undefined): number | null {\n if (value === false || value === Infinity) return null;\n return value === undefined || Number.isNaN(value) ? DEFAULT_RESET_AFTER_MS : Math.max(0, value);\n}\n\nconst statusOf = (outcome: ShareOutcome): ShareStatus => (outcome.status === 'cancelled' ? 'idle' : outcome.status);\n\n/**\n * Share with the device's share sheet on phones and tablets, and copy a titled\n * link everywhere else, with honest state for the button. Options may change on\n * every render; the latest ones are always used.\n *\n * @example\n * const { share, status, method } = useShare();\n * <button onClick={() => share({ url, title })}>\n * {status === 'copied' ? 'Link copied' : method === 'native' ? 'Share…' : 'Copy link'}\n * </button>\n */\nexport function useShare(options: UseShareOptions = {}): UseShareResult {\n const optionsRef = useRef(options);\n useIsomorphicLayoutEffect(() => {\n optionsRef.current = options;\n });\n\n const [state, setState] = useState<State>(IDLE);\n const mounted = useRef(false);\n const inFlight = useRef(false);\n const generation = useRef(0);\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n generation.current += 1;\n clearTimeout(timer.current);\n };\n }, []);\n\n const subscribe = useCallback((onChange: () => void) => {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return () => undefined;\n const list = window.matchMedia(TOUCH_FIRST);\n list.addEventListener('change', onChange);\n return () => {\n list.removeEventListener('change', onChange);\n };\n }, []);\n const method = useSyncExternalStore(\n subscribe,\n () => shareMethod(optionsRef.current),\n (): ShareMethod => 'copy',\n );\n\n const share = useCallback(async (content: ShareContent): Promise<UseShareOutcome> => {\n if (inFlight.current) return IGNORED;\n inFlight.current = true;\n const current = (generation.current += 1);\n clearTimeout(timer.current);\n setState({ status: 'sharing', outcome: null });\n // No await before this call: the share sheet needs the click's user activation.\n const outcome = await shareOrCopy(content, optionsRef.current);\n inFlight.current = false;\n if (!mounted.current || current !== generation.current) return outcome;\n setState({ status: statusOf(outcome), outcome });\n const delay = resetDelay(optionsRef.current.resetAfterMs);\n if ((outcome.status === 'shared' || outcome.status === 'copied') && delay !== null) {\n timer.current = setTimeout(() => {\n setState(IDLE);\n }, delay);\n }\n optionsRef.current.onShare?.(outcome);\n return outcome;\n }, []);\n\n const reset = useCallback(() => {\n generation.current += 1;\n clearTimeout(timer.current);\n setState(IDLE);\n }, []);\n\n return useMemo(\n () => ({\n status: state.status,\n error: state.outcome?.status === 'error' ? state.outcome.error : null,\n outcome: state.outcome,\n method,\n share,\n reset,\n }),\n [state, method, share, reset],\n );\n}\n","import { useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from 'react';\nimport { createOtpField, type OtpField, type OtpFieldOptions, type OtpSnapshot } from '../otp/field';\nimport { useIsomorphicLayoutEffect } from './utils';\n\nexport type UseOtpFieldOptions = OtpFieldOptions;\n\n/** Props for one box: spread them on an `<input>`. The field sets its value; don't pass `value`. */\nexport interface OtpInputProps {\n readonly ref: (element: HTMLInputElement | null) => void;\n readonly type: 'text';\n readonly autoComplete: 'one-time-code' | 'off';\n readonly inputMode: 'numeric' | 'text';\n readonly 'aria-label': string;\n readonly autoCapitalize: 'off' | 'characters';\n readonly spellCheck: false;\n readonly pattern?: string;\n}\n\nexport interface UseOtpFieldResult extends OtpSnapshot {\n /** Props for box `index` (0 to `length - 1`). Render one `<input>` for each. */\n readonly getInputProps: (index: number) => OtpInputProps;\n /** Fills the boxes with `code` from the first. Stable identity. */\n readonly setValue: (code: string) => void;\n /** Empties every box and focuses the first. Stable identity. */\n readonly clear: () => void;\n /** Focuses the first empty box. Stable identity. */\n readonly focus: () => void;\n}\n\nconst defaultLabel = (numeric: boolean) => (index: number, length: number) => `${numeric ? 'Digit' : 'Character'} ${String(index + 1)} of ${String(length)}`;\n\n/**\n * A one-time code field of single-character boxes, headless: typing moves to the next box\n * and Backspace to the one before; pasting a code (or an SMS holding one) into any box\n * fills them all; an SMS autofill (iOS, Android) and, with `webOtp`, the WebOTP API do too.\n * Every box has an accessible name; name the group around them.\n *\n * `length`, `alphabet` and `webOtp` are read when the field is made: a change makes a new,\n * empty field. Callbacks and `label` may change on every render.\n *\n * @example\n * const otp = useOtpField({ length: 6, onComplete: (code) => void verify(code) });\n * <div role=\"group\" aria-label=\"Verification code\">\n * {Array.from({ length: 6 }, (_, index) => <input key={index} {...otp.getInputProps(index)} />)}\n * </div>\n */\nexport function useOtpField(options: UseOtpFieldOptions = {}): UseOtpFieldResult {\n const latest = useRef(options);\n useIsomorphicLayoutEffect(() => {\n latest.current = options;\n });\n const length = options.length ?? 6;\n const alphabet = options.alphabet ?? 'numeric';\n const webOtp = options.webOtp === true;\n\n const field: OtpField = useMemo(\n () =>\n createOtpField({\n length,\n alphabet,\n webOtp,\n label: (index, total) => (latest.current.label ?? defaultLabel(alphabet === 'numeric'))(index, total),\n onChange: (snapshot) => latest.current.onChange?.(snapshot),\n onComplete: (code) => latest.current.onComplete?.(code),\n }),\n [length, alphabet, webOtp],\n );\n const snapshot = useSyncExternalStore(field.subscribe, field.getSnapshot, field.getSnapshot);\n\n // The boxes, by index, as React mounts them; attached to the field once they are all there.\n const elements = useRef<(HTMLInputElement | null)[]>([]);\n const refs = useMemo(\n () =>\n Array.from({ length }, (_, index) => (element: HTMLInputElement | null) => {\n elements.current[index] = element;\n }),\n [length],\n );\n const attached = useRef<{ readonly field: OtpField; readonly inputs: readonly HTMLInputElement[]; readonly detach: () => void } | null>(null);\n useIsomorphicLayoutEffect(() => {\n const inputs = elements.current.slice(0, length).filter((element): element is HTMLInputElement => element !== null);\n const current = attached.current;\n const same = current !== null && current.field === field && current.inputs.length === inputs.length && current.inputs.every((input, index) => input === inputs[index]);\n if (same) return;\n current?.detach();\n attached.current = inputs.length === length ? { field, inputs, detach: field.attach(inputs) } : null;\n });\n useEffect(\n () => () => {\n attached.current?.detach();\n attached.current = null;\n },\n [],\n );\n\n // This render's label: the props are rendered now, before the latest options are stored.\n const labelOf = options.label;\n const getInputProps = useCallback(\n (index: number): OtpInputProps => {\n const numeric = alphabet === 'numeric';\n const label = (labelOf ?? defaultLabel(numeric))(index, length);\n return {\n ref: refs[index] ?? (() => undefined),\n type: 'text',\n autoComplete: index === 0 ? 'one-time-code' : 'off',\n inputMode: numeric ? 'numeric' : 'text',\n 'aria-label': label,\n autoCapitalize: numeric ? 'off' : 'characters',\n spellCheck: false,\n ...(numeric ? { pattern: '[0-9]*' } : {}),\n };\n },\n [alphabet, length, refs, labelOf],\n );\n\n return {\n ...snapshot,\n getInputProps,\n setValue: field.setValue,\n clear: field.clear,\n focus: field.focus,\n };\n}\n"],"mappings":";;;;;;;;;;;;AAGA,MAAM,mBAAmC,8BAAsC,IAAI;;;;;;AAgBnF,SAAgB,UAAU,EAAE,UAAU,eAA+B;CACnE,MAAM,CAAC,SAAS,SAAS,qBAAqB;CAC9C,OAAO,oBAAC,iBAAiB,UAAlB;EAA2B,OAAO,eAAe;EAAQ;CAAoC,CAAA;AACtG;;AAGA,SAAgB,eAAuC;CACrD,OAAO,WAAW,gBAAgB;AACpC;;;;ACxBA,MAAa,4BAA4B,OAAO,WAAW,cAAc,YAAY;AAErF,SAAgB,UAAa,GAAG,MAAyD;CACvF,QAAQ,SAAS;EACf,KAAK,MAAM,OAAO,MAChB,IAAI,OAAO,QAAQ,YAAY,IAAI,IAAI;OAClC,IAAI,KAAK,IAA+B,UAAU;CAE3D;AACF;;AAGA,SAAgB,qBACd,QACA,MACoB;CACpB,QAAQ,UAAU;EAChB,SAAS,KAAK;EACd,IAAI,CAAC,MAAM,kBAAkB,KAAK,KAAK;CACzC;AACF;;;ACSA,MAAMA,4BAAqC;;AAG3C,SAAS,UAAU,SAAyB,OAA+C;CACzF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,MAAM;EAChB,OAAO,MAAM;EACb,OAAO,MAAM;CACf;AACF"}
1
+ {"version":3,"file":"index.js","names":["getServerSnapshot","getServerSnapshot","Root","Label","DEFAULT_TRIGGER_TEXT","Trigger"],"sources":["../src/react/CopyGroup.tsx","../src/react/utils.ts","../src/react/useCopy.ts","../src/react/useCopyInterceptor.ts","../src/react/useMediaQuery.ts","../src/react/useRevealOnInteraction.ts","../src/react/useDisplayStatus.ts","../src/react/LiveRegion.tsx","../src/react/TriggerLabel.tsx","../src/react/CopyField.tsx","../src/react/usePaste.ts","../src/react/usePasteDisplayStatus.ts","../src/react/PasteField.tsx","../src/react/useDragCopy.ts","../src/react/useShare.ts","../src/react/useOtpField.ts"],"sourcesContent":["import { createContext, useContext, useState, type JSX, type ReactNode } from 'react';\nimport { createCopyCoordinator, type CopyCoordinator } from '../core/copy-coordinator';\n\nconst CopyGroupContext = /* @__PURE__ */ createContext<CopyCoordinator | null>(null);\n\nexport interface CopyGroupProps {\n readonly children?: ReactNode;\n /**\n * Share a coordinator with code outside this tree (another root, a vanilla\n * `createCopyMachine`). Defaults to one owned by this group.\n */\n readonly coordinator?: CopyCoordinator;\n}\n\n/**\n * Every `useCopy` / `<CopyField.Root>` inside behaves like one clipboard:\n * a new successful copy returns the previously \"Copied\" one to idle.\n * Opt a single field out with `copyOptions={{ coordinator: null }}`. Groups nest; the nearest wins.\n */\nexport function CopyGroup({ children, coordinator }: CopyGroupProps): JSX.Element {\n const [owned] = useState(createCopyCoordinator);\n return <CopyGroupContext.Provider value={coordinator ?? owned}>{children}</CopyGroupContext.Provider>;\n}\n\n/** The nearest `<CopyGroup>`'s coordinator, or `null` outside any group. */\nexport function useCopyGroup(): CopyCoordinator | null {\n return useContext(CopyGroupContext);\n}\n","import { useEffect, useLayoutEffect, type Ref, type RefCallback } from 'react';\n\n/** `useLayoutEffect` in the browser, `useEffect` on the server (no SSR warning). */\nexport const useIsomorphicLayoutEffect: typeof useLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\nexport function mergeRefs<T>(...refs: ReadonlyArray<Ref<T> | undefined>): RefCallback<T> {\n return (node) => {\n for (const ref of refs) {\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as { current: T | null }).current = node;\n }\n };\n}\n\n/** Runs the consumer's handler first; ours is skipped if they call `preventDefault()`. */\nexport function composeEventHandlers<E extends { readonly defaultPrevented: boolean }>(\n theirs: ((event: E) => void) | undefined,\n ours: (event: E) => void,\n): (event: E) => void {\n return (event) => {\n theirs?.(event);\n if (!event.defaultPrevented) ours(event);\n };\n}\n","import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';\nimport {\n IDLE_STATE,\n canRetryState,\n createCopyMachine,\n type CopyMachine,\n type CopyMachineOptions,\n type CopyState,\n type CopyStatus,\n} from '../core/copy-machine';\nimport type { CopyCoordinator } from '../core/copy-coordinator';\nimport type { CopyError } from '../core/errors';\nimport { useCopyGroup } from './CopyGroup';\nimport { useIsomorphicLayoutEffect } from './utils';\n\nexport type UseCopyOptions = CopyMachineOptions;\n\nexport interface UseCopyResult {\n /** Full discriminated state; narrow on `state.status`. */\n readonly state: CopyState;\n readonly status: CopyStatus;\n readonly error: CopyError | null;\n /** Whether `retry()` can do anything right now. */\n readonly canRetry: boolean;\n /** Stable identity. Never rejects; resolves to a `CopyOutcome`. */\n readonly copy: CopyMachine['copy'];\n /** Stable identity. Re-attempts the last failed payload, up to `maxRetries`. */\n readonly retry: CopyMachine['retry'];\n /** Stable identity. Back to `idle`, discarding and aborting any in-flight copy. */\n readonly reset: CopyMachine['reset'];\n}\n\nconst getServerSnapshot = (): CopyState => IDLE_STATE;\n\n/** An explicit `coordinator` (including `null`) wins over the surrounding `<CopyGroup>`. */\nfunction withGroup(options: UseCopyOptions, group: CopyCoordinator | null): UseCopyOptions {\n return options.coordinator !== undefined || group === null ? options : { ...options, coordinator: group };\n}\n\n/**\n * Copy state machine bound to a component. Options may change on every render\n * (inline callbacks are fine); the latest ones are always used.\n */\nexport function useCopy(options: UseCopyOptions = {}): UseCopyResult {\n const effective = withGroup(options, useCopyGroup());\n const optionsRef = useRef(effective);\n useIsomorphicLayoutEffect(() => {\n optionsRef.current = effective;\n });\n\n const [machine] = useState(() => createCopyMachine(() => optionsRef.current));\n useEffect(() => machine.connect(), [machine]);\n\n const state = useSyncExternalStore(machine.subscribe, machine.getSnapshot, getServerSnapshot);\n const canRetry = canRetryState(state, effective.maxRetries);\n\n return useMemo(\n () => ({\n state,\n status: state.status,\n error: state.status === 'error' ? state.error : null,\n canRetry,\n copy: machine.copy,\n retry: machine.retry,\n reset: machine.reset,\n }),\n [state, canRetry, machine],\n );\n}\n","import { useEffect, useRef, useState, type RefCallback } from 'react';\nimport { registerCopyInterceptor, type CopyInterceptorOptions } from '../core/copy-interceptor';\nimport { useIsomorphicLayoutEffect } from './utils';\n\nexport interface UseCopyInterceptorOptions extends CopyInterceptorOptions {\n /** Set `false` to stop intercepting without unmounting. Default `true`. */\n readonly enabled?: boolean;\n}\n\nexport interface UseCopyInterceptorResult<T extends Element> {\n /** Attach to the element whose content you want to control. */\n readonly ref: RefCallback<T>;\n}\n\n/**\n * Rewrites, redacts or blocks native copies (Ctrl/Cmd+C, context menu) and\n * cuts whose selection touches the referenced element.\n *\n * ```tsx\n * const { ref } = useCopyInterceptor<HTMLElement>({\n * transform: ({ text }) => `${text}\\n\\nSource: ${location.href}`,\n * });\n * return <article ref={ref}>…</article>;\n * ```\n *\n * The transform runs synchronously inside the event and always sees the\n * latest props; changing it never re-subscribes. SSR-safe.\n */\nexport function useCopyInterceptor<T extends Element = HTMLElement>(\n options: UseCopyInterceptorOptions,\n): UseCopyInterceptorResult<T> {\n const optionsRef = useRef(options);\n useIsomorphicLayoutEffect(() => {\n optionsRef.current = options;\n });\n\n const [node, setNode] = useState<T | null>(null);\n const enabled = options.enabled !== false;\n\n useEffect(() => {\n if (!node || !enabled) return undefined;\n return registerCopyInterceptor(node, () => optionsRef.current);\n }, [node, enabled]);\n\n return { ref: setNode };\n}\n","import { useCallback, useRef, useSyncExternalStore } from 'react';\n\nconst getServerSnapshot = (): boolean => false;\n\n/** SSR-safe media query subscription. Server and hydration render `false`. */\nexport function useMediaQuery(query: string): boolean {\n // Cache the MediaQueryList so `subscribe` always attaches to the same\n // object. We call `matchMedia()` once per query string (per mount / query\n // change) and hold the reference for the duration. The `.matches` accessor\n // on the real MediaQueryList is live, so `getSnapshot` reads the current\n // value without re-calling `matchMedia()` on every render.\n const listRef = useRef<MediaQueryList | null>(null);\n const queryRef = useRef<string>('');\n\n const getList = useCallback((): MediaQueryList | null => {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return null;\n // Invalidate the cache when the query string changes.\n if (listRef.current === null || queryRef.current !== query) {\n listRef.current = window.matchMedia(query);\n queryRef.current = query;\n }\n return listRef.current;\n }, [query]);\n\n const subscribe = useCallback(\n (onChange: () => void) => {\n const list = getList();\n if (!list) return () => undefined;\n list.addEventListener('change', onChange);\n return () => {\n list.removeEventListener('change', onChange);\n };\n },\n [getList],\n );\n\n const getSnapshot = useCallback(() => getList()?.matches ?? false, [getList]);\n\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n","import {\n useEffect,\n useMemo,\n useRef,\n useState,\n type FocusEventHandler,\n type PointerEventHandler,\n type RefCallback,\n} from 'react';\nimport { useMediaQuery } from './useMediaQuery';\n\n/** Why the target is currently revealed, in priority order. */\nexport type RevealReason = 'forced' | 'focus' | 'hover' | 'touch' | 'no-hover-device';\n\nexport interface UseRevealOnInteractionOptions {\n /** Always reveal (e.g. a \"show actions\" user setting). */\n readonly alwaysVisible?: boolean;\n}\n\nexport interface RevealTargetProps<T extends HTMLElement> {\n readonly ref: RefCallback<T>;\n readonly onPointerEnter: PointerEventHandler<T>;\n readonly onPointerLeave: PointerEventHandler<T>;\n readonly onPointerDown: PointerEventHandler<T>;\n readonly onFocus: FocusEventHandler<T>;\n readonly onBlur: FocusEventHandler<T>;\n}\n\nexport interface UseRevealOnInteractionResult<T extends HTMLElement> {\n readonly visible: boolean;\n readonly reason: RevealReason | null;\n /** Spread onto the container that owns the hidden actions. */\n readonly targetProps: RevealTargetProps<T>;\n}\n\nfunction isFocusVisible(element: EventTarget): boolean {\n if (!(element instanceof Element)) return true;\n try {\n return element.matches(':focus-visible');\n } catch {\n return true; // Engines without :focus-visible: reveal on any focus, the accessible default.\n }\n}\n\n/**\n * Reveals secondary actions on hover, keyboard focus and touch, and always on\n * devices that cannot hover. Hover and focus are tracked independently, so a\n * touchscreen laptop never gets stuck in a \"touch only\" mode.\n *\n * Keep the actions in the DOM and in the tab order; hide them visually with\n * CSS keyed off `visible` (or `data-revealed`), never with `display: none`.\n */\nexport function useRevealOnInteraction<T extends HTMLElement = HTMLElement>(\n options: UseRevealOnInteractionOptions = {},\n): UseRevealOnInteractionResult<T> {\n const [hovered, setHovered] = useState(false);\n const [focused, setFocused] = useState(false);\n const [touched, setTouched] = useState(false);\n const cannotHover = useMediaQuery('(hover: none)');\n const nodeRef = useRef<T | null>(null);\n\n // A touch reveal lasts until the user touches somewhere else.\n useEffect(() => {\n if (!touched) return undefined;\n const dismiss = (event: PointerEvent): void => {\n const node = nodeRef.current;\n if (node && event.target instanceof Node && node.contains(event.target)) return;\n setTouched(false);\n };\n document.addEventListener('pointerdown', dismiss, true);\n return () => {\n document.removeEventListener('pointerdown', dismiss, true);\n };\n }, [touched]);\n\n const targetProps = useMemo<RevealTargetProps<T>>(\n () => ({\n ref: (node) => {\n nodeRef.current = node;\n },\n onPointerEnter: (event) => {\n if (event.pointerType !== 'touch') setHovered(true);\n },\n onPointerLeave: (event) => {\n if (event.pointerType !== 'touch') setHovered(false);\n },\n onPointerDown: (event) => {\n if (event.pointerType === 'touch') setTouched(true);\n },\n onFocus: (event) => {\n // Mouse clicks focus buttons too; only keyboard-style focus should pin the reveal.\n setFocused(isFocusVisible(event.target));\n },\n onBlur: (event) => {\n const next = event.relatedTarget;\n if (next instanceof Node && event.currentTarget.contains(next)) return;\n setFocused(false);\n },\n }),\n [],\n );\n\n const reason: RevealReason | null = options.alwaysVisible\n ? 'forced'\n : focused\n ? 'focus'\n : hovered\n ? 'hover'\n : touched\n ? 'touch'\n : cannotHover\n ? 'no-hover-device'\n : null;\n\n return { visible: reason !== null, reason, targetProps };\n}\n","import { useEffect, useState } from 'react';\nimport type { CopyStatus } from '../core/copy-machine';\nimport { useIsomorphicLayoutEffect } from './utils';\n\nexport const DEFAULT_PENDING_DELAY_MS = 150;\nexport const DEFAULT_MIN_PENDING_MS = 400;\n\nexport interface UseDisplayStatusOptions {\n /** Only show `copying` if the copy takes longer than this. Default 150 ms. */\n readonly pendingDelayMs?: number;\n /** Once `copying` is shown, keep it visible at least this long. Default 400 ms. */\n readonly minPendingMs?: number;\n}\n\ntype SettledStatus = Exclude<CopyStatus, 'copying'>;\n\n/**\n * Presentation-only view of a copy status that never flickers.\n *\n * The real `status` is honest and can be `copying` for a single frame (text\n * copies take ~1-5 ms). Rendering that directly flashes a \"Copying…\" label.\n * This hook keeps showing the previous state during fast copies, and when a\n * copy is genuinely slow it shows `copying` for a minimum time instead of a blink.\n *\n * It never changes the state machine: use `status` for logic, this for pixels.\n */\nexport function useDisplayStatus(status: CopyStatus, options: UseDisplayStatusOptions = {}): CopyStatus {\n const pendingDelayMs = Math.max(0, options.pendingDelayMs ?? DEFAULT_PENDING_DELAY_MS);\n const minPendingMs = Math.max(0, options.minPendingMs ?? DEFAULT_MIN_PENDING_MS);\n\n // Last non-copying status, shown while a fast copy is in flight. It is only read\n // while `copying`, so it is synced in a layout effect: never with a render-phase\n // setState, which on React 18 corrupts `useSyncExternalStore`'s snapshot tracking\n // and left CopyField stuck on \"Copied\" after a fast copy.\n const [settled, setSettled] = useState<SettledStatus>(status === 'copying' ? 'idle' : status);\n useIsomorphicLayoutEffect(() => {\n if (status !== 'copying') setSettled(status);\n }, [status]);\n\n // When the pending indicator became visible, or null while it is hidden.\n const [pendingShownAt, setPendingShownAt] = useState<number | null>(null);\n\n useEffect(() => {\n if (status !== 'copying') return undefined;\n const timer = setTimeout(() => {\n setPendingShownAt(Date.now());\n }, pendingDelayMs);\n return () => {\n clearTimeout(timer);\n };\n }, [status, pendingDelayMs]);\n\n useEffect(() => {\n if (status === 'copying' || pendingShownAt === null) return undefined;\n const remaining = Math.max(0, minPendingMs - (Date.now() - pendingShownAt));\n const timer = setTimeout(() => {\n setPendingShownAt(null);\n }, remaining);\n return () => {\n clearTimeout(timer);\n };\n }, [status, pendingShownAt, minPendingMs]);\n\n if (pendingShownAt !== null) return 'copying';\n return status === 'copying' ? settled : status;\n}\n","import { useEffect, useRef, type CSSProperties, type HTMLAttributes, type JSX } from 'react';\n\n/** Hides content visually while keeping it available to assistive technology. */\nexport const visuallyHiddenStyle: CSSProperties = {\n position: 'absolute',\n width: 1,\n height: 1,\n padding: 0,\n margin: -1,\n overflow: 'hidden',\n clip: 'rect(0, 0, 0, 0)',\n whiteSpace: 'nowrap',\n border: 0,\n};\n\nexport interface LiveRegionProps\n extends Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'role' | 'aria-live' | 'aria-atomic'> {\n /** Changing this text is what triggers the announcement. Empty string = silent. */\n readonly message: string;\n readonly politeness?: 'polite' | 'assertive';\n readonly visuallyHidden?: boolean;\n}\n\n/**\n * Always-mounted announcer. Screen readers ignore regions that are inserted\n * together with their content, so this must render before the first message.\n *\n * **Mount safety**: the live region is intentionally empty on mount. We write\n * the message into the DOM imperatively (via a ref) only after the element has\n * been live for at least one browser paint. This prevents SSR hydration and\n * strict-mode double-mount from producing a spurious announcement on some\n * screen readers (JAWS / NVDA observe the initial DOM during hydration and\n * re-read regions that already have text content).\n *\n * **WCAG 4.1.3 / ARIA spec**: we use `role=\"status\"` with explicit `aria-live`\n * rather than `role=\"alert\"`. `role=\"alert\"` interrupts any sentence being\n * spoken even in polite mode, which is inappropriate for copy feedback.\n * `role=\"status\"` + `aria-live` is correct for both politeness levels.\n */\nexport function LiveRegion({\n message,\n politeness = 'polite',\n visuallyHidden = true,\n style,\n ...rest\n}: LiveRegionProps): JSX.Element {\n const spanRef = useRef<HTMLSpanElement>(null);\n const mountedRef = useRef(false);\n\n useEffect(() => {\n mountedRef.current = true;\n }, []);\n\n useEffect(() => {\n const span = spanRef.current;\n /* c8 ignore next -- spanRef.current is always set by mount; guard for unmounted edge case */\n if (!span) return;\n // Delay the first write by one tick so the live region is registered with\n // the AT before any content lands in it. Subsequent updates are immediate.\n /* c8 ignore next -- jsdom effects run synchronously so mountedRef.current is always true here; this guard only fires in real browsers during the initial paint */\n if (!mountedRef.current) return;\n span.textContent = message;\n }, [message]);\n\n return (\n <span\n {...rest}\n ref={spanRef}\n role=\"status\"\n aria-live={politeness}\n aria-atomic=\"true\"\n style={visuallyHidden ? { ...visuallyHiddenStyle, ...style } : style}\n />\n );\n}\n","import type { JSX } from 'react';\nimport { useMediaQuery } from './useMediaQuery';\n\n/**\n * Default trigger label shared by `CopyField` and `PasteField`: every state's\n * text is stacked in one grid cell, so the button is always as wide as its\n * longest label and never resizes (no layout shift). Only the active label is\n * visible and exposed to assistive tech; the crossfade is skipped when the\n * user prefers reduced motion.\n */\nexport function TriggerLabel<S extends string>({\n status,\n labels,\n}: {\n readonly status: S;\n readonly labels: Readonly<Record<S, string>>;\n}): JSX.Element {\n const reduceMotion = useMediaQuery('(prefers-reduced-motion: reduce)');\n return (\n <span style={{ display: 'inline-grid' }}>\n {(Object.keys(labels) as S[]).map((candidate) => {\n const active = candidate === status;\n return (\n <span\n key={candidate}\n data-trigger-label={candidate}\n data-active={active ? '' : undefined}\n aria-hidden={!active || undefined}\n style={{\n gridArea: '1 / 1',\n opacity: active ? 1 : 0,\n visibility: active ? 'visible' : 'hidden',\n ...(reduceMotion ? {} : { transition: 'opacity 150ms ease, visibility 150ms' }),\n }}\n >\n {labels[candidate]}\n </span>\n );\n })}\n </span>\n );\n}\n","import {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useId,\n useMemo,\n type ButtonHTMLAttributes,\n type ForwardRefExoticComponent,\n type RefAttributes,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport type { CopyOutcome, CopyState, CopyStatus } from '../core/copy-machine';\nimport { describeCopyError, type CopyError } from '../core/errors';\nimport type { CopySource } from '../core/payload';\nimport { LiveRegion } from './LiveRegion';\nimport { TriggerLabel } from './TriggerLabel';\nimport { useDisplayStatus, type UseDisplayStatusOptions } from './useDisplayStatus';\nimport { useCopy, type UseCopyOptions, type UseCopyResult } from './useCopy';\nimport { useRevealOnInteraction, type RevealReason } from './useRevealOnInteraction';\nimport { composeEventHandlers, mergeRefs } from './utils';\n\nexport interface CopyFieldMessages {\n /** Announced to screen readers on success. */\n readonly copied: string;\n /** Announced on failure. Defaults to {@link describeCopyError}. */\n readonly error: (error: CopyError) => string;\n /**\n * Accessible name of the trigger button. Receives the field's `label` prop.\n * The returned string must not be empty.\n */\n readonly triggerLabel: (label: string) => string;\n}\n\nexport const defaultCopyFieldMessages: CopyFieldMessages = {\n copied: 'Copied to clipboard',\n error: describeCopyError,\n triggerLabel: (label) => `Copy ${label}`,\n};\n\nexport interface CopyFieldContextValue extends UseCopyResult {\n readonly label: string;\n readonly labelId: string;\n readonly valueId: string;\n readonly revealed: boolean;\n readonly revealReason: RevealReason | null;\n readonly messages: CopyFieldMessages;\n /** Text shown by `<CopyField.Value>` when the value is plain text; otherwise `null`. */\n readonly displayValue: string | null;\n /** Flicker-free status for rendering. Use `status` for logic, this for pixels. */\n readonly displayStatus: CopyStatus;\n /** Copies the field's current value. */\n readonly copyValue: () => Promise<CopyOutcome>;\n}\n\nconst CopyFieldContext = /* @__PURE__ */ createContext<CopyFieldContextValue | null>(null);\n\n/** Access field state to build custom parts. Must be used inside `<CopyField.Root>`. */\nexport function useCopyField(): CopyFieldContextValue {\n const context = useContext(CopyFieldContext);\n if (!context) throw new Error('useCopyField() must be used inside <CopyField.Root>.');\n return context;\n}\n\n/** Maps non-text payload kinds to a human-readable description for screen readers. */\nconst KIND_LABELS: Readonly<Record<string, string>> = /* @__PURE__ */ Object.freeze(\n Object.assign(Object.create(null) as Record<string, string>, {\n html: 'Rich text',\n image: 'Image',\n json: 'JSON data',\n multi: 'Mixed content',\n }),\n);\n\n/**\n * Returns the value's text representation when it is plain text, or a\n * descriptive fallback for non-text payloads so screen-reader users understand\n * what will be copied (A1: `CopyField.Value` must never be silent).\n */\nfunction getDisplayValue(value: CopySource): string | null {\n if (typeof value === 'string') return value;\n if (typeof value === 'function') return null; // dynamic: no stable preview\n if (value.kind === 'text') return value.value;\n return KIND_LABELS[value.kind] ?? null;\n}\n\n/* ------------------------------------------------------------------ Root */\n\nexport interface CopyFieldRootProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onCopy' | 'onError'>,\n UseDisplayStatusOptions {\n /** What to copy. Pass a function to read the latest value at click time. */\n readonly value: CopySource;\n /** Human label, used for the trigger's accessible name (\"Copy Email\"). */\n readonly label: string;\n readonly copyOptions?: UseCopyOptions;\n readonly messages?: Partial<CopyFieldMessages>;\n /** Skip hover/focus reveal and always show the trigger. */\n readonly alwaysVisible?: boolean;\n /** Render the built-in live region. Disable if your app has a global announcer. Default `true`. */\n readonly announce?: boolean;\n}\n\nconst Root: ForwardRefExoticComponent<CopyFieldRootProps & RefAttributes<HTMLDivElement>> = /* @__PURE__ */ forwardRef<HTMLDivElement, CopyFieldRootProps>(function CopyFieldRoot(\n {\n value,\n label,\n copyOptions,\n messages: messageOverrides,\n alwaysVisible = false,\n announce = true,\n pendingDelayMs,\n minPendingMs,\n children,\n onPointerEnter,\n onPointerLeave,\n onPointerDown,\n onFocus,\n onBlur,\n ...rest\n },\n forwardedRef,\n) {\n const copyState = useCopy(copyOptions);\n const displayStatus = useDisplayStatus(copyState.status, {\n ...(pendingDelayMs === undefined ? {} : { pendingDelayMs }),\n ...(minPendingMs === undefined ? {} : { minPendingMs }),\n });\n const reveal = useRevealOnInteraction<HTMLDivElement>({ alwaysVisible });\n const baseId = useId();\n const labelId = `${baseId}-label`;\n const valueId = `${baseId}-value`;\n\n const messages = useMemo<CopyFieldMessages>(\n () => ({ ...defaultCopyFieldMessages, ...messageOverrides }),\n [messageOverrides],\n );\n\n const { copy } = copyState;\n const copyValue = useCallback(() => copy(value), [copy, value]);\n const { targetProps } = reveal;\n const ref = useMemo(() => mergeRefs(targetProps.ref, forwardedRef), [targetProps.ref, forwardedRef]);\n\n const context = useMemo<CopyFieldContextValue>(\n () => ({\n ...copyState,\n label,\n labelId,\n valueId,\n revealed: reveal.visible,\n revealReason: reveal.reason,\n messages,\n displayValue: getDisplayValue(value),\n displayStatus,\n copyValue,\n }),\n [copyState, label, labelId, valueId, reveal.visible, reveal.reason, messages, value, displayStatus, copyValue],\n );\n\n const { state } = copyState;\n const announcement =\n state.status === 'copied' ? messages.copied : state.status === 'error' ? messages.error(state.error) : '';\n\n return (\n <CopyFieldContext.Provider value={context}>\n <div\n {...rest}\n ref={ref}\n data-state={state.status}\n data-display-state={displayStatus}\n data-revealed={reveal.visible ? '' : undefined}\n onPointerEnter={composeEventHandlers(onPointerEnter, targetProps.onPointerEnter)}\n onPointerLeave={composeEventHandlers(onPointerLeave, targetProps.onPointerLeave)}\n onPointerDown={composeEventHandlers(onPointerDown, targetProps.onPointerDown)}\n onFocus={composeEventHandlers(onFocus, targetProps.onFocus)}\n onBlur={composeEventHandlers(onBlur, targetProps.onBlur)}\n >\n {children}\n {announce ? <LiveRegion message={announcement} /> : null}\n </div>\n </CopyFieldContext.Provider>\n );\n});\n\n/* ----------------------------------------------------------- Label/Value */\n\nexport type CopyFieldLabelProps = HTMLAttributes<HTMLSpanElement>;\n\nconst Label: ForwardRefExoticComponent<CopyFieldLabelProps & RefAttributes<HTMLSpanElement>> = /* @__PURE__ */ forwardRef<HTMLSpanElement, CopyFieldLabelProps>(function CopyFieldLabel(\n { children, ...rest },\n ref,\n) {\n const field = useCopyField();\n return (\n <span {...rest} ref={ref} id={field.labelId}>\n {children ?? field.label}\n </span>\n );\n});\n\nexport type CopyFieldValueProps = HTMLAttributes<HTMLSpanElement>;\n\nconst Value: ForwardRefExoticComponent<CopyFieldValueProps & RefAttributes<HTMLSpanElement>> = /* @__PURE__ */ forwardRef<HTMLSpanElement, CopyFieldValueProps>(function CopyFieldValue(\n { children, ...rest },\n ref,\n) {\n const field = useCopyField();\n return (\n <span {...rest} ref={ref} id={field.valueId}>\n {children ?? field.displayValue}\n </span>\n );\n});\n\n/* --------------------------------------------------------------- Trigger */\n\nexport interface CopyFieldTriggerRenderProps {\n /** The real state. Use for logic. */\n readonly status: CopyStatus;\n /** Flicker-free state. Use for what you render. */\n readonly displayStatus: CopyStatus;\n readonly state: CopyState;\n readonly revealed: boolean;\n readonly canRetry: boolean;\n}\n\nexport interface CopyFieldTriggerProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'type'> {\n /** Static content, or a render function receiving the live state (icons, labels, spinners). */\n readonly children?: ReactNode | ((props: CopyFieldTriggerRenderProps) => ReactNode);\n}\n\nconst DEFAULT_TRIGGER_TEXT: Readonly<Record<CopyStatus, string>> = {\n idle: 'Copy',\n copying: 'Copying…',\n copied: 'Copied',\n error: 'Retry',\n};\n\nconst Trigger: ForwardRefExoticComponent<CopyFieldTriggerProps & RefAttributes<HTMLButtonElement>> = /* @__PURE__ */ forwardRef<HTMLButtonElement, CopyFieldTriggerProps>(function CopyFieldTrigger(\n { children, onClick, 'aria-label': ariaLabel, ...rest },\n ref,\n) {\n const field = useCopyField();\n const renderProps: CopyFieldTriggerRenderProps = {\n status: field.status,\n displayStatus: field.displayStatus,\n state: field.state,\n revealed: field.revealed,\n canRetry: field.canRetry,\n };\n\n // Guard: `triggerLabel` must return a non-empty string; \"Copy undefined\" is\n // not a valid accessible name (happens when the consumer omits `label`).\n const safeAriaLabel =\n (ariaLabel ?? field.messages.triggerLabel(field.label)) || defaultCopyFieldMessages.triggerLabel(field.label);\n\n return (\n <button\n {...rest}\n ref={ref}\n // Never `disabled` while copying: disabling a focused button drops keyboard focus.\n type=\"button\"\n aria-label={safeAriaLabel}\n aria-busy={field.status === 'copying' ? true : undefined}\n data-state={field.status}\n data-display-state={field.displayStatus}\n data-revealed={field.revealed ? '' : undefined}\n onClick={composeEventHandlers(onClick, () => {\n void field.copyValue();\n })}\n >\n {typeof children === 'function'\n ? children(renderProps)\n : (children ?? <TriggerLabel status={field.displayStatus} labels={DEFAULT_TRIGGER_TEXT} />)}\n </button>\n );\n});\n\n/**\n * Headless compound component for a labelled, copyable value.\n *\n * Styling hooks on Root and Trigger:\n * - `data-display-state=\"idle|copying|copied|error\"`: flicker-free, style with this\n * - `data-state`: the real, instantaneous state, for logic and tests\n * - `data-revealed`: present while the trigger should be visible\n */\nexport const CopyField: {\n readonly Root: typeof Root;\n readonly Label: typeof Label;\n readonly Value: typeof Value;\n readonly Trigger: typeof Trigger;\n} = { Root, Label, Value, Trigger } as const;\n","import {\n useEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n type ClipboardEventHandler,\n type DragEventHandler,\n} from 'react';\nimport type { CopyError } from '../core/errors';\nimport {\n PASTE_IDLE_STATE,\n canRetryPasteState,\n createPasteMachine,\n type PasteMachine,\n type PasteMachineOptions,\n type PasteState,\n type PasteStatus,\n} from '../core/paste-machine';\nimport { canAcceptDrag, resolvePasteReadOptions, type DataTransferLike, type PasteResult } from '../core/paste-reader';\nimport { useIsomorphicLayoutEffect } from './utils';\n\nexport interface UsePasteOptions extends PasteMachineOptions {\n /**\n * Also handle Ctrl/⌘+V anywhere on the page (chat-style \"paste a screenshot\").\n * Events an element already handled (`defaultPrevented`) are skipped. Default `false`.\n */\n readonly listenOnDocument?: boolean;\n}\n\nexport interface PasteTargetProps<T extends Element> {\n readonly onPaste: ClipboardEventHandler<T>;\n}\n\nexport interface PasteDropTargetProps<T extends Element> {\n readonly onDragEnter: DragEventHandler<T>;\n readonly onDragOver: DragEventHandler<T>;\n readonly onDragLeave: DragEventHandler<T>;\n readonly onDrop: DragEventHandler<T>;\n}\n\nexport interface UsePasteResult<T extends Element = HTMLElement> {\n /** Full discriminated state; narrow on `state.status`. */\n readonly state: PasteState;\n readonly status: PasteStatus;\n /** The latest result while `status === 'read'`, otherwise `null`. */\n readonly result: PasteResult | null;\n readonly error: CopyError | null;\n /** Whether `retry()` can do anything right now. */\n readonly canRetry: boolean;\n /** Stable identity. Reads the clipboard from a user gesture. Never rejects. */\n readonly paste: PasteMachine['paste'];\n /** Stable identity. Handles a paste event you received yourself. Never rejects. */\n readonly pasteEvent: PasteMachine['pasteEvent'];\n /** Stable identity. Handles a drop event you received yourself. Never rejects. */\n readonly dropEvent: PasteMachine['dropEvent'];\n /** Stable identity. Re-reads the clipboard after a retryable failure, up to `maxRetries`. */\n readonly retry: PasteMachine['retry'];\n /** Stable identity. Back to `idle`, discarding and aborting any in-flight read. */\n readonly reset: PasteMachine['reset'];\n /** Spread onto an element (drop zone, textarea, editor) to accept Ctrl/⌘+V there. */\n readonly targetProps: PasteTargetProps<T>;\n /**\n * Spread onto one element to accept drag-and-drop there, through the same\n * `accept` and limits as paste. Only drags carrying accepted types show the\n * drop cursor. Separate from `targetProps` so text fields keep native drops.\n */\n readonly dropTargetProps: PasteDropTargetProps<T>;\n /** An accepted drag is over the `dropTargetProps` element. Style the drop zone with it. */\n readonly isDragOver: boolean;\n}\n\nconst getServerSnapshot = (): PasteState => PASTE_IDLE_STATE;\n\nconst DRAG_END_EVENTS = ['drop', 'dragend'] as const;\n\n/** A text field or editable region nested inside the drop target, which should keep its native drop. */\nconst isNestedEditable = (event: { readonly target: EventTarget; readonly currentTarget: EventTarget }): boolean => {\n const { target, currentTarget } = event;\n if (target === currentTarget || !(target instanceof HTMLElement)) return false;\n if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') return true;\n // Inside an editable drop target every child is editable too: those drops are still ours to check.\n return target.isContentEditable && !(currentTarget instanceof HTMLElement && currentTarget.isContentEditable);\n};\n\n/** The drop effect the drag source allows, preferring copy: an effect it disallows cancels the drop. */\nconst dropEffectFor = (allowed: string): DataTransfer['dropEffect'] =>\n /^(all|uninitialized|copy)/.test(allowed) ? 'copy' : /move/i.test(allowed) ? 'move' : allowed === 'link' ? 'link' : 'none';\n\n/**\n * Paste state machine bound to a component. Supports a \"Paste\" button\n * (`paste()`, may prompt for permission), keyboard paste (`targetProps` or\n * `listenOnDocument`, no prompt) and drag-and-drop (`dropTargetProps`).\n * Options may change on every render.\n *\n * Everything in the result is untrusted user input.\n */\nexport function usePaste<T extends Element = HTMLElement>(options: UsePasteOptions = {}): UsePasteResult<T> {\n const optionsRef = useRef(options);\n useIsomorphicLayoutEffect(() => {\n optionsRef.current = options;\n });\n\n const [machine] = useState(() => createPasteMachine(() => optionsRef.current));\n useEffect(() => machine.connect(), [machine]);\n\n const listenOnDocument = options.listenOnDocument === true;\n useEffect(() => {\n if (!listenOnDocument) return undefined;\n const onPaste = (event: ClipboardEvent): void => {\n if (!event.defaultPrevented) void machine.pasteEvent(event);\n };\n document.addEventListener('paste', onPaste);\n return () => {\n document.removeEventListener('paste', onPaste);\n };\n }, [listenOnDocument, machine]);\n\n const state = useSyncExternalStore(machine.subscribe, machine.getSnapshot, getServerSnapshot);\n const canRetry = canRetryPasteState(state, options.maxRetries);\n\n const targetProps = useMemo<PasteTargetProps<T>>(\n () => ({\n onPaste: (event) => {\n void machine.pasteEvent(event);\n },\n }),\n [machine],\n );\n\n const [isDragOver, setIsDragOver] = useState(false);\n // dragenter/dragleave also fire for every child crossed; count them so moving inside doesn't flicker.\n const dragDepth = useRef(0);\n const [endDrag] = useState(() => (): void => {\n dragDepth.current = 0;\n setIsDragOver(false);\n });\n const dropTargetProps = useMemo<PasteDropTargetProps<T>>(() => {\n const accepts = (data: DataTransferLike): boolean => {\n try {\n return canAcceptDrag(data, resolvePasteReadOptions(optionsRef.current));\n } catch {\n return true; // Invalid options: let the drop through so it reports `invalid-payload`.\n }\n };\n return {\n onDragEnter: (event) => {\n dragDepth.current += 1;\n if (accepts(event.dataTransfer)) setIsDragOver(true);\n },\n onDragOver: (event) => {\n if (isNestedEditable(event)) return; // A field inside the target keeps its native drop.\n // Always claimed: otherwise a rejected file would be opened in place of the page.\n // `dropEffect: 'none'` then cancels the drop instead.\n event.preventDefault();\n event.dataTransfer.dropEffect = accepts(event.dataTransfer)\n ? dropEffectFor(event.dataTransfer.effectAllowed)\n : 'none';\n },\n onDragLeave: (event) => {\n const next = event.relatedTarget;\n dragDepth.current -= 1;\n // `relatedTarget` (where supported) catches a count left high by a child removed mid-drag.\n if (dragDepth.current <= 0 || (next instanceof Node && !event.currentTarget.contains(next))) endDrag();\n },\n onDrop: (event) => {\n endDrag();\n if (!isNestedEditable(event)) void machine.dropEvent(event);\n },\n };\n }, [machine, endDrag]);\n\n // A drop handled elsewhere (a consumer `onDrop` that took over, a child that\n // stopped propagation) or a cancelled drag never reaches `onDrop` / `onDragLeave`.\n useEffect(() => {\n if (!isDragOver) return undefined;\n for (const type of DRAG_END_EVENTS) window.addEventListener(type, endDrag, true);\n return () => {\n for (const type of DRAG_END_EVENTS) window.removeEventListener(type, endDrag, true);\n };\n }, [isDragOver, endDrag]);\n\n return useMemo(\n () => ({\n state,\n status: state.status,\n result: state.status === 'read' ? state.result : null,\n error: state.status === 'error' ? state.error : null,\n canRetry,\n paste: machine.paste,\n pasteEvent: machine.pasteEvent,\n dropEvent: machine.dropEvent,\n retry: machine.retry,\n reset: machine.reset,\n targetProps,\n dropTargetProps,\n isDragOver,\n }),\n [state, canRetry, machine, targetProps, dropTargetProps, isDragOver],\n );\n}\n","import { useEffect, useState } from 'react';\nimport type { PasteStatus } from '../core/paste-machine';\nimport { useIsomorphicLayoutEffect } from './utils';\n\nexport const DEFAULT_PASTE_PENDING_DELAY_MS = 150;\nexport const DEFAULT_PASTE_MIN_PENDING_MS = 400;\n\nexport interface UsePasteDisplayStatusOptions {\n /** Only show `reading` if the paste takes longer than this. Default 150 ms. */\n readonly pendingDelayMs?: number;\n /** Once `reading` is shown, keep it visible at least this long. Default 400 ms. */\n readonly minPendingMs?: number;\n}\n\ntype SettledPasteStatus = Exclude<PasteStatus, 'reading'>;\n\n/**\n * Presentation-only view of a paste status that never flickers.\n *\n * The real `status` is honest and can be `reading` for a single render frame\n * (plain-text reads take ~1-5 ms). Rendering that directly flashes a \"Reading…\"\n * label. This hook keeps showing the previous settled status during fast pastes,\n * and when a paste is genuinely slow it shows `reading` for a minimum time\n * instead of a blink.\n *\n * It never changes the state machine: use `status` for logic, this for pixels.\n */\nexport function usePasteDisplayStatus(status: PasteStatus, options: UsePasteDisplayStatusOptions = {}): PasteStatus {\n const pendingDelayMs = Math.max(0, options.pendingDelayMs ?? DEFAULT_PASTE_PENDING_DELAY_MS);\n const minPendingMs = Math.max(0, options.minPendingMs ?? DEFAULT_PASTE_MIN_PENDING_MS);\n\n // Last non-reading status, shown while a fast paste is in flight. Only read\n // while `reading`, so synced in a layout effect to avoid useSyncExternalStore\n // snapshot-tracking corruption on React 18.\n const [settled, setSettled] = useState<SettledPasteStatus>(status === 'reading' ? 'idle' : status);\n useIsomorphicLayoutEffect(() => {\n if (status !== 'reading') setSettled(status);\n }, [status]);\n\n // When the pending indicator became visible, or null while it is hidden.\n const [pendingShownAt, setPendingShownAt] = useState<number | null>(null);\n\n useEffect(() => {\n if (status !== 'reading') return undefined;\n const timer = setTimeout(() => {\n setPendingShownAt(Date.now());\n }, pendingDelayMs);\n return () => {\n clearTimeout(timer);\n };\n }, [status, pendingDelayMs]);\n\n useEffect(() => {\n if (status === 'reading' || pendingShownAt === null) return undefined;\n const remaining = Math.max(0, minPendingMs - (Date.now() - pendingShownAt));\n const timer = setTimeout(() => {\n setPendingShownAt(null);\n }, remaining);\n return () => {\n clearTimeout(timer);\n };\n }, [status, pendingShownAt, minPendingMs]);\n\n if (pendingShownAt !== null) return 'reading';\n return status === 'reading' ? settled : status;\n}\n","import {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useState,\n type ButtonHTMLAttributes,\n type ForwardRefExoticComponent,\n type RefAttributes,\n type DragEventHandler,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport type { PasteOutcome, PasteState, PasteStatus } from '../core/paste-machine';\nimport { describePasteError, type CopyError } from '../core/errors';\nimport type { PasteResult, PasteSource } from '../core/paste-reader';\nimport { LiveRegion } from './LiveRegion';\nimport { TriggerLabel } from './TriggerLabel';\nimport { usePasteDisplayStatus, type UsePasteDisplayStatusOptions } from './usePasteDisplayStatus';\nimport { usePaste, type PasteDropTargetProps, type UsePasteOptions, type UsePasteResult } from './usePaste';\nimport { useRevealOnInteraction, type RevealReason } from './useRevealOnInteraction';\nimport { composeEventHandlers, mergeRefs } from './utils';\n\n/* ---------------------------------------------------------------- Messages */\n\nexport interface PasteFieldMessages {\n /** Announced to screen readers on successful paste. */\n readonly pasted: string | ((result: PasteResult) => string);\n /**\n * Announced to screen readers when content is dropped onto the zone. When\n * you override `pasted` but not this, your `pasted` message is used for drops too.\n */\n readonly dropped?: string | ((result: PasteResult) => string);\n /** Announced on failure. Defaults to {@link describePasteError}. `source` tells drops from pastes. */\n readonly error: (error: CopyError, source?: PasteSource) => string;\n /**\n * Accessible name of the trigger button. Receives the field's `label` prop.\n * The returned string must not be empty.\n */\n readonly triggerLabel: (label: string) => string;\n /**\n * Accessible name of the drop zone / paste target area.\n * Receives the field's `label` prop.\n */\n readonly zoneLabel: (label: string) => string;\n}\n\nexport const defaultPasteFieldMessages: PasteFieldMessages = {\n pasted: 'Pasted from clipboard',\n dropped: 'Dropped content added',\n error: describePasteError,\n triggerLabel: (label) => `Paste ${label}`,\n zoneLabel: (label) => `Paste area for ${label}`,\n};\n\n/* ----------------------------------------------------------------- Context */\n\nexport interface PasteFieldContextValue extends UsePasteResult {\n readonly label: string;\n readonly labelId: string;\n readonly zoneId: string;\n readonly revealed: boolean;\n readonly revealReason: RevealReason | null;\n readonly messages: PasteFieldMessages;\n /** Flicker-free status for rendering. Use `status` for logic, this for pixels. */\n readonly displayStatus: PasteStatus;\n /** Triggers a programmatic paste (via Clipboard API, may prompt for permission). */\n readonly doPaste: () => Promise<PasteOutcome>;\n}\n\nconst PasteFieldContext = /* @__PURE__ */ createContext<PasteFieldContextValue | null>(null);\n\n/** Access field state to build custom parts. Must be used inside `<PasteField.Root>`. */\nexport function usePasteField(): PasteFieldContextValue {\n const context = useContext(PasteFieldContext);\n if (!context) throw new Error('usePasteField() must be used inside <PasteField.Root>.');\n return context;\n}\n\n/* -------------------------------------------------------------------- Root */\n\nexport interface PasteFieldRootProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onPaste' | 'onError'>,\n UsePasteDisplayStatusOptions {\n /** Human label — used for the trigger's and zone's accessible names. */\n readonly label: string;\n readonly pasteOptions?: UsePasteOptions;\n readonly messages?: Partial<PasteFieldMessages>;\n /** Skip hover/focus reveal and always show the trigger. */\n readonly alwaysVisible?: boolean;\n /** Render the built-in live region. Disable if your app has a global announcer. Default `true`. */\n readonly announce?: boolean;\n}\n\nconst Root: ForwardRefExoticComponent<PasteFieldRootProps & RefAttributes<HTMLDivElement>> = /* @__PURE__ */ forwardRef<HTMLDivElement, PasteFieldRootProps>(function PasteFieldRoot(\n {\n label,\n pasteOptions,\n messages: messageOverrides,\n alwaysVisible = false,\n announce = true,\n pendingDelayMs,\n minPendingMs,\n children,\n onPointerEnter,\n onPointerLeave,\n onPointerDown,\n onFocus,\n onBlur,\n ...rest\n },\n forwardedRef,\n) {\n const pasteState = usePaste(pasteOptions);\n const displayStatus = usePasteDisplayStatus(pasteState.status, {\n ...(pendingDelayMs === undefined ? {} : { pendingDelayMs }),\n ...(minPendingMs === undefined ? {} : { minPendingMs }),\n });\n const reveal = useRevealOnInteraction<HTMLDivElement>({ alwaysVisible });\n const baseId = useId();\n const labelId = `${baseId}-label`;\n const zoneId = `${baseId}-zone`;\n\n const messages = useMemo<PasteFieldMessages>(\n () => ({\n ...defaultPasteFieldMessages,\n // A translated `pasted` beats the English default `dropped`.\n ...(messageOverrides?.pasted === undefined ? {} : { dropped: messageOverrides.pasted }),\n ...messageOverrides,\n }),\n [messageOverrides],\n );\n\n const { paste: machinePaste } = pasteState;\n const doPaste = useCallback(() => machinePaste(), [machinePaste]);\n const { targetProps } = reveal;\n const ref = useMemo(() => mergeRefs(targetProps.ref, forwardedRef), [targetProps.ref, forwardedRef]);\n\n const context = useMemo<PasteFieldContextValue>(\n () => ({\n ...pasteState,\n label,\n labelId,\n zoneId,\n revealed: reveal.visible,\n revealReason: reveal.reason,\n messages,\n displayStatus,\n doPaste,\n }),\n [pasteState, label, labelId, zoneId, reveal.visible, reveal.reason, messages, displayStatus, doPaste],\n );\n\n const { state } = pasteState;\n\n let announcement = '';\n if (state.status === 'read') {\n const message = (state.result.source === 'drop' ? messages.dropped : undefined) ?? messages.pasted;\n announcement = typeof message === 'function' ? message(state.result) : message;\n } else if (state.status === 'error') {\n announcement = messages.error(state.error, state.source);\n }\n\n return (\n <PasteFieldContext.Provider value={context}>\n <div\n {...rest}\n ref={ref}\n data-state={state.status}\n data-display-state={displayStatus}\n data-revealed={reveal.visible ? '' : undefined}\n onPointerEnter={composeEventHandlers(onPointerEnter, targetProps.onPointerEnter)}\n onPointerLeave={composeEventHandlers(onPointerLeave, targetProps.onPointerLeave)}\n onPointerDown={composeEventHandlers(onPointerDown, targetProps.onPointerDown)}\n onFocus={composeEventHandlers(onFocus, targetProps.onFocus)}\n onBlur={composeEventHandlers(onBlur, targetProps.onBlur)}\n >\n {children}\n {announce ? <LiveRegion message={announcement} /> : null}\n </div>\n </PasteFieldContext.Provider>\n );\n});\n\n/* ------------------------------------------------------------ Label/Status */\n\nexport type PasteFieldLabelProps = HTMLAttributes<HTMLSpanElement>;\n\nconst Label: ForwardRefExoticComponent<PasteFieldLabelProps & RefAttributes<HTMLSpanElement>> = /* @__PURE__ */ forwardRef<HTMLSpanElement, PasteFieldLabelProps>(function PasteFieldLabel(\n { children, ...rest },\n ref,\n) {\n const field = usePasteField();\n return (\n <span {...rest} ref={ref} id={field.labelId}>\n {children ?? field.label}\n </span>\n );\n});\n\nexport interface PasteFieldStatusProps extends HTMLAttributes<HTMLSpanElement> {\n /** Map each paste status to a label. Defaults to English strings. */\n readonly labels?: Partial<Readonly<Record<PasteStatus, string>>>;\n}\n\nconst DEFAULT_STATUS_LABELS: Readonly<Record<PasteStatus, string>> = {\n idle: 'Ready',\n reading: 'Reading…',\n read: 'Pasted',\n error: 'Error',\n};\n\nconst Status: ForwardRefExoticComponent<PasteFieldStatusProps & RefAttributes<HTMLSpanElement>> = /* @__PURE__ */ forwardRef<HTMLSpanElement, PasteFieldStatusProps>(function PasteFieldStatus(\n { children, labels, ...rest },\n ref,\n) {\n const field = usePasteField();\n const resolved = labels ? { ...DEFAULT_STATUS_LABELS, ...labels } : DEFAULT_STATUS_LABELS;\n return (\n <span {...rest} ref={ref} data-state={field.status} data-display-state={field.displayStatus}>\n {children ?? resolved[field.displayStatus]}\n </span>\n );\n});\n\n/* ------------------------------------------------------------------- Zone */\n\nexport interface PasteFieldZoneProps extends HTMLAttributes<HTMLDivElement> {\n /** When true, the zone is always focusable (tabIndex=0). Default true. */\n readonly focusable?: boolean;\n /**\n * Accept drag-and-drop, through the same `accept` and limits as paste.\n * `data-drag-over` is present while an accepted drag is over the zone. Default true.\n */\n readonly droppable?: boolean;\n}\n\n/**\n * A focusable paste target. Accepts keyboard paste (Ctrl/⌘+V) without a\n * permission prompt and, unless `droppable={false}`, drag-and-drop. Renders\n * `data-zone` and `data-drag-over` for styling.\n *\n * Accessible name: `aria-label` prop, else `messages.zoneLabel(label)`\n * (\"Paste area for Notes\"). Pass `aria-labelledby` explicitly to name it from\n * another element instead.\n */\nconst Zone: ForwardRefExoticComponent<PasteFieldZoneProps & RefAttributes<HTMLDivElement>> = /* @__PURE__ */ forwardRef<HTMLDivElement, PasteFieldZoneProps>(function PasteFieldZone(\n {\n children,\n focusable = true,\n droppable = true,\n onPaste,\n onDragEnter,\n onDragOver,\n onDragLeave,\n onDrop,\n 'aria-label': ariaLabel,\n tabIndex,\n ...rest\n },\n ref,\n) {\n const field = usePasteField();\n const { targetProps, dropTargetProps } = field;\n const drop: Record<keyof PasteDropTargetProps<HTMLDivElement>, DragEventHandler<HTMLDivElement> | undefined> = {\n onDragEnter,\n onDragOver,\n onDragLeave,\n onDrop,\n };\n if (droppable) {\n for (const key of Object.keys(dropTargetProps) as (keyof typeof dropTargetProps)[]) {\n drop[key] = composeEventHandlers(drop[key], dropTargetProps[key]);\n }\n }\n\n // Guard: a custom `zoneLabel` returning '' must not leave the region unnamed.\n const safeAriaLabel =\n (ariaLabel ?? field.messages.zoneLabel(field.label)) || defaultPasteFieldMessages.zoneLabel(field.label);\n\n return (\n <div\n // Default shortcut hint; a consumer value in `rest` overrides it.\n aria-keyshortcuts=\"Control+V Meta+V\"\n {...rest}\n ref={ref}\n id={field.zoneId}\n role=\"region\"\n aria-label={safeAriaLabel}\n data-zone=\"\"\n data-state={field.status}\n data-display-state={field.displayStatus}\n data-drag-over={droppable && field.isDragOver ? '' : undefined}\n tabIndex={tabIndex ?? (focusable ? 0 : undefined)}\n onPaste={composeEventHandlers(onPaste, targetProps.onPaste)}\n {...drop}\n >\n {children}\n </div>\n );\n});\n\n/* ----------------------------------------------------------------- Trigger */\n\nexport interface PasteFieldTriggerRenderProps {\n /** The real state. Use for logic. */\n readonly status: PasteStatus;\n /** Flicker-free state. Use for what you render. */\n readonly displayStatus: PasteStatus;\n readonly state: PasteState;\n readonly revealed: boolean;\n /** Whether `retry()` could help after the current error. */\n readonly canRetry: boolean;\n}\n\nexport interface PasteFieldTriggerProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'type'> {\n /** Static content, or a render function receiving the live state. */\n readonly children?: ReactNode | ((props: PasteFieldTriggerRenderProps) => ReactNode);\n}\n\nconst DEFAULT_TRIGGER_TEXT: Readonly<Record<PasteStatus, string>> = {\n idle: 'Paste',\n reading: 'Pasting…',\n read: 'Pasted',\n error: 'Retry',\n};\n\nconst Trigger: ForwardRefExoticComponent<PasteFieldTriggerProps & RefAttributes<HTMLButtonElement>> = /* @__PURE__ */ forwardRef<HTMLButtonElement, PasteFieldTriggerProps>(function PasteFieldTrigger(\n { children, onClick, 'aria-label': ariaLabel, ...rest },\n ref,\n) {\n const field = usePasteField();\n const renderProps: PasteFieldTriggerRenderProps = {\n status: field.status,\n displayStatus: field.displayStatus,\n state: field.state,\n revealed: field.revealed,\n canRetry: field.canRetry,\n };\n\n const safeAriaLabel =\n (ariaLabel ?? field.messages.triggerLabel(field.label)) || defaultPasteFieldMessages.triggerLabel(field.label);\n\n return (\n <button\n {...rest}\n ref={ref}\n type=\"button\"\n aria-label={safeAriaLabel}\n aria-busy={field.status === 'reading' ? true : undefined}\n data-state={field.status}\n data-display-state={field.displayStatus}\n data-revealed={field.revealed ? '' : undefined}\n onClick={composeEventHandlers(onClick, () => {\n void field.doPaste();\n })}\n >\n {typeof children === 'function'\n ? children(renderProps)\n : (children ?? <TriggerLabel status={field.displayStatus} labels={DEFAULT_TRIGGER_TEXT} />)}\n </button>\n );\n});\n\n/* ----------------------------------------------------------------- Preview */\n\nexport interface PasteFieldPreviewRenderProps {\n readonly result: PasteResult;\n /**\n * Object URLs for `result.images`, in order, revoked automatically. Empty on\n * the server and for the first render after a paste, until they are created.\n */\n readonly imageUrls: readonly string[];\n}\n\nexport interface PasteFieldPreviewProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {\n /** Custom rendering of the latest result. Replaces the default text / image / file preview. */\n readonly children?: (props: PasteFieldPreviewRenderProps) => ReactNode;\n /** Shown while there is no pasted result (idle, reading, error). */\n readonly placeholder?: ReactNode;\n /** Pasted text longer than this is cut and ends with \"…\". Default 2000. */\n readonly maxTextLength?: number;\n /** Alt text for each pasted image. Default \"Pasted image 1 of 2\". */\n readonly imageAlt?: (index: number, total: number) => string;\n}\n\nconst NO_URLS: readonly string[] = [];\n\n/**\n * Object URLs for blobs, revoked when the blobs change or the component\n * unmounts. URLs are only returned for the blobs they were made from, so they\n * never pair with the wrong result.\n */\nfunction useObjectUrls(blobs: readonly Blob[] | undefined): readonly string[] {\n const [entry, setEntry] = useState<{ readonly blobs?: readonly Blob[]; readonly urls: readonly string[] }>({\n urls: NO_URLS,\n });\n useEffect(() => {\n if (!blobs?.length || typeof URL.createObjectURL !== 'function') return undefined;\n const urls = blobs.map((blob) => URL.createObjectURL(blob));\n setEntry({ blobs, urls });\n return () => {\n for (const url of urls) URL.revokeObjectURL(url);\n };\n }, [blobs]);\n return entry.blobs === blobs ? entry.urls : NO_URLS;\n}\n\nconst defaultImageAlt = (index: number, total: number): string => `Pasted image ${String(index + 1)} of ${String(total)}`;\n\n/**\n * Shows what was pasted: text (never HTML, which is untrusted), image\n * thumbnails and file names. Renders `placeholder` until there is a result.\n * Pass a function child to render the result yourself.\n */\nconst Preview: ForwardRefExoticComponent<PasteFieldPreviewProps & RefAttributes<HTMLDivElement>> = /* @__PURE__ */ forwardRef<HTMLDivElement, PasteFieldPreviewProps>(function PasteFieldPreview(\n { children, placeholder = null, maxTextLength = 2000, imageAlt = defaultImageAlt, ...rest },\n ref,\n) {\n const { result, status } = usePasteField();\n const imageUrls = useObjectUrls(result?.images);\n\n let content: ReactNode = placeholder;\n if (result) {\n if (children) {\n content = children({ result, imageUrls });\n } else {\n const { text } = result;\n const files = result.files.filter((file) => !file.type.startsWith('image/'));\n content = (\n <>\n {text ? (\n <pre data-preview-text=\"\">{text.length > maxTextLength ? `${text.slice(0, maxTextLength)}…` : text}</pre>\n ) : null}\n {imageUrls.map((url, index) => (\n <img key={url} data-preview-image=\"\" src={url} alt={imageAlt(index, imageUrls.length)} />\n ))}\n {files.length > 0 ? (\n <ul data-preview-files=\"\">\n {files.map((file, index) => (\n <li key={`${String(index)}-${file.name}`}>{file.name}</li>\n ))}\n </ul>\n ) : null}\n </>\n );\n }\n }\n\n return (\n <div {...rest} ref={ref} data-preview=\"\" data-state={status} data-empty={result ? undefined : ''}>\n {content}\n </div>\n );\n});\n\n/**\n * Headless compound component for a labelled, paste-ready field.\n *\n * Styling hooks on Root, Zone and Trigger:\n * - `data-display-state=\"idle|reading|read|error\"`: flicker-free, style with this\n * - `data-state`: the real, instantaneous state, for logic and tests\n * - `data-revealed`: present while the trigger should be visible\n *\n * @example\n * ```tsx\n * <PasteField.Root label=\"Notes\">\n * <PasteField.Label />\n * <PasteField.Zone />\n * <PasteField.Trigger />\n * <PasteField.Preview placeholder=\"Nothing pasted yet\" />\n * </PasteField.Root>\n * ```\n */\nexport const PasteField: {\n readonly Root: typeof Root;\n readonly Label: typeof Label;\n readonly Status: typeof Status;\n readonly Zone: typeof Zone;\n readonly Trigger: typeof Trigger;\n readonly Preview: typeof Preview;\n} = { Root, Label, Status, Zone, Trigger, Preview } as const;\n","import { useCallback, useEffect, useRef, useState, type RefCallback } from 'react';\nimport {\n applyDragCopy,\n type DragCopyOptions,\n type DragCopyOutcome,\n type DragCopyState,\n type DragCopyStatus,\n type DragStartEventLike,\n} from '../core/drag-copy';\nimport { useIsomorphicLayoutEffect } from './utils';\nimport { invoke } from '../core/machine-shared';\n\nexport interface UseDragCopyOptions extends Omit<DragCopyOptions, 'onDrag'> {\n /**\n * Set `false` to disable drag without unmounting. Removes the `draggable`\n * attribute and listener while `false`. Default `true`.\n */\n readonly enabled?: boolean;\n /** Called each time a drag starts or ends. */\n readonly onDrag?: (state: DragCopyState) => void;\n}\n\nexport interface UseDragCopyResult<T extends HTMLElement = HTMLElement> {\n /**\n * Attach to any element you want to make draggable. The hook sets\n * `draggable=\"true\"` automatically while `enabled` is `true`.\n */\n readonly ref: RefCallback<T>;\n /** `'idle' | 'dragging' | 'done'` — the current drag status. */\n readonly status: DragCopyStatus;\n /** The last `dragstart` outcome; `null` before the first drag. */\n readonly outcome: DragCopyOutcome | null;\n /**\n * For use in React's `onDragStart` prop if you need to wire it imperatively\n * (e.g. inside a render-prop component). The `ref` alone is sufficient for\n * native HTML elements: the hook attaches its own listener.\n */\n readonly onDragStart: (event: DragStartEventLike) => void;\n}\n\n/**\n * Makes an element draggable and populates its `DataTransfer` with your data.\n *\n * ```tsx\n * const { ref } = useDragCopy({\n * source: () => ({ kind: 'html', html: '<b>Hello</b>', text: 'Hello' }),\n * });\n * return <div ref={ref}>Drag me</div>;\n * ```\n *\n * - No Clipboard API needed — works in every browser supporting HTML5 drag-and-drop.\n * - The `source` callback always reads the latest props/state, never stale closures.\n * - `enabled={false}` removes `draggable` and the listener without unmounting.\n * - SSR-safe: no DOM access during server rendering.\n */\nexport function useDragCopy<T extends HTMLElement = HTMLElement>(\n options: UseDragCopyOptions,\n): UseDragCopyResult<T> {\n const optionsRef = useRef(options);\n useIsomorphicLayoutEffect(() => {\n optionsRef.current = options;\n });\n\n const [node, setNode] = useState<HTMLElement | null>(null);\n const [state, setState] = useState<DragCopyState>({ status: 'idle', outcome: null });\n\n const enabled = options.enabled !== false;\n\n // Stable handler for the React onDragStart prop path.\n const onDragStart = useCallback((event: DragStartEventLike): void => {\n const { onDrag, onError, source, effectAllowed } = optionsRef.current;\n const coreOpts: DragCopyOptions = effectAllowed !== undefined\n ? { source, effectAllowed }\n : { source };\n const outcome = applyDragCopy(event, coreOpts);\n const next: DragCopyState = { status: 'dragging', outcome };\n setState(next);\n if (outcome.status === 'failed') invoke(onError, outcome.error);\n invoke(onDrag, next);\n }, []);\n\n useEffect(() => {\n if (!node || !enabled) return undefined;\n\n node.setAttribute('draggable', 'true');\n\n function handleDragStart(raw: Event): void {\n const event = raw as DragEvent;\n const { onDrag, onError, source, effectAllowed } = optionsRef.current;\n const coreOpts: DragCopyOptions = effectAllowed !== undefined\n ? { source, effectAllowed }\n : { source };\n const outcome = applyDragCopy(\n {\n type: event.type,\n dataTransfer: event.dataTransfer,\n get defaultPrevented() {\n return event.defaultPrevented;\n },\n preventDefault: () => { event.preventDefault(); },\n },\n coreOpts,\n );\n const next: DragCopyState = { status: 'dragging', outcome };\n setState(next);\n if (outcome.status === 'failed') invoke(onError, outcome.error);\n invoke(onDrag, next);\n }\n\n function handleDragEnd(): void {\n const opts = optionsRef.current;\n setState((prev) => {\n const next: DragCopyState = { status: 'done', outcome: prev.outcome };\n invoke(opts.onDrag, next);\n return next;\n });\n }\n\n node.addEventListener('dragstart', handleDragStart);\n node.addEventListener('dragend', handleDragEnd);\n\n return () => {\n node.removeEventListener('dragstart', handleDragStart);\n node.removeEventListener('dragend', handleDragEnd);\n node.removeAttribute('draggable');\n };\n }, [node, enabled]);\n\n // Reset to idle when disabled so status accurately reflects the element's state.\n useEffect(() => {\n if (!enabled) setState({ status: 'idle', outcome: null });\n }, [enabled]);\n\n return {\n ref: setNode,\n status: state.status,\n outcome: state.outcome,\n onDragStart,\n };\n}\n","import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';\nimport { DEFAULT_RESET_AFTER_MS } from '../core/copy-machine';\nimport type { CopyError } from '../core/errors';\nimport { useIsomorphicLayoutEffect } from './utils';\nimport { shareMethod, shareOrCopy, TOUCH_FIRST, type ShareContent, type ShareMethod, type ShareOptions, type ShareOutcome } from '../share/share';\n\n/** `sharing` lasts while the share sheet is open or the copy is being written. */\nexport type ShareStatus = 'idle' | 'sharing' | 'shared' | 'copied' | 'error';\n\nexport interface UseShareOptions extends ShareOptions {\n /** Time in `shared` or `copied` before returning to `idle`. `false` keeps it. Default 2000. */\n readonly resetAfterMs?: number | false;\n /** Called with every settled outcome, including `cancelled`. */\n readonly onShare?: (outcome: ShareOutcome) => void;\n}\n\n/** What `share()` resolves to: the outcome, or `ignored` while a share is already open. */\nexport type UseShareOutcome = ShareOutcome | { readonly status: 'ignored'; readonly reason: 'in-flight' };\n\nexport interface UseShareResult {\n readonly status: ShareStatus;\n readonly error: CopyError | null;\n /** The last settled outcome; `null` before the first and after `reset()`. */\n readonly outcome: ShareOutcome | null;\n /**\n * How `share()` will share: `\"native\"` (the share sheet) or `\"copy\"`. Label the\n * button with it (\"Share…\" or \"Copy link\"). `\"copy\"` during server rendering\n * and hydration, then updated in the browser, also when the device changes.\n */\n readonly method: ShareMethod;\n /** Stable identity. Call it in a click handler. Never rejects. */\n readonly share: (content: ShareContent) => Promise<UseShareOutcome>;\n /** Stable identity. Back to `idle`; the result of a share still open is ignored. */\n readonly reset: () => void;\n}\n\ninterface State {\n readonly status: ShareStatus;\n readonly outcome: ShareOutcome | null;\n}\n\nconst IDLE: State = { status: 'idle', outcome: null };\nconst IGNORED: UseShareOutcome = /* @__PURE__ */ Object.freeze({ status: 'ignored', reason: 'in-flight' });\n\nfunction resetDelay(value: number | false | undefined): number | null {\n if (value === false || value === Infinity) return null;\n return value === undefined || Number.isNaN(value) ? DEFAULT_RESET_AFTER_MS : Math.max(0, value);\n}\n\nconst statusOf = (outcome: ShareOutcome): ShareStatus => (outcome.status === 'cancelled' ? 'idle' : outcome.status);\n\n/**\n * Share with the device's share sheet on phones and tablets, and copy a titled\n * link everywhere else, with honest state for the button. Options may change on\n * every render; the latest ones are always used.\n *\n * @example\n * const { share, status, method } = useShare();\n * <button onClick={() => share({ url, title })}>\n * {status === 'copied' ? 'Link copied' : method === 'native' ? 'Share…' : 'Copy link'}\n * </button>\n */\nexport function useShare(options: UseShareOptions = {}): UseShareResult {\n const optionsRef = useRef(options);\n useIsomorphicLayoutEffect(() => {\n optionsRef.current = options;\n });\n\n const [state, setState] = useState<State>(IDLE);\n const mounted = useRef(false);\n const inFlight = useRef(false);\n const generation = useRef(0);\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n generation.current += 1;\n clearTimeout(timer.current);\n };\n }, []);\n\n const subscribe = useCallback((onChange: () => void) => {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return () => undefined;\n const list = window.matchMedia(TOUCH_FIRST);\n list.addEventListener('change', onChange);\n return () => {\n list.removeEventListener('change', onChange);\n };\n }, []);\n const method = useSyncExternalStore(\n subscribe,\n () => shareMethod(optionsRef.current),\n (): ShareMethod => 'copy',\n );\n\n const share = useCallback(async (content: ShareContent): Promise<UseShareOutcome> => {\n if (inFlight.current) return IGNORED;\n inFlight.current = true;\n const current = (generation.current += 1);\n clearTimeout(timer.current);\n setState({ status: 'sharing', outcome: null });\n // No await before this call: the share sheet needs the click's user activation.\n const outcome = await shareOrCopy(content, optionsRef.current);\n inFlight.current = false;\n if (!mounted.current || current !== generation.current) return outcome;\n setState({ status: statusOf(outcome), outcome });\n const delay = resetDelay(optionsRef.current.resetAfterMs);\n if ((outcome.status === 'shared' || outcome.status === 'copied') && delay !== null) {\n timer.current = setTimeout(() => {\n setState(IDLE);\n }, delay);\n }\n optionsRef.current.onShare?.(outcome);\n return outcome;\n }, []);\n\n const reset = useCallback(() => {\n generation.current += 1;\n clearTimeout(timer.current);\n setState(IDLE);\n }, []);\n\n return useMemo(\n () => ({\n status: state.status,\n error: state.outcome?.status === 'error' ? state.outcome.error : null,\n outcome: state.outcome,\n method,\n share,\n reset,\n }),\n [state, method, share, reset],\n );\n}\n","import { useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from 'react';\nimport { createOtpField, type OtpField, type OtpFieldOptions, type OtpSnapshot } from '../otp/field';\nimport { useIsomorphicLayoutEffect } from './utils';\n\nexport type UseOtpFieldOptions = OtpFieldOptions;\n\n/** Props for one box: spread them on an `<input>`. The field sets its value; don't pass `value`. */\nexport interface OtpInputProps {\n readonly ref: (element: HTMLInputElement | null) => void;\n readonly type: 'text';\n readonly autoComplete: 'one-time-code' | 'off';\n readonly inputMode: 'numeric' | 'text';\n readonly 'aria-label': string;\n readonly autoCapitalize: 'off' | 'characters';\n readonly spellCheck: false;\n readonly pattern?: string;\n}\n\nexport interface UseOtpFieldResult extends OtpSnapshot {\n /** Props for box `index` (0 to `length - 1`). Render one `<input>` for each. */\n readonly getInputProps: (index: number) => OtpInputProps;\n /** Fills the boxes with `code` from the first. Stable identity. */\n readonly setValue: (code: string) => void;\n /** Empties every box and focuses the first. Stable identity. */\n readonly clear: () => void;\n /** Focuses the first empty box. Stable identity. */\n readonly focus: () => void;\n}\n\nconst defaultLabel = (numeric: boolean) => (index: number, length: number) => `${numeric ? 'Digit' : 'Character'} ${String(index + 1)} of ${String(length)}`;\n\n/**\n * A one-time code field of single-character boxes, headless: typing moves to the next box\n * and Backspace to the one before; pasting a code (or an SMS holding one) into any box\n * fills them all; an SMS autofill (iOS, Android) and, with `webOtp`, the WebOTP API do too.\n * Every box has an accessible name; name the group around them.\n *\n * `length`, `alphabet` and `webOtp` are read when the field is made: a change makes a new,\n * empty field. Callbacks and `label` may change on every render.\n *\n * @example\n * const otp = useOtpField({ length: 6, onComplete: (code) => void verify(code) });\n * <div role=\"group\" aria-label=\"Verification code\">\n * {Array.from({ length: 6 }, (_, index) => <input key={index} {...otp.getInputProps(index)} />)}\n * </div>\n */\nexport function useOtpField(options: UseOtpFieldOptions = {}): UseOtpFieldResult {\n const latest = useRef(options);\n useIsomorphicLayoutEffect(() => {\n latest.current = options;\n });\n const length = options.length ?? 6;\n const alphabet = options.alphabet ?? 'numeric';\n const webOtp = options.webOtp === true;\n\n const field: OtpField = useMemo(\n () =>\n createOtpField({\n length,\n alphabet,\n webOtp,\n label: (index, total) => (latest.current.label ?? defaultLabel(alphabet === 'numeric'))(index, total),\n onChange: (snapshot) => latest.current.onChange?.(snapshot),\n onComplete: (code) => latest.current.onComplete?.(code),\n }),\n [length, alphabet, webOtp],\n );\n const snapshot = useSyncExternalStore(field.subscribe, field.getSnapshot, field.getSnapshot);\n\n // The boxes, by index, as React mounts them; attached to the field once they are all there.\n const elements = useRef<(HTMLInputElement | null)[]>([]);\n const refs = useMemo(\n () =>\n Array.from({ length }, (_, index) => (element: HTMLInputElement | null) => {\n elements.current[index] = element;\n }),\n [length],\n );\n const attached = useRef<{ readonly field: OtpField; readonly inputs: readonly HTMLInputElement[]; readonly detach: () => void } | null>(null);\n useIsomorphicLayoutEffect(() => {\n const inputs = elements.current.slice(0, length).filter((element): element is HTMLInputElement => element !== null);\n const current = attached.current;\n const same = current !== null && current.field === field && current.inputs.length === inputs.length && current.inputs.every((input, index) => input === inputs[index]);\n if (same) return;\n current?.detach();\n attached.current = inputs.length === length ? { field, inputs, detach: field.attach(inputs) } : null;\n });\n useEffect(\n () => () => {\n attached.current?.detach();\n attached.current = null;\n },\n [],\n );\n\n // This render's label: the props are rendered now, before the latest options are stored.\n const labelOf = options.label;\n const getInputProps = useCallback(\n (index: number): OtpInputProps => {\n const numeric = alphabet === 'numeric';\n const label = (labelOf ?? defaultLabel(numeric))(index, length);\n return {\n ref: refs[index] ?? (() => undefined),\n type: 'text',\n autoComplete: index === 0 ? 'one-time-code' : 'off',\n inputMode: numeric ? 'numeric' : 'text',\n 'aria-label': label,\n autoCapitalize: numeric ? 'off' : 'characters',\n spellCheck: false,\n ...(numeric ? { pattern: '[0-9]*' } : {}),\n };\n },\n [alphabet, length, refs, labelOf],\n );\n\n return {\n ...snapshot,\n getInputProps,\n setValue: field.setValue,\n clear: field.clear,\n focus: field.focus,\n };\n}\n"],"mappings":";;;;;;;;;;;;AAGA,MAAM,mBAAmC,8BAAsC,IAAI;;;;;;AAgBnF,SAAgB,UAAU,EAAE,UAAU,eAA4C;CAChF,MAAM,CAAC,SAAS,SAAS,qBAAqB;CAC9C,OAAO,oBAAC,iBAAiB,UAAlB;EAA2B,OAAO,eAAe;EAAQ;CAAoC,CAAA;AACtG;;AAGA,SAAgB,eAAuC;CACrD,OAAO,WAAW,gBAAgB;AACpC;;;;ACxBA,MAAa,4BAAoD,OAAO,WAAW,cAAc,YAAY;AAE7G,SAAgB,UAAa,GAAG,MAAyD;CACvF,QAAQ,SAAS;EACf,KAAK,MAAM,OAAO,MAChB,IAAI,OAAO,QAAQ,YAAY,IAAI,IAAI;OAClC,IAAI,KAAK,IAA+B,UAAU;CAE3D;AACF;;AAGA,SAAgB,qBACd,QACA,MACoB;CACpB,QAAQ,UAAU;EAChB,SAAS,KAAK;EACd,IAAI,CAAC,MAAM,kBAAkB,KAAK,KAAK;CACzC;AACF;;;ACSA,MAAMA,4BAAqC;;AAG3C,SAAS,UAAU,SAAyB,OAA+C;CACzF,OAAO,QAAQ,gBAAgB,KA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ACb,OAAO,MAAM;CACf;AACF"}
package/dist/link.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const require_errors = require("./chunks/errors-BwOF6T_M.cjs");
4
- const require_url = require("./chunks/url-D4PGsRm8.cjs");
5
- const require_payload = require("./chunks/payload-J6GjHuh3.cjs");
3
+ const require_errors = require("./chunks/errors-DFmEAC4E.cjs");
4
+ const require_url = require("./chunks/url-BrhVUwn7.cjs");
5
+ const require_payload = require("./chunks/payload-tTK6REua.cjs");
6
6
  const require_inert_html = require("./chunks/inert-html-DyxjWDok.cjs");
7
7
  const require_text_field = require("./chunks/text-field-BEzUVOag.cjs");
8
8
  //#region src/link/fragment.ts
package/dist/link.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- import { o as HtmlPayload, u as MultiPayload } from "./chunks/payload-CcwKJ_bU.cjs";
2
+ import { o as HtmlPayload, u as MultiPayload } from "./chunks/payload-qkAWVXWA.cjs";
3
3
  import { t as insertText } from "./chunks/text-field-C0SGmvvR.cjs";
4
4
  import { a as cleanLinkUrl, i as TRACKING_PARAMETERS, n as DEFAULT_LINK_PROTOCOLS, o as resolveLinkUrl, r as LinkUrlOptions, t as CleanLinkOptions } from "./chunks/url-DWdElCT3.cjs";
5
5
  //#region src/link/payload.d.ts
package/dist/link.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- import { o as HtmlPayload, u as MultiPayload } from "./chunks/payload-Cl_8hCI5.js";
2
+ import { o as HtmlPayload, u as MultiPayload } from "./chunks/payload-CcvSx_Hq.js";
3
3
  import { t as insertText } from "./chunks/text-field-C0SGmvvR.js";
4
4
  import { a as cleanLinkUrl, i as TRACKING_PARAMETERS, n as DEFAULT_LINK_PROTOCOLS, o as resolveLinkUrl, r as LinkUrlOptions, t as CleanLinkOptions } from "./chunks/url-DWdElCT3.js";
5
5
  //#region src/link/payload.d.ts
package/dist/link.js CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
- import { n as copyFailure } from "./chunks/errors-9h8sdFFX.js";
3
- import { a as resolveLinkUrl, i as linkUrlResolver, n as TRACKING_PARAMETERS, r as cleanLinkUrl, t as DEFAULT_LINK_PROTOCOLS } from "./chunks/url-BcMYVCXQ.js";
4
- import { a as resolveLink, i as markdownLink, n as cleanTitle, r as linkPayload, t as DEFAULT_LINK_TITLE_LENGTH } from "./chunks/payload-DI5AorDz.js";
2
+ import { n as copyFailure } from "./chunks/errors-CT-FfUtU.js";
3
+ import { a as resolveLinkUrl, i as linkUrlResolver, n as TRACKING_PARAMETERS, r as cleanLinkUrl, t as DEFAULT_LINK_PROTOCOLS } from "./chunks/url-COID0BLY.js";
4
+ import { a as resolveLink, i as markdownLink, n as cleanTitle, r as linkPayload, t as DEFAULT_LINK_TITLE_LENGTH } from "./chunks/payload-BWQ6sPtS.js";
5
5
  import { t as parseInertHtml } from "./chunks/inert-html-D75NyVvT.js";
6
6
  import { n as insertText, t as asTextField } from "./chunks/text-field-D7PF2WlX.js";
7
7
  //#region src/link/fragment.ts
package/dist/markdown.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const require_errors = require("./chunks/errors-BwOF6T_M.cjs");
3
+ const require_errors = require("./chunks/errors-DFmEAC4E.cjs");
4
4
  const require_inert_html = require("./chunks/inert-html-DyxjWDok.cjs");
5
5
  const require_url = require("./chunks/url-B9jdFGQy.cjs");
6
6
  const require_text_field = require("./chunks/text-field-BEzUVOag.cjs");