@dashspec/renderer 0.1.9 → 0.1.11

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.
package/CHANGELOG.md CHANGED
@@ -14,6 +14,34 @@ under the new version.
14
14
 
15
15
  ## [Unreleased]
16
16
 
17
+ ## [0.1.11] - 2026-11-18
18
+
19
+ ### Added
20
+
21
+ - Table `pagination.layout: "simple"` ("Showing 1–25 of 223 rows", Previous, "Page 1 of 9",
22
+ Next) and `pagination.sizes: false` to hide the rows-per-page picker.
23
+ - Tiles `captionInline`: the caption right after the number ("12 passed"); a template `value` that
24
+ resolves to `""` draws no number.
25
+ - `fmt.date(v, { weekday, day, month, … })`: format a date with the parts you want.
26
+
27
+ ### Changed
28
+
29
+ - Charts replay their grow-in animation when the categories change completely (a drill-down, the
30
+ next week) instead of jumping to the new bars.
31
+
32
+ ### Fixed
33
+
34
+ - Tiles show hover feedback only when they do something (selectable, or the panel has `on.click`).
35
+
36
+ ## [0.1.10] - 2026-11-18
37
+
38
+ ### Added
39
+
40
+ - `Button` atom: `label`, `icon`, `iconAfter`, `variant` (primary / secondary / subtle / link),
41
+ `size`, `disabled`, `ariaLabel`; runs the panel's `on.click`. Icons `arrow-left`, `arrow-right`.
42
+ - A `toolbar` slot on every panel: a row under the title, above the body, for navigation, actions
43
+ or notes (e.g. a drill-down breadcrumb with back and previous / next buttons).
44
+
17
45
  ## [0.1.9] - 2026-11-18
18
46
 
19
47
  ### Added
@@ -190,7 +218,9 @@ First public release.
190
218
  never reach object prototypes, values inserted into Markdown are escaped, and custom
191
219
  code runs in the sandbox by default. See [docs/security.md](docs/security.md).
192
220
 
193
- [Unreleased]: https://github.com/vaskar-nowpurchase/dashspec-renderer/compare/v0.1.9...HEAD
221
+ [Unreleased]: https://github.com/vaskar-nowpurchase/dashspec-renderer/compare/v0.1.11...HEAD
222
+ [0.1.11]: https://github.com/vaskar-nowpurchase/dashspec-renderer/compare/v0.1.10...v0.1.11
223
+ [0.1.10]: https://github.com/vaskar-nowpurchase/dashspec-renderer/compare/v0.1.9...v0.1.10
194
224
  [0.1.9]: https://github.com/vaskar-nowpurchase/dashspec-renderer/compare/v0.1.8...v0.1.9
195
225
  [0.1.8]: https://github.com/vaskar-nowpurchase/dashspec-renderer/compare/v0.1.7...v0.1.8
196
226
  [0.1.7]: https://github.com/vaskar-nowpurchase/dashspec-renderer/compare/v0.1.6...v0.1.7
package/README.md CHANGED
@@ -10,7 +10,7 @@ You describe a dashboard once as a JSON document (layout, filters, data sources,
10
10
  what happens on click), and `<DashboardRenderer>` draws it. A new dashboard, or a new
11
11
  version of one, is a new document — not new frontend code and not a redeploy.
12
12
 
13
- - **30 built-in widgets**: KPIs, charts, tables, tiles, status, layout containers and
13
+ - **31 built-in widgets**: KPIs, charts, tables, tiles, status, layout containers and
14
14
  small building blocks, nestable at any depth.
15
15
  - **Data built in**: REST, GraphQL, SSE and WebSocket sources, auth and token refresh,
16
16
  caching, polling, transforms.
@@ -406,11 +406,12 @@ function createHelpers(t = {}) {
406
406
  if (m) return s ? `${m} min ${s} sec` : `${m} min`;
407
407
  return `${s} sec`;
408
408
  },
