@ids-group-ltd/ids-design-system 0.13.1 → 0.13.3
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/CHANGELOG.md +626 -0
- package/components.md +17 -9
- package/docs/agent/INDEX.md +1 -1
- package/docs/agent/charts/ds-column-chart.md +3 -2
- package/docs/agent/charts/ds-line-chart.md +2 -1
- package/docs/agent/feedback/ds-bar.md +13 -0
- package/docs/agent/forms/ds-button.md +1 -1
- package/docs/agent/forms/ds-icon-button.md +1 -1
- package/docs/agent/surfaces/ds-card.md +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-bar-chart.mjs +81 -13
- package/fesm2022/ids-group-ltd-ids-design-system-components-bar-chart.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-bar.mjs +95 -0
- package/fesm2022/ids-group-ltd-ids-design-system-components-bar.mjs.map +1 -0
- package/fesm2022/ids-group-ltd-ids-design-system-components-button.mjs +3 -0
- package/fesm2022/ids-group-ltd-ids-design-system-components-button.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-chart-legend.mjs +47 -5
- package/fesm2022/ids-group-ltd-ids-design-system-components-chart-legend.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-chart-tooltip.mjs +198 -50
- package/fesm2022/ids-group-ltd-ids-design-system-components-chart-tooltip.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-chart.mjs +973 -0
- package/fesm2022/ids-group-ltd-ids-design-system-components-chart.mjs.map +1 -0
- package/fesm2022/ids-group-ltd-ids-design-system-components-column-chart.mjs +172 -111
- package/fesm2022/ids-group-ltd-ids-design-system-components-column-chart.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-donut-chart.mjs +86 -15
- package/fesm2022/ids-group-ltd-ids-design-system-components-donut-chart.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-funnel-chart.mjs +87 -12
- package/fesm2022/ids-group-ltd-ids-design-system-components-funnel-chart.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-line-chart.mjs +193 -98
- package/fesm2022/ids-group-ltd-ids-design-system-components-line-chart.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-table.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-table.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components.mjs +233 -33
- package/fesm2022/ids-group-ltd-ids-design-system-components.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-core.mjs +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-core.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system.mjs +2 -1
- package/fesm2022/ids-group-ltd-ids-design-system.mjs.map +1 -1
- package/migrations/0.13.2.json +269 -0
- package/migrations/0.13.3.json +211 -0
- package/package.json +17 -9
- package/styles/_chart-frame.scss +117 -10
- package/styles/_chart-interactive.scss +12 -3
- package/styles/_overlay-motion.scss +7 -6
- package/styles/_tokens-charts.scss +29 -5
- package/styles/_tokens.scss +1 -1
- package/types/ids-group-ltd-ids-design-system-components-bar-chart.d.ts +68 -5
- package/types/ids-group-ltd-ids-design-system-components-bar.d.ts +63 -0
- package/types/ids-group-ltd-ids-design-system-components-button.d.ts +3 -2
- package/types/ids-group-ltd-ids-design-system-components-chart-legend.d.ts +25 -2
- package/types/ids-group-ltd-ids-design-system-components-chart-tooltip.d.ts +21 -4
- package/types/ids-group-ltd-ids-design-system-components-chart.d.ts +543 -0
- package/types/ids-group-ltd-ids-design-system-components-column-chart.d.ts +125 -37
- package/types/ids-group-ltd-ids-design-system-components-donut-chart.d.ts +43 -4
- package/types/ids-group-ltd-ids-design-system-components-funnel-chart.d.ts +52 -4
- package/types/ids-group-ltd-ids-design-system-components-line-chart.d.ts +90 -23
- package/types/ids-group-ltd-ids-design-system-components.d.ts +91 -16
- package/types/ids-group-ltd-ids-design-system-core.d.ts +73 -6
- package/types/ids-group-ltd-ids-design-system.d.ts +7 -6
- package/docs/agent/feedback/ds-progress.md +0 -7
- package/fesm2022/ids-group-ltd-ids-design-system-components-progress.mjs +0 -41
- package/fesm2022/ids-group-ltd-ids-design-system-components-progress.mjs.map +0 -1
- package/types/ids-group-ltd-ids-design-system-components-progress.d.ts +0 -22
|
@@ -86,6 +86,22 @@ function formatValue(value, locale) {
|
|
|
86
86
|
}
|
|
87
87
|
return numberFormatter(locale).format(value);
|
|
88
88
|
}
|
|
89
|
+
/** The built-in `valueFormat`: compact on a tick (`1.2M`), spelled out everywhere else
|
|
90
|
+
* (`1 248 392`). A caller-supplied formatter receives the same `location` and decides for
|
|
91
|
+
* itself; this is only the default.
|
|
92
|
+
*
|
|
93
|
+
* @internal */
|
|
94
|
+
function defaultChartFormat(value, location) {
|
|
95
|
+
if (!Number.isFinite(value)) {
|
|
96
|
+
return '—';
|
|
97
|
+
}
|
|
98
|
+
return location === 'tick'
|
|
99
|
+
? new Intl.NumberFormat(undefined, {
|
|
100
|
+
notation: 'compact',
|
|
101
|
+
maximumFractionDigits: 1,
|
|
102
|
+
}).format(value)
|
|
103
|
+
: new Intl.NumberFormat().format(value);
|
|
104
|
+
}
|
|
89
105
|
/** @internal */
|
|
90
106
|
function formatPercent(value, total) {
|
|
91
107
|
if (!total || !Number.isFinite(value) || !Number.isFinite(total)) {
|
|
@@ -149,16 +165,14 @@ function formatTick(value, step) {
|
|
|
149
165
|
? `${Math.round(scaled)}${unit.suffix}`
|
|
150
166
|
: `${scaled.toFixed(1)}${unit.suffix}`;
|
|
151
167
|
}
|
|
152
|
-
/** One mark's share of the total its siblings add up to.
|
|
168
|
+
/** One mark's share of the total its siblings add up to, as a bare percentage.
|
|
153
169
|
*
|
|
154
|
-
*
|
|
155
|
-
* that number tells the reader nothing they are not already looking at. The share is arithmetic
|
|
156
|
-
* the reader should not have to do. Empty for a lone mark, and empty for a reading that is not
|
|
170
|
+
* Empty for a lone mark, which is the whole of its own total, and empty for a reading that is not
|
|
157
171
|
* part of a total anyone can see: negatives and non-finite values are excluded from the total
|
|
158
|
-
* rather than subtracted from it.
|
|
172
|
+
* rather than subtracted from it, so a negative mark has no share rather than a misleading one.
|
|
159
173
|
*
|
|
160
174
|
* @internal */
|
|
161
|
-
function
|
|
175
|
+
function shareOfTotal(values, index) {
|
|
162
176
|
const value = values[index];
|
|
163
177
|
if (values.length < 2 || !Number.isFinite(value) || value <= 0) {
|
|
164
178
|
return '';
|
|
@@ -166,7 +180,15 @@ function describeShare(values, index) {
|
|
|
166
180
|
const total = values
|
|
167
181
|
.filter((entry) => Number.isFinite(entry) && entry > 0)
|
|
168
182
|
.reduce((sum, entry) => sum + entry, 0);
|
|
169
|
-
return total > 0 ?
|
|
183
|
+
return total > 0 ? formatPercent(value, total) : '';
|
|
184
|
+
}
|
|
185
|
+
/** The same share, phrased for a tooltip line, where no column header stands above it to say what
|
|
186
|
+
* the percentage is OF.
|
|
187
|
+
*
|
|
188
|
+
* @internal */
|
|
189
|
+
function describeShare(values, index) {
|
|
190
|
+
const share = shareOfTotal(values, index);
|
|
191
|
+
return share ? `${share} of total` : '';
|
|
170
192
|
}
|
|
171
193
|
|
|
172
194
|
/** Container width as a signal. It is 0 under SSR, while the container is
|
|
@@ -186,37 +208,111 @@ function elementWidth(host) {
|
|
|
186
208
|
return width.asReadonly();
|
|
187
209
|
}
|
|
188
210
|
|
|
211
|
+
const COORDINATE_DECIMALS = 2;
|
|
212
|
+
function roundTo(value, decimals) {
|
|
213
|
+
if (!Number.isFinite(value)) {
|
|
214
|
+
return 0;
|
|
215
|
+
}
|
|
216
|
+
return Number(value.toFixed(decimals));
|
|
217
|
+
}
|
|
218
|
+
function isPlottable(point) {
|
|
219
|
+
return Number.isFinite(point.x) && Number.isFinite(point.y);
|
|
220
|
+
}
|
|
221
|
+
function coordinatePair(point) {
|
|
222
|
+
return `${roundTo(point.x, COORDINATE_DECIMALS)},${roundTo(point.y, COORDINATE_DECIMALS)}`;
|
|
223
|
+
}
|
|
224
|
+
/** The unbroken runs of a series: a missing reading ends one run and starts the next.
|
|
225
|
+
*
|
|
226
|
+
* @internal */
|
|
227
|
+
function lineSegments(points) {
|
|
228
|
+
const segments = [];
|
|
229
|
+
let current = [];
|
|
230
|
+
for (const point of points) {
|
|
231
|
+
if (point === null) {
|
|
232
|
+
if (current.length > 0) {
|
|
233
|
+
segments.push(current);
|
|
234
|
+
}
|
|
235
|
+
current = [];
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
current.push(point);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (current.length > 0) {
|
|
242
|
+
segments.push(current);
|
|
243
|
+
}
|
|
244
|
+
return segments;
|
|
245
|
+
}
|
|
246
|
+
/** `''` rather than a partial list when a coordinate is unplottable: one `NaN` in a
|
|
247
|
+
* `points` list or a path `d` voids the whole attribute, and the line then vanishes
|
|
248
|
+
* with nothing logged.
|
|
249
|
+
*
|
|
250
|
+
* @internal */
|
|
251
|
+
function polylinePoints(segment) {
|
|
252
|
+
if (segment.length === 0 || !segment.every(isPlottable)) {
|
|
253
|
+
return '';
|
|
254
|
+
}
|
|
255
|
+
return segment.map((point) => coordinatePair(point)).join(' ');
|
|
256
|
+
}
|
|
257
|
+
/** @internal */
|
|
258
|
+
function areaPath(segment, baselineY) {
|
|
259
|
+
if (segment.length < 2 ||
|
|
260
|
+
!Number.isFinite(baselineY) ||
|
|
261
|
+
!segment.every(isPlottable)) {
|
|
262
|
+
return '';
|
|
263
|
+
}
|
|
264
|
+
const first = segment[0];
|
|
265
|
+
const last = segment[segment.length - 1];
|
|
266
|
+
const along = segment.map((point) => coordinatePair(point)).join(' L ');
|
|
267
|
+
const baseline = roundTo(baselineY, COORDINATE_DECIMALS);
|
|
268
|
+
return `M ${along} L ${roundTo(last.x, COORDINATE_DECIMALS)},${baseline} L ${roundTo(first.x, COORDINATE_DECIMALS)},${baseline} Z`;
|
|
269
|
+
}
|
|
270
|
+
|
|
189
271
|
const E10 = Math.sqrt(50);
|
|
190
272
|
const E5 = Math.sqrt(10);
|
|
191
273
|
const E2 = Math.sqrt(2);
|
|
192
|
-
/** d3's tick-increment rule. A naive `
|
|
274
|
+
/** d3's tick-increment rule. A naive `span / count` produces steps like 482, which
|
|
193
275
|
* no reader parses; this snaps to 1, 2, 5 or 10 times a power of ten. */
|
|
194
|
-
function tickIncrement(
|
|
195
|
-
const step =
|
|
276
|
+
function tickIncrement(span, targetCount) {
|
|
277
|
+
const step = span / Math.max(1, targetCount);
|
|
196
278
|
const power = Math.floor(Math.log10(step));
|
|
197
279
|
const error = step / Math.pow(10, power);
|
|
198
280
|
const factor = error >= E10 ? 10 : error >= E5 ? 5 : error >= E2 ? 2 : 1;
|
|
199
281
|
return factor * Math.pow(10, power);
|
|
200
282
|
}
|
|
283
|
+
/** The floor of a domain that has to include zero: zero itself for an all-positive
|
|
284
|
+
* series, and the most negative reading otherwise.
|
|
285
|
+
*
|
|
286
|
+
* @internal */
|
|
287
|
+
function domainMinOf(values) {
|
|
288
|
+
return values.reduce((min, value) => Math.min(min, value), 0);
|
|
289
|
+
}
|
|
201
290
|
/** @internal */
|
|
202
|
-
function tickValues(domainMax, targetCount) {
|
|
203
|
-
|
|
291
|
+
function tickValues(domainMin, domainMax, targetCount) {
|
|
292
|
+
const span = domainMax - domainMin;
|
|
293
|
+
if (!Number.isFinite(span) || span <= 0) {
|
|
204
294
|
return [0];
|
|
205
295
|
}
|
|
206
|
-
const step = tickIncrement(
|
|
296
|
+
const step = tickIncrement(span, targetCount);
|
|
297
|
+
const first = Math.floor(domainMin / step);
|
|
298
|
+
const last = Math.ceil(domainMax / step);
|
|
207
299
|
const out = [];
|
|
208
|
-
for (let i =
|
|
300
|
+
for (let i = first; i <= last; i++) {
|
|
209
301
|
out.push(i * step);
|
|
210
302
|
}
|
|
211
303
|
return out;
|
|
212
304
|
}
|
|
213
305
|
/** @internal */
|
|
214
|
-
function
|
|
215
|
-
|
|
216
|
-
|
|
306
|
+
function niceDomain(domainMin, domainMax, targetCount) {
|
|
307
|
+
const span = domainMax - domainMin;
|
|
308
|
+
if (!Number.isFinite(span) || span <= 0) {
|
|
309
|
+
return { min: 0, max: 0 };
|
|
217
310
|
}
|
|
218
|
-
const step = tickIncrement(
|
|
219
|
-
return
|
|
311
|
+
const step = tickIncrement(span, targetCount);
|
|
312
|
+
return {
|
|
313
|
+
min: Math.floor(domainMin / step) * step,
|
|
314
|
+
max: Math.ceil(domainMax / step) * step,
|
|
315
|
+
};
|
|
220
316
|
}
|
|
221
317
|
/** Distance between two ticks, which `formatTick` needs to pick a precision. A
|
|
222
318
|
* degenerate series yields a single tick and therefore no step.
|
|
@@ -226,11 +322,50 @@ function tickStep(ticks) {
|
|
|
226
322
|
return ticks.length > 1 ? ticks[1] - ticks[0] : 0;
|
|
227
323
|
}
|
|
228
324
|
/** @internal */
|
|
229
|
-
function linearScale(domainMax, rangeSize) {
|
|
230
|
-
|
|
325
|
+
function linearScale(domainMin, domainMax, rangeSize) {
|
|
326
|
+
const span = domainMax - domainMin;
|
|
327
|
+
if (!Number.isFinite(span) || span <= 0) {
|
|
231
328
|
return () => 0;
|
|
232
329
|
}
|
|
233
|
-
return (value) => (value /
|
|
330
|
+
return (value) => ((value - domainMin) / span) * rangeSize;
|
|
331
|
+
}
|
|
332
|
+
/** Positions for marks that sit AT a category rather than inside it — the readings of a line.
|
|
333
|
+
* The first is at the plot's start and the last at its end, so the run fills the axis rather than
|
|
334
|
+
* floating half a slot inside it. A single reading has no run to fill and takes the middle.
|
|
335
|
+
*
|
|
336
|
+
* `step` is the distance between neighbours, which is what a crosshair band is a slot of; at the
|
|
337
|
+
* two ends that slot is half outside the plot and the caller clamps it.
|
|
338
|
+
*
|
|
339
|
+
* @internal */
|
|
340
|
+
function pointScale(count, rangeSize) {
|
|
341
|
+
const total = Number.isFinite(count) && count > 0 ? Math.floor(count) : 0;
|
|
342
|
+
const size = Number.isFinite(rangeSize) && rangeSize > 0 ? rangeSize : 0;
|
|
343
|
+
if (total === 0) {
|
|
344
|
+
return { step: 0, count: 0, position: () => 0, indexAt: () => -1 };
|
|
345
|
+
}
|
|
346
|
+
if (total === 1) {
|
|
347
|
+
return {
|
|
348
|
+
step: size,
|
|
349
|
+
count: 1,
|
|
350
|
+
position: () => size / 2,
|
|
351
|
+
indexAt: () => 0,
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
const step = size / (total - 1);
|
|
355
|
+
return {
|
|
356
|
+
step,
|
|
357
|
+
count: total,
|
|
358
|
+
position: (index) => Math.min(Math.max(index, 0), total - 1) * step,
|
|
359
|
+
// Nearest reading, not the slot the pointer is over: with the ends on the axes the first and
|
|
360
|
+
// last slots are half-width, and rounding is what makes both of them reachable.
|
|
361
|
+
indexAt: (offset) => {
|
|
362
|
+
if (!Number.isFinite(offset) || step === 0) {
|
|
363
|
+
return -1;
|
|
364
|
+
}
|
|
365
|
+
const index = Math.round(offset / step);
|
|
366
|
+
return Math.min(Math.max(index, 0), total - 1);
|
|
367
|
+
},
|
|
368
|
+
};
|
|
234
369
|
}
|
|
235
370
|
/** @internal */
|
|
236
371
|
function bandScale(count, rangeSize, paddingRatio) {
|
|
@@ -253,6 +388,30 @@ function bandScale(count, rangeSize, paddingRatio) {
|
|
|
253
388
|
indexAt: (offset) => Math.min(count - 1, Math.max(0, Math.floor(offset / step))),
|
|
254
389
|
};
|
|
255
390
|
}
|
|
391
|
+
const ROUND_STEP_FACTORS = [1, 2, 5, 10];
|
|
392
|
+
// A step divided out of a domain and multiplied back rarely lands on itself, so a
|
|
393
|
+
// candidate equal to the minimum can compare as smaller by one bit and push the
|
|
394
|
+
// whole axis up a rung.
|
|
395
|
+
const ROUND_STEP_TOLERANCE = 1 - 1e-12;
|
|
396
|
+
/** The smallest 1/2/5/10 x power-of-ten step that is not below `minimumStep`.
|
|
397
|
+
* `niceDomain` picks its own number of intervals, so it cannot answer this: a second
|
|
398
|
+
* axis drawn against the first's gridlines has to reach its data within the intervals
|
|
399
|
+
* the first already drew.
|
|
400
|
+
*
|
|
401
|
+
* @internal */
|
|
402
|
+
function roundStepAtLeast(minimumStep) {
|
|
403
|
+
if (!Number.isFinite(minimumStep) || minimumStep <= 0) {
|
|
404
|
+
return 0;
|
|
405
|
+
}
|
|
406
|
+
const base = Math.pow(10, Math.floor(Math.log10(minimumStep)));
|
|
407
|
+
for (const factor of ROUND_STEP_FACTORS) {
|
|
408
|
+
const candidate = factor * base;
|
|
409
|
+
if (candidate >= minimumStep * ROUND_STEP_TOLERANCE) {
|
|
410
|
+
return candidate;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return 10 * base;
|
|
414
|
+
}
|
|
256
415
|
|
|
257
416
|
// Past this the entrance stops reading as one gesture and starts reading as a queue: at 40ms a
|
|
258
417
|
// 100-mark series would otherwise take four seconds to finish arriving.
|
|
@@ -293,13 +452,19 @@ function nextRovingIndex(key, current, count) {
|
|
|
293
452
|
return null;
|
|
294
453
|
}
|
|
295
454
|
}
|
|
455
|
+
/** The mark `index` within `scope`. `within` narrows the search for a chart whose marks repeat the
|
|
456
|
+
* same index once per series.
|
|
457
|
+
*
|
|
458
|
+
* @internal */
|
|
459
|
+
function markAt(scope, index, within = '') {
|
|
460
|
+
return scope?.querySelector(`${within}[data-mark-index="${index}"]`) ?? null;
|
|
461
|
+
}
|
|
296
462
|
/** Moves DOM focus to the mark `index` within `scope`, which is what makes the roving tabindex a
|
|
297
|
-
* traversal rather than a state change nobody can see.
|
|
298
|
-
* whose marks repeat the same index once per series.
|
|
463
|
+
* traversal rather than a state change nobody can see.
|
|
299
464
|
*
|
|
300
465
|
* @internal */
|
|
301
466
|
function focusMark(scope, index, within = '') {
|
|
302
|
-
const target = scope
|
|
467
|
+
const target = markAt(scope, index, within);
|
|
303
468
|
if (target instanceof HTMLElement || target instanceof SVGElement) {
|
|
304
469
|
target.focus();
|
|
305
470
|
}
|
|
@@ -324,6 +489,26 @@ function trendOf(values) {
|
|
|
324
489
|
}
|
|
325
490
|
return 'Ending where it started';
|
|
326
491
|
}
|
|
492
|
+
/** Where the readings sit against each reference line, appended to the description. A line the
|
|
493
|
+
* reader cannot see is a line that does not exist for them, and its whole point is the
|
|
494
|
+
* comparison, not its position. */
|
|
495
|
+
function describeThresholds(thresholds, points, format) {
|
|
496
|
+
const total = points.length;
|
|
497
|
+
const noun = total === 1 ? 'point' : 'points';
|
|
498
|
+
return thresholds
|
|
499
|
+
.map((threshold) => {
|
|
500
|
+
const name = threshold.label ?? 'Threshold';
|
|
501
|
+
if (threshold.to == null) {
|
|
502
|
+
const above = points.filter((point) => point.value > threshold.value).length;
|
|
503
|
+
return ` ${name} at ${format(threshold.value)}, ${above} of ${total} ${noun} above.`;
|
|
504
|
+
}
|
|
505
|
+
const low = Math.min(threshold.value, threshold.to);
|
|
506
|
+
const high = Math.max(threshold.value, threshold.to);
|
|
507
|
+
const inside = points.filter((point) => point.value >= low && point.value <= high).length;
|
|
508
|
+
return ` ${name} from ${format(low)} to ${format(high)}, ${inside} of ${total} ${noun} inside.`;
|
|
509
|
+
})
|
|
510
|
+
.join('');
|
|
511
|
+
}
|
|
327
512
|
/** The sentence a screen reader gets as the chart's accessible name. Generated rather than
|
|
328
513
|
* required, because a required one is a field that gets left at the component's default and then
|
|
329
514
|
* lies.
|
|
@@ -333,11 +518,12 @@ function trendOf(values) {
|
|
|
333
518
|
* levels of chart description, and the encoding is the one thing a screen-reader user cannot use.
|
|
334
519
|
*
|
|
335
520
|
* @internal */
|
|
336
|
-
function describeSeries(label, points, format = formatValue, tableFollows = true) {
|
|
337
|
-
const pointer = tableFollows ? ' Full values in the table below.' : '';
|
|
521
|
+
function describeSeries(label, points, format = formatValue, tableFollows = true, thresholds = []) {
|
|
338
522
|
if (points.length === 0) {
|
|
339
523
|
return `${label}. No data.`;
|
|
340
524
|
}
|
|
525
|
+
const pointer = describeThresholds(thresholds, points, format) +
|
|
526
|
+
(tableFollows ? ' Full values in the table below.' : '');
|
|
341
527
|
if (points.length === 1) {
|
|
342
528
|
return `${label}, one point: ${format(points[0].value)} at ${points[0].label}.${pointer}`;
|
|
343
529
|
}
|
|
@@ -546,12 +732,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImpo
|
|
|
546
732
|
* whether it was bound. Precedence: the component input, then
|
|
547
733
|
* `DS_CONFIG.field.reserveMessage`, then `false`.
|
|
548
734
|
*
|
|
735
|
+
* `appWideDefaultApplies` is read lazily and drops the middle step for a control that
|
|
736
|
+
* is not a form row: `ds-button` renders the same message line but does not sit in a
|
|
737
|
+
* field column, so an app-wide field setting must not give it an empty row.
|
|
738
|
+
*
|
|
549
739
|
* Call from a field initializer (an injection context), e.g.
|
|
550
740
|
* `protected readonly reserve = resolveReserveMessage(this.reserveMessage);`
|
|
551
741
|
*/
|
|
552
|
-
function resolveReserveMessage(reserveMessage) {
|
|
742
|
+
function resolveReserveMessage(reserveMessage, appWideDefaultApplies = () => true) {
|
|
553
743
|
const config = inject(DS_CONFIG);
|
|
554
|
-
return computed(() => reserveMessage() ??
|
|
744
|
+
return computed(() => reserveMessage() ??
|
|
745
|
+
(appWideDefaultApplies()
|
|
746
|
+
? (config.field?.reserveMessage ?? false)
|
|
747
|
+
: false));
|
|
555
748
|
}
|
|
556
749
|
|
|
557
750
|
const NO_ERRORS = [];
|
|
@@ -785,13 +978,20 @@ class DsMessageBase {
|
|
|
785
978
|
/** Advisory text, shown when there is no error. */
|
|
786
979
|
warning = input('', { ...(ngDevMode ? { debugName: "warning" } : /* istanbul ignore next */ {}), transform: trimmedText });
|
|
787
980
|
/** Reserve the message-row height even when empty, so the control doesn't shift
|
|
788
|
-
* the layout below it when a hint/error appears.
|
|
789
|
-
* `
|
|
981
|
+
* the layout below it when a hint/error appears. What an unset value falls back
|
|
982
|
+
* to is the subclass's call, in `reserveMessageResolved`: a field takes
|
|
983
|
+
* `DS_CONFIG.field.reserveMessage`, a button does not. */
|
|
790
984
|
reserveMessage = input(null, { ...(ngDevMode ? { debugName: "reserveMessage" } : /* istanbul ignore next */ {}), transform: (value) => (value == null ? null : booleanAttribute(value)) });
|
|
791
985
|
/** Glyph on the message line, overriding what the state resolves to. Unset
|
|
792
986
|
* follows `DS_CONFIG.field.stateIcons`; `false` removes the glyph here alone. */
|
|
793
987
|
messageIcon = input(null, ...(ngDevMode ? [{ debugName: "messageIcon" }] : /* istanbul ignore next */ []));
|
|
794
|
-
|
|
988
|
+
/** Whether an unset `reserveMessage` falls back to `DS_CONFIG.field.reserveMessage`.
|
|
989
|
+
* True for a field, whose row reserves so its neighbours do not shift; `ds-button`
|
|
990
|
+
* turns it off, because a button is not in that column and an app-wide field
|
|
991
|
+
* setting would otherwise give every button an empty message row. Read lazily, so
|
|
992
|
+
* a subclass initializer running after this one still decides it. */
|
|
993
|
+
reserveFollowsFieldDefault = true;
|
|
994
|
+
reserveMessageResolved = resolveReserveMessage(this.reserveMessage, () => this.reserveFollowsFieldDefault);
|
|
795
995
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: DsMessageBase, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
796
996
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.22", type: DsMessageBase, isStandalone: true, inputs: { hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, warning: { classPropertyName: "warning", publicName: "warning", isSignal: true, isRequired: false, transformFunction: null }, reserveMessage: { classPropertyName: "reserveMessage", publicName: "reserveMessage", isSignal: true, isRequired: false, transformFunction: null }, messageIcon: { classPropertyName: "messageIcon", publicName: "messageIcon", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
|
|
797
997
|
}
|
|
@@ -1812,5 +2012,5 @@ function createTypeAhead() {
|
|
|
1812
2012
|
* Generated bundle index. Do not edit.
|
|
1813
2013
|
*/
|
|
1814
2014
|
|
|
1815
|
-
export { CHART_RAMP_COLORS, CHART_SERIES_COLORS, DS_FIELD_WARNING_KIND, DsBooleanControlValueAccessor, DsChipTemplateDirective, DsControlValueAccessor, DsCreateTemplateDirective, DsEmptyTemplateDirective, DsFieldBase, DsGroupLabelTemplateDirective, DsMessageBase, DsOptionTemplateDirective, DsPanelFooterTemplateDirective, DsPanelHeaderTemplateDirective, DsPickerTriggerDirective, DsStaticPreview, FieldClickFocusDirective, ProjectionDroppedDirective, announceOptionCount, bandScale, chartColors, chipFit, clearOnDetach, closeOnOutsidePointer, closeOnScroll, createTypeAhead, describeSeries, describeShare, disposeWithLeave, dropdownOverlay, dsAriaCurrent, dsDestination, elementWidth, focusIsInside, focusMark, formatPercent, formatTick, formatValue, forwardOverlayTokens, largestRemainder, linearScale, nextControlId, nextRovingIndex,
|
|
2015
|
+
export { CHART_RAMP_COLORS, CHART_SERIES_COLORS, DS_FIELD_WARNING_KIND, DsBooleanControlValueAccessor, DsChipTemplateDirective, DsControlValueAccessor, DsCreateTemplateDirective, DsEmptyTemplateDirective, DsFieldBase, DsGroupLabelTemplateDirective, DsMessageBase, DsOptionTemplateDirective, DsPanelFooterTemplateDirective, DsPanelHeaderTemplateDirective, DsPickerTriggerDirective, DsStaticPreview, FieldClickFocusDirective, ProjectionDroppedDirective, announceOptionCount, areaPath, bandScale, chartColors, chipFit, clearOnDetach, closeOnOutsidePointer, closeOnScroll, createTypeAhead, defaultChartFormat, describeSeries, describeShare, disposeWithLeave, domainMinOf, dropdownOverlay, dsAriaCurrent, dsDestination, elementWidth, focusIsInside, focusMark, formatPercent, formatTick, formatValue, forwardOverlayTokens, largestRemainder, lineSegments, linearScale, markAt, nextControlId, nextRovingIndex, niceDomain, overlayPlacementOf, panelClassesOf, pointScale, polylinePoints, prepareOverlayEnter, resolveBrandValue, resolveFieldMessage, roundStepAtLeast, scrollActiveOptionIntoView, shareOfTotal, staggerDelay, tickStep, tickValues, trimmedText, valueControlBridge };
|
|
1816
2016
|
//# sourceMappingURL=ids-group-ltd-ids-design-system-components.mjs.map
|