kanto-ds 1.0.0 → 1.0.1

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.
Files changed (41) hide show
  1. package/README.md +8 -1
  2. package/dist/chunks/defaults-DKzFsNbv.js +57 -0
  3. package/dist/chunks/defaults-DKzFsNbv.js.map +1 -0
  4. package/dist/chunks/{listbox-CUXYn_3S.js → listbox-Sm3nvsC6.js} +5 -5
  5. package/dist/chunks/{listbox-CUXYn_3S.js.map → listbox-Sm3nvsC6.js.map} +1 -1
  6. package/dist/components/core/kt-icon/kt-icon.js +1 -1
  7. package/dist/components/core/kt-split-button/kt-split-button.d.ts +112 -0
  8. package/dist/components/core/kt-split-button/kt-split-button.js +262 -0
  9. package/dist/components/core/kt-split-button/kt-split-button.js.map +1 -0
  10. package/dist/components/data/kt-chart/cartesian.d.ts +62 -0
  11. package/dist/components/data/kt-chart/geometry.d.ts +41 -0
  12. package/dist/components/data/kt-chart/kt-chart.d.ts +79 -35
  13. package/dist/components/data/kt-chart/kt-chart.js +1200 -213
  14. package/dist/components/data/kt-chart/kt-chart.js.map +1 -1
  15. package/dist/components/data/kt-chart/model.d.ts +38 -0
  16. package/dist/components/data/kt-chart/point.d.ts +56 -0
  17. package/dist/components/data/kt-chart/radial.d.ts +60 -0
  18. package/dist/components/data/kt-chart/scale.d.ts +37 -0
  19. package/dist/components/forms/kt-input-menu/kt-input-menu.js +1 -1
  20. package/dist/components/forms/kt-select/kt-select.js +1 -1
  21. package/dist/components/overlays/kt-confirm-dialog/kt-confirm-dialog.js +41 -25
  22. package/dist/components/overlays/kt-confirm-dialog/kt-confirm-dialog.js.map +1 -1
  23. package/dist/components/overlays/kt-dropdown/kt-dropdown.d.ts +3 -0
  24. package/dist/components/overlays/kt-dropdown/kt-dropdown.js +48 -28
  25. package/dist/components/overlays/kt-dropdown/kt-dropdown.js.map +1 -1
  26. package/dist/components/overlays/kt-modal/kt-modal.js +12 -10
  27. package/dist/components/overlays/kt-modal/kt-modal.js.map +1 -1
  28. package/dist/icons/index.js +7 -34
  29. package/dist/icons/index.js.map +1 -1
  30. package/dist/index.d.ts +4 -2
  31. package/dist/index.js +89 -87
  32. package/dist/index.js.map +1 -1
  33. package/dist/react/index.d.ts +13 -0
  34. package/dist/react/index.js +176 -162
  35. package/dist/react/index.js.map +1 -1
  36. package/dist/vue/index.d.ts +2 -0
  37. package/dist/vue/index.js +8 -7
  38. package/dist/vue/index.js.map +1 -1
  39. package/package.json +8 -2
  40. package/dist/chunks/registry-X4LS9J5K.js +0 -30
  41. package/dist/chunks/registry-X4LS9J5K.js.map +0 -1
