@uniai-fe/uds-primitives 0.0.12 → 0.0.14
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 +4 -4
- package/src/components/input/markup/text/Base.tsx +8 -8
- package/src/components/input/markup/text/Identification.tsx +11 -10
- package/src/components/input/markup/text/Password.tsx +3 -3
- package/src/components/input/markup/text/index.ts +1 -1
- package/src/components/input/types/index.ts +5 -5
- package/src/index.tsx +1 -0
- package/src/types/form-field.ts +80 -0
- package/src/types/index.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniai-fe/uds-primitives",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "UNIAI Design System; Primitives Components Package",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"publishConfig": {
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|
|
17
|
-
"packageManager": "pnpm@10.26.
|
|
17
|
+
"packageManager": "pnpm@10.26.1",
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">=24",
|
|
20
20
|
"pnpm": ">=10"
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
"@uniai-fe/util-functions": "workspace:*",
|
|
92
92
|
"eslint": "^9.39.2",
|
|
93
93
|
"prettier": "^3.7.4",
|
|
94
|
-
"react-hook-form": "^7.
|
|
95
|
-
"sass": "^1.97.
|
|
94
|
+
"react-hook-form": "^7.69.0",
|
|
95
|
+
"sass": "^1.97.1",
|
|
96
96
|
"typescript": "~5.9.3"
|
|
97
97
|
}
|
|
98
98
|
}
|
|
@@ -62,7 +62,7 @@ const setForwardedRef = <T,>(ref: ForwardedRef<T>, value: T | null): void => {
|
|
|
62
62
|
* @param {string} [props.className] root `.input` className
|
|
63
63
|
* @param {UseFormRegisterReturn} [props.register] react-hook-form register 반환값
|
|
64
64
|
* @param {string} [props.name] native name. register 사용 시 자동으로 병합
|
|
65
|
-
* @param {
|
|
65
|
+
* @param {InputState} [props.data-simulated-state] Storybook 등에서 시각 상태 강제용
|
|
66
66
|
* @param {(event: ChangeEvent<HTMLInputElement>) => void} [props.onChange] change 핸들러
|
|
67
67
|
* @param {(event: FocusEvent<HTMLInputElement>) => void} [props.onFocus] focus 핸들러
|
|
68
68
|
* @param {(event: FocusEvent<HTMLInputElement>) => void} [props.onBlur] blur 핸들러
|
|
@@ -79,9 +79,9 @@ const Text = forwardRef<HTMLInputElement, InputProps>(
|
|
|
79
79
|
block = false,
|
|
80
80
|
left,
|
|
81
81
|
right,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
clear,
|
|
83
|
+
success,
|
|
84
|
+
error,
|
|
85
85
|
label,
|
|
86
86
|
helper,
|
|
87
87
|
hideHelper,
|
|
@@ -167,13 +167,13 @@ const Text = forwardRef<HTMLInputElement, InputProps>(
|
|
|
167
167
|
|
|
168
168
|
const statusSlot = useMemo(() => {
|
|
169
169
|
if (resolvedState === "success") {
|
|
170
|
-
return
|
|
170
|
+
return success ?? defaultStatusIcon;
|
|
171
171
|
}
|
|
172
172
|
if (resolvedState === "error") {
|
|
173
|
-
return
|
|
173
|
+
return error ?? defaultStatusIcon;
|
|
174
174
|
}
|
|
175
175
|
return null;
|
|
176
|
-
}, [defaultStatusIcon,
|
|
176
|
+
}, [defaultStatusIcon, error, resolvedState, success]);
|
|
177
177
|
|
|
178
178
|
const defaultClearIcon = useMemo(() => {
|
|
179
179
|
if (visualState === "active") {
|
|
@@ -182,7 +182,7 @@ const Text = forwardRef<HTMLInputElement, InputProps>(
|
|
|
182
182
|
return null;
|
|
183
183
|
}, [visualState]);
|
|
184
184
|
|
|
185
|
-
const effectiveClearIcon =
|
|
185
|
+
const effectiveClearIcon = clear ?? defaultClearIcon;
|
|
186
186
|
const showClearIcon = Boolean(
|
|
187
187
|
effectiveClearIcon && hasValue && resolvedState !== "disabled",
|
|
188
188
|
);
|
|
@@ -4,26 +4,27 @@ import {
|
|
|
4
4
|
forwardRef,
|
|
5
5
|
useImperativeHandle,
|
|
6
6
|
KeyboardEvent,
|
|
7
|
+
ReactNode,
|
|
7
8
|
useCallback,
|
|
8
9
|
useMemo,
|
|
9
10
|
useRef,
|
|
10
11
|
useState,
|
|
11
12
|
} from "react";
|
|
12
|
-
import type {
|
|
13
|
+
import type { InputState } from "../../types";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* IdentificationInput props. 고정 길이 숫자 코드 입력에 필요한 label/helper/state/onComplete를 제공한다.
|
|
16
17
|
* @property {number} [length=6] 입력칸 개수(4~8 사이로 자동 보정).
|
|
17
|
-
* @property {
|
|
18
|
-
* @property {
|
|
19
|
-
* @property {
|
|
18
|
+
* @property {ReactNode} [label] 상단 라벨.
|
|
19
|
+
* @property {ReactNode} [helper] helper 텍스트.
|
|
20
|
+
* @property {InputState} [state="default"] 시각 상태.
|
|
20
21
|
* @property {(code: string) => void} [onComplete] 모든 셀이 채워졌을 때 호출.
|
|
21
22
|
*/
|
|
22
23
|
export interface IdentificationInputProps {
|
|
23
24
|
length?: number;
|
|
24
|
-
label?:
|
|
25
|
-
helper?:
|
|
26
|
-
state?:
|
|
25
|
+
label?: ReactNode;
|
|
26
|
+
helper?: ReactNode;
|
|
27
|
+
state?: InputState;
|
|
27
28
|
onComplete?: (code: string) => void;
|
|
28
29
|
}
|
|
29
30
|
|
|
@@ -32,9 +33,9 @@ export interface IdentificationInputProps {
|
|
|
32
33
|
* @component
|
|
33
34
|
* @param {IdentificationInputProps} props
|
|
34
35
|
* @param {number} [props.length=6] 입력 필드 길이. 4~8 범위로 자동 보정된다.
|
|
35
|
-
* @param {
|
|
36
|
-
* @param {
|
|
37
|
-
* @param {
|
|
36
|
+
* @param {ReactNode} [props.label] 상단 label 콘텐츠.
|
|
37
|
+
* @param {ReactNode} [props.helper] helper 텍스트.
|
|
38
|
+
* @param {InputState} [props.state] 시각 상태.
|
|
38
39
|
* @param {(code: string) => void} [props.onComplete] 모든 셀이 채워졌을 때 호출되는 콜백.
|
|
39
40
|
*/
|
|
40
41
|
const IdentificationInput = forwardRef<
|
|
@@ -9,7 +9,7 @@ import HideOnIcon from "../../img/hide-on.svg";
|
|
|
9
9
|
* @property {boolean} [defaultVisible=false] 초기 렌더 시 비밀번호를 드러낼지 여부.
|
|
10
10
|
* @property {{show: string; hide: string}} [toggleLabel] 토글 버튼에 사용할 라벨 텍스트 집합.
|
|
11
11
|
*/
|
|
12
|
-
export interface
|
|
12
|
+
export interface InputPasswordProps extends Omit<InputProps, "type"> {
|
|
13
13
|
defaultVisible?: boolean;
|
|
14
14
|
toggleLabel?: {
|
|
15
15
|
show: string;
|
|
@@ -20,12 +20,12 @@ export interface PasswordInputProps extends Omit<InputProps, "type"> {
|
|
|
20
20
|
/**
|
|
21
21
|
* PasswordInput — 기본 Text 입력을 비밀번호 토글 UX로 확장한다.
|
|
22
22
|
* @component
|
|
23
|
-
* @param {
|
|
23
|
+
* @param {InputPasswordProps} props
|
|
24
24
|
* @param {boolean} [props.defaultVisible=false] 초기 노출 여부.
|
|
25
25
|
* @param {{show: string; hide: string}} [props.toggleLabel={show:"보기",hide:"숨김"}] 토글 버튼 라벨.
|
|
26
26
|
* 나머지 props는 Text Input과 동일하다.
|
|
27
27
|
*/
|
|
28
|
-
const PasswordInput = forwardRef<HTMLInputElement,
|
|
28
|
+
const PasswordInput = forwardRef<HTMLInputElement, InputPasswordProps>(
|
|
29
29
|
(
|
|
30
30
|
{
|
|
31
31
|
defaultVisible = false,
|
|
@@ -4,7 +4,7 @@ export { PasswordInput } from "./Password";
|
|
|
4
4
|
export { PhoneInput } from "./Phone";
|
|
5
5
|
export { SearchInput } from "./Search";
|
|
6
6
|
export { IdentificationInput } from "./Identification";
|
|
7
|
-
export type {
|
|
7
|
+
export type { InputPasswordProps } from "./Password";
|
|
8
8
|
export type { PhoneInputProps } from "./Phone";
|
|
9
9
|
export type { SearchInputProps } from "./Search";
|
|
10
10
|
export type { IdentificationInputProps } from "./Identification";
|
|
@@ -30,12 +30,12 @@ type NativeInputProps = ComponentPropsWithoutRef<"input">;
|
|
|
30
30
|
/**
|
|
31
31
|
* 좌우 슬롯과 status 아이콘 정의.
|
|
32
32
|
*/
|
|
33
|
-
export interface
|
|
33
|
+
export interface InputIcon {
|
|
34
34
|
left?: ReactNode;
|
|
35
35
|
right?: ReactNode;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
clear?: ReactNode;
|
|
37
|
+
success?: ReactNode;
|
|
38
|
+
error?: ReactNode;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -51,7 +51,7 @@ export interface InputFeedback {
|
|
|
51
51
|
* 텍스트 입력의 핵심 props. native input 속성에서 size는 제외하고 left/right 등 슬롯을 별도로 정의한다.
|
|
52
52
|
*/
|
|
53
53
|
export interface InputProps
|
|
54
|
-
extends Omit<NativeInputProps, "size">,
|
|
54
|
+
extends Omit<NativeInputProps, "size">, InputIcon, InputFeedback {
|
|
55
55
|
/** semantic color/token 세트 */
|
|
56
56
|
priority?: InputPriority;
|
|
57
57
|
/** 높이/타이포 세트 */
|
package/src/index.tsx
CHANGED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { InputHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import type { InputProps } from "../components/input/types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Input Field Attr; HTML native 속성 래핑
|
|
6
|
+
* @typedef {InputFieldAttr}
|
|
7
|
+
* @template FieldElement
|
|
8
|
+
* @desc
|
|
9
|
+
* - InputHTMLAttributes를 그대로 재사용해 네이티브 속성을 전달한다.
|
|
10
|
+
*/
|
|
11
|
+
export type InputFieldAttr<
|
|
12
|
+
FieldElement extends HTMLElement = HTMLInputElement,
|
|
13
|
+
> = InputHTMLAttributes<FieldElement>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Input Field Style; 레이아웃 래퍼 스타일
|
|
17
|
+
* @interface InputFieldStyle
|
|
18
|
+
* @desc
|
|
19
|
+
* - className/block 등 래퍼 스타일만 관리한다.
|
|
20
|
+
*/
|
|
21
|
+
export interface InputFieldStyle {
|
|
22
|
+
/**
|
|
23
|
+
* 필드 컨테이너 className
|
|
24
|
+
*/
|
|
25
|
+
className?: string;
|
|
26
|
+
/**
|
|
27
|
+
* label 컨테이너 className
|
|
28
|
+
*/
|
|
29
|
+
labelClassName?: string;
|
|
30
|
+
/**
|
|
31
|
+
* helper 컨테이너 className
|
|
32
|
+
*/
|
|
33
|
+
helperClassName?: string;
|
|
34
|
+
/**
|
|
35
|
+
* true면 block 레이아웃
|
|
36
|
+
*/
|
|
37
|
+
block?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Input Field Options; UX 텍스트/설명
|
|
42
|
+
* @interface InputFieldOptions
|
|
43
|
+
* @desc
|
|
44
|
+
* - label/helper/description 등 사용자-facing 정보를 정의한다.
|
|
45
|
+
*/
|
|
46
|
+
export interface InputFieldOptions {
|
|
47
|
+
/**
|
|
48
|
+
* 라벨 텍스트 또는 노드
|
|
49
|
+
*/
|
|
50
|
+
label?: ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* helper 텍스트
|
|
53
|
+
*/
|
|
54
|
+
helper?: ReactNode;
|
|
55
|
+
/**
|
|
56
|
+
* 접근성 안내/설명
|
|
57
|
+
*/
|
|
58
|
+
description?: ReactNode;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Input Field Config; attr + style + options + props
|
|
63
|
+
* @interface InputFieldConfig
|
|
64
|
+
* @template TProps
|
|
65
|
+
* @template FieldElement
|
|
66
|
+
*/
|
|
67
|
+
export interface InputFieldConfig<
|
|
68
|
+
TProps extends InputProps = InputProps,
|
|
69
|
+
FieldElement extends HTMLElement = HTMLInputElement,
|
|
70
|
+
>
|
|
71
|
+
extends InputFieldStyle, InputFieldOptions {
|
|
72
|
+
/**
|
|
73
|
+
* HTML native attr
|
|
74
|
+
*/
|
|
75
|
+
attr?: InputFieldAttr<FieldElement>;
|
|
76
|
+
/**
|
|
77
|
+
* primitives Input 계열 props
|
|
78
|
+
*/
|
|
79
|
+
props?: TProps;
|
|
80
|
+
}
|
package/src/types/index.ts
CHANGED