@fusion.dev/helix-headless 0.244.2 → 0.246.0

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 (32) hide show
  1. package/api.json +1 -1
  2. package/custom-elements.json +1 -1
  3. package/dist/heatmap/root/buckets.d.ts +27 -0
  4. package/dist/heatmap/root/buckets.js +24 -1
  5. package/dist/heatmap/root/heatmap-root.d.ts +53 -2
  6. package/dist/heatmap/root/heatmap-root.js +59 -3
  7. package/dist/spatial-bar-chart/bars.d.ts +35 -9
  8. package/dist/spatial-bar-chart/bars.js +74 -17
  9. package/dist/spatial-bar-chart/root/spatial-bar-chart-root.d.ts +22 -34
  10. package/dist/spatial-bar-chart/root/spatial-bar-chart-root.js +46 -111
  11. package/dist/spatial-heatmap/root/spatial-heatmap-root.d.ts +27 -4
  12. package/dist/spatial-heatmap/root/spatial-heatmap-root.js +52 -13
  13. package/dist/spatial-ribbon-chart/ribbons.d.ts +10 -1
  14. package/dist/spatial-ribbon-chart/ribbons.js +25 -9
  15. package/dist/spatial-ribbon-chart/root/spatial-ribbon-chart-root.d.ts +43 -3
  16. package/dist/spatial-ribbon-chart/root/spatial-ribbon-chart-root.js +46 -8
  17. package/dist/spatial-scatter-chart/field.d.ts +23 -0
  18. package/dist/spatial-scatter-chart/field.js +47 -1
  19. package/dist/spatial-scatter-chart/root/spatial-scatter-chart-root.d.ts +46 -3
  20. package/dist/spatial-scatter-chart/root/spatial-scatter-chart-root.js +56 -13
  21. package/dist/spatial-surface-chart/grid.d.ts +16 -0
  22. package/dist/spatial-surface-chart/grid.js +36 -1
  23. package/dist/spatial-surface-chart/root/spatial-surface-chart-root.d.ts +46 -2
  24. package/dist/spatial-surface-chart/root/spatial-surface-chart-root.js +53 -7
  25. package/dist/spatial-treemap/blocks.d.ts +32 -1
  26. package/dist/spatial-treemap/blocks.js +72 -2
  27. package/dist/spatial-treemap/root/spatial-treemap-root.d.ts +45 -3
  28. package/dist/spatial-treemap/root/spatial-treemap-root.js +46 -6
  29. package/lint.json +1 -1
  30. package/package.json +5 -5
  31. package/types/jsx.d.ts +246 -25
  32. package/types/vue.d.ts +167 -9
@@ -1,10 +1,11 @@
1
1
  import { __decorate } from "tslib";
2
- import { AriaForwardController, CHART_PLOT, customElement, drawTooltip, formatWords, HelixElement, HelixPlotChangeEvent, HelixPlotTurnEvent, HelixReadingChangeEvent, HelixReadingPressEvent, isRtl, MixinChartSource, MixinChartStatus, spokenReading, words, wordsLocale, } from '@fusion.dev/helix-core';
2
+ import { AriaForwardController, CHART_PLOT, customElement, drawTooltip, formatWords, HelixElement, HelixPlotChangeEvent, HelixPlotTurnEvent, HelixReadingChangeEvent, HelixReadingPressEvent, isRtl, MixinChartSource, MixinChartStatus, ReadingsMotionController, spokenReading, words, wordsLocale, } from '@fusion.dev/helix-core';
3
3
  import { html, nothing, svg, } from 'lit';
4
4
  import { property, state } from 'lit/decorators.js';
5
5
  import '../../tooltip/index.js';
6
+ import { barItems } from '../../spatial-bar-chart/bars.js';
6
7
  import { boundsOf, boxView, DragTurn, drawBox, nearestTo, PlotRoomWatch, SPATIAL_VIEW, turned, wordsFitted, } from '../../spatial-scatter-chart/view.js';
7
- import { ribbonsDrawn, ribbonsOf } from '../ribbons.js';
8
+ import { ribbonsBetween, ribbonsDrawn, ribbonsOf, } from '../ribbons.js';
8
9
  const TURNS = {
9
10
  ArrowDown: { across: 0, up: -1 },
10
11
  ArrowLeft: { across: -1, up: 0 },
@@ -15,6 +16,8 @@ const SERIES = 24;
15
16
  let HelixHeadlessSpatialRibbonChart = class HelixHeadlessSpatialRibbonChart extends MixinChartStatus(MixinChartSource(HelixElement)) {
16
17
  constructor() {
17
18
  super(...arguments);
19
+ this.grow = false;
20
+ this.growAgain = false;
18
21
  this.noBox = false;
19
22
  this.openLabel = '{place}, {series}: no value';
20
23
  this.plotLabel = '3D ribbon chart';
@@ -26,6 +29,19 @@ let HelixHeadlessSpatialRibbonChart = class HelixHeadlessSpatialRibbonChart exte
26
29
  this.camera = next(this.camera);
27
30
  }, () => this.requestUpdate());
28
31
  this.told = -1;
32
+ this.motion = new ReadingsMotionController(this, {
33
+ between: ribbonsBetween,
34
+ grow: () => this.grow,
35
+ growAgain: () => this.growAgain,
36
+ items: barItems,
37
+ timing: () => {
38
+ const style = getComputedStyle(this);
39
+ return {
40
+ duration: style.getPropertyValue('--spatial-ribbon-chart-move-duration'),
41
+ easing: style.getPropertyValue('--spatial-ribbon-chart-move-easing'),
42
+ };
43
+ },
44
+ });
29
45
  this.aria = new AriaForwardController(this, {
30
46
  target: () => this.partNamed('plot'),
31
47
  });
@@ -78,6 +94,9 @@ let HelixHeadlessSpatialRibbonChart = class HelixHeadlessSpatialRibbonChart exte
78
94
  }
