sellmate-design-system-react 1.1.3 → 2.0.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.
@@ -5,6 +5,8 @@ export interface SActionModalButton {
5
5
  color?: SButtonColor;
6
6
  outline?: boolean;
7
7
  size?: SButtonSize;
8
+ disabled?: boolean;
9
+ /** 클릭 핸들러. 모달은 자동으로 닫히지 않으므로 닫는 시점은 onOpenChange 로 직접 제어한다 */
8
10
  onClick?: () => void;
9
11
  }
10
12
  export interface SActionModalProps {
@@ -21,5 +23,10 @@ export interface SActionModalProps {
21
23
  height?: number | string;
22
24
  children?: ReactNode;
23
25
  }
24
- /** SActionModal — sd-action-modal 포팅. 헤더(제목·닫기) + 본문 + 하단 액션 버튼. */
26
+ /**
27
+ * SActionModal — sd-action-modal 포팅. 헤더(제목·닫기) + 본문 + 하단 액션 버튼.
28
+ *
29
+ * 액션 버튼은 `button.onClick` 만 호출하고 모달을 닫지 않는다. 본문에서 API 를 호출하는 경우가
30
+ * 많아 성공 여부에 따라 닫힘 시점이 달라지므로, 닫는 책임은 사용하는 쪽에 둔다.
31
+ */
25
32
  export declare function SActionModal({ open, onOpenChange, onClose, persistent, modalTitle, button, width, height, children, }: SActionModalProps): import("react").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { createContext, forwardRef, useState, useCallback, useRef, useContext } from 'react';
2
+ import { createContext, forwardRef, useState, useRef, useCallback, useContext } from 'react';
3
3
  import * as RDialog from '@radix-ui/react-dialog';
4
4
  import { clsx } from 'clsx';
5
5
  import { extendTailwindMerge } from 'tailwind-merge';
@@ -3087,6 +3087,7 @@ function SModalContainer({
3087
3087
  style
3088
3088
  }) {
3089
3089
  const [shaking, setShaking] = useState(false);
3090
+ const contentRef = useRef(null);
3090
3091
  const [portalContainer, setPortalContainer] = useState(null);
3091
3092
  const triggerShake = useCallback(() => {
3092
3093
  setShaking(false);
@@ -3101,7 +3102,12 @@ function SModalContainer({
3101
3102
  /* @__PURE__ */ jsx("div", { className: "pointer-events-none fixed inset-0 z-[1001] flex items-center justify-center", children: /* @__PURE__ */ jsxs(
3102
3103
  RDialog.Content,
3103
3104
  {
3105
+ ref: contentRef,
3104
3106
  className: "pointer-events-auto outline-none data-[state=open]:animate-modal-in data-[state=closed]:animate-modal-out",
3107
+ onOpenAutoFocus: (e) => {
3108
+ e.preventDefault();
3109
+ contentRef.current?.focus({ preventScroll: true });
3110
+ },
3105
3111
  onEscapeKeyDown: guardClose,
3106
3112
  onPointerDownOutside: guardClose,
3107
3113
  onInteractOutside: guardClose,
@@ -3349,10 +3355,8 @@ function SActionModal({
3349
3355
  color: button.color ?? "primary",
3350
3356
  outline: button.outline,
3351
3357
  size: button.size ?? "md",
3352
- onClick: () => {
3353
- button.onClick?.();
3354
- onOpenChange?.(false);
3355
- },
3358
+ disabled: button.disabled,
3359
+ onClick: () => button.onClick?.(),
3356
3360
  label: button.label ?? "\uD655\uC778"
3357
3361
  }
3358
3362
  )