@seatsio/seatsio-react 15.4.0 → 15.6.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 +12 -0
- package/build/index.d.mts +3 -8
- package/build/index.d.ts +3 -8
- package/build/index.js +14 -15
- package/build/index.js.map +1 -1
- package/build/index.mjs +10 -10
- package/build/index.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -50,6 +50,18 @@ const pricing: Pricing = [
|
|
|
50
50
|
/>
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
Areas have different properties than seats or tables. To distinguish between them, you can use the `objectType` property:
|
|
54
|
+
|
|
55
|
+
```jsx
|
|
56
|
+
onObjectSelected: (object) => {
|
|
57
|
+
if(object.objectType === 'GeneralAdmissionArea') {
|
|
58
|
+
console.log(`I am an area with ${object.numSelected} selected places`)
|
|
59
|
+
} else {
|
|
60
|
+
console.log('I am a seat, booth or table')
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
53
65
|
### onRenderStarted()
|
|
54
66
|
|
|
55
67
|
`onRenderStarted` is fired when the chart has started loading, but hasn't rendered yet:
|
package/build/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _seatsio_seatsio_types from '@seatsio/seatsio-types';
|
|
2
|
-
import { CommonConfigOptions, Seatsio, SeatingChart, EventManager, ChartDesigner, Region, ChartDesignerConfigOptions, EventManagerConfigOptions, ChartRendererConfigOptions
|
|
2
|
+
import { CommonConfigOptions, Seatsio, SeatingChart, EventManager, ChartDesigner, Region, ChartDesignerConfigOptions, EventManagerConfigOptions, ChartRendererConfigOptions } from '@seatsio/seatsio-types';
|
|
3
3
|
export * from '@seatsio/seatsio-types';
|
|
4
|
+
export { isBooth, isGeneralAdmission, isSeat, isTable } from '@seatsio/seatsio-types';
|
|
4
5
|
import * as React from 'react';
|
|
5
6
|
|
|
6
7
|
type EmbeddableProps<T> = {
|
|
@@ -41,10 +42,4 @@ declare class SeatsioSeatingChart extends Embeddable<ChartRendererConfigOptions>
|
|
|
41
42
|
createChart(seatsio: Seatsio, config: ChartRendererConfigOptions): _seatsio_seatsio_types.SeatingChart;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
declare const isTable: (obj: SelectableObject) => obj is Table;
|
|
46
|
-
declare const isSection: (obj: SelectableObject) => obj is InteractiveSection;
|
|
47
|
-
declare const isBooth: (obj: SelectableObject) => obj is Booth;
|
|
48
|
-
declare const isGeneralAdmission: (obj: SelectableObject) => obj is GeneralAdmissionArea;
|
|
49
|
-
|
|
50
|
-
export { SeatsioDesigner, SeatsioEventManager, SeatsioSeatingChart, isBooth, isGeneralAdmission, isSeat, isSection, isTable };
|
|
45
|
+
export { SeatsioDesigner, SeatsioEventManager, SeatsioSeatingChart };
|
package/build/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _seatsio_seatsio_types from '@seatsio/seatsio-types';
|
|
2
|
-
import { CommonConfigOptions, Seatsio, SeatingChart, EventManager, ChartDesigner, Region, ChartDesignerConfigOptions, EventManagerConfigOptions, ChartRendererConfigOptions
|
|
2
|
+
import { CommonConfigOptions, Seatsio, SeatingChart, EventManager, ChartDesigner, Region, ChartDesignerConfigOptions, EventManagerConfigOptions, ChartRendererConfigOptions } from '@seatsio/seatsio-types';
|
|
3
3
|
export * from '@seatsio/seatsio-types';
|
|
4
|
+
export { isBooth, isGeneralAdmission, isSeat, isTable } from '@seatsio/seatsio-types';
|
|
4
5
|
import * as React from 'react';
|
|
5
6
|
|
|
6
7
|
type EmbeddableProps<T> = {
|
|
@@ -41,10 +42,4 @@ declare class SeatsioSeatingChart extends Embeddable<ChartRendererConfigOptions>
|
|
|
41
42
|
createChart(seatsio: Seatsio, config: ChartRendererConfigOptions): _seatsio_seatsio_types.SeatingChart;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
declare const isTable: (obj: SelectableObject) => obj is Table;
|
|
46
|
-
declare const isSection: (obj: SelectableObject) => obj is InteractiveSection;
|
|
47
|
-
declare const isBooth: (obj: SelectableObject) => obj is Booth;
|
|
48
|
-
declare const isGeneralAdmission: (obj: SelectableObject) => obj is GeneralAdmissionArea;
|
|
49
|
-
|
|
50
|
-
export { SeatsioDesigner, SeatsioEventManager, SeatsioSeatingChart, isBooth, isGeneralAdmission, isSeat, isSection, isTable };
|
|
45
|
+
export { SeatsioDesigner, SeatsioEventManager, SeatsioSeatingChart };
|
package/build/index.js
CHANGED
|
@@ -32,11 +32,10 @@ __export(main_exports, {
|
|
|
32
32
|
SeatsioDesigner: () => SeatsioDesigner,
|
|
33
33
|
SeatsioEventManager: () => SeatsioEventManager,
|
|
34
34
|
SeatsioSeatingChart: () => SeatsioSeatingChart,
|
|
35
|
-
isBooth: () => isBooth,
|
|
36
|
-
isGeneralAdmission: () => isGeneralAdmission,
|
|
37
|
-
isSeat: () => isSeat,
|
|
38
|
-
|
|
39
|
-
isTable: () => isTable
|
|
35
|
+
isBooth: () => import_seatsio_types.isBooth,
|
|
36
|
+
isGeneralAdmission: () => import_seatsio_types.isGeneralAdmission,
|
|
37
|
+
isSeat: () => import_seatsio_types.isSeat,
|
|
38
|
+
isTable: () => import_seatsio_types.isTable
|
|
40
39
|
});
|
|
41
40
|
module.exports = __toCommonJS(main_exports);
|
|
42
41
|
|
|
@@ -62,11 +61,6 @@ var didPropsChange = (prevProps, nextProps) => {
|
|
|
62
61
|
return prevValue !== nextValue;
|
|
63
62
|
});
|
|
64
63
|
};
|
|
65
|
-
var isSeat = (obj) => obj.objectType === "Seat";
|
|
66
|
-
var isTable = (obj) => obj.objectType === "Table";
|
|
67
|
-
var isSection = (obj) => obj.objectType === "section";
|
|
68
|
-
var isBooth = (obj) => obj.objectType === "Booth";
|
|
69
|
-
var isGeneralAdmission = (obj) => obj.objectType === "GeneralAdmissionArea";
|
|
70
64
|
|
|
71
65
|
// src/main/Embeddable.tsx
|
|
72
66
|
var _Embeddable = class _Embeddable extends React.Component {
|
|
@@ -82,9 +76,12 @@ var _Embeddable = class _Embeddable extends React.Component {
|
|
|
82
76
|
}
|
|
83
77
|
}
|
|
84
78
|
componentDidUpdate(prevProps) {
|
|
85
|
-
if (
|
|
86
|
-
this.
|
|
87
|
-
this.
|
|
79
|
+
if (this.chart) {
|
|
80
|
+
this.chart.config = this.extractConfigFromProps();
|
|
81
|
+
if (didPropsChange(this.props, prevProps)) {
|
|
82
|
+
this.destroyChart();
|
|
83
|
+
this.createAndRenderChart();
|
|
84
|
+
}
|
|
88
85
|
}
|
|
89
86
|
}
|
|
90
87
|
getChartUrl() {
|
|
@@ -93,7 +90,6 @@ var _Embeddable = class _Embeddable extends React.Component {
|
|
|
93
90
|
async createAndRenderChart() {
|
|
94
91
|
const seatsio2 = await this.loadSeatsio();
|
|
95
92
|
const config = this.extractConfigFromProps();
|
|
96
|
-
config.container = this.container.current;
|
|
97
93
|
this.chart = this.createChart(seatsio2, config).render();
|
|
98
94
|
if (this.props.onRenderStarted) {
|
|
99
95
|
this.props.onRenderStarted(this.chart);
|
|
@@ -101,6 +97,7 @@ var _Embeddable = class _Embeddable extends React.Component {
|
|
|
101
97
|
}
|
|
102
98
|
extractConfigFromProps() {
|
|
103
99
|
let { chartJsUrl, divId, onRenderStarted, region, ...config } = this.props;
|
|
100
|
+
config.container = this.container.current;
|
|
104
101
|
return config;
|
|
105
102
|
}
|
|
106
103
|
componentWillUnmount() {
|
|
@@ -156,6 +153,9 @@ var SeatsioSeatingChart = class extends Embeddable {
|
|
|
156
153
|
return new seatsio2.SeatingChart(config);
|
|
157
154
|
}
|
|
158
155
|
};
|
|
156
|
+
|
|
157
|
+
// src/main/index.ts
|
|
158
|
+
var import_seatsio_types = require("@seatsio/seatsio-types");
|
|
159
159
|
// Annotate the CommonJS export names for ESM import in node:
|
|
160
160
|
0 && (module.exports = {
|
|
161
161
|
SeatsioDesigner,
|
|
@@ -164,7 +164,6 @@ var SeatsioSeatingChart = class extends Embeddable {
|
|
|
164
164
|
isBooth,
|
|
165
165
|
isGeneralAdmission,
|
|
166
166
|
isSeat,
|
|
167
|
-
isSection,
|
|
168
167
|
isTable
|
|
169
168
|
});
|
|
170
169
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/main/index.ts","../src/main/Embeddable.tsx","../src/main/util.ts","../src/main/SeatsioDesigner.tsx","../src/main/SeatsioEventManager.tsx","../src/main/SeatsioSeatingChart.tsx"],"sourcesContent":["export { default as SeatsioDesigner } from './SeatsioDesigner'\nexport { default as SeatsioEventManager } from './SeatsioEventManager'\nexport { default as SeatsioSeatingChart } from './SeatsioSeatingChart'\nexport { isBooth, isGeneralAdmission, isSeat,
|
|
1
|
+
{"version":3,"sources":["../src/main/index.ts","../src/main/Embeddable.tsx","../src/main/util.ts","../src/main/SeatsioDesigner.tsx","../src/main/SeatsioEventManager.tsx","../src/main/SeatsioSeatingChart.tsx"],"sourcesContent":["export { default as SeatsioDesigner } from './SeatsioDesigner'\nexport { default as SeatsioEventManager } from './SeatsioEventManager'\nexport { default as SeatsioSeatingChart } from './SeatsioSeatingChart'\nexport { isBooth, isGeneralAdmission, isSeat, isTable } from '@seatsio/seatsio-types'\nexport type * from '@seatsio/seatsio-types'\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(this.chart) {\n // @ts-ignore\n this.chart.config = this.extractConfigFromProps()\n if (didPropsChange(this.props, prevProps)) {\n this.destroyChart()\n this.createAndRenderChart()\n }\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 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 // @ts-ignore\n config.container = this.container.current\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}\n","import {Booth, GeneralAdmissionArea, InteractiveSection, Seat, SelectableObject, Table} 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","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 { EventManagerConfigOptions, Seatsio } from '@seatsio/seatsio-types'\nimport Embeddable from './Embeddable'\n\nexport default class SeatsioEventManager extends Embeddable<EventManagerConfigOptions> {\n createChart (seatsio: Seatsio, config: EventManagerConfigOptions) {\n return new seatsio.EventManager(config)\n }\n}","import { ChartRendererConfigOptions, Seatsio } from '@seatsio/seatsio-types'\nimport Embeddable from './Embeddable'\n\nexport default class SeatsioSeatingChart extends Embeddable<ChartRendererConfigOptions> {\n createChart (seatsio: Seatsio, config: ChartRendererConfigOptions) {\n return new seatsio.SeatingChart(config)\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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,EA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iD,WAAuC;AAAA,EACpF,YAAaC,UAAkB,QAAoC;AAC/D,WAAO,IAAIA,SAAQ,aAAa,MAAM;AAAA,EAC1C;AACJ;;;ALJA,2BAA6D;","names":["seatsio","seatsio","seatsio","seatsio"]}
|
package/build/index.mjs
CHANGED
|
@@ -20,11 +20,6 @@ var didPropsChange = (prevProps, nextProps) => {
|
|
|
20
20
|
return prevValue !== nextValue;
|
|
21
21
|
});
|
|
22
22
|
};
|
|
23
|
-
var isSeat = (obj) => obj.objectType === "Seat";
|
|
24
|
-
var isTable = (obj) => obj.objectType === "Table";
|
|
25
|
-
var isSection = (obj) => obj.objectType === "section";
|
|
26
|
-
var isBooth = (obj) => obj.objectType === "Booth";
|
|
27
|
-
var isGeneralAdmission = (obj) => obj.objectType === "GeneralAdmissionArea";
|
|
28
23
|
|
|
29
24
|
// src/main/Embeddable.tsx
|
|
30
25
|
var _Embeddable = class _Embeddable extends React.Component {
|
|
@@ -40,9 +35,12 @@ var _Embeddable = class _Embeddable extends React.Component {
|
|
|
40
35
|
}
|
|
41
36
|
}
|
|
42
37
|
componentDidUpdate(prevProps) {
|
|
43
|
-
if (
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
38
|
+
if (this.chart) {
|
|
39
|
+
this.chart.config = this.extractConfigFromProps();
|
|
40
|
+
if (didPropsChange(this.props, prevProps)) {
|
|
41
|
+
this.destroyChart();
|
|
42
|
+
this.createAndRenderChart();
|
|
43
|
+
}
|
|
46
44
|
}
|
|
47
45
|
}
|
|
48
46
|
getChartUrl() {
|
|
@@ -51,7 +49,6 @@ var _Embeddable = class _Embeddable extends React.Component {
|
|
|
51
49
|
async createAndRenderChart() {
|
|
52
50
|
const seatsio2 = await this.loadSeatsio();
|
|
53
51
|
const config = this.extractConfigFromProps();
|
|
54
|
-
config.container = this.container.current;
|
|
55
52
|
this.chart = this.createChart(seatsio2, config).render();
|
|
56
53
|
if (this.props.onRenderStarted) {
|
|
57
54
|
this.props.onRenderStarted(this.chart);
|
|
@@ -59,6 +56,7 @@ var _Embeddable = class _Embeddable extends React.Component {
|
|
|
59
56
|
}
|
|
60
57
|
extractConfigFromProps() {
|
|
61
58
|
let { chartJsUrl, divId, onRenderStarted, region, ...config } = this.props;
|
|
59
|
+
config.container = this.container.current;
|
|
62
60
|
return config;
|
|
63
61
|
}
|
|
64
62
|
componentWillUnmount() {
|
|
@@ -114,6 +112,9 @@ var SeatsioSeatingChart = class extends Embeddable {
|
|
|
114
112
|
return new seatsio2.SeatingChart(config);
|
|
115
113
|
}
|
|
116
114
|
};
|
|
115
|
+
|
|
116
|
+
// src/main/index.ts
|
|
117
|
+
import { isBooth, isGeneralAdmission, isSeat, isTable } from "@seatsio/seatsio-types";
|
|
117
118
|
export {
|
|
118
119
|
SeatsioDesigner,
|
|
119
120
|
SeatsioEventManager,
|
|
@@ -121,7 +122,6 @@ export {
|
|
|
121
122
|
isBooth,
|
|
122
123
|
isGeneralAdmission,
|
|
123
124
|
isSeat,
|
|
124
|
-
isSection,
|
|
125
125
|
isTable
|
|
126
126
|
};
|
|
127
127
|
//# sourceMappingURL=index.mjs.map
|
package/build/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/main/Embeddable.tsx","../src/main/util.ts","../src/main/SeatsioDesigner.tsx","../src/main/SeatsioEventManager.tsx","../src/main/SeatsioSeatingChart.tsx"],"sourcesContent":["import * as React from 'react'\nimport {didPropsChange} from './util'\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/main/Embeddable.tsx","../src/main/util.ts","../src/main/SeatsioDesigner.tsx","../src/main/SeatsioEventManager.tsx","../src/main/SeatsioSeatingChart.tsx","../src/main/index.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(this.chart) {\n // @ts-ignore\n this.chart.config = this.extractConfigFromProps()\n if (didPropsChange(this.props, prevProps)) {\n this.destroyChart()\n this.createAndRenderChart()\n }\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 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 // @ts-ignore\n config.container = this.container.current\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}\n","import {Booth, GeneralAdmissionArea, InteractiveSection, Seat, SelectableObject, Table} 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","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 { EventManagerConfigOptions, Seatsio } from '@seatsio/seatsio-types'\nimport Embeddable from './Embeddable'\n\nexport default class SeatsioEventManager extends Embeddable<EventManagerConfigOptions> {\n createChart (seatsio: Seatsio, config: EventManagerConfigOptions) {\n return new seatsio.EventManager(config)\n }\n}","import { ChartRendererConfigOptions, Seatsio } from '@seatsio/seatsio-types'\nimport Embeddable from './Embeddable'\n\nexport default class SeatsioSeatingChart extends Embeddable<ChartRendererConfigOptions> {\n createChart (seatsio: Seatsio, config: ChartRendererConfigOptions) {\n return new seatsio.SeatingChart(config)\n }\n}","export { default as SeatsioDesigner } from './SeatsioDesigner'\nexport { default as SeatsioEventManager } from './SeatsioEventManager'\nexport { default as SeatsioSeatingChart } from './SeatsioSeatingChart'\nexport { isBooth, isGeneralAdmission, isSeat, isTable } from '@seatsio/seatsio-types'\nexport type * from '@seatsio/seatsio-types'\n"],"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,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,KAAK,KAAK,aAAa;AACpE,WAAK,qBAAqB;AAC1B,WAAK,cAAc;AAAA,IACvB;AAAA,EACJ;AAAA,EAEA,mBAAoB,WAA+B;AAC/C,QAAG,KAAK,OAAO;AAEX,WAAK,MAAM,SAAS,KAAK,uBAAuB;AAChD,UAAI,eAAe,KAAK,OAAO,SAAS,GAAG;AACvC,aAAK,aAAa;AAClB,aAAK,qBAAqB;AAAA,MAC9B;AAAA,IACJ;AAAA,EACJ;AAAA,EAEA,cAAe;AACX,WAAO,KAAK,MAAM,WAAW,QAAQ,YAAY,KAAK,MAAM,M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8B,aAA9B;;;AEPA,IAAqB,kBAArB,cAA6C,WAAuC;AAAA,EAChF,YAAaC,UAAkB,QAAoC;AAC/D,WAAO,IAAIA,SAAQ,qBAAqB,MAAM;AAAA,EAClD;AACJ;;;ACJA,IAAqB,sBAArB,cAAiD,WAAsC;AAAA,EACnF,YAAaC,UAAkB,QAAmC;AAC9D,WAAO,IAAIA,SAAQ,aAAa,MAAM;AAAA,EAC1C;AACJ;;;ACJA,IAAqB,sBAArB,cAAiD,WAAuC;AAAA,EACpF,YAAaC,UAAkB,QAAoC;AAC/D,WAAO,IAAIA,SAAQ,aAAa,MAAM;AAAA,EAC1C;AACJ;;;ACJA,SAAS,SAAS,oBAAoB,QAAQ,eAAe;","names":["seatsio","seatsio","seatsio","seatsio"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seatsio/seatsio-react",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.6.0",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"module": "build/index.mjs",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "tsup",
|
|
17
|
-
"test": "jest"
|
|
17
|
+
"test": "jest --rootDir ./src/test"
|
|
18
18
|
},
|
|
19
19
|
"author": {
|
|
20
20
|
"name": "mroloux"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"build/"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@seatsio/seatsio-types": "5.
|
|
27
|
+
"@seatsio/seatsio-types": "5.5.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"react": ">=18.0.0"
|