@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,100 @@
1
+ /**
2
+ * dotNotation.ts
3
+ *
4
+ * Forma - Dot notation 관련 유틸리티 함수들 | Dot notation utility functions
5
+ * 중첩 객체의 값을 안전하게 가져오고 설정하는 기능 제공 | Provides safe getting and setting of nested object values
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
+ /**
30
+ * dot notation으로 중첩 객체의 값을 가져오는 함수 | Function to get nested object values using dot notation
31
+ * @param obj 대상 객체 | Target object
32
+ * @param path dot notation 경로 (예: "user.profile.name") | Dot notation path (e.g., "user.profile.name")
33
+ * @returns 해당 경로의 값 또는 undefined | Value at the path or undefined
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const data = { user: { profile: { name: 'John' } } };
38
+ * const name = getNestedValue(data, 'user.profile.name'); // 'John'
39
+ * ```
40
+ */
41
+ export function getNestedValue(obj, path) {
42
+ if (!path.includes(".")) {
43
+ return obj[path];
44
+ }
45
+ const keys = path.split(".");
46
+ let current = obj;
47
+ for (const key of keys) {
48
+ if (current === null || current === undefined) {
49
+ return undefined;
50
+ }
51
+ current = current[key];
52
+ }
53
+ return current;
54
+ }
55
+ /**
56
+ * dot notation으로 중첩 객체의 값을 설정하는 함수 | Function to set nested object values using dot notation
57
+ * 불변성을 유지하면서 새로운 객체를 반환 | Returns a new object while maintaining immutability
58
+ * @param obj 대상 객체 | Target object
59
+ * @param path dot notation 경로 | Dot notation path
60
+ * @param value 설정할 값 | Value to set
61
+ * @returns 새로운 객체 | New object
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * const data = { user: { profile: { name: 'John' } } };
66
+ * const newData = setNestedValue(data, 'user.profile.name', 'Jane');
67
+ * // { user: { profile: { name: 'Jane' } } }
68
+ * ```
69
+ */
70
+ export function setNestedValue(obj, path, value) {
71
+ if (!path.includes(".")) {
72
+ const result = { ...obj, [path]: value };
73
+ return result;
74
+ }
75
+ const keys = path.split(".");
76
+ const result = Array.isArray(obj) ? [...obj] : { ...obj }; // 배열 타입 보존 | Preserve array type
77
+ let current = result;
78
+ // 마지막 키 전까지 객체 생성/복사 | Create/copy objects until the last key
79
+ for (let i = 0; i < keys.length - 1; i++) {
80
+ const key = keys[i];
81
+ if (current[key] === null ||
82
+ current[key] === undefined ||
83
+ typeof current[key] !== "object") {
84
+ current[key] = {};
85
+ console.log(`📝 새 객체 생성: ${key} | Creating new object: ${key}`);
86
+ }
87
+ else {
88
+ // 배열 타입 보존하면서 복사 | Copy while preserving array type
89
+ current[key] = Array.isArray(current[key])
90
+ ? [...current[key]]
91
+ : { ...current[key] };
92
+ }
93
+ current = current[key];
94
+ }
95
+ // 마지막 키에 값 설정 | Set value to the last key
96
+ const lastKey = keys[keys.length - 1];
97
+ current[lastKey] = value;
98
+ return result;
99
+ }
100
+ //# sourceMappingURL=dotNotation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dotNotation.js","sourceRoot":"","sources":["../../../utils/dotNotation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,GAAQ,EAAE,IAAY;IACjD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,OAAO,GAAG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G,2BAA2B,GAAG,EAAE,CACrD,CAAC;QACN,CAAC;aAAM,CAAC;YACJ,oDAAoD;YACpD,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBACtC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;gBACnB,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC9B,CAAC;QACD,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,0CAA0C;IAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACtC,OAAO,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;IAEzB,OAAO,MAAM,CAAC;AAClB,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * utils/index.ts
3
+ *
4
+ * @license MIT License
5
+ * @copyright 2025 KIM YOUNG JIN (Kim Young Jin)
6
+ * @author KIM YOUNG JIN (ehfuse@gmail.com)
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ */
26
+ export { getNestedValue, setNestedValue } from "./dotNotation";
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * utils/index.ts
3
+ *
4
+ * @license MIT License
5
+ * @copyright 2025 KIM YOUNG JIN (Kim Young Jin)
6
+ * @author KIM YOUNG JIN (ehfuse@gmail.com)
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ */
26
+ export { getNestedValue, setNestedValue } from "./dotNotation";
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,67 @@
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 { FormChangeEvent, DatePickerChangeHandler, UseFormProps } from "../types/form";
32
+ import React from "react";
33
+ /**
34
+ * Forma 핵심 폼 관리 훅 / Forma core form management hook
35
+ *
36
+ * 고급 폼 상태 관리와 성능 최적화를 제공합니다
37
+ * Provides advanced form state management and performance optimization
38
+ *
39
+ * Features:
40
+ * - 개별 필드 구독으로 선택적 리렌더링 / Selective re-rendering with individual field subscriptions
41
+ * - Dot notation 지원으로 중첩 객체 처리 / Nested object handling with dot notation support
42
+ * - MUI 컴포넌트 완전 호환 / Full MUI component compatibility
43
+ * - TypeScript 완전 지원 / Complete TypeScript support
44
+ *
45
+ * @template T 폼 데이터의 타입 / Form data type
46
+ * @param props 폼 설정 옵션 / Form configuration options
47
+ * @returns 폼 관리 API 객체 / Form management API object
48
+ */
49
+ export declare function useForm<T extends Record<string, any>>({ initialValues, onSubmit, onValidate, onComplete, _externalStore, }: UseFormProps<T>): {
50
+ isSubmitting: boolean;
51
+ isValidating: boolean;
52
+ isModified: boolean;
53
+ useFormValue: (fieldName: string) => unknown;
54
+ getFormValue: (fieldName: string) => any;
55
+ getFormValues: () => T;
56
+ setFormValue: (name: string, value: any) => void;
57
+ setFormValues: (newValues: Partial<T>) => void;
58
+ setInitialFormValues: (newInitialValues: T) => void;
59
+ handleFormChange: (e: FormChangeEvent) => void;
60
+ handleDatePickerChange: DatePickerChangeHandler;
61
+ submit: (e?: React.FormEvent) => Promise<boolean>;
62
+ resetForm: () => void;
63
+ validateForm: (valuesToValidate?: T) => Promise<boolean>;
64
+ values: T;
65
+ _store: FieldStore<T>;
66
+ };
67
+ //# sourceMappingURL=useForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../hooks/useForm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EACH,eAAe,EACf,uBAAuB,EACvB,YAAY,EACf,MAAM,eAAe,CAAC;AAEvB,OAAO,KAMN,MAAM,OAAO,CAAC;AA0Bf;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EACnD,aAAa,EACb,QAAQ,EACR,UAAU,EACV,UAAU,EACV,cAAc,GACjB,EAAE,YAAY,CAAC,CAAC,CAAC;;;;8BAgKE,MAAM;8BAnBN,MAAM,KAAG,GAAG;yBASU,CAAC;yBAhD5B,MAAM,SAAS,GAAG;+BAmBb,OAAO,CAAC,CAAC,CAAC;6CAUH,CAAC;0BApFhB,eAAe;;iBAyJR,KAAK,CAAC,SAAS,KAAG,OAAO,CAAC,OAAO,CAAC;;sCA9BnB,CAAC;;;EA8GlC"}
@@ -0,0 +1,290 @@
1
+ "use strict";
2
+ /**
3
+ * useForm.ts
4
+ *
5
+ * Forma - 고급 폼 상태 관리 훅 / Advanced form state management hook
6
+ * 개별 필드 구독과 성능 최적화를 제공하는 핵심 훅
7
+ * Core hook providing individual field subscriptions and performance optimization
8
+ *
9
+ * @license MIT License
10
+ * @copyright 2025 KIM YOUNG JIN (Kim Young Jin)
11
+ * @author KIM YOUNG JIN (ehfuse@gmail.com)
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the Software is
18
+ * furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included in all
21
+ * copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ * SOFTWARE.
30
+ */
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.useForm = useForm;
33
+ const FieldStore_1 = require("../core/FieldStore");
34
+ const react_1 = require("react");
35
+ /**
36
+ * 개별 필드 구독 / Individual field subscription
37
+ * 특정 필드만 구독하여 해당 필드가 변경될 때만 리렌더링
38
+ * Subscribe to specific field only, re-render only when that field changes
39
+ */
40
+ function useFieldValue(store, fieldName) {
41
+ const [value, setValue] = (0, react_1.useState)(() => store.getValue(fieldName));
42
+ (0, react_1.useEffect)(() => {
43
+ // 구독 설정 / Setup subscription
44
+ const unsubscribe = store.subscribe(fieldName, () => {
45
+ const newValue = store.getValue(fieldName);
46
+ setValue(newValue);
47
+ });
48
+ return unsubscribe;
49
+ }, [fieldName]); // store 의존성 제거로 불필요한 재구독 방지 / Remove store dependency to prevent unnecessary re-subscriptions
50
+ return value;
51
+ }
52
+ /**
53
+ * Forma 핵심 폼 관리 훅 / Forma core form management hook
54
+ *
55
+ * 고급 폼 상태 관리와 성능 최적화를 제공합니다
56
+ * Provides advanced form state management and performance optimization
57
+ *
58
+ * Features:
59
+ * - 개별 필드 구독으로 선택적 리렌더링 / Selective re-rendering with individual field subscriptions
60
+ * - Dot notation 지원으로 중첩 객체 처리 / Nested object handling with dot notation support
61
+ * - MUI 컴포넌트 완전 호환 / Full MUI component compatibility
62
+ * - TypeScript 완전 지원 / Complete TypeScript support
63
+ *
64
+ * @template T 폼 데이터의 타입 / Form data type
65
+ * @param props 폼 설정 옵션 / Form configuration options
66
+ * @returns 폼 관리 API 객체 / Form management API object
67
+ */
68
+ function useForm({ initialValues, onSubmit, onValidate, onComplete, _externalStore, }) {
69
+ // Store 인스턴스 (외부 스토어가 있으면 사용, 없으면 로컬 생성)
70
+ // Store instance (use external store if provided, otherwise create local one)
71
+ const storeRef = (0, react_1.useRef)(null);
72
+ if (_externalStore) {
73
+ storeRef.current = _externalStore;
74
+ }
75
+ else if (!storeRef.current) {
76
+ storeRef.current = new FieldStore_1.FieldStore(initialValues);
77
+ }
78
+ const store = storeRef.current;
79
+ const [isSubmitting, setIsSubmitting] = (0, react_1.useState)(false);
80
+ const [isValidating, setIsValidating] = (0, react_1.useState)(false);
81
+ const [isModified, setIsModified] = (0, react_1.useState)(false);
82
+ // 전역 상태 구독 (isModified 추적) / Global state subscription (isModified tracking)
83
+ (0, react_1.useEffect)(() => {
84
+ const checkModified = () => {
85
+ const modified = store.isModified();
86
+ setIsModified(modified);
87
+ };
88
+ checkModified();
89
+ const unsubscribe = store.subscribeGlobal(checkModified);
90
+ return unsubscribe;
91
+ }, [store]);
92
+ // 호환성을 위한 values 객체 (비권장) / Values object for compatibility (not recommended)
93
+ const [valuesSnapshot, setValuesSnapshot] = (0, react_1.useState)(() => store.getValues());
94
+ (0, react_1.useEffect)(() => {
95
+ const unsubscribe = store.subscribeGlobal(() => {
96
+ setValuesSnapshot(store.getValues());
97
+ });
98
+ return unsubscribe;
99
+ }, [store]);
100
+ const values = valuesSnapshot;
101
+ /**
102
+ * 통합 폼 변경 핸들러 / Unified form change handler
103
+ * MUI Select, TextField, DatePicker 등 모든 컴포넌트 지원
104
+ * Supports all components: MUI Select, TextField, DatePicker, etc.
105
+ */
106
+ const handleFormChange = (0, react_1.useCallback)((e) => {
107
+ const target = e.target;
108
+ if (!target || !target.name)
109
+ return;
110
+ const { name, type, value, checked } = target;
111
+ let newValue = value;
112
+ // DatePicker 처리 (Dayjs 객체) / DatePicker handling (Dayjs object)
113
+ if (value && typeof value === "object" && value.format) {
114
+ newValue = value.format("YYYY-MM-DD");
115
+ }
116
+ // 체크박스 처리 / Checkbox handling
117
+ else if (type === "checkbox") {
118
+ newValue = checked;
119
+ }
120
+ // 숫자 타입 처리 / Number type handling
121
+ else if (type === "number") {
122
+ newValue = Number(value);
123
+ }
124
+ // null 값 처리 / Null value handling
125
+ else if (value === null) {
126
+ newValue = undefined;
127
+ }
128
+ store.setValue(name, newValue);
129
+ }, [store]);
130
+ /**
131
+ * DatePicker 전용 변경 핸들러 / DatePicker-specific change handler
132
+ * 간편한 사용을 위한 커링 함수 / Curried function for convenient usage
133
+ */
134
+ const handleDatePickerChange = (0, react_1.useCallback)((fieldName) => {
135
+ return (value, _context) => {
136
+ let newValue = value;
137
+ // DatePicker 처리 (Dayjs 객체) / DatePicker handling (Dayjs object)
138
+ if (value && typeof value === "object" && value.format) {
139
+ newValue = value.format("YYYY-MM-DD");
140
+ }
141
+ else if (value === null) {
142
+ newValue = undefined;
143
+ }
144
+ store.setValue(fieldName, newValue);
145
+ };
146
+ }, [store]);
147
+ /**
148
+ * 개별 필드 값 설정 / Set individual field value
149
+ */
150
+ const setFormValue = (0, react_1.useCallback)((name, value) => {
151
+ let processedValue = value;
152
+ // DatePicker에서 오는 Dayjs 객체 처리 / Handle Dayjs object from DatePicker
153
+ if (value && typeof value === "object" && value.format) {
154
+ processedValue = value.format("YYYY-MM-DD");
155
+ }
156
+ else if (value === null) {
157
+ processedValue = undefined;
158
+ }
159
+ store.setValue(name, processedValue);
160
+ }, [store]);
161
+ /**
162
+ * 전체 폼 값 설정 / Set all form values
163
+ */
164
+ const setFormValues = (0, react_1.useCallback)((newValues) => {
165
+ store.setValues(newValues);
166
+ }, [store]);
167
+ /**
168
+ * 초기값 재설정 / Reset initial values
169
+ */
170
+ const setInitialFormValues = (0, react_1.useCallback)((newInitialValues) => {
171
+ store.setInitialValues(newInitialValues);
172
+ }, [store]);
173
+ /**
174
+ * 구독 없이 현재 값만 가져오기 / Get current value without subscription
175
+ */
176
+ const getFormValue = (0, react_1.useCallback)((fieldName) => {
177
+ return store.getValue(fieldName);
178
+ }, [store]);
179
+ /**
180
+ * 모든 폼 값 가져오기 / Get all form values
181
+ */
182
+ const getFormValues = (0, react_1.useCallback)(() => {
183
+ return store.getValues();
184
+ }, [store]);
185
+ /**
186
+ * 개별 필드 구독 Hook / Individual field subscription hook
187
+ * 해당 필드가 변경될 때만 컴포넌트가 리렌더링됩니다
188
+ * Component re-renders only when the specific field changes
189
+ */
190
+ const useFormValue = (0, react_1.useCallback)((fieldName) => {
191
+ return useFieldValue(store, fieldName);
192
+ }, [store]);
193
+ /**
194
+ * 폼 검증 / Form validation
195
+ */
196
+ const validateForm = (0, react_1.useCallback)(async (valuesToValidate) => {
197
+ if (!onValidate)
198
+ return true;
199
+ setIsValidating(true);
200
+ const currentValues = valuesToValidate || store.getValues();
201
+ try {
202
+ return await onValidate(currentValues);
203
+ }
204
+ catch (error) {
205
+ console.error("Validation error:", error);
206
+ return false;
207
+ }
208
+ finally {
209
+ setIsValidating(false);
210
+ }
211
+ }, [onValidate, store]);
212
+ /**
213
+ * 폼 초기화 / Reset form
214
+ */
215
+ const resetForm = (0, react_1.useCallback)(() => {
216
+ store.reset();
217
+ setIsSubmitting(false);
218
+ setIsValidating(false);
219
+ }, [store]);
220
+ /**
221
+ * 폼 제출 / Submit form
222
+ */
223
+ const submit = (0, react_1.useCallback)(async (e) => {
224
+ if (e)
225
+ e.preventDefault();
226
+ const currentValues = store.getValues();
227
+ if (!(await validateForm(currentValues))) {
228
+ return false;
229
+ }
230
+ setIsSubmitting(true);
231
+ try {
232
+ if (onSubmit) {
233
+ await onSubmit(currentValues);
234
+ }
235
+ if (onComplete) {
236
+ onComplete(currentValues);
237
+ }
238
+ return true;
239
+ }
240
+ catch (error) {
241
+ console.error("Form submission error:", error);
242
+ return false;
243
+ }
244
+ finally {
245
+ setIsSubmitting(false);
246
+ }
247
+ }, [onSubmit, onComplete, validateForm, store]);
248
+ return (0, react_1.useMemo)(() => ({
249
+ // 상태 / State
250
+ isSubmitting,
251
+ isValidating,
252
+ isModified,
253
+ // 값 가져오기 / Get values
254
+ useFormValue, // Hook - 구독 있음 (성능 최적화) / with subscription (performance optimized)
255
+ getFormValue, // 함수 - 구독 없음 (현재 값만) / function - no subscription (current value only)
256
+ getFormValues, // 함수 - 모든 값 / function - all values
257
+ // 값 설정 / Set values
258
+ setFormValue, // 개별 필드 설정 / set individual field
259
+ setFormValues, // 전체 값 설정 / set all values
260
+ setInitialFormValues, // 초기값 재설정 / reset initial values
261
+ // 이벤트 핸들러 / Event handlers
262
+ handleFormChange, // 폼 요소 onChange (MUI 완전 호환) / form element onChange (fully MUI compatible)
263
+ handleDatePickerChange, // DatePicker 전용 onChange / DatePicker-specific onChange
264
+ // 폼 액션 / Form actions
265
+ submit, // 폼 제출 / submit form
266
+ resetForm, // 폼 초기화 / reset form
267
+ validateForm, // 폼 검증 / validate form
268
+ // 호환성 / Compatibility
269
+ values, // 비권장: 전체 리렌더링 발생 / not recommended: causes full re-renders
270
+ // 고급 사용 / Advanced usage
271
+ _store: store, // 직접 store 접근용 / direct store access
272
+ }), [
273
+ isSubmitting,
274
+ isValidating,
275
+ isModified,
276
+ useFormValue,
277
+ getFormValue,
278
+ getFormValues,
279
+ setFormValue,
280
+ setFormValues,
281
+ setInitialFormValues,
282
+ handleFormChange,
283
+ handleDatePickerChange,
284
+ submit,
285
+ resetForm,
286
+ validateForm,
287
+ values,
288
+ ]);
289
+ }
290
+ //# sourceMappingURL=useForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useForm.js","sourceRoot":"","sources":["../../hooks/useForm.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;AAyDH,0BA8RC;AArVD,mDAAgD;AAOhD,iCAMe;AAKf;;;;GAIG;AACH,SAAS,aAAa,CAAI,KAAsB,EAAE,SAAiB;IAC/D,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ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AC9B,CAAC;YAED,OAAO,IAAI,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,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,IAAA,eAAO,EACV,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,64 @@
1
+ "use strict";
2
+ /**
3
+ * useGlobalForm.ts
4
+ *
5
+ * Forma - 글로벌 폼 상태 관리 훅 / Global form state management hook
6
+ * 여러 컴포넌트 간 폼 상태 공유를 위한 확장 훅
7
+ * Extended hook for sharing form state across multiple components
8
+ *
9
+ * @license MIT License
10
+ * @copyright 2025 KIM YOUNG JIN (Kim Young Jin)
11
+ * @author KIM YOUNG JIN (ehfuse@gmail.com)
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the Software is
18
+ * furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included in all
21
+ * copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ * SOFTWARE.
30
+ */
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.useGlobalForm = useGlobalForm;
33
+ const react_1 = require("react");
34
+ const useForm_1 = require("./useForm");
35
+ const GlobalFormContext_1 = require("../contexts/GlobalFormContext");
36
+ /**
37
+ * 글로벌 폼 상태 관리 훅 / Global form state management hook
38
+ *
39
+ * 여러 컴포넌트 간 폼 데이터를 공유하기 위한 훅입니다
40
+ * Hook for sharing form data across multiple components
41
+ *
42
+ * 데이터 공유에만 집중하며, 초기값 설정과 제출/검증 로직은 각 컴포넌트에서 직접 처리합니다
43
+ * Focuses only on data sharing; initial values and submission/validation logic handled by individual components
44
+ *
45
+ * @template T 폼 데이터의 타입 / Form data type
46
+ * @param props 글로벌 폼 설정 옵션 / Global form configuration options
47
+ * @returns 글로벌 폼 관리 API 객체 / Global form management API object
48
+ */
49
+ function useGlobalForm({ formId, }) {
50
+ const { getOrCreateStore } = (0, react_1.useContext)(GlobalFormContext_1.GlobalFormContext);
51
+ // 글로벌 스토어 가져오기 또는 생성 / Get or create global store
52
+ const store = getOrCreateStore(formId);
53
+ // useForm에 외부 스토어 전달 (빈 초기값으로) / Pass external store to useForm (with empty initial values)
54
+ const form = (0, useForm_1.useForm)({
55
+ initialValues: {},
56
+ _externalStore: store,
57
+ });
58
+ return {
59
+ ...form,
60
+ formId, // 글로벌 폼 ID 추가 제공 / Provide additional global form ID
61
+ _store: store, // 글로벌 스토어 직접 접근용 / Direct access to global store
62
+ };
63
+ }
64
+ //# sourceMappingURL=useGlobalForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGlobalForm.js","sourceRoot":"","sources":["../../hooks/useGlobalForm.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;AAoBH,sCAmBC;AArCD,iCAAmC;AACnC,uCAAoC;AAEpC,qEAAkE;AAElE;;;;;;;;;;;;GAYG;AACH,SAAgB,aAAa,CAAgC,EACzD,MAAM,GACc;IACpB,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAA,kBAAU,EAAC,qCAAiB,CAAC,CAAC;IAE3D,kDAAkD;IAClD,MAAM,KAAK,GAAG,gBAAgB,CAAI,MAAM,CAAC,CAAC;IAE1C,4FAA4F;IAC5F,MAAM,IAAI,GAAG,IAAA,iBAAO,EAAI;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"}