@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.
- package/dist/components/composite/agGridTable/BottomTableButtons.d.ts +13 -0
- package/dist/components/composite/agGridTable/BottomTableButtons.js +92 -0
- package/dist/components/composite/agGridTable/CustomAgGridTable.d.ts +3 -2
- package/dist/components/composite/agGridTable/CustomAgGridTable.js +16 -38
- package/dist/components/composite/agGridTable/agGridTable-utils.d.ts +9 -0
- package/dist/components/composite/agGridTable/agGridTable-utils.js +1 -0
- package/dist/components/composite/agGridTable/cellEditors/index.js +3 -2
- package/dist/components/composite/agGridTable/cellEditors/numericEditor.d.ts +21 -19
- package/dist/components/composite/agGridTable/cellEditors/numericEditor.js +44 -57
- package/dist/components/composite/agGridTable/index.d.ts +2 -2
- package/dist/components/composite/agGridTable/index.js +5 -6
- package/dist/components/composite/dnd-table/dnd-table-add-rows-dialog.js +1 -0
- package/dist/components/composite/dnd-table/dnd-table-row.js +1 -0
- package/dist/components/composite/dnd-table/dnd-table.js +1 -0
- package/dist/components/composite/filter/HeaderFilterForm.js +1 -0
- package/dist/components/composite/filter/expert/ExpertFilterForm.js +1 -0
- package/dist/components/composite/filter/explicitNaming/ExplicitNamingFilterForm.js +122 -91
- package/dist/components/composite/index.js +4 -5
- package/dist/components/index.js +6 -5
- package/dist/components/ui/csvDownloader/use-csv-export.js +2 -2
- package/dist/components/ui/csvPicker/csv-picker-confirmation-dialog.d.ts +11 -0
- package/dist/components/ui/csvPicker/csv-picker-confirmation-dialog.js +65 -0
- package/dist/components/ui/csvPicker/csv-picker.d.ts +24 -0
- package/dist/components/ui/csvPicker/csv-picker.js +123 -0
- package/dist/components/{composite/agGridTable/csvUploader → ui/csvPicker}/index.d.ts +2 -2
- package/dist/components/ui/csvPicker/index.js +4 -0
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/index.js +2 -0
- package/dist/features/index.js +1 -0
- package/dist/features/network-modifications/battery/creation/BatteryCreationForm.js +2 -3
- package/dist/features/network-modifications/battery/creation/batteryCreation.utils.js +2 -3
- package/dist/features/network-modifications/battery/modification/BatteryDialogHeader.js +2 -3
- package/dist/features/network-modifications/battery/modification/BatteryDialogTabsContent.js +2 -3
- package/dist/features/network-modifications/battery/modification/batteryModification.utils.js +2 -3
- package/dist/features/network-modifications/by-filter/assignment/assignment/assignment-form.js +1 -0
- package/dist/features/network-modifications/by-filter/assignment/modification-by-assignment-form.js +1 -0
- package/dist/features/network-modifications/by-filter/deletion/ByFilterDeletionForm.js +1 -0
- package/dist/features/network-modifications/common/activePowerControl/ActivePowerControlForm.js +1 -0
- package/dist/features/network-modifications/common/connectivity/ConnectivityForm.js +1 -0
- package/dist/features/network-modifications/common/connectivity/PositionForm.js +1 -0
- package/dist/features/network-modifications/common/connectivity/VoltageLevelConnectivityForm.js +1 -0
- package/dist/features/network-modifications/common/measurements/BusbarSectionVoltageMeasurementsForm.js +2 -3
- package/dist/features/network-modifications/common/measurements/PowerWithValidityForm.js +1 -0
- package/dist/features/network-modifications/common/properties/PropertiesForm.js +1 -0
- package/dist/features/network-modifications/common/properties/PropertyForm.js +1 -0
- package/dist/features/network-modifications/common/reactiveLimits/ReactiveLimitsForm.js +1 -0
- package/dist/features/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/ReactiveCapabilityCurveRowForm.js +1 -0
- package/dist/features/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/ReactiveCapabilityCurveTableForm.js +1 -0
- package/dist/features/network-modifications/common/regulatingTerminal/RegulatingTerminalForm.js +1 -0
- package/dist/features/network-modifications/common/setpoints/SetPointsForm.js +1 -0
- package/dist/features/network-modifications/common/shortCircuit/ShortCircuitForm.js +1 -0
- package/dist/features/network-modifications/common/voltageRegulation/VoltageRegulationForm.js +1 -0
- package/dist/features/network-modifications/equipmentDeletion/EquipmentDeletionForm.js +2 -3
- package/dist/features/network-modifications/equipmentDeletion/equipmentDeletion.utils.js +1 -0
- package/dist/features/network-modifications/equipmentDeletion/hvdcLccDeletion/ShuntCompensatorSelectionForm.js +1 -0
- package/dist/features/network-modifications/generator/creation/GeneratorCreationForm.js +2 -3
- package/dist/features/network-modifications/generator/creation/generatorCreation.utils.js +2 -3
- package/dist/features/network-modifications/generator/modification/GeneratorDialogHeader.js +2 -3
- package/dist/features/network-modifications/generator/modification/GeneratorDialogTabsContent.js +2 -3
- package/dist/features/network-modifications/generator/modification/generatorModification.utils.js +2 -3
- package/dist/features/network-modifications/index.js +1 -0
- package/dist/features/network-modifications/load/common/LoadDialogHeader.js +2 -3
- package/dist/features/network-modifications/load/creation/loadCreation.utils.js +1 -0
- package/dist/features/network-modifications/load/modification/loadModification.utils.js +2 -3
- package/dist/features/network-modifications/shunt-compensator/common/CharacteristicsForm.js +1 -0
- package/dist/features/network-modifications/shunt-compensator/creation/ShuntCompensatorCreationForm.js +2 -3
- package/dist/features/network-modifications/shunt-compensator/creation/shuntCompensatorCreation.utils.js +2 -3
- package/dist/features/network-modifications/shunt-compensator/modification/ShuntCompensatorModificationForm.js +2 -3
- package/dist/features/network-modifications/shunt-compensator/modification/shuntCompensatorModification.utils.js +2 -3
- package/dist/features/network-modifications/substation/creation/SubstationCreationForm.js +2 -3
- package/dist/features/network-modifications/substation/modification/SubstationModificationForm.js +2 -3
- package/dist/features/network-modifications/voltageLevel/creation/VoltageLevelCreationForm.js +2 -3
- package/dist/features/network-modifications/voltageLevel/creation/index.js +2 -3
- package/dist/features/network-modifications/voltageLevel/creation/tabs/characteristicsTab/CharacteristicsTab.js +1 -0
- package/dist/features/network-modifications/voltageLevel/creation/tabs/structureTab/StructureTab.js +1 -0
- package/dist/features/network-modifications/voltageLevel/creation/tabs/structureTab/couplingOmnibus/CouplingOmnibusForm.js +1 -0
- package/dist/features/network-modifications/voltageLevel/creation/tabs/structureTab/switchesBetweenSections/SwitchesBetweenSections.js +1 -0
- package/dist/features/network-modifications/voltageLevel/creation/tabs/substationTab/SubstationCreationSection.js +2 -3
- package/dist/features/network-modifications/voltageLevel/creation/tabs/substationTab/SubstationTab.js +1 -0
- package/dist/features/network-modifications/voltageLevel/creation/voltageLevelCreation.utils.js +2 -3
- package/dist/features/network-modifications/voltageLevel/index.js +2 -3
- package/dist/features/network-modifications/voltageLevel/modification/VoltageLevelModificationForm.js +2 -3
- package/dist/features/parameters/common/ProviderParam.js +1 -0
- package/dist/features/parameters/common/contingency-table/columns-definitions.js +1 -0
- package/dist/features/parameters/common/limitreductions/limit-reduction-table-cell.js +1 -0
- package/dist/features/parameters/common/limitreductions/limit-reductions-table-form.js +1 -0
- package/dist/features/parameters/common/name-element-editor/name-element-editor-utils.js +1 -0
- package/dist/features/parameters/common/parameter-field.js +1 -0
- package/dist/features/parameters/common/parameter-table-field/parameter-table-field.js +1 -0
- package/dist/features/parameters/common/voltage-level-table/custom-voltage-level-table-cell.js +1 -0
- package/dist/features/parameters/common/widget/parameter-float.js +1 -0
- package/dist/features/parameters/common/widget/parameter-line-directory-items-input.js +1 -0
- package/dist/features/parameters/common/widget/parameter-line-slider.js +1 -0
- package/dist/features/parameters/dynamic-margin-calculation/dynamic-margin-calculation-form.js +1 -0
- package/dist/features/parameters/dynamic-margin-calculation/dynamic-margin-calculation-inline.js +1 -0
- package/dist/features/parameters/dynamic-margin-calculation/loads-variations-parameters.js +1 -0
- package/dist/features/parameters/dynamic-margin-calculation/use-dynamic-margin-calculation-parameters-form.js +1 -0
- package/dist/features/parameters/dynamic-security-analysis/contingency-parameters.js +1 -0
- package/dist/features/parameters/dynamic-security-analysis/dynamic-security-analysis-inline.js +1 -0
- package/dist/features/parameters/dynamic-security-analysis/dynamic-security-analysis-parameters-form.js +1 -0
- package/dist/features/parameters/dynamic-security-analysis/use-dynamic-security-analysis-parameters-form.js +1 -0
- package/dist/features/parameters/dynamic-simulation/dynamic-simulation-inline.js +1 -0
- package/dist/features/parameters/dynamic-simulation/dynamic-simulation-parameters-form.js +1 -0
- package/dist/features/parameters/dynamic-simulation/use-dynamic-simulation-parameters-form.js +1 -0
- package/dist/features/parameters/loadflow/load-flow-general-parameters.js +1 -0
- package/dist/features/parameters/loadflow/load-flow-parameters-content.js +1 -0
- package/dist/features/parameters/loadflow/load-flow-parameters-dialog.js +1 -0
- package/dist/features/parameters/loadflow/load-flow-parameters-form.js +1 -0
- package/dist/features/parameters/loadflow/load-flow-parameters-header.js +1 -0
- package/dist/features/parameters/loadflow/load-flow-parameters-inline.js +1 -0
- package/dist/features/parameters/loadflow/load-flow-parameters-utils.js +1 -0
- package/dist/features/parameters/loadflow/use-load-flow-parameters-form.js +1 -0
- package/dist/features/parameters/network-visualizations/map-parameters.js +1 -0
- package/dist/features/parameters/network-visualizations/network-area-diagram-parameters.js +1 -0
- package/dist/features/parameters/network-visualizations/network-visualizations-form.js +1 -0
- package/dist/features/parameters/network-visualizations/network-visualizations-parameters-dialog.js +1 -0
- package/dist/features/parameters/network-visualizations/network-visualizations-parameters-inline.js +1 -0
- package/dist/features/parameters/network-visualizations/single-line-diagram-parameters.js +1 -0
- package/dist/features/parameters/network-visualizations/use-network-visualizations-parameters-form.js +1 -0
- package/dist/features/parameters/pcc-min/pcc-min-form-utils.js +1 -0
- package/dist/features/parameters/pcc-min/pcc-min-parameters-dialog.js +1 -0
- package/dist/features/parameters/pcc-min/pcc-min-parameters-form.js +1 -0
- package/dist/features/parameters/pcc-min/pcc-min-parameters-inline.js +1 -0
- package/dist/features/parameters/pcc-min/use-pcc-min-parameters-form.js +1 -0
- package/dist/features/parameters/security-analysis/columns-definitions.js +1 -0
- package/dist/features/parameters/security-analysis/security-analysis-parameters-dialog.js +1 -0
- package/dist/features/parameters/security-analysis/security-analysis-parameters-form.js +1 -0
- package/dist/features/parameters/security-analysis/security-analysis-parameters-inline.js +1 -0
- package/dist/features/parameters/security-analysis/security-analysis-parameters-selector.js +1 -0
- package/dist/features/parameters/security-analysis/security-analysis-violations-hiding.js +1 -0
- package/dist/features/parameters/security-analysis/use-security-analysis-parameters-form.js +1 -0
- package/dist/features/parameters/sensi/columns-definitions.js +1 -0
- package/dist/features/parameters/sensi/sensitivity-analysis-parameters-dialog.js +1 -0
- package/dist/features/parameters/sensi/sensitivity-analysis-parameters-form.js +1 -0
- package/dist/features/parameters/sensi/sensitivity-analysis-parameters-inline.js +1 -0
- package/dist/features/parameters/sensi/sensitivity-parameters-fields.js +1 -0
- package/dist/features/parameters/sensi/sensitivity-parameters-selector.js +33 -4
- package/dist/features/parameters/sensi/use-sensitivity-analysis-parameters.js +1 -0
- package/dist/features/parameters/sensi/utils.js +1 -0
- package/dist/features/parameters/short-circuit/short-circuit-general-tab-panel.js +1 -0
- package/dist/features/parameters/short-circuit/short-circuit-icc-cluster-table-cell.js +1 -0
- package/dist/features/parameters/short-circuit/short-circuit-icc-material-table-cell.js +1 -0
- package/dist/features/parameters/short-circuit/short-circuit-parameters-content.js +1 -0
- package/dist/features/parameters/short-circuit/short-circuit-parameters-dialog.js +1 -0
- package/dist/features/parameters/short-circuit/short-circuit-parameters-form.js +1 -0
- package/dist/features/parameters/short-circuit/short-circuit-parameters-inline.js +1 -0
- package/dist/features/parameters/short-circuit/short-circuit-parameters-utils.js +1 -0
- package/dist/features/parameters/short-circuit/short-circuit-power-electronics-tab-panel.js +1 -0
- package/dist/features/parameters/short-circuit/short-circuit-study-area-tab-panel.js +1 -0
- package/dist/features/parameters/short-circuit/use-short-circuit-parameters-form.js +1 -0
- package/dist/features/parameters/voltage-init/equipment-selection-parameters.js +1 -0
- package/dist/features/parameters/voltage-init/general-parameters.js +1 -0
- package/dist/features/parameters/voltage-init/use-voltage-init-parameters-form.js +1 -0
- package/dist/features/parameters/voltage-init/voltage-init-form-utils.js +1 -0
- package/dist/features/parameters/voltage-init/voltage-init-parameters-dialog.js +1 -0
- package/dist/features/parameters/voltage-init/voltage-init-parameters-form.js +1 -0
- package/dist/features/parameters/voltage-init/voltage-init-parameters-inline.js +1 -0
- package/dist/features/parameters/voltage-init/voltage-limits-parameters.js +1 -0
- package/dist/index.js +12 -8
- package/dist/translations/en/commonButtonEn.d.ts +2 -0
- package/dist/translations/en/commonButtonEn.js +2 -0
- package/dist/translations/en/csvEn.d.ts +2 -1
- package/dist/translations/en/csvEn.js +5 -4
- package/dist/translations/fr/commonButtonFr.d.ts +2 -0
- package/dist/translations/fr/commonButtonFr.js +2 -0
- package/dist/translations/fr/csvFr.d.ts +2 -1
- package/dist/translations/fr/csvFr.js +6 -5
- package/dist/utils/algos.d.ts +1 -0
- package/dist/utils/algos.js +13 -1
- package/dist/utils/functions.d.ts +5 -0
- package/dist/utils/functions.js +5 -0
- package/dist/utils/index.js +6 -3
- package/dist/utils/langs.d.ts +1 -0
- package/dist/utils/langs.js +5 -1
- package/package.json +1 -2
- package/dist/components/composite/agGridTable/BottomRightButtons.d.ts +0 -14
- package/dist/components/composite/agGridTable/BottomRightButtons.js +0 -62
- package/dist/components/composite/agGridTable/csvUploader/CsvUploader.d.ts +0 -15
- package/dist/components/composite/agGridTable/csvUploader/CsvUploader.js +0 -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
|
|
7
|
-
cssProps
|
|
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 {
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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 ?? "
|
|
147
|
+
rowSelection: rowSelection ?? { mode: "multiRow" },
|
|
169
148
|
selectionColumnDef: { rowDrag: true, width: 80, pinned: "left" },
|
|
170
|
-
onRowDragMove: (
|
|
149
|
+
onRowDragMove: (event) => move(getIndex(event.node.data), event.overIndex),
|
|
171
150
|
detailRowAutoHeight: true,
|
|
172
|
-
onSelectionChanged: () => {
|
|
173
|
-
setSelectedRows(
|
|
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
|
-
|
|
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 @@
|
|
|
1
|
+
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CustomCellEditorProps } from 'ag-grid-react';
|
|
2
|
+
import { SuppressKeyboardEventParams } from 'ag-grid-community';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
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 './
|
|
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 {
|
|
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
|
-
|
|
7
|
-
CsvUploader,
|
|
5
|
+
BottomTableButtons,
|
|
8
6
|
CustomAgGridTable,
|
|
9
|
-
NumericEditor
|
|
7
|
+
NumericEditor,
|
|
8
|
+
suppressNonNumericKeyboardEvent
|
|
10
9
|
};
|
|
@@ -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
|
}
|