@gridsuite/commons-ui 0.242.0 → 0.243.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/README.md +6 -2
- package/dist/components/composite/filter/explicitNaming/ExplicitNamingFilterForm.js +1 -1
- package/dist/components/ui/csvPicker/csv-picker.d.ts +7 -2
- package/dist/components/ui/csvPicker/csv-picker.js +7 -6
- package/dist/index.js +0 -4
- package/dist/translations/en/index.d.ts +0 -1
- package/dist/translations/en/index.js +0 -2
- package/dist/translations/fr/index.d.ts +0 -1
- package/dist/translations/fr/index.js +0 -2
- package/package.json +1 -1
- package/dist/translations/en/inputsEn.d.ts +0 -24
- package/dist/translations/en/inputsEn.js +0 -21
- package/dist/translations/fr/inputsFr.d.ts +0 -24
- package/dist/translations/fr/inputsFr.js +0 -21
package/README.md
CHANGED
|
@@ -20,8 +20,12 @@ Components are organized as follows:
|
|
|
20
20
|
|
|
21
21
|
#### For developers
|
|
22
22
|
|
|
23
|
-
The commons-ui library
|
|
24
|
-
The `npm start` command
|
|
23
|
+
The commons-ui library has a demo app in which you can call your components to test them.
|
|
24
|
+
The `npm start` command installs the library's dependencies then launches the demo app.
|
|
25
|
+
|
|
26
|
+
The commons-ui Storybook is also available at https://www.gridsuite.org/commons-ui/.
|
|
27
|
+
It is the reference place to document and preview reusable UI components from `src/components/ui`.
|
|
28
|
+
When you add a new component under `src/components/ui`, also add the corresponding story so it is available in Storybook.
|
|
25
29
|
|
|
26
30
|
##### Development Scripts
|
|
27
31
|
|
|
@@ -10,7 +10,12 @@ type CsvPickerCallbacks<TData> = {
|
|
|
10
10
|
};
|
|
11
11
|
export type CsvPickerProps<TData = unknown> = {
|
|
12
12
|
label: string;
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Columns that must be present in the imported file. The file is accepted as soon as it
|
|
15
|
+
* contains every column listed here, in any order; any column that matches none of them is
|
|
16
|
+
* ignored (not rejected). Pass an empty array to accept any header.
|
|
17
|
+
*/
|
|
18
|
+
requiredColumns: string[];
|
|
14
19
|
maxLineNumber?: number;
|
|
15
20
|
disabled?: boolean;
|
|
16
21
|
language: string;
|
|
@@ -20,5 +25,5 @@ export type CsvPickerProps<TData = unknown> = {
|
|
|
20
25
|
onFileError: (error: string | undefined) => void;
|
|
21
26
|
getTableData?: () => unknown[];
|
|
22
27
|
} & CsvPickerCallbacks<TData>;
|
|
23
|
-
export declare function CsvPicker<TData = unknown>({ label,
|
|
28
|
+
export declare function CsvPicker<TData = unknown>({ label, requiredColumns, maxLineNumber, disabled, language, parseConfig, selectedFile, onFileChange, onFileError, onComplete, onAppend, onReplace, getTableData, }: CsvPickerProps<TData>): import("react").JSX.Element;
|
|
24
29
|
export {};
|
|
@@ -3,7 +3,6 @@ import { useState, useCallback } from "react";
|
|
|
3
3
|
import { useIntl, FormattedMessage } from "react-intl";
|
|
4
4
|
import { Button } from "@mui/material";
|
|
5
5
|
import { useCSVReader } from "react-papaparse";
|
|
6
|
-
import { equalsArrayAnyOrder } from "../../../utils/algos.js";
|
|
7
6
|
import "../../../utils/conversionUtils.js";
|
|
8
7
|
import "../../../utils/types/equipmentType.js";
|
|
9
8
|
import { hasNonEmptyRows } from "../../../utils/functions.js";
|
|
@@ -12,7 +11,7 @@ import "@mui/icons-material";
|
|
|
12
11
|
import { CsvPickerConfirmationDialog } from "./csv-picker-confirmation-dialog.js";
|
|
13
12
|
function CsvPicker({
|
|
14
13
|
label,
|
|
15
|
-
|
|
14
|
+
requiredColumns,
|
|
16
15
|
maxLineNumber,
|
|
17
16
|
disabled = false,
|
|
18
17
|
language,
|
|
@@ -30,12 +29,14 @@ function CsvPicker({
|
|
|
30
29
|
const [pendingImport, setPendingImport] = useState(null);
|
|
31
30
|
const handleUploadAccepted = useCallback(
|
|
32
31
|
(results, acceptedFile) => {
|
|
32
|
+
const actualHeader = Object.keys(results.data[0] ?? {});
|
|
33
|
+
const isHeaderValid = requiredColumns.every((column) => actualHeader.includes(column));
|
|
33
34
|
if (results.data.length === 0) {
|
|
34
35
|
onFileError(intl.formatMessage({ id: "noDataInCsvFile" }, { filename: acceptedFile.name }));
|
|
35
|
-
} else if (!
|
|
36
|
+
} else if (!isHeaderValid) {
|
|
36
37
|
console.warn("Wrong CSV headers");
|
|
37
|
-
console.warn("
|
|
38
|
-
console.warn("Actual:",
|
|
38
|
+
console.warn("Required:", requiredColumns);
|
|
39
|
+
console.warn("Actual:", actualHeader);
|
|
39
40
|
onFileError(intl.formatMessage({ id: "wrongCsvHeadersError" }, { filename: acceptedFile.name }));
|
|
40
41
|
} else if (maxLineNumber && results.data.length > maxLineNumber) {
|
|
41
42
|
onFileError(
|
|
@@ -59,7 +60,7 @@ function CsvPicker({
|
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
},
|
|
62
|
-
[
|
|
63
|
+
[requiredColumns, intl, maxLineNumber, onAppend, onComplete, onFileChange, onFileError, onReplace, getTableData]
|
|
63
64
|
);
|
|
64
65
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
65
66
|
/* @__PURE__ */ jsx(
|
package/dist/index.js
CHANGED
|
@@ -454,7 +454,6 @@ import { errorsEn } from "./translations/en/errorsEn.js";
|
|
|
454
454
|
import { filterEn } from "./translations/en/filterEn.js";
|
|
455
455
|
import { filterExpertEn } from "./translations/en/filterExpertEn.js";
|
|
456
456
|
import { flatParametersEn } from "./translations/en/flatParametersEn.js";
|
|
457
|
-
import { inputsEn } from "./translations/en/inputsEn.js";
|
|
458
457
|
import { loginEn } from "./translations/en/loginEn.js";
|
|
459
458
|
import { multipleSelectionDialogEn } from "./translations/en/multipleSelectionDialogEn.js";
|
|
460
459
|
import { reportViewerEn } from "./translations/en/reportViewerEn.js";
|
|
@@ -485,7 +484,6 @@ import { errorsFr } from "./translations/fr/errorsFr.js";
|
|
|
485
484
|
import { filterExpertFr } from "./translations/fr/filterExpertFr.js";
|
|
486
485
|
import { filterFr } from "./translations/fr/filterFr.js";
|
|
487
486
|
import { flatParametersFr } from "./translations/fr/flatParametersFr.js";
|
|
488
|
-
import { inputsFr } from "./translations/fr/inputsFr.js";
|
|
489
487
|
import { loginFr } from "./translations/fr/loginFr.js";
|
|
490
488
|
import { multipleSelectionDialogFr } from "./translations/fr/multipleSelectionDialogFr.js";
|
|
491
489
|
import { reportViewerFr } from "./translations/fr/reportViewerFr.js";
|
|
@@ -1453,8 +1451,6 @@ export {
|
|
|
1453
1451
|
initializeAuthenticationProd,
|
|
1454
1452
|
initializeDirectory,
|
|
1455
1453
|
initializedProperty,
|
|
1456
|
-
inputsEn,
|
|
1457
|
-
inputsFr,
|
|
1458
1454
|
intlInitialVoltageProfileMode,
|
|
1459
1455
|
intlPredefinedParametersOptions,
|
|
1460
1456
|
isBlankOrEmpty,
|
|
@@ -21,7 +21,6 @@ export * from './errorsEn';
|
|
|
21
21
|
export * from './filterEn';
|
|
22
22
|
export * from './filterExpertEn';
|
|
23
23
|
export * from './flatParametersEn';
|
|
24
|
-
export * from './inputsEn';
|
|
25
24
|
export * from './loginEn';
|
|
26
25
|
export * from './multipleSelectionDialogEn';
|
|
27
26
|
export * from './reportViewerEn';
|
|
@@ -15,7 +15,6 @@ import { errorsEn } from "./errorsEn.js";
|
|
|
15
15
|
import { filterEn } from "./filterEn.js";
|
|
16
16
|
import { filterExpertEn } from "./filterExpertEn.js";
|
|
17
17
|
import { flatParametersEn } from "./flatParametersEn.js";
|
|
18
|
-
import { inputsEn } from "./inputsEn.js";
|
|
19
18
|
import { loginEn } from "./loginEn.js";
|
|
20
19
|
import { multipleSelectionDialogEn } from "./multipleSelectionDialogEn.js";
|
|
21
20
|
import { reportViewerEn } from "./reportViewerEn.js";
|
|
@@ -50,7 +49,6 @@ export {
|
|
|
50
49
|
filterExpertEn,
|
|
51
50
|
flatParametersEn,
|
|
52
51
|
importParamsEn,
|
|
53
|
-
inputsEn,
|
|
54
52
|
loginEn,
|
|
55
53
|
multipleSelectionDialogEn,
|
|
56
54
|
networkModificationsEn,
|
|
@@ -21,7 +21,6 @@ export * from './errorsFr';
|
|
|
21
21
|
export * from './filterExpertFr';
|
|
22
22
|
export * from './filterFr';
|
|
23
23
|
export * from './flatParametersFr';
|
|
24
|
-
export * from './inputsFr';
|
|
25
24
|
export * from './loginFr';
|
|
26
25
|
export * from './multipleSelectionDialogFr';
|
|
27
26
|
export * from './reportViewerFr';
|
|
@@ -15,7 +15,6 @@ import { errorsFr } from "./errorsFr.js";
|
|
|
15
15
|
import { filterExpertFr } from "./filterExpertFr.js";
|
|
16
16
|
import { filterFr } from "./filterFr.js";
|
|
17
17
|
import { flatParametersFr } from "./flatParametersFr.js";
|
|
18
|
-
import { inputsFr } from "./inputsFr.js";
|
|
19
18
|
import { loginFr } from "./loginFr.js";
|
|
20
19
|
import { multipleSelectionDialogFr } from "./multipleSelectionDialogFr.js";
|
|
21
20
|
import { reportViewerFr } from "./reportViewerFr.js";
|
|
@@ -50,7 +49,6 @@ export {
|
|
|
50
49
|
filterFr,
|
|
51
50
|
flatParametersFr,
|
|
52
51
|
importParamsFr,
|
|
53
|
-
inputsFr,
|
|
54
52
|
loginFr,
|
|
55
53
|
multipleSelectionDialogFr,
|
|
56
54
|
networkModificationsFr,
|
package/package.json
CHANGED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2022, 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 const inputsEn: {
|
|
8
|
-
'inputs/kiki': string;
|
|
9
|
-
'inputs/ney': string;
|
|
10
|
-
'inputs/lapulga': string;
|
|
11
|
-
'inputs/ibra': string;
|
|
12
|
-
'inputs/float': string;
|
|
13
|
-
'inputs/integer': string;
|
|
14
|
-
'inputs/radio': string;
|
|
15
|
-
'inputs/select': string;
|
|
16
|
-
'inputs/slider': string;
|
|
17
|
-
'inputs/text': string;
|
|
18
|
-
'inputs/description': string;
|
|
19
|
-
'inputs/autocomplete': string;
|
|
20
|
-
'inputs/boolean': string;
|
|
21
|
-
'inputs/checkbox': string;
|
|
22
|
-
'inputs/switch': string;
|
|
23
|
-
'inputs/directory-items': string;
|
|
24
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const inputsEn = {
|
|
2
|
-
"inputs/kiki": "Kylian Mbappe",
|
|
3
|
-
"inputs/ney": "Neymar",
|
|
4
|
-
"inputs/lapulga": "Lionel Messi",
|
|
5
|
-
"inputs/ibra": "Zlatan Ibrahimovic",
|
|
6
|
-
"inputs/float": "Float",
|
|
7
|
-
"inputs/integer": "Integer",
|
|
8
|
-
"inputs/radio": "Radio",
|
|
9
|
-
"inputs/select": "Select",
|
|
10
|
-
"inputs/slider": "Slider",
|
|
11
|
-
"inputs/text": "Text",
|
|
12
|
-
"inputs/description": "Description",
|
|
13
|
-
"inputs/autocomplete": "Autocomplete",
|
|
14
|
-
"inputs/boolean": "Boolean",
|
|
15
|
-
"inputs/checkbox": "Checkbox",
|
|
16
|
-
"inputs/switch": "Switch",
|
|
17
|
-
"inputs/directory-items": "Directory items"
|
|
18
|
-
};
|
|
19
|
-
export {
|
|
20
|
-
inputsEn
|
|
21
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2022, 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 const inputsFr: {
|
|
8
|
-
'inputs/kiki': string;
|
|
9
|
-
'inputs/ney': string;
|
|
10
|
-
'inputs/lapulga': string;
|
|
11
|
-
'inputs/ibra': string;
|
|
12
|
-
'inputs/float': string;
|
|
13
|
-
'inputs/integer': string;
|
|
14
|
-
'inputs/radio': string;
|
|
15
|
-
'inputs/select': string;
|
|
16
|
-
'inputs/slider': string;
|
|
17
|
-
'inputs/text': string;
|
|
18
|
-
'inputs/description': string;
|
|
19
|
-
'inputs/autocomplete': string;
|
|
20
|
-
'inputs/boolean': string;
|
|
21
|
-
'inputs/checkbox': string;
|
|
22
|
-
'inputs/switch': string;
|
|
23
|
-
'inputs/directory-items': string;
|
|
24
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const inputsFr = {
|
|
2
|
-
"inputs/kiki": "Kylian Mbappe",
|
|
3
|
-
"inputs/ney": "Neymar",
|
|
4
|
-
"inputs/lapulga": "Lionel Messi",
|
|
5
|
-
"inputs/ibra": "Zlatan Ibrahimovic",
|
|
6
|
-
"inputs/float": "Float",
|
|
7
|
-
"inputs/integer": "Integer",
|
|
8
|
-
"inputs/radio": "Radio",
|
|
9
|
-
"inputs/select": "Select",
|
|
10
|
-
"inputs/slider": "Slider",
|
|
11
|
-
"inputs/text": "Text",
|
|
12
|
-
"inputs/description": "Description",
|
|
13
|
-
"inputs/autocomplete": "Autocomplete",
|
|
14
|
-
"inputs/boolean": "Boolean",
|
|
15
|
-
"inputs/checkbox": "Checkbox",
|
|
16
|
-
"inputs/switch": "Switch",
|
|
17
|
-
"inputs/directory-items": "Éléments du répertoire"
|
|
18
|
-
};
|
|
19
|
-
export {
|
|
20
|
-
inputsFr
|
|
21
|
-
};
|