@opengeoweb/shared 9.4.1 → 9.5.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
@@ -4752,4 +4752,62 @@ var getHeight = function getHeight(element) {
4752
4752
  return element.offsetHeight + marginTop + marginBottom;
4753
4753
  };
4754
4754
 
4755
- export { AlertBanner, AlertIcon, AppHeader, AppLayout, Avatar, ConfirmationDialog, ConfirmationServiceProvider, CustomAccordion, CustomDialog, CustomIconButton, CustomSlider, CustomToggleButton, CustomTooltip, DEFAULT_ERROR_MESSAGE, DraggableComponent$1 as Draggable, ErrorBoundary, 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, getHeight, getInitials, getPosition, getWarningMessage, isAxiosError, showPrompt, sliderHeaderStyle, tooltipContainerStyles, useConfirmationDialog, useControlledTooltip, useDialogActions, useIsMounted, useMakeSureContainerStaysInsideWindow, usePoller, usePreventBrowserClose, usePrevious, useUserMenu, withEggs };
4755
+ /* *
4756
+ * Licensed under the Apache License, Version 2.0 (the "License");
4757
+ * you may not use this file except in compliance with the License.
4758
+ * You may obtain a copy of the License at
4759
+ *
4760
+ * http://www.apache.org/licenses/LICENSE-2.0
4761
+ *
4762
+ * Unless required by applicable law or agreed to in writing, software
4763
+ * distributed under the License is distributed on an "AS IS" BASIS,
4764
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4765
+ * See the License for the specific language governing permissions and
4766
+ * limitations under the License.
4767
+ *
4768
+ * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4769
+ * Copyright 2024 - Finnish Meteorological Institute (FMI)
4770
+ * */
4771
+ /**
4772
+ * Utility function to keep track of number of renders by a react component
4773
+ *
4774
+ * Usage:
4775
+ * 1) reset all counters to zero by:
4776
+ * renderCounter.reset()
4777
+ * 2) in the render function of the functional component do:
4778
+ * renderCounter.count(<your react functional component>.name);
4779
+ * 3) in the test do:
4780
+ * expect(renderCounter.get(<your react functional component>.name)).toBe(1);
4781
+ *
4782
+ */
4783
+ var RenderCounter = /*#__PURE__*/function () {
4784
+ function RenderCounter() {
4785
+ _classCallCheck(this, RenderCounter);
4786
+ this.numRenders = new Map();
4787
+ }
4788
+ _createClass(RenderCounter, [{
4789
+ key: "reset",
4790
+ value: function reset() {
4791
+ var _this = this;
4792
+ this.numRenders.forEach(function (_value, key) {
4793
+ _this.numRenders.set(key, 0);
4794
+ });
4795
+ }
4796
+ }, {
4797
+ key: "count",
4798
+ value: function count(id) {
4799
+ this.numRenders.set(id, this.get(id) + 1);
4800
+ // Enable next line (for debugging) to track the number of renders per component in the developer console
4801
+ // console.log('numRenders', id, this.get(id));
4802
+ }
4803
+ }, {
4804
+ key: "get",
4805
+ value: function get(id) {
4806
+ return this.numRenders.get(id) || 0;
4807
+ }
4808
+ }]);
4809
+ return RenderCounter;
4810
+ }();
4811
+ var renderCounter = new RenderCounter();
4812
+
4813
+ export { AlertBanner, AlertIcon, AppHeader, AppLayout, Avatar, ConfirmationDialog, ConfirmationServiceProvider, CustomAccordion, CustomDialog, CustomIconButton, CustomSlider, CustomToggleButton, CustomTooltip, DEFAULT_ERROR_MESSAGE, DraggableComponent$1 as Draggable, ErrorBoundary, 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, getHeight, getInitials, getPosition, getWarningMessage, isAxiosError, 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.4.1",
3
+ "version": "9.5.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": {
@@ -2,3 +2,4 @@ export * from './axiosErrorUtils';
2
2
  export * as dateUtils from './dateUtils';
3
3
  export * from './reduxTestUtils';
4
4
  export * from './layoutUtils';
5
+ export { renderCounter } from './renderCounter';
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Utility function to keep track of number of renders by a react component
3
+ *
4
+ * Usage:
5
+ * 1) reset all counters to zero by:
6
+ * renderCounter.reset()
7
+ * 2) in the render function of the functional component do:
8
+ * renderCounter.count(<your react functional component>.name);
9
+ * 3) in the test do:
10
+ * expect(renderCounter.get(<your react functional component>.name)).toBe(1);
11
+ *
12
+ */
13
+ declare class RenderCounter {
14
+ private numRenders;
15
+ constructor();
16
+ reset(): void;
17
+ count(id: string): void;
18
+ get(id: string): number;
19
+ }
20
+ export declare const renderCounter: RenderCounter;
21
+ export {};
@@ -0,0 +1 @@
1
+ export {};