@ncds/ui-admin 1.8.21-alpha.1 → 1.8.21-alpha.10

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 (125) hide show
  1. package/dist/cjs/assets/scripts/notification/FullWidthNotification.js +17 -6
  2. package/dist/cjs/assets/scripts/notification/MessageNotification.js +10 -48
  3. package/dist/cjs/assets/scripts/notification/const/classNames.js +3 -0
  4. package/dist/cjs/assets/scripts/notification/const/index.js +1 -1
  5. package/dist/cjs/assets/scripts/notification/const/sizes.js +4 -2
  6. package/dist/cjs/assets/scripts/notification/messageTemplate.js +106 -0
  7. package/dist/cjs/assets/scripts/notification/utils.js +40 -4
  8. package/dist/cjs/constant/notification.js +21 -0
  9. package/dist/cjs/src/components/forms-and-input/input-base/InputBase.js +30 -18
  10. package/dist/cjs/src/components/forms-and-input/input-base/__tests__/InputBase.test.js +116 -0
  11. package/dist/cjs/src/components/forms-and-input/password-input/PasswordInput.js +3 -3
  12. package/dist/cjs/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.js +59 -0
  13. package/dist/cjs/src/components/index.js +11 -0
  14. package/dist/cjs/src/components/layout/ncua-scope/NcuaScope.js +8 -2
  15. package/dist/cjs/src/components/navigation/pagination/Pagination.js +3 -1
  16. package/dist/cjs/src/components/navigation/pagination/__tests__/Pagination.test.js +74 -0
  17. package/dist/cjs/src/components/overlays/notification/FullWidthNotification.js +3 -1
  18. package/dist/cjs/src/components/overlays/notification/MessageNotification.js +14 -54
  19. package/dist/cjs/src/components/overlays/notification/MessageNotificationParts.js +92 -0
  20. package/dist/cjs/src/components/overlays/notification/__tests__/MessageNotification.test.js +246 -0
  21. package/dist/cjs/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.js +209 -0
  22. package/dist/cjs/src/components/overlays/postcode-search-modal/PostcodeSearchModal.js +259 -0
  23. package/dist/cjs/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.js +70 -0
  24. package/dist/cjs/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.js +623 -0
  25. package/dist/cjs/src/components/overlays/postcode-search-modal/index.js +16 -0
  26. package/dist/cjs/src/generated/scoped-css.js +1 -1
  27. package/dist/esm/assets/scripts/notification/FullWidthNotification.js +17 -6
  28. package/dist/esm/assets/scripts/notification/MessageNotification.js +12 -50
  29. package/dist/esm/assets/scripts/notification/const/classNames.js +3 -0
  30. package/dist/esm/assets/scripts/notification/const/index.js +3 -2
  31. package/dist/esm/assets/scripts/notification/const/sizes.js +4 -2
  32. package/dist/esm/assets/scripts/notification/messageTemplate.js +100 -0
  33. package/dist/esm/assets/scripts/notification/utils.js +39 -4
  34. package/dist/esm/constant/notification.js +15 -0
  35. package/dist/esm/src/components/forms-and-input/input-base/InputBase.js +30 -18
  36. package/dist/esm/src/components/forms-and-input/input-base/__tests__/InputBase.test.js +116 -0
  37. package/dist/esm/src/components/forms-and-input/password-input/PasswordInput.js +3 -3
  38. package/dist/esm/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.js +56 -0
  39. package/dist/esm/src/components/index.js +1 -0
  40. package/dist/esm/src/components/layout/ncua-scope/NcuaScope.js +8 -2
  41. package/dist/esm/src/components/navigation/pagination/Pagination.js +3 -1
  42. package/dist/esm/src/components/navigation/pagination/__tests__/Pagination.test.js +74 -0
  43. package/dist/esm/src/components/overlays/notification/FullWidthNotification.js +3 -1
  44. package/dist/esm/src/components/overlays/notification/MessageNotification.js +15 -55
  45. package/dist/esm/src/components/overlays/notification/MessageNotificationParts.js +85 -0
  46. package/dist/esm/src/components/overlays/notification/__tests__/MessageNotification.test.js +243 -0
  47. package/dist/esm/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.js +206 -0
  48. package/dist/esm/src/components/overlays/postcode-search-modal/PostcodeSearchModal.js +252 -0
  49. package/dist/esm/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.js +63 -0
  50. package/dist/esm/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.js +620 -0
  51. package/dist/esm/src/components/overlays/postcode-search-modal/index.js +1 -0
  52. package/dist/esm/src/generated/scoped-css.js +1 -1
  53. package/dist/temp/assets/scripts/notification/FullWidthNotification.d.ts +6 -0
  54. package/dist/temp/assets/scripts/notification/FullWidthNotification.js +14 -5
  55. package/dist/temp/assets/scripts/notification/MessageNotification.d.ts +0 -3
  56. package/dist/temp/assets/scripts/notification/MessageNotification.js +9 -44
  57. package/dist/temp/assets/scripts/notification/const/classNames.d.ts +1 -0
  58. package/dist/temp/assets/scripts/notification/const/classNames.js +3 -0
  59. package/dist/temp/assets/scripts/notification/const/index.d.ts +3 -3
  60. package/dist/temp/assets/scripts/notification/const/index.js +3 -2
  61. package/dist/temp/assets/scripts/notification/const/sizes.d.ts +2 -2
  62. package/dist/temp/assets/scripts/notification/const/sizes.js +4 -2
  63. package/dist/temp/assets/scripts/notification/const/types.d.ts +30 -2
  64. package/dist/temp/assets/scripts/notification/messageTemplate.d.ts +15 -0
  65. package/dist/temp/assets/scripts/notification/messageTemplate.js +79 -0
  66. package/dist/temp/assets/scripts/notification/utils.d.ts +19 -2
  67. package/dist/temp/assets/scripts/notification/utils.js +39 -5
  68. package/dist/temp/constant/notification.d.ts +15 -0
  69. package/dist/temp/constant/notification.js +15 -0
  70. package/dist/temp/src/components/forms-and-input/input-base/InputBase.d.ts +1 -1
  71. package/dist/temp/src/components/forms-and-input/input-base/InputBase.js +26 -14
  72. package/dist/temp/src/components/forms-and-input/input-base/__tests__/InputBase.test.js +79 -0
  73. package/dist/temp/src/components/forms-and-input/password-input/PasswordInput.js +2 -2
  74. package/dist/temp/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.d.ts +1 -0
  75. package/dist/temp/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.js +48 -0
  76. package/dist/temp/src/components/index.d.ts +1 -0
  77. package/dist/temp/src/components/index.js +1 -0
  78. package/dist/temp/src/components/layout/ncua-scope/NcuaScope.js +5 -1
  79. package/dist/temp/src/components/navigation/pagination/Pagination.js +3 -1
  80. package/dist/temp/src/components/navigation/pagination/__tests__/Pagination.test.js +74 -0
  81. package/dist/temp/src/components/overlays/notification/FullWidthNotification.d.ts +6 -0
  82. package/dist/temp/src/components/overlays/notification/FullWidthNotification.js +3 -2
  83. package/dist/temp/src/components/overlays/notification/MessageNotification.d.ts +6 -0
  84. package/dist/temp/src/components/overlays/notification/MessageNotification.js +4 -13
  85. package/dist/temp/src/components/overlays/notification/MessageNotificationParts.d.ts +28 -0
  86. package/dist/temp/src/components/overlays/notification/MessageNotificationParts.js +28 -0
  87. package/dist/temp/src/components/overlays/notification/Notification.d.ts +11 -2
  88. package/dist/temp/src/components/overlays/notification/__tests__/MessageNotification.test.d.ts +1 -0
  89. package/dist/temp/src/components/overlays/notification/__tests__/MessageNotification.test.js +190 -0
  90. package/dist/temp/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.d.ts +1 -0
  91. package/dist/temp/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.js +160 -0
  92. package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModal.d.ts +45 -0
  93. package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModal.js +125 -0
  94. package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.d.ts +16 -0
  95. package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.js +24 -0
  96. package/dist/temp/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.d.ts +1 -0
  97. package/dist/temp/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.js +503 -0
  98. package/dist/temp/src/components/overlays/postcode-search-modal/index.d.ts +1 -0
  99. package/dist/temp/src/components/overlays/postcode-search-modal/index.js +1 -0
  100. package/dist/temp/src/generated/scoped-css.js +1 -1
  101. package/dist/types/assets/scripts/notification/FullWidthNotification.d.ts +6 -0
  102. package/dist/types/assets/scripts/notification/MessageNotification.d.ts +0 -3
  103. package/dist/types/assets/scripts/notification/const/classNames.d.ts +1 -0
  104. package/dist/types/assets/scripts/notification/const/index.d.ts +3 -3
  105. package/dist/types/assets/scripts/notification/const/sizes.d.ts +2 -2
  106. package/dist/types/assets/scripts/notification/const/types.d.ts +30 -2
  107. package/dist/types/assets/scripts/notification/messageTemplate.d.ts +15 -0
  108. package/dist/types/assets/scripts/notification/utils.d.ts +19 -2
  109. package/dist/types/constant/notification.d.ts +15 -0
  110. package/dist/types/src/components/forms-and-input/input-base/InputBase.d.ts +1 -1
  111. package/dist/types/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.d.ts +1 -0
  112. package/dist/types/src/components/index.d.ts +1 -0
  113. package/dist/types/src/components/overlays/notification/FullWidthNotification.d.ts +6 -0
  114. package/dist/types/src/components/overlays/notification/MessageNotification.d.ts +6 -0
  115. package/dist/types/src/components/overlays/notification/MessageNotificationParts.d.ts +28 -0
  116. package/dist/types/src/components/overlays/notification/Notification.d.ts +11 -2
  117. package/dist/types/src/components/overlays/notification/__tests__/MessageNotification.test.d.ts +1 -0
  118. package/dist/types/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.d.ts +1 -0
  119. package/dist/types/src/components/overlays/postcode-search-modal/PostcodeSearchModal.d.ts +45 -0
  120. package/dist/types/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.d.ts +16 -0
  121. package/dist/types/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.d.ts +1 -0
  122. package/dist/types/src/components/overlays/postcode-search-modal/index.d.ts +1 -0
  123. package/dist/ui-admin/assets/styles/style.css +280 -35
  124. package/dist/ui-admin/assets/styles/style.scoped.css +280 -35
  125. package/package.json +1 -1
