({
expr,
root = false,
groupPath,
operandIndex,
}: {
expr: ConditionGroupExpr;
root?: boolean;
groupPath: Path;
operandIndex?: number;
})
| 1323 | // ============================================================ |
| 1324 | |
| 1325 | function ConditionGroup({ |
| 1326 | expr, |
| 1327 | root = false, |
| 1328 | groupPath, |
| 1329 | operandIndex, |
| 1330 | }: { |
| 1331 | expr: ConditionGroupExpr; |
| 1332 | root?: boolean; |
| 1333 | groupPath: Path; |
| 1334 | operandIndex?: number; |
| 1335 | }) { |
| 1336 | const { t } = useTranslation(); |
| 1337 | const { |
| 1338 | readonly, |
| 1339 | factorList, |
| 1340 | enableRawExpression, |
| 1341 | factorOperatorOverrideMap: overrideMap, |
| 1342 | } = useExprEditorCtx(); |
| 1343 | |
| 1344 | // For root, groupPath is []; for nested groups, it includes the operandIndex |
| 1345 | const selfPath = root ? groupPath : [...groupPath, operandIndex!]; |
| 1346 | const doUpdate = useImmutableUpdate(selfPath); |
| 1347 | const parentDoUpdate = useImmutableUpdate(groupPath); |
| 1348 | |
| 1349 | const operator = expr.operator; |
| 1350 | const args = expr.args; |
| 1351 | |
| 1352 | const logicalLabel = (op: string) => { |
| 1353 | if (op === "_&&_") return "and"; |
| 1354 | if (op === "_||_") return "or"; |
| 1355 | return op; |
| 1356 | }; |
| 1357 | |
| 1358 | const addCondition = () => { |
| 1359 | const factor = factorList[0]; |
| 1360 | if (!factor) return; |
| 1361 | const operators = getOperatorListByFactor(factor, overrideMap); |
| 1362 | const op = operators[0] as ConditionOperator | undefined; |
| 1363 | if (!op) return; |
| 1364 | doUpdate((group) => { |
| 1365 | group.args.push({ |
| 1366 | type: ExprType.Condition, |
| 1367 | operator: op, |
| 1368 | args: [factor, getDefaultValue(factor, op)], |
| 1369 | } as ConditionExpr); |
| 1370 | }); |
| 1371 | }; |
| 1372 | |
| 1373 | const addConditionGroup = () => { |
| 1374 | doUpdate((group) => { |
| 1375 | group.args.push({ |
| 1376 | type: ExprType.ConditionGroup, |
| 1377 | operator: LogicalOperatorList[0], |
| 1378 | args: [], |
| 1379 | }); |
| 1380 | }); |
| 1381 | }; |
| 1382 |
nothing calls this directly
no test coverage detected