@ncds/ui-admin 1.8.26-alpha.5 → 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 (40) hide show
  1. package/dist/cjs/assets/scripts/notification/MessageNotification.js +6 -9
  2. package/dist/cjs/assets/scripts/notification/const/icons.js +17 -8
  3. package/dist/cjs/assets/scripts/notification/const/index.js +6 -0
  4. package/dist/cjs/constant/notification.js +0 -1
  5. package/dist/cjs/src/components/overlays/notification/FloatingNotification.js +1 -1
  6. package/dist/cjs/src/components/overlays/notification/MessageNotification.js +13 -9
  7. package/dist/cjs/src/components/overlays/notification/__tests__/MessageNotification.test.js +55 -13
  8. package/dist/cjs/src/generated/scoped-css.js +1 -1
  9. package/dist/esm/assets/scripts/notification/MessageNotification.js +7 -10
  10. package/dist/esm/assets/scripts/notification/const/icons.js +16 -7
  11. package/dist/esm/assets/scripts/notification/const/index.js +1 -1
  12. package/dist/esm/constant/notification.js +0 -1
  13. package/dist/esm/src/components/overlays/notification/FloatingNotification.js +1 -1
  14. package/dist/esm/src/components/overlays/notification/MessageNotification.js +13 -9
  15. package/dist/esm/src/components/overlays/notification/__tests__/MessageNotification.test.js +55 -13
  16. package/dist/esm/src/generated/scoped-css.js +1 -1
  17. package/dist/temp/assets/scripts/notification/MessageNotification.d.ts +1 -1
  18. package/dist/temp/assets/scripts/notification/MessageNotification.js +7 -11
  19. package/dist/temp/assets/scripts/notification/const/icons.d.ts +6 -6
  20. package/dist/temp/assets/scripts/notification/const/icons.js +16 -7
  21. package/dist/temp/assets/scripts/notification/const/index.d.ts +1 -1
  22. package/dist/temp/assets/scripts/notification/const/index.js +1 -1
  23. package/dist/temp/assets/scripts/notification/const/types.d.ts +1 -1
  24. package/dist/temp/constant/notification.d.ts +0 -1
  25. package/dist/temp/constant/notification.js +0 -1
  26. package/dist/temp/src/components/overlays/notification/FloatingNotification.js +1 -1
  27. package/dist/temp/src/components/overlays/notification/MessageNotification.d.ts +1 -1
  28. package/dist/temp/src/components/overlays/notification/MessageNotification.js +9 -8
  29. package/dist/temp/src/components/overlays/notification/Notification.d.ts +2 -2
  30. package/dist/temp/src/components/overlays/notification/__tests__/MessageNotification.test.js +44 -9
  31. package/dist/temp/src/generated/scoped-css.js +1 -1
  32. package/dist/types/assets/scripts/notification/MessageNotification.d.ts +1 -1
  33. package/dist/types/assets/scripts/notification/const/icons.d.ts +6 -6
  34. package/dist/types/assets/scripts/notification/const/index.d.ts +1 -1
  35. package/dist/types/assets/scripts/notification/const/types.d.ts +1 -1
  36. package/dist/types/constant/notification.d.ts +0 -1
  37. package/dist/types/src/components/overlays/notification/MessageNotification.d.ts +1 -1
  38. package/dist/types/src/components/overlays/notification/Notification.d.ts +2 -2
  39. package/dist/ui-admin/assets/styles/style.css +17 -11
  40. package/package.json +1 -1
