@pega/cosmos-react-condition-builder 9.0.0-build.16.0 → 9.0.0-build.16.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionBuilder.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAG/E,OAAO,KAAK,qBAAqB,MAAM,0BAA0B,CAAC;AA8BlE,QAAA,MAAM,gBAAgB,EAAE,+BAA+B,CAAC,qBAAqB,CAmZ5E,CAAC;AAGF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"ConditionBuilder.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAG/E,OAAO,KAAK,qBAAqB,MAAM,0BAA0B,CAAC;AA8BlE,QAAA,MAAM,gBAAgB,EAAE,+BAA+B,CAAC,qBAAqB,CAuZ5E,CAAC;AAGF,eAAe,gBAAgB,CAAC"}
@@ -16,7 +16,7 @@ const defaultProps = {
16
16
  };
17
17
  // Component for the builder
18
18
  const ConditionBuilder = forwardRef(function ConditionBuilder(props, ref) {
19
- const { fields = [], condition: seedCondition, validComparators = [], validRhsTypes = new Set(['LITERAL', 'FIELD']), dateFunctions = { DATE_TIME: [], DATE_ONLY: [] }, disallowNOT, disabled = false, readOnly = false, handle, conditionRenderer: ConditionRenderer = AtomicCondition, onLogicError } = props;
19
+ const { fields = [], condition: seedCondition, validComparators = [], validRhsTypes = new Set(['LITERAL', 'FIELD']), dateFunctions = { DATE_TIME: [], DATE_ONLY: [] }, disallowNOT, disabled = false, readOnly = false, handle, conditionRenderer: ConditionRenderer = AtomicCondition, onLogicError, onAddRow, onDeleteRow } = props;
20
20
  // Split the condition tree into a logic-string and a list of condition-rows.
21
21
  const clonedCondition = JSON.parse(JSON.stringify(seedCondition)); // Cloning to avoid modifying the original
22
22
  const { logic: seedLogic, rows: seedRows } = splitConditionForBuilder(clonedCondition);
@@ -85,6 +85,7 @@ const ConditionBuilder = forwardRef(function ConditionBuilder(props, ref) {
85
85
  updateLogicString(INSERT_ROW); // Update the logicString input to reflect the insertion
86
86
  }
87
87
  setFocusRowIndex(insertAt);
88
+ onAddRow?.(insertAt);
88
89
  };
89
90
  // Remove the row at the given index
90
91
  const removeRow = (removeAt) => {
@@ -116,6 +117,7 @@ const ConditionBuilder = forwardRef(function ConditionBuilder(props, ref) {
116
117
  }
117
118
  return removeAt;
118
119
  });
120
+ onDeleteRow?.(removeAt);
119
121
  };
120
122
  // Update a Basic-mode operator at the given index
121
123
  const updateOperator = (updateAt, newValue) => {
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionBuilder.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,MAAM,EACN,SAAS,EACT,WAAW,EACX,UAAU,EACX,MAAM,OAAO,CAAC;AAGf,OAAO,EACL,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,UAAU,EACV,OAAO,EACP,OAAO,EACP,aAAa,EACb,UAAU,EACV,MAAM,EACP,MAAM,yBAAyB,CAAC;AAGjC,OAAO,eAAe,EAAE,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGtE,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AACtB,OAAO,WAAW,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtF,OAAO,EACL,sBAAsB,EACtB,SAAS,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C1B,CAAC;AACJ,CAAC,CACF,CAAC;AACF,gBAAgB,CAAC,YAAY,GAAG,YAAY,CAAC;AAE7C,eAAe,gBAAgB,CAAC","sourcesContent":["import {\n Fragment,\n useState,\n useReducer,\n useImperativeHandle,\n useRef,\n useEffect,\n useCallback,\n forwardRef\n} from 'react';\nimport type { ChangeEvent, PropsWithoutRef } from 'react';\n\nimport {\n Button,\n Flex,\n Icon,\n Input,\n MenuButton,\n hasProp,\n useI18n,\n getFocusables,\n useLiveLog,\n Switch\n} from '@pega/cosmos-react-core';\nimport type { ForwardRefForwardPropsComponent } from '@pega/cosmos-react-core';\n\nimport AtomicCondition, { isValidCondition } from './AtomicCondition';\nimport type ConditionBuilderProps from './ConditionBuilder.types';\nimport type { Condition, HandleValue, LeafCondition } from './ConditionBuilder.types';\nimport {\n splitConditionForBuilder,\n parseLogicString,\n disambiguateLogic,\n isBasicModeApplicable,\n getBasicModeOperators,\n getLogicFromBasicMode\n} from './core/utils';\nimport rowsReducer, { INSERT_ROW, UPDATE_ROW, REMOVE_ROW } from './core/rows-reducer';\nimport type { RHSType } from './core/types';\nimport {\n StyledRowWithSeparator,\n StyledRow,\n StyledLabel,\n StyledConditionBuilder\n} from './ConditionBuilder.styles';\n\n// Default props for the builder\nconst defaultProps: Partial<ConditionBuilderProps> = {\n condition: {\n condition: {\n comparator: 'IS_NOT_NULL',\n lhs: { field: '' }\n }\n }\n};\n\n// Component for the builder\nconst ConditionBuilder: ForwardRefForwardPropsComponent<ConditionBuilderProps> = forwardRef(\n function ConditionBuilder(\n props: PropsWithoutRef<ConditionBuilderProps>,\n ref: ConditionBuilderProps['ref']\n ) {\n const {\n fields = [],\n condition: seedCondition,\n validComparators = [],\n validRhsTypes = new Set<RHSType>(['LITERAL', 'FIELD']),\n dateFunctions = { DATE_TIME: [], DATE_ONLY: [] },\n disallowNOT,\n disabled = false,\n readOnly = false,\n handle,\n conditionRenderer: ConditionRenderer = AtomicCondition,\n onLogicError\n } = props;\n\n // Split the condition tree into a logic-string and a list of condition-rows.\n const clonedCondition: Condition = JSON.parse(JSON.stringify(seedCondition)); // Cloning to avoid modifying the original\n const { logic: seedLogic, rows: seedRows } = splitConditionForBuilder(clonedCondition);\n // On load, look to use the Basic-mode if the seed-condition is simple enough\n const [isBasicMode, setIsBasicMode] = useState(() => isBasicModeApplicable(clonedCondition));\n const [operatorsList, setOperatorsList] = useState(() => getBasicModeOperators(seedLogic)); // Operators-list used in Basic-mode to render dropdowns between the rows. NOTE: When in Advanced-mode, this can contain stale values.\n const [logicString, setLogicString] = useState(seedLogic); // Logic-string used in Advanced-mode. NOTE: When in Basic-mode, this can contain stale values.\n const [cachedLogicString, setCachedLogicString] = useState(seedLogic); // Logic-string used to store the last valid logic-string in Advanced-mode. This is used to restore the logic-string when switching back from Basic-mode to Advanced-mode.\n const [conditionRows, dispatch] = useReducer(rowsReducer, seedRows); // Conditions-rows\n const [logicError, setLogicError] = useState<string | null>(null); // Used to indicate errors in the logic string\n const [showErrorIndicators, setShowErrorIndicators] = useState(false); // Used to enable inline error indicators in the condition rows\n const enableShading =\n isBasicMode && operatorsList.includes('AND') && operatorsList.includes('OR'); // In Basic mode, enable shading to indicate grouping only when both operators are present\n\n const newOperatorButtonRef = useRef<HTMLButtonElement | null>(null);\n const focusRowRef = useRef<HTMLElement | null>(null);\n const [focusRowIndex, setFocusRowIndex] = useState<number | null>(null);\n\n // Upon adding/removing rows in Advanced mode, update the logic string to reflect the change in labels\n // NOTE: The input is updated only if the previous logicString was simple enough\n const updateLogicString = (actionType: string): void => {\n const numNewRows =\n actionType === INSERT_ROW ? conditionRows.length + 1 : conditionRows.length - 1;\n\n // If only one row left after the action, simply use its label as logicString\n // NOTE: If none left, the rowsReducer adds a new empty row\n if (numNewRows <= 1) {\n setLogicString('1');\n return;\n }\n\n // If the previous string was a simple AND/OR between all the rows, update the logicString to follow the same for the new list of rows.\n // If the previous string was a single token like `1` and a new row is inserted, do an AND between the new rows, i.e. `1 AND 2`\n // For all other complex cases, skip automatically updating the string and wait for the user to change it\n // To check this, split the previous string by `OR/AND` and check if each of the resultant token is a simple numeric token\n const splitter = logicString.includes('OR') ? 'OR' : 'AND';\n const tokens = logicString.split(splitter);\n const isEveryTokenInteger = tokens.every(w => /^\\d+$/.test(w.trim()));\n if (isEveryTokenInteger) {\n setLogicString(\n new Array(numNewRows)\n .fill(0)\n .map((w, i) => i + 1)\n .join(` ${splitter} `)\n );\n }\n };\n\n // Manages the focus behavior when inserting/removing a row\n useEffect(() => {\n if (focusRowIndex === null) return;\n\n if (newOperatorButtonRef.current) {\n newOperatorButtonRef.current.focus();\n newOperatorButtonRef.current = null;\n } else if (focusRowIndex !== null) {\n getFocusables(focusRowRef)[0]?.focus();\n }\n\n setFocusRowIndex(null);\n }, [focusRowIndex]);\n\n // Insert a new row at the given index\n const insertRow = (insertAt: number): void => {\n dispatch({ type: INSERT_ROW, payload: { insertAt } }); // Insert an entry in conditionRows\n if (isBasicMode) {\n // Set up a new AND/OR selector\n const insertOpAt = insertAt - 1; // Using `insertAt-1` since the operatorsList has one less entry compared to the conditionRows\n setOperatorsList([\n ...operatorsList.slice(0, insertOpAt),\n 'AND',\n ...operatorsList.slice(insertOpAt)\n ]);\n } else {\n updateLogicString(INSERT_ROW); // Update the logicString input to reflect the insertion\n }\n setFocusRowIndex(insertAt);\n };\n\n // Remove the row at the given index\n const removeRow = (removeAt: number): void => {\n dispatch({ type: REMOVE_ROW, payload: { removeAt } }); // Remove an entry in conditionRows\n if (isBasicMode) {\n // Remove an AND/OR selector\n if (removeAt === 0) {\n // If removing the first of the condition rows, remove the extraneous operator\n setOperatorsList(operatorsList.slice(1));\n } else {\n let removeOpAt = removeAt - 1; // Using `removeAt-1` since the operatorsList has one less entry compared to the conditionRows\n if (operatorsList[removeOpAt] === 'OR' && operatorsList[removeOpAt + 1] === 'AND') {\n // If removing a condition at the start of a nested group, remove the first operator from that group. e.g. Take `(1 AND 2) OR (3 AND 4 AND 5)`. If `3` is being deleted, it should become `(1 AND 2) OR (4 AND 5)` instead of `1 AND 2 AND 4 AND 5`\n removeOpAt += 1;\n }\n setOperatorsList([\n ...operatorsList.slice(0, removeOpAt),\n ...operatorsList.slice(removeOpAt + 1)\n ]);\n }\n } else {\n updateLogicString(REMOVE_ROW); // Update the logicString input to reflect the removal\n }\n setFocusRowIndex(() => {\n if (removeAt !== 0 && removeAt === conditionRows.length - 1) {\n return removeAt - 1;\n }\n\n return removeAt;\n });\n };\n\n // Update a Basic-mode operator at the given index\n const updateOperator = (updateAt: number, newValue: 'AND' | 'OR'): void => {\n setCachedLogicString('');\n setOperatorsList([\n ...operatorsList.slice(0, updateAt),\n newValue,\n ...operatorsList.slice(updateAt + 1)\n ]);\n };\n\n // Validate the logic input. Called upon clicking outside the textBox or upon submission.\n // If the expression is invalid, shows appropriate feedback and returns null.\n // If the expression is valid, formats it by setting up brackets at necessary places (to clear any ambiguities e.g. `1 AND 2 OR 3` is formatted as `(1 AND 2) OR 3` ). Returns a save-ready condition\n const validateLogicString = (logicToUse: string): Condition | null => {\n // Set up a lookup with row-labels as keys and rows as values\n const conditionLookup: { [label: string]: LeafCondition } = {};\n conditionRows.forEach(row => {\n const { id, label, ...leaf } = row; // Discard the extra properties added by ConditionRow to the LeafCondition interface\n conditionLookup[row.label] = leaf;\n });\n\n // Convert the logic string into a condition tree\n const parseResult = parseLogicString(logicToUse, conditionLookup, disallowNOT);\n\n // Indicate any parse error\n if (hasProp(parseResult, 'error')) {\n setLogicError(parseResult.error);\n onLogicError?.(parseResult.error);\n return null;\n }\n\n // If no errors\n setLogicError(null); // Clear any previous error\n onLogicError?.(null); // Clear any previous error\n setLogicString(disambiguateLogic(logicToUse)); // Disambiguating the logic string by placing parentheses at appropriate places\n setCachedLogicString(disambiguateLogic(logicToUse));\n return parseResult.condition;\n };\n\n // Toggle between the Basic and Advanced modes\n const toggleMode = (): void => {\n if (isBasicMode) {\n // Update the logicString to match the operatorsList before switching the mode\n setLogicString(cachedLogicString || getLogicFromBasicMode(operatorsList));\n setIsBasicMode(false);\n } else {\n // If switched from advanced to basic mode the condition will be stored until another action takes place\n setCachedLogicString(logicString);\n const condition = validateLogicString(logicString); // Validate the logicString. If it is an invalid, an appropriate error is shown for the user to act on\n if (condition !== null) {\n // If the logic is simple enough, identify the new set of operators before switching to Basic mode.\n // If the logic is too complex fallback to using 'AND' between all rows\n setOperatorsList(\n isBasicModeApplicable(condition)\n ? getBasicModeOperators(logicString)\n : new Array(conditionRows.length - 1).fill('AND')\n );\n setIsBasicMode(true);\n }\n }\n };\n\n const getCondition: HandleValue['getCondition'] = (\n options = { performRowValidation: true }\n ) => {\n setShowErrorIndicators(false); // Reset any previous flag\n setLogicError(null); // Clear any previous error\n onLogicError?.(null); // Clear any previous error\n\n // If there's a single empty condition, submit with an `undefined` value (useful for clearing a previous condition)\n if (conditionRows.length === 1 && conditionRows[0].lhs.field === '') {\n return [true, undefined];\n }\n\n // Identify and indicate any invalid values in the condition rows\n const hasInvalidRows = options.performRowValidation\n ? conditionRows.some(row => !isValidCondition(row, fields, true))\n : false;\n if (hasInvalidRows) {\n setShowErrorIndicators(true); // Enable inline error indications\n return [false];\n }\n\n // Validate the Logic string\n const logicToUse = isBasicMode ? getLogicFromBasicMode(operatorsList) : logicString; // If in Basic-mode, construct a different logicString based on the operatorsList\n const condition = validateLogicString(logicToUse); // This also takes care of showing an appropriate error feedback as needed\n if (condition !== null) {\n // Can be null when the logic string has errors\n return [true, condition];\n }\n\n return [false];\n };\n\n const getLogicError: HandleValue['getLogicError'] = useCallback((): string | null => {\n return logicError;\n }, [logicError]);\n\n useImperativeHandle(\n handle,\n () => ({\n getCondition,\n getLogicError\n }),\n [getCondition, getLogicError]\n );\n\n const t = useI18n();\n\n const { announceAssertive } = useLiveLog();\n\n useEffect(() => {\n announceAssertive({ message: t('condition_builder_mode_switch') });\n }, [isBasicMode]);\n\n return (\n <StyledConditionBuilder container={{ direction: 'column', gap: 1 }} ref={ref}>\n <Flex container>\n <Switch\n label={t('condition_builder_advanced_mode_button_label')}\n aria-label={t('condition_builder_advanced_mode_button_label')}\n on={!isBasicMode}\n onChange={() => {\n toggleMode();\n }}\n disabled={disabled || readOnly}\n />\n </Flex>\n {/* Condition Rows */}\n <div role='group'>\n {conditionRows.map(({ id, label, ...leaf }, index) => {\n const rowIndexAriaLabel = `${t('condition_builder_row', [index + 1])}`;\n const deleteAriaLabel = `${t('condition_builder_field_label')} ${leaf.lhs.field\n .split('.')\n .pop()}`;\n\n let alignItems = 'end';\n if (showErrorIndicators && !isValidCondition(leaf, fields, false)) {\n alignItems = 'center';\n }\n\n return (\n <Fragment key={id}>\n {/* Row with the operator dropdown in Basic mode */}\n {isBasicMode && index > 0 && (\n <StyledRowWithSeparator\n container\n shaded={enableShading && operatorsList[index - 1] === 'AND'}\n >\n <MenuButton\n popover={{ hideOnTargetHidden: false }}\n text={operatorsList[index - 1] === 'AND' ? 'And' : 'Or'}\n variant='simple'\n menu={{\n items: [\n {\n id: 'AND',\n primary: 'And',\n onClick: () => updateOperator(index - 1, 'AND')\n },\n {\n id: 'OR',\n primary: 'Or',\n onClick: () => updateOperator(index - 1, 'OR')\n }\n ]\n }}\n ref={index === focusRowIndex ? newOperatorButtonRef : null}\n disabled={disabled || readOnly}\n />\n </StyledRowWithSeparator>\n )}\n\n {/* Row with the AtomicCondition */}\n <StyledRow\n aria-label={rowIndexAriaLabel}\n container={{ gap: 0.5, alignItems }}\n shaded={isBasicMode && enableShading}\n ref={index === focusRowIndex ? focusRowRef : null}\n >\n {/* Label */}\n {!isBasicMode && <StyledLabel>{label}</StyledLabel>}\n\n {/* Condition controls */}\n <Flex item={{ grow: 1 }}>\n <ConditionRenderer\n indicateErrors={showErrorIndicators}\n fields={fields}\n index={index}\n condition={leaf}\n onChange={(newCondition: LeafCondition) => {\n const newRow = { id, label, ...newCondition };\n dispatch({ type: UPDATE_ROW, payload: { updateAt: index, newRow } });\n }}\n validComparators={validComparators}\n dateFunctions={dateFunctions}\n validRhsTypes={validRhsTypes}\n />\n </Flex>\n\n {/* Row actions */}\n <Button\n icon\n variant='simple'\n onClick={() => {\n insertRow(index + 1);\n setCachedLogicString('');\n }}\n label={t('add_condition')}\n disabled={disabled || readOnly}\n >\n <Icon name='plus' />\n </Button>\n <Button\n icon\n variant='simple'\n onClick={() => {\n removeRow(index);\n setCachedLogicString('');\n }}\n label={t('delete')}\n aria-label={deleteAriaLabel ? t('delete_noun', [deleteAriaLabel]) : undefined}\n disabled={disabled || readOnly}\n >\n <Icon name='trash' />\n </Button>\n </StyledRow>\n </Fragment>\n );\n })}\n </div>\n\n {/* LogicString input */}\n {!isBasicMode && (\n <div>\n <Flex container={{ gap: 0.25, direction: 'column' }}>\n <Input\n label={t('condition_builder_advanced_condition_label')}\n additionalInfo={{\n heading: t('condition_builder_advanced_condition_label'),\n content: (\n <div>\n {t('condition_builder_advanced_condition_tooltip', [\n disallowNOT ? 'AND/OR' : 'AND/OR/NOT',\n disallowNOT ? '(1 OR 2) AND (3 OR 4 OR 5)' : '(1 AND 2) OR (3 AND NOT 4)'\n ])}\n </div>\n )\n }}\n type='text'\n placeholder={t('condition_builder_advanced_condition_placeholder')}\n value={logicString\n .replace(/\\bAND\\b/g, 'and')\n .replace(/\\bOR\\b/g, 'or')\n .replace(/\\bNOT\\b/g, 'not')}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n setLogicString(e.target.value);\n setCachedLogicString(e.target.value);\n }}\n onBlur={() => {\n validateLogicString(logicString);\n }}\n status={logicError !== null ? 'error' : undefined}\n info={logicError}\n required\n disabled={disabled}\n readOnly={readOnly || disabled}\n />\n </Flex>\n </div>\n )}\n </StyledConditionBuilder>\n );\n }\n);\nConditionBuilder.defaultProps = defaultProps;\n\nexport default ConditionBuilder;\n"]}
1
+ {"version":3,"file":"ConditionBuilder.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,mBAAmB,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,CAAC,EAClE,KAAK,EAAE,WAAW;6BACf,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC;6BAC1B,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC;6BACxB,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,EAC7B,QAAQ,EAAE,CAAC,CAAgC,EAAE,EAAE;4BAC7C,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;4BAC/B,oBAAoB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;wBACvC,CAAC,EACD,MAAM,EAAE,GAAG,EAAE;4BACX,mBAAmB,CAAC,WAAW,CAAC,CAAC;wBACnC,CAAC,EACD,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EACjD,IAAI,EAAE,UAAU,EAChB,QAAQ,QACR,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,IAAI,QAAQ,GAC9B,GACG,GACH,CACP,IACsB,CAC1B,CAAC;AACJ,CAAC,CACF,CAAC;AACF,gBAAgB,CAAC,YAAY,GAAG,YAAY,CAAC;AAE7C,eAAe,gBAAgB,CAAC","sourcesContent":["import {\n Fragment,\n useState,\n useReducer,\n useImperativeHandle,\n useRef,\n useEffect,\n useCallback,\n forwardRef\n} from 'react';\nimport type { ChangeEvent, PropsWithoutRef } from 'react';\n\nimport {\n Button,\n Flex,\n Icon,\n Input,\n MenuButton,\n hasProp,\n useI18n,\n getFocusables,\n useLiveLog,\n Switch\n} from '@pega/cosmos-react-core';\nimport type { ForwardRefForwardPropsComponent } from '@pega/cosmos-react-core';\n\nimport AtomicCondition, { isValidCondition } from './AtomicCondition';\nimport type ConditionBuilderProps from './ConditionBuilder.types';\nimport type { Condition, HandleValue, LeafCondition } from './ConditionBuilder.types';\nimport {\n splitConditionForBuilder,\n parseLogicString,\n disambiguateLogic,\n isBasicModeApplicable,\n getBasicModeOperators,\n getLogicFromBasicMode\n} from './core/utils';\nimport rowsReducer, { INSERT_ROW, UPDATE_ROW, REMOVE_ROW } from './core/rows-reducer';\nimport type { RHSType } from './core/types';\nimport {\n StyledRowWithSeparator,\n StyledRow,\n StyledLabel,\n StyledConditionBuilder\n} from './ConditionBuilder.styles';\n\n// Default props for the builder\nconst defaultProps: Partial<ConditionBuilderProps> = {\n condition: {\n condition: {\n comparator: 'IS_NOT_NULL',\n lhs: { field: '' }\n }\n }\n};\n\n// Component for the builder\nconst ConditionBuilder: ForwardRefForwardPropsComponent<ConditionBuilderProps> = forwardRef(\n function ConditionBuilder(\n props: PropsWithoutRef<ConditionBuilderProps>,\n ref: ConditionBuilderProps['ref']\n ) {\n const {\n fields = [],\n condition: seedCondition,\n validComparators = [],\n validRhsTypes = new Set<RHSType>(['LITERAL', 'FIELD']),\n dateFunctions = { DATE_TIME: [], DATE_ONLY: [] },\n disallowNOT,\n disabled = false,\n readOnly = false,\n handle,\n conditionRenderer: ConditionRenderer = AtomicCondition,\n onLogicError,\n onAddRow,\n onDeleteRow\n } = props;\n\n // Split the condition tree into a logic-string and a list of condition-rows.\n const clonedCondition: Condition = JSON.parse(JSON.stringify(seedCondition)); // Cloning to avoid modifying the original\n const { logic: seedLogic, rows: seedRows } = splitConditionForBuilder(clonedCondition);\n // On load, look to use the Basic-mode if the seed-condition is simple enough\n const [isBasicMode, setIsBasicMode] = useState(() => isBasicModeApplicable(clonedCondition));\n const [operatorsList, setOperatorsList] = useState(() => getBasicModeOperators(seedLogic)); // Operators-list used in Basic-mode to render dropdowns between the rows. NOTE: When in Advanced-mode, this can contain stale values.\n const [logicString, setLogicString] = useState(seedLogic); // Logic-string used in Advanced-mode. NOTE: When in Basic-mode, this can contain stale values.\n const [cachedLogicString, setCachedLogicString] = useState(seedLogic); // Logic-string used to store the last valid logic-string in Advanced-mode. This is used to restore the logic-string when switching back from Basic-mode to Advanced-mode.\n const [conditionRows, dispatch] = useReducer(rowsReducer, seedRows); // Conditions-rows\n const [logicError, setLogicError] = useState<string | null>(null); // Used to indicate errors in the logic string\n const [showErrorIndicators, setShowErrorIndicators] = useState(false); // Used to enable inline error indicators in the condition rows\n const enableShading =\n isBasicMode && operatorsList.includes('AND') && operatorsList.includes('OR'); // In Basic mode, enable shading to indicate grouping only when both operators are present\n\n const newOperatorButtonRef = useRef<HTMLButtonElement | null>(null);\n const focusRowRef = useRef<HTMLElement | null>(null);\n const [focusRowIndex, setFocusRowIndex] = useState<number | null>(null);\n\n // Upon adding/removing rows in Advanced mode, update the logic string to reflect the change in labels\n // NOTE: The input is updated only if the previous logicString was simple enough\n const updateLogicString = (actionType: string): void => {\n const numNewRows =\n actionType === INSERT_ROW ? conditionRows.length + 1 : conditionRows.length - 1;\n\n // If only one row left after the action, simply use its label as logicString\n // NOTE: If none left, the rowsReducer adds a new empty row\n if (numNewRows <= 1) {\n setLogicString('1');\n return;\n }\n\n // If the previous string was a simple AND/OR between all the rows, update the logicString to follow the same for the new list of rows.\n // If the previous string was a single token like `1` and a new row is inserted, do an AND between the new rows, i.e. `1 AND 2`\n // For all other complex cases, skip automatically updating the string and wait for the user to change it\n // To check this, split the previous string by `OR/AND` and check if each of the resultant token is a simple numeric token\n const splitter = logicString.includes('OR') ? 'OR' : 'AND';\n const tokens = logicString.split(splitter);\n const isEveryTokenInteger = tokens.every(w => /^\\d+$/.test(w.trim()));\n if (isEveryTokenInteger) {\n setLogicString(\n new Array(numNewRows)\n .fill(0)\n .map((w, i) => i + 1)\n .join(` ${splitter} `)\n );\n }\n };\n\n // Manages the focus behavior when inserting/removing a row\n useEffect(() => {\n if (focusRowIndex === null) return;\n\n if (newOperatorButtonRef.current) {\n newOperatorButtonRef.current.focus();\n newOperatorButtonRef.current = null;\n } else if (focusRowIndex !== null) {\n getFocusables(focusRowRef)[0]?.focus();\n }\n\n setFocusRowIndex(null);\n }, [focusRowIndex]);\n\n // Insert a new row at the given index\n const insertRow = (insertAt: number): void => {\n dispatch({ type: INSERT_ROW, payload: { insertAt } }); // Insert an entry in conditionRows\n if (isBasicMode) {\n // Set up a new AND/OR selector\n const insertOpAt = insertAt - 1; // Using `insertAt-1` since the operatorsList has one less entry compared to the conditionRows\n setOperatorsList([\n ...operatorsList.slice(0, insertOpAt),\n 'AND',\n ...operatorsList.slice(insertOpAt)\n ]);\n } else {\n updateLogicString(INSERT_ROW); // Update the logicString input to reflect the insertion\n }\n setFocusRowIndex(insertAt);\n onAddRow?.(insertAt);\n };\n\n // Remove the row at the given index\n const removeRow = (removeAt: number): void => {\n dispatch({ type: REMOVE_ROW, payload: { removeAt } }); // Remove an entry in conditionRows\n if (isBasicMode) {\n // Remove an AND/OR selector\n if (removeAt === 0) {\n // If removing the first of the condition rows, remove the extraneous operator\n setOperatorsList(operatorsList.slice(1));\n } else {\n let removeOpAt = removeAt - 1; // Using `removeAt-1` since the operatorsList has one less entry compared to the conditionRows\n if (operatorsList[removeOpAt] === 'OR' && operatorsList[removeOpAt + 1] === 'AND') {\n // If removing a condition at the start of a nested group, remove the first operator from that group. e.g. Take `(1 AND 2) OR (3 AND 4 AND 5)`. If `3` is being deleted, it should become `(1 AND 2) OR (4 AND 5)` instead of `1 AND 2 AND 4 AND 5`\n removeOpAt += 1;\n }\n setOperatorsList([\n ...operatorsList.slice(0, removeOpAt),\n ...operatorsList.slice(removeOpAt + 1)\n ]);\n }\n } else {\n updateLogicString(REMOVE_ROW); // Update the logicString input to reflect the removal\n }\n setFocusRowIndex(() => {\n if (removeAt !== 0 && removeAt === conditionRows.length - 1) {\n return removeAt - 1;\n }\n\n return removeAt;\n });\n onDeleteRow?.(removeAt);\n };\n\n // Update a Basic-mode operator at the given index\n const updateOperator = (updateAt: number, newValue: 'AND' | 'OR'): void => {\n setCachedLogicString('');\n setOperatorsList([\n ...operatorsList.slice(0, updateAt),\n newValue,\n ...operatorsList.slice(updateAt + 1)\n ]);\n };\n\n // Validate the logic input. Called upon clicking outside the textBox or upon submission.\n // If the expression is invalid, shows appropriate feedback and returns null.\n // If the expression is valid, formats it by setting up brackets at necessary places (to clear any ambiguities e.g. `1 AND 2 OR 3` is formatted as `(1 AND 2) OR 3` ). Returns a save-ready condition\n const validateLogicString = (logicToUse: string): Condition | null => {\n // Set up a lookup with row-labels as keys and rows as values\n const conditionLookup: { [label: string]: LeafCondition } = {};\n conditionRows.forEach(row => {\n const { id, label, ...leaf } = row; // Discard the extra properties added by ConditionRow to the LeafCondition interface\n conditionLookup[row.label] = leaf;\n });\n\n // Convert the logic string into a condition tree\n const parseResult = parseLogicString(logicToUse, conditionLookup, disallowNOT);\n\n // Indicate any parse error\n if (hasProp(parseResult, 'error')) {\n setLogicError(parseResult.error);\n onLogicError?.(parseResult.error);\n return null;\n }\n\n // If no errors\n setLogicError(null); // Clear any previous error\n onLogicError?.(null); // Clear any previous error\n setLogicString(disambiguateLogic(logicToUse)); // Disambiguating the logic string by placing parentheses at appropriate places\n setCachedLogicString(disambiguateLogic(logicToUse));\n return parseResult.condition;\n };\n\n // Toggle between the Basic and Advanced modes\n const toggleMode = (): void => {\n if (isBasicMode) {\n // Update the logicString to match the operatorsList before switching the mode\n setLogicString(cachedLogicString || getLogicFromBasicMode(operatorsList));\n setIsBasicMode(false);\n } else {\n // If switched from advanced to basic mode the condition will be stored until another action takes place\n setCachedLogicString(logicString);\n const condition = validateLogicString(logicString); // Validate the logicString. If it is an invalid, an appropriate error is shown for the user to act on\n if (condition !== null) {\n // If the logic is simple enough, identify the new set of operators before switching to Basic mode.\n // If the logic is too complex fallback to using 'AND' between all rows\n setOperatorsList(\n isBasicModeApplicable(condition)\n ? getBasicModeOperators(logicString)\n : new Array(conditionRows.length - 1).fill('AND')\n );\n setIsBasicMode(true);\n }\n }\n };\n\n const getCondition: HandleValue['getCondition'] = (\n options = { performRowValidation: true }\n ) => {\n setShowErrorIndicators(false); // Reset any previous flag\n setLogicError(null); // Clear any previous error\n onLogicError?.(null); // Clear any previous error\n\n // If there's a single empty condition, submit with an `undefined` value (useful for clearing a previous condition)\n if (conditionRows.length === 1 && conditionRows[0].lhs.field === '') {\n return [true, undefined];\n }\n\n // Identify and indicate any invalid values in the condition rows\n const hasInvalidRows = options.performRowValidation\n ? conditionRows.some(row => !isValidCondition(row, fields, true))\n : false;\n if (hasInvalidRows) {\n setShowErrorIndicators(true); // Enable inline error indications\n return [false];\n }\n\n // Validate the Logic string\n const logicToUse = isBasicMode ? getLogicFromBasicMode(operatorsList) : logicString; // If in Basic-mode, construct a different logicString based on the operatorsList\n const condition = validateLogicString(logicToUse); // This also takes care of showing an appropriate error feedback as needed\n if (condition !== null) {\n // Can be null when the logic string has errors\n return [true, condition];\n }\n\n return [false];\n };\n\n const getLogicError: HandleValue['getLogicError'] = useCallback((): string | null => {\n return logicError;\n }, [logicError]);\n\n useImperativeHandle(\n handle,\n () => ({\n getCondition,\n getLogicError\n }),\n [getCondition, getLogicError]\n );\n\n const t = useI18n();\n\n const { announceAssertive } = useLiveLog();\n\n useEffect(() => {\n announceAssertive({ message: t('condition_builder_mode_switch') });\n }, [isBasicMode]);\n\n return (\n <StyledConditionBuilder container={{ direction: 'column', gap: 1 }} ref={ref}>\n <Flex container>\n <Switch\n label={t('condition_builder_advanced_mode_button_label')}\n aria-label={t('condition_builder_advanced_mode_button_label')}\n on={!isBasicMode}\n onChange={() => {\n toggleMode();\n }}\n disabled={disabled || readOnly}\n />\n </Flex>\n {/* Condition Rows */}\n <div role='group'>\n {conditionRows.map(({ id, label, ...leaf }, index) => {\n const rowIndexAriaLabel = `${t('condition_builder_row', [index + 1])}`;\n const deleteAriaLabel = `${t('condition_builder_field_label')} ${leaf.lhs.field\n .split('.')\n .pop()}`;\n\n let alignItems = 'end';\n if (showErrorIndicators && !isValidCondition(leaf, fields, false)) {\n alignItems = 'center';\n }\n\n return (\n <Fragment key={id}>\n {/* Row with the operator dropdown in Basic mode */}\n {isBasicMode && index > 0 && (\n <StyledRowWithSeparator\n container\n shaded={enableShading && operatorsList[index - 1] === 'AND'}\n >\n <MenuButton\n popover={{ hideOnTargetHidden: false }}\n text={operatorsList[index - 1] === 'AND' ? 'And' : 'Or'}\n variant='simple'\n menu={{\n items: [\n {\n id: 'AND',\n primary: 'And',\n onClick: () => updateOperator(index - 1, 'AND')\n },\n {\n id: 'OR',\n primary: 'Or',\n onClick: () => updateOperator(index - 1, 'OR')\n }\n ]\n }}\n ref={index === focusRowIndex ? newOperatorButtonRef : null}\n disabled={disabled || readOnly}\n />\n </StyledRowWithSeparator>\n )}\n\n {/* Row with the AtomicCondition */}\n <StyledRow\n aria-label={rowIndexAriaLabel}\n container={{ gap: 0.5, alignItems }}\n shaded={isBasicMode && enableShading}\n ref={index === focusRowIndex ? focusRowRef : null}\n >\n {/* Label */}\n {!isBasicMode && <StyledLabel>{label}</StyledLabel>}\n\n {/* Condition controls */}\n <Flex item={{ grow: 1 }}>\n <ConditionRenderer\n indicateErrors={showErrorIndicators}\n fields={fields}\n index={index}\n condition={leaf}\n onChange={(newCondition: LeafCondition) => {\n const newRow = { id, label, ...newCondition };\n dispatch({ type: UPDATE_ROW, payload: { updateAt: index, newRow } });\n }}\n validComparators={validComparators}\n dateFunctions={dateFunctions}\n validRhsTypes={validRhsTypes}\n />\n </Flex>\n\n {/* Row actions */}\n <Button\n icon\n variant='simple'\n onClick={() => {\n insertRow(index + 1);\n setCachedLogicString('');\n }}\n label={t('add_condition')}\n disabled={disabled || readOnly}\n >\n <Icon name='plus' />\n </Button>\n <Button\n icon\n variant='simple'\n onClick={() => {\n removeRow(index);\n setCachedLogicString('');\n }}\n label={t('delete')}\n aria-label={deleteAriaLabel ? t('delete_noun', [deleteAriaLabel]) : undefined}\n disabled={disabled || readOnly}\n >\n <Icon name='trash' />\n </Button>\n </StyledRow>\n </Fragment>\n );\n })}\n </div>\n\n {/* LogicString input */}\n {!isBasicMode && (\n <div>\n <Flex container={{ gap: 0.25, direction: 'column' }}>\n <Input\n label={t('condition_builder_advanced_condition_label')}\n additionalInfo={{\n heading: t('condition_builder_advanced_condition_label'),\n content: (\n <div>\n {t('condition_builder_advanced_condition_tooltip', [\n disallowNOT ? 'AND/OR' : 'AND/OR/NOT',\n disallowNOT ? '(1 OR 2) AND (3 OR 4 OR 5)' : '(1 AND 2) OR (3 AND NOT 4)'\n ])}\n </div>\n )\n }}\n type='text'\n placeholder={t('condition_builder_advanced_condition_placeholder')}\n value={logicString\n .replace(/\\bAND\\b/g, 'and')\n .replace(/\\bOR\\b/g, 'or')\n .replace(/\\bNOT\\b/g, 'not')}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n setLogicString(e.target.value);\n setCachedLogicString(e.target.value);\n }}\n onBlur={() => {\n validateLogicString(logicString);\n }}\n status={logicError !== null ? 'error' : undefined}\n info={logicError}\n required\n disabled={disabled}\n readOnly={readOnly || disabled}\n />\n </Flex>\n </div>\n )}\n </StyledConditionBuilder>\n );\n }\n);\nConditionBuilder.defaultProps = defaultProps;\n\nexport default ConditionBuilder;\n"]}
@@ -155,6 +155,10 @@ export default interface ConditionBuilderProps extends BaseProps, NoChildrenProp
155
155
  disallowNOT?: boolean;
156
156
  /** Imperative handle for the component. */
157
157
  handle?: Ref<HandleValue>;
158
+ /** Callback fired when a row is added */
159
+ onAddRow?: (rowIndex: number) => void;
160
+ /** Callback fired when a row is deleted */
161
+ onDeleteRow?: (rowIndex: number) => void;
158
162
  /**
159
163
  * Callback fired when logic string validation error occurs or clears.
160
164
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionBuilder.types.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAExF,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,OAAO,EACP,UAAU,EACX,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK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C,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B"}
1
+ {"version":3,"file":"ConditionBuilder.types.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAExF,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,OAAO,EACP,UAAU,EACX,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,sCAAsC;AACtC,MAAM,WAAW,mBAAmB;IAClC;;;;;;;;;;;;;;OAcG;IACH,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED,sCAAsC;AACtC,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE;QACZ,UAAU,EAAE,UAAU,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,QAAQ,CAAC;KACpB,CAAC;CACH;AAED,qCAAqC;AACrC,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,oEAAoE;AACpE,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,UAAU,CAAC;IAEvB,GAAG,EAAE;QACH,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IAGF,GAAG,CAAC,EACA;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GACjB;QAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAC1B;QAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAA;KAAE,GAC/B;QAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CA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GAAG,CAAC,OAAO,CAAC,CAAC;IAE7B,iJAAiJ;IACjJ,aAAa,CAAC,EAAE,mBAAmB,CAAC;IAEpC,iFAAiF;IACjF,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;IAE1B,yCAAyC;IACzC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAEtC,2CAA2C;IAC3C,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAEzC;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAE9C,qFAAqF;IACrF,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionBuilder.types.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.types.ts"],"names":[],"mappings":"","sourcesContent":["// cspell:words DDTHH\nimport type { ReactNode, Ref } from 'react';\n\nimport type { BaseProps, MenuItemProps, NoChildrenProp } from '@pega/cosmos-react-core';\n\nimport type {\n Comparator,\n ComparatorsByType,\n DateFunction,\n DatePart,\n FieldType,\n RHSType,\n TimePeriod\n} from './core/types';\nimport type { AtomicConditionProps } from './AtomicCondition';\n\n/** RHS object with a Date function */\nexport interface RhsWithDateFunction {\n /**\n * Output format for the value varies based on the dateFunction:\n * YEARS: First day of year as YYYY-MM-DD\n * QUARTERS: First day of quarter as YYYY-MM-DD\n * MONTHS: First day of month as YYYY-MM-DD\n * WEEKS: First day of week as YYYY-MM-DD\n * DAYS: Date as YYYY-MM-DD\n * HOURS: YYYY-MM-DDTHH:mm:ss\n * MINUTES: YYYY-MM-DDTHH:mm:ss\n * SECONDS: YYYY-MM-DDTHH:mm:ss\n * HOURS_OF_DAY: 0-23\n * MONTHS_OF_YEAR: 1-12\n * DAYS_OF_MONTH: 1-31\n * DAYS_OF_WEEK: 1-7\n */\n value: string | number;\n dateFunction: DateFunction;\n}\n\n/** RHS object with a Relative Date */\nexport interface RhsWithRelativeDate {\n relativeDate: {\n timePeriod: TimePeriod;\n interval?: number;\n datePart: DatePart;\n };\n}\n\n/** RHS object with PARAMETER type */\nexport interface RhsWithParameter {\n parameterId: string;\n}\n\n/** Type definition for the leaf-level nodes in nested conditions */\nexport interface LeafCondition {\n comparator: Comparator;\n\n lhs: {\n field: string;\n };\n\n // Optional for some of the comparators like IS_TRUE, IS_NULL, etc.\n rhs?:\n | { field: string } // When comparing the LHS with another field\n | { value: string | number } // When comparing the LHS with a single literal value (for comparators like EQ, GTE etc.)\n | { values: string[] | number[] } // When comparing the LHS with a list of literal values (for comparators like IN, NOT_IN etc.)\n | { start: string | number; end: string | number } // When comparing numeric or date field with two values that determine range\n | RhsWithDateFunction // When comparing a date field with a date function on RHS\n | RhsWithRelativeDate // When comparing a date field with a symbolic date on RHS\n | RhsWithParameter; // When comparing the LHS with PARAMETER type\n lhsType?: string;\n}\n\n/** Type definition for objects representing condition-rows in the builder UI */\nexport interface ConditionRow extends LeafCondition {\n id: string; // To use as `key` prop when rendering a list of rows\n label: string; // Used to refer the row from a logic-string\n}\n\n/**\n * Type definition for simple/complex conditions\n * At a given node in the condition tree, it can have exactly one of the keys AND/OR/NOT/condition\n */\nexport type Condition =\n | { AND: Condition[] }\n | { OR: Condition[] }\n | { NOT: Condition }\n | { condition: LeafCondition };\n\n/** Type definition for the input Field objects for the ConditionBuilder */\n\nexport type ParameterValue = Pick<MenuItemProps, 'id' | 'primary'>;\n\nexport type ReferenceValue = Pick<MenuItemProps, 'id' | 'primary'>;\n\nexport type ValueSelectionFunction<F> = (\n args:\n | { lhs?: F; ids: string[] }\n | {\n lhs?: F;\n searchString?: string; // If missing, assume empty string\n comparator?: string; // If missing, assume EQ\n\n // If the below are missing, fetch maximum possible results\n pageNumber?: number;\n pageSize?: number;\n }\n) => Promise<string[] | ReferenceValue[]>;\n\nexport type ValueSelection<F> = string[] | ReferenceValue[] | ValueSelectionFunction<F>;\n\ninterface BasicField extends Pick<MenuItemProps, 'id' | 'primary'> {}\n\nexport type Field = BasicField &\n (\n | {\n parameters?: ParameterValue[];\n\n /**\n * For TEXT fields, if a list of possible values is known ahead of time, they can be passed.\n * Otherwise we fetch data from api and pass a promise which returns list of values\n * This enables users to select from those values instead of manually typing them\n */\n possibleValues?: ValueSelection<Field>;\n\n /**\n * Data-type for the field.\n * Has to be one of these values. Convert where necessary\n * e.g. Currency/Percentage... should be used as `DECIMAL`\n * e.g. Text(single value)/Picklist/... should be used as `TEXT`\n */\n type: FieldType;\n\n /**\n * Used to handle percentages are stored in the database,\n * determine whether value is stored in the range of 0 to 1 or 0 to 100\n */\n unit?: 'percent_1' | 'percent_100';\n }\n | {\n /** An array of type Field to represent the child items. */\n items: Field[];\n }\n );\n\n/** Valid date functions by field type */\nexport interface DateFunctionsByType {\n /** Date functions to enable for DATE_TIME fields */\n DATE_TIME: DateFunction[];\n /** Date functions to enable for DATE_ONLY fields */\n DATE_ONLY: DateFunction[];\n}\n\nexport type ValidationOptions = {\n /**\n * Whether to validate individual condition rows for completeness.\n *\n * When `true` (default): Validates each row's LHS, comparator, and RHS fields\n * When `false`: Only validates the overall logic string structure\n */\n performRowValidation?: boolean;\n};\n\nexport interface HandleValue {\n /**\n * Returns condition validity and condition or undefined if valid.\n * Undefined indicates no condition.\n */\n getCondition: (\n options?: ValidationOptions\n ) => [valid: false] | [valid: true, condition: Condition | undefined];\n getLogicError: () => string | null;\n}\n\n/** Type definition for the input props of ConditionBuilder */\nexport default interface ConditionBuilderProps extends BaseProps, NoChildrenProp {\n /** Metadata (data-model) for the Fields to use in the builder */\n fields: Field[];\n\n conditionRenderer?: (props: AtomicConditionProps) => ReactNode;\n\n /** (Optional) A seed condition for the builder. To use when editing an existing condition */\n condition?: Condition;\n\n /** (Optional) Used to limit the Comparators allowed in the builder. */\n validComparators?: ComparatorsByType[];\n\n /**\n * (Optional) Pass this to control which all types of RHS are enabled in the component\n * DEFAULT: Set(['LITERAL', 'FIELD'])\n * NOTE: If enabling `DATE_FUNCTION`s, additionally pass a `dateFunctions` prop to specify which functions are enabled\n */\n validRhsTypes?: Set<RHSType>;\n\n /** (Optional) When enabling 'DATE_FUNCTION's via `validRhsTypes`, pass this to specify which all date functions are applicable per field type */\n dateFunctions?: DateFunctionsByType;\n\n /** (Optional) Pass this if the `NOT` operator should be considered as invalid */\n disallowNOT?: boolean;\n\n /** Imperative handle for the component. */\n handle?: Ref<HandleValue>;\n\n /**\n * Callback fired when logic string validation error occurs or clears.\n */\n onLogicError?: (error: string | null) => void;\n\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: boolean;\n\n /** Disable the control. The browser defaults to false. */\n disabled?: boolean;\n\n /**\n * Ref to access the root HTMLDivElement of the ConditionBuilder.\n */\n ref?: Ref<HTMLDivElement>;\n}\n"]}
1
+ {"version":3,"file":"ConditionBuilder.types.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.types.ts"],"names":[],"mappings":"","sourcesContent":["// cspell:words DDTHH\nimport type { ReactNode, Ref } from 'react';\n\nimport type { BaseProps, MenuItemProps, NoChildrenProp } from '@pega/cosmos-react-core';\n\nimport type {\n Comparator,\n ComparatorsByType,\n DateFunction,\n DatePart,\n FieldType,\n RHSType,\n TimePeriod\n} from './core/types';\nimport type { AtomicConditionProps } from './AtomicCondition';\n\n/** RHS object with a Date function */\nexport interface RhsWithDateFunction {\n /**\n * Output format for the value varies based on the dateFunction:\n * YEARS: First day of year as YYYY-MM-DD\n * QUARTERS: First day of quarter as YYYY-MM-DD\n * MONTHS: First day of month as YYYY-MM-DD\n * WEEKS: First day of week as YYYY-MM-DD\n * DAYS: Date as YYYY-MM-DD\n * HOURS: YYYY-MM-DDTHH:mm:ss\n * MINUTES: YYYY-MM-DDTHH:mm:ss\n * SECONDS: YYYY-MM-DDTHH:mm:ss\n * HOURS_OF_DAY: 0-23\n * MONTHS_OF_YEAR: 1-12\n * DAYS_OF_MONTH: 1-31\n * DAYS_OF_WEEK: 1-7\n */\n value: string | number;\n dateFunction: DateFunction;\n}\n\n/** RHS object with a Relative Date */\nexport interface RhsWithRelativeDate {\n relativeDate: {\n timePeriod: TimePeriod;\n interval?: number;\n datePart: DatePart;\n };\n}\n\n/** RHS object with PARAMETER type */\nexport interface RhsWithParameter {\n parameterId: string;\n}\n\n/** Type definition for the leaf-level nodes in nested conditions */\nexport interface LeafCondition {\n comparator: Comparator;\n\n lhs: {\n field: string;\n };\n\n // Optional for some of the comparators like IS_TRUE, IS_NULL, etc.\n rhs?:\n | { field: string } // When comparing the LHS with another field\n | { value: string | number } // When comparing the LHS with a single literal value (for comparators like EQ, GTE etc.)\n | { values: string[] | number[] } // When comparing the LHS with a list of literal values (for comparators like IN, NOT_IN etc.)\n | { start: string | number; end: string | number } // When comparing numeric or date field with two values that determine range\n | RhsWithDateFunction // When comparing a date field with a date function on RHS\n | RhsWithRelativeDate // When comparing a date field with a symbolic date on RHS\n | RhsWithParameter; // When comparing the LHS with PARAMETER type\n lhsType?: string;\n}\n\n/** Type definition for objects representing condition-rows in the builder UI */\nexport interface ConditionRow extends LeafCondition {\n id: string; // To use as `key` prop when rendering a list of rows\n label: string; // Used to refer the row from a logic-string\n}\n\n/**\n * Type definition for simple/complex conditions\n * At a given node in the condition tree, it can have exactly one of the keys AND/OR/NOT/condition\n */\nexport type Condition =\n | { AND: Condition[] }\n | { OR: Condition[] }\n | { NOT: Condition }\n | { condition: LeafCondition };\n\n/** Type definition for the input Field objects for the ConditionBuilder */\n\nexport type ParameterValue = Pick<MenuItemProps, 'id' | 'primary'>;\n\nexport type ReferenceValue = Pick<MenuItemProps, 'id' | 'primary'>;\n\nexport type ValueSelectionFunction<F> = (\n args:\n | { lhs?: F; ids: string[] }\n | {\n lhs?: F;\n searchString?: string; // If missing, assume empty string\n comparator?: string; // If missing, assume EQ\n\n // If the below are missing, fetch maximum possible results\n pageNumber?: number;\n pageSize?: number;\n }\n) => Promise<string[] | ReferenceValue[]>;\n\nexport type ValueSelection<F> = string[] | ReferenceValue[] | ValueSelectionFunction<F>;\n\ninterface BasicField extends Pick<MenuItemProps, 'id' | 'primary'> {}\n\nexport type Field = BasicField &\n (\n | {\n parameters?: ParameterValue[];\n\n /**\n * For TEXT fields, if a list of possible values is known ahead of time, they can be passed.\n * Otherwise we fetch data from api and pass a promise which returns list of values\n * This enables users to select from those values instead of manually typing them\n */\n possibleValues?: ValueSelection<Field>;\n\n /**\n * Data-type for the field.\n * Has to be one of these values. Convert where necessary\n * e.g. Currency/Percentage... should be used as `DECIMAL`\n * e.g. Text(single value)/Picklist/... should be used as `TEXT`\n */\n type: FieldType;\n\n /**\n * Used to handle percentages are stored in the database,\n * determine whether value is stored in the range of 0 to 1 or 0 to 100\n */\n unit?: 'percent_1' | 'percent_100';\n }\n | {\n /** An array of type Field to represent the child items. */\n items: Field[];\n }\n );\n\n/** Valid date functions by field type */\nexport interface DateFunctionsByType {\n /** Date functions to enable for DATE_TIME fields */\n DATE_TIME: DateFunction[];\n /** Date functions to enable for DATE_ONLY fields */\n DATE_ONLY: DateFunction[];\n}\n\nexport type ValidationOptions = {\n /**\n * Whether to validate individual condition rows for completeness.\n *\n * When `true` (default): Validates each row's LHS, comparator, and RHS fields\n * When `false`: Only validates the overall logic string structure\n */\n performRowValidation?: boolean;\n};\n\nexport interface HandleValue {\n /**\n * Returns condition validity and condition or undefined if valid.\n * Undefined indicates no condition.\n */\n getCondition: (\n options?: ValidationOptions\n ) => [valid: false] | [valid: true, condition: Condition | undefined];\n getLogicError: () => string | null;\n}\n\n/** Type definition for the input props of ConditionBuilder */\nexport default interface ConditionBuilderProps extends BaseProps, NoChildrenProp {\n /** Metadata (data-model) for the Fields to use in the builder */\n fields: Field[];\n\n conditionRenderer?: (props: AtomicConditionProps) => ReactNode;\n\n /** (Optional) A seed condition for the builder. To use when editing an existing condition */\n condition?: Condition;\n\n /** (Optional) Used to limit the Comparators allowed in the builder. */\n validComparators?: ComparatorsByType[];\n\n /**\n * (Optional) Pass this to control which all types of RHS are enabled in the component\n * DEFAULT: Set(['LITERAL', 'FIELD'])\n * NOTE: If enabling `DATE_FUNCTION`s, additionally pass a `dateFunctions` prop to specify which functions are enabled\n */\n validRhsTypes?: Set<RHSType>;\n\n /** (Optional) When enabling 'DATE_FUNCTION's via `validRhsTypes`, pass this to specify which all date functions are applicable per field type */\n dateFunctions?: DateFunctionsByType;\n\n /** (Optional) Pass this if the `NOT` operator should be considered as invalid */\n disallowNOT?: boolean;\n\n /** Imperative handle for the component. */\n handle?: Ref<HandleValue>;\n\n /** Callback fired when a row is added */\n onAddRow?: (rowIndex: number) => void;\n\n /** Callback fired when a row is deleted */\n onDeleteRow?: (rowIndex: number) => void;\n\n /**\n * Callback fired when logic string validation error occurs or clears.\n */\n onLogicError?: (error: string | null) => void;\n\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: boolean;\n\n /** Disable the control. The browser defaults to false. */\n disabled?: boolean;\n\n /**\n * Ref to access the root HTMLDivElement of the ConditionBuilder.\n */\n ref?: Ref<HTMLDivElement>;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-condition-builder",
3
- "version": "9.0.0-build.16.0",
3
+ "version": "9.0.0-build.16.2",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "author": "Pegasystems",
6
6
  "sideEffects": [
@@ -17,7 +17,7 @@
17
17
  "build": "tsc -b tsconfig.build.json"
18
18
  },
19
19
  "dependencies": {
20
- "@pega/cosmos-react-core": "9.0.0-build.16.0",
20
+ "@pega/cosmos-react-core": "9.0.0-build.16.2",
21
21
  "@types/react": "^17.0.62 || ^18.3.3",
22
22
  "@types/react-dom": "^17.0.20 || ^18.3.0",
23
23
  "@types/styled-components": "^5.1.26",