@gridsuite/commons-ui 0.231.0 → 0.233.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.
|
@@ -10,6 +10,15 @@ import { hasNonEmptyRows } from "../../../utils/functions.js";
|
|
|
10
10
|
import "@mui/icons-material";
|
|
11
11
|
import { CustomAGGrid } from "../customAGGrid/customAggrid.js";
|
|
12
12
|
import "react-intl";
|
|
13
|
+
const getDropIndicatorPosition = ({ overNode, y }) => {
|
|
14
|
+
if (!overNode) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const overNodeTop = overNode.rowTop ?? 0;
|
|
18
|
+
const overNodeHeight = overNode.rowHeight ?? 0;
|
|
19
|
+
const overNodeMiddle = overNodeTop + overNodeHeight / 2;
|
|
20
|
+
return y < overNodeMiddle ? "above" : "below";
|
|
21
|
+
};
|
|
13
22
|
const style = (customProps) => ({
|
|
14
23
|
grid: (theme) => ({
|
|
15
24
|
height: "100%",
|
|
@@ -137,6 +146,42 @@ const CustomAgGridTable = forwardRef(
|
|
|
137
146
|
const isAnycolumnhasSort = event.api.getColumnState().some((col) => col.sort);
|
|
138
147
|
setIsSortApplied(isAnycolumnhasSort);
|
|
139
148
|
}, []);
|
|
149
|
+
const onRowDragMove = useCallback((event) => {
|
|
150
|
+
const { api, overNode } = event;
|
|
151
|
+
const dropIndicatorPosition = getDropIndicatorPosition(event);
|
|
152
|
+
if (!overNode || !dropIndicatorPosition) {
|
|
153
|
+
api.setRowDropPositionIndicator(null);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
api.setRowDropPositionIndicator({
|
|
157
|
+
row: overNode,
|
|
158
|
+
dropIndicatorPosition
|
|
159
|
+
});
|
|
160
|
+
}, []);
|
|
161
|
+
const onRowDragEnd = useCallback(
|
|
162
|
+
(event) => {
|
|
163
|
+
const { api, node, overNode } = event;
|
|
164
|
+
api.setRowDropPositionIndicator(null);
|
|
165
|
+
const dropIndicatorPosition = getDropIndicatorPosition(event);
|
|
166
|
+
if (!overNode || !dropIndicatorPosition) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const rowIndex = getIndex(node.data);
|
|
170
|
+
const overIndex = getIndex(overNode.data);
|
|
171
|
+
if (rowIndex === -1 || overIndex === -1 || rowIndex === overIndex) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const insertionIndex = dropIndicatorPosition === "above" ? overIndex : overIndex + 1;
|
|
175
|
+
const targetIndex = rowIndex < insertionIndex ? insertionIndex - 1 : insertionIndex;
|
|
176
|
+
if (rowIndex !== targetIndex) {
|
|
177
|
+
move(rowIndex, targetIndex);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
[getIndex, move]
|
|
181
|
+
);
|
|
182
|
+
const clearRowDropPositionIndicator = useCallback(({ api }) => {
|
|
183
|
+
api.setRowDropPositionIndicator(null);
|
|
184
|
+
}, []);
|
|
140
185
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
141
186
|
/* @__PURE__ */ jsx(Box, { className: theme.aggrid.theme, sx: style(cssProps).grid, children: /* @__PURE__ */ jsx(
|
|
142
187
|
CustomAGGrid,
|
|
@@ -146,7 +191,10 @@ const CustomAgGridTable = forwardRef(
|
|
|
146
191
|
cacheOverflowSize: 10,
|
|
147
192
|
rowSelection: rowSelection ?? { mode: "multiRow" },
|
|
148
193
|
selectionColumnDef: { rowDrag: true, width: 80, pinned: "left" },
|
|
149
|
-
onRowDragMove
|
|
194
|
+
onRowDragMove,
|
|
195
|
+
onRowDragEnd,
|
|
196
|
+
onRowDragLeave: clearRowDropPositionIndicator,
|
|
197
|
+
onRowDragCancel: clearRowDropPositionIndicator,
|
|
150
198
|
detailRowAutoHeight: true,
|
|
151
199
|
onSelectionChanged: (event) => {
|
|
152
200
|
setSelectedRows(event.api.getSelectedRows());
|
|
@@ -3,7 +3,8 @@ interface PowerMeasurementsFormProps {
|
|
|
3
3
|
side?: 1 | 2;
|
|
4
4
|
activePowerMeasurement?: MeasurementInfo;
|
|
5
5
|
reactivePowerMeasurement?: MeasurementInfo;
|
|
6
|
+
idPrefix?: string;
|
|
6
7
|
reactivePowerOnly?: boolean;
|
|
7
8
|
}
|
|
8
|
-
export declare function PowerMeasurementsForm({ side, activePowerMeasurement, reactivePowerMeasurement, reactivePowerOnly, }: Readonly<PowerMeasurementsFormProps>): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function PowerMeasurementsForm({ side, activePowerMeasurement, reactivePowerMeasurement, idPrefix, reactivePowerOnly, }: Readonly<PowerMeasurementsFormProps>): import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
export {};
|
|
@@ -10,6 +10,7 @@ function PowerMeasurementsForm({
|
|
|
10
10
|
side,
|
|
11
11
|
activePowerMeasurement,
|
|
12
12
|
reactivePowerMeasurement,
|
|
13
|
+
idPrefix = "",
|
|
13
14
|
reactivePowerOnly = false
|
|
14
15
|
}) {
|
|
15
16
|
const getActiveMeasurementType = (whichSide) => {
|
|
@@ -24,8 +25,12 @@ function PowerMeasurementsForm({
|
|
|
24
25
|
}
|
|
25
26
|
return whichSide === 1 ? FieldConstants.MEASUREMENT_Q1 : FieldConstants.MEASUREMENT_Q2;
|
|
26
27
|
};
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
let activePowerId = `${FieldConstants.STATE_ESTIMATION}.${getActiveMeasurementType(side)}`;
|
|
29
|
+
let reactivePowerId = `${FieldConstants.STATE_ESTIMATION}.${getReactiveMeasurementType(side)}`;
|
|
30
|
+
if (idPrefix) {
|
|
31
|
+
activePowerId = `${idPrefix}.${activePowerId}`;
|
|
32
|
+
reactivePowerId = `${idPrefix}.${reactivePowerId}`;
|
|
33
|
+
}
|
|
29
34
|
return /* @__PURE__ */ jsxs(Grid, { container: true, direction: "column", spacing: 2, children: [
|
|
30
35
|
!reactivePowerOnly && /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(
|
|
31
36
|
PowerWithValidityForm,
|