react-sync-board 0.4.1 → 0.4.4
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 +416 -325
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +416 -325
- 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
|
};
|
|
@@ -6145,6 +6190,21 @@ var usersAtom = atom({
|
|
|
6145
6190
|
key: "users",
|
|
6146
6191
|
"default": []
|
|
6147
6192
|
});
|
|
6193
|
+
var localUsersAtom = selector({
|
|
6194
|
+
key: "localUsersAtom",
|
|
6195
|
+
get: function get(_ref) {
|
|
6196
|
+
var _get = _ref.get;
|
|
6197
|
+
|
|
6198
|
+
var currentUser = _get(userAtom);
|
|
6199
|
+
|
|
6200
|
+
var users = _get(usersAtom);
|
|
6201
|
+
|
|
6202
|
+
return users.filter(function (_ref2) {
|
|
6203
|
+
var space = _ref2.space;
|
|
6204
|
+
return space === currentUser.space;
|
|
6205
|
+
});
|
|
6206
|
+
}
|
|
6207
|
+
});
|
|
6148
6208
|
|
|
6149
6209
|
var useUsers = function useUsers() {
|
|
6150
6210
|
var _useRecoilState = useRecoilState(userAtom),
|
|
@@ -6153,6 +6213,7 @@ var useUsers = function useUsers() {
|
|
|
6153
6213
|
setCurrentUserState = _useRecoilState2[1];
|
|
6154
6214
|
|
|
6155
6215
|
var users = useRecoilValue(usersAtom);
|
|
6216
|
+
var localUsers = useRecoilValue(localUsersAtom);
|
|
6156
6217
|
var setCurrentUser = React.useCallback(function (callbackOrUser) {
|
|
6157
6218
|
var callback = callbackOrUser;
|
|
6158
6219
|
|
|
@@ -6172,12 +6233,10 @@ var useUsers = function useUsers() {
|
|
|
6172
6233
|
return newUser;
|
|
6173
6234
|
});
|
|
6174
6235
|
}, [setCurrentUserState]);
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
});
|
|
6180
|
-
}, [currentUser.space, users]);
|
|
6236
|
+
React.useEffect(function () {
|
|
6237
|
+
// eslint-disable-next-line no-console
|
|
6238
|
+
console.debug("Curent user is in space ".concat(currentUser.space));
|
|
6239
|
+
}, [currentUser.space]);
|
|
6181
6240
|
return {
|
|
6182
6241
|
currentUser: currentUser,
|
|
6183
6242
|
setCurrentUser: setCurrentUser,
|
|
@@ -6900,9 +6959,6 @@ var Board = function Board(_ref) {
|
|
|
6900
6959
|
var _useDim = useDim(),
|
|
6901
6960
|
updateItemExtent = _useDim.updateItemExtent;
|
|
6902
6961
|
|
|
6903
|
-
var _useRecoilValue = useRecoilValue(ConfigurationAtom),
|
|
6904
|
-
itemExtent = _useRecoilValue.itemExtent;
|
|
6905
|
-
|
|
6906
6962
|
var boardStyle = React.useMemo(function () {
|
|
6907
6963
|
return _objectSpread2({
|
|
6908
6964
|
userSelect: "none",
|
|
@@ -6935,12 +6991,7 @@ var Board = function Board(_ref) {
|
|
|
6935
6991
|
className: "board"
|
|
6936
6992
|
}, /*#__PURE__*/React.createElement(ItemList, {
|
|
6937
6993
|
itemTemplates: itemTemplates
|
|
6938
|
-
})), /*#__PURE__*/React.createElement(
|
|
6939
|
-
style: _objectSpread2(_objectSpread2({}, itemExtent), {}, {
|
|
6940
|
-
border: "3px solid red",
|
|
6941
|
-
position: "absolute"
|
|
6942
|
-
})
|
|
6943
|
-
}))))), /*#__PURE__*/React.createElement(Selection, null));
|
|
6994
|
+
})))))), /*#__PURE__*/React.createElement(Selection, null));
|
|
6944
6995
|
};
|
|
6945
6996
|
|
|
6946
6997
|
var TOLERANCE = 100;
|
|
@@ -7462,6 +7513,11 @@ var useItemActions = function useItemActions() {
|
|
|
7462
7513
|
|
|
7463
7514
|
itemIds.forEach(function (id) {
|
|
7464
7515
|
var item = prevItemMap[id];
|
|
7516
|
+
|
|
7517
|
+
if (!item) {
|
|
7518
|
+
return;
|
|
7519
|
+
}
|
|
7520
|
+
|
|
7465
7521
|
result[id] = _objectSpread2(_objectSpread2({}, item), {}, {
|
|
7466
7522
|
x: (item.x || 0) + posDelta.x,
|
|
7467
7523
|
y: (item.y || 0) + posDelta.y,
|
|
@@ -7498,120 +7554,155 @@ var useItemActions = function useItemActions() {
|
|
|
7498
7554
|
return result;
|
|
7499
7555
|
});
|
|
7500
7556
|
}, [setItemList, wire]);
|
|
7501
|
-
var stickOnGrid =
|
|
7502
|
-
var
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7557
|
+
var stickOnGrid = useRecoilCallback(function (_ref4) {
|
|
7558
|
+
var snapshot = _ref4.snapshot;
|
|
7559
|
+
return /*#__PURE__*/function () {
|
|
7560
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(itemIds) {
|
|
7561
|
+
var _ref6,
|
|
7562
|
+
globalType,
|
|
7563
|
+
globalSize,
|
|
7564
|
+
sync,
|
|
7565
|
+
_yield$snapshot$getPr,
|
|
7566
|
+
boardWrapper,
|
|
7567
|
+
updatedItems,
|
|
7568
|
+
_args2 = arguments;
|
|
7510
7569
|
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7570
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
7571
|
+
while (1) {
|
|
7572
|
+
switch (_context2.prev = _context2.next) {
|
|
7573
|
+
case 0:
|
|
7574
|
+
_ref6 = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {}, globalType = _ref6.type, globalSize = _ref6.size;
|
|
7575
|
+
sync = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : true;
|
|
7576
|
+
_context2.next = 4;
|
|
7577
|
+
return snapshot.getPromise(ConfigurationAtom);
|
|
7515
7578
|
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7579
|
+
case 4:
|
|
7580
|
+
_yield$snapshot$getPr = _context2.sent;
|
|
7581
|
+
boardWrapper = _yield$snapshot$getPr.boardWrapper;
|
|
7582
|
+
updatedItems = {};
|
|
7583
|
+
setItemMap(function (prevItemMap) {
|
|
7584
|
+
var result = _objectSpread2({}, prevItemMap);
|
|
7519
7585
|
|
|
7520
|
-
|
|
7521
|
-
|
|
7586
|
+
itemIds.forEach(function (id) {
|
|
7587
|
+
var item = prevItemMap[id];
|
|
7588
|
+
var elem = getItemElem(boardWrapper, id);
|
|
7522
7589
|
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
}
|
|
7590
|
+
if (!elem) {
|
|
7591
|
+
return;
|
|
7592
|
+
}
|
|
7527
7593
|
|
|
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;
|
|
7594
|
+
var _ref7 = item.grid || {},
|
|
7595
|
+
itemType = _ref7.type,
|
|
7596
|
+
itemSize = _ref7.size;
|
|
7547
7597
|
|
|
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
|
-
}
|
|
7598
|
+
var type = globalType;
|
|
7599
|
+
var size = globalSize || 1; // If item specific
|
|
7565
7600
|
|
|
7566
|
-
|
|
7601
|
+
if (itemType) {
|
|
7602
|
+
type = itemType;
|
|
7603
|
+
size = itemSize || 1;
|
|
7604
|
+
}
|
|
7567
7605
|
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7606
|
+
var centerX = item.x + elem.clientWidth / 2,
|
|
7607
|
+
centerY = item.y + elem.clientHeight / 2;
|
|
7608
|
+
var newX;
|
|
7609
|
+
var newY;
|
|
7610
|
+
var sizeX;
|
|
7611
|
+
var sizeY;
|
|
7612
|
+
var px1;
|
|
7613
|
+
var px2;
|
|
7614
|
+
var py1;
|
|
7615
|
+
var py2;
|
|
7616
|
+
var diff1;
|
|
7617
|
+
var diff2;
|
|
7618
|
+
var h = size / 1.1547;
|
|
7619
|
+
|
|
7620
|
+
switch (type) {
|
|
7621
|
+
case "grid":
|
|
7622
|
+
newX = Math.round(centerX / size) * size;
|
|
7623
|
+
newY = Math.round(centerY / size) * size;
|
|
7624
|
+
break;
|
|
7625
|
+
|
|
7626
|
+
case "hexH":
|
|
7627
|
+
sizeX = 2 * h;
|
|
7628
|
+
sizeY = 3 * size;
|
|
7629
|
+
px1 = Math.round(centerX / sizeX) * sizeX;
|
|
7630
|
+
py1 = Math.round(centerY / sizeY) * sizeY;
|
|
7631
|
+
px2 = px1 > centerX ? px1 - h : px1 + h;
|
|
7632
|
+
py2 = py1 > centerY ? py1 - 1.5 * size : py1 + 1.5 * size;
|
|
7633
|
+
diff1 = Math.hypot.apply(Math, [px1 - centerX, py1 - centerY]);
|
|
7634
|
+
diff2 = Math.hypot.apply(Math, [px2 - centerX, py2 - centerY]);
|
|
7635
|
+
|
|
7636
|
+
if (diff1 < diff2) {
|
|
7637
|
+
newX = px1;
|
|
7638
|
+
newY = py1;
|
|
7639
|
+
} else {
|
|
7640
|
+
newX = px2;
|
|
7641
|
+
newY = py2;
|
|
7642
|
+
}
|
|
7643
|
+
|
|
7644
|
+
break;
|
|
7645
|
+
|
|
7646
|
+
case "hexV":
|
|
7647
|
+
sizeX = 3 * size;
|
|
7648
|
+
sizeY = 2 * h;
|
|
7649
|
+
px1 = Math.round(centerX / sizeX) * sizeX;
|
|
7650
|
+
py1 = Math.round(centerY / sizeY) * sizeY;
|
|
7651
|
+
px2 = px1 > centerX ? px1 - 1.5 * size : px1 + 1.5 * size;
|
|
7652
|
+
py2 = py1 > centerY ? py1 - h : py1 + h;
|
|
7653
|
+
diff1 = Math.hypot.apply(Math, [px1 - centerX, py1 - centerY]);
|
|
7654
|
+
diff2 = Math.hypot.apply(Math, [px2 - centerX, py2 - centerY]);
|
|
7655
|
+
|
|
7656
|
+
if (diff1 < diff2) {
|
|
7657
|
+
newX = px1;
|
|
7658
|
+
newY = py1;
|
|
7659
|
+
} else {
|
|
7660
|
+
newX = px2;
|
|
7661
|
+
newY = py2;
|
|
7662
|
+
}
|
|
7663
|
+
|
|
7664
|
+
break;
|
|
7665
|
+
|
|
7666
|
+
default:
|
|
7667
|
+
newX = item.x + elem.clientWidth / 2;
|
|
7668
|
+
newY = item.y + elem.clientHeight / 2;
|
|
7669
|
+
}
|
|
7585
7670
|
|
|
7586
|
-
|
|
7671
|
+
result[id] = _objectSpread2(_objectSpread2({}, item), {}, {
|
|
7672
|
+
x: newX - elem.clientWidth / 2,
|
|
7673
|
+
y: newY - elem.clientHeight / 2
|
|
7674
|
+
});
|
|
7675
|
+
updatedItems[id] = result[id];
|
|
7676
|
+
});
|
|
7677
|
+
return result;
|
|
7678
|
+
});
|
|
7587
7679
|
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
}
|
|
7680
|
+
if (sync) {
|
|
7681
|
+
wire.publish("batchItemsUpdate", updatedItems);
|
|
7682
|
+
}
|
|
7592
7683
|
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
});
|
|
7684
|
+
case 9:
|
|
7685
|
+
case "end":
|
|
7686
|
+
return _context2.stop();
|
|
7687
|
+
}
|
|
7688
|
+
}
|
|
7689
|
+
}, _callee2);
|
|
7690
|
+
}));
|
|
7601
7691
|
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7692
|
+
return function (_x3) {
|
|
7693
|
+
return _ref5.apply(this, arguments);
|
|
7694
|
+
};
|
|
7695
|
+
}();
|
|
7605
7696
|
}, [wire, setItemMap]);
|
|
7606
7697
|
var placeItems = React.useCallback( /*#__PURE__*/function () {
|
|
7607
|
-
var
|
|
7698
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(itemIds, gridConfig) {
|
|
7608
7699
|
var sync,
|
|
7609
|
-
|
|
7610
|
-
return regeneratorRuntime.wrap(function
|
|
7700
|
+
_args3 = arguments;
|
|
7701
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
7611
7702
|
while (1) {
|
|
7612
|
-
switch (
|
|
7703
|
+
switch (_context3.prev = _context3.next) {
|
|
7613
7704
|
case 0:
|
|
7614
|
-
sync =
|
|
7705
|
+
sync = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : true;
|
|
7615
7706
|
// Put moved items on top
|
|
7616
7707
|
putItemsOnTop(itemIds, sync); // Remove moving state
|
|
7617
7708
|
|
|
@@ -7627,14 +7718,14 @@ var useItemActions = function useItemActions() {
|
|
|
7627
7718
|
|
|
7628
7719
|
case 6:
|
|
7629
7720
|
case "end":
|
|
7630
|
-
return
|
|
7721
|
+
return _context3.stop();
|
|
7631
7722
|
}
|
|
7632
7723
|
}
|
|
7633
|
-
},
|
|
7724
|
+
}, _callee3);
|
|
7634
7725
|
}));
|
|
7635
7726
|
|
|
7636
|
-
return function (
|
|
7637
|
-
return
|
|
7727
|
+
return function (_x4, _x5) {
|
|
7728
|
+
return _ref8.apply(this, arguments);
|
|
7638
7729
|
};
|
|
7639
7730
|
}(), [batchUpdateItems, callPlaceInteractions, putItemsOnTop, stickOnGrid, updateItemExtent]);
|
|
7640
7731
|
var updateItemOrder = React.useCallback(function (newOrder) {
|
|
@@ -7673,27 +7764,27 @@ var useItemActions = function useItemActions() {
|
|
|
7673
7764
|
return reversed;
|
|
7674
7765
|
});
|
|
7675
7766
|
}, [setItemList, wire, setSelectItems]);
|
|
7676
|
-
var swapItems = useRecoilCallback(function (
|
|
7677
|
-
var snapshot =
|
|
7767
|
+
var swapItems = useRecoilCallback(function (_ref9) {
|
|
7768
|
+
var snapshot = _ref9.snapshot;
|
|
7678
7769
|
return /*#__PURE__*/function () {
|
|
7679
|
-
var
|
|
7770
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(fromIds, toIds) {
|
|
7680
7771
|
var sync,
|
|
7681
7772
|
itemMap,
|
|
7682
7773
|
fromItems,
|
|
7683
7774
|
toItems,
|
|
7684
7775
|
replaceMapItems,
|
|
7685
7776
|
replaceMap,
|
|
7686
|
-
|
|
7687
|
-
return regeneratorRuntime.wrap(function
|
|
7777
|
+
_args4 = arguments;
|
|
7778
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
7688
7779
|
while (1) {
|
|
7689
|
-
switch (
|
|
7780
|
+
switch (_context4.prev = _context4.next) {
|
|
7690
7781
|
case 0:
|
|
7691
|
-
sync =
|
|
7692
|
-
|
|
7782
|
+
sync = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : true;
|
|
7783
|
+
_context4.next = 3;
|
|
7693
7784
|
return snapshot.getPromise(ItemMapAtom);
|
|
7694
7785
|
|
|
7695
7786
|
case 3:
|
|
7696
|
-
itemMap =
|
|
7787
|
+
itemMap = _context4.sent;
|
|
7697
7788
|
fromItems = fromIds.map(function (id) {
|
|
7698
7789
|
return itemMap[id];
|
|
7699
7790
|
});
|
|
@@ -7748,38 +7839,38 @@ var useItemActions = function useItemActions() {
|
|
|
7748
7839
|
|
|
7749
7840
|
case 10:
|
|
7750
7841
|
case "end":
|
|
7751
|
-
return
|
|
7842
|
+
return _context4.stop();
|
|
7752
7843
|
}
|
|
7753
7844
|
}
|
|
7754
|
-
},
|
|
7845
|
+
}, _callee4);
|
|
7755
7846
|
}));
|
|
7756
7847
|
|
|
7757
|
-
return function (
|
|
7758
|
-
return
|
|
7848
|
+
return function (_x6, _x7) {
|
|
7849
|
+
return _ref10.apply(this, arguments);
|
|
7759
7850
|
};
|
|
7760
7851
|
}();
|
|
7761
7852
|
}, [wire, setItemList, setItemMap]);
|
|
7762
7853
|
var pushItems = React.useCallback( /*#__PURE__*/function () {
|
|
7763
|
-
var
|
|
7854
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(itemsToInsert, beforeId) {
|
|
7764
7855
|
var sync,
|
|
7765
|
-
|
|
7766
|
-
return regeneratorRuntime.wrap(function
|
|
7856
|
+
_args6 = arguments;
|
|
7857
|
+
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
7767
7858
|
while (1) {
|
|
7768
|
-
switch (
|
|
7859
|
+
switch (_context6.prev = _context6.next) {
|
|
7769
7860
|
case 0:
|
|
7770
|
-
sync =
|
|
7861
|
+
sync = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : true;
|
|
7771
7862
|
itemsToInsert.forEach( /*#__PURE__*/function () {
|
|
7772
|
-
var
|
|
7863
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(item, index) {
|
|
7773
7864
|
var center, newItem;
|
|
7774
|
-
return regeneratorRuntime.wrap(function
|
|
7865
|
+
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
7775
7866
|
while (1) {
|
|
7776
|
-
switch (
|
|
7867
|
+
switch (_context5.prev = _context5.next) {
|
|
7777
7868
|
case 0:
|
|
7778
|
-
|
|
7869
|
+
_context5.next = 2;
|
|
7779
7870
|
return getCenter();
|
|
7780
7871
|
|
|
7781
7872
|
case 2:
|
|
7782
|
-
center =
|
|
7873
|
+
center = _context5.sent;
|
|
7783
7874
|
newItem = _objectSpread2({}, item);
|
|
7784
7875
|
|
|
7785
7876
|
if (!newItem.x || !newItem.y) {
|
|
@@ -7811,28 +7902,28 @@ var useItemActions = function useItemActions() {
|
|
|
7811
7902
|
|
|
7812
7903
|
case 8:
|
|
7813
7904
|
case "end":
|
|
7814
|
-
return
|
|
7905
|
+
return _context5.stop();
|
|
7815
7906
|
}
|
|
7816
7907
|
}
|
|
7817
|
-
},
|
|
7908
|
+
}, _callee5);
|
|
7818
7909
|
}));
|
|
7819
7910
|
|
|
7820
|
-
return function (
|
|
7821
|
-
return
|
|
7911
|
+
return function (_x10, _x11) {
|
|
7912
|
+
return _ref12.apply(this, arguments);
|
|
7822
7913
|
};
|
|
7823
7914
|
}());
|
|
7824
7915
|
updateItemExtent();
|
|
7825
7916
|
|
|
7826
7917
|
case 3:
|
|
7827
7918
|
case "end":
|
|
7828
|
-
return
|
|
7919
|
+
return _context6.stop();
|
|
7829
7920
|
}
|
|
7830
7921
|
}
|
|
7831
|
-
},
|
|
7922
|
+
}, _callee6);
|
|
7832
7923
|
}));
|
|
7833
7924
|
|
|
7834
|
-
return function (
|
|
7835
|
-
return
|
|
7925
|
+
return function (_x8, _x9) {
|
|
7926
|
+
return _ref11.apply(this, arguments);
|
|
7836
7927
|
};
|
|
7837
7928
|
}(), [updateItemExtent, getCenter, setItemMap, setItemList, wire]);
|
|
7838
7929
|
var pushItem = React.useCallback(function (itemToInsert, beforeId) {
|
|
@@ -7865,40 +7956,40 @@ var useItemActions = function useItemActions() {
|
|
|
7865
7956
|
wire.publish("removeItems", itemsIdToRemove);
|
|
7866
7957
|
}
|
|
7867
7958
|
}, [wire, setItemList, setItemMap, setSelectItems]);
|
|
7868
|
-
var getItemList = useRecoilCallback(function (
|
|
7869
|
-
var snapshot =
|
|
7959
|
+
var getItemList = useRecoilCallback(function (_ref13) {
|
|
7960
|
+
var snapshot = _ref13.snapshot;
|
|
7870
7961
|
return function () {
|
|
7871
7962
|
return snapshot.getPromise(AllItemsSelector);
|
|
7872
7963
|
};
|
|
7873
7964
|
}, []);
|
|
7874
|
-
var getItems = useRecoilCallback(function (
|
|
7875
|
-
var snapshot =
|
|
7965
|
+
var getItems = useRecoilCallback(function (_ref14) {
|
|
7966
|
+
var snapshot = _ref14.snapshot;
|
|
7876
7967
|
return /*#__PURE__*/function () {
|
|
7877
|
-
var
|
|
7968
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(itemIds) {
|
|
7878
7969
|
var itemMap;
|
|
7879
|
-
return regeneratorRuntime.wrap(function
|
|
7970
|
+
return regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
7880
7971
|
while (1) {
|
|
7881
|
-
switch (
|
|
7972
|
+
switch (_context7.prev = _context7.next) {
|
|
7882
7973
|
case 0:
|
|
7883
|
-
|
|
7974
|
+
_context7.next = 2;
|
|
7884
7975
|
return snapshot.getPromise(ItemMapAtom);
|
|
7885
7976
|
|
|
7886
7977
|
case 2:
|
|
7887
|
-
itemMap =
|
|
7888
|
-
return
|
|
7978
|
+
itemMap = _context7.sent;
|
|
7979
|
+
return _context7.abrupt("return", itemIds.map(function (id) {
|
|
7889
7980
|
return itemMap[id];
|
|
7890
7981
|
}));
|
|
7891
7982
|
|
|
7892
7983
|
case 4:
|
|
7893
7984
|
case "end":
|
|
7894
|
-
return
|
|
7985
|
+
return _context7.stop();
|
|
7895
7986
|
}
|
|
7896
7987
|
}
|
|
7897
|
-
},
|
|
7988
|
+
}, _callee7);
|
|
7898
7989
|
}));
|
|
7899
7990
|
|
|
7900
|
-
return function (
|
|
7901
|
-
return
|
|
7991
|
+
return function (_x12) {
|
|
7992
|
+
return _ref15.apply(this, arguments);
|
|
7902
7993
|
};
|
|
7903
7994
|
}();
|
|
7904
7995
|
}, []);
|