@opengeoweb/shared 9.10.1 → 9.11.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/index.esm.js CHANGED
@@ -259,57 +259,6 @@ 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
- }
313
262
 
314
263
  var defaultDelay = 1000;
315
264
  var useControlledTooltip = function useControlledTooltip() {
@@ -3806,6 +3755,7 @@ var getWarningMessage = function getWarningMessage(error) {
3806
3755
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3807
3756
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
3808
3757
  * */
3758
+ var DATE_FORMAT_UTC = "yyyy-MM-dd'T'HH:mm:ss'Z'";
3809
3759
  /**
3810
3760
  * Parsing date strings with geoweb dateUtils:
3811
3761
  *
@@ -3945,7 +3895,7 @@ var setUTCDate = function setUTCDate(inDate) {
3945
3895
  * ``` dateToString(new Date(2022, 10, 12, 15, 30), 'dd MMM yyyy') ```
3946
3896
  */
3947
3897
  var dateToString = function dateToString(inDate) {
3948
- var strFormat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "yyyy-MM-dd'T'HH:mm:ss'Z'";
3898
+ var strFormat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DATE_FORMAT_UTC;
3949
3899
  var utc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
3950
3900
  if (!inDate || !isValid(inDate)) {
3951
3901
  return undefined;
@@ -4131,7 +4081,7 @@ var utc = function utc(dateStr) {
4131
4081
  * @returns {Date} - Date in UTC, undefined when not valid
4132
4082
  */
4133
4083
  var getUtcFromString = function getUtcFromString(dateStr) {
4134
- if (!dateStr) {
4084
+ if (!dateStr || typeof dateStr !== 'string') {
4135
4085
  return undefined;
4136
4086
  }
4137
4087
  if (hasOffset(dateStr)) {
@@ -4207,7 +4157,7 @@ var getNowUtc = function getNowUtc() {
4207
4157
  * @returns {string} - formatted date string
4208
4158
  */
4209
4159
  var getCurrentTimeAsString = function getCurrentTimeAsString() {
4210
- var strFormat = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "yyyy-MM-dd'T'HH:mm:ss'Z'";
4160
+ var strFormat = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DATE_FORMAT_UTC;
4211
4161
  var utc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
4212
4162
  return dateToString(getNowUtc(), strFormat, utc);
4213
4163
  };
@@ -4398,253 +4348,4 @@ var RenderCounter = /*#__PURE__*/function () {
4398
4348
  }();
4399
4349
  var renderCounter = new RenderCounter();
4400
4350
 
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 };
4351
+ 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, 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.10.1",
3
+ "version": "9.11.0",
4
4
  "description": "GeoWeb shared library with shared components and utils for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -6,7 +6,7 @@ export declare const getPosition: (menuPosition: MenuPosition) => {
6
6
  anchorOrigin: PopoverOrigin;
7
7
  transformOrigin: PopoverOrigin;
8
8
  };
9
- interface MenuItemType {
9
+ export interface MenuItemType {
10
10
  text: string;
11
11
  action: (event: React.MouseEvent) => void;
12
12
  icon?: React.ReactNode;
@@ -2,4 +2,3 @@ export * from './axiosErrorUtils';
2
2
  export * as dateUtils from './dateUtils';
3
3
  export * from './reduxTestUtils';
4
4
  export { renderCounter } from './renderCounter';
5
- export { metronome } from './metronome';
@@ -1,77 +0,0 @@
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 };
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- declare const _default: {
3
- title: string;
4
- };
5
- export default _default;
6
- export declare const MetronomeCanvasPlaygroundDemo: React.FC;
7
- export declare const MetronomeCanvasDemo: React.FC;