@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.
Files changed (105) hide show
  1. package/README.md +11 -0
  2. package/lib/cjs/Content.js +48 -0
  3. package/lib/cjs/Layout.js +48 -0
  4. package/lib/cjs/SearchTrigger.js +55 -0
  5. package/lib/cjs/Sider.js +100 -0
  6. package/lib/cjs/_virtual/Draggable.js +16 -0
  7. package/lib/cjs/_virtual/DraggableCore.js +16 -0
  8. package/lib/cjs/_virtual/Resizable.js +16 -0
  9. package/lib/cjs/_virtual/ResizableBox.js +16 -0
  10. package/lib/cjs/_virtual/cjs.js +18 -0
  11. package/lib/cjs/_virtual/domFns.js +16 -0
  12. package/lib/cjs/_virtual/getPrefix.js +16 -0
  13. package/lib/cjs/_virtual/index.js +18 -0
  14. package/lib/cjs/_virtual/index2.js +18 -0
  15. package/lib/cjs/_virtual/index3.js +18 -0
  16. package/lib/cjs/_virtual/index4.js +18 -0
  17. package/lib/cjs/_virtual/log.js +16 -0
  18. package/lib/cjs/_virtual/positionFns.js +16 -0
  19. package/lib/cjs/_virtual/propTypes.js +16 -0
  20. package/lib/cjs/_virtual/react-is.development.js +16 -0
  21. package/lib/cjs/_virtual/react-is.production.min.js +16 -0
  22. package/lib/cjs/_virtual/shims.js +16 -0
  23. package/lib/cjs/_virtual/utils.js +16 -0
  24. package/lib/cjs/index.js +24 -0
  25. package/lib/cjs/node_modules/classnames/index.js +62 -0
  26. package/lib/cjs/node_modules/object-assign/index.js +94 -0
  27. package/lib/cjs/node_modules/prop-types/checkPropTypes.js +101 -0
  28. package/lib/cjs/node_modules/prop-types/factoryWithThrowingShims.js +68 -0
  29. package/lib/cjs/node_modules/prop-types/factoryWithTypeCheckers.js +553 -0
  30. package/lib/cjs/node_modules/prop-types/index.js +36 -0
  31. package/lib/cjs/node_modules/prop-types/lib/ReactPropTypesSecret.js +25 -0
  32. package/lib/cjs/node_modules/react-draggable/build/cjs/Draggable.js +655 -0
  33. package/lib/cjs/node_modules/react-draggable/build/cjs/DraggableCore.js +670 -0
  34. package/lib/cjs/node_modules/react-draggable/build/cjs/cjs.js +23 -0
  35. package/lib/cjs/node_modules/react-draggable/build/cjs/utils/domFns.js +366 -0
  36. package/lib/cjs/node_modules/react-draggable/build/cjs/utils/getPrefix.js +69 -0
  37. package/lib/cjs/node_modules/react-draggable/build/cjs/utils/log.js +19 -0
  38. package/lib/cjs/node_modules/react-draggable/build/cjs/utils/positionFns.js +176 -0
  39. package/lib/cjs/node_modules/react-draggable/build/cjs/utils/shims.js +57 -0
  40. package/lib/cjs/node_modules/react-is/cjs/react-is.development.js +182 -0
  41. package/lib/cjs/node_modules/react-is/cjs/react-is.production.min.js +132 -0
  42. package/lib/cjs/node_modules/react-is/index.js +21 -0
  43. package/lib/cjs/node_modules/react-resizable/build/Resizable.js +366 -0
  44. package/lib/cjs/node_modules/react-resizable/build/ResizableBox.js +244 -0
  45. package/lib/cjs/node_modules/react-resizable/build/propTypes.js +115 -0
  46. package/lib/cjs/node_modules/react-resizable/build/utils.js +86 -0
  47. package/lib/cjs/node_modules/react-resizable/index.js +25 -0
  48. package/lib/cjs/packages/icons/lib/esm/components/common/search-outlined.js +65 -0
  49. package/lib/cjs/packages/icons/lib/esm/styles/index.scss.js +35 -0
  50. package/lib/cjs/styles/index.scss.js +18 -0
  51. package/lib/esm/Content.js +36 -0
  52. package/lib/esm/Layout.js +36 -0
  53. package/lib/esm/SearchTrigger.js +43 -0
  54. package/lib/esm/Sider.js +88 -0
  55. package/lib/esm/_virtual/Draggable.js +11 -0
  56. package/lib/esm/_virtual/DraggableCore.js +11 -0
  57. package/lib/esm/_virtual/Resizable.js +11 -0
  58. package/lib/esm/_virtual/ResizableBox.js +11 -0
  59. package/lib/esm/_virtual/cjs.js +13 -0
  60. package/lib/esm/_virtual/domFns.js +11 -0
  61. package/lib/esm/_virtual/getPrefix.js +11 -0
  62. package/lib/esm/_virtual/index.js +13 -0
  63. package/lib/esm/_virtual/index2.js +13 -0
  64. package/lib/esm/_virtual/index3.js +13 -0
  65. package/lib/esm/_virtual/index4.js +13 -0
  66. package/lib/esm/_virtual/log.js +11 -0
  67. package/lib/esm/_virtual/positionFns.js +11 -0
  68. package/lib/esm/_virtual/propTypes.js +11 -0
  69. package/lib/esm/_virtual/react-is.development.js +11 -0
  70. package/lib/esm/_virtual/react-is.production.min.js +11 -0
  71. package/lib/esm/_virtual/shims.js +11 -0
  72. package/lib/esm/_virtual/utils.js +11 -0
  73. package/lib/esm/index.js +14 -0
  74. package/lib/esm/node_modules/classnames/index.js +60 -0
  75. package/lib/esm/node_modules/object-assign/index.js +88 -0
  76. package/lib/esm/node_modules/prop-types/checkPropTypes.js +96 -0
  77. package/lib/esm/node_modules/prop-types/factoryWithThrowingShims.js +63 -0
  78. package/lib/esm/node_modules/prop-types/factoryWithTypeCheckers.js +548 -0
  79. package/lib/esm/node_modules/prop-types/index.js +34 -0
  80. package/lib/esm/node_modules/prop-types/lib/ReactPropTypesSecret.js +19 -0
  81. package/lib/esm/node_modules/react-draggable/build/cjs/Draggable.js +645 -0
  82. package/lib/esm/node_modules/react-draggable/build/cjs/DraggableCore.js +660 -0
  83. package/lib/esm/node_modules/react-draggable/build/cjs/cjs.js +21 -0
  84. package/lib/esm/node_modules/react-draggable/build/cjs/utils/domFns.js +361 -0
  85. package/lib/esm/node_modules/react-draggable/build/cjs/utils/getPrefix.js +67 -0
  86. package/lib/esm/node_modules/react-draggable/build/cjs/utils/log.js +17 -0
  87. package/lib/esm/node_modules/react-draggable/build/cjs/utils/positionFns.js +171 -0
  88. package/lib/esm/node_modules/react-draggable/build/cjs/utils/shims.js +52 -0
  89. package/lib/esm/node_modules/react-is/cjs/react-is.development.js +177 -0
  90. package/lib/esm/node_modules/react-is/cjs/react-is.production.min.js +127 -0
  91. package/lib/esm/node_modules/react-is/index.js +19 -0
  92. package/lib/esm/node_modules/react-resizable/build/Resizable.js +358 -0
  93. package/lib/esm/node_modules/react-resizable/build/ResizableBox.js +236 -0
  94. package/lib/esm/node_modules/react-resizable/build/propTypes.js +110 -0
  95. package/lib/esm/node_modules/react-resizable/build/utils.js +74 -0
  96. package/lib/esm/node_modules/react-resizable/index.js +20 -0
  97. package/lib/esm/packages/icons/lib/esm/components/common/search-outlined.js +53 -0
  98. package/lib/esm/packages/icons/lib/esm/styles/index.scss.js +23 -0
  99. package/lib/esm/styles/index.scss.js +13 -0
  100. package/lib/types/Content.d.ts +8 -0
  101. package/lib/types/Layout.d.ts +8 -0
  102. package/lib/types/SearchTrigger.d.ts +10 -0
  103. package/lib/types/Sider.d.ts +10 -0
  104. package/lib/types/index.d.ts +6 -0
  105. package/package.json +61 -0
