close
Programmatically closes the dialog.
close: (model: Model) => UpdateReturnEffect-native UI toolkit
Interactive demosPublished API · 0.1.0-rc.1
Published themes API declarations for components/alert-dialog.
@wsagency/wseffect-themes · MIT · source · MIT license · WS-AGENCY-NOTICE
This entry point is published in @wsagency/wseffect-themes@0.1.0-rc.1. Import it from the package subpath shown below; the signatures and documentation are read from the installed package declarations.
import * as Wseffect from '@wsagency/wseffect-themes/components/alert-dialog'closeProgrammatically closes the dialog.
close: (model: Model) => UpdateReturndescriptionIdReturns the framework-managed description id, the `-dialog-description` suffix on `model.id`. The primary path is spreading `RenderInfo`'s `description` onto your description element (`h.p([...description], [...])`), which carries this id for you. Reach for this helper only when you need the id as a value outside `toView`: a Command that calls `getElementById`, a cross-element `aria-describedby`, or a test. When the description is rendered, set `ViewInputs.hasDescription` so the dialog points at this id. Do not hand-roll the id string.
descriptionId: (model: Model) => stringembedembed: <ParentMessage>(h: HtmlBuilder<ParentMessage>, config: EmbedConfig<ParentMessage>) => HtmlEmbedConfigexport type EmbedConfig<ParentMessage> = Readonly<{
slotId: string;
model: UiDialog.Model;
toParentMessage: (message: UiDialog.Message) => ParentMessage;
title: string;
description?: string;
cancelLabel: string;
content?: ReadonlyArray<Html | string>;
actions?: ReadonlyArray<Html | string>;
}>;foldfold: <ParentModel, ParentMessage, ParentOutMessage>(config: Omit<Update.ChildFoldWithDerivedParentOutMessage<ParentModel, ParentMessage, UiDialog.Model, UiDialog.Message, UiDialog.Message, UiDialog.OutMessage, ParentOutMessage>, 'update'>) => Update.FoldWithOutMessage<ParentModel, ParentMessage, UiDialog.Message, ParentOutMessage>initinit: (config: UiDialog.InitConfig) => UiDialog.ModelMessageexport type Message = typeof Message.Type;MessageUnion of all messages the dialog component can produce.
Message: import("@wsagency/wseffect-foldkit/message").MessageUnion<{
readonly RequestedOpen: {};
readonly RequestedClose: {};
readonly SucceededShowDialog: {};
readonly FailedShowDialog: {};
readonly SucceededAcquireResources: {};
readonly FailedAcquireResources: {};
readonly CompletedCloseDialog: {};
readonly Unmounted: {};
readonly CompletedReleaseDialogResources: {};
readonly GotAnimationMessage: {
message: import("@wsagency/wseffect-foldkit/message").MessageUnion<{
readonly Showed: {};
readonly Hid: {};
readonly CompletedWaitForPaint: {
generation: Schema.Number;
};
readonly EndedAnimation: {
generation: Schema.Number;
};
}>;
};
}>Modelexport type Model = typeof Model.Type;ModelSchema for the dialog component's state, tracking its unique ID, open/closed status, animation support, and animation lifecycle phase.
Model: Schema.Struct<{
readonly id: Schema.String;
readonly isOpen: Schema.Boolean;
readonly isAnimated: Schema.Boolean;
readonly animation: Schema.Struct<{
readonly id: Schema.String;
readonly isShowing: Schema.Boolean;
readonly transitionState: Schema.Literals<readonly ["Idle", "EnterStart", "EnterAnimating", "LeaveStart", "LeaveAnimating"]>;
readonly transitionGeneration: Schema.Number;
}>;
readonly maybeFocusSelector: Schema.Option<Schema.String>;
}>openProgrammatically opens the dialog.
open: (model: Model) => UpdateReturnOutMessageexport type OutMessage = typeof OutMessage.Type;OutMessageUnion of out-messages the dialog component can produce.
OutMessage: import("@wsagency/wseffect-foldkit/message").MessageUnion<{
readonly Opened: {};
readonly Closed: {};
}>titleIdReturns the framework-managed id the dialog's `aria-labelledby` points at, the `-dialog-title` suffix on `model.id`. The primary path is spreading `RenderInfo`'s `title` onto your heading (`h.h2([...title], [...])`), which carries this id for you. Reach for this helper only when you need the id as a value outside `toView`: a Command that calls `getElementById`, a cross-element `aria-describedby`, or a test. Do not hand-roll the id string.
titleId: (model: Model) => stringupdateProcesses a Dialog Message and returns the next Model and optional Commands.
update: (model: Model, message: Message) => Readonly<{
model: {
readonly id: string;
readonly isOpen: boolean;
readonly isAnimated: boolean;
readonly animation: {
readonly id: string;
readonly isShowing: boolean;
readonly transitionState: "EnterAnimating" | "EnterStart" | "Idle" | "LeaveAnimating" | "LeaveStart";
readonly transitionGeneration: number;
};
readonly maybeFocusSelector: Option.Option<string>;
};
commands?: Update.Commands<{
readonly _tag: "RequestedOpen";
} | {
readonly _tag: "RequestedClose";
} | {
readonly _tag: "SucceededShowDialog";
} | {
readonly _tag: "FailedShowDialog";
} | {
readonly _tag: "SucceededAcquireResources";
} | {
readonly _tag: "FailedAcquireResources";
} | {
readonly _tag: "CompletedCloseDialog";
} | {
readonly _tag: "Unmounted";
} | {
readonly _tag: "CompletedReleaseDialogResources";
} | {
readonly _tag: "GotAnimationMessage";
readonly message: {
readonly _tag: "CompletedWaitForPaint";
readonly generation: number;
} | {
readonly _tag: "EndedAnimation";
readonly generation: number;
} | {
readonly _tag: "Hid";
} | {
readonly _tag: "Showed";
};
}, never>;
outMessage?: {
readonly _tag: "Opened";
} | {
readonly _tag: "Closed";
};
}>import * as Themes from '@wsagency/wseffect-themes'
import * as SliderRange from '@wsagency/wseffect-themes/components/slider/range'
import * as Option from 'effect/Option'
import { defineView } from '@wsagency/wseffect-foldkit/submodel'
import { inertHtml, type HtmlBuilder } from '@wsagency/wseffect-foldkit/html'
const example = (h: HtmlBuilder<unknown>) => (() => { const id = 'delete-project'; const model = Themes.AlertDialog.open(Themes.AlertDialog.init({ id })).model; return Themes.AlertDialog.embed(h, { slotId: id, model, toParentMessage: (message) => message, title: 'Delete project?', description: 'This action cannot be undone.', cancelLabel: 'Cancel', actions: [h.button([], ['Delete'])] }) })()