@wow-two-beta/fe 0.0.23 → 0.0.25

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 (21) hide show
  1. package/dist/chunks/{BackToTopButton.vue_vue_type_script_setup_true_lang-dge5C6We.js → BackToTopButton.vue_vue_type_script_setup_true_lang-CNMcUYtR.js} +13 -9
  2. package/dist/chunks/BackToTopButton.vue_vue_type_script_setup_true_lang-CNMcUYtR.js.map +1 -0
  3. package/dist/chunks/{KanbanCard.vue_vue_type_script_setup_true_lang-BolubhiV.js → KanbanCard.vue_vue_type_script_setup_true_lang-BCnquIre.js} +3 -3
  4. package/dist/chunks/{KanbanCard.vue_vue_type_script_setup_true_lang-BolubhiV.js.map → KanbanCard.vue_vue_type_script_setup_true_lang-BCnquIre.js.map} +1 -1
  5. package/dist/chunks/MasonryLayout.vue_vue_type_script_setup_true_lang-TuNWahLw.js.map +1 -1
  6. package/dist/chunks/{Tooltip.vue_vue_type_script_setup_true_lang-AzuqiFWY.js → Tooltip.vue_vue_type_script_setup_true_lang-vsFDijcV.js} +3 -2
  7. package/dist/chunks/{Tooltip.vue_vue_type_script_setup_true_lang-AzuqiFWY.js.map → Tooltip.vue_vue_type_script_setup_true_lang-vsFDijcV.js.map} +1 -1
  8. package/dist/chunks/{UseClipboard-x6nEdQ9f.js → UseClipboard-D5jEv39w.js} +52 -16
  9. package/dist/chunks/UseClipboard-D5jEv39w.js.map +1 -0
  10. package/dist/foundation/clipboard/ClipboardResult.d.ts +7 -0
  11. package/dist/foundation/clipboard/LegacyCopy.d.ts +6 -2
  12. package/dist/foundation/clipboard/hooks/UseClipboard.d.ts +18 -8
  13. package/dist/foundation/clipboard/index.js +2 -2
  14. package/dist/index.js +3 -3
  15. package/dist/presentation/actions/copyButton/CopyButton.vue.d.ts +3 -1
  16. package/dist/presentation/actions/index.js +1 -1
  17. package/dist/presentation/display/index.js +1 -1
  18. package/dist/presentation/overlays/index.js +1 -1
  19. package/package.json +1 -1
  20. package/dist/chunks/BackToTopButton.vue_vue_type_script_setup_true_lang-dge5C6We.js.map +0 -1
  21. package/dist/chunks/UseClipboard-x6nEdQ9f.js.map +0 -1
@@ -105,7 +105,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
105
105
  );
106
106
  }
107
107
  const contentClasses = cn(
108
- "z-tooltip rounded-md bg-inverse px-2.5 py-1.5 text-xs text-inverse-foreground shadow-md",
108
+ "rounded-md bg-inverse px-2.5 py-1.5 text-xs text-inverse-foreground shadow-md",
109
109
  "motion-safe:data-[state=open]:animate-(--animate-pop-in)",
110
110
  "motion-safe:data-[state=closed]:animate-(--animate-pop-out)"
111
111
  );
@@ -118,6 +118,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
118
118
  anchor: anchor.value,
119
119
  placement: props.placement,
120
120
  offset: 6,
121
+ class: "z-tooltip",
121
122
  onAnimationend: onAnimationEnd
