1
+ <div x-data =" {
2
+ clipboardText: '{{ value }}',
3
+ clipboardNotification: false,
4
+ copyToClipboard() {
5
+ navigator.clipboard.writeText(this.clipboardText);
6
+ this.clipboardNotification = true;
7
+ let that = this;
8
+ setTimeout(() => {
9
+ this.clipboardNotification = false;
10
+ }, 3000);
11
+ }
12
+ }" >
13
+
14
+ @jrmc.button ({ ... $props , class: jrmc .getCssClass ($props , ' gap-2' ), type: ' button' , ' @click' : ' copyToClipboard();' })
15
+ @if ($slots .copy === undefined && $slots .copied === undefined )~
16
+ {{{ await $slots .main () || text || ' ' }}}
17
+ @end ~
18
+ <template x-if =" !clipboardNotification" >
19
+ @if ($slots .copy !== undefined )~
20
+ {{{ await $slots .copy () }}}
21
+ @else
22
+ {{{ await $slots .main () || text || ' ' }}}
23
+ <svg xmlns =" http://www.w3.org/2000/svg" class =" w-4 h-4" fill =" none" viewBox =" 0 0 24 24" stroke =" currentColor" >
24
+ <path d =" M16 12.9V17.1C16 20.6 14.6 22 11.1 22H6.9C3.4 22 2 20.6 2 17.1V12.9C2 9.4 3.4 8 6.9 8H11.1C14.6 8 16 9.4 16 12.9Z" stroke-width =" 1.5" stroke-linecap =" round" stroke-linejoin =" round" />
25
+ <path d =" M22 6.9V11.1C22 14.6 20.6 16 17.1 16H16V12.9C16 9.4 14.6 8 11.1 8H8V6.9C8 3.4 9.4 2 12.9 2H17.1C20.6 2 22 3.4 22 6.9Z" stroke-width =" 1.5" stroke-linecap =" round" stroke-linejoin =" round" />
26
+ </svg >
27
+ @end ~
28
+ </template >
29
+ <template x-if =" clipboardNotification" >
30
+ @if ($slots .copied !== undefined )~
31
+ {{{ await $slots .copied () }}}
32
+ @else
33
+ {{{ await $slots .main () || text || ' ' }}}
34
+ <svg xmlns =" http://www.w3.org/2000/svg" class =" w-4 h-4 text-success" fill =" none" viewBox =" 0 0 24 24" stroke =" currentColor" >
35
+ <path d =" M22 11.1V6.9C22 3.4 20.6 2 17.1 2H12.9C9.4 2 8 3.4 8 6.9V8H11.1C14.6 8 16 9.4 16 12.9V16H17.1C20.6 16 22 14.6 22 11.1Z" stroke-width =" 1.5" stroke-linecap =" round" stroke-linejoin =" round" />
36
+ <path d =" M16 17.1V12.9C16 9.4 14.6 8 11.1 8H6.9C3.4 8 2 9.4 2 12.9V17.1C2 20.6 3.4 22 6.9 22H11.1C14.6 22 16 20.6 16 17.1Z" stroke-width =" 1.5" stroke-linecap =" round" stroke-linejoin =" round" />
37
+ <path d =" M6.08008 15L8.03008 16.95L11.9201 13.05" stroke-width =" 1.5" stroke-linecap =" round" stroke-linejoin =" round" />
38
+ </svg >
39
+ @end~
40
+ </template >
41
+ @end
42
+ </div >
0 commit comments