@dashspec/renderer 0.1.37 → 0.1.38

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.
@@ -7588,7 +7588,7 @@ declare class TransformError extends Error {
7588
7588
  declare function applyTransform(data: unknown, steps: readonly Step[], root: Scope, opts?: TransformOptions): unknown;
7589
7589
 
7590
7590
  /** This package's version. A test keeps it equal to package.json's; bump both together. */
7591
- declare const RENDERER_VERSION = "0.1.37";
7591
+ declare const RENDERER_VERSION = "0.1.38";
7592
7592
  /**
7593
7593
  * Whether `version` satisfies `range`. Supports what documents need: "1.2.3" (that or newer within the major, like
7594
7594
  * "^"), ">=1.2", ">1.2.3", "<2", "<=2.1", "^1.2", "~1.2.3", and several of them separated by spaces (all must hold).
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, b0 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 stripStrings, aY as templateReferences, aZ as translator, a_ as validateDocument } from './core-CMrDMelI.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, b0 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 stripStrings, aY as templateReferences, aZ as translator, a_ as validateDocument } from './core-DIOQeVeG.js';
2
2
  import 'zod';
3
3
  import 'react';
package/dist/core.js CHANGED
@@ -81,7 +81,7 @@ import {
81
81
  templateReferences,
82
82
  translator,
83
83
  validateDocument
84
- } from "./chunk-7II42B2U.js";
84
+ } from "./chunk-QMNPTVGN.js";
85
85
  export {
86
86
  ACTION_KINDS,
87
87
  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-CMrDMelI.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 stripStrings, aY as templateReferences, aZ as translator, a_ as validateDocument } from './core-CMrDMelI.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-DIOQeVeG.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 stripStrings, aY as templateReferences, aZ as translator, a_ as validateDocument } from './core-DIOQeVeG.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';
@@ -99,6 +99,94 @@ type CssDeclarations = CSSProperties & {
99
99
  /** Turns a `CssRules` object into a CSS string with `&` selectors; unsafe values are dropped. */
100
100
  declare function cssRulesToString(rules: CssRules, unsafe: RegExp): string;
101
101
 
102
+ /** A piece of text inside widgets: its font (a theme font), size, weight, line height and colour. */
103
+ interface TextPart {
104
+ font?: "heading" | "body" | "data";
105
+ /** px */
106
+ size?: number;
107
+ weight?: number;
108
+ /** px */
109
+ lineHeight?: number;
110
+ color?: string;
111
+ /** px above it (e.g. a subtitle under the title). */
112
+ marginTop?: number;
113
+ /** CSS padding, e.g. "24px 0". */
114
+ padding?: string;
115
+ }
116
+ /**
117
+ * The look of the parts every widget shares, as values. Each one is optional: a part the theme leaves out keeps
118
+ * DashSpec's own look, so `parts` only ever changes what it names. No class names: the renderer knows which elements
119
+ * each part is.
120
+ */
121
+ interface PartTokens {
122
+ /** Panel titles. */
123
+ title?: TextPart;
124
+ /** The line under a title (`subtitle`). */
125
+ subtitle?: TextPart;
126
+ /** Side text in a header and footers: `meta`, the live badge, chart legends, table pagers, KPI footers. */
127
+ meta?: TextPart;
128
+ /** The ⓘ next to a title. */
129
+ info?: {
130
+ size?: number;
131
+ color?: string;
132
+ };
133
+ /** KPI and tile labels. */
134
+ label?: TextPart;
135
+ /** KPI and tile values. */
136
+ value?: TextPart;
137
+ /** The unit after a KPI value. */
138
+ unit?: TextPart;
139
+ /** Notes under KPI values and tile captions. */
140
+ caption?: TextPart;
141
+ /** Empty, no-data and loading messages. */
142
+ empty?: TextPart;
143
+ /** Table header cells and body cells. */
144
+ tableHead?: TextPart;
145
+ tableCell?: TextPart;
146
+ /** Panel header: side text centred on the title, or on its first line ("start", useful with a subtitle). */
147
+ header?: {
148
+ align?: "center" | "start";
149
+ };
150
+ /** KPI cards: padding, corner radius, gap and minimum height (px). */
151
+ kpiCard?: {
152
+ padding?: number;
153
+ radius?: number;
154
+ gap?: number;
155
+ minHeight?: number;
156
+ };
157
+ /** Tiles: padding, radius, gap inside and between tiles (px), border colour, and the selected tile's label. */
158
+ tile?: {
159
+ padding?: number;
160
+ radius?: number;
161
+ gap?: number;
162
+ spacing?: number;
163
+ border?: string;
164
+ activeLabel?: TextPart;
165
+ };
166
+ /** Tables: cell padding (CSS), row divider colour, totals row and opened-row backgrounds. */
167
+ table?: {
168
+ cellPadding?: string;
169
+ rowBorder?: string;
170
+ footBackground?: string;
171
+ footWeight?: number;
172
+ openBackground?: string;
173
+ };
174
+ /** The live badge's dot (px) and colours. */
175
+ liveDot?: {
176
+ size?: number;
177
+ color?: string;
178
+ staleColor?: string;
179
+ };
180
+ /** Chart legends: gap between items, swatch size and radius (px). */
181
+ legend?: {
182
+ gap?: number;
183
+ swatch?: number;
184
+ swatchRadius?: number;
185
+ };
186
+ }
187
+ /** CSS for a theme's `scale.parts`, scoped under `scope`. Empty when the theme sets none. */
188
+ declare function partsCss(theme: Theme, scope: string): string;
189
+
102
190
  /**
103
191
  * The DashSpec token contract. Widgets read only these tokens, through `--ds-*` CSS variables,
104
192
  * never a UI library's theme. Colours change per mode; everything else is shared by both modes.
@@ -238,6 +326,8 @@ interface ScaleTokens {
238
326
  fontSize?: number;
239
327
  };
240
328
  /** Filter controls, menus and buttons: text size (px, default 13), the stepper arrows' background (default the selection colour) and the filter bar icon size (px). */
329
+ /** The look of parts every widget shares (titles, labels, values, tiles, tables…), as values. */
330
+ parts?: PartTokens;
241
331
  control?: {
242
332
  fontSize?: number;
243
333
  stepBackground?: string;
@@ -1553,4 +1643,4 @@ declare function lazyWidget<S extends z.ZodTypeAny>(def: Omit<WidgetDefinition<S
1553
1643
  fallback?: ReactNode;
1554
1644
  }): WidgetDefinition<S>;
1555
1645
 
1556
- export { AnyWidgetDefinition, BAR, BAR_ICONS, type Breakpoint, CallbackApi, type ColorTokens, ControlField, type CssDeclarations, type CssRules, DS_CLASSES, type DashEvent, DashSpecProvider, type DashSpecSettings, Dashboard, DashboardContext, type DashboardHandle, DashboardRenderer, type DashboardRendererProps, type DashboardRuntime, type DatasourceType, DateControl, DateRangeControl, type DeepPartial, type DesignSystem, type DsClass, type DsSelector, FilterBar, Grid, type GridChangeItem, type HostHooks, HttpClient, JsonValue, type LayoutSpec, ModalHost, MultiSelectControl, NetworkOptions, type NodeScope, type Option, PanelFrame, RENDERER_CSS, ResolvedRequest, type RuntimeOptions, type ScaleTokens, Scope, ScriptMode, ScriptRunner, SelectControl, Slot, SlotDefinition, type SourceState, type StatusColors, type StatusTone, type Theme, ThemeContext, type ThemeInput, type ThemeMode, ThemeScope, type ThemeScopeProps, TimeSettings, type Tree, type TypeRole, type UIChipsProps, type UIComponents, type UICustomFilterProps, type UIDateProps, type UIDateRangeProps, type UIFilterBarProps, type UIFilterDef, type UIMultiSelectProps, type UISearchProps, type UISelectProps, type UIStateProps, type UIToggleProps, WidgetDefinition, WidgetMeta, WidgetProps, type WidgetRegistry, type WidgetTheme, type WrapOptions, builtInWidgets, checkWidget, combineDesignSystems, createDashboardRuntime, createTheme, createWidgetRegistry, cssRulesToString, defaultTheme, defineDesignSystem, defineWidget, echartsTheme, layoutsForView, lazyWidget, mergeDeep, panelRows, presetRange, resolveMode, themeCssVars, themeStylesheet, timeSettingsFor, useDashSpecSettings, useDashboard, useDashboardActions, useDashboardState, useNodeScope, useThemeTokens, useTree, widgetChecks, widgetThemeCss, wrapComponent };
1646
+ export { AnyWidgetDefinition, BAR, BAR_ICONS, type Breakpoint, CallbackApi, type ColorTokens, ControlField, type CssDeclarations, type CssRules, DS_CLASSES, type DashEvent, DashSpecProvider, type DashSpecSettings, Dashboard, DashboardContext, type DashboardHandle, DashboardRenderer, type DashboardRendererProps, type DashboardRuntime, type DatasourceType, DateControl, DateRangeControl, type DeepPartial, type DesignSystem, type DsClass, type DsSelector, FilterBar, Grid, type GridChangeItem, type HostHooks, HttpClient, JsonValue, type LayoutSpec, ModalHost, MultiSelectControl, NetworkOptions, type NodeScope, type Option, PanelFrame, type PartTokens, RENDERER_CSS, ResolvedRequest, type RuntimeOptions, type ScaleTokens, Scope, ScriptMode, ScriptRunner, SelectControl, Slot, SlotDefinition, type SourceState, type StatusColors, type StatusTone, type TextPart, type Theme, ThemeContext, type ThemeInput, type ThemeMode, ThemeScope, type ThemeScopeProps, TimeSettings, type Tree, type TypeRole, type UIChipsProps, type UIComponents, type UICustomFilterProps, type UIDateProps, type UIDateRangeProps, type UIFilterBarProps, type UIFilterDef, type UIMultiSelectProps, type UISearchProps, type UISelectProps, type UIStateProps, type UIToggleProps, WidgetDefinition, WidgetMeta, WidgetProps, type WidgetRegistry, type WidgetTheme, type WrapOptions, builtInWidgets, checkWidget, combineDesignSystems, createDashboardRuntime, createTheme, createWidgetRegistry, cssRulesToString, defaultTheme, defineDesignSystem, defineWidget, echartsTheme, layoutsForView, lazyWidget, mergeDeep, panelRows, partsCss, presetRange, resolveMode, themeCssVars, themeStylesheet, timeSettingsFor, useDashSpecSettings, useDashboard, useDashboardActions, useDashboardState, useNodeScope, useThemeTokens, useTree, widgetChecks, widgetThemeCss, wrapComponent };
package/dist/index.js CHANGED
@@ -116,7 +116,7 @@ import {
116
116
  translator,
117
117
  validateDocument,
118
118
  widgetChecks
119
- } from "./chunk-7II42B2U.js";
119
+ } from "./chunk-QMNPTVGN.js";
120
120
  import {
121
121
  createStateProxy,
122
122
  getPath,
@@ -979,12 +979,12 @@ function createDataEngine(deps) {
979
979
  if (isHidden()) return schedule(id);
980
980
  if (refresh.whenVisible && !visible.has(id)) return schedule(id);
981
981
  if (typeof refresh.when === "string") {
982
- let ok = false;
982
+ let ok2 = false;
983
983
  try {
984
- ok = Boolean(evaluate(refresh.when, rootScope(deps.getTree(), deps.helpers)));
984
+ ok2 = Boolean(evaluate(refresh.when, rootScope(deps.getTree(), deps.helpers)));
985
985
  } catch {
986
986
  }
987
- if (!ok) return schedule(id);
987
+ if (!ok2) return schedule(id);
988
988
  }
989
989
  if (running.has(id)) return schedule(id);
990
990
  forced.add(id);
@@ -1755,10 +1755,10 @@ var UNITLESS = /* @__PURE__ */ new Set([
1755
1755
  ]);
1756
1756
  function cssRulesToString(rules, unsafe) {
1757
1757
  const out = [];
1758
- for (const [selector, decl] of Object.entries(rules)) {
1759
- if (!decl || typeof decl !== "object" || /[{};<>]/.test(selector)) continue;
1758
+ for (const [selector, decl2] of Object.entries(rules)) {
1759
+ if (!decl2 || typeof decl2 !== "object" || /[{};<>]/.test(selector)) continue;
1760
1760
  const sel = selector.includes("&") ? selector : `& ${selector}`;
1761
- const body = Object.entries(decl).filter(([, v]) => (typeof v === "string" || typeof v === "number") && !unsafe.test(String(v))).map(([k, v]) => {
1761
+ const body = Object.entries(decl2).filter(([, v]) => (typeof v === "string" || typeof v === "number") && !unsafe.test(String(v))).map(([k, v]) => {
1762
1762
  const prop = k.startsWith("--") ? k : k.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
1763
1763
  const val = typeof v === "number" && v !== 0 && !k.startsWith("--") && !UNITLESS.has(k) ? `${v}px` : String(v);
1764
1764
  return `${prop}: ${val};`;
@@ -1873,6 +1873,94 @@ function widgetThemeCss(theme, scope2) {
1873
1873
  return out.join("\n");
1874
1874
  }
1875
1875
 
1876
+ // src/theme/parts.ts
1877
+ var SAFE = /^[^;{}<>\\\n\r]*$/;
1878
+ var ok = (v) => typeof v === "number" && Number.isFinite(v) || typeof v === "string" && SAFE.test(v);
1879
+ var px = (v) => v === void 0 ? void 0 : `${v}px`;
1880
+ function decl(map) {
1881
+ return Object.entries(map).filter(([, v]) => v !== void 0 && ok(v)).map(([k, v]) => `${k}: ${v};`).join(" ");
1882
+ }
1883
+ function text(t) {
1884
+ if (!t) return "";
1885
+ return decl({
1886
+ "font-family": t.font && ["heading", "body", "data"].includes(t.font) ? `var(--ds-font-${t.font})` : void 0,
1887
+ "font-size": px(t.size),
1888
+ "font-weight": t.weight,
1889
+ "line-height": px(t.lineHeight),
1890
+ color: t.color,
1891
+ "margin-top": px(t.marginTop),
1892
+ padding: t.padding
1893
+ });
1894
+ }
1895
+ function partsCss(theme, scope2) {
1896
+ const p = theme.scale.parts;
1897
+ if (!p) return "";
1898
+ const rules = [
1899
+ [".ds-panel-title", text(p.title)],
1900
+ [".ds-panel-subtitle", text(p.subtitle)],
1901
+ [".ds-panel-meta, .ds-live, .ds-chart-legend, .ds-pager, .ds-kpi-foot, .ds-legend", text(p.meta)],
1902
+ [".ds-info", decl({ "font-size": px(p.info?.size), color: p.info?.color })],
1903
+ [".ds-kpi-label, .ds-tile-label", text(p.label)],
1904
+ [".ds-kpi-value, .ds-tile-value", `${text(p.value)}${p.value ? " letter-spacing: 0;" : ""}`],
1905
+ [".ds-kpi-unit", text(p.unit)],
1906
+ [".ds-kpi-note, .ds-kpi-sub, .ds-tile-caption", text(p.caption)],
1907
+ [".ds-state, .ds-kpi-empty", text(p.empty)],
1908
+ [".ds-table th", text(p.tableHead)],
1909
+ [".ds-table td", text(p.tableCell)],
1910
+ [".ds-table", p.tableCell?.font ? `font-family: var(--ds-font-${p.tableCell.font});` : ""],
1911
+ [".ds-panel-head", decl({ "align-items": p.header?.align === "start" ? "flex-start" : p.header?.align })],
1912
+ ['.ds-panel[data-kind="Kpi"]', decl({ padding: px(p.kpiCard?.padding), "border-radius": px(p.kpiCard?.radius) })],
1913
+ [
1914
+ '.ds-panel[data-kind="Kpi"] .ds-kpi',
1915
+ decl({
1916
+ gap: px(p.kpiCard?.gap),
1917
+ // The minimum is on the content so a grid can still stretch the card to its row.
1918
+ "min-height": p.kpiCard?.minHeight !== void 0 ? px(p.kpiCard.minHeight - 2 * (p.kpiCard.padding ?? 0)) : void 0
1919
+ })
1920
+ ],
1921
+ [
1922
+ ".ds-tile",
1923
+ decl({
1924
+ padding: px(p.tile?.padding),
1925
+ "border-radius": px(p.tile?.radius),
1926
+ gap: px(p.tile?.gap),
1927
+ "border-color": p.tile?.border
1928
+ })
1929
+ ],
1930
+ [".ds-tiles", decl({ "--ds-tiles-gap": px(p.tile?.spacing) })],
1931
+ [".ds-tile[data-active] .ds-tile-label", text(p.tile?.activeLabel)],
1932
+ [
1933
+ ".ds-table th, .ds-table td",
1934
+ decl({
1935
+ padding: p.table?.cellPadding,
1936
+ "border-bottom-color": p.table?.rowBorder
1937
+ })
1938
+ ],
1939
+ [
1940
+ ".ds-table tfoot td",
1941
+ decl({
1942
+ background: p.table?.footBackground,
1943
+ "font-weight": p.table?.footWeight,
1944
+ "border-top": p.table?.footBackground ? "0" : void 0
1945
+ })
1946
+ ],
1947
+ [".ds-table tr[data-expanded] > td, .ds-row-detail > td", decl({ background: p.table?.openBackground })],
1948
+ [
1949
+ ".ds-live > span",
1950
+ decl({ width: px(p.liveDot?.size), height: px(p.liveDot?.size), background: p.liveDot?.color })
1951
+ ],
1952
+ [".ds-live[data-stale] > span", decl({ background: p.liveDot?.staleColor })],
1953
+ [".ds-chart-legend", decl({ gap: px(p.legend?.gap) })],
1954
+ [
1955
+ ".ds-chart-legend .ds-swatch, .ds-legend .ds-dot",
1956
+ decl({ width: px(p.legend?.swatch), height: px(p.legend?.swatch), "border-radius": px(p.legend?.swatchRadius) })
1957
+ ]
1958
+ ];
1959
+ return rules.filter(([, body]) => body).map(
1960
+ ([sel, body]) => `${sel.split(", ").map((s) => `${scope2} ${s}`).join(", ")} { ${body} }`
1961
+ ).join("\n");
1962
+ }
1963
+
1876
1964
  // src/theme/ThemeScope.tsx
1877
1965
  import { jsx, jsxs } from "react/jsx-runtime";
1878
1966
  var DARK_QUERY = "(prefers-color-scheme: dark)";
@@ -1896,7 +1984,10 @@ function ThemeScope({ theme, mode, className, style, children }) {
1896
1984
  const vars = useMemo(() => themeCssVars(theme, resolved), [theme, resolved]);
1897
1985
  const ctx = useMemo(() => ({ theme, mode: resolved }), [theme, resolved]);
1898
1986
  const scopeId = useId();
1899
- const widgetCss = useMemo(() => widgetThemeCss(theme, `[data-ds-scope="${scopeId}"]`), [theme, scopeId]);
1987
+ const widgetCss = useMemo(() => {
1988
+ const scope2 = `[data-ds-scope="${scopeId}"]`;
1989
+ return [partsCss(theme, scope2), widgetThemeCss(theme, scope2)].filter(Boolean).join("\n");
1990
+ }, [theme, scopeId]);
1900
1991
  return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: ctx, children: /* @__PURE__ */ jsxs(
1901
1992
  "div",
1902
1993
  {
@@ -2235,8 +2326,8 @@ import "zod";
2235
2326
  // src/widgets/shared/Markdown.tsx
2236
2327
  import { Fragment } from "react";
2237
2328
  import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
2238
- function Markdown({ text, onAction }) {
2239
- const blocks = text.replace(/\r\n/g, "\n").split(/\n{2,}/);
2329
+ function Markdown({ text: text2, onAction }) {
2330
+ const blocks = text2.replace(/\r\n/g, "\n").split(/\n{2,}/);
2240
2331
  return /* @__PURE__ */ jsx5(Fragment2, { children: blocks.map((b, i) => {
2241
2332
  const lines = b.split("\n");
2242
2333
  const key = `${i}-${b.slice(0, 12)}`;
@@ -2257,8 +2348,8 @@ function Markdown({ text, onAction }) {
2257
2348
  }) });
2258
2349
  }
2259
2350
  var META = /[\\`*_[\]()#+\-.!>|~:]/g;
2260
- function escapeMarkdown(text) {
2261
- return text.replace(/\r?\n|\r/g, " ").replace(META, "\\$&");
2351
+ function escapeMarkdown(text2) {
2352
+ return text2.replace(/\r?\n|\r/g, " ").replace(META, "\\$&");
2262
2353
  }
2263
2354
  var unescapeMd = (s) => s.replace(/\\([!-/:-@[-`{-~])/g, "$1");
2264
2355
  function inline(s, onAction) {
@@ -2673,13 +2764,13 @@ function MultiSelectControl({
2673
2764
  const id = useId2();
2674
2765
  const chosen = Array.isArray(value) ? value : [];
2675
2766
  const names = options.filter((o) => chosen.includes(o.value)).map((o) => o.label);
2676
- const text = chosen.length === 0 ? emptyLabel : names.length <= 2 ? names.join(", ") : `${chosen.length} selected`;
2767
+ const text2 = chosen.length === 0 ? emptyLabel : names.length <= 2 ? names.join(", ") : `${chosen.length} selected`;
2677
2768
  return /* @__PURE__ */ jsxs5("div", { className: "ds-dd", ref: p.root, "data-block": block || void 0, "data-plain": plain || void 0, children: [
2678
2769
  /* @__PURE__ */ jsx7(
2679
2770
  PillTrigger,
2680
2771
  {
2681
2772
  label,
2682
- value: text,
2773
+ value: text2,
2683
2774
  open: p.open,
2684
2775
  onClick: () => p.setOpen(!p.open),
2685
2776
  triggerRef: p.trigger,
@@ -3099,7 +3190,7 @@ function ControlField({
3099
3190
  const r = v === "today" ? runtime.helpers.today() : interpolate(v, rootScope(runtime.getTree(), runtime.helpers));
3100
3191
  return typeof r === "number" ? new Date(r).toISOString().slice(0, 10) : r || void 0;
3101
3192
  };
3102
- const [text, setText] = useState2(typeof value === "string" ? value : "");
3193
+ const [text2, setText] = useState2(typeof value === "string" ? value : "");
3103
3194
  const timer = useRef3(void 0);
3104
3195
  useEffect2(() => setText(typeof value === "string" ? value : ""), [value]);
3105
3196
  useEffect2(() => () => clearTimeout(timer.current), []);
@@ -3110,7 +3201,7 @@ function ControlField({
3110
3201
  value,
3111
3202
  onChange,
3112
3203
  options,
3113
- text,
3204
+ text: text2,
3114
3205
  setText: (v) => {
3115
3206
  setText(v);
3116
3207
  clearTimeout(timer.current);
@@ -3219,7 +3310,7 @@ function ControlField({
3219
3310
  type: "search",
3220
3311
  "aria-label": label ?? String(def.name),
3221
3312
  placeholder: def.placeholder ?? label ?? "Search",
3222
- value: text,
3313
+ value: text2,
3223
3314
  onChange: (e) => {
3224
3315
  setText(e.target.value);
3225
3316
  clearTimeout(timer.current);
@@ -3703,7 +3794,7 @@ import "zod";
3703
3794
  import { useEffect as useEffect3, useLayoutEffect as useLayoutEffect2, useRef as useRef4, useState as useState3 } from "react";
3704
3795
  import { createPortal as createPortal2 } from "react-dom";
3705
3796
  import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
3706
- function InfoTip({ text }) {
3797
+ function InfoTip({ text: text2 }) {
3707
3798
  const ref = useRef4(null);
3708
3799
  const tip = useRef4(null);
3709
3800
  const [open, setOpen] = useState3(false);
@@ -3747,7 +3838,7 @@ function InfoTip({ text }) {
3747
3838
  ref,
3748
3839
  type: "button",
3749
3840
  className: "ds-info",
3750
- "aria-label": text,
3841
+ "aria-label": text2,
3751
3842
  onClick: (e) => e.stopPropagation(),
3752
3843
  onMouseEnter: show,
3753
3844
  onMouseLeave: hide,
@@ -3773,7 +3864,7 @@ function InfoTip({ text }) {
3773
3864
  visibility: pos ? "visible" : "hidden",
3774
3865
  ["--ds-tip-arrow"]: `${pos?.arrow ?? 0}px`
3775
3866
  },
3776
- children: text
3867
+ children: text2
3777
3868
  }
3778
3869
  ),
3779
3870
  root
@@ -3994,11 +4085,11 @@ function markPart(frame, node) {
3994
4085
  for (const n of root?.querySelectorAll(".ds-part-selected") ?? []) n.classList.remove("ds-part-selected");
3995
4086
  node?.classList.add("ds-part-selected");
3996
4087
  }
3997
- function liveLabel(text, at, h) {
4088
+ function liveLabel(text2, at, h) {
3998
4089
  const ago = at ? h.fmt.ago(at) : "\u2026";
3999
- if (typeof text !== "string") return `Live, updated ${ago}`;
4090
+ if (typeof text2 !== "string") return `Live, updated ${ago}`;
4000
4091
  const time = at ? h.fmt.date(at, { hour: "2-digit", minute: "2-digit", hour12: false }) : "\u2026";
4001
- return text.replaceAll("{time}", time).replaceAll("{ago}", ago);
4092
+ return text2.replaceAll("{time}", time).replaceAll("{ago}", ago);
4002
4093
  }
4003
4094
  function panelStyle(s) {
4004
4095
  if (!s) return void 0;
@@ -4456,11 +4547,11 @@ function loadingText(messages) {
4456
4547
  const v = messages?.loading;
4457
4548
  return v === void 0 || v === null || v === "" ? void 0 : String(v);
4458
4549
  }
4459
- function LoadingState({ text }) {
4460
- if (!text) return /* @__PURE__ */ jsx14("div", { className: "ds-skeleton", "aria-busy": "true", "aria-label": "Loading" });
4550
+ function LoadingState({ text: text2 }) {
4551
+ if (!text2) return /* @__PURE__ */ jsx14("div", { className: "ds-skeleton", "aria-busy": "true", "aria-label": "Loading" });
4461
4552
  return /* @__PURE__ */ jsxs10("output", { className: "ds-loading", "aria-busy": "true", children: [
4462
4553
  /* @__PURE__ */ jsx14("div", { className: "ds-skeleton", "aria-hidden": "true" }),
4463
- /* @__PURE__ */ jsx14("span", { className: "ds-loading-text", children: text })
4554
+ /* @__PURE__ */ jsx14("span", { className: "ds-loading-text", children: text2 })
4464
4555
  ] });
4465
4556
  }
4466
4557
 
@@ -4791,11 +4882,11 @@ var Status = defineWidget({
4791
4882
  const row = asRows(data)[0] ?? {};
4792
4883
  const state = String(field(row, spec.state) ?? "unknown");
4793
4884
  const t = spec.text ? spec.tone ?? "info" : spec.stateMap?.[state] ?? spec.tone ?? "neutral";
4794
- const text = spec.text ?? spec.labels?.[state] ?? state.charAt(0).toUpperCase() + state.slice(1);
4885
+ const text2 = spec.text ?? spec.labels?.[state] ?? state.charAt(0).toUpperCase() + state.slice(1);
4795
4886
  return /* @__PURE__ */ jsxs15("button", { type: "button", className: "ds-status", onClick: () => emit("click", "status", { datum: row, value: state }), children: [
4796
4887
  /* @__PURE__ */ jsxs15("span", { className: "ds-pill", style: { background: tone(t).bg, color: tone(t).fg, borderColor: tone(t).border }, children: [
4797
4888
  /* @__PURE__ */ jsx19("span", { className: "ds-dot", style: { background: tone(t).solid }, "aria-hidden": "true" }),
4798
- text
4889
+ text2
4799
4890
  ] }),
4800
4891
  spec.label && /* @__PURE__ */ jsx19("span", { className: "ds-status-label", children: String(field(row, spec.label) ?? "") })
4801
4892
  ] });
@@ -4828,13 +4919,13 @@ function Chips({
4828
4919
  }) {
4829
4920
  if (!chips?.length) return null;
4830
4921
  const shown = chips.filter((c) => c.when === void 0 || Boolean(evalOver(c.when, vars, helpers))).map((c) => {
4831
- let text = "";
4922
+ let text2 = "";
4832
4923
  try {
4833
4924
  const v = interpolate(c.text, scope(vars, helpers));
4834
- text = v === null || v === void 0 ? "" : String(v);
4925
+ text2 = v === null || v === void 0 ? "" : String(v);
4835
4926
  } catch {
4836
4927
  }
4837
- return { text, tone: toneOf(c.tone, vars, helpers) ?? "neutral" };
4928
+ return { text: text2, tone: toneOf(c.tone, vars, helpers) ?? "neutral" };
4838
4929
  }).filter((c) => c.text);
4839
4930
  if (shown.length === 0) return null;
4840
4931
  return /* @__PURE__ */ jsx20("span", { className: "ds-chips", children: shown.map((c, i) => (
@@ -5002,8 +5093,8 @@ var Table = defineWidget({
5002
5093
  const cell = (c, row) => {
5003
5094
  const v = field(row, c.key);
5004
5095
  if (c.type === "badge") {
5005
- const text = c.template ? tpl(c.template, row) : v === null || v === void 0 || v === "" ? "" : String(v);
5006
- if (!text) return c.empty ? /* @__PURE__ */ jsx21("span", { className: "ds-cell-empty", children: c.empty }) : "";
5096
+ const text2 = c.template ? tpl(c.template, row) : v === null || v === void 0 || v === "" ? "" : String(v);
5097
+ if (!text2) return c.empty ? /* @__PURE__ */ jsx21("span", { className: "ds-cell-empty", children: c.empty }) : "";
5007
5098
  let t = c.map?.[String(v)] ?? "neutral";
5008
5099
  if (c.tone) {
5009
5100
  try {
@@ -5013,7 +5104,7 @@ var Table = defineWidget({
5013
5104
  } catch {
5014
5105
  }
5015
5106
  }
5016
- return /* @__PURE__ */ jsx21("span", { className: "ds-chip", "data-tone": t, children: text });
5107
+ return /* @__PURE__ */ jsx21("span", { className: "ds-chip", "data-tone": t, children: text2 });
5017
5108
  }
5018
5109
  if (c.template) return tpl(c.template, row) || (c.empty ? /* @__PURE__ */ jsx21("span", { className: "ds-cell-empty", children: c.empty }) : "");
5019
5110
  if (c.list !== void 0) {
@@ -6657,10 +6748,10 @@ function Grid({
6657
6748
  const target2 = el.firstElementChild;
6658
6749
  if (target2?.querySelector('[aria-busy="true"]')) return;
6659
6750
  el.setAttribute("data-measuring", "");
6660
- const px = target2?.offsetHeight ?? 0;
6751
+ const px2 = target2?.offsetHeight ?? 0;
6661
6752
  el.removeAttribute("data-measuring");
6662
- if (!px) return;
6663
- const rows = exact ? Math.ceil(px) + gap : Math.ceil((px + gap) / (rowHeight + gap));
6753
+ if (!px2) return;
6754
+ const rows = exact ? Math.ceil(px2) + gap : Math.ceil((px2 + gap) / (rowHeight + gap));
6664
6755
  setFitRows((r) => {
6665
6756
  const cur = r[panel];
6666
6757
  if (cur === rows) return r;
@@ -6980,7 +7071,7 @@ function TourButton({ steps }) {
6980
7071
  const titleId = useId5();
6981
7072
  const textId = useId5();
6982
7073
  const step = at === null ? void 0 : steps[at];
6983
- const text = useTree(
7074
+ const text2 = useTree(
6984
7075
  useCallback7(
6985
7076
  (t) => {
6986
7077
  if (!step) return null;
@@ -7058,8 +7149,8 @@ function TourButton({ steps }) {
7058
7149
  open: true,
7059
7150
  ref: dialog,
7060
7151
  className: "ds-tour",
7061
- "aria-labelledby": text?.title ? titleId : void 0,
7062
- "aria-label": text?.title ? void 0 : "Tour",
7152
+ "aria-labelledby": text2?.title ? titleId : void 0,
7153
+ "aria-label": text2?.title ? void 0 : "Tour",
7063
7154
  "aria-describedby": textId,
7064
7155
  tabIndex: -1,
7065
7156
  style: pos ? { top: pos.top, left: pos.left } : { visibility: "hidden" },
@@ -7071,14 +7162,14 @@ function TourButton({ steps }) {
7071
7162
  },
7072
7163
  children: [
7073
7164
  /* @__PURE__ */ jsxs22("div", { className: "ds-tour-head", children: [
7074
- text?.title && /* @__PURE__ */ jsx30("h3", { className: "ds-tour-title", id: titleId, children: text.title }),
7165
+ text2?.title && /* @__PURE__ */ jsx30("h3", { className: "ds-tour-title", id: titleId, children: text2.title }),
7075
7166
  /* @__PURE__ */ jsxs22("span", { className: "ds-tour-count", children: [
7076
7167
  at + 1,
7077
7168
  " / ",
7078
7169
  steps.length
7079
7170
  ] })
7080
7171
  ] }),
7081
- /* @__PURE__ */ jsx30("p", { className: "ds-tour-text", id: textId, "aria-live": "polite", children: text?.text }),
7172
+ /* @__PURE__ */ jsx30("p", { className: "ds-tour-text", id: textId, "aria-live": "polite", children: text2?.text }),
7082
7173
  /* @__PURE__ */ jsxs22("div", { className: "ds-tour-foot", children: [
7083
7174
  /* @__PURE__ */ jsx30("button", { type: "button", className: "ds-tour-skip", onClick: close, children: "Close" }),
7084
7175
  /* @__PURE__ */ jsx30("span", { className: "ds-filters-spacer" }),
@@ -8240,7 +8331,7 @@ function DashboardBody({
8240
8331
  useCallback9(
8241
8332
  (t) => {
8242
8333
  const sc = rootScope(t, runtime.helpers);
8243
- const text = (v) => {
8334
+ const text2 = (v) => {
8244
8335
  if (!v) return void 0;
8245
8336
  try {
8246
8337
  return String(interpolate(v, sc) ?? "");
@@ -8250,9 +8341,9 @@ function DashboardBody({
8250
8341
  };
8251
8342
  return {
8252
8343
  view: t.view,
8253
- title: text(doc.spec.display.title),
8254
- description: text(doc.spec.display.description),
8255
- synced: text(doc.spec.display.syncedLabel)
8344
+ title: text2(doc.spec.display.title),
8345
+ description: text2(doc.spec.display.description),
8346
+ synced: text2(doc.spec.display.syncedLabel)
8256
8347
  };
8257
8348
  },
8258
8349
  [runtime, doc]
@@ -8290,14 +8381,14 @@ function DashboardBody({
8290
8381
  flowStyle: (id, height) => {
8291
8382
  const panel = doc.spec.panels[id];
8292
8383
  const st = panel?.style;
8293
- const px = (v) => typeof v === "number" ? `${v}px` : v;
8384
+ const px2 = (v) => typeof v === "number" ? `${v}px` : v;
8294
8385
  return {
8295
8386
  flex: st?.flex ?? "1 1 100%",
8296
8387
  // Charts and images size themselves to the card, so their card keeps its grid height; anything
8297
8388
  // else grows to fit its content.
8298
8389
  ...panel && !CONTENT_SIZED.has(panel.kind) ? { height } : {},
8299
- ...st?.minWidth !== void 0 ? { minWidth: px(st.minWidth) } : {},
8300
- ...st?.maxWidth !== void 0 ? { maxWidth: px(st.maxWidth) } : {}
8390
+ ...st?.minWidth !== void 0 ? { minWidth: px2(st.minWidth) } : {},
8391
+ ...st?.maxWidth !== void 0 ? { maxWidth: px2(st.maxWidth) } : {}
8301
8392
  };
8302
8393
  },
8303
8394
  view: head.view,
@@ -8478,6 +8569,7 @@ export {
8478
8569
  panelRows,
8479
8570
  parse,
8480
8571
  parseDuration,
8572
+ partsCss,
8481
8573
  placeholders,
8482
8574
  plantDate,
8483
8575
  plantDayStart,