@ncds/ui-admin 1.8.21-alpha.0 → 1.8.21-alpha.10
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 +17 -6
- package/dist/cjs/assets/scripts/notification/MessageNotification.js +10 -48
- package/dist/cjs/assets/scripts/notification/const/classNames.js +3 -0
- package/dist/cjs/assets/scripts/notification/const/index.js +1 -1
- package/dist/cjs/assets/scripts/notification/const/sizes.js +4 -2
- package/dist/cjs/assets/scripts/notification/messageTemplate.js +106 -0
- package/dist/cjs/assets/scripts/notification/utils.js +40 -4
- package/dist/cjs/constant/notification.js +21 -0
- package/dist/cjs/src/components/forms-and-input/input-base/InputBase.js +52 -34
- package/dist/cjs/src/components/forms-and-input/input-base/__tests__/InputBase.test.js +228 -0
- package/dist/cjs/src/components/forms-and-input/password-input/PasswordInput.js +3 -2
- package/dist/cjs/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.js +59 -0
- package/dist/cjs/src/components/index.js +22 -0
- package/dist/cjs/src/components/layout/ncua-scope/NcuaScope.js +79 -0
- package/dist/cjs/src/components/layout/ncua-scope/index.js +16 -0
- package/dist/cjs/src/components/navigation/pagination/Pagination.js +3 -1
- package/dist/cjs/src/components/navigation/pagination/__tests__/Pagination.test.js +74 -0
- package/dist/cjs/src/components/overlays/notification/FullWidthNotification.js +3 -1
- package/dist/cjs/src/components/overlays/notification/MessageNotification.js +14 -54
- package/dist/cjs/src/components/overlays/notification/MessageNotificationParts.js +92 -0
- package/dist/cjs/src/components/overlays/notification/__tests__/MessageNotification.test.js +246 -0
- package/dist/cjs/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.js +209 -0
- package/dist/cjs/src/components/overlays/postcode-search-modal/PostcodeSearchModal.js +259 -0
- package/dist/cjs/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.js +70 -0
- package/dist/cjs/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.js +623 -0
- package/dist/cjs/src/components/overlays/postcode-search-modal/index.js +16 -0
- package/dist/cjs/src/generated/scoped-css.js +9 -0
- package/dist/esm/assets/scripts/notification/FullWidthNotification.js +17 -6
- package/dist/esm/assets/scripts/notification/MessageNotification.js +12 -50
- package/dist/esm/assets/scripts/notification/const/classNames.js +3 -0
- package/dist/esm/assets/scripts/notification/const/index.js +3 -2
- package/dist/esm/assets/scripts/notification/const/sizes.js +4 -2
- package/dist/esm/assets/scripts/notification/messageTemplate.js +100 -0
- package/dist/esm/assets/scripts/notification/utils.js +39 -4
- package/dist/esm/constant/notification.js +15 -0
- package/dist/esm/src/components/forms-and-input/input-base/InputBase.js +52 -34
- package/dist/esm/src/components/forms-and-input/input-base/__tests__/InputBase.test.js +228 -0
- package/dist/esm/src/components/forms-and-input/password-input/PasswordInput.js +3 -2
- package/dist/esm/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.js +56 -0
- package/dist/esm/src/components/index.js +2 -0
- package/dist/esm/src/components/layout/ncua-scope/NcuaScope.js +73 -0
- package/dist/esm/src/components/layout/ncua-scope/index.js +1 -0
- package/dist/esm/src/components/navigation/pagination/Pagination.js +3 -1
- package/dist/esm/src/components/navigation/pagination/__tests__/Pagination.test.js +74 -0
- package/dist/esm/src/components/overlays/notification/FullWidthNotification.js +3 -1
- package/dist/esm/src/components/overlays/notification/MessageNotification.js +15 -55
- package/dist/esm/src/components/overlays/notification/MessageNotificationParts.js +85 -0
- package/dist/esm/src/components/overlays/notification/__tests__/MessageNotification.test.js +243 -0
- package/dist/esm/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.js +206 -0
- package/dist/esm/src/components/overlays/postcode-search-modal/PostcodeSearchModal.js +252 -0
- package/dist/esm/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.js +63 -0
- package/dist/esm/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.js +620 -0
- package/dist/esm/src/components/overlays/postcode-search-modal/index.js +1 -0
- package/dist/esm/src/generated/scoped-css.js +3 -0
- package/dist/temp/assets/scripts/notification/FullWidthNotification.d.ts +6 -0
- package/dist/temp/assets/scripts/notification/FullWidthNotification.js +14 -5
- package/dist/temp/assets/scripts/notification/MessageNotification.d.ts +0 -3
- package/dist/temp/assets/scripts/notification/MessageNotification.js +9 -44
- package/dist/temp/assets/scripts/notification/const/classNames.d.ts +1 -0
- package/dist/temp/assets/scripts/notification/const/classNames.js +3 -0
- package/dist/temp/assets/scripts/notification/const/index.d.ts +3 -3
- package/dist/temp/assets/scripts/notification/const/index.js +3 -2
- package/dist/temp/assets/scripts/notification/const/sizes.d.ts +2 -2
- package/dist/temp/assets/scripts/notification/const/sizes.js +4 -2
- package/dist/temp/assets/scripts/notification/const/types.d.ts +30 -2
- package/dist/temp/assets/scripts/notification/messageTemplate.d.ts +15 -0
- package/dist/temp/assets/scripts/notification/messageTemplate.js +79 -0
- package/dist/temp/assets/scripts/notification/utils.d.ts +19 -2
- package/dist/temp/assets/scripts/notification/utils.js +39 -5
- package/dist/temp/constant/notification.d.ts +15 -0
- package/dist/temp/constant/notification.js +15 -0
- package/dist/temp/src/components/forms-and-input/input-base/InputBase.d.ts +1 -1
- package/dist/temp/src/components/forms-and-input/input-base/InputBase.js +43 -26
- package/dist/temp/src/components/forms-and-input/input-base/__tests__/InputBase.test.js +174 -0
- package/dist/temp/src/components/forms-and-input/password-input/PasswordInput.js +2 -1
- package/dist/temp/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.d.ts +1 -0
- package/dist/temp/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.js +48 -0
- package/dist/temp/src/components/index.d.ts +2 -0
- package/dist/temp/src/components/index.js +2 -0
- package/dist/temp/src/components/layout/ncua-scope/NcuaScope.d.ts +32 -0
- package/dist/temp/src/components/layout/ncua-scope/NcuaScope.js +51 -0
- package/dist/temp/src/components/layout/ncua-scope/index.d.ts +1 -0
- package/dist/temp/src/components/layout/ncua-scope/index.js +1 -0
- package/dist/temp/src/components/navigation/pagination/Pagination.js +3 -1
- package/dist/temp/src/components/navigation/pagination/__tests__/Pagination.test.js +74 -0
- package/dist/temp/src/components/overlays/notification/FullWidthNotification.d.ts +6 -0
- package/dist/temp/src/components/overlays/notification/FullWidthNotification.js +3 -2
- package/dist/temp/src/components/overlays/notification/MessageNotification.d.ts +6 -0
- package/dist/temp/src/components/overlays/notification/MessageNotification.js +4 -13
- package/dist/temp/src/components/overlays/notification/MessageNotificationParts.d.ts +28 -0
- package/dist/temp/src/components/overlays/notification/MessageNotificationParts.js +28 -0
- package/dist/temp/src/components/overlays/notification/Notification.d.ts +11 -2
- package/dist/temp/src/components/overlays/notification/__tests__/MessageNotification.test.d.ts +1 -0
- package/dist/temp/src/components/overlays/notification/__tests__/MessageNotification.test.js +190 -0
- package/dist/temp/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.d.ts +1 -0
- package/dist/temp/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.js +160 -0
- package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModal.d.ts +45 -0
- package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModal.js +125 -0
- package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.d.ts +16 -0
- package/dist/temp/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.js +24 -0
- package/dist/temp/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.d.ts +1 -0
- package/dist/temp/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.js +503 -0
- package/dist/temp/src/components/overlays/postcode-search-modal/index.d.ts +1 -0
- package/dist/temp/src/components/overlays/postcode-search-modal/index.js +1 -0
- package/dist/temp/src/generated/scoped-css.d.ts +1 -0
- package/dist/temp/src/generated/scoped-css.js +3 -0
- package/dist/types/assets/scripts/notification/FullWidthNotification.d.ts +6 -0
- package/dist/types/assets/scripts/notification/MessageNotification.d.ts +0 -3
- package/dist/types/assets/scripts/notification/const/classNames.d.ts +1 -0
- package/dist/types/assets/scripts/notification/const/index.d.ts +3 -3
- package/dist/types/assets/scripts/notification/const/sizes.d.ts +2 -2
- package/dist/types/assets/scripts/notification/const/types.d.ts +30 -2
- package/dist/types/assets/scripts/notification/messageTemplate.d.ts +15 -0
- package/dist/types/assets/scripts/notification/utils.d.ts +19 -2
- package/dist/types/constant/notification.d.ts +15 -0
- package/dist/types/src/components/forms-and-input/input-base/InputBase.d.ts +1 -1
- package/dist/types/src/components/forms-and-input/password-input/__tests__/PasswordInput.test.d.ts +1 -0
- package/dist/types/src/components/index.d.ts +2 -0
- package/dist/types/src/components/layout/ncua-scope/NcuaScope.d.ts +32 -0
- package/dist/types/src/components/layout/ncua-scope/index.d.ts +1 -0
- package/dist/types/src/components/overlays/notification/FullWidthNotification.d.ts +6 -0
- package/dist/types/src/components/overlays/notification/MessageNotification.d.ts +6 -0
- package/dist/types/src/components/overlays/notification/MessageNotificationParts.d.ts +28 -0
- package/dist/types/src/components/overlays/notification/Notification.d.ts +11 -2
- package/dist/types/src/components/overlays/notification/__tests__/MessageNotification.test.d.ts +1 -0
- package/dist/types/src/components/overlays/notification/__tests__/hidePermanentlyLabel.test.d.ts +1 -0
- package/dist/types/src/components/overlays/postcode-search-modal/PostcodeSearchModal.d.ts +45 -0
- package/dist/types/src/components/overlays/postcode-search-modal/PostcodeSearchModalTip.d.ts +16 -0
- package/dist/types/src/components/overlays/postcode-search-modal/__tests__/PostcodeSearchModal.test.d.ts +1 -0
- package/dist/types/src/components/overlays/postcode-search-modal/index.d.ts +1 -0
- package/dist/types/src/generated/scoped-css.d.ts +1 -0
- package/dist/ui-admin/assets/styles/style.css +296 -56
- package/dist/ui-admin/assets/styles/style.scoped.css +8595 -0
- package/package.json +13 -6
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FeaturedIcon } from '../featuredIcon';
|
|
2
2
|
import { sanitizeHtml } from '../utils/sanitize';
|
|
3
|
-
import { CLASS_NAMES, FLOATING_ICON_MAP, MESSAGE_SIZES
|
|
4
|
-
import {
|
|
3
|
+
import { CLASS_NAMES, FLOATING_ICON_MAP, MESSAGE_SIZES } from './const';
|
|
4
|
+
import { buildMessageTemplate } from './messageTemplate';
|
|
5
|
+
import { bindNotificationEvents, createWrapperElement, setupAutoClose } from './utils';
|
|
5
6
|
export class MessageNotification {
|
|
6
7
|
constructor(options) {
|
|
7
8
|
this.options = {
|
|
@@ -24,7 +25,8 @@ export class MessageNotification {
|
|
|
24
25
|
className,
|
|
25
26
|
actions,
|
|
26
27
|
onClose,
|
|
27
|
-
onHidePermanently
|
|
28
|
+
onHidePermanently,
|
|
29
|
+
hidePermanentlyLabel
|
|
28
30
|
} = this.options;
|
|
29
31
|
// message 타입은 neutral, error, warning, success 4가지 색상만 지원
|
|
30
32
|
let actualColor = color;
|
|
@@ -41,16 +43,20 @@ export class MessageNotification {
|
|
|
41
43
|
svgString: iconSvg,
|
|
42
44
|
theme: 'light-circle',
|
|
43
45
|
color: actualColor,
|
|
44
|
-
size: MESSAGE_SIZES.FEATURED_ICON
|
|
46
|
+
size: MESSAGE_SIZES.FEATURED_ICON,
|
|
47
|
+
// React 구현과 동일하게 `__icon`(flex-shrink: 0)을 부여한다.
|
|
48
|
+
// 누락 시 긴 타이틀에서 아이콘이 찌그러진다.
|
|
49
|
+
className: CLASS_NAMES.MESSAGE.ICON
|
|
45
50
|
});
|
|
46
51
|
featuredIconElement = this.featuredIcon.getElement();
|
|
47
52
|
}
|
|
48
|
-
wrapper.innerHTML = sanitizeHtml(
|
|
53
|
+
wrapper.innerHTML = sanitizeHtml(buildMessageTemplate({
|
|
49
54
|
title,
|
|
50
55
|
supportingText,
|
|
51
56
|
actions,
|
|
52
57
|
onClose,
|
|
53
|
-
onHidePermanently
|
|
58
|
+
onHidePermanently,
|
|
59
|
+
hidePermanentlyLabel
|
|
54
60
|
}));
|
|
55
61
|
// FeaturedIcon을 content-wrapper에 추가
|
|
56
62
|
if (featuredIconElement) {
|
|
@@ -61,50 +67,6 @@ export class MessageNotification {
|
|
|
61
67
|
}
|
|
62
68
|
return wrapper;
|
|
63
69
|
}
|
|
64
|
-
buildTemplate(params) {
|
|
65
|
-
const {
|
|
66
|
-
title,
|
|
67
|
-
supportingText,
|
|
68
|
-
actions,
|
|
69
|
-
onClose,
|
|
70
|
-
onHidePermanently
|
|
71
|
-
} = params;
|
|
72
|
-
return `
|
|
73
|
-
<div class="${CLASS_NAMES.MESSAGE.CONTAINER}">
|
|
74
|
-
<div class="${CLASS_NAMES.MESSAGE.CONTENT}">
|
|
75
|
-
<div class="${CLASS_NAMES.MESSAGE.CONTENT_WRAPPER}">
|
|
76
|
-
<div class="${CLASS_NAMES.MESSAGE.TEXT_CONTAINER}">
|
|
77
|
-
<span class="${CLASS_NAMES.MESSAGE.TITLE}">${title}</span>
|
|
78
|
-
${renderSupportingText(supportingText, CLASS_NAMES.MESSAGE.SUPPORTING_TEXT)}
|
|
79
|
-
</div>
|
|
80
|
-
</div>
|
|
81
|
-
<div class="${CLASS_NAMES.MESSAGE.ACTIONS_CONTAINER}">
|
|
82
|
-
${actions && actions.length > 0 ? renderActions(actions, CLASS_NAMES.MESSAGE.ACTIONS) : ''}
|
|
83
|
-
</div>
|
|
84
|
-
<div class="${CLASS_NAMES.MESSAGE.ACTIONS_CONTAINER}">
|
|
85
|
-
${this.renderHidePermanentlyButton(onHidePermanently)}
|
|
86
|
-
${this.renderCloseButton(onClose)}
|
|
87
|
-
</div>
|
|
88
|
-
</div>
|
|
89
|
-
</div>
|
|
90
|
-
`;
|
|
91
|
-
}
|
|
92
|
-
renderHidePermanentlyButton(onHidePermanently) {
|
|
93
|
-
if (!onHidePermanently) return '';
|
|
94
|
-
return `
|
|
95
|
-
<button type="button" class="${CLASS_NAMES.COMMON.ACTION_BUTTON} ${CLASS_NAMES.COMMON.ACTION_BUTTON}--text ${CLASS_NAMES.MESSAGE.HIDE_LINK}" data-hide-permanently="true">
|
|
96
|
-
다시 보지 않기
|
|
97
|
-
</button>
|
|
98
|
-
`;
|
|
99
|
-
}
|
|
100
|
-
renderCloseButton(onClose) {
|
|
101
|
-
if (!onClose) return '';
|
|
102
|
-
return `
|
|
103
|
-
<button type="button" class="${CLASS_NAMES.MESSAGE.CLOSE_BUTTON}" aria-label="알림 닫기">
|
|
104
|
-
${SVG_ICONS['x-close'](MESSAGE_SIZES.CLOSE_BUTTON).replace('stroke="currentColor"', `stroke="#2F2F30"`)}
|
|
105
|
-
</button>
|
|
106
|
-
`;
|
|
107
|
-
}
|
|
108
70
|
bindEvents() {
|
|
109
71
|
bindNotificationEvents(this.element, this.options.actions, this.options.onClose, () => this.remove());
|
|
110
72
|
// 다시보지 않기 버튼 이벤트 바인딩
|
|
@@ -35,6 +35,9 @@ export const CLASS_NAMES = {
|
|
|
35
35
|
SUPPORTING_TEXT: 'ncua-message-notification__supporting-text',
|
|
36
36
|
ACTIONS_CONTAINER: 'ncua-message-notification__actions-container',
|
|
37
37
|
ACTIONS: 'ncua-message-notification__actions',
|
|
38
|
+
// 다시 보지 않기 + 닫기 그룹 전용 래퍼. ACTIONS_CONTAINER를 재사용하면
|
|
39
|
+
// 해당 클래스의 gap(12px)이 그룹 내부에도 적용되어 8px 규격이 깨진다.
|
|
40
|
+
FOOTER_CONTAINER: 'ncua-message-notification__footer-container',
|
|
38
41
|
HIDE_LINK: 'ncua-message-notification__hide-link',
|
|
39
42
|
CLOSE_BUTTON: 'ncua-message-notification__close-button'
|
|
40
43
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export
|
|
1
|
+
// Re-export all constants and types from separate files
|
|
2
2
|
export { CLASS_NAMES } from './classNames';
|
|
3
|
-
export {
|
|
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';
|
|
4
5
|
export { MESSAGE_CLOSE_ICON_COLORS } from './types';
|
|
@@ -26,9 +26,11 @@ export const FULL_WIDTH_SIZES = {
|
|
|
26
26
|
CLOSE_BUTTON: '20'
|
|
27
27
|
};
|
|
28
28
|
// Message 알림 고정 사이즈
|
|
29
|
+
// FEATURED_ICON(원 크기)과 ICON_PIXEL(내부 SVG 크기)은 항상 짝을 맞춰야 한다.
|
|
30
|
+
// 'md' = 40px 원 / 20px 아이콘 (FeaturedIcon iconSizeMap 기준)
|
|
29
31
|
export const MESSAGE_SIZES = {
|
|
30
|
-
FEATURED_ICON: '
|
|
31
|
-
ICON_PIXEL: '
|
|
32
|
+
FEATURED_ICON: 'md',
|
|
33
|
+
ICON_PIXEL: '20',
|
|
32
34
|
CLOSE_BUTTON: '20'
|
|
33
35
|
};
|
|
34
36
|
// 사이즈 유틸리티 함수들
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { HIDE_PERMANENTLY_LABEL } from '../../../constant/notification';
|
|
2
|
+
import { CLASS_NAMES, MESSAGE_SIZES, SVG_ICONS } from './const';
|
|
3
|
+
import { renderActions, renderSupportingText } from './utils';
|
|
4
|
+
/**
|
|
5
|
+
* message 타입 액션 버튼 사이즈. TO-BE 규격 28px이며 React `<Button size="xs">`와 같다.
|
|
6
|
+
* floating / full-width는 이 값을 쓰지 않고 `renderActions`의 기본값('sm')을 유지한다.
|
|
7
|
+
*/
|
|
8
|
+
const ACTION_BUTTON_SIZE = 'xs';
|
|
9
|
+
/**
|
|
10
|
+
* Message Notification의 마크업을 만든다.
|
|
11
|
+
* React 구현(`src/components/overlays/notification/MessageNotification.tsx`)과
|
|
12
|
+
* 동일한 클래스 트리를 산출해야 한다 — SCSS 한 벌을 두 구현이 공유한다.
|
|
13
|
+
*/
|
|
14
|
+
export function buildMessageTemplate(params) {
|
|
15
|
+
const {
|
|
16
|
+
title,
|
|
17
|
+
supportingText,
|
|
18
|
+
actions,
|
|
19
|
+
onClose,
|
|
20
|
+
onHidePermanently,
|
|
21
|
+
hidePermanentlyLabel
|
|
22
|
+
} = params;
|
|
23
|
+
return `
|
|
24
|
+
<div class="${CLASS_NAMES.MESSAGE.CONTAINER}">
|
|
25
|
+
<div class="${CLASS_NAMES.MESSAGE.CONTENT}">
|
|
26
|
+
<div class="${CLASS_NAMES.MESSAGE.CONTENT_WRAPPER}">
|
|
27
|
+
<div class="${CLASS_NAMES.MESSAGE.TEXT_CONTAINER}">
|
|
28
|
+
<span class="${CLASS_NAMES.MESSAGE.TITLE}">${title}</span>
|
|
29
|
+
${renderSupportingText(supportingText, CLASS_NAMES.MESSAGE.SUPPORTING_TEXT)}
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
${renderActionsContainer({
|
|
33
|
+
actions,
|
|
34
|
+
onClose,
|
|
35
|
+
onHidePermanently,
|
|
36
|
+
hidePermanentlyLabel
|
|
37
|
+
})}
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 액션 버튼 그룹과 닫기 그룹을 함께 감싸는 우측 영역.
|
|
44
|
+
* 이 컨테이너의 gap(12px)이 두 그룹 사이 간격을 만든다.
|
|
45
|
+
* 표시할 요소가 하나도 없으면 빈 컨테이너를 남기지 않는다.
|
|
46
|
+
*/
|
|
47
|
+
function renderActionsContainer(params) {
|
|
48
|
+
const {
|
|
49
|
+
actions,
|
|
50
|
+
onClose,
|
|
51
|
+
onHidePermanently,
|
|
52
|
+
hidePermanentlyLabel
|
|
53
|
+
} = params;
|
|
54
|
+
const actionsHtml = renderActions(actions ?? [], CLASS_NAMES.MESSAGE.ACTIONS, ACTION_BUTTON_SIZE);
|
|
55
|
+
const footerHtml = renderFooterContainer({
|
|
56
|
+
onClose,
|
|
57
|
+
onHidePermanently,
|
|
58
|
+
hidePermanentlyLabel
|
|
59
|
+
});
|
|
60
|
+
if (!actionsHtml && !footerHtml) return '';
|
|
61
|
+
return `<div class="${CLASS_NAMES.MESSAGE.ACTIONS_CONTAINER}">${actionsHtml}${footerHtml}</div>`;
|
|
62
|
+
}
|
|
63
|
+
/** 다시 보지 않기 + 닫기 그룹. 전용 래퍼를 쓰는 이유는 `CLASS_NAMES.MESSAGE.FOOTER_CONTAINER` 참조. */
|
|
64
|
+
function renderFooterContainer(params) {
|
|
65
|
+
const {
|
|
66
|
+
onClose,
|
|
67
|
+
onHidePermanently,
|
|
68
|
+
hidePermanentlyLabel
|
|
69
|
+
} = params;
|
|
70
|
+
if (!onHidePermanently && !onClose) return '';
|
|
71
|
+
return `
|
|
72
|
+
<div class="${CLASS_NAMES.MESSAGE.FOOTER_CONTAINER}">
|
|
73
|
+
${renderHidePermanentlyButton(onHidePermanently, hidePermanentlyLabel)}
|
|
74
|
+
${renderCloseButton(onClose)}
|
|
75
|
+
</div>
|
|
76
|
+
`;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 다시 보지 않기 버튼.
|
|
80
|
+
*
|
|
81
|
+
* `label`은 이 함수의 반환값이 `wrapper.innerHTML`에 들어가기 전에 `sanitizeHtml`로
|
|
82
|
+
* 처리되므로 별도 이스케이프하지 않는다 — `renderSupportingText`와 같은 정책이다.
|
|
83
|
+
*/
|
|
84
|
+
function renderHidePermanentlyButton(onHidePermanently, hidePermanentlyLabel) {
|
|
85
|
+
if (!onHidePermanently) return '';
|
|
86
|
+
const label = hidePermanentlyLabel ?? HIDE_PERMANENTLY_LABEL.message;
|
|
87
|
+
return `
|
|
88
|
+
<button type="button" class="${CLASS_NAMES.COMMON.ACTION_BUTTON} ${CLASS_NAMES.MESSAGE.HIDE_LINK}" data-hide-permanently="true">
|
|
89
|
+
${label}
|
|
90
|
+
</button>
|
|
91
|
+
`;
|
|
92
|
+
}
|
|
93
|
+
function renderCloseButton(onClose) {
|
|
94
|
+
if (!onClose) return '';
|
|
95
|
+
return `
|
|
96
|
+
<button type="button" class="${CLASS_NAMES.MESSAGE.CLOSE_BUTTON}" aria-label="알림 닫기">
|
|
97
|
+
${SVG_ICONS['x-close'](MESSAGE_SIZES.CLOSE_BUTTON).replace('stroke="currentColor"', 'stroke="#2F2F30"')}
|
|
98
|
+
</button>
|
|
99
|
+
`;
|
|
100
|
+
}
|
|
@@ -45,16 +45,51 @@ export function renderSupportingText(supportingText, className, supportTextLink)
|
|
|
45
45
|
// unsafe URL이거나 link가 없으면 링크 없이 텍스트만 렌더링
|
|
46
46
|
return `<span class="${className}">${supportingText}</span>`;
|
|
47
47
|
}
|
|
48
|
+
/** 액션 버튼 색상을 지정하지 않았을 때의 기본값. React `MessageNotificationParts`와 같다. */
|
|
49
|
+
const DEFAULT_ACTION_HIERARCHY = 'text';
|
|
50
|
+
/**
|
|
51
|
+
* 액션 버튼의 색상 수식자를 현행 어휘로 정규화한다.
|
|
52
|
+
*
|
|
53
|
+
* 구 어휘(`'link'` / `'link-gray'`)는 Link 컴포넌트의 색상 이름을 빌려 쓴 것이라
|
|
54
|
+
* `ncua-btn--link`에 대응하는 CSS가 존재하지 않았다. 기존 CDN 사용처를 깨지 않기 위해
|
|
55
|
+
* 타입에서 제거하는 대신 이 지점에서 실제 Button 테마로 매핑한다.
|
|
56
|
+
*
|
|
57
|
+
* 렌더(`renderActions`)와 이벤트 바인딩(`bindNotificationEvents`)이 이 함수를 함께 써야
|
|
58
|
+
* `data-action` 키가 어긋나지 않는다.
|
|
59
|
+
*/
|
|
60
|
+
export function resolveActionHierarchy(hierarchy) {
|
|
61
|
+
switch (hierarchy) {
|
|
62
|
+
case undefined:
|
|
63
|
+
return DEFAULT_ACTION_HIERARCHY;
|
|
64
|
+
case 'link':
|
|
65
|
+
return 'text';
|
|
66
|
+
case 'link-gray':
|
|
67
|
+
return 'text-gray';
|
|
68
|
+
default:
|
|
69
|
+
return hierarchy;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** 액션 버튼의 클릭 라우팅 키. 렌더와 바인딩이 같은 규칙으로 만들어야 한다. */
|
|
73
|
+
function buildActionKey(action) {
|
|
74
|
+
return `${action.label}-${resolveActionHierarchy(action.hierarchy)}`;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 액션 버튼 그룹 HTML을 만든다.
|
|
78
|
+
*
|
|
79
|
+
* `size` 기본값 'sm'은 floating / full-width 타입의 기존 렌더링을 그대로 보존하기 위한 것이다.
|
|
80
|
+
* message 타입만 TO-BE 규격(28px)에 맞춰 'xs'를 넘긴다 — React `<Button size="xs">`와 동일.
|
|
81
|
+
*/
|
|
48
82
|
export function renderActions(actions, wrapperClass) {
|
|
83
|
+
let size = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'sm';
|
|
49
84
|
// 액션이 없으면 빈 문자열 반환
|
|
50
85
|
if (!actions || actions.length === 0) {
|
|
51
86
|
return '';
|
|
52
87
|
}
|
|
53
88
|
const buttonsHtml = actions.map(action => {
|
|
54
89
|
const buttonHtml = `
|
|
55
|
-
<button
|
|
56
|
-
class="ncua-btn ncua-btn
|
|
57
|
-
data-action="${action
|
|
90
|
+
<button
|
|
91
|
+
class="ncua-btn ncua-btn--${size} ncua-btn--${resolveActionHierarchy(action.hierarchy)}"
|
|
92
|
+
data-action="${buildActionKey(action)}"
|
|
58
93
|
>
|
|
59
94
|
${action.label}
|
|
60
95
|
</button>`;
|
|
@@ -80,7 +115,7 @@ export function bindNotificationEvents(element, actions, onClose, onRemove) {
|
|
|
80
115
|
if (actionData) {
|
|
81
116
|
let matchedAction = null;
|
|
82
117
|
for (const action of actions) {
|
|
83
|
-
const expectedDataAction =
|
|
118
|
+
const expectedDataAction = buildActionKey(action);
|
|
84
119
|
if (actionData === expectedDataAction) {
|
|
85
120
|
matchedAction = action;
|
|
86
121
|
break;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 다시보지 않기 버튼의 타입별 기본 문구.
|
|
3
|
+
*
|
|
4
|
+
* `hidePermanentlyLabel`을 지정하지 않았을 때 쓰인다.
|
|
5
|
+
* React(`src/components/overlays/notification/`)와 Vanilla(`assets/scripts/notification/`)
|
|
6
|
+
* 두 구현이 이 상수를 함께 참조한다 — 문구가 하드코딩으로 흩어져 서로 어긋나던 문제(#460)를
|
|
7
|
+
* 막기 위한 단일 출처다.
|
|
8
|
+
*
|
|
9
|
+
* `message`와 `fullWidth`의 띄어쓰기가 다른 것은 오타가 아니라 현행 유지다.
|
|
10
|
+
* 표기 통일은 별도 결정 사항이며, 결정되면 이 파일 한 곳만 고치면 된다.
|
|
11
|
+
*/
|
|
12
|
+
export const HIDE_PERMANENTLY_LABEL = {
|
|
13
|
+
message: '다시 보지 않기',
|
|
14
|
+
fullWidth: '다시보지 않기'
|
|
15
|
+
};
|
|
@@ -5,11 +5,9 @@ import { forwardRef, useEffect, useRef, useState } from 'react';
|
|
|
5
5
|
import { COLOR } from '../../../../constant/color';
|
|
6
6
|
import { HintText } from '../../shared/hintText/HintText';
|
|
7
7
|
import { Label } from '../../shared/label/Label';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
const generalSvgSize = {
|
|
8
|
+
// 슬롯 아이콘(leadingElement/trailingElement)과 상태 아이콘(clear·validation·destructive)은 같은 크기를 쓴다.
|
|
9
|
+
// slot.size 를 명시하면 그 값이 우선한다.
|
|
10
|
+
const iconSvgSize = {
|
|
13
11
|
xs: 14,
|
|
14
12
|
sm: 20
|
|
15
13
|
};
|
|
@@ -34,20 +32,28 @@ const InputBase = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
34
32
|
...props
|
|
35
33
|
} = _ref;
|
|
36
34
|
const inputRef = useRef(null);
|
|
37
|
-
|
|
35
|
+
// controlled 인풋은 props.value 로 길이를 알 수 있으므로 상태를 두지 않는다.
|
|
36
|
+
// 입력마다 setState 를 하면 조합 중(한글 IME)에 리렌더가 끼어들어 조합이 끊긴다.
|
|
37
|
+
const isControlled = props.value !== undefined;
|
|
38
|
+
const [uncontrolledLength, setUncontrolledLength] = useState(0);
|
|
39
|
+
const valueLength = isControlled ? String(props.value ?? '').length : uncontrolledLength;
|
|
40
|
+
const hasValue = valueLength > 0;
|
|
41
|
+
const textCount = valueLength;
|
|
42
|
+
// uncontrolled 인풋만 DOM 값을 읽어 따라간다 — props.value 가 없어 길이를 알 방법이 이것뿐이다.
|
|
38
43
|
useEffect(() => {
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
if (isControlled) return;
|
|
45
|
+
const input = inputRef.current;
|
|
46
|
+
if (!input) return;
|
|
47
|
+
const syncFromInput = () => {
|
|
48
|
+
setUncontrolledLength(input.value.length);
|
|
49
|
+
};
|
|
50
|
+
syncFromInput();
|
|
51
|
+
input.addEventListener('input', syncFromInput);
|
|
52
|
+
return () => {
|
|
53
|
+
input.removeEventListener('input', syncFromInput);
|
|
54
|
+
};
|
|
55
|
+
}, [isControlled]);
|
|
56
|
+
const renderOutsideSlot = (slot, position) => {
|
|
51
57
|
if (slot.type === 'custom' && slot.placement !== 'outside') {
|
|
52
58
|
return null;
|
|
53
59
|
}
|
|
@@ -60,10 +66,15 @@ const InputBase = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
60
66
|
children: slot.label
|
|
61
67
|
});
|
|
62
68
|
case 'text':
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
{
|
|
70
|
+
// 클래스명은 리터럴로 쓴다 — MCP 의 BEM 추출기가 `ncua-input__${position}-text` 형태의
|
|
71
|
+
// 템플릿 리터럴에서는 `ncua-input__` 조각만 읽어 완성된 클래스를 잡지 못한다.
|
|
72
|
+
const textClass = position === 'leading' ? 'ncua-input__leading-text' : 'ncua-input__trailing-text';
|
|
73
|
+
return _jsx("span", {
|
|
74
|
+
className: classNames(textClass, `${textClass}--${size}`),
|
|
75
|
+
children: slot.text
|
|
76
|
+
});
|
|
77
|
+
}
|
|
67
78
|
case 'custom':
|
|
68
79
|
return slot.children;
|
|
69
80
|
default:
|
|
@@ -78,10 +89,15 @@ const InputBase = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
78
89
|
return _jsx("div", {
|
|
79
90
|
className: "ncua-input__icon-wrap",
|
|
80
91
|
children: _jsx(SlotIcon, {
|
|
81
|
-
className: classNames(`ncua-input__${position}-icon`,
|
|
92
|
+
className: classNames(`ncua-input__${position}-icon`,
|
|
93
|
+
// color 를 지정하지 않았을 때만 상태별 색(Placeholder/Filled/Focused/Disabled)을 CSS 에 맡긴다.
|
|
94
|
+
// 지정한 경우에는 이 클래스를 붙이지 않아 지정 색이 그대로 유지된다.
|
|
95
|
+
{
|
|
96
|
+
'ncua-input__slot-icon': !slot.color
|
|
97
|
+
}, slot.className),
|
|
82
98
|
color: slot.color ? COLOR[slot.color] : undefined,
|
|
83
|
-
width: slot.size ??
|
|
84
|
-
height: slot.size ??
|
|
99
|
+
width: slot.size ?? iconSvgSize[size],
|
|
100
|
+
height: slot.size ?? iconSvgSize[size]
|
|
85
101
|
})
|
|
86
102
|
});
|
|
87
103
|
}
|
|
@@ -102,8 +118,8 @@ const InputBase = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
102
118
|
onClick: onClearText,
|
|
103
119
|
children: _jsx(X, {
|
|
104
120
|
className: "ncua-input__clear-icon",
|
|
105
|
-
width:
|
|
106
|
-
height:
|
|
121
|
+
width: iconSvgSize[size],
|
|
122
|
+
height: iconSvgSize[size]
|
|
107
123
|
})
|
|
108
124
|
});
|
|
109
125
|
};
|
|
@@ -113,8 +129,8 @@ const InputBase = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
113
129
|
className: "ncua-input__icon-wrap ncua-input__right-icon",
|
|
114
130
|
children: _jsx(InfoCircle, {
|
|
115
131
|
className: "ncua-input__destructive-icon",
|
|
116
|
-
width:
|
|
117
|
-
height:
|
|
132
|
+
width: iconSvgSize[size],
|
|
133
|
+
height: iconSvgSize[size]
|
|
118
134
|
})
|
|
119
135
|
});
|
|
120
136
|
}
|
|
@@ -123,8 +139,8 @@ const InputBase = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
123
139
|
className: "ncua-input__icon-wrap ncua-input__right-icon",
|
|
124
140
|
children: _jsx(CheckCircle, {
|
|
125
141
|
className: "ncua-input__validation-icon",
|
|
126
|
-
width:
|
|
127
|
-
height:
|
|
142
|
+
width: iconSvgSize[size],
|
|
143
|
+
height: iconSvgSize[size]
|
|
128
144
|
})
|
|
129
145
|
});
|
|
130
146
|
}
|
|
@@ -149,13 +165,15 @@ const InputBase = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
149
165
|
'is-disabled': disabled,
|
|
150
166
|
'full-width': fullWidth,
|
|
151
167
|
'ncua-input__trailing-button': trailingElement?.type === 'button',
|
|
152
|
-
'ncua-input__leading-text-wrap': leadingElement?.type === 'text'
|
|
168
|
+
'ncua-input__leading-text-wrap': leadingElement?.type === 'text',
|
|
169
|
+
'ncua-input__trailing-text-wrap': trailingElement?.type === 'text',
|
|
170
|
+
'has-value': hasValue
|
|
153
171
|
}, className),
|
|
154
172
|
children: [renderLabel(), _jsxs("div", {
|
|
155
173
|
className: "ncua-input__content-wrap",
|
|
156
174
|
children: [_jsxs("div", {
|
|
157
175
|
className: "ncua-input__content",
|
|
158
|
-
children: [leadingElement && renderOutsideSlot(leadingElement), _jsxs("div", {
|
|
176
|
+
children: [leadingElement && renderOutsideSlot(leadingElement, 'leading'), _jsxs("div", {
|
|
159
177
|
className: classNames('ncua-input__field', `ncua-input__field--${size}`),
|
|
160
178
|
children: [leadingElement && renderInsideSlot(leadingElement, 'left'), _jsx("input", {
|
|
161
179
|
ref: node => {
|
|
@@ -171,7 +189,7 @@ const InputBase = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
171
189
|
maxLength: maxLength,
|
|
172
190
|
...props
|
|
173
191
|
}), renderClearButton(), renderStatusIcon(), trailingElement && renderInsideSlot(trailingElement, 'right')]
|
|
174
|
-
}), trailingElement && renderOutsideSlot(trailingElement)]
|
|
192
|
+
}), trailingElement && renderOutsideSlot(trailingElement, 'trailing')]
|
|
175
193
|
}), showTextCount && maxLength && _jsxs("div", {
|
|
176
194
|
className: "ncua-input__field-text-count",
|
|
177
195
|
children: [_jsx("output", {
|