@praxisui/core 10.0.0-rc.7 → 10.0.0-rc.71
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/README.md +519 -13
- package/ai/component-registry.json +521 -372
- package/fesm2022/praxisui-core-micro-visualization.mjs +212 -0
- package/fesm2022/praxisui-core-schema.mjs +3545 -602
- package/fesm2022/praxisui-core.mjs +92118 -49298
- package/package.json +5 -1
- package/theme-bridge.css +268 -9
- package/theming/_micro-visualization.scss +103 -0
- package/theming/_theming.scss +382 -102
- package/theming/index.scss +1 -0
- package/theming/workspace-themes.scss +519 -0
- package/types/praxisui-core-micro-visualization.d.ts +70 -0
- package/types/praxisui-core-schema.d.ts +1083 -170
- package/types/praxisui-core.d.ts +19507 -11422
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
|
|
1
3
|
function normalizeFieldAccessMetadata(value) {
|
|
2
4
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
3
5
|
return undefined;
|
|
@@ -88,6 +90,14 @@ const VISUALIZATION_KINDS = new Set([
|
|
|
88
90
|
'bullet',
|
|
89
91
|
'delta',
|
|
90
92
|
'processFlow',
|
|
93
|
+
'waterfall',
|
|
94
|
+
]);
|
|
95
|
+
const WATERFALL_ROLES = new Set([
|
|
96
|
+
'start',
|
|
97
|
+
'increase',
|
|
98
|
+
'decrease',
|
|
99
|
+
'subtotal',
|
|
100
|
+
'total',
|
|
91
101
|
]);
|
|
92
102
|
const VISUALIZATION_SURFACES = new Set([
|
|
93
103
|
'table-cell',
|
|
@@ -111,6 +121,10 @@ const VISUALIZATION_TONES = new Set([
|
|
|
111
121
|
'danger',
|
|
112
122
|
'critical',
|
|
113
123
|
]);
|
|
124
|
+
const VISUALIZATION_SCALE_SCOPES = new Set([
|
|
125
|
+
'row',
|
|
126
|
+
'page',
|
|
127
|
+
]);
|
|
114
128
|
const TABLE_SAFE_KINDS = new Set([
|
|
115
129
|
'line',
|
|
116
130
|
'area',
|
|
@@ -122,6 +136,7 @@ const TABLE_SAFE_KINDS = new Set([
|
|
|
122
136
|
'bullet',
|
|
123
137
|
'delta',
|
|
124
138
|
'processFlow',
|
|
139
|
+
'waterfall',
|
|
125
140
|
]);
|
|
126
141
|
const TABLE_CELL_RECOMMENDED_KINDS = new Set([
|
|
127
142
|
'delta',
|
|
@@ -143,7 +158,7 @@ function getPraxisTableCellVisualizationConstraint(kind) {
|
|
|
143
158
|
return 'row-density';
|
|
144
159
|
if (kind === 'processFlow')
|
|
145
160
|
return 'step-labels';
|
|
146
|
-
if (kind === 'line' || kind === 'area' || kind === 'column') {
|
|
161
|
+
if (kind === 'line' || kind === 'area' || kind === 'column' || kind === 'waterfall') {
|
|
147
162
|
return 'horizontal-space';
|
|
148
163
|
}
|
|
149
164
|
return null;
|
|
@@ -163,8 +178,8 @@ function resolvePraxisMicroVisualizationTone(value, thresholds, fallbackTone) {
|
|
|
163
178
|
if (value === undefined || value === null || !Array.isArray(thresholds) || thresholds.length === 0) {
|
|
164
179
|
return fallbackTone ? { tone: fallbackTone } : undefined;
|
|
165
180
|
}
|
|
166
|
-
const num =
|
|
167
|
-
const isNum =
|
|
181
|
+
const num = toFiniteNumber(value);
|
|
182
|
+
const isNum = num !== undefined;
|
|
168
183
|
// 1. Pass 1: Correspondencia discreta (equals) tem prioridade maxima
|
|
169
184
|
for (const t of thresholds) {
|
|
170
185
|
if (!t || !t.tone || t.equals === undefined) {
|
|
@@ -173,7 +188,8 @@ function resolvePraxisMicroVisualizationTone(value, thresholds, fallbackTone) {
|
|
|
173
188
|
if (t.equals === value || String(t.equals) === String(value)) {
|
|
174
189
|
return { tone: t.tone, label: t.label, matchedThreshold: t };
|
|
175
190
|
}
|
|
176
|
-
|
|
191
|
+
const eqNum = toFiniteNumber(t.equals);
|
|
192
|
+
if (isNum && eqNum !== undefined && eqNum === num) {
|
|
177
193
|
return { tone: t.tone, label: t.label, matchedThreshold: t };
|
|
178
194
|
}
|
|
179
195
|
}
|
|
@@ -207,6 +223,317 @@ function resolvePraxisMicroVisualizationTone(value, thresholds, fallbackTone) {
|
|
|
207
223
|
}
|
|
208
224
|
return fallbackTone ? { tone: fallbackTone } : undefined;
|
|
209
225
|
}
|
|
226
|
+
const STACKED_BAR_TONE_PAINT = {
|
|
227
|
+
info: 'var(--prx-micro-tone-info, var(--p-table-state-info-fg, var(--md-sys-color-primary, #0a6eb4)))',
|
|
228
|
+
success: 'var(--prx-micro-tone-success, var(--p-table-state-success-fg, #1b7a43))',
|
|
229
|
+
warning: 'var(--prx-micro-tone-warning, var(--p-table-state-warning-fg, #92400e))',
|
|
230
|
+
danger: 'var(--prx-micro-tone-danger, var(--p-table-state-danger-fg, var(--md-sys-color-error, #c62828)))',
|
|
231
|
+
critical: 'var(--prx-micro-tone-critical, var(--prx-micro-tone-danger, var(--p-table-state-danger-fg, var(--md-sys-color-error, #9f1239))))',
|
|
232
|
+
neutral: 'var(--prx-micro-tone-neutral, var(--md-sys-color-secondary, #5c6b73))',
|
|
233
|
+
};
|
|
234
|
+
function normalizePraxisHexColor(value) {
|
|
235
|
+
if (typeof value !== 'string') {
|
|
236
|
+
return undefined;
|
|
237
|
+
}
|
|
238
|
+
const trimmed = value.trim();
|
|
239
|
+
const match = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(trimmed);
|
|
240
|
+
if (!match) {
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
const raw = match[1].toLowerCase();
|
|
244
|
+
if (raw.length === 3) {
|
|
245
|
+
return `#${raw[0]}${raw[0]}${raw[1]}${raw[1]}${raw[2]}${raw[2]}`;
|
|
246
|
+
}
|
|
247
|
+
return `#${raw}`;
|
|
248
|
+
}
|
|
249
|
+
function getPraxisStackedBarPaintStyle(segment, fallbackTone = 'neutral') {
|
|
250
|
+
const hex = normalizePraxisHexColor(segment?.color);
|
|
251
|
+
const resolvedTone = normalizeEnum$1(segment?.tone, VISUALIZATION_TONES) ??
|
|
252
|
+
normalizeEnum$1(fallbackTone, VISUALIZATION_TONES) ??
|
|
253
|
+
'neutral';
|
|
254
|
+
const paint = hex ?? STACKED_BAR_TONE_PAINT[resolvedTone];
|
|
255
|
+
return {
|
|
256
|
+
'--prx-micro-category-color': paint,
|
|
257
|
+
color: paint,
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function isVisualizationEntrySuppressed(entry) {
|
|
261
|
+
if (!entry || typeof entry !== 'object') {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
const obj = entry;
|
|
265
|
+
return (obj.suppressed === true
|
|
266
|
+
|| obj.privacySuppressed === true
|
|
267
|
+
|| (obj.value === null && obj.state === 'suppressed'));
|
|
268
|
+
}
|
|
269
|
+
function countSuppressedEntries(entries) {
|
|
270
|
+
if (!Array.isArray(entries)) {
|
|
271
|
+
return 0;
|
|
272
|
+
}
|
|
273
|
+
let count = 0;
|
|
274
|
+
for (const entry of entries) {
|
|
275
|
+
if (isVisualizationEntrySuppressed(entry)) {
|
|
276
|
+
count += 1;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return count;
|
|
280
|
+
}
|
|
281
|
+
function resolvePreservedSuppressedCount(value) {
|
|
282
|
+
return typeof value === 'number' && Number.isFinite(value) && value > 0
|
|
283
|
+
? Math.trunc(value)
|
|
284
|
+
: 0;
|
|
285
|
+
}
|
|
286
|
+
function resolvePraxisStackedBarSegments(visualization) {
|
|
287
|
+
if (!visualization || visualization.kind !== 'stackedBar') {
|
|
288
|
+
return [];
|
|
289
|
+
}
|
|
290
|
+
if (Array.isArray(visualization.segments) && visualization.segments.length > 0) {
|
|
291
|
+
return visualization.segments.filter((seg) => !isVisualizationEntrySuppressed(seg));
|
|
292
|
+
}
|
|
293
|
+
if (Array.isArray(visualization.items) && visualization.items.length > 0) {
|
|
294
|
+
const mapped = [];
|
|
295
|
+
for (let i = 0; i < visualization.items.length; i++) {
|
|
296
|
+
if (!Object.prototype.hasOwnProperty.call(visualization.items, i)) {
|
|
297
|
+
return [];
|
|
298
|
+
}
|
|
299
|
+
const item = visualization.items[i];
|
|
300
|
+
if (!item) {
|
|
301
|
+
return [];
|
|
302
|
+
}
|
|
303
|
+
if (isVisualizationEntrySuppressed(item)) {
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
if (typeof item.value !== 'number' || !Number.isFinite(item.value) || item.value < 0) {
|
|
307
|
+
return [];
|
|
308
|
+
}
|
|
309
|
+
const hex = normalizePraxisHexColor(item.color);
|
|
310
|
+
mapped.push({
|
|
311
|
+
value: item.value,
|
|
312
|
+
...(item.label ? { label: item.label } : {}),
|
|
313
|
+
...(item.tone ? { tone: item.tone } : {}),
|
|
314
|
+
...(hex ? { color: hex } : {}),
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
return mapped;
|
|
318
|
+
}
|
|
319
|
+
return [];
|
|
320
|
+
}
|
|
321
|
+
function resolvePraxisStackedBarTotal(segments, explicitTotal) {
|
|
322
|
+
if (typeof explicitTotal === 'number' && Number.isFinite(explicitTotal) && explicitTotal >= 0) {
|
|
323
|
+
return explicitTotal;
|
|
324
|
+
}
|
|
325
|
+
return compensatedSum(segments.map((segment) => segment.value));
|
|
326
|
+
}
|
|
327
|
+
function computePraxisStackedBarSegmentWidthPct(value, resolvedTotal) {
|
|
328
|
+
if (!Number.isFinite(value) || value <= 0 || !Number.isFinite(resolvedTotal) || resolvedTotal <= 0) {
|
|
329
|
+
return 0;
|
|
330
|
+
}
|
|
331
|
+
return Math.max(0, Math.min(100, (value / resolvedTotal) * 100));
|
|
332
|
+
}
|
|
333
|
+
function formatPraxisStackedBarPercentage(value, resolvedTotal, locale) {
|
|
334
|
+
const pct = computePraxisStackedBarSegmentWidthPct(value, resolvedTotal);
|
|
335
|
+
const maximumFractionDigits = pct === 0 ? 0 : pct < 0.1 ? 3 : pct < 1 ? 2 : 1;
|
|
336
|
+
return `${new Intl.NumberFormat(locale || undefined, { maximumFractionDigits }).format(pct)}%`;
|
|
337
|
+
}
|
|
338
|
+
function resolvePraxisStackedBarAriaLabel(visualization, segments, resolvedTotal, locale) {
|
|
339
|
+
if (visualization.ariaLabel) {
|
|
340
|
+
return visualization.ariaLabel;
|
|
341
|
+
}
|
|
342
|
+
if (segments.length > 0 &&
|
|
343
|
+
segments.every((segment) => typeof segment.label === 'string' && segment.label.trim().length > 0)) {
|
|
344
|
+
const prefix = visualization.title || visualization.fallbackText;
|
|
345
|
+
const summary = segments
|
|
346
|
+
.map((segment) => `${segment.label} ${formatPraxisStackedBarPercentage(segment.value, resolvedTotal, locale)}`)
|
|
347
|
+
.join(', ');
|
|
348
|
+
return `${prefix}: ${summary}`;
|
|
349
|
+
}
|
|
350
|
+
return visualization.fallbackText;
|
|
351
|
+
}
|
|
352
|
+
function compensatedSum(values) {
|
|
353
|
+
let sum = 0;
|
|
354
|
+
let compensation = 0;
|
|
355
|
+
for (let i = 0; i < values.length; i++) {
|
|
356
|
+
const value = values[i];
|
|
357
|
+
const next = sum + value;
|
|
358
|
+
if (Math.abs(sum) >= Math.abs(value)) {
|
|
359
|
+
compensation += (sum - next) + value;
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
compensation += (value - next) + sum;
|
|
363
|
+
}
|
|
364
|
+
sum = next;
|
|
365
|
+
}
|
|
366
|
+
return sum + compensation;
|
|
367
|
+
}
|
|
368
|
+
function normalizeStackedBarDistribution(value, surface) {
|
|
369
|
+
const isTableCell = surface === 'table-cell';
|
|
370
|
+
const hasSegmentsProp = value.segments !== undefined;
|
|
371
|
+
const hasItemsProp = value.items !== undefined;
|
|
372
|
+
const hasExplicitTotalProp = Object.prototype.hasOwnProperty.call(value, 'total') &&
|
|
373
|
+
value.total !== undefined &&
|
|
374
|
+
value.total !== null;
|
|
375
|
+
const hasDeferredExpr = Boolean(normalizeExpression(value.segmentsExpr, 'segmentsExpr') ||
|
|
376
|
+
normalizeExpression(value.itemsExpr, 'itemsExpr'));
|
|
377
|
+
const rawTitle = isTableCell ? undefined : normalizeText$1(value.title);
|
|
378
|
+
if (!hasSegmentsProp && !hasItemsProp) {
|
|
379
|
+
const explicitTotal = hasExplicitTotalProp ? toFiniteNumber(value.total) : undefined;
|
|
380
|
+
const validDeferredTotal = !hasExplicitTotalProp || (explicitTotal !== undefined && explicitTotal >= 0);
|
|
381
|
+
if (!validDeferredTotal) {
|
|
382
|
+
return {
|
|
383
|
+
valid: false,
|
|
384
|
+
...(typeof value.legend === 'boolean' ? { legend: false } : {}),
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
if (!isTableCell && value.legend === true && !hasDeferredExpr) {
|
|
388
|
+
return {
|
|
389
|
+
valid: false,
|
|
390
|
+
legend: false,
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
return {
|
|
394
|
+
valid: hasDeferredExpr,
|
|
395
|
+
...(explicitTotal !== undefined ? { total: explicitTotal } : {}),
|
|
396
|
+
...(rawTitle && hasDeferredExpr ? { title: rawTitle } : {}),
|
|
397
|
+
...(typeof value.legend === 'boolean'
|
|
398
|
+
? { legend: isTableCell ? false : value.legend }
|
|
399
|
+
: {}),
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
const rawEntries = hasSegmentsProp ? value.segments : value.items;
|
|
403
|
+
if (!Array.isArray(rawEntries) || rawEntries.length === 0) {
|
|
404
|
+
return {
|
|
405
|
+
valid: false,
|
|
406
|
+
...(typeof value.legend === 'boolean' ? { legend: false } : {}),
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
const parsedSegments = [];
|
|
410
|
+
const parsedItems = [];
|
|
411
|
+
const preservedSuppressedCount = resolvePreservedSuppressedCount(value.suppressedCount);
|
|
412
|
+
let suppressedCount = 0;
|
|
413
|
+
for (let i = 0; i < rawEntries.length; i++) {
|
|
414
|
+
if (!Object.prototype.hasOwnProperty.call(rawEntries, i)) {
|
|
415
|
+
return {
|
|
416
|
+
valid: false,
|
|
417
|
+
...(typeof value.legend === 'boolean' ? { legend: false } : {}),
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
const rawEntry = rawEntries[i];
|
|
421
|
+
if (typeof rawEntry === 'number' || typeof rawEntry === 'string') {
|
|
422
|
+
const num = toFiniteNumber(rawEntry);
|
|
423
|
+
if (num === undefined || num < 0) {
|
|
424
|
+
return {
|
|
425
|
+
valid: false,
|
|
426
|
+
...(typeof value.legend === 'boolean' ? { legend: false } : {}),
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
parsedSegments.push({ value: num });
|
|
430
|
+
parsedItems.push({ value: num });
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
if (!rawEntry || typeof rawEntry !== 'object') {
|
|
434
|
+
return {
|
|
435
|
+
valid: false,
|
|
436
|
+
...(typeof value.legend === 'boolean' ? { legend: false } : {}),
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
const entryObj = rawEntry;
|
|
440
|
+
if (isVisualizationEntrySuppressed(entryObj)) {
|
|
441
|
+
suppressedCount += 1;
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
const num = toFiniteNumber(entryObj.value);
|
|
445
|
+
if (num === undefined || num < 0) {
|
|
446
|
+
return {
|
|
447
|
+
valid: false,
|
|
448
|
+
...(typeof value.legend === 'boolean' ? { legend: false } : {}),
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
const key = normalizeText$1(entryObj.key);
|
|
452
|
+
const label = normalizeText$1(entryObj.label);
|
|
453
|
+
const entryTone = normalizeEnum$1(entryObj.tone, VISUALIZATION_TONES);
|
|
454
|
+
const entryColor = normalizePraxisHexColor(entryObj.color);
|
|
455
|
+
const active = entryObj.active === true;
|
|
456
|
+
const id = normalizeText$1(entryObj.id);
|
|
457
|
+
const icon = normalizeText$1(entryObj.icon);
|
|
458
|
+
const state = normalizeText$1(entryObj.state);
|
|
459
|
+
parsedSegments.push({
|
|
460
|
+
...(key ? { key } : {}),
|
|
461
|
+
value: num,
|
|
462
|
+
...(label ? { label } : {}),
|
|
463
|
+
...(entryTone ? { tone: entryTone } : {}),
|
|
464
|
+
...(entryColor ? { color: entryColor } : {}),
|
|
465
|
+
...(active ? { active: true } : {}),
|
|
466
|
+
});
|
|
467
|
+
parsedItems.push({
|
|
468
|
+
value: num,
|
|
469
|
+
...(id ? { id } : {}),
|
|
470
|
+
...(label ? { label } : {}),
|
|
471
|
+
...(icon ? { icon } : {}),
|
|
472
|
+
...(state ? { state } : {}),
|
|
473
|
+
...(entryTone ? { tone: entryTone } : {}),
|
|
474
|
+
...(entryColor ? { color: entryColor } : {}),
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
const effectiveSuppressedCount = Math.max(preservedSuppressedCount, suppressedCount);
|
|
478
|
+
if (parsedSegments.length === 0) {
|
|
479
|
+
return {
|
|
480
|
+
valid: false,
|
|
481
|
+
...(effectiveSuppressedCount > 0 ? { suppressedCount: effectiveSuppressedCount } : {}),
|
|
482
|
+
...(typeof value.legend === 'boolean' ? { legend: false } : {}),
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
const sum = compensatedSum(parsedSegments.map((entry) => entry.value));
|
|
486
|
+
if (!Number.isFinite(sum) || sum < 0) {
|
|
487
|
+
return {
|
|
488
|
+
valid: false,
|
|
489
|
+
...(typeof value.legend === 'boolean' ? { legend: false } : {}),
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
let validatedTotal;
|
|
493
|
+
if (hasExplicitTotalProp) {
|
|
494
|
+
const explicitTotal = toFiniteNumber(value.total);
|
|
495
|
+
if (explicitTotal === undefined || !Number.isFinite(explicitTotal) || explicitTotal < 0) {
|
|
496
|
+
return {
|
|
497
|
+
valid: false,
|
|
498
|
+
...(typeof value.legend === 'boolean' ? { legend: false } : {}),
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
if (explicitTotal === 0 && sum > 0) {
|
|
502
|
+
return {
|
|
503
|
+
valid: false,
|
|
504
|
+
...(typeof value.legend === 'boolean' ? { legend: false } : {}),
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
if (explicitTotal > 0) {
|
|
508
|
+
const tolerance = Math.max(4, parsedSegments.length) * Number.EPSILON * Math.max(sum, explicitTotal);
|
|
509
|
+
if (sum - explicitTotal > tolerance) {
|
|
510
|
+
return {
|
|
511
|
+
valid: false,
|
|
512
|
+
...(typeof value.legend === 'boolean' ? { legend: false } : {}),
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
validatedTotal = explicitTotal;
|
|
517
|
+
}
|
|
518
|
+
const normalizedLegend = typeof value.legend === 'boolean' ? (isTableCell ? false : value.legend) : undefined;
|
|
519
|
+
if (!isTableCell && normalizedLegend === true) {
|
|
520
|
+
const allLabeled = parsedSegments.every((entry) => typeof entry.label === 'string' && entry.label.length > 0);
|
|
521
|
+
if (!allLabeled) {
|
|
522
|
+
return {
|
|
523
|
+
valid: false,
|
|
524
|
+
legend: false,
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
return {
|
|
529
|
+
valid: true,
|
|
530
|
+
...(hasSegmentsProp ? { segments: parsedSegments } : { items: parsedItems }),
|
|
531
|
+
...(validatedTotal !== undefined ? { total: validatedTotal } : {}),
|
|
532
|
+
...(effectiveSuppressedCount > 0 ? { suppressedCount: effectiveSuppressedCount } : {}),
|
|
533
|
+
...(rawTitle ? { title: rawTitle } : {}),
|
|
534
|
+
...(normalizedLegend !== undefined ? { legend: normalizedLegend } : {}),
|
|
535
|
+
};
|
|
536
|
+
}
|
|
210
537
|
function normalizePraxisPresentationVisualization(value) {
|
|
211
538
|
if (!value || typeof value !== 'object') {
|
|
212
539
|
return undefined;
|
|
@@ -218,23 +545,30 @@ function normalizePraxisPresentationVisualization(value) {
|
|
|
218
545
|
}
|
|
219
546
|
const surface = normalizeEnum$1(value.surface, VISUALIZATION_SURFACES);
|
|
220
547
|
const size = normalizeEnum$1(value.size, VISUALIZATION_SIZES);
|
|
548
|
+
const scaleScope = normalizeEnum$1(value.scaleScope, VISUALIZATION_SCALE_SCOPES);
|
|
221
549
|
const tone = normalizeEnum$1(value.tone, VISUALIZATION_TONES);
|
|
222
550
|
const ariaLabel = normalizeText$1(value.ariaLabel);
|
|
223
551
|
const valueSuffix = normalizeText$1(value.valueSuffix);
|
|
552
|
+
const normalizedTargetLabel = normalizeText$1(value.targetLabel);
|
|
224
553
|
const thresholdsObj = normalizeThresholds(value.thresholds);
|
|
554
|
+
const isTableCell = surface === 'table-cell';
|
|
555
|
+
const normalizedPointsObj = normalizePoints(value.points);
|
|
225
556
|
let resolvedTone = tone;
|
|
226
557
|
let resolvedAriaLabel = ariaLabel;
|
|
227
558
|
if (!resolvedTone && thresholdsObj?.thresholds?.length) {
|
|
228
559
|
let evalVal = value.value;
|
|
229
|
-
if (evalVal === undefined &&
|
|
230
|
-
|
|
231
|
-
if (last && typeof last === 'object' && Number.isFinite(last.value)) {
|
|
232
|
-
evalVal = last.value;
|
|
233
|
-
}
|
|
560
|
+
if (evalVal === undefined && normalizedPointsObj?.points?.length) {
|
|
561
|
+
evalVal = normalizedPointsObj.points[normalizedPointsObj.points.length - 1].value;
|
|
234
562
|
}
|
|
235
563
|
else if (Array.isArray(evalVal) && evalVal.length > 0) {
|
|
236
|
-
const
|
|
237
|
-
|
|
564
|
+
const visibleVals = evalVal.filter((entry) => !isVisualizationEntrySuppressed(entry));
|
|
565
|
+
if (visibleVals.length > 0) {
|
|
566
|
+
const last = visibleVals[visibleVals.length - 1];
|
|
567
|
+
evalVal = typeof last === 'object' && last !== null && 'value' in last ? last.value : last;
|
|
568
|
+
}
|
|
569
|
+
else {
|
|
570
|
+
evalVal = undefined;
|
|
571
|
+
}
|
|
238
572
|
}
|
|
239
573
|
if (evalVal !== undefined && evalVal !== null) {
|
|
240
574
|
const resolution = resolvePraxisMicroVisualizationTone(evalVal, thresholdsObj.thresholds);
|
|
@@ -246,11 +580,78 @@ function normalizePraxisPresentationVisualization(value) {
|
|
|
246
580
|
}
|
|
247
581
|
}
|
|
248
582
|
}
|
|
583
|
+
if (kind === 'stackedBar') {
|
|
584
|
+
const stacked = normalizeStackedBarDistribution(value, surface);
|
|
585
|
+
const stackedSuppressedCount = Math.max(stacked.suppressedCount ?? 0, countSuppressedEntries(value.points));
|
|
586
|
+
return {
|
|
587
|
+
kind,
|
|
588
|
+
fallbackText,
|
|
589
|
+
...(surface ? { surface } : {}),
|
|
590
|
+
...(size ? { size } : {}),
|
|
591
|
+
...(scaleScope ? { scaleScope } : {}),
|
|
592
|
+
...(stacked.title ? { title: stacked.title } : {}),
|
|
593
|
+
...(normalizeExpression(value.titleExpr, 'titleExpr') ?? {}),
|
|
594
|
+
...(stacked.legend !== undefined ? { legend: stacked.legend } : {}),
|
|
595
|
+
...(resolvedTone ? { tone: resolvedTone } : {}),
|
|
596
|
+
...(resolvedAriaLabel ? { ariaLabel: resolvedAriaLabel } : {}),
|
|
597
|
+
...(valueSuffix ? { valueSuffix } : {}),
|
|
598
|
+
...(typeof value.compactValue === 'boolean' ? { compactValue: value.compactValue } : {}),
|
|
599
|
+
...(Object.prototype.hasOwnProperty.call(value, 'value') ? { value: value.value } : {}),
|
|
600
|
+
...(normalizeExpression(value.valueExpr, 'valueExpr') ?? {}),
|
|
601
|
+
...(normalizeExpression(value.valueSuffixExpr, 'valueSuffixExpr') ?? {}),
|
|
602
|
+
...(normalizeNumber(value.min, 'min') ?? {}),
|
|
603
|
+
...(normalizeExpression(value.minExpr, 'minExpr') ?? {}),
|
|
604
|
+
...(normalizeNumber(value.max, 'max') ?? {}),
|
|
605
|
+
...(normalizeExpression(value.maxExpr, 'maxExpr') ?? {}),
|
|
606
|
+
...(stacked.total !== undefined ? { total: stacked.total } : {}),
|
|
607
|
+
...(normalizeExpression(value.totalExpr, 'totalExpr') ?? {}),
|
|
608
|
+
...(normalizeNumber(value.target, 'target') ?? {}),
|
|
609
|
+
...(normalizeExpression(value.targetExpr, 'targetExpr') ?? {}),
|
|
610
|
+
...(normalizedTargetLabel ? { targetLabel: normalizedTargetLabel } : {}),
|
|
611
|
+
...(normalizeExpression(value.targetLabelExpr, 'targetLabelExpr') ?? {}),
|
|
612
|
+
...(normalizeNumber(value.baseline, 'baseline') ?? {}),
|
|
613
|
+
...(normalizeExpression(value.baselineExpr, 'baselineExpr') ?? {}),
|
|
614
|
+
...(normalizedPointsObj ?? {}),
|
|
615
|
+
...(normalizeExpression(value.pointsExpr, 'pointsExpr') ?? {}),
|
|
616
|
+
...(stacked.segments ? { segments: stacked.segments } : {}),
|
|
617
|
+
...(value.interactiveSegments === true && !isTableCell ? { interactiveSegments: true } : {}),
|
|
618
|
+
...(typeof value.activeSelectionCount === 'number' &&
|
|
619
|
+
Number.isInteger(value.activeSelectionCount) &&
|
|
620
|
+
value.activeSelectionCount > 0 &&
|
|
621
|
+
!isTableCell
|
|
622
|
+
? { activeSelectionCount: value.activeSelectionCount }
|
|
623
|
+
: {}),
|
|
624
|
+
...(normalizeExpression(value.segmentsExpr, 'segmentsExpr') ?? {}),
|
|
625
|
+
...(normalizeThresholds(value.thresholds) ?? {}),
|
|
626
|
+
...(normalizeExpression(value.thresholdsExpr, 'thresholdsExpr') ?? {}),
|
|
627
|
+
...(stacked.items ? { items: stacked.items } : {}),
|
|
628
|
+
...(stackedSuppressedCount > 0 ? { suppressedCount: stackedSuppressedCount } : {}),
|
|
629
|
+
...(normalizeExpression(value.itemsExpr, 'itemsExpr') ?? {}),
|
|
630
|
+
...(normalizeExpression(value.toneExpr, 'toneExpr') ?? {}),
|
|
631
|
+
...(value.stepLabelWidth !== undefined && (typeof value.stepLabelWidth === 'number' || typeof value.stepLabelWidth === 'string')
|
|
632
|
+
? { stepLabelWidth: value.stepLabelWidth }
|
|
633
|
+
: {}),
|
|
634
|
+
...(typeof value.stepLabelLineClamp === 'number' && Number.isFinite(value.stepLabelLineClamp)
|
|
635
|
+
? { stepLabelLineClamp: value.stepLabelLineClamp }
|
|
636
|
+
: {}),
|
|
637
|
+
...(normalizeExpression(value.ariaLabelExpr, 'ariaLabelExpr') ?? {}),
|
|
638
|
+
...(normalizeExpression(value.fallbackTextExpr, 'fallbackTextExpr') ?? {}),
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
const normalizedTitle = isTableCell ? undefined : normalizeText$1(value.title);
|
|
642
|
+
const normalizedLegend = typeof value.legend === 'boolean' ? (isTableCell ? false : value.legend) : undefined;
|
|
643
|
+
const suppressedCount = Math.max(resolvePreservedSuppressedCount(value.suppressedCount), countSuppressedEntries(value.points)
|
|
644
|
+
+ countSuppressedEntries(value.items)
|
|
645
|
+
+ countSuppressedEntries(value.segments));
|
|
249
646
|
return {
|
|
250
647
|
kind,
|
|
251
648
|
fallbackText,
|
|
252
649
|
...(surface ? { surface } : {}),
|
|
253
650
|
...(size ? { size } : {}),
|
|
651
|
+
...(scaleScope ? { scaleScope } : {}),
|
|
652
|
+
...(normalizedTitle ? { title: normalizedTitle } : {}),
|
|
653
|
+
...(normalizeExpression(value.titleExpr, 'titleExpr') ?? {}),
|
|
654
|
+
...(normalizedLegend !== undefined ? { legend: normalizedLegend } : {}),
|
|
254
655
|
...(resolvedTone ? { tone: resolvedTone } : {}),
|
|
255
656
|
...(resolvedAriaLabel ? { ariaLabel: resolvedAriaLabel } : {}),
|
|
256
657
|
...(valueSuffix ? { valueSuffix } : {}),
|
|
@@ -258,19 +659,26 @@ function normalizePraxisPresentationVisualization(value) {
|
|
|
258
659
|
...(Object.prototype.hasOwnProperty.call(value, 'value') ? { value: value.value } : {}),
|
|
259
660
|
...(normalizeExpression(value.valueExpr, 'valueExpr') ?? {}),
|
|
260
661
|
...(normalizeExpression(value.valueSuffixExpr, 'valueSuffixExpr') ?? {}),
|
|
662
|
+
...(normalizeNumber(value.min, 'min') ?? {}),
|
|
663
|
+
...(normalizeExpression(value.minExpr, 'minExpr') ?? {}),
|
|
664
|
+
...(normalizeNumber(value.max, 'max') ?? {}),
|
|
665
|
+
...(normalizeExpression(value.maxExpr, 'maxExpr') ?? {}),
|
|
261
666
|
...(normalizeNumber(value.total, 'total') ?? {}),
|
|
262
667
|
...(normalizeExpression(value.totalExpr, 'totalExpr') ?? {}),
|
|
263
668
|
...(normalizeNumber(value.target, 'target') ?? {}),
|
|
264
669
|
...(normalizeExpression(value.targetExpr, 'targetExpr') ?? {}),
|
|
670
|
+
...(normalizedTargetLabel ? { targetLabel: normalizedTargetLabel } : {}),
|
|
671
|
+
...(normalizeExpression(value.targetLabelExpr, 'targetLabelExpr') ?? {}),
|
|
265
672
|
...(normalizeNumber(value.baseline, 'baseline') ?? {}),
|
|
266
673
|
...(normalizeExpression(value.baselineExpr, 'baselineExpr') ?? {}),
|
|
267
|
-
...(
|
|
674
|
+
...(normalizedPointsObj ?? {}),
|
|
268
675
|
...(normalizeExpression(value.pointsExpr, 'pointsExpr') ?? {}),
|
|
269
676
|
...(normalizeSegments(value.segments) ?? {}),
|
|
270
677
|
...(normalizeExpression(value.segmentsExpr, 'segmentsExpr') ?? {}),
|
|
271
678
|
...(normalizeThresholds(value.thresholds) ?? {}),
|
|
272
679
|
...(normalizeExpression(value.thresholdsExpr, 'thresholdsExpr') ?? {}),
|
|
273
680
|
...(normalizeItems(value.items) ?? {}),
|
|
681
|
+
...(suppressedCount > 0 ? { suppressedCount } : {}),
|
|
274
682
|
...(normalizeExpression(value.itemsExpr, 'itemsExpr') ?? {}),
|
|
275
683
|
...(normalizeExpression(value.toneExpr, 'toneExpr') ?? {}),
|
|
276
684
|
...(value.stepLabelWidth !== undefined && (typeof value.stepLabelWidth === 'number' || typeof value.stepLabelWidth === 'string')
|
|
@@ -287,202 +695,63 @@ function isPraxisPresentationVisualizationTableSafe(value) {
|
|
|
287
695
|
const normalized = normalizePraxisPresentationVisualization(value);
|
|
288
696
|
return !!normalized && TABLE_SAFE_KINDS.has(normalized.kind);
|
|
289
697
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
switch (
|
|
296
|
-
case '
|
|
297
|
-
return
|
|
298
|
-
case '
|
|
299
|
-
return
|
|
300
|
-
case '
|
|
301
|
-
return
|
|
302
|
-
case '
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
case 'harveyBall':
|
|
307
|
-
return renderHarveyBallVisualizationHtml(visualization, options);
|
|
308
|
-
case 'line':
|
|
309
|
-
return renderLineVisualizationHtml(visualization, options);
|
|
310
|
-
case 'area':
|
|
311
|
-
return renderAreaVisualizationHtml(visualization, options);
|
|
312
|
-
case 'column':
|
|
313
|
-
return renderColumnVisualizationHtml(visualization, options);
|
|
314
|
-
case 'processFlow':
|
|
315
|
-
return renderProcessFlowVisualizationHtml(visualization, options);
|
|
698
|
+
/**
|
|
699
|
+
* Returns a luminous 3-stop directional color ramp (`[highlight, mid, deep]`)
|
|
700
|
+
* for radial arcs, sector dials, and precision micro-visualizations.
|
|
701
|
+
*/
|
|
702
|
+
function getPraxisMicroToneGradientStops(tone) {
|
|
703
|
+
switch (tone) {
|
|
704
|
+
case 'success':
|
|
705
|
+
return ['#bef264', '#22c55e', '#15803d'];
|
|
706
|
+
case 'info':
|
|
707
|
+
return ['#93c5fd', '#3b82f6', '#3730a3'];
|
|
708
|
+
case 'warning':
|
|
709
|
+
return ['#fde047', '#f59e0b', '#b45309'];
|
|
710
|
+
case 'danger':
|
|
711
|
+
case 'critical':
|
|
712
|
+
return ['#fda4af', '#f43f5e', '#be123c'];
|
|
713
|
+
case 'neutral':
|
|
316
714
|
default:
|
|
317
|
-
return
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
function renderComparisonVisualizationHtml(visualization, options) {
|
|
321
|
-
const points = visualization.points ?? [];
|
|
322
|
-
if (points.length === 0) {
|
|
323
|
-
return renderFallbackVisualizationHtml(visualization, visualization.tone ?? 'neutral');
|
|
324
|
-
}
|
|
325
|
-
const max = Math.max(1, ...points.map((point) => Math.max(0, point.value)));
|
|
326
|
-
const rows = points
|
|
327
|
-
.map((point) => {
|
|
328
|
-
const width = percent(point.value, max);
|
|
329
|
-
return `
|
|
330
|
-
<span class="pfx-micro-viz__row" data-tone="${escapeHtml(point.tone ?? visualization.tone ?? 'info')}">
|
|
331
|
-
<span class="pfx-micro-viz__label">${escapeHtml(point.label ?? '')}</span>
|
|
332
|
-
<span class="pfx-micro-viz__track">
|
|
333
|
-
<span class="pfx-micro-viz__bar" style="width:${width}%"></span>
|
|
334
|
-
</span>
|
|
335
|
-
<span class="pfx-micro-viz__value">${escapeHtml(formatMicroNumber(point.value, options.locale))}</span>
|
|
336
|
-
</span>`;
|
|
337
|
-
})
|
|
338
|
-
.join('');
|
|
339
|
-
return `<span class="pfx-micro-viz" role="img" aria-label="${escapeHtml(visualization.ariaLabel ?? visualization.fallbackText)}">${rows}</span>`;
|
|
340
|
-
}
|
|
341
|
-
function renderStackedBarVisualizationHtml(visualization, options) {
|
|
342
|
-
const segments = visualization.segments ?? [];
|
|
343
|
-
if (segments.length === 0) {
|
|
344
|
-
return renderFallbackVisualizationHtml(visualization, visualization.tone ?? 'neutral');
|
|
345
|
-
}
|
|
346
|
-
const total = visualization.total && visualization.total > 0
|
|
347
|
-
? visualization.total
|
|
348
|
-
: Math.max(1, segments.reduce((sum, segment) => sum + Math.max(0, segment.value), 0));
|
|
349
|
-
const bars = segments
|
|
350
|
-
.map((segment) => `
|
|
351
|
-
<span
|
|
352
|
-
class="pfx-micro-viz__segment"
|
|
353
|
-
data-tone="${escapeHtml(segment.tone ?? visualization.tone ?? 'info')}"
|
|
354
|
-
style="width:${percent(segment.value, total)}%"
|
|
355
|
-
title="${escapeHtml(`${segment.label ?? ''} ${formatMicroNumber(segment.value, options.locale)}`.trim())}"
|
|
356
|
-
></span>`)
|
|
357
|
-
.join('');
|
|
358
|
-
const meta = segments
|
|
359
|
-
.slice(0, 3)
|
|
360
|
-
.map((segment) => `<span>${escapeHtml(segment.label ?? '')}: ${escapeHtml(formatMicroNumber(segment.value, options.locale))}</span>`)
|
|
361
|
-
.join('');
|
|
362
|
-
return `
|
|
363
|
-
<span class="pfx-micro-viz" role="img" aria-label="${escapeHtml(visualization.ariaLabel ?? visualization.fallbackText)}">
|
|
364
|
-
<span class="pfx-micro-viz__segments">${bars}</span>
|
|
365
|
-
<span class="pfx-micro-viz__meta">${meta}</span>
|
|
366
|
-
</span>`;
|
|
367
|
-
}
|
|
368
|
-
function resolveBulletMax(visualization) {
|
|
369
|
-
const thresholds = visualization.thresholds ?? [];
|
|
370
|
-
const thresholdValues = thresholds
|
|
371
|
-
.map(t => t.value ?? t.max ?? t.min ?? 0)
|
|
372
|
-
.filter((v) => Number.isFinite(v) && v > 0);
|
|
373
|
-
const values = [
|
|
374
|
-
toFiniteNumber(visualization.value) ?? 0,
|
|
375
|
-
visualization.target ?? 0,
|
|
376
|
-
visualization.total ?? 0,
|
|
377
|
-
...thresholdValues
|
|
378
|
-
].filter((v) => Number.isFinite(v) && v > 0);
|
|
379
|
-
return Math.max(...values, 100);
|
|
380
|
-
}
|
|
381
|
-
function renderBulletVisualizationHtml(visualization, options) {
|
|
382
|
-
const currentValue = toFiniteNumber(visualization.value);
|
|
383
|
-
if (currentValue === undefined) {
|
|
384
|
-
return renderFallbackVisualizationHtml(visualization, visualization.tone ?? 'neutral');
|
|
385
|
-
}
|
|
386
|
-
const max = resolveBulletMax(visualization);
|
|
387
|
-
const target = toFiniteNumber(visualization.target);
|
|
388
|
-
const targetLeft = target === undefined ? null : percent(target, max);
|
|
389
|
-
const isTable = visualization.surface === 'table-cell';
|
|
390
|
-
// thresholds: sort ascending by boundary value so bands draw continuously regardless of declaration order
|
|
391
|
-
const thresholds = visualization.thresholds ?? [];
|
|
392
|
-
const sortedThresholds = [...thresholds].sort((a, b) => {
|
|
393
|
-
const aVal = a.value ?? a.max ?? a.min ?? 0;
|
|
394
|
-
const bVal = b.value ?? b.max ?? b.min ?? 0;
|
|
395
|
-
return aVal - bVal;
|
|
396
|
-
});
|
|
397
|
-
let previous = 0;
|
|
398
|
-
const bands = sortedThresholds.map(t => {
|
|
399
|
-
const tVal = t.value ?? t.max ?? t.min ?? 0;
|
|
400
|
-
const current = Math.max(tVal, previous);
|
|
401
|
-
const left = max > 0 ? percent(previous, max) : '0';
|
|
402
|
-
const width = max > 0 ? percent(current - previous, max) : '0';
|
|
403
|
-
previous = current;
|
|
404
|
-
return { left, width, tone: t.tone ?? 'info' };
|
|
405
|
-
}).filter(b => parseFloat(b.width) > 0);
|
|
406
|
-
const bandsHtml = bands.map(b => `<span class="pfx-micro-bullet__range" data-tone="${escapeHtml(b.tone)}" style="left: ${b.left}%; width: ${b.width}%;"></span>`).join('');
|
|
407
|
-
const topHtml = isTable ? '' : `
|
|
408
|
-
<div class="pfx-micro-bullet__top">
|
|
409
|
-
<span class="pfx-micro-bullet__label">${escapeHtml(visualization.fallbackText)}</span>
|
|
410
|
-
<span class="pfx-micro-bullet__value">
|
|
411
|
-
${escapeHtml(formatMicroNumber(currentValue, options.locale))}
|
|
412
|
-
${target === undefined ? '' : `<span class="pfx-micro-bullet__target-val">/ Target: ${escapeHtml(formatMicroNumber(target, options.locale))}</span>`}
|
|
413
|
-
</span>
|
|
414
|
-
</div>`;
|
|
415
|
-
const bottomHtml = isTable ? '' : `
|
|
416
|
-
<div class="pfx-micro-bullet__bottom">
|
|
417
|
-
<span>${escapeHtml(formatMicroNumber(visualization.baseline ?? 0, options.locale))}</span>
|
|
418
|
-
<span>${escapeHtml(formatMicroNumber(max, options.locale))}</span>
|
|
419
|
-
</div>`;
|
|
420
|
-
const showCompactValue = isTable && visualization.compactValue !== false;
|
|
421
|
-
const compactValueHtml = showCompactValue
|
|
422
|
-
? `<span class="pfx-micro-bullet__compact-value">${escapeHtml(formatMicroNumber(currentValue, options.locale))}${escapeHtml(visualization.valueSuffix ?? '')}</span>`
|
|
423
|
-
: '';
|
|
424
|
-
return `
|
|
425
|
-
<span class="pfx-micro-viz pfx-micro-viz__bullet" data-tone="${escapeHtml(visualization.tone ?? 'info')}" role="img" aria-label="${escapeHtml(visualization.ariaLabel ?? visualization.fallbackText)}">
|
|
426
|
-
${topHtml}
|
|
427
|
-
<span class="pfx-micro-bullet__track">
|
|
428
|
-
${bandsHtml}
|
|
429
|
-
<span class="pfx-micro-bullet__actual" data-tone="${escapeHtml(visualization.tone ?? 'info')}" style="width: ${percent(currentValue, max)}%;"></span>
|
|
430
|
-
${targetLeft === null ? '' : `<span class="pfx-micro-bullet__target" style="left: ${targetLeft}%;"></span>`}
|
|
431
|
-
</span>
|
|
432
|
-
${bottomHtml}
|
|
433
|
-
${compactValueHtml}
|
|
434
|
-
</span>`;
|
|
435
|
-
}
|
|
436
|
-
function renderDeltaVisualizationHtml(visualization, options) {
|
|
437
|
-
const value = toFiniteNumber(visualization.value);
|
|
438
|
-
const direction = value === undefined ? 'neutral' : value < 0 ? 'down' : value > 0 ? 'up' : 'neutral';
|
|
439
|
-
const symbol = direction === 'up' ? '▲' : direction === 'down' ? '▼' : '→';
|
|
440
|
-
const tone = visualization.tone ??
|
|
441
|
-
(value === undefined
|
|
442
|
-
? 'neutral'
|
|
443
|
-
: value < 0
|
|
444
|
-
? 'danger'
|
|
445
|
-
: value > 0
|
|
446
|
-
? 'success'
|
|
447
|
-
: 'neutral');
|
|
448
|
-
const valueSuffix = visualization.valueSuffix ?? '';
|
|
449
|
-
const text = value === undefined
|
|
450
|
-
? visualization.fallbackText
|
|
451
|
-
: `${formatMicroNumber(Math.abs(value), options.locale)}${valueSuffix}`;
|
|
452
|
-
const directionLabel = direction === 'up'
|
|
453
|
-
? 'up'
|
|
454
|
-
: direction === 'down'
|
|
455
|
-
? 'down'
|
|
456
|
-
: 'stable';
|
|
457
|
-
const aria = visualization.ariaLabel ?? `${visualization.fallbackText}: ${directionLabel} ${text}`;
|
|
458
|
-
return `
|
|
459
|
-
<span class="pfx-micro-viz pfx-micro-viz__delta" data-tone="${escapeHtml(tone)}" data-direction="${escapeHtml(direction)}" role="img" aria-label="${escapeHtml(aria)}">
|
|
460
|
-
<span class="pfx-micro-viz__delta-symbol" aria-hidden="true">${symbol}</span>
|
|
461
|
-
<span>${escapeHtml(text)}</span>
|
|
462
|
-
</span>`;
|
|
463
|
-
}
|
|
464
|
-
function percent(value, total) {
|
|
465
|
-
if (!Number.isFinite(value) || !Number.isFinite(total) || total <= 0) {
|
|
466
|
-
return '0';
|
|
467
|
-
}
|
|
468
|
-
return Math.max(0, Math.min(100, (value / total) * 100)).toFixed(2);
|
|
715
|
+
return ['#cbd5e1', '#64748b', '#334155'];
|
|
716
|
+
}
|
|
469
717
|
}
|
|
470
718
|
function toFiniteNumber(value) {
|
|
471
|
-
|
|
719
|
+
if (typeof value === 'number') {
|
|
720
|
+
return Number.isFinite(value) ? value : undefined;
|
|
721
|
+
}
|
|
722
|
+
if (typeof value === 'string') {
|
|
723
|
+
const trimmed = value.trim();
|
|
724
|
+
if (!trimmed) {
|
|
725
|
+
return undefined;
|
|
726
|
+
}
|
|
727
|
+
const parsed = Number(trimmed);
|
|
728
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
729
|
+
}
|
|
730
|
+
return undefined;
|
|
472
731
|
}
|
|
473
|
-
function
|
|
732
|
+
function formatVisualizationMetricValue(value, options, compactValue = false, suffix = '') {
|
|
733
|
+
if (typeof options.formatValue === 'function') {
|
|
734
|
+
const custom = options.formatValue(value, compactValue);
|
|
735
|
+
if (typeof custom === 'string' && custom.trim().length > 0) {
|
|
736
|
+
return suffix && !custom.endsWith(suffix) ? `${custom}${suffix}` : custom;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
return `${formatMicroNumber(value, options.locale, compactValue)}${suffix}`;
|
|
740
|
+
}
|
|
741
|
+
function formatMicroNumber(value, locale, compactValue = false) {
|
|
742
|
+
if (compactValue && Math.abs(value) >= 1000) {
|
|
743
|
+
return new Intl.NumberFormat(locale || undefined, {
|
|
744
|
+
notation: 'compact',
|
|
745
|
+
compactDisplay: 'short',
|
|
746
|
+
maximumFractionDigits: 1,
|
|
747
|
+
}).format(value);
|
|
748
|
+
}
|
|
749
|
+
const abs = Math.abs(value);
|
|
750
|
+
const hasFraction = Math.abs(value - Math.trunc(value)) > 1e-6;
|
|
474
751
|
return new Intl.NumberFormat(locale || undefined, {
|
|
475
|
-
maximumFractionDigits:
|
|
752
|
+
maximumFractionDigits: abs < 10 ? 2 : hasFraction && abs < 1000 ? 1 : 0,
|
|
476
753
|
}).format(value);
|
|
477
754
|
}
|
|
478
|
-
function escapeHtml(value) {
|
|
479
|
-
return String(value ?? '')
|
|
480
|
-
.replace(/&/g, '&')
|
|
481
|
-
.replace(/</g, '<')
|
|
482
|
-
.replace(/>/g, '>')
|
|
483
|
-
.replace(/"/g, '"')
|
|
484
|
-
.replace(/'/g, ''');
|
|
485
|
-
}
|
|
486
755
|
function normalizePoints(value) {
|
|
487
756
|
const points = normalizeNumericEntries(value);
|
|
488
757
|
return points.length ? { points } : undefined;
|
|
@@ -545,21 +814,35 @@ function normalizeNumericEntries(value) {
|
|
|
545
814
|
}
|
|
546
815
|
return value
|
|
547
816
|
.map((item) => {
|
|
548
|
-
if (
|
|
817
|
+
if (typeof item === 'number' || typeof item === 'string') {
|
|
818
|
+
const num = toFiniteNumber(item);
|
|
819
|
+
return num !== undefined ? { value: num } : null;
|
|
820
|
+
}
|
|
821
|
+
if (!item || typeof item !== 'object' || isVisualizationEntrySuppressed(item)) {
|
|
822
|
+
return null;
|
|
823
|
+
}
|
|
824
|
+
const num = toFiniteNumber(item.value);
|
|
825
|
+
if (num === undefined) {
|
|
549
826
|
return null;
|
|
550
827
|
}
|
|
551
828
|
const label = normalizeText$1(item.label);
|
|
552
829
|
const tone = normalizeEnum$1(item.tone, VISUALIZATION_TONES);
|
|
830
|
+
const color = normalizePraxisHexColor(item.color);
|
|
831
|
+
const key = normalizeText$1(item.key);
|
|
832
|
+
const active = item.active === true;
|
|
553
833
|
return {
|
|
554
|
-
value:
|
|
834
|
+
value: num,
|
|
835
|
+
...(key ? { key } : {}),
|
|
555
836
|
...(label ? { label } : {}),
|
|
556
837
|
...(tone ? { tone } : {}),
|
|
838
|
+
...(color ? { color } : {}),
|
|
839
|
+
...(active ? { active: true } : {}),
|
|
557
840
|
};
|
|
558
841
|
})
|
|
559
842
|
.filter((item) => !!item);
|
|
560
843
|
}
|
|
561
844
|
function normalizeVisualizationItem(item) {
|
|
562
|
-
if (!item || typeof item !== 'object') {
|
|
845
|
+
if (!item || typeof item !== 'object' || isVisualizationEntrySuppressed(item)) {
|
|
563
846
|
return null;
|
|
564
847
|
}
|
|
565
848
|
const id = normalizeText$1(item.id);
|
|
@@ -567,8 +850,10 @@ function normalizeVisualizationItem(item) {
|
|
|
567
850
|
const icon = normalizeText$1(item.icon);
|
|
568
851
|
const state = normalizeText$1(item.state);
|
|
569
852
|
const tone = normalizeEnum$1(item.tone, VISUALIZATION_TONES);
|
|
570
|
-
const
|
|
571
|
-
|
|
853
|
+
const role = normalizeEnum$1(item.role, WATERFALL_ROLES);
|
|
854
|
+
const color = normalizePraxisHexColor(item.color);
|
|
855
|
+
const normalizedValue = toFiniteNumber(item.value);
|
|
856
|
+
if (!id && !label && normalizedValue === undefined && !icon && !state && !tone && !role && !color) {
|
|
572
857
|
return null;
|
|
573
858
|
}
|
|
574
859
|
return {
|
|
@@ -578,10 +863,13 @@ function normalizeVisualizationItem(item) {
|
|
|
578
863
|
...(icon ? { icon } : {}),
|
|
579
864
|
...(state ? { state } : {}),
|
|
580
865
|
...(tone ? { tone } : {}),
|
|
866
|
+
...(role ? { role } : {}),
|
|
867
|
+
...(color ? { color } : {}),
|
|
581
868
|
};
|
|
582
869
|
}
|
|
583
870
|
function normalizeNumber(value, key) {
|
|
584
|
-
|
|
871
|
+
const num = toFiniteNumber(value);
|
|
872
|
+
return num !== undefined ? { [key]: num } : undefined;
|
|
585
873
|
}
|
|
586
874
|
function normalizeEnum$1(value, allowed) {
|
|
587
875
|
if (typeof value !== 'string') {
|
|
@@ -597,296 +885,620 @@ function normalizeText$1(value) {
|
|
|
597
885
|
const trimmed = value.trim();
|
|
598
886
|
return trimmed.length ? trimmed : undefined;
|
|
599
887
|
}
|
|
600
|
-
function
|
|
601
|
-
const
|
|
602
|
-
if (
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
const
|
|
616
|
-
?
|
|
617
|
-
:
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
const
|
|
634
|
-
const
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
|
|
888
|
+
function formatPraxisWaterfallSignedValue(value, role, options = {}, compactValue = false, suffix = '') {
|
|
889
|
+
const absFormatted = formatVisualizationMetricValue(Math.abs(Number.isFinite(value) ? value : 0), options, compactValue, suffix);
|
|
890
|
+
if (role === 'start' || role === 'subtotal' || role === 'total') {
|
|
891
|
+
const negPrefix = value < 0 ? '-' : '';
|
|
892
|
+
return `= ${negPrefix}${absFormatted}`;
|
|
893
|
+
}
|
|
894
|
+
if (value > 0) {
|
|
895
|
+
return `+${absFormatted}`;
|
|
896
|
+
}
|
|
897
|
+
if (value < 0) {
|
|
898
|
+
return `-${absFormatted}`;
|
|
899
|
+
}
|
|
900
|
+
return absFormatted;
|
|
901
|
+
}
|
|
902
|
+
function resolvePraxisMicroWaterfallSteps(visualization, options = {}) {
|
|
903
|
+
const rawItems = Array.isArray(visualization.items) && visualization.items.length > 0
|
|
904
|
+
? visualization.items
|
|
905
|
+
: Array.isArray(visualization.points)
|
|
906
|
+
? visualization.points.map((pt) => typeof pt === 'number'
|
|
907
|
+
? { value: pt }
|
|
908
|
+
: {
|
|
909
|
+
label: pt.label,
|
|
910
|
+
value: pt.value,
|
|
911
|
+
tone: pt.tone,
|
|
912
|
+
...(pt.suppressed !== undefined ? { suppressed: pt.suppressed } : {}),
|
|
913
|
+
...(pt.privacySuppressed !== undefined ? { privacySuppressed: pt.privacySuppressed } : {}),
|
|
914
|
+
})
|
|
915
|
+
: [];
|
|
916
|
+
if (!rawItems.length) {
|
|
917
|
+
return [];
|
|
918
|
+
}
|
|
919
|
+
const suffix = visualization.valueSuffix ?? '';
|
|
920
|
+
const compactValue = visualization.compactValue === true;
|
|
921
|
+
const fallbackAnchorTone = visualization.tone ?? 'info';
|
|
922
|
+
const steps = [];
|
|
923
|
+
let running = 0;
|
|
924
|
+
let hasFiniteNumeric = false;
|
|
925
|
+
let hadSuppressedItems = resolvePreservedSuppressedCount(visualization.suppressedCount) > 0;
|
|
926
|
+
let visibleIncrementCount = 0;
|
|
927
|
+
for (let i = 0; i < rawItems.length; i++) {
|
|
928
|
+
const raw = rawItems[i];
|
|
929
|
+
if (!raw || typeof raw !== 'object') {
|
|
930
|
+
continue;
|
|
931
|
+
}
|
|
932
|
+
if (isVisualizationEntrySuppressed(raw)) {
|
|
933
|
+
hadSuppressedItems = true;
|
|
934
|
+
continue;
|
|
935
|
+
}
|
|
936
|
+
const rawNumeric = toFiniteNumber(raw.value);
|
|
937
|
+
if (rawNumeric !== undefined) {
|
|
938
|
+
hasFiniteNumeric = true;
|
|
939
|
+
}
|
|
940
|
+
const explicitRole = normalizeEnum$1(raw.role, WATERFALL_ROLES);
|
|
941
|
+
const role = explicitRole
|
|
942
|
+
?? (steps.length === 0 ? 'start' : (rawNumeric ?? 0) < 0 ? 'decrease' : 'increase');
|
|
943
|
+
if (rawNumeric === undefined && role !== 'subtotal' && role !== 'total') {
|
|
944
|
+
continue;
|
|
945
|
+
}
|
|
946
|
+
if (role !== 'subtotal' && role !== 'total') {
|
|
947
|
+
visibleIncrementCount += 1;
|
|
948
|
+
}
|
|
949
|
+
let start = running;
|
|
950
|
+
let end = running;
|
|
951
|
+
let delta = 0;
|
|
952
|
+
let resolvedValue = rawNumeric ?? running;
|
|
953
|
+
if (role === 'start') {
|
|
954
|
+
start = 0;
|
|
955
|
+
end = rawNumeric ?? 0;
|
|
956
|
+
delta = end;
|
|
957
|
+
running = end;
|
|
958
|
+
resolvedValue = end;
|
|
959
|
+
}
|
|
960
|
+
else if (role === 'subtotal' || role === 'total') {
|
|
961
|
+
const targetEnd = hadSuppressedItems ? running : (rawNumeric ?? running);
|
|
962
|
+
start = 0;
|
|
963
|
+
end = targetEnd;
|
|
964
|
+
delta = targetEnd;
|
|
965
|
+
running = targetEnd;
|
|
966
|
+
resolvedValue = targetEnd;
|
|
967
|
+
}
|
|
968
|
+
else if (role === 'decrease') {
|
|
969
|
+
delta = -Math.abs(rawNumeric ?? 0);
|
|
970
|
+
start = running;
|
|
971
|
+
end = running + delta;
|
|
972
|
+
running = end;
|
|
973
|
+
resolvedValue = delta;
|
|
974
|
+
}
|
|
975
|
+
else {
|
|
976
|
+
delta = Math.abs(rawNumeric ?? 0);
|
|
977
|
+
start = running;
|
|
978
|
+
end = running + delta;
|
|
979
|
+
running = end;
|
|
980
|
+
resolvedValue = delta;
|
|
981
|
+
}
|
|
982
|
+
const defaultTone = role === 'increase'
|
|
983
|
+
? 'success'
|
|
984
|
+
: role === 'decrease'
|
|
985
|
+
? 'danger'
|
|
986
|
+
: role === 'start'
|
|
987
|
+
? 'neutral'
|
|
988
|
+
: fallbackAnchorTone;
|
|
989
|
+
const tone = normalizeEnum$1(raw.tone, VISUALIZATION_TONES) ?? defaultTone;
|
|
990
|
+
const label = normalizeText$1(raw.label) ?? normalizeText$1(raw.id) ?? `#${steps.length + 1}`;
|
|
991
|
+
const signedText = formatPraxisWaterfallSignedValue(role === 'start' || role === 'subtotal' || role === 'total' ? end : delta, role, options, compactValue, suffix);
|
|
992
|
+
const endText = formatVisualizationMetricValue(Math.abs(end), options, compactValue, suffix);
|
|
993
|
+
const signedEndText = `${end < 0 ? '-' : ''}${endText}`;
|
|
994
|
+
const readout = role === 'start' || role === 'subtotal' || role === 'total'
|
|
995
|
+
? `${label}: ${signedText}`
|
|
996
|
+
: `${label}: ${signedText} (=> ${signedEndText})`;
|
|
997
|
+
steps.push({
|
|
998
|
+
...(raw.id ? { id: raw.id } : {}),
|
|
999
|
+
label,
|
|
1000
|
+
value: resolvedValue,
|
|
1001
|
+
start,
|
|
1002
|
+
end,
|
|
1003
|
+
delta,
|
|
1004
|
+
role,
|
|
1005
|
+
tone,
|
|
1006
|
+
...(raw.color ? { color: raw.color } : {}),
|
|
1007
|
+
signedText,
|
|
1008
|
+
readout,
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
if (!hasFiniteNumeric || (hadSuppressedItems && visibleIncrementCount === 0)) {
|
|
654
1012
|
return [];
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
1013
|
+
}
|
|
1014
|
+
return steps;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
const PRAXIS_QUICK_VIEW_PRESENTER = new InjectionToken('PRAXIS_QUICK_VIEW_PRESENTER');
|
|
1018
|
+
const PRAXIS_QUICK_VIEW_BODY_RENDERER = new InjectionToken('PRAXIS_QUICK_VIEW_BODY_RENDERER');
|
|
1019
|
+
const FORBIDDEN_BINDING_KEYS = new Set([
|
|
1020
|
+
'element',
|
|
1021
|
+
'nativeElement',
|
|
1022
|
+
'anchor',
|
|
1023
|
+
'hostElement',
|
|
1024
|
+
'focusOrigin',
|
|
1025
|
+
'getViewportRect',
|
|
1026
|
+
'nodes',
|
|
1027
|
+
'document',
|
|
1028
|
+
'action',
|
|
1029
|
+
'actions',
|
|
1030
|
+
'ctaAction',
|
|
1031
|
+
'overrideAction',
|
|
1032
|
+
'route',
|
|
1033
|
+
'href',
|
|
1034
|
+
'payload',
|
|
1035
|
+
'hostCapabilities',
|
|
1036
|
+
]);
|
|
1037
|
+
const RESOURCE_KEY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,199}$/;
|
|
1038
|
+
/**
|
|
1039
|
+
* Detecta se um valor candidato à serialização contém referências efêmeras de DOM ou funções.
|
|
1040
|
+
*/
|
|
1041
|
+
function containsEphemeralQuickViewRuntimeValue(value, visited = new Set()) {
|
|
1042
|
+
if (!value || typeof value !== 'object') {
|
|
1043
|
+
return typeof value === 'function';
|
|
1044
|
+
}
|
|
1045
|
+
if (visited.has(value)) {
|
|
1046
|
+
return false;
|
|
1047
|
+
}
|
|
1048
|
+
visited.add(value);
|
|
1049
|
+
if (typeof Element !== 'undefined' && value instanceof Element) {
|
|
1050
|
+
return true;
|
|
1051
|
+
}
|
|
1052
|
+
if (typeof value.nodeType === 'number' &&
|
|
1053
|
+
typeof value.nodeName === 'string') {
|
|
1054
|
+
return true;
|
|
1055
|
+
}
|
|
1056
|
+
if (Array.isArray(value)) {
|
|
1057
|
+
return value.some((item) => containsEphemeralQuickViewRuntimeValue(item, visited));
|
|
1058
|
+
}
|
|
1059
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
1060
|
+
if (key === 'element' ||
|
|
1061
|
+
key === 'nativeElement' ||
|
|
1062
|
+
key === 'hostElement' ||
|
|
1063
|
+
key === 'focusOrigin' ||
|
|
1064
|
+
typeof entry === 'function') {
|
|
1065
|
+
return true;
|
|
1066
|
+
}
|
|
1067
|
+
if (containsEphemeralQuickViewRuntimeValue(entry, visited)) {
|
|
1068
|
+
return true;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
return false;
|
|
1072
|
+
}
|
|
1073
|
+
function normalizeResourceRecordOpenReference(candidate) {
|
|
1074
|
+
if (!candidate || typeof candidate !== 'object' || Array.isArray(candidate)) {
|
|
1075
|
+
return null;
|
|
1076
|
+
}
|
|
1077
|
+
const record = candidate;
|
|
1078
|
+
const target = record['target'] && typeof record['target'] === 'object' && !Array.isArray(record['target'])
|
|
1079
|
+
? record['target']
|
|
1080
|
+
: null;
|
|
1081
|
+
const sourceIdentityField = typeof record['sourceIdentityField'] === 'string'
|
|
1082
|
+
? record['sourceIdentityField'].trim()
|
|
1083
|
+
: '';
|
|
1084
|
+
const resourceKey = typeof target?.['resourceKey'] === 'string'
|
|
1085
|
+
? target['resourceKey'].trim()
|
|
1086
|
+
: '';
|
|
1087
|
+
const surfaceId = typeof target?.['surfaceId'] === 'string'
|
|
1088
|
+
? target['surfaceId'].trim()
|
|
1089
|
+
: '';
|
|
1090
|
+
if (!sourceIdentityField ||
|
|
1091
|
+
sourceIdentityField.length > 200 ||
|
|
1092
|
+
!RESOURCE_KEY_PATTERN.test(resourceKey) ||
|
|
1093
|
+
!surfaceId ||
|
|
1094
|
+
surfaceId.length > 200) {
|
|
1095
|
+
return null;
|
|
1096
|
+
}
|
|
1097
|
+
return {
|
|
1098
|
+
sourceIdentityField,
|
|
1099
|
+
target: {
|
|
1100
|
+
resourceKey,
|
|
1101
|
+
surfaceId,
|
|
1102
|
+
},
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
/**
|
|
1106
|
+
* Valida e normaliza um `ResourceQuickViewBinding` de forma fail-closed.
|
|
1107
|
+
*/
|
|
1108
|
+
function validateResourceQuickViewBinding(value) {
|
|
1109
|
+
const diagnostics = [];
|
|
1110
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
1111
|
+
return {
|
|
1112
|
+
valid: false,
|
|
1113
|
+
binding: null,
|
|
1114
|
+
diagnostics: ['Quick View binding must be a non-null object.'],
|
|
1115
|
+
};
|
|
1116
|
+
}
|
|
1117
|
+
const record = value;
|
|
1118
|
+
for (const forbiddenKey of FORBIDDEN_BINDING_KEYS) {
|
|
1119
|
+
if (forbiddenKey in record && record[forbiddenKey] !== undefined) {
|
|
1120
|
+
diagnostics.push(`Quick View binding cannot contain runtime, inline document or action override property "${forbiddenKey}".`);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
if (containsEphemeralQuickViewRuntimeValue(record)) {
|
|
1124
|
+
diagnostics.push('Quick View binding cannot contain DOM elements or functions.');
|
|
1125
|
+
}
|
|
1126
|
+
const rawRecordOpen = record['recordOpen'];
|
|
1127
|
+
if (!rawRecordOpen || typeof rawRecordOpen !== 'object' || Array.isArray(rawRecordOpen)) {
|
|
1128
|
+
diagnostics.push('Quick View binding requires a valid "recordOpen" object.');
|
|
1129
|
+
}
|
|
1130
|
+
else {
|
|
1131
|
+
const recordOpenObj = rawRecordOpen;
|
|
1132
|
+
for (const forbiddenKey of FORBIDDEN_BINDING_KEYS) {
|
|
1133
|
+
if (forbiddenKey in recordOpenObj && recordOpenObj[forbiddenKey] !== undefined) {
|
|
1134
|
+
diagnostics.push(`Quick View recordOpen cannot contain override property "${forbiddenKey}".`);
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
if ('presentation' in recordOpenObj && recordOpenObj['presentation'] === 'popover') {
|
|
1138
|
+
diagnostics.push('Quick View recordOpen cannot declare "popover" presentation.');
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
let previewSurfaceId;
|
|
1142
|
+
const rawPreviewSurfaceId = record['previewSurfaceId'];
|
|
1143
|
+
if (rawPreviewSurfaceId !== undefined && rawPreviewSurfaceId !== null) {
|
|
1144
|
+
if (typeof rawPreviewSurfaceId === 'string' &&
|
|
1145
|
+
rawPreviewSurfaceId.trim().length > 0 &&
|
|
1146
|
+
rawPreviewSurfaceId.trim().length <= 200) {
|
|
1147
|
+
previewSurfaceId = rawPreviewSurfaceId.trim();
|
|
1148
|
+
}
|
|
1149
|
+
else {
|
|
1150
|
+
diagnostics.push('Quick View previewSurfaceId must be a non-empty string up to 200 characters.');
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
let detailPresentation;
|
|
1154
|
+
const rawDetailPresentation = record['detailPresentation'];
|
|
1155
|
+
if (rawDetailPresentation !== undefined && rawDetailPresentation !== null) {
|
|
1156
|
+
if (rawDetailPresentation === 'drawer' || rawDetailPresentation === 'modal') {
|
|
1157
|
+
detailPresentation = rawDetailPresentation;
|
|
1158
|
+
}
|
|
1159
|
+
else {
|
|
1160
|
+
diagnostics.push(`Quick View detailPresentation must be "drawer" or "modal"; received "${String(rawDetailPresentation)}".`);
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
const normalizedRecordOpen = normalizeResourceRecordOpenReference(rawRecordOpen);
|
|
1164
|
+
if (!normalizedRecordOpen) {
|
|
1165
|
+
diagnostics.push('Quick View recordOpen must declare non-empty sourceIdentityField and target.{resourceKey, surfaceId}.');
|
|
1166
|
+
}
|
|
1167
|
+
let normalizedContentRef;
|
|
1168
|
+
const rawContentRef = record['contentRef'];
|
|
1169
|
+
if (rawContentRef !== undefined && rawContentRef !== null) {
|
|
1170
|
+
if (typeof rawContentRef !== 'object' || Array.isArray(rawContentRef)) {
|
|
1171
|
+
diagnostics.push('Quick View contentRef must be an object reference to a rich-block preset.');
|
|
1172
|
+
}
|
|
1173
|
+
else {
|
|
1174
|
+
const refObj = rawContentRef;
|
|
1175
|
+
const kind = typeof refObj['kind'] === 'string' ? refObj['kind'].trim() : '';
|
|
1176
|
+
const namespace = typeof refObj['namespace'] === 'string' ? refObj['namespace'].trim() : '';
|
|
1177
|
+
const presetId = typeof refObj['presetId'] === 'string' ? refObj['presetId'].trim() : '';
|
|
1178
|
+
const version = typeof refObj['version'] === 'string' ? refObj['version'].trim() : '';
|
|
1179
|
+
if (kind !== 'rich-block') {
|
|
1180
|
+
diagnostics.push(`Quick View contentRef.kind must be "rich-block"; received "${kind || 'empty'}".`);
|
|
1181
|
+
}
|
|
1182
|
+
if (!namespace) {
|
|
1183
|
+
diagnostics.push('Quick View contentRef.namespace must be a non-empty string.');
|
|
1184
|
+
}
|
|
1185
|
+
if (!presetId) {
|
|
1186
|
+
diagnostics.push('Quick View contentRef.presetId must be a non-empty string.');
|
|
1187
|
+
}
|
|
1188
|
+
if (!version) {
|
|
1189
|
+
diagnostics.push('Quick View contentRef.version must be explicitly declared.');
|
|
1190
|
+
}
|
|
1191
|
+
if ('nodes' in refObj || 'inputs' in refObj || 'action' in refObj) {
|
|
1192
|
+
diagnostics.push('Quick View contentRef cannot embed inline nodes, inputs or actions.');
|
|
1193
|
+
}
|
|
1194
|
+
if (kind === 'rich-block' &&
|
|
1195
|
+
namespace &&
|
|
1196
|
+
presetId &&
|
|
1197
|
+
version &&
|
|
1198
|
+
!('nodes' in refObj || 'inputs' in refObj || 'action' in refObj)) {
|
|
1199
|
+
normalizedContentRef = {
|
|
1200
|
+
kind: 'rich-block',
|
|
1201
|
+
namespace,
|
|
1202
|
+
presetId,
|
|
1203
|
+
version,
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
if (diagnostics.length > 0 || !normalizedRecordOpen) {
|
|
1209
|
+
return {
|
|
1210
|
+
valid: false,
|
|
1211
|
+
binding: null,
|
|
1212
|
+
diagnostics,
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
return {
|
|
1216
|
+
valid: true,
|
|
1217
|
+
binding: {
|
|
1218
|
+
recordOpen: normalizedRecordOpen,
|
|
1219
|
+
...(previewSurfaceId ? { previewSurfaceId } : {}),
|
|
1220
|
+
...(normalizedContentRef ? { contentRef: normalizedContentRef } : {}),
|
|
1221
|
+
...(detailPresentation ? { detailPresentation } : {}),
|
|
1222
|
+
},
|
|
1223
|
+
diagnostics: [],
|
|
1224
|
+
};
|
|
1225
|
+
}
|
|
1226
|
+
function normalizeResourceQuickViewBinding(value) {
|
|
1227
|
+
return validateResourceQuickViewBinding(value).binding;
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Resolve ou sintetiza de forma determinística o `ResourceQuickViewBinding` de um campo
|
|
1231
|
+
* (`FieldDefinition` ou `FieldMetadata`), priorizando:
|
|
1232
|
+
* 1. `field.quickView` explícito;
|
|
1233
|
+
* 2. `field.presentation.interactions.quickView` explícito;
|
|
1234
|
+
* 3. síntese automática a partir de `field.resourceReference` ou `field.optionSource.detail`.
|
|
1235
|
+
*
|
|
1236
|
+
* Protege contra colisão de `valueField`/`optionSource.valuePropertyPath` (`'id'` da opção)
|
|
1237
|
+
* com o identificador da própria entidade pai quando o campo de origem possui outro nome
|
|
1238
|
+
* (ex.: `cargoId`, `fornecedorId`).
|
|
1239
|
+
*/
|
|
1240
|
+
function resolveFieldQuickViewBinding(candidate) {
|
|
1241
|
+
if (!candidate || typeof candidate !== 'object') {
|
|
1242
|
+
return null;
|
|
1243
|
+
}
|
|
1244
|
+
const explicitQuickView = normalizeResourceQuickViewBinding(candidate.quickView);
|
|
1245
|
+
if (explicitQuickView) {
|
|
1246
|
+
return explicitQuickView;
|
|
1247
|
+
}
|
|
1248
|
+
const presentationQuickView = normalizeResourceQuickViewBinding(candidate.presentation?.interactions?.quickView);
|
|
1249
|
+
if (presentationQuickView) {
|
|
1250
|
+
return presentationQuickView;
|
|
1251
|
+
}
|
|
1252
|
+
const fieldName = typeof candidate.name === 'string' ? candidate.name.trim() : '';
|
|
1253
|
+
const rawValueField = typeof candidate.valueField === 'string' ? candidate.valueField.trim() : '';
|
|
1254
|
+
const optionValueProperty = typeof candidate.optionSource?.valuePropertyPath === 'string' &&
|
|
1255
|
+
candidate.optionSource.valuePropertyPath.trim().length > 0
|
|
1256
|
+
? candidate.optionSource.valuePropertyPath.trim()
|
|
1257
|
+
: 'id';
|
|
1258
|
+
// Quando o campo possui optionSource e seu nome não coincide com rawValueField, um valueField
|
|
1259
|
+
// igual a 'id'/'value'/'key' ou a optionValueProperty (ex.: 'numero', 'codigo') refere-se à
|
|
1260
|
+
// chave do OptionDTO e nunca ao campo irmão 'id' do registro pai.
|
|
1261
|
+
const isOptionKeyAlias = rawValueField === 'id' ||
|
|
1262
|
+
rawValueField === 'value' ||
|
|
1263
|
+
rawValueField === 'key' ||
|
|
1264
|
+
rawValueField === optionValueProperty;
|
|
1265
|
+
const effectiveSiblingValueField = rawValueField &&
|
|
1266
|
+
(!candidate.optionSource ||
|
|
1267
|
+
fieldName === rawValueField ||
|
|
1268
|
+
!isOptionKeyAlias)
|
|
1269
|
+
? rawValueField
|
|
1270
|
+
: '';
|
|
1271
|
+
const refCandidate = candidate.resourceReference?.resourceKey
|
|
1272
|
+
? {
|
|
1273
|
+
resourceKey: candidate.resourceReference.resourceKey,
|
|
1274
|
+
sourceIdentityField: (typeof candidate.resourceReference.valueField === 'string'
|
|
1275
|
+
? candidate.resourceReference.valueField.trim()
|
|
1276
|
+
: '') ||
|
|
1277
|
+
effectiveSiblingValueField ||
|
|
1278
|
+
fieldName,
|
|
1279
|
+
surfaceId: candidate.resourceReference.surfaceId || 'detail',
|
|
1280
|
+
previewSurfaceId: candidate.resourceReference.previewSurfaceId,
|
|
1281
|
+
detailPresentation: candidate.resourceReference.detailPresentation === 'drawer' ||
|
|
1282
|
+
candidate.resourceReference.detailPresentation === 'modal'
|
|
1283
|
+
? candidate.resourceReference.detailPresentation
|
|
1284
|
+
: undefined,
|
|
1285
|
+
}
|
|
1286
|
+
: candidate.optionSource?.detail?.resourceKey
|
|
1287
|
+
? {
|
|
1288
|
+
resourceKey: candidate.optionSource.detail.resourceKey,
|
|
1289
|
+
sourceIdentityField: effectiveSiblingValueField || fieldName,
|
|
1290
|
+
surfaceId: candidate.optionSource.detail.surfaceId || 'detail',
|
|
1291
|
+
previewSurfaceId: candidate.optionSource.detail.previewSurfaceId,
|
|
1292
|
+
detailPresentation: candidate.optionSource.detail.presentation === 'drawer' ||
|
|
1293
|
+
candidate.optionSource.detail.presentation === 'modal'
|
|
1294
|
+
? candidate.optionSource.detail.presentation
|
|
1295
|
+
: undefined,
|
|
1296
|
+
}
|
|
1297
|
+
: undefined;
|
|
1298
|
+
if (!refCandidate || !refCandidate.sourceIdentityField) {
|
|
1299
|
+
return null;
|
|
1300
|
+
}
|
|
1301
|
+
return normalizeResourceQuickViewBinding({
|
|
1302
|
+
recordOpen: {
|
|
1303
|
+
sourceIdentityField: refCandidate.sourceIdentityField,
|
|
1304
|
+
target: {
|
|
1305
|
+
resourceKey: refCandidate.resourceKey,
|
|
1306
|
+
surfaceId: refCandidate.surfaceId || 'detail',
|
|
1307
|
+
},
|
|
1308
|
+
},
|
|
1309
|
+
...(refCandidate.previewSurfaceId
|
|
1310
|
+
? { previewSurfaceId: refCandidate.previewSurfaceId }
|
|
1311
|
+
: {}),
|
|
1312
|
+
...(refCandidate.detailPresentation
|
|
1313
|
+
? { detailPresentation: refCandidate.detailPresentation }
|
|
1314
|
+
: {}),
|
|
663
1315
|
});
|
|
664
1316
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
const
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
(
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
}
|
|
834
|
-
const isTable = visualization.surface === 'table-cell';
|
|
835
|
-
const stepLabels = items.map((item, index) => item.label ?? item.id ?? `${index + 1}`);
|
|
836
|
-
const aria = visualization.ariaLabel ?? `${visualization.fallbackText}: ${stepLabels.join(' > ')}`;
|
|
837
|
-
const labelStyleAttr = [];
|
|
838
|
-
if (visualization.stepLabelWidth !== undefined) {
|
|
839
|
-
const widthVal = typeof visualization.stepLabelWidth === 'number'
|
|
840
|
-
? `${visualization.stepLabelWidth}px`
|
|
841
|
-
: String(visualization.stepLabelWidth);
|
|
842
|
-
labelStyleAttr.push(`inline-size: ${escapeHtml(widthVal)}; max-width: ${escapeHtml(widthVal)};`);
|
|
843
|
-
}
|
|
844
|
-
if (visualization.stepLabelLineClamp !== undefined) {
|
|
845
|
-
labelStyleAttr.push(`-webkit-line-clamp: ${visualization.stepLabelLineClamp};`);
|
|
846
|
-
}
|
|
847
|
-
const labelInlineStyle = labelStyleAttr.length ? ` style="${labelStyleAttr.join(' ')}"` : '';
|
|
848
|
-
const stepsHtml = items.map((item, index) => {
|
|
849
|
-
const itemTone = item.tone ?? 'neutral';
|
|
850
|
-
const itemState = item.state ?? '';
|
|
851
|
-
const isLast = index === items.length - 1;
|
|
852
|
-
const itemLabel = stepLabels[index];
|
|
853
|
-
const label = !isTable && item.label ? `<span class="pfx-micro-step__label"${labelInlineStyle}>${escapeHtml(item.label)}</span>` : '';
|
|
854
|
-
const connector = !isLast ? `<span class="pfx-micro-step__connector" data-tone="${escapeHtml(itemTone)}"></span>` : '';
|
|
855
|
-
const stepCircle = `
|
|
856
|
-
<span class="pfx-micro-step__node" data-tone="${escapeHtml(itemTone)}" aria-hidden="true">
|
|
857
|
-
${item.icon ? `<span class="material-icons pfx-micro-step__icon" aria-hidden="true">${escapeHtml(item.icon)}</span>` : `${index + 1}`}
|
|
858
|
-
</span>`;
|
|
859
|
-
return `
|
|
860
|
-
<div class="pfx-micro-step" data-state="${escapeHtml(itemState)}" data-tone="${escapeHtml(itemTone)}">
|
|
861
|
-
<div class="pfx-micro-step__node-wrapper" title="${escapeHtml(itemLabel)}">
|
|
862
|
-
${stepCircle}
|
|
863
|
-
${label}
|
|
864
|
-
</div>
|
|
865
|
-
${connector}
|
|
866
|
-
</div>`;
|
|
867
|
-
}).join('');
|
|
868
|
-
return `
|
|
869
|
-
<span class="pfx-micro-viz pfx-micro-viz__process" role="img" aria-label="${escapeHtml(aria)}">
|
|
870
|
-
${stepsHtml}
|
|
871
|
-
</span>`;
|
|
872
|
-
}
|
|
873
|
-
function renderFallbackVisualizationHtml(visualization, tone) {
|
|
874
|
-
return `
|
|
875
|
-
<span
|
|
876
|
-
class="pfx-micro-viz pfx-micro-viz__fallback"
|
|
877
|
-
data-tone="${escapeHtml(tone)}"
|
|
878
|
-
role="img"
|
|
879
|
-
aria-label="${escapeHtml(visualization.ariaLabel ?? visualization.fallbackText)}"
|
|
880
|
-
>${escapeHtml(visualization.fallbackText)}</span>`;
|
|
1317
|
+
/**
|
|
1318
|
+
* Reconcilia o `ResourceQuickViewBinding` entre a definição base do servidor e uma
|
|
1319
|
+
* customização local persistida:
|
|
1320
|
+
* - Um `local` indefinido, nulo ou inválido nunca apaga o binding canônico do servidor (`base`).
|
|
1321
|
+
* - Quando o campo possui binding canônico do servidor (`base`), `base.recordOpen`
|
|
1322
|
+
* (recurso de destino, `surfaceId` e `sourceIdentityField`) permanece autoritativo
|
|
1323
|
+
* do servidor, permitindo que o `local` customize apenas preferências visuais de UX
|
|
1324
|
+
* (`trigger`, `previewSurfaceId`, `detailPresentation`).
|
|
1325
|
+
*/
|
|
1326
|
+
function reconcileFieldQuickViewBinding(base, local) {
|
|
1327
|
+
const normalizedBase = normalizeResourceQuickViewBinding(base);
|
|
1328
|
+
const normalizedLocal = normalizeResourceQuickViewBinding(local);
|
|
1329
|
+
if (normalizedBase && normalizedLocal) {
|
|
1330
|
+
return {
|
|
1331
|
+
...normalizedBase,
|
|
1332
|
+
...normalizedLocal,
|
|
1333
|
+
recordOpen: normalizedBase.recordOpen,
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1336
|
+
return normalizedLocal ?? normalizedBase ?? undefined;
|
|
1337
|
+
}
|
|
1338
|
+
function readQuickViewFieldOrPath(target, path) {
|
|
1339
|
+
if (Object.prototype.hasOwnProperty.call(target, path)) {
|
|
1340
|
+
return target[path];
|
|
1341
|
+
}
|
|
1342
|
+
if (!path.includes('.')) {
|
|
1343
|
+
return undefined;
|
|
1344
|
+
}
|
|
1345
|
+
return path.split('.').reduce((acc, segment) => {
|
|
1346
|
+
if (!acc || typeof acc !== 'object' || Array.isArray(acc)) {
|
|
1347
|
+
return undefined;
|
|
1348
|
+
}
|
|
1349
|
+
return Object.prototype.hasOwnProperty.call(acc, segment)
|
|
1350
|
+
? acc[segment]
|
|
1351
|
+
: undefined;
|
|
1352
|
+
}, target);
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* Resolve de forma determinística o alvo (`resourceKey`, `surfaceId`, `previewSurfaceId`, `identity`)
|
|
1356
|
+
* a partir de um `ResourceQuickViewBinding` e de um registro candidato (`sourceRecord`).
|
|
1357
|
+
*/
|
|
1358
|
+
function resolveResourceQuickViewTarget(binding, sourceRecord) {
|
|
1359
|
+
const normalized = normalizeResourceQuickViewBinding(binding);
|
|
1360
|
+
if (!normalized ||
|
|
1361
|
+
!sourceRecord ||
|
|
1362
|
+
typeof sourceRecord !== 'object' ||
|
|
1363
|
+
Array.isArray(sourceRecord)) {
|
|
1364
|
+
return null;
|
|
1365
|
+
}
|
|
1366
|
+
const record = sourceRecord;
|
|
1367
|
+
const sourceField = normalized.recordOpen.sourceIdentityField;
|
|
1368
|
+
let candidate = readQuickViewFieldOrPath(record, sourceField);
|
|
1369
|
+
if (candidate === undefined) {
|
|
1370
|
+
for (const envelopeKey of ['row', 'item', 'values']) {
|
|
1371
|
+
const nested = record[envelopeKey];
|
|
1372
|
+
if (nested && typeof nested === 'object' && !Array.isArray(nested)) {
|
|
1373
|
+
candidate = readQuickViewFieldOrPath(nested, sourceField);
|
|
1374
|
+
if (candidate !== undefined) {
|
|
1375
|
+
break;
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
if (candidate && typeof candidate === 'object' && !Array.isArray(candidate)) {
|
|
1381
|
+
const candidateObj = candidate;
|
|
1382
|
+
candidate =
|
|
1383
|
+
candidateObj['id'] ?? candidateObj['value'] ?? candidateObj['key'];
|
|
1384
|
+
}
|
|
1385
|
+
if (typeof candidate === 'number' && Number.isFinite(candidate)) {
|
|
1386
|
+
return {
|
|
1387
|
+
resourceKey: normalized.recordOpen.target.resourceKey,
|
|
1388
|
+
surfaceId: normalized.recordOpen.target.surfaceId,
|
|
1389
|
+
previewSurfaceId: normalized.previewSurfaceId || normalized.recordOpen.target.surfaceId,
|
|
1390
|
+
identity: candidate,
|
|
1391
|
+
};
|
|
1392
|
+
}
|
|
1393
|
+
if (typeof candidate === 'string' && candidate.trim().length > 0) {
|
|
1394
|
+
return {
|
|
1395
|
+
resourceKey: normalized.recordOpen.target.resourceKey,
|
|
1396
|
+
surfaceId: normalized.recordOpen.target.surfaceId,
|
|
1397
|
+
previewSurfaceId: normalized.previewSurfaceId || normalized.recordOpen.target.surfaceId,
|
|
1398
|
+
identity: candidate.trim(),
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1401
|
+
return null;
|
|
1402
|
+
}
|
|
1403
|
+
/**
|
|
1404
|
+
* Verifica se a âncora efêmera de runtime permanece conectada e visível na viewport.
|
|
1405
|
+
*/
|
|
1406
|
+
function isResourceQuickViewAnchorValid(anchor, trigger) {
|
|
1407
|
+
if (!anchor || typeof anchor !== 'object') {
|
|
1408
|
+
return false;
|
|
1409
|
+
}
|
|
1410
|
+
if (typeof anchor.isValid === 'function' && !anchor.isValid()) {
|
|
1411
|
+
return false;
|
|
1412
|
+
}
|
|
1413
|
+
const viewportWidth = typeof window !== 'undefined' && Number.isFinite(window.innerWidth) && window.innerWidth > 0
|
|
1414
|
+
? window.innerWidth
|
|
1415
|
+
: 1920;
|
|
1416
|
+
const viewportHeight = typeof window !== 'undefined' && Number.isFinite(window.innerHeight) && window.innerHeight > 0
|
|
1417
|
+
? window.innerHeight
|
|
1418
|
+
: 1080;
|
|
1419
|
+
if (anchor.kind === 'element') {
|
|
1420
|
+
const el = anchor.element;
|
|
1421
|
+
if (!el || typeof el.getBoundingClientRect !== 'function' || el.isConnected === false) {
|
|
1422
|
+
return false;
|
|
1423
|
+
}
|
|
1424
|
+
const rect = el.getBoundingClientRect();
|
|
1425
|
+
if (!Number.isFinite(rect.left) || !Number.isFinite(rect.top)) {
|
|
1426
|
+
return false;
|
|
1427
|
+
}
|
|
1428
|
+
if (rect.width === 0 && rect.height === 0) {
|
|
1429
|
+
return false;
|
|
1430
|
+
}
|
|
1431
|
+
const edgeTolerance = trigger === 'focus-shortcut' || trigger === 'explicit-button' ? 96 : 0;
|
|
1432
|
+
return (rect.bottom >= -edgeTolerance &&
|
|
1433
|
+
rect.right >= -edgeTolerance &&
|
|
1434
|
+
rect.top <= viewportHeight + edgeTolerance &&
|
|
1435
|
+
rect.left <= viewportWidth + edgeTolerance);
|
|
1436
|
+
}
|
|
1437
|
+
if (anchor.kind === 'virtual-rect') {
|
|
1438
|
+
if (!anchor.anchorKey || !anchor.anchorKey.trim()) {
|
|
1439
|
+
return false;
|
|
1440
|
+
}
|
|
1441
|
+
if (anchor.hostElement && anchor.hostElement.isConnected === false) {
|
|
1442
|
+
return false;
|
|
1443
|
+
}
|
|
1444
|
+
if (typeof anchor.getViewportRect !== 'function') {
|
|
1445
|
+
return false;
|
|
1446
|
+
}
|
|
1447
|
+
const rect = anchor.getViewportRect();
|
|
1448
|
+
if (!rect ||
|
|
1449
|
+
!Number.isFinite(rect.x) ||
|
|
1450
|
+
!Number.isFinite(rect.y) ||
|
|
1451
|
+
!Number.isFinite(rect.width) ||
|
|
1452
|
+
!Number.isFinite(rect.height) ||
|
|
1453
|
+
rect.width < 0 ||
|
|
1454
|
+
rect.height < 0) {
|
|
1455
|
+
return false;
|
|
1456
|
+
}
|
|
1457
|
+
const right = rect.right ?? rect.x + rect.width;
|
|
1458
|
+
const bottom = rect.bottom ?? rect.y + rect.height;
|
|
1459
|
+
const left = rect.left ?? rect.x;
|
|
1460
|
+
const top = rect.top ?? rect.y;
|
|
1461
|
+
return (bottom >= 0 &&
|
|
1462
|
+
right >= 0 &&
|
|
1463
|
+
top <= viewportHeight &&
|
|
1464
|
+
left <= viewportWidth);
|
|
1465
|
+
}
|
|
1466
|
+
return false;
|
|
1467
|
+
}
|
|
1468
|
+
function resolveQuickViewAnchorKey(anchor) {
|
|
1469
|
+
if (anchor.kind === 'virtual-rect') {
|
|
1470
|
+
return anchor.anchorKey.trim();
|
|
1471
|
+
}
|
|
1472
|
+
const explicit = anchor.anchorKey?.trim();
|
|
1473
|
+
if (explicit) {
|
|
1474
|
+
return explicit;
|
|
1475
|
+
}
|
|
1476
|
+
const focusKey = anchor.element?.getAttribute?.('data-praxis-focus-key')?.trim();
|
|
1477
|
+
if (focusKey) {
|
|
1478
|
+
return focusKey;
|
|
1479
|
+
}
|
|
1480
|
+
const id = anchor.element?.id?.trim();
|
|
1481
|
+
if (id) {
|
|
1482
|
+
return `element:${id}`;
|
|
1483
|
+
}
|
|
1484
|
+
return 'element:anonymous';
|
|
881
1485
|
}
|
|
882
1486
|
|
|
883
1487
|
const TONES = new Set([
|
|
884
1488
|
'neutral',
|
|
1489
|
+
'primary',
|
|
1490
|
+
'secondary',
|
|
885
1491
|
'info',
|
|
886
1492
|
'success',
|
|
887
1493
|
'warning',
|
|
888
1494
|
'danger',
|
|
889
1495
|
]);
|
|
1496
|
+
const TONE_ALIASES = {
|
|
1497
|
+
muted: 'neutral',
|
|
1498
|
+
positive: 'success',
|
|
1499
|
+
critical: 'danger',
|
|
1500
|
+
negative: 'danger',
|
|
1501
|
+
};
|
|
890
1502
|
const APPEARANCES = new Set([
|
|
891
1503
|
'plain',
|
|
892
1504
|
'soft',
|
|
@@ -923,6 +1535,9 @@ function resolveFieldPresentation(base, rules, context = {}, options = {}) {
|
|
|
923
1535
|
...effect,
|
|
924
1536
|
};
|
|
925
1537
|
matchedRule = true;
|
|
1538
|
+
if (options.matchPolicy === 'first') {
|
|
1539
|
+
break;
|
|
1540
|
+
}
|
|
926
1541
|
}
|
|
927
1542
|
return matchedRule ? { ...resolved, matchedRule } : resolved;
|
|
928
1543
|
}
|
|
@@ -937,8 +1552,8 @@ function normalizeFieldPresentation(value) {
|
|
|
937
1552
|
const label = normalizeText(value.label);
|
|
938
1553
|
const badge = normalizeText(value.badge);
|
|
939
1554
|
const tooltip = normalizeText(value.tooltip);
|
|
940
|
-
const prefix =
|
|
941
|
-
const suffix =
|
|
1555
|
+
const prefix = normalizeAffix$1(value.prefix);
|
|
1556
|
+
const suffix = normalizeAffix$1(value.suffix);
|
|
942
1557
|
const iconTrue = normalizeText(value.iconTrue);
|
|
943
1558
|
const iconFalse = normalizeText(value.iconFalse);
|
|
944
1559
|
const toneTrue = normalizeTone(value.toneTrue);
|
|
@@ -971,6 +1586,42 @@ function normalizeFieldPresentation(value) {
|
|
|
971
1586
|
: {}),
|
|
972
1587
|
};
|
|
973
1588
|
}
|
|
1589
|
+
function normalizeFieldPresentationRules(value) {
|
|
1590
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
1591
|
+
return undefined;
|
|
1592
|
+
}
|
|
1593
|
+
const normalized = [];
|
|
1594
|
+
for (const candidate of value) {
|
|
1595
|
+
if (!candidate || typeof candidate !== 'object' || Array.isArray(candidate)) {
|
|
1596
|
+
continue;
|
|
1597
|
+
}
|
|
1598
|
+
const rule = candidate;
|
|
1599
|
+
if (!Object.prototype.hasOwnProperty.call(rule, 'when')) {
|
|
1600
|
+
continue;
|
|
1601
|
+
}
|
|
1602
|
+
const when = rule['when'];
|
|
1603
|
+
if (when === undefined) {
|
|
1604
|
+
continue;
|
|
1605
|
+
}
|
|
1606
|
+
const normalizedSet = rule['set'] && typeof rule['set'] === 'object' && !Array.isArray(rule['set'])
|
|
1607
|
+
? normalizeFieldPresentation(rule['set'])
|
|
1608
|
+
: undefined;
|
|
1609
|
+
const normalizedEffect = rule['effect'] && typeof rule['effect'] === 'object' && !Array.isArray(rule['effect'])
|
|
1610
|
+
? normalizeFieldPresentation(rule['effect'])
|
|
1611
|
+
: undefined;
|
|
1612
|
+
const hasSet = !!normalizedSet && Object.keys(normalizedSet).length > 0;
|
|
1613
|
+
const hasEffect = !!normalizedEffect && Object.keys(normalizedEffect).length > 0;
|
|
1614
|
+
if (!hasSet && !hasEffect) {
|
|
1615
|
+
continue;
|
|
1616
|
+
}
|
|
1617
|
+
normalized.push({
|
|
1618
|
+
when,
|
|
1619
|
+
...(hasSet ? { set: normalizedSet } : {}),
|
|
1620
|
+
...(hasEffect ? { effect: normalizedEffect } : {}),
|
|
1621
|
+
});
|
|
1622
|
+
}
|
|
1623
|
+
return normalized.length > 0 ? normalized : undefined;
|
|
1624
|
+
}
|
|
974
1625
|
function matchesPresentationRule(rule, context, jsonLogic) {
|
|
975
1626
|
try {
|
|
976
1627
|
const result = jsonLogic.evaluate(rule.when, context);
|
|
@@ -978,15 +1629,87 @@ function matchesPresentationRule(rule, context, jsonLogic) {
|
|
|
978
1629
|
? jsonLogic.truthy(result)
|
|
979
1630
|
: Boolean(result);
|
|
980
1631
|
}
|
|
981
|
-
catch {
|
|
1632
|
+
catch {
|
|
1633
|
+
return false;
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
function normalizePresenter(value) {
|
|
1637
|
+
return normalizeEnum(value, PRESENTERS);
|
|
1638
|
+
}
|
|
1639
|
+
function normalizeTone(value) {
|
|
1640
|
+
if (typeof value !== 'string') {
|
|
1641
|
+
return undefined;
|
|
1642
|
+
}
|
|
1643
|
+
const normalized = value.trim().toLowerCase();
|
|
1644
|
+
if (!normalized) {
|
|
1645
|
+
return undefined;
|
|
1646
|
+
}
|
|
1647
|
+
if (TONES.has(normalized)) {
|
|
1648
|
+
return normalized;
|
|
1649
|
+
}
|
|
1650
|
+
return TONE_ALIASES[normalized];
|
|
1651
|
+
}
|
|
1652
|
+
const MASKED_TOKEN_SYMBOL_REGEX = /\*{2,}|•{2,}|■{2,}|█{2,}/;
|
|
1653
|
+
const MASKED_TOKEN_LABEL_REGEX = /^\[?\s*(MASKED|REDACTED|PROTEGIDO|OCULTO|ANONIMIZADO)\s*\]?$/i;
|
|
1654
|
+
/**
|
|
1655
|
+
* Identifies masked or redacted display values produced by privacy/LGPD governance policies.
|
|
1656
|
+
*/
|
|
1657
|
+
function isMaskedPresentationToken(value) {
|
|
1658
|
+
if (value === null || value === undefined) {
|
|
1659
|
+
return false;
|
|
1660
|
+
}
|
|
1661
|
+
const candidate = String(value).trim();
|
|
1662
|
+
if (!candidate) {
|
|
982
1663
|
return false;
|
|
983
1664
|
}
|
|
1665
|
+
return MASKED_TOKEN_SYMBOL_REGEX.test(candidate) || MASKED_TOKEN_LABEL_REGEX.test(candidate);
|
|
984
1666
|
}
|
|
985
|
-
|
|
986
|
-
|
|
1667
|
+
/**
|
|
1668
|
+
* Resolves visual prefix/suffix affixes around non-empty display text while:
|
|
1669
|
+
* - returning `null` for null/blank text (preventing orphan affixes),
|
|
1670
|
+
* - suppressing affixes on LGPD-masked tokens,
|
|
1671
|
+
* - avoiding affix duplication when the formatted text already carries the affix.
|
|
1672
|
+
*/
|
|
1673
|
+
function resolveAffixedPresentationParts(rawText, affixes) {
|
|
1674
|
+
if (rawText === null || rawText === undefined) {
|
|
1675
|
+
return null;
|
|
1676
|
+
}
|
|
1677
|
+
const text = String(rawText).trim();
|
|
1678
|
+
if (!text) {
|
|
1679
|
+
return null;
|
|
1680
|
+
}
|
|
1681
|
+
if (isMaskedPresentationToken(text)) {
|
|
1682
|
+
return {
|
|
1683
|
+
text,
|
|
1684
|
+
prefix: null,
|
|
1685
|
+
suffix: null,
|
|
1686
|
+
masked: true,
|
|
1687
|
+
};
|
|
1688
|
+
}
|
|
1689
|
+
const candidatePrefix = typeof affixes?.prefix === 'string' && affixes.prefix.trim().length > 0
|
|
1690
|
+
? affixes.prefix
|
|
1691
|
+
: null;
|
|
1692
|
+
const candidateSuffix = typeof affixes?.suffix === 'string' && affixes.suffix.trim().length > 0
|
|
1693
|
+
? affixes.suffix
|
|
1694
|
+
: null;
|
|
1695
|
+
const prefix = candidatePrefix && !text.startsWith(candidatePrefix) ? candidatePrefix : null;
|
|
1696
|
+
const suffix = candidateSuffix && !text.endsWith(candidateSuffix) ? candidateSuffix : null;
|
|
1697
|
+
return {
|
|
1698
|
+
text,
|
|
1699
|
+
prefix,
|
|
1700
|
+
suffix,
|
|
1701
|
+
masked: false,
|
|
1702
|
+
};
|
|
987
1703
|
}
|
|
988
|
-
|
|
989
|
-
|
|
1704
|
+
/**
|
|
1705
|
+
* Formats non-empty display text with deduplicated visual affixes, omitting affixes on masked tokens.
|
|
1706
|
+
*/
|
|
1707
|
+
function formatAffixedPresentationText(rawText, affixes) {
|
|
1708
|
+
const parts = resolveAffixedPresentationParts(rawText, affixes);
|
|
1709
|
+
if (!parts) {
|
|
1710
|
+
return null;
|
|
1711
|
+
}
|
|
1712
|
+
return `${parts.prefix ?? ''}${parts.text}${parts.suffix ?? ''}`;
|
|
990
1713
|
}
|
|
991
1714
|
function normalizeAppearance(value) {
|
|
992
1715
|
return normalizeEnum(value, APPEARANCES);
|
|
@@ -1005,15 +1728,479 @@ function normalizeText(value) {
|
|
|
1005
1728
|
const trimmed = value.trim();
|
|
1006
1729
|
return trimmed.length ? trimmed : undefined;
|
|
1007
1730
|
}
|
|
1731
|
+
function normalizeAffix$1(value) {
|
|
1732
|
+
return typeof value === 'string' && value.trim().length > 0 ? value : undefined;
|
|
1733
|
+
}
|
|
1008
1734
|
function normalizeInteractions(value) {
|
|
1735
|
+
const quickView = normalizeResourceQuickViewBinding(value.quickView);
|
|
1009
1736
|
return {
|
|
1010
1737
|
...(value.copy === true ? { copy: true } : {}),
|
|
1011
1738
|
...(value.details === true ? { details: true } : {}),
|
|
1012
1739
|
...(value.expand === true ? { expand: true } : {}),
|
|
1013
1740
|
...(value.link === true ? { link: true } : {}),
|
|
1741
|
+
...(quickView ? { quickView } : {}),
|
|
1014
1742
|
};
|
|
1015
1743
|
}
|
|
1016
1744
|
|
|
1745
|
+
/** Converts UI tokens only under declared scalar items; invalid input is never dropped or partially converted. */
|
|
1746
|
+
function normalizeScalarArrayValue(value, items) {
|
|
1747
|
+
if (items.enum !== undefined && !isScalarEnum(items.enum))
|
|
1748
|
+
return { valid: false, invalidIndices: [-1] };
|
|
1749
|
+
if (value == null)
|
|
1750
|
+
return { valid: true, value };
|
|
1751
|
+
if (!Array.isArray(value))
|
|
1752
|
+
return { valid: false, invalidIndices: [-1] };
|
|
1753
|
+
const converted = [];
|
|
1754
|
+
const invalidIndices = [];
|
|
1755
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
1756
|
+
const item = normalizeItem(value[index], items);
|
|
1757
|
+
if (item === undefined || items.enum && !items.enum.some(candidate => candidate === item))
|
|
1758
|
+
invalidIndices.push(index);
|
|
1759
|
+
else
|
|
1760
|
+
converted.push(item);
|
|
1761
|
+
}
|
|
1762
|
+
return invalidIndices.length ? { valid: false, invalidIndices } : { valid: true, value: converted };
|
|
1763
|
+
}
|
|
1764
|
+
function normalizeItem(value, items) {
|
|
1765
|
+
if (value == null)
|
|
1766
|
+
return undefined;
|
|
1767
|
+
if (items.type === 'boolean') {
|
|
1768
|
+
if (typeof value === 'boolean')
|
|
1769
|
+
return value;
|
|
1770
|
+
return value === 'true' ? true : value === 'false' ? false : undefined;
|
|
1771
|
+
}
|
|
1772
|
+
if (items.type === 'integer' || items.type === 'number') {
|
|
1773
|
+
const number = typeof value === 'number' ? value : typeof value === 'string' &&
|
|
1774
|
+
/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(value) ? Number(value) : NaN;
|
|
1775
|
+
if (!Number.isFinite(number) || items.type === 'integer' && !Number.isSafeInteger(number))
|
|
1776
|
+
return undefined;
|
|
1777
|
+
return number;
|
|
1778
|
+
}
|
|
1779
|
+
if (items.type !== 'string')
|
|
1780
|
+
return undefined;
|
|
1781
|
+
if (items.format === 'date') {
|
|
1782
|
+
if (value instanceof Date) {
|
|
1783
|
+
if (Number.isNaN(value.getTime()))
|
|
1784
|
+
return undefined;
|
|
1785
|
+
const date = `${String(value.getFullYear()).padStart(4, '0')}-${String(value.getMonth() + 1).padStart(2, '0')}-${String(value.getDate()).padStart(2, '0')}`;
|
|
1786
|
+
return isIsoDate(date) ? date : undefined;
|
|
1787
|
+
}
|
|
1788
|
+
return typeof value === 'string' && isIsoDate(value) ? value : undefined;
|
|
1789
|
+
}
|
|
1790
|
+
if (items.format === 'date-time') {
|
|
1791
|
+
if (value instanceof Date)
|
|
1792
|
+
return Number.isNaN(value.getTime()) ? undefined : value.toISOString();
|
|
1793
|
+
return typeof value === 'string' && isIsoDateTime(value) ? value : undefined;
|
|
1794
|
+
}
|
|
1795
|
+
return typeof value === 'string' ? value : undefined;
|
|
1796
|
+
}
|
|
1797
|
+
function isIsoDate(value) {
|
|
1798
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
1799
|
+
if (!match)
|
|
1800
|
+
return false;
|
|
1801
|
+
const year = Number(match[1]), month = Number(match[2]), day = Number(match[3]);
|
|
1802
|
+
const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
1803
|
+
const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
1804
|
+
return month >= 1 && month <= 12 && day >= 1 && day <= days[month - 1];
|
|
1805
|
+
}
|
|
1806
|
+
function isIsoDateTime(value) {
|
|
1807
|
+
const match = /^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(?:Z|([+-])(\d{2}):(\d{2}))?$/.exec(value);
|
|
1808
|
+
if (!match || !isIsoDate(match[1]))
|
|
1809
|
+
return false;
|
|
1810
|
+
if (Number(match[2]) > 23 || Number(match[3]) > 59 || Number(match[4] ?? 0) > 59)
|
|
1811
|
+
return false;
|
|
1812
|
+
const offsetHours = Number(match[7] ?? 0), offsetMinutes = Number(match[8] ?? 0);
|
|
1813
|
+
return offsetHours <= 18 && offsetMinutes <= 59 && (offsetHours !== 18 || offsetMinutes === 0);
|
|
1814
|
+
}
|
|
1815
|
+
/** Internal admission of the scalar subset already published in JSON Schema items. */
|
|
1816
|
+
function normalizeScalarItemsSchema(value) {
|
|
1817
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
1818
|
+
return undefined;
|
|
1819
|
+
const record = value;
|
|
1820
|
+
if (typeof record['type'] !== 'string' || !['string', 'integer', 'number', 'boolean'].includes(record['type']))
|
|
1821
|
+
return undefined;
|
|
1822
|
+
const result = { type: record['type'] };
|
|
1823
|
+
if (typeof record['format'] === 'string')
|
|
1824
|
+
result.format = record['format'];
|
|
1825
|
+
if (record['enum'] !== undefined) {
|
|
1826
|
+
if (!isScalarEnum(record['enum']))
|
|
1827
|
+
throw new TypeError('Scalar items enum must contain JSON scalar values.');
|
|
1828
|
+
result.enum = [...record['enum']];
|
|
1829
|
+
}
|
|
1830
|
+
return result;
|
|
1831
|
+
}
|
|
1832
|
+
function isScalarEnum(value) {
|
|
1833
|
+
return Array.isArray(value) && value.length > 0 && value.every(item => item === null || typeof item === 'string' || typeof item === 'boolean' || typeof item === 'number' && Number.isFinite(item));
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
/**
|
|
1837
|
+
* Enum que define os tipos de controle (`CONTROL_TYPE`) disponíveis para a apresentação dos campos de formulário.
|
|
1838
|
+
*
|
|
1839
|
+
* O `CONTROL_TYPE` especifica o tipo de elemento de UI (User Interface) que será usado para capturar ou exibir dados do campo.
|
|
1840
|
+
* Essa configuração permite que a camada de apresentação saiba como renderizar o campo e oferecer a interação adequada ao usuário.
|
|
1841
|
+
* Em casos onde o `CONTROL_TYPE` não é especificado, a camada de apresentação pode usar o valor de `TYPE` (definido em `FieldDataType`)
|
|
1842
|
+
* para decidir o controle mais adequado de forma automática.
|
|
1843
|
+
*/
|
|
1844
|
+
const FieldControlType = {
|
|
1845
|
+
AI_PROMPT: 'aiPrompt',
|
|
1846
|
+
APP_BAR: 'appBar',
|
|
1847
|
+
ARC_GAUGE: 'arcGauge',
|
|
1848
|
+
ARRAY_INPUT: 'array',
|
|
1849
|
+
ASYNC_SELECT: 'async-select',
|
|
1850
|
+
AUTO_COMPLETE: 'autoComplete',
|
|
1851
|
+
AVATAR: 'avatar',
|
|
1852
|
+
BARCODE_GENERATOR: 'barcodeGenerator',
|
|
1853
|
+
BOTTOM_NAVIGATION: 'bottomNavigation',
|
|
1854
|
+
BREADCRUMB: 'breadcrumb',
|
|
1855
|
+
BUTTON: 'button',
|
|
1856
|
+
BUTTON_TOGGLE: 'buttonToggle',
|
|
1857
|
+
CALENDAR: 'calendar',
|
|
1858
|
+
CARD: 'card',
|
|
1859
|
+
CHECKBOX: 'checkbox',
|
|
1860
|
+
CHIP_INPUT: 'chipInput',
|
|
1861
|
+
CHIP_LIST: 'chipList',
|
|
1862
|
+
CIRCULAR_GAUGE: 'circularGauge',
|
|
1863
|
+
COLOR_GRADIENT: 'colorGradient',
|
|
1864
|
+
CPF_CNPJ_INPUT: 'cpfCnpjInput',
|
|
1865
|
+
COLOR_PALETTE: 'colorPalette',
|
|
1866
|
+
COLOR_PICKER: 'colorPicker',
|
|
1867
|
+
COLOR_INPUT: 'color',
|
|
1868
|
+
CRON_BUILDER: 'cronBuilder',
|
|
1869
|
+
CONTEXT_MENU: 'contextMenu',
|
|
1870
|
+
CONVERSATIONAL_UI: 'conversationalUI',
|
|
1871
|
+
CURRENCY_INPUT: 'currency',
|
|
1872
|
+
DATE_INPUT: 'dateInput',
|
|
1873
|
+
DATE_PICKER: 'date',
|
|
1874
|
+
DATE_RANGE: 'dateRange',
|
|
1875
|
+
DATE_TIME_PICKER: 'dateTime',
|
|
1876
|
+
DATE_TIME_RANGE: 'dateTimeRange',
|
|
1877
|
+
DATETIME_LOCAL_INPUT: 'dateTimeLocal',
|
|
1878
|
+
DIALOG: 'dialog',
|
|
1879
|
+
DRAWER: 'drawer',
|
|
1880
|
+
DROP_DOWN_TREE: 'dropDownTree',
|
|
1881
|
+
EMAIL_INPUT: 'email',
|
|
1882
|
+
ENTITY_LOOKUP: 'entityLookup',
|
|
1883
|
+
EXPANSION_PANEL: 'expansionPanel',
|
|
1884
|
+
FILE_SAVER: 'fileSaver',
|
|
1885
|
+
FILE_SELECT: 'fileSelect',
|
|
1886
|
+
FILE_UPLOAD: 'upload',
|
|
1887
|
+
FILTER: 'filter',
|
|
1888
|
+
FLOATING_LABEL: 'floatingLabel',
|
|
1889
|
+
FLOATING_ACTION_BUTTON: 'floatingActionButton',
|
|
1890
|
+
GRID: 'grid',
|
|
1891
|
+
GRID_LAYOUT: 'gridLayout',
|
|
1892
|
+
INPUT: 'input',
|
|
1893
|
+
INLINE_SELECT: 'inlineSelect',
|
|
1894
|
+
INLINE_SEARCHABLE_SELECT: 'inlineSearchableSelect',
|
|
1895
|
+
INLINE_ASYNC_SELECT: 'inlineAsyncSelect',
|
|
1896
|
+
INLINE_ENTITY_LOOKUP: 'inlineEntityLookup',
|
|
1897
|
+
INLINE_AUTOCOMPLETE: 'inlineAutocomplete',
|
|
1898
|
+
INLINE_INPUT: 'inlineInput',
|
|
1899
|
+
INLINE_PHONE: 'inlinePhone',
|
|
1900
|
+
INLINE_NUMBER: 'inlineNumber',
|
|
1901
|
+
INLINE_CURRENCY: 'inlineCurrency',
|
|
1902
|
+
INLINE_CURRENCY_RANGE: 'inlineCurrencyRange',
|
|
1903
|
+
INLINE_MULTISELECT: 'inlineMultiSelect',
|
|
1904
|
+
INLINE_TOGGLE: 'inlineToggle',
|
|
1905
|
+
INLINE_RANGE: 'inlineRange',
|
|
1906
|
+
INLINE_PERIOD_RANGE: 'inlinePeriodRange',
|
|
1907
|
+
INLINE_YEAR_RANGE: 'inlineYearRange',
|
|
1908
|
+
INLINE_MONTH_RANGE: 'inlineMonthRange',
|
|
1909
|
+
INLINE_DATE: 'inlineDate',
|
|
1910
|
+
INLINE_DATE_RANGE: 'inlineDateRange',
|
|
1911
|
+
INLINE_TIME: 'inlineTime',
|
|
1912
|
+
INLINE_TIME_RANGE: 'inlineTimeRange',
|
|
1913
|
+
INLINE_TREE_SELECT: 'inlineTreeSelect',
|
|
1914
|
+
INLINE_RATING: 'inlineRating',
|
|
1915
|
+
INLINE_DISTANCE_RADIUS: 'inlineDistanceRadius',
|
|
1916
|
+
INLINE_PIPELINE_STATUS: 'inlinePipelineStatus',
|
|
1917
|
+
INLINE_SCORE_PRIORITY: 'inlineScorePriority',
|
|
1918
|
+
INLINE_RELATIVE_PERIOD: 'inlineRelativePeriod',
|
|
1919
|
+
INLINE_SENTIMENT: 'inlineSentiment',
|
|
1920
|
+
INLINE_COLOR_LABEL: 'inlineColorLabel',
|
|
1921
|
+
LINEAR_GAUGE: 'linearGauge',
|
|
1922
|
+
LIST_VIEW: 'listView',
|
|
1923
|
+
MAP: 'map',
|
|
1924
|
+
MASKED_TEXT_BOX: 'maskedTextBox',
|
|
1925
|
+
MONTH_INPUT: 'month',
|
|
1926
|
+
MULTI_COLUMN_COMBO_BOX: 'multiColumnComboBox',
|
|
1927
|
+
MULTI_SELECT: 'multiSelect',
|
|
1928
|
+
MULTI_SELECT_TREE: 'multiSelectTree',
|
|
1929
|
+
TRANSFER_LIST: 'transferList',
|
|
1930
|
+
NOTIFICATION: 'notification',
|
|
1931
|
+
NUMERIC_TEXT_BOX: 'numericTextBox',
|
|
1932
|
+
PAGER: 'pager',
|
|
1933
|
+
PAGINATOR: 'paginator',
|
|
1934
|
+
PASSWORD: 'password',
|
|
1935
|
+
PDF_VIEWER: 'pdfViewer',
|
|
1936
|
+
PHONE: 'phone',
|
|
1937
|
+
PIVOT_GRID: 'pivotGrid',
|
|
1938
|
+
POPUP: 'popup',
|
|
1939
|
+
PROGRESS_BAR: 'progressBar',
|
|
1940
|
+
PROGRESS_SPINNER: 'progressSpinner',
|
|
1941
|
+
QR_CODE: 'qrCode',
|
|
1942
|
+
RADIO: 'radio',
|
|
1943
|
+
RADIAL_GAUGE: 'radialGauge',
|
|
1944
|
+
RANGE_SLIDER: 'rangeSlider',
|
|
1945
|
+
PRICE_RANGE: 'priceRange',
|
|
1946
|
+
RATING: 'rating',
|
|
1947
|
+
RICH_TEXT_EDITOR: 'richTextEditor',
|
|
1948
|
+
RIPPLE: 'ripple',
|
|
1949
|
+
SCROLL_VIEW: 'scrollView',
|
|
1950
|
+
SEARCH_INPUT: 'search',
|
|
1951
|
+
SEARCHABLE_SELECT: 'searchable-select',
|
|
1952
|
+
SELECTION_LIST: 'selectionList',
|
|
1953
|
+
SELECT: 'select',
|
|
1954
|
+
SIGNATURE: 'signature',
|
|
1955
|
+
SLIDER: 'slider',
|
|
1956
|
+
SORTABLE: 'sortable',
|
|
1957
|
+
SORTABLE_TABLE: 'sortableTable',
|
|
1958
|
+
SPLITTER: 'splitter',
|
|
1959
|
+
SPREADSHEET: 'spreadsheet',
|
|
1960
|
+
STACK_LAYOUT: 'stackLayout',
|
|
1961
|
+
STEP_BAR: 'stepBar',
|
|
1962
|
+
STEPPER: 'stepper',
|
|
1963
|
+
SVG_ICON: 'svgIcon',
|
|
1964
|
+
TABS: 'tabs',
|
|
1965
|
+
TEXTAREA: 'textarea',
|
|
1966
|
+
TIME_INPUT: 'time',
|
|
1967
|
+
TIME_PICKER: 'timePicker',
|
|
1968
|
+
TIME_RANGE: 'timeRange',
|
|
1969
|
+
TIMELINE: 'timeline',
|
|
1970
|
+
TOGGLE: 'toggle',
|
|
1971
|
+
TOOLBAR: 'toolbar',
|
|
1972
|
+
TOOLTIP: 'tooltip',
|
|
1973
|
+
TREE_VIEW: 'treeView',
|
|
1974
|
+
TREE_SELECT: 'treeSelect',
|
|
1975
|
+
TYPOGRAPHY: 'typography',
|
|
1976
|
+
URL_INPUT: 'url',
|
|
1977
|
+
WEEK_INPUT: 'week',
|
|
1978
|
+
WINDOW: 'window',
|
|
1979
|
+
YEAR_INPUT: 'year',
|
|
1980
|
+
};
|
|
1981
|
+
|
|
1982
|
+
const INLINE_FILTER_CONTROL_TYPES = Object.freeze({
|
|
1983
|
+
SELECT: FieldControlType.INLINE_SELECT,
|
|
1984
|
+
SEARCHABLE_SELECT: FieldControlType.INLINE_SEARCHABLE_SELECT,
|
|
1985
|
+
ASYNC_SELECT: FieldControlType.INLINE_ASYNC_SELECT,
|
|
1986
|
+
ENTITY_LOOKUP: FieldControlType.INLINE_ENTITY_LOOKUP,
|
|
1987
|
+
AUTOCOMPLETE: FieldControlType.INLINE_AUTOCOMPLETE,
|
|
1988
|
+
NUMBER: FieldControlType.INLINE_NUMBER,
|
|
1989
|
+
CURRENCY: FieldControlType.INLINE_CURRENCY,
|
|
1990
|
+
CURRENCY_RANGE: FieldControlType.INLINE_CURRENCY_RANGE,
|
|
1991
|
+
MULTI_SELECT: FieldControlType.INLINE_MULTISELECT,
|
|
1992
|
+
INPUT: FieldControlType.INLINE_INPUT,
|
|
1993
|
+
PHONE: FieldControlType.INLINE_PHONE,
|
|
1994
|
+
TOGGLE: FieldControlType.INLINE_TOGGLE,
|
|
1995
|
+
RANGE: FieldControlType.INLINE_RANGE,
|
|
1996
|
+
PERIOD_RANGE: FieldControlType.INLINE_PERIOD_RANGE,
|
|
1997
|
+
YEAR_RANGE: FieldControlType.INLINE_YEAR_RANGE,
|
|
1998
|
+
MONTH_RANGE: FieldControlType.INLINE_MONTH_RANGE,
|
|
1999
|
+
DATE: FieldControlType.INLINE_DATE,
|
|
2000
|
+
DATE_RANGE: FieldControlType.INLINE_DATE_RANGE,
|
|
2001
|
+
TIME: FieldControlType.INLINE_TIME,
|
|
2002
|
+
TIME_RANGE: FieldControlType.INLINE_TIME_RANGE,
|
|
2003
|
+
TREE_SELECT: FieldControlType.INLINE_TREE_SELECT,
|
|
2004
|
+
RATING: FieldControlType.INLINE_RATING,
|
|
2005
|
+
DISTANCE_RADIUS: FieldControlType.INLINE_DISTANCE_RADIUS,
|
|
2006
|
+
PIPELINE_STATUS: FieldControlType.INLINE_PIPELINE_STATUS,
|
|
2007
|
+
SCORE_PRIORITY: FieldControlType.INLINE_SCORE_PRIORITY,
|
|
2008
|
+
RELATIVE_PERIOD: FieldControlType.INLINE_RELATIVE_PERIOD,
|
|
2009
|
+
SENTIMENT: FieldControlType.INLINE_SENTIMENT,
|
|
2010
|
+
COLOR_LABEL: FieldControlType.INLINE_COLOR_LABEL,
|
|
2011
|
+
});
|
|
2012
|
+
const INLINE_FILTER_CONTROL_TYPE_VALUES = Object.freeze(Object.values(INLINE_FILTER_CONTROL_TYPES));
|
|
2013
|
+
const INLINE_FILTER_CONTROL_TYPE_SET = new Set(INLINE_FILTER_CONTROL_TYPE_VALUES);
|
|
2014
|
+
function normalizeInlineControlTypeToken(value) {
|
|
2015
|
+
return String(value || '')
|
|
2016
|
+
.trim()
|
|
2017
|
+
.toLowerCase()
|
|
2018
|
+
.replace(/[-_\s]/g, '');
|
|
2019
|
+
}
|
|
2020
|
+
const INLINE_FILTER_CANONICAL_TOKEN_TO_CONTROL_TYPE_MAP = {
|
|
2021
|
+
inlineselect: INLINE_FILTER_CONTROL_TYPES.SELECT,
|
|
2022
|
+
inlinesearchableselect: INLINE_FILTER_CONTROL_TYPES.SEARCHABLE_SELECT,
|
|
2023
|
+
inlineasyncselect: INLINE_FILTER_CONTROL_TYPES.ASYNC_SELECT,
|
|
2024
|
+
inlineentitylookup: INLINE_FILTER_CONTROL_TYPES.ENTITY_LOOKUP,
|
|
2025
|
+
inlineautocomplete: INLINE_FILTER_CONTROL_TYPES.AUTOCOMPLETE,
|
|
2026
|
+
inlinenumber: INLINE_FILTER_CONTROL_TYPES.NUMBER,
|
|
2027
|
+
inlinecurrency: INLINE_FILTER_CONTROL_TYPES.CURRENCY,
|
|
2028
|
+
inlinecurrencyrange: INLINE_FILTER_CONTROL_TYPES.CURRENCY_RANGE,
|
|
2029
|
+
inlinemultiselect: INLINE_FILTER_CONTROL_TYPES.MULTI_SELECT,
|
|
2030
|
+
inlineinput: INLINE_FILTER_CONTROL_TYPES.INPUT,
|
|
2031
|
+
inlinephone: INLINE_FILTER_CONTROL_TYPES.PHONE,
|
|
2032
|
+
inlinetoggle: INLINE_FILTER_CONTROL_TYPES.TOGGLE,
|
|
2033
|
+
inlinerange: INLINE_FILTER_CONTROL_TYPES.RANGE,
|
|
2034
|
+
inlineperiodrange: INLINE_FILTER_CONTROL_TYPES.PERIOD_RANGE,
|
|
2035
|
+
inlineyearrange: INLINE_FILTER_CONTROL_TYPES.YEAR_RANGE,
|
|
2036
|
+
inlinemonthrange: INLINE_FILTER_CONTROL_TYPES.MONTH_RANGE,
|
|
2037
|
+
inlinedate: INLINE_FILTER_CONTROL_TYPES.DATE,
|
|
2038
|
+
inlinedaterange: INLINE_FILTER_CONTROL_TYPES.DATE_RANGE,
|
|
2039
|
+
inlinetime: INLINE_FILTER_CONTROL_TYPES.TIME,
|
|
2040
|
+
inlinetimerange: INLINE_FILTER_CONTROL_TYPES.TIME_RANGE,
|
|
2041
|
+
inlinetreeselect: INLINE_FILTER_CONTROL_TYPES.TREE_SELECT,
|
|
2042
|
+
inlinerating: INLINE_FILTER_CONTROL_TYPES.RATING,
|
|
2043
|
+
inlinedistanceradius: INLINE_FILTER_CONTROL_TYPES.DISTANCE_RADIUS,
|
|
2044
|
+
inlinepipelinestatus: INLINE_FILTER_CONTROL_TYPES.PIPELINE_STATUS,
|
|
2045
|
+
inlinescorepriority: INLINE_FILTER_CONTROL_TYPES.SCORE_PRIORITY,
|
|
2046
|
+
inlinerelativeperiod: INLINE_FILTER_CONTROL_TYPES.RELATIVE_PERIOD,
|
|
2047
|
+
inlinesentiment: INLINE_FILTER_CONTROL_TYPES.SENTIMENT,
|
|
2048
|
+
inlinecolorlabel: INLINE_FILTER_CONTROL_TYPES.COLOR_LABEL,
|
|
2049
|
+
};
|
|
2050
|
+
const INLINE_FILTER_ALIAS_TOKEN_MAP = {};
|
|
2051
|
+
for (const [token, controlType] of Object.entries(INLINE_FILTER_CANONICAL_TOKEN_TO_CONTROL_TYPE_MAP)) {
|
|
2052
|
+
INLINE_FILTER_ALIAS_TOKEN_MAP[`filter${token}`] = controlType;
|
|
2053
|
+
INLINE_FILTER_ALIAS_TOKEN_MAP[`pdxfilter${token}`] = controlType;
|
|
2054
|
+
}
|
|
2055
|
+
const INLINE_FILTER_TOKEN_TO_CONTROL_TYPE = Object.freeze({
|
|
2056
|
+
...INLINE_FILTER_CANONICAL_TOKEN_TO_CONTROL_TYPE_MAP,
|
|
2057
|
+
...INLINE_FILTER_ALIAS_TOKEN_MAP,
|
|
2058
|
+
});
|
|
2059
|
+
const INLINE_FILTER_ALIAS_TOKENS = Object.freeze(Object.keys(INLINE_FILTER_ALIAS_TOKEN_MAP));
|
|
2060
|
+
const INLINE_FILTER_CANONICAL_TOKEN_TO_BASE_CONTROL_TYPE_MAP = {
|
|
2061
|
+
inlineselect: FieldControlType.SELECT,
|
|
2062
|
+
inlinesearchableselect: FieldControlType.SEARCHABLE_SELECT,
|
|
2063
|
+
inlineasyncselect: FieldControlType.ASYNC_SELECT,
|
|
2064
|
+
inlineentitylookup: FieldControlType.ENTITY_LOOKUP,
|
|
2065
|
+
inlineautocomplete: FieldControlType.AUTO_COMPLETE,
|
|
2066
|
+
inlinenumber: FieldControlType.NUMERIC_TEXT_BOX,
|
|
2067
|
+
inlinecurrency: FieldControlType.CURRENCY_INPUT,
|
|
2068
|
+
inlinecurrencyrange: FieldControlType.PRICE_RANGE,
|
|
2069
|
+
inlinemultiselect: FieldControlType.MULTI_SELECT,
|
|
2070
|
+
inlineinput: FieldControlType.INPUT,
|
|
2071
|
+
inlinephone: FieldControlType.PHONE,
|
|
2072
|
+
inlinetoggle: FieldControlType.TOGGLE,
|
|
2073
|
+
inlinerange: FieldControlType.RANGE_SLIDER,
|
|
2074
|
+
inlineperiodrange: FieldControlType.RANGE_SLIDER,
|
|
2075
|
+
inlineyearrange: FieldControlType.YEAR_INPUT,
|
|
2076
|
+
inlinemonthrange: FieldControlType.MONTH_INPUT,
|
|
2077
|
+
inlinedate: FieldControlType.DATE_PICKER,
|
|
2078
|
+
inlinedaterange: FieldControlType.DATE_RANGE,
|
|
2079
|
+
inlinetime: FieldControlType.TIME_PICKER,
|
|
2080
|
+
inlinetimerange: FieldControlType.TIME_RANGE,
|
|
2081
|
+
inlinetreeselect: FieldControlType.TREE_SELECT,
|
|
2082
|
+
inlinerating: FieldControlType.RATING,
|
|
2083
|
+
inlinedistanceradius: FieldControlType.INLINE_DISTANCE_RADIUS,
|
|
2084
|
+
inlinepipelinestatus: FieldControlType.INLINE_PIPELINE_STATUS,
|
|
2085
|
+
inlinescorepriority: FieldControlType.INLINE_SCORE_PRIORITY,
|
|
2086
|
+
inlinerelativeperiod: FieldControlType.INLINE_RELATIVE_PERIOD,
|
|
2087
|
+
inlinesentiment: FieldControlType.INLINE_SENTIMENT,
|
|
2088
|
+
inlinecolorlabel: FieldControlType.INLINE_COLOR_LABEL,
|
|
2089
|
+
};
|
|
2090
|
+
const INLINE_FILTER_ALIAS_TOKEN_TO_BASE_CONTROL_TYPE_MAP = {};
|
|
2091
|
+
for (const [aliasToken, controlType] of Object.entries(INLINE_FILTER_ALIAS_TOKEN_MAP)) {
|
|
2092
|
+
const canonicalToken = aliasToken.startsWith('pdxfilter')
|
|
2093
|
+
? aliasToken.replace(/^pdxfilter/, '')
|
|
2094
|
+
: aliasToken.replace(/^filter/, '');
|
|
2095
|
+
const baseControlType = INLINE_FILTER_CANONICAL_TOKEN_TO_BASE_CONTROL_TYPE_MAP[canonicalToken];
|
|
2096
|
+
if (baseControlType) {
|
|
2097
|
+
INLINE_FILTER_ALIAS_TOKEN_TO_BASE_CONTROL_TYPE_MAP[aliasToken] = baseControlType;
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
const INLINE_FILTER_TOKEN_TO_BASE_CONTROL_TYPE = Object.freeze({
|
|
2101
|
+
...INLINE_FILTER_CANONICAL_TOKEN_TO_BASE_CONTROL_TYPE_MAP,
|
|
2102
|
+
...INLINE_FILTER_ALIAS_TOKEN_TO_BASE_CONTROL_TYPE_MAP,
|
|
2103
|
+
});
|
|
2104
|
+
function resolveInlineFilterControlType(value) {
|
|
2105
|
+
const token = normalizeInlineControlTypeToken(value);
|
|
2106
|
+
if (!token)
|
|
2107
|
+
return undefined;
|
|
2108
|
+
return INLINE_FILTER_TOKEN_TO_CONTROL_TYPE[token];
|
|
2109
|
+
}
|
|
2110
|
+
function resolveInlineFilterControlTypeToBaseControlType(value) {
|
|
2111
|
+
const token = normalizeInlineControlTypeToken(value);
|
|
2112
|
+
if (!token)
|
|
2113
|
+
return undefined;
|
|
2114
|
+
return INLINE_FILTER_TOKEN_TO_BASE_CONTROL_TYPE[token];
|
|
2115
|
+
}
|
|
2116
|
+
function isInlineFilterControlType(value) {
|
|
2117
|
+
return INLINE_FILTER_CONTROL_TYPE_SET.has(String(value || '').trim());
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
function toUpperSnakeCase(raw) {
|
|
2121
|
+
return raw
|
|
2122
|
+
.trim()
|
|
2123
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1_$2')
|
|
2124
|
+
.replace(/[-\s]+/g, '_')
|
|
2125
|
+
.replace(/__+/g, '_')
|
|
2126
|
+
.toUpperCase();
|
|
2127
|
+
}
|
|
2128
|
+
function normalizeControlTypeToken(value) {
|
|
2129
|
+
return String(value || '')
|
|
2130
|
+
.trim()
|
|
2131
|
+
.toLowerCase()
|
|
2132
|
+
.replace(/[-_\s]/g, '');
|
|
2133
|
+
}
|
|
2134
|
+
const CONTROL_TYPE_TOKEN_TO_KEY = Object.entries(FieldControlType).reduce((acc, [key, controlTypeValue]) => {
|
|
2135
|
+
acc[normalizeControlTypeToken(key)] = key;
|
|
2136
|
+
acc[normalizeControlTypeToken(controlTypeValue)] = key;
|
|
2137
|
+
return acc;
|
|
2138
|
+
}, {});
|
|
2139
|
+
const ALIAS_TOKEN_TO_CONTROL_TYPE = {
|
|
2140
|
+
// Legacy/common synonyms
|
|
2141
|
+
searchable: FieldControlType.SEARCHABLE_SELECT,
|
|
2142
|
+
searchableinput: FieldControlType.SEARCHABLE_SELECT,
|
|
2143
|
+
searchableselect: FieldControlType.SEARCHABLE_SELECT,
|
|
2144
|
+
materialsearchableselect: FieldControlType.SEARCHABLE_SELECT,
|
|
2145
|
+
asyncselect: FieldControlType.ASYNC_SELECT,
|
|
2146
|
+
materialasyncselect: FieldControlType.ASYNC_SELECT,
|
|
2147
|
+
entitylookup: FieldControlType.ENTITY_LOOKUP,
|
|
2148
|
+
materialentitylookup: FieldControlType.ENTITY_LOOKUP,
|
|
2149
|
+
autocomplete: FieldControlType.AUTO_COMPLETE,
|
|
2150
|
+
multiselect: FieldControlType.MULTI_SELECT,
|
|
2151
|
+
multiselecttree: FieldControlType.MULTI_SELECT_TREE,
|
|
2152
|
+
treeselect: FieldControlType.TREE_SELECT,
|
|
2153
|
+
datepicker: FieldControlType.DATE_PICKER,
|
|
2154
|
+
daterange: FieldControlType.DATE_RANGE,
|
|
2155
|
+
datetime: FieldControlType.DATETIME_LOCAL_INPUT,
|
|
2156
|
+
timepicker: FieldControlType.TIME_PICKER,
|
|
2157
|
+
timerange: FieldControlType.TIME_RANGE,
|
|
2158
|
+
pricerange: FieldControlType.PRICE_RANGE,
|
|
2159
|
+
rangeslider: FieldControlType.RANGE_SLIDER,
|
|
2160
|
+
number: FieldControlType.NUMERIC_TEXT_BOX,
|
|
2161
|
+
numeric: FieldControlType.NUMERIC_TEXT_BOX,
|
|
2162
|
+
currencyinput: FieldControlType.CURRENCY_INPUT,
|
|
2163
|
+
switch: FieldControlType.TOGGLE,
|
|
2164
|
+
radiogroup: FieldControlType.RADIO,
|
|
2165
|
+
checkboxgroup: FieldControlType.CHECKBOX,
|
|
2166
|
+
chiplist: FieldControlType.CHIP_LIST,
|
|
2167
|
+
chipinput: FieldControlType.CHIP_INPUT,
|
|
2168
|
+
searchinput: FieldControlType.SEARCH_INPUT,
|
|
2169
|
+
};
|
|
2170
|
+
function normalizeControlTypeKey(value) {
|
|
2171
|
+
const token = normalizeControlTypeToken(value);
|
|
2172
|
+
if (!token)
|
|
2173
|
+
return '';
|
|
2174
|
+
const resolvedKey = CONTROL_TYPE_TOKEN_TO_KEY[token];
|
|
2175
|
+
if (resolvedKey)
|
|
2176
|
+
return resolvedKey;
|
|
2177
|
+
return toUpperSnakeCase(String(value || ''));
|
|
2178
|
+
}
|
|
2179
|
+
function resolveControlTypeAlias(value, fallback = FieldControlType.INPUT) {
|
|
2180
|
+
const raw = String(value || '').trim();
|
|
2181
|
+
if (!raw)
|
|
2182
|
+
return fallback;
|
|
2183
|
+
const token = normalizeControlTypeToken(raw);
|
|
2184
|
+
const inlineAliased = INLINE_FILTER_TOKEN_TO_BASE_CONTROL_TYPE[token];
|
|
2185
|
+
if (inlineAliased)
|
|
2186
|
+
return inlineAliased;
|
|
2187
|
+
const aliased = ALIAS_TOKEN_TO_CONTROL_TYPE[token];
|
|
2188
|
+
if (aliased)
|
|
2189
|
+
return aliased;
|
|
2190
|
+
const resolvedKey = CONTROL_TYPE_TOKEN_TO_KEY[token];
|
|
2191
|
+
if (resolvedKey) {
|
|
2192
|
+
return FieldControlType[resolvedKey];
|
|
2193
|
+
}
|
|
2194
|
+
return raw;
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
const MAX_OPTION_SOURCE_DEPTH = 3;
|
|
2198
|
+
// Mirrors the backend custom-field key policy. Ordinary static field names are
|
|
2199
|
+
// outside this boundary; custom keys must be safe across all runtime consumers.
|
|
2200
|
+
const RESERVED_CUSTOM_FIELD_KEYS = new Set([
|
|
2201
|
+
'constructor', 'prototype', 'hasOwnProperty', 'isPrototypeOf',
|
|
2202
|
+
'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf',
|
|
2203
|
+
]);
|
|
1017
2204
|
const VALUE_PRESENTATION_TYPES = new Set([
|
|
1018
2205
|
'string',
|
|
1019
2206
|
'number',
|
|
@@ -1262,6 +2449,33 @@ class SchemaNormalizationKernel {
|
|
|
1262
2449
|
}
|
|
1263
2450
|
return false;
|
|
1264
2451
|
}
|
|
2452
|
+
parseOptionalBoolean(value) {
|
|
2453
|
+
if (typeof value === 'boolean') {
|
|
2454
|
+
return value;
|
|
2455
|
+
}
|
|
2456
|
+
if (typeof value === 'string') {
|
|
2457
|
+
const normalized = value.trim().toLowerCase();
|
|
2458
|
+
if (normalized === 'true') {
|
|
2459
|
+
return true;
|
|
2460
|
+
}
|
|
2461
|
+
if (normalized === 'false') {
|
|
2462
|
+
return false;
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
return undefined;
|
|
2466
|
+
}
|
|
2467
|
+
parseOptionalFiniteNumber(value) {
|
|
2468
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
2469
|
+
return value;
|
|
2470
|
+
}
|
|
2471
|
+
if (typeof value === 'string' && value.trim().length > 0) {
|
|
2472
|
+
const parsed = Number(value);
|
|
2473
|
+
if (Number.isFinite(parsed)) {
|
|
2474
|
+
return parsed;
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
2477
|
+
return undefined;
|
|
2478
|
+
}
|
|
1265
2479
|
/** Ensure an array of strings from various inputs. */
|
|
1266
2480
|
parseStringArray(value) {
|
|
1267
2481
|
if (Array.isArray(value)) {
|
|
@@ -1278,6 +2492,41 @@ class SchemaNormalizationKernel {
|
|
|
1278
2492
|
.filter((v) => v.length > 0);
|
|
1279
2493
|
return normalized.filter((v, index) => normalized.indexOf(v) === index);
|
|
1280
2494
|
}
|
|
2495
|
+
parseDependsOn(value) {
|
|
2496
|
+
const rawItems = Array.isArray(value)
|
|
2497
|
+
? value
|
|
2498
|
+
: typeof value === 'string'
|
|
2499
|
+
? value.split(',')
|
|
2500
|
+
: [];
|
|
2501
|
+
const normalized = rawItems
|
|
2502
|
+
.map((item) => (typeof item === 'string' ? item.trim() : ''))
|
|
2503
|
+
.filter((item) => item.length > 0);
|
|
2504
|
+
return normalized.filter((item, index) => normalized.indexOf(item) === index);
|
|
2505
|
+
}
|
|
2506
|
+
parseStrictStringRecord(value) {
|
|
2507
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
2508
|
+
return undefined;
|
|
2509
|
+
}
|
|
2510
|
+
const normalized = Object.entries(value)
|
|
2511
|
+
.reduce((acc, [key, mapValue]) => {
|
|
2512
|
+
if (typeof mapValue !== 'string') {
|
|
2513
|
+
return acc;
|
|
2514
|
+
}
|
|
2515
|
+
const normalizedKey = String(key).trim();
|
|
2516
|
+
if (!normalizedKey ||
|
|
2517
|
+
normalizedKey === '__proto__' ||
|
|
2518
|
+
normalizedKey === 'constructor' ||
|
|
2519
|
+
normalizedKey === 'prototype') {
|
|
2520
|
+
return acc;
|
|
2521
|
+
}
|
|
2522
|
+
const normalizedValue = mapValue.trim();
|
|
2523
|
+
if (normalizedValue) {
|
|
2524
|
+
acc[normalizedKey] = normalizedValue;
|
|
2525
|
+
}
|
|
2526
|
+
return acc;
|
|
2527
|
+
}, {});
|
|
2528
|
+
return Object.keys(normalized).length ? normalized : undefined;
|
|
2529
|
+
}
|
|
1281
2530
|
parseStringRecord(value) {
|
|
1282
2531
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
1283
2532
|
return undefined;
|
|
@@ -1365,9 +2614,15 @@ class SchemaNormalizationKernel {
|
|
|
1365
2614
|
if (value.kind !== undefined) {
|
|
1366
2615
|
detail.kind = String(value.kind);
|
|
1367
2616
|
}
|
|
2617
|
+
if (value.resourceKey !== undefined && String(value.resourceKey).trim().length > 0) {
|
|
2618
|
+
detail.resourceKey = String(value.resourceKey).trim();
|
|
2619
|
+
}
|
|
1368
2620
|
if (value.surfaceId !== undefined) {
|
|
1369
2621
|
detail.surfaceId = String(value.surfaceId);
|
|
1370
2622
|
}
|
|
2623
|
+
if (value.previewSurfaceId !== undefined && String(value.previewSurfaceId).trim().length > 0) {
|
|
2624
|
+
detail.previewSurfaceId = String(value.previewSurfaceId).trim();
|
|
2625
|
+
}
|
|
1371
2626
|
if (value.presentation !== undefined) {
|
|
1372
2627
|
detail.presentation = String(value.presentation);
|
|
1373
2628
|
}
|
|
@@ -1392,6 +2647,11 @@ class SchemaNormalizationKernel {
|
|
|
1392
2647
|
'resultLayout',
|
|
1393
2648
|
'primaryPropertyPath',
|
|
1394
2649
|
'avatarPropertyPath',
|
|
2650
|
+
'detailActionLabel',
|
|
2651
|
+
'quickViewActionLabel',
|
|
2652
|
+
'copyCodeActionLabel',
|
|
2653
|
+
'copyIdActionLabel',
|
|
2654
|
+
'createActionLabel',
|
|
1395
2655
|
];
|
|
1396
2656
|
stringKeys.forEach((key) => {
|
|
1397
2657
|
if (value[key] !== undefined) {
|
|
@@ -1429,6 +2689,10 @@ class SchemaNormalizationKernel {
|
|
|
1429
2689
|
if (value.maxVisibleBadges !== undefined && !Number.isNaN(Number(value.maxVisibleBadges))) {
|
|
1430
2690
|
display.maxVisibleBadges = Number(value.maxVisibleBadges);
|
|
1431
2691
|
}
|
|
2692
|
+
const actions = this.parseLookupActions(value.actions);
|
|
2693
|
+
if (actions) {
|
|
2694
|
+
display.actions = actions;
|
|
2695
|
+
}
|
|
1432
2696
|
return Object.keys(display).length ? display : undefined;
|
|
1433
2697
|
}
|
|
1434
2698
|
parseLookupDisplayField(value) {
|
|
@@ -1443,6 +2707,28 @@ class SchemaNormalizationKernel {
|
|
|
1443
2707
|
});
|
|
1444
2708
|
return Object.keys(field).length ? field : undefined;
|
|
1445
2709
|
}
|
|
2710
|
+
parseLookupActions(value) {
|
|
2711
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
2712
|
+
return undefined;
|
|
2713
|
+
}
|
|
2714
|
+
const actions = {};
|
|
2715
|
+
if (value.showDetail !== undefined) {
|
|
2716
|
+
actions.showDetail = this.parseBoolean(value.showDetail);
|
|
2717
|
+
}
|
|
2718
|
+
if (value.showQuickView !== undefined) {
|
|
2719
|
+
actions.showQuickView = this.parseBoolean(value.showQuickView);
|
|
2720
|
+
}
|
|
2721
|
+
if (value.showCopyCode !== undefined) {
|
|
2722
|
+
actions.showCopyCode = this.parseBoolean(value.showCopyCode);
|
|
2723
|
+
}
|
|
2724
|
+
if (value.showCopyId !== undefined) {
|
|
2725
|
+
actions.showCopyId = this.parseBoolean(value.showCopyId);
|
|
2726
|
+
}
|
|
2727
|
+
if (value.showCreate !== undefined) {
|
|
2728
|
+
actions.showCreate = this.parseBoolean(value.showCreate);
|
|
2729
|
+
}
|
|
2730
|
+
return Object.keys(actions).length ? actions : undefined;
|
|
2731
|
+
}
|
|
1446
2732
|
parseLookupCreate(value) {
|
|
1447
2733
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
1448
2734
|
return undefined;
|
|
@@ -1498,10 +2784,13 @@ class SchemaNormalizationKernel {
|
|
|
1498
2784
|
}
|
|
1499
2785
|
const dialog = {};
|
|
1500
2786
|
if (value.enabled !== undefined) {
|
|
1501
|
-
|
|
2787
|
+
const enabled = this.parseOptionalBoolean(value.enabled);
|
|
2788
|
+
if (enabled !== undefined) {
|
|
2789
|
+
dialog.enabled = enabled;
|
|
2790
|
+
}
|
|
1502
2791
|
}
|
|
1503
|
-
if (value.title
|
|
1504
|
-
const title =
|
|
2792
|
+
if (typeof value.title === 'string') {
|
|
2793
|
+
const title = value.title.trim();
|
|
1505
2794
|
if (title) {
|
|
1506
2795
|
dialog.title = title;
|
|
1507
2796
|
}
|
|
@@ -1513,13 +2802,22 @@ class SchemaNormalizationKernel {
|
|
|
1513
2802
|
}
|
|
1514
2803
|
}
|
|
1515
2804
|
if (value.previewPanel !== undefined) {
|
|
1516
|
-
|
|
2805
|
+
const previewPanel = this.parseOptionalBoolean(value.previewPanel);
|
|
2806
|
+
if (previewPanel !== undefined) {
|
|
2807
|
+
dialog.previewPanel = previewPanel;
|
|
2808
|
+
}
|
|
1517
2809
|
}
|
|
1518
2810
|
if (value.allowColumnChooser !== undefined) {
|
|
1519
|
-
|
|
2811
|
+
const allowColumnChooser = this.parseOptionalBoolean(value.allowColumnChooser);
|
|
2812
|
+
if (allowColumnChooser !== undefined) {
|
|
2813
|
+
dialog.allowColumnChooser = allowColumnChooser;
|
|
2814
|
+
}
|
|
1520
2815
|
}
|
|
1521
2816
|
if (value.allowSavedViews !== undefined) {
|
|
1522
|
-
|
|
2817
|
+
const allowSavedViews = this.parseOptionalBoolean(value.allowSavedViews);
|
|
2818
|
+
if (allowSavedViews !== undefined) {
|
|
2819
|
+
dialog.allowSavedViews = allowSavedViews;
|
|
2820
|
+
}
|
|
1523
2821
|
}
|
|
1524
2822
|
if (Array.isArray(value.resultColumns)) {
|
|
1525
2823
|
const resultColumns = value.resultColumns
|
|
@@ -1529,20 +2827,20 @@ class SchemaNormalizationKernel {
|
|
|
1529
2827
|
dialog.resultColumns = resultColumns;
|
|
1530
2828
|
}
|
|
1531
2829
|
}
|
|
1532
|
-
if (value.openActionLabel
|
|
1533
|
-
const openActionLabel =
|
|
2830
|
+
if (typeof value.openActionLabel === 'string') {
|
|
2831
|
+
const openActionLabel = value.openActionLabel.trim();
|
|
1534
2832
|
if (openActionLabel) {
|
|
1535
2833
|
dialog.openActionLabel = openActionLabel;
|
|
1536
2834
|
}
|
|
1537
2835
|
}
|
|
1538
|
-
if (value.applyActionLabel
|
|
1539
|
-
const applyActionLabel =
|
|
2836
|
+
if (typeof value.applyActionLabel === 'string') {
|
|
2837
|
+
const applyActionLabel = value.applyActionLabel.trim();
|
|
1540
2838
|
if (applyActionLabel) {
|
|
1541
2839
|
dialog.applyActionLabel = applyActionLabel;
|
|
1542
2840
|
}
|
|
1543
2841
|
}
|
|
1544
|
-
if (value.cancelActionLabel
|
|
1545
|
-
const cancelActionLabel =
|
|
2842
|
+
if (typeof value.cancelActionLabel === 'string') {
|
|
2843
|
+
const cancelActionLabel = value.cancelActionLabel.trim();
|
|
1546
2844
|
if (cancelActionLabel) {
|
|
1547
2845
|
dialog.cancelActionLabel = cancelActionLabel;
|
|
1548
2846
|
}
|
|
@@ -1553,19 +2851,19 @@ class SchemaNormalizationKernel {
|
|
|
1553
2851
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
1554
2852
|
return undefined;
|
|
1555
2853
|
}
|
|
1556
|
-
const field =
|
|
2854
|
+
const field = typeof value.field === 'string' ? value.field.trim() : '';
|
|
1557
2855
|
if (!field) {
|
|
1558
2856
|
return undefined;
|
|
1559
2857
|
}
|
|
1560
2858
|
const column = { field };
|
|
1561
|
-
if (value.label
|
|
1562
|
-
const label =
|
|
2859
|
+
if (typeof value.label === 'string') {
|
|
2860
|
+
const label = value.label.trim();
|
|
1563
2861
|
if (label) {
|
|
1564
2862
|
column.label = label;
|
|
1565
2863
|
}
|
|
1566
2864
|
}
|
|
1567
|
-
if (value.kind
|
|
1568
|
-
const kind =
|
|
2865
|
+
if (typeof value.kind === 'string') {
|
|
2866
|
+
const kind = value.kind.trim();
|
|
1569
2867
|
if (kind === 'code' ||
|
|
1570
2868
|
kind === 'label' ||
|
|
1571
2869
|
kind === 'description' ||
|
|
@@ -1575,15 +2873,137 @@ class SchemaNormalizationKernel {
|
|
|
1575
2873
|
column.kind = kind;
|
|
1576
2874
|
}
|
|
1577
2875
|
}
|
|
1578
|
-
if (value.width
|
|
1579
|
-
const width =
|
|
2876
|
+
if (typeof value.width === 'string') {
|
|
2877
|
+
const width = value.width.trim();
|
|
1580
2878
|
if (width) {
|
|
1581
2879
|
column.width = width;
|
|
1582
2880
|
}
|
|
1583
2881
|
}
|
|
1584
2882
|
return column;
|
|
1585
2883
|
}
|
|
1586
|
-
|
|
2884
|
+
mergeLookupDialog(base, override) {
|
|
2885
|
+
const merged = {
|
|
2886
|
+
...(this.parseLookupDialog(base) ?? {}),
|
|
2887
|
+
...(this.parseLookupDialog(override) ?? {}),
|
|
2888
|
+
};
|
|
2889
|
+
return Object.keys(merged).length ? merged : undefined;
|
|
2890
|
+
}
|
|
2891
|
+
parseLookupFilterOptions(value) {
|
|
2892
|
+
if (!Array.isArray(value)) {
|
|
2893
|
+
return undefined;
|
|
2894
|
+
}
|
|
2895
|
+
const options = [];
|
|
2896
|
+
const seen = new Set();
|
|
2897
|
+
for (const item of value) {
|
|
2898
|
+
if (typeof item === 'string' ||
|
|
2899
|
+
typeof item === 'number' ||
|
|
2900
|
+
typeof item === 'boolean') {
|
|
2901
|
+
let parsedValue;
|
|
2902
|
+
if (typeof item === 'string') {
|
|
2903
|
+
const trimmed = item.trim();
|
|
2904
|
+
if (!trimmed) {
|
|
2905
|
+
continue;
|
|
2906
|
+
}
|
|
2907
|
+
parsedValue = trimmed;
|
|
2908
|
+
}
|
|
2909
|
+
else if (typeof item === 'number') {
|
|
2910
|
+
if (!Number.isFinite(item)) {
|
|
2911
|
+
continue;
|
|
2912
|
+
}
|
|
2913
|
+
parsedValue = item;
|
|
2914
|
+
}
|
|
2915
|
+
else {
|
|
2916
|
+
parsedValue = item;
|
|
2917
|
+
}
|
|
2918
|
+
const dedupeKey = `${typeof parsedValue}:${String(parsedValue)}`;
|
|
2919
|
+
if (seen.has(dedupeKey)) {
|
|
2920
|
+
continue;
|
|
2921
|
+
}
|
|
2922
|
+
seen.add(dedupeKey);
|
|
2923
|
+
options.push({
|
|
2924
|
+
value: parsedValue,
|
|
2925
|
+
label: String(parsedValue),
|
|
2926
|
+
});
|
|
2927
|
+
continue;
|
|
2928
|
+
}
|
|
2929
|
+
if (!item || typeof item !== 'object' || Array.isArray(item)) {
|
|
2930
|
+
continue;
|
|
2931
|
+
}
|
|
2932
|
+
const raw = item;
|
|
2933
|
+
const isLegacyKeyValue = raw['key'] !== undefined &&
|
|
2934
|
+
raw['key'] !== null &&
|
|
2935
|
+
raw['label'] === undefined &&
|
|
2936
|
+
raw['text'] === undefined &&
|
|
2937
|
+
typeof raw['value'] === 'string' &&
|
|
2938
|
+
raw['key'] !== raw['value'];
|
|
2939
|
+
const rawValue = isLegacyKeyValue
|
|
2940
|
+
? raw['key']
|
|
2941
|
+
: raw['value'] !== undefined && raw['value'] !== null
|
|
2942
|
+
? raw['value']
|
|
2943
|
+
: raw['key'];
|
|
2944
|
+
const rawLabel = isLegacyKeyValue
|
|
2945
|
+
? raw['value']
|
|
2946
|
+
: raw['label'] ?? raw['text'];
|
|
2947
|
+
let parsedValue;
|
|
2948
|
+
if (typeof rawValue === 'string') {
|
|
2949
|
+
const trimmed = rawValue.trim();
|
|
2950
|
+
if (!trimmed) {
|
|
2951
|
+
continue;
|
|
2952
|
+
}
|
|
2953
|
+
parsedValue = trimmed;
|
|
2954
|
+
}
|
|
2955
|
+
else if (typeof rawValue === 'number') {
|
|
2956
|
+
if (!Number.isFinite(rawValue)) {
|
|
2957
|
+
continue;
|
|
2958
|
+
}
|
|
2959
|
+
parsedValue = rawValue;
|
|
2960
|
+
}
|
|
2961
|
+
else if (typeof rawValue === 'boolean') {
|
|
2962
|
+
parsedValue = rawValue;
|
|
2963
|
+
}
|
|
2964
|
+
else {
|
|
2965
|
+
continue;
|
|
2966
|
+
}
|
|
2967
|
+
const dedupeKey = `${typeof parsedValue}:${String(parsedValue)}`;
|
|
2968
|
+
if (seen.has(dedupeKey)) {
|
|
2969
|
+
continue;
|
|
2970
|
+
}
|
|
2971
|
+
seen.add(dedupeKey);
|
|
2972
|
+
let label;
|
|
2973
|
+
if (typeof rawLabel === 'string' && rawLabel.trim().length > 0) {
|
|
2974
|
+
label = rawLabel.trim();
|
|
2975
|
+
}
|
|
2976
|
+
else if ((typeof rawLabel === 'number' && Number.isFinite(rawLabel)) ||
|
|
2977
|
+
typeof rawLabel === 'boolean') {
|
|
2978
|
+
label = String(rawLabel);
|
|
2979
|
+
}
|
|
2980
|
+
else {
|
|
2981
|
+
label = String(parsedValue);
|
|
2982
|
+
}
|
|
2983
|
+
const option = {
|
|
2984
|
+
value: parsedValue,
|
|
2985
|
+
label,
|
|
2986
|
+
};
|
|
2987
|
+
if (typeof raw['icon'] === 'string' && raw['icon'].trim()) {
|
|
2988
|
+
option.icon = raw['icon'].trim();
|
|
2989
|
+
}
|
|
2990
|
+
if (typeof raw['tone'] === 'string' && raw['tone'].trim()) {
|
|
2991
|
+
option.tone = raw['tone'].trim();
|
|
2992
|
+
}
|
|
2993
|
+
if (typeof raw['description'] === 'string' && raw['description'].trim()) {
|
|
2994
|
+
option.description = raw['description'].trim();
|
|
2995
|
+
}
|
|
2996
|
+
if (raw['disabled'] !== undefined) {
|
|
2997
|
+
const disabled = this.parseOptionalBoolean(raw['disabled']);
|
|
2998
|
+
if (disabled !== undefined) {
|
|
2999
|
+
option.disabled = disabled;
|
|
3000
|
+
}
|
|
3001
|
+
}
|
|
3002
|
+
options.push(option);
|
|
3003
|
+
}
|
|
3004
|
+
return options.length ? options : undefined;
|
|
3005
|
+
}
|
|
3006
|
+
parseLookupFilterDefinition(value, optionSourceDepth = 0, visitedOptionSources = new Set()) {
|
|
1587
3007
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
1588
3008
|
return undefined;
|
|
1589
3009
|
}
|
|
@@ -1608,8 +3028,38 @@ class SchemaNormalizationKernel {
|
|
|
1608
3028
|
if (defaultOperator && operators.includes(defaultOperator)) {
|
|
1609
3029
|
definition.defaultOperator = defaultOperator;
|
|
1610
3030
|
}
|
|
1611
|
-
if (value.
|
|
1612
|
-
const
|
|
3031
|
+
if (value.options !== undefined) {
|
|
3032
|
+
const options = this.parseLookupFilterOptions(value.options);
|
|
3033
|
+
if (options) {
|
|
3034
|
+
definition.options = options;
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
if (typeof value.optionSource === 'string') {
|
|
3038
|
+
const optionSource = value.optionSource.trim();
|
|
3039
|
+
if (optionSource) {
|
|
3040
|
+
definition.optionSource = optionSource;
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
3043
|
+
else if (value.optionSource &&
|
|
3044
|
+
typeof value.optionSource === 'object' &&
|
|
3045
|
+
!Array.isArray(value.optionSource)) {
|
|
3046
|
+
const optionSource = this.parseOptionSource(value.optionSource, optionSourceDepth + 1, visitedOptionSources);
|
|
3047
|
+
if (optionSource) {
|
|
3048
|
+
definition.optionSource = optionSource;
|
|
3049
|
+
}
|
|
3050
|
+
}
|
|
3051
|
+
if (value.dependsOn !== undefined) {
|
|
3052
|
+
const dependsOn = this.parseDependsOn(value.dependsOn);
|
|
3053
|
+
if (dependsOn.length) {
|
|
3054
|
+
definition.dependsOn = dependsOn;
|
|
3055
|
+
}
|
|
3056
|
+
}
|
|
3057
|
+
const dependencyFilterMap = this.parseStrictStringRecord(value.dependencyFilterMap);
|
|
3058
|
+
if (dependencyFilterMap) {
|
|
3059
|
+
definition.dependencyFilterMap = dependencyFilterMap;
|
|
3060
|
+
}
|
|
3061
|
+
if (typeof value.optionsSource === 'string') {
|
|
3062
|
+
const optionsSource = value.optionsSource.trim();
|
|
1613
3063
|
if (optionsSource) {
|
|
1614
3064
|
definition.optionsSource = optionsSource;
|
|
1615
3065
|
}
|
|
@@ -1643,7 +3093,7 @@ class SchemaNormalizationKernel {
|
|
|
1643
3093
|
}, {});
|
|
1644
3094
|
return Object.keys(normalized).length ? normalized : undefined;
|
|
1645
3095
|
}
|
|
1646
|
-
parseLookupFiltering(value) {
|
|
3096
|
+
parseLookupFiltering(value, optionSourceDepth = 0, visitedOptionSources = new Set()) {
|
|
1647
3097
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
1648
3098
|
return undefined;
|
|
1649
3099
|
}
|
|
@@ -1651,7 +3101,7 @@ class SchemaNormalizationKernel {
|
|
|
1651
3101
|
if (value.availableFilters !== undefined) {
|
|
1652
3102
|
const availableFilters = Array.isArray(value.availableFilters)
|
|
1653
3103
|
? value.availableFilters
|
|
1654
|
-
.map((item) => this.parseLookupFilterDefinition(item))
|
|
3104
|
+
.map((item) => this.parseLookupFilterDefinition(item, optionSourceDepth, visitedOptionSources))
|
|
1655
3105
|
.filter((item) => !!item)
|
|
1656
3106
|
: [];
|
|
1657
3107
|
if (availableFilters.length) {
|
|
@@ -1737,6 +3187,12 @@ class SchemaNormalizationKernel {
|
|
|
1737
3187
|
filtering.searchStrategies = searchStrategies;
|
|
1738
3188
|
}
|
|
1739
3189
|
}
|
|
3190
|
+
if (typeof value.defaultSearchStrategy === 'string') {
|
|
3191
|
+
const defaultSearchStrategy = value.defaultSearchStrategy.trim();
|
|
3192
|
+
if (defaultSearchStrategy) {
|
|
3193
|
+
filtering.defaultSearchStrategy = defaultSearchStrategy;
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
1740
3196
|
return Object.keys(filtering).length ? filtering : undefined;
|
|
1741
3197
|
}
|
|
1742
3198
|
/** Parse option arrays into `{ key, value }` objects with label preservation. */
|
|
@@ -1767,16 +3223,23 @@ class SchemaNormalizationKernel {
|
|
|
1767
3223
|
return { key: String(opt), value: String(opt) };
|
|
1768
3224
|
});
|
|
1769
3225
|
}
|
|
1770
|
-
parseOptionSource(value) {
|
|
1771
|
-
if (!value ||
|
|
3226
|
+
parseOptionSource(value, depth = 0, visited = new Set()) {
|
|
3227
|
+
if (!value ||
|
|
3228
|
+
typeof value !== 'object' ||
|
|
3229
|
+
Array.isArray(value) ||
|
|
3230
|
+
depth > MAX_OPTION_SOURCE_DEPTH ||
|
|
3231
|
+
visited.has(value)) {
|
|
1772
3232
|
return undefined;
|
|
1773
3233
|
}
|
|
1774
|
-
const
|
|
1775
|
-
|
|
1776
|
-
};
|
|
1777
|
-
if (!optionSource.key) {
|
|
3234
|
+
const key = String(value.key ?? '').trim();
|
|
3235
|
+
if (!key) {
|
|
1778
3236
|
return undefined;
|
|
1779
3237
|
}
|
|
3238
|
+
const nextVisited = new Set(visited);
|
|
3239
|
+
nextVisited.add(value);
|
|
3240
|
+
const optionSource = {
|
|
3241
|
+
key,
|
|
3242
|
+
};
|
|
1780
3243
|
if (value.type !== undefined) {
|
|
1781
3244
|
const optionSourceType = this.parseOptionSourceType(value.type);
|
|
1782
3245
|
if (optionSourceType) {
|
|
@@ -1820,12 +3283,12 @@ class SchemaNormalizationKernel {
|
|
|
1820
3283
|
optionSource.searchPropertyPaths = this.parseStringArray(value.searchPropertyPaths);
|
|
1821
3284
|
}
|
|
1822
3285
|
if (value.dependsOn !== undefined) {
|
|
1823
|
-
const dependsOn = this.
|
|
3286
|
+
const dependsOn = this.parseDependsOn(value.dependsOn);
|
|
1824
3287
|
if (dependsOn.length) {
|
|
1825
3288
|
optionSource.dependsOn = dependsOn;
|
|
1826
3289
|
}
|
|
1827
3290
|
}
|
|
1828
|
-
const dependencyFilterMap = this.
|
|
3291
|
+
const dependencyFilterMap = this.parseStrictStringRecord(value.dependencyFilterMap);
|
|
1829
3292
|
if (dependencyFilterMap) {
|
|
1830
3293
|
optionSource.dependencyFilterMap = dependencyFilterMap;
|
|
1831
3294
|
}
|
|
@@ -1849,10 +3312,14 @@ class SchemaNormalizationKernel {
|
|
|
1849
3312
|
if (create) {
|
|
1850
3313
|
optionSource.create = create;
|
|
1851
3314
|
}
|
|
1852
|
-
const filtering = this.parseLookupFiltering(value.filtering);
|
|
3315
|
+
const filtering = this.parseLookupFiltering(value.filtering, depth, nextVisited);
|
|
1853
3316
|
if (filtering) {
|
|
1854
3317
|
optionSource.filtering = filtering;
|
|
1855
3318
|
}
|
|
3319
|
+
const dialog = this.parseLookupDialog(value.dialog);
|
|
3320
|
+
if (dialog) {
|
|
3321
|
+
optionSource.dialog = dialog;
|
|
3322
|
+
}
|
|
1856
3323
|
if (value.excludeSelfField !== undefined) {
|
|
1857
3324
|
optionSource.excludeSelfField = this.parseBoolean(value.excludeSelfField);
|
|
1858
3325
|
}
|
|
@@ -1898,6 +3365,34 @@ class SchemaNormalizationKernel {
|
|
|
1898
3365
|
const normalized = String(value ?? '').trim();
|
|
1899
3366
|
return OPTION_SOURCE_INVALID_SORT_POLICIES.has(normalized) ? normalized : undefined;
|
|
1900
3367
|
}
|
|
3368
|
+
parseResourceReference(value) {
|
|
3369
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
3370
|
+
return undefined;
|
|
3371
|
+
}
|
|
3372
|
+
const raw = value;
|
|
3373
|
+
const resourceKey = String(raw['resourceKey'] ?? '').trim();
|
|
3374
|
+
if (!resourceKey) {
|
|
3375
|
+
return undefined;
|
|
3376
|
+
}
|
|
3377
|
+
const ref = { resourceKey };
|
|
3378
|
+
const valueField = String(raw['valueField'] ?? '').trim();
|
|
3379
|
+
if (valueField) {
|
|
3380
|
+
ref.valueField = valueField;
|
|
3381
|
+
}
|
|
3382
|
+
const surfaceId = String(raw['surfaceId'] ?? '').trim();
|
|
3383
|
+
if (surfaceId) {
|
|
3384
|
+
ref.surfaceId = surfaceId;
|
|
3385
|
+
}
|
|
3386
|
+
const previewSurfaceId = String(raw['previewSurfaceId'] ?? '').trim();
|
|
3387
|
+
if (previewSurfaceId) {
|
|
3388
|
+
ref.previewSurfaceId = previewSurfaceId;
|
|
3389
|
+
}
|
|
3390
|
+
const detailPresentation = String(raw['detailPresentation'] ?? '').trim();
|
|
3391
|
+
if (detailPresentation === 'drawer' || detailPresentation === 'modal') {
|
|
3392
|
+
ref.detailPresentation = detailPresentation;
|
|
3393
|
+
}
|
|
3394
|
+
return ref;
|
|
3395
|
+
}
|
|
1901
3396
|
parseLookupOpenDetailMode(value) {
|
|
1902
3397
|
const normalized = String(value ?? '').trim();
|
|
1903
3398
|
return LOOKUP_OPEN_DETAIL_MODES.has(normalized) ? normalized : undefined;
|
|
@@ -2015,10 +3510,14 @@ class SchemaNormalizationKernel {
|
|
|
2015
3510
|
out.maxLength = Number(ui.maxLength);
|
|
2016
3511
|
if (ui.maxLengthMessage !== undefined)
|
|
2017
3512
|
out.maxLengthMessage = ui.maxLengthMessage;
|
|
2018
|
-
if (ui.min !== undefined)
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
3513
|
+
if (ui.min !== undefined) {
|
|
3514
|
+
const parsedMin = Number(ui.min);
|
|
3515
|
+
out.min = Number.isFinite(parsedMin) ? parsedMin : String(ui.min).trim();
|
|
3516
|
+
}
|
|
3517
|
+
if (ui.max !== undefined) {
|
|
3518
|
+
const parsedMax = Number(ui.max);
|
|
3519
|
+
out.max = Number.isFinite(parsedMax) ? parsedMax : String(ui.max).trim();
|
|
3520
|
+
}
|
|
2022
3521
|
if (ui.minMessage !== undefined)
|
|
2023
3522
|
out.minMessage = ui.minMessage;
|
|
2024
3523
|
if (ui.maxMessage !== undefined)
|
|
@@ -2150,32 +3649,269 @@ class SchemaNormalizationKernel {
|
|
|
2150
3649
|
}
|
|
2151
3650
|
return undefined;
|
|
2152
3651
|
}
|
|
2153
|
-
isNumericSchemaType(type) {
|
|
2154
|
-
const token = String(type ?? '').trim().toLowerCase();
|
|
2155
|
-
return ['number', 'integer', 'int', 'float', 'double', 'decimal'].includes(token);
|
|
3652
|
+
isNumericSchemaType(type) {
|
|
3653
|
+
const token = String(type ?? '').trim().toLowerCase();
|
|
3654
|
+
return ['number', 'integer', 'int', 'float', 'double', 'decimal'].includes(token);
|
|
3655
|
+
}
|
|
3656
|
+
resolveNumericFormatToken(prop, ui, resolvedType) {
|
|
3657
|
+
if (ui?.numberFormat?.percentage === true || ui?.['numberFormat.percentage'] === true) {
|
|
3658
|
+
return 'percent';
|
|
3659
|
+
}
|
|
3660
|
+
const explicitUiFormat = this.resolveNonEmptyStringToken(ui?.numericFormat, ui?.numberFormat?.style, ui?.['numberFormat.style']);
|
|
3661
|
+
if (explicitUiFormat) {
|
|
3662
|
+
return explicitUiFormat;
|
|
3663
|
+
}
|
|
3664
|
+
const typeToken = resolvedType ?? prop?.type;
|
|
3665
|
+
if (!this.isNumericSchemaType(typeToken)) {
|
|
3666
|
+
return undefined;
|
|
3667
|
+
}
|
|
3668
|
+
const explicitFormat = this.resolveNonEmptyStringToken(ui?.format, prop?.format);
|
|
3669
|
+
if (explicitFormat) {
|
|
3670
|
+
return explicitFormat;
|
|
3671
|
+
}
|
|
3672
|
+
if (String(prop?.type ?? '').trim().toLowerCase() === 'integer') {
|
|
3673
|
+
return 'integer';
|
|
3674
|
+
}
|
|
3675
|
+
return undefined;
|
|
3676
|
+
}
|
|
3677
|
+
/**
|
|
3678
|
+
* Converte o schema bruto do backend (OpenAPI + x-ui) em FieldDefinition[] tipado.
|
|
3679
|
+
* Regras:
|
|
3680
|
+
* - Ignora propriedades sem x-ui.
|
|
3681
|
+
* - Garante ordenação por 'order' quando presente.
|
|
3682
|
+
* - Funções condicionais/transformações sempre viram funções reais.
|
|
3683
|
+
*
|
|
3684
|
+
* @param schema Objeto OpenAPI/JSON Schema com properties e x-ui por propriedade.
|
|
3685
|
+
* @returns FieldDefinition[] prontos para mapeamento/uso no restante do sistema.
|
|
3686
|
+
*/
|
|
3687
|
+
normalizeSchema(schema) {
|
|
3688
|
+
return this.normalizeSchemaWithRoot(schema, schema);
|
|
3689
|
+
}
|
|
3690
|
+
/**
|
|
3691
|
+
* Extrai metadados estruturais de nível raiz (`x-ui` no objeto schema),
|
|
3692
|
+
* cobrindo `formLayout`, `progression`, `timeline`, `schedule`, `hierarchy`,
|
|
3693
|
+
* `calculationMemory`, `contextBinding` e `resourceState`.
|
|
3694
|
+
*/
|
|
3695
|
+
extractRootUiMetadata(schema) {
|
|
3696
|
+
const ui = schema &&
|
|
3697
|
+
typeof schema === 'object' &&
|
|
3698
|
+
!Array.isArray(schema) &&
|
|
3699
|
+
schema['x-ui'] &&
|
|
3700
|
+
typeof schema['x-ui'] === 'object' &&
|
|
3701
|
+
!Array.isArray(schema['x-ui'])
|
|
3702
|
+
? schema['x-ui']
|
|
3703
|
+
: undefined;
|
|
3704
|
+
if (!ui) {
|
|
3705
|
+
return null;
|
|
3706
|
+
}
|
|
3707
|
+
const out = {};
|
|
3708
|
+
const formLayout = this.parseSchemaFormLayout(ui['formLayout']);
|
|
3709
|
+
if (formLayout)
|
|
3710
|
+
out.formLayout = formLayout;
|
|
3711
|
+
if (ui['progression'] && typeof ui['progression'] === 'object' && !Array.isArray(ui['progression'])) {
|
|
3712
|
+
out.progression = this.clonePlain(ui['progression']);
|
|
3713
|
+
}
|
|
3714
|
+
if (ui['timeline'] && typeof ui['timeline'] === 'object' && !Array.isArray(ui['timeline'])) {
|
|
3715
|
+
out.timeline = this.clonePlain(ui['timeline']);
|
|
3716
|
+
}
|
|
3717
|
+
if (ui['timelineLanes'] && typeof ui['timelineLanes'] === 'object' && !Array.isArray(ui['timelineLanes'])) {
|
|
3718
|
+
out.timelineLanes = this.clonePlain(ui['timelineLanes']);
|
|
3719
|
+
}
|
|
3720
|
+
if (ui['schedule'] && typeof ui['schedule'] === 'object' && !Array.isArray(ui['schedule'])) {
|
|
3721
|
+
out.schedule = this.clonePlain(ui['schedule']);
|
|
3722
|
+
}
|
|
3723
|
+
if (ui['hierarchy'] && typeof ui['hierarchy'] === 'object' && !Array.isArray(ui['hierarchy'])) {
|
|
3724
|
+
out.hierarchy = this.clonePlain(ui['hierarchy']);
|
|
3725
|
+
}
|
|
3726
|
+
if (ui['relationshipGraph'] && typeof ui['relationshipGraph'] === 'object' && !Array.isArray(ui['relationshipGraph'])) {
|
|
3727
|
+
out.relationshipGraph = this.clonePlain(ui['relationshipGraph']);
|
|
3728
|
+
}
|
|
3729
|
+
if (ui['calculationMemory'] && typeof ui['calculationMemory'] === 'object' && !Array.isArray(ui['calculationMemory'])) {
|
|
3730
|
+
out.calculationMemory = this.clonePlain(ui['calculationMemory']);
|
|
3731
|
+
}
|
|
3732
|
+
const contextBinding = this.parseContextBinding(ui['contextBinding']);
|
|
3733
|
+
if (contextBinding)
|
|
3734
|
+
out.contextBinding = contextBinding;
|
|
3735
|
+
const resourceState = this.parseResourceState(ui['resourceState']);
|
|
3736
|
+
if (resourceState)
|
|
3737
|
+
out.resourceState = resourceState;
|
|
3738
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
3739
|
+
}
|
|
3740
|
+
parseSchemaFormLayout(raw) {
|
|
3741
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
3742
|
+
return undefined;
|
|
3743
|
+
}
|
|
3744
|
+
const record = raw;
|
|
3745
|
+
const rawMode = String(record['mode'] ?? 'flat').trim().toLowerCase();
|
|
3746
|
+
const mode = rawMode === 'tabs' || rawMode === 'accordion' || rawMode === 'stepper' || rawMode === 'flat'
|
|
3747
|
+
? rawMode
|
|
3748
|
+
: rawMode === 'vertical'
|
|
3749
|
+
? 'flat'
|
|
3750
|
+
: 'flat';
|
|
3751
|
+
const defaultTabId = typeof record['defaultTabId'] === 'string' && record['defaultTabId'].trim()
|
|
3752
|
+
? record['defaultTabId'].trim()
|
|
3753
|
+
: undefined;
|
|
3754
|
+
const rawTabsAppearance = typeof record['tabsAppearance'] === 'string'
|
|
3755
|
+
? record['tabsAppearance'].trim().toLowerCase()
|
|
3756
|
+
: '';
|
|
3757
|
+
const tabsAppearance = rawTabsAppearance === 'pills' ||
|
|
3758
|
+
rawTabsAppearance === 'underline' ||
|
|
3759
|
+
rawTabsAppearance === 'buttons'
|
|
3760
|
+
? rawTabsAppearance
|
|
3761
|
+
: undefined;
|
|
3762
|
+
const accordionMulti = this.parseOptionalBoolean(record['accordionMulti']);
|
|
3763
|
+
const hideSectionHeaderInTabs = this.parseOptionalBoolean(record['hideSectionHeaderInTabs']);
|
|
3764
|
+
const hideSectionHeaderInStepper = this.parseOptionalBoolean(record['hideSectionHeaderInStepper']);
|
|
3765
|
+
const rawStepperInReadMode = typeof record['stepperInReadMode'] === 'string'
|
|
3766
|
+
? record['stepperInReadMode'].trim().toLowerCase()
|
|
3767
|
+
: '';
|
|
3768
|
+
const stepperInReadMode = rawStepperInReadMode === 'presentation' ||
|
|
3769
|
+
rawStepperInReadMode === 'all' ||
|
|
3770
|
+
rawStepperInReadMode === 'none'
|
|
3771
|
+
? rawStepperInReadMode
|
|
3772
|
+
: undefined;
|
|
3773
|
+
const stepperReviewStep = this.parseOptionalBoolean(record['stepperReviewStep']);
|
|
3774
|
+
const rawSections = Array.isArray(record['sections']) ? record['sections'] : [];
|
|
3775
|
+
const sections = [];
|
|
3776
|
+
for (let idx = 0; idx < rawSections.length; idx++) {
|
|
3777
|
+
const entry = rawSections[idx];
|
|
3778
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry))
|
|
3779
|
+
continue;
|
|
3780
|
+
const item = entry;
|
|
3781
|
+
const id = String(item['id'] ?? '').trim();
|
|
3782
|
+
const title = String(item['title'] ?? '').trim();
|
|
3783
|
+
if (!id || !title)
|
|
3784
|
+
continue;
|
|
3785
|
+
const orderNum = Number(item['order']);
|
|
3786
|
+
const subtitle = typeof item['subtitle'] === 'string' && item['subtitle'].trim() ? item['subtitle'].trim() : undefined;
|
|
3787
|
+
const icon = typeof item['icon'] === 'string' && item['icon'].trim() ? item['icon'].trim() : undefined;
|
|
3788
|
+
const groups = this.parseNonBlankStringArray(item['groups']);
|
|
3789
|
+
const optional = this.parseOptionalBoolean(item['optional']);
|
|
3790
|
+
sections.push({
|
|
3791
|
+
id,
|
|
3792
|
+
title,
|
|
3793
|
+
...(subtitle ? { subtitle } : {}),
|
|
3794
|
+
...(icon ? { icon } : {}),
|
|
3795
|
+
order: Number.isFinite(orderNum) ? orderNum : idx,
|
|
3796
|
+
...(groups.length ? { groups } : {}),
|
|
3797
|
+
...(optional !== undefined ? { optional } : {}),
|
|
3798
|
+
});
|
|
3799
|
+
}
|
|
3800
|
+
sections.sort((a, b) => a.order - b.order);
|
|
3801
|
+
const rawSteps = Array.isArray(record['steps']) ? record['steps'] : [];
|
|
3802
|
+
const steps = [];
|
|
3803
|
+
for (const entry of rawSteps) {
|
|
3804
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry))
|
|
3805
|
+
continue;
|
|
3806
|
+
const item = entry;
|
|
3807
|
+
const id = String(item['id'] ?? '').trim();
|
|
3808
|
+
const label = String(item['label'] ?? '').trim() || id;
|
|
3809
|
+
const sectionIds = this.parseNonBlankStringArray(item['sectionIds']);
|
|
3810
|
+
if (!id || !sectionIds.length)
|
|
3811
|
+
continue;
|
|
3812
|
+
const description = typeof item['description'] === 'string' && item['description'].trim()
|
|
3813
|
+
? item['description'].trim()
|
|
3814
|
+
: undefined;
|
|
3815
|
+
const icon = typeof item['icon'] === 'string' && item['icon'].trim()
|
|
3816
|
+
? item['icon'].trim()
|
|
3817
|
+
: undefined;
|
|
3818
|
+
const optional = this.parseOptionalBoolean(item['optional']);
|
|
3819
|
+
const disabled = this.parseOptionalBoolean(item['disabled']);
|
|
3820
|
+
const tooltip = typeof item['tooltip'] === 'string' && item['tooltip'].trim()
|
|
3821
|
+
? item['tooltip'].trim()
|
|
3822
|
+
: undefined;
|
|
3823
|
+
const rawBadge = item['badge'];
|
|
3824
|
+
const badge = typeof rawBadge === 'string'
|
|
3825
|
+
? (rawBadge.trim() ? rawBadge.trim() : undefined)
|
|
3826
|
+
: typeof rawBadge === 'number' && Number.isFinite(rawBadge)
|
|
3827
|
+
? rawBadge
|
|
3828
|
+
: undefined;
|
|
3829
|
+
steps.push({
|
|
3830
|
+
id,
|
|
3831
|
+
label,
|
|
3832
|
+
...(description ? { description } : {}),
|
|
3833
|
+
...(icon ? { icon } : {}),
|
|
3834
|
+
sectionIds,
|
|
3835
|
+
...(optional !== undefined ? { optional } : {}),
|
|
3836
|
+
...(badge !== undefined ? { badge } : {}),
|
|
3837
|
+
...(disabled !== undefined ? { disabled } : {}),
|
|
3838
|
+
...(tooltip ? { tooltip } : {}),
|
|
3839
|
+
});
|
|
3840
|
+
}
|
|
3841
|
+
return {
|
|
3842
|
+
mode,
|
|
3843
|
+
...(defaultTabId ? { defaultTabId } : {}),
|
|
3844
|
+
...(tabsAppearance ? { tabsAppearance } : {}),
|
|
3845
|
+
...(accordionMulti !== undefined ? { accordionMulti } : {}),
|
|
3846
|
+
...(hideSectionHeaderInTabs !== undefined ? { hideSectionHeaderInTabs } : {}),
|
|
3847
|
+
...(hideSectionHeaderInStepper !== undefined ? { hideSectionHeaderInStepper } : {}),
|
|
3848
|
+
...(stepperInReadMode ? { stepperInReadMode } : {}),
|
|
3849
|
+
...(stepperReviewStep !== undefined ? { stepperReviewStep } : {}),
|
|
3850
|
+
...(sections.length ? { sections } : {}),
|
|
3851
|
+
...(steps.length ? { steps } : {}),
|
|
3852
|
+
};
|
|
3853
|
+
}
|
|
3854
|
+
parseContextBinding(raw) {
|
|
3855
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
3856
|
+
return undefined;
|
|
3857
|
+
}
|
|
3858
|
+
const record = raw;
|
|
3859
|
+
const dim = String(record['dimension'] ?? '').trim().toLowerCase();
|
|
3860
|
+
if (dim !== 'organization' &&
|
|
3861
|
+
dim !== 'company_group' &&
|
|
3862
|
+
dim !== 'unit' &&
|
|
3863
|
+
dim !== 'person' &&
|
|
3864
|
+
dim !== 'bond' &&
|
|
3865
|
+
dim !== 'contract') {
|
|
3866
|
+
return undefined;
|
|
3867
|
+
}
|
|
3868
|
+
const targetField = typeof record['targetField'] === 'string' && record['targetField'].trim()
|
|
3869
|
+
? record['targetField'].trim()
|
|
3870
|
+
: undefined;
|
|
3871
|
+
return {
|
|
3872
|
+
dimension: dim,
|
|
3873
|
+
lockWhenActive: this.parseBoolean(record['lockWhenActive']),
|
|
3874
|
+
...(targetField ? { targetField } : {}),
|
|
3875
|
+
};
|
|
2156
3876
|
}
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
if (!this.isNumericSchemaType(typeToken)) {
|
|
3877
|
+
parseResourceState(raw) {
|
|
3878
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
2160
3879
|
return undefined;
|
|
2161
3880
|
}
|
|
2162
|
-
|
|
2163
|
-
|
|
3881
|
+
const record = raw;
|
|
3882
|
+
const initialStates = this.parseNonBlankStringArray(record['initialStates']);
|
|
3883
|
+
const putMutableStates = this.parseNonBlankStringArray(record['putMutableStates']);
|
|
3884
|
+
if (!initialStates.length && !putMutableStates.length) {
|
|
3885
|
+
return undefined;
|
|
2164
3886
|
}
|
|
2165
|
-
return
|
|
3887
|
+
return {
|
|
3888
|
+
...(initialStates.length ? { initialStates } : {}),
|
|
3889
|
+
...(putMutableStates.length ? { putMutableStates } : {}),
|
|
3890
|
+
};
|
|
2166
3891
|
}
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
3892
|
+
parseMicroVisualization(raw) {
|
|
3893
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
3894
|
+
return undefined;
|
|
3895
|
+
}
|
|
3896
|
+
const normalized = normalizePraxisPresentationVisualization(raw);
|
|
3897
|
+
if (normalized) {
|
|
3898
|
+
return normalized;
|
|
3899
|
+
}
|
|
3900
|
+
const clone = this.clonePlain(raw);
|
|
3901
|
+
if (typeof clone['kind'] === 'string' && clone['kind'].trim()) {
|
|
3902
|
+
const rawKind = clone['kind'].trim();
|
|
3903
|
+
const upper = rawKind.toUpperCase();
|
|
3904
|
+
if (upper === 'HARVEY_BALL')
|
|
3905
|
+
clone['kind'] = 'harveyBall';
|
|
3906
|
+
else if (upper === 'STACKED_BAR')
|
|
3907
|
+
clone['kind'] = 'stackedBar';
|
|
3908
|
+
else if (upper === 'PROCESS_FLOW')
|
|
3909
|
+
clone['kind'] = 'processFlow';
|
|
3910
|
+
else if (upper === upper && /^[A-Z_]+$/.test(rawKind))
|
|
3911
|
+
clone['kind'] = rawKind.toLowerCase();
|
|
3912
|
+
return clone;
|
|
3913
|
+
}
|
|
3914
|
+
return undefined;
|
|
2179
3915
|
}
|
|
2180
3916
|
normalizeSchemaWithRoot(schema, rootSchema) {
|
|
2181
3917
|
if (!schema || typeof schema !== 'object') {
|
|
@@ -2195,16 +3931,62 @@ class SchemaNormalizationKernel {
|
|
|
2195
3931
|
!Array.isArray(prop['x-ui'])
|
|
2196
3932
|
? prop['x-ui']
|
|
2197
3933
|
: undefined;
|
|
3934
|
+
const hasChildProperties = prop?.properties &&
|
|
3935
|
+
typeof prop.properties === 'object' &&
|
|
3936
|
+
!Array.isArray(prop.properties);
|
|
3937
|
+
const isCustomFieldsContainer = ui?.customFieldsContainer === true ||
|
|
3938
|
+
(name === 'customFields' && prop?.type === 'object' && hasChildProperties);
|
|
3939
|
+
if (isCustomFieldsContainer) {
|
|
3940
|
+
if (hasChildProperties) {
|
|
3941
|
+
for (const key of Object.keys(prop.properties)) {
|
|
3942
|
+
if (RESERVED_CUSTOM_FIELD_KEYS.has(key)) {
|
|
3943
|
+
throw new Error(`Unsupported custom field key "${name}.${key}". Publish a key admitted by the canonical backend custom-field policy.`);
|
|
3944
|
+
}
|
|
3945
|
+
}
|
|
3946
|
+
const parentAccess = normalizeFieldAccessMetadata(ui?.fieldAccess);
|
|
3947
|
+
for (const childField of this.normalizeSchemaWithRoot(prop, rootSchema)) {
|
|
3948
|
+
const originalKey = childField.name;
|
|
3949
|
+
if (parentAccess && childField.fieldAccess &&
|
|
3950
|
+
!this.haveEquivalentFieldAccess(parentAccess, childField.fieldAccess)) {
|
|
3951
|
+
throw new Error(`Conflicting fieldAccess on custom-field container "${name}" and child "${originalKey}". Publish the effective access policy on each leaf field.`);
|
|
3952
|
+
}
|
|
3953
|
+
fields.push({
|
|
3954
|
+
...childField,
|
|
3955
|
+
name: `${name}.${originalKey}`,
|
|
3956
|
+
customField: true,
|
|
3957
|
+
customFieldKey: childField.customFieldKey ?? originalKey,
|
|
3958
|
+
customFieldScope: childField.customFieldScope ?? 'tenant',
|
|
3959
|
+
...(ui?.disabled !== undefined && this.parseBoolean(ui.disabled) ? { disabled: true } : {}),
|
|
3960
|
+
...(ui?.readOnly !== undefined && this.parseBoolean(ui.readOnly) ? { readOnly: true } : {}),
|
|
3961
|
+
...(ui?.formHidden !== undefined && this.parseBoolean(ui.formHidden) ? { formHidden: true } : {}),
|
|
3962
|
+
...(parentAccess && !childField.fieldAccess ? { fieldAccess: normalizeFieldAccessMetadata(parentAccess) } : {}),
|
|
3963
|
+
});
|
|
3964
|
+
}
|
|
3965
|
+
}
|
|
3966
|
+
// The container is wire structure, never an independent field control.
|
|
3967
|
+
continue;
|
|
3968
|
+
}
|
|
2198
3969
|
// Skip properties without x-ui metadata
|
|
2199
3970
|
if (!ui || Object.keys(ui).length === 0) {
|
|
2200
3971
|
continue;
|
|
2201
3972
|
}
|
|
2202
3973
|
const field = { name };
|
|
3974
|
+
if (ui.customField !== undefined) {
|
|
3975
|
+
field.customField = this.parseBoolean(ui.customField);
|
|
3976
|
+
}
|
|
3977
|
+
if (ui.customFieldKey != null) {
|
|
3978
|
+
field.customFieldKey = String(ui.customFieldKey);
|
|
3979
|
+
}
|
|
3980
|
+
if (ui.customFieldScope != null) {
|
|
3981
|
+
field.customFieldScope = String(ui.customFieldScope);
|
|
3982
|
+
}
|
|
2203
3983
|
// -------------------------------------------------------------------
|
|
2204
3984
|
// Basic information
|
|
2205
3985
|
// -------------------------------------------------------------------
|
|
2206
3986
|
field.label = ui.label ?? prop.title ?? name;
|
|
2207
|
-
field.type = this.resolveFieldType(prop, ui);
|
|
3987
|
+
field.type = this.resolveFieldType(prop, ui, rootSchema);
|
|
3988
|
+
if (field.type === 'array')
|
|
3989
|
+
field.items = normalizeScalarItemsSchema(prop?.items);
|
|
2208
3990
|
const numericFormat = this.resolveNumericFormatToken(prop, ui, field.type);
|
|
2209
3991
|
if (numericFormat) {
|
|
2210
3992
|
field.numericFormat = numericFormat;
|
|
@@ -2218,9 +4000,25 @@ class SchemaNormalizationKernel {
|
|
|
2218
4000
|
if (Object.keys(presentation).length > 0) {
|
|
2219
4001
|
field.presentation = presentation;
|
|
2220
4002
|
}
|
|
4003
|
+
const presentationRules = normalizeFieldPresentationRules(ui.presentationRules);
|
|
4004
|
+
if (presentationRules?.length) {
|
|
4005
|
+
field.presentationRules = presentationRules;
|
|
4006
|
+
}
|
|
2221
4007
|
if (ui.controlType) {
|
|
2222
4008
|
field.controlType = ui.controlType;
|
|
2223
4009
|
}
|
|
4010
|
+
if (this.isCanonicalMonetaryRangeUnion(prop, rootSchema)) {
|
|
4011
|
+
field.type = 'array';
|
|
4012
|
+
const controlToken = normalizeControlTypeToken(field.controlType);
|
|
4013
|
+
const isInlineCurrencyRange = controlToken === 'inlinecurrencyrange' ||
|
|
4014
|
+
resolveInlineFilterControlType(field.controlType) === 'inlineCurrencyRange';
|
|
4015
|
+
if (!isInlineCurrencyRange) {
|
|
4016
|
+
field.controlType = 'priceRange';
|
|
4017
|
+
}
|
|
4018
|
+
}
|
|
4019
|
+
if (this.inferRequireTwoBoundsFromUnion(prop, rootSchema)) {
|
|
4020
|
+
field.requireTwoBounds = true;
|
|
4021
|
+
}
|
|
2224
4022
|
if (field.controlType === 'array' || ui.array !== undefined) {
|
|
2225
4023
|
const arrayConfig = this.normalizeArrayConfig(ui, prop, rootSchema);
|
|
2226
4024
|
if (arrayConfig) {
|
|
@@ -2314,6 +4112,40 @@ class SchemaNormalizationKernel {
|
|
|
2314
4112
|
if (condRequired !== undefined) {
|
|
2315
4113
|
field.conditionalRequired = condRequired;
|
|
2316
4114
|
}
|
|
4115
|
+
if (ui.conditionalReadOnly !== undefined && ui.conditionalReadOnly !== null) {
|
|
4116
|
+
if (typeof ui.conditionalReadOnly === 'string') {
|
|
4117
|
+
const trimmed = ui.conditionalReadOnly.trim();
|
|
4118
|
+
if (trimmed) {
|
|
4119
|
+
field.conditionalReadOnly = trimmed;
|
|
4120
|
+
}
|
|
4121
|
+
}
|
|
4122
|
+
else {
|
|
4123
|
+
const condReadOnly = this.parseJsonLogicExpression(ui.conditionalReadOnly, name, 'x-ui.conditionalReadOnly');
|
|
4124
|
+
if (condReadOnly !== undefined) {
|
|
4125
|
+
field.conditionalReadOnly = condReadOnly;
|
|
4126
|
+
}
|
|
4127
|
+
}
|
|
4128
|
+
}
|
|
4129
|
+
if (ui.colSpan !== undefined) {
|
|
4130
|
+
const parsedSpan = this.parseOptionalFiniteNumber(ui.colSpan);
|
|
4131
|
+
if (parsedSpan !== undefined) {
|
|
4132
|
+
field.colSpan = Math.min(12, Math.max(1, Math.trunc(parsedSpan)));
|
|
4133
|
+
}
|
|
4134
|
+
}
|
|
4135
|
+
const contextBinding = this.parseContextBinding(ui.contextBinding);
|
|
4136
|
+
if (contextBinding) {
|
|
4137
|
+
field.contextBinding = contextBinding;
|
|
4138
|
+
}
|
|
4139
|
+
if (ui.draftCleared !== undefined) {
|
|
4140
|
+
const parsedDraftCleared = this.parseOptionalBoolean(ui.draftCleared);
|
|
4141
|
+
if (parsedDraftCleared !== undefined) {
|
|
4142
|
+
field.draftCleared = parsedDraftCleared;
|
|
4143
|
+
}
|
|
4144
|
+
}
|
|
4145
|
+
const resourceState = this.parseResourceState(ui.resourceState);
|
|
4146
|
+
if (resourceState) {
|
|
4147
|
+
field.resourceState = resourceState;
|
|
4148
|
+
}
|
|
2317
4149
|
const transformFn = this.parseTransformFunction(ui.transformValueFunction);
|
|
2318
4150
|
if (transformFn) {
|
|
2319
4151
|
field.transformValueFunction = transformFn;
|
|
@@ -2328,9 +4160,57 @@ class SchemaNormalizationKernel {
|
|
|
2328
4160
|
if (ui.tableHidden !== undefined) {
|
|
2329
4161
|
field.tableHidden = this.parseBoolean(ui.tableHidden);
|
|
2330
4162
|
}
|
|
4163
|
+
if (ui.tableOrder !== undefined) {
|
|
4164
|
+
const parsedTableOrder = this.parseOptionalFiniteNumber(ui.tableOrder);
|
|
4165
|
+
if (parsedTableOrder !== undefined) {
|
|
4166
|
+
field.tableOrder = parsedTableOrder;
|
|
4167
|
+
}
|
|
4168
|
+
}
|
|
4169
|
+
if (ui.pinned !== undefined && typeof ui.pinned === 'string') {
|
|
4170
|
+
const pinned = ui.pinned.trim().toLowerCase();
|
|
4171
|
+
if (pinned === 'start' || pinned === 'end') {
|
|
4172
|
+
field.pinned = pinned;
|
|
4173
|
+
}
|
|
4174
|
+
}
|
|
4175
|
+
if (ui.primarySearch !== undefined) {
|
|
4176
|
+
const primarySearch = this.parseOptionalBoolean(ui.primarySearch);
|
|
4177
|
+
if (primarySearch !== undefined) {
|
|
4178
|
+
field.primarySearch = primarySearch;
|
|
4179
|
+
}
|
|
4180
|
+
}
|
|
4181
|
+
if (ui.inlineFilter !== undefined) {
|
|
4182
|
+
const inlineFilter = this.parseOptionalBoolean(ui.inlineFilter);
|
|
4183
|
+
if (inlineFilter !== undefined) {
|
|
4184
|
+
field.inlineFilter = inlineFilter;
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4187
|
+
if (ui.inline !== undefined) {
|
|
4188
|
+
const inline = this.parseOptionalBoolean(ui.inline);
|
|
4189
|
+
if (inline !== undefined) {
|
|
4190
|
+
field.inline = inline;
|
|
4191
|
+
}
|
|
4192
|
+
}
|
|
4193
|
+
if (ui.microVisualization !== undefined) {
|
|
4194
|
+
const microVisualization = this.parseMicroVisualization(ui.microVisualization);
|
|
4195
|
+
if (microVisualization) {
|
|
4196
|
+
field.microVisualization = microVisualization;
|
|
4197
|
+
}
|
|
4198
|
+
}
|
|
2331
4199
|
if (ui.formHidden !== undefined) {
|
|
2332
4200
|
field.formHidden = this.parseBoolean(ui.formHidden);
|
|
2333
4201
|
}
|
|
4202
|
+
if (ui.quickViewVisible !== undefined) {
|
|
4203
|
+
const quickViewVisible = this.parseOptionalBoolean(ui.quickViewVisible);
|
|
4204
|
+
if (quickViewVisible !== undefined) {
|
|
4205
|
+
field.quickViewVisible = quickViewVisible;
|
|
4206
|
+
}
|
|
4207
|
+
}
|
|
4208
|
+
if (ui.quickViewOrder !== undefined) {
|
|
4209
|
+
const quickViewOrder = this.parseOptionalFiniteNumber(ui.quickViewOrder);
|
|
4210
|
+
if (quickViewOrder !== undefined) {
|
|
4211
|
+
field.quickViewOrder = quickViewOrder;
|
|
4212
|
+
}
|
|
4213
|
+
}
|
|
2334
4214
|
if (ui.width !== undefined) {
|
|
2335
4215
|
field.width = ui.width;
|
|
2336
4216
|
}
|
|
@@ -2414,6 +4294,9 @@ class SchemaNormalizationKernel {
|
|
|
2414
4294
|
if (ui.options !== undefined) {
|
|
2415
4295
|
field.options = this.parseOptions(ui.options);
|
|
2416
4296
|
}
|
|
4297
|
+
if (Array.isArray(prop?.enum) && prop.enum.length > 0 && field.enumValues === undefined) {
|
|
4298
|
+
field.enumValues = [...prop.enum];
|
|
4299
|
+
}
|
|
2417
4300
|
if (ui.optionGroups !== undefined) {
|
|
2418
4301
|
field.optionGroups = this.parseOptions(ui.optionGroups);
|
|
2419
4302
|
}
|
|
@@ -2431,11 +4314,11 @@ class SchemaNormalizationKernel {
|
|
|
2431
4314
|
if (optionSource) {
|
|
2432
4315
|
// Java metadata publishes cascade context beside optionSource. Keep the
|
|
2433
4316
|
// runtime contract canonical by materializing it inside optionSource.
|
|
2434
|
-
const dependsOn = this.
|
|
4317
|
+
const dependsOn = this.parseDependsOn(ui.dependsOn);
|
|
2435
4318
|
if (!optionSource.dependsOn?.length && dependsOn.length) {
|
|
2436
4319
|
optionSource.dependsOn = dependsOn;
|
|
2437
4320
|
}
|
|
2438
|
-
const dependencyFilterMap = this.
|
|
4321
|
+
const dependencyFilterMap = this.parseStrictStringRecord(ui.dependencyFilterMap);
|
|
2439
4322
|
if (!optionSource.dependencyFilterMap &&
|
|
2440
4323
|
dependencyFilterMap) {
|
|
2441
4324
|
optionSource.dependencyFilterMap = dependencyFilterMap;
|
|
@@ -2452,6 +4335,24 @@ class SchemaNormalizationKernel {
|
|
|
2452
4335
|
if (ui.filterField !== undefined) {
|
|
2453
4336
|
field.filterField = ui.filterField;
|
|
2454
4337
|
}
|
|
4338
|
+
if (ui.resourceReference !== undefined) {
|
|
4339
|
+
const resourceReference = this.parseResourceReference(ui.resourceReference);
|
|
4340
|
+
if (resourceReference) {
|
|
4341
|
+
field.resourceReference = resourceReference;
|
|
4342
|
+
}
|
|
4343
|
+
}
|
|
4344
|
+
if (ui.quickView !== undefined) {
|
|
4345
|
+
const explicitQuickView = normalizeResourceQuickViewBinding(ui.quickView);
|
|
4346
|
+
if (explicitQuickView) {
|
|
4347
|
+
field.quickView = explicitQuickView;
|
|
4348
|
+
}
|
|
4349
|
+
}
|
|
4350
|
+
if (!field.quickView) {
|
|
4351
|
+
const synthesized = resolveFieldQuickViewBinding(field);
|
|
4352
|
+
if (synthesized) {
|
|
4353
|
+
field.quickView = synthesized;
|
|
4354
|
+
}
|
|
4355
|
+
}
|
|
2455
4356
|
if (ui.multiple !== undefined) {
|
|
2456
4357
|
field.multiple = this.parseBoolean(ui.multiple);
|
|
2457
4358
|
}
|
|
@@ -2464,11 +4365,10 @@ class SchemaNormalizationKernel {
|
|
|
2464
4365
|
if (ui.filter !== undefined) {
|
|
2465
4366
|
field.filter = ui.filter;
|
|
2466
4367
|
}
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
}
|
|
4368
|
+
const explicitDialog = ui.dialog !== undefined ? this.parseLookupDialog(ui.dialog) : undefined;
|
|
4369
|
+
const resolvedDialog = this.mergeLookupDialog(field.optionSource?.dialog, explicitDialog);
|
|
4370
|
+
if (resolvedDialog) {
|
|
4371
|
+
field.dialog = resolvedDialog;
|
|
2472
4372
|
}
|
|
2473
4373
|
if (ui.detailActionLabel !== undefined) {
|
|
2474
4374
|
const detailActionLabel = String(ui.detailActionLabel).trim();
|
|
@@ -2476,6 +4376,12 @@ class SchemaNormalizationKernel {
|
|
|
2476
4376
|
field.detailActionLabel = detailActionLabel;
|
|
2477
4377
|
}
|
|
2478
4378
|
}
|
|
4379
|
+
if (ui.quickViewActionLabel !== undefined) {
|
|
4380
|
+
const quickViewActionLabel = String(ui.quickViewActionLabel).trim();
|
|
4381
|
+
if (quickViewActionLabel) {
|
|
4382
|
+
field.quickViewActionLabel = quickViewActionLabel;
|
|
4383
|
+
}
|
|
4384
|
+
}
|
|
2479
4385
|
if (ui.copyCodeActionLabel !== undefined) {
|
|
2480
4386
|
const copyCodeActionLabel = String(ui.copyCodeActionLabel).trim();
|
|
2481
4387
|
if (copyCodeActionLabel) {
|
|
@@ -2499,6 +4405,9 @@ class SchemaNormalizationKernel {
|
|
|
2499
4405
|
if (ui.actions.showDetail !== undefined) {
|
|
2500
4406
|
actions.showDetail = this.parseBoolean(ui.actions.showDetail);
|
|
2501
4407
|
}
|
|
4408
|
+
if (ui.actions.showQuickView !== undefined) {
|
|
4409
|
+
actions.showQuickView = this.parseBoolean(ui.actions.showQuickView);
|
|
4410
|
+
}
|
|
2502
4411
|
if (ui.actions.showCopyCode !== undefined) {
|
|
2503
4412
|
actions.showCopyCode = this.parseBoolean(ui.actions.showCopyCode);
|
|
2504
4413
|
}
|
|
@@ -2530,10 +4439,22 @@ class SchemaNormalizationKernel {
|
|
|
2530
4439
|
field.numericStep = Number(ui.numericStep);
|
|
2531
4440
|
}
|
|
2532
4441
|
if (ui.numericMin !== undefined) {
|
|
2533
|
-
|
|
4442
|
+
const parsedMin = Number(ui.numericMin);
|
|
4443
|
+
if (Number.isFinite(parsedMin)) {
|
|
4444
|
+
field.numericMin = parsedMin;
|
|
4445
|
+
}
|
|
4446
|
+
else if (field.min === undefined && String(ui.numericMin).trim().length > 0) {
|
|
4447
|
+
field.min = String(ui.numericMin).trim();
|
|
4448
|
+
}
|
|
2534
4449
|
}
|
|
2535
4450
|
if (ui.numericMax !== undefined) {
|
|
2536
|
-
|
|
4451
|
+
const parsedMax = Number(ui.numericMax);
|
|
4452
|
+
if (Number.isFinite(parsedMax)) {
|
|
4453
|
+
field.numericMax = parsedMax;
|
|
4454
|
+
}
|
|
4455
|
+
else if (field.max === undefined && String(ui.numericMax).trim().length > 0) {
|
|
4456
|
+
field.max = String(ui.numericMax).trim();
|
|
4457
|
+
}
|
|
2537
4458
|
}
|
|
2538
4459
|
if (ui.numericMaxLength !== undefined) {
|
|
2539
4460
|
field.numericMaxLength = Number(ui.numericMaxLength);
|
|
@@ -2541,8 +4462,419 @@ class SchemaNormalizationKernel {
|
|
|
2541
4462
|
if (ui.buttons !== undefined) {
|
|
2542
4463
|
field.buttons = this.parseButtons(ui.buttons);
|
|
2543
4464
|
}
|
|
4465
|
+
if (ui.valueLabelDisplay !== undefined) {
|
|
4466
|
+
const normalizedValueLabelDisplay = typeof ui.valueLabelDisplay === 'string'
|
|
4467
|
+
? ui.valueLabelDisplay.trim().toLowerCase()
|
|
4468
|
+
: '';
|
|
4469
|
+
if (normalizedValueLabelDisplay === 'off' ||
|
|
4470
|
+
normalizedValueLabelDisplay === 'auto' ||
|
|
4471
|
+
normalizedValueLabelDisplay === 'on') {
|
|
4472
|
+
field.valueLabelDisplay = normalizedValueLabelDisplay;
|
|
4473
|
+
}
|
|
4474
|
+
}
|
|
4475
|
+
const sliderBooleanKeys = [
|
|
4476
|
+
'thumbLabel',
|
|
4477
|
+
'discrete',
|
|
4478
|
+
'showInputs',
|
|
4479
|
+
'showInlineInputs',
|
|
4480
|
+
'showCurrencySymbol',
|
|
4481
|
+
'disableThumbSwap',
|
|
4482
|
+
'vertical',
|
|
4483
|
+
'invert',
|
|
4484
|
+
];
|
|
4485
|
+
for (const key of sliderBooleanKeys) {
|
|
4486
|
+
if (ui[key] !== undefined) {
|
|
4487
|
+
const parsed = this.parseOptionalBoolean(ui[key]);
|
|
4488
|
+
if (parsed !== undefined) {
|
|
4489
|
+
field[key] = parsed;
|
|
4490
|
+
}
|
|
4491
|
+
}
|
|
4492
|
+
}
|
|
4493
|
+
for (const guideKey of ['showTicks', 'showAnchors']) {
|
|
4494
|
+
const rawGuide = ui[guideKey];
|
|
4495
|
+
if (rawGuide !== undefined) {
|
|
4496
|
+
const parsedGuide = this.parseOptionalBoolean(rawGuide);
|
|
4497
|
+
if (parsedGuide !== undefined) {
|
|
4498
|
+
field[guideKey] = parsedGuide;
|
|
4499
|
+
}
|
|
4500
|
+
else if (typeof rawGuide === 'string' &&
|
|
4501
|
+
rawGuide.trim().toLowerCase() === 'auto') {
|
|
4502
|
+
field[guideKey] = 'auto';
|
|
4503
|
+
}
|
|
4504
|
+
}
|
|
4505
|
+
}
|
|
4506
|
+
const sliderNumberKeys = [
|
|
4507
|
+
'sliderStep',
|
|
4508
|
+
'shiftStep',
|
|
4509
|
+
'minDistance',
|
|
4510
|
+
'maxDistance',
|
|
4511
|
+
'decimalPlaces',
|
|
4512
|
+
];
|
|
4513
|
+
for (const key of sliderNumberKeys) {
|
|
4514
|
+
if (ui[key] !== undefined) {
|
|
4515
|
+
const parsed = this.parseOptionalFiniteNumber(ui[key]);
|
|
4516
|
+
if (parsed !== undefined) {
|
|
4517
|
+
field[key] = parsed;
|
|
4518
|
+
}
|
|
4519
|
+
}
|
|
4520
|
+
}
|
|
4521
|
+
// -------------------------------------------------------------------
|
|
4522
|
+
// Inline filter and specialized control metadata (x-ui)
|
|
4523
|
+
// -------------------------------------------------------------------
|
|
4524
|
+
const inlinePassThroughKeys = [
|
|
4525
|
+
'prefixIcon',
|
|
4526
|
+
'suffixIcon',
|
|
4527
|
+
'prefixIconColor',
|
|
4528
|
+
'suffixIconColor',
|
|
4529
|
+
'chipLeadingIcon',
|
|
4530
|
+
'chipTrailingIcon',
|
|
4531
|
+
'chipLeadingIconColor',
|
|
4532
|
+
'chipTrailingIconColor',
|
|
4533
|
+
'clearIcon',
|
|
4534
|
+
'clearIconColor',
|
|
4535
|
+
'showQuickClear',
|
|
4536
|
+
'clearable',
|
|
4537
|
+
'inlineAutoSize',
|
|
4538
|
+
'inlineAutoSizeMaxPx',
|
|
4539
|
+
'inlineAutoSizeMaxVw',
|
|
4540
|
+
'inlineOverlay',
|
|
4541
|
+
'inlineChipDisplay',
|
|
4542
|
+
'inlineChipSummaryTemplate',
|
|
4543
|
+
'inlineChipUnitLabel',
|
|
4544
|
+
'inlinePanelTitle',
|
|
4545
|
+
'inlinePanelSubtitle',
|
|
4546
|
+
'inlinePanelIcon',
|
|
4547
|
+
'inlinePanelIconColor',
|
|
4548
|
+
'inlineQuickPresets',
|
|
4549
|
+
'inlineQuickPresetsApplyMode',
|
|
4550
|
+
'inlineTexts',
|
|
4551
|
+
'shortcuts',
|
|
4552
|
+
'showShortcuts',
|
|
4553
|
+
'quickPresets',
|
|
4554
|
+
'quickPresetsAuto',
|
|
4555
|
+
'quickPresetsLabels',
|
|
4556
|
+
'granularity',
|
|
4557
|
+
'defaultGranularity',
|
|
4558
|
+
'selectionGrid',
|
|
4559
|
+
'showSlider',
|
|
4560
|
+
'minPeriod',
|
|
4561
|
+
'maxPeriod',
|
|
4562
|
+
'minYear',
|
|
4563
|
+
'maxYear',
|
|
4564
|
+
'minTime',
|
|
4565
|
+
'maxTime',
|
|
4566
|
+
'stepMinute',
|
|
4567
|
+
'stepMinutes',
|
|
4568
|
+
'interval',
|
|
4569
|
+
'inlineTimeTrackShifts',
|
|
4570
|
+
'inlineTrackShifts',
|
|
4571
|
+
'trackShifts',
|
|
4572
|
+
'minDistanceMinutes',
|
|
4573
|
+
'maxDistanceMinutes',
|
|
4574
|
+
'startField',
|
|
4575
|
+
'endField',
|
|
4576
|
+
'startLabel',
|
|
4577
|
+
'endLabel',
|
|
4578
|
+
'startPlaceholder',
|
|
4579
|
+
'endPlaceholder',
|
|
4580
|
+
'inputMinLabel',
|
|
4581
|
+
'inputMaxLabel',
|
|
4582
|
+
'inputExactLabel',
|
|
4583
|
+
'startMin',
|
|
4584
|
+
'startMax',
|
|
4585
|
+
'endMin',
|
|
4586
|
+
'endMax',
|
|
4587
|
+
'startMinMessage',
|
|
4588
|
+
'startMaxMessage',
|
|
4589
|
+
'endMinMessage',
|
|
4590
|
+
'endMaxMessage',
|
|
4591
|
+
'endMinOffset',
|
|
4592
|
+
'endMinOffsetMessage',
|
|
4593
|
+
'startMaxOffset',
|
|
4594
|
+
'startMaxOffsetMessage',
|
|
4595
|
+
'maxVisibleChips',
|
|
4596
|
+
'maxVisibleBadges',
|
|
4597
|
+
'showSelectAll',
|
|
4598
|
+
'selectAllLabel',
|
|
4599
|
+
'clearSelectionLabel',
|
|
4600
|
+
'searchPlaceholder',
|
|
4601
|
+
'noResultsText',
|
|
4602
|
+
'allowSelectAll',
|
|
4603
|
+
'governedPaletteRef',
|
|
4604
|
+
'palette',
|
|
4605
|
+
'paletteColors',
|
|
4606
|
+
'paletteSettings',
|
|
4607
|
+
'documentType',
|
|
4608
|
+
'version',
|
|
4609
|
+
'nodes',
|
|
4610
|
+
'nodeIdField',
|
|
4611
|
+
'parentIdField',
|
|
4612
|
+
'childrenField',
|
|
4613
|
+
'lazyLoad',
|
|
4614
|
+
'marks',
|
|
4615
|
+
'semanticBands',
|
|
4616
|
+
'distribution',
|
|
4617
|
+
'inlineDistribution',
|
|
4618
|
+
'track',
|
|
4619
|
+
'trueLabel',
|
|
4620
|
+
'falseLabel',
|
|
4621
|
+
'labelTrue',
|
|
4622
|
+
'labelFalse',
|
|
4623
|
+
'iconTrue',
|
|
4624
|
+
'iconFalse',
|
|
4625
|
+
'tone',
|
|
4626
|
+
'toneTrue',
|
|
4627
|
+
'toneFalse',
|
|
4628
|
+
'booleanFormat',
|
|
4629
|
+
'displayFormat',
|
|
4630
|
+
'currency',
|
|
4631
|
+
'currencyCode',
|
|
4632
|
+
'currencyPosition',
|
|
4633
|
+
'thousandSeparator',
|
|
4634
|
+
'thousandsSeparator',
|
|
4635
|
+
'decimalSeparator',
|
|
4636
|
+
'allowNegative',
|
|
4637
|
+
'operatorModes',
|
|
4638
|
+
'defaultOperatorMode',
|
|
4639
|
+
'requireTwoBounds',
|
|
4640
|
+
'locale',
|
|
4641
|
+
'precision',
|
|
4642
|
+
'initialsField',
|
|
4643
|
+
'optionLabelKey',
|
|
4644
|
+
'optionValueKey',
|
|
4645
|
+
'extraProperties',
|
|
4646
|
+
'rangeMode',
|
|
4647
|
+
'maxRating',
|
|
4648
|
+
'ratingMin',
|
|
4649
|
+
'ratingMax',
|
|
4650
|
+
'itemsCount',
|
|
4651
|
+
'ratingStep',
|
|
4652
|
+
'allowHalf',
|
|
4653
|
+
'ratingAllowHalf',
|
|
4654
|
+
'ratingPrecision',
|
|
4655
|
+
'ratingIcon',
|
|
4656
|
+
'ratingEmptyIcon',
|
|
4657
|
+
'ratingHalfIcon',
|
|
4658
|
+
'ratingActiveIcon',
|
|
4659
|
+
'ratingInactiveIcon',
|
|
4660
|
+
'ratingTone',
|
|
4661
|
+
'ratingToneColors',
|
|
4662
|
+
'ratingColors',
|
|
4663
|
+
'starColors',
|
|
4664
|
+
'ratingLowColor',
|
|
4665
|
+
'ratingMidColor',
|
|
4666
|
+
'ratingHighColor',
|
|
4667
|
+
'ratingGradientLowColor',
|
|
4668
|
+
'ratingGradientMidColor',
|
|
4669
|
+
'ratingGradientHighColor',
|
|
4670
|
+
'ratingToneLowColor',
|
|
4671
|
+
'ratingToneMidColor',
|
|
4672
|
+
'ratingToneHighColor',
|
|
4673
|
+
'ratingBadgeColor',
|
|
4674
|
+
'ratingBadgeIcon',
|
|
4675
|
+
'ratingBadgeIconColor',
|
|
4676
|
+
'ratingIndicatorColor',
|
|
4677
|
+
'ratingLabels',
|
|
4678
|
+
'distanceUnit',
|
|
4679
|
+
'distanceBaseUnit',
|
|
4680
|
+
'distanceUnits',
|
|
4681
|
+
'distanceAllowUnitToggle',
|
|
4682
|
+
'distanceUnitLabels',
|
|
4683
|
+
'distanceDisplayDecimals',
|
|
4684
|
+
'distanceDecimalsKm',
|
|
4685
|
+
'distanceDecimalsMi',
|
|
4686
|
+
'distancePresets',
|
|
4687
|
+
'distanceSubtitle',
|
|
4688
|
+
'distanceIcon',
|
|
4689
|
+
'distanceStart',
|
|
4690
|
+
'distanceEnd',
|
|
4691
|
+
'radiusMin',
|
|
4692
|
+
'radiusMax',
|
|
4693
|
+
'radiusStep',
|
|
4694
|
+
'radiusMode',
|
|
4695
|
+
'distanceSliderStep',
|
|
4696
|
+
'distanceRadialRings',
|
|
4697
|
+
'distanceAccentColor',
|
|
4698
|
+
'distanceRingColor',
|
|
4699
|
+
'distanceTrackColor',
|
|
4700
|
+
'distanceGlowColor',
|
|
4701
|
+
'distanceGradientLowColor',
|
|
4702
|
+
'distanceGradientMidColor',
|
|
4703
|
+
'distanceGradientHighColor',
|
|
4704
|
+
'distanceRangeBandOpacity',
|
|
4705
|
+
'pipelineOptions',
|
|
4706
|
+
'pipelineColors',
|
|
4707
|
+
'pipelineTexts',
|
|
4708
|
+
'scoreBands',
|
|
4709
|
+
'priorityBands',
|
|
4710
|
+
'severityBands',
|
|
4711
|
+
'scorePalette',
|
|
4712
|
+
'scoreTexts',
|
|
4713
|
+
'scoreSubtitle',
|
|
4714
|
+
'scoreUnit',
|
|
4715
|
+
'scoreDisplayDecimals',
|
|
4716
|
+
'scoreShowScaleLabels',
|
|
4717
|
+
'scoreShowBandChips',
|
|
4718
|
+
'scoreRangeSeparator',
|
|
4719
|
+
'scoreGradientLowColor',
|
|
4720
|
+
'scoreGradientMidColor',
|
|
4721
|
+
'scoreGradientHighColor',
|
|
4722
|
+
'scoreValueFallbackColor',
|
|
4723
|
+
'scoreEmptyGradient',
|
|
4724
|
+
'scoreIcon',
|
|
4725
|
+
'scoreBandsAriaLabel',
|
|
4726
|
+
'scoreBandAriaLabelTemplate',
|
|
4727
|
+
'scoreMin',
|
|
4728
|
+
'scoreMax',
|
|
4729
|
+
'scoreStep',
|
|
4730
|
+
'scoreMode',
|
|
4731
|
+
'scoreSliderStep',
|
|
4732
|
+
'relativePeriodOptions',
|
|
4733
|
+
'relativePeriodPresets',
|
|
4734
|
+
'relativePeriodTexts',
|
|
4735
|
+
'sentimentOptions',
|
|
4736
|
+
'sentimentPalette',
|
|
4737
|
+
'sentimentTexts',
|
|
4738
|
+
'colorLabelOptions',
|
|
4739
|
+
'colorLabelPalette',
|
|
4740
|
+
'colorLabelTexts',
|
|
4741
|
+
'timeOptions',
|
|
4742
|
+
'inlineTimeQuickPresets',
|
|
4743
|
+
'inlineVisualStyle',
|
|
4744
|
+
'percentPresets',
|
|
4745
|
+
'numberFormat',
|
|
4746
|
+
'valueLabelFormat',
|
|
4747
|
+
'scale',
|
|
4748
|
+
'optionSubtitleKey',
|
|
4749
|
+
'optionWeightKey',
|
|
4750
|
+
'optionColorKey',
|
|
4751
|
+
'optionIconKey',
|
|
4752
|
+
'optionEmojiKey',
|
|
4753
|
+
'panelSearchIcon',
|
|
4754
|
+
'panelSearchIconColor',
|
|
4755
|
+
'panelResetIcon',
|
|
4756
|
+
'panelResetIconColor',
|
|
4757
|
+
'optionSelectedIcon',
|
|
4758
|
+
'optionSelectedIconColor',
|
|
4759
|
+
'columns',
|
|
4760
|
+
'pipelineTitle',
|
|
4761
|
+
'pipelineSubtitle',
|
|
4762
|
+
'pipelineMode',
|
|
4763
|
+
'pipelineMultiple',
|
|
4764
|
+
'pipelineSearchable',
|
|
4765
|
+
'pipelineSearchPlaceholder',
|
|
4766
|
+
'pipelineOptionSubtitleKey',
|
|
4767
|
+
'pipelineOptionWeightKey',
|
|
4768
|
+
'pipelineOptionColorKey',
|
|
4769
|
+
'pipelineShowBar',
|
|
4770
|
+
'pipelineShowSelectionPills',
|
|
4771
|
+
'pipelineShowSelectAll',
|
|
4772
|
+
'pipelineSelectAllText',
|
|
4773
|
+
'pipelineShowClearAction',
|
|
4774
|
+
'pipelineClearActionText',
|
|
4775
|
+
'pipelineChipMaxVisible',
|
|
4776
|
+
'statusColors',
|
|
4777
|
+
'pipelineGradientLowColor',
|
|
4778
|
+
'pipelineGradientMidColor',
|
|
4779
|
+
'pipelineGradientHighColor',
|
|
4780
|
+
'pipelineEmptyStateText',
|
|
4781
|
+
'pipelineSelectionActionsAriaLabel',
|
|
4782
|
+
'pipelineOptionsGroupAriaLabelMultiple',
|
|
4783
|
+
'pipelineOptionsGroupAriaLabelSingle',
|
|
4784
|
+
'pipelineSelectionPillsAriaLabel',
|
|
4785
|
+
'pipelineBarAriaLabelEmpty',
|
|
4786
|
+
'pipelineBarAriaLabelSelected',
|
|
4787
|
+
'pipelineIcon',
|
|
4788
|
+
'pipelineSearchIcon',
|
|
4789
|
+
'pipelineSearchIconColor',
|
|
4790
|
+
'relativePeriodTitle',
|
|
4791
|
+
'relativePeriodSubtitle',
|
|
4792
|
+
'relativePeriodShowProgress',
|
|
4793
|
+
'relativePeriodProgressGradientLowColor',
|
|
4794
|
+
'relativePeriodProgressGradientMidColor',
|
|
4795
|
+
'relativePeriodProgressGradientHighColor',
|
|
4796
|
+
'relativePeriodColumns',
|
|
4797
|
+
'relativePeriodCloseOnSelect',
|
|
4798
|
+
'relativePeriodMultiple',
|
|
4799
|
+
'relativePeriodSearchable',
|
|
4800
|
+
'relativePeriodIcon',
|
|
4801
|
+
'relativePeriodIconKey',
|
|
4802
|
+
'relativePeriodSubtitleKey',
|
|
4803
|
+
'relativePeriodSelectedIcon',
|
|
4804
|
+
'relativePeriodSelectedIconColor',
|
|
4805
|
+
'relativePeriodOptionsAriaLabel',
|
|
4806
|
+
'relativePeriodProgressEmptyLabel',
|
|
4807
|
+
'relativePeriodEmptyStateText',
|
|
4808
|
+
'sentimentTitle',
|
|
4809
|
+
'sentimentSubtitle',
|
|
4810
|
+
'sentimentGradientLowColor',
|
|
4811
|
+
'sentimentGradientMidColor',
|
|
4812
|
+
'sentimentGradientHighColor',
|
|
4813
|
+
'sentimentShowBar',
|
|
4814
|
+
'sentimentAnimatedEmoji',
|
|
4815
|
+
'sentimentCloseOnSelect',
|
|
4816
|
+
'sentimentMultiple',
|
|
4817
|
+
'sentimentShowSelectionPills',
|
|
4818
|
+
'sentimentIcon',
|
|
4819
|
+
'sentimentColorKey',
|
|
4820
|
+
'sentimentEmojiKey',
|
|
4821
|
+
'sentimentOptionsAriaLabel',
|
|
4822
|
+
'sentimentSelectionPillsAriaLabel',
|
|
4823
|
+
'sentimentEmptyStateText',
|
|
4824
|
+
'colorLabelTitle',
|
|
4825
|
+
'colorLabelSubtitle',
|
|
4826
|
+
'colorLabelMultiple',
|
|
4827
|
+
'colorLabelColumns',
|
|
4828
|
+
'colorLabelShowSelectedBadges',
|
|
4829
|
+
'colorLabelCloseOnSelect',
|
|
4830
|
+
'colorLabelSelectionTitle',
|
|
4831
|
+
'colorLabelIcon',
|
|
4832
|
+
'colorLabelSelectedIcon',
|
|
4833
|
+
'colorLabelSelectedIconColor',
|
|
4834
|
+
'colorLabelBadgeRemoveIcon',
|
|
4835
|
+
'colorLabelBadgeRemoveIconColor',
|
|
4836
|
+
'colorLabelColorKey',
|
|
4837
|
+
'colorLabelOptionsAriaLabel',
|
|
4838
|
+
'colorLabelSelectionBadgesAriaLabel',
|
|
4839
|
+
'colorLabelRemoveSelectionAriaLabel',
|
|
4840
|
+
'colorLabelEmptyStateText',
|
|
4841
|
+
'startAriaLabel',
|
|
4842
|
+
'endAriaLabel',
|
|
4843
|
+
'inlineQuickPresetsAriaLabel',
|
|
4844
|
+
'inlineQuickPresetsCancelLabel',
|
|
4845
|
+
'inlineQuickPresetsCancelAriaLabel',
|
|
4846
|
+
'inlineQuickPresetsApplyLabel',
|
|
4847
|
+
'inlineQuickPresetsApplyAriaLabel',
|
|
4848
|
+
'shortcutsPosition',
|
|
4849
|
+
'applyOnShortcutClick',
|
|
4850
|
+
'i18nShortcuts',
|
|
4851
|
+
'startView',
|
|
4852
|
+
'startAt',
|
|
4853
|
+
'touchUi',
|
|
4854
|
+
'minDate',
|
|
4855
|
+
'maxDate',
|
|
4856
|
+
];
|
|
4857
|
+
for (const key of inlinePassThroughKeys) {
|
|
4858
|
+
if (ui[key] !== undefined && field[key] === undefined) {
|
|
4859
|
+
field[key] = ui[key];
|
|
4860
|
+
}
|
|
4861
|
+
}
|
|
2544
4862
|
fields.push(field);
|
|
2545
4863
|
}
|
|
4864
|
+
if (fields.length === 0 &&
|
|
4865
|
+
properties['parameters'] &&
|
|
4866
|
+
typeof properties['parameters'] === 'object' &&
|
|
4867
|
+
!Array.isArray(properties['parameters'])) {
|
|
4868
|
+
const parametersProp = properties['parameters'];
|
|
4869
|
+
const resolvedParametersSchema = this.resolveSchemaRef(parametersProp.$ref, rootSchema) ?? parametersProp;
|
|
4870
|
+
if (resolvedParametersSchema &&
|
|
4871
|
+
typeof resolvedParametersSchema === 'object' &&
|
|
4872
|
+
resolvedParametersSchema !== schema &&
|
|
4873
|
+
resolvedParametersSchema.properties &&
|
|
4874
|
+
typeof resolvedParametersSchema.properties === 'object') {
|
|
4875
|
+
return this.normalizeObjectSchema(resolvedParametersSchema, rootSchema);
|
|
4876
|
+
}
|
|
4877
|
+
}
|
|
2546
4878
|
// Order by the optional 'order' property when present
|
|
2547
4879
|
fields.sort((a, b) => {
|
|
2548
4880
|
const orderA = a.order ?? Number.MAX_SAFE_INTEGER;
|
|
@@ -2551,29 +4883,177 @@ class SchemaNormalizationKernel {
|
|
|
2551
4883
|
});
|
|
2552
4884
|
return fields;
|
|
2553
4885
|
}
|
|
2554
|
-
|
|
4886
|
+
haveEquivalentFieldAccess(left, right) {
|
|
4887
|
+
const identity = (access) => JSON.stringify([
|
|
4888
|
+
[...(access.visibleForAuthorities ?? [])].sort(),
|
|
4889
|
+
[...(access.editableForAuthorities ?? [])].sort(),
|
|
4890
|
+
]);
|
|
4891
|
+
return identity(left) === identity(right);
|
|
4892
|
+
}
|
|
4893
|
+
resolveSchemaNode(node, rootSchema, visited = new Set()) {
|
|
4894
|
+
if (!node || typeof node !== 'object' || Array.isArray(node)) {
|
|
4895
|
+
return node;
|
|
4896
|
+
}
|
|
4897
|
+
const ref = typeof node.$ref === 'string' ? node.$ref.trim() : '';
|
|
4898
|
+
if (!ref || visited.has(ref)) {
|
|
4899
|
+
return node;
|
|
4900
|
+
}
|
|
4901
|
+
const resolved = this.resolveSchemaRef(ref, rootSchema);
|
|
4902
|
+
if (!resolved || typeof resolved !== 'object' || Array.isArray(resolved)) {
|
|
4903
|
+
return node;
|
|
4904
|
+
}
|
|
4905
|
+
const nextVisited = new Set(visited);
|
|
4906
|
+
nextVisited.add(ref);
|
|
4907
|
+
const resolvedDeep = this.resolveSchemaNode(resolved, rootSchema, nextVisited);
|
|
4908
|
+
const { $ref: _ignoredRef, ...rest } = node;
|
|
4909
|
+
return {
|
|
4910
|
+
...(resolvedDeep && typeof resolvedDeep === 'object' ? resolvedDeep : {}),
|
|
4911
|
+
...rest,
|
|
4912
|
+
};
|
|
4913
|
+
}
|
|
4914
|
+
extractSchemaNonNullTypes(node) {
|
|
4915
|
+
if (!node || typeof node !== 'object') {
|
|
4916
|
+
return [];
|
|
4917
|
+
}
|
|
4918
|
+
const collected = [];
|
|
4919
|
+
const pushType = (raw) => {
|
|
4920
|
+
if (typeof raw !== 'string') {
|
|
4921
|
+
return;
|
|
4922
|
+
}
|
|
4923
|
+
const normalized = raw.trim().toLowerCase();
|
|
4924
|
+
if (normalized && normalized !== 'null' && !collected.includes(normalized)) {
|
|
4925
|
+
collected.push(normalized);
|
|
4926
|
+
}
|
|
4927
|
+
};
|
|
4928
|
+
const pushFrom = (raw) => {
|
|
4929
|
+
if (typeof raw === 'string') {
|
|
4930
|
+
pushType(raw);
|
|
4931
|
+
}
|
|
4932
|
+
else if (Array.isArray(raw)) {
|
|
4933
|
+
for (const item of raw) {
|
|
4934
|
+
pushType(item);
|
|
4935
|
+
}
|
|
4936
|
+
}
|
|
4937
|
+
else if (raw instanceof Set) {
|
|
4938
|
+
for (const item of raw) {
|
|
4939
|
+
pushType(item);
|
|
4940
|
+
}
|
|
4941
|
+
}
|
|
4942
|
+
};
|
|
4943
|
+
pushFrom(node.type);
|
|
4944
|
+
pushFrom(node.types);
|
|
4945
|
+
return collected;
|
|
4946
|
+
}
|
|
4947
|
+
extractUnionVariants(prop, rootSchema) {
|
|
4948
|
+
const resolvedProp = this.resolveSchemaNode(prop, rootSchema);
|
|
4949
|
+
if (!resolvedProp || typeof resolvedProp !== 'object' || Array.isArray(resolvedProp)) {
|
|
4950
|
+
return [];
|
|
4951
|
+
}
|
|
4952
|
+
const rawVariants = [
|
|
4953
|
+
...(Array.isArray(resolvedProp.oneOf) ? resolvedProp.oneOf : []),
|
|
4954
|
+
...(Array.isArray(resolvedProp.anyOf) ? resolvedProp.anyOf : []),
|
|
4955
|
+
];
|
|
4956
|
+
return rawVariants
|
|
4957
|
+
.filter((variant) => variant && typeof variant === 'object' && !Array.isArray(variant))
|
|
4958
|
+
.map((variant) => this.resolveSchemaNode(variant, rootSchema));
|
|
4959
|
+
}
|
|
4960
|
+
isArrayVariant(variant) {
|
|
4961
|
+
return this.extractSchemaNonNullTypes(variant).includes('array');
|
|
4962
|
+
}
|
|
4963
|
+
isObjectVariant(variant) {
|
|
4964
|
+
const types = this.extractSchemaNonNullTypes(variant);
|
|
4965
|
+
return (types.includes('object') ||
|
|
4966
|
+
(types.length === 0 &&
|
|
4967
|
+
!!variant?.properties &&
|
|
4968
|
+
typeof variant.properties === 'object' &&
|
|
4969
|
+
!Array.isArray(variant.properties)));
|
|
4970
|
+
}
|
|
4971
|
+
isCanonicalMonetaryRangeUnion(prop, rootSchema) {
|
|
4972
|
+
const variants = this.extractUnionVariants(prop, rootSchema);
|
|
4973
|
+
if (variants.length === 0) {
|
|
4974
|
+
return false;
|
|
4975
|
+
}
|
|
4976
|
+
const hasArrayBranch = variants.some((variant) => this.isArrayVariant(variant));
|
|
4977
|
+
if (!hasArrayBranch) {
|
|
4978
|
+
return false;
|
|
4979
|
+
}
|
|
4980
|
+
return variants.some((variant) => {
|
|
4981
|
+
if (!this.isObjectVariant(variant)) {
|
|
4982
|
+
return false;
|
|
4983
|
+
}
|
|
4984
|
+
const props = variant?.properties;
|
|
4985
|
+
if (!props || typeof props !== 'object' || Array.isArray(props)) {
|
|
4986
|
+
return false;
|
|
4987
|
+
}
|
|
4988
|
+
return (Object.prototype.hasOwnProperty.call(props, 'minPrice') &&
|
|
4989
|
+
props.minPrice != null &&
|
|
4990
|
+
Object.prototype.hasOwnProperty.call(props, 'maxPrice') &&
|
|
4991
|
+
props.maxPrice != null);
|
|
4992
|
+
});
|
|
4993
|
+
}
|
|
4994
|
+
inferRequireTwoBoundsFromUnion(prop, rootSchema) {
|
|
4995
|
+
const variants = this.extractUnionVariants(prop, rootSchema);
|
|
4996
|
+
if (variants.length === 0) {
|
|
4997
|
+
return false;
|
|
4998
|
+
}
|
|
4999
|
+
const requiredPairs = [
|
|
5000
|
+
['minPrice', 'maxPrice'],
|
|
5001
|
+
['min', 'max'],
|
|
5002
|
+
['startDate', 'endDate'],
|
|
5003
|
+
];
|
|
5004
|
+
for (const variant of variants) {
|
|
5005
|
+
if (this.isArrayVariant(variant) && Number(variant?.minItems) === 2) {
|
|
5006
|
+
return true;
|
|
5007
|
+
}
|
|
5008
|
+
if (this.isObjectVariant(variant) && Array.isArray(variant?.required)) {
|
|
5009
|
+
const requiredSet = new Set(variant.required.filter((entry) => typeof entry === 'string'));
|
|
5010
|
+
if (requiredPairs.some(([lower, upper]) => requiredSet.has(lower) && requiredSet.has(upper))) {
|
|
5011
|
+
return true;
|
|
5012
|
+
}
|
|
5013
|
+
}
|
|
5014
|
+
}
|
|
5015
|
+
return false;
|
|
5016
|
+
}
|
|
5017
|
+
resolveFieldType(prop, ui, rootSchema) {
|
|
5018
|
+
if (this.isCanonicalMonetaryRangeUnion(prop, rootSchema)) {
|
|
5019
|
+
return 'array';
|
|
5020
|
+
}
|
|
2555
5021
|
if (ui?.type !== undefined && ui?.type !== null && String(ui.type).trim() !== '') {
|
|
2556
5022
|
return String(ui.type);
|
|
2557
5023
|
}
|
|
2558
5024
|
if (String(ui?.controlType ?? '').trim() === 'array') {
|
|
2559
5025
|
return 'array';
|
|
2560
5026
|
}
|
|
2561
|
-
|
|
2562
|
-
|
|
5027
|
+
const resolvedProp = this.resolveSchemaNode(prop, rootSchema);
|
|
5028
|
+
const propTypes = this.extractSchemaNonNullTypes(resolvedProp);
|
|
5029
|
+
if (propTypes.length === 1) {
|
|
5030
|
+
return propTypes[0];
|
|
5031
|
+
}
|
|
5032
|
+
if (resolvedProp?.type && !Array.isArray(resolvedProp.type)) {
|
|
5033
|
+
return String(resolvedProp.type);
|
|
2563
5034
|
}
|
|
2564
|
-
const variants =
|
|
2565
|
-
|
|
2566
|
-
...(Array.isArray(prop?.anyOf) ? prop.anyOf : []),
|
|
2567
|
-
].filter((variant) => variant && typeof variant === 'object');
|
|
2568
|
-
const nonNullTypes = Array.from(new Set(variants
|
|
2569
|
-
.map((variant) => (typeof variant.type === 'string' ? variant.type.trim() : ''))
|
|
2570
|
-
.filter((type) => !!type && type !== 'null')));
|
|
5035
|
+
const variants = this.extractUnionVariants(prop, rootSchema);
|
|
5036
|
+
const nonNullTypes = Array.from(new Set(variants.flatMap((variant) => this.extractSchemaNonNullTypes(variant))));
|
|
2571
5037
|
if (nonNullTypes.length === 1) {
|
|
2572
5038
|
return nonNullTypes[0];
|
|
2573
5039
|
}
|
|
2574
5040
|
// Compatibilidade para schemas de range publicados como oneOf(array|object).
|
|
2575
5041
|
const controlToken = String(ui?.controlType || '').trim().toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
2576
|
-
const isRangeControl = [
|
|
5042
|
+
const isRangeControl = [
|
|
5043
|
+
'daterange',
|
|
5044
|
+
'datetimerange',
|
|
5045
|
+
'rangeslider',
|
|
5046
|
+
'pricerange',
|
|
5047
|
+
'inlinerange',
|
|
5048
|
+
'inlinecurrencyrange',
|
|
5049
|
+
'inlinedaterange',
|
|
5050
|
+
'inlineperiodrange',
|
|
5051
|
+
'inlineyearrange',
|
|
5052
|
+
'inlinemonthrange',
|
|
5053
|
+
'inlinetimerange',
|
|
5054
|
+
'inlinedistanceradius',
|
|
5055
|
+
'inlinescorepriority',
|
|
5056
|
+
].includes(controlToken);
|
|
2577
5057
|
if (isRangeControl && nonNullTypes.includes('array')) {
|
|
2578
5058
|
return 'array';
|
|
2579
5059
|
}
|
|
@@ -2589,6 +5069,10 @@ class SchemaNormalizationKernel {
|
|
|
2589
5069
|
function normalizeSchemaFields(schema) {
|
|
2590
5070
|
return new SchemaNormalizationKernel().normalizeSchema(schema);
|
|
2591
5071
|
}
|
|
5072
|
+
/** Extracts root-level `x-ui` metadata blocks (`formLayout`, `progression`, `timeline`, `schedule`, `hierarchy`, `calculationMemory`). */
|
|
5073
|
+
function extractSchemaRootUiMetadata(schema) {
|
|
5074
|
+
return new SchemaNormalizationKernel().extractRootUiMetadata(schema);
|
|
5075
|
+
}
|
|
2592
5076
|
|
|
2593
5077
|
function isObject(value) {
|
|
2594
5078
|
return value != null && typeof value === 'object' && !Array.isArray(value);
|
|
@@ -2667,8 +5151,19 @@ function clone(v) {
|
|
|
2667
5151
|
|
|
2668
5152
|
function buildBaseColumnFromDef(def) {
|
|
2669
5153
|
const type = resolveColumnTypeFromFieldDefinition(def);
|
|
2670
|
-
const format =
|
|
2671
|
-
const
|
|
5154
|
+
const format = resolveFormatFromFieldDefinition(def, type);
|
|
5155
|
+
const valueMapping = resolveSchemaValueMappingFromFieldDefinition(def);
|
|
5156
|
+
const renderer = resolveRendererFromFieldDefinition(def);
|
|
5157
|
+
const conditionalRenderers = resolveConditionalRenderersFromFieldDefinition(def);
|
|
5158
|
+
const quickView = resolveQuickViewFromFieldDefinition(def);
|
|
5159
|
+
const isAvatar = renderer?.type === 'avatar';
|
|
5160
|
+
const explicitWidth = firstNonEmptyString(def.width);
|
|
5161
|
+
const resolvedOrder = typeof def.tableOrder === 'number'
|
|
5162
|
+
? def.tableOrder
|
|
5163
|
+
: typeof def.order === 'number'
|
|
5164
|
+
? def.order
|
|
5165
|
+
: undefined;
|
|
5166
|
+
const sticky = def.pinned ?? def.sticky;
|
|
2672
5167
|
return {
|
|
2673
5168
|
field: def.name,
|
|
2674
5169
|
header: def.label || def.name,
|
|
@@ -2677,9 +5172,15 @@ function buildBaseColumnFromDef(def) {
|
|
|
2677
5172
|
sortable: def.sortable !== false,
|
|
2678
5173
|
filterable: def.filterable === true,
|
|
2679
5174
|
resizable: true,
|
|
2680
|
-
|
|
5175
|
+
...(sticky !== undefined ? { sticky } : {}),
|
|
5176
|
+
order: resolvedOrder,
|
|
5177
|
+
...(explicitWidth ? { width: explicitWidth } : isAvatar ? { width: '56px' } : {}),
|
|
5178
|
+
...(isAvatar ? { align: 'center' } : {}),
|
|
2681
5179
|
...(format ? { format } : {}),
|
|
5180
|
+
...(valueMapping ? { valueMapping } : {}),
|
|
2682
5181
|
...(renderer ? { renderer } : {}),
|
|
5182
|
+
...(conditionalRenderers?.length ? { conditionalRenderers } : {}),
|
|
5183
|
+
...(quickView ? { quickView } : {}),
|
|
2683
5184
|
};
|
|
2684
5185
|
}
|
|
2685
5186
|
function applyLocalCustomizations(baseCol, localCol) {
|
|
@@ -2706,18 +5207,40 @@ function applyLocalCustomizations(baseCol, localCol) {
|
|
|
2706
5207
|
result.headerStyle = localCol.headerStyle ?? baseCol.headerStyle;
|
|
2707
5208
|
result.cssClass = localCol.cssClass ?? baseCol.cssClass;
|
|
2708
5209
|
result.headerCssClass = localCol.headerCssClass ?? baseCol.headerCssClass;
|
|
5210
|
+
const resolvedQuickView = reconcileFieldQuickViewBinding(baseCol.quickView, localCol.quickView);
|
|
5211
|
+
if (resolvedQuickView) {
|
|
5212
|
+
result.quickView = resolvedQuickView;
|
|
5213
|
+
}
|
|
5214
|
+
else {
|
|
5215
|
+
delete result.quickView;
|
|
5216
|
+
}
|
|
2709
5217
|
// If server type changed, drop potentially incompatible formatting/renderers.
|
|
2710
5218
|
if (!typeChanged) {
|
|
2711
5219
|
result.format = localCol.format ?? baseCol.format;
|
|
2712
5220
|
result.valueMapping = localCol.valueMapping ?? baseCol.valueMapping;
|
|
2713
|
-
result.renderer = localCol.renderer ?? baseCol.renderer;
|
|
5221
|
+
result.renderer = normalizeColumnRendererQuickView(localCol.renderer ?? baseCol.renderer);
|
|
5222
|
+
const resolvedConditionalRenderers = localCol.conditionalRenderers?.length
|
|
5223
|
+
? localCol.conditionalRenderers
|
|
5224
|
+
: baseCol.conditionalRenderers;
|
|
5225
|
+
if (resolvedConditionalRenderers?.length) {
|
|
5226
|
+
result.conditionalRenderers = resolvedConditionalRenderers;
|
|
5227
|
+
}
|
|
5228
|
+
else {
|
|
5229
|
+
delete result.conditionalRenderers;
|
|
5230
|
+
}
|
|
2714
5231
|
}
|
|
2715
5232
|
else {
|
|
2716
5233
|
// Drop local presentation that may be incompatible with the new server type,
|
|
2717
5234
|
// but keep canonical server presentation for the resolved type.
|
|
2718
5235
|
result.format = baseCol.format;
|
|
2719
5236
|
result.valueMapping = baseCol.valueMapping;
|
|
2720
|
-
result.renderer =
|
|
5237
|
+
result.renderer = normalizeColumnRendererQuickView(baseCol.renderer);
|
|
5238
|
+
if (baseCol.conditionalRenderers?.length) {
|
|
5239
|
+
result.conditionalRenderers = baseCol.conditionalRenderers;
|
|
5240
|
+
}
|
|
5241
|
+
else {
|
|
5242
|
+
delete result.conditionalRenderers;
|
|
5243
|
+
}
|
|
2721
5244
|
}
|
|
2722
5245
|
return result;
|
|
2723
5246
|
}
|
|
@@ -2729,6 +5252,10 @@ function reconcileTableConfig(layout, serverDefs) {
|
|
|
2729
5252
|
const localCol = localByField.get(base.field);
|
|
2730
5253
|
return localCol ? applyLocalCustomizations(base, localCol) : base;
|
|
2731
5254
|
});
|
|
5255
|
+
if (serverDefs.some((d) => typeof d.tableOrder === 'number')) {
|
|
5256
|
+
mergedColumns.sort((a, b) => (a.order ?? Number.MAX_SAFE_INTEGER) -
|
|
5257
|
+
(b.order ?? Number.MAX_SAFE_INTEGER));
|
|
5258
|
+
}
|
|
2732
5259
|
const serverFields = new Set(serverDefs.map((d) => d.name));
|
|
2733
5260
|
const orphans = (local.columns || []).filter((c) => !serverFields.has(c.field));
|
|
2734
5261
|
const hiddenOrphans = orphans.map((c) => ({ ...c, visible: false }));
|
|
@@ -2773,8 +5300,11 @@ function resolveSemanticColumnTypeFromFieldDefinition(def) {
|
|
|
2773
5300
|
return 'string';
|
|
2774
5301
|
if (numericFormat === 'currency' || controlType === 'currency')
|
|
2775
5302
|
return 'currency';
|
|
2776
|
-
if (numericFormat === 'percent' ||
|
|
5303
|
+
if (numericFormat === 'percent' ||
|
|
5304
|
+
numericFormat === 'percentage' ||
|
|
5305
|
+
numericFormat === 'fraction') {
|
|
2777
5306
|
return 'percentage';
|
|
5307
|
+
}
|
|
2778
5308
|
if (numericFormat === 'date' || numericFormat === 'datetime')
|
|
2779
5309
|
return 'date';
|
|
2780
5310
|
if (controlType === 'numerictextbox' || controlType === 'inlinenumber')
|
|
@@ -2831,25 +5361,320 @@ function resolveTextMaskFormat(value) {
|
|
|
2831
5361
|
const hasInvalidMaskLetters = /[A-WYZa-wyz]/.test(format);
|
|
2832
5362
|
return hasMaskTokens && !hasInvalidMaskLetters ? format : undefined;
|
|
2833
5363
|
}
|
|
2834
|
-
function
|
|
2835
|
-
|
|
5364
|
+
function resolveFormatFromFieldDefinition(def, type) {
|
|
5365
|
+
if (type === 'string') {
|
|
5366
|
+
return resolveTextMaskFormatFromFieldDefinition(def);
|
|
5367
|
+
}
|
|
5368
|
+
if (type === 'currency') {
|
|
5369
|
+
return resolveSchemaCurrencyFormatFromFieldDefinition(def);
|
|
5370
|
+
}
|
|
5371
|
+
if (type === 'date') {
|
|
5372
|
+
return (firstNonEmptyString(def.displayFormat) ??
|
|
5373
|
+
firstNonEmptyString(def.extraProperties?.displayFormat));
|
|
5374
|
+
}
|
|
5375
|
+
if (type === 'boolean') {
|
|
5376
|
+
return resolveSchemaBooleanFormatFromFieldDefinition(def);
|
|
5377
|
+
}
|
|
5378
|
+
if (type === 'number') {
|
|
5379
|
+
const schemaDataType = normalizePresentationToken(def.type);
|
|
5380
|
+
const schemaFormat = normalizePresentationToken(def.format);
|
|
5381
|
+
const numericFormat = normalizePresentationToken(def.numericFormat ?? def.extraProperties?.numericFormat);
|
|
5382
|
+
if (schemaDataType === 'integer' ||
|
|
5383
|
+
schemaFormat === 'integer' ||
|
|
5384
|
+
schemaFormat === 'int32' ||
|
|
5385
|
+
schemaFormat === 'int64' ||
|
|
5386
|
+
numericFormat === 'integer' ||
|
|
5387
|
+
numericFormat === 'int32' ||
|
|
5388
|
+
numericFormat === 'int64') {
|
|
5389
|
+
return '1.0-0';
|
|
5390
|
+
}
|
|
5391
|
+
if (numericFormat === 'auto') {
|
|
5392
|
+
return undefined;
|
|
5393
|
+
}
|
|
5394
|
+
const explicitDecimals = firstFiniteNumber(def.decimalPlaces) ??
|
|
5395
|
+
firstFiniteNumber(def.extraProperties?.decimalPlaces);
|
|
5396
|
+
if (explicitDecimals !== undefined && explicitDecimals >= 0) {
|
|
5397
|
+
const decimals = Math.trunc(explicitDecimals);
|
|
5398
|
+
return `1.${decimals}-${decimals}`;
|
|
5399
|
+
}
|
|
5400
|
+
}
|
|
5401
|
+
return undefined;
|
|
5402
|
+
}
|
|
5403
|
+
function resolveSchemaCurrencyFormatFromFieldDefinition(def) {
|
|
5404
|
+
const currency = firstNonEmptyString(def.currency) ??
|
|
5405
|
+
firstNonEmptyString(def.extraProperties?.currency) ??
|
|
5406
|
+
'BRL';
|
|
5407
|
+
const decimalPlaces = firstFiniteNumber(def.decimalPlaces) ??
|
|
5408
|
+
firstFiniteNumber(def.extraProperties?.decimalPlaces) ??
|
|
5409
|
+
2;
|
|
5410
|
+
return `${currency}|symbol|${decimalPlaces}`;
|
|
5411
|
+
}
|
|
5412
|
+
function resolveSchemaBooleanFormatFromFieldDefinition(def) {
|
|
5413
|
+
const explicit = firstNonEmptyString(def.booleanFormat) ??
|
|
5414
|
+
firstNonEmptyString(def.extraProperties?.booleanFormat);
|
|
5415
|
+
if (explicit)
|
|
5416
|
+
return explicit;
|
|
5417
|
+
const trueLabel = firstNonEmptyString(def.trueLabel) ??
|
|
5418
|
+
firstNonEmptyString(def.labelTrue) ??
|
|
5419
|
+
firstNonEmptyString(def.presentation?.labelTrue) ??
|
|
5420
|
+
firstNonEmptyString(def.extraProperties?.trueLabel) ??
|
|
5421
|
+
firstNonEmptyString(def.extraProperties?.labelTrue);
|
|
5422
|
+
const falseLabel = firstNonEmptyString(def.falseLabel) ??
|
|
5423
|
+
firstNonEmptyString(def.labelFalse) ??
|
|
5424
|
+
firstNonEmptyString(def.presentation?.labelFalse) ??
|
|
5425
|
+
firstNonEmptyString(def.extraProperties?.falseLabel) ??
|
|
5426
|
+
firstNonEmptyString(def.extraProperties?.labelFalse);
|
|
5427
|
+
if (trueLabel || falseLabel) {
|
|
5428
|
+
const effectiveTrue = trueLabel || 'Sim';
|
|
5429
|
+
const effectiveFalse = falseLabel || 'Não';
|
|
5430
|
+
const tNorm = normalizePresentationToken(effectiveTrue);
|
|
5431
|
+
const fNorm = normalizePresentationToken(effectiveFalse);
|
|
5432
|
+
if (tNorm === 'ativo' && fNorm === 'inativo')
|
|
5433
|
+
return 'active-inactive';
|
|
5434
|
+
if (tNorm === 'sim' && (fNorm === 'nao' || fNorm === 'não'))
|
|
5435
|
+
return 'yes-no';
|
|
5436
|
+
return `custom|${effectiveTrue}|${effectiveFalse}`;
|
|
5437
|
+
}
|
|
5438
|
+
const name = normalizePresentationToken(def.name);
|
|
5439
|
+
if (name === 'ativo' || name === 'active' || name.endsWith('ativo')) {
|
|
5440
|
+
return 'active-inactive';
|
|
5441
|
+
}
|
|
5442
|
+
return undefined;
|
|
5443
|
+
}
|
|
5444
|
+
function resolveSchemaValueMappingFromFieldDefinition(def) {
|
|
5445
|
+
const explicit = def.valueMapping;
|
|
5446
|
+
if (explicit && typeof explicit === 'object' && !Array.isArray(explicit)) {
|
|
5447
|
+
const normalized = Object.entries(explicit).reduce((acc, [key, value]) => {
|
|
5448
|
+
if (key && typeof value === 'string' && value.trim()) {
|
|
5449
|
+
acc[key] = value.trim();
|
|
5450
|
+
}
|
|
5451
|
+
return acc;
|
|
5452
|
+
}, {});
|
|
5453
|
+
if (Object.keys(normalized).length > 0)
|
|
5454
|
+
return normalized;
|
|
5455
|
+
}
|
|
5456
|
+
const options = Array.isArray(def.options) ? def.options : [];
|
|
5457
|
+
if (options.length > 0) {
|
|
5458
|
+
const valueKey = firstNonEmptyString(def.optionValueKey) ?? 'key';
|
|
5459
|
+
const labelKey = firstNonEmptyString(def.optionLabelKey) ?? 'value';
|
|
5460
|
+
const mapping = options.reduce((acc, option) => {
|
|
5461
|
+
if (!option || typeof option !== 'object')
|
|
5462
|
+
return acc;
|
|
5463
|
+
const record = option;
|
|
5464
|
+
const value = record[valueKey] ?? record.key ?? record.id ?? record.value;
|
|
5465
|
+
const label = record[labelKey] ?? record.label ?? record.value ?? record.name;
|
|
5466
|
+
if (value !== undefined && value !== null && label !== undefined && label !== null) {
|
|
5467
|
+
acc[String(value)] = String(label);
|
|
5468
|
+
}
|
|
5469
|
+
return acc;
|
|
5470
|
+
}, {});
|
|
5471
|
+
if (Object.keys(mapping).length > 0)
|
|
5472
|
+
return mapping;
|
|
5473
|
+
}
|
|
5474
|
+
const enumValues = Array.isArray(def.enumValues)
|
|
5475
|
+
? def.enumValues
|
|
5476
|
+
.map((v) => (v != null ? String(v).trim() : ''))
|
|
5477
|
+
.filter((v) => v.length > 0)
|
|
5478
|
+
: [];
|
|
5479
|
+
if (enumValues.length > 0) {
|
|
5480
|
+
return enumValues.reduce((acc, value) => {
|
|
5481
|
+
acc[value] = humanizeSchemaEnumValue(value);
|
|
5482
|
+
return acc;
|
|
5483
|
+
}, {});
|
|
5484
|
+
}
|
|
5485
|
+
return undefined;
|
|
5486
|
+
}
|
|
5487
|
+
function humanizeSchemaEnumValue(value) {
|
|
5488
|
+
return value
|
|
5489
|
+
.toLowerCase()
|
|
5490
|
+
.split(/[_\-\s]+/)
|
|
5491
|
+
.filter(Boolean)
|
|
5492
|
+
.map((part, index) => (index === 0 ? `${part.charAt(0).toUpperCase()}${part.slice(1)}` : part))
|
|
5493
|
+
.join(' ');
|
|
5494
|
+
}
|
|
5495
|
+
function resolveQuickViewFromFieldDefinition(def) {
|
|
5496
|
+
return (resolveFieldQuickViewBinding(def) ??
|
|
5497
|
+
normalizeResourceQuickViewBinding(def['extraProperties'] && typeof def['extraProperties'] === 'object' ? def['extraProperties']['quickView'] : undefined) ??
|
|
5498
|
+
undefined);
|
|
5499
|
+
}
|
|
5500
|
+
function normalizeColumnRendererQuickView(renderer) {
|
|
5501
|
+
if (!renderer || typeof renderer !== 'object') {
|
|
5502
|
+
return renderer;
|
|
5503
|
+
}
|
|
5504
|
+
const next = { ...renderer };
|
|
5505
|
+
if (next.link && typeof next.link === 'object') {
|
|
5506
|
+
const qv = normalizeResourceQuickViewBinding(next.link.quickView);
|
|
5507
|
+
next.link = { ...next.link };
|
|
5508
|
+
if (qv) {
|
|
5509
|
+
next.link.quickView = qv;
|
|
5510
|
+
}
|
|
5511
|
+
else {
|
|
5512
|
+
delete next.link.quickView;
|
|
5513
|
+
}
|
|
5514
|
+
}
|
|
5515
|
+
if (next.badge && typeof next.badge === 'object') {
|
|
5516
|
+
const qv = normalizeResourceQuickViewBinding(next.badge.quickView);
|
|
5517
|
+
next.badge = { ...next.badge };
|
|
5518
|
+
if (qv) {
|
|
5519
|
+
next.badge.quickView = qv;
|
|
5520
|
+
}
|
|
5521
|
+
else {
|
|
5522
|
+
delete next.badge.quickView;
|
|
5523
|
+
}
|
|
5524
|
+
}
|
|
5525
|
+
if (next.chip && typeof next.chip === 'object') {
|
|
5526
|
+
const qv = normalizeResourceQuickViewBinding(next.chip.quickView);
|
|
5527
|
+
next.chip = { ...next.chip };
|
|
5528
|
+
if (qv) {
|
|
5529
|
+
next.chip.quickView = qv;
|
|
5530
|
+
}
|
|
5531
|
+
else {
|
|
5532
|
+
delete next.chip.quickView;
|
|
5533
|
+
}
|
|
5534
|
+
}
|
|
5535
|
+
if (next.icon && typeof next.icon === 'object') {
|
|
5536
|
+
const qv = normalizeResourceQuickViewBinding(next.icon.quickView);
|
|
5537
|
+
next.icon = { ...next.icon };
|
|
5538
|
+
if (qv) {
|
|
5539
|
+
next.icon.quickView = qv;
|
|
5540
|
+
}
|
|
5541
|
+
else {
|
|
5542
|
+
delete next.icon.quickView;
|
|
5543
|
+
}
|
|
5544
|
+
}
|
|
5545
|
+
if (next.compose && typeof next.compose === 'object' && Array.isArray(next.compose.items)) {
|
|
5546
|
+
next.compose = {
|
|
5547
|
+
...next.compose,
|
|
5548
|
+
items: next.compose.items.map((item) => {
|
|
5549
|
+
if (!item || typeof item !== 'object')
|
|
5550
|
+
return item;
|
|
5551
|
+
if (item.type === 'value') {
|
|
5552
|
+
const qv = normalizeResourceQuickViewBinding(item.quickView);
|
|
5553
|
+
const cloned = { ...item };
|
|
5554
|
+
if (qv)
|
|
5555
|
+
cloned.quickView = qv;
|
|
5556
|
+
else
|
|
5557
|
+
delete cloned.quickView;
|
|
5558
|
+
return cloned;
|
|
5559
|
+
}
|
|
5560
|
+
if (item.type === 'link' && item.link) {
|
|
5561
|
+
const qv = normalizeResourceQuickViewBinding(item.link.quickView);
|
|
5562
|
+
const link = { ...item.link };
|
|
5563
|
+
if (qv)
|
|
5564
|
+
link.quickView = qv;
|
|
5565
|
+
else
|
|
5566
|
+
delete link.quickView;
|
|
5567
|
+
return { ...item, link };
|
|
5568
|
+
}
|
|
5569
|
+
if (item.type === 'badge' && item.badge) {
|
|
5570
|
+
const qv = normalizeResourceQuickViewBinding(item.badge.quickView);
|
|
5571
|
+
const badge = { ...item.badge };
|
|
5572
|
+
if (qv)
|
|
5573
|
+
badge.quickView = qv;
|
|
5574
|
+
else
|
|
5575
|
+
delete badge.quickView;
|
|
5576
|
+
return { ...item, badge };
|
|
5577
|
+
}
|
|
5578
|
+
if (item.type === 'chip' && item.chip) {
|
|
5579
|
+
const qv = normalizeResourceQuickViewBinding(item.chip.quickView);
|
|
5580
|
+
const chip = { ...item.chip };
|
|
5581
|
+
if (qv)
|
|
5582
|
+
chip.quickView = qv;
|
|
5583
|
+
else
|
|
5584
|
+
delete chip.quickView;
|
|
5585
|
+
return { ...item, chip };
|
|
5586
|
+
}
|
|
5587
|
+
if (item.type === 'icon' && item.icon) {
|
|
5588
|
+
const qv = normalizeResourceQuickViewBinding(item.icon.quickView);
|
|
5589
|
+
const icon = { ...item.icon };
|
|
5590
|
+
if (qv)
|
|
5591
|
+
icon.quickView = qv;
|
|
5592
|
+
else
|
|
5593
|
+
delete icon.quickView;
|
|
5594
|
+
return { ...item, icon };
|
|
5595
|
+
}
|
|
5596
|
+
return item;
|
|
5597
|
+
}),
|
|
5598
|
+
};
|
|
5599
|
+
}
|
|
5600
|
+
return next;
|
|
5601
|
+
}
|
|
5602
|
+
function resolveRendererFromFieldDefinition(def) {
|
|
5603
|
+
const presentationRenderer = resolveRendererFromFieldPresentation(def);
|
|
5604
|
+
if (presentationRenderer)
|
|
5605
|
+
return presentationRenderer;
|
|
5606
|
+
if (isPraxisPresentationVisualizationTableSafe(def.microVisualization)) {
|
|
5607
|
+
return {
|
|
5608
|
+
type: 'microVisualization',
|
|
5609
|
+
microVisualization: {
|
|
5610
|
+
visualization: def.microVisualization,
|
|
5611
|
+
},
|
|
5612
|
+
};
|
|
5613
|
+
}
|
|
5614
|
+
if (normalizePresentationToken(def.controlType) === 'avatar') {
|
|
5615
|
+
const initialsField = firstNonEmptyString(def.initialsField) ??
|
|
5616
|
+
firstNonEmptyString(def.extraProperties?.initialsField) ??
|
|
5617
|
+
'nomeCompleto';
|
|
5618
|
+
return {
|
|
5619
|
+
type: 'avatar',
|
|
5620
|
+
avatar: {
|
|
5621
|
+
srcField: def.name,
|
|
5622
|
+
initialsField,
|
|
5623
|
+
shape: 'circle',
|
|
5624
|
+
size: 32,
|
|
5625
|
+
},
|
|
5626
|
+
};
|
|
5627
|
+
}
|
|
5628
|
+
return undefined;
|
|
5629
|
+
}
|
|
5630
|
+
function resolveSchemaConditionalRenderers(def, options) {
|
|
5631
|
+
return resolveConditionalRenderersFromFieldDefinition(def, options);
|
|
5632
|
+
}
|
|
5633
|
+
function buildSchemaSemanticColumnRenderer(def, presentationOverride, options) {
|
|
5634
|
+
return resolveRendererFromFieldPresentation(def, presentationOverride, options);
|
|
5635
|
+
}
|
|
5636
|
+
function resolveRendererFromFieldPresentation(def, presentationOverride, options) {
|
|
5637
|
+
const presentation = presentationOverride ?? def.presentation;
|
|
2836
5638
|
if (!presentation || typeof presentation !== 'object')
|
|
2837
5639
|
return undefined;
|
|
5640
|
+
if (presentation.presenter === 'microVisualization' &&
|
|
5641
|
+
isPraxisPresentationVisualizationTableSafe(presentation.visualization)) {
|
|
5642
|
+
return {
|
|
5643
|
+
type: 'microVisualization',
|
|
5644
|
+
microVisualization: {
|
|
5645
|
+
visualization: presentation.visualization,
|
|
5646
|
+
},
|
|
5647
|
+
};
|
|
5648
|
+
}
|
|
2838
5649
|
const presenter = normalizePresentationToken(presentation.presenter ?? presentation.variant);
|
|
2839
5650
|
const color = resolveSemanticPresentationColor(presentation.tone);
|
|
2840
5651
|
const variant = resolveSemanticPresentationVariant(presentation.appearance);
|
|
2841
5652
|
const icon = firstNonEmptyString(presentation.icon);
|
|
2842
5653
|
const tooltipText = firstNonEmptyString(presentation.tooltip);
|
|
2843
5654
|
const tooltip = tooltipText ? { text: tooltipText } : undefined;
|
|
5655
|
+
const fixedText = firstNonEmptyString(presentation.label);
|
|
5656
|
+
const affixes = resolveSemanticPresentationAffixes(presentation);
|
|
5657
|
+
const includeUndefinedFields = options?.includeUndefinedBadgeChipFields === true;
|
|
5658
|
+
const includeUndefinedText = options?.includeUndefinedBadgeChipText === true;
|
|
5659
|
+
const allowTextPresenterAsIconValue = options?.allowTextPresenterAsIconValue !== false;
|
|
2844
5660
|
if (presenter === 'chip') {
|
|
2845
5661
|
return {
|
|
2846
5662
|
type: 'chip',
|
|
2847
5663
|
chip: {
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
5664
|
+
...(includeUndefinedText
|
|
5665
|
+
? { text: fixedText }
|
|
5666
|
+
: fixedText !== undefined
|
|
5667
|
+
? { text: fixedText }
|
|
5668
|
+
: {}),
|
|
5669
|
+
textField: fixedText ? undefined : def.name,
|
|
5670
|
+
...(includeUndefinedFields ? { color, icon, variant, tooltip } : {
|
|
5671
|
+
...(color ? { color } : {}),
|
|
5672
|
+
...(variant ? { variant } : {}),
|
|
5673
|
+
...(icon ? { icon } : {}),
|
|
5674
|
+
...(tooltip ? { tooltip } : {}),
|
|
5675
|
+
}),
|
|
5676
|
+
...(affixes.prefix ? { prefix: affixes.prefix } : {}),
|
|
5677
|
+
...(affixes.suffix ? { suffix: affixes.suffix } : {}),
|
|
2853
5678
|
},
|
|
2854
5679
|
};
|
|
2855
5680
|
}
|
|
@@ -2857,58 +5682,176 @@ function resolveRendererFromFieldPresentation(def) {
|
|
|
2857
5682
|
return {
|
|
2858
5683
|
type: 'badge',
|
|
2859
5684
|
badge: {
|
|
2860
|
-
|
|
5685
|
+
...(includeUndefinedText
|
|
5686
|
+
? { text: fixedText }
|
|
5687
|
+
: fixedText !== undefined
|
|
5688
|
+
? { text: fixedText }
|
|
5689
|
+
: {}),
|
|
5690
|
+
textField: fixedText ? undefined : def.name,
|
|
5691
|
+
...(includeUndefinedFields ? { color, icon, variant, tooltip } : {
|
|
5692
|
+
...(color ? { color } : {}),
|
|
5693
|
+
...(variant ? { variant } : {}),
|
|
5694
|
+
...(icon ? { icon } : {}),
|
|
5695
|
+
...(tooltip ? { tooltip } : {}),
|
|
5696
|
+
}),
|
|
5697
|
+
...(affixes.prefix ? { prefix: affixes.prefix } : {}),
|
|
5698
|
+
...(affixes.suffix ? { suffix: affixes.suffix } : {}),
|
|
5699
|
+
},
|
|
5700
|
+
};
|
|
5701
|
+
}
|
|
5702
|
+
if (presenter === 'progress') {
|
|
5703
|
+
const valueExpr = `= row.${def.name.replace(/\./g, '?.')}`;
|
|
5704
|
+
return {
|
|
5705
|
+
type: 'progress',
|
|
5706
|
+
progress: {
|
|
5707
|
+
valueExpr,
|
|
5708
|
+
showLabel: true,
|
|
5709
|
+
...(color ? { color } : {}),
|
|
5710
|
+
},
|
|
5711
|
+
};
|
|
5712
|
+
}
|
|
5713
|
+
if (presenter === 'rating') {
|
|
5714
|
+
const valueExpr = `= row.${def.name.replace(/\./g, '?.')}`;
|
|
5715
|
+
return {
|
|
5716
|
+
type: 'rating',
|
|
5717
|
+
rating: {
|
|
5718
|
+
valueExpr,
|
|
5719
|
+
max: 5,
|
|
2861
5720
|
...(color ? { color } : {}),
|
|
2862
|
-
...(variant ? { variant } : {}),
|
|
2863
|
-
...(icon ? { icon } : {}),
|
|
2864
|
-
...(tooltip ? { tooltip } : {}),
|
|
2865
5721
|
},
|
|
2866
5722
|
};
|
|
2867
5723
|
}
|
|
2868
|
-
if (presenter === 'iconvalue'
|
|
5724
|
+
if (presenter === 'iconvalue' ||
|
|
5725
|
+
(allowTextPresenterAsIconValue && (presenter === 'text' || !presenter))) {
|
|
2869
5726
|
const rendererIcon = icon || firstNonEmptyString(def.icon);
|
|
2870
|
-
const affixes = resolveSemanticPresentationAffixes(presentation);
|
|
2871
5727
|
const hasAffixes = !!(affixes.prefix || affixes.suffix);
|
|
2872
5728
|
if (!rendererIcon && !hasAffixes)
|
|
2873
5729
|
return undefined;
|
|
5730
|
+
if (affixes.prefix || affixes.suffix || tooltipText) {
|
|
5731
|
+
return {
|
|
5732
|
+
type: 'icon',
|
|
5733
|
+
icon: {
|
|
5734
|
+
...(!hasAffixes && rendererIcon ? { name: rendererIcon } : {}),
|
|
5735
|
+
textField: def.name,
|
|
5736
|
+
...(color ? { color } : {}),
|
|
5737
|
+
...(tooltipText ? { ariaLabel: tooltipText } : {}),
|
|
5738
|
+
...(tooltip ? { tooltip } : {}),
|
|
5739
|
+
...affixes,
|
|
5740
|
+
},
|
|
5741
|
+
};
|
|
5742
|
+
}
|
|
5743
|
+
if (!rendererIcon)
|
|
5744
|
+
return undefined;
|
|
2874
5745
|
return {
|
|
2875
|
-
type: '
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
5746
|
+
type: 'compose',
|
|
5747
|
+
compose: {
|
|
5748
|
+
items: [
|
|
5749
|
+
{
|
|
5750
|
+
type: 'icon',
|
|
5751
|
+
icon: {
|
|
5752
|
+
name: rendererIcon,
|
|
5753
|
+
...(color ? { color } : {}),
|
|
5754
|
+
...(def.label ? { ariaLabel: def.label } : {}),
|
|
5755
|
+
},
|
|
5756
|
+
},
|
|
5757
|
+
{
|
|
5758
|
+
type: 'value',
|
|
5759
|
+
field: def.name,
|
|
5760
|
+
},
|
|
5761
|
+
],
|
|
5762
|
+
layout: {
|
|
5763
|
+
direction: 'row',
|
|
5764
|
+
gap: 6,
|
|
5765
|
+
align: 'center',
|
|
5766
|
+
},
|
|
2881
5767
|
},
|
|
2882
5768
|
};
|
|
2883
5769
|
}
|
|
2884
5770
|
return undefined;
|
|
2885
5771
|
}
|
|
5772
|
+
function resolveConditionalRenderersFromFieldDefinition(def, options) {
|
|
5773
|
+
const rules = def.presentationRules;
|
|
5774
|
+
if (!Array.isArray(rules) || rules.length === 0)
|
|
5775
|
+
return undefined;
|
|
5776
|
+
const basePresentation = def.presentation && typeof def.presentation === 'object' ? def.presentation : {};
|
|
5777
|
+
const basePresenter = basePresentation.presenter ?? basePresentation.variant;
|
|
5778
|
+
const out = [];
|
|
5779
|
+
rules.forEach((rule, index) => {
|
|
5780
|
+
if (!rule || typeof rule !== 'object' || rule.when === undefined)
|
|
5781
|
+
return;
|
|
5782
|
+
const effect = rule.set ?? rule.effect;
|
|
5783
|
+
if (!effect || typeof effect !== 'object')
|
|
5784
|
+
return;
|
|
5785
|
+
const resolvedPresenter = effect.presenter ?? effect.variant ?? basePresenter;
|
|
5786
|
+
const effectivePresentation = {
|
|
5787
|
+
...basePresentation,
|
|
5788
|
+
...effect,
|
|
5789
|
+
...(resolvedPresenter ? { presenter: resolvedPresenter } : {}),
|
|
5790
|
+
};
|
|
5791
|
+
const renderer = resolveRendererFromFieldPresentation(def, effectivePresentation, options);
|
|
5792
|
+
const tooltipText = firstNonEmptyString(effectivePresentation.tooltip);
|
|
5793
|
+
const tooltip = tooltipText ? { text: tooltipText } : undefined;
|
|
5794
|
+
if (!renderer && !tooltip)
|
|
5795
|
+
return;
|
|
5796
|
+
out.push({
|
|
5797
|
+
id: `schema-presentation-rule-${index}`,
|
|
5798
|
+
condition: rule.when,
|
|
5799
|
+
...(renderer ? { renderer } : {}),
|
|
5800
|
+
...(tooltip ? { tooltip } : {}),
|
|
5801
|
+
});
|
|
5802
|
+
});
|
|
5803
|
+
return out.length > 0 ? out : undefined;
|
|
5804
|
+
}
|
|
2886
5805
|
function resolveSemanticPresentationColor(tone) {
|
|
2887
5806
|
const normalized = normalizePresentationToken(tone);
|
|
2888
|
-
if (!normalized
|
|
5807
|
+
if (!normalized)
|
|
2889
5808
|
return undefined;
|
|
2890
|
-
|
|
5809
|
+
if (normalized === 'neutral' || normalized === 'muted')
|
|
5810
|
+
return 'basic';
|
|
5811
|
+
if (normalized === 'positive')
|
|
5812
|
+
return 'success';
|
|
5813
|
+
if (normalized === 'warning')
|
|
5814
|
+
return 'warning';
|
|
5815
|
+
if (normalized === 'danger' || normalized === 'critical' || normalized === 'negative') {
|
|
5816
|
+
return 'warn';
|
|
5817
|
+
}
|
|
5818
|
+
return normalized;
|
|
2891
5819
|
}
|
|
2892
5820
|
function resolveSemanticPresentationVariant(appearance) {
|
|
2893
5821
|
const normalized = normalizePresentationToken(appearance);
|
|
2894
|
-
return normalized === 'filled' ||
|
|
5822
|
+
return normalized === 'filled' ||
|
|
5823
|
+
normalized === 'outlined' ||
|
|
5824
|
+
normalized === 'soft' ||
|
|
5825
|
+
normalized === 'plain'
|
|
2895
5826
|
? normalized
|
|
2896
5827
|
: undefined;
|
|
2897
5828
|
}
|
|
2898
5829
|
function resolveSemanticPresentationAffixes(presentation) {
|
|
2899
|
-
const prefix =
|
|
2900
|
-
const suffix =
|
|
5830
|
+
const prefix = normalizeAffix(presentation.prefix);
|
|
5831
|
+
const suffix = normalizeAffix(presentation.suffix);
|
|
2901
5832
|
return {
|
|
2902
5833
|
...(prefix ? { prefix } : {}),
|
|
2903
5834
|
...(suffix ? { suffix } : {}),
|
|
2904
5835
|
};
|
|
2905
5836
|
}
|
|
5837
|
+
function normalizePresentationAffix(value) {
|
|
5838
|
+
return typeof value === 'string' && value.trim().length > 0 ? value : undefined;
|
|
5839
|
+
}
|
|
5840
|
+
function normalizeAffix(value) {
|
|
5841
|
+
return normalizePresentationAffix(value);
|
|
5842
|
+
}
|
|
2906
5843
|
function firstNonEmptyString(value) {
|
|
2907
5844
|
if (typeof value !== 'string')
|
|
2908
5845
|
return undefined;
|
|
2909
5846
|
const trimmed = value.trim();
|
|
2910
5847
|
return trimmed ? trimmed : undefined;
|
|
2911
5848
|
}
|
|
5849
|
+
function firstFiniteNumber(value) {
|
|
5850
|
+
if (value === null || value === undefined || value === '')
|
|
5851
|
+
return undefined;
|
|
5852
|
+
const numeric = typeof value === 'number' ? value : Number(value);
|
|
5853
|
+
return Number.isFinite(numeric) ? numeric : undefined;
|
|
5854
|
+
}
|
|
2912
5855
|
function normalizePresentationToken(value) {
|
|
2913
5856
|
return String(value ?? '').trim().toLowerCase().replace(/[\s_-]+/g, '');
|
|
2914
5857
|
}
|
|
@@ -2943,4 +5886,4 @@ function isTextualControlType(value) {
|
|
|
2943
5886
|
* Generated bundle index. Do not edit.
|
|
2944
5887
|
*/
|
|
2945
5888
|
|
|
2946
|
-
export { deepMerge, isPraxisPresentationVisualizationTableSafe, normalizeSchemaFields, resolveColumnTypeFromFieldDefinition, resolveTextMaskFormatFromFieldDefinition };
|
|
5889
|
+
export { buildSchemaSemanticColumnRenderer, deepMerge, isPraxisPresentationVisualizationTableSafe, normalizePresentationAffix, normalizeSchemaFields, resolveColumnTypeFromFieldDefinition, resolveSchemaConditionalRenderers, resolveTextMaskFormatFromFieldDefinition };
|