zmdms-webui 2.5.0 → 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/Draggable.js +3 -0
- package/dist/es/_virtual/DraggableCore.js +3 -0
- package/dist/es/_virtual/_commonjsHelpers.js +29 -1
- package/dist/es/_virtual/cjs.js +3 -0
- package/dist/es/_virtual/clsx.m.js +6 -0
- package/dist/es/_virtual/domFns.js +3 -0
- package/dist/es/_virtual/getPrefix.js +3 -0
- package/dist/es/_virtual/index2.js +2 -2
- package/dist/es/_virtual/index4.js +3 -0
- package/dist/es/_virtual/index5.js +3 -0
- package/dist/es/_virtual/log.js +3 -0
- package/dist/es/_virtual/positionFns.js +3 -0
- package/dist/es/_virtual/react-is.development2.js +3 -0
- package/dist/es/_virtual/react-is.production.min2.js +3 -0
- package/dist/es/_virtual/shims.js +3 -0
- package/dist/es/applayoutsider/appLayoutSider.d.ts +4 -0
- package/dist/es/applayoutsider/appLayoutSider.js +2 -2
- package/dist/es/applayoutsider/menu/index.js +2 -2
- package/dist/es/canvastable/canvasTable.js +1 -4
- package/dist/es/chatroom/chat-room.js +19 -0
- package/dist/es/chatroom/index.css +1 -0
- package/dist/es/chatroom/index.js +5 -0
- package/dist/es/modal/interface.d.ts +4 -0
- package/dist/es/modal/modal.js +15 -9
- package/dist/es/modal/useDraggable.js +51 -0
- package/dist/es/node_modules/immutability-helper/index.js +1 -1
- package/dist/es/node_modules/object-assign/index.js +99 -0
- package/dist/es/node_modules/prop-types/checkPropTypes.js +115 -0
- package/dist/es/node_modules/prop-types/factoryWithThrowingShims.js +74 -0
- package/dist/es/node_modules/prop-types/factoryWithTypeCheckers.js +625 -0
- package/dist/es/node_modules/prop-types/index.js +28 -0
- package/dist/es/node_modules/prop-types/lib/ReactPropTypesSecret.js +21 -0
- package/dist/es/node_modules/prop-types/lib/has.js +11 -0
- package/dist/es/node_modules/prop-types/node_modules/react-is/cjs/react-is.development.js +190 -0
- package/dist/es/node_modules/prop-types/node_modules/react-is/cjs/react-is.production.min.js +26 -0
- package/dist/es/node_modules/prop-types/node_modules/react-is/index.js +19 -0
- package/dist/es/node_modules/rc-util/es/Dom/findDOMNode.js +2 -2
- package/dist/es/node_modules/react-draggable/build/cjs/Draggable.js +474 -0
- package/dist/es/node_modules/react-draggable/build/cjs/DraggableCore.js +580 -0
- package/dist/es/node_modules/react-draggable/build/cjs/cjs.js +20 -0
- package/dist/es/node_modules/react-draggable/build/cjs/utils/domFns.js +361 -0
- package/dist/es/node_modules/react-draggable/build/cjs/utils/getPrefix.js +85 -0
- package/dist/es/node_modules/react-draggable/build/cjs/utils/log.js +10 -0
- package/dist/es/node_modules/react-draggable/build/cjs/utils/positionFns.js +214 -0
- package/dist/es/node_modules/react-draggable/build/cjs/utils/shims.js +64 -0
- package/dist/es/node_modules/react-is/cjs/react-is.development.js +1 -1
- package/dist/es/node_modules/react-is/cjs/react-is.production.min.js +1 -1
- package/dist/es/node_modules/react-is/index.js +1 -1
- package/dist/index.dark.css +1 -1
- package/dist/index.default.css +1 -1
- package/dist/less/components/ChatRoom/style/index.less +147 -0
- package/dist/less/components/ChatRoom/style/style.less +2 -0
- package/dist/less/styles/index.less +2 -0
- package/package.json +2 -1
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
import { __exports as Draggable } from '../../../../_virtual/Draggable.js';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { p as propTypesExports } from '../../../prop-types/index.js';
|
|
4
|
+
import require$$2 from 'react-dom';
|
|
5
|
+
import require$$3 from '../../../../_virtual/clsx.m.js';
|
|
6
|
+
import './utils/domFns.js';
|
|
7
|
+
import './utils/positionFns.js';
|
|
8
|
+
import './utils/shims.js';
|
|
9
|
+
import './DraggableCore.js';
|
|
10
|
+
import './utils/log.js';
|
|
11
|
+
import { __exports as shims } from '../../../../_virtual/shims.js';
|
|
12
|
+
import { __exports as DraggableCore } from '../../../../_virtual/DraggableCore.js';
|
|
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
|
+
|
|
17
|
+
(function (exports) {
|
|
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
|
+
|
|
21
|
+
Object.defineProperty(exports, "__esModule", {
|
|
22
|
+
value: true
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "DraggableCore", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _DraggableCore.default;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
exports.default = void 0;
|
|
31
|
+
|
|
32
|
+
var React = _interopRequireWildcard(React__default);
|
|
33
|
+
|
|
34
|
+
var _propTypes = _interopRequireDefault(propTypesExports);
|
|
35
|
+
|
|
36
|
+
var _reactDom = _interopRequireDefault(require$$2);
|
|
37
|
+
|
|
38
|
+
var _clsx2 = _interopRequireDefault(require$$3);
|
|
39
|
+
|
|
40
|
+
var _domFns = domFns;
|
|
41
|
+
|
|
42
|
+
var _positionFns = positionFns;
|
|
43
|
+
|
|
44
|
+
var _shims = shims;
|
|
45
|
+
|
|
46
|
+
var _DraggableCore = _interopRequireDefault(DraggableCore);
|
|
47
|
+
|
|
48
|
+
var _log = _interopRequireDefault(log);
|
|
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
|
+
|
|
102
|
+
//
|
|
103
|
+
// Define <Draggable>
|
|
104
|
+
//
|
|
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
|
+
|
|
125
|
+
if (shouldStart === false) return false;
|
|
126
|
+
|
|
127
|
+
_this.setState({
|
|
128
|
+
dragging: true,
|
|
129
|
+
dragged: true
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
_defineProperty(_assertThisInitialized(_this), "onDrag", function (e, coreData) {
|
|
134
|
+
if (!_this.state.dragging) return false;
|
|
135
|
+
(0, _log.default)('Draggable: onDrag: %j', coreData);
|
|
136
|
+
var uiData = (0, _positionFns.createDraggableData)(_assertThisInitialized(_this), coreData);
|
|
137
|
+
var newState
|
|
138
|
+
/*: $Shape<DraggableState>*/
|
|
139
|
+
= {
|
|
140
|
+
x: uiData.x,
|
|
141
|
+
y: uiData.y
|
|
142
|
+
}; // Keep within bounds.
|
|
143
|
+
|
|
144
|
+
if (_this.props.bounds) {
|
|
145
|
+
// Save original x and y.
|
|
146
|
+
var x = newState.x,
|
|
147
|
+
y = newState.y; // Add slack to the values used to calculate bound position. This will ensure that if
|
|
148
|
+
// we start removing slack, the element won't react to it right away until it's been
|
|
149
|
+
// completely removed.
|
|
150
|
+
|
|
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
|
+
|
|
159
|
+
newState.x = newStateX;
|
|
160
|
+
newState.y = newStateY; // Recalculate slack by noting how much was shaved by the boundPosition handler.
|
|
161
|
+
|
|
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.
|
|
164
|
+
|
|
165
|
+
uiData.x = newState.x;
|
|
166
|
+
uiData.y = newState.y;
|
|
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);
|
|
173
|
+
|
|
174
|
+
if (shouldUpdate === false) return false;
|
|
175
|
+
|
|
176
|
+
_this.setState(newState);
|
|
177
|
+
});
|
|
178
|
+
|
|
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
|
+
|
|
184
|
+
if (shouldContinue === false) return false;
|
|
185
|
+
(0, _log.default)('Draggable: onDragStop: %j', coreData);
|
|
186
|
+
var newState
|
|
187
|
+
/*: $Shape<DraggableState>*/
|
|
188
|
+
= {
|
|
189
|
+
dragging: false,
|
|
190
|
+
slackX: 0,
|
|
191
|
+
slackY: 0
|
|
192
|
+
}; // If this is a controlled component, the result of this operation will be to
|
|
193
|
+
// revert back to the old position. We expect a handler on `onDragStop`, at the least.
|
|
194
|
+
|
|
195
|
+
var controlled = Boolean(_this.props.position);
|
|
196
|
+
|
|
197
|
+
if (controlled) {
|
|
198
|
+
var _this$props$position = _this.props.position,
|
|
199
|
+
x = _this$props$position.x,
|
|
200
|
+
y = _this$props$position.y;
|
|
201
|
+
newState.x = x;
|
|
202
|
+
newState.y = y;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
_this.setState(newState);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
_this.state = {
|
|
209
|
+
// Whether or not we are currently dragging.
|
|
210
|
+
dragging: false,
|
|
211
|
+
// Whether or not we have been dragged before.
|
|
212
|
+
dragged: false,
|
|
213
|
+
// Current transform x and y.
|
|
214
|
+
x: props.position ? props.position.x : props.defaultPosition.x,
|
|
215
|
+
y: props.position ? props.position.y : props.defaultPosition.y,
|
|
216
|
+
prevPropsPosition: _objectSpread({}, props.position),
|
|
217
|
+
// Used for compensating for out-of-bounds drags
|
|
218
|
+
slackX: 0,
|
|
219
|
+
slackY: 0,
|
|
220
|
+
// Can only determine if SVG after mounting
|
|
221
|
+
isElementSVG: false
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
if (props.position && !(props.onDrag || props.onStop)) {
|
|
225
|
+
// eslint-disable-next-line no-console
|
|
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.');
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return _this;
|
|
230
|
+
}
|
|
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
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}, {
|
|
243
|
+
key: "componentWillUnmount",
|
|
244
|
+
value: function componentWillUnmount() {
|
|
245
|
+
this.setState({
|
|
246
|
+
dragging: false
|
|
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);
|
|
259
|
+
}
|
|
260
|
+
}, {
|
|
261
|
+
key: "render",
|
|
262
|
+
value: function render()
|
|
263
|
+
/*: ReactElement<any>*/
|
|
264
|
+
{
|
|
265
|
+
var _clsx;
|
|
266
|
+
|
|
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.
|
|
282
|
+
|
|
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
|
+
}));
|
|
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;
|
|
326
|
+
|
|
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);
|
|
346
|
+
|
|
347
|
+
exports.default = Draggable;
|
|
348
|
+
|
|
349
|
+
_defineProperty(Draggable, "displayName", 'Draggable');
|
|
350
|
+
|
|
351
|
+
_defineProperty(Draggable, "propTypes", _objectSpread(_objectSpread({}, _DraggableCore.default.propTypes), {}, {
|
|
352
|
+
/**
|
|
353
|
+
* `axis` determines which axis the draggable can move.
|
|
354
|
+
*
|
|
355
|
+
* Note that all callbacks will still return data as normal. This only
|
|
356
|
+
* controls flushing to the DOM.
|
|
357
|
+
*
|
|
358
|
+
* 'both' allows movement horizontally and vertically.
|
|
359
|
+
* 'x' limits movement to horizontal axis.
|
|
360
|
+
* 'y' limits movement to vertical axis.
|
|
361
|
+
* 'none' limits all movement.
|
|
362
|
+
*
|
|
363
|
+
* Defaults to 'both'.
|
|
364
|
+
*/
|
|
365
|
+
axis: _propTypes.default.oneOf(['both', 'x', 'y', 'none']),
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* `bounds` determines the range of movement available to the element.
|
|
369
|
+
* Available values are:
|
|
370
|
+
*
|
|
371
|
+
* 'parent' restricts movement within the Draggable's parent node.
|
|
372
|
+
*
|
|
373
|
+
* Alternatively, pass an object with the following properties, all of which are optional:
|
|
374
|
+
*
|
|
375
|
+
* {left: LEFT_BOUND, right: RIGHT_BOUND, bottom: BOTTOM_BOUND, top: TOP_BOUND}
|
|
376
|
+
*
|
|
377
|
+
* All values are in px.
|
|
378
|
+
*
|
|
379
|
+
* Example:
|
|
380
|
+
*
|
|
381
|
+
* ```jsx
|
|
382
|
+
* let App = React.createClass({
|
|
383
|
+
* render: function () {
|
|
384
|
+
* return (
|
|
385
|
+
* <Draggable bounds={{right: 300, bottom: 300}}>
|
|
386
|
+
* <div>Content</div>
|
|
387
|
+
* </Draggable>
|
|
388
|
+
* );
|
|
389
|
+
* }
|
|
390
|
+
* });
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
bounds: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
394
|
+
left: _propTypes.default.number,
|
|
395
|
+
right: _propTypes.default.number,
|
|
396
|
+
top: _propTypes.default.number,
|
|
397
|
+
bottom: _propTypes.default.number
|
|
398
|
+
}), _propTypes.default.string, _propTypes.default.oneOf([false])]),
|
|
399
|
+
defaultClassName: _propTypes.default.string,
|
|
400
|
+
defaultClassNameDragging: _propTypes.default.string,
|
|
401
|
+
defaultClassNameDragged: _propTypes.default.string,
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* `defaultPosition` specifies the x and y that the dragged item should start at
|
|
405
|
+
*
|
|
406
|
+
* Example:
|
|
407
|
+
*
|
|
408
|
+
* ```jsx
|
|
409
|
+
* let App = React.createClass({
|
|
410
|
+
* render: function () {
|
|
411
|
+
* return (
|
|
412
|
+
* <Draggable defaultPosition={{x: 25, y: 25}}>
|
|
413
|
+
* <div>I start with transformX: 25px and transformY: 25px;</div>
|
|
414
|
+
* </Draggable>
|
|
415
|
+
* );
|
|
416
|
+
* }
|
|
417
|
+
* });
|
|
418
|
+
* ```
|
|
419
|
+
*/
|
|
420
|
+
defaultPosition: _propTypes.default.shape({
|
|
421
|
+
x: _propTypes.default.number,
|
|
422
|
+
y: _propTypes.default.number
|
|
423
|
+
}),
|
|
424
|
+
positionOffset: _propTypes.default.shape({
|
|
425
|
+
x: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
426
|
+
y: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
|
|
427
|
+
}),
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* `position`, if present, defines the current position of the element.
|
|
431
|
+
*
|
|
432
|
+
* This is similar to how form elements in React work - if no `position` is supplied, the component
|
|
433
|
+
* is uncontrolled.
|
|
434
|
+
*
|
|
435
|
+
* Example:
|
|
436
|
+
*
|
|
437
|
+
* ```jsx
|
|
438
|
+
* let App = React.createClass({
|
|
439
|
+
* render: function () {
|
|
440
|
+
* return (
|
|
441
|
+
* <Draggable position={{x: 25, y: 25}}>
|
|
442
|
+
* <div>I start with transformX: 25px and transformY: 25px;</div>
|
|
443
|
+
* </Draggable>
|
|
444
|
+
* );
|
|
445
|
+
* }
|
|
446
|
+
* });
|
|
447
|
+
* ```
|
|
448
|
+
*/
|
|
449
|
+
position: _propTypes.default.shape({
|
|
450
|
+
x: _propTypes.default.number,
|
|
451
|
+
y: _propTypes.default.number
|
|
452
|
+
}),
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* These properties should be defined on the child, not here.
|
|
456
|
+
*/
|
|
457
|
+
className: _shims.dontSetMe,
|
|
458
|
+
style: _shims.dontSetMe,
|
|
459
|
+
transform: _shims.dontSetMe
|
|
460
|
+
}));
|
|
461
|
+
|
|
462
|
+
_defineProperty(Draggable, "defaultProps", _objectSpread(_objectSpread({}, _DraggableCore.default.defaultProps), {}, {
|
|
463
|
+
axis: 'both',
|
|
464
|
+
bounds: false,
|
|
465
|
+
defaultClassName: 'react-draggable',
|
|
466
|
+
defaultClassNameDragging: 'react-draggable-dragging',
|
|
467
|
+
defaultClassNameDragged: 'react-draggable-dragged',
|
|
468
|
+
defaultPosition: {
|
|
469
|
+
x: 0,
|
|
470
|
+
y: 0
|
|
471
|
+
},
|
|
472
|
+
scale: 1
|
|
473
|
+
}));
|
|
474
|
+
} (Draggable));
|