@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.
- package/LICENSE +42 -0
- package/README.md +180 -0
- package/dist/contexts/GlobalFormContext.d.ts +66 -0
- package/dist/contexts/GlobalFormContext.d.ts.map +1 -0
- package/dist/contexts/GlobalFormContext.js +110 -0
- package/dist/contexts/GlobalFormContext.js.map +1 -0
- package/dist/core/FieldStore.d.ts +100 -0
- package/dist/core/FieldStore.d.ts.map +1 -0
- package/dist/core/FieldStore.js +264 -0
- package/dist/core/FieldStore.js.map +1 -0
- package/dist/core/index.d.ts +29 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +36 -0
- package/dist/core/index.js.map +1 -0
- package/dist/esm/contexts/GlobalFormContext.d.ts +66 -0
- package/dist/esm/contexts/GlobalFormContext.d.ts.map +1 -0
- package/dist/esm/contexts/GlobalFormContext.js +106 -0
- package/dist/esm/contexts/GlobalFormContext.js.map +1 -0
- package/dist/esm/core/FieldStore.d.ts +100 -0
- package/dist/esm/core/FieldStore.d.ts.map +1 -0
- package/dist/esm/core/FieldStore.js +260 -0
- package/dist/esm/core/FieldStore.js.map +1 -0
- package/dist/esm/core/index.d.ts +29 -0
- package/dist/esm/core/index.d.ts.map +1 -0
- package/dist/esm/core/index.js +32 -0
- package/dist/esm/core/index.js.map +1 -0
- package/dist/esm/hooks/useForm.d.ts +67 -0
- package/dist/esm/hooks/useForm.d.ts.map +1 -0
- package/dist/esm/hooks/useForm.js +287 -0
- package/dist/esm/hooks/useForm.js.map +1 -0
- package/dist/esm/hooks/useGlobalForm.d.ts +45 -0
- package/dist/esm/hooks/useGlobalForm.d.ts.map +1 -0
- package/dist/esm/hooks/useGlobalForm.js +61 -0
- package/dist/esm/hooks/useGlobalForm.js.map +1 -0
- package/dist/esm/hooks/useRegisterGlobalForm.d.ts +55 -0
- package/dist/esm/hooks/useRegisterGlobalForm.d.ts.map +1 -0
- package/dist/esm/hooks/useRegisterGlobalForm.js +64 -0
- package/dist/esm/hooks/useRegisterGlobalForm.js.map +1 -0
- package/dist/esm/index.d.ts +53 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +62 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types/form.d.ts +120 -0
- package/dist/esm/types/form.d.ts.map +1 -0
- package/dist/esm/types/form.js +29 -0
- package/dist/esm/types/form.js.map +1 -0
- package/dist/esm/types/globalForm.d.ts +265 -0
- package/dist/esm/types/globalForm.d.ts.map +1 -0
- package/dist/esm/types/globalForm.js +39 -0
- package/dist/esm/types/globalForm.js.map +1 -0
- package/dist/esm/types/index.d.ts +31 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/types/index.js +30 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/utils/dotNotation.d.ts +58 -0
- package/dist/esm/utils/dotNotation.d.ts.map +1 -0
- package/dist/esm/utils/dotNotation.js +100 -0
- package/dist/esm/utils/dotNotation.js.map +1 -0
- package/dist/esm/utils/index.d.ts +27 -0
- package/dist/esm/utils/index.d.ts.map +1 -0
- package/dist/esm/utils/index.js +27 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/hooks/useForm.d.ts +67 -0
- package/dist/hooks/useForm.d.ts.map +1 -0
- package/dist/hooks/useForm.js +290 -0
- package/dist/hooks/useForm.js.map +1 -0
- package/dist/hooks/useGlobalForm.d.ts +45 -0
- package/dist/hooks/useGlobalForm.d.ts.map +1 -0
- package/dist/hooks/useGlobalForm.js +64 -0
- package/dist/hooks/useGlobalForm.js.map +1 -0
- package/dist/hooks/useRegisterGlobalForm.d.ts +55 -0
- package/dist/hooks/useRegisterGlobalForm.d.ts.map +1 -0
- package/dist/hooks/useRegisterGlobalForm.js +67 -0
- package/dist/hooks/useRegisterGlobalForm.js.map +1 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/types/form.d.ts +120 -0
- package/dist/types/form.d.ts.map +1 -0
- package/dist/types/form.js +30 -0
- package/dist/types/form.js.map +1 -0
- package/dist/types/globalForm.d.ts +265 -0
- package/dist/types/globalForm.d.ts.map +1 -0
- package/dist/types/globalForm.js +43 -0
- package/dist/types/globalForm.js.map +1 -0
- package/dist/types/index.d.ts +31 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +34 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/dotNotation.d.ts +58 -0
- package/dist/utils/dotNotation.d.ts.map +1 -0
- package/dist/utils/dotNotation.js +104 -0
- package/dist/utils/dotNotation.js.map +1 -0
- package/dist/utils/index.d.ts +27 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +32 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* FieldStore.ts
|
|
4
|
+
*
|
|
5
|
+
* Forma - 개별 필드 상태 관리 핵심 클래스 / Core class for individual field state management
|
|
6
|
+
* 선택적 구독과 성능 최적화 지원 / Supports selective 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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.FieldStore = void 0;
|
|
32
|
+
const dotNotation_1 = require("../utils/dotNotation");
|
|
33
|
+
/**
|
|
34
|
+
* 개별 필드 상태 관리 Store / Individual field state management store
|
|
35
|
+
* 선택적 구독과 성능 최적화를 위한 핵심 클래스
|
|
36
|
+
* Core class for selective subscriptions and performance optimization
|
|
37
|
+
*
|
|
38
|
+
* @template T 폼 데이터의 타입 / Form data type
|
|
39
|
+
*/
|
|
40
|
+
class FieldStore {
|
|
41
|
+
constructor(initialValues) {
|
|
42
|
+
this.fields = new Map();
|
|
43
|
+
this.dotNotationListeners = new Map(); // Dot notation 구독자 / Dot notation subscribers
|
|
44
|
+
this.globalListeners = new Set();
|
|
45
|
+
this.initialValues = { ...initialValues };
|
|
46
|
+
// 초기값으로 필드 초기화 / Initialize fields with initial values
|
|
47
|
+
Object.keys(initialValues).forEach((key) => {
|
|
48
|
+
this.fields.set(key, {
|
|
49
|
+
value: initialValues[key],
|
|
50
|
+
listeners: new Set(),
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 특정 필드 값 가져오기 / Get specific field value
|
|
56
|
+
* Dot notation 지원 / Supports dot notation
|
|
57
|
+
* @param fieldName 필드명 또는 dot notation 경로 / Field name or dot notation path
|
|
58
|
+
* @returns 필드 값 / Field value
|
|
59
|
+
*/
|
|
60
|
+
getValue(fieldName) {
|
|
61
|
+
const fieldNameStr = fieldName;
|
|
62
|
+
// dot notation이 포함된 경우 중첩 객체 접근 / Access nested object for dot notation
|
|
63
|
+
if (fieldNameStr.includes(".")) {
|
|
64
|
+
const values = this.getValues();
|
|
65
|
+
return (0, dotNotation_1.getNestedValue)(values, fieldNameStr);
|
|
66
|
+
}
|
|
67
|
+
// 일반 필드 접근 / Regular field access
|
|
68
|
+
const field = this.fields.get(fieldName);
|
|
69
|
+
return field?.value;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 특정 필드 구독 / Subscribe to specific field
|
|
73
|
+
* Dot notation 지원 / Supports dot notation
|
|
74
|
+
* @param fieldName 필드명 또는 dot notation 경로 / Field name or dot notation path
|
|
75
|
+
* @param listener 변경 시 호출될 콜백 / Callback to call on change
|
|
76
|
+
* @returns 구독 해제 함수 / Unsubscribe function
|
|
77
|
+
*/
|
|
78
|
+
subscribe(fieldName, listener) {
|
|
79
|
+
const fieldNameStr = fieldName;
|
|
80
|
+
// dot notation이 포함된 경우 정확한 경로로 구독 / Subscribe to exact path for dot notation
|
|
81
|
+
if (fieldNameStr.includes(".")) {
|
|
82
|
+
let listeners = this.dotNotationListeners.get(fieldNameStr);
|
|
83
|
+
if (!listeners) {
|
|
84
|
+
listeners = new Set();
|
|
85
|
+
this.dotNotationListeners.set(fieldNameStr, listeners);
|
|
86
|
+
}
|
|
87
|
+
listeners.add(listener);
|
|
88
|
+
return () => {
|
|
89
|
+
const listeners = this.dotNotationListeners.get(fieldNameStr);
|
|
90
|
+
if (listeners) {
|
|
91
|
+
listeners.delete(listener);
|
|
92
|
+
if (listeners.size === 0) {
|
|
93
|
+
this.dotNotationListeners.delete(fieldNameStr);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
// 일반 필드 구독 / Regular field subscription
|
|
99
|
+
let field = this.fields.get(fieldName);
|
|
100
|
+
if (!field) {
|
|
101
|
+
// 필드가 없으면 생성 / Create field if not exists
|
|
102
|
+
field = {
|
|
103
|
+
value: undefined,
|
|
104
|
+
listeners: new Set(),
|
|
105
|
+
};
|
|
106
|
+
this.fields.set(fieldName, field);
|
|
107
|
+
}
|
|
108
|
+
field.listeners.add(listener);
|
|
109
|
+
return () => {
|
|
110
|
+
field?.listeners.delete(listener);
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* 전역 구독 / Global subscription
|
|
115
|
+
* isModified 등을 위해 사용 / Used for isModified etc.
|
|
116
|
+
* @param listener 변경 시 호출될 콜백 / Callback to call on change
|
|
117
|
+
* @returns 구독 해제 함수 / Unsubscribe function
|
|
118
|
+
*/
|
|
119
|
+
subscribeGlobal(listener) {
|
|
120
|
+
this.globalListeners.add(listener);
|
|
121
|
+
return () => {
|
|
122
|
+
this.globalListeners.delete(listener);
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* 필드 값 설정 / Set field value
|
|
127
|
+
* Dot notation 지원 / Supports dot notation
|
|
128
|
+
* @param fieldName 필드명 또는 dot notation 경로 / Field name or dot notation path
|
|
129
|
+
* @param value 설정할 값 / Value to set
|
|
130
|
+
*/
|
|
131
|
+
setValue(fieldName, value) {
|
|
132
|
+
const fieldNameStr = fieldName;
|
|
133
|
+
// dot notation이 포함된 경우 / For dot notation
|
|
134
|
+
if (fieldNameStr.includes(".")) {
|
|
135
|
+
const rootField = fieldNameStr.split(".")[0];
|
|
136
|
+
const rootFieldStr = String(rootField);
|
|
137
|
+
const remainingPath = fieldNameStr.substring(rootFieldStr.length + 1);
|
|
138
|
+
let field = this.fields.get(rootField);
|
|
139
|
+
if (!field) {
|
|
140
|
+
field = {
|
|
141
|
+
value: {},
|
|
142
|
+
listeners: new Set(),
|
|
143
|
+
};
|
|
144
|
+
this.fields.set(rootField, field);
|
|
145
|
+
}
|
|
146
|
+
const newRootValue = (0, dotNotation_1.setNestedValue)(field.value || {}, remainingPath, value);
|
|
147
|
+
if (JSON.stringify(field.value) !== JSON.stringify(newRootValue)) {
|
|
148
|
+
field.value = newRootValue;
|
|
149
|
+
// 루트 필드 구독자들 알림 / Notify root field subscribers
|
|
150
|
+
field.listeners.forEach((listener) => {
|
|
151
|
+
listener();
|
|
152
|
+
});
|
|
153
|
+
// Dot notation 경로 구독자들 알림 / Notify dot notation path subscribers
|
|
154
|
+
this.dotNotationListeners.forEach((listeners, subscribedPath) => {
|
|
155
|
+
if (subscribedPath === fieldNameStr) {
|
|
156
|
+
listeners.forEach((listener) => listener());
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
// 전역 구독자들 알림 / Notify global subscribers
|
|
160
|
+
this.globalListeners.forEach((listener) => listener());
|
|
161
|
+
}
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
// 일반 필드 설정 / Regular field setting
|
|
165
|
+
let field = this.fields.get(fieldName);
|
|
166
|
+
if (!field) {
|
|
167
|
+
field = {
|
|
168
|
+
value: undefined,
|
|
169
|
+
listeners: new Set(),
|
|
170
|
+
};
|
|
171
|
+
this.fields.set(fieldName, field);
|
|
172
|
+
}
|
|
173
|
+
if (field.value !== value) {
|
|
174
|
+
field.value = value;
|
|
175
|
+
const fieldStr = fieldName;
|
|
176
|
+
// 해당 필드 구독자들 알림 / Notify field subscribers
|
|
177
|
+
field.listeners.forEach((listener) => {
|
|
178
|
+
listener();
|
|
179
|
+
});
|
|
180
|
+
// Dot notation 구독자들 알림 / Notify dot notation subscribers
|
|
181
|
+
this.dotNotationListeners.forEach((listeners, subscribedPath) => {
|
|
182
|
+
if (subscribedPath === fieldStr) {
|
|
183
|
+
listeners.forEach((listener) => listener());
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
// 전역 구독자들 알림 / Notify global subscribers
|
|
187
|
+
if (this.globalListeners.size > 0) {
|
|
188
|
+
this.globalListeners.forEach((listener) => listener());
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* 모든 값 가져오기 / Get all values
|
|
194
|
+
* @returns 모든 필드 값을 포함한 객체 / Object containing all field values
|
|
195
|
+
*/
|
|
196
|
+
getValues() {
|
|
197
|
+
const values = {};
|
|
198
|
+
this.fields.forEach((field, key) => {
|
|
199
|
+
// undefined 값을 null로 변환하여 API 전송 시 필드가 누락되지 않도록 함
|
|
200
|
+
// Convert undefined to null to prevent field omission during API transmission
|
|
201
|
+
values[key] = field.value === undefined ? null : field.value;
|
|
202
|
+
});
|
|
203
|
+
return values;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* 모든 값 설정 / Set all values
|
|
207
|
+
* @param newValues 설정할 값들 / Values to set
|
|
208
|
+
*/
|
|
209
|
+
setValues(newValues) {
|
|
210
|
+
Object.keys(newValues).forEach((key) => {
|
|
211
|
+
this.setValue(key, newValues[key]);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* 초기값 재설정 / Reset initial values
|
|
216
|
+
* @param newInitialValues 새로운 초기값 / New initial values
|
|
217
|
+
*/
|
|
218
|
+
setInitialValues(newInitialValues) {
|
|
219
|
+
this.initialValues = { ...newInitialValues };
|
|
220
|
+
// 기존 리스너를 보존하면서 값만 업데이트 / Update values while preserving existing listeners
|
|
221
|
+
Object.keys(newInitialValues).forEach((key) => {
|
|
222
|
+
const existingField = this.fields.get(key);
|
|
223
|
+
if (existingField) {
|
|
224
|
+
// 기존 필드가 있으면 값만 업데이트 / Update value only if field exists
|
|
225
|
+
existingField.value = newInitialValues[key];
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
// 새 필드면 생성 / Create new field
|
|
229
|
+
this.fields.set(key, {
|
|
230
|
+
value: newInitialValues[key],
|
|
231
|
+
listeners: new Set(),
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
// 모든 리스너에게 알림 / Notify all listeners
|
|
236
|
+
this.fields.forEach((field) => {
|
|
237
|
+
field.listeners.forEach((listener) => listener());
|
|
238
|
+
});
|
|
239
|
+
this.globalListeners.forEach((listener) => listener());
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* 수정 여부 확인 / Check if modified
|
|
243
|
+
* @returns 초기값에서 변경되었는지 여부 / Whether changed from initial values
|
|
244
|
+
*/
|
|
245
|
+
isModified() {
|
|
246
|
+
const currentValues = this.getValues();
|
|
247
|
+
return (JSON.stringify(currentValues) !== JSON.stringify(this.initialValues));
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* 초기값으로 리셋 / Reset to initial values
|
|
251
|
+
*/
|
|
252
|
+
reset() {
|
|
253
|
+
this.setValues(this.initialValues);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* 리소스 정리 / Clean up resources
|
|
257
|
+
*/
|
|
258
|
+
destroy() {
|
|
259
|
+
this.fields.clear();
|
|
260
|
+
this.globalListeners.clear();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
exports.FieldStore = FieldStore;
|
|
264
|
+
//# sourceMappingURL=FieldStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldStore.js","sourceRoot":"","sources":["../../core/FieldStore.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;AAEH,sDAAsE;AAEtE;;;;;;GAMG;AACH,MAAa,UAAU;IAOnB,YAAY,aAAgB;QANpB,WAAM,GACV,IAAI,GAAG,EAAE,CAAC;QACN,yBAAoB,GAAiC,IAAI,GAAG,EAAE,CAAC,CAAC,8CAA8C;QAE9G,oBAAe,GAAG,IAAI,GAAG,EAAc,CAAC;QAG5C,IAAI,CAAC,aAAa,GAAG,EAAE,GAAG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C,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED;;;OAGG;IACH,UAAU;QACN,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QACvC,OAAO,CACH,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CACvE,CAAC;IACN,CAAC;IAED;;OAEG;IACH,KAAK;QACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,OAAO;QACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;CACJ;AAvQD,gCAuQC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* core/index.ts
|
|
3
|
+
*
|
|
4
|
+
* Forma - 핵심 클래스들 내보내기
|
|
5
|
+
*
|
|
6
|
+
* @license MIT License
|
|
7
|
+
* @copyright 2025 KIM YOUNG JIN (Kim Young Jin)
|
|
8
|
+
* @author KIM YOUNG JIN (ehfuse@gmail.com)
|
|
9
|
+
*
|
|
10
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
* in the Software without restriction, including without limitation the rights
|
|
13
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
* furnished to do so, subject to the following conditions:
|
|
16
|
+
*
|
|
17
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
* copies or substantial portions of the Software.
|
|
19
|
+
*
|
|
20
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
* SOFTWARE.
|
|
27
|
+
*/
|
|
28
|
+
export { FieldStore } from "./FieldStore";
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* core/index.ts
|
|
4
|
+
*
|
|
5
|
+
* Forma - 핵심 클래스들 내보내기
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.FieldStore = void 0;
|
|
31
|
+
var FieldStore_1 = require("./FieldStore");
|
|
32
|
+
Object.defineProperty(exports, "FieldStore", { enumerable: true, get: function () { return FieldStore_1.FieldStore; } });
|
|
33
|
+
// 향후 추가될 핵심 클래스들
|
|
34
|
+
// export { FormValidator } from './FormValidator';
|
|
35
|
+
// export { FormStore } from './FormStore';
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../core/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;AAEH,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AAEnB,iBAAiB;AACjB,mDAAmD;AACnD,2CAA2C"}
|
|
@@ -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,106 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* GlobalFormContext.tsx
|
|
4
|
+
*
|
|
5
|
+
* Forma - 글로벌 폼 상태 관리 컨텍스트 | Global form state management context
|
|
6
|
+
* 여러 컴포넌트 간 폼 상태 공유를 위한 React Context | React Context 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 { createContext, useRef } from "react";
|
|
31
|
+
import { FieldStore } from "../core/FieldStore";
|
|
32
|
+
/**
|
|
33
|
+
* 글로벌 폼 상태 관리를 위한 React Context | React Context for global form state management
|
|
34
|
+
*/
|
|
35
|
+
export const GlobalFormContext = createContext({
|
|
36
|
+
getOrCreateStore: () => {
|
|
37
|
+
throw new Error("GlobalFormContext must be used within GlobalFormProvider");
|
|
38
|
+
},
|
|
39
|
+
registerStore: () => {
|
|
40
|
+
throw new Error("GlobalFormContext must be used within GlobalFormProvider");
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* 글로벌 폼 상태 관리 Provider | Global form state management provider
|
|
45
|
+
*
|
|
46
|
+
* 애플리케이션 최상단에 배치하여 전역 폼 상태 관리를 활성화합니다. | Place at the top of your application to enable global form state management.
|
|
47
|
+
* 각 formId별로 독립적인 FieldStore 인스턴스를 관리합니다. | Manages independent FieldStore instances for each formId.
|
|
48
|
+
*
|
|
49
|
+
* @param props Provider props
|
|
50
|
+
* @returns 글로벌 폼 컨텍스트 Provider
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* // App.tsx
|
|
55
|
+
* import { GlobalFormProvider } from '@/forma';
|
|
56
|
+
*
|
|
57
|
+
* function App() {
|
|
58
|
+
* return (
|
|
59
|
+
* <GlobalFormProvider>
|
|
60
|
+
* <Router>
|
|
61
|
+
* <Routes>
|
|
62
|
+
* <Route path="/" element={<HomePage />} />
|
|
63
|
+
* <Route path="/customer" element={<CustomerPage />} />
|
|
64
|
+
* </Routes>
|
|
65
|
+
* </Router>
|
|
66
|
+
* </GlobalFormProvider>
|
|
67
|
+
* );
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export function GlobalFormProvider({ children }) {
|
|
72
|
+
// formId별 FieldStore 인스턴스들을 관리하는 Map | Map managing FieldStore instances by formId
|
|
73
|
+
const storesRef = useRef(new Map());
|
|
74
|
+
/**
|
|
75
|
+
* formId에 해당하는 FieldStore를 가져오거나 새로 생성합니다. | Get or create FieldStore for the given formId.
|
|
76
|
+
*
|
|
77
|
+
* @param formId 폼 식별자 | Form identifier
|
|
78
|
+
* @returns FieldStore 인스턴스 | FieldStore instance
|
|
79
|
+
*/
|
|
80
|
+
const getOrCreateStore = (formId) => {
|
|
81
|
+
const stores = storesRef.current;
|
|
82
|
+
if (!stores.has(formId)) {
|
|
83
|
+
// 새로운 스토어를 빈 객체로 생성 | Create new store with empty object
|
|
84
|
+
const newStore = new FieldStore({});
|
|
85
|
+
stores.set(formId, newStore);
|
|
86
|
+
return newStore;
|
|
87
|
+
}
|
|
88
|
+
return stores.get(formId);
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* 기존 FieldStore를 글로벌 폼에 등록합니다. | Register existing FieldStore to global form.
|
|
92
|
+
*
|
|
93
|
+
* @param formId 폼 식별자 | Form identifier
|
|
94
|
+
* @param store 등록할 FieldStore 인스턴스 | FieldStore instance to register
|
|
95
|
+
*/
|
|
96
|
+
const registerStore = (formId, store) => {
|
|
97
|
+
const stores = storesRef.current;
|
|
98
|
+
stores.set(formId, store);
|
|
99
|
+
};
|
|
100
|
+
const contextValue = {
|
|
101
|
+
getOrCreateStore,
|
|
102
|
+
registerStore,
|
|
103
|
+
};
|
|
104
|
+
return (_jsx(GlobalFormContext.Provider, { value: contextValue, children: children }));
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=GlobalFormContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GlobalFormContext.js","sourceRo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AAM,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC,CAAC;IAEF,MAAM,YAAY,GAA0B;QACxC,gBAAgB;QAChB,aAAa;KAChB,CAAC;IAEF,OAAO,CACH,KAAC,iBAAiB,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"}
|