@@ -1,3 +1,4 @@
1
+ import { HIDE_PERMANENTLY_LABEL } from '../../../constant/notification';
1
2
  import { sanitizeHtml } from '../utils/sanitize';
2
3
  import { CLASS_NAMES, FULL_WIDTH_ICON_MAP, FULL_WIDTH_SIZES, SVG_ICONS } from './const';
3
4
  import { bindNotificationEvents, createWrapperElement, renderActions, renderSupportingText, setupAutoClose } from './utils';
@@ -24,7 +25,8 @@ export class FullWidthNotification {
24
25
  actions,
25
26
  onClose,
26
27
  supportTextLink,
27
- onHidePermanently
28
+ onHidePermanently,
29
+ hidePermanentlyLabel
28
30
  } = this.options;
29
31
  const wrapper = createWrapperElement(CLASS_NAMES.FULL_WIDTH.BASE, color, className);
30
32
  const iconHtml = FULL_WIDTH_ICON_MAP[color](FULL_WIDTH_SIZES.ICON);
@@ -35,7 +37,8 @@ export class FullWidthNotification {
35
37
  actions,
36
38
  onClose,
37
39
  supportTextLink,
38
- onHidePermanently
40
+ onHidePermanently,
41
+ hidePermanentlyLabel
39
42
  }));