@@ -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 {
@@ -34,16 +34,14 @@ export class MessageNotification {
34
34
  supportTextLinkTarget
35
35
  } = this.options;
36
36
  const isBlock = variant === 'block';
37
- // default 는 neutral, error, warning, success 4가지 색상만 지원 — info 는 block 에서만 유지한다.
38
- const actualColor = !isBlock && color === 'info' ? 'neutral' : color;
39
37
  const wrapperClassName = [isBlock ? CLASS_NAMES.MESSAGE.BLOCK : '', className].filter(Boolean).join(' ');
40
- const wrapper = createWrapperElement(CLASS_NAMES.MESSAGE.BASE, actualColor, wrapperClassName);
41
- const featuredIconElement = this.createFeaturedIcon(actualColor, isBlock);
38
+ const wrapper = createWrapperElement(CLASS_NAMES.MESSAGE.BASE, color, wrapperClassName);
39
+ const featuredIconElement = this.createFeaturedIcon(color, isBlock);
42
40
  wrapper.innerHTML = sanitizeHtml(buildMessageTemplate({
43
41
  title,
44
42
  supportingText,
45
43
  supportTextLink: isBlock ? supportTextLink : undefined,
46
- color: actualColor,
44
+ color,
47
45
  actions,
48
46
  onClose,
49
47
  hideCloseButton,
@@ -60,15 +58,14 @@ export class MessageNotification {
60
58
  }
61
59
  return wrapper;
62
60
  }
63
- /** 색상별 FeaturedIcon. default 는 md(40/20), block 은 sm(32/16). */
61
+ /** 색상별 FeaturedIcon. default 는 md(40/20), block 은 sm(32/16). info 아이콘만 variant 별로 다르다. */
64
62
  createFeaturedIcon(color, isBlock) {
65
- const iconFunction = MESSAGE_ICON_MAP[color];
66
- if (!iconFunction) return null;
63
+ const iconFunction = (isBlock ? MESSAGE_BLOCK_ICON_MAP : MESSAGE_ICON_MAP)[color];
67
64
  const sizes = isBlock ? MESSAGE_BLOCK_SIZES : MESSAGE_SIZES;
68
65
  this.featuredIcon = FeaturedIcon.create({
69
66
  svgString: iconFunction(sizes.ICON_PIXEL),
70
67
  theme: 'light-circle',
71
- // FeaturedIcon 에는 info 색이 없다. block+info 의 violet 톤은 message SCSS 가 덮어쓴다.
68
+ // FeaturedIcon 에는 info 색이 없다. info 의 violet 톤은 message SCSS 가 덮어쓴다.
72
69
  color: color === 'info' ? 'neutral' : color,
73
70
  size: sizes.FEATURED_ICON,
74
71
  // React 구현과 동일하게 `__icon`(flex-shrink: 0)을 부여한다.
@@ -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';
@@ -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,
@@ -27,7 +27,7 @@ const iconMap = {
27
27
  error: AlertTriangle,
28
28
  warning: AlertCircle,
29
29
  success: CheckCircle
30
- // info 는 full-width 전용이라 floating 아이콘 매핑 없음.
30
+ // info 는 floating 에서 지원하지 않으므로 아이콘 매핑 없음.
31
31
  };
32
32
  /**
33
33
  * NotificationColor → FeaturedIconColor 매핑.
@@ -5,12 +5,17 @@ import { forwardRef } from 'react';
5
5
  import { MESSAGE_CLOSE_ICON_COLOR } from '../../../../constant/notification';
6
6
  import { MessageNotificationActions, MessageNotificationContent } from './MessageNotificationParts';
7
7
  import { useAutoClose } from './useAutoClose';
8
- const iconMap = {
8
+ const DEFAULT_ICON_MAP = {
9
9
  neutral: Pin02,
10
10
  error: AlertTriangle,
11
11
  warning: AlertCircle,
12
12
  success: CheckCircle,
13
- // info 는 variant="block" 에서만 도달한다 (default 는 neutral 로 폴백).
13
+ // 디자인 기준 default 의 info 는 neutral 과 같은 핀이다.
14
+ info: Pin02
15
+ };
16
+ // block 의 info 는 InfoCircle 을 유지한다 (#536).
17
+ const BLOCK_ICON_MAP = {
18
+ ...DEFAULT_ICON_MAP,
14
19
  info: InfoCircle
15
20
  };
16
21
  const MessageNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
@@ -32,10 +37,9 @@ const MessageNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
32
37
  ...rest
33
38
  } = _ref;
34
39
  const isBlock = variant === 'block';
35
- // default 는 neutral, error, warning, success 4가지 색상만 지원 — info 는 block 에서만 유지한다.
36
- const validColor = !isBlock && color === 'info' ? 'neutral' : color;
37
- // FeaturedIcon 에는 info 색이 없다. block+info 의 violet 톤은 message SCSS 가 덮어쓴다.
38
- const featuredIconColor = validColor === 'info' ? 'neutral' : validColor;
40
+ const iconMap = isBlock ? BLOCK_ICON_MAP : DEFAULT_ICON_MAP;
41
+ // FeaturedIcon 에는 info 색이 없다. info 의 violet 톤은 message SCSS 가 덮어쓴다.
42
+ const featuredIconColor = color === 'info' ? 'neutral' : color;
39
43
  // message 는 부모가 언마운트로 닫으므로 hideCloseButton 기본 autoClose 를 적용하지 않는다.
40
44
  const shouldRemove = useAutoClose({
41
45
  autoClose,
@@ -46,7 +50,7 @@ const MessageNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
46
50
  }
47
51
  return _jsx("div", {
48
52
  ref: ref,
49
- className: classNames('ncua-message-notification', `ncua-message-notification--${validColor}`, {
53
+ className: classNames('ncua-message-notification', `ncua-message-notification--${color}`, {
50
54
  'ncua-message-notification--block': isBlock
51
55
  }, className),
52
56
  role: "alert",
@@ -60,7 +64,7 @@ const MessageNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
60
64
  supportingText: supportingText,
61
65
  supportTextLink: isBlock ? supportTextLink : undefined,
62
66
  supportTextLinkTarget: supportTextLinkTarget,
63
- icon: Icon || iconMap[validColor],
67
+ icon: Icon || iconMap[color],
64
68
  iconColor: featuredIconColor,
65
69
  iconSize: isBlock ? 'sm' : 'md'
66
70
  }), _jsx(MessageNotificationActions, {
@@ -69,7 +73,7 @@ const MessageNotification = /*#__PURE__*/forwardRef((_ref, ref) => {
69
73
  hideCloseButton: hideCloseButton,
70
74
  onHidePermanently: onHidePermanently,
71
75
  hidePermanentlyLabel: hidePermanentlyLabel,
72
- closeIconColor: MESSAGE_CLOSE_ICON_COLOR[validColor]
76
+ closeIconColor: MESSAGE_CLOSE_ICON_COLOR[color]
73
77
  })]
74
78
  })
75
79
  })
@@ -1,4 +1,5 @@
1
1
  // @vitest-environment jsdom
2
+ import { InfoCircle, Pin02 } from '@ncds/ui-admin-icon';
2
3
  import { createElement } from 'react';
3
4
  import { createRoot } from 'react-dom/client';
4
5
  import { act } from 'react-dom/test-utils';
@@ -18,16 +19,12 @@ const SELECTOR = {
18
19
  CLOSE_BUTTON: '.ncua-message-notification__close-button'
19
20
  };
20
21
  const mounted = [];
21
- function renderMessageNotification() {
22
- let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
22
+ function mount(element) {
23
23
  const container = document.createElement('div');
24
24
  document.body.appendChild(container);
25
25
  const root = createRoot(container);
26
26
  act(() => {
27
- root.render(/*#__PURE__*/createElement(MessageNotification, {
28
- title: '알림 제목',
29
- ...props
30
- }));
27
+ root.render(element);
31
28
  });
32
29
  mounted.push({
33
30
  root,
@@ -35,6 +32,20 @@ function renderMessageNotification() {
35
32
  });
36
33
  return container;
37
34
  }
35
+ function renderMessageNotification() {
36
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
37
+ return mount(/*#__PURE__*/createElement(MessageNotification, {
38
+ title: '알림 제목',
39
+ ...props
40
+ }));
41
+ }
42
+ /** 아이콘 컴포넌트를 단독 렌더해 `path[d]` 를 얻는다. 아이콘 판정은 d 비교로 한다. */
43
+ function iconPathD(Icon) {
44
+ return mount(/*#__PURE__*/createElement(Icon)).querySelector('path')?.getAttribute('d') ?? null;
45
+ }
46
+ function renderedIconPathD(container) {
47
+ return container.querySelector(`${SELECTOR.ICON} svg path`)?.getAttribute('d') ?? null;
48
+ }
38
49
  afterEach(() => {
39
50
  for (const {
40
51
  root,
@@ -143,17 +154,48 @@ describe('MessageNotification (React) — DOM 구조 계약', () => {
143
154
  expect(hideLink?.className.split(' ').filter(Boolean).sort()).toEqual(['ncua-message-notification__hide-link', 'ncua-notification__action-button']);
144
155
  });
145
156
  });
146
- describe('MessageNotification (React) — 공개 API 회귀 방지', () => {
147
- it('지원하지 않는 color("info")는 neutral로 폴백한다', () => {
148
- // Given/When: message 타입이 지원하지 않는 info 색상을 넘기면
157
+ describe('MessageNotification (React) — color="info" (#568)', () => {
158
+ it('R-01: color="info" 는 neutral 로 폴백하지 않고 --info 수식자로 렌더한다', () => {
159
+ // Given/When: variant 미지정, info 색상으로 렌더하면
160
+ const root = renderMessageNotification({
161
+ color: 'info'
162
+ }).querySelector(SELECTOR.ROOT);
163
+ // Then: info 수식자가 있고 neutral 수식자는 없다
164
+ expect(root?.classList.contains('ncua-message-notification--info')).toBe(true);
165
+ expect(root?.classList.contains('ncua-message-notification--neutral')).toBe(false);
166
+ });
167
+ it('R-02: 기본 info 아이콘은 neutral 과 같은 Pin02 다', () => {
168
+ // Given/When: variant 미지정, info 색상으로 렌더하면
149
169
  const container = renderMessageNotification({
150
170
  color: 'info'
151
171
  });
152
- // Then: neutral 수식자로 렌더되고 info 수식자는 없다
153
- const root = container.querySelector(SELECTOR.ROOT);
154
- expect(root?.classList.contains('ncua-message-notification--neutral')).toBe(true);
155
- expect(root?.classList.contains('ncua-message-notification--info')).toBe(false);
172
+ // Then: 아이콘 path 가 Pin02 와 같다
173
+ const expected = iconPathD(Pin02);
174
+ expect(expected).not.toBeNull();
175
+ expect(renderedIconPathD(container)).toBe(expected);
156
176
  });
177
+ it('R-03: info 의 FeaturedIcon 은 neutral·md 로 렌더한다 (violet 톤은 SCSS 가 덮는다)', () => {
178
+ // Given/When: variant 미지정, info 색상으로 렌더하면
179
+ const icon = renderMessageNotification({
180
+ color: 'info'
181
+ }).querySelector(SELECTOR.ICON);
182
+ // Then: FeaturedIcon 에는 info 색이 없으므로 neutral 수식자와 md 사이즈가 유지된다
183
+ expect(icon?.classList.contains('ncua-featured-icon--neutral')).toBe(true);
184
+ expect(icon?.classList.contains('ncua-featured-icon--md')).toBe(true);
185
+ });
186
+ it('R-04: block 의 info 아이콘은 InfoCircle 을 유지한다', () => {
187
+ // Given/When: block 변형에 info 색상으로 렌더하면
188
+ const container = renderMessageNotification({
189
+ variant: 'block',
190
+ color: 'info'
191
+ });
192
+ // Then: 아이콘 path 가 InfoCircle 과 같다 (#536 회귀)
193
+ const expected = iconPathD(InfoCircle);
194
+ expect(expected).not.toBeNull();
195
+ expect(renderedIconPathD(container)).toBe(expected);
196
+ });
197
+ });
198
+ describe('MessageNotification (React) — 공개 API 회귀 방지', () => {
157
199
  it('닫기/다시 보지 않기 클릭 시 핸들러가 호출되고 접근성 속성이 유지된다', () => {
158
200
  // Given: 핸들러를 지정해 렌더하고
159
201
  const onClose = vi.fn();