@@ -0,0 +1,41 @@
1
+ /**
2
+ * SVG path geometry for the chart's marks. Every function is pure and writes
3
+ * coordinates rounded to two decimals, so paths stay short and comparable.
4
+ */
5
+ export type Point = readonly [number, number];
6
+ /** One cubic Bézier piece of a curve. */
7
+ export interface Segment {
8
+ readonly from: Point;
9
+ readonly c1: Point;
10
+ readonly c2: Point;
11
+ readonly to: Point;
12
+ }
13
+ export declare const TAU: number;
14
+ export declare const round: (value: number) => number;
15
+ /** Straight segments through `points`. `move` false continues an open path. */
16
+ export declare function linearPath(points: readonly Point[], move?: boolean): string;
17
+ /**
18
+ * A monotone cubic through `points` (Fritsch–Carlson).
19
+ *
20
+ * Between two samples the curve stays within their range, so it never draws a
21
+ * peak or a dip that is not in the data — the failure of the cardinal splines
22
+ * most charts use. Needs at least three points; fewer have nothing to smooth.
23
+ */
24
+ export declare function monotoneSegments(points: readonly Point[]): Segment[];
25
+ /** A monotone curve as a path, or straight segments when there is nothing to smooth. */
26
+ export declare function monotonePath(points: readonly Point[], move?: boolean): string;
27
+ /** The point at `radius` and `angle` from a centre; 0 is twelve o'clock, clockwise. */
28
+ export declare function polar(cx: number, cy: number, radius: number, angle: number): Point;
29
+ /**
30
+ * A slice from `start` to `end`: a wedge to the centre when `inner` is 0, an
31
+ * annular sector otherwise. A whole turn is drawn as circles (and a hole, with
32
+ * `fill-rule="evenodd"`) because a single SVG arc cannot close on itself.
33
+ */
34
+ export declare function arcPath(cx: number, cy: number, inner: number, outer: number, start: number, end: number): string;
35
+ /** Which end of a bar is rounded. The baseline end always stays square. */
36
+ export type Tip = 'top' | 'bottom' | 'left' | 'right' | 'none';
37
+ /**
38
+ * A bar, rounded at its tip only. A bar rounded at the baseline too floats
39
+ * above the axis instead of standing on it.
40
+ */
41
+ export declare function barPath(x: number, y: number, width: number, height: number, radius: number, tip: Tip): string;
@@ -1,25 +1,20 @@
1
1
  import { type TemplateResult } from 'lit';
2
2
  import { KtElement } from '#internal/kt-element';
3
- export type KtChartType = 'area' | 'line' | 'bar';
4
- export interface KtSeries {
5
- readonly name: string;
6
- readonly values: readonly number[];
7
- /** Overrides the slot this series would take from the categorical order. */
8
- readonly color?: string;
9
- }
3
+ import type { Format, KtChartType, KtSeries } from './model.js';
4
+ export type { KtChartType, KtMark, KtPoint, KtSeries } from './model.js';
10
5
  /**
11
- * A small chart, drawn from the token layer.
6
+ * A chart, drawn from the token layer.
12
7
  *
13
- * Deliberately narrow: one axis, one to eight series, three marks. It is the
14
- * shape a product dashboard actually needs, not a charting library — anything
15
- * past this and you want a real one.
8
+ * Line, area and bar — stacked, sideways or mixed — plus scatter, bubble,
9
+ * pie, doughnut, polar area and radar, all in Kanto's voice: the eight
10
+ * categorical hues in fixed order, one value axis, recessive grid, and the
11
+ * data always available as a table.
16
12
  *
17
13
  * **Colour.** One series takes the brand hue: with nothing to tell apart there
18
14
  * is no identity to encode, and the title names it. Two or more take the fixed
19
15
  * categorical order in `--chart-series-1…8`, assigned by position and never
20
16
  * cycled, so a series keeps its colour when a filter removes its neighbours.
21
- * Those hues are kept clear of the semantic palette, so a line can never be
22
- * mistaken for a status.
17
+ * Slices take the same order by slice.
23
18
  *
24
19
  * **The table is not optional.** Every chart also renders its data as a table,
25
20
  * visually hidden by default. It is what a screen reader reads, and it is the
@@ -29,11 +24,14 @@ export interface KtSeries {
29
24
  * @element kt-chart
30
25
  *
31
26
  * @csspart svg - The plot.
32
- * @csspart legend - The legend, when there are two or more series.
27
+ * @csspart legend - The legend.
33
28
  * @csspart table - The data table.
34
29
  *
35
- * @fires kt-point-hover - The hovered index changed. `detail: { index }`,
36
- * with `index` of -1 when the pointer leaves.
30
+ * @fires kt-point-hover - The active point changed. `detail: { index, series }`;
31
+ * `index` is -1 when nothing is active, `series` -1 when the index spans
32
+ * every series.
33
+ * @fires kt-series-toggle - A legend item was pressed. `detail: { series, hidden }`.
34
+ * Cancelable.
37
35
  *
38
36
  * @example
39
37
  * ```js
@@ -47,49 +45,95 @@ export declare class KtChart extends KtElement {
47
45
  private observer?;
48
46
  private readonly tableId;
49
47
  private box;
48
+ /** The active category, point or slice, or -1. */
50
49
  private active;
