@uniai-fe/uds-templates 0.5.6 → 0.5.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniai-fe/uds-templates",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
4
4
  "description": "UNIAI Design System; UI Templates Package",
5
5
  "type": "module",
6
6
  "private": false,
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { createContext, useContext } from "react";
4
4
  import { Form } from "@uniai-fe/uds-primitives";
5
+ import type { DefaultValues } from "react-hook-form";
5
6
 
6
7
  import type {
7
8
  CctvApiUrlContext,
@@ -39,26 +40,32 @@ export function useCctvApiUrl(): CctvApiUrlContext {
39
40
  * @property {string} [listUrl] company-list API 요청 경로
40
41
  * @property {string} [tokenUrl] token API 요청 경로
41
42
  * @property {string} [username] CCTV 조회시 권한 확인을 위한 계정명
43
+ * @property {ContextExtension} [defaultValues] 서비스 확장 context 기본값
42
44
  * @property {React.ReactNode} children
43
45
  */
44
- export default function CCTVProvider({
46
+ export default function CCTVProvider<ContextExtension extends object = object>({
45
47
  username,
46
48
  company_id,
47
49
  cam_id,
48
50
  listUrl,
49
51
  tokenUrl,
52
+ defaultValues,
50
53
  children,
51
- }: CctvProviderProps) {
54
+ }: CctvProviderProps<ContextExtension>) {
55
+ const mergedDefaultValues = {
56
+ // 변경 설명: service 확장 context 기본값을 core CCTV form context와 한 RHF scope에서 병합한다.
57
+ ...defaultValues,
58
+ ...CCTV_CONTEXT_DEFAULT_VALUES,
59
+ username,
60
+ company_id,
61
+ cam_id,
62
+ } as DefaultValues<CctvContext<ContextExtension>>;
63
+
52
64
  return (
53
65
  <ApiUrlContext.Provider value={{ listUrl, tokenUrl }}>
54
- <Form.Provider<CctvContext>
66
+ <Form.Provider<CctvContext<ContextExtension>>
55
67
  options={{
56
- defaultValues: {
57
- ...CCTV_CONTEXT_DEFAULT_VALUES,
58
- username,
59
- company_id,
60
- cam_id,
61
- },
68
+ defaultValues: mergedDefaultValues,
62
69
  }}
63
70
  >
64
71
  {children}
@@ -11,7 +11,7 @@ import type {
11
11
  CctvCompanyCameraList,
12
12
  CctvCompanyGroup,
13
13
  CctvCompanyGroupItems,
14
- CctvContext,
14
+ CctvBaseContext,
15
15
  UseCctvContextReturn,
16
16
  } from "../types";
17
17
  import { initCompanyList } from "../utils/data";
@@ -49,7 +49,7 @@ export default function useCctvContext(): UseCctvContextReturn {
49
49
  const setCtx = useSetAtom(cctvSelectedContext);
50
50
  const liveRegistry = useAtomValue(cctvRtcLiveRegistryAtom);
51
51
  // react-hook-form context에서 control/setValue 등을 꺼낸다.
52
- const { control, setValue, ...context } = useFormContext<CctvContext>();
52
+ const { control, setValue, ...context } = useFormContext<CctvBaseContext>();
53
53
 
54
54
  // 폼 상태를 watch 하여 실시간 컨텍스트 값을 얻는다.
55
55
  const username = useWatch({ control, name: "username" });
@@ -59,13 +59,17 @@ export interface CctvApiUrlContext {
59
59
  * CCTV; 실시간 영상보기 컨텍스트
60
60
  * @property {string} [company_id] 선택된 업체 id코드
61
61
  * @property {string} [cam_id] 선택된 카메라 id코드
62
+ * @property {string} username CCTV 조회시 권한 확인을 위한 계정명
62
63
  * @property {string} [search] 검색 키워드 (입력값)
63
64
  * @property {string} [filter] 검색 키워드 (필터값)
64
65
  * @property {API_Res_CctvCompanyGroup[]} rawData 원본 데이터 배열
65
66
  * @property {boolean} isFetching 데이터 로딩 상태
66
67
  * @property {boolean} isError 데이터 에러 상태
67
68
  */
68
- export interface CctvContext extends CctvSelectedContext {
69
+ export interface CctvBaseContext extends CctvSelectedContext {
70
+ /**
71
+ * CCTV 조회시 권한 확인을 위한 계정명
72
+ */
69
73
  username: string;
70
74
  /**
71
75
  * 검색 키워드 (입력값)
@@ -79,21 +83,56 @@ export interface CctvContext extends CctvSelectedContext {
79
83
  * 원본 데이터 배열
80
84
  */
81
85
  rawData: API_Res_CctvCompanyGroup[];
86
+ /**
87
+ * 데이터 로딩 상태
88
+ */
82
89
  isFetching: boolean;
90
+ /**
91
+ * 데이터 에러 상태
92
+ */
83
93
  isError: boolean;
84
94
  }
85
95
 
96
+ /**
97
+ * CCTV; Provider form context
98
+ * @template ContextExtension
99
+ * @typedef {CctvBaseContext & ContextExtension} CctvContext
100
+ * @property {string} [company_id] 선택된 업체 id코드
101
+ * @property {string} [cam_id] 선택된 카메라 id코드
102
+ * @property {string} username CCTV 조회시 권한 확인을 위한 계정명
103
+ * @property {string} search 검색 키워드 입력값
104
+ * @property {string} filter 검색 키워드 필터값
105
+ * @property {API_Res_CctvCompanyGroup[]} rawData 원본 데이터 배열
106
+ * @property {boolean} isFetching 데이터 로딩 상태
107
+ * @property {boolean} isError 데이터 에러 상태
108
+ */
109
+ export type CctvContext<ContextExtension extends object = object> =
110
+ CctvBaseContext & ContextExtension;
111
+
86
112
  /**
87
113
  * CCTV; Provider props
114
+ * @template ContextExtension
88
115
  * @property {string} [company_id] 선택된 업체 id코드
89
116
  * @property {string} [cam_id] 선택된 카메라 id코드
90
117
  * @property {string} [listUrl] company-list API 요청 경로
91
118
  * @property {string} [tokenUrl] token API 요청 경로
92
119
  * @property {string} [username] CCTV 조회시 권한 확인을 위한 계정명
120
+ * @property {ContextExtension} [defaultValues] 서비스 확장 context 기본값
93
121
  * @property {React.ReactNode} children
94
122
  */
95
- export type CctvProviderProps = CctvSelectedContext &
96
- CctvApiUrlContext & {
97
- username?: string;
98
- children: React.ReactNode;
99
- };
123
+ export type CctvProviderProps<ContextExtension extends object = object> =
124
+ CctvSelectedContext &
125
+ CctvApiUrlContext & {
126
+ /**
127
+ * CCTV 조회시 권한 확인을 위한 계정명
128
+ */
129
+ username?: string;
130
+ /**
131
+ * 서비스 확장 context 기본값
132
+ */
133
+ defaultValues?: ContextExtension;
134
+ /**
135
+ * Provider 하위 콘텐츠
136
+ */
137
+ children: React.ReactNode;
138
+ };
@@ -7,7 +7,7 @@ import type {
7
7
  CctvCompanyGroupItems,
8
8
  } from "./list";
9
9
  import type { UseFormReturn } from "react-hook-form";
10
- import type { CctvContext } from "./context";
10
+ import type { CctvBaseContext } from "./context";
11
11
 
12
12
  /**
13
13
  * CCTV; useCctvRtcStream params
@@ -135,7 +135,7 @@ export interface UseCctvCompanyDataReturn extends Omit<
135
135
  * @property {(cam_id: string) => void} onOpenCamera 카메라 선택 함수
136
136
  * @property {() => void} onCloseCamera 카메라 선택 해제 함수
137
137
  */
138
- export interface UseCctvContextReturn extends UseFormReturn<CctvContext> {
138
+ export interface UseCctvContextReturn extends UseFormReturn<CctvBaseContext> {
139
139
  /**
140
140
  * 데이터 로딩 중 상태
141
141
  */