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/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
|
};
|
|
@@ -6153,6 +6198,21 @@ var usersAtom = recoil.atom({
|
|
|
6153
6198
|
key: "users",
|
|
6154
6199
|
"default": []
|
|
6155
6200
|
});
|
|
6201
|
+
var localUsersAtom = recoil.selector({
|
|
6202
|
+
key: "localUsersAtom",
|
|
6203
|
+
get: function get(_ref) {
|
|
6204
|
+
var _get = _ref.get;
|
|
6205
|
+
|
|
6206
|
+
var currentUser = _get(userAtom);
|
|
6207
|
+
|
|
6208
|
+
var users = _get(usersAtom);
|
|
6209
|
+
|
|
6210
|
+
return users.filter(function (_ref2) {
|
|
6211
|
+
var space = _ref2.space;
|
|
6212
|
+
return space === currentUser.space;
|
|
6213
|
+
});
|
|
6214
|
+
}
|
|
6215
|
+
});
|
|
6156
6216
|
|
|
6157
6217
|
var useUsers = function useUsers() {
|
|
6158
6218
|
var _useRecoilState = recoil.useRecoilState(userAtom),
|
|
@@ -6161,6 +6221,7 @@ var useUsers = function useUsers() {
|
|
|
6161
6221
|
setCurrentUserState = _useRecoilState2[1];
|
|
6162
6222
|
|
|
6163
6223
|
var users = recoil.useRecoilValue(usersAtom);
|
|
6224
|
+
var localUsers = recoil.useRecoilValue(localUsersAtom);
|
|
6164
6225
|
var setCurrentUser = React__default['default'].useCallback(function (callbackOrUser) {
|
|
6165
6226
|
var callback = callbackOrUser;
|
|
6166
6227
|
|
|
@@ -6180,12 +6241,10 @@ var useUsers = function useUsers() {
|
|
|
6180
6241
|
return newUser;
|
|
6181
6242
|
});
|
|
6182
6243
|
}, [setCurrentUserState]);
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
});
|
|
6188
|
-
}, [currentUser.space, users]);
|
|
6244
|
+
React__default['default'].useEffect(function () {
|
|
6245
|
+
// eslint-disable-next-line no-console
|
|
6246
|
+
console.debug("Curent user is in space ".concat(currentUser.space));
|
|
6247
|
+
}, [currentUser.space]);
|
|
6189
6248
|
return {
|
|
6190
6249
|
currentUser: currentUser,
|
|
6191
6250
|
setCurrentUser: setCurrentUser,
|
|
@@ -6908,9 +6967,6 @@ var Board = function Board(_ref) {
|
|
|
6908
6967
|
var _useDim = useDim(),
|
|
6909
6968
|
updateItemExtent = _useDim.updateItemExtent;
|
|
6910
6969
|
|
|
6911
|
-
var _useRecoilValue = recoil.useRecoilValue(ConfigurationAtom),
|
|
6912
|
-
itemExtent = _useRecoilValue.itemExtent;
|
|
6913
|
-
|
|
6914
6970
|
var boardStyle = React__default['default'].useMemo(function () {
|
|
6915
6971
|
return _objectSpread2({
|
|
6916
6972
|
userSelect: "none",
|
|
@@ -6943,12 +6999,7 @@ var Board = function Board(_ref) {
|
|
|
6943
6999
|
className: "board"
|
|
6944
7000
|
}, /*#__PURE__*/React__default['default'].createElement(ItemList, {
|
|
6945
7001
|
itemTemplates: itemTemplates
|
|
6946
|
-
})), /*#__PURE__*/React__default['default'].createElement(
|
|
6947
|
-
style: _objectSpread2(_objectSpread2({}, itemExtent), {}, {
|
|
6948
|
-
border: "3px solid red",
|
|
6949
|
-
position: "absolute"
|
|
6950
|
-
})
|
|
6951
|
-
}))))), /*#__PURE__*/React__default['default'].createElement(Selection, null));
|
|
7002
|
+
})))))), /*#__PURE__*/React__default['default'].createElement(Selection, null));
|
|
6952
7003
|
};
|
|
6953
7004
|
|
|
6954
7005
|
var TOLERANCE = 100;
|
|
@@ -7470,6 +7521,11 @@ var useItemActions = function useItemActions() {
|
|
|
7470
7521
|
|
|
7471
7522
|
itemIds.forEach(function (id) {
|
|
7472
7523
|
var item = prevItemMap[id];
|
|
7524
|
+
|
|
7525
|
+
if (!item) {
|
|
7526
|
+
return;
|
|
7527
|
+
}
|
|
7528
|
+
|
|
7473
7529
|
result[id] = _objectSpread2(_objectSpread2({}, item), {}, {
|
|
7474
7530
|
x: (item.x || 0) + posDelta.x,
|
|
7475
7531
|
y: (item.y || 0) + posDelta.y,
|
|
@@ -7506,120 +7562,155 @@ var useItemActions = function useItemActions() {
|
|
|
7506
7562
|
return result;
|
|
7507
7563
|
});
|
|
7508
7564
|
}, [setItemList, wire]);
|
|
7509
|
-
var stickOnGrid =
|
|
7510
|
-
var
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7565
|
+
var stickOnGrid = recoil.useRecoilCallback(function (_ref4) {
|
|
7566
|
+
var snapshot = _ref4.snapshot;
|
|
7567
|
+
return /*#__PURE__*/function () {
|
|
7568
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(itemIds) {
|
|
7569
|
+
var _ref6,
|
|
7570
|
+
globalType,
|
|
7571
|
+
globalSize,
|
|
7572
|
+
sync,
|
|
7573
|
+
_yield$snapshot$getPr,
|
|
7574
|
+
boardWrapper,
|
|
7575
|
+
updatedItems,
|
|
7576
|
+
_args2 = arguments;
|
|
7518
7577
|
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7578
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
7579
|
+
while (1) {
|
|
7580
|
+
switch (_context2.prev = _context2.next) {
|
|
7581
|
+
case 0:
|
|
7582
|
+
_ref6 = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {}, globalType = _ref6.type, globalSize = _ref6.size;
|
|
7583
|
+
sync = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : true;
|
|
7584
|
+
_context2.next = 4;
|
|
7585
|
+
return snapshot.getPromise(ConfigurationAtom);
|
|
7523
7586
|
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7587
|
+
case 4:
|
|
7588
|
+
_yield$snapshot$getPr = _context2.sent;
|
|
7589
|
+
boardWrapper = _yield$snapshot$getPr.boardWrapper;
|
|
7590
|
+
updatedItems = {};
|
|
7591
|
+
setItemMap(function (prevItemMap) {
|
|
7592
|
+
var result = _objectSpread2({}, prevItemMap);
|
|
7527
7593
|
|
|
7528
|
-
|
|
7529
|
-
|
|
7594
|
+
itemIds.forEach(function (id) {
|
|
7595
|
+
var item = prevItemMap[id];
|
|
7596
|
+
var elem = getItemElem(boardWrapper, id);
|
|
7530
7597
|
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
}
|
|
7598
|
+
if (!elem) {
|
|
7599
|
+
return;
|
|
7600
|
+
}
|
|
7535
7601
|
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
var newY;
|
|
7540
|
-
var sizeX;
|
|
7541
|
-
var sizeY;
|
|
7542
|
-
var px1;
|
|
7543
|
-
var px2;
|
|
7544
|
-
var py1;
|
|
7545
|
-
var py2;
|
|
7546
|
-
var diff1;
|
|
7547
|
-
var diff2;
|
|
7548
|
-
var h = size / 1.1547;
|
|
7549
|
-
|
|
7550
|
-
switch (type) {
|
|
7551
|
-
case "grid":
|
|
7552
|
-
newX = Math.round(centerX / size) * size;
|
|
7553
|
-
newY = Math.round(centerY / size) * size;
|
|
7554
|
-
break;
|
|
7602
|
+
var _ref7 = item.grid || {},
|
|
7603
|
+
itemType = _ref7.type,
|
|
7604
|
+
itemSize = _ref7.size;
|
|
7555
7605
|
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
sizeY = 3 * size;
|
|
7559
|
-
px1 = Math.round(centerX / sizeX) * sizeX;
|
|
7560
|
-
py1 = Math.round(centerY / sizeY) * sizeY;
|
|
7561
|
-
px2 = px1 > centerX ? px1 - h : px1 + h;
|
|
7562
|
-
py2 = py1 > centerY ? py1 - 1.5 * size : py1 + 1.5 * size;
|
|
7563
|
-
diff1 = Math.hypot.apply(Math, [px1 - centerX, py1 - centerY]);
|
|
7564
|
-
diff2 = Math.hypot.apply(Math, [px2 - centerX, py2 - centerY]);
|
|
7565
|
-
|
|
7566
|
-
if (diff1 < diff2) {
|
|
7567
|
-
newX = px1;
|
|
7568
|
-
newY = py1;
|
|
7569
|
-
} else {
|
|
7570
|
-
newX = px2;
|
|
7571
|
-
newY = py2;
|
|
7572
|
-
}
|
|
7606
|
+
var type = globalType;
|
|
7607
|
+
var size = globalSize || 1; // If item specific
|
|
7573
7608
|
|
|
7574
|
-
|
|
7609
|
+
if (itemType) {
|
|
7610
|
+
type = itemType;
|
|
7611
|
+
size = itemSize || 1;
|
|
7612
|
+
}
|
|
7575
7613
|
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
7614
|
+
var centerX = item.x + elem.clientWidth / 2,
|
|
7615
|
+
centerY = item.y + elem.clientHeight / 2;
|
|
7616
|
+
var newX;
|
|
7617
|
+
var newY;
|
|
7618
|
+
var sizeX;
|
|
7619
|
+
var sizeY;
|
|
7620
|
+
var px1;
|
|
7621
|
+
var px2;
|
|
7622
|
+
var py1;
|
|
7623
|
+
var py2;
|
|
7624
|
+
var diff1;
|
|
7625
|
+
var diff2;
|
|
7626
|
+
var h = size / 1.1547;
|
|
7627
|
+
|
|
7628
|
+
switch (type) {
|
|
7629
|
+
case "grid":
|
|
7630
|
+
newX = Math.round(centerX / size) * size;
|
|
7631
|
+
newY = Math.round(centerY / size) * size;
|
|
7632
|
+
break;
|
|
7633
|
+
|
|
7634
|
+
case "hexH":
|
|
7635
|
+
sizeX = 2 * h;
|
|
7636
|
+
sizeY = 3 * size;
|
|
7637
|
+
px1 = Math.round(centerX / sizeX) * sizeX;
|
|
7638
|
+
py1 = Math.round(centerY / sizeY) * sizeY;
|
|
7639
|
+
px2 = px1 > centerX ? px1 - h : px1 + h;
|
|
7640
|
+
py2 = py1 > centerY ? py1 - 1.5 * size : py1 + 1.5 * size;
|
|
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
|
+
case "hexV":
|
|
7655
|
+
sizeX = 3 * size;
|
|
7656
|
+
sizeY = 2 * h;
|
|
7657
|
+
px1 = Math.round(centerX / sizeX) * sizeX;
|
|
7658
|
+
py1 = Math.round(centerY / sizeY) * sizeY;
|
|
7659
|
+
px2 = px1 > centerX ? px1 - 1.5 * size : px1 + 1.5 * size;
|
|
7660
|
+
py2 = py1 > centerY ? py1 - h : py1 + h;
|
|
7661
|
+
diff1 = Math.hypot.apply(Math, [px1 - centerX, py1 - centerY]);
|
|
7662
|
+
diff2 = Math.hypot.apply(Math, [px2 - centerX, py2 - centerY]);
|
|
7663
|
+
|
|
7664
|
+
if (diff1 < diff2) {
|
|
7665
|
+
newX = px1;
|
|
7666
|
+
newY = py1;
|
|
7667
|
+
} else {
|
|
7668
|
+
newX = px2;
|
|
7669
|
+
newY = py2;
|
|
7670
|
+
}
|
|
7671
|
+
|
|
7672
|
+
break;
|
|
7673
|
+
|
|
7674
|
+
default:
|
|
7675
|
+
newX = item.x + elem.clientWidth / 2;
|
|
7676
|
+
newY = item.y + elem.clientHeight / 2;
|
|
7677
|
+
}
|
|
7593
7678
|
|
|
7594
|
-
|
|
7679
|
+
result[id] = _objectSpread2(_objectSpread2({}, item), {}, {
|
|
7680
|
+
x: newX - elem.clientWidth / 2,
|
|
7681
|
+
y: newY - elem.clientHeight / 2
|
|
7682
|
+
});
|
|
7683
|
+
updatedItems[id] = result[id];
|
|
7684
|
+
});
|
|
7685
|
+
return result;
|
|
7686
|
+
});
|
|
7595
7687
|
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
}
|
|
7688
|
+
if (sync) {
|
|
7689
|
+
wire.publish("batchItemsUpdate", updatedItems);
|
|
7690
|
+
}
|
|
7600
7691
|
|
|
7601
|
-
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
});
|
|
7692
|
+
case 9:
|
|
7693
|
+
case "end":
|
|
7694
|
+
return _context2.stop();
|
|
7695
|
+
}
|
|
7696
|
+
}
|
|
7697
|
+
}, _callee2);
|
|
7698
|
+
}));
|
|
7609
7699
|
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7700
|
+
return function (_x3) {
|
|
7701
|
+
return _ref5.apply(this, arguments);
|
|
7702
|
+
};
|
|
7703
|
+
}();
|
|
7613
7704
|
}, [wire, setItemMap]);
|
|
7614
7705
|
var placeItems = React__default['default'].useCallback( /*#__PURE__*/function () {
|
|
7615
|
-
var
|
|
7706
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(itemIds, gridConfig) {
|
|
7616
7707
|
var sync,
|
|
7617
|
-
|
|
7618
|
-
return regeneratorRuntime.wrap(function
|
|
7708
|
+
_args3 = arguments;
|
|
7709
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
7619
7710
|
while (1) {
|
|
7620
|
-
switch (
|
|
7711
|
+
switch (_context3.prev = _context3.next) {
|
|
7621
7712
|
case 0:
|
|
7622
|
-
sync =
|
|
7713
|
+
sync = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : true;
|
|
7623
7714
|
// Put moved items on top
|
|
7624
7715
|
putItemsOnTop(itemIds, sync); // Remove moving state
|
|
7625
7716
|
|
|
@@ -7635,14 +7726,14 @@ var useItemActions = function useItemActions() {
|
|
|
7635
7726
|
|
|
7636
7727
|
case 6:
|
|
7637
7728
|
case "end":
|
|
7638
|
-
return
|
|
7729
|
+
return _context3.stop();
|
|
7639
7730
|
}
|
|
7640
7731
|
}
|
|
7641
|
-
},
|
|
7732
|
+
}, _callee3);
|
|
7642
7733
|
}));
|
|
7643
7734
|
|
|
7644
|
-
return function (
|
|
7645
|
-
return
|
|
7735
|
+
return function (_x4, _x5) {
|
|
7736
|
+
return _ref8.apply(this, arguments);
|
|
7646
7737
|
};
|
|
7647
7738
|
}(), [batchUpdateItems, callPlaceInteractions, putItemsOnTop, stickOnGrid, updateItemExtent]);
|
|
7648
7739
|
var updateItemOrder = React__default['default'].useCallback(function (newOrder) {
|
|
@@ -7681,27 +7772,27 @@ var useItemActions = function useItemActions() {
|
|
|
7681
7772
|
return reversed;
|
|
7682
7773
|
});
|
|
7683
7774
|
}, [setItemList, wire, setSelectItems]);
|
|
7684
|
-
var swapItems = recoil.useRecoilCallback(function (
|
|
7685
|
-
var snapshot =
|
|
7775
|
+
var swapItems = recoil.useRecoilCallback(function (_ref9) {
|
|
7776
|
+
var snapshot = _ref9.snapshot;
|
|
7686
7777
|
return /*#__PURE__*/function () {
|
|
7687
|
-
var
|
|
7778
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(fromIds, toIds) {
|
|
7688
7779
|
var sync,
|
|
7689
7780
|
itemMap,
|
|
7690
7781
|
fromItems,
|
|
7691
7782
|
toItems,
|
|
7692
7783
|
replaceMapItems,
|
|
7693
7784
|
replaceMap,
|
|
7694
|
-
|
|
7695
|
-
return regeneratorRuntime.wrap(function
|
|
7785
|
+
_args4 = arguments;
|
|
7786
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
7696
7787
|
while (1) {
|
|
7697
|
-
switch (
|
|
7788
|
+
switch (_context4.prev = _context4.next) {
|
|
7698
7789
|
case 0:
|
|
7699
|
-
sync =
|
|
7700
|
-
|
|
7790
|
+
sync = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : true;
|
|
7791
|
+
_context4.next = 3;
|
|
7701
7792
|
return snapshot.getPromise(ItemMapAtom);
|
|
7702
7793
|
|
|
7703
7794
|
case 3:
|
|
7704
|
-
itemMap =
|
|
7795
|
+
itemMap = _context4.sent;
|
|
7705
7796
|
fromItems = fromIds.map(function (id) {
|
|
7706
7797
|
return itemMap[id];
|
|
7707
7798
|
});
|
|
@@ -7756,38 +7847,38 @@ var useItemActions = function useItemActions() {
|
|
|
7756
7847
|
|
|
7757
7848
|
case 10:
|
|
7758
7849
|
case "end":
|
|
7759
|
-
return
|
|
7850
|
+
return _context4.stop();
|
|
7760
7851
|
}
|
|
7761
7852
|
}
|
|
7762
|
-
},
|
|
7853
|
+
}, _callee4);
|
|
7763
7854
|
}));
|
|
7764
7855
|
|
|
7765
|
-
return function (
|
|
7766
|
-
return
|
|
7856
|
+
return function (_x6, _x7) {
|
|
7857
|
+
return _ref10.apply(this, arguments);
|
|
7767
7858
|
};
|
|
7768
7859
|
}();
|
|
7769
7860
|
}, [wire, setItemList, setItemMap]);
|
|
7770
7861
|
var pushItems = React__default['default'].useCallback( /*#__PURE__*/function () {
|
|
7771
|
-
var
|
|
7862
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(itemsToInsert, beforeId) {
|
|
7772
7863
|
var sync,
|
|
7773
|
-
|
|
7774
|
-
return regeneratorRuntime.wrap(function
|
|
7864
|
+
_args6 = arguments;
|
|
7865
|
+
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
7775
7866
|
while (1) {
|
|
7776
|
-
switch (
|
|
7867
|
+
switch (_context6.prev = _context6.next) {
|
|
7777
7868
|
case 0:
|
|
7778
|
-
sync =
|
|
7869
|
+
sync = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : true;
|
|
7779
7870
|
itemsToInsert.forEach( /*#__PURE__*/function () {
|
|
7780
|
-
var
|
|
7871
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(item, index) {
|
|
7781
7872
|
var center, newItem;
|
|
7782
|
-
return regeneratorRuntime.wrap(function
|
|
7873
|
+
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
7783
7874
|
while (1) {
|
|
7784
|
-
switch (
|
|
7875
|
+
switch (_context5.prev = _context5.next) {
|
|
7785
7876
|
case 0:
|
|
7786
|
-
|
|
7877
|
+
_context5.next = 2;
|
|
7787
7878
|
return getCenter();
|
|
7788
7879
|
|
|
7789
7880
|
case 2:
|
|
7790
|
-
center =
|
|
7881
|
+
center = _context5.sent;
|
|
7791
7882
|
newItem = _objectSpread2({}, item);
|
|
7792
7883
|
|
|
7793
7884
|
if (!newItem.x || !newItem.y) {
|
|
@@ -7819,28 +7910,28 @@ var useItemActions = function useItemActions() {
|
|
|
7819
7910
|
|
|
7820
7911
|
case 8:
|
|
7821
7912
|
case "end":
|
|
7822
|
-
return
|
|
7913
|
+
return _context5.stop();
|
|
7823
7914
|
}
|
|
7824
7915
|
}
|
|
7825
|
-
},
|
|
7916
|
+
}, _callee5);
|
|
7826
7917
|
}));
|
|
7827
7918
|
|
|
7828
|
-
return function (
|
|
7829
|
-
return
|
|
7919
|
+
return function (_x10, _x11) {
|
|
7920
|
+
return _ref12.apply(this, arguments);
|
|
7830
7921
|
};
|
|
7831
7922
|
}());
|
|
7832
7923
|
updateItemExtent();
|
|
7833
7924
|
|
|
7834
7925
|
case 3:
|
|
7835
7926
|
case "end":
|
|
7836
|
-
return
|
|
7927
|
+
return _context6.stop();
|
|
7837
7928
|
}
|
|
7838
7929
|
}
|
|
7839
|
-
},
|
|
7930
|
+
}, _callee6);
|
|
7840
7931
|
}));
|
|
7841
7932
|
|
|
7842
|
-
return function (
|
|
7843
|
-
return
|
|
7933
|
+
return function (_x8, _x9) {
|
|
7934
|
+
return _ref11.apply(this, arguments);
|
|
7844
7935
|
};
|
|
7845
7936
|
}(), [updateItemExtent, getCenter, setItemMap, setItemList, wire]);
|
|
7846
7937
|
var pushItem = React__default['default'].useCallback(function (itemToInsert, beforeId) {
|
|
@@ -7873,40 +7964,40 @@ var useItemActions = function useItemActions() {
|
|
|
7873
7964
|
wire.publish("removeItems", itemsIdToRemove);
|
|
7874
7965
|
}
|
|
7875
7966
|
}, [wire, setItemList, setItemMap, setSelectItems]);
|
|
7876
|
-
var getItemList = recoil.useRecoilCallback(function (
|
|
7877
|
-
var snapshot =
|
|
7967
|
+
var getItemList = recoil.useRecoilCallback(function (_ref13) {
|
|
7968
|
+
var snapshot = _ref13.snapshot;
|
|
7878
7969
|
return function () {
|
|
7879
7970
|
return snapshot.getPromise(AllItemsSelector);
|
|
7880
7971
|
};
|
|
7881
7972
|
}, []);
|
|
7882
|
-
var getItems = recoil.useRecoilCallback(function (
|
|
7883
|
-
var snapshot =
|
|
7973
|
+
var getItems = recoil.useRecoilCallback(function (_ref14) {
|
|
7974
|
+
var snapshot = _ref14.snapshot;
|
|
7884
7975
|
return /*#__PURE__*/function () {
|
|
7885
|
-
var
|
|
7976
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(itemIds) {
|
|
7886
7977
|
var itemMap;
|
|
7887
|
-
return regeneratorRuntime.wrap(function
|
|
7978
|
+
return regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
7888
7979
|
while (1) {
|
|
7889
|
-
switch (
|
|
7980
|
+
switch (_context7.prev = _context7.next) {
|
|
7890
7981
|
case 0:
|
|
7891
|
-
|
|
7982
|
+
_context7.next = 2;
|
|
7892
7983
|
return snapshot.getPromise(ItemMapAtom);
|
|
7893
7984
|
|
|
7894
7985
|
case 2:
|
|
7895
|
-
itemMap =
|
|
7896
|
-
return
|
|
7986
|
+
itemMap = _context7.sent;
|
|
7987
|
+
return _context7.abrupt("return", itemIds.map(function (id) {
|
|
7897
7988
|
return itemMap[id];
|
|
7898
7989
|
}));
|
|
7899
7990
|
|
|
7900
7991
|
case 4:
|
|
7901
7992
|
case "end":
|
|
7902
|
-
return
|
|
7993
|
+
return _context7.stop();
|
|
7903
7994
|
}
|
|
7904
7995
|
}
|
|
7905
|
-
},
|
|
7996
|
+
}, _callee7);
|
|
7906
7997
|
}));
|
|
7907
7998
|
|
|
7908
|
-
return function (
|
|
7909
|
-
return
|
|
7999
|
+
return function (_x12) {
|
|
8000
|
+
return _ref15.apply(this, arguments);
|
|
7910
8001
|
};
|
|
7911
8002
|
}();
|
|
7912
8003
|
}, []);
|