iticket-seatingplan-dev 1.8.8 → 1.8.9

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.
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = Controls;
7
- var _Control = _interopRequireDefault(require("./Control"));
7
+ var _reactLeafletCustomControl = _interopRequireDefault(require("react-leaflet-custom-control"));
8
8
  var _reactLeafletDraw = require("react-leaflet-draw");
9
9
  var _reactLeaflet = require("react-leaflet");
10
10
  var _react = _interopRequireWildcard(require("react"));
@@ -35,7 +35,7 @@ function Controls(_ref) {
35
35
  } = _ref;
36
36
  const [isLegendOpen, setIsLegendOpen] = (0, _react.useState)(true);
37
37
  const map = (0, _reactLeaflet.useMap)();
38
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, preventOrphanedSeats && /*#__PURE__*/_react.default.createElement(_Control.default, {
38
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, preventOrphanedSeats && /*#__PURE__*/_react.default.createElement(_reactLeafletCustomControl.default, {
39
39
  position: "topright"
40
40
  }, /*#__PURE__*/_react.default.createElement("div", {
41
41
  className: "extra-controls seat-quantity-control"
@@ -49,7 +49,7 @@ function Controls(_ref) {
49
49
  height: "16px",
50
50
  width: "16px",
51
51
  strokeWidth: "2"
52
- })))), /*#__PURE__*/_react.default.createElement(_Control.default, {
52
+ })))), /*#__PURE__*/_react.default.createElement(_reactLeafletCustomControl.default, {
53
53
  position: "bottomright"
54
54
  }, /*#__PURE__*/_react.default.createElement("div", {
55
55
  className: "legendBox"
@@ -90,7 +90,7 @@ function Controls(_ref) {
90
90
  src: _encodedSvgs.userIcon,
91
91
  width: 15,
92
92
  height: 15
93
- }), /*#__PURE__*/_react.default.createElement("p", null, "membership seats"))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null)))), /*#__PURE__*/_react.default.createElement(_Control.default, {
93
+ }), /*#__PURE__*/_react.default.createElement("p", null, "membership seats"))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null)))), /*#__PURE__*/_react.default.createElement(_reactLeafletCustomControl.default, {
94
94
  position: "topleft"
95
95
  }, /*#__PURE__*/_react.default.createElement("div", {
96
96
  className: "extra-controls"
@@ -120,7 +120,7 @@ function Controls(_ref) {
120
120
  style: {
121
121
  height: "17px"
122
122
  }
123
- })))), /*#__PURE__*/_react.default.createElement(_Control.default, {
123
+ })))), /*#__PURE__*/_react.default.createElement(_reactLeafletCustomControl.default, {
124
124
  position: "topleft"
125
125
  }, /*#__PURE__*/_react.default.createElement("div", {
126
126
  className: "extra-controls full-screen-control"
@@ -135,7 +135,7 @@ function Controls(_ref) {
135
135
  style: {
136
136
  height: "24px"
137
137
  }
138
- })))), canMultiSelect && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Control.default, {
138
+ })))), canMultiSelect && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactLeafletCustomControl.default, {
139
139
  position: "bottomleft"
140
140
  }, /*#__PURE__*/_react.default.createElement("div", {
141
141
  className: "extra-controls multi-select-control"
@@ -215,7 +215,7 @@ function Controls(_ref) {
215
215
  onMounted: drawInstance => {
216
216
  drawRef.current = drawInstance;
217
217
  }
218
- }))), /*#__PURE__*/_react.default.createElement(_Control.default, {
218
+ }))), /*#__PURE__*/_react.default.createElement(_reactLeafletCustomControl.default, {
219
219
  position: "topright"
220
220
  }, /*#__PURE__*/_react.default.createElement("button", {
221
221
  title: "Close full screen",
@@ -91,7 +91,7 @@ function SeatMap(_ref) {
91
91
  center: seatCenter
92
92
  })];
93
93
  })), [seats.seats, height, priceSectionIds]);
