@gridsuite/commons-ui 0.289.0 → 0.290.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.
@@ -1,6 +1,6 @@
1
1
  import { ColDef, ComponentType, GridApi, IFilterOptionDef } from 'ag-grid-community';
2
2
  import { UUID } from 'crypto';
3
- import { DYNAMIC_SIMULATION_RESULT_SORT_STORE, LOADFLOW_RESULT_SORT_STORE, PCCMIN_ANALYSIS_RESULT_SORT_STORE, SECURITY_ANALYSIS_RESULT_SORT_STORE, SENSITIVITY_ANALYSIS_RESULT_SORT_STORE, SHORTCIRCUIT_ANALYSIS_RESULT_SORT_STORE, SPREADSHEET_SORT_STORE, STATEESTIMATION_RESULT_SORT_STORE } from '../../../utils/store-sort-filter-fields';
3
+ import { DYNAMIC_SIMULATION_RESULT_SORT_STORE, LOADFLOW_RESULT_SORT_STORE, PCCMIN_ANALYSIS_RESULT_SORT_STORE, PROCESS_EXECUTION_HISTORY_SORT_STORE, SECURITY_ANALYSIS_RESULT_SORT_STORE, SENSITIVITY_ANALYSIS_RESULT_SORT_STORE, SHORTCIRCUIT_ANALYSIS_RESULT_SORT_STORE, SPREADSHEET_SORT_STORE, STATEESTIMATION_RESULT_SORT_STORE } from '../../../utils/store-sort-filter-fields';
4
4
  export declare enum TableType {
5
5
  Loadflow = "Loadflow",
6
6
  SecurityAnalysis = "SecurityAnalysis",
@@ -11,7 +11,8 @@ export declare enum TableType {
11
11
  Logs = "Logs",
12
12
  StateEstimation = "StateEstimation",
13
13
  PccMin = "PccMin",
14
- VoltageInit = "VoltageInit"
14
+ VoltageInit = "VoltageInit",
15
+ ProcessExecutionHistory = "ProcessExecutionHistory"
15
16
  }
16
17
  export declare enum FilterDataTypes {
17
18
  TEXT = "text",
@@ -83,6 +84,7 @@ export type TableSort = {
83
84
  [SHORTCIRCUIT_ANALYSIS_RESULT_SORT_STORE]: TableSortConfig;
84
85
  [STATEESTIMATION_RESULT_SORT_STORE]: TableSortConfig;
85
86
  [PCCMIN_ANALYSIS_RESULT_SORT_STORE]: TableSortConfig;
87
+ [PROCESS_EXECUTION_HISTORY_SORT_STORE]: TableSortConfig;
86
88
  };
87
89
  export type TableSortKeysType = keyof TableSort;
88
90
  export type SortParams = {
@@ -9,6 +9,7 @@ var TableType = /* @__PURE__ */ ((TableType2) => {
9
9
  TableType2["StateEstimation"] = "StateEstimation";
10
10
  TableType2["PccMin"] = "PccMin";
11
11
  TableType2["VoltageInit"] = "VoltageInit";
12
+ TableType2["ProcessExecutionHistory"] = "ProcessExecutionHistory";
12
13
  return TableType2;
13
14
  })(TableType || {});
14
15
  var FilterDataTypes = /* @__PURE__ */ ((FilterDataTypes2) => {
@@ -17,3 +17,4 @@ export * from './custom-aggrid-menu';
17
17
  export * from './custom-aggrid-sort';
18
18
  export * from './display-rounding';
19
19
  export * from './utils';
20
+ export * from './user-avatar';
@@ -19,6 +19,7 @@ import { CustomMenu } from "./custom-aggrid-menu.js";
19
19
  import { CustomAggridSort } from "./custom-aggrid-sort.js";
20
20
  import { DisplayRounding } from "./display-rounding.js";
21
21
  import { makeAgGridCustomHeaderColumn } from "./utils/custom-aggrid-header-utils.js";
22
+ import { UserAvatar, UserAvatarWithLabel } from "./user-avatar.js";
22
23
  export {
23
24
  BooleanCellRenderer,
24
25
  BooleanNullableCellRenderer,
@@ -50,6 +51,8 @@ export {
50
51
  SortWay,
51
52
  TableType,
52
53
  UndisplayedFilterNumberComparators,
54
+ UserAvatar,
55
+ UserAvatarWithLabel,
53
56
  addToleranceToFilter,
54
57
  computeTolerance,
55
58
  makeAgGridCustomHeaderColumn,
@@ -0,0 +1,12 @@
1
+ export type UserAvatarSize = 'small' | 'medium';
2
+ export type UserAvatarProps = {
3
+ label: string;
4
+ size?: UserAvatarSize;
5
+ backgroundColor?: string;
6
+ };
7
+ /** Colored initials avatar for a user. */
8
+ export declare function UserAvatar({ label, size, backgroundColor }: Readonly<UserAvatarProps>): import("react").JSX.Element;
9
+ /** A user name preceded by its avatar, in a compact size. */
10
+ export declare function UserAvatarWithLabel({ label }: Readonly<{
11
+ label: string;
12
+ }>): import("react").JSX.Element;
@@ -0,0 +1,49 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Tooltip, Avatar, Box } from "@mui/material";
3
+ import "../../../utils/conversionUtils.js";
4
+ import "../../../utils/types/equipmentType.js";
5
+ import "@mui/icons-material";
6
+ import { mergeSx } from "../../../utils/styles.js";
7
+ import { getAbbreviationFromUserName } from "../../../utils/user-utils.js";
8
+ const FERMAT_PRIME = 65537;
9
+ function stringToColor(string) {
10
+ let hash = 0;
11
+ const stringUniqueHash = [...string].reduce((acc, char) => {
12
+ hash = char.charCodeAt(0) + ((acc << 5) - acc) * FERMAT_PRIME;
13
+ return hash & hash;
14
+ }, 0);
15
+ return `hsl(${stringUniqueHash % 360}, 50%, 50%)`;
16
+ }
17
+ const styles = {
18
+ avatar: (theme) => ({
19
+ height: "32px",
20
+ width: "32px",
21
+ fontSize: theme.typography.fontSize
22
+ }),
23
+ avatarSmall: (theme) => ({
24
+ height: "24px",
25
+ width: "24px",
26
+ fontSize: theme.typography.pxToRem(11)
27
+ })
28
+ };
29
+ function UserAvatar({ label, size = "medium", backgroundColor }) {
30
+ return /* @__PURE__ */ jsx(Tooltip, { title: label, children: /* @__PURE__ */ jsx(
31
+ Avatar,
32
+ {
33
+ sx: mergeSx(size === "small" ? styles.avatarSmall : styles.avatar, (theme) => ({
34
+ backgroundColor: backgroundColor ?? (label ? stringToColor(label) : theme.row.hover)
35
+ })),
36
+ children: getAbbreviationFromUserName(label)
37
+ }
38
+ ) });
39
+ }
40
+ function UserAvatarWithLabel({ label }) {
41
+ return /* @__PURE__ */ jsxs(Box, { sx: { display: "inline-flex", alignItems: "center", gap: 1 }, children: [
42
+ /* @__PURE__ */ jsx(UserAvatar, { label, size: "small" }),
43
+ label
44
+ ] });
45
+ }
46
+ export {
47
+ UserAvatar,
48
+ UserAvatarWithLabel
49
+ };
@@ -66,6 +66,7 @@ import { CustomMenu } from "./customAGGrid/custom-aggrid-menu.js";
66
66
  import { CustomAggridSort } from "./customAGGrid/custom-aggrid-sort.js";
67
67
  import { DisplayRounding } from "./customAGGrid/display-rounding.js";
68
68
  import { makeAgGridCustomHeaderColumn } from "./customAGGrid/utils/custom-aggrid-header-utils.js";
69
+ import { UserAvatar, UserAvatarWithLabel } from "./customAGGrid/user-avatar.js";
69
70
  import { ReportViewer } from "./report/report-viewer/report-viewer.js";
70
71
  import { ReportFetcherContext, ReportFilterContext, useReportFetcherContext, useReportFilterContext } from "./report/report-viewer/context/report-viewer-context.js";
71
72
  import { default as default2 } from "./report/report-viewer/log-table/log-table.js";
@@ -173,6 +174,8 @@ export {
173
174
  TextValueEditor,
174
175
  TranslatedValueEditor,
175
176
  UndisplayedFilterNumberComparators,
177
+ UserAvatar,
178
+ UserAvatarWithLabel,
176
179
  ValueEditor,
177
180
  ValueSelector,
178
181
  addToleranceToFilter,
@@ -150,6 +150,7 @@ import { CustomMenu } from "./composite/customAGGrid/custom-aggrid-menu.js";
150
150
  import { CustomAggridSort } from "./composite/customAGGrid/custom-aggrid-sort.js";
151
151
  import { DisplayRounding } from "./composite/customAGGrid/display-rounding.js";
152
152
  import { makeAgGridCustomHeaderColumn } from "./composite/customAGGrid/utils/custom-aggrid-header-utils.js";
153
+ import { UserAvatar, UserAvatarWithLabel } from "./composite/customAGGrid/user-avatar.js";
153
154
  import { ReportViewer } from "./composite/report/report-viewer/report-viewer.js";
154
155
  import { ReportFetcherContext, ReportFilterContext, useReportFetcherContext, useReportFilterContext } from "./composite/report/report-viewer/context/report-viewer-context.js";
155
156
  import { default as default2 } from "./composite/report/report-viewer/log-table/log-table.js";
@@ -342,6 +343,8 @@ export {
342
343
  TreeViewFinder,
343
344
  UndisplayedFilterNumberComparators,
344
345
  UniqueNameInput,
346
+ UserAvatar,
347
+ UserAvatarWithLabel,
345
348
  ValueEditor,
346
349
  ValueSelector,
347
350
  VoltageUnitIcon,
@@ -2,19 +2,9 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { Avatar } from "@mui/material";
3
3
  import "../../../../utils/conversionUtils.js";
4
4
  import "../../../../utils/types/equipmentType.js";
5
- import { isEmpty } from "../../../../utils/functions.js";
6
5
  import "@mui/icons-material";
7
6
  import { mergeSx } from "../../../../utils/styles.js";
8
- function getAbbreviationFromUserName(name) {
9
- if (isEmpty(name)) {
10
- return "";
11
- }
12
- const [firstName, ...otherNames] = name.split(" ");
13
- if (otherNames.length > 0) {
14
- return `${firstName[0]}${otherNames.at(-1)[0]}`;
15
- }
16
- return firstName[0];
17
- }
7
+ import { getAbbreviationFromUserName } from "../../../../utils/user-utils.js";
18
8
  function UserAvatarIcon({ label, sx }) {
19
9
  return /* @__PURE__ */ jsx(
20
10
  Avatar,
package/dist/index.js CHANGED
@@ -151,6 +151,7 @@ import { CustomMenu } from "./components/composite/customAGGrid/custom-aggrid-me
151
151
  import { CustomAggridSort } from "./components/composite/customAGGrid/custom-aggrid-sort.js";
152
152
  import { DisplayRounding } from "./components/composite/customAGGrid/display-rounding.js";
153
153
  import { makeAgGridCustomHeaderColumn } from "./components/composite/customAGGrid/utils/custom-aggrid-header-utils.js";
154
+ import { UserAvatar, UserAvatarWithLabel } from "./components/composite/customAGGrid/user-avatar.js";
154
155
  import { ReportViewer } from "./components/composite/report/report-viewer/report-viewer.js";
155
156
  import { ReportFetcherContext, ReportFilterContext, useReportFetcherContext, useReportFilterContext } from "./components/composite/report/report-viewer/context/report-viewer-context.js";
156
157
  import { default as default3 } from "./components/composite/report/report-viewer/log-table/log-table.js";
@@ -1332,6 +1333,8 @@ export {
1332
1333
  UnauthorizedAccessAlert,
1333
1334
  UndisplayedFilterNumberComparators,
1334
1335
  UniqueNameInput,
1336
+ UserAvatar,
1337
+ UserAvatarWithLabel,
1335
1338
  default5 as UserInformationDialog,
1336
1339
  UserManagerMock,
1337
1340
  default6 as UserSettingsDialog,
@@ -36,3 +36,4 @@ export declare const STATEESTIMATION_RESULT = "stateEstimationResult";
36
36
  export declare const PCCMIN_ANALYSIS_RESULT_SORT_STORE = "pccminAnalysisResult";
37
37
  export declare const PCCMIN_ANALYSIS_PAGINATION_STORE_FIELD = "pccminAnalysisPagination";
38
38
  export declare const PCCMIN_RESULT = "pccMinResults";
39
+ export declare const PROCESS_EXECUTION_HISTORY_SORT_STORE = "processExecutionHistory";
@@ -30,6 +30,7 @@ const STATEESTIMATION_RESULT = "stateEstimationResult";
30
30
  const PCCMIN_ANALYSIS_RESULT_SORT_STORE = "pccminAnalysisResult";
31
31
  const PCCMIN_ANALYSIS_PAGINATION_STORE_FIELD = "pccminAnalysisPagination";
32
32
  const PCCMIN_RESULT = "pccMinResults";
33
+ const PROCESS_EXECUTION_HISTORY_SORT_STORE = "processExecutionHistory";
33
34
  export {
34
35
  ALL_BUSES,
35
36
  DYNAMIC_SIMULATION_RESULT_SORT_STORE,
@@ -42,6 +43,7 @@ export {
42
43
  PCCMIN_ANALYSIS_PAGINATION_STORE_FIELD,
43
44
  PCCMIN_ANALYSIS_RESULT_SORT_STORE,
44
45
  PCCMIN_RESULT,
46
+ PROCESS_EXECUTION_HISTORY_SORT_STORE,
45
47
  SECURITY_ANALYSIS_PAGINATION_STORE_FIELD,
46
48
  SECURITY_ANALYSIS_RESULT_N,
47
49
  SECURITY_ANALYSIS_RESULT_N_K,
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) 2026, RTE (http://www.rte-france.com)
3
+ * This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
+ */
7
+ export declare function getAbbreviationFromUserName(name: string): string;
@@ -0,0 +1,14 @@
1
+ import { isEmpty } from "@mui/material";
2
+ function getAbbreviationFromUserName(name) {
3
+ if (isEmpty(name)) {
4
+ return "";
5
+ }
6
+ const [firstName, ...otherNames] = name.split(" ");
7
+ if (otherNames.length > 0) {
8
+ return `${firstName[0]}${otherNames.at(-1)[0]}`;
9
+ }
10
+ return firstName[0];
11
+ }
12
+ export {
13
+ getAbbreviationFromUserName
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.289.0",
3
+ "version": "0.290.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",