react-validate-component 1.1.0 → 1.1.2

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.
@@ -1,5 +1,5 @@
1
1
  .invalid {
2
- border: 2px solid red;
2
+ border: 1px solid red;
3
3
  outline: none;
4
4
  }
5
5
  .invalid:focus,
@@ -26,6 +26,7 @@
26
26
  /* vType === 'outer' */
27
27
  .vinput {
28
28
  display: flex;
29
+ width: fit-content;
29
30
  }
30
31
  .vinput-top-left {
31
32
  flex-direction: column-reverse;
@@ -113,13 +114,16 @@
113
114
  }
114
115
 
115
116
  /* vType === 'tooltip' */
117
+ * {
118
+ --tooltip-default-color: #333;
119
+ }
116
120
  .tooltipMessage {
117
121
  position: absolute;
118
122
  margin: 0;
119
123
  padding: 10px 20px;
120
124
  border: 1px solid transparent;
121
125
  border-radius: 10px;
122
- background-color: black;
126
+ background-color: var(--tooltip-default-color);
123
127
  }
124
128
  p[class*='tooltipMessage-top'] {
125
129
  transform: translateY(calc(-100% - 10px));
@@ -129,15 +133,15 @@ p[class*='tooltipMessage-top']::after {
129
133
  position: absolute;
130
134
  bottom: 0;
131
135
  border: 10px solid transparent;
132
- border-top-color: black;
136
+ border-top-color: var(--tooltip-default-color);
133
137
  border-bottom: 0;
134
- margin-bottom: -11px;
138
+ margin-bottom: -10px;
135
139
  }
136
140
  .vinput.tooltipMessage-top-left {
137
141
  justify-content: flex-start;
138
142
  }
139
143
  p.tooltipMessage-top-left::after {
140
- left: 3%;
144
+ left: 10%;
141
145
  }
142
146
  .vinput.tooltipMessage-top {
143
147
  justify-content: center;
@@ -149,7 +153,7 @@ p.tooltipMessage-top::after {
149
153
  justify-content: flex-end;
150
154
  }
151
155
  p.tooltipMessage-top-right::after {
152
- left: 87%;
156
+ left: 80%;
153
157
  }
154
158
  p[class*='tooltipMessage-center'] {
155
159
  /* transform: translateY(calc(-100% - 10px)); */
@@ -166,8 +170,8 @@ p.tooltipMessage-center-right {
166
170
  transform: translateX(calc(100% + 10px));
167
171
  }
168
172
  p.tooltipMessage-center-right::after {
169
- border-right-color: black;
170
- left: -10%;
173
+ border-right-color: var(--tooltip-default-color);
174
+ left: -15%;
171
175
  }
172
176
  .vinput.tooltipMessage-center-left {
173
177
  justify-content: flex-start;
@@ -176,7 +180,7 @@ p.tooltipMessage-center-left {
176
180
  transform: translateX(calc(-100% - 10px));
177
181
  }
178
182
  p.tooltipMessage-center-left::after {
179
- border-left-color: black;
183
+ border-left-color: var(--tooltip-default-color);
180
184
  left: 100%;
181
185
  }
182
186
 
@@ -188,7 +192,7 @@ p[class*='tooltipMessage-bottom']::after {
188
192
  position: absolute;
189
193
  top: 0;
190
194
  border: 10px solid transparent;
191
- border-bottom-color: black;
195
+ border-bottom-color: var(--tooltip-default-color);
192
196
  border-top: 0;
193
197
  margin-top: -11px;
194
198
  }
@@ -196,7 +200,7 @@ p[class*='tooltipMessage-bottom']::after {
196
200
  justify-content: flex-start;
197
201
  }
198
202
  p.tooltipMessage-bottom-left::after {
199
- left: 3%;
203
+ left: 10%;
200
204
  }
201
205
  .vinput.tooltipMessage-bottom {
202
206
  justify-content: center;
@@ -208,7 +212,7 @@ p.tooltipMessage-bottom::after {
208
212
  justify-content: flex-end;
209
213
  }
210
214
  p.tooltipMessage-bottom-right::after {
211
- left: 87%;
215
+ left: 80%;
212
216
  }
213
217
 
214
218
  .animateMessage {
@@ -46,6 +46,7 @@ export function VCheckbox({
46
46
  }
47
47
 
48
48
  switch (vType) {
49
+ default:
49
50
  case 'top':
50
51
  return (
51
52
  <div>
@@ -76,7 +77,5 @@ export function VCheckbox({
76
77
  ) : null}
77
78
  </div>
78
79
  );
79
- default:
80
- return <></>;
81
80
  }
82
81
  }
@@ -13,6 +13,7 @@ export function VColor({
13
13
  props = {},
14
14
  }: VCOLOR_PARAMS) {
15
15
  switch (vType) {
16
+ default:
16
17
  case 'top':
17
18
  return (
18
19
  <>
@@ -47,7 +48,5 @@ export function VColor({
47
48
  ) : null}
48
49
  </>
49
50
  );
50
- default:
51
- return <></>;
52
51
  }
53
52
  }
@@ -13,6 +13,7 @@ export function VDate({
13
13
  props = {},
14
14
  }: VDATE_PARAMS) {
15
15
  switch (vType) {
16
+ default:
16
17
  case 'top':
17
18
  return (
18
19
  <>
@@ -47,7 +48,5 @@ export function VDate({
47
48
  ) : null}
48
49
  </>
49
50
  );
50
- default:
51
- return <></>;
52
51
  }
53
52
  }
@@ -14,6 +14,7 @@ export function VEmail({
14
14
  props = {},
15
15
  }: VEMAIL_PARAMS) {
16
16
  switch (vType) {
17
+ default:
17
18
  case 'outer':
18
19
  return (
19
20
  <div
@@ -86,7 +87,5 @@ export function VEmail({
86
87
  ) : null}
87
88
  </div>
88
89
  );
89
- default:
90
- return <div></div>;
91
90
  }
92
91
  }
@@ -38,6 +38,7 @@ export function VRadio({
38
38
  }
39
39
 
40
40
  switch (vType) {
41
+ default:
41
42
  case 'bottom':
42
43
  return (
43
44
  <>
@@ -103,7 +104,5 @@ export function VRadio({
103
104
  ) : null}
104
105
  </>
105
106
  );
106
- default:
107
- return <div></div>;
108
107
  }
109
108
  }
@@ -13,6 +13,7 @@ export function VRange({
13
13
  props = {},
14
14
  }: VRANGE_PARAMS) {
15
15
  switch (vType) {
16
+ default:
16
17
  case 'top':
17
18
  return (
18
19
  <>
@@ -47,7 +48,5 @@ export function VRange({
47
48
  ) : null}
48
49
  </>
49
50
  );
50
- default:
51
- return <></>;
52
51
  }
53
52
  }
@@ -1,134 +1,131 @@
1
- import React from 'react';
2
- import styles from '../index.module.css';
3
- import { VTEXT_PARAMS } from './vText';
4
-
5
- // Text
6
- export function VText({
7
- vState = false,
8
- vType = 'outer',
9
- vClassName = '',
10
- vShowMessage = false,
11
- vMessage = '',
12
- vLocateMessage = 'bottom',
13
- vMessageClass = '',
14
- vIsAnimate = false,
15
- vUseMaxLength = false,
16
- vMaxLength = 0,
17
- vClassMaxLength = '',
18
- props = {},
19
- }: VTEXT_PARAMS) {
20
- const inputRef = React.useRef<HTMLInputElement>(null);
21
- const [inputLength, setInputLength] = React.useState<number>(
22
- (props?.defaultValue || props?.value)?.length ?? 0
23
- );
24
-
25
- // 공통 input 태그 변수화
26
- const inputHTML = (
27
- <input
28
- type="text"
29
- ref={inputRef}
30
- {...props}
31
- onChange={e => {
32
- if (vUseMaxLength && e.target.value.length > vMaxLength) {
33
- e.preventDefault();
34
- e.target.value = e.target.value.slice(0, vMaxLength);
35
- } else {
36
- props?.onChange(e);
37
- }
38
- }}
39
- defaultValue={props?.defaultValue ?? ''}
40
- className={`${props?.className ?? ''} ${vClassName} ${
41
- vState ? styles.invalid : ''
42
- }`}
43
- ></input>
44
- );
45
-
46
- // 일부 옵션 값들은 input 기본 속성값을 이용하기 위해 merge 진행
47
- if (vUseMaxLength) {
48
- props = { ...props, maxLength: vMaxLength };
49
- }
50
-
51
- React.useEffect(() => {
52
- // 입력 최댓값을 사용할 경우 useEffect Hook 설정
53
- if (vUseMaxLength) {
54
- setInputLength((inputRef.current?.value ?? '').length);
55
- }
56
- }, [inputRef.current?.value]);
57
-
58
- switch (vType) {
59
- case 'outer':
60
- return (
61
- <div
62
- className={`${styles.vinput} ${styles[`vinput-${vLocateMessage}`]} ${
63
- vUseMaxLength ? styles.vMaxLengthContainer : ''
64
- }`}
65
- >
66
- {inputHTML}
67
- {vUseMaxLength && (
68
- <p className={`${styles.vMaxLength} ${vClassMaxLength}`}>
69
- {inputLength} / {vMaxLength}
70
- </p>
71
- )}
72
- {vState && vShowMessage ? (
73
- <p
74
- className={`${vMessageClass} ${
75
- vIsAnimate ? styles.animateMessage : ''
76
- }`}
77
- >
78
- {vMessage}
79
- </p>
80
- ) : null}
81
- </div>
82
- );
83
- case 'inner':
84
- return (
85
- <div
86
- className={`${styles.vinput} ${
87
- vUseMaxLength ? styles.vMaxLengthContainer : ''
88
- }`}
89
- >
90
- {inputHTML}
91
- {vUseMaxLength && (
92
- <p className={`${styles.vMaxLength} ${vClassMaxLength}`}>
93
- {inputLength} / {vMaxLength}
94
- </p>
95
- )}
96
- {vState && vShowMessage ? (
97
- <p
98
- className={`${vMessageClass} ${styles.innerMessage} ${
99
- styles[`innerMessage-${vLocateMessage}`]
100
- } ${vIsAnimate ? styles.animateMessage : ''}`}
101
- >
102
- {vMessage}
103
- </p>
104
- ) : null}
105
- </div>
106
- );
107
- case 'tooltip':
108
- return (
109
- <div
110
- className={`${styles.vinput} ${
111
- styles[`tooltipMessage-${vLocateMessage}`]
112
- } ${vUseMaxLength ? styles.vMaxLengthContainer : ''}`}
113
- >
114
- {inputHTML}
115
- {vUseMaxLength && (
116
- <p className={`${styles.vMaxLength} ${vClassMaxLength}`}>
117
- {inputLength} / {vMaxLength}
118
- </p>
119
- )}
120
- {vState && vShowMessage ? (
121
- <p
122
- className={`${vMessageClass} ${styles.tooltipMessage} ${
123
- styles[`tooltipMessage-${vLocateMessage}`]
124
- } ${vIsAnimate ? styles.animateMessage : ''}`}
125
- >
126
- {vMessage}
127
- </p>
128
- ) : null}
129
- </div>
130
- );
131
- default:
132
- return <div></div>;
133
- }
134
- }
1
+ import React from 'react';
2
+ import styles from '../index.module.css';
3
+ import { VTEXT_PARAMS } from './vText';
4
+
5
+ // Text
6
+ export function VText({
7
+ vState = false,
8
+ vType = 'outer',
9
+ vClassName = '',
10
+ vShowMessage = false,
11
+ vMessage = '',
12
+ vLocateMessage = 'bottom',
13
+ vMessageClass = '',
14
+ vIsAnimate = false,
15
+ vUseMaxLength = false,
16
+ vMaxLength = 0,
17
+ vClassMaxLength = '',
18
+ props = {},
19
+ }: VTEXT_PARAMS) {
20
+ const [inputLength, setInputLength] = React.useState<number>(
21
+ (props?.defaultValue || props?.value)?.length ?? 0
22
+ );
23
+
24
+ // 공통 input 태그 변수화
25
+ const inputHTML = () => {
26
+ return (
27
+ <input
28
+ type="text"
29
+ {...props}
30
+ onChange={e => {
31
+ if (vUseMaxLength && e.target.value.length > vMaxLength) {
32
+ e.preventDefault();
33
+ e.target.value = e.target.value.slice(0, vMaxLength);
34
+ } else {
35
+ props?.onChange(e);
36
+ if (vUseMaxLength) {
37
+ setInputLength(e.target.value.length);
38
+ }
39
+ }
40
+ }}
41
+ defaultValue={props?.defaultValue ?? ''}
42
+ className={`${props?.className ?? ''} ${vClassName} ${
43
+ vState ? styles.invalid : ''
44
+ }`}
45
+ ></input>
46
+ );
47
+ };
48
+
49
+ // 일부 옵션 값들은 input 기본 속성값을 이용하기 위해 merge 진행
50
+ if (vUseMaxLength) {
51
+ props = { ...props, maxLength: vMaxLength };
52
+ }
53
+
54
+ switch (vType) {
55
+ default:
56
+ case 'outer':
57
+ return (
58
+ <div
59
+ className={`${styles.vinput} ${styles[`vinput-${vLocateMessage}`]} ${
60
+ vUseMaxLength ? styles.vMaxLengthContainer : ''
61
+ }`}
62
+ >
63
+ <div style={{ position: 'relative' }}>
64
+ {inputHTML()}
65
+ {vUseMaxLength && (
66
+ <p className={`${styles.vMaxLength} ${vClassMaxLength}`}>
67
+ {inputLength} / {vMaxLength}
68
+ </p>
69
+ )}
70
+ </div>
71
+ {vState && vShowMessage ? (
72
+ <p
73
+ className={`${vMessageClass} ${
74
+ vIsAnimate ? styles.animateMessage : ''
75
+ }`}
76
+ >
77
+ {vMessage}
78
+ </p>
79
+ ) : null}
80
+ </div>
81
+ );
82
+ case 'inner':
83
+ return (
84
+ <div
85
+ className={`${styles.vinput} ${
86
+ vUseMaxLength ? styles.vMaxLengthContainer : ''
87
+ }`}
88
+ >
89
+ {inputHTML()}
90
+ {vUseMaxLength && (
91
+ <p className={`${styles.vMaxLength} ${vClassMaxLength}`}>
92
+ {inputLength} / {vMaxLength}
93
+ </p>
94
+ )}
95
+ {vState && vShowMessage ? (
96
+ <p
97
+ className={`${vMessageClass} ${styles.innerMessage} ${
98
+ styles[`innerMessage-${vLocateMessage}`]
99
+ } ${vIsAnimate ? styles.animateMessage : ''}`}
100
+ >
101
+ {vMessage}
102
+ </p>
103
+ ) : null}
104
+ </div>
105
+ );
106
+ case 'tooltip':
107
+ return (
108
+ <div
109
+ className={`${styles.vinput} ${
110
+ styles[`tooltipMessage-${vLocateMessage}`]
111
+ } ${vUseMaxLength ? styles.vMaxLengthContainer : ''}`}
112
+ >
113
+ {inputHTML()}
114
+ {vUseMaxLength && (
115
+ <p className={`${styles.vMaxLength} ${vClassMaxLength}`}>
116
+ {inputLength} / {vMaxLength}
117
+ </p>
118
+ )}
119
+ {vState && vShowMessage ? (
120
+ <p
121
+ className={`${vMessageClass} ${styles.tooltipMessage} ${
122
+ styles[`tooltipMessage-${vLocateMessage}`]
123
+ } ${vIsAnimate ? styles.animateMessage : ''}`}
124
+ >
125
+ {vMessage}
126
+ </p>
127
+ ) : null}
128
+ </div>
129
+ );
130
+ }
131
+ }
@@ -14,6 +14,7 @@ export function VURL({
14
14
  props = {},
15
15
  }: VURL_PARAMS) {
16
16
  switch (vType) {
17
+ default:
17
18
  case 'outer':
18
19
  return (
19
20
  <div
@@ -86,7 +87,5 @@ export function VURL({
86
87
  ) : null}
87
88
  </div>
88
89
  );
89
- default:
90
- return <div></div>;
91
90
  }
92
91
  }