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.
- package/dist/components/SModal/SModal.cjs +3869 -0
- package/dist/components/SModal/SModal.cjs.map +1 -0
- package/dist/components/SModal/SModal.d.ts +102 -0
- package/dist/components/SModal/SModal.js +3846 -0
- package/dist/components/SModal/SModal.js.map +1 -0
- package/dist/components/SModal/index.d.ts +1 -0
- package/dist/index.cjs +245 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +245 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SModal, type SModalRef, type SConfirmOptions, type SLoadingOptions, type SCreateOptions, type SModalCreateComponentProps, } from './SModal';
|
package/dist/index.cjs
CHANGED
|
@@ -5039,6 +5039,250 @@ function SLoadingModal({
|
|
|
5039
5039
|
}
|
|
5040
5040
|
);
|
|
5041
5041
|
}
|
|
5042
|
+
var EXIT_DURATION = 300;
|
|
5043
|
+
var EXIT_BUFFER = 100;
|
|
5044
|
+
var SModalRefImpl = class {
|
|
5045
|
+
constructor() {
|
|
5046
|
+
this.pendingClose = false;
|
|
5047
|
+
this.pendingPatches = [];
|
|
5048
|
+
this.dismissRequested = false;
|
|
5049
|
+
}
|
|
5050
|
+
onOk(fn) {
|
|
5051
|
+
this.okFn = fn;
|
|
5052
|
+
return this;
|
|
5053
|
+
}
|
|
5054
|
+
onCancel(fn) {
|
|
5055
|
+
this.cancelFn = fn;
|
|
5056
|
+
return this;
|
|
5057
|
+
}
|
|
5058
|
+
onClose(fn) {
|
|
5059
|
+
this.closeFn = fn;
|
|
5060
|
+
return this;
|
|
5061
|
+
}
|
|
5062
|
+
onClick(fn) {
|
|
5063
|
+
this.clickFn = fn;
|
|
5064
|
+
return this;
|
|
5065
|
+
}
|
|
5066
|
+
onSubmit(fn) {
|
|
5067
|
+
this.submitFn = fn;
|
|
5068
|
+
return this;
|
|
5069
|
+
}
|
|
5070
|
+
onDismissed(fn) {
|
|
5071
|
+
this.dismissedFn = fn;
|
|
5072
|
+
return this;
|
|
5073
|
+
}
|
|
5074
|
+
update(patch) {
|
|
5075
|
+
if (this.updateBinding) this.updateBinding(patch);
|
|
5076
|
+
else this.pendingPatches.push(patch);
|
|
5077
|
+
return this;
|
|
5078
|
+
}
|
|
5079
|
+
// 닫힘 트리거 — 이미 닫힘이 시작됐으면 무시(중복 콜백 방지)
|
|
5080
|
+
settle(emit2) {
|
|
5081
|
+
if (this.dismissRequested) return;
|
|
5082
|
+
this.dismissRequested = true;
|
|
5083
|
+
emit2();
|
|
5084
|
+
if (this.closeBinding) this.closeBinding();
|
|
5085
|
+
else this.pendingClose = true;
|
|
5086
|
+
}
|
|
5087
|
+
ok() {
|
|
5088
|
+
this.settle(() => this.okFn?.());
|
|
5089
|
+
return this;
|
|
5090
|
+
}
|
|
5091
|
+
cancel() {
|
|
5092
|
+
this.settle(() => this.cancelFn?.());
|
|
5093
|
+
return this;
|
|
5094
|
+
}
|
|
5095
|
+
close() {
|
|
5096
|
+
this.settle(() => this.closeFn?.());
|
|
5097
|
+
return this;
|
|
5098
|
+
}
|
|
5099
|
+
submit() {
|
|
5100
|
+
this.submitFn?.();
|
|
5101
|
+
return this;
|
|
5102
|
+
}
|
|
5103
|
+
/** @internal 마운트 컴포넌트가 닫기 함수를 등록 (등록 전 close() 호출은 지연 반영) */
|
|
5104
|
+
_bindClose(fn) {
|
|
5105
|
+
this.closeBinding = fn;
|
|
5106
|
+
if (this.pendingClose) fn();
|
|
5107
|
+
}
|
|
5108
|
+
/** @internal 마운트 컴포넌트가 옵션 갱신 함수를 등록 (등록 전 update() 호출은 지연 반영) */
|
|
5109
|
+
_bindUpdate(fn) {
|
|
5110
|
+
this.updateBinding = fn;
|
|
5111
|
+
if (this.pendingPatches.length) {
|
|
5112
|
+
this.pendingPatches.forEach(fn);
|
|
5113
|
+
this.pendingPatches = [];
|
|
5114
|
+
}
|
|
5115
|
+
}
|
|
5116
|
+
/** @internal 정리 대상(root·host) 주입 */
|
|
5117
|
+
_setTeardown(root, host) {
|
|
5118
|
+
this.root = root;
|
|
5119
|
+
this.host = host;
|
|
5120
|
+
}
|
|
5121
|
+
/** @internal 닫힘 시작 표시 — 컴포넌트 버튼·백드롭·ESC 닫힘 경로가 호출(중복 트리거 방지) */
|
|
5122
|
+
_markDismissed() {
|
|
5123
|
+
this.dismissRequested = true;
|
|
5124
|
+
}
|
|
5125
|
+
/** @internal confirm 버튼 경로에서 onOk 발화 */
|
|
5126
|
+
_emitOk() {
|
|
5127
|
+
this.okFn?.();
|
|
5128
|
+
}
|
|
5129
|
+
/** @internal confirm 버튼 경로에서 onCancel 발화 */
|
|
5130
|
+
_emitCancel() {
|
|
5131
|
+
this.cancelFn?.();
|
|
5132
|
+
}
|
|
5133
|
+
/** @internal 닫기(X) 경로에서 onClose 발화 */
|
|
5134
|
+
_emitClose() {
|
|
5135
|
+
this.closeFn?.();
|
|
5136
|
+
}
|
|
5137
|
+
/** @internal loading 버튼 경로에서 onClick 발화 */
|
|
5138
|
+
_emitClick() {
|
|
5139
|
+
this.clickFn?.();
|
|
5140
|
+
}
|
|
5141
|
+
/** @internal */
|
|
5142
|
+
_emitDismissed() {
|
|
5143
|
+
this.dismissedFn?.();
|
|
5144
|
+
}
|
|
5145
|
+
/** @internal 닫힘 애니메이션 종료 후 언마운트 */
|
|
5146
|
+
_teardown() {
|
|
5147
|
+
this.root?.unmount();
|
|
5148
|
+
this.host?.remove();
|
|
5149
|
+
}
|
|
5150
|
+
};
|
|
5151
|
+
function useExitTeardown(open, refImpl) {
|
|
5152
|
+
const dismissedRef = react.useRef(false);
|
|
5153
|
+
react.useEffect(() => {
|
|
5154
|
+
if (open || dismissedRef.current) return;
|
|
5155
|
+
dismissedRef.current = true;
|
|
5156
|
+
const t = setTimeout(() => {
|
|
5157
|
+
refImpl._emitDismissed();
|
|
5158
|
+
refImpl._teardown();
|
|
5159
|
+
}, EXIT_DURATION + EXIT_BUFFER);
|
|
5160
|
+
return () => clearTimeout(t);
|
|
5161
|
+
}, [open, refImpl]);
|
|
5162
|
+
}
|
|
5163
|
+
function ConfirmMount({ options, refImpl }) {
|
|
5164
|
+
const [open, setOpen] = react.useState(true);
|
|
5165
|
+
const [opts, setOpts] = react.useState(options);
|
|
5166
|
+
react.useEffect(() => {
|
|
5167
|
+
refImpl._bindClose(() => setOpen(false));
|
|
5168
|
+
refImpl._bindUpdate((patch) => setOpts((prev) => ({ ...prev, ...patch })));
|
|
5169
|
+
}, [refImpl]);
|
|
5170
|
+
useExitTeardown(open, refImpl);
|
|
5171
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5172
|
+
SConfirmModal,
|
|
5173
|
+
{
|
|
5174
|
+
...opts,
|
|
5175
|
+
open,
|
|
5176
|
+
onOpenChange: (o) => {
|
|
5177
|
+
if (!o) refImpl._markDismissed();
|
|
5178
|
+
setOpen(o);
|
|
5179
|
+
},
|
|
5180
|
+
onOk: () => refImpl._emitOk(),
|
|
5181
|
+
onCancel: () => refImpl._emitCancel(),
|
|
5182
|
+
onClose: () => refImpl._emitClose()
|
|
5183
|
+
}
|
|
5184
|
+
);
|
|
5185
|
+
}
|
|
5186
|
+
function LoadingMount({ options, refImpl }) {
|
|
5187
|
+
const [open, setOpen] = react.useState(true);
|
|
5188
|
+
const [opts, setOpts] = react.useState(options);
|
|
5189
|
+
const buttonClicked = react.useRef(false);
|
|
5190
|
+
react.useEffect(() => {
|
|
5191
|
+
refImpl._bindClose(() => setOpen(false));
|
|
5192
|
+
refImpl._bindUpdate((patch) => setOpts((prev) => ({ ...prev, ...patch })));
|
|
5193
|
+
}, [refImpl]);
|
|
5194
|
+
useExitTeardown(open, refImpl);
|
|
5195
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5196
|
+
SLoadingModal,
|
|
5197
|
+
{
|
|
5198
|
+
...opts,
|
|
5199
|
+
open,
|
|
5200
|
+
onOpenChange: (o) => {
|
|
5201
|
+
if (!o && buttonClicked.current) {
|
|
5202
|
+
buttonClicked.current = false;
|
|
5203
|
+
return;
|
|
5204
|
+
}
|
|
5205
|
+
if (!o) refImpl._markDismissed();
|
|
5206
|
+
setOpen(o);
|
|
5207
|
+
},
|
|
5208
|
+
onClose: () => refImpl._emitClose(),
|
|
5209
|
+
onButtonClick: () => {
|
|
5210
|
+
buttonClicked.current = true;
|
|
5211
|
+
refImpl._emitClick();
|
|
5212
|
+
}
|
|
5213
|
+
}
|
|
5214
|
+
);
|
|
5215
|
+
}
|
|
5216
|
+
function CreateMount({ options, refImpl }) {
|
|
5217
|
+
const {
|
|
5218
|
+
component: Component,
|
|
5219
|
+
componentProps,
|
|
5220
|
+
persistent,
|
|
5221
|
+
showClose,
|
|
5222
|
+
width,
|
|
5223
|
+
height,
|
|
5224
|
+
className,
|
|
5225
|
+
ariaTitle
|
|
5226
|
+
} = options;
|
|
5227
|
+
const [open, setOpen] = react.useState(true);
|
|
5228
|
+
react.useEffect(() => {
|
|
5229
|
+
refImpl._bindClose(() => setOpen(false));
|
|
5230
|
+
refImpl._bindUpdate(() => {
|
|
5231
|
+
});
|
|
5232
|
+
}, [refImpl]);
|
|
5233
|
+
useExitTeardown(open, refImpl);
|
|
5234
|
+
const componentAllProps = {
|
|
5235
|
+
...componentProps,
|
|
5236
|
+
modalRef: refImpl
|
|
5237
|
+
};
|
|
5238
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5239
|
+
SModalContainer,
|
|
5240
|
+
{
|
|
5241
|
+
open,
|
|
5242
|
+
onOpenChange: (o) => {
|
|
5243
|
+
if (!o) refImpl._markDismissed();
|
|
5244
|
+
setOpen(o);
|
|
5245
|
+
},
|
|
5246
|
+
persistent,
|
|
5247
|
+
showClose,
|
|
5248
|
+
onClose: () => refImpl.close(),
|
|
5249
|
+
ariaTitle,
|
|
5250
|
+
width,
|
|
5251
|
+
height,
|
|
5252
|
+
className,
|
|
5253
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Component, { ...componentAllProps })
|
|
5254
|
+
}
|
|
5255
|
+
);
|
|
5256
|
+
}
|
|
5257
|
+
function mount(render) {
|
|
5258
|
+
const host = document.createElement("div");
|
|
5259
|
+
document.body.appendChild(host);
|
|
5260
|
+
const refImpl = new SModalRefImpl();
|
|
5261
|
+
const root = client.createRoot(host);
|
|
5262
|
+
refImpl._setTeardown(root, host);
|
|
5263
|
+
root.render(render(refImpl));
|
|
5264
|
+
return refImpl;
|
|
5265
|
+
}
|
|
5266
|
+
var SModal = {
|
|
5267
|
+
/** 확인/취소 모달을 즉시 띄운다. 반환 핸들에 onOk/onCancel/onClose/onDismissed 체이닝. */
|
|
5268
|
+
confirm(options) {
|
|
5269
|
+
return mount((refImpl) => /* @__PURE__ */ jsxRuntime.jsx(ConfirmMount, { options, refImpl }));
|
|
5270
|
+
},
|
|
5271
|
+
/**
|
|
5272
|
+
* 로딩(스피너/에러) 모달을 즉시 띄운다. 로딩 중 임의 닫힘 방지를 위해 persistent 기본 true.
|
|
5273
|
+
* 버튼 클릭은 자동 닫힘 없이 onClick 만 발화 — update()/close() 로 후속 동작을 결정한다.
|
|
5274
|
+
*/
|
|
5275
|
+
loading(options = {}) {
|
|
5276
|
+
return mount((refImpl) => /* @__PURE__ */ jsxRuntime.jsx(LoadingMount, { options: { persistent: true, ...options }, refImpl }));
|
|
5277
|
+
},
|
|
5278
|
+
/**
|
|
5279
|
+
* 커스텀 React 컴포넌트를 SModalContainer(딤+카드) 안에 띄운다. component 에 modalRef 가
|
|
5280
|
+
* prop 으로 주입되어 컴포넌트가 ok()/cancel()/close()/submit()/onSubmit() 으로 자기 모달을 제어한다.
|
|
5281
|
+
*/
|
|
5282
|
+
create(options) {
|
|
5283
|
+
return mount((refImpl) => /* @__PURE__ */ jsxRuntime.jsx(CreateMount, { options, refImpl }));
|
|
5284
|
+
}
|
|
5285
|
+
};
|
|
5042
5286
|
|
|
5043
5287
|
// src/components/SGnb/gnb.config.ts
|
|
5044
5288
|
var gnb = (p) => `var(--cmp-gnb-${p})`;
|
|
@@ -11634,6 +11878,7 @@ exports.SLinearProgress = SLinearProgress;
|
|
|
11634
11878
|
exports.SLoadingContainer = SLoadingContainer;
|
|
11635
11879
|
exports.SLoadingModal = SLoadingModal;
|
|
11636
11880
|
exports.SLoadingViewport = SLoadingViewport;
|
|
11881
|
+
exports.SModal = SModal;
|
|
11637
11882
|
exports.SNumberInput = SNumberInput;
|
|
11638
11883
|
exports.SPage = SPage;
|
|
11639
11884
|
exports.SPagination = SPagination;
|