@uniai-fe/uds-templates 0.6.29 → 0.6.31
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.6.
|
|
3
|
+
"version": "0.6.31",
|
|
4
4
|
"description": "UNIAI Design System; UI Templates Package",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -52,13 +52,13 @@
|
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@tanstack/react-query": "^5",
|
|
55
|
-
"@uniai-fe/uds-foundation": "^0.4.
|
|
56
|
-
"@uniai-fe/uds-primitives": "^0.
|
|
57
|
-
"@uniai-fe/util-api": "^0.1.
|
|
58
|
-
"@uniai-fe/util-functions": "^0.
|
|
59
|
-
"@uniai-fe/util-jotai": "^0.1.
|
|
60
|
-
"@uniai-fe/util-next": "^0.
|
|
61
|
-
"@uniai-fe/util-rtc": "^0.1.
|
|
55
|
+
"@uniai-fe/uds-foundation": "^0.4.8",
|
|
56
|
+
"@uniai-fe/uds-primitives": "^0.8.0",
|
|
57
|
+
"@uniai-fe/util-api": "^0.1.15",
|
|
58
|
+
"@uniai-fe/util-functions": "^0.3.0",
|
|
59
|
+
"@uniai-fe/util-jotai": "^0.1.9",
|
|
60
|
+
"@uniai-fe/util-next": "^0.3.0",
|
|
61
|
+
"@uniai-fe/util-rtc": "^0.1.4",
|
|
62
62
|
"jotai": "^2",
|
|
63
63
|
"next": "^15",
|
|
64
64
|
"react": "^19",
|
|
@@ -4,13 +4,40 @@ import {
|
|
|
4
4
|
useFormContext,
|
|
5
5
|
type FieldPath,
|
|
6
6
|
type FieldValues,
|
|
7
|
+
type UseFormRegisterReturn,
|
|
7
8
|
} from "react-hook-form";
|
|
9
|
+
import { removeWhitespace } from "@uniai-fe/util-functions/convert";
|
|
8
10
|
import AuthSetPasswordFieldBase from "./FieldBase";
|
|
9
11
|
import { DEFAULT_PASSWORD_RULES } from "../data/vaildation";
|
|
10
12
|
import { PasswordHelperList, type PasswordHelperItem } from "./PasswordHelper";
|
|
11
13
|
import { useCheckPassword } from "../hooks/useCheckPassword";
|
|
12
14
|
import type { AuthSetPasswordProps } from "../types";
|
|
13
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Password register onChange 정규화
|
|
18
|
+
* @param {UseFormRegisterReturn} register RHF register 반환값
|
|
19
|
+
* @returns {UseFormRegisterReturn} whitespace 제거 onChange가 포함된 register
|
|
20
|
+
* @desc
|
|
21
|
+
* - DOM 입력값과 RHF 저장값이 같은 password whitespace 제거 기준을 보도록 한다.
|
|
22
|
+
*/
|
|
23
|
+
function normalizePasswordRegister(
|
|
24
|
+
register: UseFormRegisterReturn,
|
|
25
|
+
): UseFormRegisterReturn {
|
|
26
|
+
return {
|
|
27
|
+
...register,
|
|
28
|
+
onChange: event => {
|
|
29
|
+
const input = event.target as HTMLInputElement | undefined;
|
|
30
|
+
if (input) {
|
|
31
|
+
const normalizedValue = removeWhitespace(input.value);
|
|
32
|
+
if (input.value !== normalizedValue) {
|
|
33
|
+
input.value = normalizedValue;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return register.onChange(event);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
14
41
|
/**
|
|
15
42
|
* 비밀번호/재확인 preset; RHF 컨텍스트를 기반으로 두 필드를 동시에 구성한다.
|
|
16
43
|
* @component
|
|
@@ -82,6 +109,14 @@ export default function AuthSetPassword<
|
|
|
82
109
|
const confirmDisabled =
|
|
83
110
|
resolvedConfirmInput?.disabled ??
|
|
84
111
|
(!hasPasswordInput || !passwordRulesFulfilled);
|
|
112
|
+
const passwordRegister = normalizePasswordRegister(
|
|
113
|
+
form.register(passwordKey),
|
|
114
|
+
);
|
|
115
|
+
const confirmRegister = normalizePasswordRegister(
|
|
116
|
+
form.register(confirmKey, {
|
|
117
|
+
validate: confirmValidator,
|
|
118
|
+
}),
|
|
119
|
+
);
|
|
85
120
|
// 재확인 helper: mismatch/일치 여부에 따라 단일 항목을 노출한다.
|
|
86
121
|
const confirmHelperItems: PasswordHelperItem[] = [];
|
|
87
122
|
if (confirmHelper.state === "error" && confirmHelper.text) {
|
|
@@ -118,7 +153,7 @@ export default function AuthSetPassword<
|
|
|
118
153
|
state: passwordInputState,
|
|
119
154
|
}}
|
|
120
155
|
helper={passwordHelperContent}
|
|
121
|
-
register={
|
|
156
|
+
register={passwordRegister}
|
|
122
157
|
/>
|
|
123
158
|
<AuthSetPasswordFieldBase
|
|
124
159
|
className="password-confirm-field"
|
|
@@ -138,9 +173,7 @@ export default function AuthSetPassword<
|
|
|
138
173
|
}}
|
|
139
174
|
helper={confirmHelperContent}
|
|
140
175
|
helperState={confirmHelperState}
|
|
141
|
-
register={
|
|
142
|
-
validate: confirmValidator,
|
|
143
|
-
})}
|
|
176
|
+
register={confirmRegister}
|
|
144
177
|
/>
|
|
145
178
|
</>
|
|
146
179
|
);
|
|
@@ -4,6 +4,7 @@ import { useMemo } from "react";
|
|
|
4
4
|
import { useWatch } from "react-hook-form";
|
|
5
5
|
import type { ReactNode } from "react";
|
|
6
6
|
import type { InputState } from "@uniai-fe/uds-primitives";
|
|
7
|
+
import { removeWhitespace } from "@uniai-fe/util-functions/convert";
|
|
7
8
|
import type {
|
|
8
9
|
AuthLoginFormValues,
|
|
9
10
|
UseAuthLoginFormOptions,
|
|
@@ -74,8 +75,18 @@ export function useAuthLoginForm({
|
|
|
74
75
|
const disabled =
|
|
75
76
|
form.formState.isSubmitting || Boolean(isSubmitting) || !trimmedFilled;
|
|
76
77
|
|
|
77
|
-
/** 4) submit — onLogin
|
|
78
|
-
const onSubmit = form.handleSubmit(
|
|
78
|
+
/** 4) submit — password field만 whitespace 제거 후 onLogin으로 전달한다. */
|
|
79
|
+
const onSubmit = form.handleSubmit((submittedValues, event) => {
|
|
80
|
+
const passwordValue = submittedValues[fieldNames.password];
|
|
81
|
+
const normalizedValues: AuthLoginFormValues = {
|
|
82
|
+
...submittedValues,
|
|
83
|
+
[fieldNames.password]:
|
|
84
|
+
typeof passwordValue === "string"
|
|
85
|
+
? removeWhitespace(passwordValue)
|
|
86
|
+
: "",
|
|
87
|
+
};
|
|
88
|
+
return onLogin(normalizedValues, event);
|
|
89
|
+
});
|
|
79
90
|
|
|
80
91
|
return {
|
|
81
92
|
register,
|