@uniai-fe/uds-templates 0.3.7 → 0.3.8

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/uds-templates",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "UNIAI Design System; UI Templates Package",
5
5
  "type": "module",
6
6
  "private": false,
@@ -1,6 +1,8 @@
1
1
  "use client";
2
2
 
3
3
  import clsx from "clsx";
4
+ import { useModal } from "../../hooks/useModal";
5
+ import { ModalHeaderCloseButton } from "../core/header/CloseButton";
4
6
 
5
7
  import type { DialogHeaderProps } from "../../types";
6
8
 
@@ -13,6 +15,8 @@ import type { DialogHeaderProps } from "../../types";
13
15
  * @param {"center" | "split"} [props.layout] 헤더 레이아웃
14
16
  * @param {React.ReactNode} [props.leadingContent] 타이틀 왼쪽 콘텐츠
15
17
  * @param {React.ReactNode} [props.trailingContent] 우측 액션 콘텐츠
18
+ * @param {string} [props.stackKey] 모달 스택 키(기본 닫기 버튼 동작 연결용)
19
+ * @param {boolean} [props.activeCloseButton] 우측 기본 닫기 버튼 활성화 여부
16
20
  * @param {string} [props.className] 헤더 className
17
21
  * @example
18
22
  * <DialogHeader title="제목" description="설명" />
@@ -23,10 +27,22 @@ export function DialogHeader({
23
27
  layout = "center",
24
28
  leadingContent,
25
29
  trailingContent,
30
+ stackKey,
31
+ activeCloseButton = false,
26
32
  className,
27
33
  }: DialogHeaderProps) {
34
+ const { closeModal } = useModal();
28
35
  const hasRight = Boolean(trailingContent);
29
36
  const hasDescription = Boolean(description);
37
+ const shouldRenderDefaultCloseButton =
38
+ activeCloseButton && !hasRight && Boolean(stackKey);
39
+ const resolvedTrailingContent = shouldRenderDefaultCloseButton ? (
40
+ <ModalHeaderCloseButton
41
+ onClick={() => closeModal({ stackKey: String(stackKey) })}
42
+ />
43
+ ) : (
44
+ trailingContent
45
+ );
30
46
  // 변경: title/description은 string | number일 때만 래핑한다.
31
47
  const shouldWrapTitleAsText = ["string", "number"].includes(typeof title);
32
48
  const shouldWrapDescriptionAsText = ["string", "number"].includes(
@@ -56,9 +72,9 @@ export function DialogHeader({
56
72
  {shouldWrapTitleAsText ? <h3>{title}</h3> : title}
57
73
  </div>
58
74
  </div>
59
- {hasRight ? (
75
+ {resolvedTrailingContent ? (
60
76
  <div className="uds-modal-dialog-header-trailing">
61
- {trailingContent}
77
+ {resolvedTrailingContent}
62
78
  </div>
63
79
  ) : null}
64
80
  </div>
@@ -44,6 +44,7 @@ function createDialogFormSubmitHandler(stackKey: string): () => void {
44
44
  * @param {"center" | "split"} [options.headerLayout] 헤더 레이아웃
45
45
  * @param {React.ReactNode} [options.headerLeadingContent] 타이틀 왼쪽 콘텐츠
46
46
  * @param {React.ReactNode} [options.headerTrailingContent] 우측 액션 콘텐츠
47
+ * @param {boolean} [options.activeCloseButton] 우측 기본 닫기 버튼 표시 여부
47
48
  * @param {string} [options.headerClassName] 헤더 className
48
49
  * @param {React.ReactNode} [options.customHeader] 완전 커스텀 header
49
50
  * @param {React.ReactNode} options.content 본문 콘텐츠
@@ -66,6 +67,7 @@ export function createDialogModal<FormContext extends FieldValues>({
66
67
  headerLayout,
67
68
  headerLeadingContent,
68
69
  headerTrailingContent,
70
+ activeCloseButton,
69
71
  headerClassName,
70
72
  customHeader,
71
73
  content,
@@ -99,6 +101,8 @@ export function createDialogModal<FormContext extends FieldValues>({
99
101
  layout={headerLayout}
100
102
  leadingContent={headerLeadingContent}
101
103
  trailingContent={headerTrailingContent}
104
+ stackKey={stackKey}
105
+ activeCloseButton={activeCloseButton}
102
106
  className={headerClassName}
103
107
  />
104
108
  ) : null);
@@ -256,6 +256,8 @@ export type AlertContentsProps = {
256
256
  * @property {ModalDialogHeaderLayout} [layout] 레이아웃 정보
257
257
  * @property {ReactNode} [leadingContent] 타이틀 왼쪽 콘텐츠
258
258
  * @property {ReactNode} [trailingContent] 우측 액션 콘텐츠
259
+ * @property {string} [stackKey] 모달 스택 키(기본 닫기 버튼 동작 연결용)
260
+ * @property {boolean} [activeCloseButton] 우측 기본 닫기 버튼 활성화 여부
259
261
  * @property {string} [className] 추가 className
260
262
  */
261
263
  export interface DialogHeaderProps {
@@ -279,6 +281,14 @@ export interface DialogHeaderProps {
279
281
  * 우측 액션 콘텐츠
280
282
  */
281
283
  trailingContent?: ReactNode;
284
+ /**
285
+ * 모달 스택 키(기본 닫기 버튼 동작 연결용)
286
+ */
287
+ stackKey?: string;
288
+ /**
289
+ * 우측 기본 닫기 버튼 활성화 여부
290
+ */
291
+ activeCloseButton?: boolean;
282
292
  /**
283
293
  * 추가 className
284
294
  */
@@ -135,6 +135,7 @@ export type AlertTemplateOptions<
135
135
  * @property {ModalDialogHeaderLayout} [headerLayout] 헤더 레이아웃
136
136
  * @property {ReactNode} [headerLeadingContent] 타이틀 왼쪽 콘텐츠
137
137
  * @property {ReactNode} [headerTrailingContent] 우측 액션 콘텐츠
138
+ * @property {boolean} [activeCloseButton] 우측 기본 닫기 버튼 표시 여부
138
139
  * @property {string} [headerClassName] header 추가 className
139
140
  * @property {ReactNode} [customHeader] 완전 커스텀 header
140
141
  * @property {ReactNode} content 본문 콘텐츠
@@ -169,6 +170,10 @@ export type DialogTemplateOptions<
169
170
  * 우측 액션 콘텐츠
170
171
  */
171
172
  headerTrailingContent?: ReactNode;
173
+ /**
174
+ * 우측 기본 닫기 버튼 표시 여부
175
+ */
176
+ activeCloseButton?: boolean;
172
177
  /**
173
178
  * header 추가 className
174
179
  */