@adaptabletools/adaptable-cjs 23.0.0-canary.7 → 23.0.0-canary.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.css +75 -9
- package/package.json +1 -1
- package/src/AdaptableState/StyledColumnState.d.ts +8 -850
- package/src/AdaptableState/StyledColumnState.js +0 -10
- package/src/AdaptableState/StyledColumns/BadgeStyle.d.ts +143 -0
- package/src/AdaptableState/StyledColumns/BadgeStyle.js +12 -0
- package/src/AdaptableState/StyledColumns/BulletChartStyle.d.ts +147 -0
- package/src/AdaptableState/StyledColumns/BulletChartStyle.js +2 -0
- package/src/AdaptableState/StyledColumns/Common/BarChartCellText.d.ts +60 -0
- package/src/AdaptableState/StyledColumns/Common/BarChartCellText.js +7 -0
- package/src/AdaptableState/StyledColumns/Common/BarChartMarker.d.ts +24 -0
- package/src/AdaptableState/StyledColumns/Common/BarChartMarker.js +6 -0
- package/src/AdaptableState/StyledColumns/Common/CellTextOptions.d.ts +13 -0
- package/src/AdaptableState/StyledColumns/Common/CellTextOptions.js +7 -0
- package/src/AdaptableState/StyledColumns/Common/NumericStyledColumn.d.ts +79 -0
- package/src/AdaptableState/StyledColumns/Common/NumericStyledColumn.js +10 -0
- package/src/AdaptableState/StyledColumns/GradientStyle.d.ts +48 -0
- package/src/AdaptableState/StyledColumns/GradientStyle.js +2 -0
- package/src/AdaptableState/StyledColumns/IconStyle.d.ts +158 -0
- package/src/AdaptableState/StyledColumns/IconStyle.js +2 -0
- package/src/AdaptableState/StyledColumns/PercentBarStyle.d.ts +32 -0
- package/src/AdaptableState/StyledColumns/PercentBarStyle.js +2 -0
- package/src/AdaptableState/StyledColumns/RangeBarStyle.d.ts +155 -0
- package/src/AdaptableState/StyledColumns/RangeBarStyle.js +2 -0
- package/src/AdaptableState/StyledColumns/RatingStyle.d.ts +111 -0
- package/src/AdaptableState/StyledColumns/RatingStyle.js +2 -0
- package/src/AdaptableState/StyledColumns/SparklineStyle.d.ts +21 -0
- package/src/AdaptableState/StyledColumns/SparklineStyle.js +2 -0
- package/src/Api/ColumnScopeApi.d.ts +1 -1
- package/src/Api/Implementation/ColumnScopeApiImpl.d.ts +1 -1
- package/src/Api/Internal/StyledColumnInternalApi.d.ts +3 -1
- package/src/Utilities/Helpers/IconStylePresets.d.ts +1 -1
- package/src/Utilities/Helpers/StyledColumnGradientHelper.d.ts +3 -1
- package/src/Utilities/Helpers/barChartCellText.d.ts +63 -0
- package/src/Utilities/Helpers/barChartCellText.js +333 -0
- package/src/Utilities/Helpers/percentBarPreviewHelper.d.ts +2 -1
- package/src/Utilities/Helpers/percentBarPreviewHelper.js +3 -8
- package/src/View/Alert/Wizard/AlertButtonsEditor.js +158 -125
- package/src/View/Alert/Wizard/AlertNotificationWizardSection.js +1 -1
- package/src/View/Alert/Wizard/AlertWizard.js +9 -1
- package/src/View/Components/AdaptableObjectList/AdaptableObjectCompactList.js +3 -2
- package/src/View/Components/AdaptableObjectList/AdaptableObjectList.js +3 -2
- package/src/View/Components/AdaptableObjectList/objectListActionButtonStyles.d.ts +2 -0
- package/src/View/Components/AdaptableObjectList/objectListActionButtonStyles.js +6 -0
- package/src/View/Components/Buttons/EntityListActionButtons.js +1 -1
- package/src/View/Components/Buttons/SuspendToggleButton/SuspendToggleButton.d.ts +1 -0
- package/src/View/Components/Buttons/SuspendToggleButton/SuspendToggleButton.js +8 -8
- package/src/View/Components/ColumnFilter/ColumnFilter.js +14 -1
- package/src/View/Components/Popups/AdaptablePopup/AdaptablePopupModuleView.js +1 -1
- package/src/View/Components/RangesComponent.d.ts +2 -1
- package/src/View/Export/ExportSchedulesTab.js +3 -4
- package/src/View/Filter/FilterViewPanel.js +1 -1
- package/src/View/Layout/Wizard/sections/RowSummarySection.js +128 -102
- package/src/View/StyledColumn/Wizard/BadgePillStyleEditor.d.ts +1 -1
- package/src/View/StyledColumn/Wizard/StyledColumnBadgeSection.js +36 -30
- package/src/View/StyledColumn/Wizard/StyledColumnSliceStyleEditors.d.ts +1 -3
- package/src/View/StyledColumn/Wizard/StyledColumnWizardBulletSection.js +73 -58
- package/src/View/StyledColumn/Wizard/StyledColumnWizardIconSection.js +38 -11
- package/src/View/StyledColumn/Wizard/StyledColumnWizardRangeBarSection.js +86 -44
- package/src/View/StyledColumn/Wizard/StyledColumnWizardStyleSection/Components/BarChartCellTextLayoutEditor.d.ts +9 -0
- package/src/View/StyledColumn/Wizard/StyledColumnWizardStyleSection/Components/BarChartCellTextLayoutEditor.js +40 -0
- package/src/View/StyledColumn/Wizard/StyledColumnWizardStyleSection/Components/BarChartCellTextPreview.d.ts +23 -0
- package/src/View/StyledColumn/Wizard/StyledColumnWizardStyleSection/Components/BarChartCellTextPreview.js +62 -0
- package/src/View/StyledColumn/Wizard/StyledColumnWizardStyleSection/Components/BulletRangesSummaryPreview.d.ts +1 -1
- package/src/View/StyledColumn/Wizard/StyledColumnWizardStyleSection/Components/GradientSummaryPreview.d.ts +2 -1
- package/src/View/StyledColumn/Wizard/StyledColumnWizardStyleSection/Components/RangeBarRangesSummaryPreview.d.ts +1 -1
- package/src/View/StyledColumn/Wizard/StyledColumnWizardStyleSection/Components/StyledColumnBadgePreview.js +3 -2
- package/src/View/StyledColumn/Wizard/StyledColumnWizardStyleSection/Components/StyledColumnBulletPreview.d.ts +2 -1
- package/src/View/StyledColumn/Wizard/StyledColumnWizardStyleSection/Components/StyledColumnBulletPreview.js +13 -17
- package/src/View/StyledColumn/Wizard/StyledColumnWizardStyleSection/Components/StyledColumnChartListPreviews.d.ts +2 -1
- package/src/View/StyledColumn/Wizard/StyledColumnWizardStyleSection/Components/StyledColumnChartListPreviews.js +5 -5
- package/src/View/StyledColumn/Wizard/StyledColumnWizardStyleSection/Components/StyledColumnIconPreview.js +2 -2
- package/src/View/StyledColumn/Wizard/StyledColumnWizardStyleSection/Components/StyledColumnPercentBarPreview.js +13 -6
- package/src/View/StyledColumn/Wizard/StyledColumnWizardStyleSection/Components/StyledColumnRangeBarPreview.js +11 -17
- package/src/View/StyledColumn/Wizard/StyledColumnWizardStyleSection/Components/StyledColumnRatingPreview.d.ts +2 -1
- package/src/View/StyledColumn/Wizard/StyledColumnWizardStyleSection/StyledColumnWizardStyleSection.js +18 -54
- package/src/agGrid/AgGridColumnAdapter.js +2 -1
- package/src/agGrid/cellRenderers/BadgeRenderer.js +7 -5
- package/src/agGrid/cellRenderers/BulletChartRenderer.js +43 -42
- package/src/agGrid/cellRenderers/IconRenderer.d.ts +2 -1
- package/src/agGrid/cellRenderers/IconRenderer.js +13 -11
- package/src/agGrid/cellRenderers/PercentBarRenderer.js +24 -96
- package/src/agGrid/cellRenderers/RangeBarRenderer.js +49 -46
- package/src/env.js +2 -2
- package/src/metamodel/adaptable.metamodel.d.ts +80 -14
- package/src/metamodel/adaptable.metamodel.js +1 -1
- package/src/migration/VersionUpgrade23.d.ts +27 -31
- package/src/migration/VersionUpgrade23.js +110 -29
- package/src/types.d.ts +12 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mountBarChartCellText = exports.formatBarChartCellTextLayoutSummary = exports.getBarChartCellTextSlotPresence = exports.resolveBarChartCellTextSlots = exports.joinBarChartCellTextLabels = exports.hasBarChartCellTextLabels = exports.buildBarChartCellTextLabels = exports.toggleBarChartCellTextToken = exports.patchBarChartCellTextPlacement = exports.setBarChartCellTextPlacement = exports.mergeBarChartCellTextProperties = exports.getActiveBarChartCellTextTokens = exports.hasBarChartCellTextConfigured = exports.resolveBarChartCellTextLayout = void 0;
|
|
4
|
+
/** Default placement applied to a value whose Horizontal/Vertical were omitted. */
|
|
5
|
+
const DEFAULT_PLACEMENT = {
|
|
6
|
+
Horizontal: 'Left',
|
|
7
|
+
Vertical: 'Below',
|
|
8
|
+
};
|
|
9
|
+
const HORIZONTAL_VALUES = ['Left', 'Center', 'Right'];
|
|
10
|
+
const VERTICAL_VALUES = ['Above', 'Below', 'Merged'];
|
|
11
|
+
const isHorizontal = (value) => typeof value === 'string' &&
|
|
12
|
+
HORIZONTAL_VALUES.includes(value);
|
|
13
|
+
const isVertical = (value) => typeof value === 'string' && VERTICAL_VALUES.includes(value);
|
|
14
|
+
/** Normalise a placement, applying defaults for missing axes. */
|
|
15
|
+
const sanitizePlacement = (placement) => ({
|
|
16
|
+
Horizontal: isHorizontal(placement?.Horizontal) ? placement.Horizontal : DEFAULT_PLACEMENT.Horizontal,
|
|
17
|
+
Vertical: isVertical(placement?.Vertical) ? placement.Vertical : DEFAULT_PLACEMENT.Vertical,
|
|
18
|
+
});
|
|
19
|
+
/** Returns a layout with only the values that are actually present, defaults filled in. */
|
|
20
|
+
const sanitizeCellTextLayout = (layout) => {
|
|
21
|
+
const result = {};
|
|
22
|
+
if (layout?.CellValue) {
|
|
23
|
+
result.CellValue = sanitizePlacement(layout.CellValue);
|
|
24
|
+
}
|
|
25
|
+
if (layout?.PercentValue) {
|
|
26
|
+
result.PercentValue = sanitizePlacement(layout.PercentValue);
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
const resolveBarChartCellTextLayout = (props) => sanitizeCellTextLayout(props?.CellTextLayout);
|
|
31
|
+
exports.resolveBarChartCellTextLayout = resolveBarChartCellTextLayout;
|
|
32
|
+
/** True when any value is configured for display. */
|
|
33
|
+
const hasBarChartCellTextConfigured = (props) => {
|
|
34
|
+
const layout = (0, exports.resolveBarChartCellTextLayout)(props);
|
|
35
|
+
return Boolean(layout.CellValue || layout.PercentValue);
|
|
36
|
+
};
|
|
37
|
+
exports.hasBarChartCellTextConfigured = hasBarChartCellTextConfigured;
|
|
38
|
+
/** Set of value tokens that currently have a placement. */
|
|
39
|
+
const getActiveBarChartCellTextTokens = (props) => {
|
|
40
|
+
const layout = (0, exports.resolveBarChartCellTextLayout)(props);
|
|
41
|
+
const tokens = [];
|
|
42
|
+
if (layout.CellValue) {
|
|
43
|
+
tokens.push('CellValue');
|
|
44
|
+
}
|
|
45
|
+
if (layout.PercentValue) {
|
|
46
|
+
tokens.push('PercentageValue');
|
|
47
|
+
}
|
|
48
|
+
return tokens;
|
|
49
|
+
};
|
|
50
|
+
exports.getActiveBarChartCellTextTokens = getActiveBarChartCellTextTokens;
|
|
51
|
+
const mergeBarChartCellTextProperties = (current, patch) => {
|
|
52
|
+
const merged = { ...current, ...patch };
|
|
53
|
+
if (merged.CellTextLayout) {
|
|
54
|
+
merged.CellTextLayout = sanitizeCellTextLayout(merged.CellTextLayout);
|
|
55
|
+
if (!merged.CellTextLayout.CellValue && !merged.CellTextLayout.PercentValue) {
|
|
56
|
+
delete merged.CellTextLayout;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (!merged.CellTextLayout) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
return merged;
|
|
63
|
+
};
|
|
64
|
+
exports.mergeBarChartCellTextProperties = mergeBarChartCellTextProperties;
|
|
65
|
+
/**
|
|
66
|
+
* Set or clear a value's placement. Passing `placement: undefined` removes the value.
|
|
67
|
+
*/
|
|
68
|
+
const setBarChartCellTextPlacement = (current, token, placement) => {
|
|
69
|
+
const layout = (0, exports.resolveBarChartCellTextLayout)(current);
|
|
70
|
+
const next = { ...layout };
|
|
71
|
+
const key = token === 'CellValue' ? 'CellValue' : 'PercentValue';
|
|
72
|
+
if (placement) {
|
|
73
|
+
next[key] = sanitizePlacement(placement);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
delete next[key];
|
|
77
|
+
}
|
|
78
|
+
return (0, exports.mergeBarChartCellTextProperties)(current, { CellTextLayout: next });
|
|
79
|
+
};
|
|
80
|
+
exports.setBarChartCellTextPlacement = setBarChartCellTextPlacement;
|
|
81
|
+
/**
|
|
82
|
+
* Patch a single axis of a value's placement (creating the value with defaults if
|
|
83
|
+
* needed). Used by the wizard's placement pickers.
|
|
84
|
+
*/
|
|
85
|
+
const patchBarChartCellTextPlacement = (current, token, patch) => {
|
|
86
|
+
const layout = (0, exports.resolveBarChartCellTextLayout)(current);
|
|
87
|
+
const key = token === 'CellValue' ? 'CellValue' : 'PercentValue';
|
|
88
|
+
const existing = layout[key];
|
|
89
|
+
const nextPlacement = {
|
|
90
|
+
...(existing ?? DEFAULT_PLACEMENT),
|
|
91
|
+
...patch,
|
|
92
|
+
};
|
|
93
|
+
return (0, exports.setBarChartCellTextPlacement)(current, token, nextPlacement);
|
|
94
|
+
};
|
|
95
|
+
exports.patchBarChartCellTextPlacement = patchBarChartCellTextPlacement;
|
|
96
|
+
/**
|
|
97
|
+
* Toggle whether a value is displayed. When turning on a previously-hidden
|
|
98
|
+
* value we use the default placement (Left / Below).
|
|
99
|
+
*/
|
|
100
|
+
const toggleBarChartCellTextToken = (current, token, show) => {
|
|
101
|
+
const layout = (0, exports.resolveBarChartCellTextLayout)(current);
|
|
102
|
+
const key = token === 'CellValue' ? 'CellValue' : 'PercentValue';
|
|
103
|
+
if (show && !layout[key]) {
|
|
104
|
+
return {
|
|
105
|
+
CellTextProperties: (0, exports.setBarChartCellTextPlacement)(current, token, DEFAULT_PLACEMENT),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
if (!show && layout[key]) {
|
|
109
|
+
return {
|
|
110
|
+
CellTextProperties: (0, exports.setBarChartCellTextPlacement)(current, token, undefined),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return { CellTextProperties: current };
|
|
114
|
+
};
|
|
115
|
+
exports.toggleBarChartCellTextToken = toggleBarChartCellTextToken;
|
|
116
|
+
const buildBarChartCellTextLabels = (props, cellValueLabel, percentageLabel) => {
|
|
117
|
+
const layout = (0, exports.resolveBarChartCellTextLayout)(props);
|
|
118
|
+
const labels = {};
|
|
119
|
+
if (layout.CellValue && cellValueLabel != undefined) {
|
|
120
|
+
labels.cellValue = cellValueLabel;
|
|
121
|
+
}
|
|
122
|
+
if (layout.PercentValue && percentageLabel != undefined) {
|
|
123
|
+
labels.percentage = percentageLabel;
|
|
124
|
+
}
|
|
125
|
+
return labels;
|
|
126
|
+
};
|
|
127
|
+
exports.buildBarChartCellTextLabels = buildBarChartCellTextLabels;
|
|
128
|
+
const hasBarChartCellTextLabels = (labels) => Boolean(labels.cellValue || labels.percentage);
|
|
129
|
+
exports.hasBarChartCellTextLabels = hasBarChartCellTextLabels;
|
|
130
|
+
/** Join active labels with a space, Cell Value first then Percent Value. */
|
|
131
|
+
const joinBarChartCellTextLabels = (labels) => {
|
|
132
|
+
const parts = [];
|
|
133
|
+
if (labels.cellValue)
|
|
134
|
+
parts.push(labels.cellValue);
|
|
135
|
+
if (labels.percentage)
|
|
136
|
+
parts.push(labels.percentage);
|
|
137
|
+
return parts.join(' ');
|
|
138
|
+
};
|
|
139
|
+
exports.joinBarChartCellTextLabels = joinBarChartCellTextLabels;
|
|
140
|
+
/**
|
|
141
|
+
* Resolve which placements are populated and what text goes in each cell of
|
|
142
|
+
* the 3 × 3 grid. Empty slots are omitted. Two values landing on the same
|
|
143
|
+
* (vertical, horizontal) slot are concatenated with a single space, Cell
|
|
144
|
+
* Value before Percent Value.
|
|
145
|
+
*/
|
|
146
|
+
const resolveBarChartCellTextSlots = (props, labels) => {
|
|
147
|
+
const layout = (0, exports.resolveBarChartCellTextLayout)(props);
|
|
148
|
+
// Iteration order matters when both values share a slot: Cell Value first,
|
|
149
|
+
// then Percent Value (matches the legacy "joined" behaviour).
|
|
150
|
+
const candidates = [];
|
|
151
|
+
if (layout.CellValue && labels.cellValue) {
|
|
152
|
+
candidates.push({
|
|
153
|
+
placement: sanitizePlacement(layout.CellValue),
|
|
154
|
+
text: labels.cellValue,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
if (layout.PercentValue && labels.percentage) {
|
|
158
|
+
candidates.push({
|
|
159
|
+
placement: sanitizePlacement(layout.PercentValue),
|
|
160
|
+
text: labels.percentage,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
const slotMap = new Map();
|
|
164
|
+
for (const { placement, text } of candidates) {
|
|
165
|
+
const key = `${placement.Vertical}|${placement.Horizontal}`;
|
|
166
|
+
const existing = slotMap.get(key);
|
|
167
|
+
if (existing) {
|
|
168
|
+
existing.parts.push(text);
|
|
169
|
+
existing.text = existing.parts.join(' ');
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
slotMap.set(key, {
|
|
173
|
+
vertical: placement.Vertical,
|
|
174
|
+
horizontal: placement.Horizontal,
|
|
175
|
+
parts: [text],
|
|
176
|
+
text,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return Array.from(slotMap.values());
|
|
181
|
+
};
|
|
182
|
+
exports.resolveBarChartCellTextSlots = resolveBarChartCellTextSlots;
|
|
183
|
+
const getBarChartCellTextSlotPresence = (props) => {
|
|
184
|
+
const layout = (0, exports.resolveBarChartCellTextLayout)(props);
|
|
185
|
+
const verticals = new Set();
|
|
186
|
+
if (layout.CellValue)
|
|
187
|
+
verticals.add(sanitizePlacement(layout.CellValue).Vertical);
|
|
188
|
+
if (layout.PercentValue)
|
|
189
|
+
verticals.add(sanitizePlacement(layout.PercentValue).Vertical);
|
|
190
|
+
return {
|
|
191
|
+
hasAbove: verticals.has('Above'),
|
|
192
|
+
hasBelow: verticals.has('Below'),
|
|
193
|
+
hasMerged: verticals.has('Merged'),
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
exports.getBarChartCellTextSlotPresence = getBarChartCellTextSlotPresence;
|
|
197
|
+
// ---------------------------------------------------------------------------
|
|
198
|
+
// Summary formatting
|
|
199
|
+
// ---------------------------------------------------------------------------
|
|
200
|
+
const HORIZONTAL_LABEL = {
|
|
201
|
+
Left: 'Left',
|
|
202
|
+
Center: 'Center',
|
|
203
|
+
Right: 'Right',
|
|
204
|
+
};
|
|
205
|
+
const VERTICAL_LABEL = {
|
|
206
|
+
Above: 'Above',
|
|
207
|
+
Below: 'Below',
|
|
208
|
+
Merged: 'Merged',
|
|
209
|
+
};
|
|
210
|
+
const formatTokenLabel = (token) => token === 'CellValue' ? 'Cell Value' : 'Percent Value';
|
|
211
|
+
const formatPlacementSummary = (placement) => {
|
|
212
|
+
const { Horizontal, Vertical } = sanitizePlacement(placement);
|
|
213
|
+
return `${VERTICAL_LABEL[Vertical]}-${HORIZONTAL_LABEL[Horizontal]}`;
|
|
214
|
+
};
|
|
215
|
+
const formatBarChartCellTextLayoutSummary = (layout) => {
|
|
216
|
+
const parts = [];
|
|
217
|
+
if (layout.CellValue) {
|
|
218
|
+
parts.push(`${formatTokenLabel('CellValue')}: ${formatPlacementSummary(layout.CellValue)}`);
|
|
219
|
+
}
|
|
220
|
+
if (layout.PercentValue) {
|
|
221
|
+
parts.push(`${formatTokenLabel('PercentageValue')}: ${formatPlacementSummary(layout.PercentValue)}`);
|
|
222
|
+
}
|
|
223
|
+
return parts.length ? parts.join('; ') : undefined;
|
|
224
|
+
};
|
|
225
|
+
exports.formatBarChartCellTextLayoutSummary = formatBarChartCellTextLayoutSummary;
|
|
226
|
+
// ---------------------------------------------------------------------------
|
|
227
|
+
// DOM mount
|
|
228
|
+
// ---------------------------------------------------------------------------
|
|
229
|
+
const HORIZONTAL_FLEX_JUSTIFY = {
|
|
230
|
+
Left: 'flex-start',
|
|
231
|
+
Center: 'center',
|
|
232
|
+
Right: 'flex-end',
|
|
233
|
+
};
|
|
234
|
+
const HORIZONTAL_TEXT_ALIGN = {
|
|
235
|
+
Left: 'left',
|
|
236
|
+
Center: 'center',
|
|
237
|
+
Right: 'right',
|
|
238
|
+
};
|
|
239
|
+
const createCellTextRow = (slots, textClassName, compact) => {
|
|
240
|
+
const row = document.createElement('div');
|
|
241
|
+
row.className = textClassName;
|
|
242
|
+
row.style.display = 'flex';
|
|
243
|
+
row.style.flexDirection = 'row';
|
|
244
|
+
row.style.alignItems = 'center';
|
|
245
|
+
row.style.width = '100%';
|
|
246
|
+
// When `Above` AND `Below` are both populated, two default-size text rows
|
|
247
|
+
// would squeeze the bar to 0 on a standard ~28-40px cell, so the caller
|
|
248
|
+
// asks for a compact band (smaller font + tighter line-height).
|
|
249
|
+
// Otherwise we render at the inherited cell font for legibility.
|
|
250
|
+
if (compact) {
|
|
251
|
+
row.style.fontSize = '0.75em';
|
|
252
|
+
row.style.lineHeight = '1';
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
row.style.lineHeight = '1.2';
|
|
256
|
+
}
|
|
257
|
+
row.style.flex = '0 0 auto';
|
|
258
|
+
row.style.gap = '4px';
|
|
259
|
+
// Render fixed Left / Center / Right cells so spacing is stable even when
|
|
260
|
+
// only one or two slots are present.
|
|
261
|
+
for (const horizontal of HORIZONTAL_VALUES) {
|
|
262
|
+
const slot = slots.find((s) => s.horizontal === horizontal);
|
|
263
|
+
const cell = document.createElement('span');
|
|
264
|
+
cell.style.flex = '1';
|
|
265
|
+
cell.style.minWidth = '0';
|
|
266
|
+
cell.style.textAlign = HORIZONTAL_TEXT_ALIGN[horizontal];
|
|
267
|
+
cell.style.display = 'flex';
|
|
268
|
+
cell.style.justifyContent = HORIZONTAL_FLEX_JUSTIFY[horizontal];
|
|
269
|
+
cell.style.alignItems = 'center';
|
|
270
|
+
if (slot) {
|
|
271
|
+
cell.textContent = slot.text;
|
|
272
|
+
}
|
|
273
|
+
row.append(cell);
|
|
274
|
+
}
|
|
275
|
+
// Suppress the dummy row in the rare case where every slot for this band is
|
|
276
|
+
// empty (e.g. the only label is empty string). `String(...)` because text
|
|
277
|
+
// may arrive as a number when `params.formatValue` is undefined for a
|
|
278
|
+
// numeric column — `(11).length` is `undefined`, which would otherwise
|
|
279
|
+
// wrongly trip the empty-row branch.
|
|
280
|
+
if (!slots.some((s) => String(s.text ?? '').length)) {
|
|
281
|
+
row.style.display = 'none';
|
|
282
|
+
}
|
|
283
|
+
return row;
|
|
284
|
+
};
|
|
285
|
+
const mountBarChartCellText = (args) => {
|
|
286
|
+
const { cellTextProperties, labels, wrapperEl, textClassName } = args;
|
|
287
|
+
if (!(0, exports.hasBarChartCellTextConfigured)(cellTextProperties) || !(0, exports.hasBarChartCellTextLabels)(labels)) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const slots = (0, exports.resolveBarChartCellTextSlots)(cellTextProperties, labels);
|
|
291
|
+
if (!slots.length) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const mergedOverlayEl = args.mergedOverlayEl ?? wrapperEl;
|
|
295
|
+
const mergedPointerEventsNone = args.mergedPointerEventsNone ?? mergedOverlayEl === wrapperEl;
|
|
296
|
+
const slotsByVertical = {
|
|
297
|
+
Above: slots.filter((s) => s.vertical === 'Above'),
|
|
298
|
+
Below: slots.filter((s) => s.vertical === 'Below'),
|
|
299
|
+
Merged: slots.filter((s) => s.vertical === 'Merged'),
|
|
300
|
+
};
|
|
301
|
+
// Compact when Cell Value and Percent Value have *different* verticals
|
|
302
|
+
// (i.e. the two tokens claim two separate bands of vertical space). When
|
|
303
|
+
// they share a vertical band — or when only one token is configured —
|
|
304
|
+
// we have room for the full-size font.
|
|
305
|
+
const layout = (0, exports.resolveBarChartCellTextLayout)(cellTextProperties);
|
|
306
|
+
const compact = Boolean(layout.CellValue &&
|
|
307
|
+
layout.PercentValue &&
|
|
308
|
+
sanitizePlacement(layout.CellValue).Vertical !==
|
|
309
|
+
sanitizePlacement(layout.PercentValue).Vertical);
|
|
310
|
+
if (slotsByVertical.Above.length) {
|
|
311
|
+
const row = createCellTextRow(slotsByVertical.Above, textClassName, compact);
|
|
312
|
+
wrapperEl.prepend(row);
|
|
313
|
+
}
|
|
314
|
+
if (slotsByVertical.Below.length) {
|
|
315
|
+
const row = createCellTextRow(slotsByVertical.Below, textClassName, compact);
|
|
316
|
+
wrapperEl.append(row);
|
|
317
|
+
}
|
|
318
|
+
if (slotsByVertical.Merged.length) {
|
|
319
|
+
const row = createCellTextRow(slotsByVertical.Merged, textClassName, compact);
|
|
320
|
+
row.style.position = 'absolute';
|
|
321
|
+
row.style.top = '50%';
|
|
322
|
+
row.style.transform = 'translateY(-50%)';
|
|
323
|
+
row.style.left = '0';
|
|
324
|
+
row.style.right = '0';
|
|
325
|
+
row.style.paddingLeft = '5px';
|
|
326
|
+
row.style.paddingRight = '5px';
|
|
327
|
+
if (mergedPointerEventsNone) {
|
|
328
|
+
row.style.pointerEvents = 'none';
|
|
329
|
+
}
|
|
330
|
+
mergedOverlayEl.append(row);
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
exports.mountBarChartCellText = mountBarChartCellText;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StyledColumn } from '../../AdaptableState/StyledColumnState';
|
|
2
|
+
import { PercentBarStyle } from '../../AdaptableState/StyledColumns/PercentBarStyle';
|
|
2
3
|
export declare const hasPercentBarRangesConfigured: (pb: PercentBarStyle | undefined) => boolean;
|
|
3
4
|
/** Illustrative scale for preview — shows negatives when origin is Auto or Zero. */
|
|
4
5
|
export declare const getPercentBarPreviewScale: (pb: PercentBarStyle) => {
|
|
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const StyleHelper_1 = require("./StyleHelper");
|
|
6
6
|
const clamp_1 = tslib_1.__importDefault(require("../utils/clamp"));
|
|
7
7
|
const StyledColumnGradientHelper_1 = require("./StyledColumnGradientHelper");
|
|
8
|
+
const barChartCellText_1 = require("./barChartCellText");
|
|
8
9
|
const evenlySpacedValues = (min, max, count) => {
|
|
9
10
|
if (count <= 1) {
|
|
10
11
|
return [min];
|
|
@@ -132,14 +133,8 @@ const getPercentBarPreviewGeometry = (numericValue, pb, min, max) => {
|
|
|
132
133
|
};
|
|
133
134
|
exports.getPercentBarPreviewGeometry = getPercentBarPreviewGeometry;
|
|
134
135
|
const formatPercentBarPreviewCellText = (numericValue, percentageValue, pb) => {
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
parts.push(Number.isInteger(numericValue) ? String(numericValue) : numericValue.toFixed(1));
|
|
138
|
-
}
|
|
139
|
-
if (pb.CellText?.includes('PercentageValue')) {
|
|
140
|
-
parts.push(`${percentageValue.toFixed(0)}%`);
|
|
141
|
-
}
|
|
142
|
-
return parts.join(' ');
|
|
136
|
+
const labels = (0, barChartCellText_1.buildBarChartCellTextLabels)(pb.CellTextProperties, Number.isInteger(numericValue) ? String(numericValue) : numericValue.toFixed(1), `${percentageValue.toFixed(0)}%`);
|
|
137
|
+
return (0, barChartCellText_1.joinBarChartCellTextLabels)(labels);
|
|
143
138
|
};
|
|
144
139
|
exports.formatPercentBarPreviewCellText = formatPercentBarPreviewCellText;
|
|
145
140
|
const getPercentBarPreviewTrackColor = (pb) => {
|