@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
package/LICENSE ADDED
@@ -0,0 +1,42 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 KIM YOUNG JIN (ehfuse@gmail.com)
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.
22
+
23
+ ---
24
+
25
+ MIT 라이선스
26
+
27
+ Copyright (c) 2025 김영진 (ehfuse@gmail.com)
28
+
29
+ 이 소프트웨어와 관련 문서 파일(이하 "소프트웨어")의 사본을 얻는 모든 사람에게
30
+ 무료로 허가를 부여합니다. 이 허가에는 소프트웨어를 제한 없이 다루는 권리가
31
+ 포함되며, 여기에는 사용, 복사, 수정, 병합, 게시, 배포, 서브라이선스 및/또는
32
+ 소프트웨어 사본의 판매 권리와 소프트웨어가 제공된 사람들에게 그렇게 할 수 있는
33
+ 권한을 부여하는 권리가 포함됩니다. 단, 다음 조건을 따라야 합니다:
34
+
35
+ 위의 저작권 고지와 이 허가 고지는 소프트웨어의 모든 사본 또는 상당 부분에
36
+ 포함되어야 합니다.
37
+
38
+ 소프트웨어는 "있는 그대로" 제공되며, 상품성, 특정 목적에의 적합성 및
39
+ 비침해에 대한 보증을 포함하되 이에 국한되지 않는 명시적 또는 묵시적 보증 없이
40
+ 제공됩니다. 어떠한 경우에도 작성자 또는 저작권 보유자는 계약, 불법 행위 또는
41
+ 기타 행위에서 발생하거나, 소프트웨어나 소프트웨어의 사용 또는 기타 거래와
42
+ 관련하여 발생하는 청구, 손해 또는 기타 책임에 대해 책임지지 않습니다.
package/README.md ADDED
@@ -0,0 +1,180 @@
1
+ <!-- slide -->
2
+
3
+ # Forma
4
+
5
+ **고급 React 폼 상태 관리 라이브러리** | \*\*Advanced R## 📚 문서 | Documentation
6
+
7
+ ### 한국어 | Korean
8
+
9
+ - 🚀 **[시작 가이드](./docs/getting-started-ko.md)** - 단계별 튜토리얼과 예제
10
+ - 📖 **[완전한 문서](./docs/README-ko.md)** - API 레퍼런스, 사용 사례, 고급 기능
11
+ - 📋 **[API 레퍼런스](./docs/API-ko.md)** - 모든 메서드, 타입, 마이그레이션 가이드
12
+ - ⚡ **[성능 최적화 가이드](./docs/best-practices-ko.md)** - 최고 성능을 위한 모범 사례
13
+ - 🏠 **[GitHub](https://github.com/ehfuse/forma)**
14
+
15
+ ### English
16
+
17
+ - 🚀 **[Getting Started Guide](./docs/getting-started-en.md)** - Step-by-step tutorial and examples
18
+ - 📖 **[Complete Documentation](./docs/README-en.md)** - API reference, use cases, advanced features
19
+ - 📋 **[API Reference](./docs/API-en.md)** - All methods, types, migration guide
20
+ - ⚡ **[Performance Optimization Guide](./docs/best-practices-en.md)** - Best practices for optimal performance
21
+ - 🏠 **[GitHub](https://github.com/ehfuse/forma)**
22
+
23
+ Forma는 React 애플리케이션에서 폼 상태를 효율적으로 관리하기 위한 고성능 라이브러리입니다. 개별 필드 구독을 통한 선택적 리렌더링과 글로벌 폼 상태 공유 기능을 제공합니다.
24
+
25
+ _Forma is a high-performance library for efficiently managing form state in React applications. It provides selective re-rendering through individual field subscriptions and global form state sharing capabilities._
26
+
27
+ ## 🚀 주요 특징 | Key Features
28
+
29
+ - ✅ **개별 필드 구독** | **Individual Field Subscription**: 필드별 선택적 리렌더링으로 최적화된 성능
30
+ - ✅ **Dot Notation 최적화** | **Dot Notation Optimization**: `user.profile.name` 형태의 중첩 객체 접근
31
+ - ✅ **MUI 완전 호환** | **Full MUI Compatibility**: Material-UI 컴포넌트와 완벽한 통합
32
+ - ✅ **글로벌 폼 상태** | **Global Form State**: 여러 컴포넌트 간 폼 상태 공유
33
+ - ✅ **폼 등록 시스템** | **Form Registration System**: 기존 폼을 글로벌로 등록 가능
34
+ - ✅ **TypeScript 완전 지원** | **Full TypeScript Support**: 강력한 타입 안전성
35
+ - ✅ **React 19 최적화** | **React 19 Optimized**: 최신 React 기능 활용
36
+
37
+ ## 📦 설치 | Installation
38
+
39
+ ```bash
40
+ npm install @ehfuse/forma
41
+ ```
42
+
43
+ ```bash
44
+ yarn add @ehfuse/forma
45
+ ```
46
+
47
+ ## 🎯 빠른 시작 | Quick Start
48
+
49
+ ```tsx
50
+ import { useForm } from "@ehfuse/forma";
51
+
52
+ function MyForm() {
53
+ const form = useForm({
54
+ initialValues: { name: "", email: "" },
55
+ onSubmit: async (values) => {
56
+ console.log("제출 | Submit:", values);
57
+ },
58
+ });
59
+
60
+ return (
61
+ <form onSubmit={form.submit}>
62
+ <input
63
+ name="name"
64
+ value={form.useFormValue("name")}
65
+ onChange={form.handleFormChange}
66
+ />
67
+ <input
68
+ name="email"
69
+ value={form.useFormValue("email")}
70
+ onChange={form.handleFormChange}
71
+ />
72
+ <button type="submit">제출 | Submit</button>
73
+ </form>
74
+ );
75
+ }
76
+ ```
77
+
78
+ ## � 문서 | Documentation
79
+
80
+ ### 한국어 | Korean
81
+
82
+ - 📖 **[완전한 문서](./docs/README-ko.md)** - API 레퍼런스, 사용 사례, 고급 기능
83
+ - 🌐 **[useGlobalForm 사용법](./docs/useGlobalForm-guide-ko.md)** - 글로벌 폼 상태 관리 가이드
84
+ - ⚡ **[성능 최적화 가이드](./docs/best-practices-ko.md)** - 최고 성능을 위한 모범 사례
85
+
86
+ ### English
87
+
88
+ - 📖 **[Complete Documentation](./docs/README-en.md)** - API reference, use cases, advanced features
89
+ - 🌐 **[useGlobalForm Usage Guide](./docs/useGlobalForm-guide-en.md)** - Global form state management guide
90
+ - ⚡ **[Performance Optimization Guide](./docs/best-practices-en.md)** - Best practices for optimal performance
91
+
92
+ ## 🎯 When to choose Forma?
93
+
94
+ 언제 Forma를 선택해야 할까요?
95
+
96
+ Forma is **specialized for form state management** and shines in specific scenarios. Here's when Forma is the perfect choice for your project.
97
+
98
+ Forma는 **폼 상태 관리에 특화**된 라이브러리로 특정 시나리오에서 빛을 발합니다. 다음은 Forma가 프로젝트에 완벽한 선택이 되는 경우입니다.
99
+
100
+ ### ✨ Perfect for these use cases:
101
+
102
+ 이런 경우에 완벽합니다:
103
+
104
+ **🎨 MUI (Material-UI) Projects**
105
+ **MUI (Material-UI) 프로젝트**
106
+
107
+ - Seamless integration with MUI components
108
+ MUI 컴포넌트와 완벽한 통합
109
+ - No additional wrapper components needed
110
+ 추가 래퍼 컴포넌트 불필요
111
+ - Built-in support for MUI's controlled component patterns
112
+ MUI의 제어 컴포넌트 패턴 내장 지원
113
+
114
+ **⚡ Performance-Critical Forms**
115
+ **성능이 중요한 폼**
116
+
117
+ - Large forms with many fields (50+ inputs)
118
+ 많은 필드가 있는 대규모 폼 (50개 이상 입력)
119
+ - Real-time data visualization forms
120
+ 실시간 데이터 시각화 폼
121
+ - Forms that update frequently during user interaction
122
+ 사용자 상호작용 중 자주 업데이트되는 폼
123
+
124
+ **🔄 Multi-Step & Global Forms**
125
+ **멀티 스텝 & 글로벌 폼**
126
+
127
+ - Wizard-style multi-step forms
128
+ 마법사 스타일의 멀티 스텝 폼
129
+ - Forms shared across multiple components
130
+ 여러 컴포넌트에서 공유되는 폼
131
+ - Registration flows with data persistence
132
+ 데이터 지속성이 있는 등록 플로우
133
+
134
+ **🏗️ Complex Nested Data**
135
+ **복잡한 중첩 데이터**
136
+
137
+ - User profiles with nested address/contact info
138
+ 중첩된 주소/연락처 정보가 있는 사용자 프로필
139
+ - Product configurations with multiple layers
140
+ 다층 구조의 제품 구성
141
+ - Settings panels with grouped options
142
+ 그룹화된 옵션이 있는 설정 패널
143
+
144
+ **📊 Dynamic Form Generation**
145
+ **동적 폼 생성**
146
+
147
+ - Forms generated from API schemas
148
+ API 스키마에서 생성되는 폼
149
+ - Conditional field rendering
150
+ 조건부 필드 렌더링
151
+ - Dynamic validation rules
152
+ 동적 검증 규칙
153
+
154
+ ## 🎯 핵심 성능 원칙 | Core Performance Principles
155
+
156
+ ```tsx
157
+ // ✅ 효율적 | Efficient: 개별 필드 구독 | Individual field subscription
158
+ const userName = form.useFormValue("user.name");
159
+ const userEmail = form.useFormValue("user.email");
160
+
161
+ // user.name 변경 시 → userName 필드만 리렌더링 | Only userName field re-renders
162
+ ```
163
+
164
+ **[성능 최적화 상세 가이드 보기 | View Detailed Performance Guide](./docs/best-practices-ko.md)**
165
+
166
+ ## 🌐 링크 | Links
167
+
168
+ - **📦 NPM**: [https://www.npmjs.com/package/@ehfuse/forma](https://www.npmjs.com/package/@ehfuse/forma)
169
+ - **🐙 GitHub**: [https://github.com/ehfuse/forma](https://github.com/ehfuse/forma)
170
+ - **📄 라이선스 | License**: [MIT](./LICENSE)
171
+
172
+ ## 📞 연락처 | Contact
173
+
174
+ - **개발자 | Developer**: 김영진 (KIM YOUNG JIN)
175
+ - **이메일 | Email**: ehfuse@gmail.com
176
+ - **GitHub**: [@ehfuse](https://github.com/ehfuse)
177
+
178
+ ---
179
+
180
+ Copyright (c) 2025 김영진 (KIM YOUNG JIN) - MIT License
@@ -0,0 +1,66 @@
1
+ /**
2
+ * GlobalFormContext.tsx
3
+ *
4
+ * Forma - 글로벌 폼 상태 관리 컨텍스트 | Global form state management context
5
+ * 여러 컴포넌트 간 폼 상태 공유를 위한 React Context | React Context for sharing form state across multiple components
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
+ import { ReactNode } from "react";
30
+ import { GlobalFormContextType } from "../types/globalForm";
31
+ /**
32
+ * 글로벌 폼 상태 관리를 위한 React Context | React Context for global form state management
33
+ */
34
+ export declare const GlobalFormContext: import("react").Context<GlobalFormContextType>;
35
+ /**
36
+ * 글로벌 폼 상태 관리 Provider | Global form state management provider
37
+ *
38
+ * 애플리케이션 최상단에 배치하여 전역 폼 상태 관리를 활성화합니다. | Place at the top of your application to enable global form state management.
39
+ * 각 formId별로 독립적인 FieldStore 인스턴스를 관리합니다. | Manages independent FieldStore instances for each formId.
40
+ *
41
+ * @param props Provider props
42
+ * @returns 글로벌 폼 컨텍스트 Provider
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * // App.tsx
47
+ * import { GlobalFormProvider } from '@/forma';
48
+ *
49
+ * function App() {
50
+ * return (
51
+ * <GlobalFormProvider>
52
+ * <Router>
53
+ * <Routes>
54
+ * <Route path="/" element={<HomePage />} />
55
+ * <Route path="/customer" element={<CustomerPage />} />
56
+ * </Routes>
57
+ * </Router>
58
+ * </GlobalFormProvider>
59
+ * );
60
+ * }
61
+ * ```
62
+ */
63
+ export declare function GlobalFormProvider({ children }: {
64
+ children: ReactNode;
65
+ }): import("react/jsx-runtime").JSX.Element;
66
+ //# sourceMappingURL=GlobalFormContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GlobalFormContext.d.ts","sourceRoot":"","sources":["../../contexts/GlobalFormContext.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAyB,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,iBAAiB,gDAW5B,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,2CAiDvE"}
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GlobalFormContext = void 0;
4
+ exports.GlobalFormProvider = GlobalFormProvider;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ /**
7
+ * GlobalFormContext.tsx
8
+ *
9
+ * Forma - 글로벌 폼 상태 관리 컨텍스트 | Global form state management context
10
+ * 여러 컴포넌트 간 폼 상태 공유를 위한 React Context | React Context for sharing form state across multiple components
11
+ *
12
+ * @license MIT License
13
+ * @copyright 2025 KIM YOUNG JIN (Kim Young Jin)
14
+ * @author KIM YOUNG JIN (ehfuse@gmail.com)
15
+ *
16
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
17
+ * of this software and associated documentation files (the "Software"), to deal
18
+ * in the Software without restriction, including without limitation the rights
19
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ * copies of the Software, and to permit persons to whom the Software is
21
+ * furnished to do so, subject to the following conditions:
22
+ *
23
+ * The above copyright notice and this permission notice shall be included in all
24
+ * copies or substantial portions of the Software.
25
+ *
26
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
+ * SOFTWARE.
33
+ */
34
+ const react_1 = require("react");
35
+ const FieldStore_1 = require("../core/FieldStore");
36
+ /**
37
+ * 글로벌 폼 상태 관리를 위한 React Context | React Context for global form state management
38
+ */
39
+ exports.GlobalFormContext = (0, react_1.createContext)({
40
+ getOrCreateStore: () => {
41
+ throw new Error("GlobalFormContext must be used within GlobalFormProvider");
42
+ },
43
+ registerStore: () => {
44
+ throw new Error("GlobalFormContext must be used within GlobalFormProvider");
45
+ },
46
+ });
47
+ /**
48
+ * 글로벌 폼 상태 관리 Provider | Global form state management provider
49
+ *
50
+ * 애플리케이션 최상단에 배치하여 전역 폼 상태 관리를 활성화합니다. | Place at the top of your application to enable global form state management.
51
+ * 각 formId별로 독립적인 FieldStore 인스턴스를 관리합니다. | Manages independent FieldStore instances for each formId.
52
+ *
53
+ * @param props Provider props
54
+ * @returns 글로벌 폼 컨텍스트 Provider
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * // App.tsx
59
+ * import { GlobalFormProvider } from '@/forma';
60
+ *
61
+ * function App() {
62
+ * return (
63
+ * <GlobalFormProvider>
64
+ * <Router>
65
+ * <Routes>
66
+ * <Route path="/" element={<HomePage />} />
67
+ * <Route path="/customer" element={<CustomerPage />} />
68
+ * </Routes>
69
+ * </Router>
70
+ * </GlobalFormProvider>
71
+ * );
72
+ * }
73
+ * ```
74
+ */
75
+ function GlobalFormProvider({ children }) {
76
+ // formId별 FieldStore 인스턴스들을 관리하는 Map | Map managing FieldStore instances by formId
77
+ const storesRef = (0, react_1.useRef)(new Map());
78
+ /**
79
+ * formId에 해당하는 FieldStore를 가져오거나 새로 생성합니다. | Get or create FieldStore for the given formId.
80
+ *
81
+ * @param formId 폼 식별자 | Form identifier
82
+ * @returns FieldStore 인스턴스 | FieldStore instance
83
+ */
84
+ const getOrCreateStore = (formId) => {
85
+ const stores = storesRef.current;
86
+ if (!stores.has(formId)) {
87
+ // 새로운 스토어를 빈 객체로 생성 | Create new store with empty object
88
+ const newStore = new FieldStore_1.FieldStore({});
89
+ stores.set(formId, newStore);
90
+ return newStore;
91
+ }
92
+ return stores.get(formId);
93
+ };
94
+ /**
95
+ * 기존 FieldStore를 글로벌 폼에 등록합니다. | Register existing FieldStore to global form.
96
+ *
97
+ * @param formId 폼 식별자 | Form identifier
98
+ * @param store 등록할 FieldStore 인스턴스 | FieldStore instance to register
99
+ */
100
+ const registerStore = (formId, store) => {
101
+ const stores = storesRef.current;
102
+ stores.set(formId, store);
103
+ };
104
+ const contextValue = {
105
+ getOrCreateStore,
106
+ registerStore,
107
+ };
108
+ return ((0, jsx_runtime_1.jsx)(exports.GlobalFormContext.Provider, { value: contextValue, children: children }));
109
+ }
110
+ //# sourceMappingURL=GlobalFormContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GlobalFormContext.js","sourceRoot":"","sources":["../../contexts/GlobalFormContext.tsx"],"names":[],"mappings":";;;AA6EA,gDAiDC;;AA9HD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,iCAAyD;AACzD,mDAAgD;AAGhD;;GAEG;AACU,QAAA,iBAAiB,GAAG,IAAA,qBAAa,EAAwB;IAClE,gBAAgB,EAAE,GAAG,EAAE;QACnB,MAAM,IAAI,KAAK,CACX,0DAA0D,CAC7D,CAAC;IACN,CAAC;IACD,aAAa,EAAE,GAAG,EAAE;QAChB,MAAM,IAAI,KAAK,CACX,0DAA0D,CAC7D,CAAC;IACN,CAAC;CACJ,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAA2B;IACpE,mFAAmF;IACnF,MAAM,SAAS,GAAG,IAAA,cAAM,EAA+B,IAAI,GAAG,EAAE,CAAC,CAAC;IAElE;;;;;OAKG;IACH,MAAM,gBAAgB,GAAG,CACrB,MAAc,EACD,EAAE;QACf,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC;QAEjC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACtB,yDAAyD;YACzD,MAAM,QAAQ,GAAG,IAAI,uBAAU,CAAI,EAAO,CAAC,CAAC;YAC5C,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YAC7B,OAAO,QAAQ,CAAC;QACpB,CAAC;QAED,OAAO,MAAM,CAAC,GAAG,CAAC,MAAM,CAAkB,CAAC;IAC/C,CAAC,CAAC;IAEF;;;;;OAKG;IACH,MAAM,aAAa,GAAG,CAClB,MAAc,EACd,KAAoB,EAChB,EAAE;QACN,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC;QACjC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC,CAAC;IAEF,MAAM,YAAY,GAA0B;QACxC,gBAAgB;QAChB,aAAa;KAChB,CAAC;IAEF,OAAO,CACH,uBAAC,yBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YAC1C,QAAQ,GACgB,CAChC,CAAC;AACN,CAAC"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * FieldStore.ts
3
+ *
4
+ * Forma - 개별 필드 상태 관리 핵심 클래스 / Core class for individual field state management
5
+ * 선택적 구독과 성능 최적화 지원 / Supports selective subscriptions and performance optimization
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
+ * 개별 필드 상태 관리 Store / Individual field state management store
31
+ * 선택적 구독과 성능 최적화를 위한 핵심 클래스
32
+ * Core class for selective subscriptions and performance optimization
33
+ *
34
+ * @template T 폼 데이터의 타입 / Form data type
35
+ */
36
+ export declare class FieldStore<T extends Record<string, any>> {
37
+ private fields;
38
+ private dotNotationListeners;
39
+ private initialValues;
40
+ private globalListeners;
41
+ constructor(initialValues: T);
42
+ /**
43
+ * 특정 필드 값 가져오기 / Get specific field value
44
+ * Dot notation 지원 / Supports dot notation
45
+ * @param fieldName 필드명 또는 dot notation 경로 / Field name or dot notation path
46
+ * @returns 필드 값 / Field value
47
+ */
48
+ getValue(fieldName: keyof T | string): any;
49
+ /**
50
+ * 특정 필드 구독 / Subscribe to specific field
51
+ * Dot notation 지원 / Supports dot notation
52
+ * @param fieldName 필드명 또는 dot notation 경로 / Field name or dot notation path
53
+ * @param listener 변경 시 호출될 콜백 / Callback to call on change
54
+ * @returns 구독 해제 함수 / Unsubscribe function
55
+ */
56
+ subscribe(fieldName: keyof T | string, listener: () => void): () => void;
57
+ /**
58
+ * 전역 구독 / Global subscription
59
+ * isModified 등을 위해 사용 / Used for isModified etc.
60
+ * @param listener 변경 시 호출될 콜백 / Callback to call on change
61
+ * @returns 구독 해제 함수 / Unsubscribe function
62
+ */
63
+ subscribeGlobal(listener: () => void): () => void;
64
+ /**
65
+ * 필드 값 설정 / Set field value
66
+ * Dot notation 지원 / Supports dot notation
67
+ * @param fieldName 필드명 또는 dot notation 경로 / Field name or dot notation path
68
+ * @param value 설정할 값 / Value to set
69
+ */
70
+ setValue(fieldName: keyof T | string, value: any): void;
71
+ /**
72
+ * 모든 값 가져오기 / Get all values
73
+ * @returns 모든 필드 값을 포함한 객체 / Object containing all field values
74
+ */
75
+ getValues(): T;
76
+ /**
77
+ * 모든 값 설정 / Set all values
78
+ * @param newValues 설정할 값들 / Values to set
79
+ */
80
+ setValues(newValues: Partial<T>): void;
81
+ /**
82
+ * 초기값 재설정 / Reset initial values
83
+ * @param newInitialValues 새로운 초기값 / New initial values
84
+ */
85
+ setInitialValues(newInitialValues: T): void;
86
+ /**
87
+ * 수정 여부 확인 / Check if modified
88
+ * @returns 초기값에서 변경되었는지 여부 / Whether changed from initial values
89
+ */
90
+ isModified(): boolean;
91
+ /**
92
+ * 초기값으로 리셋 / Reset to initial values
93
+ */
94
+ reset(): void;
95
+ /**
96
+ * 리소스 정리 / Clean up resources
97
+ */
98
+ destroy(): void;
99
+ }
100
+ //# sourceMappingURL=FieldStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldStore.d.ts","sourceRoot":"","sources":["../../core/FieldStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAIH;;;;;;GAMG;AACH,qBAAa,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACjD,OAAO,CAAC,MAAM,CACA;IACd,OAAO,CAAC,oBAAoB,CAA2C;IACvE,OAAO,CAAC,aAAa,CAAI;IACzB,OAAO,CAAC,eAAe,CAAyB;gBAEpC,aAAa,EAAE,CAAC;IAW5B;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,GAAG;IAc1C;;;;;;OAMG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI;IAuC3D;;;;;OAKG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,IAAI;IAOpC;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,MAAM,EAAE,KAAK,EAAE,GAAG;IAkFhD;;;OAGG;IACH,SAAS,IAAI,CAAC;IAUd;;;OAGG;IACH,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;IAM/B;;;OAGG;IACH,gBAAgB,CAAC,gBAAgB,EAAE,CAAC;IAyBpC;;;OAGG;IACH,UAAU,IAAI,OAAO;IAOrB;;OAEG;IACH,KAAK;IAIL;;OAEG;IACH,OAAO;CAIV"}