@pega/cosmos-react-condition-builder 3.0.0-dev.3.0 → 3.0.0-dev.30.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 +6 -4
- package/lib/components/ConditionBuilder/AtomicCondition.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/AtomicCondition.js +31 -21
- 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 +16 -42
- package/lib/components/ConditionBuilder/ConditionBuilder.js.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.d.ts +5 -0
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.d.ts.map +1 -0
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.js +44 -0
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.js.map +1 -0
- package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts +41 -20
- package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.types.js.map +1 -1
- package/lib/components/ConditionBuilder/FieldCondition.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/FieldCondition.js +12 -12
- package/lib/components/ConditionBuilder/FieldCondition.js.map +1 -1
- package/lib/components/ConditionBuilder/FieldCondition.types.d.ts +11 -4
- package/lib/components/ConditionBuilder/FieldCondition.types.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/FieldCondition.types.js.map +1 -1
- package/lib/components/ConditionBuilder/HelpButton.js +1 -1
- package/lib/components/ConditionBuilder/HelpButton.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.js +1 -1
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.js +14 -21
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.js +5 -2
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.js +1 -1
- package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.d.ts +5 -3
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.js +50 -16
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.js +8 -8
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.js +1 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.d.ts +38 -0
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.d.ts.map +1 -0
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.js +133 -0
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.js.map +1 -0
- package/lib/components/ConditionBuilder/RhsControls/index.d.ts +5 -2
- package/lib/components/ConditionBuilder/RhsControls/index.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/index.js +91 -30
- package/lib/components/ConditionBuilder/RhsControls/index.js.map +1 -1
- package/lib/components/ConditionBuilder/core/comparators.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/comparators.js +4 -0
- 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 +10 -3
- package/lib/components/ConditionBuilder/core/evaluator.js.map +1 -1
- package/lib/components/ConditionBuilder/core/formatter.d.ts +1 -0
- package/lib/components/ConditionBuilder/core/formatter.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/formatter.js +84 -38
- package/lib/components/ConditionBuilder/core/formatter.js.map +1 -1
- package/lib/components/ConditionBuilder/core/transformer.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/transformer.js +37 -2
- package/lib/components/ConditionBuilder/core/transformer.js.map +1 -1
- package/lib/components/ConditionBuilder/core/types.d.ts +2 -2
- package/lib/components/ConditionBuilder/core/types.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/types.js.map +1 -1
- package/lib/components/ConditionBuilder/core/utils.d.ts +5 -1
- package/lib/components/ConditionBuilder/core/utils.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/utils.js +18 -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 +6 -0
- package/lib/components/ConditionInput/ConditionInput.d.ts.map +1 -0
- package/lib/components/ConditionInput/ConditionInput.js +215 -0
- package/lib/components/ConditionInput/ConditionInput.js.map +1 -0
- package/lib/components/ConditionInput/ConditionInput.styles.d.ts +5 -0
- package/lib/components/ConditionInput/ConditionInput.styles.d.ts.map +1 -0
- package/lib/components/ConditionInput/ConditionInput.styles.js +27 -0
- package/lib/components/ConditionInput/ConditionInput.styles.js.map +1 -0
- package/lib/components/ConditionInput/ConditionInput.types.d.ts +29 -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/ConditionInput/utils.d.ts +13 -0
- package/lib/components/ConditionInput/utils.d.ts.map +1 -0
- package/lib/components/ConditionInput/utils.js +56 -0
- package/lib/components/ConditionInput/utils.js.map +1 -0
- package/lib/components/PromotedFilters/ConditionSelector.d.ts +31 -0
- package/lib/components/PromotedFilters/ConditionSelector.d.ts.map +1 -0
- package/lib/components/PromotedFilters/ConditionSelector.js +72 -0
- package/lib/components/PromotedFilters/ConditionSelector.js.map +1 -0
- package/lib/components/PromotedFilters/PromotedFilters.d.ts +11 -0
- package/lib/components/PromotedFilters/PromotedFilters.d.ts.map +1 -0
- package/lib/components/PromotedFilters/PromotedFilters.js +118 -0
- package/lib/components/PromotedFilters/PromotedFilters.js.map +1 -0
- package/lib/components/PromotedFilters/PromotedFilters.styles.d.ts +4 -0
- package/lib/components/PromotedFilters/PromotedFilters.styles.d.ts.map +1 -0
- package/lib/components/PromotedFilters/PromotedFilters.styles.js +26 -0
- package/lib/components/PromotedFilters/PromotedFilters.styles.js.map +1 -0
- package/lib/components/PromotedFilters/PromotedFilters.types.d.ts +31 -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 +18 -12
- package/lib/components/ConditionBuilder/RhsControls/MultiValueSelector.d.ts +0 -16
- package/lib/components/ConditionBuilder/RhsControls/MultiValueSelector.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/MultiValueSelector.js +0 -43
- package/lib/components/ConditionBuilder/RhsControls/MultiValueSelector.js.map +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Comparator, FieldType } from '../ConditionBuilder/core/types';
|
|
2
|
+
import type { ConditionFieldType } from './ConditionInput.types';
|
|
3
|
+
export declare const defaultComparators: Record<ConditionFieldType, Comparator>;
|
|
4
|
+
export declare const basicFieldMap: Record<ConditionFieldType, FieldType>;
|
|
5
|
+
export declare const compareValues: (value1: string | string[] | undefined, value2: string | string[] | undefined) => boolean;
|
|
6
|
+
export declare const compareRangeValues: (value1: {
|
|
7
|
+
start: string | number | undefined;
|
|
8
|
+
end: string | number | undefined;
|
|
9
|
+
} | undefined, value2: {
|
|
10
|
+
start: string | number | undefined;
|
|
11
|
+
end: string | number | undefined;
|
|
12
|
+
} | undefined) => boolean;
|
|
13
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionInput/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,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,aAAa,WAChB,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,UAC7B,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,YAiBtC,CAAC;AAEF,eAAO,MAAM,kBAAkB,WACrB;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"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export const defaultComparators = {
|
|
2
|
+
TEXT: 'CONTAINS',
|
|
3
|
+
EMAIL: 'CONTAINS',
|
|
4
|
+
URL: 'CONTAINS',
|
|
5
|
+
PHONE: 'CONTAINS',
|
|
6
|
+
INTEGER: 'BTW',
|
|
7
|
+
DECIMAL: 'BTW',
|
|
8
|
+
PERCENTAGE: 'BTW',
|
|
9
|
+
CURRENCY: 'BTW',
|
|
10
|
+
BOOLEAN: 'IS_TRUE',
|
|
11
|
+
DATE_ONLY: 'BTW',
|
|
12
|
+
TIME_ONLY: 'BTW',
|
|
13
|
+
DATE_TIME: 'BTW',
|
|
14
|
+
PICKLIST: 'IN'
|
|
15
|
+
};
|
|
16
|
+
export const basicFieldMap = {
|
|
17
|
+
EMAIL: 'TEXT',
|
|
18
|
+
URL: 'TEXT',
|
|
19
|
+
PHONE: 'TEXT',
|
|
20
|
+
INTEGER: 'NUMBER',
|
|
21
|
+
DECIMAL: 'NUMBER',
|
|
22
|
+
PERCENTAGE: 'NUMBER',
|
|
23
|
+
CURRENCY: 'NUMBER',
|
|
24
|
+
TEXT: 'TEXT',
|
|
25
|
+
BOOLEAN: 'BOOLEAN',
|
|
26
|
+
DATE_ONLY: 'DATE_ONLY',
|
|
27
|
+
TIME_ONLY: 'TIME_ONLY',
|
|
28
|
+
DATE_TIME: 'DATE_TIME',
|
|
29
|
+
PICKLIST: 'TEXT'
|
|
30
|
+
};
|
|
31
|
+
export const compareValues = (value1, value2) => {
|
|
32
|
+
// both values are undefined
|
|
33
|
+
if (!value1 && !value2)
|
|
34
|
+
return true;
|
|
35
|
+
// only one value is undefined
|
|
36
|
+
if (!value1 || !value2)
|
|
37
|
+
return false;
|
|
38
|
+
// for strings compare only value
|
|
39
|
+
if (typeof value1 === 'string') {
|
|
40
|
+
return value1 === value2;
|
|
41
|
+
}
|
|
42
|
+
// for arrays compare length and every value
|
|
43
|
+
if (value1.length !== value2.length)
|
|
44
|
+
return false;
|
|
45
|
+
return value1.every((value, index) => value === value2[index]);
|
|
46
|
+
};
|
|
47
|
+
export const compareRangeValues = (value1, value2) => {
|
|
48
|
+
// both values are undefined
|
|
49
|
+
if (!value1 && !value2)
|
|
50
|
+
return true;
|
|
51
|
+
// only one value is undefined
|
|
52
|
+
if (!value1 || !value2)
|
|
53
|
+
return false;
|
|
54
|
+
return value1.start === value2.start && value1.end === value2.end;
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/ConditionInput/utils.ts"],"names":[],"mappings":"AAIA,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,QAAQ;IACjB,OAAO,EAAE,QAAQ;IACjB,UAAU,EAAE,QAAQ;IACpB,QAAQ,EAAE,QAAQ;IAClB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,MAAM;CACR,CAAC;AAEX,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,MAAqC,EACrC,MAAqC,EACrC,EAAE;IACF,4BAA4B;IAC5B,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEpC,8BAA8B;IAC9B,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAErC,iCAAiC;IACjC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,OAAO,MAAM,KAAK,MAAM,CAAC;KAC1B;IAED,4CAA4C;IAC5C,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAElD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACjE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,MAA4F,EAC5F,MAA4F,EAC5F,EAAE;IACF,4BAA4B;IAC5B,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEpC,8BAA8B;IAC9B,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAErC,OAAO,MAAM,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC;AACpE,CAAC,CAAC","sourcesContent":["import type { Comparator, FieldType } from '../ConditionBuilder/core/types';\n\nimport type { 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: 'NUMBER',\n DECIMAL: 'NUMBER',\n PERCENTAGE: 'NUMBER',\n CURRENCY: 'NUMBER',\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 compareValues = (\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 compareRangeValues = (\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"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { BaseProps, NoChildrenProp, ComboBoxProps, ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import { AtomicConditionProps } from '../ConditionBuilder/AtomicCondition';
|
|
4
|
+
import { LeafCondition } from '../ConditionBuilder';
|
|
5
|
+
interface ConditionSelectorProps extends BaseProps, NoChildrenProp {
|
|
6
|
+
/** Callback for onChange */
|
|
7
|
+
onChange: (condition?: LeafCondition) => void;
|
|
8
|
+
/** Callback for clear */
|
|
9
|
+
onClear?: () => void;
|
|
10
|
+
/** Used to indicate any errors on the control */
|
|
11
|
+
status?: 'error';
|
|
12
|
+
/** Custom label for input. Makes label visible if provided. */
|
|
13
|
+
label?: ComboBoxProps['label'];
|
|
14
|
+
/** Visually hides the label region. */
|
|
15
|
+
labelHidden?: ComboBoxProps['labelHidden'];
|
|
16
|
+
/** Guidance text that apppears below the input. */
|
|
17
|
+
info?: ComboBoxProps['info'];
|
|
18
|
+
/** Definition of the field the condition is created for. */
|
|
19
|
+
fields: AtomicConditionProps['fields'];
|
|
20
|
+
/** List of possible predefined Conditions */
|
|
21
|
+
conditions: {
|
|
22
|
+
id: string;
|
|
23
|
+
value: LeafCondition;
|
|
24
|
+
label?: string;
|
|
25
|
+
}[];
|
|
26
|
+
/** Currently selected condition. */
|
|
27
|
+
condition?: LeafCondition;
|
|
28
|
+
}
|
|
29
|
+
declare const ConditionSelector: FunctionComponent<ConditionSelectorProps & ForwardProps>;
|
|
30
|
+
export default ConditionSelector;
|
|
31
|
+
//# sourceMappingURL=ConditionSelector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConditionSelector.d.ts","sourceRoot":"","sources":["../../../src/components/PromotedFilters/ConditionSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmB,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,EAEL,SAAS,EAET,cAAc,EACd,aAAa,EAKb,YAAY,EAGb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAE3E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,UAAU,sBAAuB,SAAQ,SAAS,EAAE,cAAc;IAChE,4BAA4B;IAC5B,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,yBAAyB;IACzB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,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;AAmCD,QAAA,MAAM,iBAAiB,EAAE,iBAAiB,CAAC,sBAAsB,GAAG,YAAY,CAkF/E,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useRef } from 'react';
|
|
3
|
+
import { useI18n, ComboBox, Button, Icon, useConfiguration, menuHelpers, hasProp } from '@pega/cosmos-react-core';
|
|
4
|
+
import formatCondition from '../ConditionBuilder/core/formatter';
|
|
5
|
+
const equal = (c1, c2) => {
|
|
6
|
+
if (c1.comparator !== c2.comparator)
|
|
7
|
+
return false;
|
|
8
|
+
if (c1.rhs && c2.rhs) {
|
|
9
|
+
if (hasProp(c1.rhs, 'field') && hasProp(c2.rhs, 'field'))
|
|
10
|
+
return c1.rhs.field === c2.rhs.field;
|
|
11
|
+
if (hasProp(c1.rhs, 'dateFunction') && hasProp(c2.rhs, 'dateFunction')) {
|
|
12
|
+
return c1.rhs.dateFunction === c2.rhs.dateFunction && c1.rhs.value === c2.rhs.value;
|
|
13
|
+
}
|
|
14
|
+
if (hasProp(c1.rhs, 'value') && hasProp(c2.rhs, 'value'))
|
|
15
|
+
return c1.rhs.value === c2.rhs.value;
|
|
16
|
+
if (hasProp(c1.rhs, 'values') && hasProp(c2.rhs, 'values')) {
|
|
17
|
+
const rhs1 = c1.rhs;
|
|
18
|
+
const rhs2 = c2.rhs;
|
|
19
|
+
// due to https://github.com/microsoft/TypeScript/issues/44373
|
|
20
|
+
return (rhs1.values.length === rhs2.values.length &&
|
|
21
|
+
rhs1.values.every((v, i) => v === rhs2.values[i]));
|
|
22
|
+
}
|
|
23
|
+
if (hasProp(c1.rhs, 'parameterId') && hasProp(c2.rhs, 'parameterId')) {
|
|
24
|
+
return c1.rhs.parameterId === c2.rhs.parameterId;
|
|
25
|
+
}
|
|
26
|
+
if (hasProp(c1.rhs, 'relativeDate') && hasProp(c2.rhs, 'relativeDate')) {
|
|
27
|
+
return (c1.rhs.relativeDate.datePart === c2.rhs.relativeDate.datePart &&
|
|
28
|
+
c1.rhs.relativeDate.interval === c2.rhs.relativeDate.interval &&
|
|
29
|
+
c1.rhs.relativeDate.timePeriod === c2.rhs.relativeDate.timePeriod);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return c1.rhs === c2.rhs;
|
|
33
|
+
};
|
|
34
|
+
const ConditionSelector = ({ onChange, onClear, status, label, info, fields, labelHidden, conditions, condition, ...restProps }) => {
|
|
35
|
+
const t = useI18n();
|
|
36
|
+
const { locale } = useConfiguration();
|
|
37
|
+
const inputRef = useRef(null);
|
|
38
|
+
const itemsToRender = useMemo(() => {
|
|
39
|
+
return conditions.map(({ id, label: conditionLabel, value }) => {
|
|
40
|
+
return {
|
|
41
|
+
id,
|
|
42
|
+
primary: conditionLabel ??
|
|
43
|
+
formatCondition({ condition: value }, fields, t, {
|
|
44
|
+
locale,
|
|
45
|
+
omitLhs: true
|
|
46
|
+
}),
|
|
47
|
+
selected: !!value && !!condition && equal(value, condition)
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
}, [conditions, condition]);
|
|
51
|
+
const selected = useMemo(() => menuHelpers.getSelected(itemsToRender)[0], [itemsToRender]);
|
|
52
|
+
return (_jsx(ComboBox, { ...restProps, ref: inputRef, mode: 'single-select', label: label ?? t('condition_builder_possible_values_label'), labelHidden: labelHidden, placeholder: t('all'), selected: selected
|
|
53
|
+
? {
|
|
54
|
+
items: {
|
|
55
|
+
id: selected.id,
|
|
56
|
+
text: selected.primary
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
: undefined, menu: {
|
|
60
|
+
items: itemsToRender,
|
|
61
|
+
onItemClick: (id) => onChange(conditions.find(cnd => cnd.id === id)?.value)
|
|
62
|
+
}, status: status, info: status === 'error' ? t('condition_builder_empty_selection_error_text') : info, actions: onClear &&
|
|
63
|
+
condition !== undefined && (_jsx(Button, { icon: true, variant: 'simple', label: t('clear'), onClick: () => {
|
|
64
|
+
onClear();
|
|
65
|
+
if (inputRef.current) {
|
|
66
|
+
const inputEl = inputRef.current.querySelector('input');
|
|
67
|
+
inputEl?.focus();
|
|
68
|
+
}
|
|
69
|
+
}, children: _jsx(Icon, { name: 'times' }) })) }));
|
|
70
|
+
};
|
|
71
|
+
export default ConditionSelector;
|
|
72
|
+
//# sourceMappingURL=ConditionSelector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConditionSelector.js","sourceRoot":"","sources":["../../../src/components/PromotedFilters/ConditionSelector.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAqB,MAAM,OAAO,CAAC;AAE3D,OAAO,EACL,OAAO,EAEP,QAAQ,EAGR,MAAM,EACN,IAAI,EACJ,gBAAgB,EAGhB,WAAW,EACX,OAAO,EACR,MAAM,yBAAyB,CAAC;AAGjC,OAAO,eAAe,MA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EAAE,KAAK,CAAC;SACzD,EACD,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,8CAA8C,CAAC,CAAC,CAAC,CAAC,IAAI,EACnF,OAAO,EACL,OAAO;YACP,SAAS,KAAK,SAAS,IAAI,CACzB,KAAC,MAAM,IACL,IAAI,QACJ,OAAO,EAAC,QAAQ,EAChB,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,EACjB,OAAO,EAAE,GAAG,EAAE;gBACZ,OAAO,EAAE,CAAC;gBACV,IAAI,QAAQ,CAAC,OAAO,EAAE;oBACpB,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;oBACxD,OAAO,EAAE,KAAK,EAAE,CAAC;iBAClB;YACH,CAAC,YAED,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACd,CACV,GAEH,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import { useMemo, useRef, FunctionComponent } from 'react';\n\nimport {\n useI18n,\n BaseProps,\n ComboBox,\n NoChildrenProp,\n ComboBoxProps,\n Button,\n Icon,\n useConfiguration,\n MenuItemProps,\n ForwardProps,\n menuHelpers,\n hasProp\n} from '@pega/cosmos-react-core';\n\nimport { AtomicConditionProps } from '../ConditionBuilder/AtomicCondition';\nimport formatCondition from '../ConditionBuilder/core/formatter';\nimport { LeafCondition } from '../ConditionBuilder';\n\ninterface ConditionSelectorProps extends BaseProps, NoChildrenProp {\n /** Callback for onChange */\n onChange: (condition?: LeafCondition) => void;\n /** Callback for clear */\n onClear?: () => 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 equal = (c1: LeafCondition, c2: LeafCondition) => {\n if (c1.comparator !== c2.comparator) return false;\n\n if (c1.rhs && c2.rhs) {\n if (hasProp(c1.rhs, 'field') && hasProp(c2.rhs, 'field')) return c1.rhs.field === c2.rhs.field;\n if (hasProp(c1.rhs, 'dateFunction') && hasProp(c2.rhs, 'dateFunction')) {\n return c1.rhs.dateFunction === c2.rhs.dateFunction && c1.rhs.value === c2.rhs.value;\n }\n if (hasProp(c1.rhs, 'value') && hasProp(c2.rhs, 'value')) return c1.rhs.value === c2.rhs.value;\n if (hasProp(c1.rhs, 'values') && hasProp(c2.rhs, 'values')) {\n const rhs1 = c1.rhs;\n const rhs2 = c2.rhs;\n // due to https://github.com/microsoft/TypeScript/issues/44373\n return (\n rhs1.values.length === rhs2.values.length &&\n (rhs1.values as unknown[]).every((v, i) => v === rhs2.values[i])\n );\n }\n if (hasProp(c1.rhs, 'parameterId') && hasProp(c2.rhs, 'parameterId')) {\n return c1.rhs.parameterId === c2.rhs.parameterId;\n }\n if (hasProp(c1.rhs, 'relativeDate') && hasProp(c2.rhs, 'relativeDate')) {\n return (\n c1.rhs.relativeDate.datePart === c2.rhs.relativeDate.datePart &&\n c1.rhs.relativeDate.interval === c2.rhs.relativeDate.interval &&\n c1.rhs.relativeDate.timePeriod === c2.rhs.relativeDate.timePeriod\n );\n }\n }\n\n return c1.rhs === c2.rhs;\n};\n\nconst ConditionSelector: FunctionComponent<ConditionSelectorProps & ForwardProps> = ({\n onChange,\n onClear,\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 return 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 && equal(value, condition)\n };\n });\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 placeholder={t('all')}\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 actions={\n onClear &&\n condition !== undefined && (\n <Button\n icon\n variant='simple'\n label={t('clear')}\n onClick={() => {\n onClear();\n if (inputRef.current) {\n const inputEl = inputRef.current.querySelector('input');\n inputEl?.focus();\n }\n }}\n >\n <Icon name='times' />\n </Button>\n )\n }\n />\n );\n};\n\nexport default ConditionSelector;\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import { Condition } from '../ConditionBuilder/ConditionBuilder.types';
|
|
4
|
+
import { PromotedFiltersProps } from './PromotedFilters.types';
|
|
5
|
+
export interface FilterModalProps extends Pick<PromotedFiltersProps, 'filters' | 'condition'> {
|
|
6
|
+
/** Callback fired on apply of any of the filters */
|
|
7
|
+
onApply?: (condition: Condition | undefined) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const PromotedFilters: FunctionComponent<PromotedFiltersProps & ForwardProps>;
|
|
10
|
+
export default PromotedFilters;
|
|
11
|
+
//# 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,EAEL,iBAAiB,EAMlB,MAAM,OAAO,CAAC;AAEf,OAAO,EAGL,YAAY,EAQb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAiB,MAAM,4CAA4C,CAAC;AAOtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAO/D,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,oBAAoB,EAAE,SAAS,GAAG,WAAW,CAAC;IAC3F,oDAAoD;IACpD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,KAAK,IAAI,CAAC;CACtD;AA+JD,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAAC,oBAAoB,GAAG,YAAY,CAkHlF,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Button, Flex, Icon, Modal, useModalManager, useBreakpoint, useI18n, useModalContext } from '@pega/cosmos-react-core';
|
|
4
|
+
import { splitConditionForBuilder } from '../ConditionBuilder/core/utils';
|
|
5
|
+
import ConditionInput from '../ConditionInput';
|
|
6
|
+
import { StyledFieldGroup } from '../ConditionInput/ConditionInput.styles';
|
|
7
|
+
import { basicFieldMap } from '../ConditionInput/utils';
|
|
8
|
+
import ConditionSelector from './ConditionSelector';
|
|
9
|
+
import { StyledPromotedFilters, StyledClearAllButton, StyledTextWithEllipsis } from './PromotedFilters.styles';
|
|
10
|
+
const PromotedFiltersContent = forwardRef(({ filters, condition, onChange, orientation: orientationProp = 'horizontal' }, ref) => {
|
|
11
|
+
const t = useI18n();
|
|
12
|
+
const isSmallOrAbove = useBreakpoint('sm');
|
|
13
|
+
const orientation = isSmallOrAbove && orientationProp === 'horizontal' ? 'horizontal' : 'vertical';
|
|
14
|
+
// map of Conditions indexed by field name
|
|
15
|
+
const conditionsMap = condition
|
|
16
|
+
? splitConditionForBuilder(condition).rows.reduce((result, item) => {
|
|
17
|
+
const { id, label, ...leaf } = item;
|
|
18
|
+
result[item.lhs.field] = leaf;
|
|
19
|
+
return result;
|
|
20
|
+
}, {})
|
|
21
|
+
: {};
|
|
22
|
+
const createUpdatedCondition = (key, newCondition) => {
|
|
23
|
+
if (newCondition) {
|
|
24
|
+
conditionsMap[key] = newCondition;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
delete conditionsMap[key];
|
|
28
|
+
}
|
|
29
|
+
return Object.values(conditionsMap).length === 0
|
|
30
|
+
? undefined
|
|
31
|
+
: {
|
|
32
|
+
AND: Object.values(conditionsMap).map(c => {
|
|
33
|
+
return { condition: c };
|
|
34
|
+
})
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
return (_jsx(Flex, { container: {
|
|
38
|
+
gap: 2,
|
|
39
|
+
direction: orientation === 'vertical' ? 'column' : 'row',
|
|
40
|
+
wrap: 'wrap'
|
|
41
|
+
}, ref: ref, children: filters.map(({ field, mode, label, predefinedConditions }) => {
|
|
42
|
+
if (mode !== 'predefined')
|
|
43
|
+
return (_jsx(ConditionInput, { field: field, mode: mode, label: label ?? field.name, condition: conditionsMap[field.name], flat: orientation === 'vertical', onChange: (newCondition) => {
|
|
44
|
+
onChange(createUpdatedCondition(field.name, newCondition));
|
|
45
|
+
} }, field.name));
|
|
46
|
+
const selector = (_jsx(ConditionSelector, { label: label ?? field.name, labelHidden: orientation === 'vertical', fields: [
|
|
47
|
+
{
|
|
48
|
+
id: field.name,
|
|
49
|
+
type: basicFieldMap[field.type],
|
|
50
|
+
primary: label || field.name
|
|
51
|
+
}
|
|
52
|
+
], condition: conditionsMap[field.name], conditions: predefinedConditions ?? [], onChange: (newCondition) => {
|
|
53
|
+
onChange(createUpdatedCondition(field.name, newCondition));
|
|
54
|
+
}, onClear: orientation === 'horizontal'
|
|
55
|
+
? () => onChange(createUpdatedCondition(field.name, undefined))
|
|
56
|
+
: undefined }, field.name));
|
|
57
|
+
return orientation === 'vertical' ? (_jsx(StyledFieldGroup, { name: label, collapsible: true, actions: [
|
|
58
|
+
{
|
|
59
|
+
id: 'clear',
|
|
60
|
+
text: t('clear'),
|
|
61
|
+
onClick: () => onChange(createUpdatedCondition(field.name, undefined))
|
|
62
|
+
}
|
|
63
|
+
], children: selector }, field.name)) : (selector);
|
|
64
|
+
}) }));
|
|
65
|
+
});
|
|
66
|
+
const FilterModal = ({ filters, condition, onApply }) => {
|
|
67
|
+
const t = useI18n();
|
|
68
|
+
const { dismiss } = useModalContext();
|
|
69
|
+
const [newCondition, setNewCondition] = useState(condition);
|
|
70
|
+
const onApplyClick = useCallback(() => {
|
|
71
|
+
onApply?.(newCondition);
|
|
72
|
+
dismiss();
|
|
73
|
+
}, [newCondition, onApply]);
|
|
74
|
+
const actions = (_jsx(Button, { variant: 'primary', onClick: onApplyClick, children: t('apply') }));
|
|
75
|
+
return (_jsxs(Modal, { heading: t('filters'), actions: actions, stretch: true, children: [_jsx(Flex, { container: { justify: 'end' }, children: _jsx(StyledClearAllButton, { variant: 'simple', onClick: () => {
|
|
76
|
+
setNewCondition(undefined);
|
|
77
|
+
}, children: t('clear_all') }) }), _jsx(PromotedFiltersContent, { filters: filters, condition: newCondition, onChange: setNewCondition, orientation: 'vertical' })] }));
|
|
78
|
+
};
|
|
79
|
+
export const PromotedFilters = forwardRef(({ filters, condition, onChange, orientation = 'horizontal' }, ref) => {
|
|
80
|
+
const t = useI18n();
|
|
81
|
+
const isSmallOrAbove = useBreakpoint('sm');
|
|
82
|
+
const { create } = useModalManager();
|
|
83
|
+
const modalMethods = useRef();
|
|
84
|
+
// map of Conditions indexed by field name
|
|
85
|
+
const conditionsCount = condition ? splitConditionForBuilder(condition).rows.length : undefined;
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
modalMethods.current?.update({
|
|
88
|
+
filters,
|
|
89
|
+
condition
|
|
90
|
+
});
|
|
91
|
+
}, [filters, condition]);
|
|
92
|
+
const openFiltersModal = () => {
|
|
93
|
+
modalMethods.current = create(FilterModal, {
|
|
94
|
+
filters,
|
|
95
|
+
condition,
|
|
96
|
+
onApply: onChange
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
return (_jsx(Flex, { as: StyledPromotedFilters, container: {
|
|
100
|
+
alignItems: orientation === 'horizontal' && isSmallOrAbove ? 'start' : undefined,
|
|
101
|
+
justify: 'between',
|
|
102
|
+
direction: !isSmallOrAbove || orientation === 'horizontal' ? 'row' : 'column',
|
|
103
|
+
pad: 2,
|
|
104
|
+
gap: 2
|
|
105
|
+
}, ref: ref, children: isSmallOrAbove ? (_jsxs(_Fragment, { children: [orientation === 'vertical' && (_jsxs(Flex, { container: {
|
|
106
|
+
justify: 'between',
|
|
107
|
+
alignItems: 'center',
|
|
108
|
+
pad: [0, 0, 1, 0]
|
|
109
|
+
}, children: [_jsx(StyledTextWithEllipsis, { variant: 'h3', children: t('filters') }), _jsx(Button, { variant: 'simple', onClick: () => {
|
|
110
|
+
onChange();
|
|
111
|
+
}, children: t('clear_all') })] })), _jsx(PromotedFiltersContent, { filters: filters, onChange: onChange, condition: condition, orientation: orientation, ref: ref }), orientation === 'horizontal' && (_jsx("div", { children: _jsx(StyledClearAllButton, { variant: 'simple', onClick: () => {
|
|
112
|
+
onChange();
|
|
113
|
+
}, children: t('promoted_filters_clear_all_button_label') }) }))] })) : (_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'), conditionsCount && `\u00a0(${conditionsCount})`] })] }) }), _jsx(Button, { variant: 'simple', onClick: () => {
|
|
114
|
+
onChange();
|
|
115
|
+
}, children: t('clear_all') })] })) }));
|
|
116
|
+
});
|
|
117
|
+
export default PromotedFilters;
|
|
118
|
+
//# sourceMappingURL=PromotedFilters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromotedFilters.js","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAGV,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,MAAM,EACN,IAAI,EAEJ,IAAI,EACJ,KAAK,EAEL,eAAe,EACf,aAAa,EACb,OAAO,EACP,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAOlC,MAAM,sBAAsB,GAA2D,UAAU,CAC/F,CACE,EACE,OAAO,EACP,SAAS,EACT,QAAQ,EACR,WAAW,EAAE,eAAe,GAAG,YAAY,EACL,EACxC,GAAgC,EAChC,EAAE;IACF,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,WAAW,GACf,cAAc,IAAI,eAAe,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC;IAEjF,0CAA0C;IAC1C,MAAM,aAAa,GAAG,SAAS;QAC7B,CAAC,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,MA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EACZ,eAAe,IAAI,UAAU,eAAe,GAAG,IAC3C,IACF,GACA,EACT,KAAC,MAAM,IACL,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE,GAAG,EAAE;wBACZ,QAAQ,EAAE,CAAC;oBACb,CAAC,YAEA,CAAC,CAAC,WAAW,CAAC,GACR,IACR,CACJ,GACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n useCallback,\n useEffect,\n useRef,\n useState\n} from 'react';\n\nimport {\n Button,\n Flex,\n ForwardProps,\n Icon,\n Modal,\n ModalMethods,\n useModalManager,\n useBreakpoint,\n useI18n,\n useModalContext\n} from '@pega/cosmos-react-core';\n\nimport { Condition, LeafCondition } from '../ConditionBuilder/ConditionBuilder.types';\nimport { splitConditionForBuilder } from '../ConditionBuilder/core/utils';\nimport ConditionInput from '../ConditionInput';\nimport { StyledFieldGroup } from '../ConditionInput/ConditionInput.styles';\nimport { basicFieldMap } from '../ConditionInput/utils';\n\nimport ConditionSelector from './ConditionSelector';\nimport { PromotedFiltersProps } from './PromotedFilters.types';\nimport {\n StyledPromotedFilters,\n StyledClearAllButton,\n StyledTextWithEllipsis\n} from './PromotedFilters.styles';\n\nexport interface FilterModalProps extends Pick<PromotedFiltersProps, 'filters' | 'condition'> {\n /** Callback fired on apply of any of the filters */\n onApply?: (condition: Condition | undefined) => void;\n}\n\nconst PromotedFiltersContent: FunctionComponent<PromotedFiltersProps & ForwardProps> = forwardRef(\n (\n {\n filters,\n condition,\n onChange,\n orientation: orientationProp = 'horizontal'\n }: PropsWithoutRef<PromotedFiltersProps>,\n ref: PromotedFiltersProps['ref']\n ) => {\n const t = useI18n();\n const isSmallOrAbove = useBreakpoint('sm');\n const orientation =\n isSmallOrAbove && orientationProp === 'horizontal' ? 'horizontal' : 'vertical';\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 const { id, label, ...leaf } = item;\n result[item.lhs.field] = leaf;\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 Object.values(conditionsMap).length === 0\n ? undefined\n : {\n AND: Object.values(conditionsMap).map(c => {\n return { condition: c } as Condition;\n })\n };\n };\n\n return (\n <Flex\n container={{\n gap: 2,\n direction: orientation === 'vertical' ? 'column' : 'row',\n wrap: 'wrap'\n }}\n ref={ref}\n >\n {filters.map(({ field, mode, label, predefinedConditions }) => {\n if (mode !== 'predefined')\n return (\n <ConditionInput\n key={field.name}\n field={field}\n mode={mode}\n label={label ?? field.name}\n condition={conditionsMap[field.name]}\n flat={orientation === 'vertical'}\n onChange={(newCondition?: LeafCondition) => {\n onChange(createUpdatedCondition(field.name, newCondition));\n }}\n />\n );\n\n const selector = (\n <ConditionSelector\n key={field.name}\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 condition={conditionsMap[field.name]}\n conditions={predefinedConditions ?? []}\n onChange={(newCondition?: LeafCondition) => {\n onChange(createUpdatedCondition(field.name, newCondition));\n }}\n onClear={\n orientation === 'horizontal'\n ? () => onChange(createUpdatedCondition(field.name, undefined))\n : undefined\n }\n />\n );\n\n return orientation === 'vertical' ? (\n <StyledFieldGroup\n key={field.name}\n name={label}\n collapsible\n actions={[\n {\n id: 'clear',\n text: t('clear'),\n onClick: () => onChange(createUpdatedCondition(field.name, undefined))\n }\n ]}\n >\n {selector}\n </StyledFieldGroup>\n ) : (\n selector\n );\n })}\n </Flex>\n );\n }\n);\n\nconst FilterModal = ({ filters, condition, onApply }: FilterModalProps) => {\n const t = useI18n();\n\n const { dismiss } = useModalContext();\n const [newCondition, setNewCondition] = useState<Condition | undefined>(condition);\n\n const onApplyClick = useCallback(() => {\n onApply?.(newCondition);\n dismiss();\n }, [newCondition, onApply]);\n\n const actions = (\n <Button variant='primary' onClick={onApplyClick}>\n {t('apply')}\n </Button>\n );\n\n return (\n <Modal heading={t('filters')} actions={actions} stretch>\n <Flex container={{ justify: 'end' }}>\n <StyledClearAllButton\n variant='simple'\n onClick={() => {\n setNewCondition(undefined);\n }}\n >\n {t('clear_all')}\n </StyledClearAllButton>\n </Flex>\n\n <PromotedFiltersContent\n filters={filters}\n condition={newCondition}\n onChange={setNewCondition}\n orientation='vertical'\n />\n </Modal>\n );\n};\n\nexport const PromotedFilters: FunctionComponent<PromotedFiltersProps & ForwardProps> = forwardRef(\n (\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 isSmallOrAbove = useBreakpoint('sm');\n\n const { create } = useModalManager();\n const modalMethods = useRef<ModalMethods<FilterModalProps>>();\n\n // map of Conditions indexed by field name\n const conditionsCount = condition ? splitConditionForBuilder(condition).rows.length : undefined;\n\n useEffect(() => {\n modalMethods.current?.update({\n filters,\n condition\n });\n }, [filters, condition]);\n\n const openFiltersModal = () => {\n modalMethods.current = create(FilterModal, {\n filters,\n condition,\n onApply: onChange\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={ref}\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 <Button\n variant='simple'\n onClick={() => {\n onChange();\n }}\n >\n {t('clear_all')}\n </Button>\n </Flex>\n )}\n\n <PromotedFiltersContent\n filters={filters}\n onChange={onChange}\n condition={condition}\n orientation={orientation}\n ref={ref}\n />\n\n {orientation === 'horizontal' && (\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 )}\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 {conditionsCount && `\\u00a0(${conditionsCount})`}\n </span>\n </Flex>\n </Button>\n <Button\n variant='simple'\n onClick={() => {\n onChange();\n }}\n >\n {t('clear_all')}\n </Button>\n </>\n )}\n </Flex>\n );\n }\n);\n\nexport default PromotedFilters;\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const StyledPromotedFilters: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
2
|
+
export declare const StyledClearAllButton: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").ButtonProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
3
|
+
export declare const StyledTextWithEllipsis: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").TextProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
4
|
+
//# sourceMappingURL=PromotedFilters.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromotedFilters.styles.d.ts","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB,yGAKhC,CAAC;AAIH,eAAO,MAAM,oBAAoB,qOAOhC,CAAC;AAIF,eAAO,MAAM,sBAAsB,mOAIlC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import { defaultThemeProp, Button, Text } from '@pega/cosmos-react-core';
|
|
3
|
+
import { StyledModalChildrenWrap } from '@pega/cosmos-react-core/lib/components/Modal/Modal.styles';
|
|
4
|
+
export const StyledPromotedFilters = styled.div(({ theme }) => {
|
|
5
|
+
return css `
|
|
6
|
+
border-radius: ${theme.components.card['border-radius']};
|
|
7
|
+
background-color: ${theme.base.palette['secondary-background']};
|
|
8
|
+
`;
|
|
9
|
+
});
|
|
10
|
+
StyledPromotedFilters.defaultProps = defaultThemeProp;
|
|
11
|
+
export const StyledClearAllButton = styled(Button) `
|
|
12
|
+
margin: 1.125rem 0 0.625rem;
|
|
13
|
+
white-space: nowrap;
|
|
14
|
+
|
|
15
|
+
${StyledModalChildrenWrap} & {
|
|
16
|
+
margin-top: 0;
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
StyledClearAllButton.defaultProps = defaultThemeProp;
|
|
20
|
+
export const StyledTextWithEllipsis = styled(Text) `
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
white-space: nowrap;
|
|
23
|
+
text-overflow: ellipsis;
|
|
24
|
+
`;
|
|
25
|
+
StyledTextWithEllipsis.defaultProps = defaultThemeProp;
|
|
26
|
+
//# sourceMappingURL=PromotedFilters.styles.js.map
|
|
@@ -0,0 +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;AAEpG,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC5D,OAAO,GAAG,CAAA;qBACS,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC;wBACnC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC;GAC/D,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,qBAAqB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEtD,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;;;;IAI9C,uBAAuB;;;CAG1B,CAAC;AAEF,oBAAoB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAErD,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';\n\nexport const 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\nexport const StyledClearAllButton = styled(Button)`\n margin: 1.125rem 0 0.625rem;\n white-space: nowrap;\n\n ${StyledModalChildrenWrap} & {\n margin-top: 0;\n }\n`;\n\nStyledClearAllButton.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"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Ref } from 'react';
|
|
2
|
+
import { BaseProps, NoChildrenProp } from '@pega/cosmos-react-core';
|
|
3
|
+
import type { Condition, LeafCondition } from '../ConditionBuilder/ConditionBuilder.types';
|
|
4
|
+
import type { ConditionInputMode, ConditionField } from '../ConditionInput/ConditionInput.types';
|
|
5
|
+
export interface PromotedFilter {
|
|
6
|
+
/** Definition of the field to be filtered. */
|
|
7
|
+
field: ConditionField;
|
|
8
|
+
/** Display mode. */
|
|
9
|
+
mode: ConditionInputMode;
|
|
10
|
+
/** Label for the filter. */
|
|
11
|
+
label?: string;
|
|
12
|
+
/** List of possible predefined Conditions */
|
|
13
|
+
predefinedConditions?: {
|
|
14
|
+
id: string;
|
|
15
|
+
value: LeafCondition;
|
|
16
|
+
label?: string;
|
|
17
|
+
}[];
|
|
18
|
+
}
|
|
19
|
+
export interface PromotedFiltersProps extends BaseProps, NoChildrenProp {
|
|
20
|
+
/** Configuration of filters for every field that has been defined as promoted. */
|
|
21
|
+
filters: PromotedFilter[];
|
|
22
|
+
/** A value representing the current condition state. */
|
|
23
|
+
condition?: Condition;
|
|
24
|
+
/** Orientation mode. The default is horizontal. */
|
|
25
|
+
orientation?: 'vertical' | 'horizontal';
|
|
26
|
+
/** Callback fired on change of any of the filters. */
|
|
27
|
+
onChange: (condition?: Condition) => void;
|
|
28
|
+
/** Ref for the wrapping element. */
|
|
29
|
+
ref?: Ref<HTMLDivElement>;
|
|
30
|
+
}
|
|
31
|
+
//# 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,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEpE,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAC3F,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAEjG,MAAM,WAAW,cAAc;IAC7B,8CAA8C;IAC9C,KAAK,EAAE,cAAc,CAAC;IACtB,oBAAoB;IACpB,IAAI,EAAE,kBAAkB,CAAC;IACzB,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,oBAAoB,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,aAAa,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC/E;AAED,MAAM,WAAW,oBAAqB,SAAQ,SAAS,EAAE,cAAc;IACrE,kFAAkF;IAClF,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,wDAAwD;IACxD,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,mDAAmD;IACnD,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACxC,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, NoChildrenProp } from '@pega/cosmos-react-core';\n\nimport type { Condition, LeafCondition } from '../ConditionBuilder/ConditionBuilder.types';\nimport type { ConditionInputMode, ConditionField } from '../ConditionInput/ConditionInput.types';\n\nexport interface PromotedFilter {\n /** Definition of the field to be filtered. */\n field: ConditionField;\n /** Display mode. */\n mode: ConditionInputMode;\n /** Label for the filter. */\n label?: string;\n /** List of possible predefined Conditions */\n predefinedConditions?: { id: string; value: LeafCondition; label?: string }[];\n}\n\nexport interface PromotedFiltersProps extends BaseProps, NoChildrenProp {\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 /** Orientation mode. The default is horizontal. */\n orientation?: 'vertical' | 'horizontal';\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.30.0",
|
|
4
4
|
"author": "Pegasystems",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
|
@@ -16,29 +16,35 @@
|
|
|
16
16
|
"lib"
|
|
17
17
|
],
|
|
18
18
|
"sideEffects": [
|
|
19
|
+
"./src/components/ConditionBuilder/core/extendDayJs.ts",
|
|
19
20
|
"./lib/components/ConditionBuilder/core/extendDayJs.js"
|
|
20
21
|
],
|
|
21
22
|
"scripts": {
|
|
22
23
|
"build": "tsc -b"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@pega/cosmos-react-core": "3.0.0-dev.
|
|
26
|
-
"
|
|
26
|
+
"@pega/cosmos-react-core": "3.0.0-dev.30.0",
|
|
27
|
+
"@types/react": "^16.14.24 || ^17.0.38",
|
|
28
|
+
"@types/react-dom": "^16.9.14 || ^17.0.11",
|
|
29
|
+
"@types/styled-components": "^5.1.7",
|
|
30
|
+
"dayjs": "^1.10.7",
|
|
27
31
|
"polished": "^4.1.0",
|
|
28
32
|
"react": "^16.14.0 || ^17.0.0",
|
|
29
33
|
"react-dom": "^16.14.0 || ^17.0.0",
|
|
30
34
|
"styled-components": "^5.2.0"
|
|
31
35
|
},
|
|
32
36
|
"devDependencies": {
|
|
33
|
-
"@storybook/addon-a11y": "^6.4.
|
|
34
|
-
"@storybook/addon-actions": "^6.4.
|
|
35
|
-
"@storybook/addon-
|
|
36
|
-
"@storybook/addon-
|
|
37
|
-
"@storybook/
|
|
38
|
-
"@storybook/
|
|
39
|
-
"@storybook/
|
|
40
|
-
"@
|
|
37
|
+
"@storybook/addon-a11y": "^6.4.19",
|
|
38
|
+
"@storybook/addon-actions": "^6.4.19",
|
|
39
|
+
"@storybook/addon-storysource": "^6.4.19",
|
|
40
|
+
"@storybook/addon-toolbars": "^6.4.19",
|
|
41
|
+
"@storybook/addons": "^6.4.19",
|
|
42
|
+
"@storybook/react": "^6.4.19",
|
|
43
|
+
"@storybook/theming": "^6.4.19",
|
|
44
|
+
"@testing-library/jest-dom": "^5.16.2",
|
|
45
|
+
"@testing-library/react": "^12.1.3",
|
|
46
|
+
"@testing-library/user-event": "^13.5.0",
|
|
41
47
|
"enzyme": "^3.11.0",
|
|
42
|
-
"typescript": "~4.
|
|
48
|
+
"typescript": "~4.7.2"
|
|
43
49
|
}
|
|
44
50
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react';
|
|
2
|
-
import { BaseProps, ForwardProps, NoChildrenProp } from '@pega/cosmos-react-core';
|
|
3
|
-
interface MultiSelectorProps extends BaseProps, NoChildrenProp {
|
|
4
|
-
/** Previous selection */
|
|
5
|
-
values: string[];
|
|
6
|
-
/** Options for the selector */
|
|
7
|
-
options: string[];
|
|
8
|
-
/** Callback for changes */
|
|
9
|
-
onChange: (selection: string[]) => void;
|
|
10
|
-
/** Used to indicate any errors on the control */
|
|
11
|
-
status?: 'error';
|
|
12
|
-
}
|
|
13
|
-
/** A control for selecting multiple values using checkboxes in an overlay */
|
|
14
|
-
declare const MultiValueSelector: FunctionComponent<MultiSelectorProps & ForwardProps>;
|
|
15
|
-
export default MultiValueSelector;
|
|
16
|
-
//# sourceMappingURL=MultiValueSelector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MultiValueSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/RhsControls/MultiValueSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAqB,MAAM,OAAO,CAAC;AAE7D,OAAO,EAEL,SAAS,EACT,YAAY,EAIZ,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,UAAU,kBAAmB,SAAQ,SAAS,EAAE,cAAc;IAC5D,yBAAyB;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;IAEjB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,2BAA2B;IAC3B,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAExC,iDAAiD;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,6EAA6E;AAC7E,QAAA,MAAM,kBAAkB,EAAE,iBAAiB,CAAC,kBAAkB,GAAG,YAAY,CAgE5E,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|