@seatsio/seatsio-react 13.3.0 → 14.0.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 seats.io
3
+ Copyright (c) 2019 - 2023 seats.io
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -10,6 +10,8 @@ npm install --save @seatsio/seatsio-react
10
10
 
11
11
  # Usage
12
12
 
13
+ **Note** If you're using seatsio-react in a Next.js project, ensure you use the `'use client'` directive to force client-side rendering.
14
+
13
15
  ## Regular charts
14
16
 
15
17
  ### Minimal
@@ -108,21 +110,6 @@ import { SeatsioEventManager } from '@seatsio/seatsio-react';
108
110
 
109
111
  Other parameters are supported as well. For a full list, check https://docs.seats.io/docs/event-manager/configuring
110
112
 
111
- ## Chart manager
112
-
113
- ```jsx
114
- import { SeatsioChartManager } from '@seatsio/seatsio-react';
115
-
116
- <div style={{ 'height': '500px' }}>
117
- <SeatsioChartManager
118
- secretKey="<yourWorkspaceSecretKey>"
119
- chart="<yourChartKey>"
120
- mode="<manageRulesets or another mode>"
121
- region="eu"
122
- />
123
- </div>
124
- ```
125
-
126
113
  ## Seating Chart Designer
127
114
 
128
115
  To embed the seating chart designer for the purpose of creating a new chart, do this:
