Skip to content

Commit bd02e8e

Browse files
pdanpdanrstoenescu
authored andcommitted
chore(QField): Use .q-field__input for custom input in QField and QSelect quasarframework#6049 (quasarframework#6061)
1 parent 267edc8 commit bd02e8e

File tree

8 files changed

+49
-59
lines changed

8 files changed

+49
-59
lines changed

docs/src/pages/vue-components/input.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ You can use v-money directive:
193193
hint="Mask: $ #,###.00 #"
194194
>
195195
<template v-slot:control="{ id, floatingLabel, value, emitValue }">
196-
<input :id="id" class="q-field__native text-right" :value="value" @change="e => emitValue(e.target.value)" v-money="moneyFormatForDirective" v-show="floatingLabel">
196+
<input :id="id" class="q-field__input text-right" :value="value" @change="e => emitValue(e.target.value)" v-money="moneyFormatForDirective" v-show="floatingLabel">
197197
</template>
198198
</q-field>
199199
```
@@ -219,7 +219,7 @@ Or you can use money component:
219219
hint="Mask: $ #,###.00 #"
220220
>
221221
<template v-slot:control="{ id, floatingLabel, value, emitValue }">
222-
<money :id="id" class="q-field__native text-right" :value="value" @input="emitValue" v-bind="moneyFormatForComponent" v-show="floatingLabel" />
222+
<money :id="id" class="q-field__input text-right" :value="value" @input="emitValue" v-bind="moneyFormatForComponent" v-show="floatingLabel" />
223223
</template>
224224
</q-field>
225225
```

ui/dev/components/form/input.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030

3131
<q-input v-bind="props" v-model="text" required label="Required" placeholder="Write something" />
3232

33+
<q-field v-bind="props" v-model="text" required label="Required - Custom input">
34+
<template v-slot:control="{ id, floatingLabel, value, emitValue }">
35+
<input :id="id" class="q-field__input" :value="value" @input="e => emitValue(e.target.value)" v-show="floatingLabel">
36+
</template>
37+
</q-field>
38+
3339
<q-input v-bind="props" v-model="invalid" pattern="[a-z]*" label="Only [a-z]" placeholder="Write something" />
3440

3541
<q-input v-bind="props" v-model="number" type="number" label="Number" placeholder="Write a number" />

ui/dev/components/form/select-part-5-kbd.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="q-layout-padding">
3-
<div class="bg-black text-white q-pa-sm">
3+
<div class="bg-black text-white q-pa-sm q-mb-xl">
44
<q-checkbox v-model="forceMenu" toggle-indeterminate dark :label="forceMenuLabel" /> / ModelS: {{ modelS || 'null' }} / ModelM: {{ modelM || 'null' }}
55
</div>
66

ui/src/components/field/QField.sass

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ $field-transition-label-right-up: .324s cubic-bezier(.4,0,.2,1)
9696
&:before
9797
border-radius: inherit
9898

99-
&__native, &__prefix, &__suffix
99+
&__native, &__prefix, &__suffix, &__input
100100
font-weight: 400
101101
line-height: 28px
102102
letter-spacing: .00937em
@@ -109,12 +109,17 @@ $field-transition-label-right-up: .324s cubic-bezier(.4,0,.2,1)
109109
outline: 0
110110
padding: 6px 0
111111

112-
&__native
112+
&__native, &__input
113113
width: 100%
114114
min-width: 0 // needed for FF
115115
outline: 0 !important // needed for FF
116-
&[type="file"]
117-
line-height: 1em // needed for Chrome type="file"
116+
&__native[type="file"]
117+
line-height: 1em // needed for Chrome type="file"
118+
&__input
119+
padding: 0
120+
height: 0
121+
min-height: 24px
122+
line-height: 24px
118123
&__prefix, &__suffix
119124
transition: opacity $field-transition
120125
white-space: nowrap
@@ -129,10 +134,10 @@ $field-transition-label-right-up: .324s cubic-bezier(.4,0,.2,1)
129134

130135
&--readonly
131136
&.q-field--labeled
132-
.q-field__native
137+
.q-field__native, .q-field__input
133138
cursor: default
134139
&.q-field--float
135-
.q-field__native
140+
.q-field__native, .q-field__input
136141
cursor: text
137142

138143
&--disabled
@@ -167,7 +172,7 @@ $field-transition-label-right-up: .324s cubic-bezier(.4,0,.2,1)
167172
right: calc(-100% / 3)
168173
transition: transform $field-transition, right $field-transition-label-right-down
169174

170-
.q-field__native, .q-select__input
175+
.q-field__native, .q-field__input
171176
&:-webkit-autofill
172177
-webkit-animation-name: q-autofill
173178
-webkit-animation-fill-mode: both
@@ -298,7 +303,7 @@ $field-transition-label-right-up: .324s cubic-bezier(.4,0,.2,1)
298303
.q-field__control:hover:before
299304
border-color: #fff
300305

