@hi-ui/layout 4.0.0
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/README.md +11 -0
- package/lib/cjs/Content.js +48 -0
- package/lib/cjs/Layout.js +48 -0
- package/lib/cjs/SearchTrigger.js +55 -0
- package/lib/cjs/Sider.js +100 -0
- package/lib/cjs/_virtual/Draggable.js +16 -0
- package/lib/cjs/_virtual/DraggableCore.js +16 -0
- package/lib/cjs/_virtual/Resizable.js +16 -0
- package/lib/cjs/_virtual/ResizableBox.js +16 -0
- package/lib/cjs/_virtual/cjs.js +18 -0
- package/lib/cjs/_virtual/domFns.js +16 -0
- package/lib/cjs/_virtual/getPrefix.js +16 -0
- package/lib/cjs/_virtual/index.js +18 -0
- package/lib/cjs/_virtual/index2.js +18 -0
- package/lib/cjs/_virtual/index3.js +18 -0
- package/lib/cjs/_virtual/index4.js +18 -0
- package/lib/cjs/_virtual/log.js +16 -0
- package/lib/cjs/_virtual/positionFns.js +16 -0
- package/lib/cjs/_virtual/propTypes.js +16 -0
- package/lib/cjs/_virtual/react-is.development.js +16 -0
- package/lib/cjs/_virtual/react-is.production.min.js +16 -0
- package/lib/cjs/_virtual/shims.js +16 -0
- package/lib/cjs/_virtual/utils.js +16 -0
- package/lib/cjs/index.js +24 -0
- package/lib/cjs/node_modules/classnames/index.js +62 -0
- package/lib/cjs/node_modules/object-assign/index.js +94 -0
- package/lib/cjs/node_modules/prop-types/checkPropTypes.js +101 -0
- package/lib/cjs/node_modules/prop-types/factoryWithThrowingShims.js +68 -0
- package/lib/cjs/node_modules/prop-types/factoryWithTypeCheckers.js +553 -0
- package/lib/cjs/node_modules/prop-types/index.js +36 -0
- package/lib/cjs/node_modules/prop-types/lib/ReactPropTypesSecret.js +25 -0
- package/lib/cjs/node_modules/react-draggable/build/cjs/Draggable.js +655 -0
- package/lib/cjs/node_modules/react-draggable/build/cjs/DraggableCore.js +670 -0
- package/lib/cjs/node_modules/react-draggable/build/cjs/cjs.js +23 -0
- package/lib/cjs/node_modules/react-draggable/build/cjs/utils/domFns.js +366 -0
- package/lib/cjs/node_modules/react-draggable/build/cjs/utils/getPrefix.js +69 -0
- package/lib/cjs/node_modules/react-draggable/build/cjs/utils/log.js +19 -0
- package/lib/cjs/node_modules/react-draggable/build/cjs/utils/positionFns.js +176 -0
- package/lib/cjs/node_modules/react-draggable/build/cjs/utils/shims.js +57 -0
- package/lib/cjs/node_modules/react-is/cjs/react-is.development.js +182 -0
- package/lib/cjs/node_modules/react-is/cjs/react-is.production.min.js +132 -0
- package/lib/cjs/node_modules/react-is/index.js +21 -0
- package/lib/cjs/node_modules/react-resizable/build/Resizable.js +366 -0
- package/lib/cjs/node_modules/react-resizable/build/ResizableBox.js +244 -0
- package/lib/cjs/node_modules/react-resizable/build/propTypes.js +115 -0
- package/lib/cjs/node_modules/react-resizable/build/utils.js +86 -0
- package/lib/cjs/node_modules/react-resizable/index.js +25 -0
- package/lib/cjs/packages/icons/lib/esm/components/common/search-outlined.js +65 -0
- package/lib/cjs/packages/icons/lib/esm/styles/index.scss.js +35 -0
- package/lib/cjs/styles/index.scss.js +18 -0
- package/lib/esm/Content.js +36 -0
- package/lib/esm/Layout.js +36 -0
- package/lib/esm/SearchTrigger.js +43 -0
- package/lib/esm/Sider.js +88 -0
- package/lib/esm/_virtual/Draggable.js +11 -0
- package/lib/esm/_virtual/DraggableCore.js +11 -0
- package/lib/esm/_virtual/Resizable.js +11 -0
- package/lib/esm/_virtual/ResizableBox.js +11 -0
- package/lib/esm/_virtual/cjs.js +13 -0
- package/lib/esm/_virtual/domFns.js +11 -0
- package/lib/esm/_virtual/getPrefix.js +11 -0
- package/lib/esm/_virtual/index.js +13 -0
- package/lib/esm/_virtual/index2.js +13 -0
- package/lib/esm/_virtual/index3.js +13 -0
- package/lib/esm/_virtual/index4.js +13 -0
- package/lib/esm/_virtual/log.js +11 -0
- package/lib/esm/_virtual/positionFns.js +11 -0
- package/lib/esm/_virtual/propTypes.js +11 -0
- package/lib/esm/_virtual/react-is.development.js +11 -0
- package/lib/esm/_virtual/react-is.production.min.js +11 -0
- package/lib/esm/_virtual/shims.js +11 -0
- package/lib/esm/_virtual/utils.js +11 -0
- package/lib/esm/index.js +14 -0
- package/lib/esm/node_modules/classnames/index.js +60 -0
- package/lib/esm/node_modules/object-assign/index.js +88 -0
- package/lib/esm/node_modules/prop-types/checkPropTypes.js +96 -0
- package/lib/esm/node_modules/prop-types/factoryWithThrowingShims.js +63 -0
- package/lib/esm/node_modules/prop-types/factoryWithTypeCheckers.js +548 -0
- package/lib/esm/node_modules/prop-types/index.js +34 -0
- package/lib/esm/node_modules/prop-types/lib/ReactPropTypesSecret.js +19 -0
- package/lib/esm/node_modules/react-draggable/build/cjs/Draggable.js +645 -0
- package/lib/esm/node_modules/react-draggable/build/cjs/DraggableCore.js +660 -0
- package/lib/esm/node_modules/react-draggable/build/cjs/cjs.js +21 -0
- package/lib/esm/node_modules/react-draggable/build/cjs/utils/domFns.js +361 -0
- package/lib/esm/node_modules/react-draggable/build/cjs/utils/getPrefix.js +67 -0
- package/lib/esm/node_modules/react-draggable/build/cjs/utils/log.js +17 -0
- package/lib/esm/node_modules/react-draggable/build/cjs/utils/positionFns.js +171 -0
- package/lib/esm/node_modules/react-draggable/build/cjs/utils/shims.js +52 -0
- package/lib/esm/node_modules/react-is/cjs/react-is.development.js +177 -0
- package/lib/esm/node_modules/react-is/cjs/react-is.production.min.js +127 -0
- package/lib/esm/node_modules/react-is/index.js +19 -0
- package/lib/esm/node_modules/react-resizable/build/Resizable.js +358 -0
- package/lib/esm/node_modules/react-resizable/build/ResizableBox.js +236 -0
- package/lib/esm/node_modules/react-resizable/build/propTypes.js +110 -0
- package/lib/esm/node_modules/react-resizable/build/utils.js +74 -0
- package/lib/esm/node_modules/react-resizable/index.js +20 -0
- package/lib/esm/packages/icons/lib/esm/components/common/search-outlined.js +53 -0
- package/lib/esm/packages/icons/lib/esm/styles/index.scss.js +23 -0
- package/lib/esm/styles/index.scss.js +13 -0
- package/lib/types/Content.d.ts +8 -0
- package/lib/types/Layout.d.ts +8 -0
- package/lib/types/SearchTrigger.d.ts +10 -0
- package/lib/types/Sider.d.ts +10 -0
- package/lib/types/index.d.ts +6 -0
- package/package.json +61 -0
|
@@ -0,0 +1,645 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/layout
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/layout#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import { __exports as Draggable } from '../../../../_virtual/Draggable.js';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import '../../../prop-types/index.js';
|
|
13
|
+
import require$$2 from 'react-dom';
|
|
14
|
+
import '../../../classnames/index.js';
|
|
15
|
+
import './utils/domFns.js';
|
|
16
|
+
import './utils/positionFns.js';
|
|
17
|
+
import './utils/shims.js';
|
|
18
|
+
import './DraggableCore.js';
|
|
19
|
+
import './utils/log.js';
|
|
20
|
+
import { p as propTypes } from '../../../../_virtual/index2.js';
|
|
21
|
+
import { __exports as shims } from '../../../../_virtual/shims.js';
|
|
22
|
+
import { __exports as DraggableCore } from '../../../../_virtual/DraggableCore.js';
|
|
23
|
+
import { c as classnames } from '../../../../_virtual/index4.js';
|
|
24
|
+
import { __exports as domFns } from '../../../../_virtual/domFns.js';
|
|
25
|
+
import { __exports as positionFns } from '../../../../_virtual/positionFns.js';
|
|
26
|
+
import { __exports as log } from '../../../../_virtual/log.js';
|
|
27
|
+
(function (exports) {
|
|
28
|
+
Object.defineProperty(exports, "__esModule", {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "DraggableCore", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function get() {
|
|
34
|
+
return _DraggableCore["default"];
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
exports["default"] = void 0;
|
|
38
|
+
var React$1 = _interopRequireWildcard(React);
|
|
39
|
+
var _propTypes = _interopRequireDefault(propTypes.exports);
|
|
40
|
+
var _reactDom = _interopRequireDefault(require$$2);
|
|
41
|
+
var _classnames = _interopRequireDefault(classnames.exports);
|
|
42
|
+
var _domFns = domFns;
|
|
43
|
+
var _positionFns = positionFns;
|
|
44
|
+
var _shims = shims;
|
|
45
|
+
var _DraggableCore = _interopRequireDefault(DraggableCore);
|
|
46
|
+
var _log = _interopRequireDefault(log);
|
|
47
|
+
function _interopRequireDefault(obj) {
|
|
48
|
+
return obj && obj.__esModule ? obj : {
|
|
49
|
+
"default": obj
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function _getRequireWildcardCache() {
|
|
53
|
+
if (typeof WeakMap !== "function") return null;
|
|
54
|
+
var cache = new WeakMap();
|
|
55
|
+
_getRequireWildcardCache = function _getRequireWildcardCache() {
|
|
56
|
+
return cache;
|
|
57
|
+
};
|
|
58
|
+
return cache;
|
|
59
|
+
}
|
|
60
|
+
function _interopRequireWildcard(obj) {
|
|
61
|
+
if (obj && obj.__esModule) {
|
|
62
|
+
return obj;
|
|
63
|
+
}
|
|
64
|
+
if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
|
|
65
|
+
return {
|
|
66
|
+
"default": obj
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
var cache = _getRequireWildcardCache();
|
|
70
|
+
if (cache && cache.has(obj)) {
|
|
71
|
+
return cache.get(obj);
|
|
72
|
+
}
|
|
73
|
+
var newObj = {};
|
|
74
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
75
|
+
for (var key in obj) {
|
|
76
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
77
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
78
|
+
if (desc && (desc.get || desc.set)) {
|
|
79
|
+
Object.defineProperty(newObj, key, desc);
|
|
80
|
+
} else {
|
|
81
|
+
newObj[key] = obj[key];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
newObj["default"] = obj;
|
|
86
|
+
if (cache) {
|
|
87
|
+
cache.set(obj, newObj);
|
|
88
|
+
}
|
|
89
|
+
return newObj;
|
|
90
|
+
}
|
|
91
|
+
function _typeof(obj) {
|
|
92
|
+
"@babel/helpers - typeof";
|
|
93
|
+
|
|
94
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
95
|
+
_typeof = function _typeof(obj) {
|
|
96
|
+
return typeof obj;
|
|
97
|
+
};
|
|
98
|
+
} else {
|
|
99
|
+
_typeof = function _typeof(obj) {
|
|
100
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return _typeof(obj);
|
|
104
|
+
}
|
|
105
|
+
function _extends() {
|
|
106
|
+
_extends = Object.assign || function (target) {
|
|
107
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
108
|
+
var source = arguments[i];
|
|
109
|
+
for (var key in source) {
|
|
110
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
111
|
+
target[key] = source[key];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return target;
|
|
116
|
+
};
|
|
117
|
+
return _extends.apply(this, arguments);
|
|
118
|
+
}
|
|
119
|
+
function _objectWithoutProperties(source, excluded) {
|
|
120
|
+
if (source == null) return {};
|
|
121
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
122
|
+
var key, i;
|
|
123
|
+
if (Object.getOwnPropertySymbols) {
|
|
124
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
125
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
126
|
+
key = sourceSymbolKeys[i];
|
|
127
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
128
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
129
|
+
target[key] = source[key];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return target;
|
|
133
|
+
}
|
|
134
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
135
|
+
if (source == null) return {};
|
|
136
|
+
var target = {};
|
|
137
|
+
var sourceKeys = Object.keys(source);
|
|
138
|
+
var key, i;
|
|
139
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
140
|
+
key = sourceKeys[i];
|
|
141
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
142
|
+
target[key] = source[key];
|
|
143
|
+
}
|
|
144
|
+
return target;
|
|
145
|
+
}
|
|
146
|
+
function _slicedToArray(arr, i) {
|
|
147
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
148
|
+
}
|
|
149
|
+
function _nonIterableRest() {
|
|
150
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
151
|
+
}
|
|
152
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
153
|
+
if (!o) return;
|
|
154
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
155
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
156
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
157
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
158
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
159
|
+
}
|
|
160
|
+
function _arrayLikeToArray(arr, len) {
|
|
161
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
162
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
163
|
+
arr2[i] = arr[i];
|
|
164
|
+
}
|
|
165
|
+
return arr2;
|
|
166
|
+
}
|
|
167
|
+
function _iterableToArrayLimit(arr, i) {
|
|
168
|
+
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
169
|
+
var _arr = [];
|
|
170
|
+
var _n = true;
|
|
171
|
+
var _d = false;
|
|
172
|
+
var _e = undefined;
|
|
173
|
+
try {
|
|
174
|
+
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
175
|
+
_arr.push(_s.value);
|
|
176
|
+
if (i && _arr.length === i) break;
|
|
177
|
+
}
|
|
178
|
+
} catch (err) {
|
|
179
|
+
_d = true;
|
|
180
|
+
_e = err;
|
|
181
|
+
} finally {
|
|
182
|
+
try {
|
|
183
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
184
|
+
} finally {
|
|
185
|
+
if (_d) throw _e;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return _arr;
|
|
189
|
+
}
|
|
190
|
+
function _arrayWithHoles(arr) {
|
|
191
|
+
if (Array.isArray(arr)) return arr;
|
|
192
|
+
}
|
|
193
|
+
function ownKeys(object, enumerableOnly) {
|
|
194
|
+
var keys = Object.keys(object);
|
|
195
|
+
if (Object.getOwnPropertySymbols) {
|
|
196
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
197
|
+
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
198
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
199
|
+
});
|
|
200
|
+
keys.push.apply(keys, symbols);
|
|
201
|
+
}
|
|
202
|
+
return keys;
|
|
203
|
+
}
|
|
204
|
+
function _objectSpread(target) {
|
|
205
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
206
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
207
|
+
if (i % 2) {
|
|
208
|
+
ownKeys(Object(source), true).forEach(function (key) {
|
|
209
|
+
_defineProperty(target, key, source[key]);
|
|
210
|
+
});
|
|
211
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
212
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
213
|
+
} else {
|
|
214
|
+
ownKeys(Object(source)).forEach(function (key) {
|
|
215
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return target;
|
|
220
|
+
}
|
|
221
|
+
function _classCallCheck(instance, Constructor) {
|
|
222
|
+
if (!(instance instanceof Constructor)) {
|
|
223
|
+
throw new TypeError("Cannot call a class as a function");
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function _defineProperties(target, props) {
|
|
227
|
+
for (var i = 0; i < props.length; i++) {
|
|
228
|
+
var descriptor = props[i];
|
|
229
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
230
|
+
descriptor.configurable = true;
|
|
231
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
232
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
236
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
237
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
238
|
+
return Constructor;
|
|
239
|
+
}
|
|
240
|
+
function _inherits(subClass, superClass) {
|
|
241
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
242
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
243
|
+
}
|
|
244
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
245
|
+
constructor: {
|
|
246
|
+
value: subClass,
|
|
247
|
+
writable: true,
|
|
248
|
+
configurable: true
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
252
|
+
}
|
|
253
|
+
function _setPrototypeOf(o, p) {
|
|
254
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
255
|
+
o.__proto__ = p;
|
|
256
|
+
return o;
|
|
257
|
+
};
|
|
258
|
+
return _setPrototypeOf(o, p);
|
|
259
|
+
}
|
|
260
|
+
function _createSuper(Derived) {
|
|
261
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
262
|
+
return function () {
|
|
263
|
+
var Super = _getPrototypeOf(Derived),
|
|
264
|
+
result;
|
|
265
|
+
if (hasNativeReflectConstruct) {
|
|
266
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
267
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
268
|
+
} else {
|
|
269
|
+
result = Super.apply(this, arguments);
|
|
270
|
+
}
|
|
271
|
+
return _possibleConstructorReturn(this, result);
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
function _possibleConstructorReturn(self, call) {
|
|
275
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
276
|
+
return call;
|
|
277
|
+
}
|
|
278
|
+
return _assertThisInitialized(self);
|
|
279
|
+
}
|
|
280
|
+
function _assertThisInitialized(self) {
|
|
281
|
+
if (self === void 0) {
|
|
282
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
283
|
+
}
|
|
284
|
+
return self;
|
|
285
|
+
}
|
|
286
|
+
function _isNativeReflectConstruct() {
|
|
287
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
288
|
+
if (Reflect.construct.sham) return false;
|
|
289
|
+
if (typeof Proxy === "function") return true;
|
|
290
|
+
try {
|
|
291
|
+
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
|
|
292
|
+
return true;
|
|
293
|
+
} catch (e) {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
function _getPrototypeOf(o) {
|
|
298
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
299
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
300
|
+
};
|
|
301
|
+
return _getPrototypeOf(o);
|
|
302
|
+
}
|
|
303
|
+
function _defineProperty(obj, key, value) {
|
|
304
|
+
if (key in obj) {
|
|
305
|
+
Object.defineProperty(obj, key, {
|
|
306
|
+
value: value,
|
|
307
|
+
enumerable: true,
|
|
308
|
+
configurable: true,
|
|
309
|
+
writable: true
|
|
310
|
+
});
|
|
311
|
+
} else {
|
|
312
|
+
obj[key] = value;
|
|
313
|
+
}
|
|
314
|
+
return obj;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
//
|
|
318
|
+
// Define <Draggable>
|
|
319
|
+
//
|
|
320
|
+
var Draggable = /*#__PURE__*/function (_React$Component) {
|
|
321
|
+
_inherits(Draggable, _React$Component);
|
|
322
|
+
var _super = _createSuper(Draggable);
|
|
323
|
+
_createClass(Draggable, null, [{
|
|
324
|
+
key: "getDerivedStateFromProps",
|
|
325
|
+
// React 16.3+
|
|
326
|
+
// Arity (props, state)
|
|
327
|
+
value: function getDerivedStateFromProps(_ref, _ref2) {
|
|
328
|
+
var position = _ref.position;
|
|
329
|
+
var prevPropsPosition = _ref2.prevPropsPosition;
|
|
330
|
+
|
|
331
|
+
// Set x/y if a new position is provided in props that is different than the previous.
|
|
332
|
+
if (position && (!prevPropsPosition || position.x !== prevPropsPosition.x || position.y !== prevPropsPosition.y)) {
|
|
333
|
+
(0, _log["default"])('Draggable: getDerivedStateFromProps %j', {
|
|
334
|
+
position: position,
|
|
335
|
+
prevPropsPosition: prevPropsPosition
|
|
336
|
+
});
|
|
337
|
+
return {
|
|
338
|
+
x: position.x,
|
|
339
|
+
y: position.y,
|
|
340
|
+
prevPropsPosition: _objectSpread({}, position)
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
}]);
|
|
346
|
+
function Draggable(props
|
|
347
|
+
/*: DraggableProps*/) {
|
|
348
|
+
var _this;
|
|
349
|
+
_classCallCheck(this, Draggable);
|
|
350
|
+
_this = _super.call(this, props);
|
|
351
|
+
_defineProperty(_assertThisInitialized(_this), "onDragStart", function (e, coreData) {
|
|
352
|
+
(0, _log["default"])('Draggable: onDragStart: %j', coreData); // Short-circuit if user's callback killed it.
|
|
353
|
+
|
|
354
|
+
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.
|
|
355
|
+
|
|
356
|
+
if (shouldStart === false) return false;
|
|
357
|
+
_this.setState({
|
|
358
|
+
dragging: true,
|
|
359
|
+
dragged: true
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
_defineProperty(_assertThisInitialized(_this), "onDrag", function (e, coreData) {
|
|
363
|
+
if (!_this.state.dragging) return false;
|
|
364
|
+
(0, _log["default"])('Draggable: onDrag: %j', coreData);
|
|
365
|
+
var uiData = (0, _positionFns.createDraggableData)(_assertThisInitialized(_this), coreData);
|
|
366
|
+
var newState
|
|
367
|
+
/*: $Shape<DraggableState>*/ = {
|
|
368
|
+
x: uiData.x,
|
|
369
|
+
y: uiData.y
|
|
370
|
+
}; // Keep within bounds.
|
|
371
|
+
|
|
372
|
+
if (_this.props.bounds) {
|
|
373
|
+
// Save original x and y.
|
|
374
|
+
var x = newState.x,
|
|
375
|
+
y = newState.y; // Add slack to the values used to calculate bound position. This will ensure that if
|
|
376
|
+
// we start removing slack, the element won't react to it right away until it's been
|
|
377
|
+
// completely removed.
|
|
378
|
+
|
|
379
|
+
newState.x += _this.state.slackX;
|
|
380
|
+
newState.y += _this.state.slackY; // Get bound position. This will ceil/floor the x and y within the boundaries.
|
|
381
|
+
|
|
382
|
+
var _getBoundPosition = (0, _positionFns.getBoundPosition)(_assertThisInitialized(_this), newState.x, newState.y),
|
|
383
|
+
_getBoundPosition2 = _slicedToArray(_getBoundPosition, 2),
|
|
384
|
+
newStateX = _getBoundPosition2[0],
|
|
385
|
+
newStateY = _getBoundPosition2[1];
|
|
386
|
+
newState.x = newStateX;
|
|
387
|
+
newState.y = newStateY; // Recalculate slack by noting how much was shaved by the boundPosition handler.
|
|
388
|
+
|
|
389
|
+
newState.slackX = _this.state.slackX + (x - newState.x);
|
|
390
|
+
newState.slackY = _this.state.slackY + (y - newState.y); // Update the event we fire to reflect what really happened after bounds took effect.
|
|
391
|
+
|
|
392
|
+
uiData.x = newState.x;
|
|
393
|
+
uiData.y = newState.y;
|
|
394
|
+
uiData.deltaX = newState.x - _this.state.x;
|
|
395
|
+
uiData.deltaY = newState.y - _this.state.y;
|
|
396
|
+
} // Short-circuit if user's callback killed it.
|
|
397
|
+
|
|
398
|
+
var shouldUpdate = _this.props.onDrag(e, uiData);
|
|
399
|
+
if (shouldUpdate === false) return false;
|
|
400
|
+
_this.setState(newState);
|
|
401
|
+
});
|
|
402
|
+
_defineProperty(_assertThisInitialized(_this), "onDragStop", function (e, coreData) {
|
|
403
|
+
if (!_this.state.dragging) return false; // Short-circuit if user's callback killed it.
|
|
404
|
+
|
|
405
|
+
var shouldContinue = _this.props.onStop(e, (0, _positionFns.createDraggableData)(_assertThisInitialized(_this), coreData));
|
|
406
|
+
if (shouldContinue === false) return false;
|
|
407
|
+
(0, _log["default"])('Draggable: onDragStop: %j', coreData);
|
|
408
|
+
var newState
|
|
409
|
+
/*: $Shape<DraggableState>*/ = {
|
|
410
|
+
dragging: false,
|
|
411
|
+
slackX: 0,
|
|
412
|
+
slackY: 0
|
|
413
|
+
}; // If this is a controlled component, the result of this operation will be to
|
|
414
|
+
// revert back to the old position. We expect a handler on `onDragStop`, at the least.
|
|
415
|
+
|
|
416
|
+
var controlled = Boolean(_this.props.position);
|
|
417
|
+
if (controlled) {
|
|
418
|
+
var _this$props$position = _this.props.position,
|
|
419
|
+
x = _this$props$position.x,
|
|
420
|
+
y = _this$props$position.y;
|
|
421
|
+
newState.x = x;
|
|
422
|
+
newState.y = y;
|
|
423
|
+
}
|
|
424
|
+
_this.setState(newState);
|
|
425
|
+
});
|
|
426
|
+
_this.state = {
|
|
427
|
+
// Whether or not we are currently dragging.
|
|
428
|
+
dragging: false,
|
|
429
|
+
// Whether or not we have been dragged before.
|
|
430
|
+
dragged: false,
|
|
431
|
+
// Current transform x and y.
|
|
432
|
+
x: props.position ? props.position.x : props.defaultPosition.x,
|
|
433
|
+
y: props.position ? props.position.y : props.defaultPosition.y,
|
|
434
|
+
prevPropsPosition: _objectSpread({}, props.position),
|
|
435
|
+
// Used for compensating for out-of-bounds drags
|
|
436
|
+
slackX: 0,
|
|
437
|
+
slackY: 0,
|
|
438
|
+
// Can only determine if SVG after mounting
|
|
439
|
+
isElementSVG: false
|
|
440
|
+
};
|
|
441
|
+
if (props.position && !(props.onDrag || props.onStop)) {
|
|
442
|
+
// eslint-disable-next-line no-console
|
|
443
|
+
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.');
|
|
444
|
+
}
|
|
445
|
+
return _this;
|
|
446
|
+
}
|
|
447
|
+
_createClass(Draggable, [{
|
|
448
|
+
key: "componentDidMount",
|
|
449
|
+
value: function componentDidMount() {
|
|
450
|
+
// Check to see if the element passed is an instanceof SVGElement
|
|
451
|
+
if (typeof window.SVGElement !== 'undefined' && this.findDOMNode() instanceof window.SVGElement) {
|
|
452
|
+
this.setState({
|
|
453
|
+
isElementSVG: true
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}, {
|
|
458
|
+
key: "componentWillUnmount",
|
|
459
|
+
value: function componentWillUnmount() {
|
|
460
|
+
this.setState({
|
|
461
|
+
dragging: false
|
|
462
|
+
}); // prevents invariant if unmounted while dragging
|
|
463
|
+
} // React Strict Mode compatibility: if `nodeRef` is passed, we will use it instead of trying to find
|
|
464
|
+
// the underlying DOM node ourselves. See the README for more information.
|
|
465
|
+
}, {
|
|
466
|
+
key: "findDOMNode",
|
|
467
|
+
value: function findDOMNode() /*: ?HTMLElement*/
|
|
468
|
+
{
|
|
469
|
+
return this.props.nodeRef ? this.props.nodeRef.current : _reactDom["default"].findDOMNode(this);
|
|
470
|
+
}
|
|
471
|
+
}, {
|
|
472
|
+
key: "render",
|
|
473
|
+
value: function render() /*: ReactElement<any>*/
|
|
474
|
+
{
|
|
475
|
+
var _classNames;
|
|
476
|
+
var _this$props = this.props,
|
|
477
|
+
children = _this$props.children,
|
|
478
|
+
defaultPosition = _this$props.defaultPosition,
|
|
479
|
+
defaultClassName = _this$props.defaultClassName,
|
|
480
|
+
defaultClassNameDragging = _this$props.defaultClassNameDragging,
|
|
481
|
+
defaultClassNameDragged = _this$props.defaultClassNameDragged,
|
|
482
|
+
position = _this$props.position,
|
|
483
|
+
positionOffset = _this$props.positionOffset,
|
|
484
|
+
draggableCoreProps = _objectWithoutProperties(_this$props, ["axis", "bounds", "children", "defaultPosition", "defaultClassName", "defaultClassNameDragging", "defaultClassNameDragged", "position", "positionOffset", "scale"]);
|
|
485
|
+
var style = {};
|
|
486
|
+
var svgTransform = null; // If this is controlled, we don't want to move it - unless it's dragging.
|
|
487
|
+
|
|
488
|
+
var controlled = Boolean(position);
|
|
489
|
+
var draggable = !controlled || this.state.dragging;
|
|
490
|
+
var validPosition = position || defaultPosition;
|
|
491
|
+
var transformOpts = {
|
|
492
|
+
// Set left if horizontal drag is enabled
|
|
493
|
+
x: (0, _positionFns.canDragX)(this) && draggable ? this.state.x : validPosition.x,
|
|
494
|
+
// Set top if vertical drag is enabled
|
|
495
|
+
y: (0, _positionFns.canDragY)(this) && draggable ? this.state.y : validPosition.y
|
|
496
|
+
}; // If this element was SVG, we use the `transform` attribute.
|
|
497
|
+
|
|
498
|
+
if (this.state.isElementSVG) {
|
|
499
|
+
svgTransform = (0, _domFns.createSVGTransform)(transformOpts, positionOffset);
|
|
500
|
+
} else {
|
|
501
|
+
// Add a CSS transform to move the element around. This allows us to move the element around
|
|
502
|
+
// without worrying about whether or not it is relatively or absolutely positioned.
|
|
503
|
+
// If the item you are dragging already has a transform set, wrap it in a <span> so <Draggable>
|
|
504
|
+
// has a clean slate.
|
|
505
|
+
style = (0, _domFns.createCSSTransform)(transformOpts, positionOffset);
|
|
506
|
+
} // Mark with class while dragging
|
|
507
|
+
|
|
508
|
+
var className = (0, _classnames["default"])(children.props.className || '', defaultClassName, (_classNames = {}, _defineProperty(_classNames, defaultClassNameDragging, this.state.dragging), _defineProperty(_classNames, defaultClassNameDragged, this.state.dragged), _classNames)); // Reuse the child provided
|
|
509
|
+
// This makes it flexible to use whatever element is wanted (div, ul, etc)
|
|
510
|
+
|
|
511
|
+
return /*#__PURE__*/React$1.createElement(_DraggableCore["default"], _extends({}, draggableCoreProps, {
|
|
512
|
+
onStart: this.onDragStart,
|
|
513
|
+
onDrag: this.onDrag,
|
|
514
|
+
onStop: this.onDragStop
|
|
515
|
+
}), React$1.cloneElement(React$1.Children.only(children), {
|
|
516
|
+
className: className,
|
|
517
|
+
style: _objectSpread(_objectSpread({}, children.props.style), style),
|
|
518
|
+
transform: svgTransform
|
|
519
|
+
}));
|
|
520
|
+
}
|
|
521
|
+
}]);
|
|
522
|
+
return Draggable;
|
|
523
|
+
}(React$1.Component);
|
|
524
|
+
exports["default"] = Draggable;
|
|
525
|
+
_defineProperty(Draggable, "displayName", 'Draggable');
|
|
526
|
+
_defineProperty(Draggable, "propTypes", _objectSpread(_objectSpread({}, _DraggableCore["default"].propTypes), {}, {
|
|
527
|
+
/**
|
|
528
|
+
* `axis` determines which axis the draggable can move.
|
|
529
|
+
*
|
|
530
|
+
* Note that all callbacks will still return data as normal. This only
|
|
531
|
+
* controls flushing to the DOM.
|
|
532
|
+
*
|
|
533
|
+
* 'both' allows movement horizontally and vertically.
|
|
534
|
+
* 'x' limits movement to horizontal axis.
|
|
535
|
+
* 'y' limits movement to vertical axis.
|
|
536
|
+
* 'none' limits all movement.
|
|
537
|
+
*
|
|
538
|
+
* Defaults to 'both'.
|
|
539
|
+
*/
|
|
540
|
+
axis: _propTypes["default"].oneOf(['both', 'x', 'y', 'none']),
|
|
541
|
+
/**
|
|
542
|
+
* `bounds` determines the range of movement available to the element.
|
|
543
|
+
* Available values are:
|
|
544
|
+
*
|
|
545
|
+
* 'parent' restricts movement within the Draggable's parent node.
|
|
546
|
+
*
|
|
547
|
+
* Alternatively, pass an object with the following properties, all of which are optional:
|
|
548
|
+
*
|
|
549
|
+
* {left: LEFT_BOUND, right: RIGHT_BOUND, bottom: BOTTOM_BOUND, top: TOP_BOUND}
|
|
550
|
+
*
|
|
551
|
+
* All values are in px.
|
|
552
|
+
*
|
|
553
|
+
* Example:
|
|
554
|
+
*
|
|
555
|
+
* ```jsx
|
|
556
|
+
* let App = React.createClass({
|
|
557
|
+
* render: function () {
|
|
558
|
+
* return (
|
|
559
|
+
* <Draggable bounds={{right: 300, bottom: 300}}>
|
|
560
|
+
* <div>Content</div>
|
|
561
|
+
* </Draggable>
|
|
562
|
+
* );
|
|
563
|
+
* }
|
|
564
|
+
* });
|
|
565
|
+
* ```
|
|
566
|
+
*/
|
|
567
|
+
bounds: _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
568
|
+
left: _propTypes["default"].number,
|
|
569
|
+
right: _propTypes["default"].number,
|
|
570
|
+
top: _propTypes["default"].number,
|
|
571
|
+
bottom: _propTypes["default"].number
|
|
572
|
+
}), _propTypes["default"].string, _propTypes["default"].oneOf([false])]),
|
|
573
|
+
defaultClassName: _propTypes["default"].string,
|
|
574
|
+
defaultClassNameDragging: _propTypes["default"].string,
|
|
575
|
+
defaultClassNameDragged: _propTypes["default"].string,
|
|
576
|
+
/**
|
|
577
|
+
* `defaultPosition` specifies the x and y that the dragged item should start at
|
|
578
|
+
*
|
|
579
|
+
* Example:
|
|
580
|
+
*
|
|
581
|
+
* ```jsx
|
|
582
|
+
* let App = React.createClass({
|
|
583
|
+
* render: function () {
|
|
584
|
+
* return (
|
|
585
|
+
* <Draggable defaultPosition={{x: 25, y: 25}}>
|
|
586
|
+
* <div>I start with transformX: 25px and transformY: 25px;</div>
|
|
587
|
+
* </Draggable>
|
|
588
|
+
* );
|
|
589
|
+
* }
|
|
590
|
+
* });
|
|
591
|
+
* ```
|
|
592
|
+
*/
|
|
593
|
+
defaultPosition: _propTypes["default"].shape({
|
|
594
|
+
x: _propTypes["default"].number,
|
|
595
|
+
y: _propTypes["default"].number
|
|
596
|
+
}),
|
|
597
|
+
positionOffset: _propTypes["default"].shape({
|
|
598
|
+
x: _propTypes["default"].oneOfType([_propTypes["default"].number, _propTypes["default"].string]),
|
|
599
|
+
y: _propTypes["default"].oneOfType([_propTypes["default"].number, _propTypes["default"].string])
|
|
600
|
+
}),
|
|
601
|
+
/**
|
|
602
|
+
* `position`, if present, defines the current position of the element.
|
|
603
|
+
*
|
|
604
|
+
* This is similar to how form elements in React work - if no `position` is supplied, the component
|
|
605
|
+
* is uncontrolled.
|
|
606
|
+
*
|
|
607
|
+
* Example:
|
|
608
|
+
*
|
|
609
|
+
* ```jsx
|
|
610
|
+
* let App = React.createClass({
|
|
611
|
+
* render: function () {
|
|
612
|
+
* return (
|
|
613
|
+
* <Draggable position={{x: 25, y: 25}}>
|
|
614
|
+
* <div>I start with transformX: 25px and transformY: 25px;</div>
|
|
615
|
+
* </Draggable>
|
|
616
|
+
* );
|
|
617
|
+
* }
|
|
618
|
+
* });
|
|
619
|
+
* ```
|
|
620
|
+
*/
|
|
621
|
+
position: _propTypes["default"].shape({
|
|
622
|
+
x: _propTypes["default"].number,
|
|
623
|
+
y: _propTypes["default"].number
|
|
624
|
+
}),
|
|
625
|
+
/**
|
|
626
|
+
* These properties should be defined on the child, not here.
|
|
627
|
+
*/
|
|
628
|
+
className: _shims.dontSetMe,
|
|
629
|
+
style: _shims.dontSetMe,
|
|
630
|
+
transform: _shims.dontSetMe
|
|
631
|
+
}));
|
|
632
|
+
_defineProperty(Draggable, "defaultProps", _objectSpread(_objectSpread({}, _DraggableCore["default"].defaultProps), {}, {
|
|
633
|
+
axis: 'both',
|
|
634
|
+
bounds: false,
|
|
635
|
+
defaultClassName: 'react-draggable',
|
|
636
|
+
defaultClassNameDragging: 'react-draggable-dragging',
|
|
637
|
+
defaultClassNameDragged: 'react-draggable-dragged',
|
|
638
|
+
defaultPosition: {
|
|
639
|
+
x: 0,
|
|
640
|
+
y: 0
|
|
641
|
+
},
|
|
642
|
+
position: null,
|
|
643
|
+
scale: 1
|
|
644
|
+
}));
|
|
645
|
+
})(Draggable);
|