@invopop/popui 0.1.58 → 0.1.60

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,11 +3,13 @@
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 = '',
9
10
  value = '',
10
11
  monospaced = false,
12
+ vertical = false,
11
13
  children,
12
14
  onCopy,
13
15
  onLink
@@ -21,11 +23,12 @@
21
23
 
22
24
  let clickAction = $derived(onCopy || onLink)
23
25
 
24
- const handleAreaClick = (e: MouseEvent) => {
26
+ const handleAreaClick = async (e: MouseEvent) => {
25
27
  // Only handle click if not clicking on a button
26
28
  if ((e.target as HTMLElement).closest('button')) return
27
29
 
28
30
  if (onCopy) {
31
+ await copyToClipboard(value)
29
32
  onCopy()
30
33
  } else if (onLink) {
31
34
  onLink()
@@ -33,15 +36,25 @@
33
36
  }
34
37
  </script>
35
38
 
36
- <div class="flex gap-6 items-center group">
37
- <div class="text-foreground-default-secondary text-base min-w-[125px]">
39
+ <div
40
+ class={clsx('flex group', {
41
+ 'flex-col gap-1.5': vertical,
42
+ 'gap-6 items-center': !vertical
43
+ })}
44
+ >
45
+ <div
46
+ class={clsx('text-foreground-default-secondary text-base', {
47
+ 'pl-2': vertical,
48
+ 'min-w-[125px]': !vertical
49
+ })}
50
+ >
38
51
  {label}
39
52
  </div>
40
53
  <!-- svelte-ignore a11y_click_events_have_key_events -->
41
54
  <!-- svelte-ignore a11y_no_static_element_interactions -->
42
55
  <div
43
56
  class={clsx(
44
- 'flex flex-1 gap-1 items-center group-hover:bg-background-default-secondary py-1 pl-2 pr-1 rounded-md min-w-0',
57
+ 'flex flex-1 gap-1 items-center group-hover:bg-background-default-secondary py-1 pl-2 pr-1 rounded-md min-w-0 h-8',
45
58
  { 'cursor-pointer': clickAction }
46
59
  )}
47
60
  onclick={clickAction ? handleAreaClick : undefined}
@@ -57,14 +70,19 @@
57
70
  </div>
58
71
  {#if onCopy}
59
72
  <BaseButton
73
+ size="sm"
60
74
  variant="outline"
61
75
  icon={Duplicate}
62
- onclick={onCopy}
76
+ onclick={async () => {
77
+ await copyToClipboard(value)
78
+ onCopy()
79
+ }}
63
80
  class="opacity-0 group-hover:opacity-100 transition-opacity"
64
81
  />
65
82
  {/if}
66
83
  {#if onLink}
67
84
  <BaseButton
85
+ size="sm"
68
86
  variant="outline"
69
87
  icon={ExternalLink}
70
88
  onclick={onLink}
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/dist/types.d.ts CHANGED
@@ -308,7 +308,7 @@ export interface DataListItemProps {
308
308
  label?: string;
309
309
  value?: string;
310
310
  monospaced?: boolean;
311
- fullWidth?: boolean;
311
+ vertical?: boolean;
312
312
  children?: Snippet;
313
313
  onCopy?: () => void;
314
314
  onLink?: () => void;
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.60",
5
5
  "repository": {
6
6
  "url": "https://github.com/invopop/popui"
7
7
  },