importButtonfrom'./ui/button/button.qx'import { Confirm, Dialog } from'./ui/dialog/dialog.qx'import { TextField } from'./ui/input/input.qx'exportdefaultfunctionExample() {letediting = state(false)letasking = state(false)letanswer = state('')return (<divclass="example-row"><Buttonon:click={() => (editing = true)}> Edit delivery window</Button><Buttonvariant="danger"on:click={() => (asking = true)}> Cancel order</Button></div><p>Answer: {answer || 'none'}</p><Dialogtitle="Edit delivery window"bind:open={editing}><p>The customer will get an SMS with the new window.</p><TextFieldlabel="Window"value="Tomorrow, 10:00 – 12:00" /><divslot="actions"><Buttonon:click={() => (editing = false)}> Cancel</Button><Buttonvariant="primary"on:click={() => ((editing = false), (answer = 'saved'))}> Save window</Button></div></Dialog><Confirmtitle="Cancel order 10482?"confirm="Cancel order"cancel="Keep order"dangerbind:open={asking}on:confirm={() => (answer = 'cancelled')} on:cancel={() => (answer = 'kept')} > The customer is refunded 84.00 ₼ within three days. This cannot be undone.</Confirm> )}
editing stateasking stateanswer state
Add it
shell1 line
npx qatjs add dialog
Dialog
A dialog: its title, a body that scrolls, actions (`slot="actions"`, which arrives as `slots.actions`; or the `actions` prop); `bind:open`. As a custom element: <ui-dialog>.
Dialog: props
Prop
Type
Attribute
open
boolean
yes
title
QatNode
property only
size
'sm' | 'md' | 'lg'
yes
variant
'dialog' | 'sheet' | 'side'
yes
dismissible
boolean
yes
closeLabel
string
yes
actions
QatNode
property only
Dialog: events
Event
Detail
on:update:open
CustomEvent<boolean>
on:close
CustomEvent<undefined>
Confirm
A confirmation: the question, what follows, the safe answer (focused) and the confirming one. As a custom element: <ui-confirm>.