@invopop/popui 0.1.67 → 0.1.68
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.
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import BaseButton from './BaseButton.svelte'
|
|
4
4
|
import type { ButtonUuidCopyProps } from './types'
|
|
5
5
|
import { copyToClipboard } from './helpers'
|
|
6
|
+
import { cn } from './utils'
|
|
6
7
|
|
|
7
8
|
let {
|
|
8
9
|
uuid = '',
|
|
@@ -10,21 +11,13 @@
|
|
|
10
11
|
suffixLength = 4,
|
|
11
12
|
full = false,
|
|
12
13
|
disabled = false,
|
|
13
|
-
oncopied
|
|
14
|
+
oncopied,
|
|
15
|
+
class: className
|
|
14
16
|
}: ButtonUuidCopyProps = $props()
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const prefix = inputString.substring(0, prefixLength)
|
|
22
|
-
const suffix = inputString.substring(inputString.length - suffixLength)
|
|
23
|
-
|
|
24
|
-
return prefix + '...' + suffix
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let formattedUuid = $derived(full ? uuid : shortenString(uuid, prefixLength, suffixLength))
|
|
18
|
+
let prefix = $derived(uuid.substring(0, prefixLength))
|
|
19
|
+
let suffix = $derived(uuid.substring(uuid.length - suffixLength))
|
|
20
|
+
let middle = $derived(uuid.substring(prefixLength, uuid.length - suffixLength))
|
|
28
21
|
</script>
|
|
29
22
|
|
|
30
23
|
<BaseButton
|
|
@@ -34,11 +27,23 @@
|
|
|
34
27
|
iconPosition="right"
|
|
35
28
|
variant="ghost"
|
|
36
29
|
data-uuid-copy
|
|
30
|
+
class={cn(
|
|
31
|
+
'max-w-full [&_[data-button-content]]:max-w-full [&_[data-button-content]]:min-w-0 [&_[data-button-content]>span]:min-w-0',
|
|
32
|
+
className
|
|
33
|
+
)}
|
|
37
34
|
onclick={async (e) => {
|
|
38
35
|
e.stopPropagation()
|
|
39
36
|
await copyToClipboard(uuid)
|
|
40
37
|
oncopied?.(uuid)
|
|
41
38
|
}}
|
|
42
39
|
>
|
|
43
|
-
|
|
40
|
+
{#if full}
|
|
41
|
+
<span class="font-mono">{uuid}</span>
|
|
42
|
+
{:else}
|
|
43
|
+
<span class="font-mono flex items-center min-w-0 overflow-hidden">
|
|
44
|
+
<span class="shrink-0">{prefix}</span>
|
|
45
|
+
<span class="truncate min-w-0">{middle}</span>
|
|
46
|
+
<span class="shrink-0">{suffix}</span>
|
|
47
|
+
</span>
|
|
48
|
+
{/if}
|
|
44
49
|
</BaseButton>
|
|
@@ -232,10 +232,14 @@
|
|
|
232
232
|
|
|
233
233
|
{#snippet buttonContent()}
|
|
234
234
|
<div
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
'
|
|
238
|
-
|
|
235
|
+
data-button-content
|
|
236
|
+
class={clsx(
|
|
237
|
+
'inline-flex items-center transition-transform group-active/button:translate-y-px',
|
|
238
|
+
{
|
|
239
|
+
'gap-1': !iconOnly && !shortcut,
|
|
240
|
+
'gap-1.5': !iconOnly && shortcut
|
|
241
|
+
}
|
|
242
|
+
)}
|
|
239
243
|
>
|
|
240
244
|
{#if icon && !children}
|
|
241
245
|
{@render iconContent()}
|
package/dist/types.d.ts
CHANGED