Skip to main content
On this pageConstants

Ui/Dialog/test

Constants

AcquireResources

constsource
/**
 * Reacquires an initially visible Dialog's framework resources when its
 *  element mounts, including after development Model preservation restores an
 *  open Dialog without replaying initialization Commands. A successful
 *  acquisition also resumes a preserved animation transition from its current
 *  phase.
 */
const AcquireResources: LayeredMountDefinitionWithArgs<"Dialog/AcquireResources", {
  focusSelector: String
  id: String
}, {
  _tag: "SucceededAcquireResources"
} | {
  _tag: "FailedAcquireResources"
}> & Readonly<{
  layer: Layer<Handler<"Dialog/AcquireResources", Readonly<{
    element: Element
    viewStateChanges: Stream<"Live" | "Paused">
  }> & {
    focusSelector: string
    id: string
  }, {
    _tag: "SucceededAcquireResources"
  } | {
    _tag: "FailedAcquireResources"
  }>, never, never>
}>

CloseDialog

constsource
/**
 * Calls `close()` on the native dialog element and unlocks page scroll when
 *  the close released the resources `ShowDialog` installed. A close that runs
 *  before the show has installed them leaves the lock alone. When the show
 *  then fails, it releases the lock itself. When the show succeeds, update
 *  closes the dialog again. If the dialog element is gone by the time the
 *  close runs, the Command calls `Dom.releaseDialogResources` instead. That
 *  releases the scroll lock, focus trap, return focus, and stack entry if the
 *  dialog still holds them. The background is restored before return focus.
 */
const CloseDialog: LayeredCommandDefinitionWithArgs<"Dialog/CloseDialog", {
  id: String
}, {
  _tag: "CompletedCloseDialog"
}> | DefinitionWithArgsNameKeyed<"Dialog/CloseDialog", {
  id: String
}, Effect<{
  _tag: "CompletedCloseDialog"
}, never, Handler<"Dialog/CloseDialog", {
  id: string
}, {
  _tag: "CompletedCloseDialog"
}>>> | DefinitionWithArgs<"Dialog/CloseDialog", {
  id: String
}, Pick<{
  id: string
}, "id">, Effect<{
  _tag: "CompletedCloseDialog"
}, never, Handler<"Dialog/CloseDialog", {
  id: string
}, {
  _tag: "CompletedCloseDialog"
}>>> & Readonly<{
  layer: Layer<Handler<"Dialog/CloseDialog", {
    id: string
  }, {
    _tag: "CompletedCloseDialog"
  }>, never, never>
}> & Readonly<{
  toLayer: ToLayer<"Dialog/CloseDialog", {
    id: string
  }, {
    _tag: "CompletedCloseDialog"
  }>
}>

ReleaseDialogResources

constsource
/**
 * Releases the framework hygiene the dialog holds while open (scroll lock,
 *  focus trap, return focus, stack entry, background isolation) when the
 *  element unmounts without a purposeful close. Calling it after
 *  `CloseDialog` released those resources is a no-op.
 */
const ReleaseDialogResources: LayeredCommandDefinitionWithArgs<"Dialog/ReleaseDialogResources", {
  id: String
}, {
  _tag: "CompletedReleaseDialogResources"
}> | DefinitionWithArgsNameKeyed<"Dialog/ReleaseDialogResources", {
  id: String
}, Effect<{
  _tag: "CompletedReleaseDialogResources"
}, never, Handler<"Dialog/ReleaseDialogResources", {
  id: string
}, {
  _tag: "CompletedReleaseDialogResources"
}>>> | DefinitionWithArgs<"Dialog/ReleaseDialogResources", {
  id: String
}, Pick<{
  id: string
}, "id">, Effect<{
  _tag: "CompletedReleaseDialogResources"
}, never, Handler<"Dialog/ReleaseDialogResources", {
  id: string
}, {
  _tag: "CompletedReleaseDialogResources"
}>>> & Readonly<{
  layer: Layer<Handler<"Dialog/ReleaseDialogResources", {
    id: string
  }, {
    _tag: "CompletedReleaseDialogResources"
  }>, never, never>
}> & Readonly<{
  toLayer: ToLayer<"Dialog/ReleaseDialogResources", {
    id: string
  }, {
    _tag: "CompletedReleaseDialogResources"
  }>
}>

ShowDialog

constsource
/**
 * Opens the native dialog element through `Dom.showDialog`, then locks page
 *  scroll when that call acquired the dialog resources. `Dom.showDialog`
 *  makes the background inert while leaving DevTools available as a separate
 *  developer overlay. It calls `show()` rather than `showModal()` so DevTools
 *  can stay interactive, layers the dialog with a high z-index, and traps
 *  focus. For an unhandled Escape on the topmost Dialog, the
 *  helper dispatches a `CustomEvent` named `cancel`; the Dialog view maps that
 *  signal to `RequestedClose` while suppressing native `cancel` events. The
 *  Dialog component supplies its own backdrop. If the dialog element is gone
 *  by the time the show runs, the Command reports `FailedShowDialog` without
 *  taking the scroll lock. The update function then closes the Model. The
 *  acquisition becomes uninterruptible after the committed element is found,
 *  so modal resources and the scroll lock cannot split. A concurrent
 *  lifecycle acquisition reuses the resources already held by the id.
 */
const ShowDialog: LayeredCommandDefinitionWithArgs<"Dialog/ShowDialog", {
  focusSelector: String
  id: String
}, {
  _tag: "SucceededShowDialog"
} | {
  _tag: "FailedShowDialog"
}> | DefinitionWithArgsNameKeyed<"Dialog/ShowDialog", {
  focusSelector: String
  id: String
}, Effect<{
  _tag: "SucceededShowDialog"
} | {
  _tag: "FailedShowDialog"
}, never, Handler<"Dialog/ShowDialog", {
  focusSelector: string
  id: string
}, {
  _tag: "SucceededShowDialog"
} | {
  _tag: "FailedShowDialog"
}>>> | DefinitionWithArgs<"Dialog/ShowDialog", {
  focusSelector: String
  id: String
}, Pick<{
  focusSelector: string
  id: string
}, "focusSelector" | "id">, Effect<{
  _tag: "SucceededShowDialog"
} | {
  _tag: "FailedShowDialog"
}, never, Handler<"Dialog/ShowDialog", {
  focusSelector: string
  id: string
}, {
  _tag: "SucceededShowDialog"
} | {
  _tag: "FailedShowDialog"
}>>> & Readonly<{
  layer: Layer<Handler<"Dialog/ShowDialog", {
    focusSelector: string
    id: string
  }, {
    _tag: "SucceededShowDialog"
  } | {
    _tag: "FailedShowDialog"
  }>, never, never>
}> & Readonly<{
  toLayer: ToLayer<"Dialog/ShowDialog", {
    focusSelector: string
    id: string
  }, {
    _tag: "SucceededShowDialog"
  } | {
    _tag: "FailedShowDialog"
  }>
}>