nuxt-ui-tools 1.2.0 → 1.4.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 (238) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +18 -2
  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.d.ts +1 -1
  14. package/dist/runtime/dashboard/components/block/dashboard-view-scope.d.vue.ts +21 -0
  15. package/dist/runtime/dashboard/components/block/dashboard-view-scope.vue +12 -0
  16. package/dist/runtime/dashboard/components/block/dashboard-view-scope.vue.d.ts +21 -0
  17. package/dist/runtime/dashboard/components/dashboard-alerts.vue +3 -3
  18. package/dist/runtime/dashboard/components/dashboard-bar-chart.d.vue.ts +14 -3
  19. package/dist/runtime/dashboard/components/dashboard-bar-chart.vue +30 -9
  20. package/dist/runtime/dashboard/components/dashboard-bar-chart.vue.d.ts +14 -3
  21. package/dist/runtime/dashboard/components/dashboard-bars.vue +4 -4
  22. package/dist/runtime/dashboard/components/dashboard-card.vue +28 -6
  23. package/dist/runtime/dashboard/components/dashboard-combo-chart.d.vue.ts +6 -1
  24. package/dist/runtime/dashboard/components/dashboard-combo-chart.vue +13 -3
  25. package/dist/runtime/dashboard/components/dashboard-combo-chart.vue.d.ts +6 -1
  26. package/dist/runtime/dashboard/components/dashboard-donut-chart.vue +5 -5
  27. package/dist/runtime/dashboard/components/dashboard-feed.vue +1 -1
  28. package/dist/runtime/dashboard/components/dashboard-filter.d.vue.ts +67 -0
  29. package/dist/runtime/dashboard/components/dashboard-filter.vue +134 -0
  30. package/dist/runtime/dashboard/components/dashboard-filter.vue.d.ts +67 -0
  31. package/dist/runtime/dashboard/components/dashboard-filters.d.vue.ts +49 -0
  32. package/dist/runtime/dashboard/components/dashboard-filters.vue +96 -0
  33. package/dist/runtime/dashboard/components/dashboard-filters.vue.d.ts +49 -0
  34. package/dist/runtime/dashboard/components/dashboard-funnel.vue +5 -5
  35. package/dist/runtime/dashboard/components/dashboard-gauge.vue +3 -3
  36. package/dist/runtime/dashboard/components/dashboard-grid.d.vue.ts +10 -3
  37. package/dist/runtime/dashboard/components/dashboard-grid.vue +24 -9
  38. package/dist/runtime/dashboard/components/dashboard-grid.vue.d.ts +10 -3
  39. package/dist/runtime/dashboard/components/dashboard-line-chart.d.vue.ts +14 -3
  40. package/dist/runtime/dashboard/components/dashboard-line-chart.vue +30 -9
  41. package/dist/runtime/dashboard/components/dashboard-line-chart.vue.d.ts +14 -3
  42. package/dist/runtime/dashboard/components/dashboard-list.d.vue.ts +3 -0
  43. package/dist/runtime/dashboard/components/dashboard-list.vue +18 -6
  44. package/dist/runtime/dashboard/components/dashboard-list.vue.d.ts +3 -0
  45. package/dist/runtime/dashboard/components/dashboard-page.d.vue.ts +53 -0
  46. package/dist/runtime/dashboard/components/dashboard-page.vue +156 -0
  47. package/dist/runtime/dashboard/components/dashboard-page.vue.d.ts +53 -0
  48. package/dist/runtime/dashboard/components/dashboard-paired-bars.vue +4 -4
  49. package/dist/runtime/dashboard/components/dashboard-refresh.d.vue.ts +1 -1
  50. package/dist/runtime/dashboard/components/dashboard-refresh.vue +1 -0
  51. package/dist/runtime/dashboard/components/dashboard-refresh.vue.d.ts +1 -1
  52. package/dist/runtime/dashboard/components/dashboard-stack-bar.vue +4 -4
  53. package/dist/runtime/dashboard/components/dashboard-stat.d.vue.ts +14 -2
  54. package/dist/runtime/dashboard/components/dashboard-stat.vue +28 -10
  55. package/dist/runtime/dashboard/components/dashboard-stat.vue.d.ts +14 -2
  56. package/dist/runtime/dashboard/components/dashboard-stats.vue +3 -3
  57. package/dist/runtime/dashboard/components/dashboard-table.d.vue.ts +1 -1
  58. package/dist/runtime/dashboard/components/dashboard-table.vue +3 -3
  59. package/dist/runtime/dashboard/components/dashboard-table.vue.d.ts +1 -1
  60. package/dist/runtime/dashboard/components/dashboard-tabs.d.vue.ts +1 -1
  61. package/dist/runtime/dashboard/components/dashboard-tabs.vue.d.ts +1 -1
  62. package/dist/runtime/dashboard/components/dashboard-total.d.vue.ts +7 -2
  63. package/dist/runtime/dashboard/components/dashboard-total.vue +10 -2
  64. package/dist/runtime/dashboard/components/dashboard-total.vue.d.ts +7 -2
  65. package/dist/runtime/dashboard/components/dashboard-view-tabs.d.vue.ts +33 -0
  66. package/dist/runtime/dashboard/components/dashboard-view-tabs.vue +66 -0
  67. package/dist/runtime/dashboard/components/dashboard-view-tabs.vue.d.ts +33 -0
  68. package/dist/runtime/dashboard/components/dashboard-widget.vue +1 -1
  69. package/dist/runtime/dashboard/components/filter/dashboard-filter-menu.d.vue.ts +44 -0
  70. package/dist/runtime/dashboard/components/filter/dashboard-filter-menu.vue +220 -0
  71. package/dist/runtime/dashboard/components/filter/dashboard-filter-menu.vue.d.ts +44 -0
  72. package/dist/runtime/dashboard/composables/use-dashboard-api.d.ts +6 -1
  73. package/dist/runtime/dashboard/composables/use-dashboard-api.js +29 -6
  74. package/dist/runtime/dashboard/composables/use-dashboard-block.d.ts +5 -4
  75. package/dist/runtime/dashboard/composables/use-dashboard-block.js +32 -15
  76. package/dist/runtime/dashboard/composables/use-dashboard-chart.d.ts +8 -1
  77. package/dist/runtime/dashboard/composables/use-dashboard-chart.js +16 -4
  78. package/dist/runtime/dashboard/composables/use-dashboard-context.d.ts +50 -0
  79. package/dist/runtime/dashboard/composables/use-dashboard-context.js +56 -0
  80. package/dist/runtime/dashboard/composables/use-dashboard-derived.js +6 -1
  81. package/dist/runtime/dashboard/composables/use-dashboard-filter-control.d.ts +16 -0
  82. package/dist/runtime/dashboard/composables/use-dashboard-filter-control.js +161 -0
  83. package/dist/runtime/dashboard/composables/use-dashboard-filter-scope.d.ts +37 -0
  84. package/dist/runtime/dashboard/composables/use-dashboard-filter-scope.js +107 -0
  85. package/dist/runtime/dashboard/composables/use-dashboard-format.d.ts +46 -6
  86. package/dist/runtime/dashboard/composables/use-dashboard-format.js +51 -8
  87. package/dist/runtime/dashboard/composables/use-dashboard-options.d.ts +11 -4
  88. package/dist/runtime/dashboard/composables/use-dashboard-options.js +33 -47
  89. package/dist/runtime/dashboard/composables/use-dashboard-remote-options.d.ts +8 -5
  90. package/dist/runtime/dashboard/composables/use-dashboard-remote-options.js +59 -70
  91. package/dist/runtime/dashboard/composables/use-dashboard-resource.d.ts +15 -4
  92. package/dist/runtime/dashboard/composables/use-dashboard-resource.js +52 -17
  93. package/dist/runtime/dashboard/composables/use-dashboard-scope.d.ts +10 -7
  94. package/dist/runtime/dashboard/composables/use-dashboard-scope.js +26 -16
  95. package/dist/runtime/dashboard/composables/use-dashboard-series-picker.d.ts +20 -0
  96. package/dist/runtime/dashboard/composables/use-dashboard-series-picker.js +30 -0
  97. package/dist/runtime/dashboard/composables/use-dashboard-time.d.ts +2 -0
  98. package/dist/runtime/dashboard/composables/use-dashboard-time.js +4 -1
  99. package/dist/runtime/dashboard/composables/use-dashboard-ui.d.ts +12 -2
  100. package/dist/runtime/dashboard/composables/use-dashboard-ui.js +3 -0
  101. package/dist/runtime/dashboard/composables/use-dashboard-views.d.ts +15 -3
  102. package/dist/runtime/dashboard/composables/use-dashboard-views.js +33 -10
  103. package/dist/runtime/dashboard/composables/use-dashboard.d.ts +18 -12
  104. package/dist/runtime/dashboard/composables/use-dashboard.js +98 -9
  105. package/dist/runtime/dashboard/index.d.ts +3 -1
  106. package/dist/runtime/dashboard/index.js +3 -1
  107. package/dist/runtime/dashboard/schema/index.d.ts +62 -30
  108. package/dist/runtime/dashboard/schema/index.js +3 -0
  109. package/dist/runtime/dashboard/types/blocks.d.ts +30 -4
  110. package/dist/runtime/dashboard/types/charts.d.ts +2 -2
  111. package/dist/runtime/dashboard/types/controls.d.ts +123 -0
  112. package/dist/runtime/dashboard/types/filters.d.ts +236 -0
  113. package/dist/runtime/dashboard/types/index.d.ts +3 -2
  114. package/dist/runtime/dashboard/types/page.d.ts +17 -0
  115. package/dist/runtime/dashboard/types/page.js +0 -0
  116. package/dist/runtime/dashboard/types/resource.d.ts +66 -28
  117. package/dist/runtime/dashboard/types/runtime.d.ts +39 -8
  118. package/dist/runtime/dashboard/types/schema.d.ts +94 -54
  119. package/dist/runtime/dashboard/types/ui.d.ts +78 -0
  120. package/dist/runtime/dashboard/utils/builders/dashboard-filters.d.ts +142 -0
  121. package/dist/runtime/dashboard/utils/builders/dashboard-filters.js +135 -0
  122. package/dist/runtime/dashboard/utils/charts.d.ts +4 -15
  123. package/dist/runtime/dashboard/utils/charts.js +26 -28
  124. package/dist/runtime/dashboard/utils/{params/codecs.d.ts → codecs.d.ts} +2 -2
  125. package/dist/runtime/dashboard/utils/{params/codecs.js → codecs.js} +1 -1
  126. package/dist/runtime/dashboard/utils/environment.d.ts +36 -0
  127. package/dist/runtime/dashboard/utils/environment.js +30 -0
  128. package/dist/runtime/dashboard/utils/filters.d.ts +44 -0
  129. package/dist/runtime/dashboard/utils/filters.js +62 -0
  130. package/dist/runtime/dashboard/utils/format.d.ts +25 -0
  131. package/dist/runtime/dashboard/utils/format.js +66 -0
  132. package/dist/runtime/dashboard/utils/grid.d.ts +17 -0
  133. package/dist/runtime/dashboard/utils/grid.js +14 -0
  134. package/dist/runtime/dashboard/utils/options.d.ts +3 -1
  135. package/dist/runtime/dashboard/utils/options.js +6 -0
  136. package/dist/runtime/dashboard/utils/remote.d.ts +7 -0
  137. package/dist/runtime/dashboard/utils/remote.js +14 -0
  138. package/dist/runtime/dashboard/utils/resource.d.ts +16 -7
  139. package/dist/runtime/dashboard/utils/resource.js +15 -9
  140. package/dist/runtime/dashboard/utils/schema.d.ts +8 -3
  141. package/dist/runtime/dashboard/utils/schema.js +9 -4
  142. package/dist/runtime/dashboard/utils/state.d.ts +11 -6
  143. package/dist/runtime/dashboard/utils/state.js +10 -5
  144. package/dist/runtime/dashboard/utils/time.d.ts +2 -0
  145. package/dist/runtime/dashboard/utils/time.js +11 -1
  146. package/dist/runtime/dashboard/utils/ui.d.ts +1 -1
  147. package/dist/runtime/dashboard/utils/ui.js +1 -1
  148. package/dist/runtime/form/components/actions/form-actions.vue +13 -127
  149. package/dist/runtime/form/components/page/form-page-actions.d.vue.ts +3 -0
  150. package/dist/runtime/form/components/page/form-page-actions.vue +40 -0
  151. package/dist/runtime/form/components/page/form-page-actions.vue.d.ts +3 -0
  152. package/dist/runtime/form/components/page/form-page-header.d.vue.ts +24 -0
  153. package/dist/runtime/form/components/page/form-page-header.vue +99 -0
  154. package/dist/runtime/form/components/page/form-page-header.vue.d.ts +24 -0
  155. package/dist/runtime/form/components/page/form-page-navigation.d.vue.ts +34 -0
  156. package/dist/runtime/form/components/page/form-page-navigation.vue +229 -0
  157. package/dist/runtime/form/components/page/form-page-navigation.vue.d.ts +34 -0
  158. package/dist/runtime/form/components/page/form-page-section.d.vue.ts +19 -0
  159. package/dist/runtime/form/components/page/form-page-section.vue +114 -0
  160. package/dist/runtime/form/components/page/form-page-section.vue.d.ts +19 -0
  161. package/dist/runtime/form/components/page/form-page-sections.d.vue.ts +21 -0
  162. package/dist/runtime/form/components/page/form-page-sections.vue +75 -0
  163. package/dist/runtime/form/components/page/form-page-sections.vue.d.ts +21 -0
  164. package/dist/runtime/form/components/page/form-page.d.vue.ts +80 -0
  165. package/dist/runtime/form/components/page/form-page.vue +91 -0
  166. package/dist/runtime/form/components/page/form-page.vue.d.ts +80 -0
  167. package/dist/runtime/form/components/renderer/form-field-shell.vue +7 -11
  168. package/dist/runtime/form/components/root/form.vue +26 -195
  169. package/dist/runtime/form/composables/use-form-action-buttons.d.ts +32 -0
  170. package/dist/runtime/form/composables/use-form-action-buttons.js +89 -0
  171. package/dist/runtime/form/composables/use-form-actions.d.ts +8 -5
  172. package/dist/runtime/form/composables/use-form-actions.js +1 -1
  173. package/dist/runtime/form/composables/use-form-page-scroll.d.ts +22 -0
  174. package/dist/runtime/form/composables/use-form-page-scroll.js +178 -0
  175. package/dist/runtime/form/composables/use-form-page.d.ts +114 -0
  176. package/dist/runtime/form/composables/use-form-page.js +83 -0
  177. package/dist/runtime/form/composables/use-form-root.d.ts +34 -0
  178. package/dist/runtime/form/composables/use-form-root.js +171 -0
  179. package/dist/runtime/form/composables/use-form-runtime.js +13 -4
  180. package/dist/runtime/form/composables/use-form.js +2 -22
  181. package/dist/runtime/form/fields/card-selection.d.ts +1 -0
  182. package/dist/runtime/form/fields/card-selection.js +1 -0
  183. package/dist/runtime/form/fields/checkbox-card/component.vue +28 -17
  184. package/dist/runtime/form/fields/checkbox-card/types.d.ts +2 -5
  185. package/dist/runtime/form/fields/checkbox-group/component.vue +5 -0
  186. package/dist/runtime/form/fields/choice-card/choice-card-label.d.vue.ts +17 -0
  187. package/dist/runtime/form/fields/choice-card/choice-card-label.vue +50 -0
  188. package/dist/runtime/form/fields/choice-card/choice-card-label.vue.d.ts +17 -0
  189. package/dist/runtime/form/fields/choice-card/types.d.ts +31 -0
  190. package/dist/runtime/form/fields/choice-card/types.js +0 -0
  191. package/dist/runtime/form/fields/choice-card/use-choice-card.d.ts +22 -0
  192. package/dist/runtime/form/fields/choice-card/use-choice-card.js +52 -0
  193. package/dist/runtime/form/fields/radio/component.vue +10 -0
  194. package/dist/runtime/form/fields/radio-card/component.vue +17 -16
  195. package/dist/runtime/form/fields/radio-card/types.d.ts +2 -4
  196. package/dist/runtime/form/index.d.ts +1 -1
  197. package/dist/runtime/form/index.js +7 -1
  198. package/dist/runtime/form/schema/index.d.ts +1 -1
  199. package/dist/runtime/form/schema/index.js +1 -0
  200. package/dist/runtime/form/schema/page.d.ts +50 -0
  201. package/dist/runtime/form/schema/page.js +25 -0
  202. package/dist/runtime/form/types/index.d.ts +1 -0
  203. package/dist/runtime/form/types/options.d.ts +1 -11
  204. package/dist/runtime/form/types/page.d.ts +172 -0
  205. package/dist/runtime/form/types/page.js +0 -0
  206. package/dist/runtime/form/types/ui.d.ts +60 -0
  207. package/dist/runtime/form/utils/controls.d.ts +15 -0
  208. package/dist/runtime/form/utils/controls.js +38 -0
  209. package/dist/runtime/form/utils/focus.js +1 -1
  210. package/dist/runtime/form/utils/layout.js +3 -1
  211. package/dist/runtime/form/utils/page.d.ts +20 -0
  212. package/dist/runtime/form/utils/page.js +107 -0
  213. package/dist/runtime/form/utils/state.d.ts +2 -0
  214. package/dist/runtime/form/utils/state.js +1 -1
  215. package/dist/runtime/form/utils/ui.js +1 -0
  216. package/dist/runtime/i18n/locales/en.js +47 -0
  217. package/dist/runtime/i18n/locales/fr.js +47 -0
  218. package/dist/runtime/i18n/types.d.ts +70 -0
  219. package/dist/runtime/shared/styles/tokens.css +1 -1
  220. package/dist/runtime/shared/types/query.d.ts +8 -0
  221. package/dist/runtime/table/types/index.d.ts +1 -0
  222. package/dist/runtime/table/types/remote-options.d.ts +64 -0
  223. package/dist/runtime/table/types/remote-options.js +0 -0
  224. package/dist/runtime/table/types/source.d.ts +10 -1
  225. package/dist/runtime/table/utils/builders/table-source.d.ts +2 -6
  226. package/dist/runtime/table/utils/index.d.ts +1 -0
  227. package/dist/runtime/table/utils/index.js +1 -0
  228. package/dist/runtime/table/utils/remote-table-options.d.ts +26 -0
  229. package/dist/runtime/table/utils/remote-table-options.js +88 -0
  230. package/package.json +4 -1
  231. package/dist/runtime/dashboard/composables/use-dashboard-param-scope.d.ts +0 -30
  232. package/dist/runtime/dashboard/composables/use-dashboard-param-scope.js +0 -71
  233. package/dist/runtime/dashboard/types/options.d.ts +0 -46
  234. package/dist/runtime/dashboard/types/params.d.ts +0 -115
  235. package/dist/runtime/dashboard/utils/builders/dashboard-params.d.ts +0 -85
  236. package/dist/runtime/dashboard/utils/builders/dashboard-params.js +0 -87
  237. /package/dist/runtime/dashboard/types/{options.js → controls.js} +0 -0
  238. /package/dist/runtime/dashboard/types/{params.js → filters.js} +0 -0
