File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,24 @@ const formatNumberWithComma = (digits: string) => {
2020 return new Intl . NumberFormat ( 'ko-KR' ) . format ( n ) ;
2121} ;
2222
23+ const getMaxLength = ( {
24+ isChar,
25+ isTextarea,
26+ maxLength,
27+ } : {
28+ isChar : boolean ;
29+ isTextarea : boolean ;
30+ maxLength ?: number ;
31+ } ) => {
32+ if ( isChar ) {
33+ return CHAR_MAX_LENGTH ;
34+ }
35+ if ( maxLength !== undefined ) {
36+ return maxLength ;
37+ }
38+ return isTextarea ? TEXTAREA_MAX_LENGTH : undefined ;
39+ } ;
40+
2341export const TextField = ( {
2442 label,
2543 value : controlledValue ,
@@ -43,9 +61,7 @@ export const TextField = ({
4361 const isChar = type === 'char' ;
4462 const isPrice = type === 'price' ;
4563
46- const maxLen = isChar
47- ? CHAR_MAX_LENGTH
48- : ( maxLength ?? ( isTextarea ? TEXTAREA_MAX_LENGTH : undefined ) ) ;
64+ const maxLen = getMaxLength ( { isChar, isTextarea, maxLength } ) ;
4965 const normalizedValue = isPrice ? rawValue . replace ( / \D / g, '' ) : rawValue ;
5066
5167 const displayValue = useMemo ( ( ) => {
You can’t perform that action at this time.
0 commit comments