@uniai-fe/uds-primitives 0.0.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 +63 -0
- package/package.json +85 -0
- package/src/components/alternate/hooks/index.ts +4 -0
- package/src/components/alternate/img/.gitkeep +0 -0
- package/src/components/alternate/index.scss +1 -0
- package/src/components/alternate/index.tsx +4 -0
- package/src/components/alternate/markup/index.tsx +4 -0
- package/src/components/alternate/styles/index.scss +3 -0
- package/src/components/alternate/types/index.ts +4 -0
- package/src/components/alternate/utils/index.ts +4 -0
- package/src/components/badge/hooks/index.ts +4 -0
- package/src/components/badge/img/.gitkeep +0 -0
- package/src/components/badge/index.scss +1 -0
- package/src/components/badge/index.tsx +6 -0
- package/src/components/badge/markup/Badge.tsx +51 -0
- package/src/components/badge/markup/index.tsx +1 -0
- package/src/components/badge/styles/index.scss +189 -0
- package/src/components/badge/types/index.ts +55 -0
- package/src/components/badge/utils/index.ts +21 -0
- package/src/components/button/hooks/index.ts +4 -0
- package/src/components/button/img/.gitkeep +0 -0
- package/src/components/button/index.scss +1 -0
- package/src/components/button/index.tsx +6 -0
- package/src/components/button/markup/Button.tsx +175 -0
- package/src/components/button/markup/index.tsx +1 -0
- package/src/components/button/styles/index.scss +847 -0
- package/src/components/button/types/index.ts +79 -0
- package/src/components/button/utils/index.ts +58 -0
- package/src/components/calendar/hooks/index.ts +4 -0
- package/src/components/calendar/img/.gitkeep +0 -0
- package/src/components/calendar/index.scss +1 -0
- package/src/components/calendar/index.tsx +4 -0
- package/src/components/calendar/markup/index.tsx +4 -0
- package/src/components/calendar/styles/index.scss +3 -0
- package/src/components/calendar/types/index.ts +4 -0
- package/src/components/calendar/utils/index.ts +4 -0
- package/src/components/checkbox/hooks/index.ts +4 -0
- package/src/components/checkbox/img/.gitkeep +0 -0
- package/src/components/checkbox/img/check-large.svg +3 -0
- package/src/components/checkbox/img/check-medium.svg +3 -0
- package/src/components/checkbox/img/check.svg +3 -0
- package/src/components/checkbox/index.scss +1 -0
- package/src/components/checkbox/index.tsx +4 -0
- package/src/components/checkbox/markup/Checkbox.tsx +127 -0
- package/src/components/checkbox/markup/index.ts +1 -0
- package/src/components/checkbox/styles/index.scss +164 -0
- package/src/components/checkbox/types/checkbox.ts +21 -0
- package/src/components/checkbox/types/index.ts +1 -0
- package/src/components/chip/hooks/index.ts +4 -0
- package/src/components/chip/img/.gitkeep +0 -0
- package/src/components/chip/img/remove.svg +3 -0
- package/src/components/chip/index.scss +1 -0
- package/src/components/chip/index.tsx +6 -0
- package/src/components/chip/markup/Chip.tsx +103 -0
- package/src/components/chip/markup/index.tsx +1 -0
- package/src/components/chip/styles/index.scss +140 -0
- package/src/components/chip/types/index.ts +52 -0
- package/src/components/chip/utils/index.ts +36 -0
- package/src/components/dialog/hooks/index.ts +4 -0
- package/src/components/dialog/img/.gitkeep +0 -0
- package/src/components/dialog/index.scss +1 -0
- package/src/components/dialog/index.tsx +3 -0
- package/src/components/dialog/markup/confirm-dialog.tsx +316 -0
- package/src/components/dialog/markup/index.tsx +4 -0
- package/src/components/dialog/markup/notice-dialog.tsx +191 -0
- package/src/components/dialog/styles/base.scss +153 -0
- package/src/components/dialog/styles/confirm.scss +58 -0
- package/src/components/dialog/styles/index.scss +3 -0
- package/src/components/dialog/styles/notice.scss +65 -0
- package/src/components/dialog/types/index.ts +70 -0
- package/src/components/dialog/utils/index.ts +4 -0
- package/src/components/drawer/hooks/index.ts +113 -0
- package/src/components/drawer/img/.gitkeep +0 -0
- package/src/components/drawer/img/close.svg +3 -0
- package/src/components/drawer/index.scss +1 -0
- package/src/components/drawer/index.tsx +3 -0
- package/src/components/drawer/markup/drawer.tsx +421 -0
- package/src/components/drawer/markup/index.tsx +3 -0
- package/src/components/drawer/styles/index.scss +232 -0
- package/src/components/drawer/types/index.ts +51 -0
- package/src/components/drawer/utils/context.ts +15 -0
- package/src/components/drawer/utils/index.tsx +77 -0
- package/src/components/dropdown/hooks/index.ts +4 -0
- package/src/components/dropdown/img/.gitkeep +0 -0
- package/src/components/dropdown/index.scss +1 -0
- package/src/components/dropdown/index.tsx +4 -0
- package/src/components/dropdown/markup/index.tsx +4 -0
- package/src/components/dropdown/styles/index.scss +3 -0
- package/src/components/dropdown/types/index.ts +4 -0
- package/src/components/dropdown/utils/index.ts +4 -0
- package/src/components/input/hooks/index.ts +4 -0
- package/src/components/input/img/.gitkeep +0 -0
- package/src/components/input/img/check-correct.svg +3 -0
- package/src/components/input/img/check-default.svg +3 -0
- package/src/components/input/img/check-incorrect.svg +3 -0
- package/src/components/input/img/error.svg +5 -0
- package/src/components/input/img/hide-off.svg +4 -0
- package/src/components/input/img/hide-on.svg +6 -0
- package/src/components/input/img/reset.svg +3 -0
- package/src/components/input/img/search.svg +4 -0
- package/src/components/input/img/success.svg +3 -0
- package/src/components/input/index.scss +1 -0
- package/src/components/input/index.tsx +6 -0
- package/src/components/input/markup/index.tsx +1 -0
- package/src/components/input/markup/text/Base.tsx +311 -0
- package/src/components/input/markup/text/Identification.tsx +145 -0
- package/src/components/input/markup/text/Password.tsx +71 -0
- package/src/components/input/markup/text/Phone.tsx +115 -0
- package/src/components/input/markup/text/Search.tsx +35 -0
- package/src/components/input/markup/text/index.ts +10 -0
- package/src/components/input/styles/index.scss +375 -0
- package/src/components/input/types/index.ts +56 -0
- package/src/components/input/utils/index.ts +54 -0
- package/src/components/label/hooks/index.ts +4 -0
- package/src/components/label/img/.gitkeep +0 -0
- package/src/components/label/index.scss +1 -0
- package/src/components/label/index.tsx +4 -0
- package/src/components/label/markup/index.tsx +4 -0
- package/src/components/label/styles/index.scss +3 -0
- package/src/components/label/types/index.ts +4 -0
- package/src/components/label/utils/index.ts +4 -0
- package/src/components/navigation/hooks/index.ts +4 -0
- package/src/components/navigation/img/.gitkeep +0 -0
- package/src/components/navigation/index.scss +1 -0
- package/src/components/navigation/index.tsx +8 -0
- package/src/components/navigation/markup/index.tsx +2 -0
- package/src/components/navigation/markup/mobile/BottomNavigation.tsx +127 -0
- package/src/components/navigation/markup/mobile/index.ts +1 -0
- package/src/components/navigation/markup/web/index.ts +4 -0
- package/src/components/navigation/styles/index.scss +133 -0
- package/src/components/navigation/types/index.ts +38 -0
- package/src/components/navigation/utils/index.ts +23 -0
- package/src/components/pagination/hooks/index.ts +4 -0
- package/src/components/pagination/img/.gitkeep +0 -0
- package/src/components/pagination/index.scss +1 -0
- package/src/components/pagination/index.tsx +6 -0
- package/src/components/pagination/markup/Carousel.tsx +76 -0
- package/src/components/pagination/markup/Count.tsx +54 -0
- package/src/components/pagination/markup/Pagination.tsx +83 -0
- package/src/components/pagination/markup/index.tsx +3 -0
- package/src/components/pagination/styles/index.scss +155 -0
- package/src/components/pagination/types/index.ts +68 -0
- package/src/components/pagination/utils/index.ts +58 -0
- package/src/components/radio/hooks/index.ts +4 -0
- package/src/components/radio/img/.gitkeep +0 -0
- package/src/components/radio/index.scss +1 -0
- package/src/components/radio/index.tsx +7 -0
- package/src/components/radio/markup/Radio.tsx +121 -0
- package/src/components/radio/markup/RadioCard.tsx +68 -0
- package/src/components/radio/markup/RadioCardGroup.tsx +75 -0
- package/src/components/radio/markup/index.tsx +3 -0
- package/src/components/radio/styles/index.scss +252 -0
- package/src/components/radio/types/index.ts +1 -0
- package/src/components/radio/types/radio.ts +63 -0
- package/src/components/radio/utils/index.ts +4 -0
- package/src/components/scrollbar/hooks/index.ts +4 -0
- package/src/components/scrollbar/img/.gitkeep +0 -0
- package/src/components/scrollbar/index.scss +1 -0
- package/src/components/scrollbar/index.tsx +4 -0
- package/src/components/scrollbar/markup/index.tsx +4 -0
- package/src/components/scrollbar/styles/index.scss +3 -0
- package/src/components/scrollbar/types/index.ts +4 -0
- package/src/components/scrollbar/utils/index.ts +4 -0
- package/src/components/segmented-control/index.scss +1 -0
- package/src/components/segmented-control/index.tsx +7 -0
- package/src/components/segmented-control/markup/SegmentedControl.tsx +117 -0
- package/src/components/segmented-control/markup/index.ts +1 -0
- package/src/components/segmented-control/styles/index.scss +113 -0
- package/src/components/segmented-control/types/index.ts +22 -0
- package/src/components/select/hooks/index.ts +4 -0
- package/src/components/select/img/.gitkeep +0 -0
- package/src/components/select/index.scss +1 -0
- package/src/components/select/index.tsx +4 -0
- package/src/components/select/markup/index.tsx +4 -0
- package/src/components/select/styles/index.scss +3 -0
- package/src/components/select/types/index.ts +4 -0
- package/src/components/select/utils/index.ts +4 -0
- package/src/components/spinner/hooks/index.ts +4 -0
- package/src/components/spinner/img/.gitkeep +0 -0
- package/src/components/spinner/index.scss +1 -0
- package/src/components/spinner/index.tsx +4 -0
- package/src/components/spinner/markup/index.tsx +4 -0
- package/src/components/spinner/styles/index.scss +3 -0
- package/src/components/spinner/types/index.ts +4 -0
- package/src/components/spinner/utils/index.ts +4 -0
- package/src/components/tab/hooks/index.ts +4 -0
- package/src/components/tab/img/.gitkeep +0 -0
- package/src/components/tab/index.scss +1 -0
- package/src/components/tab/index.tsx +6 -0
- package/src/components/tab/markup/TabContent.tsx +29 -0
- package/src/components/tab/markup/TabList.tsx +60 -0
- package/src/components/tab/markup/TabRoot.tsx +74 -0
- package/src/components/tab/markup/TabTrigger.tsx +47 -0
- package/src/components/tab/markup/index.tsx +4 -0
- package/src/components/tab/styles/index.scss +182 -0
- package/src/components/tab/types/index.ts +46 -0
- package/src/components/tab/utils/index.ts +5 -0
- package/src/components/tab/utils/tab-context.ts +20 -0
- package/src/components/table/hooks/index.ts +4 -0
- package/src/components/table/img/.gitkeep +0 -0
- package/src/components/table/index.scss +1 -0
- package/src/components/table/index.tsx +4 -0
- package/src/components/table/markup/index.tsx +4 -0
- package/src/components/table/styles/index.scss +3 -0
- package/src/components/table/types/index.ts +4 -0
- package/src/components/table/utils/index.ts +4 -0
- package/src/hooks/index.ts +4 -0
- package/src/img/.gitkeep +0 -0
- package/src/index.scss +3 -0
- package/src/index.tsx +26 -0
- package/src/init/dayjs.ts +14 -0
- package/src/theme/ThemeProvider.tsx +25 -0
- package/src/theme/config.ts +29 -0
- package/src/theme/index.ts +3 -0
- package/src/theme/overrides.scss +215 -0
- package/src/types/index.ts +4 -0
- package/src/utils/index.ts +4 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { forwardRef, useMemo, useState } from "react";
|
|
2
|
+
import type { InputProps } from "../../types";
|
|
3
|
+
import { Text } from "./Base";
|
|
4
|
+
import HideOffIcon from "../../img/hide-off.svg";
|
|
5
|
+
import HideOnIcon from "../../img/hide-on.svg";
|
|
6
|
+
|
|
7
|
+
export interface PasswordInputProps extends Omit<
|
|
8
|
+
InputProps,
|
|
9
|
+
"type" | "defaultValue"
|
|
10
|
+
> {
|
|
11
|
+
defaultVisible?: boolean;
|
|
12
|
+
toggleLabel?: {
|
|
13
|
+
show: string;
|
|
14
|
+
hide: string;
|
|
15
|
+
};
|
|
16
|
+
defaultValue?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* PasswordInput — 기본 Text 입력을 비밀번호 토글 UX로 확장.
|
|
21
|
+
* @param props.defaultVisible 최초 노출 여부.
|
|
22
|
+
* @param props.toggleLabel 토글 버튼의 라벨 텍스트.
|
|
23
|
+
*/
|
|
24
|
+
const PasswordInput = forwardRef<HTMLInputElement, PasswordInputProps>(
|
|
25
|
+
(
|
|
26
|
+
{
|
|
27
|
+
defaultVisible = false,
|
|
28
|
+
toggleLabel = { show: "보기", hide: "숨김" },
|
|
29
|
+
suffix,
|
|
30
|
+
defaultValue,
|
|
31
|
+
...restProps
|
|
32
|
+
},
|
|
33
|
+
forwardedRef,
|
|
34
|
+
) => {
|
|
35
|
+
const [visible, setVisible] = useState(defaultVisible);
|
|
36
|
+
|
|
37
|
+
const toggleButton = useMemo(
|
|
38
|
+
() => (
|
|
39
|
+
<button
|
|
40
|
+
type="button"
|
|
41
|
+
className="input-password-toggle"
|
|
42
|
+
onClick={() => setVisible(prev => !prev)}
|
|
43
|
+
aria-pressed={visible}
|
|
44
|
+
aria-label={visible ? toggleLabel.hide : toggleLabel.show}
|
|
45
|
+
>
|
|
46
|
+
{/* 토글 상태에 따라 hide-on/off 아이콘을 교체한다. */}
|
|
47
|
+
{visible ? (
|
|
48
|
+
<HideOffIcon aria-hidden="true" />
|
|
49
|
+
) : (
|
|
50
|
+
<HideOnIcon aria-hidden="true" />
|
|
51
|
+
)}
|
|
52
|
+
</button>
|
|
53
|
+
),
|
|
54
|
+
[toggleLabel.hide, toggleLabel.show, visible],
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<Text
|
|
59
|
+
{...restProps}
|
|
60
|
+
ref={forwardedRef}
|
|
61
|
+
type={visible ? "text" : "password"}
|
|
62
|
+
defaultValue={defaultValue}
|
|
63
|
+
suffix={suffix ?? toggleButton}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
},
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
PasswordInput.displayName = "PasswordInput";
|
|
70
|
+
|
|
71
|
+
export { PasswordInput };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { maskPhone } from "@uniai-fe/util-functions";
|
|
2
|
+
import type { ChangeEvent, ComponentPropsWithoutRef } from "react";
|
|
3
|
+
import { forwardRef, useCallback, useMemo, useState } from "react";
|
|
4
|
+
import type { InputProps } from "../../types";
|
|
5
|
+
import { Text } from "./Base";
|
|
6
|
+
|
|
7
|
+
export interface PhoneInputProps extends Omit<
|
|
8
|
+
InputProps,
|
|
9
|
+
| "type"
|
|
10
|
+
| "prefix"
|
|
11
|
+
| "inputMode"
|
|
12
|
+
| "pattern"
|
|
13
|
+
| "onChange"
|
|
14
|
+
| "value"
|
|
15
|
+
| "defaultValue"
|
|
16
|
+
> {
|
|
17
|
+
value?: string;
|
|
18
|
+
defaultValue?: string;
|
|
19
|
+
onValueChange?: (value: string, digits: string) => void;
|
|
20
|
+
onChange?: ComponentPropsWithoutRef<"input">["onChange"];
|
|
21
|
+
onRequestCode?: () => void;
|
|
22
|
+
requestButtonLabel?: string;
|
|
23
|
+
requestButtonDisabled?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const MAX_DIGITS = 11;
|
|
27
|
+
|
|
28
|
+
const normalizeDigits = (value?: string) => (value ?? "").replace(/\D/g, "");
|
|
29
|
+
|
|
30
|
+
// util-functions의 maskPhone 규칙으로 자리수/패턴을 일원화한다.
|
|
31
|
+
const formatPhoneNumber = (digits: string) => maskPhone(digits);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* PhoneInput — 휴대폰 번호 마스킹과 인증번호 요청 버튼을 제공하는 입력.
|
|
35
|
+
* @param props.onValueChange 포맷팅된 값 + 숫자만 별도로 전달.
|
|
36
|
+
* @param props.onRequestCode 인증번호 요청 버튼 클릭 핸들러.
|
|
37
|
+
*/
|
|
38
|
+
const PhoneInput = forwardRef<HTMLInputElement, PhoneInputProps>(
|
|
39
|
+
(
|
|
40
|
+
{
|
|
41
|
+
value,
|
|
42
|
+
defaultValue,
|
|
43
|
+
onValueChange,
|
|
44
|
+
onChange,
|
|
45
|
+
onRequestCode,
|
|
46
|
+
requestButtonLabel = "인증번호 요청",
|
|
47
|
+
requestButtonDisabled,
|
|
48
|
+
suffix,
|
|
49
|
+
...restProps
|
|
50
|
+
},
|
|
51
|
+
forwardedRef,
|
|
52
|
+
) => {
|
|
53
|
+
const isControlled = value !== undefined;
|
|
54
|
+
const [digitsState, setDigitsState] = useState(() =>
|
|
55
|
+
normalizeDigits(defaultValue),
|
|
56
|
+
);
|
|
57
|
+
const digits = isControlled ? normalizeDigits(value) : digitsState;
|
|
58
|
+
const formattedValue = useMemo(
|
|
59
|
+
() => formatPhoneNumber(digits.slice(0, MAX_DIGITS)),
|
|
60
|
+
[digits],
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const handleChange = useCallback(
|
|
64
|
+
(event: ChangeEvent<HTMLInputElement>) => {
|
|
65
|
+
const digitsOnly = normalizeDigits(event.currentTarget.value).slice(
|
|
66
|
+
0,
|
|
67
|
+
MAX_DIGITS,
|
|
68
|
+
);
|
|
69
|
+
if (!isControlled) {
|
|
70
|
+
setDigitsState(digitsOnly);
|
|
71
|
+
}
|
|
72
|
+
const formatted = formatPhoneNumber(digitsOnly);
|
|
73
|
+
if (event.currentTarget.value !== formatted) {
|
|
74
|
+
event.currentTarget.value = formatted;
|
|
75
|
+
}
|
|
76
|
+
onValueChange?.(formatted, digitsOnly);
|
|
77
|
+
onChange?.(event);
|
|
78
|
+
},
|
|
79
|
+
[isControlled, onChange, onValueChange],
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const actionButton = useMemo(() => {
|
|
83
|
+
if (!onRequestCode) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
// 휴대폰 인증 입력은 우측 suffix에 인증 버튼을 둔다.
|
|
87
|
+
return (
|
|
88
|
+
<button
|
|
89
|
+
type="button"
|
|
90
|
+
className="input-action-button"
|
|
91
|
+
onClick={onRequestCode}
|
|
92
|
+
disabled={requestButtonDisabled}
|
|
93
|
+
>
|
|
94
|
+
{requestButtonLabel}
|
|
95
|
+
</button>
|
|
96
|
+
);
|
|
97
|
+
}, [onRequestCode, requestButtonDisabled, requestButtonLabel]);
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<Text
|
|
101
|
+
{...restProps}
|
|
102
|
+
ref={forwardedRef}
|
|
103
|
+
type="tel"
|
|
104
|
+
inputMode="tel"
|
|
105
|
+
value={formattedValue}
|
|
106
|
+
onChange={handleChange}
|
|
107
|
+
suffix={suffix ?? actionButton}
|
|
108
|
+
/>
|
|
109
|
+
);
|
|
110
|
+
},
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
PhoneInput.displayName = "PhoneInput";
|
|
114
|
+
|
|
115
|
+
export { PhoneInput };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { forwardRef, useMemo } from "react";
|
|
2
|
+
import type { InputProps } from "../../types";
|
|
3
|
+
import { Text } from "./Base";
|
|
4
|
+
import SearchIcon from "../../img/search.svg";
|
|
5
|
+
|
|
6
|
+
export interface SearchInputProps extends Omit<InputProps, "type"> {}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* SearchInput — 기본 Text 입력에 검색 아이콘 prefix를 제공한다.
|
|
10
|
+
* @param props.prefix prefix slot. 정의하지 않으면 검색 아이콘이 자동 배치된다.
|
|
11
|
+
*/
|
|
12
|
+
const SearchInput = forwardRef<HTMLInputElement, SearchInputProps>(
|
|
13
|
+
({ prefix, ...restProps }, forwardedRef) => {
|
|
14
|
+
const prefixNode = useMemo(() => {
|
|
15
|
+
if (prefix) {
|
|
16
|
+
return prefix;
|
|
17
|
+
}
|
|
18
|
+
// 검색 input은 기본적으로 돋보기 아이콘 prefix를 노출한다.
|
|
19
|
+
return <SearchIcon aria-hidden="true" />;
|
|
20
|
+
}, [prefix]);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Text
|
|
24
|
+
{...restProps}
|
|
25
|
+
ref={forwardedRef}
|
|
26
|
+
type="search"
|
|
27
|
+
prefix={prefixNode}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
SearchInput.displayName = "SearchInput";
|
|
34
|
+
|
|
35
|
+
export { SearchInput };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { Text } from "./Base";
|
|
2
|
+
export { Text as Input } from "./Base";
|
|
3
|
+
export { PasswordInput } from "./Password";
|
|
4
|
+
export { PhoneInput } from "./Phone";
|
|
5
|
+
export { SearchInput } from "./Search";
|
|
6
|
+
export { IdentificationInput } from "./Identification";
|
|
7
|
+
export type { PasswordInputProps } from "./Password";
|
|
8
|
+
export type { PhoneInputProps } from "./Phone";
|
|
9
|
+
export type { SearchInputProps } from "./Search";
|
|
10
|
+
export type { IdentificationInputProps } from "./Identification";
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
@use "@uniai-fe/uds-foundation/css";
|
|
2
|
+
|
|
3
|
+
:where(.radix-themes, .theme-root, :root) {
|
|
4
|
+
--theme-input-height-small: var(--theme-size-medium-1);
|
|
5
|
+
--theme-input-height-medium: var(--theme-size-medium-2);
|
|
6
|
+
--theme-input-height-large: var(--theme-size-medium-3);
|
|
7
|
+
--theme-input-height-teritary: calc(var(--theme-size-medium-2) + 24px);
|
|
8
|
+
--theme-input-padding-x: var(--spacing-padding-6);
|
|
9
|
+
--theme-input-padding-y: var(--spacing-padding-4);
|
|
10
|
+
--theme-input-gap: var(--spacing-gap-4);
|
|
11
|
+
--theme-input-radius-default: var(--theme-radius-large-1);
|
|
12
|
+
--theme-input-radius-teritary: var(--theme-radius-large-2);
|
|
13
|
+
--theme-input-label-color: var(--color-label-standard);
|
|
14
|
+
--theme-input-helper-color: var(--color-label-neutral);
|
|
15
|
+
--theme-input-helper-disabled-color: var(--color-label-disabled);
|
|
16
|
+
--theme-input-label-accent-color: var(--color-primary-default);
|
|
17
|
+
--theme-input-label-error-color: var(--color-error);
|
|
18
|
+
--theme-input-placeholder-color: var(--color-label-alternative);
|
|
19
|
+
--theme-input-text-color: var(--color-label-strong);
|
|
20
|
+
--theme-input-border-color: var(--color-border-standard-cool-gray);
|
|
21
|
+
--theme-input-border-width-default: 1px;
|
|
22
|
+
--theme-input-border-width-emphasis: 1.4px;
|
|
23
|
+
--theme-input-border-active: #99bdff;
|
|
24
|
+
// success 상태는 파란색 보더(blue-80) 사용
|
|
25
|
+
--theme-input-border-success: #99bdff;
|
|
26
|
+
// error 상태는 Figma 기준 44% alpha 레드 보더 사용
|
|
27
|
+
--theme-input-border-error: rgba(218, 29, 11, 0.44);
|
|
28
|
+
--theme-input-border-disabled: var(--color-border-standard-cool-gray);
|
|
29
|
+
--theme-input-border-underline-disabled: var(
|
|
30
|
+
--color-border-standard-assistive
|
|
31
|
+
);
|
|
32
|
+
--theme-input-surface: var(--color-common-100);
|
|
33
|
+
--theme-input-surface-muted: var(--color-neutral-99);
|
|
34
|
+
--theme-input-surface-disabled: var(--color-neutral-95);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.input {
|
|
38
|
+
display: flex;
|
|
39
|
+
flex-direction: column;
|
|
40
|
+
gap: var(--spacing-gap-3);
|
|
41
|
+
width: 100%;
|
|
42
|
+
|
|
43
|
+
&[data-block="true"],
|
|
44
|
+
&--block {
|
|
45
|
+
width: 100%;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.input-label {
|
|
50
|
+
color: var(--theme-input-label-color);
|
|
51
|
+
font-size: var(--font-label-small-size);
|
|
52
|
+
line-height: var(--font-label-small-line-height);
|
|
53
|
+
font-weight: var(--font-label-small-weight);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.input-label--visually-hidden {
|
|
57
|
+
position: absolute;
|
|
58
|
+
width: 1px;
|
|
59
|
+
height: 1px;
|
|
60
|
+
padding: 0;
|
|
61
|
+
margin: -1px;
|
|
62
|
+
overflow: hidden;
|
|
63
|
+
clip: rect(0 0 0 0);
|
|
64
|
+
clip-path: inset(50%);
|
|
65
|
+
white-space: nowrap;
|
|
66
|
+
border: 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.input-box {
|
|
70
|
+
width: 100%;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.input-field {
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
width: 100%;
|
|
77
|
+
gap: var(--theme-input-gap);
|
|
78
|
+
border-radius: var(--theme-input-radius-default);
|
|
79
|
+
border: var(--theme-input-border-width-default) solid
|
|
80
|
+
var(--theme-input-border-color);
|
|
81
|
+
background-color: var(--theme-input-surface);
|
|
82
|
+
padding: var(--theme-input-padding-y) var(--theme-input-padding-x);
|
|
83
|
+
min-height: var(--theme-input-height-medium);
|
|
84
|
+
transition:
|
|
85
|
+
border-color 0.15s ease,
|
|
86
|
+
background-color 0.15s ease;
|
|
87
|
+
box-sizing: border-box;
|
|
88
|
+
outline: none;
|
|
89
|
+
box-shadow: none;
|
|
90
|
+
|
|
91
|
+
&[data-size="small"] {
|
|
92
|
+
min-height: var(--theme-input-height-small);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
&[data-size="large"] {
|
|
96
|
+
min-height: var(--theme-input-height-large);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&[data-appearance="secondary"] {
|
|
100
|
+
border: none;
|
|
101
|
+
border-bottom: var(--theme-input-border-width-default) solid
|
|
102
|
+
var(--theme-input-border-color);
|
|
103
|
+
border-radius: 0;
|
|
104
|
+
padding-inline: 0;
|
|
105
|
+
padding-block: var(--spacing-padding-4);
|
|
106
|
+
background-color: transparent;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
&[data-appearance="teritary"] {
|
|
110
|
+
border-radius: var(--theme-input-radius-teritary);
|
|
111
|
+
background-color: var(--theme-input-surface);
|
|
112
|
+
min-height: var(--theme-input-height-teritary);
|
|
113
|
+
flex-wrap: wrap;
|
|
114
|
+
row-gap: var(--spacing-gap-1);
|
|
115
|
+
column-gap: var(--theme-input-gap);
|
|
116
|
+
|
|
117
|
+
.input-inline-label {
|
|
118
|
+
flex-basis: 100%;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.input-element {
|
|
122
|
+
min-height: var(--theme-size-medium-2);
|
|
123
|
+
width: auto;
|
|
124
|
+
flex: 1 1 auto;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.input-element + .input-affix {
|
|
128
|
+
// inline label 다음 줄에서 input 오른쪽 끝으로 아이콘을 밀어낸다.
|
|
129
|
+
margin-left: auto;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
&:not([data-appearance="secondary"]) {
|
|
134
|
+
&[data-state="active"],
|
|
135
|
+
&[data-state="focused"] {
|
|
136
|
+
border-color: var(--theme-input-border-active);
|
|
137
|
+
border-width: var(--theme-input-border-width-emphasis);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
&[data-state="success"] {
|
|
141
|
+
border-color: var(--theme-input-border-success);
|
|
142
|
+
border-width: var(--theme-input-border-width-emphasis);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
&[data-state="error"] {
|
|
146
|
+
border-color: var(--theme-input-border-error);
|
|
147
|
+
border-width: var(--theme-input-border-width-emphasis);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
&[data-state="disabled"] {
|
|
151
|
+
border-color: var(--theme-input-border-disabled);
|
|
152
|
+
border-width: var(--theme-input-border-width-default);
|
|
153
|
+
background-color: var(--theme-input-surface-disabled);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.input-element {
|
|
158
|
+
flex: 1 1 auto;
|
|
159
|
+
width: 100%;
|
|
160
|
+
border: none;
|
|
161
|
+
background: transparent;
|
|
162
|
+
color: var(--theme-input-text-color);
|
|
163
|
+
font-size: var(--font-body-medium-size);
|
|
164
|
+
line-height: var(--font-body-medium-line-height);
|
|
165
|
+
font-weight: var(--font-body-medium-weight);
|
|
166
|
+
outline: none;
|
|
167
|
+
box-shadow: none;
|
|
168
|
+
min-width: 0;
|
|
169
|
+
|
|
170
|
+
&::placeholder {
|
|
171
|
+
color: var(--theme-input-placeholder-color);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
&:disabled {
|
|
175
|
+
color: var(--color-label-disabled);
|
|
176
|
+
|
|
177
|
+
&::placeholder {
|
|
178
|
+
color: var(--color-label-disabled);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
&:focus,
|
|
183
|
+
&:focus-visible,
|
|
184
|
+
&:focus-within {
|
|
185
|
+
outline: none;
|
|
186
|
+
box-shadow: none;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.input-inline-label {
|
|
192
|
+
order: -2;
|
|
193
|
+
flex-basis: 100%;
|
|
194
|
+
font-size: var(--font-label-small-size);
|
|
195
|
+
line-height: var(--font-label-small-line-height);
|
|
196
|
+
color: var(--theme-input-label-color);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.input-field[data-appearance="secondary"] .input-element {
|
|
200
|
+
padding-inline: 0;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.input-field[data-appearance="teritary"] .input-element {
|
|
204
|
+
min-height: var(--theme-size-medium-2);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.input-helper-text {
|
|
208
|
+
color: var(--theme-input-helper-color);
|
|
209
|
+
font-size: var(--font-label-small-size);
|
|
210
|
+
line-height: var(--font-label-small-line-height);
|
|
211
|
+
|
|
212
|
+
[data-state="error"] & {
|
|
213
|
+
color: var(--theme-input-border-error);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
[data-state="disabled"] & {
|
|
217
|
+
color: var(--theme-input-helper-disabled-color);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.input-affix {
|
|
222
|
+
display: inline-flex;
|
|
223
|
+
align-items: center;
|
|
224
|
+
justify-content: center;
|
|
225
|
+
min-width: 20px;
|
|
226
|
+
color: var(--theme-input-helper-color);
|
|
227
|
+
|
|
228
|
+
&--prefix {
|
|
229
|
+
order: -1;
|
|
230
|
+
margin-right: var(--spacing-gap-3);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
&--suffix,
|
|
234
|
+
&--reset,
|
|
235
|
+
&--status {
|
|
236
|
+
margin-left: var(--spacing-gap-3);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
&--reset,
|
|
240
|
+
&--status {
|
|
241
|
+
color: var(--theme-input-text-color);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// 상태별 아이콘 컬러는 디자인 토큰으로 직접 지정한다.
|
|
245
|
+
&--status[data-state="error"] {
|
|
246
|
+
color: var(--color-error);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
&--status[data-state="success"] {
|
|
250
|
+
color: var(--color-primary-default);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
.input-field[data-appearance="secondary"] {
|
|
254
|
+
border-bottom-width: var(--theme-input-border-width-default);
|
|
255
|
+
|
|
256
|
+
&[data-state="active"],
|
|
257
|
+
&[data-state="focused"] {
|
|
258
|
+
border-bottom-color: var(--theme-input-border-active);
|
|
259
|
+
border-bottom-width: var(--theme-input-border-width-emphasis);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
&[data-state="success"] {
|
|
263
|
+
border-bottom-color: var(--theme-input-border-success);
|
|
264
|
+
border-bottom-width: var(--theme-input-border-width-emphasis);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
&[data-state="error"] {
|
|
268
|
+
border-bottom-color: var(--theme-input-border-error);
|
|
269
|
+
border-bottom-width: var(--theme-input-border-width-emphasis);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
&[data-state="disabled"] {
|
|
273
|
+
border-bottom-color: var(--theme-input-border-underline-disabled);
|
|
274
|
+
border-bottom-width: var(--theme-input-border-width-default);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.input[data-state="active"],
|
|
279
|
+
.input[data-state="focused"],
|
|
280
|
+
.input[data-state="success"] {
|
|
281
|
+
.input-label,
|
|
282
|
+
.input-inline-label {
|
|
283
|
+
color: var(--theme-input-label-accent-color);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.input[data-state="error"] {
|
|
288
|
+
.input-label,
|
|
289
|
+
.input-inline-label {
|
|
290
|
+
color: var(--theme-input-label-error-color);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.input-helper-text {
|
|
294
|
+
color: var(--theme-input-label-error-color);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.input[data-state="disabled"] {
|
|
299
|
+
.input-label,
|
|
300
|
+
.input-inline-label,
|
|
301
|
+
.input-helper-text,
|
|
302
|
+
.input-affix {
|
|
303
|
+
color: var(--theme-input-helper-disabled-color);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.input-field {
|
|
307
|
+
border-color: var(--theme-input-border-color);
|
|
308
|
+
background-color: var(--theme-input-surface-disabled);
|
|
309
|
+
|
|
310
|
+
&[data-appearance="secondary"] {
|
|
311
|
+
background-color: transparent;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.input-password-toggle,
|
|
317
|
+
.input-action-button {
|
|
318
|
+
border: none;
|
|
319
|
+
background: transparent;
|
|
320
|
+
color: var(--theme-input-label-accent-color);
|
|
321
|
+
font-size: var(--font-label-small-size);
|
|
322
|
+
line-height: var(--font-label-small-line-height);
|
|
323
|
+
font-weight: var(--font-label-small-weight);
|
|
324
|
+
padding: 0;
|
|
325
|
+
cursor: pointer;
|
|
326
|
+
|
|
327
|
+
&:disabled {
|
|
328
|
+
color: var(--theme-input-helper-disabled-color);
|
|
329
|
+
cursor: not-allowed;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.input-search-icon {
|
|
334
|
+
font-size: var(--font-label-large-size);
|
|
335
|
+
line-height: 1;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.one-time-code {
|
|
339
|
+
display: flex;
|
|
340
|
+
flex-direction: column;
|
|
341
|
+
gap: var(--spacing-gap-2);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.one-time-code__label {
|
|
345
|
+
font-size: var(--font-label-small-size);
|
|
346
|
+
color: var(--theme-input-label-color);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.one-time-code__fields {
|
|
350
|
+
display: flex;
|
|
351
|
+
gap: var(--spacing-gap-3);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
.one-time-code__input {
|
|
355
|
+
width: 44px;
|
|
356
|
+
height: 56px;
|
|
357
|
+
border-radius: var(--theme-input-radius-default);
|
|
358
|
+
border: var(--theme-input-border-width-default) solid
|
|
359
|
+
var(--theme-input-border-color);
|
|
360
|
+
text-align: center;
|
|
361
|
+
font-size: var(--font-heading-medium-size);
|
|
362
|
+
font-weight: var(--font-heading-medium-weight);
|
|
363
|
+
color: var(--theme-input-text-color);
|
|
364
|
+
|
|
365
|
+
&:focus {
|
|
366
|
+
outline: none;
|
|
367
|
+
border-color: var(--theme-input-border-active);
|
|
368
|
+
border-width: var(--theme-input-border-width-emphasis);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.one-time-code__helper {
|
|
373
|
+
font-size: var(--font-label-small-size);
|
|
374
|
+
color: var(--theme-input-helper-color);
|
|
375
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactElement, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export const INPUT_APPEARANCES = ["primary", "secondary", "teritary"] as const;
|
|
4
|
+
export const INPUT_SIZES = ["small", "medium", "large"] as const;
|
|
5
|
+
export const INPUT_STATES = [
|
|
6
|
+
"default",
|
|
7
|
+
"active",
|
|
8
|
+
"focused",
|
|
9
|
+
"success",
|
|
10
|
+
"error",
|
|
11
|
+
"disabled",
|
|
12
|
+
] as const;
|
|
13
|
+
|
|
14
|
+
export type InputAppearance = (typeof INPUT_APPEARANCES)[number];
|
|
15
|
+
export type InputSize = (typeof INPUT_SIZES)[number];
|
|
16
|
+
export type InputState = (typeof INPUT_STATES)[number];
|
|
17
|
+
|
|
18
|
+
type NativeInputProps = ComponentPropsWithoutRef<"input">;
|
|
19
|
+
|
|
20
|
+
export interface InputAffix {
|
|
21
|
+
prefix?: ReactNode;
|
|
22
|
+
suffix?: ReactNode;
|
|
23
|
+
resetSlot?: ReactElement;
|
|
24
|
+
successIcon?: ReactNode;
|
|
25
|
+
errorIcon?: ReactNode;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface InputFeedback {
|
|
29
|
+
label?: ReactNode;
|
|
30
|
+
helperText?: ReactNode;
|
|
31
|
+
hideHelperText?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface InputProps
|
|
35
|
+
extends
|
|
36
|
+
Omit<NativeInputProps, "prefix" | "suffix" | "size">,
|
|
37
|
+
InputAffix,
|
|
38
|
+
InputFeedback {
|
|
39
|
+
appearance?: InputAppearance;
|
|
40
|
+
size?: InputSize;
|
|
41
|
+
state?: InputState;
|
|
42
|
+
block?: boolean;
|
|
43
|
+
inputClassName?: string;
|
|
44
|
+
wrapperClassName?: string;
|
|
45
|
+
labelProps?: ComponentPropsWithoutRef<"label">;
|
|
46
|
+
helperTextProps?: ComponentPropsWithoutRef<"div">;
|
|
47
|
+
"data-simulated-state"?: InputState;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface InputClassNameOptions {
|
|
51
|
+
appearance: InputAppearance;
|
|
52
|
+
size: InputSize;
|
|
53
|
+
state: InputState;
|
|
54
|
+
block: boolean;
|
|
55
|
+
className?: string;
|
|
56
|
+
}
|