@pega/cosmos-react-condition-builder 5.0.0-dev.5.0 → 5.0.0-dev.6.1
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.
- package/lib/components/ConditionBuilder/AtomicCondition.d.ts +4 -4
- package/lib/components/ConditionBuilder/AtomicCondition.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/AtomicCondition.js +4 -1
- package/lib/components/ConditionBuilder/AtomicCondition.js.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.d.ts +3 -3
- package/lib/components/ConditionBuilder/ConditionBuilder.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.js.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.js.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts +2 -2
- package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.types.js.map +1 -1
- package/lib/components/ConditionBuilder/FieldCondition.d.ts +3 -3
- package/lib/components/ConditionBuilder/FieldCondition.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/FieldCondition.js.map +1 -1
- package/lib/components/ConditionBuilder/FieldCondition.types.d.ts +4 -4
- package/lib/components/ConditionBuilder/FieldCondition.types.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/FieldCondition.types.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.d.ts +4 -4
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.d.ts +3 -3
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.d.ts +2 -2
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.d.ts +4 -4
- package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.d.ts +4 -4
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.d.ts +3 -3
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.d.ts +4 -4
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.d.ts +4 -4
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/index.d.ts +4 -4
- package/lib/components/ConditionBuilder/RhsControls/index.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/index.js.map +1 -1
- package/lib/components/ConditionBuilder/core/comparators.d.ts +1 -1
- package/lib/components/ConditionBuilder/core/comparators.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/comparators.js +4 -4
- package/lib/components/ConditionBuilder/core/comparators.js.map +1 -1
- package/lib/components/ConditionBuilder/core/evaluator.d.ts +1 -1
- package/lib/components/ConditionBuilder/core/evaluator.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/evaluator.js.map +1 -1
- package/lib/components/ConditionBuilder/core/formatter.d.ts +4 -4
- package/lib/components/ConditionBuilder/core/formatter.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/formatter.js.map +1 -1
- package/lib/components/ConditionBuilder/core/rows-reducer.d.ts +1 -1
- package/lib/components/ConditionBuilder/core/rows-reducer.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/rows-reducer.js.map +1 -1
- package/lib/components/ConditionBuilder/core/transformer.d.ts +1 -1
- package/lib/components/ConditionBuilder/core/transformer.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/transformer.js.map +1 -1
- package/lib/components/ConditionBuilder/core/utils.d.ts +1 -1
- package/lib/components/ConditionBuilder/core/utils.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/utils.js.map +1 -1
- package/lib/components/ConditionInput/ConditionInput.d.ts +2 -2
- package/lib/components/ConditionInput/ConditionInput.d.ts.map +1 -1
- package/lib/components/ConditionInput/ConditionInput.js.map +1 -1
- package/lib/components/ConditionInput/ConditionInput.styles.d.ts +1 -1
- package/lib/components/ConditionInput/ConditionInput.styles.d.ts.map +1 -1
- package/lib/components/ConditionInput/ConditionInput.styles.js.map +1 -1
- package/lib/components/ConditionInput/ConditionInput.types.d.ts +2 -2
- package/lib/components/ConditionInput/ConditionInput.types.d.ts.map +1 -1
- package/lib/components/ConditionInput/ConditionInput.types.js.map +1 -1
- package/lib/components/ConditionInput/utils.d.ts +1 -1
- package/lib/components/ConditionInput/utils.d.ts.map +1 -1
- package/lib/components/ConditionInput/utils.js.map +1 -1
- package/lib/components/PromotedFilters/ConditionSelector.d.ts +4 -4
- package/lib/components/PromotedFilters/ConditionSelector.d.ts.map +1 -1
- package/lib/components/PromotedFilters/ConditionSelector.js.map +1 -1
- package/lib/components/PromotedFilters/PromotedFilters.d.ts +4 -4
- package/lib/components/PromotedFilters/PromotedFilters.d.ts.map +1 -1
- package/lib/components/PromotedFilters/PromotedFilters.js.map +1 -1
- package/lib/components/PromotedFilters/PromotedFilters.types.d.ts +2 -2
- package/lib/components/PromotedFilters/PromotedFilters.types.d.ts.map +1 -1
- package/lib/components/PromotedFilters/PromotedFilters.types.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FunctionComponent, Ref } from 'react';
|
|
2
|
-
import { BaseProps, HandleValue, ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
-
import { LeafCondition, Field, DateFunctionsByType } from './ConditionBuilder.types';
|
|
4
|
-
import { ComparatorsByType, RHSType } from './core/types';
|
|
1
|
+
import type { FunctionComponent, Ref } from 'react';
|
|
2
|
+
import type { BaseProps, HandleValue, ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import type { LeafCondition, Field, DateFunctionsByType } from './ConditionBuilder.types';
|
|
4
|
+
import type { ComparatorsByType, RHSType } from './core/types';
|
|
5
5
|
/** Determines the default condition object for a given LHS value */
|
|
6
6
|
export declare function getInitConditionForLhs(lhs: LeafCondition['lhs'], fields: Field[], validRhsTypes: Set<RHSType>, validComparators?: ComparatorsByType[], dateFunctions?: DateFunctionsByType): LeafCondition;
|
|
7
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AtomicCondition.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/AtomicCondition.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AtomicCondition.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/AtomicCondition.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAe,GAAG,EAAmB,MAAM,OAAO,CAAC;AAYlF,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGpF,OAAO,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAI1F,OAAO,KAAK,EAAc,iBAAiB,E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wB;IACxB,MAAM,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CAC3B;AAED,mDAAmD;AACnD,QAAA,MAAM,eAAe,EAAE,iBAAiB,CAAC,oBAAoB,GAAG,YAAY,CAqL3E,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -124,8 +124,11 @@ const AtomicCondition = forwardRef(function AtomicCondition({ condition, fields,
|
|
|
124
124
|
return; // The option is shown only when an lhs is not yet selected. Ignore this selection for those cases
|
|
125
125
|
}
|
|
126
126
|
const comparator = e.target.value;
|
|
127
|
-
const
|
|
127
|
+
const conditionRhs = condition.rhs
|
|
128
128
|
? { ...condition.rhs } // Duplicating rhs to avoid using source object as it can be mutated later.
|
|
129
|
+
: undefined;
|
|
130
|
+
const rhs = isRhsValidForComparator(conditionRhs, comparator)
|
|
131
|
+
? conditionRhs
|
|
129
132
|
: getDefaultRhs(fieldType, comparator, validRhsTypes, dateFunctions);
|
|
130
133
|
handleConditionChange({ ...condition, comparator, rhs });
|
|
131
134
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AtomicCondition.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/AtomicCondition.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EAEV,MAAM,EACN,QAAQ,EAER,mBAAmB,EACpB,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,IAAI,EACJ,MAAM,EACN,MAAM,EACN,OAAO,EACP,OAAO,EAIP,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACtB,MAAM,yBAAyB,CAAC;AAEjC,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,CAA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,CAAC,GAAG,CAAC,KAAK,EACtB,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,cAAc,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EACtE,IAAI,EACF,cAAc,IAAI,KAAK,CAAC,GAAG,CAAC,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 {\n FunctionComponent,\n ChangeEvent,\n forwardRef,\n Ref,\n useRef,\n useState,\n PropsWithoutRef,\n useImperativeHandle\n} from 'react';\n\nimport {\n Grid,\n Select,\n Option,\n useI18n,\n hasProp,\n BaseProps,\n HandleValue,\n ForwardProps,\n useConsolidatedRef,\n useFocusWithin,\n useAfterInitialEffect\n} from '@pega/cosmos-react-core';\n\nimport { getItem } from './core/utils';\nimport { LeafCondition, Field, DateFunctionsByType } from './ConditionBuilder.types';\nimport FieldSelector from './RhsControls/FieldSelector';\nimport RhsControls, { getDefaultRhs, isValidRhs } from './RhsControls';\nimport getComparatorOptions from './core/comparators';\nimport { 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: FunctionComponent<AtomicConditionProps & ForwardProps> = 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)\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 rhs = isRhsValidForComparator(condition.rhs, comparator)\n ? ({ ...condition.rhs } as LeafCondition['rhs']) // Duplicating rhs to avoid using source object as it can be mutated later.\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;AAGjC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,C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a,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 { FunctionComponent, 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 { BaseProps, HandleValue, ForwardProps } 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: FunctionComponent<AtomicConditionProps & ForwardProps> = 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)\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,6 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react';
|
|
2
|
-
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
-
import ConditionBuilderProps from './ConditionBuilder.types';
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
import type { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import type ConditionBuilderProps from './ConditionBuilder.types';
|
|
4
4
|
declare const ConditionBuilder: FunctionComponent<ConditionBuilderProps & ForwardProps>;
|
|
5
5
|
export default ConditionBuilder;
|
|
6
6
|
//# sourceMappingURL=ConditionBuilder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionBuilder.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.tsx"],"names":[],"mappings":"
|
|
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;AAiB5D,OAAO,KAAK,EAAE,YAAY,EAAqB,MAAM,yBAAyB,CAAC;AAG/E,OAAO,KAAK,qBAAqB,MAAM,0BAA0B,CAAC;AA8BlE,QAAA,MAAM,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,GAAG,YAAY,CA6Z7E,CAAC;AAGF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionBuilder.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,QAAQ,EAER,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,MAAM,EACN,SAAS,EACV,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,MAAM,EACN,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,UAAU,EAEV,OAAO,EACP,OAAO,EACP,aAAa,EA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;AACJ,CAAC,CAAC;AACF,gBAAgB,CAAC,YAAY,GAAG,YAAY,CAAC;AAE7C,eAAe,gBAAgB,CAAC","sourcesContent":["import {\n FunctionComponent,\n Fragment,\n ChangeEvent,\n useState,\n useReducer,\n useImperativeHandle,\n useRef,\n useEffect\n} from 'react';\n\nimport {\n Banner,\n Button,\n Flex,\n Icon,\n Input,\n MenuButton,\n ForwardProps,\n hasProp,\n useI18n,\n getFocusables,\n BannerHandleValue,\n Label,\n useUID,\n useLiveLog,\n AdditionalInfo\n} from '@pega/cosmos-react-core';\n\nimport AtomicCondition, { isValidCondition } from './AtomicCondition';\nimport ConditionBuilderProps, {\n Condition,\n HandleValue,\n LeafCondition\n} 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 { 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 [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 [showModeWarning, setModeWarning] = useState(false); // Used to warn user about losing information when moving away from Advanced mode\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 const labelId = useUID();\n\n const newOperatorButtonRef = useRef<HTMLButtonElement | null>(null);\n const focusRowRef = useRef<HTMLElement | null>(null);\n const [focusRowIndex, setFocusRowIndex] = useState<number | null>(null);\n const bannerHandleRef = useRef<BannerHandleValue>(null);\n const buttonRef = useRef<HTMLButtonElement>(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 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 return parseResult.condition;\n };\n\n // Toggle between the Basic and Advanced modes\n // `forceToggle:true` is passed when switching from Advanced to Basic mode despite a loss of information\n const toggleMode = (forceToggle?: boolean): void => {\n setModeWarning(false); // Clear any previous warning\n if (isBasicMode) {\n // Update the logicString to match the operatorsList before switching the mode\n setLogicString(getLogicFromBasicMode(operatorsList));\n setBasicMode(false);\n } else if (forceToggle) {\n // If forcibly toggling from Advanced to Basic despite a loss of operators\n // Set up the default `AND` operator between all rows before switching to Basic mode\n setOperatorsList(new Array(conditionRows.length - 1).fill('AND'));\n setBasicMode(true);\n } else {\n // If switching from Advanced mode\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 it's a valid condition, check if it's simple enough to be shown in Basic mode without any loss of information\n if (isBasicModeApplicable(condition)) {\n // If the logic is simple enough, identify the new set of operators before switching to Basic mode\n setOperatorsList(getBasicModeOperators(logicString));\n setBasicMode(true);\n } else {\n // If the logic is too complex show a warning for the user to act on\n setModeWarning(true);\n }\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 useEffect(() => {\n if (showModeWarning) bannerHandleRef.current?.focus();\n }, [showModeWarning]);\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: 4 }}>\n {/* Condition Rows */}\n <div>\n {conditionRows.map(({ id, label, ...leaf }, index) => {\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].toLowerCase()}\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 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={() => insertRow(index + 1)}\n label={t('add_condition')}\n >\n <Icon name='plus' />\n </Button>\n <Button\n icon\n variant='simple'\n onClick={() => removeRow(index)}\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 <Flex container={{ alignItems: 'center' }}>\n <Label htmlFor={labelId}>\n {t('condition_builder_advanced_condition_label')} \n </Label>\n\n <AdditionalInfo heading={t('condition_builder_advanced_condition_label')}>\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 </AdditionalInfo>\n </Flex>\n\n <Input\n id={labelId}\n type='text'\n placeholder={t('condition_builder_advanced_condition_placeholder')}\n value={logicString}\n onChange={(e: ChangeEvent<HTMLInputElement>) => setLogicString(e.target.value)}\n onBlur={() => validateLogicString(logicString)}\n status={logicError !== null ? 'error' : undefined}\n info={logicError}\n />\n </Flex>\n </div>\n )}\n\n {/* Submit block */}\n <Flex container={{ direction: 'column', gap: 2 }}>\n {/* Banner to show a warning when switching from Advanced to Basic mode */}\n {showModeWarning && (\n <Banner\n variant='warning'\n messages={[\n {\n label: t('condition_builder_switch_banner_text'),\n action: {\n text: t('condition_builder_confirm_button_label'),\n onClick: () => {\n toggleMode(true);\n buttonRef.current?.focus();\n }\n }\n }\n ]}\n onDismiss={() => {\n setModeWarning(false);\n buttonRef.current?.focus();\n }}\n handle={bannerHandleRef}\n />\n )}\n\n {/* Footer buttons */}\n <Flex container={{ justify: 'between' }}>\n <Button\n name='mode-switch'\n variant='simple'\n onClick={() => {\n toggleMode(false);\n }}\n aria-label={\n isBasicMode\n ? t('condition_builder_advanced_mode_button_aria_label')\n : t('condition_builder_basic_mode_button_aria_label')\n }\n ref={buttonRef}\n >\n {isBasicMode\n ? t('condition_builder_advanced_mode_button_label')\n : t('condition_builder_basic_mode_button_label')}\n </Button>\n </Flex>\n </Flex>\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,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,mBAAmB,E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EzD,GAAG,EAAE,SAAS,YAEb,WAAW;gCACV,CAAC,CAAC,CAAC,CAAC,8CAA8C,CAAC;gCACnD,CAAC,CAAC,CAAC,CAAC,2CAA2C,CAAC,GAC3C,GACJ,IACF,IACgB,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 Banner,\n Button,\n Flex,\n Icon,\n Input,\n MenuButton,\n hasProp,\n useI18n,\n getFocusables,\n Label,\n useUID,\n useLiveLog,\n AdditionalInfo\n} from '@pega/cosmos-react-core';\nimport type { ForwardProps, BannerHandleValue } 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 [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 [showModeWarning, setModeWarning] = useState(false); // Used to warn user about losing information when moving away from Advanced mode\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 const labelId = useUID();\n\n const newOperatorButtonRef = useRef<HTMLButtonElement | null>(null);\n const focusRowRef = useRef<HTMLElement | null>(null);\n const [focusRowIndex, setFocusRowIndex] = useState<number | null>(null);\n const bannerHandleRef = useRef<BannerHandleValue>(null);\n const buttonRef = useRef<HTMLButtonElement>(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 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 return parseResult.condition;\n };\n\n // Toggle between the Basic and Advanced modes\n // `forceToggle:true` is passed when switching from Advanced to Basic mode despite a loss of information\n const toggleMode = (forceToggle?: boolean): void => {\n setModeWarning(false); // Clear any previous warning\n if (isBasicMode) {\n // Update the logicString to match the operatorsList before switching the mode\n setLogicString(getLogicFromBasicMode(operatorsList));\n setBasicMode(false);\n } else if (forceToggle) {\n // If forcibly toggling from Advanced to Basic despite a loss of operators\n // Set up the default `AND` operator between all rows before switching to Basic mode\n setOperatorsList(new Array(conditionRows.length - 1).fill('AND'));\n setBasicMode(true);\n } else {\n // If switching from Advanced mode\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 it's a valid condition, check if it's simple enough to be shown in Basic mode without any loss of information\n if (isBasicModeApplicable(condition)) {\n // If the logic is simple enough, identify the new set of operators before switching to Basic mode\n setOperatorsList(getBasicModeOperators(logicString));\n setBasicMode(true);\n } else {\n // If the logic is too complex show a warning for the user to act on\n setModeWarning(true);\n }\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 useEffect(() => {\n if (showModeWarning) bannerHandleRef.current?.focus();\n }, [showModeWarning]);\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: 4 }}>\n {/* Condition Rows */}\n <div>\n {conditionRows.map(({ id, label, ...leaf }, index) => {\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].toLowerCase()}\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 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={() => insertRow(index + 1)}\n label={t('add_condition')}\n >\n <Icon name='plus' />\n </Button>\n <Button\n icon\n variant='simple'\n onClick={() => removeRow(index)}\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 <Flex container={{ alignItems: 'center' }}>\n <Label htmlFor={labelId}>\n {t('condition_builder_advanced_condition_label')} \n </Label>\n\n <AdditionalInfo heading={t('condition_builder_advanced_condition_label')}>\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 </AdditionalInfo>\n </Flex>\n\n <Input\n id={labelId}\n type='text'\n placeholder={t('condition_builder_advanced_condition_placeholder')}\n value={logicString}\n onChange={(e: ChangeEvent<HTMLInputElement>) => setLogicString(e.target.value)}\n onBlur={() => validateLogicString(logicString)}\n status={logicError !== null ? 'error' : undefined}\n info={logicError}\n />\n </Flex>\n </div>\n )}\n\n {/* Submit block */}\n <Flex container={{ direction: 'column', gap: 2 }}>\n {/* Banner to show a warning when switching from Advanced to Basic mode */}\n {showModeWarning && (\n <Banner\n variant='warning'\n messages={[\n {\n label: t('condition_builder_switch_banner_text'),\n action: {\n text: t('condition_builder_confirm_button_label'),\n onClick: () => {\n toggleMode(true);\n buttonRef.current?.focus();\n }\n }\n }\n ]}\n onDismiss={() => {\n setModeWarning(false);\n buttonRef.current?.focus();\n }}\n handle={bannerHandleRef}\n />\n )}\n\n {/* Footer buttons */}\n <Flex container={{ justify: 'between' }}>\n <Button\n name='mode-switch'\n variant='simple'\n onClick={() => {\n toggleMode(false);\n }}\n aria-label={\n isBasicMode\n ? t('condition_builder_advanced_mode_button_aria_label')\n : t('condition_builder_basic_mode_button_aria_label')\n }\n ref={buttonRef}\n >\n {isBasicMode\n ? t('condition_builder_advanced_mode_button_label')\n : t('condition_builder_basic_mode_button_label')}\n </Button>\n </Flex>\n </Flex>\n </StyledConditionBuilder>\n );\n};\nConditionBuilder.defaultProps = defaultProps;\n\nexport default ConditionBuilder;\n"]}
|
|
@@ -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,
|
|
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;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,6DAA6D,CAAC;AAE3F,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,IAAI,CAAC,CAChD,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,eAAe,EAAE,YAAY,EAAE,OAAO,EAAE,EACjD,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;QACN,aAAa,QAAQ,YAAY;yBAChB,YAAY,CAAC,EAAE,sBAAsB,OAAO;;KAEhE,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,sBAAsB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEvD,wCAAwC;AACxC,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;gBAErB,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,aAAa,CAAC;CAC9E,CAAC;AAEF,SAAS,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAChE,OAAO,GAAG,CAAA;aACC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE;GACxC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,yBAAyB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE1D,uCAAuC;AACvC,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;;;;;;;;;;CAUtD,CAAC;AAEF,sBAAsB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEvD,6CAA6C;AAC7C,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;CAOpC,CAAC;AAEF,WAAW,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,UAAU,CAAC,CACrD,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,EACjE,UAAU,EAAE,EAAE,IAAI,EAAE,EACrB,EACD,SAAS,EACV,EAAE,EAAE;IACH,MAAM,SAAS,GAAG,iBAAiB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACzD,OAAO,CACL,CAAC,SAAS;QACV,GAAG,CAAA;UACC,sBAAsB;uBACT,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAa,CAAC;yBAChD,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;yCACb,OAAO;;OAEzC,CACF,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,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';\nimport { StyledDialog } from '@pega/cosmos-react-core/lib/components/Dialog/Dialog.styles';\n\nexport const StyledConditionBuilder = styled(Flex)(\n ({\n theme: {\n base: { 'content-width': contentWidth, spacing }\n }\n }) => {\n return css`\n ${StyledPopover}:not(${StyledDialog}) & {\n min-width: min(${contentWidth.lg}, calc(100vw - 4 * ${spacing}));\n }\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\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 content: '';\n flex-grow: 1;\n background-image: linear-gradient(to right, rgba(0, 0, 0, 0.2) 60%, rgba(0, 0, 0, 0) 0%);\n background-position: left center;\n background-size: 1.75rem 0.0625rem;\n background-repeat: repeat-x;\n }\n`;\n\nStyledRowWithSeparator.defaultProps = defaultThemeProp;\n\n// Styled label for the rows in Advanced-mode\nexport const StyledLabel = styled.div`\n line-height: 2rem;\n height: 2rem;\n width: 2rem;\n min-width: 2rem;\n text-align: center;\n background: rgba(0, 0, 0, 0.04);\n`;\n\nStyledLabel.defaultProps = defaultThemeProp;\n\nexport const StyledAtomicCondition = styled(FieldGroup)(\n ({\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);\n\nStyledAtomicCondition.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Ref } from 'react';
|
|
1
|
+
import type { Ref } from 'react';
|
|
2
2
|
import type { BaseProps, NoChildrenProp, MenuItemProps } from '@pega/cosmos-react-core';
|
|
3
|
-
import { FieldType, Comparator, ComparatorsByType, DateFunction, RHSType, TimePeriod, DatePart } from './core/types';
|
|
3
|
+
import type { FieldType, Comparator, ComparatorsByType, DateFunction, RHSType, TimePeriod, DatePart } from './core/types';
|
|
4
4
|
/** RHS object with a Date function */
|
|
5
5
|
export interface RhsWithDateFunction {
|
|
6
6
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionBuilder.types.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;
|
|
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,cAAc,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExF,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,OAAO,EACP,UAAU,EACV,QAAQ,EACT,MAAM,cAAc,CAAC;AAEtB,sCAAsC;AACtC,MAAM,WAAW,mBAAmB;IAClC;;;;;;;;;;;;;;OAcG;IACH,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED,sCAAsC;AACtC,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE;QACZ,U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AAG,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionBuilder.types.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.types.ts"],"names":[],"mappings":"","sourcesContent":["// cspell:words DDTHH\nimport { Ref } from 'react';\n\nimport type { BaseProps, NoChildrenProp, MenuItemProps } from '@pega/cosmos-react-core';\n\nimport {\n FieldType,\n Comparator,\n ComparatorsByType,\n DateFunction,\n RHSType,\n TimePeriod,\n DatePart\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 ValueSelection<F> =\n | string[]\n | ReferenceValue[]\n | (({\n searchString,\n comparator,\n lhs\n }: {\n searchString?: string;\n comparator?: string;\n lhs?: F;\n }) => Promise<string[] | ReferenceValue[]>);\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. Integer/Decimal/... should be used as `NUMBER`\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 { Ref } from 'react';\n\nimport type { BaseProps, NoChildrenProp, MenuItemProps } from '@pega/cosmos-react-core';\n\nimport type {\n FieldType,\n Comparator,\n ComparatorsByType,\n DateFunction,\n RHSType,\n TimePeriod,\n DatePart\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 ValueSelection<F> =\n | string[]\n | ReferenceValue[]\n | (({\n searchString,\n comparator,\n lhs\n }: {\n searchString?: string;\n comparator?: string;\n lhs?: F;\n }) => Promise<string[] | ReferenceValue[]>);\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. Integer/Decimal/... should be used as `NUMBER`\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,6 +1,6 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react';
|
|
2
|
-
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
-
import FieldConditionProps from './FieldCondition.types';
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
import type { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import type FieldConditionProps from './FieldCondition.types';
|
|
4
4
|
/** Component for building an atomic condition on a given field */
|
|
5
5
|
declare const FieldCondition: FunctionComponent<FieldConditionProps & ForwardProps>;
|
|
6
6
|
export default FieldCondition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldCondition.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/FieldCondition.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FieldCondition.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/FieldCondition.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,KAAK,mBAAmB,MAAM,wBAAwB,CAAC;AAK9D,kEAAkE;AAClE,QAAA,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,GAAG,YAAY,CA0DzE,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldCondition.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/FieldCondition.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"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AE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,mBAAmB,EACnC,gBAAgB,EAAE,gBAAgB,EAClC,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,EAC9B,aAAa,EAAC,QAAQ,EACtB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAC,OAAO,GACf,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { useImperativeHandle, useState } from 'react';\nimport type { FunctionComponent } from 'react';\n\nimport type { ForwardProps } from '@pega/cosmos-react-core';\n\nimport type FieldConditionProps from './FieldCondition.types';\nimport type { HandleValue } from './FieldCondition.types';\nimport AtomicCondition, { getInitConditionForLhs, isValidCondition } from './AtomicCondition';\nimport type { RHSType } from './core/types';\n\n/** Component for building an atomic condition on a given field */\nconst FieldCondition: FunctionComponent<FieldConditionProps & ForwardProps> = (\n props: FieldConditionProps\n) => {\n const {\n targetField,\n fields,\n condition: seedCondition,\n validComparators,\n validRhsTypes = new Set<RHSType>(['LITERAL', 'FIELD']),\n dateFunctions,\n handle\n } = props;\n const [condition, setCondition] = useState(\n // If editing use the seedCondition, otherwise, determine an initial condition based on the targetField\n () =>\n seedCondition ||\n getInitConditionForLhs(\n { field: targetField },\n fields,\n validRhsTypes,\n validComparators,\n dateFunctions\n )\n );\n const [showErrorIndicators, setErrorIndicators] = useState(false); // Used to enable inline error indicators on the controls\n\n const getCondition: HandleValue['getCondition'] = () => {\n setErrorIndicators(false);\n\n if (isValidCondition(condition, fields, true)) {\n return [true, condition];\n }\n\n setErrorIndicators(true);\n return [false];\n };\n\n useImperativeHandle(\n handle,\n () => ({\n getCondition\n }),\n [getCondition]\n );\n\n return (\n <AtomicCondition\n condition={condition}\n fields={fields}\n indicateErrors={showErrorIndicators}\n validComparators={validComparators}\n dateFunctions={dateFunctions}\n onChange={c => setCondition(c)}\n itemDirection='column'\n validRhsTypes={validRhsTypes}\n lhsMode='label'\n />\n );\n};\n\nexport default FieldCondition;\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Ref } from 'react';
|
|
2
|
-
import { BaseProps } from '@pega/cosmos-react-core';
|
|
3
|
-
import { ComparatorsByType, RHSType } from './core/types';
|
|
4
|
-
import { Field, LeafCondition, DateFunctionsByType } from './ConditionBuilder.types';
|
|
1
|
+
import type { Ref } from 'react';
|
|
2
|
+
import type { BaseProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import type { ComparatorsByType, RHSType } from './core/types';
|
|
4
|
+
import type { Field, LeafCondition, DateFunctionsByType } from './ConditionBuilder.types';
|
|
5
5
|
export interface HandleValue {
|
|
6
6
|
/** Returns condition validity and condition if valid. */
|
|
7
7
|
getCondition: () => [valid: false] | [valid: true, condition: LeafCondition];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldCondition.types.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/FieldCondition.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"FieldCondition.types.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/FieldCondition.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE1F,MAAM,WAAW,WAAW;IAC1B,yDAAyD;IACzD,YAAY,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;CAC9E;AAED,4DAA4D;AAC5D,MAAM,CAAC,OAAO,WAAW,mBAAoB,SAAQ,SAAS;IAC5D,mEAAmE;IACnE,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEzB,iFAAiF;IACjF,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,aAAa,CAAC;IAE1B,yEAAyE;IACzE,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,2CAA2C;IAC3C,MAAM,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldCondition.types.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/FieldCondition.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Ref } from 'react';\n\nimport { BaseProps } from '@pega/cosmos-react-core';\n\nimport { ComparatorsByType, RHSType } from './core/types';\nimport { Field, LeafCondition, DateFunctionsByType } from './ConditionBuilder.types';\n\nexport interface HandleValue {\n /** Returns condition validity and condition if valid. */\n getCondition: () => [valid: false] | [valid: true, condition: LeafCondition];\n}\n\n/** Type definition for the input props of FieldCondition */\nexport default interface FieldConditionProps extends BaseProps {\n /** Id of the field on which the condition should be constructed */\n targetField: Field['id'];\n\n /** Metadata (data-model) for the Fields to use in the RHS field-selector etc. */\n fields: Field[];\n\n /** (Optional) Passed when editing an existing condition */\n condition?: LeafCondition;\n\n /** (Optional) Used to limit the Comparators allowed in the component. */\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 /** Imperative handle for the component. */\n handle?: Ref<HandleValue>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FieldCondition.types.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/FieldCondition.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Ref } from 'react';\n\nimport type { BaseProps } from '@pega/cosmos-react-core';\n\nimport type { ComparatorsByType, RHSType } from './core/types';\nimport type { Field, LeafCondition, DateFunctionsByType } from './ConditionBuilder.types';\n\nexport interface HandleValue {\n /** Returns condition validity and condition if valid. */\n getCondition: () => [valid: false] | [valid: true, condition: LeafCondition];\n}\n\n/** Type definition for the input props of FieldCondition */\nexport default interface FieldConditionProps extends BaseProps {\n /** Id of the field on which the condition should be constructed */\n targetField: Field['id'];\n\n /** Metadata (data-model) for the Fields to use in the RHS field-selector etc. */\n fields: Field[];\n\n /** (Optional) Passed when editing an existing condition */\n condition?: LeafCondition;\n\n /** (Optional) Used to limit the Comparators allowed in the component. */\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 /** Imperative handle for the component. */\n handle?: Ref<HandleValue>;\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react';
|
|
2
|
-
import { BaseProps, ForwardProps, NoChildrenProp } from '@pega/cosmos-react-core';
|
|
3
|
-
import { RhsWithDateFunction } from '../ConditionBuilder.types';
|
|
4
|
-
import { DateFunction } from '../core/types';
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
import type { BaseProps, ForwardProps, NoChildrenProp } from '@pega/cosmos-react-core';
|
|
3
|
+
import type { RhsWithDateFunction } from '../ConditionBuilder.types';
|
|
4
|
+
import type { DateFunction } from '../core/types';
|
|
5
5
|
export interface DateFunctionMenuProps extends BaseProps, NoChildrenProp {
|
|
6
6
|
/** Rhs for the condition */
|
|
7
7
|
rhs: RhsWithDateFunction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateFunctionMenu.d.ts","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/RhsControls/DateFunctionMenu.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DateFunctionMenu.d.ts","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/RhsControls/DateFunctionMenu.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAe,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAkB5D,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EAEZ,cAAc,EAGf,MAAM,yBAAyB,CAAC;AAKjC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAqClD,MAAM,WAAW,qBAAsB,SAAQ,SAAS,EAAE,cAAc;IACtE,4BAA4B;IAC5B,GAAG,EAAE,mBAAmB,CAAC;IAEzB,gDAAgD;IAChD,QAAQ,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAE7C,oEAAoE;IACpE,iBAAiB,EAAE,YAAY,EAAE,CAAC;IAElC,iDAAiD;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,gEAAgE;AAChE,QAAA,MAAM,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,GAAG,YAAY,CA+M7E,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -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C,CAC3B,KAAC,MAAM,IAAY,KAAK,EAAE,CAAC,CAAC,EAAE,YAC3B,CAAC,CAAC,KAAK,IADG,CAAC,CAAC,EAAE,CAER,CACV,CAAC,IACK,CACV,EACA,GAAG,CAAC,YAAY,KAAK,eAAe,IAAI,CACvC,KAAC,WAAW,OACN,mBAAmB,EACvB,WAAW,EAAC,QAAQ,EACpB,GAAG,EAAE,CAAC,EACN,GAAG,EAAE,EAAE,EACP,IAAI,EAAE,CAAC,EACP,WAAW,EAAE,KAAK,EAClB,QAAQ,EAAE,kBAAkB,GAC5B,CACH,EACA,GAAG,CAAC,YAAY,KAAK,cAAc,IAAI,CACtC,KAAC,cAAc,OACT,mBAAmB,EACvB,KAAK,EAAE,GAAG,CAAC,KAAkB,EAC7B,QAAQ,EAAE,iBAAiB,GAC3B,CACH,IACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["// cspell:words DDTHH\nimport { ChangeEvent, FunctionComponent, useMemo } from 'react';\n\nimport {\n BaseProps,\n ForwardProps,\n Select,\n Option,\n MonthInput,\n WeekInput,\n DateInput,\n DateTimeInput,\n NumberInput,\n FormControlProps,\n DayOfWeekInput,\n useI18n,\n useConfiguration,\n QuarterInput,\n range,\n NoChildrenProp,\n ComboBox,\n ComboBoxProps,\n MenuProps,\n menuHelpers\n} from '@pega/cosmos-react-core';\nimport DateTimeProps, {\n DateTimeCallbackParameter\n} from '@pega/cosmos-react-core/lib/components/DateTime/DateTime.types';\nimport { DayOfWeek } from '@pega/cosmos-react-core/lib/components/DateTime/Input/DayOfWeekInput';\n\nimport { RhsWithDateFunction } from '../ConditionBuilder.types';\nimport { DateFunction } from '../core/types';\n\n/**\n * Formats the input date string to match the spec expected for the given date function\n * NOTE: This assumes that the input date is set up on the UTC timezone\n * SPEC:\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 */\nfunction formatDateFunctionValue(isoDateString: string, dateFunction: DateFunction): string {\n const date = new Date(isoDateString);\n const YYYY = date.getUTCFullYear().toString().padStart(4, '0');\n const MM = (date.getUTCMonth() + 1).toString().padStart(2, '0');\n const DD = date.getUTCDate().toString().padStart(2, '0');\n const HH = date.getUTCHours().toString().padStart(2, '0');\n const mm = date.getUTCMinutes().toString().padStart(2, '0');\n const ss = date.getUTCSeconds().toString().padStart(2, '0');\n\n switch (dateFunction) {\n case 'QUARTERS':\n case 'MONTHS':\n return `${YYYY}-${MM}-01`;\n case 'WEEKS':\n case 'DAYS':\n return `${YYYY}-${MM}-${DD}`;\n case 'MINUTES':\n return `${YYYY}-${MM}-${DD}T${HH}:${mm}:00`;\n case 'SECONDS':\n return `${YYYY}-${MM}-${DD}T${HH}:${mm}:${ss}`;\n default:\n return `${YYYY}-${MM}-${DD}T${HH}:00:00`; // HOURS\n }\n}\n\nexport interface DateFunctionMenuProps extends BaseProps, NoChildrenProp {\n /** Rhs for the condition */\n rhs: RhsWithDateFunction;\n\n /** Callback for any modifications to the Rhs */\n onChange: (rhs: RhsWithDateFunction) => void;\n\n /** List of date functions enabled for the current LHS field type */\n dateFunctionsList: DateFunction[];\n\n /** Used to indicate any errors on the control */\n status?: 'error';\n}\n\n/** A menu with controls to select a Time period value on RHS */\nconst DateFunctionMenu: FunctionComponent<DateFunctionMenuProps & ForwardProps> = (\n props: DateFunctionMenuProps\n) => {\n const { rhs, onChange, dateFunctionsList, status } = props;\n const { locale } = useConfiguration();\n const t = useI18n();\n\n // Options for the Date-function selector\n const dateFunctionOptions = useMemo(() => {\n const dateFunctionLabels: Record<DateFunction, string> = {\n YEARS: t('condition_builder_year'),\n QUARTERS: t('condition_builder_quarter'),\n MONTHS: t('condition_builder_month'),\n WEEKS: t('condition_builder_week'),\n DAYS: t('condition_builder_day'),\n HOURS: t('condition_builder_hour'),\n MINUTES: t('condition_builder_minute'),\n SECONDS: t('condition_builder_second'),\n HOURS_OF_DAY: t('condition_builder_date_function_hour_of_day'),\n MONTHS_OF_YEAR: t('condition_builder_date_function_month_of_year'),\n DAYS_OF_MONTH: t('condition_builder_date_function_day_of_month'),\n DAYS_OF_WEEK: t('condition_builder_date_function_day_of_week')\n };\n\n return dateFunctionsList.map(func => ({ id: func, label: dateFunctionLabels[func] }));\n }, [dateFunctionsList, t]);\n\n // Handle changes to the Date-function selector\n const handleDatePartChange = (e: ChangeEvent<HTMLSelectElement>) => {\n const selection = e.target.value as DateFunction;\n onChange({ dateFunction: selection, value: '' });\n };\n\n // Common props for all value controls\n const valueComponentProps: FormControlProps = {\n value: rhs.value === '' ? undefined : rhs.value.toString(),\n label: t('condition_builder_value_label'),\n status,\n info: status ? t('condition_builder_invalid_value') : undefined\n };\n\n // Props for all functions that use a component from the DateTime package\n const dateComponentProps: DateTimeProps = {\n ...valueComponentProps,\n onChange: ({ valueAsISOString, state }: DateTimeCallbackParameter) => {\n // NOTE: Not relying fully on `state` since in some cases state and valueAsTimestamp are both undefined\n if (valueAsISOString === undefined || state === 'incomplete' || state === 'invalid') return;\n\n // Format the value as per spec and return\n onChange({ ...rhs, value: formatDateFunctionValue(valueAsISOString, rhs.dateFunction) });\n }\n };\n\n // HOURS_OF_DAY\n const hoursOfDayItems: MenuProps['items'] = useMemo(\n () =>\n range(0, 23).map(i => {\n const index = i.toString();\n return {\n id: index,\n primary: `${index.toString().padStart(2, '0')}:00`,\n selected: rhs.value === i\n };\n }),\n [rhs.value]\n );\n\n const hoursOfDaySelected = useMemo(() => {\n return menuHelpers.getSelected(hoursOfDayItems)[0];\n }, [hoursOfDayItems]);\n\n const hourOfDayProps: ComboBoxProps = {\n ...valueComponentProps,\n value: `${rhs.value.toString().padStart(2, '0')}:00`,\n mode: 'single-select',\n menu: {\n items: hoursOfDayItems,\n onItemClick: id => {\n onChange({ ...rhs, value: Number(id) });\n }\n },\n selected: hoursOfDaySelected\n ? {\n items: {\n id: hoursOfDaySelected.id,\n text: hoursOfDaySelected.primary\n }\n }\n : undefined\n };\n\n // YEARS\n const yearOptions = useMemo(() => {\n const currentYear = new Date().getFullYear();\n const years = range(currentYear - 10, currentYear + 10);\n return years.map(year => ({\n id: `${year}-01-01`,\n label: new Date(year, 0, 1).toLocaleString(locale, { year: 'numeric' })\n }));\n }, [locale]);\n const onYearChange = (e: ChangeEvent<HTMLSelectElement>) => {\n onChange({ ...rhs, value: e.target.value });\n };\n\n // MONTHS_OF_YEAR\n const monthOfYearOptions = useMemo(\n () =>\n range(1, 12).map(n => ({\n id: `${n}`,\n label: new Date(2021, n - 1, 1).toLocaleString(locale, { month: 'long' })\n })),\n [locale]\n );\n const onMonthOfYearChange = (e: ChangeEvent<HTMLSelectElement>) => {\n const value = e.target.value ? Number(e.target.value) : '';\n onChange({ ...rhs, value });\n };\n\n // DAYS_OF_MONTH\n const onDayOfMonthChange = (value: string) => {\n let newValue: string | number = value;\n if (newValue !== '') {\n newValue = Number(newValue);\n if (newValue > 31) newValue = 31;\n if (newValue < 1) newValue = 1;\n }\n onChange({ ...rhs, value: newValue });\n };\n\n // DAYS_OF_WEEK\n const onDayOfWeekChange = (value: DayOfWeek) => {\n onChange({ ...rhs, value });\n };\n\n return (\n <>\n {/* Date function selector */}\n <Select\n label={t('condition_builder_date_part')}\n value={rhs.dateFunction}\n onChange={handleDatePartChange}\n >\n {dateFunctionOptions.map(o => (\n <Option key={o.id} value={o.id}>\n {o.label}\n </Option>\n ))}\n </Select>\n\n {rhs.dateFunction === 'YEARS' && (\n <Select {...valueComponentProps} onChange={onYearChange} name='year-selector'>\n <Option> </Option>\n {yearOptions.map(o => (\n <Option key={o.id} value={o.id}>\n {o.label}\n </Option>\n ))}\n </Select>\n )}\n {rhs.dateFunction === 'QUARTERS' && <QuarterInput {...dateComponentProps} />}\n {rhs.dateFunction === 'MONTHS' && <MonthInput {...dateComponentProps} />}\n {rhs.dateFunction === 'WEEKS' && <WeekInput {...dateComponentProps} />}\n {rhs.dateFunction === 'DAYS' && <DateInput {...dateComponentProps} />}\n {rhs.dateFunction === 'HOURS' && (\n <DateTimeInput {...dateComponentProps} pickerInterval={60} />\n )}\n {rhs.dateFunction === 'MINUTES' && (\n <DateTimeInput {...dateComponentProps} pickerInterval={60} />\n )}\n {rhs.dateFunction === 'SECONDS' && (\n <DateTimeInput {...dateComponentProps} pickerInterval={60} withSeconds />\n )}\n {rhs.dateFunction === 'HOURS_OF_DAY' && <ComboBox {...hourOfDayProps} />}\n {rhs.dateFunction === 'MONTHS_OF_YEAR' && (\n <Select\n {...valueComponentProps}\n onChange={onMonthOfYearChange}\n name='month-of-year-selector'\n >\n <Option> </Option>\n {monthOfYearOptions.map(o => (\n <Option key={o.id} value={o.id}>\n {o.label}\n </Option>\n ))}\n </Select>\n )}\n {rhs.dateFunction === 'DAYS_OF_MONTH' && (\n <NumberInput\n {...valueComponentProps}\n placeholder='1 - 31'\n min={1}\n max={31}\n step={1}\n showDecimal={false}\n onChange={onDayOfMonthChange}\n />\n )}\n {rhs.dateFunction === 'DAYS_OF_WEEK' && (\n <DayOfWeekInput\n {...valueComponentProps}\n value={rhs.value as DayOfWeek}\n onChange={onDayOfWeekChange}\n />\n )}\n </>\n );\n};\n\nexport default DateFunctionMenu;\n"]}
|
|
1
|
+
{"version":3,"file":"DateFunctionMenu.js","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/RhsControls/DateFunctionMenu.tsx"],"names":[],"mappings":";AAAA,qBAAqB;AACrB,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGhC,OAAO,EACL,MAAM,EACN,MAAM,EACN,UAAU,EACV,SAAS,EACT,SAAS,EACT,aAAa,EACb,WAAW,EACX,cAAc,EACd,OAAO,EACP,gBAAgB,EAChB,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,WAAW,EACZ,MAAM,yBAAyB,CAAC;AAgBjC;;;;;;;;;GASG;AACH,SAAS,uBAAuB,CAAC,aAAqB,EA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AAE,GAAG,CAAC,KAAkB,EAC7B,QAAQ,EAAE,iBAAiB,GAC3B,CACH,IACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["// cspell:words DDTHH\nimport { useMemo } from 'react';\nimport type { ChangeEvent, FunctionComponent } from 'react';\n\nimport {\n Select,\n Option,\n MonthInput,\n WeekInput,\n DateInput,\n DateTimeInput,\n NumberInput,\n DayOfWeekInput,\n useI18n,\n useConfiguration,\n QuarterInput,\n range,\n ComboBox,\n menuHelpers\n} from '@pega/cosmos-react-core';\nimport type {\n BaseProps,\n ForwardProps,\n FormControlProps,\n NoChildrenProp,\n ComboBoxProps,\n MenuProps\n} from '@pega/cosmos-react-core';\nimport type DateTimeProps from '@pega/cosmos-react-core/lib/components/DateTime/DateTime.types';\nimport type { DateTimeCallbackParameter } from '@pega/cosmos-react-core/lib/components/DateTime/DateTime.types';\nimport type { DayOfWeek } from '@pega/cosmos-react-core/lib/components/DateTime/Input/DayOfWeekInput';\n\nimport type { RhsWithDateFunction } from '../ConditionBuilder.types';\nimport type { DateFunction } from '../core/types';\n\n/**\n * Formats the input date string to match the spec expected for the given date function\n * NOTE: This assumes that the input date is set up on the UTC timezone\n * SPEC:\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 */\nfunction formatDateFunctionValue(isoDateString: string, dateFunction: DateFunction): string {\n const date = new Date(isoDateString);\n const YYYY = date.getUTCFullYear().toString().padStart(4, '0');\n const MM = (date.getUTCMonth() + 1).toString().padStart(2, '0');\n const DD = date.getUTCDate().toString().padStart(2, '0');\n const HH = date.getUTCHours().toString().padStart(2, '0');\n const mm = date.getUTCMinutes().toString().padStart(2, '0');\n const ss = date.getUTCSeconds().toString().padStart(2, '0');\n\n switch (dateFunction) {\n case 'QUARTERS':\n case 'MONTHS':\n return `${YYYY}-${MM}-01`;\n case 'WEEKS':\n case 'DAYS':\n return `${YYYY}-${MM}-${DD}`;\n case 'MINUTES':\n return `${YYYY}-${MM}-${DD}T${HH}:${mm}:00`;\n case 'SECONDS':\n return `${YYYY}-${MM}-${DD}T${HH}:${mm}:${ss}`;\n default:\n return `${YYYY}-${MM}-${DD}T${HH}:00:00`; // HOURS\n }\n}\n\nexport interface DateFunctionMenuProps extends BaseProps, NoChildrenProp {\n /** Rhs for the condition */\n rhs: RhsWithDateFunction;\n\n /** Callback for any modifications to the Rhs */\n onChange: (rhs: RhsWithDateFunction) => void;\n\n /** List of date functions enabled for the current LHS field type */\n dateFunctionsList: DateFunction[];\n\n /** Used to indicate any errors on the control */\n status?: 'error';\n}\n\n/** A menu with controls to select a Time period value on RHS */\nconst DateFunctionMenu: FunctionComponent<DateFunctionMenuProps & ForwardProps> = (\n props: DateFunctionMenuProps\n) => {\n const { rhs, onChange, dateFunctionsList, status } = props;\n const { locale } = useConfiguration();\n const t = useI18n();\n\n // Options for the Date-function selector\n const dateFunctionOptions = useMemo(() => {\n const dateFunctionLabels: Record<DateFunction, string> = {\n YEARS: t('condition_builder_year'),\n QUARTERS: t('condition_builder_quarter'),\n MONTHS: t('condition_builder_month'),\n WEEKS: t('condition_builder_week'),\n DAYS: t('condition_builder_day'),\n HOURS: t('condition_builder_hour'),\n MINUTES: t('condition_builder_minute'),\n SECONDS: t('condition_builder_second'),\n HOURS_OF_DAY: t('condition_builder_date_function_hour_of_day'),\n MONTHS_OF_YEAR: t('condition_builder_date_function_month_of_year'),\n DAYS_OF_MONTH: t('condition_builder_date_function_day_of_month'),\n DAYS_OF_WEEK: t('condition_builder_date_function_day_of_week')\n };\n\n return dateFunctionsList.map(func => ({ id: func, label: dateFunctionLabels[func] }));\n }, [dateFunctionsList, t]);\n\n // Handle changes to the Date-function selector\n const handleDatePartChange = (e: ChangeEvent<HTMLSelectElement>) => {\n const selection = e.target.value as DateFunction;\n onChange({ dateFunction: selection, value: '' });\n };\n\n // Common props for all value controls\n const valueComponentProps: FormControlProps = {\n value: rhs.value === '' ? undefined : rhs.value.toString(),\n label: t('condition_builder_value_label'),\n status,\n info: status ? t('condition_builder_invalid_value') : undefined\n };\n\n // Props for all functions that use a component from the DateTime package\n const dateComponentProps: DateTimeProps = {\n ...valueComponentProps,\n onChange: ({ valueAsISOString, state }: DateTimeCallbackParameter) => {\n // NOTE: Not relying fully on `state` since in some cases state and valueAsTimestamp are both undefined\n if (valueAsISOString === undefined || state === 'incomplete' || state === 'invalid') return;\n\n // Format the value as per spec and return\n onChange({ ...rhs, value: formatDateFunctionValue(valueAsISOString, rhs.dateFunction) });\n }\n };\n\n // HOURS_OF_DAY\n const hoursOfDayItems: MenuProps['items'] = useMemo(\n () =>\n range(0, 23).map(i => {\n const index = i.toString();\n return {\n id: index,\n primary: `${index.toString().padStart(2, '0')}:00`,\n selected: rhs.value === i\n };\n }),\n [rhs.value]\n );\n\n const hoursOfDaySelected = useMemo(() => {\n return menuHelpers.getSelected(hoursOfDayItems)[0];\n }, [hoursOfDayItems]);\n\n const hourOfDayProps: ComboBoxProps = {\n ...valueComponentProps,\n value: `${rhs.value.toString().padStart(2, '0')}:00`,\n mode: 'single-select',\n menu: {\n items: hoursOfDayItems,\n onItemClick: id => {\n onChange({ ...rhs, value: Number(id) });\n }\n },\n selected: hoursOfDaySelected\n ? {\n items: {\n id: hoursOfDaySelected.id,\n text: hoursOfDaySelected.primary\n }\n }\n : undefined\n };\n\n // YEARS\n const yearOptions = useMemo(() => {\n const currentYear = new Date().getFullYear();\n const years = range(currentYear - 10, currentYear + 10);\n return years.map(year => ({\n id: `${year}-01-01`,\n label: new Date(year, 0, 1).toLocaleString(locale, { year: 'numeric' })\n }));\n }, [locale]);\n const onYearChange = (e: ChangeEvent<HTMLSelectElement>) => {\n onChange({ ...rhs, value: e.target.value });\n };\n\n // MONTHS_OF_YEAR\n const monthOfYearOptions = useMemo(\n () =>\n range(1, 12).map(n => ({\n id: `${n}`,\n label: new Date(2021, n - 1, 1).toLocaleString(locale, { month: 'long' })\n })),\n [locale]\n );\n const onMonthOfYearChange = (e: ChangeEvent<HTMLSelectElement>) => {\n const value = e.target.value ? Number(e.target.value) : '';\n onChange({ ...rhs, value });\n };\n\n // DAYS_OF_MONTH\n const onDayOfMonthChange = (value: string) => {\n let newValue: string | number = value;\n if (newValue !== '') {\n newValue = Number(newValue);\n if (newValue > 31) newValue = 31;\n if (newValue < 1) newValue = 1;\n }\n onChange({ ...rhs, value: newValue });\n };\n\n // DAYS_OF_WEEK\n const onDayOfWeekChange = (value: DayOfWeek) => {\n onChange({ ...rhs, value });\n };\n\n return (\n <>\n {/* Date function selector */}\n <Select\n label={t('condition_builder_date_part')}\n value={rhs.dateFunction}\n onChange={handleDatePartChange}\n >\n {dateFunctionOptions.map(o => (\n <Option key={o.id} value={o.id}>\n {o.label}\n </Option>\n ))}\n </Select>\n\n {rhs.dateFunction === 'YEARS' && (\n <Select {...valueComponentProps} onChange={onYearChange} name='year-selector'>\n <Option> </Option>\n {yearOptions.map(o => (\n <Option key={o.id} value={o.id}>\n {o.label}\n </Option>\n ))}\n </Select>\n )}\n {rhs.dateFunction === 'QUARTERS' && <QuarterInput {...dateComponentProps} />}\n {rhs.dateFunction === 'MONTHS' && <MonthInput {...dateComponentProps} />}\n {rhs.dateFunction === 'WEEKS' && <WeekInput {...dateComponentProps} />}\n {rhs.dateFunction === 'DAYS' && <DateInput {...dateComponentProps} />}\n {rhs.dateFunction === 'HOURS' && (\n <DateTimeInput {...dateComponentProps} pickerInterval={60} />\n )}\n {rhs.dateFunction === 'MINUTES' && (\n <DateTimeInput {...dateComponentProps} pickerInterval={60} />\n )}\n {rhs.dateFunction === 'SECONDS' && (\n <DateTimeInput {...dateComponentProps} pickerInterval={60} withSeconds />\n )}\n {rhs.dateFunction === 'HOURS_OF_DAY' && <ComboBox {...hourOfDayProps} />}\n {rhs.dateFunction === 'MONTHS_OF_YEAR' && (\n <Select\n {...valueComponentProps}\n onChange={onMonthOfYearChange}\n name='month-of-year-selector'\n >\n <Option> </Option>\n {monthOfYearOptions.map(o => (\n <Option key={o.id} value={o.id}>\n {o.label}\n </Option>\n ))}\n </Select>\n )}\n {rhs.dateFunction === 'DAYS_OF_MONTH' && (\n <NumberInput\n {...valueComponentProps}\n placeholder='1 - 31'\n min={1}\n max={31}\n step={1}\n showDecimal={false}\n onChange={onDayOfMonthChange}\n />\n )}\n {rhs.dateFunction === 'DAYS_OF_WEEK' && (\n <DayOfWeekInput\n {...valueComponentProps}\n value={rhs.value as DayOfWeek}\n onChange={onDayOfWeekChange}\n />\n )}\n </>\n );\n};\n\nexport default DateFunctionMenu;\n"]}
|