@seatsio/seatsio-react 14.14.0 → 14.16.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/index.d.mts +49 -6
- package/build/index.d.ts +49 -6
- package/build/index.js.map +1 -1
- package/build/index.mjs.map +1 -1
- package/package.json +11 -13
- package/build/Embeddable.d.mts +0 -30
- package/build/Embeddable.d.ts +0 -30
- package/build/Embeddable.js +0 -124
- package/build/Embeddable.js.map +0 -1
- package/build/Embeddable.mjs +0 -94
- package/build/Embeddable.mjs.map +0 -1
- package/build/SeatsioDesigner.d.mts +0 -10
- package/build/SeatsioDesigner.d.ts +0 -10
- package/build/SeatsioDesigner.js +0 -133
- package/build/SeatsioDesigner.js.map +0 -1
- package/build/SeatsioDesigner.mjs +0 -101
- package/build/SeatsioDesigner.mjs.map +0 -1
- package/build/SeatsioEventManager.d.mts +0 -10
- package/build/SeatsioEventManager.d.ts +0 -10
- package/build/SeatsioEventManager.js +0 -133
- package/build/SeatsioEventManager.js.map +0 -1
- package/build/SeatsioEventManager.mjs +0 -101
- package/build/SeatsioEventManager.mjs.map +0 -1
- package/build/SeatsioSeatingChart.d.mts +0 -10
- package/build/SeatsioSeatingChart.d.ts +0 -10
- package/build/SeatsioSeatingChart.js +0 -133
- package/build/SeatsioSeatingChart.js.map +0 -1
- package/build/SeatsioSeatingChart.mjs +0 -101
- package/build/SeatsioSeatingChart.mjs.map +0 -1
- package/build/util.d.mts +0 -12
- package/build/util.d.ts +0 -12
- package/build/util.js +0 -62
- package/build/util.js.map +0 -1
- package/build/util.mjs +0 -33
- package/build/util.mjs.map +0 -1
package/build/index.d.mts
CHANGED
|
@@ -1,7 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export { default as SeatsioSeatingChart } from './SeatsioSeatingChart.mjs';
|
|
4
|
-
export { isBooth, isGeneralAdmission, isSeat, isSection, isTable } from './util.mjs';
|
|
1
|
+
import * as _seatsio_seatsio_types from '@seatsio/seatsio-types';
|
|
2
|
+
import { CommonConfigOptions, Seatsio, SeatingChart, EventManager, ChartDesigner, Region, ChartDesignerConfigOptions, EventManagerConfigOptions, ChartRendererConfigOptions, SelectableObject, Seat, Table, InteractiveSection, Booth, GeneralAdmissionArea } from '@seatsio/seatsio-types';
|
|
5
3
|
export * from '@seatsio/seatsio-types';
|
|
6
|
-
import '
|
|
7
|
-
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
type EmbeddableProps<T> = {
|
|
7
|
+
onRenderStarted?: (chart: SeatingChart | EventManager) => void;
|
|
8
|
+
chartJsUrl?: string;
|
|
9
|
+
region: Region;
|
|
10
|
+
} & T;
|
|
11
|
+
declare abstract class Embeddable<T extends CommonConfigOptions> extends React.Component<EmbeddableProps<T>> {
|
|
12
|
+
private container;
|
|
13
|
+
private chart;
|
|
14
|
+
private firstRender;
|
|
15
|
+
private static seatsioBundles;
|
|
16
|
+
static defaultProps: {
|
|
17
|
+
chartJsUrl: string;
|
|
18
|
+
};
|
|
19
|
+
constructor(props: EmbeddableProps<T>);
|
|
20
|
+
abstract createChart(seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner;
|
|
21
|
+
componentDidMount(): void;
|
|
22
|
+
componentDidUpdate(prevProps: EmbeddableProps<T>): void;
|
|
23
|
+
getChartUrl(): string;
|
|
24
|
+
createAndRenderChart(): Promise<void>;
|
|
25
|
+
extractConfigFromProps(): any;
|
|
26
|
+
componentWillUnmount(): void;
|
|
27
|
+
destroyChart(): void;
|
|
28
|
+
loadSeatsio(): Promise<Seatsio>;
|
|
29
|
+
render(): React.ReactNode;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare class SeatsioDesigner extends Embeddable<ChartDesignerConfigOptions> {
|
|
33
|
+
createChart(seatsio: Seatsio, config: ChartDesignerConfigOptions): _seatsio_seatsio_types.ChartDesigner;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare class SeatsioEventManager extends Embeddable<EventManagerConfigOptions> {
|
|
37
|
+
createChart(seatsio: Seatsio, config: EventManagerConfigOptions): _seatsio_seatsio_types.EventManager;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare class SeatsioSeatingChart extends Embeddable<ChartRendererConfigOptions> {
|
|
41
|
+
createChart(seatsio: Seatsio, config: ChartRendererConfigOptions): _seatsio_seatsio_types.SeatingChart;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare const isSeat: (obj: SelectableObject) => obj is Seat;
|
|
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 };
|
package/build/index.d.ts
CHANGED
|
@@ -1,7 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export { default as SeatsioSeatingChart } from './SeatsioSeatingChart.js';
|
|
4
|
-
export { isBooth, isGeneralAdmission, isSeat, isSection, isTable } from './util.js';
|
|
1
|
+
import * as _seatsio_seatsio_types from '@seatsio/seatsio-types';
|
|
2
|
+
import { CommonConfigOptions, Seatsio, SeatingChart, EventManager, ChartDesigner, Region, ChartDesignerConfigOptions, EventManagerConfigOptions, ChartRendererConfigOptions, SelectableObject, Seat, Table, InteractiveSection, Booth, GeneralAdmissionArea } from '@seatsio/seatsio-types';
|
|
5
3
|
export * from '@seatsio/seatsio-types';
|
|
6
|
-
import '
|
|
7
|
-
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
type EmbeddableProps<T> = {
|
|
7
|
+
onRenderStarted?: (chart: SeatingChart | EventManager) => void;
|
|
8
|
+
chartJsUrl?: string;
|
|
9
|
+
region: Region;
|
|
10
|
+
} & T;
|
|
11
|
+
declare abstract class Embeddable<T extends CommonConfigOptions> extends React.Component<EmbeddableProps<T>> {
|
|
12
|
+
private container;
|
|
13
|
+
private chart;
|
|
14
|
+
private firstRender;
|
|
15
|
+
private static seatsioBundles;
|
|
16
|
+
static defaultProps: {
|
|
17
|
+
chartJsUrl: string;
|
|
18
|
+
};
|
|
19
|
+
constructor(props: EmbeddableProps<T>);
|
|
20
|
+
abstract createChart(seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner;
|
|
21
|
+
componentDidMount(): void;
|
|
22
|
+
componentDidUpdate(prevProps: EmbeddableProps<T>): void;
|
|
23
|
+
getChartUrl(): string;
|
|
24
|
+
createAndRenderChart(): Promise<void>;
|
|
25
|
+
extractConfigFromProps(): any;
|
|
26
|
+
componentWillUnmount(): void;
|
|
27
|
+
destroyChart(): void;
|
|
28
|
+
loadSeatsio(): Promise<Seatsio>;
|
|
29
|
+
render(): React.ReactNode;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare class SeatsioDesigner extends Embeddable<ChartDesignerConfigOptions> {
|
|
33
|
+
createChart(seatsio: Seatsio, config: ChartDesignerConfigOptions): _seatsio_seatsio_types.ChartDesigner;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare class SeatsioEventManager extends Embeddable<EventManagerConfigOptions> {
|
|
37
|
+
createChart(seatsio: Seatsio, config: EventManagerConfigOptions): _seatsio_seatsio_types.EventManager;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare class SeatsioSeatingChart extends Embeddable<ChartRendererConfigOptions> {
|
|
41
|
+
createChart(seatsio: Seatsio, config: ChartRendererConfigOptions): _seatsio_seatsio_types.SeatingChart;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare const isSeat: (obj: SelectableObject) => obj is Seat;
|
|
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 };
|
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, isSection, isTable } from './util'\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 (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 {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\nexport const isSeat = (obj: SelectableObject) => obj.objectType === 'Seat'\nexport const isTable = (obj: SelectableObject): obj is Table => obj.objectType === 'Table'\nexport const isSection = (obj: SelectableObject): obj is InteractiveSection => obj.objectType === 'section'\nexport const isBooth = (obj: SelectableObject): obj is Booth => obj.objectType === 'Booth'\nexport const isGeneralAdmission = (obj: SelectableObject): obj is GeneralAdmissionArea => obj.objectType === 'GeneralAdmissionArea'\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;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;AAEO,IAAM,SAAS,CAAC,
|
|
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, isSection, isTable } from './util'\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 (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 {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\nexport const isSeat = (obj: SelectableObject): obj is Seat => obj.objectType === 'Seat'\nexport const isTable = (obj: SelectableObject): obj is Table => obj.objectType === 'Table'\nexport const isSection = (obj: SelectableObject): obj is InteractiveSection => obj.objectType === 'section'\nexport const isBooth = (obj: SelectableObject): obj is Booth => obj.objectType === 'Booth'\nexport const isGeneralAdmission = (obj: SelectableObject): obj is GeneralAdmissionArea => obj.objectType === 'GeneralAdmissionArea'\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;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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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;","names":["seatsio","seatsio","seatsio","seatsio"]}
|
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 { 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 {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\nexport const isSeat = (obj: SelectableObject) => obj.objectType === 'Seat'\nexport const isTable = (obj: SelectableObject): obj is Table => obj.objectType === 'Table'\nexport const isSection = (obj: SelectableObject): obj is InteractiveSection => obj.objectType === 'section'\nexport const isBooth = (obj: SelectableObject): obj is Booth => obj.objectType === 'Booth'\nexport const isGeneralAdmission = (obj: SelectableObject): obj is GeneralAdmissionArea => obj.objectType === 'GeneralAdmissionArea'\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,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;AAEO,IAAM,SAAS,CAAC,
|
|
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 { 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 {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\nexport const isSeat = (obj: SelectableObject): obj is Seat => obj.objectType === 'Seat'\nexport const isTable = (obj: SelectableObject): obj is Table => obj.objectType === 'Table'\nexport const isSection = (obj: SelectableObject): obj is InteractiveSection => obj.objectType === 'section'\nexport const isBooth = (obj: SelectableObject): obj is Booth => obj.objectType === 'Booth'\nexport const isGeneralAdmission = (obj: SelectableObject): obj is GeneralAdmissionArea => obj.objectType === 'GeneralAdmissionArea'\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,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;AAEO,IAAM,SAAS,CAAC,QAAuC,IAAI,eAAe;AAC1E,IAAM,UAAU,CAAC,QAAwC,IAAI,eAAe;AAC5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": "build/index.js",
|
|
5
5
|
"module": "build/index.mjs",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
"url": "https://github.com/seatsio/seatsio-react"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
|
-
"prebuild": "rimraf ./build",
|
|
17
16
|
"build": "tsup",
|
|
18
17
|
"test": "jest"
|
|
19
18
|
},
|
|
@@ -25,24 +24,23 @@
|
|
|
25
24
|
"build/"
|
|
26
25
|
],
|
|
27
26
|
"dependencies": {
|
|
28
|
-
"@seatsio/seatsio-types": "3.
|
|
27
|
+
"@seatsio/seatsio-types": "3.5.0"
|
|
29
28
|
},
|
|
30
29
|
"peerDependencies": {
|
|
31
30
|
"react": ">=18.0.0"
|
|
32
31
|
},
|
|
33
32
|
"devDependencies": {
|
|
34
|
-
"@testing-library/jest-dom": "6.4.
|
|
35
|
-
"@testing-library/react": "
|
|
33
|
+
"@testing-library/jest-dom": "6.4.6",
|
|
34
|
+
"@testing-library/react": "15.0.7",
|
|
36
35
|
"@types/jest": "29.5.12",
|
|
37
|
-
"@types/react": "18.
|
|
38
|
-
"@types/react-dom": "18.
|
|
36
|
+
"@types/react": "18.3.3",
|
|
37
|
+
"@types/react-dom": "18.3.0",
|
|
39
38
|
"jest": "29.7.0",
|
|
40
39
|
"jest-environment-jsdom": "29.7.0",
|
|
41
|
-
"react": "18.
|
|
42
|
-
"react-dom": "18.
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"typescript": "5.4.3"
|
|
40
|
+
"react": "18.3.1",
|
|
41
|
+
"react-dom": "18.3.1",
|
|
42
|
+
"ts-jest": "29.1.5",
|
|
43
|
+
"tsup": "8.1.0",
|
|
44
|
+
"typescript": "5.5.3"
|
|
47
45
|
}
|
|
48
46
|
}
|
package/build/Embeddable.d.mts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { SeatingChart, EventManager, Region, CommonConfigOptions, Seatsio, ChartDesigner } from '@seatsio/seatsio-types';
|
|
3
|
-
|
|
4
|
-
type EmbeddableProps<T> = {
|
|
5
|
-
onRenderStarted?: (chart: SeatingChart | EventManager) => void;
|
|
6
|
-
chartJsUrl?: string;
|
|
7
|
-
region: Region;
|
|
8
|
-
} & T;
|
|
9
|
-
declare abstract class Embeddable<T extends CommonConfigOptions> extends React.Component<EmbeddableProps<T>> {
|
|
10
|
-
private container;
|
|
11
|
-
private chart;
|
|
12
|
-
private firstRender;
|
|
13
|
-
private static seatsioBundles;
|
|
14
|
-
static defaultProps: {
|
|
15
|
-
chartJsUrl: string;
|
|
16
|
-
};
|
|
17
|
-
constructor(props: EmbeddableProps<T>);
|
|
18
|
-
abstract createChart(seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner;
|
|
19
|
-
componentDidMount(): void;
|
|
20
|
-
componentDidUpdate(prevProps: EmbeddableProps<T>): void;
|
|
21
|
-
getChartUrl(): string;
|
|
22
|
-
createAndRenderChart(): Promise<void>;
|
|
23
|
-
extractConfigFromProps(): any;
|
|
24
|
-
componentWillUnmount(): void;
|
|
25
|
-
destroyChart(): void;
|
|
26
|
-
loadSeatsio(): Promise<Seatsio>;
|
|
27
|
-
render(): React.ReactNode;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { type EmbeddableProps, Embeddable as default };
|
package/build/Embeddable.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { SeatingChart, EventManager, Region, CommonConfigOptions, Seatsio, ChartDesigner } from '@seatsio/seatsio-types';
|
|
3
|
-
|
|
4
|
-
type EmbeddableProps<T> = {
|
|
5
|
-
onRenderStarted?: (chart: SeatingChart | EventManager) => void;
|
|
6
|
-
chartJsUrl?: string;
|
|
7
|
-
region: Region;
|
|
8
|
-
} & T;
|
|
9
|
-
declare abstract class Embeddable<T extends CommonConfigOptions> extends React.Component<EmbeddableProps<T>> {
|
|
10
|
-
private container;
|
|
11
|
-
private chart;
|
|
12
|
-
private firstRender;
|
|
13
|
-
private static seatsioBundles;
|
|
14
|
-
static defaultProps: {
|
|
15
|
-
chartJsUrl: string;
|
|
16
|
-
};
|
|
17
|
-
constructor(props: EmbeddableProps<T>);
|
|
18
|
-
abstract createChart(seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner;
|
|
19
|
-
componentDidMount(): void;
|
|
20
|
-
componentDidUpdate(prevProps: EmbeddableProps<T>): void;
|
|
21
|
-
getChartUrl(): string;
|
|
22
|
-
createAndRenderChart(): Promise<void>;
|
|
23
|
-
extractConfigFromProps(): any;
|
|
24
|
-
componentWillUnmount(): void;
|
|
25
|
-
destroyChart(): void;
|
|
26
|
-
loadSeatsio(): Promise<Seatsio>;
|
|
27
|
-
render(): React.ReactNode;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { type EmbeddableProps, Embeddable as default };
|
package/build/Embeddable.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
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;
|
|
124
|
-
//# sourceMappingURL=Embeddable.js.map
|
package/build/Embeddable.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 {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\nexport const isSeat = (obj: SelectableObject) => obj.objectType === 'Seat'\nexport const isTable = (obj: SelectableObject): obj is Table => obj.objectType === 'Table'\nexport const isSection = (obj: SelectableObject): obj is InteractiveSection => obj.objectType === 'section'\nexport const isBooth = (obj: SelectableObject): obj is Booth => obj.objectType === 'Booth'\nexport const isGeneralAdmission = (obj: SelectableObject): obj is GeneralAdmissionArea => obj.objectType === 'GeneralAdmissionArea'\n"],"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;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,K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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
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
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
|
-
};
|
|
94
|
-
//# sourceMappingURL=Embeddable.mjs.map
|
package/build/Embeddable.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 {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\nexport const isSeat = (obj: SelectableObject) => obj.objectType === 'Seat'\nexport const isTable = (obj: SelectableObject): obj is Table => obj.objectType === 'Table'\nexport const isSection = (obj: SelectableObject): obj is InteractiveSection => obj.objectType === 'section'\nexport const isBooth = (obj: SelectableObject): obj is Booth => obj.objectType === 'Booth'\nexport const isGeneralAdmission = (obj: SelectableObject): obj is GeneralAdmissionArea => obj.objectType === 'GeneralAdmissionArea'\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,QAAI,eAAe,KAAK,OAAO,SAAS,KAAK,KAAK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AAO,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"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as _seatsio_seatsio_types from '@seatsio/seatsio-types';
|
|
2
|
-
import { ChartDesignerConfigOptions, Seatsio } from '@seatsio/seatsio-types';
|
|
3
|
-
import Embeddable from './Embeddable.mjs';
|
|
4
|
-
import 'react';
|
|
5
|
-
|
|
6
|
-
declare class SeatsioDesigner extends Embeddable<ChartDesignerConfigOptions> {
|
|
7
|
-
createChart(seatsio: Seatsio, config: ChartDesignerConfigOptions): _seatsio_seatsio_types.ChartDesigner;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { SeatsioDesigner as default };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as _seatsio_seatsio_types from '@seatsio/seatsio-types';
|
|
2
|
-
import { ChartDesignerConfigOptions, Seatsio } from '@seatsio/seatsio-types';
|
|
3
|
-
import Embeddable from './Embeddable.js';
|
|
4
|
-
import 'react';
|
|
5
|
-
|
|
6
|
-
declare class SeatsioDesigner extends Embeddable<ChartDesignerConfigOptions> {
|
|
7
|
-
createChart(seatsio: Seatsio, config: ChartDesignerConfigOptions): _seatsio_seatsio_types.ChartDesigner;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { SeatsioDesigner as default };
|