nuxt-ui-tools 1.0.0 → 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.
- package/dist/module.d.mts +3 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +37 -0
- package/dist/runtime/dashboard/components/block/dashboard-block-state.d.vue.ts +12 -0
- package/dist/runtime/dashboard/components/block/dashboard-block-state.vue +59 -0
- package/dist/runtime/dashboard/components/block/dashboard-block-state.vue.d.ts +12 -0
- package/dist/runtime/dashboard/components/block/dashboard-data-table.d.vue.ts +9 -0
- package/dist/runtime/dashboard/components/block/dashboard-data-table.vue +47 -0
- package/dist/runtime/dashboard/components/block/dashboard-data-table.vue.d.ts +9 -0
- package/dist/runtime/dashboard/components/block/dashboard-ring.d.vue.ts +34 -0
- package/dist/runtime/dashboard/components/block/dashboard-ring.vue +91 -0
- package/dist/runtime/dashboard/components/block/dashboard-ring.vue.d.ts +34 -0
- package/dist/runtime/dashboard/components/block/dashboard-row-actions.d.vue.ts +13 -0
- package/dist/runtime/dashboard/components/block/dashboard-row-actions.vue +49 -0
- package/dist/runtime/dashboard/components/block/dashboard-row-actions.vue.d.ts +13 -0
- package/dist/runtime/dashboard/components/block/dashboard-skeleton.d.vue.ts +34 -0
- package/dist/runtime/dashboard/components/block/dashboard-skeleton.vue +312 -0
- package/dist/runtime/dashboard/components/block/dashboard-skeleton.vue.d.ts +34 -0
- package/dist/runtime/dashboard/components/charts/renderer.d.ts +43 -0
- package/dist/runtime/dashboard/components/charts/renderer.js +34 -0
- package/dist/runtime/dashboard/components/charts/unovis/dashboard-donut-chart.d.vue.ts +18 -0
- package/dist/runtime/dashboard/components/charts/unovis/dashboard-donut-chart.vue +45 -0
- package/dist/runtime/dashboard/components/charts/unovis/dashboard-donut-chart.vue.d.ts +18 -0
- package/dist/runtime/dashboard/components/charts/unovis/dashboard-xy-chart.d.vue.ts +14 -0
- package/dist/runtime/dashboard/components/charts/unovis/dashboard-xy-chart.vue +190 -0
- package/dist/runtime/dashboard/components/charts/unovis/dashboard-xy-chart.vue.d.ts +14 -0
- package/dist/runtime/dashboard/components/charts/unovis/dashboard-xy-marks.d.vue.ts +13 -0
- package/dist/runtime/dashboard/components/charts/unovis/dashboard-xy-marks.vue +72 -0
- package/dist/runtime/dashboard/components/charts/unovis/dashboard-xy-marks.vue.d.ts +13 -0
- package/dist/runtime/dashboard/components/charts/unovis/xy-layers.d.ts +43 -0
- package/dist/runtime/dashboard/components/charts/unovis/xy-layers.js +60 -0
- package/dist/runtime/dashboard/components/dashboard-alerts.d.vue.ts +49 -0
- package/dist/runtime/dashboard/components/dashboard-alerts.vue +226 -0
- package/dist/runtime/dashboard/components/dashboard-alerts.vue.d.ts +49 -0
- package/dist/runtime/dashboard/components/dashboard-bar-chart.d.vue.ts +53 -0
- package/dist/runtime/dashboard/components/dashboard-bar-chart.vue +131 -0
- package/dist/runtime/dashboard/components/dashboard-bar-chart.vue.d.ts +53 -0
- package/dist/runtime/dashboard/components/dashboard-bars.d.vue.ts +49 -0
- package/dist/runtime/dashboard/components/dashboard-bars.vue +187 -0
- package/dist/runtime/dashboard/components/dashboard-bars.vue.d.ts +49 -0
- package/dist/runtime/dashboard/components/dashboard-card.d.vue.ts +47 -0
- package/dist/runtime/dashboard/components/dashboard-card.vue +316 -0
- package/dist/runtime/dashboard/components/dashboard-card.vue.d.ts +47 -0
- package/dist/runtime/dashboard/components/dashboard-combo-chart.d.vue.ts +52 -0
- package/dist/runtime/dashboard/components/dashboard-combo-chart.vue +128 -0
- package/dist/runtime/dashboard/components/dashboard-combo-chart.vue.d.ts +52 -0
- package/dist/runtime/dashboard/components/dashboard-donut-chart.d.vue.ts +48 -0
- package/dist/runtime/dashboard/components/dashboard-donut-chart.vue +216 -0
- package/dist/runtime/dashboard/components/dashboard-donut-chart.vue.d.ts +48 -0
- package/dist/runtime/dashboard/components/dashboard-feed.d.vue.ts +49 -0
- package/dist/runtime/dashboard/components/dashboard-feed.vue +238 -0
- package/dist/runtime/dashboard/components/dashboard-feed.vue.d.ts +49 -0
- package/dist/runtime/dashboard/components/dashboard-funnel.d.vue.ts +34 -0
- package/dist/runtime/dashboard/components/dashboard-funnel.vue +157 -0
- package/dist/runtime/dashboard/components/dashboard-funnel.vue.d.ts +34 -0
- package/dist/runtime/dashboard/components/dashboard-gauge.d.vue.ts +55 -0
- package/dist/runtime/dashboard/components/dashboard-gauge.vue +177 -0
- package/dist/runtime/dashboard/components/dashboard-gauge.vue.d.ts +55 -0
- package/dist/runtime/dashboard/components/dashboard-grid.d.vue.ts +38 -0
- package/dist/runtime/dashboard/components/dashboard-grid.vue +49 -0
- package/dist/runtime/dashboard/components/dashboard-grid.vue.d.ts +38 -0
- package/dist/runtime/dashboard/components/dashboard-legend.d.vue.ts +8 -0
- package/dist/runtime/dashboard/components/dashboard-legend.vue +37 -0
- package/dist/runtime/dashboard/components/dashboard-legend.vue.d.ts +8 -0
- package/dist/runtime/dashboard/components/dashboard-line-chart.d.vue.ts +46 -0
- package/dist/runtime/dashboard/components/dashboard-line-chart.vue +129 -0
- package/dist/runtime/dashboard/components/dashboard-line-chart.vue.d.ts +46 -0
- package/dist/runtime/dashboard/components/dashboard-list.d.vue.ts +63 -0
- package/dist/runtime/dashboard/components/dashboard-list.vue +239 -0
- package/dist/runtime/dashboard/components/dashboard-list.vue.d.ts +63 -0
- package/dist/runtime/dashboard/components/dashboard-paired-bars.d.vue.ts +43 -0
- package/dist/runtime/dashboard/components/dashboard-paired-bars.vue +194 -0
- package/dist/runtime/dashboard/components/dashboard-paired-bars.vue.d.ts +43 -0
- package/dist/runtime/dashboard/components/dashboard-refresh.d.vue.ts +29 -0
- package/dist/runtime/dashboard/components/dashboard-refresh.vue +86 -0
- package/dist/runtime/dashboard/components/dashboard-refresh.vue.d.ts +29 -0
- package/dist/runtime/dashboard/components/dashboard-relative-time.d.vue.ts +12 -0
- package/dist/runtime/dashboard/components/dashboard-relative-time.vue +23 -0
- package/dist/runtime/dashboard/components/dashboard-relative-time.vue.d.ts +12 -0
- package/dist/runtime/dashboard/components/dashboard-stack-bar.d.vue.ts +36 -0
- package/dist/runtime/dashboard/components/dashboard-stack-bar.vue +162 -0
- package/dist/runtime/dashboard/components/dashboard-stack-bar.vue.d.ts +36 -0
- package/dist/runtime/dashboard/components/dashboard-stat.d.vue.ts +69 -0
- package/dist/runtime/dashboard/components/dashboard-stat.vue +279 -0
- package/dist/runtime/dashboard/components/dashboard-stat.vue.d.ts +69 -0
- package/dist/runtime/dashboard/components/dashboard-stats.d.vue.ts +38 -0
- package/dist/runtime/dashboard/components/dashboard-stats.vue +202 -0
- package/dist/runtime/dashboard/components/dashboard-stats.vue.d.ts +38 -0
- package/dist/runtime/dashboard/components/dashboard-table.d.vue.ts +52 -0
- package/dist/runtime/dashboard/components/dashboard-table.vue +305 -0
- package/dist/runtime/dashboard/components/dashboard-table.vue.d.ts +52 -0
- package/dist/runtime/dashboard/components/dashboard-tabs.d.vue.ts +35 -0
- package/dist/runtime/dashboard/components/dashboard-tabs.vue +55 -0
- package/dist/runtime/dashboard/components/dashboard-tabs.vue.d.ts +35 -0
- package/dist/runtime/dashboard/components/dashboard-total.d.vue.ts +10 -0
- package/dist/runtime/dashboard/components/dashboard-total.vue +32 -0
- package/dist/runtime/dashboard/components/dashboard-total.vue.d.ts +10 -0
- package/dist/runtime/dashboard/components/dashboard-widget.d.vue.ts +46 -0
- package/dist/runtime/dashboard/components/dashboard-widget.vue +84 -0
- package/dist/runtime/dashboard/components/dashboard-widget.vue.d.ts +46 -0
- package/dist/runtime/dashboard/composables/use-dashboard-api.d.ts +15 -0
- package/dist/runtime/dashboard/composables/use-dashboard-api.js +91 -0
- package/dist/runtime/dashboard/composables/use-dashboard-block.d.ts +22 -0
- package/dist/runtime/dashboard/composables/use-dashboard-block.js +35 -0
- package/dist/runtime/dashboard/composables/use-dashboard-chart.d.ts +36 -0
- package/dist/runtime/dashboard/composables/use-dashboard-chart.js +118 -0
- package/dist/runtime/dashboard/composables/use-dashboard-derived.d.ts +12 -0
- package/dist/runtime/dashboard/composables/use-dashboard-derived.js +47 -0
- package/dist/runtime/dashboard/composables/use-dashboard-format.d.ts +6 -0
- package/dist/runtime/dashboard/composables/use-dashboard-format.js +12 -0
- package/dist/runtime/dashboard/composables/use-dashboard-options.d.ts +8 -0
- package/dist/runtime/dashboard/composables/use-dashboard-options.js +63 -0
- package/dist/runtime/dashboard/composables/use-dashboard-param-scope.d.ts +30 -0
- package/dist/runtime/dashboard/composables/use-dashboard-param-scope.js +71 -0
- package/dist/runtime/dashboard/composables/use-dashboard-remote-options.d.ts +12 -0
- package/dist/runtime/dashboard/composables/use-dashboard-remote-options.js +117 -0
- package/dist/runtime/dashboard/composables/use-dashboard-resource.d.ts +35 -0
- package/dist/runtime/dashboard/composables/use-dashboard-resource.js +80 -0
- package/dist/runtime/dashboard/composables/use-dashboard-scope.d.ts +46 -0
- package/dist/runtime/dashboard/composables/use-dashboard-scope.js +127 -0
- package/dist/runtime/dashboard/composables/use-dashboard-time.d.ts +13 -0
- package/dist/runtime/dashboard/composables/use-dashboard-time.js +40 -0
- package/dist/runtime/dashboard/composables/use-dashboard-ui.d.ts +22 -0
- package/dist/runtime/dashboard/composables/use-dashboard-ui.js +19 -0
- package/dist/runtime/dashboard/composables/use-dashboard-views.d.ts +46 -0
- package/dist/runtime/dashboard/composables/use-dashboard-views.js +49 -0
- package/dist/runtime/dashboard/composables/use-dashboard.d.ts +24 -0
- package/dist/runtime/dashboard/composables/use-dashboard.js +42 -0
- package/dist/runtime/dashboard/constants/query.d.ts +16 -0
- package/dist/runtime/dashboard/constants/query.js +15 -0
- package/dist/runtime/dashboard/index.d.ts +4 -0
- package/dist/runtime/dashboard/index.js +3 -0
- package/dist/runtime/dashboard/schema/index.d.ts +57 -0
- package/dist/runtime/dashboard/schema/index.js +3 -0
- package/dist/runtime/dashboard/types/blocks.d.ts +251 -0
- package/dist/runtime/dashboard/types/blocks.js +0 -0
- package/dist/runtime/dashboard/types/charts.d.ts +60 -0
- package/dist/runtime/dashboard/types/charts.js +0 -0
- package/dist/runtime/dashboard/types/index.d.ts +7 -0
- package/dist/runtime/dashboard/types/index.js +0 -0
- package/dist/runtime/dashboard/types/options.d.ts +46 -0
- package/dist/runtime/dashboard/types/options.js +0 -0
- package/dist/runtime/dashboard/types/params.d.ts +115 -0
- package/dist/runtime/dashboard/types/params.js +0 -0
- package/dist/runtime/dashboard/types/resource.d.ts +106 -0
- package/dist/runtime/dashboard/types/resource.js +0 -0
- package/dist/runtime/dashboard/types/runtime.d.ts +44 -0
- package/dist/runtime/dashboard/types/runtime.js +0 -0
- package/dist/runtime/dashboard/types/schema.d.ts +171 -0
- package/dist/runtime/dashboard/types/schema.js +0 -0
- package/dist/runtime/dashboard/types/ui.d.ts +201 -0
- package/dist/runtime/dashboard/types/ui.js +0 -0
- package/dist/runtime/dashboard/utils/builders/dashboard-params.d.ts +85 -0
- package/dist/runtime/dashboard/utils/builders/dashboard-params.js +87 -0
- package/dist/runtime/dashboard/utils/chart-frame.d.ts +5 -0
- package/dist/runtime/dashboard/utils/chart-frame.js +27 -0
- package/dist/runtime/dashboard/utils/charts.d.ts +61 -0
- package/dist/runtime/dashboard/utils/charts.js +142 -0
- package/dist/runtime/dashboard/utils/comparison.d.ts +15 -0
- package/dist/runtime/dashboard/utils/comparison.js +19 -0
- package/dist/runtime/dashboard/utils/export.d.ts +13 -0
- package/dist/runtime/dashboard/utils/export.js +45 -0
- package/dist/runtime/dashboard/utils/options.d.ts +12 -0
- package/dist/runtime/dashboard/utils/options.js +23 -0
- package/dist/runtime/dashboard/utils/params/codecs.d.ts +14 -0
- package/dist/runtime/dashboard/utils/params/codecs.js +69 -0
- package/dist/runtime/dashboard/utils/resource.d.ts +16 -0
- package/dist/runtime/dashboard/utils/resource.js +39 -0
- package/dist/runtime/dashboard/utils/schema.d.ts +9 -0
- package/dist/runtime/dashboard/utils/schema.js +31 -0
- package/dist/runtime/dashboard/utils/sparkline.d.ts +21 -0
- package/dist/runtime/dashboard/utils/sparkline.js +53 -0
- package/dist/runtime/dashboard/utils/state.d.ts +28 -0
- package/dist/runtime/dashboard/utils/state.js +32 -0
- package/dist/runtime/dashboard/utils/time.d.ts +17 -0
- package/dist/runtime/dashboard/utils/time.js +60 -0
- package/dist/runtime/dashboard/utils/tracker.d.ts +12 -0
- package/dist/runtime/dashboard/utils/tracker.js +31 -0
- package/dist/runtime/dashboard/utils/ui.d.ts +38 -0
- package/dist/runtime/dashboard/utils/ui.js +24 -0
- package/dist/runtime/dashboard/utils/visibility.d.ts +2 -0
- package/dist/runtime/dashboard/utils/visibility.js +25 -0
- package/dist/runtime/form/components/root/form.vue +1 -1
- package/dist/runtime/form/composables/use-form-validation.d.ts +2 -3
- package/dist/runtime/form/composables/use-form-validation.js +24 -112
- package/dist/runtime/form/composables/use-form.js +1 -1
- package/dist/runtime/form/fields/password/component.vue +132 -28
- package/dist/runtime/form/fields/password/types.d.ts +6 -0
- package/dist/runtime/form/fields/text/component.vue +7 -2
- package/dist/runtime/form/types/field.d.ts +1 -1
- package/dist/runtime/form/types/options.d.ts +15 -36
- package/dist/runtime/form/types/validation.d.ts +3 -20
- package/dist/runtime/form/utils/state.d.ts +1 -14
- package/dist/runtime/form/utils/state.js +0 -199
- package/dist/runtime/i18n/locales/en.js +63 -0
- package/dist/runtime/i18n/locales/fr.js +63 -0
- package/dist/runtime/i18n/types.d.ts +68 -0
- package/dist/runtime/shared/index.d.ts +2 -0
- package/dist/runtime/shared/styles/tokens.css +1 -1
- package/dist/runtime/shared/types/query.d.ts +10 -0
- package/dist/runtime/shared/types/query.js +0 -0
- package/dist/runtime/shared/types/remote-options.d.ts +37 -0
- package/dist/runtime/shared/types/remote-options.js +0 -0
- package/dist/runtime/spreadsheet/components/layout/spreadsheet-import-footer.d.vue.ts +2 -2
- package/dist/runtime/spreadsheet/components/layout/spreadsheet-import-footer.vue.d.ts +2 -2
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-internals.d.ts +15 -15
- package/dist/runtime/spreadsheet/composables/use-spreadsheet-resolutions.d.ts +2 -2
- package/dist/runtime/spreadsheet/schema/normalize.d.ts +1 -1
- package/dist/runtime/spreadsheet/utils/references/sources.d.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-content.d.vue.ts +20 -18
- package/dist/runtime/table/components/data-list/data-list-content.vue +14 -87
- package/dist/runtime/table/components/data-list/data-list-content.vue.d.ts +20 -18
- package/dist/runtime/table/components/data-list/data-list-default.d.vue.ts +1 -4
- package/dist/runtime/table/components/data-list/data-list-default.vue.d.ts +1 -4
- package/dist/runtime/table/components/data-list/data-list-error-state.d.vue.ts +13 -0
- package/dist/runtime/table/components/data-list/data-list-error-state.vue +91 -0
- package/dist/runtime/table/components/data-list/data-list-error-state.vue.d.ts +13 -0
- package/dist/runtime/table/components/data-list/data-list-infinite-loader.d.vue.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-infinite-loader.vue.d.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-layout-switch.d.vue.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-layout-switch.vue +1 -1
- package/dist/runtime/table/components/data-list/data-list-layout-switch.vue.d.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-pagination.d.vue.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-pagination.vue.d.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-refresh.vue +42 -4
- package/dist/runtime/table/components/data-list/data-list-root.d.vue.ts +1 -9
- package/dist/runtime/table/components/data-list/data-list-root.vue.d.ts +1 -9
- package/dist/runtime/table/components/data-list/data-list-sort-menu.d.vue.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-sort-menu.vue +11 -5
- package/dist/runtime/table/components/data-list/data-list-sort-menu.vue.d.ts +1 -1
- package/dist/runtime/table/components/data-list/sort-menu-panel.d.vue.ts +2 -2
- package/dist/runtime/table/components/data-list/sort-menu-panel.vue.d.ts +2 -2
- package/dist/runtime/table/components/data-list.d.vue.ts +2 -13
- package/dist/runtime/table/components/data-list.vue.d.ts +2 -13
- package/dist/runtime/table/components/drawers/column-panel.vue +7 -2
- package/dist/runtime/table/components/filters/panel/filter-panel-chips.vue +2 -5
- package/dist/runtime/table/components/filters/panel/option-filter-panel-field.vue +1 -1
- package/dist/runtime/table/components/filters/shared/dynamic-filter-picker.d.vue.ts +2 -2
- package/dist/runtime/table/components/filters/shared/dynamic-filter-picker.vue +103 -101
- package/dist/runtime/table/components/filters/shared/dynamic-filter-picker.vue.d.ts +2 -2
- package/dist/runtime/table/components/filters/shared/filter-match-mode-button.d.vue.ts +1 -1
- package/dist/runtime/table/components/filters/shared/filter-match-mode-button.vue.d.ts +1 -1
- package/dist/runtime/table/components/filters/shared/filter-option-multiple-list.vue +2 -2
- package/dist/runtime/table/components/filters/shared/filter-option-picker-content.vue +3 -3
- package/dist/runtime/table/components/filters/shared/filter-option-single-list.vue +1 -1
- package/dist/runtime/table/components/filters/shared/filter-popover-shell.d.vue.ts +3 -3
- package/dist/runtime/table/components/filters/shared/filter-popover-shell.vue +17 -15
- package/dist/runtime/table/components/filters/shared/filter-popover-shell.vue.d.ts +3 -3
- package/dist/runtime/table/components/filters/shared/filter-searchable-panel.vue +10 -2
- package/dist/runtime/table/components/filters/sheet/filter-sheet.vue +4 -3
- package/dist/runtime/table/components/filters/tags/filter-tags-bar.vue +1 -1
- package/dist/runtime/table/components/grid/grid-renderer.vue +2 -4
- package/dist/runtime/table/components/layout/table-footer.d.vue.ts +1 -1
- package/dist/runtime/table/components/layout/table-footer.vue.d.ts +1 -1
- package/dist/runtime/table/components/table/table-cell-ellipsis.d.ts +1 -1
- package/dist/runtime/table/components/table/table-renderer.d.vue.ts +8 -2
- package/dist/runtime/table/components/table/table-renderer.vue +24 -6
- package/dist/runtime/table/components/table/table-renderer.vue.d.ts +8 -2
- package/dist/runtime/table/composables/use-option-filter-editor-state.d.ts +1 -0
- package/dist/runtime/table/composables/use-option-filter-editor-state.js +2 -2
- package/dist/runtime/table/composables/use-query-state.d.ts +3 -3
- package/dist/runtime/table/composables/use-table-actions.js +10 -5
- package/dist/runtime/table/composables/use-table-api.js +4 -1
- package/dist/runtime/table/composables/use-table-columns.d.ts +9 -5
- package/dist/runtime/table/composables/use-table-data.d.ts +2 -1
- package/dist/runtime/table/composables/use-table-data.js +19 -2
- package/dist/runtime/table/composables/use-table-filter-options.d.ts +1 -0
- package/dist/runtime/table/composables/use-table-filter-options.js +2 -1
- package/dist/runtime/table/composables/use-table-internals.d.ts +45 -33
- package/dist/runtime/table/composables/use-table-pagination.d.ts +2 -2
- package/dist/runtime/table/composables/use-table-selection.d.ts +1 -1
- package/dist/runtime/table/composables/use-table-state.d.ts +3 -3
- package/dist/runtime/table/types/actions.d.ts +3 -2
- package/dist/runtime/table/types/data-list.d.ts +8 -0
- package/dist/runtime/table/types/source.d.ts +14 -6
- package/dist/runtime/table/utils/builders/table-source.d.ts +14 -15
- package/dist/runtime/table/utils/client-query.d.ts +1 -1
- package/dist/runtime/table/utils/columns/menu.d.ts +1 -1
- package/dist/runtime/table/utils/columns/render.d.ts +13 -5
- package/dist/runtime/table/utils/columns/render.js +3 -2
- package/dist/runtime/table/utils/columns/state.d.ts +1 -1
- package/dist/runtime/table/utils/data-list-ui.d.ts +1 -1
- package/dist/runtime/table/utils/filters/editor-size.js +9 -9
- package/dist/runtime/table/utils/filters/options.js +6 -1
- package/dist/runtime/table/utils/index.d.ts +1 -0
- package/dist/runtime/table/utils/index.js +1 -0
- package/dist/runtime/table/utils/prefetch.js +5 -1
- package/dist/runtime/table/utils/source-request.d.ts +2 -0
- package/dist/runtime/table/utils/source-request.js +9 -0
- package/package.json +28 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SVG paths of a sparkline: the line, and the area under it closed on the baseline. `null` values
|
|
3
|
+
* leave gaps (each run of defined values is its own segment). The vertical range spans the data,
|
|
4
|
+
* so small variations stay visible.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveDashboardSparkline(values: readonly (number | null | undefined)[]): {
|
|
7
|
+
area: string;
|
|
8
|
+
line: string;
|
|
9
|
+
} | null;
|
|
10
|
+
/**
|
|
11
|
+
* Mini bars in the sparkline viewBox, one per value, scaled from zero to the largest value (a bar
|
|
12
|
+
* compares magnitudes, so its baseline stays at zero). `null` values leave an empty slot; the last
|
|
13
|
+
* bar is flagged, the latest period being the one a KPI reports.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveDashboardSparkBars(values: readonly (number | null | undefined)[]): {
|
|
16
|
+
height: number;
|
|
17
|
+
last: boolean;
|
|
18
|
+
width: number;
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
}[] | null;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const WIDTH = 100;
|
|
2
|
+
const HEIGHT = 32;
|
|
3
|
+
const INSET = 2;
|
|
4
|
+
export function resolveDashboardSparkline(values) {
|
|
5
|
+
const finite = values.filter((value) => Number.isFinite(value));
|
|
6
|
+
if (finite.length === 0) return null;
|
|
7
|
+
const min = Math.min(...finite);
|
|
8
|
+
const max = Math.max(...finite);
|
|
9
|
+
const step = values.length > 1 ? WIDTH / (values.length - 1) : 0;
|
|
10
|
+
const y = (value) => max === min ? HEIGHT / 2 : INSET + (1 - (value - min) / (max - min)) * (HEIGHT - INSET * 2);
|
|
11
|
+
const runs = [];
|
|
12
|
+
let run = [];
|
|
13
|
+
values.forEach((value, index) => {
|
|
14
|
+
if (value === null || value === void 0 || !Number.isFinite(value)) {
|
|
15
|
+
if (run.length) runs.push(run);
|
|
16
|
+
run = [];
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
run.push([values.length > 1 ? index * step : WIDTH / 2, y(value)]);
|
|
20
|
+
});
|
|
21
|
+
if (run.length) runs.push(run);
|
|
22
|
+
const line = runs.map(toPath).join("");
|
|
23
|
+
const area = runs.filter((points) => points.length > 1).map((points) => {
|
|
24
|
+
const first = points[0];
|
|
25
|
+
const last = points.at(-1);
|
|
26
|
+
if (!first || !last) return "";
|
|
27
|
+
return `${toPath(points)}L${last[0].toFixed(2)},${HEIGHT}L${first[0].toFixed(2)},${HEIGHT}Z`;
|
|
28
|
+
}).join("");
|
|
29
|
+
return { area, line };
|
|
30
|
+
}
|
|
31
|
+
export function resolveDashboardSparkBars(values) {
|
|
32
|
+
const finite = values.filter((value) => Number.isFinite(value));
|
|
33
|
+
if (finite.length === 0) return null;
|
|
34
|
+
const max = Math.max(0, ...finite);
|
|
35
|
+
const slot = WIDTH / Math.max(1, values.length);
|
|
36
|
+
const width = Math.max(1, slot * 0.62);
|
|
37
|
+
return values.flatMap((value, index) => {
|
|
38
|
+
if (value === null || value === void 0 || !Number.isFinite(value)) return [];
|
|
39
|
+
const height = max > 0 ? Math.max(1.5, Math.max(0, value) / max * (HEIGHT - INSET)) : 1.5;
|
|
40
|
+
return [
|
|
41
|
+
{
|
|
42
|
+
height: Number(height.toFixed(2)),
|
|
43
|
+
last: index === values.length - 1,
|
|
44
|
+
width: Number(width.toFixed(2)),
|
|
45
|
+
x: Number((index * slot + (slot - width) / 2).toFixed(2)),
|
|
46
|
+
y: Number((HEIGHT - height).toFixed(2))
|
|
47
|
+
}
|
|
48
|
+
];
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function toPath(points) {
|
|
52
|
+
return points.map(([x, y], index) => `${index ? "L" : "M"}${x.toFixed(2)},${y.toFixed(2)}`).join("");
|
|
53
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { DashboardResourceState } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Combines the states of several sources the way a dependent value experiences them: any error
|
|
4
|
+
* wins, then any pending source. Idle sources were not requested (gated by `requires`, or a
|
|
5
|
+
* deferred query nobody activated), so they do not hold the value back unless all are idle.
|
|
6
|
+
*/
|
|
7
|
+
export declare function combineDashboardStates(states: readonly DashboardResourceState[]): DashboardResourceState;
|
|
8
|
+
/** Oldest defined timestamp of a set of sources: they are all at least this fresh. */
|
|
9
|
+
export declare function resolveDashboardUpdatedAt(values: readonly (number | undefined)[]): number | undefined;
|
|
10
|
+
/** Refreshes sources in parallel and reports every failure at once. */
|
|
11
|
+
export declare function refreshDashboardSources(sources: readonly {
|
|
12
|
+
refresh: () => Promise<void>;
|
|
13
|
+
}[]): Promise<void>;
|
|
14
|
+
/** URL segment of the current view. A root param cannot use it while the dashboard has views. */
|
|
15
|
+
export declare const DASHBOARD_VIEW_URL_KEY = "view";
|
|
16
|
+
/** URL segment of the auto-refresh interval. A root param cannot use it. */
|
|
17
|
+
export declare const DASHBOARD_REFRESH_URL_KEY = "refresh";
|
|
18
|
+
/** URL key of the auto-refresh interval: `refresh`, or `<urlPrefix>.refresh`. */
|
|
19
|
+
export declare function resolveDashboardRefreshKey(urlPrefix: string | undefined): string;
|
|
20
|
+
/** Joins the non-empty segments of a URL key with dots. */
|
|
21
|
+
export declare function joinDashboardUrlKey(...segments: readonly (string | undefined)[]): string;
|
|
22
|
+
/**
|
|
23
|
+
* URL key prefix of one scope, named after what it holds: none for the root (`year`), the view
|
|
24
|
+
* key for a view (`consumption.currency`). `urlPrefix` namespaces both when set.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveDashboardScopePrefix(urlPrefix: string | undefined, viewKey?: string): string;
|
|
27
|
+
/** URL key of the current view: `view`, or `<urlPrefix>.view`. */
|
|
28
|
+
export declare function resolveDashboardViewKey(urlPrefix: string | undefined): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function combineDashboardStates(states) {
|
|
2
|
+
if (states.includes("error")) return "error";
|
|
3
|
+
if (states.includes("loading")) return "loading";
|
|
4
|
+
if (states.length > 0 && states.every((state) => state === "idle")) return "idle";
|
|
5
|
+
return "ready";
|
|
6
|
+
}
|
|
7
|
+
export function resolveDashboardUpdatedAt(values) {
|
|
8
|
+
let oldest;
|
|
9
|
+
for (const value of values) {
|
|
10
|
+
if (value !== void 0 && (oldest === void 0 || value < oldest)) oldest = value;
|
|
11
|
+
}
|
|
12
|
+
return oldest;
|
|
13
|
+
}
|
|
14
|
+
export async function refreshDashboardSources(sources) {
|
|
15
|
+
const results = await Promise.allSettled(sources.map((source) => source.refresh()));
|
|
16
|
+
const errors = results.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
17
|
+
if (errors.length > 0) throw new AggregateError(errors, "Dashboard refresh failed");
|
|
18
|
+
}
|
|
19
|
+
export const DASHBOARD_VIEW_URL_KEY = "view";
|
|
20
|
+
export const DASHBOARD_REFRESH_URL_KEY = "refresh";
|
|
21
|
+
export function resolveDashboardRefreshKey(urlPrefix) {
|
|
22
|
+
return joinDashboardUrlKey(urlPrefix, DASHBOARD_REFRESH_URL_KEY);
|
|
23
|
+
}
|
|
24
|
+
export function joinDashboardUrlKey(...segments) {
|
|
25
|
+
return segments.filter(Boolean).join(".");
|
|
26
|
+
}
|
|
27
|
+
export function resolveDashboardScopePrefix(urlPrefix, viewKey) {
|
|
28
|
+
return joinDashboardUrlKey(urlPrefix, viewKey);
|
|
29
|
+
}
|
|
30
|
+
export function resolveDashboardViewKey(urlPrefix) {
|
|
31
|
+
return joinDashboardUrlKey(urlPrefix, DASHBOARD_VIEW_URL_KEY);
|
|
32
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DashboardTimeValue } from '../types/index.js';
|
|
2
|
+
/** Epoch milliseconds of a time value; `NaN` when it cannot be parsed. */
|
|
3
|
+
export declare function toDashboardTime(value: DashboardTimeValue): number;
|
|
4
|
+
/**
|
|
5
|
+
* Short relative time: `now`, `3 min ago`, `2 hr ago`, `yesterday`, `4 days ago`, then the date
|
|
6
|
+
* itself from a week on (with the year when it differs from `now`).
|
|
7
|
+
*/
|
|
8
|
+
export declare function formatDashboardRelativeTime(time: number, now: number, locale: string): string;
|
|
9
|
+
/** Full date and time, for tooltips next to a relative time. */
|
|
10
|
+
export declare function formatDashboardDateTime(time: number, locale: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Day heading of a feed group: `Today`, `Yesterday`, then the date. Capitalized, since it starts a
|
|
13
|
+
* line.
|
|
14
|
+
*/
|
|
15
|
+
export declare function formatDashboardDay(time: number, now: number, locale: string): string;
|
|
16
|
+
/** Local start of the day of a time, used as a stable group key. */
|
|
17
|
+
export declare function startOfDashboardDay(time: number): number;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { isDate, isNumber } from "../../shared/utils/predicate.js";
|
|
2
|
+
const MINUTE = 6e4;
|
|
3
|
+
const HOUR = 60 * MINUTE;
|
|
4
|
+
const DAY = 24 * HOUR;
|
|
5
|
+
export function toDashboardTime(value) {
|
|
6
|
+
if (isNumber(value)) return value;
|
|
7
|
+
if (isDate(value)) return value.getTime();
|
|
8
|
+
return Date.parse(value);
|
|
9
|
+
}
|
|
10
|
+
const formatsByLocale = /* @__PURE__ */ new Map();
|
|
11
|
+
function resolveTimeFormats(locale) {
|
|
12
|
+
const cached = formatsByLocale.get(locale);
|
|
13
|
+
if (cached) return cached;
|
|
14
|
+
const formats = {
|
|
15
|
+
date: new Intl.DateTimeFormat(locale, { day: "numeric", month: "short" }),
|
|
16
|
+
dateWithYear: new Intl.DateTimeFormat(locale, {
|
|
17
|
+
day: "numeric",
|
|
18
|
+
month: "short",
|
|
19
|
+
year: "numeric"
|
|
20
|
+
}),
|
|
21
|
+
full: new Intl.DateTimeFormat(locale, { dateStyle: "long", timeStyle: "short" }),
|
|
22
|
+
relative: new Intl.RelativeTimeFormat(locale, { numeric: "auto", style: "short" })
|
|
23
|
+
};
|
|
24
|
+
formatsByLocale.set(locale, formats);
|
|
25
|
+
return formats;
|
|
26
|
+
}
|
|
27
|
+
export function formatDashboardRelativeTime(time, now, locale) {
|
|
28
|
+
if (!Number.isFinite(time)) return "";
|
|
29
|
+
const formats = resolveTimeFormats(locale);
|
|
30
|
+
const elapsed = now - time;
|
|
31
|
+
const distance = Math.abs(elapsed);
|
|
32
|
+
const sign = elapsed >= 0 ? -1 : 1;
|
|
33
|
+
if (distance < 45e3) return formats.relative.format(0, "second");
|
|
34
|
+
if (distance < 45 * MINUTE)
|
|
35
|
+
return formats.relative.format(sign * Math.round(distance / MINUTE), "minute");
|
|
36
|
+
if (distance < 22 * HOUR)
|
|
37
|
+
return formats.relative.format(sign * Math.round(distance / HOUR), "hour");
|
|
38
|
+
if (distance < 7 * DAY) return formats.relative.format(sign * dayDistance(time, now), "day");
|
|
39
|
+
const sameYear = new Date(time).getFullYear() === new Date(now).getFullYear();
|
|
40
|
+
return (sameYear ? formats.date : formats.dateWithYear).format(time);
|
|
41
|
+
}
|
|
42
|
+
export function formatDashboardDateTime(time, locale) {
|
|
43
|
+
return Number.isFinite(time) ? resolveTimeFormats(locale).full.format(time) : "";
|
|
44
|
+
}
|
|
45
|
+
export function formatDashboardDay(time, now, locale) {
|
|
46
|
+
if (!Number.isFinite(time)) return "";
|
|
47
|
+
const formats = resolveTimeFormats(locale);
|
|
48
|
+
const days = dayDistance(time, now);
|
|
49
|
+
const sameYear = new Date(time).getFullYear() === new Date(now).getFullYear();
|
|
50
|
+
const text = days < 2 ? formats.relative.format(-days, "day") : (sameYear ? formats.date : formats.dateWithYear).format(time);
|
|
51
|
+
return text.charAt(0).toLocaleUpperCase(locale) + text.slice(1);
|
|
52
|
+
}
|
|
53
|
+
export function startOfDashboardDay(time) {
|
|
54
|
+
const day = new Date(time);
|
|
55
|
+
day.setHours(0, 0, 0, 0);
|
|
56
|
+
return day.getTime();
|
|
57
|
+
}
|
|
58
|
+
function dayDistance(time, now) {
|
|
59
|
+
return Math.round(Math.abs(startOfDashboardDay(now) - startOfDashboardDay(time)) / DAY);
|
|
60
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DashboardSourceLike } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Records which sources a derived value reads while it evaluates. One tracker is shared by the
|
|
4
|
+
* whole dashboard; evaluation is synchronous, so a single "current collector" slot is enough.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createDashboardReadTracker(): {
|
|
7
|
+
record(source: DashboardSourceLike): void;
|
|
8
|
+
run<TResult>(reads: Set<DashboardSourceLike>, evaluate: () => TResult): TResult;
|
|
9
|
+
};
|
|
10
|
+
export type DashboardReadTracker = ReturnType<typeof createDashboardReadTracker>;
|
|
11
|
+
/** The `data` object handed to `derive`: each property reads a source's data and records the read. */
|
|
12
|
+
export declare function createDashboardTrackedData(sources: ReadonlyMap<string, DashboardSourceLike>, tracker: DashboardReadTracker): object;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { markRaw } from "vue";
|
|
2
|
+
export function createDashboardReadTracker() {
|
|
3
|
+
let current = null;
|
|
4
|
+
return {
|
|
5
|
+
record(source) {
|
|
6
|
+
current?.add(source);
|
|
7
|
+
},
|
|
8
|
+
run(reads, evaluate) {
|
|
9
|
+
const previous = current;
|
|
10
|
+
current = reads;
|
|
11
|
+
try {
|
|
12
|
+
return evaluate();
|
|
13
|
+
} finally {
|
|
14
|
+
current = previous;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function createDashboardTrackedData(sources, tracker) {
|
|
20
|
+
const data = {};
|
|
21
|
+
for (const [key, source] of sources) {
|
|
22
|
+
Object.defineProperty(data, key, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get() {
|
|
25
|
+
tracker.record(source);
|
|
26
|
+
return source.data;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return markRaw(data);
|
|
31
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { AppConfig } from 'nuxt/schema';
|
|
2
|
+
import type { DashboardUiConfig } from '../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the classes of one block part: library defaults, then each override layer
|
|
5
|
+
* (app config, then the `ui` prop), merged with tailwind-merge so later layers win.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveDashboardClasses<TKey extends string>(defaults: Record<TKey, string>, ...layers: (Partial<Record<NoInfer<TKey>, string>> | undefined)[]): Record<TKey, string>;
|
|
8
|
+
/** Default classes of `UiDashboardTable`, also used by the card's "view as table" action. */
|
|
9
|
+
export declare const DASHBOARD_TABLE_CLASSES: {
|
|
10
|
+
bar: string;
|
|
11
|
+
head: string;
|
|
12
|
+
row: string;
|
|
13
|
+
table: string;
|
|
14
|
+
td: string;
|
|
15
|
+
th: string;
|
|
16
|
+
wrapper: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A row with a `select` listener: highlighted on hover and keyboard focus of its button. The row box
|
|
20
|
+
* never moves, so its divider stays aligned with the card content; the highlight is a pseudo-element
|
|
21
|
+
* reaching 8px past both edges, behind the content (`isolate` keeps it inside the row).
|
|
22
|
+
*/
|
|
23
|
+
export declare const DASHBOARD_SELECTABLE_ROW = "relative isolate before:pointer-events-none before:absolute before:inset-y-0 before:-inset-x-2 before:-z-10 before:rounded-md before:transition-colors has-[>button:hover]:before:bg-elevated/60 has-[>button:focus-visible]:before:bg-elevated/60";
|
|
24
|
+
/**
|
|
25
|
+
* A row shown as selected (`selected` prop): the same tint as the hover, stronger, and an accent
|
|
26
|
+
* on its start edge, both drawn around the row box.
|
|
27
|
+
*/
|
|
28
|
+
export declare const DASHBOARD_SELECTED_ROW = "relative isolate before:pointer-events-none before:absolute before:inset-y-0 before:-inset-x-2 before:-z-10 before:rounded-md before:bg-elevated after:pointer-events-none after:absolute after:inset-y-2 after:-start-2 after:w-0.5 after:rounded-full after:bg-primary";
|
|
29
|
+
/**
|
|
30
|
+
* Button stretched over a selectable row, and over its highlight. It is the row's only interactive
|
|
31
|
+
* element, so the row keeps its list semantics and its content stays plain text; controls inside
|
|
32
|
+
* the row sit above it.
|
|
33
|
+
*/
|
|
34
|
+
export declare const DASHBOARD_ROW_BUTTON = "absolute inset-y-0 -inset-x-2 cursor-pointer rounded-md outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset";
|
|
35
|
+
/** Button stretched over a table row. It stays inside the row: the table may scroll sideways. */
|
|
36
|
+
export declare const DASHBOARD_TABLE_ROW_BUTTON = "absolute inset-0 cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset";
|
|
37
|
+
/** Reads `appConfig.nuxtUiTools.dashboard`; apps that do not declare it get no overrides. */
|
|
38
|
+
export declare function resolveAppDashboardUi(config: Pick<AppConfig, 'nuxtUiTools'>): DashboardUiConfig;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { twMerge } from "tailwind-merge";
|
|
2
|
+
export function resolveDashboardClasses(defaults, ...layers) {
|
|
3
|
+
const resolved = { ...defaults };
|
|
4
|
+
for (const key in defaults) {
|
|
5
|
+
resolved[key] = twMerge(defaults[key], ...layers.map((layer) => layer?.[key]));
|
|
6
|
+
}
|
|
7
|
+
return resolved;
|
|
8
|
+
}
|
|
9
|
+
export const DASHBOARD_TABLE_CLASSES = {
|
|
10
|
+
bar: "h-1.5 overflow-hidden rounded-full bg-[var(--nut-dash-track)]",
|
|
11
|
+
head: "sticky top-0 z-[1] bg-default",
|
|
12
|
+
row: "border-t border-[var(--nut-dash-grid)]",
|
|
13
|
+
table: "w-full border-collapse text-[13px]",
|
|
14
|
+
td: "px-2.5 py-2 text-muted first:ps-0 last:pe-0",
|
|
15
|
+
th: "px-2.5 pt-0.5 pb-2 text-xs font-medium whitespace-nowrap text-dimmed first:ps-0 last:pe-0",
|
|
16
|
+
wrapper: "min-w-0 overflow-auto"
|
|
17
|
+
};
|
|
18
|
+
export const DASHBOARD_SELECTABLE_ROW = "relative isolate before:pointer-events-none before:absolute before:inset-y-0 before:-inset-x-2 before:-z-10 before:rounded-md before:transition-colors has-[>button:hover]:before:bg-elevated/60 has-[>button:focus-visible]:before:bg-elevated/60";
|
|
19
|
+
export const DASHBOARD_SELECTED_ROW = "relative isolate before:pointer-events-none before:absolute before:inset-y-0 before:-inset-x-2 before:-z-10 before:rounded-md before:bg-elevated after:pointer-events-none after:absolute after:inset-y-2 after:-start-2 after:w-0.5 after:rounded-full after:bg-primary";
|
|
20
|
+
export const DASHBOARD_ROW_BUTTON = "absolute inset-y-0 -inset-x-2 cursor-pointer rounded-md outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset";
|
|
21
|
+
export const DASHBOARD_TABLE_ROW_BUTTON = "absolute inset-0 cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset";
|
|
22
|
+
export function resolveAppDashboardUi(config) {
|
|
23
|
+
return config.nuxtUiTools?.dashboard ?? {};
|
|
24
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const callbacks = /* @__PURE__ */ new WeakMap();
|
|
2
|
+
let observer = null;
|
|
3
|
+
function getVisibilityObserver() {
|
|
4
|
+
observer ??= new IntersectionObserver(
|
|
5
|
+
(entries) => {
|
|
6
|
+
for (const entry of entries) {
|
|
7
|
+
if (!entry.isIntersecting) continue;
|
|
8
|
+
const callback = callbacks.get(entry.target);
|
|
9
|
+
unobserveDashboardVisibility(entry.target);
|
|
10
|
+
callback?.();
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
{ rootMargin: "200px" }
|
|
14
|
+
);
|
|
15
|
+
return observer;
|
|
16
|
+
}
|
|
17
|
+
function unobserveDashboardVisibility(element) {
|
|
18
|
+
callbacks.delete(element);
|
|
19
|
+
observer?.unobserve(element);
|
|
20
|
+
}
|
|
21
|
+
export function observeDashboardVisibility(element, callback) {
|
|
22
|
+
callbacks.set(element, callback);
|
|
23
|
+
getVisibilityObserver().observe(element);
|
|
24
|
+
return () => unobserveDashboardVisibility(element);
|
|
25
|
+
}
|
|
@@ -293,7 +293,7 @@ function getSchemaSyncInput(schema) {
|
|
|
293
293
|
function getSchemaValidationMode(schema) {
|
|
294
294
|
const controls = getSchemaControls(schema);
|
|
295
295
|
const value = controls ? Object.getOwnPropertyDescriptor(controls, "validate")?.value : void 0;
|
|
296
|
-
return value === false || value === "required" || value === "
|
|
296
|
+
return value === false || value === "required" || value === "validators" ? value : true;
|
|
297
297
|
}
|
|
298
298
|
function getSchemaControls(schema) {
|
|
299
299
|
if (!isRecord(schema)) {
|
|
@@ -3,9 +3,8 @@ import type { FormFieldApiFactory } from './use-form-state.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Connects schema-owned field rules to Regle's validation tree.
|
|
5
5
|
*
|
|
6
|
-
* Regle owns validation execution, dirty state, async completion, and error collection
|
|
7
|
-
*
|
|
8
|
-
* so renderers only consume the resulting field errors.
|
|
6
|
+
* Regle owns validation execution, dirty state, async completion, and error collection, so
|
|
7
|
+
* renderers only consume the resulting field errors.
|
|
9
8
|
*/
|
|
10
9
|
export declare function useFormValidation(params: {
|
|
11
10
|
schema: () => FormValue;
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import { useRegle } from "@regle/core";
|
|
2
|
-
import {
|
|
2
|
+
import { withMessage } from "@regle/rules";
|
|
3
3
|
import { computed, nextTick, reactive, ref, unref, watch } from "vue";
|
|
4
4
|
import { calendarSeedFromValue, isDateFamilyRange } from "../fields/date-family/utils.js";
|
|
5
5
|
import { resolveFieldDependencies } from "../utils/dependencies.js";
|
|
6
6
|
import { createFormFieldInstance } from "../utils/field-instance.js";
|
|
7
7
|
import { getPathValue, isRecord, pathSegments } from "../utils/path.js";
|
|
8
|
-
import {
|
|
9
|
-
isBoolean,
|
|
10
|
-
isFunction,
|
|
11
|
-
isNumber,
|
|
12
|
-
isObject,
|
|
13
|
-
isString,
|
|
14
|
-
isUndefined
|
|
15
|
-
} from "../utils/predicate.js";
|
|
8
|
+
import { isBoolean, isFunction, isNumber, isObject, isString } from "../utils/predicate.js";
|
|
16
9
|
import {
|
|
17
10
|
fieldPath,
|
|
18
11
|
getArrayItemFields,
|
|
@@ -27,12 +20,11 @@ import {
|
|
|
27
20
|
resolveRequiredMessage,
|
|
28
21
|
shouldRenderField
|
|
29
22
|
} from "../utils/state.js";
|
|
30
|
-
import { resolveFormBoundaryText } from "../utils/text.js";
|
|
23
|
+
import { resolveFormBoundaryText, resolveFormText } from "../utils/text.js";
|
|
31
24
|
export function useFormValidation(params) {
|
|
32
25
|
const customErrors = ref([]);
|
|
33
26
|
const touchedPaths = ref([]);
|
|
34
27
|
const pendingPaths = ref(/* @__PURE__ */ new Map());
|
|
35
|
-
const dynamicMessages = ref(/* @__PURE__ */ new Map());
|
|
36
28
|
const validatedMessages = ref(/* @__PURE__ */ new Map());
|
|
37
29
|
const validationRuns = /* @__PURE__ */ new Map();
|
|
38
30
|
const regle = useRegle(
|
|
@@ -40,7 +32,6 @@ export function useFormValidation(params) {
|
|
|
40
32
|
() => buildRegleRules({
|
|
41
33
|
apiFactory: params.apiFactory,
|
|
42
34
|
context: params.context,
|
|
43
|
-
dynamicMessages,
|
|
44
35
|
getDateMaxMessage: params.getDateMaxMessage,
|
|
45
36
|
getDateMinMessage: params.getDateMinMessage,
|
|
46
37
|
getRequiredMessage: params.getRequiredMessage,
|
|
@@ -57,7 +48,6 @@ export function useFormValidation(params) {
|
|
|
57
48
|
() => buildRegleRules({
|
|
58
49
|
apiFactory: params.apiFactory,
|
|
59
50
|
context: params.context,
|
|
60
|
-
dynamicMessages,
|
|
61
51
|
getDateMaxMessage: params.getDateMaxMessage,
|
|
62
52
|
getDateMinMessage: params.getDateMinMessage,
|
|
63
53
|
getRequiredMessage: params.getRequiredMessage,
|
|
@@ -75,7 +65,6 @@ export function useFormValidation(params) {
|
|
|
75
65
|
() => buildPrimitiveItemRules({
|
|
76
66
|
apiFactory: params.apiFactory,
|
|
77
67
|
context: params.context,
|
|
78
|
-
dynamicMessages,
|
|
79
68
|
getDateMaxMessage: params.getDateMaxMessage,
|
|
80
69
|
getDateMinMessage: params.getDateMinMessage,
|
|
81
70
|
getRequiredMessage: params.getRequiredMessage,
|
|
@@ -92,7 +81,6 @@ export function useFormValidation(params) {
|
|
|
92
81
|
() => buildPrimitiveItemRules({
|
|
93
82
|
apiFactory: params.apiFactory,
|
|
94
83
|
context: params.context,
|
|
95
|
-
dynamicMessages,
|
|
96
84
|
getDateMaxMessage: params.getDateMaxMessage,
|
|
97
85
|
getDateMinMessage: params.getDateMinMessage,
|
|
98
86
|
getRequiredMessage: params.getRequiredMessage,
|
|
@@ -164,7 +152,6 @@ export function useFormValidation(params) {
|
|
|
164
152
|
}
|
|
165
153
|
resetRegleRoots();
|
|
166
154
|
const paths = collectFormFieldsPathsForSchema(params.schema(), params.state);
|
|
167
|
-
clearDynamicMessages(paths);
|
|
168
155
|
clearValidatedMessages(paths);
|
|
169
156
|
const prepared = prepareReglePaths(
|
|
170
157
|
{ items: itemsRegle.r$, main: regle.r$ },
|
|
@@ -214,7 +201,6 @@ export function useFormValidation(params) {
|
|
|
214
201
|
if (params.getValidationMode() === false) {
|
|
215
202
|
return true;
|
|
216
203
|
}
|
|
217
|
-
clearDynamicMessages(paths);
|
|
218
204
|
clearValidatedMessages(paths);
|
|
219
205
|
const prepared = prepareReglePaths(
|
|
220
206
|
{ items: itemsRegle.r$, main: regle.r$ },
|
|
@@ -282,7 +268,6 @@ export function useFormValidation(params) {
|
|
|
282
268
|
if (!path) {
|
|
283
269
|
customErrors.value = [];
|
|
284
270
|
touchedPaths.value = [];
|
|
285
|
-
dynamicMessages.value = /* @__PURE__ */ new Map();
|
|
286
271
|
validatedMessages.value = /* @__PURE__ */ new Map();
|
|
287
272
|
resetRegleRoots();
|
|
288
273
|
return;
|
|
@@ -294,11 +279,6 @@ export function useFormValidation(params) {
|
|
|
294
279
|
touchedPaths.value = touchedPaths.value.filter(
|
|
295
280
|
(touchedPath) => touchedPath !== key && !touchedPath.startsWith(`${key}.`)
|
|
296
281
|
);
|
|
297
|
-
dynamicMessages.value = new Map(
|
|
298
|
-
[...dynamicMessages.value.entries()].filter(
|
|
299
|
-
([messageKey]) => !messageKey.startsWith(`${key}:`)
|
|
300
|
-
)
|
|
301
|
-
);
|
|
302
282
|
validatedMessages.value = new Map(
|
|
303
283
|
[...validatedMessages.value.entries()].filter(
|
|
304
284
|
([messagePath]) => messagePath !== key && !messagePath.startsWith(`${key}.`)
|
|
@@ -308,17 +288,9 @@ export function useFormValidation(params) {
|
|
|
308
288
|
function clearValidationState() {
|
|
309
289
|
customErrors.value = [];
|
|
310
290
|
touchedPaths.value = [];
|
|
311
|
-
dynamicMessages.value = /* @__PURE__ */ new Map();
|
|
312
291
|
validatedMessages.value = /* @__PURE__ */ new Map();
|
|
313
292
|
resetRegleRoots();
|
|
314
293
|
}
|
|
315
|
-
function clearDynamicMessages(paths) {
|
|
316
|
-
dynamicMessages.value = new Map(
|
|
317
|
-
[...dynamicMessages.value.entries()].filter(
|
|
318
|
-
([messageKey]) => !paths.some((path) => messageKey.startsWith(`${path}:`))
|
|
319
|
-
)
|
|
320
|
-
);
|
|
321
|
-
}
|
|
322
294
|
function clearValidatedMessages(paths) {
|
|
323
295
|
if (!paths.length) {
|
|
324
296
|
return;
|
|
@@ -500,9 +472,7 @@ function isRegleRuleTreeNode(value) {
|
|
|
500
472
|
}
|
|
501
473
|
function buildLeafRules(params) {
|
|
502
474
|
const output = {};
|
|
503
|
-
|
|
504
|
-
const key = params.path.join(".");
|
|
505
|
-
if (params.mode !== "rules" && resolveRequired(params.field, params.callbackParams)) {
|
|
475
|
+
if (params.mode !== "validators" && resolveRequired(params.field, params.callbackParams)) {
|
|
506
476
|
output.required = withMessage(
|
|
507
477
|
(value) => !isEmptyValue(value),
|
|
508
478
|
resolveRequiredMessage(params.field, params.getRequiredMessage?.())
|
|
@@ -512,6 +482,7 @@ function buildLeafRules(params) {
|
|
|
512
482
|
return output;
|
|
513
483
|
}
|
|
514
484
|
applyDateBoundsRules(output, params);
|
|
485
|
+
applyPasswordRequirementRules(output, params);
|
|
515
486
|
const authoredValidators = "validators" in params.field ? params.field.validators : void 0;
|
|
516
487
|
let validators;
|
|
517
488
|
if (isValidatorMap(authoredValidators)) {
|
|
@@ -522,96 +493,37 @@ function buildLeafRules(params) {
|
|
|
522
493
|
if (validators) {
|
|
523
494
|
for (const name in validators) {
|
|
524
495
|
const rule = validators[name];
|
|
525
|
-
if (rule) {
|
|
496
|
+
if (rule && (params.includeAsync || !isAsyncValidator(rule))) {
|
|
526
497
|
output[name] = rule;
|
|
527
498
|
}
|
|
528
499
|
}
|
|
529
500
|
}
|
|
530
|
-
const authoredRules = isRecord(validation) ? Object.getOwnPropertyDescriptor(validation, "rules")?.value : void 0;
|
|
531
|
-
if (!Array.isArray(authoredRules)) {
|
|
532
|
-
return output;
|
|
533
|
-
}
|
|
534
|
-
authoredRules.forEach((rule, index) => {
|
|
535
|
-
if (!isRecord(rule)) {
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
538
|
-
const validate = Object.getOwnPropertyDescriptor(rule, "validate")?.value;
|
|
539
|
-
if (!isFunction(validate)) {
|
|
540
|
-
return;
|
|
541
|
-
}
|
|
542
|
-
if (!params.includeAsync && isAsyncFunction(validate)) {
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
const ruleName = resolveRuleName(rule, index);
|
|
546
|
-
const messageKey = `${key}:${ruleName}`;
|
|
547
|
-
function message() {
|
|
548
|
-
return params.dynamicMessages.value.get(messageKey) ?? resolveRuleMessage(rule, params.field);
|
|
549
|
-
}
|
|
550
|
-
if (isAsyncFunction(validate)) {
|
|
551
|
-
output[ruleName] = withMessage(
|
|
552
|
-
withAsync(
|
|
553
|
-
async () => resolveRuleResult(
|
|
554
|
-
await validate({ ...params.callbackParams, api: params.callbackParams.api }),
|
|
555
|
-
messageKey,
|
|
556
|
-
params.dynamicMessages
|
|
557
|
-
)
|
|
558
|
-
),
|
|
559
|
-
message
|
|
560
|
-
);
|
|
561
|
-
} else {
|
|
562
|
-
output[ruleName] = withMessage(
|
|
563
|
-
() => resolveRuleResult(
|
|
564
|
-
validate({ ...params.callbackParams, api: params.callbackParams.api }),
|
|
565
|
-
messageKey,
|
|
566
|
-
params.dynamicMessages
|
|
567
|
-
),
|
|
568
|
-
message
|
|
569
|
-
);
|
|
570
|
-
}
|
|
571
|
-
});
|
|
572
501
|
return output;
|
|
573
502
|
}
|
|
574
|
-
function
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
function resolveRuleResult(result, messageKey, dynamicMessages) {
|
|
578
|
-
if (isString(result)) {
|
|
579
|
-
setDynamicMessage(dynamicMessages, messageKey, result);
|
|
580
|
-
return false;
|
|
503
|
+
function applyPasswordRequirementRules(output, params) {
|
|
504
|
+
if (params.field.type !== "password") {
|
|
505
|
+
return;
|
|
581
506
|
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
function isAsyncFunction(value) {
|
|
586
|
-
return Object.getPrototypeOf(value)?.constructor?.name === "AsyncFunction";
|
|
587
|
-
}
|
|
588
|
-
function setDynamicMessage(messages, key, value) {
|
|
589
|
-
const next = new Map(messages.value);
|
|
590
|
-
next.set(key, value);
|
|
591
|
-
messages.value = next;
|
|
592
|
-
}
|
|
593
|
-
function clearDynamicMessage(messages, key) {
|
|
594
|
-
if (!messages.value.has(key)) {
|
|
507
|
+
const authoredProps = Object.getOwnPropertyDescriptor(params.field, "props")?.value;
|
|
508
|
+
const resolvedProps = isFunction(authoredProps) ? authoredProps(params.callbackParams) : authoredProps;
|
|
509
|
+
if (!isObject(resolvedProps) || !Array.isArray(resolvedProps.requirements)) {
|
|
595
510
|
return;
|
|
596
511
|
}
|
|
597
|
-
const
|
|
598
|
-
|
|
599
|
-
|
|
512
|
+
for (const requirement of resolvedProps.requirements) {
|
|
513
|
+
output[`requirement:${requirement.key}`] = withMessage(
|
|
514
|
+
(value) => isEmptyValue(value) || isString(value) && requirement.validate(value),
|
|
515
|
+
resolveFormText(requirement.label) ?? requirement.key
|
|
516
|
+
);
|
|
517
|
+
}
|
|
600
518
|
}
|
|
601
|
-
function
|
|
602
|
-
|
|
603
|
-
return isString(name) && name.length ? name : `rule-${index + 1}`;
|
|
519
|
+
function isValidatorMap(value) {
|
|
520
|
+
return isObject(value);
|
|
604
521
|
}
|
|
605
|
-
function
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
return String(message());
|
|
609
|
-
}
|
|
610
|
-
if (isString(message) || isNumber(message)) {
|
|
611
|
-
return String(message);
|
|
522
|
+
function isAsyncValidator(rule) {
|
|
523
|
+
if (isObject(rule)) {
|
|
524
|
+
return rule._async === true;
|
|
612
525
|
}
|
|
613
|
-
|
|
614
|
-
return isString(name) ? `Invalid value for ${name}.` : `Invalid value for ${field.key}.`;
|
|
526
|
+
return isFunction(rule) && Object.getPrototypeOf(rule)?.constructor?.name === "AsyncFunction";
|
|
615
527
|
}
|
|
616
528
|
function resolveRegleStatusErrors(status) {
|
|
617
529
|
const errors = readReactiveProperty(status, "$errors");
|
|
@@ -162,7 +162,7 @@ function getSchemaSyncInput(schema) {
|
|
|
162
162
|
function getSchemaValidationMode(schema) {
|
|
163
163
|
const controls = getSchemaControls(schema);
|
|
164
164
|
const value = controls ? Object.getOwnPropertyDescriptor(controls, "validate")?.value : void 0;
|
|
165
|
-
return value === false || value === "required" || value === "
|
|
165
|
+
return value === false || value === "required" || value === "validators" ? value : true;
|
|
166
166
|
}
|
|
167
167
|
function getSchemaControls(schema) {
|
|
168
168
|
if (!isRecord(schema)) {
|