@dashspec/renderer 0.1.5 → 0.1.6

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.
@@ -7481,7 +7481,7 @@ declare class TransformError extends Error {
7481
7481
  declare function applyTransform(data: unknown, steps: readonly Step[], root: Scope, opts?: TransformOptions): unknown;
7482
7482
 
7483
7483
  /** This package's version. A test keeps it equal to package.json's; bump both together. */
7484
- declare const RENDERER_VERSION = "0.1.5";
7484
+ declare const RENDERER_VERSION = "0.1.6";
7485
7485
  /**
7486
7486
  * Whether `version` satisfies `range`. Supports what documents need: "1.2.3" (that or newer within the major, like
7487
7487
  * "^"), ">=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-B5SCwhPB.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-BnA2w3yb.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-7J6WHLG6.js";
84
+ } from "./chunk-U4JCC3MX.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-B5SCwhPB.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-B5SCwhPB.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-BnA2w3yb.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-BnA2w3yb.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';
@@ -491,6 +491,36 @@ interface UIStateProps {
491
491
  panel: string;
492
492
  message?: string | undefined;
493
493
  }
494
+ /** One filter as a custom filter bar sees it: the definition from the document, as written. */
495
+ interface UIFilterDef {
496
+ name: string;
497
+ kind: string;
498
+ label?: string;
499
+ /** The whole `spec.variables` entry (options, presets, default, maxDays, stepper…). */
500
+ config: Record<string, unknown>;
501
+ }
502
+ /** What a custom filter bar (`ui.FilterBar`) receives. */
503
+ interface UIFilterBarProps {
504
+ /** The filters the bar shows now: not hidden, not placed on the canvas, `visibleWhen` true. */
505
+ filters: UIFilterDef[];
506
+ /** Every filter's current value, by name. */
507
+ values: Record<string, unknown>;
508
+ /** Set one filter; every datasource and widget reading it reacts. */
509
+ setFilter: (name: string, value: unknown) => void;
510
+ /** Back to every filter's default. */
511
+ reset: () => void;
512
+ /** True when every filter is at its default. */
513
+ isDefault: boolean;
514
+ /** The dashboard's views (from `layouts`), the current one, and a setter. */
515
+ views: {
516
+ name: string;
517
+ label: string;
518
+ }[];
519
+ view: string | null;
520
+ setView: (view: string) => void;
521
+ /** DashSpec's own control for one filter (with your design system's controls), to reuse inside your bar. */
522
+ renderControl: (name: string) => ReactNode;
523
+ }
494
524
  /**
495
525
  * Controls DashSpec draws itself (filters, panel controls, empty / error / loading states). A design system can
496
526
  * replace any of them; the rest stay DashSpec's own. Each receives the props above and nothing else.
@@ -506,6 +536,12 @@ interface UIComponents {
506
536
  EmptyState?: ComponentType<UIStateProps>;
507
537
  ErrorState?: ComponentType<UIStateProps>;
508
538
  Loading?: ComponentType<UIStateProps>;
539
+ /**
540
+ * Your own whole filter bar, in place of DashSpec's: any layout and design. It gets every filter the bar would
541
+ * show, their values, setters and the views; `renderControl(name)` draws DashSpec's own control for one filter
542
+ * where you want to reuse it. Widgets react to its changes like to the built-in bar.
543
+ */
544
+ FilterBar?: ComponentType<UIFilterBarProps>;
509
545
  /** Controls for your own filter kinds, by namespaced kind: { "acme.ShiftPicker": ShiftPicker }. */
510
546
  filters?: Record<string, ComponentType<UICustomFilterProps>>;
511
547
  }
@@ -1444,4 +1480,4 @@ declare function lazyWidget<S extends z.ZodTypeAny>(def: Omit<WidgetDefinition<S
1444
1480
  fallback?: ReactNode;
1445
1481
  }): WidgetDefinition<S>;
1446
1482
 