@@ -0,0 +1,366 @@
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
+ 'use strict';
11
+
12
+ Object.defineProperty(exports, '__esModule', {
13
+ value: true
14
+ });
15
+ var domFns = require('../../../../../_virtual/domFns.js');
16
+ require('./shims.js');
17
+ require('./getPrefix.js');
18
+ var shims = require('../../../../../_virtual/shims.js');
19
+ var getPrefix = require('../../../../../_virtual/getPrefix.js');
20
+ function _typeof(obj) {
21
+ "@babel/helpers - typeof";
22
+
23
+ if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
24
+ _typeof = function _typeof(obj) {
25
+ return typeof obj;
26
+ };
27
+ } else {
28
+ _typeof = function _typeof(obj) {
29
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
30
+ };
31
+ }
32
+ return _typeof(obj);
33
+ }
34
+ Object.defineProperty(domFns.__exports, "__esModule", {
35
+ value: true
36
+ });
37
+ domFns.__exports.matchesSelector = matchesSelector;
38
+ domFns.__exports.matchesSelectorAndParentsTo = matchesSelectorAndParentsTo;
39
+ domFns.__exports.addEvent = addEvent;
40
+ domFns.__exports.removeEvent = removeEvent;
41
+ domFns.__exports.outerHeight = outerHeight;
42
+ domFns.__exports.outerWidth = outerWidth;
43
+ domFns.__exports.innerHeight = innerHeight;
44
+ domFns.__exports.innerWidth = innerWidth;
45
+ domFns.__exports.offsetXYFromParent = offsetXYFromParent;
46
+ domFns.__exports.createCSSTransform = createCSSTransform;
47
+ domFns.__exports.createSVGTransform = createSVGTransform;
48
+ domFns.__exports.getTranslation = getTranslation;
49
+ domFns.__exports.getTouch = getTouch;
50
+ domFns.__exports.getTouchIdentifier = getTouchIdentifier;
51
+ domFns.__exports.addUserSelectStyles = addUserSelectStyles;
52
+ domFns.__exports.removeUserSelectStyles = removeUserSelectStyles;
53
+ domFns.__exports.addClassName = addClassName;
54
+ domFns.__exports.removeClassName = removeClassName;
55
+ var _shims = shims.__exports;
56
+ var _getPrefix = _interopRequireWildcard(getPrefix.__exports);
57
+ function _getRequireWildcardCache() {
58
+ if (typeof WeakMap !== "function") return null;
59
+ var cache = new WeakMap();
60
+ _getRequireWildcardCache = function _getRequireWildcardCache() {
61
+ return cache;
62
+ };
63
+ return cache;
64
+ }
65
+ function _interopRequireWildcard(obj) {
66
+ if (obj && obj.__esModule) {
67
+ return obj;
68
+ }
69
+ if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
70
+ return {
71
+ "default": obj
72
+ };
73
+ }
74
+ var cache = _getRequireWildcardCache();
75
+ if (cache && cache.has(obj)) {
76
+ return cache.get(obj);
77
+ }
78
+ var newObj = {};
79
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
80
+ for (var key in obj) {
81
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
82
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
83
+ if (desc && (desc.get || desc.set)) {
84
+ Object.defineProperty(newObj, key, desc);
85
+ } else {
86
+ newObj[key] = obj[key];
87
+ }
88
+ }
89
+ }
90
+ newObj["default"] = obj;
91
+ if (cache) {
92
+ cache.set(obj, newObj);
93
+ }
94
+ return newObj;
95
+ }
96
+ function ownKeys(object, enumerableOnly) {
97
+ var keys = Object.keys(object);
98
+ if (Object.getOwnPropertySymbols) {
99
+ var symbols = Object.getOwnPropertySymbols(object);
100
+ if (enumerableOnly) symbols = symbols.filter(function (sym) {
101
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
102
+ });
103
+ keys.push.apply(keys, symbols);
104
+ }
105
+ return keys;
106
+ }
107
+ function _objectSpread(target) {
108
+ for (var i = 1; i < arguments.length; i++) {
109
+ var source = arguments[i] != null ? arguments[i] : {};
110
+ if (i % 2) {
111
+ ownKeys(Object(source), true).forEach(function (key) {
112
+ _defineProperty(target, key, source[key]);
113
+ });
114
+ } else if (Object.getOwnPropertyDescriptors) {
115
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
116
+ } else {
117
+ ownKeys(Object(source)).forEach(function (key) {
118
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
119
+ });
120
+ }
121
+ }
122
+ return target;
123
+ }
124
+ function _defineProperty(obj, key, value) {
125
+ if (key in obj) {
126
+ Object.defineProperty(obj, key, {
127
+ value: value,
128
+ enumerable: true,
129
+ configurable: true,
130
+ writable: true
131
+ });
132
+ } else {
133
+ obj[key] = value;
134
+ }
135
+ return obj;
136
+ }
137
+ var matchesSelectorFunc = '';
138
+ function matchesSelector(el
139
+ /*: Node*/, selector
140
+ /*: string*/) /*: boolean*/
141
+ {
142
+ if (!matchesSelectorFunc) {
143
+ matchesSelectorFunc = (0, _shims.findInArray)(['matches', 'webkitMatchesSelector', 'mozMatchesSelector', 'msMatchesSelector', 'oMatchesSelector'], function (method) {
144
+ // $FlowIgnore: Doesn't think elements are indexable
145
+ return (0, _shims.isFunction)(el[method]);
146
+ });
147
+ } // Might not be found entirely (not an Element?) - in that case, bail
148
+ // $FlowIgnore: Doesn't think elements are indexable
149
+
150
+ if (!(0, _shims.isFunction)(el[matchesSelectorFunc])) return false; // $FlowIgnore: Doesn't think elements are indexable
151
+
152
+ return el[matchesSelectorFunc](selector);
153
+ } // Works up the tree to the draggable itself attempting to match selector.
154
+
155
+ function matchesSelectorAndParentsTo(el
156
+ /*: Node*/, selector
157
+ /*: string*/, baseNode
158
+ /*: Node*/) /*: boolean*/
159
+ {
160
+ var node = el;
161
+ do {
162
+ if (matchesSelector(node, selector)) return true;
163
+ if (node === baseNode) return false;
164
+ node = node.parentNode;
165
+ } while (node);
166
+ return false;
167
+ }
168
+ function addEvent(el
169
+ /*: ?Node*/, event
170
+ /*: string*/, handler
171
+ /*: Function*/, inputOptions
172
+ /*: Object*/) /*: void*/
173
+ {
174
+ if (!el) return;
175
+ var options = _objectSpread({
176
+ capture: true
177
+ }, inputOptions);
178
+ if (el.addEventListener) {
179
+ el.addEventListener(event, handler, options);
180
+ } else if (el.attachEvent) {
181
+ el.attachEvent('on' + event, handler);
182
+ } else {
183
+ // $FlowIgnore: Doesn't think elements are indexable
184
+ el['on' + event] = handler;
185
+ }
186
+ }
187
+ function removeEvent(el
188
+ /*: ?Node*/, event
189
+ /*: string*/, handler
190
+ /*: Function*/, inputOptions
191
+ /*: Object*/) /*: void*/
192
+ {
193
+ if (!el) return;
194
+ var options = _objectSpread({
195
+ capture: true
196
+ }, inputOptions);
197
+ if (el.removeEventListener) {
198
+ el.removeEventListener(event, handler, options);
199
+ } else if (el.detachEvent) {
200
+ el.detachEvent('on' + event, handler);
201
+ } else {
202
+ // $FlowIgnore: Doesn't think elements are indexable
203
+ el['on' + event] = null;
204
+ }
205
+ }
206
+ function outerHeight(node
207
+ /*: HTMLElement*/) /*: number*/
208
+ {
209
+ // This is deliberately excluding margin for our calculations, since we are using
210
+ // offsetTop which is including margin. See getBoundPosition
211
+ var height = node.clientHeight;
212
+ var computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
213
+ height += (0, _shims["int"])(computedStyle.borderTopWidth);
214
+ height += (0, _shims["int"])(computedStyle.borderBottomWidth);
215
+ return height;
216
+ }
217
+ function outerWidth(node
218
+ /*: HTMLElement*/) /*: number*/
219
+ {
220
+ // This is deliberately excluding margin for our calculations, since we are using
221
+ // offsetLeft which is including margin. See getBoundPosition
222
+ var width = node.clientWidth;
223
+ var computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
224
+ width += (0, _shims["int"])(computedStyle.borderLeftWidth);
225
+ width += (0, _shims["int"])(computedStyle.borderRightWidth);
226
+ return width;
227
+ }
228
+ function innerHeight(node
229
+ /*: HTMLElement*/) /*: number*/
230
+ {
231
+ var height = node.clientHeight;
232
+ var computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
233
+ height -= (0, _shims["int"])(computedStyle.paddingTop);
234
+ height -= (0, _shims["int"])(computedStyle.paddingBottom);
235
+ return height;
236
+ }
237
+ function innerWidth(node
238
+ /*: HTMLElement*/) /*: number*/
239
+ {
240
+ var width = node.clientWidth;
241
+ var computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
242
+ width -= (0, _shims["int"])(computedStyle.paddingLeft);
243
+ width -= (0, _shims["int"])(computedStyle.paddingRight);
244
+ return width;
245
+ } // Get from offsetParent
246
+
247
+ function offsetXYFromParent(evt
248
+ /*: {clientX: number, clientY: number}*/, offsetParent
249
+ /*: HTMLElement*/, scale
250
+ /*: number*/) /*: ControlPosition*/
251
+ {
252
+ var isBody = offsetParent === offsetParent.ownerDocument.body;
253
+ var offsetParentRect = isBody ? {
254
+ left: 0,
255
+ top: 0
256
+ } : offsetParent.getBoundingClientRect();
257
+ var x = (evt.clientX + offsetParent.scrollLeft - offsetParentRect.left) / scale;
258
+ var y = (evt.clientY + offsetParent.scrollTop - offsetParentRect.top) / scale;
259
+ return {
260
+ x: x,
261
+ y: y
262
+ };
263
+ }
264
+ function createCSSTransform(controlPos
265
+ /*: ControlPosition*/, positionOffset
266
+ /*: PositionOffsetControlPosition*/) /*: Object*/
267
+ {
268
+ var translation = getTranslation(controlPos, positionOffset, 'px');
269
+ return _defineProperty({}, (0, _getPrefix.browserPrefixToKey)('transform', _getPrefix["default"]), translation);
270
+ }
271
+ function createSVGTransform(controlPos
272
+ /*: ControlPosition*/, positionOffset
273
+ /*: PositionOffsetControlPosition*/) /*: string*/
274
+ {
275
+ var translation = getTranslation(controlPos, positionOffset, '');
276
+ return translation;
277
+ }
278
+ function getTranslation(_ref2, positionOffset
279
+ /*: PositionOffsetControlPosition*/, unitSuffix
280
+ /*: string*/) /*: string*/
281
+ {
282
+ var x = _ref2.x,
283
+ y = _ref2.y;
284
+ var translation = "translate(".concat(x).concat(unitSuffix, ",").concat(y).concat(unitSuffix, ")");
285
+ if (positionOffset) {
286
+ var defaultX = "".concat(typeof positionOffset.x === 'string' ? positionOffset.x : positionOffset.x + unitSuffix);
287
+ var defaultY = "".concat(typeof positionOffset.y === 'string' ? positionOffset.y : positionOffset.y + unitSuffix);
288
+ translation = "translate(".concat(defaultX, ", ").concat(defaultY, ")") + translation;
289
+ }
290
+ return translation;
291
+ }
292
+ function getTouch(e
293
+ /*: MouseTouchEvent*/, identifier
294
+ /*: number*/) /*: ?{clientX: number, clientY: number}*/
295
+ {
296
+ return e.targetTouches && (0, _shims.findInArray)(e.targetTouches, function (t) {
297
+ return identifier === t.identifier;
298
+ }) || e.changedTouches && (0, _shims.findInArray)(e.changedTouches, function (t) {
299
+ return identifier === t.identifier;
300
+ });
301
+ }
302
+ function getTouchIdentifier(e
303
+ /*: MouseTouchEvent*/) /*: ?number*/
304
+ {
305
+ if (e.targetTouches && e.targetTouches[0]) return e.targetTouches[0].identifier;
306
+ if (e.changedTouches && e.changedTouches[0]) return e.changedTouches[0].identifier;
307
+ } // User-select Hacks:
308
+ //
309
+ // Useful for preventing blue highlights all over everything when dragging.
310
+ // Note we're passing `document` b/c we could be iframed
311
+
312
+ function addUserSelectStyles(doc
313
+ /*: ?Document*/) {
314
+ if (!doc) return;
315
+ var styleEl = doc.getElementById('react-draggable-style-el');
316
+ if (!styleEl) {
317
+ styleEl = doc.createElement('style');
318
+ styleEl.type = 'text/css';
319
+ styleEl.id = 'react-draggable-style-el';
320
+ styleEl.innerHTML = '.react-draggable-transparent-selection *::-moz-selection {all: inherit;}\n';
321
+ styleEl.innerHTML += '.react-draggable-transparent-selection *::selection {all: inherit;}\n';
322
+ doc.getElementsByTagName('head')[0].appendChild(styleEl);
323
+ }
324
+ if (doc.body) addClassName(doc.body, 'react-draggable-transparent-selection');
325
+ }
326
+ function removeUserSelectStyles(doc
327
+ /*: ?Document*/) {
328
+ if (!doc) return;
329
+ try {
330
+ if (doc.body) removeClassName(doc.body, 'react-draggable-transparent-selection'); // $FlowIgnore: IE
331
+
332
+ if (doc.selection) {
333
+ // $FlowIgnore: IE
334
+ doc.selection.empty();
335
+ } else {
336
+ // Remove selection caused by scroll, unless it's a focused input
337
+ // (we use doc.defaultView in case we're in an iframe)
338
+ var selection = (doc.defaultView || window).getSelection();
339
+ if (selection && selection.type !== 'Caret') {
340
+ selection.removeAllRanges();
341
+ }
342
+ }
343
+ } catch (e) {// probably IE
344
+ }
345
+ }
346
+ function addClassName(el
347
+ /*: HTMLElement*/, className
348
+ /*: string*/) {
349
+ if (el.classList) {
350
+ el.classList.add(className);
351
+ } else {
352
+ if (!el.className.match(new RegExp("(?:^|\\s)".concat(className, "(?!\\S)")))) {
353
+ el.className += " ".concat(className);
354
+ }
355
+ }
356
+ }
357
+ function removeClassName(el
358
+ /*: HTMLElement*/, className
359
+ /*: string*/) {
360
+ if (el.classList) {
361
+ el.classList.remove(className);
362
+ } else {
363
+ el.className = el.className.replace(new RegExp("(?:^|\\s)".concat(className, "(?!\\S)"), 'g'), '');
364
+ }
365
+ }
366
+ exports["default"] = domFns.__exports;
@@ -0,0 +1,69 @@
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
+ 'use strict';
11
+
12
+ var getPrefix$1 = require('../../../../../_virtual/getPrefix.js');
13
+ Object.defineProperty(getPrefix$1.__exports, "__esModule", {
14
+ value: true
15
+ });
16
+ getPrefix$1.__exports.getPrefix = getPrefix;
17
+ getPrefix$1.__exports.browserPrefixToKey = browserPrefixToKey;
18
+ getPrefix$1.__exports.browserPrefixToStyle = browserPrefixToStyle;
19
+ getPrefix$1.__exports["default"] = void 0;
20
+ var prefixes = ['Moz', 'Webkit', 'O', 'ms'];
21
+ function getPrefix() /*: string*/
22
+ {
23
+ var prop
24
+ /*: string*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'transform';
25
+ // Checking specifically for 'window.document' is for pseudo-browser server-side
26
+ // environments that define 'window' as the global context.
27
+ // E.g. React-rails (see https://github.com/reactjs/react-rails/pull/84)
28
+ if (typeof window === 'undefined' || typeof window.document === 'undefined') return '';
29
+ var style = window.document.documentElement.style;
30
+ if (prop in style) return '';
31
+ for (var i = 0; i < prefixes.length; i++) {
32
+ if (browserPrefixToKey(prop, prefixes[i]) in style) return prefixes[i];
33
+ }
34
+ return '';
35
+ }
36
+ function browserPrefixToKey(prop
37
+ /*: string*/, prefix
38
+ /*: string*/) /*: string*/
39
+ {
40
+ return prefix ? "".concat(prefix).concat(kebabToTitleCase(prop)) : prop;
41
+ }
42
+ function browserPrefixToStyle(prop
43
+ /*: string*/, prefix
44
+ /*: string*/) /*: string*/
45
+ {
46
+ return prefix ? "-".concat(prefix.toLowerCase(), "-").concat(prop) : prop;
47
+ }
48
+ function kebabToTitleCase(str
49
+ /*: string*/) /*: string*/
50
+ {
51
+ var out = '';
52
+ var shouldCapitalize = true;
53
+ for (var i = 0; i < str.length; i++) {
54
+ if (shouldCapitalize) {
55
+ out += str[i].toUpperCase();
56
+ shouldCapitalize = false;
57
+ } else if (str[i] === '-') {
58
+ shouldCapitalize = true;
59
+ } else {
60
+ out += str[i];
61
+ }
62
+ }
63
+ return out;
64
+ } // Default export is the prefix itself, like 'Moz', 'Webkit', etc
65
+ // Note that you may have to re-test for certain things; for instance, Chrome 50
66
+ // can handle unprefixed `transform`, but not unprefixed `user-select`
67
+
68
+ var _default = getPrefix();
69
+ getPrefix$1.__exports["default"] = _default;
@@ -0,0 +1,19 @@
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
+ 'use strict';
11
+
12
+ var log$1 = require('../../../../../_virtual/log.js');
13
+ Object.defineProperty(log$1.__exports, "__esModule", {
14
+ value: true
15
+ });
16
+ log$1.__exports["default"] = log;
17
+
18
+ /*eslint no-console:0*/
19
+ function log() {}
@@ -0,0 +1,176 @@
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
+ 'use strict';
11
+
12
+ Object.defineProperty(exports, '__esModule', {
13
+ value: true
14
+ });
15
+ var positionFns = require('../../../../../_virtual/positionFns.js');
16
+ require('./shims.js');
17
+ require('./domFns.js');
18
+ var shims = require('../../../../../_virtual/shims.js');
19
+ var domFns = require('../../../../../_virtual/domFns.js');
20
+ Object.defineProperty(positionFns.__exports, "__esModule", {
21
+ value: true
22
+ });
23
+ positionFns.__exports.getBoundPosition = getBoundPosition;
24
+ positionFns.__exports.snapToGrid = snapToGrid;
25
+ positionFns.__exports.canDragX = canDragX;
26
+ positionFns.__exports.canDragY = canDragY;
27
+ positionFns.__exports.getControlPosition = getControlPosition;
28
+ positionFns.__exports.createCoreData = createCoreData;
29
+ positionFns.__exports.createDraggableData = createDraggableData;
30
+ var _shims = shims.__exports;
31
+ var _domFns = domFns.__exports;
32
+ function getBoundPosition(draggable
33
+ /*: Draggable*/, x
34
+ /*: number*/, y
35
+ /*: number*/) /*: [number, number]*/
36
+ {
37
+ // If no bounds, short-circuit and move on
38
+ if (!draggable.props.bounds) return [x, y]; // Clone new bounds
39
+
40
+ var bounds = draggable.props.bounds;
41
+ bounds = typeof bounds === 'string' ? bounds : cloneBounds(bounds);
42
+ var node = findDOMNode(draggable);
43
+ if (typeof bounds === 'string') {
44
+ var ownerDocument = node.ownerDocument;
45
+ var ownerWindow = ownerDocument.defaultView;
46
+ var boundNode;
47
+ if (bounds === 'parent') {
48
+ boundNode = node.parentNode;
49
+ } else {
50
+ boundNode = ownerDocument.querySelector(bounds);
51
+ }
52
+ if (!(boundNode instanceof ownerWindow.HTMLElement)) {
53
+ throw new Error('Bounds selector "' + bounds + '" could not find an element.');
54
+ }
55
+ var nodeStyle = ownerWindow.getComputedStyle(node);
56
+ var boundNodeStyle = ownerWindow.getComputedStyle(boundNode); // Compute bounds. This is a pain with padding and offsets but this gets it exactly right.
57
+
58
+ bounds = {
59
+ left: -node.offsetLeft + (0, _shims["int"])(boundNodeStyle.paddingLeft) + (0, _shims["int"])(nodeStyle.marginLeft),
60
+ top: -node.offsetTop + (0, _shims["int"])(boundNodeStyle.paddingTop) + (0, _shims["int"])(nodeStyle.marginTop),
61
+ right: (0, _domFns.innerWidth)(boundNode) - (0, _domFns.outerWidth)(node) - node.offsetLeft + (0, _shims["int"])(boundNodeStyle.paddingRight) - (0, _shims["int"])(nodeStyle.marginRight),
62
+ bottom: (0, _domFns.innerHeight)(boundNode) - (0, _domFns.outerHeight)(node) - node.offsetTop + (0, _shims["int"])(boundNodeStyle.paddingBottom) - (0, _shims["int"])(nodeStyle.marginBottom)
63
+ };
64
+ } // Keep x and y below right and bottom limits...
65
+
66
+ if ((0, _shims.isNum)(bounds.right)) x = Math.min(x, bounds.right);
67
+ if ((0, _shims.isNum)(bounds.bottom)) y = Math.min(y, bounds.bottom); // But above left and top limits.
68
+
69
+ if ((0, _shims.isNum)(bounds.left)) x = Math.max(x, bounds.left);
70
+ if ((0, _shims.isNum)(bounds.top)) y = Math.max(y, bounds.top);
71
+ return [x, y];
72
+ }
73
+ function snapToGrid(grid
74
+ /*: [number, number]*/, pendingX
75
+ /*: number*/, pendingY
76
+ /*: number*/) /*: [number, number]*/
77
+ {
78
+ var x = Math.round(pendingX / grid[0]) * grid[0];
79
+ var y = Math.round(pendingY / grid[1]) * grid[1];
80
+ return [x, y];
81
+ }
82
+ function canDragX(draggable
83
+ /*: Draggable*/) /*: boolean*/
84
+ {
85
+ return draggable.props.axis === 'both' || draggable.props.axis === 'x';
86
+ }
87
+ function canDragY(draggable
88
+ /*: Draggable*/) /*: boolean*/
89
+ {
90
+ return draggable.props.axis === 'both' || draggable.props.axis === 'y';
91
+ } // Get {x, y} positions from event.
92
+
93
+ function getControlPosition(e
94
+ /*: MouseTouchEvent*/, touchIdentifier
95
+ /*: ?number*/, draggableCore
96
+ /*: DraggableCore*/) /*: ?ControlPosition*/
97
+ {
98
+ var touchObj = typeof touchIdentifier === 'number' ? (0, _domFns.getTouch)(e, touchIdentifier) : null;
99
+ if (typeof touchIdentifier === 'number' && !touchObj) return null; // not the right touch
100
+
101
+ var node = findDOMNode(draggableCore); // User can provide an offsetParent if desired.
102
+
103
+ var offsetParent = draggableCore.props.offsetParent || node.offsetParent || node.ownerDocument.body;
104
+ return (0, _domFns.offsetXYFromParent)(touchObj || e, offsetParent, draggableCore.props.scale);
105
+ } // Create an data object exposed by <DraggableCore>'s events
106
+
107
+ function createCoreData(draggable
108
+ /*: DraggableCore*/, x
109
+ /*: number*/, y
110
+ /*: number*/) /*: DraggableData*/
111
+ {
112
+ var state = draggable.state;
113
+ var isStart = !(0, _shims.isNum)(state.lastX);
114
+ var node = findDOMNode(draggable);
115
+ if (isStart) {
116
+ // If this is our first move, use the x and y as last coords.
117
+ return {
118
+ node: node,
119
+ deltaX: 0,
120
+ deltaY: 0,
121
+ lastX: x,
122
+ lastY: y,
123
+ x: x,
124
+ y: y
125
+ };
126
+ } else {
127
+ // Otherwise calculate proper values.
128
+ return {
129
+ node: node,
130
+ deltaX: x - state.lastX,
131
+ deltaY: y - state.lastY,
132
+ lastX: state.lastX,
133
+ lastY: state.lastY,
134
+ x: x,
135
+ y: y
136
+ };
137
+ }
138
+ } // Create an data exposed by <Draggable>'s events
139
+
140
+ function createDraggableData(draggable
141
+ /*: Draggable*/, coreData
142
+ /*: DraggableData*/) /*: DraggableData*/
143
+ {
144
+ var scale = draggable.props.scale;
145
+ return {
146
+ node: coreData.node,
147
+ x: draggable.state.x + coreData.deltaX / scale,
148
+ y: draggable.state.y + coreData.deltaY / scale,
149
+ deltaX: coreData.deltaX / scale,
150
+ deltaY: coreData.deltaY / scale,
151
+ lastX: draggable.state.x,
152
+ lastY: draggable.state.y
153
+ };
154
+ } // A lot faster than stringify/parse
155
+
156
+ function cloneBounds(bounds
157
+ /*: Bounds*/) /*: Bounds*/
158
+ {
159
+ return {
160
+ left: bounds.left,
161
+ top: bounds.top,
162
+ right: bounds.right,
163
+ bottom: bounds.bottom
164
+ };
165
+ }
166
+ function findDOMNode(draggable
167
+ /*: Draggable | DraggableCore*/) /*: HTMLElement*/
168
+ {
169
+ var node = draggable.findDOMNode();
170
+ if (!node) {
171
+ throw new Error('<DraggableCore>: Unmounted during event!');
172
+ } // $FlowIgnore we can't assert on HTMLElement due to tests... FIXME
173
+
174
+ return node;
175
+ }
176
+ exports["default"] = positionFns.__exports;
@@ -0,0 +1,57 @@
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
+ 'use strict';
11
+
12
+ Object.defineProperty(exports, '__esModule', {
13
+ value: true
14
+ });
15
+ var shims = require('../../../../../_virtual/shims.js');
16
+ Object.defineProperty(shims.__exports, "__esModule", {
17
+ value: true
18
+ });
19
+ shims.__exports.findInArray = findInArray;
20
+ shims.__exports.isFunction = isFunction;
21
+ shims.__exports.isNum = isNum;
22
+ shims.__exports["int"] = _int;
23
+ shims.__exports.dontSetMe = dontSetMe;
24
+
25
+ // @credits https://gist.github.com/rogozhnikoff/a43cfed27c41e4e68cdc
26
+ function findInArray(array
27
+ /*: Array<any> | TouchList*/, callback
28
+ /*: Function*/) /*: any*/
29
+ {
30
+ for (var i = 0, length = array.length; i < length; i++) {
31
+ if (callback.apply(callback, [array[i], i, array])) return array[i];
32
+ }
33
+ }
34
+ function isFunction(func
35
+ /*: any*/) /*: boolean %checks*/
36
+ {
37
+ return typeof func === 'function' || Object.prototype.toString.call(func) === '[object Function]';
38
+ }
39
+ function isNum(num
40
+ /*: any*/) /*: boolean %checks*/
41
+ {
42
+ return typeof num === 'number' && !isNaN(num);
43
+ }
44
+ function _int(a
45
+ /*: string*/) /*: number*/
46
+ {
47
+ return parseInt(a, 10);
48
+ }
49
+ function dontSetMe(props
50
+ /*: Object*/, propName
51
+ /*: string*/, componentName
52
+ /*: string*/) {
53
+ if (props[propName]) {
54
+ return new Error("Invalid prop ".concat(propName, " passed to ").concat(componentName, " - do not set this, set it on the child."));
55
+ }
56
+ }
57
+ exports["default"] = shims.__exports;