Sign In

@astrocal/widget

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@astrocal/widget

Embeddable booking widget for Astrocal — drop-in scheduling UI for any website or app

Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
168
Maintainers
1
Weekly downloads
 
Created
Source

@astrocal/widget

Embeddable booking widget for Astrocal — drop-in scheduling UI for any website or app.

Installation

npm install @astrocal/widget

Quick Start (ESM)

import { open } from "@astrocal/widget";

open({
  eventTypeId: "your-event-type-id",
  mode: "popup",
});

Inline Mode

Mount the widget into a specific DOM element:

import { open, destroy } from "@astrocal/widget";

// Mount
open({
  eventTypeId: "your-event-type-id",
  mode: "inline",
  target: "#booking-container",
});

// Clean up when done
destroy("#booking-container");

CDN Usage (Script Tag)

For non-npm users, load the widget via a script tag:

<script src="https://cdn.astrocal.dev/widget/latest/astrocal.js"></script>
<script>
  Astrocal.open({
    eventTypeId: "your-event-type-id",
    mode: "popup",
  });
</script>

Or use auto-initialization with data attributes:

<script src="https://cdn.astrocal.dev/widget/latest/astrocal.js"></script>
<div data-astrocal-event-type-id="your-event-type-id" data-astrocal-mode="inline"></div>

API

open(config: WidgetConfig): void

Opens the booking widget in inline or popup mode.

close(): void

Closes the popup widget if open. No-op if no popup is active.

destroy(target: string | HTMLElement): void

Destroys an inline widget mounted on a target element. Removes the Shadow DOM and cleans up all resources. No-op if no widget is mounted on the target.

autoInit(): void

Scans the DOM for elements with data-astrocal-* attributes and mounts widgets automatically.

WidgetConfig

PropertyTypeDefaultDescription
eventTypeIdstringrequiredEvent type UUID to display
apiUrlstring"https://api.astrocal.dev"API base URL
mode"inline" | "popup""popup"Render mode
targetstring | HTMLElementDOM element or CSS selector (inline mode)
timezonestringauto-detectedIANA timezone override
themeThemeConfigCSS custom property overrides
colorScheme"light" | "dark" | "auto""auto"Color scheme
demobooleanfalseEnable demo mode (mock data, no API calls)
onBookingCreated(booking: BookingResult) => voidBooking success callback
onError(error: WidgetError) => voidError callback
onClose() => voidPopup close callback

ThemeConfig

PropertyCSS Custom PropertyDescription
primaryColor--astrocal-primaryPrimary action color
primaryHoverColor--astrocal-primary-hoverPrimary hover color
headingColor--astrocal-headingHeading text color
backgroundColor--astrocal-bgWidget background
textColor--astrocal-textBody text color
borderColor--astrocal-borderBorder color
borderFocusColor--astrocal-border-focusFocused border color
borderRadius--astrocal-radiusBorder radius
fontFamily--astrocal-fontFont family

SSR / Server-Side Rendering

The package is safe to import in Node.js (e.g., Next.js, Nuxt). The autoInit() function is guarded and will not run on the server. However, open() and destroy() require a browser environment and will throw a clear error if called without a DOM. close() is a silent no-op on the server.

// Safe — no error on import
import { open } from "@astrocal/widget";

// Only call in browser context
if (typeof window !== "undefined") {
  open({ eventTypeId: "..." });
}

Documentation

Full documentation at docs.astrocal.dev.

License

MIT

Keywords

scheduling

FAQs

Package last updated on 09 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts