iticket-seatingplan-dev 1.8.6 → 1.8.8

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.
@@ -0,0 +1,75 @@
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;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = Controls;
7
- var _reactLeafletCustomControl = _interopRequireDefault(require("react-leaflet-custom-control"));
7
+ var _Control = _interopRequireDefault(require("./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(_reactLeafletCustomControl.default, {
38
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, preventOrphanedSeats && /*#__PURE__*/_react.default.createElement(_Control.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(_reactLeafletCustomControl.default, {
52
+ })))), /*#__PURE__*/_react.default.createElement(_Control.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(_reactLeafletCustomControl.default, {
93
+ }), /*#__PURE__*/_react.default.createElement("p", null, "membership seats"))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null)))), /*#__PURE__*/_react.default.createElement(_Control.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(_reactLeafletCustomControl.default, {
123
+ })))), /*#__PURE__*/_react.default.createElement(_Control.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(_reactLeafletCustomControl.default, {
138
+ })))), canMultiSelect && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Control.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(_reactLeafletCustomControl.default, {
218
+ }))), /*#__PURE__*/_react.default.createElement(_Control.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;
94
+ const isOrphanMode = (seats === null || seats === void 0 ? void 0 : seats.preventOrphanedSeats) && desiredSeatQuantity > 0 && mode === _utils.modes.SINGLE;
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.find(s => s.ssId === seat.ssId) && seat.s === _utils.statuses.USER_PENDING) {
126
+ if (!seatsToRemove.some(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.find(s => s.ssId === seat.ssId) && seat.s === _utils.statuses.UNSOLD) {
230
+ if (boxBounds.contains(latlng) && !seatsToBook.some(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.find(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.some(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.find(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.some(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) {
374
+ if ((highlightedSeats === null || highlightedSeats === void 0 ? void 0 : highlightedSeats.length) > 0 && mode === _utils.modes.SINGLE) {
375
375
  setHighlightedSeats([]);
376
376
  }
377
377
  }, 400);
@@ -420,7 +420,7 @@ function SeatMap(_ref) {
420
420
  isReloading: isReloading,
421
421
  hasMembershipSeats: (seats === null || seats === void 0 || (_seats$seats2 = seats.seats) === null || _seats$seats2 === void 0 ? void 0 : _seats$seats2.filter(seat => seat.m).length) > 0,
422
422
  hasBookedSeats: (bookedSeats === null || bookedSeats === void 0 ? void 0 : bookedSeats.length) > 0
423
- }), /*#__PURE__*/_react.default.createElement(_reactLeaflet.ImageOverlay, {
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
426
  zIndex: 10
@@ -473,7 +473,7 @@ function SeatMap(_ref) {
473
473
  zIndex: 10
474
474
  }) : /*#__PURE__*/_react.default.createElement(_reactLeaflet.Circle, {
475
475
  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)) && isHoveringOnSeat, greyedOutSeats.some(gs => gs.ssId === s.ssId)),
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)),
477
477
  radius: 12000,
478
478
  eventHandlers: eventHandlers
479
479
  }, s.s === _utils.statuses.UNSOLD && hasSeatPrices ? /*#__PURE__*/_react.default.createElement(_reactLeaflet.Popup, {
@@ -44,7 +44,15 @@ const SeatingPlan = _ref => {
44
44
  connectedShowings,
45
45
  areaName,
46
46
  promoCode,
47
- bookingMode = _utils.bookingModes.SHOPSITE
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
+ }
48
56
  } = _ref;
49
57
  const [initialiseMessage, setInitialiseMessage] = (0, _react.useState)("Initialising seating plan...");
50
58
  const [isReloading, setIsReloading] = (0, _react.useState)(false);
@@ -473,8 +481,6 @@ const SeatingPlan = _ref => {
473
481
  throw new Error("Something went wrong. Please try again or contact support.");
474
482
  }
475
483
  }
476
- const img = new Image();
477
- img.src = data.background;
478
484
  setBookedSeats(data.seats.filter(s => s.s === _utils.statuses.USER_PENDING && s.bookedPrice === price).map(s => ({
479
485
  ssId: s.ssId,
480
486
  r: s.r,
@@ -485,18 +491,29 @@ const SeatingPlan = _ref => {
485
491
  pId: s.pId,
486
492
  paName: s.paName
487
493
  })));
488
- img.onload = () => {
489
- const imgSouthwest = [0, 0];
490
- const imgNortheast = [img.height * 0.015, img.width * 0.015];
491
- setBounds([imgSouthwest, imgNortheast]);
492
- setPosition([img.height * 0.005, img.width * 0.005]);
493
- setHeight(img.height * 0.5);
494
- setWidth(img.width * 0.5);
494
+ const img = new Image();
495
+ const setupSeats = (height, width) => {
496
+ const southwest = [0, 0];
497
+ const northeast = [height * 0.015, width * 0.015];
498
+ setBounds([southwest, northeast]);
499
+ setPosition([height * 0.005, width * 0.005]);
500
+ setHeight(height * 0.5);
501
+ setWidth(width * 0.5);
495
502
  setSeats(data);
496
503
  if (data.preventOrphanedSeats && !isReload) {
497
504
  setSelectQuantityPopupOpen(true);
498
505
  }
499
506
  };
507
+ if (data.background) {
508
+ img.src = data.background;
509
+ img.onload = () => {
510
+ setupSeats(img.height, img.width);
511
+ };
512
+ } else {
513
+ const estHeight = 800;
514
+ const estWidth = 800;
515
+ setupSeats(estHeight, estWidth);
516
+ }
500
517
  setIsReloading(false);
501
518
  } catch (error) {
502
519
  var _error$message;
@@ -523,19 +540,28 @@ const SeatingPlan = _ref => {
523
540
  // in full screen mode, render the map in the body, otherwise render in the seating-plan-root div
524
541
  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"));
525
542
  const backdropContainer = mounted && ((_document3 = document) === null || _document3 === void 0 ? void 0 : _document3.body);
526
-
527
- // return seating plan
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
+ };
528
551
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
529
552
  className: "seating-plan-root",
530
- id: "seating-plan-root"
553
+ id: "seating-plan-root",
554
+ style: themeStyles
531
555
  }, error ? /*#__PURE__*/_react.default.createElement("div", {
532
556
  className: "loading"
533
557
  }, /*#__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", {
534
558
  className: "seating-plan-backdrop ".concat(isFullScreen ? "full-screen" : ""),
535
- onClick: () => setIsFullScreen(false)
559
+ onClick: () => setIsFullScreen(false),
560
+ style: themeStyles
536
561
  }), backdropContainer), mapContainer && /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react.default.createElement("div", {
537
562
  className: "seating-plan-container ".concat(isFullScreen ? "full-screen" : ""),
538
- "data-mode": mode
563
+ "data-mode": mode,
564
+ style: themeStyles
539
565
  }, pricingPopupOpen && seats && seats.pricing && (canMultiSelect || seats.preventOrphanedSeats) ? /*#__PURE__*/_react.default.createElement(_PricingPopup.default, {
540
566
  onClose: () => {
541
567
  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,6 +42,7 @@ button {
42
42
  border-radius: 3px;
43
43
  text-align: left;
44
44
  backdrop-filter: blur(2px);
45
+ color: #333;
45
46
  }
46
47
 
47
48
  .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.6",
5
+ "version": "1.8.8",
6
6
  "private": false,
7
7
  "keywords": [
8
8
  "iticket",