@pega/cosmos-react-condition-builder 10.0.0-build.3.1 → 10.0.0-build.4.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.
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionBuilder.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAG/E,OAAO,KAAK,qBAAqB,MAAM,0BAA0B,CAAC;AAgClE,QAAA,MAAM,gBAAgB,EAAE,+BAA+B,CAAC,qBAAqB,CAwc5E,CAAC;AAGF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"ConditionBuilder.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAG/E,OAAO,KAAK,qBAAqB,MAAM,0BAA0B,CAAC;AAgClE,QAAA,MAAM,gBAAgB,EAAE,+BAA+B,CAAC,qBAAqB,CAyc5E,CAAC;AAGF,eAAe,gBAAgB,CAAC"}
@@ -143,6 +143,7 @@ const ConditionBuilder = forwardRef(function ConditionBuilder(props, ref) {
143
143
  ]);
144
144
  deferConditionChange();
145
145
  };
146
+ const t = useI18n();
146
147
  // Validate the logic input. Called upon clicking outside the textBox or upon submission.
147
148
  // If the expression is invalid, shows appropriate feedback and returns null.
148
149
  // 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
@@ -157,8 +158,9 @@ const ConditionBuilder = forwardRef(function ConditionBuilder(props, ref) {
157
158
  const parseResult = parseLogicString(logicToUse, conditionLookup, disallowNOT);
158
159
  // Indicate any parse error
159
160
  if (hasProp(parseResult, 'error')) {
160
- setLogicError(parseResult.error);
161
- onLogicError?.(parseResult.error);
161
+ const errorMessage = t(...parseResult.error);
162
+ setLogicError(errorMessage);
163
+ onLogicError?.(errorMessage);
162
164
  return null;
163
165
  }
164
166
  // If no errors
@@ -221,7 +223,6 @@ const ConditionBuilder = forwardRef(function ConditionBuilder(props, ref) {
221
223
  getCondition,
222
224
  getLogicError
223
225
  }), [getCondition, getLogicError]);
224
- const t = useI18n();
225
226
  const { announceAssertive } = useLiveLog();
226
227
  useEffect(() => {
227
228
  announceAssertive({ message: t('condition_builder_mode_switch') });
@@ -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,aAAa,EACb,kBAAkB,EAClB,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,EACrB,OAAO,EACR,MAAM,cAAc,CAAC;AACtB,OAAO,WAAW,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtF,OAAO,EACL,sBAAsB,EACtB,SAAS,EACT,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AAEnC,gCAAgC;AAChC,MAAM,YAAY,GAAmC;IACnD,SAAS,EAAE;QACT,SAAS,EAAE;YACT,UAAU,EAAE,aAAa;YACzB,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["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 useBreakpoint,\n useConsolidatedRef,\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 getItem\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 StyledInputLevelItem\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 timeZone,\n disallowNOT,\n disabled = false,\n readOnly = false,\n handle,\n conditionRenderer: ConditionRenderer = AtomicCondition,\n onLogicError,\n onAddRow,\n onDeleteRow,\n onConditionChange\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 const containerRef = useConsolidatedRef(ref);\n const isSmallOrAbove = useBreakpoint('sm', { breakpointRef: containerRef });\n const isMediumOrAbove = useBreakpoint('md', { breakpointRef: containerRef });\n\n /**\n * Defers onConditionChange callback to ensure state updates complete before invocation.\n * Justification: Uses setTimeout with 0ms delay for allowing dispatch and setState calls to finish and propagate to the store\n * before the parent component is notified. This prevents the parent from receiving\n * stale condition data.\n */\n const deferConditionChange = () => {\n if (onConditionChange) {\n setTimeout(onConditionChange, 0);\n }\n };\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 deferConditionChange();\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={containerRef}>\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 fieldLabel =\n getItem(fields, leaf.lhs.field)?.primary ?? leaf.lhs.field.split('.').pop();\n const deleteAriaLabel = `${t('condition_builder_field_label')} ${fieldLabel}`;\n\n const alignItems = isSmallOrAbove ? 'start' : 'stretch';\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 $nested={enableShading && operatorsList[index - 1] === 'AND'}\n >\n <MenuButton\n popover={{ hideOnTargetHidden: false }}\n text={\n operatorsList[index - 1] === 'AND'\n ? t('condition_builder_logical_and')\n : t('condition_builder_logical_or')\n }\n variant='simple'\n menu={{\n items: [\n {\n id: 'AND',\n primary: t('condition_builder_logical_and'),\n onClick: () => updateOperator(index - 1, 'AND')\n },\n {\n id: 'OR',\n primary: t('condition_builder_logical_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={{\n gap: 1,\n alignItems,\n direction: isSmallOrAbove ? 'row' : 'column',\n justify: 'between'\n }}\n $isBasicMode={isBasicMode}\n $nested={\n isBasicMode &&\n enableShading &&\n (operatorsList[index] === 'AND' || operatorsList[index - 1] === 'AND')\n }\n ref={index === focusRowIndex ? focusRowRef : null}\n >\n {/* Label */}\n {!isBasicMode && (\n <StyledInputLevelItem item={{ alignSelf: 'start' }} $row={isSmallOrAbove}>\n <StyledLabel>{label}</StyledLabel>\n </StyledInputLevelItem>\n )}\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 deferConditionChange();\n }}\n validComparators={validComparators}\n dateFunctions={dateFunctions}\n timeZone={timeZone}\n validRhsTypes={validRhsTypes}\n />\n </Flex>\n\n <StyledInputLevelItem\n container={{ justify: 'end' }}\n $row={isSmallOrAbove}\n $bottom={isSmallOrAbove && !isMediumOrAbove}\n >\n {/* Row actions */}\n <Button\n icon\n variant='simple'\n onClick={() => {\n insertRow(index + 1);\n setCachedLogicString('');\n deferConditionChange();\n }}\n label={t('add')}\n aria-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 deferConditionChange();\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 </StyledInputLevelItem>\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 <pre>\n {disallowNOT\n ? '(1 or 2) and (3 or 4 or 5)'\n : '(1 and 2) or (3 and not 4)'}\n </pre>\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 deferConditionChange();\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,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,aAAa,EACb,kBAAkB,EAClB,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,EACrB,OAAO,EACR,MAAM,cAAc,CAAC;AACtB,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BACzB,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 useBreakpoint,\n useConsolidatedRef,\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 getItem\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 StyledInputLevelItem\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 timeZone,\n disallowNOT,\n disabled = false,\n readOnly = false,\n handle,\n conditionRenderer: ConditionRenderer = AtomicCondition,\n onLogicError,\n onAddRow,\n onDeleteRow,\n onConditionChange\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 const containerRef = useConsolidatedRef(ref);\n const isSmallOrAbove = useBreakpoint('sm', { breakpointRef: containerRef });\n const isMediumOrAbove = useBreakpoint('md', { breakpointRef: containerRef });\n\n /**\n * Defers onConditionChange callback to ensure state updates complete before invocation.\n * Justification: Uses setTimeout with 0ms delay for allowing dispatch and setState calls to finish and propagate to the store\n * before the parent component is notified. This prevents the parent from receiving\n * stale condition data.\n */\n const deferConditionChange = () => {\n if (onConditionChange) {\n setTimeout(onConditionChange, 0);\n }\n };\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 deferConditionChange();\n };\n\n const t = useI18n();\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 const errorMessage = t(...parseResult.error);\n setLogicError(errorMessage);\n onLogicError?.(errorMessage);\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 { 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={containerRef}>\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 fieldLabel =\n getItem(fields, leaf.lhs.field)?.primary ?? leaf.lhs.field.split('.').pop();\n const deleteAriaLabel = `${t('condition_builder_field_label')} ${fieldLabel}`;\n\n const alignItems = isSmallOrAbove ? 'start' : 'stretch';\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 $nested={enableShading && operatorsList[index - 1] === 'AND'}\n >\n <MenuButton\n popover={{ hideOnTargetHidden: false }}\n text={\n operatorsList[index - 1] === 'AND'\n ? t('condition_builder_logical_and')\n : t('condition_builder_logical_or')\n }\n variant='simple'\n menu={{\n items: [\n {\n id: 'AND',\n primary: t('condition_builder_logical_and'),\n onClick: () => updateOperator(index - 1, 'AND')\n },\n {\n id: 'OR',\n primary: t('condition_builder_logical_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={{\n gap: 1,\n alignItems,\n direction: isSmallOrAbove ? 'row' : 'column',\n justify: 'between'\n }}\n $isBasicMode={isBasicMode}\n $nested={\n isBasicMode &&\n enableShading &&\n (operatorsList[index] === 'AND' || operatorsList[index - 1] === 'AND')\n }\n ref={index === focusRowIndex ? focusRowRef : null}\n >\n {/* Label */}\n {!isBasicMode && (\n <StyledInputLevelItem item={{ alignSelf: 'start' }} $row={isSmallOrAbove}>\n <StyledLabel>{label}</StyledLabel>\n </StyledInputLevelItem>\n )}\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 deferConditionChange();\n }}\n validComparators={validComparators}\n dateFunctions={dateFunctions}\n timeZone={timeZone}\n validRhsTypes={validRhsTypes}\n />\n </Flex>\n\n <StyledInputLevelItem\n container={{ justify: 'end' }}\n $row={isSmallOrAbove}\n $bottom={isSmallOrAbove && !isMediumOrAbove}\n >\n {/* Row actions */}\n <Button\n icon\n variant='simple'\n onClick={() => {\n insertRow(index + 1);\n setCachedLogicString('');\n deferConditionChange();\n }}\n label={t('add')}\n aria-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 deferConditionChange();\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 </StyledInputLevelItem>\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 <pre>\n {disallowNOT\n ? '(1 or 2) and (3 or 4 or 5)'\n : '(1 and 2) or (3 and not 4)'}\n </pre>\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 deferConditionChange();\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,4 +1,7 @@
1
+ import type { TranslationPack } from '@pega/cosmos-react-core';
1
2
  import type { Condition, ConditionRow, LeafCondition, Field } from '../ConditionBuilder.types';
3
+ type ConditionBuilderTranslationKey = Extract<keyof TranslationPack, `condition_builder_${string}`>;
4
+ export type ConditionBuilderParseError = [key: ConditionBuilderTranslationKey, tokens: string[]];
2
5
  /** Parses a logic-expression into a condition object. */
3
6
  export declare function parseLogicString(expression: string, conditionLookup: {
4
7
  [label: string]: LeafCondition;
@@ -6,7 +9,7 @@ export declare function parseLogicString(expression: string, conditionLookup: {
6
9
  disallowNOT?: boolean, ignoreUnusedLabels?: boolean): {
7
10
  condition: Condition;
8
11
  } | {
9
- error: string;
12
+ error: ConditionBuilderParseError;
10
13
  };
11
14
  /**
12
15
  * Takes a valid logic string and formats it with parentheses at appropriate places to keep things unambiguous
@@ -40,4 +43,5 @@ export declare function getItem(items: Field[], id: string): Field | undefined;
40
43
  * @returns - true(if the timezone component is present) or false(if no timezone is present or if format is invalid)
41
44
  */
42
45
  export declare function isAbsoluteDateString(str: string): boolean;
46
+ export {};
43
47
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/core/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAiQ/F,yDAAyD;AACzD,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE,EAAE,4CAA4C;AACjG,WAAW,GAAE,OAAe,EAC5B,kBAAkB,GAAE,OAAe,GAClC;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAqB9C;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CA0D5D;AAkDD,uFAAuF;AACvF,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,SAAS,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,YAAY,EAAE,CAAA;CAAE,CAUjG;AAGD,mIAAmI;AACnI,wBAAgB,kBAAkB,CAChC,IA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E,4CAA4C;AACjG,WAAW,GAAE,OAAe,EAC5B,kBAAkB,GAAE,OAAe,GAClC;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,0BAA0B,CAAA;CAAE,CAwBlE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CA0D5D;AAkDD,uFAAuF;AACvF,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,SAAS,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,YAAY,EAAE,CAAA;CAAE,CAUjG;AAGD,mIAAmI;AACnI,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,SAAS,EACf,WAAW,GAAE,MAAW,GACvB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAA;KAAE,CAAA;CAAE,CAkBnE;AAED,qHAAqH;AACrH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAyBnE;AAED,8FAA8F;AAC9F,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAMrE;AAED,2GAA2G;AAC3G,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,GAAG,MAAM,CAG7E;AAED,4GAA4G;AAC5G,wBAAgB,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAiBrE;AAOD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,WAE/C"}
@@ -35,7 +35,9 @@ function tokenizeExpression(expression, disallowNOT = false) {
35
35
  });
36
36
  // Return an error if any invalid tokens are present
37
37
  if (invalidWords.length > 0) {
38
- return { error: `Unexpected words/characters: ${invalidWords.join(' ')}` }; // FIXME: TR
38
+ return {
39
+ error: ['condition_builder_unexpected_words_or_characters', [invalidWords.join(' ')]]
40
+ };
39
41
  }
40
42
  return { tokens };
41
43
  }
@@ -54,11 +56,11 @@ function findInvalidPatterns(tokens) {
54
56
  const tokenType = isIntegerToken(token) ? NUMBER : token; // To simplify comparisons below
55
57
  // The expression can only start with NOT, LPAREN or NUMBER
56
58
  if (i === 0 && ![NOT, LPAREN, NUMBER].includes(tokenType)) {
57
- return `Unexpected "${token}" at the beginning.`; // FIXME: TR
59
+ return ['condition_builder_unexpected_token_at_the_beginning', [token]];
58
60
  }
59
61
  // The expression can only end with RPAREN or NUMBER
60
62
  if (i === tokens.length - 1 && ![RPAREN, NUMBER].includes(tokenType)) {
61
- return `Unexpected "${token}" at the end.`; // FIXME: TR
63
+ return ['condition_builder_unexpected_token_at_the_end', [token]];
62
64
  }
63
65
  // If there is a previous token, check if it is supposed to precede the current token
64
66
  if (i > 0) {
@@ -70,7 +72,7 @@ function findInvalidPatterns(tokens) {
70
72
  case OR:
71
73
  case RPAREN:
72
74
  if (![RPAREN, NUMBER].includes(prevTokenType)) {
73
- return `Unexpected "${token}" after "${prevToken}"`; // FIXME: TR
75
+ return ['condition_builder_unexpected_token_after_previous_token', [token, prevToken]];
74
76
  }
75
77
  break;
76
78
  // NOT/LPAREN/NUMBER can not be preceded by RPAREN or NUMBER
@@ -78,7 +80,7 @@ function findInvalidPatterns(tokens) {
78
80
  case LPAREN:
79
81
  case NUMBER:
80
82
  if ([RPAREN, NUMBER].includes(prevTokenType)) {
81
- return `Unexpected "${token}" after "${prevToken}"`; // FIXME: TR
83
+ return ['condition_builder_unexpected_token_after_previous_token', [token, prevToken]];
82
84
  }
83
85
  break;
84
86
  default: // do nothing
@@ -143,16 +145,18 @@ function getPostfixFromInfix(tokens) {
143
145
  stack.pop();
144
146
  }
145
147
  else {
146
- // FIXME: TR
147
- return { error: 'Please fix mismatched parentheses.' }; // If no LPAREN found for the current RPAREN
148
+ return {
149
+ error: ['condition_builder_mismatched_parentheses', []]
150
+ }; // If no LPAREN found for the current RPAREN
148
151
  }
149
152
  }
150
153
  }
151
154
  // While there are operators on the stack, pop them to the queue
152
155
  while (stack.length > 0) {
153
156
  if (stack[stack.length - 1] === LPAREN) {
154
- // FIXME: TR
155
- return { error: 'Please fix mismatched parentheses.' }; // If there were excess LPARENs. (Excess RPARENs are already handled in the above loop. Also, RPARENs are never pushed to the stack)
157
+ return {
158
+ error: ['condition_builder_mismatched_parentheses', []]
159
+ }; // If there were excess LPARENs. (Excess RPARENs are already handled in the above loop. Also, RPARENs are never pushed to the stack)
156
160
  }
157
161
  postfixQueue.push(stack.pop());
158
162
  }
@@ -213,11 +217,14 @@ function getConditionFromPostfix(postfixArr, conditionLookup, ignoreUnusedLabels
213
217
  if (labelsWithNoRows.length > 0) {
214
218
  if (labelsWithNoRows.length === 1) {
215
219
  return {
216
- error: `Condition ${labelsWithNoRows[0]} used in the logical string is not defined.` // FIXME: TR
220
+ error: ['condition_builder_undefined_condition_in_logical_string', [labelsWithNoRows[0]]]
217
221
  };
218
222
  }
219
223
  return {
220
- error: `Conditions ${labelsWithNoRows.join(', ')} used in the logical string are not defined.` // FIXME: TR
224
+ error: [
225
+ 'condition_builder_undefined_conditions_in_logical_string',
226
+ [labelsWithNoRows.join(', ')]
227
+ ]
221
228
  };
222
229
  }
223
230
  // Warn if any of the condition rows are unused
@@ -225,10 +232,12 @@ function getConditionFromPostfix(postfixArr, conditionLookup, ignoreUnusedLabels
225
232
  const unusedLabels = Object.keys(conditionLookup).filter(l => !usedLabels.includes(l));
226
233
  if (unusedLabels.length > 0) {
227
234
  if (unusedLabels.length === 1) {
228
- return { error: `Condition ${unusedLabels[0]} is not used in the logic expression.` }; // FIXME: TR
235
+ return {
236
+ error: ['condition_builder_unused_condition_in_logical_string', [unusedLabels[0]]]
237
+ };
229
238
  }
230
239
  return {
231
- error: `Conditions ${unusedLabels.join(', ')} are not used in the logic expression.` // FIXME: TR
240
+ error: ['condition_builder_unused_conditions_in_logical_string', [unusedLabels.join(', ')]]
232
241
  };
233
242
  }
234
243
  }
@@ -239,7 +248,9 @@ export function parseLogicString(expression, conditionLookup, // To look up cond
239
248
  disallowNOT = false, ignoreUnusedLabels = false) {
240
249
  // Handle empty expressions
241
250
  if (!expression.trim().length)
242
- return { error: 'Please provide a logic expression.' }; // FIXME: TR
251
+ return {
252
+ error: ['condition_builder_please_provide_a_logic_expression', []]
253
+ };
243
254
  // Split the expression into individual tokens
244
255
  const tokeningResult = tokenizeExpression(expression, disallowNOT);
245
256
  if (hasProp(tokeningResult, 'error'))
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/core/utils.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAI7D,MAAM,GAAG,GAAG,KAAK,CAAC;AAClB,MAAM,EAAE,GAAG,IAAI,CAAC;AAChB,MAAM,GAAG,GAAG,KAAK,CAAC;AAClB,MAAM,MAAM,GAAG,GAAG,CAAC;AACnB,MAAM,MAAM,GAAG,GAAG,CAAC;AAEnB,MAAM,aAAa,GAA6B,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,sEAAsE;AACjJ,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,0BAA0B;AAC1E,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,6CAA6C;AAE1G,MAAM,cAAc,GAAG,CAAC,KAAa,EAAW,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,0CAA0C;AAClH,MAAM,e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AC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAC3F,OAAO,iBAAiB,CAAC,WAAW,CAAC,CAAC,CAAC,+EAA+E;AACxH,CAAC;AAED,4GAA4G;AAC5G,MAAM,UAAU,OAAO,CAAC,KAAc,EAAE,EAAU;IAChD,IAAI,KAAwB,CAAC;IAC7B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAChB,IAAI,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;YACnB,KAAK,GAAG,IAAI,CAAC;YACb,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;YAC3B,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAChC,OAAO,CAAC,CAAC,KAAK,CAAC;QACjB,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC;AAED,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,wBAAwB,GAC5B,iFAAiF,CAAC;AAEpF;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,OAAO,wBAAwB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["// cspell:words LPAREN LPARENs RPAREN RPARENs\nimport { createUID, hasProp } from '@pega/cosmos-react-core';\n\nimport type { Condition, ConditionRow, LeafCondition, Field } from '../ConditionBuilder.types';\n\nconst AND = 'AND';\nconst OR = 'OR';\nconst NOT = 'NOT';\nconst LPAREN = '(';\nconst RPAREN = ')';\n\nconst precedenceMap: { [op: string]: number } = { OR: 1, AND: 2, NOT: 3 }; // Operator precedence. NOT has the highest precedence over the others\nconst operatorTokens = new Set([AND, OR, NOT]); // Valid logical operators\nconst validTokens = new Set([AND, OR, NOT, LPAREN, RPAREN]); // Other than these, integer tokens are valid\n\nconst isIntegerToken = (token: string): boolean => /^\\d+$/.test(token); // Checks if the input token is an integer\nconst isOperatorToken = (token: string): boolean => operatorTokens.has(token); // Checks if the input token is an operator\n\n/**\n * Tokenize the input expression.\n * Valid tokens are 'AND', 'OR', 'NOT', '(', ')' and any integer token.\n * Throws an error if an invalid token is found.\n */\nfunction tokenizeExpression(\n expression: string,\n disallowNOT: boolean = false\n): { tokens: string[] } | { error: string } {\n expression = expression.trim().toUpperCase(); // To simplify comparisons below; the tokens AND/OR/NOT are anyways expected to be in uppercase\n const words = expression.match(/[A-Z]+|[0-9]+|_|\\W/g); // Split contiguous alphabets and contiguous numbers into the same token. For all other characters, create a token for each character. Although `_` is not expected to be used, handling it just for completeness\n const tokens: string[] = []; // Final list of valid tokens\n const invalidWords: string[] = []; // Any invalid words are captured here\n\n // `words` will never be null because of the regex we used. Using `!` to indicate the same to TS\n words!.forEach(word => {\n // Ignore white-space characters\n if (word.trim().length > 0) {\n // If it's a token from the above Set or if it's an integer token\n if (isIntegerToken(word) || (validTokens.has(word) && !(word === NOT && disallowNOT))) {\n tokens.push(word);\n } else {\n invalidWords.push(word);\n }\n }\n });\n\n // Return an error if any invalid tokens are present\n if (invalidWords.length > 0) {\n return { error: `Unexpected words/characters: ${invalidWords.join(' ')}` }; // FIXME: TR\n }\n\n return { tokens };\n}\n\n/**\n * Captures any invalid/unexpected token patterns\n * NOTE: This does not expect any invalid tokens to be passed in the input\n * NOTE: This doesn't handle mismatched parentheses. That is handled separately in getPostfixFromInfix\n * Returns an error message about the first invalid sequence present in the input. Returns `null` if none found\n */\nfunction findInvalidPatterns(tokens: string[]): string | null {\n // These patterns are identified based on which token can precede/succeed which.\n // A table with all such permutations can be found in DOC-38200\n\n for (let i = 0; i < tokens.length; i += 1) {\n const NUMBER = 'NUMBER'; // To avoid repeating a string literal\n const token = tokens[i];\n const tokenType = isIntegerToken(token) ? NUMBER : token; // To simplify comparisons below\n\n // The expression can only start with NOT, LPAREN or NUMBER\n if (i === 0 && ![NOT, LPAREN, NUMBER].includes(tokenType)) {\n return `Unexpected \"${token}\" at the beginning.`; // FIXME: TR\n }\n\n // The expression can only end with RPAREN or NUMBER\n if (i === tokens.length - 1 && ![RPAREN, NUMBER].includes(tokenType)) {\n return `Unexpected \"${token}\" at the end.`; // FIXME: TR\n }\n\n // If there is a previous token, check if it is supposed to precede the current token\n if (i > 0) {\n const prevToken = tokens[i - 1];\n const prevTokenType = isIntegerToken(prevToken) ? NUMBER : prevToken; // To simplify comparisons below\n switch (tokenType) {\n // AND/OR/RPAREN can only be preceded by RPAREN or NUMBER\n case AND:\n case OR:\n case RPAREN:\n if (![RPAREN, NUMBER].includes(prevTokenType)) {\n return `Unexpected \"${token}\" after \"${prevToken}\"`; // FIXME: TR\n }\n break;\n\n // NOT/LPAREN/NUMBER can not be preceded by RPAREN or NUMBER\n case NOT:\n case LPAREN:\n case NUMBER:\n if ([RPAREN, NUMBER].includes(prevTokenType)) {\n return `Unexpected \"${token}\" after \"${prevToken}\"`; // FIXME: TR\n }\n break;\n default: // do nothing\n }\n }\n }\n\n // Return null if no invalid sequences\n return null;\n}\n\n/**\n * Converts an input array of Infix tokens into a Postfix array.\n * Uses the ShuntingYard algorithm.\n * NOTE: This does not expect any invalid tokens to be passed in the input\n */\nfunction getPostfixFromInfix(tokens: string[]): { postfixArr: string[] } | { error: string } {\n // Refer these for the ShuntingYard algorithm:\n // * https://brilliant.org/wiki/shunting-yard-algorithm/\n // * https://en.wikipedia.org/wiki/Shunting-yard_algorithm#The_algorithm_in_detail\n const postfixQueue: string[] = []; // Output queue\n const stack: string[] = []; // Operations stack\n\n // While there are tokens to be read\n for (let i = 0; i < tokens.length; i += 1) {\n const token = tokens[i];\n\n if (isIntegerToken(token)) {\n // If it's a number add it to queue\n postfixQueue.push(token);\n } else if (isOperatorToken(token)) {\n // If it's an operator\n // While there's an operator on the top of the stack with greater precedence (or equal precedence and the token is left-associative), pop operators from the stack onto the output queue\n if (token !== NOT) {\n // Unary operators should not cause any operators to be popped from the stack.\n // See http://wcipeg.com/wiki/Shunting_yard_algorithm#Unary_operators\n while (stack.length > 0) {\n const stackTop = stack[stack.length - 1];\n if (isOperatorToken(stackTop) && precedenceMap[stackTop] >= precedenceMap[token]) {\n postfixQueue.push(stack.pop()!);\n } else {\n break;\n }\n }\n }\n // Push the current operator onto the stack\n stack.push(token);\n } else if (token === LPAREN) {\n // If it's a left parenthesis, push it onto the stack\n stack.push(token);\n } else {\n // If it's a right parenthesis (RPAREN)\n // While there's not a left parenthesis at the top of the stack, pop operators from the stack onto the output queue\n while (stack.length > 0) {\n const stackTop = stack[stack.length - 1];\n if (stackTop === LPAREN) break;\n postfixQueue.push(stack.pop()!);\n }\n\n // Pop the left parenthesis from the stack and discard it\n if (stack.length > 0) {\n stack.pop();\n } else {\n // FIXME: TR\n return { error: 'Please fix mismatched parentheses.' }; // If no LPAREN found for the current RPAREN\n }\n }\n }\n\n // While there are operators on the stack, pop them to the queue\n while (stack.length > 0) {\n if (stack[stack.length - 1] === LPAREN) {\n // FIXME: TR\n return { error: 'Please fix mismatched parentheses.' }; // If there were excess LPARENs. (Excess RPARENs are already handled in the above loop. Also, RPARENs are never pushed to the stack)\n }\n postfixQueue.push(stack.pop()!);\n }\n\n return { postfixArr: postfixQueue };\n}\n\n/**\n * Converts an input array of Postfix tokens into a Condition tree.\n * NOTE: This expects a properly formed Postfix array as input\n */\nfunction getConditionFromPostfix(\n postfixArr: string[],\n conditionLookup: { [label: string]: LeafCondition },\n ignoreUnusedLabels: boolean\n): { condition: Condition } | { error: string } {\n // To learn more about the below algorithm, refer this: https://brilliant.org/wiki/shunting-yard-algorithm/#reverse-polish\n const operandsStack: Condition[] = [];\n const labelsWithNoRows: string[] = []; // Labels for which there is no corresponding op in conditionLookup\n const usedLabels: string[] = []; // A list of all labels used in the condition. This is used to warn about any unused operations\n postfixArr.forEach(token => {\n if (isIntegerToken(token)) {\n // If it's a numeric token (leaf condition), push it to the stack\n const conditionRow = conditionLookup[token]; // Identify the corresponding condition row\n operandsStack.push({ condition: conditionRow }); // Push it even if null so that the conversion goes on smoothly and identifies any other issues\n if (!conditionRow) {\n labelsWithNoRows.push(token); // Mark it as missing\n } else {\n usedLabels.push(token); // Mark it as used\n }\n } else if (token === NOT) {\n // If it's the NOT operator\n // Pop an operand, perform the operation and push the result back to the stack\n const operand = operandsStack.pop()!;\n operandsStack.push({ NOT: operand });\n } else {\n // If it's the AND/OR operator\n // Pop two operands, perform the operation and push the result back to the stack\n const operand2 = operandsStack.pop()!;\n const operand1 = operandsStack.pop()!;\n\n // If the inner operation is the same as the current one, consolidate them\n // e.g. `1 AND (2 AND 3)` should be consolidated as `1 AND 2 AND 3`\n // e.g. `1 OR (2 OR 3)` should be consolidated as `1 OR 2 OR 3`\n if (token === 'AND') {\n const operands = [\n ...(hasProp(operand1, 'AND') ? operand1.AND : [operand1]),\n ...(hasProp(operand2, 'AND') ? operand2.AND : [operand2])\n ];\n operandsStack.push({ AND: operands });\n } else {\n const operands = [\n ...(hasProp(operand1, 'OR') ? operand1.OR : [operand1]),\n ...(hasProp(operand2, 'OR') ? operand2.OR : [operand2])\n ];\n operandsStack.push({ OR: operands });\n }\n }\n });\n\n // If any labels are used for which there are no corresponding condition-rows\n if (labelsWithNoRows.length > 0) {\n if (labelsWithNoRows.length === 1) {\n return {\n error: `Condition ${labelsWithNoRows[0]} used in the logical string is not defined.` // FIXME: TR\n };\n }\n return {\n error: `Conditions ${labelsWithNoRows.join(', ')} used in the logical string are not defined.` // FIXME: TR\n };\n }\n\n // Warn if any of the condition rows are unused\n if (!ignoreUnusedLabels) {\n const unusedLabels = Object.keys(conditionLookup).filter(l => !usedLabels.includes(l));\n if (unusedLabels.length > 0) {\n if (unusedLabels.length === 1) {\n return { error: `Condition ${unusedLabels[0]} is not used in the logic expression.` }; // FIXME: TR\n }\n return {\n error: `Conditions ${unusedLabels.join(', ')} are not used in the logic expression.` // FIXME: TR\n };\n }\n }\n\n return { condition: operandsStack[0] };\n}\n\n/** Parses a logic-expression into a condition object. */\nexport function parseLogicString(\n expression: string,\n conditionLookup: { [label: string]: LeafCondition }, // To look up condition-rows from the labels\n disallowNOT: boolean = false,\n ignoreUnusedLabels: boolean = false\n): { condition: Condition } | { error: string } {\n // Handle empty expressions\n if (!expression.trim().length) return { error: 'Please provide a logic expression.' }; // FIXME: TR\n\n // Split the expression into individual tokens\n const tokeningResult = tokenizeExpression(expression, disallowNOT);\n if (hasProp(tokeningResult, 'error')) return tokeningResult;\n const { tokens } = tokeningResult;\n\n // Capture any invalid/unexpected token patterns\n // NOTE: This doesn't handle mismatched parentheses. That is handled below in getPostfixFromInfix\n const badPatternError = findInvalidPatterns(tokens);\n if (badPatternError !== null) return { error: badPatternError };\n\n // Convert the Infix tokens to a Postfix notation using the ShuntingYard algorithm\n const postfixResult = getPostfixFromInfix(tokens);\n if (hasProp(postfixResult, 'error')) return postfixResult;\n const { postfixArr } = postfixResult;\n\n // Convert the Postfix token to a Condition tree\n return getConditionFromPostfix(postfixArr, conditionLookup, ignoreUnusedLabels);\n}\n\n/**\n * Takes a valid logic string and formats it with parentheses at appropriate places to keep things unambiguous\n * For example, `1 AND 2 OR 3` is disambiguated as `(1 AND 2) OR 3`\n * NOTE: This expects only valid logic strings to be passed as an input\n */\nexport function disambiguateLogic(expression: string): string {\n // Split the expression into individual tokens\n const tokeningResult = tokenizeExpression(expression);\n const { tokens } = tokeningResult as { tokens: string[] }; // Only valid expressions are expected as inputs\n\n // Convert the Infix tokens to a Postfix notation using the ShuntingYard algorithm\n const postfixResult = getPostfixFromInfix(tokens);\n const { postfixArr } = postfixResult as { postfixArr: string[] };\n\n // Convert the postfix back to infix with parentheses at appropriate places\n // To learn more about the below algorithm, refer this: https://brilliant.org/wiki/shunting-yard-algorithm/#reverse-polish\n const operandsStack: string[] = [];\n postfixArr.forEach(token => {\n if (isIntegerToken(token)) {\n // If it's a numeric token (leaf condition), push it to the stack\n operandsStack.push(token);\n } else if (token === NOT) {\n // If it's the NOT operator\n // Pop an operand, perform the operation and push the result back to the stack\n const operand = operandsStack.pop()!;\n operandsStack.push(`NOT ${operand}`);\n } else {\n // If it's the AND/OR operator\n // Pop two operands, perform the operation and push the result back to the stack\n let operand2 = operandsStack.pop()!;\n let operand1 = operandsStack.pop()!;\n\n // If the inner operation is the same as the current one, consolidate them\n // e.g. `1 AND (2 AND 3)` should be consolidated as `1 AND 2 AND 3`\n // e.g. `1 OR (2 OR 3)` should be consolidated as `1 OR 2 OR 3`\n if (token === 'AND') {\n // Remove any wrapping parentheses if an operand contains just AND(s)\n if (operand1.startsWith(LPAREN) && !operand1.includes(OR) && !operand1.includes(NOT)) {\n operand1 = operand1.slice(1, -1);\n }\n if (operand2.startsWith(LPAREN) && !operand2.includes(OR) && !operand2.includes(NOT)) {\n operand2 = operand2.slice(1, -1);\n }\n operandsStack.push(`(${operand1} AND ${operand2})`);\n } else {\n // Remove any wrapping parentheses if an operand contains just OR(s)\n if (operand1.startsWith(LPAREN) && !operand1.includes(AND) && !operand1.includes(NOT)) {\n operand1 = operand1.slice(1, -1);\n }\n if (operand2.startsWith(LPAREN) && !operand2.includes(AND) && !operand2.includes(NOT)) {\n operand2 = operand2.slice(1, -1);\n }\n operandsStack.push(`(${operand1} OR ${operand2})`);\n }\n }\n });\n\n // If the root node is AND/OR, there will be extra parentheses. Remove them\n let outputLogic = operandsStack[0];\n if (outputLogic.startsWith(LPAREN) && outputLogic.endsWith(RPAREN)) {\n outputLogic = outputLogic.slice(1, -1);\n }\n return outputLogic;\n}\n\n/**\n * Recursively splits the input condition node into a logic-string and a list of condition-rows\n * NOTE: Returns an empty string and an empty array if the condition is malformed\n */\nfunction splitConditionNode(\n node: Condition,\n labelsSoFar: string[]\n): { logic: string; rows: ConditionRow[] } {\n // Using a try-catch block for safety against any malformed conditions\n try {\n let logic: string;\n const rows: ConditionRow[] = [];\n\n if (hasProp(node, 'AND')) {\n const childStrings: string[] = [];\n node.AND.forEach(n => {\n const splitResult = splitConditionNode(n, labelsSoFar); // Recursively get child rows and logic\n childStrings.push(splitResult.logic);\n rows.push(...splitResult.rows);\n });\n logic = `(${childStrings.join(' AND ')})`;\n } else if (hasProp(node, 'OR')) {\n const childStrings: string[] = [];\n node.OR.forEach(n => {\n const splitResult = splitConditionNode(n, labelsSoFar); // Recursively get child rows and logic\n childStrings.push(splitResult.logic);\n rows.push(...splitResult.rows);\n });\n logic = `(${childStrings.join(' OR ')})`;\n } else if (hasProp(node, 'NOT')) {\n const splitResult = splitConditionNode(node.NOT, labelsSoFar); // Recursively get child rows and logic\n logic = `NOT ${splitResult.logic}`;\n rows.push(...splitResult.rows);\n } else {\n // If leaf-level is reached\n const newLabel = `${labelsSoFar.length + 1}`; // Get a new label for the node\n labelsSoFar.push(newLabel); // Update for the next time\n logic = newLabel;\n rows.push({ ...node.condition, label: newLabel, id: createUID() });\n }\n\n return { logic, rows };\n } catch {\n return { logic: '', rows: [] }; // For safety against any malformed conditions\n }\n}\n\n// Splitter for internal consumption\n/** Splits the input condition tree into a logic-string and a list of condition-rows */\nexport function splitConditionForBuilder(tree: Condition): { logic: string; rows: ConditionRow[] } {\n // Recursively split the tree, starting at the root node\n const splitResult = splitConditionNode(tree, []);\n\n // If the root node is AND/OR, there will be extra parentheses. Remove them\n if (splitResult.logic.startsWith(LPAREN) && splitResult.logic.endsWith(RPAREN)) {\n splitResult.logic = splitResult.logic.slice(1, -1);\n }\n\n return splitResult;\n}\n\n// Splitter for public consumption\n/** Converts the input nested condition into a flat tree with the leaf-conditions and a logic string representing the input tree */\nexport function splitConditionTree(\n tree: Condition,\n labelPrefix: string = ''\n): { logic: string; conditions: { [label: string]: LeafCondition } } {\n // Split using the internal splitter\n const { logic, rows } = splitConditionForBuilder(tree);\n\n // Build a condition-lookup from the ConditionRow objects\n const conditionLookup: { [label: string]: LeafCondition } = {};\n rows.forEach(row => {\n const { id, label, ...leaf } = row; // Discard the excess properties set up by ConditionRow when extending LeafCondition interface\n conditionLookup[`${labelPrefix}${label}`] = leaf;\n });\n\n // Prepend labelPrefix to all numeric tokens in the logic\n let outputLogic = logic;\n if (labelPrefix !== '') {\n outputLogic = logic.replace(/\\d+/g, `${labelPrefix}$&`);\n }\n\n return { logic: outputLogic, conditions: conditionLookup };\n}\n\n/** Checks if the input Condition is simple enough to be displayed in the `Basic mode` without loss of information */\nexport function isBasicModeApplicable(condition: Condition): boolean {\n // If an OR condition is present at the outer level,\n // each child should either be a leaf condition or an AND with all leaf nodes inside\n if (hasProp(condition, 'OR')) {\n return condition.OR.every(node => {\n if (hasProp(node, 'condition')) {\n return true;\n }\n if (hasProp(node, 'AND')) {\n return node.AND.every(subNode => hasProp(subNode, 'condition'));\n }\n return false;\n });\n }\n // If an AND condition is present at the outer level, it can't have any nested levels\n if (hasProp(condition, 'AND')) {\n return condition.AND.every(node => hasProp(node, 'condition'));\n }\n // NOT operator is not supported in Basic-mode\n // eslint-disable-next-line sonarjs/prefer-single-boolean-return\n if (hasProp(condition, 'NOT')) {\n return false;\n }\n // If a single leaf condition is present at the outer level\n return true;\n}\n\n/** Returns a list of operators to show in the Basic mode, using a logicString as the input */\nexport function getBasicModeOperators(logic: string): ('AND' | 'OR')[] {\n const matches = logic.match(/(AND|OR)/g);\n if (matches === null) {\n return [];\n }\n return matches as ('AND' | 'OR')[];\n}\n\n/** Takes a list of operators from between the Basic mode rows and constructs a logic-string out of them */\nexport function getLogicFromBasicMode(operatorsList: ('AND' | 'OR')[]): string {\n const logicString = operatorsList.reduce((logic, op, i) => `${logic} ${op} ${i + 2}`, '1');\n return disambiguateLogic(logicString); // Disambiguating the logic string by placing parentheses at appropriate places\n}\n\n/** Takes a list of objects and id of the object to be found and recursively finds and returns the object */\nexport function getItem(items: Field[], id: string): Field | undefined {\n let found: Field | undefined;\n items.some(item => {\n if (item.id === id) {\n found = item;\n return true;\n }\n\n if (hasProp(item, 'items')) {\n found = getItem(item.items, id);\n return !!found;\n }\n\n return false;\n });\n\n return found;\n}\n\n// matches a ISO 8601 datetime with a timezone, it MUST have a timezone\n// used in below function\nconst isoDateWithTimezoneRegex =\n /^-?\\d{4,}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d{1,3})?)?(([+-])\\d{2}(:)?\\d{2}|Z)$/;\n\n/**\n * Checks whether given datetime string is absolute or relative\n * @param str - datetime string\n * @returns - true(if the timezone component is present) or false(if no timezone is present or if format is invalid)\n */\nexport function isAbsoluteDateString(str: string) {\n return isoDateWithTimezoneRegex.test(str);\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/core/utils.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAS7D,MAAM,GAAG,GAAG,KAAK,CAAC;AAClB,MAAM,EAAE,GAAG,IAAI,CAAC;AAChB,MAAM,GAAG,GAAG,KAAK,CAAC;AAClB,MAAM,MAAM,GAAG,GAAG,CAAC;AACnB,MAAM,MAAM,GAAG,GAAG,CAAC;AAEnB,MAAM,aAAa,GAA6B,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,sEAAsE;AACjJ,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,0BAA0B;AAC1E,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,6CAA6C;AAE1G,MAAM,cAAc,GAAG,CAAC,KAAa,EAAW,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,0CAA0C;AAClH,MAAM,eAAe,GAAG,CAAC,KAAa,EAAW,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,2CAA2C;AAE1H;;;;G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EAAE,CAAC,GAAG,KAAK,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAC3F,OAAO,iBAAiB,CAAC,WAAW,CAAC,CAAC,CAAC,+EAA+E;AACxH,CAAC;AAED,4GAA4G;AAC5G,MAAM,UAAU,OAAO,CAAC,KAAc,EAAE,EAAU;IAChD,IAAI,KAAwB,CAAC;IAC7B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAChB,IAAI,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;YACnB,KAAK,GAAG,IAAI,CAAC;YACb,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;YAC3B,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAChC,OAAO,CAAC,CAAC,KAAK,CAAC;QACjB,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC;AAED,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,wBAAwB,GAC5B,iFAAiF,CAAC;AAEpF;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,OAAO,wBAAwB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["// cspell:words LPAREN LPARENs RPAREN RPARENs\nimport { createUID, hasProp } from '@pega/cosmos-react-core';\nimport type { TranslationPack } from '@pega/cosmos-react-core';\n\nimport type { Condition, ConditionRow, LeafCondition, Field } from '../ConditionBuilder.types';\n\ntype ConditionBuilderTranslationKey = Extract<keyof TranslationPack, `condition_builder_${string}`>;\n\nexport type ConditionBuilderParseError = [key: ConditionBuilderTranslationKey, tokens: string[]];\n\nconst AND = 'AND';\nconst OR = 'OR';\nconst NOT = 'NOT';\nconst LPAREN = '(';\nconst RPAREN = ')';\n\nconst precedenceMap: { [op: string]: number } = { OR: 1, AND: 2, NOT: 3 }; // Operator precedence. NOT has the highest precedence over the others\nconst operatorTokens = new Set([AND, OR, NOT]); // Valid logical operators\nconst validTokens = new Set([AND, OR, NOT, LPAREN, RPAREN]); // Other than these, integer tokens are valid\n\nconst isIntegerToken = (token: string): boolean => /^\\d+$/.test(token); // Checks if the input token is an integer\nconst isOperatorToken = (token: string): boolean => operatorTokens.has(token); // Checks if the input token is an operator\n\n/**\n * Tokenize the input expression.\n * Valid tokens are 'AND', 'OR', 'NOT', '(', ')' and any integer token.\n * Throws an error if an invalid token is found.\n */\nfunction tokenizeExpression(\n expression: string,\n disallowNOT: boolean = false\n): { tokens: string[] } | { error: ConditionBuilderParseError } {\n expression = expression.trim().toUpperCase(); // To simplify comparisons below; the tokens AND/OR/NOT are anyways expected to be in uppercase\n const words = expression.match(/[A-Z]+|[0-9]+|_|\\W/g); // Split contiguous alphabets and contiguous numbers into the same token. For all other characters, create a token for each character. Although `_` is not expected to be used, handling it just for completeness\n const tokens: string[] = []; // Final list of valid tokens\n const invalidWords: string[] = []; // Any invalid words are captured here\n\n // `words` will never be null because of the regex we used. Using `!` to indicate the same to TS\n words!.forEach(word => {\n // Ignore white-space characters\n if (word.trim().length > 0) {\n // If it's a token from the above Set or if it's an integer token\n if (isIntegerToken(word) || (validTokens.has(word) && !(word === NOT && disallowNOT))) {\n tokens.push(word);\n } else {\n invalidWords.push(word);\n }\n }\n });\n\n // Return an error if any invalid tokens are present\n if (invalidWords.length > 0) {\n return {\n error: ['condition_builder_unexpected_words_or_characters', [invalidWords.join(' ')]]\n };\n }\n\n return { tokens };\n}\n\n/**\n * Captures any invalid/unexpected token patterns\n * NOTE: This does not expect any invalid tokens to be passed in the input\n * NOTE: This doesn't handle mismatched parentheses. That is handled separately in getPostfixFromInfix\n * Returns an error message about the first invalid sequence present in the input. Returns `null` if none found\n */\nfunction findInvalidPatterns(tokens: string[]): ConditionBuilderParseError | null {\n // These patterns are identified based on which token can precede/succeed which.\n // A table with all such permutations can be found in DOC-38200\n\n for (let i = 0; i < tokens.length; i += 1) {\n const NUMBER = 'NUMBER'; // To avoid repeating a string literal\n const token = tokens[i];\n const tokenType = isIntegerToken(token) ? NUMBER : token; // To simplify comparisons below\n\n // The expression can only start with NOT, LPAREN or NUMBER\n if (i === 0 && ![NOT, LPAREN, NUMBER].includes(tokenType)) {\n return ['condition_builder_unexpected_token_at_the_beginning', [token]];\n }\n\n // The expression can only end with RPAREN or NUMBER\n if (i === tokens.length - 1 && ![RPAREN, NUMBER].includes(tokenType)) {\n return ['condition_builder_unexpected_token_at_the_end', [token]];\n }\n\n // If there is a previous token, check if it is supposed to precede the current token\n if (i > 0) {\n const prevToken = tokens[i - 1];\n const prevTokenType = isIntegerToken(prevToken) ? NUMBER : prevToken; // To simplify comparisons below\n switch (tokenType) {\n // AND/OR/RPAREN can only be preceded by RPAREN or NUMBER\n case AND:\n case OR:\n case RPAREN:\n if (![RPAREN, NUMBER].includes(prevTokenType)) {\n return ['condition_builder_unexpected_token_after_previous_token', [token, prevToken]];\n }\n break;\n\n // NOT/LPAREN/NUMBER can not be preceded by RPAREN or NUMBER\n case NOT:\n case LPAREN:\n case NUMBER:\n if ([RPAREN, NUMBER].includes(prevTokenType)) {\n return ['condition_builder_unexpected_token_after_previous_token', [token, prevToken]];\n }\n break;\n default: // do nothing\n }\n }\n }\n\n // Return null if no invalid sequences\n return null;\n}\n\n/**\n * Converts an input array of Infix tokens into a Postfix array.\n * Uses the ShuntingYard algorithm.\n * NOTE: This does not expect any invalid tokens to be passed in the input\n */\nfunction getPostfixFromInfix(\n tokens: string[]\n): { postfixArr: string[] } | { error: ConditionBuilderParseError } {\n // Refer these for the ShuntingYard algorithm:\n // * https://brilliant.org/wiki/shunting-yard-algorithm/\n // * https://en.wikipedia.org/wiki/Shunting-yard_algorithm#The_algorithm_in_detail\n const postfixQueue: string[] = []; // Output queue\n const stack: string[] = []; // Operations stack\n\n // While there are tokens to be read\n for (let i = 0; i < tokens.length; i += 1) {\n const token = tokens[i];\n\n if (isIntegerToken(token)) {\n // If it's a number add it to queue\n postfixQueue.push(token);\n } else if (isOperatorToken(token)) {\n // If it's an operator\n // While there's an operator on the top of the stack with greater precedence (or equal precedence and the token is left-associative), pop operators from the stack onto the output queue\n if (token !== NOT) {\n // Unary operators should not cause any operators to be popped from the stack.\n // See http://wcipeg.com/wiki/Shunting_yard_algorithm#Unary_operators\n while (stack.length > 0) {\n const stackTop = stack[stack.length - 1];\n if (isOperatorToken(stackTop) && precedenceMap[stackTop] >= precedenceMap[token]) {\n postfixQueue.push(stack.pop()!);\n } else {\n break;\n }\n }\n }\n // Push the current operator onto the stack\n stack.push(token);\n } else if (token === LPAREN) {\n // If it's a left parenthesis, push it onto the stack\n stack.push(token);\n } else {\n // If it's a right parenthesis (RPAREN)\n // While there's not a left parenthesis at the top of the stack, pop operators from the stack onto the output queue\n while (stack.length > 0) {\n const stackTop = stack[stack.length - 1];\n if (stackTop === LPAREN) break;\n postfixQueue.push(stack.pop()!);\n }\n\n // Pop the left parenthesis from the stack and discard it\n if (stack.length > 0) {\n stack.pop();\n } else {\n return {\n error: ['condition_builder_mismatched_parentheses', []]\n }; // If no LPAREN found for the current RPAREN\n }\n }\n }\n\n // While there are operators on the stack, pop them to the queue\n while (stack.length > 0) {\n if (stack[stack.length - 1] === LPAREN) {\n return {\n error: ['condition_builder_mismatched_parentheses', []]\n }; // If there were excess LPARENs. (Excess RPARENs are already handled in the above loop. Also, RPARENs are never pushed to the stack)\n }\n postfixQueue.push(stack.pop()!);\n }\n\n return { postfixArr: postfixQueue };\n}\n\n/**\n * Converts an input array of Postfix tokens into a Condition tree.\n * NOTE: This expects a properly formed Postfix array as input\n */\nfunction getConditionFromPostfix(\n postfixArr: string[],\n conditionLookup: { [label: string]: LeafCondition },\n ignoreUnusedLabels: boolean\n): { condition: Condition } | { error: ConditionBuilderParseError } {\n // To learn more about the below algorithm, refer this: https://brilliant.org/wiki/shunting-yard-algorithm/#reverse-polish\n const operandsStack: Condition[] = [];\n const labelsWithNoRows: string[] = []; // Labels for which there is no corresponding op in conditionLookup\n const usedLabels: string[] = []; // A list of all labels used in the condition. This is used to warn about any unused operations\n postfixArr.forEach(token => {\n if (isIntegerToken(token)) {\n // If it's a numeric token (leaf condition), push it to the stack\n const conditionRow = conditionLookup[token]; // Identify the corresponding condition row\n operandsStack.push({ condition: conditionRow }); // Push it even if null so that the conversion goes on smoothly and identifies any other issues\n if (!conditionRow) {\n labelsWithNoRows.push(token); // Mark it as missing\n } else {\n usedLabels.push(token); // Mark it as used\n }\n } else if (token === NOT) {\n // If it's the NOT operator\n // Pop an operand, perform the operation and push the result back to the stack\n const operand = operandsStack.pop()!;\n operandsStack.push({ NOT: operand });\n } else {\n // If it's the AND/OR operator\n // Pop two operands, perform the operation and push the result back to the stack\n const operand2 = operandsStack.pop()!;\n const operand1 = operandsStack.pop()!;\n\n // If the inner operation is the same as the current one, consolidate them\n // e.g. `1 AND (2 AND 3)` should be consolidated as `1 AND 2 AND 3`\n // e.g. `1 OR (2 OR 3)` should be consolidated as `1 OR 2 OR 3`\n if (token === 'AND') {\n const operands = [\n ...(hasProp(operand1, 'AND') ? operand1.AND : [operand1]),\n ...(hasProp(operand2, 'AND') ? operand2.AND : [operand2])\n ];\n operandsStack.push({ AND: operands });\n } else {\n const operands = [\n ...(hasProp(operand1, 'OR') ? operand1.OR : [operand1]),\n ...(hasProp(operand2, 'OR') ? operand2.OR : [operand2])\n ];\n operandsStack.push({ OR: operands });\n }\n }\n });\n\n // If any labels are used for which there are no corresponding condition-rows\n if (labelsWithNoRows.length > 0) {\n if (labelsWithNoRows.length === 1) {\n return {\n error: ['condition_builder_undefined_condition_in_logical_string', [labelsWithNoRows[0]]]\n };\n }\n return {\n error: [\n 'condition_builder_undefined_conditions_in_logical_string',\n [labelsWithNoRows.join(', ')]\n ]\n };\n }\n\n // Warn if any of the condition rows are unused\n if (!ignoreUnusedLabels) {\n const unusedLabels = Object.keys(conditionLookup).filter(l => !usedLabels.includes(l));\n if (unusedLabels.length > 0) {\n if (unusedLabels.length === 1) {\n return {\n error: ['condition_builder_unused_condition_in_logical_string', [unusedLabels[0]]]\n };\n }\n return {\n error: ['condition_builder_unused_conditions_in_logical_string', [unusedLabels.join(', ')]]\n };\n }\n }\n\n return { condition: operandsStack[0] };\n}\n\n/** Parses a logic-expression into a condition object. */\nexport function parseLogicString(\n expression: string,\n conditionLookup: { [label: string]: LeafCondition }, // To look up condition-rows from the labels\n disallowNOT: boolean = false,\n ignoreUnusedLabels: boolean = false\n): { condition: Condition } | { error: ConditionBuilderParseError } {\n // Handle empty expressions\n if (!expression.trim().length)\n return {\n error: ['condition_builder_please_provide_a_logic_expression', []]\n };\n\n // Split the expression into individual tokens\n const tokeningResult = tokenizeExpression(expression, disallowNOT);\n if (hasProp(tokeningResult, 'error')) return tokeningResult;\n const { tokens } = tokeningResult;\n\n // Capture any invalid/unexpected token patterns\n // NOTE: This doesn't handle mismatched parentheses. That is handled below in getPostfixFromInfix\n const badPatternError = findInvalidPatterns(tokens);\n if (badPatternError !== null) return { error: badPatternError };\n\n // Convert the Infix tokens to a Postfix notation using the ShuntingYard algorithm\n const postfixResult = getPostfixFromInfix(tokens);\n if (hasProp(postfixResult, 'error')) return postfixResult;\n const { postfixArr } = postfixResult;\n\n // Convert the Postfix token to a Condition tree\n return getConditionFromPostfix(postfixArr, conditionLookup, ignoreUnusedLabels);\n}\n\n/**\n * Takes a valid logic string and formats it with parentheses at appropriate places to keep things unambiguous\n * For example, `1 AND 2 OR 3` is disambiguated as `(1 AND 2) OR 3`\n * NOTE: This expects only valid logic strings to be passed as an input\n */\nexport function disambiguateLogic(expression: string): string {\n // Split the expression into individual tokens\n const tokeningResult = tokenizeExpression(expression);\n const { tokens } = tokeningResult as { tokens: string[] }; // Only valid expressions are expected as inputs\n\n // Convert the Infix tokens to a Postfix notation using the ShuntingYard algorithm\n const postfixResult = getPostfixFromInfix(tokens);\n const { postfixArr } = postfixResult as { postfixArr: string[] };\n\n // Convert the postfix back to infix with parentheses at appropriate places\n // To learn more about the below algorithm, refer this: https://brilliant.org/wiki/shunting-yard-algorithm/#reverse-polish\n const operandsStack: string[] = [];\n postfixArr.forEach(token => {\n if (isIntegerToken(token)) {\n // If it's a numeric token (leaf condition), push it to the stack\n operandsStack.push(token);\n } else if (token === NOT) {\n // If it's the NOT operator\n // Pop an operand, perform the operation and push the result back to the stack\n const operand = operandsStack.pop()!;\n operandsStack.push(`NOT ${operand}`);\n } else {\n // If it's the AND/OR operator\n // Pop two operands, perform the operation and push the result back to the stack\n let operand2 = operandsStack.pop()!;\n let operand1 = operandsStack.pop()!;\n\n // If the inner operation is the same as the current one, consolidate them\n // e.g. `1 AND (2 AND 3)` should be consolidated as `1 AND 2 AND 3`\n // e.g. `1 OR (2 OR 3)` should be consolidated as `1 OR 2 OR 3`\n if (token === 'AND') {\n // Remove any wrapping parentheses if an operand contains just AND(s)\n if (operand1.startsWith(LPAREN) && !operand1.includes(OR) && !operand1.includes(NOT)) {\n operand1 = operand1.slice(1, -1);\n }\n if (operand2.startsWith(LPAREN) && !operand2.includes(OR) && !operand2.includes(NOT)) {\n operand2 = operand2.slice(1, -1);\n }\n operandsStack.push(`(${operand1} AND ${operand2})`);\n } else {\n // Remove any wrapping parentheses if an operand contains just OR(s)\n if (operand1.startsWith(LPAREN) && !operand1.includes(AND) && !operand1.includes(NOT)) {\n operand1 = operand1.slice(1, -1);\n }\n if (operand2.startsWith(LPAREN) && !operand2.includes(AND) && !operand2.includes(NOT)) {\n operand2 = operand2.slice(1, -1);\n }\n operandsStack.push(`(${operand1} OR ${operand2})`);\n }\n }\n });\n\n // If the root node is AND/OR, there will be extra parentheses. Remove them\n let outputLogic = operandsStack[0];\n if (outputLogic.startsWith(LPAREN) && outputLogic.endsWith(RPAREN)) {\n outputLogic = outputLogic.slice(1, -1);\n }\n return outputLogic;\n}\n\n/**\n * Recursively splits the input condition node into a logic-string and a list of condition-rows\n * NOTE: Returns an empty string and an empty array if the condition is malformed\n */\nfunction splitConditionNode(\n node: Condition,\n labelsSoFar: string[]\n): { logic: string; rows: ConditionRow[] } {\n // Using a try-catch block for safety against any malformed conditions\n try {\n let logic: string;\n const rows: ConditionRow[] = [];\n\n if (hasProp(node, 'AND')) {\n const childStrings: string[] = [];\n node.AND.forEach(n => {\n const splitResult = splitConditionNode(n, labelsSoFar); // Recursively get child rows and logic\n childStrings.push(splitResult.logic);\n rows.push(...splitResult.rows);\n });\n logic = `(${childStrings.join(' AND ')})`;\n } else if (hasProp(node, 'OR')) {\n const childStrings: string[] = [];\n node.OR.forEach(n => {\n const splitResult = splitConditionNode(n, labelsSoFar); // Recursively get child rows and logic\n childStrings.push(splitResult.logic);\n rows.push(...splitResult.rows);\n });\n logic = `(${childStrings.join(' OR ')})`;\n } else if (hasProp(node, 'NOT')) {\n const splitResult = splitConditionNode(node.NOT, labelsSoFar); // Recursively get child rows and logic\n logic = `NOT ${splitResult.logic}`;\n rows.push(...splitResult.rows);\n } else {\n // If leaf-level is reached\n const newLabel = `${labelsSoFar.length + 1}`; // Get a new label for the node\n labelsSoFar.push(newLabel); // Update for the next time\n logic = newLabel;\n rows.push({ ...node.condition, label: newLabel, id: createUID() });\n }\n\n return { logic, rows };\n } catch {\n return { logic: '', rows: [] }; // For safety against any malformed conditions\n }\n}\n\n// Splitter for internal consumption\n/** Splits the input condition tree into a logic-string and a list of condition-rows */\nexport function splitConditionForBuilder(tree: Condition): { logic: string; rows: ConditionRow[] } {\n // Recursively split the tree, starting at the root node\n const splitResult = splitConditionNode(tree, []);\n\n // If the root node is AND/OR, there will be extra parentheses. Remove them\n if (splitResult.logic.startsWith(LPAREN) && splitResult.logic.endsWith(RPAREN)) {\n splitResult.logic = splitResult.logic.slice(1, -1);\n }\n\n return splitResult;\n}\n\n// Splitter for public consumption\n/** Converts the input nested condition into a flat tree with the leaf-conditions and a logic string representing the input tree */\nexport function splitConditionTree(\n tree: Condition,\n labelPrefix: string = ''\n): { logic: string; conditions: { [label: string]: LeafCondition } } {\n // Split using the internal splitter\n const { logic, rows } = splitConditionForBuilder(tree);\n\n // Build a condition-lookup from the ConditionRow objects\n const conditionLookup: { [label: string]: LeafCondition } = {};\n rows.forEach(row => {\n const { id, label, ...leaf } = row; // Discard the excess properties set up by ConditionRow when extending LeafCondition interface\n conditionLookup[`${labelPrefix}${label}`] = leaf;\n });\n\n // Prepend labelPrefix to all numeric tokens in the logic\n let outputLogic = logic;\n if (labelPrefix !== '') {\n outputLogic = logic.replace(/\\d+/g, `${labelPrefix}$&`);\n }\n\n return { logic: outputLogic, conditions: conditionLookup };\n}\n\n/** Checks if the input Condition is simple enough to be displayed in the `Basic mode` without loss of information */\nexport function isBasicModeApplicable(condition: Condition): boolean {\n // If an OR condition is present at the outer level,\n // each child should either be a leaf condition or an AND with all leaf nodes inside\n if (hasProp(condition, 'OR')) {\n return condition.OR.every(node => {\n if (hasProp(node, 'condition')) {\n return true;\n }\n if (hasProp(node, 'AND')) {\n return node.AND.every(subNode => hasProp(subNode, 'condition'));\n }\n return false;\n });\n }\n // If an AND condition is present at the outer level, it can't have any nested levels\n if (hasProp(condition, 'AND')) {\n return condition.AND.every(node => hasProp(node, 'condition'));\n }\n // NOT operator is not supported in Basic-mode\n // eslint-disable-next-line sonarjs/prefer-single-boolean-return\n if (hasProp(condition, 'NOT')) {\n return false;\n }\n // If a single leaf condition is present at the outer level\n return true;\n}\n\n/** Returns a list of operators to show in the Basic mode, using a logicString as the input */\nexport function getBasicModeOperators(logic: string): ('AND' | 'OR')[] {\n const matches = logic.match(/(AND|OR)/g);\n if (matches === null) {\n return [];\n }\n return matches as ('AND' | 'OR')[];\n}\n\n/** Takes a list of operators from between the Basic mode rows and constructs a logic-string out of them */\nexport function getLogicFromBasicMode(operatorsList: ('AND' | 'OR')[]): string {\n const logicString = operatorsList.reduce((logic, op, i) => `${logic} ${op} ${i + 2}`, '1');\n return disambiguateLogic(logicString); // Disambiguating the logic string by placing parentheses at appropriate places\n}\n\n/** Takes a list of objects and id of the object to be found and recursively finds and returns the object */\nexport function getItem(items: Field[], id: string): Field | undefined {\n let found: Field | undefined;\n items.some(item => {\n if (item.id === id) {\n found = item;\n return true;\n }\n\n if (hasProp(item, 'items')) {\n found = getItem(item.items, id);\n return !!found;\n }\n\n return false;\n });\n\n return found;\n}\n\n// matches a ISO 8601 datetime with a timezone, it MUST have a timezone\n// used in below function\nconst isoDateWithTimezoneRegex =\n /^-?\\d{4,}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d{1,3})?)?(([+-])\\d{2}(:)?\\d{2}|Z)$/;\n\n/**\n * Checks whether given datetime string is absolute or relative\n * @param str - datetime string\n * @returns - true(if the timezone component is present) or false(if no timezone is present or if format is invalid)\n */\nexport function isAbsoluteDateString(str: string) {\n return isoDateWithTimezoneRegex.test(str);\n}\n"]}
@@ -7,6 +7,7 @@ export { default as formatCondition, formatRelativeDate } from './core/formatter
7
7
  export { default as transformComplexCondition } from './core/transformer';
8
8
  export type { ComparatorsByType, RHSType, FieldType, Comparator } from './core/types';
9
9
  export { splitConditionTree, parseLogicString } from './core/utils';
10
+ export type { ConditionBuilderParseError } from './core/utils';
10
11
  export { default as AtomicCondition, getInitConditionForLhs, isValidCondition } from './AtomicCondition';
11
12
  export type { AtomicConditionProps } from './AtomicCondition';
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,YAAY,EACV,OAAO,IAAI,qBAAqB,EAChC,SAAS,EACT,mBAAmB,EACnB,KAAK,EACL,aAAa,EACb,cAAc,EACf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,OAAO,IAAI,mBAAmB,EAAE,M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,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACpE,YAAY,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EACL,OAAO,IAAI,eAAe,EAC1B,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAS7C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE1E,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EACL,OAAO,IAAI,eAAe,EAC1B,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC","sourcesContent":["export { default } from './ConditionBuilder';\nexport type {\n default as ConditionBuilderProps,\n Condition,\n DateFunctionsByType,\n Field,\n LeafCondition,\n ValueSelection\n} from './ConditionBuilder.types';\nexport { default as FieldCondition } from './FieldCondition';\nexport type { default as FieldConditionProps } from './FieldCondition.types';\nexport { default as evaluateCondition } from './core/evaluator';\nexport { default as formatCondition, formatRelativeDate } from './core/formatter';\nexport { default as transformComplexCondition } from './core/transformer';\nexport type { ComparatorsByType, RHSType, FieldType, Comparator } from './core/types';\nexport { splitConditionTree, parseLogicString } from './core/utils';\nexport {\n default as AtomicCondition,\n getInitConditionForLhs,\n isValidCondition\n} from './AtomicCondition';\nexport type { AtomicConditionProps } from './AtomicCondition';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAS7C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE1E,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEpE,OAAO,EACL,OAAO,IAAI,eAAe,EAC1B,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC","sourcesContent":["export { default } from './ConditionBuilder';\nexport type {\n default as ConditionBuilderProps,\n Condition,\n DateFunctionsByType,\n Field,\n LeafCondition,\n ValueSelection\n} from './ConditionBuilder.types';\nexport { default as FieldCondition } from './FieldCondition';\nexport type { default as FieldConditionProps } from './FieldCondition.types';\nexport { default as evaluateCondition } from './core/evaluator';\nexport { default as formatCondition, formatRelativeDate } from './core/formatter';\nexport { default as transformComplexCondition } from './core/transformer';\nexport type { ComparatorsByType, RHSType, FieldType, Comparator } from './core/types';\nexport { splitConditionTree, parseLogicString } from './core/utils';\nexport type { ConditionBuilderParseError } from './core/utils';\nexport {\n default as AtomicCondition,\n getInitConditionForLhs,\n isValidCondition\n} from './AtomicCondition';\nexport type { AtomicConditionProps } from './AtomicCondition';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-condition-builder",
3
- "version": "10.0.0-build.3.1",
3
+ "version": "10.0.0-build.4.0",
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": "10.0.0-build.3.1",
20
+ "@pega/cosmos-react-core": "10.0.0-build.4.0",
21
21
  "@types/react": "^17.0.62 || ^18.3.3",
22
22
  "@types/react-dom": "^17.0.20 || ^18.3.0",
23
23
  "dayjs": "^1.11.13",