409
+ /** `style` is "date" | "datetime" | "time", or Intl options, e.g. { weekday: 'short', day: 'numeric', month: 'short' }. */
409
410
  date: (v, style = "date") => {
410
411
  if (v === null || v === void 0 || v === "") return "";
411
412
  const d = new Date(typeof v === "number" ? v : String(v));
412
413
  if (Number.isNaN(d.getTime())) return String(v);
413
- const opts = style === "time" ? { timeStyle: "short" } : style === "datetime" ? { dateStyle: "medium", timeStyle: "short" } : { dateStyle: "medium" };
414
+ const opts = typeof style === "object" && style !== null ? pickDateOptions(style) : style === "time" ? { timeStyle: "short" } : style === "datetime" ? { dateStyle: "medium", timeStyle: "short" } : { dateStyle: "medium" };
414
415
  return new Intl.DateTimeFormat(locale, { ...opts, ...t.timeZone ? { timeZone: t.timeZone } : {} }).format(d);
415
416
  },
416
417
  /** "just now", "2 min ago", "3 hr ago", "4 days ago". */
@@ -466,6 +467,23 @@ function createHelpers(t = {}) {
466
467
  t: translator(t.translations, locale)
467
468
  };
468
469
  }
470
+ var DATE_KEYS = [
471
+ "weekday",
472
+ "era",
473
+ "year",
474
+ "month",
475
+ "day",
476
+ "hour",
477
+ "minute",
478
+ "second",
479
+ "hour12",
480
+ "timeZoneName"
481
+ ];
482
+ function pickDateOptions(o) {
483
+ const out = {};
484
+ for (const k of DATE_KEYS) if (Object.hasOwn(o, k)) out[k] = o[k];
485
+ return out;
486
+ }
469
487
 
470
488
  // src/core/expr/references.ts
471
489
  var ROOTS = ["datasources", "panels", "filters", "state", "modal", "context", "event", "drill", "panel"];
