@gridsuite/commons-ui 0.77.1 → 0.78.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.
@@ -3,6 +3,7 @@ import { DARK_THEME, LANG_ENGLISH, LANG_FRENCH, LANG_SYSTEM, LIGHT_THEME } from
3
3
  import { FetchStatus } from "./constants/fetchStatus.js";
4
4
  import { FieldConstants } from "./constants/fieldConstants.js";
5
5
  import { MAX_CHAR_DESCRIPTION } from "./constants/uiConstants.js";
6
+ import { AMPERE, DEGREE, KILO_AMPERE, KILO_METER, KILO_VOLT, MEGA_VAR, MEGA_VOLT_AMPERE, MEGA_WATT, MICRO_SIEMENS, OHM, PERCENTAGE, SIEMENS } from "./constants/unitsConstants.js";
6
7
  import { GRIDSUITE_DEFAULT_PRECISION, convertInputValue, convertOutputValue, isBlankOrEmpty, kiloUnitToUnit, microUnitToUnit, roundToDefaultPrecision, roundToPrecision, unitToKiloUnit, unitToMicroUnit } from "./conversionUtils.js";
7
8
  import { areArrayElementsUnique, isObjectEmpty, keyGenerator } from "./functions.js";
8
9
  import { getFileIcon } from "./mapper/getFileIcon.js";
@@ -16,9 +17,11 @@ import { FieldType } from "./types/fieldType.js";
16
17
  import "./yupConfig.js";
17
18
  import * as yup from "yup";
