@gridsuite/commons-ui 0.193.0 → 0.194.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/directoryItemSelector/DirectoryItemSelector.js +0 -1
- package/dist/components/dnd-table-v2/deletable-table-row.d.ts +7 -0
- package/dist/components/dnd-table-v2/deletable-table-row.js +37 -0
- package/dist/components/dnd-table-v2/dnd-table-add-rows-dialog.d.ts +13 -0
- package/dist/components/dnd-table-v2/dnd-table-add-rows-dialog.js +75 -0
- package/dist/components/dnd-table-v2/dnd-table-bottom-left-buttons.d.ts +17 -0
- package/dist/components/dnd-table-v2/dnd-table-bottom-left-buttons.js +48 -0
- package/dist/components/dnd-table-v2/dnd-table-bottom-right-buttons.d.ts +17 -0
- package/dist/components/dnd-table-v2/dnd-table-bottom-right-buttons.js +103 -0
- package/dist/components/dnd-table-v2/dnd-table-row.d.ts +23 -0
- package/dist/components/dnd-table-v2/dnd-table-row.js +183 -0
- package/dist/components/dnd-table-v2/dnd-table-utils.d.ts +2 -0
- package/dist/components/dnd-table-v2/dnd-table-utils.js +10 -0
- package/dist/components/dnd-table-v2/dnd-table.d.ts +32 -0
- package/dist/components/dnd-table-v2/dnd-table.js +381 -0
- package/dist/components/dnd-table-v2/dnd-table.type.d.ts +70 -0
- package/dist/components/dnd-table-v2/dnd-table.type.js +19 -0
- package/dist/components/dnd-table-v2/index.d.ts +12 -0
- package/dist/components/dnd-table-v2/index.js +16 -0
- package/dist/components/index.js +3 -8
- package/dist/components/inputs/reactHookForm/DirectoryItemsInput.d.ts +1 -2
- package/dist/components/inputs/reactHookForm/DirectoryItemsInput.js +2 -5
- package/dist/components/inputs/reactHookForm/booleans/BooleanInput.js +6 -4
- package/dist/components/inputs/reactQueryBuilder/OperatorSelector.js +0 -1
- package/dist/components/parameters/common/contingency-table/columns-definitions.d.ts +4 -3
- package/dist/components/parameters/common/contingency-table/columns-definitions.js +23 -15
- package/dist/components/parameters/common/contingency-table/contingency-table.d.ts +2 -1
- package/dist/components/parameters/common/contingency-table/contingency-table.js +45 -44
- package/dist/components/parameters/common/contingency-table/index.js +2 -2
- package/dist/components/parameters/common/index.js +2 -2
- package/dist/components/parameters/common/parameter-field.js +2 -0
- package/dist/components/parameters/common/parameter-table/table-cell.js +1 -1
- package/dist/components/parameters/common/parameter-table-field/constants.d.ts +10 -0
- package/dist/components/parameters/common/parameter-table-field/constants.js +10 -0
- package/dist/components/parameters/common/{parameter-table → parameter-table-field}/index.d.ts +2 -3
- package/dist/components/parameters/common/parameter-table-field/index.js +9 -0
- package/dist/components/parameters/common/parameter-table-field/parameter-table-field.d.ts +11 -0
- package/dist/components/parameters/common/parameter-table-field/parameter-table-field.js +121 -0
- package/dist/components/parameters/common/parameters-edition-dialog-props.d.ts +1 -1
- package/dist/components/parameters/dynamic-margin-calculation/dynamic-margin-calculation-form.js +2 -0
- package/dist/components/parameters/dynamic-margin-calculation/dynamic-margin-calculation-inline.js +2 -0
- package/dist/components/parameters/dynamic-margin-calculation/loads-variations-parameters.js +9 -7
- package/dist/components/parameters/dynamic-margin-calculation/use-dynamic-margin-calculation-parameters-form.js +2 -0
- package/dist/components/parameters/dynamic-security-analysis/contingency-parameters.js +2 -0
- package/dist/components/parameters/dynamic-security-analysis/dynamic-security-analysis-inline.js +2 -0
- package/dist/components/parameters/dynamic-security-analysis/dynamic-security-analysis-parameters-form.js +2 -0
- package/dist/components/parameters/dynamic-security-analysis/use-dynamic-security-analysis-parameters-form.js +2 -0
- package/dist/components/parameters/dynamic-simulation/dynamic-simulation-inline.js +2 -0
- package/dist/components/parameters/dynamic-simulation/dynamic-simulation-parameters-form.js +2 -0
- package/dist/components/parameters/dynamic-simulation/mapping/mapping-parameters.js +0 -1
- package/dist/components/parameters/dynamic-simulation/use-dynamic-simulation-parameters-form.js +2 -0
- package/dist/components/parameters/index.js +3 -8
- package/dist/components/parameters/loadflow/load-flow-general-parameters.js +2 -0
- package/dist/components/parameters/loadflow/load-flow-parameters-content.js +2 -0
- package/dist/components/parameters/loadflow/load-flow-parameters-dialog.js +2 -0
- package/dist/components/parameters/loadflow/load-flow-parameters-header.js +2 -0
- package/dist/components/parameters/loadflow/load-flow-parameters-inline.js +3 -1
- package/dist/components/parameters/loadflow/load-flow-parameters-utils.js +2 -0
- package/dist/components/parameters/loadflow/use-load-flow-parameters-form.js +2 -0
- package/dist/components/parameters/network-visualizations/map-parameters.js +2 -0
- package/dist/components/parameters/network-visualizations/network-visualizations-form.js +2 -0
- package/dist/components/parameters/network-visualizations/network-visualizations-parameters-inline.js +3 -1
- package/dist/components/parameters/network-visualizations/single-line-diagram-parameters.js +2 -0
- package/dist/components/parameters/pcc-min/pcc-min-parameters-form.js +2 -0
- package/dist/components/parameters/pcc-min/pcc-min-parameters-inline.js +3 -1
- package/dist/components/parameters/security-analysis/columns-definitions.js +2 -0
- package/dist/components/parameters/security-analysis/security-analysis-parameters-dialog.js +3 -1
- package/dist/components/parameters/security-analysis/security-analysis-parameters-form.js +5 -4
- package/dist/components/parameters/security-analysis/security-analysis-parameters-inline.js +2 -0
- package/dist/components/parameters/security-analysis/security-analysis-parameters-selector.js +2 -0
- package/dist/components/parameters/security-analysis/security-analysis-violations-hiding.js +2 -0
- package/dist/components/parameters/security-analysis/use-security-analysis-parameters-form.d.ts +1 -1
- package/dist/components/parameters/security-analysis/use-security-analysis-parameters-form.js +7 -3
- package/dist/components/parameters/sensi/columns-definitions.d.ts +7 -180
- package/dist/components/parameters/sensi/columns-definitions.js +81 -73
- package/dist/components/parameters/sensi/index.js +1 -6
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-dialog.js +3 -1
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-form.js +4 -2
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-inline.js +2 -0
- package/dist/components/parameters/sensi/sensitivity-parameters-selector.js +52 -51
- package/dist/components/parameters/sensi/use-sensitivity-analysis-parameters.d.ts +2 -2
- package/dist/components/parameters/sensi/use-sensitivity-analysis-parameters.js +41 -61
- package/dist/components/parameters/sensi/utils.d.ts +4 -4
- package/dist/components/parameters/sensi/utils.js +8 -6
- package/dist/components/parameters/short-circuit/short-circuit-general-tab-panel.js +2 -0
- package/dist/components/parameters/short-circuit/short-circuit-parameters-content.js +2 -0
- package/dist/components/parameters/short-circuit/short-circuit-parameters-dialog.js +2 -0
- package/dist/components/parameters/short-circuit/short-circuit-parameters-inline.js +3 -1
- package/dist/components/parameters/short-circuit/short-circuit-parameters-utils.js +2 -0
- package/dist/components/parameters/short-circuit/short-circuit-power-electronics-tab-panel.js +2 -0
- package/dist/components/parameters/short-circuit/short-circuit-study-area-tab-panel.js +2 -0
- package/dist/components/parameters/short-circuit/use-short-circuit-parameters-form.js +2 -0
- package/dist/components/parameters/voltage-init/equipment-selection-parameters.js +2 -0
- package/dist/components/parameters/voltage-init/general-parameters.js +2 -0
- package/dist/components/parameters/voltage-init/voltage-init-parameters-form.js +2 -0
- package/dist/components/parameters/voltage-init/voltage-init-parameters-inline.js +3 -1
- package/dist/components/parameters/voltage-init/voltage-limits-parameters.js +17 -31
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/index.js +0 -2
- package/dist/index.js +3 -10
- package/package.json +1 -1
- package/dist/components/parameters/common/parameter-dnd-table-field.d.ts +0 -9
- package/dist/components/parameters/common/parameter-dnd-table-field.js +0 -86
- package/dist/components/parameters/common/parameter-table/index.js +0 -10
- package/dist/hooks/use-create-row-data.d.ts +0 -4
- package/dist/hooks/use-create-row-data.js +0 -19
- /package/dist/components/parameters/sensi/{sensitivity-Flow-parameters.d.ts → sensitivity-parameters-fields.d.ts} +0 -0
- /package/dist/components/parameters/sensi/{sensitivity-Flow-parameters.js → sensitivity-parameters-fields.js} +0 -0
|
@@ -16,7 +16,6 @@ import "localized-countries";
|
|
|
16
16
|
import "localized-countries/data/fr";
|
|
17
17
|
import "localized-countries/data/en";
|
|
18
18
|
import { useSnackMessage } from "../../hooks/useSnackMessage.js";
|
|
19
|
-
import "react-hook-form";
|
|
20
19
|
import { getExpansionPathsForSelected, fetchChildrenForExpandedNodes, initializeFromLastSelected, saveLastSelectedDirectoryFromNode } from "./utils.js";
|
|
21
20
|
const styles = {
|
|
22
21
|
icon: (theme) => ({
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TableRowProps } from '@mui/material';
|
|
2
|
+
type DeletableTableRowProps = TableRowProps & {
|
|
3
|
+
onClick: () => void;
|
|
4
|
+
disabledDeletion?: boolean | null;
|
|
5
|
+
};
|
|
6
|
+
export declare function DeletableTableRow({ onClick, disabledDeletion, children, ...otherProps }: Readonly<DeletableTableRowProps>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useIntl } from "react-intl";
|
|
4
|
+
import { TableRow, TableCell, Tooltip, IconButton } from "@mui/material";
|
|
5
|
+
import { Delete } from "@mui/icons-material";
|
|
6
|
+
function DeletableTableRow({
|
|
7
|
+
onClick,
|
|
8
|
+
disabledDeletion,
|
|
9
|
+
children,
|
|
10
|
+
...otherProps
|
|
11
|
+
}) {
|
|
12
|
+
const intl = useIntl();
|
|
13
|
+
const [isMouseHover, setIsMouseHover] = useState(false);
|
|
14
|
+
return /* @__PURE__ */ jsxs(
|
|
15
|
+
TableRow,
|
|
16
|
+
{
|
|
17
|
+
...otherProps,
|
|
18
|
+
onMouseEnter: () => setIsMouseHover(true),
|
|
19
|
+
onMouseLeave: () => setIsMouseHover(false),
|
|
20
|
+
children: [
|
|
21
|
+
children,
|
|
22
|
+
!disabledDeletion && /* @__PURE__ */ jsx(TableCell, { sx: { width: "5rem", textAlign: "center" }, children: isMouseHover && /* @__PURE__ */ jsx(
|
|
23
|
+
Tooltip,
|
|
24
|
+
{
|
|
25
|
+
title: intl.formatMessage({
|
|
26
|
+
id: "DeleteRows"
|
|
27
|
+
}),
|
|
28
|
+
children: /* @__PURE__ */ jsx(IconButton, { onClick, children: /* @__PURE__ */ jsx(Delete, {}) })
|
|
29
|
+
}
|
|
30
|
+
) })
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
DeletableTableRow
|
|
37
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023, RTE (http://www.rte-france.com)
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
+
*/
|
|
7
|
+
interface DndTableAddRowsDialogProps {
|
|
8
|
+
open: boolean;
|
|
9
|
+
handleAddButton: (rowNumber: number) => void;
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function DndTableAddRowsDialog({ open, handleAddButton, onClose }: Readonly<DndTableAddRowsDialogProps>): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Dialog, DialogTitle, DialogContent, TextField, DialogActions, Button } from "@mui/material";
|
|
3
|
+
import { FormattedMessage } from "react-intl";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import "../overflowableText/OverflowableText.js";
|
|
6
|
+
import "../../utils/conversionUtils.js";
|
|
7
|
+
import "../../utils/types/equipmentType.js";
|
|
8
|
+
import "@mui/icons-material";
|
|
9
|
+
import "../../utils/yupConfig.js";
|
|
10
|
+
import "react-hook-form";
|
|
11
|
+
import "localized-countries";
|
|
12
|
+
import "localized-countries/data/fr";
|
|
13
|
+
import "localized-countries/data/en";
|
|
14
|
+
import "notistack";
|
|
15
|
+
import "../inputs/reactHookForm/provider/CustomFormProvider.js";
|
|
16
|
+
import { CancelButton } from "../inputs/reactHookForm/utils/CancelButton.js";
|
|
17
|
+
import "yup";
|
|
18
|
+
import "../treeViewFinder/TreeViewFinder.js";
|
|
19
|
+
import "../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
|
|
20
|
+
import "../customAGGrid/customAggrid.js";
|
|
21
|
+
import "ag-grid-community";
|
|
22
|
+
import "react-papaparse";
|
|
23
|
+
import "react-csv-downloader";
|
|
24
|
+
import "../inputs/reactHookForm/numbers/RangeInput.js";
|
|
25
|
+
import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
|
|
26
|
+
import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
|
|
27
|
+
import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
|
|
28
|
+
import "@material-symbols/svg-400/outlined/add_notes.svg?react";
|
|
29
|
+
import "../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
30
|
+
import "../inputs/reactHookForm/expandableInput/ExpandableInput.js";
|
|
31
|
+
import "@react-querybuilder/material";
|
|
32
|
+
import "../filter/expert/expertFilterConstants.js";
|
|
33
|
+
import "../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
34
|
+
import "uuid";
|
|
35
|
+
import "../inputs/reactQueryBuilder/PropertyValueEditor.js";
|
|
36
|
+
import "react-querybuilder";
|
|
37
|
+
function DndTableAddRowsDialog({ open, handleAddButton, onClose }) {
|
|
38
|
+
const [rowNumber, setRowNumber] = useState(1);
|
|
39
|
+
const handleClose = () => {
|
|
40
|
+
setRowNumber(1);
|
|
41
|
+
onClose();
|
|
42
|
+
};
|
|
43
|
+
return /* @__PURE__ */ jsxs(Dialog, { open, onClose: handleClose, children: [
|
|
44
|
+
/* @__PURE__ */ jsx(DialogTitle, { children: /* @__PURE__ */ jsx(FormattedMessage, { id: "AddRowsDialogTitle" }) }),
|
|
45
|
+
/* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(
|
|
46
|
+
TextField,
|
|
47
|
+
{
|
|
48
|
+
autoFocus: true,
|
|
49
|
+
type: "Number",
|
|
50
|
+
value: rowNumber,
|
|
51
|
+
onChange: (event) => {
|
|
52
|
+
setRowNumber(!event.target.value ? 0 : parseInt(event.target.value, 10));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
) }),
|
|
56
|
+
/* @__PURE__ */ jsxs(DialogActions, { children: [
|
|
57
|
+
/* @__PURE__ */ jsx(CancelButton, { onClick: handleClose }),
|
|
58
|
+
/* @__PURE__ */ jsx(
|
|
59
|
+
Button,
|
|
60
|
+
{
|
|
61
|
+
onClick: () => {
|
|
62
|
+
handleAddButton(rowNumber);
|
|
63
|
+
handleClose();
|
|
64
|
+
},
|
|
65
|
+
variant: "outlined",
|
|
66
|
+
disabled: rowNumber <= 0,
|
|
67
|
+
children: /* @__PURE__ */ jsx(FormattedMessage, { id: "AddRowsButton" })
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
] })
|
|
71
|
+
] });
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
DndTableAddRowsDialog
|
|
75
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023, RTE (http://www.rte-france.com)
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
+
*/
|
|
7
|
+
interface DndTableBottomLeftButtonsProps {
|
|
8
|
+
handleUploadButton: () => void;
|
|
9
|
+
uploadButtonMessageId: string;
|
|
10
|
+
handleResetButton: () => void;
|
|
11
|
+
resetButtonMessageId: string;
|
|
12
|
+
withResetButton?: boolean;
|
|
13
|
+
disableUploadButton?: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function DndTableBottomLeftButtons({ handleUploadButton, uploadButtonMessageId, handleResetButton, resetButtonMessageId, withResetButton, disableUploadButton, disabled, }: Readonly<DndTableBottomLeftButtonsProps>): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Grid, Tooltip, IconButton } from "@mui/material";
|
|
3
|
+
import { Upload, Replay } from "@mui/icons-material";
|
|
4
|
+
import { useIntl } from "react-intl";
|
|
5
|
+
function DndTableBottomLeftButtons({
|
|
6
|
+
handleUploadButton,
|
|
7
|
+
uploadButtonMessageId,
|
|
8
|
+
handleResetButton,
|
|
9
|
+
resetButtonMessageId,
|
|
10
|
+
withResetButton,
|
|
11
|
+
disableUploadButton,
|
|
12
|
+
disabled
|
|
13
|
+
}) {
|
|
14
|
+
const intl = useIntl();
|
|
15
|
+
return /* @__PURE__ */ jsxs(Grid, { container: true, item: true, xs: true, spacing: 1, children: [
|
|
16
|
+
/* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(
|
|
17
|
+
Tooltip,
|
|
18
|
+
{
|
|
19
|
+
title: intl.formatMessage({
|
|
20
|
+
id: uploadButtonMessageId
|
|
21
|
+
}),
|
|
22
|
+
placement: "top",
|
|
23
|
+
children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(
|
|
24
|
+
IconButton,
|
|
25
|
+
{
|
|
26
|
+
color: "primary",
|
|
27
|
+
onClick: () => handleUploadButton(),
|
|
28
|
+
disabled: disabled || disableUploadButton,
|
|
29
|
+
children: /* @__PURE__ */ jsx(Upload, {})
|
|
30
|
+
}
|
|
31
|
+
) })
|
|
32
|
+
}
|
|
33
|
+
) }),
|
|
34
|
+
withResetButton && /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(
|
|
35
|
+
Tooltip,
|
|
36
|
+
{
|
|
37
|
+
title: intl.formatMessage({
|
|
38
|
+
id: resetButtonMessageId
|
|
39
|
+
}),
|
|
40
|
+
placement: "top",
|
|
41
|
+
children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(IconButton, { color: "primary", onClick: () => handleResetButton(), disabled, children: /* @__PURE__ */ jsx(Replay, {}) }) })
|
|
42
|
+
}
|
|
43
|
+
) })
|
|
44
|
+
] });
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
DndTableBottomLeftButtons
|
|
48
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023, RTE (http://www.rte-france.com)
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
+
*/
|
|
7
|
+
export interface DndTableBottomRightButtonsProps {
|
|
8
|
+
arrayFormName: string;
|
|
9
|
+
handleAddButton: () => void;
|
|
10
|
+
handleDeleteButton: () => void;
|
|
11
|
+
handleMoveUpButton: () => void;
|
|
12
|
+
handleMoveDownButton: () => void;
|
|
13
|
+
disableAddingRows?: boolean;
|
|
14
|
+
showMoveArrow?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function DndTableBottomRightButtons({ arrayFormName, handleAddButton, handleDeleteButton, handleMoveUpButton, handleMoveDownButton, disableAddingRows, showMoveArrow, disabled, }: Readonly<DndTableBottomRightButtonsProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Grid, Tooltip, IconButton } from "@mui/material";
|
|
3
|
+
import { AddCircle, Delete, ArrowUpward, ArrowDownward } from "@mui/icons-material";
|
|
4
|
+
import { useWatch } from "react-hook-form";
|
|
5
|
+
import { useIntl } from "react-intl";
|
|
6
|
+
import { SELECTED } from "./dnd-table.type.js";
|
|
7
|
+
function DndTableBottomRightButtons({
|
|
8
|
+
arrayFormName,
|
|
9
|
+
handleAddButton,
|
|
10
|
+
handleDeleteButton,
|
|
11
|
+
handleMoveUpButton,
|
|
12
|
+
handleMoveDownButton,
|
|
13
|
+
disableAddingRows,
|
|
14
|
+
showMoveArrow,
|
|
15
|
+
disabled
|
|
16
|
+
}) {
|
|
17
|
+
const intl = useIntl();
|
|
18
|
+
const currentRows = useWatch({
|
|
19
|
+
name: arrayFormName
|
|
20
|
+
});
|
|
21
|
+
const noRowsSelected = currentRows ? !currentRows.some((row) => row[SELECTED]) : true;
|
|
22
|
+
const firstRowSelected = noRowsSelected ? void 0 : currentRows[0]?.[SELECTED];
|
|
23
|
+
const lastRowSelected = noRowsSelected ? void 0 : currentRows[currentRows.length - 1]?.[SELECTED];
|
|
24
|
+
return /* @__PURE__ */ jsxs(Grid, { container: true, item: true, xs: true, spacing: 1, sx: { justifyContent: "flex-end" }, children: [
|
|
25
|
+
/* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(
|
|
26
|
+
Tooltip,
|
|
27
|
+
{
|
|
28
|
+
title: intl.formatMessage({
|
|
29
|
+
id: "DndAddRows"
|
|
30
|
+
}),
|
|
31
|
+
placement: "top",
|
|
32
|
+
children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(
|
|
33
|
+
IconButton,
|
|
34
|
+
{
|
|
35
|
+
color: "primary",
|
|
36
|
+
onClick: () => handleAddButton(),
|
|
37
|
+
disabled: disabled || disableAddingRows,
|
|
38
|
+
children: /* @__PURE__ */ jsx(AddCircle, {})
|
|
39
|
+
}
|
|
40
|
+
) })
|
|
41
|
+
}
|
|
42
|
+
) }),
|
|
43
|
+
/* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(
|
|
44
|
+
Tooltip,
|
|
45
|
+
{
|
|
46
|
+
title: intl.formatMessage({
|
|
47
|
+
id: "DndDeleteRows"
|
|
48
|
+
}),
|
|
49
|
+
placement: "top",
|
|
50
|
+
children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(
|
|
51
|
+
IconButton,
|
|
52
|
+
{
|
|
53
|
+
color: "primary",
|
|
54
|
+
onClick: () => handleDeleteButton(),
|
|
55
|
+
disabled: disabled || noRowsSelected,
|
|
56
|
+
children: /* @__PURE__ */ jsx(Delete, {})
|
|
57
|
+
}
|
|
58
|
+
) })
|
|
59
|
+
}
|
|
60
|
+
) }),
|
|
61
|
+
showMoveArrow && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
62
|
+
/* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(
|
|
63
|
+
Tooltip,
|
|
64
|
+
{
|
|
65
|
+
title: intl.formatMessage({
|
|
66
|
+
id: "MoveUpRows"
|
|
67
|
+
}),
|
|
68
|
+
placement: "top",
|
|
69
|
+
children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(
|
|
70
|
+
IconButton,
|
|
71
|
+
{
|
|
72
|
+
color: "primary",
|
|
73
|
+
onClick: () => handleMoveUpButton(),
|
|
74
|
+
disabled: disabled || noRowsSelected || firstRowSelected,
|
|
75
|
+
children: /* @__PURE__ */ jsx(ArrowUpward, {})
|
|
76
|
+
}
|
|
77
|
+
) })
|
|
78
|
+
}
|
|
79
|
+
) }),
|
|
80
|
+
/* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(
|
|
81
|
+
Tooltip,
|
|
82
|
+
{
|
|
83
|
+
title: intl.formatMessage({
|
|
84
|
+
id: "MoveDownRows"
|
|
85
|
+
}),
|
|
86
|
+
placement: "top",
|
|
87
|
+
children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(
|
|
88
|
+
IconButton,
|
|
89
|
+
{
|
|
90
|
+
color: "primary",
|
|
91
|
+
onClick: () => handleMoveDownButton(),
|
|
92
|
+
disabled: disabled || noRowsSelected || lastRowSelected,
|
|
93
|
+
children: /* @__PURE__ */ jsx(ArrowDownward, {})
|
|
94
|
+
}
|
|
95
|
+
) })
|
|
96
|
+
}
|
|
97
|
+
) })
|
|
98
|
+
] })
|
|
99
|
+
] });
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
DndTableBottomRightButtons
|
|
103
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SxProps, TableRowProps, Theme } from '@mui/material';
|
|
2
|
+
import { DraggableProvided, DraggableStateSnapshot } from '@hello-pangea/dnd';
|
|
3
|
+
import { DndColumn } from './dnd-table.type';
|
|
4
|
+
export type DndTableRowProps = TableRowProps & {
|
|
5
|
+
rowId: string;
|
|
6
|
+
tableName: string;
|
|
7
|
+
columnsDefinition: DndColumn[];
|
|
8
|
+
index: number;
|
|
9
|
+
provided: DraggableProvided;
|
|
10
|
+
snapshot: DraggableStateSnapshot;
|
|
11
|
+
disableDragAndDrop: boolean;
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
previousValues?: any[];
|
|
14
|
+
disableTableCell?: (rowIndex: number, column: any, tableName: string, previousValues?: any[]) => boolean;
|
|
15
|
+
getPreviousValue?: (rowIndex: number, column: any, tableName: string, previousValues?: any[]) => number | undefined;
|
|
16
|
+
isValueModified?: (index: number, tableName: string) => boolean;
|
|
17
|
+
disabledDeletion?: boolean;
|
|
18
|
+
onChangeRow: (index: number) => void;
|
|
19
|
+
onDeleteRow: (index: number) => void;
|
|
20
|
+
multiselect?: boolean;
|
|
21
|
+
nextSnapshotCellWidthSx: (isDragging: boolean) => SxProps<Theme> | undefined;
|
|
22
|
+
};
|
|
23
|
+
export declare function DndTableRow({ rowId, tableName, columnsDefinition, index, provided, snapshot, disableDragAndDrop, disabled, disableTableCell, previousValues, getPreviousValue, isValueModified, disabledDeletion, onChangeRow, onDeleteRow, multiselect, nextSnapshotCellWidthSx, }: Readonly<DndTableRowProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Tooltip, TableCell } from "@mui/material";
|
|
3
|
+
import { DragIndicator } from "@mui/icons-material";
|
|
4
|
+
import { useIntl } from "react-intl";
|
|
5
|
+
import { CheckboxInput } from "../inputs/reactHookForm/booleans/CheckboxInput.js";
|
|
6
|
+
import { SELECTED, DndColumnType } from "./dnd-table.type.js";
|
|
7
|
+
import "../overflowableText/OverflowableText.js";
|
|
8
|
+
import "../../utils/conversionUtils.js";
|
|
9
|
+
import "../../utils/types/equipmentType.js";
|
|
10
|
+
import { mergeSx } from "../../utils/styles.js";
|
|
11
|
+
import "../../utils/yupConfig.js";
|
|
12
|
+
import { ChipItemsInput } from "../inputs/reactHookForm/chip-items-input.js";
|
|
13
|
+
import { DirectoryItemsInput } from "../inputs/reactHookForm/DirectoryItemsInput.js";
|
|
14
|
+
import { RawReadOnlyInput } from "../inputs/reactHookForm/RawReadOnlyInput.js";
|
|
15
|
+
import "../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
|
|
16
|
+
import "react";
|
|
17
|
+
import "react-hook-form";
|
|
18
|
+
import "../customAGGrid/customAggrid.js";
|
|
19
|
+
import "ag-grid-community";
|
|
20
|
+
import "react-papaparse";
|
|
21
|
+
import "react-csv-downloader";
|
|
22
|
+
import "yup";
|
|
23
|
+
import { AutocompleteInput } from "../inputs/reactHookForm/autocompleteInputs/AutocompleteInput.js";
|
|
24
|
+
import { SwitchInput } from "../inputs/reactHookForm/booleans/SwitchInput.js";
|
|
25
|
+
import "../inputs/reactHookForm/provider/CustomFormProvider.js";
|
|
26
|
+
import "../inputs/reactHookForm/numbers/RangeInput.js";
|
|
27
|
+
import "localized-countries";
|
|
28
|
+
import "localized-countries/data/fr";
|
|
29
|
+
import "localized-countries/data/en";
|
|
30
|
+
import { SelectInput } from "../inputs/reactHookForm/selectInputs/SelectInput.js";
|
|
31
|
+
import { TableNumericalInput } from "../inputs/reactHookForm/tableInputs/table-numerical-input.js";
|
|
32
|
+
import { TableTextInput } from "../inputs/reactHookForm/tableInputs/table-text-input.js";
|
|
33
|
+
import { DescriptionInput } from "../inputs/reactHookForm/text/DescriptionInput.js";
|
|
34
|
+
import "../inputs/reactHookForm/expandableInput/ExpandableInput.js";
|
|
35
|
+
import "notistack";
|
|
36
|
+
import "@react-querybuilder/material";
|
|
37
|
+
import "../filter/expert/expertFilterConstants.js";
|
|
38
|
+
import "../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
39
|
+
import "uuid";
|
|
40
|
+
import "../inputs/reactQueryBuilder/PropertyValueEditor.js";
|
|
41
|
+
import "react-querybuilder";
|
|
42
|
+
import { DeletableTableRow } from "./deletable-table-row.js";
|
|
43
|
+
function DefaultTableCell({ name, rowIndex, column, width, ...props }) {
|
|
44
|
+
return /* @__PURE__ */ jsx(TableCell, { sx: mergeSx({ padding: 1 }, width), children: /* @__PURE__ */ jsx(RawReadOnlyInput, { name, ...props }) }, column.dataKey);
|
|
45
|
+
}
|
|
46
|
+
function EditableTableCell({
|
|
47
|
+
name,
|
|
48
|
+
rowIndex,
|
|
49
|
+
column,
|
|
50
|
+
width,
|
|
51
|
+
previousValue,
|
|
52
|
+
valueModified,
|
|
53
|
+
onChangeCell,
|
|
54
|
+
...props
|
|
55
|
+
}) {
|
|
56
|
+
return /* @__PURE__ */ jsxs(TableCell, { sx: mergeSx({ padding: 0.5, maxWidth: column.maxWidth }, width), children: [
|
|
57
|
+
column.type === DndColumnType.NUMERIC && /* @__PURE__ */ jsx(
|
|
58
|
+
TableNumericalInput,
|
|
59
|
+
{
|
|
60
|
+
...props,
|
|
61
|
+
name,
|
|
62
|
+
previousValue,
|
|
63
|
+
valueModified,
|
|
64
|
+
adornment: column?.adornment,
|
|
65
|
+
isClearable: column?.clearable,
|
|
66
|
+
style: {
|
|
67
|
+
textAlign: column?.textAlign
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
),
|
|
71
|
+
column.type === DndColumnType.TEXT && /* @__PURE__ */ jsx(TableTextInput, { ...props, name, showErrorMsg: column.showErrorMsg }),
|
|
72
|
+
column.type === DndColumnType.AUTOCOMPLETE && /* @__PURE__ */ jsx(
|
|
73
|
+
AutocompleteInput,
|
|
74
|
+
{
|
|
75
|
+
forcePopupIcon: true,
|
|
76
|
+
freeSolo: true,
|
|
77
|
+
name,
|
|
78
|
+
options: column.options,
|
|
79
|
+
inputTransform: (value) => value ?? "",
|
|
80
|
+
outputTransform: (value) => value,
|
|
81
|
+
size: "small"
|
|
82
|
+
}
|
|
83
|
+
),
|
|
84
|
+
column.type === DndColumnType.SELECT && /* @__PURE__ */ jsx(SelectInput, { options: column.options, name, size: "small", fullWidth: true, disableClearable: true }),
|
|
85
|
+
column.type === DndColumnType.DIRECTORY_ITEMS && /* @__PURE__ */ jsx(
|
|
86
|
+
DirectoryItemsInput,
|
|
87
|
+
{
|
|
88
|
+
name,
|
|
89
|
+
equipmentTypes: column.equipmentTypes,
|
|
90
|
+
elementType: column.elementType,
|
|
91
|
+
titleId: column.titleId,
|
|
92
|
+
hideErrorMessage: true,
|
|
93
|
+
label: void 0,
|
|
94
|
+
onChange: (value) => column.shouldHandleOnChangeCell && onChangeCell?.(value)
|
|
95
|
+
}
|
|
96
|
+
),
|
|
97
|
+
column.type === DndColumnType.CHIP_ITEMS && /* @__PURE__ */ jsx(ChipItemsInput, { name, hideErrorMessage: true }),
|
|
98
|
+
column.type === DndColumnType.SWITCH && /* @__PURE__ */ jsx(
|
|
99
|
+
SwitchInput,
|
|
100
|
+
{
|
|
101
|
+
name,
|
|
102
|
+
formProps: {
|
|
103
|
+
// callback to propagate a change to parent via column config
|
|
104
|
+
onChange: (_, checked) => column.shouldHandleOnChangeCell && onChangeCell?.(checked)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
column.type === DndColumnType.DESCRIPTIONS && /* @__PURE__ */ jsx(DescriptionInput, { name }),
|
|
109
|
+
column.type === DndColumnType.CUSTOM && column.component(rowIndex)
|
|
110
|
+
] }, column.dataKey);
|
|
111
|
+
}
|
|
112
|
+
function DndTableRow({
|
|
113
|
+
rowId,
|
|
114
|
+
tableName,
|
|
115
|
+
columnsDefinition,
|
|
116
|
+
index,
|
|
117
|
+
provided,
|
|
118
|
+
snapshot,
|
|
119
|
+
disableDragAndDrop,
|
|
120
|
+
disabled,
|
|
121
|
+
disableTableCell,
|
|
122
|
+
previousValues,
|
|
123
|
+
getPreviousValue,
|
|
124
|
+
isValueModified,
|
|
125
|
+
disabledDeletion,
|
|
126
|
+
onChangeRow,
|
|
127
|
+
onDeleteRow,
|
|
128
|
+
multiselect,
|
|
129
|
+
nextSnapshotCellWidthSx
|
|
130
|
+
}) {
|
|
131
|
+
const intl = useIntl();
|
|
132
|
+
return /* @__PURE__ */ jsxs(
|
|
133
|
+
DeletableTableRow,
|
|
134
|
+
{
|
|
135
|
+
ref: provided.innerRef,
|
|
136
|
+
...provided.draggableProps,
|
|
137
|
+
onClick: () => {
|
|
138
|
+
onDeleteRow(index);
|
|
139
|
+
},
|
|
140
|
+
disabledDeletion: disabledDeletion || multiselect,
|
|
141
|
+
children: [
|
|
142
|
+
!disableDragAndDrop && /* @__PURE__ */ jsx(
|
|
143
|
+
Tooltip,
|
|
144
|
+
{
|
|
145
|
+
title: intl.formatMessage({
|
|
146
|
+
id: "DragAndDrop"
|
|
147
|
+
}),
|
|
148
|
+
placement: "right",
|
|
149
|
+
children: /* @__PURE__ */ jsx(
|
|
150
|
+
TableCell,
|
|
151
|
+
{
|
|
152
|
+
sx: mergeSx({ textAlign: "center" }, nextSnapshotCellWidthSx(snapshot.isDragging)),
|
|
153
|
+
...disabled ? {} : { ...provided.dragHandleProps },
|
|
154
|
+
children: /* @__PURE__ */ jsx(DragIndicator, {})
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
),
|
|
159
|
+
multiselect && /* @__PURE__ */ jsx(TableCell, { sx: mergeSx({ textAlign: "center" }, nextSnapshotCellWidthSx(snapshot.isDragging)), children: /* @__PURE__ */ jsx(CheckboxInput, { name: `${tableName}[${index}].${SELECTED}`, formProps: { disabled } }) }),
|
|
160
|
+
columnsDefinition.map((column) => {
|
|
161
|
+
const Cell = column.editable ? EditableTableCell : DefaultTableCell;
|
|
162
|
+
return /* @__PURE__ */ jsx(
|
|
163
|
+
Cell,
|
|
164
|
+
{
|
|
165
|
+
name: `${tableName}[${index}].${column.dataKey}`,
|
|
166
|
+
rowIndex: index,
|
|
167
|
+
column,
|
|
168
|
+
width: nextSnapshotCellWidthSx(snapshot.isDragging),
|
|
169
|
+
disabled: disableTableCell ? disableTableCell(index, column, tableName, previousValues) : disabled,
|
|
170
|
+
previousValue: getPreviousValue ? getPreviousValue(index, column, tableName, previousValues) : void 0,
|
|
171
|
+
valueModified: isValueModified ? isValueModified(index, tableName) : false,
|
|
172
|
+
onChangeCell: () => onChangeRow(index)
|
|
173
|
+
},
|
|
174
|
+
rowId + column.dataKey
|
|
175
|
+
);
|
|
176
|
+
})
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
export {
|
|
182
|
+
DndTableRow
|
|
183
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
function getDefaultRowData(columnsDefinition) {
|
|
2
|
+
const newRowData = {};
|
|
3
|
+
columnsDefinition.forEach((columnDefinition) => {
|
|
4
|
+
newRowData[columnDefinition.dataKey] = columnDefinition.initialValue ?? null;
|
|
5
|
+
});
|
|
6
|
+
return newRowData;
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
getDefaultRowData
|
|
10
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { UseFieldArrayReturn } from 'react-hook-form';
|
|
2
|
+
import { DndColumn } from './dnd-table.type';
|
|
3
|
+
export interface DndTableProps {
|
|
4
|
+
name: string;
|
|
5
|
+
useFieldArrayOutput: UseFieldArrayReturn;
|
|
6
|
+
columnsDefinition: DndColumn[];
|
|
7
|
+
tableHeight?: number;
|
|
8
|
+
allowedToAddRows?: () => Promise<boolean>;
|
|
9
|
+
createRows?: (numberOfRows: number) => {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}[];
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
withResetButton?: boolean;
|
|
14
|
+
withAddRowsDialog?: boolean;
|
|
15
|
+
previousValues?: any[];
|
|
16
|
+
disableTableCell?: (rowIndex: number, column: any, tableName: string, previousValues?: any[]) => boolean;
|
|
17
|
+
getPreviousValue?: (rowIndex: number, column: any, tableName: string, previousValues?: any[]) => number | undefined;
|
|
18
|
+
isValueModified?: (index: number, tableName: string) => boolean;
|
|
19
|
+
disableAddingRows?: boolean;
|
|
20
|
+
showMoveArrow?: boolean;
|
|
21
|
+
disableDragAndDrop?: boolean;
|
|
22
|
+
handleUploadButton?: () => void;
|
|
23
|
+
uploadButtonMessageId?: string;
|
|
24
|
+
handleResetButton?: () => void;
|
|
25
|
+
resetButtonMessageId?: string;
|
|
26
|
+
maxRows?: number;
|
|
27
|
+
disabledDeletion?: boolean;
|
|
28
|
+
multiselect?: boolean;
|
|
29
|
+
onChange?: (changedRow: any) => void;
|
|
30
|
+
onDelete?: (removedRows: any[]) => void;
|
|
31
|
+
}
|
|
32
|
+
export declare function DndTable(props: Readonly<DndTableProps>): import("react/jsx-runtime").JSX.Element;
|