К содержимому

SusPromptDialog

SusPromptDialog

Text prompt card for modal dialogs — single text field with Confirm/Cancel actions; awaitable ShowAsync resolves to the entered string (or null on cancel).

Пакет

SusKit · Molecules (коммерческий)

Открыть в песочнице

SusKit · Molecules

Свойства

ИмяТипПо умолчанию
TitleProp<string>"Prompt"
PlaceholderProp<string>""v-model
ConfirmLabelProp<string>"OK"
CancelLabelProp<string>"Cancel"
ValueProp<string>""v-model

Слоты

Слотов нет.

События

ИмяПолеPayload
ConfirmOnConfirmstring
CancelOnCancel

Хуки стиля

Контракт USS-классов — внешний вид переопределяется без правки C#. Состояния переключаются этими классами:

  • sus-prompt-dialog
  • sus-prompt-dialog__footer

Использование

xml
<template>
  <sus:SusPromptDialog Title="Rename loadout"
                       Placeholder="Loadout name"
                       :Value="Name.Value"
                       @confirm="OnConfirm"
                       @cancel="OnCancel" />
</template>

<script>
public Prop<string> Name = new("");
void OnConfirm(string value) { /* value == current textfield content */ }
void OnCancel() { }
</script>
csharp
// Awaitable helper — hosts the card inside a SusModal and resolves when it closes.
string name = await SusPromptDialog.ShowAsync(
    title: "Rename loadout", placeholder: "Loadout name", initialValue: "Scout");
if (name != null) { /* confirmed, name is the entered text */ }

Заметки

  • Value задаёт начальное значение внутреннего SusTextfield (outlined / comfortable) и остаётся двусторонне зеркалированным, пока диалог смонтирован — читайте его после OnConfirm или используйте переданное значение напрямую.
  • OnConfirm(string) срабатывает с текущим значением textfield по кнопке подтверждения; OnCancel() — по кнопке отмены.
  • Статический хелпер ShowAsync оборачивает карточку в хост SusModal через SusModalService и резолвится в null, когда диалог закрыт через scrim модалки.