@makeaslot/react 0.1.0 → 0.1.1
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 +24 -18
- package/dist/MakeASlotFloatingButton.d.ts +7 -0
- package/dist/MakeASlotFloatingButton.d.ts.map +1 -0
- package/dist/MakeASlotFloatingButton.js +43 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/script-loader.d.ts +1 -0
- package/dist/script-loader.d.ts.map +1 -1
- package/dist/script-loader.js +3 -2
- package/dist/types.d.ts +12 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @makeaslot/react
|
|
2
2
|
|
|
3
|
-
React controls for the hosted MakeASlot booking experience.
|
|
3
|
+
React controls for the hosted MakeASlot booking experience.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -8,29 +8,41 @@ React controls for the hosted MakeASlot booking experience. The package loads th
|
|
|
8
8
|
npm install @makeaslot/react
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Default floating button
|
|
12
12
|
|
|
13
13
|
```tsx
|
|
14
|
-
import {
|
|
14
|
+
import { MakeASlotFloatingButton } from "@makeaslot/react";
|
|
15
15
|
|
|
16
|
-
export function
|
|
16
|
+
export function BookingEmbed() {
|
|
17
17
|
return (
|
|
18
|
-
<
|
|
19
|
-
origin="https://appointix.duckdns.org"
|
|
18
|
+
<MakeASlotFloatingButton
|
|
20
19
|
makeASlotLink="joe-consultancy/discovery-call"
|
|
21
20
|
presentation="modal"
|
|
22
21
|
theme="dark"
|
|
23
22
|
brandName="Joe Consultancy"
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
position="bottom-right"
|
|
24
|
+
buttonColor="#2BCEFF"
|
|
25
|
+
buttonTextColor="#003935"
|
|
26
26
|
>
|
|
27
27
|
Book now
|
|
28
|
-
</
|
|
28
|
+
</MakeASlotFloatingButton>
|
|
29
29
|
);
|
|
30
30
|
}
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
Set `presentation="drawer"` to
|
|
33
|
+
It displays a fixed call-to-action and opens the hosted booking experience. Set `presentation="drawer"` to use the right-side drawer instead.
|
|
34
|
+
|
|
35
|
+
## Button in your own layout
|
|
36
|
+
|
|
37
|
+
Use `MakeASlotButton` when the call-to-action should appear within your page rather than float above it.
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { MakeASlotButton } from "@makeaslot/react";
|
|
41
|
+
|
|
42
|
+
<MakeASlotButton makeASlotLink="joe-consultancy/discovery-call">
|
|
43
|
+
Book a discovery call
|
|
44
|
+
</MakeASlotButton>
|
|
45
|
+
```
|
|
34
46
|
|
|
35
47
|
For custom triggers, use `openMakeASlot`:
|
|
36
48
|
|
|
@@ -38,12 +50,13 @@ For custom triggers, use `openMakeASlot`:
|
|
|
38
50
|
import { openMakeASlot } from "@makeaslot/react";
|
|
39
51
|
|
|
40
52
|
openMakeASlot({
|
|
41
|
-
origin: "https://appointix.duckdns.org",
|
|
42
53
|
makeASlotLink: "joe-consultancy/discovery-call",
|
|
43
54
|
presentation: "modal",
|
|
44
55
|
});
|
|
45
56
|
```
|
|
46
57
|
|
|
58
|
+
`origin` is optional and defaults to MakeASlot's production host. Provide it only for an advanced setup, such as staging or a future custom host.
|
|
59
|
+
|
|
47
60
|
## Build and test locally
|
|
48
61
|
|
|
49
62
|
```bash
|
|
@@ -51,10 +64,3 @@ cd packages/react
|
|
|
51
64
|
npm run build
|
|
52
65
|
npm run pack:check
|
|
53
66
|
```
|
|
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 { MakeASlotFloatingButtonProps } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The default fixed-position embed CTA. It opens MakeASlot's hosted modal or
|
|
4
|
+
* drawer and does not render the booking experience inline.
|
|
5
|
+
*/
|
|
6
|
+
export declare function MakeASlotFloatingButton({ children, onClick, origin, makeASlotLink, presentation, theme, brandName, logoUrl, scriptSrc, position, buttonColor, buttonTextColor, style, type, ...buttonProps }: MakeASlotFloatingButtonProps): import("react").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=MakeASlotFloatingButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MakeASlotFloatingButton.d.ts","sourceRoot":"","sources":["../src/MakeASlotFloatingButton.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,4BAA4B,EAC7B,MAAM,YAAY,CAAC;AAOpB;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,QAAqB,EACrB,OAAO,EACP,MAAM,EACN,aAAa,EACb,YAAsB,EACtB,KAAe,EACf,SAAS,EACT,OAAO,EACP,SAAS,EACT,QAAyB,EACzB,WAAuB,EACvB,eAA2B,EAC3B,KAAK,EACL,IAAe,EACf,GAAG,WAAW,EACf,EAAE,4BAA4B,+BAyC9B"}
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
const positionStyles = {
|
|
17
|
+
"bottom-right": { right: 20, bottom: 20 },
|
|
18
|
+
"bottom-left": { left: 20, bottom: 20 },
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The default fixed-position embed CTA. It opens MakeASlot's hosted modal or
|
|
22
|
+
* drawer and does not render the booking experience inline.
|
|
23
|
+
*/
|
|
24
|
+
export function MakeASlotFloatingButton(_a) {
|
|
25
|
+
var { children = "Book now", onClick, origin, makeASlotLink, presentation = "modal", theme = "light", brandName, logoUrl, scriptSrc, position = "bottom-right", buttonColor = "#111111", buttonTextColor = "#ffffff", style, type = "button" } = _a, buttonProps = __rest(_a, ["children", "onClick", "origin", "makeASlotLink", "presentation", "theme", "brandName", "logoUrl", "scriptSrc", "position", "buttonColor", "buttonTextColor", "style", "type"]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
loadMakeASlot({ origin, scriptSrc });
|
|
28
|
+
}, [origin, scriptSrc]);
|
|
29
|
+
return (_jsx("button", Object.assign({}, buttonProps, { type: type, style: Object.assign(Object.assign({ position: "fixed", zIndex: 2147482999, border: 0, borderRadius: 9999, padding: "12px 18px", backgroundColor: buttonColor, color: buttonTextColor, font: "600 14px system-ui, sans-serif", cursor: "pointer", boxShadow: "0 8px 24px rgba(0, 0, 0, 0.2)" }, positionStyles[position]), style), onClick: (event) => {
|
|
30
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
31
|
+
if (event.defaultPrevented)
|
|
32
|
+
return;
|
|
33
|
+
openMakeASlot({
|
|
34
|
+
origin,
|
|
35
|
+
makeASlotLink,
|
|
36
|
+
presentation,
|
|
37
|
+
theme,
|
|
38
|
+
brandName,
|
|
39
|
+
logoUrl,
|
|
40
|
+
scriptSrc,
|
|
41
|
+
});
|
|
42
|
+
}, children: children })));
|
|
43
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { MakeASlotButton } from "./MakeASlotButton.js";
|
|
2
|
-
export {
|
|
3
|
-
export
|
|
2
|
+
export { MakeASlotFloatingButton } from "./MakeASlotFloatingButton.js";
|
|
3
|
+
export { DEFAULT_MAKE_A_SLOT_ORIGIN, loadMakeASlot, openMakeASlot, } from "./script-loader.js";
|
|
4
|
+
export type { MakeASlotApi, MakeASlotButtonProps, MakeASlotFloatingButtonPosition, MakeASlotFloatingButtonProps, MakeASlotOptions, MakeASlotPresentation, MakeASlotTheme, } from "./types.js";
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
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,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EACL,0BAA0B,EAC1B,aAAa,EACb,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,YAAY,EACZ,oBAAoB,EACpB,+BAA+B,EAC/B,4BAA4B,EAC5B,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,GACf,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
export { MakeASlotButton } from "./MakeASlotButton.js";
|
|
3
|
-
export {
|
|
3
|
+
export { MakeASlotFloatingButton } from "./MakeASlotFloatingButton.js";
|
|
4
|
+
export { DEFAULT_MAKE_A_SLOT_ORIGIN, loadMakeASlot, openMakeASlot, } from "./script-loader.js";
|
package/dist/script-loader.d.ts
CHANGED
|
@@ -1 +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,
|
|
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,eAAO,MAAM,0BAA0B,kCAAkC,CAAC;AAE1E,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,4BAQ/F;AAED,uEAAuE;AACvE,wBAAgB,aAAa,CAC3B,OAAO,EAAE,gBAAgB,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,QAWnD"}
|
package/dist/script-loader.js
CHANGED
|
@@ -9,7 +9,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
export const DEFAULT_MAKE_A_SLOT_ORIGIN = "https://appointix.duckdns.org";
|
|
13
|
+
function normalizedOrigin(origin = DEFAULT_MAKE_A_SLOT_ORIGIN) {
|
|
13
14
|
return origin.replace(/\/$/, "");
|
|
14
15
|
}
|
|
15
16
|
function getOrCreateQueue() {
|
|
@@ -49,6 +50,6 @@ export function openMakeASlot(options) {
|
|
|
49
50
|
if (!api)
|
|
50
51
|
return;
|
|
51
52
|
const { scriptSrc: _scriptSrc } = options, bookingOptions = __rest(options, ["scriptSrc"]);
|
|
52
|
-
api("init", bookingOptions);
|
|
53
|
+
api("init", Object.assign(Object.assign({}, bookingOptions), { origin: normalizedOrigin(bookingOptions.origin) }));
|
|
53
54
|
api("open");
|
|
54
55
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { ButtonHTMLAttributes, ReactNode } from "react";
|
|
2
2
|
export type MakeASlotPresentation = "modal" | "drawer";
|
|
3
3
|
export type MakeASlotTheme = "light" | "dark";
|
|
4
|
+
export type MakeASlotFloatingButtonPosition = "bottom-right" | "bottom-left";
|
|
4
5
|
export interface MakeASlotOptions {
|
|
5
|
-
/**
|
|
6
|
-
origin
|
|
6
|
+
/** Overrides the default MakeASlot production host. */
|
|
7
|
+
origin?: string;
|
|
7
8
|
/** The booking-link slug, or a complete booking-link URL. */
|
|
8
9
|
makeASlotLink: string;
|
|
9
10
|
/** Opens the existing booking experience as a modal or a right-side drawer. */
|
|
@@ -17,6 +18,15 @@ export interface MakeASlotButtonProps extends MakeASlotOptions, Omit<ButtonHTMLA
|
|
|
17
18
|
scriptSrc?: string;
|
|
18
19
|
children?: ReactNode;
|
|
19
20
|
}
|
|
21
|
+
export interface MakeASlotFloatingButtonProps extends MakeASlotOptions, Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
|
|
22
|
+
/** Overrides the default production embed script URL. */
|
|
23
|
+
scriptSrc?: string;
|
|
24
|
+
/** The label displayed in the floating call-to-action button. */
|
|
25
|
+
children?: ReactNode;
|
|
26
|
+
position?: MakeASlotFloatingButtonPosition;
|
|
27
|
+
buttonColor?: string;
|
|
28
|
+
buttonTextColor?: string;
|
|
29
|
+
}
|
|
20
30
|
export type MakeASlotCommand = "init" | "open" | "close";
|
|
21
31
|
export interface MakeASlotApi {
|
|
22
32
|
(command: "init", options: MakeASlotOptions): void;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +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;
|
|
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;AAC9C,MAAM,MAAM,+BAA+B,GAAG,cAAc,GAAG,aAAa,CAAC;AAE7E,MAAM,WAAW,gBAAgB;IAC/B,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,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,WAAW,4BACf,SAAQ,gBAAgB,EACtB,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,CAAC;IAC3D,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,QAAQ,CAAC,EAAE,+BAA+B,CAAC;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;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"}
|