@pega/cosmos-react-condition-builder 3.0.0-dev.2.1 → 3.0.0-dev.20.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 +27 -20
- 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 +38 -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 +35 -10
- 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.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/index.js +32 -25
- package/lib/components/ConditionBuilder/RhsControls/index.js.map +1 -1
- package/lib/components/ConditionBuilder/core/evaluator.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/evaluator.js +6 -2
- 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 +67 -27
- 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 +3 -2
- package/lib/components/ConditionBuilder/core/transformer.js.map +1 -1
- package/lib/components/ConditionBuilder/core/types.d.ts +1 -1
- 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 +218 -0
- package/lib/components/ConditionInput/ConditionInput.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/PromotedFilters/PromotedFilters.d.ts +11 -0
- package/lib/components/PromotedFilters/PromotedFilters.d.ts.map +1 -0
- package/lib/components/PromotedFilters/PromotedFilters.js +93 -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 +25 -0
- package/lib/components/PromotedFilters/PromotedFilters.types.d.ts.map +1 -0
- package/lib/components/PromotedFilters/PromotedFilters.types.js +2 -0
- package/lib/components/PromotedFilters/PromotedFilters.types.js.map +1 -0
- package/lib/components/PromotedFilters/index.d.ts +3 -0
- package/lib/components/PromotedFilters/index.d.ts.map +1 -0
- package/lib/components/PromotedFilters/index.js +2 -0
- package/lib/components/PromotedFilters/index.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/package.json +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,218 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState, useEffect } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { CompositeInput, defaultThemeProp, hasProp, Input, NumberInput, RadioButton, RadioButtonGroup, StyledGrid, useI18n, FieldGroup, StyledFieldGroupLegend, StyledButton, DateInput, TimeInput, DateTimeInput, useConfiguration } from '@pega/cosmos-react-core';
|
|
5
|
+
import AtomicCondition, { getInitConditionForLhs } from '../ConditionBuilder/AtomicCondition';
|
|
6
|
+
import formatCondition from '../ConditionBuilder/core/formatter';
|
|
7
|
+
import ValueSelector from '../ConditionBuilder/RhsControls/ValueSelector';
|
|
8
|
+
const defaultComparators = {
|
|
9
|
+
TEXT: 'CONTAINS',
|
|
10
|
+
EMAIL: 'CONTAINS',
|
|
11
|
+
URL: 'CONTAINS',
|
|
12
|
+
PHONE: 'CONTAINS',
|
|
13
|
+
INTEGER: 'EQ',
|
|
14
|
+
DECIMAL: 'EQ',
|
|
15
|
+
PERCENTAGE: 'EQ',
|
|
16
|
+
CURRENCY: 'EQ',
|
|
17
|
+
BOOLEAN: 'IS_TRUE',
|
|
18
|
+
DATE_ONLY: 'LT',
|
|
19
|
+
TIME_ONLY: 'LT',
|
|
20
|
+
DATE_TIME: 'LT',
|
|
21
|
+
PICKLIST: 'IN'
|
|
22
|
+
};
|
|
23
|
+
const basicFieldMap = {
|
|
24
|
+
EMAIL: 'TEXT',
|
|
25
|
+
URL: 'TEXT',
|
|
26
|
+
PHONE: 'TEXT',
|
|
27
|
+
INTEGER: 'NUMBER',
|
|
28
|
+
DECIMAL: 'NUMBER',
|
|
29
|
+
PERCENTAGE: 'NUMBER',
|
|
30
|
+
CURRENCY: 'NUMBER',
|
|
31
|
+
TEXT: 'TEXT',
|
|
32
|
+
BOOLEAN: 'BOOLEAN',
|
|
33
|
+
DATE_ONLY: 'DATE_ONLY',
|
|
34
|
+
TIME_ONLY: 'TIME_ONLY',
|
|
35
|
+
DATE_TIME: 'DATE_TIME',
|
|
36
|
+
PICKLIST: 'TEXT'
|
|
37
|
+
};
|
|
38
|
+
const StyledConditionRadioGroup = styled(RadioButtonGroup) `
|
|
39
|
+
${StyledGrid} {
|
|
40
|
+
display: inline-flex;
|
|
41
|
+
} ;
|
|
42
|
+
`;
|
|
43
|
+
StyledConditionRadioGroup.defaultProps = defaultThemeProp;
|
|
44
|
+
const StyledFieldGroupLegendFn = ({ theme: { base: { palette } } }) => {
|
|
45
|
+
return css `
|
|
46
|
+
${StyledFieldGroupLegend} {
|
|
47
|
+
border-block-start: 0.0625rem solid ${palette['border-line']};
|
|
48
|
+
padding-block-start: 0.625rem;
|
|
49
|
+
|
|
50
|
+
${StyledButton} {
|
|
51
|
+
border-color: transparent;
|
|
52
|
+
font-weight: initial;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
};
|
|
57
|
+
const StyledFieldGroup = styled(FieldGroup)(StyledFieldGroupLegendFn);
|
|
58
|
+
StyledFieldGroup.defaultProps = defaultThemeProp;
|
|
59
|
+
const StyledAtomicCondition = styled(AtomicCondition)(StyledFieldGroupLegendFn);
|
|
60
|
+
StyledAtomicCondition.defaultProps = defaultThemeProp;
|
|
61
|
+
const compareValues = (value1, value2) => {
|
|
62
|
+
// both values are undefined
|
|
63
|
+
if (!value1 && !value2)
|
|
64
|
+
return true;
|
|
65
|
+
// only one value is undefined
|
|
66
|
+
if (!value1 || !value2)
|
|
67
|
+
return false;
|
|
68
|
+
// for strings compare only value
|
|
69
|
+
if (typeof value1 === 'string') {
|
|
70
|
+
return value1 === value2;
|
|
71
|
+
}
|
|
72
|
+
// for arrays compare length and every value
|
|
73
|
+
if (value1.length !== value2.length)
|
|
74
|
+
return false;
|
|
75
|
+
return value1.every((value, index) => value === value2[index]);
|
|
76
|
+
};
|
|
77
|
+
const ConditionInput = forwardRef(({ field: fieldProp, condition: conditionProp, label, mode, onChange, flat = false }, ref) => {
|
|
78
|
+
const t = useI18n();
|
|
79
|
+
const { locale } = useConfiguration();
|
|
80
|
+
const { name: fieldName, type: fieldType } = fieldProp;
|
|
81
|
+
const basicType = basicFieldMap[fieldType] ?? fieldType;
|
|
82
|
+
const field = {
|
|
83
|
+
id: fieldName,
|
|
84
|
+
type: basicType,
|
|
85
|
+
primary: label || fieldName
|
|
86
|
+
};
|
|
87
|
+
const fields = [field];
|
|
88
|
+
const createConditionForDefaultMode = (value) => {
|
|
89
|
+
let valueObj;
|
|
90
|
+
if (Array.isArray(value))
|
|
91
|
+
valueObj = { values: value };
|
|
92
|
+
else
|
|
93
|
+
valueObj = { value: basicType === 'NUMBER' ? Number(value) : value };
|
|
94
|
+
return {
|
|
95
|
+
lhs: { field: fieldName },
|
|
96
|
+
comparator: defaultComparators[fieldType],
|
|
97
|
+
rhs: valueObj
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
const validComparators = fieldType === 'PICKLIST' ? [{ type: 'TEXT', comparators: ['IN'] }] : undefined;
|
|
101
|
+
const condition = conditionProp ??
|
|
102
|
+
(fieldType === 'BOOLEAN'
|
|
103
|
+
? undefined
|
|
104
|
+
: getInitConditionForLhs({ field: fieldName }, fields, new Set(['LITERAL']), validComparators));
|
|
105
|
+
const [newCondition, setNewCondition] = useState(condition);
|
|
106
|
+
let rhsValue = fieldType === 'PICKLIST' ? [] : undefined;
|
|
107
|
+
if (condition?.rhs) {
|
|
108
|
+
if (hasProp(condition.rhs, 'value')) {
|
|
109
|
+
rhsValue = condition.rhs.value.toString();
|
|
110
|
+
}
|
|
111
|
+
else if (hasProp(condition.rhs, 'values')) {
|
|
112
|
+
rhsValue = condition.rhs.values.map(String);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const [inputValue, setInputValue] = useState(rhsValue);
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
setNewCondition(condition);
|
|
118
|
+
setInputValue(rhsValue);
|
|
119
|
+
}, [conditionProp]);
|
|
120
|
+
const handleBlur = () => {
|
|
121
|
+
// trigger onChange only when value has changed
|
|
122
|
+
if (!compareValues(rhsValue, inputValue)) {
|
|
123
|
+
onChange(inputValue ? createConditionForDefaultMode(inputValue) : undefined);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const onRadioButtonChange = (value) => {
|
|
127
|
+
const updatedCondition = value === undefined
|
|
128
|
+
? undefined
|
|
129
|
+
: {
|
|
130
|
+
lhs: { field: fieldName },
|
|
131
|
+
comparator: value ? 'IS_TRUE' : 'IS_FALSE'
|
|
132
|
+
};
|
|
133
|
+
onChange(updatedCondition);
|
|
134
|
+
};
|
|
135
|
+
const onClear = () => {
|
|
136
|
+
onChange(undefined);
|
|
137
|
+
setNewCondition(condition);
|
|
138
|
+
};
|
|
139
|
+
const showAdvanced = mode === 'advanced' && fieldType !== 'BOOLEAN' && fieldType !== 'PICKLIST';
|
|
140
|
+
let defaultControl = null;
|
|
141
|
+
const valueToSet = typeof inputValue === 'string' ? inputValue : undefined;
|
|
142
|
+
if (!showAdvanced) {
|
|
143
|
+
switch (fieldType) {
|
|
144
|
+
case 'INTEGER':
|
|
145
|
+
case 'DECIMAL':
|
|
146
|
+
case 'PERCENTAGE':
|
|
147
|
+
case 'CURRENCY':
|
|
148
|
+
defaultControl = (_jsx(NumberInput, { label: label, labelHidden: flat, ref: ref, value: valueToSet, onChange: setInputValue, onBlur: handleBlur, numberOfDecimals: fieldType === 'INTEGER' ? 0 : undefined }));
|
|
149
|
+
break;
|
|
150
|
+
case 'BOOLEAN':
|
|
151
|
+
defaultControl = (_jsxs(StyledConditionRadioGroup, { ref: ref, label: label, labelHidden: flat, name: fieldName, inline: true, children: [_jsx(RadioButton, { label: t('show_all'), checked: condition === undefined, onChange: () => onRadioButtonChange() }), _jsx(RadioButton, { label: t('boolean_display_true_label'), checked: condition?.comparator === 'IS_TRUE', onChange: () => onRadioButtonChange(true) }), _jsx(RadioButton, { label: t('boolean_display_false_label'), checked: condition?.comparator === 'IS_FALSE', onChange: () => onRadioButtonChange(false) })] }));
|
|
152
|
+
break;
|
|
153
|
+
case 'DATE_ONLY':
|
|
154
|
+
defaultControl = (_jsx(DateInput, { label: label, ref: ref, value: valueToSet, onChange: ({ valueAsISOString }) => setInputValue(valueAsISOString), onBlur: ({ valueAsISOString }) => {
|
|
155
|
+
onChange(createConditionForDefaultMode(valueAsISOString));
|
|
156
|
+
} }));
|
|
157
|
+
break;
|
|
158
|
+
case 'TIME_ONLY':
|
|
159
|
+
defaultControl = (_jsx(TimeInput, { label: label, ref: ref, value: valueToSet || undefined, onChange: ({ valueAsISOString }) => setInputValue(valueAsISOString), onBlur: ({ valueAsISOString }) => {
|
|
160
|
+
onChange(createConditionForDefaultMode(valueAsISOString));
|
|
161
|
+
} }));
|
|
162
|
+
break;
|
|
163
|
+
case 'DATE_TIME':
|
|
164
|
+
defaultControl = (_jsx(DateTimeInput, { label: label, ref: ref, value: valueToSet, onChange: ({ valueAsISOString }) => setInputValue(valueAsISOString), onBlur: ({ valueAsISOString }) => {
|
|
165
|
+
onChange(createConditionForDefaultMode(valueAsISOString));
|
|
166
|
+
} }));
|
|
167
|
+
break;
|
|
168
|
+
case 'PICKLIST':
|
|
169
|
+
defaultControl = (_jsx(ValueSelector, { mode: 'multi-select', values: inputValue ?? [], selectedField: fieldProp, comparator: condition?.comparator ?? defaultComparators[fieldType], onChange: value => {
|
|
170
|
+
setInputValue(value.length > 0 ? value : undefined);
|
|
171
|
+
}, onBlur: handleBlur, onClear: onClear, placeholder: t('all'), label: label, parameters: [], rhs: { values: [] } }));
|
|
172
|
+
break;
|
|
173
|
+
case 'TEXT':
|
|
174
|
+
case 'EMAIL':
|
|
175
|
+
case 'URL':
|
|
176
|
+
case 'PHONE':
|
|
177
|
+
default:
|
|
178
|
+
defaultControl = (_jsx(Input, { label: label, labelHidden: flat, ref: ref, value: valueToSet, onChange: (e) => setInputValue(e.target.value), onBlur: handleBlur }));
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const dialog = {
|
|
183
|
+
renderer: AtomicCondition,
|
|
184
|
+
rendererProps: {
|
|
185
|
+
condition: newCondition ??
|
|
186
|
+
getInitConditionForLhs({ field: fieldName }, fields, new Set(['LITERAL'])),
|
|
187
|
+
fields,
|
|
188
|
+
onChange: setNewCondition,
|
|
189
|
+
itemDirection: 'column',
|
|
190
|
+
lhsMode: 'hidden',
|
|
191
|
+
validRhsTypes: new Set(['LITERAL']),
|
|
192
|
+
indicateErrors: false
|
|
193
|
+
},
|
|
194
|
+
onCancel: ({ close }) => {
|
|
195
|
+
setNewCondition(condition);
|
|
196
|
+
close();
|
|
197
|
+
},
|
|
198
|
+
onApply: ({ close }) => {
|
|
199
|
+
onChange(newCondition);
|
|
200
|
+
close();
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
if (flat) {
|
|
204
|
+
return showAdvanced ? (_jsx(StyledAtomicCondition, { collapsible: true, actions: [{ id: 'clear', text: t('clear'), onClick: onClear }], condition: newCondition ??
|
|
205
|
+
getInitConditionForLhs({ field: fieldName }, fields, new Set(['LITERAL'])), onChange: onChange, fields: fields, itemDirection: 'column', lhsMode: 'label', validRhsTypes: new Set(['LITERAL']), indicateErrors: false })) : (_jsx(StyledFieldGroup, { name: label, collapsible: true, actions: [{ id: 'clear', text: t('clear'), onClick: onClear }], children: defaultControl }));
|
|
206
|
+
}
|
|
207
|
+
if (showAdvanced) {
|
|
208
|
+
return (_jsx(CompositeInput, { dialog: dialog, label: label, onClear: onClear, value: conditionProp
|
|
209
|
+
? formatCondition({ condition: conditionProp }, fields, t, {
|
|
210
|
+
locale,
|
|
211
|
+
omitLhs: true
|
|
212
|
+
})
|
|
213
|
+
: undefined, placeholder: t('all'), ref: ref }));
|
|
214
|
+
}
|
|
215
|
+
return defaultControl;
|
|
216
|
+
});
|
|
217
|
+
export default ConditionInput;
|
|
218
|
+
//# sourceMappingURL=ConditionInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConditionInput.js","sourceRoot":"","sources":["../../../src/components/ConditionInput/ConditionInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAGV,QAAQ,EAER,SAAS,EACV,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAA4B,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EACL,cAAc,EAEd,gBAAgB,EAEhB,OAAO,EACP,KAAK,EACL,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,OAAO,EACP,UAAU,EACV,sBAAsB,EACtB,YAAY,EACZ,SAAS,EACT,SAAS,EACT,aAAa,EACb,gBAAgB,EACjB,MAAM,yBAAyB,C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CAAC,YAE7D,cAAc,GACE,CACpB,CAAC;KACH;IACD,IAAI,YAAY,EAAE;QAChB,OAAO,CACL,KAAC,cAAc,IACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,KAAK,EACH,aAAa;gBACX,CAAC,CAAC,eAAe,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE;oBACvD,MAAM;oBACN,OAAO,EAAE,IAAI;iBACd,CAAC;gBACJ,CAAC,CAAC,SAAS,EAEf,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,EACrB,GAAG,EAAE,GAAG,GACR,CACH,CAAC;KACH;IACD,OAAO,cAAc,CAAC;AACxB,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n useState,\n ChangeEvent,\n useEffect\n} from 'react';\nimport styled, { css, DefaultTheme, ThemeProps } from 'styled-components';\n\nimport {\n CompositeInput,\n CompositeInputProps,\n defaultThemeProp,\n ForwardProps,\n hasProp,\n Input,\n NumberInput,\n RadioButton,\n RadioButtonGroup,\n StyledGrid,\n useI18n,\n FieldGroup,\n StyledFieldGroupLegend,\n StyledButton,\n DateInput,\n TimeInput,\n DateTimeInput,\n useConfiguration\n} from '@pega/cosmos-react-core';\n\nimport type { Comparator, ComparatorsByType, FieldType } from '../ConditionBuilder/core/types';\nimport AtomicCondition, {\n AtomicConditionProps,\n getInitConditionForLhs\n} from '../ConditionBuilder/AtomicCondition';\nimport formatCondition from '../ConditionBuilder/core/formatter';\nimport type { Field, LeafCondition } from '../ConditionBuilder/ConditionBuilder.types';\nimport ValueSelector from '../ConditionBuilder/RhsControls/ValueSelector';\n\nimport type { ConditionFieldType, ConditionInputProps } from './ConditionInput.types';\n\nconst defaultComparators: Record<ConditionFieldType, Comparator> = {\n TEXT: 'CONTAINS',\n EMAIL: 'CONTAINS',\n URL: 'CONTAINS',\n PHONE: 'CONTAINS',\n INTEGER: 'EQ',\n DECIMAL: 'EQ',\n PERCENTAGE: 'EQ',\n CURRENCY: 'EQ',\n BOOLEAN: 'IS_TRUE',\n DATE_ONLY: 'LT',\n TIME_ONLY: 'LT',\n DATE_TIME: 'LT',\n PICKLIST: 'IN'\n} as const;\n\nconst basicFieldMap: Record<ConditionFieldType, FieldType> = {\n EMAIL: 'TEXT',\n URL: 'TEXT',\n PHONE: 'TEXT',\n INTEGER: 'NUMBER',\n DECIMAL: 'NUMBER',\n PERCENTAGE: 'NUMBER',\n CURRENCY: 'NUMBER',\n TEXT: 'TEXT',\n BOOLEAN: 'BOOLEAN',\n DATE_ONLY: 'DATE_ONLY',\n TIME_ONLY: 'TIME_ONLY',\n DATE_TIME: 'DATE_TIME',\n PICKLIST: 'TEXT'\n} as const;\n\nconst StyledConditionRadioGroup = styled(RadioButtonGroup)`\n ${StyledGrid} {\n display: inline-flex;\n } ;\n`;\n\nStyledConditionRadioGroup.defaultProps = defaultThemeProp;\n\nconst StyledFieldGroupLegendFn = ({\n theme: {\n base: { palette }\n }\n}: ThemeProps<DefaultTheme>) => {\n return css`\n ${StyledFieldGroupLegend} {\n border-block-start: 0.0625rem solid ${palette['border-line']};\n padding-block-start: 0.625rem;\n\n ${StyledButton} {\n border-color: transparent;\n font-weight: initial;\n }\n }\n `;\n};\n\nconst StyledFieldGroup = styled(FieldGroup)(StyledFieldGroupLegendFn);\n\nStyledFieldGroup.defaultProps = defaultThemeProp;\n\nconst StyledAtomicCondition = styled(AtomicCondition)(StyledFieldGroupLegendFn);\n\nStyledAtomicCondition.defaultProps = defaultThemeProp;\n\nconst 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\nconst ConditionInput: FunctionComponent<ConditionInputProps & ForwardProps> = forwardRef(\n (\n {\n field: fieldProp,\n condition: conditionProp,\n label,\n mode,\n onChange,\n flat = false\n }: PropsWithoutRef<ConditionInputProps>,\n ref: ConditionInputProps['ref']\n ) => {\n const t = useI18n();\n const { locale } = useConfiguration();\n\n const { name: fieldName, type: fieldType } = fieldProp;\n const basicType = basicFieldMap[fieldType] ?? fieldType;\n\n const field: Field = {\n id: fieldName,\n type: basicType,\n primary: label || fieldName\n };\n\n const fields: AtomicConditionProps['fields'] = [field];\n\n const createConditionForDefaultMode = (value: string | string[]): LeafCondition => {\n let valueObj: LeafCondition['rhs'];\n if (Array.isArray(value)) valueObj = { values: value };\n else valueObj = { value: basicType === 'NUMBER' ? Number(value) : value };\n\n return {\n lhs: { field: fieldName },\n comparator: defaultComparators[fieldType],\n rhs: valueObj\n };\n };\n\n const validComparators: ComparatorsByType[] | undefined =\n fieldType === 'PICKLIST' ? [{ type: 'TEXT', comparators: ['IN'] }] : undefined;\n\n const condition =\n conditionProp ??\n (fieldType === 'BOOLEAN'\n ? undefined\n : getInitConditionForLhs(\n { field: fieldName },\n fields,\n new Set(['LITERAL']),\n validComparators\n ));\n\n const [newCondition, setNewCondition] = useState<LeafCondition | undefined>(condition);\n\n let rhsValue: string | string[] | undefined = fieldType === 'PICKLIST' ? [] : undefined;\n\n if (condition?.rhs) {\n if (hasProp(condition.rhs, 'value')) {\n rhsValue = condition.rhs.value.toString();\n } else if (hasProp(condition.rhs, 'values')) {\n rhsValue = condition.rhs.values.map(String);\n }\n }\n\n const [inputValue, setInputValue] = useState(rhsValue);\n\n useEffect(() => {\n setNewCondition(condition);\n setInputValue(rhsValue);\n }, [conditionProp]);\n\n const handleBlur = () => {\n // trigger onChange only when value has changed\n if (!compareValues(rhsValue, inputValue)) {\n onChange(inputValue ? createConditionForDefaultMode(inputValue) : undefined);\n }\n };\n\n const onRadioButtonChange = (value?: boolean) => {\n const updatedCondition: LeafCondition | undefined =\n value === undefined\n ? undefined\n : {\n lhs: { field: fieldName },\n comparator: value ? 'IS_TRUE' : 'IS_FALSE'\n };\n onChange(updatedCondition);\n };\n\n const onClear = () => {\n onChange(undefined);\n setNewCondition(condition);\n };\n\n const showAdvanced = mode === 'advanced' && fieldType !== 'BOOLEAN' && fieldType !== 'PICKLIST';\n\n let defaultControl: JSX.Element | null = null;\n\n const valueToSet = typeof inputValue === 'string' ? inputValue : undefined;\n\n if (!showAdvanced) {\n switch (fieldType) {\n case 'INTEGER':\n case 'DECIMAL':\n case 'PERCENTAGE':\n case 'CURRENCY':\n defaultControl = (\n <NumberInput\n label={label}\n labelHidden={flat}\n ref={ref}\n value={valueToSet}\n onChange={setInputValue}\n onBlur={handleBlur}\n numberOfDecimals={fieldType === 'INTEGER' ? 0 : undefined}\n />\n );\n break;\n case 'BOOLEAN':\n defaultControl = (\n <StyledConditionRadioGroup\n ref={ref}\n label={label}\n labelHidden={flat}\n name={fieldName}\n inline\n >\n <RadioButton\n label={t('show_all')}\n checked={condition === undefined}\n onChange={() => onRadioButtonChange()}\n />\n <RadioButton\n label={t('boolean_display_true_label')}\n checked={condition?.comparator === 'IS_TRUE'}\n onChange={() => onRadioButtonChange(true)}\n />\n <RadioButton\n label={t('boolean_display_false_label')}\n checked={condition?.comparator === 'IS_FALSE'}\n onChange={() => onRadioButtonChange(false)}\n />\n </StyledConditionRadioGroup>\n );\n break;\n case 'DATE_ONLY':\n defaultControl = (\n <DateInput\n label={label}\n ref={ref}\n value={valueToSet}\n onChange={({ valueAsISOString }) => setInputValue(valueAsISOString)}\n onBlur={({ valueAsISOString }) => {\n onChange(createConditionForDefaultMode(valueAsISOString));\n }}\n />\n );\n break;\n case 'TIME_ONLY':\n defaultControl = (\n <TimeInput\n label={label}\n ref={ref}\n value={valueToSet || undefined}\n onChange={({ valueAsISOString }) => setInputValue(valueAsISOString)}\n onBlur={({ valueAsISOString }) => {\n onChange(createConditionForDefaultMode(valueAsISOString));\n }}\n />\n );\n break;\n case 'DATE_TIME':\n defaultControl = (\n <DateTimeInput\n label={label}\n ref={ref}\n value={valueToSet}\n onChange={({ valueAsISOString }) => setInputValue(valueAsISOString)}\n onBlur={({ valueAsISOString }) => {\n onChange(createConditionForDefaultMode(valueAsISOString));\n }}\n />\n );\n break;\n case 'PICKLIST':\n defaultControl = (\n <ValueSelector\n mode='multi-select'\n values={inputValue ?? []}\n selectedField={fieldProp}\n comparator={condition?.comparator ?? defaultComparators[fieldType]}\n onChange={value => {\n setInputValue(value.length > 0 ? value : undefined);\n }}\n onBlur={handleBlur}\n onClear={onClear}\n placeholder={t('all')}\n label={label}\n parameters={[]}\n rhs={{ values: [] }}\n />\n );\n break;\n case 'TEXT':\n case 'EMAIL':\n case 'URL':\n case 'PHONE':\n default:\n defaultControl = (\n <Input\n label={label}\n labelHidden={flat}\n ref={ref}\n value={valueToSet}\n onChange={(e: ChangeEvent<HTMLInputElement>) => setInputValue(e.target.value)}\n onBlur={handleBlur}\n />\n );\n break;\n }\n }\n\n const dialog: CompositeInputProps<AtomicConditionProps & ForwardProps>['dialog'] = {\n renderer: AtomicCondition,\n rendererProps: {\n condition:\n newCondition ??\n getInitConditionForLhs({ field: fieldName }, fields, new Set(['LITERAL'])),\n fields,\n onChange: setNewCondition,\n itemDirection: 'column',\n lhsMode: 'hidden',\n validRhsTypes: new Set(['LITERAL']),\n indicateErrors: false\n },\n onCancel: ({ close }) => {\n setNewCondition(condition);\n close();\n },\n onApply: ({ close }) => {\n onChange(newCondition);\n close();\n }\n };\n\n if (flat) {\n return showAdvanced ? (\n <StyledAtomicCondition\n collapsible\n actions={[{ id: 'clear', text: t('clear'), onClick: onClear }]}\n condition={\n newCondition ??\n getInitConditionForLhs({ field: fieldName }, fields, new Set(['LITERAL']))\n }\n onChange={onChange}\n fields={fields}\n itemDirection='column'\n lhsMode='label'\n validRhsTypes={new Set(['LITERAL'])}\n indicateErrors={false}\n />\n ) : (\n <StyledFieldGroup\n name={label}\n collapsible\n actions={[{ id: 'clear', text: t('clear'), onClick: onClear }]}\n >\n {defaultControl}\n </StyledFieldGroup>\n );\n }\n if (showAdvanced) {\n return (\n <CompositeInput\n dialog={dialog}\n label={label}\n onClear={onClear}\n value={\n conditionProp\n ? formatCondition({ condition: conditionProp }, fields, t, {\n locale,\n omitLhs: true\n })\n : undefined\n }\n placeholder={t('all')}\n ref={ref}\n />\n );\n }\n return defaultControl;\n }\n);\n\nexport default ConditionInput;\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Ref } from 'react';
|
|
2
|
+
import type { LeafCondition, ValueSelection } from '../ConditionBuilder';
|
|
3
|
+
export declare type ConditionFieldType = 'TEXT' | 'EMAIL' | 'URL' | 'PHONE' | 'INTEGER' | 'DECIMAL' | 'PERCENTAGE' | 'BOOLEAN' | 'CURRENCY' | 'DATE_ONLY' | 'TIME_ONLY' | 'DATE_TIME' | 'PICKLIST';
|
|
4
|
+
export interface ConditionField {
|
|
5
|
+
/** Unique field identifier. */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Type of the field. */
|
|
8
|
+
type: ConditionFieldType;
|
|
9
|
+
/** List of possible field values */
|
|
10
|
+
possibleValues?: ValueSelection<ConditionField>;
|
|
11
|
+
}
|
|
12
|
+
export declare type ConditionInputMode = 'default' | 'advanced';
|
|
13
|
+
export interface ConditionInputProps {
|
|
14
|
+
/** Definition of the field the condition is created for. */
|
|
15
|
+
field: ConditionField;
|
|
16
|
+
/** Display mode. Either with default comparator or the full-fledged */
|
|
17
|
+
mode: ConditionInputMode;
|
|
18
|
+
/** Label for the input. */
|
|
19
|
+
label?: string;
|
|
20
|
+
/** Condition value. */
|
|
21
|
+
condition?: LeafCondition;
|
|
22
|
+
/** Callback invoked when user changes the condition. */
|
|
23
|
+
onChange: (condition?: LeafCondition) => void;
|
|
24
|
+
/** Reference to the input element. */
|
|
25
|
+
ref?: Ref<HTMLInputElement>;
|
|
26
|
+
/** Whether advanced view should be wrapped in popup or just flat. */
|
|
27
|
+
flat?: boolean;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=ConditionInput.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConditionInput.types.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionInput/ConditionInput.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEzE,oBAAY,kBAAkB,GAC1B,MAAM,GACN,OAAO,GACP,KAAK,GACL,OAAO,GACP,SAAS,GACT,SAAS,GACT,YAAY,GACZ,SAAS,GACT,UAAU,GACV,WAAW,GACX,WAAW,GACX,WAAW,GACX,UAAU,CAAC;AAEf,MAAM,WAAW,cAAc;IAC7B,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,IAAI,EAAE,kBAAkB,CAAC;IACzB,oCAAoC;IACpC,cAAc,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;CACjD;AAED,oBAAY,kBAAkB,GAAG,SAAS,GAAG,UAAU,CAAC;AAExD,MAAM,WAAW,mBAAmB;IAClC,4DAA4D;IAC5D,KAAK,EAAE,cAAc,CAAC;IACtB,uEAAuE;IACvE,IAAI,EAAE,kBAAkB,CAAC;IACzB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,sCAAsC;IACtC,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC5B,qEAAqE;IACrE,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConditionInput.types.js","sourceRoot":"","sources":["../../../src/components/ConditionInput/ConditionInput.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Ref } from 'react';\n\nimport type { LeafCondition, ValueSelection } from '../ConditionBuilder';\n\nexport type ConditionFieldType =\n | 'TEXT'\n | 'EMAIL'\n | 'URL'\n | 'PHONE'\n | 'INTEGER'\n | 'DECIMAL'\n | 'PERCENTAGE'\n | 'BOOLEAN'\n | 'CURRENCY'\n | 'DATE_ONLY'\n | 'TIME_ONLY'\n | 'DATE_TIME'\n | 'PICKLIST';\n\nexport interface ConditionField {\n /** Unique field identifier. */\n name: string;\n /** Type of the field. */\n type: ConditionFieldType;\n /** List of possible field values */\n possibleValues?: ValueSelection<ConditionField>;\n}\n\nexport type ConditionInputMode = 'default' | 'advanced';\n\nexport interface ConditionInputProps {\n /** Definition of the field the condition is created for. */\n field: ConditionField;\n /** Display mode. Either with default comparator or the full-fledged */\n mode: ConditionInputMode;\n /** Label for the input. */\n label?: string;\n /** Condition value. */\n condition?: LeafCondition;\n /** Callback invoked when user changes the condition. */\n onChange: (condition?: LeafCondition) => void;\n /** Reference to the input element. */\n ref?: Ref<HTMLInputElement>;\n /** Whether advanced view should be wrapped in popup or just flat. */\n flat?: boolean;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACf,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ConditionInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["export { default } from './ConditionInput';\nexport {\n ConditionInputProps,\n ConditionInputMode,\n ConditionFieldType,\n ConditionField\n} from './ConditionInput.types';\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,EAOlB,MAAM,OAAO,CAAC;AAEf,OAAO,EAGL,YAAY,EAOb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAiB,MAAM,4CAA4C,CAAC;AAItF,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+GD,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAAC,oBAAoB,GAAG,YAAY,CAkHlF,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useCallback, useContext, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Button, Flex, Icon, Modal, ModalManagerContext, useBreakpoint, useI18n } from '@pega/cosmos-react-core';
|
|
4
|
+
import { splitConditionForBuilder } from '../ConditionBuilder/core/utils';
|
|
5
|
+
import ConditionInput from '../ConditionInput';
|
|
6
|
+
import { StyledPromotedFilters, StyledClearAllButton, StyledTextWithEllipsis } from './PromotedFilters.styles';
|
|
7
|
+
const PromotedFiltersContent = forwardRef(({ filters, condition, onChange, orientation: orientationProp = 'horizontal' }, ref) => {
|
|
8
|
+
const isSmallOrAbove = useBreakpoint('sm');
|
|
9
|
+
const orientation = isSmallOrAbove && orientationProp === 'horizontal' ? 'horizontal' : 'vertical';
|
|
10
|
+
// map of Conditions indexed by field name
|
|
11
|
+
const conditionsMap = condition
|
|
12
|
+
? splitConditionForBuilder(condition).rows.reduce((result, item) => {
|
|
13
|
+
result[item.lhs.field] = item;
|
|
14
|
+
return result;
|
|
15
|
+
}, {})
|
|
16
|
+
: {};
|
|
17
|
+
const createUpdatedCondition = (key, newCondition) => {
|
|
18
|
+
if (newCondition) {
|
|
19
|
+
conditionsMap[key] = newCondition;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
delete conditionsMap[key];
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
AND: Object.values(conditionsMap).map(c => {
|
|
26
|
+
return { condition: c };
|
|
27
|
+
})
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
return (_jsx(Flex, { container: {
|
|
31
|
+
gap: 2,
|
|
32
|
+
direction: orientation === 'vertical' ? 'column' : 'row',
|
|
33
|
+
wrap: 'wrap'
|
|
34
|
+
}, ref: ref, children: filters.map(({ field, mode, label }) => {
|
|
35
|
+
return (_jsx(ConditionInput, { field: field, mode: mode, label: label ?? field.name, condition: conditionsMap[field.name], flat: orientation === 'vertical', onChange: (newCondition) => {
|
|
36
|
+
onChange(createUpdatedCondition(field.name, newCondition));
|
|
37
|
+
} }, field.name));
|
|
38
|
+
}) }));
|
|
39
|
+
});
|
|
40
|
+
const FilterModal = ({ filters, condition, onApply }) => {
|
|
41
|
+
const t = useI18n();
|
|
42
|
+
const { ModalContext } = useContext(ModalManagerContext);
|
|
43
|
+
const { dismiss } = useContext(ModalContext);
|
|
44
|
+
const [newCondition, setNewCondition] = useState(condition);
|
|
45
|
+
const onApplyClick = useCallback(() => {
|
|
46
|
+
onApply?.(newCondition);
|
|
47
|
+
dismiss();
|
|
48
|
+
}, [newCondition, onApply]);
|
|
49
|
+
const actions = (_jsx(Button, { variant: 'primary', onClick: onApplyClick, children: t('apply') }));
|
|
50
|
+
return (_jsxs(Modal, { heading: t('filters'), actions: actions, stretch: true, children: [_jsx(Flex, { container: { justify: 'end' }, children: _jsx(StyledClearAllButton, { variant: 'simple', onClick: () => {
|
|
51
|
+
setNewCondition(undefined);
|
|
52
|
+
}, children: t('clear_all') }) }), _jsx(PromotedFiltersContent, { filters: filters, condition: newCondition, onChange: setNewCondition, orientation: 'vertical' })] }));
|
|
53
|
+
};
|
|
54
|
+
export const PromotedFilters = forwardRef(({ filters, condition, onChange, orientation = 'horizontal' }, ref) => {
|
|
55
|
+
const t = useI18n();
|
|
56
|
+
const isSmallOrAbove = useBreakpoint('sm');
|
|
57
|
+
const { create } = useContext(ModalManagerContext);
|
|
58
|
+
const modalMethods = useRef();
|
|
59
|
+
// map of Conditions indexed by field name
|
|
60
|
+
const conditionsCount = condition ? splitConditionForBuilder(condition).rows.length : undefined;
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
modalMethods.current?.update({
|
|
63
|
+
filters,
|
|
64
|
+
condition
|
|
65
|
+
});
|
|
66
|
+
}, [filters, condition]);
|
|
67
|
+
const openFiltersModal = () => {
|
|
68
|
+
modalMethods.current = create(FilterModal, {
|
|
69
|
+
filters,
|
|
70
|
+
condition,
|
|
71
|
+
onApply: onChange
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
return (_jsx(Flex, { as: StyledPromotedFilters, container: {
|
|
75
|
+
alignItems: orientation === 'horizontal' && isSmallOrAbove ? 'start' : undefined,
|
|
76
|
+
justify: 'between',
|
|
77
|
+
direction: !isSmallOrAbove || orientation === 'horizontal' ? 'row' : 'column',
|
|
78
|
+
pad: 2,
|
|
79
|
+
gap: 2
|
|
80
|
+
}, ref: ref, children: isSmallOrAbove ? (_jsxs(_Fragment, { children: [orientation === 'vertical' && (_jsxs(Flex, { container: {
|
|
81
|
+
justify: 'between',
|
|
82
|
+
alignItems: 'center',
|
|
83
|
+
pad: [0, 0, 1, 0]
|
|
84
|
+
}, children: [_jsx(StyledTextWithEllipsis, { variant: 'h3', children: t('filters') }), _jsx(Button, { variant: 'simple', onClick: () => {
|
|
85
|
+
onChange();
|
|
86
|
+
}, 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: () => {
|
|
87
|
+
onChange();
|
|
88
|
+
}, 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: () => {
|
|
89
|
+
onChange();
|
|
90
|
+
}, children: t('clear_all') })] })) }));
|
|
91
|
+
});
|
|
92
|
+
export default PromotedFilters;
|
|
93
|
+
//# sourceMappingURL=PromotedFilters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromotedFilters.js","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.tsx"],"names":[],"mappings":";AAAA,OAAO,EAC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AE,CAAC;4BACb,CAAC,YAEA,CAAC,CAAC,WAAW,CAAC,GACR,IACJ,CACR,EAED,KAAC,sBAAsB,IACrB,OAAO,EAAE,OAAO,EAChB,QAAQ,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,IACnB,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE,GAAG,EAAE;4BACZ,QAAQ,EAAE,CAAC;wBACb,CAAC,YAEA,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,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 useContext,\n useEffect,\n useRef,\n useState\n} from 'react';\n\nimport {\n Button,\n Flex,\n ForwardProps,\n Icon,\n Modal,\n ModalMethods,\n ModalManagerContext,\n useBreakpoint,\n useI18n\n} from '@pega/cosmos-react-core';\n\nimport { Condition, LeafCondition } from '../ConditionBuilder/ConditionBuilder.types';\nimport { splitConditionForBuilder } from '../ConditionBuilder/core/utils';\nimport ConditionInput from '../ConditionInput';\n\nimport { PromotedFiltersProps } from './PromotedFilters.types';\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 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 result[item.lhs.field] = item;\n return result;\n },\n {}\n )\n : {};\n\n const createUpdatedCondition = (key: string, newCondition?: LeafCondition) => {\n if (newCondition) {\n conditionsMap[key] = newCondition;\n } else {\n delete conditionsMap[key];\n }\n\n return {\n AND: Object.values(conditionsMap).map(c => {\n return { condition: c } as Condition;\n })\n };\n };\n\n return (\n <Flex\n container={{\n gap: 2,\n direction: orientation === 'vertical' ? 'column' : 'row',\n wrap: 'wrap'\n }}\n ref={ref}\n >\n {filters.map(({ field, mode, label }) => {\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 </Flex>\n );\n }\n);\n\nconst FilterModal = ({ filters, condition, onApply }: FilterModalProps) => {\n const t = useI18n();\n\n const { ModalContext } = useContext(ModalManagerContext);\n const { dismiss } = useContext(ModalContext);\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 } = useContext(ModalManagerContext);\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,25 @@
|
|
|
1
|
+
import { Ref } from 'react';
|
|
2
|
+
import { BaseProps, NoChildrenProp } from '@pega/cosmos-react-core';
|
|
3
|
+
import type { Condition } 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
|
+
}
|
|
13
|
+
export interface PromotedFiltersProps extends BaseProps, NoChildrenProp {
|
|
14
|
+
/** Configuration of filters for every field that has been defined as promoted. */
|
|
15
|
+
filters: PromotedFilter[];
|
|
16
|
+
/** A value representing the current condition state. */
|
|
17
|
+
condition?: Condition;
|
|
18
|
+
/** Orientation mode. The default is horizontal. */
|
|
19
|
+
orientation?: 'vertical' | 'horizontal';
|
|
20
|
+
/** Callback fired on change of any of the filters. */
|
|
21
|
+
onChange: (condition?: Condition) => void;
|
|
22
|
+
/** Ref for the wrapping element. */
|
|
23
|
+
ref?: Ref<HTMLDivElement>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=PromotedFilters.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromotedFilters.types.d.ts","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4CAA4C,CAAC;AAC5E,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;CAChB;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 } 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}\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"]}
|