@gridsuite/commons-ui 0.228.0 → 0.229.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.
Files changed (180) hide show
  1. package/dist/components/composite/agGridTable/BottomTableButtons.d.ts +13 -0
  2. package/dist/components/composite/agGridTable/BottomTableButtons.js +92 -0
  3. package/dist/components/composite/agGridTable/CustomAgGridTable.d.ts +3 -2
  4. package/dist/components/composite/agGridTable/CustomAgGridTable.js +16 -38
  5. package/dist/components/composite/agGridTable/agGridTable-utils.d.ts +9 -0
  6. package/dist/components/composite/agGridTable/agGridTable-utils.js +1 -0
  7. package/dist/components/composite/agGridTable/cellEditors/index.js +3 -2
  8. package/dist/components/composite/agGridTable/cellEditors/numericEditor.d.ts +21 -19
  9. package/dist/components/composite/agGridTable/cellEditors/numericEditor.js +44 -57
  10. package/dist/components/composite/agGridTable/index.d.ts +2 -2
  11. package/dist/components/composite/agGridTable/index.js +5 -6
  12. package/dist/components/composite/dnd-table/dnd-table-add-rows-dialog.js +1 -0
  13. package/dist/components/composite/dnd-table/dnd-table-row.js +1 -0
  14. package/dist/components/composite/dnd-table/dnd-table.js +1 -0
  15. package/dist/components/composite/filter/HeaderFilterForm.js +1 -0
  16. package/dist/components/composite/filter/expert/ExpertFilterForm.js +1 -0
  17. package/dist/components/composite/filter/explicitNaming/ExplicitNamingFilterForm.js +122 -91
  18. package/dist/components/composite/index.js +4 -5
  19. package/dist/components/index.js +6 -5
  20. package/dist/components/ui/csvDownloader/use-csv-export.js +2 -2
  21. package/dist/components/ui/csvPicker/csv-picker-confirmation-dialog.d.ts +11 -0
  22. package/dist/components/ui/csvPicker/csv-picker-confirmation-dialog.js +65 -0
  23. package/dist/components/ui/csvPicker/csv-picker.d.ts +24 -0
  24. package/dist/components/ui/csvPicker/csv-picker.js +123 -0
  25. package/dist/components/{composite/agGridTable/csvUploader → ui/csvPicker}/index.d.ts +2 -2
  26. package/dist/components/ui/csvPicker/index.js +4 -0
  27. package/dist/components/ui/index.d.ts +1 -0
  28. package/dist/components/ui/index.js +2 -0
  29. package/dist/features/index.js +1 -0
  30. package/dist/features/network-modifications/battery/creation/BatteryCreationForm.js +2 -3
  31. package/dist/features/network-modifications/battery/creation/batteryCreation.utils.js +2 -3
  32. package/dist/features/network-modifications/battery/modification/BatteryDialogHeader.js +2 -3
  33. package/dist/features/network-modifications/battery/modification/BatteryDialogTabsContent.js +2 -3
  34. package/dist/features/network-modifications/battery/modification/batteryModification.utils.js +2 -3
  35. package/dist/features/network-modifications/by-filter/assignment/assignment/assignment-form.js +1 -0
  36. package/dist/features/network-modifications/by-filter/assignment/modification-by-assignment-form.js +1 -0
  37. package/dist/features/network-modifications/by-filter/deletion/ByFilterDeletionForm.js +1 -0
  38. package/dist/features/network-modifications/common/activePowerControl/ActivePowerControlForm.js +1 -0
  39. package/dist/features/network-modifications/common/connectivity/ConnectivityForm.js +1 -0
  40. package/dist/features/network-modifications/common/connectivity/PositionForm.js +1 -0
  41. package/dist/features/network-modifications/common/connectivity/VoltageLevelConnectivityForm.js +1 -0
  42. package/dist/features/network-modifications/common/measurements/BusbarSectionVoltageMeasurementsForm.js +2 -3
  43. package/dist/features/network-modifications/common/measurements/PowerWithValidityForm.js +1 -0
  44. package/dist/features/network-modifications/common/properties/PropertiesForm.js +1 -0
  45. package/dist/features/network-modifications/common/properties/PropertyForm.js +1 -0
  46. package/dist/features/network-modifications/common/reactiveLimits/ReactiveLimitsForm.js +1 -0
  47. package/dist/features/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/ReactiveCapabilityCurveRowForm.js +1 -0
  48. package/dist/features/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/ReactiveCapabilityCurveTableForm.js +1 -0
  49. package/dist/features/network-modifications/common/regulatingTerminal/RegulatingTerminalForm.js +1 -0
  50. package/dist/features/network-modifications/common/setpoints/SetPointsForm.js +1 -0
  51. package/dist/features/network-modifications/common/shortCircuit/ShortCircuitForm.js +1 -0
  52. package/dist/features/network-modifications/common/voltageRegulation/VoltageRegulationForm.js +1 -0
  53. package/dist/features/network-modifications/equipmentDeletion/EquipmentDeletionForm.js +2 -3
  54. package/dist/features/network-modifications/equipmentDeletion/equipmentDeletion.utils.js +1 -0
  55. package/dist/features/network-modifications/equipmentDeletion/hvdcLccDeletion/ShuntCompensatorSelectionForm.js +1 -0
  56. package/dist/features/network-modifications/generator/creation/GeneratorCreationForm.js +2 -3
  57. package/dist/features/network-modifications/generator/creation/generatorCreation.utils.js +2 -3
  58. package/dist/features/network-modifications/generator/modification/GeneratorDialogHeader.js +2 -3
  59. package/dist/features/network-modifications/generator/modification/GeneratorDialogTabsContent.js +2 -3
  60. package/dist/features/network-modifications/generator/modification/generatorModification.utils.js +2 -3
  61. package/dist/features/network-modifications/index.js +1 -0
  62. package/dist/features/network-modifications/load/common/LoadDialogHeader.js +2 -3
  63. package/dist/features/network-modifications/load/creation/loadCreation.utils.js +1 -0
  64. package/dist/features/network-modifications/load/modification/loadModification.utils.js +2 -3
  65. package/dist/features/network-modifications/shunt-compensator/common/CharacteristicsForm.js +1 -0
  66. package/dist/features/network-modifications/shunt-compensator/creation/ShuntCompensatorCreationForm.js +2 -3
  67. package/dist/features/network-modifications/shunt-compensator/creation/shuntCompensatorCreation.utils.js +2 -3
  68. package/dist/features/network-modifications/shunt-compensator/modification/ShuntCompensatorModificationForm.js +2 -3
  69. package/dist/features/network-modifications/shunt-compensator/modification/shuntCompensatorModification.utils.js +2 -3
  70. package/dist/features/network-modifications/substation/creation/SubstationCreationForm.js +2 -3
  71. package/dist/features/network-modifications/substation/modification/SubstationModificationForm.js +2 -3
  72. package/dist/features/network-modifications/voltageLevel/creation/VoltageLevelCreationForm.js +2 -3
  73. package/dist/features/network-modifications/voltageLevel/creation/index.js +2 -3
  74. package/dist/features/network-modifications/voltageLevel/creation/tabs/characteristicsTab/CharacteristicsTab.js +1 -0
  75. package/dist/features/network-modifications/voltageLevel/creation/tabs/structureTab/StructureTab.js +1 -0
  76. package/dist/features/network-modifications/voltageLevel/creation/tabs/structureTab/couplingOmnibus/CouplingOmnibusForm.js +1 -0
  77. package/dist/features/network-modifications/voltageLevel/creation/tabs/structureTab/switchesBetweenSections/SwitchesBetweenSections.js +1 -0
  78. package/dist/features/network-modifications/voltageLevel/creation/tabs/substationTab/SubstationCreationSection.js +2 -3
  79. package/dist/features/network-modifications/voltageLevel/creation/tabs/substationTab/SubstationTab.js +1 -0
  80. package/dist/features/network-modifications/voltageLevel/creation/voltageLevelCreation.utils.js +2 -3
  81. package/dist/features/network-modifications/voltageLevel/index.js +2 -3
  82. package/dist/features/network-modifications/voltageLevel/modification/VoltageLevelModificationForm.js +2 -3
  83. package/dist/features/parameters/common/ProviderParam.js +1 -0
  84. package/dist/features/parameters/common/contingency-table/columns-definitions.js +1 -0
  85. package/dist/features/parameters/common/limitreductions/limit-reduction-table-cell.js +1 -0
  86. package/dist/features/parameters/common/limitreductions/limit-reductions-table-form.js +1 -0
  87. package/dist/features/parameters/common/name-element-editor/name-element-editor-utils.js +1 -0
  88. package/dist/features/parameters/common/parameter-field.js +1 -0
  89. package/dist/features/parameters/common/parameter-table-field/parameter-table-field.js +1 -0
  90. package/dist/features/parameters/common/voltage-level-table/custom-voltage-level-table-cell.js +1 -0
  91. package/dist/features/parameters/common/widget/parameter-float.js +1 -0
  92. package/dist/features/parameters/common/widget/parameter-line-directory-items-input.js +1 -0
  93. package/dist/features/parameters/common/widget/parameter-line-slider.js +1 -0
  94. package/dist/features/parameters/dynamic-margin-calculation/dynamic-margin-calculation-form.js +1 -0
  95. package/dist/features/parameters/dynamic-margin-calculation/dynamic-margin-calculation-inline.js +1 -0
  96. package/dist/features/parameters/dynamic-margin-calculation/loads-variations-parameters.js +1 -0
  97. package/dist/features/parameters/dynamic-margin-calculation/use-dynamic-margin-calculation-parameters-form.js +1 -0
  98. package/dist/features/parameters/dynamic-security-analysis/contingency-parameters.js +1 -0
  99. package/dist/features/parameters/dynamic-security-analysis/dynamic-security-analysis-inline.js +1 -0
  100. package/dist/features/parameters/dynamic-security-analysis/dynamic-security-analysis-parameters-form.js +1 -0
  101. package/dist/features/parameters/dynamic-security-analysis/use-dynamic-security-analysis-parameters-form.js +1 -0
  102. package/dist/features/parameters/dynamic-simulation/dynamic-simulation-inline.js +1 -0
  103. package/dist/features/parameters/dynamic-simulation/dynamic-simulation-parameters-form.js +1 -0
  104. package/dist/features/parameters/dynamic-simulation/use-dynamic-simulation-parameters-form.js +1 -0
  105. package/dist/features/parameters/loadflow/load-flow-general-parameters.js +1 -0
  106. package/dist/features/parameters/loadflow/load-flow-parameters-content.js +1 -0
  107. package/dist/features/parameters/loadflow/load-flow-parameters-dialog.js +1 -0
  108. package/dist/features/parameters/loadflow/load-flow-parameters-form.js +1 -0
  109. package/dist/features/parameters/loadflow/load-flow-parameters-header.js +1 -0
  110. package/dist/features/parameters/loadflow/load-flow-parameters-inline.js +1 -0
  111. package/dist/features/parameters/loadflow/load-flow-parameters-utils.js +1 -0
  112. package/dist/features/parameters/loadflow/use-load-flow-parameters-form.js +1 -0
  113. package/dist/features/parameters/network-visualizations/map-parameters.js +1 -0
  114. package/dist/features/parameters/network-visualizations/network-area-diagram-parameters.js +1 -0
  115. package/dist/features/parameters/network-visualizations/network-visualizations-form.js +1 -0
  116. package/dist/features/parameters/network-visualizations/network-visualizations-parameters-dialog.js +1 -0
  117. package/dist/features/parameters/network-visualizations/network-visualizations-parameters-inline.js +1 -0
  118. package/dist/features/parameters/network-visualizations/single-line-diagram-parameters.js +1 -0
  119. package/dist/features/parameters/network-visualizations/use-network-visualizations-parameters-form.js +1 -0
  120. package/dist/features/parameters/pcc-min/pcc-min-form-utils.js +1 -0
  121. package/dist/features/parameters/pcc-min/pcc-min-parameters-dialog.js +1 -0
  122. package/dist/features/parameters/pcc-min/pcc-min-parameters-form.js +1 -0
  123. package/dist/features/parameters/pcc-min/pcc-min-parameters-inline.js +1 -0
  124. package/dist/features/parameters/pcc-min/use-pcc-min-parameters-form.js +1 -0
  125. package/dist/features/parameters/security-analysis/columns-definitions.js +1 -0
  126. package/dist/features/parameters/security-analysis/security-analysis-parameters-dialog.js +1 -0
  127. package/dist/features/parameters/security-analysis/security-analysis-parameters-form.js +1 -0
  128. package/dist/features/parameters/security-analysis/security-analysis-parameters-inline.js +1 -0
  129. package/dist/features/parameters/security-analysis/security-analysis-parameters-selector.js +1 -0
  130. package/dist/features/parameters/security-analysis/security-analysis-violations-hiding.js +1 -0
  131. package/dist/features/parameters/security-analysis/use-security-analysis-parameters-form.js +1 -0
  132. package/dist/features/parameters/sensi/columns-definitions.js +1 -0
  133. package/dist/features/parameters/sensi/sensitivity-analysis-parameters-dialog.js +1 -0
  134. package/dist/features/parameters/sensi/sensitivity-analysis-parameters-form.js +1 -0
  135. package/dist/features/parameters/sensi/sensitivity-analysis-parameters-inline.js +1 -0
  136. package/dist/features/parameters/sensi/sensitivity-parameters-fields.js +1 -0
  137. package/dist/features/parameters/sensi/sensitivity-parameters-selector.js +33 -4
  138. package/dist/features/parameters/sensi/use-sensitivity-analysis-parameters.js +1 -0
  139. package/dist/features/parameters/sensi/utils.js +1 -0
  140. package/dist/features/parameters/short-circuit/short-circuit-general-tab-panel.js +1 -0
  141. package/dist/features/parameters/short-circuit/short-circuit-icc-cluster-table-cell.js +1 -0
  142. package/dist/features/parameters/short-circuit/short-circuit-icc-material-table-cell.js +1 -0
  143. package/dist/features/parameters/short-circuit/short-circuit-parameters-content.js +1 -0
  144. package/dist/features/parameters/short-circuit/short-circuit-parameters-dialog.js +1 -0
  145. package/dist/features/parameters/short-circuit/short-circuit-parameters-form.js +1 -0
  146. package/dist/features/parameters/short-circuit/short-circuit-parameters-inline.js +1 -0
  147. package/dist/features/parameters/short-circuit/short-circuit-parameters-utils.js +1 -0
  148. package/dist/features/parameters/short-circuit/short-circuit-power-electronics-tab-panel.js +1 -0
  149. package/dist/features/parameters/short-circuit/short-circuit-study-area-tab-panel.js +1 -0
  150. package/dist/features/parameters/short-circuit/use-short-circuit-parameters-form.js +1 -0
  151. package/dist/features/parameters/voltage-init/equipment-selection-parameters.js +1 -0
  152. package/dist/features/parameters/voltage-init/general-parameters.js +1 -0
  153. package/dist/features/parameters/voltage-init/use-voltage-init-parameters-form.js +1 -0
  154. package/dist/features/parameters/voltage-init/voltage-init-form-utils.js +1 -0
  155. package/dist/features/parameters/voltage-init/voltage-init-parameters-dialog.js +1 -0
  156. package/dist/features/parameters/voltage-init/voltage-init-parameters-form.js +1 -0
  157. package/dist/features/parameters/voltage-init/voltage-init-parameters-inline.js +1 -0
  158. package/dist/features/parameters/voltage-init/voltage-limits-parameters.js +1 -0
  159. package/dist/index.js +12 -8
  160. package/dist/translations/en/commonButtonEn.d.ts +2 -0
  161. package/dist/translations/en/commonButtonEn.js +2 -0
  162. package/dist/translations/en/csvEn.d.ts +2 -1
  163. package/dist/translations/en/csvEn.js +5 -4
  164. package/dist/translations/fr/commonButtonFr.d.ts +2 -0
  165. package/dist/translations/fr/commonButtonFr.js +2 -0
  166. package/dist/translations/fr/csvFr.d.ts +2 -1
  167. package/dist/translations/fr/csvFr.js +6 -5
  168. package/dist/utils/algos.d.ts +1 -0
  169. package/dist/utils/algos.js +13 -1
  170. package/dist/utils/functions.d.ts +5 -0
  171. package/dist/utils/functions.js +5 -0
  172. package/dist/utils/index.js +6 -3
  173. package/dist/utils/langs.d.ts +1 -0
  174. package/dist/utils/langs.js +5 -1
  175. package/package.json +1 -2
  176. package/dist/components/composite/agGridTable/BottomRightButtons.d.ts +0 -14
  177. package/dist/components/composite/agGridTable/BottomRightButtons.js +0 -62
  178. package/dist/components/composite/agGridTable/csvUploader/CsvUploader.d.ts +0 -15
  179. package/dist/components/composite/agGridTable/csvUploader/CsvUploader.js +0 -182
  180. package/dist/components/composite/agGridTable/csvUploader/index.js +0 -4
