mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-12 00:20:15 +00:00
Add PromptDialog to replace window.prompt (#1104)
* Save file prompt dialog * Don't download if dialog dismissed * refactor * style dialog * nit * Autofocus
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
@hide="dialogStore.closeDialog"
|
||||
@maximize="onMaximize"
|
||||
@unmaximize="onUnmaximize"
|
||||
:pt="{ header: 'pb-0' }"
|
||||
>
|
||||
<template #header>
|
||||
<component
|
||||
@@ -30,7 +31,9 @@ import { useDialogStore } from '@/stores/dialogStore'
|
||||
import Dialog from 'primevue/dialog'
|
||||
|
||||
const dialogStore = useDialogStore()
|
||||
const maximizable = computed(() => dialogStore.props.maximizable ?? false)
|
||||
const maximizable = computed(
|
||||
() => dialogStore.dialogComponentProps.maximizable ?? false
|
||||
)
|
||||
const maximized = ref(false)
|
||||
|
||||
const onMaximize = () => {
|
||||
|
||||
@@ -191,8 +191,4 @@ const openNewGithubIssue = async () => {
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.no-results-placeholder {
|
||||
padding-top: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
43
src/components/dialog/content/PromptDialogContent.vue
Normal file
43
src/components/dialog/content/PromptDialogContent.vue
Normal file
@@ -0,0 +1,43 @@
|
||||
<template>
|
||||
<div class="prompt-dialog-content flex flex-col gap-2 pt-8">
|
||||
<FloatLabel>
|
||||
<InputText
|
||||
ref="inputRef"
|
||||
v-model="inputValue"
|
||||
@keyup.enter="onConfirm"
|
||||
@focus="selectAllText"
|
||||
autofocus
|
||||
/>
|
||||
<label>{{ message }}</label>
|
||||
</FloatLabel>
|
||||
<Button @click="onConfirm">{{ $t('confirm') }}</Button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import Button from 'primevue/button'
|
||||
import InputText from 'primevue/inputtext'
|
||||
import FloatLabel from 'primevue/floatlabel'
|
||||
import { ref } from 'vue'
|
||||
import { useDialogStore } from '@/stores/dialogStore'
|
||||
|
||||
const props = defineProps<{
|
||||
message: string
|
||||
defaultValue: string
|
||||
onConfirm: (value: string) => void
|
||||
}>()
|
||||
|
||||
const inputValue = ref<string>(props.defaultValue)
|
||||
|
||||
const onConfirm = () => {
|
||||
props.onConfirm(inputValue.value)
|
||||
useDialogStore().closeDialog()
|
||||
}
|
||||
|
||||
const inputRef = ref(null)
|
||||
const selectAllText = () => {
|
||||
if (!inputRef.value) return
|
||||
const inputElement = inputRef.value.$el
|
||||
inputElement.setSelectionRange(0, inputElement.value.length)
|
||||
}
|
||||
</script>
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div
|
||||
class="flex flex-wrap content-around justify-around gap-4"
|
||||
class="flex flex-wrap content-around justify-around gap-4 mt-4"
|
||||
data-testid="template-workflows-content"
|
||||
>
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user