@centreon/ui 26.11.9 → 26.11.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.11.9",
3
+ "version": "26.11.11",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "update:deps": "pnpx npm-check-updates -i --format group",
@@ -56,7 +56,7 @@
56
56
  "test/*"
57
57
  ],
58
58
  "devDependencies": {
59
- "@biomejs/biome": "2.3.11",
59
+ "@biomejs/biome": "2.5.14",
60
60
  "@cypress/react": "^9.0.0",
61
61
  "@cypress/webpack-dev-server": "^4.0.1",
62
62
  "@faker-js/faker": "^9.5.1",
@@ -57,7 +57,6 @@ const ConnectedAutocomplete = ({
57
57
  ? [
58
58
  {
59
59
  name: 'name[lk]',
60
- // The field wraps the typed text in `%`.
61
60
  value: searchedValue.slice(1, -1)
62
61
  }
63
62
  ]
@@ -79,4 +79,4 @@ const Annotation = ({
79
79
  };
80
80
 
81
81
  export default Annotation;
82
- export { yMargin, iconSize };
82
+ export { iconSize, yMargin };
@@ -42,11 +42,11 @@ const getCurveFactory = (
42
42
 
43
43
  export {
44
44
  commonTickLabelProps,
45
- margin,
46
- getFillColor,
47
45
  dateFormat,
48
- timeFormat,
49
46
  dateTimeFormat,
47
+ getCurveFactory,
48
+ getFillColor,
49
+ margin,
50
50
  maxLinesDisplayedLegend,
51
- getCurveFactory
51
+ timeFormat
52
52
  };
@@ -5,7 +5,7 @@ import { useMemoComponent } from '@centreon/ui';
5
5
  import type { ReactElement } from 'react';
6
6
 
7
7
  import type { LineChartHeader } from './models';
8
- import { ussHeaderChartStyles } from './useHeaderStyles';
8
+ import { useHeaderChartStyles } from './useHeaderStyles';
9
9
 
10
10
  interface Props {
11
11
  header?: LineChartHeader;
@@ -13,7 +13,7 @@ interface Props {
13
13
  }
14
14
 
15
15
  const Header = ({ title, header }: Props): ReactElement => {
16
- const { classes } = ussHeaderChartStyles();
16
+ const { classes } = useHeaderChartStyles();
17
17
 
18
18
  const displayTitle = header?.displayTitle ?? true;
19
19
 
@@ -1,6 +1,6 @@
1
1
  import { makeStyles } from 'tss-react/mui';
2
2
 
3
- export const ussHeaderChartStyles = makeStyles()({
3
+ export const useHeaderChartStyles = makeStyles()({
4
4
  header: {
5
5
  display: 'grid',
6
6
  gridTemplateColumns: 'auto 1fr auto',
@@ -397,11 +397,14 @@ describe('timeSeries', () => {
397
397
  [null, 'B', 1024, null]
398
398
  ];
399
399
 
400
- it.each(
401
- cases
402
- )('formats the given value to a human readable form according to the given unit and base', (value, unit, base, formattedResult) => {
403
- expect(formatMetricValue({ base, unit, value })).toEqual(formattedResult);
404
- });
400
+ it.each(cases)(
401
+ 'formats the given value to a human readable form according to the given unit and base',
402
+ (value, unit, base, formattedResult) => {
403
+ expect(formatMetricValue({ base, unit, value })).toEqual(
404
+ formattedResult
405
+ );
406
+ }
407
+ );
405
408
  });
406
409
 
407
410
  describe('getSortedStackedLines', () => {
@@ -639,33 +642,31 @@ describe('Format value with unit', () => {
639
642
  });
640
643
 
641
644
  describe('Format the value as human readable', () => {
642
- it.each(humanReadableTestCases)('formats the value with $unit', ({
643
- value,
644
- unit,
645
- expectedResult
646
- }) => {
647
- expect(
648
- formatMetricValueWithUnit({
649
- unit,
650
- value
651
- })
652
- ).toEqual(expectedResult);
653
- });
645
+ it.each(humanReadableTestCases)(
646
+ 'formats the value with $unit',
647
+ ({ value, unit, expectedResult }) => {
648
+ expect(
649
+ formatMetricValueWithUnit({
650
+ unit,
651
+ value
652
+ })
653
+ ).toEqual(expectedResult);
654
+ }
655
+ );
654
656
  });
655
657
 
656
658
  describe('Format the value as raw', () => {
657
- it.each(rawTestCases)('formats the value with $unit', ({
658
- value,
659
- unit,
660
- expectedResult
661
- }) => {
662
- expect(
663
- formatMetricValueWithUnit({
664
- isRaw: true,
665
- unit,
666
- value
667
- })
668
- ).toEqual(expectedResult);
669
- });
659
+ it.each(rawTestCases)(
660
+ 'formats the value with $unit',
661
+ ({ value, unit, expectedResult }) => {
662
+ expect(
663
+ formatMetricValueWithUnit({
664
+ isRaw: true,
665
+ unit,
666
+ value
667
+ })
668
+ ).toEqual(expectedResult);
669
+ }
670
+ );
670
671
  });
671
672
  });
@@ -947,32 +947,32 @@ export const getStackedLinesTimeSeriesPerStackAndUnit = ({
947
947
  };
948
948
 
949
949
  export {
950
- getTimeSeries,
950
+ bisectDate,
951
+ formatMetricValue,
952
+ formatMetricValueWithUnit,
953
+ getDates,
954
+ getInvertedStackedLines,
951
955
  getLineData,
952
- getMin,
956
+ getLineForMetric,
953
957
  getMax,
954
- getTime,
955
958
  getMetrics,
956
- getValueForMetric,
957
- getMetricValuesForUnit,
958
- getUnits,
959
- getDates,
960
- getLineForMetric,
961
959
  getMetricValuesForLines,
962
- getSortedStackedLines,
963
- getTimeSeriesForLines,
964
- getStackedMetricValues,
965
- getInvertedStackedLines,
960
+ getMetricValuesForUnit,
961
+ getMetricWithLatestData,
962
+ getMin,
966
963
  getNotInvertedStackedLines,
967
- hasUnitStackedLines,
968
- getYScale,
969
964
  getScale,
970
- getXScale,
971
- formatMetricValue,
965
+ getSortedStackedLines,
966
+ getStackedMetricValues,
967
+ getTime,
968
+ getTimeSeries,
969
+ getTimeSeriesForLines,
972
970
  getTimeValue,
973
- bisectDate,
974
- getMetricWithLatestData,
975
- formatMetricValueWithUnit,
971
+ getUnits,
972
+ getValueForMetric,
973
+ getXScale,
974
+ getYScale,
975
+ getYScalePerUnit,
976
976
  getYScaleUnit,
977
- getYScalePerUnit
977
+ hasUnitStackedLines
978
978
  };
@@ -113,7 +113,6 @@ const DataCell = ({
113
113
  if (!clickable) {
114
114
  return;
115
115
  }
116
- e.preventDefault();
117
116
  e.stopPropagation();
118
117
  }}
119
118
  {...commonCellProps}
@@ -130,7 +129,6 @@ const DataCell = ({
130
129
  if (!clickable) {
131
130
  return;
132
131
  }
133
- e.preventDefault();
134
132
  e.stopPropagation();
135
133
  }}
136
134
  style={{
@@ -15,6 +15,19 @@ const ButtonColumn = ({ row }: Props): JSX.Element => (
15
15
  <Button size="small">Click to reveal details about {row.name}</Button>
16
16
  );
17
17
 
18
+ const CheckboxColumn = ({ row }: Props): JSX.Element => {
19
+ const [checked, setChecked] = useState(false);
20
+
21
+ return (
22
+ <input
23
+ aria-label={`Toggle ${row.name}`}
24
+ checked={checked}
25
+ onChange={(event) => setChecked(event.target.checked)}
26
+ type="checkbox"
27
+ />
28
+ );
29
+ };
30
+
18
31
  const LargeText = (): JSX.Element => (
19
32
  <Typography sx={{ whiteSpace: 'normal' }}>
20
33
  This is a large text that fills the content
@@ -301,4 +314,36 @@ describe('Listing', () => {
301
314
 
302
315
  cy.makeSnapshot();
303
316
  });
317
+
318
+ it('toggles a checkbox in a clickable column without clicking the row', () => {
319
+ const onRowClick = cy.stub().as('rowClick');
320
+
321
+ cy.mount({
322
+ Component: (
323
+ <div style={{ height: '100vh' }}>
324
+ <Listing
325
+ columns={[
326
+ {
327
+ Component: CheckboxColumn,
328
+ clickable: true,
329
+ id: 'toggle',
330
+ label: 'Toggle',
331
+ type: ColumnType.component
332
+ }
333
+ ]}
334
+ currentPage={1}
335
+ limit={10}
336
+ onRowClick={onRowClick}
337
+ rows={[{ id: 0, name: 'E0' }]}
338
+ totalRows={1}
339
+ />
340
+ </div>
341
+ )
342
+ });
343
+
344
+ cy.findByLabelText('Toggle E0').click();
345
+
346
+ cy.findByLabelText('Toggle E0').should('be.checked');
347
+ cy.get('@rowClick').should('not.have.been.called');
348
+ });
304
349
  });
@@ -55,5 +55,5 @@ const StatusChip = ({
55
55
  );
56
56
  };
57
57
 
58
- export { SeverityCode, getStatusColors };
58
+ export { getStatusColors, SeverityCode };
59
59
  export default StatusChip;
package/src/api/index.ts CHANGED
@@ -66,4 +66,4 @@ const deleteData =
66
66
  })
67
67
  .then(({ data }) => data);
68
68
 
69
- export { getData, patchData, postData, putData, deleteData };
69
+ export { deleteData, getData, patchData, postData, putData };
@@ -63,4 +63,5 @@ const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
63
63
  );
64
64
  }
65
65
  );
66
+
66
67
  export { IconButton };
@@ -18,4 +18,4 @@ const useGlobalRefreshIntervalStyles = makeStyles()((theme) => ({
18
18
  }
19
19
  }));
20
20
 
21
- export { useStyles, useGlobalRefreshIntervalStyles };
21
+ export { useGlobalRefreshIntervalStyles, useStyles };
@@ -77,4 +77,4 @@ const useMenu = (): UseMenu => {
77
77
  };
78
78
  };
79
79
 
80
- export { useMenu, MenuProvider };
80
+ export { MenuProvider, useMenu };
package/src/index.ts CHANGED
@@ -1,11 +1,5 @@
1
1
  import type { Props as SingleAutocompleteFieldProps } from './InputField/Select/Autocomplete';
2
2
 
3
- export { default as IconButton } from './Button/Icon';
4
- export { Checkbox, CheckboxGroup } from './Checkbox';
5
- export { default as SingleAutocompleteField } from './InputField/Select/Autocomplete';
6
- export { default as Pagination } from './Pagination';
7
- export type { SingleAutocompleteFieldProps };
8
-
9
3
  export type { ActionsListActions } from './ActionsList';
10
4
  export {
11
5
  ActionsListActionDivider,
@@ -46,7 +40,9 @@ export {
46
40
  export { WidgetResourceType as ResourceType } from './api/useGraphQuery/models';
47
41
  export { default as useMutationQuery, Method } from './api/useMutationQuery';
48
42
  export { default as useRequest } from './api/useRequest';
43
+ export { default as IconButton } from './Button/Icon';
49
44
  export { default as SaveButton } from './Button/Save';
45
+ export { Checkbox, CheckboxGroup } from './Checkbox';
50
46
  export { default as ContentWithCircularLoading } from './ContentWithCircularProgress';
51
47
  export * from './Dashboard';
52
48
  export { default as Dialog } from './Dialog';
@@ -78,6 +74,7 @@ export { default as PersistentTooltip } from './InputField/Search/PersistentTool
78
74
  export { default as RegexpHelpTooltip } from './InputField/Search/RegexpHelpTooltip';
79
75
  export type { SelectEntry } from './InputField/Select';
80
76
  export { default as SelectField } from './InputField/Select';
77
+ export { default as SingleAutocompleteField } from './InputField/Select/Autocomplete';
81
78
  export { default as MultiConnectedAutocompleteField } from './InputField/Select/Autocomplete/Connected/Multi/index';
82
79
  export { default as PopoverMultiConnectedAutocompleteField } from './InputField/Select/Autocomplete/Connected/Multi/Popover';
83
80
  export { default as SingleConnectedAutocompleteField } from './InputField/Select/Autocomplete/Connected/Single';
@@ -112,6 +109,7 @@ export { default as Module } from './Module/index';
112
109
  export { default as LicensedModule } from './Module/LicensedModule';
113
110
  export { default as MultiSelectEntries } from './MultiSelectEntries';
114
111
  export { default as PageSkeleton } from './PageSkeleton';
112
+ export { default as Pagination } from './Pagination';
115
113
  export { default as Panel } from './Panel';
116
114
  export { default as MemoizedPanel } from './Panel/Memoized';
117
115
  export { default as SectionPanel, MemoizedSectionPanel } from './Panel/Section';
@@ -145,3 +143,4 @@ export { default as Subtitle } from './Typography/Subtitle';
145
143
  export * from './utils';
146
144
  export { default as WallpaperPage } from './WallpaperPage';
147
145
  export { default as Wizard } from './Wizard';
146
+ export type { SingleAutocompleteFieldProps };
@@ -41,4 +41,4 @@ const getUrlQueryParameters = <
41
41
  return fromPairs(entries) as TQueryParameters;
42
42
  };
43
43
 
44
- export { setUrlQueryParameters, getUrlQueryParameters };
44
+ export { getUrlQueryParameters, setUrlQueryParameters };
@@ -92,4 +92,4 @@ const useLocaleDateTimeFormat = (): LocaleDateTimeFormat => {
92
92
  };
93
93
  };
94
94
 
95
- export { dateTimeFormat, dateFormat, timeFormat, useLocaleDateTimeFormat };
95
+ export { dateFormat, dateTimeFormat, timeFormat, useLocaleDateTimeFormat };