@startlibs/components 1.1.5 → 1.2.0-rc.1

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 (123) hide show
  1. package/lib/BasicBulletList.mjs +1 -1
  2. package/lib/BasicBulletList.mjs.map +1 -1
  3. package/lib/Button.mjs +3 -3
  4. package/lib/Button.mjs.map +1 -1
  5. package/lib/ContextMenu.mjs +22 -6
  6. package/lib/ContextMenu.mjs.map +1 -1
  7. package/lib/Dialog.mjs +60 -24
  8. package/lib/Dialog.mjs.map +1 -1
  9. package/lib/Icon.mjs +10 -4
  10. package/lib/Icon.mjs.map +1 -1
  11. package/lib/Loading.mjs +26 -3
  12. package/lib/Loading.mjs.map +1 -1
  13. package/lib/PageLoader.mjs +2 -2
  14. package/lib/PageLoader.mjs.map +1 -1
  15. package/lib/PersistentNotifications.mjs +1 -1
  16. package/lib/PersistentNotifications.mjs.map +1 -1
  17. package/lib/SplitColumnsContainer.mjs +77 -6
  18. package/lib/SplitColumnsContainer.mjs.map +1 -1
  19. package/lib/TextButton.mjs +1 -1
  20. package/lib/TextButton.mjs.map +1 -1
  21. package/lib/ToastNotifications.mjs +16 -14
  22. package/lib/ToastNotifications.mjs.map +1 -1
  23. package/lib/alt/dialogs/DialogWithImageHeader.mjs +1 -1
  24. package/lib/alt/dialogs/DialogWithImageHeader.mjs.map +1 -1
  25. package/lib/alt/dialogs/DialogWithSidebar.mjs +7 -3
  26. package/lib/alt/dialogs/DialogWithSidebar.mjs.map +1 -1
  27. package/lib/alt/dialogs/MobileBubbleDialog.mjs +1 -1
  28. package/lib/alt/dialogs/MobileBubbleDialog.mjs.map +1 -1
  29. package/lib/containers/DialogContainer.mjs +29 -10
  30. package/lib/containers/DialogContainer.mjs.map +1 -1
  31. package/lib/index.cjs +286 -93
  32. package/lib/index.cjs.map +1 -1
  33. package/lib/willUseIsSticky.mjs +23 -2
  34. package/lib/willUseIsSticky.mjs.map +1 -1
  35. package/lib-yak/BasicBulletList.mjs +27 -0
  36. package/lib-yak/BasicBulletList.mjs.map +1 -0
  37. package/lib-yak/Button.mjs +374 -0
  38. package/lib-yak/Button.mjs.map +1 -0
  39. package/lib-yak/ContextMenu.mjs +642 -0
  40. package/lib-yak/ContextMenu.mjs.map +1 -0
  41. package/lib-yak/Dialog.mjs +469 -0
  42. package/lib-yak/Dialog.mjs.map +1 -0
  43. package/lib-yak/Draggable.mjs +892 -0
  44. package/lib-yak/Draggable.mjs.map +1 -0
  45. package/lib-yak/ErrorBoundary.mjs +108 -0
  46. package/lib-yak/ErrorBoundary.mjs.map +1 -0
  47. package/lib-yak/FillLastLineResizer.mjs +238 -0
  48. package/lib-yak/FillLastLineResizer.mjs.map +1 -0
  49. package/lib-yak/Flip.mjs +644 -0
  50. package/lib-yak/Flip.mjs.map +1 -0
  51. package/lib-yak/FlipList.mjs +186 -0
  52. package/lib-yak/FlipList.mjs.map +1 -0
  53. package/lib-yak/FormatDate.mjs +25 -0
  54. package/lib-yak/FormatDate.mjs.map +1 -0
  55. package/lib-yak/Icon.mjs +74 -0
  56. package/lib-yak/Icon.mjs.map +1 -0
  57. package/lib-yak/Image.mjs +41 -0
  58. package/lib-yak/Image.mjs.map +1 -0
  59. package/lib-yak/Link.mjs +116 -0
  60. package/lib-yak/Link.mjs.map +1 -0
  61. package/lib-yak/Loading.mjs +54 -0
  62. package/lib-yak/Loading.mjs.map +1 -0
  63. package/lib-yak/LoadingDiv.mjs +82 -0
  64. package/lib-yak/LoadingDiv.mjs.map +1 -0
  65. package/lib-yak/Notifications.mjs +99 -0
  66. package/lib-yak/Notifications.mjs.map +1 -0
  67. package/lib-yak/PageLoader.mjs +61 -0
  68. package/lib-yak/PageLoader.mjs.map +1 -0
  69. package/lib-yak/PersistentNotifications.mjs +209 -0
  70. package/lib-yak/PersistentNotifications.mjs.map +1 -0
  71. package/lib-yak/Popup.mjs +66 -0
  72. package/lib-yak/Popup.mjs.map +1 -0
  73. package/lib-yak/SplitColumnsContainer.mjs +140 -0
  74. package/lib-yak/SplitColumnsContainer.mjs.map +1 -0
  75. package/lib-yak/SwitchDiv.mjs +60 -0
  76. package/lib-yak/SwitchDiv.mjs.map +1 -0
  77. package/lib-yak/TextButton.mjs +61 -0
  78. package/lib-yak/TextButton.mjs.map +1 -0
  79. package/lib-yak/ToastNotifications.mjs +316 -0
  80. package/lib-yak/ToastNotifications.mjs.map +1 -0
  81. package/lib-yak/Tooltip.mjs +176 -0
  82. package/lib-yak/Tooltip.mjs.map +1 -0
  83. package/lib-yak/TransitionDiv.mjs +59 -0
  84. package/lib-yak/TransitionDiv.mjs.map +1 -0
  85. package/lib-yak/WarningDialog.mjs +107 -0
  86. package/lib-yak/WarningDialog.mjs.map +1 -0
  87. package/lib-yak/alt/buttons/OnClickLoadingButton.mjs +36 -0
  88. package/lib-yak/alt/buttons/OnClickLoadingButton.mjs.map +1 -0
  89. package/lib-yak/alt/dialogs/DialogWithImageHeader.mjs +50 -0
  90. package/lib-yak/alt/dialogs/DialogWithImageHeader.mjs.map +1 -0
  91. package/lib-yak/alt/dialogs/DialogWithSidebar.mjs +193 -0
  92. package/lib-yak/alt/dialogs/DialogWithSidebar.mjs.map +1 -0
  93. package/lib-yak/alt/dialogs/MobileBubbleDialog.mjs +82 -0
  94. package/lib-yak/alt/dialogs/MobileBubbleDialog.mjs.map +1 -0
  95. package/lib-yak/containers/DialogContainer.mjs +482 -0
  96. package/lib-yak/containers/DialogContainer.mjs.map +1 -0
  97. package/lib-yak/containers/Reposition.mjs +35 -0
  98. package/lib-yak/containers/Reposition.mjs.map +1 -0
  99. package/lib-yak/containers/usePositioning.mjs +311 -0
  100. package/lib-yak/containers/usePositioning.mjs.map +1 -0
  101. package/lib-yak/index.mjs +37 -0
  102. package/lib-yak/index.mjs.map +1 -0
  103. package/lib-yak/useDialogWithToggle.mjs +18 -0
  104. package/lib-yak/useDialogWithToggle.mjs.map +1 -0
  105. package/lib-yak/willUseIsSticky.mjs +147 -0
  106. package/lib-yak/willUseIsSticky.mjs.map +1 -0
  107. package/package.json +12 -3
  108. package/src/BasicBulletList.jsx +1 -1
  109. package/src/Button.jsx +36 -30
  110. package/src/ContextMenu.jsx +21 -7
  111. package/src/Dialog.jsx +31 -12
  112. package/src/Icon.jsx +5 -4
  113. package/src/Loading.jsx +19 -5
  114. package/src/PageLoader.jsx +3 -3
  115. package/src/PersistentNotifications.jsx +2 -2
  116. package/src/SplitColumnsContainer.jsx +89 -30
  117. package/src/TextButton.jsx +1 -1
  118. package/src/ToastNotifications.jsx +15 -8
  119. package/src/alt/dialogs/DialogWithImageHeader.jsx +2 -2
  120. package/src/alt/dialogs/DialogWithSidebar.jsx +6 -5
  121. package/src/alt/dialogs/MobileBubbleDialog.jsx +1 -1
  122. package/src/containers/DialogContainer.jsx +11 -4
  123. package/src/willUseIsSticky.jsx +22 -2