18
19
  export {
20
+ AMPERE,
19
21
  Battery,
20
22
  BusBar,
21
23
  DARK_THEME,
24
+ DEGREE,
22
25
  DanglingLine,
23
26
  EQUIPMENT_TYPE,
24
27
  ElementType,
@@ -29,6 +32,9 @@ export {
29
32
  GRIDSUITE_DEFAULT_PRECISION,
30
33
  Generator,
31
34
  Hvdc,
35
+ KILO_AMPERE,
36
+ KILO_METER,
37
+ KILO_VOLT,
32
38
  LANG_ENGLISH,
33
39
  LANG_FRENCH,
34
40
  LANG_SYSTEM,
@@ -37,9 +43,16 @@ export {
37
43
  Line,
38
44
  Load,
39
45
  MAX_CHAR_DESCRIPTION,
46
+ MEGA_VAR,
47
+ MEGA_VOLT_AMPERE,
48
+ MEGA_WATT,
49
+ MICRO_SIEMENS,
40
50
  MODIFICATION_TYPES,
41
51
  ModificationType,
52
+ OHM,
42
53
  OperatingStatus,
54
+ PERCENTAGE,
55
+ SIEMENS,
43
56
  SVC,
44
57
  ShuntCompensator,
45
58
  Substation,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.77.1",
3
+ "version": "0.78.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "engines": {
6
6
  "npm": ">=9",
@@ -42,7 +42,6 @@
42
42
  "react-dnd": "^16.0.1",
43
43
  "react-dnd-html5-backend": "^16.0.1",
44
44
  "react-querybuilder": "^7.2.0",
45
- "react-virtualized": "^9.22.5",
46
45
  "reconnecting-websocket": "^4.4.0",
47
46
  "uuid": "^9.0.1"
48
47
  },
@@ -97,7 +96,6 @@
97
96
  "@types/react-beautiful-dnd": "^13.1.8",
98
97
  "@types/react-dom": "^18.2.24",
99
98
  "@types/react-resizable": "^3.0.7",
100
- "@types/react-virtualized": "^9.21.29",
101
99
  "@types/utf-8-validate": "^5.0.2",
102
100
  "@types/uuid": "^9.0.8",
103
101
  "@typescript-eslint/eslint-plugin": "^7.0.0",
@@ -1,26 +0,0 @@
1
- import { BoxProps, Theme } from '@mui/material';
2
- import { FilterAltOutlined as FilterAltOutlinedIcon } from '@mui/icons-material';
3
- import { ComponentProps, ReactNode } from 'react';
4
-
5
- interface SortButtonProps {
6
- signedRank?: number;
7
- headerHovered: boolean;
8
- hovered?: boolean;
9
- onClick: BoxProps['onClick'];
10
- }
11
- interface FilterButtonProps {
12
- filterLevel: number;
13
- headerHovered: boolean;
14
- onClick: ComponentProps<typeof FilterAltOutlinedIcon>['onClick'];
15
- }
16
- export interface ColumnHeaderProps extends BoxProps {
17
- label: ReactNode;
18
- numeric: boolean;
19
- sortSignedRank: SortButtonProps['signedRank'];
20
- filterLevel: FilterButtonProps['filterLevel'];
21
- onSortClick: SortButtonProps['onClick'];
22
- onFilterClick: FilterButtonProps['onClick'];
23
- }
24
- export declare const ColumnHeaderComponent: import('react').ForwardRefExoticComponent<Omit<ColumnHeaderProps, "ref"> & import("react").RefAttributes<import("@mui/types").OverridableComponent<import("@mui/system").BoxTypeMap<{}, "div", Theme>>>>;
25
- export declare const ColumnHeader: import('@emotion/styled').StyledComponent<Omit<ColumnHeaderProps, "ref"> & import("react").RefAttributes<import("@mui/types").OverridableComponent<import("@mui/system").BoxTypeMap<{}, "div", Theme>>> & import("@mui/system").MUIStyledCommonProps<import("@mui/system").Theme>, {}, {}>;
26
- export {};
@@ -1,108 +0,0 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { forwardRef, useState, useCallback, useRef, useMemo } from "react";
3
- import { ArrowUpward, ArrowDownward, FilterAltOutlined } from "@mui/icons-material";
4
- import { styled } from "@mui/system";
5
- import { Box } from "@mui/material";
6
- import { mergeSx } from "../../utils/styles.js";
7
- const styles = {
8
- label: {
9
- fontWeight: "bold",
10
- fontSize: "0.875rem"
11
- // to mimic TableCellRoot 'binding'
12
- },
13
- divFlex: {
14
- display: "flex",
15
- flexDirection: "row",
16
- alignItems: "center",
17
- height: "100%"
18
- },
19
- divNum: {
20
- flexDirection: "row-reverse",
21
- textAlign: "right"
22
- },
23
- sortDiv: {
24
- display: "flex",
25
- flexDirection: "column",
26
- alignItems: "center"
27
- },
28
- sortButton: {
29
- fill: "currentcolor"
30
- },
31
- filterButton: {
32
- stroke: "currentcolor"
33
- },
34
- filterTooLossy: (theme) => ({
35
- stroke: theme.palette.secondary.main
36
- }),
37
- transparent: {
38
- opacity: 0
39
- },
40
- hovered: {
41
- opacity: 0.5
42
- }
43
- };
44
- function SortButton({ signedRank = 0, ...props }) {
45
- const sortRank = Math.abs(signedRank);
46
- const visibilityStyle = (!signedRank || void 0) && (props.headerHovered ? styles.hovered : styles.transparent);
47
- return /* @__PURE__ */ jsxs(Box, { sx: styles.sortDiv, onClick: props.onClick, children: [
48
- signedRank >= 0 ? /* @__PURE__ */ jsx(ArrowUpward, { sx: visibilityStyle }) : /* @__PURE__ */ jsx(ArrowDownward, { sx: visibilityStyle }),
49
- sortRank > 1 && !props.hovered && /* @__PURE__ */ jsx("sub", { children: sortRank })
50
- ] });
51
- }
52
- function FilterButton(props) {
53
- const { filterLevel, headerHovered, onClick } = props;
54
- const visibilityStyle = !filterLevel && (headerHovered ? styles.hovered : styles.transparent);
55
- return /* @__PURE__ */ jsx(
56
- FilterAltOutlined,
57
- {
58
- onClick,
59
- sx: mergeSx(
60
- styles.filterButton,
61
- // @ts-ignore type incompatibility of styles
62
- filterLevel > 1 && styles.filterTooLossy,
63
- visibilityStyle
64
- )
65
- }
66
- );
67
- }
68
- const ColumnHeaderComponent = forwardRef((props, ref) => {
69
- const { className, label, numeric, sortSignedRank, filterLevel, onSortClick, onFilterClick, onContextMenu, style } = props;
70
- const [hovered, setHovered] = useState(false);
71
- const onHover = useCallback((evt) => {
72
- setHovered(evt.type === "mouseenter");
73
- }, []);
74
- const topmostDiv = useRef();
75
- const handleFilterClick = useMemo(() => {
76
- if (!onFilterClick) {
77
- return void 0;
78
- }
79
- return (evt) => {
80
- onFilterClick(evt);
81
- };
82
- }, [onFilterClick]);
83
- return (
84
- // @ts-ignore it does not let us define Box with onMouseEnter/onMouseLeave attributes with 'div' I think, not sure though
85
- /* @__PURE__ */ jsxs(
86
- Box,
87
- {
88
- ref: topmostDiv,
89
- onMouseEnter: onHover,
90
- onMouseLeave: onHover,
91
- sx: mergeSx(styles.divFlex, numeric ? styles.divNum : void 0),
92
- className,
93
- style,
94
- onContextMenu,
95
- children: [
96
- /* @__PURE__ */ jsx(Box, { ref, sx: styles.label, children: label }),
97
- onSortClick && /* @__PURE__ */ jsx(SortButton, { headerHovered: hovered, onClick: onSortClick, signedRank: sortSignedRank }),
98
- handleFilterClick && /* @__PURE__ */ jsx(FilterButton, { headerHovered: hovered, onClick: handleFilterClick, filterLevel })
99
- ]
100
- }
101
- )
102
- );
103
- });
104
- const ColumnHeader = styled(ColumnHeaderComponent)({});
105
- export {
106
- ColumnHeader,
107
- ColumnHeaderComponent
108
- };
@@ -1,130 +0,0 @@
1
- import { ColumnProps } from 'react-virtualized';
2
- import { ReactElement } from 'react';
3
-
4
- export interface RowProps {
5
- notClickable?: boolean;
6
- }
7
- export interface CustomColumnProps extends ColumnProps {
8
- sortable?: boolean;
9
- numeric?: boolean;
10
- indexer?: KeyedColumnsRowIndexer;
11
- label: string;
12
- clickable?: boolean;
13
- fractionDigits?: number;
14
- unit?: number;
15
- extra?: ReactElement;
16
- nostat?: boolean;
17
- }
18
- export declare enum ChangeWays {
19
- SIMPLE = "Simple",
20
- TAIL = "Tail",
21
- AMEND = "Amend",
22
- REMOVE = "Remove"
23
- }
24
- export interface ColStat {
25
- imin?: number | null;
26
- imax?: number | null;
27
- seen?: any;
28
- kept?: any;
29
- }
30
- export declare const noOpHelper: Readonly<{
31
- debugName: "noOp";
32
- maintainsStats: false;
33
- initStat: () => undefined;
34
- updateStat: (colStat: ColStat, value: number) => void;
35
- accepts: (value: any, userParams: any[] | undefined, outerParams: any[] | undefined) => true;
36
- }>;
37
- export declare const collectibleHelper: Readonly<{
38
- debugName: "collectible";
39
- maintainsStats: true;
40
- initStat: () => {
41
- seen: {};
42
- kept: {};
43
- };
44
- updateStat: (colStat: ColStat, cellValue: number, isForKeep: boolean) => void;
45
- accepts: (value: number, userParams: any[] | undefined, outerParams: any[] | undefined) => boolean;
46
- }>;
47
- export declare const getHelper: (column?: CustomColumnProps) => Readonly<{
48
- debugName: "noOp";
49
- maintainsStats: false;
50
- initStat: () => undefined;
51
- updateStat: (colStat: ColStat, value: number) => void;
52
- accepts: (value: any, userParams: any[] | undefined, outerParams: any[] | undefined) => true;
53
- }> | Readonly<{
54
- debugName: "num";
55
- maintainsStats: true;
56
- initStat: () => {
57
- imin: null;
58
- imax: null;
59
- };
60
- updateStat: (colStat: ColStat, value: number) => void;
61
- accepts: (value: number, userParams: any[] | undefined, outerParams: any[] | undefined) => true;
62
- }> | Readonly<{
63
- debugName: "collectible";
64
- maintainsStats: true;
65
- initStat: () => {
66
- seen: {};
67
- kept: {};
68
- };
69
- updateStat: (colStat: ColStat, cellValue: number, isForKeep: boolean) => void;
70
- accepts: (value: number, userParams: any[] | undefined, outerParams: any[] | undefined) => boolean;
71
- }>;
72
- export interface Preferences {
73
- isThreeState: boolean;
74
- singleColumnByDefault: boolean;
75
- }
76
- export interface FilteredRows {
77
- rowAndOrigIndex: [RowProps, number][];
78
- colsStats: Record<string, ColStat>;
79
- rowsCount: number;
80
- }
81
- /**
82
- * A rows indexer for MuiVirtualizedTable to delegate to an instance of it
83
- * for filtering, grouping and multi-column sorting via
84
- * a view index to model index array.
85
- */
86
- export declare class KeyedColumnsRowIndexer {
87
- static get CHANGE_WAYS(): typeof ChangeWays;
88
- versionSetter: ((version: number) => void) | null;
89
- byColFilter: Record<string, {
90
- userParams?: any[];
91
- outerParams?: any[];
92
- }> | null;
93
- byRowFilter: ((row: RowProps) => boolean) | null;
94
- delegatorCallback: ((instance: KeyedColumnsRowIndexer, callback: (input: any) => void) => void) | null;
95
- filterVersion: number;
96
- groupingCount: number;
97
- indirectionStatus: string | null;
98
- isThreeState: boolean;
99
- lastUsedRank: number;
100
- singleColumnByDefault: boolean;
101
- sortingState: [string, string | undefined][] | null;
102
- version: number;
103
- constructor(isThreeState?: boolean, singleColumnByDefault?: boolean, delegatorCallback?: null, versionSetter?: ((version: number) => void) | null);
104
- hasVersionSetter: () => boolean;
105
- getVersion: () => number;
106
- bumpVersion: (isFilter?: boolean) => void;
107
- updatePreferences: (preferences: Preferences) => boolean;
108
- preFilterRowMapping: (columns: CustomColumnProps[], rows: RowProps[], rowFilter: (row: RowProps) => boolean) => FilteredRows | null;
109
- makeGroupAndSortIndirector: (preFilteredRowPairs: FilteredRows | null, columns: CustomColumnProps[]) => number[] | null;
110
- getSortingAsKeyAndCodedRank: () => (string | number)[][];
111
- updateSortingFromUser: (colKey: string, change_way: ChangeWays) => boolean;
112
- codedRankByColumnIndex: (columns: CustomColumnProps[]) => number[] | null;
113
- columnSortingSignedRank: (colKey: string) => number;
114
- highestCodedColumn: (columns: CustomColumnProps[]) => number;
115
- getColFilterParams: (colKey: string | null, isForUser: boolean) => any[] | undefined;
116
- setColFilterParams: (colKey: string | null, params: any[] | null, isForUser: boolean) => boolean;
117
- getColFilterOuterParams: (colKey: string | null) => any[] | undefined;
118
- setColFilterOuterParams: (colKey: string, outerParams: any[]) => boolean;
119
- getColFilterUserParams: (colKey: string | null) => any[] | undefined;
120
- setColFilterUserParams: (colKey: string | null, params: any[] | null) => boolean;
121
- getUserFiltering: () => Record<string, object>;
122
- updateRowFiltering: (rowFilterFunc: (row: RowProps) => boolean) => void;
123
- }
124
- export declare const forTesting: {
125
- codedColumnsFromKeyAndDirection: (keyAndDirections: [
126
- string,
127
- string | undefined
128
- ][] | null, columns: CustomColumnProps[]) => number[] | null;
129
- makeCompositeComparatorFromCodedColumns: (codedColumns: number[] | null, columns: CustomColumnProps[], rowExtractor: (row: [Record<string, number | string | undefined>, number][]) => Record<string, number | string | undefined>) => (row_a_i: [Record<string, number | string | undefined>, number][], row_b_i: [Record<string, number | string | undefined>, number][]) => number;
130
- };