forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput-frame.js
More file actions
108 lines (106 loc) · 2.83 KB
/
input-frame.js
File metadata and controls
108 lines (106 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
import { stopAndPrevent } from '../utils/event.js'
import AlignMixin from './align.js'
const marginal = {
type: Array,
validator: v => v.every(i => 'icon' in i)
}
export default {
mixins: [AlignMixin],
props: {
prefix: String,
suffix: String,
stackLabel: String,
floatLabel: String,
placeholder: String,
error: Boolean,
warning: Boolean,
disable: Boolean,
readonly: Boolean,
clearable: Boolean,
color: {
type: String,
default: 'primary'
},
align: {
default: 'left'
},
dark: Boolean,
before: marginal,
after: marginal,
inverted: Boolean,
invertedLight: Boolean,
hideUnderline: Boolean,
clearValue: {},
noParentField: Boolean
},
computed: {
inputPlaceholder () {
if ((!this.floatLabel && !this.stackLabel) || this.labelIsAbove) {
return this.placeholder
}
},
isInverted () {
return this.inverted || this.invertedLight
},
isInvertedLight () {
return this.isInverted && ((this.invertedLight && !this.hasError) || (this.inverted && this.hasWarning))
},
isStandard () {
return !this.isInverted
},
isHideUnderline () {
return this.isStandard && this.hideUnderline
},
labelIsAbove () {
return this.focused || this.length || this.additionalLength || this.stackLabel
},
hasContent () {
return this.length > 0 || this.additionalLength > 0 || this.placeholder || this.placeholder === 0
},
editable () {
return !this.disable && !this.readonly
},
computedClearValue () {
return this.clearValue === void 0 ? null : this.clearValue
},
isClearable () {
return this.editable && this.clearable && this.computedClearValue !== this.model
},
hasError () {
return !!((!this.noParentField && this.field && this.field.error) || this.error)
},
hasWarning () {
// error is the higher priority
return !!(!this.hasError && ((!this.noParentField && this.field && this.field.warning) || this.warning))
},
fakeInputValue () {
return this.actualValue || this.actualValue === 0
? this.actualValue
: (
this.placeholder || this.placeholder === 0
? this.placeholder
: ''
)
},
fakeInputClasses () {
const hasValue = this.actualValue || this.actualValue === 0
return [this.alignClass, {
invisible: (this.stackLabel || this.floatLabel) && !this.labelIsAbove && !hasValue,
'q-input-target-placeholder': !hasValue && this.inputPlaceholder
}]
}
},
methods: {
clear (evt) {
if (!this.editable) {
return
}
evt && stopAndPrevent(evt)
const val = this.computedClearValue
if (this.__setModel) {
this.__setModel(val, true)
}
this.$emit('clear', val)
}
}
}