@@ -0,0 +1,892 @@
1
+ import _extends from '@babel/runtime/helpers/extends';
2
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
+ import _set from 'lodash/fp/set';
5
+ import _assign from 'lodash/fp/assign';
6
+ import _pullAt from 'lodash/fp/pullAt';
7
+ import _map from 'lodash/fp/map';
8
+ import { yakDomTag } from '@startlibs/utils/yakDomTag';
9
+ import React from 'react';
10
+ import ReactDOM from 'react-dom';
11
+ import { styled, css } from '@yak/react';
12
+ import { getScrollParent, normalizeMouse, normalizeTouch } from '@startlibs/utils';
13
+ import { FlipList } from './FlipList.mjs';
14
+
15
+ const _excluded = ["DragTag", "as", "eventHandlers", "className", "isDragging", "droppable", "dragIndex", "roundedPlaceholder", "inheritRadius", "children"],
16
+ _excluded2 = ["setItemOrder", "noResistance", "animation", "timing", "disabled", "list", "ghostScale", "setDragRef", "scrollOnDrag", "holdTouchTimer", "children"];
17
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
19
+ const {
20
+ Provider,
21
+ Consumer
22
+ } = /*#__PURE__*/React.createContext({});
23
+ const DropPosition = styled(yakDomTag("div"))`
24
+ border: 2px dashed rgba(0,0,0,0.1);
25
+ background-color: rgba(0,0,0,0.025);
26
+ border-radius: 18px;
27
+ position: absolute;
28
+ top: 0;
29
+ bottom: 0;
30
+ right: 0;
31
+ left: 0;
32
+ visibility: visible;
33
+ display: block;
34
+ border-radius: inherit;
35
+ ${props => props.rounded && css`
36
+ border-radius: 1000rem;
37
+ `}
38
+ `;
39
+ const EmptyPlaceholder = styled(yakDomTag("div"))`
40
+ position:absolute;
41
+ `;
42
+ const HORIZONTAL_DIMENSIONS = {
43
+ min: 'left',
44
+ max: 'right',
45
+ axis: 'x',
46
+ size: 'Width'
47
+ };
48
+ const VERTICAL_DIMENSIONS = {
49
+ min: 'top',
50
+ max: 'bottom',
51
+ axis: 'y',
52
+ size: 'Height'
53
+ };
54
+ const AUTO_SCROLL_BORDER_SIZE = 30;
55
+ const AUTO_SCROLL_MAX_VELOCITY = 20;
56
+ const AUTO_SCROLL_OVERFLOW_BUFFER = 100;
57
+ function easeInCubic(t) {
58
+ return Math.ceil(t * t * t / (AUTO_SCROLL_MAX_VELOCITY * AUTO_SCROLL_MAX_VELOCITY));
59
+ }
60
+ const disableWillChange = el => {
61
+ const willChange = el === null || el === void 0 ? void 0 : el.closest(".JS-has-wc");
62
+ if (willChange) {
63
+ willChange.classList.add('JS-wc-off');
64
+ disableWillChange(willChange.parentNode);
65
+ }
66
+ };
67
+ const reenableWillChange = el => {
68
+ const willChange = el === null || el === void 0 ? void 0 : el.closest(".JS-has-wc");
69
+ if (willChange) {
70
+ willChange.classList.remove('JS-wc-off');
71
+ reenableWillChange(willChange.parentNode);
72
+ }
73
+ };
74
+ const shouldPreventDrag = e => !e.target.closest('body,.drag-drop-item,[data-drag="false"],input,textarea,button').matches('body,.drag-drop-item,[data-drag="true"]');
75
+ class DraggableItem extends React.Component {
76
+ constructor() {
77
+ super(...arguments);
78
+ this.events = this.props.eventHandlers(this);
79
+ }
80
+ render() {
81
+ const _this$props = this.props,
82
+ {
83
+ DragTag,
84
+ as = 'div',
85
+ eventHandlers,
86
+ className,
87
+ isDragging,
88
+ droppable,
89
+ dragIndex,
90
+ roundedPlaceholder,
91
+ inheritRadius,
92
+ children
93
+ } = _this$props,
94
+ props = _objectWithoutProperties(_this$props, _excluded);
95
+ const Wrapper = DragTag || as;
96
+ const extraClassName = (isDragging ? ' drag-drop-placeholder' : '') + ' drag-drop-item';
97
+ return typeof children === 'function' ? children(_objectSpread(_objectSpread({
98
+ className: extraClassName
99
+ }, this.events), {}, {
100
+ children: isDragging && /*#__PURE__*/React.createElement(DropPosition, {
101
+ rounded: roundedPlaceholder,
102
+ inheritRadius: inheritRadius
103
+ })
104
+ })) : /*#__PURE__*/React.createElement(Wrapper, _extends({
105
+ className: className + extraClassName,
106
+ isDragging: isDragging
107
+ }, props, this.events), children, isDragging && /*#__PURE__*/React.createElement(DropPosition, {
108
+ rounded: roundedPlaceholder,
109
+ inheritRadius: inheritRadius
110
+ }));
111
+ }
112
+ }
113
+ DraggableItem.a = props => /*#__PURE__*/React.createElement(DraggableItem, _extends({}, props, {
114
+ DragTag: "a"
115
+ }));
116
+ const DroppableContainer = props => /*#__PURE__*/React.createElement(Consumer, null, dragProps => /*#__PURE__*/React.createElement(DroppableContainerComponent, _extends({}, props, dragProps)));
117
+ class DroppableContainerComponent extends React.Component {
118
+ constructor() {
119
+ super(...arguments);
120
+ this.draggables = [];
121
+ this.emptyPlaceholder = void 0;
122
+ this.addProps = (children, eventHandlers, activeIndex, extraProps) => children.map((c, index) => c.type === DraggableItem ? /*#__PURE__*/React.cloneElement(c, {
123
+ isDragging: activeIndex === index,
124
+ dragIndex: index,
125
+ droppable: this,
126
+ ref: el => this.draggables[index] = el,
127
+ eventHandlers: eventHandlers
128
+ }) : c);
129
+ this.toPosition = (parentRect, _ref) => {
130
+ let {
131
+ scrollTop,
132
+ scrollLeft
133
+ } = _ref;
134
+ return (el, i) => {
135
+ if (el) {
136
+ const domNode = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE.findDOMNode(el);
137
+ const {
138
+ width,
139
+ height
140
+ } = domNode.getBoundingClientRect();
141
+ return {
142
+ droppable: this,
143
+ index: i,
144
+ width,
145
+ height,
146
+ y: parentRect.top + domNode.offsetTop + height / 2 + (scrollTop || 0),
147
+ x: parentRect.left + domNode.offsetLeft + width / 2 + (scrollLeft || 0)
148
+ };
149
+ }
150
+ };
151
+ };
152
+ this.getPosition = (i, scrollXY) => {
153
+ const el = this.draggables[i];
154
+ if (el) {
155
+ const parent = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE.findDOMNode(this).offsetParent;
156
+ const parentRect = parent.getBoundingClientRect();
157
+ return this.toPosition(parentRect, 0)(el, i);
158
+ }
159
+ };
160
+ this.getPositions = (scrollXY, dragInfo) => {
161
+ if (this.props.allowDrop && !this.props.allowDrop(_map(dragInfo, v => v && v.props ? v.props.id : v))) {
162
+ return [];
163
+ }
164
+ const parent = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE.findDOMNode(this).offsetParent;
165
+ if (!parent) {
166
+ return [];
167
+ }
168
+ const parentRect = parent.getBoundingClientRect();
169
+ const toPosition = this.toPosition(parentRect, scrollXY);
170
+ const existing = this.draggables.map(toPosition).filter(_ => _);
171
+ if (existing.length || !this.props.placeholder) return existing;
172
+ return [ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE.findDOMNode(this)].map(toPosition).filter(_ => _);
173
+ };
174
+ this.repositionDragged = (array, _ref2, getActiveElement) => {
175
+ let {
176
+ active,
177
+ startIndex,
178
+ startDroppable,
179
+ activeIndex,
180
+ activeDroppable
181
+ } = _ref2;
182
+ // Repositioning dereferences startDroppable.props further down. Rendering with an
183
+ // activeDroppable but no startDroppable would take the whole tree down, so render
184
+ // the list untouched instead and let the next commit reconcile it.
185
+ if (!startDroppable) {
186
+ return array;
187
+ }
188
+ if (activeDroppable && (activeDroppable === this || startDroppable === this)) {
189
+ // remove
190
+ const removedOrInserted = _pullAt(startDroppable === this ? startIndex : [], array);
191
+ if (activeDroppable === this) {
192
+ // insert
193
+ removedOrInserted.splice(activeIndex, 0, getActiveElement());
194
+ }
195
+ return removedOrInserted;
196
+ }
197
+ return array;
198
+ };
199
+ this.getPlaceholder = (childArray, dragInfo) => childArray.find(_ => _.props.droppable) || dragInfo.startDroppable.props.children[dragInfo.startIndex];
200
+ this.getDragged = (childArray, dragInfo) => dragInfo.startDroppable === this ? childArray[dragInfo.startIndex] : /*#__PURE__*/React.cloneElement(this.getPlaceholder(childArray, dragInfo), {
201
+ key: childArray[0].key + 'si' + dragInfo.startIndex
202
+ });
203
+ this.childrenToarray = _ref3 => {
204
+ let {
205
+ children,
206
+ list,
207
+ dragInfo
208
+ } = _ref3;
209
+ const {
210
+ startDroppable,
211
+ startIndex
212
+ } = dragInfo;
213
+ if (list) {
214
+ return React.Children.toArray(children(this.repositionDragged(list, dragInfo, () => startDroppable.props.list[startIndex])));
215
+ } else {
216
+ const childArray = React.Children.toArray(children);
217
+ return this.repositionDragged(childArray, dragInfo, () => this.getDragged(childArray, dragInfo));
218
+ }
219
+ };
220
+ }
221
+ componentDidMount() {
222
+ this.props.addDroppable(this);
223
+ }
224
+ componentWillUnmount() {
225
+ this.props.removeDroppable(this);
226
+ }
227
+ render() {
228
+ const {
229
+ group,
230
+ placeholder,
231
+ dragInfo,
232
+ animation,
233
+ timing,
234
+ eventHandlers
235
+ } = this.props;
236
+ const {
237
+ active,
238
+ activeIndex,
239
+ activeDroppable
240
+ } = dragInfo;
241
+ const childArray = this.childrenToarray(this.props);
242
+ if (!childArray.length && placeholder) {
243
+ return placeholder();
244
+ }
245
+ return /*#__PURE__*/React.createElement(FlipList, {
246
+ animation: animation,
247
+ timing: timing,
248
+ play: active
249
+ }, this.addProps(childArray, eventHandlers, active && activeDroppable === this && activeIndex));
250
+ }
251
+ }
252
+ DroppableContainerComponent.defaultProps = {
253
+ placeholder: () => /*#__PURE__*/React.createElement(EmptyPlaceholder, null)
254
+ };
255
+ class DraggableContainer extends React.Component {
256
+ constructor() {
257
+ var _this;
258
+ super(...arguments);
259
+ _this = this;
260
+ this.props = void 0;
261
+ /*: {
262
+ scrollContainer,
263
+ setItemOrder,
264
+ children,
265
+ noResistance,
266
+ holdTouchTimer
267
+ }*/
268
+ this.ghost = void 0;
269
+ // dragEnd animates the ghost out over 300ms, so the tail of a drag is asynchronous
270
+ // and a new drag can start before the previous one has finished. Each drag therefore
271
+ // gets its own session holding everything its completion needs (ghost, dragInfo),
272
+ // instead of reading the shared slots a newer drag may already have taken over.
273
+ // dragToken identifies the drag that currently owns the shared state.
274
+ this.dragToken = 0;
275
+ this.activeSession = null;
276
+ this.positions = {};
277
+ this.passedResistance = false;
278
+ this.pressedEnough = false;
279
+ this.holdTouchTimer = void 0;
280
+ //: number
281
+ this.preventScroll = void 0;
282
+ //: boolean
283
+ this.state = {
284
+ dragInfo: {}
285
+ };
286
+ this.droppables = {};
287
+ this.offsetParent = void 0;
288
+ //: HTMLElement
289
+ this.parent = void 0;
290
+ //: HTMLElement
291
+ this.ghostDimensions = void 0;
292
+ //: GhostDimensions
293
+ this.itemsPositions = void 0;
294
+ //: Array<{ index: number, y: number, x: number }>
295
+ this.scrollContainer = void 0;
296
+ //: HTMLElement & any
297
+ this.lastScrollTop = void 0;
298
+ //: number
299
+ this.lastScrollLeft = void 0;
300
+ //: number
301
+ this.settedDragRef = false;
302
+ this.preventDefault = e => {
303
+ if (!shouldPreventDrag(e) && this.preventScroll) e.preventDefault();
304
+ };
305
+ this.getScrollContainer = () => {
306
+ return this.scrollContainer = this.scrollContainer || (this.props.scrollContainer ? this.props.scrollContainer : getScrollParent(ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE.findDOMNode(this)));
307
+ };
308
+ this.removeItem = el => {
309
+ this.domItems = this.domItems.filter(e => e !== el);
310
+ };
311
+ this.setOffsetParent = e => {
312
+ this.parent = e;
313
+ this.offsetParent = e && (window.getComputedStyle(e).position !== 'static' ? e : e.offsetParent);
314
+ };
315
+ this.getConstraintDimensions = () => {
316
+ if (!this.offsetParent) return {
317
+ left: 0,
318
+ top: 0,
319
+ bottom: 0,
320
+ right: 0,
321
+ width: 0,
322
+ height: 0
323
+ };
324
+ return this.offsetParent.getBoundingClientRect();
325
+ };
326
+ this.dragStart = draggable => (e, _ref4) => {
327
+ let {
328
+ pageX,
329
+ pageY,
330
+ clientX,
331
+ clientY
332
+ } = _ref4;
333
+ const currentTarget = e.currentTarget;
334
+ if (shouldPreventDrag(e) || this.props.disabled) {
335
+ return;
336
+ }
337
+ if (e.type === 'mousedown' && e.button !== 0) {
338
+ return;
339
+ }
340
+ e.stopPropagation();
341
+ this.passedResistance = false;
342
+ const holdTouchTimer = this.props.holdTouchTimer;
343
+ this.pressedEnough = !holdTouchTimer;
344
+ if (holdTouchTimer) {
345
+ e.persist();
346
+ this.holdTouchTimer = setTimeout(() => {
347
+ this.pressedEnough = true;
348
+ if (window.navigator.vibrate) window.navigator.vibrate([65]);
349
+ if (!this.state.dragInfo.active) {
350
+ this.dragMove(e, {
351
+ pageX,
352
+ pageY,
353
+ clientX,
354
+ clientY
355
+ });
356
+ }
357
+ }, holdTouchTimer);
358
+ }
359
+ const {
360
+ width,
361
+ height,
362
+ top,
363
+ left
364
+ } = currentTarget.getBoundingClientRect();
365
+ const targetStyle = window.getComputedStyle(currentTarget);
366
+ const {
367
+ top: parentTop,
368
+ left: parentLeft
369
+ } = this.getConstraintDimensions();
370
+ const offsetTop = parentTop + pageY - top + parseInt(targetStyle['margin-top'], 10);
371
+ const offsetLeft = parentLeft + pageX - left + parseInt(targetStyle['margin-left'], 10);
372
+ const {
373
+ scrollTop,
374
+ scrollLeft,
375
+ scrollY,
376
+ scrollX
377
+ } = this.getScrollContainer();
378
+ this.positions = {
379
+ originalX: pageX,
380
+ originalY: pageY,
381
+ offsetTop,
382
+ offsetLeft,
383
+ ghostHeight: height,
384
+ ghostWidth: width,
385
+ ghostMarginTop: parseInt(targetStyle['margin-top'], 10),
386
+ ghostMarginLeft: parseInt(targetStyle['margin-left'], 10),
387
+ scrollLeft: scrollLeft || 0,
388
+ scrollTop: scrollTop || 0,
389
+ scrollY: scrollY || 0,
390
+ scrollX: scrollX || 0
391
+ };
392
+ const ghost = currentTarget.cloneNode(true);
393
+ ghost.className += ' dragging';
394
+ Object.assign(ghost.style, {
395
+ transition: '',
396
+ position: 'fixed',
397
+ display: 'none',
398
+ zIndex: '10',
399
+ width: width + 'px',
400
+ height: height + 'px',
401
+ margin: '0',
402
+ top: top - clientY + 'px',
403
+ left: left - clientX + 'px'
404
+ });
405
+ this.setupMove(ghost, currentTarget.offsetParent, draggable, {
406
+ width,
407
+ height,
408
+ offsetX: pageX - left,
409
+ offsetY: pageY - top
410
+ });
411
+ window.addEventListener('mousemove', this.mouseMove);
412
+ window.addEventListener('touchmove', this.touchMove, {
413
+ passive: false
414
+ });
415
+ window.addEventListener('mouseup', this.dragEnd);
416
+ window.addEventListener('touchend', this.dragEnd);
417
+ window.addEventListener('visibilitychange', this.dragEnd);
418
+ window.addEventListener('blur', this.dragEnd, false);
419
+ window.addEventListener('selectstart', this.disableSelect);
420
+ };
421
+ this.setupMove = (el, parent, item, ghostDimensions) => {
422
+ this.ghostDimensions = ghostDimensions;
423
+ parent.click(); // close popups
424
+ this.ghost = el;
425
+ // Open this drag's session and take ownership of the shared state. Any previous
426
+ // session is now superseded: it still holds its own ghost and dragInfo, so it can
427
+ // finish animating and clean itself up without touching anything below.
428
+ this.dragToken++;
429
+ this.activeSession = {
430
+ token: this.dragToken,
431
+ ghost: el,
432
+ dragInfo: null,
433
+ ended: false,
434
+ endTimeout: null,
435
+ onTransitionEnd: null
436
+ };
437
+ parent.appendChild(this.ghost);
438
+ disableWillChange(this.ghost);
439
+ this.setState({
440
+ dragInfo: {
441
+ active: false,
442
+ startIndex: item.props.dragIndex,
443
+ activeGroup: item.props.droppable.props.group,
444
+ startDroppable: item.props.droppable
445
+ }
446
+ });
447
+ this.settedDragRef = false;
448
+ };
449
+ this.getScrollPosition = () => {
450
+ const {
451
+ scrollY,
452
+ scrollX,
453
+ scrollLeft,
454
+ scrollTop
455
+ } = this.getScrollContainer();
456
+ const left = (scrollX || 0 + scrollLeft || 0) - this.positions.scrollX - this.positions.scrollLeft;
457
+ const top = (scrollY || 0 + scrollTop || 0) - this.positions.scrollY - this.positions.scrollTop;
458
+ return {
459
+ scrollLeft: left,
460
+ scrollTop: top
461
+ };
462
+ };
463
+ this.resetPositions = function () {
464
+ let group = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.state.dragInfo.activeGroup;
465
+ _this.itemsPositions = _this.droppables[group].reduce((acc, _) => acc.concat(_.getPositions(_this.getScrollPosition(), _this.state.dragInfo)), []).sort((a, b) => a.y - b.y || a.x - b.x);
466
+ };
467
+ this.move = (x, y) => {
468
+ if (!this.settedDragRef && this.props.setDragRef) {
469
+ this.props.setDragRef(this.ghost);
470
+ this.settedDragRef = true;
471
+ }
472
+ const {
473
+ scrollTop,
474
+ scrollLeft
475
+ } = this.getScrollPosition();
476
+ this.preventScroll = true;
477
+ let item = this.findGhostIndex(x - this.ghostDimensions.offsetX + (scrollLeft || 0), y - this.ghostDimensions.offsetY + (scrollTop || 0), this.ghostDimensions.width, this.ghostDimensions.height);
478
+ if (!item) {
479
+ return;
480
+ }
481
+ const dragInfo = this.state.dragInfo;
482
+ if (item.index !== dragInfo.activeIndex || item.droppable !== dragInfo.activeDroppable) {
483
+ this.setState({
484
+ dragInfo: _assign(dragInfo, {
485
+ active: true,
486
+ activePosition: item,
487
+ activeIndex: item.index,
488
+ activeDroppable: item.droppable
489
+ })
490
+ });
491
+ }
492
+ };
493
+ this.findGhostIndex = (ghostX1, ghostY1, ghostWidth, ghostHeight) => {
494
+ const ghostY2 = ghostY1 + ghostHeight;
495
+ const ghostX2 = ghostX1 + ghostWidth;
496
+ const centerInsideGhost = this.itemsPositions.filter(position => position.y >= ghostY1 && position.x >= ghostX1 && position.y <= ghostY2 && position.x <= ghostX2);
497
+ const ghostX = ghostX1 + ghostWidth / 2;
498
+ const ghostY = ghostY1 + ghostHeight / 2;
499
+ const rectanglesIntersection = (a, b) => Math.max(0, Math.min(a.x2, b.x2) - Math.max(a.x1, b.x1)) * Math.max(0, Math.min(a.y2, b.y2) - Math.max(a.y1, b.y1));
500
+ const closestIndex = centerInsideGhost.map(item => {
501
+ const {
502
+ x,
503
+ y,
504
+ width,
505
+ height
506
+ } = item;
507
+ const area = width * height;
508
+ const intersectionArea = rectanglesIntersection(
509
+ //at least 1px wide
510
+ {
511
+ x1: x - Math.max(1, width) / 2,
512
+ x2: x + width / 2,
513
+ y1: y - Math.max(1, height) / 2,
514
+ y2: y + height / 2
515
+ }, {
516
+ x1: ghostX1,
517
+ x2: ghostX2,
518
+ y1: ghostY1,
519
+ y2: ghostY2
520
+ });
521
+ const distance = Math.sqrt(Math.pow(x - ghostX, 2) + Math.pow(y - ghostY, 2));
522
+ return {
523
+ area: intersectionArea / area,
524
+ distance
525
+ };
526
+ }).reduce((iMax, _ref5, i, arr) => {
527
+ let {
528
+ area,
529
+ distance
530
+ } = _ref5;
531
+ return area > arr[iMax].area || area === arr[iMax].area && distance < arr[iMax].distance ? i : iMax;
532
+ }, 0);
533
+ return centerInsideGhost[closestIndex];
534
+ };
535
+ this.stopMoving = session => {
536
+ // Completion runs from mouseup, from a transitionend, or from the 300ms fallback
537
+ // timer, so it can be reached more than once for the same drag.
538
+ if (!session || session.ended) {
539
+ return;
540
+ }
541
+ session.ended = true;
542
+ const {
543
+ token,
544
+ ghost,
545
+ dragInfo
546
+ } = session;
547
+ const {
548
+ activeIndex,
549
+ startIndex,
550
+ activeGroup,
551
+ activeDroppable,
552
+ startDroppable
553
+ } = dragInfo || {};
554
+ if (session.endTimeout) {
555
+ clearTimeout(session.endTimeout);
556
+ session.endTimeout = null;
557
+ }
558
+ if (ghost && session.onTransitionEnd) {
559
+ ghost.removeEventListener('transitionend', session.onTransitionEnd);
560
+ session.onTransitionEnd = null;
561
+ }
562
+
563
+ // Everything below acts on this session's own ghost and dragInfo, so it stays
564
+ // correct even once a newer drag has replaced this.ghost and this.state.dragInfo.
565
+ const finish = () => {
566
+ if (ghost !== null && ghost !== void 0 && ghost.parentNode) {
567
+ reenableWillChange(ghost);
568
+ ghost.parentNode.removeChild(ghost);
569
+ }
570
+ if (activeIndex !== startIndex && activeIndex !== undefined || activeDroppable !== startDroppable && activeDroppable !== undefined) {
571
+ var _startDroppable$props, _activeDroppable$prop;
572
+ const promise = this.props.setItemOrder(startIndex, activeIndex, startDroppable === null || startDroppable === void 0 || (_startDroppable$props = startDroppable.props) === null || _startDroppable$props === void 0 ? void 0 : _startDroppable$props.id, activeDroppable === null || activeDroppable === void 0 || (_activeDroppable$prop = activeDroppable.props) === null || _activeDroppable$prop === void 0 ? void 0 : _activeDroppable$prop.id, activeGroup);
573
+ if (promise && promise.then) {
574
+ promise.then(() => this.clearChangedOrder(token), () => this.clearChangedOrder(token));
575
+ } else {
576
+ this.clearChangedOrder(token);
577
+ }
578
+ } else {
579
+ this.clearChangedOrder(token);
580
+ }
581
+ };
582
+ if (token !== this.dragToken) {
583
+ // Superseded: a newer drag owns the shared state and the render output. Drop
584
+ // our ghost and commit our reorder, but leave that drag's state alone.
585
+ finish();
586
+ return;
587
+ }
588
+ this.setState({
589
+ saving: {
590
+ list: this.props.list,
591
+ children: this.props.children,
592
+ dragInfo: _set('active', false, dragInfo || {})
593
+ }
594
+ }, () => {
595
+ this.preventScroll = false;
596
+ this.props.setDragRef(null);
597
+ this.settedDragRef = false;
598
+ finish();
599
+ });
600
+ };
601
+ this.clearChangedOrder = token => {
602
+ // Only the drag that still owns the shared state may reset it — a superseded
603
+ // session clearing dragInfo here would wipe the drag currently in progress.
604
+ if (token !== undefined && token !== this.dragToken) {
605
+ return;
606
+ }
607
+ this.setState({
608
+ dragInfo: {},
609
+ saving: false
610
+ });
611
+ };
612
+ this.dragMove = (e, _ref6) => {
613
+ let {
614
+ pageX,
615
+ pageY,
616
+ clientX,
617
+ clientY
618
+ } = _ref6;
619
+ const distance = Math.sqrt((this.positions.originalX - pageX) ** 2 + (this.positions.originalY - pageY) ** 2);
620
+ if (e.type === 'mousemove') {
621
+ // get touchstart and touchmove
622
+ if (!this.passedResistance && !this.props.noResistance && distance < 5) {
623
+ return;
624
+ }
625
+ } else {
626
+ if (!this.pressedEnough) {
627
+ if (distance > 5) {
628
+ this.dragEnd();
629
+ }
630
+ return;
631
+ }
632
+ e.preventDefault();
633
+ }
634
+ this.passedResistance = true;
635
+ this.processAutoScroll(pageX, pageY, clientX, clientY);
636
+ };
637
+ this.completeMove = (pageX, pageY) => {
638
+ const {
639
+ scrollTop,
640
+ scrollLeft
641
+ } = this.getScrollContainer();
642
+ const scrollYDelta = this.positions.scrollTop - (scrollTop || 0);
643
+ const scrollXDelta = this.positions.scrollLeft - (scrollLeft || 0);
644
+ const ghostLeft = pageX - this.positions.offsetLeft;
645
+ const ghostTop = pageY - this.positions.offsetTop;
646
+ const {
647
+ height: parentHeight,
648
+ width: parentWidth
649
+ } = this.getConstraintDimensions();
650
+ const normalizedLeft = Math.max(Math.min(ghostLeft, parentWidth - this.positions.ghostWidth - this.positions.ghostMarginLeft + scrollXDelta), 0 - this.positions.ghostMarginLeft + scrollXDelta);
651
+ const normalizedTop = Math.max(Math.min(ghostTop, parentHeight - this.positions.ghostHeight - this.positions.ghostMarginTop + scrollYDelta), 0 - this.positions.ghostMarginTop + scrollYDelta);
652
+ const x = normalizedLeft - ghostLeft + pageX - window.scrollX;
653
+ const y = normalizedTop - ghostTop + pageY - window.scrollY;
654
+ if (this.ghost) {
655
+ this.ghost.style.transform = `translate(${x}px,${y}px)` + (this.props.ghostScale ? ' scale(' + this.props.ghostScale + ')' : '');
656
+ this.ghost.style.display = '';
657
+ }
658
+ this.move(pageX - (ghostLeft - normalizedLeft), pageY - (ghostTop - normalizedTop));
659
+ if (!this.state.dragInfo.active) {
660
+ this.setState({
661
+ dragInfo: _assign(this.state.dragInfo, {
662
+ activeIndex: this.state.dragInfo.startIndex,
663
+ activeDroppable: this.state.dragInfo.startDroppable,
664
+ active: true
665
+ })
666
+ });
667
+ }
668
+ };
669
+ this.autoScrollAnimation = void 0;
670
+ this.autoScrollX = void 0;
671
+ this.autoScrollY = void 0;
672
+ this.getFixedParentRect = (node, not) => {
673
+ if (node) {
674
+ if (window.getComputedStyle(node)['position'].toLowerCase() === 'fixed' && not !== node) return node.getBoundingClientRect();else return this.getFixedParentRect(node.offsetParent, not);
675
+ } else {
676
+ return {};
677
+ }
678
+ };
679
+ this.calculateDistanceFromBorder = (ghost, position, getElementBeforeBorder, scrollContainer, parentRect, keys) => {
680
+ const fixedUnderMouse = scrollContainer === window ? this.getFixedParentRect(getElementBeforeBorder(+AUTO_SCROLL_BORDER_SIZE), ghost) : {};
681
+ const min = scrollContainer !== window ? scrollContainer.getBoundingClientRect()[keys.min] : fixedUnderMouse[keys.max] || this.getFixedParentRect(getElementBeforeBorder(-AUTO_SCROLL_BORDER_SIZE), ghost)[keys.max] || 0;
682
+ const max = scrollContainer !== window ? scrollContainer.getBoundingClientRect()[keys.max] : fixedUnderMouse[keys.min] || this.getFixedParentRect(getElementBeforeBorder(+AUTO_SCROLL_BORDER_SIZE), ghost)[keys.min] || window['inner' + keys.size];
683
+ const distanceMin = position - AUTO_SCROLL_BORDER_SIZE - min;
684
+ const distanceMax = position + AUTO_SCROLL_BORDER_SIZE - max;
685
+ const containerMin = scrollContainer === window ? 0 : Math.max(scrollContainer.getBoundingClientRect()[keys.min], 0);
686
+ const containerMax = scrollContainer === window ? window['inner' + keys.size] : Math.min(scrollContainer.getBoundingClientRect()[keys.max], window['inner' + keys.size]);
687
+ const afterCenter = (position - containerMin) * 2 / (containerMax - containerMin) > 1;
688
+ if (distanceMin < 0 && !afterCenter) return distanceMin;
689
+ if (distanceMax > 0) return distanceMax;
690
+ return 0;
691
+ };
692
+ this.processAutoScroll = (pageX, pageY, clientX, clientY) => {
693
+ const scrollContainer = this.getScrollContainer();
694
+ const parentRect = this.getConstraintDimensions();
695
+ this.autoScrollY = this.calculateDistanceFromBorder(this.ghost, clientY, diff => document.elementFromPoint(clientX, clientY + diff), scrollContainer, parentRect, VERTICAL_DIMENSIONS);
696
+ // this.autoScrollX = this.calculateDistanceFromBorder(clientX, (diff) => document.elementFromPoint(clientX + diff, clientY), scrollContainer, parentRect, HORIZONTAL_DIMENSIONS)
697
+ this.autoScrollX = 0;
698
+ // noinspection JSSuspiciousNameCombination
699
+ const keepY = this.autoScrollX === 0 || this.autoScrollY !== 0 && Math.abs(this.autoScrollY) < Math.abs(this.autoScrollX);
700
+ this.autoScrollY = this.props.scrollOnDrag && keepY ? this.autoScrollY : 0;
701
+ this.autoScrollX = this.props.scrollOnDrag && !keepY ? this.autoScrollX : 0;
702
+ if (this.autoScrollX || this.autoScrollY) {
703
+ this.startAutoScroll(pageX, pageY, scrollContainer);
704
+ } else {
705
+ if (this.autoScrollAnimation) {
706
+ this.stopAutoScroll();
707
+ }
708
+ this.completeMove(pageX, pageY);
709
+ }
710
+ };
711
+ this.checkLimits = (delta, boundRect, constraintRect, scrollRect, keys) => {
712
+ if (delta > 0) {
713
+ if (constraintRect[keys.max] + AUTO_SCROLL_OVERFLOW_BUFFER < scrollRect[keys.max]) {
714
+ return 0;
715
+ }
716
+ }
717
+ if (delta < 0) {
718
+ if (constraintRect[keys.min] - AUTO_SCROLL_OVERFLOW_BUFFER > scrollRect[keys.min]) {
719
+ return 0;
720
+ }
721
+ }
722
+ return delta;
723
+ };
724
+ this.startAutoScroll = (pageX, pageY, scrollContainer) => {
725
+ if (!this.autoScrollAnimation) {
726
+ this.autoScrollAnimation = window.requestAnimationFrame(timestamp => {
727
+ const ghostRect = this.ghost.getBoundingClientRect();
728
+ const parentRect = this.getConstraintDimensions();
729
+ const scrollRect = scrollContainer === window ? {
730
+ top: 0,
731
+ bottom: window.innerHeight,
732
+ left: 0,
733
+ right: window.innerWidth
734
+ } : scrollContainer.getBoundingClientRect();
735
+ const deltaScrollX = easeInCubic(this.checkLimits(this.autoScrollX < 0 ? Math.max(this.autoScrollX, -AUTO_SCROLL_MAX_VELOCITY) : Math.min(this.autoScrollX, AUTO_SCROLL_MAX_VELOCITY), ghostRect, parentRect, scrollRect, HORIZONTAL_DIMENSIONS));
736
+ const deltaScrollY = easeInCubic(this.checkLimits(this.autoScrollY < 0 ? Math.max(this.autoScrollY, -AUTO_SCROLL_MAX_VELOCITY) : Math.min(this.autoScrollY, AUTO_SCROLL_MAX_VELOCITY), ghostRect, parentRect, scrollRect, VERTICAL_DIMENSIONS));
737
+ const willScroll = deltaScrollX !== 0 || deltaScrollY !== 0;
738
+ if (willScroll) {
739
+ scrollContainer.scroll((isNaN(scrollContainer.scrollLeft) ? scrollContainer.pageXOffset : scrollContainer.scrollLeft) + deltaScrollX, (isNaN(scrollContainer.scrollTop) ? scrollContainer.pageYOffset : scrollContainer.scrollTop) + deltaScrollY);
740
+ }
741
+ this.autoScrollAnimation = 0;
742
+ this.completeMove(pageX, pageY);
743
+ if (willScroll) {
744
+ this.startAutoScroll(pageX + (scrollContainer === window ? deltaScrollX : 0), pageY + (scrollContainer === window ? deltaScrollY : 0), scrollContainer);
745
+ }
746
+ });
747
+ } else {
748
+ this.completeMove(pageX, pageY);
749
+ }
750
+ };
751
+ this.stopAutoScroll = () => {
752
+ window.cancelAnimationFrame(this.autoScrollAnimation);
753
+ this.autoScrollAnimation = 0;
754
+ };
755
+ this.dragEnd = () => {
756
+ window.removeEventListener('touchmove', this.touchMove);
757
+ window.removeEventListener('mousemove', this.mouseMove);
758
+ window.removeEventListener('mouseup', this.dragEnd);
759
+ window.removeEventListener('touchend', this.dragEnd);
760
+ window.removeEventListener('visibilitychange', this.dragEnd);
761
+ window.removeEventListener('blur', this.dragEnd);
762
+ window.removeEventListener('selectstart', this.disableSelect);
763
+ this.stopAutoScroll();
764
+ this.props.setDragRef && this.props.setDragRef(null);
765
+ clearTimeout(this.holdTouchTimer);
766
+ // Wired to mouseup, touchend, visibilitychange and blur, so this can fire several
767
+ // times for one drag. Only the first call owns the session and completes it.
768
+ const session = this.activeSession;
769
+ if (!session) {
770
+ return;
771
+ }
772
+ this.activeSession = null;
773
+ session.dragInfo = this.state.dragInfo;
774
+ const ghost = session.ghost;
775
+ const {
776
+ activeDroppable,
777
+ activeIndex
778
+ } = session.dragInfo;
779
+ const finalPosition = activeDroppable && activeDroppable.getPosition(activeIndex, this.getScrollPosition());
780
+ if (activeDroppable && ghost && finalPosition) {
781
+ const {
782
+ marginTop,
783
+ marginLeft,
784
+ left,
785
+ top
786
+ } = window.getComputedStyle(ghost);
787
+ const finalLeft = finalPosition.x - Math.max(1, finalPosition.width) / 2 - parseInt(left) - parseInt(marginLeft);
788
+ const finalTop = finalPosition.y - Math.max(1, finalPosition.height) / 2 - parseInt(top) - parseInt(marginTop);
789
+ ghost.style.transition = `transform 300ms ease-in-out 0ms, opacity 300ms ease-in-out 0ms`;
790
+ const newTransform = `translate(${finalLeft}px,${finalTop}px)`;
791
+ if ((ghost.style.transform || "").replace(/\s/g, '') === newTransform) {
792
+ this.stopMoving(session);
793
+ } else {
794
+ ghost.style.transform = newTransform;
795
+ session.onTransitionEnd = () => this.stopMoving(session);
796
+ ghost.addEventListener('transitionend', session.onTransitionEnd);
797
+ session.endTimeout = setTimeout(session.onTransitionEnd, 300);
798
+ }
799
+ } else {
800
+ this.stopMoving(session);
801
+ }
802
+ };
803
+ this.addDroppable = el => {
804
+ this.droppables[el.props.group] = (this.droppables[el.props.group] || []).concat(el);
805
+ };
806
+ this.remoevDroppable = el => {
807
+ this.droppables[el.props.group] = this.droppables[el.props.group].filter(_ => _ !== el);
808
+ };
809
+ this.mouseDown = draggable => normalizeMouse(this.dragStart(draggable), this.dragEnd);
810
+ this.mouseMove = normalizeMouse(this.dragMove, this.dragEnd);
811
+ this.touchStart = draggable => normalizeTouch(this.dragStart(draggable), this.dragEnd);
812
+ this.touchMove = normalizeTouch(this.dragMove, this.dragEnd);
813
+ this.providerValue = {};
814
+ this.providerEvents = draggable => ({
815
+ onMouseDown: this.mouseDown(draggable),
816
+ onTouchStart: this.touchStart(draggable)
817
+ });
818
+ }
819
+ componentDidMount() {
820
+ this.parent.addEventListener('touchmove', this.preventDefault);
821
+ }
822
+ componentWillUnmount() {
823
+ this.parent.removeEventListener('touchmove', this.preventDefault);
824
+ }
825
+ componentDidUpdate(_, prevState) {
826
+ if (!isNaN(this.lastScrollTop) || !isNaN(this.lastScrollLeft)) {
827
+ this.getScrollContainer().scroll(this.lastScrollLeft, this.lastScrollTop);
828
+ this.lastScrollLeft = this.lastScrollTop = undefined;
829
+ }
830
+ if (this.ghost && this.ghost.parentNode) {
831
+ this.ghost.parentNode.appendChild(this.ghost);
832
+ }
833
+ if (this.state.dragInfo !== prevState.dragInfo) {
834
+ this.resetPositions();
835
+ }
836
+ }
837
+ disableSelect(event) {
838
+ event.preventDefault();
839
+ }
840
+ render() {
841
+ const _this$props2 = this.props,
842
+ {
843
+ setItemOrder,
844
+ noResistance,
845
+ animation,
846
+ timing,
847
+ disabled,
848
+ list,
849
+ ghostScale,
850
+ setDragRef,
851
+ scrollOnDrag,
852
+ holdTouchTimer,
853
+ children
854
+ } = _this$props2,
855
+ rest = _objectWithoutProperties(_this$props2, _excluded2);
856
+ const {
857
+ saving,
858
+ dragInfo
859
+ } = this.state;
860
+ this.providerValue = _assign(this.providerValue, {
861
+ addDroppable: this.addDroppable,
862
+ removeDroppable: this.remoevDroppable,
863
+ dragInfo: saving ? saving.dragInfo : dragInfo,
864
+ eventHandlers: this.providerEvents
865
+ });
866
+ if (this.scrollContainer) {
867
+ const scrollContainer = this.getScrollContainer();
868
+ this.lastScrollTop = (isNaN(scrollContainer['scrollTop']) ? scrollContainer['pageYOffset'] : scrollContainer['scrollTop']) || undefined;
869
+ this.lastScrollLeft = (isNaN(scrollContainer['scrollLeft']) ? scrollContainer['pageXOffset'] : scrollContainer['scrollLeft']) || undefined;
870
+ }
871
+ return /*#__PURE__*/React.createElement(Provider, {
872
+ value: this.providerValue
873
+ }, /*#__PURE__*/React.createElement("div", _extends({}, rest, {
874
+ ref: this.setOffsetParent
875
+ }), /*#__PURE__*/React.createElement(DroppableContainer, {
876
+ animation: animation,
877
+ timing: timing,
878
+ list: saving ? saving.list : list,
879
+ placeholder: false
880
+ }, saving ? saving.children : children)));
881
+ }
882
+ }
883
+
884
+ // type GhostDimensions = { offsetX: number, offsetY: number, width: number, height: number }
885
+ DraggableContainer.defaultProps = {
886
+ holdTouchTimer: 500,
887
+ scrollOnDrag: true,
888
+ setDragRef: () => {}
889
+ };
890
+
891
+ export { DraggableContainer, DraggableItem, DroppableContainer };
892
+ //# sourceMappingURL=Draggable.mjs.map