@os-design/drag-sort 1.0.30 → 1.0.32

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 (178) hide show
  1. package/dist/DragAndDrop.d.ts +52 -0
  2. package/dist/DragAndDrop.d.ts.map +1 -0
  3. package/dist/{esm/DragAndDrop.js → DragAndDrop.js} +26 -24
  4. package/dist/Draggable.d.ts +42 -0
  5. package/dist/Draggable.d.ts.map +1 -0
  6. package/dist/{esm/Draggable.js → Draggable.js} +12 -10
  7. package/dist/Droppable.d.ts +38 -0
  8. package/dist/Droppable.d.ts.map +1 -0
  9. package/dist/{esm/Droppable.js → Droppable.js} +13 -12
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +6 -0
  12. package/dist/utils/ListStore.d.ts +22 -0
  13. package/dist/utils/ListStore.d.ts.map +1 -0
  14. package/dist/{esm/utils → utils}/ListStore.js +1 -2
  15. package/dist/utils/NodeList.d.ts +104 -0
  16. package/dist/utils/NodeList.d.ts.map +1 -0
  17. package/dist/{esm/utils → utils}/NodeList.js +2 -3
  18. package/dist/utils/getElementOffset.d.ts.map +1 -0
  19. package/dist/{esm/utils → utils}/getElementOffset.js +1 -2
  20. package/dist/utils/getElementScroll.d.ts.map +1 -0
  21. package/dist/{esm/utils → utils}/getElementScroll.js +1 -2
  22. package/dist/{types/utils → utils}/getNodeRect.d.ts +4 -1
  23. package/dist/utils/getNodeRect.d.ts.map +1 -0
  24. package/dist/{esm/utils → utils}/getNodeRect.js +3 -5
  25. package/dist/utils/useAppendClassName.d.ts +7 -0
  26. package/dist/utils/useAppendClassName.d.ts.map +1 -0
  27. package/dist/{esm/utils → utils}/useAppendClassName.js +1 -2
  28. package/dist/{types/utils → utils}/useBlankNode.d.ts +4 -0
  29. package/dist/utils/useBlankNode.d.ts.map +1 -0
  30. package/dist/{esm/utils → utils}/useBlankNode.js +1 -2
  31. package/dist/{types/utils → utils}/useDragAndDrop.d.ts +3 -3
  32. package/dist/utils/useDragAndDrop.d.ts.map +1 -0
  33. package/dist/{esm/utils → utils}/useDragAndDrop.js +1 -2
  34. package/dist/{types/utils → utils}/useDragEffect.d.ts +3 -3
  35. package/dist/utils/useDragEffect.d.ts.map +1 -0
  36. package/dist/{esm/utils → utils}/useDragEffect.js +9 -14
  37. package/dist/{types/utils → utils}/useDroppable.d.ts +2 -2
  38. package/dist/utils/useDroppable.d.ts.map +1 -0
  39. package/dist/{esm/utils → utils}/useDroppable.js +1 -2
  40. package/dist/utils/useGeneratedId.d.ts.map +1 -0
  41. package/dist/{esm/utils → utils}/useGeneratedId.js +1 -2
  42. package/dist/{types/utils → utils}/useGetNodeStyle.d.ts +1 -1
  43. package/dist/utils/useGetNodeStyle.d.ts.map +1 -0
  44. package/dist/{esm/utils → utils}/useGetNodeStyle.js +1 -2
  45. package/dist/{types/utils → utils}/useInitRect.d.ts +1 -1
  46. package/dist/utils/useInitRect.d.ts.map +1 -0
  47. package/dist/{esm/utils → utils}/useInitRect.js +1 -2
  48. package/dist/{types/utils → utils}/useInitScrollOffset.d.ts +1 -1
  49. package/dist/utils/useInitScrollOffset.d.ts.map +1 -0
  50. package/dist/{esm/utils → utils}/useInitScrollOffset.js +2 -3
  51. package/dist/{types/utils → utils}/useMoveNode.d.ts +3 -4
  52. package/dist/utils/useMoveNode.d.ts.map +1 -0
  53. package/dist/{esm/utils → utils}/useMoveNode.js +2 -5
  54. package/dist/utils/useScrollEventByPoint.d.ts +11 -0
  55. package/dist/utils/useScrollEventByPoint.d.ts.map +1 -0
  56. package/dist/{esm/utils → utils}/useScrollEventByPoint.js +1 -2
  57. package/dist/{types/utils → utils}/useTargetList.d.ts +2 -2
  58. package/dist/utils/useTargetList.d.ts.map +1 -0
  59. package/dist/{esm/utils → utils}/useTargetList.js +2 -3
  60. package/dist/{types/utils → utils}/useTransitionStyle.d.ts +3 -0
  61. package/dist/utils/useTransitionStyle.d.ts.map +1 -0
  62. package/dist/{esm/utils → utils}/useTransitionStyle.js +1 -2
  63. package/package.json +16 -17
  64. package/src/DragAndDrop.tsx +10 -10
  65. package/src/Draggable.tsx +5 -5
  66. package/src/Droppable.tsx +6 -6
  67. package/src/utils/NodeList.ts +2 -2
  68. package/src/utils/getNodeRect.ts +1 -1
  69. package/src/utils/useAppendClassName.ts +1 -1
  70. package/src/utils/useBlankNode.ts +1 -1
  71. package/src/utils/useDragAndDrop.ts +3 -3
  72. package/src/utils/useDragEffect.ts +8 -7
  73. package/src/utils/useDroppable.ts +2 -2
  74. package/src/utils/useGetNodeStyle.ts +1 -1
  75. package/src/utils/useInitRect.ts +1 -1
  76. package/src/utils/useInitScrollOffset.ts +1 -1
  77. package/src/utils/useMoveNode.ts +3 -5
  78. package/src/utils/useTargetList.ts +2 -2
  79. package/dist/cjs/DragAndDrop.js +0 -181
  80. package/dist/cjs/DragAndDrop.js.map +0 -1
  81. package/dist/cjs/Draggable.js +0 -81
  82. package/dist/cjs/Draggable.js.map +0 -1
  83. package/dist/cjs/Droppable.js +0 -98
  84. package/dist/cjs/Droppable.js.map +0 -1
  85. package/dist/cjs/index.js +0 -68
  86. package/dist/cjs/index.js.map +0 -1
  87. package/dist/cjs/utils/ListStore.js +0 -61
  88. package/dist/cjs/utils/ListStore.js.map +0 -1
  89. package/dist/cjs/utils/NodeList.js +0 -228
  90. package/dist/cjs/utils/NodeList.js.map +0 -1
  91. package/dist/cjs/utils/getElementOffset.js +0 -22
  92. package/dist/cjs/utils/getElementOffset.js.map +0 -1
  93. package/dist/cjs/utils/getElementScroll.js +0 -22
  94. package/dist/cjs/utils/getElementScroll.js.map +0 -1
  95. package/dist/cjs/utils/getNodeRect.js +0 -38
  96. package/dist/cjs/utils/getNodeRect.js.map +0 -1
  97. package/dist/cjs/utils/useAppendClassName.js +0 -23
  98. package/dist/cjs/utils/useAppendClassName.js.map +0 -1
  99. package/dist/cjs/utils/useBlankNode.js +0 -94
  100. package/dist/cjs/utils/useBlankNode.js.map +0 -1
  101. package/dist/cjs/utils/useDragAndDrop.js +0 -22
  102. package/dist/cjs/utils/useDragAndDrop.js.map +0 -1
  103. package/dist/cjs/utils/useDragEffect.js +0 -468
  104. package/dist/cjs/utils/useDragEffect.js.map +0 -1
  105. package/dist/cjs/utils/useDroppable.js +0 -25
  106. package/dist/cjs/utils/useDroppable.js.map +0 -1
  107. package/dist/cjs/utils/useGeneratedId.js +0 -14
  108. package/dist/cjs/utils/useGeneratedId.js.map +0 -1
  109. package/dist/cjs/utils/useGetNodeStyle.js +0 -24
  110. package/dist/cjs/utils/useGetNodeStyle.js.map +0 -1
  111. package/dist/cjs/utils/useInitRect.js +0 -21
  112. package/dist/cjs/utils/useInitRect.js.map +0 -1
  113. package/dist/cjs/utils/useInitScrollOffset.js +0 -21
  114. package/dist/cjs/utils/useInitScrollOffset.js.map +0 -1
  115. package/dist/cjs/utils/useMoveNode.js +0 -90
  116. package/dist/cjs/utils/useMoveNode.js.map +0 -1
  117. package/dist/cjs/utils/useScrollEventByPoint.js +0 -57
  118. package/dist/cjs/utils/useScrollEventByPoint.js.map +0 -1
  119. package/dist/cjs/utils/useTargetList.js +0 -44
  120. package/dist/cjs/utils/useTargetList.js.map +0 -1
  121. package/dist/cjs/utils/useTransitionStyle.js +0 -26
  122. package/dist/cjs/utils/useTransitionStyle.js.map +0 -1
  123. package/dist/esm/DragAndDrop.js.map +0 -1
  124. package/dist/esm/Draggable.js.map +0 -1
  125. package/dist/esm/Droppable.js.map +0 -1
  126. package/dist/esm/index.js +0 -7
  127. package/dist/esm/index.js.map +0 -1
  128. package/dist/esm/utils/ListStore.js.map +0 -1
  129. package/dist/esm/utils/NodeList.js.map +0 -1
  130. package/dist/esm/utils/getElementOffset.js.map +0 -1
  131. package/dist/esm/utils/getElementScroll.js.map +0 -1
  132. package/dist/esm/utils/getNodeRect.js.map +0 -1
  133. package/dist/esm/utils/useAppendClassName.js.map +0 -1
  134. package/dist/esm/utils/useBlankNode.js.map +0 -1
  135. package/dist/esm/utils/useDragAndDrop.js.map +0 -1
  136. package/dist/esm/utils/useDragEffect.js.map +0 -1
  137. package/dist/esm/utils/useDroppable.js.map +0 -1
  138. package/dist/esm/utils/useGeneratedId.js.map +0 -1
  139. package/dist/esm/utils/useGetNodeStyle.js.map +0 -1
  140. package/dist/esm/utils/useInitRect.js.map +0 -1
  141. package/dist/esm/utils/useInitScrollOffset.js.map +0 -1
  142. package/dist/esm/utils/useMoveNode.js.map +0 -1
  143. package/dist/esm/utils/useScrollEventByPoint.js.map +0 -1
  144. package/dist/esm/utils/useTargetList.js.map +0 -1
  145. package/dist/esm/utils/useTransitionStyle.js.map +0 -1
  146. package/dist/types/DragAndDrop.d.ts +0 -17
  147. package/dist/types/DragAndDrop.d.ts.map +0 -1
  148. package/dist/types/Draggable.d.ts +0 -18
  149. package/dist/types/Draggable.d.ts.map +0 -1
  150. package/dist/types/Droppable.d.ts +0 -15
  151. package/dist/types/Droppable.d.ts.map +0 -1
  152. package/dist/types/index.d.ts.map +0 -1
  153. package/dist/types/utils/ListStore.d.ts +0 -10
  154. package/dist/types/utils/ListStore.d.ts.map +0 -1
  155. package/dist/types/utils/NodeList.d.ts +0 -44
  156. package/dist/types/utils/NodeList.d.ts.map +0 -1
  157. package/dist/types/utils/getElementOffset.d.ts.map +0 -1
  158. package/dist/types/utils/getElementScroll.d.ts.map +0 -1
  159. package/dist/types/utils/getNodeRect.d.ts.map +0 -1
  160. package/dist/types/utils/useAppendClassName.d.ts +0 -4
  161. package/dist/types/utils/useAppendClassName.d.ts.map +0 -1
  162. package/dist/types/utils/useBlankNode.d.ts.map +0 -1
  163. package/dist/types/utils/useDragAndDrop.d.ts.map +0 -1
  164. package/dist/types/utils/useDragEffect.d.ts.map +0 -1
  165. package/dist/types/utils/useDroppable.d.ts.map +0 -1
  166. package/dist/types/utils/useGeneratedId.d.ts.map +0 -1
  167. package/dist/types/utils/useGetNodeStyle.d.ts.map +0 -1
  168. package/dist/types/utils/useInitRect.d.ts.map +0 -1
  169. package/dist/types/utils/useInitScrollOffset.d.ts.map +0 -1
  170. package/dist/types/utils/useMoveNode.d.ts.map +0 -1
  171. package/dist/types/utils/useScrollEventByPoint.d.ts +0 -7
  172. package/dist/types/utils/useScrollEventByPoint.d.ts.map +0 -1
  173. package/dist/types/utils/useTargetList.d.ts.map +0 -1
  174. package/dist/types/utils/useTransitionStyle.d.ts.map +0 -1
  175. /package/dist/{types/index.d.ts → index.d.ts} +0 -0
  176. /package/dist/{types/utils → utils}/getElementOffset.d.ts +0 -0
  177. /package/dist/{types/utils → utils}/getElementScroll.d.ts +0 -0
  178. /package/dist/{types/utils → utils}/useGeneratedId.d.ts +0 -0
