@gridsuite/commons-ui 0.228.0 → 0.230.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 (182) 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/customAGGrid/customAggrid.js +5 -3
  13. package/dist/components/composite/dnd-table/dnd-table-add-rows-dialog.js +1 -0
  14. package/dist/components/composite/dnd-table/dnd-table-row.js +1 -0
  15. package/dist/components/composite/dnd-table/dnd-table.js +1 -0
  16. package/dist/components/composite/filter/HeaderFilterForm.js +1 -0
  17. package/dist/components/composite/filter/expert/ExpertFilterForm.js +1 -0
  18. package/dist/components/composite/filter/explicitNaming/ExplicitNamingFilterForm.js +122 -91
  19. package/dist/components/composite/index.js +4 -5
  20. package/dist/components/index.js +6 -5
  21. package/dist/components/ui/csvDownloader/use-csv-export.js +2 -2
  22. package/dist/components/ui/csvPicker/csv-picker-confirmation-dialog.d.ts +11 -0
  23. package/dist/components/ui/csvPicker/csv-picker-confirmation-dialog.js +65 -0
  24. package/dist/components/ui/csvPicker/csv-picker.d.ts +24 -0
  25. package/dist/components/ui/csvPicker/csv-picker.js +123 -0
  26. package/dist/components/{composite/agGridTable/csvUploader → ui/csvPicker}/index.d.ts +2 -2
  27. package/dist/components/ui/csvPicker/index.js +4 -0
  28. package/dist/components/ui/dialogs/elementSaveDialog/ElementSaveDialog.js +1 -1
  29. package/dist/components/ui/index.d.ts +1 -0
  30. package/dist/components/ui/index.js +2 -0
  31. package/dist/features/index.js +1 -0
  32. package/dist/features/network-modifications/battery/creation/BatteryCreationForm.js +2 -3
  33. package/dist/features/network-modifications/battery/creation/batteryCreation.utils.js +2 -3
  34. package/dist/features/network-modifications/battery/modification/BatteryDialogHeader.js +2 -3
  35. package/dist/features/network-modifications/battery/modification/BatteryDialogTabsContent.js +2 -3
  36. package/dist/features/network-modifications/battery/modification/batteryModification.utils.js +2 -3
  37. package/dist/features/network-modifications/by-filter/assignment/assignment/assignment-form.js +1 -0
  38. package/dist/features/network-modifications/by-filter/assignment/modification-by-assignment-form.js +1 -0
  39. package/dist/features/network-modifications/by-filter/deletion/ByFilterDeletionForm.js +1 -0
  40. package/dist/features/network-modifications/common/activePowerControl/ActivePowerControlForm.js +1 -0
  41. package/dist/features/network-modifications/common/connectivity/ConnectivityForm.js +1 -0
  42. package/dist/features/network-modifications/common/connectivity/PositionForm.js +1 -0
  43. package/dist/features/network-modifications/common/connectivity/VoltageLevelConnectivityForm.js +1 -0
  44. package/dist/features/network-modifications/common/measurements/BusbarSectionVoltageMeasurementsForm.js +2 -3
  45. package/dist/features/network-modifications/common/measurements/PowerWithValidityForm.js +1 -0
  46. package/dist/features/network-modifications/common/properties/PropertiesForm.js +1 -0
  47. package/dist/features/network-modifications/common/properties/PropertyForm.js +1 -0
  48. package/dist/features/network-modifications/common/reactiveLimits/ReactiveLimitsForm.js +1 -0
  49. package/dist/features/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/ReactiveCapabilityCurveRowForm.js +1 -0
  50. package/dist/features/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/ReactiveCapabilityCurveTableForm.js +1 -0
  51. package/dist/features/network-modifications/common/regulatingTerminal/RegulatingTerminalForm.js +1 -0
  52. package/dist/features/network-modifications/common/setpoints/SetPointsForm.js +1 -0
  53. package/dist/features/network-modifications/common/shortCircuit/ShortCircuitForm.js +1 -0
  54. package/dist/features/network-modifications/common/voltageRegulation/VoltageRegulationForm.js +1 -0
  55. package/dist/features/network-modifications/equipmentDeletion/EquipmentDeletionForm.js +2 -3
  56. package/dist/features/network-modifications/equipmentDeletion/equipmentDeletion.utils.js +1 -0
  57. package/dist/features/network-modifications/equipmentDeletion/hvdcLccDeletion/ShuntCompensatorSelectionForm.js +1 -0
  58. package/dist/features/network-modifications/generator/creation/GeneratorCreationForm.js +2 -3
  59. package/dist/features/network-modifications/generator/creation/generatorCreation.utils.js +2 -3
  60. package/dist/features/network-modifications/generator/modification/GeneratorDialogHeader.js +2 -3
  61. package/dist/features/network-modifications/generator/modification/GeneratorDialogTabsContent.js +2 -3
  62. package/dist/features/network-modifications/generator/modification/generatorModification.utils.js +2 -3
  63. package/dist/features/network-modifications/index.js +1 -0
  64. package/dist/features/network-modifications/load/common/LoadDialogHeader.js +2 -3
  65. package/dist/features/network-modifications/load/creation/loadCreation.utils.js +1 -0
  66. package/dist/features/network-modifications/load/modification/loadModification.utils.js +2 -3
  67. package/dist/features/network-modifications/shunt-compensator/common/CharacteristicsForm.js +1 -0
  68. package/dist/features/network-modifications/shunt-compensator/creation/ShuntCompensatorCreationForm.js +2 -3
  69. package/dist/features/network-modifications/shunt-compensator/creation/shuntCompensatorCreation.utils.js +2 -3
  70. package/dist/features/network-modifications/shunt-compensator/modification/ShuntCompensatorModificationForm.js +2 -3
  71. package/dist/features/network-modifications/shunt-compensator/modification/shuntCompensatorModification.utils.js +2 -3
  72. package/dist/features/network-modifications/substation/creation/SubstationCreationForm.js +2 -3
  73. package/dist/features/network-modifications/substation/modification/SubstationModificationForm.js +2 -3
  74. package/dist/features/network-modifications/voltageLevel/creation/VoltageLevelCreationForm.js +2 -3
  75. package/dist/features/network-modifications/voltageLevel/creation/index.js +2 -3
  76. package/dist/features/network-modifications/voltageLevel/creation/tabs/characteristicsTab/CharacteristicsTab.js +1 -0
  77. package/dist/features/network-modifications/voltageLevel/creation/tabs/structureTab/StructureTab.js +1 -0
  78. package/dist/features/network-modifications/voltageLevel/creation/tabs/structureTab/couplingOmnibus/CouplingOmnibusForm.js +1 -0
  79. package/dist/features/network-modifications/voltageLevel/creation/tabs/structureTab/switchesBetweenSections/SwitchesBetweenSections.js +1 -0
  80. package/dist/features/network-modifications/voltageLevel/creation/tabs/substationTab/SubstationCreationSection.js +2 -3
  81. package/dist/features/network-modifications/voltageLevel/creation/tabs/substationTab/SubstationTab.js +1 -0
  82. package/dist/features/network-modifications/voltageLevel/creation/voltageLevelCreation.utils.js +2 -3
  83. package/dist/features/network-modifications/voltageLevel/index.js +2 -3
  84. package/dist/features/network-modifications/voltageLevel/modification/VoltageLevelModificationForm.js +2 -3
  85. package/dist/features/parameters/common/ProviderParam.js +1 -0
  86. package/dist/features/parameters/common/contingency-table/columns-definitions.js +1 -0
  87. package/dist/features/parameters/common/limitreductions/limit-reduction-table-cell.js +1 -0
  88. package/dist/features/parameters/common/limitreductions/limit-reductions-table-form.js +1 -0
  89. package/dist/features/parameters/common/name-element-editor/name-element-editor-utils.js +1 -0
  90. package/dist/features/parameters/common/parameter-field.js +1 -0
  91. package/dist/features/parameters/common/parameter-table-field/parameter-table-field.js +1 -0
  92. package/dist/features/parameters/common/voltage-level-table/custom-voltage-level-table-cell.js +1 -0
  93. package/dist/features/parameters/common/widget/parameter-float.js +1 -0
  94. package/dist/features/parameters/common/widget/parameter-line-directory-items-input.js +1 -0
  95. package/dist/features/parameters/common/widget/parameter-line-slider.js +1 -0
  96. package/dist/features/parameters/dynamic-margin-calculation/dynamic-margin-calculation-form.js +1 -0
  97. package/dist/features/parameters/dynamic-margin-calculation/dynamic-margin-calculation-inline.js +1 -0
  98. package/dist/features/parameters/dynamic-margin-calculation/loads-variations-parameters.js +1 -0
  99. package/dist/features/parameters/dynamic-margin-calculation/use-dynamic-margin-calculation-parameters-form.js +1 -0
  100. package/dist/features/parameters/dynamic-security-analysis/contingency-parameters.js +1 -0
  101. package/dist/features/parameters/dynamic-security-analysis/dynamic-security-analysis-inline.js +1 -0
  102. package/dist/features/parameters/dynamic-security-analysis/dynamic-security-analysis-parameters-form.js +1 -0
  103. package/dist/features/parameters/dynamic-security-analysis/use-dynamic-security-analysis-parameters-form.js +1 -0
  104. package/dist/features/parameters/dynamic-simulation/dynamic-simulation-inline.js +1 -0
  105. package/dist/features/parameters/dynamic-simulation/dynamic-simulation-parameters-form.js +1 -0
  106. package/dist/features/parameters/dynamic-simulation/use-dynamic-simulation-parameters-form.js +1 -0
  107. package/dist/features/parameters/loadflow/load-flow-general-parameters.js +1 -0
  108. package/dist/features/parameters/loadflow/load-flow-parameters-content.js +1 -0
  109. package/dist/features/parameters/loadflow/load-flow-parameters-dialog.js +1 -0
  110. package/dist/features/parameters/loadflow/load-flow-parameters-form.js +1 -0
  111. package/dist/features/parameters/loadflow/load-flow-parameters-header.js +1 -0
  112. package/dist/features/parameters/loadflow/load-flow-parameters-inline.js +1 -0
  113. package/dist/features/parameters/loadflow/load-flow-parameters-utils.js +1 -0
  114. package/dist/features/parameters/loadflow/use-load-flow-parameters-form.js +1 -0
  115. package/dist/features/parameters/network-visualizations/map-parameters.js +1 -0
  116. package/dist/features/parameters/network-visualizations/network-area-diagram-parameters.js +1 -0
  117. package/dist/features/parameters/network-visualizations/network-visualizations-form.js +1 -0
  118. package/dist/features/parameters/network-visualizations/network-visualizations-parameters-dialog.js +1 -0
  119. package/dist/features/parameters/network-visualizations/network-visualizations-parameters-inline.js +1 -0
  120. package/dist/features/parameters/network-visualizations/single-line-diagram-parameters.js +1 -0
  121. package/dist/features/parameters/network-visualizations/use-network-visualizations-parameters-form.js +1 -0
  122. package/dist/features/parameters/pcc-min/pcc-min-form-utils.js +1 -0
  123. package/dist/features/parameters/pcc-min/pcc-min-parameters-dialog.js +1 -0
  124. package/dist/features/parameters/pcc-min/pcc-min-parameters-form.js +1 -0
  125. package/dist/features/parameters/pcc-min/pcc-min-parameters-inline.js +1 -0
  126. package/dist/features/parameters/pcc-min/use-pcc-min-parameters-form.js +1 -0
  127. package/dist/features/parameters/security-analysis/columns-definitions.js +1 -0
  128. package/dist/features/parameters/security-analysis/security-analysis-parameters-dialog.js +1 -0
  129. package/dist/features/parameters/security-analysis/security-analysis-parameters-form.js +1 -0
  130. package/dist/features/parameters/security-analysis/security-analysis-parameters-inline.js +1 -0
  131. package/dist/features/parameters/security-analysis/security-analysis-parameters-selector.js +1 -0
  132. package/dist/features/parameters/security-analysis/security-analysis-violations-hiding.js +1 -0
  133. package/dist/features/parameters/security-analysis/use-security-analysis-parameters-form.js +1 -0
  134. package/dist/features/parameters/sensi/columns-definitions.js +1 -0
  135. package/dist/features/parameters/sensi/sensitivity-analysis-parameters-dialog.js +1 -0
  136. package/dist/features/parameters/sensi/sensitivity-analysis-parameters-form.js +1 -0
  137. package/dist/features/parameters/sensi/sensitivity-analysis-parameters-inline.js +1 -0
  138. package/dist/features/parameters/sensi/sensitivity-parameters-fields.js +1 -0
  139. package/dist/features/parameters/sensi/sensitivity-parameters-selector.js +33 -4
  140. package/dist/features/parameters/sensi/use-sensitivity-analysis-parameters.js +1 -0
  141. package/dist/features/parameters/sensi/utils.js +1 -0
  142. package/dist/features/parameters/short-circuit/short-circuit-general-tab-panel.js +1 -0
  143. package/dist/features/parameters/short-circuit/short-circuit-icc-cluster-table-cell.js +1 -0
  144. package/dist/features/parameters/short-circuit/short-circuit-icc-material-table-cell.js +1 -0
  145. package/dist/features/parameters/short-circuit/short-circuit-parameters-content.js +1 -0
  146. package/dist/features/parameters/short-circuit/short-circuit-parameters-dialog.js +1 -0
  147. package/dist/features/parameters/short-circuit/short-circuit-parameters-form.js +1 -0
  148. package/dist/features/parameters/short-circuit/short-circuit-parameters-inline.js +1 -0
  149. package/dist/features/parameters/short-circuit/short-circuit-parameters-utils.js +1 -0
  150. package/dist/features/parameters/short-circuit/short-circuit-power-electronics-tab-panel.js +1 -0
  151. package/dist/features/parameters/short-circuit/short-circuit-study-area-tab-panel.js +1 -0
  152. package/dist/features/parameters/short-circuit/use-short-circuit-parameters-form.js +1 -0
  153. package/dist/features/parameters/voltage-init/equipment-selection-parameters.js +1 -0
  154. package/dist/features/parameters/voltage-init/general-parameters.js +1 -0
  155. package/dist/features/parameters/voltage-init/use-voltage-init-parameters-form.js +1 -0
  156. package/dist/features/parameters/voltage-init/voltage-init-form-utils.js +1 -0
  157. package/dist/features/parameters/voltage-init/voltage-init-parameters-dialog.js +1 -0
  158. package/dist/features/parameters/voltage-init/voltage-init-parameters-form.js +1 -0
  159. package/dist/features/parameters/voltage-init/voltage-init-parameters-inline.js +1 -0
  160. package/dist/features/parameters/voltage-init/voltage-limits-parameters.js +1 -0
  161. package/dist/index.js +12 -8
  162. package/dist/translations/en/commonButtonEn.d.ts +2 -0
  163. package/dist/translations/en/commonButtonEn.js +2 -0
  164. package/dist/translations/en/csvEn.d.ts +2 -1
  165. package/dist/translations/en/csvEn.js +5 -4
  166. package/dist/translations/fr/commonButtonFr.d.ts +2 -0
  167. package/dist/translations/fr/commonButtonFr.js +2 -0
  168. package/dist/translations/fr/csvFr.d.ts +2 -1
  169. package/dist/translations/fr/csvFr.js +6 -5
  170. package/dist/utils/algos.d.ts +1 -0
  171. package/dist/utils/algos.js +13 -1
  172. package/dist/utils/functions.d.ts +5 -0
  173. package/dist/utils/functions.js +5 -0
  174. package/dist/utils/index.js +6 -3
  175. package/dist/utils/langs.d.ts +1 -0
  176. package/dist/utils/langs.js +5 -1
  177. package/package.json +6 -7
  178. package/dist/components/composite/agGridTable/BottomRightButtons.d.ts +0 -14
  179. package/dist/components/composite/agGridTable/BottomRightButtons.js +0 -62
  180. package/dist/components/composite/agGridTable/csvUploader/CsvUploader.d.ts +0 -15
  181. package/dist/components/composite/agGridTable/csvUploader/CsvUploader.js +0 -182
  182. package/dist/components/composite/agGridTable/csvUploader/index.js +0 -4