122
123
  }, {
123
124
  default: withCtx(() => [
@@ -148,4 +149,4 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
148
149
  export {
149
150
  _sfc_main as _
150
151
  };
151
- //# sourceMappingURL=Tooltip.vue_vue_type_script_setup_true_lang-AzuqiFWY.js.map
152
+ //# sourceMappingURL=Tooltip.vue_vue_type_script_setup_true_lang-vsFDijcV.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.vue_vue_type_script_setup_true_lang-AzuqiFWY.js","sources":["../../src/presentation/overlays/tooltip/Tooltip.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { Placement } from '@floating-ui/vue';\n\nexport interface TooltipProps {\n /** The tooltip body. Rich content goes through the `content` slot. */\n readonly content?: string | number;\n\n /** The Floating UI placement. Default `top`. */\n readonly placement?: Placement;\n\n /** The delay before opening on hover, in ms. Default 700. */\n readonly openDelay?: number;\n\n /** The delay before closing on leave, in ms. Default 0. */\n readonly closeDelay?: number;\n\n /** Controlled axes use their canonical Vue model names; each update event requests caller state. */\n readonly open?: boolean;\n\n /** The initial open state when uncontrolled. Default `false`. */\n readonly defaultOpen?: boolean;\n\n /** The disabled mode — suppresses rendering even on hover (e.g. when content is empty). */\n readonly isDisabled?: boolean;\n}\n</script>\n\n<script setup lang=\"ts\">\nimport {\n cloneVNode,\n computed,\n createCommentVNode,\n onBeforeUnmount,\n ref,\n shallowRef,\n useSlots,\n watch,\n type VNode,\n} from 'vue';\nimport { AriaAttribute, resolveElement } from '../../../foundation/dom';\nimport { cn } from '../../../foundation/styles';\nimport { useControlled } from '../../../foundation/state';\nimport { useEscape } from '../../../foundation/shortcuts';\nimport { useId } from '../../../foundation/identifiers';\nimport { useReducedMotion } from '../../../foundation/device';\nimport { AnchoredPositioner, Portal, Presence, renderableChildren } from '../../../foundation/primitives';\n\n/**\n * Renders a hover- or focus-triggered tooltip into a Portal, positioned by Floating UI.\n *\n * Wraps a single default-slot child as the trigger. Default delays mirror the OS pattern (700ms in, 0 out). Escape\n * dismisses without moving focus (WCAG 1.4.13); the trigger is described by the tooltip via `aria-describedby` while\n * open.\n *\n * `inheritAttrs: false` because the component renders a fragment (trigger + portal) — there is no single root for\n * attrs to land on, exactly as in React.\n */\ndefineOptions({ name: 'Tooltip', inheritAttrs: false });\n\ndefineSlots<{\n /** The single child element — the trigger. Receives the handlers, the ref, and `aria-describedby`. */\n default(): unknown;\n /** The rich override for the `content` prop. */\n content?(): unknown;\n}>();\n\nconst props = withDefaults(defineProps<TooltipProps>(), {\n content: undefined,\n placement: 'top',\n openDelay: 700,\n closeDelay: 0,\n open: undefined,\n defaultOpen: false,\n isDisabled: undefined,\n});\n\nconst emit = defineEmits<{\n /** Fires when the tooltip shows or hides — the `v-model:open` half. */\n 'update:open': [open: boolean];\n}>();\n\nconst slots = useSlots();\n\n/* `useControlled` returns a handle, not React's tuple, and takes `controlled` as a getter so the\n controlled branch tracks the prop. */\nconst { value: open, setValue: setOpen } = useControlled<boolean>({\n controlled: () => props.open,\n default: props.defaultOpen,\n onChange: (next) => {\n emit('update:open', next);\n },\n});\n\nconst anchor = shallowRef<HTMLElement | null>(null);\nconst tooltipId = useId('tooltip');\n\nlet openTimer: ReturnType<typeof setTimeout> | null = null;\nlet closeTimer: ReturnType<typeof setTimeout> | null = null;\n\nfunction clear(): void {\n if (openTimer) clearTimeout(openTimer);\n if (closeTimer) clearTimeout(closeTimer);\n openTimer = null;\n closeTimer = null;\n}\n\nfunction show(): void {\n clear();\n if (props.isDisabled) return;\n openTimer = setTimeout(() => {\n if (!props.isDisabled) setOpen(true);\n }, props.openDelay);\n}\n\nfunction hide(): void {\n clear();\n closeTimer = setTimeout(() => setOpen(false), props.closeDelay);\n}\n\nwatch(\n () => props.isDisabled,\n (disabled) => {\n if (!disabled) return;\n clear();\n setOpen(false);\n },\n);\n\n/* Clear pending timers on unmount. */\nonBeforeUnmount(clear);\n\n/* WCAG 1.4.13 — Escape dismisses immediately, without moving focus. */\nuseEscape(() => {\n clear();\n setOpen(false);\n}, open);\n\nconst reducedMotion = useReducedMotion();\n\n/**\n * React gated on `!!content`; a Vue consumer can supply the body through the `content` slot\n * instead, so either source counts. An empty tooltip still never opens.\n */\nconst hasContent = computed(() => !!props.content || !!slots.content);\n\nconst visible = computed(() => !props.isDisabled && open.value && hasContent.value);\n\n/* Keep the Portal + positioner mounted while the exit animation plays.\n Becomes true with `visible`; cleared on the body's pop-out `animationend`\n (see `onAnimationEnd` below). With reduced motion no exit animation runs,\n so tear the shell down immediately on close. */\nconst mounted = ref(false);\nwatch(\n [visible, reducedMotion],\n ([isVisible, isReduced]) => {\n if (isVisible) mounted.value = true;\n else if (isReduced) mounted.value = false;\n },\n { immediate: true },\n);\n\nfunction onAnimationEnd(): void {\n if (!visible.value) mounted.value = false;\n}\n\n/** A function ref may receive a component's public instance; the positioner needs the DOM node. */\nfunction setAnchor(value: unknown): void {\n anchor.value = resolveElement(value);\n}\n\n/**\n * React cloned the child element to attach the ref, the handlers and `aria-describedby`.\n * `cloneVNode` is the Vue counterpart and merges through `mergeProps`, so a handler the\n * consumer already put on the trigger is chained rather than replaced — the job React's\n * explicit `trigger.props.onPointerEnter?.(e)` forwarding did.\n *\n * Called from the template, never from a `computed`: a vnode `ref` records the instance rendering\n * at creation as its owner. The scheduler refreshes a dirty computed before the render runs, while\n * no instance renders, and production Vue then throws reading the missing owner's `refs`.\n *\n * The listener keys are all-lowercase after `on` (`onPointerenter`, not `onPointerEnter`):\n * Vue hyphenates the remainder to derive the DOM event name, so the React casing would\n * register `pointer-enter` and never fire.\n */\nfunction renderTrigger(): VNode {\n const child = renderableChildren(slots.default?.())[0];\n if (!child) return createCommentVNode('');\n const own = child.props?.[AriaAttribute.DescribedBy] as string | undefined;\n return cloneVNode(\n child,\n {\n ref: setAnchor,\n [AriaAttribute.DescribedBy]: visible.value ? [own, tooltipId].filter(Boolean).join(' ') : own,\n onPointerenter: show,\n onPointerleave: hide,\n onFocus: show,\n onBlur: hide,\n },\n true,\n );\n}\n\nconst contentClasses = cn(\n 'z-tooltip rounded-md bg-inverse px-2.5 py-1.5 text-xs text-inverse-foreground shadow-md',\n 'motion-safe:data-[state=open]:animate-(--animate-pop-in)',\n 'motion-safe:data-[state=closed]:animate-(--animate-pop-out)',\n);\n</script>\n\n<template>\n <component :is=\"renderTrigger()\" />\n <Portal v-if=\"mounted\">\n <!-- Exit animation bubbles up from the body; once the closed-state pop-out ends, tear down\n the Portal shell. Also covers the reduced-motion path, where no animation runs and\n `Presence` has already unmounted the body. -->\n <AnchoredPositioner :anchor=\"anchor\" :placement=\"props.placement\" :offset=\"6\" @animationend=\"onAnimationEnd\">\n <!-- `Presence` clones `data-state` (\"open\" | \"closed\") + its tracking ref onto the body,\n which is what gates the pop-in / pop-out keyframes. Motion sits behind `motion-safe:`\n so reduced-motion users get an instant show/hide. -->\n <Presence :is-present=\"visible\">\n <div :id=\"tooltipId\" role=\"tooltip\" :class=\"contentClasses\">\n <slot name=\"content\">{{ props.content }}</slot>\n </div>\n </Presence>\n </AnchoredPositioner>\n </Portal>\n</template>\n"],"names":["_openBlock","_createBlock","_resolveDynamicComponent","_unref","Portal","_createVNode","AnchoredPositioner","_createElementVNode","_renderSlot","_createTextVNode","_toDisplayString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,UAAM,QAAQ;AAUd,UAAM,OAAO;AAKb,UAAM,QAAQ,SAAA;AAId,UAAM,EAAE,OAAO,MAAM,UAAU,QAAA,IAAY,cAAuB;AAAA,MAChE,YAAY,MAAM,MAAM;AAAA,MACxB,SAAS,MAAM;AAAA,MACf,UAAU,CAAC,SAAS;AAClB,aAAK,eAAe,IAAI;AAAA,MAC1B;AAAA,IAAA,CACD;AAED,UAAM,SAAS,WAA+B,IAAI;AAClD,UAAM,YAAY,MAAM,SAAS;AAEjC,QAAI,YAAkD;AACtD,QAAI,aAAmD;AAEvD,aAAS,QAAc;AACrB,UAAI,wBAAwB,SAAS;AACrC,UAAI,yBAAyB,UAAU;AACvC,kBAAY;AACZ,mBAAa;AAAA,IACf;AAEA,aAAS,OAAa;AACpB,YAAA;AACA,UAAI,MAAM,WAAY;AACtB,kBAAY,WAAW,MAAM;AAC3B,YAAI,CAAC,MAAM,WAAY,SAAQ,IAAI;AAAA,MACrC,GAAG,MAAM,SAAS;AAAA,IACpB;AAEA,aAAS,OAAa;AACpB,YAAA;AACA,mBAAa,WAAW,MAAM,QAAQ,KAAK,GAAG,MAAM,UAAU;AAAA,IAChE;AAEA;AAAA,MACE,MAAM,MAAM;AAAA,MACZ,CAAC,aAAa;AACZ,YAAI,CAAC,SAAU;AACf,cAAA;AACA,gBAAQ,KAAK;AAAA,MACf;AAAA,IAAA;AAIF,oBAAgB,KAAK;AAGrB,cAAU,MAAM;AACd,YAAA;AACA,cAAQ,KAAK;AAAA,IACf,GAAG,IAAI;AAEP,UAAM,gBAAgB,iBAAA;AAMtB,UAAM,aAAa,SAAS,MAAM,CAAC,CAAC,MAAM,WAAW,CAAC,CAAC,MAAM,OAAO;AAEpE,UAAM,UAAU,SAAS,MAAM,CAAC,MAAM,cAAc,KAAK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AAA,GAAA,EAJA,cAAY,QAAA,SAAO;AAAA,mCAC5B,MAEM;AAAA,oBAFNI,mBAEM,OAAA;AAAA,sBAFA,IAAIJ,MAAA,SAAA;AAAA,sBAAW,MAAK;AAAA,sBAAW,sBAAOA,MAAA,cAAA,CAAc;AAAA,oBAAA;sBACxDK,WAA+C,4BAA/C,MAA+C;AAAA,wBAAvBC,gBAAAC,gBAAA,MAAM,OAAO,GAAA,CAAA;AAAA,sBAAA;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Tooltip.vue_vue_type_script_setup_true_lang-vsFDijcV.js","sources":["../../src/presentation/overlays/tooltip/Tooltip.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { Placement } from '@floating-ui/vue';\n\nexport interface TooltipProps {\n /** The tooltip body. Rich content goes through the `content` slot. */\n readonly content?: string | number;\n\n /** The Floating UI placement. Default `top`. */\n readonly placement?: Placement;\n\n /** The delay before opening on hover, in ms. Default 700. */\n readonly openDelay?: number;\n\n /** The delay before closing on leave, in ms. Default 0. */\n readonly closeDelay?: number;\n\n /** Controlled axes use their canonical Vue model names; each update event requests caller state. */\n readonly open?: boolean;\n\n /** The initial open state when uncontrolled. Default `false`. */\n readonly defaultOpen?: boolean;\n\n /** The disabled mode — suppresses rendering even on hover (e.g. when content is empty). */\n readonly isDisabled?: boolean;\n}\n</script>\n\n<script setup lang=\"ts\">\nimport {\n cloneVNode,\n computed,\n createCommentVNode,\n onBeforeUnmount,\n ref,\n shallowRef,\n useSlots,\n watch,\n type VNode,\n} from 'vue';\nimport { AriaAttribute, resolveElement } from '../../../foundation/dom';\nimport { cn } from '../../../foundation/styles';\nimport { useControlled } from '../../../foundation/state';\nimport { useEscape } from '../../../foundation/shortcuts';\nimport { useId } from '../../../foundation/identifiers';\nimport { useReducedMotion } from '../../../foundation/device';\nimport { AnchoredPositioner, Portal, Presence, renderableChildren } from '../../../foundation/primitives';\n\n/**\n * Renders a hover- or focus-triggered tooltip into a Portal, positioned by Floating UI.\n *\n * Wraps a single default-slot child as the trigger. Default delays mirror the OS pattern (700ms in, 0 out). Escape\n * dismisses without moving focus (WCAG 1.4.13); the trigger is described by the tooltip via `aria-describedby` while\n * open.\n *\n * `inheritAttrs: false` because the component renders a fragment (trigger + portal) — there is no single root for\n * attrs to land on, exactly as in React.\n */\ndefineOptions({ name: 'Tooltip', inheritAttrs: false });\n\ndefineSlots<{\n /** The single child element — the trigger. Receives the handlers, the ref, and `aria-describedby`. */\n default(): unknown;\n /** The rich override for the `content` prop. */\n content?(): unknown;\n}>();\n\nconst props = withDefaults(defineProps<TooltipProps>(), {\n content: undefined,\n placement: 'top',\n openDelay: 700,\n closeDelay: 0,\n open: undefined,\n defaultOpen: false,\n isDisabled: undefined,\n});\n\nconst emit = defineEmits<{\n /** Fires when the tooltip shows or hides — the `v-model:open` half. */\n 'update:open': [open: boolean];\n}>();\n\nconst slots = useSlots();\n\n/* `useControlled` returns a handle, not React's tuple, and takes `controlled` as a getter so the\n controlled branch tracks the prop. */\nconst { value: open, setValue: setOpen } = useControlled<boolean>({\n controlled: () => props.open,\n default: props.defaultOpen,\n onChange: (next) => {\n emit('update:open', next);\n },\n});\n\nconst anchor = shallowRef<HTMLElement | null>(null);\nconst tooltipId = useId('tooltip');\n\nlet openTimer: ReturnType<typeof setTimeout> | null = null;\nlet closeTimer: ReturnType<typeof setTimeout> | null = null;\n\nfunction clear(): void {\n if (openTimer) clearTimeout(openTimer);\n if (closeTimer) clearTimeout(closeTimer);\n openTimer = null;\n closeTimer = null;\n}\n\nfunction show(): void {\n clear();\n if (props.isDisabled) return;\n openTimer = setTimeout(() => {\n if (!props.isDisabled) setOpen(true);\n }, props.openDelay);\n}\n\nfunction hide(): void {\n clear();\n closeTimer = setTimeout(() => setOpen(false), props.closeDelay);\n}\n\nwatch(\n () => props.isDisabled,\n (disabled) => {\n if (!disabled) return;\n clear();\n setOpen(false);\n },\n);\n\n/* Clear pending timers on unmount. */\nonBeforeUnmount(clear);\n\n/* WCAG 1.4.13 — Escape dismisses immediately, without moving focus. */\nuseEscape(() => {\n clear();\n setOpen(false);\n}, open);\n\nconst reducedMotion = useReducedMotion();\n\n/**\n * React gated on `!!content`; a Vue consumer can supply the body through the `content` slot\n * instead, so either source counts. An empty tooltip still never opens.\n */\nconst hasContent = computed(() => !!props.content || !!slots.content);\n\nconst visible = computed(() => !props.isDisabled && open.value && hasContent.value);\n\n/* Keep the Portal + positioner mounted while the exit animation plays.\n Becomes true with `visible`; cleared on the body's pop-out `animationend`\n (see `onAnimationEnd` below). With reduced motion no exit animation runs,\n so tear the shell down immediately on close. */\nconst mounted = ref(false);\nwatch(\n [visible, reducedMotion],\n ([isVisible, isReduced]) => {\n if (isVisible) mounted.value = true;\n else if (isReduced) mounted.value = false;\n },\n { immediate: true },\n);\n\nfunction onAnimationEnd(): void {\n if (!visible.value) mounted.value = false;\n}\n\n/** A function ref may receive a component's public instance; the positioner needs the DOM node. */\nfunction setAnchor(value: unknown): void {\n anchor.value = resolveElement(value);\n}\n\n/**\n * React cloned the child element to attach the ref, the handlers and `aria-describedby`.\n * `cloneVNode` is the Vue counterpart and merges through `mergeProps`, so a handler the\n * consumer already put on the trigger is chained rather than replaced — the job React's\n * explicit `trigger.props.onPointerEnter?.(e)` forwarding did.\n *\n * Called from the template, never from a `computed`: a vnode `ref` records the instance rendering\n * at creation as its owner. The scheduler refreshes a dirty computed before the render runs, while\n * no instance renders, and production Vue then throws reading the missing owner's `refs`.\n *\n * The listener keys are all-lowercase after `on` (`onPointerenter`, not `onPointerEnter`):\n * Vue hyphenates the remainder to derive the DOM event name, so the React casing would\n * register `pointer-enter` and never fire.\n */\nfunction renderTrigger(): VNode {\n const child = renderableChildren(slots.default?.())[0];\n if (!child) return createCommentVNode('');\n const own = child.props?.[AriaAttribute.DescribedBy] as string | undefined;\n return cloneVNode(\n child,\n {\n ref: setAnchor,\n [AriaAttribute.DescribedBy]: visible.value ? [own, tooltipId].filter(Boolean).join(' ') : own,\n onPointerenter: show,\n onPointerleave: hide,\n onFocus: show,\n onBlur: hide,\n },\n true,\n );\n}\n\nconst contentClasses = cn(\n 'rounded-md bg-inverse px-2.5 py-1.5 text-xs text-inverse-foreground shadow-md',\n 'motion-safe:data-[state=open]:animate-(--animate-pop-in)',\n 'motion-safe:data-[state=closed]:animate-(--animate-pop-out)',\n);\n</script>\n\n<template>\n <component :is=\"renderTrigger()\" />\n <Portal v-if=\"mounted\">\n <!-- Exit animation bubbles up from the body; once the closed-state pop-out ends, tear down\n the Portal shell. Also covers the reduced-motion path, where no animation runs and\n `Presence` has already unmounted the body.\n z-tooltip (100) sits on this positioned root, as Popover and Menu put their layer on theirs: its\n transform makes the stacking context, so a z-index on the body inside never lifts it above a sticky\n bar (z-sticky, 30) or a modal (z-modal, 70). -->\n <AnchoredPositioner\n :anchor=\"anchor\"\n :placement=\"props.placement\"\n :offset=\"6\"\n class=\"z-tooltip\"\n @animationend=\"onAnimationEnd\"\n >\n <!-- `Presence` clones `data-state` (\"open\" | \"closed\") + its tracking ref onto the body,\n which is what gates the pop-in / pop-out keyframes. Motion sits behind `motion-safe:`\n so reduced-motion users get an instant show/hide. -->\n <Presence :is-present=\"visible\">\n <div :id=\"tooltipId\" role=\"tooltip\" :class=\"contentClasses\">\n <slot name=\"content\">{{ props.content }}</slot>\n </div>\n </Presence>\n </AnchoredPositioner>\n </Portal>\n</template>\n"],"names":["_openBlock","_createBlock","_resolveDynamicComponent","_unref","Portal","_createVNode","AnchoredPositioner","_createElementVNode","_renderSlot","_createTextVNode","_toDisplayString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,UAAM,QAAQ;AAUd,UAAM,OAAO;AAKb,UAAM,QAAQ,SAAA;AAId,UAAM,EAAE,OAAO,MAAM,UAAU,QAAA,IAAY,cAAuB;AAAA,MAChE,YAAY,MAAM,MAAM;AAAA,MACxB,SAAS,MAAM;AAAA,MACf,UAAU,CAAC,SAAS;AAClB,aAAK,eAAe,IAAI;AAAA,MAC1B;AAAA,IAAA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
91
91
  }
92
92
  const HiddenTextareaCss = "position:fixed;top:0;left:0;width:1px;height:1px;padding:0;margin:0;border:none;outline:none;box-shadow:none;background:transparent;opacity:0;pointer-events:none;";
93
+ function mountPoint(active) {
94
+ try {
95
+ const dialog = active?.closest('dialog[open], [role="dialog"], [role="alertdialog"]');
96
+ if (dialog instanceof HTMLElement) return dialog;
97
+ } catch {
98
+ }
99
+ return document.body;
100
+ }
101
+ function saveSelection() {
102
+ try {
103
+ const selection = document.getSelection();
104
+ if (selection === null) return [];
105
+ return Array.from({ length: selection.rangeCount }, (_, index) => selection.getRangeAt(index));
106
+ } catch {
107
+ return [];
108
+ }
109
+ }
110
+ function restoreSelection(ranges) {
111
+ try {
112
+ const selection = document.getSelection();
113
+ if (selection === null) return;
114
+ selection.removeAllRanges();
115
+ for (const range of ranges) selection.addRange(range);
116
+ } catch {
117
+ }
118
+ }
93
119
  function restoreFocus(previous) {
94
120
  try {
95
121
  if (previous === null) return;
@@ -109,21 +135,23 @@ function detach(element) {
109
135
  } catch {
110
136
  }
111
137
  }
112
- function legacyCopyText(text) {
138
+ function legacyCopyText(text, anchor) {
113
139
  if (!canLegacyCopy()) return { ok: false, failure: { status: "unsupported" } };
114
140
  let element;
115
141
  let previouslyFocused = null;
142
+ let previousSelection = [];
116
143
  try {
117
144
  const body = document.body;
118
145
  if (typeof body !== "object" || body === null) return { ok: false, failure: { status: "unsupported" } };
119
146
  previouslyFocused = document.activeElement;
147
+ previousSelection = saveSelection();
120
148
  element = document.createElement("textarea");
121
149
  element.value = text;
122
150
  element.setAttribute(AriaAttribute.Hidden, "true");
123
151
  element.setAttribute("tabindex", "-1");
124
152
  element.setAttribute("readonly", "readonly");
125
153
  element.style.cssText = HiddenTextareaCss;
126
- body.appendChild(element);
154
+ mountPoint(anchor ?? previouslyFocused).appendChild(element);
127
155
  element.focus({ preventScroll: true });
128
156
  element.select();
129
157
  element.setSelectionRange(0, text.length);
@@ -136,6 +164,7 @@ function legacyCopyText(text) {
136
164
  return { ok: false, failure: toClipboardFailure(error) };
137
165
  } finally {
138
166
  if (element !== void 0) detach(element);
167
+ restoreSelection(previousSelection);
139
168
  restoreFocus(previouslyFocused);
140
169
  }
141
170
  }
@@ -143,10 +172,11 @@ function withLegacyFallback(modern, text, options) {
143
172
  if (modern.ok) return modern;
144
173
  if (options?.legacyFallback !== true) return modern;
145
174
  if (text === void 0) return modern;
146
- const legacy = legacyCopyText(text);
175
+ const legacy = legacyCopyText(text, options.anchor);
147
176
  if (legacy.ok) return legacy;
148
177
  return modern.failure.status === "unsupported" ? legacy : modern;
149
178
  }
179
+ const UnsupportedWrite = { ok: false, failure: { status: "unsupported" } };
150
180
  async function writeTextThroughApi(text) {
151
181
  const writeText = clipboardMethod("writeText");
152
182
  if (writeText === void 0) return { ok: false, failure: { status: "unsupported" } };
@@ -165,13 +195,17 @@ async function copyText(text, options) {
165
195
  options?.onError
166
196
  );
167
197
  }
168
- const result = withLegacyFallback(await writeTextThroughApi(text), text, options);
198
+ const modern = canCopy() ? await writeTextThroughApi(text) : UnsupportedWrite;
199
+ const result = withLegacyFallback(modern, text, options);
169
200
  return reportClipboardOutcome(result, options?.onError);
170
201
  } catch (error) {
171
202
  return reportClipboardOutcome({ ok: false, failure: toClipboardFailure(error) }, options?.onError);
172
203
  }
173
204
  }
174
- function useClipboard({ resetAfter = 2e3 } = {}) {
205
+ function useClipboard({
206
+ resetAfter = 2e3,
207
+ legacyFallback = true
208
+ } = {}) {
175
209
  const copied = shallowRef(false);
176
210
  const error = shallowRef(null);
177
211
  let timeout = null;
@@ -184,27 +218,29 @@ function useClipboard({ resetAfter = 2e3 } = {}) {
184
218
  copied.value = false;
185
219
  error.value = null;
186
220
  };
187
- const copy = async (text) => {
221
+ const settleAfter = (window) => {
222
+ if (window <= 0) return;
223
+ if (timeout) clearTimeout(timeout);
224
+ timeout = setTimeout(() => {
225
+ timeout = null;
226
+ copied.value = false;
227
+ error.value = null;
228
+ }, window);
229
+ };
230
+ const copy = async (text, anchor) => {
188
231
  const operation = ++generation;
189
232
  if (timeout) clearTimeout(timeout);
190
233
  timeout = null;
191
- const result = await copyText(text);
234
+ const result = await copyText(text, { legacyFallback, anchor });
192
235
  if (disposed || operation !== generation) return result;
193
236
  if (result.ok) {
194
237
  error.value = null;
195
238
  copied.value = true;
196
- const resetWindow = toValue(resetAfter);
197
- if (resetWindow > 0) {
198
- if (timeout) clearTimeout(timeout);
199
- timeout = setTimeout(() => {
200
- timeout = null;
201
- copied.value = false;
202
- }, resetWindow);
203
- }
204
239
  } else {
205
240
  copied.value = false;
206
241
  error.value = result.failure.status === "unsupported" ? new Error("Clipboard is unavailable.") : result.failure.error;
207
242
  }
243
+ settleAfter(toValue(resetAfter));
208
244
  return result;
209
245
  };
210
246
  onScopeDispose(() => {
@@ -227,4 +263,4 @@ export {
227
263
  useClipboard as u,
228
264
  withLegacyFallback as w
229
265
  };
230
- //# sourceMappingURL=UseClipboard-x6nEdQ9f.js.map
266
+ //# sourceMappingURL=UseClipboard-D5jEv39w.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseClipboard-D5jEv39w.js","sources":["../../src/foundation/clipboard/ClipboardResult.ts","../../src/foundation/clipboard/ClipboardSupport.ts","../../src/foundation/clipboard/LegacyCopy.ts","../../src/foundation/clipboard/CopyText.ts","../../src/foundation/clipboard/hooks/UseClipboard.ts"],"sourcesContent":["import type { ClipboardFailure } from './models/ClipboardFailure';\nimport type { Result } from '../results';\n\nimport { toError } from '../errors';\nexport type { ClipboardFailure } from './models/ClipboardFailure';\nexport type { ClipboardWriteResult } from './models/ClipboardWriteResult';\n\n/** The `status` discriminant of a {@link ClipboardWriteResult} — for a consumer's own switch or status→copy map. */\nexport type ClipboardWriteStatus = 'copied' | ClipboardFailure['status'];\n\n/** One MIME-typed payload read off the system clipboard. */\nexport interface ClipboardReadItem {\n /** The MIME type the platform reported — `text/plain`, `text/html`, `image/png`, … */\n readonly type: string;\n\n /** The payload itself. Read it with `blob.text()` for textual types, or hand it to `URL.createObjectURL`. */\n readonly blob: Blob;\n}\nexport type { ClipboardReadTextResult } from './models/ClipboardReadTextResult';\nexport type { ClipboardReadItemsResult } from './models/ClipboardReadItemsResult';\n\n/** The `status` discriminant shared by both read results. */\nexport type ClipboardReadStatus = 'read' | ClipboardFailure['status'];\n\n/** Tunes a clipboard read. */\nexport interface ClipboardReadOptions {\n /**\n * Called with the normalized error on a `denied` or `failed` result — the seam for a toast or telemetry hook.\n * Never called for `unsupported`, which is a capability fact rather than a failure. A throw from this callback\n * is swallowed. Called at most once per operation, on the final result.\n */\n readonly onError?: (error: Error) => void;\n}\n\n/** Tunes a clipboard write. */\nexport interface ClipboardCopyOptions extends ClipboardReadOptions {\n /**\n * Whether a write the Clipboard API cannot complete retries through the deprecated\n * `document.execCommand('copy')` path. Defaults to `false`.\n *\n * Opt in for reach — older Safari and any non-secure context have no `navigator.clipboard` at all, and\n * `execCommand` is the only write available there. Leave it off to stay on standards-track APIs only. See\n * `LegacyCopy.ts` for the deprecation caveats and for exactly when the retry runs.\n */\n readonly legacyFallback?: boolean;\n\n /**\n * The element the copy was triggered from, usually the clicked button. The legacy path mounts its temporary\n * textarea inside this element's open dialog, so a modal's focus trap cannot steal the selection. Needed\n * because Safari does not focus a clicked button, leaving `document.activeElement` on the body. Defaults to the\n * focused element.\n */\n readonly anchor?: Element | null;\n}\n\n/** The shape every result family shares, so one reporter can serve every entry point. */\ntype ClipboardOutcome = Result<unknown, ClipboardFailure>;\n\n/** Reads a caught value's `name` as a string. Guarded, so a throwing getter reads as absent. */\nfunction nameOf(value: unknown): string | undefined {\n try {\n if (typeof value !== 'object' || value === null) return undefined;\n const name: unknown = (value as { name?: unknown }).name;\n return typeof name === 'string' ? name : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Checks whether a caught value is the platform refusing rather than breaking — the split behind `denied`.\n * Exported for the sibling modules; absent from the barrel, where the statuses are the answer callers want.\n *\n * @param value The caught value.\n */\nexport function isPermissionRefusal(value: unknown): boolean {\n const name = nameOf(value);\n return name === 'NotAllowedError' || name === 'SecurityError';\n}\n\n/**\n * Turns a caught value into the `denied` or `failed` arm it belongs in. Serves reads and writes alike — the\n * returned {@link ClipboardFailure} is assignable to every result union in the slice. Exported for the sibling\n * modules; absent from the barrel. Never throws: `toError` is total.\n *\n * @param error The caught value.\n */\nexport function toClipboardFailure(error: unknown): ClipboardFailure {\n const failure = toError(error);\n return isPermissionRefusal(error) ? { status: 'denied', error: failure } : { status: 'failed', error: failure };\n}\n\n/**\n * Hands a consumer's callback the failure carried by `result`, absorbing a throw from the callback itself. A\n * reporter that throws must not convert a typed result into an unhandled rejection.\n *\n * Called once per entry point, on the FINAL result — so a write that degrades through the legacy fallback\n * reports the outcome the caller receives, not each intermediate attempt. Exported for the sibling modules;\n * absent from the barrel.\n *\n * @param result The outcome about to be returned.\n * @param onError The consumer's reporter, if they supplied one.\n * @returns `result`, unchanged — so a call site can `return reportClipboardOutcome(...)`.\n */\nexport function reportClipboardOutcome<TResult extends ClipboardOutcome>(\n result: TResult,\n onError: ((error: Error) => void) | undefined,\n): TResult {\n if (onError === undefined) return result;\n if (result.ok || !('error' in result.failure)) return result;\n\n try {\n onError(result.failure.error);\n } catch {\n // The consumer's own reporter failed. There is nothing useful left to do with that — the result still\n // reaches the caller, which is the guarantee that matters.\n }\n return result;\n}\n","/** The `ClipboardItem` constructor, narrowed to the one overload this slice calls. */\nexport type ClipboardItemConstructor = new (items: Record<string, Blob>) => ClipboardItem;\n\n/** Reads a member off an object, guarded — a throwing getter reads as `undefined`. */\nfunction member(source: object, key: string): unknown {\n try {\n return (source as Record<string, unknown>)[key];\n } catch {\n return undefined;\n }\n}\n\n/**\n * Reads `navigator.clipboard` if it is there and usable. Guarded end-to-end; returns `undefined` under SSR.\n * Exported for the sibling modules; absent from the barrel.\n */\nexport function clipboardApi(): Clipboard | undefined {\n try {\n if (typeof navigator === 'undefined') return undefined;\n const clipboard = member(navigator, 'clipboard');\n if (typeof clipboard !== 'object' || clipboard === null) return undefined;\n return clipboard as Clipboard;\n } catch {\n return undefined;\n }\n}\n\n/** The Clipboard API methods this slice calls. */\nexport const ClipboardMethodName = {\n /** Names `clipboard.writeText` — the plain-text write, implemented in every engine with a clipboard. */\n WriteText: 'writeText',\n\n /** Names `clipboard.write` — the `ClipboardItem` write, for images and multi-flavour payloads. */\n Write: 'write',\n\n /** Names `clipboard.readText` — the plain-text read. */\n ReadText: 'readText',\n\n /** Names `clipboard.read` — the `ClipboardItem` read. */\n Read: 'read',\n} as const;\n\n/** The Clipboard API methods this slice calls. */\nexport type ClipboardMethodName = (typeof ClipboardMethodName)[keyof typeof ClipboardMethodName];\n\n/**\n * Resolves one of the Clipboard API's methods, bound to the clipboard object, or `undefined` when this engine\n * does not implement it. The single gate every operation passes through. Exported for the sibling modules;\n * absent from the barrel.\n *\n * Bound rather than returned bare: a caller invoking a detached `writeText` would lose its receiver and get a\n * `TypeError` (\"Illegal invocation\") from the real implementation.\n *\n * @param name The method to resolve — `writeText`, `write`, `readText`, or `read`.\n */\nexport function clipboardMethod<TName extends ClipboardMethodName>(name: TName): Clipboard[TName] | undefined {\n const clipboard = clipboardApi();\n if (clipboard === undefined) return undefined;\n\n const method = member(clipboard, name);\n if (typeof method !== 'function') return undefined;\n\n try {\n return (method as (...args: unknown[]) => unknown).bind(clipboard) as Clipboard[TName];\n } catch {\n return undefined;\n }\n}\n\n/**\n * Reads the `ClipboardItem` constructor, which multi-format writes need and which Node and older Safari lack.\n * Exported for the sibling modules; absent from the barrel.\n */\nexport function clipboardItemConstructor(): ClipboardItemConstructor | undefined {\n try {\n const constructor = member(globalThis, 'ClipboardItem');\n if (typeof constructor !== 'function') return undefined;\n return constructor as ClipboardItemConstructor;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Whether plain-text copying is available — `navigator.clipboard.writeText`.\n *\n * `false` under SSR, in a non-secure context, and on engines predating the Clipboard API. It does NOT predict\n * the permission: a copy can still come back `denied` if the call has no user gesture behind it. Treat it as\n * \"is the road there\", not \"will the trip succeed\".\n */\nexport function canCopy(): boolean {\n return clipboardMethod(ClipboardMethodName.WriteText) !== undefined;\n}\n\n/**\n * Whether multi-format copying is available — `navigator.clipboard.write` plus a `ClipboardItem` constructor.\n * Strictly narrower than {@link canCopy}: every engine shipped `writeText` first.\n */\nexport function canCopyItems(): boolean {\n return clipboardMethod(ClipboardMethodName.Write) !== undefined && clipboardItemConstructor() !== undefined;\n}\n\n/**\n * Whether reading from the clipboard is available — `navigator.clipboard.readText`.\n *\n * Returns `false` when the method is absent, including under SSR. Even where present,\n * reading remains subject to browser permission and user-activation requirements. If all you need is the payload the\n * user just pasted, do not read at all — handle the `paste` event with `getPasteItems`, which needs no\n * permission and no prompt.\n */\nexport function canReadClipboard(): boolean {\n return clipboardMethod(ClipboardMethodName.ReadText) !== undefined;\n}\n\n/**\n * Whether the deprecated `document.execCommand('copy')` path is available — the only write that exists in a\n * non-secure context or on older Safari. Requires a document; `false` under SSR.\n *\n * A `true` here does not mean the copy will succeed: `execCommand` still requires the call to sit inside a user\n * gesture, and reports its own refusal by returning `false`.\n */\nexport function canLegacyCopy(): boolean {\n try {\n if (typeof document === 'undefined') return false;\n return typeof member(document, 'execCommand') === 'function';\n } catch {\n return false;\n }\n}\n","import { AriaAttribute } from '../dom';\nimport { toClipboardFailure, type ClipboardCopyOptions, type ClipboardWriteResult } from './ClipboardResult';\nimport { canLegacyCopy } from './ClipboardSupport';\n\n/** Off-screen but laid out — selection requires a rendered element, so `display: none` would copy nothing. */\nconst HiddenTextareaCss =\n 'position:fixed;top:0;left:0;width:1px;height:1px;padding:0;margin:0;border:none;outline:none;box-shadow:none;background:transparent;opacity:0;pointer-events:none;';\n\n/**\n * The element the temporary textarea mounts in: the trigger's (else the focused element's) open dialog when there is\n * one, else the body.\n * A modal's focus trap pulls focus back from anything mounted outside it, which would empty the selection before\n * `execCommand` reads it — so inside a dialog the textarea has to live there too.\n */\nfunction mountPoint(active: Element | null): HTMLElement {\n try {\n const dialog = active?.closest('dialog[open], [role=\"dialog\"], [role=\"alertdialog\"]');\n if (dialog instanceof HTMLElement) return dialog;\n } catch {\n // `closest` is missing on a stand-in, or the selector is refused. The body is always a valid mount point.\n }\n return document.body;\n}\n\n/** Captures the user's current selection ranges so the copy does not clobber them. Never throws. */\nfunction saveSelection(): Range[] {\n try {\n const selection = document.getSelection();\n if (selection === null) return [];\n return Array.from({ length: selection.rangeCount }, (_, index) => selection.getRangeAt(index));\n } catch {\n return [];\n }\n}\n\n/** Puts the captured ranges back. Guarded — the nodes they held may be gone. */\nfunction restoreSelection(ranges: readonly Range[]): void {\n try {\n const selection = document.getSelection();\n if (selection === null) return;\n selection.removeAllRanges();\n for (const range of ranges) selection.addRange(range);\n } catch {\n // The selection is cosmetic next to a completed copy.\n }\n}\n\n/** Restores focus to whatever held it before the textarea took it. Guarded — a stand-in may have no `focus`. */\nfunction restoreFocus(previous: Element | null): void {\n try {\n if (previous === null) return;\n const focus = (previous as { focus?: unknown }).focus;\n if (typeof focus !== 'function') return;\n (previous as HTMLElement).focus({ preventScroll: true });\n } catch {\n // The previously focused element is gone or refuses focus. Not worth failing a completed copy over.\n }\n}\n\n/** Detaches the temporary textarea, preferring `remove()` and falling back to the parent. Never throws. */\nfunction detach(element: HTMLTextAreaElement): void {\n try {\n if (typeof element.remove === 'function') {\n element.remove();\n return;\n }\n element.parentNode?.removeChild(element);\n } catch {\n // Nothing further to try. The failure to detach must not mask the copy's own result.\n }\n}\n\n/**\n * Copies `text` through the deprecated `document.execCommand('copy')` path.\n *\n * Synchronous, unlike every other write in this slice — `execCommand` is. Requires a user gesture: outside one\n * the command reports its own refusal by returning `false`, which surfaces here as `failed` (the legacy API has\n * no way to say \"denied\" specifically). Returns `unsupported` under SSR or where `execCommand` is gone.\n *\n * Exported for the sibling modules and for a consumer that wants the legacy path explicitly; the temporary\n * element is removed on every path, including a throw from `execCommand` itself. It mounts inside the focused\n * element's open dialog, so a modal's focus trap does not empty the selection, and it restores the user's own\n * selection and focus afterwards.\n *\n * Never throws.\n *\n * @param text The text to place on the clipboard.\n * @param anchor The element the copy was triggered from; the textarea mounts in its open dialog. Defaults to the\n * focused element.\n * @deprecated Prefer `copyText`, which uses the Clipboard API and falls back here only on `legacyFallback: true`.\n */\nexport function legacyCopyText(text: string, anchor?: Element | null): ClipboardWriteResult {\n if (!canLegacyCopy()) return { ok: false, failure: { status: 'unsupported' } };\n\n let element: HTMLTextAreaElement | undefined;\n let previouslyFocused: Element | null = null;\n let previousSelection: Range[] = [];\n\n try {\n const body: unknown = document.body;\n if (typeof body !== 'object' || body === null) return { ok: false, failure: { status: 'unsupported' } };\n\n previouslyFocused = document.activeElement;\n previousSelection = saveSelection();\n\n element = document.createElement('textarea');\n element.value = text;\n element.setAttribute(AriaAttribute.Hidden, 'true');\n element.setAttribute('tabindex', '-1');\n element.setAttribute('readonly', 'readonly');\n element.style.cssText = HiddenTextareaCss;\n\n mountPoint(anchor ?? previouslyFocused).appendChild(element);\n\n element.focus({ preventScroll: true });\n element.select();\n element.setSelectionRange(0, text.length);\n\n const copied = document.execCommand('copy');\n return copied\n ? { ok: true, value: undefined }\n : {\n ok: false,\n failure: { status: 'failed', error: new Error('document.execCommand(\"copy\") reported failure.') },\n };\n } catch (error) {\n return { ok: false, failure: toClipboardFailure(error) };\n } finally {\n if (element !== undefined) detach(element);\n restoreSelection(previousSelection);\n restoreFocus(previouslyFocused);\n }\n}\n\n/**\n * Retries a write that the Clipboard API could not complete through the legacy path, when the caller opted in.\n *\n * The retry runs whenever `modern` is not `copied` — not only on `unsupported`. A `denied` from\n * `navigator.clipboard` is exactly the case `execCommand` can still serve: the legacy command is gated on the\n * user gesture the call already sits in, not on the Clipboard API's permission.\n *\n * Which result wins:\n * - the legacy attempt, when it copied — a success outranks any diagnosis;\n * - otherwise `modern`, when the Clipboard API was actually present (its `denied` / `failed` is the more\n * specific account of what went wrong);\n * - otherwise the legacy attempt's own result — with no Clipboard API at all, `modern` is a bare `unsupported`\n * and the legacy failure says more.\n *\n * Exported for the sibling write modules; absent from the barrel. Never throws.\n *\n * @param modern The result the Clipboard API path produced.\n * @param text The plain-text payload, or `undefined` when the write has no text arm to degrade to.\n * @param options The caller's options — the retry runs only on `legacyFallback: true`.\n */\nexport function withLegacyFallback(\n modern: ClipboardWriteResult,\n text: string | undefined,\n options: ClipboardCopyOptions | undefined,\n): ClipboardWriteResult {\n if (modern.ok) return modern;\n if (options?.legacyFallback !== true) return modern;\n if (text === undefined) return modern;\n\n const legacy = legacyCopyText(text, options.anchor);\n if (legacy.ok) return legacy;\n return modern.failure.status === 'unsupported' ? legacy : modern;\n}\n","import {\n reportClipboardOutcome,\n toClipboardFailure,\n type ClipboardCopyOptions,\n type ClipboardWriteResult,\n} from './ClipboardResult';\nimport { canCopy, clipboardMethod } from './ClipboardSupport';\nimport { withLegacyFallback } from './LegacyCopy';\n\n/** The write outcome when the engine has no Clipboard API to try. */\nconst UnsupportedWrite: ClipboardWriteResult = { ok: false, failure: { status: 'unsupported' } };\n\n/** Runs the Clipboard API write, mapping every outcome onto the result union. Never throws. */\nasync function writeTextThroughApi(text: string): Promise<ClipboardWriteResult> {\n const writeText = clipboardMethod('writeText');\n if (writeText === undefined) return { ok: false, failure: { status: 'unsupported' } };\n\n try {\n await writeText(text);\n return { ok: true, value: undefined };\n } catch (error) {\n return { ok: false, failure: toClipboardFailure(error) };\n }\n}\n\n/**\n * Writes `text` to the system clipboard.\n *\n * Call it from a user gesture: browsers require transient activation for a clipboard write, and without one the\n * platform refuses — which surfaces as `denied`, not `unsupported`, since the API was in fact present.\n *\n * Resolves to `unsupported` under SSR, in a non-secure context, and on engines with no Clipboard API. Pass\n * `legacyFallback: true` to retry those through the deprecated `document.execCommand` path.\n *\n * Never throws, never rejects.\n *\n * @param text The text to place on the clipboard. An empty string is a valid payload — it clears the clipboard.\n * @param options Error reporting and the legacy-fallback opt-in.\n */\nexport async function copyText(text: string, options?: ClipboardCopyOptions): Promise<ClipboardWriteResult> {\n try {\n if (typeof text !== 'string') {\n return reportClipboardOutcome(\n { ok: false, failure: { status: 'failed', error: new TypeError('copyText expects a string.') } } as const,\n options?.onError,\n );\n }\n\n // With no Clipboard API there is nothing to await: the legacy copy runs in the same tick as the click, which\n // is the only window older Safari and a non-secure context grant it.\n const modern = canCopy() ? await writeTextThroughApi(text) : UnsupportedWrite;\n const result = withLegacyFallback(modern, text, options);\n return reportClipboardOutcome(result, options?.onError);\n } catch (error) {\n // Unreachable by design — every helper above is itself total. Kept so a future edit to one of them cannot\n // turn this entry point into a rejecting promise.\n return reportClipboardOutcome({ ok: false, failure: toClipboardFailure(error) }, options?.onError);\n }\n}\n","import { onScopeDispose, shallowRef, toValue, type MaybeRefOrGetter, type ShallowRef } from 'vue';\nimport { copyText } from '../CopyText';\nimport type { ClipboardWriteResult } from '../ClipboardResult';\n\nexport interface UseClipboardOptions {\n /** Reset `copied` and `error` after this many ms. Default 2000. Set 0 to keep state until explicitly reset. */\n resetAfter?: MaybeRefOrGetter<number>;\n\n /**\n * Whether a write the Clipboard API cannot complete retries through the legacy `document.execCommand('copy')`\n * path. Default `true`: a copy button that does nothing in a non-secure context, an embedded webview or a\n * browser that refuses the write is worse than the deprecated path. Pass `false` to stay on the standard API.\n */\n legacyFallback?: boolean;\n}\n\nexport interface ClipboardControls {\n /** True for `resetAfter` ms after a successful copy. */\n copied: Readonly<ShallowRef<boolean>>;\n\n /** The last failed copy's error, held for the `resetAfter` window (or until the next copy or `reset`). */\n error: Readonly<ShallowRef<Error | null>>;\n\n /**\n * Writes text and returns the completed success or failure to the caller. Pass the element that triggered the\n * copy as `anchor` so the legacy fallback stays inside that element's dialog.\n */\n copy: (text: string, anchor?: Element | null) => Promise<ClipboardWriteResult>;\n\n /** Force-clear the `copied` flag. */\n reset: () => void;\n}\n\n/**\n * Wraps `navigator.clipboard.writeText` with transient `copied` and `error` flags for\n * post-action UI (icon swap, \"Copied!\" tooltip, failure state). The write falls back to\n * `document.execCommand('copy')` when the Clipboard API is missing or refuses it. Pass\n * `resetAfter: 0` to keep the state until you call `reset()`.\n *\n * `resetAfter` may be a ref or getter; it is read at copy time, so a window\n * changed between copies takes effect on the next one.\n */\nexport function useClipboard({\n resetAfter = 2000,\n legacyFallback = true,\n}: UseClipboardOptions = {}): ClipboardControls {\n const copied = shallowRef(false);\n const error = shallowRef<Error | null>(null);\n let timeout: ReturnType<typeof setTimeout> | null = null;\n let generation = 0;\n let disposed = false;\n\n const reset = (): void => {\n generation++;\n if (timeout) clearTimeout(timeout);\n timeout = null;\n copied.value = false;\n error.value = null;\n };\n\n /** Clears the state once the window passes; a window of 0 holds it. */\n const settleAfter = (window: number): void => {\n if (window <= 0) return;\n if (timeout) clearTimeout(timeout);\n timeout = setTimeout(() => {\n timeout = null;\n copied.value = false;\n error.value = null;\n }, window);\n };\n\n const copy = async (text: string, anchor?: Element | null): Promise<ClipboardWriteResult> => {\n const operation = ++generation;\n if (timeout) clearTimeout(timeout);\n timeout = null;\n const result = await copyText(text, { legacyFallback, anchor });\n if (disposed || operation !== generation) return result;\n if (result.ok) {\n error.value = null;\n copied.value = true;\n } else {\n copied.value = false;\n error.value =\n result.failure.status === 'unsupported' ? new Error('Clipboard is unavailable.') : result.failure.error;\n }\n settleAfter(toValue(resetAfter));\n return result;\n };\n\n onScopeDispose(() => {\n disposed = true;\n if (timeout) clearTimeout(timeout);\n });\n\n return { copied, error, copy, reset };\n}\n"],"names":[],"mappings":";;;AA2DA,SAAS,OAAO,OAAoC;AAClD,MAAI;AACF,QAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;AACxD,UAAM,OAAiB,MAA6B;AACpD,WAAO,OAAO,SAAS,WAAW,OAAO;AAAA,EAC3C,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAQO,SAAS,oBAAoB,OAAyB;AAC3D,QAAM,OAAO,OAAO,KAAK;AACzB,SAAO,SAAS,qBAAqB,SAAS;AAChD;AASO,SAAS,mBAAmB,OAAkC;AACnE,QAAM,UAAU,QAAQ,KAAK;AAC7B,SAAO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ACjC,cAAU;AACV,WAAO,QAAQ;AACf,UAAM,QAAQ;AAAA,EAChB;AAGA,QAAM,cAAc,CAAC,WAAyB;AAC5C,QAAI,UAAU,EAAG;AACjB,QAAI,sBAAsB,OAAO;AACjC,cAAU,WAAW,MAAM;AACzB,gBAAU;AACV,aAAO,QAAQ;AACf,YAAM,QAAQ;AAAA,IAChB,GAAG,MAAM;AAAA,EACX;AAEA,QAAM,OAAO,OAAO,MAAc,WAA2D;AAC3F,UAAM,YAAY,EAAE;AACpB,QAAI,sBAAsB,OAAO;AACjC,cAAU;AACV,UAAM,SAAS,MAAM,SAAS,MAAM,EAAE,gBAAgB,QAAQ;AAC9D,QAAI,YAAY,cAAc,WAAY,QAAO;AACjD,QAAI,OAAO,IAAI;AACb,YAAM,QAAQ;AACd,aAAO,QAAQ;AAAA,IACjB,OAAO;AACL,aAAO,QAAQ;AACf,YAAM,QACJ,OAAO,QAAQ,WAAW,gBAAgB,IAAI,MAAM,2BAA2B,IAAI,OAAO,QAAQ;AAAA,IACtG;AACA,gBAAY,QAAQ,UAAU,CAAC;AAC/B,WAAO;AAAA,EACT;AAEA,iBAAe,MAAM;AACnB,eAAW;AACX,QAAI,sBAAsB,OAAO;AAAA,EACnC,CAAC;AAED,SAAO,EAAE,QAAQ,OAAO,MAAM,MAAA;AAChC;"}
@@ -35,6 +35,13 @@ export interface ClipboardCopyOptions extends ClipboardReadOptions {
35
35
  * `LegacyCopy.ts` for the deprecation caveats and for exactly when the retry runs.
36
36
  */
37
37
  readonly legacyFallback?: boolean;
38
+ /**
39
+ * The element the copy was triggered from, usually the clicked button. The legacy path mounts its temporary
40
+ * textarea inside this element's open dialog, so a modal's focus trap cannot steal the selection. Needed
41
+ * because Safari does not focus a clicked button, leaving `document.activeElement` on the body. Defaults to the
42
+ * focused element.
43
+ */
44
+ readonly anchor?: Element | null;
38
45
  }
39
46
  /** The shape every result family shares, so one reporter can serve every entry point. */
40
47
  type ClipboardOutcome = Result<unknown, ClipboardFailure>;
@@ -7,14 +7,18 @@ import { ClipboardCopyOptions, ClipboardWriteResult } from './ClipboardResult';
7
7
  * no way to say "denied" specifically). Returns `unsupported` under SSR or where `execCommand` is gone.
8
8
  *
9
9
  * Exported for the sibling modules and for a consumer that wants the legacy path explicitly; the temporary
10
- * element is removed on every path, including a throw from `execCommand` itself.
10
+ * element is removed on every path, including a throw from `execCommand` itself. It mounts inside the focused
11
+ * element's open dialog, so a modal's focus trap does not empty the selection, and it restores the user's own
12
+ * selection and focus afterwards.
11
13
  *
12
14
  * Never throws.
13
15
  *
14
16
  * @param text The text to place on the clipboard.
17
+ * @param anchor The element the copy was triggered from; the textarea mounts in its open dialog. Defaults to the
18
+ * focused element.
15
19
  * @deprecated Prefer `copyText`, which uses the Clipboard API and falls back here only on `legacyFallback: true`.
16
20
  */
17
- export declare function legacyCopyText(text: string): ClipboardWriteResult;
21
+ export declare function legacyCopyText(text: string, anchor?: Element | null): ClipboardWriteResult;
18
22
  /**
19
23
  * Retries a write that the Clipboard API could not complete through the legacy path, when the caller opted in.
20
24
  *
@@ -1,25 +1,35 @@
1
1
  import { MaybeRefOrGetter, ShallowRef } from 'vue';
2
2
  import { ClipboardWriteResult } from '../ClipboardResult';
3
3
  export interface UseClipboardOptions {
4
- /** Reset `copied` back to false after this many ms. Default 2000. Set 0 to keep state until explicitly reset. */
4
+ /** Reset `copied` and `error` after this many ms. Default 2000. Set 0 to keep state until explicitly reset. */
5
5
  resetAfter?: MaybeRefOrGetter<number>;
6
+ /**
7
+ * Whether a write the Clipboard API cannot complete retries through the legacy `document.execCommand('copy')`
8
+ * path. Default `true`: a copy button that does nothing in a non-secure context, an embedded webview or a
9
+ * browser that refuses the write is worse than the deprecated path. Pass `false` to stay on the standard API.
10
+ */
11
+ legacyFallback?: boolean;
6
12
  }
7
13
  export interface ClipboardControls {
8
14
  /** True for `resetAfter` ms after a successful copy. */
9
15
  copied: Readonly<ShallowRef<boolean>>;
10
- /** Last error from `navigator.clipboard.writeText`, if any. */
16
+ /** The last failed copy's error, held for the `resetAfter` window (or until the next copy or `reset`). */
11
17
  error: Readonly<ShallowRef<Error | null>>;
12
- /** Writes text and returns the completed success or failure to the caller. */
13
- copy: (text: string) => Promise<ClipboardWriteResult>;
18
+ /**
19
+ * Writes text and returns the completed success or failure to the caller. Pass the element that triggered the
20
+ * copy as `anchor` so the legacy fallback stays inside that element's dialog.
21
+ */
22
+ copy: (text: string, anchor?: Element | null) => Promise<ClipboardWriteResult>;
14
23
  /** Force-clear the `copied` flag. */
15
24
  reset: () => void;
16
25
  }
17
26
  /**
18
- * Wraps `navigator.clipboard.writeText` with a transient `copied` flag for
19
- * post-action UI (icon swap, "Copied!" tooltip). Pass `resetAfter: 0` to
20
- * keep `copied` true until you call `reset()`.
27
+ * Wraps `navigator.clipboard.writeText` with transient `copied` and `error` flags for
28
+ * post-action UI (icon swap, "Copied!" tooltip, failure state). The write falls back to
29
+ * `document.execCommand('copy')` when the Clipboard API is missing or refuses it. Pass
30
+ * `resetAfter: 0` to keep the state until you call `reset()`.
21
31
  *
22
32
  * `resetAfter` may be a ref or getter; it is read at copy time, so a window
23
33
  * changed between copies takes effect on the next one.
24
34
  */
25
- export declare function useClipboard({ resetAfter }?: UseClipboardOptions): ClipboardControls;
35
+ export declare function useClipboard({ resetAfter, legacyFallback, }?: UseClipboardOptions): ClipboardControls;
@@ -1,5 +1,5 @@
1
- import { r as reportClipboardOutcome, t as toClipboardFailure, w as withLegacyFallback, c as clipboardMethod, a as clipboardItemConstructor, b as copyText } from "../../chunks/UseClipboard-x6nEdQ9f.js";
2
- import { d, e, f, g, l, u } from "../../chunks/UseClipboard-x6nEdQ9f.js";
1
+ import { r as reportClipboardOutcome, t as toClipboardFailure, w as withLegacyFallback, c as clipboardMethod, a as clipboardItemConstructor, b as copyText } from "../../chunks/UseClipboard-D5jEv39w.js";
2
+ import { d, e, f, g, l, u } from "../../chunks/UseClipboard-D5jEv39w.js";
3
3
  import { watchPostEffect, toValue, shallowRef, onScopeDispose } from "vue";
4
4
  import { q as queryPermission } from "../../chunks/QueryPermission-24wDTTTP.js";
5
5
  const FallbackMimeType = "application/octet-stream";
package/dist/index.js CHANGED
@@ -9,12 +9,12 @@ import { i as i8 } from "./chunks/index-CuiXILXc.js";
9
9
  import { i as i9 } from "./chunks/index-DA17sNzP.js";
10
10
  import { i as i10 } from "./chunks/index-KL15HQew.js";
11
11
  import { i as i11 } from "./chunks/index-DvwkyLSw.js";
12
- import { _, a, b, c, d, F, e, f, S, g, h, i as i12, j, T, k, l, m, n, o, u, p } from "./chunks/BackToTopButton.vue_vue_type_script_setup_true_lang-dge5C6We.js";
12
+ import { _, a, b, c, d, F, e, f, S, g, h, i as i12, j, T, k, l, m, n, o, u, p } from "./chunks/BackToTopButton.vue_vue_type_script_setup_true_lang-CNMcUYtR.js";
13
13
  import { D, _ as _2, a as a2, b as b2, T as T2, t, u as u2 } from "./chunks/ToastHost.vue_vue_type_script_setup_true_lang-p0bfXJ9l.js";
14
14
  import { A, _ as _3, B, a as a3, b as b3, C, c as c2, d as d2, e as e2, f as f2, g as g2, h as h2, i as i13, j as j2, k as k2, l as l2, m as m2, n as n2, o as o2, p as p2, q, r, s, t as t2, u as u3, v, w, x, y, z, D as D2, E, F as F2, G, H, I, J, K, L, M, N, O, P, Q, R, S as S2, T as T3, U, V, W, X, Y, Z, $, a0, a1, a2 as a22, a3 as a32, a4, a5, a6, a7, a8, a9, aa, ab, a7 as a72, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, an, ao, ap, aq, ar, as, at, au, av, aw, ax, ay, az, aA, aB, aC, aD, aE, aF, aG, aH, aI, aJ, aK, aL, aM, aN, aO, aP, aQ, aR, aS, aT, aU, aV, aW, aX, aY, aZ, a_, a$, b0, b1, b2 as b22, b3 as b32, b4, b5, b6, b7, b8, b9, ba, bb, bc, bd, be, bf, bg, bh, bi, bj, bk, bl, bm, bn, bo, bp, bq, br, bs, bt, bu, bv, bw, bx, by, bz, bA, bB, bC, bD, bE, bF, bG, bH, bI, bJ, bK, bL, bM, bN, bO, bP, bQ, bR, bS, bT, bU, bV, bW, bX, bY, bZ, b_ } from "./chunks/MentionInput.vue_vue_type_script_setup_true_lang-DdT24dkW.js";
15
15
  import { _ as _4 } from "./chunks/PointControl.vue_vue_type_script_setup_true_lang-akWl2-sE.js";
16
16
  import { P as P2, _ as _5 } from "./chunks/TourPopover.vue_vue_type_script_setup_true_lang-BlajHcdp.js";
17
- import { _ as _6, a as a10, b as b10, c as c3, A as A2, d as d3, e as e3, f as f3, g as g3, h as h3, i as i14, j as j3, k as k3, l as l3, m as m3, n as n3, o as o3, p as p3, q as q2, r as r2, s as s2, B as B2, t as t3, u as u4, v as v2, w as w2, x as x2, y as y2, z as z2, C as C2, D as D3, E as E2, F as F3, G as G2, H as H2, I as I2, J as J2, K as K2, L as L2, M as M2, N as N2, O as O2, P as P3, Q as Q2, R as R2, S as S3, T as T4, U as U2, V as V2, W as W2, X as X2, Y as Y2, Z as Z2, $ as $2, a0 as a02, a1 as a12, a2 as a23, a3 as a33, a4 as a42, a5 as a52, a6 as a62, a7 as a73, a8 as a82, a9 as a92, aa as aa2, ab as ab2, ac as ac2, ad as ad2, ae as ae2, af as af2, ag as ag2, ah as ah2, ai as ai2, aj as aj2, ak as ak2, al as al2, am as am2, an as an2, ao as ao2, ap as ap2, aq as aq2, ar as ar2, as as as2, at as at2, au as au2, av as av2, aw as aw2, ax as ax2, ay as ay2, az as az2, aA as aA2, aB as aB2, aC as aC2, aD as aD2, aE as aE2, aF as aF2, aG as aG2, aH as aH2, aI as aI2, aJ as aJ2, aK as aK2, aL as aL2, aM as aM2, aN as aN2, aO as aO2, aP as aP2, aQ as aQ2, aR as aR2, aS as aS2, aT as aT2, aU as aU2, aV as aV2, aW as aW2, aX as aX2, aY as aY2, aZ as aZ2, a_ as a_2, a$ as a$2, b0 as b02, b1 as b12, b2 as b23, b3 as b33, b4 as b42, b5 as b52, b6 as b62, b7 as b72, b8 as b82, b9 as b92, ba as ba2, bb as bb2, bc as bc2, bd as bd2, be as be2, bf as bf2, bg as bg2, bh as bh2, bi as bi2, bj as bj2, bk as bk2, bl as bl2, bm as bm2, bn as bn2, bo as bo2, bp as bp2, bq as bq2, br as br2, bs as bs2, bt as bt2, bu as bu2, bv as bv2, bw as bw2, bx as bx2, by as by2, bz as bz2, bA as bA2, bB as bB2, bC as bC2, bD as bD2, bE as bE2, bF as bF2, bG as bG2, bH as bH2, bI as bI2, bJ as bJ2, bK as bK2, bL as bL2, bM as bM2, bN as bN2, bO as bO2, bP as bP2, bQ as bQ2, bR as bR2, bS as bS2, bT as bT2 } from "./chunks/KanbanCard.vue_vue_type_script_setup_true_lang-BolubhiV.js";
17
+ import { _ as _6, a as a10, b as b10, c as c3, A as A2, d as d3, e as e3, f as f3, g as g3, h as h3, i as i14, j as j3, k as k3, l as l3, m as m3, n as n3, o as o3, p as p3, q as q2, r as r2, s as s2, B as B2, t as t3, u as u4, v as v2, w as w2, x as x2, y as y2, z as z2, C as C2, D as D3, E as E2, F as F3, G as G2, H as H2, I as I2, J as J2, K as K2, L as L2, M as M2, N as N2, O as O2, P as P3, Q as Q2, R as R2, S as S3, T as T4, U as U2, V as V2, W as W2, X as X2, Y as Y2, Z as Z2, $ as $2, a0 as a02, a1 as a12, a2 as a23, a3 as a33, a4 as a42, a5 as a52, a6 as a62, a7 as a73, a8 as a82, a9 as a92, aa as aa2, ab as ab2, ac as ac2, ad as ad2, ae as ae2, af as af2, ag as ag2, ah as ah2, ai as ai2, aj as aj2, ak as ak2, al as al2, am as am2, an as an2, ao as ao2, ap as ap2, aq as aq2, ar as ar2, as as as2, at as at2, au as au2, av as av2, aw as aw2, ax as ax2, ay as ay2, az as az2, aA as aA2, aB as aB2, aC as aC2, aD as aD2, aE as aE2, aF as aF2, aG as aG2, aH as aH2, aI as aI2, aJ as aJ2, aK as aK2, aL as aL2, aM as aM2, aN as aN2, aO as aO2, aP as aP2, aQ as aQ2, aR as aR2, aS as aS2, aT as aT2, aU as aU2, aV as aV2, aW as aW2, aX as aX2, aY as aY2, aZ as aZ2, a_ as a_2, a$ as a$2, b0 as b02, b1 as b12, b2 as b23, b3 as b33, b4 as b42, b5 as b52, b6 as b62, b7 as b72, b8 as b82, b9 as b92, ba as ba2, bb as bb2, bc as bc2, bd as bd2, be as be2, bf as bf2, bg as bg2, bh as bh2, bi as bi2, bj as bj2, bk as bk2, bl as bl2, bm as bm2, bn as bn2, bo as bo2, bp as bp2, bq as bq2, br as br2, bs as bs2, bt as bt2, bu as bu2, bv as bv2, bw as bw2, bx as bx2, by as by2, bz as bz2, bA as bA2, bB as bB2, bC as bC2, bD as bD2, bE as bE2, bF as bF2, bG as bG2, bH as bH2, bI as bI2, bJ as bJ2, bK as bK2, bL as bL2, bM as bM2, bN as bN2, bO as bO2, bP as bP2, bQ as bQ2, bR as bR2, bS as bS2, bT as bT2 } from "./chunks/KanbanCard.vue_vue_type_script_setup_true_lang-BCnquIre.js";
18
18
  import { _ as _7, a as a11, b as b11, c as c4, d as d4, e as e4, f as f4, c as c5, d as d5, e as e5, f as f5, g as g4, h as h4, i as i15, j as j4, k as k4, l as l4, m as m4, n as n4, o as o4, p as p4, q as q3, r as r3, h as h5, s as s3, t as t4, u as u5, r as r4, h as h6, s as s4, t as t5, v as v3, w as w3, x as x3, y as y3, z as z3, A as A3, r as r5, h as h7, s as s5, t as t6, u as u6, B as B3, C as C3, D as D4, E as E3, F as F4 } from "./chunks/LightboxModal.vue_vue_type_script_setup_true_lang-Dm79L1eK.js";
19
19
  import { _ as _8, a as a13, b as b13, c as c6, d as d6, e as e6, f as f6, D as D5, g as g5, h as h8, i as i16, j as j5, k as k5, l as l5, m as m5, n as n5, o as o5, P as P4, p as p5, q as q4, r as r6, s as s6, t as t7, u as u7, v as v4, w as w4, x as x4, y as y4, z as z4, T as T5, A as A4, B as B4, C as C4, E as E4, F as F5, G as G3, H as H3 } from "./chunks/ErrorBoundary.vue_vue_type_script_setup_true_lang-LRQbVAiW.js";
20
20
  import { _ as _9, A as A5, a as a14, b as b14, c as c7, d as d7, e as e7, f as f7, g as g6, h as h9, i as i17, j as j6, k as k6, l as l6, m as m6, n as n6, o as o6, B as B5, p as p6, C as C5, q as q5, r as r7, s as s7, t as t8, u as u8, v as v5, w as w5, x as x5, F as F6, y as y5, G as G4, z as z5, D as D6, E as E5, H as H4, I as I3, J as J3, N as N3, K as K3, L as L3, M as M3, O as O3, P as P5, Q as Q3, R as R3, S as S4, T as T6, U as U3, V as V3, W as W3, X as X3, Y as Y3, Z as Z3, $ as $3, a0 as a03, a1 as a15, a2 as a24, a3 as a34, a4 as a43, a5 as a53, a6 as a63, a7 as a74, a8 as a83, a9 as a93, aa as aa3, ab as ab3, ac as ac3, ad as ad3, ae as ae3 } from "./chunks/MasonryLayout.vue_vue_type_script_setup_true_lang-TuNWahLw.js";
@@ -35,7 +35,7 @@ import { _ as _26, a as a29, b as b25 } from "./chunks/PopoverContent.vue_vue_ty
35
35
  import { _ as _27, R as R5, t as t11 } from "./chunks/ReportAction.vue_vue_type_script_setup_true_lang-l4DjtcpM.js";
36
36
  import { _ as _28, S as S9, s as s10 } from "./chunks/Spinner.vue_vue_type_script_setup_true_lang-CPor3q8_.js";
37
37
  import { _ as _29, T as T9, a as a30, b as b26, t as t12 } from "./chunks/Text.vue_vue_type_script_setup_true_lang-DjUtnxS2.js";
38
- import { _ as _30 } from "./chunks/Tooltip.vue_vue_type_script_setup_true_lang-AzuqiFWY.js";
38
+ import { _ as _30 } from "./chunks/Tooltip.vue_vue_type_script_setup_true_lang-vsFDijcV.js";
39
39
  import { ImageEditRecipeExtensions } from "./domain/imageEditing/index.js";
40
40
  import { L as L5 } from "./chunks/ListboxPicker.variants-hiMcl66_.js";
41
41
  import { S as S10, a as a31, p as p8, s as s11, b as b27, c as c14, d as d12, e as e11, u as u11, f as f10 } from "./chunks/SkeletonStateContext-tVYMa6xt.js";
@@ -16,6 +16,8 @@ export interface CopyButtonProps extends /* @vue-ignore */ CopyButtonAttributes
16
16
  readonly resetAfter?: number;
17
17
  /** The accessible name to announce while `copied` is true. Falls back to `aria-label` when omitted. */
18
18
  readonly copiedAriaLabel?: string;
19
+ /** The accessible name to announce while the last copy has failed. Falls back to `aria-label` when omitted. */
20
+ readonly failedAriaLabel?: string;
19
21
  /** The visual surface style. Default `ghost`. */
20
22
  readonly variant?: ButtonVariant;
21
23
  }
@@ -27,7 +29,7 @@ declare const _default: __VLS_WithSlots<import('vue').DefineComponent<CopyButton
27
29
  readonly variant: ButtonVariant;
28
30
  readonly resetAfter: number;
29
31
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>, {
30
- /** The content — receives `{ copied, error }` for a state-driven swap. Icon-only Copy/Check when omitted. */
32
+ /** The content — receives `{ copied, error }` for a state-driven swap. Icon-only Copy/Check/X when omitted. */
31
33
  default?: (props: {
32
34
  copied: boolean;
33
35
  error: Error | null;
@@ -1,4 +1,4 @@
1
- import { _, a, b, c, d, F, e, f, S, g, h, i, j, T, k, l, m, n, o, u, p } from "../../chunks/BackToTopButton.vue_vue_type_script_setup_true_lang-dge5C6We.js";
1
+ import { _, a, b, c, d, F, e, f, S, g, h, i, j, T, k, l, m, n, o, u, p } from "../../chunks/BackToTopButton.vue_vue_type_script_setup_true_lang-CNMcUYtR.js";
2
2
  import { _ as _2, B, a as a2, b as b2 } from "../../chunks/Button.vue_vue_type_script_setup_true_lang-BrgCAsgC.js";
3
3
  export {
4
4
  _ as BackToTopButton,
@@ -1,4 +1,4 @@
1
- import { _, a, b, c, A, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, B, t, u, v, w, x, y, z, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, $, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, an, ao, ap, aq, ar, as, at, au, av, aw, ax, ay, az, aA, aB, aC, aD, aE, aF, aG, aH, aI, aJ, aK, aL, aM, aN, aO, aP, aQ, aR, aS, aT, aU, aV, aW, aX, aY, aZ, a_, a$, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, ba, bb, bc, bd, be, bf, bg, bh, bi, bj, bk, bl, bm, bn, bo, bp, bq, br, bs, bt, bu, bv, bw, bx, by, bz, bA, bB, bC, bD, bE, bF, bG, bH, bI, bJ, bK, bL, bM, bN, bO, bP, bQ, bR, bS, bT } from "../../chunks/KanbanCard.vue_vue_type_script_setup_true_lang-BolubhiV.js";
1
+ import { _, a, b, c, A, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, B, t, u, v, w, x, y, z, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, $, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, an, ao, ap, aq, ar, as, at, au, av, aw, ax, ay, az, aA, aB, aC, aD, aE, aF, aG, aH, aI, aJ, aK, aL, aM, aN, aO, aP, aQ, aR, aS, aT, aU, aV, aW, aX, aY, aZ, a_, a$, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, ba, bb, bc, bd, be, bf, bg, bh, bi, bj, bk, bl, bm, bn, bo, bp, bq, br, bs, bt, bu, bv, bw, bx, by, bz, bA, bB, bC, bD, bE, bF, bG, bH, bI, bJ, bK, bL, bM, bN, bO, bP, bQ, bR, bS, bT } from "../../chunks/KanbanCard.vue_vue_type_script_setup_true_lang-BCnquIre.js";
2
2
  import { a as a10, b as b10, c as c2, d as d2, e as e2, f as f2, S as S2, g as g2, T as T2, h as h2, i as i2, j as j2, k as k2, t as t2, u as u2, l as l2 } from "../../chunks/FieldHelperText.vue_vue_type_script_setup_true_lang-eqG5AyoV.js";
3
3
  import { _ as _2, E as E2 } from "../../chunks/EmptyState.vue_vue_type_script_setup_true_lang-DHwwGzyu.js";
4
4
  import { _ as _3, H as H2, a as a11, b as b11, c as c3, S as S3, h as h3 } from "../../chunks/SectionHeading.vue_vue_type_script_setup_true_lang-CaN3iIR_.js";
@@ -4,7 +4,7 @@ import { _ as _3, B as B2 } from "../../chunks/BackdropOverlay.vue_vue_type_scri
4
4
  import { _ as _4, a as a2, b as b2, c as c3, _ as _5, b as b3, _ as _6, a as a3, b as b4, c as c4, M, d as d3, e as e3, _ as _7 } from "../../chunks/OverlayCloseButton.vue_vue_type_script_setup_true_lang-D01KYAAn.js";
5
5
  import { _ as _8, a as a4, D as D2 } from "../../chunks/DrawerContent.vue_vue_type_script_setup_true_lang-CZQnfNGk.js";
6
6
  import { _ as _9, a as a5, b as b5 } from "../../chunks/PopoverContent.vue_vue_type_script_setup_true_lang-BIHYpwzT.js";
7
- import { _ as _10 } from "../../chunks/Tooltip.vue_vue_type_script_setup_true_lang-AzuqiFWY.js";
7
+ import { _ as _10 } from "../../chunks/Tooltip.vue_vue_type_script_setup_true_lang-vsFDijcV.js";
8
8
  export {
9
9
  _2 as ActionSheet,
10
10
  a as ActionSheetAction,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wow-two-beta/fe",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "description": "Beta-forever Vue 3 fe sdk for the wow-two ecosystem — components, application adapters and browser capabilities.",
5
5
  "license": "MIT",
6
6
  "repository": {