@@ -1,181 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports["default"] = void 0;
8
- var _portal = _interopRequireDefault(require("@os-design/portal"));
9
- var _useAutoScroll = _interopRequireDefault(require("@os-design/use-auto-scroll"));
10
- var _useDrag2 = _interopRequireDefault(require("@os-design/use-drag"));
11
- var _useMemoObject = _interopRequireDefault(require("@os-design/use-memo-object"));
12
- var _usePreventDefaultEvent = _interopRequireDefault(require("@os-design/use-prevent-default-event"));
13
- var _react = _interopRequireWildcard(require("react"));
14
- var _ListStore = _interopRequireDefault(require("./utils/ListStore"));
15
- var _useDragAndDrop = require("./utils/useDragAndDrop");
16
- var _useDragEffect = _interopRequireDefault(require("./utils/useDragEffect"));
17
- var _useGeneratedId = _interopRequireDefault(require("./utils/useGeneratedId"));
18
- var _useInitRect = _interopRequireDefault(require("./utils/useInitRect"));
19
- var _useTransitionStyle = _interopRequireDefault(require("./utils/useTransitionStyle"));
20
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
21
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
24
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
25
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
26
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
27
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
28
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
29
- /**
30
- * The container containing one or more lists with draggable nodes.
31
- */
32
- var DragAndDrop = function DragAndDrop(_ref) {
33
- var draggedNodeContainer = _ref.draggedNodeContainer,
34
- _ref$minMouseDistPx = _ref.minMouseDistPx,
35
- minMouseDistPx = _ref$minMouseDistPx === void 0 ? 10 : _ref$minMouseDistPx,
36
- _ref$longPressMs = _ref.longPressMs,
37
- longPressMs = _ref$longPressMs === void 0 ? 500 : _ref$longPressMs,
38
- _ref$autoScrollDistPe = _ref.autoScrollDistPercent,
39
- autoScrollDistPercent = _ref$autoScrollDistPe === void 0 ? 20 : _ref$autoScrollDistPe,
40
- _ref$autoScrollMaxSpe = _ref.autoScrollMaxSpeedPx,
41
- autoScrollMaxSpeedPx = _ref$autoScrollMaxSpe === void 0 ? 100 : _ref$autoScrollMaxSpe,
42
- _ref$transitionDelayM = _ref.transitionDelayMs,
43
- transitionDelayMs = _ref$transitionDelayM === void 0 ? 250 : _ref$transitionDelayM,
44
- _ref$onDragEnd = _ref.onDragEnd,
45
- onDragEnd = _ref$onDragEnd === void 0 ? function () {} : _ref$onDragEnd,
46
- children = _ref.children;
47
- // The user can drag a node between the lists (the Droppable components).
48
- // To determine which list a node should be dropped in, we need to store refs to all the lists.
49
- var listStoreRef = (0, _react.useRef)(new _ListStore["default"]());
50
-
51
- // The class name for a node used to set the transition style
52
- var generatedId = (0, _useGeneratedId["default"])();
53
- var nodeClassName = (0, _react.useMemo)(function () {
54
- return "n".concat(generatedId);
55
- }, [generatedId]);
56
-
57
- // The node that is currently being dragged
58
- var _useState = (0, _react.useState)(null),
59
- _useState2 = _slicedToArray(_useState, 2),
60
- draggedNode = _useState2[0],
61
- setDraggedNode = _useState2[1];
62
- var startNodeRef = (0, _react.useRef)(null);
63
- var _useState3 = (0, _react.useState)({
64
- x: 0,
65
- y: 0
66
- }),
67
- _useState4 = _slicedToArray(_useState3, 2),
68
- cursorPosition = _useState4[0],
69
- setCursorPosition = _useState4[1];
70
-
71
- // Add a new list to the store
72
- var registerList = (0, _react.useCallback)(function (list) {
73
- listStoreRef.current.add(list);
74
- }, []);
75
-
76
- // Remove the existing list from the store
77
- var deregisterList = (0, _react.useCallback)(function (id) {
78
- listStoreRef.current.remove(id);
79
- }, []);
80
-
81
- // Set the style to delay transitions when the node is dragging
82
- (0, _useTransitionStyle["default"])({
83
- className: nodeClassName,
84
- ms: transitionDelayMs,
85
- enabled: !!draggedNode
86
- });
87
- var onDragStart = (0, _react.useCallback)(function (pos, startPos) {
88
- var startNode = startNodeRef.current;
89
- if (!startNode) return;
90
- var _startNode$node = _slicedToArray(startNode.node, 3),
91
- nodeRef = _startNode$node[2];
92
- if (!nodeRef.current) return;
93
- var rect = nodeRef.current.getBoundingClientRect();
94
- setCursorPosition(pos);
95
- setDraggedNode({
96
- list: startNode.list,
97
- node: startNode.node,
98
- position: {
99
- x: startPos.x - rect.x,
100
- y: startPos.y - rect.y
101
- }
102
- });
103
- startNodeRef.current = null;
104
- }, []);
105
- var onDragMove = (0, _react.useCallback)(function (pos) {
106
- setCursorPosition(pos);
107
- }, []);
108
- var dragEndHandler = (0, _react.useCallback)(function () {
109
- setDraggedNode(null);
110
- }, []);
111
- var _useDrag = (0, _useDrag2["default"])({
112
- onDragStart: onDragStart,
113
- onDragMove: onDragMove,
114
- onDragEnd: dragEndHandler,
115
- minMouseDistPx: minMouseDistPx,
116
- longPressMs: longPressMs
117
- }),
118
- onMouseDown = _useDrag.onMouseDown,
119
- onTouchStart = _useDrag.onTouchStart;
120
-
121
- // Handlers that determine whether a user clicks on the node
122
- var mouseDownHandler = (0, _react.useCallback)(function (e, list, node) {
123
- startNodeRef.current = {
124
- list: list,
125
- node: node
126
- };
127
- onMouseDown(e);
128
- }, [onMouseDown]);
129
- var touchStartHandler = (0, _react.useCallback)(function (e, list, node) {
130
- startNodeRef.current = {
131
- list: list,
132
- node: node
133
- };
134
- onTouchStart(e);
135
- }, [onTouchStart]);
136
-
137
- // Prevent body scrolling when the node is dragging.
138
- // It's important to attach the event to the body (not to the document). Otherwise, it won't work in mobile chrome.
139
- (0, _usePreventDefaultEvent["default"])(document.body, 'touchmove', !!draggedNode);
140
-
141
- // Implement the drag animation
142
- (0, _useDragEffect["default"])({
143
- draggedNode: draggedNode,
144
- cursorPosition: cursorPosition,
145
- listStoreRef: listStoreRef,
146
- onDragEnd: onDragEnd
147
- });
148
-
149
- // Auto scroll if the cursor position is located near the border
150
- (0, _useAutoScroll["default"])({
151
- enabled: !!draggedNode,
152
- distPercent: autoScrollDistPercent,
153
- maxSpeedPx: autoScrollMaxSpeedPx
154
- });
155
- var initRect = (0, _useInitRect["default"])(draggedNode ? draggedNode.node[2] : undefined);
156
- var dragAndDropContext = (0, _useMemoObject["default"])({
157
- registerList: registerList,
158
- deregisterList: deregisterList,
159
- onMouseDown: mouseDownHandler,
160
- onTouchStart: touchStartHandler,
161
- nodeClassName: nodeClassName
162
- });
163
- return /*#__PURE__*/_react["default"].createElement(_useDragAndDrop.DragAndDropContext.Provider, {
164
- value: dragAndDropContext
165
- }, children, draggedNode && /*#__PURE__*/_react["default"].createElement(_portal["default"], {
166
- container: draggedNodeContainer
167
- }, draggedNode.list.renderDraggedNode({
168
- index: draggedNode.node[4],
169
- id: draggedNode.node[5],
170
- style: {
171
- position: 'fixed',
172
- left: cursorPosition.x - draggedNode.position.x,
173
- top: cursorPosition.y - draggedNode.position.y,
174
- width: initRect ? initRect.initWidth : undefined,
175
- height: initRect ? initRect.initHeight : undefined,
176
- zIndex: 1001
177
- }
178
- })));
179
- };
180
- var _default = exports["default"] = DragAndDrop;
181
- //# sourceMappingURL=DragAndDrop.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DragAndDrop.js","names":["_portal","_interopRequireDefault","require","_useAutoScroll","_useDrag2","_useMemoObject","_usePreventDefaultEvent","_react","_interopRequireWildcard","_ListStore","_useDragAndDrop","_useDragEffect","_useGeneratedId","_useInitRect","_useTransitionStyle","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","obj","_slicedToArray","arr","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","o","minLen","_arrayLikeToArray","prototype","toString","slice","constructor","name","Array","from","test","len","length","arr2","l","Symbol","iterator","f","next","done","push","value","isArray","DragAndDrop","_ref","draggedNodeContainer","_ref$minMouseDistPx","minMouseDistPx","_ref$longPressMs","longPressMs","_ref$autoScrollDistPe","autoScrollDistPercent","_ref$autoScrollMaxSpe","autoScrollMaxSpeedPx","_ref$transitionDelayM","transitionDelayMs","_ref$onDragEnd","onDragEnd","children","listStoreRef","useRef","ListStore","generatedId","useGeneratedId","nodeClassName","useMemo","concat","_useState","useState","_useState2","draggedNode","setDraggedNode","startNodeRef","_useState3","x","y","_useState4","cursorPosition","setCursorPosition","registerList","useCallback","list","current","add","deregisterList","id","remove","useTransitionStyle","className","ms","enabled","onDragStart","pos","startPos","startNode","_startNode$node","node","nodeRef","rect","getBoundingClientRect","position","onDragMove","dragEndHandler","_useDrag","useDrag","onMouseDown","onTouchStart","mouseDownHandler","touchStartHandler","usePreventDefaultEvent","document","body","useDragEffect","useAutoScroll","distPercent","maxSpeedPx","initRect","useInitRect","undefined","dragAndDropContext","useMemoObject","createElement","DragAndDropContext","Provider","container","renderDraggedNode","index","style","left","top","width","initWidth","height","initHeight","zIndex","_default","exports"],"sources":["../../src/DragAndDrop.tsx"],"sourcesContent":["import Portal, { PortalProps } from '@os-design/portal';\nimport useAutoScroll from '@os-design/use-auto-scroll';\nimport useDrag, {\n OnDragEnd,\n OnDragMove,\n OnDragStart,\n Position,\n} from '@os-design/use-drag';\nimport useMemoObject from '@os-design/use-memo-object';\nimport usePreventDefaultEvent from '@os-design/use-prevent-default-event';\nimport React, {\n MouseEvent,\n TouchEvent,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport ListStore from './utils/ListStore';\nimport NodeList, { ExistingNode } from './utils/NodeList';\nimport { DragAndDropContext } from './utils/useDragAndDrop';\nimport useDragEffect, {\n DragEndHandler,\n DraggedNode,\n} from './utils/useDragEffect';\nimport useGeneratedId from './utils/useGeneratedId';\nimport useInitRect from './utils/useInitRect';\nimport useTransitionStyle from './utils/useTransitionStyle';\n\nexport interface DragAndDropProps {\n /**\n * The container in which the dragged node will be rendered.\n * @default document.body\n */\n draggedNodeContainer?: PortalProps['container'];\n /**\n * The min distance required to start dragging a node (in px).\n * @default 10\n */\n minMouseDistPx?: number;\n /**\n * The delay of the long press event required to start dragging a node on the touch device (in ms).\n * @default 500\n */\n longPressMs?: number;\n /**\n * The distance to the bound at which the list starts to scroll automatically (in percent).\n * @default 20\n */\n autoScrollDistPercent?: number;\n /**\n * The max auto scroll speed (in px).\n * @default 100\n */\n autoScrollMaxSpeedPx?: number;\n /**\n * The animation duration (in ms).\n * @default 250\n */\n transitionDelayMs?: number;\n /**\n * The callback that is called when the drag is completed.\n * @default undefined\n */\n onDragEnd?: DragEndHandler;\n /**\n * The children.\n * @default undefined\n */\n children?: React.ReactNode;\n}\n\ninterface StartNode {\n list: NodeList;\n node: ExistingNode;\n}\n\n/**\n * The container containing one or more lists with draggable nodes.\n */\nconst DragAndDrop: React.FC<DragAndDropProps> = ({\n draggedNodeContainer,\n minMouseDistPx = 10,\n longPressMs = 500,\n autoScrollDistPercent = 20,\n autoScrollMaxSpeedPx = 100,\n transitionDelayMs = 250,\n onDragEnd = () => {},\n children,\n}) => {\n // The user can drag a node between the lists (the Droppable components).\n // To determine which list a node should be dropped in, we need to store refs to all the lists.\n const listStoreRef = useRef<ListStore>(new ListStore());\n\n // The class name for a node used to set the transition style\n const generatedId = useGeneratedId();\n const nodeClassName = useMemo(() => `n${generatedId}`, [generatedId]);\n\n // The node that is currently being dragged\n const [draggedNode, setDraggedNode] = useState<DraggedNode | null>(null);\n const startNodeRef = useRef<StartNode | null>(null);\n const [cursorPosition, setCursorPosition] = useState<Position>({\n x: 0,\n y: 0,\n });\n\n // Add a new list to the store\n const registerList = useCallback((list: NodeList) => {\n listStoreRef.current.add(list);\n }, []);\n\n // Remove the existing list from the store\n const deregisterList = useCallback((id: string) => {\n listStoreRef.current.remove(id);\n }, []);\n\n // Set the style to delay transitions when the node is dragging\n useTransitionStyle({\n className: nodeClassName,\n ms: transitionDelayMs,\n enabled: !!draggedNode,\n });\n\n const onDragStart = useCallback<OnDragStart>(\n (pos: Position, startPos: Position) => {\n const startNode = startNodeRef.current;\n if (!startNode) return;\n const [, , nodeRef] = startNode.node;\n if (!nodeRef.current) return;\n const rect = nodeRef.current.getBoundingClientRect();\n setCursorPosition(pos);\n setDraggedNode({\n list: startNode.list,\n node: startNode.node,\n position: {\n x: startPos.x - rect.x,\n y: startPos.y - rect.y,\n },\n });\n startNodeRef.current = null;\n },\n []\n );\n\n const onDragMove = useCallback<OnDragMove>((pos: Position) => {\n setCursorPosition(pos);\n }, []);\n\n const dragEndHandler = useCallback<OnDragEnd>(() => {\n setDraggedNode(null);\n }, []);\n\n const { onMouseDown, onTouchStart } = useDrag({\n onDragStart,\n onDragMove,\n onDragEnd: dragEndHandler,\n minMouseDistPx,\n longPressMs,\n });\n\n // Handlers that determine whether a user clicks on the node\n const mouseDownHandler = useCallback(\n (e: MouseEvent, list: NodeList, node: ExistingNode) => {\n startNodeRef.current = { list, node };\n onMouseDown(e);\n },\n [onMouseDown]\n );\n const touchStartHandler = useCallback(\n (e: TouchEvent, list: NodeList, node: ExistingNode) => {\n startNodeRef.current = { list, node };\n onTouchStart(e);\n },\n [onTouchStart]\n );\n\n // Prevent body scrolling when the node is dragging.\n // It's important to attach the event to the body (not to the document). Otherwise, it won't work in mobile chrome.\n usePreventDefaultEvent(document.body, 'touchmove', !!draggedNode);\n\n // Implement the drag animation\n useDragEffect({\n draggedNode,\n cursorPosition,\n listStoreRef,\n onDragEnd,\n });\n\n // Auto scroll if the cursor position is located near the border\n useAutoScroll({\n enabled: !!draggedNode,\n distPercent: autoScrollDistPercent,\n maxSpeedPx: autoScrollMaxSpeedPx,\n });\n\n const initRect = useInitRect(draggedNode ? draggedNode.node[2] : undefined);\n\n const dragAndDropContext = useMemoObject({\n registerList,\n deregisterList,\n onMouseDown: mouseDownHandler,\n onTouchStart: touchStartHandler,\n nodeClassName,\n });\n\n return (\n <DragAndDropContext.Provider value={dragAndDropContext}>\n {children}\n\n {draggedNode && (\n <Portal container={draggedNodeContainer}>\n {draggedNode.list.renderDraggedNode({\n index: draggedNode.node[4],\n id: draggedNode.node[5],\n style: {\n position: 'fixed',\n left: cursorPosition.x - draggedNode.position.x,\n top: cursorPosition.y - draggedNode.position.y,\n width: initRect ? initRect.initWidth : undefined,\n height: initRect ? initRect.initHeight : undefined,\n zIndex: 1001,\n },\n })}\n </Portal>\n )}\n </DragAndDropContext.Provider>\n );\n};\n\nexport type { DragEndHandler } from './utils/useDragEffect';\n\nexport default DragAndDrop;\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAH,sBAAA,CAAAC,OAAA;AAMA,IAAAG,cAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,uBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,MAAA,GAAAC,uBAAA,CAAAN,OAAA;AAQA,IAAAO,UAAA,GAAAR,sBAAA,CAAAC,OAAA;AAEA,IAAAQ,eAAA,GAAAR,OAAA;AACA,IAAAS,cAAA,GAAAV,sBAAA,CAAAC,OAAA;AAIA,IAAAU,eAAA,GAAAX,sBAAA,CAAAC,OAAA;AACA,IAAAW,YAAA,GAAAZ,sBAAA,CAAAC,OAAA;AACA,IAAAY,mBAAA,GAAAb,sBAAA,CAAAC,OAAA;AAA4D,SAAAa,yBAA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F,CAAC,CAAC;EAEF,oBACEhF,MAAA,YAAAyI,aAAA,CAACtI,eAAA,CAAAuI,kBAAkB,CAACC,QAAQ;IAAClF,KAAK,EAAE8E;EAAmB,GACpD7D,QAAQ,EAERY,WAAW,iBACVtF,MAAA,YAAAyI,aAAA,CAAChJ,OAAA,WAAM;IAACmJ,SAAS,EAAE/E;EAAqB,GACrCyB,WAAW,CAACW,IAAI,CAAC4C,iBAAiB,CAAC;IAClCC,KAAK,EAAExD,WAAW,CAAC0B,IAAI,CAAC,CAAC,CAAC;IAC1BX,EAAE,EAAEf,WAAW,CAAC0B,IAAI,CAAC,CAAC,CAAC;IACvB+B,KAAK,EAAE;MACL3B,QAAQ,EAAE,OAAO;MACjB4B,IAAI,EAAEnD,cAAc,CAACH,CAAC,GAAGJ,WAAW,CAAC8B,QAAQ,CAAC1B,CAAC;MAC/CuD,GAAG,EAAEpD,cAAc,CAACF,CAAC,GAAGL,WAAW,CAAC8B,QAAQ,CAACzB,CAAC;MAC9CuD,KAAK,EAAEd,QAAQ,GAAGA,QAAQ,CAACe,SAAS,GAAGb,SAAS;MAChDc,MAAM,EAAEhB,QAAQ,GAAGA,QAAQ,CAACiB,UAAU,GAAGf,SAAS;MAClDgB,MAAM,EAAE;IACV;EACF,CAAC,CACK,CAEiB,CAAC;AAElC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,cAIa7F,WAAW","ignoreList":[]}
@@ -1,81 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports["default"] = void 0;
8
- var _useMemoObject = _interopRequireDefault(require("@os-design/use-memo-object"));
9
- var _react = _interopRequireWildcard(require("react"));
10
- var _useAppendClassName = _interopRequireDefault(require("./utils/useAppendClassName"));
11
- var _useDragAndDrop2 = _interopRequireDefault(require("./utils/useDragAndDrop"));
12
- var _useDroppable2 = _interopRequireDefault(require("./utils/useDroppable"));
13
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
14
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
17
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
18
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
19
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
20
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
21
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
22
- var Draggable = function Draggable(_ref) {
23
- var index = _ref.index,
24
- id = _ref.id,
25
- children = _ref.children;
26
- // The reference to the list item
27
- var ref = (0, _react.useRef)(null);
28
- // The reference to the node containing the refs to the prev and next nodes
29
- var nodeRef = (0, _react.useRef)(null);
30
- // Additional styles for moving the list item
31
- var _useState = (0, _react.useState)({}),
32
- _useState2 = _slicedToArray(_useState, 2),
33
- style = _useState2[0],
34
- setStyle = _useState2[1];
35
- var _useDragAndDrop = (0, _useDragAndDrop2["default"])(),
36
- nodeClassName = _useDragAndDrop.nodeClassName;
37
- var _useDroppable = (0, _useDroppable2["default"])(),
38
- registerNode = _useDroppable.registerNode,
39
- deregisterNode = _useDroppable.deregisterNode,
40
- onMouseDown = _useDroppable.onMouseDown,
41
- onTouchStart = _useDroppable.onTouchStart;
42
-
43
- // Register the node in the list
44
- (0, _react.useEffect)(function () {
45
- nodeRef.current = registerNode({
46
- ref: ref,
47
- setStyle: setStyle,
48
- index: index,
49
- id: id
50
- });
51
- return function () {
52
- if (!nodeRef.current) return;
53
- deregisterNode(nodeRef.current);
54
- nodeRef.current = null;
55
- };
56
- }, [deregisterNode, id, index, registerNode]);
57
-
58
- // Set the class name for the node to apply the transition style (see the DragAndDrop container)
59
- (0, _useAppendClassName["default"])(ref, nodeClassName);
60
-
61
- // Handlers that determine whether a user clicks on the node
62
- var mouseDownHandler = (0, _react.useCallback)(function (e) {
63
- if (!nodeRef.current) return;
64
- onMouseDown(e, nodeRef.current);
65
- }, [onMouseDown]);
66
- var touchStartHandler = (0, _react.useCallback)(function (e) {
67
- if (!nodeRef.current) return;
68
- onTouchStart(e, nodeRef.current);
69
- }, [onTouchStart]);
70
- var handlers = (0, _useMemoObject["default"])({
71
- onMouseDown: mouseDownHandler,
72
- onTouchStart: touchStartHandler
73
- });
74
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, children({
75
- ref: ref,
76
- style: style,
77
- handlers: handlers
78
- }));
79
- };
80
- var _default = exports["default"] = Draggable;
81
- //# sourceMappingURL=Draggable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Draggable.js","names":["_useMemoObject","_interopRequireDefault","require","_react","_interopRequireWildcard","_useAppendClassName","_useDragAndDrop2","_useDroppable2","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","obj","_slicedToArray","arr","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","o","minLen","_arrayLikeToArray","prototype","toString","slice","constructor","name","Array","from","test","len","length","arr2","l","Symbol","iterator","f","next","done","push","value","isArray","Draggable","_ref","index","id","children","ref","useRef","nodeRef","_useState","useState","_useState2","style","setStyle","_useDragAndDrop","useDragAndDrop","nodeClassName","_useDroppable","useDroppable","registerNode","deregisterNode","onMouseDown","onTouchStart","useEffect","current","useAppendClassName","mouseDownHandler","useCallback","touchStartHandler","handlers","useMemoObject","createElement","Fragment","_default","exports"],"sources":["../../src/Draggable.tsx"],"sourcesContent":["import useMemoObject from '@os-design/use-memo-object';\nimport React, {\n CSSProperties,\n MouseEvent,\n RefObject,\n TouchEvent,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport { Node } from './utils/NodeList';\nimport useAppendClassName from './utils/useAppendClassName';\nimport useDragAndDrop from './utils/useDragAndDrop';\nimport useDroppable from './utils/useDroppable';\n\nexport interface DraggableHandlers {\n /**\n * The handler that should be called when the mouse down event occurs.\n */\n onMouseDown: (e: MouseEvent) => void;\n /**\n * The handler that should be called when the touch start event occurs.\n */\n onTouchStart: (e: TouchEvent) => void;\n}\n\nexport interface DraggableChildrenProps {\n /**\n * The reference to the draggable list item.\n */\n ref: RefObject<any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n /**\n * Additional styles for moving the list item.\n */\n style: CSSProperties;\n /**\n * The handlers to catch events when the user starts dragging the list item.\n */\n handlers: DraggableHandlers;\n}\n\nexport interface DraggableProps {\n /**\n * The index of the draggable node.\n */\n index: number;\n /**\n * The ID of the draggable node.\n */\n id: string;\n /**\n * The function that renders the draggable node.\n */\n children: (props: DraggableChildrenProps) => React.ReactNode;\n}\n\nconst Draggable: React.FC<DraggableProps> = ({ index, id, children }) => {\n // The reference to the list item\n const ref = useRef<HTMLDivElement | null>(null);\n // The reference to the node containing the refs to the prev and next nodes\n const nodeRef = useRef<Node>(null);\n // Additional styles for moving the list item\n const [style, setStyle] = useState<CSSProperties>({});\n\n const { nodeClassName } = useDragAndDrop();\n const { registerNode, deregisterNode, onMouseDown, onTouchStart } =\n useDroppable();\n\n // Register the node in the list\n useEffect(() => {\n nodeRef.current = registerNode({ ref, setStyle, index, id });\n return () => {\n if (!nodeRef.current) return;\n deregisterNode(nodeRef.current);\n nodeRef.current = null;\n };\n }, [deregisterNode, id, index, registerNode]);\n\n // Set the class name for the node to apply the transition style (see the DragAndDrop container)\n useAppendClassName(ref, nodeClassName);\n\n // Handlers that determine whether a user clicks on the node\n const mouseDownHandler = useCallback(\n (e: MouseEvent) => {\n if (!nodeRef.current) return;\n onMouseDown(e, nodeRef.current);\n },\n [onMouseDown]\n );\n const touchStartHandler = useCallback(\n (e: TouchEvent) => {\n if (!nodeRef.current) return;\n onTouchStart(e, nodeRef.current);\n },\n [onTouchStart]\n );\n\n const handlers = useMemoObject({\n onMouseDown: mouseDownHandler,\n onTouchStart: touchStartHandler,\n });\n\n return <>{children({ ref, style, handlers })}</>;\n};\n\nexport default Draggable;\n"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OAAO,CAACgB,OAAO,CAAC;EAClC,CAAC,EACD,CAACF,YAAY,CACf,CAAC;EAED,IAAMO,QAAQ,GAAG,IAAAC,yBAAa,EAAC;IAC7BT,WAAW,EAAEK,gBAAgB;IAC7BJ,YAAY,EAAEM;EAChB,CAAC,CAAC;EAEF,oBAAOnF,MAAA,YAAAsF,aAAA,CAAAtF,MAAA,YAAAuF,QAAA,QAAG3B,QAAQ,CAAC;IAAEC,GAAG,EAAHA,GAAG;IAAEM,KAAK,EAALA,KAAK;IAAEiB,QAAQ,EAARA;EAAS,CAAC,CAAI,CAAC;AAClD,CAAC;AAAC,IAAAI,QAAA,GAAAC,OAAA,cAEajC,SAAS","ignoreList":[]}
@@ -1,98 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports["default"] = void 0;
8
- var _useMemoObject = _interopRequireDefault(require("@os-design/use-memo-object"));
9
- var _react = _interopRequireWildcard(require("react"));
10
- var _NodeList = _interopRequireDefault(require("./utils/NodeList"));
11
- var _useDragAndDrop2 = _interopRequireDefault(require("./utils/useDragAndDrop"));
12
- var _useDroppable = require("./utils/useDroppable");
13
- var _useGeneratedId = _interopRequireDefault(require("./utils/useGeneratedId"));
14
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
15
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
- var Droppable = function Droppable(_ref) {
18
- var renderDraggedNode = _ref.renderDraggedNode,
19
- id = _ref.id,
20
- _ref$horizontal = _ref.horizontal,
21
- horizontal = _ref$horizontal === void 0 ? false : _ref$horizontal,
22
- children = _ref.children;
23
- // The reference to the list
24
- var ref = (0, _react.useRef)(null);
25
- // The reference to the container inside the virtual list
26
- var innerRef = (0, _react.useRef)(null);
27
- // The unique ID of the list. If no ID was specified, the generated one is used.
28
- var generatedId = (0, _useGeneratedId["default"])();
29
- var droppableId = (0, _react.useMemo)(function () {
30
- return id || generatedId;
31
- }, [generatedId, id]);
32
- // The reference to the list of nodes
33
- var listRef = (0, _react.useRef)(new _NodeList["default"]({
34
- id: droppableId,
35
- ref: ref,
36
- innerRef: innerRef,
37
- horizontal: horizontal,
38
- renderDraggedNode: renderDraggedNode
39
- }));
40
-
41
- // Update the ID of the list if it changes
42
- (0, _react.useEffect)(function () {
43
- listRef.current.id = droppableId;
44
- }, [droppableId]);
45
-
46
- // Update the list orientation if it changes.
47
- // There is no need to check the order of the nodes in the list because it will be the same.
48
- (0, _react.useEffect)(function () {
49
- listRef.current.horizontal = horizontal;
50
- }, [horizontal]);
51
-
52
- // Update the callback that renders the dragged node if it changes
53
- (0, _react.useEffect)(function () {
54
- listRef.current.renderDraggedNode = renderDraggedNode;
55
- }, [renderDraggedNode]);
56
- var _useDragAndDrop = (0, _useDragAndDrop2["default"])(),
57
- registerList = _useDragAndDrop.registerList,
58
- deregisterList = _useDragAndDrop.deregisterList,
59
- onMouseDown = _useDragAndDrop.onMouseDown,
60
- onTouchStart = _useDragAndDrop.onTouchStart;
61
-
62
- // Register the list in the store
63
- (0, _react.useEffect)(function () {
64
- registerList(listRef.current);
65
- var listId = listRef.current.id;
66
- return function () {
67
- return deregisterList(listId);
68
- };
69
- }, [deregisterList, registerList]);
70
- var registerNode = (0, _react.useCallback)(function (props) {
71
- return listRef.current.add(props);
72
- }, []);
73
- var deregisterNode = (0, _react.useCallback)(function (node) {
74
- listRef.current.remove(node);
75
- }, []);
76
-
77
- // Handlers that determine whether a user clicks on the node
78
- var mouseDownHandler = (0, _react.useCallback)(function (e, node) {
79
- onMouseDown(e, listRef.current, node);
80
- }, [onMouseDown]);
81
- var touchStartHandler = (0, _react.useCallback)(function (e, node) {
82
- onTouchStart(e, listRef.current, node);
83
- }, [onTouchStart]);
84
- var droppableContext = (0, _useMemoObject["default"])({
85
- registerNode: registerNode,
86
- deregisterNode: deregisterNode,
87
- onMouseDown: mouseDownHandler,
88
- onTouchStart: touchStartHandler
89
- });
90
- return /*#__PURE__*/_react["default"].createElement(_useDroppable.DroppableContext.Provider, {
91
- value: droppableContext
92
- }, children({
93
- ref: ref,
94
- innerRef: innerRef
95
- }));
96
- };
97
- var _default = exports["default"] = Droppable;
98
- //# sourceMappingURL=Droppable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Droppable.js","names":["_useMemoObject","_interopRequireDefault","require","_react","_interopRequireWildcard","_NodeList","_useDragAndDrop2","_useDroppable","_useGeneratedId","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","obj","Droppable","_ref","renderDraggedNode","id","_ref$horizontal","horizontal","children","ref","useRef","innerRef","generatedId","useGeneratedId","droppableId","useMemo","listRef","NodeList","useEffect","current","_useDragAndDrop","useDragAndDrop","registerList","deregisterList","onMouseDown","onTouchStart","listId","registerNode","useCallback","props","add","deregisterNode","node","remove","mouseDownHandler","touchStartHandler","droppableContext","useMemoObject","createElement","DroppableContext","Provider","value","_default","exports"],"sources":["../../src/Droppable.tsx"],"sourcesContent":["import useMemoObject from '@os-design/use-memo-object';\nimport React, {\n MouseEvent,\n RefObject,\n TouchEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\nimport NodeList, {\n ExistingNode,\n NodeProps,\n RenderDraggedNode,\n} from './utils/NodeList';\nimport useDragAndDrop from './utils/useDragAndDrop';\nimport { DroppableContext } from './utils/useDroppable';\nimport useGeneratedId from './utils/useGeneratedId';\n\nexport interface DroppableChildrenProps {\n /**\n * The reference to the list.\n * If a virtual list is used, pass it to the outerRef prop.\n */\n ref: RefObject<HTMLDivElement>;\n /**\n * The reference to the container inside the virtual list.\n * Pass it to the innerRef prop.\n */\n innerRef: RefObject<HTMLDivElement>;\n}\n\nexport interface DroppableProps {\n /**\n * The function that renders the dragged node.\n */\n renderDraggedNode: RenderDraggedNode;\n /**\n * The ID of the list with draggable nodes.\n * Used to determine in which list the dragged node was dropped.\n * @default undefined\n */\n id?: string;\n /**\n * Whether the list is horizontal.\n * @default false\n */\n horizontal?: boolean;\n /**\n * The function that renders the list with draggable nodes.\n */\n children: (props: DroppableChildrenProps) => React.ReactNode;\n}\n\nconst Droppable: React.FC<DroppableProps> = ({\n renderDraggedNode,\n id,\n horizontal = false,\n children,\n}) => {\n // The reference to the list\n const ref = useRef<HTMLDivElement>(null);\n // The reference to the container inside the virtual list\n const innerRef = useRef<HTMLDivElement>(null);\n // The unique ID of the list. If no ID was specified, the generated one is used.\n const generatedId = useGeneratedId();\n const droppableId = useMemo(() => id || generatedId, [generatedId, id]);\n // The reference to the list of nodes\n const listRef = useRef(\n new NodeList({\n id: droppableId,\n ref,\n innerRef,\n horizontal,\n renderDraggedNode,\n })\n );\n\n // Update the ID of the list if it changes\n useEffect(() => {\n listRef.current.id = droppableId;\n }, [droppableId]);\n\n // Update the list orientation if it changes.\n // There is no need to check the order of the nodes in the list because it will be the same.\n useEffect(() => {\n listRef.current.horizontal = horizontal;\n }, [horizontal]);\n\n // Update the callback that renders the dragged node if it changes\n useEffect(() => {\n listRef.current.renderDraggedNode = renderDraggedNode;\n }, [renderDraggedNode]);\n\n const { registerList, deregisterList, onMouseDown, onTouchStart } =\n useDragAndDrop();\n\n // Register the list in the store\n useEffect(() => {\n registerList(listRef.current);\n const listId = listRef.current.id;\n return () => deregisterList(listId);\n }, [deregisterList, registerList]);\n\n const registerNode = useCallback(\n (props: NodeProps) => listRef.current.add(props),\n []\n );\n const deregisterNode = useCallback((node: ExistingNode) => {\n listRef.current.remove(node);\n }, []);\n\n // Handlers that determine whether a user clicks on the node\n const mouseDownHandler = useCallback(\n (e: MouseEvent, node: ExistingNode) => {\n onMouseDown(e, listRef.current, node);\n },\n [onMouseDown]\n );\n const touchStartHandler = useCallback(\n (e: TouchEvent, node: ExistingNode) => {\n onTouchStart(e, listRef.current, node);\n },\n [onTouchStart]\n );\n\n const droppableContext = useMemoObject({\n registerNode,\n deregisterNode,\n onMouseDown: mouseDownHandler,\n onTouchStart: touchStartHandler,\n });\n\n return (\n <DroppableContext.Provider value={droppableContext}>\n {(children as (props: DroppableChildrenProps) => React.ReactNode)({\n ref,\n innerRef,\n })}\n </DroppableContext.Provider>\n );\n};\n\nexport default Droppable;\n"],"mappings":";;;;;;;AAAA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AASA,IAAAG,SAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAKA,IAAAI,gBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAP,sBAAA,CAAAC,OAAA;AAAoD,SAAAO,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAA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;AAAC,IAAA+B,QAAA,GAAAC,OAAA,cAEazC,SAAS","ignoreList":[]}
package/dist/cjs/index.js DELETED
@@ -1,68 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- var _exportNames = {
8
- DragAndDrop: true,
9
- Droppable: true,
10
- Draggable: true
11
- };
12
- Object.defineProperty(exports, "DragAndDrop", {
13
- enumerable: true,
14
- get: function get() {
15
- return _DragAndDrop["default"];
16
- }
17
- });
18
- Object.defineProperty(exports, "Draggable", {
19
- enumerable: true,
20
- get: function get() {
21
- return _Draggable["default"];
22
- }
23
- });
24
- Object.defineProperty(exports, "Droppable", {
25
- enumerable: true,
26
- get: function get() {
27
- return _Droppable["default"];
28
- }
29
- });
30
- var _DragAndDrop = _interopRequireWildcard(require("./DragAndDrop"));
31
- Object.keys(_DragAndDrop).forEach(function (key) {
32
- if (key === "default" || key === "__esModule") return;
33
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
34
- if (key in exports && exports[key] === _DragAndDrop[key]) return;
35
- Object.defineProperty(exports, key, {
36
- enumerable: true,
37
- get: function get() {
38
- return _DragAndDrop[key];
39
- }
40
- });
41
- });
42
- var _Droppable = _interopRequireWildcard(require("./Droppable"));
43
- Object.keys(_Droppable).forEach(function (key) {
44
- if (key === "default" || key === "__esModule") return;
45
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
46
- if (key in exports && exports[key] === _Droppable[key]) return;
47
- Object.defineProperty(exports, key, {
48
- enumerable: true,
49
- get: function get() {
50
- return _Droppable[key];
51
- }
52
- });
53
- });
54
- var _Draggable = _interopRequireWildcard(require("./Draggable"));
55
- Object.keys(_Draggable).forEach(function (key) {
56
- if (key === "default" || key === "__esModule") return;
57
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
58
- if (key in exports && exports[key] === _Draggable[key]) return;
59
- Object.defineProperty(exports, key, {
60
- enumerable: true,
61
- get: function get() {
62
- return _Draggable[key];
63
- }
64
- });
65
- });
66
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
67
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
68
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["_DragAndDrop","_interopRequireWildcard","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_Droppable","_Draggable","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set"],"sources":["../../src/index.ts"],"sourcesContent":["export { default as DragAndDrop } from './DragAndDrop';\nexport { default as Droppable } from './Droppable';\nexport { default as Draggable } from './Draggable';\n\nexport * from './DragAndDrop';\nexport * from './Droppable';\nexport * from './Draggable';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,uBAAA,CAAAC,OAAA;AAIAC,MAAA,CAAAC,IAAA,CAAAJ,YAAA,EAAAK,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA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A;AAA4B,SAAAW,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAjB,wBAAAiB,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,gBAAAK,OAAA,CAAAL,CAAA,0BAAAA,CAAA,sBAAAA,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAP,GAAA,CAAAI,CAAA,OAAAO,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAxB,MAAA,CAAAS,cAAA,IAAAT,MAAA,CAAAyB,wBAAA,WAAAC,CAAA,IAAAX,CAAA,oBAAAW,CAAA,OAAArB,cAAA,CAAAC,IAAA,CAAAS,CAAA,EAAAW,CAAA,SAAAC,CAAA,GAAAH,CAAA,GAAAxB,MAAA,CAAAyB,wBAAA,CAAAV,CAAA,EAAAW,CAAA,UAAAC,CAAA,KAAAA,CAAA,CAAAhB,GAAA,IAAAgB,CAAA,CAAAC,GAAA,IAAA5B,MAAA,CAAAS,cAAA,CAAAa,CAAA,EAAAI,CAAA,EAAAC,CAAA,IAAAL,CAAA,CAAAI,CAAA,IAAAX,CAAA,CAAAW,CAAA,YAAAJ,CAAA,cAAAP,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAU,GAAA,CAAAb,CAAA,EAAAO,CAAA,GAAAA,CAAA","ignoreList":[]}
@@ -1,61 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
10
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
- /**
14
- * Stores all the lists where the draggable items is located.
15
- */
16
- var ListStore = /*#__PURE__*/function () {
17
- function ListStore() {
18
- _classCallCheck(this, ListStore);
19
- this.lists = void 0;
20
- this.lists = [];
21
- }
22
-
23
- /**
24
- * Adds a new list to the store.
25
- */
26
- return _createClass(ListStore, [{
27
- key: "add",
28
- value: function add(list) {
29
- this.lists.push(list);
30
- }
31
-
32
- /**
33
- * Removes the list from the store.
34
- */
35
- }, {
36
- key: "remove",
37
- value: function remove(id) {
38
- var index = this.lists.findIndex(function (item) {
39
- return item.id === id;
40
- });
41
- if (index === -1) return;
42
- this.lists.splice(index, 1);
43
- }
44
-
45
- /**
46
- * Returns the list in which the position is located.
47
- */
48
- }, {
49
- key: "findByPosition",
50
- value: function findByPosition(x, y) {
51
- return this.lists.find(function (list) {
52
- var current = list.ref.current;
53
- if (!current) return false;
54
- var rect = current.getBoundingClientRect();
55
- return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;
56
- });
57
- }
58
- }]);
59
- }();
60
- var _default = exports["default"] = ListStore;
61
- //# sourceMappingURL=ListStore.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ListStore.js","names":["ListStore","_classCallCheck","lists","_createClass","key","value","add","list","push","remove","id","index","findIndex","item","splice","findByPosition","x","y","find","current","ref","rect","getBoundingClientRect","width","height","_default","exports"],"sources":["../../../src/utils/ListStore.ts"],"sourcesContent":["import NodeList from './NodeList';\n\n/**\n * Stores all the lists where the draggable items is located.\n */\nclass ListStore {\n private lists: NodeList[];\n\n public constructor() {\n this.lists = [];\n }\n\n /**\n * Adds a new list to the store.\n */\n public add(list: NodeList) {\n this.lists.push(list);\n }\n\n /**\n * Removes the list from the store.\n */\n public remove(id: string) {\n const index = this.lists.findIndex((item) => item.id === id);\n if (index === -1) return;\n this.lists.splice(index, 1);\n }\n\n /**\n * Returns the list in which the position is located.\n */\n public findByPosition(x: number, y: number) {\n return this.lists.find((list) => {\n const { current } = list.ref;\n if (!current) return false;\n const rect = current.getBoundingClientRect();\n return (\n x >= rect.x &&\n x <= rect.x + rect.width &&\n y >= rect.y &&\n y <= rect.y + rect.height\n );\n });\n }\n}\n\nexport default ListStore;\n"],"mappings":";;;;;;;;;;;;AAEA;AACA;AACA;AAFA,IAGMA,SAAS;EAGb,SAAAA,UAAA,EAAqB;IAAAC,eAAA,OAAAD,SAAA;IAAA,KAFbE,KAAK;IAGX,IAAI,CAACA,KAAK,GAAG,EAAE;EACjB;;EAEA;AACF;AACA;EAFE,OAAAC,YAAA,CAAAH,SAAA;IAAAI,GAAA;IAAAC,KAAA,EAGA,SAAAC,IAAWC,IAAc,EAAE;MACzB,IAAI,CAACL,KAAK,CAACM,IAAI,CAACD,IAAI,CAAC;IACvB;;IAEA;AACF;AACA;EAFE;IAAAH,GAAA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