301-
.q-field__native, .q-field__prefix, .q-field__suffix, .q-select__input
306+
.q-field__native, .q-field__prefix, .q-field__suffix, .q-field__input
302307
color: #fff
303308

304309
&:not(.q-field--focused) .q-field__label, .q-field__marginal, .q-field__bottom
@@ -327,7 +332,7 @@ $field-transition-label-right-up: .324s cubic-bezier(.4,0,.2,1)
327332
.q-field__control
328333
box-shadow: $shadow-2
329334
background: #000
330-
.q-field__native, .q-field__prefix, .q-field__suffix, .q-field__prepend, .q-field__append, .q-select__input
335+
.q-field__native, .q-field__prefix, .q-field__suffix, .q-field__prepend, .q-field__append, .q-field__input
331336
color: #fff
332337

333338
&.q-field--readonly
@@ -344,7 +349,7 @@ $field-transition-label-right-up: .324s cubic-bezier(.4,0,.2,1)
344349
&.q-field--focused
345350
.q-field__control
346351
background: #fff
347-
.q-field__native, .q-field__prefix, .q-field__suffix, .q-field__prepend, .q-field__append, .q-select__input
352+
.q-field__native, .q-field__prefix, .q-field__suffix, .q-field__prepend, .q-field__append, .q-field__input
348353
color: #000
349354
&.q-field--readonly
350355
.q-field__control:before
@@ -360,7 +365,7 @@ $field-transition-label-right-up: .324s cubic-bezier(.4,0,.2,1)
360365
.q-field__prefix, .q-field__suffix
361366
opacity: 0
362367

363-
.q-field__native, .q-select__input
368+
.q-field__native, .q-field__input
364369
&::-webkit-input-placeholder
365370
color: transparent
366371
&::-moz-placeholder
@@ -399,7 +404,7 @@ $field-transition-label-right-up: .324s cubic-bezier(.4,0,.2,1)
399404
&.q-field--float .q-field__label
400405
transform: translateY(-30%) scale(.75)
401406

402-
.q-field__native, .q-select__input
407+
.q-field__native, .q-field__input
403408
&:-webkit-autofill + .q-field__label
404409
transform: translateY(-30%) scale(.75)
405410
&[type="number"]:invalid + .q-field__label

ui/src/components/field/QField.styl

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ $field-transition-label-right-up = .324s cubic-bezier(.4,0,.2,1)
9696
&:before
9797
border-radius: inherit
9898

99-
&__native, &__prefix, &__suffix
99+
&__native, &__prefix, &__suffix, &__input
100100
font-weight: 400
101101
line-height: 28px
102102
letter-spacing: .00937em
@@ -109,12 +109,17 @@ $field-transition-label-right-up = .324s cubic-bezier(.4,0,.2,1)
109109
outline: 0
110110
padding: 6px 0
111111

112-
&__native
112+
&__native, &__input
113113
width: 100%
114114
min-width: 0 // needed for FF
115115
outline: 0 !important // needed for FF
116-
&[type="file"]
117-
line-height: 1em // needed for Chrome type="file"
116+
&__native[type="file"]
117+
line-height: 1em // needed for Chrome type="file"
118+
&__input
119+
padding: 0
120+
height: 0
121+
min-height: 24px
122+
line-height: 24px
118123
&__prefix, &__suffix
119124
transition: opacity $field-transition
120125
white-space: nowrap
@@ -129,10 +134,10 @@ $field-transition-label-right-up = .324s cubic-bezier(.4,0,.2,1)
129134

130135
&--readonly
131136
&.q-field--labeled
132-
.q-field__native
137+
.q-field__native, .q-field__input
133138
cursor: default
134139
&.q-field--float
135-
.q-field__native
140+
.q-field__native, .q-field__input
136141
cursor: text
137142

138143
&--disabled
@@ -167,7 +172,7 @@ $field-transition-label-right-up = .324s cubic-bezier(.4,0,.2,1)
167172
right: calc(-100% / 3)
168173
transition: transform $field-transition, right $field-transition-label-right-down
169174

170-
.q-field__native, .q-select__input
175+
.q-field__native, .q-field__input
171176
&:-webkit-autofill
172177
-webkit-animation-name: q-autofill
173178
-webkit-animation-fill-mode: both
@@ -298,7 +303,7 @@ $field-transition-label-right-up = .324s cubic-bezier(.4,0,.2,1)
298303
.q-field__control:hover:before
299304
border-color: #fff
300305

301-
.q-field__native, .q-field__prefix, .q-field__suffix, .q-select__input
306+
.q-field__native, .q-field__prefix, .q-field__suffix, .q-field__input
302307
color: #fff
303308

