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.
- package/README.md +6 -4
- package/dist/react-validate-component.cjs.development.js +60 -67
- package/dist/react-validate-component.cjs.development.js.map +1 -1
- package/dist/react-validate-component.cjs.production.min.js +1 -1
- package/dist/react-validate-component.cjs.production.min.js.map +1 -1
- package/dist/react-validate-component.esm.js +60 -67
- package/dist/react-validate-component.esm.js.map +1 -1
- package/package.json +6 -4
- package/src/index.module.css +16 -12
- package/src/vCheckbox/index.tsx +1 -2
- package/src/vColor/index.tsx +1 -2
- package/src/vDate/index.tsx +1 -2
- package/src/vEmail/index.tsx +1 -2
- package/src/vRadio/index.tsx +1 -2
- package/src/vRange/index.tsx +1 -2
- package/src/vText/index.tsx +131 -134
- package/src/vURL/index.tsx +1 -2
package/src/index.module.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
.invalid {
|
|
2
|
-
border:
|
|
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:
|
|
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:
|
|
136
|
+
border-top-color: var(--tooltip-default-color);
|
|
133
137
|
border-bottom: 0;
|
|
134
|
-
margin-bottom: -
|
|
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:
|
|
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:
|
|
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:
|
|
170
|
-
left: -
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
215
|
+
left: 80%;
|
|
212
216
|
}
|
|
213
217
|
|
|
214
218
|
.animateMessage {
|
package/src/vCheckbox/index.tsx
CHANGED
package/src/vColor/index.tsx
CHANGED
package/src/vDate/index.tsx
CHANGED
package/src/vEmail/index.tsx
CHANGED
|
@@ -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
|
}
|
package/src/vRadio/index.tsx
CHANGED
package/src/vRange/index.tsx
CHANGED
package/src/vText/index.tsx
CHANGED
|
@@ -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
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
{
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
{
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
+
}
|
package/src/vURL/index.tsx
CHANGED