react-sync-board 0.5.4 → 0.6.0
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 +1612 -1264
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1711 -1383
- 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 +20 -20
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 } 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,
|
|
@@ -4310,1196 +4445,1312 @@ function useResizeObserver(target, callback, enabled) {
|
|
|
4310
4445
|
}, [target, ro]);
|
|
4311
4446
|
}
|
|
4312
4447
|
|
|
4313
|
-
var
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
_excluded3 = ["x", "y", "layer", "moving"];
|
|
4448
|
+
var isMacOS = function isMacOS() {
|
|
4449
|
+
var userAgent = navigator.userAgent.toLowerCase();
|
|
4450
|
+
return /mac os ?x 10/.test(userAgent);
|
|
4451
|
+
}; // From https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
|
|
4318
4452
|
|
|
4319
|
-
var
|
|
4320
|
-
var
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
}, img);
|
|
4453
|
+
var getScrollLineHeight = function getScrollLineHeight() {
|
|
4454
|
+
var iframe = document.createElement("iframe");
|
|
4455
|
+
iframe.src = "#";
|
|
4456
|
+
document.body.appendChild(iframe); // Write content in Iframe
|
|
4324
4457
|
|
|
4325
|
-
var
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
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"));
|
|
4458
|
+
var idoc = iframe.contentWindow.document;
|
|
4459
|
+
idoc.open();
|
|
4460
|
+
idoc.write("<!DOCTYPE html><html><head></head><body><span>a</span></body></html>");
|
|
4461
|
+
idoc.close();
|
|
4462
|
+
var scrollLineHeight = idoc.body.firstElementChild.offsetHeight;
|
|
4463
|
+
document.body.removeChild(iframe);
|
|
4464
|
+
return scrollLineHeight;
|
|
4340
4465
|
};
|
|
4341
|
-
/* Error boundary for broken item */
|
|
4342
4466
|
|
|
4467
|
+
var LINE_HEIGHT = getScrollLineHeight(); // Reasonable default from https://github.com/facebookarchive/fixed-data-table/blob/master/src/vendor_upstream/dom/normalizeWheel.js
|
|
4343
4468
|
|
|
4344
|
-
var
|
|
4345
|
-
_inherits(ItemErrorBoundary, _React$Component);
|
|
4469
|
+
var PAGE_HEIGHT = 800;
|
|
4346
4470
|
|
|
4347
|
-
|
|
4471
|
+
var otherPointer = function otherPointer(pointers, currentPointer) {
|
|
4472
|
+
var p2 = Object.keys(pointers).map(function (p) {
|
|
4473
|
+
return Number(p);
|
|
4474
|
+
}).find(function (pointer) {
|
|
4475
|
+
return pointer !== currentPointer;
|
|
4476
|
+
});
|
|
4477
|
+
return pointers[p2];
|
|
4478
|
+
};
|
|
4348
4479
|
|
|
4349
|
-
|
|
4350
|
-
|
|
4480
|
+
var computeDistance = function computeDistance(_ref, _ref2) {
|
|
4481
|
+
var _ref3 = _slicedToArray(_ref, 2),
|
|
4482
|
+
x1 = _ref3[0],
|
|
4483
|
+
y1 = _ref3[1];
|
|
4351
4484
|
|
|
4352
|
-
|
|
4485
|
+
var _ref4 = _slicedToArray(_ref2, 2),
|
|
4486
|
+
x2 = _ref4[0],
|
|
4487
|
+
y2 = _ref4[1];
|
|
4353
4488
|
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
};
|
|
4359
|
-
_this.onReload = _this.onReload.bind(_assertThisInitialized(_this));
|
|
4360
|
-
return _this;
|
|
4361
|
-
}
|
|
4489
|
+
var distanceX = Math.abs(x1 - x2);
|
|
4490
|
+
var distanceY = Math.abs(y1 - y2);
|
|
4491
|
+
return Math.hypot(distanceX, distanceY);
|
|
4492
|
+
};
|
|
4362
4493
|
|
|
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;
|
|
4494
|
+
var empty = function empty() {};
|
|
4380
4495
|
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4496
|
+
var protect = function protect(fn) {
|
|
4497
|
+
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
4498
|
+
var _args = arguments;
|
|
4499
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
4500
|
+
while (1) {
|
|
4501
|
+
switch (_context.prev = _context.next) {
|
|
4502
|
+
case 0:
|
|
4503
|
+
_context.prev = 0;
|
|
4504
|
+
_context.next = 3;
|
|
4505
|
+
return fn.apply(void 0, _args);
|
|
4386
4506
|
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
key: "getDerivedStateFromError",
|
|
4391
|
-
value: function getDerivedStateFromError() {
|
|
4392
|
-
return {
|
|
4393
|
-
hasError: true
|
|
4394
|
-
};
|
|
4395
|
-
}
|
|
4396
|
-
}]);
|
|
4507
|
+
case 3:
|
|
4508
|
+
_context.next = 8;
|
|
4509
|
+
break;
|
|
4397
4510
|
|
|
4398
|
-
|
|
4399
|
-
|
|
4511
|
+
case 5:
|
|
4512
|
+
_context.prev = 5;
|
|
4513
|
+
_context.t0 = _context["catch"](0);
|
|
4514
|
+
// eslint-disable-next-line no-console
|
|
4515
|
+
console.error(_context.t0);
|
|
4400
4516
|
|
|
4401
|
-
|
|
4402
|
-
|
|
4517
|
+
case 8:
|
|
4518
|
+
case "end":
|
|
4519
|
+
return _context.stop();
|
|
4520
|
+
}
|
|
4521
|
+
}
|
|
4522
|
+
}, _callee, null, [[0, 5]]);
|
|
4523
|
+
}));
|
|
4403
4524
|
};
|
|
4404
4525
|
|
|
4405
|
-
var
|
|
4406
|
-
var
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
};
|
|
4526
|
+
var Gesture = function Gesture(_ref6) {
|
|
4527
|
+
var children = _ref6.children,
|
|
4528
|
+
_ref6$onDrag = _ref6.onDrag,
|
|
4529
|
+
onDrag = _ref6$onDrag === void 0 ? empty : _ref6$onDrag,
|
|
4530
|
+
_ref6$onDragStart = _ref6.onDragStart,
|
|
4531
|
+
onDragStart = _ref6$onDragStart === void 0 ? empty : _ref6$onDragStart,
|
|
4532
|
+
_ref6$onDragEnd = _ref6.onDragEnd,
|
|
4533
|
+
onDragEnd = _ref6$onDragEnd === void 0 ? empty : _ref6$onDragEnd,
|
|
4534
|
+
_ref6$onPan = _ref6.onPan,
|
|
4535
|
+
onPan = _ref6$onPan === void 0 ? empty : _ref6$onPan,
|
|
4536
|
+
_ref6$onTap = _ref6.onTap,
|
|
4537
|
+
onTap = _ref6$onTap === void 0 ? empty : _ref6$onTap,
|
|
4538
|
+
_ref6$onLongTap = _ref6.onLongTap,
|
|
4539
|
+
onLongTap = _ref6$onLongTap === void 0 ? empty : _ref6$onLongTap,
|
|
4540
|
+
_ref6$onDoubleTap = _ref6.onDoubleTap,
|
|
4541
|
+
onDoubleTap = _ref6$onDoubleTap === void 0 ? empty : _ref6$onDoubleTap,
|
|
4542
|
+
onZoom = _ref6.onZoom;
|
|
4543
|
+
var wrapperRef = React__default.useRef(null);
|
|
4544
|
+
var stateRef = React__default.useRef({
|
|
4545
|
+
moving: false,
|
|
4546
|
+
pointers: {},
|
|
4547
|
+
mainPointer: undefined
|
|
4548
|
+
});
|
|
4549
|
+
var queueRef = React__default.useRef([]); // Queue event to avoid async mess
|
|
4430
4550
|
|
|
4431
|
-
var
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4551
|
+
var queue = React__default.useCallback(function (callback, args) {
|
|
4552
|
+
queueRef.current.push( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
4553
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
4554
|
+
while (1) {
|
|
4555
|
+
switch (_context2.prev = _context2.next) {
|
|
4556
|
+
case 0:
|
|
4557
|
+
_context2.next = 2;
|
|
4558
|
+
return protect(callback)(args);
|
|
4439
4559
|
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
}
|
|
4560
|
+
case 2:
|
|
4561
|
+
queueRef.current.shift();
|
|
4443
4562
|
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
return /*#__PURE__*/React.createElement(ItemWrapper, {
|
|
4449
|
-
rotation: rotation,
|
|
4450
|
-
locked: locked && !unlocked,
|
|
4451
|
-
selected: isSelected,
|
|
4452
|
-
layer: layer,
|
|
4453
|
-
"data-id": id,
|
|
4454
|
-
className: className
|
|
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
|
-
})));
|
|
4484
|
-
};
|
|
4563
|
+
if (!(queueRef.current.length !== 0)) {
|
|
4564
|
+
_context2.next = 6;
|
|
4565
|
+
break;
|
|
4566
|
+
}
|
|
4485
4567
|
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
prevSetState = _ref4.setState,
|
|
4489
|
-
prevIsSelected = _ref4.isSelected,
|
|
4490
|
-
prevUnlocked = _ref4.unlocked;
|
|
4491
|
-
var nextState = _ref5.state,
|
|
4492
|
-
nextSetState = _ref5.setState,
|
|
4493
|
-
nextIsSelected = _ref5.isSelected,
|
|
4494
|
-
nextUnlocked = _ref5.unlocked;
|
|
4495
|
-
return prevIsSelected === nextIsSelected && prevUnlocked === nextUnlocked && prevSetState === nextSetState && JSON.stringify(prevState) === JSON.stringify(nextState);
|
|
4496
|
-
}); // Exclude positioning from memoization
|
|
4568
|
+
_context2.next = 6;
|
|
4569
|
+
return protect(queueRef.current[0])();
|
|
4497
4570
|
|
|
4498
|
-
|
|
4499
|
-
|
|
4571
|
+
case 6:
|
|
4572
|
+
case "end":
|
|
4573
|
+
return _context2.stop();
|
|
4574
|
+
}
|
|
4575
|
+
}
|
|
4576
|
+
}, _callee2);
|
|
4577
|
+
})));
|
|
4500
4578
|
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4579
|
+
if (queueRef.current.length === 1) {
|
|
4580
|
+
protect(queueRef.current[0])();
|
|
4581
|
+
}
|
|
4582
|
+
}, []);
|
|
4583
|
+
var onWheel = React__default.useCallback(function (e) {
|
|
4584
|
+
var deltaX = e.deltaX,
|
|
4585
|
+
deltaY = e.deltaY,
|
|
4586
|
+
clientX = e.clientX,
|
|
4587
|
+
clientY = e.clientY,
|
|
4588
|
+
deltaMode = e.deltaMode,
|
|
4589
|
+
ctrlKey = e.ctrlKey,
|
|
4590
|
+
altKey = e.altKey,
|
|
4591
|
+
metaKey = e.metaKey,
|
|
4592
|
+
target = e.target; // On a MacOs trackpad, the pinch gesture sets the ctrlKey to true.
|
|
4593
|
+
// In that situation, we want to use the custom scaling, not the browser default zoom.
|
|
4594
|
+
// Hence in this situation we avoid to return immediately.
|
|
4506
4595
|
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4596
|
+
if (altKey || ctrlKey && !isMacOS()) {
|
|
4597
|
+
return;
|
|
4598
|
+
} // On a trackpad, the pinch and pan events are differentiated by the crtlKey value.
|
|
4599
|
+
// On a pinch gesture, the ctrlKey is set to true, so we want to have a scaling effect.
|
|
4600
|
+
// If we are only moving the fingers in the same direction, a pan is needed.
|
|
4601
|
+
// Ref: https://medium.com/@auchenberg/detecting-multi-touch-trackpad-gestures-in-javascript-a2505babb10e
|
|
4510
4602
|
|
|
4511
|
-
var _stateTrans = stateTrans(state, {
|
|
4512
|
-
currentUser: currentUser
|
|
4513
|
-
}),
|
|
4514
|
-
_stateTrans$x = _stateTrans.x,
|
|
4515
|
-
x = _stateTrans$x === void 0 ? 0 : _stateTrans$x,
|
|
4516
|
-
_stateTrans$y = _stateTrans.y,
|
|
4517
|
-
y = _stateTrans$y === void 0 ? 0 : _stateTrans$y,
|
|
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
|
|
4531
4603
|
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4604
|
+
if (isMacOS() && !ctrlKey) {
|
|
4605
|
+
queue(onPan, {
|
|
4606
|
+
deltaX: -2 * deltaX,
|
|
4607
|
+
deltaY: -2 * deltaY,
|
|
4608
|
+
button: 1,
|
|
4609
|
+
ctrlKey: ctrlKey,
|
|
4610
|
+
metaKey: metaKey,
|
|
4611
|
+
target: target,
|
|
4612
|
+
event: e
|
|
4613
|
+
});
|
|
4614
|
+
} else {
|
|
4615
|
+
// Quit if onZoom is not set
|
|
4616
|
+
if (onZoom === undefined || !deltaY) return;
|
|
4617
|
+
var scale = deltaY;
|
|
4537
4618
|
|
|
4538
|
-
|
|
4619
|
+
switch (deltaMode) {
|
|
4620
|
+
case 1:
|
|
4621
|
+
// Pixel
|
|
4622
|
+
scale *= LINE_HEIGHT;
|
|
4623
|
+
break;
|
|
4539
4624
|
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4625
|
+
case 2:
|
|
4626
|
+
scale *= PAGE_HEIGHT;
|
|
4627
|
+
break;
|
|
4628
|
+
}
|
|
4544
4629
|
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
}
|
|
4630
|
+
if (isMacOS()) {
|
|
4631
|
+
scale *= 2;
|
|
4632
|
+
}
|
|
4548
4633
|
|
|
4634
|
+
queue(onZoom, {
|
|
4635
|
+
scale: scale,
|
|
4636
|
+
clientX: clientX,
|
|
4637
|
+
clientY: clientY,
|
|
4638
|
+
event: e
|
|
4639
|
+
});
|
|
4640
|
+
}
|
|
4641
|
+
}, [onPan, onZoom, queue]);
|
|
4642
|
+
var onPointerDown = React__default.useCallback(function (_ref8) {
|
|
4643
|
+
var target = _ref8.target,
|
|
4644
|
+
button = _ref8.button,
|
|
4645
|
+
clientX = _ref8.clientX,
|
|
4646
|
+
clientY = _ref8.clientY,
|
|
4647
|
+
pointerId = _ref8.pointerId,
|
|
4648
|
+
altKey = _ref8.altKey,
|
|
4649
|
+
ctrlKey = _ref8.ctrlKey,
|
|
4650
|
+
metaKey = _ref8.metaKey,
|
|
4651
|
+
isPrimary = _ref8.isPrimary;
|
|
4652
|
+
// Add pointer to map
|
|
4653
|
+
stateRef.current.pointers[pointerId] = {
|
|
4654
|
+
clientX: clientX,
|
|
4655
|
+
clientY: clientY
|
|
4656
|
+
};
|
|
4549
4657
|
|
|
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;
|
|
4658
|
+
if (isPrimary) {
|
|
4659
|
+
// Clean mainPoint on primary pointer
|
|
4660
|
+
stateRef.current.mainPointer = undefined;
|
|
4661
|
+
}
|
|
4559
4662
|
|
|
4663
|
+
if (stateRef.current.mainPointer !== undefined) {
|
|
4664
|
+
if (stateRef.current.mainPointer !== pointerId) {
|
|
4665
|
+
// This is not the main pointer
|
|
4666
|
+
try {
|
|
4667
|
+
var _otherPointer = otherPointer(stateRef.current.pointers, pointerId),
|
|
4668
|
+
clientX2 = _otherPointer.clientX,
|
|
4669
|
+
clientY2 = _otherPointer.clientY;
|
|
4560
4670
|
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4671
|
+
var newClientX = (clientX2 + clientX) / 2;
|
|
4672
|
+
var newClientY = (clientY2 + clientY) / 2;
|
|
4673
|
+
var distance = computeDistance([clientX2, clientY2], [clientX, clientY]); // We update previous position as the new position is the center beetween both finger
|
|
4564
4674
|
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
})
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
"default": []
|
|
4580
|
-
});
|
|
4581
|
-
var localUsersAtom = selector({
|
|
4582
|
-
key: "localUsersAtom",
|
|
4583
|
-
get: function get(_ref) {
|
|
4584
|
-
var _get = _ref.get;
|
|
4675
|
+
Object.assign(stateRef.current, {
|
|
4676
|
+
pressed: true,
|
|
4677
|
+
moving: false,
|
|
4678
|
+
gestureStart: false,
|
|
4679
|
+
startX: clientX,
|
|
4680
|
+
startY: clientY,
|
|
4681
|
+
prevX: newClientX,
|
|
4682
|
+
prevY: newClientY,
|
|
4683
|
+
startDistance: distance,
|
|
4684
|
+
prevDistance: distance
|
|
4685
|
+
});
|
|
4686
|
+
} catch (e) {
|
|
4687
|
+
// eslint-disable-next-line no-console
|
|
4688
|
+
console.log("Error while getting other pointer. Ignoring", e); // eslint-disable-next-line no-unused-expressions
|
|
4585
4689
|
|
|
4586
|
-
|
|
4690
|
+
stateRef.current.mainPointer === undefined;
|
|
4691
|
+
}
|
|
4692
|
+
}
|
|
4587
4693
|
|
|
4588
|
-
|
|
4694
|
+
return;
|
|
4695
|
+
} // We set the mainpointer
|
|
4589
4696
|
|
|
4590
|
-
return users.filter(function (_ref2) {
|
|
4591
|
-
var space = _ref2.space;
|
|
4592
|
-
return space === currentUser.space;
|
|
4593
|
-
});
|
|
4594
|
-
}
|
|
4595
|
-
});
|
|
4596
4697
|
|
|
4597
|
-
|
|
4598
|
-
var _useRecoilState = useRecoilState(userAtom),
|
|
4599
|
-
_useRecoilState2 = _slicedToArray(_useRecoilState, 2),
|
|
4600
|
-
currentUser = _useRecoilState2[0],
|
|
4601
|
-
setCurrentUserState = _useRecoilState2[1];
|
|
4698
|
+
stateRef.current.mainPointer = pointerId; // And prepare move
|
|
4602
4699
|
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4700
|
+
Object.assign(stateRef.current, {
|
|
4701
|
+
pressed: true,
|
|
4702
|
+
moving: false,
|
|
4703
|
+
gestureStart: false,
|
|
4704
|
+
startX: clientX,
|
|
4705
|
+
startY: clientY,
|
|
4706
|
+
prevX: clientX,
|
|
4707
|
+
prevY: clientY,
|
|
4708
|
+
currentButton: button,
|
|
4709
|
+
target: target,
|
|
4710
|
+
timeStart: Date.now(),
|
|
4711
|
+
longTapTimeout: setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
4712
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
4713
|
+
while (1) {
|
|
4714
|
+
switch (_context3.prev = _context3.next) {
|
|
4715
|
+
case 0:
|
|
4716
|
+
stateRef.current.noTap = true;
|
|
4717
|
+
queue(onLongTap, {
|
|
4718
|
+
clientX: clientX,
|
|
4719
|
+
clientY: clientY,
|
|
4720
|
+
altKey: altKey,
|
|
4721
|
+
ctrlKey: ctrlKey,
|
|
4722
|
+
metaKey: metaKey,
|
|
4723
|
+
target: target
|
|
4724
|
+
});
|
|
4607
4725
|
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4726
|
+
case 2:
|
|
4727
|
+
case "end":
|
|
4728
|
+
return _context3.stop();
|
|
4729
|
+
}
|
|
4730
|
+
}
|
|
4731
|
+
}, _callee3);
|
|
4732
|
+
})), 750)
|
|
4733
|
+
});
|
|
4613
4734
|
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
setCurrentUser: setCurrentUser,
|
|
4631
|
-
users: users,
|
|
4632
|
-
localUsers: localUsers
|
|
4633
|
-
};
|
|
4634
|
-
};
|
|
4735
|
+
try {
|
|
4736
|
+
target.setPointerCapture(pointerId);
|
|
4737
|
+
} catch (e) {
|
|
4738
|
+
// eslint-disable-next-line no-console
|
|
4739
|
+
console.log("Fail to capture pointer", e);
|
|
4740
|
+
}
|
|
4741
|
+
}, [onLongTap, queue]);
|
|
4742
|
+
var onPointerMove = React__default.useCallback(function (e) {
|
|
4743
|
+
if (stateRef.current.pressed) {
|
|
4744
|
+
var pointerId = e.pointerId,
|
|
4745
|
+
eventClientX = e.clientX,
|
|
4746
|
+
eventClientY = e.clientY,
|
|
4747
|
+
altKey = e.altKey,
|
|
4748
|
+
ctrlKey = e.ctrlKey,
|
|
4749
|
+
metaKey = e.metaKey,
|
|
4750
|
+
pointerType = e.pointerType;
|
|
4635
4751
|
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4752
|
+
if (stateRef.current.mainPointer !== pointerId) {
|
|
4753
|
+
// Event from other pointer
|
|
4754
|
+
stateRef.current.pointers[pointerId] = {
|
|
4755
|
+
clientX: eventClientX,
|
|
4756
|
+
clientY: eventClientY
|
|
4757
|
+
};
|
|
4758
|
+
return;
|
|
4759
|
+
}
|
|
4639
4760
|
|
|
4640
|
-
|
|
4641
|
-
_useRecoilState2 = _slicedToArray(_useRecoilState, 2),
|
|
4642
|
-
currentUser = _useRecoilState2[0],
|
|
4643
|
-
setCurrentUserState = _useRecoilState2[1];
|
|
4761
|
+
stateRef.current.moving = true; // Do we have two fingers ?
|
|
4644
4762
|
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4763
|
+
var twoFingers = Object.keys(stateRef.current.pointers).length === 2;
|
|
4764
|
+
var clientX;
|
|
4765
|
+
var clientY;
|
|
4766
|
+
var distance;
|
|
4649
4767
|
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
});
|
|
4656
|
-
});
|
|
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
|
-
};
|
|
4768
|
+
if (twoFingers) {
|
|
4769
|
+
// Find other pointerId
|
|
4770
|
+
var _otherPointer2 = otherPointer(stateRef.current.pointers, pointerId),
|
|
4771
|
+
clientX2 = _otherPointer2.clientX,
|
|
4772
|
+
clientY2 = _otherPointer2.clientY; // Update client X with the center of each touch
|
|
4672
4773
|
|
|
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
4774
|
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4775
|
+
clientX = (clientX2 + eventClientX) / 2;
|
|
4776
|
+
clientY = (clientY2 + eventClientY) / 2;
|
|
4777
|
+
distance = computeDistance([clientX2, clientY2], [eventClientX, eventClientY]);
|
|
4778
|
+
} else {
|
|
4779
|
+
clientX = eventClientX;
|
|
4780
|
+
clientY = eventClientY;
|
|
4781
|
+
} // We drag if
|
|
4782
|
+
// On non touch device
|
|
4783
|
+
// - Button is 0
|
|
4784
|
+
// - Alt key is no pressed
|
|
4785
|
+
// or on touch devices
|
|
4786
|
+
// - We use only one finger
|
|
4695
4787
|
|
|
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
4788
|
|
|
4713
|
-
|
|
4714
|
-
}
|
|
4789
|
+
var shouldDrag = pointerType !== "touch" ? stateRef.current.currentButton === 0 && !altKey : !twoFingers;
|
|
4715
4790
|
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4791
|
+
if (shouldDrag) {
|
|
4792
|
+
// Send drag start on first move
|
|
4793
|
+
if (!stateRef.current.gestureStart) {
|
|
4794
|
+
wrapperRef.current.style.cursor = "move";
|
|
4795
|
+
stateRef.current.gestureStart = true; // Clear tap timeout
|
|
4720
4796
|
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4797
|
+
clearTimeout(stateRef.current.longTapTimeout);
|
|
4798
|
+
queue(onDragStart, {
|
|
4799
|
+
deltaX: 0,
|
|
4800
|
+
deltaY: 0,
|
|
4801
|
+
startX: stateRef.current.startX,
|
|
4802
|
+
startY: stateRef.current.startY,
|
|
4803
|
+
clientX: stateRef.current.startX,
|
|
4804
|
+
clientY: stateRef.current.startY,
|
|
4805
|
+
distanceX: 0,
|
|
4806
|
+
distanceY: 0,
|
|
4807
|
+
button: stateRef.current.currentButton,
|
|
4808
|
+
altKey: altKey,
|
|
4809
|
+
ctrlKey: ctrlKey,
|
|
4810
|
+
metaKey: metaKey,
|
|
4811
|
+
target: stateRef.current.target,
|
|
4812
|
+
event: e
|
|
4813
|
+
});
|
|
4814
|
+
} // Create closure
|
|
4727
4815
|
|
|
4728
|
-
if (isMaster) {
|
|
4729
|
-
wire.publish("updateUserList", usersRef.current);
|
|
4730
|
-
}
|
|
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
4816
|
|
|
4745
|
-
|
|
4817
|
+
var deltaX = clientX - stateRef.current.prevX;
|
|
4818
|
+
var deltaY = clientY - stateRef.current.prevY;
|
|
4819
|
+
var distanceX = clientX - stateRef.current.startX;
|
|
4820
|
+
var distanceY = clientY - stateRef.current.startY; // Drag event
|
|
4746
4821
|
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4822
|
+
queue(onDrag, {
|
|
4823
|
+
deltaX: deltaX,
|
|
4824
|
+
deltaY: deltaY,
|
|
4825
|
+
startX: stateRef.current.startX,
|
|
4826
|
+
startY: stateRef.current.startY,
|
|
4827
|
+
clientX: clientX,
|
|
4828
|
+
clientY: clientY,
|
|
4829
|
+
distanceX: distanceX,
|
|
4830
|
+
distanceY: distanceY,
|
|
4831
|
+
button: stateRef.current.currentButton,
|
|
4832
|
+
altKey: altKey,
|
|
4833
|
+
ctrlKey: ctrlKey,
|
|
4834
|
+
metaKey: metaKey,
|
|
4835
|
+
target: stateRef.current.target,
|
|
4836
|
+
event: e
|
|
4837
|
+
});
|
|
4838
|
+
} else {
|
|
4839
|
+
if (!stateRef.current.gestureStart) {
|
|
4840
|
+
wrapperRef.current.style.cursor = "move";
|
|
4841
|
+
stateRef.current.gestureStart = true; // Clear tap timeout on first move
|
|
4752
4842
|
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
if (e.key === "u" || e.key === "l") {
|
|
4756
|
-
setUnlock(true);
|
|
4757
|
-
}
|
|
4758
|
-
};
|
|
4843
|
+
clearTimeout(stateRef.current.longTapTimeout);
|
|
4844
|
+
} // Create closure
|
|
4759
4845
|
|
|
4760
|
-
var onKeyUp = function onKeyUp(e) {
|
|
4761
|
-
if (e.key === "u" || e.key === "l") {
|
|
4762
|
-
setUnlock(false);
|
|
4763
|
-
}
|
|
4764
|
-
};
|
|
4765
4846
|
|
|
4766
|
-
|
|
4767
|
-
document.addEventListener("keyup", onKeyUp);
|
|
4768
|
-
return function () {
|
|
4769
|
-
document.removeEventListener("keydown", onKeyDown);
|
|
4770
|
-
document.removeEventListener("keyup", onKeyUp);
|
|
4771
|
-
};
|
|
4772
|
-
}, []);
|
|
4773
|
-
return unlock;
|
|
4774
|
-
};
|
|
4847
|
+
var _deltaX = clientX - stateRef.current.prevX;
|
|
4775
4848
|
|
|
4776
|
-
var
|
|
4777
|
-
var itemTemplates = _ref.itemTemplates;
|
|
4849
|
+
var _deltaY = clientY - stateRef.current.prevY;
|
|
4778
4850
|
|
|
4779
|
-
|
|
4780
|
-
updateItem = _useItemActions.updateItem;
|
|
4851
|
+
var target = stateRef.current.target; // Pan event
|
|
4781
4852
|
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4853
|
+
queue(onPan, {
|
|
4854
|
+
deltaX: _deltaX,
|
|
4855
|
+
deltaY: _deltaY,
|
|
4856
|
+
button: stateRef.current.currentButton,
|
|
4857
|
+
altKey: altKey,
|
|
4858
|
+
ctrlKey: ctrlKey,
|
|
4859
|
+
metaKey: metaKey,
|
|
4860
|
+
target: target,
|
|
4861
|
+
event: e
|
|
4862
|
+
});
|
|
4785
4863
|
|
|
4786
|
-
|
|
4787
|
-
|
|
4864
|
+
if (twoFingers && distance !== stateRef.current.prevDistance && onZoom) {
|
|
4865
|
+
var scale = stateRef.current.prevDistance - distance;
|
|
4788
4866
|
|
|
4789
|
-
|
|
4790
|
-
|
|
4867
|
+
if (Math.abs(scale) > 0) {
|
|
4868
|
+
queue(onZoom, {
|
|
4869
|
+
scale: scale,
|
|
4870
|
+
clientX: clientX,
|
|
4871
|
+
clientY: clientY,
|
|
4872
|
+
event: e
|
|
4873
|
+
});
|
|
4874
|
+
stateRef.current.prevDistance = distance;
|
|
4875
|
+
}
|
|
4876
|
+
}
|
|
4877
|
+
}
|
|
4791
4878
|
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
});
|
|
4805
|
-
};
|
|
4806
|
-
|
|
4807
|
-
var SubcribeItemEvents = function SubcribeItemEvents() {
|
|
4808
|
-
var _useWire = useWire("board"),
|
|
4809
|
-
wire = _useWire.wire;
|
|
4879
|
+
stateRef.current.prevX = clientX;
|
|
4880
|
+
stateRef.current.prevY = clientY;
|
|
4881
|
+
}
|
|
4882
|
+
}, [onDrag, onDragStart, onPan, onZoom, queue]);
|
|
4883
|
+
var onPointerUp = React__default.useCallback(function (e) {
|
|
4884
|
+
var clientX = e.clientX,
|
|
4885
|
+
clientY = e.clientY,
|
|
4886
|
+
altKey = e.altKey,
|
|
4887
|
+
ctrlKey = e.ctrlKey,
|
|
4888
|
+
metaKey = e.metaKey,
|
|
4889
|
+
target = e.target,
|
|
4890
|
+
pointerId = e.pointerId;
|
|
4810
4891
|
|
|
4811
|
-
|
|
4892
|
+
if (!stateRef.current.pointers[pointerId]) {
|
|
4893
|
+
// Pointer already gone previously with another event
|
|
4894
|
+
// ignoring it
|
|
4895
|
+
return;
|
|
4896
|
+
} // Remove pointer from map
|
|
4812
4897
|
|
|
4813
|
-
var _useItemActions = useItemActions(),
|
|
4814
|
-
updateItemOrder = _useItemActions.updateItemOrder,
|
|
4815
|
-
moveItems = _useItemActions.moveItems,
|
|
4816
|
-
removeItems = _useItemActions.removeItems,
|
|
4817
|
-
pushItem = _useItemActions.pushItem;
|
|
4818
4898
|
|
|
4819
|
-
|
|
4820
|
-
setItemMap(function (prevItemMap) {
|
|
4821
|
-
return _objectSpread2(_objectSpread2({}, prevItemMap), updatedItems);
|
|
4822
|
-
});
|
|
4823
|
-
}, [setItemMap]);
|
|
4824
|
-
React.useEffect(function () {
|
|
4825
|
-
var unsub = wire.subscribe("batchItemsUpdate", function (updatedItems) {
|
|
4826
|
-
batchUpdate(updatedItems);
|
|
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];
|
|
4899
|
+
delete stateRef.current.pointers[pointerId];
|
|
4855
4900
|
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
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
|
-
};
|
|
4901
|
+
if (stateRef.current.mainPointer !== pointerId) {
|
|
4902
|
+
// If this is not the main pointer we quit here
|
|
4903
|
+
return;
|
|
4904
|
+
}
|
|
4868
4905
|
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
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
|
-
}
|
|
4906
|
+
while (Object.keys(stateRef.current.pointers).length > 0) {
|
|
4907
|
+
// If was main pointer but we have another one, this one become main
|
|
4908
|
+
stateRef.current.mainPointer = Number(Object.keys(stateRef.current.pointers)[0]);
|
|
4881
4909
|
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4910
|
+
try {
|
|
4911
|
+
stateRef.current.target.setPointerCapture(stateRef.current.mainPointer);
|
|
4912
|
+
return;
|
|
4913
|
+
} catch (error) {
|
|
4914
|
+
// eslint-disable-next-line no-console
|
|
4915
|
+
console.log("Fails to set pointer capture", error);
|
|
4916
|
+
stateRef.current.mainPointer = undefined;
|
|
4917
|
+
delete stateRef.current.pointers[Object.keys(stateRef.current.pointers)[0]];
|
|
4918
|
+
}
|
|
4919
|
+
}
|
|
4885
4920
|
|
|
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;
|
|
4921
|
+
stateRef.current.mainPointer = undefined;
|
|
4922
|
+
stateRef.current.pressed = false; // Clear longTap
|
|
4898
4923
|
|
|
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];
|
|
4924
|
+
clearTimeout(stateRef.current.longTapTimeout);
|
|
4908
4925
|
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4926
|
+
if (stateRef.current.moving) {
|
|
4927
|
+
// If we were moving, send drag end event
|
|
4928
|
+
stateRef.current.moving = false;
|
|
4929
|
+
queue(onDragEnd, {
|
|
4930
|
+
deltaX: clientX - stateRef.current.prevX,
|
|
4931
|
+
deltaY: clientY - stateRef.current.prevY,
|
|
4932
|
+
startX: stateRef.current.startX,
|
|
4933
|
+
startY: stateRef.current.startY,
|
|
4934
|
+
clientX: clientX,
|
|
4935
|
+
clientY: clientY,
|
|
4936
|
+
distanceX: clientX - stateRef.current.startX,
|
|
4937
|
+
distanceY: clientY - stateRef.current.startY,
|
|
4938
|
+
button: stateRef.current.currentButton,
|
|
4939
|
+
altKey: altKey,
|
|
4940
|
+
ctrlKey: ctrlKey,
|
|
4941
|
+
metaKey: metaKey,
|
|
4942
|
+
event: e
|
|
4943
|
+
});
|
|
4944
|
+
wrapperRef.current.style.cursor = "auto";
|
|
4945
|
+
} else {
|
|
4946
|
+
var now = Date.now();
|
|
4913
4947
|
|
|
4914
|
-
|
|
4948
|
+
if (stateRef.current.noTap) {
|
|
4949
|
+
stateRef.current.noTap = false;
|
|
4950
|
+
} // Send tap event only if time less than 300ms
|
|
4951
|
+
else if (stateRef.current.timeStart - now < 300) {
|
|
4952
|
+
queue(onTap, {
|
|
4953
|
+
clientX: clientX,
|
|
4954
|
+
clientY: clientY,
|
|
4955
|
+
altKey: altKey,
|
|
4956
|
+
ctrlKey: ctrlKey,
|
|
4957
|
+
metaKey: metaKey,
|
|
4958
|
+
target: target
|
|
4959
|
+
});
|
|
4960
|
+
}
|
|
4961
|
+
}
|
|
4962
|
+
}, [onDragEnd, onTap, queue]);
|
|
4963
|
+
var onDoubleTapHandler = React__default.useCallback(function (event) {
|
|
4964
|
+
queue(onDoubleTap, event);
|
|
4965
|
+
}, [onDoubleTap, queue]);
|
|
4966
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
4967
|
+
onWheel: onWheel,
|
|
4968
|
+
onPointerDown: onPointerDown,
|
|
4969
|
+
onPointerMove: onPointerMove,
|
|
4970
|
+
onPointerUp: onPointerUp,
|
|
4971
|
+
onPointerOut: onPointerUp,
|
|
4972
|
+
onPointerLeave: onPointerUp,
|
|
4973
|
+
onPointerCancel: onPointerUp,
|
|
4974
|
+
onDoubleClick: onDoubleTapHandler,
|
|
4975
|
+
style: {
|
|
4976
|
+
touchAction: "none"
|
|
4977
|
+
},
|
|
4978
|
+
ref: wrapperRef
|
|
4979
|
+
}, children);
|
|
4915
4980
|
};
|
|
4916
|
-
var getIdFromElem = function getIdFromElem(elem) {
|
|
4917
|
-
var _elem$dataset;
|
|
4918
4981
|
|
|
4919
|
-
|
|
4982
|
+
var _excluded$3 = ["onResize"];
|
|
4920
4983
|
|
|
4921
|
-
|
|
4922
|
-
|
|
4984
|
+
var ResizeHandler = function ResizeHandler(_ref) {
|
|
4985
|
+
var onResize = _ref.onResize,
|
|
4986
|
+
rest = _objectWithoutProperties(_ref, _excluded$3);
|
|
4923
4987
|
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4988
|
+
var onDrag = useRecoilCallback(function (_ref2) {
|
|
4989
|
+
var snapshot = _ref2.snapshot;
|
|
4990
|
+
return /*#__PURE__*/function () {
|
|
4991
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref3) {
|
|
4992
|
+
var deltaX, deltaY, event, _yield$snapshot$getPr, scale;
|
|
4927
4993
|
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4994
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
4995
|
+
while (1) {
|
|
4996
|
+
switch (_context.prev = _context.next) {
|
|
4997
|
+
case 0:
|
|
4998
|
+
deltaX = _ref3.deltaX, deltaY = _ref3.deltaY, event = _ref3.event;
|
|
4999
|
+
event.stopPropagation();
|
|
5000
|
+
_context.next = 4;
|
|
5001
|
+
return snapshot.getPromise(BoardTransformAtom);
|
|
4935
5002
|
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
5003
|
+
case 4:
|
|
5004
|
+
_yield$snapshot$getPr = _context.sent;
|
|
5005
|
+
scale = _yield$snapshot$getPr.scale;
|
|
5006
|
+
onResize({
|
|
5007
|
+
width: deltaX / scale,
|
|
5008
|
+
height: deltaY / scale
|
|
5009
|
+
});
|
|
4941
5010
|
|
|
4942
|
-
|
|
5011
|
+
case 7:
|
|
5012
|
+
case "end":
|
|
5013
|
+
return _context.stop();
|
|
5014
|
+
}
|
|
5015
|
+
}
|
|
5016
|
+
}, _callee);
|
|
5017
|
+
}));
|
|
4943
5018
|
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
left: left,
|
|
4947
|
-
top: top,
|
|
4948
|
-
right: right,
|
|
4949
|
-
bottom: bottom
|
|
5019
|
+
return function (_x) {
|
|
5020
|
+
return _ref4.apply(this, arguments);
|
|
4950
5021
|
};
|
|
4951
|
-
}
|
|
4952
|
-
|
|
4953
|
-
|
|
5022
|
+
}();
|
|
5023
|
+
}, [onResize]);
|
|
5024
|
+
return /*#__PURE__*/React__default.createElement(Gesture, {
|
|
5025
|
+
onDrag: onDrag
|
|
5026
|
+
}, /*#__PURE__*/React__default.createElement("div", rest));
|
|
5027
|
+
};
|
|
4954
5028
|
|
|
4955
|
-
|
|
4956
|
-
boundingBox.top = Math.min(top, boundingBox.top);
|
|
4957
|
-
boundingBox.right = Math.max(right, boundingBox.right);
|
|
4958
|
-
boundingBox.bottom = Math.max(bottom, boundingBox.bottom);
|
|
4959
|
-
return boundingBox;
|
|
4960
|
-
}, null);
|
|
5029
|
+
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";
|
|
4961
5030
|
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
5031
|
+
var _excluded$2 = ["type", "rotation", "id", "locked", "layer"],
|
|
5032
|
+
_excluded2 = ["state", "boardSize", "currentUser"],
|
|
5033
|
+
_excluded3 = ["x", "y", "layer", "moving"];
|
|
4965
5034
|
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
var isMacOS = function isMacOS() {
|
|
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
|
|
4975
|
-
|
|
4976
|
-
var getScrollLineHeight = function getScrollLineHeight() {
|
|
4977
|
-
var iframe = document.createElement("iframe");
|
|
4978
|
-
iframe.src = "#";
|
|
4979
|
-
document.body.appendChild(iframe); // Write content in Iframe
|
|
5035
|
+
var _templateObject$2;
|
|
5036
|
+
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) {
|
|
5037
|
+
var rotation = _ref.rotation;
|
|
5038
|
+
return rotation;
|
|
5039
|
+
}, img);
|
|
4980
5040
|
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
idoc.write("<!DOCTYPE html><html><head></head><body><span>a</span></body></html>");
|
|
4984
|
-
idoc.close();
|
|
4985
|
-
var scrollLineHeight = idoc.body.firstElementChild.offsetHeight;
|
|
4986
|
-
document.body.removeChild(iframe);
|
|
4987
|
-
return scrollLineHeight;
|
|
5041
|
+
var identity = function identity(x) {
|
|
5042
|
+
return x;
|
|
4988
5043
|
};
|
|
4989
5044
|
|
|
4990
|
-
var
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5045
|
+
var DefaultErrorComponent = function DefaultErrorComponent(_ref2) {
|
|
5046
|
+
var onReload = _ref2.onReload;
|
|
5047
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
5048
|
+
style: {
|
|
5049
|
+
width: "100px",
|
|
5050
|
+
display: "flex",
|
|
5051
|
+
flexDirection: "column",
|
|
5052
|
+
justifyContent: "center",
|
|
5053
|
+
textAlign: "center",
|
|
5054
|
+
color: "red"
|
|
5055
|
+
},
|
|
5056
|
+
className: "syncboard-error-item"
|
|
5057
|
+
}, "Sorry, this item seems broken.", /*#__PURE__*/React__default.createElement("button", {
|
|
5058
|
+
onClick: onReload
|
|
5059
|
+
}, "Reload it"));
|
|
5001
5060
|
};
|
|
5061
|
+
/* Error boundary for broken item */
|
|
5002
5062
|
|
|
5003
|
-
var computeDistance = function computeDistance(_ref, _ref2) {
|
|
5004
|
-
var _ref3 = _slicedToArray(_ref, 2),
|
|
5005
|
-
x1 = _ref3[0],
|
|
5006
|
-
y1 = _ref3[1];
|
|
5007
5063
|
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
y2 = _ref4[1];
|
|
5064
|
+
var ItemErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
5065
|
+
_inherits(ItemErrorBoundary, _React$Component);
|
|
5011
5066
|
|
|
5012
|
-
var
|
|
5013
|
-
var distanceY = Math.abs(y1 - y2);
|
|
5014
|
-
return Math.hypot(distanceX, distanceY);
|
|
5015
|
-
};
|
|
5067
|
+
var _super = _createSuper(ItemErrorBoundary);
|
|
5016
5068
|
|
|
5017
|
-
|
|
5069
|
+
function ItemErrorBoundary(props) {
|
|
5070
|
+
var _this;
|
|
5018
5071
|
|
|
5019
|
-
|
|
5020
|
-
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
5021
|
-
var _args = arguments;
|
|
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);
|
|
5072
|
+
_classCallCheck(this, ItemErrorBoundary);
|
|
5029
5073
|
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5074
|
+
_this = _super.call(this, props);
|
|
5075
|
+
_this.state = {
|
|
5076
|
+
hasError: false,
|
|
5077
|
+
itemId: props.itemId
|
|
5078
|
+
};
|
|
5079
|
+
_this.onReload = _this.onReload.bind(_assertThisInitialized(_this));
|
|
5080
|
+
return _this;
|
|
5081
|
+
}
|
|
5033
5082
|
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5083
|
+
_createClass(ItemErrorBoundary, [{
|
|
5084
|
+
key: "componentDidCatch",
|
|
5085
|
+
value: function componentDidCatch(error) {
|
|
5086
|
+
// eslint-disable-next-line no-console
|
|
5087
|
+
console.error("Error for item ".concat(this.state.itemId), error, this.props.state);
|
|
5088
|
+
}
|
|
5089
|
+
}, {
|
|
5090
|
+
key: "onReload",
|
|
5091
|
+
value: function onReload() {
|
|
5092
|
+
this.setState({
|
|
5093
|
+
hasError: false
|
|
5094
|
+
});
|
|
5095
|
+
}
|
|
5096
|
+
}, {
|
|
5097
|
+
key: "render",
|
|
5098
|
+
value: function render() {
|
|
5099
|
+
var ErrorComponent = this.props.ErrorComponent;
|
|
5039
5100
|
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
}
|
|
5101
|
+
if (this.state.hasError) {
|
|
5102
|
+
return /*#__PURE__*/React__default.createElement(ErrorComponent, {
|
|
5103
|
+
onReload: this.onReload
|
|
5104
|
+
});
|
|
5044
5105
|
}
|
|
5045
|
-
}, _callee, null, [[0, 5]]);
|
|
5046
|
-
}));
|
|
5047
|
-
};
|
|
5048
|
-
|
|
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
5106
|
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5107
|
+
return this.props.children;
|
|
5108
|
+
}
|
|
5109
|
+
}], [{
|
|
5110
|
+
key: "getDerivedStateFromError",
|
|
5111
|
+
value: function getDerivedStateFromError() {
|
|
5112
|
+
return {
|
|
5113
|
+
hasError: true
|
|
5114
|
+
};
|
|
5115
|
+
}
|
|
5116
|
+
}]);
|
|
5082
5117
|
|
|
5083
|
-
|
|
5084
|
-
|
|
5118
|
+
return ItemErrorBoundary;
|
|
5119
|
+
}(React__default.Component);
|
|
5085
5120
|
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
}
|
|
5121
|
+
var removeClass = function removeClass(e) {
|
|
5122
|
+
e.target.className = "";
|
|
5123
|
+
};
|
|
5090
5124
|
|
|
5091
|
-
|
|
5092
|
-
|
|
5125
|
+
var defaultResize = function defaultResize(_ref3) {
|
|
5126
|
+
var width = _ref3.width,
|
|
5127
|
+
height = _ref3.height,
|
|
5128
|
+
actualWidth = _ref3.actualWidth,
|
|
5129
|
+
actualHeight = _ref3.actualHeight,
|
|
5130
|
+
prevState = _ref3.prevState,
|
|
5131
|
+
keepRatio = _ref3.keepRatio;
|
|
5132
|
+
var currentWidth = prevState.width,
|
|
5133
|
+
currentHeight = prevState.height; // Parse text values if any
|
|
5134
|
+
|
|
5135
|
+
var _ref4 = [parseFloat(currentWidth), parseFloat(currentHeight)];
|
|
5136
|
+
currentWidth = _ref4[0];
|
|
5137
|
+
currentHeight = _ref4[1];
|
|
5138
|
+
|
|
5139
|
+
if (!currentWidth || Number.isNaN(Number(currentWidth))) {
|
|
5140
|
+
currentWidth = actualWidth;
|
|
5141
|
+
}
|
|
5093
5142
|
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
}
|
|
5098
|
-
}
|
|
5099
|
-
}, _callee2);
|
|
5100
|
-
})));
|
|
5143
|
+
if (!currentHeight || Number.isNaN(Number(currentHeight))) {
|
|
5144
|
+
currentHeight = actualHeight;
|
|
5145
|
+
}
|
|
5101
5146
|
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
}
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
clientX = e.clientX,
|
|
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.
|
|
5147
|
+
if (keepRatio) {
|
|
5148
|
+
var ratio = currentWidth / currentHeight;
|
|
5149
|
+
return _objectSpread2(_objectSpread2({}, prevState), {}, {
|
|
5150
|
+
width: (currentWidth + width).toFixed(1),
|
|
5151
|
+
height: (currentHeight + height / ratio).toFixed(1)
|
|
5152
|
+
});
|
|
5153
|
+
}
|
|
5118
5154
|
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
// Ref: https://medium.com/@auchenberg/detecting-multi-touch-trackpad-gestures-in-javascript-a2505babb10e
|
|
5155
|
+
return _objectSpread2(_objectSpread2({}, prevState), {}, {
|
|
5156
|
+
width: (currentWidth + width).toFixed(1),
|
|
5157
|
+
height: (currentHeight + height).toFixed(1)
|
|
5158
|
+
});
|
|
5159
|
+
};
|
|
5125
5160
|
|
|
5161
|
+
var defaultResizeDirection = {
|
|
5162
|
+
w: true,
|
|
5163
|
+
h: true,
|
|
5164
|
+
b: true
|
|
5165
|
+
};
|
|
5126
5166
|
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
deltaX: -2 * deltaX,
|
|
5130
|
-
deltaY: -2 * deltaY,
|
|
5131
|
-
button: 1,
|
|
5132
|
-
ctrlKey: ctrlKey,
|
|
5133
|
-
metaKey: metaKey,
|
|
5134
|
-
target: target,
|
|
5135
|
-
event: e
|
|
5136
|
-
});
|
|
5137
|
-
} else {
|
|
5138
|
-
// Quit if onZoom is not set
|
|
5139
|
-
if (onZoom === undefined || !deltaY) return;
|
|
5140
|
-
var scale = deltaY;
|
|
5167
|
+
var Item = function Item(_ref5) {
|
|
5168
|
+
var _itemMap$error;
|
|
5141
5169
|
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5170
|
+
var setState = _ref5.setState,
|
|
5171
|
+
_ref5$state = _ref5.state;
|
|
5172
|
+
_ref5$state = _ref5$state === void 0 ? {} : _ref5$state;
|
|
5173
|
+
|
|
5174
|
+
var type = _ref5$state.type,
|
|
5175
|
+
_ref5$state$rotation = _ref5$state.rotation,
|
|
5176
|
+
rotation = _ref5$state$rotation === void 0 ? 0 : _ref5$state$rotation,
|
|
5177
|
+
id = _ref5$state.id,
|
|
5178
|
+
locked = _ref5$state.locked,
|
|
5179
|
+
layer = _ref5$state.layer,
|
|
5180
|
+
rest = _objectWithoutProperties(_ref5$state, _excluded$2),
|
|
5181
|
+
_ref5$animate = _ref5.animate,
|
|
5182
|
+
animate = _ref5$animate === void 0 ? "hvr-pop" : _ref5$animate,
|
|
5183
|
+
isSelected = _ref5.isSelected,
|
|
5184
|
+
itemMap = _ref5.itemMap,
|
|
5185
|
+
_ref5$showResizeHandl = _ref5.showResizeHandle,
|
|
5186
|
+
showResizeHandle = _ref5$showResizeHandl === void 0 ? false : _ref5$showResizeHandl;
|
|
5187
|
+
|
|
5188
|
+
var itemWrapperRef = React__default.useRef(null);
|
|
5189
|
+
var _itemMap$type = itemMap[type],
|
|
5190
|
+
_itemMap$type$compone = _itemMap$type.component,
|
|
5191
|
+
Component = _itemMap$type$compone === void 0 ? function () {
|
|
5192
|
+
return null;
|
|
5193
|
+
} : _itemMap$type$compone,
|
|
5194
|
+
_itemMap$type$resizeD = _itemMap$type.resizeDirections,
|
|
5195
|
+
resizeDirections = _itemMap$type$resizeD === void 0 ? defaultResizeDirection : _itemMap$type$resizeD,
|
|
5196
|
+
_itemMap$type$resize = _itemMap$type.resize,
|
|
5197
|
+
resize = _itemMap$type$resize === void 0 ? defaultResize : _itemMap$type$resize;
|
|
5198
|
+
var updateState = React__default.useCallback(function (callbackOrItem) {
|
|
5199
|
+
var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
5200
|
+
return setState(id, callbackOrItem, sync);
|
|
5201
|
+
}, [setState, id]);
|
|
5202
|
+
React__default.useEffect(function () {
|
|
5203
|
+
itemWrapperRef.current.className = animate;
|
|
5204
|
+
}, [animate]);
|
|
5205
|
+
var className = "item ".concat(id);
|
|
5147
5206
|
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
}
|
|
5207
|
+
if (locked) {
|
|
5208
|
+
className += " locked";
|
|
5209
|
+
}
|
|
5152
5210
|
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5211
|
+
if (isSelected) {
|
|
5212
|
+
className += " selected";
|
|
5213
|
+
}
|
|
5156
5214
|
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5215
|
+
var onResize = React__default.useCallback(function (_ref6) {
|
|
5216
|
+
var _ref6$width = _ref6.width,
|
|
5217
|
+
width = _ref6$width === void 0 ? 0 : _ref6$width,
|
|
5218
|
+
_ref6$height = _ref6.height,
|
|
5219
|
+
height = _ref6$height === void 0 ? 0 : _ref6$height,
|
|
5220
|
+
keepRatio = _ref6.keepRatio;
|
|
5221
|
+
updateState(function (prev) {
|
|
5222
|
+
var _itemWrapperRef$curre = itemWrapperRef.current,
|
|
5223
|
+
offsetWidth = _itemWrapperRef$curre.offsetWidth,
|
|
5224
|
+
offsetHeight = _itemWrapperRef$curre.offsetHeight;
|
|
5225
|
+
return resize({
|
|
5226
|
+
prevState: prev,
|
|
5227
|
+
width: width,
|
|
5228
|
+
height: height,
|
|
5229
|
+
actualHeight: offsetHeight,
|
|
5230
|
+
actualWidth: offsetWidth,
|
|
5231
|
+
keepRatio: keepRatio
|
|
5162
5232
|
});
|
|
5163
|
-
}
|
|
5164
|
-
}, [
|
|
5165
|
-
var
|
|
5166
|
-
var
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5233
|
+
});
|
|
5234
|
+
}, [resize, updateState]);
|
|
5235
|
+
var onResizeWidth = React__default.useCallback(function (_ref7) {
|
|
5236
|
+
var width = _ref7.width;
|
|
5237
|
+
onResize({
|
|
5238
|
+
width: width
|
|
5239
|
+
});
|
|
5240
|
+
}, [onResize]);
|
|
5241
|
+
var onResizeHeight = React__default.useCallback(function (_ref8) {
|
|
5242
|
+
var height = _ref8.height;
|
|
5243
|
+
onResize({
|
|
5244
|
+
height: height
|
|
5245
|
+
});
|
|
5246
|
+
}, [onResize]);
|
|
5247
|
+
var onResizeRatio = React__default.useCallback(function (_ref9) {
|
|
5248
|
+
var width = _ref9.width;
|
|
5249
|
+
onResize({
|
|
5250
|
+
height: width,
|
|
5251
|
+
width: width,
|
|
5252
|
+
keepRatio: true
|
|
5253
|
+
});
|
|
5254
|
+
}, [onResize]);
|
|
5255
|
+
return /*#__PURE__*/React__default.createElement(ItemWrapper, {
|
|
5256
|
+
rotation: rotation,
|
|
5257
|
+
locked: locked,
|
|
5258
|
+
selected: isSelected,
|
|
5259
|
+
layer: layer,
|
|
5260
|
+
"data-id": id,
|
|
5261
|
+
className: className
|
|
5262
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
5263
|
+
style: {
|
|
5264
|
+
display: "flex"
|
|
5265
|
+
},
|
|
5266
|
+
ref: itemWrapperRef,
|
|
5267
|
+
onAnimationEnd: removeClass,
|
|
5268
|
+
onKeyDown: function onKeyDown(e) {
|
|
5269
|
+
return e.stopPropagation();
|
|
5270
|
+
},
|
|
5271
|
+
onKeyUp: function onKeyUp(e) {
|
|
5272
|
+
return e.stopPropagation();
|
|
5273
|
+
}
|
|
5274
|
+
}, /*#__PURE__*/React__default.createElement(ItemErrorBoundary, {
|
|
5275
|
+
itemId: id,
|
|
5276
|
+
state: rest,
|
|
5277
|
+
setState: updateState,
|
|
5278
|
+
ErrorComponent: (itemMap === null || itemMap === void 0 ? void 0 : (_itemMap$error = itemMap.error) === null || _itemMap$error === void 0 ? void 0 : _itemMap$error.component) || DefaultErrorComponent
|
|
5279
|
+
}, /*#__PURE__*/React__default.createElement(Component, _extends$1({}, rest, {
|
|
5280
|
+
id: id,
|
|
5281
|
+
setState: updateState
|
|
5282
|
+
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
5283
|
+
className: "corner top-left"
|
|
5284
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
5285
|
+
className: "corner top-right"
|
|
5286
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
5287
|
+
className: "corner bottom-right"
|
|
5288
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
5289
|
+
className: "corner bottom-left"
|
|
5290
|
+
}), isSelected && showResizeHandle && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, resizeDirections.b && /*#__PURE__*/React__default.createElement(ResizeHandler, {
|
|
5291
|
+
className: "resize resize-ratio",
|
|
5292
|
+
onResize: onResizeRatio
|
|
5293
|
+
}), resizeDirections.h && /*#__PURE__*/React__default.createElement(ResizeHandler, {
|
|
5294
|
+
className: "resize resize-height",
|
|
5295
|
+
onResize: onResizeHeight
|
|
5296
|
+
}), resizeDirections.w && /*#__PURE__*/React__default.createElement(ResizeHandler, {
|
|
5297
|
+
className: "resize resize-width",
|
|
5298
|
+
onResize: onResizeWidth
|
|
5299
|
+
}))));
|
|
5300
|
+
};
|
|
5301
|
+
|
|
5302
|
+
var MemoizedItem = /*#__PURE__*/memo(Item, function (_ref10, _ref11) {
|
|
5303
|
+
var prevState = _ref10.state,
|
|
5304
|
+
prevSetState = _ref10.setState,
|
|
5305
|
+
prevIsSelected = _ref10.isSelected,
|
|
5306
|
+
prevShowResizeHandle = _ref10.showResizeHandle;
|
|
5307
|
+
var nextState = _ref11.state,
|
|
5308
|
+
nextSetState = _ref11.setState,
|
|
5309
|
+
nextIsSelected = _ref11.isSelected,
|
|
5310
|
+
nextShowResizeHandle = _ref11.showResizeHandle;
|
|
5311
|
+
return prevIsSelected === nextIsSelected && prevShowResizeHandle === nextShowResizeHandle && prevSetState === nextSetState && JSON.stringify(prevState) === JSON.stringify(nextState);
|
|
5312
|
+
}); // Exclude positioning from memoization
|
|
5313
|
+
|
|
5314
|
+
var PositionedItem = function PositionedItem(_ref12) {
|
|
5315
|
+
var _ref12$state = _ref12.state,
|
|
5316
|
+
state = _ref12$state === void 0 ? {} : _ref12$state,
|
|
5317
|
+
boardSize = _ref12.boardSize,
|
|
5318
|
+
currentUser = _ref12.currentUser,
|
|
5319
|
+
rest = _objectWithoutProperties(_ref12, _excluded2);
|
|
5320
|
+
|
|
5321
|
+
if (!rest.itemMap[state.type]) {
|
|
5322
|
+
// eslint-disable-next-line no-console
|
|
5323
|
+
console.warn("Item type ".concat(state.type, " not recognized!"));
|
|
5324
|
+
return null;
|
|
5325
|
+
}
|
|
5326
|
+
|
|
5327
|
+
var _rest$itemMap$state$t = rest.itemMap[state.type].stateHook,
|
|
5328
|
+
stateHook = _rest$itemMap$state$t === void 0 ? identity : _rest$itemMap$state$t;
|
|
5329
|
+
|
|
5330
|
+
var _stateHook = stateHook(state, {
|
|
5331
|
+
currentUser: currentUser
|
|
5332
|
+
}),
|
|
5333
|
+
_stateHook$x = _stateHook.x,
|
|
5334
|
+
x = _stateHook$x === void 0 ? 0 : _stateHook$x,
|
|
5335
|
+
_stateHook$y = _stateHook.y,
|
|
5336
|
+
y = _stateHook$y === void 0 ? 0 : _stateHook$y,
|
|
5337
|
+
_stateHook$layer = _stateHook.layer,
|
|
5338
|
+
layer = _stateHook$layer === void 0 ? 0 : _stateHook$layer,
|
|
5339
|
+
moving = _stateHook.moving,
|
|
5340
|
+
stateRest = _objectWithoutProperties(_stateHook, _excluded3);
|
|
5341
|
+
|
|
5342
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
5343
|
+
style: {
|
|
5344
|
+
position: "absolute",
|
|
5345
|
+
top: "".concat(boardSize / 2, "px"),
|
|
5346
|
+
left: "".concat(boardSize / 2, "px"),
|
|
5347
|
+
display: "inline-block",
|
|
5348
|
+
transform: "translate(".concat(x, "px, ").concat(y, "px)"),
|
|
5349
|
+
zIndex: (layer + 4) * 10 + 100 + (moving ? 5 : 0) // Items z-index between 100 and 200
|
|
5180
5350
|
|
|
5181
|
-
if (isPrimary) {
|
|
5182
|
-
// Clean mainPoint on primary pointer
|
|
5183
|
-
stateRef.current.mainPointer = undefined;
|
|
5184
5351
|
}
|
|
5352
|
+
}, /*#__PURE__*/React__default.createElement(MemoizedItem, _extends$1({}, rest, {
|
|
5353
|
+
// Helps to prevent render
|
|
5354
|
+
showResizeHandle: rest.isSelected && rest.showResizeHandle,
|
|
5355
|
+
state: stateRest
|
|
5356
|
+
})));
|
|
5357
|
+
};
|
|
5185
5358
|
|
|
5186
|
-
|
|
5187
|
-
if (stateRef.current.mainPointer !== pointerId) {
|
|
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;
|
|
5359
|
+
var MemoizedPositionedItem = /*#__PURE__*/memo(PositionedItem);
|
|
5193
5360
|
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5361
|
+
var persistUser = function persistUser(user) {
|
|
5362
|
+
localStorage.setItem("user", JSON.stringify(user));
|
|
5363
|
+
};
|
|
5364
|
+
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"];
|
|
5197
5365
|
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
gestureStart: false,
|
|
5202
|
-
startX: clientX,
|
|
5203
|
-
startY: clientY,
|
|
5204
|
-
prevX: newClientX,
|
|
5205
|
-
prevY: newClientY,
|
|
5206
|
-
startDistance: distance,
|
|
5207
|
-
prevDistance: distance
|
|
5208
|
-
});
|
|
5209
|
-
} catch (e) {
|
|
5210
|
-
// eslint-disable-next-line no-console
|
|
5211
|
-
console.log("Error while getting other pointer. Ignoring", e); // eslint-disable-next-line no-unused-expressions
|
|
5366
|
+
var getRandomColor = function getRandomColor() {
|
|
5367
|
+
return colors[Math.floor(Math.random() * colors.length)];
|
|
5368
|
+
}; // TODO remove user persistence
|
|
5212
5369
|
|
|
5213
|
-
stateRef.current.mainPointer === undefined;
|
|
5214
|
-
}
|
|
5215
|
-
}
|
|
5216
5370
|
|
|
5217
|
-
|
|
5218
|
-
|
|
5371
|
+
var getUser = function getUser() {
|
|
5372
|
+
if (localStorage.user) {
|
|
5373
|
+
// Add some mandatory info if missing
|
|
5374
|
+
var localUser = _objectSpread2({
|
|
5375
|
+
name: "Player",
|
|
5376
|
+
color: getRandomColor(),
|
|
5377
|
+
uid: nanoid()
|
|
5378
|
+
}, JSON.parse(localStorage.user)); // Id is given by server
|
|
5379
|
+
// delete localUser.id;
|
|
5219
5380
|
|
|
5220
5381
|
|
|
5221
|
-
|
|
5382
|
+
persistUser(localUser);
|
|
5383
|
+
return localUser;
|
|
5384
|
+
}
|
|
5222
5385
|
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
altKey: altKey,
|
|
5244
|
-
ctrlKey: ctrlKey,
|
|
5245
|
-
metaKey: metaKey,
|
|
5246
|
-
target: target
|
|
5247
|
-
});
|
|
5386
|
+
var newUser = {
|
|
5387
|
+
name: "Player",
|
|
5388
|
+
color: getRandomColor(),
|
|
5389
|
+
uid: nanoid()
|
|
5390
|
+
};
|
|
5391
|
+
persistUser(newUser);
|
|
5392
|
+
return newUser;
|
|
5393
|
+
};
|
|
5394
|
+
var userAtom = atom({
|
|
5395
|
+
key: "user",
|
|
5396
|
+
"default": getUser()
|
|
5397
|
+
});
|
|
5398
|
+
var usersAtom = atom({
|
|
5399
|
+
key: "users",
|
|
5400
|
+
"default": []
|
|
5401
|
+
});
|
|
5402
|
+
var localUsersAtom = selector({
|
|
5403
|
+
key: "localUsersAtom",
|
|
5404
|
+
get: function get(_ref) {
|
|
5405
|
+
var _get = _ref.get;
|
|
5248
5406
|
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5407
|
+
var currentUser = _get(userAtom);
|
|
5408
|
+
|
|
5409
|
+
var users = _get(usersAtom);
|
|
5410
|
+
|
|
5411
|
+
return users.filter(function (_ref2) {
|
|
5412
|
+
var space = _ref2.space;
|
|
5413
|
+
return space === currentUser.space;
|
|
5256
5414
|
});
|
|
5415
|
+
}
|
|
5416
|
+
});
|
|
5257
5417
|
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
}
|
|
5264
|
-
}, [onLongTap, queue]);
|
|
5265
|
-
var onPointerMove = React.useCallback(function (e) {
|
|
5266
|
-
if (stateRef.current.pressed) {
|
|
5267
|
-
var pointerId = e.pointerId,
|
|
5268
|
-
eventClientX = e.clientX,
|
|
5269
|
-
eventClientY = e.clientY,
|
|
5270
|
-
altKey = e.altKey,
|
|
5271
|
-
ctrlKey = e.ctrlKey,
|
|
5272
|
-
metaKey = e.metaKey,
|
|
5273
|
-
pointerType = e.pointerType;
|
|
5418
|
+
var useUsers = function useUsers() {
|
|
5419
|
+
var _useRecoilState = useRecoilState(userAtom),
|
|
5420
|
+
_useRecoilState2 = _slicedToArray(_useRecoilState, 2),
|
|
5421
|
+
currentUser = _useRecoilState2[0],
|
|
5422
|
+
setCurrentUserState = _useRecoilState2[1];
|
|
5274
5423
|
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
clientY: eventClientY
|
|
5280
|
-
};
|
|
5281
|
-
return;
|
|
5282
|
-
}
|
|
5424
|
+
var users = useRecoilValue(usersAtom);
|
|
5425
|
+
var localUsers = useRecoilValue(localUsersAtom);
|
|
5426
|
+
var setCurrentUser = React__default.useCallback(function (callbackOrUser) {
|
|
5427
|
+
var callback = callbackOrUser;
|
|
5283
5428
|
|
|
5284
|
-
|
|
5429
|
+
if (_typeof(callbackOrUser) === "object") {
|
|
5430
|
+
callback = function callback() {
|
|
5431
|
+
return callbackOrUser;
|
|
5432
|
+
};
|
|
5433
|
+
}
|
|
5285
5434
|
|
|
5286
|
-
|
|
5287
|
-
var
|
|
5288
|
-
|
|
5289
|
-
|
|
5435
|
+
setCurrentUserState(function (prevUser) {
|
|
5436
|
+
var newUser = _objectSpread2(_objectSpread2({}, callback(prevUser)), {}, {
|
|
5437
|
+
id: prevUser.id,
|
|
5438
|
+
uid: prevUser.uid
|
|
5439
|
+
});
|
|
5290
5440
|
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5441
|
+
persistUser(newUser);
|
|
5442
|
+
return newUser;
|
|
5443
|
+
});
|
|
5444
|
+
}, [setCurrentUserState]);
|
|
5445
|
+
return {
|
|
5446
|
+
currentUser: currentUser,
|
|
5447
|
+
setCurrentUser: setCurrentUser,
|
|
5448
|
+
users: users,
|
|
5449
|
+
localUsers: localUsers
|
|
5450
|
+
};
|
|
5451
|
+
};
|
|
5296
5452
|
|
|
5453
|
+
var SubscribeUserEvents = function SubscribeUserEvents() {
|
|
5454
|
+
var usersRef = React__default.useRef([]);
|
|
5455
|
+
var setUsers = useSetRecoilState(usersAtom);
|
|
5297
5456
|
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
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
|
|
5457
|
+
var _useRecoilState = useRecoilState(userAtom),
|
|
5458
|
+
_useRecoilState2 = _slicedToArray(_useRecoilState, 2),
|
|
5459
|
+
currentUser = _useRecoilState2[0],
|
|
5460
|
+
setCurrentUserState = _useRecoilState2[1];
|
|
5310
5461
|
|
|
5462
|
+
var _useWire = useWire("room"),
|
|
5463
|
+
wire = _useWire.wire,
|
|
5464
|
+
isMaster = _useWire.isMaster,
|
|
5465
|
+
roomSpace = _useWire.room;
|
|
5311
5466
|
|
|
5312
|
-
|
|
5467
|
+
React__default.useEffect(function () {
|
|
5468
|
+
setCurrentUserState(function (prevUser) {
|
|
5469
|
+
return _objectSpread2(_objectSpread2({}, prevUser), {}, {
|
|
5470
|
+
id: wire.userId,
|
|
5471
|
+
space: roomSpace
|
|
5472
|
+
});
|
|
5473
|
+
});
|
|
5474
|
+
return function () {
|
|
5475
|
+
setCurrentUserState(function (prevUser) {
|
|
5476
|
+
return _objectSpread2(_objectSpread2({}, prevUser), {}, {
|
|
5477
|
+
id: wire.userId,
|
|
5478
|
+
space: null
|
|
5479
|
+
});
|
|
5480
|
+
});
|
|
5481
|
+
};
|
|
5482
|
+
}, [wire.userId, roomSpace, setCurrentUserState]);
|
|
5483
|
+
React__default.useEffect(function () {
|
|
5484
|
+
if (!isMaster) {
|
|
5485
|
+
var onGetUserList = function onGetUserList(userList) {
|
|
5486
|
+
usersRef.current = userList;
|
|
5487
|
+
setUsers(userList);
|
|
5488
|
+
};
|
|
5313
5489
|
|
|
5314
|
-
|
|
5315
|
-
//
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5490
|
+
wire.call("getUserList").then(onGetUserList, function () {
|
|
5491
|
+
// retry later
|
|
5492
|
+
setTimeout(function () {
|
|
5493
|
+
wire.call("getUserList") // eslint-disable-next-line no-console
|
|
5494
|
+
.then(onGetUserList, function (error) {
|
|
5495
|
+
return console.log(error);
|
|
5496
|
+
});
|
|
5497
|
+
}, 1000);
|
|
5498
|
+
});
|
|
5499
|
+
}
|
|
5500
|
+
}, [wire, isMaster, setUsers]); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5319
5501
|
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5502
|
+
var debouncedEmitUpdateUser = useDebouncedCallback(function (newUser) {
|
|
5503
|
+
wire.publish("userUpdate", newUser, true);
|
|
5504
|
+
}, [wire], 500);
|
|
5505
|
+
React__default.useEffect(function () {
|
|
5506
|
+
if (currentUser && currentUser.id) {
|
|
5507
|
+
debouncedEmitUpdateUser(currentUser);
|
|
5508
|
+
}
|
|
5509
|
+
}, [currentUser, debouncedEmitUpdateUser]);
|
|
5510
|
+
React__default.useEffect(function () {
|
|
5511
|
+
var unsub = [];
|
|
5512
|
+
|
|
5513
|
+
if (isMaster) {
|
|
5514
|
+
wire.register("getUserList", function () {
|
|
5515
|
+
return usersRef.current;
|
|
5516
|
+
}).then(function (unregister) {
|
|
5517
|
+
unsub.push(unregister);
|
|
5518
|
+
});
|
|
5519
|
+
unsub.push(wire.subscribe("userUpdate", function (user) {
|
|
5520
|
+
if (usersRef.current.find(function (u) {
|
|
5521
|
+
return u.id === user.id;
|
|
5522
|
+
})) {
|
|
5523
|
+
var newUsers = usersRef.current.map(function (u) {
|
|
5524
|
+
return u.id === user.id ? user : u;
|
|
5336
5525
|
});
|
|
5337
|
-
|
|
5526
|
+
usersRef.current = newUsers;
|
|
5527
|
+
} else {
|
|
5528
|
+
var _newUsers = [].concat(_toConsumableArray(usersRef.current), [user]);
|
|
5338
5529
|
|
|
5530
|
+
usersRef.current = _newUsers;
|
|
5531
|
+
}
|
|
5339
5532
|
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5533
|
+
setUsers(usersRef.current);
|
|
5534
|
+
wire.publish("updateUserList", usersRef.current);
|
|
5535
|
+
}));
|
|
5536
|
+
}
|
|
5344
5537
|
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
clientY: clientY,
|
|
5352
|
-
distanceX: distanceX,
|
|
5353
|
-
distanceY: distanceY,
|
|
5354
|
-
button: stateRef.current.currentButton,
|
|
5355
|
-
altKey: altKey,
|
|
5356
|
-
ctrlKey: ctrlKey,
|
|
5357
|
-
metaKey: metaKey,
|
|
5358
|
-
target: stateRef.current.target,
|
|
5359
|
-
event: e
|
|
5360
|
-
});
|
|
5361
|
-
} else {
|
|
5362
|
-
if (!stateRef.current.gestureStart) {
|
|
5363
|
-
wrapperRef.current.style.cursor = "move";
|
|
5364
|
-
stateRef.current.gestureStart = true; // Clear tap timeout on first move
|
|
5538
|
+
unsub.push(wire.subscribe("userLeave", function (userId) {
|
|
5539
|
+
usersRef.current = usersRef.current.filter(function (_ref) {
|
|
5540
|
+
var id = _ref.id;
|
|
5541
|
+
return id !== userId;
|
|
5542
|
+
});
|
|
5543
|
+
setUsers(usersRef.current);
|
|
5365
5544
|
|
|
5366
|
-
|
|
5367
|
-
|
|
5545
|
+
if (isMaster) {
|
|
5546
|
+
wire.publish("updateUserList", usersRef.current);
|
|
5547
|
+
}
|
|
5548
|
+
}));
|
|
5549
|
+
unsub.push(wire.subscribe("updateUserList", function (newList) {
|
|
5550
|
+
usersRef.current = newList;
|
|
5551
|
+
setUsers(usersRef.current);
|
|
5552
|
+
}));
|
|
5553
|
+
return function () {
|
|
5554
|
+
unsub.forEach(function (u) {
|
|
5555
|
+
return u();
|
|
5556
|
+
});
|
|
5557
|
+
};
|
|
5558
|
+
}, [wire, isMaster, setUsers]);
|
|
5559
|
+
return null;
|
|
5560
|
+
};
|
|
5561
|
+
|
|
5562
|
+
var ItemList = function ItemList() {
|
|
5563
|
+
var _useItemActions = useItemActions(),
|
|
5564
|
+
updateItem = _useItemActions.updateItem;
|
|
5565
|
+
|
|
5566
|
+
var itemList = useRecoilValue(ItemListAtom);
|
|
5567
|
+
var itemMap = useRecoilValue(ItemMapAtom);
|
|
5568
|
+
var selectedItems = useRecoilValue(SelectedItemsAtom);
|
|
5569
|
+
|
|
5570
|
+
var _useRecoilValue = useRecoilValue(ConfigurationAtom),
|
|
5571
|
+
boardSize = _useRecoilValue.boardSize,
|
|
5572
|
+
showResizeHandle = _useRecoilValue.showResizeHandle,
|
|
5573
|
+
itemTemplates = _useRecoilValue.itemTemplates;
|
|
5574
|
+
|
|
5575
|
+
var _useUsers = useUsers(),
|
|
5576
|
+
currentUser = _useUsers.currentUser;
|
|
5577
|
+
|
|
5578
|
+
return itemList.map(function (itemId) {
|
|
5579
|
+
return /*#__PURE__*/React__default.createElement(MemoizedPositionedItem, {
|
|
5580
|
+
key: itemId,
|
|
5581
|
+
state: itemMap[itemId],
|
|
5582
|
+
setState: updateItem,
|
|
5583
|
+
isSelected: selectedItems.includes(itemId),
|
|
5584
|
+
itemMap: itemTemplates,
|
|
5585
|
+
boardSize: boardSize,
|
|
5586
|
+
currentUser: currentUser,
|
|
5587
|
+
showResizeHandle: showResizeHandle
|
|
5588
|
+
});
|
|
5589
|
+
});
|
|
5590
|
+
};
|
|
5591
|
+
|
|
5592
|
+
var SubcribeItemEvents = function SubcribeItemEvents() {
|
|
5593
|
+
var _useWire = useWire("board"),
|
|
5594
|
+
wire = _useWire.wire;
|
|
5595
|
+
|
|
5596
|
+
var setItemMap = useSetRecoilState(ItemMapAtom);
|
|
5597
|
+
|
|
5598
|
+
var _useItemActions = useItemActions(),
|
|
5599
|
+
updateItemOrder = _useItemActions.updateItemOrder,
|
|
5600
|
+
moveItems = _useItemActions.moveItems,
|
|
5601
|
+
removeItems = _useItemActions.removeItems,
|
|
5602
|
+
pushItem = _useItemActions.pushItem;
|
|
5603
|
+
|
|
5604
|
+
var batchUpdate = React__default.useCallback(function (updatedItems) {
|
|
5605
|
+
setItemMap(function (prevItemMap) {
|
|
5606
|
+
return _objectSpread2(_objectSpread2({}, prevItemMap), updatedItems);
|
|
5607
|
+
});
|
|
5608
|
+
}, [setItemMap]);
|
|
5609
|
+
React__default.useEffect(function () {
|
|
5610
|
+
var unsub = wire.subscribe("batchItemsUpdate", function (updatedItems) {
|
|
5611
|
+
batchUpdate(updatedItems);
|
|
5612
|
+
});
|
|
5613
|
+
return unsub;
|
|
5614
|
+
}, [wire, batchUpdate]);
|
|
5615
|
+
React__default.useEffect(function () {
|
|
5616
|
+
var unsub = wire.subscribe("selectedItemsMove", function (_ref) {
|
|
5617
|
+
var itemIds = _ref.itemIds,
|
|
5618
|
+
posDelta = _ref.posDelta;
|
|
5619
|
+
moveItems(itemIds, posDelta, false);
|
|
5620
|
+
});
|
|
5621
|
+
return unsub;
|
|
5622
|
+
}, [wire, moveItems]);
|
|
5623
|
+
React__default.useEffect(function () {
|
|
5624
|
+
var unsub = wire.subscribe("updateItemListOrder", function (itemIds) {
|
|
5625
|
+
updateItemOrder(itemIds, false);
|
|
5626
|
+
});
|
|
5627
|
+
return unsub;
|
|
5628
|
+
}, [wire, updateItemOrder]);
|
|
5629
|
+
React__default.useEffect(function () {
|
|
5630
|
+
var unsub = wire.subscribe("pushItem", function (newItem) {
|
|
5631
|
+
pushItem(newItem, null, false);
|
|
5632
|
+
});
|
|
5633
|
+
return unsub;
|
|
5634
|
+
}, [wire, pushItem]);
|
|
5635
|
+
React__default.useEffect(function () {
|
|
5636
|
+
var unsub = wire.subscribe("insertItemBefore", function (_ref2) {
|
|
5637
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
5638
|
+
newItem = _ref3[0],
|
|
5639
|
+
beforeId = _ref3[1];
|
|
5368
5640
|
|
|
5641
|
+
pushItem(newItem, beforeId, false);
|
|
5642
|
+
});
|
|
5643
|
+
return unsub;
|
|
5644
|
+
}, [wire, pushItem]);
|
|
5645
|
+
React__default.useEffect(function () {
|
|
5646
|
+
var unsub = wire.subscribe("removeItems", function (itemIds) {
|
|
5647
|
+
removeItems(itemIds, false);
|
|
5648
|
+
});
|
|
5649
|
+
return unsub;
|
|
5650
|
+
}, [wire, removeItems]);
|
|
5651
|
+
return null;
|
|
5652
|
+
};
|
|
5369
5653
|
|
|
5370
|
-
|
|
5654
|
+
/**
|
|
5655
|
+
* Check if element or parent has className.
|
|
5656
|
+
* @param {DOMElement} element
|
|
5657
|
+
* @param {string} className
|
|
5658
|
+
*/
|
|
5659
|
+
var hasClass = function hasClass(element, className) {
|
|
5660
|
+
return element.classList && element.classList.contains(className);
|
|
5661
|
+
};
|
|
5662
|
+
var insideClass = function insideClass(element, className) {
|
|
5663
|
+
if (hasClass(element, className)) {
|
|
5664
|
+
return element;
|
|
5665
|
+
}
|
|
5371
5666
|
|
|
5372
|
-
|
|
5667
|
+
if (!element.parentNode) {
|
|
5668
|
+
return false;
|
|
5669
|
+
}
|
|
5373
5670
|
|
|
5374
|
-
|
|
5671
|
+
return insideClass(element.parentNode, className);
|
|
5672
|
+
};
|
|
5673
|
+
var isPointInsideRect = function isPointInsideRect(point, rect) {
|
|
5674
|
+
return point.x > rect.left && point.x < rect.left + rect.width && point.y > rect.top && point.y < rect.top + rect.height;
|
|
5675
|
+
};
|
|
5676
|
+
var isItemInsideElement = function isItemInsideElement(itemElement, otherElem) {
|
|
5677
|
+
var rect = otherElem.getBoundingClientRect();
|
|
5678
|
+
var fourElem = Array.from(itemElement.querySelectorAll(".corner"));
|
|
5679
|
+
return fourElem.every(function (corner) {
|
|
5680
|
+
var _corner$getBoundingCl = corner.getBoundingClientRect(),
|
|
5681
|
+
y = _corner$getBoundingCl.top,
|
|
5682
|
+
x = _corner$getBoundingCl.left;
|
|
5375
5683
|
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
});
|
|
5684
|
+
return isPointInsideRect({
|
|
5685
|
+
x: x,
|
|
5686
|
+
y: y
|
|
5687
|
+
}, rect);
|
|
5688
|
+
});
|
|
5689
|
+
};
|
|
5690
|
+
var getItemElem = function getItemElem(wrapper, itemId) {
|
|
5691
|
+
var elems = wrapper.getElementsByClassName("item ".concat(itemId));
|
|
5692
|
+
var elem = elems[0];
|
|
5386
5693
|
|
|
5387
|
-
|
|
5388
|
-
|
|
5694
|
+
if (!elem) {
|
|
5695
|
+
// eslint-disable-next-line no-console
|
|
5696
|
+
console.error("Missing item ".concat(itemId));
|
|
5697
|
+
}
|
|
5389
5698
|
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
clientY: clientY,
|
|
5395
|
-
event: e
|
|
5396
|
-
});
|
|
5397
|
-
stateRef.current.prevDistance = distance;
|
|
5398
|
-
}
|
|
5399
|
-
}
|
|
5400
|
-
}
|
|
5699
|
+
return elem;
|
|
5700
|
+
};
|
|
5701
|
+
var getIdFromElem = function getIdFromElem(elem) {
|
|
5702
|
+
var _elem$dataset;
|
|
5401
5703
|
|
|
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;
|
|
5704
|
+
var value = elem === null || elem === void 0 ? void 0 : (_elem$dataset = elem.dataset) === null || _elem$dataset === void 0 ? void 0 : _elem$dataset.id;
|
|
5414
5705
|
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
// ignoring it
|
|
5418
|
-
return;
|
|
5419
|
-
} // Remove pointer from map
|
|
5706
|
+
if (!value) {
|
|
5707
|
+
var _elem$dataset2;
|
|
5420
5708
|
|
|
5709
|
+
// eslint-disable-next-line no-console
|
|
5710
|
+
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);
|
|
5711
|
+
}
|
|
5421
5712
|
|
|
5422
|
-
|
|
5713
|
+
return value;
|
|
5714
|
+
};
|
|
5715
|
+
var getItemBoundingBox = function getItemBoundingBox(items) {
|
|
5716
|
+
var wrapper = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
|
|
5717
|
+
var result = items.reduce(function (prev, itemId) {
|
|
5718
|
+
var elem = getItemElem(wrapper, itemId);
|
|
5719
|
+
if (!elem) return null;
|
|
5423
5720
|
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5721
|
+
var _elem$getBoundingClie = elem.getBoundingClientRect(),
|
|
5722
|
+
left = _elem$getBoundingClie.left,
|
|
5723
|
+
right = _elem$getBoundingClie.right,
|
|
5724
|
+
top = _elem$getBoundingClie.top,
|
|
5725
|
+
bottom = _elem$getBoundingClie.bottom;
|
|
5428
5726
|
|
|
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]);
|
|
5727
|
+
var boundingBox;
|
|
5432
5728
|
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
|
|
5729
|
+
if (!prev) {
|
|
5730
|
+
boundingBox = {
|
|
5731
|
+
left: left,
|
|
5732
|
+
top: top,
|
|
5733
|
+
right: right,
|
|
5734
|
+
bottom: bottom
|
|
5735
|
+
};
|
|
5736
|
+
} else {
|
|
5737
|
+
boundingBox = prev;
|
|
5442
5738
|
}
|
|
5443
5739
|
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5740
|
+
boundingBox.left = Math.min(left, boundingBox.left);
|
|
5741
|
+
boundingBox.top = Math.min(top, boundingBox.top);
|
|
5742
|
+
boundingBox.right = Math.max(right, boundingBox.right);
|
|
5743
|
+
boundingBox.bottom = Math.max(bottom, boundingBox.bottom);
|
|
5744
|
+
return boundingBox;
|
|
5745
|
+
}, null);
|
|
5448
5746
|
|
|
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();
|
|
5747
|
+
if (!result) {
|
|
5748
|
+
return result;
|
|
5749
|
+
}
|
|
5470
5750
|
|
|
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);
|
|
5751
|
+
result.width = result.right - result.left;
|
|
5752
|
+
result.height = result.bottom - result.top;
|
|
5753
|
+
return result;
|
|
5503
5754
|
};
|
|
5504
5755
|
|
|
5505
5756
|
var defaultSelectorStyle = {
|
|
@@ -5540,17 +5791,17 @@ var Selector = function Selector(_ref) {
|
|
|
5540
5791
|
var _useItemActions = useItemActions(),
|
|
5541
5792
|
findElementUnderPointer = _useItemActions.findElementUnderPointer;
|
|
5542
5793
|
|
|
5543
|
-
var _React$useState =
|
|
5794
|
+
var _React$useState = React__default.useState({}),
|
|
5544
5795
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
5545
5796
|
selector = _React$useState2[0],
|
|
5546
5797
|
setSelector = _React$useState2[1];
|
|
5547
5798
|
|
|
5548
|
-
var wrapperRef =
|
|
5549
|
-
var stateRef =
|
|
5799
|
+
var wrapperRef = React__default.useRef(null);
|
|
5800
|
+
var stateRef = React__default.useRef({
|
|
5550
5801
|
moving: false
|
|
5551
5802
|
}); // Reset selection on board loading
|
|
5552
5803
|
|
|
5553
|
-
|
|
5804
|
+
React__default.useEffect(function () {
|
|
5554
5805
|
setSelected(function (prev) {
|
|
5555
5806
|
return prev.length === 0 ? prev : [];
|
|
5556
5807
|
});
|
|
@@ -5721,7 +5972,7 @@ var Selector = function Selector(_ref) {
|
|
|
5721
5972
|
}
|
|
5722
5973
|
};
|
|
5723
5974
|
|
|
5724
|
-
var onLongTap =
|
|
5975
|
+
var onLongTap = React__default.useCallback(function (_ref8) {
|
|
5725
5976
|
var target = _ref8.target;
|
|
5726
5977
|
var foundElement = insideClass(target, "item");
|
|
5727
5978
|
|
|
@@ -5796,15 +6047,15 @@ var Selector = function Selector(_ref) {
|
|
|
5796
6047
|
};
|
|
5797
6048
|
}();
|
|
5798
6049
|
}, [findElementUnderPointer, setSelected]);
|
|
5799
|
-
return /*#__PURE__*/
|
|
6050
|
+
return /*#__PURE__*/React__default.createElement(Gesture, {
|
|
5800
6051
|
onDragStart: onDragStart,
|
|
5801
6052
|
onDrag: onDrag,
|
|
5802
6053
|
onDragEnd: onDragEnd,
|
|
5803
6054
|
onTap: onTap,
|
|
5804
6055
|
onLongTap: onLongTap
|
|
5805
|
-
}, /*#__PURE__*/
|
|
6056
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
5806
6057
|
ref: wrapperRef
|
|
5807
|
-
}, selector.moving && /*#__PURE__*/
|
|
6058
|
+
}, selector.moving && /*#__PURE__*/React__default.createElement("div", {
|
|
5808
6059
|
style: _objectSpread2(_objectSpread2({}, defaultSelectorStyle), {}, {
|
|
5809
6060
|
transform: "translate(".concat(selector.left, "px, ").concat(selector.top, "px)"),
|
|
5810
6061
|
height: "".concat(selector.height, "px"),
|
|
@@ -5824,9 +6075,9 @@ var ActionPane = function ActionPane(_ref) {
|
|
|
5824
6075
|
|
|
5825
6076
|
var setSelectedItems = useSetRecoilState(SelectedItemsAtom);
|
|
5826
6077
|
var setBoardState = useSetRecoilState(BoardStateAtom);
|
|
5827
|
-
var actionRef =
|
|
6078
|
+
var actionRef = React__default.useRef({}); // Use ref because pointer events are faster than react state management
|
|
5828
6079
|
|
|
5829
|
-
var selectedItemRef =
|
|
6080
|
+
var selectedItemRef = React__default.useRef({
|
|
5830
6081
|
items: []
|
|
5831
6082
|
});
|
|
5832
6083
|
var onDragStart = useRecoilCallback(function (_ref2) {
|
|
@@ -6082,167 +6333,236 @@ var ActionPane = function ActionPane(_ref) {
|
|
|
6082
6333
|
};
|
|
6083
6334
|
}();
|
|
6084
6335
|
}, [moveItems, placeItems]);
|
|
6085
|
-
|
|
6336
|
+
React__default.useEffect(function () {
|
|
6086
6337
|
document.addEventListener("keydown", onKeyDown);
|
|
6087
6338
|
return function () {
|
|
6088
6339
|
document.removeEventListener("keydown", onKeyDown);
|
|
6089
6340
|
};
|
|
6090
6341
|
}, [onKeyDown]);
|
|
6091
|
-
return /*#__PURE__*/
|
|
6342
|
+
return /*#__PURE__*/React__default.createElement(Gesture, {
|
|
6092
6343
|
onDragStart: onDragStart,
|
|
6093
6344
|
onDrag: onDrag,
|
|
6094
6345
|
onDragEnd: onDragEnd
|
|
6095
6346
|
}, children);
|
|
6096
6347
|
};
|
|
6097
6348
|
|
|
6098
|
-
|
|
6099
|
-
|
|
6349
|
+
/**
|
|
6350
|
+
* A simple guard function:
|
|
6351
|
+
*
|
|
6352
|
+
* ```js
|
|
6353
|
+
* Math.min(Math.max(low, value), high)
|
|
6354
|
+
* ```
|
|
6355
|
+
*/
|
|
6356
|
+
function guard(low, high, value) {
|
|
6357
|
+
return Math.min(Math.max(low, value), high);
|
|
6100
6358
|
}
|
|
6101
6359
|
|
|
6102
|
-
var
|
|
6103
|
-
_inherits(
|
|
6360
|
+
var ColorError = /*#__PURE__*/function (_Error) {
|
|
6361
|
+
_inherits(ColorError, _Error);
|
|
6104
6362
|
|
|
6105
|
-
var _super = _createSuper(
|
|
6363
|
+
var _super = _createSuper(ColorError);
|
|
6106
6364
|
|
|
6107
|
-
function
|
|
6108
|
-
_classCallCheck(this,
|
|
6365
|
+
function ColorError(color) {
|
|
6366
|
+
_classCallCheck(this, ColorError);
|
|
6109
6367
|
|
|
6110
|
-
return _super.call(this, "Failed to parse color: \"".concat(
|
|
6368
|
+
return _super.call(this, "Failed to parse color: \"".concat(color, "\""));
|
|
6111
6369
|
}
|
|
6112
6370
|
|
|
6113
|
-
return
|
|
6371
|
+
return ColorError;
|
|
6114
6372
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
6115
6373
|
|
|
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);
|
|
6374
|
+
var ColorError$1 = ColorError;
|
|
6375
|
+
/**
|
|
6376
|
+
* Parses a color into red, gree, blue, alpha parts
|
|
6377
|
+
*
|
|
6378
|
+
* @param color the input color. Can be a RGB, RBGA, HSL, HSLA, or named color
|
|
6379
|
+
*/
|
|
6140
6380
|
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6381
|
+
function parseToRgba(color) {
|
|
6382
|
+
if (typeof color !== 'string') throw new ColorError$1(color);
|
|
6383
|
+
if (color.trim().toLowerCase() === 'transparent') return [0, 0, 0, 0];
|
|
6384
|
+
var normalizedColor = color.trim();
|
|
6385
|
+
normalizedColor = namedColorRegex.test(color) ? nameToHex(color) : color;
|
|
6386
|
+
var reducedHexMatch = reducedHexRegex.exec(normalizedColor);
|
|
6387
|
+
|
|
6388
|
+
if (reducedHexMatch) {
|
|
6389
|
+
var arr = Array.from(reducedHexMatch).slice(1);
|
|
6390
|
+
return [].concat(_toConsumableArray(arr.slice(0, 3).map(function (x) {
|
|
6391
|
+
return parseInt(r(x, 2), 16);
|
|
6392
|
+
})), [parseInt(r(arr[3] || 'f', 2), 16) / 255]);
|
|
6144
6393
|
}
|
|
6145
6394
|
|
|
6146
|
-
var
|
|
6395
|
+
var hexMatch = hexRegex.exec(normalizedColor);
|
|
6147
6396
|
|
|
6148
|
-
if (
|
|
6149
|
-
var
|
|
6397
|
+
if (hexMatch) {
|
|
6398
|
+
var _arr = Array.from(hexMatch).slice(1);
|
|
6150
6399
|
|
|
6151
|
-
return [].concat(_toConsumableArray(
|
|
6152
|
-
return parseInt(
|
|
6153
|
-
})), [parseInt(
|
|
6400
|
+
return [].concat(_toConsumableArray(_arr.slice(0, 3).map(function (x) {
|
|
6401
|
+
return parseInt(x, 16);
|
|
6402
|
+
})), [parseInt(_arr[3] || 'ff', 16) / 255]);
|
|
6154
6403
|
}
|
|
6155
6404
|
|
|
6156
|
-
var
|
|
6405
|
+
var rgbaMatch = rgbaRegex.exec(normalizedColor);
|
|
6157
6406
|
|
|
6158
|
-
if (
|
|
6159
|
-
var
|
|
6407
|
+
if (rgbaMatch) {
|
|
6408
|
+
var _arr2 = Array.from(rgbaMatch).slice(1);
|
|
6160
6409
|
|
|
6161
|
-
return [].concat(_toConsumableArray(
|
|
6162
|
-
return parseInt(
|
|
6163
|
-
})), [parseFloat(
|
|
6410
|
+
return [].concat(_toConsumableArray(_arr2.slice(0, 3).map(function (x) {
|
|
6411
|
+
return parseInt(x, 10);
|
|
6412
|
+
})), [parseFloat(_arr2[3] || '1')]);
|
|
6164
6413
|
}
|
|
6165
6414
|
|
|
6166
|
-
var
|
|
6415
|
+
var hslaMatch = hslaRegex.exec(normalizedColor);
|
|
6167
6416
|
|
|
6168
|
-
if (
|
|
6169
|
-
var _Array$from$slice$map = Array.from(
|
|
6417
|
+
if (hslaMatch) {
|
|
6418
|
+
var _Array$from$slice$map = Array.from(hslaMatch).slice(1).map(parseFloat),
|
|
6170
6419
|
_Array$from$slice$map2 = _slicedToArray(_Array$from$slice$map, 4),
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
if (
|
|
6177
|
-
if (
|
|
6178
|
-
return [].concat(_toConsumableArray(
|
|
6420
|
+
h = _Array$from$slice$map2[0],
|
|
6421
|
+
s = _Array$from$slice$map2[1],
|
|
6422
|
+
l = _Array$from$slice$map2[2],
|
|
6423
|
+
a = _Array$from$slice$map2[3];
|
|
6424
|
+
|
|
6425
|
+
if (guard(0, 100, s) !== s) throw new ColorError$1(color);
|
|
6426
|
+
if (guard(0, 100, l) !== l) throw new ColorError$1(color);
|
|
6427
|
+
return [].concat(_toConsumableArray(hslToRgb(h, s, l)), [a || 1]);
|
|
6179
6428
|
}
|
|
6180
6429
|
|
|
6181
|
-
throw new
|
|
6430
|
+
throw new ColorError$1(color);
|
|
6182
6431
|
}
|
|
6183
6432
|
|
|
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 _ = "";
|
|
6433
|
+
function hash(str) {
|
|
6434
|
+
var hash = 5381;
|
|
6435
|
+
var i = str.length;
|
|
6191
6436
|
|
|
6192
|
-
|
|
6193
|
-
|
|
6437
|
+
while (i) {
|
|
6438
|
+
hash = hash * 33 ^ str.charCodeAt(--i);
|
|
6194
6439
|
}
|
|
6440
|
+
/* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
|
|
6441
|
+
* integers. Since we want the results to be always positive, convert the
|
|
6442
|
+
* signed int to an unsigned by doing an unsigned bitshift. */
|
|
6443
|
+
|
|
6195
6444
|
|
|
6196
|
-
return
|
|
6197
|
-
}
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
}).join("");
|
|
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);
|
|
6445
|
+
return (hash >>> 0) % 2341;
|
|
6446
|
+
}
|
|
6447
|
+
|
|
6448
|
+
var colorToInt = function colorToInt(x) {
|
|
6449
|
+
return parseInt(x.replace(/_/g, ''), 36);
|
|
6225
6450
|
};
|
|
6226
6451
|
|
|
6227
|
-
function
|
|
6228
|
-
|
|
6452
|
+
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) {
|
|
6453
|
+
var key = colorToInt(next.substring(0, 3));
|
|
6454
|
+
var hex = colorToInt(next.substring(3)).toString(16); // NOTE: padStart could be used here but it breaks Node 6 compat
|
|
6455
|
+
// https://github.com/ricokahler/color2k/issues/351
|
|
6229
6456
|
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6457
|
+
var prefix = '';
|
|
6458
|
+
|
|
6459
|
+
for (var i = 0; i < 6 - hex.length; i++) {
|
|
6460
|
+
prefix += '0';
|
|
6233
6461
|
}
|
|
6234
6462
|
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6463
|
+
acc[key] = "".concat(prefix).concat(hex);
|
|
6464
|
+
return acc;
|
|
6465
|
+
}, {});
|
|
6466
|
+
/**
|
|
6467
|
+
* Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.
|
|
6468
|
+
*/
|
|
6240
6469
|
|
|
6241
|
-
|
|
6470
|
+
function nameToHex(color) {
|
|
6471
|
+
var normalizedColorName = color.toLowerCase().trim();
|
|
6472
|
+
var result = compressedColorMap[hash(normalizedColorName)];
|
|
6473
|
+
if (!result) throw new ColorError$1(color);
|
|
6474
|
+
return "#".concat(result);
|
|
6242
6475
|
}
|
|
6243
6476
|
|
|
6244
|
-
function
|
|
6245
|
-
return
|
|
6477
|
+
var r = function r(str, amount) {
|
|
6478
|
+
return Array.from(Array(amount)).map(function () {
|
|
6479
|
+
return str;
|
|
6480
|
+
}).join('');
|
|
6481
|
+
};
|
|
6482
|
+
|
|
6483
|
+
var reducedHexRegex = new RegExp("^#".concat(r('([a-f0-9])', 3), "([a-f0-9])?$"), 'i');
|
|
6484
|
+
var hexRegex = new RegExp("^#".concat(r('([a-f0-9]{2})', 3), "([a-f0-9]{2})?$"), 'i');
|
|
6485
|
+
var rgbaRegex = new RegExp("^rgba?\\(\\s*(\\d+)\\s*".concat(r(',\\s*(\\d+)\\s*', 2), "(?:,\\s*([\\d.]+))?\\s*\\)$"), 'i');
|
|
6486
|
+
var hslaRegex = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i;
|
|
6487
|
+
var namedColorRegex = /^[a-z]+$/i;
|
|
6488
|
+
|
|
6489
|
+
var roundColor = function roundColor(color) {
|
|
6490
|
+
return Math.round(color * 255);
|
|
6491
|
+
};
|
|
6492
|
+
|
|
6493
|
+
var hslToRgb = function hslToRgb(hue, saturation, lightness) {
|
|
6494
|
+
var l = lightness / 100;
|
|
6495
|
+
|
|
6496
|
+
if (saturation === 0) {
|
|
6497
|
+
// achromatic
|
|
6498
|
+
return [l, l, l].map(roundColor);
|
|
6499
|
+
} // formulae from https://en.wikipedia.org/wiki/HSL_and_HSV
|
|
6500
|
+
|
|
6501
|
+
|
|
6502
|
+
var huePrime = (hue % 360 + 360) % 360 / 60;
|
|
6503
|
+
var chroma = (1 - Math.abs(2 * l - 1)) * (saturation / 100);
|
|
6504
|
+
var secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
|
|
6505
|
+
var red = 0;
|
|
6506
|
+
var green = 0;
|
|
6507
|
+
var blue = 0;
|
|
6508
|
+
|
|
6509
|
+
if (huePrime >= 0 && huePrime < 1) {
|
|
6510
|
+
red = chroma;
|
|
6511
|
+
green = secondComponent;
|
|
6512
|
+
} else if (huePrime >= 1 && huePrime < 2) {
|
|
6513
|
+
red = secondComponent;
|
|
6514
|
+
green = chroma;
|
|
6515
|
+
} else if (huePrime >= 2 && huePrime < 3) {
|
|
6516
|
+
green = chroma;
|
|
6517
|
+
blue = secondComponent;
|
|
6518
|
+
} else if (huePrime >= 3 && huePrime < 4) {
|
|
6519
|
+
green = secondComponent;
|
|
6520
|
+
blue = chroma;
|
|
6521
|
+
} else if (huePrime >= 4 && huePrime < 5) {
|
|
6522
|
+
red = secondComponent;
|
|
6523
|
+
blue = chroma;
|
|
6524
|
+
} else if (huePrime >= 5 && huePrime < 6) {
|
|
6525
|
+
red = chroma;
|
|
6526
|
+
blue = secondComponent;
|
|
6527
|
+
}
|
|
6528
|
+
|
|
6529
|
+
var lightnessModification = l - chroma / 2;
|
|
6530
|
+
var finalRed = red + lightnessModification;
|
|
6531
|
+
var finalGreen = green + lightnessModification;
|
|
6532
|
+
var finalBlue = blue + lightnessModification;
|
|
6533
|
+
return [finalRed, finalGreen, finalBlue].map(roundColor);
|
|
6534
|
+
}; // taken from:
|
|
6535
|
+
|
|
6536
|
+
/**
|
|
6537
|
+
* Returns a number (float) representing the luminance of a color.
|
|
6538
|
+
*/
|
|
6539
|
+
|
|
6540
|
+
|
|
6541
|
+
function getLuminance(color) {
|
|
6542
|
+
if (color === 'transparent') return 0;
|
|
6543
|
+
|
|
6544
|
+
function f(x) {
|
|
6545
|
+
var channel = x / 255;
|
|
6546
|
+
return channel <= 0.03928 ? channel / 12.92 : Math.pow((channel + 0.055) / 1.055, 2.4);
|
|
6547
|
+
}
|
|
6548
|
+
|
|
6549
|
+
var _parseToRgba = parseToRgba(color),
|
|
6550
|
+
_parseToRgba2 = _slicedToArray(_parseToRgba, 3),
|
|
6551
|
+
r = _parseToRgba2[0],
|
|
6552
|
+
g = _parseToRgba2[1],
|
|
6553
|
+
b = _parseToRgba2[2];
|
|
6554
|
+
|
|
6555
|
+
return 0.2126 * f(r) + 0.7152 * f(g) + 0.0722 * f(b);
|
|
6556
|
+
} // taken from:
|
|
6557
|
+
/**
|
|
6558
|
+
* An alternative function to `readableColor`. Returns whether or not the
|
|
6559
|
+
* readable color (i.e. the color to be place on top the input color) should be
|
|
6560
|
+
* black.
|
|
6561
|
+
*/
|
|
6562
|
+
|
|
6563
|
+
|
|
6564
|
+
function readableColorIsBlack(color) {
|
|
6565
|
+
return getLuminance(color) > 0.179;
|
|
6246
6566
|
}
|
|
6247
6567
|
|
|
6248
6568
|
var _excluded$1 = ["pos"];
|
|
@@ -6263,39 +6583,39 @@ var Cursor = function Cursor(_ref3) {
|
|
|
6263
6583
|
_ref3$size = _ref3.size,
|
|
6264
6584
|
size = _ref3$size === void 0 ? 40 : _ref3$size,
|
|
6265
6585
|
text = _ref3.text;
|
|
6266
|
-
var textColor =
|
|
6267
|
-
return /*#__PURE__*/
|
|
6586
|
+
var textColor = readableColorIsBlack(color) ? "#222" : "#EEE";
|
|
6587
|
+
return /*#__PURE__*/React__default.createElement(StyledCursor, null, /*#__PURE__*/React__default.createElement("svg", {
|
|
6268
6588
|
version: "1.1",
|
|
6269
6589
|
id: "Layer_1",
|
|
6270
6590
|
xmlns: "http://www.w3.org/2000/svg",
|
|
6271
6591
|
viewBox: "1064.7701 445.5539 419.8101 717.0565",
|
|
6272
6592
|
width: size,
|
|
6273
6593
|
height: size
|
|
6274
|
-
}, /*#__PURE__*/
|
|
6594
|
+
}, /*#__PURE__*/React__default.createElement("path", {
|
|
6275
6595
|
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
6596
|
style: {
|
|
6277
6597
|
fill: textColor
|
|
6278
6598
|
}
|
|
6279
|
-
}), /*#__PURE__*/
|
|
6599
|
+
}), /*#__PURE__*/React__default.createElement("path", {
|
|
6280
6600
|
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
6601
|
style: {
|
|
6282
6602
|
fill: "white",
|
|
6283
6603
|
stroke: "#111",
|
|
6284
6604
|
strokeWidth: 20
|
|
6285
6605
|
}
|
|
6286
|
-
})), /*#__PURE__*/
|
|
6606
|
+
})), /*#__PURE__*/React__default.createElement(CursorName, {
|
|
6287
6607
|
color: color,
|
|
6288
6608
|
textColor: textColor
|
|
6289
6609
|
}, text));
|
|
6290
6610
|
};
|
|
6291
6611
|
|
|
6292
|
-
var MemoizedCursor = /*#__PURE__*/
|
|
6612
|
+
var MemoizedCursor = /*#__PURE__*/React__default.memo(Cursor);
|
|
6293
6613
|
|
|
6294
6614
|
var PositionnedCursor = function PositionnedCursor(_ref4) {
|
|
6295
6615
|
var pos = _ref4.pos,
|
|
6296
6616
|
rest = _objectWithoutProperties(_ref4, _excluded$1);
|
|
6297
6617
|
|
|
6298
|
-
return /*#__PURE__*/
|
|
6618
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
6299
6619
|
style: {
|
|
6300
6620
|
transform: "translate(".concat(pos.x - 5, "px, ").concat(pos.y - 3, "px)"),
|
|
6301
6621
|
top: 0,
|
|
@@ -6304,7 +6624,7 @@ var PositionnedCursor = function PositionnedCursor(_ref4) {
|
|
|
6304
6624
|
position: "fixed",
|
|
6305
6625
|
pointerEvents: "none"
|
|
6306
6626
|
}
|
|
6307
|
-
}, /*#__PURE__*/
|
|
6627
|
+
}, /*#__PURE__*/React__default.createElement(MemoizedCursor, rest));
|
|
6308
6628
|
};
|
|
6309
6629
|
|
|
6310
6630
|
var Cursors = function Cursors(_ref) {
|
|
@@ -6313,20 +6633,20 @@ var Cursors = function Cursors(_ref) {
|
|
|
6313
6633
|
var _useWire = useWire("board"),
|
|
6314
6634
|
wire = _useWire.wire;
|
|
6315
6635
|
|
|
6316
|
-
var _React$useState =
|
|
6636
|
+
var _React$useState = React__default.useState({}),
|
|
6317
6637
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
6318
6638
|
cursors = _React$useState2[0],
|
|
6319
6639
|
setCursors = _React$useState2[1];
|
|
6320
6640
|
|
|
6321
|
-
var preventRef =
|
|
6322
|
-
var usersById =
|
|
6641
|
+
var preventRef = React__default.useRef(false);
|
|
6642
|
+
var usersById = React__default.useMemo(function () {
|
|
6323
6643
|
return users.reduce(function (acc, user) {
|
|
6324
6644
|
acc[user.id] = user;
|
|
6325
6645
|
return acc;
|
|
6326
6646
|
}, {});
|
|
6327
6647
|
}, [users]); // Prevent race condition when removing user
|
|
6328
6648
|
|
|
6329
|
-
var currentCursor =
|
|
6649
|
+
var currentCursor = React__default.useMemo(function () {
|
|
6330
6650
|
return users.reduce(function (acc, user) {
|
|
6331
6651
|
if (cursors[user.id]) {
|
|
6332
6652
|
acc[user.id] = cursors[user.id];
|
|
@@ -6335,7 +6655,7 @@ var Cursors = function Cursors(_ref) {
|
|
|
6335
6655
|
return acc;
|
|
6336
6656
|
}, {});
|
|
6337
6657
|
}, [users, cursors]);
|
|
6338
|
-
|
|
6658
|
+
React__default.useEffect(function () {
|
|
6339
6659
|
setCursors(function (prevCursors) {
|
|
6340
6660
|
return users.reduce(function (acc, user) {
|
|
6341
6661
|
if (prevCursors[user.id]) {
|
|
@@ -6346,7 +6666,7 @@ var Cursors = function Cursors(_ref) {
|
|
|
6346
6666
|
}, {});
|
|
6347
6667
|
});
|
|
6348
6668
|
}, [users]);
|
|
6349
|
-
|
|
6669
|
+
React__default.useEffect(function () {
|
|
6350
6670
|
var unsub = [];
|
|
6351
6671
|
unsub.push(wire.subscribe("cursorMove", function (_ref2) {
|
|
6352
6672
|
var userId = _ref2.userId,
|
|
@@ -6377,12 +6697,12 @@ var Cursors = function Cursors(_ref) {
|
|
|
6377
6697
|
});
|
|
6378
6698
|
};
|
|
6379
6699
|
}, [wire]);
|
|
6380
|
-
return /*#__PURE__*/
|
|
6700
|
+
return /*#__PURE__*/React__default.createElement("div", null, Object.entries(currentCursor).map(function (_ref4) {
|
|
6381
6701
|
var _ref5 = _slicedToArray(_ref4, 2),
|
|
6382
6702
|
userId = _ref5[0],
|
|
6383
6703
|
pos = _ref5[1];
|
|
6384
6704
|
|
|
6385
|
-
return /*#__PURE__*/
|
|
6705
|
+
return /*#__PURE__*/React__default.createElement(PositionnedCursor, {
|
|
6386
6706
|
key: userId,
|
|
6387
6707
|
pos: pos,
|
|
6388
6708
|
text: usersById[userId].name,
|
|
@@ -6401,7 +6721,7 @@ var CursorPane = function CursorPane(_ref) {
|
|
|
6401
6721
|
user = _useUsers.currentUser,
|
|
6402
6722
|
users = _useUsers.users;
|
|
6403
6723
|
|
|
6404
|
-
var publish =
|
|
6724
|
+
var publish = React__default.useCallback(function (newPos) {
|
|
6405
6725
|
wire.publish("cursorMove", {
|
|
6406
6726
|
userId: user.id,
|
|
6407
6727
|
pos: newPos
|
|
@@ -6459,33 +6779,33 @@ var CursorPane = function CursorPane(_ref) {
|
|
|
6459
6779
|
});
|
|
6460
6780
|
};
|
|
6461
6781
|
|
|
6462
|
-
return /*#__PURE__*/
|
|
6782
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
6463
6783
|
onPointerMove: onMouseMove,
|
|
6464
6784
|
onPointerLeave: onLeave
|
|
6465
|
-
}, children, /*#__PURE__*/
|
|
6785
|
+
}, children, /*#__PURE__*/React__default.createElement(Cursors, {
|
|
6466
6786
|
users: users
|
|
6467
6787
|
}));
|
|
6468
6788
|
};
|
|
6469
6789
|
|
|
6470
6790
|
var useMousePosition = function useMousePosition(ref) {
|
|
6471
|
-
var mouseRef =
|
|
6791
|
+
var mouseRef = React__default.useRef({
|
|
6472
6792
|
hover: false,
|
|
6473
6793
|
x: 0,
|
|
6474
6794
|
y: 0
|
|
6475
6795
|
});
|
|
6476
|
-
var onMouseMove =
|
|
6796
|
+
var onMouseMove = React__default.useCallback(function (e) {
|
|
6477
6797
|
var clientX = e.clientX,
|
|
6478
6798
|
clientY = e.clientY;
|
|
6479
6799
|
mouseRef.current.x = clientX;
|
|
6480
6800
|
mouseRef.current.y = clientY;
|
|
6481
6801
|
}, []);
|
|
6482
|
-
var onMouseEnter =
|
|
6802
|
+
var onMouseEnter = React__default.useCallback(function () {
|
|
6483
6803
|
mouseRef.current.hover = true;
|
|
6484
6804
|
}, []);
|
|
6485
|
-
var onMouseLeave =
|
|
6805
|
+
var onMouseLeave = React__default.useCallback(function () {
|
|
6486
6806
|
mouseRef.current.hover = false;
|
|
6487
6807
|
}, []);
|
|
6488
|
-
|
|
6808
|
+
React__default.useEffect(function () {
|
|
6489
6809
|
var current = ref.current;
|
|
6490
6810
|
|
|
6491
6811
|
if (current) {
|
|
@@ -6501,7 +6821,7 @@ var useMousePosition = function useMousePosition(ref) {
|
|
|
6501
6821
|
|
|
6502
6822
|
return null; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6503
6823
|
}, [ref, ref.current, onMouseMove, onMouseEnter, onMouseLeave]);
|
|
6504
|
-
var getMouseInfo =
|
|
6824
|
+
var getMouseInfo = React__default.useCallback(function () {
|
|
6505
6825
|
return mouseRef.current;
|
|
6506
6826
|
}, []);
|
|
6507
6827
|
return getMouseInfo;
|
|
@@ -6512,7 +6832,7 @@ var digitCodes = _toConsumableArray(Array(5).keys()).map(function (id) {
|
|
|
6512
6832
|
});
|
|
6513
6833
|
|
|
6514
6834
|
var usePositionNavigator = function usePositionNavigator() {
|
|
6515
|
-
var _React$useState =
|
|
6835
|
+
var _React$useState = React__default.useState({}),
|
|
6516
6836
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
6517
6837
|
positions = _React$useState2[0],
|
|
6518
6838
|
setPositions = _React$useState2[1];
|
|
@@ -6572,7 +6892,7 @@ var usePositionNavigator = function usePositionNavigator() {
|
|
|
6572
6892
|
};
|
|
6573
6893
|
}();
|
|
6574
6894
|
}, [positions]);
|
|
6575
|
-
|
|
6895
|
+
React__default.useEffect(function () {
|
|
6576
6896
|
document.addEventListener("keydown", onKeyDown);
|
|
6577
6897
|
return function () {
|
|
6578
6898
|
document.removeEventListener("keydown", onKeyDown);
|
|
@@ -6587,7 +6907,7 @@ var PanZoom = function PanZoom(_ref) {
|
|
|
6587
6907
|
var children = _ref.children,
|
|
6588
6908
|
_ref$moveFirst = _ref.moveFirst,
|
|
6589
6909
|
moveFirst = _ref$moveFirst === void 0 ? false : _ref$moveFirst;
|
|
6590
|
-
var wrappedRef =
|
|
6910
|
+
var wrappedRef = React__default.useRef(null);
|
|
6591
6911
|
var dim = useRecoilValue(BoardTransformAtom);
|
|
6592
6912
|
|
|
6593
6913
|
var _useDim = useDim(),
|
|
@@ -6597,13 +6917,13 @@ var PanZoom = function PanZoom(_ref) {
|
|
|
6597
6917
|
var _useRecoilValue = useRecoilValue(ConfigurationAtom),
|
|
6598
6918
|
itemExtentGlobal = _useRecoilValue.itemExtent;
|
|
6599
6919
|
|
|
6600
|
-
var _React$useState =
|
|
6920
|
+
var _React$useState = React__default.useState(false),
|
|
6601
6921
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
6602
6922
|
centered = _React$useState2[0],
|
|
6603
6923
|
setCentered = _React$useState2[1];
|
|
6604
6924
|
|
|
6605
6925
|
var setBoardState = useSetRecoilState(BoardStateAtom);
|
|
6606
|
-
var timeoutRef =
|
|
6926
|
+
var timeoutRef = React__default.useRef({}); // Get mouse position and hover status
|
|
6607
6927
|
|
|
6608
6928
|
var getMouseInfo = useMousePosition(wrappedRef); // Hooks to save/restore position
|
|
6609
6929
|
|
|
@@ -6650,14 +6970,14 @@ var PanZoom = function PanZoom(_ref) {
|
|
|
6650
6970
|
}, _callee);
|
|
6651
6971
|
}));
|
|
6652
6972
|
}, [setDim]);
|
|
6653
|
-
|
|
6973
|
+
React__default.useEffect(function () {
|
|
6654
6974
|
if (!centered && itemExtentGlobal.left) {
|
|
6655
6975
|
// Center board on first valid extent
|
|
6656
6976
|
centerBoard();
|
|
6657
6977
|
setCentered(true);
|
|
6658
6978
|
}
|
|
6659
6979
|
}, [centerBoard, centered, itemExtentGlobal]);
|
|
6660
|
-
var onZoom =
|
|
6980
|
+
var onZoom = React__default.useCallback(function (_ref4) {
|
|
6661
6981
|
var clientX = _ref4.clientX,
|
|
6662
6982
|
clientY = _ref4.clientY,
|
|
6663
6983
|
scale = _ref4.scale;
|
|
@@ -6680,7 +7000,7 @@ var PanZoom = function PanZoom(_ref) {
|
|
|
6680
7000
|
}) : prev;
|
|
6681
7001
|
});
|
|
6682
7002
|
}, [setBoardState, zoomTo]);
|
|
6683
|
-
var onPan =
|
|
7003
|
+
var onPan = React__default.useCallback( /*#__PURE__*/function () {
|
|
6684
7004
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_ref5) {
|
|
6685
7005
|
var deltaX, deltaY;
|
|
6686
7006
|
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
@@ -6721,7 +7041,7 @@ var PanZoom = function PanZoom(_ref) {
|
|
|
6721
7041
|
return _ref6.apply(this, arguments);
|
|
6722
7042
|
};
|
|
6723
7043
|
}(), [setBoardState, setDim]);
|
|
6724
|
-
var onDrag =
|
|
7044
|
+
var onDrag = React__default.useCallback(function (state) {
|
|
6725
7045
|
var target = state.target;
|
|
6726
7046
|
var outsideItem = !insideClass(target, "item") || insideClass(target, "locked");
|
|
6727
7047
|
|
|
@@ -6837,7 +7157,7 @@ var PanZoom = function PanZoom(_ref) {
|
|
|
6837
7157
|
};
|
|
6838
7158
|
}();
|
|
6839
7159
|
}, [setDim, zoomTo, getMouseInfo]);
|
|
6840
|
-
var onKeyUp =
|
|
7160
|
+
var onKeyUp = React__default.useCallback(function (e) {
|
|
6841
7161
|
// Ignore text in Input or Textarea
|
|
6842
7162
|
if (["INPUT", "TEXTAREA"].includes(e.target.tagName)) return; // Zoom out on release
|
|
6843
7163
|
|
|
@@ -6845,7 +7165,7 @@ var PanZoom = function PanZoom(_ref) {
|
|
|
6845
7165
|
zoomTo(1 / 3, getMouseInfo());
|
|
6846
7166
|
}
|
|
6847
7167
|
}, [getMouseInfo, zoomTo]);
|
|
6848
|
-
|
|
7168
|
+
React__default.useEffect(function () {
|
|
6849
7169
|
document.addEventListener("keydown", onKeyDown);
|
|
6850
7170
|
document.addEventListener("keyup", onKeyUp);
|
|
6851
7171
|
return function () {
|
|
@@ -6853,11 +7173,11 @@ var PanZoom = function PanZoom(_ref) {
|
|
|
6853
7173
|
document.removeEventListener("keyup", onKeyUp);
|
|
6854
7174
|
};
|
|
6855
7175
|
}, [onKeyDown, onKeyUp]);
|
|
6856
|
-
return /*#__PURE__*/
|
|
7176
|
+
return /*#__PURE__*/React__default.createElement(Gesture, {
|
|
6857
7177
|
onPan: onPan,
|
|
6858
7178
|
onZoom: onZoom,
|
|
6859
7179
|
onDrag: onDrag
|
|
6860
|
-
}, /*#__PURE__*/
|
|
7180
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
6861
7181
|
style: {
|
|
6862
7182
|
display: "inline-block",
|
|
6863
7183
|
transformOrigin: "top left",
|
|
@@ -6957,13 +7277,13 @@ var BoundingBox = function BoundingBox() {
|
|
|
6957
7277
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6958
7278
|
|
|
6959
7279
|
var updateBoxDelay = useDebouncedCallback(updateBox, [updateBox], 300);
|
|
6960
|
-
|
|
7280
|
+
React__default.useEffect(function () {
|
|
6961
7281
|
// Update selected elements bounding box
|
|
6962
7282
|
updateBox();
|
|
6963
7283
|
updateBoxDelay(); // Delay to update after board item animation like tap/untap.
|
|
6964
7284
|
}, [selectedItems, itemMap, boardTransform, updateBox, updateBoxDelay]);
|
|
6965
7285
|
if (!boundingBoxLast || selectedItems.length < 2) return null;
|
|
6966
|
-
return /*#__PURE__*/
|
|
7286
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
6967
7287
|
style: _objectSpread2(_objectSpread2({}, defaultZoneStyle), {}, {
|
|
6968
7288
|
transform: "translate(".concat(boundingBoxLast.left, "px, ").concat(boundingBoxLast.top, "px)"),
|
|
6969
7289
|
height: "".concat(boundingBoxLast.height, "px"),
|
|
@@ -6980,7 +7300,7 @@ var Selection = function Selection() {
|
|
|
6980
7300
|
return null;
|
|
6981
7301
|
}
|
|
6982
7302
|
|
|
6983
|
-
return /*#__PURE__*/
|
|
7303
|
+
return /*#__PURE__*/React__default.createElement(BoundingBox, null);
|
|
6984
7304
|
};
|
|
6985
7305
|
|
|
6986
7306
|
var Board = function Board(_ref) {
|
|
@@ -6991,13 +7311,15 @@ var Board = function Board(_ref) {
|
|
|
6991
7311
|
itemTemplates = _ref$itemTemplates === void 0 ? {} : _ref$itemTemplates,
|
|
6992
7312
|
_ref$boardSize = _ref.boardSize,
|
|
6993
7313
|
boardSize = _ref$boardSize === void 0 ? DEFAULT_BOARD_MAX_SIZE : _ref$boardSize,
|
|
6994
|
-
children = _ref.children
|
|
7314
|
+
children = _ref.children,
|
|
7315
|
+
_ref$showResizeHandle = _ref.showResizeHandle,
|
|
7316
|
+
showResizeHandle = _ref$showResizeHandle === void 0 ? false : _ref$showResizeHandle;
|
|
6995
7317
|
var setConfiguration = useSetRecoilState(ConfigurationAtom);
|
|
6996
7318
|
|
|
6997
7319
|
var _useDim = useDim(),
|
|
6998
7320
|
updateItemExtent = _useDim.updateItemExtent;
|
|
6999
7321
|
|
|
7000
|
-
var boardStyle =
|
|
7322
|
+
var boardStyle = React__default.useMemo(function () {
|
|
7001
7323
|
return _objectSpread2({
|
|
7002
7324
|
userSelect: "none",
|
|
7003
7325
|
width: "".concat(boardSize, "px"),
|
|
@@ -7005,31 +7327,30 @@ var Board = function Board(_ref) {
|
|
|
7005
7327
|
backgroundColor: "#333"
|
|
7006
7328
|
}, style);
|
|
7007
7329
|
}, [boardSize, style]);
|
|
7008
|
-
|
|
7330
|
+
React__default.useEffect(function () {
|
|
7009
7331
|
setConfiguration(function (prev) {
|
|
7010
7332
|
return _objectSpread2(_objectSpread2({}, prev), {}, {
|
|
7011
7333
|
itemTemplates: itemTemplates,
|
|
7012
|
-
boardSize: boardSize
|
|
7334
|
+
boardSize: boardSize,
|
|
7335
|
+
showResizeHandle: showResizeHandle
|
|
7013
7336
|
});
|
|
7014
7337
|
});
|
|
7015
|
-
}, [itemTemplates, setConfiguration, boardSize]);
|
|
7016
|
-
|
|
7338
|
+
}, [itemTemplates, setConfiguration, boardSize, showResizeHandle]);
|
|
7339
|
+
React__default.useEffect(function () {
|
|
7017
7340
|
updateItemExtent();
|
|
7018
7341
|
setTimeout(updateItemExtent, 2000);
|
|
7019
7342
|
}, [updateItemExtent]);
|
|
7020
|
-
return /*#__PURE__*/
|
|
7343
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(SubcribeItemEvents, null), /*#__PURE__*/React__default.createElement(PanZoom, {
|
|
7021
7344
|
moveFirst: moveFirst
|
|
7022
|
-
}, /*#__PURE__*/
|
|
7345
|
+
}, /*#__PURE__*/React__default.createElement(Selector, {
|
|
7023
7346
|
moveFirst: moveFirst
|
|
7024
|
-
}, /*#__PURE__*/
|
|
7347
|
+
}, /*#__PURE__*/React__default.createElement(ActionPane, null, /*#__PURE__*/React__default.createElement(CursorPane, null, /*#__PURE__*/React__default.createElement("div", {
|
|
7025
7348
|
onContextMenu: function onContextMenu(e) {
|
|
7026
7349
|
e.preventDefault();
|
|
7027
7350
|
},
|
|
7028
7351
|
style: boardStyle,
|
|
7029
7352
|
className: "board"
|
|
7030
|
-
}, /*#__PURE__*/
|
|
7031
|
-
itemTemplates: itemTemplates
|
|
7032
|
-
}), children))))), /*#__PURE__*/React.createElement(Selection, null));
|
|
7353
|
+
}, /*#__PURE__*/React__default.createElement(ItemList, null), children))))), /*#__PURE__*/React__default.createElement(Selection, null));
|
|
7033
7354
|
};
|
|
7034
7355
|
|
|
7035
7356
|
var TOLERANCE = 100;
|
|
@@ -7061,7 +7382,7 @@ var translateBoundaries = function translateBoundaries(_ref) {
|
|
|
7061
7382
|
|
|
7062
7383
|
var useDim = function useDim() {
|
|
7063
7384
|
var setDim = useSetRecoilState(BoardTransformAtom);
|
|
7064
|
-
var scaleBoundariesRef =
|
|
7385
|
+
var scaleBoundariesRef = React__default.useRef([0.1, 8]);
|
|
7065
7386
|
|
|
7066
7387
|
var _useRecoilValue = useRecoilValue(ConfigurationAtom),
|
|
7067
7388
|
itemExtentGlobal = _useRecoilValue.itemExtent;
|
|
@@ -7373,7 +7694,7 @@ var useDim = function useDim() {
|
|
|
7373
7694
|
}));
|
|
7374
7695
|
}, []);
|
|
7375
7696
|
var debouncedUpdateItemExtent = useDebouncedCallback(updateItemExtent, [], 300);
|
|
7376
|
-
|
|
7697
|
+
React__default.useEffect(function () {
|
|
7377
7698
|
if (itemExtentGlobal.left) {
|
|
7378
7699
|
updateScaleBoundaries();
|
|
7379
7700
|
}
|
|
@@ -7389,7 +7710,7 @@ var useDim = function useDim() {
|
|
|
7389
7710
|
|
|
7390
7711
|
var useItemInteraction = function useItemInteraction(interaction) {
|
|
7391
7712
|
var setInteractions = useSetRecoilState(ItemInteractionsAtom);
|
|
7392
|
-
var register =
|
|
7713
|
+
var register = React__default.useCallback(function (callback) {
|
|
7393
7714
|
setInteractions(function (prev) {
|
|
7394
7715
|
var newInter = Array.isArray(prev[interaction]) ? [].concat(_toConsumableArray(prev[interaction]), [callback]) : [callback];
|
|
7395
7716
|
return _objectSpread2(_objectSpread2({}, prev), {}, _defineProperty({}, interaction, newInter));
|
|
@@ -7524,7 +7845,7 @@ var useItemActions = function useItemActions() {
|
|
|
7524
7845
|
};
|
|
7525
7846
|
}();
|
|
7526
7847
|
}, [setItemMap, updateItemExtent, wire]);
|
|
7527
|
-
var setItemListFull =
|
|
7848
|
+
var setItemListFull = React__default.useCallback(function (items) {
|
|
7528
7849
|
setItemMap(items.reduce(function (acc, item) {
|
|
7529
7850
|
if (item && item.id) {
|
|
7530
7851
|
acc[item.id] = item;
|
|
@@ -7540,11 +7861,11 @@ var useItemActions = function useItemActions() {
|
|
|
7540
7861
|
setSelectItems([]);
|
|
7541
7862
|
updateItemExtent();
|
|
7542
7863
|
}, [setItemList, setItemMap, setSelectItems, updateItemExtent]);
|
|
7543
|
-
var updateItem =
|
|
7864
|
+
var updateItem = React__default.useCallback(function (id, callbackOrItem) {
|
|
7544
7865
|
var sync = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
7545
7866
|
batchUpdateItems([id], callbackOrItem, sync);
|
|
7546
7867
|
}, [batchUpdateItems]);
|
|
7547
|
-
var moveItems =
|
|
7868
|
+
var moveItems = React__default.useCallback(function (itemIds, posDelta) {
|
|
7548
7869
|
var sync = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
7549
7870
|
setItemMap(function (prevItemMap) {
|
|
7550
7871
|
var result = _objectSpread2({}, prevItemMap);
|
|
@@ -7574,7 +7895,7 @@ var useItemActions = function useItemActions() {
|
|
|
7574
7895
|
|
|
7575
7896
|
updateItemExtent();
|
|
7576
7897
|
}, [setItemMap, updateItemExtent, wire]);
|
|
7577
|
-
var putItemsOnTop =
|
|
7898
|
+
var putItemsOnTop = React__default.useCallback(function (itemIdsToMove) {
|
|
7578
7899
|
var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
7579
7900
|
setItemList(function (prevItemList) {
|
|
7580
7901
|
var filtered = prevItemList.filter(function (id) {
|
|
@@ -7647,8 +7968,8 @@ var useItemActions = function useItemActions() {
|
|
|
7647
7968
|
size = itemSize || 1;
|
|
7648
7969
|
}
|
|
7649
7970
|
|
|
7650
|
-
var centerX = item.x + elem.clientWidth / 2,
|
|
7651
|
-
centerY = item.y + elem.clientHeight / 2;
|
|
7971
|
+
var centerX = item.x + elem.clientWidth / 2 - offsetX,
|
|
7972
|
+
centerY = item.y + elem.clientHeight / 2 - offsetY;
|
|
7652
7973
|
var newX;
|
|
7653
7974
|
var newY;
|
|
7654
7975
|
var sizeX;
|
|
@@ -7738,7 +8059,7 @@ var useItemActions = function useItemActions() {
|
|
|
7738
8059
|
};
|
|
7739
8060
|
}();
|
|
7740
8061
|
}, [wire, setItemMap]);
|
|
7741
|
-
var placeItems =
|
|
8062
|
+
var placeItems = React__default.useCallback( /*#__PURE__*/function () {
|
|
7742
8063
|
var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(itemIds, gridConfig) {
|
|
7743
8064
|
var sync,
|
|
7744
8065
|
_args3 = arguments;
|
|
@@ -7772,7 +8093,7 @@ var useItemActions = function useItemActions() {
|
|
|
7772
8093
|
return _ref8.apply(this, arguments);
|
|
7773
8094
|
};
|
|
7774
8095
|
}(), [batchUpdateItems, callPlaceInteractions, putItemsOnTop, stickOnGrid, updateItemExtent]);
|
|
7775
|
-
var updateItemOrder =
|
|
8096
|
+
var updateItemOrder = React__default.useCallback(function (newOrder) {
|
|
7776
8097
|
var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
7777
8098
|
setItemList(newOrder);
|
|
7778
8099
|
|
|
@@ -7780,7 +8101,7 @@ var useItemActions = function useItemActions() {
|
|
|
7780
8101
|
wire.publish("updateItemListOrder", newOrder);
|
|
7781
8102
|
}
|
|
7782
8103
|
}, [wire, setItemList]);
|
|
7783
|
-
var reverseItemsOrder =
|
|
8104
|
+
var reverseItemsOrder = React__default.useCallback(function (itemIdsToReverse) {
|
|
7784
8105
|
var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
7785
8106
|
setItemList(function (prevItemList) {
|
|
7786
8107
|
var toBeReversed = prevItemList.filter(function (id) {
|
|
@@ -7894,7 +8215,7 @@ var useItemActions = function useItemActions() {
|
|
|
7894
8215
|
};
|
|
7895
8216
|
}();
|
|
7896
8217
|
}, [wire, setItemList, setItemMap]);
|
|
7897
|
-
var pushItems =
|
|
8218
|
+
var pushItems = React__default.useCallback( /*#__PURE__*/function () {
|
|
7898
8219
|
var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(itemsToInsert, beforeId) {
|
|
7899
8220
|
var sync,
|
|
7900
8221
|
_args6 = arguments;
|
|
@@ -7970,11 +8291,11 @@ var useItemActions = function useItemActions() {
|
|
|
7970
8291
|
return _ref11.apply(this, arguments);
|
|
7971
8292
|
};
|
|
7972
8293
|
}(), [updateItemExtent, getCenter, setItemMap, setItemList, wire]);
|
|
7973
|
-
var pushItem =
|
|
8294
|
+
var pushItem = React__default.useCallback(function (itemToInsert, beforeId) {
|
|
7974
8295
|
var sync = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
7975
8296
|
pushItems([itemToInsert], beforeId, sync);
|
|
7976
8297
|
}, [pushItems]);
|
|
7977
|
-
var removeItems =
|
|
8298
|
+
var removeItems = React__default.useCallback(function (itemsIdToRemove) {
|
|
7978
8299
|
var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
7979
8300
|
// Remove from selected items first
|
|
7980
8301
|
setSelectItems(function (prevList) {
|
|
@@ -8342,12 +8663,12 @@ var useAvailableActions = function useAvailableActions() {
|
|
|
8342
8663
|
|
|
8343
8664
|
var selected = useRecoilValue(SelectedItemsAtom);
|
|
8344
8665
|
|
|
8345
|
-
var _React$useState =
|
|
8666
|
+
var _React$useState = React__default.useState([]),
|
|
8346
8667
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
8347
8668
|
availableActions = _React$useState2[0],
|
|
8348
8669
|
setAvailableActions = _React$useState2[1];
|
|
8349
8670
|
|
|
8350
|
-
var isMountedRef =
|
|
8671
|
+
var isMountedRef = React__default.useRef(false);
|
|
8351
8672
|
var getItemListOrSelected = useRecoilCallback(function (_ref) {
|
|
8352
8673
|
var snapshot = _ref.snapshot;
|
|
8353
8674
|
return /*#__PURE__*/function () {
|
|
@@ -8395,7 +8716,7 @@ var useAvailableActions = function useAvailableActions() {
|
|
|
8395
8716
|
};
|
|
8396
8717
|
}();
|
|
8397
8718
|
}, []);
|
|
8398
|
-
|
|
8719
|
+
React__default.useEffect(function () {
|
|
8399
8720
|
// Mounted guard
|
|
8400
8721
|
isMountedRef.current = true;
|
|
8401
8722
|
return function () {
|
|
@@ -8407,7 +8728,7 @@ var useAvailableActions = function useAvailableActions() {
|
|
|
8407
8728
|
* items have this exact same action with same parameters.
|
|
8408
8729
|
*/
|
|
8409
8730
|
|
|
8410
|
-
var updateAvailableActions =
|
|
8731
|
+
var updateAvailableActions = React__default.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
8411
8732
|
var _yield$getItemListOrS, _yield$getItemListOrS2, selectedItemIds, selectedItemList, allActions;
|
|
8412
8733
|
|
|
8413
8734
|
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
@@ -8459,7 +8780,7 @@ var useAvailableActions = function useAvailableActions() {
|
|
|
8459
8780
|
}, _callee2);
|
|
8460
8781
|
})), [getItemListOrSelected, itemMap]); // Update available actions when selection change
|
|
8461
8782
|
|
|
8462
|
-
|
|
8783
|
+
React__default.useEffect(function () {
|
|
8463
8784
|
updateAvailableActions();
|
|
8464
8785
|
}, [updateAvailableActions, selected]);
|
|
8465
8786
|
return {
|
|
@@ -8483,7 +8804,7 @@ var useBoardConfig = function useBoardConfig() {
|
|
|
8483
8804
|
var debouncedPublishUpdate = useDebouncedCallback(function (newConfig) {
|
|
8484
8805
|
wire.publish("updateBoardConfig", newConfig);
|
|
8485
8806
|
}, [wire], 1000);
|
|
8486
|
-
var setSyncBoardConfig =
|
|
8807
|
+
var setSyncBoardConfig = React__default.useCallback(function (callbackOrConfig) {
|
|
8487
8808
|
var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
8488
8809
|
var callback = callbackOrConfig;
|
|
8489
8810
|
|
|
@@ -8580,22 +8901,29 @@ var dayjs_min = {exports: {}};
|
|
|
8580
8901
|
return void 0 === t;
|
|
8581
8902
|
}
|
|
8582
8903
|
},
|
|
8583
|
-
|
|
8584
|
-
|
|
8904
|
+
v = "en",
|
|
8905
|
+
D = {};
|
|
8585
8906
|
|
|
8586
|
-
v
|
|
8907
|
+
D[v] = M;
|
|
8587
8908
|
|
|
8588
8909
|
var p = function p(t) {
|
|
8589
8910
|
return t instanceof _;
|
|
8590
8911
|
},
|
|
8591
|
-
S = function
|
|
8592
|
-
var
|
|
8593
|
-
if (!
|
|
8594
|
-
|
|
8595
|
-
|
|
8596
|
-
|
|
8912
|
+
S = function t(e, n, r) {
|
|
8913
|
+
var i;
|
|
8914
|
+
if (!e) return v;
|
|
8915
|
+
|
|
8916
|
+
if ("string" == typeof e) {
|
|
8917
|
+
var s = e.toLowerCase();
|
|
8918
|
+
D[s] && (i = s), n && (D[s] = n, i = s);
|
|
8919
|
+
var u = e.split("-");
|
|
8920
|
+
if (!i && u.length > 1) return t(u[0]);
|
|
8921
|
+
} else {
|
|
8922
|
+
var a = e.name;
|
|
8923
|
+
D[a] = e, i = a;
|
|
8597
8924
|
}
|
|
8598
|
-
|
|
8925
|
+
|
|
8926
|
+
return !r && i && (v = i), i || !r && v;
|
|
8599
8927
|
},
|
|
8600
8928
|
w = function w(t, e) {
|
|
8601
8929
|
if (p(t)) return t.clone();
|
|
@@ -8683,9 +9011,9 @@ var dayjs_min = {exports: {}};
|
|
|
8683
9011
|
return r ? $(1, M) : $(0, M + 1);
|
|
8684
9012
|
|
|
8685
9013
|
case o:
|
|
8686
|
-
var
|
|
8687
|
-
|
|
8688
|
-
return $(r ? m -
|
|
9014
|
+
var v = this.$locale().weekStart || 0,
|
|
9015
|
+
D = (y < v ? y + 7 : y) - v;
|
|
9016
|
+
return $(r ? m - D : m + (6 - D), M);
|
|
8689
9017
|
|
|
8690
9018
|
case a:
|
|
8691
9019
|
case d:
|
|
@@ -8802,12 +9130,12 @@ var dayjs_min = {exports: {}};
|
|
|
8802
9130
|
M = w(r),
|
|
8803
9131
|
m = (M.utcOffset() - this.utcOffset()) * e,
|
|
8804
9132
|
g = this - M,
|
|
8805
|
-
|
|
8806
|
-
return
|
|
9133
|
+
v = O.m(this, M);
|
|
9134
|
+
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
9135
|
}, m.daysInMonth = function () {
|
|
8808
9136
|
return this.endOf(f).$D;
|
|
8809
9137
|
}, m.$locale = function () {
|
|
8810
|
-
return
|
|
9138
|
+
return D[this.$L];
|
|
8811
9139
|
}, m.locale = function (t, e) {
|
|
8812
9140
|
if (!t) return this.$L;
|
|
8813
9141
|
var n = this.clone(),
|
|
@@ -8835,7 +9163,7 @@ var dayjs_min = {exports: {}};
|
|
|
8835
9163
|
return t.$i || (t(e, _, w), t.$i = !0), w;
|
|
8836
9164
|
}, w.locale = S, w.isDayjs = p, w.unix = function (t) {
|
|
8837
9165
|
return w(1e3 * t);
|
|
8838
|
-
}, w.en = v
|
|
9166
|
+
}, w.en = D[v], w.Ls = D, w.p = {}, w;
|
|
8839
9167
|
});
|
|
8840
9168
|
})(dayjs_min);
|
|
8841
9169
|
|
|
@@ -8920,12 +9248,12 @@ var useMessage = function useMessage() {
|
|
|
8920
9248
|
}, _callee);
|
|
8921
9249
|
}));
|
|
8922
9250
|
}, []);
|
|
8923
|
-
var setMessages =
|
|
9251
|
+
var setMessages = React__default.useCallback(function (newMessages) {
|
|
8924
9252
|
setMessagesState(newMessages.map(function (m) {
|
|
8925
9253
|
return parseMessage(m);
|
|
8926
9254
|
}));
|
|
8927
9255
|
}, [setMessagesState]);
|
|
8928
|
-
var initEvents =
|
|
9256
|
+
var initEvents = React__default.useCallback(function (unsub) {
|
|
8929
9257
|
unsub.push(wire.subscribe("newMessage", function (newMessage) {
|
|
8930
9258
|
setMessagesState(function (prevMessages) {
|
|
8931
9259
|
return [].concat(_toConsumableArray(prevMessages), [parseMessage(newMessage)]);
|
|
@@ -8945,7 +9273,7 @@ var useMessage = function useMessage() {
|
|
|
8945
9273
|
|
|
8946
9274
|
return unsub;
|
|
8947
9275
|
}, [wire, getMessage, isMaster, onMessage, setMessages, setMessagesState]);
|
|
8948
|
-
|
|
9276
|
+
React__default.useEffect(function () {
|
|
8949
9277
|
var unsub = [];
|
|
8950
9278
|
|
|
8951
9279
|
if (subscribeEvents) {
|
|
@@ -8958,7 +9286,7 @@ var useMessage = function useMessage() {
|
|
|
8958
9286
|
});
|
|
8959
9287
|
};
|
|
8960
9288
|
}, [initEvents, subscribeEvents]);
|
|
8961
|
-
var sendMessage =
|
|
9289
|
+
var sendMessage = React__default.useCallback(function (messageContent) {
|
|
8962
9290
|
var newMessage = generateMsg({
|
|
8963
9291
|
user: currentUser,
|
|
8964
9292
|
content: messageContent
|
|
@@ -8980,7 +9308,7 @@ var StyledBoardView = newStyled.div(_templateObject || (_templateObject = _tagge
|
|
|
8980
9308
|
var SyncBoard = function SyncBoard(_ref) {
|
|
8981
9309
|
var children = _ref.children,
|
|
8982
9310
|
style = _ref.style;
|
|
8983
|
-
var boardWrapperRef =
|
|
9311
|
+
var boardWrapperRef = React__default.useRef(null);
|
|
8984
9312
|
var setCurrentUserState = useSetRecoilState(userAtom);
|
|
8985
9313
|
|
|
8986
9314
|
var _useWire = useWire("board"),
|
|
@@ -8991,7 +9319,7 @@ var SyncBoard = function SyncBoard(_ref) {
|
|
|
8991
9319
|
uid = _useRecoilState2[0].uid,
|
|
8992
9320
|
setConfiguration = _useRecoilState2[1];
|
|
8993
9321
|
|
|
8994
|
-
|
|
9322
|
+
React__default.useEffect(function () {
|
|
8995
9323
|
// Chrome-related issue.
|
|
8996
9324
|
// Making the wheel event non-passive, which allows to use preventDefault() to prevent
|
|
8997
9325
|
// the browser original zoom and therefore allowing our custom one.
|
|
@@ -9008,7 +9336,7 @@ var SyncBoard = function SyncBoard(_ref) {
|
|
|
9008
9336
|
};
|
|
9009
9337
|
}, []); // Set user space
|
|
9010
9338
|
|
|
9011
|
-
|
|
9339
|
+
React__default.useEffect(function () {
|
|
9012
9340
|
setCurrentUserState(function (prevUser) {
|
|
9013
9341
|
return _objectSpread2(_objectSpread2({}, prevUser), {}, {
|
|
9014
9342
|
space: session
|
|
@@ -9022,7 +9350,7 @@ var SyncBoard = function SyncBoard(_ref) {
|
|
|
9022
9350
|
});
|
|
9023
9351
|
};
|
|
9024
9352
|
}, [session, setCurrentUserState]);
|
|
9025
|
-
|
|
9353
|
+
React__default.useEffect(function () {
|
|
9026
9354
|
if (!uid) {
|
|
9027
9355
|
setConfiguration(function (prev) {
|
|
9028
9356
|
return _objectSpread2(_objectSpread2({}, prev), {}, {
|
|
@@ -9031,7 +9359,7 @@ var SyncBoard = function SyncBoard(_ref) {
|
|
|
9031
9359
|
});
|
|
9032
9360
|
}
|
|
9033
9361
|
}, [setConfiguration, uid]);
|
|
9034
|
-
|
|
9362
|
+
React__default.useEffect(function () {
|
|
9035
9363
|
setConfiguration(function (prev) {
|
|
9036
9364
|
return _objectSpread2(_objectSpread2({}, prev), {}, {
|
|
9037
9365
|
boardWrapper: boardWrapperRef.current
|
|
@@ -9045,7 +9373,7 @@ var SyncBoard = function SyncBoard(_ref) {
|
|
|
9045
9373
|
});
|
|
9046
9374
|
});
|
|
9047
9375
|
});
|
|
9048
|
-
return /*#__PURE__*/
|
|
9376
|
+
return /*#__PURE__*/React__default.createElement(StyledBoardView, {
|
|
9049
9377
|
ref: boardWrapperRef,
|
|
9050
9378
|
id: uid,
|
|
9051
9379
|
className: "sync-board",
|
|
@@ -9059,11 +9387,11 @@ var ConnectedSyncBoard = function ConnectedSyncBoard(_ref2) {
|
|
|
9059
9387
|
session = _ref2.session,
|
|
9060
9388
|
props = _objectWithoutProperties(_ref2, _excluded);
|
|
9061
9389
|
|
|
9062
|
-
var _React$useState =
|
|
9390
|
+
var _React$useState = React__default.useState(room || nanoid()),
|
|
9063
9391
|
_React$useState2 = _slicedToArray(_React$useState, 1),
|
|
9064
9392
|
stableRoom = _React$useState2[0];
|
|
9065
9393
|
|
|
9066
|
-
var _React$useState3 =
|
|
9394
|
+
var _React$useState3 = React__default.useState(session || nanoid()),
|
|
9067
9395
|
_React$useState4 = _slicedToArray(_React$useState3, 1),
|
|
9068
9396
|
stableSession = _React$useState4[0];
|
|
9069
9397
|
|
|
@@ -9071,22 +9399,22 @@ var ConnectedSyncBoard = function ConnectedSyncBoard(_ref2) {
|
|
|
9071
9399
|
|
|
9072
9400
|
if (!roomChannel) {
|
|
9073
9401
|
// No room declared so we create one
|
|
9074
|
-
return /*#__PURE__*/
|
|
9402
|
+
return /*#__PURE__*/React__default.createElement(RecoilRoot, null, /*#__PURE__*/React__default.createElement(WireProvider, {
|
|
9075
9403
|
room: stableRoom,
|
|
9076
9404
|
channel: "room",
|
|
9077
9405
|
socket: socket
|
|
9078
|
-
}, /*#__PURE__*/
|
|
9406
|
+
}, /*#__PURE__*/React__default.createElement(SubscribeUserEvents, null), /*#__PURE__*/React__default.createElement(WireProvider, {
|
|
9079
9407
|
room: stableSession,
|
|
9080
9408
|
channel: "board",
|
|
9081
9409
|
socket: socket
|
|
9082
|
-
}, /*#__PURE__*/
|
|
9410
|
+
}, /*#__PURE__*/React__default.createElement(SyncBoard, props))));
|
|
9083
9411
|
}
|
|
9084
9412
|
|
|
9085
|
-
return /*#__PURE__*/
|
|
9413
|
+
return /*#__PURE__*/React__default.createElement(WireProvider, {
|
|
9086
9414
|
room: stableSession,
|
|
9087
9415
|
channel: "board",
|
|
9088
9416
|
socket: socket
|
|
9089
|
-
}, /*#__PURE__*/
|
|
9417
|
+
}, /*#__PURE__*/React__default.createElement(SyncBoard, props));
|
|
9090
9418
|
};
|
|
9091
9419
|
|
|
9092
9420
|
var ConnectedSyncRoom = function ConnectedSyncRoom(_ref) {
|
|
@@ -9094,17 +9422,17 @@ var ConnectedSyncRoom = function ConnectedSyncRoom(_ref) {
|
|
|
9094
9422
|
givenRoom = _ref.room,
|
|
9095
9423
|
children = _ref.children;
|
|
9096
9424
|
|
|
9097
|
-
var _React$useState =
|
|
9425
|
+
var _React$useState = React__default.useState(function () {
|
|
9098
9426
|
return givenRoom || nanoid();
|
|
9099
9427
|
}),
|
|
9100
9428
|
_React$useState2 = _slicedToArray(_React$useState, 1),
|
|
9101
9429
|
room = _React$useState2[0];
|
|
9102
9430
|
|
|
9103
|
-
return /*#__PURE__*/
|
|
9431
|
+
return /*#__PURE__*/React__default.createElement(RecoilRoot, null, /*#__PURE__*/React__default.createElement(WireProvider, {
|
|
9104
9432
|
room: room,
|
|
9105
9433
|
channel: "room",
|
|
9106
9434
|
socket: socket
|
|
9107
|
-
}, /*#__PURE__*/
|
|
9435
|
+
}, /*#__PURE__*/React__default.createElement(SubscribeUserEvents, null), children));
|
|
9108
9436
|
};
|
|
9109
9437
|
|
|
9110
9438
|
export { Board, ConnectedSyncBoard as BoardWrapper, ConnectedSyncRoom as RoomWrapper, useAvailableActions, useBoardConfig, useDim as useBoardPosition, useBoardState, useItemActions, useItemInteraction, useItemList as useItems, useMessage, useSelectedItems, useSelectionBox, useUsers, useWire };
|