50
+ /** The series the active point belongs to, for scatter and bubble; -1 otherwise. */
51
+ private activeSeries;
52
+ /**
53
+ * Series hidden from the legend — or slices, for pie, doughnut and polar
54
+ * area. Not `hidden`: that is HTMLElement's, and shadowing it would stop
55
+ * `chart.hidden = true` from hiding the chart.
56
+ */
57
+ private hiddenSeries;
51
58
  type: KtChartType;
52
59
  series: readonly KtSeries[];
53
- /** One label per index along the x axis. */
60
+ /** One label per index along the category axis, or per slice or spoke. */
54
61
  labels: readonly string[];
55
62
  height: number;
56
- /** Formats a value for the tooltip and the table. */
57
- format: (value: number) => string;
58
- /** Horizontal grid lines. */
63
+ /** Formats a value for the value axis, the tooltip and the table. */
64
+ format: Format;
65
+ /** Formats the x value of a scatter or bubble point. */
66
+ formatX: Format;
67
+ /** Grid lines. */
59
68
  noGrid: boolean;
69
+ /** Hides the value axis labels, for a chart too small to carry them. */
70
+ noAxis: boolean;
60
71
  /** Puts the data table on screen instead of only in the accessibility tree. */
61
72
  showTable: boolean;
62
73
  /**
63
- * Smooths the line through a monotone spline.
74
+ * Smooths lines and areas through a monotone spline.
64
75
  *
65
76
  * Off by default on purpose: a curve between two samples draws values that
66
77
  * were never measured. Turn it on when the underlying quantity really is
67
78
  * continuous and the reader knows it.
68
79
  */
69
80
  smooth: boolean;
81
+ /** Bars, and areas, on top of one another instead of side by side. */
82
+ stacked: boolean;
83
+ /** Bars along the horizontal axis, with the categories down the left. */
84
+ horizontal: boolean;
85
+ /** Pins the bottom of the value axis. */
86
+ min: number | null;
87
+ /** Pins the top of the value axis. */
88
+ max: number | null;
89
+ /** Names the total in the middle of a doughnut. */
90
+ centerLabel: string;
91
+ /** Names the sum in a stacked chart's tooltip and table. */
92
+ totalLabel: string;
70
93
  /** Accessible name. Say what the chart shows. */
71
94
  label: string;
72
95
  connectedCallback(): void;
73
96
  firstUpdated(): void;
74
97
  disconnectedCallback(): void;
75
- private colorFor;
98
+ willUpdate(changed: Map<PropertyKey, unknown>): void;
99
+ private get family();
76
100
  private get pointCount();
77
- private get bounds();
78
- private get plotArea();
79
- private xFor;
80
- private yFor;
81
- /**
82
- * A monotone cubic path — it never overshoots the samples, which a plain
83
- * cardinal spline happily does, inventing peaks that are not in the data.
84
- */
85
- private pathFor;
101
+ private colorOf;
102
+ private measureContext;
103
+ /** Text width in the axis font. Estimated where there is no canvas to ask. */
104
+ private measure;
105
+ private get cartesianView();
106
+ private get pointView();
107
+ /** Pie, doughnut and polar area: one series, whose slices are the labels. */
108
+ private get sliced();
109
+ private sliceColor;
110
+ private get radialView();
111
+ /** Whether there is anything to draw. */
112
+ private get hasData();
113
+ private setActive;
86
114
  private onPointerMove;
87
115
  private onPointerLeave;
88
- private renderGrid;
89
- private renderBars;
90
- private renderLines;
91
- private renderAxis;
116
+ /** How many positions the keyboard walks through, in order. */
117
+ private get stops();
118
+ /**
119
+ * Arrows walk the points, Home and End jump to the ends, Escape lets go.
120
+ * Every move emits `kt-point-hover` and opens the tooltip, which is a live
121
+ * region, so a keyboard user hears what a pointer user sees.
122
+ */
123
+ private onKeyDown;
124
+ /**
125
+ * Scatter and bubble: left and right walk the current series in x order,
126
+ * up and down move to the neighbouring visible series.
127
+ */
128
+ private onPointKeyDown;
129
+ private toggle;
130
+ private renderMarks;
131
+ private get tooltip();
92
132
  private renderTooltip;
133
+ private renderLegend;
134
+ private renderPointTable;
135
+ private renderSliceTable;
136
+ private renderTable;
93
137
  render(): TemplateResult;
94
138
  }
95
139
  declare global {