@ncds/ui-admin 1.8.26-alpha.5 → 1.8.26-alpha.7

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