@ncds/ui-admin 1.8.25-alpha.3 → 1.8.26-alpha.0

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 (111) hide show
  1. package/dist/cjs/assets/scripts/notification/FullWidthNotification.js +2 -0
  2. package/dist/cjs/assets/scripts/notification/MessageNotification.js +30 -23
  3. package/dist/cjs/assets/scripts/notification/const/classNames.js +3 -0
  4. package/dist/cjs/assets/scripts/notification/const/icons.js +11 -2
  5. package/dist/cjs/assets/scripts/notification/const/index.js +9 -4
  6. package/dist/cjs/assets/scripts/notification/const/sizes.js +6 -1
  7. package/dist/cjs/assets/scripts/notification/const/types.js +1 -10
  8. package/dist/cjs/assets/scripts/notification/messageTemplate.js +20 -8
  9. package/dist/cjs/assets/scripts/notification/utils.js +21 -17
  10. package/dist/cjs/constant/notification.js +15 -1
  11. package/dist/cjs/src/components/overlays/notification/FloatingNotification.js +4 -7
  12. package/dist/cjs/src/components/overlays/notification/FullWidthNotification.js +13 -8
  13. package/dist/cjs/src/components/overlays/notification/MessageNotification.js +20 -14
  14. package/dist/cjs/src/components/overlays/notification/MessageNotificationParts.js +22 -15
  15. package/dist/cjs/src/components/overlays/notification/Notification.js +6 -0
  16. package/dist/cjs/src/components/overlays/notification/NotificationActionButtons.js +27 -0
  17. package/dist/cjs/src/components/overlays/notification/__tests__/supportTextLink.test.js +58 -0
  18. package/dist/cjs/src/components/overlays/notification/linkTarget.js +18 -0
  19. package/dist/cjs/src/generated/scoped-css.js +1 -1
  20. package/dist/cjs/src/utils/index.js +11 -0
  21. package/dist/cjs/src/utils/url/__tests__/isSafeUrl.test.js +49 -0
  22. package/dist/cjs/src/utils/url/index.js +16 -0
  23. package/dist/cjs/src/utils/url/isSafeUrl.js +32 -0
  24. package/dist/esm/assets/scripts/notification/FullWidthNotification.js +3 -1
  25. package/dist/esm/assets/scripts/notification/MessageNotification.js +32 -25
  26. package/dist/esm/assets/scripts/notification/const/classNames.js +3 -0
  27. package/dist/esm/assets/scripts/notification/const/icons.js +10 -1
  28. package/dist/esm/assets/scripts/notification/const/index.js +2 -3
  29. package/dist/esm/assets/scripts/notification/const/sizes.js +5 -0
  30. package/dist/esm/assets/scripts/notification/const/types.js +1 -8
  31. package/dist/esm/assets/scripts/notification/messageTemplate.js +21 -9
  32. package/dist/esm/assets/scripts/notification/utils.js +19 -16
  33. package/dist/esm/constant/notification.js +14 -0
  34. package/dist/esm/src/components/overlays/notification/FloatingNotification.js +4 -7
  35. package/dist/esm/src/components/overlays/notification/FullWidthNotification.js +13 -8
  36. package/dist/esm/src/components/overlays/notification/MessageNotification.js +21 -15
  37. package/dist/esm/src/components/overlays/notification/MessageNotificationParts.js +22 -15
  38. package/dist/esm/src/components/overlays/notification/Notification.js +6 -0
  39. package/dist/esm/src/components/overlays/notification/NotificationActionButtons.js +21 -0
  40. package/dist/esm/src/components/overlays/notification/__tests__/supportTextLink.test.js +55 -0
  41. package/dist/esm/src/components/overlays/notification/linkTarget.js +12 -0
  42. package/dist/esm/src/generated/scoped-css.js +1 -1
  43. package/dist/esm/src/utils/index.js +3 -1
  44. package/dist/esm/src/utils/url/__tests__/isSafeUrl.test.js +47 -0
  45. package/dist/esm/src/utils/url/index.js +1 -0
  46. package/dist/esm/src/utils/url/isSafeUrl.js +26 -0
  47. package/dist/temp/assets/scripts/notification/FullWidthNotification.js +3 -2
  48. package/dist/temp/assets/scripts/notification/MessageNotification.d.ts +2 -0
  49. package/dist/temp/assets/scripts/notification/MessageNotification.js +30 -25
  50. package/dist/temp/assets/scripts/notification/const/classNames.d.ts +3 -0
  51. package/dist/temp/assets/scripts/notification/const/classNames.js +3 -0
  52. package/dist/temp/assets/scripts/notification/const/icons.d.ts +6 -0
  53. package/dist/temp/assets/scripts/notification/const/icons.js +9 -0
  54. package/dist/temp/assets/scripts/notification/const/index.d.ts +3 -4
  55. package/dist/temp/assets/scripts/notification/const/index.js +2 -3
  56. package/dist/temp/assets/scripts/notification/const/sizes.d.ts +4 -0
  57. package/dist/temp/assets/scripts/notification/const/sizes.js +5 -0
  58. package/dist/temp/assets/scripts/notification/const/types.d.ts +28 -1
  59. package/dist/temp/assets/scripts/notification/const/types.js +1 -8
  60. package/dist/temp/assets/scripts/notification/messageTemplate.d.ts +5 -1
  61. package/dist/temp/assets/scripts/notification/messageTemplate.js +16 -11
  62. package/dist/temp/assets/scripts/notification/utils.d.ts +10 -3
  63. package/dist/temp/assets/scripts/notification/utils.js +21 -18
  64. package/dist/temp/constant/notification.d.ts +13 -0
  65. package/dist/temp/constant/notification.js +14 -0
  66. package/dist/temp/src/components/overlays/notification/FloatingNotification.js +2 -2
  67. package/dist/temp/src/components/overlays/notification/FullWidthNotification.d.ts +6 -1
  68. package/dist/temp/src/components/overlays/notification/FullWidthNotification.js +7 -2
  69. package/dist/temp/src/components/overlays/notification/MessageNotification.d.ts +15 -1
  70. package/dist/temp/src/components/overlays/notification/MessageNotification.js +11 -12
  71. package/dist/temp/src/components/overlays/notification/MessageNotificationParts.d.ts +10 -5
  72. package/dist/temp/src/components/overlays/notification/MessageNotificationParts.js +9 -6
  73. package/dist/temp/src/components/overlays/notification/Notification.d.ts +23 -2
  74. package/dist/temp/src/components/overlays/notification/Notification.js +3 -3
  75. package/dist/temp/src/components/overlays/notification/NotificationActionButtons.d.ts +12 -0
  76. package/dist/temp/src/components/overlays/notification/NotificationActionButtons.js +9 -0
  77. package/dist/temp/src/components/overlays/notification/__tests__/supportTextLink.test.d.ts +1 -0
  78. package/dist/temp/src/components/overlays/notification/__tests__/supportTextLink.test.js +73 -0
  79. package/dist/temp/src/components/overlays/notification/linkTarget.d.ts +11 -0
  80. package/dist/temp/src/components/overlays/notification/linkTarget.js +9 -0
  81. package/dist/temp/src/generated/scoped-css.js +1 -1
  82. package/dist/temp/src/utils/index.d.ts +1 -0
  83. package/dist/temp/src/utils/index.js +2 -0
  84. package/dist/temp/src/utils/url/__tests__/isSafeUrl.test.d.ts +1 -0
  85. package/dist/temp/src/utils/url/__tests__/isSafeUrl.test.js +61 -0
  86. package/dist/temp/src/utils/url/index.d.ts +1 -0
  87. package/dist/temp/src/utils/url/index.js +1 -0
  88. package/dist/temp/src/utils/url/isSafeUrl.d.ts +8 -0
  89. package/dist/temp/src/utils/url/isSafeUrl.js +29 -0
  90. package/dist/types/assets/scripts/notification/MessageNotification.d.ts +2 -0
  91. package/dist/types/assets/scripts/notification/const/classNames.d.ts +3 -0
  92. package/dist/types/assets/scripts/notification/const/icons.d.ts +6 -0
  93. package/dist/types/assets/scripts/notification/const/index.d.ts +3 -4
  94. package/dist/types/assets/scripts/notification/const/sizes.d.ts +4 -0
  95. package/dist/types/assets/scripts/notification/const/types.d.ts +28 -1
  96. package/dist/types/assets/scripts/notification/messageTemplate.d.ts +5 -1
  97. package/dist/types/assets/scripts/notification/utils.d.ts +10 -3
  98. package/dist/types/constant/notification.d.ts +13 -0
  99. package/dist/types/src/components/overlays/notification/FullWidthNotification.d.ts +6 -1
  100. package/dist/types/src/components/overlays/notification/MessageNotification.d.ts +15 -1
  101. package/dist/types/src/components/overlays/notification/MessageNotificationParts.d.ts +10 -5
  102. package/dist/types/src/components/overlays/notification/Notification.d.ts +23 -2
  103. package/dist/types/src/components/overlays/notification/NotificationActionButtons.d.ts +12 -0
  104. package/dist/types/src/components/overlays/notification/__tests__/supportTextLink.test.d.ts +1 -0
  105. package/dist/types/src/components/overlays/notification/linkTarget.d.ts +11 -0
  106. package/dist/types/src/utils/index.d.ts +1 -0
  107. package/dist/types/src/utils/url/__tests__/isSafeUrl.test.d.ts +1 -0
  108. package/dist/types/src/utils/url/index.d.ts +1 -0
  109. package/dist/types/src/utils/url/isSafeUrl.d.ts +8 -0
  110. package/dist/ui-admin/assets/styles/style.css +42 -20
  111. package/package.json +1 -1
