qat

Dialog and confirm

Dialog, Confirm. They are copied into your app’s ui/ by qatjs add dialog: the code is yours to edit.

Example

Answer: none

Example.qx44 lines, 3 reactive namesOpen in the playground
import Button from './ui/button/button.qx'
import { Confirm, Dialog } from './ui/dialog/dialog.qx'
import { TextField } from './ui/input/input.qx'

export default function Example() {
  let editing = state(false)
  let asking = state(false)
  let answer = state('')
  return (
    <div class="example-row">
      <Button on:click={() => (editing = true)}>
        Edit delivery window
      </Button>
      <Button variant="danger" on:click={() => (asking = true)}>
        Cancel order
      </Button>
    </div>
    <p>Answer: {answer || 'none'}</p>
    <Dialog title="Edit delivery window" bind:open={editing}>
      <p>The customer will get an SMS with the new window.</p>
      <TextField label="Window" value="Tomorrow, 10:00 – 12:00" />
      <div slot="actions">
        <Button on:click={() => (editing = false)}>
          Cancel
        </Button>
        <Button variant="primary" on:click={() => ((editing = false), (answer = 'saved'))}>
          Save window
        </Button>
      </div>
    </Dialog>
    <Confirm
     
      title="Cancel order 10482?"
      confirm="Cancel order"
      cancel="Keep order"
      danger
      bind: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
PropTypeAttribute
openbooleanyes
titleQatNodeproperty only
size'sm' | 'md' | 'lg'yes
variant'dialog' | 'sheet' | 'side'yes
dismissiblebooleanyes
closeLabelstringyes
actionsQatNodeproperty only
Dialog: events
EventDetail
on:update:openCustomEvent<boolean>
on:closeCustomEvent<undefined>

Confirm

A confirmation: the question, what follows, the safe answer (focused) and the confirming one. As a custom element: <ui-confirm>.

Confirm: props
PropTypeAttribute
openbooleanyes
titleQatNodeproperty only
confirmstringyes
cancelstringyes
dangerbooleanyes
Confirm: events
EventDetail
on:update:openCustomEvent<boolean>
on:confirmCustomEvent<undefined>
on:cancelCustomEvent<undefined>

Keys

KeyDoes
Tabstays inside
Escclose, focus back