@ncds/ui-admin 1.8.21-alpha.8 → 1.8.21

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 (56) hide show
  1. package/dist/cjs/src/components/feedback-and-status/badge/Badge.js +1 -1
  2. package/dist/cjs/src/components/forms-and-input/input-base/InputBase.js +13 -7
  3. package/dist/cjs/src/components/forms-and-input/input-base/__tests__/InputBase.test.js +16 -11
  4. package/dist/cjs/src/components/navigation/pagination/Pagination.js +3 -1
  5. package/dist/cjs/src/components/navigation/pagination/__tests__/Pagination.test.js +74 -0
  6. package/dist/cjs/src/components/overlays/notification/CalloutNotification.js +6 -1
  7. package/dist/cjs/src/components/overlays/notification/Notification.js +22 -2
  8. package/dist/cjs/src/components/overlays/notification/__tests__/CalloutNotification.test.js +128 -0
  9. package/dist/cjs/src/components/overlays/notification/__tests__/Notification.test.js +83 -0
  10. package/dist/cjs/src/components/overlays/postcode-search-modal/PostcodeSearchModal.js +72 -90
  11. package/dist/cjs/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.js +70 -0
  12. package/dist/cjs/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.js +96 -39
  13. package/dist/cjs/src/generated/scoped-css.js +1 -1
  14. package/dist/esm/src/components/feedback-and-status/badge/Badge.js +1 -1
  15. package/dist/esm/src/components/forms-and-input/input-base/InputBase.js +13 -7
  16. package/dist/esm/src/components/forms-and-input/input-base/__tests__/InputBase.test.js +16 -11
  17. package/dist/esm/src/components/navigation/pagination/Pagination.js +3 -1
  18. package/dist/esm/src/components/navigation/pagination/__tests__/Pagination.test.js +74 -0
  19. package/dist/esm/src/components/overlays/notification/CalloutNotification.js +6 -1
  20. package/dist/esm/src/components/overlays/notification/Notification.js +22 -2
  21. package/dist/esm/src/components/overlays/notification/__tests__/CalloutNotification.test.js +125 -0
  22. package/dist/esm/src/components/overlays/notification/__tests__/Notification.test.js +80 -0
  23. package/dist/esm/src/components/overlays/postcode-search-modal/PostcodeSearchModal.js +72 -90
  24. package/dist/esm/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.js +63 -0
  25. package/dist/esm/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.js +96 -39
  26. package/dist/esm/src/generated/scoped-css.js +1 -1
  27. package/dist/temp/src/components/feedback-and-status/badge/Badge.d.ts +1 -1
  28. package/dist/temp/src/components/feedback-and-status/badge/Badge.js +1 -1
  29. package/dist/temp/src/components/forms-and-input/input-base/InputBase.js +10 -4
  30. package/dist/temp/src/components/forms-and-input/input-base/__tests__/InputBase.test.js +14 -12
  31. package/dist/temp/src/components/navigation/pagination/Pagination.js +3 -1
  32. package/dist/temp/src/components/navigation/pagination/__tests__/Pagination.test.js +74 -0
  33. package/dist/temp/src/components/overlays/notification/CalloutNotification.d.ts +3 -1
  34. package/dist/temp/src/components/overlays/notification/CalloutNotification.js +5 -1
  35. package/dist/temp/src/components/overlays/notification/Notification.d.ts +12 -2
  36. package/dist/temp/src/components/overlays/notification/Notification.js +9 -4
  37. package/dist/temp/src/components/overlays/notification/__tests__/CalloutNotification.test.d.ts +1 -0
  38. package/dist/temp/src/components/overlays/notification/__tests__/CalloutNotification.test.js +108 -0
  39. package/dist/temp/src/components/overlays/notification/__tests__/Notification.test.d.ts +1 -0
  40. package/dist/temp/src/components/overlays/notification/__tests__/Notification.test.js +71 -0
  41. package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModal.d.ts +2 -6
  42. package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModal.js +38 -27
  43. package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.d.ts +16 -0
  44. package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.js +24 -0
  45. package/dist/temp/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.js +82 -35
  46. package/dist/temp/src/generated/scoped-css.js +1 -1
  47. package/dist/types/src/components/feedback-and-status/badge/Badge.d.ts +1 -1
  48. package/dist/types/src/components/overlays/notification/CalloutNotification.d.ts +3 -1
  49. package/dist/types/src/components/overlays/notification/Notification.d.ts +12 -2
  50. package/dist/types/src/components/overlays/notification/__tests__/CalloutNotification.test.d.ts +1 -0
  51. package/dist/types/src/components/overlays/notification/__tests__/Notification.test.d.ts +1 -0
  52. package/dist/types/src/components/overlays/postcode-search-modal/PostcodeSearchModal.d.ts +2 -6
  53. package/dist/types/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.d.ts +16 -0
  54. package/dist/ui-admin/assets/styles/style.css +91 -33
  55. package/package.json +1 -1
  56. package/dist/ui-admin/assets/styles/style.scoped.css +0 -8557
@@ -1,21 +1,23 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { AnnotationInfoFill } from '@ncds/ui-admin-icon';
3
2
  import classnames from 'classnames';
4
- import { useEffect, useState } from 'react';
3
+ import { useEffect, useRef, useState } from 'react';
5
4
  import { Button } from '../../action/button';
