@pega/cosmos-react-condition-builder 5.0.0-dev.4.7 → 5.0.0-dev.4.9
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/package.json +2 -2
- package/lib/components/ConditionBuilder/AtomicCondition.d.ts +0 -57
- package/lib/components/ConditionBuilder/AtomicCondition.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/AtomicCondition.js +0 -164
- package/lib/components/ConditionBuilder/AtomicCondition.js.map +0 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.d.ts +0 -6
- package/lib/components/ConditionBuilder/ConditionBuilder.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.js +0 -271
- package/lib/components/ConditionBuilder/ConditionBuilder.js.map +0 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.d.ts +0 -7
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.js +0 -59
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.js.map +0 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts +0 -136
- package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.types.js +0 -2
- package/lib/components/ConditionBuilder/ConditionBuilder.types.js.map +0 -1
- package/lib/components/ConditionBuilder/FieldCondition.d.ts +0 -7
- package/lib/components/ConditionBuilder/FieldCondition.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/FieldCondition.js +0 -26
- package/lib/components/ConditionBuilder/FieldCondition.js.map +0 -1
- package/lib/components/ConditionBuilder/FieldCondition.types.d.ts +0 -30
- package/lib/components/ConditionBuilder/FieldCondition.types.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/FieldCondition.types.js +0 -2
- package/lib/components/ConditionBuilder/FieldCondition.types.js.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.d.ts +0 -18
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.js +0 -155
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.js.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.d.ts +0 -21
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.js +0 -60
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.js.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.d.ts +0 -18
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.js +0 -22
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.js.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.d.ts +0 -18
- package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.js +0 -119
- package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.js.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.d.ts +0 -26
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.js +0 -156
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.js.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.d.ts +0 -6
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.js +0 -112
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.js.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.d.ts +0 -20
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.js +0 -12
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.js.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.d.ts +0 -45
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.js +0 -196
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.js.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/index.d.ts +0 -42
- package/lib/components/ConditionBuilder/RhsControls/index.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/index.js +0 -321
- package/lib/components/ConditionBuilder/RhsControls/index.js.map +0 -1
- package/lib/components/ConditionBuilder/core/comparators.d.ts +0 -12
- package/lib/components/ConditionBuilder/core/comparators.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/core/comparators.js +0 -78
- package/lib/components/ConditionBuilder/core/comparators.js.map +0 -1
- package/lib/components/ConditionBuilder/core/evaluator.d.ts +0 -17
- package/lib/components/ConditionBuilder/core/evaluator.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/core/evaluator.js +0 -314
- package/lib/components/ConditionBuilder/core/evaluator.js.map +0 -1
- package/lib/components/ConditionBuilder/core/extendDayJs.d.ts +0 -2
- package/lib/components/ConditionBuilder/core/extendDayJs.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/core/extendDayJs.js +0 -4
- package/lib/components/ConditionBuilder/core/extendDayJs.js.map +0 -1
- package/lib/components/ConditionBuilder/core/formatter.d.ts +0 -17
- package/lib/components/ConditionBuilder/core/formatter.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/core/formatter.js +0 -262
- package/lib/components/ConditionBuilder/core/formatter.js.map +0 -1
- package/lib/components/ConditionBuilder/core/rows-reducer.d.ts +0 -27
- package/lib/components/ConditionBuilder/core/rows-reducer.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/core/rows-reducer.js +0 -50
- package/lib/components/ConditionBuilder/core/rows-reducer.js.map +0 -1
- package/lib/components/ConditionBuilder/core/time-utils.d.ts +0 -5
- package/lib/components/ConditionBuilder/core/time-utils.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/core/time-utils.js +0 -23
- package/lib/components/ConditionBuilder/core/time-utils.js.map +0 -1
- package/lib/components/ConditionBuilder/core/transformer.d.ts +0 -7
- package/lib/components/ConditionBuilder/core/transformer.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/core/transformer.js +0 -210
- package/lib/components/ConditionBuilder/core/transformer.js.map +0 -1
- package/lib/components/ConditionBuilder/core/types.d.ts +0 -47
- package/lib/components/ConditionBuilder/core/types.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/core/types.js +0 -2
- package/lib/components/ConditionBuilder/core/types.js.map +0 -1
- package/lib/components/ConditionBuilder/core/utils.d.ts +0 -37
- package/lib/components/ConditionBuilder/core/utils.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/core/utils.js +0 -454
- package/lib/components/ConditionBuilder/core/utils.js.map +0 -1
- package/lib/components/ConditionBuilder/index.d.ts +0 -11
- package/lib/components/ConditionBuilder/index.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/index.js +0 -8
- package/lib/components/ConditionBuilder/index.js.map +0 -1
- package/lib/components/ConditionInput/ConditionInput.d.ts +0 -6
- package/lib/components/ConditionInput/ConditionInput.d.ts.map +0 -1
- package/lib/components/ConditionInput/ConditionInput.js +0 -302
- package/lib/components/ConditionInput/ConditionInput.js.map +0 -1
- package/lib/components/ConditionInput/ConditionInput.styles.d.ts +0 -5
- package/lib/components/ConditionInput/ConditionInput.styles.d.ts.map +0 -1
- package/lib/components/ConditionInput/ConditionInput.styles.js +0 -27
- package/lib/components/ConditionInput/ConditionInput.styles.js.map +0 -1
- package/lib/components/ConditionInput/ConditionInput.types.d.ts +0 -32
- package/lib/components/ConditionInput/ConditionInput.types.d.ts.map +0 -1
- package/lib/components/ConditionInput/ConditionInput.types.js +0 -2
- package/lib/components/ConditionInput/ConditionInput.types.js.map +0 -1
- package/lib/components/ConditionInput/index.d.ts +0 -3
- package/lib/components/ConditionInput/index.d.ts.map +0 -1
- package/lib/components/ConditionInput/index.js +0 -2
- package/lib/components/ConditionInput/index.js.map +0 -1
- package/lib/components/ConditionInput/utils.d.ts +0 -17
- package/lib/components/ConditionInput/utils.d.ts.map +0 -1
- package/lib/components/ConditionInput/utils.js +0 -121
- package/lib/components/ConditionInput/utils.js.map +0 -1
- package/lib/components/PromotedFilters/ConditionSelector.d.ts +0 -31
- package/lib/components/PromotedFilters/ConditionSelector.d.ts.map +0 -1
- package/lib/components/PromotedFilters/ConditionSelector.js +0 -44
- package/lib/components/PromotedFilters/ConditionSelector.js.map +0 -1
- package/lib/components/PromotedFilters/PromotedFilters.d.ts +0 -11
- package/lib/components/PromotedFilters/PromotedFilters.d.ts.map +0 -1
- package/lib/components/PromotedFilters/PromotedFilters.js +0 -153
- package/lib/components/PromotedFilters/PromotedFilters.js.map +0 -1
- package/lib/components/PromotedFilters/PromotedFilters.styles.d.ts +0 -4
- package/lib/components/PromotedFilters/PromotedFilters.styles.d.ts.map +0 -1
- package/lib/components/PromotedFilters/PromotedFilters.styles.js +0 -38
- package/lib/components/PromotedFilters/PromotedFilters.styles.js.map +0 -1
- package/lib/components/PromotedFilters/PromotedFilters.types.d.ts +0 -33
- package/lib/components/PromotedFilters/PromotedFilters.types.d.ts.map +0 -1
- package/lib/components/PromotedFilters/PromotedFilters.types.js +0 -2
- package/lib/components/PromotedFilters/PromotedFilters.types.js.map +0 -1
- package/lib/components/PromotedFilters/index.d.ts +0 -3
- package/lib/components/PromotedFilters/index.d.ts.map +0 -1
- package/lib/components/PromotedFilters/index.js +0 -2
- package/lib/components/PromotedFilters/index.js.map +0 -1
- package/lib/index.d.ts +0 -7
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -8
- package/lib/index.js.map +0 -1
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
// cspell:words DDTHH
|
|
2
|
-
import dayjs from 'dayjs';
|
|
3
|
-
import './extendDayJs';
|
|
4
|
-
import { hasProp } from '@pega/cosmos-react-core';
|
|
5
|
-
import { getItem } from './utils';
|
|
6
|
-
const dayjsDateParts = {
|
|
7
|
-
SECONDS: 'second',
|
|
8
|
-
MINUTES: 'minute',
|
|
9
|
-
HOURS: 'hour',
|
|
10
|
-
DAYS: 'day',
|
|
11
|
-
WEEKS: 'week',
|
|
12
|
-
QUARTERS: 'quarter',
|
|
13
|
-
MONTHS: 'month',
|
|
14
|
-
YEARS: 'year'
|
|
15
|
-
};
|
|
16
|
-
/** Construct Condition with two range comparators based on the given bounds */
|
|
17
|
-
function getConditionForBetweenComparator(start, end, node) {
|
|
18
|
-
return node.comparator === 'BTW'
|
|
19
|
-
? {
|
|
20
|
-
AND: [
|
|
21
|
-
{
|
|
22
|
-
condition: {
|
|
23
|
-
lhs: node.lhs,
|
|
24
|
-
comparator: 'GTE',
|
|
25
|
-
rhs: { value: start }
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
condition: {
|
|
30
|
-
lhs: node.lhs,
|
|
31
|
-
comparator: 'LTE',
|
|
32
|
-
rhs: { value: end }
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
]
|
|
36
|
-
}
|
|
37
|
-
: {
|
|
38
|
-
OR: [
|
|
39
|
-
{
|
|
40
|
-
condition: {
|
|
41
|
-
lhs: node.lhs,
|
|
42
|
-
comparator: 'LT',
|
|
43
|
-
rhs: { value: start }
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
condition: {
|
|
48
|
-
lhs: node.lhs,
|
|
49
|
-
comparator: 'GT',
|
|
50
|
-
rhs: { value: end }
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
/** Construct a date-range filter based on the given date bounds and the comparator */
|
|
57
|
-
function getConditionFromRange(startDate, endDate, node, lhsFieldType) {
|
|
58
|
-
const formatDate = (d) => {
|
|
59
|
-
return lhsFieldType === 'DATE_ONLY' ? d.format('YYYY-MM-DD') : d.format('YYYY-MM-DDTHH:mm:ss');
|
|
60
|
-
};
|
|
61
|
-
switch (node.comparator) {
|
|
62
|
-
case 'EQ':
|
|
63
|
-
return {
|
|
64
|
-
AND: [
|
|
65
|
-
{
|
|
66
|
-
condition: {
|
|
67
|
-
lhs: node.lhs,
|
|
68
|
-
comparator: 'LTE',
|
|
69
|
-
rhs: { value: formatDate(endDate) }
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
condition: {
|
|
74
|
-
lhs: node.lhs,
|
|
75
|
-
comparator: 'GTE',
|
|
76
|
-
rhs: { value: formatDate(startDate) }
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
]
|
|
80
|
-
};
|
|
81
|
-
case 'NEQ':
|
|
82
|
-
return {
|
|
83
|
-
OR: [
|
|
84
|
-
{
|
|
85
|
-
condition: {
|
|
86
|
-
lhs: node.lhs,
|
|
87
|
-
comparator: 'GT',
|
|
88
|
-
rhs: { value: formatDate(endDate) }
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
condition: {
|
|
93
|
-
lhs: node.lhs,
|
|
94
|
-
comparator: 'LT',
|
|
95
|
-
rhs: { value: formatDate(startDate) }
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
]
|
|
99
|
-
};
|
|
100
|
-
case 'GT':
|
|
101
|
-
return {
|
|
102
|
-
condition: {
|
|
103
|
-
lhs: node.lhs,
|
|
104
|
-
comparator: 'GT',
|
|
105
|
-
rhs: { value: formatDate(endDate) }
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
case 'GTE':
|
|
109
|
-
return {
|
|
110
|
-
condition: {
|
|
111
|
-
lhs: node.lhs,
|
|
112
|
-
comparator: 'GTE',
|
|
113
|
-
rhs: { value: formatDate(startDate) }
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
case 'LT':
|
|
117
|
-
return {
|
|
118
|
-
condition: {
|
|
119
|
-
lhs: node.lhs,
|
|
120
|
-
comparator: 'LT',
|
|
121
|
-
rhs: { value: formatDate(startDate) }
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
case 'LTE':
|
|
125
|
-
return {
|
|
126
|
-
condition: {
|
|
127
|
-
lhs: node.lhs,
|
|
128
|
-
comparator: 'LTE',
|
|
129
|
-
rhs: { value: formatDate(endDate) }
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
case 'BTW':
|
|
133
|
-
case 'NOT_BTW':
|
|
134
|
-
return getConditionForBetweenComparator(formatDate(startDate), formatDate(endDate), node);
|
|
135
|
-
default:
|
|
136
|
-
return { condition: node };
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
function transformLeafCondition(node, fields, currentDateTime) {
|
|
140
|
-
const field = getItem(fields, node.lhs.field);
|
|
141
|
-
if (!field || !hasProp(field, 'type')) {
|
|
142
|
-
return { condition: node }; // Safety check
|
|
143
|
-
}
|
|
144
|
-
// Transform Relative date filters into equivalent date range filters
|
|
145
|
-
if (node.rhs && hasProp(node.rhs, 'relativeDate')) {
|
|
146
|
-
const { timePeriod, interval, datePart } = node.rhs.relativeDate;
|
|
147
|
-
const dayjsDatePart = dayjsDateParts[datePart];
|
|
148
|
-
const now = dayjs(currentDateTime);
|
|
149
|
-
let startDate = now;
|
|
150
|
-
let endDate = now;
|
|
151
|
-
if (timePeriod === 'CURRENT') {
|
|
152
|
-
startDate = now.startOf(dayjsDatePart);
|
|
153
|
-
endDate = now.endOf(dayjsDatePart);
|
|
154
|
-
}
|
|
155
|
-
else if (timePeriod === 'LAST' && interval && interval >= 1) {
|
|
156
|
-
startDate = now.subtract(interval, dayjsDatePart);
|
|
157
|
-
}
|
|
158
|
-
else if (timePeriod === 'PREVIOUS' && interval && interval >= 1) {
|
|
159
|
-
startDate = now.startOf(dayjsDatePart).subtract(interval, dayjsDatePart);
|
|
160
|
-
endDate = now.subtract(1, dayjsDatePart).endOf(dayjsDatePart);
|
|
161
|
-
}
|
|
162
|
-
else if (timePeriod === 'NEXT' && interval && interval >= 1) {
|
|
163
|
-
startDate = now.add(1, dayjsDatePart).startOf(dayjsDatePart);
|
|
164
|
-
endDate = now.endOf(dayjsDatePart).add(interval, dayjsDatePart);
|
|
165
|
-
}
|
|
166
|
-
return getConditionFromRange(startDate, endDate, node, field.type);
|
|
167
|
-
}
|
|
168
|
-
// Transform WEEKS-filters into equivalent date-range filters
|
|
169
|
-
// NOTE: This is a work-around until we make startOfDay customizable for Weeks
|
|
170
|
-
if (node.rhs && hasProp(node.rhs, 'dateFunction') && node.rhs.dateFunction === 'WEEKS') {
|
|
171
|
-
const startDate = dayjs(node.rhs.value); // Since we store it as YYYY-MM-DD, it's already the start of day
|
|
172
|
-
const endDate = startDate.add(6, 'day').endOf('day'); // Last millisecond on the 7th day from startDate
|
|
173
|
-
return getConditionFromRange(startDate, endDate, node, field.type);
|
|
174
|
-
}
|
|
175
|
-
// Transform double range comparators (BTW, NOT_BTW) into equivalent pair of single range comparators
|
|
176
|
-
if (node.rhs && hasProp(node.rhs, 'start')) {
|
|
177
|
-
if (field.type === 'NUMBER' || field.type === 'TIME_ONLY') {
|
|
178
|
-
return getConditionForBetweenComparator(node.rhs.start, node.rhs.end, node);
|
|
179
|
-
}
|
|
180
|
-
const startDate = dayjs(node.rhs.start);
|
|
181
|
-
const endDate = dayjs(node.rhs.end);
|
|
182
|
-
return getConditionFromRange(startDate, endDate, node, field.type);
|
|
183
|
-
}
|
|
184
|
-
// For all other cases
|
|
185
|
-
return { condition: node };
|
|
186
|
-
}
|
|
187
|
-
/** This function transforms Conditions with Relative Dates into Conditions with Date Ranges.
|
|
188
|
-
* Do not use this function unless you need to convert Relative Dates into Date Ranges.
|
|
189
|
-
*/
|
|
190
|
-
export default function transformComplexCondition(condition, fields, currentDateTime) {
|
|
191
|
-
if (hasProp(condition, 'AND')) {
|
|
192
|
-
const childNodes = condition.AND.map(n => transformComplexCondition(n, fields, currentDateTime));
|
|
193
|
-
return {
|
|
194
|
-
AND: childNodes
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
if (hasProp(condition, 'OR')) {
|
|
198
|
-
const childNodes = condition.OR.map(n => transformComplexCondition(n, fields, currentDateTime));
|
|
199
|
-
return {
|
|
200
|
-
OR: childNodes
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
if (hasProp(condition, 'NOT')) {
|
|
204
|
-
return {
|
|
205
|
-
NOT: transformComplexCondition(condition.NOT, fields, currentDateTime)
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
return transformLeafCondition(condition.condition, fields, currentDateTime);
|
|
209
|
-
}
|
|
210
|
-
//# sourceMappingURL=transformer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformer.js","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/core/transformer.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,OAAO,KAA2B,MAAM,OAAO,CAAC;AAChD,OAAO,eAAe,CAAC;AAEvB,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAIlD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlC,MAAM,cAAc,GAAgC;IAClD,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,QAAQ;IACjB,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,KAAK;IACX,KAAK,EAAE,MAAmB;IAC1B,QAAQ,EAAE,SAAS;IACnB,MAAM,EAAE,OAAO;IACf,KAAK,EAAE,MAAM;CACd,CAAC;AAEF,+EAA+E;AAC/E,SAAS,gCAAgC,CACvC,KAAsB,EACtB,GAAoB,EACpB,IAAmB;IAEnB,OAAO,IAAI,CAAC,UAAU,KAAK,KAAK;QAC9B,CAAC,CAAC;YACE,GAAG,EAAE;gBACH;oBACE,SAAS,E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AAO,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE;QAC7B,OAAO;YACL,GAAG,EAAE,yBAAyB,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,eAAe,CAAC;SACvE,CAAC;KACH;IAED,OAAO,sBAAsB,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["// cspell:words DDTHH\nimport dayjs, { QUnitType, Dayjs } from 'dayjs';\nimport './extendDayJs';\n\nimport { hasProp } from '@pega/cosmos-react-core';\n\nimport { Condition, LeafCondition, Field } from '../ConditionBuilder.types';\n\nimport { getItem } from './utils';\nimport { DatePart, FieldType } from './types';\n\nconst dayjsDateParts: Record<DatePart, QUnitType> = {\n SECONDS: 'second',\n MINUTES: 'minute',\n HOURS: 'hour',\n DAYS: 'day',\n WEEKS: 'week' as QUnitType,\n QUARTERS: 'quarter',\n MONTHS: 'month',\n YEARS: 'year'\n};\n\n/** Construct Condition with two range comparators based on the given bounds */\nfunction getConditionForBetweenComparator(\n start: string | number,\n end: string | number,\n node: LeafCondition\n): Condition {\n return node.comparator === 'BTW'\n ? {\n AND: [\n {\n condition: {\n lhs: node.lhs,\n comparator: 'GTE',\n rhs: { value: start }\n }\n },\n {\n condition: {\n lhs: node.lhs,\n comparator: 'LTE',\n rhs: { value: end }\n }\n }\n ]\n }\n : {\n OR: [\n {\n condition: {\n lhs: node.lhs,\n comparator: 'LT',\n rhs: { value: start }\n }\n },\n {\n condition: {\n lhs: node.lhs,\n comparator: 'GT',\n rhs: { value: end }\n }\n }\n ]\n };\n}\n\n/** Construct a date-range filter based on the given date bounds and the comparator */\nfunction getConditionFromRange(\n startDate: Dayjs,\n endDate: Dayjs,\n node: LeafCondition,\n lhsFieldType: FieldType\n): Condition {\n const formatDate = (d: Dayjs) => {\n return lhsFieldType === 'DATE_ONLY' ? d.format('YYYY-MM-DD') : d.format('YYYY-MM-DDTHH:mm:ss');\n };\n\n switch (node.comparator) {\n case 'EQ':\n return {\n AND: [\n {\n condition: {\n lhs: node.lhs,\n comparator: 'LTE',\n rhs: { value: formatDate(endDate) }\n }\n },\n {\n condition: {\n lhs: node.lhs,\n comparator: 'GTE',\n rhs: { value: formatDate(startDate) }\n }\n }\n ]\n };\n case 'NEQ':\n return {\n OR: [\n {\n condition: {\n lhs: node.lhs,\n comparator: 'GT',\n rhs: { value: formatDate(endDate) }\n }\n },\n {\n condition: {\n lhs: node.lhs,\n comparator: 'LT',\n rhs: { value: formatDate(startDate) }\n }\n }\n ]\n };\n case 'GT':\n return {\n condition: {\n lhs: node.lhs,\n comparator: 'GT',\n rhs: { value: formatDate(endDate) }\n }\n };\n case 'GTE':\n return {\n condition: {\n lhs: node.lhs,\n comparator: 'GTE',\n rhs: { value: formatDate(startDate) }\n }\n };\n case 'LT':\n return {\n condition: {\n lhs: node.lhs,\n comparator: 'LT',\n rhs: { value: formatDate(startDate) }\n }\n };\n case 'LTE':\n return {\n condition: {\n lhs: node.lhs,\n comparator: 'LTE',\n rhs: { value: formatDate(endDate) }\n }\n };\n case 'BTW':\n case 'NOT_BTW':\n return getConditionForBetweenComparator(formatDate(startDate), formatDate(endDate), node);\n default:\n return { condition: node };\n }\n}\n\nfunction transformLeafCondition(\n node: LeafCondition,\n fields: Field[],\n currentDateTime?: string\n): Condition {\n const field = getItem(fields, node.lhs.field);\n if (!field || !hasProp(field, 'type')) {\n return { condition: node }; // Safety check\n }\n\n // Transform Relative date filters into equivalent date range filters\n if (node.rhs && hasProp(node.rhs, 'relativeDate')) {\n const { timePeriod, interval, datePart } = node.rhs.relativeDate;\n const dayjsDatePart = dayjsDateParts[datePart];\n const now = dayjs(currentDateTime);\n\n let startDate = now;\n let endDate = now;\n if (timePeriod === 'CURRENT') {\n startDate = now.startOf(dayjsDatePart);\n endDate = now.endOf(dayjsDatePart);\n } else if (timePeriod === 'LAST' && interval && interval >= 1) {\n startDate = now.subtract(interval, dayjsDatePart);\n } else if (timePeriod === 'PREVIOUS' && interval && interval >= 1) {\n startDate = now.startOf(dayjsDatePart).subtract(interval, dayjsDatePart);\n endDate = now.subtract(1, dayjsDatePart).endOf(dayjsDatePart);\n } else if (timePeriod === 'NEXT' && interval && interval >= 1) {\n startDate = now.add(1, dayjsDatePart).startOf(dayjsDatePart);\n endDate = now.endOf(dayjsDatePart).add(interval, dayjsDatePart);\n }\n\n return getConditionFromRange(startDate, endDate, node, field.type);\n }\n\n // Transform WEEKS-filters into equivalent date-range filters\n // NOTE: This is a work-around until we make startOfDay customizable for Weeks\n if (node.rhs && hasProp(node.rhs, 'dateFunction') && node.rhs.dateFunction === 'WEEKS') {\n const startDate = dayjs(node.rhs.value); // Since we store it as YYYY-MM-DD, it's already the start of day\n const endDate = startDate.add(6, 'day').endOf('day'); // Last millisecond on the 7th day from startDate\n return getConditionFromRange(startDate, endDate, node, field.type);\n }\n\n // Transform double range comparators (BTW, NOT_BTW) into equivalent pair of single range comparators\n if (node.rhs && hasProp(node.rhs, 'start')) {\n if (field.type === 'NUMBER' || field.type === 'TIME_ONLY') {\n return getConditionForBetweenComparator(node.rhs.start, node.rhs.end, node);\n }\n\n const startDate = dayjs(node.rhs.start);\n const endDate = dayjs(node.rhs.end);\n return getConditionFromRange(startDate, endDate, node, field.type);\n }\n\n // For all other cases\n return { condition: node };\n}\n\n/** This function transforms Conditions with Relative Dates into Conditions with Date Ranges.\n * Do not use this function unless you need to convert Relative Dates into Date Ranges.\n */\nexport default function transformComplexCondition(\n condition: Condition,\n fields: Field[],\n currentDateTime?: string\n): Condition {\n if (hasProp(condition, 'AND')) {\n const childNodes: Condition[] = condition.AND.map(n =>\n transformComplexCondition(n, fields, currentDateTime)\n );\n return {\n AND: childNodes\n };\n }\n\n if (hasProp(condition, 'OR')) {\n const childNodes: Condition[] = condition.OR.map(n =>\n transformComplexCondition(n, fields, currentDateTime)\n );\n return {\n OR: childNodes\n };\n }\n\n if (hasProp(condition, 'NOT')) {\n return {\n NOT: transformComplexCondition(condition.NOT, fields, currentDateTime)\n };\n }\n\n return transformLeafCondition(condition.condition, fields, currentDateTime);\n}\n"]}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/** Supported field types */
|
|
2
|
-
export type FieldType = 'BOOLEAN' | 'TEXT' | 'NUMBER' | 'DATE_TIME' | 'DATE_ONLY' | 'TIME_ONLY';
|
|
3
|
-
type NullComparator = 'IS_NULL' | 'IS_NOT_NULL';
|
|
4
|
-
type EqualityComparator = 'EQ' | 'NEQ';
|
|
5
|
-
type RangeComparator = 'GT' | 'GTE' | 'LT' | 'LTE' | 'BTW' | 'NOT_BTW';
|
|
6
|
-
type TruenessComparator = 'IS_TRUE' | 'IS_FALSE';
|
|
7
|
-
type ListComparator = 'IN' | 'NOT_IN';
|
|
8
|
-
type TextMatchComparator = 'STARTS_WITH' | 'NOT_STARTS_WITH' | 'ENDS_WITH' | 'NOT_ENDS_WITH' | 'CONTAINS' | 'NOT_CONTAINS';
|
|
9
|
-
/** All supported Comparators */
|
|
10
|
-
export type Comparator = TruenessComparator | NullComparator | EqualityComparator | ListComparator | RangeComparator | TextMatchComparator;
|
|
11
|
-
/** Comparators supported for BOOLEAN fields */
|
|
12
|
-
type BooleanComparator = TruenessComparator | EqualityComparator | NullComparator;
|
|
13
|
-
/** Comparators supported for TEXT fields */
|
|
14
|
-
type TextComparator = EqualityComparator | ListComparator | TextMatchComparator | NullComparator;
|
|
15
|
-
/** Comparators supported for NUMBER fields */
|
|
16
|
-
type NumberComparator = EqualityComparator | ListComparator | RangeComparator | NullComparator;
|
|
17
|
-
/** Comparators supported for DATE_TIME/DATE_ONLY/TIME_ONLY fields */
|
|
18
|
-
type DateTimeComparator = EqualityComparator | RangeComparator | NullComparator;
|
|
19
|
-
/** Type definition to specify supported comparators by field-type */
|
|
20
|
-
export type ComparatorsByType = {
|
|
21
|
-
type: 'BOOLEAN';
|
|
22
|
-
comparators: BooleanComparator[];
|
|
23
|
-
} | {
|
|
24
|
-
type: 'TEXT';
|
|
25
|
-
comparators: TextComparator[];
|
|
26
|
-
} | {
|
|
27
|
-
type: 'NUMBER';
|
|
28
|
-
comparators: NumberComparator[];
|
|
29
|
-
} | {
|
|
30
|
-
type: 'DATE_TIME';
|
|
31
|
-
comparators: DateTimeComparator[];
|
|
32
|
-
} | {
|
|
33
|
-
type: 'DATE_ONLY';
|
|
34
|
-
comparators: DateTimeComparator[];
|
|
35
|
-
} | {
|
|
36
|
-
type: 'TIME_ONLY';
|
|
37
|
-
comparators: DateTimeComparator[];
|
|
38
|
-
};
|
|
39
|
-
export type RHSType = 'LITERAL' | 'FIELD' | 'DATE_FUNCTION' | 'RELATIVE_DATE' | 'PARAMETER';
|
|
40
|
-
/** Date function types supported on the RHS */
|
|
41
|
-
export type DateFunction = 'YEARS' | 'QUARTERS' | 'MONTHS' | 'WEEKS' | 'DAYS' | 'HOURS' | 'MINUTES' | 'SECONDS' | 'HOURS_OF_DAY' | 'MONTHS_OF_YEAR' | 'DAYS_OF_MONTH' | 'DAYS_OF_WEEK';
|
|
42
|
-
/** "Relative Date" Time Periods supported on the RHS */
|
|
43
|
-
export type TimePeriod = 'LAST' | 'PREVIOUS' | 'CURRENT' | 'NEXT';
|
|
44
|
-
/** "Relative Date" Date Parts supported on the RHS */
|
|
45
|
-
export type DatePart = 'SECONDS' | 'MINUTES' | 'HOURS' | 'DAYS' | 'WEEKS' | 'MONTHS' | 'QUARTERS' | 'YEARS';
|
|
46
|
-
export {};
|
|
47
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/core/types.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC;AAEhG,KAAK,cAAc,GAAG,SAAS,GAAG,aAAa,CAAC;AAChD,KAAK,kBAAkB,GAAG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E,GACxD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,kBAAkB,EAAE,CAAA;CAAE,CAAC;AAE7D,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,eAAe,GAAG,eAAe,GAAG,WAAW,CAAC;AAE5F,+CAA+C;AAC/C,MAAM,MAAM,YAAY,GACpB,OAAO,GACP,UAAU,GACV,QAAQ,GACR,OAAO,GACP,MAAM,GACN,OAAO,GACP,SAAS,GACT,SAAS,GACT,cAAc,GACd,gBAAgB,GAChB,eAAe,GACf,cAAc,CAAC;AAEnB,wDAAwD;AACxD,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC;AAElE,sDAAsD;AACtD,MAAM,MAAM,QAAQ,GAChB,SAAS,GACT,SAAS,GACT,OAAO,GACP,MAAM,GACN,OAAO,GACP,QAAQ,GACR,UAAU,GACV,OAAO,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/core/types.ts"],"names":[],"mappings":"","sourcesContent":["/** Supported field types */\nexport type FieldType = 'BOOLEAN' | 'TEXT' | 'NUMBER' | 'DATE_TIME' | 'DATE_ONLY' | 'TIME_ONLY';\n\ntype NullComparator = 'IS_NULL' | 'IS_NOT_NULL';\ntype EqualityComparator = 'EQ' | 'NEQ';\ntype RangeComparator = 'GT' | 'GTE' | 'LT' | 'LTE' | 'BTW' | 'NOT_BTW';\ntype TruenessComparator = 'IS_TRUE' | 'IS_FALSE';\ntype ListComparator = 'IN' | 'NOT_IN';\ntype TextMatchComparator =\n | 'STARTS_WITH'\n | 'NOT_STARTS_WITH'\n | 'ENDS_WITH'\n | 'NOT_ENDS_WITH'\n | 'CONTAINS'\n | 'NOT_CONTAINS';\n\n/** All supported Comparators */\nexport type Comparator =\n | TruenessComparator\n | NullComparator\n | EqualityComparator\n | ListComparator\n | RangeComparator\n | TextMatchComparator;\n\n/** Comparators supported for BOOLEAN fields */\ntype BooleanComparator = TruenessComparator | EqualityComparator | NullComparator;\n\n/** Comparators supported for TEXT fields */\ntype TextComparator = EqualityComparator | ListComparator | TextMatchComparator | NullComparator;\n\n/** Comparators supported for NUMBER fields */\ntype NumberComparator = EqualityComparator | ListComparator | RangeComparator | NullComparator;\n\n/** Comparators supported for DATE_TIME/DATE_ONLY/TIME_ONLY fields */\ntype DateTimeComparator = EqualityComparator | RangeComparator | NullComparator;\n\n/** Type definition to specify supported comparators by field-type */\nexport type ComparatorsByType =\n | { type: 'BOOLEAN'; comparators: BooleanComparator[] }\n | { type: 'TEXT'; comparators: TextComparator[] }\n | { type: 'NUMBER'; comparators: NumberComparator[] }\n | { type: 'DATE_TIME'; comparators: DateTimeComparator[] }\n | { type: 'DATE_ONLY'; comparators: DateTimeComparator[] }\n | { type: 'TIME_ONLY'; comparators: DateTimeComparator[] };\n\nexport type RHSType = 'LITERAL' | 'FIELD' | 'DATE_FUNCTION' | 'RELATIVE_DATE' | 'PARAMETER';\n\n/** Date function types supported on the RHS */\nexport type DateFunction =\n | 'YEARS'\n | 'QUARTERS'\n | 'MONTHS'\n | 'WEEKS'\n | 'DAYS'\n | 'HOURS'\n | 'MINUTES'\n | 'SECONDS'\n | 'HOURS_OF_DAY'\n | 'MONTHS_OF_YEAR'\n | 'DAYS_OF_MONTH'\n | 'DAYS_OF_WEEK';\n\n/** \"Relative Date\" Time Periods supported on the RHS */\nexport type TimePeriod = 'LAST' | 'PREVIOUS' | 'CURRENT' | 'NEXT';\n\n/** \"Relative Date\" Date Parts supported on the RHS */\nexport type DatePart =\n | 'SECONDS'\n | 'MINUTES'\n | 'HOURS'\n | 'DAYS'\n | 'WEEKS'\n | 'MONTHS'\n | 'QUARTERS'\n | 'YEARS';\n"]}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Condition, ConditionRow, LeafCondition, Field } from '../ConditionBuilder.types';
|
|
2
|
-
/** Parses a logic-expression into a condition object. */
|
|
3
|
-
export declare function parseLogicString(expression: string, conditionLookup: {
|
|
4
|
-
[label: string]: LeafCondition;
|
|
5
|
-
}, // To look up condition-rows from the labels
|
|
6
|
-
disallowNOT?: boolean, ignoreUnusedLabels?: boolean): {
|
|
7
|
-
condition: Condition;
|
|
8
|
-
} | {
|
|
9
|
-
error: string;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Takes a valid logic string and formats it with parentheses at appropriate places to keep things unambiguous
|
|
13
|
-
* For example, `1 AND 2 OR 3` is disambiguated as `(1 AND 2) OR 3`
|
|
14
|
-
* NOTE: This expects only valid logic strings to be passed as an input
|
|
15
|
-
*/
|
|
16
|
-
export declare function disambiguateLogic(expression: string): string;
|
|
17
|
-
/** Splits the input condition tree into a logic-string and a list of condition-rows */
|
|
18
|
-
export declare function splitConditionForBuilder(tree: Condition): {
|
|
19
|
-
logic: string;
|
|
20
|
-
rows: ConditionRow[];
|
|
21
|
-
};
|
|
22
|
-
/** Converts the input nested condition into a flat tree with the leaf-conditions and a logic string representing the input tree */
|
|
23
|
-
export declare function splitConditionTree(tree: Condition, labelPrefix?: string): {
|
|
24
|
-
logic: string;
|
|
25
|
-
conditions: {
|
|
26
|
-
[label: string]: LeafCondition;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
/** Checks if the input Condition is simple enough to be displayed in the `Basic mode` without loss of information */
|
|
30
|
-
export declare function isBasicModeApplicable(condition: Condition): boolean;
|
|
31
|
-
/** Returns a list of operators to show in the Basic mode, using a logicString as the input */
|
|
32
|
-
export declare function getBasicModeOperators(logic: string): ('AND' | 'OR')[];
|
|
33
|
-
/** Takes a list of operators from between the Basic mode rows and constructs a logic-string out of them */
|
|
34
|
-
export declare function getLogicFromBasicMode(operatorsList: ('AND' | 'OR')[]): string;
|
|
35
|
-
/** Takes a list of objects and id of the object to be found and recursively finds and returns the object */
|
|
36
|
-
export declare function getItem(items: Field[], id: string): Field | undefined;
|
|
37
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/core/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAiQ1F,yDAAyD;AACzD,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE,EAAE,4CAA4C;AACjG,WAAW,GAAE,OAAe,EAC5B,kBAAkB,GAAE,OAAe,GAClC;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAqB9C;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CA0D5D;AAkDD,uFAAuF;AACvF,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,SAAS,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,YAAY,EAAE,CAAA;CAAE,CAUjG;AAGD,mIAAmI;AACnI,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,SAAS,EACf,WAAW,GAAE,MAAW,GACvB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAA;KAAE,CAAA;CAAE,CAkBnE;AAED,qHAAqH;AACrH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAyBnE;AAED,8FAA8F;AAC9F,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAMrE;AAED,2GAA2G;AAC3G,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,CAAC,KAAK,GAAG,I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