@@ -0,0 +1,13 @@
1
+ import { CsvProps } from './agGridTable-utils';
2
+ export interface BottomTableButtonsProps {
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
+ csvProps?: CsvProps;
12
+ }
13
+ export declare function BottomTableButtons({ name, disableUp, disableDown, disableDelete, handleAddRow, handleDeleteRows, handleMoveRowUp, handleMoveRowDown, csvProps, }: BottomTableButtonsProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,92 @@
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { styled, IconButton, Grid2, Box, Button } from "@mui/material";
3
+ import { ControlPoint, Delete, ArrowCircleUp, ArrowCircleDown } from "@mui/icons-material";
4
+ import { FormattedMessage } from "react-intl";
5
+ import { useCSVDownloader } from "react-papaparse";
6
+ import { ErrorInput } from "../../ui/reactHookForm/errorManagement/ErrorInput.js";
7
+ import { FieldErrorAlert } from "../../ui/reactHookForm/errorManagement/FieldErrorAlert.js";
8
+ import "../../../utils/conversionUtils.js";
9
+ import "../../../utils/types/equipmentType.js";
10
+ import { getCsvDelimiter } from "../../../utils/langs.js";
11
+ const InnerColoredButton = styled(IconButton)(({ theme }) => {
12
+ return {
13
+ color: theme.palette.primary.main
14
+ };
15
+ });
16
+ function CsvDownloadButton({ data, fileName, delimiter, labelId, disabled }) {
17
+ const { CSVDownloader } = useCSVDownloader();
18
+ if (disabled) {
19
+ return /* @__PURE__ */ jsx(Button, { variant: "outlined", disabled: true, children: /* @__PURE__ */ jsx(FormattedMessage, { id: labelId }) });
20
+ }
21
+ return /* @__PURE__ */ jsx(CSVDownloader, { data, filename: fileName, config: { delimiter }, children: /* @__PURE__ */ jsx(Button, { variant: "outlined", children: /* @__PURE__ */ jsx(FormattedMessage, { id: labelId }) }) });
22
+ }
23
+ function BottomTableButtons({
24
+ name,
25
+ disableUp,
26
+ disableDown,
27
+ disableDelete,
28
+ handleAddRow,
29
+ handleDeleteRows,
30
+ handleMoveRowUp,
31
+ handleMoveRowDown,
32
+ csvProps
33
+ }) {
34
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
35
+ /* @__PURE__ */ jsxs(Grid2, { container: true, paddingTop: 1, alignItems: "center", spacing: 1, children: [
36
+ csvProps?.getTemplateData && /* @__PURE__ */ jsx(Grid2, { children: /* @__PURE__ */ jsx(
37
+ CsvDownloadButton,
38
+ {
39
+ data: csvProps.getTemplateData,
40
+ fileName: csvProps.fileName,
41
+ delimiter: getCsvDelimiter(csvProps.language),
42
+ labelId: "GenerateCSV"
43
+ }
44
+ ) }),
45
+ csvProps?.getTableData && /* @__PURE__ */ jsx(Grid2, { children: /* @__PURE__ */ jsx(
46
+ CsvDownloadButton,
47
+ {
48
+ data: csvProps.getTableData,
49
+ fileName: csvProps.fileName,
50
+ delimiter: getCsvDelimiter(csvProps.language),
51
+ labelId: "DownloadCSV",
52
+ disabled: !csvProps.hasTableData
53
+ }
54
+ ) }),
55
+ csvProps?.extraButtons && /* @__PURE__ */ jsx(Grid2, { children: csvProps.extraButtons }),
56
+ /* @__PURE__ */ jsxs(Grid2, { sx: { marginLeft: "auto" }, children: [
57
+ /* @__PURE__ */ jsx(InnerColoredButton, { onClick: handleAddRow, "aria-label": "Add row", children: /* @__PURE__ */ jsx(ControlPoint, {}) }),
58
+ /* @__PURE__ */ jsx(
59
+ InnerColoredButton,
60
+ {
61
+ onClick: handleDeleteRows,
62
+ disabled: disableDelete,
63
+ "aria-label": "Delete selected rows",
64
+ children: /* @__PURE__ */ jsx(Delete, {})
65
+ }
66
+ ),
67
+ /* @__PURE__ */ jsx(
68
+ InnerColoredButton,
69
+ {
70
+ disabled: disableUp,
71
+ onClick: handleMoveRowUp,
72
+ "aria-label": "Move selected rows up",
73
+ children: /* @__PURE__ */ jsx(ArrowCircleUp, {})
74
+ }
75
+ ),
76
+ /* @__PURE__ */ jsx(
77
+ InnerColoredButton,
78
+ {
79
+ disabled: disableDown,
80
+ onClick: handleMoveRowDown,
81
+ "aria-label": "Move selected rows down",
82
+ children: /* @__PURE__ */ jsx(ArrowCircleDown, {})
83
+ }
84
+ )
85
+ ] })
86
+ ] }),
87
+ /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(ErrorInput, { name, InputField: FieldErrorAlert }) })
88
+ ] });
89
+ }
90
+ export {
91
+ BottomTableButtons
92
+ };
@@ -1,9 +1,10 @@
1
1
  import { FieldValues, UseFieldArrayReturn } from 'react-hook-form';
