An open API service indexing awesome lists of open source software.

https://github.com/hebus/ngx-call

Imperative, type-safe, promise-based dialogs & overlays for Angular β€” the Angular counterpart of react-call's createCallable.
https://github.com/hebus/ngx-call

angular angular-library createcallable dialog imperative modal ngx overlay promise react-call signals typescript

Last synced: 2 days ago
JSON representation

Imperative, type-safe, promise-based dialogs & overlays for Angular β€” the Angular counterpart of react-call's createCallable.

Awesome Lists containing this project

README

          

# ngx-call

> Imperative, type-safe, promise-based dialogs & overlays for Angular β€” the Angular counterpart of [react-call](https://github.com/desko27/react-call)'s `createCallable`.

**[β–Ά Live demo & 21 examples β†’ hebus.github.io/ngx-call](https://hebus.github.io/ngx-call/)**

Call a dialog like a function. Await a confirm, resolve a value β€” no template wiring, no boilerplate.

```typescript
// 1 β€” bind any component, once
export const Confirm = createCallable<{ message: string }, boolean>(ConfirmDialog);

// 2 β€” call it like a function, anywhere
const ok = await Confirm.call({ message: "Delete this item?" });
// ^ resolves to boolean β€” fully typed
```

## Features

- **Imperative API** β€” `call`, `upsert`, `update`, `end`, `setRoot`, mirroring react-call's full surface.
- **Type-safe** β€” arguments and the resolved value are typed end-to-end.
- **Promise-based** β€” `await` any overlay; each call stacks an independent instance.
- **Zero dependencies** β€” built on Angular signals and DI.
- **Anything overlay-shaped** β€” confirms, prompts, toasts, drawers, command palettes, wizards… see the [demo](https://hebus.github.io/ngx-call/).

## How it differs from react-call

Beyond the obvious Angular-vs-React: **react-call is headless** β€” it gives you the callable/stacking mechanism and you render and style the overlay yourself. ngx-call keeps that same headless engine (`createCallable`, `injectCallRef`, stacking, `closeAll`) **and** ships optional UI primitives built directly on web-platform standards:

- **Native `` element** β€” the `Dialog` wrapper drives the real element via `showModal()` / `show()`, so you get the browser **top layer**, the native `::backdrop`, focus trapping and Esc-to-close for free β€” no re-implemented modal logic.
- **Standard Popover API** β€” `showPopover()` opens in the top layer with native light-dismiss (`closedby="any"`), ideal for menus, tooltips and non-modal panels β€” no overlay `

`, no manual outside-click handling.
- **Single-backdrop stacking** β€” stacked native modals would each paint their own `::backdrop` and cumulatively darken the page; ngx-call keeps exactly one visible backdrop across the whole stack.
- **No `` to place** β€” react-call requires you to render `` in your component tree; ngx-call mounts instances imperatively (to `document.body`) once `provideCallable()` is registered, so there's nothing to wire into a template.
- **Signals throughout** β€” `call.props()`, `call.index()`, `call.stackSize()` and `DialogService.openCount` are Angular signals.

The UI primitives are optional: use the headless `createCallable` with your own markup, or lean on `Dialog` / `DialogContent` for the batteries-included path.

**Familiar by design** β€” the public API deliberately mirrors react-call's surface (`createCallable`, and `call` / `upsert` / `update` / `end` / `setRoot`). Porting a dialog between React and Angular β€” in either direction β€” is closer to a mechanical rename than a rewrite.

## Install

```bash
npm i ngx-call
```

Then capture the root injector at bootstrap:

```typescript
bootstrapApplication(App, { providers: [provideCallable()] });
```

## Development

This is a multi-project Angular workspace: the `ngx-call` library and a `demo` application.

```bash
npm install
npm start # serves the demo at http://localhost:4200/
npx ng build ngx-call # builds the library
npx ng build demo # builds the demo app
npm test # runs unit tests (Vitest)
```

## Demo deployment

The demo is built and published to GitHub Pages on every push to `main` via
[`.github/workflows/deploy.yml`](.github/workflows/deploy.yml) β†’
[hebus.github.io/ngx-call](https://hebus.github.io/ngx-call/).

## Credits

A direct port of [desko27/react-call](https://github.com/desko27/react-call) to Angular.