6
5
  import { EmptyState } from '../../feedback-and-status/empty-state';
7
6
  import { InputBase } from '../../forms-and-input/input-base';
8
7
  import { Radio } from '../../forms-and-input/radio';
9
8
  import { Pagination } from '../../navigation/pagination';
10
9
  import { Modal } from '../modal';
10
+ import { Tip } from './PostcodeSearchModalTip';
11
11
  /** 기획서 기준값 */
12
12
  const PAGE_SIZE = 15;
13
13
  /** 페이지 번호 그룹 크기 — 초과 시 Pagination 이 점프 버튼을 노출한다 */
14
14
  const PAGER_WINDOW = 10;
15
- /** 건수를 넘으면 Tip 압축 버전으로 전환한다 (기획서 기준) */
16
- const TIP_COMPACT_THRESHOLD = 30;
15
+ /** 검색 조합 안내 문구를 띄우는 기준 결과가 수를 넘을 때만 노출한다 */
16
+ const SEARCH_HINT_MIN_TOTAL_COUNT = 30;
17
17
  /** 반응형 전환 기준 — assets/styles/base/_variable.scss 의 $breakpoint 와 동일 */
18
18
  const MOBILE_BREAKPOINT = 768;
19
+ /** 본문 스크롤 컨테이너. Modal.Content 가 overflow-y:auto 를 갖는다. */
20
+ const SCROLL_CONTAINER_SELECTOR = '.ncua-modal__content';
19
21
  const MODAL_TITLE = '주소 찾기';
20
22
  const SEARCH_PLACEHOLDER = '도로명, 지번, 건물명 검색';
21
23
  const SEARCH_BUTTON_LABEL = '검색';
@@ -23,7 +25,6 @@ const EMPTY_TITLE = '검색 결과가 없습니다.';
23
25
  const EMPTY_DESCRIPTION = '검색어를 다시 확인해 주세요.';
24
26
  const ROAD_BADGE_LABEL = '도로명';
25
27
  const JIBUN_BADGE_LABEL = '지번';
26
- const TIP_LABEL = 'Tip';
27
28
  // 라디오 그룹 이름. `ncua-` 로 시작하면 MCP 의 BEM 추출기가 CSS 클래스로 오인하므로 접두사를 뺀다.
28
29
  const RESULT_RADIO_NAME = 'postcode-search-modal-result';
29
30
  /** E0006·E0008 외 나머지 코드는 모두 같은 문구를 쓴다(기획서: E0009~E0013 통합). */
@@ -32,25 +33,8 @@ const ERROR_HINT = {
32
33
  E0006: '시도명으로는 검색이 불가합니다.',
33
34
  E0008: '검색어를 두 글자 이상 입력해주세요.',
34
35
  };
35
- /** Tip 카드 첫 줄 안내 문구 (기획서 TIPS.searchTitle) */
36
- const TIP_TITLE = '아래 조합으로 검색하면 원하는 주소를 더 쉽게 찾을 수 있어요.';
37
- /** Tip 상세 버전에 노출할 검색어 조합과 예시 주소 (기획서 TIPS.searchTips) */
38
- const TIP_ITEMS = [
39
- { combination: '도로명 + 건물번호', example: '디지털로26길 43' },
40
- { combination: '지역명(동·리) + 번지', example: '구로동 235-3' },
41
- { combination: '지역명(동·리) + 건물명(아파트명)', example: '구로동 대륭포스트타워8차' },
42
- ];
43
- /** Tip 압축 버전 문구 — 예시 주소를 빼고 조합만 한 줄로 (기획서 TIPS.searchTipsCompact) */
44
- const TIP_COMPACT_TEXT = "'도로명+건물번호', '지역명+지번', '지역명+건물명(아파트명)'";
45
- const TIP_EXAMPLE_PREFIX = '예)';
46
- const TIP_ICON_SIZE = 16;
47
36
  /** 선택 표시를 판정하는 키. 우편번호만으로는 같은 건물의 다른 지번을 구분하지 못한다. */
48
37
  const resultKey = ({ zipCode, roadAddress, jibunAddress }) => `${zipCode}|${roadAddress}|${jibunAddress}`;
49
- const resolveTipVariant = (hasResults, totalCount) => {
50
- if (!hasResults)
51
- return 'detail';
52
- return totalCount > TIP_COMPACT_THRESHOLD ? 'compact' : null;
53
- };
54
38
  /** SSR(도큐사우루스 등)에서는 초기값을 false(=PC)로 두고 mount 이후 갱신한다. */
55
39
  const useIsMobileViewport = () => {
56
40
  const [isMobile, setIsMobile] = useState(false);
@@ -67,12 +51,34 @@ const useIsMobileViewport = () => {
67
51
  }, []);
68
52
  return isMobile;
69
53
  };