@@ -1,46 +0,0 @@
1
- import type { DashboardOption, DashboardOptionParamKeys, DashboardOptionValue } from './params.js';
2
- /**
3
- * Props ready to spread onto a Nuxt UI `USelectMenu`:
4
- * `<USelectMenu v-model="dashboard.params.account" v-bind="dashboard.options.account.menu" />`.
5
- */
6
- export interface DashboardOptionsMenuBindings<TValue extends DashboardOptionValue = DashboardOptionValue> {
7
- items: DashboardOption<TValue>[];
8
- valueKey: 'value';
9
- labelKey: 'label';
10
- loading?: boolean;
11
- searchTerm?: string;
12
- ignoreFilter?: boolean;
13
- 'onUpdate:searchTerm'?: (value: string) => void;
14
- 'onUpdate:open'?: (value: boolean) => void;
15
- }
16
- /**
17
- * Option state of an option-backed param (`p.enum`, `p.options`, `p.remote`).
18
- *
19
- * Remote handles load nothing until `open` becomes `true` (or `search` is set), then page through
20
- * the source; selected values restored from the URL are hydrated through `resolveSelected`.
21
- */
22
- export interface DashboardOptionsHandle<TValue extends DashboardOptionValue = DashboardOptionValue> {
23
- /** Loaded options merged with the hydrated selected options. */
24
- readonly items: readonly DashboardOption<TValue>[];
25
- /** Options matching the current param value, in value order. */
26
- readonly selected: readonly DashboardOption<TValue>[];
27
- readonly loading: boolean;
28
- readonly loadingMore: boolean;
29
- readonly hasMore: boolean;
30
- readonly error: unknown;
31
- /** Search term. Writable; remote sources debounce it before loading. */
32
- search: string;
33
- /** Picker open state. Writable; opening a remote picker starts loading its first page. */
34
- open: boolean;
35
- loadMore(): void;
36
- refresh(): Promise<void>;
37
- readonly menu: DashboardOptionsMenuBindings<TValue>;
38
- }
39
- /** Option value type of a param: its value, or its element type for `multiple` params. */
40
- type DashboardParamOptionValue<TParam> = TParam extends {
41
- readonly defaultValue: infer TValue;
42
- } ? Extract<NonNullable<TValue> extends readonly (infer TItem)[] ? TItem : NonNullable<TValue>, DashboardOptionValue> : never;
43
- export type DashboardOptionsHandles<TParams> = {
44
- readonly [K in DashboardOptionParamKeys<TParams>]: DashboardOptionsHandle<DashboardParamOptionValue<TParams[K]>>;
45
- };
46
- export {};
@@ -1,115 +0,0 @@
1
- import type { QueryKey } from '@tanstack/vue-query';
2
- import type { HistoryMode, QueryCodec, StaticQueryStateOptions } from '../../query-state/index.js';
3
- import type { RemoteOptionsPageRequest, RemoteOptionsPagination, RemoteOptionsResult, RemoteOptionsSearch } from '../../shared/types/remote-options.js';
4
- import type { dashboardParamBuilder } from '../utils/builders/dashboard-params.js';
5
- export type DashboardParamKind = 'string' | 'number' | 'boolean' | 'date' | 'dateRange' | 'enum' | 'options' | 'remote' | 'comparison' | 'custom';
6
- /**
7
- * Period a dashboard compares against: the one right before the current range (`previous`), the
8
- * same dates a year earlier (`year`), or no comparison (`none`).
9
- */
10
- export type DashboardComparison = 'previous' | 'year' | 'none';
11
- /** Primitive value an option-backed param can hold. */
12
- export type DashboardOptionValue = string | number;
13
- /**
14
- * Option item shape. It matches Nuxt UI `USelect` / `USelectMenu` items, so option handles can be
15
- * bound to those components directly.
16
- */
17
- export interface DashboardOption<TValue extends DashboardOptionValue = DashboardOptionValue> {
18
- value: TValue;
19
- label: string;
20
- description?: string;
21
- icon?: string;
22
- avatar?: {
23
- src?: string;
24
- alt?: string;
25
- text?: string;
26
- };
27
- disabled?: boolean;
28
- }
29
- export interface DashboardDateRange {
30
- start: Date;
31
- end: Date;
32
- }
33
- /** Options shared by every `p.*` param builder. */
34
- export interface DashboardParamOptions<TDefault> {
35
- /**
36
- * Value used when the URL key is absent or cannot be parsed.
37
- * A non-`undefined` default narrows the param type: `p.string()` is `string | undefined`,
38
- * `p.string({ defaultValue: '' })` is `string`. Values equal to the default never reach the URL.
39
- */
40
- defaultValue?: TDefault;
41
- /** Override the URL segment. Defaults to the param name inside its scope prefix. */
42
- urlKey?: string;
43
- /** Remove the key from the URL when the value equals the default. Defaults to `true`. */
44
- omitDefault?: boolean;
45
- /** Router history mode for writes to this param. Params default to `'replace'`. */
46
- historyMode?: HistoryMode;
47
- }
48
- /** Request received by a remote option source. */
49
- export interface DashboardRemoteOptionsRequest {
50
- /** Current debounced search term. Empty when the menu lists unfiltered options. */
51
- search: string;
52
- /** Requested page. */
53
- page: RemoteOptionsPageRequest;
54
- }
55
- /**
56
- * Remote option source, following the same contract as the form engine's remote options:
57
- * server-side search, page or cursor pagination, and hydration of selected values that the loaded
58
- * pages do not contain (for example ids restored from the URL).
59
- */
60
- export interface DashboardRemoteOptionsConfig {
61
- /** Loads one page of options for the current search term. */
62
- load: (request: DashboardRemoteOptionsRequest) => Promise<RemoteOptionsResult<DashboardOption<string>>>;
63
- /** Resolves labels for selected values missing from the loaded pages. */
64
- resolveSelected?: (request: {
65
- values: readonly string[];
66
- }) => Promise<readonly DashboardOption<string>[]>;
67
- /** Defaults to `{ type: 'page', size: 25 }`. */
68
- pagination?: RemoteOptionsPagination;
69
- search?: RemoteOptionsSearch;
70
- /** Cache identity of the option source. Defaults to a key derived from the param location. */
71
- queryKey?: QueryKey;
72
- }
73
- /** Runtime view of a param definition, with its value type erased. */
74
- export interface DashboardRuntimeParam extends DashboardParamLike {
75
- /** Erased codec, in the shape `useQueryStates` accepts for heterogeneous schemas. */
76
- readonly codec: StaticQueryStateOptions['codec'];
77
- readonly urlKey?: string;
78
- readonly omitDefault?: boolean;
79
- readonly historyMode?: HistoryMode;
80
- /** Static option items for `p.enum` and `p.options`. */
81
- readonly items?: readonly DashboardOption[];
82
- /** Remote option source for `p.remote`. */
83
- readonly remote?: DashboardRemoteOptionsConfig;
84
- }
85
- /**
86
- * Param definition produced by the `p.*` builders. `defaultValue` carries the resolved value type:
87
- * it includes `undefined` only when no default was declared.
88
- */
89
- export type DashboardParamDefinition<TValue> = Omit<DashboardRuntimeParam, 'codec' | 'defaultValue'> & {
90
- readonly codec: QueryCodec<TValue | undefined>;
91
- readonly defaultValue: TValue;
92
- };
93
- /** Structural constraint every param definition satisfies, whatever its value type. */
94
- export interface DashboardParamLike {
95
- readonly kind: DashboardParamKind;
96
- readonly multiple: boolean;
97
- readonly defaultValue: unknown;
98
- }
99
- export type DashboardParamMap = Record<string, DashboardParamLike>;
100
- /** Empty map used when a scope declares no params, queries, or derived values. */
101
- export type DashboardEmptyMap = Record<never, never>;
102
- /** Writable, URL-synced values of a param map. Every property is a `v-model` target. */
103
- export type DashboardParamValues<TParams> = {
104
- -readonly [K in keyof TParams]: TParams[K] extends {
105
- readonly defaultValue: infer TValue;
106
- } ? TValue : never;
107
- };
108
- /** Keys of params that carry option items (`p.enum`, `p.options`, `p.remote`, `p.comparison`). */
109
- export type DashboardOptionParamKeys<TParams> = {
110
- [K in keyof TParams]: TParams[K] extends {
111
- readonly kind: 'enum' | 'options' | 'remote' | 'comparison';
112
- } ? K : never;
113
- }[keyof TParams];
114
- /** The `p` builder handed to every `params` callback. */
115
- export type DashboardParamBuilder = typeof dashboardParamBuilder;
@@ -1,85 +0,0 @@
1
- import type { QueryCodec } from '../../../query-state/index.js';
2
- import type { DashboardComparison, DashboardDateRange, DashboardOption, DashboardOptionValue, DashboardParamDefinition, DashboardParamOptions, DashboardRemoteOptionsConfig } from '../../types/index.js';
3
- type ResolveParamValue<TValue, TDefault> = undefined extends TDefault ? TValue | undefined : TValue;
4
- declare function stringParam<const TDefault extends string | undefined = undefined>(options?: DashboardParamOptions<TDefault>): DashboardParamDefinition<ResolveParamValue<string, TDefault>> & {
5
- readonly kind: 'string';
6
- };
7
- declare function numberParam<const TDefault extends number | undefined = undefined>(options?: DashboardParamOptions<TDefault>): DashboardParamDefinition<ResolveParamValue<number, TDefault>> & {
8
- readonly kind: 'number';
9
- };
10
- declare function booleanParam<const TDefault extends boolean | undefined = undefined>(options?: DashboardParamOptions<TDefault>): DashboardParamDefinition<ResolveParamValue<boolean, TDefault>> & {
11
- readonly kind: 'boolean';
12
- };
13
- declare function dateParam<const TDefault extends Date | undefined = undefined>(options?: DashboardParamOptions<TDefault>): DashboardParamDefinition<ResolveParamValue<Date, TDefault>> & {
14
- readonly kind: 'date';
15
- };
16
- declare function dateRangeParam<const TDefault extends DashboardDateRange | undefined = undefined>(options?: DashboardParamOptions<TDefault>): DashboardParamDefinition<ResolveParamValue<DashboardDateRange, TDefault>> & {
17
- readonly kind: 'dateRange';
18
- };
19
- declare function enumParam<const TValues extends readonly DashboardOptionValue[]>(values: TValues, options: DashboardParamOptions<readonly TValues[number][]> & {
20
- multiple: true;
21
- }): DashboardParamDefinition<TValues[number][]> & {
22
- readonly kind: 'enum';
23
- };
24
- declare function enumParam<const TValues extends readonly DashboardOptionValue[], const TDefault extends TValues[number] | undefined = undefined>(values: TValues, options?: DashboardParamOptions<TDefault> & {
25
- multiple?: false;
26
- }): DashboardParamDefinition<ResolveParamValue<TValues[number], TDefault>> & {
27
- readonly kind: 'enum';
28
- };
29
- declare function optionsParam<const TItems extends readonly DashboardOption[]>(items: TItems, options: DashboardParamOptions<readonly TItems[number]['value'][]> & {
30
- multiple: true;
31
- }): DashboardParamDefinition<TItems[number]['value'][]> & {
32
- readonly kind: 'options';
33
- };
34
- declare function optionsParam<const TItems extends readonly DashboardOption[], const TDefault extends TItems[number]['value'] | undefined = undefined>(items: TItems, options?: DashboardParamOptions<TDefault> & {
35
- multiple?: false;
36
- }): DashboardParamDefinition<ResolveParamValue<TItems[number]['value'], TDefault>> & {
37
- readonly kind: 'options';
38
- };
39
- declare function remoteParam(config: DashboardRemoteOptionsConfig & DashboardParamOptions<readonly string[]> & {
40
- multiple: true;
41
- }): DashboardParamDefinition<string[]> & {
42
- readonly kind: 'remote';
43
- };
44
- declare function remoteParam<const TDefault extends string | undefined = undefined>(config: DashboardRemoteOptionsConfig & DashboardParamOptions<TDefault> & {
45
- multiple?: false;
46
- }): DashboardParamDefinition<ResolveParamValue<string, TDefault>> & {
47
- readonly kind: 'remote';
48
- };
49
- /** Values of `p.comparison`, in menu order. */
50
- export declare const DASHBOARD_COMPARISONS: readonly ["previous", "year", "none"];
51
- declare function comparisonParam<const TDefault extends DashboardComparison | undefined = undefined>(options?: DashboardParamOptions<TDefault>): DashboardParamDefinition<ResolveParamValue<DashboardComparison, TDefault>> & {
52
- readonly kind: 'comparison';
53
- };
54
- declare function customParam<TValue, const TDefault extends TValue | undefined = undefined>(codec: QueryCodec<TValue>, options?: DashboardParamOptions<TDefault>): DashboardParamDefinition<ResolveParamValue<TValue, TDefault>> & {
55
- readonly kind: 'custom';
56
- };
57
- /**
58
- * The `p` builder handed to every `params` callback. Each method declares one typed, URL-synced
59
- * param; the engine renders no controls, the app binds `v-model` to the resulting value.
60
- *
61
- * Every param accepts `defaultValue` (narrows away `undefined`), `urlKey`, `omitDefault`, and
62
- * `historyMode`. Option-backed params (`enum`, `options`, `remote`) also accept `multiple: true`,
63
- * which turns the value into an always-defined array.
64
- */
65
- export declare const dashboardParamBuilder: {
66
- boolean: typeof booleanParam;
67
- /**
68
- * Comparison period: `'previous'`, `'year'`, or `'none'`. Its option handle carries localized
69
- * labels; `resolveDashboardComparisonRange(range, mode)` turns it into the range to fetch.
70
- */
71
- comparison: typeof comparisonParam;
72
- custom: typeof customParam;
73
- date: typeof dateParam;
74
- /** Inclusive date range, serialized as `YYYY-MM-DD..YYYY-MM-DD`. */
75
- dateRange: typeof dateRangeParam;
76
- /** Value(s) from a literal list, e.g. `p.enum([2024, 2025, 2026], { defaultValue: 2026 })`. */
77
- enum: typeof enumParam;
78
- number: typeof numberParam;
79
- /** Value(s) from labeled items: `{ value, label, icon?, avatar?, description? }`. */
80
- options: typeof optionsParam;
81
- /** Id(s) picked from a remote, searchable, paginated option source. */
82
- remote: typeof remoteParam;
83
- string: typeof stringParam;
84
- };
85
- export {};
@@ -1,87 +0,0 @@
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
- };