@makeaslot/react 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # @makeaslot/react
2
+
3
+ React controls for the hosted MakeASlot booking experience. The package loads the existing `embed.js` script and opens its modal or drawer; it does not render a booking form inline.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @makeaslot/react
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```tsx
14
+ import { MakeASlotButton } from "@makeaslot/react";
15
+
16
+ export function BookAppointment() {
17
+ return (
18
+ <MakeASlotButton
19
+ origin="https://appointix.duckdns.org"
20
+ makeASlotLink="joe-consultancy/discovery-call"
21
+ presentation="modal"
22
+ theme="dark"
23
+ brandName="Joe Consultancy"
24
+ logoUrl="https://appointix-server.duckdns.org/storage/booking-branding/10/logo.png"
25
+ className="book-button"
26
+ >
27
+ Book now
28
+ </MakeASlotButton>
29
+ );
30
+ }
31
+ ```
32
+
33
+ Set `presentation="drawer"` to open the same hosted booking experience in a drawer.
34
+
35
+ For custom triggers, use `openMakeASlot`:
36
+
37
+ ```tsx
38
+ import { openMakeASlot } from "@makeaslot/react";
39
+
40
+ openMakeASlot({
41
+ origin: "https://appointix.duckdns.org",
42
+ makeASlotLink: "joe-consultancy/discovery-call",
43
+ presentation: "modal",
44
+ });
45
+ ```
46
+
47
+ ## Build and test locally
48
+
49
+ ```bash
50
+ cd packages/react
51
+ npm run build
52
+ npm run pack:check
53
+ ```
54
+
55
+ `npm pack` produces the exact archive that will be published. Publish only after logging into the intended npm organization:
56
+
57
+ ```bash
58
+ cd packages/react
59
+ npm publish
60
+ ```
@@ -0,0 +1,7 @@
1
+ import type { MakeASlotButtonProps } from "./types.js";
2
+ /**
3
+ * A regular React button that opens the existing MakeASlot modal or drawer.
4
+ * It does not render a booking flow inline.
5
+ */
6
+ export declare function MakeASlotButton({ children, onClick, origin, makeASlotLink, presentation, theme, brandName, logoUrl, scriptSrc, type, ...buttonProps }: MakeASlotButtonProps): import("react").JSX.Element;
7
+ //# sourceMappingURL=MakeASlotButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MakeASlotButton.d.ts","sourceRoot":"","sources":["../src/MakeASlotButton.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAC9B,QAAqB,EACrB,OAAO,EACP,MAAM,EACN,aAAa,EACb,YAAsB,EACtB,KAAe,EACf,SAAS,EACT,OAAO,EACP,SAAS,EACT,IAAe,EACf,GAAG,WAAW,EACf,EAAE,oBAAoB,+BA2BtB"}
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { useEffect } from "react";
15
+ import { loadMakeASlot, openMakeASlot } from "./script-loader.js";
16
+ /**
17
+ * A regular React button that opens the existing MakeASlot modal or drawer.
18
+ * It does not render a booking flow inline.
19
+ */
20
+ export function MakeASlotButton(_a) {
21
+ var { children = "Book now", onClick, origin, makeASlotLink, presentation = "modal", theme = "light", brandName, logoUrl, scriptSrc, type = "button" } = _a, buttonProps = __rest(_a, ["children", "onClick", "origin", "makeASlotLink", "presentation", "theme", "brandName", "logoUrl", "scriptSrc", "type"]);
22
+ useEffect(() => {
23
+ loadMakeASlot({ origin, scriptSrc });
24
+ }, [origin, scriptSrc]);
25
+ return (_jsx("button", Object.assign({}, buttonProps, { type: type, onClick: (event) => {
26
+ onClick === null || onClick === void 0 ? void 0 : onClick(event);
27
+ if (event.defaultPrevented)
28
+ return;
29
+ openMakeASlot({
30
+ origin,
31
+ makeASlotLink,
32
+ presentation,
33
+ theme,
34
+ brandName,
35
+ logoUrl,
36
+ scriptSrc,
37
+ });
38
+ }, children: children })));
39
+ }
@@ -0,0 +1,4 @@
1
+ export { MakeASlotButton } from "./MakeASlotButton.js";
2
+ export { loadMakeASlot, openMakeASlot } from "./script-loader.js";
3
+ export type { MakeASlotApi, MakeASlotButtonProps, MakeASlotOptions, MakeASlotPresentation, MakeASlotTheme, } from "./types.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAClE,YAAY,EACV,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,GACf,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ export { MakeASlotButton } from "./MakeASlotButton.js";
3
+ export { loadMakeASlot, openMakeASlot } from "./script-loader.js";
@@ -0,0 +1,15 @@
1
+ import type { MakeASlotApi, MakeASlotOptions } from "./types.js";
2
+ declare global {
3
+ interface Window {
4
+ MakeASlot?: MakeASlotApi;
5
+ }
6
+ }
7
+ /** Loads the MakeASlot embed script if necessary and returns its global command API. */
8
+ export declare function loadMakeASlot(options: Pick<MakeASlotOptions, "origin"> & {
9
+ scriptSrc?: string;
10
+ }): MakeASlotApi | undefined;
11
+ /** Opens the existing MakeASlot modal or drawer for a booking link. */
12
+ export declare function openMakeASlot(options: MakeASlotOptions & {
13
+ scriptSrc?: string;
14
+ }): void;
15
+ //# sourceMappingURL=script-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"script-loader.d.ts","sourceRoot":"","sources":["../src/script-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEjE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,SAAS,CAAC,EAAE,YAAY,CAAC;KAC1B;CACF;AAmCD,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,4BAM/F;AAED,uEAAuE;AACvE,wBAAgB,aAAa,CAC3B,OAAO,EAAE,gBAAgB,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,QAQnD"}
@@ -0,0 +1,54 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ function normalizedOrigin(origin) {
13
+ return origin.replace(/\/$/, "");
14
+ }
15
+ function getOrCreateQueue() {
16
+ if (window.MakeASlot)
17
+ return window.MakeASlot;
18
+ const queued = ((command, options) => {
19
+ var _a;
20
+ queued.q = (_a = queued.q) !== null && _a !== void 0 ? _a : [];
21
+ queued.q.push(options === undefined ? [command] : [command, options]);
22
+ });
23
+ window.MakeASlot = queued;
24
+ return queued;
25
+ }
26
+ function ensureScript(scriptSrc) {
27
+ const absoluteSrc = new URL(scriptSrc, window.location.href).href;
28
+ const existing = Array.from(document.scripts).find((script) => script.src === absoluteSrc);
29
+ if (existing)
30
+ return;
31
+ const script = document.createElement("script");
32
+ script.src = absoluteSrc;
33
+ script.async = true;
34
+ script.dataset.makeASlotEmbed = "true";
35
+ document.head.appendChild(script);
36
+ }
37
+ /** Loads the MakeASlot embed script if necessary and returns its global command API. */
38
+ export function loadMakeASlot(options) {
39
+ var _a;
40
+ if (typeof window === "undefined")
41
+ return undefined;
42
+ const api = getOrCreateQueue();
43
+ ensureScript((_a = options.scriptSrc) !== null && _a !== void 0 ? _a : `${normalizedOrigin(options.origin)}/embed.js`);
44
+ return api;
45
+ }
46
+ /** Opens the existing MakeASlot modal or drawer for a booking link. */
47
+ export function openMakeASlot(options) {
48
+ const api = loadMakeASlot(options);
49
+ if (!api)
50
+ return;
51
+ const { scriptSrc: _scriptSrc } = options, bookingOptions = __rest(options, ["scriptSrc"]);
52
+ api("init", bookingOptions);
53
+ api("open");
54
+ }
@@ -0,0 +1,26 @@
1
+ import type { ButtonHTMLAttributes, ReactNode } from "react";
2
+ export type MakeASlotPresentation = "modal" | "drawer";
3
+ export type MakeASlotTheme = "light" | "dark";
4
+ export interface MakeASlotOptions {
5
+ /** The domain where embed.js and the booking page are hosted. */
6
+ origin: string;
7
+ /** The booking-link slug, or a complete booking-link URL. */
8
+ makeASlotLink: string;
9
+ /** Opens the existing booking experience as a modal or a right-side drawer. */
10
+ presentation?: MakeASlotPresentation;
11
+ theme?: MakeASlotTheme;
12
+ brandName?: string;
13
+ logoUrl?: string;
14
+ }
15
+ export interface MakeASlotButtonProps extends MakeASlotOptions, Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
16
+ /** Overrides the default `${origin}/embed.js` loader URL. */
17
+ scriptSrc?: string;
18
+ children?: ReactNode;
19
+ }
20
+ export type MakeASlotCommand = "init" | "open" | "close";
21
+ export interface MakeASlotApi {
22
+ (command: "init", options: MakeASlotOptions): void;
23
+ (command: "open" | "close"): void;
24
+ q?: unknown[][];
25
+ }
26
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7D,MAAM,MAAM,qBAAqB,GAAG,OAAO,GAAG,QAAQ,CAAC;AACvD,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,MAAM,CAAC;AAE9C,MAAM,WAAW,gBAAgB;IAC/B,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,aAAa,EAAE,MAAM,CAAC;IACtB,+EAA+E;IAC/E,YAAY,CAAC,EAAE,qBAAqB,CAAC;IACrC,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,oBACf,SAAQ,gBAAgB,EACtB,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,CAAC;IAC3D,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEzD,MAAM,WAAW,YAAY;IAC3B,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACnD,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;IAClC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC;CACjB"}
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@makeaslot/react",
3
+ "version": "0.1.0",
4
+ "description": "React controls for opening MakeASlot booking modals and drawers.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md"
17
+ ],
18
+ "sideEffects": false,
19
+ "peerDependencies": {
20
+ "react": ">=18.2.0 <21"
21
+ },
22
+ "devDependencies": {
23
+ "@types/react": "^19.0.0",
24
+ "typescript": "^5.0.0"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "scripts": {
30
+ "build": "tsc -p tsconfig.json",
31
+ "prepack": "npm run build",
32
+ "pack:check": "npm pack --dry-run"
33
+ }
34
+ }