304309
&:not(.q-field--focused) .q-field__label, .q-field__marginal, .q-field__bottom
@@ -327,7 +332,7 @@ $field-transition-label-right-up = .324s cubic-bezier(.4,0,.2,1)
327332
.q-field__control
328333
box-shadow: $shadow-2
329334
background: #000
330-
.q-field__native, .q-field__prefix, .q-field__suffix, .q-field__prepend, .q-field__append, .q-select__input
335+
.q-field__native, .q-field__prefix, .q-field__suffix, .q-field__prepend, .q-field__append, .q-field__input
331336
color: #fff
332337

333338
&.q-field--readonly
@@ -344,7 +349,7 @@ $field-transition-label-right-up = .324s cubic-bezier(.4,0,.2,1)
344349
&.q-field--focused
345350
.q-field__control
346351
background: #fff
347-
.q-field__native, .q-field__prefix, .q-field__suffix, .q-field__prepend, .q-field__append, .q-select__input
352+
.q-field__native, .q-field__prefix, .q-field__suffix, .q-field__prepend, .q-field__append, .q-field__input
348353
color: #000
349354
&.q-field--readonly
350355
.q-field__control:before
@@ -360,7 +365,7 @@ $field-transition-label-right-up = .324s cubic-bezier(.4,0,.2,1)
360365
.q-field__prefix, .q-field__suffix
361366
opacity: 0
362367

363-
.q-field__native, .q-select__input
368+
.q-field__native, .q-field__input
364369
&::-webkit-input-placeholder
365370
color: transparent
366371
&::-moz-placeholder
@@ -399,7 +404,7 @@ $field-transition-label-right-up = .324s cubic-bezier(.4,0,.2,1)
399404
&.q-field--float .q-field__label
400405
transform: translateY(-30%) scale(.75)
401406

402-
.q-field__native, .q-select__input
407+
.q-field__native, .q-field__input
403408
&:-webkit-autofill + .q-field__label
404409
transform: translateY(-30%) scale(.75)
405410
&[type="number"]:invalid + .q-field__label

ui/src/components/select/QSelect.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ export default Vue.extend({
161161
}
162162

163163
return this.inputClass === void 0
164-
? 'q-select__input--padding'
165-
: [this.inputClass, 'q-select__input--padding']
164+
? 'q-field__input--padding'
165+
: [this.inputClass, 'q-field__input--padding']
166166
},
167167

168168
menuContentClass () {
@@ -819,7 +819,7 @@ export default Vue.extend({
819819

820820
return h('input', {
821821
ref: 'target',
822-
staticClass: 'q-select__input q-placeholder col',
822+
staticClass: 'q-field__input q-placeholder col',
823823
style: this.inputStyle,
824824
class: this.computedInputClass,
825825
domProps: { value: this.inputValue !== void 0 ? this.inputValue : '' },
@@ -950,7 +950,7 @@ export default Vue.extend({
950950
if (this.hasDialog !== true) {
951951
// label from QField will propagate click on the input (except IE)
952952
if (
953-
(this.useInput === true && e.target.classList.contains('q-select__input') !== true) ||
953+
(this.useInput === true && e.target.classList.contains('q-field__input') !== true) ||
954954
(this.useInput !== true && e.target.classList.contains('no-outline') === true)
955955
) {
956956
return

ui/src/components/select/QSelect.sass

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,8 @@
66
.q-field__control
77
cursor: text
88

9-
&__input
10-
border: 0
11-
outline: 0 !important // needed for FF
12-
background: transparent
9+
.q-field__input
1310
min-width: 50px !important
14-
padding: 0
15-
height: 0
16-
min-height: 24px
17-
line-height: 24px
1811

1912
&--padding
2013
padding-left: 4px
@@ -25,12 +18,6 @@
2518
&.q-field--readonly
2619
.q-field__control, .q-select__dropdown-icon
2720
cursor: default
28-
&.q-field--labeled
29-
.q-select__input
30-
cursor: default
31-
&.q-field--float
32-
.q-select__input
33-
cursor: text
3421

3522
&__dialog
3623
width: 90vw !important

ui/src/components/select/QSelect.styl

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,8 @@
66
.q-field__control
77
cursor: text
88

9-
&__input
10-
border: 0
11-
outline: 0 !important // needed for FF
12-
background: transparent
9+
.q-field__input
1310
min-width: 50px !important
14-
padding: 0
15-
height: 0
16-
min-height: 24px
17-
line-height: 24px
1811

1912
&--padding
2013
padding-left: 4px
@@ -25,12 +18,6 @@
2518
&.q-field--readonly
2619
.q-field__control, .q-select__dropdown-icon
2720
cursor: default
28-
&.q-field--labeled
29-
.q-select__input
30-
cursor: default
31-
&.q-field--float
32-
.q-select__input
33-
cursor: text
3421

3522
&__dialog
3623
width: 90vw !important

0 commit comments

Comments
 (0)