@dashspec/renderer 0.1.0 → 0.1.2

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.
@@ -7423,7 +7423,7 @@ declare class TransformError extends Error {
7423
7423
  declare function applyTransform(data: unknown, steps: readonly Step[], root: Scope, opts?: TransformOptions): unknown;
7424
7424
 
7425
7425
  /** This package's version. A test keeps it equal to package.json's; bump both together. */
7426
- declare const RENDERER_VERSION = "0.1.0";
7426
+ declare const RENDERER_VERSION = "0.1.2";
7427
7427
  /**
7428
7428
  * Whether `version` satisfies `range`. Supports what documents need: "1.2.3" (that or newer within the major, like
7429
7429
  * "^"), ">=1.2", ">1.2.3", "<2", "<=2.1", "^1.2", "~1.2.3", and several of them separated by spaces (all must hold).
@@ -7567,6 +7567,12 @@ interface WidgetDefinition<S extends ZodTypeAny = ZodTypeAny> {
7567
7567
  migrations?: Record<number, (spec: Record<string, unknown>) => Record<string, unknown>>;
7568
7568
  /** "widget": the widget draws its own title (KPI cards); the frame keeps only drill, controls and badges. */
7569
7569
  header?: "panel" | "widget";
7570
+ /**
7571
+ * "widget": the widget draws its own empty state (a KPI card keeps its title and shows its `emptyText`), so the
7572
+ * frame doesn't replace it with the generic "No data" when the bound value is empty. Loading and errors still
7573
+ * come from the frame.
7574
+ */
7575
+ empty?: "panel" | "widget";
7570
7576
  /** Its slots. Every widget also has `header` (next to the title) and `footer` (under the body). */
7571
7577
  slots?: Record<string, SlotDefinition>;
7572
7578
  /**
package/dist/core.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { f as ACTION_KINDS, g as ACTION_SCHEMAS, h as API_VERSION, i as Action, j as ActionRef, k as Auth, B as BREAKPOINTS, l as BUILT_IN_DATASOURCE_TYPES, C as Callback, m as Connection, n as ConnectionSpec, o as DATE_PRESETS, D as Dashboard, p as DashboardInput, q as DataBinding, r as DataError, s as DataErrorCode, t as Datasource, u as DateRange, v as Display, w as Drill, x as Duration, y as EventHandler, z as EventMap, F as Expression, G as ExpressionError, I as FnProp, a_ as Grid, K as Handler, L as HelperSettings, M as Helpers, H as HttpClient, O as HttpClientInternals, P as Id, J as JsonValue, Q as Layout, U as LayoutItem, V as LoadOptions, X as LoadResult, Y as Metadata, Z as MigrateResult, _ as MigrationError, $ as Modal, a0 as NamedAction, N as NetworkOptions, a1 as Node, a2 as Panel, a3 as PanelControl, a4 as PanelMigration, a6 as Problem, a7 as RENDERER_VERSION, a8 as RESERVED_STATE_KEYS, a9 as RefRoot, aa as Reference, ab as Requires, R as ResolvedRequest, ac as SCHEMA_URL, S as Scope, ad as Severity, ae as Spec, a$ as StatusTone, af as Template, a as TimeSettings, ag as TokenSource, ah as TransformError, ai as TransformOptions, aj as TransformStep, ak as Translations, al as VARIABLE_KINDS, am as ValidateOptions, an as ValidationResult, ao as Variable, ap as WidgetCheck, aq as WidgetMigrations, as as applyTransform, at as buildRequestUrl, au as buildUrl, av as builtInWidgetChecks, aw as collectReferences, ax as compile, ay as createHelpers, az as createHttpClient, aA as dashboardJsonSchema, aB as evaluate, aC as evaluateSafe, aD as expressionReferences, aE as graphqlData, aF as interpolate, aG as interpolateUrl, aH as isCallbackSource, aI as isSafeUrl, aJ as loadDocument, aK as mergeConnections, aL as migrateDocument, aM as parse, aN as parseDuration, aO as placeholders, aP as plantDate, aQ as plantDayStart, aR as resolve, aS as resolveBaseUrl, aT as resolveRequest, aU as safeLink, aV as satisfies, aW as scope, aX as templateReferences, aY as translator, aZ as validateDocument } from './core-C8ay_SoY.js';
1
+ export { f as ACTION_KINDS, g as ACTION_SCHEMAS, h as API_VERSION, i as Action, j as ActionRef, k as Auth, B as BREAKPOINTS, l as BUILT_IN_DATASOURCE_TYPES, C as Callback, m as Connection, n as ConnectionSpec, o as DATE_PRESETS, D as Dashboard, p as DashboardInput, q as DataBinding, r as DataError, s as DataErrorCode, t as Datasource, u as DateRange, v as Display, w as Drill, x as Duration, y as EventHandler, z as EventMap, F as Expression, G as ExpressionError, I as FnProp, a_ as Grid, K as Handler, L as HelperSettings, M as Helpers, H as HttpClient, O as HttpClientInternals, P as Id, J as JsonValue, Q as Layout, U as LayoutItem, V as LoadOptions, X as LoadResult, Y as Metadata, Z as MigrateResult, _ as MigrationError, $ as Modal, a0 as NamedAction, N as NetworkOptions, a1 as Node, a2 as Panel, a3 as PanelControl, a4 as PanelMigration, a6 as Problem, a7 as RENDERER_VERSION, a8 as RESERVED_STATE_KEYS, a9 as RefRoot, aa as Reference, ab as Requires, R as ResolvedRequest, ac as SCHEMA_URL, S as Scope, ad as Severity, ae as Spec, a$ as StatusTone, af as Template, a as TimeSettings, ag as TokenSource, ah as TransformError, ai as TransformOptions, aj as TransformStep, ak as Translations, al as VARIABLE_KINDS, am as ValidateOptions, an as ValidationResult, ao as Variable, ap as WidgetCheck, aq as WidgetMigrations, as as applyTransform, at as buildRequestUrl, au as buildUrl, av as builtInWidgetChecks, aw as collectReferences, ax as compile, ay as createHelpers, az as createHttpClient, aA as dashboardJsonSchema, aB as evaluate, aC as evaluateSafe, aD as expressionReferences, aE as graphqlData, aF as interpolate, aG as interpolateUrl, aH as isCallbackSource, aI as isSafeUrl, aJ as loadDocument, aK as mergeConnections, aL as migrateDocument, aM as parse, aN as parseDuration, aO as placeholders, aP as plantDate, aQ as plantDayStart, aR as resolve, aS as resolveBaseUrl, aT as resolveRequest, aU as safeLink, aV as satisfies, aW as scope, aX as templateReferences, aY as translator, aZ as validateDocument } from './core-CIcJ1KNt.js';
2
2
  import 'zod';
3
3
  import 'react';
package/dist/core.js CHANGED
@@ -80,7 +80,7 @@ import {
80
80
  templateReferences,
81
81
  translator,
82
82
  validateDocument
83
- } from "./chunk-S4EW5IEA.js";
83
+ } from "./chunk-T4QLZXX4.js";
84
84
  export {
85
85
  ACTION_KINDS,
86
86
  ACTION_SCHEMAS,
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as AnyWidgetDefinition, T as TreeState, H as HttpClient, R as ResolvedRequest, a as TimeSettings, D as Dashboard, N as NetworkOptions, J as JsonValue, S as Scope, W as WidgetDefinition, b as SlotDefinition, c as SlotRenderOptions, d as WidgetMeta, e as WidgetProps } from './core-C8ay_SoY.js';
2
- export { f as ACTION_KINDS, g as ACTION_SCHEMAS, h as API_VERSION, i as Action, j as ActionRef, k as Auth, B as BREAKPOINTS, l as BUILT_IN_DATASOURCE_TYPES, C as Callback, m as Connection, n as ConnectionSpec, o as DATE_PRESETS, p as DashboardInput, q as DataBinding, r as DataError, s as DataErrorCode, t as Datasource, u as DateRange, v as Display, w as Drill, x as Duration, E as Emit, y as EventHandler, z as EventMap, F as Expression, G as ExpressionError, I as FnProp, K as Handler, L as HelperSettings, M as Helpers, O as HttpClientInternals, P as Id, Q as Layout, U as LayoutItem, V as LoadOptions, X as LoadResult, Y as Metadata, Z as MigrateResult, _ as MigrationError, $ as Modal, a0 as NamedAction, a1 as Node, a2 as Panel, a3 as PanelControl, a4 as PanelMigration, a5 as PanelState, a6 as Problem, a7 as RENDERER_VERSION, a8 as RESERVED_STATE_KEYS, a9 as RefRoot, aa as Reference, ab as Requires, ac as SCHEMA_URL, ad as Severity, ae as Spec, af as Template, ag as TokenSource, ah as TransformError, ai as TransformOptions, aj as TransformStep, ak as Translations, al as VARIABLE_KINDS, am as ValidateOptions, an as ValidationResult, ao as Variable, ap as WidgetCheck, aq as WidgetMigrations, ar as WidgetStore, as as applyTransform, at as buildRequestUrl, au as buildUrl, av as builtInWidgetChecks, aw as collectReferences, ax as compile, ay as createHelpers, az as createHttpClient, aA as dashboardJsonSchema, aB as evaluate, aC as evaluateSafe, aD as expressionReferences, aE as graphqlData, aF as interpolate, aG as interpolateUrl, aH as isCallbackSource, aI as isSafeUrl, aJ as loadDocument, aK as mergeConnections, aL as migrateDocument, aM as parse, aN as parseDuration, aO as placeholders, aP as plantDate, aQ as plantDayStart, aR as resolve, aS as resolveBaseUrl, aT as resolveRequest, aU as safeLink, aV as satisfies, aW as scope, aX as templateReferences, aY as translator, aZ as validateDocument } from './core-C8ay_SoY.js';
1
+ import { A as AnyWidgetDefinition, T as TreeState, H as HttpClient, R as ResolvedRequest, a as TimeSettings, D as Dashboard, N as NetworkOptions, J as JsonValue, S as Scope, W as WidgetDefinition, b as SlotDefinition, c as SlotRenderOptions, d as WidgetMeta, e as WidgetProps } from './core-CIcJ1KNt.js';
2
+ export { f as ACTION_KINDS, g as ACTION_SCHEMAS, h as API_VERSION, i as Action, j as ActionRef, k as Auth, B as BREAKPOINTS, l as BUILT_IN_DATASOURCE_TYPES, C as Callback, m as Connection, n as ConnectionSpec, o as DATE_PRESETS, p as DashboardInput, q as DataBinding, r as DataError, s as DataErrorCode, t as Datasource, u as DateRange, v as Display, w as Drill, x as Duration, E as Emit, y as EventHandler, z as EventMap, F as Expression, G as ExpressionError, I as FnProp, K as Handler, L as HelperSettings, M as Helpers, O as HttpClientInternals, P as Id, Q as Layout, U as LayoutItem, V as LoadOptions, X as LoadResult, Y as Metadata, Z as MigrateResult, _ as MigrationError, $ as Modal, a0 as NamedAction, a1 as Node, a2 as Panel, a3 as PanelControl, a4 as PanelMigration, a5 as PanelState, a6 as Problem, a7 as RENDERER_VERSION, a8 as RESERVED_STATE_KEYS, a9 as RefRoot, aa as Reference, ab as Requires, ac as SCHEMA_URL, ad as Severity, ae as Spec, af as Template, ag as TokenSource, ah as TransformError, ai as TransformOptions, aj as TransformStep, ak as Translations, al as VARIABLE_KINDS, am as ValidateOptions, an as ValidationResult, ao as Variable, ap as WidgetCheck, aq as WidgetMigrations, ar as WidgetStore, as as applyTransform, at as buildRequestUrl, au as buildUrl, av as builtInWidgetChecks, aw as collectReferences, ax as compile, ay as createHelpers, az as createHttpClient, aA as dashboardJsonSchema, aB as evaluate, aC as evaluateSafe, aD as expressionReferences, aE as graphqlData, aF as interpolate, aG as interpolateUrl, aH as isCallbackSource, aI as isSafeUrl, aJ as loadDocument, aK as mergeConnections, aL as migrateDocument, aM as parse, aN as parseDuration, aO as placeholders, aP as plantDate, aQ as plantDayStart, aR as resolve, aS as resolveBaseUrl, aT as resolveRequest, aU as safeLink, aV as satisfies, aW as scope, aX as templateReferences, aY as translator, aZ as validateDocument } from './core-CIcJ1KNt.js';
3
3
  import * as react from 'react';
4
4
  import { CSSProperties, ReactNode, ComponentType } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
package/dist/index.js CHANGED
@@ -114,7 +114,7 @@ import {
114
114
  translator,
115
115
  validateDocument,
116
116
  widgetChecks
117
- } from "./chunk-S4EW5IEA.js";
117
+ } from "./chunk-T4QLZXX4.js";
118
118
  import {
119
119
  createStateProxy,
120
120
  getPath,
@@ -3490,6 +3490,7 @@ var Kpi = defineWidget({
3490
3490
  ...KpiContract,
3491
3491
  implements: "kpi",
3492
3492
  header: "widget",
3493
+ empty: "widget",
3493
3494
  meta: { label: "KPI", icon: "kpi", category: "Numbers", size: { w: 3, h: 4, minW: 2, minH: 3 } },
3494
3495
  events: ["click", "hover"],
3495
3496
  parts: ["value"],
@@ -3529,7 +3530,10 @@ var Kpi = defineWidget({
3529
3530
  onClick: () => emit("click", "value", { datum: source, value }),
3530
3531
  onMouseEnter: () => emit("hover", "value", { datum: source, value }),
3531
3532
  "aria-label": `${spec.title ?? "Value"}: ${empty ? spec.emptyText ?? "no value" : fmt(value)}${unit ? ` ${unit}` : ""}`,
3532
- children: empty && spec.emptyText ? /* @__PURE__ */ jsx13("span", { className: "ds-kpi-empty", children: spec.emptyText }) : /* @__PURE__ */ jsxs8(Fragment4, { children: [
3533
+ children: empty ? (
3534
+ // No value is not zero: the author's text, else a dash.
3535
+ /* @__PURE__ */ jsx13("span", { className: "ds-kpi-empty", children: spec.emptyText || "\u2014" })
3536
+ ) : /* @__PURE__ */ jsxs8(Fragment4, { children: [
3533
3537
  /* @__PURE__ */ jsx13(
3534
3538
  "span",
3535
3539
  {
@@ -4761,7 +4765,7 @@ function PanelFrameInner({ id, nested }) {
4761
4765
  body = options.renderError?.(view.error, id) ?? /* @__PURE__ */ jsx21("div", { className: "ds-state ds-state-error", role: "alert", children: view.messages?.error ?? view.error.message });
4762
4766
  else if (view.source && view.data === void 0 && (view.status === "loading" || view.status === "idle"))
4763
4767
  body = options.renderLoading?.(id, loadingText(view.messages)) ?? /* @__PURE__ */ jsx21(LoadingState, { text: loadingText(view.messages) });
4764
- else if (view.source && isEmpty(view.data))
4768
+ else if (view.source && isEmpty(view.data) && widget.empty !== "widget")
4765
4769
  body = options.renderEmpty?.(id) ?? /* @__PURE__ */ jsx21("div", { className: "ds-state", children: view.messages?.empty ?? "No data" });
4766
4770
  else {
4767
4771
  const W = widget.component;
@@ -5889,20 +5893,20 @@ function Grid({
5889
5893
  dragOnto
5890
5894
  }) {
5891
5895
  const bpRef = useRef8("desktop");
5892
- const wrap = useRef8(null);
5896
+ const [wrapEl, setWrapEl] = useState6(null);
5893
5897
  const [measured, setMeasured] = useState6("desktop");
5894
5898
  useEffect7(() => {
5895
- const el = wrap.current;
5896
- if (!el || typeof ResizeObserver === "undefined") return;
5899
+ if (!wrapEl || typeof ResizeObserver === "undefined") return;
5897
5900
  const ro = new ResizeObserver(([e]) => {
5898
5901
  const w = e?.contentRect.width ?? 0;
5902
+ if (w === 0) return;
5899
5903
  setMeasured(
5900
5904
  w >= BREAKPOINT_MIN.tv ? "tv" : w >= BREAKPOINT_MIN.desktop ? "desktop" : w >= BREAKPOINT_MIN.tablet ? "tablet" : "mobile"
5901
5905
  );
5902
5906
  });
5903
- ro.observe(el);
5907
+ ro.observe(wrapEl);
5904
5908
  return () => ro.disconnect();
5905
- }, []);
5909
+ }, [wrapEl]);
5906
5910
  const base = useMemo7(() => layoutsForView(layouts, view, columns), [layouts, view, columns]);
5907
5911
  const { rgl, panels, cols } = useMemo7(() => {
5908
5912
  if (!hidden?.size || editable) return { rgl: base.layouts, panels: base.panels, cols: base.cols };
@@ -5916,7 +5920,7 @@ function Grid({
5916
5920
  const active = breakpoint ?? measured;
5917
5921
  if (base.modes[active] === "flow") {
5918
5922
  const hide = editable ? void 0 : hidden;
5919
- return /* @__PURE__ */ jsx26("div", { ref: wrap, className: editable ? "ds-flow ds-flow-edit" : "ds-flow", style: { gap }, children: base.ordered.filter((o) => !hide?.has(o.panel)).map((o, i) => /* @__PURE__ */ jsx26(
5923
+ return /* @__PURE__ */ jsx26("div", { ref: setWrapEl, className: editable ? "ds-flow ds-flow-edit" : "ds-flow", style: { gap }, children: base.ordered.filter((o) => !hide?.has(o.panel)).map((o, i) => /* @__PURE__ */ jsx26(
5920
5924
  "div",
5921
5925
  {
5922
5926
  className: "ds-flow-item",
@@ -5930,7 +5934,7 @@ function Grid({
5930
5934
  o.panel
5931
5935
  )) });
5932
5936
  }
5933
- return /* @__PURE__ */ jsx26("div", { ref: wrap, children: /* @__PURE__ */ jsx26(
5937
+ return /* @__PURE__ */ jsx26("div", { ref: setWrapEl, children: /* @__PURE__ */ jsx26(
5934
5938
  ResponsiveGrid,
5935
5939
  {
5936
5940
  className: editable ? "ds-grid ds-grid-edit" : "ds-grid",