@ncds/ui-admin 1.8.26-alpha.3 → 1.8.26-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/assets/scripts/notification/FloatingNotification.js +23 -7
- package/dist/cjs/assets/scripts/notification/FullWidthNotification.js +14 -3
- package/dist/cjs/assets/scripts/notification/MessageNotification.js +3 -0
- package/dist/cjs/assets/scripts/notification/Notification.js +8 -2
- package/dist/cjs/assets/scripts/notification/messageTemplate.js +21 -5
- package/dist/cjs/constant/notification.js +8 -2
- package/dist/cjs/src/components/overlays/notification/FloatingNotification.js +10 -28
- package/dist/cjs/src/components/overlays/notification/FullWidthNotification.js +9 -24
- package/dist/cjs/src/components/overlays/notification/MessageNotification.js +12 -0
- package/dist/cjs/src/components/overlays/notification/MessageNotificationParts.js +5 -2
- package/dist/cjs/src/components/overlays/notification/Notification.js +1 -0
- package/dist/cjs/src/components/overlays/notification/__tests__/CalloutNotification.test.js +8 -2
- package/dist/cjs/src/components/overlays/notification/__tests__/Notification.test.js +176 -0
- package/dist/cjs/src/components/overlays/notification/useAutoClose.js +39 -0
- package/dist/cjs/src/utils/notification/__tests__/resolveAutoClose.test.js +44 -0
- package/dist/cjs/src/utils/notification/index.js +12 -0
- package/dist/cjs/src/utils/notification/resolveAutoClose.js +22 -0
- package/dist/esm/assets/scripts/notification/FloatingNotification.js +23 -7
- package/dist/esm/assets/scripts/notification/FullWidthNotification.js +14 -3
- package/dist/esm/assets/scripts/notification/MessageNotification.js +3 -0
- package/dist/esm/assets/scripts/notification/Notification.js +8 -2
- package/dist/esm/assets/scripts/notification/messageTemplate.js +21 -5
- package/dist/esm/constant/notification.js +7 -1
- package/dist/esm/src/components/overlays/notification/FloatingNotification.js +11 -29
- package/dist/esm/src/components/overlays/notification/FullWidthNotification.js +10 -25
- package/dist/esm/src/components/overlays/notification/MessageNotification.js +12 -0
- package/dist/esm/src/components/overlays/notification/MessageNotificationParts.js +5 -2
- package/dist/esm/src/components/overlays/notification/Notification.js +1 -0
- package/dist/esm/src/components/overlays/notification/__tests__/CalloutNotification.test.js +9 -3
- package/dist/esm/src/components/overlays/notification/__tests__/Notification.test.js +177 -1
- package/dist/esm/src/components/overlays/notification/useAutoClose.js +32 -0
- package/dist/esm/src/utils/notification/__tests__/resolveAutoClose.test.js +42 -0
- package/dist/esm/src/utils/notification/index.js +1 -0
- package/dist/esm/src/utils/notification/resolveAutoClose.js +15 -0
- package/dist/temp/assets/scripts/notification/FloatingNotification.js +10 -6
- package/dist/temp/assets/scripts/notification/FullWidthNotification.js +8 -5
- package/dist/temp/assets/scripts/notification/MessageNotification.js +3 -1
- package/dist/temp/assets/scripts/notification/Notification.js +7 -1
- package/dist/temp/assets/scripts/notification/const/types.d.ts +7 -0
- package/dist/temp/assets/scripts/notification/messageTemplate.d.ts +1 -0
- package/dist/temp/assets/scripts/notification/messageTemplate.js +19 -9
- package/dist/temp/constant/notification.d.ts +6 -0
- package/dist/temp/constant/notification.js +6 -0
- package/dist/temp/src/components/overlays/notification/FloatingNotification.d.ts +8 -0
- package/dist/temp/src/components/overlays/notification/FloatingNotification.js +6 -29
- package/dist/temp/src/components/overlays/notification/FullWidthNotification.d.ts +7 -0
- package/dist/temp/src/components/overlays/notification/FullWidthNotification.js +6 -25
- package/dist/temp/src/components/overlays/notification/MessageNotification.d.ts +12 -0
- package/dist/temp/src/components/overlays/notification/MessageNotification.js +8 -2
- package/dist/temp/src/components/overlays/notification/MessageNotificationParts.d.ts +2 -1
- package/dist/temp/src/components/overlays/notification/MessageNotificationParts.js +5 -3
- package/dist/temp/src/components/overlays/notification/Notification.d.ts +14 -1
- package/dist/temp/src/components/overlays/notification/Notification.js +1 -1
- package/dist/temp/src/components/overlays/notification/__tests__/CalloutNotification.test.js +8 -1
- package/dist/temp/src/components/overlays/notification/__tests__/Notification.test.js +128 -1
- package/dist/temp/src/components/overlays/notification/useAutoClose.d.ts +15 -0
- package/dist/temp/src/components/overlays/notification/useAutoClose.js +25 -0
- package/dist/temp/src/utils/notification/__tests__/resolveAutoClose.test.d.ts +1 -0
- package/dist/temp/src/utils/notification/__tests__/resolveAutoClose.test.js +22 -0
- package/dist/temp/src/utils/notification/index.d.ts +1 -0
- package/dist/temp/src/utils/notification/index.js +1 -0
- package/dist/temp/src/utils/notification/resolveAutoClose.d.ts +14 -0
- package/dist/temp/src/utils/notification/resolveAutoClose.js +12 -0
- package/dist/types/assets/scripts/notification/const/types.d.ts +7 -0
- package/dist/types/assets/scripts/notification/messageTemplate.d.ts +1 -0
- package/dist/types/constant/notification.d.ts +6 -0
- package/dist/types/src/components/overlays/notification/FloatingNotification.d.ts +8 -0
- package/dist/types/src/components/overlays/notification/FullWidthNotification.d.ts +7 -0
- package/dist/types/src/components/overlays/notification/MessageNotification.d.ts +12 -0
- package/dist/types/src/components/overlays/notification/MessageNotificationParts.d.ts +2 -1
- package/dist/types/src/components/overlays/notification/Notification.d.ts +14 -1
- package/dist/types/src/components/overlays/notification/useAutoClose.d.ts +15 -0
- package/dist/types/src/utils/notification/__tests__/resolveAutoClose.test.d.ts +1 -0
- package/dist/types/src/utils/notification/index.d.ts +1 -0
- package/dist/types/src/utils/notification/resolveAutoClose.d.ts +14 -0
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { HIDE_CLOSE_BUTTON_AUTO_CLOSE_MS } from '../../../../constant/notification';
|
|
3
|
+
import { resolveAutoClose } from '../resolveAutoClose';
|
|
4
|
+
const EXPLICIT_MS = 5000;
|
|
5
|
+
const FALLBACK_MS = 4000;
|
|
6
|
+
const NO_AUTO_CLOSE = 0;
|
|
7
|
+
describe('resolveAutoClose', () => {
|
|
8
|
+
it('autoClose 를 명시하면 hideCloseButton·fallback 과 무관하게 그대로 쓴다 (0 포함)', () => {
|
|
9
|
+
expect(resolveAutoClose({ autoClose: EXPLICIT_MS, hideCloseButton: true, fallback: FALLBACK_MS })).toBe(EXPLICIT_MS);
|
|
10
|
+
expect(resolveAutoClose({ autoClose: NO_AUTO_CLOSE, hideCloseButton: true, fallback: FALLBACK_MS })).toBe(NO_AUTO_CLOSE);
|
|
11
|
+
});
|
|
12
|
+
it('autoClose 미지정이면 fallback 이 양수일 때 fallback 을 쓴다', () => {
|
|
13
|
+
expect(resolveAutoClose({ fallback: FALLBACK_MS })).toBe(FALLBACK_MS);
|
|
14
|
+
expect(resolveAutoClose({ hideCloseButton: true, fallback: FALLBACK_MS })).toBe(FALLBACK_MS);
|
|
15
|
+
});
|
|
16
|
+
it('autoClose·fallback 모두 없으면 hideCloseButton 일 때만 기본 3초를 준다', () => {
|
|
17
|
+
expect(resolveAutoClose({ hideCloseButton: true })).toBe(HIDE_CLOSE_BUTTON_AUTO_CLOSE_MS);
|
|
18
|
+
expect(resolveAutoClose({ hideCloseButton: true, fallback: NO_AUTO_CLOSE })).toBe(HIDE_CLOSE_BUTTON_AUTO_CLOSE_MS);
|
|
19
|
+
expect(resolveAutoClose({ hideCloseButton: false })).toBe(NO_AUTO_CLOSE);
|
|
20
|
+
expect(resolveAutoClose({})).toBe(NO_AUTO_CLOSE);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { resolveAutoClose } from './resolveAutoClose';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { resolveAutoClose } from './resolveAutoClose';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface ResolveAutoCloseParams {
|
|
2
|
+
/** 사용처가 명시한 autoClose(ms). `0`이면 자동 닫힘 없음 — 부모가 직접 닫는 용도. */
|
|
3
|
+
autoClose?: number;
|
|
4
|
+
/** floating(토스트)만 넘긴다 — 닫기 버튼이 없는 토스트가 영구히 남지 않게 기본 3초를 준다. */
|
|
5
|
+
hideCloseButton?: boolean;
|
|
6
|
+
/** 색상별 기본값 등 2순위 기본값. */
|
|
7
|
+
fallback?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 실제 적용할 autoClose(ms)를 정한다. React·Vanilla 두 구현이 공유한다.
|
|
11
|
+
* 우선순위: 명시 `autoClose` > `fallback`(양수) > `hideCloseButton`이면 3초 > 0.
|
|
12
|
+
*/
|
|
13
|
+
export declare const resolveAutoClose: ({ autoClose, hideCloseButton, fallback, }: ResolveAutoCloseParams) => number;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HIDE_CLOSE_BUTTON_AUTO_CLOSE_MS } from '../../../constant/notification';
|
|
2
|
+
/**
|
|
3
|
+
* 실제 적용할 autoClose(ms)를 정한다. React·Vanilla 두 구현이 공유한다.
|
|
4
|
+
* 우선순위: 명시 `autoClose` > `fallback`(양수) > `hideCloseButton`이면 3초 > 0.
|
|
5
|
+
*/
|
|
6
|
+
export const resolveAutoClose = ({ autoClose, hideCloseButton = false, fallback = 0, }) => {
|
|
7
|
+
if (autoClose !== undefined)
|
|
8
|
+
return autoClose;
|
|
9
|
+
if (fallback > 0)
|
|
10
|
+
return fallback;
|
|
11
|
+
return hideCloseButton ? HIDE_CLOSE_BUTTON_AUTO_CLOSE_MS : 0;
|
|
12
|
+
};
|
|
@@ -40,6 +40,13 @@ export interface BaseNotificationOptions {
|
|
|
40
40
|
supportingText?: string;
|
|
41
41
|
color?: NotificationColor;
|
|
42
42
|
onClose?: () => void;
|
|
43
|
+
/**
|
|
44
|
+
* 닫기(X) 버튼 숨김 여부. `true`면 `onClose`가 있어도 X 버튼을 렌더하지 않는다.
|
|
45
|
+
* autoClose 만료 시 `onClose` 호출은 그대로 유지된다. 기본값 `false`.
|
|
46
|
+
* floating 은 `autoClose` 미지정 시 3초 뒤 자동으로 닫힌다(직접 `remove()` 로 닫으려면 `autoClose: 0` 명시).
|
|
47
|
+
* full-width · message 는 `autoClose` 를 명시했을 때만 자동으로 닫힌다.
|
|
48
|
+
*/
|
|
49
|
+
hideCloseButton?: boolean;
|
|
43
50
|
className?: string;
|
|
44
51
|
actions?: NotificationAction[];
|
|
45
52
|
autoClose?: number;
|
|
@@ -26,3 +26,9 @@ export declare const MESSAGE_CLOSE_ICON_COLOR: {
|
|
|
26
26
|
readonly success: string;
|
|
27
27
|
readonly info: string;
|
|
28
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* floating(토스트)에서 `hideCloseButton`인데 `autoClose`를 지정하지 않았을 때 적용되는 자동 닫힘 시간(ms).
|
|
31
|
+
* 닫기 버튼이 없는 토스트가 영구히 남지 않게 한다 — DES-SPEC-027 §5.3 Toast Alert 3초.
|
|
32
|
+
* full-width · message 는 부모가 언마운트로 닫으므로 적용하지 않는다.
|
|
33
|
+
*/
|
|
34
|
+
export declare const HIDE_CLOSE_BUTTON_AUTO_CLOSE_MS = 3000;
|
|
@@ -18,6 +18,13 @@ interface FloatingNotificationProps extends Omit<ComponentPropsWithoutRef<'div'>
|
|
|
18
18
|
* 닫기 버튼 클릭 이벤트 핸들러
|
|
19
19
|
*/
|
|
20
20
|
onClose?: () => void;
|
|
21
|
+
/**
|
|
22
|
+
* 닫기(X) 버튼 숨김 여부. `true`면 `onClose`가 있어도 X 버튼을 렌더하지 않는다.
|
|
23
|
+
* autoClose 만료·모바일 전환 시 `onClose` 호출은 그대로 유지된다.
|
|
24
|
+
* `autoClose` 미지정이면 3초 뒤 자동으로 닫힌다. 부모가 직접 언마운트하려면 `autoClose={0}`을 명시한다.
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
hideCloseButton?: boolean;
|
|
21
28
|
/**
|
|
22
29
|
* 추가 CSS 클래스
|
|
23
30
|
*/
|
|
@@ -28,6 +35,7 @@ interface FloatingNotificationProps extends Omit<ComponentPropsWithoutRef<'div'>
|
|
|
28
35
|
actions?: NotificationAction[];
|
|
29
36
|
/**
|
|
30
37
|
* 자동 닫기 시간 (밀리초 단위, 0이면 자동으로 닫히지 않음)
|
|
38
|
+
* 미지정 시 0. 단 `hideCloseButton`이면 3초.
|
|
31
39
|
* @default 0
|
|
32
40
|
*/
|
|
33
41
|
autoClose?: number;
|
|
@@ -18,6 +18,13 @@ interface FullWidthNotificationProps extends Omit<ComponentPropsWithoutRef<'div'
|
|
|
18
18
|
* 닫기 버튼 클릭 이벤트 핸들러
|
|
19
19
|
*/
|
|
20
20
|
onClose?: () => void;
|
|
21
|
+
/**
|
|
22
|
+
* 닫기(X) 버튼 숨김 여부. `true`면 `onClose`가 있어도 X 버튼을 렌더하지 않는다.
|
|
23
|
+
* autoClose 만료 시 `onClose` 호출은 그대로 유지된다.
|
|
24
|
+
* 기본 자동 닫힘은 없다 — 부모가 언마운트로 닫거나 `autoClose`를 명시한다.
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
hideCloseButton?: boolean;
|
|
21
28
|
/**
|
|
22
29
|
* 추가 CSS 클래스
|
|
23
30
|
*/
|
|
@@ -23,6 +23,18 @@ interface MessageNotificationProps extends Omit<ComponentPropsWithoutRef<'div'>,
|
|
|
23
23
|
* 닫기 버튼 클릭 이벤트 핸들러
|
|
24
24
|
*/
|
|
25
25
|
onClose?: () => void;
|
|
26
|
+
/**
|
|
27
|
+
* 닫기(X) 버튼 숨김 여부. `true`면 `onClose`가 있어도 X 버튼을 렌더하지 않는다.
|
|
28
|
+
* autoClose 만료 시 `onClose` 호출은 그대로 유지된다.
|
|
29
|
+
* 기본 자동 닫힘은 없다 — 부모가 언마운트로 닫거나 `autoClose`를 명시한다.
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
hideCloseButton?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* 자동 닫기 시간 (밀리초 단위, 0이면 자동으로 닫히지 않음)
|
|
35
|
+
* @default 0
|
|
36
|
+
*/
|
|
37
|
+
autoClose?: number;
|
|
26
38
|
/**
|
|
27
39
|
* 추가 CSS 클래스
|
|
28
40
|
*/
|
|
@@ -19,6 +19,7 @@ declare const MessageNotificationContent: ({ title, supportingText, supportTextL
|
|
|
19
19
|
interface MessageNotificationActionsProps {
|
|
20
20
|
actions?: NotificationAction[];
|
|
21
21
|
onClose?: () => void;
|
|
22
|
+
hideCloseButton?: boolean;
|
|
22
23
|
onHidePermanently?: () => void;
|
|
23
24
|
hidePermanentlyLabel?: ReactNode;
|
|
24
25
|
closeIconColor: string;
|
|
@@ -28,6 +29,6 @@ interface MessageNotificationActionsProps {
|
|
|
28
29
|
* 이 컨테이너의 gap(12px)이 두 그룹 사이 간격을 만든다.
|
|
29
30
|
* 표시할 요소가 하나도 없으면 빈 컨테이너를 남기지 않는다.
|
|
30
31
|
*/
|
|
31
|
-
declare const MessageNotificationActions: ({ actions, onClose, onHidePermanently, hidePermanentlyLabel, closeIconColor, }: MessageNotificationActionsProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
32
|
+
declare const MessageNotificationActions: ({ actions, onClose, hideCloseButton, onHidePermanently, hidePermanentlyLabel, closeIconColor, }: MessageNotificationActionsProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
32
33
|
export type { MessageNotificationActionsProps, MessageNotificationContentProps };
|
|
33
34
|
export { MessageNotificationActions, MessageNotificationContent };
|
|
@@ -51,6 +51,18 @@ interface NotificationProps extends Omit<ComponentPropsWithoutRef<'div'>, 'title
|
|
|
51
51
|
* 닫기 버튼 클릭 이벤트 핸들러
|
|
52
52
|
*/
|
|
53
53
|
onClose?: () => void;
|
|
54
|
+
/**
|
|
55
|
+
* 닫기(X) 버튼 숨김 여부. floating · full-width · message 타입에서 동작한다.
|
|
56
|
+
* `true`면 `onClose`가 있어도 X 버튼을 렌더하지 않는다.
|
|
57
|
+
* autoClose 만료(및 floating의 모바일 전환) 시 `onClose` 호출은 그대로 유지되므로,
|
|
58
|
+
* "닫기 버튼 없는 자동 닫힘 토스트"(DES-SPEC-027 §5.3)에서 부모가 닫힘 시점을 받을 수 있다.
|
|
59
|
+
*
|
|
60
|
+
* floating(토스트)은 닫을 수단이 사라지지 않도록 `autoClose` 미지정 시 3초 뒤 자동으로 닫힌다
|
|
61
|
+
* (부모가 직접 언마운트해 닫으려면 `autoClose={0}` 명시). full-width · message 는 부모가 언마운트로 닫으므로
|
|
62
|
+
* `autoClose`를 명시했을 때만 자동으로 닫힌다.
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
hideCloseButton?: boolean;
|
|
54
66
|
/**
|
|
55
67
|
* 추가 CSS 클래스
|
|
56
68
|
*/
|
|
@@ -62,7 +74,8 @@ interface NotificationProps extends Omit<ComponentPropsWithoutRef<'div'>, 'title
|
|
|
62
74
|
actions?: NotificationAction[];
|
|
63
75
|
/**
|
|
64
76
|
* 자동 닫기 시간 (밀리초 단위, 0이면 자동으로 닫히지 않음)
|
|
65
|
-
* floating
|
|
77
|
+
* floating, full-width, message 타입에서 동작
|
|
78
|
+
* 미지정 시 0. 단 floating 에서 `hideCloseButton`이면 3초(DES-SPEC-027 §5.3).
|
|
66
79
|
* @default 0
|
|
67
80
|
*/
|
|
68
81
|
autoClose?: number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface UseAutoCloseParams {
|
|
2
|
+
autoClose?: number;
|
|
3
|
+
/** floating 만 넘긴다 — 닫기 버튼 없는 토스트의 기본 3초 자동 닫힘. */
|
|
4
|
+
hideCloseButton?: boolean;
|
|
5
|
+
onClose?: () => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* autoClose 타이머. 만료 시 `onClose`를 호출하고 `true`(제거됨)를 반환한다.
|
|
9
|
+
* floating · full-width · message 가 공유한다.
|
|
10
|
+
*
|
|
11
|
+
* `onClose`는 매 렌더 새 함수일 수 있어 ref 로 latest 만 보관하고 deps 에서 뺀다 —
|
|
12
|
+
* 인라인 핸들러를 넘겨도 부모 리렌더마다 타이머가 리셋되지 않는다.
|
|
13
|
+
*/
|
|
14
|
+
export declare const useAutoClose: ({ autoClose, hideCloseButton, onClose }: UseAutoCloseParams) => boolean;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { resolveAutoClose } from './resolveAutoClose';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface ResolveAutoCloseParams {
|
|
2
|
+
/** 사용처가 명시한 autoClose(ms). `0`이면 자동 닫힘 없음 — 부모가 직접 닫는 용도. */
|
|
3
|
+
autoClose?: number;
|
|
4
|
+
/** floating(토스트)만 넘긴다 — 닫기 버튼이 없는 토스트가 영구히 남지 않게 기본 3초를 준다. */
|
|
5
|
+
hideCloseButton?: boolean;
|
|
6
|
+
/** 색상별 기본값 등 2순위 기본값. */
|
|
7
|
+
fallback?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 실제 적용할 autoClose(ms)를 정한다. React·Vanilla 두 구현이 공유한다.
|
|
11
|
+
* 우선순위: 명시 `autoClose` > `fallback`(양수) > `hideCloseButton`이면 3초 > 0.
|
|
12
|
+
*/
|
|
13
|
+
export declare const resolveAutoClose: ({ autoClose, hideCloseButton, fallback, }: ResolveAutoCloseParams) => number;
|
|
14
|
+
export {};
|