@ehfuse/forma 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.
Files changed (99) hide show
  1. package/LICENSE +42 -0
  2. package/README.md +180 -0
  3. package/dist/contexts/GlobalFormContext.d.ts +66 -0
  4. package/dist/contexts/GlobalFormContext.d.ts.map +1 -0
  5. package/dist/contexts/GlobalFormContext.js +110 -0
  6. package/dist/contexts/GlobalFormContext.js.map +1 -0
  7. package/dist/core/FieldStore.d.ts +100 -0
  8. package/dist/core/FieldStore.d.ts.map +1 -0
  9. package/dist/core/FieldStore.js +264 -0
  10. package/dist/core/FieldStore.js.map +1 -0
  11. package/dist/core/index.d.ts +29 -0
  12. package/dist/core/index.d.ts.map +1 -0
  13. package/dist/core/index.js +36 -0
  14. package/dist/core/index.js.map +1 -0
  15. package/dist/esm/contexts/GlobalFormContext.d.ts +66 -0
  16. package/dist/esm/contexts/GlobalFormContext.d.ts.map +1 -0
  17. package/dist/esm/contexts/GlobalFormContext.js +106 -0
  18. package/dist/esm/contexts/GlobalFormContext.js.map +1 -0
  19. package/dist/esm/core/FieldStore.d.ts +100 -0
  20. package/dist/esm/core/FieldStore.d.ts.map +1 -0
  21. package/dist/esm/core/FieldStore.js +260 -0
  22. package/dist/esm/core/FieldStore.js.map +1 -0
  23. package/dist/esm/core/index.d.ts +29 -0
  24. package/dist/esm/core/index.d.ts.map +1 -0
  25. package/dist/esm/core/index.js +32 -0
  26. package/dist/esm/core/index.js.map +1 -0
  27. package/dist/esm/hooks/useForm.d.ts +67 -0
  28. package/dist/esm/hooks/useForm.d.ts.map +1 -0
  29. package/dist/esm/hooks/useForm.js +287 -0
  30. package/dist/esm/hooks/useForm.js.map +1 -0
  31. package/dist/esm/hooks/useGlobalForm.d.ts +45 -0
  32. package/dist/esm/hooks/useGlobalForm.d.ts.map +1 -0
  33. package/dist/esm/hooks/useGlobalForm.js +61 -0
  34. package/dist/esm/hooks/useGlobalForm.js.map +1 -0
  35. package/dist/esm/hooks/useRegisterGlobalForm.d.ts +55 -0
  36. package/dist/esm/hooks/useRegisterGlobalForm.d.ts.map +1 -0
  37. package/dist/esm/hooks/useRegisterGlobalForm.js +64 -0
  38. package/dist/esm/hooks/useRegisterGlobalForm.js.map +1 -0
  39. package/dist/esm/index.d.ts +53 -0
  40. package/dist/esm/index.d.ts.map +1 -0
  41. package/dist/esm/index.js +62 -0
  42. package/dist/esm/index.js.map +1 -0
  43. package/dist/esm/types/form.d.ts +120 -0
  44. package/dist/esm/types/form.d.ts.map +1 -0
  45. package/dist/esm/types/form.js +29 -0
  46. package/dist/esm/types/form.js.map +1 -0
  47. package/dist/esm/types/globalForm.d.ts +265 -0
  48. package/dist/esm/types/globalForm.d.ts.map +1 -0
  49. package/dist/esm/types/globalForm.js +39 -0
  50. package/dist/esm/types/globalForm.js.map +1 -0
  51. package/dist/esm/types/index.d.ts +31 -0
  52. package/dist/esm/types/index.d.ts.map +1 -0
  53. package/dist/esm/types/index.js +30 -0
  54. package/dist/esm/types/index.js.map +1 -0
  55. package/dist/esm/utils/dotNotation.d.ts +58 -0
  56. package/dist/esm/utils/dotNotation.d.ts.map +1 -0
  57. package/dist/esm/utils/dotNotation.js +100 -0
  58. package/dist/esm/utils/dotNotation.js.map +1 -0
  59. package/dist/esm/utils/index.d.ts +27 -0
  60. package/dist/esm/utils/index.d.ts.map +1 -0
  61. package/dist/esm/utils/index.js +27 -0
  62. package/dist/esm/utils/index.js.map +1 -0
  63. package/dist/hooks/useForm.d.ts +67 -0
  64. package/dist/hooks/useForm.d.ts.map +1 -0
  65. package/dist/hooks/useForm.js +290 -0
  66. package/dist/hooks/useForm.js.map +1 -0
  67. package/dist/hooks/useGlobalForm.d.ts +45 -0
  68. package/dist/hooks/useGlobalForm.d.ts.map +1 -0
  69. package/dist/hooks/useGlobalForm.js +64 -0
  70. package/dist/hooks/useGlobalForm.js.map +1 -0
  71. package/dist/hooks/useRegisterGlobalForm.d.ts +55 -0
  72. package/dist/hooks/useRegisterGlobalForm.d.ts.map +1 -0
  73. package/dist/hooks/useRegisterGlobalForm.js +67 -0
  74. package/dist/hooks/useRegisterGlobalForm.js.map +1 -0
  75. package/dist/index.d.ts +53 -0
  76. package/dist/index.d.ts.map +1 -0
  77. package/dist/index.js +73 -0
  78. package/dist/index.js.map +1 -0
  79. package/dist/types/form.d.ts +120 -0
  80. package/dist/types/form.d.ts.map +1 -0
  81. package/dist/types/form.js +30 -0
  82. package/dist/types/form.js.map +1 -0
  83. package/dist/types/globalForm.d.ts +265 -0
  84. package/dist/types/globalForm.d.ts.map +1 -0
  85. package/dist/types/globalForm.js +43 -0
  86. package/dist/types/globalForm.js.map +1 -0
  87. package/dist/types/index.d.ts +31 -0
  88. package/dist/types/index.d.ts.map +1 -0
  89. package/dist/types/index.js +34 -0
  90. package/dist/types/index.js.map +1 -0
  91. package/dist/utils/dotNotation.d.ts +58 -0
  92. package/dist/utils/dotNotation.d.ts.map +1 -0
  93. package/dist/utils/dotNotation.js +104 -0
  94. package/dist/utils/dotNotation.js.map +1 -0
  95. package/dist/utils/index.d.ts +27 -0
  96. package/dist/utils/index.d.ts.map +1 -0
  97. package/dist/utils/index.js +32 -0
  98. package/dist/utils/index.js.map +1 -0
  99. package/package.json +71 -0
