@seatlayer/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 +62 -0
- package/dist/index.cjs +75 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +31 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/package.json +36 -0
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @seatlayer/react
|
|
2
|
+
|
|
3
|
+
React component for the [SeatLayer](https://seatlayer.io) embed SDK. Render an
|
|
4
|
+
interactive seat map, let buyers select and **hold** seats in the browser, then
|
|
5
|
+
**book** them from your server. Full docs: <https://docs.seatlayer.io>
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @seatlayer/react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { useRef } from 'react';
|
|
15
|
+
import { SeatingChart, type SeatingChartHandle } from '@seatlayer/react';
|
|
16
|
+
|
|
17
|
+
export function Checkout() {
|
|
18
|
+
const chart = useRef<SeatingChartHandle>(null);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<SeatingChart
|
|
22
|
+
ref={chart}
|
|
23
|
+
event="ev_9f3a"
|
|
24
|
+
style={{ width: '100%', height: 520 }}
|
|
25
|
+
onSelectionChange={(seats) => console.log('selected', seats)}
|
|
26
|
+
onHold={({ holdId }) => bookOnYourServer(holdId)}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Drive it imperatively through the ref:
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
const hold = await chart.current?.hold(); // hold the selection (null on conflict)
|
|
36
|
+
const best = await chart.current?.bestAvailable(4); // auto-pick 4 seats and hold them
|
|
37
|
+
await chart.current?.release(); // release the current hold
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Props
|
|
41
|
+
|
|
42
|
+
Extends the vanilla SDK options minus `container` (the component owns its own mount).
|
|
43
|
+
|
|
44
|
+
| Prop | Type | Notes |
|
|
45
|
+
| --- | --- | --- |
|
|
46
|
+
| `event` | `string` | **Required.** The event key, e.g. `ev_9f3a`. |
|
|
47
|
+
| `apiBase` | `string?` | API origin. Defaults to the SeatLayer production API. |
|
|
48
|
+
| `maxSelection` | `number?` | Max seats selectable at once (default 10). |
|
|
49
|
+
| `onSelectionChange` | `(seats) => void` | Fires when the selection changes. |
|
|
50
|
+
| `onHold` | `(result) => void` | Fires when seats are held; hand `holdId` to your server. |
|
|
51
|
+
| `onError` | `(err) => void` | Fires on errors. |
|
|
52
|
+
| `className` / `style` | — | Applied to the container element. |
|
|
53
|
+
|
|
54
|
+
Changing a callback prop does **not** rebuild the canvas; only `event`, `apiBase`,
|
|
55
|
+
`maxSelection`, and `publicKey` do.
|
|
56
|
+
|
|
57
|
+
## The model
|
|
58
|
+
|
|
59
|
+
The browser **holds**; your **server books** with a secret key — a browser never
|
|
60
|
+
books directly. See the [integration guide](https://docs.seatlayer.io/getting-started/how-it-works/).
|
|
61
|
+
|
|
62
|
+
Built on [`@seatlayer/js`](https://www.npmjs.com/package/@seatlayer/js).
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
SeatingChart: () => SeatingChart
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/SeatingChart.tsx
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var import_js = require("@seatlayer/js");
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
var SeatingChart = (0, import_react.forwardRef)(
|
|
32
|
+
function SeatingChart2(props, ref) {
|
|
33
|
+
const { className, style, event, apiBase, maxSelection, publicKey } = props;
|
|
34
|
+
const containerRef = (0, import_react.useRef)(null);
|
|
35
|
+
const chartRef = (0, import_react.useRef)(null);
|
|
36
|
+
const callbacks = (0, import_react.useRef)(props);
|
|
37
|
+
callbacks.current = props;
|
|
38
|
+
(0, import_react.useEffect)(() => {
|
|
39
|
+
const el = containerRef.current;
|
|
40
|
+
if (!el) return;
|
|
41
|
+
const chart = new import_js.SeatingChart({
|
|
42
|
+
container: el,
|
|
43
|
+
event,
|
|
44
|
+
apiBase,
|
|
45
|
+
maxSelection,
|
|
46
|
+
publicKey,
|
|
47
|
+
onSelectionChange: (seats) => callbacks.current.onSelectionChange?.(seats),
|
|
48
|
+
onHold: (result) => callbacks.current.onHold?.(result),
|
|
49
|
+
onError: (err) => callbacks.current.onError?.(err)
|
|
50
|
+
});
|
|
51
|
+
chartRef.current = chart;
|
|
52
|
+
void chart.render();
|
|
53
|
+
return () => {
|
|
54
|
+
chart.destroy();
|
|
55
|
+
chartRef.current = null;
|
|
56
|
+
};
|
|
57
|
+
}, [event, apiBase, maxSelection, publicKey]);
|
|
58
|
+
(0, import_react.useImperativeHandle)(
|
|
59
|
+
ref,
|
|
60
|
+
() => ({
|
|
61
|
+
hold: () => chartRef.current?.hold() ?? Promise.resolve(null),
|
|
62
|
+
bestAvailable: (qty, categoryKey) => chartRef.current?.bestAvailable(qty, categoryKey) ?? Promise.resolve(null),
|
|
63
|
+
release: () => chartRef.current?.release() ?? Promise.resolve(),
|
|
64
|
+
getSelection: () => chartRef.current?.getSelection() ?? []
|
|
65
|
+
}),
|
|
66
|
+
[]
|
|
67
|
+
);
|
|
68
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: containerRef, className, style });
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
SeatingChart
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/SeatingChart.tsx"],"sourcesContent":["/**\n * @seatlayer/react — the React wrapper for the SeatLayer embed SDK.\n */\nexport { SeatingChart } from './SeatingChart';\nexport type {\n SeatingChartProps,\n SeatingChartHandle,\n SelectedSeat,\n HoldResult,\n BestAvailableResult,\n} from './SeatingChart';\n","import {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useRef,\n type CSSProperties,\n} from 'react';\nimport {\n SeatingChart as CoreSeatingChart,\n type SeatingChartOptions,\n type SelectedSeat,\n type HoldResult,\n type BestAvailableResult,\n} from '@seatlayer/js';\n\nexport type { SelectedSeat, HoldResult, BestAvailableResult } from '@seatlayer/js';\n\n/** Imperative handle exposed via `ref` — call these to drive the picker from your app. */\nexport interface SeatingChartHandle {\n /** Hold the current selection. Resolves the hold, or `null` on a 409 conflict. */\n hold(): Promise<HoldResult | null>;\n /** Ask the server for the `qty` best free seats and hold them atomically. */\n bestAvailable(qty: number, categoryKey?: string): Promise<BestAvailableResult | null>;\n /** Release the current hold (if any). */\n release(): Promise<void>;\n /** The current selection, with prices resolved from the chart categories. */\n getSelection(): SelectedSeat[];\n}\n\nexport interface SeatingChartProps extends Omit<SeatingChartOptions, 'container'> {\n className?: string;\n style?: CSSProperties;\n}\n\n/**\n * React wrapper around the framework-agnostic `@seatlayer/js` SDK.\n *\n * The underlying canvas is created once and torn down on unmount. Callback props\n * (`onSelectionChange`, `onHold`, `onError`) may change freely between renders\n * without re-mounting the canvas — only `event`, `apiBase`, `maxSelection`, and\n * `publicKey` trigger a rebuild.\n */\nexport const SeatingChart = forwardRef<SeatingChartHandle, SeatingChartProps>(\n function SeatingChart(props, ref) {\n const { className, style, event, apiBase, maxSelection, publicKey } = props;\n\n const containerRef = useRef<HTMLDivElement | null>(null);\n const chartRef = useRef<CoreSeatingChart | null>(null);\n\n // Always call the latest callbacks without rebuilding the chart.\n const callbacks = useRef(props);\n callbacks.current = props;\n\n useEffect(() => {\n const el = containerRef.current;\n if (!el) return;\n\n const chart = new CoreSeatingChart({\n container: el,\n event,\n apiBase,\n maxSelection,\n publicKey,\n onSelectionChange: (seats) => callbacks.current.onSelectionChange?.(seats),\n onHold: (result) => callbacks.current.onHold?.(result),\n onError: (err) => callbacks.current.onError?.(err),\n });\n chartRef.current = chart;\n void chart.render();\n\n return () => {\n chart.destroy();\n chartRef.current = null;\n };\n // Rebuild only when the identity of the chart changes.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [event, apiBase, maxSelection, publicKey]);\n\n useImperativeHandle(\n ref,\n (): SeatingChartHandle => ({\n hold: () => chartRef.current?.hold() ?? Promise.resolve(null),\n bestAvailable: (qty, categoryKey) =>\n chartRef.current?.bestAvailable(qty, categoryKey) ?? Promise.resolve(null),\n release: () => chartRef.current?.release() ?? Promise.resolve(),\n getSelection: () => chartRef.current?.getSelection() ?? [],\n }),\n [],\n );\n\n return <div ref={containerRef} className={className} style={style} />;\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAMO;AACP,gBAMO;AA6EI;AAhDJ,IAAM,mBAAe;AAAA,EAC1B,SAASA,cAAa,OAAO,KAAK;AAChC,UAAM,EAAE,WAAW,OAAO,OAAO,SAAS,cAAc,UAAU,IAAI;AAEtE,UAAM,mBAAe,qBAA8B,IAAI;AACvD,UAAM,eAAW,qBAAgC,IAAI;AAGrD,UAAM,gBAAY,qBAAO,KAAK;AAC9B,cAAU,UAAU;AAEpB,gCAAU,MAAM;AACd,YAAM,KAAK,aAAa;AACxB,UAAI,CAAC,GAAI;AAET,YAAM,QAAQ,IAAI,UAAAC,aAAiB;AAAA,QACjC,WAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,mBAAmB,CAAC,UAAU,UAAU,QAAQ,oBAAoB,KAAK;AAAA,QACzE,QAAQ,CAAC,WAAW,UAAU,QAAQ,SAAS,MAAM;AAAA,QACrD,SAAS,CAAC,QAAQ,UAAU,QAAQ,UAAU,GAAG;AAAA,MACnD,CAAC;AACD,eAAS,UAAU;AACnB,WAAK,MAAM,OAAO;AAElB,aAAO,MAAM;AACX,cAAM,QAAQ;AACd,iBAAS,UAAU;AAAA,MACrB;AAAA,IAGF,GAAG,CAAC,OAAO,SAAS,cAAc,SAAS,CAAC;AAE5C;AAAA,MACE;AAAA,MACA,OAA2B;AAAA,QACzB,MAAM,MAAM,SAAS,SAAS,KAAK,KAAK,QAAQ,QAAQ,IAAI;AAAA,QAC5D,eAAe,CAAC,KAAK,gBACnB,SAAS,SAAS,cAAc,KAAK,WAAW,KAAK,QAAQ,QAAQ,IAAI;AAAA,QAC3E,SAAS,MAAM,SAAS,SAAS,QAAQ,KAAK,QAAQ,QAAQ;AAAA,QAC9D,cAAc,MAAM,SAAS,SAAS,aAAa,KAAK,CAAC;AAAA,MAC3D;AAAA,MACA,CAAC;AAAA,IACH;AAEA,WAAO,4CAAC,SAAI,KAAK,cAAc,WAAsB,OAAc;AAAA,EACrE;AACF;","names":["SeatingChart","CoreSeatingChart"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
3
|
+
import { SeatingChartOptions, HoldResult, BestAvailableResult, SelectedSeat } from '@seatlayer/js';
|
|
4
|
+
export { BestAvailableResult, HoldResult, SelectedSeat } from '@seatlayer/js';
|
|
5
|
+
|
|
6
|
+
/** Imperative handle exposed via `ref` — call these to drive the picker from your app. */
|
|
7
|
+
interface SeatingChartHandle {
|
|
8
|
+
/** Hold the current selection. Resolves the hold, or `null` on a 409 conflict. */
|
|
9
|
+
hold(): Promise<HoldResult | null>;
|
|
10
|
+
/** Ask the server for the `qty` best free seats and hold them atomically. */
|
|
11
|
+
bestAvailable(qty: number, categoryKey?: string): Promise<BestAvailableResult | null>;
|
|
12
|
+
/** Release the current hold (if any). */
|
|
13
|
+
release(): Promise<void>;
|
|
14
|
+
/** The current selection, with prices resolved from the chart categories. */
|
|
15
|
+
getSelection(): SelectedSeat[];
|
|
16
|
+
}
|
|
17
|
+
interface SeatingChartProps extends Omit<SeatingChartOptions, 'container'> {
|
|
18
|
+
className?: string;
|
|
19
|
+
style?: CSSProperties;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* React wrapper around the framework-agnostic `@seatlayer/js` SDK.
|
|
23
|
+
*
|
|
24
|
+
* The underlying canvas is created once and torn down on unmount. Callback props
|
|
25
|
+
* (`onSelectionChange`, `onHold`, `onError`) may change freely between renders
|
|
26
|
+
* without re-mounting the canvas — only `event`, `apiBase`, `maxSelection`, and
|
|
27
|
+
* `publicKey` trigger a rebuild.
|
|
28
|
+
*/
|
|
29
|
+
declare const SeatingChart: react.ForwardRefExoticComponent<SeatingChartProps & react.RefAttributes<SeatingChartHandle>>;
|
|
30
|
+
|
|
31
|
+
export { SeatingChart, type SeatingChartHandle, type SeatingChartProps };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
3
|
+
import { SeatingChartOptions, HoldResult, BestAvailableResult, SelectedSeat } from '@seatlayer/js';
|
|
4
|
+
export { BestAvailableResult, HoldResult, SelectedSeat } from '@seatlayer/js';
|
|
5
|
+
|
|
6
|
+
/** Imperative handle exposed via `ref` — call these to drive the picker from your app. */
|
|
7
|
+
interface SeatingChartHandle {
|
|
8
|
+
/** Hold the current selection. Resolves the hold, or `null` on a 409 conflict. */
|
|
9
|
+
hold(): Promise<HoldResult | null>;
|
|
10
|
+
/** Ask the server for the `qty` best free seats and hold them atomically. */
|
|
11
|
+
bestAvailable(qty: number, categoryKey?: string): Promise<BestAvailableResult | null>;
|
|
12
|
+
/** Release the current hold (if any). */
|
|
13
|
+
release(): Promise<void>;
|
|
14
|
+
/** The current selection, with prices resolved from the chart categories. */
|
|
15
|
+
getSelection(): SelectedSeat[];
|
|
16
|
+
}
|
|
17
|
+
interface SeatingChartProps extends Omit<SeatingChartOptions, 'container'> {
|
|
18
|
+
className?: string;
|
|
19
|
+
style?: CSSProperties;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* React wrapper around the framework-agnostic `@seatlayer/js` SDK.
|
|
23
|
+
*
|
|
24
|
+
* The underlying canvas is created once and torn down on unmount. Callback props
|
|
25
|
+
* (`onSelectionChange`, `onHold`, `onError`) may change freely between renders
|
|
26
|
+
* without re-mounting the canvas — only `event`, `apiBase`, `maxSelection`, and
|
|
27
|
+
* `publicKey` trigger a rebuild.
|
|
28
|
+
*/
|
|
29
|
+
declare const SeatingChart: react.ForwardRefExoticComponent<SeatingChartProps & react.RefAttributes<SeatingChartHandle>>;
|
|
30
|
+
|
|
31
|
+
export { SeatingChart, type SeatingChartHandle, type SeatingChartProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// src/SeatingChart.tsx
|
|
2
|
+
import {
|
|
3
|
+
forwardRef,
|
|
4
|
+
useEffect,
|
|
5
|
+
useImperativeHandle,
|
|
6
|
+
useRef
|
|
7
|
+
} from "react";
|
|
8
|
+
import {
|
|
9
|
+
SeatingChart as CoreSeatingChart
|
|
10
|
+
} from "@seatlayer/js";
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
12
|
+
var SeatingChart = forwardRef(
|
|
13
|
+
function SeatingChart2(props, ref) {
|
|
14
|
+
const { className, style, event, apiBase, maxSelection, publicKey } = props;
|
|
15
|
+
const containerRef = useRef(null);
|
|
16
|
+
const chartRef = useRef(null);
|
|
17
|
+
const callbacks = useRef(props);
|
|
18
|
+
callbacks.current = props;
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const el = containerRef.current;
|
|
21
|
+
if (!el) return;
|
|
22
|
+
const chart = new CoreSeatingChart({
|
|
23
|
+
container: el,
|
|
24
|
+
event,
|
|
25
|
+
apiBase,
|
|
26
|
+
maxSelection,
|
|
27
|
+
publicKey,
|
|
28
|
+
onSelectionChange: (seats) => callbacks.current.onSelectionChange?.(seats),
|
|
29
|
+
onHold: (result) => callbacks.current.onHold?.(result),
|
|
30
|
+
onError: (err) => callbacks.current.onError?.(err)
|
|
31
|
+
});
|
|
32
|
+
chartRef.current = chart;
|
|
33
|
+
void chart.render();
|
|
34
|
+
return () => {
|
|
35
|
+
chart.destroy();
|
|
36
|
+
chartRef.current = null;
|
|
37
|
+
};
|
|
38
|
+
}, [event, apiBase, maxSelection, publicKey]);
|
|
39
|
+
useImperativeHandle(
|
|
40
|
+
ref,
|
|
41
|
+
() => ({
|
|
42
|
+
hold: () => chartRef.current?.hold() ?? Promise.resolve(null),
|
|
43
|
+
bestAvailable: (qty, categoryKey) => chartRef.current?.bestAvailable(qty, categoryKey) ?? Promise.resolve(null),
|
|
44
|
+
release: () => chartRef.current?.release() ?? Promise.resolve(),
|
|
45
|
+
getSelection: () => chartRef.current?.getSelection() ?? []
|
|
46
|
+
}),
|
|
47
|
+
[]
|
|
48
|
+
);
|
|
49
|
+
return /* @__PURE__ */ jsx("div", { ref: containerRef, className, style });
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
export {
|
|
53
|
+
SeatingChart
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/SeatingChart.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useRef,\n type CSSProperties,\n} from 'react';\nimport {\n SeatingChart as CoreSeatingChart,\n type SeatingChartOptions,\n type SelectedSeat,\n type HoldResult,\n type BestAvailableResult,\n} from '@seatlayer/js';\n\nexport type { SelectedSeat, HoldResult, BestAvailableResult } from '@seatlayer/js';\n\n/** Imperative handle exposed via `ref` — call these to drive the picker from your app. */\nexport interface SeatingChartHandle {\n /** Hold the current selection. Resolves the hold, or `null` on a 409 conflict. */\n hold(): Promise<HoldResult | null>;\n /** Ask the server for the `qty` best free seats and hold them atomically. */\n bestAvailable(qty: number, categoryKey?: string): Promise<BestAvailableResult | null>;\n /** Release the current hold (if any). */\n release(): Promise<void>;\n /** The current selection, with prices resolved from the chart categories. */\n getSelection(): SelectedSeat[];\n}\n\nexport interface SeatingChartProps extends Omit<SeatingChartOptions, 'container'> {\n className?: string;\n style?: CSSProperties;\n}\n\n/**\n * React wrapper around the framework-agnostic `@seatlayer/js` SDK.\n *\n * The underlying canvas is created once and torn down on unmount. Callback props\n * (`onSelectionChange`, `onHold`, `onError`) may change freely between renders\n * without re-mounting the canvas — only `event`, `apiBase`, `maxSelection`, and\n * `publicKey` trigger a rebuild.\n */\nexport const SeatingChart = forwardRef<SeatingChartHandle, SeatingChartProps>(\n function SeatingChart(props, ref) {\n const { className, style, event, apiBase, maxSelection, publicKey } = props;\n\n const containerRef = useRef<HTMLDivElement | null>(null);\n const chartRef = useRef<CoreSeatingChart | null>(null);\n\n // Always call the latest callbacks without rebuilding the chart.\n const callbacks = useRef(props);\n callbacks.current = props;\n\n useEffect(() => {\n const el = containerRef.current;\n if (!el) return;\n\n const chart = new CoreSeatingChart({\n container: el,\n event,\n apiBase,\n maxSelection,\n publicKey,\n onSelectionChange: (seats) => callbacks.current.onSelectionChange?.(seats),\n onHold: (result) => callbacks.current.onHold?.(result),\n onError: (err) => callbacks.current.onError?.(err),\n });\n chartRef.current = chart;\n void chart.render();\n\n return () => {\n chart.destroy();\n chartRef.current = null;\n };\n // Rebuild only when the identity of the chart changes.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [event, apiBase, maxSelection, publicKey]);\n\n useImperativeHandle(\n ref,\n (): SeatingChartHandle => ({\n hold: () => chartRef.current?.hold() ?? Promise.resolve(null),\n bestAvailable: (qty, categoryKey) =>\n chartRef.current?.bestAvailable(qty, categoryKey) ?? Promise.resolve(null),\n release: () => chartRef.current?.release() ?? Promise.resolve(),\n getSelection: () => chartRef.current?.getSelection() ?? [],\n }),\n [],\n );\n\n return <div ref={containerRef} className={className} style={style} />;\n },\n);\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EACE,gBAAgB;AAAA,OAKX;AA6EI;AAhDJ,IAAM,eAAe;AAAA,EAC1B,SAASA,cAAa,OAAO,KAAK;AAChC,UAAM,EAAE,WAAW,OAAO,OAAO,SAAS,cAAc,UAAU,IAAI;AAEtE,UAAM,eAAe,OAA8B,IAAI;AACvD,UAAM,WAAW,OAAgC,IAAI;AAGrD,UAAM,YAAY,OAAO,KAAK;AAC9B,cAAU,UAAU;AAEpB,cAAU,MAAM;AACd,YAAM,KAAK,aAAa;AACxB,UAAI,CAAC,GAAI;AAET,YAAM,QAAQ,IAAI,iBAAiB;AAAA,QACjC,WAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,mBAAmB,CAAC,UAAU,UAAU,QAAQ,oBAAoB,KAAK;AAAA,QACzE,QAAQ,CAAC,WAAW,UAAU,QAAQ,SAAS,MAAM;AAAA,QACrD,SAAS,CAAC,QAAQ,UAAU,QAAQ,UAAU,GAAG;AAAA,MACnD,CAAC;AACD,eAAS,UAAU;AACnB,WAAK,MAAM,OAAO;AAElB,aAAO,MAAM;AACX,cAAM,QAAQ;AACd,iBAAS,UAAU;AAAA,MACrB;AAAA,IAGF,GAAG,CAAC,OAAO,SAAS,cAAc,SAAS,CAAC;AAE5C;AAAA,MACE;AAAA,MACA,OAA2B;AAAA,QACzB,MAAM,MAAM,SAAS,SAAS,KAAK,KAAK,QAAQ,QAAQ,IAAI;AAAA,QAC5D,eAAe,CAAC,KAAK,gBACnB,SAAS,SAAS,cAAc,KAAK,WAAW,KAAK,QAAQ,QAAQ,IAAI;AAAA,QAC3E,SAAS,MAAM,SAAS,SAAS,QAAQ,KAAK,QAAQ,QAAQ;AAAA,QAC9D,cAAc,MAAM,SAAS,SAAS,aAAa,KAAK,CAAC;AAAA,MAC3D;AAAA,MACA,CAAC;AAAA,IACH;AAEA,WAAO,oBAAC,SAAI,KAAK,cAAc,WAAsB,OAAc;AAAA,EACrE;AACF;","names":["SeatingChart"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@seatlayer/react",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React component for the SeatLayer embed SDK — render an interactive seat picker and hold seats.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": ["dist"],
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"keywords": ["seating", "seat-map", "seatlayer", "react", "ticketing"],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsup",
|
|
22
|
+
"typecheck": "tsc --noEmit"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@seatlayer/js": "workspace:*"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"react": ">=17.0.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/react": "^19.0.0",
|
|
32
|
+
"react": "^19.0.0",
|
|
33
|
+
"tsup": "^8.5.1",
|
|
34
|
+
"typescript": "^5.9.0"
|
|
35
|
+
}
|
|
36
|
+
}
|