@ncds/ui-admin 1.8.21-alpha.4 → 1.8.21-alpha.6

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 (75) 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/overlays/notification/FullWidthNotification.js +3 -1
  10. package/dist/cjs/src/components/overlays/notification/MessageNotification.js +14 -54
  11. package/dist/cjs/src/components/overlays/notification/MessageNotificationParts.js +92 -0
  12. package/dist/cjs/src/components/overlays/notification/__tests__/MessageNotification.test.js +246 -0
  13. package/dist/cjs/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.js +209 -0
  14. package/dist/cjs/src/generated/scoped-css.js +1 -1
  15. package/dist/esm/assets/scripts/notification/FullWidthNotification.js +17 -6
  16. package/dist/esm/assets/scripts/notification/MessageNotification.js +12 -50
  17. package/dist/esm/assets/scripts/notification/const/classNames.js +3 -0
  18. package/dist/esm/assets/scripts/notification/const/index.js +3 -2
  19. package/dist/esm/assets/scripts/notification/const/sizes.js +4 -2
  20. package/dist/esm/assets/scripts/notification/messageTemplate.js +100 -0
  21. package/dist/esm/assets/scripts/notification/utils.js +39 -4
  22. package/dist/esm/constant/notification.js +15 -0
  23. package/dist/esm/src/components/overlays/notification/FullWidthNotification.js +3 -1
  24. package/dist/esm/src/components/overlays/notification/MessageNotification.js +15 -55
  25. package/dist/esm/src/components/overlays/notification/MessageNotificationParts.js +85 -0
  26. package/dist/esm/src/components/overlays/notification/__tests__/MessageNotification.test.js +243 -0
  27. package/dist/esm/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.js +206 -0
  28. package/dist/esm/src/generated/scoped-css.js +1 -1
  29. package/dist/temp/assets/scripts/notification/FullWidthNotification.d.ts +6 -0
  30. package/dist/temp/assets/scripts/notification/FullWidthNotification.js +14 -5
  31. package/dist/temp/assets/scripts/notification/MessageNotification.d.ts +0 -3
  32. package/dist/temp/assets/scripts/notification/MessageNotification.js +9 -44
  33. package/dist/temp/assets/scripts/notification/const/classNames.d.ts +1 -0
  34. package/dist/temp/assets/scripts/notification/const/classNames.js +3 -0
  35. package/dist/temp/assets/scripts/notification/const/index.d.ts +3 -3
  36. package/dist/temp/assets/scripts/notification/const/index.js +3 -2
  37. package/dist/temp/assets/scripts/notification/const/sizes.d.ts +2 -2
  38. package/dist/temp/assets/scripts/notification/const/sizes.js +4 -2
  39. package/dist/temp/assets/scripts/notification/const/types.d.ts +30 -2
  40. package/dist/temp/assets/scripts/notification/messageTemplate.d.ts +15 -0
  41. package/dist/temp/assets/scripts/notification/messageTemplate.js +79 -0
  42. package/dist/temp/assets/scripts/notification/utils.d.ts +19 -2
  43. package/dist/temp/assets/scripts/notification/utils.js +39 -5
  44. package/dist/temp/constant/notification.d.ts +15 -0
  45. package/dist/temp/constant/notification.js +15 -0
  46. package/dist/temp/src/components/overlays/notification/FullWidthNotification.d.ts +6 -0
  47. package/dist/temp/src/components/overlays/notification/FullWidthNotification.js +3 -2
  48. package/dist/temp/src/components/overlays/notification/MessageNotification.d.ts +6 -0
  49. package/dist/temp/src/components/overlays/notification/MessageNotification.js +4 -13
  50. package/dist/temp/src/components/overlays/notification/MessageNotificationParts.d.ts +28 -0
  51. package/dist/temp/src/components/overlays/notification/MessageNotificationParts.js +28 -0
  52. package/dist/temp/src/components/overlays/notification/Notification.d.ts +11 -2
  53. package/dist/temp/src/components/overlays/notification/__tests__/MessageNotification.test.d.ts +1 -0
  54. package/dist/temp/src/components/overlays/notification/__tests__/MessageNotification.test.js +190 -0
  55. package/dist/temp/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.d.ts +1 -0
  56. package/dist/temp/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.js +160 -0
  57. package/dist/temp/src/generated/scoped-css.js +1 -1
  58. package/dist/types/assets/scripts/notification/FullWidthNotification.d.ts +6 -0
  59. package/dist/types/assets/scripts/notification/MessageNotification.d.ts +0 -3
  60. package/dist/types/assets/scripts/notification/const/classNames.d.ts +1 -0
  61. package/dist/types/assets/scripts/notification/const/index.d.ts +3 -3
  62. package/dist/types/assets/scripts/notification/const/sizes.d.ts +2 -2
  63. package/dist/types/assets/scripts/notification/const/types.d.ts +30 -2
  64. package/dist/types/assets/scripts/notification/messageTemplate.d.ts +15 -0
  65. package/dist/types/assets/scripts/notification/utils.d.ts +19 -2
  66. package/dist/types/constant/notification.d.ts +15 -0
  67. package/dist/types/src/components/overlays/notification/FullWidthNotification.d.ts +6 -0
  68. package/dist/types/src/components/overlays/notification/MessageNotification.d.ts +6 -0
  69. package/dist/types/src/components/overlays/notification/MessageNotificationParts.d.ts +28 -0
  70. package/dist/types/src/components/overlays/notification/Notification.d.ts +11 -2
  71. package/dist/types/src/components/overlays/notification/__tests__/MessageNotification.test.d.ts +1 -0
  72. package/dist/types/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.d.ts +1 -0
  73. package/dist/ui-admin/assets/styles/style.css +21 -33
  74. package/dist/ui-admin/assets/styles/style.scoped.css +21 -33
  75. 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