@@ -0,0 +1,26 @@
1
+ import * as React from 'react';
2
+ import { ChartDesigner, CommonConfigOptions, EventManager, Region, SeatingChart, Seatsio } from '@seatsio/seatsio-types';
3
+ export type EmbeddableProps<T> = {
4
+ onRenderStarted?: (chart: SeatingChart) => void;
5
+ chartJsUrl?: string;
6
+ region: Region;
7
+ } & T;
8
+ export default abstract class Embeddable<T extends CommonConfigOptions> extends React.Component<EmbeddableProps<T>> {
9
+ private container;
10
+ private rendering?;
11
+ private chart;
12
+ static defaultProps: {
13
+ chartJsUrl: string;
14
+ };
15
+ constructor(props: EmbeddableProps<T>);
16
+ abstract createChart(seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner;
17
+ componentDidMount(): Promise<void>;
18
+ componentDidUpdate(prevProps: EmbeddableProps<T>): Promise<void>;
19
+ createAndRenderChart(): Promise<void>;
20
+ extractConfigFromProps(): any;
21
+ componentWillUnmount(): void;
22
+ destroyChart(): void;
23
+ getSeatsio(): Promise<any>;
24
+ loadSeatsio(): Promise<unknown>;
25
+ render(): React.ReactNode;
26
+ }
@@ -0,0 +1,98 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __rest = (this && this.__rest) || function (s, e) {
11
+ var t = {};
12
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
+ t[p] = s[p];
14
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
+ t[p[i]] = s[p[i]];
18
+ }
19
+ return t;
20
+ };
21
+ import * as React from 'react';
22
+ import { didPropsChange } from './util';
23
+ class Embeddable extends React.Component {
24
+ constructor(props) {
25
+ super(props);
26
+ this.container = React.createRef();
27
+ }
28
+ componentDidMount() {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ if (!this.rendering) {
31
+ this.rendering = this.createAndRenderChart();
32
+ }
33
+ });
34
+ }
35
+ componentDidUpdate(prevProps) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ if (didPropsChange(this.props, prevProps) && this.chart) {
38
+ this.destroyChart();
39
+ this.createAndRenderChart();
40
+ }
41
+ });
42
+ }
43
+ createAndRenderChart() {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const seatsio = yield this.getSeatsio();
46
+ const config = this.extractConfigFromProps();
47
+ config.container = this.container.current;
48
+ this.chart = this.createChart(seatsio, config).render();
49
+ if (this.props.onRenderStarted) {
50
+ this.props.onRenderStarted(this.chart);
51
+ }
52
+ });
53
+ }
54
+ extractConfigFromProps() {
55
+ // noinspection JSUnusedLocalSymbols
56
+ let _a = this.props, { chartJsUrl, divId, onRenderStarted, region } = _a, config = __rest(_a, ["chartJsUrl", "divId", "onRenderStarted", "region"]);
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
+ getSeatsio() {
68
+ if (typeof seatsio === 'undefined') {
69
+ return this.loadSeatsio();
70
+ }
71
+ else if (seatsio.region !== this.props.region) {
72
+ seatsio = undefined;
73
+ return this.loadSeatsio();
74
+ }
75
+ else {
76
+ return Promise.resolve(seatsio);
77
+ }
78
+ }
79
+ loadSeatsio() {
80
+ return new Promise((resolve, reject) => {
81
+ let script = document.createElement('script');
82
+ script.onload = () => {
83
+ seatsio.region = this.props.region;
84
+ resolve(seatsio);
85
+ };
86
+ script.onerror = () => reject(`Could not load ${script.src}`);
87
+ script.src = this.props.chartJsUrl.replace('{region}', this.props.region);
88
+ document.head.appendChild(script);
89
+ });
90
+ }
91
+ render() {
92
+ return (React.createElement("div", { ref: this.container, style: { 'height': '100%', 'width': '100%' } }));
93
+ }
94
+ }
95
+ Embeddable.defaultProps = {
96
+ chartJsUrl: 'https://cdn-{region}.seatsio.net/chart.js'
97
+ };
98
+ export default Embeddable;
@@ -0,0 +1,5 @@
1
+ import Embeddable from './Embeddable';
2
+ import { ChartDesignerConfigOptions, Seatsio } from '@seatsio/seatsio-types';
3
+ export default class SeatsioDesigner extends Embeddable<ChartDesignerConfigOptions> {
4
+ createChart(seatsio: Seatsio, config: ChartDesignerConfigOptions): import("@seatsio/seatsio-types").ChartDesigner;
5
+ }
@@ -0,0 +1,6 @@
1
+ import Embeddable from './Embeddable';
2
+ export default class SeatsioDesigner extends Embeddable {
3
+ createChart(seatsio, config) {
4
+ return new seatsio.SeatingChartDesigner(config);
5
+ }
6
+ }
@@ -0,0 +1,5 @@
1
+ import { EventManagerConfigOptions, Seatsio } from '@seatsio/seatsio-types';
2
+ import Embeddable from './Embeddable';
3
+ export default class SeatsioEventManager extends Embeddable<EventManagerConfigOptions> {
4
+ createChart(seatsio: Seatsio, config: EventManagerConfigOptions): import("@seatsio/seatsio-types").EventManager;
5
+ }
@@ -0,0 +1,6 @@
1
+ import Embeddable from './Embeddable';
2
+ export default class SeatsioEventManager extends Embeddable {
3
+ createChart(seatsio, config) {
4
+ return new seatsio.EventManager(config);
5
+ }
6
+ }
@@ -0,0 +1,5 @@
1
+ import { ChartRendererConfigOptions, Seatsio } from '@seatsio/seatsio-types';
2
+ import Embeddable from './Embeddable';
3
+ export default class SeatsioSeatingChart extends Embeddable<ChartRendererConfigOptions> {
4
+ createChart(seatsio: Seatsio, config: ChartRendererConfigOptions): import("@seatsio/seatsio-types").SeatingChart;
5
+ }
@@ -0,0 +1,6 @@
1
+ import Embeddable from './Embeddable';
2
+ export default class SeatsioSeatingChart extends Embeddable {
3
+ createChart(seatsio, config) {
4
+ return new seatsio.SeatingChart(config);
5
+ }
6
+ }
@@ -0,0 +1,4 @@
1
+ export { default as SeatsioDesigner } from './SeatsioDesigner';
2
+ export { default as SeatsioEventManager } from './SeatsioEventManager';
3
+ export { default as SeatsioSeatingChart } from './SeatsioSeatingChart';
4
+ export { isBooth, isGeneralAdmission, isSeat, isSection, isTable } from './util';
package/build/index.js CHANGED
@@ -1 +1,4 @@
1
- (()=>{"use strict";var t={n:e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{SeatsioChartManager:()=>U,SeatsioDesigner:()=>Y,SeatsioEventManager:()=>C,SeatsioSeatingChart:()=>j});const r=require("react");var n=t.n(r);function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}var i=function t(e,r){return Object.keys(e).length!==Object.keys(r).length||Object.keys(r).some((function(n){var i=e[n],u=r[n];if(i&&u){if("function"==typeof i&&"function"==typeof u)return i.toString()!==u.toString();if("object"===o(i)&&"object"===o(u))return t(i,u)}return i!==u}))};function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}var c=["divId","container","onRenderStarted","chartJsUrl","region"];function f(t,e,r,n,o,i,u){try{var c=t[i](u),f=c.value}catch(t){return void r(t)}c.done?e(f):Promise.resolve(f).then(n,o)}function a(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function u(t){f(i,n,o,u,c,"next",t)}function c(t){f(i,n,o,u,c,"throw",t)}u(void 0)}))}}function l(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,o=function(t,e){if("object"!==u(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e);if("object"!==u(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key,"string"),"symbol"===u(o)?o:String(o)),n)}var o}function p(t,e){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},p(t,e)}function s(t,e){if(e&&("object"===u(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function y(t){return y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},y(t)}var b=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&p(t,e)}(d,t);var e,r,o,u,f,b,h,v=(b=d,h=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=y(b);if(h){var r=y(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return s(this,t)});function d(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,d),(e=v.call(this,t)).container=n().createRef(),e}return e=d,r=[{key:"componentDidMount",value:(f=a((function*(){this.rendering||(this.rendering=this.createAndRenderChart())})),function(){return f.apply(this,arguments)})},{key:"componentDidUpdate",value:(u=a((function*(t){i(this.props,t)&&this.chart&&(this.destroyChart(),this.createAndRenderChart())})),function(t){return u.apply(this,arguments)})},{key:"createAndRenderChart",value:(o=a((function*(){var t=yield this.getSeatsio(),e=this.extractConfigFromProps();e.container=this.container.current,this.chart=this.createChart(t,e).render(),this.props.onRenderStarted&&this.props.onRenderStarted(this.chart)})),function(){return o.apply(this,arguments)})},{key:"extractConfigFromProps",value:function(){var t=this.props;return t.divId,t.container,t.onRenderStarted,t.chartJsUrl,t.region,function(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,c)}},{key:"componentWillUnmount",value:function(){this.destroyChart()}},{key:"destroyChart",value:function(){this.chart&&"DESTROYED"!==this.chart.state&&this.chart.destroy()}},{key:"getSeatsio",value:function(){return"undefined"==typeof seatsio?this.loadSeatsio():seatsio.region!==this.props.region?(seatsio=void 0,this.loadSeatsio()):Promise.resolve(seatsio)}},{key:"loadSeatsio",value:function(){var t=this;return new Promise((function(e,r){var n=document.createElement("script");n.onload=function(){seatsio.region=t.props.region,e(seatsio)},n.onerror=function(){return r("Could not load ".concat(n.src))},n.src=t.props.chartJsUrl.replace("{region}",t.props.region),document.head.appendChild(n)}))}},{key:"render",value:function(){return n().createElement("div",{ref:this.container,style:{height:"100%",width:"100%"}})}}],r&&l(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),d}(n().Component);function h(t){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h(t)}function v(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function d(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,o=function(t,e){if("object"!==h(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e);if("object"!==h(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key,"string"),"symbol"===h(o)?o:String(o)),n)}var o}function m(t,e){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},m(t,e)}function O(t,e){if(e&&("object"===h(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function w(t){return w=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},w(t)}b.defaultProps={chartJsUrl:"https://cdn-{region}.seatsio.net/chart.js"};var j=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&m(t,e)}(u,t);var e,r,n,o,i=(n=u,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=w(n);if(o){var r=w(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return O(this,t)});function u(){return v(this,u),i.apply(this,arguments)}return e=u,(r=[{key:"createChart",value:function(t,e){return new t.SeatingChart(e)}}])&&d(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),u}(b);function g(t){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},g(t)}function S(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function P(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,o=function(t,e){if("object"!==g(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e);if("object"!==g(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key,"string"),"symbol"===g(o)?o:String(o)),n)}var o}function _(t,e){return _=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_(t,e)}function R(t,e){if(e&&("object"===g(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function E(t){return E=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},E(t)}var C=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_(t,e)}(u,t);var e,r,n,o,i=(n=u,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=E(n);if(o){var r=E(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return R(this,t)});function u(){return S(this,u),i.apply(this,arguments)}return e=u,(r=[{key:"createChart",value:function(t,e){return new t.EventManager(e)}}])&&P(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),u}(b);function T(t){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},T(t)}function k(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function x(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,o=function(t,e){if("object"!==T(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e);if("object"!==T(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key,"string"),"symbol"===T(o)?o:String(o)),n)}var o}function D(t,e){return D=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},D(t,e)}function B(t,e){if(e&&("object"===T(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function M(t){return M=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},M(t)}var U=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&D(t,e)}(u,t);var e,r,n,o,i=(n=u,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=M(n);if(o){var r=M(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return B(this,t)});function u(){return k(this,u),i.apply(this,arguments)}return e=u,(r=[{key:"createChart",value:function(t,e){return new t.ChartManager(e)}}])&&x(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),u}(b);function J(t){return J="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},J(t)}function A(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function I(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,o=function(t,e){if("object"!==J(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e);if("object"!==J(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key,"string"),"symbol"===J(o)?o:String(o)),n)}var o}function F(t,e){return F=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},F(t,e)}function q(t,e){if(e&&("object"===J(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function W(t){return W=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},W(t)}var Y=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&F(t,e)}(u,t);var e,r,n,o,i=(n=u,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=W(n);if(o){var r=W(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return q(this,t)});function u(){return A(this,u),i.apply(this,arguments)}return e=u,(r=[{key:"createChart",value:function(t,e){return new t.SeatingChartDesigner(e)}}])&&I(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),u}(b);module.exports=e})();
1
+ export { default as SeatsioDesigner } from './SeatsioDesigner';
2
+ export { default as SeatsioEventManager } from './SeatsioEventManager';
3
+ export { default as SeatsioSeatingChart } from './SeatsioSeatingChart';
4
+ export { isBooth, isGeneralAdmission, isSeat, isSection, isTable } from './util';
@@ -0,0 +1,9 @@
1
+ import { BoothProps, GeneralAdmissionAreaProps, InteractiveSectionProps, SeatProps, SelectableObjectProps, TableProps } from "@seatsio/seatsio-types";
2
+ export declare const didPropsChange: <P extends {
3
+ [key: string]: any;
4
+ }>(prevProps: P, nextProps: P) => boolean;
5
+ export declare const isSeat: (obj: SelectableObjectProps) => obj is SeatProps;
6
+ export declare const isTable: (obj: SelectableObjectProps) => obj is TableProps;
7
+ export declare const isSection: (obj: SelectableObjectProps) => obj is InteractiveSectionProps;
8
+ export declare const isBooth: (obj: SelectableObjectProps) => obj is BoothProps;
9
+ export declare const isGeneralAdmission: (obj: SelectableObjectProps) => obj is GeneralAdmissionAreaProps;
package/build/util.js ADDED
@@ -0,0 +1,23 @@
1
+ export const didPropsChange = (prevProps, nextProps) => {
2
+ if (Object.keys(prevProps).length !== Object.keys(nextProps).length) {
3
+ return true;
4
+ }
5
+ return Object.keys(nextProps).some((propName) => {
6
+ let prevValue = prevProps[propName];
7
+ let nextValue = nextProps[propName];
8
+ if (prevValue && nextValue) {
9
+ if (typeof prevValue === 'function' && typeof nextValue === 'function') {
10
+ return prevValue.toString() !== nextValue.toString();
11
+ }
12
+ if (typeof prevValue === 'object' && typeof nextValue === 'object') {
13
+ return didPropsChange(prevValue, nextValue);
14
+ }
15
+ }
16
+ return prevValue !== nextValue;
17
+ });
18
+ };
19
+ export const isSeat = (obj) => obj.objectType === 'Seat';
20
+ export const isTable = (obj) => obj.objectType === 'Table';
21
+ export const isSection = (obj) => obj.objectType === 'section';
22
+ export const isBooth = (obj) => obj.objectType === 'Booth';
23
+ export const isGeneralAdmission = (obj) => obj.objectType === 'GeneralAdmissionArea';
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@seatsio/seatsio-react",
3
- "version": "13.3.0",
3
+ "version": "14.0.0",
4
4
  "main": "build/index.js",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/seatsio/seatsio-react"
8
8
  },
9
9
  "scripts": {
10
- "build": "webpack",
10
+ "prebuild": "rimraf ./build",
11
+ "build": "tsc",
11
12
  "test": "jest"
12
13
  },
13
14
  "author": {
@@ -21,25 +22,18 @@
21
22
  "react": ">=18.0.0"
22
23
  },
23
24
  "devDependencies": {
24
- "webpack": "5.76.0",
25
- "webpack-cli": "5.0.1",
26
- "@babel/cli": "7.21.0",
27
- "@babel/core": "7.21.0",
28
- "babel-loader": "9.1.2",
29
- "@babel/preset-react": "7.18.6",
30
- "@babel/preset-env": "7.20.2",
25
+ "@seatsio/seatsio-types": "0.3.2",
26
+ "@testing-library/jest-dom": "6.1.3",
27
+ "@testing-library/react": "14.0.0",
28
+ "@types/jest": "29.5.5",
29
+ "@types/react": "18.2.30",
30
+ "@types/react-dom": "18.2.14",
31
+ "jest": "29.5.0",
32
+ "jest-environment-jsdom": "29.7.0",
31
33
  "react": "18.2.0",
32
34
  "react-dom": "18.2.0",
33
- "@testing-library/react": "14.0.0",
34
- "@testing-library/jest-dom": "5.16.5",
35
- "jest": "29.4.3",
36
- "jest-environment-jsdom": "29.4.3"
37
- },
38
- "jest": {
39
- "verbose": true,
40
- "testEnvironment": "jsdom",
41
- "testMatch": [
42
- "<rootDir>/src/test/*.test.js"
43
- ]
35
+ "rimraf": "5.0.1",
36
+ "ts-jest": "29.1.1",
37
+ "typescript": "5.2.2"
44
38
  }
45
39
  }