nuxt-ui-tools 1.0.1 → 1.1.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 (226) hide show
  1. package/dist/module.d.mts +3 -0
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +37 -0
  4. package/dist/runtime/dashboard/components/block/dashboard-block-state.d.vue.ts +12 -0
  5. package/dist/runtime/dashboard/components/block/dashboard-block-state.vue +59 -0
  6. package/dist/runtime/dashboard/components/block/dashboard-block-state.vue.d.ts +12 -0
  7. package/dist/runtime/dashboard/components/block/dashboard-data-table.d.vue.ts +9 -0
  8. package/dist/runtime/dashboard/components/block/dashboard-data-table.vue +47 -0
  9. package/dist/runtime/dashboard/components/block/dashboard-data-table.vue.d.ts +9 -0
  10. package/dist/runtime/dashboard/components/block/dashboard-ring.d.vue.ts +34 -0
  11. package/dist/runtime/dashboard/components/block/dashboard-ring.vue +91 -0
  12. package/dist/runtime/dashboard/components/block/dashboard-ring.vue.d.ts +34 -0
  13. package/dist/runtime/dashboard/components/block/dashboard-row-actions.d.vue.ts +13 -0
  14. package/dist/runtime/dashboard/components/block/dashboard-row-actions.vue +49 -0
  15. package/dist/runtime/dashboard/components/block/dashboard-row-actions.vue.d.ts +13 -0
  16. package/dist/runtime/dashboard/components/block/dashboard-skeleton.d.vue.ts +34 -0
  17. package/dist/runtime/dashboard/components/block/dashboard-skeleton.vue +312 -0
  18. package/dist/runtime/dashboard/components/block/dashboard-skeleton.vue.d.ts +34 -0
  19. package/dist/runtime/dashboard/components/charts/renderer.d.ts +43 -0
  20. package/dist/runtime/dashboard/components/charts/renderer.js +34 -0
  21. package/dist/runtime/dashboard/components/charts/unovis/dashboard-donut-chart.d.vue.ts +18 -0
  22. package/dist/runtime/dashboard/components/charts/unovis/dashboard-donut-chart.vue +45 -0
  23. package/dist/runtime/dashboard/components/charts/unovis/dashboard-donut-chart.vue.d.ts +18 -0
  24. package/dist/runtime/dashboard/components/charts/unovis/dashboard-xy-chart.d.vue.ts +14 -0
  25. package/dist/runtime/dashboard/components/charts/unovis/dashboard-xy-chart.vue +190 -0
  26. package/dist/runtime/dashboard/components/charts/unovis/dashboard-xy-chart.vue.d.ts +14 -0
  27. package/dist/runtime/dashboard/components/charts/unovis/dashboard-xy-marks.d.vue.ts +13 -0
  28. package/dist/runtime/dashboard/components/charts/unovis/dashboard-xy-marks.vue +72 -0
  29. package/dist/runtime/dashboard/components/charts/unovis/dashboard-xy-marks.vue.d.ts +13 -0
  30. package/dist/runtime/dashboard/components/charts/unovis/xy-layers.d.ts +43 -0
  31. package/dist/runtime/dashboard/components/charts/unovis/xy-layers.js +60 -0
  32. package/dist/runtime/dashboard/components/dashboard-alerts.d.vue.ts +49 -0
  33. package/dist/runtime/dashboard/components/dashboard-alerts.vue +226 -0
  34. package/dist/runtime/dashboard/components/dashboard-alerts.vue.d.ts +49 -0
  35. package/dist/runtime/dashboard/components/dashboard-bar-chart.d.vue.ts +53 -0
  36. package/dist/runtime/dashboard/components/dashboard-bar-chart.vue +131 -0
  37. package/dist/runtime/dashboard/components/dashboard-bar-chart.vue.d.ts +53 -0
  38. package/dist/runtime/dashboard/components/dashboard-bars.d.vue.ts +49 -0
  39. package/dist/runtime/dashboard/components/dashboard-bars.vue +187 -0
  40. package/dist/runtime/dashboard/components/dashboard-bars.vue.d.ts +49 -0
  41. package/dist/runtime/dashboard/components/dashboard-card.d.vue.ts +47 -0
  42. package/dist/runtime/dashboard/components/dashboard-card.vue +316 -0
  43. package/dist/runtime/dashboard/components/dashboard-card.vue.d.ts +47 -0
  44. package/dist/runtime/dashboard/components/dashboard-combo-chart.d.vue.ts +52 -0
  45. package/dist/runtime/dashboard/components/dashboard-combo-chart.vue +128 -0
  46. package/dist/runtime/dashboard/components/dashboard-combo-chart.vue.d.ts +52 -0
  47. package/dist/runtime/dashboard/components/dashboard-donut-chart.d.vue.ts +48 -0
  48. package/dist/runtime/dashboard/components/dashboard-donut-chart.vue +216 -0
  49. package/dist/runtime/dashboard/components/dashboard-donut-chart.vue.d.ts +48 -0
  50. package/dist/runtime/dashboard/components/dashboard-feed.d.vue.ts +49 -0
  51. package/dist/runtime/dashboard/components/dashboard-feed.vue +238 -0
  52. package/dist/runtime/dashboard/components/dashboard-feed.vue.d.ts +49 -0
  53. package/dist/runtime/dashboard/components/dashboard-funnel.d.vue.ts +34 -0
  54. package/dist/runtime/dashboard/components/dashboard-funnel.vue +157 -0
  55. package/dist/runtime/dashboard/components/dashboard-funnel.vue.d.ts +34 -0
  56. package/dist/runtime/dashboard/components/dashboard-gauge.d.vue.ts +55 -0
  57. package/dist/runtime/dashboard/components/dashboard-gauge.vue +177 -0
  58. package/dist/runtime/dashboard/components/dashboard-gauge.vue.d.ts +55 -0
  59. package/dist/runtime/dashboard/components/dashboard-grid.d.vue.ts +38 -0
  60. package/dist/runtime/dashboard/components/dashboard-grid.vue +49 -0
  61. package/dist/runtime/dashboard/components/dashboard-grid.vue.d.ts +38 -0
  62. package/dist/runtime/dashboard/components/dashboard-legend.d.vue.ts +8 -0
  63. package/dist/runtime/dashboard/components/dashboard-legend.vue +37 -0
  64. package/dist/runtime/dashboard/components/dashboard-legend.vue.d.ts +8 -0
  65. package/dist/runtime/dashboard/components/dashboard-line-chart.d.vue.ts +46 -0
  66. package/dist/runtime/dashboard/components/dashboard-line-chart.vue +129 -0
  67. package/dist/runtime/dashboard/components/dashboard-line-chart.vue.d.ts +46 -0
  68. package/dist/runtime/dashboard/components/dashboard-list.d.vue.ts +63 -0
  69. package/dist/runtime/dashboard/components/dashboard-list.vue +239 -0
  70. package/dist/runtime/dashboard/components/dashboard-list.vue.d.ts +63 -0
  71. package/dist/runtime/dashboard/components/dashboard-paired-bars.d.vue.ts +43 -0
  72. package/dist/runtime/dashboard/components/dashboard-paired-bars.vue +194 -0
  73. package/dist/runtime/dashboard/components/dashboard-paired-bars.vue.d.ts +43 -0
  74. package/dist/runtime/dashboard/components/dashboard-refresh.d.vue.ts +29 -0
  75. package/dist/runtime/dashboard/components/dashboard-refresh.vue +86 -0
  76. package/dist/runtime/dashboard/components/dashboard-refresh.vue.d.ts +29 -0
  77. package/dist/runtime/dashboard/components/dashboard-relative-time.d.vue.ts +12 -0
  78. package/dist/runtime/dashboard/components/dashboard-relative-time.vue +23 -0
  79. package/dist/runtime/dashboard/components/dashboard-relative-time.vue.d.ts +12 -0
  80. package/dist/runtime/dashboard/components/dashboard-stack-bar.d.vue.ts +36 -0
  81. package/dist/runtime/dashboard/components/dashboard-stack-bar.vue +162 -0
  82. package/dist/runtime/dashboard/components/dashboard-stack-bar.vue.d.ts +36 -0
  83. package/dist/runtime/dashboard/components/dashboard-stat.d.vue.ts +69 -0
  84. package/dist/runtime/dashboard/components/dashboard-stat.vue +279 -0
  85. package/dist/runtime/dashboard/components/dashboard-stat.vue.d.ts +69 -0
  86. package/dist/runtime/dashboard/components/dashboard-stats.d.vue.ts +38 -0
  87. package/dist/runtime/dashboard/components/dashboard-stats.vue +202 -0
  88. package/dist/runtime/dashboard/components/dashboard-stats.vue.d.ts +38 -0
  89. package/dist/runtime/dashboard/components/dashboard-table.d.vue.ts +52 -0
  90. package/dist/runtime/dashboard/components/dashboard-table.vue +305 -0
  91. package/dist/runtime/dashboard/components/dashboard-table.vue.d.ts +52 -0
  92. package/dist/runtime/dashboard/components/dashboard-tabs.d.vue.ts +35 -0
  93. package/dist/runtime/dashboard/components/dashboard-tabs.vue +55 -0
  94. package/dist/runtime/dashboard/components/dashboard-tabs.vue.d.ts +35 -0
  95. package/dist/runtime/dashboard/components/dashboard-total.d.vue.ts +10 -0
  96. package/dist/runtime/dashboard/components/dashboard-total.vue +32 -0
  97. package/dist/runtime/dashboard/components/dashboard-total.vue.d.ts +10 -0
  98. package/dist/runtime/dashboard/components/dashboard-widget.d.vue.ts +46 -0
  99. package/dist/runtime/dashboard/components/dashboard-widget.vue +84 -0
  100. package/dist/runtime/dashboard/components/dashboard-widget.vue.d.ts +46 -0
  101. package/dist/runtime/dashboard/composables/use-dashboard-api.d.ts +15 -0
  102. package/dist/runtime/dashboard/composables/use-dashboard-api.js +91 -0
  103. package/dist/runtime/dashboard/composables/use-dashboard-block.d.ts +22 -0
  104. package/dist/runtime/dashboard/composables/use-dashboard-block.js +35 -0
  105. package/dist/runtime/dashboard/composables/use-dashboard-chart.d.ts +36 -0
  106. package/dist/runtime/dashboard/composables/use-dashboard-chart.js +118 -0
  107. package/dist/runtime/dashboard/composables/use-dashboard-derived.d.ts +12 -0
  108. package/dist/runtime/dashboard/composables/use-dashboard-derived.js +47 -0
  109. package/dist/runtime/dashboard/composables/use-dashboard-format.d.ts +6 -0
  110. package/dist/runtime/dashboard/composables/use-dashboard-format.js +12 -0
  111. package/dist/runtime/dashboard/composables/use-dashboard-options.d.ts +8 -0
  112. package/dist/runtime/dashboard/composables/use-dashboard-options.js +63 -0
  113. package/dist/runtime/dashboard/composables/use-dashboard-param-scope.d.ts +30 -0
  114. package/dist/runtime/dashboard/composables/use-dashboard-param-scope.js +71 -0
  115. package/dist/runtime/dashboard/composables/use-dashboard-remote-options.d.ts +12 -0
  116. package/dist/runtime/dashboard/composables/use-dashboard-remote-options.js +117 -0
  117. package/dist/runtime/dashboard/composables/use-dashboard-resource.d.ts +35 -0
  118. package/dist/runtime/dashboard/composables/use-dashboard-resource.js +80 -0
  119. package/dist/runtime/dashboard/composables/use-dashboard-scope.d.ts +46 -0
  120. package/dist/runtime/dashboard/composables/use-dashboard-scope.js +127 -0
  121. package/dist/runtime/dashboard/composables/use-dashboard-time.d.ts +13 -0
  122. package/dist/runtime/dashboard/composables/use-dashboard-time.js +40 -0
  123. package/dist/runtime/dashboard/composables/use-dashboard-ui.d.ts +22 -0
  124. package/dist/runtime/dashboard/composables/use-dashboard-ui.js +19 -0
  125. package/dist/runtime/dashboard/composables/use-dashboard-views.d.ts +46 -0
  126. package/dist/runtime/dashboard/composables/use-dashboard-views.js +49 -0
  127. package/dist/runtime/dashboard/composables/use-dashboard.d.ts +24 -0
  128. package/dist/runtime/dashboard/composables/use-dashboard.js +42 -0
  129. package/dist/runtime/dashboard/constants/query.d.ts +16 -0
  130. package/dist/runtime/dashboard/constants/query.js +15 -0
  131. package/dist/runtime/dashboard/index.d.ts +4 -0
  132. package/dist/runtime/dashboard/index.js +3 -0
  133. package/dist/runtime/dashboard/schema/index.d.ts +57 -0
  134. package/dist/runtime/dashboard/schema/index.js +3 -0
  135. package/dist/runtime/dashboard/types/blocks.d.ts +251 -0
  136. package/dist/runtime/dashboard/types/blocks.js +0 -0
  137. package/dist/runtime/dashboard/types/charts.d.ts +60 -0
  138. package/dist/runtime/dashboard/types/charts.js +0 -0
  139. package/dist/runtime/dashboard/types/index.d.ts +7 -0
  140. package/dist/runtime/dashboard/types/index.js +0 -0
  141. package/dist/runtime/dashboard/types/options.d.ts +46 -0
  142. package/dist/runtime/dashboard/types/options.js +0 -0
  143. package/dist/runtime/dashboard/types/params.d.ts +115 -0
  144. package/dist/runtime/dashboard/types/params.js +0 -0
  145. package/dist/runtime/dashboard/types/resource.d.ts +106 -0
  146. package/dist/runtime/dashboard/types/resource.js +0 -0
  147. package/dist/runtime/dashboard/types/runtime.d.ts +44 -0
  148. package/dist/runtime/dashboard/types/runtime.js +0 -0
  149. package/dist/runtime/dashboard/types/schema.d.ts +171 -0
  150. package/dist/runtime/dashboard/types/schema.js +0 -0
  151. package/dist/runtime/dashboard/types/ui.d.ts +201 -0
  152. package/dist/runtime/dashboard/types/ui.js +0 -0
  153. package/dist/runtime/dashboard/utils/builders/dashboard-params.d.ts +85 -0
  154. package/dist/runtime/dashboard/utils/builders/dashboard-params.js +87 -0
  155. package/dist/runtime/dashboard/utils/chart-frame.d.ts +5 -0
  156. package/dist/runtime/dashboard/utils/chart-frame.js +27 -0
  157. package/dist/runtime/dashboard/utils/charts.d.ts +61 -0
  158. package/dist/runtime/dashboard/utils/charts.js +142 -0
  159. package/dist/runtime/dashboard/utils/comparison.d.ts +15 -0
  160. package/dist/runtime/dashboard/utils/comparison.js +19 -0
  161. package/dist/runtime/dashboard/utils/export.d.ts +13 -0
  162. package/dist/runtime/dashboard/utils/export.js +45 -0
  163. package/dist/runtime/dashboard/utils/options.d.ts +12 -0
  164. package/dist/runtime/dashboard/utils/options.js +23 -0
  165. package/dist/runtime/dashboard/utils/params/codecs.d.ts +14 -0
  166. package/dist/runtime/dashboard/utils/params/codecs.js +69 -0
  167. package/dist/runtime/dashboard/utils/resource.d.ts +16 -0
  168. package/dist/runtime/dashboard/utils/resource.js +39 -0
  169. package/dist/runtime/dashboard/utils/schema.d.ts +9 -0
  170. package/dist/runtime/dashboard/utils/schema.js +31 -0
  171. package/dist/runtime/dashboard/utils/sparkline.d.ts +21 -0
  172. package/dist/runtime/dashboard/utils/sparkline.js +53 -0
  173. package/dist/runtime/dashboard/utils/state.d.ts +28 -0
  174. package/dist/runtime/dashboard/utils/state.js +32 -0
  175. package/dist/runtime/dashboard/utils/time.d.ts +17 -0
  176. package/dist/runtime/dashboard/utils/time.js +60 -0
  177. package/dist/runtime/dashboard/utils/tracker.d.ts +12 -0
  178. package/dist/runtime/dashboard/utils/tracker.js +31 -0
  179. package/dist/runtime/dashboard/utils/ui.d.ts +38 -0
  180. package/dist/runtime/dashboard/utils/ui.js +24 -0
  181. package/dist/runtime/dashboard/utils/visibility.d.ts +2 -0
  182. package/dist/runtime/dashboard/utils/visibility.js +25 -0
  183. package/dist/runtime/form/types/options.d.ts +15 -36
  184. package/dist/runtime/i18n/locales/en.js +62 -0
  185. package/dist/runtime/i18n/locales/fr.js +62 -0
  186. package/dist/runtime/i18n/types.d.ts +67 -0
  187. package/dist/runtime/shared/index.d.ts +2 -0
  188. package/dist/runtime/shared/styles/tokens.css +1 -1
  189. package/dist/runtime/shared/types/query.d.ts +10 -0
  190. package/dist/runtime/shared/types/query.js +0 -0
  191. package/dist/runtime/shared/types/remote-options.d.ts +37 -0
  192. package/dist/runtime/shared/types/remote-options.js +0 -0
  193. package/dist/runtime/spreadsheet/components/layout/spreadsheet-import-footer.d.vue.ts +2 -2
  194. package/dist/runtime/spreadsheet/components/layout/spreadsheet-import-footer.vue.d.ts +2 -2
  195. package/dist/runtime/spreadsheet/composables/use-spreadsheet-internals.d.ts +15 -15
  196. package/dist/runtime/spreadsheet/composables/use-spreadsheet-resolutions.d.ts +2 -2
  197. package/dist/runtime/spreadsheet/schema/normalize.d.ts +1 -1
  198. package/dist/runtime/spreadsheet/utils/references/sources.d.ts +1 -1
  199. package/dist/runtime/table/components/data-list/data-list-content.d.vue.ts +1 -1
  200. package/dist/runtime/table/components/data-list/data-list-content.vue.d.ts +1 -1
  201. package/dist/runtime/table/components/data-list/data-list-infinite-loader.d.vue.ts +1 -1
  202. package/dist/runtime/table/components/data-list/data-list-infinite-loader.vue.d.ts +1 -1
  203. package/dist/runtime/table/components/data-list/data-list-layout-switch.d.vue.ts +1 -1
  204. package/dist/runtime/table/components/data-list/data-list-layout-switch.vue.d.ts +1 -1
  205. package/dist/runtime/table/components/data-list/data-list-pagination.d.vue.ts +1 -1
  206. package/dist/runtime/table/components/data-list/data-list-pagination.vue.d.ts +1 -1
  207. package/dist/runtime/table/components/data-list/data-list-sort-menu.d.vue.ts +1 -1
  208. package/dist/runtime/table/components/data-list/data-list-sort-menu.vue.d.ts +1 -1
  209. package/dist/runtime/table/components/data-list/sort-menu-panel.d.vue.ts +2 -2
  210. package/dist/runtime/table/components/data-list/sort-menu-panel.vue.d.ts +2 -2
  211. package/dist/runtime/table/components/filters/shared/filter-match-mode-button.d.vue.ts +1 -1
  212. package/dist/runtime/table/components/filters/shared/filter-match-mode-button.vue.d.ts +1 -1
  213. package/dist/runtime/table/components/layout/table-footer.d.vue.ts +1 -1
  214. package/dist/runtime/table/components/layout/table-footer.vue.d.ts +1 -1
  215. package/dist/runtime/table/components/table/table-cell-ellipsis.d.ts +1 -1
  216. package/dist/runtime/table/composables/use-query-state.d.ts +3 -3
  217. package/dist/runtime/table/composables/use-table-columns.d.ts +3 -3
  218. package/dist/runtime/table/composables/use-table-internals.d.ts +27 -27
  219. package/dist/runtime/table/composables/use-table-pagination.d.ts +2 -2
  220. package/dist/runtime/table/composables/use-table-selection.d.ts +1 -1
  221. package/dist/runtime/table/composables/use-table-state.d.ts +3 -3
  222. package/dist/runtime/table/types/source.d.ts +4 -5
  223. package/dist/runtime/table/utils/columns/menu.d.ts +1 -1
  224. package/dist/runtime/table/utils/columns/state.d.ts +1 -1
  225. package/dist/runtime/table/utils/data-list-ui.d.ts +1 -1
  226. package/package.json +28 -1
