@neutro/form 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 agnostic-web
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/adapters/angular.ts
21
+ var angular_exports = {};
22
+ __export(angular_exports, {
23
+ useAngularForm: () => useAngularForm,
24
+ useAngularFormPath: () => useAngularFormPath
25
+ });
26
+ module.exports = __toCommonJS(angular_exports);
27
+
28
+ // ../adapters/angular/dist/index.js
29
+ var import_core = require("@angular/core");
30
+ function useAngularForm(form) {
31
+ const formSignal = (0, import_core.signal)(form.getState());
32
+ const unsubscribe = form.subscribe((s) => {
33
+ formSignal.set(s);
34
+ });
35
+ (0, import_core.inject)(import_core.DestroyRef).onDestroy(unsubscribe);
36
+ return {
37
+ state: formSignal.asReadonly(),
38
+ get: form.get,
39
+ set: form.set,
40
+ connect: form.connect,
41
+ submit: form.submit,
42
+ handleSubmit: form.handleSubmit,
43
+ reset: form.reset,
44
+ batch: form.batch,
45
+ arrayAppend: form.arrayAppend,
46
+ arrayInsert: form.arrayInsert,
47
+ arrayRemove: form.arrayRemove,
48
+ arrayMove: form.arrayMove,
49
+ arraySwap: form.arraySwap
50
+ };
51
+ }
52
+ function useAngularFormPath(form, path) {
53
+ const value = (0, import_core.signal)(form.get(path));
54
+ const fieldState = (0, import_core.signal)(null);
55
+ const unsubscribe = form.subscribeToPath(path, (v, fs) => {
56
+ value.set(v);
57
+ fieldState.set(fs);
58
+ });
59
+ (0, import_core.inject)(import_core.DestroyRef).onDestroy(unsubscribe);
60
+ return { value: value.asReadonly(), fieldState: fieldState.asReadonly() };
61
+ }
62
+ // Annotate the CommonJS export names for ESM import in node:
63
+ 0 && (module.exports = {
64
+ useAngularForm,
65
+ useAngularFormPath
66
+ });
@@ -0,0 +1,6 @@
1
+ export * from '@neutro/form-angular';
2
+ import '@neutro/form-react';
3
+ import '@neutro/form-solid';
4
+ import '@neutro/form-svelte';
5
+ import '@neutro/form-vue';
6
+ import '@neutro/form-core';
@@ -0,0 +1,6 @@
1
+ export * from '@neutro/form-angular';
2
+ import '@neutro/form-react';
3
+ import '@neutro/form-solid';
4
+ import '@neutro/form-svelte';
5
+ import '@neutro/form-vue';
6
+ import '@neutro/form-core';
@@ -0,0 +1,38 @@
1
+ // ../adapters/angular/dist/index.js
2
+ import { signal, DestroyRef, inject } from "@angular/core";
3
+ function useAngularForm(form) {
4
+ const formSignal = signal(form.getState());
5
+ const unsubscribe = form.subscribe((s) => {
6
+ formSignal.set(s);
7
+ });
8
+ inject(DestroyRef).onDestroy(unsubscribe);
9
+ return {
10
+ state: formSignal.asReadonly(),
11
+ get: form.get,
12
+ set: form.set,
13
+ connect: form.connect,
14
+ submit: form.submit,
15
+ handleSubmit: form.handleSubmit,
16
+ reset: form.reset,
17
+ batch: form.batch,
18
+ arrayAppend: form.arrayAppend,
19
+ arrayInsert: form.arrayInsert,
20
+ arrayRemove: form.arrayRemove,
21
+ arrayMove: form.arrayMove,
22
+ arraySwap: form.arraySwap
23
+ };
24
+ }
25
+ function useAngularFormPath(form, path) {
26
+ const value = signal(form.get(path));
27
+ const fieldState = signal(null);
28
+ const unsubscribe = form.subscribeToPath(path, (v, fs) => {
29
+ value.set(v);
30
+ fieldState.set(fs);
31
+ });
32
+ inject(DestroyRef).onDestroy(unsubscribe);
33
+ return { value: value.asReadonly(), fieldState: fieldState.asReadonly() };
34
+ }
35
+ export {
36
+ useAngularForm,
37
+ useAngularFormPath
38
+ };
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/adapters/react.ts
21
+ var react_exports = {};
22
+ __export(react_exports, {
23
+ useForm: () => useForm,
24
+ useFormConnect: () => useFormConnect,
25
+ useFormPath: () => useFormPath
26
+ });
27
+ module.exports = __toCommonJS(react_exports);
28
+
29
+ // ../adapters/react/dist/index.js
30
+ var import_react = require("react");
31
+ function useForm(form) {
32
+ const state = (0, import_react.useSyncExternalStore)(form.subscribe, form.getState, form.getState);
33
+ return {
34
+ ...state,
35
+ get: form.get,
36
+ set: form.set,
37
+ connect: form.connect,
38
+ submit: form.submit,
39
+ handleSubmit: form.handleSubmit,
40
+ reset: form.reset,
41
+ batch: form.batch,
42
+ subscribeToPath: form.subscribeToPath,
43
+ validate: form.validate,
44
+ getPayload: form.getPayload,
45
+ getConnectedCount: form.getConnectedCount,
46
+ destroy: form.destroy,
47
+ arrayAppend: form.arrayAppend,
48
+ arrayInsert: form.arrayInsert,
49
+ arrayRemove: form.arrayRemove,
50
+ arrayMove: form.arrayMove,
51
+ arraySwap: form.arraySwap
52
+ };
53
+ }
54
+ function useFormPath(form, path) {
55
+ const subscribe = (0, import_react.useCallback)(
56
+ (onStoreChange) => form.subscribeToPath(path, () => onStoreChange()),
57
+ [form, path]
58
+ );
59
+ const getSnapshot = (0, import_react.useCallback)(() => form.get(path), [form, path]);
60
+ return (0, import_react.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
61
+ }
62
+ function useFormConnect(form) {
63
+ const cleanups = (0, import_react.useRef)(/* @__PURE__ */ new Map());
64
+ return (0, import_react.useCallback)(
65
+ (path, options) => (el) => {
66
+ if (el) {
67
+ cleanups.current.get(path)?.();
68
+ cleanups.current.set(path, form.connect(path, el, options));
69
+ } else {
70
+ cleanups.current.get(path)?.();
71
+ cleanups.current.delete(path);
72
+ }
73
+ },
74
+ [form]
75
+ );
76
+ }
77
+ // Annotate the CommonJS export names for ESM import in node:
78
+ 0 && (module.exports = {
79
+ useForm,
80
+ useFormConnect,
81
+ useFormPath
82
+ });
@@ -0,0 +1 @@
1
+ export * from '@neutro/form-react';
@@ -0,0 +1 @@
1
+ export * from '@neutro/form-react';
@@ -0,0 +1,53 @@
1
+ // ../adapters/react/dist/index.js
2
+ import { useSyncExternalStore, useCallback, useRef } from "react";
3
+ function useForm(form) {
4
+ const state = useSyncExternalStore(form.subscribe, form.getState, form.getState);
5
+ return {
6
+ ...state,
7
+ get: form.get,
8
+ set: form.set,
9
+ connect: form.connect,
10
+ submit: form.submit,
11
+ handleSubmit: form.handleSubmit,
12
+ reset: form.reset,
13
+ batch: form.batch,
14
+ subscribeToPath: form.subscribeToPath,
15
+ validate: form.validate,
16
+ getPayload: form.getPayload,
17
+ getConnectedCount: form.getConnectedCount,
18
+ destroy: form.destroy,
19
+ arrayAppend: form.arrayAppend,
20
+ arrayInsert: form.arrayInsert,
21
+ arrayRemove: form.arrayRemove,
22
+ arrayMove: form.arrayMove,
23
+ arraySwap: form.arraySwap
24
+ };
25
+ }
26
+ function useFormPath(form, path) {
27
+ const subscribe = useCallback(
28
+ (onStoreChange) => form.subscribeToPath(path, () => onStoreChange()),
29
+ [form, path]
30
+ );
31
+ const getSnapshot = useCallback(() => form.get(path), [form, path]);
32
+ return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
33
+ }
34
+ function useFormConnect(form) {
35
+ const cleanups = useRef(/* @__PURE__ */ new Map());
36
+ return useCallback(
37
+ (path, options) => (el) => {
38
+ if (el) {
39
+ cleanups.current.get(path)?.();
40
+ cleanups.current.set(path, form.connect(path, el, options));
41
+ } else {
42
+ cleanups.current.get(path)?.();
43
+ cleanups.current.delete(path);
44
+ }
45
+ },
46
+ [form]
47
+ );
48
+ }
49
+ export {
50
+ useForm,
51
+ useFormConnect,
52
+ useFormPath
53
+ };
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/adapters/solid.ts
21
+ var solid_exports = {};
22
+ __export(solid_exports, {
23
+ useSolidForm: () => useSolidForm,
24
+ useSolidFormPath: () => useSolidFormPath
25
+ });
26
+ module.exports = __toCommonJS(solid_exports);
27
+
28
+ // ../adapters/solid/dist/index.js
29
+ var import_solid_js = require("solid-js");
30
+ var import_store = require("solid-js/store");
31
+ function useSolidForm(form) {
32
+ const [state, setState] = (0, import_store.createStore)(form.getState());
33
+ const unsubscribe = form.subscribe((s) => {
34
+ setState((0, import_store.reconcile)(s));
35
+ });
36
+ (0, import_solid_js.onCleanup)(unsubscribe);
37
+ return [
38
+ state,
39
+ {
40
+ get: form.get,
41
+ set: form.set,
42
+ connect: form.connect,
43
+ submit: form.submit,
44
+ handleSubmit: form.handleSubmit,
45
+ reset: form.reset,
46
+ batch: form.batch,
47
+ arrayAppend: form.arrayAppend,
48
+ arrayInsert: form.arrayInsert,
49
+ arrayRemove: form.arrayRemove,
50
+ arrayMove: form.arrayMove,
51
+ arraySwap: form.arraySwap
52
+ }
53
+ ];
54
+ }
55
+ function useSolidFormPath(form, path) {
56
+ const [value, setValue] = (0, import_solid_js.createSignal)(form.get(path()));
57
+ const [fieldState, setFieldState] = (0, import_solid_js.createSignal)(null);
58
+ const unsubscribe = form.subscribeToPath(path(), (v, fs) => {
59
+ setValue(() => v);
60
+ setFieldState(() => fs);
61
+ });
62
+ (0, import_solid_js.onCleanup)(unsubscribe);
63
+ return { value, fieldState };
64
+ }
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ useSolidForm,
68
+ useSolidFormPath
69
+ });
@@ -0,0 +1 @@
1
+ export * from '@neutro/form-solid';
@@ -0,0 +1 @@
1
+ export * from '@neutro/form-solid';
@@ -0,0 +1,41 @@
1
+ // ../adapters/solid/dist/index.js
2
+ import { createSignal, onCleanup } from "solid-js";
3
+ import { createStore, reconcile } from "solid-js/store";
4
+ function useSolidForm(form) {
5
+ const [state, setState] = createStore(form.getState());
6
+ const unsubscribe = form.subscribe((s) => {
7
+ setState(reconcile(s));
8
+ });
9
+ onCleanup(unsubscribe);
10
+ return [
11
+ state,
12
+ {
13
+ get: form.get,
14
+ set: form.set,
15
+ connect: form.connect,
16
+ submit: form.submit,
17
+ handleSubmit: form.handleSubmit,
18
+ reset: form.reset,
19
+ batch: form.batch,
20
+ arrayAppend: form.arrayAppend,
21
+ arrayInsert: form.arrayInsert,
22
+ arrayRemove: form.arrayRemove,
23
+ arrayMove: form.arrayMove,
24
+ arraySwap: form.arraySwap
25
+ }
26
+ ];
27
+ }
28
+ function useSolidFormPath(form, path) {
29
+ const [value, setValue] = createSignal(form.get(path()));
30
+ const [fieldState, setFieldState] = createSignal(null);
31
+ const unsubscribe = form.subscribeToPath(path(), (v, fs) => {
32
+ setValue(() => v);
33
+ setFieldState(() => fs);
34
+ });
35
+ onCleanup(unsubscribe);
36
+ return { value, fieldState };
37
+ }
38
+ export {
39
+ useSolidForm,
40
+ useSolidFormPath
41
+ };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/adapters/svelte.ts
21
+ var svelte_exports = {};
22
+ __export(svelte_exports, {
23
+ useSvelteForm: () => useSvelteForm,
24
+ useSvelteFormPath: () => useSvelteFormPath
25
+ });
26
+ module.exports = __toCommonJS(svelte_exports);
27
+
28
+ // ../adapters/svelte/dist/index.js
29
+ var import_store = require("svelte/store");
30
+ function useSvelteForm(form) {
31
+ const state = (0, import_store.readable)(
32
+ form.getState(),
33
+ (set) => form.subscribe((s) => set(s))
34
+ );
35
+ return {
36
+ state,
37
+ get: form.get,
38
+ set: form.set,
39
+ connect: form.connect,
40
+ submit: form.submit,
41
+ handleSubmit: form.handleSubmit,
42
+ reset: form.reset,
43
+ batch: form.batch,
44
+ arrayAppend: form.arrayAppend,
45
+ arrayInsert: form.arrayInsert,
46
+ arrayRemove: form.arrayRemove,
47
+ arrayMove: form.arrayMove,
48
+ arraySwap: form.arraySwap
49
+ };
50
+ }
51
+ function useSvelteFormPath(form, path) {
52
+ const field = (0, import_store.readable)(
53
+ { value: form.get(path), fieldState: null },
54
+ (set) => form.subscribeToPath(path, (v, fs) => set({ value: v, fieldState: fs }))
55
+ );
56
+ return field;
57
+ }
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ useSvelteForm,
61
+ useSvelteFormPath
62
+ });
@@ -0,0 +1 @@
1
+ export * from '@neutro/form-svelte';
@@ -0,0 +1 @@
1
+ export * from '@neutro/form-svelte';
@@ -0,0 +1,34 @@
1
+ // ../adapters/svelte/dist/index.js
2
+ import { readable } from "svelte/store";
3
+ function useSvelteForm(form) {
4
+ const state = readable(
5
+ form.getState(),
6
+ (set) => form.subscribe((s) => set(s))
7
+ );
8
+ return {
9
+ state,
10
+ get: form.get,
11
+ set: form.set,
12
+ connect: form.connect,
13
+ submit: form.submit,
14
+ handleSubmit: form.handleSubmit,
15
+ reset: form.reset,
16
+ batch: form.batch,
17
+ arrayAppend: form.arrayAppend,
18
+ arrayInsert: form.arrayInsert,
19
+ arrayRemove: form.arrayRemove,
20
+ arrayMove: form.arrayMove,
21
+ arraySwap: form.arraySwap
22
+ };
23
+ }
24
+ function useSvelteFormPath(form, path) {
25
+ const field = readable(
26
+ { value: form.get(path), fieldState: null },
27
+ (set) => form.subscribeToPath(path, (v, fs) => set({ value: v, fieldState: fs }))
28
+ );
29
+ return field;
30
+ }
31
+ export {
32
+ useSvelteForm,
33
+ useSvelteFormPath
34
+ };
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/adapters/vue.ts
21
+ var vue_exports = {};
22
+ __export(vue_exports, {
23
+ useVueForm: () => useVueForm,
24
+ useVueFormPath: () => useVueFormPath
25
+ });
26
+ module.exports = __toCommonJS(vue_exports);
27
+
28
+ // ../adapters/vue/dist/index.js
29
+ var import_vue = require("vue");
30
+ function useVueForm(form) {
31
+ const state = (0, import_vue.shallowRef)(form.getState());
32
+ const unsubscribe = form.subscribe((s) => {
33
+ state.value = s;
34
+ });
35
+ (0, import_vue.onUnmounted)(unsubscribe);
36
+ return {
37
+ state: (0, import_vue.readonly)(state),
38
+ get: form.get,
39
+ set: form.set,
40
+ connect: form.connect,
41
+ submit: form.submit,
42
+ handleSubmit: form.handleSubmit,
43
+ reset: form.reset,
44
+ batch: form.batch,
45
+ arrayAppend: form.arrayAppend,
46
+ arrayInsert: form.arrayInsert,
47
+ arrayRemove: form.arrayRemove,
48
+ arrayMove: form.arrayMove,
49
+ arraySwap: form.arraySwap
50
+ };
51
+ }
52
+ function useVueFormPath(form, path) {
53
+ const value = (0, import_vue.shallowRef)(form.get((0, import_vue.unref)(path)));
54
+ const fieldState = (0, import_vue.shallowRef)(null);
55
+ let unsubscribe = form.subscribeToPath((0, import_vue.unref)(path), (v, fs) => {
56
+ value.value = v;
57
+ fieldState.value = fs;
58
+ });
59
+ (0, import_vue.watch)(
60
+ () => (0, import_vue.unref)(path),
61
+ (newPath) => {
62
+ unsubscribe();
63
+ value.value = form.get(newPath);
64
+ fieldState.value = null;
65
+ unsubscribe = form.subscribeToPath(newPath, (v, fs) => {
66
+ value.value = v;
67
+ fieldState.value = fs;
68
+ });
69
+ }
70
+ );
71
+ (0, import_vue.onUnmounted)(() => unsubscribe());
72
+ return { value: (0, import_vue.readonly)(value), fieldState: (0, import_vue.readonly)(fieldState) };
73
+ }
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ useVueForm,
77
+ useVueFormPath
78
+ });
@@ -0,0 +1 @@
1
+ export * from '@neutro/form-vue';
@@ -0,0 +1 @@
1
+ export * from '@neutro/form-vue';
@@ -0,0 +1,50 @@
1
+ // ../adapters/vue/dist/index.js
2
+ import { shallowRef, readonly, unref, watch, onUnmounted } from "vue";
3
+ function useVueForm(form) {
4
+ const state = shallowRef(form.getState());
5
+ const unsubscribe = form.subscribe((s) => {
6
+ state.value = s;
7
+ });
8
+ onUnmounted(unsubscribe);
9
+ return {
10
+ state: readonly(state),
11
+ get: form.get,
12
+ set: form.set,
13
+ connect: form.connect,
14
+ submit: form.submit,
15
+ handleSubmit: form.handleSubmit,
16
+ reset: form.reset,
17
+ batch: form.batch,
18
+ arrayAppend: form.arrayAppend,
19
+ arrayInsert: form.arrayInsert,
20
+ arrayRemove: form.arrayRemove,
21
+ arrayMove: form.arrayMove,
22
+ arraySwap: form.arraySwap
23
+ };
24
+ }
25
+ function useVueFormPath(form, path) {
26
+ const value = shallowRef(form.get(unref(path)));
27
+ const fieldState = shallowRef(null);
28
+ let unsubscribe = form.subscribeToPath(unref(path), (v, fs) => {
29
+ value.value = v;
30
+ fieldState.value = fs;
31
+ });
32
+ watch(
33
+ () => unref(path),
34
+ (newPath) => {
35
+ unsubscribe();
36
+ value.value = form.get(newPath);
37
+ fieldState.value = null;
38
+ unsubscribe = form.subscribeToPath(newPath, (v, fs) => {
39
+ value.value = v;
40
+ fieldState.value = fs;
41
+ });
42
+ }
43
+ );
44
+ onUnmounted(() => unsubscribe());
45
+ return { value: readonly(value), fieldState: readonly(fieldState) };
46
+ }
47
+ export {
48
+ useVueForm,
49
+ useVueFormPath
50
+ };