@ncds/ui-admin 1.8.26-alpha.4 → 1.8.26-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 (95) hide show
  1. package/dist/cjs/assets/scripts/notification/FloatingNotification.js +23 -7
  2. package/dist/cjs/assets/scripts/notification/FullWidthNotification.js +14 -3
  3. package/dist/cjs/assets/scripts/notification/MessageNotification.js +9 -9
  4. package/dist/cjs/assets/scripts/notification/Notification.js +8 -2
  5. package/dist/cjs/assets/scripts/notification/const/icons.js +17 -8
  6. package/dist/cjs/assets/scripts/notification/const/index.js +6 -0
  7. package/dist/cjs/assets/scripts/notification/messageTemplate.js +21 -5
  8. package/dist/cjs/constant/notification.js +8 -3
  9. package/dist/cjs/src/components/overlays/notification/FloatingNotification.js +11 -29
  10. package/dist/cjs/src/components/overlays/notification/FullWidthNotification.js +9 -24
  11. package/dist/cjs/src/components/overlays/notification/MessageNotification.js +25 -9
  12. package/dist/cjs/src/components/overlays/notification/MessageNotificationParts.js +5 -2
  13. package/dist/cjs/src/components/overlays/notification/Notification.js +1 -0
  14. package/dist/cjs/src/components/overlays/notification/__tests__/CalloutNotification.test.js +8 -2
  15. package/dist/cjs/src/components/overlays/notification/__tests__/MessageNotification.test.js +55 -13
  16. package/dist/cjs/src/components/overlays/notification/__tests__/Notification.test.js +176 -0
  17. package/dist/cjs/src/components/overlays/notification/useAutoClose.js +39 -0
  18. package/dist/cjs/src/generated/scoped-css.js +1 -1
  19. package/dist/cjs/src/utils/notification/__tests__/resolveAutoClose.test.js +44 -0
  20. package/dist/cjs/src/utils/notification/index.js +12 -0
  21. package/dist/cjs/src/utils/notification/resolveAutoClose.js +22 -0
  22. package/dist/esm/assets/scripts/notification/FloatingNotification.js +23 -7
  23. package/dist/esm/assets/scripts/notification/FullWidthNotification.js +14 -3
  24. package/dist/esm/assets/scripts/notification/MessageNotification.js +10 -10
  25. package/dist/esm/assets/scripts/notification/Notification.js +8 -2
  26. package/dist/esm/assets/scripts/notification/const/icons.js +16 -7
  27. package/dist/esm/assets/scripts/notification/const/index.js +1 -1
  28. package/dist/esm/assets/scripts/notification/messageTemplate.js +21 -5
  29. package/dist/esm/constant/notification.js +7 -2
  30. package/dist/esm/src/components/overlays/notification/FloatingNotification.js +12 -30
  31. package/dist/esm/src/components/overlays/notification/FullWidthNotification.js +10 -25
  32. package/dist/esm/src/components/overlays/notification/MessageNotification.js +25 -9
  33. package/dist/esm/src/components/overlays/notification/MessageNotificationParts.js +5 -2
  34. package/dist/esm/src/components/overlays/notification/Notification.js +1 -0
  35. package/dist/esm/src/components/overlays/notification/__tests__/CalloutNotification.test.js +9 -3
  36. package/dist/esm/src/components/overlays/notification/__tests__/MessageNotification.test.js +55 -13
  37. package/dist/esm/src/components/overlays/notification/__tests__/Notification.test.js +177 -1
  38. package/dist/esm/src/components/overlays/notification/useAutoClose.js +32 -0
  39. package/dist/esm/src/generated/scoped-css.js +1 -1
  40. package/dist/esm/src/utils/notification/__tests__/resolveAutoClose.test.js +42 -0
  41. package/dist/esm/src/utils/notification/index.js +1 -0
  42. package/dist/esm/src/utils/notification/resolveAutoClose.js +15 -0
  43. package/dist/temp/assets/scripts/notification/FloatingNotification.js +10 -6
  44. package/dist/temp/assets/scripts/notification/FullWidthNotification.js +8 -5
  45. package/dist/temp/assets/scripts/notification/MessageNotification.d.ts +1 -1
  46. package/dist/temp/assets/scripts/notification/MessageNotification.js +10 -12
  47. package/dist/temp/assets/scripts/notification/Notification.js +7 -1
  48. package/dist/temp/assets/scripts/notification/const/icons.d.ts +6 -6
  49. package/dist/temp/assets/scripts/notification/const/icons.js +16 -7
  50. package/dist/temp/assets/scripts/notification/const/index.d.ts +1 -1
  51. package/dist/temp/assets/scripts/notification/const/index.js +1 -1
  52. package/dist/temp/assets/scripts/notification/const/types.d.ts +8 -1
  53. package/dist/temp/assets/scripts/notification/messageTemplate.d.ts +1 -0
  54. package/dist/temp/assets/scripts/notification/messageTemplate.js +19 -9
  55. package/dist/temp/constant/notification.d.ts +6 -1
  56. package/dist/temp/constant/notification.js +6 -1
  57. package/dist/temp/src/components/overlays/notification/FloatingNotification.d.ts +8 -0
  58. package/dist/temp/src/components/overlays/notification/FloatingNotification.js +7 -30
  59. package/dist/temp/src/components/overlays/notification/FullWidthNotification.d.ts +7 -0
  60. package/dist/temp/src/components/overlays/notification/FullWidthNotification.js +6 -25
  61. package/dist/temp/src/components/overlays/notification/MessageNotification.d.ts +13 -1
  62. package/dist/temp/src/components/overlays/notification/MessageNotification.js +16 -9
  63. package/dist/temp/src/components/overlays/notification/MessageNotificationParts.d.ts +2 -1
  64. package/dist/temp/src/components/overlays/notification/MessageNotificationParts.js +5 -3
  65. package/dist/temp/src/components/overlays/notification/Notification.d.ts +16 -3
  66. package/dist/temp/src/components/overlays/notification/Notification.js +1 -1
  67. package/dist/temp/src/components/overlays/notification/__tests__/CalloutNotification.test.js +8 -1
  68. package/dist/temp/src/components/overlays/notification/__tests__/MessageNotification.test.js +44 -9
  69. package/dist/temp/src/components/overlays/notification/__tests__/Notification.test.js +128 -1
  70. package/dist/temp/src/components/overlays/notification/useAutoClose.d.ts +15 -0
  71. package/dist/temp/src/components/overlays/notification/useAutoClose.js +25 -0
  72. package/dist/temp/src/generated/scoped-css.js +1 -1
  73. package/dist/temp/src/utils/notification/__tests__/resolveAutoClose.test.d.ts +1 -0
  74. package/dist/temp/src/utils/notification/__tests__/resolveAutoClose.test.js +22 -0
  75. package/dist/temp/src/utils/notification/index.d.ts +1 -0
  76. package/dist/temp/src/utils/notification/index.js +1 -0
  77. package/dist/temp/src/utils/notification/resolveAutoClose.d.ts +14 -0
  78. package/dist/temp/src/utils/notification/resolveAutoClose.js +12 -0
  79. package/dist/types/assets/scripts/notification/MessageNotification.d.ts +1 -1
  80. package/dist/types/assets/scripts/notification/const/icons.d.ts +6 -6
  81. package/dist/types/assets/scripts/notification/const/index.d.ts +1 -1
  82. package/dist/types/assets/scripts/notification/const/types.d.ts +8 -1
  83. package/dist/types/assets/scripts/notification/messageTemplate.d.ts +1 -0
  84. package/dist/types/constant/notification.d.ts +6 -1
  85. package/dist/types/src/components/overlays/notification/FloatingNotification.d.ts +8 -0
  86. package/dist/types/src/components/overlays/notification/FullWidthNotification.d.ts +7 -0
  87. package/dist/types/src/components/overlays/notification/MessageNotification.d.ts +13 -1
  88. package/dist/types/src/components/overlays/notification/MessageNotificationParts.d.ts +2 -1
  89. package/dist/types/src/components/overlays/notification/Notification.d.ts +16 -3
  90. package/dist/types/src/components/overlays/notification/useAutoClose.d.ts +15 -0
  91. package/dist/types/src/utils/notification/__tests__/resolveAutoClose.test.d.ts +1 -0
  92. package/dist/types/src/utils/notification/index.d.ts +1 -0
  93. package/dist/types/src/utils/notification/resolveAutoClose.d.ts +14 -0
  94. package/dist/ui-admin/assets/styles/style.css +17 -11
  95. package/package.json +1 -1
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ var _vitest = require("vitest");
4
+ var _notification = require("../../../../constant/notification");
5
+ var _resolveAutoClose = require("../resolveAutoClose");
6
+ const EXPLICIT_MS = 5000;
7
+ const FALLBACK_MS = 4000;
8
+ const NO_AUTO_CLOSE = 0;
9
+ (0, _vitest.describe)('resolveAutoClose', () => {
10
+ (0, _vitest.it)('autoClose 를 명시하면 hideCloseButton·fallback 과 무관하게 그대로 쓴다 (0 포함)', () => {
11
+ (0, _vitest.expect)((0, _resolveAutoClose.resolveAutoClose)({
12
+ autoClose: EXPLICIT_MS,
13
+ hideCloseButton: true,
14
+ fallback: FALLBACK_MS
15
+ })).toBe(EXPLICIT_MS);
16
+ (0, _vitest.expect)((0, _resolveAutoClose.resolveAutoClose)({
17
+ autoClose: NO_AUTO_CLOSE,
18
+ hideCloseButton: true,
19
+ fallback: FALLBACK_MS
20
+ })).toBe(NO_AUTO_CLOSE);
21
+ });
22
+ (0, _vitest.it)('autoClose 미지정이면 fallback 이 양수일 때 fallback 을 쓴다', () => {
23
+ (0, _vitest.expect)((0, _resolveAutoClose.resolveAutoClose)({
24
+ fallback: FALLBACK_MS
25
+ })).toBe(FALLBACK_MS);
26
+ (0, _vitest.expect)((0, _resolveAutoClose.resolveAutoClose)({
27
+ hideCloseButton: true,
28
+ fallback: FALLBACK_MS
29
+ })).toBe(FALLBACK_MS);
30
+ });
31
+ (0, _vitest.it)('autoClose·fallback 모두 없으면 hideCloseButton 일 때만 기본 3초를 준다', () => {
32
+ (0, _vitest.expect)((0, _resolveAutoClose.resolveAutoClose)({
33
+ hideCloseButton: true
34
+ })).toBe(_notification.HIDE_CLOSE_BUTTON_AUTO_CLOSE_MS);
35
+ (0, _vitest.expect)((0, _resolveAutoClose.resolveAutoClose)({
36
+ hideCloseButton: true,
37
+ fallback: NO_AUTO_CLOSE
38
+ })).toBe(_notification.HIDE_CLOSE_BUTTON_AUTO_CLOSE_MS);
39
+ (0, _vitest.expect)((0, _resolveAutoClose.resolveAutoClose)({
40
+ hideCloseButton: false
41
+ })).toBe(NO_AUTO_CLOSE);
42
+ (0, _vitest.expect)((0, _resolveAutoClose.resolveAutoClose)({})).toBe(NO_AUTO_CLOSE);
43
+ });
44
+ });
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "resolveAutoClose", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _resolveAutoClose.resolveAutoClose;
10
+ }
11
+ });
12
+ var _resolveAutoClose = require("./resolveAutoClose");
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.resolveAutoClose = void 0;
7
+ var _notification = require("../../../constant/notification");
8
+ /**
9
+ * 실제 적용할 autoClose(ms)를 정한다. React·Vanilla 두 구현이 공유한다.
10
+ * 우선순위: 명시 `autoClose` > `fallback`(양수) > `hideCloseButton`이면 3초 > 0.
11
+ */
12
+ const resolveAutoClose = _ref => {
13
+ let {
14
+ autoClose,
15
+ hideCloseButton = false,
16
+ fallback = 0
17
+ } = _ref;
18
+ if (autoClose !== undefined) return autoClose;
19
+ if (fallback > 0) return fallback;
20
+ return hideCloseButton ? _notification.HIDE_CLOSE_BUTTON_AUTO_CLOSE_MS : 0;
21
+ };
22
+ exports.resolveAutoClose = resolveAutoClose;
@@ -1,4 +1,5 @@
1
1
  import { MEDIA_QUERY } from '../../../src/constant/breakpoint';
