iticket-seatingplan-dev 1.6.1 → 1.6.3

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,14 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = Map;
7
- require("leaflet-gesture-handling/dist/leaflet-gesture-handling.css");
7
+ require("./styles/gestureHandling.css");
8
8
  require("leaflet-draw/dist/leaflet.draw.css");
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _reactLeaflet = require("react-leaflet");
11
11
  var L = _interopRequireWildcard(require("leaflet"));
12
12
  var _reactLeafletDraw = require("react-leaflet-draw");
13
- var _leafletGestureHandling2 = require("leaflet-gesture-handling");
14
- var _reactLeafletCustomControl = _interopRequireDefault(require("react-leaflet-custom-control"));
13
+ var _gestureHandling2 = require("./gestureHandling");
14
+ var _Control = _interopRequireDefault(require("./Control"));
15
15
  var _encodedSvgs = require("./assets/encodedSvgs");
16
16
  var _utils = require("../utils");
17
17
  var _PriceButton = _interopRequireDefault(require("./PriceButton"));
@@ -183,7 +183,7 @@ function Map(_ref) {
183
183
  // to allow users to scroll past the map when it's not full screen.
184
184
  (0, _react.useEffect)(() => {
185
185
  if (!isFullScreen) {
186
- map.addHandler("gestureHandling", _leafletGestureHandling2.GestureHandling);
186
+ map.addHandler("gestureHandling", _gestureHandling2.GestureHandling);
187
187
  // @ts-ignore
188
188
  map.gestureHandling.enable();
189
189
  }
@@ -195,7 +195,7 @@ function Map(_ref) {
195
195
  map.dragging.disable();
196
196
  }
197
197
  }, [mode, map]);
198
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactLeafletCustomControl.default, {
198
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Control.default, {
199
199
  position: "bottomright"
200
200
  }, /*#__PURE__*/_react.default.createElement("div", {
201
201
  className: "legendBox"
@@ -236,7 +236,7 @@ function Map(_ref) {
236
236
  src: _encodedSvgs.userIcon,
237
237
  width: 15,
238
238
  height: 15
239
- }), /*#__PURE__*/_react.default.createElement("p", null, "membership seats"))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null)))), /*#__PURE__*/_react.default.createElement(_reactLeafletCustomControl.default, {
239
+ }), /*#__PURE__*/_react.default.createElement("p", null, "membership seats"))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null)))), /*#__PURE__*/_react.default.createElement(_Control.default, {
240
240
  position: "topleft"
241
241
  }, /*#__PURE__*/_react.default.createElement("div", {
242
242
  className: "extra-controls"
@@ -266,7 +266,7 @@ function Map(_ref) {
266
266
  style: {
267
267
  height: "17px"
268
268
  }
269
- })))), /*#__PURE__*/_react.default.createElement(_reactLeafletCustomControl.default, {
269
+ })))), /*#__PURE__*/_react.default.createElement(_Control.default, {
270
270
  position: "topleft"
271
271
  }, /*#__PURE__*/_react.default.createElement("div", {
272
272
  className: "extra-controls full-screen-control"
@@ -281,7 +281,7 @@ function Map(_ref) {
281
281
  style: {
282
282
  height: "24px"
283
283
  }
284
- })))), canMultiSelect && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactLeafletCustomControl.default, {
284
+ })))), canMultiSelect && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Control.default, {
285
285
  position: "bottomleft"
286
286
  }, /*#__PURE__*/_react.default.createElement("div", {
287
287
  className: "extra-controls multi-select-control"
@@ -361,7 +361,7 @@ function Map(_ref) {
361
361
  onMounted: drawInstance => {
362
362
  drawRef.current = drawInstance;
363
363
  }
364
- }))), /*#__PURE__*/_react.default.createElement(_reactLeafletCustomControl.default, {
364
+ }))), /*#__PURE__*/_react.default.createElement(_Control.default, {
365
365
  position: "topright"
366
366
  }, /*#__PURE__*/_react.default.createElement("button", {
367
367
  title: "Close full screen",
@@ -0,0 +1,214 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.GestureHandling = void 0;
7
+ var L = _interopRequireWildcard(require("leaflet"));
8
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
9
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
+ /*
11
+ * * Leaflet Gesture Handling **
12
+ * * Version 1.1.8
13
+ */
14
+
15
+ const LanguageContent = {
16
+ en: {
17
+ touch: "Use two fingers to move the map",
18
+ scroll: "Use ctrl + scroll to zoom the map",
19
+ scrollMac: "Use \u2318 + scroll to zoom the map"
20
+ }
21
+ };
22
+ L.Map.mergeOptions({
23
+ gestureHandlingOptions: {
24
+ text: {},
25
+ duration: 500
26
+ }
27
+ });
28
+ var draggingMap = false;
29
+ var GestureHandling = exports.GestureHandling = L.Handler.extend({
30
+ addHooks: function addHooks() {
31
+ this._handleTouch = this._handleTouch.bind(this);
32
+ this._setupPluginOptions();
33
+ this._setLanguageContent();
34
+ this._disableInteractions();
35
+
36
+ //Uses native event listeners instead of L.DomEvent due to issues with Android touch events
37
+ //turning into pointer events
38
+ this._map._container.addEventListener("touchstart", this._handleTouch);
39
+ this._map._container.addEventListener("touchmove", this._handleTouch);
40
+ this._map._container.addEventListener("touchend", this._handleTouch);
41
+ this._map._container.addEventListener("touchcancel", this._handleTouch);
42
+ this._map._container.addEventListener("click", this._handleTouch);
43
+ L.DomEvent.on(this._map._container, "wheel", this._handleScroll, this);
44
+ L.DomEvent.on(this._map, "mouseover", this._handleMouseOver, this);
45
+ // removed this as it's triggering on canvas points
46
+ // L.DomEvent.on(this._map, "mouseout", this._handleMouseOut, this);
47
+
48
+ // Listen to these events so will not disable dragging if the user moves the mouse out the boundary of the map container whilst actively dragging the map.
49
+ L.DomEvent.on(this._map, "movestart", this._handleDragging, this);
50
+ L.DomEvent.on(this._map, "move", this._handleDragging, this);
51
+ L.DomEvent.on(this._map, "moveend", this._handleDragging, this);
52
+ },
53
+ removeHooks: function removeHooks() {
54
+ this._enableInteractions();
55
+ this._map._container.removeEventListener("touchstart", this._handleTouch);
56
+ this._map._container.removeEventListener("touchmove", this._handleTouch);
57
+ this._map._container.removeEventListener("touchend", this._handleTouch);
58
+ this._map._container.removeEventListener("touchcancel", this._handleTouch);
59
+ this._map._container.removeEventListener("click", this._handleTouch);
60
+ L.DomEvent.off(this._map._container, "wheel", this._handleScroll, this);
61
+ L.DomEvent.off(this._map, "mouseover", this._handleMouseOver, this);
62
+ L.DomEvent.off(this._map, "mouseout", this._handleMouseOut, this);
63
+ L.DomEvent.off(this._map, "movestart", this._handleDragging, this);
64
+ L.DomEvent.off(this._map, "move", this._handleDragging, this);
65
+ L.DomEvent.off(this._map, "moveend", this._handleDragging, this);
66
+ },
67
+ _handleDragging: function _handleDragging(e) {
68
+ if (e.type == "movestart" || e.type == "move") {
69
+ draggingMap = true;
70
+ } else if (e.type == "moveend") {
71
+ draggingMap = false;
72
+ }
73
+ },
74
+ _disableInteractions: function _disableInteractions() {
75
+ this._map.dragging.disable();
76
+ this._map.scrollWheelZoom.disable();
77
+ if (this._map.tap) {
78
+ this._map.tap.disable();
79
+ }
80
+ },
81
+ _enableInteractions: function _enableInteractions() {
82
+ this._map.dragging.enable();
83
+ this._map.scrollWheelZoom.enable();
84
+ if (this._map.tap) {
85
+ this._map.tap.enable();
86
+ }
87
+ },
88
+ _setupPluginOptions: function _setupPluginOptions() {
89
+ //For backwards compatibility, merge gestureHandlingText into the new options object
90
+ if (this._map.options.gestureHandlingText) {
91
+ this._map.options.gestureHandlingOptions.text = this._map.options.gestureHandlingText;
92
+ }
93
+ },
94
+ _setLanguageContent: function _setLanguageContent() {
95
+ var languageContent;
96
+ //If user has supplied custom language, use that
97
+ if (this._map.options.gestureHandlingOptions && this._map.options.gestureHandlingOptions.text && this._map.options.gestureHandlingOptions.text.touch && this._map.options.gestureHandlingOptions.text.scroll && this._map.options.gestureHandlingOptions.text.scrollMac) {
98
+ languageContent = this._map.options.gestureHandlingOptions.text;
99
+ } else {
100
+ //Otherwise auto set it from the language files
101
+
102
+ //Determine their language e.g fr or en-US
103
+ // var lang = this._getUserLanguage();
104
+ var lang = "en";
105
+
106
+ //If we couldn't find it default to en
107
+ // if (!lang) {
108
+ // lang = "en";
109
+ // }
110
+
111
+ //Lookup the appropriate language content
112
+ if (LanguageContent[lang]) {
113
+ languageContent = LanguageContent[lang];
114
+ }
115
+
116
+ //If no result, try searching by the first part only. e.g en-US just use en.
117
+ if (!languageContent && lang.indexOf("-") !== -1) {
118
+ lang = lang.split("-")[0];
119
+ languageContent = LanguageContent[lang];
120
+ }
121
+ if (!languageContent) {
122
+ // If still nothing, default to English
123
+ // console.log("No lang found for", lang);
124
+ lang = "en";
125
+ languageContent = LanguageContent[lang];
126
+ }
127
+ }
128
+
129
+ //TEST
130
+ // languageContent = LanguageContent["bg"];
131
+
132
+ //Check if they're on a mac for display of command instead of ctrl
133
+ var mac = false;
134
+ if (navigator.platform.toUpperCase().indexOf("MAC") >= 0) {
135
+ mac = true;
136
+ }
137
+ var scrollContent = languageContent.scroll;
138
+ if (mac) {
139
+ scrollContent = languageContent.scrollMac;
140
+ }
141
+ this._map._container.setAttribute("data-gesture-handling-touch-content", languageContent.touch);
142
+ this._map._container.setAttribute("data-gesture-handling-scroll-content", scrollContent);
143
+ },
144
+ _getUserLanguage: function _getUserLanguage() {
145
+ var lang = navigator.languages ? navigator.languages[0] : navigator.language;
146
+ return lang;
147
+ },
148
+ _handleTouch: function _handleTouch(e) {
149
+ //Disregard touch events on the minimap if present
150
+ var ignoreList = ["leaflet-control-minimap", "leaflet-interactive", "leaflet-popup-content", "leaflet-popup-content-wrapper", "leaflet-popup-close-button", "leaflet-control-zoom-in", "leaflet-control-zoom-out"];
151
+ var ignoreElement = false;
152
+ for (var i = 0; i < ignoreList.length; i++) {
153
+ if (L.DomUtil.hasClass(e.target, ignoreList[i])) {
154
+ ignoreElement = true;
155
+ }
156
+ }
157
+ if (ignoreElement) {
158
+ if (L.DomUtil.hasClass(e.target, "leaflet-interactive") && e.type === "touchmove" && e.touches.length === 1) {
159
+ L.DomUtil.addClass(this._map._container, "leaflet-gesture-handling-touch-warning");
160
+ this._disableInteractions();
161
+ } else {
162
+ L.DomUtil.removeClass(this._map._container, "leaflet-gesture-handling-touch-warning");
163
+ }
164
+ return;
165
+ }
166
+ // screenLog(e.type+' '+e.touches.length);
167
+ if (e.type !== "touchmove" && e.type !== "touchstart") {
168
+ L.DomUtil.removeClass(this._map._container, "leaflet-gesture-handling-touch-warning");
169
+ return;
170
+ }
171
+ if (e.touches.length === 1) {
172
+ // added condition for touchmove, because the overlay appearing when you only clicked is annoying.
173
+ if (e.type === "touchmove") {
174
+ L.DomUtil.addClass(this._map._container, "leaflet-gesture-handling-touch-warning");
175
+ this._disableInteractions();
176
+ }
177
+ } else {
178
+ e.preventDefault();
179
+ this._enableInteractions();
180
+ L.DomUtil.removeClass(this._map._container, "leaflet-gesture-handling-touch-warning");
181
+ }
182
+ },
183
+ _isScrolling: false,
184
+ _handleScroll: function _handleScroll(e) {
185
+ if (e.metaKey || e.ctrlKey) {
186
+ e.preventDefault();
187
+ L.DomUtil.removeClass(this._map._container, "leaflet-gesture-handling-scroll-warning");
188
+ this._map.scrollWheelZoom.enable();
189
+ } else {
190
+ L.DomUtil.addClass(this._map._container, "leaflet-gesture-handling-scroll-warning");
191
+ this._map.scrollWheelZoom.disable();
192
+ clearTimeout(this._isScrolling);
193
+
194
+ // Set a timeout to run after scrolling ends
195
+ this._isScrolling = setTimeout(function () {
196
+ // Run the callback
197
+ var warnings = document.getElementsByClassName("leaflet-gesture-handling-scroll-warning");
198
+ for (var i = 0; i < warnings.length; i++) {
199
+ L.DomUtil.removeClass(warnings[i], "leaflet-gesture-handling-scroll-warning");
200
+ }
201
+ }, this._map.options.gestureHandlingOptions.duration);
202
+ }
203
+ },
204
+ _handleMouseOver: function _handleMouseOver(e) {
205
+ this._enableInteractions();
206
+ },
207
+ _handleMouseOut: function _handleMouseOut(e) {
208
+ if (!draggingMap) {
209
+ this._disableInteractions();
210
+ }
211
+ }
212
+ });
213
+ L.Map.addInitHook("addHandler", "gestureHandling", GestureHandling);
214
+ var _default = exports.default = GestureHandling;
@@ -0,0 +1,40 @@
1
+ @keyframes leaflet-gestures-fadein {
2
+ 0% {
3
+ opacity: 0;
4
+ }
5
+ 100% {
6
+ opacity: 1;
7
+ }
8
+ }
9
+
10
+ .leaflet-container::after {
11
+ animation: leaflet-gestures-fadein 0.8s backwards;
12
+ color: #fff;
13
+ font-family: "Roboto", Arial, sans-serif;
14
+ font-size: 22px;
15
+ justify-content: center;
16
+ display: flex;
17
+ align-items: center;
18
+ padding: 15px;
19
+ position: absolute;
20
+ top: 0;
21
+ left: 0;
22
+ right: 0;
23
+ bottom: 0;
24
+ background: rgba(0, 0, 0, 0.5);
25
+ z-index: 461;
26
+ pointer-events: none;
27
+ }
28
+
29
+ .leaflet-gesture-handling-touch-warning::after,
30
+ .leaflet-gesture-handling-scroll-warning::after {
31
+ animation: leaflet-gestures-fadein 0.8s forwards;
32
+ }
33
+
34
+ .leaflet-gesture-handling-touch-warning::after {
35
+ content: attr(data-gesture-handling-touch-content);
36
+ }
37
+
38
+ .leaflet-gesture-handling-scroll-warning::after {
39
+ content: attr(data-gesture-handling-scroll-content);
40
+ }
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.6.1",
5
+ "version": "1.6.3",
6
6
  "private": false,
7
7
  "keywords": [
8
8
  "iticket",