@seatsio/seatsio-react 14.2.0 → 14.4.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/build/Embeddable.d.mts +8 -7
- package/build/Embeddable.d.ts +8 -7
- package/build/Embeddable.js +123 -1
- package/build/Embeddable.js.map +1 -1
- package/build/Embeddable.mjs +93 -1
- package/build/Embeddable.mjs.map +1 -1
- package/build/SeatsioDesigner.js +132 -1
- package/build/SeatsioDesigner.js.map +1 -1
- package/build/SeatsioDesigner.mjs +100 -1
- package/build/SeatsioDesigner.mjs.map +1 -1
- package/build/SeatsioEventManager.js +132 -1
- package/build/SeatsioEventManager.js.map +1 -1
- package/build/SeatsioEventManager.mjs +100 -1
- package/build/SeatsioEventManager.mjs.map +1 -1
- package/build/SeatsioSeatingChart.js +132 -1
- package/build/SeatsioSeatingChart.js.map +1 -1
- package/build/SeatsioSeatingChart.mjs +100 -1
- package/build/SeatsioSeatingChart.mjs.map +1 -1
- package/build/index.js +169 -1
- package/build/index.js.map +1 -1
- package/build/index.mjs +126 -1
- package/build/index.mjs.map +1 -1
- package/build/util.js +61 -1
- package/build/util.js.map +1 -1
- package/build/util.mjs +32 -1
- package/build/util.mjs.map +1 -1
- package/package.json +7 -7
package/build/Embeddable.d.mts
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { SeatingChart, Region, CommonConfigOptions, Seatsio,
|
|
2
|
+
import { SeatingChart, EventManager, Region, CommonConfigOptions, Seatsio, ChartDesigner } from '@seatsio/seatsio-types';
|
|
3
3
|
|
|
4
4
|
type EmbeddableProps<T> = {
|
|
5
|
-
onRenderStarted?: (chart: SeatingChart) => void;
|
|
5
|
+
onRenderStarted?: (chart: SeatingChart | EventManager) => void;
|
|
6
6
|
chartJsUrl?: string;
|
|
7
7
|
region: Region;
|
|
8
8
|
} & T;
|
|
9
9
|
declare abstract class Embeddable<T extends CommonConfigOptions> extends React.Component<EmbeddableProps<T>> {
|
|
10
10
|
private container;
|
|
11
|
-
private rendering?;
|
|
12
11
|
private chart;
|
|
12
|
+
private firstRender;
|
|
13
|
+
private static seatsioBundles;
|
|
13
14
|
static defaultProps: {
|
|
14
15
|
chartJsUrl: string;
|
|
15
16
|
};
|
|
16
17
|
constructor(props: EmbeddableProps<T>);
|
|
17
18
|
abstract createChart(seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner;
|
|
18
|
-
componentDidMount():
|
|
19
|
-
componentDidUpdate(prevProps: EmbeddableProps<T>):
|
|
19
|
+
componentDidMount(): void;
|
|
20
|
+
componentDidUpdate(prevProps: EmbeddableProps<T>): void;
|
|
21
|
+
getChartUrl(): string;
|
|
20
22
|
createAndRenderChart(): Promise<void>;
|
|
21
23
|
extractConfigFromProps(): any;
|
|
22
24
|
componentWillUnmount(): void;
|
|
23
25
|
destroyChart(): void;
|
|
24
|
-
|
|
25
|
-
loadSeatsio(): Promise<unknown>;
|
|
26
|
+
loadSeatsio(): Promise<Seatsio>;
|
|
26
27
|
render(): React.ReactNode;
|
|
27
28
|
}
|
|
28
29
|
|
package/build/Embeddable.d.ts
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { SeatingChart, Region, CommonConfigOptions, Seatsio,
|
|
2
|
+
import { SeatingChart, EventManager, Region, CommonConfigOptions, Seatsio, ChartDesigner } from '@seatsio/seatsio-types';
|
|
3
3
|
|
|
4
4
|
type EmbeddableProps<T> = {
|
|
5
|
-
onRenderStarted?: (chart: SeatingChart) => void;
|
|
5
|
+
onRenderStarted?: (chart: SeatingChart | EventManager) => void;
|
|
6
6
|
chartJsUrl?: string;
|
|
7
7
|
region: Region;
|
|
8
8
|
} & T;
|
|
9
9
|
declare abstract class Embeddable<T extends CommonConfigOptions> extends React.Component<EmbeddableProps<T>> {
|
|
10
10
|
private container;
|
|
11
|
-
private rendering?;
|
|
12
11
|
private chart;
|
|
12
|
+
private firstRender;
|
|
13
|
+
private static seatsioBundles;
|
|
13
14
|
static defaultProps: {
|
|
14
15
|
chartJsUrl: string;
|
|
15
16
|
};
|
|
16
17
|
constructor(props: EmbeddableProps<T>);
|
|
17
18
|
abstract createChart(seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner;
|
|
18
|
-
componentDidMount():
|
|
19
|
-
componentDidUpdate(prevProps: EmbeddableProps<T>):
|
|
19
|
+
componentDidMount(): void;
|
|
20
|
+
componentDidUpdate(prevProps: EmbeddableProps<T>): void;
|
|
21
|
+
getChartUrl(): string;
|
|
20
22
|
createAndRenderChart(): Promise<void>;
|
|
21
23
|
extractConfigFromProps(): any;
|
|
22
24
|
componentWillUnmount(): void;
|
|
23
25
|
destroyChart(): void;
|
|
24
|
-
|
|
25
|
-
loadSeatsio(): Promise<unknown>;
|
|
26
|
+
loadSeatsio(): Promise<Seatsio>;
|
|
26
27
|
render(): React.ReactNode;
|
|
27
28
|
}
|
|
28
29
|
|
package/build/Embeddable.js
CHANGED
|
@@ -1,2 +1,124 @@
|
|
|
1
|
-
var
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/main/Embeddable.tsx
|
|
30
|
+
var Embeddable_exports = {};
|
|
31
|
+
__export(Embeddable_exports, {
|
|
32
|
+
default: () => Embeddable
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(Embeddable_exports);
|
|
35
|
+
var React = __toESM(require("react"));
|
|
36
|
+
|
|
37
|
+
// src/main/util.ts
|
|
38
|
+
var didPropsChange = (prevProps, nextProps) => {
|
|
39
|
+
if (Object.keys(prevProps).length !== Object.keys(nextProps).length) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
return Object.keys(nextProps).some((propName) => {
|
|
43
|
+
let prevValue = prevProps[propName];
|
|
44
|
+
let nextValue = nextProps[propName];
|
|
45
|
+
if (prevValue && nextValue) {
|
|
46
|
+
if (typeof prevValue === "function" && typeof nextValue === "function") {
|
|
47
|
+
return prevValue.toString() !== nextValue.toString();
|
|
48
|
+
}
|
|
49
|
+
if (typeof prevValue === "object" && typeof nextValue === "object") {
|
|
50
|
+
return didPropsChange(prevValue, nextValue);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return prevValue !== nextValue;
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// src/main/Embeddable.tsx
|
|
58
|
+
var _Embeddable = class _Embeddable extends React.Component {
|
|
59
|
+
constructor(props) {
|
|
60
|
+
super(props);
|
|
61
|
+
this.container = React.createRef();
|
|
62
|
+
this.firstRender = true;
|
|
63
|
+
}
|
|
64
|
+
componentDidMount() {
|
|
65
|
+
if (!_Embeddable.seatsioBundles[this.getChartUrl()] || this.firstRender) {
|
|
66
|
+
this.createAndRenderChart();
|
|
67
|
+
this.firstRender = false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
componentDidUpdate(prevProps) {
|
|
71
|
+
if (didPropsChange(this.props, prevProps) && this.chart) {
|
|
72
|
+
this.destroyChart();
|
|
73
|
+
this.createAndRenderChart();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
getChartUrl() {
|
|
77
|
+
return this.props.chartJsUrl.replace("{region}", this.props.region);
|
|
78
|
+
}
|
|
79
|
+
async createAndRenderChart() {
|
|
80
|
+
const seatsio2 = await this.loadSeatsio();
|
|
81
|
+
const config = this.extractConfigFromProps();
|
|
82
|
+
config.container = this.container.current;
|
|
83
|
+
this.chart = this.createChart(seatsio2, config).render();
|
|
84
|
+
if (this.props.onRenderStarted) {
|
|
85
|
+
this.props.onRenderStarted(this.chart);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
extractConfigFromProps() {
|
|
89
|
+
let { chartJsUrl, divId, onRenderStarted, region, ...config } = this.props;
|
|
90
|
+
return config;
|
|
91
|
+
}
|
|
92
|
+
componentWillUnmount() {
|
|
93
|
+
this.destroyChart();
|
|
94
|
+
}
|
|
95
|
+
destroyChart() {
|
|
96
|
+
if (this.chart && this.chart.state !== "DESTROYED") {
|
|
97
|
+
this.chart.destroy();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
loadSeatsio() {
|
|
101
|
+
const chartUrl = this.getChartUrl();
|
|
102
|
+
if (!_Embeddable.seatsioBundles[chartUrl]) {
|
|
103
|
+
_Embeddable.seatsioBundles[chartUrl] = new Promise((resolve, reject) => {
|
|
104
|
+
const script = document.head.appendChild(document.createElement("script"));
|
|
105
|
+
window.seatsio = void 0;
|
|
106
|
+
script.onload = () => {
|
|
107
|
+
resolve(seatsio);
|
|
108
|
+
};
|
|
109
|
+
script.onerror = () => reject(`Could not load ${script.src}`);
|
|
110
|
+
script.src = chartUrl;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return _Embeddable.seatsioBundles[chartUrl];
|
|
114
|
+
}
|
|
115
|
+
render() {
|
|
116
|
+
return /* @__PURE__ */ React.createElement("div", { ref: this.container, style: { "height": "100%", "width": "100%" } });
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
_Embeddable.seatsioBundles = {};
|
|
120
|
+
_Embeddable.defaultProps = {
|
|
121
|
+
chartJsUrl: "https://cdn-{region}.seatsio.net/chart.js"
|
|
122
|
+
};
|
|
123
|
+
var Embeddable = _Embeddable;
|
|
2
124
|
//# sourceMappingURL=Embeddable.js.map
|
package/build/Embeddable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/main/Embeddable.tsx"],"sourcesContent":["import * as React from 'react'\nimport {didPropsChange} from './util'\nimport { ChartDesigner, CommonConfigOptions, EventManager, Region, SeatingChart, Seatsio } from '@seatsio/seatsio-types'\n\nexport type EmbeddableProps<T> = {\n onRenderStarted?: (chart: SeatingChart) => void\n chartJsUrl?: string\n region: Region\n} & T\n\nexport default abstract class Embeddable<T extends CommonConfigOptions> extends React.Component<EmbeddableProps<T>> {\n private container: React.RefObject<HTMLDivElement>\n private
|
|
1
|
+
{"version":3,"sources":["../src/main/Embeddable.tsx","../src/main/util.ts"],"sourcesContent":["import * as React from 'react'\nimport {didPropsChange} from './util'\nimport { ChartDesigner, CommonConfigOptions, EventManager, Region, SeatingChart, Seatsio } from '@seatsio/seatsio-types'\n\nexport type EmbeddableProps<T > = {\n onRenderStarted?: (chart: SeatingChart | EventManager) => void\n chartJsUrl?: string\n region: Region\n} & T\n\nexport default abstract class Embeddable<T extends CommonConfigOptions> extends React.Component<EmbeddableProps<T>> {\n private container: React.RefObject<HTMLDivElement>\n private chart: SeatingChart\n private firstRender: boolean\n\n private static seatsioBundles: { [key: string]: Promise<Seatsio> } = {}\n\n static defaultProps = {\n chartJsUrl: 'https://cdn-{region}.seatsio.net/chart.js'\n }\n\n constructor(props: EmbeddableProps<T>) {\n super(props);\n this.container = React.createRef()\n this.firstRender = true\n }\n\n abstract createChart (seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner\n\n componentDidMount () {\n if (!Embeddable.seatsioBundles[this.getChartUrl()] || this.firstRender) {\n this.createAndRenderChart()\n this.firstRender = false\n }\n }\n\n componentDidUpdate (prevProps: EmbeddableProps<T>) {\n if (didPropsChange(this.props, prevProps) && this.chart) {\n this.destroyChart()\n this.createAndRenderChart()\n }\n }\n\n getChartUrl () {\n return this.props.chartJsUrl.replace('{region}', this.props.region)\n }\n\n async createAndRenderChart () {\n const seatsio = await this.loadSeatsio()\n const config = this.extractConfigFromProps()\n config.container = this.container.current\n this.chart = this.createChart(seatsio, config).render()\n if (this.props.onRenderStarted) {\n this.props.onRenderStarted(this.chart)\n }\n }\n\n extractConfigFromProps (): any {\n let { chartJsUrl, divId, onRenderStarted, region, ...config } = this.props\n return config\n }\n\n componentWillUnmount () {\n this.destroyChart()\n }\n\n destroyChart () {\n if (this.chart && (this.chart as any).state !== 'DESTROYED') {\n this.chart.destroy()\n }\n }\n\n loadSeatsio (): Promise<Seatsio> {\n const chartUrl = this.getChartUrl()\n if (!Embeddable.seatsioBundles[chartUrl]) {\n Embeddable.seatsioBundles[chartUrl] = new Promise<Seatsio>((resolve, reject) => {\n const script = document.head.appendChild(document.createElement('script'))\n // Seatsio global is not replaced if already present, which would cause the wrong region bundle to resolve when changing region\n window.seatsio = undefined\n script.onload = () => {\n resolve(seatsio)\n }\n script.onerror = () => reject(`Could not load ${script.src}`)\n script.src = chartUrl\n })\n }\n\n return Embeddable.seatsioBundles[chartUrl]\n }\n\n render (): React.ReactNode {\n return (\n <div ref={this.container as unknown as React.RefObject<HTMLDivElement>} style={{'height': '100%', 'width': '100%'}} />\n )\n }\n}","import { BoothProps, GeneralAdmissionAreaProps, InteractiveObjectProps, InteractiveSectionProps, SeatProps, SelectableObjectProps, TableProps } from \"@seatsio/seatsio-types\"\n\nexport const didPropsChange = <P extends { [key: string]: any}>(prevProps: P, nextProps: P): boolean => {\n if (Object.keys(prevProps).length !== Object.keys(nextProps).length) {\n return true\n }\n return Object.keys(nextProps).some((propName: string) => {\n let prevValue = prevProps[propName]\n let nextValue = nextProps[propName]\n if (prevValue && nextValue) {\n if (typeof prevValue === 'function' && typeof nextValue === 'function') {\n return prevValue.toString() !== nextValue.toString()\n }\n if (typeof prevValue === 'object' && typeof nextValue === 'object') {\n return didPropsChange(prevValue, nextValue)\n }\n }\n return prevValue !== nextValue\n })\n}\n\nexport const isSeat = (obj: SelectableObjectProps): obj is SeatProps => obj.objectType === 'Seat'\nexport const isTable = (obj: SelectableObjectProps): obj is TableProps => obj.objectType === 'Table'\nexport const isSection = (obj: SelectableObjectProps): obj is InteractiveSectionProps => obj.objectType === 'section'\nexport const isBooth = (obj: SelectableObjectProps): obj is BoothProps => obj.objectType === 'Booth'\nexport const isGeneralAdmission = (obj: SelectableObjectProps): obj is GeneralAdmissionAreaProps => obj.objectType === 'GeneralAdmissionArea'"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;;;ACEhB,IAAM,iBAAiB,CAAkC,WAAc,cAA0B;AACpG,MAAI,OAAO,KAAK,SAAS,EAAE,WAAW,OAAO,KAAK,SAAS,EAAE,QAAQ;AACjE,WAAO;AAAA,EACX;AACA,SAAO,OAAO,KAAK,SAAS,EAAE,KAAK,CAAC,aAAqB;AACrD,QAAI,YAAY,UAAU,QAAQ;AAClC,QAAI,YAAY,UAAU,QAAQ;AAClC,QAAI,aAAa,WAAW;AACxB,UAAI,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AACZ,QAAI,KAAK,SAAU,KAAK,MAAc,UAAU,aAAa;AACzD,WAAK,MAAM,QAAQ;AAAA,IACvB;AAAA,EACJ;AAAA,EAEA,cAAiC;AAC7B,UAAM,WAAW,KAAK,YAAY;AAClC,QAAI,CAAC,YAAW,eAAe,QAAQ,GAAG;AACtC,kBAAW,eAAe,QAAQ,IAAI,IAAI,QAAiB,CAAC,SAAS,WAAW;AAC5E,cAAM,SAAS,SAAS,KAAK,YAAY,SAAS,cAAc,QAAQ,CAAC;AAEzE,eAAO,UAAU;AACjB,eAAO,SAAS,MAAM;AAClB,kBAAQ,OAAO;AAAA,QACnB;AACA,eAAO,UAAU,MAAM,OAAO,kBAAkB,OAAO,GAAG,EAAE;AAC5D,eAAO,MAAM;AAAA,MACjB,CAAC;AAAA,IACL;AAEA,WAAO,YAAW,eAAe,QAAQ;AAAA,EAC7C;AAAA,EAEA,SAA2B;AACvB,WACI,oCAAC,SAAI,KAAK,KAAK,WAAyD,OAAO,EAAC,UAAU,QAAQ,SAAS,OAAM,GAAG;AAAA,EAE5H;AACJ;AArF8B,YAKX,iBAAsD,CAAC;AAL5C,YAOnB,eAAe;AAAA,EAClB,YAAY;AAChB;AATJ,IAA8B,aAA9B;","names":["seatsio"]}
|
package/build/Embeddable.mjs
CHANGED
|
@@ -1,2 +1,94 @@
|
|
|
1
|
-
|
|
1
|
+
// src/main/Embeddable.tsx
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
// src/main/util.ts
|
|
5
|
+
var didPropsChange = (prevProps, nextProps) => {
|
|
6
|
+
if (Object.keys(prevProps).length !== Object.keys(nextProps).length) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
return Object.keys(nextProps).some((propName) => {
|
|
10
|
+
let prevValue = prevProps[propName];
|
|
11
|
+
let nextValue = nextProps[propName];
|
|
12
|
+
if (prevValue && nextValue) {
|
|
13
|
+
if (typeof prevValue === "function" && typeof nextValue === "function") {
|
|
14
|
+
return prevValue.toString() !== nextValue.toString();
|
|
15
|
+
}
|
|
16
|
+
if (typeof prevValue === "object" && typeof nextValue === "object") {
|
|
17
|
+
return didPropsChange(prevValue, nextValue);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return prevValue !== nextValue;
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// src/main/Embeddable.tsx
|
|
25
|
+
var _Embeddable = class _Embeddable extends React.Component {
|
|
26
|
+
constructor(props) {
|
|
27
|
+
super(props);
|
|
28
|
+
this.container = React.createRef();
|
|
29
|
+
this.firstRender = true;
|
|
30
|
+
}
|
|
31
|
+
componentDidMount() {
|
|
32
|
+
if (!_Embeddable.seatsioBundles[this.getChartUrl()] || this.firstRender) {
|
|
33
|
+
this.createAndRenderChart();
|
|
34
|
+
this.firstRender = false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
componentDidUpdate(prevProps) {
|
|
38
|
+
if (didPropsChange(this.props, prevProps) && this.chart) {
|
|
39
|
+
this.destroyChart();
|
|
40
|
+
this.createAndRenderChart();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
getChartUrl() {
|
|
44
|
+
return this.props.chartJsUrl.replace("{region}", this.props.region);
|
|
45
|
+
}
|
|
46
|
+
async createAndRenderChart() {
|
|
47
|
+
const seatsio2 = await this.loadSeatsio();
|
|
48
|
+
const config = this.extractConfigFromProps();
|
|
49
|
+
config.container = this.container.current;
|
|
50
|
+
this.chart = this.createChart(seatsio2, config).render();
|
|
51
|
+
if (this.props.onRenderStarted) {
|
|
52
|
+
this.props.onRenderStarted(this.chart);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
extractConfigFromProps() {
|
|
56
|
+
let { chartJsUrl, divId, onRenderStarted, region, ...config } = this.props;
|
|
57
|
+
return config;
|
|
58
|
+
}
|
|
59
|
+
componentWillUnmount() {
|
|
60
|
+
this.destroyChart();
|
|
61
|
+
}
|
|
62
|
+
destroyChart() {
|
|
63
|
+
if (this.chart && this.chart.state !== "DESTROYED") {
|
|
64
|
+
this.chart.destroy();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
loadSeatsio() {
|
|
68
|
+
const chartUrl = this.getChartUrl();
|
|
69
|
+
if (!_Embeddable.seatsioBundles[chartUrl]) {
|
|
70
|
+
_Embeddable.seatsioBundles[chartUrl] = new Promise((resolve, reject) => {
|
|
71
|
+
const script = document.head.appendChild(document.createElement("script"));
|
|
72
|
+
window.seatsio = void 0;
|
|
73
|
+
script.onload = () => {
|
|
74
|
+
resolve(seatsio);
|
|
75
|
+
};
|
|
76
|
+
script.onerror = () => reject(`Could not load ${script.src}`);
|
|
77
|
+
script.src = chartUrl;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return _Embeddable.seatsioBundles[chartUrl];
|
|
81
|
+
}
|
|
82
|
+
render() {
|
|
83
|
+
return /* @__PURE__ */ React.createElement("div", { ref: this.container, style: { "height": "100%", "width": "100%" } });
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
_Embeddable.seatsioBundles = {};
|
|
87
|
+
_Embeddable.defaultProps = {
|
|
88
|
+
chartJsUrl: "https://cdn-{region}.seatsio.net/chart.js"
|
|
89
|
+
};
|
|
90
|
+
var Embeddable = _Embeddable;
|
|
91
|
+
export {
|
|
92
|
+
Embeddable as default
|
|
93
|
+
};
|
|
2
94
|
//# sourceMappingURL=Embeddable.mjs.map
|
package/build/Embeddable.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/main/Embeddable.tsx"],"sourcesContent":["import * as React from 'react'\nimport {didPropsChange} from './util'\nimport { ChartDesigner, CommonConfigOptions, EventManager, Region, SeatingChart, Seatsio } from '@seatsio/seatsio-types'\n\nexport type EmbeddableProps<T> = {\n onRenderStarted?: (chart: SeatingChart) => void\n chartJsUrl?: string\n region: Region\n} & T\n\nexport default abstract class Embeddable<T extends CommonConfigOptions> extends React.Component<EmbeddableProps<T>> {\n private container: React.RefObject<HTMLDivElement>\n private
|
|
1
|
+
{"version":3,"sources":["../src/main/Embeddable.tsx","../src/main/util.ts"],"sourcesContent":["import * as React from 'react'\nimport {didPropsChange} from './util'\nimport { ChartDesigner, CommonConfigOptions, EventManager, Region, SeatingChart, Seatsio } from '@seatsio/seatsio-types'\n\nexport type EmbeddableProps<T > = {\n onRenderStarted?: (chart: SeatingChart | EventManager) => void\n chartJsUrl?: string\n region: Region\n} & T\n\nexport default abstract class Embeddable<T extends CommonConfigOptions> extends React.Component<EmbeddableProps<T>> {\n private container: React.RefObject<HTMLDivElement>\n private chart: SeatingChart\n private firstRender: boolean\n\n private static seatsioBundles: { [key: string]: Promise<Seatsio> } = {}\n\n static defaultProps = {\n chartJsUrl: 'https://cdn-{region}.seatsio.net/chart.js'\n }\n\n constructor(props: EmbeddableProps<T>) {\n super(props);\n this.container = React.createRef()\n this.firstRender = true\n }\n\n abstract createChart (seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner\n\n componentDidMount () {\n if (!Embeddable.seatsioBundles[this.getChartUrl()] || this.firstRender) {\n this.createAndRenderChart()\n this.firstRender = false\n }\n }\n\n componentDidUpdate (prevProps: EmbeddableProps<T>) {\n if (didPropsChange(this.props, prevProps) && this.chart) {\n this.destroyChart()\n this.createAndRenderChart()\n }\n }\n\n getChartUrl () {\n return this.props.chartJsUrl.replace('{region}', this.props.region)\n }\n\n async createAndRenderChart () {\n const seatsio = await this.loadSeatsio()\n const config = this.extractConfigFromProps()\n config.container = this.container.current\n this.chart = this.createChart(seatsio, config).render()\n if (this.props.onRenderStarted) {\n this.props.onRenderStarted(this.chart)\n }\n }\n\n extractConfigFromProps (): any {\n let { chartJsUrl, divId, onRenderStarted, region, ...config } = this.props\n return config\n }\n\n componentWillUnmount () {\n this.destroyChart()\n }\n\n destroyChart () {\n if (this.chart && (this.chart as any).state !== 'DESTROYED') {\n this.chart.destroy()\n }\n }\n\n loadSeatsio (): Promise<Seatsio> {\n const chartUrl = this.getChartUrl()\n if (!Embeddable.seatsioBundles[chartUrl]) {\n Embeddable.seatsioBundles[chartUrl] = new Promise<Seatsio>((resolve, reject) => {\n const script = document.head.appendChild(document.createElement('script'))\n // Seatsio global is not replaced if already present, which would cause the wrong region bundle to resolve when changing region\n window.seatsio = undefined\n script.onload = () => {\n resolve(seatsio)\n }\n script.onerror = () => reject(`Could not load ${script.src}`)\n script.src = chartUrl\n })\n }\n\n return Embeddable.seatsioBundles[chartUrl]\n }\n\n render (): React.ReactNode {\n return (\n <div ref={this.container as unknown as React.RefObject<HTMLDivElement>} style={{'height': '100%', 'width': '100%'}} />\n )\n }\n}","import { BoothProps, GeneralAdmissionAreaProps, InteractiveObjectProps, InteractiveSectionProps, SeatProps, SelectableObjectProps, TableProps } from \"@seatsio/seatsio-types\"\n\nexport const didPropsChange = <P extends { [key: string]: any}>(prevProps: P, nextProps: P): boolean => {\n if (Object.keys(prevProps).length !== Object.keys(nextProps).length) {\n return true\n }\n return Object.keys(nextProps).some((propName: string) => {\n let prevValue = prevProps[propName]\n let nextValue = nextProps[propName]\n if (prevValue && nextValue) {\n if (typeof prevValue === 'function' && typeof nextValue === 'function') {\n return prevValue.toString() !== nextValue.toString()\n }\n if (typeof prevValue === 'object' && typeof nextValue === 'object') {\n return didPropsChange(prevValue, nextValue)\n }\n }\n return prevValue !== nextValue\n })\n}\n\nexport const isSeat = (obj: SelectableObjectProps): obj is SeatProps => obj.objectType === 'Seat'\nexport const isTable = (obj: SelectableObjectProps): obj is TableProps => obj.objectType === 'Table'\nexport const isSection = (obj: SelectableObjectProps): obj is InteractiveSectionProps => obj.objectType === 'section'\nexport const isBooth = (obj: SelectableObjectProps): obj is BoothProps => obj.objectType === 'Booth'\nexport const isGeneralAdmission = (obj: SelectableObjectProps): obj is GeneralAdmissionAreaProps => obj.objectType === 'GeneralAdmissionArea'"],"mappings":";AAAA,YAAY,WAAW;;;ACEhB,IAAM,iBAAiB,CAAkC,WAAc,cAA0B;AACpG,MAAI,OAA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AAM,gBAAgB,KAAK,KAAK;AAAA,IACzC;AAAA,EACJ;AAAA,EAEA,yBAA+B;AAC3B,QAAI,EAAE,YAAY,OAAO,iBAAiB,QAAQ,GAAG,OAAO,IAAI,KAAK;AACrE,WAAO;AAAA,EACX;AAAA,EAEA,uBAAwB;AACpB,SAAK,aAAa;AAAA,EACtB;AAAA,EAEA,eAAgB;AACZ,QAAI,KAAK,SAAU,KAAK,MAAc,UAAU,aAAa;AACzD,WAAK,MAAM,QAAQ;AAAA,IACvB;AAAA,EACJ;AAAA,EAEA,cAAiC;AAC7B,UAAM,WAAW,KAAK,YAAY;AAClC,QAAI,CAAC,YAAW,eAAe,QAAQ,GAAG;AACtC,kBAAW,eAAe,QAAQ,IAAI,IAAI,QAAiB,CAAC,SAAS,WAAW;AAC5E,cAAM,SAAS,SAAS,KAAK,YAAY,SAAS,cAAc,QAAQ,CAAC;AAEzE,eAAO,UAAU;AACjB,eAAO,SAAS,MAAM;AAClB,kBAAQ,OAAO;AAAA,QACnB;AACA,eAAO,UAAU,MAAM,OAAO,kBAAkB,OAAO,GAAG,EAAE;AAC5D,eAAO,MAAM;AAAA,MACjB,CAAC;AAAA,IACL;AAEA,WAAO,YAAW,eAAe,QAAQ;AAAA,EAC7C;AAAA,EAEA,SAA2B;AACvB,WACI,oCAAC,SAAI,KAAK,KAAK,WAAyD,OAAO,EAAC,UAAU,QAAQ,SAAS,OAAM,GAAG;AAAA,EAE5H;AACJ;AArF8B,YAKX,iBAAsD,CAAC;AAL5C,YAOnB,eAAe;AAAA,EAClB,YAAY;AAChB;AATJ,IAA8B,aAA9B;","names":["seatsio"]}
|
package/build/SeatsioDesigner.js
CHANGED
|
@@ -1,2 +1,133 @@
|
|
|
1
|
-
var
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/main/SeatsioDesigner.tsx
|
|
30
|
+
var SeatsioDesigner_exports = {};
|
|
31
|
+
__export(SeatsioDesigner_exports, {
|
|
32
|
+
default: () => SeatsioDesigner
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(SeatsioDesigner_exports);
|
|
35
|
+
|
|
36
|
+
// src/main/Embeddable.tsx
|
|
37
|
+
var React = __toESM(require("react"));
|
|
38
|
+
|
|
39
|
+
// src/main/util.ts
|
|
40
|
+
var didPropsChange = (prevProps, nextProps) => {
|
|
41
|
+
if (Object.keys(prevProps).length !== Object.keys(nextProps).length) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
return Object.keys(nextProps).some((propName) => {
|
|
45
|
+
let prevValue = prevProps[propName];
|
|
46
|
+
let nextValue = nextProps[propName];
|
|
47
|
+
if (prevValue && nextValue) {
|
|
48
|
+
if (typeof prevValue === "function" && typeof nextValue === "function") {
|
|
49
|
+
return prevValue.toString() !== nextValue.toString();
|
|
50
|
+
}
|
|
51
|
+
if (typeof prevValue === "object" && typeof nextValue === "object") {
|
|
52
|
+
return didPropsChange(prevValue, nextValue);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return prevValue !== nextValue;
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// src/main/Embeddable.tsx
|
|
60
|
+
var _Embeddable = class _Embeddable extends React.Component {
|
|
61
|
+
constructor(props) {
|
|
62
|
+
super(props);
|
|
63
|
+
this.container = React.createRef();
|
|
64
|
+
this.firstRender = true;
|
|
65
|
+
}
|
|
66
|
+
componentDidMount() {
|
|
67
|
+
if (!_Embeddable.seatsioBundles[this.getChartUrl()] || this.firstRender) {
|
|
68
|
+
this.createAndRenderChart();
|
|
69
|
+
this.firstRender = false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
componentDidUpdate(prevProps) {
|
|
73
|
+
if (didPropsChange(this.props, prevProps) && this.chart) {
|
|
74
|
+
this.destroyChart();
|
|
75
|
+
this.createAndRenderChart();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
getChartUrl() {
|
|
79
|
+
return this.props.chartJsUrl.replace("{region}", this.props.region);
|
|
80
|
+
}
|
|
81
|
+
async createAndRenderChart() {
|
|
82
|
+
const seatsio2 = await this.loadSeatsio();
|
|
83
|
+
const config = this.extractConfigFromProps();
|
|
84
|
+
config.container = this.container.current;
|
|
85
|
+
this.chart = this.createChart(seatsio2, config).render();
|
|
86
|
+
if (this.props.onRenderStarted) {
|
|
87
|
+
this.props.onRenderStarted(this.chart);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
extractConfigFromProps() {
|
|
91
|
+
let { chartJsUrl, divId, onRenderStarted, region, ...config } = this.props;
|
|
92
|
+
return config;
|
|
93
|
+
}
|
|
94
|
+
componentWillUnmount() {
|
|
95
|
+
this.destroyChart();
|
|
96
|
+
}
|
|
97
|
+
destroyChart() {
|
|
98
|
+
if (this.chart && this.chart.state !== "DESTROYED") {
|
|
99
|
+
this.chart.destroy();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
loadSeatsio() {
|
|
103
|
+
const chartUrl = this.getChartUrl();
|
|
104
|
+
if (!_Embeddable.seatsioBundles[chartUrl]) {
|
|
105
|
+
_Embeddable.seatsioBundles[chartUrl] = new Promise((resolve, reject) => {
|
|
106
|
+
const script = document.head.appendChild(document.createElement("script"));
|
|
107
|
+
window.seatsio = void 0;
|
|
108
|
+
script.onload = () => {
|
|
109
|
+
resolve(seatsio);
|
|
110
|
+
};
|
|
111
|
+
script.onerror = () => reject(`Could not load ${script.src}`);
|
|
112
|
+
script.src = chartUrl;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return _Embeddable.seatsioBundles[chartUrl];
|
|
116
|
+
}
|
|
117
|
+
render() {
|
|
118
|
+
return /* @__PURE__ */ React.createElement("div", { ref: this.container, style: { "height": "100%", "width": "100%" } });
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
_Embeddable.seatsioBundles = {};
|
|
122
|
+
_Embeddable.defaultProps = {
|
|
123
|
+
chartJsUrl: "https://cdn-{region}.seatsio.net/chart.js"
|
|
124
|
+
};
|
|
125
|
+
var Embeddable = _Embeddable;
|
|
126
|
+
|
|
127
|
+
// src/main/SeatsioDesigner.tsx
|
|
128
|
+
var SeatsioDesigner = class extends Embeddable {
|
|
129
|
+
createChart(seatsio2, config) {
|
|
130
|
+
return new seatsio2.SeatingChartDesigner(config);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
2
133
|
//# sourceMappingURL=SeatsioDesigner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/main/SeatsioDesigner.tsx"],"sourcesContent":["import Embeddable from './Embeddable'\nimport { ChartDesignerConfigOptions, Seatsio } from '@seatsio/seatsio-types'\n\nexport default class SeatsioDesigner extends Embeddable<ChartDesignerConfigOptions> {\n createChart (seatsio: Seatsio, config: ChartDesignerConfigOptions) {\n return new seatsio.SeatingChartDesigner(config)\n }\n}"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/main/SeatsioDesigner.tsx","../src/main/Embeddable.tsx","../src/main/util.ts"],"sourcesContent":["import Embeddable from './Embeddable'\nimport { ChartDesignerConfigOptions, Seatsio } from '@seatsio/seatsio-types'\n\nexport default class SeatsioDesigner extends Embeddable<ChartDesignerConfigOptions> {\n createChart (seatsio: Seatsio, config: ChartDesignerConfigOptions) {\n return new seatsio.SeatingChartDesigner(config)\n }\n}","import * as React from 'react'\nimport {didPropsChange} from './util'\nimport { ChartDesigner, CommonConfigOptions, EventManager, Region, SeatingChart, Seatsio } from '@seatsio/seatsio-types'\n\nexport type EmbeddableProps<T > = {\n onRenderStarted?: (chart: SeatingChart | EventManager) => void\n chartJsUrl?: string\n region: Region\n} & T\n\nexport default abstract class Embeddable<T extends CommonConfigOptions> extends React.Component<EmbeddableProps<T>> {\n private container: React.RefObject<HTMLDivElement>\n private chart: SeatingChart\n private firstRender: boolean\n\n private static seatsioBundles: { [key: string]: Promise<Seatsio> } = {}\n\n static defaultProps = {\n chartJsUrl: 'https://cdn-{region}.seatsio.net/chart.js'\n }\n\n constructor(props: EmbeddableProps<T>) {\n super(props);\n this.container = React.createRef()\n this.firstRender = true\n }\n\n abstract createChart (seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner\n\n componentDidMount () {\n if (!Embeddable.seatsioBundles[this.getChartUrl()] || this.firstRender) {\n this.createAndRenderChart()\n this.firstRender = false\n }\n }\n\n componentDidUpdate (prevProps: EmbeddableProps<T>) {\n if (didPropsChange(this.props, prevProps) && this.chart) {\n this.destroyChart()\n this.createAndRenderChart()\n }\n }\n\n getChartUrl () {\n return this.props.chartJsUrl.replace('{region}', this.props.region)\n }\n\n async createAndRenderChart () {\n const seatsio = await this.loadSeatsio()\n const config = this.extractConfigFromProps()\n config.container = this.container.current\n this.chart = this.createChart(seatsio, config).render()\n if (this.props.onRenderStarted) {\n this.props.onRenderStarted(this.chart)\n }\n }\n\n extractConfigFromProps (): any {\n let { chartJsUrl, divId, onRenderStarted, region, ...config } = this.props\n return config\n }\n\n componentWillUnmount () {\n this.destroyChart()\n }\n\n destroyChart () {\n if (this.chart && (this.chart as any).state !== 'DESTROYED') {\n this.chart.destroy()\n }\n }\n\n loadSeatsio (): Promise<Seatsio> {\n const chartUrl = this.getChartUrl()\n if (!Embeddable.seatsioBundles[chartUrl]) {\n Embeddable.seatsioBundles[chartUrl] = new Promise<Seatsio>((resolve, reject) => {\n const script = document.head.appendChild(document.createElement('script'))\n // Seatsio global is not replaced if already present, which would cause the wrong region bundle to resolve when changing region\n window.seatsio = undefined\n script.onload = () => {\n resolve(seatsio)\n }\n script.onerror = () => reject(`Could not load ${script.src}`)\n script.src = chartUrl\n })\n }\n\n return Embeddable.seatsioBundles[chartUrl]\n }\n\n render (): React.ReactNode {\n return (\n <div ref={this.container as unknown as React.RefObject<HTMLDivElement>} style={{'height': '100%', 'width': '100%'}} />\n )\n }\n}","import { BoothProps, GeneralAdmissionAreaProps, InteractiveObjectProps, InteractiveSectionProps, SeatProps, SelectableObjectProps, TableProps } from \"@seatsio/seatsio-types\"\n\nexport const didPropsChange = <P extends { [key: string]: any}>(prevProps: P, nextProps: P): boolean => {\n if (Object.keys(prevProps).length !== Object.keys(nextProps).length) {\n return true\n }\n return Object.keys(nextProps).some((propName: string) => {\n let prevValue = prevProps[propName]\n let nextValue = nextProps[propName]\n if (prevValue && nextValue) {\n if (typeof prevValue === 'function' && typeof nextValue === 'function') {\n return prevValue.toString() !== nextValue.toString()\n }\n if (typeof prevValue === 'object' && typeof nextValue === 'object') {\n return didPropsChange(prevValue, nextValue)\n }\n }\n return prevValue !== nextValue\n })\n}\n\nexport const isSeat = (obj: SelectableObjectProps): obj is SeatProps => obj.objectType === 'Seat'\nexport const isTable = (obj: SelectableObjectProps): obj is TableProps => obj.objectType === 'Table'\nexport const isSection = (obj: SelectableObjectProps): obj is InteractiveSectionProps => obj.objectType === 'section'\nexport const isBooth = (obj: SelectableObjectProps): obj is BoothProps => obj.objectType === 'Booth'\nexport const isGeneralAdmission = (obj: SelectableObjectProps): obj is GeneralAdmissionAreaProps => obj.objectType === 'GeneralAdmissionArea'"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;;;ACEhB,IAAM,iBAAiB,CAAkC,WAAc,cAA0B;AACpG,MAAI,OAAO,KAAK,SAAS,EAAE,WAAW,OAAO,KAAK,SAAS,EAAE,QAAQ;AACjE,WAAO;AAAA,EACX;AACA,SAAO,OAAO,KAAK,SAAS,EAAE,KAAK,CAAC,aAAqB;AACrD,QAAI,YAAY,UAAU,QAAQ;AAClC,QAAI,YAAY,UAAU,QAAQ;AAClC,QAAI,aAAa,WAAW;AACxB,UAAI,OAAO,cAAc,cAAc,OAAO,cAAc,YAAY;AACpE,eAAO,UAAU,SAAS,MAAM,UAAU,SAAS;AAAA,MACvD;AACA,UAAI,OAAO,cAAc,YAAY,OAAO,cAAc,UAAU;AAChE,eAAO,eAAe,WAAW,SAAS;AAAA,MAC9C;AAAA,IACJ;AACA,WAAO,cAAc;AAAA,EACzB,CAAC;AACL;;;ADTA,IAA8B,cAA9B,MAA8B,oBAAwD,gBAA8B;AAAA,EAWhH,YAAY,OAA2B;AACnC,UAAM,KAAK;AACX,SAAK,YAAkB,gBAAU;AACjC,SAAK,cAAc;AAAA,EACvB;AAAA,EAIA,oBAAqB;AACjB,QAAI,CAAC,YAAW,eAAe,KAAK,YAAY,CAAC,KAA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C5D,eAAO,MAAM;AAAA,MACjB,CAAC;AAAA,IACL;AAEA,WAAO,YAAW,eAAe,QAAQ;AAAA,EAC7C;AAAA,EAEA,SAA2B;AACvB,WACI,oCAAC,SAAI,KAAK,KAAK,WAAyD,OAAO,EAAC,UAAU,QAAQ,SAAS,OAAM,GAAG;AAAA,EAE5H;AACJ;AArF8B,YAKX,iBAAsD,CAAC;AAL5C,YAOnB,eAAe;AAAA,EAClB,YAAY;AAChB;AATJ,IAA8B,aAA9B;;;ADPA,IAAqB,kBAArB,cAA6C,WAAuC;AAAA,EAChF,YAAaC,UAAkB,QAAoC;AAC/D,WAAO,IAAIA,SAAQ,qBAAqB,MAAM;AAAA,EAClD;AACJ;","names":["seatsio","seatsio"]}
|
|
@@ -1,2 +1,101 @@
|
|
|
1
|
-
|
|
1
|
+
// src/main/Embeddable.tsx
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
// src/main/util.ts
|
|
5
|
+
var didPropsChange = (prevProps, nextProps) => {
|
|
6
|
+
if (Object.keys(prevProps).length !== Object.keys(nextProps).length) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
return Object.keys(nextProps).some((propName) => {
|
|
10
|
+
let prevValue = prevProps[propName];
|
|
11
|
+
let nextValue = nextProps[propName];
|
|
12
|
+
if (prevValue && nextValue) {
|
|
13
|
+
if (typeof prevValue === "function" && typeof nextValue === "function") {
|
|
14
|
+
return prevValue.toString() !== nextValue.toString();
|
|
15
|
+
}
|
|
16
|
+
if (typeof prevValue === "object" && typeof nextValue === "object") {
|
|
17
|
+
return didPropsChange(prevValue, nextValue);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return prevValue !== nextValue;
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// src/main/Embeddable.tsx
|
|
25
|
+
var _Embeddable = class _Embeddable extends React.Component {
|
|
26
|
+
constructor(props) {
|
|
27
|
+
super(props);
|
|
28
|
+
this.container = React.createRef();
|
|
29
|
+
this.firstRender = true;
|
|
30
|
+
}
|
|
31
|
+
componentDidMount() {
|
|
32
|
+
if (!_Embeddable.seatsioBundles[this.getChartUrl()] || this.firstRender) {
|
|
33
|
+
this.createAndRenderChart();
|
|
34
|
+
this.firstRender = false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
componentDidUpdate(prevProps) {
|
|
38
|
+
if (didPropsChange(this.props, prevProps) && this.chart) {
|
|
39
|
+
this.destroyChart();
|
|
40
|
+
this.createAndRenderChart();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
getChartUrl() {
|
|
44
|
+
return this.props.chartJsUrl.replace("{region}", this.props.region);
|
|
45
|
+
}
|
|
46
|
+
async createAndRenderChart() {
|
|
47
|
+
const seatsio2 = await this.loadSeatsio();
|
|
48
|
+
const config = this.extractConfigFromProps();
|
|
49
|
+
config.container = this.container.current;
|
|
50
|
+
this.chart = this.createChart(seatsio2, config).render();
|
|
51
|
+
if (this.props.onRenderStarted) {
|
|
52
|
+
this.props.onRenderStarted(this.chart);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
extractConfigFromProps() {
|
|
56
|
+
let { chartJsUrl, divId, onRenderStarted, region, ...config } = this.props;
|
|
57
|
+
return config;
|
|
58
|
+
}
|
|
59
|
+
componentWillUnmount() {
|
|
60
|
+
this.destroyChart();
|
|
61
|
+
}
|
|
62
|
+
destroyChart() {
|
|
63
|
+
if (this.chart && this.chart.state !== "DESTROYED") {
|
|
64
|
+
this.chart.destroy();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
loadSeatsio() {
|
|
68
|
+
const chartUrl = this.getChartUrl();
|
|
69
|
+
if (!_Embeddable.seatsioBundles[chartUrl]) {
|
|
70
|
+
_Embeddable.seatsioBundles[chartUrl] = new Promise((resolve, reject) => {
|
|
71
|
+
const script = document.head.appendChild(document.createElement("script"));
|
|
72
|
+
window.seatsio = void 0;
|
|
73
|
+
script.onload = () => {
|
|
74
|
+
resolve(seatsio);
|
|
75
|
+
};
|
|
76
|
+
script.onerror = () => reject(`Could not load ${script.src}`);
|
|
77
|
+
script.src = chartUrl;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return _Embeddable.seatsioBundles[chartUrl];
|
|
81
|
+
}
|
|
82
|
+
render() {
|
|
83
|
+
return /* @__PURE__ */ React.createElement("div", { ref: this.container, style: { "height": "100%", "width": "100%" } });
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
_Embeddable.seatsioBundles = {};
|
|
87
|
+
_Embeddable.defaultProps = {
|
|
88
|
+
chartJsUrl: "https://cdn-{region}.seatsio.net/chart.js"
|
|
89
|
+
};
|
|
90
|
+
var Embeddable = _Embeddable;
|
|
91
|
+
|
|
92
|
+
// src/main/SeatsioDesigner.tsx
|
|
93
|
+
var SeatsioDesigner = class extends Embeddable {
|
|
94
|
+
createChart(seatsio2, config) {
|
|
95
|
+
return new seatsio2.SeatingChartDesigner(config);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
export {
|
|
99
|
+
SeatsioDesigner as default
|
|
100
|
+
};
|
|
2
101
|
//# sourceMappingURL=SeatsioDesigner.mjs.map
|