@carbon/ibm-products
Version:
Carbon for IBM Products
104 lines (103 loc) • 3.21 kB
TypeScript
/**
* Copyright IBM Corp. 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import { Condition, ConditionGroup, LogicalOperator } from '../ConditionBuilder.types';
/**
* This component build each block of condition consisting of property, operator value and close button.
*/
interface ConditionBlockProps {
condition?: Condition;
onRemove: (e: React.MouseEvent<HTMLButtonElement>) => void;
onChange: (condition: Condition) => void;
onConnectorOperatorChange?: (op: string) => void;
onStatementChange?: (v: string) => void;
addConditionHandler?: (conditionIndex: number) => void;
addConditionSubGroupHandler?: (conditionIndex: number) => void;
hideConditionSubGroupPreviewHandler?: () => void;
showConditionSubGroupPreviewHandler?: () => void;
hideConditionPreviewHandler?: () => void;
showConditionPreviewHandler?: () => void;
conjunction?: LogicalOperator;
isStatement?: boolean;
group: ConditionGroup;
conditionIndex: number;
aria: {
level: number;
posinset: number;
setsize?: number;
};
isLastCondition: (index: number, conditions: (ConditionGroup | Condition)[]) => void;
}
declare const ConditionBlock: {
(props: ConditionBlockProps): React.JSX.Element;
propTypes: {
/**
* callback to add a new condition
*/
addConditionHandler: any;
/**
* callback to add a new condition subgroup
*/
addConditionSubGroupHandler: any;
/**
* object hold aria attributes
*/
aria: any;
condition: any;
conditionIndex: any;
/**
* string that decides to show the condition connector
*/
conjunction: any;
/**
* object that hold the current group object where is condition is part of
*/
group: any;
/**
* handler for hiding sub group preview
*/
hideConditionPreviewHandler: any;
/**
* handler for hiding sub group preview
*/
hideConditionSubGroupPreviewHandler: any;
isLastCondition: any;
/**
* boolean that decides to show the statement(if/ excl.if)
*/
isStatement: any;
/**
* callback to update the current condition of the state tree
*/
onChange: any;
/**
* callback to handle the connector(and/or) change
*/
onConnectorOperatorChange: any;
/**
* callback for Remove a condition
*/
onRemove: any;
/**
* callback to handle the statement(if/ excl.if) change
*/
onStatementChange: any;
/**
* handler for showing add condition preview
*/
showConditionPreviewHandler: any;
/**
* handler for showing sub group preview
*/
showConditionSubGroupPreviewHandler: any;
/**
* object that hold the current condition
*/
state: any;
};
};
export default ConditionBlock;