@seatsio/seatsio-react 15.5.0 → 15.7.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 +3 -8
- package/build/index.d.ts +3 -8
- package/build/index.js +10 -14
- package/build/index.js.map +1 -1
- package/build/index.mjs +3 -6
- package/build/index.mjs.map +1 -1
- package/package.json +8 -8
package/build/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _seatsio_seatsio_types from '@seatsio/seatsio-types';
|
|
2
|
-
import { CommonConfigOptions,
|
|
2
|
+
import { CommonConfigOptions, SeatingChart, EventManager, Region, Seatsio, ChartDesigner, 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,
|
|
2
|
+
import { CommonConfigOptions, SeatingChart, EventManager, Region, Seatsio, ChartDesigner, 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
|
@@ -27,18 +27,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
|
|
29
29
|
// src/main/index.ts
|
|
30
|
-
var
|
|
31
|
-
__export(
|
|
30
|
+
var index_exports = {};
|
|
31
|
+
__export(index_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
|
-
module.exports = __toCommonJS(
|
|
40
|
+
module.exports = __toCommonJS(index_exports);
|
|
42
41
|
|
|
43
42
|
// src/main/Embeddable.tsx
|
|
44
43
|
var React = __toESM(require("react"));
|
|
@@ -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 {
|
|
@@ -159,6 +153,9 @@ var SeatsioSeatingChart = class extends Embeddable {
|
|
|
159
153
|
return new seatsio2.SeatingChart(config);
|
|
160
154
|
}
|
|
161
155
|
};
|
|
156
|
+
|
|
157
|
+
// src/main/index.ts
|
|
158
|
+
var import_seatsio_types = require("@seatsio/seatsio-types");
|
|
162
159
|
// Annotate the CommonJS export names for ESM import in node:
|
|
163
160
|
0 && (module.exports = {
|
|
164
161
|
SeatsioDesigner,
|
|
@@ -167,7 +164,6 @@ var SeatsioSeatingChart = class extends Embeddable {
|
|
|
167
164
|
isBooth,
|
|
168
165
|
isGeneralAdmission,
|
|
169
166
|
isSeat,
|
|
170
|
-
isSection,
|
|
171
167
|
isTable
|
|
172
168
|
});
|
|
173
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,EAAE,KAAK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C;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 {
|
|
@@ -117,6 +112,9 @@ var SeatsioSeatingChart = class extends Embeddable {
|
|
|
117
112
|
return new seatsio2.SeatingChart(config);
|
|
118
113
|
}
|
|
119
114
|
};
|
|
115
|
+
|
|
116
|
+
// src/main/index.ts
|
|
117
|
+
import { isBooth, isGeneralAdmission, isSeat, isTable } from "@seatsio/seatsio-types";
|
|
120
118
|
export {
|
|
121
119
|
SeatsioDesigner,
|
|
122
120
|
SeatsioEventManager,
|
|
@@ -124,7 +122,6 @@ export {
|
|
|
124
122
|
isBooth,
|
|
125
123
|
isGeneralAdmission,
|
|
126
124
|
isSeat,
|
|
127
|
-
isSection,
|
|
128
125
|
isTable
|
|
129
126
|
};
|
|
130
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 {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
|
|
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,iBAA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JA,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.7.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"
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"jest-environment-jsdom": "29.7.0",
|
|
40
40
|
"react": "18.3.1",
|
|
41
41
|
"react-dom": "18.3.1",
|
|
42
|
-
"semver": "7.
|
|
43
|
-
"ts-jest": "29.2.
|
|
44
|
-
"tsup": "8.
|
|
45
|
-
"typescript": "5.
|
|
46
|
-
"zx": "8.3.
|
|
42
|
+
"semver": "7.7.1",
|
|
43
|
+
"ts-jest": "29.2.6",
|
|
44
|
+
"tsup": "8.4.0",
|
|
45
|
+
"typescript": "5.8.2",
|
|
46
|
+
"zx": "8.3.2"
|
|
47
47
|
}
|
|
48
48
|
}
|