@centreon/ui 26.5.10 → 26.5.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "26.5.10",
3
+ "version": "26.5.11",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "update:deps": "pnpx npm-check-updates -i --format group",
@@ -13,7 +13,6 @@ import {
13
13
 
14
14
  import ExpandableContainer from '../components/ExpandableContainer';
15
15
  import type { Parameters } from '../components/ExpandableContainer/models';
16
- import LoadingSkeleton from '../LoadingSkeleton';
17
16
  import { useMemoComponent, useViewportIntersection } from '../utils';
18
17
  import { isResizingItemAtom } from './atoms';
19
18
  import { useDashboardItemStyles } from './Dashboard.styles';
@@ -21,7 +20,10 @@ import { useDashboardItemStyles } from './Dashboard.styles';
21
20
  interface DashboardItemProps {
22
21
  additionalMemoProps?: Array<unknown>;
23
22
  canMove?: boolean;
24
- children: ReactElement;
23
+ children: Array<
24
+ | ReactElement
25
+ | (({ isInViewport }: { isInViewport: boolean }) => ReactElement)
26
+ >;
25
27
  className?: string;
26
28
  disablePadding?: boolean;
27
29
  header?: ReactElement | ((params: Parameters) => ReactElement);
@@ -139,15 +141,10 @@ const Item = ({
139
141
  !disablePadding && classes.widgetPadding
140
142
  )}
141
143
  >
142
- {!isInViewport ? (
143
- <LoadingSkeleton
144
- animation={false}
145
- data-widget-skeleton={id}
146
- height="100%"
147
- width="100%"
148
- />
149
- ) : (
150
- children
144
+ {children.map((child) =>
145
+ typeof child === 'function'
146
+ ? child({ isInViewport })
147
+ : child
151
148
  )}
152
149
  </div>
153
150
  </Card>
@@ -35,6 +35,7 @@ interface UseMetricsQueryProps {
35
35
  timePeriodType: number;
36
36
  };
37
37
  isEnabled?: boolean;
38
+ enforceIsEnabled?: boolean;
38
39
  }
39
40
 
40
41
  interface UseMetricsQueryState {
@@ -101,7 +102,8 @@ const useGraphQuery = ({
101
102
  refreshCount,
102
103
  bypassQueryParams = false,
103
104
  prefix,
104
- isEnabled = true
105
+ isEnabled = true,
106
+ enforceIsEnabled
105
107
  }: UseMetricsQueryProps): UseMetricsQueryState => {
106
108
  const timePeriodToUse = equals(timePeriod?.timePeriodType, -1)
107
109
  ? {
@@ -159,9 +161,10 @@ const useGraphQuery = ({
159
161
  ],
160
162
  queryOptions: {
161
163
  enabled:
162
- areResourcesFullfilled(resources) &&
163
- !isEmpty(definedMetrics) &&
164
- isEnabled,
164
+ enforceIsEnabled ??
165
+ (areResourcesFullfilled(resources) &&
166
+ !isEmpty(definedMetrics) &&
167
+ isEnabled),
165
168
  refetchInterval: refreshInterval,
166
169
  suspense: false
167
170
  },
@@ -32,10 +32,9 @@ export const useViewportIntersection = (
32
32
  observer.current.disconnect();
33
33
  }
34
34
 
35
- observer.current = new window.IntersectionObserver(
36
- ([newEntry]) => setEntry(newEntry),
37
- options
38
- );
35
+ observer.current = new window.IntersectionObserver(([newEntry]) => {
36
+ setEntry(newEntry);
37
+ }, options);
39
38
 
40
39
  if (element) {
41
40
  observer.current.observe(element);