70
- const Tip = ({ compact = false, className }) => {
71
- return (_jsxs("div", { className: classnames('ncua-postcode-search-modal__tip', className), children: [!compact && (_jsxs("p", { className: "ncua-postcode-search-modal__tip-label", children: [_jsx(AnnotationInfoFill, { className: "ncua-postcode-search-modal__tip-icon", width: TIP_ICON_SIZE, height: TIP_ICON_SIZE }), TIP_LABEL] })), _jsx("p", { className: "ncua-postcode-search-modal__tip-title", children: TIP_TITLE }), compact ? (_jsx("p", { className: "ncua-postcode-search-modal__tip-compact-text", children: TIP_COMPACT_TEXT })) : (_jsx("ul", { className: "ncua-postcode-search-modal__tip-list", children: TIP_ITEMS.map(({ combination, example }) => (_jsxs("li", { className: "ncua-postcode-search-modal__tip-item", children: [_jsx("span", { className: "ncua-postcode-search-modal__tip-combination", children: combination }), _jsx("span", { className: "ncua-postcode-search-modal__tip-example", children: `${TIP_EXAMPLE_PREFIX} ${example}` })] }, combination))) }))] }));
54
+ /**
55
+ * 본문이 위로 스크롤됐는지 여부.
56
+ * 고정된 검색 영역과 스크롤되는 결과 사이의 경계선을 스크롤 중에만 그리기 위해 쓴다.
57
+ * enabled 가 false 면 감시를 걸지 않고 항상 false 를 돌려준다.
58
+ */
59
+ const useIsContentScrolled = (rootRef, enabled) => {
60
+ const [isScrolled, setIsScrolled] = useState(false);
61
+ useEffect(() => {
62
+ if (!enabled) {
63
+ setIsScrolled(false);
64
+ return;
65
+ }
66
+ const scroller = rootRef.current?.closest(SCROLL_CONTAINER_SELECTOR);
67
+ if (!scroller)
68
+ return;
69
+ const sync = () => setIsScrolled(scroller.scrollTop > 0);
70
+ // 결과가 바뀌어도 스크롤 위치는 남을 수 있어 구독 시점의 값으로 먼저 맞춘다.
71
+ sync();
72
+ scroller.addEventListener('scroll', sync, { passive: true });
73
+ return () => {
74
+ scroller.removeEventListener('scroll', sync);
75
+ };
76
+ }, [rootRef, enabled]);
77
+ return isScrolled;
72
78
  };
73
- Tip.displayName = 'PostcodeSearchModal.Tip';
74
79
  const PostcodeSearchModal = ({ open, onClose, zIndex, className, searchQuery, onSearchQueryChange, onSearch, results, totalCount, currentPage, onPageChange, pageSize = PAGE_SIZE, loading = false, errorCode, onSelect, }) => {
75
80
  const isMobile = useIsMobileViewport();
81
+ const rootRef = useRef(null);
76
82
  // 선택 표시는 컴포넌트가 직접 들고 있는다. 사용처는 onSelect 로 값만 받으면 된다.
77
83
  // 우편번호는 한 페이지에 중복될 수 있어 주소 전체를 키로 쓴다.
78
84
  const [selectedKey, setSelectedKey] = useState();
@@ -90,10 +96,13 @@ const PostcodeSearchModal = ({ open, onClose, zIndex, className, searchQuery, on
90
96
  }, [open]);
91
97
  const hasError = Boolean(errorCode);
92
98
  const hasResults = !hasError && results.length > 0;
99
+ // 결과가 적으면 굳이 검색 조합을 안내하지 않는다.
100
+ const showSearchHint = hasResults && totalCount > SEARCH_HINT_MIN_TOTAL_COUNT;
93
101
  // 검색을 실행한 검색어와 현재 입력값이 같을 때만 "결과 없음"으로 본다.
94
102
  // 입력 중에는 두 값이 달라지고, 응답을 기다리는 동안에는 loading 이 막는다.
95
103
  const showEmptyState = !hasError && !loading && results.length === 0 && searchQuery !== '' && searchQuery === searchedQuery;
96
- const tipVariant = resolveTipVariant(hasResults, totalCount);
104
+ // 결과 목록이 있을 때만 스크롤이 생기므로 그때만 감시한다.
105
+ const isContentScrolled = useIsContentScrolled(rootRef, open && hasResults);
97
106
  const handleSearchQueryChange = (event) => {
98
107
  onSearchQueryChange(event.target.value);
99
108
  };
@@ -108,7 +117,9 @@ const PostcodeSearchModal = ({ open, onClose, zIndex, className, searchQuery, on
108
117
  event.preventDefault();
109
118
  handleSearch();
110
119
  };
111
- return (_jsxs(Modal, { isOpen: open, onClose: onClose, size: "md", zIndex: zIndex, className: className, children: [_jsx(Modal.Header, { title: MODAL_TITLE, onClose: onClose, showDivider: true }), _jsx(Modal.Content, { children: _jsxs("div", { className: "ncua-postcode-search-modal", children: [_jsxs("div", { className: "ncua-postcode-search-modal__search", children: [_jsx(InputBase, { className: "ncua-postcode-search-modal__search-input", size: "sm", fullWidth: true, value: searchQuery, onChange: handleSearchQueryChange, onKeyDown: handleSearchKeyDown, placeholder: SEARCH_PLACEHOLDER, destructive: hasError, hintText: errorCode ? (ERROR_HINT[errorCode] ?? DEFAULT_ERROR_HINT) : undefined }), _jsx(Button, { className: "ncua-postcode-search-modal__search-button", label: SEARCH_BUTTON_LABEL, size: "sm", hierarchy: "secondary", onClick: handleSearch })] }), tipVariant && _jsx(PostcodeSearchModal.Tip, { compact: tipVariant === 'compact' }), hasResults && (_jsxs(_Fragment, { children: [_jsxs("p", { className: "ncua-postcode-search-modal__count", children: ["\uAC80\uC0C9 ", _jsx("b", { children: totalCount }), "\uAC1C"] }), _jsx("ul", { className: "ncua-postcode-search-modal__list", children: results.map((result, index) => (_jsx("li", { className: "ncua-postcode-search-modal__item", children: _jsx(Radio, { name: RESULT_RADIO_NAME, value: result.zipCode, checked: selectedKey === resultKey(result), onChange: () => {
120
+ return (_jsxs(Modal, { isOpen: open, onClose: onClose, size: "md", zIndex: zIndex, className: className, children: [_jsx(Modal.Header, { title: MODAL_TITLE, onClose: onClose, showDivider: true }), _jsx(Modal.Content, { children: _jsxs("div", { className: "ncua-postcode-search-modal", ref: rootRef, children: [_jsxs("div", { className: classnames('ncua-postcode-search-modal__search-area', {
121
+ 'is-fixed': hasResults && isContentScrolled,
122
+ }), children: [_jsxs("div", { className: "ncua-postcode-search-modal__search", children: [_jsx(InputBase, { className: "ncua-postcode-search-modal__search-input", size: "sm", fullWidth: true, value: searchQuery, clearText: !!searchQuery, onClearText: () => onSearchQueryChange(''), onChange: handleSearchQueryChange, onKeyDown: handleSearchKeyDown, placeholder: SEARCH_PLACEHOLDER, destructive: hasError, hintText: errorCode ? (ERROR_HINT[errorCode] ?? DEFAULT_ERROR_HINT) : undefined }), _jsx(Button, { className: "ncua-postcode-search-modal__search-button", label: SEARCH_BUTTON_LABEL, size: "sm", hierarchy: "secondary", onClick: handleSearch })] }), showSearchHint && (_jsxs("div", { children: [_jsx("p", { className: "ncua-postcode-search-modal__result-title", children: "\uC544\uB798 \uC870\uD569\uC73C\uB85C \uAC80\uC0C9 \uC2DC \uC8FC\uC18C\uB97C \uB354 \uC27D\uAC8C \uCC3E\uC744 \uC218 \uC788\uC5B4\uC694." }), _jsx("p", { className: "ncua-postcode-search-modal__result-desc", children: "\uB3C4\uB85C\uBA85+\uAC74\uBB3C\uBC88\uD638, \uC9C0\uC5ED\uBA85+\uC9C0\uBC88, \uC9C0\uC5ED\uBA85+\uAC74\uBB3C\uBA85(\uC544\uD30C\uD2B8\uBA85)" })] }))] }), !hasResults && _jsx(PostcodeSearchModal.Tip, {}), hasResults && (_jsxs(_Fragment, { children: [_jsxs("p", { className: "ncua-postcode-search-modal__count", children: ["\uAC80\uC0C9 ", _jsx("b", { children: totalCount }), "\uAC1C"] }), _jsx("ul", { className: "ncua-postcode-search-modal__list", children: results.map((result, index) => (_jsx("li", { className: "ncua-postcode-search-modal__item", children: _jsx(Radio, { name: RESULT_RADIO_NAME, value: result.zipCode, checked: selectedKey === resultKey(result), onChange: () => {
112
123
  setSelectedKey(resultKey(result));
113
124
  onSelect(result);
114
125
  }, text: _jsxs(_Fragment, { children: [_jsxs("span", { className: "ncua-postcode-search-modal__addr-line", children: [_jsx("span", { className: "ncua-postcode-search-modal__badge", children: ROAD_BADGE_LABEL }), _jsx("span", { className: "ncua-postcode-search-modal__item-road", children: result.roadAddress }), _jsx("span", { className: "ncua-postcode-search-modal__item-zip", children: result.zipCode })] }), _jsxs("span", { className: "ncua-postcode-search-modal__addr-line", children: [_jsx("span", { className: "ncua-postcode-search-modal__badge", children: JIBUN_BADGE_LABEL }), _jsx("span", { className: "ncua-postcode-search-modal__item-jibun", children: result.jibunAddress })] })] }) }) }, `${result.zipCode}-${index}`))) }), _jsx("div", { className: "ncua-postcode-search-modal__pagination", children: _jsx(Pagination, { totalCount: totalCount, itemCountPerPage: pageSize, pageCount: PAGER_WINDOW, currentPage: currentPage, breakPoint: isMobile ? 'mo' : 'pc', onPageChange: onPageChange }) })] })), showEmptyState && (_jsx("div", { className: "ncua-postcode-search-modal__empty", children: _jsx(EmptyState, { title: EMPTY_TITLE, description: EMPTY_DESCRIPTION }) }))] }) })] }));
@@ -0,0 +1,16 @@
1
+ interface PostcodeSearchModalTipProps {
2
+ className?: string;
3
+ }
4
+ /** Tip 카드 첫 줄 안내 문구 (기획서 TIPS.searchTitle) */
5
+ declare const TIP_TITLE = "\uC544\uB798 \uC870\uD569\uC73C\uB85C \uAC80\uC0C9\uD558\uBA74 \uC6D0\uD558\uB294 \uC8FC\uC18C\uB97C \uB354 \uC27D\uAC8C \uCC3E\uC744 \uC218 \uC788\uC5B4\uC694.";
6
+ /**
7
+ * 검색어 조합을 안내하는 Tip 카드.
8
+ * 결과 목록이 없는 화면(초기·오류·결과 없음)에서만 노출된다.
9
+ * 결과가 있을 때는 모달이 안내 문구 한 줄만 검색 영역에 붙여 고정한다.
10
+ */
11
+ declare const Tip: {
12
+ ({ className }: PostcodeSearchModalTipProps): import("react/jsx-runtime").JSX.Element;
13
+ displayName: string;
14
+ };
15
+ export { Tip, TIP_TITLE };
16
+ export type { PostcodeSearchModalTipProps };
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { AnnotationInfoFill } from '@ncds/ui-admin-icon';
3
+ import classnames from 'classnames';
4
+ const TIP_LABEL = 'Tip';
5
+ /** Tip 카드 첫 줄 안내 문구 (기획서 TIPS.searchTitle) */
6
+ const TIP_TITLE = '아래 조합으로 검색하면 원하는 주소를 더 쉽게 찾을 수 있어요.';
7
+ /** Tip 에 노출할 검색어 조합과 예시 주소 (기획서 TIPS.searchTips) */
8
+ const TIP_ITEMS = [
9
+ { combination: '도로명 + 건물번호', example: '디지털로26길 43' },
10
+ { combination: '지역명(동·리) + 번지', example: '구로동 235-3' },
11
+ { combination: '지역명(동·리) + 건물명(아파트명)', example: '구로동 대륭포스트타워8차' },
12
+ ];
13
+ const TIP_EXAMPLE_PREFIX = '예)';
14
+ const TIP_ICON_SIZE = 16;
15
+ /**
16
+ * 검색어 조합을 안내하는 Tip 카드.
17
+ * 결과 목록이 없는 화면(초기·오류·결과 없음)에서만 노출된다.
18
+ * 결과가 있을 때는 모달이 안내 문구 한 줄만 검색 영역에 붙여 고정한다.
19
+ */
20
+ const Tip = ({ className }) => {
21
+ return (_jsxs("div", { className: classnames('ncua-postcode-search-modal__tip', className), children: [_jsxs("p", { className: "ncua-postcode-search-modal__tip-label", children: [_jsx(AnnotationInfoFill, { className: "ncua-postcode-search-modal__tip-icon", width: TIP_ICON_SIZE, height: TIP_ICON_SIZE }), TIP_LABEL] }), _jsx("p", { className: "ncua-postcode-search-modal__tip-title", children: TIP_TITLE }), _jsx("ul", { className: "ncua-postcode-search-modal__tip-list", children: TIP_ITEMS.map(({ combination, example }) => (_jsxs("li", { className: "ncua-postcode-search-modal__tip-item", children: [_jsx("span", { className: "ncua-postcode-search-modal__tip-combination", children: combination }), _jsx("span", { className: "ncua-postcode-search-modal__tip-example", children: `${TIP_EXAMPLE_PREFIX} ${example}` })] }, combination))) })] }));
22
+ };
23
+ Tip.displayName = 'PostcodeSearchModal.Tip';
24
+ export { Tip, TIP_TITLE };
@@ -7,11 +7,11 @@ import { PostcodeSearchModal } from '../PostcodeSearchModal';
7
7
  // React 18에서 act() 사용 시 필요한 플래그 (미설정 시 console.error 경고 발생)
8
8
  globalThis.IS_REACT_ACT_ENVIRONMENT = true;
9
9
  const PAGE_SIZE = 15;
10
- /** Tip 압축 임계값(30) 이하 결과 건수 — Tip 미노출 케이스 */
10
+ /** 페이지에 들어가는 결과 건수 — Tip 카드 미노출 케이스 */
11
11
  const SMALL_RESULT_COUNT = 5;
12
12
  /** SMALL_RESULT_COUNT 기준 총 페이지 수 */
13
13
  const SMALL_RESULT_TOTAL_PAGE = 1;
14
- /** Tip 압축 임계값(30) 초과 결과 건수 — Tip 압축 + totalPage(3) <= 페이지 그룹 크기(10) */
14
+ /** 여러 페이지로 나뉘는 결과 건수 — totalPage(3) <= 페이지 그룹 크기(10) */
15
15
  const LARGE_RESULT_COUNT = 45;
16
16
  /** LARGE_RESULT_COUNT 기준 총 페이지 수 */
17
17
  const LARGE_RESULT_TOTAL_PAGE = 3;
@@ -19,6 +19,10 @@ const LARGE_RESULT_TOTAL_PAGE = 3;
19
19
  const HUGE_RESULT_COUNT = 200;
20
20
  /** 클릭 대상 페이지 번호 */
21
21
  const TARGET_PAGE = 3;
22
+ /** 본문을 아래로 내린 상태를 흉내 낼 scrollTop 값 */
23
+ const SCROLLED_OFFSET = 120;
24
+ /** 맨 위로 되돌린 scrollTop 값 */
25
+ const SCROLL_TOP = 0;
22
26
  /** 결과 더미 생성 기준값 */
23
27
  const ZIP_CODE_BASE = 13529;
24
28
  const ROAD_NUMBER_BASE = 242;
@@ -89,7 +93,21 @@ function baseProps(overrides = {}) {
89
93
  };
90
94
  }
91
95
  const tipOf = (el) => el.querySelector('.ncua-postcode-search-modal__tip');
92
- const isCompactTip = (el) => Boolean(el.querySelector('.ncua-postcode-search-modal__tip-compact-text'));
96
+ const searchAreaOf = (el) => el.querySelector('.ncua-postcode-search-modal__search-area');
97
+ const isFixedSearchArea = (el) => Boolean(searchAreaOf(el)?.classList.contains('is-fixed'));
98
+ const scrollerOf = (el) => el.querySelector('.ncua-modal__content');
99
+ /** jsdom 은 레이아웃이 없어 scrollTop 이 항상 0 이므로, 값을 덮어쓰고 scroll 이벤트를 쏜다. */
100
+ function scrollContent(el, scrollTop) {
101
+ const scroller = scrollerOf(el);
102
+ if (!scroller)
103
+ throw new Error('모달 본문 스크롤 컨테이너를 찾을 수 없습니다');
104
+ Object.defineProperty(scroller, 'scrollTop', { value: scrollTop, configurable: true });
105
+ act(() => {
106
+ scroller.dispatchEvent(new Event('scroll'));
107
+ });
108
+ }
109
+ const resultTitleOf = (el) => el.querySelector('.ncua-postcode-search-modal__result-title');
110
+ const resultDescOf = (el) => el.querySelector('.ncua-postcode-search-modal__result-desc');
93
111
  const countLabelOf = (el) => el.querySelector('.ncua-postcode-search-modal__count');
94
112
  const itemsOf = (el) => el.querySelectorAll('.ncua-postcode-search-modal__item');
95
113
  const inputRootOf = (el) => el.querySelector('.ncua-input');
@@ -109,13 +127,13 @@ afterEach(() => {
109
127
  vi.unstubAllGlobals();
110
128
  });
111
129
  describe('PostcodeSearchModal — Case 1: 검색 전 초기 상태', () => {
112
- it('상세 Tip 노출되고 카운트·리스트·페이지네이션·EmptyState 는 렌더되지 않는다', () => {
130
+ it('Tip 카드만 노출되고 카운트·리스트·페이지네이션·EmptyState 는 렌더되지 않는다', () => {
113
131
  // Given: 검색어·결과가 비어 있고 에러도 없는 상태에서
114
132
  // When: 모달을 열면
115
133
  const el = render(baseProps());
116
- // Then: 상세 Tip 노출되고 결과 영역은 전부 미노출이다
134
+ // Then: Tip 카드만 노출되고 결과 영역은 전부 미노출이다
117
135
  expect(tipOf(el)).not.toBeNull();
118
- expect(isCompactTip(el)).toBe(false);
136
+ expect(resultTitleOf(el)).toBeNull();
119
137
  expect(countLabelOf(el)).toBeNull();
120
138
  expect(el.querySelector('.ncua-postcode-search-modal__list')).toBeNull();
121
139
  expect(paginationOf(el)).toBeNull();
@@ -153,12 +171,12 @@ describe('PostcodeSearchModal — Case 2~4: 에러코드별 hint 매핑', () =>
153
171
  expect(inputRootOf(el)?.classList.contains('destructive')).toBe(true);
154
172
  expect(hintOf(el)?.textContent).toBe(hint);
155
173
  });
156
- it('에러 상태에서는 상세 Tip 노출되고 리스트·EmptyState 는 미노출이다', () => {
174
+ it('에러 상태에서는 Tip 카드가 노출되고 리스트·EmptyState 는 미노출이다', () => {
157
175
  // Given/When: 에러코드를 전달해 렌더하면
158
176
  const el = render(baseProps({ searchQuery: '서', errorCode: 'E0008' }));
159
- // Then: 상세 Tip 남는다
177
+ // Then: Tip 카드만 남는다
160
178
  expect(tipOf(el)).not.toBeNull();
161
- expect(isCompactTip(el)).toBe(false);
179
+ expect(resultTitleOf(el)).toBeNull();
162
180
  expect(el.querySelector('.ncua-postcode-search-modal__list')).toBeNull();
163
181
  expect(emptyStateOf(el)).toBeNull();
164
182
  expect(paginationOf(el)).toBeNull();
@@ -170,11 +188,11 @@ describe('PostcodeSearchModal — Case 5: 검색 결과 없음', () => {
170
188
  render(baseProps({ searchQuery: '', results: [], totalCount: 0 }));
171
189
  // When: 검색을 실행하지 않고 글자만 입력하면
172
190
  const el = render(baseProps({ searchQuery: '존재하지않는주소', results: [], totalCount: 0 }));
173
- // Then: "검색 결과가 없습니다." 는 뜨지 않고 상세 Tip 유지된다
191
+ // Then: "검색 결과가 없습니다." 는 뜨지 않고 Tip 카드만 유지된다
174
192
  expect(emptyStateOf(el)).toBeNull();
175
193
  expect(tipOf(el)).not.toBeNull();
176
194
  });
177
- it('EmptyState 가 "검색 결과가 없습니다." 로 렌더되고 상세 Tip 유지된다', () => {
195
+ it('EmptyState 가 "검색 결과가 없습니다." 로 렌더되고 Tip 카드가 유지된다', () => {
178
196
  // Given: 검색어는 있으나 결과가 0건인 상태에서
179
197
  const el = render(baseProps({ searchQuery: '존재하지않는주소', results: [], totalCount: 0 }));
180
198
  // When: 검색 버튼을 눌러 실제로 검색을 실행하면
@@ -184,18 +202,18 @@ describe('PostcodeSearchModal — Case 5: 검색 결과 없음', () => {
184
202
  // Then: EmptyState 가 노출되고 오류 스타일은 아니며 페이지네이션은 없다
185
203
  expect(emptyStateOf(el)?.textContent).toContain('검색 결과가 없습니다.');
186
204
  expect(tipOf(el)).not.toBeNull();
187
- expect(isCompactTip(el)).toBe(false);
205
+ expect(resultTitleOf(el)).toBeNull();
188
206
  expect(inputRootOf(el)?.classList.contains('destructive')).toBe(false);
189
207
  expect(paginationOf(el)).toBeNull();
190
208
  expect(countLabelOf(el)).toBeNull();
191
209
  });
192
210
  });
193
- describe('PostcodeSearchModal — Case 6: 결과 30건 이하', () => {
194
- it('카운트 "검색 5개" 와 5행 리스트가 렌더되고 Tip 미노출된다', () => {
211
+ describe('PostcodeSearchModal — Case 6: 결과 있음', () => {
212
+ it('카운트 "검색 5개" 와 5행 리스트가 렌더되고 Tip 카드는 미노출된다', () => {
195
213
  // Given/When: 5건 결과를 전달하면
196
214
  const results = makeResults(SMALL_RESULT_COUNT);
197
215
  const el = render(baseProps({ searchQuery: '판교로', results, totalCount: SMALL_RESULT_COUNT }));
198
- // Then: 카운트·리스트가 노출되고 Tip 사라진다
216
+ // Then: 카운트·리스트가 노출되고 Tip 카드는 사라진다
199
217
  expect(countLabelOf(el)?.textContent).toBe(`검색 ${SMALL_RESULT_COUNT}개`);
200
218
  expect(itemsOf(el)).toHaveLength(SMALL_RESULT_COUNT);
201
219
  expect(tipOf(el)).toBeNull();
@@ -224,15 +242,26 @@ describe('PostcodeSearchModal — Case 6: 결과 30건 이하', () => {
224
242
  expect(el.querySelectorAll('.ncua-pagination__page-num')).toHaveLength(SMALL_RESULT_TOTAL_PAGE);
225
243
  });
226
244
  });
227
- describe('PostcodeSearchModal — Case 7: 결과 30건 초과', () => {
228
- it('카운트 "검색 45개" 와 15행 리스트, 압축 Tip 렌더된다', () => {
245
+ describe('PostcodeSearchModal — Case 7: 결과 여러 페이지', () => {
246
+ it('카운트 "검색 45개" 와 15행 리스트가 렌더되고 Tip 카드 대신 결과 안내 문구가 남는다', () => {
229
247
  // Given/When: 45건 중 첫 페이지 15건을 전달하면
230
248
  const el = render(baseProps({ searchQuery: '판교로', results: makeResults(PAGE_SIZE), totalCount: LARGE_RESULT_COUNT }));
231
- // Then: 압축 Tip 노출된다
249
+ // Then: Tip 카드는 사라지고 검색 영역의 안내 문구(제목·조합)가 남는다
232
250
  expect(countLabelOf(el)?.textContent).toBe(`검색 ${LARGE_RESULT_COUNT}개`);
233
251
  expect(itemsOf(el)).toHaveLength(PAGE_SIZE);
234
- expect(tipOf(el)).not.toBeNull();
235
- expect(isCompactTip(el)).toBe(true);
252
+ expect(tipOf(el)).toBeNull();
253
+ expect(resultTitleOf(el)?.textContent).toBe('아래 조합으로 검색 시 주소를 더 쉽게 찾을 수 있어요.');
254
+ expect(resultDescOf(el)?.textContent).toBe('도로명+건물번호, 지역명+지번, 지역명+건물명(아파트명)');
255
+ });
256
+ it('검색 인풋과 안내 문구가 같은 고정 영역 안에 묶이고 결과 목록은 그 밖에 있다', () => {
257
+ // Given/When: 결과가 여러 페이지인 상태로 렌더하면
258
+ const el = render(baseProps({ searchQuery: '판교로', results: makeResults(PAGE_SIZE), totalCount: LARGE_RESULT_COUNT }));
259
+ // Then: 상단 고정 영역이 인풋 행과 안내 문구를 함께 감싸고, 스크롤되는 목록은 밖에 남는다
260
+ const searchArea = searchAreaOf(el);
261
+ expect(searchArea?.querySelector('.ncua-postcode-search-modal__search')).not.toBeNull();
262
+ expect(searchArea?.querySelector('.ncua-postcode-search-modal__result-title')).not.toBeNull();
263
+ expect(searchArea?.querySelector('.ncua-postcode-search-modal__result-desc')).not.toBeNull();
264
+ expect(searchArea?.querySelector('.ncua-postcode-search-modal__list')).toBeNull();
236
265
  });
237
266
  it('totalPage(3) 가 PAGER_WINDOW(10) 이하이므로 점프 버튼은 노출되지 않는다', () => {
238
267
  // Given/When: totalCount=45, PAGE_SIZE=15 → totalPage=3
@@ -251,7 +280,8 @@ describe('PostcodeSearchModal — Case 8: 결과 대량', () => {
251
280
  expect(el.querySelector('.ncua-pagination__before')).not.toBeNull();
252
281
  expect(el.querySelector('.ncua-pagination__next')).not.toBeNull();
253
282
  expect(el.querySelector('.ncua-pagination__last')).not.toBeNull();
254
- expect(isCompactTip(el)).toBe(true);
283
+ expect(tipOf(el)).toBeNull();
284
+ expect(resultTitleOf(el)).not.toBeNull();
255
285
  });
256
286
  it('3페이지 버튼을 클릭하면 onPageChange(3) 이 호출된다', () => {
257
287
  // Given: 대량 결과가 렌더된 상태에서
@@ -418,8 +448,8 @@ describe('PostcodeSearchModal — 반응형 전환', () => {
418
448
  });
419
449
  });
420
450
  describe('PostcodeSearchModal.Tip — 서브컴포넌트', () => {
421
- it('상세 모드는 조합 3종과 예시 주소를 모두 보여준다', () => {
422
- // Given/When: 상세 Tip 노출되는 초기 상태로 렌더하면
451
+ it('조합 3종과 예시 주소를 모두 보여준다', () => {
452
+ // Given/When: Tip 카드가 노출되는 초기 상태로 렌더하면
423
453
  const el = render(baseProps());
424
454
  // Then: 안내 문구와 3개 조합, 예시 주소가 모두 포함된다
425
455
  const tipText = tipOf(el)?.textContent ?? '';
@@ -431,19 +461,8 @@ describe('PostcodeSearchModal.Tip — 서브컴포넌트', () => {
431
461
  expect(tipText).toContain('지역명(동·리) + 건물명(아파트명)');
432
462
  expect(tipText).toContain('예) 구로동 대륭포스트타워8차');
433
463
  });
434
- it('압축 모드는 조합 3종만 보여주고 예시는 생략한다', () => {
435
- // Given/When: 30건 초과 결과로 압축 Tip 을 렌더하면
436
- const el = render(baseProps({ searchQuery: '판교로', results: makeResults(PAGE_SIZE), totalCount: LARGE_RESULT_COUNT }));
437
- // Then: 조합만 한 줄로 남고 예시 주소는 없다
438
- const tipText = tipOf(el)?.textContent ?? '';
439
- expect(tipText).toContain('아래 조합으로 검색하면 원하는 주소를 더 쉽게 찾을 수 있어요.');
440
- expect(tipText).toContain("'도로명+건물번호', '지역명+지번', '지역명+건물명(아파트명)'");
441
- expect(tipText).not.toContain('디지털로26길 43');
442
- expect(tipText).not.toContain('구로동 235-3');
443
- expect(tipText).not.toContain('구로동 대륭포스트타워8차');
444
- });
445
464
  it('Tip 아이콘은 하드코딩 SVG 가 아니라 아이콘 슬롯 클래스로 렌더된다', () => {
446
- // Given/When: 상세 Tip 렌더하면
465
+ // Given/When: Tip 카드를 렌더하면
447
466
  const el = render(baseProps());
448
467
  // Then: 지정한 아이콘 클래스를 가진 svg 가 존재한다
449
468
  expect(tipOf(el)?.querySelector('svg.ncua-postcode-search-modal__tip-icon')).not.toBeNull();
@@ -454,3 +473,31 @@ describe('PostcodeSearchModal.Tip — 서브컴포넌트', () => {
454
473
  expect(PostcodeSearchModal.Tip.displayName).toBe('PostcodeSearchModal.Tip');
455
474
  });
456
475
  });
476
+ describe('PostcodeSearchModal — 검색 영역 고정 표시', () => {
477
+ it('결과가 있어도 스크롤하기 전에는 is-fixed 가 붙지 않는다', () => {
478
+ // Given/When: 결과를 스크롤하지 않은 상태로 렌더하면
479
+ const el = render(baseProps({ searchQuery: '판교로', results: makeResults(PAGE_SIZE), totalCount: LARGE_RESULT_COUNT }));
480
+ // Then: 검색 영역이 아직 떠 있지 않으므로 경계선 클래스도 없다
481
+ expect(isFixedSearchArea(el)).toBe(false);
482
+ });
483
+ it('결과를 스크롤하면 is-fixed 가 붙고, 맨 위로 돌아오면 다시 사라진다', () => {
484
+ // Given: 결과가 렌더된 상태에서
485
+ const el = render(baseProps({ searchQuery: '판교로', results: makeResults(PAGE_SIZE), totalCount: LARGE_RESULT_COUNT }));
486
+ // When: 본문을 아래로 스크롤하면
487
+ scrollContent(el, SCROLLED_OFFSET);
488
+ // Then: 경계선 클래스가 붙는다
489
+ expect(isFixedSearchArea(el)).toBe(true);
490
+ // When: 다시 맨 위로 올리면
491
+ scrollContent(el, SCROLL_TOP);
492
+ // Then: 경계선 클래스가 사라진다
493
+ expect(isFixedSearchArea(el)).toBe(false);
494
+ });
495
+ it('결과가 없으면 스크롤이 일어나도 is-fixed 가 붙지 않는다', () => {
496
+ // Given: 초기 상태(결과 없음)로 렌더하고
497
+ const el = render(baseProps());
498
+ // When: 본문 스크롤 이벤트가 들어와도
499
+ scrollContent(el, SCROLLED_OFFSET);
500
+ // Then: 고정할 대상이 없으므로 클래스는 붙지 않는다
501
+ expect(isFixedSearchArea(el)).toBe(false);
502
+ });
503
+ });