1447
- export { AnyWidgetDefinition, BAR, BAR_ICONS, type Breakpoint, CallbackApi, type ColorTokens, ControlField, type DashEvent, DashSpecProvider, type DashSpecSettings, Dashboard, DashboardContext, type DashboardHandle, DashboardRenderer, type DashboardRendererProps, type DashboardRuntime, type DatasourceType, DateControl, DateRangeControl, type DeepPartial, type DesignSystem, 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 UIMultiSelectProps, type UISearchProps, type UISelectProps, type UIStateProps, type UIToggleProps, WidgetDefinition, WidgetMeta, WidgetProps, type WidgetRegistry, type WrapOptions, builtInWidgets, checkWidget, combineDesignSystems, createDashboardRuntime, createTheme, createWidgetRegistry, defaultTheme, defineDesignSystem, defineWidget, echartsTheme, layoutsForView, lazyWidget, mergeDeep, panelRows, presetRange, resolveMode, themeCssVars, themeStylesheet, timeSettingsFor, useDashSpecSettings, useDashboard, useDashboardActions, useDashboardState, useNodeScope, useThemeTokens, useTree, widgetChecks, wrapComponent };
1483
+ export { AnyWidgetDefinition, BAR, BAR_ICONS, type Breakpoint, CallbackApi, type ColorTokens, ControlField, type DashEvent, DashSpecProvider, type DashSpecSettings, Dashboard, DashboardContext, type DashboardHandle, DashboardRenderer, type DashboardRendererProps, type DashboardRuntime, type DatasourceType, DateControl, DateRangeControl, type DeepPartial, type DesignSystem, 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 WrapOptions, builtInWidgets, checkWidget, combineDesignSystems, createDashboardRuntime, createTheme, createWidgetRegistry, defaultTheme, defineDesignSystem, defineWidget, echartsTheme, layoutsForView, lazyWidget, mergeDeep, panelRows, presetRange, resolveMode, themeCssVars, themeStylesheet, timeSettingsFor, useDashSpecSettings, useDashboard, useDashboardActions, useDashboardState, useNodeScope, useThemeTokens, useTree, widgetChecks, wrapComponent };
package/dist/index.js CHANGED
@@ -115,7 +115,7 @@ import {
115
115
  translator,
116
116
  validateDocument,
117
117
  widgetChecks
118
- } from "./chunk-7J6WHLG6.js";
118
+ } from "./chunk-U4JCC3MX.js";
119
119
  import {
120
120
  createStateProxy,
121
121
  getPath,
@@ -3154,13 +3154,14 @@ function FilterBar() {
3154
3154
  useCallback2(
3155
3155
  (t) => ({
3156
3156
  filters: t.filters,
3157
+ view: t.view,
3157
3158
  visible: variables.filter(
3158
3159
  (v) => typeof v.visibleWhen !== "string" || Boolean(evaluateSafe(v.visibleWhen, rootScope(t, runtime.helpers), true))
3159
3160
  ).map((v) => v.name).join("\0")
3160
3161
  }),
3161
3162
  [variables, runtime]
3162
3163
  ),
3163
- (a, b) => a.filters === b.filters && a.visible === b.visible
3164
+ (a, b) => a.filters === b.filters && a.visible === b.visible && a.view === b.view
3164
3165
  );
3165
3166
  const visibleNames = new Set(state.visible.split("\0"));
3166
3167
  const [draft, setDraft] = useState2(null);
@@ -3185,6 +3186,48 @@ function FilterBar() {
3185
3186
  if (shown.length === 0 || bar.show === false) return null;
3186
3187
  const values = { ...state.filters, ...draft };
3187
3188
  const set = (name, value, apply) => apply ? runtime.store.dispatch(stateActions.setFilter({ name, value })) : setDraft((d) => ({ ...d, [name]: value }));
3189
+ const Custom = options.ui?.FilterBar;
3190
+ if (Custom && !options.onFilterSelect) {
3191
+ const layouts = runtime.doc.spec.layouts ?? [];
3192
+ const views = [];
3193
+ for (const l of layouts)
3194
+ if (l.view && !views.some((v) => v.name === l.view)) views.push({ name: l.view, label: l.label ?? l.view });
3195
+ const byName = new Map(variables.map((v) => [v.name, v]));
3196
+ return /* @__PURE__ */ jsx8(
3197
+ Custom,
3198
+ {
3199
+ filters: shown.map((v) => ({
3200
+ name: v.name,
3201
+ kind: v.kind,
3202
+ ...typeof v.label === "string" ? { label: v.label } : {},
3203
+ config: v
3204
+ })),
3205
+ values,
3206
+ setFilter: (name, value) => runtime.store.dispatch(stateActions.setFilter({ name, value })),
3207
+ reset: () => {
3208
+ setDraft(null);
3209
+ for (const [name, value] of Object.entries(defaults()))
3210
+ runtime.store.dispatch(stateActions.setFilter({ name, value }));
3211
+ },
3212
+ isDefault,
3213
+ views,
3214
+ view: state.view,
3215
+ setView: (view) => runtime.store.dispatch(stateActions.setView(view)),
3216
+ renderControl: (name) => {
3217
+ const def = byName.get(name);
3218
+ return def ? /* @__PURE__ */ jsx8(
3219
+ ControlField,
3220
+ {
3221
+ compact: true,
3222
+ def,
3223
+ value: values[name],
3224
+ onChange: (val) => set(name, val, applyMode(def) === "change")
3225
+ }
3226
+ ) : null;
3227
+ }
3228
+ }
3229
+ );
3230
+ }
3188
3231
  const toolbar = /* @__PURE__ */ jsxs5(
3189
3232
  "div",
3190
3233
  {