@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,10 @@
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
6
  import { boundsOf, boxView, DragTurn, drawBox, inBox, nearestTo, PlotRoomWatch, SPATIAL_VIEW, shape, turned, wordsFitted, } from '../../spatial-scatter-chart/view.js';
7
- import { levelOf, surfaceOf } from '../grid.js';
7
+ import { levelOf, surfaceBetween, surfaceItems, surfaceOf } from '../grid.js';
8
8
  const LIGHT = (() => {
9
9
  const [x, y, z] = [-0.45, 1, 0.35];
10
10
  const length = Math.hypot(x, y, z);
@@ -21,6 +21,8 @@ let HelixHeadlessSpatialSurfaceChart = class HelixHeadlessSpatialSurfaceChart ex
21
21
  constructor() {
22
22
  super(...arguments);
23
23
  this.contours = false;
24
+ this.grow = false;
25
+ this.growAgain = false;
24
26
  this.noBox = false;
25
27
  this.openLabel = '{across} {x}, {depth} {z}: no reading';
26
28
  this.plotLabel = '3D surface chart';
@@ -33,6 +35,19 @@ let HelixHeadlessSpatialSurfaceChart = class HelixHeadlessSpatialSurfaceChart ex
33
35
  }, () => this.requestUpdate());
34
36
  this.placed = [];
35
37
  this.told = -1;
38
+ this.motion = new ReadingsMotionController(this, {
39
+ between: surfaceBetween,
40
+ grow: () => this.grow,
41
+ growAgain: () => this.growAgain,
42
+ items: surfaceItems,
43
+ timing: () => {
44
+ const style = getComputedStyle(this);
45
+ return {
46
+ duration: style.getPropertyValue('--spatial-surface-chart-move-duration'),
47
+ easing: style.getPropertyValue('--spatial-surface-chart-move-easing'),
48
+ };
49
+ },
50
+ });
36
51
  this.aria = new AriaForwardController(this, {
37
52
  target: () => this.partNamed('plot'),
38
53
  });
@@ -83,6 +98,9 @@ let HelixHeadlessSpatialSurfaceChart = class HelixHeadlessSpatialSurfaceChart ex
83
98
  }
84
99
  return this.memo.field;
85
100
  }
101
+ get shown() {
102
+ return this.motion.drawn ?? this.field;
103
+ }
86
104
  get active() {
87
105
  return this.pointer.at;
88
106
  }
@@ -106,7 +124,9 @@ let HelixHeadlessSpatialSurfaceChart = class HelixHeadlessSpatialSurfaceChart ex
106
124
  }
107
125
  willUpdate(changed) {
108
126
  super.willUpdate(changed);
109
- this.pointer.grid = Math.max(1, this.field.depths.length);
127
+ const field = this.field;
128
+ this.pointer.grid = Math.max(1, field.depths.length);
129
+ this.motion.follow(field, field.readings > 0);
110
130
  }