@@ -0,0 +1,87 @@
1
+ import {
2
+ createListCodec,
3
+ createOptionValueCodec,
4
+ createSafeCodec,
5
+ dateRangeCodec,
6
+ localDateCodec,
7
+ optionalBooleanCodec,
8
+ optionalNumberCodec,
9
+ optionalStringCodec
10
+ } from "../params/codecs.js";
11
+ function defineParam(kind, codec, options = {}) {
12
+ const multiple = options.multiple === true;
13
+ return {
14
+ codec: multiple ? createListCodec(codec) : codec,
15
+ defaultValue: options.defaultValue ?? (multiple ? [] : void 0),
16
+ historyMode: options.historyMode,
17
+ items: options.items,
18
+ kind,
19
+ multiple,
20
+ omitDefault: options.omitDefault,
21
+ remote: options.remote,
22
+ urlKey: options.urlKey
23
+ };
24
+ }
25
+ function stringParam(options) {
26
+ return defineParam("string", optionalStringCodec, options);
27
+ }
28
+ function numberParam(options) {
29
+ return defineParam("number", optionalNumberCodec, options);
30
+ }
31
+ function booleanParam(options) {
32
+ return defineParam("boolean", optionalBooleanCodec, options);
33
+ }
34
+ function dateParam(options) {
35
+ return defineParam("date", localDateCodec, options);
36
+ }
37
+ function dateRangeParam(options) {
38
+ return defineParam("dateRange", dateRangeCodec, options);
39
+ }
40
+ function enumParam(values, options) {
41
+ const items = values.map((value) => ({ label: String(value), value }));
42
+ return defineParam("enum", createOptionValueCodec(values), { ...options, items });
43
+ }
44
+ function optionsParam(items, options) {
45
+ const codec = createOptionValueCodec(items.map((item) => item.value));
46
+ return defineParam("options", codec, { ...options, items });
47
+ }
48
+ function remoteParam(config) {
49
+ const { load, pagination, queryKey, resolveSelected, search, ...options } = config;
50
+ const remote = { load, pagination, queryKey, resolveSelected, search };
51
+ return defineParam("remote", optionalStringCodec, { ...options, remote });
52
+ }
53
+ export const DASHBOARD_COMPARISONS = [
54
+ "previous",
55
+ "year",
56
+ "none"
57
+ ];
58
+ function comparisonParam(options) {
59
+ const items = DASHBOARD_COMPARISONS.map((value) => ({ label: value, value }));
60
+ return defineParam("comparison", createOptionValueCodec(DASHBOARD_COMPARISONS), {
61
+ ...options,
62
+ items
63
+ });
64
+ }
65
+ function customParam(codec, options) {
66
+ return defineParam("custom", createSafeCodec(codec), options);
67
+ }
68
+ export const dashboardParamBuilder = {
69
+ boolean: booleanParam,
70
+ /**
71
+ * Comparison period: `'previous'`, `'year'`, or `'none'`. Its option handle carries localized
72
+ * labels; `resolveDashboardComparisonRange(range, mode)` turns it into the range to fetch.
73
+ */
74
+ comparison: comparisonParam,
75
+ custom: customParam,
76
+ date: dateParam,
77
+ /** Inclusive date range, serialized as `YYYY-MM-DD..YYYY-MM-DD`. */
78
+ dateRange: dateRangeParam,
79
+ /** Value(s) from a literal list, e.g. `p.enum([2024, 2025, 2026], { defaultValue: 2026 })`. */
80
+ enum: enumParam,
81
+ number: numberParam,
82
+ /** Value(s) from labeled items: `{ value, label, icon?, avatar?, description? }`. */
83
+ options: optionsParam,
84
+ /** Id(s) picked from a remote, searchable, paginated option source. */
85
+ remote: remoteParam,
86
+ string: stringParam
87
+ };
@@ -0,0 +1,5 @@
1
+ import type { DashboardChartDatum, DashboardChartFrame, DashboardDataTable } from '../types/index.js';
2
+ /** Table of a chart: one row per x position, one column per series, values in their axis format. */
3
+ export declare function tabulateDashboardFrame(frame: DashboardChartFrame, category: string): DashboardDataTable;
4
+ /** Tooltip HTML for one x position: the label, then one row per series with its formatted value. */
5
+ export declare function renderDashboardChartTooltip(frame: DashboardChartFrame, datum: DashboardChartDatum): string;
@@ -0,0 +1,27 @@
1
+ import { escapeDashboardHtml } from "./charts.js";
2
+ import { toDashboardCell } from "./export.js";
3
+ export function tabulateDashboardFrame(frame, category) {
4
+ return {
5
+ columns: [
6
+ { key: "$x", label: category, numeric: false },
7
+ ...frame.series.map((series) => ({ key: series.key, label: series.label, numeric: true }))
8
+ ],
9
+ rows: frame.data.map((datum) => [
10
+ toDashboardCell(frame.labels[datum.index]),
11
+ ...frame.series.map((series) => {
12
+ const value = datum.values[series.index];
13
+ const axis = series.axis === "right" && frame.right ? frame.right : frame.left;
14
+ return toDashboardCell(value, value === void 0 ? "" : axis.format(value));
15
+ })
16
+ ])
17
+ };
18
+ }
19
+ export function renderDashboardChartTooltip(frame, datum) {
20
+ const rows = frame.series.map((series) => {
21
+ const value = datum.values[series.index];
22
+ if (value === void 0) return "";
23
+ const axis = series.axis === "right" && frame.right ? frame.right : frame.left;
24
+ return `<div class="nut-dash-tip-row"><i style="background:${series.color}"></i><span>${escapeDashboardHtml(series.label)}</span><b>${escapeDashboardHtml(axis.format(value))}</b></div>`;
25
+ }).join("");
26
+ return `<div class="nut-dash-tip"><div class="nut-dash-tip-title">${escapeDashboardHtml(frame.labels[datum.index] ?? "")}</div>${rows}</div>`;
27
+ }
@@ -0,0 +1,61 @@
1
+ import type { DashboardAxisOptions, DashboardChartFrameAxis, DashboardHighlight, DashboardLegendItem, DashboardSelected, DashboardSeries, DashboardSeriesColor, DashboardValueFormat } from '../types/index.js';
2
+ export declare const DASHBOARD_PALETTE_SIZE = 6;
3
+ /**
4
+ * Resolves a series color to a CSS value. Palette slots and Nuxt UI colors map to CSS variables, so
5
+ * charts follow the theme and dark mode without re-rendering. Nuxt UI has no `--ui-neutral` (neutral
6
+ * is only a scale), so `neutral` maps to the muted text gray, which adapts to the color mode.
7
+ */
8
+ export declare function resolveDashboardColor(color: DashboardSeriesColor | undefined, index: number): string;
9
+ /** A series with its display fields resolved once per render. */
10
+ export interface DashboardResolvedSeries<TRow> {
11
+ key: string;
12
+ label: string;
13
+ color: string;
14
+ dashed: boolean;
15
+ type: 'bar' | 'line' | 'area';
16
+ axis: 'left' | 'right';
17
+ value: DashboardSeries<TRow>['value'];
18
+ }
19
+ /**
20
+ * A faded tone of a color, mixed into the page background: `keep` percent of the color remains.
21
+ * Used for the bars that recede around a highlight or a selection, and for comparison series.
22
+ */
23
+ export declare function fadeDashboardColor(color: string, keep?: number): string;
24
+ /**
25
+ * Resolves the series of a chart. A series with `compare` expands into itself and its comparison
26
+ * series right after it: a faded bar, or a dashed line for lines and areas.
27
+ */
28
+ export declare function resolveDashboardSeries<TRow>(series: readonly DashboardSeries<TRow>[], defaultType: 'bar' | 'line' | 'area', compareLabel?: (label: string) => string): DashboardResolvedSeries<TRow>[];
29
+ /**
30
+ * Datums a bar chart draws at full strength, or `null` when every datum does. A selection wins over
31
+ * a highlight; `max`, `min`, and `last` read the total of each datum's values.
32
+ */
33
+ export declare function resolveDashboardEmphasis<TRow>(rows: readonly TRow[], totals: readonly number[], highlight: DashboardHighlight<TRow> | undefined, selected: DashboardSelected<TRow> | undefined): boolean[] | null;
34
+ export declare function toDashboardLegend<TRow>(series: readonly DashboardResolvedSeries<TRow>[]): DashboardLegendItem[];
35
+ /** Rounds a maximum up to a readable axis bound (1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8 × 10ⁿ). */
36
+ export declare function niceDashboardMax(value: number): number;
37
+ /** Readable interval count for a nice maximum: `2000` → 4 (every 500), `1500` → 3, `50` → 5. */
38
+ export declare function niceDashboardTickCount(max: number): number;
39
+ /**
40
+ * Value domain and tick values covering every value: `0` included, the top rounded to a readable
41
+ * bound with some headroom, and evenly spaced ticks that land on round numbers.
42
+ */
43
+ export declare function resolveDashboardAxis(values: readonly (number | null | undefined)[], axis: DashboardAxisOptions | undefined, headroom?: number): Pick<DashboardChartFrameAxis, 'domain' | 'ticks'>;
44
+ /** Default formatters of one locale: numbers, signed changes, and shares (both in percent). */
45
+ export interface DashboardFormats {
46
+ /** Locale number, compact from 10 000 (`12,6 k`). */
47
+ number: DashboardValueFormat;
48
+ /** Signed percent change: `12.4` → `+12,4 %`. */
49
+ delta: DashboardValueFormat;
50
+ /** Percent share: `57` → `57 %`. */
51
+ percent: DashboardValueFormat;
52
+ }
53
+ /**
54
+ * Formatters of one locale. `Intl.NumberFormat` instances are costly to build and stateless, so they
55
+ * are created once per locale and shared by every block.
56
+ */
57
+ export declare function resolveDashboardFormats(locale: string): DashboardFormats;
58
+ /** Escapes text interpolated into chart tooltip HTML. */
59
+ export declare function escapeDashboardHtml(value: string): string;
60
+ /** Deterministic pseudo-random sequence, so placeholders render identically on server and client. */
61
+ export declare function createDashboardSeededRandom(seed: string): () => number;
@@ -0,0 +1,142 @@
1
+ import { isNullish } from "../../shared/utils/predicate.js";
2
+ import { resolveTextValue } from "../../shared/utils/render.js";
3
+ export const DASHBOARD_PALETTE_SIZE = 6;
4
+ const nuxtUiColors = /* @__PURE__ */ new Set(["error", "info", "primary", "secondary", "success", "warning"]);
5
+ export function resolveDashboardColor(color, index) {
6
+ if (isNullish(color)) return `var(--nut-dash-s${index % DASHBOARD_PALETTE_SIZE + 1})`;
7
+ const slot = /^series-(\d)$/u.exec(color);
8
+ if (slot) return `var(--nut-dash-s${slot[1]})`;
9
+ if (color === "neutral") return "var(--ui-text-muted)";
10
+ if (nuxtUiColors.has(color)) return `var(--ui-${color})`;
11
+ return color;
12
+ }
13
+ export function fadeDashboardColor(color, keep = 30) {
14
+ return `color-mix(in oklab, ${color} ${keep}%, var(--ui-bg))`;
15
+ }
16
+ export function resolveDashboardSeries(series, defaultType, compareLabel = (label) => label) {
17
+ return series.flatMap((entry, index) => {
18
+ const type = entry.type ?? defaultType;
19
+ const label = resolveTextValue(entry.label, entry.key);
20
+ const resolved = {
21
+ // Bars always use the left axis: the secondary axis only draws lines and areas.
22
+ axis: type === "bar" ? "left" : entry.axis ?? "left",
23
+ color: resolveDashboardColor(entry.color, index),
24
+ dashed: entry.dashed ?? false,
25
+ key: entry.key,
26
+ label,
27
+ type,
28
+ value: entry.value
29
+ };
30
+ if (!entry.compare) return [resolved];
31
+ return [
32
+ resolved,
33
+ {
34
+ axis: resolved.axis,
35
+ color: fadeDashboardColor(resolved.color, type === "bar" ? 38 : 55),
36
+ dashed: type !== "bar",
37
+ key: `${entry.key}:compare`,
38
+ label: resolveTextValue(entry.compareLabel, compareLabel(label)),
39
+ type: type === "bar" ? "bar" : "line",
40
+ value: entry.compare
41
+ }
42
+ ];
43
+ });
44
+ }
45
+ export function resolveDashboardEmphasis(rows, totals, highlight, selected) {
46
+ const picked = selected ? rows.map((row, index) => selected(row, index)) : [];
47
+ if (picked.includes(true)) return picked;
48
+ if (!highlight || rows.length === 0) return null;
49
+ if (highlight === "last") return rows.map((_, index) => index === rows.length - 1);
50
+ if (highlight === "max" || highlight === "min") {
51
+ const target = highlight === "max" ? Math.max(...totals) : Math.min(...totals);
52
+ const first = totals.indexOf(target);
53
+ return rows.map((_, index) => index === first);
54
+ }
55
+ return rows.map((row, index) => highlight(row, index));
56
+ }
57
+ export function toDashboardLegend(series) {
58
+ return series.map(({ color, dashed, key, label }) => ({ color, dashed, key, label }));
59
+ }
60
+ export function niceDashboardMax(value) {
61
+ if (value <= 0) return 1;
62
+ const power = 10 ** Math.floor(Math.log10(value));
63
+ const step = [1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10].find((candidate) => value / power <= candidate) ?? 10;
64
+ return step * power;
65
+ }
66
+ const niceTickCounts = /* @__PURE__ */ new Map([
67
+ [1, 4],
68
+ [1.2, 4],
69
+ [1.5, 3],
70
+ [2, 4],
71
+ [2.5, 5],
72
+ [3, 3],
73
+ [4, 4],
74
+ [5, 5],
75
+ [6, 3],
76
+ [8, 4],
77
+ [10, 5]
78
+ ]);
79
+ export function niceDashboardTickCount(max) {
80
+ if (max <= 0) return 4;
81
+ const power = 10 ** Math.floor(Math.log10(max));
82
+ return niceTickCounts.get(Number((max / power).toFixed(2))) ?? 4;
83
+ }
84
+ export function resolveDashboardAxis(values, axis, headroom = 1.05) {
85
+ const finite = values.filter((value) => Number.isFinite(value));
86
+ const lowest = Math.min(0, ...finite);
87
+ if (lowest < 0 && axis?.min === void 0 && axis?.max === void 0)
88
+ return resolveDivergingAxis(lowest, Math.max(0, ...finite), headroom, axis?.ticks);
89
+ const min = axis?.min ?? lowest;
90
+ const max = axis?.max ?? niceDashboardMax(Math.max(0, ...finite) * headroom);
91
+ const count = Math.max(1, Math.round(axis?.ticks ?? niceDashboardTickCount(max - min)));
92
+ const ticks = Array.from({ length: count + 1 }, (_, index) => min + (max - min) * index / count);
93
+ return { domain: [min, max], ticks };
94
+ }
95
+ function resolveDivergingAxis(lowest, highest, headroom, ticks = 4) {
96
+ const bottom = -lowest * headroom;
97
+ const top = highest * headroom;
98
+ const rough = (top + bottom) / Math.max(1, ticks);
99
+ const power = 10 ** Math.floor(Math.log10(rough));
100
+ const step = ([1, 2, 2.5, 5, 10].find((candidate) => rough / power <= candidate) ?? 10) * power;
101
+ const min = -Math.ceil(bottom / step) * step;
102
+ const max = Math.ceil(top / step) * step;
103
+ const count = Math.max(1, Math.round((max - min) / step));
104
+ return {
105
+ domain: [min, max],
106
+ ticks: Array.from({ length: count + 1 }, (_, index) => min + step * index)
107
+ };
108
+ }
109
+ const formatsByLocale = /* @__PURE__ */ new Map();
110
+ export function resolveDashboardFormats(locale) {
111
+ const cached = formatsByLocale.get(locale);
112
+ if (cached) return cached;
113
+ const plain = new Intl.NumberFormat(locale, { maximumFractionDigits: 1 });
114
+ const compact = new Intl.NumberFormat(locale, { maximumFractionDigits: 1, notation: "compact" });
115
+ const delta = new Intl.NumberFormat(locale, {
116
+ maximumFractionDigits: 1,
117
+ signDisplay: "exceptZero",
118
+ style: "percent"
119
+ });
120
+ const percent = new Intl.NumberFormat(locale, { maximumFractionDigits: 1, style: "percent" });
121
+ const formats = {
122
+ delta: (value) => delta.format(value / 100),
123
+ number: (value) => Math.abs(value) >= 1e4 ? compact.format(value) : plain.format(value),
124
+ percent: (value) => percent.format(value / 100)
125
+ };
126
+ formatsByLocale.set(locale, formats);
127
+ return formats;
128
+ }
129
+ export function escapeDashboardHtml(value) {
130
+ return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;");
131
+ }
132
+ export function createDashboardSeededRandom(seed) {
133
+ let state = [...seed].reduce(
134
+ (hash, char) => Math.imul(hash ^ char.charCodeAt(0), 16777619),
135
+ 2166136261
136
+ );
137
+ return () => {
138
+ state = Math.imul(state ^ state >>> 15, state | 1);
139
+ state ^= state + Math.imul(state ^ state >>> 7, state | 61);
140
+ return ((state ^ state >>> 14) >>> 0) / 4294967296;
141
+ };
142
+ }
@@ -0,0 +1,15 @@
1
+ import type { DashboardComparison, DashboardDateRange } from '../types/index.js';
2
+ /**
3
+ * Range to compare `range` against: the period of the same length right before it (`previous`), or
4
+ * the same dates a year earlier (`year`, Feb 29 falling back to Feb 28). `undefined` without a range
5
+ * or with `none`. Days are calendar days: the result never drifts across daylight-saving changes.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * queryFn: () => api.revenue({
10
+ * range: params.range,
11
+ * previous: resolveDashboardComparisonRange(params.range, params.compare),
12
+ * })
13
+ * ```
14
+ */
15
+ export declare function resolveDashboardComparisonRange(range: DashboardDateRange | null | undefined, comparison: DashboardComparison | null | undefined): DashboardDateRange | undefined;
@@ -0,0 +1,19 @@
1
+ export function resolveDashboardComparisonRange(range, comparison) {
2
+ if (!range || !comparison || comparison === "none") return void 0;
3
+ if (comparison === "year") return { end: yearBefore(range.end), start: yearBefore(range.start) };
4
+ const days = calendarDaysBetween(range.start, range.end) + 1;
5
+ const end = addDays(range.start, -1);
6
+ return { end, start: addDays(end, -(days - 1)) };
7
+ }
8
+ function addDays(date, days) {
9
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + days);
10
+ }
11
+ function yearBefore(date) {
12
+ const shifted = new Date(date.getFullYear() - 1, date.getMonth(), date.getDate());
13
+ return shifted.getMonth() === date.getMonth() ? shifted : new Date(shifted.getFullYear(), shifted.getMonth(), 0);
14
+ }
15
+ function calendarDaysBetween(start, end) {
16
+ const from = Date.UTC(start.getFullYear(), start.getMonth(), start.getDate());
17
+ const to = Date.UTC(end.getFullYear(), end.getMonth(), end.getDate());
18
+ return Math.max(0, Math.round((to - from) / 864e5));
19
+ }
@@ -0,0 +1,13 @@
1
+ import type { DashboardDataCell, DashboardDataTable } from '../types/index.js';
2
+ /** A table cell from a raw value and, optionally, its display text (defaults to the value). */
3
+ export declare function toDashboardCell(value: string | number | null | undefined, text?: string): DashboardDataCell;
4
+ /**
5
+ * Serializes a data table to CSV the way spreadsheet apps of the locale read it: numbers are raw
6
+ * (not formatted) with the locale decimal mark, and locales whose decimal mark is a comma use `;`
7
+ * between fields. Every text field is quoted.
8
+ */
9
+ export declare function toDashboardCsv(table: DashboardDataTable, locale: string): string;
10
+ /** File name from a card title: `Consommation mensuelle` → `consommation-mensuelle.csv`. */
11
+ export declare function resolveDashboardFileName(title: string, extension: string): string;
12
+ /** Downloads text as a file. The BOM lets spreadsheet apps detect UTF-8 (accents, `€`). */
13
+ export declare function downloadDashboardFile(name: string, content: string, type?: string): void;
@@ -0,0 +1,45 @@
1
+ import { isNumber } from "../../shared/utils/predicate.js";
2
+ export function toDashboardCell(value, text) {
3
+ return {
4
+ text: text ?? (value === null || value === void 0 ? "" : String(value)),
5
+ value: value ?? null
6
+ };
7
+ }
8
+ const decimalByLocale = /* @__PURE__ */ new Map();
9
+ function decimalSeparator(locale) {
10
+ let separator = decimalByLocale.get(locale);
11
+ if (separator === void 0) {
12
+ separator = new Intl.NumberFormat(locale).formatToParts(1.5).find((part) => part.type === "decimal")?.value ?? ".";
13
+ decimalByLocale.set(locale, separator);
14
+ }
15
+ return separator;
16
+ }
17
+ export function toDashboardCsv(table, locale) {
18
+ const decimal = decimalSeparator(locale);
19
+ const delimiter = decimal === "," ? ";" : ",";
20
+ const field = (cell) => {
21
+ if (cell.value === null) return "";
22
+ if (isNumber(cell.value)) return String(cell.value).replace(".", decimal);
23
+ return quote(cell.value);
24
+ };
25
+ const lines = [
26
+ table.columns.map((column) => quote(column.label)).join(delimiter),
27
+ ...table.rows.map((row) => row.map(field).join(delimiter))
28
+ ];
29
+ return lines.join("\r\n");
30
+ }
31
+ function quote(text) {
32
+ return `"${text.replaceAll('"', '""')}"`;
33
+ }
34
+ export function resolveDashboardFileName(title, extension) {
35
+ const slug = title.normalize("NFD").replaceAll(/[̀-ͯ]/gu, "").toLowerCase().replaceAll(/[^a-z0-9]+/gu, "-").replaceAll(/^-+|-+$/gu, "");
36
+ return `${slug || "dashboard"}.${extension}`;
37
+ }
38
+ export function downloadDashboardFile(name, content, type = "text/csv") {
39
+ const url = URL.createObjectURL(new Blob(["\uFEFF", content], { type: `${type};charset=utf-8` }));
40
+ const link = document.createElement("a");
41
+ link.href = url;
42
+ link.download = name;
43
+ link.click();
44
+ setTimeout(() => URL.revokeObjectURL(url), 0);
45
+ }
@@ -0,0 +1,12 @@
1
+ import type { RemoteOptionsResult } from '../../shared/types/remote-options.js';
2
+ import type { DashboardOption } from '../types/index.js';
3
+ export interface DashboardRemotePageParam {
4
+ index: number;
5
+ cursor: string | null;
6
+ }
7
+ /** Normalizes a single or multiple param value to its string keys, in value order. */
8
+ export declare function resolveDashboardOptionValues(value: unknown): string[];
9
+ /** Next page of a page- or cursor-paginated remote source, or `undefined` at the end. */
10
+ export declare function resolveDashboardRemoteNextPage(page: RemoteOptionsResult<DashboardOption<string>>, loadedPages: number): DashboardRemotePageParam | undefined;
11
+ /** Unique options by value, keeping the first occurrence. */
12
+ export declare function mergeDashboardOptions(...lists: readonly (readonly DashboardOption[])[]): DashboardOption[];
@@ -0,0 +1,23 @@
1
+ import { isNullish } from "../../shared/utils/predicate.js";
2
+ export function resolveDashboardOptionValues(value) {
3
+ if (Array.isArray(value)) return value.filter((entry) => !isNullish(entry)).map(String);
4
+ return isNullish(value) ? [] : [String(value)];
5
+ }
6
+ export function resolveDashboardRemoteNextPage(page, loadedPages) {
7
+ if ("nextCursor" in page)
8
+ return page.nextCursor ? { cursor: page.nextCursor, index: loadedPages + 1 } : void 0;
9
+ return page.hasMore ? { cursor: null, index: loadedPages + 1 } : void 0;
10
+ }
11
+ export function mergeDashboardOptions(...lists) {
12
+ const seen = /* @__PURE__ */ new Set();
13
+ const merged = [];
14
+ for (const list of lists) {
15
+ for (const option of list) {
16
+ const key = String(option.value);
17
+ if (seen.has(key)) continue;
18
+ seen.add(key);
19
+ merged.push(option);
20
+ }
21
+ }
22
+ return merged;
23
+ }
@@ -0,0 +1,14 @@
1
+ import type { QueryCodec } from '../../../query-state/index.js';
2
+ import type { DashboardDateRange, DashboardOptionValue } from '../../types/index.js';
3
+ export declare const optionalStringCodec: QueryCodec<string | undefined>;
4
+ export declare const optionalNumberCodec: QueryCodec<number | undefined>;
5
+ export declare const optionalBooleanCodec: QueryCodec<boolean | undefined>;
6
+ /** Calendar date, serialized as local `YYYY-MM-DD` so it never shifts across time zones. */
7
+ export declare const localDateCodec: QueryCodec<Date | undefined>;
8
+ export declare const dateRangeCodec: QueryCodec<DashboardDateRange | undefined>;
9
+ /** Single value from a fixed list of strings or numbers. Unknown raw values parse to `undefined`. */
10
+ export declare function createOptionValueCodec(values: readonly DashboardOptionValue[]): QueryCodec<DashboardOptionValue | undefined>;
11
+ /** Comma-separated list over an item codec. Invalid items are dropped; empty lists leave the URL. */
12
+ export declare function createListCodec<TItem>(itemCodec: QueryCodec<TItem | undefined>): QueryCodec<TItem[] | undefined>;
13
+ /** Wraps a consumer codec so parse failures fall back to the default instead of throwing. */
14
+ export declare function createSafeCodec<TValue>(codec: QueryCodec<TValue>): QueryCodec<TValue | undefined>;
@@ -0,0 +1,69 @@
1
+ import { isNullish } from "../../../shared/utils/predicate.js";
2
+ export const optionalStringCodec = {
3
+ parse: (raw) => raw === "" ? void 0 : raw,
4
+ serialize: (value) => isNullish(value) || value === "" ? null : value
5
+ };
6
+ export const optionalNumberCodec = {
7
+ parse(raw) {
8
+ const value = Number(raw);
9
+ return raw === "" || Number.isNaN(value) ? void 0 : value;
10
+ },
11
+ serialize: (value) => isNullish(value) ? null : String(value)
12
+ };
13
+ export const optionalBooleanCodec = {
14
+ parse: (raw) => raw === "true" ? true : raw === "false" ? false : void 0,
15
+ serialize: (value) => isNullish(value) ? null : String(value)
16
+ };
17
+ export const localDateCodec = {
18
+ parse: parseLocalDate,
19
+ serialize: (value) => isNullish(value) ? null : formatLocalDate(value)
20
+ };
21
+ export const dateRangeCodec = {
22
+ parse(raw) {
23
+ const [start, end] = raw.split("..").map(parseLocalDate);
24
+ return start && end ? { end, start } : void 0;
25
+ },
26
+ serialize: (value) => isNullish(value) ? null : `${formatLocalDate(value.start)}..${formatLocalDate(value.end)}`
27
+ };
28
+ export function createOptionValueCodec(values) {
29
+ const byRaw = new Map(values.map((value) => [String(value), value]));
30
+ return {
31
+ parse: (raw) => byRaw.get(raw),
32
+ serialize: (value) => isNullish(value) || !byRaw.has(String(value)) ? null : String(value)
33
+ };
34
+ }
35
+ export function createListCodec(itemCodec) {
36
+ return {
37
+ parse(raw) {
38
+ if (raw === "") return [];
39
+ return raw.split(",").map((part) => itemCodec.parse(part)).filter((item) => item !== void 0);
40
+ },
41
+ serialize(value) {
42
+ if (isNullish(value) || value.length === 0) return null;
43
+ return value.map((item) => itemCodec.serialize(item)).filter((item) => item !== null).join(",");
44
+ }
45
+ };
46
+ }
47
+ export function createSafeCodec(codec) {
48
+ return {
49
+ parse(raw) {
50
+ try {
51
+ return codec.parse(raw);
52
+ } catch {
53
+ return void 0;
54
+ }
55
+ },
56
+ serialize: (value) => value === void 0 ? null : codec.serialize(value)
57
+ };
58
+ }
59
+ function parseLocalDate(raw) {
60
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/u.exec(raw);
61
+ if (!match) return void 0;
62
+ const date = new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3]));
63
+ return Number.isNaN(date.getTime()) ? void 0 : date;
64
+ }
65
+ function formatLocalDate(value) {
66
+ const month = String(value.getMonth() + 1).padStart(2, "0");
67
+ const day = String(value.getDate()).padStart(2, "0");
68
+ return `${value.getFullYear()}-${month}-${day}`;
69
+ }
@@ -0,0 +1,16 @@
1
+ import type { ShallowRef } from 'vue';
2
+ import type { useDashboardResource } from '../composables/use-dashboard-resource.js';
3
+ import type { DashboardSourceLike, DashboardStage } from '../types/index.js';
4
+ export type DashboardResourceSlot = ShallowRef<ReturnType<typeof useDashboardResource> | null>;
5
+ /**
6
+ * Public resource object returned by `stage.query(...)`. It exists before its key is known (keys
7
+ * come from the object the `queries` builder returns), so it reads the resource runtime through a
8
+ * slot. Reads before instantiation track the slot, which keeps dependent gates reactive.
9
+ */
10
+ export declare function createDashboardResourceFacade(stage: DashboardStage, slot: DashboardResourceSlot, defaultValue: unknown): DashboardSourceLike & {
11
+ kind: 'query';
12
+ stage: DashboardStage;
13
+ active: boolean;
14
+ params: object;
15
+ options: object;
16
+ };
@@ -0,0 +1,39 @@
1
+ import { markRaw } from "vue";
2
+ const emptyFacade = markRaw({});
3
+ export function createDashboardResourceFacade(stage, slot, defaultValue) {
4
+ return markRaw({
5
+ activate() {
6
+ slot.value?.activate();
7
+ },
8
+ get active() {
9
+ return slot.value?.active.value ?? false;
10
+ },
11
+ get data() {
12
+ return slot.value ? slot.value.data.value : defaultValue;
13
+ },
14
+ get error() {
15
+ return slot.value?.error.value ?? void 0;
16
+ },
17
+ get id() {
18
+ return slot.value?.id ?? "";
19
+ },
20
+ kind: "query",
21
+ get options() {
22
+ return slot.value?.widget.options ?? emptyFacade;
23
+ },
24
+ get params() {
25
+ return slot.value?.widget.values ?? emptyFacade;
26
+ },
27
+ refresh: () => slot.value?.refresh() ?? Promise.resolve(),
28
+ get refreshing() {
29
+ return slot.value?.refreshing.value ?? false;
30
+ },
31
+ stage,
32
+ get state() {
33
+ return slot.value?.state.value ?? "idle";
34
+ },
35
+ get updatedAt() {
36
+ return slot.value?.updatedAt.value;
37
+ }
38
+ });
39
+ }
@@ -0,0 +1,9 @@
1
+ import type { DashboardSchemaLike } from '../types/index.js';
2
+ import type { DashboardRuntimeSchema } from '../types/runtime.js';
3
+ /**
4
+ * Erases the schema generics once so the runtime can invoke every builder with the contexts it
5
+ * creates. Views are resolved here (their builder is an identity function at runtime).
6
+ */
7
+ export declare function resolveDashboardRuntimeSchema(schema: DashboardSchemaLike): DashboardRuntimeSchema;
8
+ /** Dev guard mirroring the compile-time key checks, for schemas assembled without inference. */
9
+ export declare function assertDashboardMemberKey(key: string, taken: ReadonlySet<string>, scope: string): void;
@@ -0,0 +1,31 @@
1
+ const reservedKeys = /* @__PURE__ */ new Set([
2
+ "autoRefresh",
3
+ "options",
4
+ "params",
5
+ "refresh",
6
+ "refreshing",
7
+ "schema",
8
+ "state",
9
+ "updatedAt",
10
+ "view"
11
+ ]);
12
+ export function resolveDashboardRuntimeSchema(schema) {
13
+ const input = schema;
14
+ const views = Object.entries(input.views?.((view) => view) ?? {});
15
+ return {
16
+ autoRefresh: input.autoRefresh,
17
+ defaultView: input.defaultView ?? views[0]?.[0],
18
+ derive: input.derive,
19
+ key: input.key,
20
+ label: input.label,
21
+ params: input.params,
22
+ queries: input.queries,
23
+ urlPrefix: input.urlPrefix,
24
+ views
25
+ };
26
+ }
27
+ export function assertDashboardMemberKey(key, taken, scope) {
28
+ if (reservedKeys.has(key) || taken.has(key)) {
29
+ throw new Error(`[dashboard] "${key}" in ${scope} is reserved or already used.`);
30
+ }
31
+ }