@@ -1,26 +1,34 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Pin02, XClose } from '@ncds/ui-admin-icon';
3
3
  import { HIDE_PERMANENTLY_LABEL } from '../../../../constant/notification';
4
- import { Button } from '../../action/button';
4
+ import { isSafeUrl } from '../../../utils/url';
5
5
  import { FeaturedIcon } from '../../image-and-icons/featured-icon/FeaturedIcon';
6
- /** 아이콘 + 제목/서포팅 텍스트 영역. */
6
+ import { getLinkTargetAttributes } from './linkTarget';
7
+ import { NotificationActionButtons } from './NotificationActionButtons';
8
+ /** 아이콘 + 제목/서포팅 텍스트(또는 텍스트 링크) 영역. */
7
9
  const MessageNotificationContent = _ref => {
8
10
  let {
9
11
  title,
10
12
  supportingText,
13
+ supportTextLink,
14
+ supportTextLinkTarget,
11
15
  icon,
12
16
  iconColor,
13
- showIcon
17
+ iconSize
14
18
  } = _ref;
15
19
  const featuredIconProps = {
16
20
  icon: icon || Pin02,
17
- size: 'md',
21
+ size: iconSize,
18
22
  color: iconColor,
19
23
  theme: 'light-circle'
20
24
  };
25
+ const supportingTextNode = supportingText && _jsx("span", {
26
+ className: "ncua-message-notification__supporting-text",
27
+ children: supportingText
28
+ });
21
29
  return _jsxs("div", {
22
30
  className: "ncua-message-notification__content-wrapper",
23
- children: [showIcon && _jsx(FeaturedIcon, {
31
+ children: [_jsx(FeaturedIcon, {
24
32
  ...featuredIconProps,
25
33
  className: "ncua-message-notification__icon"
26
34
  }), _jsxs("div", {
@@ -28,10 +36,12 @@ const MessageNotificationContent = _ref => {
28
36
  children: [_jsx("span", {
29
37
  className: "ncua-message-notification__title",
30
38
  children: title
31
- }), supportingText && _jsx("span", {
32
- className: "ncua-message-notification__supporting-text",
33
- children: supportingText
34
- })]
39
+ }), supportTextLink && isSafeUrl(supportTextLink) && supportingTextNode ? _jsx("a", {
40
+ href: supportTextLink,
41
+ className: "ncua-message-notification__link",
42
+ ...getLinkTargetAttributes(supportTextLinkTarget),
43
+ children: supportingTextNode
44
+ }) : supportingTextNode]
35
45
  })]
36
46
  });
37
47
  };
@@ -55,12 +65,9 @@ const MessageNotificationActions = _ref2 => {
55
65
  className: "ncua-message-notification__actions-container",
56
66
  children: [hasActions && _jsx("div", {
57
67
  className: "ncua-message-notification__actions",
58
- children: actions?.map(action => _jsx(Button, {
59
- size: "xs",
60
- hierarchy: action.hierarchy || 'text',
61
- label: action.label,
62
- onClick: action?.onClick
63
- }, `${action.label}-${action.hierarchy}`))
68
+ children: _jsx(NotificationActionButtons, {
69
+ actions: actions ?? []
70
+ })
64
71
  }), hasFooter && _jsxs("div", {
65
72
  className: "ncua-message-notification__footer-container",
66
73
  children: [onHidePermanently && _jsx("button", {
@@ -13,6 +13,8 @@ const Notification = /*#__PURE__*/forwardRef(
13
13
  color = 'neutral',
14
14
  width,
15
15
  supportTextLink,
16
+ supportTextLinkTarget,
17
+ variant,
16
18
  ...rest
17
19
  } = _ref;
18
20
  if (type === 'floating') {
@@ -26,6 +28,7 @@ const Notification = /*#__PURE__*/forwardRef(
26
28
  return _jsx(FullWidthNotification, {
27
29
  color: color,
28
30
  supportTextLink: supportTextLink,
31
+ supportTextLinkTarget: supportTextLinkTarget,
29
32
  ...rest,
30
33
  ref: ref
31
34
  });
@@ -33,6 +36,9 @@ const Notification = /*#__PURE__*/forwardRef(
33
36
  if (type === 'message') {
34
37
  return _jsx(MessageNotification, {
35
38
  color: color,
39
+ variant: variant,
40
+ supportTextLink: supportTextLink,
41
+ supportTextLinkTarget: supportTextLinkTarget,
36
42
  ...rest,
37
43
  ref: ref
38
44
  });
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Button } from '../../action/button';
3
+ /**
4
+ * 알림 액션 버튼 목록. 모든 type 이 같은 규격(`ncua-btn--xs` + hierarchy, 기본 `text`)을 쓴다(#535).
5
+ * Vanilla `renderActions`(assets/scripts/notification/utils.ts)와 같은 클래스를 산출해야 한다.
6
+ * 감싸는 래퍼(`__actions`)는 type 마다 클래스가 달라 호출부가 담당한다.
7
+ */
8
+ const NotificationActionButtons = _ref => {
9
+ let {
10
+ actions
11
+ } = _ref;
12
+ return _jsx(_Fragment, {
13
+ children: actions.map(action => _jsx(Button, {
14
+ size: "xs",
15
+ hierarchy: action.hierarchy || 'text',
16
+ label: action.label,
17
+ onClick: action.onClick
18
+ }, `${action.label}-${action.hierarchy}`))
19
+ });
20
+ };
21
+ export { NotificationActionButtons };
@@ -0,0 +1,55 @@
1
+ // @vitest-environment jsdom
2
+ import { createElement } from 'react';
3
+ import { createRoot } from 'react-dom/client';
4
+ import { act } from 'react-dom/test-utils';
5
+ import { afterEach, describe, expect, it } from 'vitest';
6
+ import { FullWidthNotification } from '../FullWidthNotification';
7
+ import { MessageNotification } from '../MessageNotification';
8
+ /**
9
+ * React 텍스트 링크(`supportTextLink`)의 프로토콜 검사 (#538 리뷰 H2).
10
+ * Vanilla `renderSupportingText` 와 같은 정책 — unsafe URL 이면 링크 없이 텍스트만 렌더한다.
11
+ */
12
+ globalThis.IS_REACT_ACT_ENVIRONMENT = true;
13
+ const cleanups = [];
14
+ afterEach(() => {
15
+ for (const cleanup of cleanups.splice(0)) cleanup();
16
+ });
17
+ function mount(element) {
18
+ const container = document.createElement('div');
19
+ document.body.appendChild(container);
20
+ const root = createRoot(container);
21
+ act(() => {
22
+ root.render(element);
23
+ });
24
+ cleanups.push(() => {
25
+ act(() => root.unmount());
26
+ container.remove();
27
+ });
28
+ return container;
29
+ }
30
+ const IMPLEMENTATIONS = [['MessageNotification(block)', supportTextLink => mount(/*#__PURE__*/createElement(MessageNotification, {
31
+ title: '공지',
32
+ variant: 'block',
33
+ supportingText: '자세히 보기',
34
+ supportTextLink
35
+ })), '.ncua-message-notification__supporting-text'], ['FullWidthNotification', supportTextLink => mount(/*#__PURE__*/createElement(FullWidthNotification, {
36
+ title: '공지',
37
+ supportingText: '자세히 보기',
38
+ supportTextLink
39
+ })), '.ncua-full-width-notification__supporting-text']];
40
+ const UNSAFE = ['javascript:alert(1)', ' JavaScript:alert(1)', 'JAVASCRIPT:alert(1)', '\tjavascript:alert(1)', 'data:text/html,<script>alert(1)</script>'];
41
+ const SAFE = ['https://example.com/notice/1', 'http://example.com/notice/1', '/notice/1', 'notice/1'];
42
+ describe.each(IMPLEMENTATIONS)('%s — supportTextLink 프로토콜 검사', (_, render, supportingTextSelector) => {
43
+ it.each(UNSAFE)('unsafe %j → 링크 없이 텍스트만 렌더한다', url => {
44
+ const container = render(url);
45
+ expect(container.querySelector('a')).toBeNull();
46
+ expect(container.querySelector(supportingTextSelector)?.textContent).toBe('자세히 보기');
47
+ });
48
+ it.each(SAFE)('safe %j → 그대로 링크로 렌더한다', url => {
49
+ const container = render(url);
50
+ const anchors = container.querySelectorAll('a');
51
+ expect(anchors).toHaveLength(1);
52
+ expect(anchors[0].getAttribute('href')).toBe(url);
53
+ expect(anchors[0].querySelector(supportingTextSelector)?.textContent).toBe('자세히 보기');
54
+ });
55
+ });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 텍스트 링크(`supportTextLink`)의 `<a>`에 붙일 target·rel 속성.
3
+ *
4
+ * `'_blank'`일 때만 새 탭 + `rel="noopener noreferrer"`를 반환하고, `'_self'`(기본)는 아무 속성도 붙이지 않는다.
5
+ * Vanilla `applySupportTextLinkTarget`과 같은 마크업을 산출해야 한다.
6
+ */
7
+ export function getLinkTargetAttributes(target) {
8
+ return target === '_blank' ? {
9
+ target: '_blank',
10
+ rel: 'noopener noreferrer'
11
+ } : undefined;
12
+ }