40
43
  return wrapper;
41
44
  }
@@ -47,7 +50,8 @@ export class FullWidthNotification {
47
50
  actions,
48
51
  onClose,
49
52
  supportTextLink,
50
- onHidePermanently
53
+ onHidePermanently,
54
+ hidePermanentlyLabel
51
55
  } = params;
52
56
  return `
53
57
  <div class="${CLASS_NAMES.FULL_WIDTH.CONTAINER}">
@@ -61,18 +65,25 @@ export class FullWidthNotification {
61
65
  </div>
62
66
  <div class="${CLASS_NAMES.FULL_WIDTH.ACTIONS_CONTAINER}">
63
67
  ${actions && actions.length > 0 ? renderActions(actions, CLASS_NAMES.FULL_WIDTH.ACTIONS) : ''}
64
- ${this.renderHidePermanentlyButton(onHidePermanently)}
68
+ ${this.renderHidePermanentlyButton(onHidePermanently, hidePermanentlyLabel)}
65
69
  ${this.renderCloseButton(onClose)}
66
70
  </div>
67
71
  </div>
68
72
  </div>
69
73
  `;
70
74
  }
71
- renderHidePermanentlyButton(onHidePermanently) {
75
+ /**
76
+ * 다시보지 않기 버튼.
77
+ *
78
+ * `label`은 이 함수의 반환값이 `wrapper.innerHTML`에 들어가기 전에 `sanitizeHtml`로
79
+ * 처리되므로 별도 이스케이프하지 않는다 — `renderSupportingText`와 같은 정책이다.
80
+ */
81
+ renderHidePermanentlyButton(onHidePermanently, hidePermanentlyLabel) {
72
82
  if (!onHidePermanently) return '';
83
+ const label = hidePermanentlyLabel ?? HIDE_PERMANENTLY_LABEL.fullWidth;
73
84
  return `
74
85
  <button type="button" class="ncua-notification__action-button ncua-notification__action-button--text ncua-full-width-notification__link" data-hide-permanently="true">
75
- 다시보지 않기
86
+ ${label}
76
87
  </button>
77
88
  `;
78
89
  }
@@ -1,7 +1,8 @@
1
1
  import { FeaturedIcon } from '../featuredIcon';
2
2
  import { sanitizeHtml } from '../utils/sanitize';
3
- import { CLASS_NAMES, FLOATING_ICON_MAP, MESSAGE_SIZES, SVG_ICONS } from './const';
4
- import { bindNotificationEvents, createWrapperElement, renderActions, renderSupportingText, setupAutoClose } from './utils';
3
+ import { CLASS_NAMES, FLOATING_ICON_MAP, MESSAGE_SIZES } from './const';
4
+ import { buildMessageTemplate } from './messageTemplate';
5
+ import { bindNotificationEvents, createWrapperElement, setupAutoClose } from './utils';
5
6
  export class MessageNotification {
6
7
  constructor(options) {
7
8
  this.options = {
@@ -24,7 +25,8 @@ export class MessageNotification {
24
25
  className,
25
26
  actions,
26
27
  onClose,
27
- onHidePermanently
28
+ onHidePermanently,
29
+ hidePermanentlyLabel
28
30
  } = this.options;
29
31
  // message 타입은 neutral, error, warning, success 4가지 색상만 지원
30
32
  let actualColor = color;
@@ -41,16 +43,20 @@ export class MessageNotification {
41
43
  svgString: iconSvg,
42
44
  theme: 'light-circle',
43
45
  color: actualColor,
44
- size: MESSAGE_SIZES.FEATURED_ICON
46
+ size: MESSAGE_SIZES.FEATURED_ICON,
47
+ // React 구현과 동일하게 `__icon`(flex-shrink: 0)을 부여한다.
48
+ // 누락 시 긴 타이틀에서 아이콘이 찌그러진다.
49
+ className: CLASS_NAMES.MESSAGE.ICON
45
50
  });
46
51
  featuredIconElement = this.featuredIcon.getElement();
47
52
  }
48
- wrapper.innerHTML = sanitizeHtml(this.buildTemplate({
53
+ wrapper.innerHTML = sanitizeHtml(buildMessageTemplate({
49
54
  title,
50
55
  supportingText,
51
56
  actions,
52
57
  onClose,
53
- onHidePermanently
58
+ onHidePermanently,
59
+ hidePermanentlyLabel
54
60
  }));
55
61
  // FeaturedIcon을 content-wrapper에 추가
56
62
  if (featuredIconElement) {
@@ -61,50 +67,6 @@ export class MessageNotification {
61
67
  }
62
68
  return wrapper;
63
69
  }
64
- buildTemplate(params) {
65
- const {
66
- title,
67
- supportingText,
68
- actions,
69
- onClose,
70
- onHidePermanently
71
- } = params;
72
- return `
73
- <div class="${CLASS_NAMES.MESSAGE.CONTAINER}">
74
- <div class="${CLASS_NAMES.MESSAGE.CONTENT}">
75
- <div class="${CLASS_NAMES.MESSAGE.CONTENT_WRAPPER}">
76
- <div class="${CLASS_NAMES.MESSAGE.TEXT_CONTAINER}">
77
- <span class="${CLASS_NAMES.MESSAGE.TITLE}">${title}</span>
78
- ${renderSupportingText(supportingText, CLASS_NAMES.MESSAGE.SUPPORTING_TEXT)}
79
- </div>
80
- </div>
81
- <div class="${CLASS_NAMES.MESSAGE.ACTIONS_CONTAINER}">
82
- ${actions && actions.length > 0 ? renderActions(actions, CLASS_NAMES.MESSAGE.ACTIONS) : ''}
83
- </div>
84
- <div class="${CLASS_NAMES.MESSAGE.ACTIONS_CONTAINER}">
85
- ${this.renderHidePermanentlyButton(onHidePermanently)}
86
- ${this.renderCloseButton(onClose)}
87
- </div>
88
- </div>
89
- </div>
90
- `;
91
- }
92
- renderHidePermanentlyButton(onHidePermanently) {
93
- if (!onHidePermanently) return '';
94
- return `
95
- <button type="button" class="${CLASS_NAMES.COMMON.ACTION_BUTTON} ${CLASS_NAMES.COMMON.ACTION_BUTTON}--text ${CLASS_NAMES.MESSAGE.HIDE_LINK}" data-hide-permanently="true">
96
- 다시 보지 않기
97
- </button>
98
- `;
99
- }
100
- renderCloseButton(onClose) {
101
- if (!onClose) return '';
102
- return `
103
- <button type="button" class="${CLASS_NAMES.MESSAGE.CLOSE_BUTTON}" aria-label="알림 닫기">
104
- ${SVG_ICONS['x-close'](MESSAGE_SIZES.CLOSE_BUTTON).replace('stroke="currentColor"', `stroke="#2F2F30"`)}
105
- </button>
106
- `;
107
- }
108
70
  bindEvents() {
109
71
  bindNotificationEvents(this.element, this.options.actions, this.options.onClose, () => this.remove());
110
72
  // 다시보지 않기 버튼 이벤트 바인딩
@@ -35,6 +35,9 @@ export const CLASS_NAMES = {
35
35
  SUPPORTING_TEXT: 'ncua-message-notification__supporting-text',
36
36
  ACTIONS_CONTAINER: 'ncua-message-notification__actions-container',
37
37
  ACTIONS: 'ncua-message-notification__actions',
38
+ // 다시 보지 않기 + 닫기 그룹 전용 래퍼. ACTIONS_CONTAINER를 재사용하면
39
+ // 해당 클래스의 gap(12px)이 그룹 내부에도 적용되어 8px 규격이 깨진다.
40
+ FOOTER_CONTAINER: 'ncua-message-notification__footer-container',
38
41
  HIDE_LINK: 'ncua-message-notification__hide-link',
39
42
  CLOSE_BUTTON: 'ncua-message-notification__close-button'
40
43
  },
@@ -1,4 +1,5 @@
1
- export { SVG_ICONS, FLOATING_ICON_MAP, FULL_WIDTH_ICON_MAP, ICON_MAP } from './icons';
1
+ // Re-export all constants and types from separate files
2
2
  export { CLASS_NAMES } from './classNames';
3
- export { FEATURED_ICON_SIZES, ICON_PIXEL_SIZES, CLOSE_BUTTON_SIZES, CLOSE_BUTTON_SVG_SIZES, FULL_WIDTH_SIZES, MESSAGE_SIZES, getSizes } from './sizes';
3
+ export { FLOATING_ICON_MAP, FULL_WIDTH_ICON_MAP, ICON_MAP, SVG_ICONS } from './icons';
4
+ export { CLOSE_BUTTON_SIZES, CLOSE_BUTTON_SVG_SIZES, FEATURED_ICON_SIZES, FULL_WIDTH_SIZES, getSizes, ICON_PIXEL_SIZES, MESSAGE_SIZES } from './sizes';
4
5
  export { MESSAGE_CLOSE_ICON_COLORS } from './types';
@@ -26,9 +26,11 @@ export const FULL_WIDTH_SIZES = {
26
26
  CLOSE_BUTTON: '20'
27
27
  };
28
28
  // Message 알림 고정 사이즈
29
+ // FEATURED_ICON(원 크기)과 ICON_PIXEL(내부 SVG 크기)은 항상 짝을 맞춰야 한다.
30
+ // 'md' = 40px 원 / 20px 아이콘 (FeaturedIcon iconSizeMap 기준)
29
31
  export const MESSAGE_SIZES = {
30
- FEATURED_ICON: 'lg',
31
- ICON_PIXEL: '24',
32
+ FEATURED_ICON: 'md',
33
+ ICON_PIXEL: '20',
32
34
  CLOSE_BUTTON: '20'
33
35
  };
34
36
  // 사이즈 유틸리티 함수들
@@ -0,0 +1,100 @@
1
+ import { HIDE_PERMANENTLY_LABEL } from '../../../constant/notification';
2
+ import { CLASS_NAMES, MESSAGE_SIZES, SVG_ICONS } from './const';
3
+ import { renderActions, renderSupportingText } from './utils';
4
+ /**
5
+ * message 타입 액션 버튼 사이즈. TO-BE 규격 28px이며 React `<Button size="xs">`와 같다.
6
+ * floating / full-width는 이 값을 쓰지 않고 `renderActions`의 기본값('sm')을 유지한다.
7
+ */
8
+ const ACTION_BUTTON_SIZE = 'xs';
9
+ /**
10
+ * Message Notification의 마크업을 만든다.
11
+ * React 구현(`src/components/overlays/notification/MessageNotification.tsx`)과
12
+ * 동일한 클래스 트리를 산출해야 한다 — SCSS 한 벌을 두 구현이 공유한다.
13
+ */
14
+ export function buildMessageTemplate(params) {
15
+ const {
16
+ title,
17
+ supportingText,
18
+ actions,
19
+ onClose,
20
+ onHidePermanently,
21
+ hidePermanentlyLabel
22
+ } = params;
23
+ return `
24
+ <div class="${CLASS_NAMES.MESSAGE.CONTAINER}">
25
+ <div class="${CLASS_NAMES.MESSAGE.CONTENT}">
26
+ <div class="${CLASS_NAMES.MESSAGE.CONTENT_WRAPPER}">
27
+ <div class="${CLASS_NAMES.MESSAGE.TEXT_CONTAINER}">
28
+ <span class="${CLASS_NAMES.MESSAGE.TITLE}">${title}</span>
29
+ ${renderSupportingText(supportingText, CLASS_NAMES.MESSAGE.SUPPORTING_TEXT)}
30
+ </div>
31
+ </div>
32
+ ${renderActionsContainer({
33
+ actions,
34
+ onClose,
35
+ onHidePermanently,
36
+ hidePermanentlyLabel
37
+ })}
38
+ </div>
39
+ </div>
40
+ `;
41
+ }
42
+ /**
43
+ * 액션 버튼 그룹과 닫기 그룹을 함께 감싸는 우측 영역.
44
+ * 이 컨테이너의 gap(12px)이 두 그룹 사이 간격을 만든다.
45
+ * 표시할 요소가 하나도 없으면 빈 컨테이너를 남기지 않는다.
46
+ */
47
+ function renderActionsContainer(params) {
48
+ const {
49
+ actions,
50
+ onClose,
51
+ onHidePermanently,
52
+ hidePermanentlyLabel
53
+ } = params;
54
+ const actionsHtml = renderActions(actions ?? [], CLASS_NAMES.MESSAGE.ACTIONS, ACTION_BUTTON_SIZE);
55
+ const footerHtml = renderFooterContainer({
56
+ onClose,
57
+ onHidePermanently,
58
+ hidePermanentlyLabel
59
+ });
60
+ if (!actionsHtml && !footerHtml) return '';
61
+ return `<div class="${CLASS_NAMES.MESSAGE.ACTIONS_CONTAINER}">${actionsHtml}${footerHtml}</div>`;
62
+ }
63
+ /** 다시 보지 않기 + 닫기 그룹. 전용 래퍼를 쓰는 이유는 `CLASS_NAMES.MESSAGE.FOOTER_CONTAINER` 참조. */
64
+ function renderFooterContainer(params) {
65
+ const {
66
+ onClose,
67
+ onHidePermanently,
68
+ hidePermanentlyLabel
69
+ } = params;
70
+ if (!onHidePermanently && !onClose) return '';
71
+ return `
72
+ <div class="${CLASS_NAMES.MESSAGE.FOOTER_CONTAINER}">
73
+ ${renderHidePermanentlyButton(onHidePermanently, hidePermanentlyLabel)}
74
+ ${renderCloseButton(onClose)}
75
+ </div>
76
+ `;
77
+ }
78
+ /**
79
+ * 다시 보지 않기 버튼.
80
+ *
81
+ * `label`은 이 함수의 반환값이 `wrapper.innerHTML`에 들어가기 전에 `sanitizeHtml`로
82
+ * 처리되므로 별도 이스케이프하지 않는다 — `renderSupportingText`와 같은 정책이다.
83
+ */
84
+ function renderHidePermanentlyButton(onHidePermanently, hidePermanentlyLabel) {
85
+ if (!onHidePermanently) return '';
86
+ const label = hidePermanentlyLabel ?? HIDE_PERMANENTLY_LABEL.message;
87
+ return `
88
+ <button type="button" class="${CLASS_NAMES.COMMON.ACTION_BUTTON} ${CLASS_NAMES.MESSAGE.HIDE_LINK}" data-hide-permanently="true">
89
+ ${label}
90
+ </button>
91
+ `;
92
+ }
93
+ function renderCloseButton(onClose) {
94
+ if (!onClose) return '';
95
+ return `
96
+ <button type="button" class="${CLASS_NAMES.MESSAGE.CLOSE_BUTTON}" aria-label="알림 닫기">
97
+ ${SVG_ICONS['x-close'](MESSAGE_SIZES.CLOSE_BUTTON).replace('stroke="currentColor"', 'stroke="#2F2F30"')}
98
+ </button>
99
+ `;
100
+ }
@@ -45,16 +45,51 @@ export function renderSupportingText(supportingText, className, supportTextLink)
45
45
  // unsafe URL이거나 link가 없으면 링크 없이 텍스트만 렌더링
46
46
  return `<span class="${className}">${supportingText}</span>`;
47
47
  }
48
+ /** 액션 버튼 색상을 지정하지 않았을 때의 기본값. React `MessageNotificationParts`와 같다. */
49
+ const DEFAULT_ACTION_HIERARCHY = 'text';
50
+ /**
51
+ * 액션 버튼의 색상 수식자를 현행 어휘로 정규화한다.
52
+ *
53
+ * 구 어휘(`'link'` / `'link-gray'`)는 Link 컴포넌트의 색상 이름을 빌려 쓴 것이라
54
+ * `ncua-btn--link`에 대응하는 CSS가 존재하지 않았다. 기존 CDN 사용처를 깨지 않기 위해
55
+ * 타입에서 제거하는 대신 이 지점에서 실제 Button 테마로 매핑한다.
56
+ *
57
+ * 렌더(`renderActions`)와 이벤트 바인딩(`bindNotificationEvents`)이 이 함수를 함께 써야
58
+ * `data-action` 키가 어긋나지 않는다.
59
+ */
60
+ export function resolveActionHierarchy(hierarchy) {
61
+ switch (hierarchy) {
62
+ case undefined:
63
+ return DEFAULT_ACTION_HIERARCHY;
64
+ case 'link':
65
+ return 'text';
66
+ case 'link-gray':
67
+ return 'text-gray';
68
+ default:
69
+ return hierarchy;
70
+ }
71
+ }
72
+ /** 액션 버튼의 클릭 라우팅 키. 렌더와 바인딩이 같은 규칙으로 만들어야 한다. */
73
+ function buildActionKey(action) {
74
+ return `${action.label}-${resolveActionHierarchy(action.hierarchy)}`;
75
+ }
76
+ /**
77
+ * 액션 버튼 그룹 HTML을 만든다.
78
+ *
79
+ * `size` 기본값 'sm'은 floating / full-width 타입의 기존 렌더링을 그대로 보존하기 위한 것이다.
80
+ * message 타입만 TO-BE 규격(28px)에 맞춰 'xs'를 넘긴다 — React `<Button size="xs">`와 동일.
81
+ */
48
82
  export function renderActions(actions, wrapperClass) {
83
+ let size = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'sm';
49
84
  // 액션이 없으면 빈 문자열 반환
50
85
  if (!actions || actions.length === 0) {
51
86
  return '';
52
87
  }
53
88
  const buttonsHtml = actions.map(action => {
54
89
  const buttonHtml = `
55
- <button
56
- class="ncua-btn ncua-btn--sm ncua-btn--${action.hierarchy || 'text'}"
57
- data-action="${action.label}-${action.hierarchy}"
90
+ <button
91
+ class="ncua-btn ncua-btn--${size} ncua-btn--${resolveActionHierarchy(action.hierarchy)}"
92
+ data-action="${buildActionKey(action)}"
58
93
  >
59
94
  ${action.label}
60
95
  </button>`;
@@ -80,7 +115,7 @@ export function bindNotificationEvents(element, actions, onClose, onRemove) {
80
115
  if (actionData) {
81
116
  let matchedAction = null;
82
117
  for (const action of actions) {
83
- const expectedDataAction = `${action.label}-${action.hierarchy || 'link'}`;
118
+ const expectedDataAction = buildActionKey(action);
84
119
  if (actionData === expectedDataAction) {
85
120
  matchedAction = action;
86
121
  break;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 다시보지 않기 버튼의 타입별 기본 문구.
3
+ *
4
+ * `hidePermanentlyLabel`을 지정하지 않았을 때 쓰인다.
5
+ * React(`src/components/overlays/notification/`)와 Vanilla(`assets/scripts/notification/`)
6
+ * 두 구현이 이 상수를 함께 참조한다 — 문구가 하드코딩으로 흩어져 서로 어긋나던 문제(#460)를
7
+ * 막기 위한 단일 출처다.
8
+ *
9
+ * `message`와 `fullWidth`의 띄어쓰기가 다른 것은 오타가 아니라 현행 유지다.
10
+ * 표기 통일은 별도 결정 사항이며, 결정되면 이 파일 한 곳만 고치면 된다.
11
+ */
12
+ export const HIDE_PERMANENTLY_LABEL = {
13
+ message: '다시 보지 않기',
14
+ fullWidth: '다시보지 않기'
15
+ };
@@ -32,27 +32,28 @@ const InputBase = /*#__PURE__*/forwardRef((_ref, ref) => {
32
32
  ...props
33
33
  } = _ref;
34
34
  const inputRef = useRef(null);
35
- const [textCount, setTextCount] = useState(0);
36
- const [hasValue, setHasValue] = useState(false);
37
- // 유무는 DOM에서 읽는다 — props.value 판정하면 uncontrolled Input에서 항상 빈 값으로 보인다.
38
- // biome-ignore lint/correctness/useExhaustiveDependencies: controlled 값이 프로그래밍적으로 바뀔 때는 input 이벤트가 나지 않아 props.value로 재동기화해야 한다
35
+ // controlled 인풋은 props.value 로 길이를 알 수 있으므로 상태를 두지 않는다.
36
+ // 입력마다 setState 하면 조합 중(한글 IME)에 리렌더가 끼어들어 조합이 끊긴다.
37
+ const isControlled = props.value !== undefined;
38
+ const [uncontrolledLength, setUncontrolledLength] = useState(0);
39
+ const valueLength = isControlled ? String(props.value ?? '').length : uncontrolledLength;
40
+ const hasValue = valueLength > 0;
41
+ const textCount = valueLength;
42
+ // uncontrolled 인풋만 DOM 값을 읽어 따라간다 — props.value 가 없어 길이를 알 방법이 이것뿐이다.
39
43
  useEffect(() => {
44
+ if (isControlled) return;
40
45
  const input = inputRef.current;
41
46
  if (!input) return;
42
47
  const syncFromInput = () => {
43
- const {
44
- length
45
- } = input.value;
46
- setHasValue(length > 0);
47
- setTextCount(length);
48
+ setUncontrolledLength(input.value.length);
48
49
  };
49
50
  syncFromInput();
50
51
  input.addEventListener('input', syncFromInput);
51
52
  return () => {
52
53
  input.removeEventListener('input', syncFromInput);
53
54
  };
54
- }, [props.value]);
55
- const renderOutsideSlot = slot => {
55
+ }, [isControlled]);
56
+ const renderOutsideSlot = (slot, position) => {
56
57
  if (slot.type === 'custom' && slot.placement !== 'outside') {
57
58
  return null;
58
59
  }
@@ -65,10 +66,15 @@ const InputBase = /*#__PURE__*/forwardRef((_ref, ref) => {
65
66
  children: slot.label
66
67
  });
67
68
  case 'text':
68
- return _jsx("span", {
69
- className: classNames('ncua-input__leading-text', `ncua-input__leading-text--${size}`),
70
- children: slot.text
71
- });
69
+ {
70
+ // 클래스명은 리터럴로 쓴다 — MCP 의 BEM 추출기가 `ncua-input__${position}-text` 형태의
71
+ // 템플릿 리터럴에서는 `ncua-input__` 조각만 읽어 완성된 클래스를 잡지 못한다.
72
+ const textClass = position === 'leading' ? 'ncua-input__leading-text' : 'ncua-input__trailing-text';
73
+ return _jsx("span", {
74
+ className: classNames(textClass, `${textClass}--${size}`),
75
+ children: slot.text
76
+ });
77
+ }
72
78
  case 'custom':
73
79
  return slot.children;
74
80
  default:
@@ -83,7 +89,12 @@ const InputBase = /*#__PURE__*/forwardRef((_ref, ref) => {
83
89
  return _jsx("div", {
84
90
  className: "ncua-input__icon-wrap",
85
91
  children: _jsx(SlotIcon, {
86
- className: classNames(`ncua-input__${position}-icon`, slot.className),
92
+ className: classNames(`ncua-input__${position}-icon`,
93
+ // color 를 지정하지 않았을 때만 상태별 색(Placeholder/Filled/Focused/Disabled)을 CSS 에 맡긴다.
94
+ // 지정한 경우에는 이 클래스를 붙이지 않아 지정 색이 그대로 유지된다.
95
+ {
96
+ 'ncua-input__slot-icon': !slot.color
97
+ }, slot.className),
87
98
  color: slot.color ? COLOR[slot.color] : undefined,
88
99
  width: slot.size ?? iconSvgSize[size],
89
100
  height: slot.size ?? iconSvgSize[size]
@@ -155,13 +166,14 @@ const InputBase = /*#__PURE__*/forwardRef((_ref, ref) => {
155
166
  'full-width': fullWidth,
156
167
  'ncua-input__trailing-button': trailingElement?.type === 'button',
157
168
  'ncua-input__leading-text-wrap': leadingElement?.type === 'text',
169
+ 'ncua-input__trailing-text-wrap': trailingElement?.type === 'text',
158
170
  'has-value': hasValue
159
171
  }, className),
160
172
  children: [renderLabel(), _jsxs("div", {
161
173
  className: "ncua-input__content-wrap",
162
174
  children: [_jsxs("div", {
163
175
  className: "ncua-input__content",
164
- children: [leadingElement && renderOutsideSlot(leadingElement), _jsxs("div", {
176
+ children: [leadingElement && renderOutsideSlot(leadingElement, 'leading'), _jsxs("div", {
165
177
  className: classNames('ncua-input__field', `ncua-input__field--${size}`),
166
178
  children: [leadingElement && renderInsideSlot(leadingElement, 'left'), _jsx("input", {
167
179
  ref: node => {
@@ -177,7 +189,7 @@ const InputBase = /*#__PURE__*/forwardRef((_ref, ref) => {
177
189
  maxLength: maxLength,
178
190
  ...props
179
191
  }), renderClearButton(), renderStatusIcon(), trailingElement && renderInsideSlot(trailingElement, 'right')]
180
- }), trailingElement && renderOutsideSlot(trailingElement)]
192
+ }), trailingElement && renderOutsideSlot(trailingElement, 'trailing')]
181
193
  }), showTextCount && maxLength && _jsxs("div", {
182
194
  className: "ncua-input__field-text-count",
183
195
  children: [_jsx("output", {
@@ -4,6 +4,7 @@ import { createElement } from 'react';
4
4
  import { createRoot } from 'react-dom/client';
5
5
  import { act } from 'react-dom/test-utils';
6
6
  import { describe, expect, it, vi } from 'vitest';
7
+ import { COLOR } from '../../../../../constant/color';
7
8
  import { InputBase } from '../InputBase';
8
9
  // React 18에서 act() 사용 시 필요한 플래그 (미설정 시 console.error 경고 발생)
9
10
  globalThis.IS_REACT_ACT_ENVIRONMENT = true;
@@ -130,6 +131,55 @@ describe('InputBase — 아이콘 사이즈', () => {
130
131
  view.unmount();
131
132
  });
132
133
  });
134
+ describe('InputBase — 슬롯 아이콘 상태 색상', () => {
135
+ // 상태별 색은 CSS 가 결정한다. jsdom 에서는 스타일시트를 로드하지 않으므로
136
+ // "상태 규칙을 타는 클래스가 붙었는지" 와 "지정 색이 인라인으로 남았는지" 로 검증한다.
137
+ const leftIconOf = container => container.querySelector('.ncua-input__left-icon');
138
+ it('color 를 지정하지 않으면 상태 색상 클래스가 붙는다', () => {
139
+ // Given/When: color 없이 슬롯 아이콘을 렌더하면
140
+ const view = mountInputBase({
141
+ leadingElement: {
142
+ type: 'icon',
143
+ icon: SearchLg
144
+ }
145
+ });
146
+ // Then: 상태 규칙을 타는 클래스가 붙고, 인라인 색은 지정되지 않는다
147
+ const icon = leftIconOf(view.container);
148
+ expect(icon?.classList.contains('ncua-input__slot-icon')).toBe(true);
149
+ expect(icon?.hasAttribute('color')).toBe(false);
150
+ view.unmount();
151
+ });
152
+ it('color 를 지정하면 상태 색상 클래스가 붙지 않고 지정 색이 유지된다', () => {
153
+ // Given/When: color 를 지정해 렌더하면
154
+ const view = mountInputBase({
155
+ leadingElement: {
156
+ type: 'icon',
157
+ icon: SearchLg,
158
+ color: 'blue500'
159
+ }
160
+ });
161
+ // Then: 상태 규칙에서 제외되고 지정한 색이 그대로 남는다
162
+ const icon = leftIconOf(view.container);
163
+ expect(icon?.classList.contains('ncua-input__slot-icon')).toBe(false);
164
+ expect(icon?.getAttribute('color')).toBe(COLOR.blue500);
165
+ view.unmount();
166
+ });
167
+ it('slot.className 을 함께 주어도 상태 색상 클래스가 유지된다', () => {
168
+ // Given/When: className 을 추가로 넘기면
169
+ const view = mountInputBase({
170
+ leadingElement: {
171
+ type: 'icon',
172
+ icon: SearchLg,
173
+ className: 'my-icon'
174
+ }
175
+ });
176
+ // Then: 두 클래스가 모두 붙는다
177
+ const icon = leftIconOf(view.container);
178
+ expect(icon?.classList.contains('ncua-input__slot-icon')).toBe(true);
179
+ expect(icon?.classList.contains('my-icon')).toBe(true);
180
+ view.unmount();
181
+ });
182
+ });
133
183
  describe('InputBase — has-value 상태 클래스', () => {
134
184
  const typeInto = (container, text) => {
135
185
  const input = container.querySelector('input');
@@ -178,4 +228,70 @@ describe('InputBase — has-value 상태 클래스', () => {
178
228
  expect(view.container.querySelector('.ncua-input')?.classList.contains('has-value')).toBe(true);
179
229
  view.unmount();
180
230
  });
231
+ });
232
+ describe('InputBase — 텍스트 슬롯', () => {
233
+ it('leadingElement 텍스트는 leading 클래스와 wrap 클래스가 붙는다', () => {
234
+ const {
235
+ container,
236
+ unmount
237
+ } = mountInputBase({
238
+ leadingElement: {
239
+ type: 'text',
240
+ text: 'https://'
241
+ }
242
+ });
243
+ const text = container.querySelector('.ncua-input__leading-text');
244
+ expect(text?.textContent).toBe('https://');
245
+ expect(container.querySelector('.ncua-input__leading-text-wrap')).not.toBeNull();
246
+ unmount();
247
+ });
248
+ it('trailingElement 텍스트는 trailing 클래스와 wrap 클래스가 붙는다', () => {
249
+ const {
250
+ container,
251
+ unmount
252
+ } = mountInputBase({
253
+ trailingElement: {
254
+ type: 'text',
255
+ text: 'px'
256
+ }
257
+ });
258
+ const text = container.querySelector('.ncua-input__trailing-text');
259
+ expect(text?.textContent).toBe('px');
260
+ expect(container.querySelector('.ncua-input__trailing-text-wrap')).not.toBeNull();
261
+ // leading 클래스가 섞이면 모서리·테두리 방향이 반대가 된다
262
+ expect(container.querySelector('.ncua-input__leading-text')).toBeNull();
263
+ unmount();
264
+ });
265
+ it('trailingElement 텍스트는 입력 필드 뒤에 온다', () => {
266
+ const {
267
+ container,
268
+ unmount
269
+ } = mountInputBase({
270
+ trailingElement: {
271
+ type: 'text',
272
+ text: 'px'
273
+ }
274
+ });
275
+ const content = container.querySelector('.ncua-input__content');
276
+ const children = Array.from(content?.children ?? []);
277
+ const fieldIndex = children.findIndex(el => el.classList.contains('ncua-input__field'));
278
+ const textIndex = children.findIndex(el => el.classList.contains('ncua-input__trailing-text'));
279
+ expect(fieldIndex).toBeGreaterThanOrEqual(0);
280
+ expect(textIndex).toBeGreaterThan(fieldIndex);
281
+ unmount();
282
+ });
283
+ it('사이즈 modifier 가 함께 붙는다', () => {
284
+ const {
285
+ container,
286
+ unmount
287
+ } = mountInputBase({
288
+ size: 'sm',
289
+ trailingElement: {
290
+ type: 'text',
291
+ text: 'px'
292
+ }
293
+ });
294
+ expect(container.querySelector('.ncua-input__trailing-text--sm')).not.toBeNull();
295
+ unmount();
296
+ });
181
297
  });
@@ -26,9 +26,9 @@ export const PasswordInput = /*#__PURE__*/forwardRef((_ref, ref) => {
26
26
  type: isVisible ? 'text' : 'password',
27
27
  leadingElement: {
28
28
  type: 'icon',
29
- icon: Lock01,
30
- // 색은 CSS가 결정한다 여기서 props.value로 판정하면 uncontrolled Input에서 영원히 빈 값 취급된다
31
- className: 'ncua-input__password-lock-icon'
29
+ icon: Lock01
30
+ // color 넘기지 않아 슬롯 아이콘 공통 규칙(상태별 색)을 그대로 따른다.
31
+ // 여기서 props.value 로 판정하면 uncontrolled Input 에서 영원히 빈 값 취급된다.
32
32
  },
33
33
  trailingElement: {
34
34
  type: 'custom',