@design.estate/dees-catalog 21.27.0 → 21.28.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.
@@ -20,11 +20,20 @@ import { dcLocalize } from '../../i18n/localize.js';
20
20
  * Handles library loading, chart lifecycle, resize observation, and theme switching.
21
21
  * Subclasses implement `buildOption()` to define their chart configuration.
22
22
  *
23
- * A chart is a tile (`dees-tile`): its `label` heads it in the standard header bar and its legend,
24
- * a `dees-legend` whose items switch their series, is in the standard footer bar. One header per
25
- * tile: a chart in a pane that heads it already hands its title to the pane's header and leaves
26
- * `label` empty, and then draws no header row of its own; `summary` still names it to a screen
23
+ * A chart is a tile (`dees-tile`): its `label` heads it in the standard header bar, with `meta` at
24
+ * the bar's end, and its legend, a `dees-legend` whose items switch their series, is in the
25
+ * standard footer bar. Rows of the host's own about the chart (a notice, what the chart leaves out,
26
+ * figures it does not end on) go into the slots `above` and `below`, over and under the plot: at
27
+ * the tile's inset, the header's, with the legend still the tile's last row at its full width. A
28
+ * host so needs no tile of its own around a chart: the chart is the tile. One header per tile: a
29
+ * chart in a pane that heads it already hands its title to the pane's header and leaves `label`
30
+ * and `meta` empty, and then draws no header row of its own; `summary` still names it to a screen
27
31
  * reader.
32
+ *
33
+ * The host's height holds the whole tile (400px by default): the header, the rows, the plot and the
34
+ * legend, the plot taking what the rest leaves. A chart whose rows vary takes `height: auto`, and
35
+ * its plot is then `--dees-chart-plot-height` tall (320px by default, what the default height
36
+ * leaves the plot under a header and a legend of one row).
28
37
  */
29
38
  export abstract class DeesChartEchartsBase extends DeesElement {
30
39
  /** The chart's words and formats, in the reader's language. */
@@ -38,6 +47,14 @@ export abstract class DeesChartEchartsBase extends DeesElement {
38
47
  @property({ reflect: true })
39
48
  accessor label: string = '';
40
49
 
50
+ /**
51
+ * A short text at the end of the header bar, beside `label`: what the chart covers or in which
52
+ * terms ("Fiscal year 2026 to date · net of VAT"). Muted, as a table's `heading2`; where the tile
53
+ * is too narrow for both it wraps under the label, at its start, and the bar grows by that line.
54
+ */
55
+ @property({ reflect: true })
56
+ accessor meta: string = '';
57
+
41
58
  /** Drop the chart's outer frame and surface: the host already owns the surface. */
42
59
  @property({ type: Boolean, reflect: true })
43
60
  accessor frameless: boolean = false;
@@ -139,18 +156,34 @@ export abstract class DeesChartEchartsBase extends DeesElement {
139
156
  off: !this.legendShown(item.name),
140
157
  }));
141
158
  return html`<dees-tile .frameless=${this.frameless}>
142
- ${this.label ? html`<div slot="header" class="chartHeader"><h2 class="chartLabel">${this.label}</h2></div>` : ''}
143
- <div class="chartContainer" aria-hidden="true"><div class="chartPlot"></div></div>
159
+ ${this.label || this.meta ? html`<div slot="header" class="chartHeader ${this.meta ? 'hasMeta' : ''}">${this.label
160
+ ? html`<h2 class="chartLabel">${this.label}</h2>`
161
+ : ''}${this.meta ? html`<span class="chartMeta">${this.meta}</span>` : ''}</div>` : ''}
162
+ ${this.renderRows('above')}
163
+ <div class="chartArea">
164
+ <div class="chartContainer" aria-hidden="true"><div class="chartPlot"></div></div>
165
+ ${message ? html`<div class="chartState" role="status">${message}</div>` : ''}
166
+ </div>
167
+ ${this.renderRows('below')}
144
168
  <p class="chartSummary">${this.summary || this.dataSummary()}</p>
145
169
  ${legend.length ? html`<div slot="footer" class="chartLegend"><dees-legend interactive label=${this.t('chart.series')} .items=${legend} @item-toggle=${(event: CustomEvent<IDeesLegendToggleDetail>) => {
146
170
  const hidden = new Set(this.hiddenSeries);
147
171
  if (event.detail.on) hidden.delete(event.detail.item.label); else hidden.add(event.detail.item.label);
148
172
  this.hiddenSeries = hidden; this.updateChart();
149
173
  }}></dees-legend></div>` : ''}
150
- ${message ? html`<div class="chartState" role="status">${message}</div>` : ''}
151
174
  </dees-tile>`;
