react-sync-board 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +397 -310
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +397 -310
- package/dist/esm/index.js.map +1 -1
- package/dist/react-sync-board.min.js +3 -3
- package/dist/react-sync-board.min.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -4684,11 +4684,35 @@ var isItemInsideElement = function isItemInsideElement(itemElement, otherElem) {
|
|
|
4684
4684
|
}, rect);
|
|
4685
4685
|
});
|
|
4686
4686
|
};
|
|
4687
|
+
var getItemElem = function getItemElem(wrapper, itemId) {
|
|
4688
|
+
var elems = wrapper.getElementsByClassName("item ".concat(itemId));
|
|
4689
|
+
var elem = elems[0];
|
|
4690
|
+
|
|
4691
|
+
if (!elem) {
|
|
4692
|
+
// eslint-disable-next-line no-console
|
|
4693
|
+
console.error("Missing item ".concat(itemId));
|
|
4694
|
+
}
|
|
4695
|
+
|
|
4696
|
+
return elem;
|
|
4697
|
+
};
|
|
4698
|
+
var getIdFromElem = function getIdFromElem(elem) {
|
|
4699
|
+
var _elem$dataset;
|
|
4700
|
+
|
|
4701
|
+
var value = elem === null || elem === void 0 ? void 0 : (_elem$dataset = elem.dataset) === null || _elem$dataset === void 0 ? void 0 : _elem$dataset.id;
|
|
4702
|
+
|
|
4703
|
+
if (!value) {
|
|
4704
|
+
var _elem$dataset2;
|
|
4705
|
+
|
|
4706
|
+
// eslint-disable-next-line no-console
|
|
4707
|
+
console.error("getIdFromElem call fails", elem, JSON.stringify(elem === null || elem === void 0 ? void 0 : elem.dataset), elem === null || elem === void 0 ? void 0 : (_elem$dataset2 = elem.dataset) === null || _elem$dataset2 === void 0 ? void 0 : _elem$dataset2.id);
|
|
4708
|
+
}
|
|
4709
|
+
|
|
4710
|
+
return value;
|
|
4711
|
+
};
|
|
4687
4712
|
var getItemBoundingBox = function getItemBoundingBox(items) {
|
|
4688
4713
|
var wrapper = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
|
|
4689
4714
|
var result = items.reduce(function (prev, itemId) {
|
|
4690
|
-
var
|
|
4691
|
-
var elem = elems[0];
|
|
4715
|
+
var elem = getItemElem(wrapper, itemId);
|
|
4692
4716
|
if (!elem) return null;
|
|
4693
4717
|
|
|
4694
4718
|
var _elem$getBoundingClie = elem.getBoundingClientRect(),
|
|
@@ -4774,23 +4798,53 @@ var computeDistance = function computeDistance(_ref, _ref2) {
|
|
|
4774
4798
|
|
|
4775
4799
|
var empty = function empty() {};
|
|
4776
4800
|
|
|
4777
|
-
var
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4801
|
+
var protect = function protect(fn) {
|
|
4802
|
+
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
4803
|
+
var _args = arguments;
|
|
4804
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
4805
|
+
while (1) {
|
|
4806
|
+
switch (_context.prev = _context.next) {
|
|
4807
|
+
case 0:
|
|
4808
|
+
_context.prev = 0;
|
|
4809
|
+
_context.next = 3;
|
|
4810
|
+
return fn.apply(void 0, _args);
|
|
4811
|
+
|
|
4812
|
+
case 3:
|
|
4813
|
+
_context.next = 8;
|
|
4814
|
+
break;
|
|
4815
|
+
|
|
4816
|
+
case 5:
|
|
4817
|
+
_context.prev = 5;
|
|
4818
|
+
_context.t0 = _context["catch"](0);
|
|
4819
|
+
// eslint-disable-next-line no-console
|
|
4820
|
+
console.error(_context.t0);
|
|
4821
|
+
|
|
4822
|
+
case 8:
|
|
4823
|
+
case "end":
|
|
4824
|
+
return _context.stop();
|
|
4825
|
+
}
|
|
4826
|
+
}
|
|
4827
|
+
}, _callee, null, [[0, 5]]);
|
|
4828
|
+
}));
|
|
4829
|
+
};
|
|
4830
|
+
|
|
4831
|
+
var Gesture = function Gesture(_ref6) {
|
|
4832
|
+
var children = _ref6.children,
|
|
4833
|
+
_ref6$onDrag = _ref6.onDrag,
|
|
4834
|
+
onDrag = _ref6$onDrag === void 0 ? empty : _ref6$onDrag,
|
|
4835
|
+
_ref6$onDragStart = _ref6.onDragStart,
|
|
4836
|
+
onDragStart = _ref6$onDragStart === void 0 ? empty : _ref6$onDragStart,
|
|
4837
|
+
_ref6$onDragEnd = _ref6.onDragEnd,
|
|
4838
|
+
onDragEnd = _ref6$onDragEnd === void 0 ? empty : _ref6$onDragEnd,
|
|
4839
|
+
_ref6$onPan = _ref6.onPan,
|
|
4840
|
+
onPan = _ref6$onPan === void 0 ? empty : _ref6$onPan,
|
|
4841
|
+
_ref6$onTap = _ref6.onTap,
|
|
4842
|
+
onTap = _ref6$onTap === void 0 ? empty : _ref6$onTap,
|
|
4843
|
+
_ref6$onLongTap = _ref6.onLongTap,
|
|
4844
|
+
onLongTap = _ref6$onLongTap === void 0 ? empty : _ref6$onLongTap,
|
|
4845
|
+
_ref6$onDoubleTap = _ref6.onDoubleTap,
|
|
4846
|
+
onDoubleTap = _ref6$onDoubleTap === void 0 ? empty : _ref6$onDoubleTap,
|
|
4847
|
+
onZoom = _ref6.onZoom;
|
|
4794
4848
|
var wrapperRef = React.useRef(null);
|
|
4795
4849
|
var stateRef = React.useRef({
|
|
4796
4850
|
moving: false,
|
|
@@ -4799,36 +4853,36 @@ var Gesture = function Gesture(_ref5) {
|
|
|
4799
4853
|
});
|
|
4800
4854
|
var queueRef = React.useRef([]); // Queue event to avoid async mess
|
|
4801
4855
|
|
|
4802
|
-
var queue = React.useCallback(function (callback) {
|
|
4803
|
-
queueRef.current.push( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
4804
|
-
return regeneratorRuntime.wrap(function
|
|
4856
|
+
var queue = React.useCallback(function (callback, args) {
|
|
4857
|
+
queueRef.current.push( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
4858
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
4805
4859
|
while (1) {
|
|
4806
|
-
switch (
|
|
4860
|
+
switch (_context2.prev = _context2.next) {
|
|
4807
4861
|
case 0:
|
|
4808
|
-
|
|
4809
|
-
return callback();
|
|
4862
|
+
_context2.next = 2;
|
|
4863
|
+
return protect(callback)(args);
|
|
4810
4864
|
|
|
4811
4865
|
case 2:
|
|
4812
4866
|
queueRef.current.shift();
|
|
4813
4867
|
|
|
4814
4868
|
if (!(queueRef.current.length !== 0)) {
|
|
4815
|
-
|
|
4869
|
+
_context2.next = 6;
|
|
4816
4870
|
break;
|
|
4817
4871
|
}
|
|
4818
4872
|
|
|
4819
|
-
|
|
4820
|
-
return queueRef.current[0]();
|
|
4873
|
+
_context2.next = 6;
|
|
4874
|
+
return protect(queueRef.current[0])();
|
|
4821
4875
|
|
|
4822
4876
|
case 6:
|
|
4823
4877
|
case "end":
|
|
4824
|
-
return
|
|
4878
|
+
return _context2.stop();
|
|
4825
4879
|
}
|
|
4826
4880
|
}
|
|
4827
|
-
},
|
|
4881
|
+
}, _callee2);
|
|
4828
4882
|
})));
|
|
4829
4883
|
|
|
4830
4884
|
if (queueRef.current.length === 1) {
|
|
4831
|
-
queueRef.current[0]();
|
|
4885
|
+
protect(queueRef.current[0])();
|
|
4832
4886
|
}
|
|
4833
4887
|
}, []);
|
|
4834
4888
|
var onWheel = React.useCallback(function (e) {
|
|
@@ -4853,16 +4907,14 @@ var Gesture = function Gesture(_ref5) {
|
|
|
4853
4907
|
|
|
4854
4908
|
|
|
4855
4909
|
if (isMacOS() && !ctrlKey) {
|
|
4856
|
-
queue(
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
event: e
|
|
4865
|
-
});
|
|
4910
|
+
queue(onPan, {
|
|
4911
|
+
deltaX: -2 * deltaX,
|
|
4912
|
+
deltaY: -2 * deltaY,
|
|
4913
|
+
button: 1,
|
|
4914
|
+
ctrlKey: ctrlKey,
|
|
4915
|
+
metaKey: metaKey,
|
|
4916
|
+
target: target,
|
|
4917
|
+
event: e
|
|
4866
4918
|
});
|
|
4867
4919
|
} else {
|
|
4868
4920
|
// Quit if onZoom is not set
|
|
@@ -4884,26 +4936,24 @@ var Gesture = function Gesture(_ref5) {
|
|
|
4884
4936
|
scale *= 2;
|
|
4885
4937
|
}
|
|
4886
4938
|
|
|
4887
|
-
queue(
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
event: e
|
|
4893
|
-
});
|
|
4939
|
+
queue(onZoom, {
|
|
4940
|
+
scale: scale,
|
|
4941
|
+
clientX: clientX,
|
|
4942
|
+
clientY: clientY,
|
|
4943
|
+
event: e
|
|
4894
4944
|
});
|
|
4895
4945
|
}
|
|
4896
4946
|
}, [onPan, onZoom, queue]);
|
|
4897
|
-
var onPointerDown = React.useCallback(function (
|
|
4898
|
-
var target =
|
|
4899
|
-
button =
|
|
4900
|
-
clientX =
|
|
4901
|
-
clientY =
|
|
4902
|
-
pointerId =
|
|
4903
|
-
altKey =
|
|
4904
|
-
ctrlKey =
|
|
4905
|
-
metaKey =
|
|
4906
|
-
isPrimary =
|
|
4947
|
+
var onPointerDown = React.useCallback(function (_ref8) {
|
|
4948
|
+
var target = _ref8.target,
|
|
4949
|
+
button = _ref8.button,
|
|
4950
|
+
clientX = _ref8.clientX,
|
|
4951
|
+
clientY = _ref8.clientY,
|
|
4952
|
+
pointerId = _ref8.pointerId,
|
|
4953
|
+
altKey = _ref8.altKey,
|
|
4954
|
+
ctrlKey = _ref8.ctrlKey,
|
|
4955
|
+
metaKey = _ref8.metaKey,
|
|
4956
|
+
isPrimary = _ref8.isPrimary;
|
|
4907
4957
|
// Add pointer to map
|
|
4908
4958
|
stateRef.current.pointers[pointerId] = {
|
|
4909
4959
|
clientX: clientX,
|
|
@@ -4939,6 +4989,7 @@ var Gesture = function Gesture(_ref5) {
|
|
|
4939
4989
|
prevDistance: distance
|
|
4940
4990
|
});
|
|
4941
4991
|
} catch (e) {
|
|
4992
|
+
// eslint-disable-next-line no-console
|
|
4942
4993
|
console.log("Error while getting other pointer. Ignoring", e); // eslint-disable-next-line no-unused-expressions
|
|
4943
4994
|
|
|
4944
4995
|
stateRef.current.mainPointer === undefined;
|
|
@@ -4962,35 +5013,34 @@ var Gesture = function Gesture(_ref5) {
|
|
|
4962
5013
|
currentButton: button,
|
|
4963
5014
|
target: target,
|
|
4964
5015
|
timeStart: Date.now(),
|
|
4965
|
-
longTapTimeout: setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
4966
|
-
return regeneratorRuntime.wrap(function
|
|
5016
|
+
longTapTimeout: setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
5017
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
4967
5018
|
while (1) {
|
|
4968
|
-
switch (
|
|
5019
|
+
switch (_context3.prev = _context3.next) {
|
|
4969
5020
|
case 0:
|
|
4970
5021
|
stateRef.current.noTap = true;
|
|
4971
|
-
queue(
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
target: target
|
|
4979
|
-
});
|
|
5022
|
+
queue(onLongTap, {
|
|
5023
|
+
clientX: clientX,
|
|
5024
|
+
clientY: clientY,
|
|
5025
|
+
altKey: altKey,
|
|
5026
|
+
ctrlKey: ctrlKey,
|
|
5027
|
+
metaKey: metaKey,
|
|
5028
|
+
target: target
|
|
4980
5029
|
});
|
|
4981
5030
|
|
|
4982
5031
|
case 2:
|
|
4983
5032
|
case "end":
|
|
4984
|
-
return
|
|
5033
|
+
return _context3.stop();
|
|
4985
5034
|
}
|
|
4986
5035
|
}
|
|
4987
|
-
},
|
|
5036
|
+
}, _callee3);
|
|
4988
5037
|
})), 750)
|
|
4989
5038
|
});
|
|
4990
5039
|
|
|
4991
5040
|
try {
|
|
4992
5041
|
target.setPointerCapture(pointerId);
|
|
4993
5042
|
} catch (e) {
|
|
5043
|
+
// eslint-disable-next-line no-console
|
|
4994
5044
|
console.log("Fail to capture pointer", e);
|
|
4995
5045
|
}
|
|
4996
5046
|
}, [onLongTap, queue]);
|
|
@@ -5050,38 +5100,13 @@ var Gesture = function Gesture(_ref5) {
|
|
|
5050
5100
|
stateRef.current.gestureStart = true; // Clear tap timeout
|
|
5051
5101
|
|
|
5052
5102
|
clearTimeout(stateRef.current.longTapTimeout);
|
|
5053
|
-
queue(
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
deltaY: 0,
|
|
5057
|
-
startX: stateRef.current.startX,
|
|
5058
|
-
startY: stateRef.current.startY,
|
|
5059
|
-
distanceX: 0,
|
|
5060
|
-
distanceY: 0,
|
|
5061
|
-
button: stateRef.current.currentButton,
|
|
5062
|
-
altKey: altKey,
|
|
5063
|
-
ctrlKey: ctrlKey,
|
|
5064
|
-
metaKey: metaKey,
|
|
5065
|
-
target: stateRef.current.target,
|
|
5066
|
-
event: e
|
|
5067
|
-
});
|
|
5068
|
-
});
|
|
5069
|
-
} // Create closure
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
var deltaX = clientX - stateRef.current.prevX;
|
|
5073
|
-
var deltaY = clientY - stateRef.current.prevY;
|
|
5074
|
-
var distanceX = clientX - stateRef.current.startX;
|
|
5075
|
-
var distanceY = clientY - stateRef.current.startY; // Drag event
|
|
5076
|
-
|
|
5077
|
-
queue(function () {
|
|
5078
|
-
return onDrag({
|
|
5079
|
-
deltaX: deltaX,
|
|
5080
|
-
deltaY: deltaY,
|
|
5103
|
+
queue(onDragStart, {
|
|
5104
|
+
deltaX: 0,
|
|
5105
|
+
deltaY: 0,
|
|
5081
5106
|
startX: stateRef.current.startX,
|
|
5082
5107
|
startY: stateRef.current.startY,
|
|
5083
|
-
distanceX:
|
|
5084
|
-
distanceY:
|
|
5108
|
+
distanceX: 0,
|
|
5109
|
+
distanceY: 0,
|
|
5085
5110
|
button: stateRef.current.currentButton,
|
|
5086
5111
|
altKey: altKey,
|
|
5087
5112
|
ctrlKey: ctrlKey,
|
|
@@ -5089,6 +5114,27 @@ var Gesture = function Gesture(_ref5) {
|
|
|
5089
5114
|
target: stateRef.current.target,
|
|
5090
5115
|
event: e
|
|
5091
5116
|
});
|
|
5117
|
+
} // Create closure
|
|
5118
|
+
|
|
5119
|
+
|
|
5120
|
+
var deltaX = clientX - stateRef.current.prevX;
|
|
5121
|
+
var deltaY = clientY - stateRef.current.prevY;
|
|
5122
|
+
var distanceX = clientX - stateRef.current.startX;
|
|
5123
|
+
var distanceY = clientY - stateRef.current.startY; // Drag event
|
|
5124
|
+
|
|
5125
|
+
queue(onDrag, {
|
|
5126
|
+
deltaX: deltaX,
|
|
5127
|
+
deltaY: deltaY,
|
|
5128
|
+
startX: stateRef.current.startX,
|
|
5129
|
+
startY: stateRef.current.startY,
|
|
5130
|
+
distanceX: distanceX,
|
|
5131
|
+
distanceY: distanceY,
|
|
5132
|
+
button: stateRef.current.currentButton,
|
|
5133
|
+
altKey: altKey,
|
|
5134
|
+
ctrlKey: ctrlKey,
|
|
5135
|
+
metaKey: metaKey,
|
|
5136
|
+
target: stateRef.current.target,
|
|
5137
|
+
event: e
|
|
5092
5138
|
});
|
|
5093
5139
|
} else {
|
|
5094
5140
|
if (!stateRef.current.gestureStart) {
|
|
@@ -5105,30 +5151,26 @@ var Gesture = function Gesture(_ref5) {
|
|
|
5105
5151
|
|
|
5106
5152
|
var target = stateRef.current.target; // Pan event
|
|
5107
5153
|
|
|
5108
|
-
queue(
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
event: e
|
|
5118
|
-
});
|
|
5154
|
+
queue(onPan, {
|
|
5155
|
+
deltaX: _deltaX,
|
|
5156
|
+
deltaY: _deltaY,
|
|
5157
|
+
button: stateRef.current.currentButton,
|
|
5158
|
+
altKey: altKey,
|
|
5159
|
+
ctrlKey: ctrlKey,
|
|
5160
|
+
metaKey: metaKey,
|
|
5161
|
+
target: target,
|
|
5162
|
+
event: e
|
|
5119
5163
|
});
|
|
5120
5164
|
|
|
5121
5165
|
if (twoFingers && distance !== stateRef.current.prevDistance && onZoom) {
|
|
5122
5166
|
var scale = stateRef.current.prevDistance - distance;
|
|
5123
5167
|
|
|
5124
5168
|
if (Math.abs(scale) > 0) {
|
|
5125
|
-
queue(
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
event: e
|
|
5131
|
-
});
|
|
5169
|
+
queue(onZoom, {
|
|
5170
|
+
scale: scale,
|
|
5171
|
+
clientX: clientX,
|
|
5172
|
+
clientY: clientY,
|
|
5173
|
+
event: e
|
|
5132
5174
|
});
|
|
5133
5175
|
stateRef.current.prevDistance = distance;
|
|
5134
5176
|
}
|
|
@@ -5170,6 +5212,7 @@ var Gesture = function Gesture(_ref5) {
|
|
|
5170
5212
|
stateRef.current.target.setPointerCapture(stateRef.current.mainPointer);
|
|
5171
5213
|
return;
|
|
5172
5214
|
} catch (error) {
|
|
5215
|
+
// eslint-disable-next-line no-console
|
|
5173
5216
|
console.log("Fails to set pointer capture", error);
|
|
5174
5217
|
stateRef.current.mainPointer = undefined;
|
|
5175
5218
|
delete stateRef.current.pointers[Object.keys(stateRef.current.pointers)[0]];
|
|
@@ -5184,20 +5227,18 @@ var Gesture = function Gesture(_ref5) {
|
|
|
5184
5227
|
if (stateRef.current.moving) {
|
|
5185
5228
|
// If we were moving, send drag end event
|
|
5186
5229
|
stateRef.current.moving = false;
|
|
5187
|
-
queue(
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
event: e
|
|
5200
|
-
});
|
|
5230
|
+
queue(onDragEnd, {
|
|
5231
|
+
deltaX: clientX - stateRef.current.prevX,
|
|
5232
|
+
deltaY: clientY - stateRef.current.prevY,
|
|
5233
|
+
startX: stateRef.current.startX,
|
|
5234
|
+
startY: stateRef.current.startY,
|
|
5235
|
+
distanceX: clientX - stateRef.current.startX,
|
|
5236
|
+
distanceY: clientY - stateRef.current.startY,
|
|
5237
|
+
button: stateRef.current.currentButton,
|
|
5238
|
+
altKey: altKey,
|
|
5239
|
+
ctrlKey: ctrlKey,
|
|
5240
|
+
metaKey: metaKey,
|
|
5241
|
+
event: e
|
|
5201
5242
|
});
|
|
5202
5243
|
wrapperRef.current.style.cursor = "auto";
|
|
5203
5244
|
} else {
|
|
@@ -5207,22 +5248,20 @@ var Gesture = function Gesture(_ref5) {
|
|
|
5207
5248
|
stateRef.current.noTap = false;
|
|
5208
5249
|
} // Send tap event only if time less than 300ms
|
|
5209
5250
|
else if (stateRef.current.timeStart - now < 300) {
|
|
5210
|
-
queue(
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
target: target
|
|
5218
|
-
});
|
|
5251
|
+
queue(onTap, {
|
|
5252
|
+
clientX: clientX,
|
|
5253
|
+
clientY: clientY,
|
|
5254
|
+
altKey: altKey,
|
|
5255
|
+
ctrlKey: ctrlKey,
|
|
5256
|
+
metaKey: metaKey,
|
|
5257
|
+
target: target
|
|
5219
5258
|
});
|
|
5220
5259
|
}
|
|
5221
5260
|
}
|
|
5222
5261
|
}, [onDragEnd, onTap, queue]);
|
|
5223
5262
|
var onDoubleTapHandler = React.useCallback(function (event) {
|
|
5224
|
-
onDoubleTap
|
|
5225
|
-
}, [onDoubleTap]);
|
|
5263
|
+
queue(onDoubleTap, event);
|
|
5264
|
+
}, [onDoubleTap, queue]);
|
|
5226
5265
|
return /*#__PURE__*/React.createElement("div", {
|
|
5227
5266
|
onWheel: onWheel,
|
|
5228
5267
|
onPointerDown: onPointerDown,
|
|
@@ -5255,22 +5294,16 @@ var findSelected = function findSelected(itemMap, wrapper) {
|
|
|
5255
5294
|
|
|
5256
5295
|
var selector = selectors[0];
|
|
5257
5296
|
return Array.from(wrapper.getElementsByClassName("item")).filter(function (elem) {
|
|
5258
|
-
var id = elem
|
|
5297
|
+
var id = getIdFromElem(elem);
|
|
5259
5298
|
var item = itemMap[id];
|
|
5260
5299
|
|
|
5261
|
-
if (!item) {
|
|
5262
|
-
// Avoid to find item that are not yet removed from DOM
|
|
5263
|
-
console.error("Missing item ".concat(id));
|
|
5264
|
-
return false;
|
|
5265
|
-
}
|
|
5266
|
-
|
|
5267
|
-
if (item.locked) {
|
|
5300
|
+
if (!item || item.locked) {
|
|
5268
5301
|
return false;
|
|
5269
5302
|
}
|
|
5270
5303
|
|
|
5271
5304
|
return isItemInsideElement(elem, selector);
|
|
5272
5305
|
}).map(function (elem) {
|
|
5273
|
-
return elem
|
|
5306
|
+
return getIdFromElem(elem);
|
|
5274
5307
|
});
|
|
5275
5308
|
};
|
|
5276
5309
|
|
|
@@ -5448,7 +5481,8 @@ var Selector = function Selector(_ref) {
|
|
|
5448
5481
|
var foundElement = insideClass(target, "item");
|
|
5449
5482
|
|
|
5450
5483
|
if (foundElement) {
|
|
5451
|
-
|
|
5484
|
+
var id = getIdFromElem(foundElement);
|
|
5485
|
+
setSelected([id]);
|
|
5452
5486
|
}
|
|
5453
5487
|
}, [setSelected]);
|
|
5454
5488
|
var onTap = useRecoilCallback(function (_ref9) {
|
|
@@ -5469,15 +5503,25 @@ var Selector = function Selector(_ref) {
|
|
|
5469
5503
|
}
|
|
5470
5504
|
|
|
5471
5505
|
setSelected([]);
|
|
5472
|
-
_context3.next =
|
|
5506
|
+
_context3.next = 14;
|
|
5473
5507
|
break;
|
|
5474
5508
|
|
|
5475
5509
|
case 6:
|
|
5476
|
-
itemId = foundItem
|
|
5477
|
-
|
|
5510
|
+
itemId = getIdFromElem(foundItem); // Being defensive here to avoid bug
|
|
5511
|
+
|
|
5512
|
+
if (itemId) {
|
|
5513
|
+
_context3.next = 10;
|
|
5514
|
+
break;
|
|
5515
|
+
}
|
|
5516
|
+
|
|
5517
|
+
setSelected([]);
|
|
5518
|
+
return _context3.abrupt("return");
|
|
5519
|
+
|
|
5520
|
+
case 10:
|
|
5521
|
+
_context3.next = 12;
|
|
5478
5522
|
return snapshot.getPromise(SelectedItemsAtom);
|
|
5479
5523
|
|
|
5480
|
-
case
|
|
5524
|
+
case 12:
|
|
5481
5525
|
selectedItems = _context3.sent;
|
|
5482
5526
|
|
|
5483
5527
|
if (foundItem && !selectedItems.includes(itemId)) {
|
|
@@ -5490,7 +5534,7 @@ var Selector = function Selector(_ref) {
|
|
|
5490
5534
|
}
|
|
5491
5535
|
}
|
|
5492
5536
|
|
|
5493
|
-
case
|
|
5537
|
+
case 14:
|
|
5494
5538
|
case "end":
|
|
5495
5539
|
return _context3.stop();
|
|
5496
5540
|
}
|
|
@@ -5569,7 +5613,7 @@ var ActionPane = function ActionPane(_ref) {
|
|
|
5569
5613
|
case 8:
|
|
5570
5614
|
selectedItems = _context.sent;
|
|
5571
5615
|
selectedItemRef.current.items = selectedItems;
|
|
5572
|
-
itemId = foundElement
|
|
5616
|
+
itemId = getIdFromElem(foundElement);
|
|
5573
5617
|
|
|
5574
5618
|
if (!selectedItems.includes(itemId)) {
|
|
5575
5619
|
if (ctrlKey || metaKey) {
|
|
@@ -5962,8 +6006,8 @@ function F(t) {
|
|
|
5962
6006
|
var _excluded$1 = ["pos"];
|
|
5963
6007
|
|
|
5964
6008
|
var _templateObject$1, _templateObject2;
|
|
5965
|
-
var StyledCursor = newStyled.div(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n align-items: center;\n z-index: 210;\n"])));
|
|
5966
|
-
var CursorName = newStyled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: ", ";\n font-weight: bold;\n padding: 0 0.5em;\n border-radius: 2px;\n max-width: 5em;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-left: -0.5em;\n margin-top: 1.7em;\n whitespace: nowrap;\n background-color: ", ";\n"])), function (_ref) {
|
|
6009
|
+
var StyledCursor = newStyled.div(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n align-items: center;\n z-index: 210;\n pointer-events: none;\n"])));
|
|
6010
|
+
var CursorName = newStyled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: ", ";\n font-weight: bold;\n padding: 0 0.5em;\n border-radius: 2px;\n max-width: 5em;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-left: -0.5em;\n margin-top: 1.7em;\n whitespace: nowrap;\n pointer-events: none;\n background-color: ", ";\n"])), function (_ref) {
|
|
5967
6011
|
var textColor = _ref.textColor;
|
|
5968
6012
|
return textColor;
|
|
5969
6013
|
}, function (_ref2) {
|
|
@@ -6015,7 +6059,8 @@ var PositionnedCursor = function PositionnedCursor(_ref4) {
|
|
|
6015
6059
|
top: 0,
|
|
6016
6060
|
left: 0,
|
|
6017
6061
|
zIndex: 210,
|
|
6018
|
-
position: "fixed"
|
|
6062
|
+
position: "fixed",
|
|
6063
|
+
pointerEvents: "none"
|
|
6019
6064
|
}
|
|
6020
6065
|
}, /*#__PURE__*/React.createElement(MemoizedCursor, rest));
|
|
6021
6066
|
};
|
|
@@ -6173,6 +6218,8 @@ var useUsers = function useUsers() {
|
|
|
6173
6218
|
});
|
|
6174
6219
|
}, [setCurrentUserState]);
|
|
6175
6220
|
var localUsers = React.useMemo(function () {
|
|
6221
|
+
// eslint-disable-next-line no-console
|
|
6222
|
+
console.debug("Curent user is in space ".concat(currentUser.space));
|
|
6176
6223
|
return users.filter(function (_ref) {
|
|
6177
6224
|
var space = _ref.space;
|
|
6178
6225
|
return space === currentUser.space;
|
|
@@ -7454,6 +7501,11 @@ var useItemActions = function useItemActions() {
|
|
|
7454
7501
|
|
|
7455
7502
|
itemIds.forEach(function (id) {
|
|
7456
7503
|
var item = prevItemMap[id];
|
|
7504
|
+
|
|
7505
|
+
if (!item) {
|
|
7506
|
+
return;
|
|
7507
|
+
}
|
|
7508
|
+
|
|
7457
7509
|
result[id] = _objectSpread2(_objectSpread2({}, item), {}, {
|
|
7458
7510
|
x: (item.x || 0) + posDelta.x,
|
|
7459
7511
|
y: (item.y || 0) + posDelta.y,
|
|
@@ -7490,120 +7542,155 @@ var useItemActions = function useItemActions() {
|
|
|
7490
7542
|
return result;
|
|
7491
7543
|
});
|
|
7492
7544
|
}, [setItemList, wire]);
|
|
7493
|
-
var stickOnGrid =
|
|
7494
|
-
var
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7545
|
+
var stickOnGrid = useRecoilCallback(function (_ref4) {
|
|
7546
|
+
var snapshot = _ref4.snapshot;
|
|
7547
|
+
return /*#__PURE__*/function () {
|
|
7548
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(itemIds) {
|
|
7549
|
+
var _ref6,
|
|
7550
|
+
globalType,
|
|
7551
|
+
globalSize,
|
|
7552
|
+
sync,
|
|
7553
|
+
_yield$snapshot$getPr,
|
|
7554
|
+
boardWrapper,
|
|
7555
|
+
updatedItems,
|
|
7556
|
+
_args2 = arguments;
|
|
7502
7557
|
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7558
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
7559
|
+
while (1) {
|
|
7560
|
+
switch (_context2.prev = _context2.next) {
|
|
7561
|
+
case 0:
|
|
7562
|
+
_ref6 = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {}, globalType = _ref6.type, globalSize = _ref6.size;
|
|
7563
|
+
sync = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : true;
|
|
7564
|
+
_context2.next = 4;
|
|
7565
|
+
return snapshot.getPromise(ConfigurationAtom);
|
|
7507
7566
|
|
|
7508
|
-
|
|
7509
|
-
|
|
7510
|
-
|
|
7567
|
+
case 4:
|
|
7568
|
+
_yield$snapshot$getPr = _context2.sent;
|
|
7569
|
+
boardWrapper = _yield$snapshot$getPr.boardWrapper;
|
|
7570
|
+
updatedItems = {};
|
|
7571
|
+
setItemMap(function (prevItemMap) {
|
|
7572
|
+
var result = _objectSpread2({}, prevItemMap);
|
|
7511
7573
|
|
|
7512
|
-
|
|
7513
|
-
|
|
7574
|
+
itemIds.forEach(function (id) {
|
|
7575
|
+
var item = prevItemMap[id];
|
|
7576
|
+
var elem = getItemElem(boardWrapper, id);
|
|
7514
7577
|
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
}
|
|
7578
|
+
if (!elem) {
|
|
7579
|
+
return;
|
|
7580
|
+
}
|
|
7519
7581
|
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
var newY;
|
|
7524
|
-
var sizeX;
|
|
7525
|
-
var sizeY;
|
|
7526
|
-
var px1;
|
|
7527
|
-
var px2;
|
|
7528
|
-
var py1;
|
|
7529
|
-
var py2;
|
|
7530
|
-
var diff1;
|
|
7531
|
-
var diff2;
|
|
7532
|
-
var h = size / 1.1547;
|
|
7533
|
-
|
|
7534
|
-
switch (type) {
|
|
7535
|
-
case "grid":
|
|
7536
|
-
newX = Math.round(centerX / size) * size;
|
|
7537
|
-
newY = Math.round(centerY / size) * size;
|
|
7538
|
-
break;
|
|
7582
|
+
var _ref7 = item.grid || {},
|
|
7583
|
+
itemType = _ref7.type,
|
|
7584
|
+
itemSize = _ref7.size;
|
|
7539
7585
|
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
sizeY = 3 * size;
|
|
7543
|
-
px1 = Math.round(centerX / sizeX) * sizeX;
|
|
7544
|
-
py1 = Math.round(centerY / sizeY) * sizeY;
|
|
7545
|
-
px2 = px1 > centerX ? px1 - h : px1 + h;
|
|
7546
|
-
py2 = py1 > centerY ? py1 - 1.5 * size : py1 + 1.5 * size;
|
|
7547
|
-
diff1 = Math.hypot.apply(Math, [px1 - centerX, py1 - centerY]);
|
|
7548
|
-
diff2 = Math.hypot.apply(Math, [px2 - centerX, py2 - centerY]);
|
|
7549
|
-
|
|
7550
|
-
if (diff1 < diff2) {
|
|
7551
|
-
newX = px1;
|
|
7552
|
-
newY = py1;
|
|
7553
|
-
} else {
|
|
7554
|
-
newX = px2;
|
|
7555
|
-
newY = py2;
|
|
7556
|
-
}
|
|
7586
|
+
var type = globalType;
|
|
7587
|
+
var size = globalSize || 1; // If item specific
|
|
7557
7588
|
|
|
7558
|
-
|
|
7589
|
+
if (itemType) {
|
|
7590
|
+
type = itemType;
|
|
7591
|
+
size = itemSize || 1;
|
|
7592
|
+
}
|
|
7559
7593
|
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7594
|
+
var centerX = item.x + elem.clientWidth / 2,
|
|
7595
|
+
centerY = item.y + elem.clientHeight / 2;
|
|
7596
|
+
var newX;
|
|
7597
|
+
var newY;
|
|
7598
|
+
var sizeX;
|
|
7599
|
+
var sizeY;
|
|
7600
|
+
var px1;
|
|
7601
|
+
var px2;
|
|
7602
|
+
var py1;
|
|
7603
|
+
var py2;
|
|
7604
|
+
var diff1;
|
|
7605
|
+
var diff2;
|
|
7606
|
+
var h = size / 1.1547;
|
|
7607
|
+
|
|
7608
|
+
switch (type) {
|
|
7609
|
+
case "grid":
|
|
7610
|
+
newX = Math.round(centerX / size) * size;
|
|
7611
|
+
newY = Math.round(centerY / size) * size;
|
|
7612
|
+
break;
|
|
7613
|
+
|
|
7614
|
+
case "hexH":
|
|
7615
|
+
sizeX = 2 * h;
|
|
7616
|
+
sizeY = 3 * size;
|
|
7617
|
+
px1 = Math.round(centerX / sizeX) * sizeX;
|
|
7618
|
+
py1 = Math.round(centerY / sizeY) * sizeY;
|
|
7619
|
+
px2 = px1 > centerX ? px1 - h : px1 + h;
|
|
7620
|
+
py2 = py1 > centerY ? py1 - 1.5 * size : py1 + 1.5 * size;
|
|
7621
|
+
diff1 = Math.hypot.apply(Math, [px1 - centerX, py1 - centerY]);
|
|
7622
|
+
diff2 = Math.hypot.apply(Math, [px2 - centerX, py2 - centerY]);
|
|
7623
|
+
|
|
7624
|
+
if (diff1 < diff2) {
|
|
7625
|
+
newX = px1;
|
|
7626
|
+
newY = py1;
|
|
7627
|
+
} else {
|
|
7628
|
+
newX = px2;
|
|
7629
|
+
newY = py2;
|
|
7630
|
+
}
|
|
7631
|
+
|
|
7632
|
+
break;
|
|
7633
|
+
|
|
7634
|
+
case "hexV":
|
|
7635
|
+
sizeX = 3 * size;
|
|
7636
|
+
sizeY = 2 * h;
|
|
7637
|
+
px1 = Math.round(centerX / sizeX) * sizeX;
|
|
7638
|
+
py1 = Math.round(centerY / sizeY) * sizeY;
|
|
7639
|
+
px2 = px1 > centerX ? px1 - 1.5 * size : px1 + 1.5 * size;
|
|
7640
|
+
py2 = py1 > centerY ? py1 - h : py1 + h;
|
|
7641
|
+
diff1 = Math.hypot.apply(Math, [px1 - centerX, py1 - centerY]);
|
|
7642
|
+
diff2 = Math.hypot.apply(Math, [px2 - centerX, py2 - centerY]);
|
|
7643
|
+
|
|
7644
|
+
if (diff1 < diff2) {
|
|
7645
|
+
newX = px1;
|
|
7646
|
+
newY = py1;
|
|
7647
|
+
} else {
|
|
7648
|
+
newX = px2;
|
|
7649
|
+
newY = py2;
|
|
7650
|
+
}
|
|
7651
|
+
|
|
7652
|
+
break;
|
|
7653
|
+
|
|
7654
|
+
default:
|
|
7655
|
+
newX = item.x + elem.clientWidth / 2;
|
|
7656
|
+
newY = item.y + elem.clientHeight / 2;
|
|
7657
|
+
}
|
|
7577
7658
|
|
|
7578
|
-
|
|
7659
|
+
result[id] = _objectSpread2(_objectSpread2({}, item), {}, {
|
|
7660
|
+
x: newX - elem.clientWidth / 2,
|
|
7661
|
+
y: newY - elem.clientHeight / 2
|
|
7662
|
+
});
|
|
7663
|
+
updatedItems[id] = result[id];
|
|
7664
|
+
});
|
|
7665
|
+
return result;
|
|
7666
|
+
});
|
|
7579
7667
|
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
}
|
|
7668
|
+
if (sync) {
|
|
7669
|
+
wire.publish("batchItemsUpdate", updatedItems);
|
|
7670
|
+
}
|
|
7584
7671
|
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
});
|
|
7672
|
+
case 9:
|
|
7673
|
+
case "end":
|
|
7674
|
+
return _context2.stop();
|
|
7675
|
+
}
|
|
7676
|
+
}
|
|
7677
|
+
}, _callee2);
|
|
7678
|
+
}));
|
|
7593
7679
|
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7680
|
+
return function (_x3) {
|
|
7681
|
+
return _ref5.apply(this, arguments);
|
|
7682
|
+
};
|
|
7683
|
+
}();
|
|
7597
7684
|
}, [wire, setItemMap]);
|
|
7598
7685
|
var placeItems = React.useCallback( /*#__PURE__*/function () {
|
|
7599
|
-
var
|
|
7686
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(itemIds, gridConfig) {
|
|
7600
7687
|
var sync,
|
|
7601
|
-
|
|
7602
|
-
return regeneratorRuntime.wrap(function
|
|
7688
|
+
_args3 = arguments;
|
|
7689
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
7603
7690
|
while (1) {
|
|
7604
|
-
switch (
|
|
7691
|
+
switch (_context3.prev = _context3.next) {
|
|
7605
7692
|
case 0:
|
|
7606
|
-
sync =
|
|
7693
|
+
sync = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : true;
|
|
7607
7694
|
// Put moved items on top
|
|
7608
7695
|
putItemsOnTop(itemIds, sync); // Remove moving state
|
|
7609
7696
|
|
|
@@ -7619,14 +7706,14 @@ var useItemActions = function useItemActions() {
|
|
|
7619
7706
|
|
|
7620
7707
|
case 6:
|
|
7621
7708
|
case "end":
|
|
7622
|
-
return
|
|
7709
|
+
return _context3.stop();
|
|
7623
7710
|
}
|
|
7624
7711
|
}
|
|
7625
|
-
},
|
|
7712
|
+
}, _callee3);
|
|
7626
7713
|
}));
|
|
7627
7714
|
|
|
7628
|
-
return function (
|
|
7629
|
-
return
|
|
7715
|
+
return function (_x4, _x5) {
|
|
7716
|
+
return _ref8.apply(this, arguments);
|
|
7630
7717
|
};
|
|
7631
7718
|
}(), [batchUpdateItems, callPlaceInteractions, putItemsOnTop, stickOnGrid, updateItemExtent]);
|
|
7632
7719
|
var updateItemOrder = React.useCallback(function (newOrder) {
|
|
@@ -7665,27 +7752,27 @@ var useItemActions = function useItemActions() {
|
|
|
7665
7752
|
return reversed;
|
|
7666
7753
|
});
|
|
7667
7754
|
}, [setItemList, wire, setSelectItems]);
|
|
7668
|
-
var swapItems = useRecoilCallback(function (
|
|
7669
|
-
var snapshot =
|
|
7755
|
+
var swapItems = useRecoilCallback(function (_ref9) {
|
|
7756
|
+
var snapshot = _ref9.snapshot;
|
|
7670
7757
|
return /*#__PURE__*/function () {
|
|
7671
|
-
var
|
|
7758
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(fromIds, toIds) {
|
|
7672
7759
|
var sync,
|
|
7673
7760
|
itemMap,
|
|
7674
7761
|
fromItems,
|
|
7675
7762
|
toItems,
|
|
7676
7763
|
replaceMapItems,
|
|
7677
7764
|
replaceMap,
|
|
7678
|
-
|
|
7679
|
-
return regeneratorRuntime.wrap(function
|
|
7765
|
+
_args4 = arguments;
|
|
7766
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
7680
7767
|
while (1) {
|
|
7681
|
-
switch (
|
|
7768
|
+
switch (_context4.prev = _context4.next) {
|
|
7682
7769
|
case 0:
|
|
7683
|
-
sync =
|
|
7684
|
-
|
|
7770
|
+
sync = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : true;
|
|
7771
|
+
_context4.next = 3;
|
|
7685
7772
|
return snapshot.getPromise(ItemMapAtom);
|
|
7686
7773
|
|
|
7687
7774
|
case 3:
|
|
7688
|
-
itemMap =
|
|
7775
|
+
itemMap = _context4.sent;
|
|
7689
7776
|
fromItems = fromIds.map(function (id) {
|
|
7690
7777
|
return itemMap[id];
|
|
7691
7778
|
});
|
|
@@ -7740,38 +7827,38 @@ var useItemActions = function useItemActions() {
|
|
|
7740
7827
|
|
|
7741
7828
|
case 10:
|
|
7742
7829
|
case "end":
|
|
7743
|
-
return
|
|
7830
|
+
return _context4.stop();
|
|
7744
7831
|
}
|
|
7745
7832
|
}
|
|
7746
|
-
},
|
|
7833
|
+
}, _callee4);
|
|
7747
7834
|
}));
|
|
7748
7835
|
|
|
7749
|
-
return function (
|
|
7750
|
-
return
|
|
7836
|
+
return function (_x6, _x7) {
|
|
7837
|
+
return _ref10.apply(this, arguments);
|
|
7751
7838
|
};
|
|
7752
7839
|
}();
|
|
7753
7840
|
}, [wire, setItemList, setItemMap]);
|
|
7754
7841
|
var pushItems = React.useCallback( /*#__PURE__*/function () {
|
|
7755
|
-
var
|
|
7842
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(itemsToInsert, beforeId) {
|
|
7756
7843
|
var sync,
|
|
7757
|
-
|
|
7758
|
-
return regeneratorRuntime.wrap(function
|
|
7844
|
+
_args6 = arguments;
|
|
7845
|
+
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
7759
7846
|
while (1) {
|
|
7760
|
-
switch (
|
|
7847
|
+
switch (_context6.prev = _context6.next) {
|
|
7761
7848
|
case 0:
|
|
7762
|
-
sync =
|
|
7849
|
+
sync = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : true;
|
|
7763
7850
|
itemsToInsert.forEach( /*#__PURE__*/function () {
|
|
7764
|
-
var
|
|
7851
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(item, index) {
|
|
7765
7852
|
var center, newItem;
|
|
7766
|
-
return regeneratorRuntime.wrap(function
|
|
7853
|
+
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
7767
7854
|
while (1) {
|
|
7768
|
-
switch (
|
|
7855
|
+
switch (_context5.prev = _context5.next) {
|
|
7769
7856
|
case 0:
|
|
7770
|
-
|
|
7857
|
+
_context5.next = 2;
|
|
7771
7858
|
return getCenter();
|
|
7772
7859
|
|
|
7773
7860
|
case 2:
|
|
7774
|
-
center =
|
|
7861
|
+
center = _context5.sent;
|
|
7775
7862
|
newItem = _objectSpread2({}, item);
|
|
7776
7863
|
|
|
7777
7864
|
if (!newItem.x || !newItem.y) {
|
|
@@ -7803,28 +7890,28 @@ var useItemActions = function useItemActions() {
|
|
|
7803
7890
|
|
|
7804
7891
|
case 8:
|
|
7805
7892
|
case "end":
|
|
7806
|
-
return
|
|
7893
|
+
return _context5.stop();
|
|
7807
7894
|
}
|
|
7808
7895
|
}
|
|
7809
|
-
},
|
|
7896
|
+
}, _callee5);
|
|
7810
7897
|
}));
|
|
7811
7898
|
|
|
7812
|
-
return function (
|
|
7813
|
-
return
|
|
7899
|
+
return function (_x10, _x11) {
|
|
7900
|
+
return _ref12.apply(this, arguments);
|
|
7814
7901
|
};
|
|
7815
7902
|
}());
|
|
7816
7903
|
updateItemExtent();
|
|
7817
7904
|
|
|
7818
7905
|
case 3:
|
|
7819
7906
|
case "end":
|
|
7820
|
-
return
|
|
7907
|
+
return _context6.stop();
|
|
7821
7908
|
}
|
|
7822
7909
|
}
|
|
7823
|
-
},
|
|
7910
|
+
}, _callee6);
|
|
7824
7911
|
}));
|
|
7825
7912
|
|
|
7826
|
-
return function (
|
|
7827
|
-
return
|
|
7913
|
+
return function (_x8, _x9) {
|
|
7914
|
+
return _ref11.apply(this, arguments);
|
|
7828
7915
|
};
|
|
7829
7916
|
}(), [updateItemExtent, getCenter, setItemMap, setItemList, wire]);
|
|
7830
7917
|
var pushItem = React.useCallback(function (itemToInsert, beforeId) {
|
|
@@ -7857,40 +7944,40 @@ var useItemActions = function useItemActions() {
|
|
|
7857
7944
|
wire.publish("removeItems", itemsIdToRemove);
|
|
7858
7945
|
}
|
|
7859
7946
|
}, [wire, setItemList, setItemMap, setSelectItems]);
|
|
7860
|
-
var getItemList = useRecoilCallback(function (
|
|
7861
|
-
var snapshot =
|
|
7947
|
+
var getItemList = useRecoilCallback(function (_ref13) {
|
|
7948
|
+
var snapshot = _ref13.snapshot;
|
|
7862
7949
|
return function () {
|
|
7863
7950
|
return snapshot.getPromise(AllItemsSelector);
|
|
7864
7951
|
};
|
|
7865
7952
|
}, []);
|
|
7866
|
-
var getItems = useRecoilCallback(function (
|
|
7867
|
-
var snapshot =
|
|
7953
|
+
var getItems = useRecoilCallback(function (_ref14) {
|
|
7954
|
+
var snapshot = _ref14.snapshot;
|
|
7868
7955
|
return /*#__PURE__*/function () {
|
|
7869
|
-
var
|
|
7956
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(itemIds) {
|
|
7870
7957
|
var itemMap;
|
|
7871
|
-
return regeneratorRuntime.wrap(function
|
|
7958
|
+
return regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
7872
7959
|
while (1) {
|
|
7873
|
-
switch (
|
|
7960
|
+
switch (_context7.prev = _context7.next) {
|
|
7874
7961
|
case 0:
|
|
7875
|
-
|
|
7962
|
+
_context7.next = 2;
|
|
7876
7963
|
return snapshot.getPromise(ItemMapAtom);
|
|
7877
7964
|
|
|
7878
7965
|
case 2:
|
|
7879
|
-
itemMap =
|
|
7880
|
-
return
|
|
7966
|
+
itemMap = _context7.sent;
|
|
7967
|
+
return _context7.abrupt("return", itemIds.map(function (id) {
|
|
7881
7968
|
return itemMap[id];
|
|
7882
7969
|
}));
|
|
7883
7970
|
|
|
7884
7971
|
case 4:
|
|
7885
7972
|
case "end":
|
|
7886
|
-
return
|
|
7973
|
+
return _context7.stop();
|
|
7887
7974
|
}
|
|
7888
7975
|
}
|
|
7889
|
-
},
|
|
7976
|
+
}, _callee7);
|
|
7890
7977
|
}));
|
|
7891
7978
|
|
|
7892
|
-
return function (
|
|
7893
|
-
return
|
|
7979
|
+
return function (_x12) {
|
|
7980
|
+
return _ref15.apply(this, arguments);
|
|
7894
7981
|
};
|
|
7895
7982
|
}();
|
|
7896
7983
|
}, []);
|