sellmate-design-system-react 0.11.0 → 0.12.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.
@@ -0,0 +1,102 @@
1
+ import { type ComponentType } from 'react';
2
+ import { type SConfirmModalProps } from '../SConfirmModal';
3
+ import { type SLoadingModalProps } from '../SLoadingModal';
4
+ /** SModal.confirm 옵션 — 제어 흐름을 서비스가 담당하므로 관련 props 는 제외 */
5
+ export type SConfirmOptions = Omit<SConfirmModalProps, 'open' | 'onOpenChange' | 'onOk' | 'onCancel' | 'onClose'>;
6
+ /** SModal.loading 옵션 — 제어 흐름을 서비스가 담당하므로 관련 props 는 제외 */
7
+ export type SLoadingOptions = Omit<SLoadingModalProps, 'open' | 'onOpenChange' | 'onClose' | 'onButtonClick'>;
8
+ /**
9
+ * create() 가 커스텀 컴포넌트에 주입하는 prop.
10
+ * (컴포넌트 문서 생성기 docs:gen 은 `*Props` interface 를 "컴포넌트"로 취급하므로,
11
+ * 서비스인 SModal 이 컴포넌트로 잘못 문서화되지 않도록 type 별칭으로 둔다. README 는 수작성.)
12
+ */
13
+ export type SModalCreateComponentProps = {
14
+ /** 모달 제어 핸들. 컴포넌트에서 ok()/cancel()/close()/submit()/onSubmit() 호출 */
15
+ modalRef: SModalRef;
16
+ };
17
+ /** SModal.create 옵션 — 커스텀 React 컴포넌트를 SModalContainer(딤+카드) 안에 렌더 */
18
+ export interface SCreateOptions<P extends object = Record<string, never>> {
19
+ /** 모달 본문으로 렌더할 컴포넌트. modalRef 가 prop 으로 주입된다. */
20
+ component: ComponentType<P & SModalCreateComponentProps>;
21
+ /** component 에 전달할 추가 props (modalRef 제외) */
22
+ componentProps?: P;
23
+ /** 백드롭·ESC 로 안 닫히고 흔들림 */
24
+ persistent?: boolean;
25
+ /** 우측 상단 닫기(X) 버튼 (기본 false) */
26
+ showClose?: boolean;
27
+ width?: number | string;
28
+ height?: number | string;
29
+ className?: string;
30
+ /** 접근성 제목 (스크린리더용) */
31
+ ariaTitle?: string;
32
+ }
33
+ /**
34
+ * SModal.confirm / loading / create 반환 핸들 — 체이닝 콜백 등록 + 트리거/update/close.
35
+ * 원본 sdModal 의 ModalDialogRef 와 동일하게 단일 타입이며, 모달 종류에 따라 관련 있는
36
+ * 메서드만 실제 발화한다(예: onOk/onCancel 은 confirm, onClick 은 loading, onSubmit 은 create).
37
+ */
38
+ export interface SModalRef {
39
+ /** 확인 버튼 클릭 (confirm) 또는 ok() 트리거 */
40
+ onOk(fn: () => void): SModalRef;
41
+ /** 취소(서브) 버튼 클릭 (confirm) 또는 cancel() 트리거 */
42
+ onCancel(fn: () => void): SModalRef;
43
+ /** 닫기(X) 버튼 클릭 또는 close() 트리거 */
44
+ onClose(fn: () => void): SModalRef;
45
+ /**
46
+ * 단일 버튼 모달(loading error 등)의 버튼 클릭. 자동 닫힘이 없으므로
47
+ * consumer 가 update()/close() 로 후속 동작을 결정한다. (원본 sdModal onClick)
48
+ */
49
+ onClick(fn: () => void): SModalRef;
50
+ /**
51
+ * create 커스텀 모달의 제출(submit). 자동 닫힘 없이 fn 만 호출하므로 API 응답을
52
+ * 받은 뒤 ok()/close()/update() 로 후속 동작을 결정한다. (원본 sdModal onSubmit)
53
+ */
54
+ onSubmit(fn: () => void): SModalRef;
55
+ /** 사유와 무관하게 모달이 완전히 닫혀 언마운트된 뒤 (백드롭·ESC 닫힘 포함) */
56
+ onDismissed(fn: () => void): SModalRef;
57
+ /** 표시 중 옵션 갱신 (loading→error, progress, 메시지 등). create 는 미지원. */
58
+ update(patch: Partial<SConfirmOptions & SLoadingOptions>): SModalRef;
59
+ /** onOk 트리거 + 닫기 (저장/처리 성공 시맨틱) */
60
+ ok(): SModalRef;
61
+ /** onCancel 트리거 + 닫기 (작업 취소 시맨틱) */
62
+ cancel(): SModalRef;
63
+ /** onClose 트리거 + 닫기 (중립적 닫기, persistent 여부와 무관) */
64
+ close(): SModalRef;
65
+ /** onSubmit 트리거 (닫힘 없음) — create 커스텀 컴포넌트가 제출 버튼에서 호출 */
66
+ submit(): SModalRef;
67
+ }
68
+ /**
69
+ * SModal — 명령형 모달 서비스.
70
+ *
71
+ * @example
72
+ * // 확인/취소
73
+ * SModal.confirm({ type: 'negative', modalTitle: '삭제하시겠습니까?', mainButtonLabel: '삭제', subButtonLabel: '취소' })
74
+ * .onOk(() => deleteItem())
75
+ * .onCancel(() => {});
76
+ *
77
+ * @example
78
+ * // 로딩 → 완료 or 에러
79
+ * const ref = SModal.loading({ message: '업로드 중...' });
80
+ * try { await upload(); ref.close(); }
81
+ * catch { ref.update({ state: 'error', message: '업로드 실패' }).onClick(() => retry()); }
82
+ *
83
+ * @example
84
+ * // 커스텀 컴포넌트 모달 — 컴포넌트가 modalRef 로 자기 모달 제어
85
+ * SModal.create({ component: OrderFormModal, componentProps: { orderId }, persistent: true })
86
+ * .onSubmit(async () => { await save(); ref.ok(); })
87
+ * .onDismissed(() => {});
88
+ */
89
+ export declare const SModal: {
90
+ /** 확인/취소 모달을 즉시 띄운다. 반환 핸들에 onOk/onCancel/onClose/onDismissed 체이닝. */
91
+ confirm(options: SConfirmOptions): SModalRef;
92
+ /**
93
+ * 로딩(스피너/에러) 모달을 즉시 띄운다. 로딩 중 임의 닫힘 방지를 위해 persistent 기본 true.
94
+ * 버튼 클릭은 자동 닫힘 없이 onClick 만 발화 — update()/close() 로 후속 동작을 결정한다.
95
+ */
96
+ loading(options?: SLoadingOptions): SModalRef;
97
+ /**
98
+ * 커스텀 React 컴포넌트를 SModalContainer(딤+카드) 안에 띄운다. component 에 modalRef 가
99
+ * prop 으로 주입되어 컴포넌트가 ok()/cancel()/close()/submit()/onSubmit() 으로 자기 모달을 제어한다.
100
+ */
101
+ create<P extends object = Record<string, never>>(options: SCreateOptions<P>): SModalRef;
102
+ };