bank20baht-ui 0.12.2 → 0.12.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.
@@ -26,9 +26,9 @@ export declare class BahtLineChart extends BahtChartBase {
26
26
  /** Accessible summary; falls back to a generated sentence. */
27
27
  label: string;
28
28
  /**
29
- * Drawing width in SVG units. It follows the host up to `W`, so on a phone
30
- * one unit is one CSS pixel and tick text keeps its real size instead of
31
- * shrinking with a 640-wide drawing scaled into a 360px card.
29
+ * Drawing width in SVG units. It follows the host, so one unit is one CSS
30
+ * pixel and tick text keeps its real size: not shrunk on a phone, not blown
31
+ * up in a wide card (a capped drawing stretched to 1050px set 11px ticks at 18px).
32
32
  */
33
33
  private width;
34
34
  private resizeObserver;
@@ -1,16 +1,16 @@
1
1
  import { html as _, nothing as y, svg as l } from "lit";
2
- import { property as x, state as H, customElement as N } from "lit/decorators.js";
2
+ import { property as x, state as E, customElement as H } from "lit/decorators.js";
3
3
  import { hasDom as k, arr as L } from "../base.js";
4
- import { BahtChartBase as W, niceTicks as q, linearScale as O, chartColor as g, renderTableTwin as R } from "./charts.js";
5
- var U = Object.defineProperty, V = Object.getOwnPropertyDescriptor, c = (o, s, $, r) => {
6
- for (var d = r > 1 ? void 0 : r ? V(s, $) : s, f = o.length - 1, b; f >= 0; f--)
4
+ import { BahtChartBase as N, niceTicks as W, linearScale as O, chartColor as g, renderTableTwin as q } from "./charts.js";
5
+ var R = Object.defineProperty, U = Object.getOwnPropertyDescriptor, c = (o, s, $, r) => {
6
+ for (var d = r > 1 ? void 0 : r ? U(s, $) : s, f = o.length - 1, b; f >= 0; f--)
7
7
  (b = o[f]) && (d = (r ? b(s, $, d) : b(d)) || d);
8
- return r && d && U(s, $, d), d;
8
+ return r && d && R(s, $, d), d;
9
9
  };
10
- const T = 640, X = 280, A = 260, I = 56, a = { top: 14, right: 72, bottom: 30, left: 60 };
11
- let h = class extends W {
10
+ const V = 640, X = 280, A = 260, I = 56, a = { top: 14, right: 72, bottom: 30, left: 60 };
11
+ let h = class extends N {
12
12
  constructor() {
13
- super(...arguments), this.series = [], this.categories = [], this.area = !1, this.markers = [], this.forecast = 0, this.baseline = null, this.labelValues = "ends", this.label = "", this.width = T, this.crosshairAt = null;
13
+ super(...arguments), this.series = [], this.categories = [], this.area = !1, this.markers = [], this.forecast = 0, this.baseline = null, this.labelValues = "ends", this.label = "", this.width = V, this.crosshairAt = null;
14
14
  }
15
15
  connectedCallback() {
16
16
  super.connectedCallback(), !(!k() || typeof ResizeObserver > "u") && (this.resizeObserver = new ResizeObserver(() => {
@@ -31,7 +31,7 @@ let h = class extends W {
31
31
  if (!k() || !this.isConnected) return;
32
32
  const o = this.clientWidth;
33
33
  if (o <= 0) return;
34
- const s = Math.min(T, Math.max(X, Math.round(o)));
34
+ const s = Math.max(X, Math.round(o));
35
35
  s !== this.width && (this.width = s);
36
36
  }
37
37
  get plot() {
@@ -44,20 +44,20 @@ let h = class extends W {
44
44
  }), { series: s, categories: $ } = o;
45
45
  if (s.length === 0)
46
46
  return _`<div class=${this.rootClass("baht-line-chart")}>${this.renderEmpty()}</div>`;
47
- const r = Math.max(...s.map((t) => t.values.length)), d = s.flatMap((t) => t.values).filter((t) => Number.isFinite(t)), f = Math.max(0, ...d, ...this.markers.map((t) => t.value)), b = q(f, 4), z = b[b.length - 1] ?? 1, { w: v, h: F } = this.plot, p = O([0, Math.max(1, r - 1)], [a.left, a.left + v]), i = O([0, z], [a.top + F, a.top]), M = Math.max(0, r - 1 - Math.max(0, this.forecast)), w = (t, e, n) => t.slice(e, n + 1).map((u, m) => `${m === 0 ? "M" : "L"}${p(e + m).toFixed(2)},${i(u).toFixed(2)}`).join(" "), P = s.map((t, e) => ({
47
+ const r = Math.max(...s.map((t) => t.values.length)), d = s.flatMap((t) => t.values).filter((t) => Number.isFinite(t)), f = Math.max(0, ...d, ...this.markers.map((t) => t.value)), b = W(f, 4), T = b[b.length - 1] ?? 1, { w: v, h: F } = this.plot, p = O([0, Math.max(1, r - 1)], [a.left, a.left + v]), i = O([0, T], [a.top + F, a.top]), M = Math.max(0, r - 1 - Math.max(0, this.forecast)), w = (t, e, n) => t.slice(e, n + 1).map((u, m) => `${m === 0 ? "M" : "L"}${p(e + m).toFixed(2)},${i(u).toFixed(2)}`).join(" "), P = s.map((t, e) => ({
48
48
  i: e,
49
49
  name: t.name,
50
50
  value: t.values[t.values.length - 1] ?? 0,
51
51
  yPos: i(t.values[t.values.length - 1] ?? 0),
52
52
  color: g(e, t.color)
53
- })), C = [...P].sort((t, e) => t.yPos - e.yPos), B = C.some((t, e) => e > 0 && t.yPos - C[e - 1].yPos < 15), j = this.labelValues === "ends" && !B, D = Math.max(1, Math.ceil(r / Math.max(2, Math.min(8, Math.floor(v / I))))), E = this.label || `Line chart, ${s.length} series over ${r} points. ${s.map((t, e) => `${t.name}: ${this.fmt(P[e].value)} at the end`).join(". ")}`;
53
+ })), C = [...P].sort((t, e) => t.yPos - e.yPos), z = C.some((t, e) => e > 0 && t.yPos - C[e - 1].yPos < 15), B = this.labelValues === "ends" && !z, j = Math.max(1, Math.ceil(r / Math.max(2, Math.min(8, Math.floor(v / I))))), D = this.label || `Line chart, ${s.length} series over ${r} points. ${s.map((t, e) => `${t.name}: ${this.fmt(P[e].value)} at the end`).join(". ")}`;
54
54
  return _`<div class=${this.rootClass("baht-line-chart")}>
55
55
  <svg
56
56
  class="baht-chart-svg"
57
57
  viewBox="0 0 ${this.width} ${A}"
58
58
  preserveAspectRatio="xMidYMid meet"
59
59
  role="img"
60
- aria-label=${E}
60
+ aria-label=${D}
61
61
  >
62
62
  ${b.map(
63
63
  (t) => l`
@@ -91,13 +91,13 @@ let h = class extends W {
91
91
  cy=${i(t.values[t.values.length - 1] ?? 0).toFixed(2)} r="4" fill=${n}/>`
92
92
  ), u;
93
93
  })}
94
- ${j ? P.map(
94
+ ${B ? P.map(
95
95
  (t) => l`
96
96
  <text class="baht-chart-end-label" x=${p(r - 1) + 10} y=${(t.yPos + 4).toFixed(2)}
97
97
  text-anchor="start">${this.fmt(t.value)}</text>`
98
98
  ) : y}
99
99
  ${$.map(
100
- (t, e) => e % D === 0 ? l`<text class="baht-chart-tick" x=${p(e).toFixed(2)} y=${A - 10} text-anchor="middle">${t}</text>` : y
100
+ (t, e) => e % j === 0 ? l`<text class="baht-chart-tick" x=${p(e).toFixed(2)} y=${A - 10} text-anchor="middle">${t}</text>` : y
101
101
  )}
102
102
  ${Array.from({ length: r }, (t, e) => {
103
103
  const n = v / Math.max(1, r - 1), u = `${$[e] ?? `Point ${e + 1}`}: ${s.map((m) => `${m.name} ${this.fmt(m.values[e] ?? 0)}`).join(", ")}`;
@@ -125,7 +125,7 @@ let h = class extends W {
125
125
  s.map((t, e) => ({ label: t.name, color: g(e, t.color) })),
126
126
  "line"
127
127
  )}
128
- ${this.showTable ? R(
128
+ ${this.showTable ? q(
129
129
  this.label || "Line chart data",
130
130
  ["Point", ...s.map((t) => t.name)],
131
131
  Array.from({ length: r }, (t, e) => [
@@ -167,10 +167,10 @@ c([
167
167
  x()
168
168
  ], h.prototype, "label", 2);
169
169
  c([
170
- H()
170
+ E()
171
171
  ], h.prototype, "width", 2);
172
172
  h = c([
173
- N("baht-line-chart")
173
+ H("baht-line-chart")
174
174
  ], h);
175
175
  export {
176
176
  h as BahtLineChart
@@ -29,6 +29,15 @@
29
29
  .baht-field--w-full {
30
30
  flex-basis: 100%;
31
31
  }
32
+ /* Phone: a half- or quarter-width field is too narrow to read (a datepicker
33
+ cut "19:02" to "19:0"), so every field takes the whole row. */
34
+ @media (max-width: 480px) {
35
+ .baht-field--w-1-4,
36
+ .baht-field--w-1-2,
37
+ .baht-field--w-3-4 {
38
+ flex-basis: 100%;
39
+ }
40
+ }
32
41
  .baht-field--hidden {
33
42
  display: none;
34
43
  }
@@ -10143,7 +10143,7 @@
10143
10143
  "name": "width",
10144
10144
  "privacy": "private",
10145
10145
  "default": "640",
10146
- "description": "Drawing width in SVG units. It follows the host up to `W`, so on a phone\none unit is one CSS pixel and tick text keeps its real size instead of\nshrinking with a 640-wide drawing scaled into a 360px card.",
10146
+ "description": "Drawing width in SVG units. It follows the host, so one unit is one CSS\npixel and tick text keeps its real size: not shrunk on a phone, not blown\nup in a wide card (a capped drawing stretched to 1050px set 11px ticks at 18px).",
10147
10147
  "type": {
10148
10148
  "text": "number"
10149
10149
  }
package/dist/tokens.css CHANGED
@@ -463,6 +463,15 @@
463
463
  .baht-field--w-full {
464
464
  flex-basis: 100%;
465
465
  }
466
+ /* Phone: a half- or quarter-width field is too narrow to read (a datepicker
467
+ cut "19:02" to "19:0"), so every field takes the whole row. */
468
+ @media (max-width: 480px) {
469
+ .baht-field--w-1-4,
470
+ .baht-field--w-1-2,
471
+ .baht-field--w-3-4 {
472
+ flex-basis: 100%;
473
+ }
474
+ }
466
475
  .baht-field--hidden {
467
476
  display: none;
468
477
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "name": "bank20baht-ui",
4
- "version": "0.12.2",
4
+ "version": "0.12.3",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bank20baht-ui",
3
- "version": "0.12.2",
3
+ "version": "0.12.3",
4
4
  "type": "module",
5
5
  "description": "JSON-driven form + workflow engine. Send JSON in, get an interactive form out.",
6
6
  "license": "MIT",