/** * Alert-dialog handle factory — mirrors Base UI React's * `createAlertDialogHandle`. * * Constructs a `DialogHandle` whose store is shape-compatible with * ``. At runtime the handle is a plain `DialogHandle`; * only the store's default configuration differs (modal, * disablePointerDismissal, role=alertdialog). In the Solid port those * knobs are imposed by `` itself (the root forces * `modal: true` / `disablePointerDismissal: true` regardless of store * state), so the handle is a bare `DialogHandle`. * * TypeScript-only `__brand` phantom discriminator: * * The `AlertDialogHandle` type is a nominal branding of * `DialogHandle` via a `declare readonly __brand: * "AlertDialogHandle"` phantom property. The property does not exist at * runtime — it only exists in the type system — so structural assignment * from a plain `DialogHandle` into an `AlertDialogHandle`-typed slot is * rejected. Branded handles remain assignable *to* `DialogHandle`-typed * slots (the Dialog `Trigger` re-exported under the `AlertDialog` * namespace accepts this), but a `DialogHandle` created via * `Dialog.createHandle()` cannot be passed where an `AlertDialogHandle` * is required. */ import { DialogHandle, DialogStore } from "../dialog/store/dialog-store"; /** * Nominal (brand-typed) alias of `DialogHandle` used by * `` / `AlertDialog.createHandle`. Identical shape to * `DialogHandle` at runtime; the phantom `__brand` property exists only * in the type system so a plain `DialogHandle` cannot be passed where an * `AlertDialogHandle` is expected. */ export type AlertDialogHandle = DialogHandle & { /** @internal phantom discriminator — does not exist at runtime. */ readonly __brand: "AlertDialogHandle"; }; export function createAlertDialogHandle< Payload = unknown, >(): AlertDialogHandle { return new DialogHandle( new DialogStore(), ) as AlertDialogHandle; }