2
+ import { resolveAutoClose } from '../../../src/utils/notification';
2
3
  import { FeaturedIcon } from '../featuredIcon';
3
4
  import { ButtonCloseX } from '../shared/ButtonCloseX';
4
5
  import { sanitizeHtml } from '../utils/sanitize';
@@ -10,9 +11,13 @@ export class FloatingNotification {
10
11
  color: 'neutral',
11
12
  className: '',
12
13
  actions: [],
13
- autoClose: 0,
14
+ hideCloseButton: false,
14
15
  supportingText: undefined,
15
- ...options
16
+ ...options,
17
+ autoClose: resolveAutoClose({
18
+ autoClose: options.autoClose,
19
+ hideCloseButton: options.hideCloseButton
20
+ })
16
21
  };
17
22
  this.element = this.createElement();
18
23
  this.bindEvents();
@@ -26,7 +31,8 @@ export class FloatingNotification {
26
31
  color,
27
32
  className,
28
33
  actions,
29
- onClose
34
+ onClose,
35
+ hideCloseButton
30
36
  } = this.options;
31
37
  // 플로팅 알림에서 info 색상 사용 시 neutral로 대체
32
38
  let actualColor = color;
@@ -55,6 +61,7 @@ export class FloatingNotification {
55
61
  supportingText,
56
62
  actions,
57
63
  onClose,
64
+ hideCloseButton,
58
65
  isMobile: mobile
59
66
  }));
