@pega/cosmos-react-condition-builder 3.0.0-dev.12.0 → 3.0.0-dev.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/ConditionBuilder/AtomicCondition.d.ts +1 -1
- package/lib/components/ConditionBuilder/AtomicCondition.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/AtomicCondition.js.map +1 -1
- package/lib/components/ConditionBuilder/core/formatter.js +2 -2
- package/lib/components/ConditionBuilder/core/formatter.js.map +1 -1
- package/lib/components/ConditionInput/ConditionInput.d.ts +6 -0
- package/lib/components/ConditionInput/ConditionInput.d.ts.map +1 -0
- package/lib/components/ConditionInput/ConditionInput.js +124 -0
- package/lib/components/ConditionInput/ConditionInput.js.map +1 -0
- package/lib/components/ConditionInput/ConditionInput.types.d.ts +21 -0
- package/lib/components/ConditionInput/ConditionInput.types.d.ts.map +1 -0
- package/lib/components/ConditionInput/ConditionInput.types.js +2 -0
- package/lib/components/ConditionInput/ConditionInput.types.js.map +1 -0
- package/lib/components/ConditionInput/index.d.ts +3 -0
- package/lib/components/ConditionInput/index.d.ts.map +1 -0
- package/lib/components/ConditionInput/index.js +2 -0
- package/lib/components/ConditionInput/index.js.map +1 -0
- package/lib/components/PromotedFilters/PromotedFilters.d.ts +6 -0
- package/lib/components/PromotedFilters/PromotedFilters.d.ts.map +1 -0
- package/lib/components/PromotedFilters/PromotedFilters.js +50 -0
- package/lib/components/PromotedFilters/PromotedFilters.js.map +1 -0
- package/lib/components/PromotedFilters/PromotedFilters.types.d.ts +25 -0
- package/lib/components/PromotedFilters/PromotedFilters.types.d.ts.map +1 -0
- package/lib/components/PromotedFilters/PromotedFilters.types.js +2 -0
- package/lib/components/PromotedFilters/PromotedFilters.types.js.map +1 -0
- package/lib/components/PromotedFilters/index.d.ts +3 -0
- package/lib/components/PromotedFilters/index.d.ts.map +1 -0
- package/lib/components/PromotedFilters/index.js +2 -0
- package/lib/components/PromotedFilters/index.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/package.json +5 -2
|
@@ -12,7 +12,7 @@ export declare function getInitConditionForLhs(lhs: LeafCondition['lhs'], fields
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function isValidCondition(condition: LeafCondition, fields: Field[], trimValues?: boolean): boolean;
|
|
14
14
|
/** Type definition for the input props of AtomicCondition */
|
|
15
|
-
interface AtomicConditionProps extends BaseProps {
|
|
15
|
+
export interface AtomicConditionProps extends BaseProps {
|
|
16
16
|
/** Condition to use in the component */
|
|
17
17
|
condition: LeafCondition;
|
|
18
18
|
/** Metadata (data-model) for the Fields to use in the Condition */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AtomicCondition.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/AtomicCondition.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAe,MAAM,OAAO,CAAC;AAEvD,OAAO,EAOL,SAAS,EACT,YAAY,EACb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAIrF,OAAO,EAAc,iBAAiB,EAAa,OAAO,EAAE,MAAM,cAAc,CAAC;AA2CjF,oEAAoE;AACpE,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,aAAa,CAAC,KAAK,CAAC,EACzB,MAAM,EAAE,KAAK,EAAE,EACf,aAAa,EAAE,GAAG,CAAC,OAAO,CAAC,EAC3B,gBAAgB,CAAC,EAAE,iBAAiB,EAAE,EACtC,aAAa,CAAC,EAAE,mBAAmB,GAClC,aAAa,CAcf;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,aAAa,EACxB,MAAM,EAAE,KAAK,EAAE,EACf,UAAU,GAAE,OAAe,GAC1B,OAAO,CAST;AAED,6DAA6D;AA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AAC,KAAK,EAC1B,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,cAAc,IAAI,SAAS,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAC1E,IAAI,EACF,cAAc,IAAI,SAAS,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE;oBAC1C,CAAC,CAAC,CAAC,CAAC,iDAAiD,CAAC;oBACtD,CAAC,CAAC,SAAS,GAEf,CACH,EAGD,KAAC,MAAM,IACL,KAAK,EAAE,SAAS,CAAC,UAAU,EAC3B,QAAQ,EAAE,sBAAsB,EAChC,IAAI,EAAC,YAAY,EACjB,KAAK,EAAC,GAAG,EACT,WAAW,kBAEV,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,SAAS,CAAC,GAAG,EAClB,UAAU,EAAE,SAAS,CAAC,UAAU,EAChC,GAAG,EAAE,SAAS,CAAC,GAAG,EAClB,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,GACrC,IACG,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { FunctionComponent, ChangeEvent } from 'react';\n\nimport {\n Grid,\n Select,\n Option,\n Text,\n useI18n,\n hasProp,\n BaseProps,\n ForwardProps\n} from '@pega/cosmos-react-core';\n\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';\n\n// Returns field-type for a given field-name\nfunction getFieldType(fieldName: string, fields: Field[]): FieldType | undefined {\n const matchingField = fields.find(f => f.name === fieldName);\n return matchingField?.type;\n}\n\n// Returns display label for a given field-name\nfunction getFieldLabel(fieldName: string, fields: Field[]): string | undefined {\n const matchingField = fields.find(f => f.name === fieldName);\n return matchingField?.label || matchingField?.name;\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 // `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, fieldType, trimValues);\n}\n\n/** Type definition for the input props of AtomicCondition */\ninterface 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) => void;\n\n /** Item flow direction. Defaults to 'row' */\n itemDirection?: 'row' | 'column';\n\n /**\n * Allows showing the LHS as a readonly label.\n * NOTE: Make sure that a valid LHS is passed in the 'condition'\n */\n showLhsAsLabel?: boolean;\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\n/** A controlled component for Atomic Conditions */\nconst AtomicCondition: FunctionComponent<AtomicConditionProps & ForwardProps> = (\n props: AtomicConditionProps\n) => {\n const {\n condition,\n fields,\n indicateErrors,\n validComparators,\n onChange,\n itemDirection,\n showLhsAsLabel,\n validRhsTypes = new Set<RHSType>(['LITERAL', 'FIELD']),\n dateFunctions\n } = props;\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: 'Select…' }]; // FIXME: TR\n\n // Handle change in the field-selector\n const handleFieldChange = (id: string) => {\n const lhs = { field: id };\n const newCondition = getInitConditionForLhs(\n lhs,\n fields,\n validRhsTypes,\n validComparators,\n dateFunctions\n ); // Determine comparator and rhs for the new lhs\n onChange(newCondition); // Submit the new condition\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\n : getDefaultRhs(fieldType as FieldType, comparator, validRhsTypes, dateFunctions);\n onChange({ ...condition, comparator, rhs }); // Submit the new condition\n };\n\n // Handle change in the RHS\n const handleRHSChange = (rhs: LeafCondition['rhs']) => {\n onChange({ ...condition, rhs }); // Submit the new condition\n };\n\n const t = useI18n();\n\n return (\n // Using minmax() to get equal widths: https://stackoverflow.com/a/61240964/4247448\n <Grid\n sm={{\n container: { cols: itemDirection === 'column' ? '1fr' : 'repeat(3, minmax(5rem,1fr))' }\n }}\n md={{\n container: { cols: itemDirection === 'column' ? '1fr' : 'repeat(3, minmax(10rem,1fr))' }\n }}\n container={{\n justifyItems: 'stretch',\n colGap: 0.5,\n rowGap: 0.5\n }}\n >\n {/* LHS label */}\n {showLhsAsLabel && (\n <Text variant='secondary'>{getFieldLabel(condition.lhs.field, fields)}</Text>\n )}\n {/* LHS selector */}\n {!showLhsAsLabel && (\n <FieldSelector\n value={condition.lhs.field}\n onChange={handleFieldChange}\n fields={fields}\n status={indicateErrors && condition.lhs.field === '' ? 'error' : undefined}\n info={\n indicateErrors && condition.lhs.field === ''\n ? t('condition_builder_condition_select_info_default')\n : undefined\n }\n />\n )}\n\n {/* Comparator selector */}\n <Select\n value={condition.comparator}\n onChange={handleComparatorChange}\n name='comparator'\n label='-'\n labelHidden\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={condition.lhs}\n comparator={condition.comparator}\n rhs={condition.rhs}\n fields={fields}\n onChange={handleRHSChange}\n indicateErrors={indicateErrors}\n validRhsTypes={validRhsTypes}\n dateFunctions={dateFunctions}\n itemDirection={itemDirection || 'row'}\n />\n </Grid>\n );\n};\n\nexport default AtomicCondition;\n"]}
|
|
1
|
+
{"version":3,"file":"AtomicCondition.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/AtomicCondition.tsx"],"names":[],"mappings":";AAEA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,MAAM,EACN,IAAI,EACJ,OAAO,EACP,OAAO,EAGR,MAAM,yBAAyB,CAAC;AAGjC,OAAO,aAAa,MAAM,6BAA6B,CAAC;AACxD,OAAO,WAAW,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,oBAAoB,MAAM,oBAAoB,CAAC;AAGtD,4CAA4C;AAC5C,SAAS,YAAY,CAAC,SAAiB,EAAE,MAAe;IACtD,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IAC7D,OAAO,aAAa,EAAE,IAAI,CAAC;A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d,QAAQ,EAAE,eAAe,EACzB,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,IAAI,KAAK,GACrC,IACG,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { FunctionComponent, ChangeEvent } from 'react';\n\nimport {\n Grid,\n Select,\n Option,\n Text,\n useI18n,\n hasProp,\n BaseProps,\n ForwardProps\n} from '@pega/cosmos-react-core';\n\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';\n\n// Returns field-type for a given field-name\nfunction getFieldType(fieldName: string, fields: Field[]): FieldType | undefined {\n const matchingField = fields.find(f => f.name === fieldName);\n return matchingField?.type;\n}\n\n// Returns display label for a given field-name\nfunction getFieldLabel(fieldName: string, fields: Field[]): string | undefined {\n const matchingField = fields.find(f => f.name === fieldName);\n return matchingField?.label || matchingField?.name;\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 // `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, 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) => void;\n\n /** Item flow direction. Defaults to 'row' */\n itemDirection?: 'row' | 'column';\n\n /**\n * Allows showing the LHS as a readonly label.\n * NOTE: Make sure that a valid LHS is passed in the 'condition'\n */\n showLhsAsLabel?: boolean;\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\n/** A controlled component for Atomic Conditions */\nconst AtomicCondition: FunctionComponent<AtomicConditionProps & ForwardProps> = (\n props: AtomicConditionProps\n) => {\n const {\n condition,\n fields,\n indicateErrors,\n validComparators,\n onChange,\n itemDirection,\n showLhsAsLabel,\n validRhsTypes = new Set<RHSType>(['LITERAL', 'FIELD']),\n dateFunctions\n } = props;\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: 'Select…' }]; // FIXME: TR\n\n // Handle change in the field-selector\n const handleFieldChange = (id: string) => {\n const lhs = { field: id };\n const newCondition = getInitConditionForLhs(\n lhs,\n fields,\n validRhsTypes,\n validComparators,\n dateFunctions\n ); // Determine comparator and rhs for the new lhs\n onChange(newCondition); // Submit the new condition\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\n : getDefaultRhs(fieldType as FieldType, comparator, validRhsTypes, dateFunctions);\n onChange({ ...condition, comparator, rhs }); // Submit the new condition\n };\n\n // Handle change in the RHS\n const handleRHSChange = (rhs: LeafCondition['rhs']) => {\n onChange({ ...condition, rhs }); // Submit the new condition\n };\n\n const t = useI18n();\n\n return (\n // Using minmax() to get equal widths: https://stackoverflow.com/a/61240964/4247448\n <Grid\n sm={{\n container: { cols: itemDirection === 'column' ? '1fr' : 'repeat(3, minmax(5rem,1fr))' }\n }}\n md={{\n container: { cols: itemDirection === 'column' ? '1fr' : 'repeat(3, minmax(10rem,1fr))' }\n }}\n container={{\n justifyItems: 'stretch',\n colGap: 0.5,\n rowGap: 0.5\n }}\n >\n {/* LHS label */}\n {showLhsAsLabel && (\n <Text variant='secondary'>{getFieldLabel(condition.lhs.field, fields)}</Text>\n )}\n {/* LHS selector */}\n {!showLhsAsLabel && (\n <FieldSelector\n value={condition.lhs.field}\n onChange={handleFieldChange}\n fields={fields}\n status={indicateErrors && condition.lhs.field === '' ? 'error' : undefined}\n info={\n indicateErrors && condition.lhs.field === ''\n ? t('condition_builder_condition_select_info_default')\n : undefined\n }\n />\n )}\n\n {/* Comparator selector */}\n <Select\n value={condition.comparator}\n onChange={handleComparatorChange}\n name='comparator'\n label='-'\n labelHidden\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={condition.lhs}\n comparator={condition.comparator}\n rhs={condition.rhs}\n fields={fields}\n onChange={handleRHSChange}\n indicateErrors={indicateErrors}\n validRhsTypes={validRhsTypes}\n dateFunctions={dateFunctions}\n itemDirection={itemDirection || 'row'}\n />\n </Grid>\n );\n};\n\nexport default AtomicCondition;\n"]}
|
|
@@ -99,8 +99,8 @@ function formatLeafCondition(leaf, fields, translate, { locale = 'en-US' } = {})
|
|
|
99
99
|
break;
|
|
100
100
|
case 'NUMBER':
|
|
101
101
|
rhsText = getFormattedValue(rhs.value.toString(), locale, undefined, {
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
useGrouping: true,
|
|
103
|
+
maximumFractionDigits: 4
|
|
104
104
|
});
|
|
105
105
|
break;
|
|
106
106
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/core/formatter.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,mEAAmE;AACnE,OAAO,EAAE,OAAO,EAAmB,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAExF,OAAO,EAAE,UAAU,EAAE,MAAM,6DAA6D,CAAC;AAKzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,MAAM,GAAG,GAAG,CAAC;AACnB,MAAM,MAAM,GAAG,GAAG,CAAC;AAOnB,MAAM,UAAU,kBAAkB,CAChC,SAA+C,EAC/C,UAAsB,EACtB,QAAkB,EAClB,QAAiB;IAEjB,MAAM,cAAc,GAClB,UAAU,KAAK,SAAS;QACtB,CAAC,CAAC,6BAA6B,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;QACpE,CAAC,CAAC,qBAAqB,UAAU,CAAC,WAAW,EAAE,MAAM,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC;IAClF,OAAO,SAAS,CAAC,cAAuC,EAAE,CAAC,QAAQ,IAAI,CAAC,CAAC,EAAE;QACzE,KAAK,EAAE,QAAQ,IAAI,CAAC;KACrB,CAAC,CAAC;AACL,CAAC;AAED,4EAA4E;AAC5E,SAAS,mBAAmB,CAC1B,IAAmB,EACnB,MAAe,EACf,SAA+C,EAC/C,EAAE,MAAM,GAAG,OAAO,KAA6B,EAAE;IAEjD,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAEtC,kCAAkC;IAClC,MA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AAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACpD,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KAC1B;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["// cSpell:words LPAREN RPAREN\n// FIXME: TR (Several constructs in this file need to be localized)\nimport { hasProp, TranslationPack } from '@pega/cosmos-react-core';\nimport { getFormattedValue } from '@pega/cosmos-react-core/lib/components/Number/utils';\nimport { TranslationFunction } from '@pega/cosmos-react-core/lib/i18n/translate';\nimport { getQuarter } from '@pega/cosmos-react-core/lib/components/DateTime/Input/utils';\n\nimport { Condition, LeafCondition, Field } from '../ConditionBuilder.types';\n\nimport { DatePart, TimePeriod } from './types';\nimport { convertMsToTimeValue } from './time-utils';\n\nconst LPAREN = '(';\nconst RPAREN = ')';\n\n/** Options object optionally passed to formatCondition method. */\ninterface ConditionFormatOptions {\n locale?: string;\n}\n\nexport function formatRelativeDate(\n translate: TranslationFunction<TranslationPack>,\n timePeriod: TimePeriod,\n datePart: DatePart,\n interval?: number\n): string {\n const translationKey =\n timePeriod === 'CURRENT'\n ? `condition_builder_current_${datePart.toLowerCase().slice(0, -1)}`\n : `condition_builder_${timePeriod.toLowerCase()}_X_${datePart.toLowerCase()}`;\n return translate(translationKey as keyof TranslationPack, [interval ?? 0], {\n count: interval ?? 0\n });\n}\n\n/** Returns a user-friendly text representation of a given leaf condition */\nfunction formatLeafCondition(\n leaf: LeafCondition,\n fields: Field[],\n translate: TranslationFunction<TranslationPack>,\n { locale = 'en-US' }: ConditionFormatOptions = {}\n): string {\n const { lhs, comparator, rhs } = leaf;\n\n // Determine texts for LHS and RHS\n const lhsField = fields.find(f => f.name === lhs.field) as Field; // Expecting valid inputs\n const lhsText = lhsField.label || lhsField.name; // label is optional\n let rhsText = '';\n if (rhs) {\n if (hasProp(rhs, 'field')) {\n // If RHS is another field\n const rhsField = fields.find(f => f.name === rhs.field) as Field; // Expecting valid inputs\n rhsText = rhsField.label || rhsField.name; // label is optional\n } else if (hasProp(rhs, 'value')) {\n if (hasProp(rhs, 'dateFunction')) {\n // If RHS is a date function value\n switch (rhs.dateFunction) {\n case 'YEARS':\n rhsText = new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {\n year: 'numeric'\n });\n break;\n case 'QUARTERS': {\n const formattedYear = new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {\n year: 'numeric'\n });\n const quarterNumber = getQuarter(rhs.value);\n rhsText = `${translate(`date_quarter_q${quarterNumber}`, [formattedYear])}`;\n break;\n }\n case 'MONTHS':\n rhsText = new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {\n year: 'numeric',\n month: 'short'\n });\n break;\n case 'WEEKS':\n rhsText = `Week of ${new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {\n year: 'numeric',\n month: 'short',\n day: 'numeric'\n })}`;\n break;\n case 'DAYS':\n rhsText = new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {\n year: 'numeric',\n month: 'short',\n day: 'numeric'\n });\n break;\n case 'HOURS':\n rhsText = new Date(rhs.value).toLocaleString(locale, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n hour: 'numeric',\n hour12: true\n });\n break;\n case 'MONTHS_OF_YEAR':\n rhsText = new Date(2021, (rhs.value as number) - 1, 1).toLocaleString(locale, {\n month: 'long'\n });\n break;\n case 'DAYS_OF_MONTH':\n rhsText = `Day ${rhs.value} of month`;\n break;\n case 'DAYS_OF_WEEK':\n // Choosing Feb-2021 as it starts on a Monday\n rhsText = new Date(2021, 1, rhs.value as number).toLocaleString(locale, {\n weekday: 'long'\n });\n break;\n default: // Not needed\n }\n } else {\n // If RHS is a single literal value\n switch (lhsField.type) {\n case 'TIME_ONLY':\n // For these cases, rhs.value is stored as # of milliseconds since day-start\n rhsText = convertMsToTimeValue(rhs.value as number);\n break;\n case 'NUMBER':\n rhsText = getFormattedValue(rhs.value.toString(), locale, undefined, {\n showGroupSeparators: true,\n numberOfDecimals: 4\n });\n break;\n default:\n rhsText = rhs.value as string;\n }\n }\n } else if (hasProp(rhs, 'relativeDate')) {\n const {\n relativeDate: { timePeriod, interval, datePart }\n } = rhs;\n rhsText = formatRelativeDate(translate, timePeriod, datePart, interval);\n } else {\n rhsText = rhs.values.join(', '); // If RHS is a list of values\n }\n }\n\n switch (comparator) {\n case 'IS_NULL':\n return `${lhsText} is null`;\n case 'IS_NOT_NULL':\n return `${lhsText} is not null`;\n case 'IS_TRUE':\n return `${lhsText} is true`;\n case 'IS_FALSE':\n return `${lhsText} is false`;\n case 'EQ':\n return `${lhsText} is ${rhsText}`;\n case 'NEQ':\n return `${lhsText} isn't ${rhsText}`;\n case 'IN':\n return `${lhsText} is among ${rhsText}`;\n case 'NOT_IN':\n return `${lhsText} is not among ${rhsText}`;\n case 'GT':\n return `${lhsText} > ${rhsText}`;\n case 'GTE':\n return `${lhsText} >= ${rhsText}`;\n case 'LT':\n return `${lhsText} < ${rhsText}`;\n case 'LTE':\n return `${lhsText} <= ${rhsText}`;\n case 'STARTS_WITH':\n return `${lhsText} starts with ${rhsText}`;\n case 'NOT_STARTS_WITH':\n return `${lhsText} doesn't start with ${rhsText}`;\n case 'ENDS_WITH':\n return `${lhsText} ends with ${rhsText}`;\n case 'NOT_ENDS_WITH':\n return `${lhsText} doesn't end with ${rhsText}`;\n case 'CONTAINS':\n return `${lhsText} contains ${rhsText}`;\n case 'NOT_CONTAINS':\n return `${lhsText} doesn't contain ${rhsText}`;\n default:\n return ''; // Not needed\n }\n}\n\n/** Returns a user-friendly text representation of the given node in a condition */\nfunction formatConditionNode(\n node: Condition,\n fields: Field[],\n translate: TranslationFunction<TranslationPack>,\n options?: ConditionFormatOptions\n): string {\n if (hasProp(node, 'AND')) {\n const childStrings = node.AND.map(n => formatConditionNode(n, fields, translate, options));\n return `(${childStrings.join(' AND ')})`;\n }\n\n if (hasProp(node, 'OR')) {\n const childStrings = node.OR.map(n => formatConditionNode(n, fields, translate, options));\n return `(${childStrings.join(' OR ')})`;\n }\n\n if (hasProp(node, 'NOT')) {\n const childString = formatConditionNode(node.NOT, fields, translate, options);\n if (childString.startsWith(LPAREN) && childString.endsWith(RPAREN)) {\n // Avoid double brackets when the child node is an AND/OR node\n return `NOT ${childString}`;\n }\n return `NOT (${childString})`;\n }\n\n return formatLeafCondition(node.condition, fields, translate, options); // If leaf-level is reached\n}\n\n/**\n * Returns a user-friendly text representation of a given complex condition\n * The input `fields` are used to look up display labels for the fields\n */\nexport default function formatCondition(\n condition: Condition,\n fields: Field[],\n translate: TranslationFunction<TranslationPack>,\n options?: ConditionFormatOptions\n): string {\n // Recursively format the tree, starting at the root node\n let text = formatConditionNode(condition, fields, translate, options);\n\n // If the root node is AND/OR, there will be extra parentheses. Remove them\n if (text.startsWith(LPAREN) && text.endsWith(RPAREN)) {\n text = text.slice(1, -1);\n }\n\n return text;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/core/formatter.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,mEAAmE;AACnE,OAAO,EAAE,OAAO,EAAmB,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAExF,OAAO,EAAE,UAAU,EAAE,MAAM,6DAA6D,CAAC;AAKzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,MAAM,GAAG,GAAG,CAAC;AACnB,MAAM,MAAM,GAAG,GAAG,CAAC;AAOnB,MAAM,UAAU,kBAAkB,CAChC,SAA+C,EAC/C,UAAsB,EACtB,QAAkB,EAClB,QAAiB;IAEjB,MAAM,cAAc,GAClB,UAAU,KAAK,SAAS;QACtB,CAAC,CAAC,6BAA6B,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,E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8DAA8D;YAC9D,OAAO,OAAO,WAAW,EAAE,CAAC;SAC7B;QACD,OAAO,QAAQ,WAAW,GAAG,CAAC;KAC/B;IAED,OAAO,mBAAmB,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,2BAA2B;AACrG,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,SAAoB,EACpB,MAAe,EACf,SAA+C,EAC/C,OAAgC;IAEhC,yDAAyD;IACzD,IAAI,IAAI,GAAG,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAEtE,2EAA2E;IAC3E,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACpD,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KAC1B;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["// cSpell:words LPAREN RPAREN\n// FIXME: TR (Several constructs in this file need to be localized)\nimport { hasProp, TranslationPack } from '@pega/cosmos-react-core';\nimport { getFormattedValue } from '@pega/cosmos-react-core/lib/components/Number/utils';\nimport { TranslationFunction } from '@pega/cosmos-react-core/lib/i18n/translate';\nimport { getQuarter } from '@pega/cosmos-react-core/lib/components/DateTime/Input/utils';\n\nimport { Condition, LeafCondition, Field } from '../ConditionBuilder.types';\n\nimport { DatePart, TimePeriod } from './types';\nimport { convertMsToTimeValue } from './time-utils';\n\nconst LPAREN = '(';\nconst RPAREN = ')';\n\n/** Options object optionally passed to formatCondition method. */\ninterface ConditionFormatOptions {\n locale?: string;\n}\n\nexport function formatRelativeDate(\n translate: TranslationFunction<TranslationPack>,\n timePeriod: TimePeriod,\n datePart: DatePart,\n interval?: number\n): string {\n const translationKey =\n timePeriod === 'CURRENT'\n ? `condition_builder_current_${datePart.toLowerCase().slice(0, -1)}`\n : `condition_builder_${timePeriod.toLowerCase()}_X_${datePart.toLowerCase()}`;\n return translate(translationKey as keyof TranslationPack, [interval ?? 0], {\n count: interval ?? 0\n });\n}\n\n/** Returns a user-friendly text representation of a given leaf condition */\nfunction formatLeafCondition(\n leaf: LeafCondition,\n fields: Field[],\n translate: TranslationFunction<TranslationPack>,\n { locale = 'en-US' }: ConditionFormatOptions = {}\n): string {\n const { lhs, comparator, rhs } = leaf;\n\n // Determine texts for LHS and RHS\n const lhsField = fields.find(f => f.name === lhs.field) as Field; // Expecting valid inputs\n const lhsText = lhsField.label || lhsField.name; // label is optional\n let rhsText = '';\n if (rhs) {\n if (hasProp(rhs, 'field')) {\n // If RHS is another field\n const rhsField = fields.find(f => f.name === rhs.field) as Field; // Expecting valid inputs\n rhsText = rhsField.label || rhsField.name; // label is optional\n } else if (hasProp(rhs, 'value')) {\n if (hasProp(rhs, 'dateFunction')) {\n // If RHS is a date function value\n switch (rhs.dateFunction) {\n case 'YEARS':\n rhsText = new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {\n year: 'numeric'\n });\n break;\n case 'QUARTERS': {\n const formattedYear = new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {\n year: 'numeric'\n });\n const quarterNumber = getQuarter(rhs.value);\n rhsText = `${translate(`date_quarter_q${quarterNumber}`, [formattedYear])}`;\n break;\n }\n case 'MONTHS':\n rhsText = new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {\n year: 'numeric',\n month: 'short'\n });\n break;\n case 'WEEKS':\n rhsText = `Week of ${new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {\n year: 'numeric',\n month: 'short',\n day: 'numeric'\n })}`;\n break;\n case 'DAYS':\n rhsText = new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {\n year: 'numeric',\n month: 'short',\n day: 'numeric'\n });\n break;\n case 'HOURS':\n rhsText = new Date(rhs.value).toLocaleString(locale, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n hour: 'numeric',\n hour12: true\n });\n break;\n case 'MONTHS_OF_YEAR':\n rhsText = new Date(2021, (rhs.value as number) - 1, 1).toLocaleString(locale, {\n month: 'long'\n });\n break;\n case 'DAYS_OF_MONTH':\n rhsText = `Day ${rhs.value} of month`;\n break;\n case 'DAYS_OF_WEEK':\n // Choosing Feb-2021 as it starts on a Monday\n rhsText = new Date(2021, 1, rhs.value as number).toLocaleString(locale, {\n weekday: 'long'\n });\n break;\n default: // Not needed\n }\n } else {\n // If RHS is a single literal value\n switch (lhsField.type) {\n case 'TIME_ONLY':\n // For these cases, rhs.value is stored as # of milliseconds since day-start\n rhsText = convertMsToTimeValue(rhs.value as number);\n break;\n case 'NUMBER':\n rhsText = getFormattedValue(rhs.value.toString(), locale, undefined, {\n useGrouping: true,\n maximumFractionDigits: 4\n });\n break;\n default:\n rhsText = rhs.value as string;\n }\n }\n } else if (hasProp(rhs, 'relativeDate')) {\n const {\n relativeDate: { timePeriod, interval, datePart }\n } = rhs;\n rhsText = formatRelativeDate(translate, timePeriod, datePart, interval);\n } else {\n rhsText = rhs.values.join(', '); // If RHS is a list of values\n }\n }\n\n switch (comparator) {\n case 'IS_NULL':\n return `${lhsText} is null`;\n case 'IS_NOT_NULL':\n return `${lhsText} is not null`;\n case 'IS_TRUE':\n return `${lhsText} is true`;\n case 'IS_FALSE':\n return `${lhsText} is false`;\n case 'EQ':\n return `${lhsText} is ${rhsText}`;\n case 'NEQ':\n return `${lhsText} isn't ${rhsText}`;\n case 'IN':\n return `${lhsText} is among ${rhsText}`;\n case 'NOT_IN':\n return `${lhsText} is not among ${rhsText}`;\n case 'GT':\n return `${lhsText} > ${rhsText}`;\n case 'GTE':\n return `${lhsText} >= ${rhsText}`;\n case 'LT':\n return `${lhsText} < ${rhsText}`;\n case 'LTE':\n return `${lhsText} <= ${rhsText}`;\n case 'STARTS_WITH':\n return `${lhsText} starts with ${rhsText}`;\n case 'NOT_STARTS_WITH':\n return `${lhsText} doesn't start with ${rhsText}`;\n case 'ENDS_WITH':\n return `${lhsText} ends with ${rhsText}`;\n case 'NOT_ENDS_WITH':\n return `${lhsText} doesn't end with ${rhsText}`;\n case 'CONTAINS':\n return `${lhsText} contains ${rhsText}`;\n case 'NOT_CONTAINS':\n return `${lhsText} doesn't contain ${rhsText}`;\n default:\n return ''; // Not needed\n }\n}\n\n/** Returns a user-friendly text representation of the given node in a condition */\nfunction formatConditionNode(\n node: Condition,\n fields: Field[],\n translate: TranslationFunction<TranslationPack>,\n options?: ConditionFormatOptions\n): string {\n if (hasProp(node, 'AND')) {\n const childStrings = node.AND.map(n => formatConditionNode(n, fields, translate, options));\n return `(${childStrings.join(' AND ')})`;\n }\n\n if (hasProp(node, 'OR')) {\n const childStrings = node.OR.map(n => formatConditionNode(n, fields, translate, options));\n return `(${childStrings.join(' OR ')})`;\n }\n\n if (hasProp(node, 'NOT')) {\n const childString = formatConditionNode(node.NOT, fields, translate, options);\n if (childString.startsWith(LPAREN) && childString.endsWith(RPAREN)) {\n // Avoid double brackets when the child node is an AND/OR node\n return `NOT ${childString}`;\n }\n return `NOT (${childString})`;\n }\n\n return formatLeafCondition(node.condition, fields, translate, options); // If leaf-level is reached\n}\n\n/**\n * Returns a user-friendly text representation of a given complex condition\n * The input `fields` are used to look up display labels for the fields\n */\nexport default function formatCondition(\n condition: Condition,\n fields: Field[],\n translate: TranslationFunction<TranslationPack>,\n options?: ConditionFormatOptions\n): string {\n // Recursively format the tree, starting at the root node\n let text = formatConditionNode(condition, fields, translate, options);\n\n // If the root node is AND/OR, there will be extra parentheses. Remove them\n if (text.startsWith(LPAREN) && text.endsWith(RPAREN)) {\n text = text.slice(1, -1);\n }\n\n return text;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import { ConditionInputProps } from './ConditionInput.types';
|
|
4
|
+
declare const ConditionInput: FunctionComponent<ConditionInputProps & ForwardProps>;
|
|
5
|
+
export default ConditionInput;
|
|
6
|
+
//# sourceMappingURL=ConditionInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConditionInput.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionInput/ConditionInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAKlB,MAAM,OAAO,CAAC;AAGf,OAAO,EAIL,YAAY,EAQb,MAAM,yBAAyB,CAAC;AAUjC,OAAO,EAAsB,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAkCjF,QAAA,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,GAAG,YAAY,CA6KzE,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState, useEffect } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { CompositeInput, defaultThemeProp, hasProp, Input, NumberInput, RadioButton, RadioButtonGroup, StyledGrid, useI18n } from '@pega/cosmos-react-core';
|
|
5
|
+
import AtomicCondition, { getInitConditionForLhs } from '../ConditionBuilder/AtomicCondition';
|
|
6
|
+
import formatCondition from '../ConditionBuilder/core/formatter';
|
|
7
|
+
const defaultComparators = {
|
|
8
|
+
TEXT: 'CONTAINS',
|
|
9
|
+
EMAIL: 'CONTAINS',
|
|
10
|
+
URL: 'CONTAINS',
|
|
11
|
+
PHONE: 'CONTAINS',
|
|
12
|
+
INTEGER: 'EQ',
|
|
13
|
+
DECIMAL: 'EQ',
|
|
14
|
+
PERCENTAGE: 'EQ',
|
|
15
|
+
CURRENCY: 'EQ',
|
|
16
|
+
BOOLEAN: 'IS_TRUE'
|
|
17
|
+
};
|
|
18
|
+
const basicFieldMap = {
|
|
19
|
+
EMAIL: 'TEXT',
|
|
20
|
+
URL: 'TEXT',
|
|
21
|
+
PHONE: 'TEXT',
|
|
22
|
+
INTEGER: 'NUMBER',
|
|
23
|
+
DECIMAL: 'NUMBER',
|
|
24
|
+
PERCENTAGE: 'NUMBER',
|
|
25
|
+
CURRENCY: 'NUMBER',
|
|
26
|
+
TEXT: 'TEXT',
|
|
27
|
+
BOOLEAN: 'BOOLEAN'
|
|
28
|
+
};
|
|
29
|
+
const StyledConditionRadioGroup = styled(RadioButtonGroup) `
|
|
30
|
+
${StyledGrid} {
|
|
31
|
+
display: inline-flex;
|
|
32
|
+
} ;
|
|
33
|
+
`;
|
|
34
|
+
StyledConditionRadioGroup.defaultProps = defaultThemeProp;
|
|
35
|
+
const ConditionInput = forwardRef(({ fieldName, fieldType, condition: conditionProp, fieldLabel, mode, onChange }, ref) => {
|
|
36
|
+
const t = useI18n();
|
|
37
|
+
const basicType = basicFieldMap[fieldType] ?? fieldType;
|
|
38
|
+
const fields = [
|
|
39
|
+
{ name: fieldName, type: basicType, label: fieldLabel }
|
|
40
|
+
];
|
|
41
|
+
const condition = conditionProp ??
|
|
42
|
+
(fieldType === 'BOOLEAN'
|
|
43
|
+
? undefined
|
|
44
|
+
: getInitConditionForLhs({ field: fieldName }, fields, new Set(['LITERAL'])));
|
|
45
|
+
const onRadioButtonChange = (value) => {
|
|
46
|
+
const updatedCondition = value === undefined
|
|
47
|
+
? undefined
|
|
48
|
+
: {
|
|
49
|
+
lhs: { field: fieldName },
|
|
50
|
+
comparator: value ? 'IS_TRUE' : 'IS_FALSE'
|
|
51
|
+
};
|
|
52
|
+
onChange(updatedCondition);
|
|
53
|
+
};
|
|
54
|
+
const createConditionForDefaultMode = (value) => {
|
|
55
|
+
return {
|
|
56
|
+
lhs: { field: fieldName },
|
|
57
|
+
comparator: defaultComparators[fieldType],
|
|
58
|
+
rhs: { value: basicType === 'NUMBER' ? Number(value) : value }
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
const rhsValue = condition?.rhs && hasProp(condition.rhs, 'value')
|
|
62
|
+
? condition.rhs.value.toString()
|
|
63
|
+
: undefined;
|
|
64
|
+
const [inputValue, setInputValue] = useState(rhsValue);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
setInputValue(rhsValue);
|
|
67
|
+
}, [conditionProp]);
|
|
68
|
+
const showAdvanced = mode === 'advanced' && fieldType !== 'BOOLEAN';
|
|
69
|
+
let defaultControl = null;
|
|
70
|
+
if (!showAdvanced) {
|
|
71
|
+
switch (fieldType) {
|
|
72
|
+
case 'INTEGER':
|
|
73
|
+
case 'DECIMAL':
|
|
74
|
+
case 'PERCENTAGE':
|
|
75
|
+
case 'CURRENCY':
|
|
76
|
+
defaultControl = (_jsx(NumberInput, { label: fieldLabel, ref: ref, value: inputValue, onChange: setInputValue, onBlur: value => {
|
|
77
|
+
onChange(createConditionForDefaultMode(value));
|
|
78
|
+
}, numberOfDecimals: fieldType === 'INTEGER' ? 0 : undefined }));
|
|
79
|
+
break;
|
|
80
|
+
case 'BOOLEAN':
|
|
81
|
+
defaultControl = (_jsxs(StyledConditionRadioGroup, { ref: ref, label: fieldLabel, name: fieldName, inline: true, children: [_jsx(RadioButton, { label: t('show_all'), checked: condition === undefined, onChange: () => onRadioButtonChange() }), _jsx(RadioButton, { label: t('boolean_display_true_label'), checked: condition?.comparator === 'IS_TRUE', onChange: () => onRadioButtonChange(true) }), _jsx(RadioButton, { label: t('boolean_display_false_label'), checked: condition?.comparator === 'IS_FALSE', onChange: () => onRadioButtonChange(false) })] }));
|
|
82
|
+
break;
|
|
83
|
+
case 'TEXT':
|
|
84
|
+
case 'EMAIL':
|
|
85
|
+
case 'URL':
|
|
86
|
+
case 'PHONE':
|
|
87
|
+
default:
|
|
88
|
+
defaultControl = (_jsx(Input, { label: fieldLabel, ref: ref, value: inputValue, onChange: (e) => setInputValue(e.target.value), onBlur: (e) => onChange(createConditionForDefaultMode(e.target.value)) }));
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const [newCondition, setNewCondition] = useState(condition);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
setNewCondition(condition);
|
|
95
|
+
}, [conditionProp]);
|
|
96
|
+
const dialog = {
|
|
97
|
+
renderer: AtomicCondition,
|
|
98
|
+
rendererProps: {
|
|
99
|
+
condition: newCondition ??
|
|
100
|
+
getInitConditionForLhs({ field: fieldName }, fields, new Set(['LITERAL'])),
|
|
101
|
+
fields,
|
|
102
|
+
onChange: setNewCondition,
|
|
103
|
+
itemDirection: 'column',
|
|
104
|
+
showLhsAsLabel: true,
|
|
105
|
+
validRhsTypes: new Set(['LITERAL']),
|
|
106
|
+
indicateErrors: false
|
|
107
|
+
},
|
|
108
|
+
onCancel: ({ close }) => {
|
|
109
|
+
setNewCondition(condition);
|
|
110
|
+
close();
|
|
111
|
+
},
|
|
112
|
+
onApply: ({ close }) => {
|
|
113
|
+
onChange(newCondition);
|
|
114
|
+
close();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const onClear = () => {
|
|
118
|
+
onChange(undefined);
|
|
119
|
+
setNewCondition(condition);
|
|
120
|
+
};
|
|
121
|
+
return (_jsx(_Fragment, { children: showAdvanced ? (_jsx(CompositeInput, { dialog: dialog, label: fieldLabel, onClear: onClear, value: conditionProp ? formatCondition({ condition: conditionProp }, fields, t) : undefined, placeholder: t('all'), ref: ref })) : (defaultControl) }));
|
|
122
|
+
});
|
|
123
|
+
export default ConditionInput;
|
|
124
|
+
//# sourceMappingURL=ConditionInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConditionInput.js","sourceRoot":"","sources":["../../../src/components/ConditionInput/ConditionInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAGV,QAAQ,EAER,SAAS,EACV,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EACL,cAAc,EAEd,gBAAgB,EAEhB,OAAO,EACP,KAAK,EACL,WAAW,EACX,WAAW,EACX,gBAAgB,EACh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AAE,KAAK,EAAE,EAAE,EAAE;YACrB,QAAQ,CAAC,YAAY,CAAC,CAAC;YACvB,KAAK,EAAE,CAAC;QACV,CAAC;KACF,CAAC;IAEF,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,QAAQ,CAAC,SAAS,CAAC,CAAC;QACpB,eAAe,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC,CAAC;IAEF,OAAO,CACL,4BACG,YAAY,CAAC,CAAC,CAAC,CACd,KAAC,cAAc,IACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,OAAO,EAChB,KAAK,EACH,aAAa,CAAC,CAAC,CAAC,eAAe,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAEtF,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,EACrB,GAAG,EAAE,GAAG,GACR,CACH,CAAC,CAAC,CAAC,CACF,cAAc,CACf,GACA,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n useState,\n ChangeEvent,\n useEffect\n} from 'react';\nimport styled from 'styled-components';\n\nimport {\n CompositeInput,\n CompositeInputProps,\n defaultThemeProp,\n ForwardProps,\n hasProp,\n Input,\n NumberInput,\n RadioButton,\n RadioButtonGroup,\n StyledGrid,\n useI18n\n} from '@pega/cosmos-react-core';\n\nimport type { Comparator, FieldType } from '../ConditionBuilder/core/types';\nimport AtomicCondition, {\n AtomicConditionProps,\n getInitConditionForLhs\n} from '../ConditionBuilder/AtomicCondition';\nimport formatCondition from '../ConditionBuilder/core/formatter';\nimport type { LeafCondition } from '../ConditionBuilder/ConditionBuilder.types';\n\nimport { ConditionFieldType, ConditionInputProps } from './ConditionInput.types';\n\nconst defaultComparators: Record<ConditionFieldType, Comparator> = {\n TEXT: 'CONTAINS',\n EMAIL: 'CONTAINS',\n URL: 'CONTAINS',\n PHONE: 'CONTAINS',\n INTEGER: 'EQ',\n DECIMAL: 'EQ',\n PERCENTAGE: 'EQ',\n CURRENCY: 'EQ',\n BOOLEAN: 'IS_TRUE'\n} as const;\n\nconst basicFieldMap: Record<ConditionFieldType, FieldType> = {\n EMAIL: 'TEXT',\n URL: 'TEXT',\n PHONE: 'TEXT',\n INTEGER: 'NUMBER',\n DECIMAL: 'NUMBER',\n PERCENTAGE: 'NUMBER',\n CURRENCY: 'NUMBER',\n TEXT: 'TEXT',\n BOOLEAN: 'BOOLEAN'\n} as const;\n\nconst StyledConditionRadioGroup = styled(RadioButtonGroup)`\n ${StyledGrid} {\n display: inline-flex;\n } ;\n`;\n\nStyledConditionRadioGroup.defaultProps = defaultThemeProp;\n\nconst ConditionInput: FunctionComponent<ConditionInputProps & ForwardProps> = forwardRef(\n (\n {\n fieldName,\n fieldType,\n condition: conditionProp,\n fieldLabel,\n mode,\n onChange\n }: PropsWithoutRef<ConditionInputProps>,\n ref: ConditionInputProps['ref']\n ) => {\n const t = useI18n();\n\n const basicType = basicFieldMap[fieldType] ?? fieldType;\n\n const fields: AtomicConditionProps['fields'] = [\n { name: fieldName, type: basicType, label: fieldLabel }\n ];\n\n const condition =\n conditionProp ??\n (fieldType === 'BOOLEAN'\n ? undefined\n : getInitConditionForLhs({ field: fieldName }, fields, new Set(['LITERAL'])));\n\n const onRadioButtonChange = (value?: boolean) => {\n const updatedCondition: LeafCondition | undefined =\n value === undefined\n ? undefined\n : {\n lhs: { field: fieldName },\n comparator: value ? 'IS_TRUE' : 'IS_FALSE'\n };\n onChange(updatedCondition);\n };\n\n const createConditionForDefaultMode = (value: string) => {\n return {\n lhs: { field: fieldName },\n comparator: defaultComparators[fieldType],\n rhs: { value: basicType === 'NUMBER' ? Number(value) : value }\n };\n };\n\n const rhsValue =\n condition?.rhs && hasProp(condition.rhs, 'value')\n ? condition.rhs.value.toString()\n : undefined;\n\n const [inputValue, setInputValue] = useState(rhsValue);\n\n useEffect(() => {\n setInputValue(rhsValue);\n }, [conditionProp]);\n\n const showAdvanced = mode === 'advanced' && fieldType !== 'BOOLEAN';\n\n let defaultControl: JSX.Element | null = null;\n\n if (!showAdvanced) {\n switch (fieldType) {\n case 'INTEGER':\n case 'DECIMAL':\n case 'PERCENTAGE':\n case 'CURRENCY':\n defaultControl = (\n <NumberInput\n label={fieldLabel}\n ref={ref}\n value={inputValue}\n onChange={setInputValue}\n onBlur={value => {\n onChange(createConditionForDefaultMode(value));\n }}\n numberOfDecimals={fieldType === 'INTEGER' ? 0 : undefined}\n />\n );\n break;\n case 'BOOLEAN':\n defaultControl = (\n <StyledConditionRadioGroup ref={ref} label={fieldLabel} name={fieldName} inline>\n <RadioButton\n label={t('show_all')}\n checked={condition === undefined}\n onChange={() => onRadioButtonChange()}\n />\n <RadioButton\n label={t('boolean_display_true_label')}\n checked={condition?.comparator === 'IS_TRUE'}\n onChange={() => onRadioButtonChange(true)}\n />\n <RadioButton\n label={t('boolean_display_false_label')}\n checked={condition?.comparator === 'IS_FALSE'}\n onChange={() => onRadioButtonChange(false)}\n />\n </StyledConditionRadioGroup>\n );\n break;\n case 'TEXT':\n case 'EMAIL':\n case 'URL':\n case 'PHONE':\n default:\n defaultControl = (\n <Input\n label={fieldLabel}\n ref={ref}\n value={inputValue}\n onChange={(e: ChangeEvent<HTMLInputElement>) => setInputValue(e.target.value)}\n onBlur={(e: ChangeEvent<HTMLInputElement>) =>\n onChange(createConditionForDefaultMode(e.target.value))\n }\n />\n );\n break;\n }\n }\n\n const [newCondition, setNewCondition] = useState<LeafCondition | undefined>(condition);\n\n useEffect(() => {\n setNewCondition(condition);\n }, [conditionProp]);\n\n const dialog: CompositeInputProps<AtomicConditionProps & ForwardProps>['dialog'] = {\n renderer: AtomicCondition,\n rendererProps: {\n condition:\n newCondition ??\n getInitConditionForLhs({ field: fieldName }, fields, new Set(['LITERAL'])),\n fields,\n onChange: setNewCondition,\n itemDirection: 'column',\n showLhsAsLabel: true,\n validRhsTypes: new Set(['LITERAL']),\n indicateErrors: false\n },\n onCancel: ({ close }) => {\n setNewCondition(condition);\n close();\n },\n onApply: ({ close }) => {\n onChange(newCondition);\n close();\n }\n };\n\n const onClear = () => {\n onChange(undefined);\n setNewCondition(condition);\n };\n\n return (\n <>\n {showAdvanced ? (\n <CompositeInput\n dialog={dialog}\n label={fieldLabel}\n onClear={onClear}\n value={\n conditionProp ? formatCondition({ condition: conditionProp }, fields, t) : undefined\n }\n placeholder={t('all')}\n ref={ref}\n />\n ) : (\n defaultControl\n )}\n </>\n );\n }\n);\n\nexport default ConditionInput;\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Ref } from 'react';
|
|
2
|
+
import { LeafCondition } from '../ConditionBuilder';
|
|
3
|
+
export declare type ConditionFieldType = 'TEXT' | 'EMAIL' | 'URL' | 'PHONE' | 'INTEGER' | 'DECIMAL' | 'PERCENTAGE' | 'BOOLEAN' | 'CURRENCY';
|
|
4
|
+
export declare type ConditionInputMode = 'default' | 'advanced';
|
|
5
|
+
export interface ConditionInputProps {
|
|
6
|
+
/** Name of the field the condition is created for. */
|
|
7
|
+
fieldName: string;
|
|
8
|
+
/** Type of the field the condition is created for. */
|
|
9
|
+
fieldType: ConditionFieldType;
|
|
10
|
+
/** Display mode. Either with default comparator or the full-fledged. */
|
|
11
|
+
mode: ConditionInputMode;
|
|
12
|
+
/** Label for the input. */
|
|
13
|
+
fieldLabel?: string;
|
|
14
|
+
/** Condition value. */
|
|
15
|
+
condition?: LeafCondition;
|
|
16
|
+
/** Callback invoked when user changes the condition. */
|
|
17
|
+
onChange: (condition?: LeafCondition) => void;
|
|
18
|
+
/** Reference to the input element. */
|
|
19
|
+
ref?: Ref<HTMLInputElement>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=ConditionInput.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConditionInput.types.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionInput/ConditionInput.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,oBAAY,kBAAkB,GAC1B,MAAM,GACN,OAAO,GACP,KAAK,GACL,OAAO,GACP,SAAS,GACT,SAAS,GACT,YAAY,GACZ,SAAS,GACT,UAAU,CAAC;AAEf,oBAAY,kBAAkB,GAAG,SAAS,GAAG,UAAU,CAAC;AAExD,MAAM,WAAW,mBAAmB;IAClC,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,SAAS,EAAE,kBAAkB,CAAC;IAC9B,wEAAwE;IACxE,IAAI,EAAE,kBAAkB,CAAC;IACzB,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uBAAuB;IACvB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,sCAAsC;IACtC,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;CAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConditionInput.types.js","sourceRoot":"","sources":["../../../src/components/ConditionInput/ConditionInput.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Ref } from 'react';\n\nimport { LeafCondition } from '../ConditionBuilder';\n\nexport type ConditionFieldType =\n | 'TEXT'\n | 'EMAIL'\n | 'URL'\n | 'PHONE'\n | 'INTEGER'\n | 'DECIMAL'\n | 'PERCENTAGE'\n | 'BOOLEAN'\n | 'CURRENCY';\n\nexport type ConditionInputMode = 'default' | 'advanced';\n\nexport interface ConditionInputProps {\n /** Name of the field the condition is created for. */\n fieldName: string;\n /** Type of the field the condition is created for. */\n fieldType: ConditionFieldType;\n /** Display mode. Either with default comparator or the full-fledged. */\n mode: ConditionInputMode;\n /** Label for the input. */\n fieldLabel?: string;\n /** Condition value. */\n condition?: LeafCondition;\n /** Callback invoked when user changes the condition. */\n onChange: (condition?: LeafCondition) => void;\n /** Reference to the input element. */\n ref?: Ref<HTMLInputElement>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ConditionInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["export { default } from './ConditionInput';\nexport {\n ConditionInputProps,\n ConditionInputMode,\n ConditionFieldType\n} from './ConditionInput.types';\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import { PromotedFiltersProps } from './PromotedFilters.types';
|
|
4
|
+
declare const PromotedFilters: FunctionComponent<PromotedFiltersProps & ForwardProps>;
|
|
5
|
+
export default PromotedFilters;
|
|
6
|
+
//# sourceMappingURL=PromotedFilters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromotedFilters.d.ts","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAmB,MAAM,OAAO,CAAC;AAGvE,OAAO,EAAkC,YAAY,EAAW,MAAM,yBAAyB,CAAC;AAMhG,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAkB/D,QAAA,MAAM,eAAe,EAAE,iBAAiB,CAAC,oBAAoB,GAAG,YAAY,CAqE3E,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { Button, defaultThemeProp, Flex, useI18n } from '@pega/cosmos-react-core';
|
|
5
|
+
import { splitConditionForBuilder } from '../ConditionBuilder/core/utils';
|
|
6
|
+
import ConditionInput from '../ConditionInput';
|
|
7
|
+
const StyledPromotedFilters = styled.div(({ theme }) => {
|
|
8
|
+
return css `
|
|
9
|
+
border-radius: ${theme.components.card['border-radius']};
|
|
10
|
+
background-color: ${theme.base.palette['secondary-background']};
|
|
11
|
+
`;
|
|
12
|
+
});
|
|
13
|
+
StyledPromotedFilters.defaultProps = defaultThemeProp;
|
|
14
|
+
const StyledClearAllButton = styled(Button) `
|
|
15
|
+
margin-top: 0.625rem;
|
|
16
|
+
white-space: nowrap;
|
|
17
|
+
`;
|
|
18
|
+
StyledClearAllButton.defaultProps = defaultThemeProp;
|
|
19
|
+
const PromotedFilters = forwardRef(({ filters, condition, onChange }, ref) => {
|
|
20
|
+
const t = useI18n();
|
|
21
|
+
// map of Conditions indexed by field name
|
|
22
|
+
const conditionsMap = condition
|
|
23
|
+
? splitConditionForBuilder(condition).rows.reduce((result, item) => {
|
|
24
|
+
result[item.lhs.field] = item;
|
|
25
|
+
return result;
|
|
26
|
+
}, {})
|
|
27
|
+
: {};
|
|
28
|
+
const createUpdatedCondition = (key, newCondition) => {
|
|
29
|
+
if (newCondition) {
|
|
30
|
+
conditionsMap[key] = newCondition;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
delete conditionsMap[key];
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
AND: Object.values(conditionsMap).map(c => {
|
|
37
|
+
return { condition: c };
|
|
38
|
+
})
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
return (_jsxs(Flex, { as: StyledPromotedFilters, container: { alignItems: 'start', justify: 'between', pad: 2, gap: 2 }, ref: ref, children: [_jsx(Flex, { container: { wrap: 'wrap', gap: 2 }, children: filters.map(filter => {
|
|
42
|
+
return (_jsx(ConditionInput, { fieldName: filter.fieldName, fieldType: filter.fieldType, mode: filter.mode, fieldLabel: filter.fieldLabel ?? filter.fieldName, condition: conditionsMap[filter.fieldName], onChange: (newCondition) => {
|
|
43
|
+
onChange(createUpdatedCondition(filter.fieldName, newCondition));
|
|
44
|
+
} }, filter.fieldName));
|
|
45
|
+
}) }), _jsx("div", { children: _jsx(StyledClearAllButton, { variant: 'simple', onClick: () => {
|
|
46
|
+
onChange();
|
|
47
|
+
}, children: t('promoted_filters_clear_all_button_label') }) })] }));
|
|
48
|
+
});
|
|
49
|
+
export default PromotedFilters;
|
|
50
|
+
//# sourceMappingURL=PromotedFilters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromotedFilters.js","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsC,MAAM,OAAO,CAAC;AACvE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAgB,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGhG,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAI/C,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACrD,OAAO,GAAG,CAAA;qBACS,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC;wBACnC,KAAK,CAAC,IAAI,CAAC,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AAC,EAAE,GAAG,EAAE,CAAC,EAAE,EACtE,GAAG,EAAE,GAAG,aAER,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,YACtC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;oBACpB,OAAO,CACL,KAAC,cAAc,IAEb,SAAS,EAAE,MAAM,CAAC,SAAS,EAC3B,SAAS,EAAE,MAAM,CAAC,SAAS,EAC3B,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,SAAS,EACjD,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,EAC1C,QAAQ,EAAE,CAAC,YAA4B,EAAE,EAAE;4BACzC,QAAQ,CAAC,sBAAsB,CAAC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;wBACnE,CAAC,IARI,MAAM,CAAC,SAAS,CASrB,CACH,CAAC;gBACJ,CAAC,CAAC,GACG,EAEP,wBACE,KAAC,oBAAoB,IACnB,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE,GAAG,EAAE;wBACZ,QAAQ,EAAE,CAAC;oBACb,CAAC,YAEA,CAAC,CAAC,yCAAyC,CAAC,GACxB,GACnB,IACD,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { Button, defaultThemeProp, Flex, ForwardProps, useI18n } from '@pega/cosmos-react-core';\n\nimport { Condition, LeafCondition } from '../ConditionBuilder/ConditionBuilder.types';\nimport { splitConditionForBuilder } from '../ConditionBuilder/core/utils';\nimport ConditionInput from '../ConditionInput';\n\nimport { PromotedFiltersProps } from './PromotedFilters.types';\n\nconst StyledPromotedFilters = styled.div(({ theme }) => {\n return css`\n border-radius: ${theme.components.card['border-radius']};\n background-color: ${theme.base.palette['secondary-background']};\n `;\n});\n\nStyledPromotedFilters.defaultProps = defaultThemeProp;\n\nconst StyledClearAllButton = styled(Button)`\n margin-top: 0.625rem;\n white-space: nowrap;\n`;\n\nStyledClearAllButton.defaultProps = defaultThemeProp;\n\nconst PromotedFilters: FunctionComponent<PromotedFiltersProps & ForwardProps> = forwardRef(\n (\n { filters, condition, onChange }: PropsWithoutRef<PromotedFiltersProps>,\n ref: PromotedFiltersProps['ref']\n ) => {\n const t = useI18n();\n\n // map of Conditions indexed by field name\n const conditionsMap = condition\n ? splitConditionForBuilder(condition).rows.reduce(\n (result: { [key: string]: LeafCondition }, item) => {\n result[item.lhs.field] = item;\n return result;\n },\n {}\n )\n : {};\n\n const createUpdatedCondition = (key: string, newCondition?: LeafCondition) => {\n if (newCondition) {\n conditionsMap[key] = newCondition;\n } else {\n delete conditionsMap[key];\n }\n\n return {\n AND: Object.values(conditionsMap).map(c => {\n return { condition: c } as Condition;\n })\n };\n };\n\n return (\n <Flex\n as={StyledPromotedFilters}\n container={{ alignItems: 'start', justify: 'between', pad: 2, gap: 2 }}\n ref={ref}\n >\n <Flex container={{ wrap: 'wrap', gap: 2 }}>\n {filters.map(filter => {\n return (\n <ConditionInput\n key={filter.fieldName}\n fieldName={filter.fieldName}\n fieldType={filter.fieldType}\n mode={filter.mode}\n fieldLabel={filter.fieldLabel ?? filter.fieldName}\n condition={conditionsMap[filter.fieldName]}\n onChange={(newCondition?: LeafCondition) => {\n onChange(createUpdatedCondition(filter.fieldName, newCondition));\n }}\n />\n );\n })}\n </Flex>\n\n <div>\n <StyledClearAllButton\n variant='simple'\n onClick={() => {\n onChange();\n }}\n >\n {t('promoted_filters_clear_all_button_label')}\n </StyledClearAllButton>\n </div>\n </Flex>\n );\n }\n);\n\nexport default PromotedFilters;\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Ref } from 'react';
|
|
2
|
+
import { BaseProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import type { Condition } from '../ConditionBuilder/ConditionBuilder.types';
|
|
4
|
+
import type { ConditionInputMode, ConditionFieldType } from '../ConditionInput/ConditionInput.types';
|
|
5
|
+
export interface PromotedFilter {
|
|
6
|
+
/** Unique field identifier. */
|
|
7
|
+
fieldName: string;
|
|
8
|
+
/** Type of the field. */
|
|
9
|
+
fieldType: ConditionFieldType;
|
|
10
|
+
/** Display mode. */
|
|
11
|
+
mode: ConditionInputMode;
|
|
12
|
+
/** Label for the filter. */
|
|
13
|
+
fieldLabel?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface PromotedFiltersProps extends BaseProps {
|
|
16
|
+
/** Configuration of filters for every field that has been defined as promoted. */
|
|
17
|
+
filters: PromotedFilter[];
|
|
18
|
+
/** A value representing the current condition state. */
|
|
19
|
+
condition?: Condition;
|
|
20
|
+
/** Callback fired on change of any of the filters. */
|
|
21
|
+
onChange: (condition?: Condition) => void;
|
|
22
|
+
/** Ref for the wrapping element. */
|
|
23
|
+
ref?: Ref<HTMLDivElement>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=PromotedFilters.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromotedFilters.types.d.ts","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,wCAAwC,CAAC;AAEhD,MAAM,WAAW,cAAc;IAC7B,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,yBAAyB;IACzB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,oBAAoB;IACpB,IAAI,EAAE,kBAAkB,CAAC;IACzB,4BAA4B;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,oBAAqB,SAAQ,SAAS;IACrD,kFAAkF;IAClF,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,wDAAwD;IACxD,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,sDAAsD;IACtD,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAE,SAAS,KAAK,IAAI,CAAC;IAC1C,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromotedFilters.types.js","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Ref } from 'react';\n\nimport { BaseProps } from '@pega/cosmos-react-core';\n\nimport type { Condition } from '../ConditionBuilder/ConditionBuilder.types';\nimport type {\n ConditionInputMode,\n ConditionFieldType\n} from '../ConditionInput/ConditionInput.types';\n\nexport interface PromotedFilter {\n /** Unique field identifier. */\n fieldName: string;\n /** Type of the field. */\n fieldType: ConditionFieldType;\n /** Display mode. */\n mode: ConditionInputMode;\n /** Label for the filter. */\n fieldLabel?: string;\n}\n\nexport interface PromotedFiltersProps extends BaseProps {\n /** Configuration of filters for every field that has been defined as promoted. */\n filters: PromotedFilter[];\n /** A value representing the current condition state. */\n condition?: Condition;\n /** Callback fired on change of any of the filters. */\n onChange: (condition?: Condition) => void;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PromotedFilters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/PromotedFilters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["export { default } from './PromotedFilters';\nexport { PromotedFiltersProps, PromotedFilter } from './PromotedFilters.types';\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export { default as ConditionBuilder } from './components/ConditionBuilder';
|
|
2
2
|
export * from './components/ConditionBuilder';
|
|
3
|
+
export { default as ConditionInput } from './components/ConditionInput';
|
|
4
|
+
export * from './components/ConditionInput';
|
|
5
|
+
export { default as PromotedFilters } from './components/PromotedFilters';
|
|
6
|
+
export * from './components/PromotedFilters';
|
|
3
7
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,cAAc,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,cAAc,+BAA+B,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAC;AACxE,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC1E,cAAc,8BAA8B,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
// This file is autogenerated. Any changes will be overwritten.
|
|
2
2
|
export { default as ConditionBuilder } from './components/ConditionBuilder';
|
|
3
3
|
export * from './components/ConditionBuilder';
|
|
4
|
+
export { default as ConditionInput } from './components/ConditionInput';
|
|
5
|
+
export * from './components/ConditionInput';
|
|
6
|
+
export { default as PromotedFilters } from './components/PromotedFilters';
|
|
7
|
+
export * from './components/PromotedFilters';
|
|
4
8
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,cAAc,+BAA+B,CAAC","sourcesContent":["// This file is autogenerated. Any changes will be overwritten.\nexport { default as ConditionBuilder } from './components/ConditionBuilder';\nexport * from './components/ConditionBuilder';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,cAAc,+BAA+B,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAC;AACxE,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC1E,cAAc,8BAA8B,CAAC","sourcesContent":["// This file is autogenerated. Any changes will be overwritten.\nexport { default as ConditionBuilder } from './components/ConditionBuilder';\nexport * from './components/ConditionBuilder';\nexport { default as ConditionInput } from './components/ConditionInput';\nexport * from './components/ConditionInput';\nexport { default as PromotedFilters } from './components/PromotedFilters';\nexport * from './components/PromotedFilters';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pega/cosmos-react-condition-builder",
|
|
3
|
-
"version": "3.0.0-dev.
|
|
3
|
+
"version": "3.0.0-dev.13.0",
|
|
4
4
|
"author": "Pegasystems",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"build": "tsc -b"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@pega/cosmos-react-core": "3.0.0-dev.
|
|
25
|
+
"@pega/cosmos-react-core": "3.0.0-dev.13.0",
|
|
26
26
|
"@types/react": "^16.14.24 || ^17.0.38",
|
|
27
27
|
"@types/react-dom": "^16.9.14 || ^17.0.11",
|
|
28
28
|
"@types/styled-components": "^5.1.7",
|
|
@@ -40,6 +40,9 @@
|
|
|
40
40
|
"@storybook/addons": "^6.4.19",
|
|
41
41
|
"@storybook/react": "^6.4.19",
|
|
42
42
|
"@storybook/theming": "^6.4.19",
|
|
43
|
+
"@testing-library/jest-dom": "^5.16.2",
|
|
44
|
+
"@testing-library/react": "^12.1.3",
|
|
45
|
+
"@testing-library/user-event": "^13.5.0",
|
|
43
46
|
"enzyme": "^3.11.0",
|
|
44
47
|
"typescript": "~4.6.2"
|
|
45
48
|
}
|