@uniai-fe/uds-templates 0.12.0 → 0.12.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/README.md +7 -0
- package/package.json +7 -7
- package/src/cctv/hooks/useFullscreen.ts +49 -10
package/README.md
CHANGED
|
@@ -39,6 +39,13 @@ import { Frame, Modal } from "@uniai-fe/uds-templates";
|
|
|
39
39
|
|
|
40
40
|
`@uniai-fe/uds-templates/src/**`와 export map에 없는 category path는 public API가 아니다.
|
|
41
41
|
|
|
42
|
+
### CCTV 전체화면
|
|
43
|
+
|
|
44
|
+
`useCctvFullscreen`은 서비스가 지정한 container를 전체화면으로 전환한다.
|
|
45
|
+
화면 방향 API를 지원하면 전체화면 동안 `landscape`를 요청하며, 종료·대상 제거 시
|
|
46
|
+
고정을 해제해 기본 방향 정책으로 돌아간다. 세로 방향 복귀를 강제하지 않는다.
|
|
47
|
+
방향 API 미지원·요청 거부는 전체화면 시청을 차단하지 않는다.
|
|
48
|
+
|
|
42
49
|
## Styles
|
|
43
50
|
|
|
44
51
|
CSS consumer는 dependency order대로 각 public entry를 로드한다.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniai-fe/uds-templates",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "UNIAI Design System; UI Templates Package",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -67,16 +67,16 @@
|
|
|
67
67
|
"react-hook-form": "^7.84.0",
|
|
68
68
|
"sass": "^1.101.7",
|
|
69
69
|
"typescript": "6.0.3",
|
|
70
|
-
"@uniai-fe/react-hooks": "0.3.0",
|
|
71
|
-
"@uniai-fe/eslint-config": "0.4.2",
|
|
72
|
-
"@uniai-fe/tsconfig": "0.2.0",
|
|
73
70
|
"@uniai-fe/next-devkit": "0.4.0",
|
|
74
|
-
"@uniai-fe/
|
|
75
|
-
"@uniai-fe/uds-foundation": "0.6.0",
|
|
76
|
-
"@uniai-fe/util-functions": "0.4.3",
|
|
71
|
+
"@uniai-fe/eslint-config": "0.4.2",
|
|
77
72
|
"@uniai-fe/uds-primitives": "0.12.5",
|
|
78
73
|
"@uniai-fe/util-jotai": "0.3.0",
|
|
74
|
+
"@uniai-fe/react-hooks": "0.3.0",
|
|
75
|
+
"@uniai-fe/util-api": "0.2.1",
|
|
76
|
+
"@uniai-fe/tsconfig": "0.2.0",
|
|
79
77
|
"@uniai-fe/util-rtc": "0.2.1",
|
|
78
|
+
"@uniai-fe/util-functions": "0.4.3",
|
|
79
|
+
"@uniai-fe/uds-foundation": "0.6.0",
|
|
80
80
|
"@uniai-fe/util-next": "0.5.0"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
@@ -8,6 +8,8 @@ import type { UseCctvFullscreenReturn } from "../types";
|
|
|
8
8
|
* @hook
|
|
9
9
|
* @desc 대상 element의 표준 Fullscreen API 지원 여부와 실제 document 상태를 동기화한다.
|
|
10
10
|
* 요청 실패는 기존 viewer를 유지하며, 외부 종료 후에는 진입 전 focus를 복원한다.
|
|
11
|
+
* 지원 환경에서는 진입 후 가로 방향을 요청하고 종료·대상 제거 시 기본 방향 정책으로 돌려준다.
|
|
12
|
+
* 방향 요청 실패는 전체화면 성공에 영향을 주지 않으며 종료 후 세로 방향을 강제하지 않는다.
|
|
11
13
|
* @return {UseCctvFullscreenReturn} 대상 ref callback과 전체화면 상태·action
|
|
12
14
|
*/
|
|
13
15
|
export function useCctvFullscreen(): UseCctvFullscreenReturn {
|
|
@@ -16,18 +18,33 @@ export function useCctvFullscreen(): UseCctvFullscreenReturn {
|
|
|
16
18
|
const targetElementRef = useRef<HTMLElement | null>(null);
|
|
17
19
|
const entryFocusRef = useRef<HTMLElement | null>(null);
|
|
18
20
|
const wasFullscreenRef = useRef(false);
|
|
21
|
+
const unlockOrientationRef = useRef<(() => void) | null>(null);
|
|
22
|
+
|
|
23
|
+
const releaseOrientation = useCallback(() => {
|
|
24
|
+
const unlock = unlockOrientationRef.current;
|
|
25
|
+
unlockOrientationRef.current = null;
|
|
26
|
+
try {
|
|
27
|
+
unlock?.();
|
|
28
|
+
} catch {
|
|
29
|
+
// 숨겨진 document 등에서 해제가 거부돼도 전체화면 종료와 focus 복원을 유지한다.
|
|
30
|
+
}
|
|
31
|
+
}, []);
|
|
19
32
|
|
|
20
33
|
/**
|
|
21
34
|
* service가 선택한 전체화면 대상 element를 hook lifecycle에 연결한다.
|
|
22
35
|
*/
|
|
23
|
-
const targetRef = useCallback(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
const targetRef = useCallback(
|
|
37
|
+
(element: HTMLElement | null) => {
|
|
38
|
+
if (targetElementRef.current !== element) releaseOrientation();
|
|
39
|
+
targetElementRef.current = element;
|
|
40
|
+
setTargetElement(element);
|
|
41
|
+
|
|
42
|
+
if (element === null) {
|
|
43
|
+
setIsFullscreen(false);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
[releaseOrientation],
|
|
47
|
+
);
|
|
31
48
|
|
|
32
49
|
/**
|
|
33
50
|
* 외부 종료 후에도 사용자가 시작한 control로 keyboard focus를 돌려보낸다.
|
|
@@ -54,6 +71,7 @@ export function useCctvFullscreen(): UseCctvFullscreenReturn {
|
|
|
54
71
|
setIsFullscreen(nextIsFullscreen);
|
|
55
72
|
|
|
56
73
|
if (!nextIsFullscreen && wasFullscreenRef.current) {
|
|
74
|
+
releaseOrientation();
|
|
57
75
|
restoreEntryFocus();
|
|
58
76
|
}
|
|
59
77
|
|
|
@@ -79,6 +97,7 @@ export function useCctvFullscreen(): UseCctvFullscreenReturn {
|
|
|
79
97
|
synchronizeFullscreenState,
|
|
80
98
|
);
|
|
81
99
|
|
|
100
|
+
releaseOrientation();
|
|
82
101
|
if (ownerDocument.fullscreenElement === targetElement) {
|
|
83
102
|
void ownerDocument.exitFullscreen().catch(() => undefined);
|
|
84
103
|
}
|
|
@@ -89,7 +108,7 @@ export function useCctvFullscreen(): UseCctvFullscreenReturn {
|
|
|
89
108
|
|
|
90
109
|
wasFullscreenRef.current = false;
|
|
91
110
|
};
|
|
92
|
-
}, [restoreEntryFocus, targetElement]);
|
|
111
|
+
}, [releaseOrientation, restoreEntryFocus, targetElement]);
|
|
93
112
|
|
|
94
113
|
/**
|
|
95
114
|
* 현재 service target의 표준 전체화면 진입을 요청한다.
|
|
@@ -117,6 +136,25 @@ export function useCctvFullscreen(): UseCctvFullscreenReturn {
|
|
|
117
136
|
|
|
118
137
|
try {
|
|
119
138
|
await target.requestFullscreen();
|
|
139
|
+
const orientation = target.ownerDocument.defaultView?.screen.orientation;
|
|
140
|
+
if (
|
|
141
|
+
targetElementRef.current === target &&
|
|
142
|
+
target.ownerDocument.fullscreenElement === target &&
|
|
143
|
+
typeof orientation?.lock === "function" &&
|
|
144
|
+
typeof orientation.unlock === "function"
|
|
145
|
+
) {
|
|
146
|
+
// 대기 중에도 종료가 pending lock을 취소할 수 있도록 먼저 소유권을 기록한다.
|
|
147
|
+
const unlock = () => orientation.unlock();
|
|
148
|
+
unlockOrientationRef.current = unlock;
|
|
149
|
+
try {
|
|
150
|
+
await orientation.lock("landscape");
|
|
151
|
+
} catch {
|
|
152
|
+
// 이전 요청의 거부가 이후 전체화면 세션의 해제 책임을 지우지 않도록 구분한다.
|
|
153
|
+
if (unlockOrientationRef.current === unlock) {
|
|
154
|
+
unlockOrientationRef.current = null;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
120
158
|
return true;
|
|
121
159
|
} catch {
|
|
122
160
|
entryFocusRef.current = null;
|
|
@@ -140,11 +178,12 @@ export function useCctvFullscreen(): UseCctvFullscreenReturn {
|
|
|
140
178
|
|
|
141
179
|
try {
|
|
142
180
|
await target.ownerDocument.exitFullscreen();
|
|
181
|
+
releaseOrientation();
|
|
143
182
|
return true;
|
|
144
183
|
} catch {
|
|
145
184
|
return false;
|
|
146
185
|
}
|
|
147
|
-
}, []);
|
|
186
|
+
}, [releaseOrientation]);
|
|
148
187
|
|
|
149
188
|
/**
|
|
150
189
|
* 현재 document 소유 상태에 따라 target의 진입 또는 종료 action을 선택한다.
|