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/index.d.ts CHANGED
@@ -26,6 +26,7 @@ export * from './components/SGuide';
26
26
  export * from './components/SConfirmModal';
27
27
  export * from './components/SActionModal';
28
28
  export * from './components/SLoadingModal';
29
+ export * from './components/SModal';
29
30
  export * from './components/SGnb';
30
31
  export * from './components/SLayout';
31
32
  export * from './components/SPage';
package/dist/index.js CHANGED
@@ -5011,6 +5011,250 @@ function SLoadingModal({
5011
5011
  }
5012
5012
  );
5013
5013
  }
5014
+ var EXIT_DURATION = 300;
5015
+ var EXIT_BUFFER = 100;
5016
+ var SModalRefImpl = class {
5017
+ constructor() {
5018
+ this.pendingClose = false;
5019
+ this.pendingPatches = [];
5020
+ this.dismissRequested = false;
5021
+ }
5022
+ onOk(fn) {
5023
+ this.okFn = fn;
5024
+ return this;
5025
+ }
5026
+ onCancel(fn) {
5027
+ this.cancelFn = fn;
5028
+ return this;
5029
+ }
5030
+ onClose(fn) {
5031
+ this.closeFn = fn;
5032
+ return this;
5033
+ }
5034
+ onClick(fn) {
5035
+ this.clickFn = fn;
5036
+ return this;
5037
+ }
5038
+ onSubmit(fn) {
5039
+ this.submitFn = fn;
5040
+ return this;
5041
+ }
5042
+ onDismissed(fn) {
5043
+ this.dismissedFn = fn;
5044
+ return this;
5045
+ }
5046
+ update(patch) {
5047
+ if (this.updateBinding) this.updateBinding(patch);
5048
+ else this.pendingPatches.push(patch);
5049
+ return this;
5050
+ }
5051
+ // 닫힘 트리거 — 이미 닫힘이 시작됐으면 무시(중복 콜백 방지)
5052
+ settle(emit2) {
5053
+ if (this.dismissRequested) return;
5054
+ this.dismissRequested = true;
5055
+ emit2();
5056
+ if (this.closeBinding) this.closeBinding();
5057
+ else this.pendingClose = true;
5058
+ }
5059
+ ok() {
5060
+ this.settle(() => this.okFn?.());
5061
+ return this;
5062
+ }
5063
+ cancel() {
5064
+ this.settle(() => this.cancelFn?.());
5065
+ return this;
5066
+ }
5067
+ close() {
5068
+ this.settle(() => this.closeFn?.());
5069
+ return this;
5070
+ }
5071
+ submit() {
5072
+ this.submitFn?.();
5073
+ return this;
5074
+ }
5075
+ /** @internal 마운트 컴포넌트가 닫기 함수를 등록 (등록 전 close() 호출은 지연 반영) */
5076
+ _bindClose(fn) {
5077
+ this.closeBinding = fn;
5078
+ if (this.pendingClose) fn();
5079
+ }
5080
+ /** @internal 마운트 컴포넌트가 옵션 갱신 함수를 등록 (등록 전 update() 호출은 지연 반영) */
5081
+ _bindUpdate(fn) {
5082
+ this.updateBinding = fn;
5083
+ if (this.pendingPatches.length) {
5084
+ this.pendingPatches.forEach(fn);
5085
+ this.pendingPatches = [];
5086
+ }
5087
+ }
5088
+ /** @internal 정리 대상(root·host) 주입 */
5089
+ _setTeardown(root, host) {
5090
+ this.root = root;
5091
+ this.host = host;
5092
+ }
5093
+ /** @internal 닫힘 시작 표시 — 컴포넌트 버튼·백드롭·ESC 닫힘 경로가 호출(중복 트리거 방지) */
5094
+ _markDismissed() {
5095
+ this.dismissRequested = true;
5096
+ }
5097
+ /** @internal confirm 버튼 경로에서 onOk 발화 */
5098
+ _emitOk() {
5099
+ this.okFn?.();
5100
+ }
5101
+ /** @internal confirm 버튼 경로에서 onCancel 발화 */
5102
+ _emitCancel() {
5103
+ this.cancelFn?.();
5104
+ }
5105
+ /** @internal 닫기(X) 경로에서 onClose 발화 */
5106
+ _emitClose() {
5107
+ this.closeFn?.();
5108
+ }
5109
+ /** @internal loading 버튼 경로에서 onClick 발화 */
5110
+ _emitClick() {
5111
+ this.clickFn?.();
5112
+ }
5113
+ /** @internal */
5114
+ _emitDismissed() {
5115
+ this.dismissedFn?.();
5116
+ }
5117
+ /** @internal 닫힘 애니메이션 종료 후 언마운트 */
5118
+ _teardown() {
5119
+ this.root?.unmount();
5120
+ this.host?.remove();
5121
+ }
5122
+ };
5123
+ function useExitTeardown(open, refImpl) {
5124
+ const dismissedRef = useRef(false);
5125
+ useEffect(() => {
5126
+ if (open || dismissedRef.current) return;
5127
+ dismissedRef.current = true;
5128
+ const t = setTimeout(() => {
5129
+ refImpl._emitDismissed();
5130
+ refImpl._teardown();
5131
+ }, EXIT_DURATION + EXIT_BUFFER);
5132
+ return () => clearTimeout(t);
5133
+ }, [open, refImpl]);
5134
+ }
5135
+ function ConfirmMount({ options, refImpl }) {
5136
+ const [open, setOpen] = useState(true);
5137
+ const [opts, setOpts] = useState(options);
5138
+ useEffect(() => {
5139
+ refImpl._bindClose(() => setOpen(false));
5140
+ refImpl._bindUpdate((patch) => setOpts((prev) => ({ ...prev, ...patch })));
5141
+ }, [refImpl]);
5142
+ useExitTeardown(open, refImpl);
5143
+ return /* @__PURE__ */ jsx(
5144
+ SConfirmModal,
5145
+ {
5146
+ ...opts,
5147
+ open,
5148
+ onOpenChange: (o) => {
5149
+ if (!o) refImpl._markDismissed();
5150
+ setOpen(o);
5151
+ },
5152
+ onOk: () => refImpl._emitOk(),
5153
+ onCancel: () => refImpl._emitCancel(),
5154
+ onClose: () => refImpl._emitClose()
5155
+ }
5156
+ );
5157
+ }
5158
+ function LoadingMount({ options, refImpl }) {
5159
+ const [open, setOpen] = useState(true);
5160
+ const [opts, setOpts] = useState(options);
5161
+ const buttonClicked = useRef(false);
5162
+ useEffect(() => {
5163
+ refImpl._bindClose(() => setOpen(false));
5164
+ refImpl._bindUpdate((patch) => setOpts((prev) => ({ ...prev, ...patch })));
5165
+ }, [refImpl]);
5166
+ useExitTeardown(open, refImpl);
5167
+ return /* @__PURE__ */ jsx(
5168
+ SLoadingModal,
5169
+ {
5170
+ ...opts,
5171
+ open,
5172
+ onOpenChange: (o) => {
5173
+ if (!o && buttonClicked.current) {
5174
+ buttonClicked.current = false;
5175
+ return;
5176
+ }
5177
+ if (!o) refImpl._markDismissed();
5178
+ setOpen(o);
5179
+ },
5180
+ onClose: () => refImpl._emitClose(),
5181
+ onButtonClick: () => {
5182
+ buttonClicked.current = true;
5183
+ refImpl._emitClick();
5184
+ }
5185
+ }
5186
+ );
5187
+ }
5188
+ function CreateMount({ options, refImpl }) {
5189
+ const {
5190
+ component: Component,
5191
+ componentProps,
5192
+ persistent,
5193
+ showClose,
5194
+ width,
5195
+ height,
5196
+ className,
5197
+ ariaTitle
5198
+ } = options;
5199
+ const [open, setOpen] = useState(true);
5200
+ useEffect(() => {
5201
+ refImpl._bindClose(() => setOpen(false));
5202
+ refImpl._bindUpdate(() => {
5203
+ });
5204
+ }, [refImpl]);
5205
+ useExitTeardown(open, refImpl);
5206
+ const componentAllProps = {
5207
+ ...componentProps,
5208
+ modalRef: refImpl
5209
+ };
5210
+ return /* @__PURE__ */ jsx(
5211
+ SModalContainer,
5212
+ {
5213
+ open,
5214
+ onOpenChange: (o) => {
5215
+ if (!o) refImpl._markDismissed();
5216
+ setOpen(o);
5217
+ },
5218
+ persistent,
5219
+ showClose,
5220
+ onClose: () => refImpl.close(),
5221
+ ariaTitle,
5222
+ width,
5223
+ height,
5224
+ className,
5225
+ children: /* @__PURE__ */ jsx(Component, { ...componentAllProps })
5226
+ }
5227
+ );
5228
+ }
5229
+ function mount(render) {
5230
+ const host = document.createElement("div");
5231
+ document.body.appendChild(host);
5232
+ const refImpl = new SModalRefImpl();
5233
+ const root = createRoot(host);
5234
+ refImpl._setTeardown(root, host);
5235
+ root.render(render(refImpl));
5236
+ return refImpl;
5237
+ }
5238
+ var SModal = {
5239
+ /** 확인/취소 모달을 즉시 띄운다. 반환 핸들에 onOk/onCancel/onClose/onDismissed 체이닝. */
5240
+ confirm(options) {
5241
+ return mount((refImpl) => /* @__PURE__ */ jsx(ConfirmMount, { options, refImpl }));
5242
+ },
5243
+ /**
5244
+ * 로딩(스피너/에러) 모달을 즉시 띄운다. 로딩 중 임의 닫힘 방지를 위해 persistent 기본 true.
5245
+ * 버튼 클릭은 자동 닫힘 없이 onClick 만 발화 — update()/close() 로 후속 동작을 결정한다.
5246
+ */
5247
+ loading(options = {}) {
5248
+ return mount((refImpl) => /* @__PURE__ */ jsx(LoadingMount, { options: { persistent: true, ...options }, refImpl }));
5249
+ },
5250
+ /**
5251
+ * 커스텀 React 컴포넌트를 SModalContainer(딤+카드) 안에 띄운다. component 에 modalRef 가
5252
+ * prop 으로 주입되어 컴포넌트가 ok()/cancel()/close()/submit()/onSubmit() 으로 자기 모달을 제어한다.
5253
+ */
5254
+ create(options) {
5255
+ return mount((refImpl) => /* @__PURE__ */ jsx(CreateMount, { options, refImpl }));
5256
+ }
5257
+ };
5014
5258
 
