nuxt-ui-tools 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/module.mjs +18 -2
- package/dist/runtime/dashboard/components/block/dashboard-block-state.d.vue.ts +2 -0
- package/dist/runtime/dashboard/components/block/dashboard-block-state.vue +4 -1
- package/dist/runtime/dashboard/components/block/dashboard-block-state.vue.d.ts +2 -0
- package/dist/runtime/dashboard/components/block/dashboard-chips.d.vue.ts +20 -0
- package/dist/runtime/dashboard/components/block/dashboard-chips.vue +42 -0
- package/dist/runtime/dashboard/components/block/dashboard-chips.vue.d.ts +20 -0
- package/dist/runtime/dashboard/components/block/dashboard-series-picker.d.vue.ts +8 -0
- package/dist/runtime/dashboard/components/block/dashboard-series-picker.vue +29 -0
- package/dist/runtime/dashboard/components/block/dashboard-series-picker.vue.d.ts +8 -0
- package/dist/runtime/dashboard/components/block/dashboard-skeleton.d.vue.ts +1 -1
- package/dist/runtime/dashboard/components/block/dashboard-skeleton.vue.d.ts +1 -1
- package/dist/runtime/dashboard/components/block/dashboard-view-scope.d.vue.ts +21 -0
- package/dist/runtime/dashboard/components/block/dashboard-view-scope.vue +12 -0
- package/dist/runtime/dashboard/components/block/dashboard-view-scope.vue.d.ts +21 -0
- package/dist/runtime/dashboard/components/dashboard-alerts.vue +3 -3
- package/dist/runtime/dashboard/components/dashboard-bar-chart.d.vue.ts +14 -3
- package/dist/runtime/dashboard/components/dashboard-bar-chart.vue +30 -9
- package/dist/runtime/dashboard/components/dashboard-bar-chart.vue.d.ts +14 -3
- package/dist/runtime/dashboard/components/dashboard-bars.vue +4 -4
- package/dist/runtime/dashboard/components/dashboard-card.vue +28 -6
- package/dist/runtime/dashboard/components/dashboard-combo-chart.d.vue.ts +6 -1
- package/dist/runtime/dashboard/components/dashboard-combo-chart.vue +13 -3
- package/dist/runtime/dashboard/components/dashboard-combo-chart.vue.d.ts +6 -1
- package/dist/runtime/dashboard/components/dashboard-donut-chart.vue +5 -5
- package/dist/runtime/dashboard/components/dashboard-feed.vue +1 -1
- package/dist/runtime/dashboard/components/dashboard-filter.d.vue.ts +67 -0
- package/dist/runtime/dashboard/components/dashboard-filter.vue +134 -0
- package/dist/runtime/dashboard/components/dashboard-filter.vue.d.ts +67 -0
- package/dist/runtime/dashboard/components/dashboard-filters.d.vue.ts +49 -0
- package/dist/runtime/dashboard/components/dashboard-filters.vue +96 -0
- package/dist/runtime/dashboard/components/dashboard-filters.vue.d.ts +49 -0
- package/dist/runtime/dashboard/components/dashboard-funnel.vue +5 -5
- package/dist/runtime/dashboard/components/dashboard-gauge.vue +3 -3
- package/dist/runtime/dashboard/components/dashboard-grid.d.vue.ts +10 -3
- package/dist/runtime/dashboard/components/dashboard-grid.vue +24 -9
- package/dist/runtime/dashboard/components/dashboard-grid.vue.d.ts +10 -3
- package/dist/runtime/dashboard/components/dashboard-line-chart.d.vue.ts +14 -3
- package/dist/runtime/dashboard/components/dashboard-line-chart.vue +30 -9
- package/dist/runtime/dashboard/components/dashboard-line-chart.vue.d.ts +14 -3
- package/dist/runtime/dashboard/components/dashboard-list.d.vue.ts +3 -0
- package/dist/runtime/dashboard/components/dashboard-list.vue +18 -6
- package/dist/runtime/dashboard/components/dashboard-list.vue.d.ts +3 -0
- package/dist/runtime/dashboard/components/dashboard-page.d.vue.ts +53 -0
- package/dist/runtime/dashboard/components/dashboard-page.vue +156 -0
- package/dist/runtime/dashboard/components/dashboard-page.vue.d.ts +53 -0
- package/dist/runtime/dashboard/components/dashboard-paired-bars.vue +4 -4
- package/dist/runtime/dashboard/components/dashboard-refresh.d.vue.ts +1 -1
- package/dist/runtime/dashboard/components/dashboard-refresh.vue +1 -0
- package/dist/runtime/dashboard/components/dashboard-refresh.vue.d.ts +1 -1
- package/dist/runtime/dashboard/components/dashboard-stack-bar.vue +4 -4
- package/dist/runtime/dashboard/components/dashboard-stat.d.vue.ts +14 -2
- package/dist/runtime/dashboard/components/dashboard-stat.vue +28 -10
- package/dist/runtime/dashboard/components/dashboard-stat.vue.d.ts +14 -2
- package/dist/runtime/dashboard/components/dashboard-stats.vue +3 -3
- package/dist/runtime/dashboard/components/dashboard-table.d.vue.ts +1 -1
- package/dist/runtime/dashboard/components/dashboard-table.vue +3 -3
- package/dist/runtime/dashboard/components/dashboard-table.vue.d.ts +1 -1
- package/dist/runtime/dashboard/components/dashboard-tabs.d.vue.ts +1 -1
- package/dist/runtime/dashboard/components/dashboard-tabs.vue.d.ts +1 -1
- package/dist/runtime/dashboard/components/dashboard-total.d.vue.ts +7 -2
- package/dist/runtime/dashboard/components/dashboard-total.vue +10 -2
- package/dist/runtime/dashboard/components/dashboard-total.vue.d.ts +7 -2
- package/dist/runtime/dashboard/components/dashboard-view-tabs.d.vue.ts +33 -0
- package/dist/runtime/dashboard/components/dashboard-view-tabs.vue +66 -0
- package/dist/runtime/dashboard/components/dashboard-view-tabs.vue.d.ts +33 -0
- package/dist/runtime/dashboard/components/dashboard-widget.vue +1 -1
- package/dist/runtime/dashboard/components/filter/dashboard-filter-menu.d.vue.ts +44 -0
- package/dist/runtime/dashboard/components/filter/dashboard-filter-menu.vue +220 -0
- package/dist/runtime/dashboard/components/filter/dashboard-filter-menu.vue.d.ts +44 -0
- package/dist/runtime/dashboard/composables/use-dashboard-api.d.ts +6 -1
- package/dist/runtime/dashboard/composables/use-dashboard-api.js +29 -6
- package/dist/runtime/dashboard/composables/use-dashboard-block.d.ts +5 -4
- package/dist/runtime/dashboard/composables/use-dashboard-block.js +32 -15
- package/dist/runtime/dashboard/composables/use-dashboard-chart.d.ts +8 -1
- package/dist/runtime/dashboard/composables/use-dashboard-chart.js +16 -4
- package/dist/runtime/dashboard/composables/use-dashboard-context.d.ts +50 -0
- package/dist/runtime/dashboard/composables/use-dashboard-context.js +56 -0
- package/dist/runtime/dashboard/composables/use-dashboard-derived.js +6 -1
- package/dist/runtime/dashboard/composables/use-dashboard-filter-control.d.ts +16 -0
- package/dist/runtime/dashboard/composables/use-dashboard-filter-control.js +161 -0
- package/dist/runtime/dashboard/composables/use-dashboard-filter-scope.d.ts +37 -0
- package/dist/runtime/dashboard/composables/use-dashboard-filter-scope.js +107 -0
- package/dist/runtime/dashboard/composables/use-dashboard-format.d.ts +46 -6
- package/dist/runtime/dashboard/composables/use-dashboard-format.js +51 -8
- package/dist/runtime/dashboard/composables/use-dashboard-options.d.ts +11 -4
- package/dist/runtime/dashboard/composables/use-dashboard-options.js +33 -47
- package/dist/runtime/dashboard/composables/use-dashboard-remote-options.d.ts +8 -5
- package/dist/runtime/dashboard/composables/use-dashboard-remote-options.js +59 -70
- package/dist/runtime/dashboard/composables/use-dashboard-resource.d.ts +15 -4
- package/dist/runtime/dashboard/composables/use-dashboard-resource.js +52 -17
- package/dist/runtime/dashboard/composables/use-dashboard-scope.d.ts +10 -7
- package/dist/runtime/dashboard/composables/use-dashboard-scope.js +26 -16
- package/dist/runtime/dashboard/composables/use-dashboard-series-picker.d.ts +20 -0
- package/dist/runtime/dashboard/composables/use-dashboard-series-picker.js +30 -0
- package/dist/runtime/dashboard/composables/use-dashboard-time.d.ts +2 -0
- package/dist/runtime/dashboard/composables/use-dashboard-time.js +4 -1
- package/dist/runtime/dashboard/composables/use-dashboard-ui.d.ts +12 -2
- package/dist/runtime/dashboard/composables/use-dashboard-ui.js +3 -0
- package/dist/runtime/dashboard/composables/use-dashboard-views.d.ts +15 -3
- package/dist/runtime/dashboard/composables/use-dashboard-views.js +33 -10
- package/dist/runtime/dashboard/composables/use-dashboard.d.ts +18 -12
- package/dist/runtime/dashboard/composables/use-dashboard.js +98 -9
- package/dist/runtime/dashboard/index.d.ts +3 -1
- package/dist/runtime/dashboard/index.js +3 -1
- package/dist/runtime/dashboard/schema/index.d.ts +62 -30
- package/dist/runtime/dashboard/schema/index.js +3 -0
- package/dist/runtime/dashboard/types/blocks.d.ts +30 -4
- package/dist/runtime/dashboard/types/charts.d.ts +2 -2
- package/dist/runtime/dashboard/types/controls.d.ts +123 -0
- package/dist/runtime/dashboard/types/filters.d.ts +236 -0
- package/dist/runtime/dashboard/types/index.d.ts +3 -2
- package/dist/runtime/dashboard/types/page.d.ts +17 -0
- package/dist/runtime/dashboard/types/page.js +0 -0
- package/dist/runtime/dashboard/types/resource.d.ts +66 -28
- package/dist/runtime/dashboard/types/runtime.d.ts +39 -8
- package/dist/runtime/dashboard/types/schema.d.ts +94 -54
- package/dist/runtime/dashboard/types/ui.d.ts +78 -0
- package/dist/runtime/dashboard/utils/builders/dashboard-filters.d.ts +142 -0
- package/dist/runtime/dashboard/utils/builders/dashboard-filters.js +135 -0
- package/dist/runtime/dashboard/utils/charts.d.ts +4 -15
- package/dist/runtime/dashboard/utils/charts.js +26 -28
- package/dist/runtime/dashboard/utils/{params/codecs.d.ts → codecs.d.ts} +2 -2
- package/dist/runtime/dashboard/utils/{params/codecs.js → codecs.js} +1 -1
- package/dist/runtime/dashboard/utils/environment.d.ts +36 -0
- package/dist/runtime/dashboard/utils/environment.js +30 -0
- package/dist/runtime/dashboard/utils/filters.d.ts +44 -0
- package/dist/runtime/dashboard/utils/filters.js +62 -0
- package/dist/runtime/dashboard/utils/format.d.ts +25 -0
- package/dist/runtime/dashboard/utils/format.js +66 -0
- package/dist/runtime/dashboard/utils/grid.d.ts +17 -0
- package/dist/runtime/dashboard/utils/grid.js +14 -0
- package/dist/runtime/dashboard/utils/options.d.ts +3 -1
- package/dist/runtime/dashboard/utils/options.js +6 -0
- package/dist/runtime/dashboard/utils/remote.d.ts +7 -0
- package/dist/runtime/dashboard/utils/remote.js +14 -0
- package/dist/runtime/dashboard/utils/resource.d.ts +16 -7
- package/dist/runtime/dashboard/utils/resource.js +15 -9
- package/dist/runtime/dashboard/utils/schema.d.ts +8 -3
- package/dist/runtime/dashboard/utils/schema.js +9 -4
- package/dist/runtime/dashboard/utils/state.d.ts +11 -6
- package/dist/runtime/dashboard/utils/state.js +10 -5
- package/dist/runtime/dashboard/utils/time.d.ts +2 -0
- package/dist/runtime/dashboard/utils/time.js +11 -1
- package/dist/runtime/dashboard/utils/ui.d.ts +1 -1
- package/dist/runtime/dashboard/utils/ui.js +1 -1
- package/dist/runtime/form/components/actions/form-actions.vue +13 -127
- package/dist/runtime/form/components/page/form-page-actions.d.vue.ts +3 -0
- package/dist/runtime/form/components/page/form-page-actions.vue +40 -0
- package/dist/runtime/form/components/page/form-page-actions.vue.d.ts +3 -0
- package/dist/runtime/form/components/page/form-page-header.d.vue.ts +24 -0
- package/dist/runtime/form/components/page/form-page-header.vue +99 -0
- package/dist/runtime/form/components/page/form-page-header.vue.d.ts +24 -0
- package/dist/runtime/form/components/page/form-page-navigation.d.vue.ts +34 -0
- package/dist/runtime/form/components/page/form-page-navigation.vue +229 -0
- package/dist/runtime/form/components/page/form-page-navigation.vue.d.ts +34 -0
- package/dist/runtime/form/components/page/form-page-section.d.vue.ts +19 -0
- package/dist/runtime/form/components/page/form-page-section.vue +114 -0
- package/dist/runtime/form/components/page/form-page-section.vue.d.ts +19 -0
- package/dist/runtime/form/components/page/form-page-sections.d.vue.ts +21 -0
- package/dist/runtime/form/components/page/form-page-sections.vue +75 -0
- package/dist/runtime/form/components/page/form-page-sections.vue.d.ts +21 -0
- package/dist/runtime/form/components/page/form-page.d.vue.ts +80 -0
- package/dist/runtime/form/components/page/form-page.vue +91 -0
- package/dist/runtime/form/components/page/form-page.vue.d.ts +80 -0
- package/dist/runtime/form/components/renderer/form-field-shell.vue +7 -11
- package/dist/runtime/form/components/root/form.vue +26 -195
- package/dist/runtime/form/composables/use-form-action-buttons.d.ts +32 -0
- package/dist/runtime/form/composables/use-form-action-buttons.js +89 -0
- package/dist/runtime/form/composables/use-form-actions.d.ts +8 -5
- package/dist/runtime/form/composables/use-form-actions.js +1 -1
- package/dist/runtime/form/composables/use-form-page-scroll.d.ts +22 -0
- package/dist/runtime/form/composables/use-form-page-scroll.js +178 -0
- package/dist/runtime/form/composables/use-form-page.d.ts +114 -0
- package/dist/runtime/form/composables/use-form-page.js +83 -0
- package/dist/runtime/form/composables/use-form-root.d.ts +34 -0
- package/dist/runtime/form/composables/use-form-root.js +171 -0
- package/dist/runtime/form/composables/use-form-runtime.js +13 -4
- package/dist/runtime/form/composables/use-form.js +2 -22
- package/dist/runtime/form/fields/card-selection.d.ts +1 -0
- package/dist/runtime/form/fields/card-selection.js +1 -0
- package/dist/runtime/form/fields/checkbox-card/component.vue +28 -17
- package/dist/runtime/form/fields/checkbox-card/types.d.ts +2 -5
- package/dist/runtime/form/fields/checkbox-group/component.vue +5 -0
- package/dist/runtime/form/fields/choice-card/choice-card-label.d.vue.ts +17 -0
- package/dist/runtime/form/fields/choice-card/choice-card-label.vue +50 -0
- package/dist/runtime/form/fields/choice-card/choice-card-label.vue.d.ts +17 -0
- package/dist/runtime/form/fields/choice-card/types.d.ts +31 -0
- package/dist/runtime/form/fields/choice-card/types.js +0 -0
- package/dist/runtime/form/fields/choice-card/use-choice-card.d.ts +22 -0
- package/dist/runtime/form/fields/choice-card/use-choice-card.js +52 -0
- package/dist/runtime/form/fields/radio/component.vue +10 -0
- package/dist/runtime/form/fields/radio-card/component.vue +17 -16
- package/dist/runtime/form/fields/radio-card/types.d.ts +2 -4
- package/dist/runtime/form/index.d.ts +1 -1
- package/dist/runtime/form/index.js +7 -1
- package/dist/runtime/form/schema/index.d.ts +1 -1
- package/dist/runtime/form/schema/index.js +1 -0
- package/dist/runtime/form/schema/page.d.ts +50 -0
- package/dist/runtime/form/schema/page.js +25 -0
- package/dist/runtime/form/types/index.d.ts +1 -0
- package/dist/runtime/form/types/options.d.ts +1 -11
- package/dist/runtime/form/types/page.d.ts +172 -0
- package/dist/runtime/form/types/page.js +0 -0
- package/dist/runtime/form/types/ui.d.ts +60 -0
- package/dist/runtime/form/utils/controls.d.ts +15 -0
- package/dist/runtime/form/utils/controls.js +38 -0
- package/dist/runtime/form/utils/focus.js +1 -1
- package/dist/runtime/form/utils/layout.js +3 -1
- package/dist/runtime/form/utils/page.d.ts +20 -0
- package/dist/runtime/form/utils/page.js +107 -0
- package/dist/runtime/form/utils/state.d.ts +2 -0
- package/dist/runtime/form/utils/state.js +1 -1
- package/dist/runtime/form/utils/ui.js +1 -0
- package/dist/runtime/i18n/locales/en.js +47 -0
- package/dist/runtime/i18n/locales/fr.js +47 -0
- package/dist/runtime/i18n/types.d.ts +70 -0
- package/dist/runtime/shared/styles/tokens.css +1 -1
- package/dist/runtime/shared/types/query.d.ts +8 -0
- package/dist/runtime/table/types/index.d.ts +1 -0
- package/dist/runtime/table/types/remote-options.d.ts +64 -0
- package/dist/runtime/table/types/remote-options.js +0 -0
- package/dist/runtime/table/types/source.d.ts +10 -1
- package/dist/runtime/table/utils/builders/table-source.d.ts +2 -6
- package/dist/runtime/table/utils/index.d.ts +1 -0
- package/dist/runtime/table/utils/index.js +1 -0
- package/dist/runtime/table/utils/remote-table-options.d.ts +26 -0
- package/dist/runtime/table/utils/remote-table-options.js +88 -0
- package/package.json +4 -1
- package/dist/runtime/dashboard/composables/use-dashboard-param-scope.d.ts +0 -30
- package/dist/runtime/dashboard/composables/use-dashboard-param-scope.js +0 -71
- package/dist/runtime/dashboard/types/options.d.ts +0 -46
- package/dist/runtime/dashboard/types/params.d.ts +0 -115
- package/dist/runtime/dashboard/utils/builders/dashboard-params.d.ts +0 -85
- package/dist/runtime/dashboard/utils/builders/dashboard-params.js +0 -87
- /package/dist/runtime/dashboard/types/{options.js → controls.js} +0 -0
- /package/dist/runtime/dashboard/types/{params.js → filters.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { computed, shallowRef } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { dashboardFilterBuilder } from "../utils/builders/dashboard-filters.js";
|
|
3
3
|
import { createDashboardResourceFacade } from "../utils/resource.js";
|
|
4
|
-
import { assertDashboardMemberKey } from "../utils/schema.js";
|
|
4
|
+
import { assertDashboardMemberKey, resolveDashboardFilters } from "../utils/schema.js";
|
|
5
5
|
import {
|
|
6
6
|
combineDashboardStates,
|
|
7
7
|
refreshDashboardSources,
|
|
@@ -9,19 +9,20 @@ import {
|
|
|
9
9
|
} from "../utils/state.js";
|
|
10
10
|
import { createDashboardTrackedData } from "../utils/tracker.js";
|
|
11
11
|
import { useDashboardDerived } from "./use-dashboard-derived.js";
|
|
12
|
-
import {
|
|
12
|
+
import { useDashboardFilterScope } from "./use-dashboard-filter-scope.js";
|
|
13
13
|
import { useDashboardResource } from "./use-dashboard-resource.js";
|
|
14
14
|
export function useDashboardScope(params) {
|
|
15
15
|
const { input, scopeKey } = params;
|
|
16
|
+
const enabled = params.enabled ?? computed(() => true);
|
|
16
17
|
const queryKey = [params.schemaKey, scopeKey || "$root"];
|
|
17
|
-
const
|
|
18
|
-
|
|
18
|
+
const scopeLabel = scopeKey ? `view "${scopeKey}"` : "the dashboard root";
|
|
19
|
+
const filterScope = useDashboardFilterScope({
|
|
20
|
+
definitions: resolveDashboardFilters({ builder: dashboardFilterBuilder, input: input.filters }),
|
|
21
|
+
environment: params.environment,
|
|
22
|
+
owner: scopeLabel,
|
|
19
23
|
prefix: params.prefix,
|
|
20
24
|
queryKey
|
|
21
25
|
});
|
|
22
|
-
const visibleParams = mergeDashboardParamValues(
|
|
23
|
-
params.shared ? [params.shared, paramScope] : [paramScope]
|
|
24
|
-
);
|
|
25
26
|
const declared = shallowRef(false);
|
|
26
27
|
const declarations = /* @__PURE__ */ new Map();
|
|
27
28
|
const resources = [];
|
|
@@ -35,7 +36,12 @@ export function useDashboardScope(params) {
|
|
|
35
36
|
query(definition) {
|
|
36
37
|
const query = typeof definition === "function" ? { query: definition } : definition;
|
|
37
38
|
const slot = shallowRef(null);
|
|
38
|
-
const facade = createDashboardResourceFacade(
|
|
39
|
+
const facade = createDashboardResourceFacade({
|
|
40
|
+
defaultValue: query.defaultValue,
|
|
41
|
+
slot,
|
|
42
|
+
stage,
|
|
43
|
+
tracker: params.tracker
|
|
44
|
+
});
|
|
39
45
|
declarations.set(facade, { input: query, slot, stage });
|
|
40
46
|
return facade;
|
|
41
47
|
}
|
|
@@ -45,24 +51,26 @@ export function useDashboardScope(params) {
|
|
|
45
51
|
background: createStage("background"),
|
|
46
52
|
deferred: createStage("deferred"),
|
|
47
53
|
essential: createStage("essential"),
|
|
48
|
-
|
|
54
|
+
filters: filterScope.values
|
|
49
55
|
});
|
|
50
|
-
const scopeLabel = scopeKey ? `view "${scopeKey}"` : "the dashboard root";
|
|
51
56
|
const taken = new Set(params.rootSources?.keys());
|
|
52
57
|
const members = /* @__PURE__ */ new Map();
|
|
53
58
|
function instantiate(key, declaration) {
|
|
54
59
|
const resource = useDashboardResource({
|
|
60
|
+
environment: params.environment,
|
|
55
61
|
id: scopeKey ? `${scopeKey}.${key}` : key,
|
|
56
62
|
input: declaration.input,
|
|
57
63
|
key,
|
|
58
64
|
scope: {
|
|
59
65
|
active: params.active,
|
|
66
|
+
enabled,
|
|
60
67
|
prefix: params.prefix,
|
|
61
68
|
queryKey,
|
|
62
69
|
refetchInterval: params.refetchInterval,
|
|
63
70
|
settled
|
|
64
71
|
},
|
|
65
|
-
stage: declaration.stage
|
|
72
|
+
stage: declaration.stage,
|
|
73
|
+
tracker: params.tracker
|
|
66
74
|
});
|
|
67
75
|
declaration.slot.value = resource;
|
|
68
76
|
resources.push(resource);
|
|
@@ -84,7 +92,7 @@ export function useDashboardScope(params) {
|
|
|
84
92
|
new Map([...params.rootSources ?? [], ...members]),
|
|
85
93
|
params.tracker
|
|
86
94
|
);
|
|
87
|
-
const derived = input.derive?.({ data,
|
|
95
|
+
const derived = input.derive?.({ data, filters: filterScope.values }) ?? {};
|
|
88
96
|
for (const [key, evaluate] of Object.entries(derived)) {
|
|
89
97
|
assertDashboardMemberKey(key, taken, scopeLabel);
|
|
90
98
|
taken.add(key);
|
|
@@ -93,9 +101,10 @@ export function useDashboardScope(params) {
|
|
|
93
101
|
}
|
|
94
102
|
const essentials = resources.filter((resource) => resource.stage === "essential");
|
|
95
103
|
const state = computed(() => {
|
|
104
|
+
if (!enabled.value) return "disabled";
|
|
96
105
|
if (!params.active.value) return "idle";
|
|
97
106
|
const combined = combineDashboardStates(essentials.map((resource) => resource.state.value));
|
|
98
|
-
return combined === "idle" ? "ready" : combined;
|
|
107
|
+
return combined === "idle" || combined === "disabled" ? "ready" : combined;
|
|
99
108
|
});
|
|
100
109
|
const updatedAt = computed(
|
|
101
110
|
() => resolveDashboardUpdatedAt(
|
|
@@ -106,7 +115,7 @@ export function useDashboardScope(params) {
|
|
|
106
115
|
let pending = null;
|
|
107
116
|
function refresh() {
|
|
108
117
|
pending ??= refreshDashboardSources(
|
|
109
|
-
resources.filter((resource) => resource.active.value)
|
|
118
|
+
resources.filter((resource) => resource.active.value && resource.state.value !== "disabled")
|
|
110
119
|
).finally(() => {
|
|
111
120
|
pending = null;
|
|
112
121
|
refreshing.value = false;
|
|
@@ -115,9 +124,10 @@ export function useDashboardScope(params) {
|
|
|
115
124
|
return pending;
|
|
116
125
|
}
|
|
117
126
|
return {
|
|
127
|
+
enabled,
|
|
128
|
+
filterScope,
|
|
118
129
|
label: input.label,
|
|
119
130
|
members,
|
|
120
|
-
paramScope,
|
|
121
131
|
refresh,
|
|
122
132
|
refreshing,
|
|
123
133
|
resources,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DashboardFilterControl, DashboardOptionValue, DashboardSeries } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Series of an XY chart: the declared list, or one series per option a filter picks. With a filter,
|
|
4
|
+
* the chart draws the picker (add from the options, presets) and one removable chip per series, in
|
|
5
|
+
* the series' own color, in place of the legend.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useDashboardSeriesPicker<TRow, TItem extends DashboardOptionValue>(params: {
|
|
8
|
+
series: () => readonly DashboardSeries<TRow>[] | DashboardFilterControl<unknown, TItem>;
|
|
9
|
+
value: () => ((row: TRow, item: TItem) => number | null | undefined) | undefined;
|
|
10
|
+
}): {
|
|
11
|
+
chips: import("vue").ComputedRef<{
|
|
12
|
+
color: string;
|
|
13
|
+
key: string;
|
|
14
|
+
label: string;
|
|
15
|
+
remove: () => void;
|
|
16
|
+
removeLabel: string;
|
|
17
|
+
}[]>;
|
|
18
|
+
picker: import("vue").ComputedRef<DashboardFilterControl<unknown, TItem> | undefined>;
|
|
19
|
+
series: import("vue").ComputedRef<readonly DashboardSeries<TRow>[]>;
|
|
20
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import { useUiToolsLocale } from "../../i18n/use-locale.js";
|
|
3
|
+
import { DASHBOARD_PALETTE_SIZE, resolveDashboardColor } from "../utils/charts.js";
|
|
4
|
+
import { resolveDashboardFilterSeries } from "../utils/filters.js";
|
|
5
|
+
export function useDashboardSeriesPicker(params) {
|
|
6
|
+
const { t } = useUiToolsLocale();
|
|
7
|
+
const picker = computed(() => {
|
|
8
|
+
const declared = params.series();
|
|
9
|
+
return isSeriesList(declared) ? void 0 : declared;
|
|
10
|
+
});
|
|
11
|
+
const series = computed(() => {
|
|
12
|
+
const declared = params.series();
|
|
13
|
+
return isSeriesList(declared) ? declared : resolveDashboardFilterSeries(declared, params.value());
|
|
14
|
+
});
|
|
15
|
+
const chips = computed(() => {
|
|
16
|
+
const filter = picker.value;
|
|
17
|
+
if (!filter) return [];
|
|
18
|
+
return filter.selected.map((option, index) => ({
|
|
19
|
+
color: resolveDashboardColor(`series-${index % DASHBOARD_PALETTE_SIZE + 1}`, index),
|
|
20
|
+
key: String(option.value),
|
|
21
|
+
label: option.label,
|
|
22
|
+
remove: () => filter.toggle(option.value),
|
|
23
|
+
removeLabel: t("dashboard.series.remove", { label: option.label })
|
|
24
|
+
}));
|
|
25
|
+
});
|
|
26
|
+
return { chips, picker, series };
|
|
27
|
+
}
|
|
28
|
+
function isSeriesList(value) {
|
|
29
|
+
return Array.isArray(value);
|
|
30
|
+
}
|
|
@@ -10,4 +10,6 @@ export declare function useDashboardTime(): {
|
|
|
10
10
|
day: (value: DashboardTimeValue) => string;
|
|
11
11
|
/** `3 min ago`, `yesterday`, then the date. */
|
|
12
12
|
relative: (value: DashboardTimeValue) => string;
|
|
13
|
+
/** Today's date, following the clock across midnight. */
|
|
14
|
+
today: () => string;
|
|
13
15
|
};
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
formatDashboardDateTime,
|
|
5
5
|
formatDashboardDay,
|
|
6
6
|
formatDashboardRelativeTime,
|
|
7
|
+
formatDashboardToday,
|
|
7
8
|
toDashboardTime
|
|
8
9
|
} from "../utils/time.js";
|
|
9
10
|
const TICK = 3e4;
|
|
@@ -35,6 +36,8 @@ export function useDashboardTime() {
|
|
|
35
36
|
/** Day heading: `Today`, `Yesterday`, then the date. */
|
|
36
37
|
day: (value) => formatDashboardDay(toDashboardTime(value), clock.value, code.value),
|
|
37
38
|
/** `3 min ago`, `yesterday`, then the date. */
|
|
38
|
-
relative: (value) => formatDashboardRelativeTime(toDashboardTime(value), clock.value, code.value)
|
|
39
|
+
relative: (value) => formatDashboardRelativeTime(toDashboardTime(value), clock.value, code.value),
|
|
40
|
+
/** Today's date, following the clock across midnight. */
|
|
41
|
+
today: () => formatDashboardToday(clock.value, code.value)
|
|
39
42
|
};
|
|
40
43
|
}
|
|
@@ -4,19 +4,29 @@ import type { DashboardMenu, DashboardUiConfig } from '../types/index.js';
|
|
|
4
4
|
export declare function useDashboardUi(): ComputedRef<DashboardUiConfig>;
|
|
5
5
|
interface DashboardGridContext {
|
|
6
6
|
panels: ComputedRef<boolean>;
|
|
7
|
+
/** Column count at the current breakpoint. */
|
|
8
|
+
columns: ComputedRef<number>;
|
|
9
|
+
/** Space between cells, a CSS length (`1px` in panels, where the gap draws the rules). */
|
|
10
|
+
gap: ComputedRef<string>;
|
|
11
|
+
/** Rows that are not full share their free width between their cells. */
|
|
12
|
+
fill: ComputedRef<boolean>;
|
|
7
13
|
/** Card menu of the blocks that do not set their own. */
|
|
8
14
|
menu: ComputedRef<DashboardMenu | undefined>;
|
|
9
15
|
/** `freshness` of the blocks that do not set their own. */
|
|
10
16
|
freshness: ComputedRef<boolean | undefined>;
|
|
11
17
|
}
|
|
12
18
|
/**
|
|
13
|
-
* Lets blocks know whether they sit in a `panels` grid (joined cells, no card borders),
|
|
14
|
-
*
|
|
19
|
+
* Lets blocks know whether they sit in a `panels` grid (joined cells, no card borders), hands them
|
|
20
|
+
* the grid's block defaults, and the geometry their cell style is computed from. A nested grid
|
|
21
|
+
* inherits the defaults it does not set.
|
|
15
22
|
*/
|
|
16
23
|
export declare function provideDashboardGrid(params: {
|
|
17
24
|
panels: () => boolean;
|
|
18
25
|
menu: () => DashboardMenu | undefined;
|
|
19
26
|
freshness: () => boolean | undefined;
|
|
27
|
+
columns: () => number;
|
|
28
|
+
gap: () => string;
|
|
29
|
+
fill: () => boolean;
|
|
20
30
|
}): void;
|
|
21
31
|
export declare function useDashboardGridContext(): DashboardGridContext | null;
|
|
22
32
|
export {};
|
|
@@ -9,7 +9,10 @@ const dashboardGridKey = Symbol("nuxt-ui-tools.dashboard-grid");
|
|
|
9
9
|
export function provideDashboardGrid(params) {
|
|
10
10
|
const parent = useDashboardGridContext();
|
|
11
11
|
provide(dashboardGridKey, {
|
|
12
|
+
columns: computed(params.columns),
|
|
13
|
+
fill: computed(params.fill),
|
|
12
14
|
freshness: computed(() => params.freshness() ?? parent?.freshness.value),
|
|
15
|
+
gap: computed(params.gap),
|
|
13
16
|
menu: computed(() => params.menu() ?? parent?.menu.value),
|
|
14
17
|
panels: computed(params.panels)
|
|
15
18
|
});
|
|
@@ -1,46 +1,58 @@
|
|
|
1
1
|
import type { ComputedRef } from 'vue';
|
|
2
2
|
import type { DashboardSourceLike } from '../types/index.js';
|
|
3
3
|
import type { DashboardRuntimeSchema } from '../types/runtime.js';
|
|
4
|
+
import type { DashboardEnvironment } from '../utils/environment.js';
|
|
4
5
|
import type { DashboardReadTracker } from '../utils/tracker.js';
|
|
5
6
|
import { useDashboardScope } from './use-dashboard-scope.js';
|
|
6
7
|
/**
|
|
7
8
|
* Owns the view controller: the URL-synced current view (`view`, pushed to history so Back returns
|
|
8
9
|
* to the previous tab) and one scope per view. A view's queries stay idle until the view is opened
|
|
9
10
|
* once, then stay warm across switches.
|
|
11
|
+
*
|
|
12
|
+
* A view whose `enabled` condition does not hold is out of the dashboard: it has no tab, the
|
|
13
|
+
* current view never resolves to it (a URL naming it falls back to the default view, else the
|
|
14
|
+
* first enabled one), and its scope is inactive with every query `disabled`.
|
|
10
15
|
*/
|
|
11
16
|
export declare function useDashboardViews(params: {
|
|
12
17
|
schema: DashboardRuntimeSchema;
|
|
13
18
|
root: ReturnType<typeof useDashboardScope>;
|
|
14
19
|
refetchInterval: ComputedRef<number>;
|
|
15
20
|
tracker: DashboardReadTracker;
|
|
21
|
+
environment: DashboardEnvironment;
|
|
16
22
|
}): {
|
|
17
23
|
current: import("vue").WritableComputedRef<string, string>;
|
|
18
24
|
keys: string[];
|
|
19
25
|
views: {
|
|
26
|
+
enabled: ComputedRef<boolean>;
|
|
27
|
+
input: import("../types/runtime.js").DashboardRuntimeScopeInput;
|
|
20
28
|
key: string;
|
|
21
29
|
label: () => string;
|
|
22
30
|
opened: import("vue").ShallowRef<boolean, boolean>;
|
|
23
31
|
scope: {
|
|
32
|
+
enabled: ComputedRef<boolean>;
|
|
33
|
+
filterScope: import("./use-dashboard-filter-scope.js").DashboardFilterScope;
|
|
24
34
|
label: import("../../shared/index.js").LazyTextValue | undefined;
|
|
25
35
|
members: Map<string, DashboardSourceLike<unknown>>;
|
|
26
|
-
paramScope: import("./use-dashboard-param-scope.js").DashboardParamScope;
|
|
27
36
|
refresh: () => Promise<void>;
|
|
28
37
|
refreshing: import("vue").ShallowRef<boolean, boolean>;
|
|
29
38
|
resources: {
|
|
30
39
|
activate: () => void;
|
|
31
40
|
active: ComputedRef<boolean>;
|
|
32
41
|
data: ComputedRef<unknown>;
|
|
33
|
-
error:
|
|
42
|
+
error: ComputedRef<unknown>;
|
|
34
43
|
id: string;
|
|
35
44
|
refresh: () => Promise<void>;
|
|
45
|
+
fetching: ComputedRef<boolean>;
|
|
36
46
|
refreshing: ComputedRef<boolean>;
|
|
37
47
|
stage: import("..").DashboardStage;
|
|
38
48
|
state: ComputedRef<import("..").DashboardResourceState>;
|
|
39
49
|
updatedAt: ComputedRef<number | undefined>;
|
|
40
|
-
|
|
50
|
+
filters: import("./use-dashboard-filter-scope.js").DashboardFilterScope;
|
|
41
51
|
}[];
|
|
42
52
|
state: ComputedRef<import("..").DashboardResourceState>;
|
|
43
53
|
updatedAt: ComputedRef<number | undefined>;
|
|
44
54
|
};
|
|
45
55
|
}[];
|
|
46
56
|
};
|
|
57
|
+
/** No filter may take the URL key of the current view. */
|
|
58
|
+
export declare function assertDashboardViewUrlKeys(owner: string, urlKeys: readonly string[]): void;
|
|
@@ -3,26 +3,41 @@ import { createEnumCodec, useQueryState } from "../../query-state/index.js";
|
|
|
3
3
|
import { resolveTextValue } from "../../shared/utils/render.js";
|
|
4
4
|
import {
|
|
5
5
|
DASHBOARD_VIEW_URL_KEY,
|
|
6
|
+
resolveDashboardCondition,
|
|
6
7
|
resolveDashboardScopePrefix,
|
|
7
8
|
resolveDashboardViewKey
|
|
8
9
|
} from "../utils/state.js";
|
|
9
10
|
import { useDashboardScope } from "./use-dashboard-scope.js";
|
|
10
11
|
export function useDashboardViews(params) {
|
|
11
12
|
const { schema } = params;
|
|
12
|
-
|
|
13
|
-
throw new Error(
|
|
14
|
-
`[dashboard] Root param URL key "${DASHBOARD_VIEW_URL_KEY}" is reserved for the current view of "${schema.key}". Rename the param or set its \`urlKey\`.`
|
|
15
|
-
);
|
|
16
|
-
}
|
|
13
|
+
assertDashboardViewUrlKeys("", params.root.filterScope.urlKeys);
|
|
17
14
|
const keys = schema.views.map(([key]) => key);
|
|
18
|
-
const
|
|
15
|
+
const stored = useQueryState({
|
|
19
16
|
codec: createEnumCodec(keys),
|
|
20
17
|
defaultValue: schema.defaultView ?? keys[0] ?? "",
|
|
21
18
|
historyMode: "push",
|
|
22
19
|
key: resolveDashboardViewKey(schema.urlPrefix)
|
|
23
20
|
});
|
|
21
|
+
const conditions = new Map(
|
|
22
|
+
schema.views.map(([key, input]) => [
|
|
23
|
+
key,
|
|
24
|
+
computed(() => resolveDashboardCondition(input.enabled))
|
|
25
|
+
])
|
|
26
|
+
);
|
|
27
|
+
const isEnabled = (key) => conditions.get(key)?.value ?? false;
|
|
28
|
+
const current = computed({
|
|
29
|
+
get: () => {
|
|
30
|
+
if (isEnabled(stored.value)) return stored.value;
|
|
31
|
+
const fallback = [schema.defaultView, ...keys].find((key) => key && isEnabled(key));
|
|
32
|
+
return fallback ?? stored.value;
|
|
33
|
+
},
|
|
34
|
+
set: (key) => {
|
|
35
|
+
if (isEnabled(key)) stored.value = key;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
24
38
|
const rootSources = new Map(params.root.members);
|
|
25
39
|
const views = schema.views.map(([key, input]) => {
|
|
40
|
+
const enabled = conditions.get(key) ?? computed(() => true);
|
|
26
41
|
const opened = shallowRef(false);
|
|
27
42
|
watch(
|
|
28
43
|
() => current.value === key,
|
|
@@ -32,18 +47,26 @@ export function useDashboardViews(params) {
|
|
|
32
47
|
{ flush: "sync", immediate: true }
|
|
33
48
|
);
|
|
34
49
|
const scope = useDashboardScope({
|
|
35
|
-
active: computed(() => opened.value),
|
|
50
|
+
active: computed(() => opened.value && enabled.value),
|
|
51
|
+
enabled,
|
|
52
|
+
environment: params.environment,
|
|
36
53
|
input,
|
|
37
|
-
prefix: resolveDashboardScopePrefix(schema.urlPrefix
|
|
54
|
+
prefix: resolveDashboardScopePrefix(schema.urlPrefix),
|
|
38
55
|
refetchInterval: params.refetchInterval,
|
|
39
56
|
rootSources,
|
|
40
57
|
schemaKey: schema.key,
|
|
41
58
|
scopeKey: key,
|
|
42
|
-
shared: params.root.paramScope,
|
|
43
59
|
tracker: params.tracker
|
|
44
60
|
});
|
|
61
|
+
assertDashboardViewUrlKeys(key, scope.filterScope.urlKeys);
|
|
45
62
|
const label = () => resolveTextValue(input.label, key);
|
|
46
|
-
return { key, label, opened, scope };
|
|
63
|
+
return { enabled, input, key, label, opened, scope };
|
|
47
64
|
});
|
|
48
65
|
return { current, keys, views };
|
|
49
66
|
}
|
|
67
|
+
export function assertDashboardViewUrlKeys(owner, urlKeys) {
|
|
68
|
+
if (urlKeys.includes(DASHBOARD_VIEW_URL_KEY))
|
|
69
|
+
throw new Error(
|
|
70
|
+
`[dashboard] A filter of ${owner ? `view "${owner}"` : "the dashboard root"} uses the URL key "${DASHBOARD_VIEW_URL_KEY}", which holds the current view. Rename the filter or set its \`urlKey\`.`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
import type { DashboardApi, DashboardSchemaLike } from '../types/index.js';
|
|
1
|
+
import type { DashboardApi, DashboardSchemaLike, DashboardSchemaOf } from '../types/index.js';
|
|
2
2
|
/**
|
|
3
|
-
* Instantiates a dashboard
|
|
4
|
-
*
|
|
3
|
+
* Instantiates a dashboard. Call it once in `<script setup>` with a schema, or with a function
|
|
4
|
+
* returning one: the function runs right away, and again whenever something it reads changes (the
|
|
5
|
+
* route's id, the workspace), rebuilding the dashboard for the new input behind the same object.
|
|
5
6
|
*
|
|
6
|
-
* The returned object has no refs: `dashboard.
|
|
7
|
-
* `dashboard.state` are plain reads,
|
|
8
|
-
* can be bound to a block with `:source="dashboard.revenue"`.
|
|
7
|
+
* The returned object has no refs: `dashboard.filters.year`, `dashboard.revenue.data`,
|
|
8
|
+
* `dashboard.state` are plain reads, filters are `v-model` targets, controls drive pickers, and
|
|
9
|
+
* every query / derived value can be bound to a block with `:source="dashboard.revenue"`.
|
|
10
|
+
* Descendant components get it with `injectDashboard(schema)`, and a view with `useDashboardView`.
|
|
11
|
+
*
|
|
12
|
+
* A schema function runs again outside component setup: call app-level composables in it
|
|
13
|
+
* (`useNuxtApp()`, a store, `useRoute()`) and `useDashboardFormat()`, not `useI18n()` or lifecycle
|
|
14
|
+
* hooks.
|
|
9
15
|
*
|
|
10
16
|
* @example
|
|
11
17
|
* ```vue
|
|
12
18
|
* <script setup lang="ts">
|
|
13
|
-
* const
|
|
19
|
+
* const route = useRoute()
|
|
20
|
+
* const account = useDashboard(() => accountSchema({ accountId: String(route.params.id) }))
|
|
14
21
|
* </script>
|
|
15
22
|
*
|
|
16
23
|
* <template>
|
|
17
|
-
* <
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* </UiDashboardGrid>
|
|
24
|
+
* <UiDashboardPage :dashboard="account" title="Account">
|
|
25
|
+
* <template #activity><AccountActivity /></template>
|
|
26
|
+
* </UiDashboardPage>
|
|
21
27
|
* </template>
|
|
22
28
|
* ```
|
|
23
29
|
*/
|
|
24
|
-
export declare function useDashboard<const
|
|
30
|
+
export declare function useDashboard<const TSource extends DashboardSchemaLike | (() => DashboardSchemaLike)>(source: TSource): DashboardApi<DashboardSchemaOf<TSource>>;
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
effectScope,
|
|
4
|
+
getCurrentInstance,
|
|
5
|
+
markRaw,
|
|
6
|
+
onScopeDispose,
|
|
7
|
+
shallowRef,
|
|
8
|
+
watch
|
|
9
|
+
} from "vue";
|
|
10
|
+
import { useUiToolsLocale } from "../../i18n/use-locale.js";
|
|
2
11
|
import { numberCodec, useQueryState } from "../../query-state/index.js";
|
|
12
|
+
import { withDashboardLocale } from "../utils/environment.js";
|
|
3
13
|
import { resolveDashboardRuntimeSchema } from "../utils/schema.js";
|
|
4
14
|
import {
|
|
5
15
|
DASHBOARD_REFRESH_URL_KEY,
|
|
@@ -8,11 +18,67 @@ import {
|
|
|
8
18
|
} from "../utils/state.js";
|
|
9
19
|
import { createDashboardReadTracker } from "../utils/tracker.js";
|
|
10
20
|
import { useDashboardApi } from "./use-dashboard-api.js";
|
|
21
|
+
import { provideDashboard } from "./use-dashboard-context.js";
|
|
11
22
|
import { useDashboardScope } from "./use-dashboard-scope.js";
|
|
12
23
|
import { useDashboardViews } from "./use-dashboard-views.js";
|
|
13
|
-
export function useDashboard(
|
|
24
|
+
export function useDashboard(source) {
|
|
25
|
+
const locale = useUiToolsLocale();
|
|
26
|
+
if (typeof source !== "function") {
|
|
27
|
+
const runtime = createDashboardRuntime(source, locale);
|
|
28
|
+
provideDashboard({
|
|
29
|
+
api: runtime.api,
|
|
30
|
+
current: () => runtime.current(),
|
|
31
|
+
findView: (declaration) => runtime.findView(declaration),
|
|
32
|
+
schema: () => source,
|
|
33
|
+
source,
|
|
34
|
+
view: (key) => runtime.views.get(key)
|
|
35
|
+
});
|
|
36
|
+
return runtime.api;
|
|
37
|
+
}
|
|
38
|
+
const app = getCurrentInstance()?.appContext.app;
|
|
39
|
+
const withContext = (run) => withDashboardLocale(locale, () => app ? app.runWithContext(run) : run());
|
|
40
|
+
const schema = computed(() => withContext(source));
|
|
41
|
+
let scope = effectScope(true);
|
|
42
|
+
const current = shallowRef(build(scope, schema.value));
|
|
43
|
+
function build(owner, next) {
|
|
44
|
+
const runtime = withContext(() => owner.run(() => createDashboardRuntime(next, locale)));
|
|
45
|
+
if (!runtime) throw new Error("[dashboard] The dashboard scope stopped while building.");
|
|
46
|
+
return runtime;
|
|
47
|
+
}
|
|
48
|
+
watch(schema, (next) => {
|
|
49
|
+
const previous = scope;
|
|
50
|
+
scope = effectScope(true);
|
|
51
|
+
current.value = build(scope, next);
|
|
52
|
+
previous.stop();
|
|
53
|
+
});
|
|
54
|
+
onScopeDispose(() => scope.stop());
|
|
55
|
+
const views = /* @__PURE__ */ new Map();
|
|
56
|
+
const view = (key) => {
|
|
57
|
+
let handle = views.get(key);
|
|
58
|
+
if (!handle) {
|
|
59
|
+
handle = createStableFacade(() => current.value.views.get(key));
|
|
60
|
+
views.set(key, handle);
|
|
61
|
+
}
|
|
62
|
+
return handle;
|
|
63
|
+
};
|
|
64
|
+
const api = createStableFacade(
|
|
65
|
+
() => current.value.api,
|
|
66
|
+
(key) => current.value.views.has(key) ? view(key) : void 0
|
|
67
|
+
);
|
|
68
|
+
provideDashboard({
|
|
69
|
+
api,
|
|
70
|
+
current: () => current.value.current(),
|
|
71
|
+
findView: (declaration) => current.value.findView(declaration),
|
|
72
|
+
schema: () => schema.value,
|
|
73
|
+
source,
|
|
74
|
+
view: (key) => current.value.views.has(key) ? view(key) : void 0
|
|
75
|
+
});
|
|
76
|
+
return api;
|
|
77
|
+
}
|
|
78
|
+
function createDashboardRuntime(schema, locale) {
|
|
14
79
|
const runtime = resolveDashboardRuntimeSchema(schema);
|
|
15
80
|
const tracker = createDashboardReadTracker();
|
|
81
|
+
const environment = { locale, registry: /* @__PURE__ */ new Map() };
|
|
16
82
|
const autoRefresh = useQueryState({
|
|
17
83
|
codec: numberCodec,
|
|
18
84
|
defaultValue: Math.max(0, runtime.autoRefresh ?? 0),
|
|
@@ -24,6 +90,7 @@ export function useDashboard(schema) {
|
|
|
24
90
|
);
|
|
25
91
|
const root = useDashboardScope({
|
|
26
92
|
active: computed(() => true),
|
|
93
|
+
environment,
|
|
27
94
|
input: runtime,
|
|
28
95
|
prefix: resolveDashboardScopePrefix(runtime.urlPrefix),
|
|
29
96
|
refetchInterval,
|
|
@@ -31,12 +98,34 @@ export function useDashboard(schema) {
|
|
|
31
98
|
scopeKey: "",
|
|
32
99
|
tracker
|
|
33
100
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
101
|
+
const views = runtime.views.length > 0 ? useDashboardViews({ environment, refetchInterval, root, schema: runtime, tracker }) : null;
|
|
102
|
+
for (const scope of [root, ...views?.views.map((view) => view.scope) ?? []]) {
|
|
103
|
+
if (scope.filterScope.urlKeys.includes(DASHBOARD_REFRESH_URL_KEY))
|
|
104
|
+
throw new Error(
|
|
105
|
+
`[dashboard] A filter of "${runtime.key}" uses the URL key "${DASHBOARD_REFRESH_URL_KEY}", which holds the auto-refresh interval. Rename the filter or set its \`urlKey\`.`
|
|
106
|
+
);
|
|
38
107
|
}
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
return
|
|
108
|
+
const { api, handles } = useDashboardApi({ autoRefresh, root, schema, views });
|
|
109
|
+
const declarations = new Map(runtime.views.map(([key, input]) => [input, key]));
|
|
110
|
+
return {
|
|
111
|
+
api,
|
|
112
|
+
current: () => views?.current.value,
|
|
113
|
+
findView: (declaration) => declarations.get(declaration),
|
|
114
|
+
views: handles
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function createStableFacade(read, member) {
|
|
118
|
+
const target = () => read() ?? {};
|
|
119
|
+
return markRaw(
|
|
120
|
+
new Proxy(/* @__PURE__ */ Object.create(null), {
|
|
121
|
+
get: (_, key) => (typeof key === "string" ? member?.(key) : void 0) ?? Reflect.get(target(), key),
|
|
122
|
+
getOwnPropertyDescriptor: (_, key) => {
|
|
123
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target(), key);
|
|
124
|
+
return descriptor ? { ...descriptor, configurable: true } : void 0;
|
|
125
|
+
},
|
|
126
|
+
has: (_, key) => Reflect.has(target(), key),
|
|
127
|
+
ownKeys: () => Reflect.ownKeys(target()),
|
|
128
|
+
set: (_, key, value) => Reflect.set(target(), key, value)
|
|
129
|
+
})
|
|
130
|
+
);
|
|
42
131
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { useDashboard } from './composables/use-dashboard.js';
|
|
2
|
-
export {
|
|
2
|
+
export { injectDashboard, useDashboardView } from './composables/use-dashboard-context.js';
|
|
3
|
+
export { useDashboardFormat } from './composables/use-dashboard-format.js';
|
|
4
|
+
export { defineDashboardSchema, defineDashboardView } from './schema/index.js';
|
|
3
5
|
export { resolveDashboardComparisonRange } from './utils/comparison.js';
|
|
4
6
|
export type * from './types';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { useDashboard } from "./composables/use-dashboard.js";
|
|
2
|
-
export {
|
|
2
|
+
export { injectDashboard, useDashboardView } from "./composables/use-dashboard-context.js";
|
|
3
|
+
export { useDashboardFormat } from "./composables/use-dashboard-format.js";
|
|
4
|
+
export { defineDashboardSchema, defineDashboardView } from "./schema/index.js";
|
|
3
5
|
export { resolveDashboardComparisonRange } from "./utils/comparison.js";
|