@aivex/ui 1.2.0-dev.57 → 1.2.0-dev.59

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.
Files changed (68) hide show
  1. package/dist/DESIGN.md +1 -1
  2. package/dist/components/Coachmark/Coachmark.cjs.map +1 -1
  3. package/dist/components/Coachmark/Coachmark.d.cts +2 -1
  4. package/dist/components/Coachmark/Coachmark.d.ts +2 -1
  5. package/dist/components/Coachmark/Coachmark.js.map +1 -1
  6. package/dist/components/Dialog/Dialog.cjs.map +1 -1
  7. package/dist/components/Dialog/Dialog.d.cts +2 -1
  8. package/dist/components/Dialog/Dialog.d.ts +2 -1
  9. package/dist/components/Dialog/Dialog.js.map +1 -1
  10. package/dist/components/Icon/index.cjs +1 -1
  11. package/dist/components/Icon/index.cjs.map +1 -1
  12. package/dist/components/Icon/index.d.cts +28 -0
  13. package/dist/components/Icon/index.d.ts +28 -0
  14. package/dist/components/Icon/index.js +280 -250
  15. package/dist/components/Icon/index.js.map +1 -1
  16. package/dist/components/Modal/Modal.cjs.map +1 -1
  17. package/dist/components/Modal/Modal.d.cts +4 -5
  18. package/dist/components/Modal/Modal.d.ts +4 -5
  19. package/dist/components/Modal/Modal.js.map +1 -1
  20. package/dist/components/ShapeEditor/ShapeEditor.cjs +1 -1
  21. package/dist/components/ShapeEditor/ShapeEditor.cjs.map +1 -1
  22. package/dist/components/ShapeEditor/ShapeEditor.js +406 -428
  23. package/dist/components/ShapeEditor/ShapeEditor.js.map +1 -1
  24. package/dist/components/ShapeEditor/_components/OverlayMarkers.cjs +2 -0
  25. package/dist/components/ShapeEditor/_components/OverlayMarkers.cjs.map +1 -0
  26. package/dist/components/ShapeEditor/_components/OverlayMarkers.d.cts +16 -0
  27. package/dist/components/ShapeEditor/_components/OverlayMarkers.d.ts +16 -0
  28. package/dist/components/ShapeEditor/_components/OverlayMarkers.js +41 -0
  29. package/dist/components/ShapeEditor/_components/OverlayMarkers.js.map +1 -0
  30. package/dist/components/ShapeEditor/_model/types/props.d.cts +3 -1
  31. package/dist/components/ShapeEditor/_model/types/props.d.ts +3 -1
  32. package/dist/components/ShapeEditor/_state/createInteractionController.cjs +1 -1
  33. package/dist/components/ShapeEditor/_state/createInteractionController.cjs.map +1 -1
  34. package/dist/components/ShapeEditor/_state/createInteractionController.js +4 -2
  35. package/dist/components/ShapeEditor/_state/createInteractionController.js.map +1 -1
  36. package/dist/components/ShapeEditor/_state/useAssistant.cjs +1 -1
  37. package/dist/components/ShapeEditor/_state/useAssistant.cjs.map +1 -1
  38. package/dist/components/ShapeEditor/_state/useAssistant.d.cts +1 -0
  39. package/dist/components/ShapeEditor/_state/useAssistant.d.ts +1 -0
  40. package/dist/components/ShapeEditor/_state/useAssistant.js +81 -74
  41. package/dist/components/ShapeEditor/_state/useAssistant.js.map +1 -1
  42. package/dist/components/ShapeEditor/_state/useDrawSession.cjs +1 -1
  43. package/dist/components/ShapeEditor/_state/useDrawSession.cjs.map +1 -1
  44. package/dist/components/ShapeEditor/_state/useDrawSession.d.cts +4 -1
  45. package/dist/components/ShapeEditor/_state/useDrawSession.d.ts +4 -1
  46. package/dist/components/ShapeEditor/_state/useDrawSession.js +184 -164
  47. package/dist/components/ShapeEditor/_state/useDrawSession.js.map +1 -1
  48. package/dist/components/ShapeEditor/_state/useEditorDocument.cjs +1 -1
  49. package/dist/components/ShapeEditor/_state/useEditorDocument.cjs.map +1 -1
  50. package/dist/components/ShapeEditor/_state/useEditorDocument.d.cts +7 -0
  51. package/dist/components/ShapeEditor/_state/useEditorDocument.d.ts +7 -0
  52. package/dist/components/ShapeEditor/_state/useEditorDocument.js +61 -31
  53. package/dist/components/ShapeEditor/_state/useEditorDocument.js.map +1 -1
  54. package/dist/components/ShapeEditor/_state/useSelectionModel.cjs +1 -1
  55. package/dist/components/ShapeEditor/_state/useSelectionModel.cjs.map +1 -1
  56. package/dist/components/ShapeEditor/_state/useSelectionModel.js +10 -3
  57. package/dist/components/ShapeEditor/_state/useSelectionModel.js.map +1 -1
  58. package/dist/components/Toast/Toast.cjs.map +1 -1
  59. package/dist/components/Toast/Toast.d.cts +2 -1
  60. package/dist/components/Toast/Toast.d.ts +2 -1
  61. package/dist/components/Toast/Toast.js.map +1 -1
  62. package/dist/index.cjs +1 -1
  63. package/dist/index.js +53 -53
  64. package/dist/llms-full.txt +11 -11
  65. package/dist/llms.txt +2 -2
  66. package/dist/utils/dataAttributes.d.cts +7 -0
  67. package/dist/utils/dataAttributes.d.ts +7 -0
  68. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.cjs","names":[],"sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import * as RadixDialog from \"@radix-ui/react-dialog\";\nimport {\n type ComponentPropsWithoutRef,\n createContext,\n type HTMLAttributes,\n type ReactNode,\n type Ref,\n useContext,\n useId,\n} from \"react\";\nimport { Button, type ButtonProps } from \"@/components/Button\";\nimport { CloseIcon } from \"@/components/Icon\";\nimport type { IconButtonProps } from \"@/components/IconButton\";\nimport { IconButton } from \"@/components/IconButton\";\nimport { overlayVariants } from \"@/components/Overlay/Overlay\";\nimport { cn } from \"@/utils/cn\";\nimport { useModalAutoFocus } from \"@/utils/useModalAutoFocus\";\n\ntype ModalContentProps = ComponentPropsWithoutRef<typeof RadixDialog.Content>;\nconst ModalContext = createContext(false);\ntype ModalOpenAutoFocusHandler = (event: Event) => void;\n\n/**\n * Modal 최대 폭 — sm 384px, md 548px, lg 720px, xl 960px, full은 화면 크기 - 32px(높이 포함).\n * 높이는 내용만큼이며 화면 높이의 80%를 넘으면 본문이 스크롤된다.\n */\nexport type ModalSize = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\";\n\nconst modalSizeClasses = {\n sm: \"aivex:max-w-modal-sm\",\n md: \"aivex:max-w-modal-md\",\n lg: \"aivex:max-w-modal-lg\",\n xl: \"aivex:max-w-[960px]\",\n full: \"aivex:h-[calc(100dvh-32px)] aivex:max-w-[calc(100vw-32px)]\",\n} as const;\n\nconst modalSurfaceClassName = cn(\n \"aivex:flex aivex:max-h-[80dvh] aivex:w-[85vw] aivex:flex-col aivex:gap-2xl aivex:overflow-hidden aivex:p-2xl\",\n \"aivex:rounded-2xl aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:shadow-xl aivex:outline-none\",\n);\nconst modalHeaderClassName = \"aivex:flex aivex:w-full aivex:flex-col aivex:gap-xs\";\n\ninterface ModalHeaderProps extends Omit<HTMLAttributes<HTMLDivElement>, \"className\" | \"title\"> {\n title: ReactNode;\n titleId?: string;\n description?: ReactNode;\n headingButton?: ModalHeadingButtonProps;\n onClose?: () => void;\n closeAriaLabel?: string;\n closeButtonProps?: ModalCloseButtonProps;\n ref?: Ref<HTMLDivElement>;\n}\n\nfunction ModalHeader({\n title,\n titleId,\n description,\n headingButton,\n onClose,\n closeAriaLabel = \"Close modal\",\n closeButtonProps,\n ref,\n ...props\n}: ModalHeaderProps) {\n const isInsideModalRoot = useContext(ModalContext);\n const titleElement = (\n <h2\n {...(titleId ? { id: titleId } : {})}\n className=\"aivex:m-0 aivex:whitespace-pre-line aivex:text-heading-xs aivex:text-text-primary aivex:break-words\"\n >\n {title}\n </h2>\n );\n const descriptionElement = description ? (\n <p className=\"aivex:m-0 aivex:whitespace-pre-line aivex:text-body-md-regular aivex:text-text-secondary aivex:break-words\">\n {description}\n </p>\n ) : null;\n const closeButton = (\n <IconButton\n {...closeButtonProps}\n size=\"md\"\n onClick={onClose}\n className=\"aivex:shrink-0\"\n aria-label={closeAriaLabel}\n >\n <CloseIcon size={24} />\n </IconButton>\n );\n const headingButtonElement = headingButton ? <ModalHeadingButton button={headingButton} /> : null;\n\n return (\n <div ref={ref} className={modalHeaderClassName} {...props}>\n <div className=\"aivex:flex aivex:w-full aivex:items-center aivex:justify-center aivex:gap-md\">\n {headingButtonElement}\n <div className=\"aivex:flex aivex:min-w-0 aivex:flex-1 aivex:flex-col aivex:justify-center\">\n {isInsideModalRoot ? (\n <RadixDialog.Title asChild>{titleElement}</RadixDialog.Title>\n ) : (\n titleElement\n )}\n </div>\n {onClose\n ? closeButton\n : isInsideModalRoot && <RadixDialog.Close asChild>{closeButton}</RadixDialog.Close>}\n </div>\n {isInsideModalRoot && descriptionElement ? (\n <RadixDialog.Description asChild>{descriptionElement}</RadixDialog.Description>\n ) : (\n descriptionElement\n )}\n </div>\n );\n}\n\n/** 제목 왼쪽 아이콘 버튼(뒤로 가기 등) — IconButton props에서 크기·모양은 Modal이 고정한다. */\nexport interface ModalHeadingButtonProps\n extends Omit<IconButtonProps, \"asChild\" | \"children\" | \"className\" | \"ref\" | \"shape\" | \"size\"> {\n /** 아이콘 전용 버튼이라 접근성 이름이 필수다. */\n \"aria-label\": string;\n /** 버튼 안에 그릴 아이콘(예: `<ArrowLeftIcon size={24} />`). */\n children: ReactNode;\n}\n\n/**\n * 헤더 닫기(X) 버튼에 덧붙일 속성(`data-*`·`id`·`disabled` 등) — 크기·모양·동작·접근성 이름은\n * Modal이 고정한다(이름은 closeAriaLabel로 바꾼다).\n */\nexport interface ModalCloseButtonProps\n extends Omit<\n IconButtonProps,\n | \"aria-label\"\n | \"asChild\"\n | \"children\"\n | \"className\"\n | \"dangerouslySetInnerHTML\"\n | \"onClick\"\n | \"ref\"\n | \"shape\"\n | \"size\"\n > {\n /** 객체 리터럴로 넘기므로 data 속성을 타입에 명시한다(JSX가 아니면 하이픈 이름도 검사된다). */\n [dataAttribute: `data-${string}`]: string | undefined;\n}\n\nfunction ModalHeadingButton({ button }: { button: ModalHeadingButtonProps }) {\n const { children, ...props } = button;\n\n return (\n <IconButton size=\"md\" className=\"aivex:shrink-0\" {...props}>\n {children}\n </IconButton>\n );\n}\n\ninterface ModalBodyProps extends Omit<HTMLAttributes<HTMLDivElement>, \"className\"> {\n ref?: Ref<HTMLDivElement>;\n}\n\nfunction ModalBody({ children, ref, ...props }: ModalBodyProps) {\n return (\n // 세로 flex여야 표면의 max-h가 자식까지 전달돼, 자식의 flex-1 min-h-0 목록이 본문 대신 스크롤된다.\n // 일반 자식이 줄어들지 않게 하는 규칙은 styles.css(data-aivex-modal-body)에 있다.\n <div\n ref={ref}\n data-aivex-modal-body=\"\"\n className=\"aivex:flex aivex:min-h-0 aivex:flex-1 aivex:flex-col aivex:overflow-y-auto\"\n {...props}\n >\n {children}\n </div>\n );\n}\n\n/** 푸터 버튼 — Button props에서 색·크기·스타일은 Modal이 고정하고 라벨은 children으로 받는다. */\nexport interface ModalButtonProps\n extends Omit<\n ButtonProps,\n \"asChild\" | \"children\" | \"className\" | \"color\" | \"ref\" | \"size\" | \"style\" | \"variant\"\n > {\n /** 버튼 라벨 */\n children: ReactNode;\n}\n\ninterface ModalFooterProps extends Omit<HTMLAttributes<HTMLDivElement>, \"className\" | \"children\"> {\n tertiaryButton?: ModalButtonProps;\n secondaryButton?: ModalButtonProps;\n primaryButton?: ModalButtonProps;\n ref?: Ref<HTMLDivElement>;\n}\n\nfunction ModalFooter({\n tertiaryButton,\n secondaryButton,\n primaryButton,\n ref,\n ...props\n}: ModalFooterProps) {\n return (\n <div\n ref={ref}\n className=\"aivex:flex aivex:h-10 aivex:w-full aivex:items-center aivex:justify-end aivex:gap-lg\"\n {...props}\n >\n <div className=\"aivex:flex aivex:min-w-0 aivex:flex-1 aivex:items-center aivex:justify-start\">\n {tertiaryButton && (\n <ModalActionButton\n button={tertiaryButton}\n variant=\"ghost\"\n color=\"secondary\"\n className=\"aivex:min-w-9\"\n />\n )}\n </div>\n <div className=\"aivex:flex aivex:shrink-0 aivex:items-center aivex:justify-end aivex:gap-lg\">\n {secondaryButton && (\n <ModalActionButton\n button={secondaryButton}\n variant=\"solid\"\n color=\"secondary\"\n className=\"aivex:min-w-[84px]\"\n />\n )}\n {primaryButton && (\n <ModalActionButton\n button={primaryButton}\n variant=\"solid\"\n color=\"primary\"\n className=\"aivex:min-w-[84px]\"\n />\n )}\n </div>\n </div>\n );\n}\n\ninterface ModalActionButtonProps {\n button: ModalButtonProps;\n variant: ButtonProps[\"variant\"];\n color: ButtonProps[\"color\"];\n className?: string;\n}\n\nfunction ModalActionButton({ button, variant, color, className }: ModalActionButtonProps) {\n const { children, ...props } = button;\n\n return (\n <Button variant={variant} color={color} size=\"lg\" className={className} {...props}>\n {children}\n </Button>\n );\n}\n\ninterface ModalRootProps\n extends Omit<\n ModalContentProps,\n | \"children\"\n | \"className\"\n | \"defaultOpen\"\n | \"onInteractOutside\"\n | \"onKeyDown\"\n | \"open\"\n | \"ref\"\n | \"title\"\n > {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n children: ReactNode;\n size?: ModalSize;\n closeOnInteractOutside?: boolean;\n onOpenAutoFocus?: ModalOpenAutoFocusHandler;\n onInteractOutside?: ModalContentProps[\"onInteractOutside\"];\n onKeyDown?: ModalContentProps[\"onKeyDown\"];\n ref?: Ref<HTMLDivElement>;\n}\n\nfunction ModalRoot({\n open,\n defaultOpen,\n onOpenChange,\n children,\n size = \"md\",\n closeOnInteractOutside = true,\n onOpenAutoFocus,\n onCloseAutoFocus,\n onInteractOutside,\n onKeyDown,\n onKeyUp,\n ref,\n ...props\n}: ModalRootProps) {\n const autoFocus = useModalAutoFocus(onOpenAutoFocus, onCloseAutoFocus);\n return (\n <RadixDialog.Root open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange}>\n <RadixDialog.Portal>\n <RadixDialog.Overlay className={overlayVariants({ variant: \"dim\" })} />\n <RadixDialog.Content\n ref={ref}\n className={cn(\n \"aivex:fixed aivex:left-1/2 aivex:top-1/2 aivex:z-(--aivex-z-modal)\",\n \"aivex:-translate-x-1/2 aivex:-translate-y-1/2\",\n modalSurfaceClassName,\n modalSizeClasses[size],\n )}\n onInteractOutside={(event) => {\n onInteractOutside?.(event);\n if (!closeOnInteractOutside && !event.defaultPrevented) event.preventDefault();\n }}\n {...autoFocus}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n {...props}\n >\n <ModalContext.Provider value={true}>{children}</ModalContext.Provider>\n </RadixDialog.Content>\n </RadixDialog.Portal>\n </RadixDialog.Root>\n );\n}\n\nexport interface ModalSurfaceProps {\n /** 제목(필수) — 표면의 aria-labelledby로 연결된다. */\n title: ReactNode;\n /** 제목 아래 설명. */\n description?: ReactNode;\n /** 제목 왼쪽 아이콘 버튼(뒤로 가기 등). */\n headingButton?: ModalHeadingButtonProps;\n /** 본문 — 넘치면 본문 영역만 세로 스크롤한다. */\n children?: ReactNode;\n /** 푸터 왼쪽 끝의 ghost 버튼(보조 동작). */\n tertiaryButton?: ModalButtonProps;\n /** 푸터 오른쪽의 secondary 버튼(취소·이전). */\n secondaryButton?: ModalButtonProps;\n /** 푸터 오른쪽 끝의 primary 버튼(확인·다음). */\n primaryButton?: ModalButtonProps;\n /**\n * 최대 폭.\n * @default \"md\"\n */\n size?: ModalSize;\n /** 지정하면 헤더에 닫기(X) 버튼을 렌더한다. 열림 상태가 없으므로 숨김은 소비자가 처리한다. */\n onClose?: () => void;\n /**\n * 닫기 버튼 aria-label.\n * @default \"Close modal\"\n */\n closeAriaLabel?: string;\n /** 닫기(X) 버튼에 덧붙일 속성 — 예: `{ \"data-track-id\": \"invite-close-btn\" }`. */\n closeButtonProps?: ModalCloseButtonProps;\n ref?: Ref<HTMLDivElement>;\n}\n\n/**\n * Modal과 같은 카드 표면을 포털·딤·포커스 트랩 없이 제자리에 그리는 정적 변형.\n *\n * 상단 버튼 아래에 붙는 패널처럼 위치를 소비자가 잡는 경우나 문서·미리보기에 쓴다.\n * 열림 상태·Esc·바깥 클릭 처리가 없으니 화면을 막는 모달이 필요하면 Modal을 쓴다.\n *\n * @example\n * ```tsx\n * import { ModalSurface } from \"@aivex/ui\";\n *\n * <div className=\"absolute right-6 top-6\">\n * <ModalSurface title=\"작업 상태\" size=\"md\" onClose={() => setVisible(false)}>\n * 진행 중인 작업 2개\n * </ModalSurface>\n * </div>\n * ```\n */\nfunction ModalSurface({\n title,\n description,\n headingButton,\n children,\n tertiaryButton,\n secondaryButton,\n primaryButton,\n size = \"md\",\n onClose,\n closeAriaLabel,\n closeButtonProps,\n ref,\n}: ModalSurfaceProps) {\n const titleId = useId();\n const hasFooter = Boolean(tertiaryButton || secondaryButton || primaryButton);\n\n return (\n <div\n ref={ref}\n role=\"dialog\"\n // 포커스를 가두지도 뒤를 막지도 않는 비모달 표면이라 aria-modal을 달지 않는다.\n // 달면 보조기기가 나머지 페이지를 비활성으로 보고 탐색을 막는다.\n aria-labelledby={titleId}\n className={cn(modalSurfaceClassName, modalSizeClasses[size])}\n >\n <ModalHeader\n title={title}\n titleId={titleId}\n description={description}\n headingButton={headingButton}\n onClose={onClose}\n closeAriaLabel={closeAriaLabel}\n closeButtonProps={closeButtonProps}\n />\n {children && <ModalBody>{children}</ModalBody>}\n {hasFooter && (\n <ModalFooter\n tertiaryButton={tertiaryButton}\n secondaryButton={secondaryButton}\n primaryButton={primaryButton}\n />\n )}\n </div>\n );\n}\n\nexport interface ModalProps {\n /** 열림 상태(제어). onOpenChange와 함께 쓴다. */\n open?: boolean;\n /** 초기 열림 상태(비제어). */\n defaultOpen?: boolean;\n /** 열림 상태가 바뀔 때 호출 — 닫기(X)·Esc·바깥 클릭 모두 false로 알린다. */\n onOpenChange?: (open: boolean) => void;\n /** 제목(필수) — 모달의 접근성 이름이 된다. */\n title: ReactNode;\n /** 제목 아래 설명 — 접근성 설명으로 연결된다. */\n description?: ReactNode;\n /** 제목 왼쪽 아이콘 버튼(뒤로 가기 등). */\n headingButton?: ModalHeadingButtonProps;\n /** 본문(폼·목록 등) — 넘치면 본문 영역만 세로 스크롤한다. */\n children?: ReactNode;\n /** 푸터 왼쪽 끝의 ghost 버튼(보조 동작). 눌러도 자동으로 닫히지 않는다. */\n tertiaryButton?: ModalButtonProps;\n /** 푸터 오른쪽의 secondary 버튼(취소·이전). 눌러도 자동으로 닫히지 않는다. */\n secondaryButton?: ModalButtonProps;\n /** 푸터 오른쪽 끝의 primary 버튼(확인·다음). 눌러도 자동으로 닫히지 않는다. */\n primaryButton?: ModalButtonProps;\n /**\n * 최대 폭.\n * @default \"md\"\n */\n size?: ModalSize;\n /**\n * 바깥(딤) 클릭으로 닫을지 여부. 입력 중 실수로 닫히면 안 되는 폼은 false.\n * @default true\n */\n closeOnInteractOutside?: boolean;\n /** 열릴 때 자동 포커스 직전 호출 — event.preventDefault()로 기본 포커스 이동을 막을 수 있다. */\n onOpenAutoFocus?: ModalOpenAutoFocusHandler;\n /**\n * 헤더 닫기(X) 버튼 aria-label.\n * @default \"Close modal\"\n */\n closeAriaLabel?: string;\n /** 헤더 닫기(X) 버튼에 덧붙일 속성 — 예: `{ \"data-track-id\": \"invite-close-btn\" }`. */\n closeButtonProps?: ModalCloseButtonProps;\n}\n\n/**\n * 제목·본문·푸터 버튼으로 구성된 표준 모달 창(딤 + 화면 중앙 카드).\n *\n * 입력 폼, 선택 목록, 여러 단계 흐름처럼 본문이 있는 작업에 쓴다. 제목·설명과 버튼만 있는\n * 짧은 확인 질문은 Dialog, 카드 틀을 벗어난 자유 레이아웃(검색 팔레트 등)은 ModalBase,\n * 화면 옆에서 미끄러져 나오는 시트는 Drawer를 쓴다. 헤더에 닫기(X) 버튼이 자동으로 붙고,\n * 푸터 버튼은 눌러도 닫히지 않으니 onClick에서 open을 직접 false로 바꾼다. title은 필수다.\n *\n * @example\n * ```tsx\n * import { Button, Modal, Textbox } from \"@aivex/ui\";\n *\n * const [open, setOpen] = useState(false);\n *\n * <Button onClick={() => setOpen(true)}>워크스페이스 생성</Button>\n * <Modal\n * open={open}\n * onOpenChange={setOpen}\n * size=\"md\"\n * title=\"워크스페이스 생성\"\n * description=\"생성할 워크스페이스명을 입력하세요.\"\n * secondaryButton={{ children: \"취소\", onClick: () => setOpen(false) }}\n * primaryButton={{ children: \"생성\", onClick: () => setOpen(false) }}\n * >\n * <Textbox aria-label=\"워크스페이스명\" placeholder=\"워크스페이스명을 입력하세요\" />\n * </Modal>\n * ```\n */\nfunction Modal({\n open,\n defaultOpen,\n onOpenChange,\n title,\n description,\n headingButton,\n children,\n tertiaryButton,\n secondaryButton,\n primaryButton,\n size,\n closeOnInteractOutside,\n onOpenAutoFocus,\n closeAriaLabel,\n closeButtonProps,\n}: ModalProps) {\n const hasFooter = Boolean(tertiaryButton || secondaryButton || primaryButton);\n\n return (\n <ModalRoot\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n size={size}\n closeOnInteractOutside={closeOnInteractOutside}\n onOpenAutoFocus={onOpenAutoFocus}\n // 설명이 없는 모달임을 Radix에 알린다 — 명시하지 않으면 개발 모드에서 매번 경고한다.\n {...(description ? {} : { \"aria-describedby\": undefined })}\n >\n <ModalHeader\n title={title}\n description={description}\n headingButton={headingButton}\n closeAriaLabel={closeAriaLabel}\n closeButtonProps={closeButtonProps}\n />\n {children && <ModalBody>{children}</ModalBody>}\n {hasFooter && (\n <ModalFooter\n tertiaryButton={tertiaryButton}\n secondaryButton={secondaryButton}\n primaryButton={primaryButton}\n />\n )}\n </ModalRoot>\n );\n}\n\nexport { Modal, ModalSurface };\n"],"mappings":"2YAmBA,IAAM,GAAA,EAAA,EAAA,eAA6B,GAAM,CASnC,EAAmB,CACvB,GAAI,uBACJ,GAAI,uBACJ,GAAI,uBACJ,GAAI,sBACJ,KAAM,6DACP,CAEK,EAAwB,EAAA,GAC5B,+GACA,mHACD,CACK,EAAuB,sDAa7B,SAAS,EAAY,CACnB,QACA,UACA,cACA,gBACA,UACA,iBAAiB,cACjB,mBACA,MACA,GAAG,GACgB,CACnB,IAAM,GAAA,EAAA,EAAA,YAA+B,EAAa,CAC5C,GACJ,EAAA,EAAA,KAAC,KAAD,CACE,GAAK,EAAU,CAAE,GAAI,EAAS,CAAG,EAAE,CACnC,UAAU,+GAET,EACE,CAAA,CAED,EAAqB,GACzB,EAAA,EAAA,KAAC,IAAD,CAAG,UAAU,sHACV,EACC,CAAA,CACF,KACE,GACJ,EAAA,EAAA,KAAC,EAAA,WAAD,CACE,GAAI,EACJ,KAAK,KACL,QAAS,EACT,UAAU,iBACV,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iB,CACjB,EAAY,GAAQ,GAAkB,GAAmB,GAE/D,OACE,EAAA,EAAA,MAAC,MAAD,CACO,MACL,KAAK,SAGL,kBAAiB,EACjB,UAAW,EAAA,GAAG,EAAuB,EAAiB,GAAM,UAN9D,EAQE,EAAA,EAAA,KAAC,EAAD,CACS,QACE,UACI,cACE,gBACN,UACO,iBACE,mBAClB,CAAA,CACD,IAAY,EAAA,EAAA,KAAC,EAAD,CAAY,WAAqB,CAAA,CAC7C,IACC,EAAA,EAAA,KAAC,EAAD,CACkB,iBACC,kBACF,gBACf,CAAA,CAEA,GA0EV,SAAS,EAAM,CACb,OACA,cACA,eACA,QACA,cACA,gBACA,WACA,iBACA,kBACA,gBACA,OACA,yBACA,kBACA,iBACA,oBACa,CACb,IAAM,EAAY,GAAQ,GAAkB,GAAmB,GAE/D,OACE,EAAA,EAAA,MAAC,EAAD,CACQ,OACO,cACC,eACR,OACkB,yBACP,kBAEjB,GAAK,EAAc,EAAE,CAAG,CAAE,mBAAoB,IAAA,GAAW,UAR3D,EAUE,EAAA,EAAA,KAAC,EAAD,CACS,QACM,cACE,gBACC,iBACE,mBAClB,CAAA,CACD,IAAY,EAAA,EAAA,KAAC,EAAD,CAAY,WAAqB,CAAA,CAC7C,IACC,EAAA,EAAA,KAAC,EAAD,CACkB,iBACC,kBACF,gBACf,CAAA,CAEM"}
