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.
- package/dist/es/_virtual/_commonjsHelpers.js +29 -1
- package/dist/es/_virtual/clsx.m.js +6 -0
- package/dist/es/node_modules/react-draggable/build/cjs/Draggable.js +262 -200
- package/dist/es/node_modules/react-draggable/build/cjs/DraggableCore.js +311 -184
- package/dist/es/node_modules/react-draggable/build/cjs/cjs.js +5 -6
- package/dist/es/node_modules/react-draggable/build/cjs/utils/domFns.js +217 -93
- package/dist/es/node_modules/react-draggable/build/cjs/utils/getPrefix.js +53 -20
- package/dist/es/node_modules/react-draggable/build/cjs/utils/log.js +1 -0
- package/dist/es/node_modules/react-draggable/build/cjs/utils/positionFns.js +126 -67
- package/dist/es/node_modules/react-draggable/build/cjs/utils/shims.js +38 -7
- package/package.json +2 -2
- package/dist/es/_virtual/clsx.js +0 -3
- package/dist/es/node_modules/react-draggable/node_modules/clsx/dist/clsx.js +0 -7
|
@@ -4,4 +4,32 @@ function getDefaultExportFromCjs (x) {
|
|
|
4
4
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
function getAugmentedNamespace(n) {
|
|
8
|
+
if (n.__esModule) return n;
|
|
9
|
+
var f = n.default;
|
|
10
|
+
if (typeof f == "function") {
|
|
11
|
+
var a = function a () {
|
|
12
|
+
if (this instanceof a) {
|
|
13
|
+
var args = [null];
|
|
14
|
+
args.push.apply(args, arguments);
|
|
15
|
+
var Ctor = Function.bind.apply(f, args);
|
|
16
|
+
return new Ctor();
|
|
17
|
+
}
|
|
18
|
+
return f.apply(this, arguments);
|
|
19
|
+
};
|
|
20
|
+
a.prototype = f.prototype;
|
|
21
|
+
} else a = {};
|
|
22
|
+
Object.defineProperty(a, '__esModule', {value: true});
|
|
23
|
+
Object.keys(n).forEach(function (k) {
|
|
24
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
25
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return n[k];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
return a;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { commonjsGlobal, getAugmentedNamespace, getDefaultExportFromCjs };
|
|
@@ -2,187 +2,210 @@ import { __exports as Draggable } from '../../../../_virtual/Draggable.js';
|
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { p as propTypesExports } from '../../../prop-types/index.js';
|
|
4
4
|
import require$$2 from 'react-dom';
|
|
5
|
-
import
|
|
5
|
+
import require$$3 from '../../../../_virtual/clsx.m.js';
|
|
6
6
|
import './utils/domFns.js';
|
|
7
7
|
import './utils/positionFns.js';
|
|
8
8
|
import './utils/shims.js';
|
|
9
9
|
import './DraggableCore.js';
|
|
10
10
|
import './utils/log.js';
|
|
11
|
-
import { __exports as domFns } from '../../../../_virtual/domFns.js';
|
|
12
|
-
import { __exports as positionFns } from '../../../../_virtual/positionFns.js';
|
|
13
11
|
import { __exports as shims } from '../../../../_virtual/shims.js';
|
|
14
12
|
import { __exports as DraggableCore } from '../../../../_virtual/DraggableCore.js';
|
|
15
13
|
import { __exports as log } from '../../../../_virtual/log.js';
|
|
14
|
+
import { __exports as domFns } from '../../../../_virtual/domFns.js';
|
|
15
|
+
import { __exports as positionFns } from '../../../../_virtual/positionFns.js';
|
|
16
16
|
|
|
17
17
|
(function (exports) {
|
|
18
18
|
|
|
19
|
+
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); }
|
|
20
|
+
|
|
19
21
|
Object.defineProperty(exports, "__esModule", {
|
|
20
22
|
value: true
|
|
21
23
|
});
|
|
22
24
|
Object.defineProperty(exports, "DraggableCore", {
|
|
23
25
|
enumerable: true,
|
|
24
|
-
get: function () {
|
|
26
|
+
get: function get() {
|
|
25
27
|
return _DraggableCore.default;
|
|
26
28
|
}
|
|
27
29
|
});
|
|
28
30
|
exports.default = void 0;
|
|
31
|
+
|
|
29
32
|
var React = _interopRequireWildcard(React__default);
|
|
33
|
+
|
|
30
34
|
var _propTypes = _interopRequireDefault(propTypesExports);
|
|
35
|
+
|
|
31
36
|
var _reactDom = _interopRequireDefault(require$$2);
|
|
32
|
-
|
|
37
|
+
|
|
38
|
+
var _clsx2 = _interopRequireDefault(require$$3);
|
|
39
|
+
|
|
33
40
|
var _domFns = domFns;
|
|
41
|
+
|
|
34
42
|
var _positionFns = positionFns;
|
|
43
|
+
|
|
35
44
|
var _shims = shims;
|
|
45
|
+
|
|
36
46
|
var _DraggableCore = _interopRequireDefault(DraggableCore);
|
|
47
|
+
|
|
37
48
|
var _log = _interopRequireDefault(log);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
49
|
+
|
|
50
|
+
var _excluded = ["axis", "bounds", "children", "defaultPosition", "defaultClassName", "defaultClassNameDragging", "defaultClassNameDragged", "position", "positionOffset", "scale"];
|
|
51
|
+
|
|
52
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
53
|
+
|
|
54
|
+
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); }
|
|
55
|
+
|
|
56
|
+
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; }
|
|
57
|
+
|
|
58
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
59
|
+
|
|
60
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
61
|
+
|
|
62
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
63
|
+
|
|
64
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
65
|
+
|
|
66
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
67
|
+
|
|
68
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
69
|
+
|
|
70
|
+
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."); }
|
|
71
|
+
|
|
72
|
+
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); }
|
|
73
|
+
|
|
74
|
+
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; }
|
|
75
|
+
|
|
76
|
+
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; }
|
|
77
|
+
|
|
78
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
79
|
+
|
|
80
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
81
|
+
|
|
82
|
+
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); } }
|
|
83
|
+
|
|
84
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
85
|
+
|
|
86
|
+
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); }
|
|
87
|
+
|
|
88
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
89
|
+
|
|
90
|
+
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); }; }
|
|
91
|
+
|
|
92
|
+
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); }
|
|
93
|
+
|
|
94
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
95
|
+
|
|
96
|
+
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; } }
|
|
97
|
+
|
|
98
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
99
|
+
|
|
100
|
+
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; }
|
|
101
|
+
|
|
70
102
|
//
|
|
71
103
|
// Define <Draggable>
|
|
72
104
|
//
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
...position
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
constructor(props /*: DraggableProps*/) {
|
|
100
|
-
super(props);
|
|
101
|
-
_defineProperty(this, "onDragStart", (e, coreData) => {
|
|
102
|
-
(0, _log.default)('Draggable: onDragStart: %j', coreData);
|
|
103
|
-
|
|
104
|
-
// Short-circuit if user's callback killed it.
|
|
105
|
-
const shouldStart = this.props.onStart(e, (0, _positionFns.createDraggableData)(this, coreData));
|
|
106
|
-
// Kills start event on core as well, so move handlers are never bound.
|
|
105
|
+
var Draggable = /*#__PURE__*/function (_React$Component) {
|
|
106
|
+
_inherits(Draggable, _React$Component);
|
|
107
|
+
|
|
108
|
+
var _super = _createSuper(Draggable);
|
|
109
|
+
|
|
110
|
+
function Draggable(props
|
|
111
|
+
/*: DraggableProps*/
|
|
112
|
+
) {
|
|
113
|
+
var _this;
|
|
114
|
+
|
|
115
|
+
_classCallCheck(this, Draggable);
|
|
116
|
+
|
|
117
|
+
_this = _super.call(this, props);
|
|
118
|
+
|
|
119
|
+
_defineProperty(_assertThisInitialized(_this), "onDragStart", function (e, coreData) {
|
|
120
|
+
(0, _log.default)('Draggable: onDragStart: %j', coreData); // Short-circuit if user's callback killed it.
|
|
121
|
+
|
|
122
|
+
var shouldStart = _this.props.onStart(e, (0, _positionFns.createDraggableData)(_assertThisInitialized(_this), coreData)); // Kills start event on core as well, so move handlers are never bound.
|
|
123
|
+
|
|
124
|
+
|
|
107
125
|
if (shouldStart === false) return false;
|
|
108
|
-
|
|
126
|
+
|
|
127
|
+
_this.setState({
|
|
109
128
|
dragging: true,
|
|
110
129
|
dragged: true
|
|
111
130
|
});
|
|
112
131
|
});
|
|
113
|
-
|
|
114
|
-
|
|
132
|
+
|
|
133
|
+
_defineProperty(_assertThisInitialized(_this), "onDrag", function (e, coreData) {
|
|
134
|
+
if (!_this.state.dragging) return false;
|
|
115
135
|
(0, _log.default)('Draggable: onDrag: %j', coreData);
|
|
116
|
-
|
|
117
|
-
|
|
136
|
+
var uiData = (0, _positionFns.createDraggableData)(_assertThisInitialized(_this), coreData);
|
|
137
|
+
var newState
|
|
138
|
+
/*: $Shape<DraggableState>*/
|
|
139
|
+
= {
|
|
118
140
|
x: uiData.x,
|
|
119
|
-
y: uiData.y
|
|
120
|
-
|
|
121
|
-
slackY: 0
|
|
122
|
-
};
|
|
141
|
+
y: uiData.y
|
|
142
|
+
}; // Keep within bounds.
|
|
123
143
|
|
|
124
|
-
|
|
125
|
-
if (this.props.bounds) {
|
|
144
|
+
if (_this.props.bounds) {
|
|
126
145
|
// Save original x and y.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
y
|
|
130
|
-
} = newState;
|
|
131
|
-
|
|
132
|
-
// Add slack to the values used to calculate bound position. This will ensure that if
|
|
146
|
+
var x = newState.x,
|
|
147
|
+
y = newState.y; // Add slack to the values used to calculate bound position. This will ensure that if
|
|
133
148
|
// we start removing slack, the element won't react to it right away until it's been
|
|
134
149
|
// completely removed.
|
|
135
|
-
newState.x += this.state.slackX;
|
|
136
|
-
newState.y += this.state.slackY;
|
|
137
150
|
|
|
138
|
-
|
|
139
|
-
|
|
151
|
+
newState.x += _this.state.slackX;
|
|
152
|
+
newState.y += _this.state.slackY; // Get bound position. This will ceil/floor the x and y within the boundaries.
|
|
153
|
+
|
|
154
|
+
var _getBoundPosition = (0, _positionFns.getBoundPosition)(_assertThisInitialized(_this), newState.x, newState.y),
|
|
155
|
+
_getBoundPosition2 = _slicedToArray(_getBoundPosition, 2),
|
|
156
|
+
newStateX = _getBoundPosition2[0],
|
|
157
|
+
newStateY = _getBoundPosition2[1];
|
|
158
|
+
|
|
140
159
|
newState.x = newStateX;
|
|
141
|
-
newState.y = newStateY;
|
|
160
|
+
newState.y = newStateY; // Recalculate slack by noting how much was shaved by the boundPosition handler.
|
|
142
161
|
|
|
143
|
-
|
|
144
|
-
newState.
|
|
145
|
-
newState.slackY = this.state.slackY + (y - newState.y);
|
|
162
|
+
newState.slackX = _this.state.slackX + (x - newState.x);
|
|
163
|
+
newState.slackY = _this.state.slackY + (y - newState.y); // Update the event we fire to reflect what really happened after bounds took effect.
|
|
146
164
|
|
|
147
|
-
// Update the event we fire to reflect what really happened after bounds took effect.
|
|
148
165
|
uiData.x = newState.x;
|
|
149
166
|
uiData.y = newState.y;
|
|
150
|
-
uiData.deltaX = newState.x -
|
|
151
|
-
uiData.deltaY = newState.y -
|
|
152
|
-
}
|
|
167
|
+
uiData.deltaX = newState.x - _this.state.x;
|
|
168
|
+
uiData.deltaY = newState.y - _this.state.y;
|
|
169
|
+
} // Short-circuit if user's callback killed it.
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
var shouldUpdate = _this.props.onDrag(e, uiData);
|
|
153
173
|
|
|
154
|
-
// Short-circuit if user's callback killed it.
|
|
155
|
-
const shouldUpdate = this.props.onDrag(e, uiData);
|
|
156
174
|
if (shouldUpdate === false) return false;
|
|
157
|
-
|
|
175
|
+
|
|
176
|
+
_this.setState(newState);
|
|
158
177
|
});
|
|
159
|
-
_defineProperty(this, "onDragStop", (e, coreData) => {
|
|
160
|
-
if (!this.state.dragging) return false;
|
|
161
178
|
|
|
162
|
-
|
|
163
|
-
|
|
179
|
+
_defineProperty(_assertThisInitialized(_this), "onDragStop", function (e, coreData) {
|
|
180
|
+
if (!_this.state.dragging) return false; // Short-circuit if user's callback killed it.
|
|
181
|
+
|
|
182
|
+
var shouldContinue = _this.props.onStop(e, (0, _positionFns.createDraggableData)(_assertThisInitialized(_this), coreData));
|
|
183
|
+
|
|
164
184
|
if (shouldContinue === false) return false;
|
|
165
185
|
(0, _log.default)('Draggable: onDragStop: %j', coreData);
|
|
166
|
-
|
|
186
|
+
var newState
|
|
187
|
+
/*: $Shape<DraggableState>*/
|
|
188
|
+
= {
|
|
167
189
|
dragging: false,
|
|
168
190
|
slackX: 0,
|
|
169
191
|
slackY: 0
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
// If this is a controlled component, the result of this operation will be to
|
|
192
|
+
}; // If this is a controlled component, the result of this operation will be to
|
|
173
193
|
// revert back to the old position. We expect a handler on `onDragStop`, at the least.
|
|
174
|
-
|
|
194
|
+
|
|
195
|
+
var controlled = Boolean(_this.props.position);
|
|
196
|
+
|
|
175
197
|
if (controlled) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
} = this.props.position;
|
|
198
|
+
var _this$props$position = _this.props.position,
|
|
199
|
+
x = _this$props$position.x,
|
|
200
|
+
y = _this$props$position.y;
|
|
180
201
|
newState.x = x;
|
|
181
202
|
newState.y = y;
|
|
182
203
|
}
|
|
183
|
-
|
|
204
|
+
|
|
205
|
+
_this.setState(newState);
|
|
184
206
|
});
|
|
185
|
-
|
|
207
|
+
|
|
208
|
+
_this.state = {
|
|
186
209
|
// Whether or not we are currently dragging.
|
|
187
210
|
dragging: false,
|
|
188
211
|
// Whether or not we have been dragged before.
|
|
@@ -190,107 +213,142 @@ import { __exports as log } from '../../../../_virtual/log.js';
|
|
|
190
213
|
// Current transform x and y.
|
|
191
214
|
x: props.position ? props.position.x : props.defaultPosition.x,
|
|
192
215
|
y: props.position ? props.position.y : props.defaultPosition.y,
|
|
193
|
-
prevPropsPosition: {
|
|
194
|
-
...props.position
|
|
195
|
-
},
|
|
216
|
+
prevPropsPosition: _objectSpread({}, props.position),
|
|
196
217
|
// Used for compensating for out-of-bounds drags
|
|
197
218
|
slackX: 0,
|
|
198
219
|
slackY: 0,
|
|
199
220
|
// Can only determine if SVG after mounting
|
|
200
221
|
isElementSVG: false
|
|
201
222
|
};
|
|
223
|
+
|
|
202
224
|
if (props.position && !(props.onDrag || props.onStop)) {
|
|
203
225
|
// eslint-disable-next-line no-console
|
|
204
226
|
console.warn('A `position` was applied to this <Draggable>, without drag handlers. This will make this ' + 'component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the ' + '`position` of this element.');
|
|
205
227
|
}
|
|
228
|
+
|
|
229
|
+
return _this;
|
|
206
230
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
231
|
+
|
|
232
|
+
_createClass(Draggable, [{
|
|
233
|
+
key: "componentDidMount",
|
|
234
|
+
value: function componentDidMount() {
|
|
235
|
+
// Check to see if the element passed is an instanceof SVGElement
|
|
236
|
+
if (typeof window.SVGElement !== 'undefined' && this.findDOMNode() instanceof window.SVGElement) {
|
|
237
|
+
this.setState({
|
|
238
|
+
isElementSVG: true
|
|
239
|
+
});
|
|
240
|
+
}
|
|
213
241
|
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
242
|
+
}, {
|
|
243
|
+
key: "componentWillUnmount",
|
|
244
|
+
value: function componentWillUnmount() {
|
|
217
245
|
this.setState({
|
|
218
246
|
dragging: false
|
|
219
247
|
}); // prevents invariant if unmounted while dragging
|
|
248
|
+
} // React Strict Mode compatibility: if `nodeRef` is passed, we will use it instead of trying to find
|
|
249
|
+
// the underlying DOM node ourselves. See the README for more information.
|
|
250
|
+
|
|
251
|
+
}, {
|
|
252
|
+
key: "findDOMNode",
|
|
253
|
+
value: function findDOMNode()
|
|
254
|
+
/*: ?HTMLElement*/
|
|
255
|
+
{
|
|
256
|
+
var _this$props$nodeRef$c, _this$props, _this$props$nodeRef;
|
|
257
|
+
|
|
258
|
+
return (_this$props$nodeRef$c = (_this$props = this.props) === null || _this$props === void 0 ? void 0 : (_this$props$nodeRef = _this$props.nodeRef) === null || _this$props$nodeRef === void 0 ? void 0 : _this$props$nodeRef.current) !== null && _this$props$nodeRef$c !== void 0 ? _this$props$nodeRef$c : _reactDom.default.findDOMNode(this);
|
|
220
259
|
}
|
|
221
|
-
}
|
|
260
|
+
}, {
|
|
261
|
+
key: "render",
|
|
262
|
+
value: function render()
|
|
263
|
+
/*: ReactElement<any>*/
|
|
264
|
+
{
|
|
265
|
+
var _clsx;
|
|
222
266
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
positionOffset,
|
|
239
|
-
scale,
|
|
240
|
-
...draggableCoreProps
|
|
241
|
-
} = this.props;
|
|
242
|
-
let style = {};
|
|
243
|
-
let svgTransform = null;
|
|
244
|
-
|
|
245
|
-
// If this is controlled, we don't want to move it - unless it's dragging.
|
|
246
|
-
const controlled = Boolean(position);
|
|
247
|
-
const draggable = !controlled || this.state.dragging;
|
|
248
|
-
const validPosition = position || defaultPosition;
|
|
249
|
-
const transformOpts = {
|
|
250
|
-
// Set left if horizontal drag is enabled
|
|
251
|
-
x: (0, _positionFns.canDragX)(this) && draggable ? this.state.x : validPosition.x,
|
|
252
|
-
// Set top if vertical drag is enabled
|
|
253
|
-
y: (0, _positionFns.canDragY)(this) && draggable ? this.state.y : validPosition.y
|
|
254
|
-
};
|
|
267
|
+
var _this$props2 = this.props;
|
|
268
|
+
_this$props2.axis;
|
|
269
|
+
_this$props2.bounds;
|
|
270
|
+
var children = _this$props2.children,
|
|
271
|
+
defaultPosition = _this$props2.defaultPosition,
|
|
272
|
+
defaultClassName = _this$props2.defaultClassName,
|
|
273
|
+
defaultClassNameDragging = _this$props2.defaultClassNameDragging,
|
|
274
|
+
defaultClassNameDragged = _this$props2.defaultClassNameDragged,
|
|
275
|
+
position = _this$props2.position,
|
|
276
|
+
positionOffset = _this$props2.positionOffset;
|
|
277
|
+
_this$props2.scale;
|
|
278
|
+
var draggableCoreProps = _objectWithoutProperties(_this$props2, _excluded);
|
|
279
|
+
|
|
280
|
+
var style = {};
|
|
281
|
+
var svgTransform = null; // If this is controlled, we don't want to move it - unless it's dragging.
|
|
255
282
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
283
|
+
var controlled = Boolean(position);
|
|
284
|
+
var draggable = !controlled || this.state.dragging;
|
|
285
|
+
var validPosition = position || defaultPosition;
|
|
286
|
+
var transformOpts = {
|
|
287
|
+
// Set left if horizontal drag is enabled
|
|
288
|
+
x: (0, _positionFns.canDragX)(this) && draggable ? this.state.x : validPosition.x,
|
|
289
|
+
// Set top if vertical drag is enabled
|
|
290
|
+
y: (0, _positionFns.canDragY)(this) && draggable ? this.state.y : validPosition.y
|
|
291
|
+
}; // If this element was SVG, we use the `transform` attribute.
|
|
292
|
+
|
|
293
|
+
if (this.state.isElementSVG) {
|
|
294
|
+
svgTransform = (0, _domFns.createSVGTransform)(transformOpts, positionOffset);
|
|
295
|
+
} else {
|
|
296
|
+
// Add a CSS transform to move the element around. This allows us to move the element around
|
|
297
|
+
// without worrying about whether or not it is relatively or absolutely positioned.
|
|
298
|
+
// If the item you are dragging already has a transform set, wrap it in a <span> so <Draggable>
|
|
299
|
+
// has a clean slate.
|
|
300
|
+
style = (0, _domFns.createCSSTransform)(transformOpts, positionOffset);
|
|
301
|
+
} // Mark with class while dragging
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
var className = (0, _clsx2.default)(children.props.className || '', defaultClassName, (_clsx = {}, _defineProperty(_clsx, defaultClassNameDragging, this.state.dragging), _defineProperty(_clsx, defaultClassNameDragged, this.state.dragged), _clsx)); // Reuse the child provided
|
|
305
|
+
// This makes it flexible to use whatever element is wanted (div, ul, etc)
|
|
306
|
+
|
|
307
|
+
return /*#__PURE__*/React.createElement(_DraggableCore.default, _extends({}, draggableCoreProps, {
|
|
308
|
+
onStart: this.onDragStart,
|
|
309
|
+
onDrag: this.onDrag,
|
|
310
|
+
onStop: this.onDragStop
|
|
311
|
+
}), /*#__PURE__*/React.cloneElement(React.Children.only(children), {
|
|
312
|
+
className: className,
|
|
313
|
+
style: _objectSpread(_objectSpread({}, children.props.style), style),
|
|
314
|
+
transform: svgTransform
|
|
315
|
+
}));
|
|
265
316
|
}
|
|
317
|
+
}], [{
|
|
318
|
+
key: "getDerivedStateFromProps",
|
|
319
|
+
value: // React 16.3+
|
|
320
|
+
// Arity (props, state)
|
|
321
|
+
function getDerivedStateFromProps(_ref, _ref2)
|
|
322
|
+
/*: ?$Shape<DraggableState>*/
|
|
323
|
+
{
|
|
324
|
+
var position = _ref.position;
|
|
325
|
+
var prevPropsPosition = _ref2.prevPropsPosition;
|
|
266
326
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
327
|
+
// Set x/y if a new position is provided in props that is different than the previous.
|
|
328
|
+
if (position && (!prevPropsPosition || position.x !== prevPropsPosition.x || position.y !== prevPropsPosition.y)) {
|
|
329
|
+
(0, _log.default)('Draggable: getDerivedStateFromProps %j', {
|
|
330
|
+
position: position,
|
|
331
|
+
prevPropsPosition: prevPropsPosition
|
|
332
|
+
});
|
|
333
|
+
return {
|
|
334
|
+
x: position.x,
|
|
335
|
+
y: position.y,
|
|
336
|
+
prevPropsPosition: _objectSpread({}, position)
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
}]);
|
|
343
|
+
|
|
344
|
+
return Draggable;
|
|
345
|
+
}(React.Component);
|
|
272
346
|
|
|
273
|
-
// Reuse the child provided
|
|
274
|
-
// This makes it flexible to use whatever element is wanted (div, ul, etc)
|
|
275
|
-
return /*#__PURE__*/React.createElement(_DraggableCore.default, _extends({}, draggableCoreProps, {
|
|
276
|
-
onStart: this.onDragStart,
|
|
277
|
-
onDrag: this.onDrag,
|
|
278
|
-
onStop: this.onDragStop
|
|
279
|
-
}), /*#__PURE__*/React.cloneElement(React.Children.only(children), {
|
|
280
|
-
className: className,
|
|
281
|
-
style: {
|
|
282
|
-
...children.props.style,
|
|
283
|
-
...style
|
|
284
|
-
},
|
|
285
|
-
transform: svgTransform
|
|
286
|
-
}));
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
347
|
exports.default = Draggable;
|
|
348
|
+
|
|
290
349
|
_defineProperty(Draggable, "displayName", 'Draggable');
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
..._DraggableCore.default.propTypes,
|
|
350
|
+
|
|
351
|
+
_defineProperty(Draggable, "propTypes", _objectSpread(_objectSpread({}, _DraggableCore.default.propTypes), {}, {
|
|
294
352
|
/**
|
|
295
353
|
* `axis` determines which axis the draggable can move.
|
|
296
354
|
*
|
|
@@ -305,6 +363,7 @@ import { __exports as log } from '../../../../_virtual/log.js';
|
|
|
305
363
|
* Defaults to 'both'.
|
|
306
364
|
*/
|
|
307
365
|
axis: _propTypes.default.oneOf(['both', 'x', 'y', 'none']),
|
|
366
|
+
|
|
308
367
|
/**
|
|
309
368
|
* `bounds` determines the range of movement available to the element.
|
|
310
369
|
* Available values are:
|
|
@@ -340,6 +399,7 @@ import { __exports as log } from '../../../../_virtual/log.js';
|
|
|
340
399
|
defaultClassName: _propTypes.default.string,
|
|
341
400
|
defaultClassNameDragging: _propTypes.default.string,
|
|
342
401
|
defaultClassNameDragged: _propTypes.default.string,
|
|
402
|
+
|
|
343
403
|
/**
|
|
344
404
|
* `defaultPosition` specifies the x and y that the dragged item should start at
|
|
345
405
|
*
|
|
@@ -365,6 +425,7 @@ import { __exports as log } from '../../../../_virtual/log.js';
|
|
|
365
425
|
x: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
366
426
|
y: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
|
|
367
427
|
}),
|
|
428
|
+
|
|
368
429
|
/**
|
|
369
430
|
* `position`, if present, defines the current position of the element.
|
|
370
431
|
*
|
|
@@ -389,15 +450,16 @@ import { __exports as log } from '../../../../_virtual/log.js';
|
|
|
389
450
|
x: _propTypes.default.number,
|
|
390
451
|
y: _propTypes.default.number
|
|
391
452
|
}),
|
|
453
|
+
|
|
392
454
|
/**
|
|
393
455
|
* These properties should be defined on the child, not here.
|
|
394
456
|
*/
|
|
395
457
|
className: _shims.dontSetMe,
|
|
396
458
|
style: _shims.dontSetMe,
|
|
397
459
|
transform: _shims.dontSetMe
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
|
|
460
|
+
}));
|
|
461
|
+
|
|
462
|
+
_defineProperty(Draggable, "defaultProps", _objectSpread(_objectSpread({}, _DraggableCore.default.defaultProps), {}, {
|
|
401
463
|
axis: 'both',
|
|
402
464
|
bounds: false,
|
|
403
465
|
defaultClassName: 'react-draggable',
|
|
@@ -408,5 +470,5 @@ import { __exports as log } from '../../../../_virtual/log.js';
|
|
|
408
470
|
y: 0
|
|
409
471
|
},
|
|
410
472
|
scale: 1
|
|
411
|
-
});
|
|
473
|
+
}));
|
|
412
474
|
} (Draggable));
|