跳转到内容

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(商业)

在 Playground 中打开

SusKit · Molecules

属性

名称类型默认值
TitleProp<string>"Prompt"
PlaceholderProp<string>""v-model
ConfirmLabelProp<string>"OK"
CancelLabelProp<string>"Cancel"
ValueProp<string>""v-model

插槽

没有插槽。

事件

名称字段载荷
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 辅助通过 SusModalService 将卡片包进 SusModal 宿主;若通过模态 scrim 关闭,则解析为 null