@ehfuse/forma 1.6.9 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/contexts/GlobalFormaContext.d.ts +1 -2
- package/dist/contexts/GlobalFormaContext.d.ts.map +1 -1
- package/dist/contexts/GlobalFormaContext.js +77 -2
- package/dist/contexts/GlobalFormaContext.js.map +1 -1
- package/dist/esm/contexts/GlobalFormaContext.d.ts +1 -2
- package/dist/esm/contexts/GlobalFormaContext.d.ts.map +1 -1
- package/dist/esm/contexts/GlobalFormaContext.js +78 -3
- package/dist/esm/contexts/GlobalFormaContext.js.map +1 -1
- package/dist/esm/hooks/useBreakpoint.d.ts +51 -0
- package/dist/esm/hooks/useBreakpoint.d.ts.map +1 -0
- package/dist/esm/hooks/useBreakpoint.js +113 -0
- package/dist/esm/hooks/useBreakpoint.js.map +1 -0
- package/dist/esm/hooks/useModal.d.ts +62 -0
- package/dist/esm/hooks/useModal.d.ts.map +1 -0
- package/dist/esm/hooks/useModal.js +150 -0
- package/dist/esm/hooks/useModal.js.map +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/breakpoint.d.ts +62 -0
- package/dist/esm/types/breakpoint.d.ts.map +1 -0
- package/dist/esm/types/breakpoint.js +25 -0
- package/dist/esm/types/breakpoint.js.map +1 -0
- package/dist/esm/types/globalForm.d.ts +7 -0
- package/dist/esm/types/globalForm.d.ts.map +1 -1
- package/dist/esm/types/index.d.ts +2 -0
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/modal.d.ts +27 -0
- package/dist/esm/types/modal.d.ts.map +1 -0
- package/dist/esm/types/modal.js +11 -0
- package/dist/esm/types/modal.js.map +1 -0
- package/dist/hooks/useBreakpoint.d.ts +51 -0
- package/dist/hooks/useBreakpoint.d.ts.map +1 -0
- package/dist/hooks/useBreakpoint.js +117 -0
- package/dist/hooks/useBreakpoint.js.map +1 -0
- package/dist/hooks/useModal.d.ts +62 -0
- package/dist/hooks/useModal.d.ts.map +1 -0
- package/dist/hooks/useModal.js +153 -0
- package/dist/hooks/useModal.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/types/breakpoint.d.ts +62 -0
- package/dist/types/breakpoint.d.ts.map +1 -0
- package/dist/types/breakpoint.js +26 -0
- package/dist/types/breakpoint.js.map +1 -0
- package/dist/types/globalForm.d.ts +7 -0
- package/dist/types/globalForm.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modal.d.ts +27 -0
- package/dist/types/modal.d.ts.map +1 -0
- package/dist/types/modal.js +12 -0
- package/dist/types/modal.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,6 +17,8 @@ Forma는 React 애플리케이션에서 폼과 상태를 **간편하면서도
|
|
|
17
17
|
- ✅ **Individual Field Subscription**: Optimized performance through selective re-rendering per field
|
|
18
18
|
- 🌟 **Global State Subscription**: Subscribe to entire state with `useValue("*")` pattern for optimal performance
|
|
19
19
|
- ✅ **General State Management**: Efficient management of non-form states with `useFormaState`
|
|
20
|
+
- 🎭 **Modal Stack Management**: Mobile-friendly modal handling with back button support via `useModal`
|
|
21
|
+
- 📱 **Responsive Breakpoint Management**: Screen size detection and adaptive UI with `useBreakpoint`
|
|
20
22
|
- ✅ **Dot Notation Optimization**: Access nested objects like `user.profile.name`
|
|
21
23
|
- ✅ **Full MUI Compatibility**: Perfect integration with Material-UI components
|
|
22
24
|
- ✅ **Global Form State**: Share form state across multiple components
|
|
@@ -30,6 +32,8 @@ Forma는 React 애플리케이션에서 폼과 상태를 **간편하면서도
|
|
|
30
32
|
- ✅ **개별 필드 구독**: 필드별 선택적 리렌더링으로 최적화된 성능
|
|
31
33
|
- 🌟 **전체 상태 구독**: `useValue("*")` 패턴으로 전체 상태를 한 번에 구독하여 최적 성능 제공
|
|
32
34
|
- ✅ **범용 상태 관리**: `useFormaState`로 폼 외 일반 상태도 효율적 관리
|
|
35
|
+
- 🎭 **모달 스택 관리**: `useModal`로 뒤로가기 지원하는 모바일 친화적 모달 처리
|
|
36
|
+
- 📱 **반응형 브레이크포인트 관리**: `useBreakpoint`로 화면 크기 감지 및 적응형 UI 구현
|
|
33
37
|
- ✅ **Dot Notation 최적화**: `user.profile.name` 형태의 중첩 객체 접근
|
|
34
38
|
- ✅ **MUI 완전 호환**: Material-UI 컴포넌트와 완벽한 통합
|
|
35
39
|
- ✅ **글로벌 폼 상태**: 여러 컴포넌트 간 폼 상태 공유
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
* 여러 컴포넌트 간 폼 상태 공유를 위한 React Context | React Context for sharing form state across multiple components
|
|
6
6
|
*
|
|
7
7
|
* @license MIT License
|
|
8
|
-
* @copyright 2025 KIM YOUNG JIN (
|
|
9
|
-
* @author KIM YOUNG JIN (ehfuse@gmail.com)
|
|
8
|
+
* @copyright 2025 KIM YOUNG JIN (ehfuse@gmail.com)
|
|
10
9
|
*
|
|
11
10
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
11
|
* of this software and associated documentation files (the "Software"), to deal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalFormaContext.d.ts","sourceRoot":"","sources":["../../contexts/GlobalFormaContext.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"GlobalFormaContext.d.ts","sourceRoot":"","sources":["../../contexts/GlobalFormaContext.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAGH,SAAS,EAIZ,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,kBAAkB,iDAqD7B,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,2CAmSxE"}
|
|
@@ -10,8 +10,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
10
10
|
* 여러 컴포넌트 간 폼 상태 공유를 위한 React Context | React Context for sharing form state across multiple components
|
|
11
11
|
*
|
|
12
12
|
* @license MIT License
|
|
13
|
-
* @copyright 2025 KIM YOUNG JIN (
|
|
14
|
-
* @author KIM YOUNG JIN (ehfuse@gmail.com)
|
|
13
|
+
* @copyright 2025 KIM YOUNG JIN (ehfuse@gmail.com)
|
|
15
14
|
*
|
|
16
15
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
17
16
|
* of this software and associated documentation files (the "Software"), to deal
|
|
@@ -37,6 +36,7 @@ const FieldStore_1 = require("../core/FieldStore");
|
|
|
37
36
|
* 글로벌 폼 상태 관리를 위한 React Context | React Context for global form state management
|
|
38
37
|
*/
|
|
39
38
|
exports.GlobalFormaContext = (0, react_1.createContext)({
|
|
39
|
+
// FieldStore 관련
|
|
40
40
|
getOrCreateStore: () => {
|
|
41
41
|
throw new Error("GlobalFormaContext must be used within GlobalFormaProvider");
|
|
42
42
|
},
|
|
@@ -58,6 +58,16 @@ exports.GlobalFormaContext = (0, react_1.createContext)({
|
|
|
58
58
|
validateAndStoreAutoCleanupSetting: () => {
|
|
59
59
|
throw new Error("GlobalFormaContext must be used within GlobalFormaProvider");
|
|
60
60
|
},
|
|
61
|
+
// 모달 스택 관리
|
|
62
|
+
appendOpenModal: () => {
|
|
63
|
+
throw new Error("GlobalFormaContext must be used within GlobalFormaProvider");
|
|
64
|
+
},
|
|
65
|
+
removeOpenModal: () => {
|
|
66
|
+
throw new Error("GlobalFormaContext must be used within GlobalFormaProvider");
|
|
67
|
+
},
|
|
68
|
+
closeLastModal: () => {
|
|
69
|
+
throw new Error("GlobalFormaContext must be used within GlobalFormaProvider");
|
|
70
|
+
},
|
|
61
71
|
});
|
|
62
72
|
/**
|
|
63
73
|
* 글로벌 Forma 상태 관리 Provider | Global Forma state management provider
|
|
@@ -96,6 +106,10 @@ function GlobalFormaProvider({ children }) {
|
|
|
96
106
|
const autoCleanupRefCountsRef = (0, react_1.useRef)(new Map());
|
|
97
107
|
// formId별 autoCleanup 설정을 추적하는 Map | Map tracking autoCleanup settings by formId
|
|
98
108
|
const autoCleanupSettingsRef = (0, react_1.useRef)(new Map());
|
|
109
|
+
// ========== 모달 스택 관리 상태 ==========
|
|
110
|
+
const [openModalIds, setOpenModalIds] = (0, react_1.useState)([]);
|
|
111
|
+
const openModalIdsRef = (0, react_1.useRef)([]);
|
|
112
|
+
const modalTrackingRef = (0, react_1.useRef)([]);
|
|
99
113
|
/**
|
|
100
114
|
* formId에 해당하는 FieldStore를 가져오거나 새로 생성합니다. | Get or create FieldStore for the given formId.
|
|
101
115
|
*
|
|
@@ -243,7 +257,64 @@ function GlobalFormaProvider({ children }) {
|
|
|
243
257
|
}
|
|
244
258
|
}
|
|
245
259
|
};
|
|
260
|
+
// ========== 모달 및 네비게이션 관련 함수 ==========
|
|
261
|
+
/**
|
|
262
|
+
* 모달 등록
|
|
263
|
+
*/
|
|
264
|
+
const appendOpenModal = (0, react_1.useCallback)((modalId) => {
|
|
265
|
+
if (modalTrackingRef.current.includes(modalId))
|
|
266
|
+
return;
|
|
267
|
+
modalTrackingRef.current.push(modalId);
|
|
268
|
+
setOpenModalIds((prevIds) => {
|
|
269
|
+
const newOpenIds = [...prevIds, modalId];
|
|
270
|
+
return newOpenIds;
|
|
271
|
+
});
|
|
272
|
+
window.history.pushState({ modalOpen: modalId }, "", window.location.href);
|
|
273
|
+
}, []);
|
|
274
|
+
/**
|
|
275
|
+
* 모달 등록 해제
|
|
276
|
+
*/
|
|
277
|
+
const removeOpenModal = (0, react_1.useCallback)((modalId) => {
|
|
278
|
+
setOpenModalIds((prevIds) => {
|
|
279
|
+
if (prevIds.includes(modalId)) {
|
|
280
|
+
const newOpenIds = prevIds.filter((id) => id !== modalId);
|
|
281
|
+
modalTrackingRef.current = modalTrackingRef.current.filter((id) => id !== modalId);
|
|
282
|
+
return newOpenIds;
|
|
283
|
+
}
|
|
284
|
+
return prevIds;
|
|
285
|
+
});
|
|
286
|
+
}, []);
|
|
287
|
+
/**
|
|
288
|
+
* 마지막으로 열린 모달 닫기
|
|
289
|
+
*/
|
|
290
|
+
const closeLastModal = (0, react_1.useCallback)(() => {
|
|
291
|
+
if (openModalIds.length === 0)
|
|
292
|
+
return false;
|
|
293
|
+
const lastModalId = openModalIds[openModalIds.length - 1];
|
|
294
|
+
window.dispatchEvent(new CustomEvent(`modal:close:${lastModalId}`));
|
|
295
|
+
return true;
|
|
296
|
+
}, [openModalIds]);
|
|
297
|
+
// 모달 ID 추적을 위해 ref 업데이트
|
|
298
|
+
(0, react_1.useEffect)(() => {
|
|
299
|
+
openModalIdsRef.current = openModalIds;
|
|
300
|
+
}, [openModalIds]);
|
|
301
|
+
// popstate 이벤트 핸들러 (뒤로가기 시 모달 닫기)
|
|
302
|
+
(0, react_1.useEffect)(() => {
|
|
303
|
+
const handlePopState = (e) => {
|
|
304
|
+
// 열린 모달이 있으면 모달을 닫기
|
|
305
|
+
if (openModalIdsRef.current.length > 0) {
|
|
306
|
+
e.preventDefault();
|
|
307
|
+
closeLastModal();
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
window.addEventListener("popstate", handlePopState);
|
|
312
|
+
return () => {
|
|
313
|
+
window.removeEventListener("popstate", handlePopState);
|
|
314
|
+
};
|
|
315
|
+
}, [closeLastModal]);
|
|
246
316
|
const contextValue = {
|
|
317
|
+
// FieldStore 관련
|
|
247
318
|
getOrCreateStore,
|
|
248
319
|
registerStore,
|
|
249
320
|
unregisterStore,
|
|
@@ -251,6 +322,10 @@ function GlobalFormaProvider({ children }) {
|
|
|
251
322
|
incrementRef,
|
|
252
323
|
decrementRef,
|
|
253
324
|
validateAndStoreAutoCleanupSetting,
|
|
325
|
+
// 모달 스택 관리
|
|
326
|
+
appendOpenModal,
|
|
327
|
+
removeOpenModal,
|
|
328
|
+
closeLastModal,
|
|
254
329
|
};
|
|
255
330
|
return ((0, jsx_runtime_1.jsx)(exports.GlobalFormaContext.Provider, { value: contextValue, children: children }));
|
|
256
331
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalFormaContext.js","sourceRoot":"","sources":["../../contexts/GlobalFormaContext.tsx"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"GlobalFormaContext.js","sourceRoot":"","sources":["../../contexts/GlobalFormaContext.tsx"],"names":[],"mappings":";;;AA6HA,kDAmSC;;AAhaD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,iCAOe;AACf,mDAAgD;AAGhD;;GAEG;AACU,QAAA,kBAAkB,GAAG,IAAA,qBAAa,EAAyB;IACpE,gBAAgB;IAChB,gBAAgB,EAAE,GAAG,EAAE;QACnB,MAAM,IAAI,KAAK,CACX,4DAA4D,CAC/D,CAAC;IACN,CAAC;IACD,aAAa,EAAE,GAAG,EAAE;QAChB,MAAM,IAAI,KAAK,CACX,4DAA4D,CAC/D,CAAC;IACN,CAAC;IACD,eAAe,EAAE,GAAG,EAAE;QAClB,MAAM,IAAI,KAAK,CACX,4DAA4D,CAC/D,CAAC;IACN,CAAC;IACD,WAAW,EAAE,GAAG,EAAE;QACd,MAAM,IAAI,KAAK,CACX,4DAA4D,CAC/D,CAAC;IACN,CAAC;IACD,YAAY,EAAE,GAAG,EAAE;QACf,MAAM,IAAI,KAAK,CACX,4DAA4D,CAC/D,CAAC;IACN,CAAC;IACD,YAAY,EAAE,GAAG,EAAE;QACf,MAAM,IAAI,KAAK,CACX,4DAA4D,CAC/D,CAAC;IACN,CAAC;IACD,kCAAkC,EAAE,GAAG,EAAE;QACrC,M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xC,oBAAoB;YACpB,IAAI,eAAe,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrC,CAAC,CAAC,cAAc,EAAE,CAAC;gBACnB,cAAc,EAAE,CAAC;gBACjB,OAAO;YACX,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QAEpD,OAAO,GAAG,EAAE;YACR,MAAM,CAAC,mBAAmB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QAC3D,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;IAErB,MAAM,YAAY,GAA2B;QACzC,gBAAgB;QAChB,gBAAgB;QAChB,aAAa;QACb,eAAe;QACf,WAAW;QACX,YAAY;QACZ,YAAY;QACZ,kCAAkC;QAClC,WAAW;QACX,eAAe;QACf,eAAe;QACf,cAAc;KACjB,CAAC;IAEF,OAAO,CACH,uBAAC,0BAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YAC3C,QAAQ,GACiB,CACjC,CAAC;AACN,CAAC"}
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
* 여러 컴포넌트 간 폼 상태 공유를 위한 React Context | React Context for sharing form state across multiple components
|
|
6
6
|
*
|
|
7
7
|
* @license MIT License
|
|
8
|
-
* @copyright 2025 KIM YOUNG JIN (
|
|
9
|
-
* @author KIM YOUNG JIN (ehfuse@gmail.com)
|
|
8
|
+
* @copyright 2025 KIM YOUNG JIN (ehfuse@gmail.com)
|
|
10
9
|
*
|
|
11
10
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
11
|
* of this software and associated documentation files (the "Software"), to deal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalFormaContext.d.ts","sourceRoot":"","sources":["../../../contexts/GlobalFormaContext.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"GlobalFormaContext.d.ts","sourceRoot":"","sources":["../../../contexts/GlobalFormaContext.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAGH,SAAS,EAIZ,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,kBAAkB,iDAqD7B,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,2CAmSxE"}
|
|
@@ -6,8 +6,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
6
6
|
* 여러 컴포넌트 간 폼 상태 공유를 위한 React Context | React Context for sharing form state across multiple components
|
|
7
7
|
*
|
|
8
8
|
* @license MIT License
|
|
9
|
-
* @copyright 2025 KIM YOUNG JIN (
|
|
10
|
-
* @author KIM YOUNG JIN (ehfuse@gmail.com)
|
|
9
|
+
* @copyright 2025 KIM YOUNG JIN (ehfuse@gmail.com)
|
|
11
10
|
*
|
|
12
11
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
12
|
* of this software and associated documentation files (the "Software"), to deal
|
|
@@ -27,12 +26,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
27
26
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
27
|
* SOFTWARE.
|
|
29
28
|
*/
|
|
30
|
-
import { createContext, useRef } from "react";
|
|
29
|
+
import { createContext, useRef, useState, useEffect, useCallback, } from "react";
|
|
31
30
|
import { FieldStore } from "../core/FieldStore";
|
|
32
31
|
/**
|
|
33
32
|
* 글로벌 폼 상태 관리를 위한 React Context | React Context for global form state management
|
|
34
33
|
*/
|
|
35
34
|
export const GlobalFormaContext = createContext({
|
|
35
|
+
// FieldStore 관련
|
|
36
36
|
getOrCreateStore: () => {
|
|
37
37
|
throw new Error("GlobalFormaContext must be used within GlobalFormaProvider");
|
|
38
38
|
},
|
|
@@ -54,6 +54,16 @@ export const GlobalFormaContext = createContext({
|
|
|
54
54
|
validateAndStoreAutoCleanupSetting: () => {
|
|
55
55
|
throw new Error("GlobalFormaContext must be used within GlobalFormaProvider");
|
|
56
56
|
},
|
|
57
|
+
// 모달 스택 관리
|
|
58
|
+
appendOpenModal: () => {
|
|
59
|
+
throw new Error("GlobalFormaContext must be used within GlobalFormaProvider");
|
|
60
|
+
},
|
|
61
|
+
removeOpenModal: () => {
|
|
62
|
+
throw new Error("GlobalFormaContext must be used within GlobalFormaProvider");
|
|
63
|
+
},
|
|
64
|
+
closeLastModal: () => {
|
|
65
|
+
throw new Error("GlobalFormaContext must be used within GlobalFormaProvider");
|
|
66
|
+
},
|
|
57
67
|
});
|
|
58
68
|
/**
|
|
59
69
|
* 글로벌 Forma 상태 관리 Provider | Global Forma state management provider
|
|
@@ -92,6 +102,10 @@ export function GlobalFormaProvider({ children }) {
|
|
|
92
102
|
const autoCleanupRefCountsRef = useRef(new Map());
|
|
93
103
|
// formId별 autoCleanup 설정을 추적하는 Map | Map tracking autoCleanup settings by formId
|
|
94
104
|
const autoCleanupSettingsRef = useRef(new Map());
|
|
105
|
+
// ========== 모달 스택 관리 상태 ==========
|
|
106
|
+
const [openModalIds, setOpenModalIds] = useState([]);
|
|
107
|
+
const openModalIdsRef = useRef([]);
|
|
108
|
+
const modalTrackingRef = useRef([]);
|
|
95
109
|
/**
|
|
96
110
|
* formId에 해당하는 FieldStore를 가져오거나 새로 생성합니다. | Get or create FieldStore for the given formId.
|
|
97
111
|
*
|
|
@@ -239,7 +253,64 @@ export function GlobalFormaProvider({ children }) {
|
|
|
239
253
|
}
|
|
240
254
|
}
|
|
241
255
|
};
|
|
256
|
+
// ========== 모달 및 네비게이션 관련 함수 ==========
|
|
257
|
+
/**
|
|
258
|
+
* 모달 등록
|
|
259
|
+
*/
|
|
260
|
+
const appendOpenModal = useCallback((modalId) => {
|
|
261
|
+
if (modalTrackingRef.current.includes(modalId))
|
|
262
|
+
return;
|
|
263
|
+
modalTrackingRef.current.push(modalId);
|
|
264
|
+
setOpenModalIds((prevIds) => {
|
|
265
|
+
const newOpenIds = [...prevIds, modalId];
|
|
266
|
+
return newOpenIds;
|
|
267
|
+
});
|
|
268
|
+
window.history.pushState({ modalOpen: modalId }, "", window.location.href);
|
|
269
|
+
}, []);
|
|
270
|
+
/**
|
|
271
|
+
* 모달 등록 해제
|
|
272
|
+
*/
|
|
273
|
+
const removeOpenModal = useCallback((modalId) => {
|
|
274
|
+
setOpenModalIds((prevIds) => {
|
|
275
|
+
if (prevIds.includes(modalId)) {
|
|
276
|
+
const newOpenIds = prevIds.filter((id) => id !== modalId);
|
|
277
|
+
modalTrackingRef.current = modalTrackingRef.current.filter((id) => id !== modalId);
|
|
278
|
+
return newOpenIds;
|
|
279
|
+
}
|
|
280
|
+
return prevIds;
|
|
281
|
+
});
|
|
282
|
+
}, []);
|
|
283
|
+
/**
|
|
284
|
+
* 마지막으로 열린 모달 닫기
|
|
285
|
+
*/
|
|
286
|
+
const closeLastModal = useCallback(() => {
|
|
287
|
+
if (openModalIds.length === 0)
|
|
288
|
+
return false;
|
|
289
|
+
const lastModalId = openModalIds[openModalIds.length - 1];
|
|
290
|
+
window.dispatchEvent(new CustomEvent(`modal:close:${lastModalId}`));
|
|
291
|
+
return true;
|
|
292
|
+
}, [openModalIds]);
|
|
293
|
+
// 모달 ID 추적을 위해 ref 업데이트
|
|
294
|
+
useEffect(() => {
|
|
295
|
+
openModalIdsRef.current = openModalIds;
|
|
296
|
+
}, [openModalIds]);
|
|
297
|
+
// popstate 이벤트 핸들러 (뒤로가기 시 모달 닫기)
|
|
298
|
+
useEffect(() => {
|
|
299
|
+
const handlePopState = (e) => {
|
|
300
|
+
// 열린 모달이 있으면 모달을 닫기
|
|
301
|
+
if (openModalIdsRef.current.length > 0) {
|
|
302
|
+
e.preventDefault();
|
|
303
|
+
closeLastModal();
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
window.addEventListener("popstate", handlePopState);
|
|
308
|
+
return () => {
|
|
309
|
+
window.removeEventListener("popstate", handlePopState);
|
|
310
|
+
};
|
|
311
|
+
}, [closeLastModal]);
|
|
242
312
|
const contextValue = {
|
|
313
|
+
// FieldStore 관련
|
|
243
314
|
getOrCreateStore,
|
|
244
315
|
registerStore,
|
|
245
316
|
unregisterStore,
|
|
@@ -247,6 +318,10 @@ export function GlobalFormaProvider({ children }) {
|
|
|
247
318
|
incrementRef,
|
|
248
319
|
decrementRef,
|
|
249
320
|
validateAndStoreAutoCleanupSetting,
|
|
321
|
+
// 모달 스택 관리
|
|
322
|
+
appendOpenModal,
|
|
323
|
+
removeOpenModal,
|
|
324
|
+
closeLastModal,
|
|
250
325
|
};
|
|
251
326
|
return (_jsx(GlobalFormaContext.Provider, { value: contextValue, children: children }));
|
|
252
327
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalFormaContext.js","sourceRoot":"","sources":["../../../contexts/GlobalFormaContext.tsx"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"GlobalFormaContext.js","sourceRoot":"","sources":["../../../contexts/GlobalFormaContext.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EACH,aAAa,EACb,MAAM,EAEN,QAAQ,EACR,SAAS,EACT,WAAW,GACd,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAyB;IACpE,gBAAgB;IAChB,gBAAgB,EAAE,GAAG,EAAE;QACnB,MAAM,IAAI,KAAK,CACX,4DAA4D,CAC/D,CAAC;IACN,CAAC;IACD,aAAa,EAAE,GAAG,EAAE;QAChB,MAAM,IAAI,KAAK,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obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import type { UseBreakpointReturn } from "../types/breakpoint";
|
|
25
|
+
/**
|
|
26
|
+
* useBreakpoint Hook
|
|
27
|
+
*
|
|
28
|
+
* Manages responsive breakpoint state for screen size detection.
|
|
29
|
+
* Provides both "down" (below threshold) and "up" (above threshold) states.
|
|
30
|
+
*
|
|
31
|
+
* 화면 크기 감지를 위한 반응형 브레이크포인트 상태를 관리합니다.
|
|
32
|
+
* "down" (임계값 이하) 및 "up" (임계값 이상) 상태를 모두 제공합니다.
|
|
33
|
+
*
|
|
34
|
+
* @returns {UseBreakpointReturn} Breakpoint state object
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* function ResponsiveComponent() {
|
|
39
|
+
* const breakpoint = useBreakpoint();
|
|
40
|
+
*
|
|
41
|
+
* return (
|
|
42
|
+
* <div>
|
|
43
|
+
* {breakpoint.smUp ? <DesktopView /> : <MobileView />}
|
|
44
|
+
* {breakpoint.mdUp && <SidebarNav />}
|
|
45
|
+
* </div>
|
|
46
|
+
* );
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare const useBreakpoint: () => UseBreakpointReturn;
|
|
51
|
+
//# sourceMappingURL=useBreakpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBreakpoint.d.ts","sourceRoot":"","sources":["../../../hooks/useBreakpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAY/D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,aAAa,QAAO,mBA4DhC,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 KIM YOUNG JIN (ehfuse@gmail.com)
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import { useState, useEffect } from "react";
|
|
25
|
+
// 브레이크포인트 정의 (픽셀 단위)
|
|
26
|
+
const breakpoints = {
|
|
27
|
+
xs: 0,
|
|
28
|
+
sm: 600,
|
|
29
|
+
md: 900,
|
|
30
|
+
lg: 1200,
|
|
31
|
+
xl: 1536,
|
|
32
|
+
xxl: 1920,
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* useBreakpoint Hook
|
|
36
|
+
*
|
|
37
|
+
* Manages responsive breakpoint state for screen size detection.
|
|
38
|
+
* Provides both "down" (below threshold) and "up" (above threshold) states.
|
|
39
|
+
*
|
|
40
|
+
* 화면 크기 감지를 위한 반응형 브레이크포인트 상태를 관리합니다.
|
|
41
|
+
* "down" (임계값 이하) 및 "up" (임계값 이상) 상태를 모두 제공합니다.
|
|
42
|
+
*
|
|
43
|
+
* @returns {UseBreakpointReturn} Breakpoint state object
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* function ResponsiveComponent() {
|
|
48
|
+
* const breakpoint = useBreakpoint();
|
|
49
|
+
*
|
|
50
|
+
* return (
|
|
51
|
+
* <div>
|
|
52
|
+
* {breakpoint.smUp ? <DesktopView /> : <MobileView />}
|
|
53
|
+
* {breakpoint.mdUp && <SidebarNav />}
|
|
54
|
+
* </div>
|
|
55
|
+
* );
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export const useBreakpoint = () => {
|
|
60
|
+
const [windowWidth, setWindowWidth] = useState(typeof window !== "undefined" ? window.innerWidth : 0);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (typeof window === "undefined")
|
|
63
|
+
return;
|
|
64
|
+
const handleResize = () => {
|
|
65
|
+
setWindowWidth(window.innerWidth);
|
|
66
|
+
};
|
|
67
|
+
window.addEventListener("resize", handleResize);
|
|
68
|
+
return () => window.removeEventListener("resize", handleResize);
|
|
69
|
+
}, []);
|
|
70
|
+
// 각 브레이크포인트별 미디어쿼리 결과 (해당 브레이크포인트 이하인지)
|
|
71
|
+
const xs = windowWidth < breakpoints.sm;
|
|
72
|
+
const sm = windowWidth < breakpoints.md;
|
|
73
|
+
const md = windowWidth < breakpoints.lg;
|
|
74
|
+
const lg = windowWidth < breakpoints.xl;
|
|
75
|
+
const xl = windowWidth < breakpoints.xxl;
|
|
76
|
+
const xxl = windowWidth >= breakpoints.xxl;
|
|
77
|
+
const xsUp = windowWidth >= breakpoints.xs;
|
|
78
|
+
const smUp = windowWidth >= breakpoints.sm;
|
|
79
|
+
const mdUp = windowWidth >= breakpoints.md;
|
|
80
|
+
const lgUp = windowWidth >= breakpoints.lg;
|
|
81
|
+
const xlUp = windowWidth >= breakpoints.xl;
|
|
82
|
+
const xxlUp = windowWidth >= breakpoints.xxl;
|
|
83
|
+
// 객체 형태로 반환하여 breakpoint.sm 식으로 접근 가능
|
|
84
|
+
return {
|
|
85
|
+
xs,
|
|
86
|
+
sm,
|
|
87
|
+
md,
|
|
88
|
+
lg,
|
|
89
|
+
xl,
|
|
90
|
+
xxl,
|
|
91
|
+
xsUp,
|
|
92
|
+
smUp,
|
|
93
|
+
mdUp,
|
|
94
|
+
lgUp,
|
|
95
|
+
xlUp,
|
|
96
|
+
xxlUp,
|
|
97
|
+
breakpoint: {
|
|
98
|
+
xs,
|
|
99
|
+
sm,
|
|
100
|
+
md,
|
|
101
|
+
lg,
|
|
102
|
+
xl,
|
|
103
|
+
xxl,
|
|
104
|
+
xsUp,
|
|
105
|
+
smUp,
|
|
106
|
+
mdUp,
|
|
107
|
+
lgUp,
|
|
108
|
+
xlUp,
|
|
109
|
+
xxlUp,
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=useBreakpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBreakpoint.js","sourceRoot":"","sources":["../../../hooks/useBreakpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAG5C,qBAAqB;AACrB,MAAM,WAAW,GAAG;IAChB,EAAE,EAAE,CAAC;IACL,EAAE,EAAE,GAAG;IACP,EAAE,EAAE,GAAG;IACP,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,GAAG,EAAE,IAAI;CACH,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAwB,EAAE;IACnD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAC1C,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CACxD,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,OAAO,MAAM,KAAK,WAAW;YAAE,OAAO;QAE1C,MAAM,YAAY,GAAG,GAAG,EAAE;YACtB,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACtC,CAAC,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAChD,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAA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|
+
* 모달 상태 관리 및 뒤로가기 처리를 위한 React Hook
|
|
5
|
+
* Modal state management and back navigation handling React Hook
|
|
6
|
+
*
|
|
7
|
+
* @license MIT License
|
|
8
|
+
* @copyright 2025 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
|
+
import { UseModalProps, UseModalReturn } from "../types/modal";
|
|
29
|
+
/**
|
|
30
|
+
* useModal - 모달 상태 관리 및 뒤로가기 처리 훅
|
|
31
|
+
*
|
|
32
|
+
* 모바일 환경에서 모달이 열려있을 때 뒤로가기를 누르면
|
|
33
|
+
* 페이지가 뒤로 가는 것이 아니라 모달이 닫히도록 처리합니다.
|
|
34
|
+
*
|
|
35
|
+
* Handles modal state and back navigation.
|
|
36
|
+
* When a modal is open and user presses back button,
|
|
37
|
+
* the modal closes instead of navigating back.
|
|
38
|
+
*
|
|
39
|
+
* @param props - initialOpen: 초기 열림 상태, onClose: 닫힐 때 콜백
|
|
40
|
+
* @returns isOpen, open, close, toggle, modalId
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* function MyComponent() {
|
|
45
|
+
* const modal = useModal({
|
|
46
|
+
* onClose: () => console.log('Modal closed')
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* return (
|
|
50
|
+
* <>
|
|
51
|
+
* <button onClick={modal.open}>Open Modal</button>
|
|
52
|
+
* <Dialog open={modal.isOpen} onClose={modal.close}>
|
|
53
|
+
* <DialogTitle>My Modal</DialogTitle>
|
|
54
|
+
* <DialogContent>Content here</DialogContent>
|
|
55
|
+
* </Dialog>
|
|
56
|
+
* </>
|
|
57
|
+
* );
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function useModal({ initialOpen, onClose: externalOnClose, }?: UseModalProps): UseModalReturn;
|
|
62
|
+
//# sourceMappingURL=useModal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useModal.d.ts","sourceRoot":"","sources":["../../../hooks/useModal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAWH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAU/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,QAAQ,CAAC,EACrB,WAAmB,EACnB,OAAO,EAAE,eAAe,GAC3B,GAAE,aAAkB,GAAG,cAAc,CAiGrC"}
|