5015
5259
  // src/components/SGnb/gnb.config.ts
5016
5260
  var gnb = (p) => `var(--cmp-gnb-${p})`;
@@ -11559,6 +11803,6 @@ function STimeRangePicker({
11559
11803
  );
11560
11804
  }
11561
11805
 
11562
- export { BADGE_COLORS, BUTTON_COLORS, BUTTON_SIZES, COLOR_KEYS, GNB_COLORS, GNB_COMMON, GNB_FOLD_MS, GNB_HEADER, GNB_MENU, GNB_MENU_WIDTH, GNB_RAIL, GNB_RAIL_WIDTH, ICONS, PAGE_BACKGROUNDS, SActionModal, SBadge, SBarcodeInput, SButton, SCROLL_AREA_AXES, SCalendar, SCallout, SCard, SCheckbox, SChip, SChipInput, SCircleProgress, SConfirmModal, SDatePicker, SDateRangePicker, SDivider, SDropdownButton, SExpansionItem, SField, SFilePicker, SForm, SGhostButton, SGnb, SGuide, SIcon, SInput, SKeyValueTable, SLayout, SLayoutContext, SLinearProgress, SLoadingContainer, SLoadingModal, SLoadingViewport, SNumberInput, SPage, SPagination, SPopover, SPopup, SPortal, SRadio, SRadioButton, SRadioGroup, SScrollArea, SSelect, SStepper, SSwitch, STEPPER_SIZES, STable, STabs, STag, STextLink, STextarea, STimePicker, STimeRangePicker, SToast, SToastContainer, SToggle, STooltip, TAG_COLORS, TAG_SHAPES, TAG_SIZES, TIMEPICKER_SIZES, TIMEPICKER_SIZE_CONFIG, buttonPreset, cn, findGnbAncestors, findGnbRailValue, isColorKey, loading, resolveColor, useSLayout };
11806
+ export { BADGE_COLORS, BUTTON_COLORS, BUTTON_SIZES, COLOR_KEYS, GNB_COLORS, GNB_COMMON, GNB_FOLD_MS, GNB_HEADER, GNB_MENU, GNB_MENU_WIDTH, GNB_RAIL, GNB_RAIL_WIDTH, ICONS, PAGE_BACKGROUNDS, SActionModal, SBadge, SBarcodeInput, SButton, SCROLL_AREA_AXES, SCalendar, SCallout, SCard, SCheckbox, SChip, SChipInput, SCircleProgress, SConfirmModal, SDatePicker, SDateRangePicker, SDivider, SDropdownButton, SExpansionItem, SField, SFilePicker, SForm, SGhostButton, SGnb, SGuide, SIcon, SInput, SKeyValueTable, SLayout, SLayoutContext, SLinearProgress, SLoadingContainer, SLoadingModal, SLoadingViewport, SModal, SNumberInput, SPage, SPagination, SPopover, SPopup, SPortal, SRadio, SRadioButton, SRadioGroup, SScrollArea, SSelect, SStepper, SSwitch, STEPPER_SIZES, STable, STabs, STag, STextLink, STextarea, STimePicker, STimeRangePicker, SToast, SToastContainer, SToggle, STooltip, TAG_COLORS, TAG_SHAPES, TAG_SIZES, TIMEPICKER_SIZES, TIMEPICKER_SIZE_CONFIG, buttonPreset, cn, findGnbAncestors, findGnbRailValue, isColorKey, loading, resolveColor, useSLayout };
11563
11807
  //# sourceMappingURL=index.js.map
11564
11808
  //# sourceMappingURL=index.js.map