@seatsio/seatsio-react 14.2.0 → 14.3.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.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 +1 -1
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 extends React.Component {
|
|
59
|
+
constructor(props) {
|
|
60
|
+
super(props);
|
|
61
|
+
this.container = React.createRef();
|
|
62
|
+
}
|
|
63
|
+
async componentDidMount() {
|
|
64
|
+
if (!this.rendering) {
|
|
65
|
+
this.rendering = this.createAndRenderChart();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async componentDidUpdate(prevProps) {
|
|
69
|
+
if (didPropsChange(this.props, prevProps) && this.chart) {
|
|
70
|
+
this.destroyChart();
|
|
71
|
+
this.createAndRenderChart();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async createAndRenderChart() {
|
|
75
|
+
const seatsio2 = await this.getSeatsio();
|
|
76
|
+
const config = this.extractConfigFromProps();
|
|
77
|
+
config.container = this.container.current;
|
|
78
|
+
this.chart = this.createChart(seatsio2, config).render();
|
|
79
|
+
if (this.props.onRenderStarted) {
|
|
80
|
+
this.props.onRenderStarted(this.chart);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
extractConfigFromProps() {
|
|
84
|
+
let { chartJsUrl, divId, onRenderStarted, region, ...config } = this.props;
|
|
85
|
+
return config;
|
|
86
|
+
}
|
|
87
|
+
componentWillUnmount() {
|
|
88
|
+
this.destroyChart();
|
|
89
|
+
}
|
|
90
|
+
destroyChart() {
|
|
91
|
+
if (this.chart && this.chart.state !== "DESTROYED") {
|
|
92
|
+
this.chart.destroy();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
getSeatsio() {
|
|
96
|
+
if (typeof seatsio === "undefined") {
|
|
97
|
+
return this.loadSeatsio();
|
|
98
|
+
} else if (seatsio.region !== this.props.region) {
|
|
99
|
+
seatsio = void 0;
|
|
100
|
+
return this.loadSeatsio();
|
|
101
|
+
} else {
|
|
102
|
+
return Promise.resolve(seatsio);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
loadSeatsio() {
|
|
106
|
+
return new Promise((resolve, reject) => {
|
|
107
|
+
let script = document.createElement("script");
|
|
108
|
+
script.onload = () => {
|
|
109
|
+
seatsio.region = this.props.region;
|
|
110
|
+
resolve(seatsio);
|
|
111
|
+
};
|
|
112
|
+
script.onerror = () => reject(`Could not load ${script.src}`);
|
|
113
|
+
script.src = this.props.chartJsUrl.replace("{region}", this.props.region);
|
|
114
|
+
document.head.appendChild(script);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
render() {
|
|
118
|
+
return /* @__PURE__ */ React.createElement("div", { ref: this.container, style: { "height": "100%", "width": "100%" } });
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
Embeddable.defaultProps = {
|
|
122
|
+
chartJsUrl: "https://cdn-{region}.seatsio.net/chart.js"
|
|
123
|
+
};
|
|
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 rendering?: Promise<void>\n private chart: SeatingChart\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 }\n\n abstract createChart (seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner\n\n async componentDidMount () {\n if(!this.rendering) {\n this.rendering = this.createAndRenderChart()\n }\n }\n\n async componentDidUpdate (prevProps: EmbeddableProps<T>) {\n if (didPropsChange(this.props, prevProps) && this.chart) {\n this.destroyChart()\n this.createAndRenderChart()\n }\n }\n\n async createAndRenderChart () {\n const seatsio = await this.getSeatsio()\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 // noinspection JSUnusedLocalSymbols\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 getSeatsio () {\n if (typeof seatsio === 'undefined') {\n return this.loadSeatsio()\n } else if (seatsio.region !== this.props.region) {\n seatsio = undefined\n return this.loadSeatsio()\n } else {\n return Promise.resolve(seatsio)\n }\n }\n\n loadSeatsio () {\n return new Promise((resolve, reject) => {\n let script = document.createElement('script')\n script.onload = () => {\n seatsio.region = this.props.region\n resolve(seatsio)\n }\n script.onerror = () => reject(`Could not load ${script.src}`)\n script.src = this.props.chartJsUrl.replace('{region}', this.props.region)\n document.head.appendChild(script)\n })\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}"],"mappings":"
|
|
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) => 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 rendering?: Promise<void>\n private chart: SeatingChart\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 }\n\n abstract createChart (seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner\n\n async componentDidMount () {\n if(!this.rendering) {\n this.rendering = this.createAndRenderChart()\n }\n }\n\n async componentDidUpdate (prevProps: EmbeddableProps<T>) {\n if (didPropsChange(this.props, prevProps) && this.chart) {\n this.destroyChart()\n this.createAndRenderChart()\n }\n }\n\n async createAndRenderChart () {\n const seatsio = await this.getSeatsio()\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 // noinspection JSUnusedLocalSymbols\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 getSeatsio () {\n if (typeof seatsio === 'undefined') {\n return this.loadSeatsio()\n } else if (seatsio.region !== this.props.region) {\n seatsio = undefined\n return this.loadSeatsio()\n } else {\n return Promise.resolve(seatsio)\n }\n }\n\n loadSeatsio () {\n return new Promise((resolve, reject) => {\n let script = document.createElement('script')\n script.onload = () => {\n seatsio.region = this.props.region\n resolve(seatsio)\n }\n script.onerror = () => reject(`Could not load ${script.src}`)\n script.src = this.props.chartJsUrl.replace('{region}', this.props.region)\n document.head.appendChild(script)\n })\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,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;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A,cAAe;AACX,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACpC,UAAI,SAAS,SAAS,cAAc,QAAQ;AAC5C,aAAO,SAAS,MAAM;AAClB,gBAAQ,SAAS,KAAK,MAAM;AAC5B,gBAAQ,OAAO;AAAA,MACnB;AACA,aAAO,UAAU,MAAM,OAAO,kBAAkB,OAAO,GAAG,EAAE;AAC5D,aAAO,MAAM,KAAK,MAAM,WAAW,QAAQ,YAAY,KAAK,MAAM,MAAM;AACxE,eAAS,KAAK,YAAY,MAAM;AAAA,IACpC,CAAC;AAAA,EACL;AAAA,EAEA,SAA2B;AACvB,WACI,oCAAC,SAAI,KAAK,KAAK,WAAyD,OAAO,EAAC,UAAU,QAAQ,SAAS,OAAM,GAAG;AAAA,EAE5H;AACJ;AApF8B,WAKnB,eAAe;AAAA,EAClB,YAAY;AAChB;","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 extends React.Component {
|
|
26
|
+
constructor(props) {
|
|
27
|
+
super(props);
|
|
28
|
+
this.container = React.createRef();
|
|
29
|
+
}
|
|
30
|
+
async componentDidMount() {
|
|
31
|
+
if (!this.rendering) {
|
|
32
|
+
this.rendering = this.createAndRenderChart();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async componentDidUpdate(prevProps) {
|
|
36
|
+
if (didPropsChange(this.props, prevProps) && this.chart) {
|
|
37
|
+
this.destroyChart();
|
|
38
|
+
this.createAndRenderChart();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async createAndRenderChart() {
|
|
42
|
+
const seatsio2 = await this.getSeatsio();
|
|
43
|
+
const config = this.extractConfigFromProps();
|
|
44
|
+
config.container = this.container.current;
|
|
45
|
+
this.chart = this.createChart(seatsio2, config).render();
|
|
46
|
+
if (this.props.onRenderStarted) {
|
|
47
|
+
this.props.onRenderStarted(this.chart);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
extractConfigFromProps() {
|
|
51
|
+
let { chartJsUrl, divId, onRenderStarted, region, ...config } = this.props;
|
|
52
|
+
return config;
|
|
53
|
+
}
|
|
54
|
+
componentWillUnmount() {
|
|
55
|
+
this.destroyChart();
|
|
56
|
+
}
|
|
57
|
+
destroyChart() {
|
|
58
|
+
if (this.chart && this.chart.state !== "DESTROYED") {
|
|
59
|
+
this.chart.destroy();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
getSeatsio() {
|
|
63
|
+
if (typeof seatsio === "undefined") {
|
|
64
|
+
return this.loadSeatsio();
|
|
65
|
+
} else if (seatsio.region !== this.props.region) {
|
|
66
|
+
seatsio = void 0;
|
|
67
|
+
return this.loadSeatsio();
|
|
68
|
+
} else {
|
|
69
|
+
return Promise.resolve(seatsio);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
loadSeatsio() {
|
|
73
|
+
return new Promise((resolve, reject) => {
|
|
74
|
+
let script = document.createElement("script");
|
|
75
|
+
script.onload = () => {
|
|
76
|
+
seatsio.region = this.props.region;
|
|
77
|
+
resolve(seatsio);
|
|
78
|
+
};
|
|
79
|
+
script.onerror = () => reject(`Could not load ${script.src}`);
|
|
80
|
+
script.src = this.props.chartJsUrl.replace("{region}", this.props.region);
|
|
81
|
+
document.head.appendChild(script);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
render() {
|
|
85
|
+
return /* @__PURE__ */ React.createElement("div", { ref: this.container, style: { "height": "100%", "width": "100%" } });
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
Embeddable.defaultProps = {
|
|
89
|
+
chartJsUrl: "https://cdn-{region}.seatsio.net/chart.js"
|
|
90
|
+
};
|
|
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 rendering?: Promise<void>\n private chart: SeatingChart\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 }\n\n abstract createChart (seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner\n\n async componentDidMount () {\n if(!this.rendering) {\n this.rendering = this.createAndRenderChart()\n }\n }\n\n async componentDidUpdate (prevProps: EmbeddableProps<T>) {\n if (didPropsChange(this.props, prevProps) && this.chart) {\n this.destroyChart()\n this.createAndRenderChart()\n }\n }\n\n async createAndRenderChart () {\n const seatsio = await this.getSeatsio()\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 // noinspection JSUnusedLocalSymbols\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 getSeatsio () {\n if (typeof seatsio === 'undefined') {\n return this.loadSeatsio()\n } else if (seatsio.region !== this.props.region) {\n seatsio = undefined\n return this.loadSeatsio()\n } else {\n return Promise.resolve(seatsio)\n }\n }\n\n loadSeatsio () {\n return new Promise((resolve, reject) => {\n let script = document.createElement('script')\n script.onload = () => {\n seatsio.region = this.props.region\n resolve(seatsio)\n }\n script.onerror = () => reject(`Could not load ${script.src}`)\n script.src = this.props.chartJsUrl.replace('{region}', this.props.region)\n document.head.appendChild(script)\n })\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}"],"mappings":"AAAA,
|
|
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) => 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 rendering?: Promise<void>\n private chart: SeatingChart\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 }\n\n abstract createChart (seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner\n\n async componentDidMount () {\n if(!this.rendering) {\n this.rendering = this.createAndRenderChart()\n }\n }\n\n async componentDidUpdate (prevProps: EmbeddableProps<T>) {\n if (didPropsChange(this.props, prevProps) && this.chart) {\n this.destroyChart()\n this.createAndRenderChart()\n }\n }\n\n async createAndRenderChart () {\n const seatsio = await this.getSeatsio()\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 // noinspection JSUnusedLocalSymbols\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 getSeatsio () {\n if (typeof seatsio === 'undefined') {\n return this.loadSeatsio()\n } else if (seatsio.region !== this.props.region) {\n seatsio = undefined\n return this.loadSeatsio()\n } else {\n return Promise.resolve(seatsio)\n }\n }\n\n loadSeatsio () {\n return new Promise((resolve, reject) => {\n let script = document.createElement('script')\n script.onload = () => {\n seatsio.region = this.props.region\n resolve(seatsio)\n }\n script.onerror = () => reject(`Could not load ${script.src}`)\n script.src = this.props.chartJsUrl.replace('{region}', this.props.region)\n document.head.appendChild(script)\n })\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,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,aAA9B,cAAsF,gBAA8B;AAAA,EAShH,YAAY,OAA2B;AACnC,UAAM,KA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,gBAAQ,SAAS,KAAK,MAAM;AAC5B,gBAAQ,OAAO;AAAA,MACnB;AACA,aAAO,UAAU,MAAM,OAAO,kBAAkB,OAAO,GAAG,EAAE;AAC5D,aAAO,MAAM,KAAK,MAAM,WAAW,QAAQ,YAAY,KAAK,MAAM,MAAM;AACxE,eAAS,KAAK,YAAY,MAAM;AAAA,IACpC,CAAC;AAAA,EACL;AAAA,EAEA,SAA2B;AACvB,WACI,oCAAC,SAAI,KAAK,KAAK,WAAyD,OAAO,EAAC,UAAU,QAAQ,SAAS,OAAM,GAAG;AAAA,EAE5H;AACJ;AApF8B,WAKnB,eAAe;AAAA,EAClB,YAAY;AAChB;","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 extends React.Component {
|
|
61
|
+
constructor(props) {
|
|
62
|
+
super(props);
|
|
63
|
+
this.container = React.createRef();
|
|
64
|
+
}
|
|
65
|
+
async componentDidMount() {
|
|
66
|
+
if (!this.rendering) {
|
|
67
|
+
this.rendering = this.createAndRenderChart();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async componentDidUpdate(prevProps) {
|
|
71
|
+
if (didPropsChange(this.props, prevProps) && this.chart) {
|
|
72
|
+
this.destroyChart();
|
|
73
|
+
this.createAndRenderChart();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async createAndRenderChart() {
|
|
77
|
+
const seatsio2 = await this.getSeatsio();
|
|
78
|
+
const config = this.extractConfigFromProps();
|
|
79
|
+
config.container = this.container.current;
|
|
80
|
+
this.chart = this.createChart(seatsio2, config).render();
|
|
81
|
+
if (this.props.onRenderStarted) {
|
|
82
|
+
this.props.onRenderStarted(this.chart);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
extractConfigFromProps() {
|
|
86
|
+
let { chartJsUrl, divId, onRenderStarted, region, ...config } = this.props;
|
|
87
|
+
return config;
|
|
88
|
+
}
|
|
89
|
+
componentWillUnmount() {
|
|
90
|
+
this.destroyChart();
|
|
91
|
+
}
|
|
92
|
+
destroyChart() {
|
|
93
|
+
if (this.chart && this.chart.state !== "DESTROYED") {
|
|
94
|
+
this.chart.destroy();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
getSeatsio() {
|
|
98
|
+
if (typeof seatsio === "undefined") {
|
|
99
|
+
return this.loadSeatsio();
|
|
100
|
+
} else if (seatsio.region !== this.props.region) {
|
|
101
|
+
seatsio = void 0;
|
|
102
|
+
return this.loadSeatsio();
|
|
103
|
+
} else {
|
|
104
|
+
return Promise.resolve(seatsio);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
loadSeatsio() {
|
|
108
|
+
return new Promise((resolve, reject) => {
|
|
109
|
+
let script = document.createElement("script");
|
|
110
|
+
script.onload = () => {
|
|
111
|
+
seatsio.region = this.props.region;
|
|
112
|
+
resolve(seatsio);
|
|
113
|
+
};
|
|
114
|
+
script.onerror = () => reject(`Could not load ${script.src}`);
|
|
115
|
+
script.src = this.props.chartJsUrl.replace("{region}", this.props.region);
|
|
116
|
+
document.head.appendChild(script);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
render() {
|
|
120
|
+
return /* @__PURE__ */ React.createElement("div", { ref: this.container, style: { "height": "100%", "width": "100%" } });
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
Embeddable.defaultProps = {
|
|
124
|
+
chartJsUrl: "https://cdn-{region}.seatsio.net/chart.js"
|
|
125
|
+
};
|
|
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) => 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 rendering?: Promise<void>\n private chart: SeatingChart\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 }\n\n abstract createChart (seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner\n\n async componentDidMount () {\n if(!this.rendering) {\n this.rendering = this.createAndRenderChart()\n }\n }\n\n async componentDidUpdate (prevProps: EmbeddableProps<T>) {\n if (didPropsChange(this.props, prevProps) && this.chart) {\n this.destroyChart()\n this.createAndRenderChart()\n }\n }\n\n async createAndRenderChart () {\n const seatsio = await this.getSeatsio()\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 // noinspection JSUnusedLocalSymbols\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 getSeatsio () {\n if (typeof seatsio === 'undefined') {\n return this.loadSeatsio()\n } else if (seatsio.region !== this.props.region) {\n seatsio = undefined\n return this.loadSeatsio()\n } else {\n return Promise.resolve(seatsio)\n }\n }\n\n loadSeatsio () {\n return new Promise((resolve, reject) => {\n let script = document.createElement('script')\n script.onload = () => {\n seatsio.region = this.props.region\n resolve(seatsio)\n }\n script.onerror = () => reject(`Could not load ${script.src}`)\n script.src = this.props.chartJsUrl.replace('{region}', this.props.region)\n document.head.appendChild(script)\n })\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,cAA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C5B,WAAW,QAAQ,WAAW,KAAK,MAAM,QAAQ;AAC7C,gBAAU;AACV,aAAO,KAAK,YAAY;AAAA,IAC5B,OAAO;AACH,aAAO,QAAQ,QAAQ,OAAO;AAAA,IAClC;AAAA,EACJ;AAAA,EAEA,cAAe;AACX,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACpC,UAAI,SAAS,SAAS,cAAc,QAAQ;AAC5C,aAAO,SAAS,MAAM;AAClB,gBAAQ,SAAS,KAAK,MAAM;AAC5B,gBAAQ,OAAO;AAAA,MACnB;AACA,aAAO,UAAU,MAAM,OAAO,kBAAkB,OAAO,GAAG,EAAE;AAC5D,aAAO,MAAM,KAAK,MAAM,WAAW,QAAQ,YAAY,KAAK,MAAM,MAAM;AACxE,eAAS,KAAK,YAAY,MAAM;AAAA,IACpC,CAAC;AAAA,EACL;AAAA,EAEA,SAA2B;AACvB,WACI,oCAAC,SAAI,KAAK,KAAK,WAAyD,OAAO,EAAC,UAAU,QAAQ,SAAS,OAAM,GAAG;AAAA,EAE5H;AACJ;AApF8B,WAKnB,eAAe;AAAA,EAClB,YAAY;AAChB;;;ADdJ,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 extends React.Component {
|
|
26
|
+
constructor(props) {
|
|
27
|
+
super(props);
|
|
28
|
+
this.container = React.createRef();
|
|
29
|
+
}
|
|
30
|
+
async componentDidMount() {
|
|
31
|
+
if (!this.rendering) {
|
|
32
|
+
this.rendering = this.createAndRenderChart();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async componentDidUpdate(prevProps) {
|
|
36
|
+
if (didPropsChange(this.props, prevProps) && this.chart) {
|
|
37
|
+
this.destroyChart();
|
|
38
|
+
this.createAndRenderChart();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async createAndRenderChart() {
|
|
42
|
+
const seatsio2 = await this.getSeatsio();
|
|
43
|
+
const config = this.extractConfigFromProps();
|
|
44
|
+
config.container = this.container.current;
|
|
45
|
+
this.chart = this.createChart(seatsio2, config).render();
|
|
46
|
+
if (this.props.onRenderStarted) {
|
|
47
|
+
this.props.onRenderStarted(this.chart);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
extractConfigFromProps() {
|
|
51
|
+
let { chartJsUrl, divId, onRenderStarted, region, ...config } = this.props;
|
|
52
|
+
return config;
|
|
53
|
+
}
|
|
54
|
+
componentWillUnmount() {
|
|
55
|
+
this.destroyChart();
|
|
56
|
+
}
|
|
57
|
+
destroyChart() {
|
|
58
|
+
if (this.chart && this.chart.state !== "DESTROYED") {
|
|
59
|
+
this.chart.destroy();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
getSeatsio() {
|
|
63
|
+
if (typeof seatsio === "undefined") {
|
|
64
|
+
return this.loadSeatsio();
|
|
65
|
+
} else if (seatsio.region !== this.props.region) {
|
|
66
|
+
seatsio = void 0;
|
|
67
|
+
return this.loadSeatsio();
|
|
68
|
+
} else {
|
|
69
|
+
return Promise.resolve(seatsio);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
loadSeatsio() {
|
|
73
|
+
return new Promise((resolve, reject) => {
|
|
74
|
+
let script = document.createElement("script");
|
|
75
|
+
script.onload = () => {
|
|
76
|
+
seatsio.region = this.props.region;
|
|
77
|
+
resolve(seatsio);
|
|
78
|
+
};
|
|
79
|
+
script.onerror = () => reject(`Could not load ${script.src}`);
|
|
80
|
+
script.src = this.props.chartJsUrl.replace("{region}", this.props.region);
|
|
81
|
+
document.head.appendChild(script);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
render() {
|
|
85
|
+
return /* @__PURE__ */ React.createElement("div", { ref: this.container, style: { "height": "100%", "width": "100%" } });
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
Embeddable.defaultProps = {
|
|
89
|
+
chartJsUrl: "https://cdn-{region}.seatsio.net/chart.js"
|
|
90
|
+
};
|
|
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
|
|
@@ -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":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/main/Embeddable.tsx","../src/main/util.ts","../src/main/SeatsioDesigner.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 rendering?: Promise<void>\n private chart: SeatingChart\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 }\n\n abstract createChart (seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner\n\n async componentDidMount () {\n if(!this.rendering) {\n this.rendering = this.createAndRenderChart()\n }\n }\n\n async componentDidUpdate (prevProps: EmbeddableProps<T>) {\n if (didPropsChange(this.props, prevProps) && this.chart) {\n this.destroyChart()\n this.createAndRenderChart()\n }\n }\n\n async createAndRenderChart () {\n const seatsio = await this.getSeatsio()\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 // noinspection JSUnusedLocalSymbols\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 getSeatsio () {\n if (typeof seatsio === 'undefined') {\n return this.loadSeatsio()\n } else if (seatsio.region !== this.props.region) {\n seatsio = undefined\n return this.loadSeatsio()\n } else {\n return Promise.resolve(seatsio)\n }\n }\n\n loadSeatsio () {\n return new Promise((resolve, reject) => {\n let script = document.createElement('script')\n script.onload = () => {\n seatsio.region = this.props.region\n resolve(seatsio)\n }\n script.onerror = () => reject(`Could not load ${script.src}`)\n script.src = this.props.chartJsUrl.replace('{region}', this.props.region)\n document.head.appendChild(script)\n })\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'","import Embeddable from './Embeddable'\nimport { ChartDesignerConfigOptions, Seatsio } from '@seatsio/seatsio-types'\n\nexport default class SeatsioDesigner extends Embeddable<ChartDesignerConfigOptions> {\n createChart (seatsio: Seatsio, config: ChartD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