94
- const isOrphanMode = (seats === null || seats === void 0 ? void 0 : seats.preventOrphanedSeats) && desiredSeatQuantity > 0 && mode === _utils.modes.SINGLE;
94
+ const isOrphanMode = (seats === null || seats === void 0 ? void 0 : seats.preventOrphanedSeats) && desiredSeatQuantity > 0;
95
95
  const isTouchScreen = (0, _utils.getIsTouchScreen)();
96
96
 
97
97
  // L.drawLocal.draw.toolbar.buttons.rectangle = "Box select";
@@ -123,7 +123,7 @@ function SeatMap(_ref) {
123
123
  } else if (mode === _utils.modes.REMOVE) {
124
124
  const seatsToRemove = [];
125
125
  selectedSeats.forEach(seat => {
126
- if (!seatsToRemove.some(s => s.ssId === seat.ssId) && seat.s === _utils.statuses.USER_PENDING) {
126
+ if (!seatsToRemove.find(s => s.ssId === seat.ssId) && seat.s === _utils.statuses.USER_PENDING) {
127
127
  seatsToRemove.push(seat);
128
128
  }
129
129
  });
@@ -227,7 +227,7 @@ function SeatMap(_ref) {
227
227
  lng: seat.x
228
228
  };
229
229
  const latlng = [seatCenter.lat, seatCenter.lng];
230
- if (boxBounds.contains(latlng) && !seatsToBook.some(s => s.ssId === seat.ssId) && seat.s === _utils.statuses.UNSOLD) {
230
+ if (boxBounds.contains(latlng) && !seatsToBook.find(s => s.ssId === seat.ssId) && seat.s === _utils.statuses.UNSOLD) {
231
231
  seatsToBook.push(seat);
232
232
  }
233
233
  });
@@ -328,7 +328,7 @@ function SeatMap(_ref) {
328
328
  }
329
329
  };
330
330
  const onMouseDown = (0, _react.useCallback)((s, hasSeatPrices) => {
331
- if ((mode === _utils.modes.DRAG || mode === _utils.modes.REMOVE) && canMultiSelect && hasSeatPrices && !selectedSeats.some(seat => seat.ssId === s.ssId) && s.s === (mode === _utils.modes.DRAG ? _utils.statuses.UNSOLD : _utils.statuses.USER_PENDING)) {
331
+ if ((mode === _utils.modes.DRAG || mode === _utils.modes.REMOVE) && canMultiSelect && hasSeatPrices && !selectedSeats.find(seat => seat.ssId === s.ssId) && s.s === (mode === _utils.modes.DRAG ? _utils.statuses.UNSOLD : _utils.statuses.USER_PENDING)) {
332
332
  setSelectedSeats(prev => [...prev, s]);
333
333
  }
334
334
  }, [mode, canMultiSelect, selectedSeats, setSelectedSeats]);
@@ -339,7 +339,7 @@ function SeatMap(_ref) {
339
339
  if (hideTooltipTimeoutRef.current) {
340
340
  clearTimeout(hideTooltipTimeoutRef.current);
341
341
  }
342
- if ((mode === _utils.modes.DRAG || mode === _utils.modes.REMOVE) && isDragging && canMultiSelect && hasSeatPrices && !selectedSeats.some(seat => seat.ssId === s.ssId) && s.s === (mode === _utils.modes.DRAG ? _utils.statuses.UNSOLD : _utils.statuses.USER_PENDING)) {
342
+ if ((mode === _utils.modes.DRAG || mode === _utils.modes.REMOVE) && isDragging && canMultiSelect && hasSeatPrices && !selectedSeats.find(seat => seat.ssId === s.ssId) && s.s === (mode === _utils.modes.DRAG ? _utils.statuses.UNSOLD : _utils.statuses.USER_PENDING)) {
343
343
  setSelectedSeats(prev => [...prev, s]);
344
344
  return;
345
345
  }
@@ -371,7 +371,7 @@ function SeatMap(_ref) {
371
371
  infoVisible: false
372
372
  }));
373
373
  }
