@pega/cosmos-react-condition-builder 8.0.0-build.3.2 → 8.0.0-build.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 +3 -3
- package/lib/components/ConditionBuilder/AtomicCondition.d.ts.map +1 -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 +8 -6
- 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.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/FieldCondition.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/FieldSelector.js +1 -1
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.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/RhsModeSwitch.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.d.ts +3 -3
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.js +154 -114
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/index.js.map +1 -1
- package/lib/components/ConditionBuilder/core/comparators.js.map +1 -1
- package/lib/components/ConditionBuilder/core/evaluator.js +1 -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/rows-reducer.js.map +1 -1
- package/lib/components/ConditionBuilder/core/transformer.d.ts +1 -1
- package/lib/components/ConditionBuilder/core/transformer.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/transformer.js +71 -25
- package/lib/components/ConditionBuilder/core/transformer.js.map +1 -1
- 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 +8 -4
- 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 +5 -3
- package/lib/components/ConditionInput/ConditionInput.types.d.ts.map +1 -1
- package/lib/components/ConditionInput/ConditionInput.types.js.map +1 -1
- package/lib/components/ConditionInput/utils.d.ts +1 -1
- package/lib/components/ConditionInput/utils.d.ts.map +1 -1
- package/lib/components/ConditionInput/utils.js +5 -2
- package/lib/components/ConditionInput/utils.js.map +1 -1
- package/lib/components/PromotedFilters/ConditionSelector.d.ts +1 -1
- package/lib/components/PromotedFilters/ConditionSelector.d.ts.map +1 -1
- package/lib/components/PromotedFilters/ConditionSelector.js.map +1 -1
- package/lib/components/PromotedFilters/PromotedFilters.d.ts +2 -8
- package/lib/components/PromotedFilters/PromotedFilters.d.ts.map +1 -1
- package/lib/components/PromotedFilters/PromotedFilters.js +100 -69
- 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 +3 -3
- package/lib/components/PromotedFilters/PromotedFilters.styles.js.map +1 -1
- package/lib/components/PromotedFilters/PromotedFilters.types.d.ts +57 -8
- package/lib/components/PromotedFilters/PromotedFilters.types.d.ts.map +1 -1
- package/lib/components/PromotedFilters/PromotedFilters.types.js.map +1 -1
- package/package.json +8 -8
|
@@ -1,50 +1,61 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
-
import { Button, Flex, Icon, Modal, useModalManager, useBreakpoint, useI18n, useModalContext, hasProp } from '@pega/cosmos-react-core';
|
|
2
|
+
import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
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';
|
|
6
6
|
import { StyledVerticalFieldGroup } from '../ConditionInput/ConditionInput.styles';
|
|
7
|
-
import { basicFieldMap } from '../ConditionInput/utils';
|
|
7
|
+
import { basicFieldMap, conditionsEqual } from '../ConditionInput/utils';
|
|
8
8
|
import ConditionSelector from './ConditionSelector';
|
|
9
|
-
import { StyledPromotedFilters,
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
import { StyledPromotedFilters, StyledTextWithEllipsis, StyledPromotedFiltersButton } from './PromotedFilters.styles';
|
|
10
|
+
const isValidNewCondition = (newCondition) => {
|
|
11
|
+
if (!newCondition?.rhs)
|
|
12
|
+
return true;
|
|
13
|
+
if (!hasProp(newCondition.rhs, 'start') && !hasProp(newCondition.rhs, 'end'))
|
|
14
|
+
return true;
|
|
15
|
+
return !Number.isNaN(newCondition.rhs.start) && !Number.isNaN(newCondition.rhs.end);
|
|
16
|
+
};
|
|
17
|
+
const generateCondition = (value) => {
|
|
18
|
+
const storeValues = Object.values(value);
|
|
19
|
+
return storeValues.length === 0
|
|
20
|
+
? undefined
|
|
21
|
+
: {
|
|
22
|
+
AND: storeValues.map(c => ({ condition: c }))
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const withStore = (WrappedComponent) => memo(({ conditionStore, filterId, ...componentProps }) => {
|
|
26
|
+
const [storeValue, setStore] = useSimpleStore(conditionStore, val => val[filterId], conditionsEqual);
|
|
27
|
+
const handleOnChange = (newCondition) => {
|
|
28
|
+
if (!isValidNewCondition(newCondition))
|
|
29
|
+
return;
|
|
24
30
|
if (newCondition) {
|
|
25
|
-
|
|
31
|
+
if (!newCondition.filterId && filterId !== newCondition.lhs?.field)
|
|
32
|
+
newCondition = { ...newCondition, filterId };
|
|
33
|
+
setStore(cur => ({
|
|
34
|
+
...cur,
|
|
35
|
+
[filterId]: newCondition
|
|
36
|
+
}));
|
|
26
37
|
}
|
|
27
38
|
else {
|
|
28
|
-
|
|
39
|
+
setStore(({ ...cur }) => {
|
|
40
|
+
delete cur[filterId];
|
|
41
|
+
return cur;
|
|
42
|
+
});
|
|
29
43
|
}
|
|
30
|
-
return Object.values(conditionsMap).length === 0
|
|
31
|
-
? undefined
|
|
32
|
-
: {
|
|
33
|
-
AND: Object.values(conditionsMap).map(c => {
|
|
34
|
-
return { condition: c };
|
|
35
|
-
})
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
const isValidNewCondition = (newCondition) => {
|
|
39
|
-
if (!newCondition?.rhs)
|
|
40
|
-
return true;
|
|
41
|
-
if (!hasProp(newCondition.rhs, 'start') && !hasProp(newCondition.rhs, 'end'))
|
|
42
|
-
return true;
|
|
43
|
-
return !Number.isNaN(newCondition.rhs.start) && !Number.isNaN(newCondition.rhs.end);
|
|
44
44
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
return (_jsx(WrappedComponent, { condition: storeValue, ...componentProps, onChange: handleOnChange }));
|
|
46
|
+
});
|
|
47
|
+
const ConditionInputWithStore = withStore(ConditionInput);
|
|
48
|
+
const ConditionSelectorWithStore = withStore(ConditionSelector);
|
|
49
|
+
const PromotedFiltersContent = memo(forwardRef(function PromotedFiltersContent({ filters, conditionStore, orientation: orientationProp = 'horizontal', fields }, ref) {
|
|
50
|
+
const t = useI18n();
|
|
51
|
+
const isSmallOrAbove = useBreakpoint('sm');
|
|
52
|
+
const orientation = isSmallOrAbove && orientationProp === 'horizontal' ? 'horizontal' : 'vertical';
|
|
53
|
+
const [collapsed, setCollapsed] = useState(false);
|
|
54
|
+
const onClear = (fieldName) => {
|
|
55
|
+
conditionStore.setStore(cur => {
|
|
56
|
+
delete cur[fieldName];
|
|
57
|
+
return cur;
|
|
58
|
+
});
|
|
48
59
|
};
|
|
49
60
|
return (_jsx(Flex, { container: {
|
|
50
61
|
rowGap: 1,
|
|
@@ -52,59 +63,79 @@ const PromotedFiltersContent = forwardRef(function PromotedFiltersContent({ filt
|
|
|
52
63
|
direction: orientation === 'vertical' ? 'column' : 'row',
|
|
53
64
|
wrap: 'wrap',
|
|
54
65
|
alignItems: orientation === 'vertical' ? 'stretch' : 'start'
|
|
55
|
-
}, ref: ref, children: filters.map(({ field, mode, label, predefinedConditions }) => {
|
|
66
|
+
}, ref: ref, children: filters.map(({ id, field, mode, label, predefinedConditions }) => {
|
|
67
|
+
id = id ?? field.name;
|
|
56
68
|
if (mode !== 'predefined')
|
|
57
|
-
return (_jsx(
|
|
58
|
-
const selector = (_jsx(
|
|
69
|
+
return (_jsx(ConditionInputWithStore, { conditionStore: conditionStore, filterId: id, field: field, mode: mode, label: label ?? field.name, flat: orientation === 'vertical', fields: fields }, id));
|
|
70
|
+
const selector = (_jsx(ConditionSelectorWithStore, { conditionStore: conditionStore, filterId: id, label: label ?? field.name, labelHidden: orientation === 'vertical', fields: [
|
|
59
71
|
{
|
|
60
72
|
id: field.name,
|
|
61
73
|
type: basicFieldMap[field.type],
|
|
62
74
|
primary: label || field.name
|
|
63
75
|
}
|
|
64
|
-
],
|
|
65
|
-
|
|
66
|
-
onChange(createUpdatedCondition(field.name, newCondition));
|
|
67
|
-
}, onClear: orientation === 'horizontal'
|
|
68
|
-
? () => onChange(createUpdatedCondition(field.name, undefined))
|
|
69
|
-
: undefined }, field.name));
|
|
70
|
-
return orientation === 'vertical' ? (_jsx(StyledVerticalFieldGroup, { name: label ?? field.name, collapsed: collapsed, onToggleCollapsed: () => setCollapsed(cur => !cur), actions: [
|
|
76
|
+
], conditions: predefinedConditions ?? [], onClear: () => onClear(id) }, id));
|
|
77
|
+
return orientation === 'vertical' ? (_jsx(StyledVerticalFieldGroup, { name: label ?? id, collapsed: collapsed, onToggleCollapsed: () => setCollapsed(cur => !cur), actions: [
|
|
71
78
|
{
|
|
72
79
|
id: 'clear',
|
|
73
80
|
text: t('clear'),
|
|
74
|
-
onClick: () =>
|
|
81
|
+
onClick: () => onClear(id)
|
|
75
82
|
}
|
|
76
|
-
], children: selector },
|
|
83
|
+
], children: selector }, id)) : (selector);
|
|
77
84
|
}) }));
|
|
78
|
-
});
|
|
79
|
-
const FilterModal = ({ filters,
|
|
85
|
+
}));
|
|
86
|
+
const FilterModal = ({ filters, conditionStore, fields, onApply, onCancel }) => {
|
|
80
87
|
const t = useI18n();
|
|
81
|
-
const { dismiss } = useModalContext();
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return (_jsxs(Modal, { heading: t('filters'), actions: actions, stretch: true, children: [_jsx(Flex, { container: { justify: 'end' }, children: _jsx(StyledClearAllButton, { variant: 'simple', onClick: () => setNewCondition(undefined), children: t('clear_all') }) }), _jsx(PromotedFiltersContent, { filters: filters, condition: newCondition, onChange: setNewCondition, orientation: 'vertical' })] }));
|
|
88
|
+
const { dismiss, unmount } = useModalContext();
|
|
89
|
+
const handleApplyClick = () => {
|
|
90
|
+
onApply();
|
|
91
|
+
unmount();
|
|
92
|
+
};
|
|
93
|
+
const actions = (_jsxs(_Fragment, { children: [_jsx(Button, { onClick: dismiss, children: t('cancel') }), _jsx(Button, { onClick: handleApplyClick, children: t('apply') })] }));
|
|
94
|
+
return (_jsx(Modal, { heading: t('filters'), actions: actions, onBeforeClose: onCancel, children: _jsx(PromotedFiltersContent, { filters: filters, conditionStore: conditionStore, orientation: 'vertical', fields: fields }) }));
|
|
89
95
|
};
|
|
90
|
-
export const PromotedFilters = forwardRef(function PromotedFilters({ filters, condition, onChange, orientation = 'horizontal' }, ref) {
|
|
96
|
+
export const PromotedFilters = forwardRef(function PromotedFilters({ filters, condition, onChange, orientation = 'horizontal', fields, handle }, ref) {
|
|
91
97
|
const t = useI18n();
|
|
92
|
-
const
|
|
98
|
+
const promotedFiltersRef = useRef(null);
|
|
99
|
+
const isSmallOrAbove = useBreakpoint('sm', { breakpointRef: promotedFiltersRef });
|
|
93
100
|
const { create } = useModalManager();
|
|
94
101
|
const modalMethods = useRef();
|
|
95
|
-
|
|
96
|
-
const
|
|
102
|
+
const conditionStore = useSimpleStoreInstance({});
|
|
103
|
+
const prepareConditionForStore = useCallback(() => {
|
|
104
|
+
return condition
|
|
105
|
+
? splitConditionForBuilder(condition).rows.reduce((result, item) => {
|
|
106
|
+
const { id, label, ...leaf } = item;
|
|
107
|
+
result[leaf.filterId ?? leaf.lhs.field] = leaf;
|
|
108
|
+
return result;
|
|
109
|
+
}, {})
|
|
110
|
+
: {};
|
|
111
|
+
}, [condition]);
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
conditionStore.setStore(prepareConditionForStore());
|
|
114
|
+
}, [prepareConditionForStore]);
|
|
115
|
+
const selectedCount = Object.values(conditionStore.getStore()).length;
|
|
116
|
+
useImperativeHandle(handle, () => ({ getCondition: () => generateCondition(conditionStore.getStore()) }), []);
|
|
117
|
+
const onApply = useCallback(() => onChange(generateCondition(conditionStore.getStore())), [onChange]);
|
|
118
|
+
const onClear = useCallback(() => {
|
|
119
|
+
conditionStore.setStore({});
|
|
120
|
+
onChange();
|
|
121
|
+
}, [onChange]);
|
|
122
|
+
const onCancel = useCallback(() => {
|
|
123
|
+
conditionStore.setStore(prepareConditionForStore());
|
|
124
|
+
}, [prepareConditionForStore]);
|
|
97
125
|
useEffect(() => {
|
|
98
126
|
modalMethods.current?.update({
|
|
99
127
|
filters,
|
|
100
|
-
|
|
128
|
+
conditionStore,
|
|
129
|
+
fields
|
|
101
130
|
});
|
|
102
|
-
}, [filters, condition]);
|
|
131
|
+
}, [filters, condition, fields]);
|
|
103
132
|
const openFiltersModal = () => {
|
|
104
133
|
modalMethods.current = create(FilterModal, {
|
|
105
134
|
filters,
|
|
106
|
-
|
|
107
|
-
|
|
135
|
+
conditionStore,
|
|
136
|
+
fields,
|
|
137
|
+
onApply,
|
|
138
|
+
onCancel
|
|
108
139
|
});
|
|
109
140
|
};
|
|
110
141
|
return (_jsx(Flex, { as: StyledPromotedFilters, container: {
|
|
@@ -113,11 +144,11 @@ export const PromotedFilters = forwardRef(function PromotedFilters({ filters, co
|
|
|
113
144
|
direction: !isSmallOrAbove || orientation === 'horizontal' ? 'row' : 'column',
|
|
114
145
|
pad: 2,
|
|
115
146
|
gap: 2
|
|
116
|
-
}, ref:
|
|
147
|
+
}, ref: promotedFiltersRef, children: isSmallOrAbove ? (_jsxs(_Fragment, { children: [orientation === 'vertical' && (_jsxs(Flex, { container: {
|
|
117
148
|
justify: 'between',
|
|
118
149
|
alignItems: 'center',
|
|
119
150
|
pad: [0, 0, 1, 0]
|
|
120
|
-
}, children: [_jsx(StyledTextWithEllipsis, { variant: 'h3', children: t('filters') }), _jsx(Button, {
|
|
151
|
+
}, 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 }), 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') })] })) }));
|
|
121
152
|
});
|
|
122
153
|
export default PromotedFilters;
|
|
123
154
|
//# 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,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG7E,OAAO,EACL,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,eAAe,EACf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AQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,GAAG,EAAE,GAAG,GACR,EAED,WAAW,KAAK,YAAY,IAAI,CAC/B,wBACE,KAAC,oBAAoB,IAAC,OAAO,EAAC,QAAQ,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,YAC7D,CAAC,CAAC,yCAAyC,CAAC,GACxB,GACnB,CACP,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,eAAe,IAAI,UAAU,eAAe,GAAG,IAC3C,IACF,GACA,EACT,KAAC,MAAM,IAAC,OAAO,EAAC,QAAQ,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,YAC/C,CAAC,CAAC,WAAW,CAAC,GACR,IACR,CACJ,GACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { forwardRef, 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} from '@pega/cosmos-react-core';\nimport type { ForwardProps, ModalMethods } 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 { StyledVerticalFieldGroup } from '../ConditionInput/ConditionInput.styles';\nimport { basicFieldMap } from '../ConditionInput/utils';\n\nimport ConditionSelector from './ConditionSelector';\nimport type { 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 function PromotedFiltersContent(\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 const [collapsed, setCollapsed] = useState(false);\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 const isValidNewCondition = (newCondition: LeafCondition | undefined): 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\n const handleOnChange = (fieldName: string, newCondition?: LeafCondition) => {\n if (isValidNewCondition(newCondition))\n onChange(createUpdatedCondition(fieldName, newCondition));\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 <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 => handleOnChange(field.name, newCondition)}\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 if (isValidNewCondition(newCondition))\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 <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: () => onChange(createUpdatedCondition(field.name, undefined))\n }\n ]}\n >\n {selector}\n </StyledVerticalFieldGroup>\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 <>\n <Button onClick={dismiss}>{t('cancel')}</Button>\n <Button variant='primary' onClick={onApplyClick}>\n {t('apply')}\n </Button>\n </>\n );\n\n return (\n <Modal heading={t('filters')} actions={actions} stretch>\n <Flex container={{ justify: 'end' }}>\n <StyledClearAllButton variant='simple' onClick={() => setNewCondition(undefined)}>\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 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 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 variant='simple' onClick={() => onChange()}>\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 variant='simple' onClick={() => onChange()}>\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 variant='simple' onClick={() => onChange()}>\n {t('clear_all')}\n </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,OAAO,EACP,eAAe,EACf,OAAO,EACP,cAAc,EACd,sBAAsB,EACvB,MAAM,yBAAyB,CAAC;AASjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAMpD,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,2BAA2B,EAC5B,MAAM,0BAA0B,CAAC;AAElC,MAAM,mBAAmB,GAAG,CAAC,YAAoD,EAAW,EAAE;IAC5F,IAAI,CAAC,YAAY,EAAE,GAAG;QAAE,OAAO,IAAI,CAAC;IACpC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CA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,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};\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 ...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 setStore(cur => ({\n ...cur,\n [filterId]: newCondition\n }));\n } else {\n setStore(({ ...cur }) => {\n delete cur[filterId];\n return cur;\n });\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 }: 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(({ 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 />\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 onClear={() => onClear(id)}\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 actions={[\n {\n id: 'clear',\n text: t('clear'),\n onClick: () => onClear(id)\n }\n ]}\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 () => 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 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 />\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
|
|
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,
|
|
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: ${theme.components.card['border-radius']};
|
|
7
|
+
border-radius: calc(${theme.components.card['border-radius']} * 0.75);
|
|
8
8
|
background-color: ${theme.base.palette['secondary-background']};
|
|
9
9
|
padding-block: ${theme.base.spacing};
|
|
10
10
|
|
|
@@ -20,7 +20,7 @@ export const StyledPromotedFilters = styled.div(({ theme }) => {
|
|
|
20
20
|
`;
|
|
21
21
|
});
|
|
22
22
|
StyledPromotedFilters.defaultProps = defaultThemeProp;
|
|
23
|
-
export const
|
|
23
|
+
export const StyledPromotedFiltersButton = styled(Button) `
|
|
24
24
|
margin: 1.125rem 0 0.625rem;
|
|
25
25
|
white-space: nowrap;
|
|
26
26
|
|
|
@@ -28,7 +28,7 @@ export const StyledClearAllButton = styled(Button) `
|
|
|
28
28
|
margin-top: 0;
|
|
29
29
|
}
|
|
30
30
|
`;
|
|
31
|
-
|
|
31
|
+
StyledPromotedFiltersButton.defaultProps = defaultThemeProp;
|
|
32
32
|
export const StyledTextWithEllipsis = styled(Text) `
|
|
33
33
|
overflow: hidden;
|
|
34
34
|
white-space: nowrap;
|
|
@@ -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;0BACc,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC;wBACxC,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: calc(${theme.components.card['border-radius']} * 0.75);\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"]}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { Ref } from 'react';
|
|
2
|
-
import type { BaseProps,
|
|
3
|
-
import type {
|
|
2
|
+
import type { BaseProps, NoChildrenProp, SimpleStore } from '@pega/cosmos-react-core';
|
|
3
|
+
import type { Field, LeafCondition } from '../ConditionBuilder/ConditionBuilder.types';
|
|
4
4
|
import type { ConditionInputMode, ConditionField } from '../ConditionInput/ConditionInput.types';
|
|
5
5
|
export interface PromotedFilter {
|
|
6
|
+
/** Optional for multiple filters on the same field. */
|
|
7
|
+
id?: string;
|
|
6
8
|
/** Definition of the field to be filtered. */
|
|
7
9
|
field: ConditionField;
|
|
8
10
|
/** Display mode. */
|
|
@@ -16,18 +18,65 @@ export interface PromotedFilter {
|
|
|
16
18
|
label?: string;
|
|
17
19
|
}[];
|
|
18
20
|
}
|
|
21
|
+
export interface HandleValue {
|
|
22
|
+
/** Returns currently visible condition in the PromotedFilters */
|
|
23
|
+
getCondition: () => PromotedFiltersProps['condition'];
|
|
24
|
+
}
|
|
19
25
|
export interface PromotedFiltersProps extends BaseProps, NoChildrenProp {
|
|
20
26
|
/** Configuration of filters for every field that has been defined as promoted. */
|
|
21
27
|
filters: PromotedFilter[];
|
|
22
|
-
/** A value representing the current condition state. */
|
|
23
|
-
condition?:
|
|
24
|
-
|
|
28
|
+
/** A value representing the current condition state. Optional filterId for multiple filters per field support. */
|
|
29
|
+
condition?: {
|
|
30
|
+
AND: {
|
|
31
|
+
condition: LeafCondition & {
|
|
32
|
+
filterId?: string;
|
|
33
|
+
};
|
|
34
|
+
}[];
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Orientation mode.
|
|
38
|
+
* @default 'horizontal'
|
|
39
|
+
*/
|
|
25
40
|
orientation?: 'vertical' | 'horizontal';
|
|
26
|
-
/**
|
|
27
|
-
|
|
41
|
+
/** Metadata (data-model) for the Fields to use in the RHS field-selector */
|
|
42
|
+
fields?: Field[];
|
|
43
|
+
/** Callback fired on apply click. */
|
|
44
|
+
onChange: (condition?: {
|
|
45
|
+
AND: {
|
|
46
|
+
condition: LeafCondition & {
|
|
47
|
+
filterId?: string;
|
|
48
|
+
};
|
|
49
|
+
}[];
|
|
50
|
+
}) => void;
|
|
28
51
|
/** Ref for the wrapping element. */
|
|
29
52
|
ref?: Ref<HTMLDivElement>;
|
|
30
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Imperative handle.
|
|
55
|
+
* Used to fetch the currently visible condition, regardless of the `Apply` click
|
|
56
|
+
*/
|
|
31
57
|
handle?: Ref<HandleValue>;
|
|
32
58
|
}
|
|
59
|
+
export interface PromotedFiltersContentProps extends BaseProps, NoChildrenProp {
|
|
60
|
+
/** Configuration of filters for every field that has been defined as promoted. */
|
|
61
|
+
filters: PromotedFilter[];
|
|
62
|
+
/** A value representing the condition store. */
|
|
63
|
+
conditionStore: SimpleStore<{
|
|
64
|
+
[key: string]: LeafCondition | undefined;
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Orientation mode.
|
|
68
|
+
* @default 'horizontal'
|
|
69
|
+
*/
|
|
70
|
+
orientation?: 'vertical' | 'horizontal';
|
|
71
|
+
/** Metadata (data-model) for the Fields to use in the RHS field-selector */
|
|
72
|
+
fields?: Field[];
|
|
73
|
+
/** Ref for the wrapping element. */
|
|
74
|
+
ref?: Ref<HTMLDivElement>;
|
|
75
|
+
}
|
|
76
|
+
export interface FilterModalProps extends Pick<PromotedFiltersContentProps, 'filters' | 'conditionStore' | 'fields'> {
|
|
77
|
+
/** Callback fired on apply */
|
|
78
|
+
onApply: () => void;
|
|
79
|
+
/** Callback fired on cancel */
|
|
80
|
+
onCancel: () => void;
|
|
81
|
+
}
|
|
33
82
|
//# sourceMappingURL=PromotedFilters.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromotedFilters.types.d.ts","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"PromotedFilters.types.d.ts","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtF,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAEjG,MAAM,WAAW,cAAc;IAC7B,uDAAuD;IACvD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,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,WAAW;IAC1B,iEAAiE;IACjE,YAAY,EAAE,MAAM,oBAAoB,CAAC,WAAW,CAAC,CAAC;C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AgB,GAAG,QAAQ,CAAC;IAClF,8BAA8B;IAC9B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromotedFilters.types.js","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Ref } from 'react';\n\nimport type { BaseProps,
|
|
1
|
+
{"version":3,"file":"PromotedFilters.types.js","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Ref } from 'react';\n\nimport type { BaseProps, NoChildrenProp, SimpleStore } from '@pega/cosmos-react-core';\n\nimport type { Field, LeafCondition } from '../ConditionBuilder/ConditionBuilder.types';\nimport type { ConditionInputMode, ConditionField } from '../ConditionInput/ConditionInput.types';\n\nexport interface PromotedFilter {\n /** Optional for multiple filters on the same field. */\n id?: string;\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 HandleValue {\n /** Returns currently visible condition in the PromotedFilters */\n getCondition: () => PromotedFiltersProps['condition'];\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. Optional filterId for multiple filters per field support. */\n condition?: { AND: { condition: LeafCondition & { filterId?: string } }[] };\n /**\n * Orientation mode.\n * @default 'horizontal'\n */\n orientation?: 'vertical' | 'horizontal';\n /** Metadata (data-model) for the Fields to use in the RHS field-selector */\n fields?: Field[];\n /** Callback fired on apply click. */\n onChange: (condition?: { AND: { condition: LeafCondition & { filterId?: string } }[] }) => void;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n /**\n * Imperative handle.\n * Used to fetch the currently visible condition, regardless of the `Apply` click\n */\n handle?: Ref<HandleValue>;\n}\n\nexport interface PromotedFiltersContentProps extends BaseProps, NoChildrenProp {\n /** Configuration of filters for every field that has been defined as promoted. */\n filters: PromotedFilter[];\n /** A value representing the condition store. */\n conditionStore: SimpleStore<{ [key: string]: LeafCondition | undefined }>;\n /**\n * Orientation mode.\n * @default 'horizontal'\n */\n orientation?: 'vertical' | 'horizontal';\n /** Metadata (data-model) for the Fields to use in the RHS field-selector */\n fields?: Field[];\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nexport interface FilterModalProps\n extends Pick<PromotedFiltersContentProps, 'filters' | 'conditionStore' | 'fields'> {\n /** Callback fired on apply */\n onApply: () => void;\n /** Callback fired on cancel */\n onCancel: () => void;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pega/cosmos-react-condition-builder",
|
|
3
|
-
"version": "8.0.0-build.
|
|
3
|
+
"version": "8.0.0-build.30.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/pegasystems/cosmos-react.git",
|
|
@@ -22,20 +22,20 @@
|
|
|
22
22
|
"build": "tsc -b tsconfig.build.json"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@pega/cosmos-react-core": "8.0.0-build.
|
|
26
|
-
"@types/react": "^17.0.62",
|
|
27
|
-
"@types/react-dom": "^17.0.20",
|
|
25
|
+
"@pega/cosmos-react-core": "8.0.0-build.30.0",
|
|
26
|
+
"@types/react": "^17.0.62 || ^18.3.3",
|
|
27
|
+
"@types/react-dom": "^17.0.20 || ^18.3.0",
|
|
28
28
|
"@types/styled-components": "^5.1.26",
|
|
29
29
|
"dayjs": "^1.11.10",
|
|
30
30
|
"polished": "^4.1.0",
|
|
31
|
-
"react": "^17.0.0",
|
|
32
|
-
"react-dom": "^17.0.0",
|
|
31
|
+
"react": "^17.0.0 || ^18.0.0",
|
|
32
|
+
"react-dom": "^17.0.0 || ^18.0.0",
|
|
33
33
|
"styled-components": "^5.2.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@storybook/react": "~8.2.9",
|
|
37
|
-
"@testing-library/react": "^
|
|
37
|
+
"@testing-library/react": "^16.0.0",
|
|
38
38
|
"@testing-library/user-event": "^14.5.1",
|
|
39
|
-
"typescript": "~5.
|
|
39
|
+
"typescript": "~5.5.4"
|
|
40
40
|
}
|
|
41
41
|
}
|