1
+ {"version":3,"file":"Modal.cjs","names":[],"sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import * as RadixDialog from \"@radix-ui/react-dialog\";\nimport {\n type ComponentPropsWithoutRef,\n createContext,\n type HTMLAttributes,\n type ReactNode,\n type Ref,\n useContext,\n useId,\n} from \"react\";\nimport { Button, type ButtonProps } from \"@/components/Button\";\nimport { CloseIcon } from \"@/components/Icon\";\nimport type { IconButtonProps } from \"@/components/IconButton\";\nimport { IconButton } from \"@/components/IconButton\";\nimport { overlayVariants } from \"@/components/Overlay/Overlay\";\nimport { cn } from \"@/utils/cn\";\nimport type { DataAttributes } from \"@/utils/dataAttributes\";\nimport { useModalAutoFocus } from \"@/utils/useModalAutoFocus\";\n\ntype ModalContentProps = ComponentPropsWithoutRef<typeof RadixDialog.Content>;\nconst ModalContext = createContext(false);\ntype ModalOpenAutoFocusHandler = (event: Event) => void;\n\n/**\n * Modal 최대 폭 — sm 384px, md 548px, lg 720px, xl 960px, full은 화면 크기 - 32px(높이 포함).\n * 높이는 내용만큼이며 화면 높이의 80%를 넘으면 본문이 스크롤된다.\n */\nexport type ModalSize = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\";\n\nconst modalSizeClasses = {\n sm: \"aivex:max-w-modal-sm\",\n md: \"aivex:max-w-modal-md\",\n lg: \"aivex:max-w-modal-lg\",\n xl: \"aivex:max-w-[960px]\",\n full: \"aivex:h-[calc(100dvh-32px)] aivex:max-w-[calc(100vw-32px)]\",\n} as const;\n\nconst modalSurfaceClassName = cn(\n \"aivex:flex aivex:max-h-[80dvh] aivex:w-[85vw] aivex:flex-col aivex:gap-2xl aivex:overflow-hidden aivex:p-2xl\",\n \"aivex:rounded-2xl aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:shadow-xl aivex:outline-none\",\n);\nconst modalHeaderClassName = \"aivex:flex aivex:w-full aivex:flex-col aivex:gap-xs\";\n\ninterface ModalHeaderProps extends Omit<HTMLAttributes<HTMLDivElement>, \"className\" | \"title\"> {\n title: ReactNode;\n titleId?: string;\n description?: ReactNode;\n headingButton?: ModalHeadingButtonProps;\n onClose?: () => void;\n closeAriaLabel?: string;\n closeButtonProps?: ModalCloseButtonProps;\n ref?: Ref<HTMLDivElement>;\n}\n\nfunction ModalHeader({\n title,\n titleId,\n description,\n headingButton,\n onClose,\n closeAriaLabel = \"Close modal\",\n closeButtonProps,\n ref,\n ...props\n}: ModalHeaderProps) {\n const isInsideModalRoot = useContext(ModalContext);\n const titleElement = (\n <h2\n {...(titleId ? { id: titleId } : {})}\n className=\"aivex:m-0 aivex:whitespace-pre-line aivex:text-heading-xs aivex:text-text-primary aivex:break-words\"\n >\n {title}\n </h2>\n );\n const descriptionElement = description ? (\n <p className=\"aivex:m-0 aivex:whitespace-pre-line aivex:text-body-md-regular aivex:text-text-secondary aivex:break-words\">\n {description}\n </p>\n ) : null;\n const closeButton = (\n <IconButton\n {...closeButtonProps}\n size=\"md\"\n onClick={onClose}\n className=\"aivex:shrink-0\"\n aria-label={closeAriaLabel}\n >\n <CloseIcon size={24} />\n </IconButton>\n );\n const headingButtonElement = headingButton ? <ModalHeadingButton button={headingButton} /> : null;\n\n return (\n <div ref={ref} className={modalHeaderClassName} {...props}>\n <div className=\"aivex:flex aivex:w-full aivex:items-center aivex:justify-center aivex:gap-md\">\n {headingButtonElement}\n <div className=\"aivex:flex aivex:min-w-0 aivex:flex-1 aivex:flex-col aivex:justify-center\">\n {isInsideModalRoot ? (\n <RadixDialog.Title asChild>{titleElement}</RadixDialog.Title>\n ) : (\n titleElement\n )}\n </div>\n {onClose\n ? closeButton\n : isInsideModalRoot && <RadixDialog.Close asChild>{closeButton}</RadixDialog.Close>}\n </div>\n {isInsideModalRoot && descriptionElement ? (\n <RadixDialog.Description asChild>{descriptionElement}</RadixDialog.Description>\n ) : (\n descriptionElement\n )}\n </div>\n );\n}\n\n/** 제목 왼쪽 아이콘 버튼(뒤로 가기 등) — IconButton props에서 크기·모양은 Modal이 고정한다. */\nexport interface ModalHeadingButtonProps\n extends Omit<IconButtonProps, \"asChild\" | \"children\" | \"className\" | \"ref\" | \"shape\" | \"size\">,\n DataAttributes {\n /** 아이콘 전용 버튼이라 접근성 이름이 필수다. */\n \"aria-label\": string;\n /** 버튼 안에 그릴 아이콘(예: `<ArrowLeftIcon size={24} />`). */\n children: ReactNode;\n}\n\n/**\n * 헤더 닫기(X) 버튼에 덧붙일 속성(`data-*`·`id`·`disabled` 등) — 크기·모양·동작·접근성 이름은\n * Modal이 고정한다(이름은 closeAriaLabel로 바꾼다).\n */\nexport interface ModalCloseButtonProps\n extends Omit<\n IconButtonProps,\n | \"aria-label\"\n | \"asChild\"\n | \"children\"\n | \"className\"\n | \"dangerouslySetInnerHTML\"\n | \"onClick\"\n | \"ref\"\n | \"shape\"\n | \"size\"\n >,\n DataAttributes {}\n\nfunction ModalHeadingButton({ button }: { button: ModalHeadingButtonProps }) {\n const { children, ...props } = button;\n\n return (\n <IconButton size=\"md\" className=\"aivex:shrink-0\" {...props}>\n {children}\n </IconButton>\n );\n}\n\ninterface ModalBodyProps extends Omit<HTMLAttributes<HTMLDivElement>, \"className\"> {\n ref?: Ref<HTMLDivElement>;\n}\n\nfunction ModalBody({ children, ref, ...props }: ModalBodyProps) {\n return (\n // 세로 flex여야 표면의 max-h가 자식까지 전달돼, 자식의 flex-1 min-h-0 목록이 본문 대신 스크롤된다.\n // 일반 자식이 줄어들지 않게 하는 규칙은 styles.css(data-aivex-modal-body)에 있다.\n <div\n ref={ref}\n data-aivex-modal-body=\"\"\n className=\"aivex:flex aivex:min-h-0 aivex:flex-1 aivex:flex-col aivex:overflow-y-auto\"\n {...props}\n >\n {children}\n </div>\n );\n}\n\n/** 푸터 버튼 — Button props에서 색·크기·스타일은 Modal이 고정하고 라벨은 children으로 받는다. */\nexport interface ModalButtonProps\n extends Omit<\n ButtonProps,\n \"asChild\" | \"children\" | \"className\" | \"color\" | \"ref\" | \"size\" | \"style\" | \"variant\"\n >,\n DataAttributes {\n /** 버튼 라벨 */\n children: ReactNode;\n}\n\ninterface ModalFooterProps extends Omit<HTMLAttributes<HTMLDivElement>, \"className\" | \"children\"> {\n tertiaryButton?: ModalButtonProps;\n secondaryButton?: ModalButtonProps;\n primaryButton?: ModalButtonProps;\n ref?: Ref<HTMLDivElement>;\n}\n\nfunction ModalFooter({\n tertiaryButton,\n secondaryButton,\n primaryButton,\n ref,\n ...props\n}: ModalFooterProps) {\n return (\n <div\n ref={ref}\n className=\"aivex:flex aivex:h-10 aivex:w-full aivex:items-center aivex:justify-end aivex:gap-lg\"\n {...props}\n >\n <div className=\"aivex:flex aivex:min-w-0 aivex:flex-1 aivex:items-center aivex:justify-start\">\n {tertiaryButton && (\n <ModalActionButton\n button={tertiaryButton}\n variant=\"ghost\"\n color=\"secondary\"\n className=\"aivex:min-w-9\"\n />\n )}\n </div>\n <div className=\"aivex:flex aivex:shrink-0 aivex:items-center aivex:justify-end aivex:gap-lg\">\n {secondaryButton && (\n <ModalActionButton\n button={secondaryButton}\n variant=\"solid\"\n color=\"secondary\"\n className=\"aivex:min-w-[84px]\"\n />\n )}\n {primaryButton && (\n <ModalActionButton\n button={primaryButton}\n variant=\"solid\"\n color=\"primary\"\n className=\"aivex:min-w-[84px]\"\n />\n )}\n </div>\n </div>\n );\n}\n\ninterface ModalActionButtonProps {\n button: ModalButtonProps;\n variant: ButtonProps[\"variant\"];\n color: ButtonProps[\"color\"];\n className?: string;\n}\n\nfunction ModalActionButton({ button, variant, color, className }: ModalActionButtonProps) {\n const { children, ...props } = button;\n\n return (\n <Button variant={variant} color={color} size=\"lg\" className={className} {...props}>\n {children}\n </Button>\n );\n}\n\ninterface ModalRootProps\n extends Omit<\n ModalContentProps,\n | \"children\"\n | \"className\"\n | \"defaultOpen\"\n | \"onInteractOutside\"\n | \"onKeyDown\"\n | \"open\"\n | \"ref\"\n | \"title\"\n > {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n children: ReactNode;\n size?: ModalSize;\n closeOnInteractOutside?: boolean;\n onOpenAutoFocus?: ModalOpenAutoFocusHandler;\n onInteractOutside?: ModalContentProps[\"onInteractOutside\"];\n onKeyDown?: ModalContentProps[\"onKeyDown\"];\n ref?: Ref<HTMLDivElement>;\n}\n\nfunction ModalRoot({\n open,\n defaultOpen,\n onOpenChange,\n children,\n size = \"md\",\n closeOnInteractOutside = true,\n onOpenAutoFocus,\n onCloseAutoFocus,\n onInteractOutside,\n onKeyDown,\n onKeyUp,\n ref,\n ...props\n}: ModalRootProps) {\n const autoFocus = useModalAutoFocus(onOpenAutoFocus, onCloseAutoFocus);\n return (\n <RadixDialog.Root open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange}>\n <RadixDialog.Portal>\n <RadixDialog.Overlay className={overlayVariants({ variant: \"dim\" })} />\n <RadixDialog.Content\n ref={ref}\n className={cn(\n \"aivex:fixed aivex:left-1/2 aivex:top-1/2 aivex:z-(--aivex-z-modal)\",\n \"aivex:-translate-x-1/2 aivex:-translate-y-1/2\",\n modalSurfaceClassName,\n modalSizeClasses[size],\n )}\n onInteractOutside={(event) => {\n onInteractOutside?.(event);\n if (!closeOnInteractOutside && !event.defaultPrevented) event.preventDefault();\n }}\n {...autoFocus}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n {...props}\n >\n <ModalContext.Provider value={true}>{children}</ModalContext.Provider>\n </RadixDialog.Content>\n </RadixDialog.Portal>\n </RadixDialog.Root>\n );\n}\n\nexport interface ModalSurfaceProps {\n /** 제목(필수) — 표면의 aria-labelledby로 연결된다. */\n title: ReactNode;\n /** 제목 아래 설명. */\n description?: ReactNode;\n /** 제목 왼쪽 아이콘 버튼(뒤로 가기 등). */\n headingButton?: ModalHeadingButtonProps;\n /** 본문 — 넘치면 본문 영역만 세로 스크롤한다. */\n children?: ReactNode;\n /** 푸터 왼쪽 끝의 ghost 버튼(보조 동작). */\n tertiaryButton?: ModalButtonProps;\n /** 푸터 오른쪽의 secondary 버튼(취소·이전). */\n secondaryButton?: ModalButtonProps;\n /** 푸터 오른쪽 끝의 primary 버튼(확인·다음). */\n primaryButton?: ModalButtonProps;\n /**\n * 최대 폭.\n * @default \"md\"\n */\n size?: ModalSize;\n /** 지정하면 헤더에 닫기(X) 버튼을 렌더한다. 열림 상태가 없으므로 숨김은 소비자가 처리한다. */\n onClose?: () => void;\n /**\n * 닫기 버튼 aria-label.\n * @default \"Close modal\"\n */\n closeAriaLabel?: string;\n /** 닫기(X) 버튼에 덧붙일 속성 — 예: `{ \"data-track-id\": \"invite-close-btn\" }`. */\n closeButtonProps?: ModalCloseButtonProps;\n ref?: Ref<HTMLDivElement>;\n}\n\n/**\n * Modal과 같은 카드 표면을 포털·딤·포커스 트랩 없이 제자리에 그리는 정적 변형.\n *\n * 상단 버튼 아래에 붙는 패널처럼 위치를 소비자가 잡는 경우나 문서·미리보기에 쓴다.\n * 열림 상태·Esc·바깥 클릭 처리가 없으니 화면을 막는 모달이 필요하면 Modal을 쓴다.\n *\n * @example\n * ```tsx\n * import { ModalSurface } from \"@aivex/ui\";\n *\n * <div className=\"absolute right-6 top-6\">\n * <ModalSurface title=\"작업 상태\" size=\"md\" onClose={() => setVisible(false)}>\n * 진행 중인 작업 2개\n * </ModalSurface>\n * </div>\n * ```\n */\nfunction ModalSurface({\n title,\n description,\n headingButton,\n children,\n tertiaryButton,\n secondaryButton,\n primaryButton,\n size = \"md\",\n onClose,\n closeAriaLabel,\n closeButtonProps,\n ref,\n}: ModalSurfaceProps) {\n const titleId = useId();\n const hasFooter = Boolean(tertiaryButton || secondaryButton || primaryButton);\n\n return (\n <div\n ref={ref}\n role=\"dialog\"\n // 포커스를 가두지도 뒤를 막지도 않는 비모달 표면이라 aria-modal을 달지 않는다.\n // 달면 보조기기가 나머지 페이지를 비활성으로 보고 탐색을 막는다.\n aria-labelledby={titleId}\n className={cn(modalSurfaceClassName, modalSizeClasses[size])}\n >\n <ModalHeader\n title={title}\n titleId={titleId}\n description={description}\n headingButton={headingButton}\n onClose={onClose}\n closeAriaLabel={closeAriaLabel}\n closeButtonProps={closeButtonProps}\n />\n {children && <ModalBody>{children}</ModalBody>}\n {hasFooter && (\n <ModalFooter\n tertiaryButton={tertiaryButton}\n secondaryButton={secondaryButton}\n primaryButton={primaryButton}\n />\n )}\n </div>\n );\n}\n\nexport interface ModalProps {\n /** 열림 상태(제어). onOpenChange와 함께 쓴다. */\n open?: boolean;\n /** 초기 열림 상태(비제어). */\n defaultOpen?: boolean;\n /** 열림 상태가 바뀔 때 호출 — 닫기(X)·Esc·바깥 클릭 모두 false로 알린다. */\n onOpenChange?: (open: boolean) => void;\n /** 제목(필수) — 모달의 접근성 이름이 된다. */\n title: ReactNode;\n /** 제목 아래 설명 — 접근성 설명으로 연결된다. */\n description?: ReactNode;\n /** 제목 왼쪽 아이콘 버튼(뒤로 가기 등). */\n headingButton?: ModalHeadingButtonProps;\n /** 본문(폼·목록 등) — 넘치면 본문 영역만 세로 스크롤한다. */\n children?: ReactNode;\n /** 푸터 왼쪽 끝의 ghost 버튼(보조 동작). 눌러도 자동으로 닫히지 않는다. */\n tertiaryButton?: ModalButtonProps;\n /** 푸터 오른쪽의 secondary 버튼(취소·이전). 눌러도 자동으로 닫히지 않는다. */\n secondaryButton?: ModalButtonProps;\n /** 푸터 오른쪽 끝의 primary 버튼(확인·다음). 눌러도 자동으로 닫히지 않는다. */\n primaryButton?: ModalButtonProps;\n /**\n * 최대 폭.\n * @default \"md\"\n */\n size?: ModalSize;\n /**\n * 바깥(딤) 클릭으로 닫을지 여부. 입력 중 실수로 닫히면 안 되는 폼은 false.\n * @default true\n */\n closeOnInteractOutside?: boolean;\n /** 열릴 때 자동 포커스 직전 호출 — event.preventDefault()로 기본 포커스 이동을 막을 수 있다. */\n onOpenAutoFocus?: ModalOpenAutoFocusHandler;\n /**\n * 헤더 닫기(X) 버튼 aria-label.\n * @default \"Close modal\"\n */\n closeAriaLabel?: string;\n /** 헤더 닫기(X) 버튼에 덧붙일 속성 — 예: `{ \"data-track-id\": \"invite-close-btn\" }`. */\n closeButtonProps?: ModalCloseButtonProps;\n}\n\n/**\n * 제목·본문·푸터 버튼으로 구성된 표준 모달 창(딤 + 화면 중앙 카드).\n *\n * 입력 폼, 선택 목록, 여러 단계 흐름처럼 본문이 있는 작업에 쓴다. 제목·설명과 버튼만 있는\n * 짧은 확인 질문은 Dialog, 카드 틀을 벗어난 자유 레이아웃(검색 팔레트 등)은 ModalBase,\n * 화면 옆에서 미끄러져 나오는 시트는 Drawer를 쓴다. 헤더에 닫기(X) 버튼이 자동으로 붙고,\n * 푸터 버튼은 눌러도 닫히지 않으니 onClick에서 open을 직접 false로 바꾼다. title은 필수다.\n *\n * @example\n * ```tsx\n * import { Button, Modal, Textbox } from \"@aivex/ui\";\n *\n * const [open, setOpen] = useState(false);\n *\n * <Button onClick={() => setOpen(true)}>워크스페이스 생성</Button>\n * <Modal\n * open={open}\n * onOpenChange={setOpen}\n * size=\"md\"\n * title=\"워크스페이스 생성\"\n * description=\"생성할 워크스페이스명을 입력하세요.\"\n * secondaryButton={{ children: \"취소\", onClick: () => setOpen(false) }}\n * primaryButton={{ children: \"생성\", onClick: () => setOpen(false) }}\n * >\n * <Textbox aria-label=\"워크스페이스명\" placeholder=\"워크스페이스명을 입력하세요\" />\n * </Modal>\n * ```\n */\nfunction Modal({\n open,\n defaultOpen,\n onOpenChange,\n title,\n description,\n headingButton,\n children,\n tertiaryButton,\n secondaryButton,\n primaryButton,\n size,\n closeOnInteractOutside,\n onOpenAutoFocus,\n closeAriaLabel,\n closeButtonProps,\n}: ModalProps) {\n const hasFooter = Boolean(tertiaryButton || secondaryButton || primaryButton);\n\n return (\n <ModalRoot\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n size={size}\n closeOnInteractOutside={closeOnInteractOutside}\n onOpenAutoFocus={onOpenAutoFocus}\n // 설명이 없는 모달임을 Radix에 알린다 — 명시하지 않으면 개발 모드에서 매번 경고한다.\n {...(description ? {} : { \"aria-describedby\": undefined })}\n >\n <ModalHeader\n title={title}\n description={description}\n headingButton={headingButton}\n closeAriaLabel={closeAriaLabel}\n closeButtonProps={closeButtonProps}\n />\n {children && <ModalBody>{children}</ModalBody>}\n {hasFooter && (\n <ModalFooter\n tertiaryButton={tertiaryButton}\n secondaryButton={secondaryButton}\n primaryButton={primaryButton}\n />\n )}\n </ModalRoot>\n );\n}\n\nexport { Modal, ModalSurface };\n"],"mappings":"2YAoBA,IAAM,GAAA,EAAA,EAAA,eAA6B,GAAM,CASnC,EAAmB,CACvB,GAAI,uBACJ,GAAI,uBACJ,GAAI,uBACJ,GAAI,sBACJ,KAAM,6DACP,CAE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ACC,EAAA,EAAA,KAAC,EAAD,CACkB,iBACC,kBACF,gBACf,CAAA,CAEM"}
@@ -1,6 +1,7 @@
1
1
  import { type ReactNode, type Ref } from "react";
