nuxt-ui-tools 1.11.1 → 1.11.2
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/runtime/form/components/provider/form-overlay-host.vue +3 -0
- package/dist/runtime/form/components/root/form.d.vue.ts +2 -1
- package/dist/runtime/form/components/root/form.vue +2 -0
- package/dist/runtime/form/components/root/form.vue.d.ts +2 -1
- package/dist/runtime/form/composables/use-form-overlay-controller.d.ts +1 -0
- package/dist/runtime/form/composables/use-form-overlay-controller.js +10 -0
- package/dist/runtime/form/composables/use-form-root.d.ts +4 -2
- package/dist/runtime/form/composables/use-form-root.js +13 -10
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -49,6 +49,7 @@ function resolveSchemaUi(schema) {
|
|
|
49
49
|
>
|
|
50
50
|
<FormRoot
|
|
51
51
|
:form="overlay.form"
|
|
52
|
+
:runtime="overlay.runtime"
|
|
52
53
|
shell="drawer"
|
|
53
54
|
:show-close-button="drawerConfig?.showCloseButton !== false"
|
|
54
55
|
:ui="formUi"
|
|
@@ -70,6 +71,7 @@ function resolveSchemaUi(schema) {
|
|
|
70
71
|
>
|
|
71
72
|
<FormRoot
|
|
72
73
|
:form="overlay.form"
|
|
74
|
+
:runtime="overlay.runtime"
|
|
73
75
|
shell="fullscreen"
|
|
74
76
|
:show-close-button="fullscreenConfig?.showCloseButton !== false"
|
|
75
77
|
:ui="formUi"
|
|
@@ -91,6 +93,7 @@ function resolveSchemaUi(schema) {
|
|
|
91
93
|
>
|
|
92
94
|
<FormRoot
|
|
93
95
|
:form="overlay.form"
|
|
96
|
+
:runtime="overlay.runtime"
|
|
94
97
|
shell="modal"
|
|
95
98
|
:show-close-button="modalConfig?.showCloseButton !== false"
|
|
96
99
|
:ui="formUi"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { FormValue, FormObject, FormRendererController, FormRenderShell, FormUiConfig, FormValidationMode } from '../../types/index.js';
|
|
1
|
+
import type { FormValue, FormObject, FormRendererController, FormRuntime, FormRenderShell, FormUiConfig, FormValidationMode } from '../../types/index.js';
|
|
2
2
|
type __VLS_Props = {
|
|
3
3
|
form?: FormRendererController;
|
|
4
|
+
runtime?: FormRuntime;
|
|
4
5
|
schema?: FormValue;
|
|
5
6
|
input?: FormObject;
|
|
6
7
|
shell?: FormRenderShell;
|
|
@@ -20,6 +20,7 @@ import FormFieldRenderer from "../renderer/form-field-renderer.vue";
|
|
|
20
20
|
import FormDirectionalTransition from "../utils/form-directional-transition.vue";
|
|
21
21
|
const props = defineProps({
|
|
22
22
|
form: { type: Object, required: false },
|
|
23
|
+
runtime: { type: Object, required: false },
|
|
23
24
|
schema: { type: null, required: false },
|
|
24
25
|
input: { type: null, required: false },
|
|
25
26
|
shell: { type: String, required: false },
|
|
@@ -42,6 +43,7 @@ const {
|
|
|
42
43
|
submit
|
|
43
44
|
} = useFormRoot({
|
|
44
45
|
form: () => props.form,
|
|
46
|
+
runtime: () => props.runtime,
|
|
45
47
|
input: () => props.input,
|
|
46
48
|
onCancelled: (value) => emit("cancel", value),
|
|
47
49
|
onSubmitted: (value, result) => emit("submit", value, result),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { FormValue, FormObject, FormRendererController, FormRenderShell, FormUiConfig, FormValidationMode } from '../../types/index.js';
|
|
1
|
+
import type { FormValue, FormObject, FormRendererController, FormRuntime, FormRenderShell, FormUiConfig, FormValidationMode } from '../../types/index.js';
|
|
2
2
|
type __VLS_Props = {
|
|
3
3
|
form?: FormRendererController;
|
|
4
|
+
runtime?: FormRuntime;
|
|
4
5
|
schema?: FormValue;
|
|
5
6
|
input?: FormObject;
|
|
6
7
|
shell?: FormRenderShell;
|
|
@@ -8,5 +8,6 @@ export declare function useFormOverlayController(instance: FormApiRuntimeInstanc
|
|
|
8
8
|
handleSubmitted: (formData: FormObject, result: FormSubmitHandlerResult<FormValue>) => void;
|
|
9
9
|
open: import("vue").Ref<boolean, boolean>;
|
|
10
10
|
resolveAfterClose: () => void;
|
|
11
|
+
runtime: import("../types/index.js").FormRuntime;
|
|
11
12
|
title: import("vue").ComputedRef<string | undefined>;
|
|
12
13
|
};
|
|
@@ -3,6 +3,7 @@ import { getFormOverlayDescription, getFormOverlayTitle } from "../utils/overlay
|
|
|
3
3
|
import { isRecord } from "../utils/path.js";
|
|
4
4
|
import { useForm } from "./use-form.js";
|
|
5
5
|
import { useFormApi } from "./use-form-api.js";
|
|
6
|
+
import { useFormRuntime } from "./use-form-runtime.js";
|
|
6
7
|
export function useFormOverlayController(instance) {
|
|
7
8
|
const formApi = useFormApi();
|
|
8
9
|
const form = useForm({
|
|
@@ -17,6 +18,13 @@ export function useFormOverlayController(instance) {
|
|
|
17
18
|
() => getFormOverlayDescription(instance.schema) ?? getFormOverlayTitle(instance.schema) ?? "Form"
|
|
18
19
|
);
|
|
19
20
|
const dismissible = computed(() => !form.isSubmitting.value);
|
|
21
|
+
const runtime = useFormRuntime({
|
|
22
|
+
input: form.input,
|
|
23
|
+
schema: form.schema,
|
|
24
|
+
syncInput: form.syncInput,
|
|
25
|
+
validationMode: form.validationMode
|
|
26
|
+
});
|
|
27
|
+
form.bind(runtime);
|
|
20
28
|
formApi.setController(instance.id, form);
|
|
21
29
|
const runtimeControls = {
|
|
22
30
|
close: requestCancel,
|
|
@@ -24,6 +32,7 @@ export function useFormOverlayController(instance) {
|
|
|
24
32
|
};
|
|
25
33
|
formApi.setRuntimeControls(instance.id, runtimeControls);
|
|
26
34
|
onBeforeUnmount(() => {
|
|
35
|
+
form.unbind(runtime);
|
|
27
36
|
formApi.removeController(instance.id, form);
|
|
28
37
|
formApi.removeRuntimeControls(instance.id, runtimeControls);
|
|
29
38
|
});
|
|
@@ -85,6 +94,7 @@ export function useFormOverlayController(instance) {
|
|
|
85
94
|
handleSubmitted,
|
|
86
95
|
open,
|
|
87
96
|
resolveAfterClose,
|
|
97
|
+
runtime,
|
|
88
98
|
title
|
|
89
99
|
};
|
|
90
100
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { FormObject, FormRendererController, FormSubmitHandlerResult, FormUiConfig, FormValidationMode, FormValue } from '../types/index.js';
|
|
1
|
+
import type { FormObject, FormRendererController, FormRuntime, FormSubmitHandlerResult, FormUiConfig, FormValidationMode, FormValue } from '../types/index.js';
|
|
2
2
|
export interface UseFormRootParams {
|
|
3
3
|
/** Controller from `useForm`. Its schema, input, and policies win over the direct ones. */
|
|
4
4
|
form: () => FormRendererController | undefined;
|
|
5
|
+
/** Runtime owned by a parent. The root renders it and neither creates, binds nor disposes it. */
|
|
6
|
+
runtime?: () => FormRuntime | undefined;
|
|
5
7
|
schema: () => FormValue;
|
|
6
8
|
input: () => FormObject | undefined;
|
|
7
9
|
syncInput: () => boolean | readonly string[] | undefined;
|
|
@@ -27,7 +29,7 @@ export declare function useFormRoot(params: UseFormRootParams): {
|
|
|
27
29
|
};
|
|
28
30
|
input: import("vue").ComputedRef<import("../../shared/index.js").GenericObject | undefined>;
|
|
29
31
|
refreshContext: () => Promise<void>;
|
|
30
|
-
runtime:
|
|
32
|
+
runtime: FormRuntime;
|
|
31
33
|
schema: import("vue").ComputedRef<{}>;
|
|
32
34
|
submit: () => Promise<void>;
|
|
33
35
|
validationMode: import("vue").ComputedRef<FormValidationMode>;
|
|
@@ -34,17 +34,20 @@ export function useFormRoot(params) {
|
|
|
34
34
|
const validationMode = computed(
|
|
35
35
|
() => params.form()?.validationMode.value ?? params.validate() ?? getSchemaValidationMode(schema.value)
|
|
36
36
|
);
|
|
37
|
-
const
|
|
37
|
+
const ownedRuntime = params.runtime?.();
|
|
38
|
+
const runtime = ownedRuntime ?? useFormRuntime({ input, schema, syncInput, validationMode });
|
|
38
39
|
provideFormRuntime(runtime);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
previousController
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
if (!ownedRuntime) {
|
|
41
|
+
watch(
|
|
42
|
+
params.form,
|
|
43
|
+
(controller, previousController) => {
|
|
44
|
+
previousController?.unbind(runtime);
|
|
45
|
+
controller?.bind(runtime);
|
|
46
|
+
},
|
|
47
|
+
{ immediate: true }
|
|
48
|
+
);
|
|
49
|
+
onBeforeUnmount(() => params.form()?.unbind(runtime));
|
|
50
|
+
}
|
|
48
51
|
onMounted(async () => {
|
|
49
52
|
await nextTick();
|
|
50
53
|
const target = getSchemaAutoFocus(schema.value);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-ui-tools",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.2",
|
|
4
4
|
"description": "Nuxt module and runtime toolkit for UI-heavy Nuxt applications",
|
|
5
5
|
"homepage": "https://github.com/ChronicStone/nuxt-ui-tools#readme",
|
|
6
6
|
"bugs": "https://github.com/ChronicStone/nuxt-ui-tools/issues",
|