@pega/cosmos-react-condition-builder 9.0.0-build.9.1 → 9.0.0-build.9.11

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.
Files changed (23) hide show
  1. package/lib/components/ConditionBuilder/AtomicCondition.d.ts +2 -0
  2. package/lib/components/ConditionBuilder/AtomicCondition.d.ts.map +1 -1
  3. package/lib/components/ConditionBuilder/AtomicCondition.js.map +1 -1
  4. package/lib/components/ConditionBuilder/ConditionBuilder.d.ts +2 -3
  5. package/lib/components/ConditionBuilder/ConditionBuilder.d.ts.map +1 -1
  6. package/lib/components/ConditionBuilder/ConditionBuilder.js +32 -21
  7. package/lib/components/ConditionBuilder/ConditionBuilder.js.map +1 -1
  8. package/lib/components/ConditionBuilder/ConditionBuilder.styles.d.ts +2 -1
  9. package/lib/components/ConditionBuilder/ConditionBuilder.styles.d.ts.map +1 -1
  10. package/lib/components/ConditionBuilder/ConditionBuilder.styles.js.map +1 -1
  11. package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts +27 -2
  12. package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts.map +1 -1
  13. package/lib/components/ConditionBuilder/ConditionBuilder.types.js.map +1 -1
  14. package/lib/components/ConditionBuilder/core/transformer.d.ts +1 -1
  15. package/lib/components/ConditionBuilder/core/transformer.d.ts.map +1 -1
  16. package/lib/components/ConditionBuilder/core/transformer.js +7 -7
  17. package/lib/components/ConditionBuilder/core/transformer.js.map +1 -1
  18. package/lib/components/ConditionBuilder/index.d.ts +2 -1
  19. package/lib/components/ConditionBuilder/index.d.ts.map +1 -1
  20. package/lib/components/ConditionBuilder/index.js.map +1 -1
  21. package/lib/components/ConditionInput/ConditionInput.styles.d.ts +1 -1
  22. package/lib/components/ConditionInput/ConditionInput.styles.d.ts.map +1 -1
  23. package/package.json +2 -2
