zmdms-webui 2.5.1 → 2.5.2

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.
@@ -6,31 +6,74 @@ import './utils/domFns.js';
6
6
  import './utils/positionFns.js';
7
7
  import './utils/shims.js';
8
8
  import './utils/log.js';
9
- import { __exports as domFns } from '../../../../_virtual/domFns.js';
10
9
  import { __exports as shims } from '../../../../_virtual/shims.js';
11
10
  import { __exports as log } from '../../../../_virtual/log.js';
11
+ import { __exports as domFns } from '../../../../_virtual/domFns.js';
12
12
  import { __exports as positionFns } from '../../../../_virtual/positionFns.js';
13
13
 
14
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
15
+
14
16
  Object.defineProperty(DraggableCore$1, "__esModule", {
15
17
  value: true
16
18
  });
17
19
  DraggableCore$1.default = void 0;
20
+
18
21
  var React = _interopRequireWildcard(React__default);
22
+
19
23
  var _propTypes = _interopRequireDefault(propTypesExports);
24
+
20
25
  var _reactDom = _interopRequireDefault(require$$2);
26
+
21
27
  var _domFns = domFns;
28
+
22
29
  var _positionFns = positionFns;
30
+
23
31
  var _shims = shims;
32
+
24
33
  var _log = _interopRequireDefault(log);
25
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
26
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
27
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
28
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
29
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
30
- /*:: import type {EventHandler, MouseTouchEvent} from './utils/types';*/
31
- /*:: import type {Element as ReactElement} from 'react';*/
34
+
35
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36
+
37
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
38
+
39
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
40
+
41
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
42
+
43
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
44
+
45
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
46
+
47
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
48
+
49
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
50
+
51
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
52
+
53
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
54
+
55
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
56
+
57
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
58
+
59
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
60
+
61
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
62
+
63
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
64
+
65
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
66
+
67
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
68
+
69
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
70
+
71
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
72
+
73
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
74
+
32
75
  // Simple abstraction for dragging events names.