111
131
  connectedCallback() {
112
132
  super.connectedCallback();
@@ -120,10 +140,16 @@ let HelixHeadlessSpatialSurfaceChart = class HelixHeadlessSpatialSurfaceChart ex
120
140
  updated(changed) {
121
141
  super.updated(changed);
122
142
  const field = this.field;
143
+ const shown = this.shown;
123
144
  if (field !== this.last) {
124
145
  this.last = field;
146
+ this.lastShown = shown;
125
147
  this.dispatchEvent(new HelixPlotChangeEvent({ kind: 'data' }));
126
148
  }
149
+ else if (shown !== this.lastShown) {
150
+ this.lastShown = shown;
151
+ this.dispatchEvent(new HelixPlotChangeEvent({ kind: 'move' }));
152
+ }
127
153
  if (this.pointer.at !== this.told) {
128
154
  this.told = this.pointer.at;
129
155
  this.dispatchEvent(new HelixPlotChangeEvent({ kind: 'focus' }));
@@ -162,8 +188,12 @@ let HelixHeadlessSpatialSurfaceChart = class HelixHeadlessSpatialSurfaceChart ex
162
188
  </div>
163
189
  ${readable ? this.renderSummary(field) : this.renderStatus()}${this.renderSonify()}${this.renderTable()}`;
164
190
  }
165
- renderFallback(field, at) {
166
- const view = wordsFitted(this.plotRoom.room, (words) => boxView(field.axes, this.camera, [], this.noBox, words, wordsLocale(this)));
191
+ renderFallback(read, at) {
192
+ const view = wordsFitted(this.plotRoom.room, (words) => boxView(read.axes, this.camera, [], this.noBox, words, wordsLocale(this)));
193
+ const field = this.motion.moving ? this.shown : read;
194
+ const moving = field === read
195
+ ? view
196
+ : boxView(field.axes, this.camera, [], this.noBox, view.words, wordsLocale(this));
167
197
  const depths = field.depths.length;
168
198
  const boxed = field.cells.map((cell) => cell.value === undefined
169
199
  ? undefined
@@ -196,7 +226,17 @@ let HelixHeadlessSpatialSurfaceChart = class HelixHeadlessSpatialSurfaceChart ex
196
226
  faces.sort((one, other) => one.depth - other.depth);
197
227
  const active = places.find((place) => place.index === at);
198
228
  const row = field.cells[at]?.row;
199
- const bounds = this.drag.frame(this.noBox ? boundsOf(places, 0.1) : view.bounds, view.on([0, 0, 0]));
229
+ const bounds = this.drag.frame(this.noBox
230
+ ? boundsOf(read.cells.flatMap((cell) => cell.value === undefined
231
+ ? []
232
+ : [
233
+ view.on([
234
+ inBox(read.axes.x, cell.x),
235
+ inBox(read.axes.y, cell.value),
236
+ inBox(read.axes.z, cell.z),
237
+ ]),
238
+ ]), 0.1)
239
+ : view.bounds, view.on([0, 0, 0]));
200
240
  const short = (value) => Math.round(value * 1000) / 1000;
201
241
  return html `<div aria-hidden="true" dir="ltr" ?hidden=${this.rendered} part="fallback">
202
242
  <svg
@@ -210,7 +250,7 @@ let HelixHeadlessSpatialSurfaceChart = class HelixHeadlessSpatialSurfaceChart ex
210
250
  @pointerleave=${this.onDrawingLeave}
211
251
  @pointermove=${this.onDrawingMove}
212
252
  @pointerup=${this.onDrawingTap}
213
- >${this.noBox ? nothing : drawBox(view)}${faces.map((face) => svg `<path d=${shape(face.points.map((point) => view.on(point)))} data-corners=${face.corners.join(' ')} part="face" style="--spatial-surface-chart-level: ${short(face.level)}; --spatial-surface-chart-shade: ${short(face.shade)}"></path>${this.contours ? this.renderContoursIn(field, face.square, view.on) : nothing}`)}${active
253
+ >${this.noBox ? nothing : drawBox(moving)}${faces.map((face) => svg `<path d=${shape(face.points.map((point) => view.on(point)))} data-corners=${face.corners.join(' ')} part="face" style="--spatial-surface-chart-level: ${short(face.level)}; --spatial-surface-chart-shade: ${short(face.shade)}"></path>${this.contours ? this.renderContoursIn(field, face.square, view.on) : nothing}`)}${active
214
254
  ? 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(row)}</foreignObject>`
215
255
  : nothing}</svg>
216
256
  </div>`;
@@ -290,6 +330,12 @@ let HelixHeadlessSpatialSurfaceChart = class HelixHeadlessSpatialSurfaceChart ex
290
330
  __decorate([
291
331
  property({ reflect: true, type: Boolean })
292
332
  ], HelixHeadlessSpatialSurfaceChart.prototype, "contours", void 0);
333
+ __decorate([
334
+ property({ reflect: true, type: Boolean })
335
+ ], HelixHeadlessSpatialSurfaceChart.prototype, "grow", void 0);
336
+ __decorate([
337
+ property({ attribute: 'grow-again', reflect: true, type: Boolean })
338
+ ], HelixHeadlessSpatialSurfaceChart.prototype, "growAgain", void 0);
293
339
  __decorate([
294
340
  property({ attribute: 'no-box', reflect: true, type: Boolean })
295
341
  ], HelixHeadlessSpatialSurfaceChart.prototype, "noBox", void 0);
@@ -6,7 +6,7 @@
6
6
  * that is the same, and blocks painted in the wrong order cover the ones in
7
7
  * front of them.
8
8
  */
9
- import { type Drawn, type PagePoint, type Projection } from '@fusion.dev/helix-core';
9
+ import { type Drawn, type MotionItem, type MotionShares, type PagePoint, type Projection } from '@fusion.dev/helix-core';
10
10
  import { type FieldRow, type PlotAxis } from '../spatial-scatter-chart/field.js';
11
11
  import { type BoxExtent } from '../spatial-scatter-chart/view.js';
12
12
  /** A part of the floor: across from `x0` to `x1`, and in depth from `z0` to `z1`, each from -1 to 1. */
@@ -24,8 +24,19 @@ export interface TreemapBlock {
24
24
  group: string;
25
25
  /** Its group's place among the groups, which its color is read by. */
26
26
  groupIndex: number;
27
+ /**
28
+ * How much of its height it stands at, from 0 on the floor to 1, on a field
29
+ * drawn between two tables while it grows in or shrinks away. A table's own
30
+ * field has none, and every block stands whole.
31
+ */
32
+ grown?: number | undefined;
27
33
  /** Its height, from the second numeric column, where the table has one. */
28
34
  height?: number | undefined;
35
+ /**
36
+ * What the block is known by from one table to the next, on a field drawn
37
+ * between two while the readings move. A table's own field has none.
38
+ */
39
+ key?: string | undefined;
29
40
  /** The row's own label. */
30
41
  label: string;
31
42
  /** The row it was read from, counting from zero. */
@@ -72,6 +83,26 @@ export declare const squarified: (sizes: readonly number[], within: FloorArea) =
72
83
  * largest stand at the back left**, where they hide the least.
73
84
  */
74
85
  export declare const treemapOf: (rows: readonly FieldRow[], columns: readonly number[], groupBy?: string) => TreemapField;
86
+ /**
87
+ * The key of each block of `field`, in its order: its label, numbered where a
88
+ * label comes again. A field drawn between two tables carries each block's
89
+ * key with it.
90
+ */
91
+ export declare const blockKeys: (field: TreemapField) => string[];
92
+ /** Each block as the chart's motion knows it: by its key, growing in in the table's order. */
93
+ export declare const blockItems: (field: TreemapField) => MotionItem[];
94
+ /**
95
+ * The blocks `at` the shares between `from` and `to`, which the chart draws
96
+ * while its readings move. **A block both tables hold moves** to its new
97
+ * part of the floor and its new height. **A block only `to` holds grows**:
98
+ * from the floor while the chart grows in, and in a later table from the
99
+ * middle of its part of the floor as well, while its neighbors make room.
100
+ * **A block only `from` held shrinks** to the middle of its part and to the
101
+ * floor, after `to`'s blocks, and goes. The height's axis moves with
102
+ * `at.axes`. With no `from`, every block rises from the floor where it
103
+ * stands.
104
+ */
105
+ export declare const blocksBetween: (from: TreemapField | undefined, to: TreemapField, at: MotionShares) => TreemapField;
75
106
  /** A block as the chart's own drawing paints it. */
76
107
  export interface DrawnBlock {
77
108
  /** Its eight corners on the page, which a drawing with no box is framed around. */
@@ -1,4 +1,4 @@
1
- import { solid, ticks } from '@fusion.dev/helix-core';
1
+ import { keysOf, mix, mixAxis, solid, ticks, } from '@fusion.dev/helix-core';
2
2
  import { niceRange } from '../spatial-scatter-chart/field.js';
3
3
  import { inBox } from '../spatial-scatter-chart/view.js';
4
4
  const HEIGHT = 0.6;
@@ -122,12 +122,82 @@ export const treemapOf = (rows, columns, groupBy = '') => {
122
122
  size: nameOf(sizeAt),
123
123
  };
124
124
  };
125
+ export const blockKeys = (field) => {
126
+ const keys = keysOf(field.blocks.map((block) => block.label));
127
+ return field.blocks.map((block, index) => block.key ?? keys[index]);
128
+ };
129
+ export const blockItems = (field) => blockKeys(field).map((key, step) => ({ key, step }));
130
+ const mixArea = (from, to, share) => ({
131
+ x0: mix(from.x0, to.x0, share),
132
+ x1: mix(from.x1, to.x1, share),
133
+ z0: mix(from.z0, to.z0, share),
134
+ z1: mix(from.z1, to.z1, share),
135
+ });
136
+ const middleOf = (area) => {
137
+ const [x, z] = [(area.x0 + area.x1) / 2, (area.z0 + area.z1) / 2];
138
+ return { x0: x, x1: x, z0: z, z1: z };
139
+ };
140
+ export const blocksBetween = (from, to, at) => {
141
+ const before = new Map();
142
+ if (from) {
143
+ const had = blockKeys(from);
144
+ from.blocks.forEach((block, index) => {
145
+ before.set(had[index], block);
146
+ });
147
+ }
148
+ const keys = blockKeys(to);
149
+ const blocks = to.blocks.map((block, index) => {
150
+ const key = keys[index];
151
+ const share = at.share(key);
152
+ const old = before.get(key);
153
+ if (!old || at.floor(key)) {
154
+ const start = old ? old.area : from ? middleOf(block.area) : block.area;
155
+ return { ...block, area: mixArea(start, block.area, share), grown: share, key };
156
+ }
157
+ const height = old.height !== undefined && block.height !== undefined
158
+ ? mix(old.height, block.height, share)
159
+ : block.height;
160
+ return {
161
+ ...block,
162
+ area: mixArea(old.area, block.area, share),
163
+ grown: mix(old.grown ?? 1, 1, share),
164
+ height,
165
+ key,
166
+ };
167
+ });
168
+ const kept = new Set(keys);
169
+ for (const [key, old] of before) {
170
+ const share = at.share(key);
171
+ if (!kept.has(key) && share < 1) {
172
+ blocks.push({
173
+ ...old,
174
+ area: mixArea(old.area, middleOf(old.area), share),
175
+ grown: (old.grown ?? 1) * (1 - share),
176
+ key,
177
+ });
178
+ }
179
+ }
180
+ if (!from || at.axes >= 1 || from.height !== to.height) {
181
+ return { ...to, blocks };
182
+ }
183
+ const [fx, fy, fz] = from.axes.extent;
184
+ const [tx, ty, tz] = to.axes.extent;
185
+ return {
186
+ ...to,
187
+ axes: {
188
+ ...to.axes,
189
+ extent: [mix(fx, tx, at.axes), mix(fy, ty, at.axes), mix(fz, tz, at.axes)],
190
+ y: mixAxis(from.axes.y, to.axes.y, at.axes),
191
+ },
192
+ blocks,
193
+ };
194
+ };
125
195
  export const blocksDrawn = (field, projection) => {
126
196
  const [ex, ey, ez] = field.axes.extent;
127
197
  const zero = inBox(field.axes.y, 0) * ey;
128
198
  const tall = field.height !== '';
129
199
  return field.blocks.map((block, index) => {
130
- const top = inBox(field.axes.y, tall ? (block.height ?? 0) : 1) * ey;
200
+ const top = inBox(field.axes.y, (tall ? (block.height ?? 0) : 1) * (block.grown ?? 1)) * ey;
131
201
  const base = Math.min(zero, top);
132
202
  const height = Math.abs(top - zero);
133
203
  const floor = {
@@ -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 TreemapField } from '../blocks.js';
@@ -68,7 +68,7 @@ declare const HelixHeadlessSpatialTreemap_base: typeof HelixElement & (new (...a
68
68
  * @slot error - Content shown after `error-text` while it is set and there are no readings, such as a button that tries again.
69
69
  * @slot loading - Content shown while `loading` is set and there are no readings yet. Falls back to `loading-text`.
70
70
  *
71
- * @event {HelixPlotChangeEvent} helix-plot-change - The blocks or the block the keys rest on changed, which the renderer is told. It stays on the chart.
71
+ * @event {HelixPlotChangeEvent} helix-plot-change - The blocks or the block the keys rest on changed, or a frame of a move drew the blocks on their way, which the renderer is told. It stays on the chart.
72
72
  * @event {HelixPlotTurnEvent} helix-plot-turn - Shift with an arrow asked the view to turn, by a step across or up.
73
73
  * @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.
74
74
  * @event {HelixReadingPressEvent} helix-reading-press - A block was clicked or pressed with Enter or Space, with the same detail as `helix-reading-change`.
@@ -110,6 +110,8 @@ declare const HelixHeadlessSpatialTreemap_base: typeof HelixElement & (new (...a
110
110
  * @csspart tooltip-surface-top - The bubble while it is above the reading. Set alongside `tooltip-surface`.
111
111
  * @csspart tooltip-value - A column's value inside the tooltip.
112
112
  *
113
+ * @cssproperty --spatial-treemap-move-duration - How long the blocks take to move to a new table's readings: a block the table keeps moves to its new part of the floor and its new height, a block it adds grows from the middle of its part, and a block it drops shrinks away. Unset, a new table is drawn at once. The growth under `grow` keeps its own timing.
114
+ * @cssproperty --spatial-treemap-move-easing - The curve the blocks move to new readings along.
113
115
  * @cssproperty --spatial-treemap-shade - How far a block's face turns from the light, from 0 for its top. The component writes it on each face, and the stylesheet that shades the face reads it.
114
116
  *
115
117
  * @cssstate active - While a block is shown, under the pointer or the keys.
@@ -126,6 +128,29 @@ export declare class HelixHeadlessSpatialTreemap extends HelixHeadlessSpatialTre
126
128
  static words: string;
127
129
  /** The column of text that gathers the rows into groups, by its heading. None by default. */
128
130
  groupBy: string;
131
+ /**
132
+ * Grows the blocks 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 blocks stand at their
139
+ * readings from the start. A later table grows the blocks it adds, each
140
+ * from the floor, so a reading that arrives while the chart is in view
141
+ * arrives the same way. The blocks it keeps move to their new parts of the floor and their new heights on `--spatial-treemap-move-duration`, and stand there at once where it is unset.
142
+ */
143
+ grow: boolean;
144
+ /**
145
+ * Grows the blocks 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 blocks 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;
129
154
  /**
130
155
  * Draws no box: no edges, grid, numbers, or names, so the readings stand
131
156
  * alone and fill the plot, as a picture on a product's own page does. The
@@ -154,6 +179,14 @@ export declare class HelixHeadlessSpatialTreemap extends HelixHeadlessSpatialTre
154
179
  private last;
155
180
  /** The block the keys rested on last, so a change of it can be told. */
156
181
  private told;
182
+ /**
183
+ * Moves the blocks from one table to the next, and grows them in under
184
+ * `grow`, timed by `--spatial-treemap-move-duration` and
185
+ * `--spatial-treemap-move-easing`.
186
+ */
187
+ protected readonly motion: ReadingsMotionController<TreemapField>;
188
+ /** The blocks drawn last, kept so a frame of their move can be told. */
189
+ private lastShown;
157
190
  /** Carries a host `aria-labelledby` and `aria-describedby` to the plot. */
158
191
  protected readonly aria: AriaForwardController;
159
192
  /**
@@ -178,7 +211,7 @@ export declare class HelixHeadlessSpatialTreemap extends HelixHeadlessSpatialTre
178
211
  * A touch keeps it until a tap lands elsewhere, and a mouse leaving a
179
212
  * reading the keys moved to leaves it. Called by the connector.
180
213
  */
181
- requestActive(index: number, kind?: 'mouse' | 'pen' | 'touch'): void;
214
+ requestActive(at: number, kind?: 'mouse' | 'pen' | 'touch'): void;
182
215
  /**
183
216
  * Says where the renderer draws the reading, as fractions of the plot from
184
217
  * its top left, or `undefined` while it draws none. The tooltip points
@@ -188,6 +221,15 @@ export declare class HelixHeadlessSpatialTreemap extends HelixHeadlessSpatialTre
188
221
  x: number;
189
222
  y: number;
190
223
  } | undefined): void;
224
+ /**
225
+ * The blocks as drawn this frame, which a renderer draws: `field` at rest,
226
+ * and while the readings move, every block between its last place and its
227
+ * new one, in `field`'s order, then each block the last table had and the
228
+ * new one does not, shrinking away.
229
+ */
230
+ get shown(): TreemapField;
231
+ /** Decided before the table is drawn, so a block that grows never shows at its height first. */
232
+ protected willUpdate(changed: PropertyValues<this>): void;
191
233
  connectedCallback(): void;
192
234
  protected updated(changed: PropertyValues): void;
193
235
  /**
@@ -1,10 +1,10 @@
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
6
  import { boundsOf, boxView, DragTurn, drawBox, PlotRoomWatch, SPATIAL_VIEW, turned, wordsFitted, } from '../../spatial-scatter-chart/view.js';
7
- import { blocksDrawn, paintOrder, treemapOf, } from '../blocks.js';
7
+ import { blockItems, blocksBetween, blocksDrawn, paintOrder, treemapOf, } from '../blocks.js';
8
8
  const TURNS = {
9
9
  ArrowDown: { across: 0, up: -1 },
10
10
  ArrowLeft: { across: -1, up: 0 },
@@ -16,6 +16,8 @@ let HelixHeadlessSpatialTreemap = class HelixHeadlessSpatialTreemap extends Mixi
16
16
  constructor() {
17
17
  super(...arguments);
18
18
  this.groupBy = '';
19
+ this.grow = false;
20
+ this.growAgain = false;
19
21
  this.noBox = false;
20
22
  this.plotLabel = '3D treemap';
21
23
  this.summaryLabel = '{count, plural, one {# item} other {# items}} in {groups, plural, one {# group} other {# groups}}, sized from {low} to {high}.';
@@ -26,6 +28,19 @@ let HelixHeadlessSpatialTreemap = class HelixHeadlessSpatialTreemap extends Mixi
26
28
  this.camera = next(this.camera);
27
29
  }, () => this.requestUpdate());
28
30
  this.told = -1;
31
+ this.motion = new ReadingsMotionController(this, {
32
+ between: blocksBetween,
33
+ grow: () => this.grow,
34
+ growAgain: () => this.growAgain,
35
+ items: blockItems,
36
+ timing: () => {
37
+ const style = getComputedStyle(this);
38
+ return {
39
+ duration: style.getPropertyValue('--spatial-treemap-move-duration'),
40
+ easing: style.getPropertyValue('--spatial-treemap-move-easing'),
41
+ };
42
+ },
43
+ });
29
44
  this.aria = new AriaForwardController(this, {
30
45
  target: () => this.partNamed('plot'),
31
46
  });
@@ -94,7 +109,8 @@ let HelixHeadlessSpatialTreemap = class HelixHeadlessSpatialTreemap extends Mixi
94
109
  this.rendered = on;
95
110
  this.toggleState('drawn', on);
96
111
  }
97
- requestActive(index, kind = 'mouse') {
112
+ requestActive(at, kind = 'mouse') {
113
+ const index = at < this.field.blocks.length ? at : -1;
98
114
  if (kind === 'touch') {
99
115
  this.pointer.tapTo(index);
100
116
  }
@@ -105,6 +121,14 @@ let HelixHeadlessSpatialTreemap = class HelixHeadlessSpatialTreemap extends Mixi
105
121
  placeReading(at) {
106
122
  this.place = at;
107
123
  }
124
+ get shown() {
125
+ return this.motion.drawn ?? this.field;
126
+ }
127
+ willUpdate(changed) {
128
+ super.willUpdate(changed);
129
+ const field = this.field;
130
+ this.motion.follow(field, field.blocks.length > 0);
131
+ }
108
132
  connectedCallback() {
109
133
  super.connectedCallback();
110
134
  this.pointer.axis = 'none';
@@ -117,10 +141,16 @@ let HelixHeadlessSpatialTreemap = class HelixHeadlessSpatialTreemap extends Mixi
117
141
  updated(changed) {
118
142
  super.updated(changed);
119
143
  const field = this.field;
144
+ const shown = this.shown;
120
145
  if (field !== this.last) {
121
146
  this.last = field;
147
+ this.lastShown = shown;
122
148
  this.dispatchEvent(new HelixPlotChangeEvent({ kind: 'data' }));
123
149
  }
150
+ else if (shown !== this.lastShown) {
151
+ this.lastShown = shown;
152
+ this.dispatchEvent(new HelixPlotChangeEvent({ kind: 'move' }));
153
+ }
124
154
  if (this.pointer.at !== this.told) {
125
155
  this.told = this.pointer.at;
126
156
  this.dispatchEvent(new HelixPlotChangeEvent({ kind: 'focus' }));
@@ -157,10 +187,14 @@ let HelixHeadlessSpatialTreemap = class HelixHeadlessSpatialTreemap extends Mixi
157
187
  }
158
188
  renderFallback(field, at) {
159
189
  const view = wordsFitted(this.plotRoom.room, (words) => boxView(field.axes, this.camera, [], this.noBox, words, wordsLocale(this)));
160
- const blocks = blocksDrawn(field, view.projection);
190
+ const drawn = this.motion.moving ? this.shown : field;
191
+ const moving = drawn === field
192
+ ? view
193
+ : boxView(drawn.axes, this.camera, [], this.noBox, view.words, wordsLocale(this));
194
+ const blocks = blocksDrawn(drawn, view.projection);
161
195
  const active = blocks[at];
162
196
  const bounds = this.drag.frame(this.noBox
163
- ? boundsOf(blocks.flatMap((block) => block.corners), 0.1)
197
+ ? boundsOf((drawn === field ? blocks : blocksDrawn(field, view.projection)).flatMap((block) => block.corners), 0.1)
164
198
  : view.bounds, view.on([0, 0, 0]));
165
199
  return html `<div aria-hidden="true" dir="ltr" ?hidden=${this.rendered} part="fallback">
166
200
  <svg
@@ -174,7 +208,7 @@ let HelixHeadlessSpatialTreemap = class HelixHeadlessSpatialTreemap extends Mixi
174
208
  @pointerleave=${this.onDrawingLeave}
175
209
  @pointermove=${this.onDrawingMove}
176
210
  @pointerup=${this.onDrawingTap}
177
- >${this.noBox ? nothing : drawBox(view)}${paintOrder(view.projection, blocks).map((block) => svg `${this.renderBlock(field, block, at)}${block === active ? svg `<path d=${active.drawn.outline} part="ring"></path>` : nothing}`)}${active
211
+ >${this.noBox ? nothing : drawBox(moving)}${paintOrder(view.projection, blocks).map((block) => svg `${this.renderBlock(drawn, block, at)}${block === active ? svg `<path d=${active.drawn.outline} part="ring"></path>` : nothing}`)}${active
178
212
  ? svg `<path d=${active.drawn.outline} part="ring-behind"></path><foreignObject height="0.001" overflow="visible" width="0.001" x=${active.drawn.peak.x} y=${active.drawn.peak.y}>${this.renderOwnTooltip(field.blocks[at]?.row)}</foreignObject>`
179
213
  : nothing}</svg>
180
214
  </div>`;
@@ -224,6 +258,12 @@ let HelixHeadlessSpatialTreemap = class HelixHeadlessSpatialTreemap extends Mixi
224
258
  __decorate([
225
259
  property({ attribute: 'group-by' })
226
260
  ], HelixHeadlessSpatialTreemap.prototype, "groupBy", void 0);
261
+ __decorate([
262
+ property({ reflect: true, type: Boolean })
263
+ ], HelixHeadlessSpatialTreemap.prototype, "grow", void 0);
264
+ __decorate([
265
+ property({ attribute: 'grow-again', reflect: true, type: Boolean })
266
+ ], HelixHeadlessSpatialTreemap.prototype, "growAgain", void 0);
227
267
  __decorate([
228
268
  property({ attribute: 'no-box', reflect: true, type: Boolean })
229
269
  ], HelixHeadlessSpatialTreemap.prototype, "noBox", void 0);