@@ -1808,7 +1826,7 @@ function migrateDocument(input, widgets = []) {
1808
1826
  import { z as z10 } from "zod";
1809
1827
 
1810
1828
  // src/version.ts
1811
- var RENDERER_VERSION = "0.1.9";
1829
+ var RENDERER_VERSION = "0.1.11";
1812
1830
  var parse2 = (v) => {
1813
1831
  const m = /^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:[-+].*)?$/.exec(v.trim());
1814
1832
  return m ? [Number(m[1]), Number(m[2] ?? 0), Number(m[3] ?? 0)] : void 0;
@@ -2227,8 +2245,8 @@ function validateDocument(input, options = {}) {
2227
2245
  for (const [slot, list2] of Object.entries(p.slots)) {
2228
2246
  if (!Array.isArray(list2)) continue;
2229
2247
  const ids = list2.filter((c) => typeof c === "string");
2230
- const rule = slot === "header" || slot === "footer" ? { accepts: "small" } : def?.slots?.[slot];
2231
- if (def && !rule && !def.openSlots && slot !== "header" && slot !== "footer")
2248
+ const rule = slot === "header" || slot === "footer" || slot === "toolbar" ? { accepts: "small" } : def?.slots?.[slot];
2249
+ if (def && !rule && !def.openSlots && slot !== "header" && slot !== "footer" && slot !== "toolbar")
2232
2250
  warn(["spec", "panels", pid, "slots", slot], "unknown-slot", `${String(p.kind)} has no slot "${slot}"`);
2233
2251
  if (rule?.max !== void 0 && ids.length > rule.max)
2234
2252
  err(["spec", "panels", pid, "slots", slot], "slot-full", `Slot "${slot}" takes at most ${rule.max}`);
@@ -2243,7 +2261,7 @@ function validateDocument(input, options = {}) {
2243
2261
  placed.add(c);
2244
2262
  const ck = byKind.get(String(child.kind));
2245
2263
  const accepts = rule?.accepts ?? "any";
2246
- if (ck && accepts === "small" && !ck.small && slot !== "footer")
2264
+ if (ck && accepts === "small" && !ck.small && slot !== "footer" && slot !== "toolbar")
2247
2265
  err(at, "slot-accepts", `${String(child.kind)} can't go in "${slot}" (it takes badges, atoms and filters)`);
2248
2266
  if (Array.isArray(accepts) && !accepts.includes(String(child.kind)))
2249
2267
  err(at, "slot-accepts", `Slot "${slot}" takes ${accepts.join(", ")}`);
@@ -2924,7 +2942,11 @@ var schema = z25.object({
2924
2942
  mode: z25.enum(["client", "server"]).default("client"),
2925
2943
  pageSize: z25.number().int().min(1).max(500).default(20),
2926
2944
  pageSizes: z25.array(z25.number().int().min(1)).default([10, 20, 50, 100]),
2927
- totalPath: z25.string().optional()
2945
+ totalPath: z25.string().optional(),
2946
+ /** "pages" (default): numbered pages. "simple": "Showing 1–25 of 223 rows", Previous, "Page 1 of 9", Next. */
2947
+ layout: z25.enum(["pages", "simple"]).default("pages"),
2948
+ /** Show the rows-per-page picker. */
2949
+ sizes: z25.boolean().default(true)
2928
2950
  }).strict().optional(),
2929
2951
  /** A search box. "server": writes `ui.search` (debounced) for the datasource; "client": matches row text. */
2930
2952
  search: z25.union([
@@ -2973,6 +2995,8 @@ var TilesContract = {
2973
2995
  value: z26.string(),
2974
2996
  /** Small text under the number: plain ("heats") or per row ("of ${row.total} pending"). */
2975
2997
  caption: z26.string().optional(),
2998
+ /** Put the caption on the number's line, right after it ("12 passed"). */
2999
+ captionInline: z26.boolean().default(false),
2976
3000
  /** Optional status dot per tile. */
2977
3001
  status: z26.string().optional(),
2978
3002
  statusMap: ToneMap.optional(),
@@ -3017,6 +3041,8 @@ var ICONS = {
3017
3041
  alert: "M12 3 2 20h20zM12 10v4M12 17h.01",
3018
3042
  up: "M7 14l5-5 5 5",
3019
3043
  down: "M7 10l5 5 5-5",
3044
+ "arrow-left": "M19 12H5M11 6l-6 6 6 6",
3045
+ "arrow-right": "M5 12h14M13 6l6 6-6 6",
3020
3046
  gauge: "M4 18a8 8 0 1 1 16 0M12 18l4-6",
3021
3047
  box: "M3 7l9-4 9 4v10l-9 4-9-4zM3 7l9 4 9-4M12 11v10",
3022
3048
  user: "M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4 21a8 8 0 0 1 16 0",
@@ -3103,6 +3129,25 @@ var DividerContract = {
3103
3129
  dashed: z27.boolean().default(false)
3104
3130
  }).strict()
3105
3131
  };
3132
+ var ButtonContract = {
3133
+ kind: "Button",
3134
+ version: 1,
3135
+ small: true,
3136
+ schema: z27.object({
3137
+ ...Atom,
3138
+ /** Text on the button (template). Leave out for an icon-only button (give it an `ariaLabel`). */
3139
+ label: z27.string().optional(),
3140
+ icon: z27.enum(ICON_NAMES).optional(),
3141
+ /** Put the icon after the label. */
3142
+ iconAfter: z27.boolean().default(false),
3143
+ /** "primary" (filled), "secondary" (outlined), "subtle" (tinted, no border) or "link" (text only). */
3144
+ variant: z27.enum(["primary", "secondary", "subtle", "link"]).default("secondary"),
3145
+ size: z27.enum(["sm", "md"]).default("md"),
3146
+ /** Disabled when true, e.g. "${datasources.trend.data.meta.prev_week == null}". */
3147
+ disabled: z27.boolean().default(false),
3148
+ ariaLabel: z27.string().optional()
3149
+ }).strict()
3150
+ };
3106
3151
 
3107
3152
  // src/widgets/schemas/charts.ts
3108
3153
  import { z as z28 } from "zod";
@@ -3302,7 +3347,8 @@ var builtInWidgetContracts = [
3302
3347
  ValueContract,
3303
3348
  ProgressContract,
3304
3349
  IconContract,
3305
- DividerContract
3350
+ DividerContract,
3351
+ ButtonContract
3306
3352
  ];
3307
3353
  var builtInWidgetChecks = contractChecks(builtInWidgetContracts);
3308
3354
 
@@ -3411,6 +3457,7 @@ export {
3411
3457
  ProgressContract,
3412
3458
  IconContract,
3413
3459
  DividerContract,
3460
+ ButtonContract,
3414
3461
  BarChartContract,
3415
3462
  LineChartContract,
3416
3463
  PieChartContract,
@@ -3424,4 +3471,4 @@ export {
3424
3471
  RepeaterContract,
3425
3472
  builtInWidgetChecks
3426
3473
  };
3427
- //# sourceMappingURL=chunk-5EYC4E5K.js.map
3474
+ //# sourceMappingURL=chunk-RSIUW5J4.js.map