33
- const eventsFor = {
76
+ var eventsFor = {
34
77
  touch: {
35
78
  start: 'touchstart',
36
79
  move: 'touchmove',
@@ -41,22 +84,31 @@ const eventsFor = {
41
84
  move: 'mousemove',
42
85
  stop: 'mouseup'
43
86
  }
44
- };
87
+ }; // Default to mouse events.
88
+
89
+ var dragEventFor = eventsFor.mouse;
90
+ /*:: type DraggableCoreState = {
91
+ dragging: boolean,
92
+ lastX: number,
93
+ lastY: number,
94
+ touchIdentifier: ?number
95
+ };*/
45
96
 
46
- // Default to mouse events.
47
- let dragEventFor = eventsFor.mouse;
48
97
  /*:: export type DraggableData = {
49
98
  node: HTMLElement,
50
99
  x: number, y: number,
51
100
  deltaX: number, deltaY: number,
52
101
  lastX: number, lastY: number,
53
102
  };*/
103
+
54
104
  /*:: export type DraggableEventHandler = (e: MouseEvent, data: DraggableData) => void | false;*/
105
+
55
106
  /*:: export type ControlPosition = {x: number, y: number};*/
107
+
56
108
  /*:: export type PositionOffsetControlPosition = {x: number|string, y: number|string};*/
109
+
57
110
  /*:: export type DraggableCoreDefaultProps = {
58
111
  allowAnyClick: boolean,
59
- allowMobileScroll: boolean,
60
112
  disabled: boolean,
61
113
  enableUserSelectHack: boolean,
62
114
  onStart: DraggableEventHandler,
@@ -65,6 +117,7 @@ let dragEventFor = eventsFor.mouse;
65
117
  onMouseDown: (e: MouseEvent) => void,
66
118
  scale: number,
67
119
  };*/
120
+
68
121
  /*:: export type DraggableCoreProps = {
69
122
  ...DraggableCoreDefaultProps,
70
123
  cancel: string,
@@ -74,239 +127,305 @@ let dragEventFor = eventsFor.mouse;
74
127
  handle: string,
75
128
  nodeRef?: ?React.ElementRef<any>,
76
129
  };*/
130
+
77
131
  //
78
132
  // Define <DraggableCore>.
79
133
  //
80
134
  // <DraggableCore> is for advanced usage of <Draggable>. It maintains minimal internal state so it can
81
135
  // work well with libraries that require more control over the element.
82
136
  //
137
+ var DraggableCore = /*#__PURE__*/function (_React$Component) {
138
+ _inherits(DraggableCore, _React$Component);
83
139
 
84
- class DraggableCore extends React.Component /*:: <DraggableCoreProps>*/{
85
- constructor() {
86
- super(...arguments);
87
- _defineProperty(this, "dragging", false);
88
- // Used while dragging to determine deltas.
89
- _defineProperty(this, "lastX", NaN);
90
- _defineProperty(this, "lastY", NaN);
91
- _defineProperty(this, "touchIdentifier", null);
92
- _defineProperty(this, "mounted", false);
93
- _defineProperty(this, "handleDragStart", e => {
140
+ var _super = _createSuper(DraggableCore);
141
+
142
+ function DraggableCore() {
143
+ var _this;
144
+
145
+ _classCallCheck(this, DraggableCore);
146
+
147
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
148
+ args[_key] = arguments[_key];
149
+ }
150
+
151
+ _this = _super.call.apply(_super, [this].concat(args));
152
+
153
+ _defineProperty(_assertThisInitialized(_this), "state", {
154
+ dragging: false,
155
+ // Used while dragging to determine deltas.
156
+ lastX: NaN,
157
+ lastY: NaN,
158
+ touchIdentifier: null
159
+ });
160
+
161
+ _defineProperty(_assertThisInitialized(_this), "mounted", false);
162
+
163
+ _defineProperty(_assertThisInitialized(_this), "handleDragStart", function (e) {
94
164
  // Make it possible to attach event handlers on top of this one.
95
- this.props.onMouseDown(e);
165
+ _this.props.onMouseDown(e); // Only accept left-clicks.
166
+
96
167
 
97
- // Only accept left-clicks.
98
- if (!this.props.allowAnyClick && typeof e.button === 'number' && e.button !== 0) return false;
168
+ if (!_this.props.allowAnyClick && typeof e.button === 'number' && e.button !== 0) return false; // Get nodes. Be sure to grab relative document (could be iframed)
169
+
170
+ var thisNode = _this.findDOMNode();
99
171
 
100
- // Get nodes. Be sure to grab relative document (could be iframed)
101
- const thisNode = this.findDOMNode();
102
172
  if (!thisNode || !thisNode.ownerDocument || !thisNode.ownerDocument.body) {
103
173
  throw new Error('<DraggableCore> not mounted on DragStart!');
104
174
  }
105
- const {
106
- ownerDocument
107
- } = thisNode;
108
175
 
109
- // Short circuit if handle or cancel prop was provided and selector doesn't match.
110
- if (this.props.disabled || !(e.target instanceof ownerDocument.defaultView.Node) || this.props.handle && !(0, _domFns.matchesSelectorAndParentsTo)(e.target, this.props.handle, thisNode) || this.props.cancel && (0, _domFns.matchesSelectorAndParentsTo)(e.target, this.props.cancel, thisNode)) {
111
- return;
112
- }
176
+ var ownerDocument = thisNode.ownerDocument; // Short circuit if handle or cancel prop was provided and selector doesn't match.
113
177
 
114
- // Prevent scrolling on mobile devices, like ipad/iphone.
178
+ if (_this.props.disabled || !(e.target instanceof ownerDocument.defaultView.Node) || _this.props.handle && !(0, _domFns.matchesSelectorAndParentsTo)(e.target, _this.props.handle, thisNode) || _this.props.cancel && (0, _domFns.matchesSelectorAndParentsTo)(e.target, _this.props.cancel, thisNode)) {
179
+ return;
180
+ } // Prevent scrolling on mobile devices, like ipad/iphone.
115
181
  // Important that this is after handle/cancel.
116
- if (e.type === 'touchstart' && !this.props.allowMobileScroll) e.preventDefault();
117
182
 
118
- // Set touch identifier in component state if this is a touch event. This allows us to
183
+
184
+ if (e.type === 'touchstart') e.preventDefault(); // Set touch identifier in component state if this is a touch event. This allows us to
119
185
  // distinguish between individual touches on multitouch screens by identifying which
120
186
  // touchpoint was set to this element.
121
- const touchIdentifier = (0, _domFns.getTouchIdentifier)(e);
122
- this.touchIdentifier = touchIdentifier;
123
187
 
124
- // Get the current drag point from the event. This is used as the offset.
125
- const position = (0, _positionFns.getControlPosition)(e, touchIdentifier, this);
188
+ var touchIdentifier = (0, _domFns.getTouchIdentifier)(e);
189
+
190
+ _this.setState({
191
+ touchIdentifier: touchIdentifier
192
+ }); // Get the current drag point from the event. This is used as the offset.
193
+
194
+
195
+ var position = (0, _positionFns.getControlPosition)(e, touchIdentifier, _assertThisInitialized(_this));
126
196
  if (position == null) return; // not possible but satisfies flow
127
- const {
128
- x,
129
- y
130
- } = position;
131
197
 
132
- // Create an event object with all the data parents need to make a decision here.
133
- const coreEvent = (0, _positionFns.createCoreData)(this, x, y);
134
- (0, _log.default)('DraggableCore: handleDragStart: %j', coreEvent);
198
+ var x = position.x,
199
+ y = position.y; // Create an event object with all the data parents need to make a decision here.
200
+
201
+ var coreEvent = (0, _positionFns.createCoreData)(_assertThisInitialized(_this), x, y);
202
+ (0, _log.default)('DraggableCore: handleDragStart: %j', coreEvent); // Call event handler. If it returns explicit false, cancel.
135
203
 
136
- // Call event handler. If it returns explicit false, cancel.
137
- (0, _log.default)('calling', this.props.onStart);
138
- const shouldUpdate = this.props.onStart(e, coreEvent);
139
- if (shouldUpdate === false || this.mounted === false) return;
204
+ (0, _log.default)('calling', _this.props.onStart);
140
205
 
141
- // Add a style to the body to disable user-select. This prevents text from
206
+ var shouldUpdate = _this.props.onStart(e, coreEvent);
207
+
208
+ if (shouldUpdate === false || _this.mounted === false) return; // Add a style to the body to disable user-select. This prevents text from
142
209
  // being selected all over the page.
143
- if (this.props.enableUserSelectHack) (0, _domFns.addUserSelectStyles)(ownerDocument);
144
210
 
145
- // Initiate dragging. Set the current x and y as offsets
211
+ if (_this.props.enableUserSelectHack) (0, _domFns.addUserSelectStyles)(ownerDocument); // Initiate dragging. Set the current x and y as offsets
146
212
  // so we know how much we've moved during the drag. This allows us
147
213
  // to drag elements around even if they have been moved, without issue.
148
- this.dragging = true;
149
- this.lastX = x;
150
- this.lastY = y;
151
214
 
152
- // Add events to the document directly so we catch when the user's mouse/touch moves outside of
215
+ _this.setState({
216
+ dragging: true,
217
+ lastX: x,
218
+ lastY: y
219
+ }); // Add events to the document directly so we catch when the user's mouse/touch moves outside of
153
220
  // this element. We use different events depending on whether or not we have detected that this
154
221
  // is a touch-capable device.
155
- (0, _domFns.addEvent)(ownerDocument, dragEventFor.move, this.handleDrag);
156
- (0, _domFns.addEvent)(ownerDocument, dragEventFor.stop, this.handleDragStop);
222
+
223
+
224
+ (0, _domFns.addEvent)(ownerDocument, dragEventFor.move, _this.handleDrag);
225
+ (0, _domFns.addEvent)(ownerDocument, dragEventFor.stop, _this.handleDragStop);
157
226
  });
158
- _defineProperty(this, "handleDrag", e => {
227
+
228
+ _defineProperty(_assertThisInitialized(_this), "handleDrag", function (e) {
159
229
  // Get the current drag point from the event. This is used as the offset.
160
- const position = (0, _positionFns.getControlPosition)(e, this.touchIdentifier, this);
230
+ var position = (0, _positionFns.getControlPosition)(e, _this.state.touchIdentifier, _assertThisInitialized(_this));
161
231
  if (position == null) return;
162
- let {
163
- x,
164
- y
165
- } = position;
166
-
167
- // Snap to grid if prop has been provided
168
- if (Array.isArray(this.props.grid)) {
169
- let deltaX = x - this.lastX,
170
- deltaY = y - this.lastY;
171
- [deltaX, deltaY] = (0, _positionFns.snapToGrid)(this.props.grid, deltaX, deltaY);
232
+ var x = position.x,
233
+ y = position.y; // Snap to grid if prop has been provided
234
+
235
+ if (Array.isArray(_this.props.grid)) {
236
+ var deltaX = x - _this.state.lastX,
237
+ deltaY = y - _this.state.lastY;
238
+
239
+ var _snapToGrid = (0, _positionFns.snapToGrid)(_this.props.grid, deltaX, deltaY);
240
+
241
+ var _snapToGrid2 = _slicedToArray(_snapToGrid, 2);
242
+
243
+ deltaX = _snapToGrid2[0];
244
+ deltaY = _snapToGrid2[1];
172
245
  if (!deltaX && !deltaY) return; // skip useless drag
173
- x = this.lastX + deltaX, y = this.lastY + deltaY;
246
+
247
+ x = _this.state.lastX + deltaX, y = _this.state.lastY + deltaY;
174
248
  }
175
- const coreEvent = (0, _positionFns.createCoreData)(this, x, y);
176
- (0, _log.default)('DraggableCore: handleDrag: %j', coreEvent);
177
249
 
178
- // Call event handler. If it returns explicit false, trigger end.
179
- const shouldUpdate = this.props.onDrag(e, coreEvent);
180
- if (shouldUpdate === false || this.mounted === false) {
250
+ var coreEvent = (0, _positionFns.createCoreData)(_assertThisInitialized(_this), x, y);
251
+ (0, _log.default)('DraggableCore: handleDrag: %j', coreEvent); // Call event handler. If it returns explicit false, trigger end.
252
+
253
+ var shouldUpdate = _this.props.onDrag(e, coreEvent);
254
+
255
+ if (shouldUpdate === false || _this.mounted === false) {
181
256
  try {
182
257
  // $FlowIgnore
183
- this.handleDragStop(new MouseEvent('mouseup'));
258
+ _this.handleDragStop(new MouseEvent('mouseup'));
184
259
  } catch (err) {
185
260
  // Old browsers
186
- const event = ((document.createEvent('MouseEvents') /*: any*/) /*: MouseTouchEvent*/);
187
- // I see why this insanity was deprecated
261
+ var event = ((document.createEvent('MouseEvents')
262
+ /*: any*/
263
+ )
264
+ /*: MouseTouchEvent*/
265
+ ); // I see why this insanity was deprecated
188
266
  // $FlowIgnore
267
+
189
268
  event.initMouseEvent('mouseup', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
190
- this.handleDragStop(event);
269
+
270
+ _this.handleDragStop(event);
191
271
  }
272
+
192
273
  return;
193
274
  }
194
- this.lastX = x;
195
- this.lastY = y;
275
+
276
+ _this.setState({
277
+ lastX: x,
278
+ lastY: y
279
+ });
196
280
  });
197
- _defineProperty(this, "handleDragStop", e => {
198
- if (!this.dragging) return;
199
- const position = (0, _positionFns.getControlPosition)(e, this.touchIdentifier, this);
281
+
282
+ _defineProperty(_assertThisInitialized(_this), "handleDragStop", function (e) {
283
+ if (!_this.state.dragging) return;
284
+ var position = (0, _positionFns.getControlPosition)(e, _this.state.touchIdentifier, _assertThisInitialized(_this));
200
285
  if (position == null) return;
201
- let {
202
- x,
203
- y
204
- } = position;
205
-
206
- // Snap to grid if prop has been provided
207
- if (Array.isArray(this.props.grid)) {
208
- let deltaX = x - this.lastX || 0;
209
- let deltaY = y - this.lastY || 0;
210
- [deltaX, deltaY] = (0, _positionFns.snapToGrid)(this.props.grid, deltaX, deltaY);
211
- x = this.lastX + deltaX, y = this.lastY + deltaY;
286
+ var x = position.x,
287
+ y = position.y; // Snap to grid if prop has been provided
288
+
289
+ if (Array.isArray(_this.props.grid)) {
290
+ var deltaX = x - _this.state.lastX || 0;
291
+ var deltaY = y - _this.state.lastY || 0;
292
+
293
+ var _snapToGrid3 = (0, _positionFns.snapToGrid)(_this.props.grid, deltaX, deltaY);
294
+
295
+ var _snapToGrid4 = _slicedToArray(_snapToGrid3, 2);
296
+
297
+ deltaX = _snapToGrid4[0];
298
+ deltaY = _snapToGrid4[1];
299
+ x = _this.state.lastX + deltaX, y = _this.state.lastY + deltaY;
212
300
  }
213
- const coreEvent = (0, _positionFns.createCoreData)(this, x, y);
214
301
 
215
- // Call event handler
216
- const shouldContinue = this.props.onStop(e, coreEvent);
217
- if (shouldContinue === false || this.mounted === false) return false;
218
- const thisNode = this.findDOMNode();
302
+ var coreEvent = (0, _positionFns.createCoreData)(_assertThisInitialized(_this), x, y); // Call event handler
303
+
304
+ var shouldContinue = _this.props.onStop(e, coreEvent);
305
+
306
+ if (shouldContinue === false || _this.mounted === false) return false;
307
+
308
+ var thisNode = _this.findDOMNode();
309
+
219
310
  if (thisNode) {
220
311
  // Remove user-select hack
221
- if (this.props.enableUserSelectHack) (0, _domFns.scheduleRemoveUserSelectStyles)(thisNode.ownerDocument);
312
+ if (_this.props.enableUserSelectHack) (0, _domFns.removeUserSelectStyles)(thisNode.ownerDocument);
222
313
  }
223
- (0, _log.default)('DraggableCore: handleDragStop: %j', coreEvent);
224
314
 
225
- // Reset the el.
226
- this.dragging = false;
227
- this.lastX = NaN;
228
- this.lastY = NaN;
315
+ (0, _log.default)('DraggableCore: handleDragStop: %j', coreEvent); // Reset the el.
316
+
317
+ _this.setState({
318
+ dragging: false,
319
+ lastX: NaN,
320
+ lastY: NaN
321
+ });
322
+
229
323
  if (thisNode) {
230
324
  // Remove event handlers
231
325
  (0, _log.default)('DraggableCore: Removing handlers');
232
- (0, _domFns.removeEvent)(thisNode.ownerDocument, dragEventFor.move, this.handleDrag);
233
- (0, _domFns.removeEvent)(thisNode.ownerDocument, dragEventFor.stop, this.handleDragStop);
326
+ (0, _domFns.removeEvent)(thisNode.ownerDocument, dragEventFor.move, _this.handleDrag);
327
+ (0, _domFns.removeEvent)(thisNode.ownerDocument, dragEventFor.stop, _this.handleDragStop);
234
328
  }
235
329
  });
236
- _defineProperty(this, "onMouseDown", e => {
330
+
331
+ _defineProperty(_assertThisInitialized(_this), "onMouseDown", function (e) {
237
332
  dragEventFor = eventsFor.mouse; // on touchscreen laptops we could switch back to mouse
238
333
 
239
- return this.handleDragStart(e);
334
+ return _this.handleDragStart(e);
240
335
  });
241
- _defineProperty(this, "onMouseUp", e => {
336
+
337
+ _defineProperty(_assertThisInitialized(_this), "onMouseUp", function (e) {
242
338
  dragEventFor = eventsFor.mouse;
243
- return this.handleDragStop(e);
339
+ return _this.handleDragStop(e);
244
340
  });
245
- // Same as onMouseDown (start drag), but now consider this a touch device.
246
- _defineProperty(this, "onTouchStart", e => {
341
+
342
+ _defineProperty(_assertThisInitialized(_this), "onTouchStart", function (e) {
247
343
  // We're on a touch device now, so change the event handlers
248
344
  dragEventFor = eventsFor.touch;
249
- return this.handleDragStart(e);
345
+ return _this.handleDragStart(e);
250
346
  });
251
- _defineProperty(this, "onTouchEnd", e => {
347
+
348
+ _defineProperty(_assertThisInitialized(_this), "onTouchEnd", function (e) {
252
349
  // We're on a touch device now, so change the event handlers
253
350
  dragEventFor = eventsFor.touch;
254
- return this.handleDragStop(e);
351
+ return _this.handleDragStop(e);
255
352
  });
353
+
354
+ return _this;
256
355
  }
257
- componentDidMount() {
258
- this.mounted = true;
259
- // Touch handlers must be added with {passive: false} to be cancelable.
260
- // https://developers.google.com/web/updates/2017/01/scrolling-intervention
261
- const thisNode = this.findDOMNode();
262
- if (thisNode) {
263
- (0, _domFns.addEvent)(thisNode, eventsFor.touch.start, this.onTouchStart, {
264
- passive: false
265
- });
356
+
357
+ _createClass(DraggableCore, [{
358
+ key: "componentDidMount",
359
+ value: function componentDidMount() {
360
+ this.mounted = true; // Touch handlers must be added with {passive: false} to be cancelable.
361
+ // https://developers.google.com/web/updates/2017/01/scrolling-intervention
362
+
363
+ var thisNode = this.findDOMNode();
364
+
365
+ if (thisNode) {
366
+ (0, _domFns.addEvent)(thisNode, eventsFor.touch.start, this.onTouchStart, {
367
+ passive: false
368
+ });
369
+ }
266
370
  }
267
- }
268
- componentWillUnmount() {
269
- this.mounted = false;
270
- // Remove any leftover event handlers. Remove both touch and mouse handlers in case
271
- // some browser quirk caused a touch event to fire during a mouse move, or vice versa.
272
- const thisNode = this.findDOMNode();
273
- if (thisNode) {
274
- const {
275
- ownerDocument
276
- } = thisNode;
277
- (0, _domFns.removeEvent)(ownerDocument, eventsFor.mouse.move, this.handleDrag);
278
- (0, _domFns.removeEvent)(ownerDocument, eventsFor.touch.move, this.handleDrag);
279
- (0, _domFns.removeEvent)(ownerDocument, eventsFor.mouse.stop, this.handleDragStop);
280
- (0, _domFns.removeEvent)(ownerDocument, eventsFor.touch.stop, this.handleDragStop);
281
- (0, _domFns.removeEvent)(thisNode, eventsFor.touch.start, this.onTouchStart, {
282
- passive: false
371
+ }, {
372
+ key: "componentWillUnmount",
373
+ value: function componentWillUnmount() {
374
+ this.mounted = false; // Remove any leftover event handlers. Remove both touch and mouse handlers in case
375
+ // some browser quirk caused a touch event to fire during a mouse move, or vice versa.
376
+
377
+ var thisNode = this.findDOMNode();
378
+
379
+ if (thisNode) {
380
+ var ownerDocument = thisNode.ownerDocument;
381
+ (0, _domFns.removeEvent)(ownerDocument, eventsFor.mouse.move, this.handleDrag);
382
+ (0, _domFns.removeEvent)(ownerDocument, eventsFor.touch.move, this.handleDrag);
383
+ (0, _domFns.removeEvent)(ownerDocument, eventsFor.mouse.stop, this.handleDragStop);
384
+ (0, _domFns.removeEvent)(ownerDocument, eventsFor.touch.stop, this.handleDragStop);
385
+ (0, _domFns.removeEvent)(thisNode, eventsFor.touch.start, this.onTouchStart, {
386
+ passive: false
387
+ });
388
+ if (this.props.enableUserSelectHack) (0, _domFns.removeUserSelectStyles)(ownerDocument);
389
+ }
390
+ } // React Strict Mode compatibility: if `nodeRef` is passed, we will use it instead of trying to find
391
+ // the underlying DOM node ourselves. See the README for more information.
392
+
393
+ }, {
394
+ key: "findDOMNode",
395
+ value: function findDOMNode()
396
+ /*: ?HTMLElement*/
397
+ {
398
+ var _this$props, _this$props2, _this$props2$nodeRef;
399
+
400
+ return (_this$props = this.props) !== null && _this$props !== void 0 && _this$props.nodeRef ? (_this$props2 = this.props) === null || _this$props2 === void 0 ? void 0 : (_this$props2$nodeRef = _this$props2.nodeRef) === null || _this$props2$nodeRef === void 0 ? void 0 : _this$props2$nodeRef.current : _reactDom.default.findDOMNode(this);
401
+ }
402
+ }, {
403
+ key: "render",
404
+ value: function render()
405
+ /*: React.Element<any>*/
406
+ {
407
+ // Reuse the child provided
408
+ // This makes it flexible to use whatever element is wanted (div, ul, etc)
409
+ return /*#__PURE__*/React.cloneElement(React.Children.only(this.props.children), {
410
+ // Note: mouseMove handler is attached to document so it will still function
411
+ // when the user drags quickly and leaves the bounds of the element.
412
+ onMouseDown: this.onMouseDown,
413
+ onMouseUp: this.onMouseUp,
414
+ // onTouchStart is added on `componentDidMount` so they can be added with
415
+ // {passive: false}, which allows it to cancel. See
416
+ // https://developers.google.com/web/updates/2017/01/scrolling-intervention
417
+ onTouchEnd: this.onTouchEnd
283
418
  });
284
- if (this.props.enableUserSelectHack) (0, _domFns.scheduleRemoveUserSelectStyles)(ownerDocument);
285
419
  }
286
- }
420
+ }]);
421
+
422
+ return DraggableCore;
423
+ }(React.Component);
287
424
 
288
- // React Strict Mode compatibility: if `nodeRef` is passed, we will use it instead of trying to find
289
- // the underlying DOM node ourselves. See the README for more information.
290
- findDOMNode() /*: ?HTMLElement*/{
291
- return this.props?.nodeRef ? this.props?.nodeRef?.current : _reactDom.default.findDOMNode(this);
292
- }
293
- render() /*: React.Element<any>*/{
294
- // Reuse the child provided
295
- // This makes it flexible to use whatever element is wanted (div, ul, etc)
296
- return /*#__PURE__*/React.cloneElement(React.Children.only(this.props.children), {
297
- // Note: mouseMove handler is attached to document so it will still function
298
- // when the user drags quickly and leaves the bounds of the element.
299
- onMouseDown: this.onMouseDown,
300
- onMouseUp: this.onMouseUp,
301
- // onTouchStart is added on `componentDidMount` so they can be added with
302
- // {passive: false}, which allows it to cancel. See
303
- // https://developers.google.com/web/updates/2017/01/scrolling-intervention
304
- onTouchEnd: this.onTouchEnd
305
- });
306
- }
307
- }
308
425
  DraggableCore$1.default = DraggableCore;
426
+
309
427
  _defineProperty(DraggableCore, "displayName", 'DraggableCore');
428
+
310
429
  _defineProperty(DraggableCore, "propTypes", {
311
430
  /**
312
431
  * `allowAnyClick` allows dragging using any mouse button.
@@ -315,39 +434,39 @@ _defineProperty(DraggableCore, "propTypes", {
315
434
  * Defaults to `false`.
316
435
  */
317
436
  allowAnyClick: _propTypes.default.bool,
318
- /**
319
- * `allowMobileScroll` turns off cancellation of the 'touchstart' event
320
- * on mobile devices. Only enable this if you are having trouble with click
321
- * events. Prefer using 'handle' / 'cancel' instead.
322
- *
323
- * Defaults to `false`.
324
- */
325
- allowMobileScroll: _propTypes.default.bool,
326
- children: _propTypes.default.node.isRequired,
437
+
327
438
  /**
328
439
  * `disabled`, if true, stops the <Draggable> from dragging. All handlers,
329
440
  * with the exception of `onMouseDown`, will not fire.
330
441
  */
331
442
  disabled: _propTypes.default.bool,
443
+
332
444
  /**
333
445
  * By default, we add 'user-select:none' attributes to the document body
334
446
  * to prevent ugly text selection during drag. If this is causing problems
335
447
  * for your app, set this to `false`.
336
448
  */
337
449
  enableUserSelectHack: _propTypes.default.bool,
450
+
338
451
  /**
339
452
  * `offsetParent`, if set, uses the passed DOM node to compute drag offsets
340
453
  * instead of using the parent node.
341
454
  */
342
- offsetParent: function (props /*: DraggableCoreProps*/, propName /*: $Keys<DraggableCoreProps>*/) {
455
+ offsetParent: function offsetParent(props
456
+ /*: DraggableCoreProps*/
457
+ , propName
458
+ /*: $Keys<DraggableCoreProps>*/
459
+ ) {
343
460
  if (props[propName] && props[propName].nodeType !== 1) {
344
461
  throw new Error('Draggable\'s offsetParent must be a DOM Node.');
345
462
  }
346
463
  },
464
+
347
465
  /**
348
466
  * `grid` specifies the x and y that dragging should snap to.
349
467
  */
350
468
  grid: _propTypes.default.arrayOf(_propTypes.default.number),
469
+
351
470
  /**
352
471
  * `handle` specifies a selector to be used as the handle that initiates drag.
353
472
  *
@@ -369,6 +488,7 @@ _defineProperty(DraggableCore, "propTypes", {
369
488
  * ```
370
489
  */
371
490
  handle: _propTypes.default.string,
491
+
372
492
  /**
373
493
  * `cancel` specifies a selector to be used to prevent drag initialization.
374
494
  *
@@ -390,6 +510,7 @@ _defineProperty(DraggableCore, "propTypes", {
390
510
  * ```
391
511
  */
392
512
  cancel: _propTypes.default.string,
513
+
393
514
  /* If running in React Strict mode, ReactDOM.findDOMNode() is deprecated.
394
515
  * Unfortunately, in order for <Draggable> to work properly, we need raw access
395
516
  * to the underlying DOM node. If you want to avoid the warning, pass a `nodeRef`
@@ -408,30 +529,36 @@ _defineProperty(DraggableCore, "propTypes", {
408
529
  * pointing to the actual child DOM node and not a custom component.
409
530
  */
410
531
  nodeRef: _propTypes.default.object,
532
+
411
533
  /**
412
534
  * Called when dragging starts.
413
535
  * If this function returns the boolean false, dragging will be canceled.
414
536
  */
415
537
  onStart: _propTypes.default.func,
538
+
416
539
  /**
417
540
  * Called while dragging.
418
541
  * If this function returns the boolean false, dragging will be canceled.
419
542
  */
420
543
  onDrag: _propTypes.default.func,
544
+
421
545
  /**
422
546
  * Called when dragging stops.
423
547
  * If this function returns the boolean false, the drag will remain active.
424
548
  */
425
549
  onStop: _propTypes.default.func,
550
+
426
551
  /**
427
552
  * A workaround option which can be passed if onMouseDown needs to be accessed,
428
553
  * since it'll always be blocked (as there is internal use of onMouseDown)
429
554
  */
430
555
  onMouseDown: _propTypes.default.func,
556
+
431
557
  /**
432
558
  * `scale`, if set, applies scaling while dragging an element
433
559
  */
434
560
  scale: _propTypes.default.number,
561
+
435
562
  /**
436
563
  * These properties should be defined on the child, not here.
437
564
  */
@@ -439,15 +566,15 @@ _defineProperty(DraggableCore, "propTypes", {
439
566
  style: _shims.dontSetMe,
440
567
  transform: _shims.dontSetMe
441
568
  });
569
+
442
570
  _defineProperty(DraggableCore, "defaultProps", {
443
571
  allowAnyClick: false,
444
572
  // by default only accept left click
445
- allowMobileScroll: false,
446
573
  disabled: false,
447
574
  enableUserSelectHack: true,
448
- onStart: function () {},
449
- onDrag: function () {},
450
- onStop: function () {},
451
- onMouseDown: function () {},
575
+ onStart: function onStart() {},
576
+ onDrag: function onDrag() {},
577
+ onStop: function onStop() {},
578
+ onMouseDown: function onMouseDown() {},
452
579
  scale: 1
453
580
  });