2
+ import { CsvProps } from './agGridTable-utils';
2
3
  import { CustomAGGridProps } from '../customAGGrid';
3
4
  export type CustomAgGridTableProps = Required<Pick<CustomAGGridProps, 'columnDefs'>> & Pick<CustomAGGridProps, 'defaultColDef' | 'pagination' | 'paginationPageSize' | 'alwaysShowVerticalScroll' | 'stopEditingWhenCellsLoseFocus' | 'rowSelection' | 'overrideLocales' | 'loading'> & {
4
5
  name: string;
5
6
  makeDefaultRowData: any;
6
- csvProps: unknown;
7
- cssProps: unknown;
7
+ csvProps?: CsvProps;
8
+ cssProps?: unknown;
8
9
  };
9
10
  export declare const CustomAgGridTable: import('react').ForwardRefExoticComponent<Readonly<CustomAgGridTableProps> & import('react').RefAttributes<UseFieldArrayReturn<FieldValues, string>>>;
@@ -2,37 +2,22 @@ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
2
  import { forwardRef, useState, useImperativeHandle, useCallback, useEffect } from "react";
3
3
  import { useFormContext, useFieldArray } from "react-hook-form";
4
4
  import { useTheme, Box } from "@mui/material";
5
- import { BottomRightButtons } from "./BottomRightButtons.js";
5
+ import { BottomTableButtons } from "./BottomTableButtons.js";
6
6
  import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