79
95
  return this.memo.field;
80
96
  }
97
+ get shown() {
98
+ return this.motion.drawn ?? this.field;
99
+ }
81
100
  get active() {
82
101
  return this.pointer.at;
83
102
  }
@@ -88,7 +107,8 @@ let HelixHeadlessSpatialRibbonChart = class HelixHeadlessSpatialRibbonChart exte
88
107
  this.rendered = on;
89
108
  this.toggleState('drawn', on);
90
109
  }
91
- requestActive(index, kind = 'mouse') {
110
+ requestActive(at, kind = 'mouse') {
111
+ const index = at < this.field.cells.length ? at : -1;
92
112
  if (kind === 'touch') {
93
113
  this.pointer.tapTo(index);
94
114
  }
@@ -101,7 +121,9 @@ let HelixHeadlessSpatialRibbonChart = class HelixHeadlessSpatialRibbonChart exte
101
121
  }
102
122
  willUpdate(changed) {
103
123
  super.willUpdate(changed);
104
- this.pointer.grid = Math.max(1, this.field.series.length);
124
+ const field = this.field;
125
+ this.pointer.grid = Math.max(1, field.series.length);
126
+ this.motion.follow(field, field.readings > 0);
105
127
  }
106
128
  connectedCallback() {
107
129
  super.connectedCallback();
@@ -119,10 +141,16 @@ let HelixHeadlessSpatialRibbonChart = class HelixHeadlessSpatialRibbonChart exte
119
141
  updated(changed) {
120
142
  super.updated(changed);
121
143
  const field = this.field;
144
+ const shown = this.shown;
122
145
  if (field !== this.last) {
123
146
  this.last = field;
147
+ this.lastShown = shown;
124
148
  this.dispatchEvent(new HelixPlotChangeEvent({ kind: 'data' }));
125
149
  }
150
+ else if (shown !== this.lastShown) {
151
+ this.lastShown = shown;
152
+ this.dispatchEvent(new HelixPlotChangeEvent({ kind: 'move' }));
153
+ }
126
154
  if (this.pointer.at !== this.told) {
127
155
  this.told = this.pointer.at;
128
156
  this.dispatchEvent(new HelixPlotChangeEvent({ kind: 'focus' }));
@@ -155,13 +183,17 @@ let HelixHeadlessSpatialRibbonChart = class HelixHeadlessSpatialRibbonChart exte
155
183
  }
156
184
  renderFallback(field, at) {
157
185
  const view = wordsFitted(this.plotRoom.room, (words) => boxView(field.axes, this.camera, [], this.noBox, words, wordsLocale(this)));
158
- const ribbons = ribbonsDrawn(field, view.projection).sort((one, other) => one.depth - other.depth);
186
+ const drawn = this.motion.moving ? this.shown : field;
187
+ const moving = drawn === field
188
+ ? view
189
+ : boxView(drawn.axes, this.camera, [], this.noBox, view.words, wordsLocale(this));
190
+ const ribbons = ribbonsDrawn(drawn, view.projection).sort((one, other) => one.depth - other.depth);
159
191
  const places = ribbons.flatMap((ribbon) => ribbon.readings);
160
- this.placed = places;
192
+ this.placed = places.filter((place) => place.index < field.cells.length);
161
193
  const active = places.find((place) => place.index === at);
162
194
  const cell = field.cells[at];
163
195
  const bounds = this.drag.frame(this.noBox
164
- ? boundsOf(ribbons.flatMap((ribbon) => ribbon.outline), 0.1)
196
+ ? boundsOf(ribbonsDrawn(field, view.projection).flatMap((ribbon) => ribbon.outline), 0.1)
165
197
  : view.bounds, view.on([0, 0, 0]));
166
198
  return html `<div aria-hidden="true" dir="ltr" ?hidden=${this.rendered} part="fallback">
167
199
  <svg
@@ -175,7 +207,7 @@ let HelixHeadlessSpatialRibbonChart = class HelixHeadlessSpatialRibbonChart exte
175
207
  @pointerleave=${this.onDrawingLeave}
176
208
  @pointermove=${this.onDrawingMove}
177
209
  @pointerup=${this.onDrawingTap}
178
- >${this.noBox ? nothing : drawBox(view)}${ribbons.map((ribbon) => this.renderRibbon(ribbon))}${active
210
+ >${this.noBox ? nothing : drawBox(moving)}${ribbons.map((ribbon) => this.renderRibbon(ribbon))}${active
179
211
  ? svg `<circle cx=${active.x} cy=${active.y} part="ring" r="0.06"></circle><foreignObject height="0.001" overflow="visible" width="0.001" x=${active.x} y=${active.y}>${this.renderOwnTooltip(cell?.row)}</foreignObject>`
180
212
  : nothing}</svg>
181
213
  </div>`;
@@ -230,6 +262,12 @@ let HelixHeadlessSpatialRibbonChart = class HelixHeadlessSpatialRibbonChart exte
230
262
  return html `<p id="helix-chart-summary" part="summary">${said}</p>`;
231
263
  }
232
264
  };
265
+ __decorate([
266
+ property({ reflect: true, type: Boolean })
267
+ ], HelixHeadlessSpatialRibbonChart.prototype, "grow", void 0);
268
+ __decorate([
269
+ property({ attribute: 'grow-again', reflect: true, type: Boolean })
270
+ ], HelixHeadlessSpatialRibbonChart.prototype, "growAgain", void 0);
233
271
  __decorate([
234
272
  property({ attribute: 'no-box', reflect: true, type: Boolean })
235
273
  ], HelixHeadlessSpatialRibbonChart.prototype, "noBox", void 0);
@@ -5,6 +5,7 @@
5
5
  * range that does not reach the round numbers either side puts a point on
6
6
  * the edge of the box, and a row read into the wrong axis looks like data.
7
7
  */
8
+ import { type MotionItem, type MotionShares } from '@fusion.dev/helix-core';
8
9
  /** What the field reads of a row: its label and its cells, with their headings and numbers. */
9
10
  export interface FieldRow {
10
11
  cells: readonly {
@@ -20,6 +21,11 @@ export interface PlotPoint {
20
21
  group: string;
21
22
  /** The point's place among the groups, which its color is read by. */
22
23
  groupIndex: number;
24
+ /**
25
+ * What the point is known by from one table to the next, on a field drawn
26
+ * between two while the readings move. A table's own field has none.
27
+ */
28
+ key?: string | undefined;
23
29
  /** The row's own label. */
24
30
  label: string;
25
31
  /** The row it was read from, counting from zero. */
@@ -69,3 +75,20 @@ export declare const niceRange: (low: number, high: number) => [number, number];
69
75
  export declare const fieldOf: (rows: readonly FieldRow[], columns: readonly number[], groupBy?: string) => PlotField;
70
76
  /** Where a number stands along an axis, from 0 at its low end to 1 at its high end. */
71
77
  export declare const along: (axis: PlotAxis, value: number) => number;
78
+ /**
79
+ * The key of each point of `field`, in its order: its label, numbered where
80
+ * a label comes again. A field drawn between two tables carries each point's
81
+ * key with it.
82
+ */
83
+ export declare const pointKeys: (field: PlotField) => string[];
84
+ /** Each point as the chart's motion knows it: by its key, growing in in the table's order. */
85
+ export declare const pointItems: (field: PlotField) => MotionItem[];
86
+ /**
87
+ * The points `at` the shares between `from` and `to`, which the chart draws
88
+ * while its readings move. **A point both tables hold moves** from its old
89
+ * place to its new one, **a point only `to` holds rises** from the floor of
90
+ * the box where it stands across and in depth, and **a point only `from`
91
+ * held sinks** to the floor, after `to`'s points, and goes. The axes move
92
+ * with `at.axes`. With no `from`, every point rises from the floor.
93
+ */
94
+ export declare const pointsBetween: (from: PlotField | undefined, to: PlotField, at: MotionShares) => PlotField;
@@ -1,4 +1,4 @@
1
- import { ticks } from '@fusion.dev/helix-core';
1
+ import { keysOf, mix, mixAxis, ticks, } from '@fusion.dev/helix-core';
2
2
  export const niceRange = (low, high) => {
3
3
  if (!Number.isFinite(low) || !Number.isFinite(high)) {
4
4
  return [0, 1];
@@ -59,3 +59,49 @@ export const along = (axis, value) => {
59
59
  const [low, high] = axis.range;
60
60
  return high === low ? 0.5 : (value - low) / (high - low);
61
61
  };
62
+ export const pointKeys = (field) => {
63
+ const keys = keysOf(field.points.map((point) => point.label));
64
+ return field.points.map((point, index) => point.key ?? keys[index]);
65
+ };
66
+ export const pointItems = (field) => pointKeys(field).map((key, step) => ({ key, step }));
67
+ export const pointsBetween = (from, to, at) => {
68
+ const axes = from && at.axes < 1
69
+ ? {
70
+ x: mixAxis(from.axes.x, to.axes.x, at.axes),
71
+ y: mixAxis(from.axes.y, to.axes.y, at.axes),
72
+ z: mixAxis(from.axes.z, to.axes.z, at.axes),
73
+ }
74
+ : to.axes;
75
+ const floor = axes.y.range[0];
76
+ const before = new Map();
77
+ if (from) {
78
+ const had = pointKeys(from);
79
+ from.points.forEach((point, index) => {
80
+ before.set(had[index], point);
81
+ });
82
+ }
83
+ const keys = pointKeys(to);
84
+ const points = to.points.map((point, index) => {
85
+ const key = keys[index];
86
+ const share = at.share(key);
87
+ const old = before.get(key);
88
+ if (!old || at.floor(key)) {
89
+ return { ...point, key, y: mix(floor, point.y, share) };
90
+ }
91
+ return {
92
+ ...point,
93
+ key,
94
+ x: mix(old.x, point.x, share),
95
+ y: mix(old.y, point.y, share),
96
+ z: mix(old.z, point.z, share),
97
+ };
98
+ });
99
+ const kept = new Set(keys);
100
+ for (const [key, old] of before) {
101
+ const share = at.share(key);
102
+ if (!kept.has(key) && share < 1) {
103
+ points.push({ ...old, key, y: mix(old.y, floor, share) });
104
+ }
105
+ }
106
+ return { ...to, axes, points };
107
+ };
@@ -1,4 +1,4 @@
1
- import { AriaForwardController, HelixElement } from '@fusion.dev/helix-core';
1
+ import { AriaForwardController, HelixElement, ReadingsMotionController } from '@fusion.dev/helix-core';
2
2
  import { type PropertyValues, type TemplateResult } from 'lit';
3
3
  import '../../tooltip/index.js';
4
4
  import { type PlotField } from '../field.js';
@@ -64,7 +64,7 @@ declare const HelixHeadlessSpatialScatterChart_base: typeof HelixElement & (new
64
64
  * @slot error - Content shown after `error-text` while it is set and there are no readings, such as a button that tries again.
65
65
  * @slot loading - Content shown while `loading` is set and there are no points yet. Falls back to `loading-text`.
66
66
  *
67
- * @event {HelixPlotChangeEvent} helix-plot-change - The points or the point the keys rest on changed, which the renderer is told. It stays on the chart.
67
+ * @event {HelixPlotChangeEvent} helix-plot-change - The points or the point the keys rest on changed, or a frame of a move drew the points on their way, which the renderer is told. It stays on the chart.
68
68
  * @event {HelixPlotTurnEvent} helix-plot-turn - Shift with an arrow asked the view to turn, by a step across or up.
69
69
  * @event {HelixReadingChangeEvent} helix-reading-change - The reading moved, or was put away: `index` is the row, or `-1` for none, with its `label` and the `pointerType` that moved it.
70
70
  * @event {HelixReadingPressEvent} helix-reading-press - A point was clicked, tapped, or pressed with Enter or Space, with the same detail as `helix-reading-change`.
@@ -105,6 +105,9 @@ declare const HelixHeadlessSpatialScatterChart_base: typeof HelixElement & (new
105
105
  * @csspart tooltip-surface-top - The bubble while it is above the reading. Set alongside `tooltip-surface`.
106
106
  * @csspart tooltip-value - A column's value inside the tooltip.
107
107
  *
108
+ * @cssproperty --spatial-scatter-chart-move-duration - How long the points take to move to a new table's readings: a point the table keeps moves to its new place, a point it adds rises from the floor, and a point it drops sinks to the floor. Unset, a new table is drawn at once. The growth under `grow` keeps its own timing.
109
+ * @cssproperty --spatial-scatter-chart-move-easing - The curve the points move to new readings along.
110
+ *
108
111
  * @cssstate active - While a point is shown, under the pointer or the keys.
109
112
  * @cssstate drawn - While a renderer has drawn the points, and the chart's own drawing is hidden.
110
113
  * @cssstate empty - While the `empty` part stands in place of the points.
@@ -125,6 +128,29 @@ export declare class HelixHeadlessSpatialScatterChart extends HelixHeadlessSpati
125
128
  dropLines: boolean;
126
129
  /** The column of text that puts each point in a group, by its heading. None by default. */
127
130
  groupBy: string;
131
+ /**
132
+ * Grows the points in from the floor the first time the chart comes
133
+ * into view with readings, one after another in the order of the table, so the drawing arrives the way a
134
+ * page's own picture does. The growth is fast at first, slows to rest,
135
+ * and never passes a reading.
136
+ *
137
+ * Under `prefers-reduced-motion`, or where the page has paused its motion
138
+ * through `pauseMotion` or `Motion Toggle`, the points stand at their
139
+ * readings from the start. A later table grows the points it adds, each
140
+ * from the floor, so a reading that arrives while the chart is in view
141
+ * arrives the same way. The points it keeps move to their new places on `--spatial-scatter-chart-move-duration`, and stand there at once where it is unset.
142
+ */
143
+ grow: boolean;
144
+ /**
145
+ * Grows the points in again each time the chart comes back into view
146
+ * after it left it, as a pane does when it is opened again, where `grow`
147
+ * alone grows them the first time only. Only a chart that grows takes it.
148
+ *
149
+ * While it is out of view the points stand at the floor, so the first
150
+ * frame after it returns is the start of the growth and never a flash of
151
+ * the whole drawing.
152
+ */
153
+ growAgain: boolean;
128
154
  /**
129
155
  * Draws no box: no edges, grid, numbers, or names, so the readings stand
130
156
  * alone and fill the plot, as a picture on a product's own page does. The
@@ -154,6 +180,14 @@ export declare class HelixHeadlessSpatialScatterChart extends HelixHeadlessSpati
154
180
  private last;
155
181
  /** The point the keys rested on last, so a change of it can be told. */
156
182
  private told;
183
+ /**
184
+ * Moves the points from one table to the next, and grows them in under
185
+ * `grow`, timed by `--spatial-scatter-chart-move-duration` and
186
+ * `--spatial-scatter-chart-move-easing`.
187
+ */
188
+ protected readonly motion: ReadingsMotionController<PlotField>;
189
+ /** The points drawn last, kept so a frame of their move can be told. */
190
+ private lastShown;
157
191
  /** Carries a host `aria-labelledby` and `aria-describedby` to the plot. */
158
192
  protected readonly aria: AriaForwardController;
159
193
  /**
@@ -164,6 +198,13 @@ export declare class HelixHeadlessSpatialScatterChart extends HelixHeadlessSpati
164
198
  get field(): PlotField;
165
199
  /** The field last read, and what it was read from. */
166
200
  private memo;
201
+ /**
202
+ * The points as drawn this frame, which a renderer draws: `field` at rest,
203
+ * and while the readings move, every point between its last place and its
204
+ * new one, in `field`'s order, then each point the last table had and the
205
+ * new one does not, sinking to the floor.
206
+ */
207
+ get shown(): PlotField;
167
208
  /** The point the keys or the pointer rest on, as its place in `field.points`, or `-1`. */
168
209
  get active(): number;
169
210
  /** The number of points, which the keys walk. */
@@ -179,7 +220,7 @@ export declare class HelixHeadlessSpatialScatterChart extends HelixHeadlessSpati
179
220
  * A touch keeps it until a tap lands elsewhere, and a mouse leaving a
180
221
  * reading the keys moved to leaves it. Called by the connector.
181
222
  */
182
- requestActive(index: number, kind?: 'mouse' | 'pen' | 'touch'): void;
223
+ requestActive(at: number, kind?: 'mouse' | 'pen' | 'touch'): void;
183
224
  /**
184
225
  * Says where the renderer draws the reading, as fractions of the plot from
185
226
  * its top left, or `undefined` while it draws none. The tooltip points
@@ -189,6 +230,8 @@ export declare class HelixHeadlessSpatialScatterChart extends HelixHeadlessSpati
189
230
  x: number;
190
231
  y: number;
191
232
  } | undefined): void;
233
+ /** Decided before the table is drawn, so a point that rises never shows at its place first. */
234
+ protected willUpdate(changed: PropertyValues<this>): void;
192
235
  connectedCallback(): void;
193
236
  protected updated(changed: PropertyValues): void;
194
237
  /**
@@ -1,9 +1,9 @@
1
1
  import { __decorate } from "tslib";
2
- import { AriaForwardController, CHART_PLOT, customElement, drawTooltip, formatWords, HelixElement, HelixPlotChangeEvent, HelixPlotTurnEvent, HelixReadingChangeEvent, HelixReadingPressEvent, isRtl, MixinChartSource, MixinChartStatus, shortNumber, spokenReading, words, wordsLocale, } from '@fusion.dev/helix-core';
2
+ import { AriaForwardController, CHART_PLOT, customElement, drawTooltip, formatWords, HelixElement, HelixPlotChangeEvent, HelixPlotTurnEvent, HelixReadingChangeEvent, HelixReadingPressEvent, isRtl, MixinChartSource, MixinChartStatus, ReadingsMotionController, shortNumber, spokenReading, words, wordsLocale, } from '@fusion.dev/helix-core';
3
3
  import { html, nothing, svg } from 'lit';
4
4
  import { property, state } from 'lit/decorators.js';
5
5
  import '../../tooltip/index.js';
6
- import { fieldOf } from '../field.js';
6
+ import { fieldOf, pointItems, pointsBetween } from '../field.js';
7
7
  import { boundsOf, boxView, DragTurn, drawBox, inBox, nearestTo, PlotRoomWatch, SPATIAL_VIEW, turned, wordsFitted, } from '../view.js';
8
8
  const SERIES = 24;
9
9
  const TURNS = {
@@ -17,6 +17,8 @@ let HelixHeadlessSpatialScatterChart = class HelixHeadlessSpatialScatterChart ex
17
17
  super(...arguments);
18
18
  this.dropLines = false;
19
19
  this.groupBy = '';
20
+ this.grow = false;
21
+ this.growAgain = false;
20
22
  this.noBox = false;
21
23
  this.plotLabel = '3D scatter chart';
22
24
  this.summaryLabel = '{count, plural, one {# point} other {# points}}: {x} across, {y} up, and {z} in depth.';
@@ -29,6 +31,19 @@ let HelixHeadlessSpatialScatterChart = class HelixHeadlessSpatialScatterChart ex
29
31
  this.placed = [];
30
32
  this.last = undefined;
31
33
  this.told = -1;
34
+ this.motion = new ReadingsMotionController(this, {
35
+ between: pointsBetween,
36
+ grow: () => this.grow,
37
+ growAgain: () => this.growAgain,
38
+ items: pointItems,
39
+ timing: () => {
40
+ const style = getComputedStyle(this);
41
+ return {
42
+ duration: style.getPropertyValue('--spatial-scatter-chart-move-duration'),
43
+ easing: style.getPropertyValue('--spatial-scatter-chart-move-easing'),
44
+ };
45
+ },
46
+ });
32
47
  this.aria = new AriaForwardController(this, {
33
48
  target: () => this.partNamed('plot'),
34
49
  });
@@ -84,6 +99,9 @@ let HelixHeadlessSpatialScatterChart = class HelixHeadlessSpatialScatterChart ex
84
99
  }
85
100
  return this.memo.field;
86
101
  }
102
+ get shown() {
103
+ return this.motion.drawn ?? this.field;
104
+ }
87
105
  get active() {
88
106
  return this.pointer.at;
89
107
  }
@@ -94,7 +112,8 @@ let HelixHeadlessSpatialScatterChart = class HelixHeadlessSpatialScatterChart ex
94
112
  this.rendered = on;
95
113
  this.toggleState('drawn', on);
96
114
  }
97
- requestActive(index, kind = 'mouse') {
115
+ requestActive(at, kind = 'mouse') {
116
+ const index = at < this.field.points.length ? at : -1;
98
117
  if (kind === 'touch') {
99
118
  this.pointer.tapTo(index);
100
119
  }
@@ -105,6 +124,11 @@ let HelixHeadlessSpatialScatterChart = class HelixHeadlessSpatialScatterChart ex
105
124
  placeReading(at) {
106
125
  this.place = at;
107
126
  }
127
+ willUpdate(changed) {
128
+ super.willUpdate(changed);
129
+ const field = this.field;
130
+ this.motion.follow(field, field.points.length > 0);
131
+ }
108
132
  connectedCallback() {
109
133
  super.connectedCallback();
110
134
  this.pointer.axis = 'none';
@@ -121,10 +145,16 @@ let HelixHeadlessSpatialScatterChart = class HelixHeadlessSpatialScatterChart ex
121
145
  updated(changed) {
122
146
  super.updated(changed);
123
147
  const field = this.field;
148
+ const shown = this.shown;
124
149
  if (field !== this.last) {
125
150
  this.last = field;
151
+ this.lastShown = shown;
126
152
  this.dispatchEvent(new HelixPlotChangeEvent({ kind: 'data' }));
127
153
  }
154
+ else if (shown !== this.lastShown) {
155
+ this.lastShown = shown;
156
+ this.dispatchEvent(new HelixPlotChangeEvent({ kind: 'move' }));
157
+ }
128
158
  if (this.pointer.at !== this.told) {
129
159
  this.told = this.pointer.at;
130
160
  this.dispatchEvent(new HelixPlotChangeEvent({ kind: 'focus' }));
@@ -155,14 +185,19 @@ let HelixHeadlessSpatialScatterChart = class HelixHeadlessSpatialScatterChart ex
155
185
  </div>
156
186
  ${readable ? this.renderSummary(field) : this.renderStatus()}${this.renderSonify()}${this.renderTable()}`;
157
187
  }
158
- renderFallback(field, at) {
159
- const view = wordsFitted(this.plotRoom.room, (words) => boxView(field.axes, this.camera, [], this.noBox, words, wordsLocale(this)));
188
+ renderFallback(read, at) {
189
+ const view = wordsFitted(this.plotRoom.room, (words) => boxView(read.axes, this.camera, [], this.noBox, words, wordsLocale(this)));
190
+ const field = this.motion.moving ? this.shown : read;
191
+ const moving = field === read
192
+ ? view
193
+ : boxView(field.axes, this.camera, [], this.noBox, view.words, wordsLocale(this));
194
+ const placeOf = (axes, point) => [
195
+ inBox(axes.x, point.x),
196
+ inBox(axes.y, point.y),
197
+ inBox(axes.z, point.z),
198
+ ];
160
199
  const places = field.points.map((point, index) => {
161
- const box = [
162
- inBox(field.axes.x, point.x),
163
- inBox(field.axes.y, point.y),
164
- inBox(field.axes.z, point.z),
165
- ];
200
+ const box = placeOf(field.axes, point);
166
201
  return {
167
202
  depth: view.depth(box),
168
203
  foot: view.on([box[0], -1, box[2]]),
@@ -171,10 +206,12 @@ let HelixHeadlessSpatialScatterChart = class HelixHeadlessSpatialScatterChart ex
171
206
  ...view.on(box),
172
207
  };
173
208
  });
174
- this.placed = places;
209
+ this.placed = places.slice(0, read.points.length);
175
210
  const painted = [...places].sort((one, other) => one.depth - other.depth);
176
211
  const active = places[at];
177
- const bounds = this.drag.frame(this.noBox ? boundsOf(places, 0.1) : view.bounds, view.on([0, 0, 0]));
212
+ const bounds = this.drag.frame(this.noBox
213
+ ? boundsOf(read.points.map((point) => view.on(placeOf(read.axes, point))), 0.1)
214
+ : view.bounds, view.on([0, 0, 0]));
178
215
  return html `<div aria-hidden="true" dir="ltr" ?hidden=${this.rendered} part="fallback">
179
216
  <svg
180
217
  part="drawing"
@@ -187,7 +224,7 @@ let HelixHeadlessSpatialScatterChart = class HelixHeadlessSpatialScatterChart ex
187
224
  @pointerleave=${this.onDrawingLeave}
188
225
  @pointermove=${this.onDrawingMove}
189
226
  @pointerup=${this.onDrawingTap}
190
- >${this.noBox ? nothing : drawBox(view)}${painted.map((place) => svg `${this.dropLines ? svg `<path d="M${shortNumber(place.x)} ${shortNumber(place.y)}L${shortNumber(place.foot.x)} ${shortNumber(place.foot.y)}" part="drop-line" style="--chart-series: var(--chart-series-${(place.point.groupIndex % SERIES) + 1})"></path>` : nothing}<circle cx=${place.x} cy=${place.y} part="point${place.index === at ? ' point-active' : ''}" r="0.045" style="--chart-series: var(--chart-series-${(place.point.groupIndex % SERIES) + 1})"></circle>`)}${active
227
+ >${this.noBox ? nothing : drawBox(moving)}${painted.map((place) => svg `${this.dropLines ? svg `<path d="M${shortNumber(place.x)} ${shortNumber(place.y)}L${shortNumber(place.foot.x)} ${shortNumber(place.foot.y)}" part="drop-line" style="--chart-series: var(--chart-series-${(place.point.groupIndex % SERIES) + 1})"></path>` : nothing}<circle cx=${place.x} cy=${place.y} part="point${place.index === at ? ' point-active' : ''}" r="0.045" style="--chart-series: var(--chart-series-${(place.point.groupIndex % SERIES) + 1})"></circle>`)}${active
191
228
  ? svg `<circle cx=${active.x} cy=${active.y} part="ring" r="0.085"></circle><foreignObject height="0.001" overflow="visible" width="0.001" x=${active.x} y=${active.y}>${this.renderOwnTooltip(active.point.row)}</foreignObject>`
192
229
  : nothing}</svg>
193
230
  </div>`;
@@ -237,6 +274,12 @@ __decorate([
237
274
  __decorate([
238
275
  property({ attribute: 'group-by' })
239
276
  ], HelixHeadlessSpatialScatterChart.prototype, "groupBy", void 0);
277
+ __decorate([
278
+ property({ reflect: true, type: Boolean })
279
+ ], HelixHeadlessSpatialScatterChart.prototype, "grow", void 0);
280
+ __decorate([
281
+ property({ attribute: 'grow-again', reflect: true, type: Boolean })
282
+ ], HelixHeadlessSpatialScatterChart.prototype, "growAgain", void 0);
240
283
  __decorate([
241
284
  property({ attribute: 'no-box', reflect: true, type: Boolean })
242
285
  ], HelixHeadlessSpatialScatterChart.prototype, "noBox", void 0);
@@ -5,6 +5,7 @@
5
5
  * reading put in the wrong cell bends the surface in a place the data never
6
6
  * did, and a missing reading drawn as zero digs a pit that is not there.
7
7
  */
8
+ import { type MotionItem, type MotionShares } from '@fusion.dev/helix-core';
8
9
  import { type FieldRow, type PlotAxis } from '../spatial-scatter-chart/field.js';
9
10
  /** One place on the grid: where it stands across and in depth, and its reading, where the table has one. */
10
11
  export interface SurfaceCell {
@@ -73,3 +74,18 @@ export interface Contour {
73
74
  export declare const contoursOf: (field: SurfaceField, levels: readonly number[]) => Contour[];
74
75
  /** The levels a surface's contour lines run at: its height's ticks strictly between its lowest and highest reading. */
75
76
  export declare const contourLevels: (field: SurfaceField) => number[];
77
+ /** Each place on the grid as the chart's motion knows it: by where it stands, growing in a row across at a time. */
78
+ export declare const surfaceItems: (field: SurfaceField) => MotionItem[];
79
+ /**
80
+ * The surface `at` the shares between `from` and `to`, which the chart draws
81
+ * while its readings move: **each place rises or falls from its old height to
82
+ * its new one**, a place that gains a reading rises from the lowest reading,
83
+ * and one that loses its reading sinks to it and then opens. The height's
84
+ * axis and its ramp move with `at.axes`, and the contour lines are drawn at
85
+ * the new levels through the surface as it moves. With no `from`, the
86
+ * surface rises from a sheet at its lowest reading.
87
+ *
88
+ * **A grid whose places changed cannot be matched**, place for place, so it
89
+ * is drawn as `to` at once.
90
+ */
91
+ export declare const surfaceBetween: (from: SurfaceField | undefined, to: SurfaceField, at: MotionShares) => SurfaceField;
@@ -1,4 +1,4 @@
1
- import { ticks } from '@fusion.dev/helix-core';
1
+ import { mix, mixAxis, ticks } from '@fusion.dev/helix-core';
2
2
  import { niceRange } from '../spatial-scatter-chart/field.js';
3
3
  export const surfaceOf = (rows, columns) => {
4
4
  const [xAt, zAt, yAt] = columns;
@@ -111,3 +111,38 @@ export const contoursOf = (field, levels) => {
111
111
  });
112
112
  };
113
113
  export const contourLevels = (field) => field.axes.y.ticks.filter((tick) => tick > field.lowest && tick < field.highest);
114
+ const placeKey = (cell) => `${cell.x}\u0001${cell.z}`;
115
+ export const surfaceItems = (field) => field.cells.map((cell, index) => ({
116
+ key: placeKey(cell),
117
+ step: Math.floor(index / Math.max(field.depths.length, 1)),
118
+ }));
119
+ const samePlaces = (one, other) => one.length === other.length && one.every((place, at) => place === other[at]);
120
+ export const surfaceBetween = (from, to, at) => {
121
+ if (from && !(samePlaces(from.acrosses, to.acrosses) && samePlaces(from.depths, to.depths))) {
122
+ return to;
123
+ }
124
+ const moved = from !== undefined && at.axes < 1;
125
+ const lowest = moved ? mix(from.lowest, to.lowest, at.axes) : to.lowest;
126
+ const highest = moved ? mix(from.highest, to.highest, at.axes) : to.highest;
127
+ const cells = to.cells.map((cell, index) => {
128
+ const share = at.share(placeKey(cell));
129
+ const old = from?.cells[index];
130
+ if (cell.value === undefined) {
131
+ return old?.value !== undefined && share < 1
132
+ ? { ...old, value: mix(old.value, lowest, share) }
133
+ : cell;
134
+ }
135
+ const start = !old || old.value === undefined || at.floor(placeKey(cell)) ? lowest : old.value;
136
+ return { ...cell, value: mix(start, cell.value, share) };
137
+ });
138
+ const field = {
139
+ ...to,
140
+ axes: moved ? { ...to.axes, y: mixAxis(from.axes.y, to.axes.y, at.axes) } : to.axes,
141
+ cells,
142
+ contours: [],
143
+ highest,
144
+ lowest,
145
+ };
146
+ field.contours = contoursOf(field, contourLevels(to));
147
+ return field;
148
+ };
@@ -1,4 +1,4 @@
1
- import { AriaForwardController, HelixElement } from '@fusion.dev/helix-core';
1
+ import { AriaForwardController, HelixElement, ReadingsMotionController } from '@fusion.dev/helix-core';
2
2
  import { type PropertyValues, type TemplateResult } from 'lit';
3
3
  import '../../tooltip/index.js';
4
4
  import { type SurfaceField } from '../grid.js';
@@ -66,7 +66,7 @@ declare const HelixHeadlessSpatialSurfaceChart_base: typeof HelixElement & (new
66
66
  * @slot error - Content shown after `error-text` while it is set and there are no readings, such as a button that tries again.
67
67
  * @slot loading - Content shown while `loading` is set and there are no readings yet. Falls back to `loading-text`.
68
68
  *
69
- * @event {HelixPlotChangeEvent} helix-plot-change - The readings or the place the keys rest on changed, which the renderer is told. It stays on the chart.
69
+ * @event {HelixPlotChangeEvent} helix-plot-change - The readings or the place the keys rest on changed, or a frame of a move drew the surface on its way, which the renderer is told. It stays on the chart.
70
70
  * @event {HelixPlotTurnEvent} helix-plot-turn - Shift with an arrow asked the view to turn, by a step across or up.
71
71
  * @event {HelixReadingChangeEvent} helix-reading-change - The reading moved, or was put away: `index` is the row, or `-1` for none or a place with no reading, with its `label` and the `pointerType` that moved it.
72
72
  * @event {HelixReadingPressEvent} helix-reading-press - A place was clicked or pressed with Enter or Space, with the same detail as `helix-reading-change`.
@@ -107,6 +107,8 @@ declare const HelixHeadlessSpatialSurfaceChart_base: typeof HelixElement & (new
107
107
  * @csspart tooltip-value - A column's value inside the tooltip.
108
108
  *
109
109
  * @cssproperty --spatial-surface-chart-level - How high a face of the surface stands between the lowest reading and the highest, from 0 to 1: its corners' average. The component writes it on each face, and the stylesheet that colors the face along the ramp reads it.
110
+ * @cssproperty --spatial-surface-chart-move-duration - How long the surface takes to move to a new table's readings: each place rises or falls to its new height, a place that gains a reading rises from the lowest one, and a place that loses its reading sinks to it. A grid whose places changed is drawn at once. Unset, a new table is drawn at once. The rise under `grow` keeps its own timing.
111
+ * @cssproperty --spatial-surface-chart-move-easing - The curve the surface moves to new readings along.
110
112
  * @cssproperty --spatial-surface-chart-shade - How far a face of the surface turns from the light, as a share of lightness to take from its color, from 0 facing it to about 0.3. The component writes it on each face, and the stylesheet that shades the face reads it.
111
113
  *
112
114
  * @cssstate active - While a place is shown, under the pointer or the keys.
@@ -127,6 +129,34 @@ export declare class HelixHeadlessSpatialSurfaceChart extends HelixHeadlessSpati
127
129
  * same height read as such. A renderer draws them too.
128
130
  */
129
131
  contours: boolean;
132
+ /**
133
+ * Raises the surface from a flat sheet at its lowest reading the first
134
+ * time the chart comes into view with readings, each row across a little
135
+ * after the one before it, so the drawing arrives the way a page's own
136
+ * picture does. The rise is fast at first, slows to rest, and never passes
137
+ * a reading.
138
+ *
139
+ * Under `prefers-reduced-motion`, or where the page has paused its motion
140
+ * through `pauseMotion` or `Motion Toggle`, the surface stands at its
141
+ * readings from the start. A later table moves the surface on
142
+ * `--spatial-surface-chart-move-duration`, and stands it at its new
143
+ * readings at once where that is unset: each place rises or falls to its
144
+ * new height, a place that gains a reading rises from the lowest reading,
145
+ * and one that loses its reading sinks to it. A table whose places across
146
+ * or in depth changed draws its new grid at once, since its places cannot
147
+ * be matched to the old ones.
148
+ */
149
+ grow: boolean;
150
+ /**
151
+ * Raises the surface again each time the chart comes back into view after
152
+ * it left it, as a pane does when it is opened again, where `grow` alone
153
+ * raises it the first time only. Only a chart that grows takes it.
154
+ *
155
+ * While it is out of view the surface lies flat, so the first frame after
156
+ * it returns is the start of the rise and never a flash of the whole
157
+ * drawing.
158
+ */
159
+ growAgain: boolean;
130
160
  /**
131
161
  * Draws no box: no edges, grid, numbers, or names, so the readings stand
132
162
  * alone and fill the plot, as a picture on a product's own page does. The
@@ -164,6 +194,14 @@ export declare class HelixHeadlessSpatialSurfaceChart extends HelixHeadlessSpati
164
194
  private last;
165
195
  /** The place the keys rested on last, so a change of it can be told. */
166
196
  private told;
197
+ /**
198
+ * Moves the surface from one table to the next, and raises it under
199
+ * `grow`, timed by `--spatial-surface-chart-move-duration` and
200
+ * `--spatial-surface-chart-move-easing`.
201
+ */
202
+ protected readonly motion: ReadingsMotionController<SurfaceField>;
203
+ /** The surface drawn last, kept so a frame of its move can be told. */
204
+ private lastShown;
167
205
  /** Carries a host `aria-labelledby` and `aria-describedby` to the plot. */
168
206
  protected readonly aria: AriaForwardController;
169
207
  /**
@@ -174,6 +212,12 @@ export declare class HelixHeadlessSpatialSurfaceChart extends HelixHeadlessSpati
174
212
  get field(): SurfaceField;
175
213
  /** The field last read, and the rows it was read from. */
176
214
  private memo;
215
+ /**
216
+ * The surface as drawn this frame, which a renderer draws: `field` at
217
+ * rest, and while the readings move, each place between its last height
218
+ * and its new one, with the contour lines through it.
219
+ */
220
+ get shown(): SurfaceField;
177
221
  /** The place the keys or the pointer rest on, as its place in `field.cells`, or `-1`. */
178
222
  get active(): number;
179
223
  /** The number of places on the grid, which the keys walk. */