@uniai-fe/ui-legacy 0.1.27 → 0.1.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniai-fe/ui-legacy",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "description": "Legacy UI Toolkit for UNIAI FE Projects",
5
5
  "type": "module",
6
6
  "private": false,
@@ -1,12 +1,17 @@
1
1
  "use client";
2
2
 
3
- import { FormProvider, useForm } from "react-hook-form";
3
+ import {
4
+ FormProvider,
5
+ type FieldValues,
6
+ type UseFormReturn,
7
+ } from "react-hook-form";
4
8
 
5
9
  export default function ModalFormProvider({
10
+ formMethods,
6
11
  children,
7
12
  }: {
13
+ formMethods: UseFormReturn<FieldValues>;
8
14
  children: React.ReactNode;
9
15
  }) {
10
- const formMethods = useForm({ mode: "all" });
11
16
  return <FormProvider {...formMethods}>{children}</FormProvider>;
12
17
  }
@@ -7,9 +7,29 @@ import ModalFormProvider from "../form/Provider";
7
7
 
8
8
  export default function ModalLayoutContainer({
9
9
  stackKey,
10
- modalProps: { data, isModalForm, formOptions, isHeader, isNoTitle },
10
+ modalProps: { data, formOptions, formMethods, isHeader, isNoTitle },
11
11
  isDraggable,
12
12
  }: ModalComponentPropsType) {
13
+ const layoutBody = (
14
+ <>
15
+ <ModalBody body={data?.body} />
16
+ {data?.footerBtns && <ModalFooter btns={data.footerBtns} />}
17
+ </>
18
+ );
19
+
20
+ // 변경 설명: 신규 formMethods가 있으면 해당 RHF context를 최우선으로 사용하고,
21
+ // 없을 때만 기존 formOptions 기반 provider를 유지해 서비스 호환성을 보존한다.
22
+ const content =
23
+ typeof formMethods !== "undefined" ? (
24
+ <ModalFormProvider formMethods={formMethods}>
25
+ {layoutBody}
26
+ </ModalFormProvider>
27
+ ) : typeof formOptions !== "undefined" ? (
28
+ <Form.Provider {...formOptions}>{layoutBody}</Form.Provider>
29
+ ) : (
30
+ layoutBody
31
+ );
32
+
13
33
  const Layout = (
14
34
  <>
15
35
  {isHeader && (
@@ -22,23 +42,9 @@ export default function ModalLayoutContainer({
22
42
  isNoTitle={isNoTitle}
23
43
  />
24
44
  )}
25
- {isModalForm ? (
26
- <ModalFormProvider>
27
- <ModalBody body={data?.body} />
28
- {data?.footerBtns && <ModalFooter btns={data.footerBtns} />}
29
- </ModalFormProvider>
30
- ) : (
31
- <>
32
- <ModalBody body={data?.body} />
33
- {data?.footerBtns && <ModalFooter btns={data.footerBtns} />}
34
- </>
35
- )}
45
+ {content}
36
46
  </>
37
47
  );
38
48
 
39
- return typeof formOptions !== "undefined" ? (
40
- <Form.Provider {...formOptions}>{Layout}</Form.Provider>
41
- ) : (
42
- Layout
43
- );
49
+ return Layout;
44
50
  }
@@ -25,6 +25,7 @@ export default function ModalBasicContainer({
25
25
  data,
26
26
  isModalForm,
27
27
  formOptions,
28
+ formMethods,
28
29
  isNoTitle,
29
30
  },
30
31
  } = stackData;
@@ -40,7 +41,14 @@ export default function ModalBasicContainer({
40
41
  >
41
42
  <ModalLayoutContainer
42
43
  stackKey={stackKey}
43
- modalProps={{ data, isModalForm, formOptions, isHeader, isNoTitle }}
44
+ modalProps={{
45
+ data,
46
+ isModalForm,
47
+ formOptions,
48
+ formMethods,
49
+ isHeader,
50
+ isNoTitle,
51
+ }}
44
52
  />
45
53
  </StyledModalBasic.container>
46
54
  );
@@ -1,5 +1,6 @@
1
1
  import type { LinkProps } from "next/link";
2
2
  import type { ButtonDefaultPropsType } from "../button";
3
+ import type { FieldValues, UseFormProps, UseFormReturn } from "react-hook-form";
3
4
 
4
5
  // 모달 활성화 타입
5
6
  export type ModalShowType = "init" | boolean;
@@ -60,16 +61,21 @@ export type ModalPropsType = Partial<{
60
61
  isFooter: boolean;
61
62
  initDragPos: ModalPositionDataType;
62
63
  /**
63
- * @deprecated formOptions대신 활용할 것. formOptions 여부로 form context 활성화
64
+ * @deprecated formMethods를 활용할 것.
64
65
  */
65
66
  isModalForm: boolean;
66
67
  /**
67
68
  * FormProvider 옵션
69
+ * @deprecated formMethods를 활용할 것.
68
70
  */
69
71
  formOptions: Partial<{
70
- options: UseFormProps<FormDataType>;
71
- callback: (params: UseFormReturn<FormDataType>) => void | undefined;
72
+ options: UseFormProps<FieldValues>;
73
+ callback: (params: UseFormReturn<FieldValues>) => void | undefined;
72
74
  }>;
75
+ /**
76
+ * modal context
77
+ */
78
+ formMethods: UseFormReturn<FieldValues>;
73
79
  role: string;
74
80
  show: ModalShowType; // init: 최초 렌더링 시 / on: 활성화 / off: 비활성화
75
81
  showDelay: number;