nuxt-ui-tools 1.0.1 → 1.2.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 +315 -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 +239 -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 +5 -0
- package/dist/runtime/dashboard/utils/options.js +18 -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/types/options.d.ts +15 -36
- package/dist/runtime/i18n/locales/en.js +65 -1
- package/dist/runtime/i18n/locales/fr.js +65 -1
- package/dist/runtime/i18n/types.d.ts +70 -0
- package/dist/runtime/shared/index.d.ts +2 -0
- package/dist/runtime/shared/styles/scrollbars.css +1 -1
- 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/shared/utils/remote-options.d.ts +10 -0
- package/dist/runtime/shared/utils/remote-options.js +6 -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 +1 -1
- package/dist/runtime/table/components/data-list/data-list-content.vue.d.ts +1 -1
- 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.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-sort-menu.d.vue.ts +1 -1
- 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/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-list-end.d.vue.ts +11 -0
- package/dist/runtime/table/components/filters/shared/filter-option-list-end.vue +76 -0
- package/dist/runtime/table/components/filters/shared/filter-option-list-end.vue.d.ts +11 -0
- package/dist/runtime/table/components/filters/shared/filter-option-loading-list.d.vue.ts +3 -0
- package/dist/runtime/table/components/filters/shared/filter-option-loading-list.vue +2 -1
- package/dist/runtime/table/components/filters/shared/filter-option-loading-list.vue.d.ts +3 -0
- package/dist/runtime/table/components/filters/shared/filter-option-multiple-list.vue +1 -1
- package/dist/runtime/table/components/filters/shared/filter-option-picker-content.vue +13 -0
- package/dist/runtime/table/components/filters/shared/filter-option-single-list.d.vue.ts +2 -0
- package/dist/runtime/table/components/filters/shared/filter-option-single-list.vue +1 -1
- package/dist/runtime/table/components/filters/shared/filter-option-single-list.vue.d.ts +2 -0
- package/dist/runtime/table/components/filters/shared/filter-option-tree-content.d.vue.ts +3 -0
- package/dist/runtime/table/components/filters/shared/filter-option-tree-content.vue +2 -2
- package/dist/runtime/table/components/filters/shared/filter-option-tree-content.vue.d.ts +3 -0
- package/dist/runtime/table/components/filters/shared/filter-searchable-panel.vue +1 -0
- 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/composables/use-option-filter-editor-state.d.ts +13 -1
- package/dist/runtime/table/composables/use-option-filter-editor-state.js +6 -2
- package/dist/runtime/table/composables/use-query-state.d.ts +3 -3
- package/dist/runtime/table/composables/use-table-columns.d.ts +3 -3
- package/dist/runtime/table/composables/use-table-filter-options.d.ts +11 -1
- package/dist/runtime/table/composables/use-table-filter-options.js +128 -17
- package/dist/runtime/table/composables/use-table-filter-selected-options.d.ts +20 -0
- package/dist/runtime/table/composables/use-table-filter-selected-options.js +99 -0
- package/dist/runtime/table/composables/use-table-filters.d.ts +5 -0
- package/dist/runtime/table/composables/use-table-filters.js +20 -1
- package/dist/runtime/table/composables/use-table-internals.d.ts +42 -27
- package/dist/runtime/table/composables/use-table-pagination.d.ts +2 -2
- package/dist/runtime/table/composables/use-table-remote-filter-options.d.ts +42 -0
- package/dist/runtime/table/composables/use-table-remote-filter-options.js +102 -0
- 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/filters.d.ts +42 -0
- package/dist/runtime/table/types/source.d.ts +9 -5
- package/dist/runtime/table/utils/columns/menu.d.ts +1 -1
- 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/options.d.ts +2 -0
- package/dist/runtime/table/utils/filters/options.js +1 -1
- package/dist/runtime/table/utils/prefetch.js +21 -1
- package/package.json +28 -1
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { useUiToolsLocale } from "#ui-tools/i18n";
|
|
4
|
+
import { isNumber, isString } from "#ui-tools/shared/utils/predicate";
|
|
5
|
+
import { resolveTextValue } from "#ui-tools/shared/utils/render";
|
|
6
|
+
import { useDashboardFormat } from "../composables/use-dashboard-format";
|
|
7
|
+
import { useDashboardUi } from "../composables/use-dashboard-ui";
|
|
8
|
+
import { resolveDashboardColor } from "../utils/charts";
|
|
9
|
+
import { toDashboardCell } from "../utils/export";
|
|
10
|
+
import { resolveDashboardClasses } from "../utils/ui";
|
|
11
|
+
import DashboardRing from "./block/dashboard-ring.vue";
|
|
12
|
+
import DashboardSkeleton from "./block/dashboard-skeleton.vue";
|
|
13
|
+
import DashboardCard from "./dashboard-card.vue";
|
|
14
|
+
const {
|
|
15
|
+
source,
|
|
16
|
+
card = true,
|
|
17
|
+
menu = void 0,
|
|
18
|
+
freshness = void 0,
|
|
19
|
+
value,
|
|
20
|
+
min = 0,
|
|
21
|
+
max = 100,
|
|
22
|
+
target,
|
|
23
|
+
format,
|
|
24
|
+
caption,
|
|
25
|
+
color = "series-1",
|
|
26
|
+
variant = "arc",
|
|
27
|
+
diameter = 168,
|
|
28
|
+
thickness = 12,
|
|
29
|
+
ui,
|
|
30
|
+
...block
|
|
31
|
+
} = defineProps({
|
|
32
|
+
title: { type: [String, Number, Function], required: false },
|
|
33
|
+
subtitle: { type: [String, Number, Function], required: false },
|
|
34
|
+
size: { type: String, required: false },
|
|
35
|
+
rows: { type: String, required: false },
|
|
36
|
+
card: { type: Boolean, required: false },
|
|
37
|
+
activation: { type: String, required: false },
|
|
38
|
+
empty: { type: Object, required: false },
|
|
39
|
+
menu: { type: [Boolean, Array, Function], required: false },
|
|
40
|
+
actions: { type: Array, required: false },
|
|
41
|
+
freshness: { type: Boolean, required: false },
|
|
42
|
+
source: { type: Object, required: true },
|
|
43
|
+
value: { type: Function, required: true },
|
|
44
|
+
min: { type: [Number, Function], required: false },
|
|
45
|
+
max: { type: [Number, Function], required: false },
|
|
46
|
+
target: { type: Function, required: false },
|
|
47
|
+
format: { type: Function, required: false },
|
|
48
|
+
caption: { type: [String, Number, Function], required: false },
|
|
49
|
+
color: { type: [String, Function], required: false },
|
|
50
|
+
variant: { type: String, required: false },
|
|
51
|
+
diameter: { type: Number, required: false },
|
|
52
|
+
thickness: { type: Number, required: false },
|
|
53
|
+
ui: { type: Object, required: false }
|
|
54
|
+
});
|
|
55
|
+
defineSlots();
|
|
56
|
+
const { t } = useUiToolsLocale();
|
|
57
|
+
const formats = useDashboardFormat();
|
|
58
|
+
const appUi = useDashboardUi();
|
|
59
|
+
const classes = computed(
|
|
60
|
+
() => resolveDashboardClasses(
|
|
61
|
+
{
|
|
62
|
+
caption: "mt-1 block text-[11.5px] text-muted",
|
|
63
|
+
ring: "mx-auto",
|
|
64
|
+
scale: "mx-auto -mt-3 flex justify-between px-1 text-[11px] text-dimmed tabular-nums",
|
|
65
|
+
value: "block text-[28px] leading-none font-semibold tracking-tight text-highlighted tabular-nums"
|
|
66
|
+
},
|
|
67
|
+
appUi.value.gauge,
|
|
68
|
+
ui
|
|
69
|
+
)
|
|
70
|
+
);
|
|
71
|
+
const gauge = computed(() => {
|
|
72
|
+
const data = source.data;
|
|
73
|
+
if (data === void 0) return null;
|
|
74
|
+
const amount = value(data);
|
|
75
|
+
if (!isNumber(amount) || !Number.isFinite(amount)) return null;
|
|
76
|
+
const low = isNumber(min) ? min : min(data);
|
|
77
|
+
const high = isNumber(max) ? max : max(data);
|
|
78
|
+
const span = high - low;
|
|
79
|
+
const share = span > 0 ? (amount - low) / span : 0;
|
|
80
|
+
const goal = target?.(data);
|
|
81
|
+
const formatValue = format ?? formats.number.value;
|
|
82
|
+
const text = caption === void 0 || isString(caption) || isNumber(caption) ? caption : caption(data);
|
|
83
|
+
return {
|
|
84
|
+
caption: resolveTextValue(text),
|
|
85
|
+
color: resolveDashboardColor(isString(color) ? color : color(amount, share), 0),
|
|
86
|
+
data,
|
|
87
|
+
high: formatValue(high),
|
|
88
|
+
highRaw: high,
|
|
89
|
+
low: formatValue(low),
|
|
90
|
+
lowRaw: low,
|
|
91
|
+
raw: amount,
|
|
92
|
+
share,
|
|
93
|
+
target: isNumber(goal) && span > 0 ? (goal - low) / span : null,
|
|
94
|
+
targetText: isNumber(goal) ? t("dashboard.stat.goal", { value: formatValue(goal) }) : "",
|
|
95
|
+
targetValue: isNumber(goal) ? goal : null,
|
|
96
|
+
value: formatValue(amount)
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
function tabulate() {
|
|
100
|
+
const current = gauge.value;
|
|
101
|
+
return {
|
|
102
|
+
columns: [
|
|
103
|
+
{ key: "label", label: t("dashboard.table.label"), numeric: false },
|
|
104
|
+
{ key: "value", label: t("dashboard.table.value"), numeric: true }
|
|
105
|
+
],
|
|
106
|
+
rows: current ? [
|
|
107
|
+
[
|
|
108
|
+
toDashboardCell(t("dashboard.table.value")),
|
|
109
|
+
toDashboardCell(current.raw, current.value)
|
|
110
|
+
],
|
|
111
|
+
...current.targetValue === null ? [] : [[toDashboardCell(current.targetText), toDashboardCell(current.targetValue)]]
|
|
112
|
+
] : []
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
</script>
|
|
116
|
+
|
|
117
|
+
<template>
|
|
118
|
+
<DashboardCard
|
|
119
|
+
v-bind="block"
|
|
120
|
+
:card
|
|
121
|
+
:menu
|
|
122
|
+
:freshness
|
|
123
|
+
:ui
|
|
124
|
+
:source
|
|
125
|
+
:is-empty="gauge === null"
|
|
126
|
+
:tabulate
|
|
127
|
+
:view-as-table="false"
|
|
128
|
+
:expandable="false"
|
|
129
|
+
>
|
|
130
|
+
<template #skeleton>
|
|
131
|
+
<DashboardSkeleton kind="gauge" :diameter />
|
|
132
|
+
</template>
|
|
133
|
+
<template v-if="$slots['header-right']" #header-right>
|
|
134
|
+
<slot name="header-right" />
|
|
135
|
+
</template>
|
|
136
|
+
<template v-if="$slots.toolbar" #toolbar>
|
|
137
|
+
<slot name="toolbar" />
|
|
138
|
+
</template>
|
|
139
|
+
<template v-if="$slots.footer" #footer>
|
|
140
|
+
<slot name="footer" />
|
|
141
|
+
</template>
|
|
142
|
+
|
|
143
|
+
<!-- Centered in whatever height the grid row gives the card. -->
|
|
144
|
+
<div v-if="gauge" class="flex h-full flex-col items-center justify-center">
|
|
145
|
+
<DashboardRing
|
|
146
|
+
:ratio="gauge.share"
|
|
147
|
+
:size="diameter"
|
|
148
|
+
:thickness
|
|
149
|
+
:color="gauge.color"
|
|
150
|
+
:arc="variant === 'arc'"
|
|
151
|
+
:target="gauge.target"
|
|
152
|
+
:class="classes.ring"
|
|
153
|
+
role="meter"
|
|
154
|
+
:aria-valuemin="gauge.lowRaw"
|
|
155
|
+
:aria-valuemax="gauge.highRaw"
|
|
156
|
+
:aria-valuenow="gauge.raw"
|
|
157
|
+
:aria-valuetext="gauge.value"
|
|
158
|
+
:aria-label="gauge.caption || void 0"
|
|
159
|
+
>
|
|
160
|
+
<slot name="center" :data="gauge.data" :value="gauge.value" :share="gauge.share">
|
|
161
|
+
<b :class="classes.value">{{ gauge.value }}</b>
|
|
162
|
+
<small v-if="gauge.caption" :class="classes.caption">{{ gauge.caption }}</small>
|
|
163
|
+
</slot>
|
|
164
|
+
</DashboardRing>
|
|
165
|
+
<div
|
|
166
|
+
v-if="variant === 'arc'"
|
|
167
|
+
:class="classes.scale"
|
|
168
|
+
:style="{ width: `${diameter}px` }"
|
|
169
|
+
aria-hidden="true"
|
|
170
|
+
>
|
|
171
|
+
<span>{{ gauge.low }}</span>
|
|
172
|
+
<span v-if="gauge.targetText" class="text-muted">{{ gauge.targetText }}</span>
|
|
173
|
+
<span>{{ gauge.high }}</span>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
</DashboardCard>
|
|
177
|
+
</template>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { LazyTextValue } from '#ui-tools/shared/types/utils';
|
|
2
|
+
import type { DashboardBlockBaseProps, DashboardBlockUi, DashboardGaugeUi, DashboardSeriesColor, DashboardSourceLike, DashboardValueFormat } from '../types/index.js';
|
|
3
|
+
declare const __VLS_export: <TData>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<Omit<DashboardBlockBaseProps, "ui"> & {
|
|
5
|
+
source: DashboardSourceLike<TData>;
|
|
6
|
+
/** Current value, placed between `min` and `max`. */
|
|
7
|
+
value: (data: TData & ({} | null)) => number | null | undefined;
|
|
8
|
+
/** Start of the scale. Defaults to `0`. */
|
|
9
|
+
min?: number | ((data: TData & ({} | null)) => number);
|
|
10
|
+
/** End of the scale (a goal, a capacity). Defaults to `100`. */
|
|
11
|
+
max?: number | ((data: TData & ({} | null)) => number);
|
|
12
|
+
/** Target on the scale, drawn as a tick across the ring. `null` hides it. */
|
|
13
|
+
target?: (data: TData & ({} | null)) => number | null | undefined;
|
|
14
|
+
/** Center value format. Defaults to the locale number format. */
|
|
15
|
+
format?: DashboardValueFormat;
|
|
16
|
+
/** Text under the value, inside the ring. */
|
|
17
|
+
caption?: LazyTextValue | ((data: TData & ({} | null)) => LazyTextValue | undefined);
|
|
18
|
+
/**
|
|
19
|
+
* Filled stroke color: a palette slot, a Nuxt UI color, any CSS color, or a function of the
|
|
20
|
+
* value and its share of the scale (`0`–`1`), e.g. to turn red past a threshold.
|
|
21
|
+
*/
|
|
22
|
+
color?: DashboardSeriesColor | ((value: number, share: number) => DashboardSeriesColor);
|
|
23
|
+
/** `arc`: a 240° gauge open at the bottom, with the scale bounds under it. `ring`: a full ring. */
|
|
24
|
+
variant?: "arc" | "ring";
|
|
25
|
+
/** Ring size in pixels. */
|
|
26
|
+
diameter?: number;
|
|
27
|
+
thickness?: number;
|
|
28
|
+
ui?: DashboardBlockUi & DashboardGaugeUi;
|
|
29
|
+
}> & (typeof globalThis extends {
|
|
30
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
31
|
+
} ? P : {});
|
|
32
|
+
expose: (exposed: {}) => void;
|
|
33
|
+
attrs: any;
|
|
34
|
+
slots: {
|
|
35
|
+
/** Content in the middle of the ring, instead of the value and caption. */
|
|
36
|
+
center?: (props: {
|
|
37
|
+
data: TData & ({} | null);
|
|
38
|
+
value: string;
|
|
39
|
+
share: number;
|
|
40
|
+
}) => unknown;
|
|
41
|
+
'header-right'?: () => unknown;
|
|
42
|
+
toolbar?: () => unknown;
|
|
43
|
+
footer?: () => unknown;
|
|
44
|
+
};
|
|
45
|
+
emit: {};
|
|
46
|
+
}>) => import("vue").VNode & {
|
|
47
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
48
|
+
};
|
|
49
|
+
declare const _default: typeof __VLS_export;
|
|
50
|
+
export default _default;
|
|
51
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
52
|
+
[K in keyof T]: T[K];
|
|
53
|
+
} : {
|
|
54
|
+
[K in keyof T as K]: T[K];
|
|
55
|
+
}) & {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { DashboardGridUi, DashboardMenu } from '../types/index.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Column count, responsive: `"2 md:3 xl:5"`. Defaults to `12`. */
|
|
4
|
+
columns?: string;
|
|
5
|
+
/**
|
|
6
|
+
* `cards`: separate cards with a gap. `panels`: one bordered surface whose cells are separated by
|
|
7
|
+
* 1px rules (rows should be full for the rules to read as a grid).
|
|
8
|
+
*/
|
|
9
|
+
variant?: 'cards' | 'panels';
|
|
10
|
+
/** Gap between cards, any CSS length. Defaults to `1rem`; ignored by `panels`. */
|
|
11
|
+
gap?: string;
|
|
12
|
+
/** Grid span when this grid is nested in another grid, responsive. */
|
|
13
|
+
size?: string;
|
|
14
|
+
/** Card menu of every block inside that does not set its own `menu`. */
|
|
15
|
+
menu?: DashboardMenu;
|
|
16
|
+
/** `freshness` of every block inside that does not set its own. */
|
|
17
|
+
freshness?: boolean;
|
|
18
|
+
ui?: DashboardGridUi;
|
|
19
|
+
};
|
|
20
|
+
declare var __VLS_1: {};
|
|
21
|
+
type __VLS_Slots = {} & {
|
|
22
|
+
default?: (props: typeof __VLS_1) => any;
|
|
23
|
+
};
|
|
24
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
25
|
+
variant: "cards" | "panels";
|
|
26
|
+
menu: DashboardMenu;
|
|
27
|
+
columns: string;
|
|
28
|
+
freshness: boolean;
|
|
29
|
+
gap: string;
|
|
30
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
31
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
32
|
+
declare const _default: typeof __VLS_export;
|
|
33
|
+
export default _default;
|
|
34
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
35
|
+
new (): {
|
|
36
|
+
$slots: S;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
import { computed } from "vue";
|
|
4
|
+
import { useResponsiveValue } from "#ui-tools/shared/composables/use-responsive-value";
|
|
5
|
+
import { provideDashboardGrid, useDashboardUi } from "../composables/use-dashboard-ui";
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
columns: { type: String, required: false, default: "12" },
|
|
8
|
+
variant: { type: String, required: false, default: "cards" },
|
|
9
|
+
gap: { type: String, required: false, default: "1rem" },
|
|
10
|
+
size: { type: String, required: false },
|
|
11
|
+
menu: { type: [Boolean, Array, Function], required: false, default: void 0 },
|
|
12
|
+
freshness: { type: Boolean, required: false, default: void 0 },
|
|
13
|
+
ui: { type: Object, required: false }
|
|
14
|
+
});
|
|
15
|
+
provideDashboardGrid({
|
|
16
|
+
freshness: () => props.freshness,
|
|
17
|
+
menu: () => props.menu,
|
|
18
|
+
panels: () => props.variant === "panels"
|
|
19
|
+
});
|
|
20
|
+
const appUi = useDashboardUi();
|
|
21
|
+
const columns = useResponsiveValue(() => props.columns, "grid-cols");
|
|
22
|
+
const span = useResponsiveValue(() => props.size ?? "", "col");
|
|
23
|
+
const style = computed(
|
|
24
|
+
() => [
|
|
25
|
+
"display: grid",
|
|
26
|
+
columns.value,
|
|
27
|
+
props.variant === "cards" && `gap: ${props.gap}`,
|
|
28
|
+
span.value ?? "grid-column: 1 / -1"
|
|
29
|
+
].filter(Boolean).join("; ")
|
|
30
|
+
);
|
|
31
|
+
const classes = computed(
|
|
32
|
+
() => twMerge(
|
|
33
|
+
"min-w-0",
|
|
34
|
+
props.variant === "panels" && [
|
|
35
|
+
"gap-px overflow-hidden rounded-lg border border-default bg-(--ui-border)",
|
|
36
|
+
appUi.value.grid?.panels,
|
|
37
|
+
props.ui?.panels
|
|
38
|
+
],
|
|
39
|
+
appUi.value.grid?.root,
|
|
40
|
+
props.ui?.root
|
|
41
|
+
)
|
|
42
|
+
);
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<template>
|
|
46
|
+
<div :style="style" :class="classes" :data-variant="variant">
|
|
47
|
+
<slot />
|
|
48
|
+
</div>
|
|
49
|
+
</template>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { DashboardGridUi, DashboardMenu } from '../types/index.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Column count, responsive: `"2 md:3 xl:5"`. Defaults to `12`. */
|
|
4
|
+
columns?: string;
|
|
5
|
+
/**
|
|
6
|
+
* `cards`: separate cards with a gap. `panels`: one bordered surface whose cells are separated by
|
|
7
|
+
* 1px rules (rows should be full for the rules to read as a grid).
|
|
8
|
+
*/
|
|
9
|
+
variant?: 'cards' | 'panels';
|
|
10
|
+
/** Gap between cards, any CSS length. Defaults to `1rem`; ignored by `panels`. */
|
|
11
|
+
gap?: string;
|
|
12
|
+
/** Grid span when this grid is nested in another grid, responsive. */
|
|
13
|
+
size?: string;
|
|
14
|
+
/** Card menu of every block inside that does not set its own `menu`. */
|
|
15
|
+
menu?: DashboardMenu;
|
|
16
|
+
/** `freshness` of every block inside that does not set its own. */
|
|
17
|
+
freshness?: boolean;
|
|
18
|
+
ui?: DashboardGridUi;
|
|
19
|
+
};
|
|
20
|
+
declare var __VLS_1: {};
|
|
21
|
+
type __VLS_Slots = {} & {
|
|
22
|
+
default?: (props: typeof __VLS_1) => any;
|
|
23
|
+
};
|
|
24
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
25
|
+
variant: "cards" | "panels";
|
|
26
|
+
menu: DashboardMenu;
|
|
27
|
+
columns: string;
|
|
28
|
+
freshness: boolean;
|
|
29
|
+
gap: string;
|
|
30
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
31
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
32
|
+
declare const _default: typeof __VLS_export;
|
|
33
|
+
export default _default;
|
|
34
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
35
|
+
new (): {
|
|
36
|
+
$slots: S;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DashboardLegendItem, DashboardLegendUi } from '../types/index.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
items: readonly DashboardLegendItem[];
|
|
4
|
+
ui?: DashboardLegendUi;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { useDashboardUi } from "../composables/use-dashboard-ui";
|
|
4
|
+
import { resolveDashboardClasses } from "../utils/ui";
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
items: { type: Array, required: true },
|
|
7
|
+
ui: { type: Object, required: false }
|
|
8
|
+
});
|
|
9
|
+
const appUi = useDashboardUi();
|
|
10
|
+
const classes = computed(
|
|
11
|
+
() => resolveDashboardClasses(
|
|
12
|
+
{
|
|
13
|
+
item: "inline-flex items-center gap-1.5 whitespace-nowrap",
|
|
14
|
+
root: "flex flex-wrap items-center gap-x-3.5 gap-y-1 text-xs text-muted",
|
|
15
|
+
swatch: "shrink-0"
|
|
16
|
+
},
|
|
17
|
+
appUi.value.legend,
|
|
18
|
+
props.ui
|
|
19
|
+
)
|
|
20
|
+
);
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<ul :class="classes.root">
|
|
25
|
+
<li v-for="item in items" :key="item.key" :class="classes.item">
|
|
26
|
+
<span
|
|
27
|
+
aria-hidden="true"
|
|
28
|
+
:class="[
|
|
29
|
+
classes.swatch,
|
|
30
|
+
item.dashed ? 'h-0 w-3 border-t-2 border-dashed' : 'size-[9px] rounded-[3px]'
|
|
31
|
+
]"
|
|
32
|
+
:style="item.dashed ? { borderColor: item.color } : { background: item.color }"
|
|
33
|
+
/>
|
|
34
|
+
{{ item.label }}
|
|
35
|
+
</li>
|
|
36
|
+
</ul>
|
|
37
|
+
</template>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DashboardLegendItem, DashboardLegendUi } from '../types/index.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
items: readonly DashboardLegendItem[];
|
|
4
|
+
ui?: DashboardLegendUi;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { LazyTextValue } from '#ui-tools/shared/types/utils';
|
|
2
|
+
import type { DashboardAxisOptions, DashboardBlockBaseProps, DashboardReferenceLine, DashboardSelected, DashboardSelectEvent, DashboardSeries, DashboardSourceLike, DashboardValueFormat } from '../types/index.js';
|
|
3
|
+
declare const __VLS_export: <TRow>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<DashboardBlockBaseProps & {
|
|
5
|
+
source: DashboardSourceLike<readonly TRow[] | undefined>;
|
|
6
|
+
x: (row: TRow, index: number) => string | number | Date;
|
|
7
|
+
xFormat?: (value: string | number | Date) => string;
|
|
8
|
+
/** Header of the category column in the table view and CSV export. */
|
|
9
|
+
xLabel?: LazyTextValue;
|
|
10
|
+
series: readonly DashboardSeries<TRow>[];
|
|
11
|
+
/** Dashed line, e.g. the previous period. */
|
|
12
|
+
comparison?: DashboardSeries<TRow>;
|
|
13
|
+
/** Fills the area under every solid series. */
|
|
14
|
+
area?: boolean;
|
|
15
|
+
yAxis?: DashboardAxisOptions;
|
|
16
|
+
format?: DashboardValueFormat;
|
|
17
|
+
reference?: DashboardReferenceLine | readonly DashboardReferenceLine[];
|
|
18
|
+
height?: number;
|
|
19
|
+
legend?: boolean;
|
|
20
|
+
/** Expected number of x positions, drawn by the loading skeleton before data arrives. */
|
|
21
|
+
points?: number;
|
|
22
|
+
/** Rows shown as selected: a band marks their x position. */
|
|
23
|
+
selected?: DashboardSelected<TRow>;
|
|
24
|
+
/** A click on the chart selects the x position under the pointer. */
|
|
25
|
+
onSelect?: (event: DashboardSelectEvent<TRow>) => void;
|
|
26
|
+
}> & (typeof globalThis extends {
|
|
27
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
28
|
+
} ? P : {});
|
|
29
|
+
expose: (exposed: {}) => void;
|
|
30
|
+
attrs: any;
|
|
31
|
+
slots: {
|
|
32
|
+
'header-right'?: () => unknown;
|
|
33
|
+
toolbar?: () => unknown;
|
|
34
|
+
footer?: () => unknown;
|
|
35
|
+
};
|
|
36
|
+
emit: {};
|
|
37
|
+
}>) => import("vue").VNode & {
|
|
38
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
39
|
+
};
|
|
40
|
+
declare const _default: typeof __VLS_export;
|
|
41
|
+
export default _default;
|
|
42
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
43
|
+
[K in keyof T]: T[K];
|
|
44
|
+
} : {
|
|
45
|
+
[K in keyof T as K]: T[K];
|
|
46
|
+
}) & {};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useMounted } from "@vueuse/core";
|
|
3
|
+
import { computed } from "vue";
|
|
4
|
+
import {
|
|
5
|
+
resolveDashboardExpandedHeight,
|
|
6
|
+
useDashboardChart
|
|
7
|
+
} from "../composables/use-dashboard-chart";
|
|
8
|
+
import DashboardSkeleton from "./block/dashboard-skeleton.vue";
|
|
9
|
+
import { dashboardChartRenderer } from "./charts/renderer";
|
|
10
|
+
import DashboardCard from "./dashboard-card.vue";
|
|
11
|
+
const {
|
|
12
|
+
source,
|
|
13
|
+
card = true,
|
|
14
|
+
menu = void 0,
|
|
15
|
+
freshness = void 0,
|
|
16
|
+
x,
|
|
17
|
+
xFormat,
|
|
18
|
+
xLabel,
|
|
19
|
+
series,
|
|
20
|
+
comparison,
|
|
21
|
+
area = false,
|
|
22
|
+
yAxis,
|
|
23
|
+
format,
|
|
24
|
+
reference,
|
|
25
|
+
height = 250,
|
|
26
|
+
legend = true,
|
|
27
|
+
points = 12,
|
|
28
|
+
selected,
|
|
29
|
+
onSelect,
|
|
30
|
+
...block
|
|
31
|
+
} = defineProps({
|
|
32
|
+
title: { type: [String, Number, Function], required: false },
|
|
33
|
+
subtitle: { type: [String, Number, Function], required: false },
|
|
34
|
+
size: { type: String, required: false },
|
|
35
|
+
rows: { type: String, required: false },
|
|
36
|
+
card: { type: Boolean, required: false },
|
|
37
|
+
activation: { type: String, required: false },
|
|
38
|
+
empty: { type: Object, required: false },
|
|
39
|
+
menu: { type: [Boolean, Array, Function], required: false },
|
|
40
|
+
actions: { type: Array, required: false },
|
|
41
|
+
freshness: { type: Boolean, required: false },
|
|
42
|
+
ui: { type: Object, required: false },
|
|
43
|
+
source: { type: Object, required: true },
|
|
44
|
+
x: { type: Function, required: true },
|
|
45
|
+
xFormat: { type: Function, required: false },
|
|
46
|
+
xLabel: { type: [String, Number, Function], required: false },
|
|
47
|
+
series: { type: Array, required: true },
|
|
48
|
+
comparison: { type: Object, required: false },
|
|
49
|
+
area: { type: Boolean, required: false },
|
|
50
|
+
yAxis: { type: Object, required: false },
|
|
51
|
+
format: { type: Function, required: false },
|
|
52
|
+
reference: { type: [Object, Array], required: false },
|
|
53
|
+
height: { type: Number, required: false },
|
|
54
|
+
legend: { type: Boolean, required: false },
|
|
55
|
+
points: { type: Number, required: false },
|
|
56
|
+
selected: { type: Function, required: false },
|
|
57
|
+
onSelect: { type: Function, required: false }
|
|
58
|
+
});
|
|
59
|
+
defineSlots();
|
|
60
|
+
const mounted = useMounted();
|
|
61
|
+
const allSeries = computed(() => {
|
|
62
|
+
const solid = series.map((entry, index) => ({
|
|
63
|
+
...entry,
|
|
64
|
+
color: entry.color ?? `series-${index % 6 + 1}`,
|
|
65
|
+
type: entry.type ?? (area && !entry.dashed ? "area" : "line")
|
|
66
|
+
}));
|
|
67
|
+
return comparison ? [{ color: "series-2", ...comparison, dashed: true, type: "line" }, ...solid] : solid;
|
|
68
|
+
});
|
|
69
|
+
const seed = computed(() => allSeries.value.map((entry) => entry.key).join("|"));
|
|
70
|
+
const skeletonSeries = computed(() => series.length);
|
|
71
|
+
const skeletonPoints = computed(() => source.data?.length || points);
|
|
72
|
+
const chart = useDashboardChart({
|
|
73
|
+
defaultType: "line",
|
|
74
|
+
format: () => format,
|
|
75
|
+
onSelect: () => onSelect,
|
|
76
|
+
references: () => reference,
|
|
77
|
+
rows: () => source.data ?? [],
|
|
78
|
+
selected: () => selected,
|
|
79
|
+
series: () => allSeries.value,
|
|
80
|
+
x: () => x,
|
|
81
|
+
xFormat: () => xFormat,
|
|
82
|
+
xLabel: () => xLabel,
|
|
83
|
+
yAxis: () => yAxis
|
|
84
|
+
});
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
<template>
|
|
88
|
+
<DashboardCard
|
|
89
|
+
v-bind="block"
|
|
90
|
+
:card
|
|
91
|
+
:menu
|
|
92
|
+
:freshness
|
|
93
|
+
:source
|
|
94
|
+
:legend="legend ? chart.legend.value : void 0"
|
|
95
|
+
:is-empty="chart.frame.value.data.length === 0 || chart.frame.value.series.length === 0"
|
|
96
|
+
:tabulate="chart.tabulate"
|
|
97
|
+
>
|
|
98
|
+
<template #skeleton>
|
|
99
|
+
<DashboardSkeleton
|
|
100
|
+
kind="lines"
|
|
101
|
+
:height
|
|
102
|
+
:series="skeletonSeries"
|
|
103
|
+
:count="skeletonPoints"
|
|
104
|
+
:seed
|
|
105
|
+
/>
|
|
106
|
+
</template>
|
|
107
|
+
<template v-if="$slots['header-right']" #header-right>
|
|
108
|
+
<slot name="header-right" />
|
|
109
|
+
</template>
|
|
110
|
+
<template v-if="$slots.toolbar" #toolbar>
|
|
111
|
+
<slot name="toolbar" />
|
|
112
|
+
</template>
|
|
113
|
+
<template v-if="$slots.footer" #footer>
|
|
114
|
+
<slot name="footer" />
|
|
115
|
+
</template>
|
|
116
|
+
|
|
117
|
+
<template #default="{ expanded }">
|
|
118
|
+
<component
|
|
119
|
+
:is="dashboardChartRenderer.xy"
|
|
120
|
+
v-if="mounted"
|
|
121
|
+
:frame="chart.frame.value"
|
|
122
|
+
:height="expanded ? resolveDashboardExpandedHeight(height) : height"
|
|
123
|
+
:selectable="chart.selectable.value"
|
|
124
|
+
@select="chart.select"
|
|
125
|
+
/>
|
|
126
|
+
<div v-else aria-hidden="true" :style="{ height: `${height}px` }" />
|
|
127
|
+
</template>
|
|
128
|
+
</DashboardCard>
|
|
129
|
+
</template>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { LazyTextValue } from '#ui-tools/shared/types/utils';
|
|
2
|
+
import type { DashboardAxisOptions, DashboardBlockBaseProps, DashboardReferenceLine, DashboardSelected, DashboardSelectEvent, DashboardSeries, DashboardSourceLike, DashboardValueFormat } from '../types/index.js';
|
|
3
|
+
declare const __VLS_export: <TRow>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<DashboardBlockBaseProps & {
|
|
5
|
+
source: DashboardSourceLike<readonly TRow[] | undefined>;
|
|
6
|
+
x: (row: TRow, index: number) => string | number | Date;
|
|
7
|
+
xFormat?: (value: string | number | Date) => string;
|
|
8
|
+
/** Header of the category column in the table view and CSV export. */
|
|
9
|
+
xLabel?: LazyTextValue;
|
|
10
|
+
series: readonly DashboardSeries<TRow>[];
|
|
11
|
+
/** Dashed line, e.g. the previous period. */
|
|
12
|
+
comparison?: DashboardSeries<TRow>;
|
|
13
|
+
/** Fills the area under every solid series. */
|
|
14
|
+
area?: boolean;
|
|
15
|
+
yAxis?: DashboardAxisOptions;
|
|
16
|
+
format?: DashboardValueFormat;
|
|
17
|
+
reference?: DashboardReferenceLine | readonly DashboardReferenceLine[];
|
|
18
|
+
height?: number;
|
|
19
|
+
legend?: boolean;
|
|
20
|
+
/** Expected number of x positions, drawn by the loading skeleton before data arrives. */
|
|
21
|
+
points?: number;
|
|
22
|
+
/** Rows shown as selected: a band marks their x position. */
|
|
23
|
+
selected?: DashboardSelected<TRow>;
|
|
24
|
+
/** A click on the chart selects the x position under the pointer. */
|
|
25
|
+
onSelect?: (event: DashboardSelectEvent<TRow>) => void;
|
|
26
|
+
}> & (typeof globalThis extends {
|
|
27
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
28
|
+
} ? P : {});
|
|
29
|
+
expose: (exposed: {}) => void;
|
|
30
|
+
attrs: any;
|
|
31
|
+
slots: {
|
|
32
|
+
'header-right'?: () => unknown;
|
|
33
|
+
toolbar?: () => unknown;
|
|
34
|
+
footer?: () => unknown;
|
|
35
|
+
};
|
|
36
|
+
emit: {};
|
|
37
|
+
}>) => import("vue").VNode & {
|
|
38
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
39
|
+
};
|
|
40
|
+
declare const _default: typeof __VLS_export;
|
|
41
|
+
export default _default;
|
|
42
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
43
|
+
[K in keyof T]: T[K];
|
|
44
|
+
} : {
|
|
45
|
+
[K in keyof T as K]: T[K];
|
|
46
|
+
}) & {};
|