152
175
  }
153
176
 
177
+ /**
178
+ * The host's rows over or under the plot, from the slot `above` or `below`; no row, and no room,
179
+ * while nothing is slotted there. Read from the light DOM as each render runs, so the first frame
180
+ * already has them; a `slotchange` renders again.
181
+ */
182
+ private renderRows(placeArg: 'above' | 'below'): TemplateResult {
183
+ const slotted = this.querySelector(`:scope > [slot="${placeArg}"]`) !== null;
184
+ return html`<div class="chartRows ${placeArg} ${slotted ? '' : 'empty'}"><slot name=${placeArg} @slotchange=${() => this.requestUpdate()}></slot></div>`;
185
+ }
186
+
154
187
  public async updated(changedProperties: Map<PropertyKey, unknown>) {
155
188
  super.updated(changedProperties);
156
189
  if (changedProperties.has('goBright') && this.chartInstance) {
@@ -20,6 +20,11 @@ export const chartFrameStyles = css`
20
20
  dees-tile::part(outer) { border-color: var(--dees-color-border-subtle); }
21
21
  .chartHeader { ${tileHeaderBar} }
22
22
  .chartLabel { flex: 1; min-width: 0; margin: 0; font: inherit; overflow-wrap: anywhere; }
23
+ /* The meta text at the end of the header's line, muted as a table's subtitle; where the tile is
24
+ too narrow for both it wraps under the title, at its start, and the bar grows by that line. */
25
+ .chartHeader.hasMeta { flex-wrap: wrap; gap: var(--dees-spacing-2xs) var(--dees-spacing-md); }
26
+ .chartHeader.hasMeta .chartLabel { flex: 1 1 auto; }
27
+ .chartMeta { min-width: 0; color: var(--dees-color-text-muted); font-weight: 400; overflow-wrap: anywhere; }
23
28
  .chartLegend { ${tileFooterBar} }
24
29
  .chartContainer { position: absolute; inset: 0; }
25
30
  .chartState { position: absolute; inset: 0; display: grid; place-content: center; padding: 24px; text-align: center; color: var(--dees-color-text-muted); background: var(--dees-color-bg-primary); }
@@ -30,11 +35,19 @@ export const chartFrameStyles = css`
30
35
  @media (pointer: coarse) { .expandBtn { width: var(--dees-control-height-touch); height: var(--dees-control-height-touch); } }
31
36
  `;
32
37
  /**
33
- * The element ECharts draws into fills the frame, whatever position ECharts writes on it. ECharts
34
- * insets its plot by 16px itself; under a region inset the frame adds the rest, so axes and
35
- * labels line up with the header.
38
+ * The tile's content is a column: the host's rows above, the plot, the host's rows below. The rows
39
+ * keep their height and sit at the tile's inset, the header's; the plot takes the rest of the
40
+ * host's height, or, while the host's height is `auto`, `--dees-chart-plot-height`.
41
+ *
42
+ * The element ECharts draws into fills the plot's frame, whatever position ECharts writes on it.
43
+ * ECharts insets its plot by 16px itself; under a region inset the frame adds the rest, so axes
44
+ * and labels line up with the header.
36
45
  */
37
46
  const echartsPlotStyles = css`
47
+ dees-tile::part(content) { display: flex; flex-direction: column; }
48
+ .chartArea { position: relative; flex: 1 1 var(--dees-chart-plot-height, 320px); min-height: 0; }
49
+ .chartRows { flex: none; display: flex; flex-direction: column; gap: var(--dees-spacing-md); padding: var(--dees-spacing-md) var(--chart-inset-inline, var(--dees-spacing-lg)); }
50
+ .chartRows.empty { display: none; }
38
51
  .chartContainer { inset-inline: calc(var(--chart-inset-inline, 16px) - 16px); }
39
52
  .chartPlot { width: 100%; height: 100%; }
40
53
  `;