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