react-sync-board 0.5.5 → 0.6.1
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 +1689 -1279
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1792 -1403
- 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 +19 -19
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { forwardRef, useContext, createContext, createElement, Fragment, useRef, useLayoutEffect, useEffect, useMemo, memo, useCallback } from 'react';
|
|
3
|
+
import { atom, selector, useRecoilValue, useRecoilCallback, useRecoilState, useSetRecoilState, RecoilRoot } from 'recoil';
|
|
3
4
|
|
|
4
5
|
function ownKeys(object, enumerableOnly) {
|
|
5
6
|
var keys = Object.keys(object);
|
|
@@ -460,26 +461,17 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
|
460
461
|
};
|
|
461
462
|
}
|
|
462
463
|
|
|
463
|
-
// This file replaces `index.js` in bundlers like webpack or Rollup,
|
|
464
|
-
|
|
465
464
|
var nanoid = function nanoid() {
|
|
466
465
|
var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 21;
|
|
467
466
|
var id = '';
|
|
468
|
-
var bytes = crypto.getRandomValues(new Uint8Array(size));
|
|
467
|
+
var bytes = crypto.getRandomValues(new Uint8Array(size));
|
|
469
468
|
|
|
470
469
|
while (size--) {
|
|
471
|
-
// It is incorrect to use bytes exceeding the alphabet size.
|
|
472
|
-
// The following mask reduces the random byte in the 0-255 value
|
|
473
|
-
// range to the 0-63 value range. Therefore, adding hacks, such
|
|
474
|
-
// as empty string fallback or magic numbers, is unneccessary because
|
|
475
|
-
// the bitmask trims bytes down to the alphabet size.
|
|
476
470
|
var _byte = bytes[size] & 63;
|
|
477
471
|
|
|
478
472
|
if (_byte < 36) {
|
|
479
|
-
// `0-9a-z`
|
|
480
473
|
id += _byte.toString(36);
|
|
481
474
|
} else if (_byte < 62) {
|
|
482
|
-
// `A-Z`
|
|
483
475
|
id += (_byte - 26).toString(36).toUpperCase();
|
|
484
476
|
} else if (_byte < 63) {
|
|
485
477
|
id += '_';
|
|
@@ -771,7 +763,7 @@ function memoize(fn) {
|
|
|
771
763
|
};
|
|
772
764
|
}
|
|
773
765
|
|
|
774
|
-
var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/; // https://esbench.com/bench/5bfee68a4cd7e6009ef61d23
|
|
766
|
+
var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/; // https://esbench.com/bench/5bfee68a4cd7e6009ef61d23
|
|
775
767
|
|
|
776
768
|
var isPropValid = /* #__PURE__ */memoize(function (prop) {
|
|
777
769
|
return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111
|
|
@@ -844,7 +836,13 @@ var StyleSheet = /*#__PURE__*/function () {
|
|
|
844
836
|
var before;
|
|
845
837
|
|
|
846
838
|
if (_this.tags.length === 0) {
|
|
847
|
-
|
|
839
|
+
if (_this.insertionPoint) {
|
|
840
|
+
before = _this.insertionPoint.nextSibling;
|
|
841
|
+
} else if (_this.prepend) {
|
|
842
|
+
before = _this.container.firstChild;
|
|
843
|
+
} else {
|
|
844
|
+
before = _this.before;
|
|
845
|
+
}
|
|
848
846
|
} else {
|
|
849
847
|
before = _this.tags[_this.tags.length - 1].nextSibling;
|
|
850
848
|
}
|
|
@@ -862,6 +860,7 @@ var StyleSheet = /*#__PURE__*/function () {
|
|
|
862
860
|
this.key = options.key;
|
|
863
861
|
this.container = options.container;
|
|
864
862
|
this.prepend = options.prepend;
|
|
863
|
+
this.insertionPoint = options.insertionPoint;
|
|
865
864
|
this.before = null;
|
|
866
865
|
}
|
|
867
866
|
|
|
@@ -902,7 +901,7 @@ var StyleSheet = /*#__PURE__*/function () {
|
|
|
902
901
|
// the big drawback is that the css won't be editable in devtools
|
|
903
902
|
sheet.insertRule(rule, sheet.cssRules.length);
|
|
904
903
|
} catch (e) {
|
|
905
|
-
if (process.env.NODE_ENV !== 'production' && !/:(-moz-placeholder|-ms-input-placeholder|-moz-read-write|-moz-read-only){/.test(rule)) {
|
|
904
|
+
if (process.env.NODE_ENV !== 'production' && !/:(-moz-placeholder|-moz-focus-inner|-moz-focusring|-ms-input-placeholder|-moz-read-write|-moz-read-only|-ms-clear){/.test(rule)) {
|
|
906
905
|
console.error("There was a problem inserting the following rule: \"" + rule + "\"", e);
|
|
907
906
|
}
|
|
908
907
|
}
|
|
@@ -916,7 +915,7 @@ var StyleSheet = /*#__PURE__*/function () {
|
|
|
916
915
|
_proto.flush = function flush() {
|
|
917
916
|
// $FlowFixMe
|
|
918
917
|
this.tags.forEach(function (tag) {
|
|
919
|
-
return tag.parentNode.removeChild(tag);
|
|
918
|
+
return tag.parentNode && tag.parentNode.removeChild(tag);
|
|
920
919
|
});
|
|
921
920
|
this.tags = [];
|
|
922
921
|
this.ctr = 0;
|
|
@@ -949,13 +948,19 @@ var abs = Math.abs;
|
|
|
949
948
|
*/
|
|
950
949
|
|
|
951
950
|
var from = String.fromCharCode;
|
|
951
|
+
/**
|
|
952
|
+
* @param {object}
|
|
953
|
+
* @return {object}
|
|
954
|
+
*/
|
|
955
|
+
|
|
956
|
+
var assign = Object.assign;
|
|
952
957
|
/**
|
|
953
958
|
* @param {string} value
|
|
954
959
|
* @param {number} length
|
|
955
960
|
* @return {number}
|
|
956
961
|
*/
|
|
957
962
|
|
|
958
|
-
function hash(value, length) {
|
|
963
|
+
function hash$1(value, length) {
|
|
959
964
|
return (((length << 2 ^ charat(value, 0)) << 2 ^ charat(value, 1)) << 2 ^ charat(value, 2)) << 2 ^ charat(value, 3);
|
|
960
965
|
}
|
|
961
966
|
/**
|
|
@@ -987,7 +992,7 @@ function replace(value, pattern, replacement) {
|
|
|
987
992
|
}
|
|
988
993
|
/**
|
|
989
994
|
* @param {string} value
|
|
990
|
-
* @param {string}
|
|
995
|
+
* @param {string} search
|
|
991
996
|
* @return {number}
|
|
992
997
|
*/
|
|
993
998
|
|
|
@@ -1056,11 +1061,11 @@ var character = 0;
|
|
|
1056
1061
|
var characters = '';
|
|
1057
1062
|
/**
|
|
1058
1063
|
* @param {string} value
|
|
1059
|
-
* @param {object} root
|
|
1060
|
-
* @param {object
|
|
1064
|
+
* @param {object | null} root
|
|
1065
|
+
* @param {object | null} parent
|
|
1061
1066
|
* @param {string} type
|
|
1062
|
-
* @param {string[]} props
|
|
1063
|
-
* @param {object[]} children
|
|
1067
|
+
* @param {string[] | string} props
|
|
1068
|
+
* @param {object[] | string} children
|
|
1064
1069
|
* @param {number} length
|
|
1065
1070
|
*/
|
|
1066
1071
|
|
|
@@ -1079,13 +1084,15 @@ function node(value, root, parent, type, props, children, length) {
|
|
|
1079
1084
|
};
|
|
1080
1085
|
}
|
|
1081
1086
|
/**
|
|
1082
|
-
* @param {string} value
|
|
1083
1087
|
* @param {object} root
|
|
1084
|
-
* @param {
|
|
1088
|
+
* @param {object} props
|
|
1089
|
+
* @return {object}
|
|
1085
1090
|
*/
|
|
1086
1091
|
|
|
1087
|
-
function copy(
|
|
1088
|
-
return node(
|
|
1092
|
+
function copy(root, props) {
|
|
1093
|
+
return assign(node('', null, null, '', null, null, 0), root, {
|
|
1094
|
+
length: -root.length
|
|
1095
|
+
}, props);
|
|
1089
1096
|
}
|
|
1090
1097
|
/**
|
|
1091
1098
|
* @return {number}
|
|
@@ -1244,7 +1251,8 @@ function delimiter(type) {
|
|
|
1244
1251
|
|
|
1245
1252
|
case 34:
|
|
1246
1253
|
case 39:
|
|
1247
|
-
|
|
1254
|
+
if (type !== 34 && type !== 39) delimiter(character);
|
|
1255
|
+
break;
|
|
1248
1256
|
// (
|
|
1249
1257
|
|
|
1250
1258
|
case 40:
|
|
@@ -1328,11 +1336,18 @@ function parse(value, root, parent, rule, rules, rulesets, pseudo, points, decla
|
|
|
1328
1336
|
|
|
1329
1337
|
while (scanning) {
|
|
1330
1338
|
switch (previous = character, character = next()) {
|
|
1331
|
-
//
|
|
1339
|
+
// (
|
|
1340
|
+
case 40:
|
|
1341
|
+
if (previous != 108 && characters.charCodeAt(length - 1) == 58) {
|
|
1342
|
+
if (indexof(characters += replace(delimit(character), '&', '&\f'), '&\f') != -1) ampersand = -1;
|
|
1343
|
+
break;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
// " ' [
|
|
1347
|
+
|
|
1332
1348
|
case 34:
|
|
1333
1349
|
case 39:
|
|
1334
1350
|
case 91:
|
|
1335
|
-
case 40:
|
|
1336
1351
|
characters += delimit(character);
|
|
1337
1352
|
break;
|
|
1338
1353
|
// \t \n \r \s
|
|
@@ -1398,7 +1413,7 @@ function parse(value, root, parent, rule, rules, rulesets, pseudo, points, decla
|
|
|
1398
1413
|
break;
|
|
1399
1414
|
|
|
1400
1415
|
default:
|
|
1401
|
-
parse(characters, reference, reference, reference, [''], children,
|
|
1416
|
+
parse(characters, reference, reference, reference, [''], children, 0, points, children);
|
|
1402
1417
|
}
|
|
1403
1418
|
}
|
|
1404
1419
|
|
|
@@ -1427,7 +1442,7 @@ function parse(value, root, parent, rule, rules, rulesets, pseudo, points, decla
|
|
|
1427
1442
|
case 64:
|
|
1428
1443
|
// -
|
|
1429
1444
|
if (peek() === 45) characters += delimit(next());
|
|
1430
|
-
atrule = peek(), offset = strlen(type = characters += identifier(caret())), character++;
|
|
1445
|
+
atrule = peek(), offset = length = strlen(type = characters += identifier(caret())), character++;
|
|
1431
1446
|
break;
|
|
1432
1447
|
// -
|
|
1433
1448
|
|
|
@@ -1497,7 +1512,7 @@ function declaration(value, root, parent, length) {
|
|
|
1497
1512
|
*/
|
|
1498
1513
|
|
|
1499
1514
|
function prefix(value, length) {
|
|
1500
|
-
switch (hash(value, length)) {
|
|
1515
|
+
switch (hash$1(value, length)) {
|
|
1501
1516
|
// color-adjust
|
|
1502
1517
|
case 5103:
|
|
1503
1518
|
return WEBKIT + 'print-' + value + value;
|
|
@@ -1702,6 +1717,9 @@ function stringify(element, index, children, callback) {
|
|
|
1702
1717
|
case COMMENT:
|
|
1703
1718
|
return '';
|
|
1704
1719
|
|
|
1720
|
+
case KEYFRAMES:
|
|
1721
|
+
return element["return"] = element.value + '{' + serialize(element.children, callback) + '}';
|
|
1722
|
+
|
|
1705
1723
|
case RULESET:
|
|
1706
1724
|
element.value = element.props.join(',');
|
|
1707
1725
|
}
|
|
@@ -1744,13 +1762,15 @@ function rulesheet(callback) {
|
|
|
1744
1762
|
*/
|
|
1745
1763
|
|
|
1746
1764
|
function prefixer(element, index, children, callback) {
|
|
1747
|
-
if (!element["return"]) switch (element.type) {
|
|
1765
|
+
if (element.length > -1) if (!element["return"]) switch (element.type) {
|
|
1748
1766
|
case DECLARATION:
|
|
1749
1767
|
element["return"] = prefix(element.value, element.length);
|
|
1750
1768
|
break;
|
|
1751
1769
|
|
|
1752
1770
|
case KEYFRAMES:
|
|
1753
|
-
return serialize([copy(
|
|
1771
|
+
return serialize([copy(element, {
|
|
1772
|
+
value: replace(element.value, '@', '@' + WEBKIT)
|
|
1773
|
+
})], callback);
|
|
1754
1774
|
|
|
1755
1775
|
case RULESET:
|
|
1756
1776
|
if (element.length) return combine(element.props, function (value) {
|
|
@@ -1758,11 +1778,19 @@ function prefixer(element, index, children, callback) {
|
|
|
1758
1778
|
// :read-(only|write)
|
|
1759
1779
|
case ':read-only':
|
|
1760
1780
|
case ':read-write':
|
|
1761
|
-
return serialize([copy(
|
|
1781
|
+
return serialize([copy(element, {
|
|
1782
|
+
props: [replace(value, /:(read-\w+)/, ':' + MOZ + '$1')]
|
|
1783
|
+
})], callback);
|
|
1762
1784
|
// :placeholder
|
|
1763
1785
|
|
|
1764
1786
|
case '::placeholder':
|
|
1765
|
-
return serialize([copy(
|
|
1787
|
+
return serialize([copy(element, {
|
|
1788
|
+
props: [replace(value, /:(plac\w+)/, ':' + WEBKIT + 'input-$1')]
|
|
1789
|
+
}), copy(element, {
|
|
1790
|
+
props: [replace(value, /:(plac\w+)/, ':' + MOZ + '$1')]
|
|
1791
|
+
}), copy(element, {
|
|
1792
|
+
props: [replace(value, /:(plac\w+)/, MS + 'input-$1')]
|
|
1793
|
+
})], callback);
|
|
1766
1794
|
}
|
|
1767
1795
|
|
|
1768
1796
|
return '';
|
|
@@ -1772,6 +1800,29 @@ function prefixer(element, index, children, callback) {
|
|
|
1772
1800
|
|
|
1773
1801
|
var last = function last(arr) {
|
|
1774
1802
|
return arr.length ? arr[arr.length - 1] : null;
|
|
1803
|
+
}; // based on https://github.com/thysultan/stylis.js/blob/e6843c373ebcbbfade25ebcc23f540ed8508da0a/src/Tokenizer.js#L239-L244
|
|
1804
|
+
|
|
1805
|
+
|
|
1806
|
+
var identifierWithPointTracking = function identifierWithPointTracking(begin, points, index) {
|
|
1807
|
+
var previous = 0;
|
|
1808
|
+
var character = 0;
|
|
1809
|
+
|
|
1810
|
+
while (true) {
|
|
1811
|
+
previous = character;
|
|
1812
|
+
character = peek(); // &\f
|
|
1813
|
+
|
|
1814
|
+
if (previous === 38 && character === 12) {
|
|
1815
|
+
points[index] = 1;
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
if (token(character)) {
|
|
1819
|
+
break;
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
next();
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
return slice(begin, position);
|
|
1775
1826
|
};
|
|
1776
1827
|
|
|
1777
1828
|
var toRules = function toRules(parsed, points) {
|
|
@@ -1791,7 +1842,7 @@ var toRules = function toRules(parsed, points) {
|
|
|
1791
1842
|
points[index] = 1;
|
|
1792
1843
|
}
|
|
1793
1844
|
|
|
1794
|
-
parsed[index] +=
|
|
1845
|
+
parsed[index] += identifierWithPointTracking(position - 1, points, index);
|
|
1795
1846
|
break;
|
|
1796
1847
|
|
|
1797
1848
|
case 2:
|
|
@@ -1825,8 +1876,9 @@ var getRules = function getRules(value, points) {
|
|
|
1825
1876
|
var fixedElements = /* #__PURE__ */new WeakMap();
|
|
1826
1877
|
|
|
1827
1878
|
var compat = function compat(element) {
|
|
1828
|
-
if (element.type !== 'rule' || !element.parent || // .length indicates
|
|
1829
|
-
|
|
1879
|
+
if (element.type !== 'rule' || !element.parent || // positive .length indicates that this rule contains pseudo
|
|
1880
|
+
// negative .length indicates that this rule has been already prefixed
|
|
1881
|
+
element.length < 1) {
|
|
1830
1882
|
return;
|
|
1831
1883
|
}
|
|
1832
1884
|
|
|
@@ -2062,7 +2114,8 @@ var createCache = function createCache(options) {
|
|
|
2062
2114
|
container: container,
|
|
2063
2115
|
nonce: options.nonce,
|
|
2064
2116
|
speedy: options.speedy,
|
|
2065
|
-
prepend: options.prepend
|
|
2117
|
+
prepend: options.prepend,
|
|
2118
|
+
insertionPoint: options.insertionPoint
|
|
2066
2119
|
}),
|
|
2067
2120
|
nonce: options.nonce,
|
|
2068
2121
|
inserted: inserted,
|
|
@@ -2080,22 +2133,22 @@ var reactIs$1 = {exports: {}};
|
|
|
2080
2133
|
var reactIs_production_min = {};
|
|
2081
2134
|
|
|
2082
2135
|
var b = "function" === typeof Symbol && Symbol["for"],
|
|
2083
|
-
c
|
|
2136
|
+
c = b ? Symbol["for"]("react.element") : 60103,
|
|
2084
2137
|
d = b ? Symbol["for"]("react.portal") : 60106,
|
|
2085
|
-
e
|
|
2086
|
-
f
|
|
2138
|
+
e = b ? Symbol["for"]("react.fragment") : 60107,
|
|
2139
|
+
f = b ? Symbol["for"]("react.strict_mode") : 60108,
|
|
2087
2140
|
g = b ? Symbol["for"]("react.profiler") : 60114,
|
|
2088
2141
|
h = b ? Symbol["for"]("react.provider") : 60109,
|
|
2089
2142
|
k = b ? Symbol["for"]("react.context") : 60110,
|
|
2090
|
-
l
|
|
2143
|
+
l = b ? Symbol["for"]("react.async_mode") : 60111,
|
|
2091
2144
|
m = b ? Symbol["for"]("react.concurrent_mode") : 60111,
|
|
2092
|
-
n
|
|
2145
|
+
n = b ? Symbol["for"]("react.forward_ref") : 60112,
|
|
2093
2146
|
p = b ? Symbol["for"]("react.suspense") : 60113,
|
|
2094
2147
|
q = b ? Symbol["for"]("react.suspense_list") : 60120,
|
|
2095
2148
|
r$1 = b ? Symbol["for"]("react.memo") : 60115,
|
|
2096
|
-
t
|
|
2149
|
+
t = b ? Symbol["for"]("react.lazy") : 60116,
|
|
2097
2150
|
v = b ? Symbol["for"]("react.block") : 60121,
|
|
2098
|
-
w
|
|
2151
|
+
w = b ? Symbol["for"]("react.fundamental") : 60117,
|
|
2099
2152
|
x = b ? Symbol["for"]("react.responder") : 60118,
|
|
2100
2153
|
y = b ? Symbol["for"]("react.scope") : 60119;
|
|
2101
2154
|
|
|
@@ -2104,21 +2157,21 @@ function z(a) {
|
|
|
2104
2157
|
var u = a.$$typeof;
|
|
2105
2158
|
|
|
2106
2159
|
switch (u) {
|
|
2107
|
-
case c
|
|
2160
|
+
case c:
|
|
2108
2161
|
switch (a = a.type, a) {
|
|
2109
|
-
case l
|
|
2162
|
+
case l:
|
|
2110
2163
|
case m:
|
|
2111
|
-
case e
|
|
2164
|
+
case e:
|
|
2112
2165
|
case g:
|
|
2113
|
-
case f
|
|
2166
|
+
case f:
|
|
2114
2167
|
case p:
|
|
2115
2168
|
return a;
|
|
2116
2169
|
|
|
2117
2170
|
default:
|
|
2118
2171
|
switch (a = a && a.$$typeof, a) {
|
|
2119
2172
|
case k:
|
|
2120
|
-
case n
|
|
2121
|
-
case t
|
|
2173
|
+
case n:
|
|
2174
|
+
case t:
|
|
2122
2175
|
case r$1:
|
|
2123
2176
|
case h:
|
|
2124
2177
|
return a;
|
|
@@ -2139,22 +2192,22 @@ function A(a) {
|
|
|
2139
2192
|
return z(a) === m;
|
|
2140
2193
|
}
|
|
2141
2194
|
|
|
2142
|
-
reactIs_production_min.AsyncMode = l
|
|
2195
|
+
reactIs_production_min.AsyncMode = l;
|
|
2143
2196
|
reactIs_production_min.ConcurrentMode = m;
|
|
2144
2197
|
reactIs_production_min.ContextConsumer = k;
|
|
2145
2198
|
reactIs_production_min.ContextProvider = h;
|
|
2146
|
-
reactIs_production_min.Element = c
|
|
2147
|
-
reactIs_production_min.ForwardRef = n
|
|
2148
|
-
reactIs_production_min.Fragment = e
|
|
2149
|
-
reactIs_production_min.Lazy = t
|
|
2199
|
+
reactIs_production_min.Element = c;
|
|
2200
|
+
reactIs_production_min.ForwardRef = n;
|
|
2201
|
+
reactIs_production_min.Fragment = e;
|
|
2202
|
+
reactIs_production_min.Lazy = t;
|
|
2150
2203
|
reactIs_production_min.Memo = r$1;
|
|
2151
2204
|
reactIs_production_min.Portal = d;
|
|
2152
2205
|
reactIs_production_min.Profiler = g;
|
|
2153
|
-
reactIs_production_min.StrictMode = f
|
|
2206
|
+
reactIs_production_min.StrictMode = f;
|
|
2154
2207
|
reactIs_production_min.Suspense = p;
|
|
2155
2208
|
|
|
2156
2209
|
reactIs_production_min.isAsyncMode = function (a) {
|
|
2157
|
-
return A(a) || z(a) === l
|
|
2210
|
+
return A(a) || z(a) === l;
|
|
2158
2211
|
};
|
|
2159
2212
|
|
|
2160
2213
|
reactIs_production_min.isConcurrentMode = A;
|
|
@@ -2168,19 +2221,19 @@ reactIs_production_min.isContextProvider = function (a) {
|
|
|
2168
2221
|
};
|
|
2169
2222
|
|
|
2170
2223
|
reactIs_production_min.isElement = function (a) {
|
|
2171
|
-
return "object" === _typeof(a) && null !== a && a.$$typeof === c
|
|
2224
|
+
return "object" === _typeof(a) && null !== a && a.$$typeof === c;
|
|
2172
2225
|
};
|
|
2173
2226
|
|
|
2174
2227
|
reactIs_production_min.isForwardRef = function (a) {
|
|
2175
|
-
return z(a) === n
|
|
2228
|
+
return z(a) === n;
|
|
2176
2229
|
};
|
|
2177
2230
|
|
|
2178
2231
|
reactIs_production_min.isFragment = function (a) {
|
|
2179
|
-
return z(a) === e
|
|
2232
|
+
return z(a) === e;
|
|
2180
2233
|
};
|
|
2181
2234
|
|
|
2182
2235
|
reactIs_production_min.isLazy = function (a) {
|
|
2183
|
-
return z(a) === t
|
|
2236
|
+
return z(a) === t;
|
|
2184
2237
|
};
|
|
2185
2238
|
|
|
2186
2239
|
reactIs_production_min.isMemo = function (a) {
|
|
@@ -2196,7 +2249,7 @@ reactIs_production_min.isProfiler = function (a) {
|
|
|
2196
2249
|
};
|
|
2197
2250
|
|
|
2198
2251
|
reactIs_production_min.isStrictMode = function (a) {
|
|
2199
|
-
return z(a) === f
|
|
2252
|
+
return z(a) === f;
|
|
2200
2253
|
};
|
|
2201
2254
|
|
|
2202
2255
|
reactIs_production_min.isSuspense = function (a) {
|
|
@@ -2204,7 +2257,7 @@ reactIs_production_min.isSuspense = function (a) {
|
|
|
2204
2257
|
};
|
|
2205
2258
|
|
|
2206
2259
|
reactIs_production_min.isValidElementType = function (a) {
|
|
2207
|
-
return "string" === typeof a || "function" === typeof a || a === e
|
|
2260
|
+
return "string" === typeof a || "function" === typeof a || a === e || a === m || a === g || a === f || a === p || a === q || "object" === _typeof(a) && null !== a && (a.$$typeof === t || a.$$typeof === r$1 || a.$$typeof === h || a.$$typeof === k || a.$$typeof === n || a.$$typeof === w || a.$$typeof === x || a.$$typeof === y || a.$$typeof === v);
|
|
2208
2261
|
};
|
|
2209
2262
|
|
|
2210
2263
|
reactIs_production_min.typeOf = z;
|
|
@@ -2430,7 +2483,7 @@ function getRegisteredStyles$1(registered, registeredStyles, classNames) {
|
|
|
2430
2483
|
return rawClassName;
|
|
2431
2484
|
}
|
|
2432
2485
|
|
|
2433
|
-
var
|
|
2486
|
+
var registerStyles$1 = function registerStyles(cache, serialized, isStringTag) {
|
|
2434
2487
|
var className = cache.key + "-" + serialized.name;
|
|
2435
2488
|
|
|
2436
2489
|
if ( // we only need to add the styles to the registered cache if the
|
|
@@ -2445,6 +2498,11 @@ var insertStyles$1 = function insertStyles(cache, serialized, isStringTag) {
|
|
|
2445
2498
|
isBrowser$3 === false) && cache.registered[className] === undefined) {
|
|
2446
2499
|
cache.registered[className] = serialized.styles;
|
|
2447
2500
|
}
|
|
2501
|
+
};
|
|
2502
|
+
|
|
2503
|
+
var insertStyles$1 = function insertStyles(cache, serialized, isStringTag) {
|
|
2504
|
+
registerStyles$1(cache, serialized, isStringTag);
|
|
2505
|
+
var className = cache.key + "-" + serialized.name;
|
|
2448
2506
|
|
|
2449
2507
|
if (cache.inserted[serialized.name] === undefined) {
|
|
2450
2508
|
var current = serialized;
|
|
@@ -2602,7 +2660,7 @@ var processStyleValue$1 = function processStyleValue(key, value) {
|
|
|
2602
2660
|
};
|
|
2603
2661
|
|
|
2604
2662
|
if (process.env.NODE_ENV !== 'production') {
|
|
2605
|
-
var contentValuePattern$1 = /(attr|counters?|url|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/;
|
|
2663
|
+
var contentValuePattern$1 = /(var|attr|counters?|url|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/;
|
|
2606
2664
|
var contentValues$1 = ['normal', 'none', 'initial', 'inherit', 'unset'];
|
|
2607
2665
|
var oldProcessStyleValue$1 = processStyleValue$1;
|
|
2608
2666
|
var msPattern$1 = /^-ms-/;
|
|
@@ -2869,7 +2927,7 @@ var serializeStyles$1 = function serializeStyles(args, registered, mergedProps)
|
|
|
2869
2927
|
};
|
|
2870
2928
|
};
|
|
2871
2929
|
|
|
2872
|
-
var hasOwnProperty =
|
|
2930
|
+
var hasOwnProperty = {}.hasOwnProperty;
|
|
2873
2931
|
var EmotionCacheContext = /* #__PURE__ */createContext( // we're doing this to avoid preconstruct's dead code elimination in this one case
|
|
2874
2932
|
// because this module is primarily intended for the browser and node
|
|
2875
2933
|
// but it's also required in react native and similar environments sometimes
|
|
@@ -2879,6 +2937,11 @@ var EmotionCacheContext = /* #__PURE__ */createContext( // we're doing this to a
|
|
|
2879
2937
|
typeof HTMLElement !== 'undefined' ? /* #__PURE__ */createCache({
|
|
2880
2938
|
key: 'css'
|
|
2881
2939
|
}) : null);
|
|
2940
|
+
|
|
2941
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2942
|
+
EmotionCacheContext.displayName = 'EmotionCacheContext';
|
|
2943
|
+
}
|
|
2944
|
+
|
|
2882
2945
|
EmotionCacheContext.Provider;
|
|
2883
2946
|
|
|
2884
2947
|
var withEmotionCache = function withEmotionCache(func) {
|
|
@@ -2892,9 +2955,32 @@ var withEmotionCache = function withEmotionCache(func) {
|
|
|
2892
2955
|
|
|
2893
2956
|
var ThemeContext = /* #__PURE__ */createContext({});
|
|
2894
2957
|
|
|
2958
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2959
|
+
ThemeContext.displayName = 'EmotionThemeContext';
|
|
2960
|
+
}
|
|
2961
|
+
|
|
2962
|
+
var useInsertionEffect$2 = React['useInsertion' + 'Effect'] ? React['useInsertion' + 'Effect'] : function useInsertionEffect(create) {
|
|
2963
|
+
create();
|
|
2964
|
+
};
|
|
2965
|
+
|
|
2966
|
+
function useInsertionEffectMaybe$1(create) {
|
|
2967
|
+
useInsertionEffect$2(create);
|
|
2968
|
+
}
|
|
2969
|
+
|
|
2895
2970
|
var typePropName = '__EMOTION_TYPE_PLEASE_DO_NOT_USE__';
|
|
2896
2971
|
var labelPropName = '__EMOTION_LABEL_PLEASE_DO_NOT_USE__';
|
|
2897
2972
|
|
|
2973
|
+
var Insertion$2 = function Insertion(_ref) {
|
|
2974
|
+
var cache = _ref.cache,
|
|
2975
|
+
serialized = _ref.serialized,
|
|
2976
|
+
isStringTag = _ref.isStringTag;
|
|
2977
|
+
registerStyles$1(cache, serialized, isStringTag);
|
|
2978
|
+
useInsertionEffectMaybe$1(function () {
|
|
2979
|
+
return insertStyles$1(cache, serialized, isStringTag);
|
|
2980
|
+
});
|
|
2981
|
+
return null;
|
|
2982
|
+
};
|
|
2983
|
+
|
|
2898
2984
|
var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
|
|
2899
2985
|
var cssProp = props.css; // so that using `css` from `emotion` and passing the result to the css prop works
|
|
2900
2986
|
// not passing the registered cache to serializeStyles because it would
|
|
@@ -2904,7 +2990,7 @@ var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
|
|
|
2904
2990
|
cssProp = cache.registered[cssProp];
|
|
2905
2991
|
}
|
|
2906
2992
|
|
|
2907
|
-
var
|
|
2993
|
+
var WrappedComponent = props[typePropName];
|
|
2908
2994
|
var registeredStyles = [cssProp];
|
|
2909
2995
|
var className = '';
|
|
2910
2996
|
|
|
@@ -2914,7 +3000,7 @@ var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
|
|
|
2914
3000
|
className = props.className + " ";
|
|
2915
3001
|
}
|
|
2916
3002
|
|
|
2917
|
-
var serialized = serializeStyles$1(registeredStyles, undefined,
|
|
3003
|
+
var serialized = serializeStyles$1(registeredStyles, undefined, useContext(ThemeContext));
|
|
2918
3004
|
|
|
2919
3005
|
if (process.env.NODE_ENV !== 'production' && serialized.name.indexOf('-') === -1) {
|
|
2920
3006
|
var labelFromStack = props[labelPropName];
|
|
@@ -2924,7 +3010,6 @@ var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
|
|
|
2924
3010
|
}
|
|
2925
3011
|
}
|
|
2926
3012
|
|
|
2927
|
-
insertStyles$1(cache, serialized, typeof type === 'string');
|
|
2928
3013
|
className += cache.key + "-" + serialized.name;
|
|
2929
3014
|
var newProps = {};
|
|
2930
3015
|
|
|
@@ -2936,8 +3021,11 @@ var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
|
|
|
2936
3021
|
|
|
2937
3022
|
newProps.ref = ref;
|
|
2938
3023
|
newProps.className = className;
|
|
2939
|
-
|
|
2940
|
-
|
|
3024
|
+
return /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement(Insertion$2, {
|
|
3025
|
+
cache: cache,
|
|
3026
|
+
serialized: serialized,
|
|
3027
|
+
isStringTag: typeof WrappedComponent === 'string'
|
|
3028
|
+
}), /*#__PURE__*/createElement(WrappedComponent, newProps));
|
|
2941
3029
|
});
|
|
2942
3030
|
|
|
2943
3031
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -2946,7 +3034,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
2946
3034
|
|
|
2947
3035
|
var pkg = {
|
|
2948
3036
|
name: "@emotion/react",
|
|
2949
|
-
version: "11.
|
|
3037
|
+
version: "11.9.0",
|
|
2950
3038
|
main: "dist/emotion-react.cjs.js",
|
|
2951
3039
|
module: "dist/emotion-react.esm.js",
|
|
2952
3040
|
browser: {
|
|
@@ -2954,19 +3042,19 @@ var pkg = {
|
|
|
2954
3042
|
"./dist/emotion-react.esm.js": "./dist/emotion-react.browser.esm.js"
|
|
2955
3043
|
},
|
|
2956
3044
|
types: "types/index.d.ts",
|
|
2957
|
-
files: ["src", "dist", "jsx-runtime", "jsx-dev-runtime", "
|
|
3045
|
+
files: ["src", "dist", "jsx-runtime", "jsx-dev-runtime", "_isolated-hnrs", "types/*.d.ts", "macro.js", "macro.d.ts", "macro.js.flow"],
|
|
2958
3046
|
sideEffects: false,
|
|
2959
|
-
author: "
|
|
3047
|
+
author: "Emotion Contributors",
|
|
2960
3048
|
license: "MIT",
|
|
2961
3049
|
scripts: {
|
|
2962
3050
|
"test:typescript": "dtslint types"
|
|
2963
3051
|
},
|
|
2964
3052
|
dependencies: {
|
|
2965
3053
|
"@babel/runtime": "^7.13.10",
|
|
2966
|
-
"@emotion/
|
|
2967
|
-
"@emotion/
|
|
2968
|
-
"@emotion/
|
|
2969
|
-
"@emotion/utils": "^1.
|
|
3054
|
+
"@emotion/babel-plugin": "^11.7.1",
|
|
3055
|
+
"@emotion/cache": "^11.7.1",
|
|
3056
|
+
"@emotion/serialize": "^1.0.3",
|
|
3057
|
+
"@emotion/utils": "^1.1.0",
|
|
2970
3058
|
"@emotion/weak-memoize": "^0.2.5",
|
|
2971
3059
|
"hoist-non-react-statics": "^3.3.1"
|
|
2972
3060
|
},
|
|
@@ -2984,15 +3072,16 @@ var pkg = {
|
|
|
2984
3072
|
},
|
|
2985
3073
|
devDependencies: {
|
|
2986
3074
|
"@babel/core": "^7.13.10",
|
|
2987
|
-
"@emotion/css": "11.
|
|
2988
|
-
"@emotion/css-prettifier": "1.0.
|
|
3075
|
+
"@emotion/css": "11.9.0",
|
|
3076
|
+
"@emotion/css-prettifier": "1.0.1",
|
|
2989
3077
|
"@emotion/server": "11.4.0",
|
|
2990
|
-
"@emotion/styled": "11.
|
|
3078
|
+
"@emotion/styled": "11.8.1",
|
|
2991
3079
|
"@types/react": "^16.9.11",
|
|
2992
|
-
dtslint: "^
|
|
3080
|
+
dtslint: "^4.2.1",
|
|
2993
3081
|
"html-tag-names": "^1.1.2",
|
|
2994
3082
|
react: "16.14.0",
|
|
2995
|
-
"svg-tag-names": "^1.1.1"
|
|
3083
|
+
"svg-tag-names": "^1.1.1",
|
|
3084
|
+
typescript: "^4.5.5"
|
|
2996
3085
|
},
|
|
2997
3086
|
repository: "https://github.com/emotion-js/emotion/tree/main/packages/react",
|
|
2998
3087
|
publishConfig: {
|
|
@@ -3000,11 +3089,12 @@ var pkg = {
|
|
|
3000
3089
|
},
|
|
3001
3090
|
"umd:main": "dist/emotion-react.umd.min.js",
|
|
3002
3091
|
preconstruct: {
|
|
3003
|
-
entrypoints: ["./index.js", "./jsx-runtime.js", "./jsx-dev-runtime.js", "./
|
|
3092
|
+
entrypoints: ["./index.js", "./jsx-runtime.js", "./jsx-dev-runtime.js", "./_isolated-hnrs.js"],
|
|
3004
3093
|
umdName: "emotionReact"
|
|
3005
3094
|
}
|
|
3006
3095
|
};
|
|
3007
3096
|
|
|
3097
|
+
var useInsertionEffect$1 = React['useInsertion' + 'Effect'] ? React['useInsertion' + 'Effect'] : useLayoutEffect;
|
|
3008
3098
|
var warnedAboutCssPropForGlobal = false; // maintain place over rerenders.
|
|
3009
3099
|
// initial render from browser, insertBefore context.sheet.tags[0] or if a style hasn't been inserted there yet, appendChild
|
|
3010
3100
|
// initial client-side render from SSR, use place of hydrating tag
|
|
@@ -3020,14 +3110,15 @@ var Global = /* #__PURE__ */withEmotionCache(function (props, cache) {
|
|
|
3020
3110
|
}
|
|
3021
3111
|
|
|
3022
3112
|
var styles = props.styles;
|
|
3023
|
-
var serialized = serializeStyles$1([styles], undefined,
|
|
3113
|
+
var serialized = serializeStyles$1([styles], undefined, useContext(ThemeContext)); // but it is based on a constant that will never change at runtime
|
|
3024
3114
|
// it's effectively like having two implementations and switching them out
|
|
3025
3115
|
// so it's not actually breaking anything
|
|
3026
3116
|
|
|
3027
3117
|
var sheetRef = useRef();
|
|
3028
|
-
|
|
3029
|
-
var key = cache.key + "-global";
|
|
3030
|
-
|
|
3118
|
+
useInsertionEffect$1(function () {
|
|
3119
|
+
var key = cache.key + "-global"; // use case of https://github.com/emotion-js/emotion/issues/2675
|
|
3120
|
+
|
|
3121
|
+
var sheet = new cache.sheet.constructor({
|
|
3031
3122
|
key: key,
|
|
3032
3123
|
nonce: cache.sheet.nonce,
|
|
3033
3124
|
container: cache.sheet.container,
|
|
@@ -3053,7 +3144,7 @@ var Global = /* #__PURE__ */withEmotionCache(function (props, cache) {
|
|
|
3053
3144
|
sheet.flush();
|
|
3054
3145
|
};
|
|
3055
3146
|
}, [cache]);
|
|
3056
|
-
|
|
3147
|
+
useInsertionEffect$1(function () {
|
|
3057
3148
|
var sheetRefCurrent = sheetRef.current;
|
|
3058
3149
|
var sheet = sheetRefCurrent[0],
|
|
3059
3150
|
rehydrating = sheetRefCurrent[1];
|
|
@@ -3168,8 +3259,20 @@ function merge(registered, css, className) {
|
|
|
3168
3259
|
return rawClassName + css(registeredStyles);
|
|
3169
3260
|
}
|
|
3170
3261
|
|
|
3262
|
+
var Insertion$1 = function Insertion(_ref) {
|
|
3263
|
+
var cache = _ref.cache,
|
|
3264
|
+
serializedArr = _ref.serializedArr;
|
|
3265
|
+
useInsertionEffectMaybe$1(function () {
|
|
3266
|
+
for (var i = 0; i < serializedArr.length; i++) {
|
|
3267
|
+
insertStyles$1(cache, serializedArr[i], false);
|
|
3268
|
+
}
|
|
3269
|
+
});
|
|
3270
|
+
return null;
|
|
3271
|
+
};
|
|
3272
|
+
|
|
3171
3273
|
var ClassNames = /* #__PURE__ */withEmotionCache(function (props, cache) {
|
|
3172
3274
|
var hasRendered = false;
|
|
3275
|
+
var serializedArr = [];
|
|
3173
3276
|
|
|
3174
3277
|
var css = function css() {
|
|
3175
3278
|
if (hasRendered && process.env.NODE_ENV !== 'production') {
|
|
@@ -3181,9 +3284,9 @@ var ClassNames = /* #__PURE__ */withEmotionCache(function (props, cache) {
|
|
|
3181
3284
|
}
|
|
3182
3285
|
|
|
3183
3286
|
var serialized = serializeStyles$1(args, cache.registered);
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3287
|
+
serializedArr.push(serialized); // registration has to happen here as the result of this might get consumed by `cx`
|
|
3288
|
+
|
|
3289
|
+
registerStyles$1(cache, serialized, false);
|
|
3187
3290
|
return cache.key + "-" + serialized.name;
|
|
3188
3291
|
};
|
|
3189
3292
|
|
|
@@ -3206,7 +3309,10 @@ var ClassNames = /* #__PURE__ */withEmotionCache(function (props, cache) {
|
|
|
3206
3309
|
};
|
|
3207
3310
|
var ele = props.children(content);
|
|
3208
3311
|
hasRendered = true;
|
|
3209
|
-
return
|
|
3312
|
+
return /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement(Insertion$1, {
|
|
3313
|
+
cache: cache,
|
|
3314
|
+
serializedArr: serializedArr
|
|
3315
|
+
}), ele);
|
|
3210
3316
|
});
|
|
3211
3317
|
|
|
3212
3318
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -3219,7 +3325,10 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
3219
3325
|
var isJest = typeof jest !== 'undefined';
|
|
3220
3326
|
|
|
3221
3327
|
if (isBrowser$2 && !isJest) {
|
|
3222
|
-
|
|
3328
|
+
// globalThis has wide browser support - https://caniuse.com/?search=globalThis, Node.js 12 and later
|
|
3329
|
+
var globalContext = // $FlowIgnore
|
|
3330
|
+
typeof globalThis !== 'undefined' ? globalThis // eslint-disable-line no-undef
|
|
3331
|
+
: isBrowser$2 ? window : global;
|
|
3223
3332
|
var globalKey = "__EMOTION_REACT_" + pkg.version.split('.')[0] + "__";
|
|
3224
3333
|
|
|
3225
3334
|
if (globalContext[globalKey]) {
|
|
@@ -3244,7 +3353,7 @@ function getRegisteredStyles(registered, registeredStyles, classNames) {
|
|
|
3244
3353
|
return rawClassName;
|
|
3245
3354
|
}
|
|
3246
3355
|
|
|
3247
|
-
var
|
|
3356
|
+
var registerStyles = function registerStyles(cache, serialized, isStringTag) {
|
|
3248
3357
|
var className = cache.key + "-" + serialized.name;
|
|
3249
3358
|
|
|
3250
3359
|
if ( // we only need to add the styles to the registered cache if the
|
|
@@ -3259,6 +3368,11 @@ var insertStyles = function insertStyles(cache, serialized, isStringTag) {
|
|
|
3259
3368
|
isBrowser$1 === false) && cache.registered[className] === undefined) {
|
|
3260
3369
|
cache.registered[className] = serialized.styles;
|
|
3261
3370
|
}
|
|
3371
|
+
};
|
|
3372
|
+
|
|
3373
|
+
var insertStyles = function insertStyles(cache, serialized, isStringTag) {
|
|
3374
|
+
registerStyles(cache, serialized, isStringTag);
|
|
3375
|
+
var className = cache.key + "-" + serialized.name;
|
|
3262
3376
|
|
|
3263
3377
|
if (cache.inserted[serialized.name] === undefined) {
|
|
3264
3378
|
var current = serialized;
|
|
@@ -3610,8 +3724,27 @@ var composeShouldForwardProps = function composeShouldForwardProps(tag, options,
|
|
|
3610
3724
|
return shouldForwardProp;
|
|
3611
3725
|
};
|
|
3612
3726
|
|
|
3727
|
+
var useInsertionEffect = React['useInsertion' + 'Effect'] ? React['useInsertion' + 'Effect'] : function useInsertionEffect(create) {
|
|
3728
|
+
create();
|
|
3729
|
+
};
|
|
3730
|
+
|
|
3731
|
+
function useInsertionEffectMaybe(create) {
|
|
3732
|
+
useInsertionEffect(create);
|
|
3733
|
+
}
|
|
3734
|
+
|
|
3613
3735
|
var ILLEGAL_ESCAPE_SEQUENCE_ERROR = "You have illegal escape sequence in your template literal, most likely inside content's property value.\nBecause you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \"content: '\\00d7';\" should become \"content: '\\\\00d7';\".\nYou can read more about this here:\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences";
|
|
3614
3736
|
|
|
3737
|
+
var Insertion = function Insertion(_ref) {
|
|
3738
|
+
var cache = _ref.cache,
|
|
3739
|
+
serialized = _ref.serialized,
|
|
3740
|
+
isStringTag = _ref.isStringTag;
|
|
3741
|
+
registerStyles(cache, serialized, isStringTag);
|
|
3742
|
+
useInsertionEffectMaybe(function () {
|
|
3743
|
+
return insertStyles(cache, serialized, isStringTag);
|
|
3744
|
+
});
|
|
3745
|
+
return null;
|
|
3746
|
+
};
|
|
3747
|
+
|
|
3615
3748
|
var createStyled = function createStyled(tag, options) {
|
|
3616
3749
|
if (process.env.NODE_ENV !== 'production') {
|
|
3617
3750
|
if (tag === undefined) {
|
|
@@ -3662,7 +3795,7 @@ var createStyled = function createStyled(tag, options) {
|
|
|
3662
3795
|
|
|
3663
3796
|
|
|
3664
3797
|
var Styled = withEmotionCache(function (props, cache, ref) {
|
|
3665
|
-
var
|
|
3798
|
+
var FinalTag = shouldUseAs && props.as || baseTag;
|
|
3666
3799
|
var className = '';
|
|
3667
3800
|
var classInterpolations = [];
|
|
3668
3801
|
var mergedProps = props;
|
|
@@ -3684,14 +3817,13 @@ var createStyled = function createStyled(tag, options) {
|
|
|
3684
3817
|
}
|
|
3685
3818
|
|
|
3686
3819
|
var serialized = serializeStyles(styles.concat(classInterpolations), cache.registered, mergedProps);
|
|
3687
|
-
insertStyles(cache, serialized, typeof finalTag === 'string');
|
|
3688
3820
|
className += cache.key + "-" + serialized.name;
|
|
3689
3821
|
|
|
3690
3822
|
if (targetClassName !== undefined) {
|
|
3691
3823
|
className += " " + targetClassName;
|
|
3692
3824
|
}
|
|
3693
3825
|
|
|
3694
|
-
var finalShouldForwardProp = shouldUseAs && shouldForwardProp === undefined ? getDefaultShouldForwardProp(
|
|
3826
|
+
var finalShouldForwardProp = shouldUseAs && shouldForwardProp === undefined ? getDefaultShouldForwardProp(FinalTag) : defaultShouldForwardProp;
|
|
3695
3827
|
var newProps = {};
|
|
3696
3828
|
|
|
3697
3829
|
for (var _key in props) {
|
|
@@ -3705,8 +3837,11 @@ var createStyled = function createStyled(tag, options) {
|
|
|
3705
3837
|
|
|
3706
3838
|
newProps.className = className;
|
|
3707
3839
|
newProps.ref = ref;
|
|
3708
|
-
|
|
3709
|
-
|
|
3840
|
+
return /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement(Insertion, {
|
|
3841
|
+
cache: cache,
|
|
3842
|
+
serialized: serialized,
|
|
3843
|
+
isStringTag: typeof FinalTag === 'string'
|
|
3844
|
+
}), /*#__PURE__*/createElement(FinalTag, newProps));
|
|
3710
3845
|
});
|
|
3711
3846
|
Styled.displayName = identifierName !== undefined ? identifierName : "Styled(" + (typeof baseTag === 'string' ? baseTag : baseTag.displayName || baseTag.name || 'Component') + ")";
|
|
3712
3847
|
Styled.defaultProps = tag.defaultProps;
|
|
@@ -3783,12 +3918,12 @@ var StyledSpinner = newStyled.div(_templateObject2$1 || (_templateObject2$1 = _t
|
|
|
3783
3918
|
var Spinner = function Spinner(_ref12) {
|
|
3784
3919
|
var _ref12$size = _ref12.size,
|
|
3785
3920
|
size = _ref12$size === void 0 ? 100 : _ref12$size;
|
|
3786
|
-
return /*#__PURE__*/
|
|
3921
|
+
return /*#__PURE__*/React__default.createElement(StyledSpinner, {
|
|
3787
3922
|
size: size
|
|
3788
3923
|
});
|
|
3789
3924
|
};
|
|
3790
3925
|
|
|
3791
|
-
var Context = /*#__PURE__*/
|
|
3926
|
+
var Context = /*#__PURE__*/React__default.createContext();
|
|
3792
3927
|
var WireProvider = function WireProvider(_ref) {
|
|
3793
3928
|
var socket = _ref.socket,
|
|
3794
3929
|
room = _ref.room,
|
|
@@ -3796,31 +3931,31 @@ var WireProvider = function WireProvider(_ref) {
|
|
|
3796
3931
|
channel = _ref$channel === void 0 ? "default" : _ref$channel,
|
|
3797
3932
|
children = _ref.children;
|
|
3798
3933
|
|
|
3799
|
-
var _React$useState =
|
|
3934
|
+
var _React$useState = React__default.useState(false),
|
|
3800
3935
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
3801
3936
|
joined = _React$useState2[0],
|
|
3802
3937
|
setJoined = _React$useState2[1];
|
|
3803
3938
|
|
|
3804
|
-
var _React$useState3 =
|
|
3939
|
+
var _React$useState3 = React__default.useState(false),
|
|
3805
3940
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
3806
3941
|
isMaster = _React$useState4[0],
|
|
3807
3942
|
setIsMaster = _React$useState4[1];
|
|
3808
3943
|
|
|
3809
|
-
var _React$useState5 =
|
|
3944
|
+
var _React$useState5 = React__default.useState(null),
|
|
3810
3945
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
3811
3946
|
wire = _React$useState6[0],
|
|
3812
3947
|
setWire = _React$useState6[1];
|
|
3813
3948
|
|
|
3814
|
-
var roomRef =
|
|
3815
|
-
var mountedRef =
|
|
3949
|
+
var roomRef = React__default.useRef(null);
|
|
3950
|
+
var mountedRef = React__default.useRef(false);
|
|
3816
3951
|
var existingC2C = useContext(Context);
|
|
3817
|
-
|
|
3952
|
+
React__default.useEffect(function () {
|
|
3818
3953
|
mountedRef.current = true;
|
|
3819
3954
|
return function () {
|
|
3820
3955
|
mountedRef.current = false;
|
|
3821
3956
|
};
|
|
3822
3957
|
}, []);
|
|
3823
|
-
|
|
3958
|
+
React__default.useEffect(function () {
|
|
3824
3959
|
if (!socket) {
|
|
3825
3960
|
return null;
|
|
3826
3961
|
}
|
|
@@ -3837,7 +3972,7 @@ var WireProvider = function WireProvider(_ref) {
|
|
|
3837
3972
|
socket.off("disconnect", disconnect);
|
|
3838
3973
|
};
|
|
3839
3974
|
}, [channel, socket]);
|
|
3840
|
-
|
|
3975
|
+
React__default.useEffect(function () {
|
|
3841
3976
|
// Connect
|
|
3842
3977
|
if (!socket) {
|
|
3843
3978
|
return null;
|
|
@@ -3872,7 +4007,7 @@ var WireProvider = function WireProvider(_ref) {
|
|
|
3872
4007
|
}, [channel, room, socket]);
|
|
3873
4008
|
|
|
3874
4009
|
if (!joined || !wire) {
|
|
3875
|
-
return /*#__PURE__*/
|
|
4010
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
3876
4011
|
style: {
|
|
3877
4012
|
position: "absolute",
|
|
3878
4013
|
top: "0",
|
|
@@ -3882,10 +4017,10 @@ var WireProvider = function WireProvider(_ref) {
|
|
|
3882
4017
|
justifyContent: "center",
|
|
3883
4018
|
alignItems: "center"
|
|
3884
4019
|
}
|
|
3885
|
-
}, /*#__PURE__*/
|
|
4020
|
+
}, /*#__PURE__*/React__default.createElement(Spinner, null));
|
|
3886
4021
|
}
|
|
3887
4022
|
|
|
3888
|
-
return /*#__PURE__*/
|
|
4023
|
+
return /*#__PURE__*/React__default.createElement(Context.Provider, {
|
|
3889
4024
|
value: _objectSpread2(_objectSpread2({}, existingC2C), {}, _defineProperty({}, channel, {
|
|
3890
4025
|
wire: wire,
|
|
3891
4026
|
joined: joined,
|
|
@@ -3975,10 +4110,6 @@ var useItemList = function useItemList() {
|
|
|
3975
4110
|
return items;
|
|
3976
4111
|
};
|
|
3977
4112
|
|
|
3978
|
-
var useSelectedItems = function useSelectedItems() {
|
|
3979
|
-
return useRecoilValue(SelectedItemsAtom);
|
|
3980
|
-
};
|
|
3981
|
-
|
|
3982
4113
|
/**
|
|
3983
4114
|
* Run effect only when component is unmounted.
|
|
3984
4115
|
*
|
|
@@ -4166,6 +4297,28 @@ function useThrottledCallback(callback, deps, delay, noTrailing) {
|
|
|
4166
4297
|
}, __spreadArray([delay, noTrailing], deps, true));
|
|
4167
4298
|
}
|
|
4168
4299
|
|
|
4300
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4301
|
+
/**
|
|
4302
|
+
* Like `useEffect`, but passed function is debounced.
|
|
4303
|
+
*
|
|
4304
|
+
* @param callback Callback like for `useEffect`, but without ability to return
|
|
4305
|
+
* a cleanup function.
|
|
4306
|
+
* @param deps Dependencies list that will be passed to underlying `useEffect`
|
|
4307
|
+
* and `useDebouncedCallback`.
|
|
4308
|
+
* @param delay Debounce delay.
|
|
4309
|
+
* @param maxWait Maximum amount of milliseconds that function can be delayed
|
|
4310
|
+
* before it's force execution. 0 means no max wait.
|
|
4311
|
+
*/
|
|
4312
|
+
|
|
4313
|
+
function useDebouncedEffect(callback, deps, delay, maxWait) {
|
|
4314
|
+
if (maxWait === void 0) {
|
|
4315
|
+
maxWait = 0;
|
|
4316
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4317
|
+
|
|
4318
|
+
|
|
4319
|
+
useEffect(useDebouncedCallback(callback, deps, delay, maxWait), deps);
|
|
4320
|
+
}
|
|
4321
|
+
|
|
4169
4322
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4170
4323
|
/**
|
|
4171
4324
|
* Like `useEffect`, but passed function is throttled.
|
|
@@ -4310,1196 +4463,1349 @@ function useResizeObserver(target, callback, enabled) {
|
|
|
4310
4463
|
}, [target, ro]);
|
|
4311
4464
|
}
|
|
4312
4465
|
|
|
4313
|
-
var
|
|
4466
|
+
var useDebouncedItems = function useDebouncedItems() {
|
|
4467
|
+
var items = useRecoilValue(AllItemsSelector);
|
|
4314
4468
|
|
|
4315
|
-
var
|
|
4316
|
-
|
|
4317
|
-
|
|
4469
|
+
var _React$useState = React__default.useState(items),
|
|
4470
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
4471
|
+
debouncedItems = _React$useState2[0],
|
|
4472
|
+
setDebouncedItems = _React$useState2[1];
|
|
4318
4473
|
|
|
4319
|
-
var
|
|
4320
|
-
var
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4474
|
+
var updateDebouncedItems = useRecoilCallback(function (_ref) {
|
|
4475
|
+
var snapshot = _ref.snapshot;
|
|
4476
|
+
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
4477
|
+
var currentItemMap;
|
|
4478
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
4479
|
+
while (1) {
|
|
4480
|
+
switch (_context.prev = _context.next) {
|
|
4481
|
+
case 0:
|
|
4482
|
+
_context.next = 2;
|
|
4483
|
+
return snapshot.getPromise(AllItemsSelector);
|
|
4324
4484
|
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
style: {
|
|
4329
|
-
width: "100px",
|
|
4330
|
-
display: "flex",
|
|
4331
|
-
flexDirection: "column",
|
|
4332
|
-
justifyContent: "center",
|
|
4333
|
-
textAlign: "center",
|
|
4334
|
-
color: "red"
|
|
4335
|
-
},
|
|
4336
|
-
className: "syncboard-error-item"
|
|
4337
|
-
}, "Sorry, this item seems broken.", /*#__PURE__*/React.createElement("button", {
|
|
4338
|
-
onClick: onReload
|
|
4339
|
-
}, "Reload it"));
|
|
4340
|
-
};
|
|
4341
|
-
/* Error boundary for broken item */
|
|
4485
|
+
case 2:
|
|
4486
|
+
currentItemMap = _context.sent;
|
|
4487
|
+
setDebouncedItems(currentItemMap);
|
|
4342
4488
|
|
|
4489
|
+
case 4:
|
|
4490
|
+
case "end":
|
|
4491
|
+
return _context.stop();
|
|
4492
|
+
}
|
|
4493
|
+
}
|
|
4494
|
+
}, _callee);
|
|
4495
|
+
}));
|
|
4496
|
+
}, []);
|
|
4497
|
+
useDebouncedEffect(updateDebouncedItems, [items], 300);
|
|
4498
|
+
return debouncedItems;
|
|
4499
|
+
};
|
|
4343
4500
|
|
|
4344
|
-
var
|
|
4345
|
-
|
|
4501
|
+
var useSelectedItems = function useSelectedItems() {
|
|
4502
|
+
return useRecoilValue(SelectedItemsAtom);
|
|
4503
|
+
};
|
|
4346
4504
|
|
|
4347
|
-
|
|
4505
|
+
var isMacOS = function isMacOS() {
|
|
4506
|
+
var userAgent = navigator.userAgent.toLowerCase();
|
|
4507
|
+
return /mac os ?x 10/.test(userAgent);
|
|
4508
|
+
}; // From https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
|
|
4348
4509
|
|
|
4349
|
-
|
|
4350
|
-
|
|
4510
|
+
var getScrollLineHeight = function getScrollLineHeight() {
|
|
4511
|
+
var iframe = document.createElement("iframe");
|
|
4512
|
+
iframe.src = "#";
|
|
4513
|
+
document.body.appendChild(iframe); // Write content in Iframe
|
|
4351
4514
|
|
|
4352
|
-
|
|
4515
|
+
var idoc = iframe.contentWindow.document;
|
|
4516
|
+
idoc.open();
|
|
4517
|
+
idoc.write("<!DOCTYPE html><html><head></head><body><span>a</span></body></html>");
|
|
4518
|
+
idoc.close();
|
|
4519
|
+
var scrollLineHeight = idoc.body.firstElementChild.offsetHeight;
|
|
4520
|
+
document.body.removeChild(iframe);
|
|
4521
|
+
return scrollLineHeight;
|
|
4522
|
+
};
|
|
4353
4523
|
|
|
4354
|
-
|
|
4355
|
-
_this.state = {
|
|
4356
|
-
hasError: false,
|
|
4357
|
-
itemId: props.itemId
|
|
4358
|
-
};
|
|
4359
|
-
_this.onReload = _this.onReload.bind(_assertThisInitialized(_this));
|
|
4360
|
-
return _this;
|
|
4361
|
-
}
|
|
4524
|
+
var LINE_HEIGHT = getScrollLineHeight(); // Reasonable default from https://github.com/facebookarchive/fixed-data-table/blob/master/src/vendor_upstream/dom/normalizeWheel.js
|
|
4362
4525
|
|
|
4363
|
-
|
|
4364
|
-
key: "componentDidCatch",
|
|
4365
|
-
value: function componentDidCatch(error) {
|
|
4366
|
-
// eslint-disable-next-line no-console
|
|
4367
|
-
console.error("Error for item ".concat(this.state.itemId), error, this.props.state);
|
|
4368
|
-
}
|
|
4369
|
-
}, {
|
|
4370
|
-
key: "onReload",
|
|
4371
|
-
value: function onReload() {
|
|
4372
|
-
this.setState({
|
|
4373
|
-
hasError: false
|
|
4374
|
-
});
|
|
4375
|
-
}
|
|
4376
|
-
}, {
|
|
4377
|
-
key: "render",
|
|
4378
|
-
value: function render() {
|
|
4379
|
-
var ErrorComponent = this.props.ErrorComponent;
|
|
4526
|
+
var PAGE_HEIGHT = 800;
|
|
4380
4527
|
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4528
|
+
var otherPointer = function otherPointer(pointers, currentPointer) {
|
|
4529
|
+
var p2 = Object.keys(pointers).map(function (p) {
|
|
4530
|
+
return Number(p);
|
|
4531
|
+
}).find(function (pointer) {
|
|
4532
|
+
return pointer !== currentPointer;
|
|
4533
|
+
});
|
|
4534
|
+
return pointers[p2];
|
|
4535
|
+
};
|
|
4386
4536
|
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
value: function getDerivedStateFromError() {
|
|
4392
|
-
return {
|
|
4393
|
-
hasError: true
|
|
4394
|
-
};
|
|
4395
|
-
}
|
|
4396
|
-
}]);
|
|
4537
|
+
var computeDistance = function computeDistance(_ref, _ref2) {
|
|
4538
|
+
var _ref3 = _slicedToArray(_ref, 2),
|
|
4539
|
+
x1 = _ref3[0],
|
|
4540
|
+
y1 = _ref3[1];
|
|
4397
4541
|
|
|
4398
|
-
|
|
4399
|
-
|
|
4542
|
+
var _ref4 = _slicedToArray(_ref2, 2),
|
|
4543
|
+
x2 = _ref4[0],
|
|
4544
|
+
y2 = _ref4[1];
|
|
4400
4545
|
|
|
4401
|
-
var
|
|
4402
|
-
|
|
4546
|
+
var distanceX = Math.abs(x1 - x2);
|
|
4547
|
+
var distanceY = Math.abs(y1 - y2);
|
|
4548
|
+
return Math.hypot(distanceX, distanceY);
|
|
4403
4549
|
};
|
|
4404
4550
|
|
|
4405
|
-
var
|
|
4406
|
-
var _itemMap$error;
|
|
4407
|
-
|
|
4408
|
-
var setState = _ref3.setState,
|
|
4409
|
-
_ref3$state = _ref3.state;
|
|
4410
|
-
_ref3$state = _ref3$state === void 0 ? {} : _ref3$state;
|
|
4411
|
-
|
|
4412
|
-
var type = _ref3$state.type,
|
|
4413
|
-
_ref3$state$rotation = _ref3$state.rotation,
|
|
4414
|
-
rotation = _ref3$state$rotation === void 0 ? 0 : _ref3$state$rotation,
|
|
4415
|
-
id = _ref3$state.id,
|
|
4416
|
-
locked = _ref3$state.locked,
|
|
4417
|
-
layer = _ref3$state.layer,
|
|
4418
|
-
rest = _objectWithoutProperties(_ref3$state, _excluded$2),
|
|
4419
|
-
_ref3$animate = _ref3.animate,
|
|
4420
|
-
animate = _ref3$animate === void 0 ? "hvr-pop" : _ref3$animate,
|
|
4421
|
-
isSelected = _ref3.isSelected,
|
|
4422
|
-
itemMap = _ref3.itemMap,
|
|
4423
|
-
unlocked = _ref3.unlocked;
|
|
4424
|
-
|
|
4425
|
-
var animateRef = React.useRef(null);
|
|
4426
|
-
|
|
4427
|
-
var Component = itemMap[type].component || function () {
|
|
4428
|
-
return null;
|
|
4429
|
-
};
|
|
4551
|
+
var empty = function empty() {};
|
|
4430
4552
|
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4553
|
+
var protect = function protect(fn) {
|
|
4554
|
+
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
4555
|
+
var _args = arguments;
|
|
4556
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
4557
|
+
while (1) {
|
|
4558
|
+
switch (_context.prev = _context.next) {
|
|
4559
|
+
case 0:
|
|
4560
|
+
_context.prev = 0;
|
|
4561
|
+
_context.next = 3;
|
|
4562
|
+
return fn.apply(void 0, _args);
|
|
4439
4563
|
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4564
|
+
case 3:
|
|
4565
|
+
_context.next = 8;
|
|
4566
|
+
break;
|
|
4443
4567
|
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4568
|
+
case 5:
|
|
4569
|
+
_context.prev = 5;
|
|
4570
|
+
_context.t0 = _context["catch"](0);
|
|
4571
|
+
// eslint-disable-next-line no-console
|
|
4572
|
+
console.error(_context.t0);
|
|
4447
4573
|
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
4456
|
-
style: {
|
|
4457
|
-
display: "flex"
|
|
4458
|
-
},
|
|
4459
|
-
ref: animateRef,
|
|
4460
|
-
onAnimationEnd: removeClass,
|
|
4461
|
-
onKeyDown: function onKeyDown(e) {
|
|
4462
|
-
return e.stopPropagation();
|
|
4463
|
-
},
|
|
4464
|
-
onKeyUp: function onKeyUp(e) {
|
|
4465
|
-
return e.stopPropagation();
|
|
4466
|
-
}
|
|
4467
|
-
}, /*#__PURE__*/React.createElement(ItemErrorBoundary, {
|
|
4468
|
-
itemId: id,
|
|
4469
|
-
state: rest,
|
|
4470
|
-
setState: updateState,
|
|
4471
|
-
ErrorComponent: (itemMap === null || itemMap === void 0 ? void 0 : (_itemMap$error = itemMap.error) === null || _itemMap$error === void 0 ? void 0 : _itemMap$error.component) || DefaultErrorComponent
|
|
4472
|
-
}, /*#__PURE__*/React.createElement(Component, _extends$1({}, rest, {
|
|
4473
|
-
id: id,
|
|
4474
|
-
setState: updateState
|
|
4475
|
-
}))), /*#__PURE__*/React.createElement("div", {
|
|
4476
|
-
className: "corner top-left"
|
|
4477
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
4478
|
-
className: "corner top-right"
|
|
4479
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
4480
|
-
className: "corner bottom-left"
|
|
4481
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
4482
|
-
className: "corner bottom-right"
|
|
4483
|
-
})));
|
|
4574
|
+
case 8:
|
|
4575
|
+
case "end":
|
|
4576
|
+
return _context.stop();
|
|
4577
|
+
}
|
|
4578
|
+
}
|
|
4579
|
+
}, _callee, null, [[0, 5]]);
|
|
4580
|
+
}));
|
|
4484
4581
|
};
|
|
4485
4582
|
|
|
4486
|
-
var
|
|
4487
|
-
var
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4583
|
+
var Gesture = function Gesture(_ref6) {
|
|
4584
|
+
var children = _ref6.children,
|
|
4585
|
+
_ref6$onDrag = _ref6.onDrag,
|
|
4586
|
+
onDrag = _ref6$onDrag === void 0 ? empty : _ref6$onDrag,
|
|
4587
|
+
_ref6$onDragStart = _ref6.onDragStart,
|
|
4588
|
+
onDragStart = _ref6$onDragStart === void 0 ? empty : _ref6$onDragStart,
|
|
4589
|
+
_ref6$onDragEnd = _ref6.onDragEnd,
|
|
4590
|
+
onDragEnd = _ref6$onDragEnd === void 0 ? empty : _ref6$onDragEnd,
|
|
4591
|
+
_ref6$onPan = _ref6.onPan,
|
|
4592
|
+
onPan = _ref6$onPan === void 0 ? empty : _ref6$onPan,
|
|
4593
|
+
_ref6$onTap = _ref6.onTap,
|
|
4594
|
+
onTap = _ref6$onTap === void 0 ? empty : _ref6$onTap,
|
|
4595
|
+
_ref6$onLongTap = _ref6.onLongTap,
|
|
4596
|
+
onLongTap = _ref6$onLongTap === void 0 ? empty : _ref6$onLongTap,
|
|
4597
|
+
_ref6$onDoubleTap = _ref6.onDoubleTap,
|
|
4598
|
+
onDoubleTap = _ref6$onDoubleTap === void 0 ? empty : _ref6$onDoubleTap,
|
|
4599
|
+
onZoom = _ref6.onZoom;
|
|
4600
|
+
var wrapperRef = React__default.useRef(null);
|
|
4601
|
+
var stateRef = React__default.useRef({
|
|
4602
|
+
moving: false,
|
|
4603
|
+
pointers: {},
|
|
4604
|
+
mainPointer: undefined
|
|
4605
|
+
});
|
|
4606
|
+
var queueRef = React__default.useRef([]); // Queue event to avoid async mess
|
|
4607
|
+
|
|
4608
|
+
var queue = React__default.useCallback(function (callback, args) {
|
|
4609
|
+
queueRef.current.push( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
4610
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
4611
|
+
while (1) {
|
|
4612
|
+
switch (_context2.prev = _context2.next) {
|
|
4613
|
+
case 0:
|
|
4614
|
+
_context2.next = 2;
|
|
4615
|
+
return protect(callback)(args);
|
|
4497
4616
|
|
|
4498
|
-
|
|
4499
|
-
|
|
4617
|
+
case 2:
|
|
4618
|
+
queueRef.current.shift();
|
|
4500
4619
|
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
rest = _objectWithoutProperties(_ref6, _excluded2);
|
|
4620
|
+
if (!(queueRef.current.length !== 0)) {
|
|
4621
|
+
_context2.next = 6;
|
|
4622
|
+
break;
|
|
4623
|
+
}
|
|
4506
4624
|
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
};
|
|
4625
|
+
_context2.next = 6;
|
|
4626
|
+
return protect(queueRef.current[0])();
|
|
4510
4627
|
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
_stateTrans$layer = _stateTrans.layer,
|
|
4519
|
-
layer = _stateTrans$layer === void 0 ? 0 : _stateTrans$layer,
|
|
4520
|
-
moving = _stateTrans.moving,
|
|
4521
|
-
stateRest = _objectWithoutProperties(_stateTrans, _excluded3);
|
|
4522
|
-
|
|
4523
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
4524
|
-
style: {
|
|
4525
|
-
position: "absolute",
|
|
4526
|
-
top: "".concat(boardSize / 2, "px"),
|
|
4527
|
-
left: "".concat(boardSize / 2, "px"),
|
|
4528
|
-
display: "inline-block",
|
|
4529
|
-
transform: "translate(".concat(x, "px, ").concat(y, "px)"),
|
|
4530
|
-
zIndex: (layer + 4) * 10 + 100 + (moving ? 5 : 0) // Items z-index between 100 and 200
|
|
4628
|
+
case 6:
|
|
4629
|
+
case "end":
|
|
4630
|
+
return _context2.stop();
|
|
4631
|
+
}
|
|
4632
|
+
}
|
|
4633
|
+
}, _callee2);
|
|
4634
|
+
})));
|
|
4531
4635
|
|
|
4636
|
+
if (queueRef.current.length === 1) {
|
|
4637
|
+
protect(queueRef.current[0])();
|
|
4532
4638
|
}
|
|
4533
|
-
},
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4639
|
+
}, []);
|
|
4640
|
+
var onWheel = React__default.useCallback(function (e) {
|
|
4641
|
+
var deltaX = e.deltaX,
|
|
4642
|
+
deltaY = e.deltaY,
|
|
4643
|
+
clientX = e.clientX,
|
|
4644
|
+
clientY = e.clientY,
|
|
4645
|
+
deltaMode = e.deltaMode,
|
|
4646
|
+
ctrlKey = e.ctrlKey,
|
|
4647
|
+
altKey = e.altKey,
|
|
4648
|
+
metaKey = e.metaKey,
|
|
4649
|
+
target = e.target; // On a MacOs trackpad, the pinch gesture sets the ctrlKey to true.
|
|
4650
|
+
// In that situation, we want to use the custom scaling, not the browser default zoom.
|
|
4651
|
+
// Hence in this situation we avoid to return immediately.
|
|
4537
4652
|
|
|
4538
|
-
|
|
4653
|
+
if (altKey || ctrlKey && !isMacOS()) {
|
|
4654
|
+
return;
|
|
4655
|
+
} // On a trackpad, the pinch and pan events are differentiated by the crtlKey value.
|
|
4656
|
+
// On a pinch gesture, the ctrlKey is set to true, so we want to have a scaling effect.
|
|
4657
|
+
// If we are only moving the fingers in the same direction, a pan is needed.
|
|
4658
|
+
// Ref: https://medium.com/@auchenberg/detecting-multi-touch-trackpad-gestures-in-javascript-a2505babb10e
|
|
4539
4659
|
|
|
4540
|
-
var persistUser = function persistUser(user) {
|
|
4541
|
-
localStorage.setItem("user", JSON.stringify(user));
|
|
4542
|
-
};
|
|
4543
|
-
var colors = ["#037758", "#99092a", "#067070", "#c6650f", "#008726", "#3d7004", "#348402", "#057f58", "#b58612", "#c44c01", "#0a7704", "#0e910e", "#027377", "#c99e02", "#054160", "#157a01", "#b10de2", "#0d6289", "#bc5d03", "#ba0cd1", "#d39f10", "#0c4c7a", "#460782", "#a51f10", "#cecb10", "#9b0943", "#607f0c", "#007a4b", "#bf0daa", "#af0ad8"];
|
|
4544
4660
|
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4661
|
+
if (isMacOS() && !ctrlKey) {
|
|
4662
|
+
queue(onPan, {
|
|
4663
|
+
deltaX: -2 * deltaX,
|
|
4664
|
+
deltaY: -2 * deltaY,
|
|
4665
|
+
button: 1,
|
|
4666
|
+
ctrlKey: ctrlKey,
|
|
4667
|
+
metaKey: metaKey,
|
|
4668
|
+
target: target,
|
|
4669
|
+
event: e
|
|
4670
|
+
});
|
|
4671
|
+
} else {
|
|
4672
|
+
// Quit if onZoom is not set
|
|
4673
|
+
if (onZoom === undefined || !deltaY) return;
|
|
4674
|
+
var scale = deltaY;
|
|
4548
4675
|
|
|
4676
|
+
switch (deltaMode) {
|
|
4677
|
+
case 1:
|
|
4678
|
+
// Pixel
|
|
4679
|
+
scale *= LINE_HEIGHT;
|
|
4680
|
+
break;
|
|
4549
4681
|
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
name: "Player",
|
|
4555
|
-
color: getRandomColor(),
|
|
4556
|
-
uid: nanoid()
|
|
4557
|
-
}, JSON.parse(localStorage.user)); // Id is given by server
|
|
4558
|
-
// delete localUser.id;
|
|
4682
|
+
case 2:
|
|
4683
|
+
scale *= PAGE_HEIGHT;
|
|
4684
|
+
break;
|
|
4685
|
+
}
|
|
4559
4686
|
|
|
4687
|
+
if (isMacOS()) {
|
|
4688
|
+
scale *= 2;
|
|
4689
|
+
}
|
|
4560
4690
|
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4691
|
+
queue(onZoom, {
|
|
4692
|
+
scale: scale,
|
|
4693
|
+
clientX: clientX,
|
|
4694
|
+
clientY: clientY,
|
|
4695
|
+
event: e
|
|
4696
|
+
});
|
|
4697
|
+
}
|
|
4698
|
+
}, [onPan, onZoom, queue]);
|
|
4699
|
+
var onPointerDown = React__default.useCallback(function (_ref8) {
|
|
4700
|
+
var target = _ref8.target,
|
|
4701
|
+
button = _ref8.button,
|
|
4702
|
+
clientX = _ref8.clientX,
|
|
4703
|
+
clientY = _ref8.clientY,
|
|
4704
|
+
pointerId = _ref8.pointerId,
|
|
4705
|
+
altKey = _ref8.altKey,
|
|
4706
|
+
ctrlKey = _ref8.ctrlKey,
|
|
4707
|
+
metaKey = _ref8.metaKey,
|
|
4708
|
+
isPrimary = _ref8.isPrimary;
|
|
4709
|
+
// Add pointer to map
|
|
4710
|
+
stateRef.current.pointers[pointerId] = {
|
|
4711
|
+
clientX: clientX,
|
|
4712
|
+
clientY: clientY
|
|
4713
|
+
};
|
|
4564
4714
|
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
};
|
|
4570
|
-
persistUser(newUser);
|
|
4571
|
-
return newUser;
|
|
4572
|
-
};
|
|
4573
|
-
var userAtom = atom({
|
|
4574
|
-
key: "user",
|
|
4575
|
-
"default": getUser()
|
|
4576
|
-
});
|
|
4577
|
-
var usersAtom = atom({
|
|
4578
|
-
key: "users",
|
|
4579
|
-
"default": []
|
|
4580
|
-
});
|
|
4581
|
-
var localUsersAtom = selector({
|
|
4582
|
-
key: "localUsersAtom",
|
|
4583
|
-
get: function get(_ref) {
|
|
4584
|
-
var _get = _ref.get;
|
|
4715
|
+
if (isPrimary) {
|
|
4716
|
+
// Clean mainPoint on primary pointer
|
|
4717
|
+
stateRef.current.mainPointer = undefined;
|
|
4718
|
+
}
|
|
4585
4719
|
|
|
4586
|
-
|
|
4720
|
+
if (stateRef.current.mainPointer !== undefined) {
|
|
4721
|
+
if (stateRef.current.mainPointer !== pointerId) {
|
|
4722
|
+
// This is not the main pointer
|
|
4723
|
+
try {
|
|
4724
|
+
var _otherPointer = otherPointer(stateRef.current.pointers, pointerId),
|
|
4725
|
+
clientX2 = _otherPointer.clientX,
|
|
4726
|
+
clientY2 = _otherPointer.clientY;
|
|
4587
4727
|
|
|
4588
|
-
|
|
4728
|
+
var newClientX = (clientX2 + clientX) / 2;
|
|
4729
|
+
var newClientY = (clientY2 + clientY) / 2;
|
|
4730
|
+
var distance = computeDistance([clientX2, clientY2], [clientX, clientY]); // We update previous position as the new position is the center beetween both finger
|
|
4589
4731
|
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4732
|
+
Object.assign(stateRef.current, {
|
|
4733
|
+
pressed: true,
|
|
4734
|
+
moving: false,
|
|
4735
|
+
gestureStart: false,
|
|
4736
|
+
startX: clientX,
|
|
4737
|
+
startY: clientY,
|
|
4738
|
+
prevX: newClientX,
|
|
4739
|
+
prevY: newClientY,
|
|
4740
|
+
startDistance: distance,
|
|
4741
|
+
prevDistance: distance
|
|
4742
|
+
});
|
|
4743
|
+
} catch (e) {
|
|
4744
|
+
// eslint-disable-next-line no-console
|
|
4745
|
+
console.log("Error while getting other pointer. Ignoring", e); // eslint-disable-next-line no-unused-expressions
|
|
4596
4746
|
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
currentUser = _useRecoilState2[0],
|
|
4601
|
-
setCurrentUserState = _useRecoilState2[1];
|
|
4747
|
+
stateRef.current.mainPointer === undefined;
|
|
4748
|
+
}
|
|
4749
|
+
}
|
|
4602
4750
|
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
var setCurrentUser = React.useCallback(function (callbackOrUser) {
|
|
4606
|
-
var callback = callbackOrUser;
|
|
4751
|
+
return;
|
|
4752
|
+
} // We set the mainpointer
|
|
4607
4753
|
|
|
4608
|
-
if (_typeof(callbackOrUser) === "object") {
|
|
4609
|
-
callback = function callback() {
|
|
4610
|
-
return callbackOrUser;
|
|
4611
|
-
};
|
|
4612
|
-
}
|
|
4613
|
-
|
|
4614
|
-
setCurrentUserState(function (prevUser) {
|
|
4615
|
-
var newUser = _objectSpread2(_objectSpread2({}, callback(prevUser)), {}, {
|
|
4616
|
-
id: prevUser.id,
|
|
4617
|
-
uid: prevUser.uid
|
|
4618
|
-
});
|
|
4619
|
-
|
|
4620
|
-
persistUser(newUser);
|
|
4621
|
-
return newUser;
|
|
4622
|
-
});
|
|
4623
|
-
}, [setCurrentUserState]);
|
|
4624
|
-
React.useEffect(function () {
|
|
4625
|
-
// eslint-disable-next-line no-console
|
|
4626
|
-
console.debug("Curent user is in space ".concat(currentUser.space));
|
|
4627
|
-
}, [currentUser.space]);
|
|
4628
|
-
return {
|
|
4629
|
-
currentUser: currentUser,
|
|
4630
|
-
setCurrentUser: setCurrentUser,
|
|
4631
|
-
users: users,
|
|
4632
|
-
localUsers: localUsers
|
|
4633
|
-
};
|
|
4634
|
-
};
|
|
4635
4754
|
|
|
4636
|
-
|
|
4637
|
-
var usersRef = React.useRef([]);
|
|
4638
|
-
var setUsers = useSetRecoilState(usersAtom);
|
|
4639
|
-
|
|
4640
|
-
var _useRecoilState = useRecoilState(userAtom),
|
|
4641
|
-
_useRecoilState2 = _slicedToArray(_useRecoilState, 2),
|
|
4642
|
-
currentUser = _useRecoilState2[0],
|
|
4643
|
-
setCurrentUserState = _useRecoilState2[1];
|
|
4755
|
+
stateRef.current.mainPointer = pointerId; // And prepare move
|
|
4644
4756
|
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4757
|
+
Object.assign(stateRef.current, {
|
|
4758
|
+
pressed: true,
|
|
4759
|
+
moving: false,
|
|
4760
|
+
gestureStart: false,
|
|
4761
|
+
startX: clientX,
|
|
4762
|
+
startY: clientY,
|
|
4763
|
+
prevX: clientX,
|
|
4764
|
+
prevY: clientY,
|
|
4765
|
+
currentButton: button,
|
|
4766
|
+
target: target,
|
|
4767
|
+
timeStart: Date.now(),
|
|
4768
|
+
longTapTimeout: setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
4769
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
4770
|
+
while (1) {
|
|
4771
|
+
switch (_context3.prev = _context3.next) {
|
|
4772
|
+
case 0:
|
|
4773
|
+
stateRef.current.noTap = true;
|
|
4774
|
+
queue(onLongTap, {
|
|
4775
|
+
clientX: clientX,
|
|
4776
|
+
clientY: clientY,
|
|
4777
|
+
altKey: altKey,
|
|
4778
|
+
ctrlKey: ctrlKey,
|
|
4779
|
+
metaKey: metaKey,
|
|
4780
|
+
target: target
|
|
4781
|
+
});
|
|
4649
4782
|
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4783
|
+
case 2:
|
|
4784
|
+
case "end":
|
|
4785
|
+
return _context3.stop();
|
|
4786
|
+
}
|
|
4787
|
+
}
|
|
4788
|
+
}, _callee3);
|
|
4789
|
+
})), 750)
|
|
4656
4790
|
});
|
|
4657
|
-
return function () {
|
|
4658
|
-
setCurrentUserState(function (prevUser) {
|
|
4659
|
-
return _objectSpread2(_objectSpread2({}, prevUser), {}, {
|
|
4660
|
-
id: wire.userId,
|
|
4661
|
-
space: null
|
|
4662
|
-
});
|
|
4663
|
-
});
|
|
4664
|
-
};
|
|
4665
|
-
}, [wire.userId, roomSpace, setCurrentUserState]);
|
|
4666
|
-
React.useEffect(function () {
|
|
4667
|
-
if (!isMaster) {
|
|
4668
|
-
var onGetUserList = function onGetUserList(userList) {
|
|
4669
|
-
usersRef.current = userList;
|
|
4670
|
-
setUsers(userList);
|
|
4671
|
-
};
|
|
4672
|
-
|
|
4673
|
-
wire.call("getUserList").then(onGetUserList, function () {
|
|
4674
|
-
// retry later
|
|
4675
|
-
setTimeout(function () {
|
|
4676
|
-
wire.call("getUserList") // eslint-disable-next-line no-console
|
|
4677
|
-
.then(onGetUserList, function (error) {
|
|
4678
|
-
return console.log(error);
|
|
4679
|
-
});
|
|
4680
|
-
}, 1000);
|
|
4681
|
-
});
|
|
4682
|
-
}
|
|
4683
|
-
}, [wire, isMaster, setUsers]); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4684
|
-
|
|
4685
|
-
var debouncedEmitUpdateUser = useDebouncedCallback(function (newUser) {
|
|
4686
|
-
wire.publish("userUpdate", newUser, true);
|
|
4687
|
-
}, [wire], 500);
|
|
4688
|
-
React.useEffect(function () {
|
|
4689
|
-
if (currentUser && currentUser.id) {
|
|
4690
|
-
debouncedEmitUpdateUser(currentUser);
|
|
4691
|
-
}
|
|
4692
|
-
}, [currentUser, debouncedEmitUpdateUser]);
|
|
4693
|
-
React.useEffect(function () {
|
|
4694
|
-
var unsub = [];
|
|
4695
|
-
|
|
4696
|
-
if (isMaster) {
|
|
4697
|
-
wire.register("getUserList", function () {
|
|
4698
|
-
return usersRef.current;
|
|
4699
|
-
}).then(function (unregister) {
|
|
4700
|
-
unsub.push(unregister);
|
|
4701
|
-
});
|
|
4702
|
-
unsub.push(wire.subscribe("userUpdate", function (user) {
|
|
4703
|
-
if (usersRef.current.find(function (u) {
|
|
4704
|
-
return u.id === user.id;
|
|
4705
|
-
})) {
|
|
4706
|
-
var newUsers = usersRef.current.map(function (u) {
|
|
4707
|
-
return u.id === user.id ? user : u;
|
|
4708
|
-
});
|
|
4709
|
-
usersRef.current = newUsers;
|
|
4710
|
-
} else {
|
|
4711
|
-
var _newUsers = [].concat(_toConsumableArray(usersRef.current), [user]);
|
|
4712
|
-
|
|
4713
|
-
usersRef.current = _newUsers;
|
|
4714
|
-
}
|
|
4715
4791
|
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4792
|
+
try {
|
|
4793
|
+
target.setPointerCapture(pointerId);
|
|
4794
|
+
} catch (e) {
|
|
4795
|
+
// eslint-disable-next-line no-console
|
|
4796
|
+
console.log("Fail to capture pointer", e);
|
|
4719
4797
|
}
|
|
4798
|
+
}, [onLongTap, queue]);
|
|
4799
|
+
var onPointerMove = React__default.useCallback(function (e) {
|
|
4800
|
+
if (stateRef.current.pressed) {
|
|
4801
|
+
var pointerId = e.pointerId,
|
|
4802
|
+
eventClientX = e.clientX,
|
|
4803
|
+
eventClientY = e.clientY,
|
|
4804
|
+
altKey = e.altKey,
|
|
4805
|
+
ctrlKey = e.ctrlKey,
|
|
4806
|
+
metaKey = e.metaKey,
|
|
4807
|
+
pointerType = e.pointerType;
|
|
4720
4808
|
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
if (isMaster) {
|
|
4729
|
-
wire.publish("updateUserList", usersRef.current);
|
|
4809
|
+
if (stateRef.current.mainPointer !== pointerId) {
|
|
4810
|
+
// Event from other pointer
|
|
4811
|
+
stateRef.current.pointers[pointerId] = {
|
|
4812
|
+
clientX: eventClientX,
|
|
4813
|
+
clientY: eventClientY
|
|
4814
|
+
};
|
|
4815
|
+
return;
|
|
4730
4816
|
}
|
|
4731
|
-
}));
|
|
4732
|
-
unsub.push(wire.subscribe("updateUserList", function (newList) {
|
|
4733
|
-
usersRef.current = newList;
|
|
4734
|
-
setUsers(usersRef.current);
|
|
4735
|
-
}));
|
|
4736
|
-
return function () {
|
|
4737
|
-
unsub.forEach(function (u) {
|
|
4738
|
-
return u();
|
|
4739
|
-
});
|
|
4740
|
-
};
|
|
4741
|
-
}, [wire, isMaster, setUsers]);
|
|
4742
|
-
return null;
|
|
4743
|
-
};
|
|
4744
4817
|
|
|
4745
|
-
|
|
4818
|
+
stateRef.current.moving = true; // Do we have two fingers ?
|
|
4746
4819
|
|
|
4747
|
-
var
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
setUnlock = _React$useState2[1];
|
|
4820
|
+
var twoFingers = Object.keys(stateRef.current.pointers).length === 2;
|
|
4821
|
+
var clientX;
|
|
4822
|
+
var clientY;
|
|
4823
|
+
var distance;
|
|
4752
4824
|
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
};
|
|
4825
|
+
if (twoFingers) {
|
|
4826
|
+
// Find other pointerId
|
|
4827
|
+
var _otherPointer2 = otherPointer(stateRef.current.pointers, pointerId),
|
|
4828
|
+
clientX2 = _otherPointer2.clientX,
|
|
4829
|
+
clientY2 = _otherPointer2.clientY; // Update client X with the center of each touch
|
|
4759
4830
|
|
|
4760
|
-
var onKeyUp = function onKeyUp(e) {
|
|
4761
|
-
if (e.key === "u" || e.key === "l") {
|
|
4762
|
-
setUnlock(false);
|
|
4763
|
-
}
|
|
4764
|
-
};
|
|
4765
4831
|
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4832
|
+
clientX = (clientX2 + eventClientX) / 2;
|
|
4833
|
+
clientY = (clientY2 + eventClientY) / 2;
|
|
4834
|
+
distance = computeDistance([clientX2, clientY2], [eventClientX, eventClientY]);
|
|
4835
|
+
} else {
|
|
4836
|
+
clientX = eventClientX;
|
|
4837
|
+
clientY = eventClientY;
|
|
4838
|
+
} // We drag if
|
|
4839
|
+
// On non touch device
|
|
4840
|
+
// - Button is 0
|
|
4841
|
+
// - Alt key is no pressed
|
|
4842
|
+
// or on touch devices
|
|
4843
|
+
// - We use only one finger
|
|
4775
4844
|
|
|
4776
|
-
var ItemList = function ItemList(_ref) {
|
|
4777
|
-
var itemTemplates = _ref.itemTemplates;
|
|
4778
4845
|
|
|
4779
|
-
|
|
4780
|
-
updateItem = _useItemActions.updateItem;
|
|
4846
|
+
var shouldDrag = pointerType !== "touch" ? stateRef.current.currentButton === 0 && !altKey : !twoFingers;
|
|
4781
4847
|
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4848
|
+
if (shouldDrag) {
|
|
4849
|
+
// Send drag start on first move
|
|
4850
|
+
if (!stateRef.current.gestureStart) {
|
|
4851
|
+
wrapperRef.current.style.cursor = "move";
|
|
4852
|
+
stateRef.current.gestureStart = true; // Clear tap timeout
|
|
4785
4853
|
|
|
4786
|
-
|
|
4787
|
-
|
|
4854
|
+
clearTimeout(stateRef.current.longTapTimeout);
|
|
4855
|
+
queue(onDragStart, {
|
|
4856
|
+
deltaX: 0,
|
|
4857
|
+
deltaY: 0,
|
|
4858
|
+
startX: stateRef.current.startX,
|
|
4859
|
+
startY: stateRef.current.startY,
|
|
4860
|
+
clientX: stateRef.current.startX,
|
|
4861
|
+
clientY: stateRef.current.startY,
|
|
4862
|
+
distanceX: 0,
|
|
4863
|
+
distanceY: 0,
|
|
4864
|
+
button: stateRef.current.currentButton,
|
|
4865
|
+
altKey: altKey,
|
|
4866
|
+
ctrlKey: ctrlKey,
|
|
4867
|
+
metaKey: metaKey,
|
|
4868
|
+
target: stateRef.current.target,
|
|
4869
|
+
event: e
|
|
4870
|
+
});
|
|
4871
|
+
} // Create closure
|
|
4788
4872
|
|
|
4789
|
-
var _useUsers = useUsers(),
|
|
4790
|
-
currentUser = _useUsers.currentUser;
|
|
4791
4873
|
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
state: itemMap[itemId],
|
|
4797
|
-
setState: updateItem,
|
|
4798
|
-
isSelected: selectedItems.includes(itemId),
|
|
4799
|
-
unlocked: unlocked,
|
|
4800
|
-
itemMap: itemTemplates,
|
|
4801
|
-
boardSize: boardSize,
|
|
4802
|
-
currentUser: currentUser
|
|
4803
|
-
});
|
|
4804
|
-
});
|
|
4805
|
-
};
|
|
4874
|
+
var deltaX = clientX - stateRef.current.prevX;
|
|
4875
|
+
var deltaY = clientY - stateRef.current.prevY;
|
|
4876
|
+
var distanceX = clientX - stateRef.current.startX;
|
|
4877
|
+
var distanceY = clientY - stateRef.current.startY; // Drag event
|
|
4806
4878
|
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
});
|
|
4828
|
-
return unsub;
|
|
4829
|
-
}, [wire, batchUpdate]);
|
|
4830
|
-
React.useEffect(function () {
|
|
4831
|
-
var unsub = wire.subscribe("selectedItemsMove", function (_ref) {
|
|
4832
|
-
var itemIds = _ref.itemIds,
|
|
4833
|
-
posDelta = _ref.posDelta;
|
|
4834
|
-
moveItems(itemIds, posDelta, false);
|
|
4835
|
-
});
|
|
4836
|
-
return unsub;
|
|
4837
|
-
}, [wire, moveItems]);
|
|
4838
|
-
React.useEffect(function () {
|
|
4839
|
-
var unsub = wire.subscribe("updateItemListOrder", function (itemIds) {
|
|
4840
|
-
updateItemOrder(itemIds, false);
|
|
4841
|
-
});
|
|
4842
|
-
return unsub;
|
|
4843
|
-
}, [wire, updateItemOrder]);
|
|
4844
|
-
React.useEffect(function () {
|
|
4845
|
-
var unsub = wire.subscribe("pushItem", function (newItem) {
|
|
4846
|
-
pushItem(newItem, null, false);
|
|
4847
|
-
});
|
|
4848
|
-
return unsub;
|
|
4849
|
-
}, [wire, pushItem]);
|
|
4850
|
-
React.useEffect(function () {
|
|
4851
|
-
var unsub = wire.subscribe("insertItemBefore", function (_ref2) {
|
|
4852
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
4853
|
-
newItem = _ref3[0],
|
|
4854
|
-
beforeId = _ref3[1];
|
|
4855
|
-
|
|
4856
|
-
pushItem(newItem, beforeId, false);
|
|
4857
|
-
});
|
|
4858
|
-
return unsub;
|
|
4859
|
-
}, [wire, pushItem]);
|
|
4860
|
-
React.useEffect(function () {
|
|
4861
|
-
var unsub = wire.subscribe("removeItems", function (itemIds) {
|
|
4862
|
-
removeItems(itemIds, false);
|
|
4863
|
-
});
|
|
4864
|
-
return unsub;
|
|
4865
|
-
}, [wire, removeItems]);
|
|
4866
|
-
return null;
|
|
4867
|
-
};
|
|
4879
|
+
queue(onDrag, {
|
|
4880
|
+
deltaX: deltaX,
|
|
4881
|
+
deltaY: deltaY,
|
|
4882
|
+
startX: stateRef.current.startX,
|
|
4883
|
+
startY: stateRef.current.startY,
|
|
4884
|
+
clientX: clientX,
|
|
4885
|
+
clientY: clientY,
|
|
4886
|
+
distanceX: distanceX,
|
|
4887
|
+
distanceY: distanceY,
|
|
4888
|
+
button: stateRef.current.currentButton,
|
|
4889
|
+
altKey: altKey,
|
|
4890
|
+
ctrlKey: ctrlKey,
|
|
4891
|
+
metaKey: metaKey,
|
|
4892
|
+
target: stateRef.current.target,
|
|
4893
|
+
event: e
|
|
4894
|
+
});
|
|
4895
|
+
} else {
|
|
4896
|
+
if (!stateRef.current.gestureStart) {
|
|
4897
|
+
wrapperRef.current.style.cursor = "move";
|
|
4898
|
+
stateRef.current.gestureStart = true; // Clear tap timeout on first move
|
|
4868
4899
|
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
* @param {DOMElement} element
|
|
4872
|
-
* @param {string} className
|
|
4873
|
-
*/
|
|
4874
|
-
var hasClass = function hasClass(element, className) {
|
|
4875
|
-
return element.classList && element.classList.contains(className);
|
|
4876
|
-
};
|
|
4877
|
-
var insideClass = function insideClass(element, className) {
|
|
4878
|
-
if (hasClass(element, className)) {
|
|
4879
|
-
return element;
|
|
4880
|
-
}
|
|
4900
|
+
clearTimeout(stateRef.current.longTapTimeout);
|
|
4901
|
+
} // Create closure
|
|
4881
4902
|
|
|
4882
|
-
if (!element.parentNode) {
|
|
4883
|
-
return false;
|
|
4884
|
-
}
|
|
4885
4903
|
|
|
4886
|
-
|
|
4887
|
-
};
|
|
4888
|
-
var isPointInsideRect = function isPointInsideRect(point, rect) {
|
|
4889
|
-
return point.x > rect.left && point.x < rect.left + rect.width && point.y > rect.top && point.y < rect.top + rect.height;
|
|
4890
|
-
};
|
|
4891
|
-
var isItemInsideElement = function isItemInsideElement(itemElement, otherElem) {
|
|
4892
|
-
var rect = otherElem.getBoundingClientRect();
|
|
4893
|
-
var fourElem = Array.from(itemElement.querySelectorAll(".corner"));
|
|
4894
|
-
return fourElem.every(function (corner) {
|
|
4895
|
-
var _corner$getBoundingCl = corner.getBoundingClientRect(),
|
|
4896
|
-
y = _corner$getBoundingCl.top,
|
|
4897
|
-
x = _corner$getBoundingCl.left;
|
|
4904
|
+
var _deltaX = clientX - stateRef.current.prevX;
|
|
4898
4905
|
|
|
4899
|
-
|
|
4900
|
-
x: x,
|
|
4901
|
-
y: y
|
|
4902
|
-
}, rect);
|
|
4903
|
-
});
|
|
4904
|
-
};
|
|
4905
|
-
var getItemElem = function getItemElem(wrapper, itemId) {
|
|
4906
|
-
var elems = wrapper.getElementsByClassName("item ".concat(itemId));
|
|
4907
|
-
var elem = elems[0];
|
|
4906
|
+
var _deltaY = clientY - stateRef.current.prevY;
|
|
4908
4907
|
|
|
4909
|
-
|
|
4910
|
-
// eslint-disable-next-line no-console
|
|
4911
|
-
console.error("Missing item ".concat(itemId));
|
|
4912
|
-
}
|
|
4908
|
+
var target = stateRef.current.target; // Pan event
|
|
4913
4909
|
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4910
|
+
queue(onPan, {
|
|
4911
|
+
deltaX: _deltaX,
|
|
4912
|
+
deltaY: _deltaY,
|
|
4913
|
+
button: stateRef.current.currentButton,
|
|
4914
|
+
altKey: altKey,
|
|
4915
|
+
ctrlKey: ctrlKey,
|
|
4916
|
+
metaKey: metaKey,
|
|
4917
|
+
target: target,
|
|
4918
|
+
event: e
|
|
4919
|
+
});
|
|
4918
4920
|
|
|
4919
|
-
|
|
4921
|
+
if (twoFingers && distance !== stateRef.current.prevDistance && onZoom) {
|
|
4922
|
+
var scale = stateRef.current.prevDistance - distance;
|
|
4920
4923
|
|
|
4921
|
-
|
|
4922
|
-
|
|
4924
|
+
if (Math.abs(scale) > 0) {
|
|
4925
|
+
queue(onZoom, {
|
|
4926
|
+
scale: scale,
|
|
4927
|
+
clientX: clientX,
|
|
4928
|
+
clientY: clientY,
|
|
4929
|
+
event: e
|
|
4930
|
+
});
|
|
4931
|
+
stateRef.current.prevDistance = distance;
|
|
4932
|
+
}
|
|
4933
|
+
}
|
|
4934
|
+
}
|
|
4923
4935
|
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4936
|
+
stateRef.current.prevX = clientX;
|
|
4937
|
+
stateRef.current.prevY = clientY;
|
|
4938
|
+
}
|
|
4939
|
+
}, [onDrag, onDragStart, onPan, onZoom, queue]);
|
|
4940
|
+
var onPointerUp = React__default.useCallback(function (e) {
|
|
4941
|
+
var clientX = e.clientX,
|
|
4942
|
+
clientY = e.clientY,
|
|
4943
|
+
altKey = e.altKey,
|
|
4944
|
+
ctrlKey = e.ctrlKey,
|
|
4945
|
+
metaKey = e.metaKey,
|
|
4946
|
+
target = e.target,
|
|
4947
|
+
pointerId = e.pointerId;
|
|
4927
4948
|
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
var elem = getItemElem(wrapper, itemId);
|
|
4934
|
-
if (!elem) return null;
|
|
4949
|
+
if (!stateRef.current.pointers[pointerId]) {
|
|
4950
|
+
// Pointer already gone previously with another event
|
|
4951
|
+
// ignoring it
|
|
4952
|
+
return;
|
|
4953
|
+
} // Remove pointer from map
|
|
4935
4954
|
|
|
4936
|
-
var _elem$getBoundingClie = elem.getBoundingClientRect(),
|
|
4937
|
-
left = _elem$getBoundingClie.left,
|
|
4938
|
-
right = _elem$getBoundingClie.right,
|
|
4939
|
-
top = _elem$getBoundingClie.top,
|
|
4940
|
-
bottom = _elem$getBoundingClie.bottom;
|
|
4941
4955
|
|
|
4942
|
-
|
|
4956
|
+
delete stateRef.current.pointers[pointerId];
|
|
4943
4957
|
|
|
4944
|
-
if (
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
top: top,
|
|
4948
|
-
right: right,
|
|
4949
|
-
bottom: bottom
|
|
4950
|
-
};
|
|
4951
|
-
} else {
|
|
4952
|
-
boundingBox = prev;
|
|
4958
|
+
if (stateRef.current.mainPointer !== pointerId) {
|
|
4959
|
+
// If this is not the main pointer we quit here
|
|
4960
|
+
return;
|
|
4953
4961
|
}
|
|
4954
4962
|
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
boundingBox.bottom = Math.max(bottom, boundingBox.bottom);
|
|
4959
|
-
return boundingBox;
|
|
4960
|
-
}, null);
|
|
4963
|
+
while (Object.keys(stateRef.current.pointers).length > 0) {
|
|
4964
|
+
// If was main pointer but we have another one, this one become main
|
|
4965
|
+
stateRef.current.mainPointer = Number(Object.keys(stateRef.current.pointers)[0]);
|
|
4961
4966
|
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4967
|
+
try {
|
|
4968
|
+
stateRef.current.target.setPointerCapture(stateRef.current.mainPointer);
|
|
4969
|
+
return;
|
|
4970
|
+
} catch (error) {
|
|
4971
|
+
// eslint-disable-next-line no-console
|
|
4972
|
+
console.log("Fails to set pointer capture", error);
|
|
4973
|
+
stateRef.current.mainPointer = undefined;
|
|
4974
|
+
delete stateRef.current.pointers[Object.keys(stateRef.current.pointers)[0]];
|
|
4975
|
+
}
|
|
4976
|
+
}
|
|
4965
4977
|
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
return result;
|
|
4969
|
-
};
|
|
4978
|
+
stateRef.current.mainPointer = undefined;
|
|
4979
|
+
stateRef.current.pressed = false; // Clear longTap
|
|
4970
4980
|
|
|
4971
|
-
|
|
4972
|
-
var userAgent = navigator.userAgent.toLowerCase();
|
|
4973
|
-
return /mac os ?x 10/.test(userAgent);
|
|
4974
|
-
}; // From https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
|
|
4981
|
+
clearTimeout(stateRef.current.longTapTimeout);
|
|
4975
4982
|
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4983
|
+
if (stateRef.current.moving) {
|
|
4984
|
+
// If we were moving, send drag end event
|
|
4985
|
+
stateRef.current.moving = false;
|
|
4986
|
+
queue(onDragEnd, {
|
|
4987
|
+
deltaX: clientX - stateRef.current.prevX,
|
|
4988
|
+
deltaY: clientY - stateRef.current.prevY,
|
|
4989
|
+
startX: stateRef.current.startX,
|
|
4990
|
+
startY: stateRef.current.startY,
|
|
4991
|
+
clientX: clientX,
|
|
4992
|
+
clientY: clientY,
|
|
4993
|
+
distanceX: clientX - stateRef.current.startX,
|
|
4994
|
+
distanceY: clientY - stateRef.current.startY,
|
|
4995
|
+
button: stateRef.current.currentButton,
|
|
4996
|
+
altKey: altKey,
|
|
4997
|
+
ctrlKey: ctrlKey,
|
|
4998
|
+
metaKey: metaKey,
|
|
4999
|
+
event: e
|
|
5000
|
+
});
|
|
5001
|
+
wrapperRef.current.style.cursor = "auto";
|
|
5002
|
+
} else {
|
|
5003
|
+
var now = Date.now();
|
|
4980
5004
|
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
5005
|
+
if (stateRef.current.noTap) {
|
|
5006
|
+
stateRef.current.noTap = false;
|
|
5007
|
+
} // Send tap event only if time less than 300ms
|
|
5008
|
+
else if (stateRef.current.timeStart - now < 300) {
|
|
5009
|
+
queue(onTap, {
|
|
5010
|
+
clientX: clientX,
|
|
5011
|
+
clientY: clientY,
|
|
5012
|
+
altKey: altKey,
|
|
5013
|
+
ctrlKey: ctrlKey,
|
|
5014
|
+
metaKey: metaKey,
|
|
5015
|
+
target: target
|
|
5016
|
+
});
|
|
5017
|
+
}
|
|
5018
|
+
}
|
|
5019
|
+
}, [onDragEnd, onTap, queue]);
|
|
5020
|
+
var onDoubleTapHandler = React__default.useCallback(function (event) {
|
|
5021
|
+
queue(onDoubleTap, event);
|
|
5022
|
+
}, [onDoubleTap, queue]);
|
|
5023
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
5024
|
+
onWheel: onWheel,
|
|
5025
|
+
onPointerDown: onPointerDown,
|
|
5026
|
+
onPointerMove: onPointerMove,
|
|
5027
|
+
onPointerUp: onPointerUp,
|
|
5028
|
+
onPointerOut: onPointerUp,
|
|
5029
|
+
onPointerLeave: onPointerUp,
|
|
5030
|
+
onPointerCancel: onPointerUp,
|
|
5031
|
+
onDoubleClick: onDoubleTapHandler,
|
|
5032
|
+
style: {
|
|
5033
|
+
touchAction: "none"
|
|
5034
|
+
},
|
|
5035
|
+
ref: wrapperRef
|
|
5036
|
+
}, children);
|
|
4988
5037
|
};
|
|
4989
5038
|
|
|
4990
|
-
var
|
|
5039
|
+
var _excluded$3 = ["onResize"];
|
|
4991
5040
|
|
|
4992
|
-
var
|
|
5041
|
+
var ResizeHandler = function ResizeHandler(_ref) {
|
|
5042
|
+
var onResize = _ref.onResize,
|
|
5043
|
+
rest = _objectWithoutProperties(_ref, _excluded$3);
|
|
4993
5044
|
|
|
4994
|
-
var
|
|
4995
|
-
|
|
4996
|
-
return
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
});
|
|
5000
|
-
return pointers[p2];
|
|
5001
|
-
};
|
|
5045
|
+
var onDrag = useRecoilCallback(function (_ref2) {
|
|
5046
|
+
var snapshot = _ref2.snapshot;
|
|
5047
|
+
return /*#__PURE__*/function () {
|
|
5048
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref3) {
|
|
5049
|
+
var deltaX, deltaY, event, _yield$snapshot$getPr, scale;
|
|
5002
5050
|
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5051
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
5052
|
+
while (1) {
|
|
5053
|
+
switch (_context.prev = _context.next) {
|
|
5054
|
+
case 0:
|
|
5055
|
+
deltaX = _ref3.deltaX, deltaY = _ref3.deltaY, event = _ref3.event;
|
|
5056
|
+
event.stopPropagation();
|
|
5057
|
+
_context.next = 4;
|
|
5058
|
+
return snapshot.getPromise(BoardTransformAtom);
|
|
5007
5059
|
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5060
|
+
case 4:
|
|
5061
|
+
_yield$snapshot$getPr = _context.sent;
|
|
5062
|
+
scale = _yield$snapshot$getPr.scale;
|
|
5063
|
+
onResize({
|
|
5064
|
+
width: deltaX / scale,
|
|
5065
|
+
height: deltaY / scale
|
|
5066
|
+
});
|
|
5011
5067
|
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5068
|
+
case 7:
|
|
5069
|
+
case "end":
|
|
5070
|
+
return _context.stop();
|
|
5071
|
+
}
|
|
5072
|
+
}
|
|
5073
|
+
}, _callee);
|
|
5074
|
+
}));
|
|
5075
|
+
|
|
5076
|
+
return function (_x) {
|
|
5077
|
+
return _ref4.apply(this, arguments);
|
|
5078
|
+
};
|
|
5079
|
+
}();
|
|
5080
|
+
}, [onResize]);
|
|
5081
|
+
return /*#__PURE__*/React__default.createElement(Gesture, {
|
|
5082
|
+
onDrag: onDrag
|
|
5083
|
+
}, /*#__PURE__*/React__default.createElement("div", rest));
|
|
5015
5084
|
};
|
|
5016
5085
|
|
|
5017
|
-
var
|
|
5086
|
+
var img = "data:image/svg+xml,%3c%3fxml version='1.0' encoding='UTF-8' standalone='no'%3f%3e%3csvg xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:cc='http://creativecommons.org/ns%23' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns%23' xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' xmlns:sodipodi='http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd' xmlns:inkscape='http://www.inkscape.org/namespaces/inkscape' version='1.1' x='0px' y='0px' viewBox='0 0 75.601318 94.9' xml:space='preserve' id='svg26' sodipodi:docname='lock.svg' width='75.601318' height='94.900002' inkscape:version='0.92.5 (2060ec1f9f%2c 2020-04-08)'%3e%3cmetadata id='metadata32'%3e%3crdf:RDF%3e%3ccc:Work rdf:about=''%3e%3cdc:format%3eimage/svg%2bxml%3c/dc:format%3e%3cdc:type rdf:resource='http://purl.org/dc/dcmitype/StillImage' /%3e%3cdc:title%3e%3c/dc:title%3e%3c/cc:Work%3e%3c/rdf:RDF%3e%3c/metadata%3e%3cdefs id='defs30' /%3e%3csodipodi:namedview pagecolor='black' bordercolor='%23666666' borderopacity='1' objecttolerance='10' gridtolerance='10' guidetolerance='10' inkscape:pageopacity='0' inkscape:pageshadow='2' inkscape:window-width='1848' inkscape:window-height='1016' id='namedview28' showgrid='false' fit-margin-top='0' fit-margin-left='0' fit-margin-right='0' fit-margin-bottom='0' inkscape:zoom='5.3400704' inkscape:cx='3.2640013' inkscape:cy='45.072152' inkscape:window-x='1512' inkscape:window-y='27' inkscape:window-maximized='1' inkscape:current-layer='g16' /%3e%3cg id='g16' transform='translate(-12.2%2c-2.5)'%3e%3cpath d='M 75.4%2c36.8 H 34.1 V 24.6 c 0%2c-8.8 7.1%2c-15.9 15.9%2c-15.9 8.8%2c0 15.9%2c7.1 15.9%2c15.9 0%2c1.7 1.4%2c3.1 3.1%2c3.1 1.7%2c0 3.1%2c-1.4 3.1%2c-3.1 C 72.1%2c12.4 62.2%2c2.5 50%2c2.5 37.8%2c2.5 27.9%2c12.4 27.9%2c24.6 v 12.2 h -3.3 c -6.9%2c0 -12.4%2c5.6 -12.4%2c12.4 V 85 c 0%2c6.9 5.6%2c12.4 12.4%2c12.4 h 50.8 c 6.9%2c0 12.4%2c-5.6 12.4%2c-12.4 V 49.2 C 87.9%2c42.3 82.3%2c36.8 75.4%2c36.8 Z m 6.2%2c48.3 c 0%2c3.4 -2.8%2c6.2 -6.2%2c6.2 H 24.6 c -3.4%2c0 -6.2%2c-2.8 -6.2%2c-6.2 V 49.2 c 0%2c-3.4 2.8%2c-6.2 6.2%2c-6.2 h 50.8 c 3.4%2c0 6.2%2c2.8 6.2%2c6.2 z' id='path12' inkscape:connector-curvature='0' style='fill:white%3bfill-opacity:1' /%3e%3cpath d='m 59.8%2c57.6 -12.5%2c12.5 -7%2c-7 c -1.2%2c-1.2 -3.2%2c-1.2 -4.4%2c0 -1.2%2c1.2 -1.2%2c3.2 0%2c4.4 l 9.2%2c9.2 c 0.6%2c0.6 1.4%2c0.9 2.2%2c0.9 0.8%2c0 1.6%2c-0.3 2.2%2c-0.9 L 64.2%2c62 c 1.2%2c-1.2 1.2%2c-3.2 0%2c-4.4 -1.2%2c-1.2 -3.2%2c-1.2 -4.4%2c0 z' id='path14' inkscape:connector-curvature='0' style='fill:white%3bfill-opacity:1' /%3e%3c/g%3e%3c/svg%3e";
|
|
5018
5087
|
|
|
5019
|
-
var
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
5023
|
-
while (1) {
|
|
5024
|
-
switch (_context.prev = _context.next) {
|
|
5025
|
-
case 0:
|
|
5026
|
-
_context.prev = 0;
|
|
5027
|
-
_context.next = 3;
|
|
5028
|
-
return fn.apply(void 0, _args);
|
|
5088
|
+
var _excluded$2 = ["type", "rotation", "id", "locked", "layer"],
|
|
5089
|
+
_excluded2 = ["state", "boardSize", "currentUser"],
|
|
5090
|
+
_excluded3 = ["x", "y", "layer", "moving"];
|
|
5029
5091
|
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5092
|
+
var _templateObject$2;
|
|
5093
|
+
var ItemWrapper = newStyled.div(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral(["\n display: inline-block;\n transition: transform 150ms;\n user-select: none;\n padding: 2px;\n box-sizing: border-box;\n transform: rotate(", "deg);\n\n & .corner {\n position: absolute;\n width: 0px;\n height: 0px;\n }\n\n & .top-left {\n top: 0;\n left: 0;\n }\n & .top-right {\n top: 0;\n right: 0;\n }\n & .bottom-left {\n bottom: 0;\n left: 0;\n }\n & .bottom-right {\n bottom: 0;\n right: 0;\n }\n\n &.selected {\n border: 2px dashed #db5034;\n padding: 0px;\n cursor: pointer;\n }\n\n &.locked::after {\n content: \"\";\n position: absolute;\n width: 24px;\n height: 30px;\n top: 4px;\n right: 4px;\n opacity: 0.1;\n background-image: url(\"", "\");\n background-size: cover;\n user-select: none;\n }\n\n &.locked:hover::after {\n opacity: 0.3;\n }\n\n & .resize {\n position: absolute;\n\n width: 10px;\n height: 10px;\n border: 2px solid #db5034;\n background-color: #db5034;\n cursor: move;\n\n &.resize-width {\n cursor: ew-resize;\n right: -6px;\n top: calc(50% - 5px);\n }\n &.resize-height {\n cursor: ns-resize;\n bottom: -6px;\n left: calc(50% - 5px);\n }\n &.resize-ratio {\n cursor: nwse-resize;\n bottom: -6px;\n right: -6px;\n }\n }\n"])), function (_ref) {
|
|
5094
|
+
var rotation = _ref.rotation;
|
|
5095
|
+
return rotation;
|
|
5096
|
+
}, img);
|
|
5033
5097
|
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
// eslint-disable-next-line no-console
|
|
5038
|
-
console.error(_context.t0);
|
|
5098
|
+
var identity = function identity(x) {
|
|
5099
|
+
return x;
|
|
5100
|
+
};
|
|
5039
5101
|
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5102
|
+
var DefaultErrorComponent = function DefaultErrorComponent(_ref2) {
|
|
5103
|
+
var onReload = _ref2.onReload;
|
|
5104
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
5105
|
+
style: {
|
|
5106
|
+
width: "100px",
|
|
5107
|
+
display: "flex",
|
|
5108
|
+
flexDirection: "column",
|
|
5109
|
+
justifyContent: "center",
|
|
5110
|
+
textAlign: "center",
|
|
5111
|
+
color: "red"
|
|
5112
|
+
},
|
|
5113
|
+
className: "syncboard-error-item"
|
|
5114
|
+
}, "Sorry, this item seems broken.", /*#__PURE__*/React__default.createElement("button", {
|
|
5115
|
+
onClick: onReload
|
|
5116
|
+
}, "Reload it"));
|
|
5047
5117
|
};
|
|
5118
|
+
/* Error boundary for broken item */
|
|
5048
5119
|
|
|
5049
|
-
var Gesture = function Gesture(_ref6) {
|
|
5050
|
-
var children = _ref6.children,
|
|
5051
|
-
_ref6$onDrag = _ref6.onDrag,
|
|
5052
|
-
onDrag = _ref6$onDrag === void 0 ? empty : _ref6$onDrag,
|
|
5053
|
-
_ref6$onDragStart = _ref6.onDragStart,
|
|
5054
|
-
onDragStart = _ref6$onDragStart === void 0 ? empty : _ref6$onDragStart,
|
|
5055
|
-
_ref6$onDragEnd = _ref6.onDragEnd,
|
|
5056
|
-
onDragEnd = _ref6$onDragEnd === void 0 ? empty : _ref6$onDragEnd,
|
|
5057
|
-
_ref6$onPan = _ref6.onPan,
|
|
5058
|
-
onPan = _ref6$onPan === void 0 ? empty : _ref6$onPan,
|
|
5059
|
-
_ref6$onTap = _ref6.onTap,
|
|
5060
|
-
onTap = _ref6$onTap === void 0 ? empty : _ref6$onTap,
|
|
5061
|
-
_ref6$onLongTap = _ref6.onLongTap,
|
|
5062
|
-
onLongTap = _ref6$onLongTap === void 0 ? empty : _ref6$onLongTap,
|
|
5063
|
-
_ref6$onDoubleTap = _ref6.onDoubleTap,
|
|
5064
|
-
onDoubleTap = _ref6$onDoubleTap === void 0 ? empty : _ref6$onDoubleTap,
|
|
5065
|
-
onZoom = _ref6.onZoom;
|
|
5066
|
-
var wrapperRef = React.useRef(null);
|
|
5067
|
-
var stateRef = React.useRef({
|
|
5068
|
-
moving: false,
|
|
5069
|
-
pointers: {},
|
|
5070
|
-
mainPointer: undefined
|
|
5071
|
-
});
|
|
5072
|
-
var queueRef = React.useRef([]); // Queue event to avoid async mess
|
|
5073
5120
|
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
5077
|
-
while (1) {
|
|
5078
|
-
switch (_context2.prev = _context2.next) {
|
|
5079
|
-
case 0:
|
|
5080
|
-
_context2.next = 2;
|
|
5081
|
-
return protect(callback)(args);
|
|
5121
|
+
var ItemErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
5122
|
+
_inherits(ItemErrorBoundary, _React$Component);
|
|
5082
5123
|
|
|
5083
|
-
|
|
5084
|
-
queueRef.current.shift();
|
|
5124
|
+
var _super = _createSuper(ItemErrorBoundary);
|
|
5085
5125
|
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
break;
|
|
5089
|
-
}
|
|
5126
|
+
function ItemErrorBoundary(props) {
|
|
5127
|
+
var _this;
|
|
5090
5128
|
|
|
5091
|
-
|
|
5092
|
-
return protect(queueRef.current[0])();
|
|
5129
|
+
_classCallCheck(this, ItemErrorBoundary);
|
|
5093
5130
|
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5131
|
+
_this = _super.call(this, props);
|
|
5132
|
+
_this.state = {
|
|
5133
|
+
hasError: false,
|
|
5134
|
+
itemId: props.itemId
|
|
5135
|
+
};
|
|
5136
|
+
_this.onReload = _this.onReload.bind(_assertThisInitialized(_this));
|
|
5137
|
+
return _this;
|
|
5138
|
+
}
|
|
5101
5139
|
|
|
5102
|
-
|
|
5103
|
-
|
|
5140
|
+
_createClass(ItemErrorBoundary, [{
|
|
5141
|
+
key: "componentDidCatch",
|
|
5142
|
+
value: function componentDidCatch(error) {
|
|
5143
|
+
// eslint-disable-next-line no-console
|
|
5144
|
+
console.error("Error for item ".concat(this.state.itemId), error, this.props.state);
|
|
5104
5145
|
}
|
|
5105
|
-
},
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
clientY = e.clientY,
|
|
5111
|
-
deltaMode = e.deltaMode,
|
|
5112
|
-
ctrlKey = e.ctrlKey,
|
|
5113
|
-
altKey = e.altKey,
|
|
5114
|
-
metaKey = e.metaKey,
|
|
5115
|
-
target = e.target; // On a MacOs trackpad, the pinch gesture sets the ctrlKey to true.
|
|
5116
|
-
// In that situation, we want to use the custom scaling, not the browser default zoom.
|
|
5117
|
-
// Hence in this situation we avoid to return immediately.
|
|
5118
|
-
|
|
5119
|
-
if (altKey || ctrlKey && !isMacOS()) {
|
|
5120
|
-
return;
|
|
5121
|
-
} // On a trackpad, the pinch and pan events are differentiated by the crtlKey value.
|
|
5122
|
-
// On a pinch gesture, the ctrlKey is set to true, so we want to have a scaling effect.
|
|
5123
|
-
// If we are only moving the fingers in the same direction, a pan is needed.
|
|
5124
|
-
// Ref: https://medium.com/@auchenberg/detecting-multi-touch-trackpad-gestures-in-javascript-a2505babb10e
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
if (isMacOS() && !ctrlKey) {
|
|
5128
|
-
queue(onPan, {
|
|
5129
|
-
deltaX: -2 * deltaX,
|
|
5130
|
-
deltaY: -2 * deltaY,
|
|
5131
|
-
button: 1,
|
|
5132
|
-
ctrlKey: ctrlKey,
|
|
5133
|
-
metaKey: metaKey,
|
|
5134
|
-
target: target,
|
|
5135
|
-
event: e
|
|
5146
|
+
}, {
|
|
5147
|
+
key: "onReload",
|
|
5148
|
+
value: function onReload() {
|
|
5149
|
+
this.setState({
|
|
5150
|
+
hasError: false
|
|
5136
5151
|
});
|
|
5137
|
-
}
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
switch (deltaMode) {
|
|
5143
|
-
case 1:
|
|
5144
|
-
// Pixel
|
|
5145
|
-
scale *= LINE_HEIGHT;
|
|
5146
|
-
break;
|
|
5147
|
-
|
|
5148
|
-
case 2:
|
|
5149
|
-
scale *= PAGE_HEIGHT;
|
|
5150
|
-
break;
|
|
5151
|
-
}
|
|
5152
|
+
}
|
|
5153
|
+
}, {
|
|
5154
|
+
key: "render",
|
|
5155
|
+
value: function render() {
|
|
5156
|
+
var ErrorComponent = this.props.ErrorComponent;
|
|
5152
5157
|
|
|
5153
|
-
if (
|
|
5154
|
-
|
|
5158
|
+
if (this.state.hasError) {
|
|
5159
|
+
return /*#__PURE__*/React__default.createElement(ErrorComponent, {
|
|
5160
|
+
onReload: this.onReload
|
|
5161
|
+
});
|
|
5155
5162
|
}
|
|
5156
5163
|
|
|
5157
|
-
|
|
5158
|
-
scale: scale,
|
|
5159
|
-
clientX: clientX,
|
|
5160
|
-
clientY: clientY,
|
|
5161
|
-
event: e
|
|
5162
|
-
});
|
|
5164
|
+
return this.props.children;
|
|
5163
5165
|
}
|
|
5164
|
-
}, [
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
pointerId = _ref8.pointerId,
|
|
5171
|
-
altKey = _ref8.altKey,
|
|
5172
|
-
ctrlKey = _ref8.ctrlKey,
|
|
5173
|
-
metaKey = _ref8.metaKey,
|
|
5174
|
-
isPrimary = _ref8.isPrimary;
|
|
5175
|
-
// Add pointer to map
|
|
5176
|
-
stateRef.current.pointers[pointerId] = {
|
|
5177
|
-
clientX: clientX,
|
|
5178
|
-
clientY: clientY
|
|
5179
|
-
};
|
|
5180
|
-
|
|
5181
|
-
if (isPrimary) {
|
|
5182
|
-
// Clean mainPoint on primary pointer
|
|
5183
|
-
stateRef.current.mainPointer = undefined;
|
|
5166
|
+
}], [{
|
|
5167
|
+
key: "getDerivedStateFromError",
|
|
5168
|
+
value: function getDerivedStateFromError() {
|
|
5169
|
+
return {
|
|
5170
|
+
hasError: true
|
|
5171
|
+
};
|
|
5184
5172
|
}
|
|
5173
|
+
}]);
|
|
5185
5174
|
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
// This is not the main pointer
|
|
5189
|
-
try {
|
|
5190
|
-
var _otherPointer = otherPointer(stateRef.current.pointers, pointerId),
|
|
5191
|
-
clientX2 = _otherPointer.clientX,
|
|
5192
|
-
clientY2 = _otherPointer.clientY;
|
|
5175
|
+
return ItemErrorBoundary;
|
|
5176
|
+
}(React__default.Component);
|
|
5193
5177
|
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5178
|
+
var removeClass = function removeClass(e) {
|
|
5179
|
+
e.target.className = "";
|
|
5180
|
+
};
|
|
5197
5181
|
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5182
|
+
var defaultResize = function defaultResize(_ref3) {
|
|
5183
|
+
var width = _ref3.width,
|
|
5184
|
+
height = _ref3.height,
|
|
5185
|
+
actualWidth = _ref3.actualWidth,
|
|
5186
|
+
actualHeight = _ref3.actualHeight,
|
|
5187
|
+
prevState = _ref3.prevState,
|
|
5188
|
+
keepRatio = _ref3.keepRatio;
|
|
5189
|
+
var currentWidth = prevState.width,
|
|
5190
|
+
currentHeight = prevState.height; // Parse text values if any
|
|
5191
|
+
|
|
5192
|
+
var _ref4 = [parseFloat(currentWidth), parseFloat(currentHeight)];
|
|
5193
|
+
currentWidth = _ref4[0];
|
|
5194
|
+
currentHeight = _ref4[1];
|
|
5195
|
+
|
|
5196
|
+
if (!currentWidth || Number.isNaN(Number(currentWidth))) {
|
|
5197
|
+
currentWidth = actualWidth;
|
|
5198
|
+
}
|
|
5212
5199
|
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5200
|
+
if (!currentHeight || Number.isNaN(Number(currentHeight))) {
|
|
5201
|
+
currentHeight = actualHeight;
|
|
5202
|
+
}
|
|
5216
5203
|
|
|
5217
|
-
|
|
5218
|
-
|
|
5204
|
+
if (keepRatio) {
|
|
5205
|
+
var ratio = currentWidth / currentHeight;
|
|
5206
|
+
return _objectSpread2(_objectSpread2({}, prevState), {}, {
|
|
5207
|
+
width: (currentWidth + width).toFixed(1),
|
|
5208
|
+
height: (currentHeight + height / ratio).toFixed(1)
|
|
5209
|
+
});
|
|
5210
|
+
}
|
|
5211
|
+
|
|
5212
|
+
return _objectSpread2(_objectSpread2({}, prevState), {}, {
|
|
5213
|
+
width: (currentWidth + width).toFixed(1),
|
|
5214
|
+
height: (currentHeight + height).toFixed(1)
|
|
5215
|
+
});
|
|
5216
|
+
};
|
|
5219
5217
|
|
|
5218
|
+
var defaultResizeDirection = {
|
|
5219
|
+
w: true,
|
|
5220
|
+
h: true,
|
|
5221
|
+
b: true
|
|
5222
|
+
};
|
|
5220
5223
|
|
|
5221
|
-
|
|
5224
|
+
var Item = function Item(_ref5) {
|
|
5225
|
+
var _itemMap$error;
|
|
5222
5226
|
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5227
|
+
var setState = _ref5.setState,
|
|
5228
|
+
_ref5$state = _ref5.state;
|
|
5229
|
+
_ref5$state = _ref5$state === void 0 ? {} : _ref5$state;
|
|
5230
|
+
|
|
5231
|
+
var type = _ref5$state.type,
|
|
5232
|
+
_ref5$state$rotation = _ref5$state.rotation,
|
|
5233
|
+
rotation = _ref5$state$rotation === void 0 ? 0 : _ref5$state$rotation,
|
|
5234
|
+
id = _ref5$state.id,
|
|
5235
|
+
locked = _ref5$state.locked,
|
|
5236
|
+
layer = _ref5$state.layer,
|
|
5237
|
+
rest = _objectWithoutProperties(_ref5$state, _excluded$2),
|
|
5238
|
+
_ref5$animate = _ref5.animate,
|
|
5239
|
+
animate = _ref5$animate === void 0 ? "hvr-pop" : _ref5$animate,
|
|
5240
|
+
isSelected = _ref5.isSelected,
|
|
5241
|
+
itemMap = _ref5.itemMap,
|
|
5242
|
+
_ref5$showResizeHandl = _ref5.showResizeHandle,
|
|
5243
|
+
showResizeHandle = _ref5$showResizeHandl === void 0 ? false : _ref5$showResizeHandl;
|
|
5244
|
+
|
|
5245
|
+
var itemWrapperRef = React__default.useRef(null);
|
|
5246
|
+
var _itemMap$type = itemMap[type],
|
|
5247
|
+
_itemMap$type$compone = _itemMap$type.component,
|
|
5248
|
+
Component = _itemMap$type$compone === void 0 ? function () {
|
|
5249
|
+
return null;
|
|
5250
|
+
} : _itemMap$type$compone,
|
|
5251
|
+
_itemMap$type$resizeD = _itemMap$type.resizeDirections,
|
|
5252
|
+
resizeDirections = _itemMap$type$resizeD === void 0 ? defaultResizeDirection : _itemMap$type$resizeD,
|
|
5253
|
+
_itemMap$type$resize = _itemMap$type.resize,
|
|
5254
|
+
resize = _itemMap$type$resize === void 0 ? defaultResize : _itemMap$type$resize;
|
|
5255
|
+
var updateState = React__default.useCallback(function (callbackOrItem) {
|
|
5256
|
+
var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
5257
|
+
return setState(id, callbackOrItem, sync);
|
|
5258
|
+
}, [setState, id]);
|
|
5259
|
+
React__default.useEffect(function () {
|
|
5260
|
+
itemWrapperRef.current.className = animate;
|
|
5261
|
+
}, [animate]);
|
|
5262
|
+
var className = "item ".concat(id);
|
|
5248
5263
|
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5264
|
+
if (locked) {
|
|
5265
|
+
className += " locked";
|
|
5266
|
+
}
|
|
5267
|
+
|
|
5268
|
+
if (isSelected) {
|
|
5269
|
+
className += " selected";
|
|
5270
|
+
}
|
|
5271
|
+
|
|
5272
|
+
var onResize = React__default.useCallback(function (_ref6) {
|
|
5273
|
+
var _ref6$width = _ref6.width,
|
|
5274
|
+
width = _ref6$width === void 0 ? 0 : _ref6$width,
|
|
5275
|
+
_ref6$height = _ref6.height,
|
|
5276
|
+
height = _ref6$height === void 0 ? 0 : _ref6$height,
|
|
5277
|
+
keepRatio = _ref6.keepRatio;
|
|
5278
|
+
updateState(function (prev) {
|
|
5279
|
+
var _itemWrapperRef$curre = itemWrapperRef.current,
|
|
5280
|
+
offsetWidth = _itemWrapperRef$curre.offsetWidth,
|
|
5281
|
+
offsetHeight = _itemWrapperRef$curre.offsetHeight;
|
|
5282
|
+
return resize({
|
|
5283
|
+
prevState: prev,
|
|
5284
|
+
width: width,
|
|
5285
|
+
height: height,
|
|
5286
|
+
actualHeight: offsetHeight,
|
|
5287
|
+
actualWidth: offsetWidth,
|
|
5288
|
+
keepRatio: keepRatio
|
|
5289
|
+
});
|
|
5290
|
+
});
|
|
5291
|
+
}, [resize, updateState]);
|
|
5292
|
+
var onResizeWidth = React__default.useCallback(function (_ref7) {
|
|
5293
|
+
var width = _ref7.width;
|
|
5294
|
+
onResize({
|
|
5295
|
+
width: width
|
|
5256
5296
|
});
|
|
5297
|
+
}, [onResize]);
|
|
5298
|
+
var onResizeHeight = React__default.useCallback(function (_ref8) {
|
|
5299
|
+
var height = _ref8.height;
|
|
5300
|
+
onResize({
|
|
5301
|
+
height: height
|
|
5302
|
+
});
|
|
5303
|
+
}, [onResize]);
|
|
5304
|
+
var onResizeRatio = React__default.useCallback(function (_ref9) {
|
|
5305
|
+
var width = _ref9.width;
|
|
5306
|
+
onResize({
|
|
5307
|
+
height: width,
|
|
5308
|
+
width: width,
|
|
5309
|
+
keepRatio: true
|
|
5310
|
+
});
|
|
5311
|
+
}, [onResize]);
|
|
5312
|
+
return /*#__PURE__*/React__default.createElement(ItemWrapper, {
|
|
5313
|
+
rotation: rotation,
|
|
5314
|
+
locked: locked,
|
|
5315
|
+
selected: isSelected,
|
|
5316
|
+
layer: layer,
|
|
5317
|
+
"data-id": id,
|
|
5318
|
+
className: className
|
|
5319
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
5320
|
+
style: {
|
|
5321
|
+
display: "flex"
|
|
5322
|
+
},
|
|
5323
|
+
ref: itemWrapperRef,
|
|
5324
|
+
onAnimationEnd: removeClass,
|
|
5325
|
+
onKeyDown: function onKeyDown(e) {
|
|
5326
|
+
return e.stopPropagation();
|
|
5327
|
+
},
|
|
5328
|
+
onKeyUp: function onKeyUp(e) {
|
|
5329
|
+
return e.stopPropagation();
|
|
5330
|
+
}
|
|
5331
|
+
}, /*#__PURE__*/React__default.createElement(ItemErrorBoundary, {
|
|
5332
|
+
itemId: id,
|
|
5333
|
+
state: rest,
|
|
5334
|
+
setState: updateState,
|
|
5335
|
+
ErrorComponent: (itemMap === null || itemMap === void 0 ? void 0 : (_itemMap$error = itemMap.error) === null || _itemMap$error === void 0 ? void 0 : _itemMap$error.component) || DefaultErrorComponent
|
|
5336
|
+
}, /*#__PURE__*/React__default.createElement(Component, _extends$1({}, rest, {
|
|
5337
|
+
id: id,
|
|
5338
|
+
setState: updateState
|
|
5339
|
+
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
5340
|
+
className: "corner top-left"
|
|
5341
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
5342
|
+
className: "corner top-right"
|
|
5343
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
5344
|
+
className: "corner bottom-right"
|
|
5345
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
5346
|
+
className: "corner bottom-left"
|
|
5347
|
+
}), isSelected && showResizeHandle && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, resizeDirections.b && /*#__PURE__*/React__default.createElement(ResizeHandler, {
|
|
5348
|
+
className: "resize resize-ratio",
|
|
5349
|
+
onResize: onResizeRatio
|
|
5350
|
+
}), resizeDirections.h && /*#__PURE__*/React__default.createElement(ResizeHandler, {
|
|
5351
|
+
className: "resize resize-height",
|
|
5352
|
+
onResize: onResizeHeight
|
|
5353
|
+
}), resizeDirections.w && /*#__PURE__*/React__default.createElement(ResizeHandler, {
|
|
5354
|
+
className: "resize resize-width",
|
|
5355
|
+
onResize: onResizeWidth
|
|
5356
|
+
}))));
|
|
5357
|
+
};
|
|
5358
|
+
|
|
5359
|
+
var MemoizedItem = /*#__PURE__*/memo(Item, function (_ref10, _ref11) {
|
|
5360
|
+
var prevState = _ref10.state,
|
|
5361
|
+
prevSetState = _ref10.setState,
|
|
5362
|
+
prevIsSelected = _ref10.isSelected,
|
|
5363
|
+
prevShowResizeHandle = _ref10.showResizeHandle;
|
|
5364
|
+
var nextState = _ref11.state,
|
|
5365
|
+
nextSetState = _ref11.setState,
|
|
5366
|
+
nextIsSelected = _ref11.isSelected,
|
|
5367
|
+
nextShowResizeHandle = _ref11.showResizeHandle;
|
|
5368
|
+
return prevIsSelected === nextIsSelected && prevShowResizeHandle === nextShowResizeHandle && prevSetState === nextSetState && JSON.stringify(prevState) === JSON.stringify(nextState);
|
|
5369
|
+
}); // Exclude positioning from memoization
|
|
5370
|
+
|
|
5371
|
+
var PositionedItem = function PositionedItem(_ref12) {
|
|
5372
|
+
var _ref12$state = _ref12.state,
|
|
5373
|
+
state = _ref12$state === void 0 ? {} : _ref12$state,
|
|
5374
|
+
boardSize = _ref12.boardSize,
|
|
5375
|
+
currentUser = _ref12.currentUser,
|
|
5376
|
+
rest = _objectWithoutProperties(_ref12, _excluded2);
|
|
5377
|
+
|
|
5378
|
+
if (!rest.itemMap[state.type]) {
|
|
5379
|
+
return null;
|
|
5380
|
+
}
|
|
5381
|
+
|
|
5382
|
+
var _rest$itemMap$state$t = rest.itemMap[state.type].stateHook,
|
|
5383
|
+
stateHook = _rest$itemMap$state$t === void 0 ? identity : _rest$itemMap$state$t;
|
|
5384
|
+
|
|
5385
|
+
var _stateHook = stateHook(state, {
|
|
5386
|
+
currentUser: currentUser
|
|
5387
|
+
}),
|
|
5388
|
+
_stateHook$x = _stateHook.x,
|
|
5389
|
+
x = _stateHook$x === void 0 ? 0 : _stateHook$x,
|
|
5390
|
+
_stateHook$y = _stateHook.y,
|
|
5391
|
+
y = _stateHook$y === void 0 ? 0 : _stateHook$y,
|
|
5392
|
+
_stateHook$layer = _stateHook.layer,
|
|
5393
|
+
layer = _stateHook$layer === void 0 ? 0 : _stateHook$layer,
|
|
5394
|
+
moving = _stateHook.moving,
|
|
5395
|
+
stateRest = _objectWithoutProperties(_stateHook, _excluded3);
|
|
5396
|
+
|
|
5397
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
5398
|
+
style: {
|
|
5399
|
+
position: "absolute",
|
|
5400
|
+
top: "".concat(boardSize / 2, "px"),
|
|
5401
|
+
left: "".concat(boardSize / 2, "px"),
|
|
5402
|
+
display: "inline-block",
|
|
5403
|
+
transform: "translate(".concat(x, "px, ").concat(y, "px)"),
|
|
5404
|
+
zIndex: (layer + 4) * 10 + 100 + (moving ? 5 : 0) // Items z-index between 100 and 200
|
|
5257
5405
|
|
|
5258
|
-
try {
|
|
5259
|
-
target.setPointerCapture(pointerId);
|
|
5260
|
-
} catch (e) {
|
|
5261
|
-
// eslint-disable-next-line no-console
|
|
5262
|
-
console.log("Fail to capture pointer", e);
|
|
5263
5406
|
}
|
|
5264
|
-
},
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
altKey = e.altKey,
|
|
5271
|
-
ctrlKey = e.ctrlKey,
|
|
5272
|
-
metaKey = e.metaKey,
|
|
5273
|
-
pointerType = e.pointerType;
|
|
5407
|
+
}, /*#__PURE__*/React__default.createElement(MemoizedItem, _extends$1({}, rest, {
|
|
5408
|
+
// Helps to prevent render
|
|
5409
|
+
showResizeHandle: rest.isSelected && rest.showResizeHandle,
|
|
5410
|
+
state: stateRest
|
|
5411
|
+
})));
|
|
5412
|
+
};
|
|
5274
5413
|
|
|
5275
|
-
|
|
5276
|
-
// Event from other pointer
|
|
5277
|
-
stateRef.current.pointers[pointerId] = {
|
|
5278
|
-
clientX: eventClientX,
|
|
5279
|
-
clientY: eventClientY
|
|
5280
|
-
};
|
|
5281
|
-
return;
|
|
5282
|
-
}
|
|
5414
|
+
var MemoizedPositionedItem = /*#__PURE__*/memo(PositionedItem);
|
|
5283
5415
|
|
|
5284
|
-
|
|
5416
|
+
var persistUser = function persistUser(user) {
|
|
5417
|
+
localStorage.setItem("user", JSON.stringify(user));
|
|
5418
|
+
};
|
|
5419
|
+
var colors = ["#037758", "#99092a", "#067070", "#c6650f", "#008726", "#3d7004", "#348402", "#057f58", "#b58612", "#c44c01", "#0a7704", "#0e910e", "#027377", "#c99e02", "#054160", "#157a01", "#b10de2", "#0d6289", "#bc5d03", "#ba0cd1", "#d39f10", "#0c4c7a", "#460782", "#a51f10", "#cecb10", "#9b0943", "#607f0c", "#007a4b", "#bf0daa", "#af0ad8"];
|
|
5285
5420
|
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
var distance;
|
|
5421
|
+
var getRandomColor = function getRandomColor() {
|
|
5422
|
+
return colors[Math.floor(Math.random() * colors.length)];
|
|
5423
|
+
}; // TODO remove user persistence
|
|
5290
5424
|
|
|
5291
|
-
if (twoFingers) {
|
|
5292
|
-
// Find other pointerId
|
|
5293
|
-
var _otherPointer2 = otherPointer(stateRef.current.pointers, pointerId),
|
|
5294
|
-
clientX2 = _otherPointer2.clientX,
|
|
5295
|
-
clientY2 = _otherPointer2.clientY; // Update client X with the center of each touch
|
|
5296
5425
|
|
|
5426
|
+
var getUser = function getUser() {
|
|
5427
|
+
if (localStorage.user) {
|
|
5428
|
+
// Add some mandatory info if missing
|
|
5429
|
+
var localUser = _objectSpread2({
|
|
5430
|
+
name: "Player",
|
|
5431
|
+
color: getRandomColor(),
|
|
5432
|
+
uid: nanoid()
|
|
5433
|
+
}, JSON.parse(localStorage.user)); // Id is given by server
|
|
5434
|
+
// delete localUser.id;
|
|
5297
5435
|
|
|
5298
|
-
clientX = (clientX2 + eventClientX) / 2;
|
|
5299
|
-
clientY = (clientY2 + eventClientY) / 2;
|
|
5300
|
-
distance = computeDistance([clientX2, clientY2], [eventClientX, eventClientY]);
|
|
5301
|
-
} else {
|
|
5302
|
-
clientX = eventClientX;
|
|
5303
|
-
clientY = eventClientY;
|
|
5304
|
-
} // We drag if
|
|
5305
|
-
// On non touch device
|
|
5306
|
-
// - Button is 0
|
|
5307
|
-
// - Alt key is no pressed
|
|
5308
|
-
// or on touch devices
|
|
5309
|
-
// - We use only one finger
|
|
5310
5436
|
|
|
5437
|
+
persistUser(localUser);
|
|
5438
|
+
return localUser;
|
|
5439
|
+
}
|
|
5311
5440
|
|
|
5312
|
-
|
|
5441
|
+
var newUser = {
|
|
5442
|
+
name: "Player",
|
|
5443
|
+
color: getRandomColor(),
|
|
5444
|
+
uid: nanoid()
|
|
5445
|
+
};
|
|
5446
|
+
persistUser(newUser);
|
|
5447
|
+
return newUser;
|
|
5448
|
+
};
|
|
5449
|
+
var userAtom = atom({
|
|
5450
|
+
key: "user",
|
|
5451
|
+
"default": getUser()
|
|
5452
|
+
});
|
|
5453
|
+
var usersAtom = atom({
|
|
5454
|
+
key: "users",
|
|
5455
|
+
"default": []
|
|
5456
|
+
});
|
|
5457
|
+
var localUsersAtom = selector({
|
|
5458
|
+
key: "localUsersAtom",
|
|
5459
|
+
get: function get(_ref) {
|
|
5460
|
+
var _get = _ref.get;
|
|
5313
5461
|
|
|
5314
|
-
|
|
5315
|
-
// Send drag start on first move
|
|
5316
|
-
if (!stateRef.current.gestureStart) {
|
|
5317
|
-
wrapperRef.current.style.cursor = "move";
|
|
5318
|
-
stateRef.current.gestureStart = true; // Clear tap timeout
|
|
5462
|
+
var currentUser = _get(userAtom);
|
|
5319
5463
|
|
|
5320
|
-
|
|
5321
|
-
queue(onDragStart, {
|
|
5322
|
-
deltaX: 0,
|
|
5323
|
-
deltaY: 0,
|
|
5324
|
-
startX: stateRef.current.startX,
|
|
5325
|
-
startY: stateRef.current.startY,
|
|
5326
|
-
clientX: stateRef.current.startX,
|
|
5327
|
-
clientY: stateRef.current.startY,
|
|
5328
|
-
distanceX: 0,
|
|
5329
|
-
distanceY: 0,
|
|
5330
|
-
button: stateRef.current.currentButton,
|
|
5331
|
-
altKey: altKey,
|
|
5332
|
-
ctrlKey: ctrlKey,
|
|
5333
|
-
metaKey: metaKey,
|
|
5334
|
-
target: stateRef.current.target,
|
|
5335
|
-
event: e
|
|
5336
|
-
});
|
|
5337
|
-
} // Create closure
|
|
5464
|
+
var users = _get(usersAtom);
|
|
5338
5465
|
|
|
5466
|
+
return users.filter(function (_ref2) {
|
|
5467
|
+
var space = _ref2.space;
|
|
5468
|
+
return space === currentUser.space;
|
|
5469
|
+
});
|
|
5470
|
+
}
|
|
5471
|
+
});
|
|
5339
5472
|
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5473
|
+
var useUsers = function useUsers() {
|
|
5474
|
+
var _useRecoilState = useRecoilState(userAtom),
|
|
5475
|
+
_useRecoilState2 = _slicedToArray(_useRecoilState, 2),
|
|
5476
|
+
currentUser = _useRecoilState2[0],
|
|
5477
|
+
setCurrentUserState = _useRecoilState2[1];
|
|
5344
5478
|
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5479
|
+
var users = useRecoilValue(usersAtom);
|
|
5480
|
+
var localUsers = useRecoilValue(localUsersAtom);
|
|
5481
|
+
var setCurrentUser = React__default.useCallback(function (callbackOrUser) {
|
|
5482
|
+
var callback = callbackOrUser;
|
|
5483
|
+
|
|
5484
|
+
if (_typeof(callbackOrUser) === "object") {
|
|
5485
|
+
callback = function callback() {
|
|
5486
|
+
return callbackOrUser;
|
|
5487
|
+
};
|
|
5488
|
+
}
|
|
5489
|
+
|
|
5490
|
+
setCurrentUserState(function (prevUser) {
|
|
5491
|
+
var newUser = _objectSpread2(_objectSpread2({}, callback(prevUser)), {}, {
|
|
5492
|
+
id: prevUser.id,
|
|
5493
|
+
uid: prevUser.uid
|
|
5494
|
+
});
|
|
5495
|
+
|
|
5496
|
+
persistUser(newUser);
|
|
5497
|
+
return newUser;
|
|
5498
|
+
});
|
|
5499
|
+
}, [setCurrentUserState]);
|
|
5500
|
+
return {
|
|
5501
|
+
currentUser: currentUser,
|
|
5502
|
+
setCurrentUser: setCurrentUser,
|
|
5503
|
+
users: users,
|
|
5504
|
+
localUsers: localUsers
|
|
5505
|
+
};
|
|
5506
|
+
};
|
|
5507
|
+
|
|
5508
|
+
var SubscribeUserEvents = function SubscribeUserEvents() {
|
|
5509
|
+
var usersRef = React__default.useRef([]);
|
|
5510
|
+
var setUsers = useSetRecoilState(usersAtom);
|
|
5511
|
+
|
|
5512
|
+
var _useRecoilState = useRecoilState(userAtom),
|
|
5513
|
+
_useRecoilState2 = _slicedToArray(_useRecoilState, 2),
|
|
5514
|
+
currentUser = _useRecoilState2[0],
|
|
5515
|
+
setCurrentUserState = _useRecoilState2[1];
|
|
5516
|
+
|
|
5517
|
+
var _useWire = useWire("room"),
|
|
5518
|
+
wire = _useWire.wire,
|
|
5519
|
+
isMaster = _useWire.isMaster,
|
|
5520
|
+
roomSpace = _useWire.room;
|
|
5521
|
+
|
|
5522
|
+
React__default.useEffect(function () {
|
|
5523
|
+
setCurrentUserState(function (prevUser) {
|
|
5524
|
+
return _objectSpread2(_objectSpread2({}, prevUser), {}, {
|
|
5525
|
+
id: wire.userId,
|
|
5526
|
+
space: roomSpace
|
|
5527
|
+
});
|
|
5528
|
+
});
|
|
5529
|
+
return function () {
|
|
5530
|
+
setCurrentUserState(function (prevUser) {
|
|
5531
|
+
return _objectSpread2(_objectSpread2({}, prevUser), {}, {
|
|
5532
|
+
id: wire.userId,
|
|
5533
|
+
space: null
|
|
5360
5534
|
});
|
|
5361
|
-
}
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5535
|
+
});
|
|
5536
|
+
};
|
|
5537
|
+
}, [wire.userId, roomSpace, setCurrentUserState]);
|
|
5538
|
+
React__default.useEffect(function () {
|
|
5539
|
+
if (!isMaster) {
|
|
5540
|
+
var onGetUserList = function onGetUserList(userList) {
|
|
5541
|
+
usersRef.current = userList;
|
|
5542
|
+
setUsers(userList);
|
|
5543
|
+
};
|
|
5365
5544
|
|
|
5366
|
-
|
|
5367
|
-
|
|
5545
|
+
wire.call("getUserList").then(onGetUserList, function () {
|
|
5546
|
+
// retry later
|
|
5547
|
+
setTimeout(function () {
|
|
5548
|
+
wire.call("getUserList") // eslint-disable-next-line no-console
|
|
5549
|
+
.then(onGetUserList, function (error) {
|
|
5550
|
+
return console.log(error);
|
|
5551
|
+
});
|
|
5552
|
+
}, 1000);
|
|
5553
|
+
});
|
|
5554
|
+
}
|
|
5555
|
+
}, [wire, isMaster, setUsers]); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5556
|
+
|
|
5557
|
+
var debouncedEmitUpdateUser = useDebouncedCallback(function (newUser) {
|
|
5558
|
+
wire.publish("userUpdate", newUser, true);
|
|
5559
|
+
}, [wire], 500);
|
|
5560
|
+
React__default.useEffect(function () {
|
|
5561
|
+
if (currentUser && currentUser.id) {
|
|
5562
|
+
debouncedEmitUpdateUser(currentUser);
|
|
5563
|
+
}
|
|
5564
|
+
}, [currentUser, debouncedEmitUpdateUser]);
|
|
5565
|
+
React__default.useEffect(function () {
|
|
5566
|
+
var unsub = [];
|
|
5567
|
+
|
|
5568
|
+
if (isMaster) {
|
|
5569
|
+
wire.register("getUserList", function () {
|
|
5570
|
+
return usersRef.current;
|
|
5571
|
+
}).then(function (unregister) {
|
|
5572
|
+
unsub.push(unregister);
|
|
5573
|
+
});
|
|
5574
|
+
unsub.push(wire.subscribe("userUpdate", function (user) {
|
|
5575
|
+
if (usersRef.current.find(function (u) {
|
|
5576
|
+
return u.id === user.id;
|
|
5577
|
+
})) {
|
|
5578
|
+
var newUsers = usersRef.current.map(function (u) {
|
|
5579
|
+
return u.id === user.id ? user : u;
|
|
5580
|
+
});
|
|
5581
|
+
usersRef.current = newUsers;
|
|
5582
|
+
} else {
|
|
5583
|
+
var _newUsers = [].concat(_toConsumableArray(usersRef.current), [user]);
|
|
5584
|
+
|
|
5585
|
+
usersRef.current = _newUsers;
|
|
5586
|
+
}
|
|
5587
|
+
|
|
5588
|
+
setUsers(usersRef.current);
|
|
5589
|
+
wire.publish("updateUserList", usersRef.current);
|
|
5590
|
+
}));
|
|
5591
|
+
}
|
|
5592
|
+
|
|
5593
|
+
unsub.push(wire.subscribe("userLeave", function (userId) {
|
|
5594
|
+
usersRef.current = usersRef.current.filter(function (_ref) {
|
|
5595
|
+
var id = _ref.id;
|
|
5596
|
+
return id !== userId;
|
|
5597
|
+
});
|
|
5598
|
+
setUsers(usersRef.current);
|
|
5599
|
+
|
|
5600
|
+
if (isMaster) {
|
|
5601
|
+
wire.publish("updateUserList", usersRef.current);
|
|
5602
|
+
}
|
|
5603
|
+
}));
|
|
5604
|
+
unsub.push(wire.subscribe("updateUserList", function (newList) {
|
|
5605
|
+
usersRef.current = newList;
|
|
5606
|
+
setUsers(usersRef.current);
|
|
5607
|
+
}));
|
|
5608
|
+
return function () {
|
|
5609
|
+
unsub.forEach(function (u) {
|
|
5610
|
+
return u();
|
|
5611
|
+
});
|
|
5612
|
+
};
|
|
5613
|
+
}, [wire, isMaster, setUsers]);
|
|
5614
|
+
return null;
|
|
5615
|
+
};
|
|
5616
|
+
|
|
5617
|
+
var ItemList = function ItemList() {
|
|
5618
|
+
var _useItemActions = useItemActions(),
|
|
5619
|
+
updateItem = _useItemActions.updateItem;
|
|
5620
|
+
|
|
5621
|
+
var itemList = useRecoilValue(ItemListAtom);
|
|
5622
|
+
var itemMap = useRecoilValue(ItemMapAtom);
|
|
5623
|
+
var selectedItems = useRecoilValue(SelectedItemsAtom);
|
|
5624
|
+
|
|
5625
|
+
var _useRecoilValue = useRecoilValue(ConfigurationAtom),
|
|
5626
|
+
boardSize = _useRecoilValue.boardSize,
|
|
5627
|
+
showResizeHandle = _useRecoilValue.showResizeHandle,
|
|
5628
|
+
itemTemplates = _useRecoilValue.itemTemplates;
|
|
5368
5629
|
|
|
5630
|
+
var _useUsers = useUsers(),
|
|
5631
|
+
currentUser = _useUsers.currentUser;
|
|
5632
|
+
|
|
5633
|
+
return itemList.map(function (itemId) {
|
|
5634
|
+
return /*#__PURE__*/React__default.createElement(MemoizedPositionedItem, {
|
|
5635
|
+
key: itemId,
|
|
5636
|
+
state: itemMap[itemId],
|
|
5637
|
+
setState: updateItem,
|
|
5638
|
+
isSelected: selectedItems.includes(itemId),
|
|
5639
|
+
itemMap: itemTemplates,
|
|
5640
|
+
boardSize: boardSize,
|
|
5641
|
+
currentUser: currentUser,
|
|
5642
|
+
showResizeHandle: showResizeHandle
|
|
5643
|
+
});
|
|
5644
|
+
});
|
|
5645
|
+
};
|
|
5646
|
+
|
|
5647
|
+
var SubcribeItemEvents = function SubcribeItemEvents() {
|
|
5648
|
+
var _useWire = useWire("board"),
|
|
5649
|
+
wire = _useWire.wire;
|
|
5650
|
+
|
|
5651
|
+
var setItemMap = useSetRecoilState(ItemMapAtom);
|
|
5652
|
+
|
|
5653
|
+
var _useItemActions = useItemActions(),
|
|
5654
|
+
updateItemOrder = _useItemActions.updateItemOrder,
|
|
5655
|
+
moveItems = _useItemActions.moveItems,
|
|
5656
|
+
removeItems = _useItemActions.removeItems,
|
|
5657
|
+
pushItem = _useItemActions.pushItem;
|
|
5658
|
+
|
|
5659
|
+
var batchUpdate = React__default.useCallback(function (updatedItems) {
|
|
5660
|
+
setItemMap(function (prevItemMap) {
|
|
5661
|
+
return _objectSpread2(_objectSpread2({}, prevItemMap), updatedItems);
|
|
5662
|
+
});
|
|
5663
|
+
}, [setItemMap]);
|
|
5664
|
+
React__default.useEffect(function () {
|
|
5665
|
+
var unsub = wire.subscribe("batchItemsUpdate", function (updatedItems) {
|
|
5666
|
+
batchUpdate(updatedItems);
|
|
5667
|
+
});
|
|
5668
|
+
return unsub;
|
|
5669
|
+
}, [wire, batchUpdate]);
|
|
5670
|
+
React__default.useEffect(function () {
|
|
5671
|
+
var unsub = wire.subscribe("selectedItemsMove", function (_ref) {
|
|
5672
|
+
var itemIds = _ref.itemIds,
|
|
5673
|
+
posDelta = _ref.posDelta;
|
|
5674
|
+
moveItems(itemIds, posDelta, false);
|
|
5675
|
+
});
|
|
5676
|
+
return unsub;
|
|
5677
|
+
}, [wire, moveItems]);
|
|
5678
|
+
React__default.useEffect(function () {
|
|
5679
|
+
var unsub = wire.subscribe("updateItemListOrder", function (itemIds) {
|
|
5680
|
+
updateItemOrder(itemIds, false);
|
|
5681
|
+
});
|
|
5682
|
+
return unsub;
|
|
5683
|
+
}, [wire, updateItemOrder]);
|
|
5684
|
+
React__default.useEffect(function () {
|
|
5685
|
+
var unsub = wire.subscribe("pushItem", function (newItem) {
|
|
5686
|
+
pushItem(newItem, null, false);
|
|
5687
|
+
});
|
|
5688
|
+
return unsub;
|
|
5689
|
+
}, [wire, pushItem]);
|
|
5690
|
+
React__default.useEffect(function () {
|
|
5691
|
+
var unsub = wire.subscribe("insertItemBefore", function (_ref2) {
|
|
5692
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
5693
|
+
newItem = _ref3[0],
|
|
5694
|
+
beforeId = _ref3[1];
|
|
5695
|
+
|
|
5696
|
+
pushItem(newItem, beforeId, false);
|
|
5697
|
+
});
|
|
5698
|
+
return unsub;
|
|
5699
|
+
}, [wire, pushItem]);
|
|
5700
|
+
React__default.useEffect(function () {
|
|
5701
|
+
var unsub = wire.subscribe("removeItems", function (itemIds) {
|
|
5702
|
+
removeItems(itemIds, false);
|
|
5703
|
+
});
|
|
5704
|
+
return unsub;
|
|
5705
|
+
}, [wire, removeItems]);
|
|
5706
|
+
return null;
|
|
5707
|
+
};
|
|
5369
5708
|
|
|
5370
|
-
|
|
5709
|
+
/**
|
|
5710
|
+
* Check if element or parent has className.
|
|
5711
|
+
* @param {DOMElement} element
|
|
5712
|
+
* @param {string} className
|
|
5713
|
+
*/
|
|
5714
|
+
var hasClass = function hasClass(element, className) {
|
|
5715
|
+
return element.classList && element.classList.contains(className);
|
|
5716
|
+
};
|
|
5717
|
+
var insideClass = function insideClass(element, className) {
|
|
5718
|
+
if (hasClass(element, className)) {
|
|
5719
|
+
return element;
|
|
5720
|
+
}
|
|
5371
5721
|
|
|
5372
|
-
|
|
5722
|
+
if (!element.parentNode) {
|
|
5723
|
+
return false;
|
|
5724
|
+
}
|
|
5373
5725
|
|
|
5374
|
-
|
|
5726
|
+
return insideClass(element.parentNode, className);
|
|
5727
|
+
};
|
|
5728
|
+
var isPointInsideRect = function isPointInsideRect(point, rect) {
|
|
5729
|
+
return point.x > rect.left && point.x < rect.left + rect.width && point.y > rect.top && point.y < rect.top + rect.height;
|
|
5730
|
+
};
|
|
5731
|
+
var isItemInsideElement = function isItemInsideElement(itemElement, otherElem) {
|
|
5732
|
+
var rect = otherElem.getBoundingClientRect();
|
|
5733
|
+
var fourElem = Array.from(itemElement.querySelectorAll(".corner"));
|
|
5734
|
+
return fourElem.every(function (corner) {
|
|
5735
|
+
var _corner$getBoundingCl = corner.getBoundingClientRect(),
|
|
5736
|
+
y = _corner$getBoundingCl.top,
|
|
5737
|
+
x = _corner$getBoundingCl.left;
|
|
5375
5738
|
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
});
|
|
5739
|
+
return isPointInsideRect({
|
|
5740
|
+
x: x,
|
|
5741
|
+
y: y
|
|
5742
|
+
}, rect);
|
|
5743
|
+
});
|
|
5744
|
+
};
|
|
5745
|
+
var getItemElem = function getItemElem(wrapper, itemId) {
|
|
5746
|
+
var elems = wrapper.getElementsByClassName("item ".concat(itemId));
|
|
5747
|
+
var elem = elems[0];
|
|
5386
5748
|
|
|
5387
|
-
|
|
5388
|
-
|
|
5749
|
+
if (!elem) {
|
|
5750
|
+
// eslint-disable-next-line no-console
|
|
5751
|
+
console.error("Missing item ".concat(itemId));
|
|
5752
|
+
}
|
|
5389
5753
|
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
clientY: clientY,
|
|
5395
|
-
event: e
|
|
5396
|
-
});
|
|
5397
|
-
stateRef.current.prevDistance = distance;
|
|
5398
|
-
}
|
|
5399
|
-
}
|
|
5400
|
-
}
|
|
5754
|
+
return elem;
|
|
5755
|
+
};
|
|
5756
|
+
var getIdFromElem = function getIdFromElem(elem) {
|
|
5757
|
+
var _elem$dataset;
|
|
5401
5758
|
|
|
5402
|
-
|
|
5403
|
-
stateRef.current.prevY = clientY;
|
|
5404
|
-
}
|
|
5405
|
-
}, [onDrag, onDragStart, onPan, onZoom, queue]);
|
|
5406
|
-
var onPointerUp = React.useCallback(function (e) {
|
|
5407
|
-
var clientX = e.clientX,
|
|
5408
|
-
clientY = e.clientY,
|
|
5409
|
-
altKey = e.altKey,
|
|
5410
|
-
ctrlKey = e.ctrlKey,
|
|
5411
|
-
metaKey = e.metaKey,
|
|
5412
|
-
target = e.target,
|
|
5413
|
-
pointerId = e.pointerId;
|
|
5759
|
+
var value = elem === null || elem === void 0 ? void 0 : (_elem$dataset = elem.dataset) === null || _elem$dataset === void 0 ? void 0 : _elem$dataset.id;
|
|
5414
5760
|
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
// ignoring it
|
|
5418
|
-
return;
|
|
5419
|
-
} // Remove pointer from map
|
|
5761
|
+
if (!value) {
|
|
5762
|
+
var _elem$dataset2;
|
|
5420
5763
|
|
|
5764
|
+
// eslint-disable-next-line no-console
|
|
5765
|
+
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);
|
|
5766
|
+
}
|
|
5421
5767
|
|
|
5422
|
-
|
|
5768
|
+
return value;
|
|
5769
|
+
};
|
|
5770
|
+
var getItemBoundingBox = function getItemBoundingBox(items) {
|
|
5771
|
+
var wrapper = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
|
|
5772
|
+
var result = items.reduce(function (prev, itemId) {
|
|
5773
|
+
var elem = getItemElem(wrapper, itemId);
|
|
5774
|
+
if (!elem) return null;
|
|
5423
5775
|
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5776
|
+
var _elem$getBoundingClie = elem.getBoundingClientRect(),
|
|
5777
|
+
left = _elem$getBoundingClie.left,
|
|
5778
|
+
right = _elem$getBoundingClie.right,
|
|
5779
|
+
top = _elem$getBoundingClie.top,
|
|
5780
|
+
bottom = _elem$getBoundingClie.bottom;
|
|
5428
5781
|
|
|
5429
|
-
|
|
5430
|
-
// If was main pointer but we have another one, this one become main
|
|
5431
|
-
stateRef.current.mainPointer = Number(Object.keys(stateRef.current.pointers)[0]);
|
|
5782
|
+
var boundingBox;
|
|
5432
5783
|
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
|
|
5784
|
+
if (!prev) {
|
|
5785
|
+
boundingBox = {
|
|
5786
|
+
left: left,
|
|
5787
|
+
top: top,
|
|
5788
|
+
right: right,
|
|
5789
|
+
bottom: bottom
|
|
5790
|
+
};
|
|
5791
|
+
} else {
|
|
5792
|
+
boundingBox = prev;
|
|
5442
5793
|
}
|
|
5443
5794
|
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5795
|
+
boundingBox.left = Math.min(left, boundingBox.left);
|
|
5796
|
+
boundingBox.top = Math.min(top, boundingBox.top);
|
|
5797
|
+
boundingBox.right = Math.max(right, boundingBox.right);
|
|
5798
|
+
boundingBox.bottom = Math.max(bottom, boundingBox.bottom);
|
|
5799
|
+
return boundingBox;
|
|
5800
|
+
}, null);
|
|
5448
5801
|
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
queue(onDragEnd, {
|
|
5453
|
-
deltaX: clientX - stateRef.current.prevX,
|
|
5454
|
-
deltaY: clientY - stateRef.current.prevY,
|
|
5455
|
-
startX: stateRef.current.startX,
|
|
5456
|
-
startY: stateRef.current.startY,
|
|
5457
|
-
clientX: clientX,
|
|
5458
|
-
clientY: clientY,
|
|
5459
|
-
distanceX: clientX - stateRef.current.startX,
|
|
5460
|
-
distanceY: clientY - stateRef.current.startY,
|
|
5461
|
-
button: stateRef.current.currentButton,
|
|
5462
|
-
altKey: altKey,
|
|
5463
|
-
ctrlKey: ctrlKey,
|
|
5464
|
-
metaKey: metaKey,
|
|
5465
|
-
event: e
|
|
5466
|
-
});
|
|
5467
|
-
wrapperRef.current.style.cursor = "auto";
|
|
5468
|
-
} else {
|
|
5469
|
-
var now = Date.now();
|
|
5802
|
+
if (!result) {
|
|
5803
|
+
return result;
|
|
5804
|
+
}
|
|
5470
5805
|
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
else if (stateRef.current.timeStart - now < 300) {
|
|
5475
|
-
queue(onTap, {
|
|
5476
|
-
clientX: clientX,
|
|
5477
|
-
clientY: clientY,
|
|
5478
|
-
altKey: altKey,
|
|
5479
|
-
ctrlKey: ctrlKey,
|
|
5480
|
-
metaKey: metaKey,
|
|
5481
|
-
target: target
|
|
5482
|
-
});
|
|
5483
|
-
}
|
|
5484
|
-
}
|
|
5485
|
-
}, [onDragEnd, onTap, queue]);
|
|
5486
|
-
var onDoubleTapHandler = React.useCallback(function (event) {
|
|
5487
|
-
queue(onDoubleTap, event);
|
|
5488
|
-
}, [onDoubleTap, queue]);
|
|
5489
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
5490
|
-
onWheel: onWheel,
|
|
5491
|
-
onPointerDown: onPointerDown,
|
|
5492
|
-
onPointerMove: onPointerMove,
|
|
5493
|
-
onPointerUp: onPointerUp,
|
|
5494
|
-
onPointerOut: onPointerUp,
|
|
5495
|
-
onPointerLeave: onPointerUp,
|
|
5496
|
-
onPointerCancel: onPointerUp,
|
|
5497
|
-
onDoubleClick: onDoubleTapHandler,
|
|
5498
|
-
style: {
|
|
5499
|
-
touchAction: "none"
|
|
5500
|
-
},
|
|
5501
|
-
ref: wrapperRef
|
|
5502
|
-
}, children);
|
|
5806
|
+
result.width = result.right - result.left;
|
|
5807
|
+
result.height = result.bottom - result.top;
|
|
5808
|
+
return result;
|
|
5503
5809
|
};
|
|
5504
5810
|
|
|
5505
5811
|
var defaultSelectorStyle = {
|
|
@@ -5540,17 +5846,17 @@ var Selector = function Selector(_ref) {
|
|
|
5540
5846
|
var _useItemActions = useItemActions(),
|
|
5541
5847
|
findElementUnderPointer = _useItemActions.findElementUnderPointer;
|
|
5542
5848
|
|
|
5543
|
-
var _React$useState =
|
|
5849
|
+
var _React$useState = React__default.useState({}),
|
|
5544
5850
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
5545
5851
|
selector = _React$useState2[0],
|
|
5546
5852
|
setSelector = _React$useState2[1];
|
|
5547
5853
|
|
|
5548
|
-
var wrapperRef =
|
|
5549
|
-
var stateRef =
|
|
5854
|
+
var wrapperRef = React__default.useRef(null);
|
|
5855
|
+
var stateRef = React__default.useRef({
|
|
5550
5856
|
moving: false
|
|
5551
5857
|
}); // Reset selection on board loading
|
|
5552
5858
|
|
|
5553
|
-
|
|
5859
|
+
React__default.useEffect(function () {
|
|
5554
5860
|
setSelected(function (prev) {
|
|
5555
5861
|
return prev.length === 0 ? prev : [];
|
|
5556
5862
|
});
|
|
@@ -5721,7 +6027,7 @@ var Selector = function Selector(_ref) {
|
|
|
5721
6027
|
}
|
|
5722
6028
|
};
|
|
5723
6029
|
|
|
5724
|
-
var onLongTap =
|
|
6030
|
+
var onLongTap = React__default.useCallback(function (_ref8) {
|
|
5725
6031
|
var target = _ref8.target;
|
|
5726
6032
|
var foundElement = insideClass(target, "item");
|
|
5727
6033
|
|
|
@@ -5796,15 +6102,15 @@ var Selector = function Selector(_ref) {
|
|
|
5796
6102
|
};
|
|
5797
6103
|
}();
|
|
5798
6104
|
}, [findElementUnderPointer, setSelected]);
|
|
5799
|
-
return /*#__PURE__*/
|
|
6105
|
+
return /*#__PURE__*/React__default.createElement(Gesture, {
|
|
5800
6106
|
onDragStart: onDragStart,
|
|
5801
6107
|
onDrag: onDrag,
|
|
5802
6108
|
onDragEnd: onDragEnd,
|
|
5803
6109
|
onTap: onTap,
|
|
5804
6110
|
onLongTap: onLongTap
|
|
5805
|
-
}, /*#__PURE__*/
|
|
6111
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
5806
6112
|
ref: wrapperRef
|
|
5807
|
-
}, selector.moving && /*#__PURE__*/
|
|
6113
|
+
}, selector.moving && /*#__PURE__*/React__default.createElement("div", {
|
|
5808
6114
|
style: _objectSpread2(_objectSpread2({}, defaultSelectorStyle), {}, {
|
|
5809
6115
|
transform: "translate(".concat(selector.left, "px, ").concat(selector.top, "px)"),
|
|
5810
6116
|
height: "".concat(selector.height, "px"),
|
|
@@ -5824,9 +6130,9 @@ var ActionPane = function ActionPane(_ref) {
|
|
|
5824
6130
|
|
|
5825
6131
|
var setSelectedItems = useSetRecoilState(SelectedItemsAtom);
|
|
5826
6132
|
var setBoardState = useSetRecoilState(BoardStateAtom);
|
|
5827
|
-
var actionRef =
|
|
6133
|
+
var actionRef = React__default.useRef({}); // Use ref because pointer events are faster than react state management
|
|
5828
6134
|
|
|
5829
|
-
var selectedItemRef =
|
|
6135
|
+
var selectedItemRef = React__default.useRef({
|
|
5830
6136
|
items: []
|
|
5831
6137
|
});
|
|
5832
6138
|
var onDragStart = useRecoilCallback(function (_ref2) {
|
|
@@ -6082,167 +6388,236 @@ var ActionPane = function ActionPane(_ref) {
|
|
|
6082
6388
|
};
|
|
6083
6389
|
}();
|
|
6084
6390
|
}, [moveItems, placeItems]);
|
|
6085
|
-
|
|
6391
|
+
React__default.useEffect(function () {
|
|
6086
6392
|
document.addEventListener("keydown", onKeyDown);
|
|
6087
6393
|
return function () {
|
|
6088
6394
|
document.removeEventListener("keydown", onKeyDown);
|
|
6089
6395
|
};
|
|
6090
6396
|
}, [onKeyDown]);
|
|
6091
|
-
return /*#__PURE__*/
|
|
6397
|
+
return /*#__PURE__*/React__default.createElement(Gesture, {
|
|
6092
6398
|
onDragStart: onDragStart,
|
|
6093
6399
|
onDrag: onDrag,
|
|
6094
6400
|
onDragEnd: onDragEnd
|
|
6095
6401
|
}, children);
|
|
6096
6402
|
};
|
|
6097
6403
|
|
|
6098
|
-
|
|
6099
|
-
|
|
6404
|
+
/**
|
|
6405
|
+
* A simple guard function:
|
|
6406
|
+
*
|
|
6407
|
+
* ```js
|
|
6408
|
+
* Math.min(Math.max(low, value), high)
|
|
6409
|
+
* ```
|
|
6410
|
+
*/
|
|
6411
|
+
function guard(low, high, value) {
|
|
6412
|
+
return Math.min(Math.max(low, value), high);
|
|
6100
6413
|
}
|
|
6101
6414
|
|
|
6102
|
-
var
|
|
6103
|
-
_inherits(
|
|
6415
|
+
var ColorError = /*#__PURE__*/function (_Error) {
|
|
6416
|
+
_inherits(ColorError, _Error);
|
|
6104
6417
|
|
|
6105
|
-
var _super = _createSuper(
|
|
6418
|
+
var _super = _createSuper(ColorError);
|
|
6106
6419
|
|
|
6107
|
-
function
|
|
6108
|
-
_classCallCheck(this,
|
|
6420
|
+
function ColorError(color) {
|
|
6421
|
+
_classCallCheck(this, ColorError);
|
|
6109
6422
|
|
|
6110
|
-
return _super.call(this, "Failed to parse color: \"".concat(
|
|
6423
|
+
return _super.call(this, "Failed to parse color: \"".concat(color, "\""));
|
|
6111
6424
|
}
|
|
6112
6425
|
|
|
6113
|
-
return
|
|
6426
|
+
return ColorError;
|
|
6114
6427
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
6115
6428
|
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
e = o[function (t) {
|
|
6123
|
-
var n = 5381,
|
|
6124
|
-
r = t.length;
|
|
6125
|
-
|
|
6126
|
-
for (; r;) {
|
|
6127
|
-
n = 33 * n ^ t.charCodeAt(--r);
|
|
6128
|
-
}
|
|
6129
|
-
|
|
6130
|
-
return (n >>> 0) % 2341;
|
|
6131
|
-
}(r)];
|
|
6132
|
-
|
|
6133
|
-
if (!e) throw new n(t);
|
|
6134
|
-
return "#".concat(e);
|
|
6135
|
-
}(r) : r;
|
|
6136
|
-
var f = s.exec(e);
|
|
6137
|
-
|
|
6138
|
-
if (f) {
|
|
6139
|
-
var _t = Array.from(f).slice(1);
|
|
6429
|
+
var ColorError$1 = ColorError;
|
|
6430
|
+
/**
|
|
6431
|
+
* Parses a color into red, gree, blue, alpha parts
|
|
6432
|
+
*
|
|
6433
|
+
* @param color the input color. Can be a RGB, RBGA, HSL, HSLA, or named color
|
|
6434
|
+
*/
|
|
6140
6435
|
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6436
|
+
function parseToRgba(color) {
|
|
6437
|
+
if (typeof color !== 'string') throw new ColorError$1(color);
|
|
6438
|
+
if (color.trim().toLowerCase() === 'transparent') return [0, 0, 0, 0];
|
|
6439
|
+
var normalizedColor = color.trim();
|
|
6440
|
+
normalizedColor = namedColorRegex.test(color) ? nameToHex(color) : color;
|
|
6441
|
+
var reducedHexMatch = reducedHexRegex.exec(normalizedColor);
|
|
6442
|
+
|
|
6443
|
+
if (reducedHexMatch) {
|
|
6444
|
+
var arr = Array.from(reducedHexMatch).slice(1);
|
|
6445
|
+
return [].concat(_toConsumableArray(arr.slice(0, 3).map(function (x) {
|
|
6446
|
+
return parseInt(r(x, 2), 16);
|
|
6447
|
+
})), [parseInt(r(arr[3] || 'f', 2), 16) / 255]);
|
|
6144
6448
|
}
|
|
6145
6449
|
|
|
6146
|
-
var
|
|
6450
|
+
var hexMatch = hexRegex.exec(normalizedColor);
|
|
6147
6451
|
|
|
6148
|
-
if (
|
|
6149
|
-
var
|
|
6452
|
+
if (hexMatch) {
|
|
6453
|
+
var _arr = Array.from(hexMatch).slice(1);
|
|
6150
6454
|
|
|
6151
|
-
return [].concat(_toConsumableArray(
|
|
6152
|
-
return parseInt(
|
|
6153
|
-
})), [parseInt(
|
|
6455
|
+
return [].concat(_toConsumableArray(_arr.slice(0, 3).map(function (x) {
|
|
6456
|
+
return parseInt(x, 16);
|
|
6457
|
+
})), [parseInt(_arr[3] || 'ff', 16) / 255]);
|
|
6154
6458
|
}
|
|
6155
6459
|
|
|
6156
|
-
var
|
|
6460
|
+
var rgbaMatch = rgbaRegex.exec(normalizedColor);
|
|
6157
6461
|
|
|
6158
|
-
if (
|
|
6159
|
-
var
|
|
6462
|
+
if (rgbaMatch) {
|
|
6463
|
+
var _arr2 = Array.from(rgbaMatch).slice(1);
|
|
6160
6464
|
|
|
6161
|
-
return [].concat(_toConsumableArray(
|
|
6162
|
-
return parseInt(
|
|
6163
|
-
})), [parseFloat(
|
|
6465
|
+
return [].concat(_toConsumableArray(_arr2.slice(0, 3).map(function (x) {
|
|
6466
|
+
return parseInt(x, 10);
|
|
6467
|
+
})), [parseFloat(_arr2[3] || '1')]);
|
|
6164
6468
|
}
|
|
6165
6469
|
|
|
6166
|
-
var
|
|
6470
|
+
var hslaMatch = hslaRegex.exec(normalizedColor);
|
|
6167
6471
|
|
|
6168
|
-
if (
|
|
6169
|
-
var _Array$from$slice$map = Array.from(
|
|
6472
|
+
if (hslaMatch) {
|
|
6473
|
+
var _Array$from$slice$map = Array.from(hslaMatch).slice(1).map(parseFloat),
|
|
6170
6474
|
_Array$from$slice$map2 = _slicedToArray(_Array$from$slice$map, 4),
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
if (
|
|
6177
|
-
if (
|
|
6178
|
-
return [].concat(_toConsumableArray(
|
|
6475
|
+
h = _Array$from$slice$map2[0],
|
|
6476
|
+
s = _Array$from$slice$map2[1],
|
|
6477
|
+
l = _Array$from$slice$map2[2],
|
|
6478
|
+
a = _Array$from$slice$map2[3];
|
|
6479
|
+
|
|
6480
|
+
if (guard(0, 100, s) !== s) throw new ColorError$1(color);
|
|
6481
|
+
if (guard(0, 100, l) !== l) throw new ColorError$1(color);
|
|
6482
|
+
return [].concat(_toConsumableArray(hslToRgb(h, s, l)), [a || 1]);
|
|
6179
6483
|
}
|
|
6180
6484
|
|
|
6181
|
-
throw new
|
|
6485
|
+
throw new ColorError$1(color);
|
|
6182
6486
|
}
|
|
6183
6487
|
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
o = "1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm".split(" ").reduce(function (t, n) {
|
|
6188
|
-
var r = e(n.substring(0, 3)),
|
|
6189
|
-
o = e(n.substring(3)).toString(16);
|
|
6190
|
-
var _ = "";
|
|
6488
|
+
function hash(str) {
|
|
6489
|
+
var hash = 5381;
|
|
6490
|
+
var i = str.length;
|
|
6191
6491
|
|
|
6192
|
-
|
|
6193
|
-
|
|
6492
|
+
while (i) {
|
|
6493
|
+
hash = hash * 33 ^ str.charCodeAt(--i);
|
|
6194
6494
|
}
|
|
6495
|
+
/* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
|
|
6496
|
+
* integers. Since we want the results to be always positive, convert the
|
|
6497
|
+
* signed int to an unsigned by doing an unsigned bitshift. */
|
|
6195
6498
|
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
},
|
|
6203
|
-
s = new RegExp("^#".concat(_("([a-f0-9])", 3), "([a-f0-9])?$"), "i"),
|
|
6204
|
-
i = new RegExp("^#".concat(_("([a-f0-9]{2})", 3), "([a-f0-9]{2})?$"), "i"),
|
|
6205
|
-
a = new RegExp("^rgba?\\(\\s*(\\d+)\\s*".concat(_(",\\s*(\\d+)\\s*", 2), "(?:,\\s*([\\d.]+))?\\s*\\)$"), "i"),
|
|
6206
|
-
c = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i,
|
|
6207
|
-
u = /^[a-z]+$/i,
|
|
6208
|
-
f = function f(t) {
|
|
6209
|
-
return Math.round(255 * t);
|
|
6210
|
-
},
|
|
6211
|
-
l = function l(t, n, r) {
|
|
6212
|
-
var e = r / 100;
|
|
6213
|
-
if (0 === n) return [e, e, e].map(f);
|
|
6214
|
-
|
|
6215
|
-
var o = (t % 360 + 360) % 360 / 60,
|
|
6216
|
-
_ = (1 - Math.abs(2 * e - 1)) * (n / 100),
|
|
6217
|
-
s = _ * (1 - Math.abs(o % 2 - 1));
|
|
6218
|
-
|
|
6219
|
-
var i = 0,
|
|
6220
|
-
a = 0,
|
|
6221
|
-
c = 0;
|
|
6222
|
-
o >= 0 && o < 1 ? (i = _, a = s) : o >= 1 && o < 2 ? (i = s, a = _) : o >= 2 && o < 3 ? (a = _, c = s) : o >= 3 && o < 4 ? (a = s, c = _) : o >= 4 && o < 5 ? (i = s, c = _) : o >= 5 && o < 6 && (i = _, c = s);
|
|
6223
|
-
var u = e - _ / 2;
|
|
6224
|
-
return [i + u, a + u, c + u].map(f);
|
|
6499
|
+
|
|
6500
|
+
return (hash >>> 0) % 2341;
|
|
6501
|
+
}
|
|
6502
|
+
|
|
6503
|
+
var colorToInt = function colorToInt(x) {
|
|
6504
|
+
return parseInt(x.replace(/_/g, ''), 36);
|
|
6225
6505
|
};
|
|
6226
6506
|
|
|
6227
|
-
function
|
|
6228
|
-
|
|
6507
|
+
var compressedColorMap = '1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm'.split(' ').reduce(function (acc, next) {
|
|
6508
|
+
var key = colorToInt(next.substring(0, 3));
|
|
6509
|
+
var hex = colorToInt(next.substring(3)).toString(16); // NOTE: padStart could be used here but it breaks Node 6 compat
|
|
6510
|
+
// https://github.com/ricokahler/color2k/issues/351
|
|
6511
|
+
|
|
6512
|
+
var prefix = '';
|
|
6229
6513
|
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
return n <= .03928 ? n / 12.92 : Math.pow((n + .055) / 1.055, 2.4);
|
|
6514
|
+
for (var i = 0; i < 6 - hex.length; i++) {
|
|
6515
|
+
prefix += '0';
|
|
6233
6516
|
}
|
|
6234
6517
|
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6518
|
+
acc[key] = "".concat(prefix).concat(hex);
|
|
6519
|
+
return acc;
|
|
6520
|
+
}, {});
|
|
6521
|
+
/**
|
|
6522
|
+
* Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.
|
|
6523
|
+
*/
|
|
6240
6524
|
|
|
6241
|
-
|
|
6525
|
+
function nameToHex(color) {
|
|
6526
|
+
var normalizedColorName = color.toLowerCase().trim();
|
|
6527
|
+
var result = compressedColorMap[hash(normalizedColorName)];
|
|
6528
|
+
if (!result) throw new ColorError$1(color);
|
|
6529
|
+
return "#".concat(result);
|
|
6242
6530
|
}
|
|
6243
6531
|
|
|
6244
|
-
function
|
|
6245
|
-
return
|
|
6532
|
+
var r = function r(str, amount) {
|
|
6533
|
+
return Array.from(Array(amount)).map(function () {
|
|
6534
|
+
return str;
|
|
6535
|
+
}).join('');
|
|
6536
|
+
};
|
|
6537
|
+
|
|
6538
|
+
var reducedHexRegex = new RegExp("^#".concat(r('([a-f0-9])', 3), "([a-f0-9])?$"), 'i');
|
|
6539
|
+
var hexRegex = new RegExp("^#".concat(r('([a-f0-9]{2})', 3), "([a-f0-9]{2})?$"), 'i');
|
|
6540
|
+
var rgbaRegex = new RegExp("^rgba?\\(\\s*(\\d+)\\s*".concat(r(',\\s*(\\d+)\\s*', 2), "(?:,\\s*([\\d.]+))?\\s*\\)$"), 'i');
|
|
6541
|
+
var hslaRegex = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i;
|
|
6542
|
+
var namedColorRegex = /^[a-z]+$/i;
|
|
6543
|
+
|
|
6544
|
+
var roundColor = function roundColor(color) {
|
|
6545
|
+
return Math.round(color * 255);
|
|
6546
|
+
};
|
|
6547
|
+
|
|
6548
|
+
var hslToRgb = function hslToRgb(hue, saturation, lightness) {
|
|
6549
|
+
var l = lightness / 100;
|
|
6550
|
+
|
|
6551
|
+
if (saturation === 0) {
|
|
6552
|
+
// achromatic
|
|
6553
|
+
return [l, l, l].map(roundColor);
|
|
6554
|
+
} // formulae from https://en.wikipedia.org/wiki/HSL_and_HSV
|
|
6555
|
+
|
|
6556
|
+
|
|
6557
|
+
var huePrime = (hue % 360 + 360) % 360 / 60;
|
|
6558
|
+
var chroma = (1 - Math.abs(2 * l - 1)) * (saturation / 100);
|
|
6559
|
+
var secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
|
|
6560
|
+
var red = 0;
|
|
6561
|
+
var green = 0;
|
|
6562
|
+
var blue = 0;
|
|
6563
|
+
|
|
6564
|
+
if (huePrime >= 0 && huePrime < 1) {
|
|
6565
|
+
red = chroma;
|
|
6566
|
+
green = secondComponent;
|
|
6567
|
+
} else if (huePrime >= 1 && huePrime < 2) {
|
|
6568
|
+
red = secondComponent;
|
|
6569
|
+
green = chroma;
|
|
6570
|
+
} else if (huePrime >= 2 && huePrime < 3) {
|
|
6571
|
+
green = chroma;
|
|
6572
|
+
blue = secondComponent;
|
|
6573
|
+
} else if (huePrime >= 3 && huePrime < 4) {
|
|
6574
|
+
green = secondComponent;
|
|
6575
|
+
blue = chroma;
|
|
6576
|
+
} else if (huePrime >= 4 && huePrime < 5) {
|
|
6577
|
+
red = secondComponent;
|
|
6578
|
+
blue = chroma;
|
|
6579
|
+
} else if (huePrime >= 5 && huePrime < 6) {
|
|
6580
|
+
red = chroma;
|
|
6581
|
+
blue = secondComponent;
|
|
6582
|
+
}
|
|
6583
|
+
|
|
6584
|
+
var lightnessModification = l - chroma / 2;
|
|
6585
|
+
var finalRed = red + lightnessModification;
|
|
6586
|
+
var finalGreen = green + lightnessModification;
|
|
6587
|
+
var finalBlue = blue + lightnessModification;
|
|
6588
|
+
return [finalRed, finalGreen, finalBlue].map(roundColor);
|
|
6589
|
+
}; // taken from:
|
|
6590
|
+
|
|
6591
|
+
/**
|
|
6592
|
+
* Returns a number (float) representing the luminance of a color.
|
|
6593
|
+
*/
|
|
6594
|
+
|
|
6595
|
+
|
|
6596
|
+
function getLuminance(color) {
|
|
6597
|
+
if (color === 'transparent') return 0;
|
|
6598
|
+
|
|
6599
|
+
function f(x) {
|
|
6600
|
+
var channel = x / 255;
|
|
6601
|
+
return channel <= 0.03928 ? channel / 12.92 : Math.pow((channel + 0.055) / 1.055, 2.4);
|
|
6602
|
+
}
|
|
6603
|
+
|
|
6604
|
+
var _parseToRgba = parseToRgba(color),
|
|
6605
|
+
_parseToRgba2 = _slicedToArray(_parseToRgba, 3),
|
|
6606
|
+
r = _parseToRgba2[0],
|
|
6607
|
+
g = _parseToRgba2[1],
|
|
6608
|
+
b = _parseToRgba2[2];
|
|
6609
|
+
|
|
6610
|
+
return 0.2126 * f(r) + 0.7152 * f(g) + 0.0722 * f(b);
|
|
6611
|
+
} // taken from:
|
|
6612
|
+
/**
|
|
6613
|
+
* An alternative function to `readableColor`. Returns whether or not the
|
|
6614
|
+
* readable color (i.e. the color to be place on top the input color) should be
|
|
6615
|
+
* black.
|
|
6616
|
+
*/
|
|
6617
|
+
|
|
6618
|
+
|
|
6619
|
+
function readableColorIsBlack(color) {
|
|
6620
|
+
return getLuminance(color) > 0.179;
|
|
6246
6621
|
}
|
|
6247
6622
|
|
|
6248
6623
|
var _excluded$1 = ["pos"];
|
|
@@ -6263,39 +6638,39 @@ var Cursor = function Cursor(_ref3) {
|
|
|
6263
6638
|
_ref3$size = _ref3.size,
|
|
6264
6639
|
size = _ref3$size === void 0 ? 40 : _ref3$size,
|
|
6265
6640
|
text = _ref3.text;
|
|
6266
|
-
var textColor =
|
|
6267
|
-
return /*#__PURE__*/
|
|
6641
|
+
var textColor = readableColorIsBlack(color) ? "#222" : "#EEE";
|
|
6642
|
+
return /*#__PURE__*/React__default.createElement(StyledCursor, null, /*#__PURE__*/React__default.createElement("svg", {
|
|
6268
6643
|
version: "1.1",
|
|
6269
6644
|
id: "Layer_1",
|
|
6270
6645
|
xmlns: "http://www.w3.org/2000/svg",
|
|
6271
6646
|
viewBox: "1064.7701 445.5539 419.8101 717.0565",
|
|
6272
6647
|
width: size,
|
|
6273
6648
|
height: size
|
|
6274
|
-
}, /*#__PURE__*/
|
|
6649
|
+
}, /*#__PURE__*/React__default.createElement("path", {
|
|
6275
6650
|
d: "m 1197.1015,869.718 -62.2719,-154.49286 133.3276,-9.05842 -257.6915,-253.12748 1.2392,356.98609 88.2465,-79.47087 61.702,152.78366 z",
|
|
6276
6651
|
style: {
|
|
6277
6652
|
fill: textColor
|
|
6278
6653
|
}
|
|
6279
|
-
}), /*#__PURE__*/
|
|
6654
|
+
}), /*#__PURE__*/React__default.createElement("path", {
|
|
6280
6655
|
d: "m 1193.0939,861.12419 -62.2719,-154.49286 133.3276,-9.05842 -257.6915,-253.12748 1.2392,356.98609 88.2465,-79.47087 61.702,152.78366 z",
|
|
6281
6656
|
style: {
|
|
6282
6657
|
fill: "white",
|
|
6283
6658
|
stroke: "#111",
|
|
6284
6659
|
strokeWidth: 20
|
|
6285
6660
|
}
|
|
6286
|
-
})), /*#__PURE__*/
|
|
6661
|
+
})), /*#__PURE__*/React__default.createElement(CursorName, {
|
|
6287
6662
|
color: color,
|
|
6288
6663
|
textColor: textColor
|
|
6289
6664
|
}, text));
|
|
6290
6665
|
};
|
|
6291
6666
|
|
|
6292
|
-
var MemoizedCursor = /*#__PURE__*/
|
|
6667
|
+
var MemoizedCursor = /*#__PURE__*/React__default.memo(Cursor);
|
|
6293
6668
|
|
|
6294
6669
|
var PositionnedCursor = function PositionnedCursor(_ref4) {
|
|
6295
6670
|
var pos = _ref4.pos,
|
|
6296
6671
|
rest = _objectWithoutProperties(_ref4, _excluded$1);
|
|
6297
6672
|
|
|
6298
|
-
return /*#__PURE__*/
|
|
6673
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
6299
6674
|
style: {
|
|
6300
6675
|
transform: "translate(".concat(pos.x - 5, "px, ").concat(pos.y - 3, "px)"),
|
|
6301
6676
|
top: 0,
|
|
@@ -6304,7 +6679,7 @@ var PositionnedCursor = function PositionnedCursor(_ref4) {
|
|
|
6304
6679
|
position: "fixed",
|
|
6305
6680
|
pointerEvents: "none"
|
|
6306
6681
|
}
|
|
6307
|
-
}, /*#__PURE__*/
|
|
6682
|
+
}, /*#__PURE__*/React__default.createElement(MemoizedCursor, rest));
|
|
6308
6683
|
};
|
|
6309
6684
|
|
|
6310
6685
|
var Cursors = function Cursors(_ref) {
|
|
@@ -6313,20 +6688,20 @@ var Cursors = function Cursors(_ref) {
|
|
|
6313
6688
|
var _useWire = useWire("board"),
|
|
6314
6689
|
wire = _useWire.wire;
|
|
6315
6690
|
|
|
6316
|
-
var _React$useState =
|
|
6691
|
+
var _React$useState = React__default.useState({}),
|
|
6317
6692
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
6318
6693
|
cursors = _React$useState2[0],
|
|
6319
6694
|
setCursors = _React$useState2[1];
|
|
6320
6695
|
|
|
6321
|
-
var preventRef =
|
|
6322
|
-
var usersById =
|
|
6696
|
+
var preventRef = React__default.useRef(false);
|
|
6697
|
+
var usersById = React__default.useMemo(function () {
|
|
6323
6698
|
return users.reduce(function (acc, user) {
|
|
6324
6699
|
acc[user.id] = user;
|
|
6325
6700
|
return acc;
|
|
6326
6701
|
}, {});
|
|
6327
6702
|
}, [users]); // Prevent race condition when removing user
|
|
6328
6703
|
|
|
6329
|
-
var currentCursor =
|
|
6704
|
+
var currentCursor = React__default.useMemo(function () {
|
|
6330
6705
|
return users.reduce(function (acc, user) {
|
|
6331
6706
|
if (cursors[user.id]) {
|
|
6332
6707
|
acc[user.id] = cursors[user.id];
|
|
@@ -6335,7 +6710,7 @@ var Cursors = function Cursors(_ref) {
|
|
|
6335
6710
|
return acc;
|
|
6336
6711
|
}, {});
|
|
6337
6712
|
}, [users, cursors]);
|
|
6338
|
-
|
|
6713
|
+
React__default.useEffect(function () {
|
|
6339
6714
|
setCursors(function (prevCursors) {
|
|
6340
6715
|
return users.reduce(function (acc, user) {
|
|
6341
6716
|
if (prevCursors[user.id]) {
|
|
@@ -6346,7 +6721,7 @@ var Cursors = function Cursors(_ref) {
|
|
|
6346
6721
|
}, {});
|
|
6347
6722
|
});
|
|
6348
6723
|
}, [users]);
|
|
6349
|
-
|
|
6724
|
+
React__default.useEffect(function () {
|
|
6350
6725
|
var unsub = [];
|
|
6351
6726
|
unsub.push(wire.subscribe("cursorMove", function (_ref2) {
|
|
6352
6727
|
var userId = _ref2.userId,
|
|
@@ -6377,12 +6752,12 @@ var Cursors = function Cursors(_ref) {
|
|
|
6377
6752
|
});
|
|
6378
6753
|
};
|
|
6379
6754
|
}, [wire]);
|
|
6380
|
-
return /*#__PURE__*/
|
|
6755
|
+
return /*#__PURE__*/React__default.createElement("div", null, Object.entries(currentCursor).map(function (_ref4) {
|
|
6381
6756
|
var _ref5 = _slicedToArray(_ref4, 2),
|
|
6382
6757
|
userId = _ref5[0],
|
|
6383
6758
|
pos = _ref5[1];
|
|
6384
6759
|
|
|
6385
|
-
return /*#__PURE__*/
|
|
6760
|
+
return /*#__PURE__*/React__default.createElement(PositionnedCursor, {
|
|
6386
6761
|
key: userId,
|
|
6387
6762
|
pos: pos,
|
|
6388
6763
|
text: usersById[userId].name,
|
|
@@ -6401,7 +6776,7 @@ var CursorPane = function CursorPane(_ref) {
|
|
|
6401
6776
|
user = _useUsers.currentUser,
|
|
6402
6777
|
users = _useUsers.users;
|
|
6403
6778
|
|
|
6404
|
-
var publish =
|
|
6779
|
+
var publish = React__default.useCallback(function (newPos) {
|
|
6405
6780
|
wire.publish("cursorMove", {
|
|
6406
6781
|
userId: user.id,
|
|
6407
6782
|
pos: newPos
|
|
@@ -6459,33 +6834,33 @@ var CursorPane = function CursorPane(_ref) {
|
|
|
6459
6834
|
});
|
|
6460
6835
|
};
|
|
6461
6836
|
|
|
6462
|
-
return /*#__PURE__*/
|
|
6837
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
6463
6838
|
onPointerMove: onMouseMove,
|
|
6464
6839
|
onPointerLeave: onLeave
|
|
6465
|
-
}, children, /*#__PURE__*/
|
|
6840
|
+
}, children, /*#__PURE__*/React__default.createElement(Cursors, {
|
|
6466
6841
|
users: users
|
|
6467
6842
|
}));
|
|
6468
6843
|
};
|
|
6469
6844
|
|
|
6470
6845
|
var useMousePosition = function useMousePosition(ref) {
|
|
6471
|
-
var mouseRef =
|
|
6846
|
+
var mouseRef = React__default.useRef({
|
|
6472
6847
|
hover: false,
|
|
6473
6848
|
x: 0,
|
|
6474
6849
|
y: 0
|
|
6475
6850
|
});
|
|
6476
|
-
var onMouseMove =
|
|
6851
|
+
var onMouseMove = React__default.useCallback(function (e) {
|
|
6477
6852
|
var clientX = e.clientX,
|
|
6478
6853
|
clientY = e.clientY;
|
|
6479
6854
|
mouseRef.current.x = clientX;
|
|
6480
6855
|
mouseRef.current.y = clientY;
|
|
6481
6856
|
}, []);
|
|
6482
|
-
var onMouseEnter =
|
|
6857
|
+
var onMouseEnter = React__default.useCallback(function () {
|
|
6483
6858
|
mouseRef.current.hover = true;
|
|
6484
6859
|
}, []);
|
|
6485
|
-
var onMouseLeave =
|
|
6860
|
+
var onMouseLeave = React__default.useCallback(function () {
|
|
6486
6861
|
mouseRef.current.hover = false;
|
|
6487
6862
|
}, []);
|
|
6488
|
-
|
|
6863
|
+
React__default.useEffect(function () {
|
|
6489
6864
|
var current = ref.current;
|
|
6490
6865
|
|
|
6491
6866
|
if (current) {
|
|
@@ -6501,7 +6876,7 @@ var useMousePosition = function useMousePosition(ref) {
|
|
|
6501
6876
|
|
|
6502
6877
|
return null; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6503
6878
|
}, [ref, ref.current, onMouseMove, onMouseEnter, onMouseLeave]);
|
|
6504
|
-
var getMouseInfo =
|
|
6879
|
+
var getMouseInfo = React__default.useCallback(function () {
|
|
6505
6880
|
return mouseRef.current;
|
|
6506
6881
|
}, []);
|
|
6507
6882
|
return getMouseInfo;
|
|
@@ -6512,7 +6887,7 @@ var digitCodes = _toConsumableArray(Array(5).keys()).map(function (id) {
|
|
|
6512
6887
|
});
|
|
6513
6888
|
|
|
6514
6889
|
var usePositionNavigator = function usePositionNavigator() {
|
|
6515
|
-
var _React$useState =
|
|
6890
|
+
var _React$useState = React__default.useState({}),
|
|
6516
6891
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
6517
6892
|
positions = _React$useState2[0],
|
|
6518
6893
|
setPositions = _React$useState2[1];
|
|
@@ -6572,7 +6947,7 @@ var usePositionNavigator = function usePositionNavigator() {
|
|
|
6572
6947
|
};
|
|
6573
6948
|
}();
|
|
6574
6949
|
}, [positions]);
|
|
6575
|
-
|
|
6950
|
+
React__default.useEffect(function () {
|
|
6576
6951
|
document.addEventListener("keydown", onKeyDown);
|
|
6577
6952
|
return function () {
|
|
6578
6953
|
document.removeEventListener("keydown", onKeyDown);
|
|
@@ -6587,7 +6962,7 @@ var PanZoom = function PanZoom(_ref) {
|
|
|
6587
6962
|
var children = _ref.children,
|
|
6588
6963
|
_ref$moveFirst = _ref.moveFirst,
|
|
6589
6964
|
moveFirst = _ref$moveFirst === void 0 ? false : _ref$moveFirst;
|
|
6590
|
-
var wrappedRef =
|
|
6965
|
+
var wrappedRef = React__default.useRef(null);
|
|
6591
6966
|
var dim = useRecoilValue(BoardTransformAtom);
|
|
6592
6967
|
|
|
6593
6968
|
var _useDim = useDim(),
|
|
@@ -6597,13 +6972,13 @@ var PanZoom = function PanZoom(_ref) {
|
|
|
6597
6972
|
var _useRecoilValue = useRecoilValue(ConfigurationAtom),
|
|
6598
6973
|
itemExtentGlobal = _useRecoilValue.itemExtent;
|
|
6599
6974
|
|
|
6600
|
-
var _React$useState =
|
|
6975
|
+
var _React$useState = React__default.useState(false),
|
|
6601
6976
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
6602
6977
|
centered = _React$useState2[0],
|
|
6603
6978
|
setCentered = _React$useState2[1];
|
|
6604
6979
|
|
|
6605
6980
|
var setBoardState = useSetRecoilState(BoardStateAtom);
|
|
6606
|
-
var timeoutRef =
|
|
6981
|
+
var timeoutRef = React__default.useRef({}); // Get mouse position and hover status
|
|
6607
6982
|
|
|
6608
6983
|
var getMouseInfo = useMousePosition(wrappedRef); // Hooks to save/restore position
|
|
6609
6984
|
|
|
@@ -6650,14 +7025,14 @@ var PanZoom = function PanZoom(_ref) {
|
|
|
6650
7025
|
}, _callee);
|
|
6651
7026
|
}));
|
|
6652
7027
|
}, [setDim]);
|
|
6653
|
-
|
|
7028
|
+
React__default.useEffect(function () {
|
|
6654
7029
|
if (!centered && itemExtentGlobal.left) {
|
|
6655
7030
|
// Center board on first valid extent
|
|
6656
7031
|
centerBoard();
|
|
6657
7032
|
setCentered(true);
|
|
6658
7033
|
}
|
|
6659
7034
|
}, [centerBoard, centered, itemExtentGlobal]);
|
|
6660
|
-
var onZoom =
|
|
7035
|
+
var onZoom = React__default.useCallback(function (_ref4) {
|
|
6661
7036
|
var clientX = _ref4.clientX,
|
|
6662
7037
|
clientY = _ref4.clientY,
|
|
6663
7038
|
scale = _ref4.scale;
|
|
@@ -6680,7 +7055,7 @@ var PanZoom = function PanZoom(_ref) {
|
|
|
6680
7055
|
}) : prev;
|
|
6681
7056
|
});
|
|
6682
7057
|
}, [setBoardState, zoomTo]);
|
|
6683
|
-
var onPan =
|
|
7058
|
+
var onPan = React__default.useCallback( /*#__PURE__*/function () {
|
|
6684
7059
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_ref5) {
|
|
6685
7060
|
var deltaX, deltaY;
|
|
6686
7061
|
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
@@ -6721,7 +7096,7 @@ var PanZoom = function PanZoom(_ref) {
|
|
|
6721
7096
|
return _ref6.apply(this, arguments);
|
|
6722
7097
|
};
|
|
6723
7098
|
}(), [setBoardState, setDim]);
|
|
6724
|
-
var onDrag =
|
|
7099
|
+
var onDrag = React__default.useCallback(function (state) {
|
|
6725
7100
|
var target = state.target;
|
|
6726
7101
|
var outsideItem = !insideClass(target, "item") || insideClass(target, "locked");
|
|
6727
7102
|
|
|
@@ -6837,7 +7212,7 @@ var PanZoom = function PanZoom(_ref) {
|
|
|
6837
7212
|
};
|
|
6838
7213
|
}();
|
|
6839
7214
|
}, [setDim, zoomTo, getMouseInfo]);
|
|
6840
|
-
var onKeyUp =
|
|
7215
|
+
var onKeyUp = React__default.useCallback(function (e) {
|
|
6841
7216
|
// Ignore text in Input or Textarea
|
|
6842
7217
|
if (["INPUT", "TEXTAREA"].includes(e.target.tagName)) return; // Zoom out on release
|
|
6843
7218
|
|
|
@@ -6845,7 +7220,7 @@ var PanZoom = function PanZoom(_ref) {
|
|
|
6845
7220
|
zoomTo(1 / 3, getMouseInfo());
|
|
6846
7221
|
}
|
|
6847
7222
|
}, [getMouseInfo, zoomTo]);
|
|
6848
|
-
|
|
7223
|
+
React__default.useEffect(function () {
|
|
6849
7224
|
document.addEventListener("keydown", onKeyDown);
|
|
6850
7225
|
document.addEventListener("keyup", onKeyUp);
|
|
6851
7226
|
return function () {
|
|
@@ -6853,11 +7228,11 @@ var PanZoom = function PanZoom(_ref) {
|
|
|
6853
7228
|
document.removeEventListener("keyup", onKeyUp);
|
|
6854
7229
|
};
|
|
6855
7230
|
}, [onKeyDown, onKeyUp]);
|
|
6856
|
-
return /*#__PURE__*/
|
|
7231
|
+
return /*#__PURE__*/React__default.createElement(Gesture, {
|
|
6857
7232
|
onPan: onPan,
|
|
6858
7233
|
onZoom: onZoom,
|
|
6859
7234
|
onDrag: onDrag
|
|
6860
|
-
}, /*#__PURE__*/
|
|
7235
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
6861
7236
|
style: {
|
|
6862
7237
|
display: "inline-block",
|
|
6863
7238
|
transformOrigin: "top left",
|
|
@@ -6957,17 +7332,17 @@ var BoundingBox = function BoundingBox() {
|
|
|
6957
7332
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6958
7333
|
|
|
6959
7334
|
var updateBoxDelay = useDebouncedCallback(updateBox, [updateBox], 300);
|
|
6960
|
-
|
|
7335
|
+
React__default.useEffect(function () {
|
|
6961
7336
|
// Update selected elements bounding box
|
|
6962
7337
|
updateBox();
|
|
6963
7338
|
updateBoxDelay(); // Delay to update after board item animation like tap/untap.
|
|
6964
7339
|
}, [selectedItems, itemMap, boardTransform, updateBox, updateBoxDelay]);
|
|
6965
7340
|
if (!boundingBoxLast || selectedItems.length < 2) return null;
|
|
6966
|
-
return /*#__PURE__*/
|
|
7341
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
6967
7342
|
style: _objectSpread2(_objectSpread2({}, defaultZoneStyle), {}, {
|
|
6968
7343
|
transform: "translate(".concat(boundingBoxLast.left, "px, ").concat(boundingBoxLast.top, "px)"),
|
|
6969
|
-
height: "".concat(boundingBoxLast.height
|
|
6970
|
-
width: "".concat(boundingBoxLast.width
|
|
7344
|
+
height: "".concat(boundingBoxLast.height, "px"),
|
|
7345
|
+
width: "".concat(boundingBoxLast.width, "px")
|
|
6971
7346
|
}),
|
|
6972
7347
|
className: "selection"
|
|
6973
7348
|
});
|
|
@@ -6980,7 +7355,7 @@ var Selection = function Selection() {
|
|
|
6980
7355
|
return null;
|
|
6981
7356
|
}
|
|
6982
7357
|
|
|
6983
|
-
return /*#__PURE__*/
|
|
7358
|
+
return /*#__PURE__*/React__default.createElement(BoundingBox, null);
|
|
6984
7359
|
};
|
|
6985
7360
|
|
|
6986
7361
|
var Board = function Board(_ref) {
|
|
@@ -6991,13 +7366,15 @@ var Board = function Board(_ref) {
|
|
|
6991
7366
|
itemTemplates = _ref$itemTemplates === void 0 ? {} : _ref$itemTemplates,
|
|
6992
7367
|
_ref$boardSize = _ref.boardSize,
|
|
6993
7368
|
boardSize = _ref$boardSize === void 0 ? DEFAULT_BOARD_MAX_SIZE : _ref$boardSize,
|
|
6994
|
-
children = _ref.children
|
|
7369
|
+
children = _ref.children,
|
|
7370
|
+
_ref$showResizeHandle = _ref.showResizeHandle,
|
|
7371
|
+
showResizeHandle = _ref$showResizeHandle === void 0 ? false : _ref$showResizeHandle;
|
|
6995
7372
|
var setConfiguration = useSetRecoilState(ConfigurationAtom);
|
|
6996
7373
|
|
|
6997
7374
|
var _useDim = useDim(),
|
|
6998
7375
|
updateItemExtent = _useDim.updateItemExtent;
|
|
6999
7376
|
|
|
7000
|
-
var boardStyle =
|
|
7377
|
+
var boardStyle = React__default.useMemo(function () {
|
|
7001
7378
|
return _objectSpread2({
|
|
7002
7379
|
userSelect: "none",
|
|
7003
7380
|
width: "".concat(boardSize, "px"),
|
|
@@ -7005,31 +7382,30 @@ var Board = function Board(_ref) {
|
|
|
7005
7382
|
backgroundColor: "#333"
|
|
7006
7383
|
}, style);
|
|
7007
7384
|
}, [boardSize, style]);
|
|
7008
|
-
|
|
7385
|
+
React__default.useEffect(function () {
|
|
7009
7386
|
setConfiguration(function (prev) {
|
|
7010
7387
|
return _objectSpread2(_objectSpread2({}, prev), {}, {
|
|
7011
7388
|
itemTemplates: itemTemplates,
|
|
7012
|
-
boardSize: boardSize
|
|
7389
|
+
boardSize: boardSize,
|
|
7390
|
+
showResizeHandle: showResizeHandle
|
|
7013
7391
|
});
|
|
7014
7392
|
});
|
|
7015
|
-
}, [itemTemplates, setConfiguration, boardSize]);
|
|
7016
|
-
|
|
7393
|
+
}, [itemTemplates, setConfiguration, boardSize, showResizeHandle]);
|
|
7394
|
+
React__default.useEffect(function () {
|
|
7017
7395
|
updateItemExtent();
|
|
7018
7396
|
setTimeout(updateItemExtent, 2000);
|
|
7019
7397
|
}, [updateItemExtent]);
|
|
7020
|
-
return /*#__PURE__*/
|
|
7398
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(SubcribeItemEvents, null), /*#__PURE__*/React__default.createElement(PanZoom, {
|
|
7021
7399
|
moveFirst: moveFirst
|
|
7022
|
-
}, /*#__PURE__*/
|
|
7400
|
+
}, /*#__PURE__*/React__default.createElement(Selector, {
|
|
7023
7401
|
moveFirst: moveFirst
|
|
7024
|
-
}, /*#__PURE__*/
|
|
7402
|
+
}, /*#__PURE__*/React__default.createElement(ActionPane, null, /*#__PURE__*/React__default.createElement(CursorPane, null, /*#__PURE__*/React__default.createElement("div", {
|
|
7025
7403
|
onContextMenu: function onContextMenu(e) {
|
|
7026
7404
|
e.preventDefault();
|
|
7027
7405
|
},
|
|
7028
7406
|
style: boardStyle,
|
|
7029
7407
|
className: "board"
|
|
7030
|
-
}, /*#__PURE__*/
|
|
7031
|
-
itemTemplates: itemTemplates
|
|
7032
|
-
}), children))))), /*#__PURE__*/React.createElement(Selection, null));
|
|
7408
|
+
}, /*#__PURE__*/React__default.createElement(ItemList, null), children))))), /*#__PURE__*/React__default.createElement(Selection, null));
|
|
7033
7409
|
};
|
|
7034
7410
|
|
|
7035
7411
|
var TOLERANCE = 100;
|
|
@@ -7061,7 +7437,7 @@ var translateBoundaries = function translateBoundaries(_ref) {
|
|
|
7061
7437
|
|
|
7062
7438
|
var useDim = function useDim() {
|
|
7063
7439
|
var setDim = useSetRecoilState(BoardTransformAtom);
|
|
7064
|
-
var scaleBoundariesRef =
|
|
7440
|
+
var scaleBoundariesRef = React__default.useRef([0.1, 8]);
|
|
7065
7441
|
|
|
7066
7442
|
var _useRecoilValue = useRecoilValue(ConfigurationAtom),
|
|
7067
7443
|
itemExtentGlobal = _useRecoilValue.itemExtent;
|
|
@@ -7373,7 +7749,7 @@ var useDim = function useDim() {
|
|
|
7373
7749
|
}));
|
|
7374
7750
|
}, []);
|
|
7375
7751
|
var debouncedUpdateItemExtent = useDebouncedCallback(updateItemExtent, [], 300);
|
|
7376
|
-
|
|
7752
|
+
React__default.useEffect(function () {
|
|
7377
7753
|
if (itemExtentGlobal.left) {
|
|
7378
7754
|
updateScaleBoundaries();
|
|
7379
7755
|
}
|
|
@@ -7389,7 +7765,7 @@ var useDim = function useDim() {
|
|
|
7389
7765
|
|
|
7390
7766
|
var useItemInteraction = function useItemInteraction(interaction) {
|
|
7391
7767
|
var setInteractions = useSetRecoilState(ItemInteractionsAtom);
|
|
7392
|
-
var register =
|
|
7768
|
+
var register = React__default.useCallback(function (callback) {
|
|
7393
7769
|
setInteractions(function (prev) {
|
|
7394
7770
|
var newInter = Array.isArray(prev[interaction]) ? [].concat(_toConsumableArray(prev[interaction]), [callback]) : [callback];
|
|
7395
7771
|
return _objectSpread2(_objectSpread2({}, prev), {}, _defineProperty({}, interaction, newInter));
|
|
@@ -7524,7 +7900,7 @@ var useItemActions = function useItemActions() {
|
|
|
7524
7900
|
};
|
|
7525
7901
|
}();
|
|
7526
7902
|
}, [setItemMap, updateItemExtent, wire]);
|
|
7527
|
-
var setItemListFull =
|
|
7903
|
+
var setItemListFull = React__default.useCallback(function (items) {
|
|
7528
7904
|
setItemMap(items.reduce(function (acc, item) {
|
|
7529
7905
|
if (item && item.id) {
|
|
7530
7906
|
acc[item.id] = item;
|
|
@@ -7540,11 +7916,11 @@ var useItemActions = function useItemActions() {
|
|
|
7540
7916
|
setSelectItems([]);
|
|
7541
7917
|
updateItemExtent();
|
|
7542
7918
|
}, [setItemList, setItemMap, setSelectItems, updateItemExtent]);
|
|
7543
|
-
var updateItem =
|
|
7919
|
+
var updateItem = React__default.useCallback(function (id, callbackOrItem) {
|
|
7544
7920
|
var sync = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
7545
7921
|
batchUpdateItems([id], callbackOrItem, sync);
|
|
7546
7922
|
}, [batchUpdateItems]);
|
|
7547
|
-
var moveItems =
|
|
7923
|
+
var moveItems = React__default.useCallback(function (itemIds, posDelta) {
|
|
7548
7924
|
var sync = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
7549
7925
|
setItemMap(function (prevItemMap) {
|
|
7550
7926
|
var result = _objectSpread2({}, prevItemMap);
|
|
@@ -7574,7 +7950,7 @@ var useItemActions = function useItemActions() {
|
|
|
7574
7950
|
|
|
7575
7951
|
updateItemExtent();
|
|
7576
7952
|
}, [setItemMap, updateItemExtent, wire]);
|
|
7577
|
-
var putItemsOnTop =
|
|
7953
|
+
var putItemsOnTop = React__default.useCallback(function (itemIdsToMove) {
|
|
7578
7954
|
var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
7579
7955
|
setItemList(function (prevItemList) {
|
|
7580
7956
|
var filtered = prevItemList.filter(function (id) {
|
|
@@ -7738,7 +8114,7 @@ var useItemActions = function useItemActions() {
|
|
|
7738
8114
|
};
|
|
7739
8115
|
}();
|
|
7740
8116
|
}, [wire, setItemMap]);
|
|
7741
|
-
var placeItems =
|
|
8117
|
+
var placeItems = React__default.useCallback( /*#__PURE__*/function () {
|
|
7742
8118
|
var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(itemIds, gridConfig) {
|
|
7743
8119
|
var sync,
|
|
7744
8120
|
_args3 = arguments;
|
|
@@ -7772,7 +8148,7 @@ var useItemActions = function useItemActions() {
|
|
|
7772
8148
|
return _ref8.apply(this, arguments);
|
|
7773
8149
|
};
|
|
7774
8150
|
}(), [batchUpdateItems, callPlaceInteractions, putItemsOnTop, stickOnGrid, updateItemExtent]);
|
|
7775
|
-
var updateItemOrder =
|
|
8151
|
+
var updateItemOrder = React__default.useCallback(function (newOrder) {
|
|
7776
8152
|
var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
7777
8153
|
setItemList(newOrder);
|
|
7778
8154
|
|
|
@@ -7780,7 +8156,7 @@ var useItemActions = function useItemActions() {
|
|
|
7780
8156
|
wire.publish("updateItemListOrder", newOrder);
|
|
7781
8157
|
}
|
|
7782
8158
|
}, [wire, setItemList]);
|
|
7783
|
-
var reverseItemsOrder =
|
|
8159
|
+
var reverseItemsOrder = React__default.useCallback(function (itemIdsToReverse) {
|
|
7784
8160
|
var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
7785
8161
|
setItemList(function (prevItemList) {
|
|
7786
8162
|
var toBeReversed = prevItemList.filter(function (id) {
|
|
@@ -7894,7 +8270,7 @@ var useItemActions = function useItemActions() {
|
|
|
7894
8270
|
};
|
|
7895
8271
|
}();
|
|
7896
8272
|
}, [wire, setItemList, setItemMap]);
|
|
7897
|
-
var pushItems =
|
|
8273
|
+
var pushItems = React__default.useCallback( /*#__PURE__*/function () {
|
|
7898
8274
|
var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(itemsToInsert, beforeId) {
|
|
7899
8275
|
var sync,
|
|
7900
8276
|
_args6 = arguments;
|
|
@@ -7970,11 +8346,11 @@ var useItemActions = function useItemActions() {
|
|
|
7970
8346
|
return _ref11.apply(this, arguments);
|
|
7971
8347
|
};
|
|
7972
8348
|
}(), [updateItemExtent, getCenter, setItemMap, setItemList, wire]);
|
|
7973
|
-
var pushItem =
|
|
8349
|
+
var pushItem = React__default.useCallback(function (itemToInsert, beforeId) {
|
|
7974
8350
|
var sync = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
7975
8351
|
pushItems([itemToInsert], beforeId, sync);
|
|
7976
8352
|
}, [pushItems]);
|
|
7977
|
-
var removeItems =
|
|
8353
|
+
var removeItems = React__default.useCallback(function (itemsIdToRemove) {
|
|
7978
8354
|
var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
7979
8355
|
// Remove from selected items first
|
|
7980
8356
|
setSelectItems(function (prevList) {
|
|
@@ -8337,17 +8713,26 @@ var getActionsFromItem = function getActionsFromItem(item, itemMap) {
|
|
|
8337
8713
|
};
|
|
8338
8714
|
|
|
8339
8715
|
var useAvailableActions = function useAvailableActions() {
|
|
8716
|
+
var itemMap = useRecoilValue(ItemMapAtom);
|
|
8717
|
+
|
|
8340
8718
|
var _useRecoilValue = useRecoilValue(ConfigurationAtom),
|
|
8341
|
-
|
|
8719
|
+
itemTemplates = _useRecoilValue.itemTemplates;
|
|
8342
8720
|
|
|
8343
8721
|
var selected = useRecoilValue(SelectedItemsAtom);
|
|
8344
8722
|
|
|
8345
|
-
var _React$useState =
|
|
8723
|
+
var _React$useState = React__default.useState([]),
|
|
8346
8724
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
8347
8725
|
availableActions = _React$useState2[0],
|
|
8348
8726
|
setAvailableActions = _React$useState2[1];
|
|
8349
8727
|
|
|
8350
|
-
var isMountedRef =
|
|
8728
|
+
var isMountedRef = React__default.useRef(false);
|
|
8729
|
+
React__default.useEffect(function () {
|
|
8730
|
+
// Mounted guard
|
|
8731
|
+
isMountedRef.current = true;
|
|
8732
|
+
return function () {
|
|
8733
|
+
isMountedRef.current = false;
|
|
8734
|
+
};
|
|
8735
|
+
}, []);
|
|
8351
8736
|
var getItemListOrSelected = useRecoilCallback(function (_ref) {
|
|
8352
8737
|
var snapshot = _ref.snapshot;
|
|
8353
8738
|
return /*#__PURE__*/function () {
|
|
@@ -8395,19 +8780,12 @@ var useAvailableActions = function useAvailableActions() {
|
|
|
8395
8780
|
};
|
|
8396
8781
|
}();
|
|
8397
8782
|
}, []);
|
|
8398
|
-
React.useEffect(function () {
|
|
8399
|
-
// Mounted guard
|
|
8400
|
-
isMountedRef.current = true;
|
|
8401
|
-
return function () {
|
|
8402
|
-
isMountedRef.current = false;
|
|
8403
|
-
};
|
|
8404
|
-
}, []);
|
|
8405
8783
|
/**
|
|
8406
8784
|
* Returns available actions for selected items. An action is kept only if all
|
|
8407
8785
|
* items have this exact same action with same parameters.
|
|
8408
8786
|
*/
|
|
8409
8787
|
|
|
8410
|
-
var updateAvailableActions =
|
|
8788
|
+
var updateAvailableActions = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
8411
8789
|
var _yield$getItemListOrS, _yield$getItemListOrS2, selectedItemIds, selectedItemList, allActions;
|
|
8412
8790
|
|
|
8413
8791
|
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
@@ -8437,13 +8815,13 @@ var useAvailableActions = function useAvailableActions() {
|
|
|
8437
8815
|
|
|
8438
8816
|
case 9:
|
|
8439
8817
|
allActions = selectedItemList.reduce(function (acc, item) {
|
|
8440
|
-
var itemActions = getActionsFromItem(item,
|
|
8818
|
+
var itemActions = getActionsFromItem(item, itemTemplates);
|
|
8441
8819
|
return acc.filter(function (value) {
|
|
8442
8820
|
return itemActions.some(function (itemAction) {
|
|
8443
8821
|
return es6(value, itemAction);
|
|
8444
8822
|
});
|
|
8445
8823
|
});
|
|
8446
|
-
}, getActionsFromItem(selectedItemList[0],
|
|
8824
|
+
}, getActionsFromItem(selectedItemList[0], itemTemplates));
|
|
8447
8825
|
setAvailableActions(allActions);
|
|
8448
8826
|
_context2.next = 14;
|
|
8449
8827
|
break;
|
|
@@ -8457,11 +8835,11 @@ var useAvailableActions = function useAvailableActions() {
|
|
|
8457
8835
|
}
|
|
8458
8836
|
}
|
|
8459
8837
|
}, _callee2);
|
|
8460
|
-
})), [getItemListOrSelected,
|
|
8838
|
+
})), [getItemListOrSelected, itemTemplates]); // Update available actions when selection change
|
|
8839
|
+
|
|
8840
|
+
React__default.useEffect(updateAvailableActions, [updateAvailableActions, selected]); // Debounced update available actions when items change
|
|
8461
8841
|
|
|
8462
|
-
|
|
8463
|
-
updateAvailableActions();
|
|
8464
|
-
}, [updateAvailableActions, selected]);
|
|
8842
|
+
useDebouncedEffect(updateAvailableActions, [itemMap, updateAvailableActions], 300);
|
|
8465
8843
|
return {
|
|
8466
8844
|
availableActions: availableActions
|
|
8467
8845
|
};
|
|
@@ -8483,7 +8861,7 @@ var useBoardConfig = function useBoardConfig() {
|
|
|
8483
8861
|
var debouncedPublishUpdate = useDebouncedCallback(function (newConfig) {
|
|
8484
8862
|
wire.publish("updateBoardConfig", newConfig);
|
|
8485
8863
|
}, [wire], 1000);
|
|
8486
|
-
var setSyncBoardConfig =
|
|
8864
|
+
var setSyncBoardConfig = React__default.useCallback(function (callbackOrConfig) {
|
|
8487
8865
|
var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
8488
8866
|
var callback = callbackOrConfig;
|
|
8489
8867
|
|
|
@@ -8580,22 +8958,29 @@ var dayjs_min = {exports: {}};
|
|
|
8580
8958
|
return void 0 === t;
|
|
8581
8959
|
}
|
|
8582
8960
|
},
|
|
8583
|
-
|
|
8584
|
-
|
|
8961
|
+
v = "en",
|
|
8962
|
+
D = {};
|
|
8585
8963
|
|
|
8586
|
-
v
|
|
8964
|
+
D[v] = M;
|
|
8587
8965
|
|
|
8588
8966
|
var p = function p(t) {
|
|
8589
8967
|
return t instanceof _;
|
|
8590
8968
|
},
|
|
8591
|
-
S = function
|
|
8592
|
-
var
|
|
8593
|
-
if (!
|
|
8594
|
-
|
|
8595
|
-
|
|
8596
|
-
|
|
8969
|
+
S = function t(e, n, r) {
|
|
8970
|
+
var i;
|
|
8971
|
+
if (!e) return v;
|
|
8972
|
+
|
|
8973
|
+
if ("string" == typeof e) {
|
|
8974
|
+
var s = e.toLowerCase();
|
|
8975
|
+
D[s] && (i = s), n && (D[s] = n, i = s);
|
|
8976
|
+
var u = e.split("-");
|
|
8977
|
+
if (!i && u.length > 1) return t(u[0]);
|
|
8978
|
+
} else {
|
|
8979
|
+
var a = e.name;
|
|
8980
|
+
D[a] = e, i = a;
|
|
8597
8981
|
}
|
|
8598
|
-
|
|
8982
|
+
|
|
8983
|
+
return !r && i && (v = i), i || !r && v;
|
|
8599
8984
|
},
|
|
8600
8985
|
w = function w(t, e) {
|
|
8601
8986
|
if (p(t)) return t.clone();
|
|
@@ -8683,9 +9068,9 @@ var dayjs_min = {exports: {}};
|
|
|
8683
9068
|
return r ? $(1, M) : $(0, M + 1);
|
|
8684
9069
|
|
|
8685
9070
|
case o:
|
|
8686
|
-
var
|
|
8687
|
-
|
|
8688
|
-
return $(r ? m -
|
|
9071
|
+
var v = this.$locale().weekStart || 0,
|
|
9072
|
+
D = (y < v ? y + 7 : y) - v;
|
|
9073
|
+
return $(r ? m - D : m + (6 - D), M);
|
|
8689
9074
|
|
|
8690
9075
|
case a:
|
|
8691
9076
|
case d:
|
|
@@ -8802,12 +9187,12 @@ var dayjs_min = {exports: {}};
|
|
|
8802
9187
|
M = w(r),
|
|
8803
9188
|
m = (M.utcOffset() - this.utcOffset()) * e,
|
|
8804
9189
|
g = this - M,
|
|
8805
|
-
|
|
8806
|
-
return
|
|
9190
|
+
v = O.m(this, M);
|
|
9191
|
+
return v = (l = {}, l[c] = v / 12, l[f] = v, l[h] = v / 3, l[o] = (g - m) / 6048e5, l[a] = (g - m) / 864e5, l[u] = g / n, l[s] = g / e, l[i] = g / t, l)[y] || g, $ ? v : O.a(v);
|
|
8807
9192
|
}, m.daysInMonth = function () {
|
|
8808
9193
|
return this.endOf(f).$D;
|
|
8809
9194
|
}, m.$locale = function () {
|
|
8810
|
-
return
|
|
9195
|
+
return D[this.$L];
|
|
8811
9196
|
}, m.locale = function (t, e) {
|
|
8812
9197
|
if (!t) return this.$L;
|
|
8813
9198
|
var n = this.clone(),
|
|
@@ -8835,7 +9220,7 @@ var dayjs_min = {exports: {}};
|
|
|
8835
9220
|
return t.$i || (t(e, _, w), t.$i = !0), w;
|
|
8836
9221
|
}, w.locale = S, w.isDayjs = p, w.unix = function (t) {
|
|
8837
9222
|
return w(1e3 * t);
|
|
8838
|
-
}, w.en = v
|
|
9223
|
+
}, w.en = D[v], w.Ls = D, w.p = {}, w;
|
|
8839
9224
|
});
|
|
8840
9225
|
})(dayjs_min);
|
|
8841
9226
|
|
|
@@ -8920,12 +9305,12 @@ var useMessage = function useMessage() {
|
|
|
8920
9305
|
}, _callee);
|
|
8921
9306
|
}));
|
|
8922
9307
|
}, []);
|
|
8923
|
-
var setMessages =
|
|
9308
|
+
var setMessages = React__default.useCallback(function (newMessages) {
|
|
8924
9309
|
setMessagesState(newMessages.map(function (m) {
|
|
8925
9310
|
return parseMessage(m);
|
|
8926
9311
|
}));
|
|
8927
9312
|
}, [setMessagesState]);
|
|
8928
|
-
var initEvents =
|
|
9313
|
+
var initEvents = React__default.useCallback(function (unsub) {
|
|
8929
9314
|
unsub.push(wire.subscribe("newMessage", function (newMessage) {
|
|
8930
9315
|
setMessagesState(function (prevMessages) {
|
|
8931
9316
|
return [].concat(_toConsumableArray(prevMessages), [parseMessage(newMessage)]);
|
|
@@ -8945,7 +9330,7 @@ var useMessage = function useMessage() {
|
|
|
8945
9330
|
|
|
8946
9331
|
return unsub;
|
|
8947
9332
|
}, [wire, getMessage, isMaster, onMessage, setMessages, setMessagesState]);
|
|
8948
|
-
|
|
9333
|
+
React__default.useEffect(function () {
|
|
8949
9334
|
var unsub = [];
|
|
8950
9335
|
|
|
8951
9336
|
if (subscribeEvents) {
|
|
@@ -8958,7 +9343,7 @@ var useMessage = function useMessage() {
|
|
|
8958
9343
|
});
|
|
8959
9344
|
};
|
|
8960
9345
|
}, [initEvents, subscribeEvents]);
|
|
8961
|
-
var sendMessage =
|
|
9346
|
+
var sendMessage = React__default.useCallback(function (messageContent) {
|
|
8962
9347
|
var newMessage = generateMsg({
|
|
8963
9348
|
user: currentUser,
|
|
8964
9349
|
content: messageContent
|
|
@@ -8980,7 +9365,7 @@ var StyledBoardView = newStyled.div(_templateObject || (_templateObject = _tagge
|
|
|
8980
9365
|
var SyncBoard = function SyncBoard(_ref) {
|
|
8981
9366
|
var children = _ref.children,
|
|
8982
9367
|
style = _ref.style;
|
|
8983
|
-
var boardWrapperRef =
|
|
9368
|
+
var boardWrapperRef = React__default.useRef(null);
|
|
8984
9369
|
var setCurrentUserState = useSetRecoilState(userAtom);
|
|
8985
9370
|
|
|
8986
9371
|
var _useWire = useWire("board"),
|
|
@@ -8991,7 +9376,7 @@ var SyncBoard = function SyncBoard(_ref) {
|
|
|
8991
9376
|
uid = _useRecoilState2[0].uid,
|
|
8992
9377
|
setConfiguration = _useRecoilState2[1];
|
|
8993
9378
|
|
|
8994
|
-
|
|
9379
|
+
React__default.useEffect(function () {
|
|
8995
9380
|
// Chrome-related issue.
|
|
8996
9381
|
// Making the wheel event non-passive, which allows to use preventDefault() to prevent
|
|
8997
9382
|
// the browser original zoom and therefore allowing our custom one.
|
|
@@ -9008,7 +9393,7 @@ var SyncBoard = function SyncBoard(_ref) {
|
|
|
9008
9393
|
};
|
|
9009
9394
|
}, []); // Set user space
|
|
9010
9395
|
|
|
9011
|
-
|
|
9396
|
+
React__default.useEffect(function () {
|
|
9012
9397
|
setCurrentUserState(function (prevUser) {
|
|
9013
9398
|
return _objectSpread2(_objectSpread2({}, prevUser), {}, {
|
|
9014
9399
|
space: session
|
|
@@ -9022,7 +9407,7 @@ var SyncBoard = function SyncBoard(_ref) {
|
|
|
9022
9407
|
});
|
|
9023
9408
|
};
|
|
9024
9409
|
}, [session, setCurrentUserState]);
|
|
9025
|
-
|
|
9410
|
+
React__default.useEffect(function () {
|
|
9026
9411
|
if (!uid) {
|
|
9027
9412
|
setConfiguration(function (prev) {
|
|
9028
9413
|
return _objectSpread2(_objectSpread2({}, prev), {}, {
|
|
@@ -9031,7 +9416,7 @@ var SyncBoard = function SyncBoard(_ref) {
|
|
|
9031
9416
|
});
|
|
9032
9417
|
}
|
|
9033
9418
|
}, [setConfiguration, uid]);
|
|
9034
|
-
|
|
9419
|
+
React__default.useEffect(function () {
|
|
9035
9420
|
setConfiguration(function (prev) {
|
|
9036
9421
|
return _objectSpread2(_objectSpread2({}, prev), {}, {
|
|
9037
9422
|
boardWrapper: boardWrapperRef.current
|
|
@@ -9039,13 +9424,17 @@ var SyncBoard = function SyncBoard(_ref) {
|
|
|
9039
9424
|
});
|
|
9040
9425
|
}, [setConfiguration, uid]);
|
|
9041
9426
|
useResizeObserver(boardWrapperRef, function () {
|
|
9042
|
-
|
|
9427
|
+
if (!boardWrapperRef.current) {
|
|
9428
|
+
return;
|
|
9429
|
+
}
|
|
9430
|
+
|
|
9431
|
+
setConfiguration(function (prev) {
|
|
9043
9432
|
return _objectSpread2(_objectSpread2({}, prev), {}, {
|
|
9044
9433
|
boardWrapperRect: boardWrapperRef.current.getBoundingClientRect()
|
|
9045
9434
|
});
|
|
9046
9435
|
});
|
|
9047
9436
|
});
|
|
9048
|
-
return /*#__PURE__*/
|
|
9437
|
+
return /*#__PURE__*/React__default.createElement(StyledBoardView, {
|
|
9049
9438
|
ref: boardWrapperRef,
|
|
9050
9439
|
id: uid,
|
|
9051
9440
|
className: "sync-board",
|
|
@@ -9059,11 +9448,11 @@ var ConnectedSyncBoard = function ConnectedSyncBoard(_ref2) {
|
|
|
9059
9448
|
session = _ref2.session,
|
|
9060
9449
|
props = _objectWithoutProperties(_ref2, _excluded);
|
|
9061
9450
|
|
|
9062
|
-
var _React$useState =
|
|
9451
|
+
var _React$useState = React__default.useState(room || nanoid()),
|
|
9063
9452
|
_React$useState2 = _slicedToArray(_React$useState, 1),
|
|
9064
9453
|
stableRoom = _React$useState2[0];
|
|
9065
9454
|
|
|
9066
|
-
var _React$useState3 =
|
|
9455
|
+
var _React$useState3 = React__default.useState(session || nanoid()),
|
|
9067
9456
|
_React$useState4 = _slicedToArray(_React$useState3, 1),
|
|
9068
9457
|
stableSession = _React$useState4[0];
|
|
9069
9458
|
|
|
@@ -9071,22 +9460,22 @@ var ConnectedSyncBoard = function ConnectedSyncBoard(_ref2) {
|
|
|
9071
9460
|
|
|
9072
9461
|
if (!roomChannel) {
|
|
9073
9462
|
// No room declared so we create one
|
|
9074
|
-
return /*#__PURE__*/
|
|
9463
|
+
return /*#__PURE__*/React__default.createElement(RecoilRoot, null, /*#__PURE__*/React__default.createElement(WireProvider, {
|
|
9075
9464
|
room: stableRoom,
|
|
9076
9465
|
channel: "room",
|
|
9077
9466
|
socket: socket
|
|
9078
|
-
}, /*#__PURE__*/
|
|
9467
|
+
}, /*#__PURE__*/React__default.createElement(SubscribeUserEvents, null), /*#__PURE__*/React__default.createElement(WireProvider, {
|
|
9079
9468
|
room: stableSession,
|
|
9080
9469
|
channel: "board",
|
|
9081
9470
|
socket: socket
|
|
9082
|
-
}, /*#__PURE__*/
|
|
9471
|
+
}, /*#__PURE__*/React__default.createElement(SyncBoard, props))));
|
|
9083
9472
|
}
|
|
9084
9473
|
|
|
9085
|
-
return /*#__PURE__*/
|
|
9474
|
+
return /*#__PURE__*/React__default.createElement(WireProvider, {
|
|
9086
9475
|
room: stableSession,
|
|
9087
9476
|
channel: "board",
|
|
9088
9477
|
socket: socket
|
|
9089
|
-
}, /*#__PURE__*/
|
|
9478
|
+
}, /*#__PURE__*/React__default.createElement(SyncBoard, props));
|
|
9090
9479
|
};
|
|
9091
9480
|
|
|
9092
9481
|
var ConnectedSyncRoom = function ConnectedSyncRoom(_ref) {
|
|
@@ -9094,18 +9483,18 @@ var ConnectedSyncRoom = function ConnectedSyncRoom(_ref) {
|
|
|
9094
9483
|
givenRoom = _ref.room,
|
|
9095
9484
|
children = _ref.children;
|
|
9096
9485
|
|
|
9097
|
-
var _React$useState =
|
|
9486
|
+
var _React$useState = React__default.useState(function () {
|
|
9098
9487
|
return givenRoom || nanoid();
|
|
9099
9488
|
}),
|
|
9100
9489
|
_React$useState2 = _slicedToArray(_React$useState, 1),
|
|
9101
9490
|
room = _React$useState2[0];
|
|
9102
9491
|
|
|
9103
|
-
return /*#__PURE__*/
|
|
9492
|
+
return /*#__PURE__*/React__default.createElement(RecoilRoot, null, /*#__PURE__*/React__default.createElement(WireProvider, {
|
|
9104
9493
|
room: room,
|
|
9105
9494
|
channel: "room",
|
|
9106
9495
|
socket: socket
|
|
9107
|
-
}, /*#__PURE__*/
|
|
9496
|
+
}, /*#__PURE__*/React__default.createElement(SubscribeUserEvents, null), children));
|
|
9108
9497
|
};
|
|
9109
9498
|
|
|
9110
|
-
export { Board, ConnectedSyncBoard as BoardWrapper, ConnectedSyncRoom as RoomWrapper, useAvailableActions, useBoardConfig, useDim as useBoardPosition, useBoardState, useItemActions, useItemInteraction, useItemList as useItems, useMessage, useSelectedItems, useSelectionBox, useUsers, useWire };
|
|
9499
|
+
export { Board, ConnectedSyncBoard as BoardWrapper, ConnectedSyncRoom as RoomWrapper, useAvailableActions, useBoardConfig, useDim as useBoardPosition, useBoardState, useDebouncedItems, useItemActions, useItemInteraction, useItemList as useItems, useMessage, useSelectedItems, useSelectionBox, useUsers, useWire };
|
|
9111
9500
|
//# sourceMappingURL=index.js.map
|