@opengeoweb/shared 9.9.0 → 9.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.esm.js +666 -31
- package/package.json +2 -2
- package/src/lib/components/CanvasComponent/CanvasComponent.d.ts +71 -0
- package/src/lib/components/CanvasComponent/CanvasComponent.stories.d.ts +7 -0
- package/src/lib/components/CanvasComponent/index.d.ts +1 -0
- package/src/lib/components/TooltipSelect/TooltipSelect.d.ts +4 -3
- package/src/lib/components/index.d.ts +1 -0
- package/src/lib/utils/index.d.ts +1 -1
- package/src/lib/utils/metronome.d.ts +77 -0
- package/src/lib/utils/metronome.spec.d.ts +1 -0
- package/src/lib/utils/metronome.stories.d.ts +7 -0
- package/src/lib/utils/layoutUtils.d.ts +0 -1
- /package/src/lib/{utils/layoutUtils.spec.d.ts → components/CanvasComponent/CanvasComponent.spec.d.ts} +0 -0
package/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default, { useRef } from 'react';
|
|
2
|
+
import React__default, { useRef, Component } from 'react';
|
|
3
3
|
import { Box, Typography, Tooltip, IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button, CircularProgress, Alert, AlertTitle, useTheme, Drawer, Link, Avatar as Avatar$1, Paper, ClickAwayListener, MenuList, MenuItem, Grid, RadioGroup, FormControlLabel, Radio, List, ListItem, Tabs, Tab, Backdrop, Slider, ToggleButton, Menu, ListSubheader, ListItemText, ListItemIcon, Select, Accordion, AccordionSummary, AccordionDetails, FormLabel, Switch, TextField, InputAdornment } from '@mui/material';
|
|
4
4
|
import { Close, Exclamation, Success, Info, ChevronRight, GeoWebLogo, HamburgerMenu, Resize, useThemeContext, DragHandle, ArrowLeft, ArrowRight, KeyOption, ArrowUp, ArrowDown, KeyCommand, Options, ChevronDown, Search, Clear, Cached } from '@opengeoweb/theme';
|
|
5
5
|
import { throttle, escapeRegExp, debounce } from 'lodash';
|
|
@@ -259,6 +259,57 @@ function _nonIterableSpread() {
|
|
|
259
259
|
function _nonIterableRest() {
|
|
260
260
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
261
261
|
}
|
|
262
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
263
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
264
|
+
if (!it) {
|
|
265
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
266
|
+
if (it) o = it;
|
|
267
|
+
var i = 0;
|
|
268
|
+
var F = function () {};
|
|
269
|
+
return {
|
|
270
|
+
s: F,
|
|
271
|
+
n: function () {
|
|
272
|
+
if (i >= o.length) return {
|
|
273
|
+
done: true
|
|
274
|
+
};
|
|
275
|
+
return {
|
|
276
|
+
done: false,
|
|
277
|
+
value: o[i++]
|
|
278
|
+
};
|
|
279
|
+
},
|
|
280
|
+
e: function (e) {
|
|
281
|
+
throw e;
|
|
282
|
+
},
|
|
283
|
+
f: F
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
287
|
+
}
|
|
288
|
+
var normalCompletion = true,
|
|
289
|
+
didErr = false,
|
|
290
|
+
err;
|
|
291
|
+
return {
|
|
292
|
+
s: function () {
|
|
293
|
+
it = it.call(o);
|
|
294
|
+
},
|
|
295
|
+
n: function () {
|
|
296
|
+
var step = it.next();
|
|
297
|
+
normalCompletion = step.done;
|
|
298
|
+
return step;
|
|
299
|
+
},
|
|
300
|
+
e: function (e) {
|
|
301
|
+
didErr = true;
|
|
302
|
+
err = e;
|
|
303
|
+
},
|
|
304
|
+
f: function () {
|
|
305
|
+
try {
|
|
306
|
+
if (!normalCompletion && it.return != null) it.return();
|
|
307
|
+
} finally {
|
|
308
|
+
if (didErr) throw err;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
}
|
|
262
313
|
|
|
263
314
|
var defaultDelay = 1000;
|
|
264
315
|
var useControlledTooltip = function useControlledTooltip() {
|
|
@@ -2886,7 +2937,9 @@ var TooltipSelect = function TooltipSelect(_a) {
|
|
|
2886
2937
|
isEnabled = _a.isEnabled,
|
|
2887
2938
|
noStyling = _a.noStyling,
|
|
2888
2939
|
hasBackgroundColor = _a.hasBackgroundColor,
|
|
2889
|
-
|
|
2940
|
+
_a$variant = _a.variant,
|
|
2941
|
+
variant = _a$variant === void 0 ? 'standard' : _a$variant,
|
|
2942
|
+
props = __rest(_a, ["tooltip", "list", "currentIndex", "onChangeMouseWheel", "requiresCtrlToChange", "isEnabled", "noStyling", "hasBackgroundColor", "variant"]);
|
|
2890
2943
|
var _React$useState = React.useState(false),
|
|
2891
2944
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
2892
2945
|
selectOpen = _React$useState2[0],
|
|
@@ -2936,7 +2989,7 @@ var TooltipSelect = function TooltipSelect(_a) {
|
|
|
2936
2989
|
placement: "top",
|
|
2937
2990
|
open: tooltipOpen
|
|
2938
2991
|
}, /*#__PURE__*/React.createElement(Select, Object.assign({
|
|
2939
|
-
variant:
|
|
2992
|
+
variant: variant,
|
|
2940
2993
|
disableUnderline: true,
|
|
2941
2994
|
onOpen: onOpen,
|
|
2942
2995
|
onClose: onClose,
|
|
@@ -3323,6 +3376,366 @@ var LastUpdateTime = function LastUpdateTime(_ref) {
|
|
|
3323
3376
|
}, /*#__PURE__*/React__default.createElement(Cached, null)));
|
|
3324
3377
|
};
|
|
3325
3378
|
|
|
3379
|
+
var CanvasComponent = /*#__PURE__*/function (_Component) {
|
|
3380
|
+
_inherits(CanvasComponent, _Component);
|
|
3381
|
+
function CanvasComponent(props) {
|
|
3382
|
+
var _this;
|
|
3383
|
+
_classCallCheck(this, CanvasComponent);
|
|
3384
|
+
_this = _callSuper(this, CanvasComponent, [props]);
|
|
3385
|
+
_this.canvas = null;
|
|
3386
|
+
_this.ctx = null;
|
|
3387
|
+
_this.currentWidth = 1;
|
|
3388
|
+
_this.currentHeight = 1;
|
|
3389
|
+
_this.canvascontaineroutside = null;
|
|
3390
|
+
_this.canvascontainer = null;
|
|
3391
|
+
_this.timer = null;
|
|
3392
|
+
_this.redrawTimer = null;
|
|
3393
|
+
_this.loopHasStarted = false;
|
|
3394
|
+
_this.mounted = false;
|
|
3395
|
+
_this.updateCanvas = _this.updateCanvas.bind(_assertThisInitialized(_this));
|
|
3396
|
+
_this.handleMouseMoveEvent = _this.handleMouseMoveEvent.bind(_assertThisInitialized(_this));
|
|
3397
|
+
_this.handleMouseUpEvent = _this.handleMouseUpEvent.bind(_assertThisInitialized(_this));
|
|
3398
|
+
_this.handleMouseDownEvent = _this.handleMouseDownEvent.bind(_assertThisInitialized(_this));
|
|
3399
|
+
_this.resize = _this.resize.bind(_assertThisInitialized(_this));
|
|
3400
|
+
_this._handleWindowResize = _this._handleWindowResize.bind(_assertThisInitialized(_this));
|
|
3401
|
+
_this.handleClickEvent = _this.handleClickEvent.bind(_assertThisInitialized(_this));
|
|
3402
|
+
_this.handleWheelEvent = _this.handleWheelEvent.bind(_assertThisInitialized(_this));
|
|
3403
|
+
_this.handleTouchStartEvent = _this.handleTouchStartEvent.bind(_assertThisInitialized(_this));
|
|
3404
|
+
_this.handleTouchEndEvent = _this.handleTouchEndEvent.bind(_assertThisInitialized(_this));
|
|
3405
|
+
_this.handleTouchMoveEvent = _this.handleTouchMoveEvent.bind(_assertThisInitialized(_this));
|
|
3406
|
+
_this.onKeyUp = _this.onKeyUp.bind(_assertThisInitialized(_this));
|
|
3407
|
+
_this.onBlur = _this.onBlur.bind(_assertThisInitialized(_this));
|
|
3408
|
+
_this.onFocus = _this.onFocus.bind(_assertThisInitialized(_this));
|
|
3409
|
+
_this.startLoop = _this.startLoop.bind(_assertThisInitialized(_this));
|
|
3410
|
+
_this._documentKeyDown = _this._documentKeyDown.bind(_assertThisInitialized(_this));
|
|
3411
|
+
_this._isFocussed = false;
|
|
3412
|
+
_this.canvas = null;
|
|
3413
|
+
_this.canvascontaineroutside = /*#__PURE__*/React__default.createRef();
|
|
3414
|
+
_this.canvascontainer = /*#__PURE__*/React__default.createRef();
|
|
3415
|
+
return _this;
|
|
3416
|
+
}
|
|
3417
|
+
_createClass(CanvasComponent, [{
|
|
3418
|
+
key: "componentDidMount",
|
|
3419
|
+
value: function componentDidMount() {
|
|
3420
|
+
var _this2 = this;
|
|
3421
|
+
this.mounted = true;
|
|
3422
|
+
if (this.canvas) {
|
|
3423
|
+
this.canvas.addEventListener('mousemove', this.handleMouseMoveEvent);
|
|
3424
|
+
this.canvas.addEventListener('mouseup', this.handleMouseUpEvent);
|
|
3425
|
+
this.canvas.addEventListener('mousedown', this.handleMouseDownEvent);
|
|
3426
|
+
this.canvas.addEventListener('touchstart', this.handleTouchStartEvent);
|
|
3427
|
+
this.canvas.addEventListener('touchend', this.handleTouchEndEvent);
|
|
3428
|
+
this.canvas.addEventListener('touchmove', this.handleTouchMoveEvent);
|
|
3429
|
+
this.canvas.addEventListener('wheel', this.handleWheelEvent);
|
|
3430
|
+
this.canvas.addEventListener('click', this.handleClickEvent);
|
|
3431
|
+
document.addEventListener('keydown', this._documentKeyDown, false);
|
|
3432
|
+
this.resize();
|
|
3433
|
+
this.updateCanvas();
|
|
3434
|
+
}
|
|
3435
|
+
var _this$props = this.props,
|
|
3436
|
+
onKeyUp = _this$props.onKeyUp,
|
|
3437
|
+
loopInterval = _this$props.redrawInterval;
|
|
3438
|
+
if (onKeyUp) {
|
|
3439
|
+
window.addEventListener('keyup', this.onKeyUp);
|
|
3440
|
+
}
|
|
3441
|
+
window.addEventListener('resize', this._handleWindowResize);
|
|
3442
|
+
if (this.canvascontaineroutside && this.canvascontaineroutside.current && onKeyUp) {
|
|
3443
|
+
this.canvascontaineroutside.current.focus();
|
|
3444
|
+
}
|
|
3445
|
+
this.timer = setInterval(function () {
|
|
3446
|
+
_this2.resize();
|
|
3447
|
+
}, 1000);
|
|
3448
|
+
if (loopInterval) {
|
|
3449
|
+
this.redrawTimer = setInterval(function () {
|
|
3450
|
+
_this2.updateCanvas();
|
|
3451
|
+
}, loopInterval);
|
|
3452
|
+
}
|
|
3453
|
+
}
|
|
3454
|
+
}, {
|
|
3455
|
+
key: "shouldComponentUpdate",
|
|
3456
|
+
value: function shouldComponentUpdate() {
|
|
3457
|
+
var _this3 = this;
|
|
3458
|
+
window.requestAnimationFrame(function () {
|
|
3459
|
+
_this3.updateCanvas();
|
|
3460
|
+
});
|
|
3461
|
+
return false;
|
|
3462
|
+
}
|
|
3463
|
+
}, {
|
|
3464
|
+
key: "componentWillUnmount",
|
|
3465
|
+
value: function componentWillUnmount() {
|
|
3466
|
+
this.mounted = false;
|
|
3467
|
+
window.removeEventListener('resize', this._handleWindowResize);
|
|
3468
|
+
var onKeyUp = this.props.onKeyUp;
|
|
3469
|
+
if (onKeyUp) {
|
|
3470
|
+
window.removeEventListener('keyup', this.onKeyUp);
|
|
3471
|
+
}
|
|
3472
|
+
if (this.canvas) {
|
|
3473
|
+
this.canvas.removeEventListener('mousedown', this.handleMouseDownEvent);
|
|
3474
|
+
this.canvas.removeEventListener('mouseup', this.handleMouseUpEvent);
|
|
3475
|
+
this.canvas.removeEventListener('mousemove', this.handleMouseMoveEvent);
|
|
3476
|
+
this.canvas.removeEventListener('touchstart', this.handleTouchStartEvent);
|
|
3477
|
+
this.canvas.removeEventListener('touchend', this.handleTouchEndEvent);
|
|
3478
|
+
this.canvas.removeEventListener('touchmove', this.handleTouchMoveEvent);
|
|
3479
|
+
this.canvas.removeEventListener('wheel', this.handleWheelEvent);
|
|
3480
|
+
this.canvas.removeEventListener('click', this.handleClickEvent);
|
|
3481
|
+
document.removeEventListener('keydown', this._documentKeyDown);
|
|
3482
|
+
}
|
|
3483
|
+
clearInterval(this.timer);
|
|
3484
|
+
clearInterval(this.redrawTimer);
|
|
3485
|
+
}
|
|
3486
|
+
}, {
|
|
3487
|
+
key: "handleMouseMoveEvent",
|
|
3488
|
+
value: function handleMouseMoveEvent(event) {
|
|
3489
|
+
var _this$props2 = this.props,
|
|
3490
|
+
onMouseMove = _this$props2.onMouseMove,
|
|
3491
|
+
onCanvasClick = _this$props2.onCanvasClick;
|
|
3492
|
+
var x = event.offsetX;
|
|
3493
|
+
var y = event.offsetY;
|
|
3494
|
+
if (event.buttons === 1) {
|
|
3495
|
+
onCanvasClick(x, y, this.currentWidth, this.currentHeight);
|
|
3496
|
+
}
|
|
3497
|
+
onMouseMove(x, y, event, this.currentWidth);
|
|
3498
|
+
}
|
|
3499
|
+
}, {
|
|
3500
|
+
key: "handleMouseUpEvent",
|
|
3501
|
+
value: function handleMouseUpEvent(event) {
|
|
3502
|
+
var onMouseUp = this.props.onMouseUp;
|
|
3503
|
+
var x = event.offsetX;
|
|
3504
|
+
onMouseUp(x);
|
|
3505
|
+
}
|
|
3506
|
+
}, {
|
|
3507
|
+
key: "handleMouseDownEvent",
|
|
3508
|
+
value: function handleMouseDownEvent(event) {
|
|
3509
|
+
var onMouseDown = this.props.onMouseDown;
|
|
3510
|
+
var x = event.offsetX;
|
|
3511
|
+
var y = event.offsetY;
|
|
3512
|
+
onMouseDown(x, y, this.currentWidth);
|
|
3513
|
+
}
|
|
3514
|
+
}, {
|
|
3515
|
+
key: "handleTouchStartEvent",
|
|
3516
|
+
value: function handleTouchStartEvent(event) {
|
|
3517
|
+
var onTouchStart = this.props.onTouchStart;
|
|
3518
|
+
onTouchStart(event, this.currentWidth);
|
|
3519
|
+
}
|
|
3520
|
+
}, {
|
|
3521
|
+
key: "handleTouchEndEvent",
|
|
3522
|
+
value: function handleTouchEndEvent() {
|
|
3523
|
+
var onTouchEnd = this.props.onTouchEnd;
|
|
3524
|
+
onTouchEnd();
|
|
3525
|
+
}
|
|
3526
|
+
}, {
|
|
3527
|
+
key: "handleTouchMoveEvent",
|
|
3528
|
+
value: function handleTouchMoveEvent(event) {
|
|
3529
|
+
var _this$props3 = this.props,
|
|
3530
|
+
onTouchMove = _this$props3.onTouchMove,
|
|
3531
|
+
onCanvasClick = _this$props3.onCanvasClick;
|
|
3532
|
+
var touches = event && event.touches && event.touches[0];
|
|
3533
|
+
if (touches && touches.clientX && touches.clientY) {
|
|
3534
|
+
var x2 = event.touches[0].clientX - event.touches[0].target.offsetLeft;
|
|
3535
|
+
var y2 = event.touches[0].clientY;
|
|
3536
|
+
onCanvasClick(x2, y2, this.currentWidth, this.currentHeight);
|
|
3537
|
+
}
|
|
3538
|
+
onTouchMove(event, this.currentWidth);
|
|
3539
|
+
}
|
|
3540
|
+
}, {
|
|
3541
|
+
key: "handleClickEvent",
|
|
3542
|
+
value: function handleClickEvent(event) {
|
|
3543
|
+
var onCanvasClick = this.props.onCanvasClick;
|
|
3544
|
+
var x = event.offsetX;
|
|
3545
|
+
var y = event.offsetY;
|
|
3546
|
+
onCanvasClick(x, y, this.currentWidth, this.currentHeight);
|
|
3547
|
+
}
|
|
3548
|
+
}, {
|
|
3549
|
+
key: "handleWheelEvent",
|
|
3550
|
+
value: function handleWheelEvent(event) {
|
|
3551
|
+
var onWheel = this.props.onWheel;
|
|
3552
|
+
onWheel({
|
|
3553
|
+
event: event,
|
|
3554
|
+
deltaY: event.deltaY,
|
|
3555
|
+
deltaX: event.deltaX,
|
|
3556
|
+
canvasWidth: event.srcElement.width,
|
|
3557
|
+
mouseX: event.offsetX
|
|
3558
|
+
});
|
|
3559
|
+
}
|
|
3560
|
+
}, {
|
|
3561
|
+
key: "onFocus",
|
|
3562
|
+
value: function onFocus() {
|
|
3563
|
+
var isFocussed = this.props.isFocussed;
|
|
3564
|
+
this._isFocussed = true;
|
|
3565
|
+
if (isFocussed) {
|
|
3566
|
+
isFocussed(true);
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3569
|
+
}, {
|
|
3570
|
+
key: "onBlur",
|
|
3571
|
+
value: function onBlur() {
|
|
3572
|
+
var isFocussed = this.props.isFocussed;
|
|
3573
|
+
this._isFocussed = false;
|
|
3574
|
+
if (isFocussed) {
|
|
3575
|
+
isFocussed(false);
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
}, {
|
|
3579
|
+
key: "onKeyUp",
|
|
3580
|
+
value: function onKeyUp(event) {
|
|
3581
|
+
var onKeyUp = this.props.onKeyUp;
|
|
3582
|
+
if (onKeyUp) {
|
|
3583
|
+
onKeyUp(event);
|
|
3584
|
+
}
|
|
3585
|
+
if (this.canvascontaineroutside && this.canvascontaineroutside.current && onKeyUp) {
|
|
3586
|
+
if (event.code === 'Escape') {
|
|
3587
|
+
this.canvascontaineroutside.current.focus();
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
}, {
|
|
3592
|
+
key: "_documentKeyDown",
|
|
3593
|
+
value: function _documentKeyDown(event) {
|
|
3594
|
+
if (this._isFocussed) {
|
|
3595
|
+
var onKeyDown = this.props.onKeyDown;
|
|
3596
|
+
if (onKeyDown) {
|
|
3597
|
+
onKeyDown(event);
|
|
3598
|
+
}
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
}, {
|
|
3602
|
+
key: "_handleWindowResize",
|
|
3603
|
+
value: function _handleWindowResize() {
|
|
3604
|
+
this.resize();
|
|
3605
|
+
}
|
|
3606
|
+
}, {
|
|
3607
|
+
key: "startLoop",
|
|
3608
|
+
value: function startLoop() {
|
|
3609
|
+
var onRenderCanvas = this.props.onRenderCanvas;
|
|
3610
|
+
if (this.mounted === false || this.loopHasStarted === false) {
|
|
3611
|
+
return;
|
|
3612
|
+
}
|
|
3613
|
+
if (this.canvas) {
|
|
3614
|
+
onRenderCanvas(this.ctx, this.currentWidth, this.currentHeight, this.canvas);
|
|
3615
|
+
}
|
|
3616
|
+
requestAnimationFrame(this.startLoop);
|
|
3617
|
+
}
|
|
3618
|
+
}, {
|
|
3619
|
+
key: "updateCanvas",
|
|
3620
|
+
value: function updateCanvas() {
|
|
3621
|
+
if (!this.canvas) {
|
|
3622
|
+
return;
|
|
3623
|
+
}
|
|
3624
|
+
var _this$props4 = this.props,
|
|
3625
|
+
onRenderCanvas = _this$props4.onRenderCanvas,
|
|
3626
|
+
loop = _this$props4.loop;
|
|
3627
|
+
this.ctx = this.canvas.getContext('2d');
|
|
3628
|
+
if (!this.ctx) {
|
|
3629
|
+
return;
|
|
3630
|
+
}
|
|
3631
|
+
if (this.ctx.canvas.height !== this.currentHeight) {
|
|
3632
|
+
this.ctx.canvas.height = this.currentHeight;
|
|
3633
|
+
}
|
|
3634
|
+
if (this.ctx.canvas.width !== this.currentWidth) {
|
|
3635
|
+
this.ctx.canvas.width = this.currentWidth;
|
|
3636
|
+
}
|
|
3637
|
+
if (loop !== true) {
|
|
3638
|
+
this.loopHasStarted = false;
|
|
3639
|
+
onRenderCanvas(this.ctx, this.currentWidth, this.currentHeight, this.canvas);
|
|
3640
|
+
} else if (this.loopHasStarted === false) {
|
|
3641
|
+
this.loopHasStarted = true;
|
|
3642
|
+
this.startLoop();
|
|
3643
|
+
}
|
|
3644
|
+
}
|
|
3645
|
+
}, {
|
|
3646
|
+
key: "resize",
|
|
3647
|
+
value: function resize() {
|
|
3648
|
+
var canvascontainer = this.canvascontainer,
|
|
3649
|
+
resizeCallback = this.props.resizeCallback;
|
|
3650
|
+
if (canvascontainer && canvascontainer.current) {
|
|
3651
|
+
var newWidth = canvascontainer.current.clientWidth;
|
|
3652
|
+
var newHeight = canvascontainer.current.clientHeight;
|
|
3653
|
+
if (newWidth !== undefined && newHeight !== undefined && (this.currentWidth !== newWidth || this.currentHeight !== newHeight)) {
|
|
3654
|
+
this.currentWidth = newWidth;
|
|
3655
|
+
this.currentHeight = newHeight;
|
|
3656
|
+
this.updateCanvas();
|
|
3657
|
+
resizeCallback && resizeCallback(newWidth);
|
|
3658
|
+
}
|
|
3659
|
+
}
|
|
3660
|
+
}
|
|
3661
|
+
}, {
|
|
3662
|
+
key: "render",
|
|
3663
|
+
value: function render() {
|
|
3664
|
+
var _this4 = this;
|
|
3665
|
+
this.updateCanvas();
|
|
3666
|
+
this._handleWindowResize();
|
|
3667
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
3668
|
+
role: "button",
|
|
3669
|
+
ref: this.canvascontaineroutside,
|
|
3670
|
+
tabIndex: 0,
|
|
3671
|
+
onFocus: this.onFocus,
|
|
3672
|
+
onBlur: this.onBlur,
|
|
3673
|
+
style: {
|
|
3674
|
+
height: '100%',
|
|
3675
|
+
width: '100%',
|
|
3676
|
+
border: 'none',
|
|
3677
|
+
display: 'block',
|
|
3678
|
+
overflow: 'hidden'
|
|
3679
|
+
}
|
|
3680
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
3681
|
+
ref: this.canvascontainer,
|
|
3682
|
+
style: {
|
|
3683
|
+
minWidth: 'inherit',
|
|
3684
|
+
minHeight: 'inherit',
|
|
3685
|
+
width: 'inherit',
|
|
3686
|
+
height: 'inherit',
|
|
3687
|
+
overflow: 'hidden',
|
|
3688
|
+
display: 'block',
|
|
3689
|
+
border: 'none'
|
|
3690
|
+
},
|
|
3691
|
+
"data-testid": "canvas-container"
|
|
3692
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
3693
|
+
style: {
|
|
3694
|
+
overflow: 'visible',
|
|
3695
|
+
width: 0,
|
|
3696
|
+
height: 0
|
|
3697
|
+
},
|
|
3698
|
+
role: "presentation",
|
|
3699
|
+
"aria-label": "canvas"
|
|
3700
|
+
}, /*#__PURE__*/React__default.createElement("canvas", {
|
|
3701
|
+
ref: function ref(canvas) {
|
|
3702
|
+
_this4.canvas = canvas;
|
|
3703
|
+
}
|
|
3704
|
+
}))));
|
|
3705
|
+
}
|
|
3706
|
+
}]);
|
|
3707
|
+
return CanvasComponent;
|
|
3708
|
+
}(Component);
|
|
3709
|
+
CanvasComponent.defaultProps = {
|
|
3710
|
+
onRenderCanvas: function onRenderCanvas() {
|
|
3711
|
+
/* intentionally left blank */
|
|
3712
|
+
},
|
|
3713
|
+
onCanvasClick: function onCanvasClick() {
|
|
3714
|
+
/* intentionally left blank */
|
|
3715
|
+
},
|
|
3716
|
+
onMouseMove: function onMouseMove() {
|
|
3717
|
+
/* intentionally left blank */
|
|
3718
|
+
},
|
|
3719
|
+
onMouseUp: function onMouseUp() {
|
|
3720
|
+
/* intentionally left blank */
|
|
3721
|
+
},
|
|
3722
|
+
onMouseDown: function onMouseDown() {
|
|
3723
|
+
/* intentionally left blank */
|
|
3724
|
+
},
|
|
3725
|
+
onTouchStart: function onTouchStart() {
|
|
3726
|
+
/* intentionally left blank */
|
|
3727
|
+
},
|
|
3728
|
+
onTouchEnd: function onTouchEnd() {
|
|
3729
|
+
/* intentionally left blank */
|
|
3730
|
+
},
|
|
3731
|
+
onTouchMove: function onTouchMove() {
|
|
3732
|
+
/* intentionally left blank */
|
|
3733
|
+
},
|
|
3734
|
+
onWheel: function onWheel() {
|
|
3735
|
+
/* intentionally left blank */
|
|
3736
|
+
}
|
|
3737
|
+
};
|
|
3738
|
+
|
|
3326
3739
|
/* *
|
|
3327
3740
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3328
3741
|
* you may not use this file except in compliance with the License.
|
|
@@ -3927,33 +4340,6 @@ var createToolkitMockStoreWithEggs = function createToolkitMockStoreWithEggs(sto
|
|
|
3927
4340
|
return store;
|
|
3928
4341
|
};
|
|
3929
4342
|
|
|
3930
|
-
/* *
|
|
3931
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3932
|
-
* you may not use this file except in compliance with the License.
|
|
3933
|
-
* You may obtain a copy of the License at
|
|
3934
|
-
*
|
|
3935
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3936
|
-
*
|
|
3937
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
3938
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3939
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3940
|
-
* See the License for the specific language governing permissions and
|
|
3941
|
-
* limitations under the License.
|
|
3942
|
-
*
|
|
3943
|
-
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
3944
|
-
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
3945
|
-
* */
|
|
3946
|
-
// TODO: Move to related component when doing this user story: https://gitlab.com/opengeoweb/geoweb-assets/-/issues/2955
|
|
3947
|
-
var getHeight = function getHeight(element) {
|
|
3948
|
-
if (!element) {
|
|
3949
|
-
return null;
|
|
3950
|
-
}
|
|
3951
|
-
var style = getComputedStyle(element);
|
|
3952
|
-
var marginTop = style.marginTop ? parseInt(style.marginTop, 10) : 0;
|
|
3953
|
-
var marginBottom = style.marginTop ? parseInt(style.marginBottom, 10) : 0;
|
|
3954
|
-
return element.offsetHeight + marginTop + marginBottom;
|
|
3955
|
-
};
|
|
3956
|
-
|
|
3957
4343
|
/* *
|
|
3958
4344
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3959
4345
|
* you may not use this file except in compliance with the License.
|
|
@@ -4012,4 +4398,253 @@ var RenderCounter = /*#__PURE__*/function () {
|
|
|
4012
4398
|
}();
|
|
4013
4399
|
var renderCounter = new RenderCounter();
|
|
4014
4400
|
|
|
4015
|
-
|
|
4401
|
+
/* *
|
|
4402
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4403
|
+
* you may not use this file except in compliance with the License.
|
|
4404
|
+
* You may obtain a copy of the License at
|
|
4405
|
+
*
|
|
4406
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4407
|
+
*
|
|
4408
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4409
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4410
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4411
|
+
* See the License for the specific language governing permissions and
|
|
4412
|
+
* limitations under the License.
|
|
4413
|
+
*
|
|
4414
|
+
* Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
4415
|
+
* Copyright 2024 - Finnish Meteorological Institute (FMI)
|
|
4416
|
+
* */
|
|
4417
|
+
/**
|
|
4418
|
+
* This class should NEVER be initialized with new Metronome(). Use the
|
|
4419
|
+
* exported variable. To reset the metronome use unregisterAllTimers()
|
|
4420
|
+
* to remove all existing timers followed by init() to initialize the
|
|
4421
|
+
* ticks.
|
|
4422
|
+
*/
|
|
4423
|
+
var Metronome = /*#__PURE__*/function () {
|
|
4424
|
+
function Metronome() {
|
|
4425
|
+
_classCallCheck(this, Metronome);
|
|
4426
|
+
this.tickId = 0;
|
|
4427
|
+
this.step = this.step.bind(this);
|
|
4428
|
+
this.isPaused = this.isPaused.bind(this);
|
|
4429
|
+
this.continueTimer = this.continueTimer.bind(this);
|
|
4430
|
+
this.pauseTimer = this.pauseTimer.bind(this);
|
|
4431
|
+
this.toggleTimer = this.toggleTimer.bind(this);
|
|
4432
|
+
this.init = this.init.bind(this);
|
|
4433
|
+
this.unregisterAllTimers = this.unregisterAllTimers.bind(this);
|
|
4434
|
+
this.setSpeed = this.setSpeed.bind(this);
|
|
4435
|
+
this.interval = null;
|
|
4436
|
+
this.init();
|
|
4437
|
+
this.handleTimerTicks = null;
|
|
4438
|
+
this.timers = [];
|
|
4439
|
+
}
|
|
4440
|
+
_createClass(Metronome, [{
|
|
4441
|
+
key: "init",
|
|
4442
|
+
value: function init() {
|
|
4443
|
+
if (this.interval != null) {
|
|
4444
|
+
clearInterval(this.interval);
|
|
4445
|
+
}
|
|
4446
|
+
this.interval = setInterval(this.step, 10);
|
|
4447
|
+
}
|
|
4448
|
+
}, {
|
|
4449
|
+
key: "unregisterAllTimers",
|
|
4450
|
+
value: function unregisterAllTimers() {
|
|
4451
|
+
this.timers.length = 0;
|
|
4452
|
+
}
|
|
4453
|
+
}, {
|
|
4454
|
+
key: "step",
|
|
4455
|
+
value: function step() {
|
|
4456
|
+
var _this = this;
|
|
4457
|
+
this.tickId += 1;
|
|
4458
|
+
var triggeredTimerIds = [];
|
|
4459
|
+
this.timers.forEach(function (timer) {
|
|
4460
|
+
// Delay in x10 ms
|
|
4461
|
+
var delay = 100 / timer.hertz;
|
|
4462
|
+
// Get nearest multiple of delay
|
|
4463
|
+
var nearestDelay = delay * Math.floor((_this.tickId + delay / 2) / delay);
|
|
4464
|
+
var distanceToDelay = _this.tickId - nearestDelay;
|
|
4465
|
+
if (Math.abs(distanceToDelay) < 0.5 || distanceToDelay === -0.5) {
|
|
4466
|
+
if (!timer.isPaused) {
|
|
4467
|
+
timer.timerFunc && timer.timerFunc(timer.timerId, _this.tickId);
|
|
4468
|
+
triggeredTimerIds.push(timer.timerId);
|
|
4469
|
+
}
|
|
4470
|
+
}
|
|
4471
|
+
});
|
|
4472
|
+
// Trigger the handleTimerTicks function with all collected timerIds
|
|
4473
|
+
if (triggeredTimerIds.length > 0) {
|
|
4474
|
+
this.handleTimerTicks && this.handleTimerTicks(triggeredTimerIds);
|
|
4475
|
+
}
|
|
4476
|
+
}
|
|
4477
|
+
/**
|
|
4478
|
+
* Multiple timers with varying frequencies can be made at the same
|
|
4479
|
+
* time however each timerId must be unique. If you attempt to create
|
|
4480
|
+
* two timers with the same timerId, the second will silently be ignored.
|
|
4481
|
+
*
|
|
4482
|
+
* @param timerFunc The function to be executed at the given hertz frequency
|
|
4483
|
+
* @param hertz Frequency of the timer given in hertz
|
|
4484
|
+
* @param timerId Id of the timer
|
|
4485
|
+
* @returns Timer or nothing if no timer was created
|
|
4486
|
+
*/
|
|
4487
|
+
}, {
|
|
4488
|
+
key: "register",
|
|
4489
|
+
value: function register(timerFunc, hertz, timerId) {
|
|
4490
|
+
var existingTimer = this.timers.find(function (timer) {
|
|
4491
|
+
return timer.timerId === timerId;
|
|
4492
|
+
});
|
|
4493
|
+
if (existingTimer) {
|
|
4494
|
+
existingTimer.hertz = hertz;
|
|
4495
|
+
existingTimer.timerFunc = timerFunc;
|
|
4496
|
+
return existingTimer;
|
|
4497
|
+
}
|
|
4498
|
+
this.timers.push({
|
|
4499
|
+
timerFunc: timerFunc,
|
|
4500
|
+
hertz: hertz,
|
|
4501
|
+
timerId: timerId,
|
|
4502
|
+
isPaused: false
|
|
4503
|
+
});
|
|
4504
|
+
return this.timers.at(-1);
|
|
4505
|
+
}
|
|
4506
|
+
/**
|
|
4507
|
+
* Unregistering a timer completely removes it, if you want to pause a
|
|
4508
|
+
* timer, then use pauseTimer()
|
|
4509
|
+
*
|
|
4510
|
+
* @param timerId Id of the timer
|
|
4511
|
+
*/
|
|
4512
|
+
}, {
|
|
4513
|
+
key: "unregister",
|
|
4514
|
+
value: function unregister(timerId) {
|
|
4515
|
+
var indexToRemove = this.timers.findIndex(function (timer) {
|
|
4516
|
+
return timer.timerId === timerId;
|
|
4517
|
+
});
|
|
4518
|
+
if (indexToRemove > -1) {
|
|
4519
|
+
this.timers.splice(indexToRemove, 1);
|
|
4520
|
+
}
|
|
4521
|
+
}
|
|
4522
|
+
/**
|
|
4523
|
+
* Checks if a timer is paused
|
|
4524
|
+
*
|
|
4525
|
+
* @param timerId Id of the timer
|
|
4526
|
+
* @returns true if the timer is paused, false if it is running
|
|
4527
|
+
*/
|
|
4528
|
+
}, {
|
|
4529
|
+
key: "isPaused",
|
|
4530
|
+
value: function isPaused(timerId) {
|
|
4531
|
+
var _iterator = _createForOfIteratorHelper(this.timers),
|
|
4532
|
+
_step;
|
|
4533
|
+
try {
|
|
4534
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
4535
|
+
var timer = _step.value;
|
|
4536
|
+
if (timer.timerId === timerId && timer.isPaused) {
|
|
4537
|
+
return true;
|
|
4538
|
+
}
|
|
4539
|
+
}
|
|
4540
|
+
} catch (err) {
|
|
4541
|
+
_iterator.e(err);
|
|
4542
|
+
} finally {
|
|
4543
|
+
_iterator.f();
|
|
4544
|
+
}
|
|
4545
|
+
return false;
|
|
4546
|
+
}
|
|
4547
|
+
/**
|
|
4548
|
+
* Continues running a timer
|
|
4549
|
+
*
|
|
4550
|
+
* @param timerId Id of the timer
|
|
4551
|
+
*/
|
|
4552
|
+
}, {
|
|
4553
|
+
key: "continueTimer",
|
|
4554
|
+
value: function continueTimer(timerId) {
|
|
4555
|
+
var _iterator2 = _createForOfIteratorHelper(this.timers),
|
|
4556
|
+
_step2;
|
|
4557
|
+
try {
|
|
4558
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
4559
|
+
var timer = _step2.value;
|
|
4560
|
+
if (timer.timerId === timerId) {
|
|
4561
|
+
timer.isPaused = false;
|
|
4562
|
+
break;
|
|
4563
|
+
}
|
|
4564
|
+
}
|
|
4565
|
+
} catch (err) {
|
|
4566
|
+
_iterator2.e(err);
|
|
4567
|
+
} finally {
|
|
4568
|
+
_iterator2.f();
|
|
4569
|
+
}
|
|
4570
|
+
}
|
|
4571
|
+
/**
|
|
4572
|
+
* Pauses a timer
|
|
4573
|
+
*
|
|
4574
|
+
* @param timerId Id of the timer
|
|
4575
|
+
*/
|
|
4576
|
+
}, {
|
|
4577
|
+
key: "pauseTimer",
|
|
4578
|
+
value: function pauseTimer(timerId) {
|
|
4579
|
+
var _iterator3 = _createForOfIteratorHelper(this.timers),
|
|
4580
|
+
_step3;
|
|
4581
|
+
try {
|
|
4582
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
4583
|
+
var timer = _step3.value;
|
|
4584
|
+
if (timer.timerId === timerId) {
|
|
4585
|
+
timer.isPaused = true;
|
|
4586
|
+
break;
|
|
4587
|
+
}
|
|
4588
|
+
}
|
|
4589
|
+
} catch (err) {
|
|
4590
|
+
_iterator3.e(err);
|
|
4591
|
+
} finally {
|
|
4592
|
+
_iterator3.f();
|
|
4593
|
+
}
|
|
4594
|
+
}
|
|
4595
|
+
/**
|
|
4596
|
+
* Toggles a timer to be paused or running. Be careful when asking redux
|
|
4597
|
+
* to toggle a timer, it might toggle twice and therefore do nothing
|
|
4598
|
+
*
|
|
4599
|
+
* @param timerId Id of the timer
|
|
4600
|
+
*/
|
|
4601
|
+
}, {
|
|
4602
|
+
key: "toggleTimer",
|
|
4603
|
+
value: function toggleTimer(timerId) {
|
|
4604
|
+
var _iterator4 = _createForOfIteratorHelper(this.timers),
|
|
4605
|
+
_step4;
|
|
4606
|
+
try {
|
|
4607
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
4608
|
+
var timer = _step4.value;
|
|
4609
|
+
if (timer.timerId === timerId) {
|
|
4610
|
+
timer.isPaused = !timer.isPaused;
|
|
4611
|
+
break;
|
|
4612
|
+
}
|
|
4613
|
+
}
|
|
4614
|
+
} catch (err) {
|
|
4615
|
+
_iterator4.e(err);
|
|
4616
|
+
} finally {
|
|
4617
|
+
_iterator4.f();
|
|
4618
|
+
}
|
|
4619
|
+
}
|
|
4620
|
+
/**
|
|
4621
|
+
* Sets the speed of a timer to a new frequency given in hertz
|
|
4622
|
+
*
|
|
4623
|
+
* @param timerId Id of the timer
|
|
4624
|
+
* @param hertz Frequency of the timer given in hertz
|
|
4625
|
+
*/
|
|
4626
|
+
}, {
|
|
4627
|
+
key: "setSpeed",
|
|
4628
|
+
value: function setSpeed(timerId, hertz) {
|
|
4629
|
+
var _iterator5 = _createForOfIteratorHelper(this.timers),
|
|
4630
|
+
_step5;
|
|
4631
|
+
try {
|
|
4632
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
4633
|
+
var timer = _step5.value;
|
|
4634
|
+
if (timer.timerId === timerId) {
|
|
4635
|
+
timer.hertz = hertz;
|
|
4636
|
+
break;
|
|
4637
|
+
}
|
|
4638
|
+
}
|
|
4639
|
+
} catch (err) {
|
|
4640
|
+
_iterator5.e(err);
|
|
4641
|
+
} finally {
|
|
4642
|
+
_iterator5.f();
|
|
4643
|
+
}
|
|
4644
|
+
}
|
|
4645
|
+
}]);
|
|
4646
|
+
return Metronome;
|
|
4647
|
+
}();
|
|
4648
|
+
var metronome = new Metronome();
|
|
4649
|
+
|
|
4650
|
+
export { AlertBanner, AlertIcon, AppHeader, AppLayout, Avatar, BUTTON_TITLE, CanvasComponent, ConfirmationDialog, ConfirmationServiceProvider, CustomAccordion, CustomDialog, CustomIconButton, CustomSlider, CustomToggleButton, CustomTooltip, DEFAULT_ERROR_MESSAGE, DraggableComponent$1 as Draggable, ErrorBoundary, LastUpdateTime, ResizeComponent as Resizable, SearchField, SearchFieldButton, SearchHighlight, StatusTag, SwitchButton, ToggleMenu, ToolContainer, DraggableComponent as ToolContainerDraggable, ToolFooter, ToolHeader, TooltipSelect, UserMenu, UserMenuItemCheatSheet, MenuItemTheme as UserMenuItemTheme, adjustPosition, calculateDialogSizeAndPosition, calculateStartSize, createMockStoreWithEggs, createMockStoreWithEggsAndMiddleware, createToolkitMockStoreWithEggs, index as dateUtils, defaultDelay, getAxiosErrorMessage, getAxiosWarningMessage, getErrorMessage, getInitials, getLastUpdateTitle, getPosition, getWarningMessage, isAxiosError, metronome, pollingIntervalTimeout, renderCounter, showPrompt, sliderHeaderStyle, tooltipContainerStyles, useConfirmationDialog, useControlledTooltip, useDialogActions, useIsMounted, useMakeSureContainerStaysInsideWindow, usePoller, usePreventBrowserClose, usePrevious, useUserMenu, withEggs };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeoweb/shared",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.10.1",
|
|
4
4
|
"description": "GeoWeb shared library with shared components and utils for the opengeoweb project",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"url": "git@gitlab.com:opengeoweb/opengeoweb.git"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@mui/material": "5.
|
|
11
|
+
"@mui/material": "~5.15.11",
|
|
12
12
|
"@opengeoweb/theme": "*",
|
|
13
13
|
"react-draggable": "^4.4.6",
|
|
14
14
|
"re-resizable": "^6.9.11",
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
interface CanvasComponentProps {
|
|
3
|
+
onRenderCanvas: (ctx: CanvasRenderingContext2D, width: number, height: number, canvas: HTMLCanvasElement) => void;
|
|
4
|
+
onCanvasClick?: (x: number, y: number, width: number, height: number) => void;
|
|
5
|
+
onMouseMove?: (x: number, y: number, event: MouseEvent, width: number) => void;
|
|
6
|
+
onMouseUp?: (x: number) => void;
|
|
7
|
+
onMouseDown?: (x: number, y: number, width: number) => void;
|
|
8
|
+
onTouchStart?: (event: TouchEvent, width: number) => void;
|
|
9
|
+
onTouchEnd?: () => void;
|
|
10
|
+
onTouchMove?: (event: TouchEvent, width: number) => void;
|
|
11
|
+
onKeyUp?: (event: KeyboardEvent) => void;
|
|
12
|
+
onKeyDown?: (event: KeyboardEvent) => void;
|
|
13
|
+
isFocussed?: (isFocussed: boolean) => void;
|
|
14
|
+
onWheel?: ({ event, deltaY, deltaX, canvasWidth, mouseX, }: {
|
|
15
|
+
event: WheelEvent;
|
|
16
|
+
deltaY: number;
|
|
17
|
+
deltaX: number;
|
|
18
|
+
canvasWidth: number;
|
|
19
|
+
mouseX: number;
|
|
20
|
+
}) => void;
|
|
21
|
+
loop?: boolean;
|
|
22
|
+
redrawInterval?: number;
|
|
23
|
+
resizeCallback?: (newWidth: number) => void;
|
|
24
|
+
children?: React.ReactNode;
|
|
25
|
+
}
|
|
26
|
+
export declare class CanvasComponent extends Component<CanvasComponentProps> {
|
|
27
|
+
canvas: HTMLCanvasElement | null;
|
|
28
|
+
ctx: CanvasRenderingContext2D | null;
|
|
29
|
+
currentWidth: number;
|
|
30
|
+
currentHeight: number;
|
|
31
|
+
canvascontaineroutside: React.RefObject<HTMLDivElement> | null;
|
|
32
|
+
canvascontainer: React.RefObject<HTMLDivElement> | null;
|
|
33
|
+
timer: ReturnType<typeof setTimeout> | null;
|
|
34
|
+
redrawTimer: ReturnType<typeof setTimeout> | null;
|
|
35
|
+
loopHasStarted: boolean;
|
|
36
|
+
mounted: boolean;
|
|
37
|
+
static defaultProps: {
|
|
38
|
+
onRenderCanvas: () => void;
|
|
39
|
+
onCanvasClick: () => void;
|
|
40
|
+
onMouseMove: () => void;
|
|
41
|
+
onMouseUp: () => void;
|
|
42
|
+
onMouseDown: () => void;
|
|
43
|
+
onTouchStart: () => void;
|
|
44
|
+
onTouchEnd: () => void;
|
|
45
|
+
onTouchMove: () => void;
|
|
46
|
+
onWheel: () => void;
|
|
47
|
+
};
|
|
48
|
+
private _isFocussed;
|
|
49
|
+
constructor(props: CanvasComponentProps);
|
|
50
|
+
componentDidMount(): void;
|
|
51
|
+
shouldComponentUpdate(): boolean;
|
|
52
|
+
componentWillUnmount(): void;
|
|
53
|
+
handleMouseMoveEvent(event: MouseEvent): void;
|
|
54
|
+
handleMouseUpEvent(event: MouseEvent): void;
|
|
55
|
+
handleMouseDownEvent(event: MouseEvent): void;
|
|
56
|
+
handleTouchStartEvent(event: TouchEvent): void;
|
|
57
|
+
handleTouchEndEvent(): void;
|
|
58
|
+
handleTouchMoveEvent(event: TouchEvent): void;
|
|
59
|
+
handleClickEvent(event: MouseEvent): void;
|
|
60
|
+
handleWheelEvent(event: WheelEvent): void;
|
|
61
|
+
onFocus(): void;
|
|
62
|
+
onBlur(): void;
|
|
63
|
+
onKeyUp(event: KeyboardEvent): void;
|
|
64
|
+
_documentKeyDown(event: KeyboardEvent): void;
|
|
65
|
+
_handleWindowResize(): void;
|
|
66
|
+
startLoop(): void;
|
|
67
|
+
updateCanvas(): void;
|
|
68
|
+
resize(): void;
|
|
69
|
+
render(): React.ReactElement;
|
|
70
|
+
}
|
|
71
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CanvasComponent';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { BaseSelectProps, SelectVariants } from '@mui/material';
|
|
3
3
|
interface ListELement {
|
|
4
4
|
value: string;
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
type TooltipSelectProps = BaseSelectProps & {
|
|
7
7
|
tooltip: string;
|
|
8
8
|
list?: ListELement[];
|
|
9
9
|
currentIndex?: number;
|
|
@@ -12,6 +12,7 @@ interface TooltipSelectProps extends SelectProps {
|
|
|
12
12
|
isEnabled?: boolean;
|
|
13
13
|
noStyling?: boolean;
|
|
14
14
|
hasBackgroundColor?: boolean;
|
|
15
|
-
|
|
15
|
+
variant?: SelectVariants;
|
|
16
|
+
};
|
|
16
17
|
export declare const TooltipSelect: React.FC<TooltipSelectProps>;
|
|
17
18
|
export {};
|
package/src/lib/utils/index.d.ts
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
type TimerFunction = (timerId: string, tickId: number) => void;
|
|
3
|
+
interface Timer {
|
|
4
|
+
timerFunc: TimerFunction | null;
|
|
5
|
+
hertz: number;
|
|
6
|
+
timerId: string;
|
|
7
|
+
isPaused: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* This class should NEVER be initialized with new Metronome(). Use the
|
|
11
|
+
* exported variable. To reset the metronome use unregisterAllTimers()
|
|
12
|
+
* to remove all existing timers followed by init() to initialize the
|
|
13
|
+
* ticks.
|
|
14
|
+
*/
|
|
15
|
+
declare class Metronome {
|
|
16
|
+
tickId: number;
|
|
17
|
+
timers: Timer[];
|
|
18
|
+
interval: NodeJS.Timeout | null;
|
|
19
|
+
handleTimerTicks: ((timerIds: string[]) => void) | null;
|
|
20
|
+
constructor();
|
|
21
|
+
init(): void;
|
|
22
|
+
unregisterAllTimers(): void;
|
|
23
|
+
step(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Multiple timers with varying frequencies can be made at the same
|
|
26
|
+
* time however each timerId must be unique. If you attempt to create
|
|
27
|
+
* two timers with the same timerId, the second will silently be ignored.
|
|
28
|
+
*
|
|
29
|
+
* @param timerFunc The function to be executed at the given hertz frequency
|
|
30
|
+
* @param hertz Frequency of the timer given in hertz
|
|
31
|
+
* @param timerId Id of the timer
|
|
32
|
+
* @returns Timer or nothing if no timer was created
|
|
33
|
+
*/
|
|
34
|
+
register(timerFunc: TimerFunction | null, hertz: number, timerId: string): Timer | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Unregistering a timer completely removes it, if you want to pause a
|
|
37
|
+
* timer, then use pauseTimer()
|
|
38
|
+
*
|
|
39
|
+
* @param timerId Id of the timer
|
|
40
|
+
*/
|
|
41
|
+
unregister(timerId: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Checks if a timer is paused
|
|
44
|
+
*
|
|
45
|
+
* @param timerId Id of the timer
|
|
46
|
+
* @returns true if the timer is paused, false if it is running
|
|
47
|
+
*/
|
|
48
|
+
isPaused(timerId: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Continues running a timer
|
|
51
|
+
*
|
|
52
|
+
* @param timerId Id of the timer
|
|
53
|
+
*/
|
|
54
|
+
continueTimer(timerId: string): void;
|
|
55
|
+
/**
|
|
56
|
+
* Pauses a timer
|
|
57
|
+
*
|
|
58
|
+
* @param timerId Id of the timer
|
|
59
|
+
*/
|
|
60
|
+
pauseTimer(timerId: string): void;
|
|
61
|
+
/**
|
|
62
|
+
* Toggles a timer to be paused or running. Be careful when asking redux
|
|
63
|
+
* to toggle a timer, it might toggle twice and therefore do nothing
|
|
64
|
+
*
|
|
65
|
+
* @param timerId Id of the timer
|
|
66
|
+
*/
|
|
67
|
+
toggleTimer(timerId: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* Sets the speed of a timer to a new frequency given in hertz
|
|
70
|
+
*
|
|
71
|
+
* @param timerId Id of the timer
|
|
72
|
+
* @param hertz Frequency of the timer given in hertz
|
|
73
|
+
*/
|
|
74
|
+
setSpeed(timerId: string, hertz: number): void;
|
|
75
|
+
}
|
|
76
|
+
declare const metronome: Metronome;
|
|
77
|
+
export { metronome };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getHeight: (element: HTMLDivElement) => number | null;
|
|
File without changes
|