@pega/cosmos-react-condition-builder 5.0.0-dev.4.6 → 5.0.0-dev.4.8

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.
Files changed (145) hide show
  1. package/package.json +2 -2
  2. package/lib/components/ConditionBuilder/AtomicCondition.d.ts +0 -57
  3. package/lib/components/ConditionBuilder/AtomicCondition.d.ts.map +0 -1
  4. package/lib/components/ConditionBuilder/AtomicCondition.js +0 -164
  5. package/lib/components/ConditionBuilder/AtomicCondition.js.map +0 -1
  6. package/lib/components/ConditionBuilder/ConditionBuilder.d.ts +0 -6
  7. package/lib/components/ConditionBuilder/ConditionBuilder.d.ts.map +0 -1
  8. package/lib/components/ConditionBuilder/ConditionBuilder.js +0 -271
  9. package/lib/components/ConditionBuilder/ConditionBuilder.js.map +0 -1
  10. package/lib/components/ConditionBuilder/ConditionBuilder.styles.d.ts +0 -7
  11. package/lib/components/ConditionBuilder/ConditionBuilder.styles.d.ts.map +0 -1
  12. package/lib/components/ConditionBuilder/ConditionBuilder.styles.js +0 -59
  13. package/lib/components/ConditionBuilder/ConditionBuilder.styles.js.map +0 -1
  14. package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts +0 -136
  15. package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts.map +0 -1
  16. package/lib/components/ConditionBuilder/ConditionBuilder.types.js +0 -2
  17. package/lib/components/ConditionBuilder/ConditionBuilder.types.js.map +0 -1
  18. package/lib/components/ConditionBuilder/FieldCondition.d.ts +0 -7
  19. package/lib/components/ConditionBuilder/FieldCondition.d.ts.map +0 -1
  20. package/lib/components/ConditionBuilder/FieldCondition.js +0 -26
  21. package/lib/components/ConditionBuilder/FieldCondition.js.map +0 -1
  22. package/lib/components/ConditionBuilder/FieldCondition.types.d.ts +0 -30
  23. package/lib/components/ConditionBuilder/FieldCondition.types.d.ts.map +0 -1
  24. package/lib/components/ConditionBuilder/FieldCondition.types.js +0 -2
  25. package/lib/components/ConditionBuilder/FieldCondition.types.js.map +0 -1
  26. package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.d.ts +0 -18
  27. package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.d.ts.map +0 -1
  28. package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.js +0 -155
  29. package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.js.map +0 -1
  30. package/lib/components/ConditionBuilder/RhsControls/FieldSelector.d.ts +0 -21
  31. package/lib/components/ConditionBuilder/RhsControls/FieldSelector.d.ts.map +0 -1
  32. package/lib/components/ConditionBuilder/RhsControls/FieldSelector.js +0 -60
  33. package/lib/components/ConditionBuilder/RhsControls/FieldSelector.js.map +0 -1
  34. package/lib/components/ConditionBuilder/RhsControls/NumericInput.d.ts +0 -18
  35. package/lib/components/ConditionBuilder/RhsControls/NumericInput.d.ts.map +0 -1
  36. package/lib/components/ConditionBuilder/RhsControls/NumericInput.js +0 -22
  37. package/lib/components/ConditionBuilder/RhsControls/NumericInput.js.map +0 -1
  38. package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.d.ts +0 -18
  39. package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.d.ts.map +0 -1
  40. package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.js +0 -119
  41. package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.js.map +0 -1
  42. package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.d.ts +0 -26
  43. package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.d.ts.map +0 -1
  44. package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.js +0 -156
  45. package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.js.map +0 -1
  46. package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.d.ts +0 -6
  47. package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.d.ts.map +0 -1
  48. package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.js +0 -112
  49. package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.js.map +0 -1
  50. package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.d.ts +0 -20
  51. package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.d.ts.map +0 -1
  52. package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.js +0 -12
  53. package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.js.map +0 -1
  54. package/lib/components/ConditionBuilder/RhsControls/ValueSelector.d.ts +0 -45
  55. package/lib/components/ConditionBuilder/RhsControls/ValueSelector.d.ts.map +0 -1
  56. package/lib/components/ConditionBuilder/RhsControls/ValueSelector.js +0 -196
  57. package/lib/components/ConditionBuilder/RhsControls/ValueSelector.js.map +0 -1
  58. package/lib/components/ConditionBuilder/RhsControls/index.d.ts +0 -42
  59. package/lib/components/ConditionBuilder/RhsControls/index.d.ts.map +0 -1
  60. package/lib/components/ConditionBuilder/RhsControls/index.js +0 -321
  61. package/lib/components/ConditionBuilder/RhsControls/index.js.map +0 -1
  62. package/lib/components/ConditionBuilder/core/comparators.d.ts +0 -12
  63. package/lib/components/ConditionBuilder/core/comparators.d.ts.map +0 -1
  64. package/lib/components/ConditionBuilder/core/comparators.js +0 -78
  65. package/lib/components/ConditionBuilder/core/comparators.js.map +0 -1
  66. package/lib/components/ConditionBuilder/core/evaluator.d.ts +0 -17
  67. package/lib/components/ConditionBuilder/core/evaluator.d.ts.map +0 -1
  68. package/lib/components/ConditionBuilder/core/evaluator.js +0 -314
  69. package/lib/components/ConditionBuilder/core/evaluator.js.map +0 -1
  70. package/lib/components/ConditionBuilder/core/extendDayJs.d.ts +0 -2
  71. package/lib/components/ConditionBuilder/core/extendDayJs.d.ts.map +0 -1
  72. package/lib/components/ConditionBuilder/core/extendDayJs.js +0 -4
  73. package/lib/components/ConditionBuilder/core/extendDayJs.js.map +0 -1
  74. package/lib/components/ConditionBuilder/core/formatter.d.ts +0 -17
  75. package/lib/components/ConditionBuilder/core/formatter.d.ts.map +0 -1
  76. package/lib/components/ConditionBuilder/core/formatter.js +0 -262
  77. package/lib/components/ConditionBuilder/core/formatter.js.map +0 -1
  78. package/lib/components/ConditionBuilder/core/rows-reducer.d.ts +0 -27
  79. package/lib/components/ConditionBuilder/core/rows-reducer.d.ts.map +0 -1
  80. package/lib/components/ConditionBuilder/core/rows-reducer.js +0 -50
  81. package/lib/components/ConditionBuilder/core/rows-reducer.js.map +0 -1
  82. package/lib/components/ConditionBuilder/core/time-utils.d.ts +0 -5
  83. package/lib/components/ConditionBuilder/core/time-utils.d.ts.map +0 -1
  84. package/lib/components/ConditionBuilder/core/time-utils.js +0 -23
  85. package/lib/components/ConditionBuilder/core/time-utils.js.map +0 -1
  86. package/lib/components/ConditionBuilder/core/transformer.d.ts +0 -7
  87. package/lib/components/ConditionBuilder/core/transformer.d.ts.map +0 -1
  88. package/lib/components/ConditionBuilder/core/transformer.js +0 -210
  89. package/lib/components/ConditionBuilder/core/transformer.js.map +0 -1
  90. package/lib/components/ConditionBuilder/core/types.d.ts +0 -47
  91. package/lib/components/ConditionBuilder/core/types.d.ts.map +0 -1
  92. package/lib/components/ConditionBuilder/core/types.js +0 -2
  93. package/lib/components/ConditionBuilder/core/types.js.map +0 -1
  94. package/lib/components/ConditionBuilder/core/utils.d.ts +0 -37
  95. package/lib/components/ConditionBuilder/core/utils.d.ts.map +0 -1
  96. package/lib/components/ConditionBuilder/core/utils.js +0 -454
  97. package/lib/components/ConditionBuilder/core/utils.js.map +0 -1
  98. package/lib/components/ConditionBuilder/index.d.ts +0 -11
  99. package/lib/components/ConditionBuilder/index.d.ts.map +0 -1
  100. package/lib/components/ConditionBuilder/index.js +0 -8
  101. package/lib/components/ConditionBuilder/index.js.map +0 -1
  102. package/lib/components/ConditionInput/ConditionInput.d.ts +0 -6
  103. package/lib/components/ConditionInput/ConditionInput.d.ts.map +0 -1
  104. package/lib/components/ConditionInput/ConditionInput.js +0 -302
  105. package/lib/components/ConditionInput/ConditionInput.js.map +0 -1
  106. package/lib/components/ConditionInput/ConditionInput.styles.d.ts +0 -5
  107. package/lib/components/ConditionInput/ConditionInput.styles.d.ts.map +0 -1
  108. package/lib/components/ConditionInput/ConditionInput.styles.js +0 -27
  109. package/lib/components/ConditionInput/ConditionInput.styles.js.map +0 -1
  110. package/lib/components/ConditionInput/ConditionInput.types.d.ts +0 -32
  111. package/lib/components/ConditionInput/ConditionInput.types.d.ts.map +0 -1
  112. package/lib/components/ConditionInput/ConditionInput.types.js +0 -2
  113. package/lib/components/ConditionInput/ConditionInput.types.js.map +0 -1
  114. package/lib/components/ConditionInput/index.d.ts +0 -3
  115. package/lib/components/ConditionInput/index.d.ts.map +0 -1
  116. package/lib/components/ConditionInput/index.js +0 -2
  117. package/lib/components/ConditionInput/index.js.map +0 -1
  118. package/lib/components/ConditionInput/utils.d.ts +0 -17
  119. package/lib/components/ConditionInput/utils.d.ts.map +0 -1
  120. package/lib/components/ConditionInput/utils.js +0 -121
  121. package/lib/components/ConditionInput/utils.js.map +0 -1
  122. package/lib/components/PromotedFilters/ConditionSelector.d.ts +0 -31
  123. package/lib/components/PromotedFilters/ConditionSelector.d.ts.map +0 -1
  124. package/lib/components/PromotedFilters/ConditionSelector.js +0 -44
  125. package/lib/components/PromotedFilters/ConditionSelector.js.map +0 -1
  126. package/lib/components/PromotedFilters/PromotedFilters.d.ts +0 -11
  127. package/lib/components/PromotedFilters/PromotedFilters.d.ts.map +0 -1
  128. package/lib/components/PromotedFilters/PromotedFilters.js +0 -153
  129. package/lib/components/PromotedFilters/PromotedFilters.js.map +0 -1
  130. package/lib/components/PromotedFilters/PromotedFilters.styles.d.ts +0 -4
  131. package/lib/components/PromotedFilters/PromotedFilters.styles.d.ts.map +0 -1
  132. package/lib/components/PromotedFilters/PromotedFilters.styles.js +0 -38
  133. package/lib/components/PromotedFilters/PromotedFilters.styles.js.map +0 -1
  134. package/lib/components/PromotedFilters/PromotedFilters.types.d.ts +0 -33
  135. package/lib/components/PromotedFilters/PromotedFilters.types.d.ts.map +0 -1
  136. package/lib/components/PromotedFilters/PromotedFilters.types.js +0 -2
  137. package/lib/components/PromotedFilters/PromotedFilters.types.js.map +0 -1
  138. package/lib/components/PromotedFilters/index.d.ts +0 -3
  139. package/lib/components/PromotedFilters/index.d.ts.map +0 -1
  140. package/lib/components/PromotedFilters/index.js +0 -2
  141. package/lib/components/PromotedFilters/index.js.map +0 -1
  142. package/lib/index.d.ts +0 -7
  143. package/lib/index.d.ts.map +0 -1
  144. package/lib/index.js +0 -8
  145. package/lib/index.js.map +0 -1