@@ -0,0 +1,287 @@
1
+ /**
2
+ * useForm.ts
3
+ *
4
+ * Forma - 고급 폼 상태 관리 훅 / Advanced form state management hook
5
+ * 개별 필드 구독과 성능 최적화를 제공하는 핵심 훅
6
+ * Core hook providing individual field subscriptions and performance optimization
7
+ *
8
+ * @license MIT License
9
+ * @copyright 2025 KIM YOUNG JIN (Kim Young Jin)
10
+ * @author KIM YOUNG JIN (ehfuse@gmail.com)
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+ import { FieldStore } from "../core/FieldStore";
31
+ import { useEffect, useState, useCallback, useRef, useMemo, } from "react";
32
+ /**
33
+ * 개별 필드 구독 / Individual field subscription
34
+ * 특정 필드만 구독하여 해당 필드가 변경될 때만 리렌더링
35
+ * Subscribe to specific field only, re-render only when that field changes
36
+ */
37
+ function useFieldValue(store, fieldName) {
38
+ const [value, setValue] = useState(() => store.getValue(fieldName));
39
+ useEffect(() => {
40
+ // 구독 설정 / Setup subscription
41
+ const unsubscribe = store.subscribe(fieldName, () => {
42
+ const newValue = store.getValue(fieldName);
43
+ setValue(newValue);
44
+ });
45
+ return unsubscribe;
46
+ }, [fieldName]); // store 의존성 제거로 불필요한 재구독 방지 / Remove store dependency to prevent unnecessary re-subscriptions
47
+ return value;
48
+ }
49
+ /**
50
+ * Forma 핵심 폼 관리 훅 / Forma core form management hook
51
+ *
52
+ * 고급 폼 상태 관리와 성능 최적화를 제공합니다
53
+ * Provides advanced form state management and performance optimization
54
+ *
55
+ * Features:
56
+ * - 개별 필드 구독으로 선택적 리렌더링 / Selective re-rendering with individual field subscriptions
57
+ * - Dot notation 지원으로 중첩 객체 처리 / Nested object handling with dot notation support
58
+ * - MUI 컴포넌트 완전 호환 / Full MUI component compatibility
59
+ * - TypeScript 완전 지원 / Complete TypeScript support
60
+ *
61
+ * @template T 폼 데이터의 타입 / Form data type
62
+ * @param props 폼 설정 옵션 / Form configuration options
63
+ * @returns 폼 관리 API 객체 / Form management API object
64
+ */
65
+ export function useForm({ initialValues, onSubmit, onValidate, onComplete, _externalStore, }) {
66
+ // Store 인스턴스 (외부 스토어가 있으면 사용, 없으면 로컬 생성)
67
+ // Store instance (use external store if provided, otherwise create local one)
68
+ const storeRef = useRef(null);
69
+ if (_externalStore) {
70
+ storeRef.current = _externalStore;
71
+ }
72
+ else if (!storeRef.current) {
73
+ storeRef.current = new FieldStore(initialValues);
74
+ }
75
+ const store = storeRef.current;
76
+ const [isSubmitting, setIsSubmitting] = useState(false);
77
+ const [isValidating, setIsValidating] = useState(false);
78
+ const [isModified, setIsModified] = useState(false);
79
+ // 전역 상태 구독 (isModified 추적) / Global state subscription (isModified tracking)
80
+ useEffect(() => {
81
+ const checkModified = () => {
82
+ const modified = store.isModified();
83
+ setIsModified(modified);
84
+ };
85
+ checkModified();
86
+ const unsubscribe = store.subscribeGlobal(checkModified);
87
+ return unsubscribe;
88
+ }, [store]);
89
+ // 호환성을 위한 values 객체 (비권장) / Values object for compatibility (not recommended)
90
+ const [valuesSnapshot, setValuesSnapshot] = useState(() => store.getValues());
91
+ useEffect(() => {
92
+ const unsubscribe = store.subscribeGlobal(() => {
93
+ setValuesSnapshot(store.getValues());
94
+ });
95
+ return unsubscribe;
96
+ }, [store]);
97
+ const values = valuesSnapshot;
98
+ /**
99
+ * 통합 폼 변경 핸들러 / Unified form change handler
100
+ * MUI Select, TextField, DatePicker 등 모든 컴포넌트 지원
101
+ * Supports all components: MUI Select, TextField, DatePicker, etc.
102
+ */
103
+ const handleFormChange = useCallback((e) => {
104
+ const target = e.target;
105
+ if (!target || !target.name)
106
+ return;
107
+ const { name, type, value, checked } = target;
108
+ let newValue = value;
109
+ // DatePicker 처리 (Dayjs 객체) / DatePicker handling (Dayjs object)
110
+ if (value && typeof value === "object" && value.format) {
111
+ newValue = value.format("YYYY-MM-DD");
112
+ }
113
+ // 체크박스 처리 / Checkbox handling
114
+ else if (type === "checkbox") {
115
+ newValue = checked;
116
+ }
117
+ // 숫자 타입 처리 / Number type handling
118
+ else if (type === "number") {
119
+ newValue = Number(value);
120
+ }
121
+ // null 값 처리 / Null value handling
122
+ else if (value === null) {
123
+ newValue = undefined;
124
+ }
125
+ store.setValue(name, newValue);
126
+ }, [store]);
127
+ /**
128
+ * DatePicker 전용 변경 핸들러 / DatePicker-specific change handler
129
+ * 간편한 사용을 위한 커링 함수 / Curried function for convenient usage
130
+ */
131
+ const handleDatePickerChange = useCallback((fieldName) => {
132
+ return (value, _context) => {
133
+ let newValue = value;
134
+ // DatePicker 처리 (Dayjs 객체) / DatePicker handling (Dayjs object)
135
+ if (value && typeof value === "object" && value.format) {
136
+ newValue = value.format("YYYY-MM-DD");
137
+ }
138
+ else if (value === null) {
139
+ newValue = undefined;
140
+ }
141
+ store.setValue(fieldName, newValue);
142
+ };
143
+ }, [store]);
144
+ /**
145
+ * 개별 필드 값 설정 / Set individual field value
146
+ */
147
+ const setFormValue = useCallback((name, value) => {
148
+ let processedValue = value;
149
+ // DatePicker에서 오는 Dayjs 객체 처리 / Handle Dayjs object from DatePicker
150
+ if (value && typeof value === "object" && value.format) {
151
+ processedValue = value.format("YYYY-MM-DD");
152
+ }
153
+ else if (value === null) {
154
+ processedValue = undefined;
155
+ }
156
+ store.setValue(name, processedValue);
157
+ }, [store]);
158
+ /**
159
+ * 전체 폼 값 설정 / Set all form values
160
+ */
161
+ const setFormValues = useCallback((newValues) => {
162
+ store.setValues(newValues);
163
+ }, [store]);
164
+ /**
165
+ * 초기값 재설정 / Reset initial values
166
+ */
167
+ const setInitialFormValues = useCallback((newInitialValues) => {
168
+ store.setInitialValues(newInitialValues);
169
+ }, [store]);
170
+ /**
171
+ * 구독 없이 현재 값만 가져오기 / Get current value without subscription
172
+ */
173
+ const getFormValue = useCallback((fieldName) => {
174
+ return store.getValue(fieldName);
175
+ }, [store]);
176
+ /**
177
+ * 모든 폼 값 가져오기 / Get all form values
178
+ */
179
+ const getFormValues = useCallback(() => {
180
+ return store.getValues();
181
+ }, [store]);
182
+ /**
183
+ * 개별 필드 구독 Hook / Individual field subscription hook
184
+ * 해당 필드가 변경될 때만 컴포넌트가 리렌더링됩니다
185
+ * Component re-renders only when the specific field changes
186
+ */
187
+ const useFormValue = useCallback((fieldName) => {
188
+ return useFieldValue(store, fieldName);
189
+ }, [store]);
190
+ /**
191
+ * 폼 검증 / Form validation
192
+ */
193
+ const validateForm = useCallback(async (valuesToValidate) => {
194
+ if (!onValidate)
195
+ return true;
196
+ setIsValidating(true);
197
+ const currentValues = valuesToValidate || store.getValues();
198
+ try {
199
+ return await onValidate(currentValues);
200
+ }
201
+ catch (error) {
202
+ console.error("Validation error:", error);
203
+ return false;
204
+ }
205
+ finally {
206
+ setIsValidating(false);
207
+ }
208
+ }, [onValidate, store]);
209
+ /**
210
+ * 폼 초기화 / Reset form
211
+ */
212
+ const resetForm = useCallback(() => {
213
+ store.reset();
214
+ setIsSubmitting(false);
215
+ setIsValidating(false);
216
+ }, [store]);
217
+ /**
218
+ * 폼 제출 / Submit form
219
+ */
220
+ const submit = useCallback(async (e) => {
221
+ if (e)
222
+ e.preventDefault();
223
+ const currentValues = store.getValues();
224
+ if (!(await validateForm(currentValues))) {
225
+ return false;
226
+ }
227
+ setIsSubmitting(true);
228
+ try {
229
+ if (onSubmit) {
230
+ await onSubmit(currentValues);
231
+ }
232
+ if (onComplete) {
233
+ onComplete(currentValues);
234
+ }
235
+ return true;
236
+ }
237
+ catch (error) {
238
+ console.error("Form submission error:", error);
239
+ return false;
240
+ }
241
+ finally {
242
+ setIsSubmitting(false);
243
+ }
244
+ }, [onSubmit, onComplete, validateForm, store]);
245
+ return useMemo(() => ({
246
+ // 상태 / State
247
+ isSubmitting,
248
+ isValidating,
249
+ isModified,
250
+ // 값 가져오기 / Get values
251
+ useFormValue, // Hook - 구독 있음 (성능 최적화) / with subscription (performance optimized)
252
+ getFormValue, // 함수 - 구독 없음 (현재 값만) / function - no subscription (current value only)
253
+ getFormValues, // 함수 - 모든 값 / function - all values
254
+ // 값 설정 / Set values
255
+ setFormValue, // 개별 필드 설정 / set individual field
256
+ setFormValues, // 전체 값 설정 / set all values
257
+ setInitialFormValues, // 초기값 재설정 / reset initial values
258
+ // 이벤트 핸들러 / Event handlers
259
+ handleFormChange, // 폼 요소 onChange (MUI 완전 호환) / form element onChange (fully MUI compatible)
260
+ handleDatePickerChange, // DatePicker 전용 onChange / DatePicker-specific onChange
261
+ // 폼 액션 / Form actions
262
+ submit, // 폼 제출 / submit form
263
+ resetForm, // 폼 초기화 / reset form
264
+ validateForm, // 폼 검증 / validate form
265
+ // 호환성 / Compatibility
266
+ values, // 비권장: 전체 리렌더링 발생 / not recommended: causes full re-renders
267
+ // 고급 사용 / Advanced usage
268
+ _store: store, // 직접 store 접근용 / direct store access
269
+ }), [
270
+ isSubmitting,
271
+ isValidating,
272
+ isModified,
273
+ useFormValue,
274
+ getFormValue,
275
+ getFormValues,
276
+ setFormValue,
277
+ setFormValues,
278
+ setInitialFormValues,
279
+ handleFormChange,
280
+ handleDatePickerChange,
281
+ submit,
282
+ resetForm,
283
+ validateForm,
284
+ values,
285
+ ]);
286
+ }
287
+ //# sourceMappingURL=useForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useForm.js","sourceRoot":"","sources":["../../../hooks/useForm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAOhD,OAAc,EACV,SAAS,EACT,QAAQ,EACR,WAAW,EACX,MAAM,EACN,OAAO,GACV,MAAM,OAAO,CAAC;AAKf;;;;GAIG;AACH,SAAS,aAAa,CAAI,KAAsB,EAAE,S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CAAC;YACb,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;YAC/C,OAAO,KAAK,CAAC;QACjB,CAAC;gBAAS,CAAC;YACP,eAAe,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;IACL,CAAC,EACD,CAAC,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,CAAC,CAC9C,CAAC;IAEF,OAAO,OAAO,CACV,GAAG,EAAE,CAAC,CAAC;QACH,aAAa;QACb,YAAY;QACZ,YAAY;QACZ,UAAU;QAEV,sBAAsB;QACtB,YAAY,EAAE,oEAAoE;QAClF,YAAY,EAAE,uEAAuE;QACrF,aAAa,EAAE,oCAAoC;QAEnD,oBAAoB;QACpB,YAAY,EAAE,kCAAkC;QAChD,aAAa,EAAE,2BAA2B;QAC1C,oBAAoB,EAAE,iCAAiC;QAEvD,2BAA2B;QAC3B,gBAAgB,EAAE,2EAA2E;QAC7F,sBAAsB,EAAE,wDAAwD;QAEhF,sBAAsB;QACtB,MAAM,EAAE,qBAAqB;QAC7B,SAAS,EAAE,qBAAqB;QAChC,YAAY,EAAE,uBAAuB;QAErC,sBAAsB;QACtB,MAAM,EAAE,4DAA4D;QAEpE,yBAAyB;QACzB,MAAM,EAAE,KAAK,EAAE,qCAAqC;KACvD,CAAC,EACF;QACI,YAAY;QACZ,YAAY;QACZ,UAAU;QACV,YAAY;QACZ,YAAY;QACZ,aAAa;QACb,YAAY;QACZ,aAAa;QACb,oBAAoB;QACpB,gBAAgB;QAChB,sBAAsB;QACtB,MAAM;QACN,SAAS;QACT,YAAY;QACZ,MAAM;KACT,CACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * useGlobalForm.ts
3
+ *
4
+ * Forma - 글로벌 폼 상태 관리 훅 / Global form state management hook
5
+ * 여러 컴포넌트 간 폼 상태 공유를 위한 확장 훅
6
+ * Extended hook for sharing form state across multiple components
7
+ *
8
+ * @license MIT License
9
+ * @copyright 2025 KIM YOUNG JIN (Kim Young Jin)
10
+ * @author KIM YOUNG JIN (ehfuse@gmail.com)
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+ import { UseGlobalFormProps, UseGlobalFormReturn } from "../types/globalForm";
31
+ /**
32
+ * 글로벌 폼 상태 관리 훅 / Global form state management hook
33
+ *
34
+ * 여러 컴포넌트 간 폼 데이터를 공유하기 위한 훅입니다
35
+ * Hook for sharing form data across multiple components
36
+ *
37
+ * 데이터 공유에만 집중하며, 초기값 설정과 제출/검증 로직은 각 컴포넌트에서 직접 처리합니다
38
+ * Focuses only on data sharing; initial values and submission/validation logic handled by individual components
39
+ *
40
+ * @template T 폼 데이터의 타입 / Form data type
41
+ * @param props 글로벌 폼 설정 옵션 / Global form configuration options
42
+ * @returns 글로벌 폼 관리 API 객체 / Global form management API object
43
+ */
44
+ export declare function useGlobalForm<T extends Record<string, any>>({ formId, }: UseGlobalFormProps<T>): UseGlobalFormReturn<T>;
45
+ //# sourceMappingURL=useGlobalForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGlobalForm.d.ts","sourceRoot":"","sources":["../../../hooks/useGlobalForm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG9E;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EACzD,MAAM,GACT,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAiBhD"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * useGlobalForm.ts
3
+ *
4
+ * Forma - 글로벌 폼 상태 관리 훅 / Global form state management hook
5
+ * 여러 컴포넌트 간 폼 상태 공유를 위한 확장 훅
6
+ * Extended hook for sharing form state across multiple components
7
+ *
8
+ * @license MIT License
9
+ * @copyright 2025 KIM YOUNG JIN (Kim Young Jin)
10
+ * @author KIM YOUNG JIN (ehfuse@gmail.com)
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+ import { useContext } from "react";
31
+ import { useForm } from "./useForm";
32
+ import { GlobalFormContext } from "../contexts/GlobalFormContext";
33
+ /**
34
+ * 글로벌 폼 상태 관리 훅 / Global form state management hook
35
+ *
36
+ * 여러 컴포넌트 간 폼 데이터를 공유하기 위한 훅입니다
37
+ * Hook for sharing form data across multiple components
38
+ *
39
+ * 데이터 공유에만 집중하며, 초기값 설정과 제출/검증 로직은 각 컴포넌트에서 직접 처리합니다
40
+ * Focuses only on data sharing; initial values and submission/validation logic handled by individual components
41
+ *
42
+ * @template T 폼 데이터의 타입 / Form data type
43
+ * @param props 글로벌 폼 설정 옵션 / Global form configuration options
44
+ * @returns 글로벌 폼 관리 API 객체 / Global form management API object
45
+ */
46
+ export function useGlobalForm({ formId, }) {
47
+ const { getOrCreateStore } = useContext(GlobalFormContext);
48
+ // 글로벌 스토어 가져오기 또는 생성 / Get or create global store
49
+ const store = getOrCreateStore(formId);
50
+ // useForm에 외부 스토어 전달 (빈 초기값으로) / Pass external store to useForm (with empty initial values)
51
+ const form = useForm({
52
+ initialValues: {},
53
+ _externalStore: store,
54
+ });
55
+ return {
56
+ ...form,
57
+ formId, // 글로벌 폼 ID 추가 제공 / Provide additional global form ID
58
+ _store: store, // 글로벌 스토어 직접 접근용 / Direct access to global store
59
+ };
60
+ }
61
+ //# sourceMappingURL=useGlobalForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGlobalForm.js","sourceRoot":"","sources":["../../../hooks/useGlobalForm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAAgC,EACzD,MAAM,GACc;IACpB,MAAM,EAAE,gBAAgB,EAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAE3D,kDAAkD;IAClD,MAAM,KAAK,GAAG,gBAAgB,CAAI,MAAM,CAAC,CAAC;IAE1C,4FAA4F;IAC5F,MAAM,IAAI,GAAG,OAAO,CAAI;QACpB,aAAa,EAAE,EAAO;QACtB,cAAc,EAAE,KAAK;KACxB,CAAC,CAAC;IAEH,OAAO;QACH,GAAG,IAAI;QACP,MAAM,EAAE,qDAAqD;QAC7D,MAAM,EAAE,KAAK,EAAE,iDAAiD;KACzC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * useRegisterGlobalForm.ts
3
+ *
4
+ * Forma - 기존 useForm을 글로벌 폼으로 등록하는 훅 | Hook to register existing useForm as global form
5
+ * 기존에 만든 로컬 폼을 글로벌 상태로 공유할 수 있게 해주는 유틸리티
6
+ * Utility to enable sharing existing local forms as global state
7
+ *
8
+ * @license MIT License
9
+ * @copyright 2025 KIM YOUNG JIN (Kim Young Jin)
10
+ * @author KIM YOUNG JIN (ehfuse@gmail.com)
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+ import { UseFormReturn } from "../types/form";
31
+ /**
32
+ * 기존 useForm을 글로벌 폼으로 등록하는 훅 | Hook to register existing useForm as global form
33
+ *
34
+ * 이미 만들어진 로컬 폼을 글로벌 상태로 공유하고 싶을 때 사용합니다.
35
+ * Use this when you want to share an already created local form as global state.
36
+ *
37
+ * @template T 폼 데이터의 타입 | Form data type
38
+ * @param formId 글로벌 폼 식별자 | Global form identifier
39
+ * @param form 등록할 useForm 인스턴스 | useForm instance to register
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * function MyComponent() {
44
+ * const form = useForm({ initialValues: { name: '', email: '' } });
45
+ *
46
+ * // 로컬 폼을 글로벌로 등록
47
+ * useRegisterGlobalForm('my-form-id', form);
48
+ *
49
+ * // 이제 다른 컴포넌트에서 useGlobalForm({ formId: 'my-form-id' })로 접근 가능
50
+ * return <div>...</div>;
51
+ * }
52
+ * ```
53
+ */
54
+ export declare function useRegisterGlobalForm<T extends Record<string, any>>(formId: string, form: UseFormReturn<T>): void;
55
+ //# sourceMappingURL=useRegisterGlobalForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRegisterGlobalForm.d.ts","sourceRoot":"","sources":["../../../hooks/useRegisterGlobalForm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC/D,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GACvB,IAAI,CASN"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * useRegisterGlobalForm.ts
3
+ *
4
+ * Forma - 기존 useForm을 글로벌 폼으로 등록하는 훅 | Hook to register existing useForm as global form
5
+ * 기존에 만든 로컬 폼을 글로벌 상태로 공유할 수 있게 해주는 유틸리티
6
+ * Utility to enable sharing existing local forms as global state
7
+ *
8
+ * @license MIT License
9
+ * @copyright 2025 KIM YOUNG JIN (Kim Young Jin)
10
+ * @author KIM YOUNG JIN (ehfuse@gmail.com)
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+ import { useContext, useEffect } from "react";
31
+ import { GlobalFormContext } from "../contexts/GlobalFormContext";
32
+ /**
33
+ * 기존 useForm을 글로벌 폼으로 등록하는 훅 | Hook to register existing useForm as global form
34
+ *
35
+ * 이미 만들어진 로컬 폼을 글로벌 상태로 공유하고 싶을 때 사용합니다.
36
+ * Use this when you want to share an already created local form as global state.
37
+ *
38
+ * @template T 폼 데이터의 타입 | Form data type
39
+ * @param formId 글로벌 폼 식별자 | Global form identifier
40
+ * @param form 등록할 useForm 인스턴스 | useForm instance to register
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * function MyComponent() {
45
+ * const form = useForm({ initialValues: { name: '', email: '' } });
46
+ *
47
+ * // 로컬 폼을 글로벌로 등록
48
+ * useRegisterGlobalForm('my-form-id', form);
49
+ *
50
+ * // 이제 다른 컴포넌트에서 useGlobalForm({ formId: 'my-form-id' })로 접근 가능
51
+ * return <div>...</div>;
52
+ * }
53
+ * ```
54
+ */
55
+ export function useRegisterGlobalForm(formId, form) {
56
+ const { registerStore } = useContext(GlobalFormContext);
57
+ useEffect(() => {
58
+ // useForm의 내부 store를 글로벌에 등록 | Register useForm's internal store globally
59
+ if (form._store) {
60
+ registerStore(formId, form._store);
61
+ }
62
+ }, [formId, form._store, registerStore]);
63
+ }
64
+ //# sourceMappingURL=useRegisterGlobalForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRegisterGlobalForm.js","sourceRoot":"","sources":["../../../hooks/useRegisterGlobalForm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,qBAAqB,CACjC,MAAc,EACd,IAAsB;IAEtB,MAAM,EAAE,aAAa,EAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAExD,SAAS,CAAC,GAAG,EAAE;QACX,0EAA0E;QAC1E,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC;IACL,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * index.ts
3
+ *
4
+ * Forma - Advanced React form state management library
5
+ * Main entry point and API exports
6
+ *
7
+ * @license MIT License
8
+ * @copyright 2025 KIM YOUNG JIN (Kim Young Jin)
9
+ * @author KIM YOUNG JIN (ehfuse@gmail.com)
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in all
19
+ * copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ * SOFTWARE.
28
+ */
29
+ export { useForm } from "./hooks/useForm";
30
+ export { useGlobalForm } from "./hooks/useGlobalForm";
31
+ export { useRegisterGlobalForm } from "./hooks/useRegisterGlobalForm";
32
+ export { GlobalFormContext, GlobalFormProvider, } from "./contexts/GlobalFormContext";
33
+ export { FieldStore } from "./core/FieldStore";
34
+ export { getNestedValue, setNestedValue } from "./utils/dotNotation";
35
+ export type { UseFormProps, UseFormReturn, FormChangeEvent, DatePickerChangeHandler, } from "./types/form";
36
+ export type { UseGlobalFormProps, UseGlobalFormReturn, GlobalFormProviderProps, GlobalFormContextType, GlobalFormStoreMap, GlobalFormMetadata, GlobalFormEvent, GlobalFormEventListener, GlobalFormConfig, GlobalFormMiddleware, ExtendedGlobalFormProviderProps, } from "./types/globalForm";
37
+ /**
38
+ * Forma library version
39
+ */
40
+ export declare const FORMA_VERSION = "1.0.0";
41
+ /**
42
+ * Forma library metadata
43
+ */
44
+ export declare const FORMA_METADATA: {
45
+ readonly name: "Forma";
46
+ readonly version: "1.0.0";
47
+ readonly description: "Advanced React form state management library";
48
+ readonly author: "KIM YOUNG JIN (Kim Young Jin)";
49
+ readonly email: "ehfuse@gmail.com";
50
+ readonly license: "MIT";
51
+ readonly features: readonly ["Optimized re-rendering with individual field subscriptions", "Nested object handling with dot notation support", "Full compatibility with MUI components", "Global form state management", "Complete TypeScript support", "Leveraging latest React 19 features"];
52
+ };
53
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAGtE,OAAO,EACH,iBAAiB,EACjB,kBAAkB,GACrB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrE,YAAY,EACR,YAAY,EACZ,aAAa,EACb,eAAe,EACf,uBAAuB,GAC1B,MAAM,cAAc,CAAC;AAGtB,YAAY,EACR,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,oBAAoB,EACpB,+BAA+B,GAClC,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,eAAO,MAAM,aAAa,UAAU,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;CAejB,CAAC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * index.ts
3
+ *
4
+ * Forma - Advanced React form state management library
5
+ * Main entry point and API exports
6
+ *
7
+ * @license MIT License
8
+ * @copyright 2025 KIM YOUNG JIN (Kim Young Jin)
9
+ * @author KIM YOUNG JIN (ehfuse@gmail.com)
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in all
19
+ * copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ * SOFTWARE.
28
+ */
29
+ // ===== Core Hooks =====
30
+ export { useForm } from "./hooks/useForm";
31
+ export { useGlobalForm } from "./hooks/useGlobalForm";
32
+ export { useRegisterGlobalForm } from "./hooks/useRegisterGlobalForm";
33
+ // ===== Context & Providers =====
34
+ export { GlobalFormContext, GlobalFormProvider, } from "./contexts/GlobalFormContext";
35
+ // ===== Core Classes =====
36
+ export { FieldStore } from "./core/FieldStore";
37
+ // ===== Utility Functions =====
38
+ export { getNestedValue, setNestedValue } from "./utils/dotNotation";
39
+ /**
40
+ * Forma library version
41
+ */
42
+ export const FORMA_VERSION = "1.0.0";
43
+ /**
44
+ * Forma library metadata
45
+ */
46
+ export const FORMA_METADATA = {
47
+ name: "Forma",
48
+ version: FORMA_VERSION,
49
+ description: "Advanced React form state management library",
50
+ author: "KIM YOUNG JIN (Kim Young Jin)",
51
+ email: "ehfuse@gmail.com",
52
+ license: "MIT",
53
+ features: [
54
+ "Optimized re-rendering with individual field subscriptions",
55
+ "Nested object handling with dot notation support",
56
+ "Full compatibility with MUI components",
57
+ "Global form state management",
58
+ "Complete TypeScript support",
59
+ "Leveraging latest React 19 features",
60
+ ],
61
+ };
62
+ //# sourceMappingURL=index.js.map