@pega/cosmos-react-condition-builder 8.0.0-build.6.0 → 8.0.0-build.60.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 +3 -3
- 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.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.js +42 -60
- package/lib/components/ConditionBuilder/ConditionBuilder.js.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.d.ts +4 -4
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.js +18 -6
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.js.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts +11 -5
- 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/RhsControls/DateFunctionMenu.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.js.map +1 -1
- 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/ValueSelector.d.ts +2 -4
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.js +166 -130
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/index.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/index.js +12 -14
- 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 +35 -39
- package/lib/components/ConditionBuilder/core/comparators.js.map +1 -1
- package/lib/components/ConditionBuilder/core/evaluator.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/evaluator.js +11 -1
- package/lib/components/ConditionBuilder/core/evaluator.js.map +1 -1
- package/lib/components/ConditionBuilder/core/extendDayJs.js +4 -0
- package/lib/components/ConditionBuilder/core/extendDayJs.js.map +1 -1
- package/lib/components/ConditionBuilder/core/formatter.js +1 -1
- package/lib/components/ConditionBuilder/core/formatter.js.map +1 -1
- package/lib/components/ConditionBuilder/core/transformer.d.ts +18 -1
- package/lib/components/ConditionBuilder/core/transformer.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/transformer.js +120 -30
- package/lib/components/ConditionBuilder/core/transformer.js.map +1 -1
- package/lib/components/ConditionBuilder/core/utils.d.ts +6 -0
- package/lib/components/ConditionBuilder/core/utils.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/utils.js +11 -0
- package/lib/components/ConditionBuilder/core/utils.js.map +1 -1
- package/lib/components/ConditionBuilder/index.d.ts +1 -1
- package/lib/components/ConditionBuilder/index.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/index.js.map +1 -1
- package/lib/components/ConditionInput/ConditionInput.d.ts +2 -3
- package/lib/components/ConditionInput/ConditionInput.d.ts.map +1 -1
- package/lib/components/ConditionInput/ConditionInput.js +40 -28
- package/lib/components/ConditionInput/ConditionInput.js.map +1 -1
- package/lib/components/ConditionInput/ConditionInput.styles.d.ts +2 -2
- package/lib/components/ConditionInput/ConditionInput.styles.d.ts.map +1 -1
- package/lib/components/ConditionInput/ConditionInput.types.d.ts +3 -1
- 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.map +1 -1
- package/lib/components/ConditionInput/utils.js +5 -2
- package/lib/components/ConditionInput/utils.js.map +1 -1
- package/lib/components/PromotedFilters/ConditionSelector.d.ts +0 -2
- package/lib/components/PromotedFilters/ConditionSelector.d.ts.map +1 -1
- package/lib/components/PromotedFilters/ConditionSelector.js +13 -12
- package/lib/components/PromotedFilters/ConditionSelector.js.map +1 -1
- package/lib/components/PromotedFilters/PromotedFilters.d.ts +2 -3
- package/lib/components/PromotedFilters/PromotedFilters.d.ts.map +1 -1
- package/lib/components/PromotedFilters/PromotedFilters.js +55 -46
- package/lib/components/PromotedFilters/PromotedFilters.js.map +1 -1
- package/lib/components/PromotedFilters/PromotedFilters.styles.d.ts +2 -2
- package/lib/components/PromotedFilters/PromotedFilters.styles.d.ts.map +1 -1
- package/lib/components/PromotedFilters/PromotedFilters.styles.js +1 -1
- package/lib/components/PromotedFilters/PromotedFilters.styles.js.map +1 -1
- package/lib/components/PromotedFilters/PromotedFilters.types.d.ts +35 -6
- package/lib/components/PromotedFilters/PromotedFilters.types.d.ts.map +1 -1
- package/lib/components/PromotedFilters/PromotedFilters.types.js.map +1 -1
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionInput.types.js","sourceRoot":"","sources":["../../../src/components/ConditionInput/ConditionInput.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Ref } from 'react';\n\nimport type { BaseProps, HandleValue, NoChildrenProp } from '@pega/cosmos-react-core';\n\nimport type { LeafCondition, ValueSelection } 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 | 'DATE_ONLY'\n | 'TIME_ONLY'\n | 'DATE_TIME'\n | 'PICKLIST';\n\nexport interface ConditionField {\n /** Unique field identifier. */\n name: string;\n /** Type of the field. */\n type: ConditionFieldType;\n /** List of possible field values */\n possibleValues?: ValueSelection<ConditionField>;\n}\n\nexport type ConditionInputMode = 'default' | 'advanced' | 'predefined';\n\nexport interface ConditionInputProps extends BaseProps, NoChildrenProp {\n /** Definition of the field the condition is created for. */\n field: ConditionField;\n /** Display mode. Either with default comparator or the full-fledged */\n mode: ConditionInputMode;\n /** Label for the input. */\n label?: 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 | HTMLFieldSetElement | HTMLDivElement>;\n /** Whether advanced view should be wrapped in popup or just flat. */\n flat?: boolean;\n /** Imperative handle */\n handle?: Ref<HandleValue>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ConditionInput.types.js","sourceRoot":"","sources":["../../../src/components/ConditionInput/ConditionInput.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Ref } from 'react';\n\nimport type { BaseProps, HandleValue, NoChildrenProp } from '@pega/cosmos-react-core';\n\nimport type { Field, LeafCondition, ValueSelection } 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 | 'DATE_ONLY'\n | 'TIME_ONLY'\n | 'DATE_TIME'\n | 'PICKLIST';\n\nexport interface ConditionField {\n /** Unique field identifier. */\n name: string;\n /** Type of the field. */\n type: ConditionFieldType;\n /** List of possible field values */\n possibleValues?: ValueSelection<ConditionField>;\n}\n\nexport type ConditionInputMode = 'default' | 'advanced' | 'predefined';\n\nexport interface ConditionInputProps extends BaseProps, NoChildrenProp {\n /** Definition of the field the condition is created for. */\n field: ConditionField;\n /** Display mode. Either with default comparator or the full-fledged */\n mode: ConditionInputMode;\n /** Label for the input. */\n label?: string;\n /** Condition value. */\n condition?: LeafCondition;\n /** Metadata (data-model) for the Fields to use in the RHS field-selector */\n fields?: Field[];\n /** Callback invoked when user changes the condition. */\n onChange: (condition?: LeafCondition) => void;\n /** Reference to the input element. */\n ref?: Ref<HTMLInputElement | HTMLFieldSetElement | HTMLDivElement>;\n /** Whether advanced view should be wrapped in popup or just flat. */\n flat?: boolean;\n /** Imperative handle */\n handle?: Ref<HandleValue>;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionInput/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE5E,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjF,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,kBAAkB,EAAE,UAAU,CAc5D,CAAC;AAEX,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,kBAAkB,EAAE,SAAS,CActD,CAAC;AAEX,eAAO,MAAM,WAAW,WACd,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,UAC7B,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,YAiBtC,CAAC;AAEF,eAAO,MAAM,gBAAgB,WACnB;IAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG,SAAS,UACpF;IAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG,SAAS,YAS7F,CAAC;AAEF,eAAO,MAAM,eAAe,eACd,aAAa,GAAG,SAAS,cACzB,aAAa,G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BACpC,cAAc,CAAC,gBAAgB,CAAC,KAC/C,cAAc,CAAC,KAAK,CAAC,GAAG,SAS1B,CAAC"}
|
|
@@ -114,8 +114,11 @@ export const convertFieldToConditionField = (lhs) => {
|
|
|
114
114
|
export const possibleFieldValuesToConditionFieldValues = (possibleValues) => {
|
|
115
115
|
if (possibleValues === undefined || typeof possibleValues !== 'function')
|
|
116
116
|
return possibleValues;
|
|
117
|
-
return
|
|
118
|
-
return possibleValues({
|
|
117
|
+
return args => {
|
|
118
|
+
return possibleValues({
|
|
119
|
+
...args,
|
|
120
|
+
lhs: convertFieldToConditionField(args.lhs)
|
|
121
|
+
});
|
|
119
122
|
};
|
|
120
123
|
};
|
|
121
124
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/ConditionInput/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAOlD,MAAM,CAAC,MAAM,kBAAkB,GAA2C;IACxE,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;IACjB,GAAG,EAAE,UAAU;IACf,KAAK,EAAE,UAAU;IACjB,OAAO,EAAE,KAAK;IACd,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,KAAK;IACjB,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,QAAQ,EAAE,IAAI;CACN,CAAC;AAEX,MAAM,CAAC,MAAM,aAAa,GAA0C;IAClE,KAAK,EAAE,MAAM;IACb,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,MAAM;IACb,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,SAAS;IACrB,QAAQ,EAAE,SAAS;IACnB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;I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type { Field, LeafCondition, ValueSelection } from '../ConditionBuilder';\nimport type { Comparator, FieldType } from '../ConditionBuilder/core/types';\n\nimport type { ConditionField, ConditionFieldType } from './ConditionInput.types';\n\nexport const defaultComparators: Record<ConditionFieldType, Comparator> = {\n TEXT: 'CONTAINS',\n EMAIL: 'CONTAINS',\n URL: 'CONTAINS',\n PHONE: 'CONTAINS',\n INTEGER: 'BTW',\n DECIMAL: 'BTW',\n PERCENTAGE: 'BTW',\n CURRENCY: 'BTW',\n BOOLEAN: 'IS_TRUE',\n DATE_ONLY: 'BTW',\n TIME_ONLY: 'BTW',\n DATE_TIME: 'BTW',\n PICKLIST: 'IN'\n} as const;\n\nexport const basicFieldMap: Record<ConditionFieldType, FieldType> = {\n EMAIL: 'TEXT',\n URL: 'TEXT',\n PHONE: 'TEXT',\n INTEGER: 'INTEGER',\n DECIMAL: 'DECIMAL',\n PERCENTAGE: 'DECIMAL',\n CURRENCY: 'DECIMAL',\n TEXT: 'TEXT',\n BOOLEAN: 'BOOLEAN',\n DATE_ONLY: 'DATE_ONLY',\n TIME_ONLY: 'TIME_ONLY',\n DATE_TIME: 'DATE_TIME',\n PICKLIST: 'TEXT'\n} as const;\n\nexport const valuesEqual = (\n value1: string | string[] | undefined,\n value2: string | string[] | undefined\n) => {\n // both values are undefined\n if (!value1 && !value2) return true;\n\n // only one value is undefined\n if (!value1 || !value2) return false;\n\n // for strings compare only value\n if (typeof value1 === 'string') {\n return value1 === value2;\n }\n\n // for arrays compare length and every value\n if (value1.length !== value2.length) return false;\n\n return value1.every((value, index) => value === value2[index]);\n};\n\nexport const rangeValuesEqual = (\n value1: { start: string | number | undefined; end: string | number | undefined } | undefined,\n value2: { start: string | number | undefined; end: string | number | undefined } | undefined\n) => {\n // both values are undefined\n if (!value1 && !value2) return true;\n\n // only one value is undefined\n if (!value1 || !value2) return false;\n\n return value1.start === value2.start && value1.end === value2.end;\n};\n\nexport const conditionsEqual = (\n condition1: LeafCondition | undefined,\n condition2: LeafCondition | undefined\n) => {\n // both values are undefined\n if (!condition1 && !condition2) return true;\n\n // only one value is undefined\n if (!condition1 || !condition2) return false;\n\n // conditions are for different fields\n if (condition1.lhs?.field !== condition2.lhs?.field) return false;\n\n // comparators are different\n if (condition1.comparator !== condition2.comparator) return false;\n\n // comparators are unary\n if (!condition1.rhs && !condition2.rhs) return true;\n\n if (condition1.rhs && condition2.rhs) {\n // datefunction is first, cause it contains also 'value' prop, so it would fall into next condition block\n if (hasProp(condition1.rhs, 'dateFunction') && hasProp(condition2.rhs, 'dateFunction')) {\n return (\n condition1.rhs.dateFunction === condition2.rhs.dateFunction &&\n valuesEqual(condition1.rhs.value.toString(), condition2.rhs.value.toString())\n );\n }\n if (hasProp(condition1.rhs, 'value') && hasProp(condition2.rhs, 'value')) {\n if (typeof condition1.rhs.value !== typeof condition2.rhs.value) return false;\n return valuesEqual(condition1.rhs.value.toString(), condition2.rhs.value.toString());\n }\n if (hasProp(condition1.rhs, 'values') && hasProp(condition2.rhs, 'values')) {\n if (typeof condition1.rhs.values[0] !== typeof condition2.rhs.values[0]) return false;\n return valuesEqual(\n condition1.rhs.values.map(p => p.toString()),\n condition2.rhs.values.map(p => p.toString())\n );\n }\n if (hasProp(condition1.rhs, 'start') && hasProp(condition2.rhs, 'start')) {\n return rangeValuesEqual(condition1.rhs, condition2.rhs);\n }\n if (hasProp(condition1.rhs, 'relativeDate') && hasProp(condition2.rhs, 'relativeDate')) {\n return (\n condition1.rhs.relativeDate.datePart === condition2.rhs.relativeDate.datePart &&\n condition1.rhs.relativeDate.interval === condition2.rhs.relativeDate.interval &&\n condition1.rhs.relativeDate.timePeriod === condition2.rhs.relativeDate.timePeriod\n );\n }\n if (hasProp(condition1.rhs, 'field') && hasProp(condition2.rhs, 'field')) {\n return condition1.rhs.field === condition2.rhs.field;\n }\n if (hasProp(condition1.rhs, 'parameterId') && hasProp(condition2.rhs, 'parameterId')) {\n return condition1.rhs.parameterId === condition2.rhs.parameterId;\n }\n }\n\n return false;\n};\n\nexport const convertFieldToConditionField = (lhs?: Field) => {\n return lhs && hasProp(lhs, 'type')\n ? ({\n name: lhs.id,\n type: lhs.type === 'DECIMAL' ? 'INTEGER' : lhs.type\n } as ConditionField)\n : undefined;\n};\n\nexport const possibleFieldValuesToConditionFieldValues = (\n possibleValues: ConditionField['possibleValues']\n): ValueSelection<Field> | undefined => {\n if (possibleValues === undefined || typeof possibleValues !== 'function') return possibleValues;\n\n return ({\n searchString,\n comparator,\n lhs\n }: {\n searchString?: string;\n comparator?: string;\n lhs?: Field;\n }) => {\n return possibleValues({ searchString, comparator, lhs: convertFieldToConditionField(lhs) });\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/ConditionInput/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAOlD,MAAM,CAAC,MAAM,kBAAkB,GAA2C;IACxE,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;IACjB,GAAG,EAAE,UAAU;IACf,KAAK,EAAE,UAAU;IACjB,OAAO,EAAE,KAAK;IACd,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,KAAK;IACjB,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,QAAQ,EAAE,IAAI;CACN,CAAC;AAEX,MAAM,CAAC,MAAM,aAAa,GAA0C;IAClE,KAAK,EAAE,MAAM;IACb,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,MAAM;IACb,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,SAAS;IACrB,QAAQ,EAAE,SAAS;IACnB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,QAAQ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AG,EAAE,OAAO,CAAC,EAAE,CAAC;YACzE,OAAO,UAAU,CAAC,GAAG,CAAC,KAAK,KAAK,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC;QACvD,CAAC;QACD,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,aAAa,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,aAAa,CAAC,EAAE,CAAC;YACrF,OAAO,UAAU,CAAC,GAAG,CAAC,WAAW,KAAK,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC;QACnE,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,GAAW,EAAE,EAAE;IAC1D,OAAO,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC;QAChC,CAAC,CAAE;YACC,IAAI,EAAE,GAAG,CAAC,EAAE;YACZ,IAAI,EAAE,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI;SACjC;QACtB,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,yCAAyC,GAAG,CACvD,cAAgD,EACb,EAAE;IACrC,IAAI,cAAc,KAAK,SAAS,IAAI,OAAO,cAAc,KAAK,UAAU;QAAE,OAAO,cAAc,CAAC;IAEhG,OAAO,IAAI,CAAC,EAAE;QACZ,OAAO,cAAc,CAAC;YACpB,GAAG,IAAI;YACP,GAAG,EAAE,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC;SAC5C,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { hasProp } from '@pega/cosmos-react-core';\n\nimport type { Field, LeafCondition, ValueSelection } from '../ConditionBuilder';\nimport type { Comparator, FieldType } from '../ConditionBuilder/core/types';\n\nimport type { ConditionField, ConditionFieldType } from './ConditionInput.types';\n\nexport const defaultComparators: Record<ConditionFieldType, Comparator> = {\n TEXT: 'CONTAINS',\n EMAIL: 'CONTAINS',\n URL: 'CONTAINS',\n PHONE: 'CONTAINS',\n INTEGER: 'BTW',\n DECIMAL: 'BTW',\n PERCENTAGE: 'BTW',\n CURRENCY: 'BTW',\n BOOLEAN: 'IS_TRUE',\n DATE_ONLY: 'BTW',\n TIME_ONLY: 'BTW',\n DATE_TIME: 'BTW',\n PICKLIST: 'IN'\n} as const;\n\nexport const basicFieldMap: Record<ConditionFieldType, FieldType> = {\n EMAIL: 'TEXT',\n URL: 'TEXT',\n PHONE: 'TEXT',\n INTEGER: 'INTEGER',\n DECIMAL: 'DECIMAL',\n PERCENTAGE: 'DECIMAL',\n CURRENCY: 'DECIMAL',\n TEXT: 'TEXT',\n BOOLEAN: 'BOOLEAN',\n DATE_ONLY: 'DATE_ONLY',\n TIME_ONLY: 'TIME_ONLY',\n DATE_TIME: 'DATE_TIME',\n PICKLIST: 'TEXT'\n} as const;\n\nexport const valuesEqual = (\n value1: string | string[] | undefined,\n value2: string | string[] | undefined\n) => {\n // both values are undefined\n if (!value1 && !value2) return true;\n\n // only one value is undefined\n if (!value1 || !value2) return false;\n\n // for strings compare only value\n if (typeof value1 === 'string') {\n return value1 === value2;\n }\n\n // for arrays compare length and every value\n if (value1.length !== value2.length) return false;\n\n return value1.every((value, index) => value === value2[index]);\n};\n\nexport const rangeValuesEqual = (\n value1: { start: string | number | undefined; end: string | number | undefined } | undefined,\n value2: { start: string | number | undefined; end: string | number | undefined } | undefined\n) => {\n // both values are undefined\n if (!value1 && !value2) return true;\n\n // only one value is undefined\n if (!value1 || !value2) return false;\n\n return value1.start === value2.start && value1.end === value2.end;\n};\n\nexport const conditionsEqual = (\n condition1: LeafCondition | undefined,\n condition2: LeafCondition | undefined\n) => {\n // both values are undefined\n if (!condition1 && !condition2) return true;\n\n // only one value is undefined\n if (!condition1 || !condition2) return false;\n\n // conditions are for different fields\n if (condition1.lhs?.field !== condition2.lhs?.field) return false;\n\n // comparators are different\n if (condition1.comparator !== condition2.comparator) return false;\n\n // comparators are unary\n if (!condition1.rhs && !condition2.rhs) return true;\n\n if (condition1.rhs && condition2.rhs) {\n // datefunction is first, cause it contains also 'value' prop, so it would fall into next condition block\n if (hasProp(condition1.rhs, 'dateFunction') && hasProp(condition2.rhs, 'dateFunction')) {\n return (\n condition1.rhs.dateFunction === condition2.rhs.dateFunction &&\n valuesEqual(condition1.rhs.value.toString(), condition2.rhs.value.toString())\n );\n }\n if (hasProp(condition1.rhs, 'value') && hasProp(condition2.rhs, 'value')) {\n if (typeof condition1.rhs.value !== typeof condition2.rhs.value) return false;\n return valuesEqual(condition1.rhs.value.toString(), condition2.rhs.value.toString());\n }\n if (hasProp(condition1.rhs, 'values') && hasProp(condition2.rhs, 'values')) {\n if (typeof condition1.rhs.values[0] !== typeof condition2.rhs.values[0]) return false;\n return valuesEqual(\n condition1.rhs.values.map(p => p.toString()),\n condition2.rhs.values.map(p => p.toString())\n );\n }\n if (hasProp(condition1.rhs, 'start') && hasProp(condition2.rhs, 'start')) {\n return rangeValuesEqual(condition1.rhs, condition2.rhs);\n }\n if (hasProp(condition1.rhs, 'relativeDate') && hasProp(condition2.rhs, 'relativeDate')) {\n return (\n condition1.rhs.relativeDate.datePart === condition2.rhs.relativeDate.datePart &&\n condition1.rhs.relativeDate.interval === condition2.rhs.relativeDate.interval &&\n condition1.rhs.relativeDate.timePeriod === condition2.rhs.relativeDate.timePeriod\n );\n }\n if (hasProp(condition1.rhs, 'field') && hasProp(condition2.rhs, 'field')) {\n return condition1.rhs.field === condition2.rhs.field;\n }\n if (hasProp(condition1.rhs, 'parameterId') && hasProp(condition2.rhs, 'parameterId')) {\n return condition1.rhs.parameterId === condition2.rhs.parameterId;\n }\n }\n\n return false;\n};\n\nexport const convertFieldToConditionField = (lhs?: Field) => {\n return lhs && hasProp(lhs, 'type')\n ? ({\n name: lhs.id,\n type: lhs.type === 'DECIMAL' ? 'INTEGER' : lhs.type\n } as ConditionField)\n : undefined;\n};\n\nexport const possibleFieldValuesToConditionFieldValues = (\n possibleValues: ConditionField['possibleValues']\n): ValueSelection<Field> | undefined => {\n if (possibleValues === undefined || typeof possibleValues !== 'function') return possibleValues;\n\n return args => {\n return possibleValues({\n ...args,\n lhs: convertFieldToConditionField(args.lhs)\n });\n };\n};\n"]}
|
|
@@ -5,8 +5,6 @@ import type { LeafCondition } from '../ConditionBuilder';
|
|
|
5
5
|
export interface ConditionSelectorProps extends BaseProps, NoChildrenProp {
|
|
6
6
|
/** Callback for onChange */
|
|
7
7
|
onChange: (condition?: LeafCondition) => void;
|
|
8
|
-
/** Callback for clear */
|
|
9
|
-
onClear?: () => void;
|
|
10
8
|
/** Used to indicate any errors on the control */
|
|
11
9
|
status?: 'error';
|
|
12
10
|
/** Custom label for input. Makes label visible if provided. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionSelector.d.ts","sourceRoot":"","sources":["../../../src/components/PromotedFilters/ConditionSelector.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ConditionSelector.d.ts","sourceRoot":"","sources":["../../../src/components/PromotedFilters/ConditionSelector.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAS/C,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,aAAa,EAEb,YAAY,EACb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD,MAAM,WAAW,sBAAuB,SAAQ,SAAS,EAAE,cAAc;IACvE,4BAA4B;IAC5B,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,iDAAiD;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,+DAA+D;IAC/D,KAAK,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/B,uCAAuC;IACvC,WAAW,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IAC3C,mDAAmD;IACnD,IAAI,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7B,4DAA4D;IAC5D,MAAM,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IACvC,6CAA6C;IAC7C,UAAU,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,aAAa,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACnE,oCAAoC;IACpC,SAAS,CAAC,EAAE,aAAa,CAAC;CAC3B;AAED,QAAA,MAAM,iBAAiB,EAAE,iBAAiB,CAAC,sBAAsB,GAAG,YAAY,CAsE/E,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, useRef } from 'react';
|
|
3
|
-
import { useI18n, ComboBox,
|
|
3
|
+
import { useI18n, ComboBox, useConfiguration, menuHelpers, createUID } from '@pega/cosmos-react-core';
|
|
4
4
|
import formatCondition from '../ConditionBuilder/core/formatter';
|
|
5
5
|
import { conditionsEqual } from '../ConditionInput/utils';
|
|
6
|
-
const ConditionSelector = ({ onChange,
|
|
6
|
+
const ConditionSelector = ({ onChange, status, label, info, fields, labelHidden, conditions, condition, ...restProps }) => {
|
|
7
7
|
const t = useI18n();
|
|
8
8
|
const { locale } = useConfiguration();
|
|
9
9
|
const inputRef = useRef(null);
|
|
10
10
|
const itemsToRender = useMemo(() => {
|
|
11
|
-
|
|
11
|
+
const items = conditions.map(({ id, label: conditionLabel, value }) => {
|
|
12
12
|
return {
|
|
13
13
|
id,
|
|
14
14
|
primary: conditionLabel ??
|
|
@@ -19,9 +19,17 @@ const ConditionSelector = ({ onChange, onClear, status, label, info, fields, lab
|
|
|
19
19
|
selected: !!value && !!condition && conditionsEqual(value, condition)
|
|
20
20
|
};
|
|
21
21
|
});
|
|
22
|
+
if (condition) {
|
|
23
|
+
items.unshift({
|
|
24
|
+
id: createUID(),
|
|
25
|
+
primary: '',
|
|
26
|
+
selected: false
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return items;
|
|
22
30
|
}, [conditions, condition]);
|
|
23
31
|
const selected = useMemo(() => menuHelpers.getSelected(itemsToRender)[0], [itemsToRender]);
|
|
24
|
-
return (_jsx(ComboBox, { ...restProps, ref: inputRef, mode: 'single-select', label: label ?? t('condition_builder_possible_values_label'), labelHidden: labelHidden,
|
|
32
|
+
return (_jsx(ComboBox, { ...restProps, ref: inputRef, mode: 'single-select', label: label ?? t('condition_builder_possible_values_label'), labelHidden: labelHidden, selected: selected
|
|
25
33
|
? {
|
|
26
34
|
items: {
|
|
27
35
|
id: selected.id,
|
|
@@ -31,14 +39,7 @@ const ConditionSelector = ({ onChange, onClear, status, label, info, fields, lab
|
|
|
31
39
|
: undefined, menu: {
|
|
32
40
|
items: itemsToRender,
|
|
33
41
|
onItemClick: (id) => onChange(conditions.find(cnd => cnd.id === id)?.value)
|
|
34
|
-
}, status: status, info: status === 'error' ? t('condition_builder_empty_selection_error_text') : info
|
|
35
|
-
condition !== undefined && (_jsx(Button, { icon: true, variant: 'simple', label: t('clear'), onClick: () => {
|
|
36
|
-
onClear();
|
|
37
|
-
if (inputRef.current) {
|
|
38
|
-
const inputEl = inputRef.current.querySelector('input');
|
|
39
|
-
inputEl?.focus();
|
|
40
|
-
}
|
|
41
|
-
}, children: _jsx(Icon, { name: 'times' }) })) }));
|
|
42
|
+
}, status: status, info: status === 'error' ? t('condition_builder_empty_selection_error_text') : info }));
|
|
42
43
|
};
|
|
43
44
|
export default ConditionSelector;
|
|
44
45
|
//# sourceMappingURL=ConditionSelector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionSelector.js","sourceRoot":"","sources":["../../../src/components/PromotedFilters/ConditionSelector.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGxC,OAAO,EACL,OAAO,EACP,QAAQ,EACR,
|
|
1
|
+
{"version":3,"file":"ConditionSelector.js","sourceRoot":"","sources":["../../../src/components/PromotedFilters/ConditionSelector.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGxC,OAAO,EACL,OAAO,EACP,QAAQ,EACR,gBAAgB,EAChB,WAAW,EACX,SAAS,EACV,MAAM,yBAAyB,CAAC;AAUjC,OAAO,eAAe,MAAM,oCAAoC,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAqB1D,MAAM,iBAAiB,GAA6D,CAAC,EACnF,QAAQ,EACR,MAAM,EACN,KAAK,EACL,IAAI,EACJ,MAAM,EACN,WAAW,EACX,UAAU,EACV,SAAS,EACT,GAAG,SAAS,EACW,EAAE,EAAE;IAC3B,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE,CAAC;IAEtC,MAAM,QAAQ,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC9C,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,EAAE;QACjC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,EAAE,EAAE;YACpE,OAAO;gBACL,EAAE;gBACF,OAAO,EACL,cAAc;oBACd,eAAe,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE;wBAC/C,MAAM;wBACN,OAAO,EAAE,IAAI;qBACd,CAAC;gBACJ,Q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AAC,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import { useMemo, useRef } from 'react';\nimport type { FunctionComponent } from 'react';\n\nimport {\n useI18n,\n ComboBox,\n useConfiguration,\n menuHelpers,\n createUID\n} from '@pega/cosmos-react-core';\nimport type {\n BaseProps,\n NoChildrenProp,\n ComboBoxProps,\n MenuItemProps,\n ForwardProps\n} from '@pega/cosmos-react-core';\n\nimport type { AtomicConditionProps } from '../ConditionBuilder/AtomicCondition';\nimport formatCondition from '../ConditionBuilder/core/formatter';\nimport type { LeafCondition } from '../ConditionBuilder';\nimport { conditionsEqual } from '../ConditionInput/utils';\n\nexport interface ConditionSelectorProps extends BaseProps, NoChildrenProp {\n /** Callback for onChange */\n onChange: (condition?: LeafCondition) => void;\n /** Used to indicate any errors on the control */\n status?: 'error';\n /** Custom label for input. Makes label visible if provided. */\n label?: ComboBoxProps['label'];\n /** Visually hides the label region. */\n labelHidden?: ComboBoxProps['labelHidden'];\n /** Guidance text that apppears below the input. */\n info?: ComboBoxProps['info'];\n /** Definition of the field the condition is created for. */\n fields: AtomicConditionProps['fields'];\n /** List of possible predefined Conditions */\n conditions: { id: string; value: LeafCondition; label?: string }[];\n /** Currently selected condition. */\n condition?: LeafCondition;\n}\n\nconst ConditionSelector: FunctionComponent<ConditionSelectorProps & ForwardProps> = ({\n onChange,\n status,\n label,\n info,\n fields,\n labelHidden,\n conditions,\n condition,\n ...restProps\n}: ConditionSelectorProps) => {\n const t = useI18n();\n const { locale } = useConfiguration();\n\n const inputRef = useRef<HTMLDivElement>(null);\n const itemsToRender = useMemo(() => {\n const items = conditions.map(({ id, label: conditionLabel, value }) => {\n return {\n id,\n primary:\n conditionLabel ??\n formatCondition({ condition: value }, fields, t, {\n locale,\n omitLhs: true\n }),\n selected: !!value && !!condition && conditionsEqual(value, condition)\n };\n });\n if (condition) {\n items.unshift({\n id: createUID(),\n primary: '',\n selected: false\n });\n }\n\n return items;\n }, [conditions, condition]);\n\n const selected = useMemo<MenuItemProps | undefined>(\n () => menuHelpers.getSelected(itemsToRender)[0],\n [itemsToRender]\n );\n\n return (\n <ComboBox\n {...restProps}\n ref={inputRef}\n mode='single-select'\n label={label ?? t('condition_builder_possible_values_label')}\n labelHidden={labelHidden}\n selected={\n selected\n ? {\n items: {\n id: selected.id,\n text: selected.primary\n }\n }\n : undefined\n }\n menu={{\n items: itemsToRender,\n onItemClick: (id: MenuItemProps['id']) =>\n onChange(conditions.find(cnd => cnd.id === id)?.value)\n }}\n status={status}\n info={status === 'error' ? t('condition_builder_empty_selection_error_text') : info}\n />\n );\n};\n\nexport default ConditionSelector;\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ForwardProps } from '@pega/cosmos-react-core';
|
|
1
|
+
import type { ForwardRefForwardPropsComponent } from '@pega/cosmos-react-core';
|
|
3
2
|
import type { PromotedFiltersProps } from './PromotedFilters.types';
|
|
4
|
-
export declare const PromotedFilters:
|
|
3
|
+
export declare const PromotedFilters: ForwardRefForwardPropsComponent<PromotedFiltersProps>;
|
|
5
4
|
export default PromotedFilters;
|
|
6
5
|
//# sourceMappingURL=PromotedFilters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromotedFilters.d.ts","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PromotedFilters.d.ts","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EACV,+BAA+B,EAIhC,MAAM,yBAAyB,CAAC;AASjC,OAAO,KAAK,EAGV,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AAuMjC,eAAO,MAAM,eAAe,EAAE,+BAA+B,CAAC,oBAAoB,CAuJjF,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
3
3
|
import { Button, Flex, Icon, Modal, useModalManager, useBreakpoint, useI18n, useModalContext, hasProp, useSimpleStore, useSimpleStoreInstance } from '@pega/cosmos-react-core';
|
|
4
4
|
import { splitConditionForBuilder } from '../ConditionBuilder/core/utils';
|
|
5
5
|
import ConditionInput from '../ConditionInput';
|
|
@@ -18,65 +18,65 @@ const generateCondition = (value) => {
|
|
|
18
18
|
const storeValues = Object.values(value);
|
|
19
19
|
return storeValues.length === 0
|
|
20
20
|
? undefined
|
|
21
|
-
: {
|
|
21
|
+
: {
|
|
22
|
+
AND: storeValues.map(c => ({ condition: c }))
|
|
23
|
+
};
|
|
22
24
|
};
|
|
23
|
-
const
|
|
24
|
-
const [storeValue, setStore] = useSimpleStore(conditionStore, val => val[
|
|
25
|
-
const
|
|
26
|
-
if (newCondition)
|
|
27
|
-
|
|
25
|
+
const withStore = (WrappedComponent) => memo(({ conditionStore, filterId, onApply, ...componentProps }) => {
|
|
26
|
+
const [storeValue, setStore] = useSimpleStore(conditionStore, val => val[filterId], conditionsEqual);
|
|
27
|
+
const handleOnChange = (newCondition) => {
|
|
28
|
+
if (!isValidNewCondition(newCondition))
|
|
29
|
+
return;
|
|
30
|
+
if (newCondition) {
|
|
31
|
+
if (!newCondition.filterId && filterId !== newCondition.lhs?.field)
|
|
32
|
+
newCondition = { ...newCondition, filterId };
|
|
33
|
+
if (conditionsEqual(storeValue, newCondition))
|
|
34
|
+
return;
|
|
35
|
+
setStore(cur => ({
|
|
36
|
+
...cur,
|
|
37
|
+
[filterId]: newCondition
|
|
38
|
+
}));
|
|
39
|
+
onApply?.();
|
|
40
|
+
}
|
|
28
41
|
else {
|
|
29
|
-
|
|
30
|
-
|
|
42
|
+
if (!storeValue)
|
|
43
|
+
return;
|
|
44
|
+
setStore(({ ...cur }) => {
|
|
45
|
+
delete cur[filterId];
|
|
31
46
|
return cur;
|
|
32
47
|
});
|
|
48
|
+
onApply?.();
|
|
33
49
|
}
|
|
34
50
|
};
|
|
35
|
-
|
|
36
|
-
if (isValidNewCondition(newCondition))
|
|
37
|
-
updateStore(newCondition);
|
|
38
|
-
};
|
|
39
|
-
return (_jsx(WrappedComponent, { ...componentProps, field: field, condition: storeValue, onChange: (newCondition) => handleOnChange(newCondition) }));
|
|
51
|
+
return (_jsx(WrappedComponent, { condition: storeValue, ...componentProps, onChange: handleOnChange }));
|
|
40
52
|
});
|
|
41
|
-
const ConditionInputWithStore =
|
|
42
|
-
const ConditionSelectorWithStore =
|
|
43
|
-
const PromotedFiltersContent = memo(forwardRef(function PromotedFiltersContent({ filters, conditionStore, orientation: orientationProp = 'horizontal' }, ref) {
|
|
44
|
-
const t = useI18n();
|
|
53
|
+
const ConditionInputWithStore = withStore(ConditionInput);
|
|
54
|
+
const ConditionSelectorWithStore = withStore(ConditionSelector);
|
|
55
|
+
const PromotedFiltersContent = memo(forwardRef(function PromotedFiltersContent({ filters, conditionStore, orientation: orientationProp = 'horizontal', fields, onApply }, ref) {
|
|
45
56
|
const isSmallOrAbove = useBreakpoint('sm');
|
|
46
57
|
const orientation = isSmallOrAbove && orientationProp === 'horizontal' ? 'horizontal' : 'vertical';
|
|
47
58
|
const [collapsed, setCollapsed] = useState(false);
|
|
48
|
-
const onClear = (fieldName) => {
|
|
49
|
-
conditionStore.setStore(cur => {
|
|
50
|
-
delete cur[fieldName];
|
|
51
|
-
return cur;
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
59
|
return (_jsx(Flex, { container: {
|
|
55
60
|
rowGap: 1,
|
|
56
61
|
colGap: 2,
|
|
57
62
|
direction: orientation === 'vertical' ? 'column' : 'row',
|
|
58
63
|
wrap: 'wrap',
|
|
59
64
|
alignItems: orientation === 'vertical' ? 'stretch' : 'start'
|
|
60
|
-
}, ref: ref, children: filters.map(({ field, mode, label, predefinedConditions }) => {
|
|
65
|
+
}, ref: ref, children: filters.map(({ id, field, mode, label, predefinedConditions }) => {
|
|
66
|
+
id = id ?? field.name;
|
|
61
67
|
if (mode !== 'predefined')
|
|
62
|
-
return (_jsx(ConditionInputWithStore, { conditionStore: conditionStore, field: field, mode: mode, label: label ?? field.name, flat: orientation === 'vertical' },
|
|
63
|
-
const selector = (_jsx(ConditionSelectorWithStore, { conditionStore: conditionStore, label: label ?? field.name, labelHidden: orientation === 'vertical',
|
|
68
|
+
return (_jsx(ConditionInputWithStore, { conditionStore: conditionStore, filterId: id, field: field, mode: mode, label: label ?? field.name, flat: orientation === 'vertical', fields: fields, onApply: onApply }, id));
|
|
69
|
+
const selector = (_jsx(ConditionSelectorWithStore, { conditionStore: conditionStore, filterId: id, label: label ?? field.name, labelHidden: orientation === 'vertical', fields: [
|
|
64
70
|
{
|
|
65
71
|
id: field.name,
|
|
66
72
|
type: basicFieldMap[field.type],
|
|
67
73
|
primary: label || field.name
|
|
68
74
|
}
|
|
69
|
-
], conditions: predefinedConditions ?? [],
|
|
70
|
-
return orientation === 'vertical' ? (_jsx(StyledVerticalFieldGroup, { name: label ??
|
|
71
|
-
{
|
|
72
|
-
id: 'clear',
|
|
73
|
-
text: t('clear'),
|
|
74
|
-
onClick: () => onClear(field.name)
|
|
75
|
-
}
|
|
76
|
-
], children: selector }, field.name)) : (selector);
|
|
75
|
+
], conditions: predefinedConditions ?? [], onApply: onApply ?? (() => { }) }, id));
|
|
76
|
+
return orientation === 'vertical' ? (_jsx(StyledVerticalFieldGroup, { name: label ?? id, collapsed: collapsed, onToggleCollapsed: () => setCollapsed(cur => !cur), children: selector }, id)) : (selector);
|
|
77
77
|
}) }));
|
|
78
78
|
}));
|
|
79
|
-
const FilterModal = ({ filters, conditionStore, onApply, onCancel }) => {
|
|
79
|
+
const FilterModal = ({ filters, conditionStore, fields, onApply, onCancel }) => {
|
|
80
80
|
const t = useI18n();
|
|
81
81
|
const { dismiss, unmount } = useModalContext();
|
|
82
82
|
const handleApplyClick = () => {
|
|
@@ -84,9 +84,9 @@ const FilterModal = ({ filters, conditionStore, onApply, onCancel }) => {
|
|
|
84
84
|
unmount();
|
|
85
85
|
};
|
|
86
86
|
const actions = (_jsxs(_Fragment, { children: [_jsx(Button, { onClick: dismiss, children: t('cancel') }), _jsx(Button, { onClick: handleApplyClick, children: t('apply') })] }));
|
|
87
|
-
return (_jsx(Modal, { heading: t('filters'), actions: actions, onBeforeClose: onCancel, children: _jsx(PromotedFiltersContent, { filters: filters, conditionStore: conditionStore, orientation: 'vertical' }) }));
|
|
87
|
+
return (_jsx(Modal, { heading: t('filters'), actions: actions, onBeforeClose: onCancel, children: _jsx(PromotedFiltersContent, { filters: filters, conditionStore: conditionStore, orientation: 'vertical', fields: fields }) }));
|
|
88
88
|
};
|
|
89
|
-
export const PromotedFilters = forwardRef(function PromotedFilters({ filters, condition, onChange, orientation = 'horizontal' }, ref) {
|
|
89
|
+
export const PromotedFilters = forwardRef(function PromotedFilters({ filters, condition, onChange, orientation = 'horizontal', fields, handle }, ref) {
|
|
90
90
|
const t = useI18n();
|
|
91
91
|
const promotedFiltersRef = useRef(null);
|
|
92
92
|
const isSmallOrAbove = useBreakpoint('sm', { breakpointRef: promotedFiltersRef });
|
|
@@ -97,7 +97,7 @@ export const PromotedFilters = forwardRef(function PromotedFilters({ filters, co
|
|
|
97
97
|
return condition
|
|
98
98
|
? splitConditionForBuilder(condition).rows.reduce((result, item) => {
|
|
99
99
|
const { id, label, ...leaf } = item;
|
|
100
|
-
result[
|
|
100
|
+
result[leaf.filterId ?? leaf.lhs.field] = leaf;
|
|
101
101
|
return result;
|
|
102
102
|
}, {})
|
|
103
103
|
: {};
|
|
@@ -106,24 +106,33 @@ export const PromotedFilters = forwardRef(function PromotedFilters({ filters, co
|
|
|
106
106
|
conditionStore.setStore(prepareConditionForStore());
|
|
107
107
|
}, [prepareConditionForStore]);
|
|
108
108
|
const selectedCount = Object.values(conditionStore.getStore()).length;
|
|
109
|
-
|
|
109
|
+
useImperativeHandle(handle, () => ({ getCondition: () => generateCondition(conditionStore.getStore()) }), []);
|
|
110
|
+
const onApply = useCallback(() => {
|
|
111
|
+
const storeValue = generateCondition(conditionStore.getStore());
|
|
112
|
+
if (JSON.stringify(condition) !== JSON.stringify(storeValue))
|
|
113
|
+
onChange(storeValue);
|
|
114
|
+
}, [onChange, prepareConditionForStore]);
|
|
110
115
|
const onClear = useCallback(() => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
116
|
+
if (condition) {
|
|
117
|
+
conditionStore.setStore({});
|
|
118
|
+
onChange();
|
|
119
|
+
}
|
|
120
|
+
}, [onChange, prepareConditionForStore]);
|
|
114
121
|
const onCancel = useCallback(() => {
|
|
115
122
|
conditionStore.setStore(prepareConditionForStore());
|
|
116
123
|
}, [prepareConditionForStore]);
|
|
117
124
|
useEffect(() => {
|
|
118
125
|
modalMethods.current?.update({
|
|
119
126
|
filters,
|
|
120
|
-
conditionStore
|
|
127
|
+
conditionStore,
|
|
128
|
+
fields
|
|
121
129
|
});
|
|
122
|
-
}, [filters, condition]);
|
|
130
|
+
}, [filters, condition, fields]);
|
|
123
131
|
const openFiltersModal = () => {
|
|
124
132
|
modalMethods.current = create(FilterModal, {
|
|
125
133
|
filters,
|
|
126
134
|
conditionStore,
|
|
135
|
+
fields,
|
|
127
136
|
onApply,
|
|
128
137
|
onCancel
|
|
129
138
|
});
|
|
@@ -138,7 +147,7 @@ export const PromotedFilters = forwardRef(function PromotedFilters({ filters, co
|
|
|
138
147
|
justify: 'between',
|
|
139
148
|
alignItems: 'center',
|
|
140
149
|
pad: [0, 0, 1, 0]
|
|
141
|
-
}, children: [_jsx(StyledTextWithEllipsis, { variant: 'h3', children: t('filters') }), _jsxs("div", { children: [_jsx(Button, { onClick: onClear, children: t('reset') }), _jsx(Button, { onClick: onApply, children: t('apply') })] })] })), _jsx(PromotedFiltersContent, { filters: filters, conditionStore: conditionStore, orientation: orientation, ref: ref }), orientation === 'horizontal' && (_jsxs(Flex, { container: true, children: [_jsx(StyledPromotedFiltersButton, { onClick: onClear, children: t('reset') }), _jsx(StyledPromotedFiltersButton, { onClick: onApply, children: t('apply') })] }))] })) : (_jsxs(_Fragment, { children: [_jsx(Button, { type: 'button', variant: 'text', onClick: openFiltersModal, children: _jsxs(Flex, { container: { alignItems: 'center', gap: 0.5 }, forwardedAs: 'span', children: [_jsx(Icon, { name: 'filter' }), _jsxs("span", { children: [t('filters'), !!selectedCount && `\u00a0(${selectedCount})`] })] }) }), _jsx(Button, { onClick: onClear, children: t('reset') })] })) }));
|
|
150
|
+
}, children: [_jsx(StyledTextWithEllipsis, { variant: 'h3', children: t('filters') }), _jsxs("div", { children: [_jsx(Button, { onClick: onClear, children: t('reset') }), _jsx(Button, { onClick: onApply, children: t('apply') })] })] })), _jsx(PromotedFiltersContent, { filters: filters, conditionStore: conditionStore, fields: fields, orientation: orientation, ref: ref, onApply: onApply }), orientation === 'horizontal' && (_jsxs(Flex, { container: true, children: [_jsx(StyledPromotedFiltersButton, { onClick: onClear, children: t('reset') }), _jsx(StyledPromotedFiltersButton, { onClick: onApply, children: t('apply') })] }))] })) : (_jsxs(_Fragment, { children: [_jsx(Button, { type: 'button', variant: 'text', onClick: openFiltersModal, children: _jsxs(Flex, { container: { alignItems: 'center', gap: 0.5 }, forwardedAs: 'span', children: [_jsx(Icon, { name: 'filter' }), _jsxs("span", { children: [t('filters'), !!selectedCount && `\u00a0(${selectedCount})`] })] }) }), _jsx(Button, { onClick: onClear, children: t('reset') })] })) }));
|
|
142
151
|
});
|
|
143
152
|
export default PromotedFilters;
|
|
144
153
|
//# sourceMappingURL=PromotedFilters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromotedFilters.js","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,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Ac,EAC9B,WAAW,EAAE,WAAW,EACxB,GAAG,EAAE,GAAG,GACR,EAED,WAAW,KAAK,YAAY,IAAI,CAC/B,MAAC,IAAI,IAAC,SAAS,mBACb,KAAC,2BAA2B,IAAC,OAAO,EAAE,OAAO,YAC1C,CAAC,CAAC,OAAO,CAAC,GACiB,EAC9B,KAAC,2BAA2B,IAAC,OAAO,EAAE,OAAO,YAC1C,CAAC,CAAC,OAAO,CAAC,GACiB,IACzB,CACR,IACA,CACJ,CAAC,CAAC,CAAC,CACF,8BACE,KAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAC,MAAM,EAAC,OAAO,EAAE,gBAAgB,YAC5D,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,WAAW,EAAC,MAAM,aACrE,KAAC,IAAI,IAAC,IAAI,EAAC,QAAQ,GAAG,EACtB,2BACG,CAAC,CAAC,SAAS,CAAC,EACZ,CAAC,CAAC,aAAa,IAAI,UAAU,aAAa,GAAG,IACzC,IACF,GACA,EACT,KAAC,MAAM,IAAC,OAAO,EAAE,OAAO,YAAG,CAAC,CAAC,OAAO,CAAC,GAAU,IAC9C,CACJ,GACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { forwardRef, memo, useCallback, useEffect, useRef, useState } from 'react';\nimport type { FunctionComponent, PropsWithoutRef } from 'react';\n\nimport {\n Button,\n Flex,\n Icon,\n Modal,\n useModalManager,\n useBreakpoint,\n useI18n,\n useModalContext,\n hasProp,\n useSimpleStore,\n useSimpleStoreInstance\n} from '@pega/cosmos-react-core';\nimport type { ForwardProps, ModalMethods, OmitStrict, SimpleStore } from '@pega/cosmos-react-core';\n\nimport type { Condition, LeafCondition } from '../ConditionBuilder/ConditionBuilder.types';\nimport { splitConditionForBuilder } from '../ConditionBuilder/core/utils';\nimport ConditionInput from '../ConditionInput';\nimport type { ConditionField } from '../ConditionInput';\nimport { StyledVerticalFieldGroup } from '../ConditionInput/ConditionInput.styles';\nimport { basicFieldMap, conditionsEqual } from '../ConditionInput/utils';\n\nimport ConditionSelector from './ConditionSelector';\nimport type {\n FilterModalProps,\n PromotedFiltersContentProps,\n PromotedFiltersProps\n} from './PromotedFilters.types';\nimport {\n StyledPromotedFilters,\n StyledTextWithEllipsis,\n StyledPromotedFiltersButton\n} from './PromotedFilters.styles';\n\nconst isValidNewCondition = (newCondition?: LeafCondition): boolean => {\n if (!newCondition?.rhs) return true;\n if (!hasProp(newCondition.rhs, 'start') && !hasProp(newCondition.rhs, 'end')) return true;\n return !Number.isNaN(newCondition.rhs.start) && !Number.isNaN(newCondition.rhs.end);\n};\n\nconst generateCondition = (value: { [key: string]: LeafCondition | undefined }) => {\n const storeValues = Object.values(value);\n return storeValues.length === 0\n ? undefined\n : { AND: storeValues.map(c => ({ condition: c }) as Condition) };\n};\n\ntype WithStoreProps = {\n conditionStore: SimpleStore<{ [key: string]: LeafCondition | undefined }>;\n field: ConditionField;\n};\n\nconst injectStore = <\n T extends { onChange: (condition?: LeafCondition) => void; condition?: LeafCondition }\n>(\n WrappedComponent: FunctionComponent<T>\n): FunctionComponent<OmitStrict<T, 'onChange'> & WithStoreProps> =>\n memo(({ conditionStore, field, ...componentProps }) => {\n const [storeValue, setStore] = useSimpleStore(\n conditionStore,\n val => val[field.name],\n conditionsEqual\n );\n\n const updateStore = (newCondition?: LeafCondition) => {\n if (newCondition) setStore(cur => ({ ...cur, [field.name]: newCondition }));\n else {\n setStore(cur => {\n delete cur[field.name];\n return cur;\n });\n }\n };\n\n const handleOnChange = (newCondition?: LeafCondition) => {\n if (isValidNewCondition(newCondition)) updateStore(newCondition);\n };\n\n return (\n <WrappedComponent\n {...(componentProps as T)}\n field={field}\n condition={storeValue}\n onChange={(newCondition?: LeafCondition) => handleOnChange(newCondition)}\n />\n );\n });\n\nconst ConditionInputWithStore = injectStore(ConditionInput);\nconst ConditionSelectorWithStore = injectStore(ConditionSelector);\n\nconst PromotedFiltersContent: FunctionComponent<PromotedFiltersContentProps & ForwardProps> = memo(\n forwardRef(function PromotedFiltersContent(\n {\n filters,\n conditionStore,\n orientation: orientationProp = 'horizontal'\n }: PropsWithoutRef<PromotedFiltersContentProps>,\n ref: PromotedFiltersProps['ref']\n ) {\n const t = useI18n();\n const isSmallOrAbove = useBreakpoint('sm');\n const orientation =\n isSmallOrAbove && orientationProp === 'horizontal' ? 'horizontal' : 'vertical';\n const [collapsed, setCollapsed] = useState(false);\n\n const onClear = (fieldName: string) => {\n conditionStore.setStore(cur => {\n delete cur[fieldName];\n return cur;\n });\n };\n\n return (\n <Flex\n container={{\n rowGap: 1,\n colGap: 2,\n direction: orientation === 'vertical' ? 'column' : 'row',\n wrap: 'wrap',\n alignItems: orientation === 'vertical' ? 'stretch' : 'start'\n }}\n ref={ref}\n >\n {filters.map(({ field, mode, label, predefinedConditions }) => {\n if (mode !== 'predefined')\n return (\n <ConditionInputWithStore\n conditionStore={conditionStore}\n key={field.name}\n field={field}\n mode={mode}\n label={label ?? field.name}\n flat={orientation === 'vertical'}\n />\n );\n\n const selector = (\n <ConditionSelectorWithStore\n conditionStore={conditionStore}\n key={field.name}\n label={label ?? field.name}\n labelHidden={orientation === 'vertical'}\n field={field}\n fields={[\n {\n id: field.name,\n type: basicFieldMap[field.type],\n primary: label || field.name\n }\n ]}\n conditions={predefinedConditions ?? []}\n onClear={() => onClear(field.name)}\n />\n );\n\n return orientation === 'vertical' ? (\n <StyledVerticalFieldGroup\n key={field.name}\n name={label ?? field.name}\n collapsed={collapsed}\n onToggleCollapsed={() => setCollapsed(cur => !cur)}\n actions={[\n {\n id: 'clear',\n text: t('clear'),\n onClick: () => onClear(field.name)\n }\n ]}\n >\n {selector}\n </StyledVerticalFieldGroup>\n ) : (\n selector\n );\n })}\n </Flex>\n );\n })\n);\n\nconst FilterModal = ({ filters, conditionStore, onApply, onCancel }: FilterModalProps) => {\n const t = useI18n();\n\n const { dismiss, unmount } = useModalContext();\n\n const handleApplyClick = () => {\n onApply();\n unmount();\n };\n\n const actions = (\n <>\n <Button onClick={dismiss}>{t('cancel')}</Button>\n <Button onClick={handleApplyClick}>{t('apply')}</Button>\n </>\n );\n\n return (\n <Modal heading={t('filters')} actions={actions} onBeforeClose={onCancel}>\n <PromotedFiltersContent\n filters={filters}\n conditionStore={conditionStore}\n orientation='vertical'\n />\n </Modal>\n );\n};\n\nexport const PromotedFilters: FunctionComponent<PromotedFiltersProps & ForwardProps> = forwardRef(\n function PromotedFilters(\n {\n filters,\n condition,\n onChange,\n orientation = 'horizontal'\n }: PropsWithoutRef<PromotedFiltersProps>,\n ref: PromotedFiltersProps['ref']\n ) {\n const t = useI18n();\n\n const promotedFiltersRef = useRef<HTMLDivElement>(null);\n const isSmallOrAbove = useBreakpoint('sm', { breakpointRef: promotedFiltersRef });\n\n const { create } = useModalManager();\n const modalMethods = useRef<ModalMethods<FilterModalProps>>();\n\n const conditionStore = useSimpleStoreInstance({});\n\n const prepareConditionForStore = useCallback(() => {\n return condition\n ? splitConditionForBuilder(condition).rows.reduce(\n (result: { [key: string]: LeafCondition | undefined }, item) => {\n const { id, label, ...leaf } = item;\n result[item.lhs.field] = leaf;\n return result;\n },\n {}\n )\n : {};\n }, [condition]);\n\n useEffect(() => {\n conditionStore.setStore(prepareConditionForStore());\n }, [prepareConditionForStore]);\n\n const selectedCount = Object.values(conditionStore.getStore()).length;\n\n const onApply = useCallback(\n () => onChange(generateCondition(conditionStore.getStore())),\n [onChange]\n );\n\n const onClear = useCallback(() => {\n conditionStore.setStore({});\n onChange();\n }, [onChange]);\n\n const onCancel = useCallback(() => {\n conditionStore.setStore(prepareConditionForStore());\n }, [prepareConditionForStore]);\n\n useEffect(() => {\n modalMethods.current?.update({\n filters,\n conditionStore\n });\n }, [filters, condition]);\n\n const openFiltersModal = () => {\n modalMethods.current = create(FilterModal, {\n filters,\n conditionStore,\n onApply,\n onCancel\n });\n };\n\n return (\n <Flex\n as={StyledPromotedFilters}\n container={{\n alignItems: orientation === 'horizontal' && isSmallOrAbove ? 'start' : undefined,\n justify: 'between',\n direction: !isSmallOrAbove || orientation === 'horizontal' ? 'row' : 'column',\n pad: 2,\n gap: 2\n }}\n ref={promotedFiltersRef}\n >\n {isSmallOrAbove ? (\n <>\n {orientation === 'vertical' && (\n <Flex\n container={{\n justify: 'between',\n alignItems: 'center',\n pad: [0, 0, 1, 0]\n }}\n >\n <StyledTextWithEllipsis variant='h3'>{t('filters')}</StyledTextWithEllipsis>\n <div>\n <Button onClick={onClear}>{t('reset')}</Button>\n <Button onClick={onApply}>{t('apply')}</Button>\n </div>\n </Flex>\n )}\n\n <PromotedFiltersContent\n filters={filters}\n conditionStore={conditionStore}\n orientation={orientation}\n ref={ref}\n />\n\n {orientation === 'horizontal' && (\n <Flex container>\n <StyledPromotedFiltersButton onClick={onClear}>\n {t('reset')}\n </StyledPromotedFiltersButton>\n <StyledPromotedFiltersButton onClick={onApply}>\n {t('apply')}\n </StyledPromotedFiltersButton>\n </Flex>\n )}\n </>\n ) : (\n <>\n <Button type='button' variant='text' onClick={openFiltersModal}>\n <Flex container={{ alignItems: 'center', gap: 0.5 }} forwardedAs='span'>\n <Icon name='filter' />\n <span>\n {t('filters')}\n {!!selectedCount && `\\u00a0(${selectedCount})`}\n </span>\n </Flex>\n </Button>\n <Button onClick={onClear}>{t('reset')}</Button>\n </>\n )}\n </Flex>\n );\n }\n);\n\nexport default PromotedFilters;\n"]}
|
|
1
|
+
{"version":3,"file":"PromotedFilters.js","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,IAAI,EACJ,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AAGf,OAAO,EACL,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,eAAe,EACf,aAAa,EACb,OAA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AAC,OAAO,EAAE,OAAO,YAAG,CAAC,CAAC,OAAO,CAAC,GAAU,EAC/C,KAAC,MAAM,IAAC,OAAO,EAAE,OAAO,YAAG,CAAC,CAAC,OAAO,CAAC,GAAU,IAC3C,IACD,CACR,EAED,KAAC,sBAAsB,IACrB,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,OAAO,GAChB,EAED,WAAW,KAAK,YAAY,IAAI,CAC/B,MAAC,IAAI,IAAC,SAAS,mBACb,KAAC,2BAA2B,IAAC,OAAO,EAAE,OAAO,YAC1C,CAAC,CAAC,OAAO,CAAC,GACiB,EAC9B,KAAC,2BAA2B,IAAC,OAAO,EAAE,OAAO,YAC1C,CAAC,CAAC,OAAO,CAAC,GACiB,IACzB,CACR,IACA,CACJ,CAAC,CAAC,CAAC,CACF,8BACE,KAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAC,MAAM,EAAC,OAAO,EAAE,gBAAgB,YAC5D,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,WAAW,EAAC,MAAM,aACrE,KAAC,IAAI,IAAC,IAAI,EAAC,QAAQ,GAAG,EACtB,2BACG,CAAC,CAAC,SAAS,CAAC,EACZ,CAAC,CAAC,aAAa,IAAI,UAAU,aAAa,GAAG,IACzC,IACF,GACA,EACT,KAAC,MAAM,IAAC,OAAO,EAAE,OAAO,YAAG,CAAC,CAAC,OAAO,CAAC,GAAU,IAC9C,CACJ,GACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import {\n forwardRef,\n memo,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState\n} from 'react';\nimport type { ComponentType, PropsWithoutRef } from 'react';\n\nimport {\n Button,\n Flex,\n Icon,\n Modal,\n useModalManager,\n useBreakpoint,\n useI18n,\n useModalContext,\n hasProp,\n useSimpleStore,\n useSimpleStoreInstance\n} from '@pega/cosmos-react-core';\nimport type {\n ForwardRefForwardPropsComponent,\n ModalMethods,\n OmitStrict,\n SimpleStore\n} from '@pega/cosmos-react-core';\n\nimport type { ConditionRow, LeafCondition } from '../ConditionBuilder/ConditionBuilder.types';\nimport { splitConditionForBuilder } from '../ConditionBuilder/core/utils';\nimport ConditionInput from '../ConditionInput';\nimport { StyledVerticalFieldGroup } from '../ConditionInput/ConditionInput.styles';\nimport { basicFieldMap, conditionsEqual } from '../ConditionInput/utils';\n\nimport ConditionSelector from './ConditionSelector';\nimport type {\n FilterModalProps,\n PromotedFiltersContentProps,\n PromotedFiltersProps\n} from './PromotedFilters.types';\nimport {\n StyledPromotedFilters,\n StyledTextWithEllipsis,\n StyledPromotedFiltersButton\n} from './PromotedFilters.styles';\n\nconst isValidNewCondition = (newCondition?: LeafCondition & { filterId?: string }): boolean => {\n if (!newCondition?.rhs) return true;\n if (!hasProp(newCondition.rhs, 'start') && !hasProp(newCondition.rhs, 'end')) return true;\n return !Number.isNaN(newCondition.rhs.start) && !Number.isNaN(newCondition.rhs.end);\n};\n\nconst generateCondition = (value: {\n [key: string]: (LeafCondition & { filterId?: string }) | undefined;\n}) => {\n const storeValues = Object.values(value);\n return storeValues.length === 0\n ? undefined\n : {\n AND: storeValues.map(\n c => ({ condition: c }) as { condition: LeafCondition & { filterId?: string } }\n )\n };\n};\n\ntype WithStoreProps = {\n conditionStore: SimpleStore<{\n [key: string]: (LeafCondition & { filterId?: string }) | undefined;\n }>;\n filterId: string;\n onApply: () => void;\n};\n\nconst withStore = <\n P extends {\n onChange: (condition?: LeafCondition & { filterId?: string }) => void;\n condition?: LeafCondition & { filterId?: string };\n }\n>(\n WrappedComponent: ComponentType<P>\n) =>\n memo(\n ({\n conditionStore,\n filterId,\n onApply,\n ...componentProps\n }: OmitStrict<P, 'onChange'> & WithStoreProps) => {\n const [storeValue, setStore] = useSimpleStore(\n conditionStore,\n val => val[filterId],\n conditionsEqual\n );\n\n const handleOnChange = (newCondition?: LeafCondition & { filterId?: string }) => {\n if (!isValidNewCondition(newCondition)) return;\n if (newCondition) {\n if (!newCondition.filterId && filterId !== newCondition.lhs?.field)\n newCondition = { ...newCondition, filterId };\n if (conditionsEqual(storeValue, newCondition)) return;\n setStore(cur => ({\n ...cur,\n [filterId]: newCondition\n }));\n onApply?.();\n } else {\n if (!storeValue) return;\n setStore(({ ...cur }) => {\n delete cur[filterId];\n return cur;\n });\n onApply?.();\n }\n };\n\n return (\n <WrappedComponent\n condition={storeValue}\n {...(componentProps as unknown as P)}\n onChange={handleOnChange}\n />\n );\n }\n );\n\nconst ConditionInputWithStore = withStore(ConditionInput);\nconst ConditionSelectorWithStore = withStore(ConditionSelector);\n\nconst PromotedFiltersContent = memo(\n forwardRef(function PromotedFiltersContent(\n {\n filters,\n conditionStore,\n orientation: orientationProp = 'horizontal',\n fields,\n onApply\n }: PropsWithoutRef<PromotedFiltersContentProps>,\n ref: PromotedFiltersProps['ref']\n ) {\n const isSmallOrAbove = useBreakpoint('sm');\n const orientation =\n isSmallOrAbove && orientationProp === 'horizontal' ? 'horizontal' : 'vertical';\n const [collapsed, setCollapsed] = useState(false);\n\n return (\n <Flex\n container={{\n rowGap: 1,\n colGap: 2,\n direction: orientation === 'vertical' ? 'column' : 'row',\n wrap: 'wrap',\n alignItems: orientation === 'vertical' ? 'stretch' : 'start'\n }}\n ref={ref}\n >\n {filters.map(({ id, field, mode, label, predefinedConditions }) => {\n id = id ?? field.name;\n if (mode !== 'predefined')\n return (\n <ConditionInputWithStore\n conditionStore={conditionStore}\n key={id}\n filterId={id}\n field={field}\n mode={mode}\n label={label ?? field.name}\n flat={orientation === 'vertical'}\n fields={fields}\n onApply={onApply}\n />\n );\n\n const selector = (\n <ConditionSelectorWithStore\n conditionStore={conditionStore}\n key={id}\n filterId={id}\n label={label ?? field.name}\n labelHidden={orientation === 'vertical'}\n fields={[\n {\n id: field.name,\n type: basicFieldMap[field.type],\n primary: label || field.name\n }\n ]}\n conditions={predefinedConditions ?? []}\n onApply={onApply ?? (() => {})}\n />\n );\n\n return orientation === 'vertical' ? (\n <StyledVerticalFieldGroup\n key={id}\n name={label ?? id}\n collapsed={collapsed}\n onToggleCollapsed={() => setCollapsed(cur => !cur)}\n >\n {selector}\n </StyledVerticalFieldGroup>\n ) : (\n selector\n );\n })}\n </Flex>\n );\n })\n);\n\nconst FilterModal = ({ filters, conditionStore, fields, onApply, onCancel }: FilterModalProps) => {\n const t = useI18n();\n\n const { dismiss, unmount } = useModalContext();\n\n const handleApplyClick = () => {\n onApply();\n unmount();\n };\n\n const actions = (\n <>\n <Button onClick={dismiss}>{t('cancel')}</Button>\n <Button onClick={handleApplyClick}>{t('apply')}</Button>\n </>\n );\n\n return (\n <Modal heading={t('filters')} actions={actions} onBeforeClose={onCancel}>\n <PromotedFiltersContent\n filters={filters}\n conditionStore={conditionStore}\n orientation='vertical'\n fields={fields}\n />\n </Modal>\n );\n};\n\nexport const PromotedFilters: ForwardRefForwardPropsComponent<PromotedFiltersProps> = forwardRef(\n function PromotedFilters(\n {\n filters,\n condition,\n onChange,\n orientation = 'horizontal',\n fields,\n handle\n }: PropsWithoutRef<PromotedFiltersProps>,\n ref: PromotedFiltersProps['ref']\n ) {\n const t = useI18n();\n\n const promotedFiltersRef = useRef<HTMLDivElement>(null);\n const isSmallOrAbove = useBreakpoint('sm', { breakpointRef: promotedFiltersRef });\n\n const { create } = useModalManager();\n const modalMethods = useRef<ModalMethods<FilterModalProps>>();\n\n const conditionStore = useSimpleStoreInstance({});\n\n const prepareConditionForStore = useCallback(() => {\n return condition\n ? splitConditionForBuilder(condition).rows.reduce(\n (\n result: { [key: string]: (LeafCondition & { filterId?: string }) | undefined },\n item: ConditionRow & { filterId?: string }\n ) => {\n const { id, label, ...leaf } = item;\n result[leaf.filterId ?? leaf.lhs.field] = leaf;\n return result;\n },\n {}\n )\n : {};\n }, [condition]);\n\n useEffect(() => {\n conditionStore.setStore(prepareConditionForStore());\n }, [prepareConditionForStore]);\n\n const selectedCount = Object.values(conditionStore.getStore()).length;\n\n useImperativeHandle(\n handle,\n () => ({ getCondition: () => generateCondition(conditionStore.getStore()) }),\n []\n );\n\n const onApply = useCallback(() => {\n const storeValue = generateCondition(conditionStore.getStore());\n if (JSON.stringify(condition) !== JSON.stringify(storeValue)) onChange(storeValue);\n }, [onChange, prepareConditionForStore]);\n\n const onClear = useCallback(() => {\n if (condition) {\n conditionStore.setStore({});\n onChange();\n }\n }, [onChange, prepareConditionForStore]);\n\n const onCancel = useCallback(() => {\n conditionStore.setStore(prepareConditionForStore());\n }, [prepareConditionForStore]);\n\n useEffect(() => {\n modalMethods.current?.update({\n filters,\n conditionStore,\n fields\n });\n }, [filters, condition, fields]);\n\n const openFiltersModal = () => {\n modalMethods.current = create(FilterModal, {\n filters,\n conditionStore,\n fields,\n onApply,\n onCancel\n });\n };\n\n return (\n <Flex\n as={StyledPromotedFilters}\n container={{\n alignItems: orientation === 'horizontal' && isSmallOrAbove ? 'start' : undefined,\n justify: 'between',\n direction: !isSmallOrAbove || orientation === 'horizontal' ? 'row' : 'column',\n pad: 2,\n gap: 2\n }}\n ref={promotedFiltersRef}\n >\n {isSmallOrAbove ? (\n <>\n {orientation === 'vertical' && (\n <Flex\n container={{\n justify: 'between',\n alignItems: 'center',\n pad: [0, 0, 1, 0]\n }}\n >\n <StyledTextWithEllipsis variant='h3'>{t('filters')}</StyledTextWithEllipsis>\n <div>\n <Button onClick={onClear}>{t('reset')}</Button>\n <Button onClick={onApply}>{t('apply')}</Button>\n </div>\n </Flex>\n )}\n\n <PromotedFiltersContent\n filters={filters}\n conditionStore={conditionStore}\n fields={fields}\n orientation={orientation}\n ref={ref}\n onApply={onApply}\n />\n\n {orientation === 'horizontal' && (\n <Flex container>\n <StyledPromotedFiltersButton onClick={onClear}>\n {t('reset')}\n </StyledPromotedFiltersButton>\n <StyledPromotedFiltersButton onClick={onApply}>\n {t('apply')}\n </StyledPromotedFiltersButton>\n </Flex>\n )}\n </>\n ) : (\n <>\n <Button type='button' variant='text' onClick={openFiltersModal}>\n <Flex container={{ alignItems: 'center', gap: 0.5 }} forwardedAs='span'>\n <Icon name='filter' />\n <span>\n {t('filters')}\n {!!selectedCount && `\\u00a0(${selectedCount})`}\n </span>\n </Flex>\n </Button>\n <Button onClick={onClear}>{t('reset')}</Button>\n </>\n )}\n </Flex>\n );\n }\n);\n\nexport default PromotedFilters;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const StyledPromotedFilters: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
2
|
-
export declare const StyledPromotedFiltersButton: import("styled-components").StyledComponent<import("
|
|
3
|
-
export declare const StyledTextWithEllipsis: import("styled-components").StyledComponent<import("
|
|
2
|
+
export declare const StyledPromotedFiltersButton: import("styled-components").StyledComponent<import("@pega/cosmos-react-core").ForwardRefForwardPropsComponent<import("@pega/cosmos-react-core").ButtonProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
3
|
+
export declare const StyledTextWithEllipsis: import("styled-components").StyledComponent<import("@pega/cosmos-react-core").ForwardRefForwardPropsComponent<import("@pega/cosmos-react-core").TextProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
4
4
|
//# sourceMappingURL=PromotedFilters.styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromotedFilters.styles.d.ts","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.styles.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,qBAAqB,yGAgBhC,CAAC;AAIH,eAAO,MAAM,2BAA2B,
|
|
1
|
+
{"version":3,"file":"PromotedFilters.styles.d.ts","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.styles.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,qBAAqB,yGAgBhC,CAAC;AAIH,eAAO,MAAM,2BAA2B,oNAOvC,CAAC;AAIF,eAAO,MAAM,sBAAsB,kNAIlC,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { StyledModalChildrenWrap } from '@pega/cosmos-react-core/lib/components/
|
|
|
4
4
|
import { StyledSelectInput } from '@pega/cosmos-react-core/lib/components/ComboBox/ComboBox.styles';
|
|
5
5
|
export const StyledPromotedFilters = styled.div(({ theme }) => {
|
|
6
6
|
return css `
|
|
7
|
-
border-radius:
|
|
7
|
+
border-radius: var(--border-radius, ${theme.components.card['border-radius']});
|
|
8
8
|
background-color: ${theme.base.palette['secondary-background']};
|
|
9
9
|
padding-block: ${theme.base.spacing};
|
|
10
10
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromotedFilters.styles.js","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2DAA2D,CAAC;AACpG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iEAAiE,CAAC;AAEpG,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC5D,OAAO,GAAG,CAAA;
|
|
1
|
+
{"version":3,"file":"PromotedFilters.styles.js","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2DAA2D,CAAC;AACpG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iEAAiE,CAAC;AAEpG,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC5D,OAAO,GAAG,CAAA;0CAC8B,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC;wBACxD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC;qBAC7C,KAAK,CAAC,IAAI,CAAC,OAAO;;MAEjC,iBAAiB;wBACC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC;;;;YAInF,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,YAAY,CAAC;;;;GAIjF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,qBAAqB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEtD,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;;;;IAIrD,uBAAuB;;;CAG1B,CAAC;AAEF,2BAA2B,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE5D,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;;;CAIjD,CAAC;AAEF,sBAAsB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp, Button, Text } from '@pega/cosmos-react-core';\nimport { StyledModalChildrenWrap } from '@pega/cosmos-react-core/lib/components/Modal/Modal.styles';\nimport { StyledSelectInput } from '@pega/cosmos-react-core/lib/components/ComboBox/ComboBox.styles';\n\nexport const StyledPromotedFilters = styled.div(({ theme }) => {\n return css`\n border-radius: var(--border-radius, ${theme.components.card['border-radius']});\n background-color: ${theme.base.palette['secondary-background']};\n padding-block: ${theme.base.spacing};\n\n ${StyledSelectInput} {\n min-width: calc(${theme.base['content-width'].xs} + ${theme.base['hit-area']['mouse-min']});\n\n @media (pointer: coarse) {\n min-width: calc(\n ${theme.base['content-width'].xs} + ${theme.base['hit-area']['finger-min']}\n );\n }\n }\n `;\n});\n\nStyledPromotedFilters.defaultProps = defaultThemeProp;\n\nexport const StyledPromotedFiltersButton = styled(Button)`\n margin: 1.125rem 0 0.625rem;\n white-space: nowrap;\n\n ${StyledModalChildrenWrap} & {\n margin-top: 0;\n }\n`;\n\nStyledPromotedFiltersButton.defaultProps = defaultThemeProp;\n\nexport const StyledTextWithEllipsis = styled(Text)`\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n`;\n\nStyledTextWithEllipsis.defaultProps = defaultThemeProp;\n"]}
|