@uniai-fe/uds-templates 0.0.8 → 0.0.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/styles.css +280 -327
- package/package.json +11 -8
- package/src/components/auth/container/AuthContainer.tsx +24 -0
- package/src/components/auth/container/index.scss +52 -0
- package/src/components/auth/container/index.tsx +4 -0
- package/src/components/auth/container/types.ts +8 -0
- package/src/components/auth/index.tsx +20 -0
- package/src/components/auth/login/data/valid-options.ts +8 -0
- package/src/components/auth/login/hooks/index.ts +6 -0
- package/src/components/auth/login/hooks/useAuthLoginForm.ts +80 -0
- package/src/components/auth/login/index.scss +1 -0
- package/src/components/auth/login/index.tsx +18 -0
- package/src/components/auth/login/markup/Container.tsx +34 -0
- package/src/components/auth/login/markup/FormField.tsx +115 -0
- package/src/components/auth/login/markup/LinkButtons.tsx +40 -0
- package/src/components/auth/login/styles/login.scss +52 -0
- package/src/components/auth/login/types/form.ts +0 -0
- package/src/components/auth/login/types/hooks.ts +82 -0
- package/src/components/auth/login/types/props.ts +95 -0
- package/src/components/auth/login/types.ts +2 -0
- package/src/index.tsx +1 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { SubmitHandler } from "react-hook-form";
|
|
3
|
+
import type { AuthContainerProps } from "../../container";
|
|
4
|
+
import type {
|
|
5
|
+
InputFieldConfig,
|
|
6
|
+
InputPasswordProps,
|
|
7
|
+
InputProps,
|
|
8
|
+
} from "@uniai-fe/uds-primitives";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 로그인 입력 필드 설정
|
|
12
|
+
* @typedef {AuthLoginFieldConfig}
|
|
13
|
+
* @template TProps
|
|
14
|
+
* @desc
|
|
15
|
+
* - InputFieldConfig 제네릭을 래핑해 로그인 요구사항과 연결한다.
|
|
16
|
+
* - props 제네릭으로 Input/PasswordInput 등 세부 props를 주입한다.
|
|
17
|
+
*/
|
|
18
|
+
export type AuthLoginFieldConfig<TProps extends InputProps = InputProps> =
|
|
19
|
+
InputFieldConfig<TProps>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 로그인 필드 묶음
|
|
23
|
+
* @template TAdditional
|
|
24
|
+
* @desc
|
|
25
|
+
* - 필수 id/password 필드와 확장 필드를 포함한다.
|
|
26
|
+
* @property {AuthLoginFieldConfig} id 아이디 필드 설정
|
|
27
|
+
* @property {AuthLoginFieldConfig} password 비밀번호 필드 설정
|
|
28
|
+
*/
|
|
29
|
+
export type AuthLoginFields<
|
|
30
|
+
TAdditional extends Record<string, AuthLoginFieldConfig> = Record<
|
|
31
|
+
string,
|
|
32
|
+
AuthLoginFieldConfig
|
|
33
|
+
>,
|
|
34
|
+
> = TAdditional & {
|
|
35
|
+
/**
|
|
36
|
+
* 아이디 필드 설정
|
|
37
|
+
*/
|
|
38
|
+
id: AuthLoginFieldConfig<InputProps>;
|
|
39
|
+
/**
|
|
40
|
+
* 비밀번호 필드 설정
|
|
41
|
+
*/
|
|
42
|
+
password: AuthLoginFieldConfig<InputPasswordProps>;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 로그인 필드 옵션
|
|
47
|
+
* @template TFields
|
|
48
|
+
* @desc
|
|
49
|
+
* - fields, formAttr, onLogin을 묶어 전달한다.
|
|
50
|
+
* @property {TFields} fields 로그인 입력 필드 설정
|
|
51
|
+
* @property {React.FormHTMLAttributes<HTMLFormElement>} [formAttr] form 요소 attr
|
|
52
|
+
* @property {SubmitHandler<Record<string, string>>} onLogin 로그인 제출 핸들러
|
|
53
|
+
*/
|
|
54
|
+
export type AuthLoginFieldOptions<
|
|
55
|
+
TFields extends AuthLoginFields = AuthLoginFields,
|
|
56
|
+
> = {
|
|
57
|
+
/** 로그인 필드 설정 */
|
|
58
|
+
fields: TFields;
|
|
59
|
+
/** form 요소에 전달할 attr */
|
|
60
|
+
formAttr?: React.FormHTMLAttributes<HTMLFormElement>;
|
|
61
|
+
/** 로그인 제출 핸들러 */
|
|
62
|
+
onLogin: SubmitHandler<Record<string, string>>;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 로그인 화면 링크 옵션
|
|
67
|
+
* @typedef {Object} AuthLoginLinkOptions
|
|
68
|
+
* @desc
|
|
69
|
+
* - 아이디/비밀번호 찾기, 회원가입 링크를 전달한다.
|
|
70
|
+
* @property {Object} find 아이디/비밀번호 찾기 링크
|
|
71
|
+
* @property {string} find.id 아이디 찾기 링크
|
|
72
|
+
* @property {string} find.password 비밀번호 찾기 링크
|
|
73
|
+
* @property {string} signup 회원가입 링크
|
|
74
|
+
*/
|
|
75
|
+
export type AuthLoginLinkOptions = {
|
|
76
|
+
find: {
|
|
77
|
+
id: string;
|
|
78
|
+
password: string;
|
|
79
|
+
};
|
|
80
|
+
signup: string;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 로그인 템플릿 props
|
|
85
|
+
* @template TFields
|
|
86
|
+
* @desc
|
|
87
|
+
* - AuthContainer props와 fieldOptions/linkOptions를 조합한다.
|
|
88
|
+
* @property {AuthLoginFieldOptions<TFields>} fieldOptions 입력 필드/폼 옵션
|
|
89
|
+
* @property {AuthLoginLinkOptions} linkOptions 링크 옵션
|
|
90
|
+
*/
|
|
91
|
+
export type AuthLoginProps<TFields extends AuthLoginFields = AuthLoginFields> =
|
|
92
|
+
Omit<AuthContainerProps, "children"> & {
|
|
93
|
+
fieldOptions: AuthLoginFieldOptions<TFields>;
|
|
94
|
+
linkOptions: AuthLoginLinkOptions;
|
|
95
|
+
};
|
package/src/index.tsx
CHANGED