@dashspec/renderer 0.1.4 → 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.
@@ -182,6 +182,43 @@ export const acme = defineDesignSystem({
182
182
  (`${filters.shift}`), starts at `default` (or `null`), and is written to the URL as text.
183
183
  A namespaced filter kind with no registered component renders nothing.
184
184
 
185
+ ## Your own filter bar
186
+
187
+ Register a whole filter bar as `ui.FilterBar` (on `DashSpecProvider`, a design system or the
188
+ renderer) and it replaces DashSpec's: any layout, any design. Widgets and datasources react to
189
+ it exactly as to the built-in bar.
190
+
191
+ ```tsx
192
+ import type { UIFilterBarProps } from "@dashspec/renderer";
193
+
194
+ function MyFilterBar({ filters, values, setFilter, reset, isDefault, views, view, setView, renderControl }: UIFilterBarProps) {
195
+ return (
196
+ <header className="my-bar">
197
+ {filters.map((f) =>
198
+ f.name === "period" ? <MyDatePicker key={f.name} value={values.period} onChange={(v) => setFilter("period", v)} />
199
+ : <span key={f.name}>{renderControl(f.name)}</span>, // DashSpec's own control, with your design system's parts
200
+ )}
201
+ <select value={view ?? ""} onChange={(e) => setView(e.target.value)}>
202
+ {views.map((v) => <option key={v.name} value={v.name}>{v.label}</option>)}
203
+ </select>
204
+ {!isDefault && <button onClick={reset}>Reset</button>}
205
+ </header>
206
+ );
207
+ }
208
+
209
+ <DashSpecProvider ui={{ FilterBar: MyFilterBar }}>…</DashSpecProvider>
210
+ ```
211
+
212
+ `filters` lists what the bar would show now (not `hidden`, not placed on the canvas as a `Filter`
213
+ node, `visibleWhen` true), each with its whole `spec.variables` entry as `config`. In the
214
+ Builder's edit mode DashSpec's own bar is shown so filters stay selectable.
215
+
216
+ **Filters outside the renderer.** Keep the controls anywhere in your app and pass their values
217
+ in: `variables={{ period, line }}` on `DashboardRenderer` (controlled) with
218
+ `onVariableChange`, or call `useDashboardActions(id).setVariable(name, value)` from any
219
+ component. Set `display.filterBar.show: false` in the document to hide DashSpec's bar. See
220
+ [State and events](state-and-events.md).
221
+
185
222
  ## Combine several
186
223
 
187
224
  Pass several design systems; they combine:
package/docs/theming.md CHANGED
@@ -29,6 +29,7 @@ interface Theme {
29
29
  | `scale.z` | `raised`, `sticky`, `overlay`, `tooltip` |
30
30
  | `scale.breakpoints` | `sm`, `md`, `lg`, `xl`, `tv` (px) |
31
31
  | `scale.density` | `"compact"`, `"comfortable"` (default) or `"spacious"`. Scales every `--ds-space-*` (×0.75, ×1, ×1.25, rounded) and sets `--ds-control-height` (30, 36, 42 px) for filters, buttons and inputs; also emitted as `--ds-density`. Your own widgets can read it with `useThemeTokens` |
32
+ | `scale.chip` | Status chips ("On track", "Target un-defined"): `radius`, `border`, `weight`, `paddingX`, `height`, `fontSize` in px. Leave out for the default look; e.g. `{ "radius": 999, "border": 0, "weight": 700 }` for borderless pills |
32
33
  | `surface` | `page`, `card`, `sunken`, `overlay`, `selection`, `scrim`, `backdrop?` (page background, may be a gradient), `tableHeader?` |
33
34
  | `text` | `primary`, `secondary`, `subtle`, `disabled`, `onFill` |
34
35
  | `border` | `default`, `control`, `focus` |
package/docs/widgets.md CHANGED
@@ -66,7 +66,7 @@ Field props such as `x`, `label` or `value` name a field of each data row; dot p
66
66
 
67
67
  | Kind | What it shows | Main props | Events |
68
68
  |---|---|---|---|
69
- | `Kpi` | A metric card: label, big value, target and an "On track / Action needed" chip | `unit`, `format`, `decimals`, `target`, `targetLabel`, `goodWhen` (`up` / `down` / `none`), `badge`, `statusLabels`, `compare`, `band`, `progress`, `note`, `emptyText`, `empty` (show `emptyText` even with a value), `sublabel`, `size` (`normal` / `hero`), `tone` | `click`, `hover` (part `value`) |
69
+ | `Kpi` | A metric card: label, big value, target and an "On track / Action needed" chip | `unit`, `unitStyle` (`small` / `value`), `format`, `decimals`, `target`, `targetLabel`, `goodWhen` (`up` / `down` / `none`), `badge`, `statusLabels`, `compare`, `band`, `progress`, `note`, `emptyText`, `empty` (show `emptyText` even with a value), `sublabel`, `size` (`normal` / `hero`), `tone` | `click`, `hover` (part `value`) |
70
70
  | `Tiles` | One tile per row: label, big number, caption | `label`, `value` (required), `caption`, `status`, `statusMap`, `valueTone`, `count`, `format`, `unit`, `columns`, `minTileWidth`, `wrap`, `selectable`, `selected` | `click`, `hover`, `select` (part `tile`) |
71
71
  | `Gauge` | A value on an arc or circle with coloured bands | `min` (0), `max` (100), `bands: [{ to, tone }]`, `shape` (`arc` / `circle`), `unit`, `format`, `decimals` | `click` |
72
72
  | `Status` | A status badge from a state field, or fixed text | `state` (field, default `"state"`), `stateMap`, `labels`, `label`, `text`, `tone` | `click` |
@@ -147,7 +147,7 @@ Charts take their colours from the theme's `chart.series` tokens (see
147
147
 
148
148
  | Kind | What it shows | Main props | Events |
149
149
  |---|---|---|---|
150
- | `Table` | Rows and columns with sorting, search, filters, paging, totals and pivots | `columns` (below), `columnsFrom`, `totals`, `pivot`, `pagination`, `search`, `sorting`, `filtering`, `sticky`, `rowKey`, `rowMutedWhen`, `virtual`, `density` | `rowClick`, `cellClick`, `hover` (parts `row`, `cell`) |
150
+ | `Table` | Rows and columns with sorting, search, filters, paging, totals and pivots | `columns` (below), `columnsFrom`, `totals`, `pivot`, `pagination`, `search`, `sorting`, `filtering`, `sticky`, `rowKey`, `rowMutedWhen`, `virtual`, `density`, `maxHeight` (px; rows scroll past it) | `rowClick`, `cellClick`, `hover` (parts `row`, `cell`) |
151
151
  | `CardGrid` | One card per row with fields, a status and a progress bar | `cardTitle` (required), `fields: [{ key, label, format, unit }]`, `status`, `statusMap`, `progress: { value, max, label }`, `badge`, `minCardWidth`, `selectable`, `selected`, `rowKey` | `click`, `select` (part `card`) |
152
152
 
153
153
  A table column is `{ key, label?, type?, … }`. `type` is `text`, `number`, `badge`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashspec/renderer",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Draws a dashboard from DashSpec JSON: widgets, data, events, state.",
5
5
  "keywords": [
6
6
  "dashboard",