@ncds/ui-admin 1.8.26-alpha.6 → 1.8.26-alpha.8
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.
- package/dist/cjs/assets/scripts/notification/FloatingNotification.js +4 -1
- package/dist/cjs/assets/scripts/notification/FullWidthNotification.js +5 -1
- package/dist/cjs/assets/scripts/notification/MessageNotification.js +7 -16
- package/dist/cjs/assets/scripts/notification/const/classNames.js +0 -2
- package/dist/cjs/assets/scripts/notification/const/icons.js +1 -11
- package/dist/cjs/assets/scripts/notification/const/index.js +0 -12
- package/dist/cjs/assets/scripts/notification/const/sizes.js +1 -6
- package/dist/cjs/assets/scripts/notification/messageTemplate.js +4 -2
- package/dist/cjs/assets/scripts/notification/utils.js +13 -5
- package/dist/cjs/src/components/overlays/notification/MessageNotification.js +4 -19
- package/dist/cjs/src/components/overlays/notification/MessageNotificationParts.js +7 -18
- package/dist/cjs/src/components/overlays/notification/Notification.js +6 -5
- package/dist/cjs/src/components/overlays/notification/__tests__/MessageNotification.test.js +7 -7
- package/dist/cjs/src/components/overlays/notification/__tests__/Notification.test.js +8 -0
- package/dist/cjs/src/components/overlays/notification/__tests__/supportTextLink.test.js +1 -7
- package/dist/cjs/src/generated/scoped-css.js +1 -1
- package/dist/cjs/src/utils/url/isSafeUrl.js +1 -1
- package/dist/cjs/vitest.config.js +12 -1
- package/dist/esm/assets/scripts/notification/FloatingNotification.js +4 -1
- package/dist/esm/assets/scripts/notification/FullWidthNotification.js +5 -1
- package/dist/esm/assets/scripts/notification/MessageNotification.js +9 -18
- package/dist/esm/assets/scripts/notification/const/classNames.js +0 -2
- package/dist/esm/assets/scripts/notification/const/icons.js +0 -10
- package/dist/esm/assets/scripts/notification/const/index.js +2 -2
- package/dist/esm/assets/scripts/notification/const/sizes.js +0 -5
- package/dist/esm/assets/scripts/notification/messageTemplate.js +4 -2
- package/dist/esm/assets/scripts/notification/utils.js +11 -4
- package/dist/esm/src/components/overlays/notification/MessageNotification.js +5 -20
- package/dist/esm/src/components/overlays/notification/MessageNotificationParts.js +7 -18
- package/dist/esm/src/components/overlays/notification/Notification.js +6 -5
- package/dist/esm/src/components/overlays/notification/__tests__/MessageNotification.test.js +8 -8
- package/dist/esm/src/components/overlays/notification/__tests__/Notification.test.js +8 -0
- package/dist/esm/src/components/overlays/notification/__tests__/supportTextLink.test.js +1 -7
- package/dist/esm/src/generated/scoped-css.js +1 -1
- package/dist/esm/src/utils/url/isSafeUrl.js +1 -1
- package/dist/esm/vitest.config.js +12 -1
- package/dist/temp/assets/scripts/notification/FloatingNotification.js +1 -1
- package/dist/temp/assets/scripts/notification/FullWidthNotification.js +1 -1
- package/dist/temp/assets/scripts/notification/MessageNotification.d.ts +1 -1
- package/dist/temp/assets/scripts/notification/MessageNotification.js +9 -15
- package/dist/temp/assets/scripts/notification/const/classNames.d.ts +0 -2
- package/dist/temp/assets/scripts/notification/const/classNames.js +0 -2
- package/dist/temp/assets/scripts/notification/const/icons.d.ts +0 -2
- package/dist/temp/assets/scripts/notification/const/icons.js +0 -10
- package/dist/temp/assets/scripts/notification/const/index.d.ts +3 -3
- package/dist/temp/assets/scripts/notification/const/index.js +2 -2
- package/dist/temp/assets/scripts/notification/const/sizes.d.ts +0 -4
- package/dist/temp/assets/scripts/notification/const/sizes.js +0 -5
- package/dist/temp/assets/scripts/notification/const/types.d.ts +7 -22
- package/dist/temp/assets/scripts/notification/messageTemplate.d.ts +0 -2
- package/dist/temp/assets/scripts/notification/messageTemplate.js +2 -2
- package/dist/temp/assets/scripts/notification/utils.d.ts +10 -1
- package/dist/temp/assets/scripts/notification/utils.js +6 -3
- package/dist/temp/src/components/overlays/notification/FloatingNotification.d.ts +3 -4
- package/dist/temp/src/components/overlays/notification/FullWidthNotification.d.ts +2 -4
- package/dist/temp/src/components/overlays/notification/MessageNotification.d.ts +2 -18
- package/dist/temp/src/components/overlays/notification/MessageNotification.js +4 -8
- package/dist/temp/src/components/overlays/notification/MessageNotificationParts.d.ts +4 -10
- package/dist/temp/src/components/overlays/notification/MessageNotificationParts.js +4 -7
- package/dist/temp/src/components/overlays/notification/Notification.d.ts +8 -28
- package/dist/temp/src/components/overlays/notification/Notification.js +4 -2
- package/dist/temp/src/components/overlays/notification/__tests__/MessageNotification.test.js +12 -9
- package/dist/temp/src/components/overlays/notification/__tests__/Notification.test.js +5 -0
- package/dist/temp/src/components/overlays/notification/__tests__/supportTextLink.test.js +0 -11
- package/dist/temp/src/generated/scoped-css.js +1 -1
- package/dist/temp/src/utils/url/isSafeUrl.d.ts +1 -1
- package/dist/temp/src/utils/url/isSafeUrl.js +1 -1
- package/dist/temp/vitest.config.js +11 -0
- package/dist/types/assets/scripts/notification/MessageNotification.d.ts +1 -1
- package/dist/types/assets/scripts/notification/const/classNames.d.ts +0 -2
- package/dist/types/assets/scripts/notification/const/icons.d.ts +0 -2
- package/dist/types/assets/scripts/notification/const/index.d.ts +3 -3
- package/dist/types/assets/scripts/notification/const/sizes.d.ts +0 -4
- package/dist/types/assets/scripts/notification/const/types.d.ts +7 -22
- package/dist/types/assets/scripts/notification/messageTemplate.d.ts +0 -2
- package/dist/types/assets/scripts/notification/utils.d.ts +10 -1
- package/dist/types/src/components/overlays/notification/FloatingNotification.d.ts +3 -4
- package/dist/types/src/components/overlays/notification/FullWidthNotification.d.ts +2 -4
- package/dist/types/src/components/overlays/notification/MessageNotification.d.ts +2 -18
- package/dist/types/src/components/overlays/notification/MessageNotificationParts.d.ts +4 -10
- package/dist/types/src/components/overlays/notification/Notification.d.ts +8 -28
- package/dist/types/src/utils/url/isSafeUrl.d.ts +1 -1
- package/dist/ui-admin/assets/styles/style.css +0 -19
- package/package.json +2 -2
|
@@ -95,7 +95,10 @@ class FloatingNotification {
|
|
|
95
95
|
<div class="${_const.CLASS_NAMES.FLOATING.TITLE_WRAPPER}">
|
|
96
96
|
<span class="${_const.CLASS_NAMES.FLOATING.TITLE}">${title}</span>
|
|
97
97
|
</div>
|
|
98
|
-
${(0, _utils.renderSupportingText)(
|
|
98
|
+
${(0, _utils.renderSupportingText)({
|
|
99
|
+
supportingText,
|
|
100
|
+
className: _const.CLASS_NAMES.FLOATING.SUPPORTING_TEXT
|
|
101
|
+
})}
|
|
99
102
|
${actions && actions.length > 0 ? (0, _utils.renderActions)(actions, _const.CLASS_NAMES.FLOATING.ACTIONS) : ''}
|
|
100
103
|
</div>
|
|
101
104
|
</div>
|
|
@@ -72,7 +72,11 @@ class FullWidthNotification {
|
|
|
72
72
|
<div class="${_const.CLASS_NAMES.FULL_WIDTH.ICON}">${iconHtml}</div>
|
|
73
73
|
<div class="${_const.CLASS_NAMES.FULL_WIDTH.TEXT_CONTAINER}">
|
|
74
74
|
<span class="${_const.CLASS_NAMES.FULL_WIDTH.TITLE}">${title}</span>
|
|
75
|
-
${(0, _utils.renderSupportingText)(
|
|
75
|
+
${(0, _utils.renderSupportingText)({
|
|
76
|
+
supportingText,
|
|
77
|
+
className: _const.CLASS_NAMES.FULL_WIDTH.SUPPORTING_TEXT,
|
|
78
|
+
supportTextLink
|
|
79
|
+
})}
|
|
76
80
|
</div>
|
|
77
81
|
</div>
|
|
78
82
|
<div class="${_const.CLASS_NAMES.FULL_WIDTH.ACTIONS_CONTAINER}">
|
|
@@ -34,19 +34,13 @@ class MessageNotification {
|
|
|
34
34
|
onClose,
|
|
35
35
|
hideCloseButton,
|
|
36
36
|
onHidePermanently,
|
|
37
|
-
hidePermanentlyLabel
|
|
38
|
-
variant,
|
|
39
|
-
supportTextLink,
|
|
40
|
-
supportTextLinkTarget
|
|
37
|
+
hidePermanentlyLabel
|
|
41
38
|
} = this.options;
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const wrapper = (0, _utils.createWrapperElement)(_const.CLASS_NAMES.MESSAGE.BASE, color, wrapperClassName);
|
|
45
|
-
const featuredIconElement = this.createFeaturedIcon(color, isBlock);
|
|
39
|
+
const wrapper = (0, _utils.createWrapperElement)(_const.CLASS_NAMES.MESSAGE.BASE, color, className);
|
|
40
|
+
const featuredIconElement = this.createFeaturedIcon(color);
|
|
46
41
|
wrapper.innerHTML = (0, _sanitize.sanitizeHtml)((0, _messageTemplate.buildMessageTemplate)({
|
|
47
42
|
title,
|
|
48
43
|
supportingText,
|
|
49
|
-
supportTextLink: isBlock ? supportTextLink : undefined,
|
|
50
44
|
color,
|
|
51
45
|
actions,
|
|
52
46
|
onClose,
|
|
@@ -54,7 +48,6 @@ class MessageNotification {
|
|
|
54
48
|
onHidePermanently,
|
|
55
49
|
hidePermanentlyLabel
|
|
56
50
|
}));
|
|
57
|
-
(0, _utils.applySupportTextLinkTarget)(wrapper, _const.CLASS_NAMES.MESSAGE.TEXT_CONTAINER, _const.CLASS_NAMES.MESSAGE.LINK, supportTextLinkTarget);
|
|
58
51
|
// FeaturedIcon을 content-wrapper에 추가
|
|
59
52
|
if (featuredIconElement) {
|
|
60
53
|
const contentWrapper = wrapper.querySelector(`.${_const.CLASS_NAMES.MESSAGE.CONTENT_WRAPPER}`);
|
|
@@ -64,16 +57,14 @@ class MessageNotification {
|
|
|
64
57
|
}
|
|
65
58
|
return wrapper;
|
|
66
59
|
}
|
|
67
|
-
/** 색상별 FeaturedIcon.
|
|
68
|
-
createFeaturedIcon(color
|
|
69
|
-
const iconFunction = (isBlock ? _const.MESSAGE_BLOCK_ICON_MAP : _const.MESSAGE_ICON_MAP)[color];
|
|
70
|
-
const sizes = isBlock ? _const.MESSAGE_BLOCK_SIZES : _const.MESSAGE_SIZES;
|
|
60
|
+
/** 색상별 FeaturedIcon. md(40px 원 / 20px 아이콘) 고정. */
|
|
61
|
+
createFeaturedIcon(color) {
|
|
71
62
|
this.featuredIcon = _featuredIcon.FeaturedIcon.create({
|
|
72
|
-
svgString:
|
|
63
|
+
svgString: _const.MESSAGE_ICON_MAP[color](_const.MESSAGE_SIZES.ICON_PIXEL),
|
|
73
64
|
theme: 'light-circle',
|
|
74
65
|
// FeaturedIcon 에는 info 색이 없다. info 의 violet 톤은 message SCSS 가 덮어쓴다.
|
|
75
66
|
color: color === 'info' ? 'neutral' : color,
|
|
76
|
-
size:
|
|
67
|
+
size: _const.MESSAGE_SIZES.FEATURED_ICON,
|
|
77
68
|
// React 구현과 동일하게 `__icon`(flex-shrink: 0)을 부여한다.
|
|
78
69
|
// 누락 시 긴 타이틀에서 아이콘이 찌그러진다.
|
|
79
70
|
className: _const.CLASS_NAMES.MESSAGE.ICON
|
|
@@ -33,7 +33,6 @@ const CLASS_NAMES = exports.CLASS_NAMES = {
|
|
|
33
33
|
},
|
|
34
34
|
MESSAGE: {
|
|
35
35
|
BASE: 'ncua-message-notification',
|
|
36
|
-
BLOCK: 'ncua-message-notification--block',
|
|
37
36
|
CONTAINER: 'ncua-message-notification__container',
|
|
38
37
|
CONTENT: 'ncua-message-notification__content',
|
|
39
38
|
CONTENT_WRAPPER: 'ncua-message-notification__content-wrapper',
|
|
@@ -41,7 +40,6 @@ const CLASS_NAMES = exports.CLASS_NAMES = {
|
|
|
41
40
|
TEXT_CONTAINER: 'ncua-message-notification__text-container',
|
|
42
41
|
TITLE: 'ncua-message-notification__title',
|
|
43
42
|
SUPPORTING_TEXT: 'ncua-message-notification__supporting-text',
|
|
44
|
-
LINK: 'ncua-message-notification__link',
|
|
45
43
|
ACTIONS_CONTAINER: 'ncua-message-notification__actions-container',
|
|
46
44
|
ACTIONS: 'ncua-message-notification__actions',
|
|
47
45
|
// 다시 보지 않기 + 닫기 그룹 전용 래퍼. ACTIONS_CONTAINER를 재사용하면
|
|
@@ -3,12 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.SVG_ICONS = exports.MESSAGE_ICON_MAP = exports.
|
|
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>`;
|
|
6
|
+
exports.SVG_ICONS = exports.MESSAGE_ICON_MAP = exports.ICON_MAP = exports.FULL_WIDTH_ICON_MAP = exports.FLOATING_ICON_MAP = void 0;
|
|
12
7
|
// SVG 아이콘들 (크기는 동적으로 설정)
|
|
13
8
|
const SVG_ICONS = exports.SVG_ICONS = {
|
|
14
9
|
'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>`,
|
|
@@ -41,9 +36,4 @@ const MESSAGE_ICON_MAP = exports.MESSAGE_ICON_MAP = {
|
|
|
41
36
|
warning: SVG_ICONS['alert-circle'],
|
|
42
37
|
success: SVG_ICONS['check-circle'],
|
|
43
38
|
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
|
|
49
39
|
};
|
|
@@ -57,18 +57,6 @@ 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
|
-
});
|
|
66
|
-
Object.defineProperty(exports, "MESSAGE_BLOCK_SIZES", {
|
|
67
|
-
enumerable: true,
|
|
68
|
-
get: function () {
|
|
69
|
-
return _sizes.MESSAGE_BLOCK_SIZES;
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
60
|
Object.defineProperty(exports, "MESSAGE_ICON_MAP", {
|
|
73
61
|
enumerable: true,
|
|
74
62
|
get: function () {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getSizes = exports.MESSAGE_SIZES = exports.
|
|
6
|
+
exports.getSizes = exports.MESSAGE_SIZES = exports.ICON_PIXEL_SIZES = exports.FULL_WIDTH_SIZES = exports.FEATURED_ICON_SIZES = exports.CLOSE_BUTTON_SVG_SIZES = exports.CLOSE_BUTTON_SIZES = void 0;
|
|
7
7
|
// 알림 컴포넌트 사이즈 관련 상수들
|
|
8
8
|
// FeaturedIcon 사이즈
|
|
9
9
|
const FEATURED_ICON_SIZES = exports.FEATURED_ICON_SIZES = {
|
|
@@ -39,11 +39,6 @@ const MESSAGE_SIZES = exports.MESSAGE_SIZES = {
|
|
|
39
39
|
ICON_PIXEL: '20',
|
|
40
40
|
CLOSE_BUTTON: '20'
|
|
41
41
|
};
|
|
42
|
-
// Message 알림 Block 변형 사이즈. 'sm' = 32px 원 / 16px 아이콘. 닫기 버튼은 default 와 같다.
|
|
43
|
-
const MESSAGE_BLOCK_SIZES = exports.MESSAGE_BLOCK_SIZES = {
|
|
44
|
-
FEATURED_ICON: 'sm',
|
|
45
|
-
ICON_PIXEL: '16'
|
|
46
|
-
};
|
|
47
42
|
// 사이즈 유틸리티 함수들
|
|
48
43
|
const getSizes = exports.getSizes = {
|
|
49
44
|
featuredIcon: isMobile => isMobile ? FEATURED_ICON_SIZES.MOBILE : FEATURED_ICON_SIZES.DESKTOP,
|
|
@@ -21,7 +21,6 @@ function buildMessageTemplate(params) {
|
|
|
21
21
|
const {
|
|
22
22
|
title,
|
|
23
23
|
supportingText,
|
|
24
|
-
supportTextLink,
|
|
25
24
|
color,
|
|
26
25
|
actions,
|
|
27
26
|
onClose,
|
|
@@ -35,7 +34,10 @@ function buildMessageTemplate(params) {
|
|
|
35
34
|
<div class="${_const.CLASS_NAMES.MESSAGE.CONTENT_WRAPPER}">
|
|
36
35
|
<div class="${_const.CLASS_NAMES.MESSAGE.TEXT_CONTAINER}">
|
|
37
36
|
<span class="${_const.CLASS_NAMES.MESSAGE.TITLE}">${title}</span>
|
|
38
|
-
${(0, _utils.renderSupportingText)(
|
|
37
|
+
${(0, _utils.renderSupportingText)({
|
|
38
|
+
supportingText,
|
|
39
|
+
className: _const.CLASS_NAMES.MESSAGE.SUPPORTING_TEXT
|
|
40
|
+
})}
|
|
39
41
|
</div>
|
|
40
42
|
</div>
|
|
41
43
|
${renderActionsContainer({
|
|
@@ -9,7 +9,7 @@ exports.buildClassName = buildClassName;
|
|
|
9
9
|
exports.createWrapperElement = createWrapperElement;
|
|
10
10
|
exports.isMobile = void 0;
|
|
11
11
|
exports.renderActions = renderActions;
|
|
12
|
-
exports.renderSupportingText =
|
|
12
|
+
exports.renderSupportingText = void 0;
|
|
13
13
|
exports.resolveActionHierarchy = resolveActionHierarchy;
|
|
14
14
|
exports.setupAutoClose = setupAutoClose;
|
|
15
15
|
var _breakpoint = require("../../../src/constant/breakpoint");
|
|
@@ -36,19 +36,26 @@ function buildClassName(baseClass, color, className) {
|
|
|
36
36
|
function escapeHtmlAttr(str) {
|
|
37
37
|
return str.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''');
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
/**
|
|
40
|
+
* 보조 텍스트 HTML을 만든다. `supportTextLink` 링크는 full-width 전용 클래스(`CLASS_NAMES.FULL_WIDTH.LINK`)로 렌더한다.
|
|
41
|
+
*/
|
|
42
|
+
const renderSupportingText = _ref => {
|
|
43
|
+
let {
|
|
44
|
+
supportingText,
|
|
45
|
+
className,
|
|
46
|
+
supportTextLink
|
|
47
|
+
} = _ref;
|
|
41
48
|
if (!supportingText) return '';
|
|
42
49
|
// 본문(supportingText) 자체는 이 함수의 호출 결과가 wrapper.innerHTML에
|
|
43
50
|
// 들어가기 전에 DOMPurify로 sanitize되므로 별도 이스케이프하지 않는다.
|
|
44
51
|
// 이렇게 해야 <br>, <strong> 등 서식용 태그가 그대로 동작한다.
|
|
45
52
|
if (supportTextLink && (0, _url.isSafeUrl)(supportTextLink)) {
|
|
46
53
|
const safeLink = escapeHtmlAttr(supportTextLink);
|
|
47
|
-
return `<a href="${safeLink}" class="${
|
|
54
|
+
return `<a href="${safeLink}" class="${_const.CLASS_NAMES.FULL_WIDTH.LINK}"><span class="${className}">${supportingText}</span></a>`;
|
|
48
55
|
}
|
|
49
56
|
// unsafe URL이거나 link가 없으면 링크 없이 텍스트만 렌더링
|
|
50
57
|
return `<span class="${className}">${supportingText}</span>`;
|
|
51
|
-
}
|
|
58
|
+
};
|
|
52
59
|
/**
|
|
53
60
|
* `supportTextLinkTarget`이 `'_blank'`이면 `renderSupportingText`가 만든 링크를 새 탭으로 연다.
|
|
54
61
|
*
|
|
@@ -56,6 +63,7 @@ function renderSupportingText(supportingText, className, supportTextLink) {
|
|
|
56
63
|
* DOMPurify 에 target 을 전역 허용하면 사용자 입력 HTML 의 `<a target>`까지 rel 없이 통과하기 때문이다.
|
|
57
64
|
* 런타임 입력이므로 `'_blank'`가 아닌 값은 전부 `'_self'`(속성 미부여)로 취급한다.
|
|
58
65
|
*/
|
|
66
|
+
exports.renderSupportingText = renderSupportingText;
|
|
59
67
|
function applySupportTextLinkTarget(root, textContainerClassName, linkClassName, target) {
|
|
60
68
|
if (target !== '_blank') return;
|
|
61
69
|
const link = root.querySelector(`.${textContainerClassName} > a.${linkClassName}`);
|
|
@@ -17,14 +17,9 @@ const DEFAULT_ICON_MAP = {
|
|
|
17
17
|
error: _uiAdminIcon.AlertTriangle,
|
|
18
18
|
warning: _uiAdminIcon.AlertCircle,
|
|
19
19
|
success: _uiAdminIcon.CheckCircle,
|
|
20
|
-
// 디자인 기준
|
|
20
|
+
// 디자인 기준 info 는 neutral 과 같은 핀이다.
|
|
21
21
|
info: _uiAdminIcon.Pin02
|
|
22
22
|
};
|
|
23
|
-
// block 의 info 는 InfoCircle 을 유지한다 (#536).
|
|
24
|
-
const BLOCK_ICON_MAP = {
|
|
25
|
-
...DEFAULT_ICON_MAP,
|
|
26
|
-
info: _uiAdminIcon.InfoCircle
|
|
27
|
-
};
|
|
28
23
|
const MessageNotification = exports.MessageNotification = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
29
24
|
let {
|
|
30
25
|
title,
|
|
@@ -38,13 +33,8 @@ const MessageNotification = exports.MessageNotification = /*#__PURE__*/(0, _reac
|
|
|
38
33
|
actions,
|
|
39
34
|
onHidePermanently,
|
|
40
35
|
hidePermanentlyLabel,
|
|
41
|
-
variant = 'default',
|
|
42
|
-
supportTextLink,
|
|
43
|
-
supportTextLinkTarget,
|
|
44
36
|
...rest
|
|
45
37
|
} = _ref;
|
|
46
|
-
const isBlock = variant === 'block';
|
|
47
|
-
const iconMap = isBlock ? BLOCK_ICON_MAP : DEFAULT_ICON_MAP;
|
|
48
38
|
// FeaturedIcon 에는 info 색이 없다. info 의 violet 톤은 message SCSS 가 덮어쓴다.
|
|
49
39
|
const featuredIconColor = color === 'info' ? 'neutral' : color;
|
|
50
40
|
// message 는 부모가 언마운트로 닫으므로 hideCloseButton 기본 autoClose 를 적용하지 않는다.
|
|
@@ -57,9 +47,7 @@ const MessageNotification = exports.MessageNotification = /*#__PURE__*/(0, _reac
|
|
|
57
47
|
}
|
|
58
48
|
return (0, _jsxRuntime.jsx)("div", {
|
|
59
49
|
ref: ref,
|
|
60
|
-
className: (0, _classnames.default)('ncua-message-notification', `ncua-message-notification--${color}`,
|
|
61
|
-
'ncua-message-notification--block': isBlock
|
|
62
|
-
}, className),
|
|
50
|
+
className: (0, _classnames.default)('ncua-message-notification', `ncua-message-notification--${color}`, className),
|
|
63
51
|
role: "alert",
|
|
64
52
|
...rest,
|
|
65
53
|
children: (0, _jsxRuntime.jsx)("div", {
|
|
@@ -69,11 +57,8 @@ const MessageNotification = exports.MessageNotification = /*#__PURE__*/(0, _reac
|
|
|
69
57
|
children: [(0, _jsxRuntime.jsx)(_MessageNotificationParts.MessageNotificationContent, {
|
|
70
58
|
title: title,
|
|
71
59
|
supportingText: supportingText,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
icon: Icon || iconMap[color],
|
|
75
|
-
iconColor: featuredIconColor,
|
|
76
|
-
iconSize: isBlock ? 'sm' : 'md'
|
|
60
|
+
icon: Icon || DEFAULT_ICON_MAP[color],
|
|
61
|
+
iconColor: featuredIconColor
|
|
77
62
|
}), (0, _jsxRuntime.jsx)(_MessageNotificationParts.MessageNotificationActions, {
|
|
78
63
|
actions: actions,
|
|
79
64
|
onClose: onClose,
|
|
@@ -7,31 +7,22 @@ exports.MessageNotificationContent = exports.MessageNotificationActions = void 0
|
|
|
7
7
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
8
|
var _uiAdminIcon = require("@ncds/ui-admin-icon");
|
|
9
9
|
var _notification = require("../../../../constant/notification");
|
|
10
|
-
var _url = require("../../../utils/url");
|
|
11
10
|
var _FeaturedIcon = require("../../image-and-icons/featured-icon/FeaturedIcon");
|
|
12
|
-
var _linkTarget = require("./linkTarget");
|
|
13
11
|
var _NotificationActionButtons = require("./NotificationActionButtons");
|
|
14
|
-
/** 아이콘 + 제목/서포팅 텍스트(
|
|
12
|
+
/** 아이콘 + 제목/서포팅 텍스트 영역. FeaturedIcon 은 md(40px 원 / 20px 아이콘) 고정. */
|
|
15
13
|
const MessageNotificationContent = _ref => {
|
|
16
14
|
let {
|
|
17
15
|
title,
|
|
18
16
|
supportingText,
|
|
19
|
-
supportTextLink,
|
|
20
|
-
supportTextLinkTarget,
|
|
21
17
|
icon,
|
|
22
|
-
iconColor
|
|
23
|
-
iconSize
|
|
18
|
+
iconColor
|
|
24
19
|
} = _ref;
|
|
25
20
|
const featuredIconProps = {
|
|
26
21
|
icon: icon || _uiAdminIcon.Pin02,
|
|
27
|
-
size:
|
|
22
|
+
size: 'md',
|
|
28
23
|
color: iconColor,
|
|
29
24
|
theme: 'light-circle'
|
|
30
25
|
};
|
|
31
|
-
const supportingTextNode = supportingText && (0, _jsxRuntime.jsx)("span", {
|
|
32
|
-
className: "ncua-message-notification__supporting-text",
|
|
33
|
-
children: supportingText
|
|
34
|
-
});
|
|
35
26
|
return (0, _jsxRuntime.jsxs)("div", {
|
|
36
27
|
className: "ncua-message-notification__content-wrapper",
|
|
37
28
|
children: [(0, _jsxRuntime.jsx)(_FeaturedIcon.FeaturedIcon, {
|
|
@@ -42,12 +33,10 @@ const MessageNotificationContent = _ref => {
|
|
|
42
33
|
children: [(0, _jsxRuntime.jsx)("span", {
|
|
43
34
|
className: "ncua-message-notification__title",
|
|
44
35
|
children: title
|
|
45
|
-
}),
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
children: supportingTextNode
|
|
50
|
-
}) : supportingTextNode]
|
|
36
|
+
}), supportingText && (0, _jsxRuntime.jsx)("span", {
|
|
37
|
+
className: "ncua-message-notification__supporting-text",
|
|
38
|
+
children: supportingText
|
|
39
|
+
})]
|
|
51
40
|
})]
|
|
52
41
|
});
|
|
53
42
|
};
|
|
@@ -20,9 +20,13 @@ const Notification = exports.Notification = /*#__PURE__*/(0, _react.forwardRef)(
|
|
|
20
20
|
width,
|
|
21
21
|
supportTextLink,
|
|
22
22
|
supportTextLinkTarget,
|
|
23
|
-
|
|
24
|
-
...rest
|
|
23
|
+
...props
|
|
25
24
|
} = _ref;
|
|
25
|
+
// #580 에서 제거된 message `variant` 가 런타임에 넘어와도 DOM 속성으로 새지 않게 어떤 type 에도 전달하지 않는다.
|
|
26
|
+
const {
|
|
27
|
+
variant: _variant,
|
|
28
|
+
...rest
|
|
29
|
+
} = props;
|
|
26
30
|
if (type === 'floating') {
|
|
27
31
|
return (0, _jsxRuntime.jsx)(_FloatingNotification.FloatingNotification, {
|
|
28
32
|
color: color,
|
|
@@ -42,9 +46,6 @@ const Notification = exports.Notification = /*#__PURE__*/(0, _react.forwardRef)(
|
|
|
42
46
|
if (type === 'message') {
|
|
43
47
|
return (0, _jsxRuntime.jsx)(_MessageNotification.MessageNotification, {
|
|
44
48
|
color: color,
|
|
45
|
-
variant: variant,
|
|
46
|
-
supportTextLink: supportTextLink,
|
|
47
|
-
supportTextLinkTarget: supportTextLinkTarget,
|
|
48
49
|
...rest,
|
|
49
50
|
ref: ref
|
|
50
51
|
});
|
|
@@ -159,7 +159,7 @@ function renderedIconPathD(container) {
|
|
|
159
159
|
});
|
|
160
160
|
(0, _vitest.describe)('MessageNotification (React) — color="info" (#568)', () => {
|
|
161
161
|
(0, _vitest.it)('R-01: color="info" 는 neutral 로 폴백하지 않고 --info 수식자로 렌더한다', () => {
|
|
162
|
-
// Given/When:
|
|
162
|
+
// Given/When: info 색상으로 렌더하면
|
|
163
163
|
const root = renderMessageNotification({
|
|
164
164
|
color: 'info'
|
|
165
165
|
}).querySelector(SELECTOR.ROOT);
|
|
@@ -168,7 +168,7 @@ function renderedIconPathD(container) {
|
|
|
168
168
|
(0, _vitest.expect)(root?.classList.contains('ncua-message-notification--neutral')).toBe(false);
|
|
169
169
|
});
|
|
170
170
|
(0, _vitest.it)('R-02: 기본 info 아이콘은 neutral 과 같은 Pin02 다', () => {
|
|
171
|
-
// Given/When:
|
|
171
|
+
// Given/When: info 색상으로 렌더하면
|
|
172
172
|
const container = renderMessageNotification({
|
|
173
173
|
color: 'info'
|
|
174
174
|
});
|
|
@@ -178,7 +178,7 @@ function renderedIconPathD(container) {
|
|
|
178
178
|
(0, _vitest.expect)(renderedIconPathD(container)).toBe(expected);
|
|
179
179
|
});
|
|
180
180
|
(0, _vitest.it)('R-03: info 의 FeaturedIcon 은 neutral·md 로 렌더한다 (violet 톤은 SCSS 가 덮는다)', () => {
|
|
181
|
-
// Given/When:
|
|
181
|
+
// Given/When: info 색상으로 렌더하면
|
|
182
182
|
const icon = renderMessageNotification({
|
|
183
183
|
color: 'info'
|
|
184
184
|
}).querySelector(SELECTOR.ICON);
|
|
@@ -186,14 +186,14 @@ function renderedIconPathD(container) {
|
|
|
186
186
|
(0, _vitest.expect)(icon?.classList.contains('ncua-featured-icon--neutral')).toBe(true);
|
|
187
187
|
(0, _vitest.expect)(icon?.classList.contains('ncua-featured-icon--md')).toBe(true);
|
|
188
188
|
});
|
|
189
|
-
(0, _vitest.it)('R-04: block
|
|
190
|
-
// Given/When:
|
|
189
|
+
(0, _vitest.it)('R-04: 런타임에 variant="block" 이 넘어와도 info 아이콘은 Pin02 다 (#580 Block 변형 제거)', () => {
|
|
190
|
+
// Given/When: 제거된 variant prop 을 런타임 입력으로 넘겨 info 색상으로 렌더하면
|
|
191
191
|
const container = renderMessageNotification({
|
|
192
192
|
variant: 'block',
|
|
193
193
|
color: 'info'
|
|
194
194
|
});
|
|
195
|
-
// Then: 아이콘 path 가
|
|
196
|
-
const expected = iconPathD(_uiAdminIcon.
|
|
195
|
+
// Then: 아이콘 path 가 Pin02 와 같다
|
|
196
|
+
const expected = iconPathD(_uiAdminIcon.Pin02);
|
|
197
197
|
(0, _vitest.expect)(expected).not.toBeNull();
|
|
198
198
|
(0, _vitest.expect)(renderedIconPathD(container)).toBe(expected);
|
|
199
199
|
});
|
|
@@ -75,6 +75,14 @@ const render = props => {
|
|
|
75
75
|
});
|
|
76
76
|
(0, _vitest.expect)(element?.hasAttribute('supporttextlink')).toBe(false);
|
|
77
77
|
});
|
|
78
|
+
_vitest.it.each(['floating', 'full-width', 'message'])('type=%s 에 제거된 variant="block" 을 주어도 DOM 속성으로 새지 않는다 (#580)', type => {
|
|
79
|
+
const element = render({
|
|
80
|
+
type,
|
|
81
|
+
variant: 'block'
|
|
82
|
+
});
|
|
83
|
+
(0, _vitest.expect)(element).not.toBeNull();
|
|
84
|
+
(0, _vitest.expect)(element?.hasAttribute('variant')).toBe(false);
|
|
85
|
+
});
|
|
78
86
|
(0, _vitest.it)('정의되지 않은 type 은 아무것도 렌더하지 않는다', () => {
|
|
79
87
|
const element = render({
|
|
80
88
|
type: 'banner'
|
|
@@ -5,7 +5,6 @@ var _client = require("react-dom/client");
|
|
|
5
5
|
var _testUtils = require("react-dom/test-utils");
|
|
6
6
|
var _vitest = require("vitest");
|
|
7
7
|
var _FullWidthNotification = require("../FullWidthNotification");
|
|
8
|
-
var _MessageNotification = require("../MessageNotification");
|
|
9
8
|
// @vitest-environment jsdom
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -30,12 +29,7 @@ function mount(element) {
|
|
|
30
29
|
});
|
|
31
30
|
return container;
|
|
32
31
|
}
|
|
33
|
-
const IMPLEMENTATIONS = [['
|
|
34
|
-
title: '공지',
|
|
35
|
-
variant: 'block',
|
|
36
|
-
supportingText: '자세히 보기',
|
|
37
|
-
supportTextLink
|
|
38
|
-
})), '.ncua-message-notification__supporting-text'], ['FullWidthNotification', supportTextLink => mount(/*#__PURE__*/(0, _react.createElement)(_FullWidthNotification.FullWidthNotification, {
|
|
32
|
+
const IMPLEMENTATIONS = [['FullWidthNotification', supportTextLink => mount(/*#__PURE__*/(0, _react.createElement)(_FullWidthNotification.FullWidthNotification, {
|
|
39
33
|
title: '공지',
|
|
40
34
|
supportingText: '자세히 보기',
|
|
41
35
|
supportTextLink
|