374
- if ((highlightedSeats === null || highlightedSeats === void 0 ? void 0 : highlightedSeats.length) > 0 && mode === _utils.modes.SINGLE) {
374
+ if ((highlightedSeats === null || highlightedSeats === void 0 ? void 0 : highlightedSeats.length) > 0) {
375
375
  setHighlightedSeats([]);
376
376
  }
377
377
  }, 400);
@@ -423,7 +423,12 @@ function SeatMap(_ref) {
423
423
  }), (seats === null || seats === void 0 ? void 0 : seats.background) && /*#__PURE__*/_react.default.createElement(_reactLeaflet.ImageOverlay, {
424
424
  url: seats === null || seats === void 0 ? void 0 : seats.background,
425
425
  bounds: [[0, 0], [height * 0.03, width * 0.03]],
426
- zIndex: 10
426
+ zIndex: 10,
427
+ eventHandlers: {
428
+ error: i => {
429
+ i.target.remove();
430
+ }
431
+ }
427
432
  }), seats && seats.seats && seats.seats.map((s, i) => {
428
433
  var _seatsMap$get2, _seats$pricing3, _chosenSeat$seat, _chosenSeat$seat2, _chosenSeat$seat3;
429
434
  const seatCenter = ((_seatsMap$get2 = seatsMap.get(s.sId)) === null || _seatsMap$get2 === void 0 ? void 0 : _seatsMap$get2.center) || {
@@ -473,7 +478,7 @@ function SeatMap(_ref) {
473
478
  zIndex: 10
474
479
  }) : /*#__PURE__*/_react.default.createElement(_reactLeaflet.Circle, {
475
480
  center: [seatCenter.lat, seatCenter.lng],
476
- pathOptions: (0, _utils.getInitialColor)(s, price, s.loading || ticketPopupOpen && (chosenSeat === null || chosenSeat === void 0 || (_chosenSeat$seat3 = chosenSeat.seat) === null || _chosenSeat$seat3 === void 0 ? void 0 : _chosenSeat$seat3.ssId) === s.ssId, !hasSeatPrices, (selectedSeats.some(selectedSeat => selectedSeat.ssId === s.ssId) || highlightedSeats.some(hs => hs.ssId === s.ssId)) && (isOrphanMode ? isHoveringOnSeat : true), greyedOutSeats.some(gs => gs.ssId === s.ssId)),
481
+ pathOptions: (0, _utils.getInitialColor)(s, price, s.loading || ticketPopupOpen && (chosenSeat === null || chosenSeat === void 0 || (_chosenSeat$seat3 = chosenSeat.seat) === null || _chosenSeat$seat3 === void 0 ? void 0 : _chosenSeat$seat3.ssId) === s.ssId, !hasSeatPrices, (selectedSeats.some(selectedSeat => selectedSeat.ssId === s.ssId) || highlightedSeats.some(hs => hs.ssId === s.ssId)) && isHoveringOnSeat, greyedOutSeats.some(gs => gs.ssId === s.ssId)),
477
482
  radius: 12000,
478
483
  eventHandlers: eventHandlers
479
484
  }, s.s === _utils.statuses.UNSOLD && hasSeatPrices ? /*#__PURE__*/_react.default.createElement(_reactLeaflet.Popup, {
@@ -44,15 +44,7 @@ const SeatingPlan = _ref => {
44
44
  connectedShowings,
45
45
  areaName,
46
46
  promoCode,
47
- bookingMode = _utils.bookingModes.SHOPSITE,
48
- theme = {
49
- accent: "#6366f1",
50
- accentDark: "#3730a3",
51
- accentLight: "#e0e7ff",
52
- flexiAccent: "#e32664",
53
- flexiAccentDark: "#ffd3e2",
54
- flexiAccentLight: "#be003f"
55
- }
47
+ bookingMode = _utils.bookingModes.SHOPSITE
56
48
  } = _ref;
57
49
  const [initialiseMessage, setInitialiseMessage] = (0, _react.useState)("Initialising seating plan...");
58
50
  const [isReloading, setIsReloading] = (0, _react.useState)(false);
@@ -504,15 +496,19 @@ const SeatingPlan = _ref => {
504
496
  setSelectQuantityPopupOpen(true);
505
497
  }
506
498
  };
499
+ const fallbackHeight = 800;
500
+ const fallbackWidth = 800;
507
501
  if (data.background) {
508
502
  img.src = data.background;
503
+ img.onerror = () => {
504
+ setupSeats(fallbackHeight, fallbackWidth);
505
+ img.src = "";
506
+ };
509
507
  img.onload = () => {
510
508
  setupSeats(img.height, img.width);
511
509
  };
512
510
  } else {
513
- const estHeight = 800;
514
- const estWidth = 800;
515
- setupSeats(estHeight, estWidth);
511
+ setupSeats(fallbackHeight, fallbackWidth);
516
512
  }
517
513
  setIsReloading(false);
518
514
  } catch (error) {
@@ -540,28 +536,19 @@ const SeatingPlan = _ref => {
540
536
  // in full screen mode, render the map in the body, otherwise render in the seating-plan-root div
541
537
  const mapContainer = mounted && (isFullScreen ? (_document = document) === null || _document === void 0 ? void 0 : _document.body : (_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.getElementById("seating-plan-root"));
542
538
  const backdropContainer = mounted && ((_document3 = document) === null || _document3 === void 0 ? void 0 : _document3.body);
543
- const themeStyles = {
544
- "--accent": theme.accent,
545
- "--accent-dark": theme.accentDark,
546
- "--accent-light": theme.accentLight,
547
- "--flexi-accent": theme.flexiAccent,
548
- "--flexi-accent-light": theme.flexiAccentLight,
549
- "--flexi-accent-dark": theme.flexiAccentDark
550
- };
539
+
540
+ // return seating plan
551
541
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
552
542
  className: "seating-plan-root",
553
- id: "seating-plan-root",
554
- style: themeStyles
543
+ id: "seating-plan-root"
555
544
  }, error ? /*#__PURE__*/_react.default.createElement("div", {
556
545
  className: "loading"
557
546
  }, /*#__PURE__*/_react.default.createElement("h1", null, "OOPS!"), /*#__PURE__*/_react.default.createElement("div", null, error.response.data.message)) : position && area === areaId ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, backdropContainer && /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react.default.createElement("div", {
558
547
  className: "seating-plan-backdrop ".concat(isFullScreen ? "full-screen" : ""),
559
- onClick: () => setIsFullScreen(false),
560
- style: themeStyles
548
+ onClick: () => setIsFullScreen(false)
561
549
  }), backdropContainer), mapContainer && /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react.default.createElement("div", {
562
550
  className: "seating-plan-container ".concat(isFullScreen ? "full-screen" : ""),
563
- "data-mode": mode,
564
- style: themeStyles
551
+ "data-mode": mode
565
552
  }, pricingPopupOpen && seats && seats.pricing && (canMultiSelect || seats.preventOrphanedSeats) ? /*#__PURE__*/_react.default.createElement(_PricingPopup.default, {
566
553
  onClose: () => {
567
554
  setPricingPopupOpen(false);
@@ -27,12 +27,12 @@ button {
27
27
  }
28
28
 
29
29
  .seating-plan-container {
30
- /* --accent: rgb(99 102 241);
30
+ --accent: rgb(99 102 241);
31
31
  --accent-dark: rgb(55 48 163);
32
32
  --accent-light: rgb(224 231 255);
33
33
  --flexi-accent: rgb(227 38 100);
34
34
  --flexi-accent-light: rgb(255 211 226);
35
- --flexi-accent-dark: rgb(190 0 63); */
35
+ --flexi-accent-dark: rgb(190 0 63);
36
36
  font-family: inherit;
37
37
  }
38
38
 
@@ -42,7 +42,6 @@ button {
42
42
  border-radius: 3px;
43
43
  text-align: left;
44
44
  backdrop-filter: blur(2px);
45
- color: #333;
46
45
  }
47
46
 
48
47
  .legend-header {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "iticket-seatingplan-dev",
3
3
  "description": "Seating plan with FLEXi pricing",
4
4
  "author": "gedwyne",
5
- "version": "1.8.8",
5
+ "version": "1.8.9",
6
6
  "private": false,
7
7
  "keywords": [
8
8
  "iticket",
@@ -1,75 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _leaflet = _interopRequireDefault(require("leaflet"));
8
- var _react = _interopRequireDefault(require("react"));
9
- var _reactLeaflet = require("react-leaflet");
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
12
- const POSITION_CLASSES = {
13
- bottomleft: "leaflet-bottom leaflet-left",
14
- bottomright: "leaflet-bottom leaflet-right",
15
- topleft: "leaflet-top leaflet-left",
16
- topright: "leaflet-top leaflet-right"
17
- };
18
- const Control = props => {
19
- var _props$container;
20
- const [portalRoot, setPortalRoot] = _react.default.useState(document.createElement("div"));
21
- const positionClass = props.position && POSITION_CLASSES[props.position] || POSITION_CLASSES.topright;
22
- const controlContainerRef = /*#__PURE__*/_react.default.createRef();
23
- const map = (0, _reactLeaflet.useMap)();
24
-
25
- /**
26
- * Whenever the control container ref is created,
27
- * Ensure the click / scroll propagation is removed
28
- * This way click/scroll events do not bubble down to the map
29
- */
30
- _react.default.useEffect(() => {
31
- if (controlContainerRef.current !== null) {
32
- _leaflet.default.DomEvent.disableClickPropagation(controlContainerRef.current);
33
- _leaflet.default.DomEvent.disableScrollPropagation(controlContainerRef.current);
34
- }
35
- }, [controlContainerRef]);
36
-
37
- /**
38
- * Whenever the position is changed, go ahead and get the container of the map and the first
39
- * instance of the position class in that map container
40
- * Fixes #17
41
- */
42
- _react.default.useEffect(() => {
43
- const mapContainer = map.getContainer();
44
- const targetDiv = mapContainer.getElementsByClassName(positionClass);
45
- setPortalRoot(targetDiv[0]);
46
- }, [positionClass]);
47
-
48
- /**
49
- * Whenever the portal root is complete,
50
- * append or prepend the control container to the portal root
51
- */
52
- _react.default.useEffect(() => {
53
- if (portalRoot !== null) {
54
- if (props.prepend !== undefined && props.prepend === true) {
55
- portalRoot.prepend(controlContainerRef.current);
56
- } else {
57
- portalRoot.append(controlContainerRef.current);
58
- }
59
- }
60
- }, [portalRoot, props.prepend, controlContainerRef]);
61
-
62
- /**
63
- * Concatenate the props.container className to the class of the control div
64
- */
65
- const className = (((_props$container = props.container) === null || _props$container === void 0 || (_props$container = _props$container.className) === null || _props$container === void 0 ? void 0 : _props$container.concat(" ")) || "") + "leaflet-control";
66
-
67
- /**
68
- * Render
69
- */
70
- return /*#__PURE__*/_react.default.createElement("div", _extends({}, props.container, {
71
- ref: controlContainerRef,
72
- className: className
73
- }), props.children);
74
- };
75
- var _default = exports.default = Control;