next-chessground 0.13.11 → 1.0.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/index.es.js +164 -157
- package/dist/index.js +164 -157
- package/package.json +4 -4
package/dist/index.es.js
CHANGED
|
@@ -5280,140 +5280,129 @@ const useChess = props => {
|
|
|
5280
5280
|
var reactPureModal_min = createCommonjsModule(function (module, exports) {
|
|
5281
5281
|
!function (e, t) {
|
|
5282
5282
|
module.exports = t(React, require$$1);
|
|
5283
|
-
}(commonjsGlobal,
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
}
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
},
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
}
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
e
|
|
5331
|
-
}, function (e, t, o) {}, function (e, t, o) {
|
|
5332
|
-
|
|
5333
|
-
o.r(t);
|
|
5334
|
-
var n = o(0),
|
|
5335
|
-
a = o.n(n),
|
|
5336
|
-
r = o(1);
|
|
5337
|
-
function c(e) {
|
|
5283
|
+
}(commonjsGlobal, (e, t) => (() => {
|
|
5284
|
+
var o = {
|
|
5285
|
+
494: () => {},
|
|
5286
|
+
156: t => {
|
|
5287
|
+
|
|
5288
|
+
t.exports = e;
|
|
5289
|
+
},
|
|
5290
|
+
111: e => {
|
|
5291
|
+
|
|
5292
|
+
e.exports = t;
|
|
5293
|
+
}
|
|
5294
|
+
},
|
|
5295
|
+
n = {};
|
|
5296
|
+
function a(e) {
|
|
5297
|
+
var t = n[e];
|
|
5298
|
+
if (void 0 !== t) return t.exports;
|
|
5299
|
+
var r = n[e] = {
|
|
5300
|
+
exports: {}
|
|
5301
|
+
};
|
|
5302
|
+
return o[e](r, r.exports, a), r.exports;
|
|
5303
|
+
}
|
|
5304
|
+
a.n = e => {
|
|
5305
|
+
var t = e && e.__esModule ? () => e.default : () => e;
|
|
5306
|
+
return a.d(t, {
|
|
5307
|
+
a: t
|
|
5308
|
+
}), t;
|
|
5309
|
+
}, a.d = (e, t) => {
|
|
5310
|
+
for (var o in t) a.o(t, o) && !a.o(e, o) && Object.defineProperty(e, o, {
|
|
5311
|
+
enumerable: !0,
|
|
5312
|
+
get: t[o]
|
|
5313
|
+
});
|
|
5314
|
+
}, a.o = (e, t) => Object.prototype.hasOwnProperty.call(e, t), a.r = e => {
|
|
5315
|
+
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, {
|
|
5316
|
+
value: "Module"
|
|
5317
|
+
}), Object.defineProperty(e, "__esModule", {
|
|
5318
|
+
value: !0
|
|
5319
|
+
});
|
|
5320
|
+
};
|
|
5321
|
+
var r = {};
|
|
5322
|
+
return (() => {
|
|
5323
|
+
|
|
5324
|
+
a.r(r), a.d(r, {
|
|
5325
|
+
default: () => s
|
|
5326
|
+
});
|
|
5327
|
+
var e = a(156),
|
|
5328
|
+
t = a.n(e),
|
|
5329
|
+
o = a(111);
|
|
5330
|
+
function n(e) {
|
|
5338
5331
|
const {
|
|
5339
|
-
children:
|
|
5340
|
-
replace:
|
|
5341
|
-
bodyClass:
|
|
5332
|
+
children: o,
|
|
5333
|
+
replace: n,
|
|
5334
|
+
bodyClass: a,
|
|
5342
5335
|
header: r,
|
|
5343
5336
|
footer: c,
|
|
5344
|
-
onDragStart:
|
|
5345
|
-
onDragEnd:
|
|
5346
|
-
onClose:
|
|
5337
|
+
onDragStart: l,
|
|
5338
|
+
onDragEnd: s,
|
|
5339
|
+
onClose: u,
|
|
5347
5340
|
closeButton: i,
|
|
5348
5341
|
closeButtonPosition: d
|
|
5349
5342
|
} = e;
|
|
5350
|
-
return
|
|
5343
|
+
return n ? o : t().createElement("div", {
|
|
5351
5344
|
className: "panel panel-default " + ("bottom" === d ? "additional-row" : "")
|
|
5352
|
-
},
|
|
5345
|
+
}, t().createElement("div", {
|
|
5353
5346
|
className: "panel-heading",
|
|
5354
|
-
onTouchStart:
|
|
5355
|
-
onMouseDown:
|
|
5356
|
-
onTouchEnd:
|
|
5357
|
-
onMouseUp:
|
|
5358
|
-
}, r &&
|
|
5347
|
+
onTouchStart: l,
|
|
5348
|
+
onMouseDown: l,
|
|
5349
|
+
onTouchEnd: s,
|
|
5350
|
+
onMouseUp: s
|
|
5351
|
+
}, r && t().createElement("h3", {
|
|
5359
5352
|
className: "panel-title"
|
|
5360
|
-
}, r)),
|
|
5361
|
-
className:
|
|
5362
|
-
},
|
|
5353
|
+
}, r)), t().createElement("div", {
|
|
5354
|
+
className: a
|
|
5355
|
+
}, o), c && t().createElement("div", {
|
|
5363
5356
|
className: "panel-footer"
|
|
5364
|
-
}, c),
|
|
5357
|
+
}, c), t().createElement("div", {
|
|
5365
5358
|
className: "close",
|
|
5366
|
-
onClick:
|
|
5359
|
+
onClick: u,
|
|
5367
5360
|
style: {
|
|
5368
5361
|
position: "header" === d ? "absolute" : "static",
|
|
5369
5362
|
margin: "bottom" === d ? "10px auto" : ""
|
|
5370
5363
|
}
|
|
5371
5364
|
}, i));
|
|
5372
5365
|
}
|
|
5373
|
-
|
|
5366
|
+
n.defaultProps = {
|
|
5374
5367
|
closeButton: "×",
|
|
5375
5368
|
closeButtonPosition: "header",
|
|
5376
5369
|
replace: !1,
|
|
5377
5370
|
draggable: !1
|
|
5378
5371
|
};
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
function l(
|
|
5382
|
-
let
|
|
5383
|
-
const [
|
|
5384
|
-
[
|
|
5385
|
-
[i, d] =
|
|
5386
|
-
[
|
|
5387
|
-
[
|
|
5388
|
-
[
|
|
5389
|
-
[
|
|
5372
|
+
const c = n;
|
|
5373
|
+
a(494);
|
|
5374
|
+
function l(n) {
|
|
5375
|
+
let a = Math.random().toString();
|
|
5376
|
+
const [r, l] = (0, e.useState)(!1),
|
|
5377
|
+
[s, u] = (0, e.useState)(null),
|
|
5378
|
+
[i, d] = (0, e.useState)(null),
|
|
5379
|
+
[p, m] = (0, e.useState)(0),
|
|
5380
|
+
[f, g] = (0, e.useState)(0),
|
|
5381
|
+
[h, v] = (0, e.useState)(0),
|
|
5382
|
+
[b, y] = (0, e.useState)(0),
|
|
5390
5383
|
{
|
|
5391
|
-
isOpen:
|
|
5392
|
-
onClose:
|
|
5393
|
-
} =
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
isPassive: !1
|
|
5414
|
-
}), document.removeEventListener("keydown", O), document.body.classList.remove("body-modal-fix"), s(null), d(null), p(0), b(0), v(0), y(0);
|
|
5415
|
-
}
|
|
5416
|
-
function S(e) {
|
|
5384
|
+
isOpen: E,
|
|
5385
|
+
onClose: S
|
|
5386
|
+
} = n,
|
|
5387
|
+
T = (0, e.useCallback)(() => {
|
|
5388
|
+
document.body.classList.remove("body-modal-fix");
|
|
5389
|
+
}, []);
|
|
5390
|
+
(0, e.useEffect)(() => (E && (document.addEventListener("keydown", x), document.activeElement instanceof HTMLElement && document.activeElement.blur(), document.body.classList.add("body-modal-fix")), () => {
|
|
5391
|
+
document.querySelector(".pure-modal") || (document.removeEventListener("keydown", x), T(), u(null), d(null), m(0), g(0), v(0), y(0));
|
|
5392
|
+
}), [E]);
|
|
5393
|
+
const x = (0, e.useCallback)(e => {
|
|
5394
|
+
const t = document.querySelectorAll(".pure-modal"),
|
|
5395
|
+
o = t.length > 1,
|
|
5396
|
+
n = t[t.length - 1];
|
|
5397
|
+
return !(o && !n.className.includes(a)) && !("Escape" !== e.key || !document.activeElement) && (P(e), !0);
|
|
5398
|
+
}, [P, a]);
|
|
5399
|
+
if (!E) return null;
|
|
5400
|
+
function P(e) {
|
|
5401
|
+
e && (e.stopPropagation(), e.preventDefault()), null == S || S({
|
|
5402
|
+
isPassive: Boolean(e)
|
|
5403
|
+
});
|
|
5404
|
+
}
|
|
5405
|
+
function M(e) {
|
|
5417
5406
|
return e instanceof TouchEvent && e.changedTouches.length > 0 ? {
|
|
5418
5407
|
pageX: e.changedTouches[0].pageX,
|
|
5419
5408
|
pageY: e.changedTouches[0].pageY
|
|
@@ -5425,81 +5414,81 @@ var reactPureModal_min = createCommonjsModule(function (module, exports) {
|
|
|
5425
5414
|
pageY: 0
|
|
5426
5415
|
};
|
|
5427
5416
|
}
|
|
5428
|
-
function
|
|
5429
|
-
if (e instanceof TouchEvent && e.changedTouches && e.changedTouches.length > 1) return
|
|
5417
|
+
function j(e) {
|
|
5418
|
+
if (e instanceof TouchEvent && e.changedTouches && e.changedTouches.length > 1) return B();
|
|
5430
5419
|
e.preventDefault();
|
|
5431
5420
|
const {
|
|
5432
5421
|
pageX: t,
|
|
5433
5422
|
pageY: o
|
|
5434
|
-
} =
|
|
5435
|
-
"number" == typeof
|
|
5423
|
+
} = M(e);
|
|
5424
|
+
"number" == typeof s && "number" == typeof i && (m(t - s - h), g(o - i - b));
|
|
5436
5425
|
}
|
|
5437
|
-
function
|
|
5438
|
-
return
|
|
5426
|
+
function B() {
|
|
5427
|
+
return l(!1);
|
|
5439
5428
|
}
|
|
5440
5429
|
const {
|
|
5441
|
-
children:
|
|
5442
|
-
replace:
|
|
5443
|
-
className:
|
|
5444
|
-
header:
|
|
5430
|
+
children: D,
|
|
5431
|
+
replace: N = !1,
|
|
5432
|
+
className: k,
|
|
5433
|
+
header: w,
|
|
5445
5434
|
footer: C,
|
|
5446
|
-
scrollable:
|
|
5447
|
-
draggable:
|
|
5448
|
-
width:
|
|
5449
|
-
closeButton:
|
|
5450
|
-
closeButtonPosition:
|
|
5435
|
+
scrollable: X = !0,
|
|
5436
|
+
draggable: Y = !1,
|
|
5437
|
+
width: q,
|
|
5438
|
+
closeButton: L,
|
|
5439
|
+
closeButtonPosition: O,
|
|
5451
5440
|
portal: _ = !1
|
|
5452
|
-
} =
|
|
5453
|
-
let
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
const
|
|
5458
|
-
className:
|
|
5441
|
+
} = n;
|
|
5442
|
+
let $ = ["pure-modal-backdrop"],
|
|
5443
|
+
A = ["pure-modal", a],
|
|
5444
|
+
H = ["panel-body"];
|
|
5445
|
+
k && (A = A.concat(k)), X ? H = H.concat("scrollable") : ($ = $.concat("scrollable"), A = A.concat("auto-height")), Y && ($ = $.concat("backdrop-overflow-hidden"));
|
|
5446
|
+
const R = t().createElement("div", {
|
|
5447
|
+
className: $.join(" "),
|
|
5459
5448
|
onMouseDown: function (e) {
|
|
5460
5449
|
if (e) {
|
|
5461
5450
|
if (!e.target.classList.contains("pure-modal-backdrop")) return;
|
|
5462
5451
|
e.stopPropagation(), e.preventDefault();
|
|
5463
5452
|
}
|
|
5464
|
-
|
|
5453
|
+
P(e);
|
|
5465
5454
|
},
|
|
5466
|
-
onTouchMove:
|
|
5467
|
-
onMouseMove:
|
|
5468
|
-
},
|
|
5469
|
-
className:
|
|
5455
|
+
onTouchMove: r ? j : void 0,
|
|
5456
|
+
onMouseMove: r ? j : void 0
|
|
5457
|
+
}, t().createElement("div", {
|
|
5458
|
+
className: A.join(" "),
|
|
5470
5459
|
style: {
|
|
5471
|
-
transform: `translate(${
|
|
5460
|
+
transform: `translate(${p}px, ${f}px)`,
|
|
5472
5461
|
transition: "none",
|
|
5473
|
-
width:
|
|
5462
|
+
width: q
|
|
5474
5463
|
}
|
|
5475
|
-
},
|
|
5476
|
-
replace:
|
|
5477
|
-
header:
|
|
5464
|
+
}, t().createElement(c, {
|
|
5465
|
+
replace: N,
|
|
5466
|
+
header: w,
|
|
5478
5467
|
footer: C,
|
|
5479
|
-
onDragStart:
|
|
5468
|
+
onDragStart: Y ? function (e) {
|
|
5480
5469
|
if (e instanceof TouchEvent && e.changedTouches && e.changedTouches.length > 1) return;
|
|
5481
5470
|
e.preventDefault();
|
|
5482
5471
|
const {
|
|
5483
5472
|
pageX: t,
|
|
5484
5473
|
pageY: o
|
|
5485
|
-
} =
|
|
5474
|
+
} = M(e),
|
|
5486
5475
|
{
|
|
5487
5476
|
top: n,
|
|
5488
5477
|
left: a
|
|
5489
5478
|
} = e.currentTarget.getBoundingClientRect();
|
|
5490
|
-
|
|
5479
|
+
l(!0), u("number" == typeof s ? s : a), d("number" == typeof i ? i : n), v(t - a), y(o - n);
|
|
5491
5480
|
} : void 0,
|
|
5492
|
-
onDragEnd:
|
|
5493
|
-
onClose:
|
|
5494
|
-
bodyClass:
|
|
5495
|
-
closeButton:
|
|
5496
|
-
closeButtonPosition:
|
|
5497
|
-
},
|
|
5498
|
-
return _ ?
|
|
5499
|
-
}
|
|
5500
|
-
|
|
5501
|
-
}
|
|
5502
|
-
});
|
|
5481
|
+
onDragEnd: Y ? B : void 0,
|
|
5482
|
+
onClose: P,
|
|
5483
|
+
bodyClass: H.join(" "),
|
|
5484
|
+
closeButton: L,
|
|
5485
|
+
closeButtonPosition: O
|
|
5486
|
+
}, D)));
|
|
5487
|
+
return _ ? (0, o.createPortal)(R, document.body) : R;
|
|
5488
|
+
}
|
|
5489
|
+
const s = t().memo(l);
|
|
5490
|
+
})(), r;
|
|
5491
|
+
})());
|
|
5503
5492
|
});
|
|
5504
5493
|
|
|
5505
5494
|
var Modal = /*@__PURE__*/getDefaultExportFromCjs(reactPureModal_min);
|
|
@@ -5584,6 +5573,19 @@ const useDisclosure = (initialState = false) => {
|
|
|
5584
5573
|
};
|
|
5585
5574
|
};
|
|
5586
5575
|
|
|
5576
|
+
const cleanShapes = shapes => {
|
|
5577
|
+
try {
|
|
5578
|
+
// Iterate over each shape and remove the ']' character from the dest string
|
|
5579
|
+
shapes.forEach(shape => {
|
|
5580
|
+
// Use a regular expression to remove all occurrences of ']'
|
|
5581
|
+
shape.dest = shape.dest.replace(/\]/g, '');
|
|
5582
|
+
});
|
|
5583
|
+
return shapes;
|
|
5584
|
+
} catch {
|
|
5585
|
+
return shapes;
|
|
5586
|
+
}
|
|
5587
|
+
};
|
|
5588
|
+
|
|
5587
5589
|
const cgProps = props => {
|
|
5588
5590
|
const cgProps = {};
|
|
5589
5591
|
|
|
@@ -5611,6 +5613,11 @@ const cgProps = props => {
|
|
|
5611
5613
|
};
|
|
5612
5614
|
}
|
|
5613
5615
|
|
|
5616
|
+
// fix shapes
|
|
5617
|
+
if (cgProps.shapes) {
|
|
5618
|
+
cgProps.shapes = cleanShapes(cgProps.shapes);
|
|
5619
|
+
}
|
|
5620
|
+
|
|
5614
5621
|
// helper for Chessground editing mode
|
|
5615
5622
|
if (props.editing) {
|
|
5616
5623
|
cgProps.movable = {
|
package/dist/index.js
CHANGED
|
@@ -5289,140 +5289,129 @@ const useChess = props => {
|
|
|
5289
5289
|
var reactPureModal_min = createCommonjsModule(function (module, exports) {
|
|
5290
5290
|
!function (e, t) {
|
|
5291
5291
|
module.exports = t(React__default["default"], require$$1__default["default"]);
|
|
5292
|
-
}(commonjsGlobal,
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
}
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
},
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
}
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
e
|
|
5340
|
-
}, function (e, t, o) {}, function (e, t, o) {
|
|
5341
|
-
|
|
5342
|
-
o.r(t);
|
|
5343
|
-
var n = o(0),
|
|
5344
|
-
a = o.n(n),
|
|
5345
|
-
r = o(1);
|
|
5346
|
-
function c(e) {
|
|
5292
|
+
}(commonjsGlobal, (e, t) => (() => {
|
|
5293
|
+
var o = {
|
|
5294
|
+
494: () => {},
|
|
5295
|
+
156: t => {
|
|
5296
|
+
|
|
5297
|
+
t.exports = e;
|
|
5298
|
+
},
|
|
5299
|
+
111: e => {
|
|
5300
|
+
|
|
5301
|
+
e.exports = t;
|
|
5302
|
+
}
|
|
5303
|
+
},
|
|
5304
|
+
n = {};
|
|
5305
|
+
function a(e) {
|
|
5306
|
+
var t = n[e];
|
|
5307
|
+
if (void 0 !== t) return t.exports;
|
|
5308
|
+
var r = n[e] = {
|
|
5309
|
+
exports: {}
|
|
5310
|
+
};
|
|
5311
|
+
return o[e](r, r.exports, a), r.exports;
|
|
5312
|
+
}
|
|
5313
|
+
a.n = e => {
|
|
5314
|
+
var t = e && e.__esModule ? () => e.default : () => e;
|
|
5315
|
+
return a.d(t, {
|
|
5316
|
+
a: t
|
|
5317
|
+
}), t;
|
|
5318
|
+
}, a.d = (e, t) => {
|
|
5319
|
+
for (var o in t) a.o(t, o) && !a.o(e, o) && Object.defineProperty(e, o, {
|
|
5320
|
+
enumerable: !0,
|
|
5321
|
+
get: t[o]
|
|
5322
|
+
});
|
|
5323
|
+
}, a.o = (e, t) => Object.prototype.hasOwnProperty.call(e, t), a.r = e => {
|
|
5324
|
+
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, {
|
|
5325
|
+
value: "Module"
|
|
5326
|
+
}), Object.defineProperty(e, "__esModule", {
|
|
5327
|
+
value: !0
|
|
5328
|
+
});
|
|
5329
|
+
};
|
|
5330
|
+
var r = {};
|
|
5331
|
+
return (() => {
|
|
5332
|
+
|
|
5333
|
+
a.r(r), a.d(r, {
|
|
5334
|
+
default: () => s
|
|
5335
|
+
});
|
|
5336
|
+
var e = a(156),
|
|
5337
|
+
t = a.n(e),
|
|
5338
|
+
o = a(111);
|
|
5339
|
+
function n(e) {
|
|
5347
5340
|
const {
|
|
5348
|
-
children:
|
|
5349
|
-
replace:
|
|
5350
|
-
bodyClass:
|
|
5341
|
+
children: o,
|
|
5342
|
+
replace: n,
|
|
5343
|
+
bodyClass: a,
|
|
5351
5344
|
header: r,
|
|
5352
5345
|
footer: c,
|
|
5353
|
-
onDragStart:
|
|
5354
|
-
onDragEnd:
|
|
5355
|
-
onClose:
|
|
5346
|
+
onDragStart: l,
|
|
5347
|
+
onDragEnd: s,
|
|
5348
|
+
onClose: u,
|
|
5356
5349
|
closeButton: i,
|
|
5357
5350
|
closeButtonPosition: d
|
|
5358
5351
|
} = e;
|
|
5359
|
-
return
|
|
5352
|
+
return n ? o : t().createElement("div", {
|
|
5360
5353
|
className: "panel panel-default " + ("bottom" === d ? "additional-row" : "")
|
|
5361
|
-
},
|
|
5354
|
+
}, t().createElement("div", {
|
|
5362
5355
|
className: "panel-heading",
|
|
5363
|
-
onTouchStart:
|
|
5364
|
-
onMouseDown:
|
|
5365
|
-
onTouchEnd:
|
|
5366
|
-
onMouseUp:
|
|
5367
|
-
}, r &&
|
|
5356
|
+
onTouchStart: l,
|
|
5357
|
+
onMouseDown: l,
|
|
5358
|
+
onTouchEnd: s,
|
|
5359
|
+
onMouseUp: s
|
|
5360
|
+
}, r && t().createElement("h3", {
|
|
5368
5361
|
className: "panel-title"
|
|
5369
|
-
}, r)),
|
|
5370
|
-
className:
|
|
5371
|
-
},
|
|
5362
|
+
}, r)), t().createElement("div", {
|
|
5363
|
+
className: a
|
|
5364
|
+
}, o), c && t().createElement("div", {
|
|
5372
5365
|
className: "panel-footer"
|
|
5373
|
-
}, c),
|
|
5366
|
+
}, c), t().createElement("div", {
|
|
5374
5367
|
className: "close",
|
|
5375
|
-
onClick:
|
|
5368
|
+
onClick: u,
|
|
5376
5369
|
style: {
|
|
5377
5370
|
position: "header" === d ? "absolute" : "static",
|
|
5378
5371
|
margin: "bottom" === d ? "10px auto" : ""
|
|
5379
5372
|
}
|
|
5380
5373
|
}, i));
|
|
5381
5374
|
}
|
|
5382
|
-
|
|
5375
|
+
n.defaultProps = {
|
|
5383
5376
|
closeButton: "×",
|
|
5384
5377
|
closeButtonPosition: "header",
|
|
5385
5378
|
replace: !1,
|
|
5386
5379
|
draggable: !1
|
|
5387
5380
|
};
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
function l(
|
|
5391
|
-
let
|
|
5392
|
-
const [
|
|
5393
|
-
[
|
|
5394
|
-
[i, d] =
|
|
5395
|
-
[
|
|
5396
|
-
[
|
|
5397
|
-
[
|
|
5398
|
-
[
|
|
5381
|
+
const c = n;
|
|
5382
|
+
a(494);
|
|
5383
|
+
function l(n) {
|
|
5384
|
+
let a = Math.random().toString();
|
|
5385
|
+
const [r, l] = (0, e.useState)(!1),
|
|
5386
|
+
[s, u] = (0, e.useState)(null),
|
|
5387
|
+
[i, d] = (0, e.useState)(null),
|
|
5388
|
+
[p, m] = (0, e.useState)(0),
|
|
5389
|
+
[f, g] = (0, e.useState)(0),
|
|
5390
|
+
[h, v] = (0, e.useState)(0),
|
|
5391
|
+
[b, y] = (0, e.useState)(0),
|
|
5399
5392
|
{
|
|
5400
|
-
isOpen:
|
|
5401
|
-
onClose:
|
|
5402
|
-
} =
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
isPassive: !1
|
|
5423
|
-
}), document.removeEventListener("keydown", O), document.body.classList.remove("body-modal-fix"), s(null), d(null), p(0), b(0), v(0), y(0);
|
|
5424
|
-
}
|
|
5425
|
-
function S(e) {
|
|
5393
|
+
isOpen: E,
|
|
5394
|
+
onClose: S
|
|
5395
|
+
} = n,
|
|
5396
|
+
T = (0, e.useCallback)(() => {
|
|
5397
|
+
document.body.classList.remove("body-modal-fix");
|
|
5398
|
+
}, []);
|
|
5399
|
+
(0, e.useEffect)(() => (E && (document.addEventListener("keydown", x), document.activeElement instanceof HTMLElement && document.activeElement.blur(), document.body.classList.add("body-modal-fix")), () => {
|
|
5400
|
+
document.querySelector(".pure-modal") || (document.removeEventListener("keydown", x), T(), u(null), d(null), m(0), g(0), v(0), y(0));
|
|
5401
|
+
}), [E]);
|
|
5402
|
+
const x = (0, e.useCallback)(e => {
|
|
5403
|
+
const t = document.querySelectorAll(".pure-modal"),
|
|
5404
|
+
o = t.length > 1,
|
|
5405
|
+
n = t[t.length - 1];
|
|
5406
|
+
return !(o && !n.className.includes(a)) && !("Escape" !== e.key || !document.activeElement) && (P(e), !0);
|
|
5407
|
+
}, [P, a]);
|
|
5408
|
+
if (!E) return null;
|
|
5409
|
+
function P(e) {
|
|
5410
|
+
e && (e.stopPropagation(), e.preventDefault()), null == S || S({
|
|
5411
|
+
isPassive: Boolean(e)
|
|
5412
|
+
});
|
|
5413
|
+
}
|
|
5414
|
+
function M(e) {
|
|
5426
5415
|
return e instanceof TouchEvent && e.changedTouches.length > 0 ? {
|
|
5427
5416
|
pageX: e.changedTouches[0].pageX,
|
|
5428
5417
|
pageY: e.changedTouches[0].pageY
|
|
@@ -5434,81 +5423,81 @@ var reactPureModal_min = createCommonjsModule(function (module, exports) {
|
|
|
5434
5423
|
pageY: 0
|
|
5435
5424
|
};
|
|
5436
5425
|
}
|
|
5437
|
-
function
|
|
5438
|
-
if (e instanceof TouchEvent && e.changedTouches && e.changedTouches.length > 1) return
|
|
5426
|
+
function j(e) {
|
|
5427
|
+
if (e instanceof TouchEvent && e.changedTouches && e.changedTouches.length > 1) return B();
|
|
5439
5428
|
e.preventDefault();
|
|
5440
5429
|
const {
|
|
5441
5430
|
pageX: t,
|
|
5442
5431
|
pageY: o
|
|
5443
|
-
} =
|
|
5444
|
-
"number" == typeof
|
|
5432
|
+
} = M(e);
|
|
5433
|
+
"number" == typeof s && "number" == typeof i && (m(t - s - h), g(o - i - b));
|
|
5445
5434
|
}
|
|
5446
|
-
function
|
|
5447
|
-
return
|
|
5435
|
+
function B() {
|
|
5436
|
+
return l(!1);
|
|
5448
5437
|
}
|
|
5449
5438
|
const {
|
|
5450
|
-
children:
|
|
5451
|
-
replace:
|
|
5452
|
-
className:
|
|
5453
|
-
header:
|
|
5439
|
+
children: D,
|
|
5440
|
+
replace: N = !1,
|
|
5441
|
+
className: k,
|
|
5442
|
+
header: w,
|
|
5454
5443
|
footer: C,
|
|
5455
|
-
scrollable:
|
|
5456
|
-
draggable:
|
|
5457
|
-
width:
|
|
5458
|
-
closeButton:
|
|
5459
|
-
closeButtonPosition:
|
|
5444
|
+
scrollable: X = !0,
|
|
5445
|
+
draggable: Y = !1,
|
|
5446
|
+
width: q,
|
|
5447
|
+
closeButton: L,
|
|
5448
|
+
closeButtonPosition: O,
|
|
5460
5449
|
portal: _ = !1
|
|
5461
|
-
} =
|
|
5462
|
-
let
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
const
|
|
5467
|
-
className:
|
|
5450
|
+
} = n;
|
|
5451
|
+
let $ = ["pure-modal-backdrop"],
|
|
5452
|
+
A = ["pure-modal", a],
|
|
5453
|
+
H = ["panel-body"];
|
|
5454
|
+
k && (A = A.concat(k)), X ? H = H.concat("scrollable") : ($ = $.concat("scrollable"), A = A.concat("auto-height")), Y && ($ = $.concat("backdrop-overflow-hidden"));
|
|
5455
|
+
const R = t().createElement("div", {
|
|
5456
|
+
className: $.join(" "),
|
|
5468
5457
|
onMouseDown: function (e) {
|
|
5469
5458
|
if (e) {
|
|
5470
5459
|
if (!e.target.classList.contains("pure-modal-backdrop")) return;
|
|
5471
5460
|
e.stopPropagation(), e.preventDefault();
|
|
5472
5461
|
}
|
|
5473
|
-
|
|
5462
|
+
P(e);
|
|
5474
5463
|
},
|
|
5475
|
-
onTouchMove:
|
|
5476
|
-
onMouseMove:
|
|
5477
|
-
},
|
|
5478
|
-
className:
|
|
5464
|
+
onTouchMove: r ? j : void 0,
|
|
5465
|
+
onMouseMove: r ? j : void 0
|
|
5466
|
+
}, t().createElement("div", {
|
|
5467
|
+
className: A.join(" "),
|
|
5479
5468
|
style: {
|
|
5480
|
-
transform: `translate(${
|
|
5469
|
+
transform: `translate(${p}px, ${f}px)`,
|
|
5481
5470
|
transition: "none",
|
|
5482
|
-
width:
|
|
5471
|
+
width: q
|
|
5483
5472
|
}
|
|
5484
|
-
},
|
|
5485
|
-
replace:
|
|
5486
|
-
header:
|
|
5473
|
+
}, t().createElement(c, {
|
|
5474
|
+
replace: N,
|
|
5475
|
+
header: w,
|
|
5487
5476
|
footer: C,
|
|
5488
|
-
onDragStart:
|
|
5477
|
+
onDragStart: Y ? function (e) {
|
|
5489
5478
|
if (e instanceof TouchEvent && e.changedTouches && e.changedTouches.length > 1) return;
|
|
5490
5479
|
e.preventDefault();
|
|
5491
5480
|
const {
|
|
5492
5481
|
pageX: t,
|
|
5493
5482
|
pageY: o
|
|
5494
|
-
} =
|
|
5483
|
+
} = M(e),
|
|
5495
5484
|
{
|
|
5496
5485
|
top: n,
|
|
5497
5486
|
left: a
|
|
5498
5487
|
} = e.currentTarget.getBoundingClientRect();
|
|
5499
|
-
|
|
5488
|
+
l(!0), u("number" == typeof s ? s : a), d("number" == typeof i ? i : n), v(t - a), y(o - n);
|
|
5500
5489
|
} : void 0,
|
|
5501
|
-
onDragEnd:
|
|
5502
|
-
onClose:
|
|
5503
|
-
bodyClass:
|
|
5504
|
-
closeButton:
|
|
5505
|
-
closeButtonPosition:
|
|
5506
|
-
},
|
|
5507
|
-
return _ ?
|
|
5508
|
-
}
|
|
5509
|
-
|
|
5510
|
-
}
|
|
5511
|
-
});
|
|
5490
|
+
onDragEnd: Y ? B : void 0,
|
|
5491
|
+
onClose: P,
|
|
5492
|
+
bodyClass: H.join(" "),
|
|
5493
|
+
closeButton: L,
|
|
5494
|
+
closeButtonPosition: O
|
|
5495
|
+
}, D)));
|
|
5496
|
+
return _ ? (0, o.createPortal)(R, document.body) : R;
|
|
5497
|
+
}
|
|
5498
|
+
const s = t().memo(l);
|
|
5499
|
+
})(), r;
|
|
5500
|
+
})());
|
|
5512
5501
|
});
|
|
5513
5502
|
|
|
5514
5503
|
var Modal = /*@__PURE__*/getDefaultExportFromCjs(reactPureModal_min);
|
|
@@ -5593,6 +5582,19 @@ const useDisclosure = (initialState = false) => {
|
|
|
5593
5582
|
};
|
|
5594
5583
|
};
|
|
5595
5584
|
|
|
5585
|
+
const cleanShapes = shapes => {
|
|
5586
|
+
try {
|
|
5587
|
+
// Iterate over each shape and remove the ']' character from the dest string
|
|
5588
|
+
shapes.forEach(shape => {
|
|
5589
|
+
// Use a regular expression to remove all occurrences of ']'
|
|
5590
|
+
shape.dest = shape.dest.replace(/\]/g, '');
|
|
5591
|
+
});
|
|
5592
|
+
return shapes;
|
|
5593
|
+
} catch {
|
|
5594
|
+
return shapes;
|
|
5595
|
+
}
|
|
5596
|
+
};
|
|
5597
|
+
|
|
5596
5598
|
const cgProps = props => {
|
|
5597
5599
|
const cgProps = {};
|
|
5598
5600
|
|
|
@@ -5620,6 +5622,11 @@ const cgProps = props => {
|
|
|
5620
5622
|
};
|
|
5621
5623
|
}
|
|
5622
5624
|
|
|
5625
|
+
// fix shapes
|
|
5626
|
+
if (cgProps.shapes) {
|
|
5627
|
+
cgProps.shapes = cleanShapes(cgProps.shapes);
|
|
5628
|
+
}
|
|
5629
|
+
|
|
5623
5630
|
// helper for Chessground editing mode
|
|
5624
5631
|
if (props.editing) {
|
|
5625
5632
|
cgProps.movable = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-chessground",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "React and Next wrapper for Chessground with chessboard and pieces out of the box",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"chess.js": "^0.12.0",
|
|
31
31
|
"chessground": "^7.12.0",
|
|
32
32
|
"merge-class-names": "^1.4.2",
|
|
33
|
-
"react-pure-modal": "^2.
|
|
33
|
+
"react-pure-modal": "^2.2.7",
|
|
34
34
|
"store2": "^2.12.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"eslint": "^7.11.0",
|
|
49
49
|
"eslint-plugin-react": "^7.21.4",
|
|
50
50
|
"prettier": "^2.1.2",
|
|
51
|
-
"react": "
|
|
52
|
-
"react-dom": "
|
|
51
|
+
"react": "^18.3.1",
|
|
52
|
+
"react-dom": "^18.3.1",
|
|
53
53
|
"rollup": "^2.32.1",
|
|
54
54
|
"rollup-plugin-babel": "^4.4.0",
|
|
55
55
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|