@gridsuite/commons-ui 0.139.0 → 0.140.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/dist/components/csvDownloader/csv-export.d.ts +1 -1
- package/dist/components/csvDownloader/csv-export.js +5 -14
- package/dist/components/csvDownloader/csv-export.type.d.ts +1 -1
- package/dist/components/csvDownloader/use-csv-export.d.ts +1 -1
- package/dist/components/csvDownloader/use-csv-export.js +11 -11
- package/dist/components/filter/FilterCreationDialog.js +2 -1
- package/dist/components/filter/FilterForm.d.ts +16 -2
- package/dist/components/filter/FilterForm.js +5 -10
- package/dist/components/filter/HeaderFilterForm.d.ts +7 -11
- package/dist/components/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js +8 -1
- package/dist/components/filter/explicitNaming/ExplicitNamingFilterForm.d.ts +3 -1
- package/dist/components/filter/explicitNaming/ExplicitNamingFilterForm.js +9 -2
- package/dist/index.js +2 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/navigator-clipboard.d.ts +7 -0
- package/dist/utils/navigator-clipboard.js +16 -0
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { CsvExportProps } from './csv-export.type';
|
|
2
|
-
export declare function CsvExport({ columns, tableNamePrefix, tableName, disabled, skipColumnHeaders, skipPinnedBottom, language,
|
|
2
|
+
export declare function CsvExport({ columns, tableNamePrefix, tableName, disabled, skipColumnHeaders, skipPinnedBottom, language, getData, }: CsvExportProps): JSX.Element;
|
|
@@ -10,29 +10,20 @@ function CsvExport({
|
|
|
10
10
|
skipColumnHeaders = false,
|
|
11
11
|
skipPinnedBottom = false,
|
|
12
12
|
language,
|
|
13
|
-
|
|
13
|
+
getData
|
|
14
14
|
}) {
|
|
15
|
-
const
|
|
15
|
+
const csvExport = useCsvExport();
|
|
16
16
|
const download = useCallback(() => {
|
|
17
|
-
|
|
17
|
+
csvExport.getData({
|
|
18
18
|
columns,
|
|
19
19
|
tableName,
|
|
20
20
|
tableNamePrefix,
|
|
21
21
|
skipColumnHeaders,
|
|
22
22
|
skipPinnedBottom,
|
|
23
23
|
language,
|
|
24
|
-
|
|
24
|
+
getData
|
|
25
25
|
});
|
|
26
|
-
}, [
|
|
27
|
-
downloadCSVData,
|
|
28
|
-
columns,
|
|
29
|
-
tableName,
|
|
30
|
-
tableNamePrefix,
|
|
31
|
-
skipColumnHeaders,
|
|
32
|
-
skipPinnedBottom,
|
|
33
|
-
language,
|
|
34
|
-
exportDataAsCsv
|
|
35
|
-
]);
|
|
26
|
+
}, [columns, csvExport, tableName, tableNamePrefix, skipColumnHeaders, skipPinnedBottom, language, getData]);
|
|
36
27
|
return /* @__PURE__ */ jsx(ExportCsvButton, { disabled, onClick: download });
|
|
37
28
|
}
|
|
38
29
|
export {
|
|
@@ -7,7 +7,7 @@ export type CsvDownloadProps = {
|
|
|
7
7
|
skipColumnHeaders?: boolean;
|
|
8
8
|
skipPinnedBottom?: boolean;
|
|
9
9
|
language: GsLang;
|
|
10
|
-
|
|
10
|
+
getData: (params?: CsvExportParams) => string | undefined | void;
|
|
11
11
|
};
|
|
12
12
|
export type CsvExportProps = CsvDownloadProps & {
|
|
13
13
|
disabled: boolean;
|
|
@@ -7,30 +7,30 @@ import "@mui/icons-material";
|
|
|
7
7
|
import "../../utils/types/equipmentType.js";
|
|
8
8
|
import "../../utils/yupConfig.js";
|
|
9
9
|
const NA_VALUE = "N/A";
|
|
10
|
-
const formatNAValue = (value, intl) => {
|
|
11
|
-
return value === NA_VALUE ? intl.formatMessage({ id: "export/undefined" }) : value;
|
|
12
|
-
};
|
|
13
10
|
const useCsvExport = () => {
|
|
14
11
|
const intl = useIntl();
|
|
15
|
-
const
|
|
16
|
-
return tableName.trim().replace(/[\\/:"*?<>|\s]/g, "-").substring(0, 27);
|
|
17
|
-
}, []);
|
|
18
|
-
const downloadCSVData = useCallback(
|
|
12
|
+
const getData = useCallback(
|
|
19
13
|
(props) => {
|
|
14
|
+
const formatNAValue = (value) => {
|
|
15
|
+
return value === NA_VALUE ? intl.formatMessage({ id: "export/undefined" }) : value;
|
|
16
|
+
};
|
|
20
17
|
const hasColId = (colId) => {
|
|
21
18
|
return colId !== void 0;
|
|
22
19
|
};
|
|
23
20
|
const processCell = (params) => {
|
|
24
21
|
if (params.column.getColId() === "limitName") {
|
|
25
|
-
return formatNAValue(params.value
|
|
22
|
+
return formatNAValue(params.value);
|
|
26
23
|
}
|
|
27
24
|
if (props.language === LANG_FRENCH && typeof params.value === "number") {
|
|
28
25
|
return params.value.toString().replace(".", ",");
|
|
29
26
|
}
|
|
30
27
|
return params.value;
|
|
31
28
|
};
|
|
29
|
+
const getCSVFilename = (tableName) => {
|
|
30
|
+
return tableName.trim().replace(/[\\/:"*?<>|\s]/g, "-").substring(0, 27);
|
|
31
|
+
};
|
|
32
32
|
const prefix = props.tableNamePrefix ?? "";
|
|
33
|
-
props.
|
|
33
|
+
return props.getData({
|
|
34
34
|
suppressQuotes: false,
|
|
35
35
|
skipPinnedBottom: props.skipPinnedBottom,
|
|
36
36
|
columnSeparator: props.language === LANG_FRENCH ? ";" : ",",
|
|
@@ -41,9 +41,9 @@ const useCsvExport = () => {
|
|
|
41
41
|
processCellCallback: processCell
|
|
42
42
|
});
|
|
43
43
|
},
|
|
44
|
-
[
|
|
44
|
+
[intl]
|
|
45
45
|
);
|
|
46
|
-
return {
|
|
46
|
+
return { getData };
|
|
47
47
|
};
|
|
48
48
|
export {
|
|
49
49
|
useCsvExport
|
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { UUID } from 'node:crypto';
|
|
2
|
+
import { GsLang } from '../../utils';
|
|
3
|
+
export interface FilterFormProps {
|
|
4
|
+
creation?: boolean;
|
|
5
|
+
activeDirectory?: UUID;
|
|
6
|
+
filterType?: {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
};
|
|
10
|
+
sourceFilterForExplicitNamingConversion?: {
|
|
11
|
+
id: UUID;
|
|
12
|
+
equipmentType: string;
|
|
13
|
+
};
|
|
14
|
+
language?: GsLang;
|
|
15
|
+
}
|
|
16
|
+
export declare function FilterForm({ sourceFilterForExplicitNamingConversion, creation, activeDirectory, filterType, language, }: Readonly<FilterFormProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -20,21 +20,16 @@ function FilterForm({
|
|
|
20
20
|
sourceFilterForExplicitNamingConversion,
|
|
21
21
|
creation,
|
|
22
22
|
activeDirectory,
|
|
23
|
-
filterType
|
|
23
|
+
filterType,
|
|
24
|
+
language
|
|
24
25
|
}) {
|
|
25
26
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
26
|
-
/* @__PURE__ */ jsx(Box, { sx: unscrollableDialogStyles.unscrollableHeader, children: /* @__PURE__ */ jsx(
|
|
27
|
-
HeaderFilterForm,
|
|
28
|
-
{
|
|
29
|
-
creation,
|
|
30
|
-
activeDirectory,
|
|
31
|
-
sourceFilterForExplicitNamingConversion
|
|
32
|
-
}
|
|
33
|
-
) }),
|
|
27
|
+
/* @__PURE__ */ jsx(Box, { sx: unscrollableDialogStyles.unscrollableHeader, children: /* @__PURE__ */ jsx(HeaderFilterForm, { creation, activeDirectory }) }),
|
|
34
28
|
filterType?.id === FilterType.EXPLICIT_NAMING.id && /* @__PURE__ */ jsx(
|
|
35
29
|
ExplicitNamingFilterForm,
|
|
36
30
|
{
|
|
37
|
-
sourceFilterForExplicitNamingConversion
|
|
31
|
+
sourceFilterForExplicitNamingConversion,
|
|
32
|
+
language
|
|
38
33
|
}
|
|
39
34
|
),
|
|
40
35
|
filterType?.id === FilterType.EXPERT.id && /* @__PURE__ */ jsx(ExpertFilterForm, {})
|
|
@@ -10,21 +10,17 @@ export declare const filterStyles: {
|
|
|
10
10
|
readonly width: "50%";
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export declare const HeaderFilterSchema: {
|
|
14
|
+
name: yup.StringSchema<string, yup.AnyObject, undefined, "">;
|
|
15
|
+
equipmentType: yup.StringSchema<string, yup.AnyObject, undefined, "">;
|
|
16
|
+
description: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
|
|
17
|
+
};
|
|
18
|
+
export interface HeaderFilterFormProps {
|
|
14
19
|
creation?: boolean;
|
|
15
20
|
activeDirectory?: UUID;
|
|
16
|
-
filterType?: {
|
|
17
|
-
id: string;
|
|
18
|
-
label: string;
|
|
19
|
-
};
|
|
20
21
|
sourceFilterForExplicitNamingConversion?: {
|
|
21
22
|
id: UUID;
|
|
22
23
|
equipmentType: string;
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
|
-
export declare
|
|
26
|
-
name: yup.StringSchema<string, yup.AnyObject, undefined, "">;
|
|
27
|
-
equipmentType: yup.StringSchema<string, yup.AnyObject, undefined, "">;
|
|
28
|
-
description: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
|
|
29
|
-
};
|
|
30
|
-
export declare function HeaderFilterForm({ creation, activeDirectory }: Readonly<FilterFormProps>): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare function HeaderFilterForm({ creation, activeDirectory }: Readonly<HeaderFilterFormProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -102,7 +102,14 @@ function ExplicitNamingFilterEditionDialog({
|
|
|
102
102
|
isDataFetching: dataFetchStatus === FetchStatus.FETCHING,
|
|
103
103
|
language,
|
|
104
104
|
unscrollableFullHeight: true,
|
|
105
|
-
children: isDataReady && /* @__PURE__ */ jsx(
|
|
105
|
+
children: isDataReady && /* @__PURE__ */ jsx(
|
|
106
|
+
FilterForm,
|
|
107
|
+
{
|
|
108
|
+
activeDirectory,
|
|
109
|
+
filterType: FilterType.EXPLICIT_NAMING,
|
|
110
|
+
language
|
|
111
|
+
}
|
|
112
|
+
)
|
|
106
113
|
}
|
|
107
114
|
);
|
|
108
115
|
}
|
|
@@ -2,6 +2,7 @@ import { UUID } from 'node:crypto';
|
|
|
2
2
|
import { FieldConstants } from '../../../utils/constants/fieldConstants';
|
|
3
3
|
import { default as yup } from '../../../utils/yupConfig';
|
|
4
4
|
import { DISTRIBUTION_KEY } from '../constants/FilterConstants';
|
|
5
|
+
import { GsLang } from '../../../utils';
|
|
5
6
|
export declare const explicitNamingFilterSchema: {
|
|
6
7
|
filterEquipmentsAttributes: yup.ArraySchema<{
|
|
7
8
|
equipmentID?: string | null | undefined;
|
|
@@ -22,6 +23,7 @@ export interface FilterForExplicitConversionProps {
|
|
|
22
23
|
}
|
|
23
24
|
interface ExplicitNamingFilterFormProps {
|
|
24
25
|
sourceFilterForExplicitNamingConversion?: FilterForExplicitConversionProps;
|
|
26
|
+
language?: GsLang;
|
|
25
27
|
}
|
|
26
|
-
export declare function ExplicitNamingFilterForm({ sourceFilterForExplicitNamingConversion }: ExplicitNamingFilterFormProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare function ExplicitNamingFilterForm({ sourceFilterForExplicitNamingConversion, language, }: Readonly<ExplicitNamingFilterFormProps>): import("react/jsx-runtime").JSX.Element;
|
|
27
29
|
export {};
|
|
@@ -23,7 +23,10 @@ import "../../dialogs/descriptionModificationDialog/DescriptionModificationDialo
|
|
|
23
23
|
import "../../dialogs/elementSaveDialog/ElementSaveDialog.js";
|
|
24
24
|
import { FILTER_EQUIPMENTS_ATTRIBUTES } from "./ExplicitNamingFilterConstants.js";
|
|
25
25
|
import { filterStyles } from "../HeaderFilterForm.js";
|
|
26
|
+
import "../../../utils/conversionUtils.js";
|
|
26
27
|
import { snackWithFallback } from "../../../utils/error.js";
|
|
28
|
+
import "@mui/icons-material";
|
|
29
|
+
import "../../../utils/types/equipmentType.js";
|
|
27
30
|
import * as yup from "yup";
|
|
28
31
|
function isGeneratorOrLoad(equipmentType) {
|
|
29
32
|
return equipmentType === Generator.type || equipmentType === Load.type;
|
|
@@ -58,7 +61,10 @@ function getExplicitNamingFilterEmptyFormData() {
|
|
|
58
61
|
[FILTER_EQUIPMENTS_ATTRIBUTES]: makeDefaultTableRows()
|
|
59
62
|
};
|
|
60
63
|
}
|
|
61
|
-
function ExplicitNamingFilterForm({
|
|
64
|
+
function ExplicitNamingFilterForm({
|
|
65
|
+
sourceFilterForExplicitNamingConversion,
|
|
66
|
+
language
|
|
67
|
+
}) {
|
|
62
68
|
const intl = useIntl();
|
|
63
69
|
const { snackError } = useSnackMessage();
|
|
64
70
|
const { getValues, setValue } = useFormContext();
|
|
@@ -203,7 +209,8 @@ function ExplicitNamingFilterForm({ sourceFilterForExplicitNamingConversion }) {
|
|
|
203
209
|
id: "filterCsvFileName"
|
|
204
210
|
}),
|
|
205
211
|
fileHeaders: csvFileHeaders,
|
|
206
|
-
getDataFromCsv: getDataFromCsvFile
|
|
212
|
+
getDataFromCsv: getDataFromCsvFile,
|
|
213
|
+
language
|
|
207
214
|
},
|
|
208
215
|
cssProps: {
|
|
209
216
|
padding: 1,
|
package/dist/index.js
CHANGED
|
@@ -213,6 +213,7 @@ import { areArrayElementsUnique, isObjectEmpty, keyGenerator } from "./utils/fun
|
|
|
213
213
|
import { LANG_ENGLISH, LANG_FRENCH, LANG_SYSTEM } from "./utils/langs.js";
|
|
214
214
|
import { getFileIcon } from "./utils/mapper/getFileIcon.js";
|
|
215
215
|
import { equipmentTypesForPredefinedPropertiesMapper } from "./utils/mapper/equipmentTypesForPredefinedPropertiesMapper.js";
|
|
216
|
+
import { copyToClipboard } from "./utils/navigator-clipboard.js";
|
|
216
217
|
import { NotificationsUrlKeys, PREFIX_CONFIG_NOTIFICATION_WS, PREFIX_DIRECTORY_NOTIFICATION_WS, PREFIX_STUDY_NOTIFICATION_WS } from "./utils/constants/notificationsProvider.js";
|
|
217
218
|
import { DARK_THEME, LIGHT_THEME, makeComposeClasses, mergeSx, toNestedGlobalSelectors } from "./utils/styles.js";
|
|
218
219
|
import { CustomError, formatMessageValues } from "./utils/types/CustomError.js";
|
|
@@ -687,6 +688,7 @@ export {
|
|
|
687
688
|
componentsFr,
|
|
688
689
|
convertInputValue,
|
|
689
690
|
convertOutputValue,
|
|
691
|
+
copyToClipboard,
|
|
690
692
|
countRules,
|
|
691
693
|
createFilter,
|
|
692
694
|
createParameter,
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from './error';
|
|
|
11
11
|
export * from './functions';
|
|
12
12
|
export * from './langs';
|
|
13
13
|
export * from './mapper';
|
|
14
|
+
export * from './navigator-clipboard';
|
|
14
15
|
export * from './constants/notificationsProvider';
|
|
15
16
|
export * from './styles';
|
|
16
17
|
export * from './types';
|
package/dist/utils/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import { areArrayElementsUnique, isObjectEmpty, keyGenerator } from "./functions
|
|
|
11
11
|
import { LANG_ENGLISH, LANG_FRENCH, LANG_SYSTEM } from "./langs.js";
|
|
12
12
|
import { getFileIcon } from "./mapper/getFileIcon.js";
|
|
13
13
|
import { equipmentTypesForPredefinedPropertiesMapper } from "./mapper/equipmentTypesForPredefinedPropertiesMapper.js";
|
|
14
|
+
import { copyToClipboard } from "./navigator-clipboard.js";
|
|
14
15
|
import { NotificationsUrlKeys, PREFIX_CONFIG_NOTIFICATION_WS, PREFIX_DIRECTORY_NOTIFICATION_WS, PREFIX_STUDY_NOTIFICATION_WS } from "./constants/notificationsProvider.js";
|
|
15
16
|
import { DARK_THEME, LIGHT_THEME, makeComposeClasses, mergeSx, toNestedGlobalSelectors } from "./styles.js";
|
|
16
17
|
import { CustomError, formatMessageValues } from "./types/CustomError.js";
|
|
@@ -102,6 +103,7 @@ export {
|
|
|
102
103
|
catchErrorHandler,
|
|
103
104
|
convertInputValue,
|
|
104
105
|
convertOutputValue,
|
|
106
|
+
copyToClipboard,
|
|
105
107
|
equalsArray,
|
|
106
108
|
equipmentStyles,
|
|
107
109
|
equipmentTypesForPredefinedPropertiesMapper,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, 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 copyToClipboard(valueToCopy: string, onSuccess?: () => void, onError?: () => void): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
function copyToClipboard(valueToCopy, onSuccess, onError) {
|
|
2
|
+
if ("clipboard" in navigator) {
|
|
3
|
+
navigator.clipboard.writeText(valueToCopy).then(() => {
|
|
4
|
+
if (onSuccess) onSuccess();
|
|
5
|
+
}).catch((error) => {
|
|
6
|
+
console.error("Clipboard copy error: ", error);
|
|
7
|
+
if (onError) onError();
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
console.error("navigator.clipboard is not supported by your current navigator");
|
|
11
|
+
if (onError) onError();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
copyToClipboard
|
|
16
|
+
};
|