@@ -1,262 +0,0 @@
1
- // cspell:words LPAREN RPAREN
2
- // FIXME: TR (Several constructs in this file need to be localized)
3
- import { formatDateTime, hasProp, isValidDate, parseToDate } from '@pega/cosmos-react-core';
4
- import { getFormattedValue } from '@pega/cosmos-react-core/lib/components/Number/utils';
5
- import { getDayOfWeekNamesMap, getQuarter } from '@pega/cosmos-react-core/lib/components/DateTime/Input/utils';
6
- import { getItem } from './utils';
7
- const LPAREN = '(';
8
- const RPAREN = ')';
9
- export function formatRelativeDate(translate, timePeriod, datePart, interval) {
10
- const translationKey = timePeriod === 'CURRENT'
11
- ? `condition_builder_current_${datePart.toLowerCase().slice(0, -1)}`
12
- : `condition_builder_${timePeriod.toLowerCase()}_X_${datePart.toLowerCase()}`;
13
- return translate(translationKey, [interval ?? 0], {
14
- count: interval ?? 0
15
- });
16
- }
17
- function formatLiteralValue(type, rhsValue, locale, translate) {
18
- switch (type) {
19
- case 'TIME_ONLY':
20
- // For these cases, rhs.value is stored as # of milliseconds since day-start
21
- return (rhsValue || rhsValue === 0) && isValidDate(parseToDate(rhsValue))
22
- ? formatDateTime(parseToDate(rhsValue), {
23
- t: translate,
24
- locale,
25
- format: 'long',
26
- variant: 'time',
27
- timeZone: 'UTC'
28
- })
29
- : '';
30
- case 'DATE_ONLY':
31
- // For these cases, rhs.value is stored as # of milliseconds since day-start
32
- return (rhsValue || rhsValue === 0) && isValidDate(parseToDate(rhsValue))
33
- ? formatDateTime(parseToDate(rhsValue), {
34
- t: translate,
35
- locale,
36
- format: 'numeric',
37
- variant: 'date',
38
- timeZone: 'UTC'
39
- })
40
- : '';
41
- case 'DATE_TIME':
42
- // For these cases, rhs.value is stored as # of milliseconds since day-start
43
- return (rhsValue || rhsValue === 0) && isValidDate(parseToDate(rhsValue))
44
- ? formatDateTime(parseToDate(rhsValue), {
45
- t: translate,
46
- locale,
47
- format: 'numeric',
48
- variant: 'datetime',
49
- timeZone: 'UTC'
50
- })
51
- : '';
52
- case 'NUMBER':
53
- return getFormattedValue(rhsValue.toString(), locale, undefined, {
54
- useGrouping: true
55
- });
56
- break;
57
- default:
58
- return rhsValue.toString();
59
- }
60
- }
61
- /** Returns a user-friendly text representation of a given leaf condition */
62
- function formatLeafCondition(leaf, fields, translate, { locale = 'en-US', omitLhs = false } = {}) {
63
- const { lhs, comparator, rhs } = leaf;
64
- // Determine texts for LHS and RHS
65
- const lhsField = getItem(fields, lhs.field); // Expecting valid inputs
66
- const lhsText = omitLhs ? '' : `${lhsField.primary} `;
67
- let rhsText = '';
68
- if (!hasProp(lhsField, 'type'))
69
- return '';
70
- if (rhs) {
71
- if (hasProp(rhs, 'field')) {
72
- // If RHS is another field
73
- const rhsField = getItem(fields, rhs.field); // Expecting valid inputs
74
- rhsText = rhsField.primary;
75
- }
76
- else if (hasProp(rhs, 'value')) {
77
- if (hasProp(rhs, 'dateFunction')) {
78
- // If RHS is a date function value
79
- switch (rhs.dateFunction) {
80
- case 'YEARS':
81
- rhsText = new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {
82
- year: 'numeric'
83
- });
84
- break;
85
- case 'QUARTERS': {
86
- const formattedYear = new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {
87
- year: 'numeric'
88
- });
89
- const quarterNumber = getQuarter(rhs.value);
90
- rhsText = `${translate(`date_quarter_q${quarterNumber}`, [formattedYear])}`;
91
- break;
92
- }
93
- case 'MONTHS':
94
- rhsText = new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {
95
- year: 'numeric',
96
- month: 'short'
97
- });
98
- break;
99
- case 'WEEKS':
100
- rhsText = `Week of ${new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {
101
- year: 'numeric',
102
- month: 'short',
103
- day: 'numeric'
104
- })}`;
105
- break;
106
- case 'DAYS':
107
- rhsText = new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {
108
- year: 'numeric',
109
- month: 'short',
110
- day: 'numeric'
111
- });
112
- break;
113
- case 'HOURS':
114
- rhsText = new Date(rhs.value).toLocaleString(locale, {
115
- year: 'numeric',
116
- month: 'short',
117
- day: 'numeric',
118
- hour: 'numeric',
119
- hour12: true
120
- });
121
- break;
122
- case 'MINUTES':
123
- rhsText = new Date(rhs.value).toLocaleString(locale, {
124
- year: 'numeric',
125
- month: 'short',
126
- day: 'numeric',
127
- hour: 'numeric',
128
- hour12: true,
129
- minute: 'numeric'
130
- });
131
- break;
132
- case 'SECONDS':
133
- rhsText = new Date(rhs.value).toLocaleString(locale, {
134
- year: 'numeric',
135
- month: 'short',
136
- day: 'numeric',
137
- hour: 'numeric',
138
- hour12: true,
139
- minute: 'numeric',
140
- second: 'numeric'
141
- });
142
- break;
143
- case 'MONTHS_OF_YEAR':
144
- rhsText = new Date(2021, rhs.value - 1, 1).toLocaleString(locale, {
145
- month: 'long'
146
- });
147
- break;
148
- case 'HOURS_OF_DAY':
149
- rhsText = `Hour ${rhs.value} of day`;
150
- break;
151
- case 'DAYS_OF_MONTH':
152
- rhsText = `Day ${rhs.value} of month`;
153
- break;
154
- case 'DAYS_OF_WEEK': {
155
- const dayOfWeekOptions = getDayOfWeekNamesMap();
156
- rhsText = dayOfWeekOptions[Number(rhs.value)];
157
- break;
158
- }
159
- default: // Not needed
160
- }
161
- }
162
- else {
163
- // If RHS is a single literal value
164
- rhsText = formatLiteralValue(lhsField.type, rhs.value, locale, translate);
165
- }
166
- }
167
- else if (hasProp(rhs, 'relativeDate')) {
168
- const { relativeDate: { timePeriod, interval, datePart } } = rhs;
169
- rhsText = formatRelativeDate(translate, timePeriod, datePart, interval);
170
- }
171
- else if (hasProp(rhs, 'parameterId')) {
172
- const parameterValue = lhsField.parameters?.find(item => item.id === rhs.parameterId);
173
- rhsText = parameterValue?.primary ?? '';
174
- }
175
- else if (hasProp(rhs, 'values')) {
176
- rhsText = rhs.values.join(', ');
177
- }
178
- else if (hasProp(rhs, 'start')) {
179
- const startValue = formatLiteralValue(lhsField.type, rhs.start, locale, translate);
180
- const endValue = formatLiteralValue(lhsField.type, rhs.end, locale, translate);
181
- rhsText = `${startValue} - ${endValue}`;
182
- }
183
- }
184
- switch (comparator) {
185
- case 'IS_NULL':
186
- return `${lhsText}is null`;
187
- case 'IS_NOT_NULL':
188
- return `${lhsText}is not null`;
189
- case 'IS_TRUE':
190
- return `${lhsText}is true`;
191
- case 'IS_FALSE':
192
- return `${lhsText}is false`;
193
- case 'EQ':
194
- return `${lhsText}is ${rhsText}`;
195
- case 'NEQ':
196
- return `${lhsText}isn't ${rhsText}`;
197
- case 'IN':
198
- return `${lhsText}is among ${rhsText}`;
199
- case 'NOT_IN':
200
- return `${lhsText}is not among ${rhsText}`;
201
- case 'GT':
202
- return `${lhsText}> ${rhsText}`;
203
- case 'GTE':
204
- return `${lhsText}>= ${rhsText}`;
205
- case 'LT':
206
- return `${lhsText}< ${rhsText}`;
207
- case 'LTE':
208
- return `${lhsText}<= ${rhsText}`;
209
- case 'BTW':
210
- return `${lhsText}is between ${rhsText}`;
211
- case 'NOT_BTW':
212
- return `${lhsText}is not between ${rhsText}`;
213
- case 'STARTS_WITH':
214
- return `${lhsText}starts with ${rhsText}`;
215
- case 'NOT_STARTS_WITH':
216
- return `${lhsText}doesn't start with ${rhsText}`;
217
- case 'ENDS_WITH':
218
- return `${lhsText}ends with ${rhsText}`;
219
- case 'NOT_ENDS_WITH':
220
- return `${lhsText}doesn't end with ${rhsText}`;
221
- case 'CONTAINS':
222
- return `${lhsText}contains ${rhsText}`;
223
- case 'NOT_CONTAINS':
224
- return `${lhsText}doesn't contain ${rhsText}`;
225
- default:
226
- return ''; // Not needed
227
- }
228
- }
229
- /** Returns a user-friendly text representation of the given node in a condition */
230
- function formatConditionNode(node, fields, translate, options) {
231
- if (hasProp(node, 'AND')) {
232
- const childStrings = node.AND.map(n => formatConditionNode(n, fields, translate, options));
233
- return `(${childStrings.join(' AND ')})`;
234
- }
235
- if (hasProp(node, 'OR')) {
236
- const childStrings = node.OR.map(n => formatConditionNode(n, fields, translate, options));
237
- return `(${childStrings.join(' OR ')})`;
238
- }
239
- if (hasProp(node, 'NOT')) {
240
- const childString = formatConditionNode(node.NOT, fields, translate, options);
241
- if (childString.startsWith(LPAREN) && childString.endsWith(RPAREN)) {
242
- // Avoid double brackets when the child node is an AND/OR node
243
- return `NOT ${childString}`;
244
- }
245
- return `NOT (${childString})`;
246
- }
247
- return formatLeafCondition(node.condition, fields, translate, options); // If leaf-level is reached
248
- }
249
- /**
250
- * Returns a user-friendly text representation of a given complex condition
251
- * The input `fields` are used to look up display labels for the fields
252
- */
253
- export default function formatCondition(condition, fields, translate, options) {
254
- // Recursively format the tree, starting at the root node
255
- let text = formatConditionNode(condition, fields, translate, options);
256
- // If the root node is AND/OR, there will be extra parentheses. Remove them
257
- if (text.startsWith(LPAREN) && text.endsWith(RPAREN)) {
258
- text = text.slice(1, -1);
259
- }
260
- return text;
261
- }
262
- //# sourceMappingURL=formatter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/core/formatter.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,mEAAmE;AACnE,OAAO,EACL,cAAc,EACd,OAAO,EACP,WAAW,EACX,WAAW,EAEZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAExF,OAAO,EACL,oBAAoB,EACpB,UAAU,EACX,MAAM,6DAA6D,CAAC;AAIrE,OAAO,EAAE,OAAO,EAA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E,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;QAC1F,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;KACzC;IAED,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE;QACxB,MAAM,WAAW,GAAG,mBAAmB,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAC9E,IAAI,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YAClE,8DAA8D;YAC9D,OAAO,OAAO,WAAW,EAAE,CAAC;SAC7B;QACD,OAAO,QAAQ,WAAW,GAAG,CAAC;KAC/B;IAED,OAAO,mBAAmB,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,2BAA2B;AACrG,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,SAAoB,EACpB,MAAe,EACf,SAA+C,EAC/C,OAAgC;IAEhC,yDAAyD;IACzD,IAAI,IAAI,GAAG,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAEtE,2EAA2E;IAC3E,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACpD,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KAC1B;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["// cspell:words LPAREN RPAREN\n// FIXME: TR (Several constructs in this file need to be localized)\nimport {\n formatDateTime,\n hasProp,\n isValidDate,\n parseToDate,\n TranslationPack\n} from '@pega/cosmos-react-core';\nimport { getFormattedValue } from '@pega/cosmos-react-core/lib/components/Number/utils';\nimport { TranslationFunction } from '@pega/cosmos-react-core/lib/i18n/translate';\nimport {\n getDayOfWeekNamesMap,\n getQuarter\n} from '@pega/cosmos-react-core/lib/components/DateTime/Input/utils';\n\nimport { Condition, LeafCondition, Field } from '../ConditionBuilder.types';\n\nimport { getItem } from './utils';\nimport { DatePart, FieldType, TimePeriod } from './types';\n\nconst LPAREN = '(';\nconst RPAREN = ')';\n\n/** Options object optionally passed to formatCondition method. */\ninterface ConditionFormatOptions {\n locale?: string;\n omitLhs?: boolean;\n}\n\nexport function formatRelativeDate(\n translate: TranslationFunction<TranslationPack>,\n timePeriod: TimePeriod,\n datePart: DatePart,\n interval?: number\n): string {\n const translationKey =\n timePeriod === 'CURRENT'\n ? `condition_builder_current_${datePart.toLowerCase().slice(0, -1)}`\n : `condition_builder_${timePeriod.toLowerCase()}_X_${datePart.toLowerCase()}`;\n return translate(translationKey as keyof TranslationPack, [interval ?? 0], {\n count: interval ?? 0\n });\n}\n\nfunction formatLiteralValue(\n type: FieldType,\n rhsValue: string | number,\n locale: string,\n translate: TranslationFunction<TranslationPack>\n): string {\n switch (type) {\n case 'TIME_ONLY':\n // For these cases, rhs.value is stored as # of milliseconds since day-start\n return (rhsValue || rhsValue === 0) && isValidDate(parseToDate(rhsValue))\n ? formatDateTime(parseToDate(rhsValue), {\n t: translate,\n locale,\n format: 'long',\n variant: 'time',\n timeZone: 'UTC'\n })\n : '';\n case 'DATE_ONLY':\n // For these cases, rhs.value is stored as # of milliseconds since day-start\n return (rhsValue || rhsValue === 0) && isValidDate(parseToDate(rhsValue))\n ? formatDateTime(parseToDate(rhsValue), {\n t: translate,\n locale,\n format: 'numeric',\n variant: 'date',\n timeZone: 'UTC'\n })\n : '';\n case 'DATE_TIME':\n // For these cases, rhs.value is stored as # of milliseconds since day-start\n return (rhsValue || rhsValue === 0) && isValidDate(parseToDate(rhsValue))\n ? formatDateTime(parseToDate(rhsValue), {\n t: translate,\n locale,\n format: 'numeric',\n variant: 'datetime',\n timeZone: 'UTC'\n })\n : '';\n case 'NUMBER':\n return getFormattedValue(rhsValue.toString(), locale, undefined, {\n useGrouping: true\n });\n break;\n default:\n return rhsValue.toString();\n }\n}\n\n/** Returns a user-friendly text representation of a given leaf condition */\nfunction formatLeafCondition(\n leaf: LeafCondition,\n fields: Field[],\n translate: TranslationFunction<TranslationPack>,\n { locale = 'en-US', omitLhs = false }: ConditionFormatOptions = {}\n): string {\n const { lhs, comparator, rhs } = leaf;\n\n // Determine texts for LHS and RHS\n const lhsField = getItem(fields, lhs.field) as Field; // Expecting valid inputs\n const lhsText = omitLhs ? '' : `${lhsField.primary} `;\n let rhsText = '';\n if (!hasProp(lhsField, 'type')) return '';\n if (rhs) {\n if (hasProp(rhs, 'field')) {\n // If RHS is another field\n const rhsField = getItem(fields, rhs.field) as Field; // Expecting valid inputs\n rhsText = rhsField.primary;\n } else if (hasProp(rhs, 'value')) {\n if (hasProp(rhs, 'dateFunction')) {\n // If RHS is a date function value\n switch (rhs.dateFunction) {\n case 'YEARS':\n rhsText = new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {\n year: 'numeric'\n });\n break;\n case 'QUARTERS': {\n const formattedYear = new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {\n year: 'numeric'\n });\n const quarterNumber = getQuarter(rhs.value);\n rhsText = `${translate(`date_quarter_q${quarterNumber}`, [formattedYear])}`;\n break;\n }\n case 'MONTHS':\n rhsText = new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {\n year: 'numeric',\n month: 'short'\n });\n break;\n case 'WEEKS':\n rhsText = `Week of ${new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {\n year: 'numeric',\n month: 'short',\n day: 'numeric'\n })}`;\n break;\n case 'DAYS':\n rhsText = new Date(`${rhs.value}T00:00:00`).toLocaleString(locale, {\n year: 'numeric',\n month: 'short',\n day: 'numeric'\n });\n break;\n case 'HOURS':\n rhsText = new Date(rhs.value).toLocaleString(locale, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n hour: 'numeric',\n hour12: true\n });\n break;\n case 'MINUTES':\n rhsText = new Date(rhs.value).toLocaleString(locale, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n hour: 'numeric',\n hour12: true,\n minute: 'numeric'\n });\n break;\n case 'SECONDS':\n rhsText = new Date(rhs.value).toLocaleString(locale, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n hour: 'numeric',\n hour12: true,\n minute: 'numeric',\n second: 'numeric'\n });\n break;\n case 'MONTHS_OF_YEAR':\n rhsText = new Date(2021, (rhs.value as number) - 1, 1).toLocaleString(locale, {\n month: 'long'\n });\n break;\n case 'HOURS_OF_DAY':\n rhsText = `Hour ${rhs.value} of day`;\n break;\n case 'DAYS_OF_MONTH':\n rhsText = `Day ${rhs.value} of month`;\n break;\n case 'DAYS_OF_WEEK': {\n const dayOfWeekOptions = getDayOfWeekNamesMap();\n rhsText = dayOfWeekOptions[Number(rhs.value)];\n break;\n }\n default: // Not needed\n }\n } else {\n // If RHS is a single literal value\n rhsText = formatLiteralValue(lhsField.type, rhs.value, locale, translate);\n }\n } else if (hasProp(rhs, 'relativeDate')) {\n const {\n relativeDate: { timePeriod, interval, datePart }\n } = rhs;\n rhsText = formatRelativeDate(translate, timePeriod, datePart, interval);\n } else if (hasProp(rhs, 'parameterId')) {\n const parameterValue = lhsField.parameters?.find(item => item.id === rhs.parameterId);\n rhsText = parameterValue?.primary ?? '';\n } else if (hasProp(rhs, 'values')) {\n rhsText = rhs.values.join(', ');\n } else if (hasProp(rhs, 'start')) {\n const startValue = formatLiteralValue(lhsField.type, rhs.start, locale, translate);\n const endValue = formatLiteralValue(lhsField.type, rhs.end, locale, translate);\n\n rhsText = `${startValue} - ${endValue}`;\n }\n }\n\n switch (comparator) {\n case 'IS_NULL':\n return `${lhsText}is null`;\n case 'IS_NOT_NULL':\n return `${lhsText}is not null`;\n case 'IS_TRUE':\n return `${lhsText}is true`;\n case 'IS_FALSE':\n return `${lhsText}is false`;\n case 'EQ':\n return `${lhsText}is ${rhsText}`;\n case 'NEQ':\n return `${lhsText}isn't ${rhsText}`;\n case 'IN':\n return `${lhsText}is among ${rhsText}`;\n case 'NOT_IN':\n return `${lhsText}is not among ${rhsText}`;\n case 'GT':\n return `${lhsText}> ${rhsText}`;\n case 'GTE':\n return `${lhsText}>= ${rhsText}`;\n case 'LT':\n return `${lhsText}< ${rhsText}`;\n case 'LTE':\n return `${lhsText}<= ${rhsText}`;\n case 'BTW':\n return `${lhsText}is between ${rhsText}`;\n case 'NOT_BTW':\n return `${lhsText}is not between ${rhsText}`;\n case 'STARTS_WITH':\n return `${lhsText}starts with ${rhsText}`;\n case 'NOT_STARTS_WITH':\n return `${lhsText}doesn't start with ${rhsText}`;\n case 'ENDS_WITH':\n return `${lhsText}ends with ${rhsText}`;\n case 'NOT_ENDS_WITH':\n return `${lhsText}doesn't end with ${rhsText}`;\n case 'CONTAINS':\n return `${lhsText}contains ${rhsText}`;\n case 'NOT_CONTAINS':\n return `${lhsText}doesn't contain ${rhsText}`;\n default:\n return ''; // Not needed\n }\n}\n\n/** Returns a user-friendly text representation of the given node in a condition */\nfunction formatConditionNode(\n node: Condition,\n fields: Field[],\n translate: TranslationFunction<TranslationPack>,\n options?: ConditionFormatOptions\n): string {\n if (hasProp(node, 'AND')) {\n const childStrings = node.AND.map(n => formatConditionNode(n, fields, translate, options));\n return `(${childStrings.join(' AND ')})`;\n }\n\n if (hasProp(node, 'OR')) {\n const childStrings = node.OR.map(n => formatConditionNode(n, fields, translate, options));\n return `(${childStrings.join(' OR ')})`;\n }\n\n if (hasProp(node, 'NOT')) {\n const childString = formatConditionNode(node.NOT, fields, translate, options);\n if (childString.startsWith(LPAREN) && childString.endsWith(RPAREN)) {\n // Avoid double brackets when the child node is an AND/OR node\n return `NOT ${childString}`;\n }\n return `NOT (${childString})`;\n }\n\n return formatLeafCondition(node.condition, fields, translate, options); // If leaf-level is reached\n}\n\n/**\n * Returns a user-friendly text representation of a given complex condition\n * The input `fields` are used to look up display labels for the fields\n */\nexport default function formatCondition(\n condition: Condition,\n fields: Field[],\n translate: TranslationFunction<TranslationPack>,\n options?: ConditionFormatOptions\n): string {\n // Recursively format the tree, starting at the root node\n let text = formatConditionNode(condition, fields, translate, options);\n\n // If the root node is AND/OR, there will be extra parentheses. Remove them\n if (text.startsWith(LPAREN) && text.endsWith(RPAREN)) {\n text = text.slice(1, -1);\n }\n\n return text;\n}\n"]}
@@ -1,27 +0,0 @@
1
- import { ConditionRow } from '../ConditionBuilder.types';
2
- export declare const INSERT_ROW = "INSERT_ROW";
3
- export declare const UPDATE_ROW = "UPDATE_ROW";
4
- export declare const REMOVE_ROW = "REMOVE_ROW";
5
- interface InsertAction {
6
- type: 'INSERT_ROW';
7
- payload: {
8
- insertAt: number;
9
- };
10
- }
11
- interface UpdateAction {
12
- type: 'UPDATE_ROW';
13
- payload: {
14
- updateAt: number;
15
- newRow: ConditionRow;
16
- };
17
- }
18
- interface RemoveAction {
19
- type: 'REMOVE_ROW';
20
- payload: {
21
- removeAt: number;
22
- };
23
- }
24
- type RowAction = InsertAction | UpdateAction | RemoveAction;
25
- export default function rowsReducer(rows: ConditionRow[], action: RowAction): ConditionRow[];
26
- export {};
27
- //# sourceMappingURL=rows-reducer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rows-reducer.d.ts","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/core/rows-reducer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAazD,eAAO,MAAM,UAAU,eAAe,CAAC;AACvC,eAAO,MAAM,UAAU,eAAe,CAAC;AACvC,eAAO,MAAM,UAAU,eAAe,CAAC;AAGvC,UAAU,YAAY;IACpB,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/B;AACD,UAAU,YAAY;IACpB,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE;QACP,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,YAAY,CAAC;KACtB,CAAC;CACH;AACD,UAAU,YAAY;IACpB,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/B;AACD,KAAK,SAAS,GAAG,YAAY,GAAG,YAAY,GAAG,YAAY,CAAC;AAG5D,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,SAAS,GAAG,YAAY,EAAE,CAoC3F"}
@@ -1,50 +0,0 @@
1
- import { createUID } from '@pega/cosmos-react-core';
2
- // Returns a new empty condition row
3
- const getNewRow = () => {
4
- return {
5
- id: createUID(),
6
- label: '',
7
- comparator: 'IS_NOT_NULL',
8
- lhs: { field: '' }
9
- };
10
- };
11
- // Action types as variables. Helps avoid errors due to typos
12
- export const INSERT_ROW = 'INSERT_ROW';
13
- export const UPDATE_ROW = 'UPDATE_ROW';
14
- export const REMOVE_ROW = 'REMOVE_ROW';
15
- // Reducer for the condition rows
16
- export default function rowsReducer(rows, action) {
17
- switch (action.type) {
18
- // Insert an empty condition at the given index
19
- case INSERT_ROW: {
20
- const { insertAt } = action.payload;
21
- const newRows = [...rows.slice(0, insertAt), getNewRow(), ...rows.slice(insertAt)];
22
- newRows.forEach((row, index) => {
23
- // Update `label`s to have intuitive row-labels. NOTE: The logicString is updated separately for the label-change
24
- row.label = `${index + 1}`;
25
- });
26
- return newRows;
27
- }
28
- // Update existing condition at the given index
29
- case UPDATE_ROW: {
30
- const { updateAt, newRow } = action.payload;
31
- return [...rows.slice(0, updateAt), newRow, ...rows.slice(updateAt + 1)];
32
- }
33
- // Remove existing condition at the given index
34
- case REMOVE_ROW: {
35
- const { removeAt } = action.payload;
36
- const newRows = [...rows.slice(0, removeAt), ...rows.slice(removeAt + 1)];
37
- if (newRows.length === 0) {
38
- newRows.push(getNewRow()); // Ensure that there is always at least one row
39
- }
40
- newRows.forEach((row, index) => {
41
- // Update `label`s to have intuitive row-labels. NOTE: The logicString is updated separately for the label-change
42
- row.label = `${index + 1}`;
43
- });
44
- return newRows;
45
- }
46
- default:
47
- return rows;
48
- }
49
- }
50
- //# sourceMappingURL=rows-reducer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rows-reducer.js","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/core/rows-reducer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAIpD,oCAAoC;AACpC,MAAM,SAAS,GAAG,GAAiB,EAAE;IACnC,OAAO;QACL,EAAE,EAAE,SAAS,EAAE;QACf,KAAK,EAAE,EAAE;QACT,UAAU,EAAE,aAAa;QACzB,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;KACnB,CAAC;AACJ,CAAC,CAAC;AAEF,6DAA6D;AAC7D,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC;AACvC,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC;AACvC,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC;AAoBvC,iCAAiC;AACjC,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAoB,EAAE,MAAiB;IACzE,QAAQ,MAAM,CAAC,IAAI,EAAE;QACnB,+CAA+C;QAC/C,KAAK,UAAU,CAAC,CAAC;YACf,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;YACpC,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,SAAS,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;YACnF,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;gBAC7B,iHAAiH;gBACjH,GAAG,CAAC,KAAK,GAAG,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC;YAC7B,CAAC,CAAC,CAAC;YACH,OAAO,OAAO,CAAC;SAChB;QAED,+CAA+C;QAC/C,KAAK,UAAU,CAAC,CAAC;YACf,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;YAC5C,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;SAC1E;QAED,+CAA+C;QAC/C,KAAK,UAAU,CAAC,CAAC;YACf,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;YACpC,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;YAC1E,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;gBACxB,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,+CAA+C;aAC3E;YACD,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;gBAC7B,iHAAiH;gBACjH,GAAG,CAAC,KAAK,GAAG,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC;YAC7B,CAAC,CAAC,CAAC;YACH,OAAO,OAAO,CAAC;SAChB;QAED;YACE,OAAO,IAAI,CAAC;KACf;AACH,CAAC","sourcesContent":["import { createUID } from '@pega/cosmos-react-core';\n\nimport { ConditionRow } from '../ConditionBuilder.types';\n\n// Returns a new empty condition row\nconst getNewRow = (): ConditionRow => {\n return {\n id: createUID(),\n label: '',\n comparator: 'IS_NOT_NULL',\n lhs: { field: '' }\n };\n};\n\n// Action types as variables. Helps avoid errors due to typos\nexport const INSERT_ROW = 'INSERT_ROW';\nexport const UPDATE_ROW = 'UPDATE_ROW';\nexport const REMOVE_ROW = 'REMOVE_ROW';\n\n// Set up the reducer action-type as a union of different possible actions\ninterface InsertAction {\n type: 'INSERT_ROW'; // String-literal type to force a single value\n payload: { insertAt: number };\n}\ninterface UpdateAction {\n type: 'UPDATE_ROW'; // String-literal type to force a single value\n payload: {\n updateAt: number;\n newRow: ConditionRow;\n };\n}\ninterface RemoveAction {\n type: 'REMOVE_ROW'; // String-literal type to force a single value\n payload: { removeAt: number };\n}\ntype RowAction = InsertAction | UpdateAction | RemoveAction;\n\n// Reducer for the condition rows\nexport default function rowsReducer(rows: ConditionRow[], action: RowAction): ConditionRow[] {\n switch (action.type) {\n // Insert an empty condition at the given index\n case INSERT_ROW: {\n const { insertAt } = action.payload;\n const newRows = [...rows.slice(0, insertAt), getNewRow(), ...rows.slice(insertAt)];\n newRows.forEach((row, index) => {\n // Update `label`s to have intuitive row-labels. NOTE: The logicString is updated separately for the label-change\n row.label = `${index + 1}`;\n });\n return newRows;\n }\n\n // Update existing condition at the given index\n case UPDATE_ROW: {\n const { updateAt, newRow } = action.payload;\n return [...rows.slice(0, updateAt), newRow, ...rows.slice(updateAt + 1)];\n }\n\n // Remove existing condition at the given index\n case REMOVE_ROW: {\n const { removeAt } = action.payload;\n const newRows = [...rows.slice(0, removeAt), ...rows.slice(removeAt + 1)];\n if (newRows.length === 0) {\n newRows.push(getNewRow()); // Ensure that there is always at least one row\n }\n newRows.forEach((row, index) => {\n // Update `label`s to have intuitive row-labels. NOTE: The logicString is updated separately for the label-change\n row.label = `${index + 1}`;\n });\n return newRows;\n }\n\n default:\n return rows;\n }\n}\n"]}
@@ -1,5 +0,0 @@
1
- /** Converts an `hh:mm:ss` value into the number of milliseconds since 00:00:00 */
2
- export declare function convertTimeValueToMs(value: string): number;
3
- /** Converts a milliseconds value into an `hh:mm:ss` format */
4
- export declare function convertMsToTimeValue(value: number): string;
5
- //# sourceMappingURL=time-utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"time-utils.d.ts","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/core/time-utils.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ1D;AAED,8DAA8D;AAC9D,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAa1D"}
@@ -1,23 +0,0 @@
1
- /** Converts an `hh:mm:ss` value into the number of milliseconds since 00:00:00 */
2
- export function convertTimeValueToMs(value) {
3
- // Determine the different time components
4
- const hh = Number(value.slice(0, 2));
5
- const mm = Number(value.slice(3, 5));
6
- const ss = Number(value.slice(6, 8));
7
- // Return the number of seconds since 00:00:00
8
- return hh * 60 * 60 * 1000 + mm * 60 * 1000 + ss * 1000;
9
- }
10
- /** Converts a milliseconds value into an `hh:mm:ss` format */
11
- export function convertMsToTimeValue(value) {
12
- // Determine the different time components
13
- const hours = Math.floor(value / (60 * 60 * 1000));
14
- value -= hours * 60 * 60 * 1000;
15
- const minutes = Math.floor(value / (60 * 1000));
16
- value -= minutes * 60 * 1000;
17
- const seconds = Math.floor(value / 1000);
18
- const hh = hours.toString().padStart(2, '0');
19
- const mm = minutes.toString().padStart(2, '0');
20
- const ss = seconds.toString().padStart(2, '0');
21
- return `${hh}:${mm}:${ss}`;
22
- }
23
- //# sourceMappingURL=time-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"time-utils.js","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/core/time-utils.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,0CAA0C;IAC1C,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACrC,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACrC,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAErC,8CAA8C;IAC9C,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,IAAI,CAAC;AAC1D,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,0CAA0C;IAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;IACnD,KAAK,IAAI,KAAK,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAChC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;IAChD,KAAK,IAAI,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC;IAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;IAEzC,MAAM,EAAE,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC7C,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC/C,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAE/C,OAAO,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["/** Converts an `hh:mm:ss` value into the number of milliseconds since 00:00:00 */\nexport function convertTimeValueToMs(value: string): number {\n // Determine the different time components\n const hh = Number(value.slice(0, 2));\n const mm = Number(value.slice(3, 5));\n const ss = Number(value.slice(6, 8));\n\n // Return the number of seconds since 00:00:00\n return hh * 60 * 60 * 1000 + mm * 60 * 1000 + ss * 1000;\n}\n\n/** Converts a milliseconds value into an `hh:mm:ss` format */\nexport function convertMsToTimeValue(value: number): string {\n // Determine the different time components\n const hours = Math.floor(value / (60 * 60 * 1000));\n value -= hours * 60 * 60 * 1000;\n const minutes = Math.floor(value / (60 * 1000));\n value -= minutes * 60 * 1000;\n const seconds = Math.floor(value / 1000);\n\n const hh = hours.toString().padStart(2, '0');\n const mm = minutes.toString().padStart(2, '0');\n const ss = seconds.toString().padStart(2, '0');\n\n return `${hh}:${mm}:${ss}`;\n}\n"]}
@@ -1,7 +0,0 @@
1
- import './extendDayJs';
2
- import { Condition, Field } from '../ConditionBuilder.types';
3
- /** This function transforms Conditions with Relative Dates into Conditions with Date Ranges.
4
- * Do not use this function unless you need to convert Relative Dates into Date Ranges.
5
- */
6
- export default function transformComplexCondition(condition: Condition, fields: Field[], currentDateTime?: string): Condition;
7
- //# sourceMappingURL=transformer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/core/transformer.ts"],"names":[],"mappings":"AAEA,OAAO,eAAe,CAAC;AAIvB,OAAO,EAAE,SAAS,EAAiB,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAgN5E;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,KAAK,EAAE,EACf,eAAe,CAAC,EAAE,MAAM,GACvB,SAAS,CA0BX"}