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/cjs/index.js
CHANGED
|
@@ -4692,11 +4692,35 @@ var isItemInsideElement = function isItemInsideElement(itemElement, otherElem) {
|
|
|
4692
4692
|
}, rect);
|
|
4693
4693
|
});
|
|
4694
4694
|
};
|
|
4695
|
+
var getItemElem = function getItemElem(wrapper, itemId) {
|
|
4696
|
+
var elems = wrapper.getElementsByClassName("item ".concat(itemId));
|
|
4697
|
+
var elem = elems[0];
|
|
4698
|
+
|
|
4699
|
+
if (!elem) {
|
|
4700
|
+
// eslint-disable-next-line no-console
|
|
4701
|
+
console.error("Missing item ".concat(itemId));
|
|
4702
|
+
}
|
|
4703
|
+
|
|
4704
|
+
return elem;
|
|
4705
|
+
};
|
|
4706
|
+
var getIdFromElem = function getIdFromElem(elem) {
|
|
4707
|
+
var _elem$dataset;
|
|
4708
|
+
|
|
4709
|
+
var value = elem === null || elem === void 0 ? void 0 : (_elem$dataset = elem.dataset) === null || _elem$dataset === void 0 ? void 0 : _elem$dataset.id;
|
|
4710
|
+
|
|
4711
|
+
if (!value) {
|
|
4712
|
+
var _elem$dataset2;
|
|
4713
|
+
|
|
4714
|
+
// eslint-disable-next-line no-console
|
|
4715
|
+
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);
|
|
4716
|
+
}
|
|
4717
|
+
|
|
4718
|
+
return value;
|
|
4719
|
+
};
|
|
4695
4720
|
var getItemBoundingBox = function getItemBoundingBox(items) {
|
|
4696
4721
|
var wrapper = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
|
|
4697
4722
|
var result = items.reduce(function (prev, itemId) {
|
|
4698
|
-
var
|
|
4699
|
-
var elem = elems[0];
|
|
4723
|
+
var elem = getItemElem(wrapper, itemId);
|
|
4700
4724
|
if (!elem) return null;
|
|
4701
4725
|
|
|
4702
4726
|
var _elem$getBoundingClie = elem.getBoundingClientRect(),
|
|
@@ -4782,23 +4806,53 @@ var computeDistance = function computeDistance(_ref, _ref2) {
|
|
|
4782
4806
|
|
|
4783
4807
|
var empty = function empty() {};
|
|
4784
4808
|
|
|
4785
|
-
var
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4809
|
+
var protect = function protect(fn) {
|
|
4810
|
+
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
4811
|
+
var _args = arguments;
|
|
4812
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
4813
|
+
while (1) {
|
|
4814
|
+
switch (_context.prev = _context.next) {
|
|
4815
|
+
case 0:
|
|
4816
|
+
_context.prev = 0;
|
|
4817
|
+
_context.next = 3;
|
|
4818
|
+
return fn.apply(void 0, _args);
|
|
4819
|
+
|
|
4820
|
+
case 3:
|
|
4821
|
+
_context.next = 8;
|
|
4822
|
+
break;
|
|
4823
|
+
|
|
4824
|
+
case 5:
|
|
4825
|
+
_context.prev = 5;
|
|
4826
|
+
_context.t0 = _context["catch"](0);
|
|
4827
|
+
// eslint-disable-next-line no-console
|
|
4828
|
+
console.error(_context.t0);
|
|
4829
|
+
|
|
4830
|
+
case 8:
|
|
4831
|
+
case "end":
|
|
4832
|
+
return _context.stop();
|
|
4833
|
+
}
|
|
4834
|
+
}
|
|
4835
|
+
}, _callee, null, [[0, 5]]);
|
|
4836
|
+
}));
|
|
4837
|
+
};
|
|
4838
|
+
|
|
4839
|
+
var Gesture = function Gesture(_ref6) {
|
|
4840
|
+
var children = _ref6.children,
|
|
4841
|
+
_ref6$onDrag = _ref6.onDrag,
|
|
4842
|
+
onDrag = _ref6$onDrag === void 0 ? empty : _ref6$onDrag,
|
|
4843
|
+
_ref6$onDragStart = _ref6.onDragStart,
|
|
4844
|
+
onDragStart = _ref6$onDragStart === void 0 ? empty : _ref6$onDragStart,
|
|
4845
|
+
_ref6$onDragEnd = _ref6.onDragEnd,
|
|
4846
|
+
onDragEnd = _ref6$onDragEnd === void 0 ? empty : _ref6$onDragEnd,
|
|
4847
|
+
_ref6$onPan = _ref6.onPan,
|
|
4848
|
+
onPan = _ref6$onPan === void 0 ? empty : _ref6$onPan,
|
|
4849
|
+
_ref6$onTap = _ref6.onTap,
|
|
4850
|
+
onTap = _ref6$onTap === void 0 ? empty : _ref6$onTap,
|
|
4851
|
+
_ref6$onLongTap = _ref6.onLongTap,
|
|
4852
|
+
onLongTap = _ref6$onLongTap === void 0 ? empty : _ref6$onLongTap,
|
|
4853
|
+
_ref6$onDoubleTap = _ref6.onDoubleTap,
|
|
4854
|
+
onDoubleTap = _ref6$onDoubleTap === void 0 ? empty : _ref6$onDoubleTap,
|
|
4855
|
+
onZoom = _ref6.onZoom;
|
|
4802
4856
|
var wrapperRef = React__default['default'].useRef(null);
|
|
4803
4857
|
var stateRef = React__default['default'].useRef({
|
|
4804
4858
|
moving: false,
|
|
@@ -4807,36 +4861,36 @@ var Gesture = function Gesture(_ref5) {
|
|
|
4807
4861
|
});
|
|
4808
4862
|
var queueRef = React__default['default'].useRef([]); // Queue event to avoid async mess
|
|
4809
4863
|
|
|
4810
|
-
var queue = React__default['default'].useCallback(function (callback) {
|
|
4811
|
-
queueRef.current.push( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
4812
|
-
return regeneratorRuntime.wrap(function
|
|
4864
|
+
var queue = React__default['default'].useCallback(function (callback, args) {
|
|
4865
|
+
queueRef.current.push( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
4866
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
4813
4867
|
while (1) {
|
|
4814
|
-
switch (
|
|
4868
|
+
switch (_context2.prev = _context2.next) {
|
|
4815
4869
|
case 0:
|
|
4816
|
-
|
|
4817
|
-
return callback();
|
|
4870
|
+
_context2.next = 2;
|
|
4871
|
+
return protect(callback)(args);
|
|
4818
4872
|
|
|
4819
4873
|
case 2:
|
|
4820
4874
|
queueRef.current.shift();
|
|
4821
4875
|
|
|
4822
4876
|
if (!(queueRef.current.length !== 0)) {
|
|
4823
|
-
|
|
4877
|
+
_context2.next = 6;
|
|
4824
4878
|
break;
|
|
4825
4879
|
}
|
|
4826
4880
|
|
|
4827
|
-
|
|
4828
|
-
return queueRef.current[0]();
|
|
4881
|
+
_context2.next = 6;
|
|
4882
|
+
return protect(queueRef.current[0])();
|
|
4829
4883
|
|
|
4830
4884
|
case 6:
|
|
4831
4885
|
case "end":
|
|
4832
|
-
return
|
|
4886
|
+
return _context2.stop();
|
|
4833
4887
|
}
|
|
4834
4888
|
}
|
|
4835
|
-
},
|
|
4889
|
+
}, _callee2);
|
|
4836
4890
|
})));
|
|
4837
4891
|
|
|
4838
4892
|
if (queueRef.current.length === 1) {
|
|
4839
|
-
queueRef.current[0]();
|
|
4893
|
+
protect(queueRef.current[0])();
|
|
4840
4894
|
}
|
|
4841
4895
|
}, []);
|
|
4842
4896
|
var onWheel = React__default['default'].useCallback(function (e) {
|
|
@@ -4861,16 +4915,14 @@ var Gesture = function Gesture(_ref5) {
|
|
|
4861
4915
|
|
|
4862
4916
|
|
|
4863
4917
|
if (isMacOS() && !ctrlKey) {
|
|
4864
|
-
queue(
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
event: e
|
|
4873
|
-
});
|
|
4918
|
+
queue(onPan, {
|
|
4919
|
+
deltaX: -2 * deltaX,
|
|
4920
|
+
deltaY: -2 * deltaY,
|
|
4921
|
+
button: 1,
|
|
4922
|
+
ctrlKey: ctrlKey,
|
|
4923
|
+
metaKey: metaKey,
|
|
4924
|
+
target: target,
|
|
4925
|
+
event: e
|
|
4874
4926
|
});
|
|
4875
4927
|
} else {
|
|
4876
4928
|
// Quit if onZoom is not set
|
|
@@ -4892,26 +4944,24 @@ var Gesture = function Gesture(_ref5) {
|
|
|
4892
4944
|
scale *= 2;
|
|
4893
4945
|
}
|
|
4894
4946
|
|
|
4895
|
-
queue(
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
event: e
|
|
4901
|
-
});
|
|
4947
|
+
queue(onZoom, {
|
|
4948
|
+
scale: scale,
|
|
4949
|
+
clientX: clientX,
|
|
4950
|
+
clientY: clientY,
|
|
4951
|
+
event: e
|
|
4902
4952
|
});
|
|
4903
4953
|
}
|
|
4904
4954
|
}, [onPan, onZoom, queue]);
|
|
4905
|
-
var onPointerDown = React__default['default'].useCallback(function (
|
|
4906
|
-
var target =
|
|
4907
|
-
button =
|
|
4908
|
-
clientX =
|
|
4909
|
-
clientY =
|
|
4910
|
-
pointerId =
|
|
4911
|
-
altKey =
|
|
4912
|
-
ctrlKey =
|
|
4913
|
-
metaKey =
|
|
4914
|
-
isPrimary =
|
|
4955
|
+
var onPointerDown = React__default['default'].useCallback(function (_ref8) {
|
|
4956
|
+
var target = _ref8.target,
|
|
4957
|
+
button = _ref8.button,
|
|
4958
|
+
clientX = _ref8.clientX,
|
|
4959
|
+
clientY = _ref8.clientY,
|
|
4960
|
+
pointerId = _ref8.pointerId,
|
|
4961
|
+
altKey = _ref8.altKey,
|
|
4962
|
+
ctrlKey = _ref8.ctrlKey,
|
|
4963
|
+
metaKey = _ref8.metaKey,
|
|
4964
|
+
isPrimary = _ref8.isPrimary;
|
|
4915
4965
|
// Add pointer to map
|
|
4916
4966
|
stateRef.current.pointers[pointerId] = {
|
|
4917
4967
|
clientX: clientX,
|
|
@@ -4947,6 +4997,7 @@ var Gesture = function Gesture(_ref5) {
|
|
|
4947
4997
|
prevDistance: distance
|
|
4948
4998
|
});
|
|
4949
4999
|
} catch (e) {
|
|
5000
|
+
// eslint-disable-next-line no-console
|
|
4950
5001
|
console.log("Error while getting other pointer. Ignoring", e); // eslint-disable-next-line no-unused-expressions
|
|
4951
5002
|
|
|
4952
5003
|
stateRef.current.mainPointer === undefined;
|
|
@@ -4970,35 +5021,34 @@ var Gesture = function Gesture(_ref5) {
|
|
|
4970
5021
|
currentButton: button,
|
|
4971
5022
|
target: target,
|
|
4972
5023
|
timeStart: Date.now(),
|
|
4973
|
-
longTapTimeout: setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
4974
|
-
return regeneratorRuntime.wrap(function
|
|
5024
|
+
longTapTimeout: setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
5025
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
4975
5026
|
while (1) {
|
|
4976
|
-
switch (
|
|
5027
|
+
switch (_context3.prev = _context3.next) {
|
|
4977
5028
|
case 0:
|
|
4978
5029
|
stateRef.current.noTap = true;
|
|
4979
|
-
queue(
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
target: target
|
|
4987
|
-
});
|
|
5030
|
+
queue(onLongTap, {
|
|
5031
|
+
clientX: clientX,
|
|
5032
|
+
clientY: clientY,
|
|
5033
|
+
altKey: altKey,
|
|
5034
|
+
ctrlKey: ctrlKey,
|
|
5035
|
+
metaKey: metaKey,
|
|
5036
|
+
target: target
|
|
4988
5037
|
});
|
|
4989
5038
|
|
|
4990
5039
|
case 2:
|
|
4991
5040
|
case "end":
|
|
4992
|
-
return
|
|
5041
|
+
return _context3.stop();
|
|
4993
5042
|
}
|
|
4994
5043
|
}
|
|
4995
|
-
},
|
|
5044
|
+
}, _callee3);
|
|
4996
5045
|
})), 750)
|
|
4997
5046
|
});
|
|
4998
5047
|
|
|
4999
5048
|
try {
|
|
5000
5049
|
target.setPointerCapture(pointerId);
|
|
5001
5050
|
} catch (e) {
|
|
5051
|
+
// eslint-disable-next-line no-console
|
|
5002
5052
|
console.log("Fail to capture pointer", e);
|
|
5003
5053
|
}
|
|
5004
5054
|
}, [onLongTap, queue]);
|
|
@@ -5058,38 +5108,13 @@ var Gesture = function Gesture(_ref5) {
|
|
|
5058
5108
|
stateRef.current.gestureStart = true; // Clear tap timeout
|
|
5059
5109
|
|
|
5060
5110
|
clearTimeout(stateRef.current.longTapTimeout);
|
|
5061
|
-
queue(
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
deltaY: 0,
|
|
5065
|
-
startX: stateRef.current.startX,
|
|
5066
|
-
startY: stateRef.current.startY,
|
|
5067
|
-
distanceX: 0,
|
|
5068
|
-
distanceY: 0,
|
|
5069
|
-
button: stateRef.current.currentButton,
|
|
5070
|
-
altKey: altKey,
|
|
5071
|
-
ctrlKey: ctrlKey,
|
|
5072
|
-
metaKey: metaKey,
|
|
5073
|
-
target: stateRef.current.target,
|
|
5074
|
-
event: e
|
|
5075
|
-
});
|
|
5076
|
-
});
|
|
5077
|
-
} // Create closure
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
var deltaX = clientX - stateRef.current.prevX;
|
|
5081
|
-
var deltaY = clientY - stateRef.current.prevY;
|
|
5082
|
-
var distanceX = clientX - stateRef.current.startX;
|
|
5083
|
-
var distanceY = clientY - stateRef.current.startY; // Drag event
|
|
5084
|
-
|
|
5085
|
-
queue(function () {
|
|
5086
|
-
return onDrag({
|
|
5087
|
-
deltaX: deltaX,
|
|
5088
|
-
deltaY: deltaY,
|
|
5111
|
+
queue(onDragStart, {
|
|
5112
|
+
deltaX: 0,
|
|
5113
|
+
deltaY: 0,
|
|
5089
5114
|
startX: stateRef.current.startX,
|
|
5090
5115
|
startY: stateRef.current.startY,
|
|
5091
|
-
distanceX:
|
|
5092
|
-
distanceY:
|
|
5116
|
+
distanceX: 0,
|
|
5117
|
+
distanceY: 0,
|
|
5093
5118
|
button: stateRef.current.currentButton,
|
|
5094
5119
|
altKey: altKey,
|
|
5095
5120
|
ctrlKey: ctrlKey,
|
|
@@ -5097,6 +5122,27 @@ var Gesture = function Gesture(_ref5) {
|
|
|
5097
5122
|
target: stateRef.current.target,
|
|
5098
5123
|
event: e
|
|
5099
5124
|
});
|
|
5125
|
+
} // Create closure
|
|
5126
|
+
|
|
5127
|
+
|
|
5128
|
+
var deltaX = clientX - stateRef.current.prevX;
|
|
5129
|
+
var deltaY = clientY - stateRef.current.prevY;
|
|
5130
|
+
var distanceX = clientX - stateRef.current.startX;
|
|
5131
|
+
var distanceY = clientY - stateRef.current.startY; // Drag event
|
|
5132
|
+
|
|
5133
|
+
queue(onDrag, {
|
|
5134
|
+
deltaX: deltaX,
|
|
5135
|
+
deltaY: deltaY,
|
|
5136
|
+
startX: stateRef.current.startX,
|
|
5137
|
+
startY: stateRef.current.startY,
|
|
5138
|
+
distanceX: distanceX,
|
|
5139
|
+
distanceY: distanceY,
|
|
5140
|
+
button: stateRef.current.currentButton,
|
|
5141
|
+
altKey: altKey,
|
|
5142
|
+
ctrlKey: ctrlKey,
|
|
5143
|
+
metaKey: metaKey,
|
|
5144
|
+
target: stateRef.current.target,
|
|
5145
|
+
event: e
|
|
5100
5146
|
});
|
|
5101
5147
|
} else {
|
|
5102
5148
|
if (!stateRef.current.gestureStart) {
|
|
@@ -5113,30 +5159,26 @@ var Gesture = function Gesture(_ref5) {
|
|
|
5113
5159
|
|
|
5114
5160
|
var target = stateRef.current.target; // Pan event
|
|
5115
5161
|
|
|
5116
|
-
queue(
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
event: e
|
|
5126
|
-
});
|
|
5162
|
+
queue(onPan, {
|
|
5163
|
+
deltaX: _deltaX,
|
|
5164
|
+
deltaY: _deltaY,
|
|
5165
|
+
button: stateRef.current.currentButton,
|
|
5166
|
+
altKey: altKey,
|
|
5167
|
+
ctrlKey: ctrlKey,
|
|
5168
|
+
metaKey: metaKey,
|
|
5169
|
+
target: target,
|
|
5170
|
+
event: e
|
|
5127
5171
|
});
|
|
5128
5172
|
|
|
5129
5173
|
if (twoFingers && distance !== stateRef.current.prevDistance && onZoom) {
|
|
5130
5174
|
var scale = stateRef.current.prevDistance - distance;
|
|
5131
5175
|
|
|
5132
5176
|
if (Math.abs(scale) > 0) {
|
|
5133
|
-
queue(
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
event: e
|
|
5139
|
-
});
|
|
5177
|
+
queue(onZoom, {
|
|
5178
|
+
scale: scale,
|
|
5179
|
+
clientX: clientX,
|
|
5180
|
+
clientY: clientY,
|
|
5181
|
+
event: e
|
|
5140
5182
|
});
|
|
5141
5183
|
stateRef.current.prevDistance = distance;
|
|
5142
5184
|
}
|
|
@@ -5178,6 +5220,7 @@ var Gesture = function Gesture(_ref5) {
|
|
|
5178
5220
|
stateRef.current.target.setPointerCapture(stateRef.current.mainPointer);
|
|
5179
5221
|
return;
|
|
5180
5222
|
} catch (error) {
|
|
5223
|
+
// eslint-disable-next-line no-console
|
|
5181
5224
|
console.log("Fails to set pointer capture", error);
|
|
5182
5225
|
stateRef.current.mainPointer = undefined;
|
|
5183
5226
|
delete stateRef.current.pointers[Object.keys(stateRef.current.pointers)[0]];
|
|
@@ -5192,20 +5235,18 @@ var Gesture = function Gesture(_ref5) {
|
|
|
5192
5235
|
if (stateRef.current.moving) {
|
|
5193
5236
|
// If we were moving, send drag end event
|
|
5194
5237
|
stateRef.current.moving = false;
|
|
5195
|
-
queue(
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
event: e
|
|
5208
|
-
});
|
|
5238
|
+
queue(onDragEnd, {
|
|
5239
|
+
deltaX: clientX - stateRef.current.prevX,
|
|
5240
|
+
deltaY: clientY - stateRef.current.prevY,
|
|
5241
|
+
startX: stateRef.current.startX,
|
|
5242
|
+
startY: stateRef.current.startY,
|
|
5243
|
+
distanceX: clientX - stateRef.current.startX,
|
|
5244
|
+
distanceY: clientY - stateRef.current.startY,
|
|
5245
|
+
button: stateRef.current.currentButton,
|
|
5246
|
+
altKey: altKey,
|
|
5247
|
+
ctrlKey: ctrlKey,
|
|
5248
|
+
metaKey: metaKey,
|
|
5249
|
+
event: e
|
|
5209
5250
|
});
|
|
5210
5251
|
wrapperRef.current.style.cursor = "auto";
|
|
5211
5252
|
} else {
|
|
@@ -5215,22 +5256,20 @@ var Gesture = function Gesture(_ref5) {
|
|
|
5215
5256
|
stateRef.current.noTap = false;
|
|
5216
5257
|
} // Send tap event only if time less than 300ms
|
|
5217
5258
|
else if (stateRef.current.timeStart - now < 300) {
|
|
5218
|
-
queue(
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
target: target
|
|
5226
|
-
});
|
|
5259
|
+
queue(onTap, {
|
|
5260
|
+
clientX: clientX,
|
|
5261
|
+
clientY: clientY,
|
|
5262
|
+
altKey: altKey,
|
|
5263
|
+
ctrlKey: ctrlKey,
|
|
5264
|
+
metaKey: metaKey,
|
|
5265
|
+
target: target
|
|
5227
5266
|
});
|
|
5228
5267
|
}
|
|
5229
5268
|
}
|
|
5230
5269
|
}, [onDragEnd, onTap, queue]);
|
|
5231
5270
|
var onDoubleTapHandler = React__default['default'].useCallback(function (event) {
|
|
5232
|
-
onDoubleTap
|
|
5233
|
-
}, [onDoubleTap]);
|
|
5271
|
+
queue(onDoubleTap, event);
|
|
5272
|
+
}, [onDoubleTap, queue]);
|
|
5234
5273
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
5235
5274
|
onWheel: onWheel,
|
|
5236
5275
|
onPointerDown: onPointerDown,
|
|
@@ -5263,22 +5302,16 @@ var findSelected = function findSelected(itemMap, wrapper) {
|
|
|
5263
5302
|
|
|
5264
5303
|
var selector = selectors[0];
|
|
5265
5304
|
return Array.from(wrapper.getElementsByClassName("item")).filter(function (elem) {
|
|
5266
|
-
var id = elem
|
|
5305
|
+
var id = getIdFromElem(elem);
|
|
5267
5306
|
var item = itemMap[id];
|
|
5268
5307
|
|
|
5269
|
-
if (!item) {
|
|
5270
|
-
// Avoid to find item that are not yet removed from DOM
|
|
5271
|
-
console.error("Missing item ".concat(id));
|
|
5272
|
-
return false;
|
|
5273
|
-
}
|
|
5274
|
-
|
|
5275
|
-
if (item.locked) {
|
|
5308
|
+
if (!item || item.locked) {
|
|
5276
5309
|
return false;
|
|
5277
5310
|
}
|
|
5278
5311
|
|
|
5279
5312
|
return isItemInsideElement(elem, selector);
|
|
5280
5313
|
}).map(function (elem) {
|
|
5281
|
-
return elem
|
|
5314
|
+
return getIdFromElem(elem);
|
|
5282
5315
|
});
|
|
5283
5316
|
};
|
|
5284
5317
|
|
|
@@ -5456,7 +5489,8 @@ var Selector = function Selector(_ref) {
|
|
|
5456
5489
|
var foundElement = insideClass(target, "item");
|
|
5457
5490
|
|
|
5458
5491
|
if (foundElement) {
|
|
5459
|
-
|
|
5492
|
+
var id = getIdFromElem(foundElement);
|
|
5493
|
+
setSelected([id]);
|
|
5460
5494
|
}
|
|
5461
5495
|
}, [setSelected]);
|
|
5462
5496
|
var onTap = recoil.useRecoilCallback(function (_ref9) {
|
|
@@ -5477,15 +5511,25 @@ var Selector = function Selector(_ref) {
|
|
|
5477
5511
|
}
|
|
5478
5512
|
|
|
5479
5513
|
setSelected([]);
|
|
5480
|
-
_context3.next =
|
|
5514
|
+
_context3.next = 14;
|
|
5481
5515
|
break;
|
|
5482
5516
|
|
|
5483
5517
|
case 6:
|
|
5484
|
-
itemId = foundItem
|
|
5485
|
-
|
|
5518
|
+
itemId = getIdFromElem(foundItem); // Being defensive here to avoid bug
|
|
5519
|
+
|
|
5520
|
+
if (itemId) {
|
|
5521
|
+
_context3.next = 10;
|
|
5522
|
+
break;
|
|
5523
|
+
}
|
|
5524
|
+
|
|
5525
|
+
setSelected([]);
|
|
5526
|
+
return _context3.abrupt("return");
|
|
5527
|
+
|
|
5528
|
+
case 10:
|
|
5529
|
+
_context3.next = 12;
|
|
5486
5530
|
return snapshot.getPromise(SelectedItemsAtom);
|
|
5487
5531
|
|
|
5488
|
-
case
|
|
5532
|
+
case 12:
|
|
5489
5533
|
selectedItems = _context3.sent;
|
|
5490
5534
|
|
|
5491
5535
|
if (foundItem && !selectedItems.includes(itemId)) {
|
|
@@ -5498,7 +5542,7 @@ var Selector = function Selector(_ref) {
|
|
|
5498
5542
|
}
|
|
5499
5543
|
}
|
|
5500
5544
|
|
|
5501
|
-
case
|
|
5545
|
+
case 14:
|
|
5502
5546
|
case "end":
|
|
5503
5547
|
return _context3.stop();
|
|
5504
5548
|
}
|
|
@@ -5577,7 +5621,7 @@ var ActionPane = function ActionPane(_ref) {
|
|
|
5577
5621
|
case 8:
|
|
5578
5622
|
selectedItems = _context.sent;
|
|
5579
5623
|
selectedItemRef.current.items = selectedItems;
|
|
5580
|
-
itemId = foundElement
|
|
5624
|
+
itemId = getIdFromElem(foundElement);
|
|
5581
5625
|
|
|
5582
5626
|
if (!selectedItems.includes(itemId)) {
|
|
5583
5627
|
if (ctrlKey || metaKey) {
|
|
@@ -5970,8 +6014,8 @@ function F(t) {
|
|
|
5970
6014
|
var _excluded$1 = ["pos"];
|
|
5971
6015
|
|
|
5972
6016
|
var _templateObject$1, _templateObject2;
|
|
5973
|
-
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"])));
|
|
5974
|
-
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) {
|
|
6017
|
+
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"])));
|
|
6018
|
+
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) {
|
|
5975
6019
|
var textColor = _ref.textColor;
|
|
5976
6020
|
return textColor;
|
|
5977
6021
|
}, function (_ref2) {
|
|
@@ -6023,7 +6067,8 @@ var PositionnedCursor = function PositionnedCursor(_ref4) {
|
|
|
6023
6067
|
top: 0,
|
|
6024
6068
|
left: 0,
|
|
6025
6069
|
zIndex: 210,
|
|
6026
|
-
position: "fixed"
|
|
6070
|
+
position: "fixed",
|
|
6071
|
+
pointerEvents: "none"
|
|
6027
6072
|
}
|
|
6028
6073
|
}, /*#__PURE__*/React__default['default'].createElement(MemoizedCursor, rest));
|
|
6029
6074
|
};
|
|
@@ -6181,6 +6226,8 @@ var useUsers = function useUsers() {
|
|
|
6181
6226
|
});
|
|
6182
6227
|
}, [setCurrentUserState]);
|
|
6183
6228
|
var localUsers = React__default['default'].useMemo(function () {
|
|
6229
|
+
// eslint-disable-next-line no-console
|
|
6230
|
+
console.debug("Curent user is in space ".concat(currentUser.space));
|
|
6184
6231
|
return users.filter(function (_ref) {
|
|
6185
6232
|
var space = _ref.space;
|
|
6186
6233
|
return space === currentUser.space;
|
|
@@ -7462,6 +7509,11 @@ var useItemActions = function useItemActions() {
|
|
|
7462
7509
|
|
|
7463
7510
|
itemIds.forEach(function (id) {
|
|
7464
7511
|
var item = prevItemMap[id];
|
|
7512
|
+
|
|
7513
|
+
if (!item) {
|
|
7514
|
+
return;
|
|
7515
|
+
}
|
|
7516
|
+
|
|
7465
7517
|
result[id] = _objectSpread2(_objectSpread2({}, item), {}, {
|
|
7466
7518
|
x: (item.x || 0) + posDelta.x,
|
|
7467
7519
|
y: (item.y || 0) + posDelta.y,
|
|
@@ -7498,120 +7550,155 @@ var useItemActions = function useItemActions() {
|
|
|
7498
7550
|
return result;
|
|
7499
7551
|
});
|
|
7500
7552
|
}, [setItemList, wire]);
|
|
7501
|
-
var stickOnGrid =
|
|
7502
|
-
var
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7553
|
+
var stickOnGrid = recoil.useRecoilCallback(function (_ref4) {
|
|
7554
|
+
var snapshot = _ref4.snapshot;
|
|
7555
|
+
return /*#__PURE__*/function () {
|
|
7556
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(itemIds) {
|
|
7557
|
+
var _ref6,
|
|
7558
|
+
globalType,
|
|
7559
|
+
globalSize,
|
|
7560
|
+
sync,
|
|
7561
|
+
_yield$snapshot$getPr,
|
|
7562
|
+
boardWrapper,
|
|
7563
|
+
updatedItems,
|
|
7564
|
+
_args2 = arguments;
|
|
7510
7565
|
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7566
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
7567
|
+
while (1) {
|
|
7568
|
+
switch (_context2.prev = _context2.next) {
|
|
7569
|
+
case 0:
|
|
7570
|
+
_ref6 = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {}, globalType = _ref6.type, globalSize = _ref6.size;
|
|
7571
|
+
sync = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : true;
|
|
7572
|
+
_context2.next = 4;
|
|
7573
|
+
return snapshot.getPromise(ConfigurationAtom);
|
|
7515
7574
|
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7575
|
+
case 4:
|
|
7576
|
+
_yield$snapshot$getPr = _context2.sent;
|
|
7577
|
+
boardWrapper = _yield$snapshot$getPr.boardWrapper;
|
|
7578
|
+
updatedItems = {};
|
|
7579
|
+
setItemMap(function (prevItemMap) {
|
|
7580
|
+
var result = _objectSpread2({}, prevItemMap);
|
|
7519
7581
|
|
|
7520
|
-
|
|
7521
|
-
|
|
7582
|
+
itemIds.forEach(function (id) {
|
|
7583
|
+
var item = prevItemMap[id];
|
|
7584
|
+
var elem = getItemElem(boardWrapper, id);
|
|
7522
7585
|
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
}
|
|
7586
|
+
if (!elem) {
|
|
7587
|
+
return;
|
|
7588
|
+
}
|
|
7527
7589
|
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
7531
|
-
var newY;
|
|
7532
|
-
var sizeX;
|
|
7533
|
-
var sizeY;
|
|
7534
|
-
var px1;
|
|
7535
|
-
var px2;
|
|
7536
|
-
var py1;
|
|
7537
|
-
var py2;
|
|
7538
|
-
var diff1;
|
|
7539
|
-
var diff2;
|
|
7540
|
-
var h = size / 1.1547;
|
|
7541
|
-
|
|
7542
|
-
switch (type) {
|
|
7543
|
-
case "grid":
|
|
7544
|
-
newX = Math.round(centerX / size) * size;
|
|
7545
|
-
newY = Math.round(centerY / size) * size;
|
|
7546
|
-
break;
|
|
7590
|
+
var _ref7 = item.grid || {},
|
|
7591
|
+
itemType = _ref7.type,
|
|
7592
|
+
itemSize = _ref7.size;
|
|
7547
7593
|
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
sizeY = 3 * size;
|
|
7551
|
-
px1 = Math.round(centerX / sizeX) * sizeX;
|
|
7552
|
-
py1 = Math.round(centerY / sizeY) * sizeY;
|
|
7553
|
-
px2 = px1 > centerX ? px1 - h : px1 + h;
|
|
7554
|
-
py2 = py1 > centerY ? py1 - 1.5 * size : py1 + 1.5 * size;
|
|
7555
|
-
diff1 = Math.hypot.apply(Math, [px1 - centerX, py1 - centerY]);
|
|
7556
|
-
diff2 = Math.hypot.apply(Math, [px2 - centerX, py2 - centerY]);
|
|
7557
|
-
|
|
7558
|
-
if (diff1 < diff2) {
|
|
7559
|
-
newX = px1;
|
|
7560
|
-
newY = py1;
|
|
7561
|
-
} else {
|
|
7562
|
-
newX = px2;
|
|
7563
|
-
newY = py2;
|
|
7564
|
-
}
|
|
7594
|
+
var type = globalType;
|
|
7595
|
+
var size = globalSize || 1; // If item specific
|
|
7565
7596
|
|
|
7566
|
-
|
|
7597
|
+
if (itemType) {
|
|
7598
|
+
type = itemType;
|
|
7599
|
+
size = itemSize || 1;
|
|
7600
|
+
}
|
|
7567
7601
|
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7602
|
+
var centerX = item.x + elem.clientWidth / 2,
|
|
7603
|
+
centerY = item.y + elem.clientHeight / 2;
|
|
7604
|
+
var newX;
|
|
7605
|
+
var newY;
|
|
7606
|
+
var sizeX;
|
|
7607
|
+
var sizeY;
|
|
7608
|
+
var px1;
|
|
7609
|
+
var px2;
|
|
7610
|
+
var py1;
|
|
7611
|
+
var py2;
|
|
7612
|
+
var diff1;
|
|
7613
|
+
var diff2;
|
|
7614
|
+
var h = size / 1.1547;
|
|
7615
|
+
|
|
7616
|
+
switch (type) {
|
|
7617
|
+
case "grid":
|
|
7618
|
+
newX = Math.round(centerX / size) * size;
|
|
7619
|
+
newY = Math.round(centerY / size) * size;
|
|
7620
|
+
break;
|
|
7621
|
+
|
|
7622
|
+
case "hexH":
|
|
7623
|
+
sizeX = 2 * h;
|
|
7624
|
+
sizeY = 3 * size;
|
|
7625
|
+
px1 = Math.round(centerX / sizeX) * sizeX;
|
|
7626
|
+
py1 = Math.round(centerY / sizeY) * sizeY;
|
|
7627
|
+
px2 = px1 > centerX ? px1 - h : px1 + h;
|
|
7628
|
+
py2 = py1 > centerY ? py1 - 1.5 * size : py1 + 1.5 * size;
|
|
7629
|
+
diff1 = Math.hypot.apply(Math, [px1 - centerX, py1 - centerY]);
|
|
7630
|
+
diff2 = Math.hypot.apply(Math, [px2 - centerX, py2 - centerY]);
|
|
7631
|
+
|
|
7632
|
+
if (diff1 < diff2) {
|
|
7633
|
+
newX = px1;
|
|
7634
|
+
newY = py1;
|
|
7635
|
+
} else {
|
|
7636
|
+
newX = px2;
|
|
7637
|
+
newY = py2;
|
|
7638
|
+
}
|
|
7639
|
+
|
|
7640
|
+
break;
|
|
7641
|
+
|
|
7642
|
+
case "hexV":
|
|
7643
|
+
sizeX = 3 * size;
|
|
7644
|
+
sizeY = 2 * h;
|
|
7645
|
+
px1 = Math.round(centerX / sizeX) * sizeX;
|
|
7646
|
+
py1 = Math.round(centerY / sizeY) * sizeY;
|
|
7647
|
+
px2 = px1 > centerX ? px1 - 1.5 * size : px1 + 1.5 * size;
|
|
7648
|
+
py2 = py1 > centerY ? py1 - h : py1 + h;
|
|
7649
|
+
diff1 = Math.hypot.apply(Math, [px1 - centerX, py1 - centerY]);
|
|
7650
|
+
diff2 = Math.hypot.apply(Math, [px2 - centerX, py2 - centerY]);
|
|
7651
|
+
|
|
7652
|
+
if (diff1 < diff2) {
|
|
7653
|
+
newX = px1;
|
|
7654
|
+
newY = py1;
|
|
7655
|
+
} else {
|
|
7656
|
+
newX = px2;
|
|
7657
|
+
newY = py2;
|
|
7658
|
+
}
|
|
7659
|
+
|
|
7660
|
+
break;
|
|
7661
|
+
|
|
7662
|
+
default:
|
|
7663
|
+
newX = item.x + elem.clientWidth / 2;
|
|
7664
|
+
newY = item.y + elem.clientHeight / 2;
|
|
7665
|
+
}
|
|
7585
7666
|
|
|
7586
|
-
|
|
7667
|
+
result[id] = _objectSpread2(_objectSpread2({}, item), {}, {
|
|
7668
|
+
x: newX - elem.clientWidth / 2,
|
|
7669
|
+
y: newY - elem.clientHeight / 2
|
|
7670
|
+
});
|
|
7671
|
+
updatedItems[id] = result[id];
|
|
7672
|
+
});
|
|
7673
|
+
return result;
|
|
7674
|
+
});
|
|
7587
7675
|
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
}
|
|
7676
|
+
if (sync) {
|
|
7677
|
+
wire.publish("batchItemsUpdate", updatedItems);
|
|
7678
|
+
}
|
|
7592
7679
|
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
});
|
|
7680
|
+
case 9:
|
|
7681
|
+
case "end":
|
|
7682
|
+
return _context2.stop();
|
|
7683
|
+
}
|
|
7684
|
+
}
|
|
7685
|
+
}, _callee2);
|
|
7686
|
+
}));
|
|
7601
7687
|
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7688
|
+
return function (_x3) {
|
|
7689
|
+
return _ref5.apply(this, arguments);
|
|
7690
|
+
};
|
|
7691
|
+
}();
|
|
7605
7692
|
}, [wire, setItemMap]);
|
|
7606
7693
|
var placeItems = React__default['default'].useCallback( /*#__PURE__*/function () {
|
|
7607
|
-
var
|
|
7694
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(itemIds, gridConfig) {
|
|
7608
7695
|
var sync,
|
|
7609
|
-
|
|
7610
|
-
return regeneratorRuntime.wrap(function
|
|
7696
|
+
_args3 = arguments;
|
|
7697
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
7611
7698
|
while (1) {
|
|
7612
|
-
switch (
|
|
7699
|
+
switch (_context3.prev = _context3.next) {
|
|
7613
7700
|
case 0:
|
|
7614
|
-
sync =
|
|
7701
|
+
sync = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : true;
|
|
7615
7702
|
// Put moved items on top
|
|
7616
7703
|
putItemsOnTop(itemIds, sync); // Remove moving state
|
|
7617
7704
|
|
|
@@ -7627,14 +7714,14 @@ var useItemActions = function useItemActions() {
|
|
|
7627
7714
|
|
|
7628
7715
|
case 6:
|
|
7629
7716
|
case "end":
|
|
7630
|
-
return
|
|
7717
|
+
return _context3.stop();
|
|
7631
7718
|
}
|
|
7632
7719
|
}
|
|
7633
|
-
},
|
|
7720
|
+
}, _callee3);
|
|
7634
7721
|
}));
|
|
7635
7722
|
|
|
7636
|
-
return function (
|
|
7637
|
-
return
|
|
7723
|
+
return function (_x4, _x5) {
|
|
7724
|
+
return _ref8.apply(this, arguments);
|
|
7638
7725
|
};
|
|
7639
7726
|
}(), [batchUpdateItems, callPlaceInteractions, putItemsOnTop, stickOnGrid, updateItemExtent]);
|
|
7640
7727
|
var updateItemOrder = React__default['default'].useCallback(function (newOrder) {
|
|
@@ -7673,27 +7760,27 @@ var useItemActions = function useItemActions() {
|
|
|
7673
7760
|
return reversed;
|
|
7674
7761
|
});
|
|
7675
7762
|
}, [setItemList, wire, setSelectItems]);
|
|
7676
|
-
var swapItems = recoil.useRecoilCallback(function (
|
|
7677
|
-
var snapshot =
|
|
7763
|
+
var swapItems = recoil.useRecoilCallback(function (_ref9) {
|
|
7764
|
+
var snapshot = _ref9.snapshot;
|
|
7678
7765
|
return /*#__PURE__*/function () {
|
|
7679
|
-
var
|
|
7766
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(fromIds, toIds) {
|
|
7680
7767
|
var sync,
|
|
7681
7768
|
itemMap,
|
|
7682
7769
|
fromItems,
|
|
7683
7770
|
toItems,
|
|
7684
7771
|
replaceMapItems,
|
|
7685
7772
|
replaceMap,
|
|
7686
|
-
|
|
7687
|
-
return regeneratorRuntime.wrap(function
|
|
7773
|
+
_args4 = arguments;
|
|
7774
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
7688
7775
|
while (1) {
|
|
7689
|
-
switch (
|
|
7776
|
+
switch (_context4.prev = _context4.next) {
|
|
7690
7777
|
case 0:
|
|
7691
|
-
sync =
|
|
7692
|
-
|
|
7778
|
+
sync = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : true;
|
|
7779
|
+
_context4.next = 3;
|
|
7693
7780
|
return snapshot.getPromise(ItemMapAtom);
|
|
7694
7781
|
|
|
7695
7782
|
case 3:
|
|
7696
|
-
itemMap =
|
|
7783
|
+
itemMap = _context4.sent;
|
|
7697
7784
|
fromItems = fromIds.map(function (id) {
|
|
7698
7785
|
return itemMap[id];
|
|
7699
7786
|
});
|
|
@@ -7748,38 +7835,38 @@ var useItemActions = function useItemActions() {
|
|
|
7748
7835
|
|
|
7749
7836
|
case 10:
|
|
7750
7837
|
case "end":
|
|
7751
|
-
return
|
|
7838
|
+
return _context4.stop();
|
|
7752
7839
|
}
|
|
7753
7840
|
}
|
|
7754
|
-
},
|
|
7841
|
+
}, _callee4);
|
|
7755
7842
|
}));
|
|
7756
7843
|
|
|
7757
|
-
return function (
|
|
7758
|
-
return
|
|
7844
|
+
return function (_x6, _x7) {
|
|
7845
|
+
return _ref10.apply(this, arguments);
|
|
7759
7846
|
};
|
|
7760
7847
|
}();
|
|
7761
7848
|
}, [wire, setItemList, setItemMap]);
|
|
7762
7849
|
var pushItems = React__default['default'].useCallback( /*#__PURE__*/function () {
|
|
7763
|
-
var
|
|
7850
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(itemsToInsert, beforeId) {
|
|
7764
7851
|
var sync,
|
|
7765
|
-
|
|
7766
|
-
return regeneratorRuntime.wrap(function
|
|
7852
|
+
_args6 = arguments;
|
|
7853
|
+
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
7767
7854
|
while (1) {
|
|
7768
|
-
switch (
|
|
7855
|
+
switch (_context6.prev = _context6.next) {
|
|
7769
7856
|
case 0:
|
|
7770
|
-
sync =
|
|
7857
|
+
sync = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : true;
|
|
7771
7858
|
itemsToInsert.forEach( /*#__PURE__*/function () {
|
|
7772
|
-
var
|
|
7859
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(item, index) {
|
|
7773
7860
|
var center, newItem;
|
|
7774
|
-
return regeneratorRuntime.wrap(function
|
|
7861
|
+
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
7775
7862
|
while (1) {
|
|
7776
|
-
switch (
|
|
7863
|
+
switch (_context5.prev = _context5.next) {
|
|
7777
7864
|
case 0:
|
|
7778
|
-
|
|
7865
|
+
_context5.next = 2;
|
|
7779
7866
|
return getCenter();
|
|
7780
7867
|
|
|
7781
7868
|
case 2:
|
|
7782
|
-
center =
|
|
7869
|
+
center = _context5.sent;
|
|
7783
7870
|
newItem = _objectSpread2({}, item);
|
|
7784
7871
|
|
|
7785
7872
|
if (!newItem.x || !newItem.y) {
|
|
@@ -7811,28 +7898,28 @@ var useItemActions = function useItemActions() {
|
|
|
7811
7898
|
|
|
7812
7899
|
case 8:
|
|
7813
7900
|
case "end":
|
|
7814
|
-
return
|
|
7901
|
+
return _context5.stop();
|
|
7815
7902
|
}
|
|
7816
7903
|
}
|
|
7817
|
-
},
|
|
7904
|
+
}, _callee5);
|
|
7818
7905
|
}));
|
|
7819
7906
|
|
|
7820
|
-
return function (
|
|
7821
|
-
return
|
|
7907
|
+
return function (_x10, _x11) {
|
|
7908
|
+
return _ref12.apply(this, arguments);
|
|
7822
7909
|
};
|
|
7823
7910
|
}());
|
|
7824
7911
|
updateItemExtent();
|
|
7825
7912
|
|
|
7826
7913
|
case 3:
|
|
7827
7914
|
case "end":
|
|
7828
|
-
return
|
|
7915
|
+
return _context6.stop();
|
|
7829
7916
|
}
|
|
7830
7917
|
}
|
|
7831
|
-
},
|
|
7918
|
+
}, _callee6);
|
|
7832
7919
|
}));
|
|
7833
7920
|
|
|
7834
|
-
return function (
|
|
7835
|
-
return
|
|
7921
|
+
return function (_x8, _x9) {
|
|
7922
|
+
return _ref11.apply(this, arguments);
|
|
7836
7923
|
};
|
|
7837
7924
|
}(), [updateItemExtent, getCenter, setItemMap, setItemList, wire]);
|
|
7838
7925
|
var pushItem = React__default['default'].useCallback(function (itemToInsert, beforeId) {
|
|
@@ -7865,40 +7952,40 @@ var useItemActions = function useItemActions() {
|
|
|
7865
7952
|
wire.publish("removeItems", itemsIdToRemove);
|
|
7866
7953
|
}
|
|
7867
7954
|
}, [wire, setItemList, setItemMap, setSelectItems]);
|
|
7868
|
-
var getItemList = recoil.useRecoilCallback(function (
|
|
7869
|
-
var snapshot =
|
|
7955
|
+
var getItemList = recoil.useRecoilCallback(function (_ref13) {
|
|
7956
|
+
var snapshot = _ref13.snapshot;
|
|
7870
7957
|
return function () {
|
|
7871
7958
|
return snapshot.getPromise(AllItemsSelector);
|
|
7872
7959
|
};
|
|
7873
7960
|
}, []);
|
|
7874
|
-
var getItems = recoil.useRecoilCallback(function (
|
|
7875
|
-
var snapshot =
|
|
7961
|
+
var getItems = recoil.useRecoilCallback(function (_ref14) {
|
|
7962
|
+
var snapshot = _ref14.snapshot;
|
|
7876
7963
|
return /*#__PURE__*/function () {
|
|
7877
|
-
var
|
|
7964
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(itemIds) {
|
|
7878
7965
|
var itemMap;
|
|
7879
|
-
return regeneratorRuntime.wrap(function
|
|
7966
|
+
return regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
7880
7967
|
while (1) {
|
|
7881
|
-
switch (
|
|
7968
|
+
switch (_context7.prev = _context7.next) {
|
|
7882
7969
|
case 0:
|
|
7883
|
-
|
|
7970
|
+
_context7.next = 2;
|
|
7884
7971
|
return snapshot.getPromise(ItemMapAtom);
|
|
7885
7972
|
|
|
7886
7973
|
case 2:
|
|
7887
|
-
itemMap =
|
|
7888
|
-
return
|
|
7974
|
+
itemMap = _context7.sent;
|
|
7975
|
+
return _context7.abrupt("return", itemIds.map(function (id) {
|
|
7889
7976
|
return itemMap[id];
|
|
7890
7977
|
}));
|
|
7891
7978
|
|
|
7892
7979
|
case 4:
|
|
7893
7980
|
case "end":
|
|
7894
|
-
return
|
|
7981
|
+
return _context7.stop();
|
|
7895
7982
|
}
|
|
7896
7983
|
}
|
|
7897
|
-
},
|
|
7984
|
+
}, _callee7);
|
|
7898
7985
|
}));
|
|
7899
7986
|
|
|
7900
|
-
return function (
|
|
7901
|
-
return
|
|
7987
|
+
return function (_x12) {
|
|
7988
|
+
return _ref15.apply(this, arguments);
|
|
7902
7989
|
};
|
|
7903
7990
|
}();
|
|
7904
7991
|
}, []);
|