2
2
  import { type ButtonProps } from "../Button/index.cjs";
3
3
  import type { IconButtonProps } from "../IconButton/index.cjs";
4
+ import type { DataAttributes } from "../../utils/dataAttributes.cjs";
4
5
  type ModalOpenAutoFocusHandler = (event: Event) => void;
5
6
  /**
6
7
  * Modal 최대 폭 — sm 384px, md 548px, lg 720px, xl 960px, full은 화면 크기 - 32px(높이 포함).
@@ -8,7 +9,7 @@ type ModalOpenAutoFocusHandler = (event: Event) => void;
8
9
  */
9
10
  export type ModalSize = "sm" | "md" | "lg" | "xl" | "full";
10
11
  /** 제목 왼쪽 아이콘 버튼(뒤로 가기 등) — IconButton props에서 크기·모양은 Modal이 고정한다. */
11
- export interface ModalHeadingButtonProps extends Omit<IconButtonProps, "asChild" | "children" | "className" | "ref" | "shape" | "size"> {
12
+ export interface ModalHeadingButtonProps extends Omit<IconButtonProps, "asChild" | "children" | "className" | "ref" | "shape" | "size">, DataAttributes {
12
13
  /** 아이콘 전용 버튼이라 접근성 이름이 필수다. */
13
14
  "aria-label": string;
14
15
  /** 버튼 안에 그릴 아이콘(예: `<ArrowLeftIcon size={24} />`). */
@@ -18,12 +19,10 @@ export interface ModalHeadingButtonProps extends Omit<IconButtonProps, "asChild"
18
19
  * 헤더 닫기(X) 버튼에 덧붙일 속성(`data-*`·`id`·`disabled` 등) — 크기·모양·동작·접근성 이름은
19
20
  * Modal이 고정한다(이름은 closeAriaLabel로 바꾼다).
20
21
  */
21
- export interface ModalCloseButtonProps extends Omit<IconButtonProps, "aria-label" | "asChild" | "children" | "className" | "dangerouslySetInnerHTML" | "onClick" | "ref" | "shape" | "size"> {
22
- /** 객체 리터럴로 넘기므로 data 속성을 타입에 명시한다(JSX가 아니면 하이픈 이름도 검사된다). */
23
- [dataAttribute: `data-${string}`]: string | undefined;
22
+ export interface ModalCloseButtonProps extends Omit<IconButtonProps, "aria-label" | "asChild" | "children" | "className" | "dangerouslySetInnerHTML" | "onClick" | "ref" | "shape" | "size">, DataAttributes {
24
23
  }
25
24
  /** 푸터 버튼 — Button props에서 색·크기·스타일은 Modal이 고정하고 라벨은 children으로 받는다. */
26
- export interface ModalButtonProps extends Omit<ButtonProps, "asChild" | "children" | "className" | "color" | "ref" | "size" | "style" | "variant"> {
25
+ export interface ModalButtonProps extends Omit<ButtonProps, "asChild" | "children" | "className" | "color" | "ref" | "size" | "style" | "variant">, DataAttributes {
27
26
  /** 버튼 라벨 */
28
27
  children: ReactNode;
29
28
  }
@@ -1,6 +1,7 @@
1
1
  import { type ReactNode, type Ref } from "react";
2
2
  import { type ButtonProps } from "../Button/index.js";
3
3
  import type { IconButtonProps } from "../IconButton/index.js";
4
+ import type { DataAttributes } from "../../utils/dataAttributes.js";
4
5
  type ModalOpenAutoFocusHandler = (event: Event) => void;
5
6
  /**
6
7
  * Modal 최대 폭 — sm 384px, md 548px, lg 720px, xl 960px, full은 화면 크기 - 32px(높이 포함).
@@ -8,7 +9,7 @@ type ModalOpenAutoFocusHandler = (event: Event) => void;
8
9
  */
9
10
  export type ModalSize = "sm" | "md" | "lg" | "xl" | "full";
10
11
  /** 제목 왼쪽 아이콘 버튼(뒤로 가기 등) — IconButton props에서 크기·모양은 Modal이 고정한다. */
11
- export interface ModalHeadingButtonProps extends Omit<IconButtonProps, "asChild" | "children" | "className" | "ref" | "shape" | "size"> {
12
+ export interface ModalHeadingButtonProps extends Omit<IconButtonProps, "asChild" | "children" | "className" | "ref" | "shape" | "size">, DataAttributes {
12
13
  /** 아이콘 전용 버튼이라 접근성 이름이 필수다. */
13
14
  "aria-label": string;
14
15
  /** 버튼 안에 그릴 아이콘(예: `<ArrowLeftIcon size={24} />`). */
@@ -18,12 +19,10 @@ export interface ModalHeadingButtonProps extends Omit<IconButtonProps, "asChild"
18
19
  * 헤더 닫기(X) 버튼에 덧붙일 속성(`data-*`·`id`·`disabled` 등) — 크기·모양·동작·접근성 이름은
19
20
  * Modal이 고정한다(이름은 closeAriaLabel로 바꾼다).
20
21
  */
21
- export interface ModalCloseButtonProps extends Omit<IconButtonProps, "aria-label" | "asChild" | "children" | "className" | "dangerouslySetInnerHTML" | "onClick" | "ref" | "shape" | "size"> {
22
- /** 객체 리터럴로 넘기므로 data 속성을 타입에 명시한다(JSX가 아니면 하이픈 이름도 검사된다). */
23
- [dataAttribute: `data-${string}`]: string | undefined;
22
+ export interface ModalCloseButtonProps extends Omit<IconButtonProps, "aria-label" | "asChild" | "children" | "className" | "dangerouslySetInnerHTML" | "onClick" | "ref" | "shape" | "size">, DataAttributes {
24
23
  }
25
24
  /** 푸터 버튼 — Button props에서 색·크기·스타일은 Modal이 고정하고 라벨은 children으로 받는다. */
26
- export interface ModalButtonProps extends Omit<ButtonProps, "asChild" | "children" | "className" | "color" | "ref" | "size" | "style" | "variant"> {
25
+ export interface ModalButtonProps extends Omit<ButtonProps, "asChild" | "children" | "className" | "color" | "ref" | "size" | "style" | "variant">, DataAttributes {
27
26
  /** 버튼 라벨 */
28
27
  children: ReactNode;
29
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.js","names":[],"sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import * as RadixDialog from \"@radix-ui/react-dialog\";\nimport {\n type ComponentPropsWithoutRef,\n createContext,\n type HTMLAttributes,\n type ReactNode,\n type Ref,\n useContext,\n useId,\n} from \"react\";\nimport { Button, type ButtonProps } from \"@/components/Button\";\nimport { CloseIcon } from \"@/components/Icon\";\nimport type { IconButtonProps } from \"@/components/IconButton\";\nimport { IconButton } from \"@/components/IconButton\";\nimport { overlayVariants } from \"@/components/Overlay/Overlay\";\nimport { cn } from \"@/utils/cn\";\nimport { useModalAutoFocus } from \"@/utils/useModalAutoFocus\";\n\ntype ModalContentProps = ComponentPropsWithoutRef<typeof RadixDialog.Content>;\nconst ModalContext = createContext(false);\ntype ModalOpenAutoFocusHandler = (event: Event) => void;\n\n/**\n * Modal 최대 폭 — sm 384px, md 548px, lg 720px, xl 960px, full은 화면 크기 - 32px(높이 포함).\n * 높이는 내용만큼이며 화면 높이의 80%를 넘으면 본문이 스크롤된다.\n */\nexport type ModalSize = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\";\n\nconst modalSizeClasses = {\n sm: \"aivex:max-w-modal-sm\",\n md: \"aivex:max-w-modal-md\",\n lg: \"aivex:max-w-modal-lg\",\n xl: \"aivex:max-w-[960px]\",\n full: \"aivex:h-[calc(100dvh-32px)] aivex:max-w-[calc(100vw-32px)]\",\n} as const;\n\nconst modalSurfaceClassName = cn(\n \"aivex:flex aivex:max-h-[80dvh] aivex:w-[85vw] aivex:flex-col aivex:gap-2xl aivex:overflow-hidden aivex:p-2xl\",\n \"aivex:rounded-2xl aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:shadow-xl aivex:outline-none\",\n);\nconst modalHeaderClassName = \"aivex:flex aivex:w-full aivex:flex-col aivex:gap-xs\";\n\ninterface ModalHeaderProps extends Omit<HTMLAttributes<HTMLDivElement>, \"className\" | \"title\"> {\n title: ReactNode;\n titleId?: string;\n description?: ReactNode;\n headingButton?: ModalHeadingButtonProps;\n onClose?: () => void;\n closeAriaLabel?: string;\n closeButtonProps?: ModalCloseButtonProps;\n ref?: Ref<HTMLDivElement>;\n}\n\nfunction ModalHeader({\n title,\n titleId,\n description,\n headingButton,\n onClose,\n closeAriaLabel = \"Close modal\",\n closeButtonProps,\n ref,\n ...props\n}: ModalHeaderProps) {\n const isInsideModalRoot = useContext(ModalContext);\n const titleElement = (\n <h2\n {...(titleId ? { id: titleId } : {})}\n className=\"aivex:m-0 aivex:whitespace-pre-line aivex:text-heading-xs aivex:text-text-primary aivex:break-words\"\n >\n {title}\n </h2>\n );\n const descriptionElement = description ? (\n <p className=\"aivex:m-0 aivex:whitespace-pre-line aivex:text-body-md-regular aivex:text-text-secondary aivex:break-words\">\n {description}\n </p>\n ) : null;\n const closeButton = (\n <IconButton\n {...closeButtonProps}\n size=\"md\"\n onClick={onClose}\n className=\"aivex:shrink-0\"\n aria-label={closeAriaLabel}\n >\n <CloseIcon size={24} />\n </IconButton>\n );\n const headingButtonElement = headingButton ? <ModalHeadingButton button={headingButton} /> : null;\n\n return (\n <div ref={ref} className={modalHeaderClassName} {...props}>\n <div className=\"aivex:flex aivex:w-full aivex:items-center aivex:justify-center aivex:gap-md\">\n {headingButtonElement}\n <div className=\"aivex:flex aivex:min-w-0 aivex:flex-1 aivex:flex-col aivex:justify-center\">\n {isInsideModalRoot ? (\n <RadixDialog.Title asChild>{titleElement}</RadixDialog.Title>\n ) : (\n titleElement\n )}\n </div>\n {onClose\n ? closeButton\n : isInsideModalRoot && <RadixDialog.Close asChild>{closeButton}</RadixDialog.Close>}\n </div>\n {isInsideModalRoot && descriptionElement ? (\n <RadixDialog.Description asChild>{descriptionElement}</RadixDialog.Description>\n ) : (\n descriptionElement\n )}\n </div>\n );\n}\n\n/** 제목 왼쪽 아이콘 버튼(뒤로 가기 등) — IconButton props에서 크기·모양은 Modal이 고정한다. */\nexport interface ModalHeadingButtonProps\n extends Omit<IconButtonProps, \"asChild\" | \"children\" | \"className\" | \"ref\" | \"shape\" | \"size\"> {\n /** 아이콘 전용 버튼이라 접근성 이름이 필수다. */\n \"aria-label\": string;\n /** 버튼 안에 그릴 아이콘(예: `<ArrowLeftIcon size={24} />`). */\n children: ReactNode;\n}\n\n/**\n * 헤더 닫기(X) 버튼에 덧붙일 속성(`data-*`·`id`·`disabled` 등) — 크기·모양·동작·접근성 이름은\n * Modal이 고정한다(이름은 closeAriaLabel로 바꾼다).\n */\nexport interface ModalCloseButtonProps\n extends Omit<\n IconButtonProps,\n | \"aria-label\"\n | \"asChild\"\n | \"children\"\n | \"className\"\n | \"dangerouslySetInnerHTML\"\n | \"onClick\"\n | \"ref\"\n | \"shape\"\n | \"size\"\n > {\n /** 객체 리터럴로 넘기므로 data 속성을 타입에 명시한다(JSX가 아니면 하이픈 이름도 검사된다). */\n [dataAttribute: `data-${string}`]: string | undefined;\n}\n\nfunction ModalHeadingButton({ button }: { button: ModalHeadingButtonProps }) {\n const { children, ...props } = button;\n\n return (\n <IconButton size=\"md\" className=\"aivex:shrink-0\" {...props}>\n {children}\n </IconButton>\n );\n}\n\ninterface ModalBodyProps extends Omit<HTMLAttributes<HTMLDivElement>, \"className\"> {\n ref?: Ref<HTMLDivElement>;\n}\n\nfunction ModalBody({ children, ref, ...props }: ModalBodyProps) {\n return (\n // 세로 flex여야 표면의 max-h가 자식까지 전달돼, 자식의 flex-1 min-h-0 목록이 본문 대신 스크롤된다.\n // 일반 자식이 줄어들지 않게 하는 규칙은 styles.css(data-aivex-modal-body)에 있다.\n <div\n ref={ref}\n data-aivex-modal-body=\"\"\n className=\"aivex:flex aivex:min-h-0 aivex:flex-1 aivex:flex-col aivex:overflow-y-auto\"\n {...props}\n >\n {children}\n </div>\n );\n}\n\n/** 푸터 버튼 — Button props에서 색·크기·스타일은 Modal이 고정하고 라벨은 children으로 받는다. */\nexport interface ModalButtonProps\n extends Omit<\n ButtonProps,\n \"asChild\" | \"children\" | \"className\" | \"color\" | \"ref\" | \"size\" | \"style\" | \"variant\"\n > {\n /** 버튼 라벨 */\n children: ReactNode;\n}\n\ninterface ModalFooterProps extends Omit<HTMLAttributes<HTMLDivElement>, \"className\" | \"children\"> {\n tertiaryButton?: ModalButtonProps;\n secondaryButton?: ModalButtonProps;\n primaryButton?: ModalButtonProps;\n ref?: Ref<HTMLDivElement>;\n}\n\nfunction ModalFooter({\n tertiaryButton,\n secondaryButton,\n primaryButton,\n ref,\n ...props\n}: ModalFooterProps) {\n return (\n <div\n ref={ref}\n className=\"aivex:flex aivex:h-10 aivex:w-full aivex:items-center aivex:justify-end aivex:gap-lg\"\n {...props}\n >\n <div className=\"aivex:flex aivex:min-w-0 aivex:flex-1 aivex:items-center aivex:justify-start\">\n {tertiaryButton && (\n <ModalActionButton\n button={tertiaryButton}\n variant=\"ghost\"\n color=\"secondary\"\n className=\"aivex:min-w-9\"\n />\n )}\n </div>\n <div className=\"aivex:flex aivex:shrink-0 aivex:items-center aivex:justify-end aivex:gap-lg\">\n {secondaryButton && (\n <ModalActionButton\n button={secondaryButton}\n variant=\"solid\"\n color=\"secondary\"\n className=\"aivex:min-w-[84px]\"\n />\n )}\n {primaryButton && (\n <ModalActionButton\n button={primaryButton}\n variant=\"solid\"\n color=\"primary\"\n className=\"aivex:min-w-[84px]\"\n />\n )}\n </div>\n </div>\n );\n}\n\ninterface ModalActionButtonProps {\n button: ModalButtonProps;\n variant: ButtonProps[\"variant\"];\n color: ButtonProps[\"color\"];\n className?: string;\n}\n\nfunction ModalActionButton({ button, variant, color, className }: ModalActionButtonProps) {\n const { children, ...props } = button;\n\n return (\n <Button variant={variant} color={color} size=\"lg\" className={className} {...props}>\n {children}\n </Button>\n );\n}\n\ninterface ModalRootProps\n extends Omit<\n ModalContentProps,\n | \"children\"\n | \"className\"\n | \"defaultOpen\"\n | \"onInteractOutside\"\n | \"onKeyDown\"\n | \"open\"\n | \"ref\"\n | \"title\"\n > {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n children: ReactNode;\n size?: ModalSize;\n closeOnInteractOutside?: boolean;\n onOpenAutoFocus?: ModalOpenAutoFocusHandler;\n onInteractOutside?: ModalContentProps[\"onInteractOutside\"];\n onKeyDown?: ModalContentProps[\"onKeyDown\"];\n ref?: Ref<HTMLDivElement>;\n}\n\nfunction ModalRoot({\n open,\n defaultOpen,\n onOpenChange,\n children,\n size = \"md\",\n closeOnInteractOutside = true,\n onOpenAutoFocus,\n onCloseAutoFocus,\n onInteractOutside,\n onKeyDown,\n onKeyUp,\n ref,\n ...props\n}: ModalRootProps) {\n const autoFocus = useModalAutoFocus(onOpenAutoFocus, onCloseAutoFocus);\n return (\n <RadixDialog.Root open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange}>\n <RadixDialog.Portal>\n <RadixDialog.Overlay className={overlayVariants({ variant: \"dim\" })} />\n <RadixDialog.Content\n ref={ref}\n className={cn(\n \"aivex:fixed aivex:left-1/2 aivex:top-1/2 aivex:z-(--aivex-z-modal)\",\n \"aivex:-translate-x-1/2 aivex:-translate-y-1/2\",\n modalSurfaceClassName,\n modalSizeClasses[size],\n )}\n onInteractOutside={(event) => {\n onInteractOutside?.(event);\n if (!closeOnInteractOutside && !event.defaultPrevented) event.preventDefault();\n }}\n {...autoFocus}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n {...props}\n >\n <ModalContext.Provider value={true}>{children}</ModalContext.Provider>\n </RadixDialog.Content>\n </RadixDialog.Portal>\n </RadixDialog.Root>\n );\n}\n\nexport interface ModalSurfaceProps {\n /** 제목(필수) — 표면의 aria-labelledby로 연결된다. */\n title: ReactNode;\n /** 제목 아래 설명. */\n description?: ReactNode;\n /** 제목 왼쪽 아이콘 버튼(뒤로 가기 등). */\n headingButton?: ModalHeadingButtonProps;\n /** 본문 — 넘치면 본문 영역만 세로 스크롤한다. */\n children?: ReactNode;\n /** 푸터 왼쪽 끝의 ghost 버튼(보조 동작). */\n tertiaryButton?: ModalButtonProps;\n /** 푸터 오른쪽의 secondary 버튼(취소·이전). */\n secondaryButton?: ModalButtonProps;\n /** 푸터 오른쪽 끝의 primary 버튼(확인·다음). */\n primaryButton?: ModalButtonProps;\n /**\n * 최대 폭.\n * @default \"md\"\n */\n size?: ModalSize;\n /** 지정하면 헤더에 닫기(X) 버튼을 렌더한다. 열림 상태가 없으므로 숨김은 소비자가 처리한다. */\n onClose?: () => void;\n /**\n * 닫기 버튼 aria-label.\n * @default \"Close modal\"\n */\n closeAriaLabel?: string;\n /** 닫기(X) 버튼에 덧붙일 속성 — 예: `{ \"data-track-id\": \"invite-close-btn\" }`. */\n closeButtonProps?: ModalCloseButtonProps;\n ref?: Ref<HTMLDivElement>;\n}\n\n/**\n * Modal과 같은 카드 표면을 포털·딤·포커스 트랩 없이 제자리에 그리는 정적 변형.\n *\n * 상단 버튼 아래에 붙는 패널처럼 위치를 소비자가 잡는 경우나 문서·미리보기에 쓴다.\n * 열림 상태·Esc·바깥 클릭 처리가 없으니 화면을 막는 모달이 필요하면 Modal을 쓴다.\n *\n * @example\n * ```tsx\n * import { ModalSurface } from \"@aivex/ui\";\n *\n * <div className=\"absolute right-6 top-6\">\n * <ModalSurface title=\"작업 상태\" size=\"md\" onClose={() => setVisible(false)}>\n * 진행 중인 작업 2개\n * </ModalSurface>\n * </div>\n * ```\n */\nfunction ModalSurface({\n title,\n description,\n headingButton,\n children,\n tertiaryButton,\n secondaryButton,\n primaryButton,\n size = \"md\",\n onClose,\n closeAriaLabel,\n closeButtonProps,\n ref,\n}: ModalSurfaceProps) {\n const titleId = useId();\n const hasFooter = Boolean(tertiaryButton || secondaryButton || primaryButton);\n\n return (\n <div\n ref={ref}\n role=\"dialog\"\n // 포커스를 가두지도 뒤를 막지도 않는 비모달 표면이라 aria-modal을 달지 않는다.\n // 달면 보조기기가 나머지 페이지를 비활성으로 보고 탐색을 막는다.\n aria-labelledby={titleId}\n className={cn(modalSurfaceClassName, modalSizeClasses[size])}\n >\n <ModalHeader\n title={title}\n titleId={titleId}\n description={description}\n headingButton={headingButton}\n onClose={onClose}\n closeAriaLabel={closeAriaLabel}\n closeButtonProps={closeButtonProps}\n />\n {children && <ModalBody>{children}</ModalBody>}\n {hasFooter && (\n <ModalFooter\n tertiaryButton={tertiaryButton}\n secondaryButton={secondaryButton}\n primaryButton={primaryButton}\n />\n )}\n </div>\n );\n}\n\nexport interface ModalProps {\n /** 열림 상태(제어). onOpenChange와 함께 쓴다. */\n open?: boolean;\n /** 초기 열림 상태(비제어). */\n defaultOpen?: boolean;\n /** 열림 상태가 바뀔 때 호출 — 닫기(X)·Esc·바깥 클릭 모두 false로 알린다. */\n onOpenChange?: (open: boolean) => void;\n /** 제목(필수) — 모달의 접근성 이름이 된다. */\n title: ReactNode;\n /** 제목 아래 설명 — 접근성 설명으로 연결된다. */\n description?: ReactNode;\n /** 제목 왼쪽 아이콘 버튼(뒤로 가기 등). */\n headingButton?: ModalHeadingButtonProps;\n /** 본문(폼·목록 등) — 넘치면 본문 영역만 세로 스크롤한다. */\n children?: ReactNode;\n /** 푸터 왼쪽 끝의 ghost 버튼(보조 동작). 눌러도 자동으로 닫히지 않는다. */\n tertiaryButton?: ModalButtonProps;\n /** 푸터 오른쪽의 secondary 버튼(취소·이전). 눌러도 자동으로 닫히지 않는다. */\n secondaryButton?: ModalButtonProps;\n /** 푸터 오른쪽 끝의 primary 버튼(확인·다음). 눌러도 자동으로 닫히지 않는다. */\n primaryButton?: ModalButtonProps;\n /**\n * 최대 폭.\n * @default \"md\"\n */\n size?: ModalSize;\n /**\n * 바깥(딤) 클릭으로 닫을지 여부. 입력 중 실수로 닫히면 안 되는 폼은 false.\n * @default true\n */\n closeOnInteractOutside?: boolean;\n /** 열릴 때 자동 포커스 직전 호출 — event.preventDefault()로 기본 포커스 이동을 막을 수 있다. */\n onOpenAutoFocus?: ModalOpenAutoFocusHandler;\n /**\n * 헤더 닫기(X) 버튼 aria-label.\n * @default \"Close modal\"\n */\n closeAriaLabel?: string;\n /** 헤더 닫기(X) 버튼에 덧붙일 속성 — 예: `{ \"data-track-id\": \"invite-close-btn\" }`. */\n closeButtonProps?: ModalCloseButtonProps;\n}\n\n/**\n * 제목·본문·푸터 버튼으로 구성된 표준 모달 창(딤 + 화면 중앙 카드).\n *\n * 입력 폼, 선택 목록, 여러 단계 흐름처럼 본문이 있는 작업에 쓴다. 제목·설명과 버튼만 있는\n * 짧은 확인 질문은 Dialog, 카드 틀을 벗어난 자유 레이아웃(검색 팔레트 등)은 ModalBase,\n * 화면 옆에서 미끄러져 나오는 시트는 Drawer를 쓴다. 헤더에 닫기(X) 버튼이 자동으로 붙고,\n * 푸터 버튼은 눌러도 닫히지 않으니 onClick에서 open을 직접 false로 바꾼다. title은 필수다.\n *\n * @example\n * ```tsx\n * import { Button, Modal, Textbox } from \"@aivex/ui\";\n *\n * const [open, setOpen] = useState(false);\n *\n * <Button onClick={() => setOpen(true)}>워크스페이스 생성</Button>\n * <Modal\n * open={open}\n * onOpenChange={setOpen}\n * size=\"md\"\n * title=\"워크스페이스 생성\"\n * description=\"생성할 워크스페이스명을 입력하세요.\"\n * secondaryButton={{ children: \"취소\", onClick: () => setOpen(false) }}\n * primaryButton={{ children: \"생성\", onClick: () => setOpen(false) }}\n * >\n * <Textbox aria-label=\"워크스페이스명\" placeholder=\"워크스페이스명을 입력하세요\" />\n * </Modal>\n * ```\n */\nfunction Modal({\n open,\n defaultOpen,\n onOpenChange,\n title,\n description,\n headingButton,\n children,\n tertiaryButton,\n secondaryButton,\n primaryButton,\n size,\n closeOnInteractOutside,\n onOpenAutoFocus,\n closeAriaLabel,\n closeButtonProps,\n}: ModalProps) {\n const hasFooter = Boolean(tertiaryButton || secondaryButton || primaryButton);\n\n return (\n <ModalRoot\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n size={size}\n closeOnInteractOutside={closeOnInteractOutside}\n onOpenAutoFocus={onOpenAutoFocus}\n // 설명이 없는 모달임을 Radix에 알린다 — 명시하지 않으면 개발 모드에서 매번 경고한다.\n {...(description ? {} : { \"aria-describedby\": undefined })}\n >\n <ModalHeader\n title={title}\n description={description}\n headingButton={headingButton}\n closeAriaLabel={closeAriaLabel}\n closeButtonProps={closeButtonProps}\n />\n {children && <ModalBody>{children}</ModalBody>}\n {hasFooter && (\n <ModalFooter\n tertiaryButton={tertiaryButton}\n secondaryButton={secondaryButton}\n primaryButton={primaryButton}\n />\n )}\n </ModalRoot>\n );\n}\n\nexport { Modal, ModalSurface };\n"],"mappings":";;;;;;;;;;;AAmBA,IAAM,IAAe,EAAc,GAAM,EASnC,IAAmB;CACvB,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM;CACP,EAEK,IAAwB,EAC5B,gHACA,mHACD,EACK,IAAuB;AAa7B,SAAS,EAAY,EACnB,UACA,YACA,gBACA,kBACA,YACA,oBAA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CACpB,IAAM,IAAU,GAAO,EACjB,IAAY,GAAQ,KAAkB,KAAmB;AAE/D,QACE,kBAAC,OAAD;EACO;EACL,MAAK;EAGL,mBAAiB;EACjB,WAAW,EAAG,GAAuB,EAAiB,GAAM;YAN9D;GAQE,kBAAC,GAAD;IACS;IACE;IACI;IACE;IACN;IACO;IACE;IAClB,CAAA;GACD,KAAY,kBAAC,GAAD,EAAY,aAAqB,CAAA;GAC7C,KACC,kBAAC,GAAD;IACkB;IACC;IACF;IACf,CAAA;GAEA;;;AA0EV,SAAS,EAAM,EACb,SACA,gBACA,iBACA,UACA,gBACA,kBACA,aACA,mBACA,oBACA,kBACA,SACA,2BACA,oBACA,mBACA,uBACa;CACb,IAAM,IAAY,GAAQ,KAAkB,KAAmB;AAE/D,QACE,kBAAC,GAAD;EACQ;EACO;EACC;EACR;EACkB;EACP;EAEjB,GAAK,IAAc,EAAE,GAAG,EAAE,oBAAoB,KAAA,GAAW;YAR3D;GAUE,kBAAC,GAAD;IACS;IACM;IACE;IACC;IACE;IAClB,CAAA;GACD,KAAY,kBAAC,GAAD,EAAY,aAAqB,CAAA;GAC7C,KACC,kBAAC,GAAD;IACkB;IACC;IACF;IACf,CAAA;GAEM"}
1
+ {"version":3,"file":"Modal.js","names":[],"sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import * as RadixDialog from \"@radix-ui/react-dialog\";\nimport {\n type ComponentPropsWithoutRef,\n createContext,\n type HTMLAttributes,\n type ReactNode,\n type Ref,\n useContext,\n useId,\n} from \"react\";\nimport { Button, type ButtonProps } from \"@/components/Button\";\nimport { CloseIcon } from \"@/components/Icon\";\nimport type { IconButtonProps } from \"@/components/IconButton\";\nimport { IconButton } from \"@/components/IconButton\";\nimport { overlayVariants } from \"@/components/Overlay/Overlay\";\nimport { cn } from \"@/utils/cn\";\nimport type { DataAttributes } from \"@/utils/dataAttributes\";\nimport { useModalAutoFocus } from \"@/utils/useModalAutoFocus\";\n\ntype ModalContentProps = ComponentPropsWithoutRef<typeof RadixDialog.Content>;\nconst ModalContext = createContext(false);\ntype ModalOpenAutoFocusHandler = (event: Event) => void;\n\n/**\n * Modal 최대 폭 — sm 384px, md 548px, lg 720px, xl 960px, full은 화면 크기 - 32px(높이 포함).\n * 높이는 내용만큼이며 화면 높이의 80%를 넘으면 본문이 스크롤된다.\n */\nexport type ModalSize = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\";\n\nconst modalSizeClasses = {\n sm: \"aivex:max-w-modal-sm\",\n md: \"aivex:max-w-modal-md\",\n lg: \"aivex:max-w-modal-lg\",\n xl: \"aivex:max-w-[960px]\",\n full: \"aivex:h-[calc(100dvh-32px)] aivex:max-w-[calc(100vw-32px)]\",\n} as const;\n\nconst modalSurfaceClassName = cn(\n \"aivex:flex aivex:max-h-[80dvh] aivex:w-[85vw] aivex:flex-col aivex:gap-2xl aivex:overflow-hidden aivex:p-2xl\",\n \"aivex:rounded-2xl aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:shadow-xl aivex:outline-none\",\n);\nconst modalHeaderClassName = \"aivex:flex aivex:w-full aivex:flex-col aivex:gap-xs\";\n\ninterface ModalHeaderProps extends Omit<HTMLAttributes<HTMLDivElement>, \"className\" | \"title\"> {\n title: ReactNode;\n titleId?: string;\n description?: ReactNode;\n headingButton?: ModalHeadingButtonProps;\n onClose?: () => void;\n closeAriaLabel?: string;\n closeButtonProps?: ModalCloseButtonProps;\n ref?: Ref<HTMLDivElement>;\n}\n\nfunction ModalHeader({\n title,\n titleId,\n description,\n headingButton,\n onClose,\n closeAriaLabel = \"Close modal\",\n closeButtonProps,\n ref,\n ...props\n}: ModalHeaderProps) {\n const isInsideModalRoot = useContext(ModalContext);\n const titleElement = (\n <h2\n {...(titleId ? { id: titleId } : {})}\n className=\"aivex:m-0 aivex:whitespace-pre-line aivex:text-heading-xs aivex:text-text-primary aivex:break-words\"\n >\n {title}\n </h2>\n );\n const descriptionElement = description ? (\n <p className=\"aivex:m-0 aivex:whitespace-pre-line aivex:text-body-md-regular aivex:text-text-secondary aivex:break-words\">\n {description}\n </p>\n ) : null;\n const closeButton = (\n <IconButton\n {...closeButtonProps}\n size=\"md\"\n onClick={onClose}\n className=\"aivex:shrink-0\"\n aria-label={closeAriaLabel}\n >\n <CloseIcon size={24} />\n </IconButton>\n );\n const headingButtonElement = headingButton ? <ModalHeadingButton button={headingButton} /> : null;\n\n return (\n <div ref={ref} className={modalHeaderClassName} {...props}>\n <div className=\"aivex:flex aivex:w-full aivex:items-center aivex:justify-center aivex:gap-md\">\n {headingButtonElement}\n <div className=\"aivex:flex aivex:min-w-0 aivex:flex-1 aivex:flex-col aivex:justify-center\">\n {isInsideModalRoot ? (\n <RadixDialog.Title asChild>{titleElement}</RadixDialog.Title>\n ) : (\n titleElement\n )}\n </div>\n {onClose\n ? closeButton\n : isInsideModalRoot && <RadixDialog.Close asChild>{closeButton}</RadixDialog.Close>}\n </div>\n {isInsideModalRoot && descriptionElement ? (\n <RadixDialog.Description asChild>{descriptionElement}</RadixDialog.Description>\n ) : (\n descriptionElement\n )}\n </div>\n );\n}\n\n/** 제목 왼쪽 아이콘 버튼(뒤로 가기 등) — IconButton props에서 크기·모양은 Modal이 고정한다. */\nexport interface ModalHeadingButtonProps\n extends Omit<IconButtonProps, \"asChild\" | \"children\" | \"className\" | \"ref\" | \"shape\" | \"size\">,\n DataAttributes {\n /** 아이콘 전용 버튼이라 접근성 이름이 필수다. */\n \"aria-label\": string;\n /** 버튼 안에 그릴 아이콘(예: `<ArrowLeftIcon size={24} />`). */\n children: ReactNode;\n}\n\n/**\n * 헤더 닫기(X) 버튼에 덧붙일 속성(`data-*`·`id`·`disabled` 등) — 크기·모양·동작·접근성 이름은\n * Modal이 고정한다(이름은 closeAriaLabel로 바꾼다).\n */\nexport interface ModalCloseButtonProps\n extends Omit<\n IconButtonProps,\n | \"aria-label\"\n | \"asChild\"\n | \"children\"\n | \"className\"\n | \"dangerouslySetInnerHTML\"\n | \"onClick\"\n | \"ref\"\n | \"shape\"\n | \"size\"\n >,\n DataAttributes {}\n\nfunction ModalHeadingButton({ button }: { button: ModalHeadingButtonProps }) {\n const { children, ...props } = button;\n\n return (\n <IconButton size=\"md\" className=\"aivex:shrink-0\" {...props}>\n {children}\n </IconButton>\n );\n}\n\ninterface ModalBodyProps extends Omit<HTMLAttributes<HTMLDivElement>, \"className\"> {\n ref?: Ref<HTMLDivElement>;\n}\n\nfunction ModalBody({ children, ref, ...props }: ModalBodyProps) {\n return (\n // 세로 flex여야 표면의 max-h가 자식까지 전달돼, 자식의 flex-1 min-h-0 목록이 본문 대신 스크롤된다.\n // 일반 자식이 줄어들지 않게 하는 규칙은 styles.css(data-aivex-modal-body)에 있다.\n <div\n ref={ref}\n data-aivex-modal-body=\"\"\n className=\"aivex:flex aivex:min-h-0 aivex:flex-1 aivex:flex-col aivex:overflow-y-auto\"\n {...props}\n >\n {children}\n </div>\n );\n}\n\n/** 푸터 버튼 — Button props에서 색·크기·스타일은 Modal이 고정하고 라벨은 children으로 받는다. */\nexport interface ModalButtonProps\n extends Omit<\n ButtonProps,\n \"asChild\" | \"children\" | \"className\" | \"color\" | \"ref\" | \"size\" | \"style\" | \"variant\"\n >,\n DataAttributes {\n /** 버튼 라벨 */\n children: ReactNode;\n}\n\ninterface ModalFooterProps extends Omit<HTMLAttributes<HTMLDivElement>, \"className\" | \"children\"> {\n tertiaryButton?: ModalButtonProps;\n secondaryButton?: ModalButtonProps;\n primaryButton?: ModalButtonProps;\n ref?: Ref<HTMLDivElement>;\n}\n\nfunction ModalFooter({\n tertiaryButton,\n secondaryButton,\n primaryButton,\n ref,\n ...props\n}: ModalFooterProps) {\n return (\n <div\n ref={ref}\n className=\"aivex:flex aivex:h-10 aivex:w-full aivex:items-center aivex:justify-end aivex:gap-lg\"\n {...props}\n >\n <div className=\"aivex:flex aivex:min-w-0 aivex:flex-1 aivex:items-center aivex:justify-start\">\n {tertiaryButton && (\n <ModalActionButton\n button={tertiaryButton}\n variant=\"ghost\"\n color=\"secondary\"\n className=\"aivex:min-w-9\"\n />\n )}\n </div>\n <div className=\"aivex:flex aivex:shrink-0 aivex:items-center aivex:justify-end aivex:gap-lg\">\n {secondaryButton && (\n <ModalActionButton\n button={secondaryButton}\n variant=\"solid\"\n color=\"secondary\"\n className=\"aivex:min-w-[84px]\"\n />\n )}\n {primaryButton && (\n <ModalActionButton\n button={primaryButton}\n variant=\"solid\"\n color=\"primary\"\n className=\"aivex:min-w-[84px]\"\n />\n )}\n </div>\n </div>\n );\n}\n\ninterface ModalActionButtonProps {\n button: ModalButtonProps;\n variant: ButtonProps[\"variant\"];\n color: ButtonProps[\"color\"];\n className?: string;\n}\n\nfunction ModalActionButton({ button, variant, color, className }: ModalActionButtonProps) {\n const { children, ...props } = button;\n\n return (\n <Button variant={variant} color={color} size=\"lg\" className={className} {...props}>\n {children}\n </Button>\n );\n}\n\ninterface ModalRootProps\n extends Omit<\n ModalContentProps,\n | \"children\"\n | \"className\"\n | \"defaultOpen\"\n | \"onInteractOutside\"\n | \"onKeyDown\"\n | \"open\"\n | \"ref\"\n | \"title\"\n > {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n children: ReactNode;\n size?: ModalSize;\n closeOnInteractOutside?: boolean;\n onOpenAutoFocus?: ModalOpenAutoFocusHandler;\n onInteractOutside?: ModalContentProps[\"onInteractOutside\"];\n onKeyDown?: ModalContentProps[\"onKeyDown\"];\n ref?: Ref<HTMLDivElement>;\n}\n\nfunction ModalRoot({\n open,\n defaultOpen,\n onOpenChange,\n children,\n size = \"md\",\n closeOnInteractOutside = true,\n onOpenAutoFocus,\n onCloseAutoFocus,\n onInteractOutside,\n onKeyDown,\n onKeyUp,\n ref,\n ...props\n}: ModalRootProps) {\n const autoFocus = useModalAutoFocus(onOpenAutoFocus, onCloseAutoFocus);\n return (\n <RadixDialog.Root open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange}>\n <RadixDialog.Portal>\n <RadixDialog.Overlay className={overlayVariants({ variant: \"dim\" })} />\n <RadixDialog.Content\n ref={ref}\n className={cn(\n \"aivex:fixed aivex:left-1/2 aivex:top-1/2 aivex:z-(--aivex-z-modal)\",\n \"aivex:-translate-x-1/2 aivex:-translate-y-1/2\",\n modalSurfaceClassName,\n modalSizeClasses[size],\n )}\n onInteractOutside={(event) => {\n onInteractOutside?.(event);\n if (!closeOnInteractOutside && !event.defaultPrevented) event.preventDefault();\n }}\n {...autoFocus}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n {...props}\n >\n <ModalContext.Provider value={true}>{children}</ModalContext.Provider>\n </RadixDialog.Content>\n </RadixDialog.Portal>\n </RadixDialog.Root>\n );\n}\n\nexport interface ModalSurfaceProps {\n /** 제목(필수) — 표면의 aria-labelledby로 연결된다. */\n title: ReactNode;\n /** 제목 아래 설명. */\n description?: ReactNode;\n /** 제목 왼쪽 아이콘 버튼(뒤로 가기 등). */\n headingButton?: ModalHeadingButtonProps;\n /** 본문 — 넘치면 본문 영역만 세로 스크롤한다. */\n children?: ReactNode;\n /** 푸터 왼쪽 끝의 ghost 버튼(보조 동작). */\n tertiaryButton?: ModalButtonProps;\n /** 푸터 오른쪽의 secondary 버튼(취소·이전). */\n secondaryButton?: ModalButtonProps;\n /** 푸터 오른쪽 끝의 primary 버튼(확인·다음). */\n primaryButton?: ModalButtonProps;\n /**\n * 최대 폭.\n * @default \"md\"\n */\n size?: ModalSize;\n /** 지정하면 헤더에 닫기(X) 버튼을 렌더한다. 열림 상태가 없으므로 숨김은 소비자가 처리한다. */\n onClose?: () => void;\n /**\n * 닫기 버튼 aria-label.\n * @default \"Close modal\"\n */\n closeAriaLabel?: string;\n /** 닫기(X) 버튼에 덧붙일 속성 — 예: `{ \"data-track-id\": \"invite-close-btn\" }`. */\n closeButtonProps?: ModalCloseButtonProps;\n ref?: Ref<HTMLDivElement>;\n}\n\n/**\n * Modal과 같은 카드 표면을 포털·딤·포커스 트랩 없이 제자리에 그리는 정적 변형.\n *\n * 상단 버튼 아래에 붙는 패널처럼 위치를 소비자가 잡는 경우나 문서·미리보기에 쓴다.\n * 열림 상태·Esc·바깥 클릭 처리가 없으니 화면을 막는 모달이 필요하면 Modal을 쓴다.\n *\n * @example\n * ```tsx\n * import { ModalSurface } from \"@aivex/ui\";\n *\n * <div className=\"absolute right-6 top-6\">\n * <ModalSurface title=\"작업 상태\" size=\"md\" onClose={() => setVisible(false)}>\n * 진행 중인 작업 2개\n * </ModalSurface>\n * </div>\n * ```\n */\nfunction ModalSurface({\n title,\n description,\n headingButton,\n children,\n tertiaryButton,\n secondaryButton,\n primaryButton,\n size = \"md\",\n onClose,\n closeAriaLabel,\n closeButtonProps,\n ref,\n}: ModalSurfaceProps) {\n const titleId = useId();\n const hasFooter = Boolean(tertiaryButton || secondaryButton || primaryButton);\n\n return (\n <div\n ref={ref}\n role=\"dialog\"\n // 포커스를 가두지도 뒤를 막지도 않는 비모달 표면이라 aria-modal을 달지 않는다.\n // 달면 보조기기가 나머지 페이지를 비활성으로 보고 탐색을 막는다.\n aria-labelledby={titleId}\n className={cn(modalSurfaceClassName, modalSizeClasses[size])}\n >\n <ModalHeader\n title={title}\n titleId={titleId}\n description={description}\n headingButton={headingButton}\n onClose={onClose}\n closeAriaLabel={closeAriaLabel}\n closeButtonProps={closeButtonProps}\n />\n {children && <ModalBody>{children}</ModalBody>}\n {hasFooter && (\n <ModalFooter\n tertiaryButton={tertiaryButton}\n secondaryButton={secondaryButton}\n primaryButton={primaryButton}\n />\n )}\n </div>\n );\n}\n\nexport interface ModalProps {\n /** 열림 상태(제어). onOpenChange와 함께 쓴다. */\n open?: boolean;\n /** 초기 열림 상태(비제어). */\n defaultOpen?: boolean;\n /** 열림 상태가 바뀔 때 호출 — 닫기(X)·Esc·바깥 클릭 모두 false로 알린다. */\n onOpenChange?: (open: boolean) => void;\n /** 제목(필수) — 모달의 접근성 이름이 된다. */\n title: ReactNode;\n /** 제목 아래 설명 — 접근성 설명으로 연결된다. */\n description?: ReactNode;\n /** 제목 왼쪽 아이콘 버튼(뒤로 가기 등). */\n headingButton?: ModalHeadingButtonProps;\n /** 본문(폼·목록 등) — 넘치면 본문 영역만 세로 스크롤한다. */\n children?: ReactNode;\n /** 푸터 왼쪽 끝의 ghost 버튼(보조 동작). 눌러도 자동으로 닫히지 않는다. */\n tertiaryButton?: ModalButtonProps;\n /** 푸터 오른쪽의 secondary 버튼(취소·이전). 눌러도 자동으로 닫히지 않는다. */\n secondaryButton?: ModalButtonProps;\n /** 푸터 오른쪽 끝의 primary 버튼(확인·다음). 눌러도 자동으로 닫히지 않는다. */\n primaryButton?: ModalButtonProps;\n /**\n * 최대 폭.\n * @default \"md\"\n */\n size?: ModalSize;\n /**\n * 바깥(딤) 클릭으로 닫을지 여부. 입력 중 실수로 닫히면 안 되는 폼은 false.\n * @default true\n */\n closeOnInteractOutside?: boolean;\n /** 열릴 때 자동 포커스 직전 호출 — event.preventDefault()로 기본 포커스 이동을 막을 수 있다. */\n onOpenAutoFocus?: ModalOpenAutoFocusHandler;\n /**\n * 헤더 닫기(X) 버튼 aria-label.\n * @default \"Close modal\"\n */\n closeAriaLabel?: string;\n /** 헤더 닫기(X) 버튼에 덧붙일 속성 — 예: `{ \"data-track-id\": \"invite-close-btn\" }`. */\n closeButtonProps?: ModalCloseButtonProps;\n}\n\n/**\n * 제목·본문·푸터 버튼으로 구성된 표준 모달 창(딤 + 화면 중앙 카드).\n *\n * 입력 폼, 선택 목록, 여러 단계 흐름처럼 본문이 있는 작업에 쓴다. 제목·설명과 버튼만 있는\n * 짧은 확인 질문은 Dialog, 카드 틀을 벗어난 자유 레이아웃(검색 팔레트 등)은 ModalBase,\n * 화면 옆에서 미끄러져 나오는 시트는 Drawer를 쓴다. 헤더에 닫기(X) 버튼이 자동으로 붙고,\n * 푸터 버튼은 눌러도 닫히지 않으니 onClick에서 open을 직접 false로 바꾼다. title은 필수다.\n *\n * @example\n * ```tsx\n * import { Button, Modal, Textbox } from \"@aivex/ui\";\n *\n * const [open, setOpen] = useState(false);\n *\n * <Button onClick={() => setOpen(true)}>워크스페이스 생성</Button>\n * <Modal\n * open={open}\n * onOpenChange={setOpen}\n * size=\"md\"\n * title=\"워크스페이스 생성\"\n * description=\"생성할 워크스페이스명을 입력하세요.\"\n * secondaryButton={{ children: \"취소\", onClick: () => setOpen(false) }}\n * primaryButton={{ children: \"생성\", onClick: () => setOpen(false) }}\n * >\n * <Textbox aria-label=\"워크스페이스명\" placeholder=\"워크스페이스명을 입력하세요\" />\n * </Modal>\n * ```\n */\nfunction Modal({\n open,\n defaultOpen,\n onOpenChange,\n title,\n description,\n headingButton,\n children,\n tertiaryButton,\n secondaryButton,\n primaryButton,\n size,\n closeOnInteractOutside,\n onOpenAutoFocus,\n closeAriaLabel,\n closeButtonProps,\n}: ModalProps) {\n const hasFooter = Boolean(tertiaryButton || secondaryButton || primaryButton);\n\n return (\n <ModalRoot\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n size={size}\n closeOnInteractOutside={closeOnInteractOutside}\n onOpenAutoFocus={onOpenAutoFocus}\n // 설명이 없는 모달임을 Radix에 알린다 — 명시하지 않으면 개발 모드에서 매번 경고한다.\n {...(description ? {} : { \"aria-describedby\": undefined })}\n >\n <ModalHeader\n title={title}\n description={description}\n headingButton={headingButton}\n closeAriaLabel={closeAriaLabel}\n closeButtonProps={closeButtonProps}\n />\n {children && <ModalBody>{children}</ModalBody>}\n {hasFooter && (\n <ModalFooter\n tertiaryButton={tertiaryButton}\n secondaryButton={secondaryButton}\n primaryButton={primaryButton}\n />\n )}\n </ModalRoot>\n );\n}\n\nexport { Modal, ModalSurface };\n"],"mappings":";;;;;;;;;;;AAoBA,IAAM,IAAe,EAAc,GAAM,EASnC,IAAmB;CACvB,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM;CACP,EAEK,IAAwB,EAC5B,gHACA,mHACD,EACK,IAAuB;AAa7B,SAAS,EAAY,EACnB,UACA,YACA,gBACA,kBACA,YACA,o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oB;CACpB,IAAM,IAAU,GAAO,EACjB,IAAY,GAAQ,KAAkB,KAAmB;AAE/D,QACE,kBAAC,OAAD;EACO;EACL,MAAK;EAGL,mBAAiB;EACjB,WAAW,EAAG,GAAuB,EAAiB,GAAM;YAN9D;GAQE,kBAAC,GAAD;IACS;IACE;IACI;IACE;IACN;IACO;IACE;IAClB,CAAA;GACD,KAAY,kBAAC,GAAD,EAAY,aAAqB,CAAA;GAC7C,KACC,kBAAC,GAAD;IACkB;IACC;IACF;IACf,CAAA;GAEA;;;AA0EV,SAAS,EAAM,EACb,SACA,gBACA,iBACA,UACA,gBACA,kBACA,aACA,mBACA,oBACA,kBACA,SACA,2BACA,oBACA,mBACA,uBACa;CACb,IAAM,IAAY,GAAQ,KAAkB,KAAmB;AAE/D,QACE,kBAAC,GAAD;EACQ;EACO;EACC;EACR;EACkB;EACP;EAEjB,GAAK,IAAc,EAAE,GAAG,EAAE,oBAAoB,KAAA,GAAW;YAR3D;GAUE,kBAAC,GAAD;IACS;IACM;IACE;IACC;IACE;IAClB,CAAA;GACD,KAAY,kBAAC,GAAD,EAAY,aAAqB,CAAA;GAC7C,KACC,kBAAC,GAAD;IACkB;IACC;IACF;IACf,CAAA;GAEM"}
@@ -1,2 +1,2 @@
1
- "use client";"use client";require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`./_model/geometry.cjs`),t=require(`./_model/strings.cjs`),n=require(`./_model/tools.cjs`),r=require(`./_components/AssistantOverlay.cjs`),i=require(`./_components/ContextMenu.cjs`),a=require(`./_components/CursorGuide.cjs`),ee=require(`./_components/ImageStateOverlay.cjs`),te=require(`./_components/Minimap.cjs`),ne=require(`./_components/SelectionInfo.cjs`),re=require(`./_model/clipboard.cjs`),ie=require(`./_model/cursors.cjs`),ae=require(`./_model/overlays.cjs`),oe=require(`./_state/buildContextMenuItems.cjs`),se=require(`./_state/buildHotkeyActions.cjs`),ce=require(`./_state/createInteractionController.cjs`),le=require(`./_state/useAssistant.cjs`),o=require(`./_state/useLatestRef.cjs`),ue=require(`./_state/useDrawSession.cjs`),de=require(`./_state/useEditorDocument.cjs`),fe=require(`./_state/useEditorHandle.cjs`),pe=require(`./_state/useEditorHotkeys.cjs`),me=require(`./_state/useEditorView.cjs`),he=require(`./_state/useEngineLifecycle.cjs`),ge=require(`./_state/useMinimapNavigation.cjs`),_e=require(`./_state/useMinimapSync.cjs`),ve=require(`./_state/useSelectionActions.cjs`),ye=require(`./_state/useSelectionInfoOverlay.cjs`),be=require(`./_state/useSelectionModel.cjs`),xe=require(`./_state/useViewportControls.cjs`);let s=require(`react`),c=require(`react/jsx-runtime`);function l({document:l,clipboardScope:Se,renderImageState:Ce,dimmed:we=!1,selectedIds:Te,activeTool:u,draftStyle:Ee,draftMeta:d,readOnly:f,disableMarquee:De,locked:p,onLockedInteraction:Oe,onDrawAttemptWithoutDraft:ke,onIdleEscape:Ae,overrideShapeInteraction:m,defaultViewSettings:je,viewSettings:Me,onViewSettingsChange:Ne,showMinimap:Pe=!0,minimapPosition:Fe=`bottom-left`,showViewSettings:Ie=!0,getContextMenuItems:Le,strings:Re,viewSettingItems:ze,canMergeSelection:Be,brushSize:Ve=20,zoomBound:He,zoomAnimationDuration:Ue=300,decorationShapes:h,regionMask:g,overlayMarkers:We,renderOverlayMarker:Ge,onOverlayMarkerClick:Ke,renderImageOverlay:qe,getSelectionLabel:Je,hideSelectionLabelDot:Ye,formatSelectionInfo:Xe,externalTools:Ze,assistant:Qe,keymap:$e,handleRef:et,onActiveToolChange:tt,onSelectionChange:nt,onEditingChange:rt,onShapesCreated:it,onShapesUpdated:at,onShapesDeleted:ot,onDrawSessionChange:st,onDraftShapeChange:ct,onViewportChange:lt,onShapesTransformPreview:ut}){let dt=(0,s.useRef)(null),_=(0,s.useRef)(null),ft=(0,s.useRef)(null),pt=(0,s.useRef)(null),mt=(0,s.useRef)(null),ht=`${(0,s.useId)()}-minimap`,[v,gt]=(0,s.useState)(null),[y,_t]=(0,s.useState)(!1),[b,vt]=(0,s.useState)(!1),[x,yt]=(0,s.useState)(null),[bt,xt]=(0,s.useState)({active:!1,kind:`none`,canUndo:!1,canRedo:!1}),[St,Ct]=(0,s.useState)(!0),[wt,Tt]=(0,s.useState)(!1),S=l?.id??``,Et=l?.imageUrl??``,Dt=l?.displayImageUrl,Ot=l?.coordinateSize,kt=l?.initialShapes,At=l?.initialSelectedIds,jt=Dt??Et,[Mt,Nt]=(0,s.useState)(`loading`),Pt=Mt===`loading`&&l!==null&&!jt?`missing`:Mt,[Ft,It]=(0,s.useState)(null),Lt=(0,s.useCallback)((e,t)=>{Nt(e),It(e===`error`?t??null:null)},[]),C=de.useEditorDocument({onShapesCreated:it,onShapesUpdated:at,onShapesDeleted:ot}),w=(0,s.useMemo)(()=>new Map((Ze??[]).map(e=>[e.id,e])),[Ze]),T=(0,s.useRef)(w);(0,s.useLayoutEffect)(()=>{T.current=w},[w]);let Rt=o.useLatestRef(bt),E=(0,s.useMemo)(()=>t.mergeEditorStrings(Re),[Re]),{seededDefaults:zt,view:D,setView:Bt,updateView:Vt}=me.useEditorView({defaultViewSettings:je,viewSettings:Me,onViewSettingsChange:Ne}),O=(0,s.useMemo)(()=>!v||!g?null:ae.buildRegionOverlayData(g,v.w,v.h),[v,g]),Ht=o.useLatestRef(O),Ut=o.useLatestRef(we),Wt=o.useLatestRef(v),Gt=o.useLatestRef(Ot),Kt=o.useLatestRef(Ot?.imageSize),k=o.useLatestRef(u),A=o.useLatestRef(Ee),qt=o.useLatestRef(d),Jt=o.useLatestRef(Ve),Yt=o.useLatestRef(D.simplifyStrength),j=!!f||!!p,M=o.useLatestRef(j),Xt=o.useLatestRef(De),Zt=o.useLatestRef(p),Qt=o.useLatestRef(Oe),$t=o.useLatestRef(f),N=(0,s.useCallback)((e=!0)=>$t.current||!Zt.current||!e?!1:(Qt.current?.(),!0),[]),en=o.useLatestRef(ke),tn=o.useLatestRef(m),P=o.useLatestRef(C),F=(0,s.useRef)(null),{selectedIds:I,selRef:L,changeSelection:R}=be.useSelectionModel({controlledSelectedIds:Te,onSelectionChange:nt,docShapes:C.shapes,docRef:P,overrideInteractionRef:tn,interactionControllerRef:F,engineRef:_}),z=(0,s.useRef)(!1),B=(0,s.useRef)(`idle`),V=(0,s.useRef)(null),H=(0,s.useCallback)(()=>{let e=_.current;if(!e)return;let t=k.current,n=T.current.get(t),r=Rt.current;e.setCursor(ie.resolveEditorCursor({tool:t,externalToolCursor:n?.cursor,isSpacePressed:z.current,interactionMode:B.current,rendererCursorHint:V.current,isPolygonDrawing:r.kind===`polygon`&&r.active}))},[]),nn=(0,s.useCallback)(e=>{B.current!==e&&(B.current=e,H())},[H]),rn=(0,s.useCallback)(e=>{V.current!==e&&(V.current=e,H())},[H]),an=o.useLatestRef(R),[U,W]=(0,s.useState)(null),on=o.useLatestRef((0,s.useCallback)(e=>W(e),[])),sn=o.useLatestRef(U),cn=o.useLatestRef(lt),ln=(0,s.useRef)(null),{registerMinimapShape:un,applyMinimapPreview:dn,syncMinimap:G}=_e.useMinimapSync({engineRef:_,docRef:P,overlayRef:pt,zoomLabelRef:mt,minimapRectRef:ft,minimapSize:204,onViewportChangeRef:cn,onScreenOverlaySyncRef:ln}),K=ye.useSelectionInfoOverlay({engineRef:_,docRef:P,draftRef:A,draftMetaRef:qt,screenOverlaySyncRef:ln,formatSelectionInfo:Xe,onDraftShapeChange:ct}),fn=K.applyPreview,pn=o.useLatestRef((0,s.useCallback)(e=>{dn(e),fn(e),ut?.(e)},[dn,fn,ut])),mn=o.useLatestRef(K.onDrawPreview),hn=(0,s.useCallback)((t,n)=>{let r=A.current;if(!r||M.current)return;let i=e.generateId();P.current.create({id:i,type:t,points:n,style:r,meta:d}),an.current([i])},[d]),gn=o.useLatestRef(hn),q=ue.useDrawSession({toolRef:k,selRef:L,docRef:P,readOnlyRef:M,draftRef:A,brushSizeRef:Jt,simplifyEpsilonRef:Yt,draftMeta:d,engineRef:_,onDrawSessionChange:(0,s.useCallback)(e=>{xt(e),st?.(e)},[st]),onDraftShapeChange:ct,changeSelection:R,createShape:hn}),_n=o.useLatestRef(q),{reset:vn,undoSession:yn,redoSession:bn,canUndoSession:xn,canRedoSession:Sn,handleToolChange:Cn,handleBrushSelectionChange:wn}=q,J=le.useAssistant({docRef:P,draftRef:A,draftMeta:d,changeSelection:R,assistantRef:o.useLatestRef(Qe)}),Tn=o.useLatestRef(J),En=(0,s.useMemo)(()=>re.createClipboardDocumentId(S),[S]),Y=ve.useSelectionActions({doc:C,selRef:L,effectiveReadOnly:j,changeSelection:R,canMergeSelection:Be,clipboardDocumentId:En,clipboardScope:Se??En}),Dn=(0,s.useMemo)(()=>({undo:()=>{M.current||yn()||C.undo()},redo:()=>{M.current||bn()||C.redo()},canUndo:()=>xn()||C.canUndo(),canRedo:()=>Sn()||C.canRedo()}),[C,yn,bn,xn,Sn]),{zoomToBounds:On,zoomToShapes:kn,zoomToSelection:An,zoomAtCenter:jn}=xe.useViewportControls({engineRef:_,doc:C,selRef:L,zoomAnimationDuration:Ue,zoomBound:He,ready:b}),Mn=o.useLatestRef(D);fe.useEditorHandle({handleRef:et,engineRef:_,loadedImageRef:Wt,regionOverlayRef:Ht,viewRef:Mn,doc:C,history:Dn,drawSession:q,selection:Y,changeSelection:R,rejectLockedEdit:N,viewport:{zoomToBounds:On,zoomToShapes:kn,zoomToSelection:An,zoomAtCenter:jn}});let Nn=o.useLatestRef({strokeWidth:D.strokeSize}),Pn=(0,s.useCallback)(()=>{let e=ce.createInteractionController({engineRef:_,toolRef:k,externalToolMapRef:T,spaceRef:z,docRef:P,renderShapesRef:Fn,renderDefaultsRef:Nn,selRef:L,draftRef:A,readOnlyRef:M,disableMarqueeRef:Xt,lockedRef:Zt,onLockedInteraction:()=>Qt.current?.(),onDrawAttemptWithoutDraft:()=>en.current?.(),createRef:gn,selectRef:an,enterEditRef:on,editingIdRef:sn,drawSessionRef:_n,assistantRef:Tn,setCursorHint:rn,setInteractionMode:nn,syncMinimap:G,onTransformPreview:e=>pn.current(e),onDrawPreview:e=>mn.current(e)});return F.current=e,e},[L,rn,nn,G]);(0,s.useEffect)(()=>()=>{F.current=null},[]);let X=(0,s.useMemo)(()=>{let e=m?C.shapes.map(e=>{let t=m(e);return t?{...e,interaction:{...e.interaction,...t}}:e}):C.shapes;return h?.length?[...h.map(e=>({...e,interaction:{...e.interaction,selectable:!1,draggable:!1,editable:!1,hitTestDisabled:!0}})),...e]:e},[C.shapes,m,h]),Fn=o.useLatestRef(X);he.useEngineLifecycle({hostRef:dt,engineRef:_,documentId:S,renderedImageUrl:jt,makeCallbacks:Pn,viewRef:Mn,readOnlyRef:M,toolRef:k,renderShapesRef:Fn,coordinateSizeRef:Gt,imageSizeRef:Kt,selRef:L,regionOverlayRef:Ht,dimmedRef:Ut,syncMinimap:G,setImage:gt,setImageVisible:_t,setReady:vt,setImageStatus:Lt,onContextMenuRequest:yt}),(0,s.useEffect)(()=>{_.current?.setShapes(X,L.current),G()},[X,L,G]),(0,s.useEffect)(()=>{_.current?.setSelection(I)},[I]),(0,s.useEffect)(()=>{_.current?.setEditing(U)},[U,b]);let In=o.useLatestRef(rt);(0,s.useEffect)(()=>{In.current?.(U)},[U]),(0,s.useLayoutEffect)(()=>{F.current?.cancelGesture(),W(null)},[u,S]),(0,s.useEffect)(()=>{U&&(I.length!==1||I[0]!==U)&&W(null)},[I,U]),(0,s.useEffect)(()=>{let e=_.current;e&&(e.setFilter(D.brightness,D.contrast),e.setRenderDefaults({strokeWidth:D.strokeSize}),e.setImageSmoothing(D.imageSmoothing),G())},[D.brightness,D.contrast,D.strokeSize,D.imageSmoothing,G]),(0,s.useLayoutEffect)(()=>{b&&_.current?.setOverlays(D.showRegionMask?O:null,we)},[b,O,D.showRegionMask,we]),(0,s.useEffect)(()=>{!b||!v||G()},[b,v,D.showRegionMask,g,G]),(0,s.useEffect)(()=>{b&&_.current?.setTransformEnabled(!j&&u!==n.TOOL.BRUSH)},[j,b,u]),(0,s.useEffect)(()=>{p&&W(null)},[p]),(0,s.useEffect)(()=>{Cn(u,T.current.has(u))},[u,Cn]);let Z=J.finalize;(0,s.useEffect)(()=>{Z()},[u,Z]),(0,s.useEffect)(()=>{B.current=`idle`,V.current=null,H()},[u,H]),(0,s.useEffect)(()=>{wn(I,j)},[I,u,j,wn]),(0,s.useEffect)(()=>{b&&H()},[u,bt,w,b,H]);let Ln=o.useLatestRef(At),Q=l!==null,Rn=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=Q?S:null;Rn.current!==e&&(Rn.current=e,yt(null),W(null),B.current=`idle`,V.current=null,C.reset(Q?kt??[]:[]),R(Q?Ln.current??[]:[]),vn(),Z(),H())},[Q,S,kt,C.reset,R,vn,Z,H]),pe.useEditorHotkeys({keymap:$e,hostRef:dt,actions:se.buildHotkeyActions({history:Dn,selection:Y,drawSession:q,assistant:J,controller:()=>F.current,externalTool:()=>T.current.get(k.current),hasSelection:()=>L.current.length>0,rejectLockedEdit:N,editLocked:j,editingId:U,setEditingId:W,vertexEditTarget:()=>{let t=L.current;if(t.length!==1)return null;let n=P.current.getShapes().find(e=>e.id===t[0]);return n&&e.canEditVertices(n)?n.id:null},deleteEditingVertices:(0,s.useCallback)(()=>{let t=sn.current;if(!t||j)return!1;let n=_.current,r=new Set(n?.getVertexSelection()??[]);if(!r.size)return!1;let i=P.current.getShapes().find(e=>e.id===t);if(!i)return!1;let a=i.points.filter((e,t)=>!r.has(t)),ee=i.type===e.SHAPE_TYPE.LINE?2:3;return a.length<ee?!1:(P.current.update([{...i,points:a}]),n?.setVertexSelection([]),!0)},[j]),zoomAtCenter:jn,zoom100:()=>_.current?.zoom100(),zoomFit:()=>_.current?.fit(),toggleMinimap:()=>Ct(e=>!e),toggleCursorGuide:()=>Bt(e=>({...e,showCursorGuide:!e.showCursorGuide})),togglePixelation:()=>Bt(e=>({...e,imageSmoothing:!e.imageSmoothing})),selectTool:e=>tt?.(e),onIdleEscape:Ae}),spaceRef:z,onSpaceDown:()=>{_.current?.setPanMode(!0),H()},onSpaceUp:()=>{_.current?.setPanMode(!1),B.current===`panning`?nn(`idle`):H()},nudge:(e,t)=>N(Y.getEditableSelection().length>0)||Y.nudgeSelection(e,t)});let $=(0,s.useMemo)(()=>X.filter(t=>I.includes(t.id)&&e.isShapeVisible(t)),[X,I]),zn=(0,s.useMemo)(()=>K.drawPreviewShape?[...$,K.drawPreviewShape]:$,[$,K.drawPreviewShape]),Bn=x?oe.buildContextMenuItems({strings:E.contextMenu,point:x.img,shapes:C.shapes,selectedIds:I,hostReadOnly:!!f,editLocked:j,selection:Y,canMergeSelection:Be,history:Dn,enterVertexEdit:W,zoomToSelection:An,refineShape:Qe?J.refineShape:void 0}):[],Vn=x&&Le?Le(Bn,{selectedIds:I,readOnly:j}):Bn,Hn=ge.useMinimapNavigation({engineRef:_,image:v,wheelZoom:D.wheelZoom,minimapSize:204}),Un=(0,s.useCallback)(()=>{_.current?.zoom100()},[]),Wn=(0,s.useCallback)(()=>{Ct(e=>!e)},[]),Gn=(0,s.useCallback)(()=>{Tt(e=>!e)},[]),Kn=(0,s.useCallback)(()=>{Tt(!1)},[]);return(0,c.jsxs)(`div`,{className:`aivex:relative aivex:h-full aivex:w-full aivex:overflow-hidden aivex:bg-black`,children:[(0,c.jsx)(`div`,{ref:dt,role:`application`,"aria-label":E.canvasLabel,tabIndex:0,onPointerDownCapture:e=>e.currentTarget.focus({preventScroll:!0}),className:`aivex:h-full aivex:w-full`,style:{opacity:+!!y,transition:y?`opacity 0.3s ease`:`none`}}),Pt!==`ready`&&(0,c.jsx)(ee.ImageStateOverlay,{status:Pt,error:Ft,render:Ce,loadingLabel:E.imageLoading,missingLabel:E.imageMissing,errorLabel:E.imageLoadError,errorActions:E.imageErrorActions,errorHints:E.imageErrorHints}),b&&v&&(0,c.jsxs)(`div`,{className:`aivex:pointer-events-none aivex:absolute aivex:inset-0 aivex:overflow-hidden`,children:[zn.length>0&&(0,c.jsx)(`div`,{className:`aivex:absolute aivex:inset-0`,children:(0,c.jsx)(ne.SelectionInfo,{shapes:zn,getLabel:Je,hideDot:Ye,formatInfo:Xe,register:K.register,viewport:_.current?.viewport??{scale:1,x:0,y:0}})}),(0,c.jsxs)(`div`,{ref:pt,style:{position:`absolute`,top:0,left:0,width:v.w,height:v.h,transformOrigin:`0 0`},children:[!!We?.length&&Ge&&(0,c.jsx)(`div`,{style:{position:`absolute`,left:0,top:0,width:v.w,height:v.h,pointerEvents:`none`},children:We.map(e=>(0,c.jsx)(`div`,{role:e.disabled?void 0:`button`,tabIndex:e.disabled?void 0:0,"aria-pressed":e.selected||void 0,onClick:t=>{t.stopPropagation(),e.disabled||Ke?.(e)},onKeyDown:t=>{e.disabled||t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),t.stopPropagation(),Ke?.(e))},style:{position:`absolute`,left:e.point.x,top:e.point.y,transform:e.anchor===`topLeft`?`scale(var(--editor-overlay-inverse-scale, 1))`:`translate(-50%, -50%) scale(var(--editor-overlay-inverse-scale, 1))`,transformOrigin:e.anchor===`topLeft`?`0 0`:`center`,zIndex:e.selected?1:void 0,pointerEvents:e.disabled?`none`:`auto`,cursor:e.disabled?`default`:`pointer`},children:Ge(e)},e.id))}),qe?.({image:v,viewport:_.current?.viewport??{scale:1,x:0,y:0}}),Qe&&(J.status===`loading`||J.boxes.length>0)&&(0,c.jsx)(r.AssistantOverlay,{image:v,points:J.points,boxes:J.boxes,status:J.status})]})]}),b&&D.showCursorGuide&&(0,c.jsx)(a.CursorGuide,{color:`#1e88e5`}),v&&Pe&&(0,c.jsx)(te.Minimap,{image:v,imageUrl:jt,imageVisible:y,loading:!b,region:O,roiMaskId:ht,shapes:X,view:D,viewDefaults:zt,onChangeView:Vt,nav:Hn,registerShape:un,rectRef:ft,zoomLabelRef:mt,onZoom100:Un,open:St,onToggleOpen:Wn,position:Fe,labels:E.minimap,settingsLabels:E.viewSettings,settingsItems:ze,showSettings:Ie,settingsOpen:wt,onToggleSettings:Gn,onCloseSettings:Kn}),x&&(0,c.jsx)(i.ContextMenu,{x:x.x,y:x.y,items:Vn,onClose:()=>yt(null)})]})}exports.ShapeEditor=l;
1
+ "use client";"use client";require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`./_model/geometry.cjs`),t=require(`./_model/strings.cjs`),n=require(`./_model/tools.cjs`),r=require(`./_components/AssistantOverlay.cjs`),i=require(`./_components/ContextMenu.cjs`),a=require(`./_components/CursorGuide.cjs`),ee=require(`./_components/ImageStateOverlay.cjs`),te=require(`./_components/Minimap.cjs`),ne=require(`./_components/OverlayMarkers.cjs`),re=require(`./_components/SelectionInfo.cjs`),ie=require(`./_model/clipboard.cjs`),ae=require(`./_model/cursors.cjs`),oe=require(`./_model/overlays.cjs`),se=require(`./_state/buildContextMenuItems.cjs`),ce=require(`./_state/buildHotkeyActions.cjs`),le=require(`./_state/createInteractionController.cjs`),ue=require(`./_state/useAssistant.cjs`),o=require(`./_state/useLatestRef.cjs`),de=require(`./_state/useDrawSession.cjs`),fe=require(`./_state/useEditorDocument.cjs`),pe=require(`./_state/useEditorHandle.cjs`),me=require(`./_state/useEditorHotkeys.cjs`),he=require(`./_state/useEditorView.cjs`),ge=require(`./_state/useEngineLifecycle.cjs`),_e=require(`./_state/useMinimapNavigation.cjs`),ve=require(`./_state/useMinimapSync.cjs`),ye=require(`./_state/useSelectionActions.cjs`),be=require(`./_state/useSelectionInfoOverlay.cjs`),xe=require(`./_state/useSelectionModel.cjs`),Se=require(`./_state/useViewportControls.cjs`);let s=require(`react`),c=require(`react/jsx-runtime`);var Ce={scale:1,x:0,y:0};function l({document:l,clipboardScope:we,renderImageState:Te,dimmed:Ee=!1,selectedIds:De,activeTool:u,draftStyle:Oe,draftMeta:d,readOnly:ke,disableMarquee:Ae,locked:f,onLockedInteraction:je,onDrawAttemptWithoutDraft:Me,onIdleEscape:Ne,overrideShapeInteraction:p,defaultViewSettings:Pe,viewSettings:Fe,onViewSettingsChange:Ie,showMinimap:Le=!0,minimapPosition:Re=`bottom-left`,showViewSettings:ze=!0,getContextMenuItems:Be,strings:Ve,viewSettingItems:He,canMergeSelection:Ue,brushSize:We=20,zoomBound:Ge,zoomAnimationDuration:Ke=300,decorationShapes:m,regionMask:h,overlayMarkers:qe,renderOverlayMarker:Je,onOverlayMarkerClick:Ye,renderImageOverlay:Xe,getSelectionLabel:Ze,hideSelectionLabelDot:Qe,formatSelectionInfo:$e,externalTools:et,assistant:g,keymap:tt,handleRef:nt,onActiveToolChange:rt,onSelectionChange:it,onEditingChange:at,onShapesCreated:ot,onShapesUpdated:st,onShapesDeleted:ct,onDrawSessionChange:lt,onDraftShapeChange:ut,onViewportChange:dt,onShapesTransformPreview:ft}){let _=(0,s.useRef)(null),v=(0,s.useRef)(null),pt=(0,s.useRef)(null),mt=(0,s.useRef)(null),ht=(0,s.useRef)(null),gt=`${(0,s.useId)()}-minimap`,[y,_t]=(0,s.useState)(null),[vt,yt]=(0,s.useState)(!1),[b,bt]=(0,s.useState)(!1),[x,S]=(0,s.useState)(null),[xt,St]=(0,s.useState)({active:!1,kind:`none`,canUndo:!1,canRedo:!1}),[Ct,wt]=(0,s.useState)(!0),[Tt,Et]=(0,s.useState)(!1),C=l?.id??``,Dt=l?.imageUrl??``,Ot=l?.displayImageUrl,kt=l?.coordinateSize,At=l?.initialShapes,jt=l?.initialSelectedIds,w=Ot??Dt,[Mt,Nt]=(0,s.useState)(`loading`),Pt=Mt===`loading`&&l!==null&&!w?`missing`:Mt,[Ft,It]=(0,s.useState)(null),Lt=(0,s.useCallback)((e,t)=>{Nt(e),It(e===`error`?t??null:null)},[]),T=fe.useEditorDocument({onShapesCreated:ot,onShapesUpdated:st,onShapesDeleted:ct}),Rt=(0,s.useMemo)(()=>new Map((et??[]).map(e=>[e.id,e])),[et]),E=o.useLatestRef(Rt),zt=o.useLatestRef(xt),D=(0,s.useMemo)(()=>t.mergeEditorStrings(Ve),[Ve]),{seededDefaults:Bt,view:O,setView:Vt,updateView:Ht}=he.useEditorView({defaultViewSettings:Pe,viewSettings:Fe,onViewSettingsChange:Ie}),k=(0,s.useMemo)(()=>!y||!h?null:oe.buildRegionOverlayData(h,y.w,y.h),[y,h]),Ut=o.useLatestRef(k),Wt=o.useLatestRef(Ee),Gt=o.useLatestRef(y),Kt=o.useLatestRef(kt),qt=o.useLatestRef(kt?.imageSize),A=o.useLatestRef(u),j=o.useLatestRef(Oe),Jt=o.useLatestRef(d),Yt=o.useLatestRef(We),Xt=o.useLatestRef(O.simplifyStrength),M=!!ke||!!f,N=o.useLatestRef(M),Zt=o.useLatestRef(Ae),Qt=o.useLatestRef(f),$t=o.useLatestRef(je),en=o.useLatestRef(ke),P=(0,s.useCallback)((e=!0)=>en.current||!Qt.current||!e?!1:($t.current?.(),!0),[]),tn=o.useLatestRef(Me),nn=o.useLatestRef(p),F=o.useLatestRef(T),I=(0,s.useRef)(null),{selectedIds:L,selRef:R,changeSelection:z}=xe.useSelectionModel({controlledSelectedIds:De,onSelectionChange:it,docShapes:T.shapes,docRef:F,overrideInteractionRef:nn,interactionControllerRef:I,engineRef:v}),B=(0,s.useRef)(!1),V=(0,s.useRef)(`idle`),H=(0,s.useRef)(null),U=(0,s.useCallback)(()=>{let e=v.current;if(!e)return;let t=A.current,n=E.current.get(t),r=zt.current;e.setCursor(ae.resolveEditorCursor({tool:t,externalToolCursor:n?.cursor,isSpacePressed:B.current,interactionMode:V.current,rendererCursorHint:H.current,isPolygonDrawing:r.kind===`polygon`&&r.active}))},[]),W=(0,s.useCallback)(()=>{V.current=`idle`,H.current=null,U()},[U]),rn=(0,s.useCallback)(e=>{V.current!==e&&(V.current=e,U())},[U]),an=(0,s.useCallback)(e=>{H.current!==e&&(H.current=e,U())},[U]),on=o.useLatestRef(z),[G,K]=(0,s.useState)(null),sn=o.useLatestRef((0,s.useCallback)(e=>K(e),[])),cn=o.useLatestRef(G),ln=o.useLatestRef(dt),un=(0,s.useRef)(null),{registerMinimapShape:dn,applyMinimapPreview:fn,syncMinimap:q}=ve.useMinimapSync({engineRef:v,docRef:F,overlayRef:mt,zoomLabelRef:ht,minimapRectRef:pt,minimapSize:204,onViewportChangeRef:ln,onScreenOverlaySyncRef:un}),J=be.useSelectionInfoOverlay({engineRef:v,docRef:F,draftRef:j,draftMetaRef:Jt,screenOverlaySyncRef:un,formatSelectionInfo:$e,onDraftShapeChange:ut}),pn=J.applyPreview,mn=o.useLatestRef((0,s.useCallback)(e=>{fn(e),pn(e),ft?.(e)},[fn,pn,ft])),hn=o.useLatestRef(J.onDrawPreview),gn=(0,s.useCallback)((t,n)=>{let r=j.current;if(!r||N.current)return;let i=e.generateId();F.current.create({id:i,type:t,points:n,style:r,meta:Jt.current}),on.current([i])},[]),_n=o.useLatestRef(gn),Y=de.useDrawSession({toolRef:A,selRef:R,docRef:F,readOnlyRef:N,draftRef:j,brushSizeRef:Yt,simplifyEpsilonRef:Xt,draftMeta:d,engineRef:v,onDrawSessionChange:(0,s.useCallback)(e=>{St(e),lt?.(e)},[lt]),onDraftShapeChange:ut,changeSelection:z,createShape:gn,onDrawAttemptWithoutDraft:Me}),vn=o.useLatestRef(Y),{reset:yn,undoSession:bn,redoSession:xn,canUndoSession:Sn,canRedoSession:Cn,handleToolChange:wn,handleBrushSelectionChange:Tn,syncBrushTargets:En}=Y,X=ue.useAssistant({docRef:F,draftRef:j,draftMeta:d,changeSelection:z,assistantRef:o.useLatestRef(g)}),Dn=o.useLatestRef(X),On=(0,s.useMemo)(()=>ie.createClipboardDocumentId(C),[C]),Z=ye.useSelectionActions({doc:T,selRef:R,effectiveReadOnly:M,changeSelection:z,canMergeSelection:Ue,clipboardDocumentId:On,clipboardScope:we??On}),kn=(0,s.useMemo)(()=>({undo:()=>{N.current||bn()||T.undo()},redo:()=>{N.current||xn()||T.redo()},canUndo:()=>Sn()||T.canUndo(),canRedo:()=>Cn()||T.canRedo()}),[T,bn,xn,Sn,Cn]),{zoomToBounds:An,zoomToShapes:jn,zoomToSelection:Mn,zoomAtCenter:Nn}=Se.useViewportControls({engineRef:v,doc:T,selRef:R,zoomAnimationDuration:Ke,zoomBound:Ge,ready:b}),Pn=o.useLatestRef(O);pe.useEditorHandle({handleRef:nt,engineRef:v,loadedImageRef:Gt,regionOverlayRef:Ut,viewRef:Pn,doc:T,history:kn,drawSession:Y,selection:Z,changeSelection:z,rejectLockedEdit:P,viewport:{zoomToBounds:An,zoomToShapes:jn,zoomToSelection:Mn,zoomAtCenter:Nn}});let Fn=o.useLatestRef({strokeWidth:O.strokeSize}),In=(0,s.useCallback)(()=>{let e=le.createInteractionController({engineRef:v,toolRef:A,externalToolMapRef:E,spaceRef:B,docRef:F,renderShapesRef:Ln,renderDefaultsRef:Fn,selRef:R,draftRef:j,readOnlyRef:N,disableMarqueeRef:Zt,lockedRef:Qt,onLockedInteraction:()=>$t.current?.(),onDrawAttemptWithoutDraft:()=>tn.current?.(),createRef:_n,selectRef:on,enterEditRef:sn,editingIdRef:cn,drawSessionRef:vn,assistantRef:Dn,setCursorHint:an,setInteractionMode:rn,syncMinimap:q,onTransformPreview:e=>mn.current(e),onDrawPreview:e=>hn.current(e)});return I.current=e,e},[R,an,rn,q]);(0,s.useEffect)(()=>()=>{I.current=null},[]);let Q=(0,s.useMemo)(()=>{let e=p?T.shapes.map(e=>{let t=p(e);return t?{...e,interaction:{...e.interaction,...t}}:e}):T.shapes;return m?.length?[...m.map(e=>({...e,interaction:{...e.interaction,selectable:!1,draggable:!1,editable:!1,hitTestDisabled:!0}})),...e]:e},[T.shapes,p,m]),Ln=o.useLatestRef(Q);ge.useEngineLifecycle({hostRef:_,engineRef:v,documentId:C,renderedImageUrl:w,makeCallbacks:In,viewRef:Pn,readOnlyRef:N,toolRef:A,renderShapesRef:Ln,coordinateSizeRef:Kt,imageSizeRef:qt,selRef:R,regionOverlayRef:Ut,dimmedRef:Wt,syncMinimap:q,setImage:_t,setImageVisible:yt,setReady:bt,setImageStatus:Lt,onContextMenuRequest:S}),(0,s.useEffect)(()=>{v.current?.setShapes(Q,R.current),q()},[Q,R,q]),(0,s.useEffect)(()=>{v.current?.setSelection(L)},[L]),(0,s.useEffect)(()=>{v.current?.setEditing(G)},[G,b]);let Rn=o.useLatestRef(at);(0,s.useEffect)(()=>{Rn.current?.(G)},[G]),(0,s.useLayoutEffect)(()=>{I.current?.cancelGesture(),K(null)},[u,C]),(0,s.useEffect)(()=>{G&&(L.length!==1||L[0]!==G)&&K(null)},[L,G]),(0,s.useEffect)(()=>{let e=v.current;e&&(e.setFilter(O.brightness,O.contrast),e.setRenderDefaults({strokeWidth:O.strokeSize}),e.setImageSmoothing(O.imageSmoothing),q())},[O.brightness,O.contrast,O.strokeSize,O.imageSmoothing,q]),(0,s.useLayoutEffect)(()=>{b&&v.current?.setOverlays(O.showRegionMask?k:null,Ee)},[b,k,O.showRegionMask,Ee]),(0,s.useEffect)(()=>{!b||!y||q()},[b,y,O.showRegionMask,h,q]),(0,s.useEffect)(()=>{b&&v.current?.setTransformEnabled(!M&&u!==n.TOOL.BRUSH)},[M,b,u]),(0,s.useEffect)(()=>{f&&K(null)},[f]);let zn=X.finalize,Bn=X.discard;(0,s.useEffect)(()=>{wn(u,E.current.has(u)),zn(),W()},[u,wn,zn,W]),(0,s.useEffect)(()=>{Tn(L,M)},[L,u,M,Tn]),(0,s.useLayoutEffect)(()=>{En()},[T.shapes,En]),(0,s.useEffect)(()=>{b&&U()},[u,xt,Rt,b,U]);let Vn=o.useLatestRef(jt),$=l!==null,Hn=$?C:null;(0,s.useLayoutEffect)(()=>{Bn()},[Hn,Bn]);let Un=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=Hn;Un.current!==e&&(Un.current=e,S(null),K(null),T.reset($?At??[]:[]),z($?Vn.current??[]:[]),yn(),W())},[Hn,$,At,T.reset,z,yn,W]),me.useEditorHotkeys({keymap:tt,hostRef:_,actions:ce.buildHotkeyActions({history:kn,selection:Z,drawSession:Y,assistant:X,controller:()=>I.current,externalTool:()=>E.current.get(A.current),hasSelection:()=>R.current.length>0,rejectLockedEdit:P,editLocked:M,editingId:G,setEditingId:K,vertexEditTarget:()=>{let t=R.current;if(t.length!==1)return null;let n=F.current.getShapes().find(e=>e.id===t[0]);return n&&e.canEditVertices(n)?n.id:null},deleteEditingVertices:(0,s.useCallback)(()=>{let t=cn.current;if(!t||N.current)return!1;let n=v.current,r=new Set(n?.getVertexSelection()??[]);if(!r.size)return!1;let i=F.current.getShapes().find(e=>e.id===t);if(!i)return!1;let a=i.points.filter((e,t)=>!r.has(t)),ee=i.type===e.SHAPE_TYPE.LINE?2:3;return a.length<ee?!1:(F.current.update([{...i,points:a}]),n?.setVertexSelection([]),!0)},[]),zoomAtCenter:Nn,zoom100:()=>v.current?.zoom100(),zoomFit:()=>v.current?.fit(),toggleMinimap:()=>wt(e=>!e),toggleCursorGuide:()=>Vt(e=>({...e,showCursorGuide:!e.showCursorGuide})),togglePixelation:()=>Vt(e=>({...e,imageSmoothing:!e.imageSmoothing})),selectTool:e=>rt?.(e),onIdleEscape:Ne}),spaceRef:B,onSpaceDown:()=>{v.current?.setPanMode(!0),U()},onSpaceUp:()=>{v.current?.setPanMode(!1),V.current===`panning`?rn(`idle`):U()},nudge:(e,t)=>P(Z.getEditableSelection().length>0)||Z.nudgeSelection(e,t)});let Wn=(0,s.useMemo)(()=>Q.filter(t=>L.includes(t.id)&&e.isShapeVisible(t)),[Q,L]),Gn=(0,s.useMemo)(()=>J.drawPreviewShape?[...Wn,J.drawPreviewShape]:Wn,[Wn,J.drawPreviewShape]),Kn=x?se.buildContextMenuItems({strings:D.contextMenu,point:x.img,shapes:T.shapes,selectedIds:L,hostReadOnly:!!ke,editLocked:M,selection:Z,canMergeSelection:Ue,history:kn,enterVertexEdit:K,zoomToSelection:Mn,refineShape:g?X.refineShape:void 0}):[],qn=x&&Be?Be(Kn,{selectedIds:L,readOnly:M}):Kn,Jn=_e.useMinimapNavigation({engineRef:v,image:y,wheelZoom:O.wheelZoom,minimapSize:204}),Yn=v.current?.viewport??Ce,Xn=(0,s.useCallback)(()=>{v.current?.zoom100()},[]),Zn=(0,s.useCallback)(()=>{wt(e=>!e)},[]),Qn=(0,s.useCallback)(()=>{Et(e=>!e)},[]),$n=(0,s.useCallback)(()=>{Et(!1)},[]);return(0,c.jsxs)(`div`,{className:`aivex:relative aivex:h-full aivex:w-full aivex:overflow-hidden aivex:bg-black`,children:[(0,c.jsx)(`div`,{ref:_,role:`application`,"aria-label":D.canvasLabel,tabIndex:0,onPointerDownCapture:e=>e.currentTarget.focus({preventScroll:!0}),className:`aivex:h-full aivex:w-full`,style:{opacity:+!!vt,transition:vt?`opacity 0.3s ease`:`none`}}),Pt!==`ready`&&(0,c.jsx)(ee.ImageStateOverlay,{status:Pt,error:Ft,render:Te,loadingLabel:D.imageLoading,missingLabel:D.imageMissing,errorLabel:D.imageLoadError,errorActions:D.imageErrorActions,errorHints:D.imageErrorHints}),b&&y&&(0,c.jsxs)(`div`,{className:`aivex:pointer-events-none aivex:absolute aivex:inset-0 aivex:overflow-hidden`,children:[Gn.length>0&&(0,c.jsx)(`div`,{className:`aivex:absolute aivex:inset-0`,children:(0,c.jsx)(re.SelectionInfo,{shapes:Gn,getLabel:Ze,hideDot:Qe,formatInfo:$e,register:J.register,viewport:Yn})}),(0,c.jsxs)(`div`,{ref:mt,style:{position:`absolute`,top:0,left:0,width:y.w,height:y.h,transformOrigin:`0 0`},children:[!!qe?.length&&Je&&(0,c.jsx)(ne.OverlayMarkers,{markers:qe,width:y.w,height:y.h,render:Je,onClick:Ye}),Xe?.({image:y,viewport:Yn}),g&&(X.status===`loading`||X.boxes.length>0)&&(0,c.jsx)(r.AssistantOverlay,{image:y,points:X.points,boxes:X.boxes,status:X.status})]})]}),b&&O.showCursorGuide&&(0,c.jsx)(a.CursorGuide,{color:`#1e88e5`}),y&&Le&&(0,c.jsx)(te.Minimap,{image:y,imageUrl:w,imageVisible:vt,loading:!b,region:k,roiMaskId:gt,shapes:Q,view:O,viewDefaults:Bt,onChangeView:Ht,nav:Jn,registerShape:dn,rectRef:pt,zoomLabelRef:ht,onZoom100:Xn,open:Ct,onToggleOpen:Zn,position:Re,labels:D.minimap,settingsLabels:D.viewSettings,settingsItems:He,showSettings:ze,settingsOpen:Tt,onToggleSettings:Qn,onCloseSettings:$n}),x&&(0,c.jsx)(i.ContextMenu,{x:x.x,y:x.y,items:qn,onClose:()=>S(null)})]})}exports.ShapeEditor=l;
2
2
  //# sourceMappingURL=ShapeEditor.cjs.map