@praxisui/core 10.0.0-rc.62 → 10.0.0-rc.63
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 +17 -2
- package/ai/component-registry.json +2 -2
- package/fesm2022/praxisui-core-micro-visualization.mjs +194 -0
- package/fesm2022/praxisui-core-schema.mjs +240 -829
- package/fesm2022/praxisui-core.mjs +11017 -2992
- package/package.json +5 -1
- package/theming/_micro-visualization.scss +103 -0
- package/theming/index.scss +1 -0
- package/types/praxisui-core-micro-visualization.d.ts +66 -0
- package/types/praxisui-core-schema.d.ts +29 -3
- package/types/praxisui-core.d.ts +1101 -42
|
@@ -684,35 +684,6 @@ function isPraxisPresentationVisualizationTableSafe(value) {
|
|
|
684
684
|
const normalized = normalizePraxisPresentationVisualization(value);
|
|
685
685
|
return !!normalized && TABLE_SAFE_KINDS.has(normalized.kind);
|
|
686
686
|
}
|
|
687
|
-
function computeMicroSvgIdSuffix(visualization, options) {
|
|
688
|
-
const ptsKey = visualization.points
|
|
689
|
-
?.map((p) => `${p.label ?? ''}:${p.value}:${p.tone ?? ''}`)
|
|
690
|
-
.join(',') ?? '';
|
|
691
|
-
const seed = [
|
|
692
|
-
options.idPrefix ?? '',
|
|
693
|
-
visualization.kind,
|
|
694
|
-
visualization.surface ?? '',
|
|
695
|
-
visualization.tone ?? '',
|
|
696
|
-
String(visualization.value ?? ''),
|
|
697
|
-
String(visualization.total ?? ''),
|
|
698
|
-
String(visualization.target ?? ''),
|
|
699
|
-
visualization.fallbackText,
|
|
700
|
-
visualization.title ?? '',
|
|
701
|
-
ptsKey,
|
|
702
|
-
].join('|');
|
|
703
|
-
let hash = 0x811c9dc5;
|
|
704
|
-
for (let i = 0; i < seed.length; i++) {
|
|
705
|
-
hash ^= seed.charCodeAt(i);
|
|
706
|
-
hash = Math.imul(hash, 0x01000193);
|
|
707
|
-
}
|
|
708
|
-
return (hash >>> 0).toString(36);
|
|
709
|
-
}
|
|
710
|
-
function resolveTargetReferenceLabel(visualization, options) {
|
|
711
|
-
if (visualization.targetLabel) {
|
|
712
|
-
return visualization.targetLabel;
|
|
713
|
-
}
|
|
714
|
-
return options.locale?.toLowerCase().startsWith('pt') ? 'Meta' : 'Target';
|
|
715
|
-
}
|
|
716
687
|
/**
|
|
717
688
|
* Returns a luminous 3-stop directional color ramp (`[highlight, mid, deep]`)
|
|
718
689
|
* for radial arcs, sector dials, and precision micro-visualizations.
|
|
@@ -733,275 +704,6 @@ function getPraxisMicroToneGradientStops(tone) {
|
|
|
733
704
|
return ['#cbd5e1', '#64748b', '#334155'];
|
|
734
705
|
}
|
|
735
706
|
}
|
|
736
|
-
function renderPraxisPresentationVisualizationHtml(value, options = {}) {
|
|
737
|
-
const visualization = normalizePraxisPresentationVisualization(value);
|
|
738
|
-
if (!visualization) {
|
|
739
|
-
return '';
|
|
740
|
-
}
|
|
741
|
-
switch (visualization.kind) {
|
|
742
|
-
case 'comparison':
|
|
743
|
-
return renderComparisonVisualizationHtml(visualization, options);
|
|
744
|
-
case 'stackedBar':
|
|
745
|
-
return renderStackedBarVisualizationHtml(visualization, options);
|
|
746
|
-
case 'bullet':
|
|
747
|
-
return renderBulletVisualizationHtml(visualization, options);
|
|
748
|
-
case 'delta':
|
|
749
|
-
return renderDeltaVisualizationHtml(visualization, options);
|
|
750
|
-
case 'radial':
|
|
751
|
-
return renderRadialVisualizationHtml(visualization, options);
|
|
752
|
-
case 'harveyBall':
|
|
753
|
-
return renderHarveyBallVisualizationHtml(visualization, options);
|
|
754
|
-
case 'line':
|
|
755
|
-
return renderLineVisualizationHtml(visualization, options);
|
|
756
|
-
case 'area':
|
|
757
|
-
return renderAreaVisualizationHtml(visualization, options);
|
|
758
|
-
case 'column':
|
|
759
|
-
return renderColumnVisualizationHtml(visualization, options);
|
|
760
|
-
case 'processFlow':
|
|
761
|
-
return renderProcessFlowVisualizationHtml(visualization, options);
|
|
762
|
-
case 'waterfall':
|
|
763
|
-
return renderWaterfallVisualizationHtml(visualization, options);
|
|
764
|
-
default:
|
|
765
|
-
return `<span class="pfx-micro-viz__fallback">${escapeHtml(visualization.fallbackText)}</span>`;
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
function renderComparisonVisualizationHtml(visualization, options) {
|
|
769
|
-
let points = visualization.points ?? [];
|
|
770
|
-
if (points.length === 0) {
|
|
771
|
-
const primaryValue = toFiniteNumber(visualization.value);
|
|
772
|
-
const referenceValue = toFiniteNumber(visualization.baseline) ?? toFiniteNumber(visualization.target);
|
|
773
|
-
if (primaryValue !== undefined) {
|
|
774
|
-
points = [
|
|
775
|
-
{ value: primaryValue, tone: visualization.tone ?? 'info' },
|
|
776
|
-
...(referenceValue !== undefined
|
|
777
|
-
? [{ value: referenceValue, tone: 'neutral' }]
|
|
778
|
-
: []),
|
|
779
|
-
];
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
if (points.length === 0) {
|
|
783
|
-
return renderFallbackVisualizationHtml(visualization, visualization.tone ?? 'neutral');
|
|
784
|
-
}
|
|
785
|
-
const explicitCeiling = Math.max(toFiniteNumber(visualization.max) ?? 0, toFiniteNumber(visualization.total) ?? 0);
|
|
786
|
-
const max = Math.max(1, explicitCeiling, ...points.map((point) => Math.max(0, point.value)));
|
|
787
|
-
const suffix = visualization.valueSuffix ?? '';
|
|
788
|
-
const useCompact = visualization.compactValue === true;
|
|
789
|
-
const rows = points
|
|
790
|
-
.map((point) => {
|
|
791
|
-
const width = percent(point.value, max);
|
|
792
|
-
const formattedVal = formatVisualizationMetricValue(point.value, options, useCompact, suffix);
|
|
793
|
-
const alreadyPercent = (suffix.trim() === '%' || formattedVal.trim().endsWith('%')) && max === 100;
|
|
794
|
-
const readout = alreadyPercent
|
|
795
|
-
? `${point.label ? `${point.label}: ` : ''}${formattedVal}`
|
|
796
|
-
: `${point.label ? `${point.label}: ` : ''}${formattedVal} (${Math.round(Number(width))}%)`;
|
|
797
|
-
return `
|
|
798
|
-
<span class="pfx-micro-viz__row" data-tone="${escapeHtml(point.tone ?? visualization.tone ?? 'info')}" data-micro-readout="${escapeHtml(readout)}">
|
|
799
|
-
<span class="pfx-micro-viz__label">${escapeHtml(point.label ?? '')}</span>
|
|
800
|
-
<span class="pfx-micro-viz__track">
|
|
801
|
-
<span class="pfx-micro-viz__bar" style="width:${width}%"></span>
|
|
802
|
-
</span>
|
|
803
|
-
<span class="pfx-micro-viz__value">${escapeHtml(formattedVal)}</span>
|
|
804
|
-
</span>`;
|
|
805
|
-
})
|
|
806
|
-
.join('');
|
|
807
|
-
return `<span class="pfx-micro-viz pfx-micro-viz__comparison" role="img" aria-label="${escapeHtml(visualization.ariaLabel ?? visualization.fallbackText)}">${rows}</span>`;
|
|
808
|
-
}
|
|
809
|
-
function renderStackedBarVisualizationHtml(visualization, options) {
|
|
810
|
-
const segments = resolvePraxisStackedBarSegments(visualization);
|
|
811
|
-
if (segments.length === 0) {
|
|
812
|
-
return renderFallbackVisualizationHtml(visualization, visualization.tone ?? 'neutral');
|
|
813
|
-
}
|
|
814
|
-
const isTable = visualization.surface === 'table-cell';
|
|
815
|
-
const resolvedTotal = resolvePraxisStackedBarTotal(segments, visualization.total);
|
|
816
|
-
const suffix = visualization.valueSuffix ?? '';
|
|
817
|
-
const useCompact = visualization.compactValue === true;
|
|
818
|
-
const fallbackTone = visualization.tone ?? 'neutral';
|
|
819
|
-
const aria = resolvePraxisStackedBarAriaLabel(visualization, segments, resolvedTotal, options.locale);
|
|
820
|
-
const buildSegmentReadout = (segment) => {
|
|
821
|
-
const formattedVal = formatVisualizationMetricValue(segment.value, options, useCompact, suffix);
|
|
822
|
-
const pctText = formatPraxisStackedBarPercentage(segment.value, resolvedTotal, options.locale);
|
|
823
|
-
const alreadyPercent = suffix.trim() === '%' || formattedVal.trim().endsWith('%');
|
|
824
|
-
const metricPart = alreadyPercent ? formattedVal : `${formattedVal} (${pctText})`;
|
|
825
|
-
return segment.label ? `${segment.label}: ${metricPart}` : metricPart;
|
|
826
|
-
};
|
|
827
|
-
const bars = segments
|
|
828
|
-
.map((segment) => {
|
|
829
|
-
const widthPct = computePraxisStackedBarSegmentWidthPct(segment.value, resolvedTotal);
|
|
830
|
-
const isZero = segment.value === 0 || widthPct === 0;
|
|
831
|
-
const paint = getPraxisStackedBarPaintStyle(segment, fallbackTone);
|
|
832
|
-
const paintCss = `--prx-micro-category-color:${paint['--prx-micro-category-color']};color:${paint['color']}`;
|
|
833
|
-
const readout = buildSegmentReadout(segment);
|
|
834
|
-
return `
|
|
835
|
-
<span
|
|
836
|
-
class="pfx-micro-viz__segment"
|
|
837
|
-
data-tone="${escapeHtml(segment.tone ?? fallbackTone)}"${isZero ? '\n data-zero="true"' : ''}
|
|
838
|
-
data-micro-readout="${escapeHtml(readout)}"
|
|
839
|
-
style="width:${widthPct}%;${escapeHtml(paintCss)}"
|
|
840
|
-
></span>`;
|
|
841
|
-
})
|
|
842
|
-
.join('');
|
|
843
|
-
const titleHtml = !isTable && visualization.title
|
|
844
|
-
? `\n <span class="pfx-micro-viz__title">${escapeHtml(visualization.title)}</span>`
|
|
845
|
-
: '';
|
|
846
|
-
const legendHtml = !isTable && visualization.legend === true
|
|
847
|
-
? `\n <span class="pfx-micro-viz__legend" role="list">${segments
|
|
848
|
-
.map((segment) => {
|
|
849
|
-
const paint = getPraxisStackedBarPaintStyle(segment, fallbackTone);
|
|
850
|
-
const paintCss = `--prx-micro-category-color:${paint['--prx-micro-category-color']};color:${paint['color']}`;
|
|
851
|
-
const pctText = formatPraxisStackedBarPercentage(segment.value, resolvedTotal, options.locale);
|
|
852
|
-
const readout = buildSegmentReadout(segment);
|
|
853
|
-
return `<span class="pfx-micro-viz__legend-item" role="listitem" data-micro-readout="${escapeHtml(readout)}"><span class="pfx-micro-viz__legend-swatch" style="${escapeHtml(paintCss)}" aria-hidden="true"></span><span class="pfx-micro-viz__legend-label">${escapeHtml(segment.label ?? '')}</span><span class="pfx-micro-viz__legend-value">${escapeHtml(pctText)}</span></span>`;
|
|
854
|
-
})
|
|
855
|
-
.join('')}</span>`
|
|
856
|
-
: '';
|
|
857
|
-
const suppressedAttr = visualization.suppressedCount
|
|
858
|
-
? ` data-suppressed-count="${visualization.suppressedCount}"`
|
|
859
|
-
: '';
|
|
860
|
-
return `
|
|
861
|
-
<span class="pfx-micro-viz pfx-micro-viz__stacked" role="img" aria-label="${escapeHtml(aria)}"${suppressedAttr}>${titleHtml}
|
|
862
|
-
<span class="pfx-micro-viz__segments">${bars}</span>${legendHtml}
|
|
863
|
-
</span>`;
|
|
864
|
-
}
|
|
865
|
-
function resolveBulletMax(visualization) {
|
|
866
|
-
const thresholds = visualization.thresholds ?? [];
|
|
867
|
-
const thresholdValues = thresholds
|
|
868
|
-
.map(t => t.value ?? t.max ?? t.min ?? 0)
|
|
869
|
-
.filter((v) => Number.isFinite(v) && v > 0);
|
|
870
|
-
const values = [
|
|
871
|
-
toFiniteNumber(visualization.value) ?? 0,
|
|
872
|
-
visualization.target ?? 0,
|
|
873
|
-
visualization.total ?? 0,
|
|
874
|
-
visualization.max ?? 0,
|
|
875
|
-
...thresholdValues
|
|
876
|
-
].filter((v) => Number.isFinite(v) && v > 0);
|
|
877
|
-
const fallbackCeiling = visualization.total && visualization.total > 0
|
|
878
|
-
? visualization.total
|
|
879
|
-
: visualization.max && visualization.max > 0
|
|
880
|
-
? visualization.max
|
|
881
|
-
: 100;
|
|
882
|
-
return Math.max(...values, fallbackCeiling);
|
|
883
|
-
}
|
|
884
|
-
function renderBulletVisualizationHtml(visualization, options) {
|
|
885
|
-
const currentValue = toFiniteNumber(visualization.value);
|
|
886
|
-
if (currentValue === undefined) {
|
|
887
|
-
return renderFallbackVisualizationHtml(visualization, visualization.tone ?? 'neutral');
|
|
888
|
-
}
|
|
889
|
-
const max = resolveBulletMax(visualization);
|
|
890
|
-
const target = toFiniteNumber(visualization.target);
|
|
891
|
-
const targetLeft = target === undefined ? null : percent(target, max);
|
|
892
|
-
const isTable = visualization.surface === 'table-cell';
|
|
893
|
-
const suffix = visualization.valueSuffix ?? '';
|
|
894
|
-
// thresholds: sort ascending by boundary value so bands draw continuously regardless of declaration order
|
|
895
|
-
const thresholds = visualization.thresholds ?? [];
|
|
896
|
-
const sortedThresholds = [...thresholds].sort((a, b) => {
|
|
897
|
-
const aVal = a.value ?? a.max ?? a.min ?? 0;
|
|
898
|
-
const bVal = b.value ?? b.max ?? b.min ?? 0;
|
|
899
|
-
return aVal - bVal;
|
|
900
|
-
});
|
|
901
|
-
let previous = 0;
|
|
902
|
-
const bands = sortedThresholds.map(t => {
|
|
903
|
-
const tVal = t.value ?? t.max ?? t.min ?? 0;
|
|
904
|
-
const current = Math.max(tVal, previous);
|
|
905
|
-
const left = max > 0 ? percent(previous, max) : '0';
|
|
906
|
-
const width = max > 0 ? percent(current - previous, max) : '0';
|
|
907
|
-
previous = current;
|
|
908
|
-
return { left, width, tone: t.tone ?? 'info' };
|
|
909
|
-
}).filter(b => parseFloat(b.width) > 0);
|
|
910
|
-
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('');
|
|
911
|
-
const bandsLayerHtml = bandsHtml
|
|
912
|
-
? `<span class="pfx-micro-bullet__bands">${bandsHtml}</span>`
|
|
913
|
-
: '';
|
|
914
|
-
const targetLabel = resolveTargetReferenceLabel(visualization, options);
|
|
915
|
-
const topMetricHtml = visualization.compactValue === false
|
|
916
|
-
? target === undefined
|
|
917
|
-
? ''
|
|
918
|
-
: `<span class="pfx-micro-bullet__target-val">${escapeHtml(targetLabel)}: ${escapeHtml(formatVisualizationMetricValue(target, options, false, suffix))}</span>`
|
|
919
|
-
: `<span class="pfx-micro-bullet__value">
|
|
920
|
-
${escapeHtml(formatVisualizationMetricValue(currentValue, options, false, suffix))}
|
|
921
|
-
${target === undefined ? '' : `<span class="pfx-micro-bullet__target-val">/ ${escapeHtml(targetLabel)}: ${escapeHtml(formatVisualizationMetricValue(target, options, false, suffix))}</span>`}
|
|
922
|
-
</span>`;
|
|
923
|
-
const topHtml = isTable ? '' : `
|
|
924
|
-
<div class="pfx-micro-bullet__top">
|
|
925
|
-
<span class="pfx-micro-bullet__label">${escapeHtml(visualization.title || visualization.fallbackText)}</span>
|
|
926
|
-
${topMetricHtml}
|
|
927
|
-
</div>`;
|
|
928
|
-
const bottomHtml = isTable ? '' : `
|
|
929
|
-
<div class="pfx-micro-bullet__bottom">
|
|
930
|
-
<span>${escapeHtml(formatVisualizationMetricValue(visualization.baseline ?? 0, options, false, suffix))}</span>
|
|
931
|
-
<span>${escapeHtml(formatVisualizationMetricValue(max, options, false, suffix))}</span>
|
|
932
|
-
</div>`;
|
|
933
|
-
const showCompactValue = isTable && visualization.compactValue !== false;
|
|
934
|
-
const useCompactNotation = visualization.compactValue === true;
|
|
935
|
-
const compactValueHtml = showCompactValue
|
|
936
|
-
? `<span class="pfx-micro-bullet__compact-value">${escapeHtml(formatVisualizationMetricValue(currentValue, options, useCompactNotation, suffix))}</span>`
|
|
937
|
-
: '';
|
|
938
|
-
const currentStr = formatVisualizationMetricValue(currentValue, options, false, suffix);
|
|
939
|
-
const diff = target !== undefined ? currentValue - target : undefined;
|
|
940
|
-
const diffSign = diff !== undefined && diff > 0 ? '+' : '';
|
|
941
|
-
const bulletReadout = target !== undefined && diff !== undefined
|
|
942
|
-
? `${currentStr} / ${targetLabel} ${formatVisualizationMetricValue(target, options, false, suffix)} (${diffSign}${formatVisualizationMetricValue(diff, options, false, suffix)})`
|
|
943
|
-
: `${currentStr} / ${formatVisualizationMetricValue(max, options, false, suffix)}`;
|
|
944
|
-
const suppressTabIndex = isTable || options.interactiveContainer === true;
|
|
945
|
-
const tabIndexAttr = suppressTabIndex ? '' : ' tabindex="0"';
|
|
946
|
-
return `
|
|
947
|
-
<span class="pfx-micro-viz pfx-micro-viz__bullet"${tabIndexAttr} data-tone="${escapeHtml(visualization.tone ?? 'info')}" data-micro-readout="${escapeHtml(bulletReadout)}" role="img" aria-label="${escapeHtml(visualization.ariaLabel ?? visualization.fallbackText)}">
|
|
948
|
-
${topHtml}
|
|
949
|
-
<span class="pfx-micro-bullet__track">
|
|
950
|
-
${bandsLayerHtml}
|
|
951
|
-
<span class="pfx-micro-bullet__actual" data-tone="${escapeHtml(visualization.tone ?? 'info')}" style="width: ${percent(currentValue, max)}%;"></span>
|
|
952
|
-
${targetLeft === null ? '' : `<span class="pfx-micro-bullet__target" style="left: ${targetLeft}%;"></span>`}
|
|
953
|
-
</span>
|
|
954
|
-
${bottomHtml}
|
|
955
|
-
${compactValueHtml}
|
|
956
|
-
</span>`;
|
|
957
|
-
}
|
|
958
|
-
function renderDeltaVisualizationHtml(visualization, options) {
|
|
959
|
-
const value = toFiniteNumber(visualization.value);
|
|
960
|
-
const direction = value === undefined ? 'neutral' : value < 0 ? 'down' : value > 0 ? 'up' : 'neutral';
|
|
961
|
-
const symbol = direction === 'up' ? '▲' : direction === 'down' ? '▼' : '→';
|
|
962
|
-
const tone = visualization.tone ??
|
|
963
|
-
(value === undefined
|
|
964
|
-
? 'neutral'
|
|
965
|
-
: value < 0
|
|
966
|
-
? 'danger'
|
|
967
|
-
: value > 0
|
|
968
|
-
? 'success'
|
|
969
|
-
: 'neutral');
|
|
970
|
-
const valueSuffix = visualization.valueSuffix ?? '';
|
|
971
|
-
const text = value === undefined
|
|
972
|
-
? visualization.fallbackText
|
|
973
|
-
: formatVisualizationMetricValue(Math.abs(value), options, visualization.compactValue === true, valueSuffix);
|
|
974
|
-
const directionLabel = direction === 'up'
|
|
975
|
-
? 'up'
|
|
976
|
-
: direction === 'down'
|
|
977
|
-
? 'down'
|
|
978
|
-
: 'stable';
|
|
979
|
-
const aria = visualization.ariaLabel ?? `${visualization.fallbackText}: ${directionLabel} ${text}`;
|
|
980
|
-
const target = toFiniteNumber(visualization.target);
|
|
981
|
-
const baseline = toFiniteNumber(visualization.baseline);
|
|
982
|
-
const isTable = visualization.surface === 'table-cell';
|
|
983
|
-
const suppressTabIndex = isTable || options.interactiveContainer === true;
|
|
984
|
-
const targetLabel = resolveTargetReferenceLabel(visualization, options);
|
|
985
|
-
const deltaReadout = target !== undefined
|
|
986
|
-
? `${targetLabel} ${formatVisualizationMetricValue(target, options, false, valueSuffix)}`
|
|
987
|
-
: baseline !== undefined
|
|
988
|
-
? `Base ${formatVisualizationMetricValue(baseline, options, false, valueSuffix)}`
|
|
989
|
-
: null;
|
|
990
|
-
const readoutAttr = deltaReadout
|
|
991
|
-
? `${suppressTabIndex ? '' : ' tabindex="0"'} data-micro-readout="${escapeHtml(deltaReadout)}"`
|
|
992
|
-
: '';
|
|
993
|
-
return `
|
|
994
|
-
<span class="pfx-micro-viz pfx-micro-viz__delta" data-tone="${escapeHtml(tone)}" data-direction="${escapeHtml(direction)}"${readoutAttr} role="img" aria-label="${escapeHtml(aria)}">
|
|
995
|
-
<span class="pfx-micro-viz__delta-symbol" aria-hidden="true">${symbol}</span>
|
|
996
|
-
<span>${escapeHtml(text)}</span>
|
|
997
|
-
</span>`;
|
|
998
|
-
}
|
|
999
|
-
function percent(value, total) {
|
|
1000
|
-
if (!Number.isFinite(value) || !Number.isFinite(total) || total <= 0) {
|
|
1001
|
-
return '0';
|
|
1002
|
-
}
|
|
1003
|
-
return Math.max(0, Math.min(100, (value / total) * 100)).toFixed(2);
|
|
1004
|
-
}
|
|
1005
707
|
function toFiniteNumber(value) {
|
|
1006
708
|
if (typeof value === 'number') {
|
|
1007
709
|
return Number.isFinite(value) ? value : undefined;
|
|
@@ -1039,14 +741,6 @@ function formatMicroNumber(value, locale, compactValue = false) {
|
|
|
1039
741
|
maximumFractionDigits: abs < 10 ? 2 : hasFraction && abs < 1000 ? 1 : 0,
|
|
1040
742
|
}).format(value);
|
|
1041
743
|
}
|
|
1042
|
-
function escapeHtml(value) {
|
|
1043
|
-
return String(value ?? '')
|
|
1044
|
-
.replace(/&/g, '&')
|
|
1045
|
-
.replace(/</g, '<')
|
|
1046
|
-
.replace(/>/g, '>')
|
|
1047
|
-
.replace(/"/g, '"')
|
|
1048
|
-
.replace(/'/g, ''');
|
|
1049
|
-
}
|
|
1050
744
|
function normalizePoints(value) {
|
|
1051
745
|
const points = normalizeNumericEntries(value);
|
|
1052
746
|
return points.length ? { points } : undefined;
|
|
@@ -1176,421 +870,6 @@ function normalizeText$1(value) {
|
|
|
1176
870
|
const trimmed = value.trim();
|
|
1177
871
|
return trimmed.length ? trimmed : undefined;
|
|
1178
872
|
}
|
|
1179
|
-
function renderRadialVisualizationHtml(visualization, options) {
|
|
1180
|
-
const value = toFiniteNumber(visualization.value);
|
|
1181
|
-
if (value === undefined) {
|
|
1182
|
-
return renderFallbackVisualizationHtml(visualization, visualization.tone ?? 'neutral');
|
|
1183
|
-
}
|
|
1184
|
-
const total = visualization.total && visualization.total > 0 ? visualization.total : 100;
|
|
1185
|
-
const rawPct = Math.max(0, (value / total) * 100);
|
|
1186
|
-
const arcPct = Math.min(100, rawPct);
|
|
1187
|
-
const tone = visualization.tone ?? 'info';
|
|
1188
|
-
const suffix = visualization.valueSuffix ?? '';
|
|
1189
|
-
const dashArray = `${arcPct.toFixed(1)}, 100`;
|
|
1190
|
-
const hasFractionalPct = rawPct < 100 && Math.abs(rawPct - Math.round(rawPct)) >= 0.05;
|
|
1191
|
-
const displayPctNum = hasFractionalPct ? Number(rawPct.toFixed(1)) : Math.round(rawPct);
|
|
1192
|
-
const radialNumStr = formatMicroNumber(displayPctNum, options.locale, false);
|
|
1193
|
-
const pctText = `${radialNumStr}%`;
|
|
1194
|
-
const aria = visualization.ariaLabel ?? `${visualization.fallbackText} (${pctText})`;
|
|
1195
|
-
const isTable = visualization.surface === 'table-cell';
|
|
1196
|
-
const isZero = rawPct <= 0;
|
|
1197
|
-
const svgSuffix = computeMicroSvgIdSuffix(visualization, options);
|
|
1198
|
-
const gradId = `pfx-rad-grad-${tone}-${svgSuffix}`;
|
|
1199
|
-
const [stop0, stop1, stop2] = getPraxisMicroToneGradientStops(tone);
|
|
1200
|
-
const targetVal = toFiniteNumber(visualization.target);
|
|
1201
|
-
const targetPct = targetVal !== undefined && targetVal > 0
|
|
1202
|
-
? Math.max(0, Math.min(100, (targetVal / total) * 100))
|
|
1203
|
-
: null;
|
|
1204
|
-
const targetArcHtml = targetPct !== null
|
|
1205
|
-
? `<circle class="pfx-micro-radial-svg__target-arc" cx="18" cy="18" r="13.8" pathLength="100" stroke-dasharray="${targetPct.toFixed(1)}, 100" transform="rotate(-90 18 18)" />`
|
|
1206
|
-
: '';
|
|
1207
|
-
const digitTierAttr = radialNumStr.length >= 4
|
|
1208
|
-
? ' data-digits="4"'
|
|
1209
|
-
: radialNumStr.length === 3
|
|
1210
|
-
? ' data-digits="3"'
|
|
1211
|
-
: '';
|
|
1212
|
-
const svgText = isTable
|
|
1213
|
-
? ''
|
|
1214
|
-
: `<text x="18" y="20.6" class="pfx-micro-radial-svg__text"${digitTierAttr}><tspan class="pfx-micro-radial-svg__num">${escapeHtml(radialNumStr)}</tspan><tspan class="pfx-micro-radial-svg__unit">%</tspan></text>`;
|
|
1215
|
-
const externalText = isTable
|
|
1216
|
-
? `<span class="pfx-micro-radial-value">${escapeHtml(pctText)}</span>`
|
|
1217
|
-
: '';
|
|
1218
|
-
const formattedVal = formatVisualizationMetricValue(value, options, false, suffix);
|
|
1219
|
-
const formattedTotal = formatVisualizationMetricValue(total, options, false, suffix);
|
|
1220
|
-
const alreadyPercent = (suffix.trim() === '%' || formattedVal.trim().endsWith('%')) && total === 100;
|
|
1221
|
-
const radialReadout = alreadyPercent
|
|
1222
|
-
? formattedVal
|
|
1223
|
-
: `${formattedVal} / ${formattedTotal} (${pctText})`;
|
|
1224
|
-
const suppressTabIndex = isTable || options.interactiveContainer === true;
|
|
1225
|
-
const tabIndexAttr = suppressTabIndex ? '' : ' tabindex="0"';
|
|
1226
|
-
return `
|
|
1227
|
-
<span class="pfx-micro-viz pfx-micro-viz__radial"${tabIndexAttr} data-tone="${escapeHtml(tone)}" data-micro-readout="${escapeHtml(radialReadout)}" role="img" aria-label="${escapeHtml(aria)}">
|
|
1228
|
-
<svg class="pfx-micro-radial-svg" viewBox="0 0 36 36">
|
|
1229
|
-
<defs>
|
|
1230
|
-
<linearGradient id="${escapeHtml(gradId)}" x1="100%" y1="55%" x2="10%" y2="15%">
|
|
1231
|
-
<stop offset="0%" stop-color="${stop0}" />
|
|
1232
|
-
<stop offset="52%" stop-color="${stop1}" />
|
|
1233
|
-
<stop offset="100%" stop-color="${stop2}" />
|
|
1234
|
-
</linearGradient>
|
|
1235
|
-
</defs>
|
|
1236
|
-
<circle class="pfx-micro-radial-svg__bezel" cx="18" cy="18" r="17" />
|
|
1237
|
-
<circle class="pfx-micro-radial-svg__track" cx="18" cy="18" r="13.8" pathLength="100" />
|
|
1238
|
-
${targetArcHtml}
|
|
1239
|
-
<circle class="pfx-micro-radial-svg__bar" cx="18" cy="18" r="13.8" pathLength="100"${isZero ? ' data-zero="true"' : ''} stroke="url(#${escapeHtml(gradId)})" stroke-dasharray="${dashArray}" transform="rotate(-90 18 18)" />
|
|
1240
|
-
<circle class="pfx-micro-radial-svg__medallion" cx="18" cy="18" r="10.9" />
|
|
1241
|
-
${svgText}
|
|
1242
|
-
</svg>
|
|
1243
|
-
${externalText}
|
|
1244
|
-
</span>`;
|
|
1245
|
-
}
|
|
1246
|
-
function renderHarveyBallVisualizationHtml(visualization, options) {
|
|
1247
|
-
const value = toFiniteNumber(visualization.value);
|
|
1248
|
-
if (value === undefined) {
|
|
1249
|
-
return renderFallbackVisualizationHtml(visualization, visualization.tone ?? 'neutral');
|
|
1250
|
-
}
|
|
1251
|
-
const total = visualization.total && visualization.total > 0 ? visualization.total : 100;
|
|
1252
|
-
const rawPct = Math.max(0, (value / total) * 100);
|
|
1253
|
-
const arcPct = Math.min(100, rawPct);
|
|
1254
|
-
const tone = visualization.tone ?? 'info';
|
|
1255
|
-
const isTable = visualization.surface === 'table-cell';
|
|
1256
|
-
const suppressTabIndex = isTable || options.interactiveContainer === true;
|
|
1257
|
-
const tabIndexAttr = suppressTabIndex ? '' : ' tabindex="0"';
|
|
1258
|
-
const suffix = visualization.valueSuffix ?? '';
|
|
1259
|
-
const isZero = rawPct <= 0;
|
|
1260
|
-
const svgSuffix = computeMicroSvgIdSuffix(visualization, options);
|
|
1261
|
-
const gradId = `pfx-harvey-grad-${tone}-${svgSuffix}`;
|
|
1262
|
-
const [stop0, stop1, stop2] = getPraxisMicroToneGradientStops(tone);
|
|
1263
|
-
const dashArray = `${arcPct.toFixed(2)} 100`;
|
|
1264
|
-
const roundedPct = Math.round(rawPct);
|
|
1265
|
-
const aria = visualization.ariaLabel ?? `${visualization.fallbackText} (${roundedPct}%)`;
|
|
1266
|
-
const formattedValue = formatVisualizationMetricValue(value, options, false, suffix);
|
|
1267
|
-
const formattedTotal = formatVisualizationMetricValue(total, options, false, suffix);
|
|
1268
|
-
const harveyReadout = `${formattedValue}/${formattedTotal} (${roundedPct}%)`;
|
|
1269
|
-
const pctBadgeHtml = isTable
|
|
1270
|
-
? ''
|
|
1271
|
-
: `<span class="pfx-micro-harvey-pct">${roundedPct}%</span>`;
|
|
1272
|
-
return `
|
|
1273
|
-
<span class="pfx-micro-viz pfx-micro-viz__harvey"${tabIndexAttr} data-tone="${escapeHtml(tone)}" data-micro-readout="${escapeHtml(harveyReadout)}" role="img" aria-label="${escapeHtml(aria)}">
|
|
1274
|
-
<svg class="pfx-micro-harvey-svg" viewBox="0 0 36 36">
|
|
1275
|
-
<defs>
|
|
1276
|
-
<linearGradient id="${escapeHtml(gradId)}" x1="15%" y1="10%" x2="85%" y2="90%">
|
|
1277
|
-
<stop offset="0%" stop-color="${stop0}" />
|
|
1278
|
-
<stop offset="52%" stop-color="${stop1}" />
|
|
1279
|
-
<stop offset="100%" stop-color="${stop2}" />
|
|
1280
|
-
</linearGradient>
|
|
1281
|
-
</defs>
|
|
1282
|
-
<circle class="pfx-micro-harvey-svg__bezel" cx="18" cy="18" r="16.8" />
|
|
1283
|
-
<circle class="pfx-micro-harvey-svg__track" cx="18" cy="18" r="14" />
|
|
1284
|
-
<circle class="pfx-micro-harvey-svg__bar" cx="18" cy="18" r="7" pathLength="100"${isZero ? ' data-zero="true"' : ''} stroke="url(#${escapeHtml(gradId)})" stroke-dasharray="${dashArray}" transform="rotate(-90 18 18)" />
|
|
1285
|
-
<circle class="pfx-micro-harvey-svg__pin" cx="18" cy="18" r="1.8" />
|
|
1286
|
-
</svg>
|
|
1287
|
-
<span class="pfx-micro-harvey-fraction">
|
|
1288
|
-
<strong>${escapeHtml(formattedValue)}</strong>
|
|
1289
|
-
<span class="pfx-separator">/</span>
|
|
1290
|
-
<span class="pfx-total">${escapeHtml(formattedTotal)}</span>
|
|
1291
|
-
</span>
|
|
1292
|
-
${pctBadgeHtml}
|
|
1293
|
-
</span>`;
|
|
1294
|
-
}
|
|
1295
|
-
function resolveTrendBounds(points, visualization, anchorZero = false) {
|
|
1296
|
-
const values = points.map((p) => p.value);
|
|
1297
|
-
const refValue = toFiniteNumber(visualization?.target) ?? toFiniteNumber(visualization?.baseline);
|
|
1298
|
-
const explicitMin = toFiniteNumber(visualization?.min);
|
|
1299
|
-
const explicitMax = toFiniteNumber(visualization?.max);
|
|
1300
|
-
const baseCandidates = anchorZero ? [...values, 0] : [...values];
|
|
1301
|
-
if (refValue !== undefined) {
|
|
1302
|
-
baseCandidates.push(refValue);
|
|
1303
|
-
}
|
|
1304
|
-
const minVal = explicitMin !== undefined ? Math.min(explicitMin, ...baseCandidates) : Math.min(...baseCandidates);
|
|
1305
|
-
const maxVal = explicitMax !== undefined ? Math.max(explicitMax, ...baseCandidates) : Math.max(...baseCandidates);
|
|
1306
|
-
const valRange = maxVal - minVal === 0 ? 1 : maxVal - minVal;
|
|
1307
|
-
return { minVal, maxVal, valRange, refValue };
|
|
1308
|
-
}
|
|
1309
|
-
function getPointsCoordinates(points, width, height, padding, visualization) {
|
|
1310
|
-
if (points.length < 2)
|
|
1311
|
-
return [];
|
|
1312
|
-
const { minVal, valRange } = resolveTrendBounds(points, visualization, false);
|
|
1313
|
-
return points.map((p, index) => {
|
|
1314
|
-
const x = padding + (index / (points.length - 1)) * (width - 2 * padding);
|
|
1315
|
-
const y = height - padding - ((p.value - minVal) / valRange) * (height - 2 * padding);
|
|
1316
|
-
return { x, y };
|
|
1317
|
-
});
|
|
1318
|
-
}
|
|
1319
|
-
function renderTrendReferenceLineHtml(points, width, height, padding, visualization, anchorZero = false) {
|
|
1320
|
-
const { minVal, valRange, refValue } = resolveTrendBounds(points, visualization, anchorZero);
|
|
1321
|
-
if (refValue === undefined) {
|
|
1322
|
-
return '';
|
|
1323
|
-
}
|
|
1324
|
-
const refY = height - padding - ((refValue - minVal) / valRange) * (height - 2 * padding);
|
|
1325
|
-
return `<line class="pfx-micro-trend__ref-line" x1="${padding}" y1="${refY.toFixed(1)}" x2="${width - padding}" y2="${refY.toFixed(1)}" stroke="currentColor" stroke-opacity="0.38" stroke-width="1" stroke-dasharray="2 2" />`;
|
|
1326
|
-
}
|
|
1327
|
-
function renderTrendScrubLayerHtml(points, coords, width, height, visualization, options) {
|
|
1328
|
-
const defaultTone = visualization.tone ?? 'info';
|
|
1329
|
-
const suffix = visualization.valueSuffix ?? '';
|
|
1330
|
-
const slicesHtml = points
|
|
1331
|
-
.map((point, index) => {
|
|
1332
|
-
const coord = coords[index] ?? { x: 50, y: 15 };
|
|
1333
|
-
const xPct = ((coord.x / width) * 100).toFixed(1);
|
|
1334
|
-
const yPct = ((coord.y / height) * 100).toFixed(1);
|
|
1335
|
-
const pointTone = point.tone ??
|
|
1336
|
-
(visualization.thresholds?.length
|
|
1337
|
-
? resolvePraxisMicroVisualizationTone(point.value, visualization.thresholds)?.tone ?? defaultTone
|
|
1338
|
-
: defaultTone);
|
|
1339
|
-
const labelPrefix = point.label ? `${point.label}: ` : `#${index + 1}: `;
|
|
1340
|
-
const readout = `${labelPrefix}${formatVisualizationMetricValue(point.value, options, visualization.compactValue === true, suffix)}`;
|
|
1341
|
-
return `<span class="pfx-micro-trend__scrub-slice" data-tone="${escapeHtml(pointTone)}" data-micro-readout="${escapeHtml(readout)}" style="--pfx-scrub-x:${xPct}%;--pfx-scrub-y:${yPct}%;"></span>`;
|
|
1342
|
-
})
|
|
1343
|
-
.join('');
|
|
1344
|
-
return `<span class="pfx-micro-trend__scrub-layer" aria-hidden="true">${slicesHtml}</span>`;
|
|
1345
|
-
}
|
|
1346
|
-
function renderLineVisualizationHtml(visualization, options) {
|
|
1347
|
-
const points = visualization.points ?? [];
|
|
1348
|
-
const tone = visualization.tone ?? 'info';
|
|
1349
|
-
if (points.length < 2) {
|
|
1350
|
-
return renderFallbackVisualizationHtml(visualization, tone);
|
|
1351
|
-
}
|
|
1352
|
-
const width = 100;
|
|
1353
|
-
const height = 30;
|
|
1354
|
-
const padding = 4;
|
|
1355
|
-
const coords = getPointsCoordinates(points, width, height, padding, visualization);
|
|
1356
|
-
const pathD = coords.map((c, i) => `${i === 0 ? 'M' : 'L'} ${c.x.toFixed(1)} ${c.y.toFixed(1)}`).join(' ');
|
|
1357
|
-
const lastCoord = coords[coords.length - 1];
|
|
1358
|
-
const refLineHtml = renderTrendReferenceLineHtml(points, width, height, padding, visualization, false);
|
|
1359
|
-
// Highlight extreme/boundary values
|
|
1360
|
-
let minIdx = 0;
|
|
1361
|
-
let maxIdx = 0;
|
|
1362
|
-
for (let i = 1; i < points.length; i++) {
|
|
1363
|
-
if (points[i].value < points[minIdx].value)
|
|
1364
|
-
minIdx = i;
|
|
1365
|
-
if (points[i].value > points[maxIdx].value)
|
|
1366
|
-
maxIdx = i;
|
|
1367
|
-
}
|
|
1368
|
-
const lastTone = points[points.length - 1].tone ?? tone;
|
|
1369
|
-
const markers = [
|
|
1370
|
-
{ x: coords[0].x, y: coords[0].y, tone: points[0].tone ?? tone },
|
|
1371
|
-
{ x: lastCoord.x, y: lastCoord.y, tone: lastTone }
|
|
1372
|
-
];
|
|
1373
|
-
if (minIdx !== 0 && minIdx !== coords.length - 1) {
|
|
1374
|
-
markers.push({ x: coords[minIdx].x, y: coords[minIdx].y, tone: points[minIdx].tone ?? 'danger' });
|
|
1375
|
-
}
|
|
1376
|
-
if (maxIdx !== 0 && maxIdx !== coords.length - 1) {
|
|
1377
|
-
markers.push({ x: coords[maxIdx].x, y: coords[maxIdx].y, tone: points[maxIdx].tone ?? 'success' });
|
|
1378
|
-
}
|
|
1379
|
-
const endpointHaloHtml = `<circle cx="${lastCoord.x.toFixed(1)}" cy="${lastCoord.y.toFixed(1)}" r="5" class="pfx-micro-trend__endpoint-halo" data-tone="${escapeHtml(lastTone)}" />`;
|
|
1380
|
-
const circlesHtml = markers.map(c => `<circle cx="${c.x.toFixed(1)}" cy="${c.y.toFixed(1)}" r="2.5" class="pfx-micro-trend__marker" data-tone="${escapeHtml(c.tone)}" />`).join('');
|
|
1381
|
-
const scrubLayerHtml = renderTrendScrubLayerHtml(points, coords, width, height, visualization, options);
|
|
1382
|
-
const isTable = visualization.surface === 'table-cell';
|
|
1383
|
-
const firstPoint = points[0];
|
|
1384
|
-
const lastPoint = points[points.length - 1];
|
|
1385
|
-
const suffix = visualization.valueSuffix ?? '';
|
|
1386
|
-
const leftHtml = isTable ? '' : `
|
|
1387
|
-
<div class="pfx-micro-trend__label-col pfx-micro-trend__label-col--start">
|
|
1388
|
-
<span class="pfx-micro-trend__value">${escapeHtml(formatVisualizationMetricValue(firstPoint.value, options, visualization.compactValue === true, suffix))}</span>
|
|
1389
|
-
${firstPoint.label ? `<span class="pfx-micro-trend__label">${escapeHtml(firstPoint.label)}</span>` : ''}
|
|
1390
|
-
</div>`;
|
|
1391
|
-
const rightHtml = isTable ? '' : `
|
|
1392
|
-
<div class="pfx-micro-trend__label-col pfx-micro-trend__label-col--end">
|
|
1393
|
-
<span class="pfx-micro-trend__value">${escapeHtml(formatVisualizationMetricValue(lastPoint.value, options, visualization.compactValue === true, suffix))}</span>
|
|
1394
|
-
${lastPoint.label ? `<span class="pfx-micro-trend__label">${escapeHtml(lastPoint.label)}</span>` : ''}
|
|
1395
|
-
</div>`;
|
|
1396
|
-
return `
|
|
1397
|
-
<span class="pfx-micro-viz-container">
|
|
1398
|
-
${leftHtml}
|
|
1399
|
-
<span class="pfx-micro-viz pfx-micro-viz__line" data-tone="${escapeHtml(tone)}" role="img" aria-label="${escapeHtml(visualization.ariaLabel ?? visualization.fallbackText)}">
|
|
1400
|
-
<svg class="pfx-micro-line__svg" viewBox="0 0 100 30">
|
|
1401
|
-
${refLineHtml}
|
|
1402
|
-
<path class="pfx-micro-line__path" d="${pathD}" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" />
|
|
1403
|
-
${endpointHaloHtml}
|
|
1404
|
-
${circlesHtml}
|
|
1405
|
-
</svg>
|
|
1406
|
-
${scrubLayerHtml}
|
|
1407
|
-
</span>
|
|
1408
|
-
${rightHtml}
|
|
1409
|
-
</span>`;
|
|
1410
|
-
}
|
|
1411
|
-
function renderAreaVisualizationHtml(visualization, options) {
|
|
1412
|
-
const points = visualization.points ?? [];
|
|
1413
|
-
const tone = visualization.tone ?? 'info';
|
|
1414
|
-
if (points.length < 2) {
|
|
1415
|
-
return renderFallbackVisualizationHtml(visualization, tone);
|
|
1416
|
-
}
|
|
1417
|
-
const width = 100;
|
|
1418
|
-
const height = 30;
|
|
1419
|
-
const padding = 4;
|
|
1420
|
-
const coords = getPointsCoordinates(points, width, height, padding, visualization);
|
|
1421
|
-
const lineD = coords.map((c, i) => `${i === 0 ? 'M' : 'L'} ${c.x.toFixed(1)} ${c.y.toFixed(1)}`).join(' ');
|
|
1422
|
-
const refLineHtml = renderTrendReferenceLineHtml(points, width, height, padding, visualization, false);
|
|
1423
|
-
const firstX = coords[0].x.toFixed(1);
|
|
1424
|
-
const lastCoord = coords[coords.length - 1];
|
|
1425
|
-
const lastX = lastCoord.x.toFixed(1);
|
|
1426
|
-
const areaD = `${lineD} L ${lastX} ${height} L ${firstX} ${height} Z`;
|
|
1427
|
-
const areaGradId = `pfx-area-grad-${tone}-${computeMicroSvgIdSuffix(visualization, options)}`;
|
|
1428
|
-
// Highlight extreme/boundary values
|
|
1429
|
-
let minIdx = 0;
|
|
1430
|
-
let maxIdx = 0;
|
|
1431
|
-
for (let i = 1; i < points.length; i++) {
|
|
1432
|
-
if (points[i].value < points[minIdx].value)
|
|
1433
|
-
minIdx = i;
|
|
1434
|
-
if (points[i].value > points[maxIdx].value)
|
|
1435
|
-
maxIdx = i;
|
|
1436
|
-
}
|
|
1437
|
-
const lastTone = points[points.length - 1].tone ?? tone;
|
|
1438
|
-
const markers = [
|
|
1439
|
-
{ x: coords[0].x, y: coords[0].y, tone: points[0].tone ?? tone },
|
|
1440
|
-
{ x: lastCoord.x, y: lastCoord.y, tone: lastTone }
|
|
1441
|
-
];
|
|
1442
|
-
if (minIdx !== 0 && minIdx !== coords.length - 1) {
|
|
1443
|
-
markers.push({ x: coords[minIdx].x, y: coords[minIdx].y, tone: points[minIdx].tone ?? 'danger' });
|
|
1444
|
-
}
|
|
1445
|
-
if (maxIdx !== 0 && maxIdx !== coords.length - 1) {
|
|
1446
|
-
markers.push({ x: coords[maxIdx].x, y: coords[maxIdx].y, tone: points[maxIdx].tone ?? 'success' });
|
|
1447
|
-
}
|
|
1448
|
-
const endpointHaloHtml = `<circle cx="${lastCoord.x.toFixed(1)}" cy="${lastCoord.y.toFixed(1)}" r="5" class="pfx-micro-trend__endpoint-halo" data-tone="${escapeHtml(lastTone)}" />`;
|
|
1449
|
-
const circlesHtml = markers.map(c => `<circle cx="${c.x.toFixed(1)}" cy="${c.y.toFixed(1)}" r="2.5" class="pfx-micro-trend__marker" data-tone="${escapeHtml(c.tone)}" />`).join('');
|
|
1450
|
-
const scrubLayerHtml = renderTrendScrubLayerHtml(points, coords, width, height, visualization, options);
|
|
1451
|
-
const isTable = visualization.surface === 'table-cell';
|
|
1452
|
-
const firstPoint = points[0];
|
|
1453
|
-
const lastPoint = points[points.length - 1];
|
|
1454
|
-
const suffix = visualization.valueSuffix ?? '';
|
|
1455
|
-
const leftHtml = isTable ? '' : `
|
|
1456
|
-
<div class="pfx-micro-trend__label-col pfx-micro-trend__label-col--start">
|
|
1457
|
-
<span class="pfx-micro-trend__value">${escapeHtml(formatVisualizationMetricValue(firstPoint.value, options, visualization.compactValue === true, suffix))}</span>
|
|
1458
|
-
${firstPoint.label ? `<span class="pfx-micro-trend__label">${escapeHtml(firstPoint.label)}</span>` : ''}
|
|
1459
|
-
</div>`;
|
|
1460
|
-
const rightHtml = isTable ? '' : `
|
|
1461
|
-
<div class="pfx-micro-trend__label-col pfx-micro-trend__label-col--end">
|
|
1462
|
-
<span class="pfx-micro-trend__value">${escapeHtml(formatVisualizationMetricValue(lastPoint.value, options, visualization.compactValue === true, suffix))}</span>
|
|
1463
|
-
${lastPoint.label ? `<span class="pfx-micro-trend__label">${escapeHtml(lastPoint.label)}</span>` : ''}
|
|
1464
|
-
</div>`;
|
|
1465
|
-
return `
|
|
1466
|
-
<span class="pfx-micro-viz-container">
|
|
1467
|
-
${leftHtml}
|
|
1468
|
-
<span class="pfx-micro-viz pfx-micro-viz__area" data-tone="${escapeHtml(tone)}" role="img" aria-label="${escapeHtml(visualization.ariaLabel ?? visualization.fallbackText)}">
|
|
1469
|
-
<svg class="pfx-micro-area__svg" viewBox="0 0 100 30">
|
|
1470
|
-
<defs>
|
|
1471
|
-
<linearGradient id="${escapeHtml(areaGradId)}" x1="0%" y1="0%" x2="0%" y2="100%">
|
|
1472
|
-
<stop offset="0%" stop-color="currentColor" stop-opacity="0.32" />
|
|
1473
|
-
<stop offset="100%" stop-color="currentColor" stop-opacity="0.02" />
|
|
1474
|
-
</linearGradient>
|
|
1475
|
-
</defs>
|
|
1476
|
-
${refLineHtml}
|
|
1477
|
-
<path class="pfx-micro-area__fill" d="${areaD}" fill="url(#${escapeHtml(areaGradId)})" />
|
|
1478
|
-
<path class="pfx-micro-area__path" d="${lineD}" fill="none" stroke="currentColor" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" />
|
|
1479
|
-
${endpointHaloHtml}
|
|
1480
|
-
${circlesHtml}
|
|
1481
|
-
</svg>
|
|
1482
|
-
${scrubLayerHtml}
|
|
1483
|
-
</span>
|
|
1484
|
-
${rightHtml}
|
|
1485
|
-
</span>`;
|
|
1486
|
-
}
|
|
1487
|
-
function renderColumnVisualizationHtml(visualization, options) {
|
|
1488
|
-
const points = visualization.points ?? [];
|
|
1489
|
-
const tone = visualization.tone ?? 'info';
|
|
1490
|
-
if (points.length === 0) {
|
|
1491
|
-
return renderFallbackVisualizationHtml(visualization, tone);
|
|
1492
|
-
}
|
|
1493
|
-
const width = 100;
|
|
1494
|
-
const height = 30;
|
|
1495
|
-
const padding = 4;
|
|
1496
|
-
const { minVal, valRange } = resolveTrendBounds(points, visualization, true);
|
|
1497
|
-
const refLineHtml = renderTrendReferenceLineHtml(points, width, height, padding, visualization, true);
|
|
1498
|
-
const colWidth = Math.max(2, (width - 2 * padding) / points.length - 2);
|
|
1499
|
-
const colCoords = [];
|
|
1500
|
-
const columnsHtml = points.map((p, i) => {
|
|
1501
|
-
const x = padding + i * ((width - 2 * padding) / points.length) + 1;
|
|
1502
|
-
const rectHeight = Math.max(2, ((p.value - minVal) / valRange) * (height - 2 * padding));
|
|
1503
|
-
const rectY = height - padding - rectHeight;
|
|
1504
|
-
colCoords.push({ x: x + colWidth / 2, y: rectY });
|
|
1505
|
-
const itemTone = p.tone ??
|
|
1506
|
-
(visualization.thresholds?.length
|
|
1507
|
-
? resolvePraxisMicroVisualizationTone(p.value, visualization.thresholds)?.tone ?? tone
|
|
1508
|
-
: tone);
|
|
1509
|
-
const latestAttr = i === points.length - 1 ? ' data-latest="true"' : '';
|
|
1510
|
-
return `<rect class="pfx-micro-column__bar" x="${x.toFixed(1)}" y="${rectY.toFixed(1)}" width="${colWidth.toFixed(1)}" height="${rectHeight.toFixed(1)}" rx="2" fill="currentColor" data-tone="${escapeHtml(itemTone)}"${latestAttr} />`;
|
|
1511
|
-
}).join('');
|
|
1512
|
-
const scrubLayerHtml = renderTrendScrubLayerHtml(points, colCoords, width, height, visualization, options);
|
|
1513
|
-
const isTable = visualization.surface === 'table-cell';
|
|
1514
|
-
const firstPoint = points[0];
|
|
1515
|
-
const lastPoint = points[points.length - 1];
|
|
1516
|
-
const suffix = visualization.valueSuffix ?? '';
|
|
1517
|
-
const leftHtml = isTable ? '' : `
|
|
1518
|
-
<div class="pfx-micro-trend__label-col pfx-micro-trend__label-col--start">
|
|
1519
|
-
<span class="pfx-micro-trend__value">${escapeHtml(formatVisualizationMetricValue(firstPoint.value, options, visualization.compactValue === true, suffix))}</span>
|
|
1520
|
-
${firstPoint.label ? `<span class="pfx-micro-trend__label">${escapeHtml(firstPoint.label)}</span>` : ''}
|
|
1521
|
-
</div>`;
|
|
1522
|
-
const rightHtml = isTable ? '' : `
|
|
1523
|
-
<div class="pfx-micro-trend__label-col pfx-micro-trend__label-col--end">
|
|
1524
|
-
<span class="pfx-micro-trend__value">${escapeHtml(formatVisualizationMetricValue(lastPoint.value, options, visualization.compactValue === true, suffix))}</span>
|
|
1525
|
-
${lastPoint.label ? `<span class="pfx-micro-trend__label">${escapeHtml(lastPoint.label)}</span>` : ''}
|
|
1526
|
-
</div>`;
|
|
1527
|
-
return `
|
|
1528
|
-
<span class="pfx-micro-viz-container">
|
|
1529
|
-
${leftHtml}
|
|
1530
|
-
<span class="pfx-micro-viz pfx-micro-viz__column" data-tone="${escapeHtml(tone)}" role="img" aria-label="${escapeHtml(visualization.ariaLabel ?? visualization.fallbackText)}">
|
|
1531
|
-
<svg class="pfx-micro-column__svg" viewBox="0 0 100 30">
|
|
1532
|
-
${columnsHtml}
|
|
1533
|
-
${refLineHtml}
|
|
1534
|
-
</svg>
|
|
1535
|
-
${scrubLayerHtml}
|
|
1536
|
-
</span>
|
|
1537
|
-
${rightHtml}
|
|
1538
|
-
</span>`;
|
|
1539
|
-
}
|
|
1540
|
-
function renderProcessFlowVisualizationHtml(visualization, options) {
|
|
1541
|
-
const items = visualization.items ?? [];
|
|
1542
|
-
if (items.length === 0) {
|
|
1543
|
-
return renderFallbackVisualizationHtml(visualization, visualization.tone ?? 'neutral');
|
|
1544
|
-
}
|
|
1545
|
-
const isTable = visualization.surface === 'table-cell';
|
|
1546
|
-
const stepLabels = items.map((item, index) => item.label ?? item.id ?? `${index + 1}`);
|
|
1547
|
-
const aria = visualization.ariaLabel ?? `${visualization.fallbackText}: ${stepLabels.join(' > ')}`;
|
|
1548
|
-
const labelStyleAttr = [];
|
|
1549
|
-
if (visualization.stepLabelWidth !== undefined) {
|
|
1550
|
-
const widthVal = typeof visualization.stepLabelWidth === 'number'
|
|
1551
|
-
? `${visualization.stepLabelWidth}px`
|
|
1552
|
-
: String(visualization.stepLabelWidth);
|
|
1553
|
-
labelStyleAttr.push(`inline-size: ${escapeHtml(widthVal)}; max-width: ${escapeHtml(widthVal)};`);
|
|
1554
|
-
}
|
|
1555
|
-
if (visualization.stepLabelLineClamp !== undefined) {
|
|
1556
|
-
labelStyleAttr.push(`-webkit-line-clamp: ${visualization.stepLabelLineClamp};`);
|
|
1557
|
-
}
|
|
1558
|
-
const labelInlineStyle = labelStyleAttr.length ? ` style="${labelStyleAttr.join(' ')}"` : '';
|
|
1559
|
-
const stepsHtml = items.map((item, index) => {
|
|
1560
|
-
const itemTone = item.tone ?? 'neutral';
|
|
1561
|
-
const itemState = item.state ?? '';
|
|
1562
|
-
const isLast = index === items.length - 1;
|
|
1563
|
-
const itemLabel = stepLabels[index];
|
|
1564
|
-
const normalizedIcon = item.icon ? item.icon.replace(/-/g, '_') : undefined;
|
|
1565
|
-
const label = !isTable && item.label ? `<span class="pfx-micro-step__label"${labelInlineStyle}>${escapeHtml(item.label)}</span>` : '';
|
|
1566
|
-
const isActiveStep = itemState === 'active' ||
|
|
1567
|
-
itemState === 'current' ||
|
|
1568
|
-
itemState === 'in_progress' ||
|
|
1569
|
-
normalizedIcon === 'sync' ||
|
|
1570
|
-
normalizedIcon === 'pending' ||
|
|
1571
|
-
normalizedIcon === 'pending_actions' ||
|
|
1572
|
-
normalizedIcon === 'schedule' ||
|
|
1573
|
-
(!itemState && itemTone === 'warning');
|
|
1574
|
-
const stepReadout = `${index + 1}/${items.length} · ${itemLabel}`;
|
|
1575
|
-
const connector = !isLast ? `<span class="pfx-micro-step__connector" data-tone="${escapeHtml(itemTone)}"></span>` : '';
|
|
1576
|
-
const stepCircle = `
|
|
1577
|
-
<span class="pfx-micro-step__node" data-tone="${escapeHtml(itemTone)}"${isActiveStep ? ' data-active="true"' : ''} aria-hidden="true">
|
|
1578
|
-
${normalizedIcon ? `<span class="material-icons pfx-micro-step__icon" aria-hidden="true">${escapeHtml(normalizedIcon)}</span>` : `${index + 1}`}
|
|
1579
|
-
</span>`;
|
|
1580
|
-
return `
|
|
1581
|
-
<div class="pfx-micro-step" data-state="${escapeHtml(itemState)}" data-tone="${escapeHtml(itemTone)}">
|
|
1582
|
-
<div class="pfx-micro-step__node-wrapper" data-micro-readout="${escapeHtml(stepReadout)}" title="${escapeHtml(itemLabel)}">
|
|
1583
|
-
${stepCircle}
|
|
1584
|
-
${label}
|
|
1585
|
-
</div>
|
|
1586
|
-
${connector}
|
|
1587
|
-
</div>`;
|
|
1588
|
-
}).join('');
|
|
1589
|
-
return `
|
|
1590
|
-
<span class="pfx-micro-viz pfx-micro-viz__process" role="img" aria-label="${escapeHtml(aria)}">
|
|
1591
|
-
${stepsHtml}
|
|
1592
|
-
</span>`;
|
|
1593
|
-
}
|
|
1594
873
|
function formatPraxisWaterfallSignedValue(value, role, options = {}, compactValue = false, suffix = '') {
|
|
1595
874
|
const absFormatted = formatVisualizationMetricValue(Math.abs(Number.isFinite(value) ? value : 0), options, compactValue, suffix);
|
|
1596
875
|
if (role === 'start' || role === 'subtotal' || role === 'total') {
|
|
@@ -1719,90 +998,6 @@ function resolvePraxisMicroWaterfallSteps(visualization, options = {}) {
|
|
|
1719
998
|
}
|
|
1720
999
|
return steps;
|
|
1721
1000
|
}
|
|
1722
|
-
function renderWaterfallVisualizationHtml(visualization, options) {
|
|
1723
|
-
const steps = resolvePraxisMicroWaterfallSteps(visualization, options);
|
|
1724
|
-
const fallbackTone = visualization.tone ?? 'info';
|
|
1725
|
-
if (steps.length === 0) {
|
|
1726
|
-
return renderFallbackVisualizationHtml(visualization, fallbackTone);
|
|
1727
|
-
}
|
|
1728
|
-
const width = 100;
|
|
1729
|
-
const height = 32;
|
|
1730
|
-
const xPad = 4;
|
|
1731
|
-
const yPad = 4;
|
|
1732
|
-
const plotHeight = height - 2 * yPad;
|
|
1733
|
-
const minVal = Math.min(0, ...steps.flatMap((s) => [s.start, s.end]));
|
|
1734
|
-
const maxVal = Math.max(0, ...steps.flatMap((s) => [s.start, s.end]));
|
|
1735
|
-
const span = Math.max(1e-6, maxVal - minVal);
|
|
1736
|
-
const yFor = (val) => yPad + (1 - (val - minVal) / span) * plotHeight;
|
|
1737
|
-
const slotW = (width - 2 * xPad) / steps.length;
|
|
1738
|
-
const barW = Math.max(3, Math.min(18, slotW * 0.64));
|
|
1739
|
-
const barOffset = (slotW - barW) / 2;
|
|
1740
|
-
const barsHtml = [];
|
|
1741
|
-
const connectorsHtml = [];
|
|
1742
|
-
const scrubSlicesHtml = [];
|
|
1743
|
-
for (let i = 0; i < steps.length; i++) {
|
|
1744
|
-
const step = steps[i];
|
|
1745
|
-
const x = xPad + i * slotW + barOffset;
|
|
1746
|
-
const yStart = yFor(step.start);
|
|
1747
|
-
const yEnd = yFor(step.end);
|
|
1748
|
-
const topY = Math.min(yStart, yEnd);
|
|
1749
|
-
const rectH = Math.max(2, Math.abs(yEnd - yStart));
|
|
1750
|
-
const clampedY = Math.min(height - yPad - 2, topY);
|
|
1751
|
-
const styleAttr = step.color ? ` style="color:${escapeHtml(step.color)}"` : '';
|
|
1752
|
-
barsHtml.push(`<rect class="pfx-micro-waterfall__bar" x="${x.toFixed(1)}" y="${clampedY.toFixed(1)}" width="${barW.toFixed(1)}" height="${rectH.toFixed(1)}" rx="1.5" fill="currentColor" data-role="${escapeHtml(step.role)}" data-tone="${escapeHtml(step.tone)}"${styleAttr} />`);
|
|
1753
|
-
if (i < steps.length - 1) {
|
|
1754
|
-
const nextX = xPad + (i + 1) * slotW + barOffset;
|
|
1755
|
-
const connY = step.end > step.start
|
|
1756
|
-
? clampedY
|
|
1757
|
-
: step.end < step.start
|
|
1758
|
-
? clampedY + rectH
|
|
1759
|
-
: Math.min(height - yPad, Math.max(clampedY, Math.min(clampedY + rectH, yEnd)));
|
|
1760
|
-
connectorsHtml.push(`<line class="pfx-micro-waterfall__connector" x1="${(x + barW).toFixed(1)}" y1="${connY.toFixed(1)}" x2="${nextX.toFixed(1)}" y2="${connY.toFixed(1)}" />`);
|
|
1761
|
-
}
|
|
1762
|
-
scrubSlicesHtml.push(`<span class="pfx-micro-waterfall__scrub-slice" data-tone="${escapeHtml(step.tone)}" data-role="${escapeHtml(step.role)}" data-micro-readout="${escapeHtml(step.readout)}" title="${escapeHtml(step.readout)}"></span>`);
|
|
1763
|
-
}
|
|
1764
|
-
const zeroY = yFor(0);
|
|
1765
|
-
const baselineHtml = `<line class="pfx-micro-waterfall__baseline" x1="2" y1="${zeroY.toFixed(1)}" x2="${(width - 2).toFixed(1)}" y2="${zeroY.toFixed(1)}" />`;
|
|
1766
|
-
const isTable = visualization.surface === 'table-cell';
|
|
1767
|
-
const firstStep = steps[0];
|
|
1768
|
-
const lastStep = steps[steps.length - 1];
|
|
1769
|
-
const aria = visualization.ariaLabel
|
|
1770
|
-
?? `${visualization.fallbackText}: ${steps.map((s) => s.readout).join('; ')}`;
|
|
1771
|
-
const startSummaryHtml = !isTable && firstStep
|
|
1772
|
-
? `<div class="pfx-micro-trend__label-col pfx-micro-trend__label-col--start">
|
|
1773
|
-
<span class="pfx-micro-trend__value">${escapeHtml(firstStep.signedText)}</span>
|
|
1774
|
-
<span class="pfx-micro-trend__label">${escapeHtml(firstStep.label)}</span>
|
|
1775
|
-
</div>`
|
|
1776
|
-
: '';
|
|
1777
|
-
const endSummaryHtml = !isTable && lastStep && steps.length > 1
|
|
1778
|
-
? `<div class="pfx-micro-trend__label-col pfx-micro-trend__label-col--end">
|
|
1779
|
-
<span class="pfx-micro-trend__value">${escapeHtml(lastStep.signedText)}</span>
|
|
1780
|
-
<span class="pfx-micro-trend__label">${escapeHtml(lastStep.label)}</span>
|
|
1781
|
-
</div>`
|
|
1782
|
-
: '';
|
|
1783
|
-
return `
|
|
1784
|
-
<span class="pfx-micro-viz-container">
|
|
1785
|
-
${startSummaryHtml}
|
|
1786
|
-
<span class="pfx-micro-viz pfx-micro-viz__waterfall" data-tone="${escapeHtml(fallbackTone)}" role="img" aria-label="${escapeHtml(aria)}">
|
|
1787
|
-
<svg class="pfx-micro-waterfall__svg" viewBox="0 0 ${width} ${height}" preserveAspectRatio="none">
|
|
1788
|
-
${baselineHtml}
|
|
1789
|
-
${connectorsHtml.join('')}
|
|
1790
|
-
${barsHtml.join('')}
|
|
1791
|
-
</svg>
|
|
1792
|
-
<span class="pfx-micro-waterfall__scrub-layer">${scrubSlicesHtml.join('')}</span>
|
|
1793
|
-
</span>
|
|
1794
|
-
${endSummaryHtml}
|
|
1795
|
-
</span>`;
|
|
1796
|
-
}
|
|
1797
|
-
function renderFallbackVisualizationHtml(visualization, tone) {
|
|
1798
|
-
return `
|
|
1799
|
-
<span
|
|
1800
|
-
class="pfx-micro-viz pfx-micro-viz__fallback"
|
|
1801
|
-
data-tone="${escapeHtml(tone)}"
|
|
1802
|
-
role="img"
|
|
1803
|
-
aria-label="${escapeHtml(visualization.ariaLabel ?? visualization.fallbackText)}"
|
|
1804
|
-
>${escapeHtml(visualization.fallbackText)}</span>`;
|
|
1805
|
-
}
|
|
1806
1001
|
|
|
1807
1002
|
const PRAXIS_QUICK_VIEW_PRESENTER = new InjectionToken('PRAXIS_QUICK_VIEW_PRESENTER');
|
|
1808
1003
|
const PRAXIS_QUICK_VIEW_BODY_RENDERER = new InjectionToken('PRAXIS_QUICK_VIEW_BODY_RENDERER');
|
|
@@ -2276,11 +1471,19 @@ function resolveQuickViewAnchorKey(anchor) {
|
|
|
2276
1471
|
|
|
2277
1472
|
const TONES = new Set([
|
|
2278
1473
|
'neutral',
|
|
1474
|
+
'primary',
|
|
1475
|
+
'secondary',
|
|
2279
1476
|
'info',
|
|
2280
1477
|
'success',
|
|
2281
1478
|
'warning',
|
|
2282
1479
|
'danger',
|
|
2283
1480
|
]);
|
|
1481
|
+
const TONE_ALIASES = {
|
|
1482
|
+
muted: 'neutral',
|
|
1483
|
+
positive: 'success',
|
|
1484
|
+
critical: 'danger',
|
|
1485
|
+
negative: 'danger',
|
|
1486
|
+
};
|
|
2284
1487
|
const APPEARANCES = new Set([
|
|
2285
1488
|
'plain',
|
|
2286
1489
|
'soft',
|
|
@@ -2317,6 +1520,9 @@ function resolveFieldPresentation(base, rules, context = {}, options = {}) {
|
|
|
2317
1520
|
...effect,
|
|
2318
1521
|
};
|
|
2319
1522
|
matchedRule = true;
|
|
1523
|
+
if (options.matchPolicy === 'first') {
|
|
1524
|
+
break;
|
|
1525
|
+
}
|
|
2320
1526
|
}
|
|
2321
1527
|
return matchedRule ? { ...resolved, matchedRule } : resolved;
|
|
2322
1528
|
}
|
|
@@ -2331,8 +1537,8 @@ function normalizeFieldPresentation(value) {
|
|
|
2331
1537
|
const label = normalizeText(value.label);
|
|
2332
1538
|
const badge = normalizeText(value.badge);
|
|
2333
1539
|
const tooltip = normalizeText(value.tooltip);
|
|
2334
|
-
const prefix =
|
|
2335
|
-
const suffix =
|
|
1540
|
+
const prefix = normalizeAffix$1(value.prefix);
|
|
1541
|
+
const suffix = normalizeAffix$1(value.suffix);
|
|
2336
1542
|
const iconTrue = normalizeText(value.iconTrue);
|
|
2337
1543
|
const iconFalse = normalizeText(value.iconFalse);
|
|
2338
1544
|
const toneTrue = normalizeTone(value.toneTrue);
|
|
@@ -2365,6 +1571,42 @@ function normalizeFieldPresentation(value) {
|
|
|
2365
1571
|
: {}),
|
|
2366
1572
|
};
|
|
2367
1573
|
}
|
|
1574
|
+
function normalizeFieldPresentationRules(value) {
|
|
1575
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
1576
|
+
return undefined;
|
|
1577
|
+
}
|
|
1578
|
+
const normalized = [];
|
|
1579
|
+
for (const candidate of value) {
|
|
1580
|
+
if (!candidate || typeof candidate !== 'object' || Array.isArray(candidate)) {
|
|
1581
|
+
continue;
|
|
1582
|
+
}
|
|
1583
|
+
const rule = candidate;
|
|
1584
|
+
if (!Object.prototype.hasOwnProperty.call(rule, 'when')) {
|
|
1585
|
+
continue;
|
|
1586
|
+
}
|
|
1587
|
+
const when = rule['when'];
|
|
1588
|
+
if (when === undefined) {
|
|
1589
|
+
continue;
|
|
1590
|
+
}
|
|
1591
|
+
const normalizedSet = rule['set'] && typeof rule['set'] === 'object' && !Array.isArray(rule['set'])
|
|
1592
|
+
? normalizeFieldPresentation(rule['set'])
|
|
1593
|
+
: undefined;
|
|
1594
|
+
const normalizedEffect = rule['effect'] && typeof rule['effect'] === 'object' && !Array.isArray(rule['effect'])
|
|
1595
|
+
? normalizeFieldPresentation(rule['effect'])
|
|
1596
|
+
: undefined;
|
|
1597
|
+
const hasSet = !!normalizedSet && Object.keys(normalizedSet).length > 0;
|
|
1598
|
+
const hasEffect = !!normalizedEffect && Object.keys(normalizedEffect).length > 0;
|
|
1599
|
+
if (!hasSet && !hasEffect) {
|
|
1600
|
+
continue;
|
|
1601
|
+
}
|
|
1602
|
+
normalized.push({
|
|
1603
|
+
when,
|
|
1604
|
+
...(hasSet ? { set: normalizedSet } : {}),
|
|
1605
|
+
...(hasEffect ? { effect: normalizedEffect } : {}),
|
|
1606
|
+
});
|
|
1607
|
+
}
|
|
1608
|
+
return normalized.length > 0 ? normalized : undefined;
|
|
1609
|
+
}
|
|
2368
1610
|
function matchesPresentationRule(rule, context, jsonLogic) {
|
|
2369
1611
|
try {
|
|
2370
1612
|
const result = jsonLogic.evaluate(rule.when, context);
|
|
@@ -2380,7 +1622,79 @@ function normalizePresenter(value) {
|
|
|
2380
1622
|
return normalizeEnum(value, PRESENTERS);
|
|
2381
1623
|
}
|
|
2382
1624
|
function normalizeTone(value) {
|
|
2383
|
-
|
|
1625
|
+
if (typeof value !== 'string') {
|
|
1626
|
+
return undefined;
|
|
1627
|
+
}
|
|
1628
|
+
const normalized = value.trim().toLowerCase();
|
|
1629
|
+
if (!normalized) {
|
|
1630
|
+
return undefined;
|
|
1631
|
+
}
|
|
1632
|
+
if (TONES.has(normalized)) {
|
|
1633
|
+
return normalized;
|
|
1634
|
+
}
|
|
1635
|
+
return TONE_ALIASES[normalized];
|
|
1636
|
+
}
|
|
1637
|
+
const MASKED_TOKEN_SYMBOL_REGEX = /\*{2,}|•{2,}|■{2,}|█{2,}/;
|
|
1638
|
+
const MASKED_TOKEN_LABEL_REGEX = /^\[?\s*(MASKED|REDACTED|PROTEGIDO|OCULTO|ANONIMIZADO)\s*\]?$/i;
|
|
1639
|
+
/**
|
|
1640
|
+
* Identifies masked or redacted display values produced by privacy/LGPD governance policies.
|
|
1641
|
+
*/
|
|
1642
|
+
function isMaskedPresentationToken(value) {
|
|
1643
|
+
if (value === null || value === undefined) {
|
|
1644
|
+
return false;
|
|
1645
|
+
}
|
|
1646
|
+
const candidate = String(value).trim();
|
|
1647
|
+
if (!candidate) {
|
|
1648
|
+
return false;
|
|
1649
|
+
}
|
|
1650
|
+
return MASKED_TOKEN_SYMBOL_REGEX.test(candidate) || MASKED_TOKEN_LABEL_REGEX.test(candidate);
|
|
1651
|
+
}
|
|
1652
|
+
/**
|
|
1653
|
+
* Resolves visual prefix/suffix affixes around non-empty display text while:
|
|
1654
|
+
* - returning `null` for null/blank text (preventing orphan affixes),
|
|
1655
|
+
* - suppressing affixes on LGPD-masked tokens,
|
|
1656
|
+
* - avoiding affix duplication when the formatted text already carries the affix.
|
|
1657
|
+
*/
|
|
1658
|
+
function resolveAffixedPresentationParts(rawText, affixes) {
|
|
1659
|
+
if (rawText === null || rawText === undefined) {
|
|
1660
|
+
return null;
|
|
1661
|
+
}
|
|
1662
|
+
const text = String(rawText).trim();
|
|
1663
|
+
if (!text) {
|
|
1664
|
+
return null;
|
|
1665
|
+
}
|
|
1666
|
+
if (isMaskedPresentationToken(text)) {
|
|
1667
|
+
return {
|
|
1668
|
+
text,
|
|
1669
|
+
prefix: null,
|
|
1670
|
+
suffix: null,
|
|
1671
|
+
masked: true,
|
|
1672
|
+
};
|
|
1673
|
+
}
|
|
1674
|
+
const candidatePrefix = typeof affixes?.prefix === 'string' && affixes.prefix.trim().length > 0
|
|
1675
|
+
? affixes.prefix
|
|
1676
|
+
: null;
|
|
1677
|
+
const candidateSuffix = typeof affixes?.suffix === 'string' && affixes.suffix.trim().length > 0
|
|
1678
|
+
? affixes.suffix
|
|
1679
|
+
: null;
|
|
1680
|
+
const prefix = candidatePrefix && !text.startsWith(candidatePrefix) ? candidatePrefix : null;
|
|
1681
|
+
const suffix = candidateSuffix && !text.endsWith(candidateSuffix) ? candidateSuffix : null;
|
|
1682
|
+
return {
|
|
1683
|
+
text,
|
|
1684
|
+
prefix,
|
|
1685
|
+
suffix,
|
|
1686
|
+
masked: false,
|
|
1687
|
+
};
|
|
1688
|
+
}
|
|
1689
|
+
/**
|
|
1690
|
+
* Formats non-empty display text with deduplicated visual affixes, omitting affixes on masked tokens.
|
|
1691
|
+
*/
|
|
1692
|
+
function formatAffixedPresentationText(rawText, affixes) {
|
|
1693
|
+
const parts = resolveAffixedPresentationParts(rawText, affixes);
|
|
1694
|
+
if (!parts) {
|
|
1695
|
+
return null;
|
|
1696
|
+
}
|
|
1697
|
+
return `${parts.prefix ?? ''}${parts.text}${parts.suffix ?? ''}`;
|
|
2384
1698
|
}
|
|
2385
1699
|
function normalizeAppearance(value) {
|
|
2386
1700
|
return normalizeEnum(value, APPEARANCES);
|
|
@@ -2399,6 +1713,9 @@ function normalizeText(value) {
|
|
|
2399
1713
|
const trimmed = value.trim();
|
|
2400
1714
|
return trimmed.length ? trimmed : undefined;
|
|
2401
1715
|
}
|
|
1716
|
+
function normalizeAffix$1(value) {
|
|
1717
|
+
return typeof value === 'string' && value.trim().length > 0 ? value : undefined;
|
|
1718
|
+
}
|
|
2402
1719
|
function normalizeInteractions(value) {
|
|
2403
1720
|
const quickView = normalizeResourceQuickViewBinding(value.quickView);
|
|
2404
1721
|
return {
|
|
@@ -4668,6 +3985,10 @@ class SchemaNormalizationKernel {
|
|
|
4668
3985
|
if (Object.keys(presentation).length > 0) {
|
|
4669
3986
|
field.presentation = presentation;
|
|
4670
3987
|
}
|
|
3988
|
+
const presentationRules = normalizeFieldPresentationRules(ui.presentationRules);
|
|
3989
|
+
if (presentationRules?.length) {
|
|
3990
|
+
field.presentationRules = presentationRules;
|
|
3991
|
+
}
|
|
4671
3992
|
if (ui.controlType) {
|
|
4672
3993
|
field.controlType = ui.controlType;
|
|
4673
3994
|
}
|
|
@@ -5818,6 +5139,7 @@ function buildBaseColumnFromDef(def) {
|
|
|
5818
5139
|
const format = resolveFormatFromFieldDefinition(def, type);
|
|
5819
5140
|
const valueMapping = resolveSchemaValueMappingFromFieldDefinition(def);
|
|
5820
5141
|
const renderer = resolveRendererFromFieldDefinition(def);
|
|
5142
|
+
const conditionalRenderers = resolveConditionalRenderersFromFieldDefinition(def);
|
|
5821
5143
|
const quickView = resolveQuickViewFromFieldDefinition(def);
|
|
5822
5144
|
const isAvatar = renderer?.type === 'avatar';
|
|
5823
5145
|
const explicitWidth = firstNonEmptyString(def.width);
|
|
@@ -5842,6 +5164,7 @@ function buildBaseColumnFromDef(def) {
|
|
|
5842
5164
|
...(format ? { format } : {}),
|
|
5843
5165
|
...(valueMapping ? { valueMapping } : {}),
|
|
5844
5166
|
...(renderer ? { renderer } : {}),
|
|
5167
|
+
...(conditionalRenderers?.length ? { conditionalRenderers } : {}),
|
|
5845
5168
|
...(quickView ? { quickView } : {}),
|
|
5846
5169
|
};
|
|
5847
5170
|
}
|
|
@@ -5881,13 +5204,28 @@ function applyLocalCustomizations(baseCol, localCol) {
|
|
|
5881
5204
|
result.format = localCol.format ?? baseCol.format;
|
|
5882
5205
|
result.valueMapping = localCol.valueMapping ?? baseCol.valueMapping;
|
|
5883
5206
|
result.renderer = normalizeColumnRendererQuickView(localCol.renderer ?? baseCol.renderer);
|
|
5207
|
+
const resolvedConditionalRenderers = localCol.conditionalRenderers?.length
|
|
5208
|
+
? localCol.conditionalRenderers
|
|
5209
|
+
: baseCol.conditionalRenderers;
|
|
5210
|
+
if (resolvedConditionalRenderers?.length) {
|
|
5211
|
+
result.conditionalRenderers = resolvedConditionalRenderers;
|
|
5212
|
+
}
|
|
5213
|
+
else {
|
|
5214
|
+
delete result.conditionalRenderers;
|
|
5215
|
+
}
|
|
5884
5216
|
}
|
|
5885
5217
|
else {
|
|
5886
5218
|
// Drop local presentation that may be incompatible with the new server type,
|
|
5887
5219
|
// but keep canonical server presentation for the resolved type.
|
|
5888
5220
|
result.format = baseCol.format;
|
|
5889
5221
|
result.valueMapping = baseCol.valueMapping;
|
|
5890
|
-
result.renderer =
|
|
5222
|
+
result.renderer = normalizeColumnRendererQuickView(baseCol.renderer);
|
|
5223
|
+
if (baseCol.conditionalRenderers?.length) {
|
|
5224
|
+
result.conditionalRenderers = baseCol.conditionalRenderers;
|
|
5225
|
+
}
|
|
5226
|
+
else {
|
|
5227
|
+
delete result.conditionalRenderers;
|
|
5228
|
+
}
|
|
5891
5229
|
}
|
|
5892
5230
|
return result;
|
|
5893
5231
|
}
|
|
@@ -6274,8 +5612,14 @@ function resolveRendererFromFieldDefinition(def) {
|
|
|
6274
5612
|
}
|
|
6275
5613
|
return undefined;
|
|
6276
5614
|
}
|
|
6277
|
-
function
|
|
6278
|
-
|
|
5615
|
+
function resolveSchemaConditionalRenderers(def, options) {
|
|
5616
|
+
return resolveConditionalRenderersFromFieldDefinition(def, options);
|
|
5617
|
+
}
|
|
5618
|
+
function buildSchemaSemanticColumnRenderer(def, presentationOverride, options) {
|
|
5619
|
+
return resolveRendererFromFieldPresentation(def, presentationOverride, options);
|
|
5620
|
+
}
|
|
5621
|
+
function resolveRendererFromFieldPresentation(def, presentationOverride, options) {
|
|
5622
|
+
const presentation = presentationOverride ?? def.presentation;
|
|
6279
5623
|
if (!presentation || typeof presentation !== 'object')
|
|
6280
5624
|
return undefined;
|
|
6281
5625
|
if (presentation.presenter === 'microVisualization' &&
|
|
@@ -6294,15 +5638,28 @@ function resolveRendererFromFieldPresentation(def) {
|
|
|
6294
5638
|
const tooltipText = firstNonEmptyString(presentation.tooltip);
|
|
6295
5639
|
const tooltip = tooltipText ? { text: tooltipText } : undefined;
|
|
6296
5640
|
const fixedText = firstNonEmptyString(presentation.label);
|
|
5641
|
+
const affixes = resolveSemanticPresentationAffixes(presentation);
|
|
5642
|
+
const includeUndefinedFields = options?.includeUndefinedBadgeChipFields === true;
|
|
5643
|
+
const includeUndefinedText = options?.includeUndefinedBadgeChipText === true;
|
|
5644
|
+
const allowTextPresenterAsIconValue = options?.allowTextPresenterAsIconValue !== false;
|
|
6297
5645
|
if (presenter === 'chip') {
|
|
6298
5646
|
return {
|
|
6299
5647
|
type: 'chip',
|
|
6300
5648
|
chip: {
|
|
6301
|
-
...(
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
5649
|
+
...(includeUndefinedText
|
|
5650
|
+
? { text: fixedText }
|
|
5651
|
+
: fixedText !== undefined
|
|
5652
|
+
? { text: fixedText }
|
|
5653
|
+
: {}),
|
|
5654
|
+
textField: fixedText ? undefined : def.name,
|
|
5655
|
+
...(includeUndefinedFields ? { color, icon, variant, tooltip } : {
|
|
5656
|
+
...(color ? { color } : {}),
|
|
5657
|
+
...(variant ? { variant } : {}),
|
|
5658
|
+
...(icon ? { icon } : {}),
|
|
5659
|
+
...(tooltip ? { tooltip } : {}),
|
|
5660
|
+
}),
|
|
5661
|
+
...(affixes.prefix ? { prefix: affixes.prefix } : {}),
|
|
5662
|
+
...(affixes.suffix ? { suffix: affixes.suffix } : {}),
|
|
6306
5663
|
},
|
|
6307
5664
|
};
|
|
6308
5665
|
}
|
|
@@ -6310,11 +5667,20 @@ function resolveRendererFromFieldPresentation(def) {
|
|
|
6310
5667
|
return {
|
|
6311
5668
|
type: 'badge',
|
|
6312
5669
|
badge: {
|
|
6313
|
-
...(
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
5670
|
+
...(includeUndefinedText
|
|
5671
|
+
? { text: fixedText }
|
|
5672
|
+
: fixedText !== undefined
|
|
5673
|
+
? { text: fixedText }
|
|
5674
|
+
: {}),
|
|
5675
|
+
textField: fixedText ? undefined : def.name,
|
|
5676
|
+
...(includeUndefinedFields ? { color, icon, variant, tooltip } : {
|
|
5677
|
+
...(color ? { color } : {}),
|
|
5678
|
+
...(variant ? { variant } : {}),
|
|
5679
|
+
...(icon ? { icon } : {}),
|
|
5680
|
+
...(tooltip ? { tooltip } : {}),
|
|
5681
|
+
}),
|
|
5682
|
+
...(affixes.prefix ? { prefix: affixes.prefix } : {}),
|
|
5683
|
+
...(affixes.suffix ? { suffix: affixes.suffix } : {}),
|
|
6318
5684
|
},
|
|
6319
5685
|
};
|
|
6320
5686
|
}
|
|
@@ -6340,9 +5706,9 @@ function resolveRendererFromFieldPresentation(def) {
|
|
|
6340
5706
|
},
|
|
6341
5707
|
};
|
|
6342
5708
|
}
|
|
6343
|
-
if (presenter === 'iconvalue' ||
|
|
5709
|
+
if (presenter === 'iconvalue' ||
|
|
5710
|
+
(allowTextPresenterAsIconValue && (presenter === 'text' || !presenter))) {
|
|
6344
5711
|
const rendererIcon = icon || firstNonEmptyString(def.icon);
|
|
6345
|
-
const affixes = resolveSemanticPresentationAffixes(presentation);
|
|
6346
5712
|
const hasAffixes = !!(affixes.prefix || affixes.suffix);
|
|
6347
5713
|
if (!rendererIcon && !hasAffixes)
|
|
6348
5714
|
return undefined;
|
|
@@ -6354,6 +5720,7 @@ function resolveRendererFromFieldPresentation(def) {
|
|
|
6354
5720
|
textField: def.name,
|
|
6355
5721
|
...(color ? { color } : {}),
|
|
6356
5722
|
...(tooltipText ? { ariaLabel: tooltipText } : {}),
|
|
5723
|
+
...(tooltip ? { tooltip } : {}),
|
|
6357
5724
|
...affixes,
|
|
6358
5725
|
},
|
|
6359
5726
|
};
|
|
@@ -6387,14 +5754,52 @@ function resolveRendererFromFieldPresentation(def) {
|
|
|
6387
5754
|
}
|
|
6388
5755
|
return undefined;
|
|
6389
5756
|
}
|
|
5757
|
+
function resolveConditionalRenderersFromFieldDefinition(def, options) {
|
|
5758
|
+
const rules = def.presentationRules;
|
|
5759
|
+
if (!Array.isArray(rules) || rules.length === 0)
|
|
5760
|
+
return undefined;
|
|
5761
|
+
const basePresentation = def.presentation && typeof def.presentation === 'object' ? def.presentation : {};
|
|
5762
|
+
const basePresenter = basePresentation.presenter ?? basePresentation.variant;
|
|
5763
|
+
const out = [];
|
|
5764
|
+
rules.forEach((rule, index) => {
|
|
5765
|
+
if (!rule || typeof rule !== 'object' || rule.when === undefined)
|
|
5766
|
+
return;
|
|
5767
|
+
const effect = rule.set ?? rule.effect;
|
|
5768
|
+
if (!effect || typeof effect !== 'object')
|
|
5769
|
+
return;
|
|
5770
|
+
const resolvedPresenter = effect.presenter ?? effect.variant ?? basePresenter;
|
|
5771
|
+
const effectivePresentation = {
|
|
5772
|
+
...basePresentation,
|
|
5773
|
+
...effect,
|
|
5774
|
+
...(resolvedPresenter ? { presenter: resolvedPresenter } : {}),
|
|
5775
|
+
};
|
|
5776
|
+
const renderer = resolveRendererFromFieldPresentation(def, effectivePresentation, options);
|
|
5777
|
+
const tooltipText = firstNonEmptyString(effectivePresentation.tooltip);
|
|
5778
|
+
const tooltip = tooltipText ? { text: tooltipText } : undefined;
|
|
5779
|
+
if (!renderer && !tooltip)
|
|
5780
|
+
return;
|
|
5781
|
+
out.push({
|
|
5782
|
+
id: `schema-presentation-rule-${index}`,
|
|
5783
|
+
condition: rule.when,
|
|
5784
|
+
...(renderer ? { renderer } : {}),
|
|
5785
|
+
...(tooltip ? { tooltip } : {}),
|
|
5786
|
+
});
|
|
5787
|
+
});
|
|
5788
|
+
return out.length > 0 ? out : undefined;
|
|
5789
|
+
}
|
|
6390
5790
|
function resolveSemanticPresentationColor(tone) {
|
|
6391
5791
|
const normalized = normalizePresentationToken(tone);
|
|
6392
|
-
if (normalized === 'neutral')
|
|
6393
|
-
return 'basic';
|
|
6394
5792
|
if (!normalized)
|
|
6395
5793
|
return undefined;
|
|
6396
|
-
if (normalized === '
|
|
5794
|
+
if (normalized === 'neutral' || normalized === 'muted')
|
|
5795
|
+
return 'basic';
|
|
5796
|
+
if (normalized === 'positive')
|
|
5797
|
+
return 'success';
|
|
5798
|
+
if (normalized === 'warning')
|
|
5799
|
+
return 'warning';
|
|
5800
|
+
if (normalized === 'danger' || normalized === 'critical' || normalized === 'negative') {
|
|
6397
5801
|
return 'warn';
|
|
5802
|
+
}
|
|
6398
5803
|
return normalized;
|
|
6399
5804
|
}
|
|
6400
5805
|
function resolveSemanticPresentationVariant(appearance) {
|
|
@@ -6407,13 +5812,19 @@ function resolveSemanticPresentationVariant(appearance) {
|
|
|
6407
5812
|
: undefined;
|
|
6408
5813
|
}
|
|
6409
5814
|
function resolveSemanticPresentationAffixes(presentation) {
|
|
6410
|
-
const prefix =
|
|
6411
|
-
const suffix =
|
|
5815
|
+
const prefix = normalizeAffix(presentation.prefix);
|
|
5816
|
+
const suffix = normalizeAffix(presentation.suffix);
|
|
6412
5817
|
return {
|
|
6413
5818
|
...(prefix ? { prefix } : {}),
|
|
6414
5819
|
...(suffix ? { suffix } : {}),
|
|
6415
5820
|
};
|
|
6416
5821
|
}
|
|
5822
|
+
function normalizePresentationAffix(value) {
|
|
5823
|
+
return typeof value === 'string' && value.trim().length > 0 ? value : undefined;
|
|
5824
|
+
}
|
|
5825
|
+
function normalizeAffix(value) {
|
|
5826
|
+
return normalizePresentationAffix(value);
|
|
5827
|
+
}
|
|
6417
5828
|
function firstNonEmptyString(value) {
|
|
6418
5829
|
if (typeof value !== 'string')
|
|
6419
5830
|
return undefined;
|
|
@@ -6460,4 +5871,4 @@ function isTextualControlType(value) {
|
|
|
6460
5871
|
* Generated bundle index. Do not edit.
|
|
6461
5872
|
*/
|
|
6462
5873
|
|
|
6463
|
-
export { deepMerge, isPraxisPresentationVisualizationTableSafe, normalizeSchemaFields, resolveColumnTypeFromFieldDefinition, resolveTextMaskFormatFromFieldDefinition };
|
|
5874
|
+
export { buildSchemaSemanticColumnRenderer, deepMerge, isPraxisPresentationVisualizationTableSafe, normalizePresentationAffix, normalizeSchemaFields, resolveColumnTypeFromFieldDefinition, resolveSchemaConditionalRenderers, resolveTextMaskFormatFromFieldDefinition };
|