@@ -1,6 +1,8 @@
1
1
  const commonButtonFr = {
2
2
  cancel: "Annuler",
3
3
  validate: "Valider",
4
+ add: "Ajouter",
5
+ replace: "Remplacer",
4
6
  "button.changeType": "Modifier",
5
7
  "button.changeOperator": "Modifier",
6
8
  "button.restore": "Restaurer"
@@ -5,11 +5,12 @@
5
5
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
6
  */
7
7
  export declare const csvFr: {
8
- ImportCSV: string;
9
8
  noDataInCsvFile: string;
10
9
  wrongCsvHeadersError: string;
11
10
  keepCSVDataMessage: string;
12
11
  GenerateCSV: string;
12
+ DownloadCSV: string;
13
13
  UploadCSV: string;
14
14
  uploadMessage: string;
15
+ tooManyLinesInCsvFile: string;
15
16
  };
@@ -1,11 +1,12 @@
1
1
  const csvFr = {
2
- ImportCSV: "Import CSV",
3
- noDataInCsvFile: "Aucune donnée trouvée dans ce fichier",
4
- wrongCsvHeadersError: "Les en-têtes du fichier CSV sont incorrects. Utilisez le bouton Générer le modèle CSV pour obtenir le format CSV pris en charge",
2
+ noDataInCsvFile: 'Aucune donnée trouvée dans le fichier "{filename}"',
3
+ wrongCsvHeadersError: 'Les en-têtes du fichier "{filename}" sont incorrects. Utilisez le bouton Générer le modèle CSV pour obtenir le format CSV pris en charge',
5
4
  keepCSVDataMessage: "Voulez-vous remplacer la liste existante ou y ajouter les nouvelles données ?",
6
5
  GenerateCSV: "Générer le modèle CSV",
7
- UploadCSV: "Télécharger le CSV",
8
- uploadMessage: " Aucun fichier sélectionné"
6
+ DownloadCSV: "Télécharger en CSV",
7
+ UploadCSV: "Charger un CSV",
8
+ uploadMessage: " Aucun fichier sélectionné",
9
+ tooManyLinesInCsvFile: 'Le nombre de lignes dans le fichier "{filename}" ne doit pas dépasser {value}'
9
10
  };
10
11
  export {
11
12
  csvFr
@@ -5,3 +5,4 @@
5
5
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
6
  */
7
7
  export declare function equalsArray<T>(a: T[] | null, b: T[]): boolean;
8
+ export declare function equalsArrayAnyOrder<T>(a: T[] | null, b: T[] | null): boolean;
@@ -21,6 +21,18 @@ function equalsArray(a, b) {
21
21
  }
22
22
  return true;
23
23
  }
24
+ function equalsArrayAnyOrder(a, b) {
25
+ if (a === b) {
26
+ return true;
27
+ }
28
+ if (!a || !b || a.length !== b.length) {
29
+ return false;
30
+ }
31
+ const sortedA = [...a].sort();
32
+ const sortedB = [...b].sort();
33
+ return sortedA.every((value, index) => value === sortedB[index]);
34
+ }
24
35
  export {
25
- equalsArray
36
+ equalsArray,
37
+ equalsArrayAnyOrder
26
38
  };
@@ -4,6 +4,11 @@
4
4
  * License, v. 2.0. If a copy of the MPL was not distributed with this
5
5
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
6
  */
7
+ /**
8
+ * Returns true when the given form rows contain at least one cell with a
9
+ * non-empty value (excluding the AG_GRID_ROW_UUID identifier column).
10
+ */
11
+ export declare const hasNonEmptyRows: (rows: unknown) => boolean;
7
12
  /**
8
13
  * function to generate a key
9
14
  * @returns {number} key
@@ -1,3 +1,7 @@
1
+ import { FieldConstants } from "./constants/fieldConstants.js";
2
+ const hasNonEmptyRows = (rows) => Array.isArray(rows) && rows.some(
3
+ (row) => row && Object.keys(row).filter((key) => key !== FieldConstants.AG_GRID_ROW_UUID).some((key) => row[key] !== void 0 && row[key] !== null && String(row[key]).trim().length > 0)
4
+ );
1
5
  function keyGenerator() {
2
6
  let key = 1;
3
7
  return () => {
@@ -19,6 +23,7 @@ const isObjectEmpty = (object) => object && Object.keys(object).length === 0;
19
23
  export {
20
24
  areArrayElementsUnique,
21
25
  arraysContainIdenticalStrings,
26
+ hasNonEmptyRows,
22
27
  isEmpty,
23
28
  isObjectEmpty,
24
29
  keyGenerator
@@ -1,4 +1,4 @@
1
- import { equalsArray } from "./algos.js";
1
+ import { equalsArray, equalsArrayAnyOrder } from "./algos.js";
2
2
  import { ActivePowerAdornment, AmpereAdornment, KiloAmpereAdornment, KilometerAdornment, MVAPowerAdornment, MicroSusceptanceAdornment, OhmAdornment, PercentageAdornment, ReactivePowerAdornment, SusceptanceAdornment, VoltageAdornment } from "./constants/adornments.js";
3
3
  import { FetchStatus } from "./constants/fetchStatus.js";
4
4
  import { FieldConstants } from "./constants/fieldConstants.js";
@@ -9,9 +9,9 @@ import { FILTERS, FILTER_ID, FILTER_NAME, ID } from "./constants/filterConstant.
9
9
  import { DUPLICATED_PROPS_ERROR, YUP_DEFAULT, YUP_NOT_NULL, YUP_NOT_TYPE_DEFAULT, YUP_NOT_TYPE_NUMBER, YUP_POSITIVE, YUP_REQUIRED } from "./constants/translationKeys.js";
10
10
  import { GRIDSUITE_DEFAULT_PRECISION, convertInputValue, convertOutputValue, isBlankOrEmpty, kiloUnitToUnit, microUnitToUnit, roundToDefaultPrecision, roundToPrecision, toModificationOperation, unitToKiloUnit, unitToMicroUnit } from "./conversionUtils.js";
11
11
  import { catchErrorHandler, extractErrorMessageDescriptor, snackWithFallback } from "./error.js";
12
- import { areArrayElementsUnique, arraysContainIdenticalStrings, isEmpty, isObjectEmpty, keyGenerator } from "./functions.js";
12
+ import { areArrayElementsUnique, arraysContainIdenticalStrings, hasNonEmptyRows, isEmpty, isObjectEmpty, keyGenerator } from "./functions.js";
13
13
  import { getEquipmentTypeShortLabel } from "./labelUtils.js";
14
- import { LANG_ENGLISH, LANG_FRENCH, LANG_SYSTEM } from "./langs.js";
14
+ import { LANG_ENGLISH, LANG_FRENCH, LANG_SYSTEM, getCsvDelimiter } from "./langs.js";
15
15
  import { getFileIcon } from "./mapper/getFileIcon.js";
16
16
  import { equipmentTypesForPredefinedPropertiesMapper } from "./mapper/equipmentTypesForPredefinedPropertiesMapper.js";
17
17
  import { copyToClipboard } from "./navigator-clipboard.js";
@@ -150,10 +150,12 @@ export {
150
150
  convertOutputValue,
151
151
  copyToClipboard,
152
152
  equalsArray,
153
+ equalsArrayAnyOrder,
153
154
  equipmentStyles,
154
155
  equipmentTypesForPredefinedPropertiesMapper,
155
156
  extractErrorMessageDescriptor,
156
157
  getConnectionDirectionLabel,
158
+ getCsvDelimiter,
157
159
  getEnergySourceLabel,
158
160
  getEquipmentTypeShortLabel,
159
161
  getEquipmentsInfosForSearchBar,
@@ -163,6 +165,7 @@ export {
163
165
  getLabelOrValue,
164
166
  getLoadTypeLabel,
165
167
  getObjectId,
168
+ hasNonEmptyRows,
166
169
  isBlankOrEmpty,
167
170
  isEmpty,
168
171
  isInjection,
@@ -3,3 +3,4 @@ export declare const LANG_ENGLISH = "en";
3
3
  export declare const LANG_FRENCH = "fr";
4
4
  export type GsLangUser = typeof LANG_ENGLISH | typeof LANG_FRENCH;
5
5
  export type GsLang = GsLangUser | typeof LANG_SYSTEM;
6
+ export declare function getCsvDelimiter(language: string | undefined): ';' | ',';
@@ -1,8 +1,12 @@
1
1
  const LANG_SYSTEM = "sys";
2
2
  const LANG_ENGLISH = "en";
3
3
  const LANG_FRENCH = "fr";
4
+ function getCsvDelimiter(language) {
5
+ return language === LANG_FRENCH ? ";" : ",";
6
+ }
4
7
  export {
5
8
  LANG_ENGLISH,
6
9
  LANG_FRENCH,
7
- LANG_SYSTEM
10
+ LANG_SYSTEM,
11
+ getCsvDelimiter
8
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.228.0",
3
+ "version": "0.229.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",
@@ -58,7 +58,6 @@
58
58
  "mui-nested-menu": "^4.0.1",
59
59
  "oidc-client-ts": "^3.5.0",
60
60
  "prop-types": "^15.8.1",
61
- "react-csv-downloader": "^3.3.0",
62
61
  "react-dnd": "^16.0.1",
63
62
  "react-dnd-html5-backend": "^16.0.1",
64
63
  "react-querybuilder": "^8.11.0",
@@ -1,14 +0,0 @@
1
- import { FieldValues, UseFieldArrayReturn } from 'react-hook-form';
2
- export interface BottomRightButtonsProps {
3
- name: string;
4
- disableUp: boolean;
5
- disableDown: boolean;
6
- disableDelete: boolean;
7
- handleAddRow: () => void;
8
- handleDeleteRows: () => void;
9
- handleMoveRowUp: () => void;
10
- handleMoveRowDown: () => void;
11
- useFieldArrayOutput: UseFieldArrayReturn<FieldValues, string, 'id'>;
12
- csvProps: any;
13
- }
14
- export declare function BottomRightButtons({ name, disableUp, disableDown, disableDelete, handleAddRow, handleDeleteRows, handleMoveRowUp, handleMoveRowDown, useFieldArrayOutput, csvProps, }: BottomRightButtonsProps): import("react/jsx-runtime").JSX.Element;
@@ -1,62 +0,0 @@
1
- import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
- import { styled, IconButton, Grid, Box } from "@mui/material";
3
- import { Upload, ControlPoint, Delete, ArrowCircleUp, ArrowCircleDown } from "@mui/icons-material";
4
- import { useState } from "react";
5
- import { useIntl } from "react-intl";
6
- import { CustomTooltip } from "../../ui/tooltip/CustomTooltip.js";
7
- import { ErrorInput } from "../../ui/reactHookForm/errorManagement/ErrorInput.js";
8
- import { FieldErrorAlert } from "../../ui/reactHookForm/errorManagement/FieldErrorAlert.js";
9
- import { CsvUploader } from "./csvUploader/CsvUploader.js";
10
- const InnerColoredButton = styled(IconButton)(({ theme }) => {
11
- return {
12
- color: theme.palette.primary.main
13
- };
14
- });
15
- function BottomRightButtons({
16
- name,
17
- disableUp,
18
- disableDown,
19
- disableDelete,
20
- handleAddRow,
21
- handleDeleteRows,
22
- handleMoveRowUp,
23
- handleMoveRowDown,
24
- useFieldArrayOutput,
25
- csvProps
26
- }) {
27
- const [uploaderOpen, setUploaderOpen] = useState(false);
28
- const intl = useIntl();
29
- return /* @__PURE__ */ jsxs(Fragment, { children: [
30
- /* @__PURE__ */ jsxs(Grid, { container: true, paddingTop: 1, paddingLeft: 2, children: [
31
- /* @__PURE__ */ jsx(Grid, { item: true, xs: 1, children: csvProps && /* @__PURE__ */ jsx(InnerColoredButton, { onClick: () => setUploaderOpen(true), children: /* @__PURE__ */ jsx(
32
- CustomTooltip,
33
- {
34
- title: intl.formatMessage({
35
- id: "ImportCSV"
36
- }),
37
- children: /* @__PURE__ */ jsx(Upload, {})
38
- }
39
- ) }) }),
40
- /* @__PURE__ */ jsxs(Grid, { item: true, xs: 11, sx: { display: "flex", justifyContent: "right" }, children: [
41
- /* @__PURE__ */ jsx(InnerColoredButton, { onClick: handleAddRow, children: /* @__PURE__ */ jsx(ControlPoint, {}) }, "addButton"),
42
- /* @__PURE__ */ jsx(InnerColoredButton, { onClick: handleDeleteRows, disabled: disableDelete, children: /* @__PURE__ */ jsx(Delete, {}) }, "DeleteButton"),
43
- /* @__PURE__ */ jsx(InnerColoredButton, { disabled: disableUp, onClick: handleMoveRowUp, children: /* @__PURE__ */ jsx(ArrowCircleUp, {}) }, "upButton"),
44
- /* @__PURE__ */ jsx(InnerColoredButton, { disabled: disableDown, onClick: handleMoveRowDown, children: /* @__PURE__ */ jsx(ArrowCircleDown, {}) }, "downButton")
45
- ] })
46
- ] }),
47
- /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(ErrorInput, { name, InputField: FieldErrorAlert }) }),
48
- /* @__PURE__ */ jsx(
49
- CsvUploader,
50
- {
51
- open: uploaderOpen,
52
- onClose: () => setUploaderOpen(false),
53
- name,
54
- useFieldArrayOutput,
55
- ...csvProps
56
- }
57
- )
58
- ] });
59
- }
60
- export {
61
- BottomRightButtons
62
- };
@@ -1,15 +0,0 @@
1
- import { GsLang } from '../../../../utils';
2
- export interface CsvUploaderProps {
3
- name: string;
4
- onClose: () => void;
5
- open: boolean;
6
- title: string[];
7
- fileHeaders: string[];
8
- fileName: string;
9
- csvData: unknown;
10
- validateData: (rows: string[][]) => boolean;
11
- getDataFromCsv: any;
12
- useFieldArrayOutput: any;
13
- language: GsLang;
14
- }
15
- export declare function CsvUploader({ name, onClose, open, title, fileHeaders, fileName, csvData, validateData, getDataFromCsv, useFieldArrayOutput, language, }: Readonly<CsvUploaderProps>): import("react/jsx-runtime").JSX.Element;
@@ -1,182 +0,0 @@
1
- import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
- import { Dialog, DialogTitle, DialogContent, Grid, Button, Alert, DialogActions, DialogContentText } from "@mui/material";
3
- import { useCSVReader, RECORD_SEP, UNIT_SEP } from "react-papaparse";
4
- import React, { useState, useMemo } from "react";
5
- import { useIntl, FormattedMessage } from "react-intl";
6
- import CsvDownloader from "react-csv-downloader";
7
- import { useWatch } from "react-hook-form";
8
- import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
9
- import "../../../../utils/conversionUtils.js";
10
- import "../../../../utils/types/equipmentType.js";
11
- import { LANG_FRENCH } from "../../../../utils/langs.js";
12
- import "@mui/icons-material";
13
- import { CancelButton } from "../../../ui/reactHookForm/utils/CancelButton.js";
14
- import "yup";
15
- function CsvUploader({
16
- name,
17
- onClose,
18
- open,
19
- title,
20
- fileHeaders,
21
- fileName,
22
- csvData,
23
- validateData = () => true,
24
- getDataFromCsv,
25
- useFieldArrayOutput,
26
- language
27
- }) {
28
- const watchTableValues = useWatch({ name });
29
- const { append, replace } = useFieldArrayOutput;
30
- const [createError, setCreateError] = React.useState("");
31
- const intl = useIntl();
32
- const { CSVReader } = useCSVReader();
33
- const [importedData, setImportedData] = useState([]);
34
- const [isConfirmationPopupOpen, setIsConfirmationPopupOpen] = useState(false);
35
- const data = useMemo(() => {
36
- const newData = [...[fileHeaders]];
37
- if (Array.isArray(csvData)) {
38
- csvData.forEach((row) => newData.push([row]));
39
- }
40
- return newData;
41
- }, [csvData, fileHeaders]);
42
- const handleClose = () => {
43
- onClose();
44
- setCreateError("");
45
- };
46
- const validateCsvFile = (rows) => {
47
- if (rows.length === 0) {
48
- setCreateError(intl.formatMessage({ id: "noDataInCsvFile" }));
49
- return false;
50
- }
51
- for (let i = 0; i < fileHeaders.length; i++) {
52
- if (fileHeaders[i] !== "" && rows[0][i] !== fileHeaders[i]) {
53
- setCreateError(intl.formatMessage({ id: "wrongCsvHeadersError" }));
54
- return false;
55
- }
56
- }
57
- return validateData(rows);
58
- };
59
- const getResultsFromImportedData = () => {
60
- return importedData.filter((row) => {
61
- if (row[0].startsWith("#")) {
62
- return false;
63
- }
64
- return row.some((column) => !!column?.trim());
65
- });
66
- };
67
- const handleFileSubmit = (keepTableValues) => {
68
- if (importedData.length !== 0) {
69
- const result = getResultsFromImportedData();
70
- if (validateCsvFile(result)) {
71
- result.splice(0, 1);
72
- const dataFromCsv = getDataFromCsv(result);
73
- if (keepTableValues) {
74
- append(dataFromCsv);
75
- } else {
76
- replace(dataFromCsv);
77
- }
78
- handleClose();
79
- }
80
- } else {
81
- setCreateError(intl.formatMessage({ id: "noDataInCsvFile" }));
82
- }
83
- };
84
- const handleOpenCSVConfirmationDataDialog = () => {
85
- const isValuesInTable = Array.isArray(watchTableValues) && watchTableValues.some(
86
- (val) => val && Object.keys(val).filter((key) => key !== FieldConstants.AG_GRID_ROW_UUID).some((e) => val[e] !== void 0 && val[e] !== null && String(val[e]).trim().length > 0)
87
- );
88
- if (isValuesInTable && getResultsFromImportedData().length > 0) {
89
- setIsConfirmationPopupOpen(true);
90
- } else {
91
- setIsConfirmationPopupOpen(false);
92
- handleFileSubmit(false);
93
- }
94
- };
95
- const handleAddPopupConfirmation = () => {
96
- handleFileSubmit(true);
97
- setIsConfirmationPopupOpen(false);
98
- };
99
- const handleReplacePopupConfirmation = () => {
100
- handleFileSubmit(false);
101
- setIsConfirmationPopupOpen(false);
102
- };
103
- const handleCancelDialog = () => {
104
- setIsConfirmationPopupOpen(false);
105
- };
106
- const renderConfirmationCsvData = () => {
107
- return /* @__PURE__ */ jsxs(Dialog, { open: isConfirmationPopupOpen, "aria-labelledby": "dialog-confirmation-csv-data", children: [
108
- /* @__PURE__ */ jsx(DialogTitle, { id: "dialog-confirmation-csv-data", children: "Confirmation" }),
109
- /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(DialogContentText, { children: intl.formatMessage({ id: "keepCSVDataMessage" }) }) }),
110
- /* @__PURE__ */ jsxs(DialogActions, { children: [
111
- /* @__PURE__ */ jsx(CancelButton, { onClick: handleCancelDialog }),
112
- /* @__PURE__ */ jsx(Button, { onClick: () => handleReplacePopupConfirmation(), variant: "outlined", children: /* @__PURE__ */ jsx(FormattedMessage, { id: "replace" }) }),
113
- /* @__PURE__ */ jsx(Button, { onClick: () => handleAddPopupConfirmation(), variant: "outlined", children: /* @__PURE__ */ jsx(FormattedMessage, { id: "add" }) })
114
- ] })
115
- ] });
116
- };
117
- return /* @__PURE__ */ jsxs(Fragment, { children: [
118
- /* @__PURE__ */ jsxs(Dialog, { open, onClose: handleClose, fullWidth: true, children: [
119
- /* @__PURE__ */ jsx(DialogTitle, { children: title }),
120
- /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsxs("div", { children: [
121
- /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 2, children: [
122
- /* @__PURE__ */ jsx(Grid, { container: true, item: true, children: /* @__PURE__ */ jsx(Grid, { item: true, xs: 6, children: /* @__PURE__ */ jsx(
123
- CsvDownloader,
124
- {
125
- datas: data,
126
- filename: fileName,
127
- separator: language === LANG_FRENCH ? ";" : ",",
128
- children: /* @__PURE__ */ jsx(Button, { variant: "contained", children: /* @__PURE__ */ jsx(FormattedMessage, { id: "GenerateCSV" }) })
129
- }
130
- ) }) }),
131
- /* @__PURE__ */ jsx(Grid, { container: true, item: true, spacing: 3, children: /* @__PURE__ */ jsx(
132
- CSVReader,
133
- {
134
- onUploadAccepted: (results) => {
135
- setImportedData([...results.data]);
136
- setCreateError("");
137
- },
138
- config: {
139
- // We use | for multi values in one cell, then we remove it from the default value for this config, to avoid delimiter autodetection
140
- delimitersToGuess: [",", " ", ";", RECORD_SEP, UNIT_SEP],
141
- delimiter: language === LANG_FRENCH ? ";" : ","
142
- },
143
- children: ({ getRootProps, acceptedFile }) => /* @__PURE__ */ jsxs(Grid, { item: true, children: [
144
- /* @__PURE__ */ jsx(Button, { ...getRootProps(), variant: "contained", children: /* @__PURE__ */ jsx(FormattedMessage, { id: "UploadCSV" }) }),
145
- /* @__PURE__ */ jsx(
146
- "span",
147
- {
148
- style: {
149
- marginLeft: "10px",
150
- fontWeight: "bold"
151
- },
152
- children: acceptedFile ? acceptedFile.name : intl.formatMessage({
153
- id: "uploadMessage"
154
- })
155
- }
156
- )
157
- ] })
158
- }
159
- ) })
160
- ] }),
161
- createError !== "" && /* @__PURE__ */ jsx(Alert, { severity: "error", children: createError })
162
- ] }) }),
163
- /* @__PURE__ */ jsxs(DialogActions, { children: [
164
- /* @__PURE__ */ jsx(CancelButton, { onClick: handleClose }),
165
- /* @__PURE__ */ jsx(
166
- Button,
167
- {
168
- variant: "outlined",
169
- onClick: () => handleOpenCSVConfirmationDataDialog(),
170
- disabled: createError !== "",
171
- "data-testid": "ValidateButton",
172
- children: /* @__PURE__ */ jsx(FormattedMessage, { id: "validate" })
173
- }
174
- )
175
- ] })
176
- ] }),
177
- renderConfirmationCsvData()
178
- ] });
179
- }
180
- export {
181
- CsvUploader
182
- };
@@ -1,4 +0,0 @@
1
- import { CsvUploader } from "./CsvUploader.js";
2
- export {
3
- CsvUploader
4
- };