iticket-seatingplan-dev 1.8.6 → 1.8.7

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;
@@ -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,8 +473,6 @@ const SeatingPlan = _ref => {
473
473
  throw new Error("Something went wrong. Please try again or contact support.");
474
474
  }
475
475
  }
476
- const img = new Image();
477
- img.src = data.background;
478
476
  setBookedSeats(data.seats.filter(s => s.s === _utils.statuses.USER_PENDING && s.bookedPrice === price).map(s => ({
479
477
  ssId: s.ssId,
480
478
  r: s.r,
@@ -485,18 +483,29 @@ const SeatingPlan = _ref => {
485
483
  pId: s.pId,
486
484
  paName: s.paName
487
485
  })));
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);
486
+ const img = new Image();
487
+ const setupSeats = (height, width) => {
488
+ const southwest = [0, 0];
489
+ const northeast = [height * 0.015, width * 0.015];
490
+ setBounds([southwest, northeast]);
491
+ setPosition([height * 0.005, width * 0.005]);
492
+ setHeight(height * 0.5);
493
+ setWidth(width * 0.5);
495
494
  setSeats(data);
496
495
  if (data.preventOrphanedSeats && !isReload) {
497
496
  setSelectQuantityPopupOpen(true);
498
497
  }
499
498
  };
499
+ if (data.background) {
500
+ img.src = data.background;
501
+ img.onload = () => {
502
+ setupSeats(img.height, img.width);
503
+ };
504
+ } else {
505
+ const estHeight = 800;
506
+ const estWidth = 800;
507
+ setupSeats(estHeight, estWidth);
508
+ }
500
509
  setIsReloading(false);
501
510
  } catch (error) {
502
511
  var _error$message;
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.7",
6
6
  "private": false,
7
7
  "keywords": [
8
8
  "iticket",