7
7
  import "../../../utils/conversionUtils.js";
8
8
  import "../../../utils/types/equipmentType.js";
9
+ import { hasNonEmptyRows } from "../../../utils/functions.js";
9
10
  import "@mui/icons-material";
10
11
  import { CustomAGGrid } from "../customAGGrid/customAggrid.js";
11
12
  import "react-intl";
12
13
  const style = (customProps) => ({
13
14
  grid: (theme) => ({
14
- width: "auto",
15
15
  height: "100%",
16
- position: "relative",
17
- // - AG Grid colors override -
18
- // It shouldn't be exactly like this, but I couldn't make it works otherwise
19
- // https://www.ag-grid.com/react-data-grid/global-style-customisation/
20
- "--ag-alpine-active-color": `${theme.palette.primary.main} !important`,
21
- "--ag-checkbox-indeterminate-color": `${theme.palette.primary.main} !important`,
22
- "--ag-background-color": `${theme.agGridBackground.color} !important`,
23
- "--ag-header-background-color": `${theme.agGridBackground.color} !important`,
24
- "--ag-odd-row-background-color": `${theme.agGridBackground.color} !important`,
25
- "--ag-modal-overlay-background-color": `${theme.agGridBackground.color} !important`,
26
- "--ag-selected-row-background-color": "transparent !important",
27
- "--ag-range-selection-border-color": "transparent !important",
28
16
  // overrides the default computed max height for ag grid default selector editor to make it more usable
29
17
  // can be removed if a custom selector editor is implemented
30
18
  "& .ag-select-list": {
31
19
  maxHeight: "300px !important"
32
20
  },
33
- "& .ag-root-wrapper-body": {
34
- maxHeight: "500px"
35
- },
36
21
  "& .ag-cell": {
37
22
  boxShadow: "none"
38
23
  },
@@ -46,14 +31,9 @@ const style = (customProps) => ({
46
31
  border: "none",
47
32
  boxShadow: "none"
48
33
  },
49
- "& .numeric-input": {
50
- fontSize: "calc(var(--ag-font-size) + 1px)",
51
- paddingLeft: "calc(var(--ag-cell-horizontal-padding) - 1px)",
52
- width: "100%",
53
- height: "100%",
54
- border: "inherit",
55
- outline: "inherit",
56
- backgroundColor: theme.agGridBackground.color
34
+ // Color the checkbox (checked & indeterminate) grey instead of AG Grid's default accent (blue).
35
+ "& .ag-checkbox-input-wrapper.ag-checked::after, & .ag-checkbox-input-wrapper.ag-indeterminate::after": {
36
+ color: `${theme.palette.text.secondary}`
57
37
  },
58
38
  "& .Mui-focused .MuiOutlinedInput-root": {
59
39
  // borders moves row height
@@ -87,6 +67,7 @@ const CustomAgGridTable = forwardRef(
87
67
  const { append, remove, update, swap, move } = useFieldArrayOutput;
88
68
  useImperativeHandle(ref, () => useFieldArrayOutput, [useFieldArrayOutput]);
89
69
  const rowData = watch(name);
70
+ const hasTableData = hasNonEmptyRows(rowData);
90
71
  const isFirstSelected = Boolean(
91
72
  rowData?.length && gridApi?.api.getRowNode(rowData[0][FieldConstants.AG_GRID_ROW_UUID])?.isSelected()
92
73
  );
@@ -136,13 +117,11 @@ const CustomAgGridTable = forwardRef(
136
117
  const onGridReady = (params) => {
137
118
  setGridApi(params);
138
119
  };
139
- const onRowDataUpdated = () => {
120
+ const onRowDataUpdated = (event) => {
140
121
  setNewRowAdded(false);
141
- if (gridApi?.api) {
142
- const lastIndex = rowData.length - 1;
143
- gridApi.api.paginationGoToLastPage();
144
- gridApi.api.ensureIndexVisible(lastIndex, "bottom");
145
- }
122
+ const lastIndex = rowData.length - 1;
123
+ event.api.paginationGoToLastPage();
124
+ event.api.ensureIndexVisible(lastIndex, "bottom");
146
125
  };
147
126
  const onCellEditingStopped = useCallback(
148
127
  (event) => {
@@ -165,12 +144,12 @@ const CustomAgGridTable = forwardRef(
165
144
  rowData,
166
145
  onGridReady,
167
146
  cacheOverflowSize: 10,
168
- rowSelection: rowSelection ?? "multiple",
147
+ rowSelection: rowSelection ?? { mode: "multiRow" },
169
148
  selectionColumnDef: { rowDrag: true, width: 80, pinned: "left" },
170
- onRowDragMove: (e) => move(getIndex(e.node.data), e.overIndex),
149
+ onRowDragMove: (event) => move(getIndex(event.node.data), event.overIndex),
171
150
  detailRowAutoHeight: true,
172
- onSelectionChanged: () => {
173
- setSelectedRows(gridApi.api.getSelectedRows());
151
+ onSelectionChanged: (event) => {
152
+ setSelectedRows(event.api.getSelectedRows());
174
153
  },
175
154
  onRowDataUpdated: newRowAdded ? onRowDataUpdated : void 0,
176
155
  onCellEditingStopped,
@@ -182,7 +161,7 @@ const CustomAgGridTable = forwardRef(
182
161
  }
183
162
  ) }),
184
163
  /* @__PURE__ */ jsx(
185
- BottomRightButtons,
164
+ BottomTableButtons,
186
165
  {
187
166
  name,
188
167
  handleAddRow,
@@ -192,8 +171,7 @@ const CustomAgGridTable = forwardRef(
192
171
  disableUp: noRowSelected || isFirstSelected || isSortApplied,
193
172
  disableDown: noRowSelected || isLastSelected || isSortApplied,
194
173
  disableDelete: noRowSelected,
195
- csvProps,
196
- useFieldArrayOutput
174
+ csvProps: csvProps && { ...csvProps, hasTableData }
197
175
  }
198
176
  )
199
177
  ] });
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ export interface CsvProps {
3
+ fileName: string;
4
+ language?: string;
5
+ getTemplateData?: () => unknown[];
6
+ getTableData?: () => unknown[];
7
+ extraButtons?: ReactNode;
8
+ hasTableData?: boolean;
9
+ }
@@ -1,4 +1,5 @@
1
- import { NumericEditor } from "./numericEditor.js";
1
+ import { NumericEditor, suppressNonNumericKeyboardEvent } from "./numericEditor.js";
2
2
  export {
3
- NumericEditor
3
+ NumericEditor,
4
+ suppressNonNumericKeyboardEvent
4
5
  };
@@ -1,21 +1,23 @@
1
- import { ICellEditorComp, ICellEditorParams } from 'ag-grid-community';
1
+ import { CustomCellEditorProps } from 'ag-grid-react';
2
+ import { SuppressKeyboardEventParams } from 'ag-grid-community';
2
3
  /**
3
- * This is a modified version of the cell editor proposed by AGGrid itself :
4
- * https://www.ag-grid.com/javascript-data-grid/component-cell-editor/#cell-editor-example
5
- * I use this JS version instead of the React version because it's simpler and lighter.
6
- * React version if you want to check, with forwardRef, useEffect and useImperativeHandle :
7
- * https://www.ag-grid.com/react-data-grid/component-cell-editor/#cell-editor-example
4
+ * `suppressKeyboardEvent` callback to put on any column using {@link NumericEditor}.
5
+ * Prevents ag-grid from starting an edit when a non-numeric printable key is pressed on a focused cell.
6
+ * Numeric keys still start editing; keys pressed while already editing are left to the input's own onKeyDown handling.
8
7
  */
9
- export declare class NumericEditor implements ICellEditorComp {
10
- private eInput;
11
- private cancelBeforeStart;
12
- init(params: ICellEditorParams): void;
13
- private static isBackspace;
14
- private static isNavigationKey;
15
- getGui(): HTMLInputElement;
16
- afterGuiAttached(): void;
17
- isCancelBeforeStart(): boolean;
18
- getValue(): number | null;
19
- private static isCharNumeric;
20
- private static isNumericKey;
21
- }
8
+ export declare const suppressNonNumericKeyboardEvent: (params: SuppressKeyboardEventParams) => boolean;
9
+ /**
10
+ * Custom numeric cell editor (see ag-grid custom cell editor docs:
11
+ * https://www.ag-grid.com/react-data-grid/cell-editors/#custom-components).
12
+ * Restricts typing to digits and decimal separators while keeping the raw text in the input,
13
+ * and commits the value as a number (or null) via onValueChange.
14
+ *
15
+ * NB: the `eventKey`-driven logic below (seeding the initial value from the triggering key in the
16
+ * useState/useEffect) only matters when editing is started by typing a character on a focused cell,
17
+ * i.e. when the column uses `singleClickEdit: false`. With `singleClickEdit: true` (what we mostly
18
+ * use), editing starts on click, `eventKey` is null, and those branches are effectively inert.
19
+ *
20
+ * Columns using this editor should also set `suppressKeyboardEvent: suppressNonNumericKeyboardEvent`
21
+ * so that a non-numeric key on a focused cell doesn't start an edit.
22
+ */
23
+ export declare function NumericEditor({ value, onValueChange, eventKey }: CustomCellEditorProps): import("react/jsx-runtime").JSX.Element;
@@ -1,62 +1,49 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useRef, useState, useEffect } from "react";
1
3
  import { KeyCode } from "ag-grid-community";
2
- class NumericEditor {
3
- // gets called once before the renderer is used
4
- init(params) {
5
- this.eInput = document.createElement("input");
6
- this.eInput.classList.add("numeric-input");
7
- if (params.eventKey === KeyCode.BACKSPACE) {
8
- this.eInput.value = "";
9
- } else if (NumericEditor.isCharNumeric(params.eventKey)) {
10
- this.eInput.value = params.eventKey;
11
- } else if (params.value !== void 0 && params.value !== null) {
12
- this.eInput.value = params.value;
4
+ const isCharNumeric = (charStr) => !!charStr && /\d|,|\./.test(charStr);
5
+ const suppressNonNumericKeyboardEvent = (params) => !params.editing && params.event.key.length === 1 && !isCharNumeric(params.event.key);
6
+ const toNumber = (text) => {
7
+ const result = Number.parseFloat(text.replace(",", "."));
8
+ return Number.isNaN(result) ? null : result;
9
+ };
10
+ function NumericEditor({ value, onValueChange, eventKey }) {
11
+ const refInput = useRef(null);
12
+ const [text, setText] = useState(() => {
13
+ if (eventKey === KeyCode.BACKSPACE) {
14
+ return "";
15
+ }
16
+ if (eventKey?.length === 1 && isCharNumeric(eventKey)) {
17
+ return eventKey;
18
+ }
19
+ return value == null ? "" : String(value);
20
+ });
21
+ useEffect(() => {
22
+ onValueChange(toNumber(text));
23
+ refInput.current?.select();
24
+ }, []);
25
+ const handleChange = (event) => {
26
+ setText(event.target.value);
27
+ onValueChange(toNumber(event.target.value));
28
+ };
29
+ const handleKeyDown = (event) => {
30
+ if (event.key.length === 1 && !isCharNumeric(event.key)) {
31
+ event.preventDefault();
32
+ }
33
+ };
34
+ return /* @__PURE__ */ jsx("div", { className: "ag-cell-editor ag-text-field ag-input-field", role: "presentation", children: /* @__PURE__ */ jsx("div", { className: "ag-wrapper ag-input-wrapper ag-text-field-input-wrapper", role: "presentation", children: /* @__PURE__ */ jsx(
35
+ "input",
36
+ {
37
+ ref: refInput,
38
+ className: "ag-input-field-input ag-text-field-input",
39
+ type: "text",
40
+ value: text,
41
+ onChange: handleChange,
42
+ onKeyDown: handleKeyDown
13
43
  }
14
- this.eInput.addEventListener("keydown", (event) => {
15
- if (!event.key || event.key.length !== 1) {
16
- return;
17
- }
18
- if (!NumericEditor.isNumericKey(event)) {
19
- this.eInput.focus();
20
- if (event.preventDefault) {
21
- event.preventDefault();
22
- }
23
- } else if (NumericEditor.isNavigationKey(event) || NumericEditor.isBackspace(event)) {
24
- event.stopPropagation();
25
- }
26
- });
27
- const isNotANumber = params.eventKey && params.eventKey.length === 1 && "1234567890,.".indexOf(params.eventKey) < 0;
28
- this.cancelBeforeStart = !!isNotANumber;
29
- }
30
- static isBackspace(event) {
31
- return event.key === KeyCode.BACKSPACE;
32
- }
33
- static isNavigationKey(event) {
34
- return event.key === "ArrowLeft" || event.key === "ArrowRight";
35
- }
36
- // gets called once when grid ready to insert the element
37
- getGui() {
38
- return this.eInput;
39
- }
40
- // focus and select can be done after the gui is attached
41
- afterGuiAttached() {
42
- this.eInput.focus();
43
- }
44
- // returns the new value after editing
45
- isCancelBeforeStart() {
46
- return this.cancelBeforeStart;
47
- }
48
- // returns the new value after editing
49
- getValue() {
50
- const result = parseFloat(this.eInput.value.replace(",", "."));
51
- return Number.isNaN(result) ? null : result;
52
- }
53
- static isCharNumeric(charStr) {
54
- return charStr && /\d|,|\./.test(charStr);
55
- }
56
- static isNumericKey(event) {
57
- return NumericEditor.isCharNumeric(event.key);
58
- }
44
+ ) }) });
59
45
  }
60
46
  export {
61
- NumericEditor
47
+ NumericEditor,
48
+ suppressNonNumericKeyboardEvent
62
49
  };
@@ -4,7 +4,7 @@
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
- export * from './BottomRightButtons';
7
+ export * from './BottomTableButtons';
8
8
  export * from './CustomAgGridTable';
9
+ export * from './agGridTable-utils';
9
10
  export * from './cellEditors';
10
- export * from './csvUploader';
@@ -1,10 +1,9 @@
1
- import { BottomRightButtons } from "./BottomRightButtons.js";
1
+ import { BottomTableButtons } from "./BottomTableButtons.js";
2
2
  import { CustomAgGridTable } from "./CustomAgGridTable.js";
3
- import { NumericEditor } from "./cellEditors/numericEditor.js";
4
- import { CsvUploader } from "./csvUploader/CsvUploader.js";
3
+ import { NumericEditor, suppressNonNumericKeyboardEvent } from "./cellEditors/numericEditor.js";
5
4
  export {
6
- BottomRightButtons,
7
- CsvUploader,
5
+ BottomTableButtons,
8
6
  CustomAgGridTable,
9
- NumericEditor
7
+ NumericEditor,
8
+ suppressNonNumericKeyboardEvent
10
9
  };
@@ -1,14 +1,16 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { forwardRef, useMemo } from "react";
3
- import { AgGridReact } from "ag-grid-react";
3
+ import { AgGridProvider, AgGridReact } from "ag-grid-react";
4
4
  import "ag-grid-community/styles/ag-grid.css";
5
5
  import "ag-grid-community/styles/ag-theme-alpine.css";
6
+ import { AllCommunityModule } from "ag-grid-community";
6
7
  import { AG_GRID_LOCALE_EN, AG_GRID_LOCALE_FR } from "@ag-grid-community/locale";
7
8
  import { useIntl } from "react-intl";
8
9
  import { useTheme, Box } from "@mui/material";
9
10
  import { mergeSx } from "../../../utils/styles.js";
10
11
  import { CUSTOM_AGGRID_THEME, styles } from "./customAggrid.style.js";
11
12
  import { LANG_ENGLISH, LANG_FRENCH } from "../../../utils/langs.js";
13
+ const modules = [AllCommunityModule];
12
14
  function useAgGridLocale(overrideLocales) {
13
15
  const intl = useIntl();
14
16
  return useMemo(() => {
@@ -43,7 +45,7 @@ const CustomAGGrid = forwardRef(
43
45
  component: "div",
44
46
  sx: mergeSx(styles.grid, sx),
45
47
  className: `${theme.aggrid.theme} ${CUSTOM_AGGRID_THEME}`,
46
- children: /* @__PURE__ */ jsx(
48
+ children: /* @__PURE__ */ jsx(AgGridProvider, { modules, children: /* @__PURE__ */ jsx(
47
49
  AgGridReact,
48
50
  {
49
51
  ref,
@@ -53,7 +55,7 @@ const CustomAGGrid = forwardRef(
53
55
  theme: "legacy",
54
56
  ...agGridReactProps
55
57
  }
56
- )
58
+ ) })
57
59
  }
58
60
  );
59
61
  }
@@ -28,6 +28,7 @@ import "../../ui/dialogs/elementSaveDialog/ElementSaveDialog.js";
28
28
  import "../../ui/snackbarProvider/SnackbarProvider.js";
29
29
  import "mui-nested-menu";
30
30
  import "react-resizable-panels";
31
+ import "react-papaparse";
31
32
  function DndTableAddRowsDialog({ open, handleAddButton, onClose }) {
32
33
  const [rowNumber, setRowNumber] = useState(1);
33
34
  const handleClose = () => {
@@ -40,6 +40,7 @@ import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
40
40
  import "@material-symbols/svg-400/outlined/add_notes.svg?react";
41
41
  import "mui-nested-menu";
42
42
  import "react-resizable-panels";
43
+ import "react-papaparse";
43
44
  import { DeletableTableRow } from "./deletable-table-row.js";
44
45
  function DefaultTableCell({ name, rowIndex, column, width, ...props }) {
45
46
  return /* @__PURE__ */ jsx(TableCell, { sx: mergeSx({ padding: 1 }, width), children: /* @__PURE__ */ jsx(RawReadOnlyInput, { name, ...props }) }, column.dataKey);
@@ -36,6 +36,7 @@ import "../../ui/dialogs/elementSaveDialog/ElementSaveDialog.js";
36
36
  import "../../ui/snackbarProvider/SnackbarProvider.js";
37
37
  import "mui-nested-menu";
38
38
  import "react-resizable-panels";
39
+ import "react-papaparse";
39
40
  import { DndTableRow } from "./dnd-table-row.js";
40
41
  const styles = {
41
42
  columnsStyle: {
@@ -32,6 +32,7 @@ import "../../ui/dialogs/elementSaveDialog/ElementSaveDialog.js";
32
32
  import "../../ui/snackbarProvider/SnackbarProvider.js";
33
33
  import "mui-nested-menu";
34
34
  import "react-resizable-panels";
35
+ import "react-papaparse";
35
36
  const filterStyles = {
36
37
  textField: {
37
38
  minWidth: "250px",
@@ -40,6 +40,7 @@ import "../../../ui/reactHookForm/expandableInput/ExpandableInput.js";
40
40
  import "../../../ui/snackbarProvider/SnackbarProvider.js";
41
41
  import "mui-nested-menu";
42
42
  import "react-resizable-panels";
43
+ import "react-papaparse";
43
44
  import '../../../../assets/ExpertFilterForm.css';function isSupportedEquipmentType(equipmentType) {
44
45
  return Object.values(EXPERT_FILTER_EQUIPMENTS).map((equipments) => equipments.id).includes(equipmentType);
45
46
  }