File tree Expand file tree Collapse file tree 5 files changed +52
-14
lines changed
Expand file tree Collapse file tree 5 files changed +52
-14
lines changed Original file line number Diff line number Diff line change 11<script setup lang="ts">
2- import { VueInput } from ' @vue/devtools-ui'
2+ import { VueIcon , VueInput } from ' @vue/devtools-ui'
33import AppConnecting from ' ~/components/AppConnecting.vue'
44
55const props = defineProps <{
@@ -16,6 +16,8 @@ const _network = scriptWrapper(props.network!)
1616
1717const local = ref (_local )
1818const network = ref (_network )
19+
20+ const { copy } = useCopy ()
1921 </script >
2022
2123<template >
@@ -28,11 +30,13 @@ const network = ref(_network)
2830 <p class =" text-center text-sm op80 text-base" >
2931 Add one of the following to the top of your page 👇:
3032 </p >
31- <div class =" mt-3 $ui-fcc flex-row" >
32- <VueInput v-model =" local" left-icon =" i-carbon-copy" class =" w-400px!" />
33+ <div class =" mt-3 $ui-fcc flex-row gap3" >
34+ <VueInput v-model =" local" class =" w-380px!" />
35+ <VueIcon icon =" i-carbon-copy" class =" cursor-pointer text-primary-300 hover:text-primary-500" @click =" copy(local)" />
3336 </div >
34- <div class =" mt-3 $ui-fcc flex-row" >
35- <VueInput v-model =" network" left-icon =" i-carbon-copy" class =" w-400px!" />
37+ <div class =" mt-3 $ui-fcc flex-row gap3" >
38+ <VueInput v-model =" network" class =" w-380px!" />
39+ <VueIcon icon =" i-carbon-copy" class =" cursor-pointer text-primary-300 hover:text-primary-500" @click =" copy(network)" />
3640 </div >
3741 </div >
3842 </AppConnecting >
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ const codeSnippets = computed(() => {
5757 return items
5858})
5959
60- const copy = useCopy ()
60+ const { copy } = useCopy ()
6161const timeAgo = useTimeAgo (() => asset .value .mtime )
6262const fileSize = computed (() => {
6363 const size = asset .value .size
@@ -159,7 +159,7 @@ const supportsPreview = computed(() => {
159159 icon =" i-carbon-copy"
160160 action mr1 mt--2px flex-none
161161 :border =" false"
162- @click =" copy(asset.publicPath, 'assets-public-path')"
162+ @click =" copy(asset.publicPath, { silent: false, type: 'assets-public-path' } )"
163163 />
164164 <RouterLink
165165 :to =" asset.publicPath"
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ const props = defineProps<{
99}>()
1010
1111const selected = shallowRef <CodeSnippet | undefined >(props .codeSnippets [0 ])
12- const copy = useCopy ()
12+ const { copy } = useCopy ()
1313
1414const selectedLang = computed (() => (selected .value ?.lang || ' text' ) as BuiltinLanguage )
1515
@@ -45,7 +45,7 @@ watchEffect(() => {
4545 w-full of-auto p3
4646 />
4747 <div flex =" ~ gap-2" px3 pb3 >
48- <VueButton @click =" copy(selected!.code, eventType || `code-snippet-${selected.name}`)" >
48+ <VueButton @click =" copy(selected!.code, { silent: false, type: eventType || `code-snippet-${selected.name}` } )" >
4949 Copy
5050 <template #icon >
5151 <slot name =" i-carbon-copy" />
Original file line number Diff line number Diff line change 1+ import { showVueNotification } from '@vue/devtools-ui'
2+
3+ interface CopyOptions {
4+ silent ?: boolean
5+ type ?: string
6+ }
7+
18export function useCopy ( ) {
2- const clipboard = useClipboard ( )
9+ const { copy : _copy , copied } = useClipboard ( )
10+
11+ const copy = ( text : string , options : CopyOptions = { } ) => {
12+ const {
13+ silent = false ,
14+ type = '' ,
15+ } = options
16+ _copy ( text ) . then ( ( ) => {
17+ if ( ! silent ) {
18+ showVueNotification ( {
19+ message : 'Copied to clipboard' ,
20+ type : 'success' ,
21+ duration : 3000 ,
22+ } )
23+ }
24+ } ) . catch ( ( ) => {
25+ if ( ! silent ) {
26+ showVueNotification ( {
27+ message : 'Failed to copy to clipboard' ,
28+ type : 'error' ,
29+ duration : 3000 ,
30+ } )
31+ }
32+ } )
33+ }
334
4- return ( text : string , type ?: string ) => {
5- clipboard . copy ( text )
35+ return {
36+ copy,
37+ copied,
638 }
739}
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ const props = withDefaults(defineProps<{
1515 loading? : boolean
1616 autoFocus? : boolean
1717 loadingDebounceTime? : number
18+ readonly? : boolean
1819}>(), {
1920 placeholder: ' ' ,
2021 variant: ' normal' ,
@@ -26,6 +27,7 @@ const props = withDefaults(defineProps<{
2627 loading: false ,
2728 autoFocus: false ,
2829 loadingDebounceTime: 0 ,
30+ readonly: false ,
2931})
3032
3133const emit = defineEmits <{
@@ -42,7 +44,7 @@ const focused = refWithControl(false, {
4244 emit (' updateFocused' , value )
4345 },
4446})
45- const noFocusAnimation = computed (() => props .variant === ' flat' || props .variant === ' warning' )
47+ const noFocusAnimation = computed (() => props .variant === ' flat' || props .variant === ' warning' || props . disabled || props . readonly )
4648
4749const disabled = computed (() => props .disabled || loading .value )
4850
@@ -100,7 +102,7 @@ watchEffect(() => {
100102 <input
101103 ref =" inputRef" v-model =" value"
102104 class =" $ui-base w-full bg-transparent color-inherit outline-none placeholder-color-gray-500 dark:placeholder-gray-300" :type =" props.password ? 'password' : 'text'"
103- :placeholder =" placeholder" :disabled =" disabled"
105+ :placeholder =" placeholder" :disabled =" disabled || readonly "
104106 @blur =" focused = false"
105107 >
106108 <div v-if =" loading" :class =" iconClasses" >
You can’t perform that action at this time.
0 commit comments