@ids-group-ltd/ids-design-system 0.13.2 → 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 +265 -0
- package/components.md +12 -16
- package/docs/agent/INDEX.md +1 -2
- package/docs/agent/charts/ds-column-chart.md +3 -2
- package/docs/agent/feedback/ds-bar.md +13 -0
- package/fesm2022/ids-group-ltd-ids-design-system-components-bar-chart.mjs +9 -10
- 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-chart-tooltip.mjs +70 -41
- 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 +141 -120
- 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 +42 -11
- 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 +16 -7
- 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 +14 -83
- 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 +163 -21
- 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 -2
- package/fesm2022/ids-group-ltd-ids-design-system.mjs.map +1 -1
- package/migrations/0.13.3.json +211 -0
- package/package.json +17 -17
- package/styles/_chart-frame.scss +16 -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 +2 -1
- 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 +2 -2
- package/types/ids-group-ltd-ids-design-system-components-chart-tooltip.d.ts +7 -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 +95 -38
- package/types/ids-group-ltd-ids-design-system-components-donut-chart.d.ts +15 -2
- package/types/ids-group-ltd-ids-design-system-components-funnel-chart.d.ts +6 -1
- package/types/ids-group-ltd-ids-design-system-components-line-chart.d.ts +8 -18
- package/types/ids-group-ltd-ids-design-system-components.d.ts +58 -9
- package/types/ids-group-ltd-ids-design-system-core.d.ts +55 -4
- package/types/ids-group-ltd-ids-design-system.d.ts +4 -4
- package/docs/agent/feedback/ds-meter.md +0 -11
- package/docs/agent/feedback/ds-progress.md +0 -10
- package/fesm2022/ids-group-ltd-ids-design-system-components-meter.mjs +0 -61
- package/fesm2022/ids-group-ltd-ids-design-system-components-meter.mjs.map +0 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-progress.mjs +0 -65
- package/fesm2022/ids-group-ltd-ids-design-system-components-progress.mjs.map +0 -1
- package/types/ids-group-ltd-ids-design-system-components-meter.d.ts +0 -36
- package/types/ids-group-ltd-ids-design-system-components-progress.d.ts +0 -40
|
@@ -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)) {
|
|
@@ -192,37 +208,111 @@ function elementWidth(host) {
|
|
|
192
208
|
return width.asReadonly();
|
|
193
209
|
}
|
|
194
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
|
+
|
|
195
271
|
const E10 = Math.sqrt(50);
|
|
196
272
|
const E5 = Math.sqrt(10);
|
|
197
273
|
const E2 = Math.sqrt(2);
|
|
198
|
-
/** d3's tick-increment rule. A naive `
|
|
274
|
+
/** d3's tick-increment rule. A naive `span / count` produces steps like 482, which
|
|
199
275
|
* no reader parses; this snaps to 1, 2, 5 or 10 times a power of ten. */
|
|
200
|
-
function tickIncrement(
|
|
201
|
-
const step =
|
|
276
|
+
function tickIncrement(span, targetCount) {
|
|
277
|
+
const step = span / Math.max(1, targetCount);
|
|
202
278
|
const power = Math.floor(Math.log10(step));
|
|
203
279
|
const error = step / Math.pow(10, power);
|
|
204
280
|
const factor = error >= E10 ? 10 : error >= E5 ? 5 : error >= E2 ? 2 : 1;
|
|
205
281
|
return factor * Math.pow(10, power);
|
|
206
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
|
+
}
|
|
207
290
|
/** @internal */
|
|
208
|
-
function tickValues(domainMax, targetCount) {
|
|
209
|
-
|
|
291
|
+
function tickValues(domainMin, domainMax, targetCount) {
|
|
292
|
+
const span = domainMax - domainMin;
|
|
293
|
+
if (!Number.isFinite(span) || span <= 0) {
|
|
210
294
|
return [0];
|
|
211
295
|
}
|
|
212
|
-
const step = tickIncrement(
|
|
296
|
+
const step = tickIncrement(span, targetCount);
|
|
297
|
+
const first = Math.floor(domainMin / step);
|
|
298
|
+
const last = Math.ceil(domainMax / step);
|
|
213
299
|
const out = [];
|
|
214
|
-
for (let i =
|
|
300
|
+
for (let i = first; i <= last; i++) {
|
|
215
301
|
out.push(i * step);
|
|
216
302
|
}
|
|
217
303
|
return out;
|
|
218
304
|
}
|
|
219
305
|
/** @internal */
|
|
220
|
-
function
|
|
221
|
-
|
|
222
|
-
|
|
306
|
+
function niceDomain(domainMin, domainMax, targetCount) {
|
|
307
|
+
const span = domainMax - domainMin;
|
|
308
|
+
if (!Number.isFinite(span) || span <= 0) {
|
|
309
|
+
return { min: 0, max: 0 };
|
|
223
310
|
}
|
|
224
|
-
const step = tickIncrement(
|
|
225
|
-
return
|
|
311
|
+
const step = tickIncrement(span, targetCount);
|
|
312
|
+
return {
|
|
313
|
+
min: Math.floor(domainMin / step) * step,
|
|
314
|
+
max: Math.ceil(domainMax / step) * step,
|
|
315
|
+
};
|
|
226
316
|
}
|
|
227
317
|
/** Distance between two ticks, which `formatTick` needs to pick a precision. A
|
|
228
318
|
* degenerate series yields a single tick and therefore no step.
|
|
@@ -232,11 +322,12 @@ function tickStep(ticks) {
|
|
|
232
322
|
return ticks.length > 1 ? ticks[1] - ticks[0] : 0;
|
|
233
323
|
}
|
|
234
324
|
/** @internal */
|
|
235
|
-
function linearScale(domainMax, rangeSize) {
|
|
236
|
-
|
|
325
|
+
function linearScale(domainMin, domainMax, rangeSize) {
|
|
326
|
+
const span = domainMax - domainMin;
|
|
327
|
+
if (!Number.isFinite(span) || span <= 0) {
|
|
237
328
|
return () => 0;
|
|
238
329
|
}
|
|
239
|
-
return (value) => (value /
|
|
330
|
+
return (value) => ((value - domainMin) / span) * rangeSize;
|
|
240
331
|
}
|
|
241
332
|
/** Positions for marks that sit AT a category rather than inside it — the readings of a line.
|
|
242
333
|
* The first is at the plot's start and the last at its end, so the run fills the axis rather than
|
|
@@ -297,6 +388,30 @@ function bandScale(count, rangeSize, paddingRatio) {
|
|
|
297
388
|
indexAt: (offset) => Math.min(count - 1, Math.max(0, Math.floor(offset / step))),
|
|
298
389
|
};
|
|
299
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
|
+
}
|
|
300
415
|
|
|
301
416
|
// Past this the entrance stops reading as one gesture and starts reading as a queue: at 40ms a
|
|
302
417
|
// 100-mark series would otherwise take four seconds to finish arriving.
|
|
@@ -337,13 +452,19 @@ function nextRovingIndex(key, current, count) {
|
|
|
337
452
|
return null;
|
|
338
453
|
}
|
|
339
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
|
+
}
|
|
340
462
|
/** Moves DOM focus to the mark `index` within `scope`, which is what makes the roving tabindex a
|
|
341
|
-
* traversal rather than a state change nobody can see.
|
|
342
|
-
* whose marks repeat the same index once per series.
|
|
463
|
+
* traversal rather than a state change nobody can see.
|
|
343
464
|
*
|
|
344
465
|
* @internal */
|
|
345
466
|
function focusMark(scope, index, within = '') {
|
|
346
|
-
const target = scope
|
|
467
|
+
const target = markAt(scope, index, within);
|
|
347
468
|
if (target instanceof HTMLElement || target instanceof SVGElement) {
|
|
348
469
|
target.focus();
|
|
349
470
|
}
|
|
@@ -368,6 +489,26 @@ function trendOf(values) {
|
|
|
368
489
|
}
|
|
369
490
|
return 'Ending where it started';
|
|
370
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
|
+
}
|
|
371
512
|
/** The sentence a screen reader gets as the chart's accessible name. Generated rather than
|
|
372
513
|
* required, because a required one is a field that gets left at the component's default and then
|
|
373
514
|
* lies.
|
|
@@ -377,11 +518,12 @@ function trendOf(values) {
|
|
|
377
518
|
* levels of chart description, and the encoding is the one thing a screen-reader user cannot use.
|
|
378
519
|
*
|
|
379
520
|
* @internal */
|
|
380
|
-
function describeSeries(label, points, format = formatValue, tableFollows = true) {
|
|
381
|
-
const pointer = tableFollows ? ' Full values in the table below.' : '';
|
|
521
|
+
function describeSeries(label, points, format = formatValue, tableFollows = true, thresholds = []) {
|
|
382
522
|
if (points.length === 0) {
|
|
383
523
|
return `${label}. No data.`;
|
|
384
524
|
}
|
|
525
|
+
const pointer = describeThresholds(thresholds, points, format) +
|
|
526
|
+
(tableFollows ? ' Full values in the table below.' : '');
|
|
385
527
|
if (points.length === 1) {
|
|
386
528
|
return `${label}, one point: ${format(points[0].value)} at ${points[0].label}.${pointer}`;
|
|
387
529
|
}
|
|
@@ -1870,5 +2012,5 @@ function createTypeAhead() {
|
|
|
1870
2012
|
* Generated bundle index. Do not edit.
|
|
1871
2013
|
*/
|
|
1872
2014
|
|
|
1873
|
-
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 };
|
|
1874
2016
|
//# sourceMappingURL=ids-group-ltd-ids-design-system-components.mjs.map
|