@invopop/popui 0.1.58 → 0.1.59

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.
@@ -2,6 +2,7 @@
2
2
  import { Duplicate } from '@invopop/ui-icons'
3
3
  import BaseButton from './BaseButton.svelte'
4
4
  import type { ButtonUuidCopyProps } from './types'
5
+ import { copyToClipboard } from './helpers'
5
6
 
6
7
  let {
7
8
  uuid = '',
@@ -35,7 +36,7 @@
35
36
  data-uuid-copy
36
37
  onclick={async (e) => {
37
38
  e.stopPropagation()
38
- await navigator.clipboard.writeText(uuid)
39
+ await copyToClipboard(uuid)
39
40
  oncopied?.(uuid)
40
41
  }}
41
42
  >
@@ -3,6 +3,7 @@
3
3
  import type { DataListItemProps } from './types'
4
4
  import BaseButton from './BaseButton.svelte'
5
5
  import { Duplicate, ExternalLink } from '@invopop/ui-icons'
6
+ import { copyToClipboard } from './helpers'
6
7
 
7
8
  let {
8
9
  label = '',
@@ -21,11 +22,12 @@
21
22
 
22
23
  let clickAction = $derived(onCopy || onLink)
23
24
 
24
- const handleAreaClick = (e: MouseEvent) => {
25
+ const handleAreaClick = async (e: MouseEvent) => {
25
26
  // Only handle click if not clicking on a button
26
27
  if ((e.target as HTMLElement).closest('button')) return
27
28
 
28
29
  if (onCopy) {
30
+ await copyToClipboard(value)
29
31
  onCopy()
30
32
  } else if (onLink) {
31
33
  onLink()
@@ -46,7 +48,7 @@
46
48
  )}
47
49
  onclick={clickAction ? handleAreaClick : undefined}
48
50
  >
49
- <div class="flex-1 min-w-0">
51
+ <div class="flex-1 min-w-0 h-8">
50
52
  <div class={valueStyles}>
51
53
  {#if children}
52
54
  {@render children()}
@@ -59,7 +61,10 @@
59
61
  <BaseButton
60
62
  variant="outline"
61
63
  icon={Duplicate}
62
- onclick={onCopy}
64
+ onclick={async () => {
65
+ await copyToClipboard(value)
66
+ onCopy()
67
+ }}
63
68
  class="opacity-0 group-hover:opacity-100 transition-opacity"
64
69
  />
65
70
  {/if}
package/dist/helpers.d.ts CHANGED
@@ -11,3 +11,4 @@ export declare function scrollIntoTableView(element: HTMLElement): void;
11
11
  export declare function isInputFocused(): boolean;
12
12
  export declare function toCalendarDate(date: Date): DateValue;
13
13
  export declare function datesFromToday(): DatesFromToday;
14
+ export declare function copyToClipboard(text: string): Promise<void>;
package/dist/helpers.js CHANGED
@@ -120,3 +120,6 @@ export function datesFromToday() {
120
120
  endOfLastQuarter
121
121
  };
122
122
  }
123
+ export async function copyToClipboard(text) {
124
+ await navigator.clipboard.writeText(text);
125
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@invopop/popui",
3
3
  "license": "MIT",
4
- "version": "0.1.58",
4
+ "version": "0.1.59",
5
5
  "repository": {
6
6
  "url": "https://github.com/invopop/popui"
7
7
  },