@ilokesto/form 1.0.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/README.ko.md +1276 -0
- package/README.md +1277 -0
- package/dist/FormStateSummary-YyGT9nfY.js +124 -0
- package/dist/adapters/FormStateSummary.d.ts +12 -0
- package/dist/adapters/dom/FieldValue.d.ts +2 -0
- package/dist/adapters/dom/RegisterBinding.d.ts +14 -0
- package/dist/adapters/dom/index.d.ts +3 -0
- package/dist/adapters/dom/types.d.ts +22 -0
- package/dist/core/array/ArrayItemReorder.d.ts +6 -0
- package/dist/core/array/ArrayKeyGenerator.d.ts +4 -0
- package/dist/core/array/FormArrayController.d.ts +21 -0
- package/dist/core/array/FormArrayFactory.d.ts +8 -0
- package/dist/core/array/FormArrayMutationPlanner.d.ts +14 -0
- package/dist/core/array/FormArrayPath.d.ts +6 -0
- package/dist/core/array/FormArrayRebaser.d.ts +7 -0
- package/dist/core/array/index.d.ts +1 -0
- package/dist/core/form/CreateForm.d.ts +23 -0
- package/dist/core/form/FormFieldCommands.d.ts +15 -0
- package/dist/core/form/FormSubmitter.d.ts +9 -0
- package/dist/core/form/index.d.ts +1 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/path/FormPath.d.ts +9 -0
- package/dist/core/path/index.d.ts +1 -0
- package/dist/core/state/FieldStateFactory.d.ts +6 -0
- package/dist/core/state/FormStateInitializer.d.ts +7 -0
- package/dist/core/state/FormStateReader.d.ts +11 -0
- package/dist/core/state/FormStateStore.d.ts +23 -0
- package/dist/core/state/FormStateWriter.d.ts +16 -0
- package/dist/core/state/index.d.ts +1 -0
- package/dist/core/types.d.ts +96 -0
- package/dist/core/validation/StandardSchemaValidator.d.ts +14 -0
- package/dist/core/validation/ValidationEngine.d.ts +25 -0
- package/dist/core/validation/index.d.ts +1 -0
- package/dist/core/value/ValueHelper.d.ts +7 -0
- package/dist/core/value/index.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1245 -0
- package/dist/react/RegisterBinding.d.ts +5 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.js +83 -0
- package/dist/react/types.d.ts +64 -0
- package/dist/react/useField.d.ts +3 -0
- package/dist/react/useFieldSchemaRegistration.d.ts +4 -0
- package/dist/react/useForm.d.ts +3 -0
- package/dist/react/useFormSnapshot.d.ts +2 -0
- package/dist/react/useFormState.d.ts +3 -0
- package/dist/react/useRegister.d.ts +6 -0
- package/dist/solid/RegisterBinding.d.ts +5 -0
- package/dist/solid/index.d.ts +2 -0
- package/dist/solid/index.js +110 -0
- package/dist/solid/types.d.ts +68 -0
- package/dist/solid/useField.d.ts +3 -0
- package/dist/solid/useFieldSchemaRegistration.d.ts +3 -0
- package/dist/solid/useForm.d.ts +3 -0
- package/dist/solid/useFormSnapshot.d.ts +3 -0
- package/dist/solid/useFormState.d.ts +3 -0
- package/dist/solid/useRegister.d.ts +6 -0
- package/dist/svelte/RegisterAction.d.ts +4 -0
- package/dist/svelte/index.d.ts +2 -0
- package/dist/svelte/index.js +107 -0
- package/dist/svelte/types.d.ts +12 -0
- package/dist/svelte/useForm.d.ts +3 -0
- package/dist/svelte/useFormState.d.ts +4 -0
- package/dist/vue/RegisterBinding.d.ts +5 -0
- package/dist/vue/index.d.ts +2 -0
- package/dist/vue/index.js +110 -0
- package/dist/vue/types.d.ts +68 -0
- package/dist/vue/useField.d.ts +3 -0
- package/dist/vue/useFieldSchemaRegistration.d.ts +3 -0
- package/dist/vue/useForm.d.ts +3 -0
- package/dist/vue/useFormSnapshot.d.ts +3 -0
- package/dist/vue/useFormState.d.ts +3 -0
- package/dist/vue/useRegister.d.ts +6 -0
- package/package.json +93 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { c as p, f as o, g, a as F } from "../FormStateSummary-YyGT9nfY.js";
|
|
2
|
+
import { getCurrentScope as l, onScopeDispose as h, shallowRef as S } from "vue";
|
|
3
|
+
function m(e, t, r, n) {
|
|
4
|
+
const s = p(e, t, r, n);
|
|
5
|
+
return {
|
|
6
|
+
name: s.name,
|
|
7
|
+
type: s.type,
|
|
8
|
+
get value() {
|
|
9
|
+
return s.value;
|
|
10
|
+
},
|
|
11
|
+
get checked() {
|
|
12
|
+
return s.checked;
|
|
13
|
+
},
|
|
14
|
+
onInput: (a) => {
|
|
15
|
+
s.input(a.currentTarget);
|
|
16
|
+
},
|
|
17
|
+
onChange: (a) => {
|
|
18
|
+
s.change(a.currentTarget);
|
|
19
|
+
},
|
|
20
|
+
onBlur: () => {
|
|
21
|
+
s.blur();
|
|
22
|
+
},
|
|
23
|
+
onFocus: () => {
|
|
24
|
+
s.focus();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function d(e, t) {
|
|
29
|
+
const r = t.flatMap((n) => n.schema ? [e.registerFieldSchema(n.name, { schema: n.schema, schemaOptions: n.schemaOptions })] : []);
|
|
30
|
+
r.length !== 0 && l() && h(() => {
|
|
31
|
+
r.forEach((n) => n());
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function c(e) {
|
|
35
|
+
const t = S(e.getState()), r = e.subscribe(() => {
|
|
36
|
+
t.value = e.getState();
|
|
37
|
+
});
|
|
38
|
+
return l() && h(r), t;
|
|
39
|
+
}
|
|
40
|
+
function y(e, t) {
|
|
41
|
+
d(e, [t]);
|
|
42
|
+
const r = c(e), n = () => g(e, r.value, t.name);
|
|
43
|
+
return {
|
|
44
|
+
props: m(e, t, n, o(t.name)),
|
|
45
|
+
get value() {
|
|
46
|
+
return n().value;
|
|
47
|
+
},
|
|
48
|
+
setValue(u) {
|
|
49
|
+
e.setValue(t.name, u, { source: "program" });
|
|
50
|
+
},
|
|
51
|
+
get errors() {
|
|
52
|
+
return [...n().errors];
|
|
53
|
+
},
|
|
54
|
+
get dirty() {
|
|
55
|
+
return n().dirty;
|
|
56
|
+
},
|
|
57
|
+
get touched() {
|
|
58
|
+
return n().touched;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function b(e) {
|
|
63
|
+
const t = c(e), r = () => F(t.value);
|
|
64
|
+
return {
|
|
65
|
+
get state() {
|
|
66
|
+
return t.value;
|
|
67
|
+
},
|
|
68
|
+
get errors() {
|
|
69
|
+
return r().errors;
|
|
70
|
+
},
|
|
71
|
+
get dirtyFields() {
|
|
72
|
+
return r().dirtyFields;
|
|
73
|
+
},
|
|
74
|
+
get touchedFields() {
|
|
75
|
+
return r().touchedFields;
|
|
76
|
+
},
|
|
77
|
+
get isDirty() {
|
|
78
|
+
return r().isDirty;
|
|
79
|
+
},
|
|
80
|
+
get isValid() {
|
|
81
|
+
return r().isValid;
|
|
82
|
+
},
|
|
83
|
+
get isSubmitting() {
|
|
84
|
+
return r().isSubmitting;
|
|
85
|
+
},
|
|
86
|
+
get submitCount() {
|
|
87
|
+
return r().submitCount;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function v(e, t, ...r) {
|
|
92
|
+
const n = Array.isArray(t) || r.length > 0, s = R(t, r);
|
|
93
|
+
d(e, s);
|
|
94
|
+
const u = c(e), a = s.map((i) => m(
|
|
95
|
+
e,
|
|
96
|
+
i,
|
|
97
|
+
() => g(e, u.value, i.name),
|
|
98
|
+
o(i.name)
|
|
99
|
+
));
|
|
100
|
+
return n ? a : a[0];
|
|
101
|
+
}
|
|
102
|
+
function R(e, t) {
|
|
103
|
+
return Array.isArray(e) ? e : t.length > 0 ? [e, ...t] : [e];
|
|
104
|
+
}
|
|
105
|
+
function A(e) {
|
|
106
|
+
return { form: e, useRegister: ((s, ...u) => v(e, s, ...u)), useField: ((s) => y(e, s)), useFormState: () => b(e) };
|
|
107
|
+
}
|
|
108
|
+
export {
|
|
109
|
+
A as useForm
|
|
110
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Form, FormError, FormState } from '../core/index.js';
|
|
2
|
+
import type { DomValue, RegisterOptions } from '../adapters/dom.js';
|
|
3
|
+
export type { RegisterOptions } from '../adapters/dom.js';
|
|
4
|
+
type VueBindingHandlers<TElement extends HTMLElement> = {
|
|
5
|
+
onInput: (event: Event & {
|
|
6
|
+
currentTarget: TElement;
|
|
7
|
+
}) => void;
|
|
8
|
+
onChange: (event: Event & {
|
|
9
|
+
currentTarget: TElement;
|
|
10
|
+
}) => void;
|
|
11
|
+
onBlur: (event: FocusEvent & {
|
|
12
|
+
currentTarget: TElement;
|
|
13
|
+
}) => void;
|
|
14
|
+
onFocus: (event: FocusEvent & {
|
|
15
|
+
currentTarget: TElement;
|
|
16
|
+
}) => void;
|
|
17
|
+
};
|
|
18
|
+
export type VueInputRegisterProps = VueBindingHandlers<HTMLInputElement> & {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly type: string;
|
|
21
|
+
readonly value?: DomValue;
|
|
22
|
+
readonly checked?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type VueSelectRegisterProps = VueBindingHandlers<HTMLSelectElement> & {
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly value?: DomValue;
|
|
27
|
+
};
|
|
28
|
+
export type VueTextareaRegisterProps = VueBindingHandlers<HTMLTextAreaElement> & {
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly value?: string | number;
|
|
31
|
+
};
|
|
32
|
+
export type VueCustomRegisterProps<TElement extends HTMLElement = HTMLElement> = VueBindingHandlers<TElement> & {
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly value?: unknown;
|
|
35
|
+
readonly checked?: boolean;
|
|
36
|
+
};
|
|
37
|
+
export type VueRegisterElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | HTMLElement;
|
|
38
|
+
export type VueRegisterPropsForElement<TElement extends VueRegisterElement> = TElement extends HTMLSelectElement ? VueSelectRegisterProps : TElement extends HTMLTextAreaElement ? VueTextareaRegisterProps : TElement extends HTMLInputElement ? VueInputRegisterProps : VueCustomRegisterProps<TElement>;
|
|
39
|
+
export type VueRegisterProps = VueRegisterPropsForElement<VueRegisterElement>;
|
|
40
|
+
export type VueRegisterPropsList<TElement extends VueRegisterElement, TOptions extends readonly RegisterOptions[]> = {
|
|
41
|
+
[Index in keyof TOptions]: TOptions[Index] extends RegisterOptions ? VueRegisterPropsForElement<TElement> : never;
|
|
42
|
+
};
|
|
43
|
+
export type VueFieldReturn<TProps extends VueRegisterProps = VueInputRegisterProps> = {
|
|
44
|
+
readonly props: TProps;
|
|
45
|
+
readonly value: unknown;
|
|
46
|
+
setValue(value: unknown): void;
|
|
47
|
+
readonly errors: FormError[];
|
|
48
|
+
readonly dirty: boolean;
|
|
49
|
+
readonly touched: boolean;
|
|
50
|
+
};
|
|
51
|
+
export type VueFormStateReturn<TValues> = {
|
|
52
|
+
readonly state: Readonly<FormState<TValues>>;
|
|
53
|
+
readonly errors: Record<string, FormError[]>;
|
|
54
|
+
readonly dirtyFields: Record<string, true>;
|
|
55
|
+
readonly touchedFields: Record<string, true>;
|
|
56
|
+
readonly isDirty: boolean;
|
|
57
|
+
readonly isValid: boolean;
|
|
58
|
+
readonly isSubmitting: boolean;
|
|
59
|
+
readonly submitCount: number;
|
|
60
|
+
};
|
|
61
|
+
export type VueForm<TValues> = {
|
|
62
|
+
form: Form<TValues>;
|
|
63
|
+
useRegister<TElement extends VueRegisterElement = HTMLInputElement>(options: RegisterOptions): VueRegisterPropsForElement<TElement>;
|
|
64
|
+
useRegister<TElement extends VueRegisterElement = HTMLInputElement, TOptions extends readonly RegisterOptions[] = readonly RegisterOptions[]>(options: TOptions): VueRegisterPropsList<TElement, TOptions>;
|
|
65
|
+
useRegister<TElement extends VueRegisterElement = HTMLInputElement, TOptions extends readonly RegisterOptions[] = readonly RegisterOptions[]>(...options: TOptions): VueRegisterPropsList<TElement, TOptions>;
|
|
66
|
+
useField<TElement extends VueRegisterElement = HTMLInputElement>(options: RegisterOptions): VueFieldReturn<VueRegisterPropsForElement<TElement>>;
|
|
67
|
+
useFormState(): VueFormStateReturn<TValues>;
|
|
68
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Form } from '../core/index.js';
|
|
2
|
+
import type { RegisterOptions, VueFieldReturn, VueRegisterElement, VueRegisterPropsForElement } from './types.js';
|
|
3
|
+
export declare function useFieldWithForm<TValues, TElement extends VueRegisterElement = HTMLInputElement>(form: Form<TValues>, options: RegisterOptions): VueFieldReturn<VueRegisterPropsForElement<TElement>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Form } from '../core/index.js';
|
|
2
|
+
import type { RegisterOptions, VueRegisterElement, VueRegisterPropsForElement, VueRegisterPropsList } from './types.js';
|
|
3
|
+
export declare function useRegisterWithForm<TValues, TElement extends VueRegisterElement = HTMLInputElement>(form: Form<TValues>, options: RegisterOptions): VueRegisterPropsForElement<TElement>;
|
|
4
|
+
export declare function useRegisterWithForm<TValues, TElement extends VueRegisterElement = HTMLInputElement, TOptions extends readonly RegisterOptions[] = readonly RegisterOptions[]>(form: Form<TValues>, options: TOptions): VueRegisterPropsList<TElement, TOptions>;
|
|
5
|
+
export declare function useRegisterWithForm<TValues, TElement extends VueRegisterElement = HTMLInputElement, TOptions extends readonly RegisterOptions[] = readonly RegisterOptions[]>(form: Form<TValues>, ...options: TOptions): VueRegisterPropsList<TElement, TOptions>;
|
|
6
|
+
export declare function useRegisterWithForm<TValues>(form: Form<TValues>, first: RegisterOptions | readonly RegisterOptions[], ...rest: readonly RegisterOptions[]): VueRegisterPropsForElement<VueRegisterElement> | VueRegisterPropsForElement<VueRegisterElement>[];
|
package/package.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ilokesto/form",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/ilokesto/form"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://ilokesto.ayden94.com/en/form",
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"keywords": [
|
|
12
|
+
"form",
|
|
13
|
+
"validation"
|
|
14
|
+
],
|
|
15
|
+
"author": "Jeong Jinho <wpfekdml@me.com>",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"types": "dist/index.d.ts",
|
|
19
|
+
"module": "dist/index.js",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"import": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./react": {
|
|
26
|
+
"import": "./dist/react/index.js",
|
|
27
|
+
"types": "./dist/react/index.d.ts"
|
|
28
|
+
},
|
|
29
|
+
"./vue": {
|
|
30
|
+
"import": "./dist/vue/index.js",
|
|
31
|
+
"types": "./dist/vue/index.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"./solid": {
|
|
34
|
+
"import": "./dist/solid/index.js",
|
|
35
|
+
"types": "./dist/solid/index.d.ts"
|
|
36
|
+
},
|
|
37
|
+
"./svelte": {
|
|
38
|
+
"import": "./dist/svelte/index.js",
|
|
39
|
+
"types": "./dist/svelte/index.d.ts"
|
|
40
|
+
},
|
|
41
|
+
"./package.json": "./package.json"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist"
|
|
45
|
+
],
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@ilokesto/store": "1.1.1",
|
|
48
|
+
"immer": "^11.1.8"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@testing-library/react": "^16.3.2",
|
|
52
|
+
"@types/node": "^22.19.1",
|
|
53
|
+
"@types/react": "^19.2.15",
|
|
54
|
+
"@types/react-dom": "^19.2.3",
|
|
55
|
+
"jsdom": "^27.4.0",
|
|
56
|
+
"react": "^19.0.0",
|
|
57
|
+
"react-dom": "^19.2.6",
|
|
58
|
+
"solid-js": "^1.9.13",
|
|
59
|
+
"svelte": "^5.55.9",
|
|
60
|
+
"typescript": "^6.0.2",
|
|
61
|
+
"vite": "^7.3.3",
|
|
62
|
+
"vitest": "^4.1.7",
|
|
63
|
+
"vue": "^3.5.34"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"react": "^19.0.0",
|
|
67
|
+
"vue": "^3.5.0",
|
|
68
|
+
"solid-js": "^1.9.0",
|
|
69
|
+
"svelte": "^5.0.0"
|
|
70
|
+
},
|
|
71
|
+
"peerDependenciesMeta": {
|
|
72
|
+
"react": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"vue": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"solid-js": {
|
|
79
|
+
"optional": true
|
|
80
|
+
},
|
|
81
|
+
"svelte": {
|
|
82
|
+
"optional": true
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"publishConfig": {
|
|
86
|
+
"access": "public"
|
|
87
|
+
},
|
|
88
|
+
"scripts": {
|
|
89
|
+
"build": "rm -rf dist && tsc --emitDeclarationOnly && node scripts/fix-dts-imports.mjs && vite build",
|
|
90
|
+
"typecheck": "tsc --noEmit",
|
|
91
|
+
"test": "vitest run"
|
|
92
|
+
}
|
|
93
|
+
}
|