+ };
@@ -3,6 +3,7 @@ import { AlertTriangle, CheckCircle, InfoCircle, MessageChatSquare, XClose } fro
3
3
  import classNames from 'classnames';
4
4
  import { forwardRef, useEffect, useRef, useState } from 'react';
5
5
  import { COLOR } from '../../../../constant/color';
6
+ import { HIDE_PERMANENTLY_LABEL } from '../../../../constant/notification';
6
7
  const iconMap = {
7
8
  neutral: MessageChatSquare,
8
9
  error: AlertTriangle,
@@ -28,6 +29,7 @@ const FullWidthNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
28
29
  autoClose = 0,
29
30
  supportTextLink,
30
31
  onHidePermanently,
32
+ hidePermanentlyLabel = HIDE_PERMANENTLY_LABEL.fullWidth,
31
33
  ...rest
32
34
  } = _ref;
33
35
  const [shouldRemove, setShouldRemove] = useState(false);
@@ -109,7 +111,7 @@ const FullWidthNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
109
111
  type: "button",
110
112
  className: classNames('ncua-notification__action-button', 'ncua-notification__action-button--text', 'ncua-full-width-notification__link'),
111
113
  onClick: onHidePermanently,
112
- children: "\uB2E4\uC2DC\uBCF4\uC9C0 \uC54A\uAE30"
114
+ children: hidePermanentlyLabel
113
115
  }), onClose && _jsx("button", {
114
116
  type: "button",
115
117
  className: "ncua-full-width-notification__close-button",
@@ -1,10 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { AlertCircle, AlertTriangle, CheckCircle, Pin02, XClose } from '@ncds/ui-admin-icon';
2
+ import { AlertCircle, AlertTriangle, CheckCircle, Pin02 } from '@ncds/ui-admin-icon';
3
3
  import classNames from 'classnames';
4
4
  import { forwardRef } from 'react';
5
5
  import { COLOR } from '../../../../constant/color';
6
- import { Button } from '../../action/button';
7
- import { FeaturedIcon } from '../../image-and-icons/featured-icon/FeaturedIcon';
6
+ import { MessageNotificationActions, MessageNotificationContent } from './MessageNotificationParts';
8
7
  const iconMap = {
9
8
  neutral: Pin02,
10
9
  error: AlertTriangle,
@@ -27,18 +26,11 @@ const MessageNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
27
26
  className,
28
27
  actions,
29
28
  onHidePermanently,
29
+ hidePermanentlyLabel,
30
30
  ...rest
31
31
  } = _ref;
32
32
  // message 타입은 neutral, error, warning, success 4가지 색상만 지원
33
33
  const validColor = color === 'info' ? 'neutral' : color;
34
- const iconColor = validColor;
35
- const featuredIconProps = {
36
- icon: Icon || iconMap[validColor] || Pin02,
37
- size: 'lg',
38
- color: iconColor,
39
- theme: 'light-circle'
40
- };
41
- const closeIconColor = COLOR[iconColorMap[validColor] || 'gray700'];
42
34
  return _jsx("div", {
43
35
  ref: ref,
44
36
  className: classNames('ncua-message-notification', `ncua-message-notification--${validColor}`, className),
@@ -48,50 +40,18 @@ const MessageNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
48
40
  className: "ncua-message-notification__container",
49
41
  children: _jsxs("div", {
50
42
  className: "ncua-message-notification__content",
51
- children: [_jsxs("div", {
52
- className: "ncua-message-notification__content-wrapper",
53
- children: [iconMap[validColor] && _jsx(FeaturedIcon, {
54
- ...featuredIconProps,
55
- className: "ncua-message-notification__icon"
56
- }), _jsxs("div", {
57
- className: "ncua-message-notification__text-container",
58
- children: [_jsx("span", {
59
- className: "ncua-message-notification__title",
60
- children: title
61
- }), supportingText && _jsx("span", {
62
- className: "ncua-message-notification__supporting-text",
63
- children: supportingText
64
- })]
65
- })]
66
- }), _jsx("div", {
67
- className: "ncua-message-notification__actions-container",
68
- children: actions && _jsx("div", {
69
- className: "ncua-message-notification__actions",
70
- children: actions.map(action => _jsx(Button, {
71
- size: "xs",
72
- hierarchy: action.hierarchy || 'text',
73
- label: action.label,
74
- onClick: action?.onClick
75
- }, `${action.label}-${action.hierarchy}`))
76
- })
77
- }), _jsxs("div", {
78
- className: "ncua-message-notification__footer-container",
79
- children: [onHidePermanently && _jsx("button", {
80
- type: "button",
81
- className: classNames('ncua-notification__action-button', 'ncua-notification__action-button--link', 'ncua-message-notification__hide-link'),
82
- onClick: onHidePermanently,
83
- children: "\uB2E4\uC2DC \uBCF4\uC9C0 \uC54A\uAE30"
84
- }), onClose && _jsx("button", {
85
- type: "button",
86
- className: "ncua-message-notification__close-button",
87
- onClick: onClose,
88
- "aria-label": "\uC54C\uB9BC \uB2EB\uAE30",
89
- children: _jsx(XClose, {
90
- width: 20,
91
- height: 20,
92
- color: closeIconColor
93
- })
94
- })]
43
+ children: [_jsx(MessageNotificationContent, {
44
+ title: title,
45
+ supportingText: supportingText,
46
+ icon: Icon || iconMap[validColor],
47
+ iconColor: validColor,
48
+ showIcon: Boolean(iconMap[validColor])
49
+ }), _jsx(MessageNotificationActions, {
50
+ actions: actions,
51
+ onClose: onClose,
52
+ onHidePermanently: onHidePermanently,
53
+ hidePermanentlyLabel: hidePermanentlyLabel,
54
+ closeIconColor: COLOR[iconColorMap[validColor] || 'gray700']
95
55
  })]
96
56
  })
97
57
  })
@@ -0,0 +1,85 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Pin02, XClose } from '@ncds/ui-admin-icon';
3
+ import { HIDE_PERMANENTLY_LABEL } from '../../../../constant/notification';
4
+ import { Button } from '../../action/button';
5
+ import { FeaturedIcon } from '../../image-and-icons/featured-icon/FeaturedIcon';
6
+ /** 아이콘 + 제목/서포팅 텍스트 영역. */
7
+ const MessageNotificationContent = _ref => {
8
+ let {
9
+ title,
10
+ supportingText,
11
+ icon,
12
+ iconColor,
13
+ showIcon
14
+ } = _ref;
15
+ const featuredIconProps = {
16
+ icon: icon || Pin02,
17
+ size: 'md',
18
+ color: iconColor,
19
+ theme: 'light-circle'
20
+ };
21
+ return _jsxs("div", {
22
+ className: "ncua-message-notification__content-wrapper",
23
+ children: [showIcon && _jsx(FeaturedIcon, {
24
+ ...featuredIconProps,
25
+ className: "ncua-message-notification__icon"
26
+ }), _jsxs("div", {
27
+ className: "ncua-message-notification__text-container",
28
+ children: [_jsx("span", {
29
+ className: "ncua-message-notification__title",
30
+ children: title
31
+ }), supportingText && _jsx("span", {
32
+ className: "ncua-message-notification__supporting-text",
33
+ children: supportingText
34
+ })]
35
+ })]
36
+ });
37
+ };
38
+ /**
39
+ * 액션 버튼 그룹 + 닫기 그룹을 감싸는 우측 영역.
40
+ * 이 컨테이너의 gap(12px)이 두 그룹 사이 간격을 만든다.
41
+ * 표시할 요소가 하나도 없으면 빈 컨테이너를 남기지 않는다.
42
+ */
43
+ const MessageNotificationActions = _ref2 => {
44
+ let {
45
+ actions,
46
+ onClose,
47
+ onHidePermanently,
48
+ hidePermanentlyLabel = HIDE_PERMANENTLY_LABEL.message,
49
+ closeIconColor
50
+ } = _ref2;
51
+ const hasActions = Boolean(actions?.length);
52
+ const hasFooter = Boolean(onHidePermanently || onClose);
53
+ if (!hasActions && !hasFooter) return null;
54
+ return _jsxs("div", {
55
+ className: "ncua-message-notification__actions-container",
56
+ children: [hasActions && _jsx("div", {
57
+ className: "ncua-message-notification__actions",
58
+ children: actions?.map(action => _jsx(Button, {
59
+ size: "xs",
60
+ hierarchy: action.hierarchy || 'text',
61
+ label: action.label,
62
+ onClick: action?.onClick
63
+ }, `${action.label}-${action.hierarchy}`))
64
+ }), hasFooter && _jsxs("div", {
65
+ className: "ncua-message-notification__footer-container",
66
+ children: [onHidePermanently && _jsx("button", {
67
+ type: "button",
68
+ className: "ncua-notification__action-button ncua-message-notification__hide-link",
69
+ onClick: onHidePermanently,
70
+ children: hidePermanentlyLabel
71
+ }), onClose && _jsx("button", {
72
+ type: "button",
73
+ className: "ncua-message-notification__close-button",
74
+ onClick: onClose,
75
+ "aria-label": "\uC54C\uB9BC \uB2EB\uAE30",
76
+ children: _jsx(XClose, {
77
+ width: 20,
78
+ height: 20,
79
+ color: closeIconColor
80
+ })
81
+ })]
82
+ })]
83
+ });
84
+ };
85
+ export { MessageNotificationActions, MessageNotificationContent };