nuxt-ui-tools 1.1.0 → 1.3.0

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.
Files changed (213) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +10 -1
  3. package/dist/runtime/dashboard/components/block/dashboard-block-state.d.vue.ts +2 -0
  4. package/dist/runtime/dashboard/components/block/dashboard-block-state.vue +4 -1
  5. package/dist/runtime/dashboard/components/block/dashboard-block-state.vue.d.ts +2 -0
  6. package/dist/runtime/dashboard/components/block/dashboard-chips.d.vue.ts +20 -0
  7. package/dist/runtime/dashboard/components/block/dashboard-chips.vue +42 -0
  8. package/dist/runtime/dashboard/components/block/dashboard-chips.vue.d.ts +20 -0
  9. package/dist/runtime/dashboard/components/block/dashboard-series-picker.d.vue.ts +8 -0
  10. package/dist/runtime/dashboard/components/block/dashboard-series-picker.vue +29 -0
  11. package/dist/runtime/dashboard/components/block/dashboard-series-picker.vue.d.ts +8 -0
  12. package/dist/runtime/dashboard/components/block/dashboard-skeleton.d.vue.ts +1 -1
  13. package/dist/runtime/dashboard/components/block/dashboard-skeleton.vue +6 -3
  14. package/dist/runtime/dashboard/components/block/dashboard-skeleton.vue.d.ts +1 -1
  15. package/dist/runtime/dashboard/components/block/dashboard-view-scope.d.vue.ts +21 -0
  16. package/dist/runtime/dashboard/components/block/dashboard-view-scope.vue +12 -0
  17. package/dist/runtime/dashboard/components/block/dashboard-view-scope.vue.d.ts +21 -0
  18. package/dist/runtime/dashboard/components/dashboard-alerts.vue +3 -3
  19. package/dist/runtime/dashboard/components/dashboard-bar-chart.d.vue.ts +14 -3
  20. package/dist/runtime/dashboard/components/dashboard-bar-chart.vue +30 -9
  21. package/dist/runtime/dashboard/components/dashboard-bar-chart.vue.d.ts +14 -3
  22. package/dist/runtime/dashboard/components/dashboard-bars.vue +4 -4
  23. package/dist/runtime/dashboard/components/dashboard-card.vue +28 -6
  24. package/dist/runtime/dashboard/components/dashboard-combo-chart.d.vue.ts +6 -1
  25. package/dist/runtime/dashboard/components/dashboard-combo-chart.vue +13 -3
  26. package/dist/runtime/dashboard/components/dashboard-combo-chart.vue.d.ts +6 -1
  27. package/dist/runtime/dashboard/components/dashboard-donut-chart.vue +5 -5
  28. package/dist/runtime/dashboard/components/dashboard-feed.vue +8 -7
  29. package/dist/runtime/dashboard/components/dashboard-filter.d.vue.ts +67 -0
  30. package/dist/runtime/dashboard/components/dashboard-filter.vue +134 -0
  31. package/dist/runtime/dashboard/components/dashboard-filter.vue.d.ts +67 -0
  32. package/dist/runtime/dashboard/components/dashboard-filters.d.vue.ts +49 -0
  33. package/dist/runtime/dashboard/components/dashboard-filters.vue +96 -0
  34. package/dist/runtime/dashboard/components/dashboard-filters.vue.d.ts +49 -0
  35. package/dist/runtime/dashboard/components/dashboard-funnel.vue +5 -5
  36. package/dist/runtime/dashboard/components/dashboard-gauge.vue +3 -3
  37. package/dist/runtime/dashboard/components/dashboard-grid.d.vue.ts +10 -3
  38. package/dist/runtime/dashboard/components/dashboard-grid.vue +24 -9
  39. package/dist/runtime/dashboard/components/dashboard-grid.vue.d.ts +10 -3
  40. package/dist/runtime/dashboard/components/dashboard-line-chart.d.vue.ts +14 -3
  41. package/dist/runtime/dashboard/components/dashboard-line-chart.vue +30 -9
  42. package/dist/runtime/dashboard/components/dashboard-line-chart.vue.d.ts +14 -3
  43. package/dist/runtime/dashboard/components/dashboard-list.d.vue.ts +3 -0
  44. package/dist/runtime/dashboard/components/dashboard-list.vue +18 -6
  45. package/dist/runtime/dashboard/components/dashboard-list.vue.d.ts +3 -0
  46. package/dist/runtime/dashboard/components/dashboard-page.d.vue.ts +53 -0
  47. package/dist/runtime/dashboard/components/dashboard-page.vue +156 -0
  48. package/dist/runtime/dashboard/components/dashboard-page.vue.d.ts +53 -0
  49. package/dist/runtime/dashboard/components/dashboard-paired-bars.vue +4 -4
  50. package/dist/runtime/dashboard/components/dashboard-refresh.d.vue.ts +1 -1
  51. package/dist/runtime/dashboard/components/dashboard-refresh.vue +1 -0
  52. package/dist/runtime/dashboard/components/dashboard-refresh.vue.d.ts +1 -1
  53. package/dist/runtime/dashboard/components/dashboard-stack-bar.vue +4 -4
  54. package/dist/runtime/dashboard/components/dashboard-stat.d.vue.ts +14 -2
  55. package/dist/runtime/dashboard/components/dashboard-stat.vue +28 -10
  56. package/dist/runtime/dashboard/components/dashboard-stat.vue.d.ts +14 -2
  57. package/dist/runtime/dashboard/components/dashboard-stats.vue +3 -3
  58. package/dist/runtime/dashboard/components/dashboard-table.d.vue.ts +1 -1
  59. package/dist/runtime/dashboard/components/dashboard-table.vue +3 -3
  60. package/dist/runtime/dashboard/components/dashboard-table.vue.d.ts +1 -1
  61. package/dist/runtime/dashboard/components/dashboard-tabs.d.vue.ts +1 -1
  62. package/dist/runtime/dashboard/components/dashboard-tabs.vue.d.ts +1 -1
  63. package/dist/runtime/dashboard/components/dashboard-total.d.vue.ts +7 -2
  64. package/dist/runtime/dashboard/components/dashboard-total.vue +10 -2
  65. package/dist/runtime/dashboard/components/dashboard-total.vue.d.ts +7 -2
  66. package/dist/runtime/dashboard/components/dashboard-view-tabs.d.vue.ts +33 -0
  67. package/dist/runtime/dashboard/components/dashboard-view-tabs.vue +66 -0
  68. package/dist/runtime/dashboard/components/dashboard-view-tabs.vue.d.ts +33 -0
  69. package/dist/runtime/dashboard/components/dashboard-widget.vue +1 -1
  70. package/dist/runtime/dashboard/components/filter/dashboard-filter-menu.d.vue.ts +44 -0
  71. package/dist/runtime/dashboard/components/filter/dashboard-filter-menu.vue +220 -0
  72. package/dist/runtime/dashboard/components/filter/dashboard-filter-menu.vue.d.ts +44 -0
  73. package/dist/runtime/dashboard/composables/use-dashboard-api.d.ts +6 -1
  74. package/dist/runtime/dashboard/composables/use-dashboard-api.js +29 -6
  75. package/dist/runtime/dashboard/composables/use-dashboard-block.d.ts +5 -4
  76. package/dist/runtime/dashboard/composables/use-dashboard-block.js +32 -15
  77. package/dist/runtime/dashboard/composables/use-dashboard-chart.d.ts +8 -1
  78. package/dist/runtime/dashboard/composables/use-dashboard-chart.js +16 -4
  79. package/dist/runtime/dashboard/composables/use-dashboard-context.d.ts +50 -0
  80. package/dist/runtime/dashboard/composables/use-dashboard-context.js +56 -0
  81. package/dist/runtime/dashboard/composables/use-dashboard-derived.js +6 -1
  82. package/dist/runtime/dashboard/composables/use-dashboard-filter-control.d.ts +16 -0
  83. package/dist/runtime/dashboard/composables/use-dashboard-filter-control.js +161 -0
  84. package/dist/runtime/dashboard/composables/use-dashboard-filter-scope.d.ts +37 -0
  85. package/dist/runtime/dashboard/composables/use-dashboard-filter-scope.js +107 -0
  86. package/dist/runtime/dashboard/composables/use-dashboard-format.d.ts +46 -6
  87. package/dist/runtime/dashboard/composables/use-dashboard-format.js +51 -8
  88. package/dist/runtime/dashboard/composables/use-dashboard-options.d.ts +11 -4
  89. package/dist/runtime/dashboard/composables/use-dashboard-options.js +33 -47
  90. package/dist/runtime/dashboard/composables/use-dashboard-remote-options.d.ts +8 -5
  91. package/dist/runtime/dashboard/composables/use-dashboard-remote-options.js +66 -77
  92. package/dist/runtime/dashboard/composables/use-dashboard-resource.d.ts +15 -4
  93. package/dist/runtime/dashboard/composables/use-dashboard-resource.js +52 -17
  94. package/dist/runtime/dashboard/composables/use-dashboard-scope.d.ts +10 -7
  95. package/dist/runtime/dashboard/composables/use-dashboard-scope.js +26 -16
  96. package/dist/runtime/dashboard/composables/use-dashboard-series-picker.d.ts +20 -0
  97. package/dist/runtime/dashboard/composables/use-dashboard-series-picker.js +30 -0
  98. package/dist/runtime/dashboard/composables/use-dashboard-time.d.ts +2 -0
  99. package/dist/runtime/dashboard/composables/use-dashboard-time.js +4 -1
  100. package/dist/runtime/dashboard/composables/use-dashboard-ui.d.ts +12 -2
  101. package/dist/runtime/dashboard/composables/use-dashboard-ui.js +3 -0
  102. package/dist/runtime/dashboard/composables/use-dashboard-views.d.ts +15 -3
  103. package/dist/runtime/dashboard/composables/use-dashboard-views.js +33 -10
  104. package/dist/runtime/dashboard/composables/use-dashboard.d.ts +18 -12
  105. package/dist/runtime/dashboard/composables/use-dashboard.js +98 -9
  106. package/dist/runtime/dashboard/index.d.ts +3 -1
  107. package/dist/runtime/dashboard/index.js +3 -1
  108. package/dist/runtime/dashboard/schema/index.d.ts +62 -30
  109. package/dist/runtime/dashboard/schema/index.js +3 -0
  110. package/dist/runtime/dashboard/types/blocks.d.ts +30 -4
  111. package/dist/runtime/dashboard/types/charts.d.ts +2 -2
  112. package/dist/runtime/dashboard/types/controls.d.ts +123 -0
  113. package/dist/runtime/dashboard/types/filters.d.ts +236 -0
  114. package/dist/runtime/dashboard/types/index.d.ts +3 -2
  115. package/dist/runtime/dashboard/types/page.d.ts +17 -0
  116. package/dist/runtime/dashboard/types/page.js +0 -0
  117. package/dist/runtime/dashboard/types/resource.d.ts +66 -28
  118. package/dist/runtime/dashboard/types/runtime.d.ts +39 -8
  119. package/dist/runtime/dashboard/types/schema.d.ts +94 -54
  120. package/dist/runtime/dashboard/types/ui.d.ts +78 -0
  121. package/dist/runtime/dashboard/utils/builders/dashboard-filters.d.ts +142 -0
  122. package/dist/runtime/dashboard/utils/builders/dashboard-filters.js +135 -0
  123. package/dist/runtime/dashboard/utils/charts.d.ts +4 -15
  124. package/dist/runtime/dashboard/utils/charts.js +26 -28
  125. package/dist/runtime/dashboard/utils/{params/codecs.d.ts → codecs.d.ts} +2 -2
  126. package/dist/runtime/dashboard/utils/{params/codecs.js → codecs.js} +1 -1
  127. package/dist/runtime/dashboard/utils/environment.d.ts +36 -0
  128. package/dist/runtime/dashboard/utils/environment.js +30 -0
  129. package/dist/runtime/dashboard/utils/filters.d.ts +44 -0
  130. package/dist/runtime/dashboard/utils/filters.js +62 -0
  131. package/dist/runtime/dashboard/utils/format.d.ts +25 -0
  132. package/dist/runtime/dashboard/utils/format.js +66 -0
  133. package/dist/runtime/dashboard/utils/grid.d.ts +17 -0
  134. package/dist/runtime/dashboard/utils/grid.js +14 -0
  135. package/dist/runtime/dashboard/utils/options.d.ts +3 -8
  136. package/dist/runtime/dashboard/utils/options.js +6 -5
  137. package/dist/runtime/dashboard/utils/remote.d.ts +7 -0
  138. package/dist/runtime/dashboard/utils/remote.js +14 -0
  139. package/dist/runtime/dashboard/utils/resource.d.ts +16 -7
  140. package/dist/runtime/dashboard/utils/resource.js +15 -9
  141. package/dist/runtime/dashboard/utils/schema.d.ts +8 -3
  142. package/dist/runtime/dashboard/utils/schema.js +9 -4
  143. package/dist/runtime/dashboard/utils/state.d.ts +11 -6
  144. package/dist/runtime/dashboard/utils/state.js +10 -5
  145. package/dist/runtime/dashboard/utils/time.d.ts +2 -0
  146. package/dist/runtime/dashboard/utils/time.js +11 -1
  147. package/dist/runtime/dashboard/utils/ui.d.ts +1 -1
  148. package/dist/runtime/dashboard/utils/ui.js +1 -1
  149. package/dist/runtime/form/components/root/form.vue +1 -1
  150. package/dist/runtime/form/fields/card-selection.d.ts +1 -0
  151. package/dist/runtime/form/fields/card-selection.js +1 -0
  152. package/dist/runtime/form/fields/checkbox-card/component.vue +3 -1
  153. package/dist/runtime/form/fields/checkbox-group/component.vue +5 -0
  154. package/dist/runtime/form/fields/radio/component.vue +10 -0
  155. package/dist/runtime/form/fields/radio-card/component.vue +3 -1
  156. package/dist/runtime/form/types/options.d.ts +1 -11
  157. package/dist/runtime/form/utils/focus.js +1 -1
  158. package/dist/runtime/i18n/locales/en.js +32 -1
  159. package/dist/runtime/i18n/locales/fr.js +32 -1
  160. package/dist/runtime/i18n/types.d.ts +44 -0
  161. package/dist/runtime/shared/styles/scrollbars.css +1 -1
  162. package/dist/runtime/shared/styles/tokens.css +1 -1
  163. package/dist/runtime/shared/types/query.d.ts +8 -0
  164. package/dist/runtime/shared/utils/remote-options.d.ts +10 -0
  165. package/dist/runtime/shared/utils/remote-options.js +6 -0
  166. package/dist/runtime/table/components/filters/shared/filter-option-list-end.d.vue.ts +11 -0
  167. package/dist/runtime/table/components/filters/shared/filter-option-list-end.vue +76 -0
  168. package/dist/runtime/table/components/filters/shared/filter-option-list-end.vue.d.ts +11 -0
  169. package/dist/runtime/table/components/filters/shared/filter-option-loading-list.d.vue.ts +3 -0
  170. package/dist/runtime/table/components/filters/shared/filter-option-loading-list.vue +2 -1
  171. package/dist/runtime/table/components/filters/shared/filter-option-loading-list.vue.d.ts +3 -0
  172. package/dist/runtime/table/components/filters/shared/filter-option-multiple-list.vue +1 -1
  173. package/dist/runtime/table/components/filters/shared/filter-option-picker-content.vue +13 -0
  174. package/dist/runtime/table/components/filters/shared/filter-option-single-list.d.vue.ts +2 -0
  175. package/dist/runtime/table/components/filters/shared/filter-option-single-list.vue +1 -1
  176. package/dist/runtime/table/components/filters/shared/filter-option-single-list.vue.d.ts +2 -0
  177. package/dist/runtime/table/components/filters/shared/filter-option-tree-content.d.vue.ts +3 -0
  178. package/dist/runtime/table/components/filters/shared/filter-option-tree-content.vue +2 -2
  179. package/dist/runtime/table/components/filters/shared/filter-option-tree-content.vue.d.ts +3 -0
  180. package/dist/runtime/table/components/filters/shared/filter-searchable-panel.vue +1 -0
  181. package/dist/runtime/table/composables/use-option-filter-editor-state.d.ts +13 -1
  182. package/dist/runtime/table/composables/use-option-filter-editor-state.js +6 -2
  183. package/dist/runtime/table/composables/use-table-filter-options.d.ts +11 -1
  184. package/dist/runtime/table/composables/use-table-filter-options.js +128 -17
  185. package/dist/runtime/table/composables/use-table-filter-selected-options.d.ts +20 -0
  186. package/dist/runtime/table/composables/use-table-filter-selected-options.js +99 -0
  187. package/dist/runtime/table/composables/use-table-filters.d.ts +5 -0
  188. package/dist/runtime/table/composables/use-table-filters.js +20 -1
  189. package/dist/runtime/table/composables/use-table-internals.d.ts +15 -0
  190. package/dist/runtime/table/composables/use-table-remote-filter-options.d.ts +42 -0
  191. package/dist/runtime/table/composables/use-table-remote-filter-options.js +102 -0
  192. package/dist/runtime/table/types/filters.d.ts +42 -0
  193. package/dist/runtime/table/types/index.d.ts +1 -0
  194. package/dist/runtime/table/types/remote-options.d.ts +64 -0
  195. package/dist/runtime/table/types/remote-options.js +0 -0
  196. package/dist/runtime/table/types/source.d.ts +15 -1
  197. package/dist/runtime/table/utils/builders/table-source.d.ts +2 -6
  198. package/dist/runtime/table/utils/filters/options.d.ts +2 -0
  199. package/dist/runtime/table/utils/filters/options.js +1 -1
  200. package/dist/runtime/table/utils/index.d.ts +1 -0
  201. package/dist/runtime/table/utils/index.js +1 -0
  202. package/dist/runtime/table/utils/prefetch.js +21 -1
  203. package/dist/runtime/table/utils/remote-table-options.d.ts +26 -0
  204. package/dist/runtime/table/utils/remote-table-options.js +88 -0
  205. package/package.json +4 -1
  206. package/dist/runtime/dashboard/composables/use-dashboard-param-scope.d.ts +0 -30
  207. package/dist/runtime/dashboard/composables/use-dashboard-param-scope.js +0 -71
  208. package/dist/runtime/dashboard/types/options.d.ts +0 -46
  209. package/dist/runtime/dashboard/types/params.d.ts +0 -115
  210. package/dist/runtime/dashboard/utils/builders/dashboard-params.d.ts +0 -85
  211. package/dist/runtime/dashboard/utils/builders/dashboard-params.js +0 -87
  212. /package/dist/runtime/dashboard/types/{options.js → controls.js} +0 -0
  213. /package/dist/runtime/dashboard/types/{params.js → filters.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  import type { QueryKey } from '@tanstack/vue-query';
2
- import type { DashboardOptionsHandles } from './options.js';
3
- import type { DashboardEmptyMap, DashboardParamBuilder, DashboardParamMap, DashboardParamValues } from './params.js';
2
+ import type { DashboardFilterControls } from './controls.js';
3
+ import type { DashboardEmptyMap, DashboardFilterMap, DashboardFilterValues, DashboardFiltersInput } from './filters.js';
4
4
  import type { DashboardKeyError } from './schema.js';
5
5
  /**
6
6
  * Fetch stage of a query.
@@ -11,7 +11,18 @@ import type { DashboardKeyError } from './schema.js';
11
11
  * scroll into view).
12
12
  */
13
13
  export type DashboardStage = 'essential' | 'background' | 'deferred';
14
- export type DashboardResourceState = 'idle' | 'loading' | 'ready' | 'error';
14
+ /**
15
+ * - `idle`: not requested yet (a deferred query nobody activated, an unopened view).
16
+ * - `loading` / `ready` / `error`: the fetch lifecycle.
17
+ * - `disabled`: an `enabled` condition does not hold (its own, or its view's). The resource never
18
+ * fetches and holds its `defaultValue`; blocks bound to it render nothing.
19
+ */
20
+ export type DashboardResourceState = 'idle' | 'loading' | 'ready' | 'error' | 'disabled';
21
+ /**
22
+ * Whether a view, query, or filter is part of the dashboard right now, read lazily and reactively:
23
+ * what the schema function knows (the audience), another filter, data.
24
+ */
25
+ export type DashboardCondition = () => boolean;
15
26
  /**
16
27
  * Contract every block binds to through `:source`. Query resources and derived resources both
17
28
  * satisfy it. Every member is a plain value read through a getter — there is no `.value`.
@@ -24,6 +35,13 @@ export interface DashboardSourceLike<TData = unknown> {
24
35
  readonly error: unknown;
25
36
  /** A background refetch is running while `state` is still `'ready'`. */
26
37
  readonly refreshing: boolean;
38
+ /**
39
+ * A request for this source is in flight, whatever its state: the first load, a refetch of shown
40
+ * data, or a retry after an error (TanStack keeps an errored query in `error` while it refetches).
41
+ * Blocks draw their progress bar from it. Optional so hand-written sources keep fitting; blocks
42
+ * fall back to `refreshing`.
43
+ */
44
+ readonly fetching?: boolean;
27
45
  /**
28
46
  * When the data was last fetched successfully (epoch milliseconds). `undefined` until the first
29
47
  * success. A derived value reports its oldest input.
@@ -34,19 +52,21 @@ export interface DashboardSourceLike<TData = unknown> {
34
52
  refresh(): Promise<void>;
35
53
  }
36
54
  /** A declared query, as exposed on the dashboard facade. */
37
- export interface DashboardResource<TData, TParams extends DashboardParamMap = DashboardEmptyMap, TStage extends DashboardStage = DashboardStage> extends DashboardSourceLike<TData> {
55
+ export interface DashboardResource<TData, TFilters extends DashboardFilterMap = DashboardEmptyMap, TStage extends DashboardStage = DashboardStage> extends DashboardSourceLike<TData> {
38
56
  readonly kind: 'query';
57
+ readonly fetching: boolean;
39
58
  readonly stage: TStage;
40
59
  /** `false` while the owning view has never been opened or a `deferred` query was not activated. */
41
60
  readonly active: boolean;
42
- /** Widget-scoped params, URL-synced under this resource's key. */
43
- readonly params: DashboardParamValues<TParams>;
44
- /** Option handles for option-backed widget params. */
45
- readonly options: DashboardOptionsHandles<TParams>;
61
+ /** Values of the filters declared on this query, URL-synced under the query key. */
62
+ readonly filters: DashboardFilterValues<TFilters>;
63
+ /** Controls of the same filters: bind them to a chart's `series`, `UiDashboardFilter`, or any control. */
64
+ readonly controls: DashboardFilterControls<TFilters>;
46
65
  }
47
66
  /** A value declared in `derive`, exposed as a resource whose state follows the data it reads. */
48
67
  export interface DashboardDerived<TData> extends DashboardSourceLike<TData> {
49
68
  readonly kind: 'derived';
69
+ readonly fetching: boolean;
50
70
  }
51
71
  export type DashboardSourceMap = Record<string, DashboardSourceLike>;
52
72
  /** Data of a source once it is `ready` (`undefined` is excluded, `null` is kept). */
@@ -62,25 +82,42 @@ export type DashboardQueryData<TQuery> = TQuery extends {
62
82
  queryFn?: infer TFn;
63
83
  } ? TFn extends (...args: never[]) => infer TResult ? Awaited<TResult> : never : never;
64
84
  /** Scope handed to the configured query factory. */
65
- export interface DashboardQueryScope<TParams extends DashboardParamMap, TRequired> {
66
- /** Widget-scoped params declared on this query. */
67
- params: Readonly<DashboardParamValues<TParams>>;
85
+ export interface DashboardQueryScope<TFilters extends DashboardFilterMap, TRequired> {
86
+ /** Values of the filters declared on this query. */
87
+ filters: Readonly<DashboardFilterValues<TFilters>>;
68
88
  /** Non-nullish value returned by `requires`. */
69
89
  required: NonNullable<TRequired>;
70
90
  }
71
- export interface DashboardQueryInput<TQuery extends DashboardQueryLike, TParams extends DashboardParamMap, TRequired> {
72
- /** Widget-scoped params, URL-synced under `<scope>.<queryKey>.<param>`. */
73
- params?: (p: DashboardParamBuilder) => TParams;
91
+ export interface DashboardQueryInput<TQuery extends DashboardQueryLike, TFilters extends DashboardFilterMap, TRequired, TSelected> {
92
+ /**
93
+ * Filters of this query only, e.g. the products a chart tracks, URL-synced under
94
+ * `<queryKey>.<filter>`. Their controls drive the block bound to the query.
95
+ */
96
+ filters?: DashboardFiltersInput<TFilters>;
74
97
  /**
75
- * Gate and narrow. While it returns `null` or `undefined`, the resource stays `idle` and never
76
- * fetches; once set, `scope.required` is the non-nullish value. Reading another resource's
77
- * `data` here expresses a dependent query.
98
+ * Gate and narrow. While it returns `null` or `undefined` the query does not fetch; once set,
99
+ * `scope.required` is the non-nullish value. Reading another resource's `data` here expresses a
100
+ * dependent query: the resource is `loading` while the resources it read load, and once they
101
+ * are ready without satisfying it, `ready` with its `defaultValue` (`idle` without one).
78
102
  */
79
103
  requires?: () => TRequired;
80
- /** Extra boolean gate, combined with `requires` and with stage activation. */
81
- enabled?: () => boolean;
82
- /** Reactive query factory returning a TanStack query definition. */
83
- query: (scope: DashboardQueryScope<NoInfer<TParams>, NoInfer<TRequired>>) => TQuery;
104
+ /**
105
+ * Whether the query exists for the current dashboard state, e.g. a section this workspace may
106
+ * not see. While it is `false` the query never fetches, its state is `disabled` and its data its
107
+ * `defaultValue`, and every block bound to it renders nothing (grids close the gap). To wait for
108
+ * data instead, use `requires`.
109
+ */
110
+ enabled?: DashboardCondition;
111
+ /**
112
+ * Reactive query factory returning a TanStack query definition. Several resources may share one
113
+ * factory: they share its request and cache entry, and each `select`s its own part.
114
+ */
115
+ query: (scope: DashboardQueryScope<NoInfer<TFilters>, NoInfer<TRequired>>) => TQuery;
116
+ /**
117
+ * Picks or reshapes the part of the query result this resource exposes. The cached result stays
118
+ * whole, so resources selecting from the same query never refetch it.
119
+ */
120
+ select?: (data: DashboardQueryData<TQuery>) => TSelected;
84
121
  /** Keep previous data while a new key loads. Defaults to `true`. */
85
122
  keepPreviousData?: boolean;
86
123
  staleTime?: number;
@@ -91,16 +128,17 @@ export interface DashboardQueryInput<TQuery extends DashboardQueryLike, TParams
91
128
  export interface DashboardQueryStage<TStage extends DashboardStage> {
92
129
  /** Plain query. `data` is `T | undefined`. */
93
130
  query<TQuery extends DashboardQueryLike>(factory: () => TQuery): DashboardResource<DashboardQueryData<TQuery> | undefined, DashboardEmptyMap, TStage>;
94
- /** Configured query without a default. `data` is `T | undefined`. */
95
- query<TQuery extends DashboardQueryLike, const TParams extends DashboardParamMap = DashboardEmptyMap, TRequired = undefined>(input: DashboardQueryInput<TQuery, TParams, TRequired> & {
131
+ /** Configured query without a default. `data` is `T | undefined` (`T`: the `select` result). */
132
+ query<TQuery extends DashboardQueryLike, const TFilters extends DashboardFilterMap = DashboardEmptyMap, TRequired = undefined, TSelected = DashboardQueryData<TQuery>>(input: DashboardQueryInput<TQuery, TFilters, TRequired, TSelected> & {
96
133
  defaultValue?: undefined;
97
- }): DashboardResource<DashboardQueryData<TQuery> | undefined, TParams, TStage>;
134
+ }): DashboardResource<NoInfer<TSelected> | undefined, TFilters, TStage>;
98
135
  /**
99
136
  * Configured query with a default. `data` is always defined. The default is inferred on its own
100
- * (so property order inside the object does not matter) and checked against the query result: a
101
- * mismatching default turns the resource into a `DashboardKeyError`, rejected by `queries`.
137
+ * (so property order inside the object does not matter) and checked against the query result (or
138
+ * the `select` result): a mismatching default turns the resource into a `DashboardKeyError`,
139
+ * rejected by `queries`.
102
140
  */
103
- query<TQuery extends DashboardQueryLike, const TParams extends DashboardParamMap = DashboardEmptyMap, TRequired = undefined, TDefault = never>(input: DashboardQueryInput<TQuery, TParams, TRequired> & {
141
+ query<TQuery extends DashboardQueryLike, const TFilters extends DashboardFilterMap = DashboardEmptyMap, TRequired = undefined, TSelected = DashboardQueryData<TQuery>, TDefault = never>(input: DashboardQueryInput<TQuery, TFilters, TRequired, TSelected> & {
104
142
  defaultValue: TDefault;
105
- }): [TDefault] extends [DashboardQueryData<TQuery>] ? DashboardResource<DashboardQueryData<TQuery>, TParams, TStage> : DashboardKeyError<'defaultValue is not assignable to the query data type.'>;
143
+ }): [TDefault] extends [NoInfer<TSelected>] ? DashboardResource<NoInfer<TSelected>, TFilters, TStage> : DashboardKeyError<'defaultValue is not assignable to the query data type.'>;
106
144
  }
@@ -1,19 +1,23 @@
1
+ import type { ComputedRef, Ref } from 'vue';
1
2
  import type { QueryDefinition } from '../../shared/types/query.js';
2
3
  import type { LazyTextValue } from '../../shared/types/utils.js';
3
- import type { DashboardParamBuilder, DashboardParamMap } from './params.js';
4
- import type { DashboardSourceLike, DashboardStage } from './resource.js';
4
+ import type { DashboardOptionsMenuBindings } from './controls.js';
5
+ import type { DashboardFilterBuilder, DashboardFilterLike, DashboardOption } from './filters.js';
6
+ import type { DashboardCondition, DashboardSourceLike, DashboardStage } from './resource.js';
5
7
  /**
6
8
  * Runtime (type-erased) view of the schema. The public schema types carry precise generics; the
7
9
  * runtime reads the same objects through these shapes after one normalization step.
8
10
  */
11
+ export type DashboardRuntimeFiltersInput = (f: DashboardFilterBuilder) => Record<string, DashboardFilterLike>;
9
12
  export interface DashboardRuntimeQueryInput {
10
- params?: (p: DashboardParamBuilder) => DashboardParamMap;
13
+ filters?: DashboardRuntimeFiltersInput;
11
14
  requires?: () => unknown;
12
- enabled?: () => boolean;
15
+ enabled?: DashboardCondition;
13
16
  query: (scope: {
14
- params: object;
17
+ filters: object;
15
18
  required: unknown;
16
19
  }) => QueryDefinition;
20
+ select?: (data: unknown) => unknown;
17
21
  defaultValue?: unknown;
18
22
  keepPreviousData?: boolean;
19
23
  staleTime?: number;
@@ -23,15 +27,17 @@ export interface DashboardRuntimeStage {
23
27
  }
24
28
  export type DashboardRuntimeStages = Record<DashboardStage, DashboardRuntimeStage>;
25
29
  export interface DashboardRuntimeQueriesContext extends DashboardRuntimeStages {
26
- params: object;
30
+ filters: object;
27
31
  }
28
32
  export interface DashboardRuntimeDeriveContext {
29
33
  data: object;
30
- params: object;
34
+ filters: object;
31
35
  }
32
36
  export interface DashboardRuntimeScopeInput {
33
37
  label?: LazyTextValue;
34
- params?: (p: DashboardParamBuilder) => DashboardParamMap;
38
+ /** Availability of a view. */
39
+ enabled?: DashboardCondition;
40
+ filters?: DashboardRuntimeFiltersInput;
35
41
  queries?: (context: DashboardRuntimeQueriesContext) => Record<string, DashboardSourceLike>;
36
42
  derive?: (context: DashboardRuntimeDeriveContext) => Record<string, () => unknown>;
37
43
  }
@@ -40,5 +46,30 @@ export interface DashboardRuntimeSchema extends DashboardRuntimeScopeInput {
40
46
  urlPrefix?: string;
41
47
  autoRefresh?: number;
42
48
  defaultView?: string;
49
+ /** Views in declaration order. Each input is the object the schema declared. */
43
50
  views: [key: string, view: DashboardRuntimeScopeInput][];
44
51
  }
52
+ /**
53
+ * Option list behind one filter control, static or remote. Both option composables return this
54
+ * shape so the control composes either without branching.
55
+ */
56
+ export interface DashboardRuntimeOptionList {
57
+ /** Options matching the current search. */
58
+ items: ComputedRef<readonly DashboardOption[]>;
59
+ /** Every option known so far (all static items; loaded pages and hydrated values), by value key. */
60
+ known: ComputedRef<ReadonlyMap<string, DashboardOption>>;
61
+ /** Position of each static option, used to keep multiple values in item order. */
62
+ order: ComputedRef<ReadonlyMap<string, number> | null>;
63
+ loading: ComputedRef<boolean>;
64
+ loadingMore: ComputedRef<boolean>;
65
+ hasMore: ComputedRef<boolean>;
66
+ error: ComputedRef<unknown>;
67
+ /** Labels of selected values are being fetched. */
68
+ resolving: ComputedRef<boolean>;
69
+ search: Ref<string>;
70
+ open: Ref<boolean>;
71
+ loadMore: () => void;
72
+ refresh: () => Promise<void>;
73
+ /** Menu bindings beyond items and keys (search wiring of remote lists). */
74
+ menu: ComputedRef<Partial<DashboardOptionsMenuBindings>>;
75
+ }
@@ -1,44 +1,47 @@
1
1
  import type { LazyTextValue, Prettify } from '../../shared/types/utils.js';
2
- import type { DashboardOptionsHandles } from './options.js';
3
- import type { DashboardEmptyMap, DashboardParamBuilder, DashboardParamMap, DashboardParamValues } from './params.js';
4
- import type { DashboardDerived, DashboardQueryStage, DashboardResourceState, DashboardSourceLike, DashboardSourceMap } from './resource.js';
2
+ import type { DashboardFilterControls } from './controls.js';
3
+ import type { DashboardEmptyMap, DashboardFilterBuilder, DashboardFilterLike, DashboardFilterMap, DashboardFiltersInput, DashboardFilterValues } from './filters.js';
4
+ import type { DashboardCondition, DashboardDerived, DashboardQueryStage, DashboardResourceState, DashboardSourceLike, DashboardSourceMap } from './resource.js';
5
5
  /** `derive` entries: each one is a function evaluated reactively into a derived resource. */
6
6
  export type DashboardDeriveMap = Record<string, () => unknown>;
7
7
  /** Context received by a scope's `queries` builder. */
8
- export interface DashboardQueriesContext<TParams> {
8
+ export interface DashboardQueriesContext<TFilters> {
9
9
  essential: DashboardQueryStage<'essential'>;
10
10
  background: DashboardQueryStage<'background'>;
11
11
  deferred: DashboardQueryStage<'deferred'>;
12
- /** Params visible to this scope (shared params plus the view's own params). */
13
- params: Readonly<DashboardParamValues<TParams>>;
12
+ /** Values of the scope's filters. */
13
+ filters: Readonly<DashboardFilterValues<TFilters>>;
14
14
  }
15
15
  /** `data` of every source a `derive` builder can read. */
16
16
  export type DashboardSourceData<TSources> = {
17
17
  readonly [K in keyof TSources]: TSources[K] extends DashboardSourceLike<infer TData> ? TData : never;
18
18
  };
19
19
  /** Context received by a scope's `derive` builder. */
20
- export interface DashboardDeriveContext<TParams, TSources> {
20
+ export interface DashboardDeriveContext<TFilters, TSources> {
21
21
  /**
22
- * Current data of every query visible to this scope. Reads are tracked: a derived value's
23
- * `state` follows the state of the queries it actually read during its last evaluation.
22
+ * Current data of every query of this scope. Reads are tracked: a derived value's `state` follows
23
+ * the state of the queries it actually read during its last evaluation.
24
24
  */
25
25
  data: DashboardSourceData<TSources>;
26
- params: Readonly<DashboardParamValues<TParams>>;
26
+ filters: Readonly<DashboardFilterValues<TFilters>>;
27
27
  }
28
28
  export type DashboardDerivedResources<TDerive> = {
29
29
  readonly [K in keyof TDerive]: TDerive[K] extends () => infer TResult ? DashboardDerived<TResult> : never;
30
30
  };
31
- /** Params, queries and derived values of one scope (the dashboard root or one view). */
32
- export interface DashboardScopeInput<TShared extends DashboardParamMap, TVisibleSources, TParams extends DashboardParamMap, TQueries extends DashboardSourceMap, TDerive extends DashboardDeriveMap> {
33
- /** Typed, URL-synced params owned by this scope. */
34
- params?: (p: DashboardParamBuilder) => TParams;
35
- /** Staged queries owned by this scope. Declared once, when `useDashboard()` runs. */
36
- queries?: (context: DashboardQueriesContext<TShared & TParams>) => TQueries;
31
+ /** Filters, queries and derived values of one scope (the dashboard root or one view). */
32
+ export interface DashboardScopeInput<TFilters extends DashboardFilterMap, TQueries extends DashboardSourceMap, TDerive extends DashboardDeriveMap> {
33
+ /**
34
+ * Filters of this scope, declared inline with the `f` builder. A filter key names one state across
35
+ * the dashboard: two views declaring `year` share its value, so it survives a tab change.
36
+ */
37
+ filters?: DashboardFiltersInput<TFilters>;
38
+ /** Staged queries of this scope. Declared once, when `useDashboard()` runs. */
39
+ queries?: (context: DashboardQueriesContext<TFilters>) => TQueries;
37
40
  /** Derived values computed from query data, exposed as resources with automatic state. */
38
- derive?: (context: DashboardDeriveContext<TShared & TParams, TVisibleSources & TQueries>) => TDerive;
41
+ derive?: (context: DashboardDeriveContext<TFilters, TQueries>) => TDerive;
39
42
  }
40
43
  /** Names owned by the runtime on the dashboard root and on every view handle. */
41
- export type DashboardReservedKey = 'params' | 'options' | 'state' | 'refreshing' | 'refresh' | 'updatedAt' | 'autoRefresh' | 'view' | 'schema';
44
+ export type DashboardReservedKey = 'filters' | 'controls' | 'filtered' | 'resetFilters' | 'state' | 'refreshing' | 'refresh' | 'updatedAt' | 'autoRefresh' | 'view' | 'schema';
42
45
  declare const DashboardKeyErrorBrand: unique symbol;
43
46
  /** Unsatisfiable type. Its hover text is the error message the consumer reads. */
44
47
  export interface DashboardKeyError<TMessage extends string> {
@@ -49,40 +52,31 @@ type Guard<TSlot extends string, TBad, TMessage extends string> = [TBad] extends
49
52
  };
50
53
  /** Compile-time collision checks for one scope's queries and derived values. */
51
54
  export type DashboardScopeGuard<TQueries, TDerive, TTaken = never> = Guard<'queries', Extract<keyof TQueries, DashboardReservedKey | TTaken>, `Query key "${Extract<keyof TQueries, DashboardReservedKey | TTaken> & string}" is reserved or already used.`> & Guard<'derive', Extract<keyof TDerive, DashboardReservedKey | TTaken | keyof TQueries>, `Derived key "${Extract<keyof TDerive, DashboardReservedKey | TTaken | keyof TQueries> & string}" is reserved or already used.`>;
52
- /** A view declared through the `view(...)` builder. */
53
- export interface DashboardView<TParams extends DashboardParamMap, TQueries extends DashboardSourceMap, TDerive extends DashboardDeriveMap> {
55
+ /** A view (tab): its label, its own filters, queries and derived values. */
56
+ export interface DashboardView<TFilters extends DashboardFilterMap, TQueries extends DashboardSourceMap, TDerive extends DashboardDeriveMap> {
54
57
  /** Tab label. The lazy form keeps it translation-friendly. */
55
58
  readonly label?: LazyTextValue;
56
- readonly params?: (p: DashboardParamBuilder) => TParams;
59
+ /** Availability of the view (see `defineDashboardView`). */
60
+ readonly enabled?: DashboardCondition;
61
+ readonly filters?: (f: DashboardFilterBuilder) => TFilters;
57
62
  readonly queries?: (context: never) => TQueries;
58
63
  readonly derive?: (context: never) => TDerive;
59
64
  }
60
- export type DashboardViewMap = Record<string, DashboardView<DashboardParamMap, DashboardSourceMap, DashboardDeriveMap>>;
61
- type DashboardViewResult<TParams extends DashboardParamMap, TQueries extends DashboardSourceMap, TDerive extends DashboardDeriveMap, TRootSources> = [Extract<keyof TQueries | keyof TDerive, DashboardReservedKey | keyof TRootSources>] extends [
62
- never
63
- ] ? [Extract<keyof TDerive, keyof TQueries>] extends [never] ? DashboardView<TParams, TQueries, TDerive> : DashboardKeyError<`Derived key "${Extract<keyof TDerive, keyof TQueries> & string}" collides with a query of the same view.`> : DashboardKeyError<`View member "${Extract<keyof TQueries | keyof TDerive, DashboardReservedKey | keyof TRootSources> & string}" is reserved or collides with a root query or derived value.`>;
64
- /**
65
- * Declares one view. Its queries see the shared params plus its own, and its `derive` can read root
66
- * queries and derived values as well as its own queries.
67
- *
68
- * The result is `NoInfer`: otherwise the contextual `DashboardViewMap` would become an inference
69
- * candidate, and a view without queries would infer `TQueries` as the open constraint.
70
- */
71
- export type DashboardViewBuilder<TShared extends DashboardParamMap, TRootSources> = <const TParams extends DashboardParamMap = DashboardEmptyMap, const TQueries extends DashboardSourceMap = DashboardEmptyMap, const TDerive extends DashboardDeriveMap = DashboardEmptyMap>(view: {
72
- label?: LazyTextValue;
73
- } & DashboardScopeInput<TShared, TRootSources, TParams, TQueries, TDerive>) => DashboardViewResult<NoInfer<TParams>, NoInfer<TQueries>, NoInfer<TDerive>, TRootSources>;
65
+ /** Loosest filters input, for structural constraints. */
66
+ type DashboardFiltersLike = (f: DashboardFilterBuilder) => Record<string, DashboardFilterLike>;
67
+ export type DashboardViewMap = Record<string, DashboardView<DashboardFilterMap, DashboardSourceMap, DashboardDeriveMap>>;
74
68
  /** Resolved dashboard schema returned by `defineDashboardSchema`. */
75
- export interface DashboardSchema<TParams extends DashboardParamMap = DashboardEmptyMap, TQueries extends DashboardSourceMap = DashboardEmptyMap, TDerive extends DashboardDeriveMap = DashboardEmptyMap, TViews extends DashboardViewMap = DashboardEmptyMap> {
69
+ export interface DashboardSchema<TFilters extends DashboardFilterMap = DashboardEmptyMap, TQueries extends DashboardSourceMap = DashboardEmptyMap, TDerive extends DashboardDeriveMap = DashboardEmptyMap, TViews extends DashboardViewMap = DashboardEmptyMap> {
76
70
  /** Stable identity, used in default query keys and devtools labels. */
77
71
  readonly key: string;
78
72
  /** Prefix prepended to every URL key this dashboard owns. Use it when two dashboards share a page. */
79
73
  readonly urlPrefix?: string;
80
74
  /** Default auto-refresh interval in seconds (`0`: off). */
81
75
  readonly autoRefresh?: number;
82
- readonly params?: (p: DashboardParamBuilder) => TParams;
76
+ readonly filters?: (f: DashboardFilterBuilder) => TFilters;
83
77
  readonly queries?: (context: never) => TQueries;
84
78
  readonly derive?: (context: never) => TDerive;
85
- readonly views?: (view: never) => TViews;
79
+ readonly views?: TViews;
86
80
  readonly defaultView?: keyof TViews & string;
87
81
  }
88
82
  /** Structural constraint every schema returned by `defineDashboardSchema` satisfies. */
@@ -90,15 +84,34 @@ export interface DashboardSchemaLike {
90
84
  readonly key: string;
91
85
  readonly urlPrefix?: string;
92
86
  readonly autoRefresh?: number;
93
- readonly params?: (p: DashboardParamBuilder) => DashboardParamMap;
87
+ readonly filters?: DashboardFiltersLike;
94
88
  readonly queries?: (context: never) => DashboardSourceMap;
95
89
  readonly derive?: (context: never) => DashboardDeriveMap;
96
- readonly views?: (view: never) => DashboardViewMap;
90
+ readonly views?: DashboardViewMap;
97
91
  readonly defaultView?: string;
98
92
  }
99
- type InferParams<T> = T extends {
100
- params?: (p: never) => infer TParams;
101
- } ? TParams extends DashboardParamMap ? TParams : DashboardEmptyMap : DashboardEmptyMap;
93
+ /** Structural constraint every view returned by `defineDashboardView` satisfies. */
94
+ export interface DashboardViewLike {
95
+ readonly label?: LazyTextValue;
96
+ readonly enabled?: DashboardCondition;
97
+ readonly filters?: DashboardFiltersLike;
98
+ readonly queries?: (context: never) => DashboardSourceMap;
99
+ readonly derive?: (context: never) => DashboardDeriveMap;
100
+ }
101
+ /**
102
+ * A schema, or a function returning one: `salesSchema`, `accountSchema` (which takes the account),
103
+ * `() => accountSchema({ accountId })`.
104
+ */
105
+ export type DashboardSchemaInput = DashboardSchemaLike | ((...args: never[]) => DashboardSchemaLike);
106
+ /** The schema a `DashboardSchemaInput` describes: the object, or what the function returns. */
107
+ export type DashboardSchemaOf<TInput> = TInput extends (...args: never[]) => infer TSchema ? TSchema : TInput;
108
+ /** A view, or a function returning one: `consumptionView` (which takes the workspace). */
109
+ export type DashboardViewInput = DashboardViewLike | ((...args: never[]) => DashboardViewLike);
110
+ /** The view a `DashboardViewInput` describes: the object, or what the function returns. */
111
+ export type DashboardViewOf<TInput> = TInput extends (...args: never[]) => infer TView ? TView : TInput;
112
+ type InferFilters<T> = T extends {
113
+ filters?: (f: never) => infer TFilters;
114
+ } ? TFilters extends DashboardFilterMap ? TFilters : DashboardEmptyMap : DashboardEmptyMap;
102
115
  type InferQueries<T> = T extends {
103
116
  queries?: (context: never) => infer TQueries;
104
117
  } ? TQueries extends DashboardSourceMap ? TQueries : DashboardEmptyMap : DashboardEmptyMap;
@@ -106,14 +119,24 @@ type InferDerive<T> = T extends {
106
119
  derive?: (context: never) => infer TDerive;
107
120
  } ? TDerive extends DashboardDeriveMap ? TDerive : DashboardEmptyMap : DashboardEmptyMap;
108
121
  type InferViews<T> = T extends {
109
- views?: (view: never) => infer TViews;
110
- } ? TViews extends DashboardViewMap ? TViews : DashboardEmptyMap : DashboardEmptyMap;
122
+ views?: infer TViews;
123
+ } ? Exclude<TViews, undefined> extends DashboardViewMap ? Exclude<TViews, undefined> : DashboardEmptyMap : DashboardEmptyMap;
111
124
  /** Runtime members shared by the dashboard root and every view handle. */
112
- export interface DashboardScopeMembers<TParams> {
113
- /** Params owned by this scope. Writable, URL-synced, `v-model`-ready. */
114
- readonly params: DashboardParamValues<TParams>;
115
- /** Option handles of this scope's option-backed params. */
116
- readonly options: DashboardOptionsHandles<TParams>;
125
+ export interface DashboardScopeMembers<TFilters> {
126
+ /** Values of the scope's filters. Writable, `v-model`-ready: `consumption.filters.year`. */
127
+ readonly filters: DashboardFilterValues<TFilters>;
128
+ /**
129
+ * Controls of the same filters: label, display text, option list, and the `toggle` / `reset`
130
+ * actions. Bind them to `UiDashboardFilter`, a chart's `series`, or any control.
131
+ */
132
+ readonly controls: DashboardFilterControls<TFilters>;
133
+ /**
134
+ * A filter on screen differs from its default: the root's and the current view's for the
135
+ * dashboard, the view's own for a view handle. Headless filters are ignored.
136
+ */
137
+ readonly filtered: boolean;
138
+ /** Restores the default of every filter `filtered` considers. */
139
+ resetFilters(): void;
117
140
  /**
118
141
  * `idle` while the scope has never been active, `error` if an active essential query failed,
119
142
  * `loading` while essentials load, `ready` once they all succeeded.
@@ -134,19 +157,26 @@ export interface DashboardViewMeta<TKey extends string> {
134
157
  readonly label: string;
135
158
  /** The view is the current one. */
136
159
  readonly active: boolean;
160
+ /** The view's `enabled` condition holds. A disabled view has no tab and cannot be current. */
161
+ readonly enabled: boolean;
137
162
  /** The view has been opened at least once; its queries stay warm afterwards. */
138
163
  readonly opened: boolean;
139
164
  }
140
165
  export interface DashboardViewController<TKey extends string> {
141
- /** Current view. Writable and URL-synced under `view`. */
166
+ /**
167
+ * Current view. Writable and URL-synced under `view`. Always an enabled view: a URL naming a
168
+ * disabled one reads as the default view (or the first enabled), and writing a disabled view is
169
+ * ignored.
170
+ */
142
171
  current: TKey;
143
- /** Ordered view descriptors, ready for `UTabs` items. */
172
+ /** Enabled views in declaration order, ready for `UTabs` items. */
144
173
  readonly items: readonly {
145
174
  value: TKey;
146
175
  label: string;
147
176
  }[];
148
177
  }
149
- export type DashboardViewHandle<TView, TKey extends string> = Prettify<InferQueries<TView> & DashboardDerivedResources<InferDerive<TView>> & DashboardScopeMembers<InferParams<TView>> & {
178
+ /** Handle of one view: its queries, derived values and filters (`consumption.filters.year`). */
179
+ export type DashboardViewHandle<TView, TKey extends string> = Prettify<InferQueries<TView> & DashboardDerivedResources<InferDerive<TView>> & DashboardScopeMembers<InferFilters<TView>> & {
150
180
  readonly view: DashboardViewMeta<TKey>;
151
181
  }>;
152
182
  type DashboardViewHandles<TViews> = {
@@ -165,7 +195,17 @@ type DashboardRootViewMembers<TViews> = [keyof TViews] extends [never] ? unknown
165
195
  readonly view: DashboardViewController<keyof TViews & string>;
166
196
  };
167
197
  /** Facade returned by `useDashboard(schema)`. */
168
- export type DashboardApi<TSchema> = Prettify<InferQueries<TSchema> & DashboardDerivedResources<InferDerive<TSchema>> & DashboardViewHandles<InferViews<TSchema>> & DashboardScopeMembers<InferParams<TSchema>> & DashboardRootMembers & DashboardRootViewMembers<InferViews<TSchema>> & {
198
+ export type DashboardApi<TSchema> = Prettify<InferQueries<TSchema> & DashboardDerivedResources<InferDerive<TSchema>> & DashboardViewHandles<InferViews<TSchema>> & DashboardScopeMembers<InferFilters<TSchema>> & DashboardRootMembers & DashboardRootViewMembers<InferViews<TSchema>> & {
169
199
  readonly schema: TSchema;
170
200
  }>;
201
+ /**
202
+ * Type of the dashboard `useDashboard` returns, for props and helpers:
203
+ * `InferDashboard<typeof accountSchema>` (a schema function) or `InferDashboard<typeof salesSchema>`.
204
+ */
205
+ export type InferDashboard<TInput> = DashboardApi<DashboardSchemaOf<TInput>>;
206
+ /**
207
+ * Type of the handle `useDashboardView` returns: `InferDashboardView<typeof consumptionView>` (a
208
+ * view function) or the type of a view object.
209
+ */
210
+ export type InferDashboardView<TInput> = DashboardViewHandle<DashboardViewOf<TInput>, string>;
171
211
  export {};
@@ -165,6 +165,79 @@ export interface DashboardStateUi {
165
165
  title?: string;
166
166
  description?: string;
167
167
  }
168
+ /** Classes of `UiDashboardFilter`: the pill, its menu, and the `button` variant. */
169
+ export interface DashboardFilterUi {
170
+ /** Pill around the trigger and the clear button. Carries `data-active` once the filter filters. */
171
+ root?: string;
172
+ trigger?: string;
173
+ /** Filter name, before the value. */
174
+ label?: string;
175
+ value?: string;
176
+ chevron?: string;
177
+ /** Clear button of an active pill. */
178
+ clear?: string;
179
+ /** Trigger of `variant="button"`. */
180
+ button?: string;
181
+ /** Popover panel. */
182
+ content?: string;
183
+ /** Heading of the panel (`variant="button"`). */
184
+ title?: string;
185
+ search?: string;
186
+ list?: string;
187
+ item?: string;
188
+ /** Checkbox of multiple filters. */
189
+ check?: string;
190
+ /** Check mark of the selected item of single filters. */
191
+ tick?: string;
192
+ /** Initials tile of items with an `avatar`. */
193
+ avatar?: string;
194
+ /** Trailing text of items with a `hint`. */
195
+ hint?: string;
196
+ separator?: string;
197
+ /** "No results", loading, and error rows. */
198
+ note?: string;
199
+ }
200
+ /** Classes of `UiDashboardFilters`. */
201
+ export interface DashboardFiltersUi {
202
+ /** The bar: a row that scrolls sideways on narrow screens and wraps on large ones. */
203
+ root?: string;
204
+ reset?: string;
205
+ }
206
+ /**
207
+ * Classes of the chips a block draws in its toolbar: the series a filter picks on a chart, and the
208
+ * drill-down filters (`filters`) a block is narrowed by.
209
+ */
210
+ export interface DashboardChipsUi {
211
+ chip?: string;
212
+ /** Color square of a series chip. */
213
+ swatch?: string;
214
+ /** Filter name, before its value, on a filter chip. */
215
+ label?: string;
216
+ remove?: string;
217
+ }
218
+ /** Classes of `UiDashboardPage`. */
219
+ export interface DashboardPageUi {
220
+ /** The page, and its scroll container: the tabs and filters stick to its top. */
221
+ root?: string;
222
+ header?: string;
223
+ title?: string;
224
+ /** Today's date and when the data was fetched, under the title. */
225
+ description?: string;
226
+ /** Page actions and the refresh control. */
227
+ actions?: string;
228
+ /** Pinned band of the tabs and the filter bar. Carries `data-stuck` once content scrolls under it. */
229
+ toolbar?: string;
230
+ tabs?: string;
231
+ filters?: string;
232
+ /** Around the current view: its padding and the space between its grids. */
233
+ body?: string;
234
+ }
235
+ /** Classes of `UiDashboardViewTabs`. */
236
+ export interface DashboardViewTabsUi {
237
+ /** The strip: it scrolls sideways when the tabs overflow. */
238
+ root?: string;
239
+ tab?: string;
240
+ }
168
241
  /**
169
242
  * App-wide dashboard theming, read from `appConfig.nuxtUiTools.dashboard`.
170
243
  *
@@ -198,4 +271,9 @@ export interface DashboardUiConfig {
198
271
  feed?: DashboardFeedUi;
199
272
  table?: DashboardTableUi;
200
273
  state?: DashboardStateUi;
274
+ filter?: DashboardFilterUi;
275
+ filters?: DashboardFiltersUi;
276
+ viewTabs?: DashboardViewTabsUi;
277
+ page?: DashboardPageUi;
278
+ chips?: DashboardChipsUi;
201
279
  }