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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Header of a form page: the schema `header` (eyebrow, title, description), an unsaved-changes
|
|
3
|
+
* badge while a form with `controls.dirtyCheck` is modified, and the page actions. It stays
|
|
4
|
+
* pinned while the page scrolls on wide layouts, and sections scroll to just below it.
|
|
5
|
+
*/
|
|
6
|
+
type __VLS_Slots = {
|
|
7
|
+
/** Before the heading, e.g. an avatar of the record. */
|
|
8
|
+
leading?: () => unknown;
|
|
9
|
+
eyebrow?: () => unknown;
|
|
10
|
+
title?: () => unknown;
|
|
11
|
+
/** Replaces the description, keeping the unsaved-changes badge after it. */
|
|
12
|
+
description?: () => unknown;
|
|
13
|
+
/** Replaces the page actions. */
|
|
14
|
+
actions?: () => unknown;
|
|
15
|
+
};
|
|
16
|
+
declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
17
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
18
|
+
declare const _default: typeof __VLS_export;
|
|
19
|
+
export default _default;
|
|
20
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
21
|
+
new (): {
|
|
22
|
+
$slots: S;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import UBadge from "@nuxt/ui/components/Badge.vue";
|
|
3
|
+
import { useResizeObserver } from "@vueuse/core";
|
|
4
|
+
import { computed, onBeforeUnmount, useTemplateRef } from "vue";
|
|
5
|
+
import { useUiToolsLocale } from "../../../i18n/use-locale";
|
|
6
|
+
import { useFormPageContext } from "../../composables/use-form-page";
|
|
7
|
+
import { useFormUi } from "../../composables/use-form-ui";
|
|
8
|
+
import { getFormHeader } from "../../utils/overlay";
|
|
9
|
+
import { isRecord } from "../../utils/path";
|
|
10
|
+
import { resolveFormBoundaryText } from "../../utils/text";
|
|
11
|
+
import { mergeFormUiClass } from "../../utils/ui";
|
|
12
|
+
import FormPageActions from "./form-page-actions.vue";
|
|
13
|
+
defineSlots();
|
|
14
|
+
const page = useFormPageContext();
|
|
15
|
+
const formUi = useFormUi();
|
|
16
|
+
const { t } = useUiToolsLocale();
|
|
17
|
+
const pageUi = computed(() => formUi.ui.value.page?.ui);
|
|
18
|
+
const header = computed(() => getFormHeader(page.root.schema.value));
|
|
19
|
+
const eyebrow = computed(() => headerText(header.value, "eyebrow"));
|
|
20
|
+
const title = computed(() => headerText(header.value, "title"));
|
|
21
|
+
const description = computed(() => headerText(header.value, "description"));
|
|
22
|
+
const unsaved = computed(() => page.dirtyCheck.value && page.root.runtime.isDirty.value);
|
|
23
|
+
const element = useTemplateRef("element");
|
|
24
|
+
useResizeObserver(element, () => {
|
|
25
|
+
const node = element.value;
|
|
26
|
+
page.stickyOffset.value = node && getComputedStyle(node).position === "sticky" ? node.offsetHeight : 0;
|
|
27
|
+
});
|
|
28
|
+
onBeforeUnmount(() => {
|
|
29
|
+
page.stickyOffset.value = 0;
|
|
30
|
+
});
|
|
31
|
+
function headerText(config, key) {
|
|
32
|
+
return isRecord(config) ? resolveFormBoundaryText(config[key]) : void 0;
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<template>
|
|
37
|
+
<header
|
|
38
|
+
ref="element"
|
|
39
|
+
:class="
|
|
40
|
+
mergeFormUiClass(
|
|
41
|
+
'z-10 flex flex-col gap-3 border-b border-default bg-default px-4 py-4 @3xl/form-page:sticky @3xl/form-page:top-0 @3xl/form-page:flex-row @3xl/form-page:items-center @3xl/form-page:justify-between @3xl/form-page:gap-5 @3xl/form-page:px-7 @3xl/form-page:pt-[18px] @3xl/form-page:pb-4',
|
|
42
|
+
pageUi?.header
|
|
43
|
+
)
|
|
44
|
+
"
|
|
45
|
+
data-form-page-header
|
|
46
|
+
>
|
|
47
|
+
<div :class="mergeFormUiClass('flex min-w-0 items-center gap-3.5', pageUi?.headerContent)">
|
|
48
|
+
<slot name="leading" />
|
|
49
|
+
<div :class="mergeFormUiClass('grid min-w-0 gap-1.5', pageUi?.heading)">
|
|
50
|
+
<p
|
|
51
|
+
v-if="eyebrow || $slots.eyebrow"
|
|
52
|
+
:class="
|
|
53
|
+
mergeFormUiClass(
|
|
54
|
+
'text-[11px] font-semibold tracking-[0.08em] text-dimmed uppercase',
|
|
55
|
+
pageUi?.eyebrow
|
|
56
|
+
)
|
|
57
|
+
"
|
|
58
|
+
>
|
|
59
|
+
<slot name="eyebrow">{{ eyebrow }}</slot>
|
|
60
|
+
</p>
|
|
61
|
+
<h1
|
|
62
|
+
v-if="title || $slots.title"
|
|
63
|
+
:class="
|
|
64
|
+
mergeFormUiClass(
|
|
65
|
+
'm-0 truncate text-[22px] leading-[1.1] font-semibold tracking-[-0.025em] text-highlighted @3xl/form-page:text-[28px]',
|
|
66
|
+
pageUi?.title
|
|
67
|
+
)
|
|
68
|
+
"
|
|
69
|
+
>
|
|
70
|
+
<slot name="title">{{ title }}</slot>
|
|
71
|
+
</h1>
|
|
72
|
+
<div
|
|
73
|
+
v-if="description || unsaved || $slots.description"
|
|
74
|
+
:class="
|
|
75
|
+
mergeFormUiClass(
|
|
76
|
+
'flex flex-wrap items-center gap-2.5 text-[13.5px] text-muted',
|
|
77
|
+
pageUi?.meta
|
|
78
|
+
)
|
|
79
|
+
"
|
|
80
|
+
>
|
|
81
|
+
<slot name="description">
|
|
82
|
+
<span v-if="description">{{ description }}</span>
|
|
83
|
+
</slot>
|
|
84
|
+
<UBadge
|
|
85
|
+
v-if="unsaved"
|
|
86
|
+
color="warning"
|
|
87
|
+
variant="soft"
|
|
88
|
+
:label="t('form.page.unsavedChanges')"
|
|
89
|
+
:class="pageUi?.unsaved"
|
|
90
|
+
data-form-page-unsaved
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
<slot name="actions">
|
|
96
|
+
<FormPageActions />
|
|
97
|
+
</slot>
|
|
98
|
+
</header>
|
|
99
|
+
</template>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Header of a form page: the schema `header` (eyebrow, title, description), an unsaved-changes
|
|
3
|
+
* badge while a form with `controls.dirtyCheck` is modified, and the page actions. It stays
|
|
4
|
+
* pinned while the page scrolls on wide layouts, and sections scroll to just below it.
|
|
5
|
+
*/
|
|
6
|
+
type __VLS_Slots = {
|
|
7
|
+
/** Before the heading, e.g. an avatar of the record. */
|
|
8
|
+
leading?: () => unknown;
|
|
9
|
+
eyebrow?: () => unknown;
|
|
10
|
+
title?: () => unknown;
|
|
11
|
+
/** Replaces the description, keeping the unsaved-changes badge after it. */
|
|
12
|
+
description?: () => unknown;
|
|
13
|
+
/** Replaces the page actions. */
|
|
14
|
+
actions?: () => unknown;
|
|
15
|
+
};
|
|
16
|
+
declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
17
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
18
|
+
declare const _default: typeof __VLS_export;
|
|
19
|
+
export default _default;
|
|
20
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
21
|
+
new (): {
|
|
22
|
+
$slots: S;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { FormPageSectionState } from '../../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Navigation of a form page: one entry per visible section, following the section in view.
|
|
4
|
+
* An entry shows whether its section is complete, invalid, or still to fill, marks optional
|
|
5
|
+
* sections, and, with `controls.dirtyCheck`, a dot on modified sections. The footer sums up
|
|
6
|
+
* the sections left to complete, or the modified ones with dirty checking.
|
|
7
|
+
*
|
|
8
|
+
* From 768px of page width it is a pinned column; below, a row of chips that scrolls sideways.
|
|
9
|
+
*/
|
|
10
|
+
type __VLS_Slots = {
|
|
11
|
+
/** Replaces the heading, which comes from the schema `navigation.title`. */
|
|
12
|
+
title?: () => unknown;
|
|
13
|
+
/** Replaces an entry. Call `select` to scroll to the section. */
|
|
14
|
+
item?: (props: {
|
|
15
|
+
section: FormPageSectionState;
|
|
16
|
+
active: boolean;
|
|
17
|
+
select: () => void;
|
|
18
|
+
}) => unknown;
|
|
19
|
+
/** Replaces the summary under the entries. */
|
|
20
|
+
footer?: (props: {
|
|
21
|
+
sections: readonly FormPageSectionState[];
|
|
22
|
+
remaining: number;
|
|
23
|
+
modified: number;
|
|
24
|
+
}) => unknown;
|
|
25
|
+
};
|
|
26
|
+
declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
27
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
28
|
+
declare const _default: typeof __VLS_export;
|
|
29
|
+
export default _default;
|
|
30
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
31
|
+
new (): {
|
|
32
|
+
$slots: S;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import UIcon from "@nuxt/ui/components/Icon.vue";
|
|
3
|
+
import { computed, nextTick, useId, useTemplateRef, watch } from "vue";
|
|
4
|
+
import { useUiToolsLocale } from "../../../i18n/use-locale";
|
|
5
|
+
import { useFormPageContext } from "../../composables/use-form-page";
|
|
6
|
+
import { useFormUi } from "../../composables/use-form-ui";
|
|
7
|
+
import { mergeFormUiClass } from "../../utils/ui";
|
|
8
|
+
defineSlots();
|
|
9
|
+
const CHIP_ROW_INSET = 16;
|
|
10
|
+
const page = useFormPageContext();
|
|
11
|
+
const formUi = useFormUi();
|
|
12
|
+
const { code, t } = useUiToolsLocale();
|
|
13
|
+
const pageUi = computed(() => formUi.ui.value.page?.ui);
|
|
14
|
+
const titleId = useId();
|
|
15
|
+
const plurals = computed(() => new Intl.PluralRules(code.value));
|
|
16
|
+
const summary = computed(() => {
|
|
17
|
+
if (page.dirtyCheck.value) {
|
|
18
|
+
const count2 = page.modified.value;
|
|
19
|
+
if (!count2) {
|
|
20
|
+
return { text: t("form.page.unmodified") };
|
|
21
|
+
}
|
|
22
|
+
return sentence(count2, isOne(count2) ? "form.page.modifiedOne" : "form.page.modifiedOther");
|
|
23
|
+
}
|
|
24
|
+
const count = page.remaining.value;
|
|
25
|
+
return count ? sentence(count, "form.page.remaining") : { text: t("form.page.complete") };
|
|
26
|
+
});
|
|
27
|
+
function isOne(count) {
|
|
28
|
+
return plurals.value.select(count) === "one";
|
|
29
|
+
}
|
|
30
|
+
function sentence(count, message) {
|
|
31
|
+
const [before = "", after = ""] = t(message).split("{count}");
|
|
32
|
+
const phrase = t(isOne(count) ? "form.page.sectionsOne" : "form.page.sectionsOther", { count });
|
|
33
|
+
return { after, before, phrase };
|
|
34
|
+
}
|
|
35
|
+
function dirtyShown(section) {
|
|
36
|
+
return page.dirtyCheck.value && section.dirty;
|
|
37
|
+
}
|
|
38
|
+
function statusLabel(section) {
|
|
39
|
+
const status = t(`form.page.status.${section.status}`);
|
|
40
|
+
return dirtyShown(section) ? `${status}, ${t("form.page.unsavedChanges")}` : status;
|
|
41
|
+
}
|
|
42
|
+
const list = useTemplateRef("list");
|
|
43
|
+
watch(
|
|
44
|
+
() => page.active.value,
|
|
45
|
+
async (key) => {
|
|
46
|
+
await nextTick();
|
|
47
|
+
const row = list.value;
|
|
48
|
+
if (!row || !key || row.scrollWidth <= row.clientWidth) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const entry = [...row.children].find(
|
|
52
|
+
(child) => child.getAttribute("data-form-page-entry") === key
|
|
53
|
+
);
|
|
54
|
+
if (!entry) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const box = row.getBoundingClientRect();
|
|
58
|
+
const rect = entry.getBoundingClientRect();
|
|
59
|
+
const overflow = rect.left < box.left ? rect.left - box.left : Math.max(0, rect.right - box.right);
|
|
60
|
+
if (overflow) {
|
|
61
|
+
row.scrollBy?.({ behavior: "smooth", left: overflow + Math.sign(overflow) * CHIP_ROW_INSET });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
function select(event, key) {
|
|
66
|
+
if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
page.scrollTo(key, { focus: true });
|
|
71
|
+
}
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<template>
|
|
75
|
+
<nav
|
|
76
|
+
:aria-labelledby="page.navigationTitle.value || $slots.title ? titleId : void 0"
|
|
77
|
+
:aria-label="page.navigationTitle.value || $slots.title ? void 0 : t('form.page.navigation')"
|
|
78
|
+
:class="
|
|
79
|
+
mergeFormUiClass(
|
|
80
|
+
'flex min-w-0 flex-col gap-3.5 @3xl/form-page:sticky @3xl/form-page:top-[calc(var(--nut-form-page-header,0px)+var(--nut-form-page-gap,24px))]',
|
|
81
|
+
pageUi?.navigation
|
|
82
|
+
)
|
|
83
|
+
"
|
|
84
|
+
data-form-page-navigation
|
|
85
|
+
>
|
|
86
|
+
<div :class="mergeFormUiClass('flex min-w-0 flex-col gap-2', pageUi?.navigationGroup)">
|
|
87
|
+
<p
|
|
88
|
+
v-if="page.navigationTitle.value || $slots.title"
|
|
89
|
+
:id="titleId"
|
|
90
|
+
:class="
|
|
91
|
+
mergeFormUiClass(
|
|
92
|
+
'hidden px-2.5 text-[11px] font-semibold tracking-[0.08em] text-dimmed uppercase @3xl/form-page:block',
|
|
93
|
+
pageUi?.navigationTitle
|
|
94
|
+
)
|
|
95
|
+
"
|
|
96
|
+
>
|
|
97
|
+
<slot name="title">{{ page.navigationTitle.value }}</slot>
|
|
98
|
+
</p>
|
|
99
|
+
<ul
|
|
100
|
+
ref="list"
|
|
101
|
+
role="list"
|
|
102
|
+
:class="
|
|
103
|
+
mergeFormUiClass(
|
|
104
|
+
'm-0 flex list-none gap-1.5 overflow-x-auto p-0 [scrollbar-width:none] @3xl/form-page:flex-col @3xl/form-page:gap-0.5 @3xl/form-page:overflow-visible',
|
|
105
|
+
pageUi?.navigationList
|
|
106
|
+
)
|
|
107
|
+
"
|
|
108
|
+
>
|
|
109
|
+
<li
|
|
110
|
+
v-for="section in page.sections.value"
|
|
111
|
+
:key="section.key"
|
|
112
|
+
:data-form-page-entry="section.key"
|
|
113
|
+
:class="mergeFormUiClass('shrink-0 @3xl/form-page:shrink', pageUi?.navigationEntry)"
|
|
114
|
+
>
|
|
115
|
+
<slot
|
|
116
|
+
name="item"
|
|
117
|
+
:section
|
|
118
|
+
:active="section.key === page.active.value"
|
|
119
|
+
:select="() => page.scrollTo(section.key, { focus: true })"
|
|
120
|
+
>
|
|
121
|
+
<a
|
|
122
|
+
:href="`#${section.key}`"
|
|
123
|
+
:aria-current="section.key === page.active.value ? 'location' : void 0"
|
|
124
|
+
:data-active="section.key === page.active.value || void 0"
|
|
125
|
+
:data-state="section.status"
|
|
126
|
+
:data-dirty="dirtyShown(section) || void 0"
|
|
127
|
+
:class="
|
|
128
|
+
mergeFormUiClass(
|
|
129
|
+
'group flex h-8 min-w-0 items-center gap-2 rounded-md border border-default bg-default px-2.5 text-[12.5px] font-medium text-muted no-underline transition-colors hover:text-highlighted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary data-[active]:border-primary data-[active]:bg-primary/10 data-[active]:text-highlighted @3xl/form-page:h-9 @3xl/form-page:gap-2.5 @3xl/form-page:rounded-[7px] @3xl/form-page:border-transparent @3xl/form-page:bg-transparent @3xl/form-page:text-[13.5px] @3xl/form-page:hover:bg-elevated @3xl/form-page:data-[active]:border-transparent @3xl/form-page:data-[active]:bg-default @3xl/form-page:data-[active]:font-semibold @3xl/form-page:data-[active]:shadow-[inset_2px_0_0_var(--ui-primary)]',
|
|
130
|
+
pageUi?.navigationItem
|
|
131
|
+
)
|
|
132
|
+
"
|
|
133
|
+
@click="select($event, section.key)"
|
|
134
|
+
>
|
|
135
|
+
<span
|
|
136
|
+
:data-state="section.status"
|
|
137
|
+
aria-hidden="true"
|
|
138
|
+
:class="
|
|
139
|
+
mergeFormUiClass(
|
|
140
|
+
'grid size-4 shrink-0 place-items-center rounded-full border-[1.5px] border-accented text-[10px] leading-none font-bold group-data-[active]:border-primary data-[state=complete]:border-(--ui-text-highlighted) data-[state=complete]:bg-(--ui-text-highlighted) data-[state=complete]:text-(--ui-bg) data-[state=invalid]:border-error data-[state=invalid]:bg-error data-[state=invalid]:text-inverted group-data-[active]:data-[state=complete]:border-primary group-data-[active]:data-[state=complete]:bg-primary group-data-[active]:data-[state=complete]:text-inverted',
|
|
141
|
+
pageUi?.navigationIndicator
|
|
142
|
+
)
|
|
143
|
+
"
|
|
144
|
+
>
|
|
145
|
+
<UIcon
|
|
146
|
+
v-if="section.status === 'complete'"
|
|
147
|
+
name="i-lucide-check"
|
|
148
|
+
:class="mergeFormUiClass('size-2.5', pageUi?.navigationIndicatorIcon)"
|
|
149
|
+
/>
|
|
150
|
+
<template v-else-if="section.status === 'invalid'">!</template>
|
|
151
|
+
<span
|
|
152
|
+
v-else
|
|
153
|
+
:class="
|
|
154
|
+
mergeFormUiClass(
|
|
155
|
+
'hidden size-1.5 rounded-full bg-primary group-data-[active]:block',
|
|
156
|
+
pageUi?.navigationIndicatorMarker
|
|
157
|
+
)
|
|
158
|
+
"
|
|
159
|
+
/>
|
|
160
|
+
</span>
|
|
161
|
+
<span
|
|
162
|
+
:class="
|
|
163
|
+
mergeFormUiClass(
|
|
164
|
+
'whitespace-nowrap @3xl/form-page:min-w-0 @3xl/form-page:flex-1 @3xl/form-page:truncate',
|
|
165
|
+
pageUi?.navigationLabel
|
|
166
|
+
)
|
|
167
|
+
"
|
|
168
|
+
>
|
|
169
|
+
{{ section.label }}
|
|
170
|
+
</span>
|
|
171
|
+
<span class="sr-only">{{ statusLabel(section) }}</span>
|
|
172
|
+
<span
|
|
173
|
+
v-if="dirtyShown(section)"
|
|
174
|
+
aria-hidden="true"
|
|
175
|
+
:class="
|
|
176
|
+
mergeFormUiClass(
|
|
177
|
+
'size-1.5 shrink-0 rounded-full bg-primary',
|
|
178
|
+
pageUi?.navigationDirty
|
|
179
|
+
)
|
|
180
|
+
"
|
|
181
|
+
data-form-page-dirty
|
|
182
|
+
/>
|
|
183
|
+
<span
|
|
184
|
+
v-else-if="section.optional && section.status !== 'complete'"
|
|
185
|
+
:class="
|
|
186
|
+
mergeFormUiClass(
|
|
187
|
+
'hidden shrink-0 text-[11px] font-normal text-dimmed @3xl/form-page:inline',
|
|
188
|
+
pageUi?.navigationOptional
|
|
189
|
+
)
|
|
190
|
+
"
|
|
191
|
+
>
|
|
192
|
+
{{ t("form.page.optional") }}
|
|
193
|
+
</span>
|
|
194
|
+
</a>
|
|
195
|
+
</slot>
|
|
196
|
+
</li>
|
|
197
|
+
</ul>
|
|
198
|
+
</div>
|
|
199
|
+
<div :class="mergeFormUiClass('hidden px-2.5 @3xl/form-page:block', pageUi?.navigationFooter)">
|
|
200
|
+
<div
|
|
201
|
+
:class="
|
|
202
|
+
mergeFormUiClass(
|
|
203
|
+
'border-t border-muted pt-3.5 text-[12.5px] leading-normal text-muted',
|
|
204
|
+
pageUi?.navigationSummary
|
|
205
|
+
)
|
|
206
|
+
"
|
|
207
|
+
data-form-page-summary
|
|
208
|
+
>
|
|
209
|
+
<slot
|
|
210
|
+
name="footer"
|
|
211
|
+
:sections="page.sections.value"
|
|
212
|
+
:remaining="page.remaining.value"
|
|
213
|
+
:modified="page.modified.value"
|
|
214
|
+
>
|
|
215
|
+
<template v-if="'phrase' in summary">
|
|
216
|
+
{{ summary.before
|
|
217
|
+
}}<b
|
|
218
|
+
:class="
|
|
219
|
+
mergeFormUiClass('font-semibold text-highlighted', pageUi?.navigationSummaryCount)
|
|
220
|
+
"
|
|
221
|
+
>{{ summary.phrase }}</b
|
|
222
|
+
>{{ summary.after }}
|
|
223
|
+
</template>
|
|
224
|
+
<template v-else>{{ summary.text }}</template>
|
|
225
|
+
</slot>
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
</nav>
|
|
229
|
+
</template>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { FormPageSectionState } from '../../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Navigation of a form page: one entry per visible section, following the section in view.
|
|
4
|
+
* An entry shows whether its section is complete, invalid, or still to fill, marks optional
|
|
5
|
+
* sections, and, with `controls.dirtyCheck`, a dot on modified sections. The footer sums up
|
|
6
|
+
* the sections left to complete, or the modified ones with dirty checking.
|
|
7
|
+
*
|
|
8
|
+
* From 768px of page width it is a pinned column; below, a row of chips that scrolls sideways.
|
|
9
|
+
*/
|
|
10
|
+
type __VLS_Slots = {
|
|
11
|
+
/** Replaces the heading, which comes from the schema `navigation.title`. */
|
|
12
|
+
title?: () => unknown;
|
|
13
|
+
/** Replaces an entry. Call `select` to scroll to the section. */
|
|
14
|
+
item?: (props: {
|
|
15
|
+
section: FormPageSectionState;
|
|
16
|
+
active: boolean;
|
|
17
|
+
select: () => void;
|
|
18
|
+
}) => unknown;
|
|
19
|
+
/** Replaces the summary under the entries. */
|
|
20
|
+
footer?: (props: {
|
|
21
|
+
sections: readonly FormPageSectionState[];
|
|
22
|
+
remaining: number;
|
|
23
|
+
modified: number;
|
|
24
|
+
}) => unknown;
|
|
25
|
+
};
|
|
26
|
+
declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
27
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
28
|
+
declare const _default: typeof __VLS_export;
|
|
29
|
+
export default _default;
|
|
30
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
31
|
+
new (): {
|
|
32
|
+
$slots: S;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FormPageSectionEntry, FormPageSectionState } from '../../types/index.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
entry: FormPageSectionEntry;
|
|
4
|
+
section: FormPageSectionState;
|
|
5
|
+
};
|
|
6
|
+
type __VLS_Slots = {
|
|
7
|
+
actions?: (props: {
|
|
8
|
+
section: FormPageSectionState;
|
|
9
|
+
}) => unknown;
|
|
10
|
+
};
|
|
11
|
+
declare const __VLS_base: 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>;
|
|
12
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
13
|
+
declare const _default: typeof __VLS_export;
|
|
14
|
+
export default _default;
|
|
15
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
16
|
+
new (): {
|
|
17
|
+
$slots: S;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import UBadge from "@nuxt/ui/components/Badge.vue";
|
|
3
|
+
import UButton from "@nuxt/ui/components/Button.vue";
|
|
4
|
+
import { computed, onBeforeUnmount, onMounted, useId, useTemplateRef } from "vue";
|
|
5
|
+
import { useUiToolsLocale } from "../../../i18n/use-locale";
|
|
6
|
+
import { useFormGridLayout } from "../../composables/use-form-layout";
|
|
7
|
+
import { useFormPageContext } from "../../composables/use-form-page";
|
|
8
|
+
import { provideFormRuntime } from "../../composables/use-form-runtime";
|
|
9
|
+
import { useFormUi } from "../../composables/use-form-ui";
|
|
10
|
+
import { resolveFormLayoutConfig } from "../../utils/layout";
|
|
11
|
+
import { mergeFormUiClass } from "../../utils/ui";
|
|
12
|
+
import FormFieldRenderer from "../renderer/form-field-renderer.vue";
|
|
13
|
+
const props = defineProps({
|
|
14
|
+
entry: { type: Object, required: true },
|
|
15
|
+
section: { type: Object, required: true }
|
|
16
|
+
});
|
|
17
|
+
defineSlots();
|
|
18
|
+
const page = useFormPageContext();
|
|
19
|
+
const formUi = useFormUi();
|
|
20
|
+
const { t } = useUiToolsLocale();
|
|
21
|
+
const { runtime } = page.root;
|
|
22
|
+
const pageUi = computed(() => formUi.ui.value.page?.ui);
|
|
23
|
+
const titleId = useId();
|
|
24
|
+
const dirty = computed(() => page.dirtyCheck.value && props.section.dirty);
|
|
25
|
+
const layout = computed(
|
|
26
|
+
() => resolveFormLayoutConfig(runtime.currentLayout.value, props.entry.section.layout)
|
|
27
|
+
);
|
|
28
|
+
provideFormRuntime({ ...runtime, currentLayout: layout });
|
|
29
|
+
const grid = useFormGridLayout({ layout });
|
|
30
|
+
const element = useTemplateRef("element");
|
|
31
|
+
let unregister;
|
|
32
|
+
onMounted(() => {
|
|
33
|
+
if (element.value) {
|
|
34
|
+
unregister = page.register(props.section.key, element.value);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
onBeforeUnmount(() => unregister?.());
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<template>
|
|
41
|
+
<section
|
|
42
|
+
:id="section.key"
|
|
43
|
+
ref="element"
|
|
44
|
+
:aria-labelledby="titleId"
|
|
45
|
+
:data-form-page-section="section.key"
|
|
46
|
+
:data-state="section.status"
|
|
47
|
+
:data-dirty="dirty || void 0"
|
|
48
|
+
:class="
|
|
49
|
+
mergeFormUiClass(
|
|
50
|
+
'flex min-w-0 scroll-mt-[calc(var(--nut-form-page-header,0px)+var(--nut-form-page-gap,24px))] flex-col gap-[18px] rounded-xl border border-default bg-default px-5 pt-5 pb-6 transition-[border-color,box-shadow] duration-200 @3xl/form-page:px-6 @3xl/form-page:pt-[22px] data-[dirty]:border-primary data-[dirty]:ring-4 data-[dirty]:ring-primary/20',
|
|
51
|
+
pageUi?.section
|
|
52
|
+
)
|
|
53
|
+
"
|
|
54
|
+
>
|
|
55
|
+
<header
|
|
56
|
+
:class="
|
|
57
|
+
mergeFormUiClass('flex flex-wrap items-center gap-x-3 gap-y-1', pageUi?.sectionHeader)
|
|
58
|
+
"
|
|
59
|
+
>
|
|
60
|
+
<h2
|
|
61
|
+
:id="titleId"
|
|
62
|
+
tabindex="-1"
|
|
63
|
+
:class="
|
|
64
|
+
mergeFormUiClass(
|
|
65
|
+
'm-0 text-lg font-semibold tracking-[-0.015em] text-highlighted focus:outline-none',
|
|
66
|
+
pageUi?.sectionTitle
|
|
67
|
+
)
|
|
68
|
+
"
|
|
69
|
+
data-form-page-section-title
|
|
70
|
+
>
|
|
71
|
+
{{ section.label }}
|
|
72
|
+
</h2>
|
|
73
|
+
<p
|
|
74
|
+
v-if="section.description"
|
|
75
|
+
:class="mergeFormUiClass('m-0 text-[13px] text-muted', pageUi?.sectionDescription)"
|
|
76
|
+
>
|
|
77
|
+
{{ section.description }}
|
|
78
|
+
</p>
|
|
79
|
+
<UBadge
|
|
80
|
+
v-if="section.optional"
|
|
81
|
+
color="neutral"
|
|
82
|
+
variant="soft"
|
|
83
|
+
:label="t('form.page.optional')"
|
|
84
|
+
:class="mergeFormUiClass('capitalize', pageUi?.sectionOptional)"
|
|
85
|
+
/>
|
|
86
|
+
<div
|
|
87
|
+
v-if="dirty || $slots.actions"
|
|
88
|
+
:class="mergeFormUiClass('ms-auto flex items-center gap-2', pageUi?.sectionActions)"
|
|
89
|
+
>
|
|
90
|
+
<slot name="actions" :section />
|
|
91
|
+
<UButton
|
|
92
|
+
v-if="dirty"
|
|
93
|
+
type="button"
|
|
94
|
+
color="neutral"
|
|
95
|
+
variant="ghost"
|
|
96
|
+
size="sm"
|
|
97
|
+
icon="i-lucide-rotate-ccw"
|
|
98
|
+
:label="t('form.page.resetSection')"
|
|
99
|
+
:class="pageUi?.sectionReset"
|
|
100
|
+
data-form-page-reset
|
|
101
|
+
@click="page.resetSection(section.key)"
|
|
102
|
+
/>
|
|
103
|
+
</div>
|
|
104
|
+
</header>
|
|
105
|
+
<div :class="mergeFormUiClass('min-w-0', pageUi?.sectionBody)" :style="grid.style.value">
|
|
106
|
+
<FormFieldRenderer
|
|
107
|
+
v-for="field in entry.section.fields"
|
|
108
|
+
:key="field.key"
|
|
109
|
+
:field="field"
|
|
110
|
+
:parent-path="[]"
|
|
111
|
+
/>
|
|
112
|
+
</div>
|
|
113
|
+
</section>
|
|
114
|
+
</template>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FormPageSectionEntry, FormPageSectionState } from '../../types/index.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
entry: FormPageSectionEntry;
|
|
4
|
+
section: FormPageSectionState;
|
|
5
|
+
};
|
|
6
|
+
type __VLS_Slots = {
|
|
7
|
+
actions?: (props: {
|
|
8
|
+
section: FormPageSectionState;
|
|
9
|
+
}) => unknown;
|
|
10
|
+
};
|
|
11
|
+
declare const __VLS_base: 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>;
|
|
12
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
13
|
+
declare const _default: typeof __VLS_export;
|
|
14
|
+
export default _default;
|
|
15
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
16
|
+
new (): {
|
|
17
|
+
$slots: S;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { FormPageSectionState } from '../../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Cards of a form page, one per visible section, each with its title, description, fields, and,
|
|
4
|
+
* with `controls.dirtyCheck`, a ring and a reset button while it is modified. Skeleton cards
|
|
5
|
+
* stand in while the schema context loads.
|
|
6
|
+
*/
|
|
7
|
+
type __VLS_Slots = {
|
|
8
|
+
/** Extra buttons in a section header, before its reset button. */
|
|
9
|
+
actions?: (props: {
|
|
10
|
+
section: FormPageSectionState;
|
|
11
|
+
}) => unknown;
|
|
12
|
+
};
|
|
13
|
+
declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
14
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
17
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
18
|
+
new (): {
|
|
19
|
+
$slots: S;
|
|
20
|
+
};
|
|
21
|
+
};
|