@sellmate/design-system-react 1.0.46 → 1.0.47
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/components/components.d.ts +7 -0
- package/dist/components/components.js +13 -0
- package/dist/components/components.server.d.ts +7 -0
- package/dist/components/components.server.js +10 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/sdModal.d.ts +35 -0
- package/dist/sdModal.js +60 -0
- package/lib/components/components.server.ts +18 -0
- package/lib/components/components.ts +20 -0
- package/lib/index.ts +38 -36
- package/lib/sdModal.ts +99 -0
- package/package.json +2 -2
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
|
|
4
4
|
*/
|
|
5
5
|
import { type CheckedType, type DropdownButtonValue, type RadioValue, type SdBarcodeInputCustomEvent, type SdButtonCustomEvent, type SdButtonV2CustomEvent, type SdCheckboxCustomEvent, type SdDropdownButtonCustomEvent, type SdFilePickerCustomEvent, type SdInputCustomEvent, type SdNumberInputCustomEvent, type SdRadioButtonGroupCustomEvent, type SdRadioCustomEvent, type SdRadioGroupCustomEvent, type SdSelectCustomEvent, type SdSelectDropdownCustomEvent, type SdSelectGroupCustomEvent, type SdSelectMultipleCustomEvent, type SdSelectMultipleGroupCustomEvent, type SdSelectOptionCustomEvent, type SdSelectOptionGroupCustomEvent, type SdSelectV2CustomEvent, type SdSelectV2ListItemCustomEvent, type SdSelectV2ListboxCustomEvent, type SdTextareaCustomEvent, type SelectEvents, type SelectMultipleEvents, type SelectOption, type SelectOptionGroup, type SelectV2Option, type SelectV2OptionSelectDetail, type SelectV2Value } from "@sellmate/design-system";
|
|
6
|
+
import { SdActionModal as SdActionModalElement } from "@sellmate/design-system/dist/components/sd-action-modal.js";
|
|
6
7
|
import { SdBadge as SdBadgeElement } from "@sellmate/design-system/dist/components/sd-badge.js";
|
|
7
8
|
import { SdBarcodeInput as SdBarcodeInputElement } from "@sellmate/design-system/dist/components/sd-barcode-input.js";
|
|
8
9
|
import { SdButtonV2 as SdButtonV2Element } from "@sellmate/design-system/dist/components/sd-button-v2.js";
|
|
@@ -55,6 +56,11 @@ import { SdToggleButton as SdToggleButtonElement } from "@sellmate/design-system
|
|
|
55
56
|
import { SdToggle as SdToggleElement } from "@sellmate/design-system/dist/components/sd-toggle.js";
|
|
56
57
|
import { SdTooltip as SdTooltipElement } from "@sellmate/design-system/dist/components/sd-tooltip.js";
|
|
57
58
|
import type { EventName, StencilReactComponent } from '@stencil/react-output-target/runtime';
|
|
59
|
+
export type SdActionModalEvents = {
|
|
60
|
+
onSdClose: EventName<CustomEvent<void>>;
|
|
61
|
+
onSdOk: EventName<CustomEvent<void>>;
|
|
62
|
+
};
|
|
63
|
+
export declare const SdActionModal: StencilReactComponent<SdActionModalElement, SdActionModalEvents>;
|
|
58
64
|
export type SdBadgeEvents = NonNullable<unknown>;
|
|
59
65
|
export declare const SdBadge: StencilReactComponent<SdBadgeElement, SdBadgeEvents>;
|
|
60
66
|
export type SdBarcodeInputEvents = {
|
|
@@ -87,6 +93,7 @@ export type SdCheckboxEvents = {
|
|
|
87
93
|
export declare const SdCheckbox: StencilReactComponent<SdCheckboxElement, SdCheckboxEvents>;
|
|
88
94
|
export type SdConfirmModalEvents = {
|
|
89
95
|
onSdClose: EventName<CustomEvent<void>>;
|
|
96
|
+
onSdCancel: EventName<CustomEvent<void>>;
|
|
90
97
|
onSdOk: EventName<CustomEvent<void>>;
|
|
91
98
|
};
|
|
92
99
|
export declare const SdConfirmModal: StencilReactComponent<SdConfirmModalElement, SdConfirmModalEvents>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { SdActionModal as SdActionModalElement, defineCustomElement as defineSdActionModal } from "@sellmate/design-system/dist/components/sd-action-modal.js";
|
|
2
3
|
import { SdBadge as SdBadgeElement, defineCustomElement as defineSdBadge } from "@sellmate/design-system/dist/components/sd-badge.js";
|
|
3
4
|
import { SdBarcodeInput as SdBarcodeInputElement, defineCustomElement as defineSdBarcodeInput } from "@sellmate/design-system/dist/components/sd-barcode-input.js";
|
|
4
5
|
import { SdButtonV2 as SdButtonV2Element, defineCustomElement as defineSdButtonV2 } from "@sellmate/design-system/dist/components/sd-button-v2.js";
|
|
@@ -52,6 +53,17 @@ import { SdToggle as SdToggleElement, defineCustomElement as defineSdToggle } fr
|
|
|
52
53
|
import { SdTooltip as SdTooltipElement, defineCustomElement as defineSdTooltip } from "@sellmate/design-system/dist/components/sd-tooltip.js";
|
|
53
54
|
import { createComponent } from '@stencil/react-output-target/runtime';
|
|
54
55
|
import React from 'react';
|
|
56
|
+
export const SdActionModal = /*@__PURE__*/ createComponent({
|
|
57
|
+
tagName: 'sd-action-modal',
|
|
58
|
+
elementClass: SdActionModalElement,
|
|
59
|
+
// @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
|
|
60
|
+
react: React,
|
|
61
|
+
events: {
|
|
62
|
+
onSdClose: 'sdClose',
|
|
63
|
+
onSdOk: 'sdOk'
|
|
64
|
+
},
|
|
65
|
+
defineCustomElement: defineSdActionModal
|
|
66
|
+
});
|
|
55
67
|
export const SdBadge = /*@__PURE__*/ createComponent({
|
|
56
68
|
tagName: 'sd-badge',
|
|
57
69
|
elementClass: SdBadgeElement,
|
|
@@ -122,6 +134,7 @@ export const SdConfirmModal = /*@__PURE__*/ createComponent({
|
|
|
122
134
|
react: React,
|
|
123
135
|
events: {
|
|
124
136
|
onSdClose: 'sdClose',
|
|
137
|
+
onSdCancel: 'sdCancel',
|
|
125
138
|
onSdOk: 'sdOk'
|
|
126
139
|
},
|
|
127
140
|
defineCustomElement: defineSdConfirmModal
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
|
|
4
4
|
*/
|
|
5
5
|
import { type CheckedType, type DropdownButtonValue, type RadioValue, type SdBarcodeInputCustomEvent, type SdButtonCustomEvent, type SdButtonV2CustomEvent, type SdCheckboxCustomEvent, type SdDropdownButtonCustomEvent, type SdFilePickerCustomEvent, type SdInputCustomEvent, type SdNumberInputCustomEvent, type SdRadioButtonGroupCustomEvent, type SdRadioCustomEvent, type SdRadioGroupCustomEvent, type SdSelectCustomEvent, type SdSelectDropdownCustomEvent, type SdSelectGroupCustomEvent, type SdSelectMultipleCustomEvent, type SdSelectMultipleGroupCustomEvent, type SdSelectOptionCustomEvent, type SdSelectOptionGroupCustomEvent, type SdSelectV2CustomEvent, type SdSelectV2ListItemCustomEvent, type SdSelectV2ListboxCustomEvent, type SdTextareaCustomEvent, type SelectEvents, type SelectMultipleEvents, type SelectOption, type SelectOptionGroup, type SelectV2Option, type SelectV2OptionSelectDetail, type SelectV2Value } from "@sellmate/design-system";
|
|
6
|
+
import { SdActionModal as SdActionModalElement } from "@sellmate/design-system/dist/components/sd-action-modal.js";
|
|
6
7
|
import { SdBadge as SdBadgeElement } from "@sellmate/design-system/dist/components/sd-badge.js";
|
|
7
8
|
import { SdBarcodeInput as SdBarcodeInputElement } from "@sellmate/design-system/dist/components/sd-barcode-input.js";
|
|
8
9
|
import { SdButtonV2 as SdButtonV2Element } from "@sellmate/design-system/dist/components/sd-button-v2.js";
|
|
@@ -57,6 +58,11 @@ import { SdTooltip as SdTooltipElement } from "@sellmate/design-system/dist/comp
|
|
|
57
58
|
import type { EventName, StencilReactComponent } from '@stencil/react-output-target/runtime';
|
|
58
59
|
import { type SerializeShadowRootOptions } from '@stencil/react-output-target/ssr';
|
|
59
60
|
export declare const serializeShadowRoot: SerializeShadowRootOptions;
|
|
61
|
+
export type SdActionModalEvents = {
|
|
62
|
+
onSdClose: EventName<CustomEvent<void>>;
|
|
63
|
+
onSdOk: EventName<CustomEvent<void>>;
|
|
64
|
+
};
|
|
65
|
+
export declare const SdActionModal: StencilReactComponent<SdActionModalElement, SdActionModalEvents>;
|
|
60
66
|
export type SdBadgeEvents = NonNullable<unknown>;
|
|
61
67
|
export declare const SdBadge: StencilReactComponent<SdBadgeElement, SdBadgeEvents>;
|
|
62
68
|
export type SdBarcodeInputEvents = {
|
|
@@ -89,6 +95,7 @@ export type SdCheckboxEvents = {
|
|
|
89
95
|
export declare const SdCheckbox: StencilReactComponent<SdCheckboxElement, SdCheckboxEvents>;
|
|
90
96
|
export type SdConfirmModalEvents = {
|
|
91
97
|
onSdClose: EventName<CustomEvent<void>>;
|
|
98
|
+
onSdCancel: EventName<CustomEvent<void>>;
|
|
92
99
|
onSdOk: EventName<CustomEvent<void>>;
|
|
93
100
|
};
|
|
94
101
|
export declare const SdConfirmModal: StencilReactComponent<SdConfirmModalElement, SdConfirmModalEvents>;
|
|
@@ -7,6 +7,16 @@
|
|
|
7
7
|
import * as clientComponents from '@sellmate/design-system-react';
|
|
8
8
|
import { createComponent } from '@stencil/react-output-target/ssr';
|
|
9
9
|
export const serializeShadowRoot = { default: "declarative-shadow-dom" };
|
|
10
|
+
export const SdActionModal = /*@__PURE__*/ createComponent({
|
|
11
|
+
tagName: 'sd-action-modal',
|
|
12
|
+
properties: {
|
|
13
|
+
title: 'title',
|
|
14
|
+
buttonLabel: 'button-label'
|
|
15
|
+
},
|
|
16
|
+
hydrateModule: import('@sellmate/design-system/hydrate'),
|
|
17
|
+
clientModule: clientComponents.SdActionModal,
|
|
18
|
+
serializeShadowRoot,
|
|
19
|
+
});
|
|
10
20
|
export const SdBadge = /*@__PURE__*/ createComponent({
|
|
11
21
|
tagName: 'sd-badge',
|
|
12
22
|
properties: {
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,6 @@ export * from './components/components.js';
|
|
|
2
2
|
export { defineCustomElements } from '@sellmate/design-system/loader';
|
|
3
3
|
export { SdTable } from './SdTable';
|
|
4
4
|
export type { SdTableProps } from './SdTable';
|
|
5
|
+
export { sdModal } from './sdModal';
|
|
6
|
+
export type { SdModalCreateOption } from './sdModal';
|
|
5
7
|
export type { SdTableSortDir, SdTableColumn, Row as SdTableRow, SelectOption, SelectOptionGroup, SelectEvents, SelectMultipleEvents, SelectStyleProps, RadioValue, RadioOption, ButtonVariant, ButtonSize, ButtonV2Name, DropdownButtonItem, DropdownButtonName, DropdownButtonSize, DropdownButtonValue, Rule, ValidatableField, SdTooltipProps, TagName, ToastType, CheckedType, Type as DateBoxType, TabOption, } from '@sellmate/design-system';
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ComponentType } from 'react';
|
|
2
|
+
import { type ConfirmModalOptions, type ModalDialogChain, type SdModalCreateOption as CoreSdModalCreateOption, type SdModalGlobalOptions } from '@sellmate/design-system/utils';
|
|
3
|
+
/**
|
|
4
|
+
* `sdModal.create` 에 넘기는 입력.
|
|
5
|
+
*
|
|
6
|
+
* - `component` 에 HTMLElement 를 넘기면 core `sdModal.create` 로 바로 위임합니다.
|
|
7
|
+
* 이 경우 `componentProps` 는 무시됩니다.
|
|
8
|
+
* - `component` 에 React 컴포넌트(`ComponentType`) 를 넘기면 `componentProps` 로
|
|
9
|
+
* props 를 지정해 `createRoot + flushSync` 로 렌더한 뒤 core 로 위임합니다.
|
|
10
|
+
* - `persist` 는 core 옵션을 그대로 전달합니다.
|
|
11
|
+
*/
|
|
12
|
+
export interface SdModalCreateOption extends Omit<CoreSdModalCreateOption, 'component'> {
|
|
13
|
+
component: HTMLElement | ComponentType<any>;
|
|
14
|
+
componentProps?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* React-aware `sdModal`.
|
|
18
|
+
*
|
|
19
|
+
* - `sdModal.confirm(options)` — core 와 동일
|
|
20
|
+
* - `sdModal.create({ component, componentProps?, persist? })` —
|
|
21
|
+
* `component` 가 HTMLElement 면 core 로 위임, React 컴포넌트면
|
|
22
|
+
* `createRoot + flushSync` 로 렌더한 뒤 위임합니다. 모달이 닫히면
|
|
23
|
+
* 자동으로 언마운트됩니다.
|
|
24
|
+
*
|
|
25
|
+
* 주의: React 의 `createRoot` 는 새 React 트리를 만들기 때문에 부모 트리의
|
|
26
|
+
* Context Provider(Redux store, React Router, Theme 등) 를 상속받지 못합니다.
|
|
27
|
+
* 모달 내부에서 Context 가 필요하면 전달하는 컴포넌트 내부에서 직접 Provider 로
|
|
28
|
+
* 감싸주세요.
|
|
29
|
+
*/
|
|
30
|
+
export declare const sdModal: {
|
|
31
|
+
confirm(options: ConfirmModalOptions): ModalDialogChain;
|
|
32
|
+
configure(options: SdModalGlobalOptions): void;
|
|
33
|
+
create(input: SdModalCreateOption): ModalDialogChain;
|
|
34
|
+
};
|
|
35
|
+
export default sdModal;
|
package/dist/sdModal.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createElement } from 'react';
|
|
3
|
+
import { flushSync } from 'react-dom';
|
|
4
|
+
import { createRoot } from 'react-dom/client';
|
|
5
|
+
import { sdModal as coreSdModal, } from '@sellmate/design-system/utils';
|
|
6
|
+
function isHTMLElement(value) {
|
|
7
|
+
return typeof HTMLElement !== 'undefined' && value instanceof HTMLElement;
|
|
8
|
+
}
|
|
9
|
+
function mountReactComponent(component, componentProps) {
|
|
10
|
+
const host = document.createElement('div');
|
|
11
|
+
const root = createRoot(host);
|
|
12
|
+
// flushSync 로 동기 렌더 → firstElementChild 즉시 접근 가능
|
|
13
|
+
flushSync(() => {
|
|
14
|
+
root.render(createElement(component, componentProps));
|
|
15
|
+
});
|
|
16
|
+
const el = host.firstElementChild;
|
|
17
|
+
if (!el) {
|
|
18
|
+
root.unmount();
|
|
19
|
+
throw new Error('[sdModal] 전달한 React 컴포넌트의 루트는 단일 요소여야 합니다.');
|
|
20
|
+
}
|
|
21
|
+
return { el, host, root };
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* React-aware `sdModal`.
|
|
25
|
+
*
|
|
26
|
+
* - `sdModal.confirm(options)` — core 와 동일
|
|
27
|
+
* - `sdModal.create({ component, componentProps?, persist? })` —
|
|
28
|
+
* `component` 가 HTMLElement 면 core 로 위임, React 컴포넌트면
|
|
29
|
+
* `createRoot + flushSync` 로 렌더한 뒤 위임합니다. 모달이 닫히면
|
|
30
|
+
* 자동으로 언마운트됩니다.
|
|
31
|
+
*
|
|
32
|
+
* 주의: React 의 `createRoot` 는 새 React 트리를 만들기 때문에 부모 트리의
|
|
33
|
+
* Context Provider(Redux store, React Router, Theme 등) 를 상속받지 못합니다.
|
|
34
|
+
* 모달 내부에서 Context 가 필요하면 전달하는 컴포넌트 내부에서 직접 Provider 로
|
|
35
|
+
* 감싸주세요.
|
|
36
|
+
*/
|
|
37
|
+
export const sdModal = {
|
|
38
|
+
confirm(options) {
|
|
39
|
+
return coreSdModal.confirm(options);
|
|
40
|
+
},
|
|
41
|
+
configure(options) {
|
|
42
|
+
coreSdModal.configure(options);
|
|
43
|
+
},
|
|
44
|
+
create(input) {
|
|
45
|
+
const { component, componentProps = {}, persist } = input;
|
|
46
|
+
// HTMLElement 오버로드: core 로 바로 위임
|
|
47
|
+
if (isHTMLElement(component)) {
|
|
48
|
+
return coreSdModal.create({ component, persist });
|
|
49
|
+
}
|
|
50
|
+
// React 컴포넌트 오버로드
|
|
51
|
+
const { el, host, root } = mountReactComponent(component, componentProps);
|
|
52
|
+
const chain = coreSdModal.create({ component: el, persist });
|
|
53
|
+
chain.onDismissed(() => {
|
|
54
|
+
root.unmount();
|
|
55
|
+
host.remove();
|
|
56
|
+
});
|
|
57
|
+
return chain;
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
export default sdModal;
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import * as clientComponents from '@sellmate/design-system-react';
|
|
10
10
|
|
|
11
11
|
import { type CheckedType, type DropdownButtonValue, type Event, type RadioValue, type SdBarcodeInputCustomEvent, type SdButtonCustomEvent, type SdButtonV2CustomEvent, type SdCheckboxCustomEvent, type SdDropdownButtonCustomEvent, type SdFilePickerCustomEvent, type SdInputCustomEvent, type SdNumberInputCustomEvent, type SdRadioButtonGroupCustomEvent, type SdRadioCustomEvent, type SdRadioGroupCustomEvent, type SdSelectCustomEvent, type SdSelectDropdownCustomEvent, type SdSelectGroupCustomEvent, type SdSelectMultipleCustomEvent, type SdSelectMultipleGroupCustomEvent, type SdSelectOptionCustomEvent, type SdSelectOptionGroupCustomEvent, type SdSelectV2CustomEvent, type SdSelectV2ListItemCustomEvent, type SdSelectV2ListboxCustomEvent, type SdTextareaCustomEvent, type SelectEvents, type SelectMultipleEvents, type SelectOption, type SelectOptionGroup, type SelectV2Option, type SelectV2OptionSelectDetail, type SelectV2Value } from "@sellmate/design-system";
|
|
12
|
+
import { SdActionModal as SdActionModalElement } from "@sellmate/design-system/dist/components/sd-action-modal.js";
|
|
12
13
|
import { SdBadge as SdBadgeElement } from "@sellmate/design-system/dist/components/sd-badge.js";
|
|
13
14
|
import { SdBarcodeInput as SdBarcodeInputElement } from "@sellmate/design-system/dist/components/sd-barcode-input.js";
|
|
14
15
|
import { SdButtonV2 as SdButtonV2Element } from "@sellmate/design-system/dist/components/sd-button-v2.js";
|
|
@@ -65,6 +66,22 @@ import { createComponent, type HydrateModule, type ReactWebComponent, type Seria
|
|
|
65
66
|
|
|
66
67
|
export const serializeShadowRoot: SerializeShadowRootOptions = { default: "declarative-shadow-dom" };
|
|
67
68
|
|
|
69
|
+
export type SdActionModalEvents = {
|
|
70
|
+
onSdClose: EventName<CustomEvent<void>>,
|
|
71
|
+
onSdOk: EventName<CustomEvent<void>>
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const SdActionModal: StencilReactComponent<SdActionModalElement, SdActionModalEvents> = /*@__PURE__*/ createComponent<SdActionModalElement, SdActionModalEvents>({
|
|
75
|
+
tagName: 'sd-action-modal',
|
|
76
|
+
properties: {
|
|
77
|
+
title: 'title',
|
|
78
|
+
buttonLabel: 'button-label'
|
|
79
|
+
},
|
|
80
|
+
hydrateModule: import('@sellmate/design-system/hydrate') as Promise<HydrateModule>,
|
|
81
|
+
clientModule: clientComponents.SdActionModal as ReactWebComponent<SdActionModalElement, SdActionModalEvents>,
|
|
82
|
+
serializeShadowRoot,
|
|
83
|
+
});
|
|
84
|
+
|
|
68
85
|
export type SdBadgeEvents = NonNullable<unknown>;
|
|
69
86
|
|
|
70
87
|
export const SdBadge: StencilReactComponent<SdBadgeElement, SdBadgeEvents> = /*@__PURE__*/ createComponent<SdBadgeElement, SdBadgeEvents>({
|
|
@@ -195,6 +212,7 @@ export const SdCheckbox: StencilReactComponent<SdCheckboxElement, SdCheckboxEven
|
|
|
195
212
|
|
|
196
213
|
export type SdConfirmModalEvents = {
|
|
197
214
|
onSdClose: EventName<CustomEvent<void>>,
|
|
215
|
+
onSdCancel: EventName<CustomEvent<void>>,
|
|
198
216
|
onSdOk: EventName<CustomEvent<void>>
|
|
199
217
|
};
|
|
200
218
|
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
/* eslint-disable */
|
|
9
9
|
|
|
10
10
|
import { type CheckedType, type DropdownButtonValue, type Event, type RadioValue, type SdBarcodeInputCustomEvent, type SdButtonCustomEvent, type SdButtonV2CustomEvent, type SdCheckboxCustomEvent, type SdDropdownButtonCustomEvent, type SdFilePickerCustomEvent, type SdInputCustomEvent, type SdNumberInputCustomEvent, type SdRadioButtonGroupCustomEvent, type SdRadioCustomEvent, type SdRadioGroupCustomEvent, type SdSelectCustomEvent, type SdSelectDropdownCustomEvent, type SdSelectGroupCustomEvent, type SdSelectMultipleCustomEvent, type SdSelectMultipleGroupCustomEvent, type SdSelectOptionCustomEvent, type SdSelectOptionGroupCustomEvent, type SdSelectV2CustomEvent, type SdSelectV2ListItemCustomEvent, type SdSelectV2ListboxCustomEvent, type SdTextareaCustomEvent, type SelectEvents, type SelectMultipleEvents, type SelectOption, type SelectOptionGroup, type SelectV2Option, type SelectV2OptionSelectDetail, type SelectV2Value } from "@sellmate/design-system";
|
|
11
|
+
import { SdActionModal as SdActionModalElement, defineCustomElement as defineSdActionModal } from "@sellmate/design-system/dist/components/sd-action-modal.js";
|
|
11
12
|
import { SdBadge as SdBadgeElement, defineCustomElement as defineSdBadge } from "@sellmate/design-system/dist/components/sd-badge.js";
|
|
12
13
|
import { SdBarcodeInput as SdBarcodeInputElement, defineCustomElement as defineSdBarcodeInput } from "@sellmate/design-system/dist/components/sd-barcode-input.js";
|
|
13
14
|
import { SdButtonV2 as SdButtonV2Element, defineCustomElement as defineSdButtonV2 } from "@sellmate/design-system/dist/components/sd-button-v2.js";
|
|
@@ -63,6 +64,23 @@ import type { EventName, StencilReactComponent } from '@stencil/react-output-tar
|
|
|
63
64
|
import { createComponent } from '@stencil/react-output-target/runtime';
|
|
64
65
|
import React from 'react';
|
|
65
66
|
|
|
67
|
+
export type SdActionModalEvents = {
|
|
68
|
+
onSdClose: EventName<CustomEvent<void>>,
|
|
69
|
+
onSdOk: EventName<CustomEvent<void>>
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const SdActionModal: StencilReactComponent<SdActionModalElement, SdActionModalEvents> = /*@__PURE__*/ createComponent<SdActionModalElement, SdActionModalEvents>({
|
|
73
|
+
tagName: 'sd-action-modal',
|
|
74
|
+
elementClass: SdActionModalElement,
|
|
75
|
+
// @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
|
|
76
|
+
react: React,
|
|
77
|
+
events: {
|
|
78
|
+
onSdClose: 'sdClose',
|
|
79
|
+
onSdOk: 'sdOk'
|
|
80
|
+
} as SdActionModalEvents,
|
|
81
|
+
defineCustomElement: defineSdActionModal
|
|
82
|
+
});
|
|
83
|
+
|
|
66
84
|
export type SdBadgeEvents = NonNullable<unknown>;
|
|
67
85
|
|
|
68
86
|
export const SdBadge: StencilReactComponent<SdBadgeElement, SdBadgeEvents> = /*@__PURE__*/ createComponent<SdBadgeElement, SdBadgeEvents>({
|
|
@@ -156,6 +174,7 @@ export const SdCheckbox: StencilReactComponent<SdCheckboxElement, SdCheckboxEven
|
|
|
156
174
|
|
|
157
175
|
export type SdConfirmModalEvents = {
|
|
158
176
|
onSdClose: EventName<CustomEvent<void>>,
|
|
177
|
+
onSdCancel: EventName<CustomEvent<void>>,
|
|
159
178
|
onSdOk: EventName<CustomEvent<void>>
|
|
160
179
|
};
|
|
161
180
|
|
|
@@ -166,6 +185,7 @@ export const SdConfirmModal: StencilReactComponent<SdConfirmModalElement, SdConf
|
|
|
166
185
|
react: React,
|
|
167
186
|
events: {
|
|
168
187
|
onSdClose: 'sdClose',
|
|
188
|
+
onSdCancel: 'sdCancel',
|
|
169
189
|
onSdOk: 'sdOk'
|
|
170
190
|
} as SdConfirmModalEvents,
|
|
171
191
|
defineCustomElement: defineSdConfirmModal
|
package/lib/index.ts
CHANGED
|
@@ -4,43 +4,45 @@ export * from './components/components.js';
|
|
|
4
4
|
export { defineCustomElements } from '@sellmate/design-system/loader';
|
|
5
5
|
export { SdTable } from './SdTable';
|
|
6
6
|
export type { SdTableProps } from './SdTable';
|
|
7
|
+
export { sdModal } from './sdModal';
|
|
8
|
+
export type { SdModalCreateOption } from './sdModal';
|
|
7
9
|
|
|
8
10
|
// Export commonly used types for React usage
|
|
9
11
|
export type {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
12
|
+
// Table types
|
|
13
|
+
SdTableSortDir,
|
|
14
|
+
SdTableColumn,
|
|
15
|
+
Row as SdTableRow,
|
|
16
|
+
// Select types
|
|
17
|
+
SelectOption,
|
|
18
|
+
SelectOptionGroup,
|
|
19
|
+
SelectEvents,
|
|
20
|
+
SelectMultipleEvents,
|
|
21
|
+
SelectStyleProps,
|
|
22
|
+
// Radio types
|
|
23
|
+
RadioValue,
|
|
24
|
+
RadioOption,
|
|
25
|
+
// Button types
|
|
26
|
+
ButtonVariant,
|
|
27
|
+
ButtonSize,
|
|
28
|
+
ButtonV2Name,
|
|
29
|
+
DropdownButtonItem,
|
|
30
|
+
DropdownButtonName,
|
|
31
|
+
DropdownButtonSize,
|
|
32
|
+
DropdownButtonValue,
|
|
33
|
+
// Form types
|
|
34
|
+
Rule,
|
|
35
|
+
ValidatableField,
|
|
36
|
+
// Tooltip types
|
|
37
|
+
SdTooltipProps,
|
|
38
|
+
// Tag types
|
|
39
|
+
TagName,
|
|
40
|
+
// Toast types
|
|
41
|
+
ToastType,
|
|
42
|
+
// Checkbox types
|
|
43
|
+
CheckedType,
|
|
44
|
+
// Date types
|
|
45
|
+
Type as DateBoxType,
|
|
46
|
+
// Tab types
|
|
47
|
+
TabOption,
|
|
46
48
|
} from '@sellmate/design-system';
|
package/lib/sdModal.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { createElement, type ComponentType } from 'react';
|
|
4
|
+
import { flushSync } from 'react-dom';
|
|
5
|
+
import { createRoot, type Root } from 'react-dom/client';
|
|
6
|
+
import {
|
|
7
|
+
sdModal as coreSdModal,
|
|
8
|
+
type ConfirmModalOptions,
|
|
9
|
+
type ModalDialogChain,
|
|
10
|
+
type SdModalCreateOption as CoreSdModalCreateOption,
|
|
11
|
+
type SdModalGlobalOptions,
|
|
12
|
+
} from '@sellmate/design-system/utils';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* `sdModal.create` 에 넘기는 입력.
|
|
16
|
+
*
|
|
17
|
+
* - `component` 에 HTMLElement 를 넘기면 core `sdModal.create` 로 바로 위임합니다.
|
|
18
|
+
* 이 경우 `componentProps` 는 무시됩니다.
|
|
19
|
+
* - `component` 에 React 컴포넌트(`ComponentType`) 를 넘기면 `componentProps` 로
|
|
20
|
+
* props 를 지정해 `createRoot + flushSync` 로 렌더한 뒤 core 로 위임합니다.
|
|
21
|
+
* - `persist` 는 core 옵션을 그대로 전달합니다.
|
|
22
|
+
*/
|
|
23
|
+
export interface SdModalCreateOption
|
|
24
|
+
extends Omit<CoreSdModalCreateOption, 'component'> {
|
|
25
|
+
component: HTMLElement | ComponentType<any>;
|
|
26
|
+
componentProps?: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function isHTMLElement(value: unknown): value is HTMLElement {
|
|
30
|
+
return typeof HTMLElement !== 'undefined' && value instanceof HTMLElement;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function mountReactComponent(
|
|
34
|
+
component: ComponentType<any>,
|
|
35
|
+
componentProps: Record<string, unknown>,
|
|
36
|
+
): { el: HTMLElement; host: HTMLElement; root: Root } {
|
|
37
|
+
const host = document.createElement('div');
|
|
38
|
+
const root = createRoot(host);
|
|
39
|
+
|
|
40
|
+
// flushSync 로 동기 렌더 → firstElementChild 즉시 접근 가능
|
|
41
|
+
flushSync(() => {
|
|
42
|
+
root.render(createElement(component, componentProps));
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const el = host.firstElementChild as HTMLElement | null;
|
|
46
|
+
if (!el) {
|
|
47
|
+
root.unmount();
|
|
48
|
+
throw new Error(
|
|
49
|
+
'[sdModal] 전달한 React 컴포넌트의 루트는 단일 요소여야 합니다.',
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return { el, host, root };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* React-aware `sdModal`.
|
|
58
|
+
*
|
|
59
|
+
* - `sdModal.confirm(options)` — core 와 동일
|
|
60
|
+
* - `sdModal.create({ component, componentProps?, persist? })` —
|
|
61
|
+
* `component` 가 HTMLElement 면 core 로 위임, React 컴포넌트면
|
|
62
|
+
* `createRoot + flushSync` 로 렌더한 뒤 위임합니다. 모달이 닫히면
|
|
63
|
+
* 자동으로 언마운트됩니다.
|
|
64
|
+
*
|
|
65
|
+
* 주의: React 의 `createRoot` 는 새 React 트리를 만들기 때문에 부모 트리의
|
|
66
|
+
* Context Provider(Redux store, React Router, Theme 등) 를 상속받지 못합니다.
|
|
67
|
+
* 모달 내부에서 Context 가 필요하면 전달하는 컴포넌트 내부에서 직접 Provider 로
|
|
68
|
+
* 감싸주세요.
|
|
69
|
+
*/
|
|
70
|
+
export const sdModal = {
|
|
71
|
+
confirm(options: ConfirmModalOptions): ModalDialogChain {
|
|
72
|
+
return coreSdModal.confirm(options);
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
configure(options: SdModalGlobalOptions): void {
|
|
76
|
+
coreSdModal.configure(options);
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
create(input: SdModalCreateOption): ModalDialogChain {
|
|
80
|
+
const { component, componentProps = {}, persist } = input;
|
|
81
|
+
|
|
82
|
+
// HTMLElement 오버로드: core 로 바로 위임
|
|
83
|
+
if (isHTMLElement(component)) {
|
|
84
|
+
return coreSdModal.create({ component, persist });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// React 컴포넌트 오버로드
|
|
88
|
+
const { el, host, root } = mountReactComponent(component, componentProps);
|
|
89
|
+
const chain = coreSdModal.create({ component: el, persist });
|
|
90
|
+
chain.onDismissed(() => {
|
|
91
|
+
root.unmount();
|
|
92
|
+
host.remove();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
return chain;
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export default sdModal;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sellmate/design-system-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.47",
|
|
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.
|
|
57
|
+
"@sellmate/design-system": "^1.0.47",
|
|
58
58
|
"@stencil/react-output-target": "^1.2.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|