60
67
  // FeaturedIcon을 container에 추가
@@ -72,6 +79,7 @@ export class FloatingNotification {
72
79
  supportingText,
73
80
  actions,
74
81
  onClose,
82
+ hideCloseButton,
75
83
  isMobile
76
84
  } = params;
77
85
  return `
@@ -86,12 +94,20 @@ export class FloatingNotification {
86
94
  </div>
87
95
  </div>
88
96
  </div>
89
- ${this.renderCloseButton(onClose, isMobile)}
97
+ ${this.renderCloseButton({
98
+ onClose,
99
+ isMobile,
100
+ hideCloseButton
101
+ })}
90
102
  `;
91
103
  }
92
- renderCloseButton(onClose) {
93
- let isMobile = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
94
- if (!onClose) return '';
104
+ renderCloseButton(params) {
105
+ const {
106
+ onClose,
107
+ isMobile = false,
108
+ hideCloseButton = false
109
+ } = params;
110
+ if (!onClose || hideCloseButton) return '';
95
111
  const size = getSizes.closeButton(isMobile);
96
112
  return ButtonCloseX(size, 'light', CLASS_NAMES.FLOATING.CLOSE_BUTTON, '알림 닫기', onClose);
97
113
  }
@@ -9,6 +9,7 @@ export class FullWidthNotification {
9
9
  className: '',
10
10
  actions: [],
11
11
  autoClose: 0,
12
+ hideCloseButton: false,
12
13
  supportingText: undefined,
13
14
  ...options
14
15
  };
@@ -24,6 +25,7 @@ export class FullWidthNotification {
24
25
  className,
25
26
  actions,
26
27
  onClose,
28
+ hideCloseButton,
27
29
  supportTextLink,
28
30
  supportTextLinkTarget,
29
31
  onHidePermanently,
@@ -37,6 +39,7 @@ export class FullWidthNotification {
37
39
  supportingText,
38
40
  actions,
39
41
  onClose,
42
+ hideCloseButton,
40
43
  supportTextLink,
41
44
  onHidePermanently,
42
45
  hidePermanentlyLabel
@@ -51,6 +54,7 @@ export class FullWidthNotification {
51
54
  supportingText,
52
55
  actions,
53
56
  onClose,
57
+ hideCloseButton,
54
58
  supportTextLink,
55
59
  onHidePermanently,
56
60
  hidePermanentlyLabel
@@ -68,7 +72,10 @@ export class FullWidthNotification {
68
72
  <div class="${CLASS_NAMES.FULL_WIDTH.ACTIONS_CONTAINER}">
69
73
  ${actions && actions.length > 0 ? renderActions(actions, CLASS_NAMES.FULL_WIDTH.ACTIONS) : ''}
70
74
  ${this.renderHidePermanentlyButton(onHidePermanently, hidePermanentlyLabel)}
71
- ${this.renderCloseButton(onClose)}
75
+ ${this.renderCloseButton({
76
+ onClose,
77
+ hideCloseButton
78
+ })}
72
79
  </div>
73
80
  </div>
74
81
  </div>
@@ -89,8 +96,12 @@ export class FullWidthNotification {
89
96
  </button>
90
97
  `;
91
98
  }
92
- renderCloseButton(onClose) {
93
- if (!onClose) return '';
99
+ renderCloseButton(params) {
100
+ const {
101
+ onClose,
102
+ hideCloseButton = false
103
+ } = params;
104
+ if (!onClose || hideCloseButton) return '';
94
105
  return `
95
106
  <button type="button" class="${CLASS_NAMES.FULL_WIDTH.CLOSE_BUTTON}" aria-label="알림 닫기">
96
107
  ${SVG_ICONS['x-close'](FULL_WIDTH_SIZES.CLOSE_BUTTON)}
@@ -1,6 +1,6 @@
1
1
  import { FeaturedIcon } from '../featuredIcon';
2
2
  import { sanitizeHtml } from '../utils/sanitize';
3
- import { CLASS_NAMES, MESSAGE_BLOCK_SIZES, MESSAGE_ICON_MAP, MESSAGE_SIZES } from './const';
3
+ import { CLASS_NAMES, MESSAGE_BLOCK_ICON_MAP, MESSAGE_BLOCK_SIZES, MESSAGE_ICON_MAP, MESSAGE_SIZES } from './const';
4
4
  import { buildMessageTemplate } from './messageTemplate';
5
5
  import { applySupportTextLinkTarget, bindNotificationEvents, createWrapperElement, setupAutoClose } from './utils';
6
6
  export class MessageNotification {
@@ -10,6 +10,7 @@ export class MessageNotification {
10
10
  className: '',
11
11
  actions: [],
12
12
  autoClose: 0,
13
+ hideCloseButton: false,
13
14
  supportingText: undefined,
14
15
  ...options
15
16
  };
@@ -25,6 +26,7 @@ export class MessageNotification {
25
26
  className,
26
27
  actions,
27
28
  onClose,
29
+ hideCloseButton,
28
30
  onHidePermanently,
29
31
  hidePermanentlyLabel,
30
32
  variant,
@@ -32,18 +34,17 @@ export class MessageNotification {
32
34
  supportTextLinkTarget
33
35
  } = this.options;
34
36
  const isBlock = variant === 'block';
35
- // default 는 neutral, error, warning, success 4가지 색상만 지원 — info 는 block 에서만 유지한다.
36
- const actualColor = !isBlock && color === 'info' ? 'neutral' : color;
37
37
  const wrapperClassName = [isBlock ? CLASS_NAMES.MESSAGE.BLOCK : '', className].filter(Boolean).join(' ');
38
- const wrapper = createWrapperElement(CLASS_NAMES.MESSAGE.BASE, actualColor, wrapperClassName);
39
- const featuredIconElement = this.createFeaturedIcon(actualColor, isBlock);
38
+ const wrapper = createWrapperElement(CLASS_NAMES.MESSAGE.BASE, color, wrapperClassName);
39
+ const featuredIconElement = this.createFeaturedIcon(color, isBlock);
40
40
  wrapper.innerHTML = sanitizeHtml(buildMessageTemplate({
41
41
  title,
42
42
  supportingText,
43
43
  supportTextLink: isBlock ? supportTextLink : undefined,
44
- color: actualColor,
44
+ color,
45
45
  actions,
46
46
  onClose,
47
+ hideCloseButton,
47
48
  onHidePermanently,
48
49
  hidePermanentlyLabel
49
50
  }));
@@ -57,15 +58,14 @@ export class MessageNotification {
57
58
  }
58
59
  return wrapper;
59
60
  }
60
- /** 색상별 FeaturedIcon. default 는 md(40/20), block 은 sm(32/16). */
61
+ /** 색상별 FeaturedIcon. default 는 md(40/20), block 은 sm(32/16). info 아이콘만 variant 별로 다르다. */
61
62
  createFeaturedIcon(color, isBlock) {
62
- const iconFunction = MESSAGE_ICON_MAP[color];
63
- if (!iconFunction) return null;
63
+ const iconFunction = (isBlock ? MESSAGE_BLOCK_ICON_MAP : MESSAGE_ICON_MAP)[color];
64
64
  const sizes = isBlock ? MESSAGE_BLOCK_SIZES : MESSAGE_SIZES;
65
65
  this.featuredIcon = FeaturedIcon.create({
66
66
  svgString: iconFunction(sizes.ICON_PIXEL),
67
67
  theme: 'light-circle',
68
- // FeaturedIcon 에는 info 색이 없다. block+info 의 violet 톤은 message SCSS 가 덮어쓴다.
68
+ // FeaturedIcon 에는 info 색이 없다. info 의 violet 톤은 message SCSS 가 덮어쓴다.
69
69
  color: color === 'info' ? 'neutral' : color,
70
70
  size: sizes.FEATURED_ICON,
71
71
  // React 구현과 동일하게 `__icon`(flex-shrink: 0)을 부여한다.
@@ -1,3 +1,4 @@
1
+ import { resolveAutoClose } from '../../../src/utils/notification';
1
2
  import { FloatingNotification } from './FloatingNotification';
2
3
  import { FullWidthNotification } from './FullWidthNotification';
3
4
  import { MessageNotification } from './MessageNotification';
@@ -73,8 +74,13 @@ export class NcuaNotification {
73
74
  supportingText,
74
75
  color,
75
76
  type: 'floating',
76
- autoClose: autoCloseMap[color],
77
- ...options
77
+ ...options,
78
+ // 명시 autoClose > 색상별 기본값 > (floating 이고 hideCloseButton 이면 3초). neutral 은 기본 0 이라 세 번째 분기가 필요.
79
+ autoClose: resolveAutoClose({
80
+ autoClose: options?.autoClose,
81
+ hideCloseButton: (options?.type ?? 'floating') === 'floating' && options?.hideCloseButton,
82
+ fallback: autoCloseMap[color]
83
+ })
78
84
  });
79
85
  }
80
86
  // 클래스를 생성하지 않고도 기본 floating 알림 생성을 하기 위한 함수들
@@ -1,3 +1,8 @@
1
+ /**
2
+ * message block 변형의 InfoCircle. `SVG_ICONS['info-circle']`은 full-width 전용 class·color 가 박혀 있어
3
+ * 쓰지 않는다 (`.ncua-full-width-notification__icon`은 모바일에서 숨겨진다).
4
+ */
5
+ const INFO_CIRCLE_ICON = size => `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" fill="none" viewBox="0 0 24 24" stroke="none"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 16v-4m0-4h.01M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10"></path></svg>`;
1
6
  // SVG 아이콘들 (크기는 동적으로 설정)
2
7
  export const SVG_ICONS = {
3
8
  'pin-02': size => `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" fill="none" viewBox="0 0 24 24" stroke="none"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.377 15.616 2.72 21.273m8.974-14.631-1.56 1.56a2 2 0 0 1-.264.242 1 1 0 0 1-.207.111c-.082.032-.17.05-.347.085l-3.665.733c-.952.19-1.428.286-1.65.537a1 1 0 0 0-.243.8c.046.333.39.677 1.076 1.363l7.086 7.086c.686.687 1.03 1.03 1.362 1.076a1 1 0 0 0 .801-.242c.251-.223.346-.7.537-1.651l.733-3.665c.035-.176.053-.265.085-.347a1 1 0 0 1 .11-.207c.051-.072.115-.136.242-.263l1.561-1.561c.082-.082.122-.122.167-.158q.06-.047.126-.085c.05-.029.103-.051.208-.097l2.495-1.069c.727-.312 1.091-.467 1.256-.72a1 1 0 0 0 .144-.747c-.06-.295-.34-.575-.9-1.135l-5.142-5.143c-.56-.56-.84-.84-1.135-.9a1 1 0 0 0-.748.145c-.252.165-.407.529-.72 1.256l-1.068 2.495a2 2 0 0 1-.097.208 1 1 0 0 1-.085.126 2 2 0 0 1-.158.167"></path></svg>`,
@@ -23,12 +28,16 @@ export const FULL_WIDTH_ICON_MAP = {
23
28
  info: SVG_ICONS['info-circle']
24
29
  };
25
30
  export const ICON_MAP = FULL_WIDTH_ICON_MAP;
26
- /**
27
- * message 타입 아이콘. floating 과 같은 4색에 block 변형 전용 info 를 더한다.
28
- * `SVG_ICONS['info-circle']`은 full-width 전용 class·color 가 박혀 있어 쓰지 않는다
29
- * (`.ncua-full-width-notification__icon`은 모바일에서 숨겨진다).
30
- */
31
+ /** message 기본 타입 아이콘. floating 과 같은 4색에 info(neutral 과 같은 핀)를 더한다. */
31
32
  export const MESSAGE_ICON_MAP = {
32
- ...FLOATING_ICON_MAP,
33
- info: size => `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" fill="none" viewBox="0 0 24 24" stroke="none"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 16v-4m0-4h.01M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10"></path></svg>`
33
+ neutral: SVG_ICONS['pin-02'],
34
+ error: SVG_ICONS['alert-triangle'],
35
+ warning: SVG_ICONS['alert-circle'],
36
+ success: SVG_ICONS['check-circle'],
37
+ info: SVG_ICONS['pin-02']
38
+ };
39
+ /** block 변형 아이콘. info 만 InfoCircle 로 다르다 (#536 유지). */
40
+ export const MESSAGE_BLOCK_ICON_MAP = {
41
+ ...MESSAGE_ICON_MAP,
42
+ info: INFO_CIRCLE_ICON
34
43
  };
@@ -1,4 +1,4 @@
1
1
  // Re-export all constants and types from separate files
2
2
  export { CLASS_NAMES } from './classNames';
3
- export { FLOATING_ICON_MAP, FULL_WIDTH_ICON_MAP, ICON_MAP, MESSAGE_ICON_MAP, SVG_ICONS } from './icons';
3
+ export { FLOATING_ICON_MAP, FULL_WIDTH_ICON_MAP, ICON_MAP, MESSAGE_BLOCK_ICON_MAP, MESSAGE_ICON_MAP, SVG_ICONS } from './icons';
4
4
  export { CLOSE_BUTTON_SIZES, CLOSE_BUTTON_SVG_SIZES, FEATURED_ICON_SIZES, FULL_WIDTH_SIZES, getSizes, ICON_PIXEL_SIZES, MESSAGE_BLOCK_SIZES, MESSAGE_SIZES } from './sizes';
@@ -19,6 +19,7 @@ export function buildMessageTemplate(params) {
19
19
  color,
20
20
  actions,
21
21
  onClose,
22
+ hideCloseButton,
22
23
  onHidePermanently,
23
24
  hidePermanentlyLabel
24
25
  } = params;
@@ -34,6 +35,7 @@ export function buildMessageTemplate(params) {
34
35
  ${renderActionsContainer({
35
36
  actions,
36
37
  onClose,
38
+ hideCloseButton,
37
39
  onHidePermanently,
38
40
  hidePermanentlyLabel,
39
41
  color
@@ -51,6 +53,7 @@ function renderActionsContainer(params) {
51
53
  const {
52
54
  actions,
53
55
  onClose,
56
+ hideCloseButton,
54
57
  onHidePermanently,
55
58
  hidePermanentlyLabel,
56
59
  color
@@ -58,6 +61,7 @@ function renderActionsContainer(params) {
58
61
  const actionsHtml = renderActions(actions ?? [], CLASS_NAMES.MESSAGE.ACTIONS, ACTION_BUTTON_SIZE);
59
62
  const footerHtml = renderFooterContainer({
60
63
  onClose,
64
+ hideCloseButton,
61
65
  onHidePermanently,
62
66
  hidePermanentlyLabel,
63
67
  color
@@ -69,15 +73,23 @@ function renderActionsContainer(params) {
69
73
  function renderFooterContainer(params) {
70
74
  const {
71
75
  onClose,
76
+ hideCloseButton,
72
77
  onHidePermanently,
73
78
  hidePermanentlyLabel,
74
79
  color
75
80
  } = params;
76
- if (!onHidePermanently && !onClose) return '';
81
+ // footer 컨테이너와 닫기 버튼이 같은 판정을 보게 해 빈 footer 가 남지 않게 한다.
82
+ // cf. React `MessageNotificationParts.tsx` 의 showCloseButton — 두 구현이 같은 판정을 유지해야 한다.
83
+ const showCloseButton = Boolean(onClose) && !hideCloseButton;
84
+ if (!onHidePermanently && !showCloseButton) return '';
77
85
  return `
78
86
  <div class="${CLASS_NAMES.MESSAGE.FOOTER_CONTAINER}">
79
87
  ${renderHidePermanentlyButton(onHidePermanently, hidePermanentlyLabel)}
80
- ${renderCloseButton(onClose, color)}
88
+ ${renderCloseButton({
89
+ onClose,
90
+ hideCloseButton,
91
+ color
92
+ })}
81
93
  </div>
82
94
  `;
83
95
  }
@@ -100,9 +112,13 @@ function renderHidePermanentlyButton(onHidePermanently, hidePermanentlyLabel) {
100
112
  * 닫기(X) 버튼. 아이콘 색은 React `<XClose color>`와 같이 svg 의 `color` 속성으로 주고
101
113
  * path 는 `stroke="currentColor"`로 상속받는다 — 두 구현이 같은 마크업을 낸다.
102
114
  */
103
- function renderCloseButton(onClose) {
104
- let color = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'neutral';
105
- if (!onClose) return '';
115
+ function renderCloseButton(params) {
116
+ const {
117
+ onClose,
118
+ hideCloseButton = false,
119
+ color = 'neutral'
120
+ } = params;
121
+ if (!onClose || hideCloseButton) return '';
106
122
  const iconColor = MESSAGE_CLOSE_ICON_COLOR[color];
107
123
  return `
108
124
  <button type="button" class="${CLASS_NAMES.MESSAGE.CLOSE_BUTTON}" aria-label="알림 닫기">
@@ -18,7 +18,6 @@ export const HIDE_PERMANENTLY_LABEL = {
18
18
  * message 타입 닫기(X) 아이콘의 color 별 색.
19
19
  *
20
20
  * React(`MessageNotification.tsx`)와 Vanilla(`messageTemplate.ts`)가 함께 참조하는 단일 출처다.
21
- * `info`는 `variant: 'block'`에서만 렌더된다(default 는 neutral 로 폴백).
22
21
  */
23
22
  export const MESSAGE_CLOSE_ICON_COLOR = {
24
23
  neutral: COLOR.gray700,
@@ -26,4 +25,10 @@ export const MESSAGE_CLOSE_ICON_COLOR = {
26
25
  warning: COLOR.orange500,
27
26
  success: COLOR.green600,
28
27
  info: COLOR.violet600
29
- };
28
+ };
29
+ /**
30
+ * floating(토스트)에서 `hideCloseButton`인데 `autoClose`를 지정하지 않았을 때 적용되는 자동 닫힘 시간(ms).
31
+ * 닫기 버튼이 없는 토스트가 영구히 남지 않게 한다 — DES-SPEC-027 §5.3 Toast Alert 3초.
32
+ * full-width · message 는 부모가 언마운트로 닫으므로 적용하지 않는다.
33
+ */
34
+ export const HIDE_CLOSE_BUTTON_AUTO_CLOSE_MS = 3000;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { AlertCircle, AlertTriangle, CheckCircle, Pin02 } from '@ncds/ui-admin-icon';
3
3
  import classNames from 'classnames';
4
- import { forwardRef, useEffect, useId, useRef, useState } from 'react';
4
+ import { forwardRef, useEffect, useId, useState } from 'react';
5
5
  import { createPortal } from 'react-dom';
6
6
  import { MEDIA_QUERY } from '../../../constant/breakpoint';
7
7
  import { useMediaQuery } from '../../../hooks/useMediaQuery';
@@ -11,6 +11,7 @@ import { FeaturedIcon } from '../../image-and-icons/featured-icon/FeaturedIcon';
11
11
  // 하므로 React 컴포넌트는 deep relative path 로 vanilla internals 를 직접 import 하지 않는다.
12
12
  import { mountFloatingNotificationHost } from './host';
13
13
  import { NotificationActionButtons } from './NotificationActionButtons';
14
+ import { useAutoClose } from './useAutoClose';
14
15
  /**
15
16
  * 색상별 a11y role.
16
17
  * - error/warning → role="alert" (implicit aria-live="assertive": 즉시 발화)
@@ -26,7 +27,7 @@ const iconMap = {
26
27
  error: AlertTriangle,
27
28
  warning: AlertCircle,
28
29
  success: CheckCircle
29
- // info 는 full-width 전용이라 floating 아이콘 매핑 없음.
30
+ // info 는 floating 에서 지원하지 않으므로 아이콘 매핑 없음.
30
31
  };
31
32
  /**
32
33
  * NotificationColor → FeaturedIconColor 매핑.
@@ -65,13 +66,19 @@ const FloatingNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
65
66
  supportingText,
66
67
  color = 'neutral',
67
68
  onClose,
69
+ hideCloseButton = false,
68
70
  className,
69
71
  actions,
70
- autoClose = 0,
72
+ autoClose,
71
73
  portal = false,
72
74
  ...rest
73
75
  } = _ref;
74
- const [shouldRemove, setShouldRemove] = useState(false);
76
+ // floating 은 닫기 버튼이 없는데 autoClose 도 없으면 영구히 남으므로 기본 3초를 준다.
77
+ const shouldRemove = useAutoClose({
78
+ autoClose,
79
+ hideCloseButton,
80
+ onClose
81
+ });
75
82
  const featuredIconProps = {
76
83
  icon: iconMap[color] || Pin02,
77
84
  size: 'sm',
@@ -81,31 +88,6 @@ const FloatingNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
81
88
  const isMobile = useMediaQuery(MEDIA_QUERY.mobile, {
82
89
  onMatched: onClose
83
90
  });
84
- // onClose 는 매 렌더 새 함수 ref 일 수 있으므로 ref 로 latest 만 보관.
85
- // → autoClose 타이머 effect 의 deps 에서 onClose 를 빼서 타이머 재시작 회피.
86
- // render 본문에서 직접 할당 — useEffect 로 미루면 같은 commit 안에서 fire 되는 타이머가 stale onClose 를 볼 위험.
87
- const onCloseRef = useRef(onClose);
88
- onCloseRef.current = onClose;
89
- // autoClose 타이머 관리
90
- const timerRef = useRef(null);
91
- // onClose 는 onCloseRef 로 latest 만 추적하므로 deps 에서 제외 (의도된 패턴).
92
- useEffect(() => {
93
- // autoClose 가 0 보다 크면 타이머 설정.
94
- if (autoClose > 0) {
95
- timerRef.current = setTimeout(() => {
96
- onCloseRef.current?.();
97
- // DOM 에서 바로 제거
98
- setShouldRemove(true);
99
- }, autoClose);
100
- }
101
- // cleanup: 컴포넌트 언마운트 또는 autoClose 변경 시 타이머 정리
102
- return () => {
103
- if (timerRef.current) {
104
- clearTimeout(timerRef.current);
105
- timerRef.current = null;
106
- }
107
- };
108
- }, [autoClose]);
109
91
  // portal=true 일 때만 호스트가 필요하다.
110
92
  const host = useMountFloatingNotificationHost(portal);
111
93
  // a11y — 카드 root 의 role 과 제목/본문 ID. 색상에 따라 alert(error/warning) / status(나머지) 로 분기.
@@ -155,7 +137,7 @@ const FloatingNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
155
137
  })]
156
138
  })]
157
139
  })
158
- }), onClose && _jsx(ButtonCloseX, {
140
+ }), onClose && !hideCloseButton && _jsx(ButtonCloseX, {
159
141
  theme: "light",
160
142
  className: "ncua-floating-notification__close-button",
161
143
  size: isMobile ? 'sm' : 'xs',
@@ -1,12 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { AlertTriangle, CheckCircle, InfoCircle, MessageChatSquare, XClose } from '@ncds/ui-admin-icon';
3
3
  import classNames from 'classnames';
4
- import { forwardRef, useEffect, useRef, useState } from 'react';
4
+ import { forwardRef } from 'react';
5
5
  import { COLOR } from '../../../../constant/color';
6
6
  import { HIDE_PERMANENTLY_LABEL } from '../../../../constant/notification';
7
7
  import { isSafeUrl } from '../../../utils/url';
8
8
  import { getLinkTargetAttributes } from './linkTarget';
9
9
  import { NotificationActionButtons } from './NotificationActionButtons';
10
+ import { useAutoClose } from './useAutoClose';
10
11
  const iconMap = {
11
12
  neutral: MessageChatSquare,
12
13
  error: AlertTriangle,
@@ -27,43 +28,27 @@ const FullWidthNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
27
28
  supportingText,
28
29
  color = 'neutral',
29
30
  onClose,
31
+ hideCloseButton = false,
30
32
  className,
31
33
  actions,
32
- autoClose = 0,
34
+ autoClose,
33
35
  supportTextLink,
34
36
  supportTextLinkTarget,
35
37
  onHidePermanently,
36
38
  hidePermanentlyLabel = HIDE_PERMANENTLY_LABEL.fullWidth,
37
39
  ...rest
38
40
  } = _ref;
39
- const [shouldRemove, setShouldRemove] = useState(false);
41
+ // full-width 는 부모가 언마운트로 닫으므로 hideCloseButton 기본 autoClose 를 적용하지 않는다.
42
+ const shouldRemove = useAutoClose({
43
+ autoClose,
44
+ onClose
45
+ });
40
46
  // unsafe URL(javascript: 등)이면 링크 없이 텍스트만 렌더한다 — Vanilla `renderSupportingText` 와 같은 정책.
41
47
  const safeSupportTextLink = supportTextLink && isSafeUrl(supportTextLink) ? supportTextLink : undefined;
42
48
  const closeIconSize = {
43
49
  width: 20,
44
50
  height: 20
45
51
  };
46
- // autoClose 타이머 관리
47
- const timerRef = useRef(null);
48
- useEffect(() => {
49
- // autoClose가 0보다 크면 무조건 타이머 설정
50
- if (autoClose > 0) {
51
- timerRef.current = setTimeout(() => {
52
- if (onClose) {
53
- onClose();
54
- }
55
- // DOM에서 바로 제거
56
- setShouldRemove(true);
57
- }, autoClose);
58
- }
59
- // cleanup 함수: 컴포넌트 언마운트 시 타이머 정리
60
- return () => {
61
- if (timerRef.current) {
62
- clearTimeout(timerRef.current);
63
- timerRef.current = null;
64
- }
65
- };
66
- }, [autoClose, onClose]);
67
52
  // DOM에서 완전히 제거
68
53
  if (shouldRemove) {
69
54
  return null;
@@ -117,7 +102,7 @@ const FullWidthNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
117
102
  className: classNames('ncua-notification__action-button', 'ncua-notification__action-button--text', 'ncua-full-width-notification__link'),
118
103
  onClick: onHidePermanently,
119
104
  children: hidePermanentlyLabel
120
- }), onClose && _jsx("button", {
105
+ }), onClose && !hideCloseButton && _jsx("button", {
121
106
  type: "button",
122
107
  className: "ncua-full-width-notification__close-button",
123
108
  onClick: onClose,