@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
|
@@ -19,6 +19,8 @@ const Notification = exports.Notification = /*#__PURE__*/(0, _react.forwardRef)(
|
|
|
19
19
|
color = 'neutral',
|
|
20
20
|
width,
|
|
21
21
|
supportTextLink,
|
|
22
|
+
supportTextLinkTarget,
|
|
23
|
+
variant,
|
|
22
24
|
...rest
|
|
23
25
|
} = _ref;
|
|
24
26
|
if (type === 'floating') {
|
|
@@ -32,6 +34,7 @@ const Notification = exports.Notification = /*#__PURE__*/(0, _react.forwardRef)(
|
|
|
32
34
|
return (0, _jsxRuntime.jsx)(_FullWidthNotification.FullWidthNotification, {
|
|
33
35
|
color: color,
|
|
34
36
|
supportTextLink: supportTextLink,
|
|
37
|
+
supportTextLinkTarget: supportTextLinkTarget,
|
|
35
38
|
...rest,
|
|
36
39
|
ref: ref
|
|
37
40
|
});
|
|
@@ -39,6 +42,9 @@ const Notification = exports.Notification = /*#__PURE__*/(0, _react.forwardRef)(
|
|
|
39
42
|
if (type === 'message') {
|
|
40
43
|
return (0, _jsxRuntime.jsx)(_MessageNotification.MessageNotification, {
|
|
41
44
|
color: color,
|
|
45
|
+
variant: variant,
|
|
46
|
+
supportTextLink: supportTextLink,
|
|
47
|
+
supportTextLinkTarget: supportTextLinkTarget,
|
|
42
48
|
...rest,
|
|
43
49
|
ref: ref
|
|
44
50
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NotificationActionButtons = void 0;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _button = require("../../action/button");
|
|
9
|
+
/**
|
|
10
|
+
* 알림 액션 버튼 목록. 모든 type 이 같은 규격(`ncua-btn--xs` + hierarchy, 기본 `text`)을 쓴다(#535).
|
|
11
|
+
* Vanilla `renderActions`(assets/scripts/notification/utils.ts)와 같은 클래스를 산출해야 한다.
|
|
12
|
+
* 감싸는 래퍼(`__actions`)는 type 마다 클래스가 달라 호출부가 담당한다.
|
|
13
|
+
*/
|
|
14
|
+
const NotificationActionButtons = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
actions
|
|
17
|
+
} = _ref;
|
|
18
|
+
return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
19
|
+
children: actions.map(action => (0, _jsxRuntime.jsx)(_button.Button, {
|
|
20
|
+
size: "xs",
|
|
21
|
+
hierarchy: action.hierarchy || 'text',
|
|
22
|
+
label: action.label,
|
|
23
|
+
onClick: action.onClick
|
|
24
|
+
}, `${action.label}-${action.hierarchy}`))
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
exports.NotificationActionButtons = NotificationActionButtons;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = require("react");
|
|
4
|
+
var _client = require("react-dom/client");
|
|
5
|
+
var _testUtils = require("react-dom/test-utils");
|
|
6
|
+
var _vitest = require("vitest");
|
|
7
|
+
var _FullWidthNotification = require("../FullWidthNotification");
|
|
8
|
+
var _MessageNotification = require("../MessageNotification");
|
|
9
|
+
// @vitest-environment jsdom
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* React 텍스트 링크(`supportTextLink`)의 프로토콜 검사 (#538 리뷰 H2).
|
|
13
|
+
* Vanilla `renderSupportingText` 와 같은 정책 — unsafe URL 이면 링크 없이 텍스트만 렌더한다.
|
|
14
|
+
*/
|
|
15
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
16
|
+
const cleanups = [];
|
|
17
|
+
(0, _vitest.afterEach)(() => {
|
|
18
|
+
for (const cleanup of cleanups.splice(0)) cleanup();
|
|
19
|
+
});
|
|
20
|
+
function mount(element) {
|
|
21
|
+
const container = document.createElement('div');
|
|
22
|
+
document.body.appendChild(container);
|
|
23
|
+
const root = (0, _client.createRoot)(container);
|
|
24
|
+
(0, _testUtils.act)(() => {
|
|
25
|
+
root.render(element);
|
|
26
|
+
});
|
|
27
|
+
cleanups.push(() => {
|
|
28
|
+
(0, _testUtils.act)(() => root.unmount());
|
|
29
|
+
container.remove();
|
|
30
|
+
});
|
|
31
|
+
return container;
|
|
32
|
+
}
|
|
33
|
+
const IMPLEMENTATIONS = [['MessageNotification(block)', supportTextLink => mount(/*#__PURE__*/(0, _react.createElement)(_MessageNotification.MessageNotification, {
|
|
34
|
+
title: '공지',
|
|
35
|
+
variant: 'block',
|
|
36
|
+
supportingText: '자세히 보기',
|
|
37
|
+
supportTextLink
|
|
38
|
+
})), '.ncua-message-notification__supporting-text'], ['FullWidthNotification', supportTextLink => mount(/*#__PURE__*/(0, _react.createElement)(_FullWidthNotification.FullWidthNotification, {
|
|
39
|
+
title: '공지',
|
|
40
|
+
supportingText: '자세히 보기',
|
|
41
|
+
supportTextLink
|
|
42
|
+
})), '.ncua-full-width-notification__supporting-text']];
|
|
43
|
+
const UNSAFE = ['javascript:alert(1)', ' JavaScript:alert(1)', 'JAVASCRIPT:alert(1)', '\tjavascript:alert(1)', 'data:text/html,<script>alert(1)</script>'];
|
|
44
|
+
const SAFE = ['https://example.com/notice/1', 'http://example.com/notice/1', '/notice/1', 'notice/1'];
|
|
45
|
+
_vitest.describe.each(IMPLEMENTATIONS)('%s — supportTextLink 프로토콜 검사', (_, render, supportingTextSelector) => {
|
|
46
|
+
_vitest.it.each(UNSAFE)('unsafe %j → 링크 없이 텍스트만 렌더한다', url => {
|
|
47
|
+
const container = render(url);
|
|
48
|
+
(0, _vitest.expect)(container.querySelector('a')).toBeNull();
|
|
49
|
+
(0, _vitest.expect)(container.querySelector(supportingTextSelector)?.textContent).toBe('자세히 보기');
|
|
50
|
+
});
|
|
51
|
+
_vitest.it.each(SAFE)('safe %j → 그대로 링크로 렌더한다', url => {
|
|
52
|
+
const container = render(url);
|
|
53
|
+
const anchors = container.querySelectorAll('a');
|
|
54
|
+
(0, _vitest.expect)(anchors).toHaveLength(1);
|
|
55
|
+
(0, _vitest.expect)(anchors[0].getAttribute('href')).toBe(url);
|
|
56
|
+
(0, _vitest.expect)(anchors[0].querySelector(supportingTextSelector)?.textContent).toBe('자세히 보기');
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getLinkTargetAttributes = getLinkTargetAttributes;
|
|
7
|
+
/**
|
|
8
|
+
* 텍스트 링크(`supportTextLink`)의 `<a>`에 붙일 target·rel 속성.
|
|
9
|
+
*
|
|
10
|
+
* `'_blank'`일 때만 새 탭 + `rel="noopener noreferrer"`를 반환하고, `'_self'`(기본)는 아무 속성도 붙이지 않는다.
|
|
11
|
+
* Vanilla `applySupportTextLinkTarget`과 같은 마크업을 산출해야 한다.
|
|
12
|
+
*/
|
|
13
|
+
function getLinkTargetAttributes(target) {
|
|
14
|
+
return target === '_blank' ? {
|
|
15
|
+
target: '_blank',
|
|
16
|
+
rel: 'noopener noreferrer'
|
|
17
|
+
} : undefined;
|
|
18
|
+
}
|