@ncds/ui-admin 1.8.25 → 1.8.26-alpha.1
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/FullWidthNotification.js +2 -0
- package/dist/cjs/assets/scripts/notification/MessageNotification.js +30 -23
- package/dist/cjs/assets/scripts/notification/const/classNames.js +3 -0
- package/dist/cjs/assets/scripts/notification/const/icons.js +11 -2
- package/dist/cjs/assets/scripts/notification/const/index.js +9 -4
- package/dist/cjs/assets/scripts/notification/const/sizes.js +6 -1
- package/dist/cjs/assets/scripts/notification/const/types.js +1 -10
- package/dist/cjs/assets/scripts/notification/messageTemplate.js +20 -8
- package/dist/cjs/assets/scripts/notification/utils.js +21 -17
- package/dist/cjs/constant/notification.js +15 -1
- package/dist/cjs/src/components/feedback-and-status/badge/Badge.js +1 -1
- package/dist/cjs/src/components/overlays/notification/FloatingNotification.js +4 -7
- package/dist/cjs/src/components/overlays/notification/FullWidthNotification.js +13 -8
- package/dist/cjs/src/components/overlays/notification/MessageNotification.js +20 -14
- package/dist/cjs/src/components/overlays/notification/MessageNotificationParts.js +22 -15
- package/dist/cjs/src/components/overlays/notification/Notification.js +6 -0
- package/dist/cjs/src/components/overlays/notification/NotificationActionButtons.js +27 -0
- package/dist/cjs/src/components/overlays/notification/__tests__/supportTextLink.test.js +58 -0
- package/dist/cjs/src/components/overlays/notification/linkTarget.js +18 -0
- package/dist/cjs/src/generated/scoped-css.js +1 -1
- package/dist/cjs/src/utils/index.js +11 -0
- package/dist/cjs/src/utils/url/__tests__/isSafeUrl.test.js +49 -0
- package/dist/cjs/src/utils/url/index.js +16 -0
- package/dist/cjs/src/utils/url/isSafeUrl.js +32 -0
- package/dist/esm/assets/scripts/notification/FullWidthNotification.js +3 -1
- package/dist/esm/assets/scripts/notification/MessageNotification.js +32 -25
- package/dist/esm/assets/scripts/notification/const/classNames.js +3 -0
- package/dist/esm/assets/scripts/notification/const/icons.js +10 -1
- package/dist/esm/assets/scripts/notification/const/index.js +2 -3
- package/dist/esm/assets/scripts/notification/const/sizes.js +5 -0
- package/dist/esm/assets/scripts/notification/const/types.js +1 -8
- package/dist/esm/assets/scripts/notification/messageTemplate.js +21 -9
- package/dist/esm/assets/scripts/notification/utils.js +19 -16
- package/dist/esm/constant/notification.js +14 -0
- package/dist/esm/src/components/feedback-and-status/badge/Badge.js +1 -1
- package/dist/esm/src/components/overlays/notification/FloatingNotification.js +4 -7
- package/dist/esm/src/components/overlays/notification/FullWidthNotification.js +13 -8
- package/dist/esm/src/components/overlays/notification/MessageNotification.js +21 -15
- package/dist/esm/src/components/overlays/notification/MessageNotificationParts.js +22 -15
- package/dist/esm/src/components/overlays/notification/Notification.js +6 -0
- package/dist/esm/src/components/overlays/notification/NotificationActionButtons.js +21 -0
- package/dist/esm/src/components/overlays/notification/__tests__/supportTextLink.test.js +55 -0
- package/dist/esm/src/components/overlays/notification/linkTarget.js +12 -0
- package/dist/esm/src/generated/scoped-css.js +1 -1
- package/dist/esm/src/utils/index.js +3 -1
- package/dist/esm/src/utils/url/__tests__/isSafeUrl.test.js +47 -0
- package/dist/esm/src/utils/url/index.js +1 -0
- package/dist/esm/src/utils/url/isSafeUrl.js +26 -0
- package/dist/temp/assets/scripts/notification/FullWidthNotification.js +3 -2
- package/dist/temp/assets/scripts/notification/MessageNotification.d.ts +2 -0
- package/dist/temp/assets/scripts/notification/MessageNotification.js +30 -25
- package/dist/temp/assets/scripts/notification/const/classNames.d.ts +3 -0
- package/dist/temp/assets/scripts/notification/const/classNames.js +3 -0
- package/dist/temp/assets/scripts/notification/const/icons.d.ts +6 -0
- package/dist/temp/assets/scripts/notification/const/icons.js +9 -0
- package/dist/temp/assets/scripts/notification/const/index.d.ts +3 -4
- package/dist/temp/assets/scripts/notification/const/index.js +2 -3
- package/dist/temp/assets/scripts/notification/const/sizes.d.ts +4 -0
- package/dist/temp/assets/scripts/notification/const/sizes.js +5 -0
- package/dist/temp/assets/scripts/notification/const/types.d.ts +28 -1
- package/dist/temp/assets/scripts/notification/const/types.js +1 -8
- package/dist/temp/assets/scripts/notification/messageTemplate.d.ts +5 -1
- package/dist/temp/assets/scripts/notification/messageTemplate.js +16 -11
- package/dist/temp/assets/scripts/notification/utils.d.ts +10 -3
- package/dist/temp/assets/scripts/notification/utils.js +21 -18
- package/dist/temp/constant/notification.d.ts +13 -0
- package/dist/temp/constant/notification.js +14 -0
- package/dist/temp/src/components/feedback-and-status/badge/Badge.d.ts +1 -1
- package/dist/temp/src/components/feedback-and-status/badge/Badge.js +1 -1
- package/dist/temp/src/components/overlays/notification/FloatingNotification.js +2 -2
- package/dist/temp/src/components/overlays/notification/FullWidthNotification.d.ts +6 -1
- package/dist/temp/src/components/overlays/notification/FullWidthNotification.js +7 -2
- package/dist/temp/src/components/overlays/notification/MessageNotification.d.ts +15 -1
- package/dist/temp/src/components/overlays/notification/MessageNotification.js +11 -12
- package/dist/temp/src/components/overlays/notification/MessageNotificationParts.d.ts +10 -5
- package/dist/temp/src/components/overlays/notification/MessageNotificationParts.js +9 -6
- package/dist/temp/src/components/overlays/notification/Notification.d.ts +23 -2
- package/dist/temp/src/components/overlays/notification/Notification.js +3 -3
- package/dist/temp/src/components/overlays/notification/NotificationActionButtons.d.ts +12 -0
- package/dist/temp/src/components/overlays/notification/NotificationActionButtons.js +9 -0
- package/dist/temp/src/components/overlays/notification/__tests__/supportTextLink.test.d.ts +1 -0
- package/dist/temp/src/components/overlays/notification/__tests__/supportTextLink.test.js +73 -0
- package/dist/temp/src/components/overlays/notification/linkTarget.d.ts +11 -0
- package/dist/temp/src/components/overlays/notification/linkTarget.js +9 -0
- package/dist/temp/src/generated/scoped-css.js +1 -1
- package/dist/temp/src/utils/index.d.ts +1 -0
- package/dist/temp/src/utils/index.js +2 -0
- package/dist/temp/src/utils/url/__tests__/isSafeUrl.test.d.ts +1 -0
- package/dist/temp/src/utils/url/__tests__/isSafeUrl.test.js +61 -0
- package/dist/temp/src/utils/url/index.d.ts +1 -0
- package/dist/temp/src/utils/url/index.js +1 -0
- package/dist/temp/src/utils/url/isSafeUrl.d.ts +8 -0
- package/dist/temp/src/utils/url/isSafeUrl.js +29 -0
- package/dist/types/assets/scripts/notification/MessageNotification.d.ts +2 -0
- package/dist/types/assets/scripts/notification/const/classNames.d.ts +3 -0
- package/dist/types/assets/scripts/notification/const/icons.d.ts +6 -0
- package/dist/types/assets/scripts/notification/const/index.d.ts +3 -4
- package/dist/types/assets/scripts/notification/const/sizes.d.ts +4 -0
- package/dist/types/assets/scripts/notification/const/types.d.ts +28 -1
- package/dist/types/assets/scripts/notification/messageTemplate.d.ts +5 -1
- package/dist/types/assets/scripts/notification/utils.d.ts +10 -3
- package/dist/types/constant/notification.d.ts +13 -0
- package/dist/types/src/components/feedback-and-status/badge/Badge.d.ts +1 -1
- package/dist/types/src/components/overlays/notification/FullWidthNotification.d.ts +6 -1
- package/dist/types/src/components/overlays/notification/MessageNotification.d.ts +15 -1
- package/dist/types/src/components/overlays/notification/MessageNotificationParts.d.ts +10 -5
- package/dist/types/src/components/overlays/notification/Notification.d.ts +23 -2
- package/dist/types/src/components/overlays/notification/NotificationActionButtons.d.ts +12 -0
- package/dist/types/src/components/overlays/notification/__tests__/supportTextLink.test.d.ts +1 -0
- package/dist/types/src/components/overlays/notification/linkTarget.d.ts +11 -0
- package/dist/types/src/utils/index.d.ts +1 -0
- package/dist/types/src/utils/url/__tests__/isSafeUrl.test.d.ts +1 -0
- package/dist/types/src/utils/url/index.d.ts +1 -0
- package/dist/types/src/utils/url/isSafeUrl.d.ts +8 -0
- package/dist/ui-admin/assets/styles/style.css +54 -34
- package/package.json +1 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { isSafeUrl } from '../isSafeUrl';
|
|
3
|
+
/**
|
|
4
|
+
* 알림 텍스트 링크(`supportTextLink`)의 href 허용 여부.
|
|
5
|
+
* React·Vanilla 가 이 함수 하나를 공유한다 (#538 리뷰 H2).
|
|
6
|
+
*
|
|
7
|
+
* 이 파일은 vitest 기본 환경(node)에서 돈다 — `window` 가 없는 SSR 상황 자체가 검증 대상이다.
|
|
8
|
+
*/
|
|
9
|
+
const SAFE = ['https://example.com/notice/1', 'http://example.com', 'HTTPS://EXAMPLE.COM', '/notice/1', 'notice/1', '../notice', '?page=2', '#section', ' https://example.com '];
|
|
10
|
+
const UNSAFE = ['javascript:alert(1)', 'JavaScript:alert(1)', ' JavaScript:alert(1)', '\tjavascript:alert(1)', 'java\nscript:alert(1)', 'data:text/html,<script>alert(1)</script>', 'DATA:text/html;base64,PHNjcmlwdD4=', 'vbscript:msgbox(1)', 'file:///etc/passwd', 'mailto:a@example.com', 'http://'];
|
|
11
|
+
describe('isSafeUrl — window 없음(SSR)', () => {
|
|
12
|
+
it('window 가 정의되지 않은 환경이다', () => {
|
|
13
|
+
expect(typeof window).toBe('undefined');
|
|
14
|
+
});
|
|
15
|
+
it.each(SAFE)('허용: %j', url => {
|
|
16
|
+
expect(isSafeUrl(url)).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
it.each(UNSAFE)('차단: %j', url => {
|
|
19
|
+
expect(isSafeUrl(url)).toBe(false);
|
|
20
|
+
});
|
|
21
|
+
it('빈 문자열은 차단한다', () => {
|
|
22
|
+
expect(isSafeUrl('')).toBe(false);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe('isSafeUrl — window 존재', () => {
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
vi.unstubAllGlobals();
|
|
28
|
+
});
|
|
29
|
+
it('현재 origin 기준으로 상대경로를 해석해 허용한다', () => {
|
|
30
|
+
vi.stubGlobal('window', {
|
|
31
|
+
location: {
|
|
32
|
+
origin: 'https://admin.example.com'
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
expect(isSafeUrl('/notice/1')).toBe(true);
|
|
36
|
+
expect(isSafeUrl('javascript:alert(1)')).toBe(false);
|
|
37
|
+
});
|
|
38
|
+
it('origin 이 "null"(about:blank·sandbox iframe)이어도 상대경로를 허용한다', () => {
|
|
39
|
+
vi.stubGlobal('window', {
|
|
40
|
+
location: {
|
|
41
|
+
origin: 'null'
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
expect(isSafeUrl('/notice/1')).toBe(true);
|
|
45
|
+
expect(isSafeUrl(' JavaScript:alert(1)')).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './isSafeUrl';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 상대경로 해석용 기본 origin. `window` 가 없거나(SSR) origin 이 불투명(`"null"` — about:blank,
|
|
3
|
+
* sandbox iframe)일 때 쓴다. 판정은 프로토콜만 보므로 실제 호스트와 무관하다.
|
|
4
|
+
*/
|
|
5
|
+
const FALLBACK_ORIGIN = 'http://localhost';
|
|
6
|
+
function resolveBaseOrigin() {
|
|
7
|
+
if (typeof window === 'undefined') return FALLBACK_ORIGIN;
|
|
8
|
+
const origin = window.location?.origin;
|
|
9
|
+
return origin && origin !== 'null' ? origin : FALLBACK_ORIGIN;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 링크 href 로 넣어도 안전한 URL 인지 판정한다. http/https 및 상대경로만 허용한다.
|
|
13
|
+
* javascript:, data:, file: 등 위험 프로토콜로 인한 XSS / 외부 페이로드 로딩을 차단.
|
|
14
|
+
*
|
|
15
|
+
* URL 파서가 앞뒤 공백·탭·개행 제거와 scheme 소문자화를 하므로 ` JavaScript:` 같은 우회도 막힌다.
|
|
16
|
+
* React(`MessageNotificationParts`·`FullWidthNotification`)와 Vanilla(`renderSupportingText`)가 공유한다.
|
|
17
|
+
*/
|
|
18
|
+
export function isSafeUrl(url) {
|
|
19
|
+
if (!url.trim()) return false;
|
|
20
|
+
try {
|
|
21
|
+
const parsed = new URL(url, resolveBaseOrigin());
|
|
22
|
+
return parsed.protocol === 'http:' || parsed.protocol === 'https:';
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HIDE_PERMANENTLY_LABEL } from '../../../constant/notification';
|
|
2
2
|
import { sanitizeHtml } from '../utils/sanitize';
|
|
3
3
|
import { CLASS_NAMES, FULL_WIDTH_ICON_MAP, FULL_WIDTH_SIZES, SVG_ICONS } from './const';
|
|
4
|
-
import { bindNotificationEvents, createWrapperElement, renderActions, renderSupportingText, setupAutoClose, } from './utils';
|
|
4
|
+
import { applySupportTextLinkTarget, bindNotificationEvents, createWrapperElement, renderActions, renderSupportingText, setupAutoClose, } from './utils';
|
|
5
5
|
export class FullWidthNotification {
|
|
6
6
|
constructor(options) {
|
|
7
7
|
this.options = {
|
|
@@ -17,7 +17,7 @@ export class FullWidthNotification {
|
|
|
17
17
|
this.setupAutoClose();
|
|
18
18
|
}
|
|
19
19
|
createElement() {
|
|
20
|
-
const { title, supportingText, color, className, actions, onClose, supportTextLink, onHidePermanently, hidePermanentlyLabel, } = this.options;
|
|
20
|
+
const { title, supportingText, color, className, actions, onClose, supportTextLink, supportTextLinkTarget, onHidePermanently, hidePermanentlyLabel, } = this.options;
|
|
21
21
|
const wrapper = createWrapperElement(CLASS_NAMES.FULL_WIDTH.BASE, color, className);
|
|
22
22
|
const iconHtml = FULL_WIDTH_ICON_MAP[color](FULL_WIDTH_SIZES.ICON);
|
|
23
23
|
wrapper.innerHTML = sanitizeHtml(this.buildTemplate({
|
|
@@ -30,6 +30,7 @@ export class FullWidthNotification {
|
|
|
30
30
|
onHidePermanently,
|
|
31
31
|
hidePermanentlyLabel,
|
|
32
32
|
}));
|
|
33
|
+
applySupportTextLinkTarget(wrapper, CLASS_NAMES.FULL_WIDTH.TEXT_CONTAINER, CLASS_NAMES.FULL_WIDTH.LINK, supportTextLinkTarget);
|
|
33
34
|
return wrapper;
|
|
34
35
|
}
|
|
35
36
|
buildTemplate(params) {
|
|
@@ -9,6 +9,8 @@ export declare class MessageNotification {
|
|
|
9
9
|
private featuredIcon?;
|
|
10
10
|
constructor(options: MessageNotificationOptions);
|
|
11
11
|
private createElement;
|
|
12
|
+
/** 색상별 FeaturedIcon. default 는 md(40/20), block 은 sm(32/16). */
|
|
13
|
+
private createFeaturedIcon;
|
|
12
14
|
private bindEvents;
|
|
13
15
|
private setupAutoClose;
|
|
14
16
|
getElement(): HTMLElement;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FeaturedIcon } from '../featuredIcon';
|
|
2
2
|
import { sanitizeHtml } from '../utils/sanitize';
|
|
3
|
-
import { CLASS_NAMES,
|
|
3
|
+
import { CLASS_NAMES, MESSAGE_BLOCK_SIZES, MESSAGE_ICON_MAP, MESSAGE_SIZES } from './const';
|
|
4
4
|
import { buildMessageTemplate } from './messageTemplate';
|
|
5
|
-
import { bindNotificationEvents, createWrapperElement, setupAutoClose } from './utils';
|
|
5
|
+
import { applySupportTextLinkTarget, bindNotificationEvents, createWrapperElement, setupAutoClose } from './utils';
|
|
6
6
|
export class MessageNotification {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
this.options = {
|
|
@@ -18,37 +18,24 @@ export class MessageNotification {
|
|
|
18
18
|
this.setupAutoClose();
|
|
19
19
|
}
|
|
20
20
|
createElement() {
|
|
21
|
-
const { title, supportingText, color, className, actions, onClose, onHidePermanently, hidePermanentlyLabel } = this.options;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const iconFunction = FLOATING_ICON_MAP[actualColor];
|
|
29
|
-
// FeaturedIcon 생성
|
|
30
|
-
let featuredIconElement = null;
|
|
31
|
-
if (iconFunction) {
|
|
32
|
-
const iconSvg = iconFunction(MESSAGE_SIZES.ICON_PIXEL);
|
|
33
|
-
this.featuredIcon = FeaturedIcon.create({
|
|
34
|
-
svgString: iconSvg,
|
|
35
|
-
theme: 'light-circle',
|
|
36
|
-
color: actualColor,
|
|
37
|
-
size: MESSAGE_SIZES.FEATURED_ICON,
|
|
38
|
-
// React 구현과 동일하게 `__icon`(flex-shrink: 0)을 부여한다.
|
|
39
|
-
// 누락 시 긴 타이틀에서 아이콘이 찌그러진다.
|
|
40
|
-
className: CLASS_NAMES.MESSAGE.ICON,
|
|
41
|
-
});
|
|
42
|
-
featuredIconElement = this.featuredIcon.getElement();
|
|
43
|
-
}
|
|
21
|
+
const { title, supportingText, color, className, actions, onClose, onHidePermanently, hidePermanentlyLabel, variant, supportTextLink, supportTextLinkTarget, } = this.options;
|
|
22
|
+
const isBlock = variant === 'block';
|
|
23
|
+
// default 는 neutral, error, warning, success 4가지 색상만 지원 — info 는 block 에서만 유지한다.
|
|
24
|
+
const actualColor = !isBlock && color === 'info' ? 'neutral' : color;
|
|
25
|
+
const wrapperClassName = [isBlock ? CLASS_NAMES.MESSAGE.BLOCK : '', className].filter(Boolean).join(' ');
|
|
26
|
+
const wrapper = createWrapperElement(CLASS_NAMES.MESSAGE.BASE, actualColor, wrapperClassName);
|
|
27
|
+
const featuredIconElement = this.createFeaturedIcon(actualColor, isBlock);
|
|
44
28
|
wrapper.innerHTML = sanitizeHtml(buildMessageTemplate({
|
|
45
29
|
title,
|
|
46
30
|
supportingText,
|
|
31
|
+
supportTextLink: isBlock ? supportTextLink : undefined,
|
|
32
|
+
color: actualColor,
|
|
47
33
|
actions,
|
|
48
34
|
onClose,
|
|
49
35
|
onHidePermanently,
|
|
50
36
|
hidePermanentlyLabel,
|
|
51
37
|
}));
|
|
38
|
+
applySupportTextLinkTarget(wrapper, CLASS_NAMES.MESSAGE.TEXT_CONTAINER, CLASS_NAMES.MESSAGE.LINK, supportTextLinkTarget);
|
|
52
39
|
// FeaturedIcon을 content-wrapper에 추가
|
|
53
40
|
if (featuredIconElement) {
|
|
54
41
|
const contentWrapper = wrapper.querySelector(`.${CLASS_NAMES.MESSAGE.CONTENT_WRAPPER}`);
|
|
@@ -58,6 +45,24 @@ export class MessageNotification {
|
|
|
58
45
|
}
|
|
59
46
|
return wrapper;
|
|
60
47
|
}
|
|
48
|
+
/** 색상별 FeaturedIcon. default 는 md(40/20), block 은 sm(32/16). */
|
|
49
|
+
createFeaturedIcon(color, isBlock) {
|
|
50
|
+
const iconFunction = MESSAGE_ICON_MAP[color];
|
|
51
|
+
if (!iconFunction)
|
|
52
|
+
return null;
|
|
53
|
+
const sizes = isBlock ? MESSAGE_BLOCK_SIZES : MESSAGE_SIZES;
|
|
54
|
+
this.featuredIcon = FeaturedIcon.create({
|
|
55
|
+
svgString: iconFunction(sizes.ICON_PIXEL),
|
|
56
|
+
theme: 'light-circle',
|
|
57
|
+
// FeaturedIcon 에는 info 색이 없다. block+info 의 violet 톤은 message SCSS 가 덮어쓴다.
|
|
58
|
+
color: (color === 'info' ? 'neutral' : color),
|
|
59
|
+
size: sizes.FEATURED_ICON,
|
|
60
|
+
// React 구현과 동일하게 `__icon`(flex-shrink: 0)을 부여한다.
|
|
61
|
+
// 누락 시 긴 타이틀에서 아이콘이 찌그러진다.
|
|
62
|
+
className: CLASS_NAMES.MESSAGE.ICON,
|
|
63
|
+
});
|
|
64
|
+
return this.featuredIcon.getElement();
|
|
65
|
+
}
|
|
61
66
|
bindEvents() {
|
|
62
67
|
bindNotificationEvents(this.element, this.options.actions, this.options.onClose, () => this.remove());
|
|
63
68
|
// 다시보지 않기 버튼 이벤트 바인딩
|
|
@@ -8,6 +8,7 @@ export declare const CLASS_NAMES: {
|
|
|
8
8
|
readonly TEXT_CONTAINER: "ncua-full-width-notification__text-container";
|
|
9
9
|
readonly TITLE: "ncua-full-width-notification__title";
|
|
10
10
|
readonly SUPPORTING_TEXT: "ncua-full-width-notification__supporting-text";
|
|
11
|
+
readonly LINK: "ncua-full-width-notification__link";
|
|
11
12
|
readonly ACTIONS_CONTAINER: "ncua-full-width-notification__actions-container";
|
|
12
13
|
readonly ACTIONS: "ncua-full-width-notification__actions";
|
|
13
14
|
readonly CLOSE_BUTTON: "ncua-full-width-notification__close-button";
|
|
@@ -25,6 +26,7 @@ export declare const CLASS_NAMES: {
|
|
|
25
26
|
};
|
|
26
27
|
readonly MESSAGE: {
|
|
27
28
|
readonly BASE: "ncua-message-notification";
|
|
29
|
+
readonly BLOCK: "ncua-message-notification--block";
|
|
28
30
|
readonly CONTAINER: "ncua-message-notification__container";
|
|
29
31
|
readonly CONTENT: "ncua-message-notification__content";
|
|
30
32
|
readonly CONTENT_WRAPPER: "ncua-message-notification__content-wrapper";
|
|
@@ -32,6 +34,7 @@ export declare const CLASS_NAMES: {
|
|
|
32
34
|
readonly TEXT_CONTAINER: "ncua-message-notification__text-container";
|
|
33
35
|
readonly TITLE: "ncua-message-notification__title";
|
|
34
36
|
readonly SUPPORTING_TEXT: "ncua-message-notification__supporting-text";
|
|
37
|
+
readonly LINK: "ncua-message-notification__link";
|
|
35
38
|
readonly ACTIONS_CONTAINER: "ncua-message-notification__actions-container";
|
|
36
39
|
readonly ACTIONS: "ncua-message-notification__actions";
|
|
37
40
|
readonly FOOTER_CONTAINER: "ncua-message-notification__footer-container";
|
|
@@ -9,6 +9,7 @@ export const CLASS_NAMES = {
|
|
|
9
9
|
TEXT_CONTAINER: 'ncua-full-width-notification__text-container',
|
|
10
10
|
TITLE: 'ncua-full-width-notification__title',
|
|
11
11
|
SUPPORTING_TEXT: 'ncua-full-width-notification__supporting-text',
|
|
12
|
+
LINK: 'ncua-full-width-notification__link',
|
|
12
13
|
ACTIONS_CONTAINER: 'ncua-full-width-notification__actions-container',
|
|
13
14
|
ACTIONS: 'ncua-full-width-notification__actions',
|
|
14
15
|
CLOSE_BUTTON: 'ncua-full-width-notification__close-button',
|
|
@@ -26,6 +27,7 @@ export const CLASS_NAMES = {
|
|
|
26
27
|
},
|
|
27
28
|
MESSAGE: {
|
|
28
29
|
BASE: 'ncua-message-notification',
|
|
30
|
+
BLOCK: 'ncua-message-notification--block',
|
|
29
31
|
CONTAINER: 'ncua-message-notification__container',
|
|
30
32
|
CONTENT: 'ncua-message-notification__content',
|
|
31
33
|
CONTENT_WRAPPER: 'ncua-message-notification__content-wrapper',
|
|
@@ -33,6 +35,7 @@ export const CLASS_NAMES = {
|
|
|
33
35
|
TEXT_CONTAINER: 'ncua-message-notification__text-container',
|
|
34
36
|
TITLE: 'ncua-message-notification__title',
|
|
35
37
|
SUPPORTING_TEXT: 'ncua-message-notification__supporting-text',
|
|
38
|
+
LINK: 'ncua-message-notification__link',
|
|
36
39
|
ACTIONS_CONTAINER: 'ncua-message-notification__actions-container',
|
|
37
40
|
ACTIONS: 'ncua-message-notification__actions',
|
|
38
41
|
// 다시 보지 않기 + 닫기 그룹 전용 래퍼. ACTIONS_CONTAINER를 재사용하면
|
|
@@ -23,3 +23,9 @@ export declare const ICON_MAP: {
|
|
|
23
23
|
readonly success: (size: string) => string;
|
|
24
24
|
readonly info: (size: string) => string;
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* message 타입 아이콘. floating 과 같은 4색에 block 변형 전용 info 를 더한다.
|
|
28
|
+
* `SVG_ICONS['info-circle']`은 full-width 전용 class·color 가 박혀 있어 쓰지 않는다
|
|
29
|
+
* (`.ncua-full-width-notification__icon`은 모바일에서 숨겨진다).
|
|
30
|
+
*/
|
|
31
|
+
export declare const MESSAGE_ICON_MAP: Partial<Record<NotificationColor, (size: string) => string>>;
|
|
@@ -23,3 +23,12 @@ export const FULL_WIDTH_ICON_MAP = {
|
|
|
23
23
|
info: SVG_ICONS['info-circle'],
|
|
24
24
|
};
|
|
25
25
|
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
|
+
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>`,
|
|
34
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { CLASS_NAMES } from './classNames';
|
|
2
|
-
export { FLOATING_ICON_MAP, FULL_WIDTH_ICON_MAP, ICON_MAP, SVG_ICONS } from './icons';
|
|
3
|
-
export { CLOSE_BUTTON_SIZES, CLOSE_BUTTON_SVG_SIZES, FEATURED_ICON_SIZES, FULL_WIDTH_SIZES, getSizes, ICON_PIXEL_SIZES, MESSAGE_SIZES, } from './sizes';
|
|
4
|
-
export type { BaseNotificationOptions, LegacyNotificationHierarchy, NotificationAction, NotificationActionButtonSize, NotificationColor, NotificationHierarchy, } from './types';
|
|
5
|
-
export { MESSAGE_CLOSE_ICON_COLORS } from './types';
|
|
2
|
+
export { FLOATING_ICON_MAP, FULL_WIDTH_ICON_MAP, ICON_MAP, MESSAGE_ICON_MAP, SVG_ICONS } from './icons';
|
|
3
|
+
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';
|
|
4
|
+
export type { BaseNotificationOptions, LegacyNotificationHierarchy, NotificationAction, NotificationActionButtonSize, NotificationColor, NotificationHierarchy, NotificationLinkTarget, NotificationVariant, } from './types';
|
|
@@ -1,5 +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, SVG_ICONS } from './icons';
|
|
4
|
-
export { CLOSE_BUTTON_SIZES, CLOSE_BUTTON_SVG_SIZES, FEATURED_ICON_SIZES, FULL_WIDTH_SIZES, getSizes, ICON_PIXEL_SIZES, MESSAGE_SIZES, } from './sizes';
|
|
5
|
-
export { MESSAGE_CLOSE_ICON_COLORS } from './types';
|
|
3
|
+
export { FLOATING_ICON_MAP, FULL_WIDTH_ICON_MAP, ICON_MAP, MESSAGE_ICON_MAP, SVG_ICONS } from './icons';
|
|
4
|
+
export { CLOSE_BUTTON_SIZES, CLOSE_BUTTON_SVG_SIZES, FEATURED_ICON_SIZES, FULL_WIDTH_SIZES, getSizes, ICON_PIXEL_SIZES, MESSAGE_BLOCK_SIZES, MESSAGE_SIZES, } from './sizes';
|
|
@@ -24,6 +24,10 @@ export declare const MESSAGE_SIZES: {
|
|
|
24
24
|
readonly ICON_PIXEL: "20";
|
|
25
25
|
readonly CLOSE_BUTTON: "20";
|
|
26
26
|
};
|
|
27
|
+
export declare const MESSAGE_BLOCK_SIZES: {
|
|
28
|
+
readonly FEATURED_ICON: "sm";
|
|
29
|
+
readonly ICON_PIXEL: "16";
|
|
30
|
+
};
|
|
27
31
|
export declare const getSizes: {
|
|
28
32
|
readonly featuredIcon: (isMobile: boolean) => "sm" | "md";
|
|
29
33
|
readonly iconPixel: (isMobile: boolean) => "20" | "16";
|
|
@@ -33,6 +33,11 @@ export const MESSAGE_SIZES = {
|
|
|
33
33
|
ICON_PIXEL: '20',
|
|
34
34
|
CLOSE_BUTTON: '20',
|
|
35
35
|
};
|
|
36
|
+
// Message 알림 Block 변형 사이즈. 'sm' = 32px 원 / 16px 아이콘. 닫기 버튼은 default 와 같다.
|
|
37
|
+
export const MESSAGE_BLOCK_SIZES = {
|
|
38
|
+
FEATURED_ICON: 'sm',
|
|
39
|
+
ICON_PIXEL: '16',
|
|
40
|
+
};
|
|
36
41
|
// 사이즈 유틸리티 함수들
|
|
37
42
|
export const getSizes = {
|
|
38
43
|
featuredIcon: (isMobile) => (isMobile ? FEATURED_ICON_SIZES.MOBILE : FEATURED_ICON_SIZES.DESKTOP),
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
export type NotificationColor = 'neutral' | 'error' | 'warning' | 'success' | 'info';
|
|
2
|
+
/**
|
|
3
|
+
* message 타입의 표시 변형. React `NotificationVariant`와 같은 어휘다.
|
|
4
|
+
* - `'default'`: 기존 message
|
|
5
|
+
* - `'block'`: 서브 페이지 공지용 (흰 배경, FeaturedIcon sm, 제목 + 텍스트 링크 1행, info 유지)
|
|
6
|
+
*/
|
|
7
|
+
export type NotificationVariant = 'default' | 'block';
|
|
8
|
+
/**
|
|
9
|
+
* 텍스트 링크(`supportTextLink`)를 여는 대상. React `NotificationLinkTarget`과 같은 어휘다.
|
|
10
|
+
* - `'_self'`: 같은 탭 (target·rel 미부여)
|
|
11
|
+
* - `'_blank'`: 새 탭 (`target="_blank"` + `rel="noopener noreferrer"`)
|
|
12
|
+
*/
|
|
13
|
+
export type NotificationLinkTarget = '_self' | '_blank';
|
|
2
14
|
/**
|
|
3
15
|
* 알림 액션 버튼(`ncua-btn`)의 색상 수식자.
|
|
4
16
|
* React `NotificationAction.hierarchy`와 동일한 어휘를 쓴다 — `ButtonTheme`의 부분집합이다.
|
|
@@ -31,7 +43,23 @@ export interface BaseNotificationOptions {
|
|
|
31
43
|
className?: string;
|
|
32
44
|
actions?: NotificationAction[];
|
|
33
45
|
autoClose?: number;
|
|
46
|
+
/**
|
|
47
|
+
* supportingText에 대한 링크 URL. full-width 타입, message 타입의 `variant: 'block'`에서 사용 가능.
|
|
48
|
+
* http/https 만 허용되며 그 외 프로토콜은 링크 없이 텍스트만 렌더된다.
|
|
49
|
+
*/
|
|
34
50
|
supportTextLink?: string;
|
|
51
|
+
/**
|
|
52
|
+
* 텍스트 링크를 여는 대상. `supportTextLink`가 렌더될 때만 동작한다.
|
|
53
|
+
* `'_blank'`이면 새 탭으로 열고 `rel="noopener noreferrer"`를 함께 붙인다.
|
|
54
|
+
* `'_blank'`가 아닌 값은 모두 `'_self'`(같은 탭)로 취급한다.
|
|
55
|
+
* @default '_self'
|
|
56
|
+
*/
|
|
57
|
+
supportTextLinkTarget?: NotificationLinkTarget;
|
|
58
|
+
/**
|
|
59
|
+
* message 타입의 표시 변형. message 타입에서만 동작한다.
|
|
60
|
+
* @default 'default'
|
|
61
|
+
*/
|
|
62
|
+
variant?: NotificationVariant;
|
|
35
63
|
onHidePermanently?: () => void;
|
|
36
64
|
/**
|
|
37
65
|
* 다시보지 않기 버튼의 라벨. full-width, message 타입에서 사용 가능하며
|
|
@@ -44,4 +72,3 @@ export interface BaseNotificationOptions {
|
|
|
44
72
|
*/
|
|
45
73
|
hidePermanentlyLabel?: string;
|
|
46
74
|
}
|
|
47
|
-
export declare const MESSAGE_CLOSE_ICON_COLORS: Record<NotificationColor, string>;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import type { NotificationAction } from './const';
|
|
1
|
+
import type { NotificationAction, NotificationColor } from './const';
|
|
2
2
|
export interface MessageTemplateParams {
|
|
3
3
|
title: string;
|
|
4
4
|
supportingText?: string;
|
|
5
|
+
/** 지정 시 `supportingText`를 텍스트 링크로 렌더한다 (block 변형 전용, http/https 만 허용). */
|
|
6
|
+
supportTextLink?: string;
|
|
7
|
+
/** 닫기 아이콘 색 결정용. 미지정 시 neutral. */
|
|
8
|
+
color?: NotificationColor;
|
|
5
9
|
actions?: NotificationAction[];
|
|
6
10
|
onClose?: () => void;
|
|
7
11
|
onHidePermanently?: () => void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { HIDE_PERMANENTLY_LABEL } from '../../../constant/notification';
|
|
1
|
+
import { HIDE_PERMANENTLY_LABEL, MESSAGE_CLOSE_ICON_COLOR } from '../../../constant/notification';
|
|
2
2
|
import { CLASS_NAMES, MESSAGE_SIZES, SVG_ICONS } from './const';
|
|
3
3
|
import { renderActions, renderSupportingText } from './utils';
|
|
4
4
|
/**
|
|
5
5
|
* message 타입 액션 버튼 사이즈. TO-BE 규격 28px이며 React `<Button size="xs">`와 같다.
|
|
6
|
-
*
|
|
6
|
+
* `renderActions` 기본값도 'xs'(#535)지만 message 규격을 명시적으로 고정해 둔다.
|
|
7
7
|
*/
|
|
8
8
|
const ACTION_BUTTON_SIZE = 'xs';
|
|
9
9
|
/**
|
|
@@ -12,17 +12,17 @@ const ACTION_BUTTON_SIZE = 'xs';
|
|
|
12
12
|
* 동일한 클래스 트리를 산출해야 한다 — SCSS 한 벌을 두 구현이 공유한다.
|
|
13
13
|
*/
|
|
14
14
|
export function buildMessageTemplate(params) {
|
|
15
|
-
const { title, supportingText, actions, onClose, onHidePermanently, hidePermanentlyLabel } = params;
|
|
15
|
+
const { title, supportingText, supportTextLink, color, actions, onClose, onHidePermanently, hidePermanentlyLabel } = params;
|
|
16
16
|
return `
|
|
17
17
|
<div class="${CLASS_NAMES.MESSAGE.CONTAINER}">
|
|
18
18
|
<div class="${CLASS_NAMES.MESSAGE.CONTENT}">
|
|
19
19
|
<div class="${CLASS_NAMES.MESSAGE.CONTENT_WRAPPER}">
|
|
20
20
|
<div class="${CLASS_NAMES.MESSAGE.TEXT_CONTAINER}">
|
|
21
21
|
<span class="${CLASS_NAMES.MESSAGE.TITLE}">${title}</span>
|
|
22
|
-
${renderSupportingText(supportingText, CLASS_NAMES.MESSAGE.SUPPORTING_TEXT)}
|
|
22
|
+
${renderSupportingText(supportingText, CLASS_NAMES.MESSAGE.SUPPORTING_TEXT, supportTextLink, CLASS_NAMES.MESSAGE.LINK)}
|
|
23
23
|
</div>
|
|
24
24
|
</div>
|
|
25
|
-
${renderActionsContainer({ actions, onClose, onHidePermanently, hidePermanentlyLabel })}
|
|
25
|
+
${renderActionsContainer({ actions, onClose, onHidePermanently, hidePermanentlyLabel, color })}
|
|
26
26
|
</div>
|
|
27
27
|
</div>
|
|
28
28
|
`;
|
|
@@ -33,22 +33,22 @@ export function buildMessageTemplate(params) {
|
|
|
33
33
|
* 표시할 요소가 하나도 없으면 빈 컨테이너를 남기지 않는다.
|
|
34
34
|
*/
|
|
35
35
|
function renderActionsContainer(params) {
|
|
36
|
-
const { actions, onClose, onHidePermanently, hidePermanentlyLabel } = params;
|
|
36
|
+
const { actions, onClose, onHidePermanently, hidePermanentlyLabel, color } = params;
|
|
37
37
|
const actionsHtml = renderActions(actions ?? [], CLASS_NAMES.MESSAGE.ACTIONS, ACTION_BUTTON_SIZE);
|
|
38
|
-
const footerHtml = renderFooterContainer({ onClose, onHidePermanently, hidePermanentlyLabel });
|
|
38
|
+
const footerHtml = renderFooterContainer({ onClose, onHidePermanently, hidePermanentlyLabel, color });
|
|
39
39
|
if (!actionsHtml && !footerHtml)
|
|
40
40
|
return '';
|
|
41
41
|
return `<div class="${CLASS_NAMES.MESSAGE.ACTIONS_CONTAINER}">${actionsHtml}${footerHtml}</div>`;
|
|
42
42
|
}
|
|
43
43
|
/** 다시 보지 않기 + 닫기 그룹. 전용 래퍼를 쓰는 이유는 `CLASS_NAMES.MESSAGE.FOOTER_CONTAINER` 참조. */
|
|
44
44
|
function renderFooterContainer(params) {
|
|
45
|
-
const { onClose, onHidePermanently, hidePermanentlyLabel } = params;
|
|
45
|
+
const { onClose, onHidePermanently, hidePermanentlyLabel, color } = params;
|
|
46
46
|
if (!onHidePermanently && !onClose)
|
|
47
47
|
return '';
|
|
48
48
|
return `
|
|
49
49
|
<div class="${CLASS_NAMES.MESSAGE.FOOTER_CONTAINER}">
|
|
50
50
|
${renderHidePermanentlyButton(onHidePermanently, hidePermanentlyLabel)}
|
|
51
|
-
${renderCloseButton(onClose)}
|
|
51
|
+
${renderCloseButton(onClose, color)}
|
|
52
52
|
</div>
|
|
53
53
|
`;
|
|
54
54
|
}
|
|
@@ -68,12 +68,17 @@ function renderHidePermanentlyButton(onHidePermanently, hidePermanentlyLabel) {
|
|
|
68
68
|
</button>
|
|
69
69
|
`;
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
/**
|
|
72
|
+
* 닫기(X) 버튼. 아이콘 색은 React `<XClose color>`와 같이 svg 의 `color` 속성으로 주고
|
|
73
|
+
* path 는 `stroke="currentColor"`로 상속받는다 — 두 구현이 같은 마크업을 낸다.
|
|
74
|
+
*/
|
|
75
|
+
function renderCloseButton(onClose, color = 'neutral') {
|
|
72
76
|
if (!onClose)
|
|
73
77
|
return '';
|
|
78
|
+
const iconColor = MESSAGE_CLOSE_ICON_COLOR[color];
|
|
74
79
|
return `
|
|
75
80
|
<button type="button" class="${CLASS_NAMES.MESSAGE.CLOSE_BUTTON}" aria-label="알림 닫기">
|
|
76
|
-
${SVG_ICONS['x-close'](MESSAGE_SIZES.CLOSE_BUTTON).replace('
|
|
81
|
+
${SVG_ICONS['x-close'](MESSAGE_SIZES.CLOSE_BUTTON).replace('<svg ', `<svg color="${iconColor}" `)}
|
|
77
82
|
</button>
|
|
78
83
|
`;
|
|
79
84
|
}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import type { LegacyNotificationHierarchy, NotificationAction, NotificationActionButtonSize, NotificationColor, NotificationHierarchy } from './const';
|
|
2
2
|
export declare function createWrapperElement(baseClass: string, color: NotificationColor, className?: string): HTMLElement;
|
|
3
3
|
export declare function buildClassName(baseClass: string, color: NotificationColor, className?: string): string;
|
|
4
|
-
export declare function renderSupportingText(supportingText?: string, className?: string, supportTextLink?: string): string;
|
|
4
|
+
export declare function renderSupportingText(supportingText?: string, className?: string, supportTextLink?: string, linkClassName?: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* `supportTextLinkTarget`이 `'_blank'`이면 `renderSupportingText`가 만든 링크를 새 탭으로 연다.
|
|
7
|
+
*
|
|
8
|
+
* target 은 sanitize **이후** 우리가 만든 링크(텍스트 컨테이너의 직계 `<a>`)에만 지정한다.
|
|
9
|
+
* DOMPurify 에 target 을 전역 허용하면 사용자 입력 HTML 의 `<a target>`까지 rel 없이 통과하기 때문이다.
|
|
10
|
+
* 런타임 입력이므로 `'_blank'`가 아닌 값은 전부 `'_self'`(속성 미부여)로 취급한다.
|
|
11
|
+
*/
|
|
12
|
+
export declare function applySupportTextLinkTarget(root: HTMLElement, textContainerClassName: string, linkClassName: string, target: unknown): void;
|
|
5
13
|
/**
|
|
6
14
|
* 액션 버튼의 색상 수식자를 현행 어휘로 정규화한다.
|
|
7
15
|
*
|
|
@@ -16,8 +24,7 @@ export declare function resolveActionHierarchy(hierarchy?: NotificationHierarchy
|
|
|
16
24
|
/**
|
|
17
25
|
* 액션 버튼 그룹 HTML을 만든다.
|
|
18
26
|
*
|
|
19
|
-
* `size` 기본값 '
|
|
20
|
-
* message 타입만 TO-BE 규격(28px)에 맞춰 'xs'를 넘긴다 — React `<Button size="xs">`와 동일.
|
|
27
|
+
* `size` 기본값 'xs'는 디자인 기준(#535 — 모든 type 액션 버튼 xs)이며 React `<Button size="xs">`와 같다.
|
|
21
28
|
*/
|
|
22
29
|
export declare function renderActions(actions: NotificationAction[], wrapperClass: string, size?: NotificationActionButtonSize): string;
|
|
23
30
|
export declare function bindNotificationEvents(element: HTMLElement, actions: NotificationAction[], onClose?: () => void, onRemove?: () => void): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BREAKPOINT } from '../../../src/constant/breakpoint';
|
|
2
|
+
import { isSafeUrl } from '../../../src/utils/url';
|
|
2
3
|
import { CLASS_NAMES } from './const';
|
|
3
4
|
// 공통 유틸리티 함수들
|
|
4
5
|
export function createWrapperElement(baseClass, color, className) {
|
|
@@ -14,19 +15,6 @@ export function buildClassName(baseClass, color, className) {
|
|
|
14
15
|
}
|
|
15
16
|
return classes.join(' ');
|
|
16
17
|
}
|
|
17
|
-
/**
|
|
18
|
-
* http/https 프로토콜만 허용한다.
|
|
19
|
-
* javascript:, data:, file: 등 위험 프로토콜로 인한 XSS / 외부 페이로드 로딩을 차단.
|
|
20
|
-
*/
|
|
21
|
-
function isSafeUrl(url) {
|
|
22
|
-
try {
|
|
23
|
-
const parsed = new URL(url, window.location.origin);
|
|
24
|
-
return parsed.protocol === 'http:' || parsed.protocol === 'https:';
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
18
|
/**
|
|
31
19
|
* HTML 속성 값에 안전하게 삽입하기 위한 최소 이스케이프.
|
|
32
20
|
* 본문(body)이 아닌 속성 컨텍스트에서의 따옴표 탈출(`" onclick="..."`)을 방지.
|
|
@@ -34,7 +22,7 @@ function isSafeUrl(url) {
|
|
|
34
22
|
function escapeHtmlAttr(str) {
|
|
35
23
|
return str.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''');
|
|
36
24
|
}
|
|
37
|
-
export function renderSupportingText(supportingText, className, supportTextLink) {
|
|
25
|
+
export function renderSupportingText(supportingText, className, supportTextLink, linkClassName = CLASS_NAMES.FULL_WIDTH.LINK) {
|
|
38
26
|
if (!supportingText)
|
|
39
27
|
return '';
|
|
40
28
|
// 본문(supportingText) 자체는 이 함수의 호출 결과가 wrapper.innerHTML에
|
|
@@ -42,11 +30,27 @@ export function renderSupportingText(supportingText, className, supportTextLink)
|
|
|
42
30
|
// 이렇게 해야 <br>, <strong> 등 서식용 태그가 그대로 동작한다.
|
|
43
31
|
if (supportTextLink && isSafeUrl(supportTextLink)) {
|
|
44
32
|
const safeLink = escapeHtmlAttr(supportTextLink);
|
|
45
|
-
return `<a href="${safeLink}" class="
|
|
33
|
+
return `<a href="${safeLink}" class="${linkClassName}"><span class="${className}">${supportingText}</span></a>`;
|
|
46
34
|
}
|
|
47
35
|
// unsafe URL이거나 link가 없으면 링크 없이 텍스트만 렌더링
|
|
48
36
|
return `<span class="${className}">${supportingText}</span>`;
|
|
49
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* `supportTextLinkTarget`이 `'_blank'`이면 `renderSupportingText`가 만든 링크를 새 탭으로 연다.
|
|
40
|
+
*
|
|
41
|
+
* target 은 sanitize **이후** 우리가 만든 링크(텍스트 컨테이너의 직계 `<a>`)에만 지정한다.
|
|
42
|
+
* DOMPurify 에 target 을 전역 허용하면 사용자 입력 HTML 의 `<a target>`까지 rel 없이 통과하기 때문이다.
|
|
43
|
+
* 런타임 입력이므로 `'_blank'`가 아닌 값은 전부 `'_self'`(속성 미부여)로 취급한다.
|
|
44
|
+
*/
|
|
45
|
+
export function applySupportTextLinkTarget(root, textContainerClassName, linkClassName, target) {
|
|
46
|
+
if (target !== '_blank')
|
|
47
|
+
return;
|
|
48
|
+
const link = root.querySelector(`.${textContainerClassName} > a.${linkClassName}`);
|
|
49
|
+
if (!link)
|
|
50
|
+
return;
|
|
51
|
+
link.setAttribute('target', '_blank');
|
|
52
|
+
link.setAttribute('rel', 'noopener noreferrer');
|
|
53
|
+
}
|
|
50
54
|
/** 액션 버튼 색상을 지정하지 않았을 때의 기본값. React `MessageNotificationParts`와 같다. */
|
|
51
55
|
const DEFAULT_ACTION_HIERARCHY = 'text';
|
|
52
56
|
/**
|
|
@@ -78,10 +82,9 @@ function buildActionKey(action) {
|
|
|
78
82
|
/**
|
|
79
83
|
* 액션 버튼 그룹 HTML을 만든다.
|
|
80
84
|
*
|
|
81
|
-
* `size` 기본값 '
|
|
82
|
-
* message 타입만 TO-BE 규격(28px)에 맞춰 'xs'를 넘긴다 — React `<Button size="xs">`와 동일.
|
|
85
|
+
* `size` 기본값 'xs'는 디자인 기준(#535 — 모든 type 액션 버튼 xs)이며 React `<Button size="xs">`와 같다.
|
|
83
86
|
*/
|
|
84
|
-
export function renderActions(actions, wrapperClass, size = '
|
|
87
|
+
export function renderActions(actions, wrapperClass, size = 'xs') {
|
|
85
88
|
// 액션이 없으면 빈 문자열 반환
|
|
86
89
|
if (!actions || actions.length === 0) {
|
|
87
90
|
return '';
|
|
@@ -13,3 +13,16 @@ export declare const HIDE_PERMANENTLY_LABEL: {
|
|
|
13
13
|
readonly message: "다시 보지 않기";
|
|
14
14
|
readonly fullWidth: "다시보지 않기";
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* message 타입 닫기(X) 아이콘의 color 별 색.
|
|
18
|
+
*
|
|
19
|
+
* React(`MessageNotification.tsx`)와 Vanilla(`messageTemplate.ts`)가 함께 참조하는 단일 출처다.
|
|
20
|
+
* `info`는 `variant: 'block'`에서만 렌더된다(default 는 neutral 로 폴백).
|
|
21
|
+
*/
|
|
22
|
+
export declare const MESSAGE_CLOSE_ICON_COLOR: {
|
|
23
|
+
readonly neutral: string;
|
|
24
|
+
readonly error: string;
|
|
25
|
+
readonly warning: string;
|
|
26
|
+
readonly success: string;
|
|
27
|
+
readonly info: string;
|
|
28
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { COLOR } from './color';
|
|
1
2
|
/**
|
|
2
3
|
* 다시보지 않기 버튼의 타입별 기본 문구.
|
|
3
4
|
*
|
|
@@ -13,3 +14,16 @@ export const HIDE_PERMANENTLY_LABEL = {
|
|
|
13
14
|
message: '다시 보지 않기',
|
|
14
15
|
fullWidth: '다시보지 않기',
|
|
15
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* message 타입 닫기(X) 아이콘의 color 별 색.
|
|
19
|
+
*
|
|
20
|
+
* React(`MessageNotification.tsx`)와 Vanilla(`messageTemplate.ts`)가 함께 참조하는 단일 출처다.
|
|
21
|
+
* `info`는 `variant: 'block'`에서만 렌더된다(default 는 neutral 로 폴백).
|
|
22
|
+
*/
|
|
23
|
+
export const MESSAGE_CLOSE_ICON_COLOR = {
|
|
24
|
+
neutral: COLOR.gray700,
|
|
25
|
+
error: COLOR.red500,
|
|
26
|
+
warning: COLOR.orange500,
|
|
27
|
+
success: COLOR.green600,
|
|
28
|
+
info: COLOR.violet600,
|
|
29
|
+
};
|
|
@@ -16,4 +16,4 @@ type BadgeProps = {
|
|
|
16
16
|
};
|
|
17
17
|
declare const Badge: ({ label, type, color, className, leadingIcon, trailingIcon, size, }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
18
|
export { Badge };
|
|
19
|
-
export type {
|
|
19
|
+
export type { BadgeColor, BadgeProps, BadgeSize, BadgeType };
|