@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
- function shortenString(inputString: string, prefixLength: number, suffixLength: number) {
17
- if (inputString.length <= prefixLength + suffixLength) {
18
- return inputString // Return the whole string if it's too short
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
- <span class="font-mono">{formattedUuid}</span>
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
- class={clsx('inline-flex items-center transition-transform group-active/button:translate-y-px', {
236
- 'gap-1': !iconOnly && !shortcut,
237
- 'gap-1.5': !iconOnly && shortcut
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()}
@@ -14,6 +14,7 @@
14
14
  full={config?.full}
15
15
  disabled={config?.disabled}
16
16
  oncopied={config?.onCopy}
17
+ class="!font-[weight:inherit]"
17
18
  />
18
19
  </div>
19
20
  {:else}
package/dist/types.d.ts CHANGED
@@ -266,6 +266,7 @@ export interface ButtonUuidCopyProps {
266
266
  full?: boolean;
267
267
  disabled?: boolean;
268
268
  oncopied?: (label: string) => void;
269
+ class?: string;
269
270
  }
270
271
  export interface ButtonSearchProps {
271
272
  value?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@invopop/popui",
3
3
  "license": "MIT",
4
- "version": "0.1.67",
4
+ "version": "0.1.68",
5
5
  "repository": {
6
6
  "url": "https://github.com/invopop/popui"
7
7
  },