@@ -15,6 +15,8 @@ export declare function isValidCondition(condition: LeafCondition, fields: Field
15
15
  export interface AtomicConditionProps extends BaseProps {
16
16
  /** Condition to use in the component */
17
17
  condition: LeafCondition;
18
+ /** (Optional) Index of the condition. Used when rendering multiple conditions */
19
+ index?: number;
18
20
  /** Metadata (data-model) for the Fields to use in the Condition */
19
21
  fields: Field[];
20
22
  /** Used to enable inline error indicators on invalid inputs */
@@ -1 +1 @@
1
- {"version":3,"file":"AtomicCondition.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/AtomicCondition.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAe,GAAG,EAAmB,MAAM,OAAO,CAAC;AAY/D,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,+BAA+B,EAChC,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAI1F,OAAO,KAAK,EAAc,iBAAiB,EAAa,OAAO,EAAE,MAAM,cAAc,CAAC;AAoDtF,oEAAoE;AACpE,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,aAAa,CAAC,KAAK,CAAC,EACzB,MAAM,EAAE,KAAK,EAAE,EACf,aAAa,EAAE,GAAG,CAAC,OAAO,CAAC,EAC3B,gBAAgB,CAAC,EAAE,iBAAiB,EAAE,EACtC,aAAa,CAAC,EAAE,mBAAmB,GAClC,aAAa,CAcf;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,aAAa,EACxB,MAAM,EAAE,KAAK,EAAE,EACf,UAAU,GAAE,OAAe,GAC1B,OAAO,CAST;AAED,6DAA6D;AAC7D,MAAM,WAAW,oBAAqB,SAAQ,SAAS;IACrD,wCAAwC;IACxC,SAAS,EAAE,aAAa,CAAC;IAEzB,mEAAmE;IACnE,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB,+DAA+D;IAC/D,cAAc,EAAE,OAAO,CAAC;IAExB,gFAAgF;IAChF,gBAAgB,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAEvC,sDAAsD;IACtD,QAA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AAoB,CAwL1E,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"AtomicCondition.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/AtomicCondition.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAG1E,OAAO,EACL,IAAI,EACJ,MAAM,EACN,MAAM,EACN,OAAO,EACP,OAAO,EACP,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACtB,MAAM,yBAAyB,CAAC;AAOjC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,aAAa,MAAM,6BAA6B,CAAC;AACxD,OAAO,WAAW,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,oBAAoB,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,4CAA4C;AAC5C,SAAS,YAAY,CAAC,SAAiB,EAAE,MAAe;IACtD,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACjD,OAAO,aAAa,IAAI,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1F,CAAC;AAED,+CAA+C;AAC/C,SAAS,aAAa,CAAC,SAAiB,EAAE,MAAe;IACvD,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACjD,OAAO,aAAa,EAAE,OAAO,CAAC;AAChC,CAAC;AAED;;;GAGG;AACH,SAAS,uBAAuB,CAAC,GAAyB,EAAE,UAAsB;IAChF,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,CAAC,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,CAA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C,KAAK,KAAK,EAAE;wBACtC,CAAC,CAAC,CAAC,CAAC,iDAAiD,CAAC;wBACtD,CAAC,CAAC,SAAS,GAEf,CACH,EAGD,KAAC,MAAM,IACL,KAAK,EAAE,KAAK,CAAC,UAAU,EACvB,QAAQ,EAAE,sBAAsB,EAChC,IAAI,EAAC,YAAY,EACjB,KAAK,EAAE,CAAC,CAAC,oCAAoC,CAAC,YAE7C,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAC/B,KAAC,MAAM,IAAiB,KAAK,EAAE,MAAM,CAAC,EAAE,YACrC,MAAM,CAAC,KAAK,IADF,MAAM,CAAC,EAAE,CAEb,CACV,CAAC,GACK,EAGT,KAAC,WAAW,IACV,GAAG,EAAE,KAAK,CAAC,GAAG,EACd,UAAU,EAAE,KAAK,CAAC,UAAU,EAC5B,GAAG,EAAE,KAAK,CAAC,GAAG,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,eAAe,EACzB,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,IAAI,KAAK,EACrC,MAAM,EAAE,SAAS,GACjB,IACG,GACe,CACzB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { forwardRef, useRef, useState, useImperativeHandle } from 'react';\nimport type { ChangeEvent, Ref, PropsWithoutRef } from 'react';\n\nimport {\n Grid,\n Select,\n Option,\n useI18n,\n hasProp,\n useConsolidatedRef,\n useFocusWithin,\n useAfterInitialEffect\n} from '@pega/cosmos-react-core';\nimport type {\n BaseProps,\n HandleValue,\n ForwardRefForwardPropsComponent\n} from '@pega/cosmos-react-core';\n\nimport { getItem } from './core/utils';\nimport type { LeafCondition, Field, DateFunctionsByType } from './ConditionBuilder.types';\nimport FieldSelector from './RhsControls/FieldSelector';\nimport RhsControls, { getDefaultRhs, isValidRhs } from './RhsControls';\nimport getComparatorOptions from './core/comparators';\nimport type { Comparator, ComparatorsByType, FieldType, RHSType } from './core/types';\nimport { StyledAtomicCondition } from './ConditionBuilder.styles';\n\n// Returns field-type for a given field-name\nfunction getFieldType(fieldName: string, fields: Field[]): FieldType | undefined {\n const matchingField = getItem(fields, fieldName);\n return matchingField && hasProp(matchingField, 'type') ? matchingField.type : undefined;\n}\n\n// Returns display label for a given field-name\nfunction getFieldLabel(fieldName: string, fields: Field[]): string | undefined {\n const matchingField = getItem(fields, fieldName);\n return matchingField?.primary;\n}\n\n/**\n * Upon changing the comparator, checks if the old RHS is valid for the new comparator\n * NOTE: This works under the assumption that the LHS doesn't change\n */\nfunction isRhsValidForComparator(rhs: LeafCondition['rhs'], comparator: Comparator): boolean {\n if (rhs === undefined) {\n return ['IS_NULL', 'IS_NOT_NULL', 'IS_TRUE', 'IS_FALSE'].includes(comparator);\n }\n if (hasProp(rhs, 'values')) {\n return ['IN', 'NOT_IN'].includes(comparator);\n }\n\n if (hasProp(rhs, 'parameterId')) {\n return ['EQ', 'NEQ'].includes(comparator);\n }\n\n if (hasProp(rhs, 'start')) {\n return ['BTW', 'NOT_BTW'].includes(comparator);\n }\n\n // `rhs.field` and `rhs.value` cases\n return [\n 'EQ',\n 'NEQ',\n 'GT',\n 'GTE',\n 'LT',\n 'LTE',\n 'STARTS_WITH',\n 'NOT_STARTS_WITH',\n 'ENDS_WITH',\n 'NOT_ENDS_WITH',\n 'CONTAINS',\n 'NOT_CONTAINS'\n ].includes(comparator);\n}\n\n/** Determines the default condition object for a given LHS value */\nexport function getInitConditionForLhs(\n lhs: LeafCondition['lhs'],\n fields: Field[],\n validRhsTypes: Set<RHSType>,\n validComparators?: ComparatorsByType[],\n dateFunctions?: DateFunctionsByType\n): LeafCondition {\n let comparator: Comparator;\n let rhs: LeafCondition['rhs'];\n if (lhs.field === '') {\n // If the empty option is selected, reset the comparator and rhs to their default values\n comparator = 'IS_NOT_NULL';\n rhs = undefined;\n } else {\n const newFieldType = getFieldType(lhs.field, fields) as FieldType;\n comparator = getComparatorOptions(newFieldType, validComparators)[0].id; // Find the applicable comparators and select the first among them\n rhs = getDefaultRhs(newFieldType, comparator, validRhsTypes, dateFunctions);\n }\n\n return { lhs, comparator, rhs };\n}\n\n/**\n * Verifies if all the values in the condition are valid.\n * NOTES:\n * - This is intended to be used only on conditions emitted by the components in this package.\n * - If a condition is manually constructed outside these components, this utility could miss some malformed conditions.\n */\nexport function isValidCondition(\n condition: LeafCondition,\n fields: Field[],\n trimValues: boolean = false\n): boolean {\n // If no field is yet selected on the LHS\n if (condition.lhs.field === '') {\n return false;\n }\n // If a field is present on the LHS, check if the RHS is valid\n // No need to check the comparator since the comparator is always assigned a valid value\n const fieldType = getFieldType(condition.lhs.field, fields);\n return isValidRhs(condition.rhs, condition.lhs, fields, fieldType, trimValues);\n}\n\n/** Type definition for the input props of AtomicCondition */\nexport interface AtomicConditionProps extends BaseProps {\n /** Condition to use in the component */\n condition: LeafCondition;\n\n /** Metadata (data-model) for the Fields to use in the Condition */\n fields: Field[];\n\n /** Used to enable inline error indicators on invalid inputs */\n indicateErrors: boolean;\n\n /** (Optional) Lookup used to limit the Comparators allowed in the Condition. */\n validComparators?: ComparatorsByType[];\n\n /** Callback for any modifications to the Condition */\n onChange?: (newCondition: LeafCondition, status?: 'error') => void;\n\n /** Callback fired when the condition changes. */\n onBlur?: (newCondition?: LeafCondition) => void;\n\n /** Item flow direction. Defaults to 'row' */\n itemDirection?: 'row' | 'column';\n\n /**\n * Allows presenting the LHS as a readonly text, input or hidden. Defaults presenting as 'input'.\n * NOTE: Make sure that a valid LHS is passed in the 'condition'\n */\n lhsMode?: 'input' | 'label' | 'hidden';\n\n /** Restricts RHS values to only specified types of values.\n * DEFAULT: Set(['LITERAL', 'FIELD']).\n * WARNING: There are LHS/Comparator pairings that require specific RHS types. Please be mindful of\n * these incompatibilities when limiting RHS value types using this prop. We do not support\n * limiting RHS field types to incompatible types and it will result in a validation error\n * if you do so. The pairings referred to here are as follows:\n * - BOOLEAN LHS Fields coupled with \"EQ\" or \"NEQ\" comparators, will always yield a Field RHS\n * - Any LHS Fields coupled with \"IN\" or \"NOT_IN\" comparators, will always yield a Literal RHS (Comma separated list)\n * If you would like to limit RHS value types and avoid these incompatibilities, you will need to exclude these\n * comparators using the validComparators prop.\n */\n validRhsTypes?: Set<RHSType>;\n\n /** (Optional) When enabling 'DATE_FUNCTION's via `validRhsTypes`, pass this to specify which all date functions are applicable per field type */\n dateFunctions?: DateFunctionsByType;\n\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n /** Imperative handle */\n handle?: Ref<HandleValue>;\n}\n\n/** A controlled component for Atomic Conditions */\nconst AtomicCondition: ForwardRefForwardPropsComponent<AtomicConditionProps> = forwardRef(\n function AtomicCondition(\n {\n condition,\n fields,\n indicateErrors,\n validComparators,\n onChange,\n onBlur,\n itemDirection,\n lhsMode = 'input',\n validRhsTypes = new Set<RHSType>(['LITERAL', 'FIELD']),\n dateFunctions,\n handle,\n ...restProps\n }: PropsWithoutRef<AtomicConditionProps>,\n ref: AtomicConditionProps['ref']\n ) {\n const t = useI18n();\n\n // stores condition form state\n const [state, setState] = useState<LeafCondition>(condition);\n // ref needed to handle use case of onChange and onBlur being triggered at the same time\n // state is not updated by the time blur is invoked, ref is always set to newest value\n const newCondition = useRef(condition);\n\n const fieldType = getFieldType(condition.lhs.field, fields); // Can be `undefined` if no match or if no previous field\n const comparatorOptions = fieldType\n ? getComparatorOptions(fieldType, validComparators).map(option => ({\n ...option,\n label: t(`condition_builder_comparator_${option.label}`)\n }))\n : [{ id: '', label: t('condition_builder_select_placeholder') }];\n\n useAfterInitialEffect(() => {\n setState(condition);\n }, [condition]);\n\n const onFocusChange = (focused: boolean) => {\n if (!focused) {\n // newCondition is returned, as it stores newest value\n onBlur?.(\n newCondition.current && isValidCondition(newCondition.current, fields, true)\n ? newCondition.current\n : undefined\n );\n }\n };\n\n const containerRef = useConsolidatedRef(ref);\n useFocusWithin([containerRef], onFocusChange);\n\n // Handle condition update\n const handleConditionChange = (updatedCondition: LeafCondition, status?: 'error') => {\n newCondition.current = updatedCondition;\n // new condition is returned with status to allow recognizing errors and avoiding clearing wrong values from input\n onChange?.(updatedCondition, status);\n };\n\n // Handle change in the field-selector\n const handleFieldChange = (id: string) => {\n const lhs = { field: id };\n const initCondition = getInitConditionForLhs(\n lhs,\n fields,\n validRhsTypes,\n validComparators,\n dateFunctions\n ); // Determine comparator and rhs for the new lhs\n handleConditionChange(initCondition);\n };\n\n // Handle change in the comparator\n const handleComparatorChange = (e: ChangeEvent<HTMLSelectElement>) => {\n if (e.target.value === '') {\n return; // The option is shown only when an lhs is not yet selected. Ignore this selection for those cases\n }\n const comparator = e.target.value as Comparator;\n const conditionRhs = condition.rhs\n ? ({ ...condition.rhs } as LeafCondition['rhs']) // Duplicating rhs to avoid using source object as it can be mutated later.\n : undefined;\n\n const rhs = isRhsValidForComparator(conditionRhs, comparator)\n ? conditionRhs\n : getDefaultRhs(fieldType as FieldType, comparator, validRhsTypes, dateFunctions);\n\n handleConditionChange({ ...condition, comparator, rhs });\n };\n\n // Handle change in the RHS\n const handleRHSChange = (rhs: LeafCondition['rhs'], status?: 'error') => {\n handleConditionChange({ ...condition, rhs }, status);\n };\n\n const rhsHandle = useRef<HandleValue>(null);\n\n const clear = () => {\n rhsHandle.current?.clear();\n if (newCondition.current) {\n handleConditionChange(\n getInitConditionForLhs(state.lhs, fields, validRhsTypes, validComparators, dateFunctions)\n );\n }\n };\n\n useImperativeHandle(\n handle,\n () => ({\n clear\n }),\n [clear]\n );\n\n const lhsLabel = getFieldLabel(condition.lhs.field, fields);\n\n return (\n // Using minmax() to get equal widths: https://stackoverflow.com/a/61240964/4247448\n <StyledAtomicCondition\n {...restProps}\n name={lhsMode === 'label' ? lhsLabel : undefined}\n aria-label={lhsMode === 'hidden' ? lhsLabel : undefined}\n >\n <Grid\n sm={{\n container: {\n cols:\n itemDirection === 'column'\n ? 'minmax(0, 1fr)'\n : `repeat(${lhsMode !== 'input' ? 2 : 3}, minmax(0,1fr))`\n }\n }}\n container={{\n justifyItems: 'stretch',\n colGap: 0.5,\n rowGap: 0.5\n }}\n ref={containerRef}\n >\n {/* LHS selector */}\n {lhsMode === 'input' && (\n <FieldSelector\n value={state.lhs.field}\n onChange={handleFieldChange}\n fields={fields}\n status={indicateErrors && state.lhs.field === '' ? 'error' : undefined}\n info={\n indicateErrors && state.lhs.field === ''\n ? t('condition_builder_condition_select_info_default')\n : undefined\n }\n />\n )}\n\n {/* Comparator selector */}\n <Select\n value={state.comparator}\n onChange={handleComparatorChange}\n name='comparator'\n label={t('condition_builder_comparator_label')}\n >\n {comparatorOptions.map(option => (\n <Option key={option.id} value={option.id}>\n {option.label}\n </Option>\n ))}\n </Select>\n\n {/* RHS controls */}\n <RhsControls\n lhs={state.lhs}\n comparator={state.comparator}\n rhs={state.rhs}\n fields={fields}\n onChange={handleRHSChange}\n indicateErrors={indicateErrors}\n validRhsTypes={validRhsTypes}\n dateFunctions={dateFunctions}\n itemDirection={itemDirection || 'row'}\n handle={rhsHandle}\n />\n </Grid>\n </StyledAtomicCondition>\n );\n }\n);\n\nexport default AtomicCondition;\n"]}
1
+ {"version":3,"file":"AtomicCondition.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/AtomicCondition.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAG1E,OAAO,EACL,IAAI,EACJ,MAAM,EACN,MAAM,EACN,OAAO,EACP,OAAO,EACP,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACtB,MAAM,yBAAyB,CAAC;AAOjC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,aAAa,MAAM,6BAA6B,CAAC;AACxD,OAAO,WAAW,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,oBAAoB,MAA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EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,eAAe,EACzB,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,IAAI,KAAK,EACrC,MAAM,EAAE,SAAS,GACjB,IACG,GACe,CACzB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { forwardRef, useRef, useState, useImperativeHandle } from 'react';\nimport type { ChangeEvent, Ref, PropsWithoutRef } from 'react';\n\nimport {\n Grid,\n Select,\n Option,\n useI18n,\n hasProp,\n useConsolidatedRef,\n useFocusWithin,\n useAfterInitialEffect\n} from '@pega/cosmos-react-core';\nimport type {\n BaseProps,\n HandleValue,\n ForwardRefForwardPropsComponent\n} from '@pega/cosmos-react-core';\n\nimport { getItem } from './core/utils';\nimport type { LeafCondition, Field, DateFunctionsByType } from './ConditionBuilder.types';\nimport FieldSelector from './RhsControls/FieldSelector';\nimport RhsControls, { getDefaultRhs, isValidRhs } from './RhsControls';\nimport getComparatorOptions from './core/comparators';\nimport type { Comparator, ComparatorsByType, FieldType, RHSType } from './core/types';\nimport { StyledAtomicCondition } from './ConditionBuilder.styles';\n\n// Returns field-type for a given field-name\nfunction getFieldType(fieldName: string, fields: Field[]): FieldType | undefined {\n const matchingField = getItem(fields, fieldName);\n return matchingField && hasProp(matchingField, 'type') ? matchingField.type : undefined;\n}\n\n// Returns display label for a given field-name\nfunction getFieldLabel(fieldName: string, fields: Field[]): string | undefined {\n const matchingField = getItem(fields, fieldName);\n return matchingField?.primary;\n}\n\n/**\n * Upon changing the comparator, checks if the old RHS is valid for the new comparator\n * NOTE: This works under the assumption that the LHS doesn't change\n */\nfunction isRhsValidForComparator(rhs: LeafCondition['rhs'], comparator: Comparator): boolean {\n if (rhs === undefined) {\n return ['IS_NULL', 'IS_NOT_NULL', 'IS_TRUE', 'IS_FALSE'].includes(comparator);\n }\n if (hasProp(rhs, 'values')) {\n return ['IN', 'NOT_IN'].includes(comparator);\n }\n\n if (hasProp(rhs, 'parameterId')) {\n return ['EQ', 'NEQ'].includes(comparator);\n }\n\n if (hasProp(rhs, 'start')) {\n return ['BTW', 'NOT_BTW'].includes(comparator);\n }\n\n // `rhs.field` and `rhs.value` cases\n return [\n 'EQ',\n 'NEQ',\n 'GT',\n 'GTE',\n 'LT',\n 'LTE',\n 'STARTS_WITH',\n 'NOT_STARTS_WITH',\n 'ENDS_WITH',\n 'NOT_ENDS_WITH',\n 'CONTAINS',\n 'NOT_CONTAINS'\n ].includes(comparator);\n}\n\n/** Determines the default condition object for a given LHS value */\nexport function getInitConditionForLhs(\n lhs: LeafCondition['lhs'],\n fields: Field[],\n validRhsTypes: Set<RHSType>,\n validComparators?: ComparatorsByType[],\n dateFunctions?: DateFunctionsByType\n): LeafCondition {\n let comparator: Comparator;\n let rhs: LeafCondition['rhs'];\n if (lhs.field === '') {\n // If the empty option is selected, reset the comparator and rhs to their default values\n comparator = 'IS_NOT_NULL';\n rhs = undefined;\n } else {\n const newFieldType = getFieldType(lhs.field, fields) as FieldType;\n comparator = getComparatorOptions(newFieldType, validComparators)[0].id; // Find the applicable comparators and select the first among them\n rhs = getDefaultRhs(newFieldType, comparator, validRhsTypes, dateFunctions);\n }\n\n return { lhs, comparator, rhs };\n}\n\n/**\n * Verifies if all the values in the condition are valid.\n * NOTES:\n * - This is intended to be used only on conditions emitted by the components in this package.\n * - If a condition is manually constructed outside these components, this utility could miss some malformed conditions.\n */\nexport function isValidCondition(\n condition: LeafCondition,\n fields: Field[],\n trimValues: boolean = false\n): boolean {\n // If no field is yet selected on the LHS\n if (condition.lhs.field === '') {\n return false;\n }\n // If a field is present on the LHS, check if the RHS is valid\n // No need to check the comparator since the comparator is always assigned a valid value\n const fieldType = getFieldType(condition.lhs.field, fields);\n return isValidRhs(condition.rhs, condition.lhs, fields, fieldType, trimValues);\n}\n\n/** Type definition for the input props of AtomicCondition */\nexport interface AtomicConditionProps extends BaseProps {\n /** Condition to use in the component */\n condition: LeafCondition;\n\n /** (Optional) Index of the condition. Used when rendering multiple conditions */\n index?: number;\n\n /** Metadata (data-model) for the Fields to use in the Condition */\n fields: Field[];\n\n /** Used to enable inline error indicators on invalid inputs */\n indicateErrors: boolean;\n\n /** (Optional) Lookup used to limit the Comparators allowed in the Condition. */\n validComparators?: ComparatorsByType[];\n\n /** Callback for any modifications to the Condition */\n onChange?: (newCondition: LeafCondition, status?: 'error') => void;\n\n /** Callback fired when the condition changes. */\n onBlur?: (newCondition?: LeafCondition) => void;\n\n /** Item flow direction. Defaults to 'row' */\n itemDirection?: 'row' | 'column';\n\n /**\n * Allows presenting the LHS as a readonly text, input or hidden. Defaults presenting as 'input'.\n * NOTE: Make sure that a valid LHS is passed in the 'condition'\n */\n lhsMode?: 'input' | 'label' | 'hidden';\n\n /** Restricts RHS values to only specified types of values.\n * DEFAULT: Set(['LITERAL', 'FIELD']).\n * WARNING: There are LHS/Comparator pairings that require specific RHS types. Please be mindful of\n * these incompatibilities when limiting RHS value types using this prop. We do not support\n * limiting RHS field types to incompatible types and it will result in a validation error\n * if you do so. The pairings referred to here are as follows:\n * - BOOLEAN LHS Fields coupled with \"EQ\" or \"NEQ\" comparators, will always yield a Field RHS\n * - Any LHS Fields coupled with \"IN\" or \"NOT_IN\" comparators, will always yield a Literal RHS (Comma separated list)\n * If you would like to limit RHS value types and avoid these incompatibilities, you will need to exclude these\n * comparators using the validComparators prop.\n */\n validRhsTypes?: Set<RHSType>;\n\n /** (Optional) When enabling 'DATE_FUNCTION's via `validRhsTypes`, pass this to specify which all date functions are applicable per field type */\n dateFunctions?: DateFunctionsByType;\n\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n /** Imperative handle */\n handle?: Ref<HandleValue>;\n}\n\n/** A controlled component for Atomic Conditions */\nconst AtomicCondition: ForwardRefForwardPropsComponent<AtomicConditionProps> = forwardRef(\n function AtomicCondition(\n {\n condition,\n fields,\n indicateErrors,\n validComparators,\n onChange,\n onBlur,\n itemDirection,\n lhsMode = 'input',\n validRhsTypes = new Set<RHSType>(['LITERAL', 'FIELD']),\n dateFunctions,\n handle,\n ...restProps\n }: PropsWithoutRef<AtomicConditionProps>,\n ref: AtomicConditionProps['ref']\n ) {\n const t = useI18n();\n\n // stores condition form state\n const [state, setState] = useState<LeafCondition>(condition);\n // ref needed to handle use case of onChange and onBlur being triggered at the same time\n // state is not updated by the time blur is invoked, ref is always set to newest value\n const newCondition = useRef(condition);\n\n const fieldType = getFieldType(condition.lhs.field, fields); // Can be `undefined` if no match or if no previous field\n const comparatorOptions = fieldType\n ? getComparatorOptions(fieldType, validComparators).map(option => ({\n ...option,\n label: t(`condition_builder_comparator_${option.label}`)\n }))\n : [{ id: '', label: t('condition_builder_select_placeholder') }];\n\n useAfterInitialEffect(() => {\n setState(condition);\n }, [condition]);\n\n const onFocusChange = (focused: boolean) => {\n if (!focused) {\n // newCondition is returned, as it stores newest value\n onBlur?.(\n newCondition.current && isValidCondition(newCondition.current, fields, true)\n ? newCondition.current\n : undefined\n );\n }\n };\n\n const containerRef = useConsolidatedRef(ref);\n useFocusWithin([containerRef], onFocusChange);\n\n // Handle condition update\n const handleConditionChange = (updatedCondition: LeafCondition, status?: 'error') => {\n newCondition.current = updatedCondition;\n // new condition is returned with status to allow recognizing errors and avoiding clearing wrong values from input\n onChange?.(updatedCondition, status);\n };\n\n // Handle change in the field-selector\n const handleFieldChange = (id: string) => {\n const lhs = { field: id };\n const initCondition = getInitConditionForLhs(\n lhs,\n fields,\n validRhsTypes,\n validComparators,\n dateFunctions\n ); // Determine comparator and rhs for the new lhs\n handleConditionChange(initCondition);\n };\n\n // Handle change in the comparator\n const handleComparatorChange = (e: ChangeEvent<HTMLSelectElement>) => {\n if (e.target.value === '') {\n return; // The option is shown only when an lhs is not yet selected. Ignore this selection for those cases\n }\n const comparator = e.target.value as Comparator;\n const conditionRhs = condition.rhs\n ? ({ ...condition.rhs } as LeafCondition['rhs']) // Duplicating rhs to avoid using source object as it can be mutated later.\n : undefined;\n\n const rhs = isRhsValidForComparator(conditionRhs, comparator)\n ? conditionRhs\n : getDefaultRhs(fieldType as FieldType, comparator, validRhsTypes, dateFunctions);\n\n handleConditionChange({ ...condition, comparator, rhs });\n };\n\n // Handle change in the RHS\n const handleRHSChange = (rhs: LeafCondition['rhs'], status?: 'error') => {\n handleConditionChange({ ...condition, rhs }, status);\n };\n\n const rhsHandle = useRef<HandleValue>(null);\n\n const clear = () => {\n rhsHandle.current?.clear();\n if (newCondition.current) {\n handleConditionChange(\n getInitConditionForLhs(state.lhs, fields, validRhsTypes, validComparators, dateFunctions)\n );\n }\n };\n\n useImperativeHandle(\n handle,\n () => ({\n clear\n }),\n [clear]\n );\n\n const lhsLabel = getFieldLabel(condition.lhs.field, fields);\n\n return (\n // Using minmax() to get equal widths: https://stackoverflow.com/a/61240964/4247448\n <StyledAtomicCondition\n {...restProps}\n name={lhsMode === 'label' ? lhsLabel : undefined}\n aria-label={lhsMode === 'hidden' ? lhsLabel : undefined}\n >\n <Grid\n sm={{\n container: {\n cols:\n itemDirection === 'column'\n ? 'minmax(0, 1fr)'\n : `repeat(${lhsMode !== 'input' ? 2 : 3}, minmax(0,1fr))`\n }\n }}\n container={{\n justifyItems: 'stretch',\n colGap: 0.5,\n rowGap: 0.5\n }}\n ref={containerRef}\n >\n {/* LHS selector */}\n {lhsMode === 'input' && (\n <FieldSelector\n value={state.lhs.field}\n onChange={handleFieldChange}\n fields={fields}\n status={indicateErrors && state.lhs.field === '' ? 'error' : undefined}\n info={\n indicateErrors && state.lhs.field === ''\n ? t('condition_builder_condition_select_info_default')\n : undefined\n }\n />\n )}\n\n {/* Comparator selector */}\n <Select\n value={state.comparator}\n onChange={handleComparatorChange}\n name='comparator'\n label={t('condition_builder_comparator_label')}\n >\n {comparatorOptions.map(option => (\n <Option key={option.id} value={option.id}>\n {option.label}\n </Option>\n ))}\n </Select>\n\n {/* RHS controls */}\n <RhsControls\n lhs={state.lhs}\n comparator={state.comparator}\n rhs={state.rhs}\n fields={fields}\n onChange={handleRHSChange}\n indicateErrors={indicateErrors}\n validRhsTypes={validRhsTypes}\n dateFunctions={dateFunctions}\n itemDirection={itemDirection || 'row'}\n handle={rhsHandle}\n />\n </Grid>\n </StyledAtomicCondition>\n );\n }\n);\n\nexport default AtomicCondition;\n"]}
@@ -1,6 +1,5 @@
1
- import type { FunctionComponent } from 'react';
2
- import type { ForwardProps } from '@pega/cosmos-react-core';
1
+ import type { ForwardRefForwardPropsComponent } from '@pega/cosmos-react-core';
3
2
  import type ConditionBuilderProps from './ConditionBuilder.types';
4
- declare const ConditionBuilder: FunctionComponent<ConditionBuilderProps & ForwardProps>;
3
+ declare const ConditionBuilder: ForwardRefForwardPropsComponent<ConditionBuilderProps>;
5
4
  export default ConditionBuilder;
6
5
  //# sourceMappingURL=ConditionBuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionBuilder.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAe,MAAM,OAAO,CAAC;AAc5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,KAAK,qBAAqB,MAAM,0BAA0B,CAAC;AA8BlE,QAAA,MAAM,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,GAAG,YAAY,CAwX7E,CAAC;AAGF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"ConditionBuilder.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAG/E,OAAO,KAAK,qBAAqB,MAAM,0BAA0B,CAAC;AA8BlE,QAAA,MAAM,gBAAgB,EAAE,+BAA+B,CAAC,qBAAqB,CAmZ5E,CAAC;AAGF,eAAe,gBAAgB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Fragment, useState, useReducer, useImperativeHandle, useRef, useEffect } from 'react';
2
+ import { Fragment, useState, useReducer, useImperativeHandle, useRef, useEffect, useCallback, forwardRef } from 'react';
3
3
  import { Button, Flex, Icon, Input, MenuButton, hasProp, useI18n, getFocusables, useLiveLog, Switch } from '@pega/cosmos-react-core';
4
4
  import AtomicCondition, { isValidCondition } from './AtomicCondition';
5
5
  import { splitConditionForBuilder, parseLogicString, disambiguateLogic, isBasicModeApplicable, getBasicModeOperators, getLogicFromBasicMode } from './core/utils';
@@ -15,19 +15,19 @@ const defaultProps = {
15
15
  }
16
16
  };
17
17
  // Component for the builder
18
- const ConditionBuilder = (props) => {
19
- const { fields, condition: seedCondition, validComparators, validRhsTypes = new Set(['LITERAL', 'FIELD']), dateFunctions, disallowNOT, handle } = props;
18
+ const ConditionBuilder = forwardRef(function ConditionBuilder(props, ref) {
19
+ const { fields = [], condition: seedCondition, validComparators = [], validRhsTypes = new Set(['LITERAL', 'FIELD']), dateFunctions = { DATE_TIME: [], DATE_ONLY: [] }, disallowNOT, disabled = false, readOnly = false, handle, conditionRenderer: ConditionRenderer = AtomicCondition, onLogicError } = props;
20
20
  // Split the condition tree into a logic-string and a list of condition-rows.
21
21
  const clonedCondition = JSON.parse(JSON.stringify(seedCondition)); // Cloning to avoid modifying the original
22
22
  const { logic: seedLogic, rows: seedRows } = splitConditionForBuilder(clonedCondition);
23
23
  // On load, look to use the Basic-mode if the seed-condition is simple enough
24
- const [isBasicMode, setBasicMode] = useState(() => isBasicModeApplicable(clonedCondition));
24
+ const [isBasicMode, setIsBasicMode] = useState(() => isBasicModeApplicable(clonedCondition));
25
25
  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.
26
26
  const [logicString, setLogicString] = useState(seedLogic); // Logic-string used in Advanced-mode. NOTE: When in Basic-mode, this can contain stale values.
27
27
  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.
28
28
  const [conditionRows, dispatch] = useReducer(rowsReducer, seedRows); // Conditions-rows
29
29
  const [logicError, setLogicError] = useState(null); // Used to indicate errors in the logic string
30
- const [showErrorIndicators, setErrorIndicators] = useState(false); // Used to enable inline error indicators in the condition rows
30
+ const [showErrorIndicators, setShowErrorIndicators] = useState(false); // Used to enable inline error indicators in the condition rows
31
31
  const enableShading = isBasicMode && operatorsList.includes('AND') && operatorsList.includes('OR'); // In Basic mode, enable shading to indicate grouping only when both operators are present
32
32
  const newOperatorButtonRef = useRef(null);
33
33
  const focusRowRef = useRef(null);
@@ -141,10 +141,12 @@ const ConditionBuilder = (props) => {
141
141
  // Indicate any parse error
142
142
  if (hasProp(parseResult, 'error')) {
143
143
  setLogicError(parseResult.error);
144
+ onLogicError?.(parseResult.error);
144
145
  return null;
145
146
  }
146
147
  // If no errors
147
148
  setLogicError(null); // Clear any previous error
149
+ onLogicError?.(null); // Clear any previous error
148
150
  setLogicString(disambiguateLogic(logicToUse)); // Disambiguating the logic string by placing parentheses at appropriate places
149
151
  setCachedLogicString(disambiguateLogic(logicToUse));
150
152
  return parseResult.condition;
@@ -154,7 +156,7 @@ const ConditionBuilder = (props) => {
154
156
  if (isBasicMode) {
155
157
  // Update the logicString to match the operatorsList before switching the mode
156
158
  setLogicString(cachedLogicString || getLogicFromBasicMode(operatorsList));
157
- setBasicMode(false);
159
+ setIsBasicMode(false);
158
160
  }
159
161
  else {
160
162
  // If switched from advanced to basic mode the condition will be stored until another action takes place
@@ -166,21 +168,24 @@ const ConditionBuilder = (props) => {
166
168
  setOperatorsList(isBasicModeApplicable(condition)
167
169
  ? getBasicModeOperators(logicString)
168
170
  : new Array(conditionRows.length - 1).fill('AND'));
169
- setBasicMode(true);
171
+ setIsBasicMode(true);
170
172
  }
171
173
  }
172
174
  };
173
- const getCondition = () => {
174
- setErrorIndicators(false); // Reset any previous flag
175
+ const getCondition = (options = { performRowValidation: true }) => {
176
+ setShowErrorIndicators(false); // Reset any previous flag
175
177
  setLogicError(null); // Clear any previous error
178
+ onLogicError?.(null); // Clear any previous error
176
179
  // If there's a single empty condition, submit with an `undefined` value (useful for clearing a previous condition)
177
180
  if (conditionRows.length === 1 && conditionRows[0].lhs.field === '') {
178
181
  return [true, undefined];
179
182
  }
180
183
  // Identify and indicate any invalid values in the condition rows
181
- const hasInvalidRows = conditionRows.some(row => !isValidCondition(row, fields, true));
184
+ const hasInvalidRows = options.performRowValidation
185
+ ? conditionRows.some(row => !isValidCondition(row, fields, true))
186
+ : false;
182
187
  if (hasInvalidRows) {
183
- setErrorIndicators(true); // Enable inline error indications
188
+ setShowErrorIndicators(true); // Enable inline error indications
184
189
  return [false];
185
190
  }
186
191
  // Validate the Logic string
@@ -192,17 +197,21 @@ const ConditionBuilder = (props) => {
192
197
  }
193
198
  return [false];
194
199
  };
200
+ const getLogicError = useCallback(() => {
201
+ return logicError;
202
+ }, [logicError]);
195
203
  useImperativeHandle(handle, () => ({
196
- getCondition
197
- }), [getCondition]);
204
+ getCondition,
205
+ getLogicError
206
+ }), [getCondition, getLogicError]);
198
207
  const t = useI18n();
199
208
  const { announceAssertive } = useLiveLog();
200
209
  useEffect(() => {
201
210
  announceAssertive({ message: t('condition_builder_mode_switch') });
202
211
  }, [isBasicMode]);
203
- return (_jsxs(StyledConditionBuilder, { container: { direction: 'column', gap: 1 }, children: [_jsx(Flex, { container: true, children: _jsx(Switch, { label: t('condition_builder_advanced_mode_button_label'), "aria-label": t('condition_builder_advanced_mode_button_label'), on: !isBasicMode, onChange: () => {
212
+ return (_jsxs(StyledConditionBuilder, { container: { direction: 'column', gap: 1 }, ref: ref, children: [_jsx(Flex, { container: true, children: _jsx(Switch, { label: t('condition_builder_advanced_mode_button_label'), "aria-label": t('condition_builder_advanced_mode_button_label'), on: !isBasicMode, onChange: () => {
204
213
  toggleMode();
205
- } }) }), _jsx("div", { role: 'group', children: conditionRows.map(({ id, label, ...leaf }, index) => {
214
+ }, disabled: disabled || readOnly }) }), _jsx("div", { role: 'group', children: conditionRows.map(({ id, label, ...leaf }, index) => {
206
215
  const rowIndexAriaLabel = `${t('condition_builder_row', [index + 1])}`;
207
216
  const deleteAriaLabel = `${t('condition_builder_field_label')} ${leaf.lhs.field
208
217
  .split('.')
@@ -224,16 +233,16 @@ const ConditionBuilder = (props) => {
224
233
  onClick: () => updateOperator(index - 1, 'OR')
225
234
  }
226
235
  ]
227
- }, ref: index === focusRowIndex ? newOperatorButtonRef : null }) })), _jsxs(StyledRow, { "aria-label": rowIndexAriaLabel, container: { gap: 0.5, alignItems }, shaded: isBasicMode && enableShading, ref: index === focusRowIndex ? focusRowRef : null, children: [!isBasicMode && _jsx(StyledLabel, { children: label }), _jsx(Flex, { item: { grow: 1 }, children: _jsx(AtomicCondition, { condition: leaf, fields: fields, indicateErrors: showErrorIndicators, validComparators: validComparators, dateFunctions: dateFunctions, onChange: (newCondition) => {
236
+ }, ref: index === focusRowIndex ? newOperatorButtonRef : null, disabled: disabled || readOnly }) })), _jsxs(StyledRow, { "aria-label": rowIndexAriaLabel, container: { gap: 0.5, alignItems }, shaded: isBasicMode && enableShading, ref: index === focusRowIndex ? focusRowRef : null, children: [!isBasicMode && _jsx(StyledLabel, { children: label }), _jsx(Flex, { item: { grow: 1 }, children: _jsx(ConditionRenderer, { indicateErrors: showErrorIndicators, fields: fields, index: index, condition: leaf, onChange: (newCondition) => {
228
237
  const newRow = { id, label, ...newCondition };
229
238
  dispatch({ type: UPDATE_ROW, payload: { updateAt: index, newRow } });
230
- }, validRhsTypes: validRhsTypes }) }), _jsx(Button, { icon: true, variant: 'simple', onClick: () => {
239
+ }, validComparators: validComparators, dateFunctions: dateFunctions, validRhsTypes: validRhsTypes }) }), _jsx(Button, { icon: true, variant: 'simple', onClick: () => {
231
240
  insertRow(index + 1);
232
241
  setCachedLogicString('');
233
- }, label: t('add_condition'), children: _jsx(Icon, { name: 'plus' }) }), _jsx(Button, { icon: true, variant: 'simple', onClick: () => {
242
+ }, label: t('add_condition'), disabled: disabled || readOnly, children: _jsx(Icon, { name: 'plus' }) }), _jsx(Button, { icon: true, variant: 'simple', onClick: () => {
234
243
  removeRow(index);
235
244
  setCachedLogicString('');
236
- }, label: t('delete'), "aria-label": deleteAriaLabel ? t('delete_noun', [deleteAriaLabel]) : undefined, children: _jsx(Icon, { name: 'trash' }) })] })] }, id));
245
+ }, label: t('delete'), "aria-label": deleteAriaLabel ? t('delete_noun', [deleteAriaLabel]) : undefined, disabled: disabled || readOnly, children: _jsx(Icon, { name: 'trash' }) })] })] }, id));
237
246
  }) }), !isBasicMode && (_jsx("div", { children: _jsx(Flex, { container: { gap: 0.25, direction: 'column' }, children: _jsx(Input, { label: t('condition_builder_advanced_condition_label'), additionalInfo: {
238
247
  heading: t('condition_builder_advanced_condition_label'),
239
248
  content: (_jsx("div", { children: t('condition_builder_advanced_condition_tooltip', [
@@ -246,8 +255,10 @@ const ConditionBuilder = (props) => {
246
255
  .replace(/\bNOT\b/g, 'not'), onChange: (e) => {
247
256
  setLogicString(e.target.value);
248
257
  setCachedLogicString(e.target.value);
249
- }, onBlur: () => validateLogicString(logicString), status: logicError !== null ? 'error' : undefined, info: logicError, required: true }) }) }))] }));
250
- };
258
+ }, onBlur: () => {
259
+ validateLogicString(logicString);
260
+ }, status: logicError !== null ? 'error' : undefined, info: logicError, required: true, disabled: disabled, readOnly: readOnly || disabled }) }) }))] }));
261
+ });
251
262
  ConditionBuilder.defaultProps = defaultProps;
252
263
  export default ConditionBuilder;
253
264
  //# sourceMappingURL=ConditionBuilder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionBuilder.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,E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CAAC;4BACxD,OAAO,EAAE,CACP,wBACG,CAAC,CAAC,8CAA8C,EAAE;oCACjD,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY;oCACrC,WAAW,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,4BAA4B;iCAC1E,CAAC,GACE,CACP;yBACF,EACD,IAAI,EAAC,MAAM,EACX,WAAW,EAAE,CAAC,CAAC,kDAAkD,CAAC,EAClE,KAAK,EAAE,WAAW;6BACf,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC;6BAC1B,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC;6BACxB,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,EAC7B,QAAQ,EAAE,CAAC,CAAgC,EAAE,EAAE;4BAC7C,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;4BAC/B,oBAAoB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;wBACvC,CAAC,EACD,MAAM,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,WAAW,CAAC,EAC9C,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EACjD,IAAI,EAAE,UAAU,EAChB,QAAQ,SACR,GACG,GACH,CACP,IACsB,CAC1B,CAAC;AACJ,CAAC,CAAC;AACF,gBAAgB,CAAC,YAAY,GAAG,YAAY,CAAC;AAE7C,eAAe,gBAAgB,CAAC","sourcesContent":["import { Fragment, useState, useReducer, useImperativeHandle, useRef, useEffect } from 'react';\nimport type { FunctionComponent, ChangeEvent } from 'react';\n\nimport {\n Button,\n Flex,\n Icon,\n Input,\n MenuButton,\n hasProp,\n useI18n,\n getFocusables,\n useLiveLog,\n Switch\n} from '@pega/cosmos-react-core';\nimport type { ForwardProps } from '@pega/cosmos-react-core';\n\nimport AtomicCondition, { isValidCondition } from './AtomicCondition';\nimport type ConditionBuilderProps from './ConditionBuilder.types';\nimport type { Condition, HandleValue, LeafCondition } from './ConditionBuilder.types';\nimport {\n splitConditionForBuilder,\n parseLogicString,\n disambiguateLogic,\n isBasicModeApplicable,\n getBasicModeOperators,\n getLogicFromBasicMode\n} from './core/utils';\nimport rowsReducer, { INSERT_ROW, UPDATE_ROW, REMOVE_ROW } from './core/rows-reducer';\nimport type { RHSType } from './core/types';\nimport {\n StyledRowWithSeparator,\n StyledRow,\n StyledLabel,\n StyledConditionBuilder\n} from './ConditionBuilder.styles';\n\n// Default props for the builder\nconst defaultProps: Partial<ConditionBuilderProps> = {\n condition: {\n condition: {\n comparator: 'IS_NOT_NULL',\n lhs: { field: '' }\n }\n }\n};\n\n// Component for the builder\nconst ConditionBuilder: FunctionComponent<ConditionBuilderProps & ForwardProps> = (\n props: ConditionBuilderProps\n) => {\n const {\n fields,\n condition: seedCondition,\n validComparators,\n validRhsTypes = new Set<RHSType>(['LITERAL', 'FIELD']),\n dateFunctions,\n disallowNOT,\n handle\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\n // On load, look to use the Basic-mode if the seed-condition is simple enough\n const [isBasicMode, setBasicMode] = 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, setErrorIndicators] = useState(false); // Used to enable inline error indicators in the condition rows\n const enableShading =\n isBasicMode && operatorsList.includes('AND') && operatorsList.includes('OR'); // In Basic mode, enable shading to indicate grouping only when both operators are present\n\n const newOperatorButtonRef = useRef<HTMLButtonElement | null>(null);\n const focusRowRef = useRef<HTMLElement | null>(null);\n const [focusRowIndex, setFocusRowIndex] = useState<number | null>(null);\n\n // Upon adding/removing rows in Advanced mode, update the logic string to reflect the change in labels\n // NOTE: The input is updated only if the previous logicString was simple enough\n const updateLogicString = (actionType: string): void => {\n const numNewRows =\n actionType === INSERT_ROW ? conditionRows.length + 1 : conditionRows.length - 1;\n\n // If only one row left after the action, simply use its label as logicString\n // NOTE: If none left, the rowsReducer adds a new empty row\n if (numNewRows <= 1) {\n setLogicString('1');\n return;\n }\n\n // If the previous string was a simple AND/OR between all the rows, update the logicString to follow the same for the new list of rows.\n // If the previous string was a single token like `1` and a new row is inserted, do an AND between the new rows, i.e. `1 AND 2`\n // For all other complex cases, skip automatically updating the string and wait for the user to change it\n // To check this, split the previous string by `OR/AND` and check if each of the resultant token is a simple numeric token\n const splitter = logicString.includes('OR') ? 'OR' : 'AND';\n const tokens = logicString.split(splitter);\n const isEveryTokenInteger = tokens.every(w => /^\\d+$/.test(w.trim()));\n if (isEveryTokenInteger) {\n setLogicString(\n new Array(numNewRows)\n .fill(0)\n .map((w, i) => i + 1)\n .join(` ${splitter} `)\n );\n }\n };\n\n // Manages the focus behavior when inserting/removing a row\n useEffect(() => {\n if (focusRowIndex === null) return;\n\n if (newOperatorButtonRef.current) {\n newOperatorButtonRef.current.focus();\n newOperatorButtonRef.current = null;\n } else if (focusRowIndex !== null) {\n getFocusables(focusRowRef)[0]?.focus();\n }\n\n setFocusRowIndex(null);\n }, [focusRowIndex]);\n\n // Insert a new row at the given index\n const insertRow = (insertAt: number): void => {\n dispatch({ type: INSERT_ROW, payload: { insertAt } }); // Insert an entry in conditionRows\n if (isBasicMode) {\n // Set up a new AND/OR selector\n const insertOpAt = insertAt - 1; // Using `insertAt-1` since the operatorsList has one less entry compared to the conditionRows\n setOperatorsList([\n ...operatorsList.slice(0, insertOpAt),\n 'AND',\n ...operatorsList.slice(insertOpAt)\n ]);\n } else {\n updateLogicString(INSERT_ROW); // Update the logicString input to reflect the insertion\n }\n setFocusRowIndex(insertAt);\n };\n\n // Remove the row at the given index\n const removeRow = (removeAt: number): void => {\n dispatch({ type: REMOVE_ROW, payload: { removeAt } }); // Remove an entry in conditionRows\n if (isBasicMode) {\n // Remove an AND/OR selector\n if (removeAt === 0) {\n // If removing the first of the condition rows, remove the extraneous operator\n setOperatorsList(operatorsList.slice(1));\n } else {\n let removeOpAt = removeAt - 1; // Using `removeAt-1` since the operatorsList has one less entry compared to the conditionRows\n if (operatorsList[removeOpAt] === 'OR' && operatorsList[removeOpAt + 1] === 'AND') {\n // If removing a condition at the start of a nested group, remove the first operator from that group. e.g. Take `(1 AND 2) OR (3 AND 4 AND 5)`. If `3` is being deleted, it should become `(1 AND 2) OR (4 AND 5)` instead of `1 AND 2 AND 4 AND 5`\n removeOpAt += 1;\n }\n setOperatorsList([\n ...operatorsList.slice(0, removeOpAt),\n ...operatorsList.slice(removeOpAt + 1)\n ]);\n }\n } else {\n updateLogicString(REMOVE_ROW); // Update the logicString input to reflect the removal\n }\n setFocusRowIndex(() => {\n if (removeAt !== 0 && removeAt === conditionRows.length - 1) {\n return removeAt - 1;\n }\n\n return removeAt;\n });\n };\n\n // Update a Basic-mode operator at the given index\n const updateOperator = (updateAt: number, newValue: 'AND' | 'OR'): void => {\n setCachedLogicString('');\n setOperatorsList([\n ...operatorsList.slice(0, updateAt),\n newValue,\n ...operatorsList.slice(updateAt + 1)\n ]);\n };\n\n // Validate the logic input. Called upon clicking outside the textBox or upon submission.\n // If the expression is invalid, shows appropriate feedback and returns null.\n // If the expression is valid, formats it by setting up brackets at necessary places (to clear any ambiguities e.g. `1 AND 2 OR 3` is formatted as `(1 AND 2) OR 3` ). Returns a save-ready condition\n const validateLogicString = (logicToUse: string): Condition | null => {\n // Set up a lookup with row-labels as keys and rows as values\n const conditionLookup: { [label: string]: LeafCondition } = {};\n conditionRows.forEach(row => {\n const { id, label, ...leaf } = row; // Discard the extra properties added by ConditionRow to the LeafCondition interface\n conditionLookup[row.label] = leaf;\n });\n\n // Convert the logic string into a condition tree\n const parseResult = parseLogicString(logicToUse, conditionLookup, disallowNOT);\n\n // Indicate any parse error\n if (hasProp(parseResult, 'error')) {\n setLogicError(parseResult.error);\n return null;\n }\n\n // If no errors\n setLogicError(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 setBasicMode(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 setBasicMode(true);\n }\n }\n };\n\n const getCondition: HandleValue['getCondition'] = () => {\n setErrorIndicators(false); // Reset any previous flag\n setLogicError(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 = conditionRows.some(row => !isValidCondition(row, fields, true));\n if (hasInvalidRows) {\n setErrorIndicators(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 useImperativeHandle(\n handle,\n () => ({\n getCondition\n }),\n [getCondition]\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 }}>\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 />\n </Flex>\n {/* Condition Rows */}\n <div role='group'>\n {conditionRows.map(({ id, label, ...leaf }, index) => {\n const rowIndexAriaLabel = `${t('condition_builder_row', [index + 1])}`;\n const deleteAriaLabel = `${t('condition_builder_field_label')} ${leaf.lhs.field\n .split('.')\n .pop()}`;\n\n let alignItems = 'end';\n if (showErrorIndicators && !isValidCondition(leaf, fields, false)) {\n alignItems = 'center';\n }\n\n return (\n <Fragment key={id}>\n {/* Row with the operator dropdown in Basic mode */}\n {isBasicMode && index > 0 && (\n <StyledRowWithSeparator\n container\n shaded={enableShading && operatorsList[index - 1] === 'AND'}\n >\n <MenuButton\n popover={{ hideOnTargetHidden: false }}\n text={operatorsList[index - 1] === 'AND' ? 'And' : 'Or'}\n variant='simple'\n menu={{\n items: [\n {\n id: 'AND',\n primary: 'And',\n onClick: () => updateOperator(index - 1, 'AND')\n },\n {\n id: 'OR',\n primary: 'Or',\n onClick: () => updateOperator(index - 1, 'OR')\n }\n ]\n }}\n ref={index === focusRowIndex ? newOperatorButtonRef : null}\n />\n </StyledRowWithSeparator>\n )}\n\n {/* Row with the AtomicCondition */}\n <StyledRow\n aria-label={rowIndexAriaLabel}\n container={{ gap: 0.5, alignItems }}\n shaded={isBasicMode && enableShading}\n ref={index === focusRowIndex ? focusRowRef : null}\n >\n {/* Label */}\n {!isBasicMode && <StyledLabel>{label}</StyledLabel>}\n\n {/* Condition controls */}\n <Flex item={{ grow: 1 }}>\n <AtomicCondition\n condition={leaf}\n fields={fields}\n indicateErrors={showErrorIndicators}\n validComparators={validComparators}\n dateFunctions={dateFunctions}\n onChange={(newCondition: LeafCondition) => {\n const newRow = { id, label, ...newCondition };\n dispatch({ type: UPDATE_ROW, payload: { updateAt: index, newRow } });\n }}\n validRhsTypes={validRhsTypes}\n />\n </Flex>\n\n {/* Row actions */}\n <Button\n icon\n variant='simple'\n onClick={() => {\n insertRow(index + 1);\n setCachedLogicString('');\n }}\n label={t('add_condition')}\n >\n <Icon name='plus' />\n </Button>\n <Button\n icon\n variant='simple'\n onClick={() => {\n removeRow(index);\n setCachedLogicString('');\n }}\n label={t('delete')}\n aria-label={deleteAriaLabel ? t('delete_noun', [deleteAriaLabel]) : undefined}\n >\n <Icon name='trash' />\n </Button>\n </StyledRow>\n </Fragment>\n );\n })}\n </div>\n\n {/* LogicString input */}\n {!isBasicMode && (\n <div>\n <Flex container={{ gap: 0.25, direction: 'column' }}>\n <Input\n label={t('condition_builder_advanced_condition_label')}\n additionalInfo={{\n heading: t('condition_builder_advanced_condition_label'),\n content: (\n <div>\n {t('condition_builder_advanced_condition_tooltip', [\n disallowNOT ? 'AND/OR' : 'AND/OR/NOT',\n disallowNOT ? '(1 OR 2) AND (3 OR 4 OR 5)' : '(1 AND 2) OR (3 AND NOT 4)'\n ])}\n </div>\n )\n }}\n type='text'\n placeholder={t('condition_builder_advanced_condition_placeholder')}\n value={logicString\n .replace(/\\bAND\\b/g, 'and')\n .replace(/\\bOR\\b/g, 'or')\n .replace(/\\bNOT\\b/g, 'not')}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n setLogicString(e.target.value);\n setCachedLogicString(e.target.value);\n }}\n onBlur={() => validateLogicString(logicString)}\n status={logicError !== null ? 'error' : undefined}\n info={logicError}\n required\n />\n </Flex>\n </div>\n )}\n </StyledConditionBuilder>\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,MAAM,EACP,MAAM,yBAAyB,CAAC;AAGjC,OAAO,eAAe,EAAE,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGtE,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AACtB,OAAO,WAAW,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtF,OAAO,EACL,sBAAsB,EACtB,SAAS,EACT,WAAW,EACX,sBAAsB,EACvB,MAAM,2BAA2B,CAAC;AAEnC,gCAAgC;AAChC,MAAM,YAAY,GAAmC;IACnD,SAAS,EAAE;QACT,SAAS,EAAE;YACT,UAAU,EAAE,aAAa;YACzB,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;SACnB;KACF;CACF,CAAC;AAEF,4BAA4B;AAC5B,MAAM,gBAAgB,GAA2D,UAAU,CACzF,SAAS,gBAAgB,CACvB,KAA6C,EAC7C,GAAiC;IAEjC,MAAM,EACJ,MAAM,GAAG,EAAE,EACX,SAAS,EAAE,aAAa,EACxB,gBAAgB,GAAG,EAAE,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AAQ,CAAC,CAAC,CAAC,YAAY;oCACrC,WAAW,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,4BAA4B;iCAC1E,CAAC,GACE,CACP;yBACF,EACD,IAAI,EAAC,MAAM,EACX,WAAW,EAAE,CAAC,CAAC,kDAAkD,CAAC,EAClE,KAAK,EAAE,WAAW;6BACf,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC;6BAC1B,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC;6BACxB,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,EAC7B,QAAQ,EAAE,CAAC,CAAgC,EAAE,EAAE;4BAC7C,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;4BAC/B,oBAAoB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;wBACvC,CAAC,EACD,MAAM,EAAE,GAAG,EAAE;4BACX,mBAAmB,CAAC,WAAW,CAAC,CAAC;wBACnC,CAAC,EACD,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EACjD,IAAI,EAAE,UAAU,EAChB,QAAQ,QACR,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,IAAI,QAAQ,GAC9B,GACG,GACH,CACP,IACsB,CAC1B,CAAC;AACJ,CAAC,CACF,CAAC;AACF,gBAAgB,CAAC,YAAY,GAAG,YAAY,CAAC;AAE7C,eAAe,gBAAgB,CAAC","sourcesContent":["import {\n Fragment,\n useState,\n useReducer,\n useImperativeHandle,\n useRef,\n useEffect,\n useCallback,\n forwardRef\n} from 'react';\nimport type { ChangeEvent, PropsWithoutRef } from 'react';\n\nimport {\n Button,\n Flex,\n Icon,\n Input,\n MenuButton,\n hasProp,\n useI18n,\n getFocusables,\n useLiveLog,\n Switch\n} from '@pega/cosmos-react-core';\nimport type { ForwardRefForwardPropsComponent } from '@pega/cosmos-react-core';\n\nimport AtomicCondition, { isValidCondition } from './AtomicCondition';\nimport type ConditionBuilderProps from './ConditionBuilder.types';\nimport type { Condition, HandleValue, LeafCondition } from './ConditionBuilder.types';\nimport {\n splitConditionForBuilder,\n parseLogicString,\n disambiguateLogic,\n isBasicModeApplicable,\n getBasicModeOperators,\n getLogicFromBasicMode\n} from './core/utils';\nimport rowsReducer, { INSERT_ROW, UPDATE_ROW, REMOVE_ROW } from './core/rows-reducer';\nimport type { RHSType } from './core/types';\nimport {\n StyledRowWithSeparator,\n StyledRow,\n StyledLabel,\n StyledConditionBuilder\n} from './ConditionBuilder.styles';\n\n// Default props for the builder\nconst defaultProps: Partial<ConditionBuilderProps> = {\n condition: {\n condition: {\n comparator: 'IS_NOT_NULL',\n lhs: { field: '' }\n }\n }\n};\n\n// Component for the builder\nconst ConditionBuilder: ForwardRefForwardPropsComponent<ConditionBuilderProps> = forwardRef(\n function ConditionBuilder(\n props: PropsWithoutRef<ConditionBuilderProps>,\n ref: ConditionBuilderProps['ref']\n ) {\n const {\n fields = [],\n condition: seedCondition,\n validComparators = [],\n validRhsTypes = new Set<RHSType>(['LITERAL', 'FIELD']),\n dateFunctions = { DATE_TIME: [], DATE_ONLY: [] },\n disallowNOT,\n disabled = false,\n readOnly = false,\n handle,\n conditionRenderer: ConditionRenderer = AtomicCondition,\n onLogicError\n } = props;\n\n // Split the condition tree into a logic-string and a list of condition-rows.\n const clonedCondition: Condition = JSON.parse(JSON.stringify(seedCondition)); // Cloning to avoid modifying the original\n const { logic: seedLogic, rows: seedRows } = splitConditionForBuilder(clonedCondition);\n // On load, look to use the Basic-mode if the seed-condition is simple enough\n const [isBasicMode, setIsBasicMode] = useState(() => isBasicModeApplicable(clonedCondition));\n const [operatorsList, setOperatorsList] = useState(() => getBasicModeOperators(seedLogic)); // Operators-list used in Basic-mode to render dropdowns between the rows. NOTE: When in Advanced-mode, this can contain stale values.\n const [logicString, setLogicString] = useState(seedLogic); // Logic-string used in Advanced-mode. NOTE: When in Basic-mode, this can contain stale values.\n const [cachedLogicString, setCachedLogicString] = useState(seedLogic); // Logic-string used to store the last valid logic-string in Advanced-mode. This is used to restore the logic-string when switching back from Basic-mode to Advanced-mode.\n const [conditionRows, dispatch] = useReducer(rowsReducer, seedRows); // Conditions-rows\n const [logicError, setLogicError] = useState<string | null>(null); // Used to indicate errors in the logic string\n const [showErrorIndicators, setShowErrorIndicators] = useState(false); // Used to enable inline error indicators in the condition rows\n const enableShading =\n isBasicMode && operatorsList.includes('AND') && operatorsList.includes('OR'); // In Basic mode, enable shading to indicate grouping only when both operators are present\n\n const newOperatorButtonRef = useRef<HTMLButtonElement | null>(null);\n const focusRowRef = useRef<HTMLElement | null>(null);\n const [focusRowIndex, setFocusRowIndex] = useState<number | null>(null);\n\n // Upon adding/removing rows in Advanced mode, update the logic string to reflect the change in labels\n // NOTE: The input is updated only if the previous logicString was simple enough\n const updateLogicString = (actionType: string): void => {\n const numNewRows =\n actionType === INSERT_ROW ? conditionRows.length + 1 : conditionRows.length - 1;\n\n // If only one row left after the action, simply use its label as logicString\n // NOTE: If none left, the rowsReducer adds a new empty row\n if (numNewRows <= 1) {\n setLogicString('1');\n return;\n }\n\n // If the previous string was a simple AND/OR between all the rows, update the logicString to follow the same for the new list of rows.\n // If the previous string was a single token like `1` and a new row is inserted, do an AND between the new rows, i.e. `1 AND 2`\n // For all other complex cases, skip automatically updating the string and wait for the user to change it\n // To check this, split the previous string by `OR/AND` and check if each of the resultant token is a simple numeric token\n const splitter = logicString.includes('OR') ? 'OR' : 'AND';\n const tokens = logicString.split(splitter);\n const isEveryTokenInteger = tokens.every(w => /^\\d+$/.test(w.trim()));\n if (isEveryTokenInteger) {\n setLogicString(\n new Array(numNewRows)\n .fill(0)\n .map((w, i) => i + 1)\n .join(` ${splitter} `)\n );\n }\n };\n\n // Manages the focus behavior when inserting/removing a row\n useEffect(() => {\n if (focusRowIndex === null) return;\n\n if (newOperatorButtonRef.current) {\n newOperatorButtonRef.current.focus();\n newOperatorButtonRef.current = null;\n } else if (focusRowIndex !== null) {\n getFocusables(focusRowRef)[0]?.focus();\n }\n\n setFocusRowIndex(null);\n }, [focusRowIndex]);\n\n // Insert a new row at the given index\n const insertRow = (insertAt: number): void => {\n dispatch({ type: INSERT_ROW, payload: { insertAt } }); // Insert an entry in conditionRows\n if (isBasicMode) {\n // Set up a new AND/OR selector\n const insertOpAt = insertAt - 1; // Using `insertAt-1` since the operatorsList has one less entry compared to the conditionRows\n setOperatorsList([\n ...operatorsList.slice(0, insertOpAt),\n 'AND',\n ...operatorsList.slice(insertOpAt)\n ]);\n } else {\n updateLogicString(INSERT_ROW); // Update the logicString input to reflect the insertion\n }\n setFocusRowIndex(insertAt);\n };\n\n // Remove the row at the given index\n const removeRow = (removeAt: number): void => {\n dispatch({ type: REMOVE_ROW, payload: { removeAt } }); // Remove an entry in conditionRows\n if (isBasicMode) {\n // Remove an AND/OR selector\n if (removeAt === 0) {\n // If removing the first of the condition rows, remove the extraneous operator\n setOperatorsList(operatorsList.slice(1));\n } else {\n let removeOpAt = removeAt - 1; // Using `removeAt-1` since the operatorsList has one less entry compared to the conditionRows\n if (operatorsList[removeOpAt] === 'OR' && operatorsList[removeOpAt + 1] === 'AND') {\n // If removing a condition at the start of a nested group, remove the first operator from that group. e.g. Take `(1 AND 2) OR (3 AND 4 AND 5)`. If `3` is being deleted, it should become `(1 AND 2) OR (4 AND 5)` instead of `1 AND 2 AND 4 AND 5`\n removeOpAt += 1;\n }\n setOperatorsList([\n ...operatorsList.slice(0, removeOpAt),\n ...operatorsList.slice(removeOpAt + 1)\n ]);\n }\n } else {\n updateLogicString(REMOVE_ROW); // Update the logicString input to reflect the removal\n }\n setFocusRowIndex(() => {\n if (removeAt !== 0 && removeAt === conditionRows.length - 1) {\n return removeAt - 1;\n }\n\n return removeAt;\n });\n };\n\n // Update a Basic-mode operator at the given index\n const updateOperator = (updateAt: number, newValue: 'AND' | 'OR'): void => {\n setCachedLogicString('');\n setOperatorsList([\n ...operatorsList.slice(0, updateAt),\n newValue,\n ...operatorsList.slice(updateAt + 1)\n ]);\n };\n\n // Validate the logic input. Called upon clicking outside the textBox or upon submission.\n // If the expression is invalid, shows appropriate feedback and returns null.\n // If the expression is valid, formats it by setting up brackets at necessary places (to clear any ambiguities e.g. `1 AND 2 OR 3` is formatted as `(1 AND 2) OR 3` ). Returns a save-ready condition\n const validateLogicString = (logicToUse: string): Condition | null => {\n // Set up a lookup with row-labels as keys and rows as values\n const conditionLookup: { [label: string]: LeafCondition } = {};\n conditionRows.forEach(row => {\n const { id, label, ...leaf } = row; // Discard the extra properties added by ConditionRow to the LeafCondition interface\n conditionLookup[row.label] = leaf;\n });\n\n // Convert the logic string into a condition tree\n const parseResult = parseLogicString(logicToUse, conditionLookup, disallowNOT);\n\n // Indicate any parse error\n if (hasProp(parseResult, 'error')) {\n setLogicError(parseResult.error);\n onLogicError?.(parseResult.error);\n return null;\n }\n\n // If no errors\n setLogicError(null); // Clear any previous error\n onLogicError?.(null); // Clear any previous error\n setLogicString(disambiguateLogic(logicToUse)); // Disambiguating the logic string by placing parentheses at appropriate places\n setCachedLogicString(disambiguateLogic(logicToUse));\n return parseResult.condition;\n };\n\n // Toggle between the Basic and Advanced modes\n const toggleMode = (): void => {\n if (isBasicMode) {\n // Update the logicString to match the operatorsList before switching the mode\n setLogicString(cachedLogicString || getLogicFromBasicMode(operatorsList));\n setIsBasicMode(false);\n } else {\n // If switched from advanced to basic mode the condition will be stored until another action takes place\n setCachedLogicString(logicString);\n const condition = validateLogicString(logicString); // Validate the logicString. If it is an invalid, an appropriate error is shown for the user to act on\n if (condition !== null) {\n // If the logic is simple enough, identify the new set of operators before switching to Basic mode.\n // If the logic is too complex fallback to using 'AND' between all rows\n setOperatorsList(\n isBasicModeApplicable(condition)\n ? getBasicModeOperators(logicString)\n : new Array(conditionRows.length - 1).fill('AND')\n );\n setIsBasicMode(true);\n }\n }\n };\n\n const getCondition: HandleValue['getCondition'] = (\n options = { performRowValidation: true }\n ) => {\n setShowErrorIndicators(false); // Reset any previous flag\n setLogicError(null); // Clear any previous error\n onLogicError?.(null); // Clear any previous error\n\n // If there's a single empty condition, submit with an `undefined` value (useful for clearing a previous condition)\n if (conditionRows.length === 1 && conditionRows[0].lhs.field === '') {\n return [true, undefined];\n }\n\n // Identify and indicate any invalid values in the condition rows\n const hasInvalidRows = options.performRowValidation\n ? conditionRows.some(row => !isValidCondition(row, fields, true))\n : false;\n if (hasInvalidRows) {\n setShowErrorIndicators(true); // Enable inline error indications\n return [false];\n }\n\n // Validate the Logic string\n const logicToUse = isBasicMode ? getLogicFromBasicMode(operatorsList) : logicString; // If in Basic-mode, construct a different logicString based on the operatorsList\n const condition = validateLogicString(logicToUse); // This also takes care of showing an appropriate error feedback as needed\n if (condition !== null) {\n // Can be null when the logic string has errors\n return [true, condition];\n }\n\n return [false];\n };\n\n const getLogicError: HandleValue['getLogicError'] = useCallback((): string | null => {\n return logicError;\n }, [logicError]);\n\n useImperativeHandle(\n handle,\n () => ({\n getCondition,\n getLogicError\n }),\n [getCondition, getLogicError]\n );\n\n const t = useI18n();\n\n const { announceAssertive } = useLiveLog();\n\n useEffect(() => {\n announceAssertive({ message: t('condition_builder_mode_switch') });\n }, [isBasicMode]);\n\n return (\n <StyledConditionBuilder container={{ direction: 'column', gap: 1 }} ref={ref}>\n <Flex container>\n <Switch\n label={t('condition_builder_advanced_mode_button_label')}\n aria-label={t('condition_builder_advanced_mode_button_label')}\n on={!isBasicMode}\n onChange={() => {\n toggleMode();\n }}\n disabled={disabled || readOnly}\n />\n </Flex>\n {/* Condition Rows */}\n <div role='group'>\n {conditionRows.map(({ id, label, ...leaf }, index) => {\n const rowIndexAriaLabel = `${t('condition_builder_row', [index + 1])}`;\n const deleteAriaLabel = `${t('condition_builder_field_label')} ${leaf.lhs.field\n .split('.')\n .pop()}`;\n\n let alignItems = 'end';\n if (showErrorIndicators && !isValidCondition(leaf, fields, false)) {\n alignItems = 'center';\n }\n\n return (\n <Fragment key={id}>\n {/* Row with the operator dropdown in Basic mode */}\n {isBasicMode && index > 0 && (\n <StyledRowWithSeparator\n container\n shaded={enableShading && operatorsList[index - 1] === 'AND'}\n >\n <MenuButton\n popover={{ hideOnTargetHidden: false }}\n text={operatorsList[index - 1] === 'AND' ? 'And' : 'Or'}\n variant='simple'\n menu={{\n items: [\n {\n id: 'AND',\n primary: 'And',\n onClick: () => updateOperator(index - 1, 'AND')\n },\n {\n id: 'OR',\n primary: 'Or',\n onClick: () => updateOperator(index - 1, 'OR')\n }\n ]\n }}\n ref={index === focusRowIndex ? newOperatorButtonRef : null}\n disabled={disabled || readOnly}\n />\n </StyledRowWithSeparator>\n )}\n\n {/* Row with the AtomicCondition */}\n <StyledRow\n aria-label={rowIndexAriaLabel}\n container={{ gap: 0.5, alignItems }}\n shaded={isBasicMode && enableShading}\n ref={index === focusRowIndex ? focusRowRef : null}\n >\n {/* Label */}\n {!isBasicMode && <StyledLabel>{label}</StyledLabel>}\n\n {/* Condition controls */}\n <Flex item={{ grow: 1 }}>\n <ConditionRenderer\n indicateErrors={showErrorIndicators}\n fields={fields}\n index={index}\n condition={leaf}\n onChange={(newCondition: LeafCondition) => {\n const newRow = { id, label, ...newCondition };\n dispatch({ type: UPDATE_ROW, payload: { updateAt: index, newRow } });\n }}\n validComparators={validComparators}\n dateFunctions={dateFunctions}\n validRhsTypes={validRhsTypes}\n />\n </Flex>\n\n {/* Row actions */}\n <Button\n icon\n variant='simple'\n onClick={() => {\n insertRow(index + 1);\n setCachedLogicString('');\n }}\n label={t('add_condition')}\n disabled={disabled || readOnly}\n >\n <Icon name='plus' />\n </Button>\n <Button\n icon\n variant='simple'\n onClick={() => {\n removeRow(index);\n setCachedLogicString('');\n }}\n label={t('delete')}\n aria-label={deleteAriaLabel ? t('delete_noun', [deleteAriaLabel]) : undefined}\n disabled={disabled || readOnly}\n >\n <Icon name='trash' />\n </Button>\n </StyledRow>\n </Fragment>\n );\n })}\n </div>\n\n {/* LogicString input */}\n {!isBasicMode && (\n <div>\n <Flex container={{ gap: 0.25, direction: 'column' }}>\n <Input\n label={t('condition_builder_advanced_condition_label')}\n additionalInfo={{\n heading: t('condition_builder_advanced_condition_label'),\n content: (\n <div>\n {t('condition_builder_advanced_condition_tooltip', [\n disallowNOT ? 'AND/OR' : 'AND/OR/NOT',\n disallowNOT ? '(1 OR 2) AND (3 OR 4 OR 5)' : '(1 AND 2) OR (3 AND NOT 4)'\n ])}\n </div>\n )\n }}\n type='text'\n placeholder={t('condition_builder_advanced_condition_placeholder')}\n value={logicString\n .replace(/\\bAND\\b/g, 'and')\n .replace(/\\bOR\\b/g, 'or')\n .replace(/\\bNOT\\b/g, 'not')}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n setLogicString(e.target.value);\n setCachedLogicString(e.target.value);\n }}\n onBlur={() => {\n validateLogicString(logicString);\n }}\n status={logicError !== null ? 'error' : undefined}\n info={logicError}\n required\n disabled={disabled}\n readOnly={readOnly || disabled}\n />\n </Flex>\n </div>\n )}\n </StyledConditionBuilder>\n );\n }\n);\nConditionBuilder.defaultProps = defaultProps;\n\nexport default ConditionBuilder;\n"]}
@@ -1,4 +1,5 @@
1
- export declare const StyledConditionBuilder: import("styled-components").StyledComponent<import("@pega/cosmos-react-core").ForwardRefForwardPropsComponent<import("@pega/cosmos-react-core").FlexProps>, import("styled-components").DefaultTheme, {}, never>;
1
+ import { Flex } from '@pega/cosmos-react-core';
2
+ export declare const StyledConditionBuilder: typeof Flex;
2
3
  export declare const StyledRow: import("styled-components").StyledComponent<import("@pega/cosmos-react-core").ForwardRefForwardPropsComponent<import("@pega/cosmos-react-core").FlexProps>, import("styled-components").DefaultTheme, {}, never>;
3
4
  export declare const StyledTimePeriodContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
4
5
  export declare const StyledRowWithSeparator: import("styled-components").StyledComponent<import("@pega/cosmos-react-core").ForwardRefForwardPropsComponent<import("@pega/cosmos-react-core").FlexProps>, import("styled-components").DefaultTheme, {}, never>;
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionBuilder.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.styles.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,sBAAsB,kNAWjC,CAAC;AAKH,eAAO,MAAM,SAAS,kNAOrB,CAAC;AAIF,eAAO,MAAM,yBAAyB,yGAIpC,CAAC;AAKH,eAAO,MAAM,sBAAsB,kNAgBlC,CAAC;AAKF,eAAO,MAAM,WAAW,yGASvB,CAAC;AAIF,eAAO,MAAM,qBAAqB,wNAkBhC,CAAC"}
1
+ {"version":3,"file":"ConditionBuilder.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.styles.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,IAAI,EAGL,MAAM,yBAAyB,CAAC;AAGjC,eAAO,MAAM,sBAAsB,EAAE,OAAO,IAW1C,CAAC;AAKH,eAAO,MAAM,SAAS,kNAOrB,CAAC;AAIF,eAAO,MAAM,yBAAyB,yGAIpC,CAAC;AAKH,eAAO,MAAM,sBAAsB,kNAgBlC,CAAC;AAKF,eAAO,MAAM,WAAW,yGASvB,CAAC;AAIF,eAAO,MAAM,qBAAqB,wNAkBhC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionBuilder.styles.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,IAAI,EACJ,sBAAsB,EACtB,aAAa,EACd,MAAM,yBAAyB,CAAC;AAGjC,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAClD,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,eAAe,EAAE,YAAY,EAAE,OAAO,EAAE,EACjD,EACF,EAAE,EAAE;IACH,O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EAAE;IACH,MAAM,SAAS,GAAG,iBAAiB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACzD,OAAO,CACL,CAAC,SAAS;QACV,GAAG,CAAA;QACC,sBAAsB;qBACT,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAa,CAAC;uBAChD,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;uCACb,OAAO;;KAEzC,CACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,qBAAqB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport {\n calculateFontSize,\n defaultThemeProp,\n FieldGroup,\n Flex,\n StyledFieldGroupLegend,\n StyledPopover\n} from '@pega/cosmos-react-core';\nimport type { FontSize } from '@pega/cosmos-react-core';\n\nexport const StyledConditionBuilder = styled(Flex)(({\n theme: {\n base: { 'content-width': contentWidth, spacing }\n }\n}) => {\n return css`\n ${StyledPopover}:has(&) {\n min-inline-size: min(${contentWidth.lg}, calc(100vw - 4 * ${spacing}));\n max-inline-size: calc(100vw - 4 * ${spacing});\n }\n `;\n});\n\nStyledConditionBuilder.defaultProps = defaultThemeProp;\n\n// Styled wrapper for each Condition row\nexport const StyledRow = styled(Flex)`\n padding: 0.25rem;\n background: ${props => (props.shaded ? 'rgba(0, 0, 0, 0.05)' : 'transparent')};\n\n &:first-of-type {\n padding-top: 0;\n }\n`;\n\nStyledRow.defaultProps = defaultThemeProp;\n\nexport const StyledTimePeriodContainer = styled.div(({ theme }) => {\n return css`\n width: ${theme.base['content-width'].sm};\n `;\n});\n\nStyledTimePeriodContainer.defaultProps = defaultThemeProp;\n\n// Styled row-separators for Basic-mode\nexport const StyledRowWithSeparator = styled(StyledRow)`\n padding: 0 0.25rem;\n &::after,\n &::before {\n content: '';\n flex-grow: 1;\n background-image: linear-gradient(to right, rgba(0, 0, 0, 0.4) 60%, rgba(0, 0, 0, 0) 0%);\n background-position: left center;\n background-size: 0.5rem 0.0625rem;\n background-repeat: repeat-x;\n }\n\n &::before {\n width: 1rem;\n flex-grow: 0;\n }\n`;\n\nStyledRowWithSeparator.defaultProps = defaultThemeProp;\n\n// Styled label for the rows in Advanced-mode\nexport const StyledLabel = styled.div`\n font-weight: bold;\n line-height: 2rem;\n height: 2rem;\n width: 2rem;\n min-width: 2rem;\n margin-bottom: calc(0.125rem);\n text-align: center;\n background: rgba(0, 0, 0, 0.04);\n`;\n\nStyledLabel.defaultProps = defaultThemeProp;\n\nexport const StyledAtomicCondition = styled(FieldGroup)(({\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, spacing },\n components: { text }\n },\n collapsed\n}) => {\n const fontSizes = calculateFontSize(fontSize, fontScale);\n return (\n !collapsed &&\n css`\n ${StyledFieldGroupLegend} {\n font-size: ${fontSizes[text.secondary['font-size'] as FontSize]};\n font-weight: ${text.secondary['font-weight']};\n margin-block-end: calc(0.5 * ${spacing});\n }\n `\n );\n});\n\nStyledAtomicCondition.defaultProps = defaultThemeProp;\n"]}
1
+ {"version":3,"file":"ConditionBuilder.styles.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,IAAI,EACJ,sBAAsB,EACtB,aAAa,EACd,MAAM,yBAAyB,CAAC;AAGjC,MAAM,CAAC,MAAM,sBAAsB,GAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAC/D,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,eAAe,EAAE,YAAY,EAAE,OAAO,EAAE,EACjD,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;MACN,aAAa;6BACU,YAAY,CAAC,EAAE,sBAAsB,OAAO;0CAC/B,OAAO;;GAE9C,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,sBAAsB,CAAC,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SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAa,CAAC;uBAChD,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;uCACb,OAAO;;KAEzC,CACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,qBAAqB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport {\n calculateFontSize,\n defaultThemeProp,\n FieldGroup,\n Flex,\n StyledFieldGroupLegend,\n StyledPopover\n} from '@pega/cosmos-react-core';\nimport type { FontSize } from '@pega/cosmos-react-core';\n\nexport const StyledConditionBuilder: typeof Flex = styled(Flex)(({\n theme: {\n base: { 'content-width': contentWidth, spacing }\n }\n}) => {\n return css`\n ${StyledPopover}:has(&) {\n min-inline-size: min(${contentWidth.lg}, calc(100vw - 4 * ${spacing}));\n max-inline-size: calc(100vw - 4 * ${spacing});\n }\n `;\n});\n\nStyledConditionBuilder.defaultProps = defaultThemeProp;\n\n// Styled wrapper for each Condition row\nexport const StyledRow = styled(Flex)`\n padding: 0.25rem;\n background: ${props => (props.shaded ? 'rgba(0, 0, 0, 0.05)' : 'transparent')};\n\n &:first-of-type {\n padding-top: 0;\n }\n`;\n\nStyledRow.defaultProps = defaultThemeProp;\n\nexport const StyledTimePeriodContainer = styled.div(({ theme }) => {\n return css`\n width: ${theme.base['content-width'].sm};\n `;\n});\n\nStyledTimePeriodContainer.defaultProps = defaultThemeProp;\n\n// Styled row-separators for Basic-mode\nexport const StyledRowWithSeparator = styled(StyledRow)`\n padding: 0 0.25rem;\n &::after,\n &::before {\n content: '';\n flex-grow: 1;\n background-image: linear-gradient(to right, rgba(0, 0, 0, 0.4) 60%, rgba(0, 0, 0, 0) 0%);\n background-position: left center;\n background-size: 0.5rem 0.0625rem;\n background-repeat: repeat-x;\n }\n\n &::before {\n width: 1rem;\n flex-grow: 0;\n }\n`;\n\nStyledRowWithSeparator.defaultProps = defaultThemeProp;\n\n// Styled label for the rows in Advanced-mode\nexport const StyledLabel = styled.div`\n font-weight: bold;\n line-height: 2rem;\n height: 2rem;\n width: 2rem;\n min-width: 2rem;\n margin-bottom: calc(0.125rem);\n text-align: center;\n background: rgba(0, 0, 0, 0.04);\n`;\n\nStyledLabel.defaultProps = defaultThemeProp;\n\nexport const StyledAtomicCondition = styled(FieldGroup)(({\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, spacing },\n components: { text }\n },\n collapsed\n}) => {\n const fontSizes = calculateFontSize(fontSize, fontScale);\n return (\n !collapsed &&\n css`\n ${StyledFieldGroupLegend} {\n font-size: ${fontSizes[text.secondary['font-size'] as FontSize]};\n font-weight: ${text.secondary['font-weight']};\n margin-block-end: calc(0.5 * ${spacing});\n }\n `\n );\n});\n\nStyledAtomicCondition.defaultProps = defaultThemeProp;\n"]}
@@ -1,6 +1,7 @@
1
- import type { Ref } from 'react';
1
+ import type { ReactNode, Ref } from 'react';
2
2
  import type { BaseProps, MenuItemProps, NoChildrenProp } from '@pega/cosmos-react-core';
3
3
  import type { Comparator, ComparatorsByType, DateFunction, DatePart, FieldType, RHSType, TimePeriod } from './core/types';
4
+ import type { AtomicConditionProps } from './AtomicCondition';
4
5
  /** RHS object with a Date function */
5
6
  export interface RhsWithDateFunction {
6
7
  /**
@@ -49,6 +50,7 @@ export interface LeafCondition {
49
50
  start: string | number;
50
51
  end: string | number;
51
52
  } | RhsWithDateFunction | RhsWithRelativeDate | RhsWithParameter;
53
+ lhsType?: string;
52
54
  }
53
55
  /** Type definition for objects representing condition-rows in the builder UI */
54
56
  export interface ConditionRow extends LeafCondition {
@@ -110,17 +112,28 @@ export interface DateFunctionsByType {
110
112
  /** Date functions to enable for DATE_ONLY fields */
111
113
  DATE_ONLY: DateFunction[];
112
114
  }
115
+ export type ValidationOptions = {
116
+ /**
117
+ * Whether to validate individual condition rows for completeness.
118
+ *
119
+ * When `true` (default): Validates each row's LHS, comparator, and RHS fields
120
+ * When `false`: Only validates the overall logic string structure
121
+ */
122
+ performRowValidation?: boolean;
123
+ };
113
124
  export interface HandleValue {
114
125
  /**
115
126
  * Returns condition validity and condition or undefined if valid.
116
127
  * Undefined indicates no condition.
117
128
  */
118
- getCondition: () => [valid: false] | [valid: true, condition: Condition | undefined];
129
+ getCondition: (options?: ValidationOptions) => [valid: false] | [valid: true, condition: Condition | undefined];
130
+ getLogicError: () => string | null;
119
131
  }
120
132
  /** Type definition for the input props of ConditionBuilder */
121
133
  export default interface ConditionBuilderProps extends BaseProps, NoChildrenProp {
122
134
  /** Metadata (data-model) for the Fields to use in the builder */
123
135
  fields: Field[];
136
+ conditionRenderer?: (props: AtomicConditionProps) => ReactNode;
124
137
  /** (Optional) A seed condition for the builder. To use when editing an existing condition */
125
138
  condition?: Condition;
126
139
  /** (Optional) Used to limit the Comparators allowed in the builder. */
@@ -137,6 +150,18 @@ export default interface ConditionBuilderProps extends BaseProps, NoChildrenProp
137
150
  disallowNOT?: boolean;
138
151
  /** Imperative handle for the component. */
139
152
  handle?: Ref<HandleValue>;
153
+ /**
154
+ * Callback fired when logic string validation error occurs or clears.
155
+ */
156
+ onLogicError?: (error: string | null) => void;
157
+ /** Makes the input non editable and non clickable. The browser defaults to false. */
158
+ readOnly?: boolean;
159
+ /** Disable the control. The browser defaults to false. */
160
+ disabled?: boolean;
161
+ /**
162
+ * Ref to access the root HTMLDivElement of the ConditionBuilder.
163
+ */
164
+ ref?: Ref<HTMLDivElement>;
140
165
  }
141
166
  export {};
142
167
  //# sourceMappingURL=ConditionBuilder.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionBuilder.types.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAExF,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,YA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CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC,CAAC;CACtF;AAED,8DAA8D;AAC9D,MAAM,CAAC,OAAO,WAAW,qBAAsB,SAAQ,SAAS,EAAE,cAAc;IAC9E,iEAAiE;IACjE,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB,6FAA6F;IAC7F,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB,uEAAuE;IACvE,gBAAgB,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAEvC;;;;OAIG;IACH,aAAa,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAE7B,iJAAiJ;IACjJ,aAAa,CAAC,EAAE,mBAAmB,CAAC;IAEpC,iFAAiF;IACjF,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CAC3B"}
1
+ {"version":3,"file":"ConditionBuilder.types.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAExF,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,OAAO,EACP,UAAU,EACX,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,sCAAsC;AACtC,MAAM,WAAW,mBAAmB;IAClC;;;;;;;;;;;;;;OAcG;IACH,KAAK,EAAE,MAAM,GAAG,MAAM,CAA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;OAGG;IACH,YAAY,EAAE,CACZ,OAAO,CAAC,EAAE,iBAAiB,KACxB,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC,CAAC;IACtE,aAAa,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;CACpC;AAED,8DAA8D;AAC9D,MAAM,CAAC,OAAO,WAAW,qBAAsB,SAAQ,SAAS,EAAE,cAAc;IAC9E,iEAAiE;IACjE,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,SAAS,CAAC;IAE/D,6FAA6F;IAC7F,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB,uEAAuE;IACvE,gBAAgB,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAEvC;;;;OAIG;IACH,aAAa,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAE7B,iJAAiJ;IACjJ,aAAa,CAAC,EAAE,mBAAmB,CAAC;IAEpC,iFAAiF;IACjF,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;IAE1B;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAE9C,qFAAqF;IACrF,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionBuilder.types.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.types.ts"],"names":[],"mappings":"","sourcesContent":["// cspell:words DDTHH\nimport type { Ref } from 'react';\n\nimport type { BaseProps, MenuItemProps, NoChildrenProp } from '@pega/cosmos-react-core';\n\nimport type {\n Comparator,\n ComparatorsByType,\n DateFunction,\n DatePart,\n FieldType,\n RHSType,\n TimePeriod\n} from './core/types';\n\n/** RHS object with a Date function */\nexport interface RhsWithDateFunction {\n /**\n * Output format for the value varies based on the dateFunction:\n * YEARS: First day of year as YYYY-MM-DD\n * QUARTERS: First day of quarter as YYYY-MM-DD\n * MONTHS: First day of month as YYYY-MM-DD\n * WEEKS: First day of week as YYYY-MM-DD\n * DAYS: Date as YYYY-MM-DD\n * HOURS: YYYY-MM-DDTHH:mm:ss\n * MINUTES: YYYY-MM-DDTHH:mm:ss\n * SECONDS: YYYY-MM-DDTHH:mm:ss\n * HOURS_OF_DAY: 0-23\n * MONTHS_OF_YEAR: 1-12\n * DAYS_OF_MONTH: 1-31\n * DAYS_OF_WEEK: 1-7\n */\n value: string | number;\n dateFunction: DateFunction;\n}\n\n/** RHS object with a Relative Date */\nexport interface RhsWithRelativeDate {\n relativeDate: {\n timePeriod: TimePeriod;\n interval?: number;\n datePart: DatePart;\n };\n}\n\n/** RHS object with PARAMETER type */\nexport interface RhsWithParameter {\n parameterId: string;\n}\n\n/** Type definition for the leaf-level nodes in nested conditions */\nexport interface LeafCondition {\n comparator: Comparator;\n\n lhs: {\n field: string;\n };\n\n // Optional for some of the comparators like IS_TRUE, IS_NULL, etc.\n rhs?:\n | { field: string } // When comparing the LHS with another field\n | { value: string | number } // When comparing the LHS with a single literal value (for comparators like EQ, GTE etc.)\n | { values: string[] | number[] } // When comparing the LHS with a list of literal values (for comparators like IN, NOT_IN etc.)\n | { start: string | number; end: string | number } // When comparing numeric or date field with two values that determine range\n | RhsWithDateFunction // When comparing a date field with a date function on RHS\n | RhsWithRelativeDate // When comparing a date field with a symbolic date on RHS\n | RhsWithParameter; // When comparing the LHS with PARAMETER type\n}\n\n/** Type definition for objects representing condition-rows in the builder UI */\nexport interface ConditionRow extends LeafCondition {\n id: string; // To use as `key` prop when rendering a list of rows\n label: string; // Used to refer the row from a logic-string\n}\n\n/**\n * Type definition for simple/complex conditions\n * At a given node in the condition tree, it can have exactly one of the keys AND/OR/NOT/condition\n */\nexport type Condition =\n | { AND: Condition[] }\n | { OR: Condition[] }\n | { NOT: Condition }\n | { condition: LeafCondition };\n\n/** Type definition for the input Field objects for the ConditionBuilder */\n\nexport type ParameterValue = Pick<MenuItemProps, 'id' | 'primary'>;\n\nexport type ReferenceValue = Pick<MenuItemProps, 'id' | 'primary'>;\n\nexport type ValueSelectionFunction<F> = (\n args:\n | { lhs?: F; ids: string[] }\n | {\n lhs?: F;\n searchString?: string; // If missing, assume empty string\n comparator?: string; // If missing, assume EQ\n\n // If the below are missing, fetch maximum possible results\n pageNumber?: number;\n pageSize?: number;\n }\n) => Promise<string[] | ReferenceValue[]>;\n\nexport type ValueSelection<F> = string[] | ReferenceValue[] | ValueSelectionFunction<F>;\n\ninterface BasicField extends Pick<MenuItemProps, 'id' | 'primary'> {}\n\nexport type Field = BasicField &\n (\n | {\n parameters?: ParameterValue[];\n\n /**\n * For TEXT fields, if a list of possible values is known ahead of time, they can be passed.\n * Otherwise we fetch data from api and pass a promise which returns list of values\n * This enables users to select from those values instead of manually typing them\n */\n possibleValues?: ValueSelection<Field>;\n\n /**\n * Data-type for the field.\n * Has to be one of these values. Convert where necessary\n * e.g. Currency/Percentage... should be used as `DECIMAL`\n * e.g. Text(single value)/Picklist/... should be used as `TEXT`\n */\n type: FieldType;\n }\n | {\n /** An array of type Field to represent the child items. */\n items: Field[];\n }\n );\n\n/** Valid date functions by field type */\nexport interface DateFunctionsByType {\n /** Date functions to enable for DATE_TIME fields */\n DATE_TIME: DateFunction[];\n /** Date functions to enable for DATE_ONLY fields */\n DATE_ONLY: DateFunction[];\n}\n\nexport interface HandleValue {\n /**\n * Returns condition validity and condition or undefined if valid.\n * Undefined indicates no condition.\n */\n getCondition: () => [valid: false] | [valid: true, condition: Condition | undefined];\n}\n\n/** Type definition for the input props of ConditionBuilder */\nexport default interface ConditionBuilderProps extends BaseProps, NoChildrenProp {\n /** Metadata (data-model) for the Fields to use in the builder */\n fields: Field[];\n\n /** (Optional) A seed condition for the builder. To use when editing an existing condition */\n condition?: Condition;\n\n /** (Optional) Used to limit the Comparators allowed in the builder. */\n validComparators?: ComparatorsByType[];\n\n /**\n * (Optional) Pass this to control which all types of RHS are enabled in the component\n * DEFAULT: Set(['LITERAL', 'FIELD'])\n * NOTE: If enabling `DATE_FUNCTION`s, additionally pass a `dateFunctions` prop to specify which functions are enabled\n */\n validRhsTypes?: Set<RHSType>;\n\n /** (Optional) When enabling 'DATE_FUNCTION's via `validRhsTypes`, pass this to specify which all date functions are applicable per field type */\n dateFunctions?: DateFunctionsByType;\n\n /** (Optional) Pass this if the `NOT` operator should be considered as invalid */\n disallowNOT?: boolean;\n\n /** Imperative handle for the component. */\n handle?: Ref<HandleValue>;\n}\n"]}
1
+ {"version":3,"file":"ConditionBuilder.types.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.types.ts"],"names":[],"mappings":"","sourcesContent":["// cspell:words DDTHH\nimport type { ReactNode, Ref } from 'react';\n\nimport type { BaseProps, MenuItemProps, NoChildrenProp } from '@pega/cosmos-react-core';\n\nimport type {\n Comparator,\n ComparatorsByType,\n DateFunction,\n DatePart,\n FieldType,\n RHSType,\n TimePeriod\n} from './core/types';\nimport type { AtomicConditionProps } from './AtomicCondition';\n\n/** RHS object with a Date function */\nexport interface RhsWithDateFunction {\n /**\n * Output format for the value varies based on the dateFunction:\n * YEARS: First day of year as YYYY-MM-DD\n * QUARTERS: First day of quarter as YYYY-MM-DD\n * MONTHS: First day of month as YYYY-MM-DD\n * WEEKS: First day of week as YYYY-MM-DD\n * DAYS: Date as YYYY-MM-DD\n * HOURS: YYYY-MM-DDTHH:mm:ss\n * MINUTES: YYYY-MM-DDTHH:mm:ss\n * SECONDS: YYYY-MM-DDTHH:mm:ss\n * HOURS_OF_DAY: 0-23\n * MONTHS_OF_YEAR: 1-12\n * DAYS_OF_MONTH: 1-31\n * DAYS_OF_WEEK: 1-7\n */\n value: string | number;\n dateFunction: DateFunction;\n}\n\n/** RHS object with a Relative Date */\nexport interface RhsWithRelativeDate {\n relativeDate: {\n timePeriod: TimePeriod;\n interval?: number;\n datePart: DatePart;\n };\n}\n\n/** RHS object with PARAMETER type */\nexport interface RhsWithParameter {\n parameterId: string;\n}\n\n/** Type definition for the leaf-level nodes in nested conditions */\nexport interface LeafCondition {\n comparator: Comparator;\n\n lhs: {\n field: string;\n };\n\n // Optional for some of the comparators like IS_TRUE, IS_NULL, etc.\n rhs?:\n | { field: string } // When comparing the LHS with another field\n | { value: string | number } // When comparing the LHS with a single literal value (for comparators like EQ, GTE etc.)\n | { values: string[] | number[] } // When comparing the LHS with a list of literal values (for comparators like IN, NOT_IN etc.)\n | { start: string | number; end: string | number } // When comparing numeric or date field with two values that determine range\n | RhsWithDateFunction // When comparing a date field with a date function on RHS\n | RhsWithRelativeDate // When comparing a date field with a symbolic date on RHS\n | RhsWithParameter; // When comparing the LHS with PARAMETER type\n lhsType?: string;\n}\n\n/** Type definition for objects representing condition-rows in the builder UI */\nexport interface ConditionRow extends LeafCondition {\n id: string; // To use as `key` prop when rendering a list of rows\n label: string; // Used to refer the row from a logic-string\n}\n\n/**\n * Type definition for simple/complex conditions\n * At a given node in the condition tree, it can have exactly one of the keys AND/OR/NOT/condition\n */\nexport type Condition =\n | { AND: Condition[] }\n | { OR: Condition[] }\n | { NOT: Condition }\n | { condition: LeafCondition };\n\n/** Type definition for the input Field objects for the ConditionBuilder */\n\nexport type ParameterValue = Pick<MenuItemProps, 'id' | 'primary'>;\n\nexport type ReferenceValue = Pick<MenuItemProps, 'id' | 'primary'>;\n\nexport type ValueSelectionFunction<F> = (\n args:\n | { lhs?: F; ids: string[] }\n | {\n lhs?: F;\n searchString?: string; // If missing, assume empty string\n comparator?: string; // If missing, assume EQ\n\n // If the below are missing, fetch maximum possible results\n pageNumber?: number;\n pageSize?: number;\n }\n) => Promise<string[] | ReferenceValue[]>;\n\nexport type ValueSelection<F> = string[] | ReferenceValue[] | ValueSelectionFunction<F>;\n\ninterface BasicField extends Pick<MenuItemProps, 'id' | 'primary'> {}\n\nexport type Field = BasicField &\n (\n | {\n parameters?: ParameterValue[];\n\n /**\n * For TEXT fields, if a list of possible values is known ahead of time, they can be passed.\n * Otherwise we fetch data from api and pass a promise which returns list of values\n * This enables users to select from those values instead of manually typing them\n */\n possibleValues?: ValueSelection<Field>;\n\n /**\n * Data-type for the field.\n * Has to be one of these values. Convert where necessary\n * e.g. Currency/Percentage... should be used as `DECIMAL`\n * e.g. Text(single value)/Picklist/... should be used as `TEXT`\n */\n type: FieldType;\n }\n | {\n /** An array of type Field to represent the child items. */\n items: Field[];\n }\n );\n\n/** Valid date functions by field type */\nexport interface DateFunctionsByType {\n /** Date functions to enable for DATE_TIME fields */\n DATE_TIME: DateFunction[];\n /** Date functions to enable for DATE_ONLY fields */\n DATE_ONLY: DateFunction[];\n}\n\nexport type ValidationOptions = {\n /**\n * Whether to validate individual condition rows for completeness.\n *\n * When `true` (default): Validates each row's LHS, comparator, and RHS fields\n * When `false`: Only validates the overall logic string structure\n */\n performRowValidation?: boolean;\n};\n\nexport interface HandleValue {\n /**\n * Returns condition validity and condition or undefined if valid.\n * Undefined indicates no condition.\n */\n getCondition: (\n options?: ValidationOptions\n ) => [valid: false] | [valid: true, condition: Condition | undefined];\n getLogicError: () => string | null;\n}\n\n/** Type definition for the input props of ConditionBuilder */\nexport default interface ConditionBuilderProps extends BaseProps, NoChildrenProp {\n /** Metadata (data-model) for the Fields to use in the builder */\n fields: Field[];\n\n conditionRenderer?: (props: AtomicConditionProps) => ReactNode;\n\n /** (Optional) A seed condition for the builder. To use when editing an existing condition */\n condition?: Condition;\n\n /** (Optional) Used to limit the Comparators allowed in the builder. */\n validComparators?: ComparatorsByType[];\n\n /**\n * (Optional) Pass this to control which all types of RHS are enabled in the component\n * DEFAULT: Set(['LITERAL', 'FIELD'])\n * NOTE: If enabling `DATE_FUNCTION`s, additionally pass a `dateFunctions` prop to specify which functions are enabled\n */\n validRhsTypes?: Set<RHSType>;\n\n /** (Optional) When enabling 'DATE_FUNCTION's via `validRhsTypes`, pass this to specify which all date functions are applicable per field type */\n dateFunctions?: DateFunctionsByType;\n\n /** (Optional) Pass this if the `NOT` operator should be considered as invalid */\n disallowNOT?: boolean;\n\n /** Imperative handle for the component. */\n handle?: Ref<HandleValue>;\n\n /**\n * Callback fired when logic string validation error occurs or clears.\n */\n onLogicError?: (error: string | null) => void;\n\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: boolean;\n\n /** Disable the control. The browser defaults to false. */\n disabled?: boolean;\n\n /**\n * Ref to access the root HTMLDivElement of the ConditionBuilder.\n */\n ref?: Ref<HTMLDivElement>;\n}\n"]}
@@ -20,5 +20,5 @@ import type { Condition, Field } from '../ConditionBuilder.types';
20
20
  * `["2025-05-12T11:24:45.000", "2025-05-12T11:24:45.999"]`.
21
21
  *
22
22
  */
23
- export default function transformComplexCondition(condition: Condition, fields: Field[], currentDateTime?: string, timezone?: string): Condition;
23
+ export default function transformComplexCondition(condition: Condition, fields: Field[], transformRelativeDate?: boolean, currentDateTime?: string, timezone?: string): Condition;
24
24
  //# sourceMappingURL=transformer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/core/transformer.ts"],"names":[],"mappings":"AAGA,OAAO,eAAe,CAAC;AAIvB,OAAO,KAAK,EAAE,SAAS,EAAiB,KAAK,EAAE,MAAM,2BAA2B,CAAC;AA2TjF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,KAAK,EAAE,EACf,eAAe,CAAC,EAAE,MAAM,EACxB,QAAQ,CAAC,EAAE,MAAM,GAChB,SAAS,CA0BX"}
1
+ {"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/core/transformer.ts"],"names":[],"mappings":"AAGA,OAAO,eAAe,CAAC;AAIvB,OAAO,KAAK,EAAE,SAAS,EAAiB,KAAK,EAAE,MAAM,2BAA2B,CAAC;AA4TjF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,KAAK,EAAE,EACf,qBAAqB,UAAO,EAC5B,eAAe,CAAC,EAAE,MAAM,EACxB,QAAQ,CAAC,EAAE,MAAM,GAChB,SAAS,CAsCX"}
@@ -154,7 +154,7 @@ function getConditionFromRange(startDate, endDate, node, lhsFieldType, timezone)
154
154
  return { condition: node };
155
155
  }
156
156
  }
157
- function transformLeafCondition(node, fields, currentDateTime, timezone) {
157
+ function transformLeafCondition(node, fields, transformRelativeDate = true, currentDateTime, timezone) {
158
158
  const field = getItem(fields, node.lhs.field);
159
159
  if (!field || !hasProp(field, 'type')) {
160
160
  return { condition: node }; // Safety check
@@ -196,7 +196,7 @@ function transformLeafCondition(node, fields, currentDateTime, timezone) {
196
196
  }
197
197
  }
198
198
  // Transform Relative date filters into equivalent date range filters
199
- if (node.rhs && hasProp(node.rhs, 'relativeDate')) {
199
+ if (node.rhs && transformRelativeDate && hasProp(node.rhs, 'relativeDate')) {
200
200
  const { timePeriod, interval, datePart } = node.rhs.relativeDate;
201
201
  const dayjsDatePart = dayjsDateParts[datePart];
202
202
  const now = !currentDateTime || isAbsoluteDateString(currentDateTime)
@@ -280,24 +280,24 @@ function transformLeafCondition(node, fields, currentDateTime, timezone) {
280
280
  * `["2025-05-12T11:24:45.000", "2025-05-12T11:24:45.999"]`.
281
281
  *
282
282
  */
283
- export default function transformComplexCondition(condition, fields, currentDateTime, timezone) {
283
+ export default function transformComplexCondition(condition, fields, transformRelativeDate = true, currentDateTime, timezone) {
284
284
  if (hasProp(condition, 'AND')) {
285
- const childNodes = condition.AND.map(n => transformComplexCondition(n, fields, currentDateTime, timezone));
285
+ const childNodes = condition.AND.map(n => transformComplexCondition(n, fields, transformRelativeDate, currentDateTime, timezone));
286
286
  return {
287
287
  AND: childNodes
288
288
  };
289
289
  }
290
290
  if (hasProp(condition, 'OR')) {
291
- const childNodes = condition.OR.map(n => transformComplexCondition(n, fields, currentDateTime, timezone));
291
+ const childNodes = condition.OR.map(n => transformComplexCondition(n, fields, transformRelativeDate, currentDateTime, timezone));
292
292
  return {
293
293
  OR: childNodes
294
294
  };
295
295
  }
296
296
  if (hasProp(condition, 'NOT')) {
297
297
  return {
298
- NOT: transformComplexCondition(condition.NOT, fields, currentDateTime, timezone)
298
+ NOT: transformComplexCondition(condition.NOT, fields, transformRelativeDate, currentDateTime, timezone)
299
299
  };
300
300
  }
301
- return transformLeafCondition(condition.condition, fields, currentDateTime, timezone);
301
+ return transformLeafCondition(condition.condition, fields, transformRelativeDate, currentDateTime, timezone);
302
302
  }
303
303
  //# sourceMappingURL=transformer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transformer.js","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/core/transformer.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,eAAe,CAAC;AAEvB,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGlD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAExD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,cAAc,GAAgC;IAClD,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,QAAQ;IACjB,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,KAAK;IACX,KAAK,EAAE,MAAmB;IAC1B,QAAQ,EAAE,SAAS;IACnB,MAAM,EAAE,OAAO;IACf,KAAK,EAA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,CAAC;QACD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;IAChC,CAAC;IAED,sBAAsB;IACtB,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,SAAoB,EACpB,MAAe,EACf,eAAwB,EACxB,QAAiB;IAEjB,IAAI,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,UAAU,GAAgB,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CACpD,yBAAyB,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,QAAQ,CAAC,CAChE,CAAC;QACF,OAAO;YACL,GAAG,EAAE,UAAU;SAChB,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC;QAC7B,MAAM,UAAU,GAAgB,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CACnD,yBAAyB,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,QAAQ,CAAC,CAChE,CAAC;QACF,OAAO;YACL,EAAE,EAAE,UAAU;SACf,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO;YACL,GAAG,EAAE,yBAAyB,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,QAAQ,CAAC;SACjF,CAAC;IACJ,CAAC;IAED,OAAO,sBAAsB,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;AACxF,CAAC","sourcesContent":["// cspell:words DDTHH\nimport dayjs from 'dayjs';\nimport type { Dayjs, QUnitType } from 'dayjs';\nimport './extendDayJs';\n\nimport { hasProp } from '@pega/cosmos-react-core';\n\nimport type { Condition, LeafCondition, Field } from '../ConditionBuilder.types';\nimport { truncateISODateString } from '../RhsControls';\n\nimport { getItem, isAbsoluteDateString } from './utils';\nimport type { DatePart, FieldType } from './types';\nimport { convertTimeValueToMs } from './time-utils';\n\nconst dayjsDateParts: Record<DatePart, QUnitType> = {\n SECONDS: 'second',\n MINUTES: 'minute',\n HOURS: 'hour',\n DAYS: 'day',\n WEEKS: 'week' as QUnitType,\n QUARTERS: 'quarter',\n MONTHS: 'month',\n YEARS: 'year'\n};\n\n/** Construct Condition with two range comparators based on the given bounds */\nfunction getConditionForBetweenComparator(\n start: string | number,\n end: string | number,\n node: LeafCondition\n): Condition {\n return node.comparator === 'BTW'\n ? {\n AND: [\n {\n condition: {\n lhs: node.lhs,\n comparator: 'GTE',\n rhs: { value: start }\n }\n },\n {\n condition: {\n lhs: node.lhs,\n comparator: 'LTE',\n rhs: { value: end }\n }\n }\n ]\n }\n : {\n OR: [\n {\n condition: {\n lhs: node.lhs,\n comparator: 'LT',\n rhs: { value: start }\n }\n },\n {\n condition: {\n lhs: node.lhs,\n comparator: 'GT',\n rhs: { value: end }\n }\n }\n ]\n };\n}\n\nfunction getDateStringInTimezone(d: Dayjs, tz: string): string {\n return d.tz(tz).format('YYYY-MM-DDTHH:mm:ss.SSS');\n}\n\n/** Construct a date-range filter based on the given date bounds and the comparator */\nfunction getConditionFromRange(\n startDate: Dayjs,\n endDate: Dayjs,\n node: LeafCondition,\n lhsFieldType: FieldType,\n timezone?: string\n): Condition {\n const formatDate = (d: Dayjs, tz?: string): string => {\n let isoString: string;\n if (tz) {\n isoString = getDateStringInTimezone(d, tz);\n } else {\n const time = d.toDate().getTime();\n const timezoneOffset = new Date(time).getTimezoneOffset() * 60000;\n isoString = new Date(time - timezoneOffset).toISOString().slice(0, -1);\n }\n if (lhsFieldType === 'TIME_ONLY') return truncateISODateString(isoString, lhsFieldType);\n if (lhsFieldType === 'DATE_ONLY') return isoString.substring(0, isoString.indexOf('T'));\n return isoString;\n };\n\n switch (node.comparator) {\n case 'EQ':\n return {\n AND: [\n {\n condition: {\n lhs: node.lhs,\n comparator: 'LTE',\n rhs: { value: formatDate(endDate, timezone) }\n }\n },\n {\n condition: {\n lhs: node.lhs,\n comparator: 'GTE',\n rhs: { value: formatDate(startDate, timezone) }\n }\n }\n ]\n };\n case 'NEQ':\n return {\n OR: [\n {\n condition: {\n lhs: node.lhs,\n comparator: 'GT',\n rhs: { value: formatDate(endDate, timezone) }\n }\n },\n {\n condition: {\n lhs: node.lhs,\n comparator: 'LT',\n rhs: { value: formatDate(startDate, timezone) }\n }\n }\n ]\n };\n case 'GT':\n return {\n condition: {\n lhs: node.lhs,\n comparator: 'GT',\n rhs: { value: formatDate(endDate, timezone) }\n }\n };\n case 'GTE':\n return {\n condition: {\n lhs: node.lhs,\n comparator: 'GTE',\n rhs: { value: formatDate(startDate, timezone) }\n }\n };\n case 'LT':\n return {\n condition: {\n lhs: node.lhs,\n comparator: 'LT',\n rhs: { value: formatDate(startDate, timezone) }\n }\n };\n case 'LTE':\n return {\n condition: {\n lhs: node.lhs,\n comparator: 'LTE',\n rhs: { value: formatDate(endDate, timezone) }\n }\n };\n case 'BTW':\n case 'NOT_BTW':\n return getConditionForBetweenComparator(\n formatDate(startDate, timezone),\n formatDate(endDate, timezone),\n node\n );\n default:\n return { condition: node };\n }\n}\n\nfunction transformLeafCondition(\n node: LeafCondition,\n fields: Field[],\n currentDateTime?: string,\n timezone?: string\n): Condition {\n const field = getItem(fields, node.lhs.field);\n\n if (!field || !hasProp(field, 'type')) {\n return { condition: node }; // Safety check\n }\n\n if (\n (node.comparator === 'EQ' || node.comparator === 'NEQ') &&\n node.rhs &&\n hasProp(node.rhs, 'value') &&\n Object.keys(node.rhs).length === 1 &&\n typeof node.rhs.value === 'string'\n ) {\n const dateTime = node.rhs.value;\n\n const timePartsCount = dateTime.split(':').length;\n if (field.type === 'DATE_TIME') {\n const date = isAbsoluteDateString(dateTime)\n ? dayjs(dateTime).tz(timezone)\n : dayjs.tz(dateTime, timezone);\n let startDate = date;\n let endDate = date;\n // For HH:MM:SS expand milliseconds to 0-999\n if (timePartsCount === 3) {\n startDate = startDate.millisecond(0);\n endDate = endDate.millisecond(999);\n\n return getConditionFromRange(startDate, endDate, node, field.type, timezone);\n }\n // HH:MM expand seconds to 0-59\n if (timePartsCount === 2) {\n startDate = startDate.second(0).millisecond(0);\n endDate = endDate.second(59).millisecond(999);\n return getConditionFromRange(startDate, endDate, node, field.type, timezone);\n }\n } else if (field.type === 'TIME_ONLY') {\n const dateTimeMs = convertTimeValueToMs(node.rhs.value);\n\n // HH:MM expand seconds to 0-59\n if (timePartsCount === 2) {\n const startDate = dayjs(dateTimeMs).tz(timezone).second(0).millisecond(0);\n const endDate = dayjs(dateTimeMs).tz(timezone).second(59).millisecond(0);\n return getConditionFromRange(startDate, endDate, node, field.type, timezone);\n }\n }\n }\n\n // Transform Relative date filters into equivalent date range filters\n if (node.rhs && hasProp(node.rhs, 'relativeDate')) {\n const { timePeriod, interval, datePart } = node.rhs.relativeDate;\n const dayjsDatePart = dayjsDateParts[datePart];\n const now =\n !currentDateTime || isAbsoluteDateString(currentDateTime)\n ? dayjs.utc(dayjs(currentDateTime).tz(timezone))\n : dayjs.tz(currentDateTime, timezone);\n\n let startDate = now;\n let endDate = now;\n if (timePeriod === 'CURRENT') {\n startDate = now.startOf(dayjsDatePart);\n endDate = now.endOf(dayjsDatePart);\n } else if (timePeriod === 'LAST' && interval && interval >= 1) {\n startDate = now.subtract(interval, dayjsDatePart);\n } else if (timePeriod === 'PREVIOUS' && interval && interval >= 1) {\n startDate = now.startOf(dayjsDatePart).subtract(interval, dayjsDatePart);\n endDate = now.subtract(1, dayjsDatePart).endOf(dayjsDatePart);\n } else if (timePeriod === 'NEXT' && interval && interval >= 1) {\n startDate = now.add(1, dayjsDatePart).startOf(dayjsDatePart);\n endDate = now.endOf(dayjsDatePart).add(interval, dayjsDatePart);\n }\n\n return getConditionFromRange(\n startDate.tz(timezone),\n endDate.tz(timezone),\n node,\n field.type,\n timezone\n );\n }\n\n // Transform WEEKS-filters into equivalent date-range filters\n // NOTE: This is a work-around until we make startOfDay customizable for Weeks\n if (node.rhs && hasProp(node.rhs, 'dateFunction') && node.rhs.dateFunction === 'WEEKS') {\n const startDate =\n typeof node.rhs.value === 'number' || isAbsoluteDateString(node.rhs.value)\n ? dayjs.utc(dayjs(node.rhs.value).tz(timezone)).startOf('day').tz(timezone)\n : dayjs.tz(node.rhs.value, timezone).startOf('day'); // Since we store it as YYYY-MM-DD, it's already the start of day\n\n const endDate = startDate.add(7, 'day').subtract(1, 'millisecond'); // Last millisecond on the 7th day from startDate\n return getConditionFromRange(startDate, endDate, node, field.type, timezone);\n }\n\n // Transform double range comparators (BTW, NOT_BTW) into equivalent pair of single range comparators\n if (node.rhs && hasProp(node.rhs, 'start')) {\n if (field.type === 'DECIMAL' || field.type === 'INTEGER' || field.type === 'TIME_ONLY') {\n return getConditionForBetweenComparator(node.rhs.start, node.rhs.end, node);\n }\n\n const startDate =\n typeof node.rhs.start === 'number' || isAbsoluteDateString(node.rhs.start)\n ? dayjs(node.rhs.start).tz(timezone)\n : dayjs.tz(node.rhs.start, timezone);\n const endDate =\n typeof node.rhs.end === 'number' || isAbsoluteDateString(node.rhs.end)\n ? dayjs(node.rhs.end).tz(timezone)\n : dayjs.tz(node.rhs.end, timezone);\n\n return getConditionFromRange(startDate, endDate, node, field.type, timezone);\n }\n\n // apply timezone to date-time fields\n if (timezone && field.type === 'DATE_TIME' && node.rhs && !hasProp(node.rhs, 'dateFunction')) {\n const newNode: LeafCondition = { ...node };\n if (newNode.rhs && hasProp(newNode.rhs, 'value')) {\n newNode.rhs.value = getDateStringInTimezone(\n typeof newNode.rhs.value === 'number' || isAbsoluteDateString(newNode.rhs.value)\n ? dayjs(newNode.rhs.value)\n : dayjs.tz(newNode.rhs.value, timezone),\n timezone\n );\n }\n if (newNode.rhs && hasProp(newNode.rhs, 'values')) {\n const valuesWithTimezone = newNode.rhs.values.map(v =>\n getDateStringInTimezone(\n typeof v === 'number' || isAbsoluteDateString(v) ? dayjs(v) : dayjs.tz(v, timezone),\n timezone\n )\n );\n newNode.rhs.values = valuesWithTimezone;\n }\n return { condition: newNode };\n }\n\n // For all other cases\n return { condition: node };\n}\n\n/** This function transforms Conditions with Relative Dates into Conditions with Date Ranges.\n * Do not use this function unless you need to convert Relative Dates into Date Ranges.\n *\n * If `currentDateTime` is not provided, the current system time will be used.\n * If `timezone` is not provided, the system's timezone will be used for conversion.\n *\n * The `timezone` prop is applied to the date-time values within the condition when the transformation occurs.\n * If `timezone` is specified, the date-time will be converted from UTC (or the provided reference time) to the specified timezone.\n * Then, the transformed date will be used to generate a range.\n * This transformation ensures that the start and end times account for timezone differences when considering the condition's range.\n *\n * For example:\n * - A UTC date-time `2025-05-12T11:24:45.946Z` will be transformed to `2025-05-12T07:24:45.946-04:00` (in the `-04:00` timezone).\n * The date-time will then be converted into a range:\n * `[\"2025-05-12T07:24:45.000\", \"2025-05-12T07:24:45.999\"]`.\n * - A date-time without a timezone (`2025-05-12T11:24:45.946`) will be parsed in the timezone (e.g., `-04:00`).\n * The parsed time will then be transformed into a range like:\n * `[\"2025-05-12T11:24:45.000\", \"2025-05-12T11:24:45.999\"]`.\n *\n */\nexport default function transformComplexCondition(\n condition: Condition,\n fields: Field[],\n currentDateTime?: string,\n timezone?: string\n): Condition {\n if (hasProp(condition, 'AND')) {\n const childNodes: Condition[] = condition.AND.map(n =>\n transformComplexCondition(n, fields, currentDateTime, timezone)\n );\n return {\n AND: childNodes\n };\n }\n\n if (hasProp(condition, 'OR')) {\n const childNodes: Condition[] = condition.OR.map(n =>\n transformComplexCondition(n, fields, currentDateTime, timezone)\n );\n return {\n OR: childNodes\n };\n }\n\n if (hasProp(condition, 'NOT')) {\n return {\n NOT: transformComplexCondition(condition.NOT, fields, currentDateTime, timezone)\n };\n }\n\n return transformLeafCondition(condition.condition, fields, currentDateTime, timezone);\n}\n"]}
1
+ {"version":3,"file":"transformer.js","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/core/transformer.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,eAAe,CAAC;AAEvB,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGlD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAExD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,cAAc,GAAgC;IAClD,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,QAAQ;IACjB,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,KAAK;IACX,KAAK,EAAE,MAAmB;IAC1B,QAAQ,EAAE,SAAS;IACnB,MAAM,EAAE,OAAO;IACf,KAAK,EAAE,MAAM;CACd,CAAC;AAEF,+EAA+E;AAC/E,SAAS,gCAAgC,CACvC,KAAsB,EACtB,GAAoB,EACpB,IAAmB;IAEnB,OAAO,IAAI,CAAC,UAAU,KAAK,KAAK;QAC9B,CAAC,CAAC;YACE,GAAG,EAAE;gBACH;oBACE,SAAS,EAAE;wBACT,GAAG,EAAE,IAAI,CAAC,GAAG;wBACb,UAAU,EAAE,KAAK;wBACjB,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE;qBACtB;iBACF;gBACD;oBACE,SAAS,EAAE;wBACT,GAAG,EAAE,IAAI,CAAC,GAAG;wBACb,UAAU,EAAE,KAAK;wBACjB,GAAG,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE;qBACpB;iBACF;aACF;SACF;QACH,CAAC,CAAC;YACE,EAAE,EAAE;gBACF;oBACE,SAAS,EAAE;wBACT,GAAG,EAAE,IAAI,CAAC,GAAG;wBACb,UAAU,EAAE,IAAI;wBAChB,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE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AO,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC;QAC7B,MAAM,UAAU,GAAgB,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CACnD,yBAAyB,CAAC,CAAC,EAAE,MAAM,EAAE,qBAAqB,EAAE,eAAe,EAAE,QAAQ,CAAC,CACvF,CAAC;QACF,OAAO;YACL,EAAE,EAAE,UAAU;SACf,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO;YACL,GAAG,EAAE,yBAAyB,CAC5B,SAAS,CAAC,GAAG,EACb,MAAM,EACN,qBAAqB,EACrB,eAAe,EACf,QAAQ,CACT;SACF,CAAC;IACJ,CAAC;IAED,OAAO,sBAAsB,CAC3B,SAAS,CAAC,SAAS,EACnB,MAAM,EACN,qBAAqB,EACrB,eAAe,EACf,QAAQ,CACT,CAAC;AACJ,CAAC","sourcesContent":["// cspell:words DDTHH\nimport dayjs from 'dayjs';\nimport type { Dayjs, QUnitType } from 'dayjs';\nimport './extendDayJs';\n\nimport { hasProp } from '@pega/cosmos-react-core';\n\nimport type { Condition, LeafCondition, Field } from '../ConditionBuilder.types';\nimport { truncateISODateString } from '../RhsControls';\n\nimport { getItem, isAbsoluteDateString } from './utils';\nimport type { DatePart, FieldType } from './types';\nimport { convertTimeValueToMs } from './time-utils';\n\nconst dayjsDateParts: Record<DatePart, QUnitType> = {\n SECONDS: 'second',\n MINUTES: 'minute',\n HOURS: 'hour',\n DAYS: 'day',\n WEEKS: 'week' as QUnitType,\n QUARTERS: 'quarter',\n MONTHS: 'month',\n YEARS: 'year'\n};\n\n/** Construct Condition with two range comparators based on the given bounds */\nfunction getConditionForBetweenComparator(\n start: string | number,\n end: string | number,\n node: LeafCondition\n): Condition {\n return node.comparator === 'BTW'\n ? {\n AND: [\n {\n condition: {\n lhs: node.lhs,\n comparator: 'GTE',\n rhs: { value: start }\n }\n },\n {\n condition: {\n lhs: node.lhs,\n comparator: 'LTE',\n rhs: { value: end }\n }\n }\n ]\n }\n : {\n OR: [\n {\n condition: {\n lhs: node.lhs,\n comparator: 'LT',\n rhs: { value: start }\n }\n },\n {\n condition: {\n lhs: node.lhs,\n comparator: 'GT',\n rhs: { value: end }\n }\n }\n ]\n };\n}\n\nfunction getDateStringInTimezone(d: Dayjs, tz: string): string {\n return d.tz(tz).format('YYYY-MM-DDTHH:mm:ss.SSS');\n}\n\n/** Construct a date-range filter based on the given date bounds and the comparator */\nfunction getConditionFromRange(\n startDate: Dayjs,\n endDate: Dayjs,\n node: LeafCondition,\n lhsFieldType: FieldType,\n timezone?: string\n): Condition {\n const formatDate = (d: Dayjs, tz?: string): string => {\n let isoString: string;\n if (tz) {\n isoString = getDateStringInTimezone(d, tz);\n } else {\n const time = d.toDate().getTime();\n const timezoneOffset = new Date(time).getTimezoneOffset() * 60000;\n isoString = new Date(time - timezoneOffset).toISOString().slice(0, -1);\n }\n if (lhsFieldType === 'TIME_ONLY') return truncateISODateString(isoString, lhsFieldType);\n if (lhsFieldType === 'DATE_ONLY') return isoString.substring(0, isoString.indexOf('T'));\n return isoString;\n };\n\n switch (node.comparator) {\n case 'EQ':\n return {\n AND: [\n {\n condition: {\n lhs: node.lhs,\n comparator: 'LTE',\n rhs: { value: formatDate(endDate, timezone) }\n }\n },\n {\n condition: {\n lhs: node.lhs,\n comparator: 'GTE',\n rhs: { value: formatDate(startDate, timezone) }\n }\n }\n ]\n };\n case 'NEQ':\n return {\n OR: [\n {\n condition: {\n lhs: node.lhs,\n comparator: 'GT',\n rhs: { value: formatDate(endDate, timezone) }\n }\n },\n {\n condition: {\n lhs: node.lhs,\n comparator: 'LT',\n rhs: { value: formatDate(startDate, timezone) }\n }\n }\n ]\n };\n case 'GT':\n return {\n condition: {\n lhs: node.lhs,\n comparator: 'GT',\n rhs: { value: formatDate(endDate, timezone) }\n }\n };\n case 'GTE':\n return {\n condition: {\n lhs: node.lhs,\n comparator: 'GTE',\n rhs: { value: formatDate(startDate, timezone) }\n }\n };\n case 'LT':\n return {\n condition: {\n lhs: node.lhs,\n comparator: 'LT',\n rhs: { value: formatDate(startDate, timezone) }\n }\n };\n case 'LTE':\n return {\n condition: {\n lhs: node.lhs,\n comparator: 'LTE',\n rhs: { value: formatDate(endDate, timezone) }\n }\n };\n case 'BTW':\n case 'NOT_BTW':\n return getConditionForBetweenComparator(\n formatDate(startDate, timezone),\n formatDate(endDate, timezone),\n node\n );\n default:\n return { condition: node };\n }\n}\n\nfunction transformLeafCondition(\n node: LeafCondition,\n fields: Field[],\n transformRelativeDate = true,\n currentDateTime?: string,\n timezone?: string\n): Condition {\n const field = getItem(fields, node.lhs.field);\n\n if (!field || !hasProp(field, 'type')) {\n return { condition: node }; // Safety check\n }\n\n if (\n (node.comparator === 'EQ' || node.comparator === 'NEQ') &&\n node.rhs &&\n hasProp(node.rhs, 'value') &&\n Object.keys(node.rhs).length === 1 &&\n typeof node.rhs.value === 'string'\n ) {\n const dateTime = node.rhs.value;\n\n const timePartsCount = dateTime.split(':').length;\n if (field.type === 'DATE_TIME') {\n const date = isAbsoluteDateString(dateTime)\n ? dayjs(dateTime).tz(timezone)\n : dayjs.tz(dateTime, timezone);\n let startDate = date;\n let endDate = date;\n // For HH:MM:SS expand milliseconds to 0-999\n if (timePartsCount === 3) {\n startDate = startDate.millisecond(0);\n endDate = endDate.millisecond(999);\n\n return getConditionFromRange(startDate, endDate, node, field.type, timezone);\n }\n // HH:MM expand seconds to 0-59\n if (timePartsCount === 2) {\n startDate = startDate.second(0).millisecond(0);\n endDate = endDate.second(59).millisecond(999);\n return getConditionFromRange(startDate, endDate, node, field.type, timezone);\n }\n } else if (field.type === 'TIME_ONLY') {\n const dateTimeMs = convertTimeValueToMs(node.rhs.value);\n\n // HH:MM expand seconds to 0-59\n if (timePartsCount === 2) {\n const startDate = dayjs(dateTimeMs).tz(timezone).second(0).millisecond(0);\n const endDate = dayjs(dateTimeMs).tz(timezone).second(59).millisecond(0);\n return getConditionFromRange(startDate, endDate, node, field.type, timezone);\n }\n }\n }\n\n // Transform Relative date filters into equivalent date range filters\n if (node.rhs && transformRelativeDate && hasProp(node.rhs, 'relativeDate')) {\n const { timePeriod, interval, datePart } = node.rhs.relativeDate;\n const dayjsDatePart = dayjsDateParts[datePart];\n const now =\n !currentDateTime || isAbsoluteDateString(currentDateTime)\n ? dayjs.utc(dayjs(currentDateTime).tz(timezone))\n : dayjs.tz(currentDateTime, timezone);\n\n let startDate = now;\n let endDate = now;\n if (timePeriod === 'CURRENT') {\n startDate = now.startOf(dayjsDatePart);\n endDate = now.endOf(dayjsDatePart);\n } else if (timePeriod === 'LAST' && interval && interval >= 1) {\n startDate = now.subtract(interval, dayjsDatePart);\n } else if (timePeriod === 'PREVIOUS' && interval && interval >= 1) {\n startDate = now.startOf(dayjsDatePart).subtract(interval, dayjsDatePart);\n endDate = now.subtract(1, dayjsDatePart).endOf(dayjsDatePart);\n } else if (timePeriod === 'NEXT' && interval && interval >= 1) {\n startDate = now.add(1, dayjsDatePart).startOf(dayjsDatePart);\n endDate = now.endOf(dayjsDatePart).add(interval, dayjsDatePart);\n }\n\n return getConditionFromRange(\n startDate.tz(timezone),\n endDate.tz(timezone),\n node,\n field.type,\n timezone\n );\n }\n\n // Transform WEEKS-filters into equivalent date-range filters\n // NOTE: This is a work-around until we make startOfDay customizable for Weeks\n if (node.rhs && hasProp(node.rhs, 'dateFunction') && node.rhs.dateFunction === 'WEEKS') {\n const startDate =\n typeof node.rhs.value === 'number' || isAbsoluteDateString(node.rhs.value)\n ? dayjs.utc(dayjs(node.rhs.value).tz(timezone)).startOf('day').tz(timezone)\n : dayjs.tz(node.rhs.value, timezone).startOf('day'); // Since we store it as YYYY-MM-DD, it's already the start of day\n\n const endDate = startDate.add(7, 'day').subtract(1, 'millisecond'); // Last millisecond on the 7th day from startDate\n return getConditionFromRange(startDate, endDate, node, field.type, timezone);\n }\n\n // Transform double range comparators (BTW, NOT_BTW) into equivalent pair of single range comparators\n if (node.rhs && hasProp(node.rhs, 'start')) {\n if (field.type === 'DECIMAL' || field.type === 'INTEGER' || field.type === 'TIME_ONLY') {\n return getConditionForBetweenComparator(node.rhs.start, node.rhs.end, node);\n }\n\n const startDate =\n typeof node.rhs.start === 'number' || isAbsoluteDateString(node.rhs.start)\n ? dayjs(node.rhs.start).tz(timezone)\n : dayjs.tz(node.rhs.start, timezone);\n const endDate =\n typeof node.rhs.end === 'number' || isAbsoluteDateString(node.rhs.end)\n ? dayjs(node.rhs.end).tz(timezone)\n : dayjs.tz(node.rhs.end, timezone);\n\n return getConditionFromRange(startDate, endDate, node, field.type, timezone);\n }\n\n // apply timezone to date-time fields\n if (timezone && field.type === 'DATE_TIME' && node.rhs && !hasProp(node.rhs, 'dateFunction')) {\n const newNode: LeafCondition = { ...node };\n if (newNode.rhs && hasProp(newNode.rhs, 'value')) {\n newNode.rhs.value = getDateStringInTimezone(\n typeof newNode.rhs.value === 'number' || isAbsoluteDateString(newNode.rhs.value)\n ? dayjs(newNode.rhs.value)\n : dayjs.tz(newNode.rhs.value, timezone),\n timezone\n );\n }\n if (newNode.rhs && hasProp(newNode.rhs, 'values')) {\n const valuesWithTimezone = newNode.rhs.values.map(v =>\n getDateStringInTimezone(\n typeof v === 'number' || isAbsoluteDateString(v) ? dayjs(v) : dayjs.tz(v, timezone),\n timezone\n )\n );\n newNode.rhs.values = valuesWithTimezone;\n }\n return { condition: newNode };\n }\n\n // For all other cases\n return { condition: node };\n}\n\n/** This function transforms Conditions with Relative Dates into Conditions with Date Ranges.\n * Do not use this function unless you need to convert Relative Dates into Date Ranges.\n *\n * If `currentDateTime` is not provided, the current system time will be used.\n * If `timezone` is not provided, the system's timezone will be used for conversion.\n *\n * The `timezone` prop is applied to the date-time values within the condition when the transformation occurs.\n * If `timezone` is specified, the date-time will be converted from UTC (or the provided reference time) to the specified timezone.\n * Then, the transformed date will be used to generate a range.\n * This transformation ensures that the start and end times account for timezone differences when considering the condition's range.\n *\n * For example:\n * - A UTC date-time `2025-05-12T11:24:45.946Z` will be transformed to `2025-05-12T07:24:45.946-04:00` (in the `-04:00` timezone).\n * The date-time will then be converted into a range:\n * `[\"2025-05-12T07:24:45.000\", \"2025-05-12T07:24:45.999\"]`.\n * - A date-time without a timezone (`2025-05-12T11:24:45.946`) will be parsed in the timezone (e.g., `-04:00`).\n * The parsed time will then be transformed into a range like:\n * `[\"2025-05-12T11:24:45.000\", \"2025-05-12T11:24:45.999\"]`.\n *\n */\nexport default function transformComplexCondition(\n condition: Condition,\n fields: Field[],\n transformRelativeDate = true,\n currentDateTime?: string,\n timezone?: string\n): Condition {\n if (hasProp(condition, 'AND')) {\n const childNodes: Condition[] = condition.AND.map(n =>\n transformComplexCondition(n, fields, transformRelativeDate, currentDateTime, timezone)\n );\n return {\n AND: childNodes\n };\n }\n\n if (hasProp(condition, 'OR')) {\n const childNodes: Condition[] = condition.OR.map(n =>\n transformComplexCondition(n, fields, transformRelativeDate, currentDateTime, timezone)\n );\n return {\n OR: childNodes\n };\n }\n\n if (hasProp(condition, 'NOT')) {\n return {\n NOT: transformComplexCondition(\n condition.NOT,\n fields,\n transformRelativeDate,\n currentDateTime,\n timezone\n )\n };\n }\n\n return transformLeafCondition(\n condition.condition,\n fields,\n transformRelativeDate,\n currentDateTime,\n timezone\n );\n}\n"]}
@@ -5,7 +5,8 @@ export type { default as FieldConditionProps } from './FieldCondition.types';
5
5
  export { default as evaluateCondition } from './core/evaluator';
6
6
  export { default as formatCondition, formatRelativeDate } from './core/formatter';
7
7
  export { default as transformComplexCondition } from './core/transformer';
8
- export type { ComparatorsByType, RHSType, FieldType } from './core/types';
8
+ export type { ComparatorsByType, RHSType, FieldType, Comparator } from './core/types';
9
9
  export { splitConditionTree, parseLogicString } from './core/utils';
10
10
  export { default as AtomicCondition, getInitConditionForLhs, isValidCondition } from './AtomicCondition';
11
+ export type { AtomicConditionProps } from './AtomicCondition';
11
12
  //# 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,MAAM,wBAAwB,CAAC;AAC7E,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;AAC1E,YAAY,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EACL,OAAO,IAAI,eAAe,EAC1B,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC"}
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,MAAM,wBAAwB,CAAC;AAC7E,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;AAC1E,YAAY,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACpE,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 } from './core/types';\nexport { splitConditionTree, parseLogicString } from './core/utils';\nexport {\n default as AtomicCondition,\n getInitConditionForLhs,\n isValidCondition\n} 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;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,5 +1,5 @@
1
1
  import type { DefaultTheme } from 'styled-components';
2
2
  export declare const StyledConditionRadioGroup: import("styled-components").StyledComponent<"fieldset", DefaultTheme, {}, never>;
3
3
  export declare const StyledVerticalFieldGroup: import("styled-components").StyledComponent<import("@pega/cosmos-react-core").ForwardRefForwardPropsComponent<import("@pega/cosmos-react-core").FieldGroupProps>, DefaultTheme, {}, never>;
4
- export declare const StyledVerticalAtomicCondition: import("styled-components").StyledComponent<import("@pega/cosmos-react-core").ForwardRefForwardPropsComponent<import("../ConditionBuilder/AtomicCondition").AtomicConditionProps>, DefaultTheme, {}, never>;
4
+ export declare const StyledVerticalAtomicCondition: import("styled-components").StyledComponent<import("@pega/cosmos-react-core").ForwardRefForwardPropsComponent<import("../ConditionBuilder").AtomicConditionProps>, DefaultTheme, {}, never>;
5
5
  //# sourceMappingURL=ConditionInput.styles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionInput.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionInput/ConditionInput.styles.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAalE,eAAO,MAAM,yBAAyB,kFAIrC,CAAC;AAsBF,eAAO,MAAM,wBAAwB,4LAA+C,CAAC;AAIrF,eAAO,MAAM,6BAA6B,6MAAoD,CAAC"}
1
+ {"version":3,"file":"ConditionInput.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionInput/ConditionInput.styles.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAalE,eAAO,MAAM,yBAAyB,kFAIrC,CAAC;AAsBF,eAAO,MAAM,wBAAwB,4LAA+C,CAAC;AAIrF,eAAO,MAAM,6BAA6B,6LAAoD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-condition-builder",
3
- "version": "9.0.0-build.9.1",
3
+ "version": "9.0.0-build.9.11",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "author": "Pegasystems",
6
6
  "sideEffects": [
@@ -17,7 +17,7 @@
17
17
  "build": "tsc -b tsconfig.build.json"
18
18
  },
19
19
  "dependencies": {
20
- "@pega/cosmos-react-core": "9.0.0-build.9.1",
20
+ "@pega/cosmos-react-core": "9.0.0-build.9.11",
21
21
  "@types/react": "^17.0.62 || ^18.3.3",
22
22
  "@types/react-dom": "^17.0.20 || ^18.3.0",
23
23
  "@types/styled-components": "^5.1.26",