File tree Expand file tree Collapse file tree 2 files changed +48
-12
lines changed Expand file tree Collapse file tree 2 files changed +48
-12
lines changed Original file line number Diff line number Diff line change 7373 :dark =" darkMode"
7474 type =" number"
7575 />
76+ <br >
77+ <VueInputUi
78+ v-model =" value9"
79+ label =" Required input"
80+ hint =" is required"
81+ :dark =" darkMode"
82+ required
83+ />
7684 </div >
7785 </div >
7886 </div >
96104 value6: ' Hello world!' ,
97105 value7: null ,
98106 value8: null ,
107+ value9: null ,
99108 darkMode: false
100109 }
101110 }
Original file line number Diff line number Diff line change 77 'has-error': error,
88 'is-disabled': disabled,
99 'is-dark': dark,
10- 'is-focused': valid
10+ 'is-focused': valid,
11+ 'has-hint': hint && !value
1112 }, size]"
1213 class =" field"
1314 @click =" focusInput"
1617 :id =" id"
1718 ref =" VueInputUi"
1819 v-model =" inputValue"
19- :placeholder =" label "
20+ :placeholder =" labelValue "
2021 :disabled =" disabled"
2122 :style =" [borderStyle]"
2223 :type =" type"
2324 class =" field-input"
2425 :readonly =" readonly"
26+ :required =" required"
2527 @focus =" onFocus"
2628 @blur =" onBlur"
2729 @click =" $emit('click')"
2830 >
2931 <label
3032 ref =" label"
3133 :for =" id"
32- :class =" error ? 'text-danger' : null"
34+ :class =" error ? 'lm- text-danger' : null"
3335 :style =" [colorStyle]"
3436 class =" field-label"
3537 @click =" focusInput"
3638 >
37- {{ hint || label }}
39+ {{ hintValue || labelValue }}
3840 </label >
3941 </div >
4042</template >
5557 type: { type: String , default: ' text' },
5658 readonly: { type: Boolean , default: false },
5759 valid: { type: Boolean , default: false },
58- validColor: { type: String , default: ' yellowgreen' }
60+ validColor: { type: String , default: ' yellowgreen' },
61+ required: { type: Boolean , default: false }
5962 },
6063 data : function () {
6164 return {
8285 set (value) {
8386 this .$emit (' input' , value)
8487 }
88+ },
89+ labelValue () {
90+ let label = this .label
91+ if (this .required && label) {
92+ label += ` *`
93+ }
94+ return label
95+ },
96+ hintValue () {
97+ let hint = this .hint
98+ if (this .required && hint) {
99+ hint += ` *`
100+ }
101+ return hint
85102 }
86103 },
87104 methods: {
123140 }
124141 .field-label {
125142 position : absolute ;
126- top : 3 px ;
143+ top : 4 px ;
127144 cursor : pointer ;
128145 left : 13px ;
129146 -webkit-transform : translateY (25% );
152169 font-size : 14px ;
153170 z-index : 0 ;
154171 }
155- & .has-error {
156- .field-input {
157- border-color : orangered !important ;
158- }
159- }
160172 & .has-value {
161173 .field-label {
162174 opacity : 1 ;
168180 padding-top : 14px ;
169181 }
170182 }
183+ & .has-hint {
184+ .field-label {
185+ opacity : 1 ;
186+ transform : translateY (0 );
187+ font-size : 11px ;
188+ }
189+ .field-input {
190+ padding-top : 14px ;
191+ }
192+ }
171193 & .is-focused {
172194 .field-input {
173195 border-color : dodgerblue ;
176198 color : dodgerblue ;
177199 }
178200 }
201+ & .has-error {
202+ .field-input {
203+ border-color : orangered !important ;
204+ }
205+ }
179206 & .is-disabled {
180207 .field-input {
181208 border-color : #CCC ;
185212 cursor : default ;
186213 }
187214 }
188- .text-danger {
215+ .lm- text-danger {
189216 color : orangered !important ;
190217 }
191218 & .is-dark {
You can’t perform that action at this time.
0 commit comments