@sellmate/design-system-react 1.0.56 → 1.0.57

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/dist/sdModal.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type ComponentType } from 'react';
2
- import { type ConfirmModalOptions, type ModalDialogChain, type SdModalCreateOption as CoreSdModalCreateOption, type SdModalGlobalOptions } from '@sellmate/design-system/utils';
2
+ import { type ConfirmModalOptions, type ModalDialogRef, type SdModalCreateOption as CoreSdModalCreateOption, type SdModalGlobalOptions } from '@sellmate/design-system/utils';
3
3
  /**
4
4
  * `sdModal.create` 에 넘기는 입력.
5
5
  *
@@ -28,8 +28,8 @@ export interface SdModalCreateOption extends Omit<CoreSdModalCreateOption, 'comp
28
28
  * 감싸주세요.
29
29
  */
30
30
  export declare const sdModal: {
31
- confirm(options: ConfirmModalOptions): ModalDialogChain;
31
+ confirm(options: ConfirmModalOptions): ModalDialogRef;
32
32
  configure(options: SdModalGlobalOptions): void;
33
- create(input: SdModalCreateOption): ModalDialogChain;
33
+ create(input: SdModalCreateOption): ModalDialogRef;
34
34
  };
35
35
  export default sdModal;
package/dist/sdModal.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { createElement } from 'react';
3
3
  import { flushSync } from 'react-dom';
4
4
  import { createRoot } from 'react-dom/client';
5
- import { sdModal as coreSdModal, } from '@sellmate/design-system/utils';
5
+ import { sdModal as coreSdModal, _createSdModalRef, _attachSdModalWithRef, } from '@sellmate/design-system/utils';
6
6
  function isHTMLElement(value) {
7
7
  return typeof HTMLElement !== 'undefined' && value instanceof HTMLElement;
8
8
  }
@@ -47,14 +47,18 @@ export const sdModal = {
47
47
  if (isHTMLElement(component)) {
48
48
  return coreSdModal.create({ component, persist });
49
49
  }
50
- // React 컴포넌트 오버로드
51
- const { el, host, root } = mountReactComponent(component, componentProps);
52
- const chain = coreSdModal.create({ component: el, persist });
53
- chain.onDismissed(() => {
50
+ // React 컴포넌트 오버로드 — modalRef 를 먼저 만들어 props 에 주입한 뒤 mount
51
+ const modalRef = _createSdModalRef();
52
+ const { el, host, root } = mountReactComponent(component, {
53
+ ...componentProps,
54
+ modalRef,
55
+ });
56
+ _attachSdModalWithRef(modalRef, { component: el, persist });
57
+ modalRef.onDismissed(() => {
54
58
  root.unmount();
55
59
  host.remove();
56
60
  });
57
- return chain;
61
+ return modalRef;
58
62
  },
59
63
  };
60
64
  export default sdModal;
package/lib/sdModal.ts CHANGED
@@ -5,8 +5,10 @@ import { flushSync } from 'react-dom';
5
5
  import { createRoot, type Root } from 'react-dom/client';
6
6
  import {
7
7
  sdModal as coreSdModal,
8
+ _createSdModalRef,
9
+ _attachSdModalWithRef,
8
10
  type ConfirmModalOptions,
9
- type ModalDialogChain,
11
+ type ModalDialogRef,
10
12
  type SdModalCreateOption as CoreSdModalCreateOption,
11
13
  type SdModalGlobalOptions,
12
14
  } from '@sellmate/design-system/utils';
@@ -68,7 +70,7 @@ function mountReactComponent(
68
70
  * 감싸주세요.
69
71
  */
70
72
  export const sdModal = {
71
- confirm(options: ConfirmModalOptions): ModalDialogChain {
73
+ confirm(options: ConfirmModalOptions): ModalDialogRef {
72
74
  return coreSdModal.confirm(options);
73
75
  },
74
76
 
@@ -76,7 +78,7 @@ export const sdModal = {
76
78
  coreSdModal.configure(options);
77
79
  },
78
80
 
79
- create(input: SdModalCreateOption): ModalDialogChain {
81
+ create(input: SdModalCreateOption): ModalDialogRef {
80
82
  const { component, componentProps = {}, persist } = input;
81
83
 
82
84
  // HTMLElement 오버로드: core 로 바로 위임
@@ -84,15 +86,19 @@ export const sdModal = {
84
86
  return coreSdModal.create({ component, persist });
85
87
  }
86
88
 
87
- // React 컴포넌트 오버로드
88
- const { el, host, root } = mountReactComponent(component, componentProps);
89
- const chain = coreSdModal.create({ component: el, persist });
90
- chain.onDismissed(() => {
89
+ // React 컴포넌트 오버로드 — modalRef 를 먼저 만들어 props 에 주입한 뒤 mount
90
+ const modalRef = _createSdModalRef();
91
+ const { el, host, root } = mountReactComponent(component, {
92
+ ...componentProps,
93
+ modalRef,
94
+ });
95
+ _attachSdModalWithRef(modalRef, { component: el, persist });
96
+ modalRef.onDismissed(() => {
91
97
  root.unmount();
92
98
  host.remove();
93
99
  });
94
100
 
95
- return chain;
101
+ return modalRef;
96
102
  },
97
103
  };
98
104
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sellmate/design-system-react",
3
- "version": "1.0.56",
3
+ "version": "1.0.57",
4
4
  "description": "Design System - React Component Wrappers",
5
5
  "keywords": [
6
6
  "react",
@@ -54,7 +54,7 @@
54
54
  "dev": "tsc --watch"
55
55
  },
56
56
  "dependencies": {
57
- "@sellmate/design-system": "^1.0.56",
57
+ "@sellmate/design-system": "^1.0.57",
58
58
  "@stencil/react-output-target": "^1.2.0"
59
59
  },
60
60
  "peerDependencies": {