buefy 0.9.20 → 0.9.21
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/CHANGELOG.md +1741 -1741
- package/dist/buefy.css +1 -1
- package/dist/buefy.esm.js +45 -25
- package/dist/buefy.esm.min.js +2 -2
- package/dist/buefy.js +45 -25
- package/dist/buefy.min.css +1 -1
- package/dist/buefy.min.js +2 -2
- package/dist/cjs/autocomplete.js +5 -5
- package/dist/cjs/breadcrumb.js +1 -1
- package/dist/cjs/button.js +3 -3
- package/dist/cjs/carousel.js +3 -3
- package/dist/cjs/{chunk-5ed8a75a.js → chunk-09574ad9.js} +3 -3
- package/dist/cjs/{chunk-7c11fdde.js → chunk-201c9e5c.js} +1 -1
- package/dist/cjs/{chunk-545e1c7f.js → chunk-2a96ec68.js} +2 -2
- package/dist/cjs/{chunk-9103eeda.js → chunk-437dd7a0.js} +1 -0
- package/dist/cjs/{chunk-7545a2bd.js → chunk-7b44db6e.js} +2 -2
- package/dist/cjs/{chunk-670ac7e7.js → chunk-85b00a19.js} +7 -7
- package/dist/cjs/{chunk-3ef2e7dd.js → chunk-95c4b826.js} +3 -3
- package/dist/cjs/{chunk-5010c284.js → chunk-99367591.js} +18 -2
- package/dist/cjs/{chunk-73f8eef8.js → chunk-a6b29437.js} +1 -1
- package/dist/cjs/{chunk-cd626a19.js → chunk-bcab8905.js} +6 -6
- package/dist/cjs/{chunk-7e877557.js → chunk-befea70a.js} +2 -2
- package/dist/cjs/{chunk-4bcfaf1c.js → chunk-cc9676a6.js} +1 -1
- package/dist/cjs/{chunk-03279fd8.js → chunk-dddb035c.js} +1 -1
- package/dist/cjs/{chunk-e872f5e2.js → chunk-e0373ab6.js} +1 -1
- package/dist/cjs/{chunk-2d94476d.js → chunk-e90b3d05.js} +2 -2
- package/dist/cjs/{chunk-f5285f14.js → chunk-eba24a95.js} +1 -1
- package/dist/cjs/{chunk-e86d3eeb.js → chunk-f5139026.js} +1 -1
- package/dist/cjs/{chunk-d03d9202.js → chunk-f8eb56c6.js} +21 -21
- package/dist/cjs/{chunk-93c51748.js → chunk-fb8ff6be.js} +1 -1
- package/dist/cjs/clockpicker.js +7 -7
- package/dist/cjs/colorpicker.js +8 -8
- package/dist/cjs/config.js +1 -1
- package/dist/cjs/datepicker.js +8 -8
- package/dist/cjs/datetimepicker.js +10 -10
- package/dist/cjs/dialog.js +4 -4
- package/dist/cjs/dropdown.js +2 -2
- package/dist/cjs/field.js +2 -2
- package/dist/cjs/icon.js +2 -2
- package/dist/cjs/image.js +2 -2
- package/dist/cjs/index.js +19 -19
- package/dist/cjs/input.js +4 -4
- package/dist/cjs/loading.js +1 -1
- package/dist/cjs/menu.js +2 -2
- package/dist/cjs/message.js +3 -3
- package/dist/cjs/modal.js +2 -2
- package/dist/cjs/notification.js +4 -4
- package/dist/cjs/numberinput.js +4 -4
- package/dist/cjs/pagination.js +3 -3
- package/dist/cjs/progress.js +1 -1
- package/dist/cjs/rate.js +2 -2
- package/dist/cjs/select.js +4 -4
- package/dist/cjs/sidebar.js +1 -1
- package/dist/cjs/slider.js +2 -2
- package/dist/cjs/snackbar.js +2 -2
- package/dist/cjs/steps.js +3 -3
- package/dist/cjs/switch.js +1 -1
- package/dist/cjs/table.js +11 -8
- package/dist/cjs/tabs.js +3 -3
- package/dist/cjs/taginput.js +5 -5
- package/dist/cjs/timepicker.js +9 -9
- package/dist/cjs/toast.js +2 -2
- package/dist/cjs/tooltip.js +2 -2
- package/dist/cjs/upload.js +2 -2
- package/dist/components/autocomplete/index.js +2 -1
- package/dist/components/autocomplete/index.min.js +2 -2
- package/dist/components/breadcrumb/index.js +2 -1
- package/dist/components/breadcrumb/index.min.js +1 -1
- package/dist/components/button/index.js +3 -2
- package/dist/components/button/index.min.js +2 -2
- package/dist/components/carousel/index.js +2 -1
- package/dist/components/carousel/index.min.js +2 -2
- package/dist/components/checkbox/index.js +1 -1
- package/dist/components/checkbox/index.min.js +1 -1
- package/dist/components/clockpicker/index.js +22 -21
- package/dist/components/clockpicker/index.min.js +2 -2
- package/dist/components/collapse/index.js +1 -1
- package/dist/components/collapse/index.min.js +1 -1
- package/dist/components/colorpicker/index.js +39 -22
- package/dist/components/colorpicker/index.min.js +2 -2
- package/dist/components/datepicker/index.js +22 -21
- package/dist/components/datepicker/index.min.js +2 -2
- package/dist/components/datetimepicker/index.js +22 -21
- package/dist/components/datetimepicker/index.min.js +2 -2
- package/dist/components/dialog/index.js +3 -2
- package/dist/components/dialog/index.min.js +2 -2
- package/dist/components/dropdown/index.js +2 -1
- package/dist/components/dropdown/index.min.js +1 -1
- package/dist/components/field/index.js +22 -21
- package/dist/components/field/index.min.js +1 -1
- package/dist/components/icon/index.js +2 -1
- package/dist/components/icon/index.min.js +2 -2
- package/dist/components/image/index.js +2 -1
- package/dist/components/image/index.min.js +2 -2
- package/dist/components/input/index.js +2 -1
- package/dist/components/input/index.min.js +2 -2
- package/dist/components/loading/index.js +1 -1
- package/dist/components/loading/index.min.js +1 -1
- package/dist/components/menu/index.js +2 -1
- package/dist/components/menu/index.min.js +2 -2
- package/dist/components/message/index.js +2 -1
- package/dist/components/message/index.min.js +2 -2
- package/dist/components/modal/index.js +2 -1
- package/dist/components/modal/index.min.js +2 -2
- package/dist/components/navbar/index.js +1 -1
- package/dist/components/navbar/index.min.js +1 -1
- package/dist/components/notification/index.js +2 -1
- package/dist/components/notification/index.min.js +2 -2
- package/dist/components/numberinput/index.js +2 -1
- package/dist/components/numberinput/index.min.js +2 -2
- package/dist/components/pagination/index.js +2 -1
- package/dist/components/pagination/index.min.js +2 -2
- package/dist/components/progress/index.js +2 -1
- package/dist/components/progress/index.min.js +2 -2
- package/dist/components/radio/index.js +1 -1
- package/dist/components/radio/index.min.js +1 -1
- package/dist/components/rate/index.js +2 -1
- package/dist/components/rate/index.min.js +2 -2
- package/dist/components/select/index.js +2 -1
- package/dist/components/select/index.min.js +2 -2
- package/dist/components/sidebar/index.js +2 -1
- package/dist/components/sidebar/index.min.js +1 -1
- package/dist/components/skeleton/index.js +1 -1
- package/dist/components/skeleton/index.min.js +1 -1
- package/dist/components/slider/index.js +19 -2
- package/dist/components/slider/index.min.js +2 -2
- package/dist/components/snackbar/index.js +2 -1
- package/dist/components/snackbar/index.min.js +1 -1
- package/dist/components/steps/index.js +2 -1
- package/dist/components/steps/index.min.js +2 -2
- package/dist/components/switch/index.js +2 -1
- package/dist/components/switch/index.min.js +1 -1
- package/dist/components/table/index.js +7 -3
- package/dist/components/table/index.min.js +2 -2
- package/dist/components/tabs/index.js +2 -1
- package/dist/components/tabs/index.min.js +2 -2
- package/dist/components/tag/index.js +1 -1
- package/dist/components/tag/index.min.js +1 -1
- package/dist/components/taginput/index.js +2 -1
- package/dist/components/taginput/index.min.js +2 -2
- package/dist/components/timepicker/index.js +22 -21
- package/dist/components/timepicker/index.min.js +2 -2
- package/dist/components/toast/index.js +2 -1
- package/dist/components/toast/index.min.js +1 -1
- package/dist/components/tooltip/index.js +19 -2
- package/dist/components/tooltip/index.min.js +2 -2
- package/dist/components/upload/index.js +2 -1
- package/dist/components/upload/index.min.js +2 -2
- package/dist/esm/autocomplete.js +6 -6
- package/dist/esm/breadcrumb.js +1 -1
- package/dist/esm/button.js +4 -4
- package/dist/esm/carousel.js +3 -3
- package/dist/esm/{chunk-726445a2.js → chunk-17b33cd2.js} +1 -1
- package/dist/esm/{chunk-aed3f638.js → chunk-293c457c.js} +6 -6
- package/dist/esm/{chunk-d35985c7.js → chunk-33e1434e.js} +1 -1
- package/dist/esm/{chunk-690d5be4.js → chunk-493ff0a9.js} +1 -1
- package/dist/esm/{chunk-51455f8c.js → chunk-4e788733.js} +2 -2
- package/dist/esm/{chunk-970672ce.js → chunk-6c64686f.js} +7 -7
- package/dist/esm/{chunk-c2803e80.js → chunk-6e56b8bc.js} +2 -2
- package/dist/esm/{chunk-5435bd9a.js → chunk-7bb9107f.js} +1 -1
- package/dist/esm/{chunk-e044aa02.js → chunk-7e17a637.js} +1 -1
- package/dist/esm/{chunk-4fb80d59.js → chunk-83c8b459.js} +3 -3
- package/dist/esm/{chunk-ced7578e.js → chunk-9b0b8225.js} +18 -2
- package/dist/esm/{chunk-d9232770.js → chunk-a32d1427.js} +1 -1
- package/dist/esm/{chunk-598015da.js → chunk-ade5b253.js} +1 -1
- package/dist/esm/{chunk-8747d0a8.js → chunk-b0123b89.js} +2 -2
- package/dist/esm/{chunk-58cdbf2b.js → chunk-b5576437.js} +3 -3
- package/dist/esm/{chunk-1a4fde6d.js → chunk-c5284276.js} +2 -2
- package/dist/esm/{chunk-2509b537.js → chunk-d46e7ff0.js} +21 -21
- package/dist/esm/{chunk-8ed29c41.js → chunk-e92e3389.js} +1 -0
- package/dist/esm/{chunk-6d96579e.js → chunk-f32d0228.js} +1 -1
- package/dist/esm/clockpicker.js +7 -7
- package/dist/esm/colorpicker.js +8 -8
- package/dist/esm/config.js +1 -1
- package/dist/esm/datepicker.js +9 -9
- package/dist/esm/datetimepicker.js +10 -10
- package/dist/esm/dialog.js +4 -4
- package/dist/esm/dropdown.js +3 -3
- package/dist/esm/field.js +3 -3
- package/dist/esm/icon.js +3 -3
- package/dist/esm/image.js +3 -3
- package/dist/esm/index.js +19 -19
- package/dist/esm/input.js +5 -5
- package/dist/esm/loading.js +1 -1
- package/dist/esm/menu.js +2 -2
- package/dist/esm/message.js +3 -3
- package/dist/esm/modal.js +3 -3
- package/dist/esm/notification.js +4 -4
- package/dist/esm/numberinput.js +4 -4
- package/dist/esm/pagination.js +4 -4
- package/dist/esm/progress.js +1 -1
- package/dist/esm/rate.js +2 -2
- package/dist/esm/select.js +5 -5
- package/dist/esm/sidebar.js +1 -1
- package/dist/esm/slider.js +2 -2
- package/dist/esm/snackbar.js +2 -2
- package/dist/esm/steps.js +3 -3
- package/dist/esm/switch.js +1 -1
- package/dist/esm/table.js +11 -8
- package/dist/esm/tabs.js +3 -3
- package/dist/esm/taginput.js +5 -5
- package/dist/esm/timepicker.js +10 -10
- package/dist/esm/toast.js +2 -2
- package/dist/esm/tooltip.js +3 -3
- package/dist/esm/upload.js +2 -2
- package/dist/vetur/attributes.json +5 -1
- package/dist/vetur/tags.json +1 -1
- package/package.json +1 -1
- package/src/components/button/Button.spec.js +14 -0
- package/src/components/button/Button.vue +1 -1
- package/src/components/field/Field.vue +272 -272
- package/src/components/table/TableColumn.vue +121 -118
- package/src/components/tooltip/Tooltip.vue +12 -1
- package/src/utils/config.js +1 -0
|
@@ -1,272 +1,272 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="field" :class="rootClasses">
|
|
3
|
-
<div
|
|
4
|
-
v-if="horizontal"
|
|
5
|
-
class="field-label"
|
|
6
|
-
:class="[customClass, fieldLabelSize]">
|
|
7
|
-
<label
|
|
8
|
-
v-if="hasLabel"
|
|
9
|
-
:for="labelFor"
|
|
10
|
-
:class="customClass"
|
|
11
|
-
class="label" >
|
|
12
|
-
<slot v-if="$slots.label" name="label"/>
|
|
13
|
-
<template v-else>{{ label }}</template>
|
|
14
|
-
</label>
|
|
15
|
-
</div>
|
|
16
|
-
<template v-else>
|
|
17
|
-
<label
|
|
18
|
-
v-if="hasLabel"
|
|
19
|
-
:for="labelFor"
|
|
20
|
-
:class="customClass"
|
|
21
|
-
class="label">
|
|
22
|
-
<slot v-if="$slots.label" name="label"/>
|
|
23
|
-
<template v-else>{{ label }}</template>
|
|
24
|
-
</label>
|
|
25
|
-
</template>
|
|
26
|
-
<b-field-body
|
|
27
|
-
v-if="horizontal"
|
|
28
|
-
:message="newMessage ? formattedMessage : ''"
|
|
29
|
-
:type="newType">
|
|
30
|
-
<slot/>
|
|
31
|
-
</b-field-body>
|
|
32
|
-
<div v-else-if="hasInnerField" class="field-body">
|
|
33
|
-
<b-field
|
|
34
|
-
:addons="false"
|
|
35
|
-
:type="newType"
|
|
36
|
-
:class="innerFieldClasses">
|
|
37
|
-
<slot/>
|
|
38
|
-
</b-field>
|
|
39
|
-
</div>
|
|
40
|
-
<template v-else>
|
|
41
|
-
<slot/>
|
|
42
|
-
</template>
|
|
43
|
-
<p
|
|
44
|
-
v-if="hasMessage && !horizontal"
|
|
45
|
-
class="help"
|
|
46
|
-
:class="newType"
|
|
47
|
-
>
|
|
48
|
-
<slot v-if="$slots.message" name="message"/>
|
|
49
|
-
<template v-else>
|
|
50
|
-
<template v-for="(mess, i) in formattedMessage">
|
|
51
|
-
{{ mess }}
|
|
52
|
-
<br :key="i" v-if="(i + 1) < formattedMessage.length">
|
|
53
|
-
</template>
|
|
54
|
-
</template>
|
|
55
|
-
</p>
|
|
56
|
-
</div>
|
|
57
|
-
</template>
|
|
58
|
-
|
|
59
|
-
<script>
|
|
60
|
-
import config from '../../utils/config'
|
|
61
|
-
import FieldBody from './FieldBody'
|
|
62
|
-
|
|
63
|
-
export default {
|
|
64
|
-
name: 'BField',
|
|
65
|
-
components: {
|
|
66
|
-
[FieldBody.name]: FieldBody
|
|
67
|
-
},
|
|
68
|
-
provide() {
|
|
69
|
-
return {
|
|
70
|
-
'BField': this
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
inject: {
|
|
74
|
-
parent: {
|
|
75
|
-
from: 'BField',
|
|
76
|
-
default: false
|
|
77
|
-
}
|
|
78
|
-
}, // Used internally only when using Field in Field
|
|
79
|
-
props: {
|
|
80
|
-
type: [String, Object],
|
|
81
|
-
label: String,
|
|
82
|
-
labelFor: String,
|
|
83
|
-
message: [String, Array, Object],
|
|
84
|
-
grouped: Boolean,
|
|
85
|
-
groupMultiline: Boolean,
|
|
86
|
-
position: String,
|
|
87
|
-
expanded: Boolean,
|
|
88
|
-
horizontal: Boolean,
|
|
89
|
-
addons: {
|
|
90
|
-
type: Boolean,
|
|
91
|
-
default: true
|
|
92
|
-
},
|
|
93
|
-
customClass: String,
|
|
94
|
-
labelPosition: {
|
|
95
|
-
type: String,
|
|
96
|
-
default: () => { return config.defaultFieldLabelPosition }
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
data() {
|
|
100
|
-
return {
|
|
101
|
-
newType: this.type,
|
|
102
|
-
newMessage: this.message,
|
|
103
|
-
fieldLabelSize: null,
|
|
104
|
-
_isField: true // Used internally by Input and Select
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
computed: {
|
|
108
|
-
rootClasses() {
|
|
109
|
-
return [{
|
|
110
|
-
'is-expanded': this.expanded,
|
|
111
|
-
'is-horizontal': this.horizontal,
|
|
112
|
-
'is-floating-in-label': this.hasLabel && !this.horizontal &&
|
|
113
|
-
this.labelPosition === 'inside',
|
|
114
|
-
'is-floating-label': this.hasLabel && !this.horizontal &&
|
|
115
|
-
this.labelPosition === 'on-border'
|
|
116
|
-
},
|
|
117
|
-
this.numberInputClasses]
|
|
118
|
-
},
|
|
119
|
-
innerFieldClasses() {
|
|
120
|
-
return [
|
|
121
|
-
this.fieldType(),
|
|
122
|
-
this.newPosition,
|
|
123
|
-
{
|
|
124
|
-
'is-grouped-multiline': this.groupMultiline
|
|
125
|
-
}
|
|
126
|
-
]
|
|
127
|
-
},
|
|
128
|
-
hasInnerField() {
|
|
129
|
-
return this.grouped || this.groupMultiline || this.hasAddons()
|
|
130
|
-
},
|
|
131
|
-
/**
|
|
132
|
-
* Correct Bulma class for the side of the addon or group.
|
|
133
|
-
*
|
|
134
|
-
* This is not kept like the others (is-small, etc.),
|
|
135
|
-
* because since 'has-addons' is set automatically it
|
|
136
|
-
* doesn't make sense to teach users what addons are exactly.
|
|
137
|
-
*/
|
|
138
|
-
newPosition() {
|
|
139
|
-
if (this.position === undefined) return
|
|
140
|
-
|
|
141
|
-
const position = this.position.split('-')
|
|
142
|
-
if (position.length < 1) return
|
|
143
|
-
|
|
144
|
-
const prefix = this.grouped
|
|
145
|
-
? 'is-grouped-'
|
|
146
|
-
: 'has-addons-'
|
|
147
|
-
|
|
148
|
-
if (this.position) return prefix + position[1]
|
|
149
|
-
},
|
|
150
|
-
/**
|
|
151
|
-
* Formatted message in case it's an array
|
|
152
|
-
* (each element is separated by <br> tag)
|
|
153
|
-
*/
|
|
154
|
-
formattedMessage() {
|
|
155
|
-
if (this.parent && this.parent.hasInnerField) {
|
|
156
|
-
return '' // Message will be displayed in parent field
|
|
157
|
-
}
|
|
158
|
-
if (typeof this.newMessage === 'string') {
|
|
159
|
-
return [this.newMessage]
|
|
160
|
-
}
|
|
161
|
-
let messages = []
|
|
162
|
-
if (Array.isArray(this.newMessage)) {
|
|
163
|
-
this.newMessage.forEach((message) => {
|
|
164
|
-
if (typeof message === 'string') {
|
|
165
|
-
messages.push(message)
|
|
166
|
-
} else {
|
|
167
|
-
for (let key in message) {
|
|
168
|
-
if (message[key]) {
|
|
169
|
-
messages.push(key)
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
})
|
|
174
|
-
} else {
|
|
175
|
-
for (let key in this.newMessage) {
|
|
176
|
-
if (this.newMessage[key]) {
|
|
177
|
-
messages.push(key)
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return messages.filter((m) => { if (m) return m })
|
|
182
|
-
},
|
|
183
|
-
hasLabel() {
|
|
184
|
-
return this.label || this.$slots.label
|
|
185
|
-
},
|
|
186
|
-
hasMessage() {
|
|
187
|
-
return ((!this.parent || !this.parent.hasInnerField) && this.newMessage) ||
|
|
188
|
-
this.$slots.message
|
|
189
|
-
},
|
|
190
|
-
numberInputClasses() {
|
|
191
|
-
if (this.$slots.default) {
|
|
192
|
-
const numberinput = this.$slots.default.filter((node) => node.tag && node.tag.toLowerCase().indexOf('numberinput') >= 0)[0]
|
|
193
|
-
if (numberinput) {
|
|
194
|
-
const classes = ['has-numberinput']
|
|
195
|
-
const controlsPosition = numberinput.componentOptions.propsData.controlsPosition
|
|
196
|
-
const size = numberinput.componentOptions.propsData.size
|
|
197
|
-
if (controlsPosition) {
|
|
198
|
-
classes.push(`has-numberinput-${controlsPosition}`)
|
|
199
|
-
}
|
|
200
|
-
if (size) {
|
|
201
|
-
classes.push(`has-numberinput-${size}`)
|
|
202
|
-
}
|
|
203
|
-
return classes
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
return null
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
watch: {
|
|
210
|
-
/**
|
|
211
|
-
* Set internal type when prop change.
|
|
212
|
-
*/
|
|
213
|
-
type(value) {
|
|
214
|
-
this.newType = value
|
|
215
|
-
},
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Set internal message when prop change.
|
|
219
|
-
*/
|
|
220
|
-
message(value) {
|
|
221
|
-
this.newMessage = value
|
|
222
|
-
},
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Set parent message if we use Field in Field.
|
|
226
|
-
*/
|
|
227
|
-
newMessage(value) {
|
|
228
|
-
if (this.parent && this.parent.hasInnerField) {
|
|
229
|
-
if (!this.parent.type) {
|
|
230
|
-
this.parent.newType = this.newType
|
|
231
|
-
}
|
|
232
|
-
if (!this.parent.message) {
|
|
233
|
-
this.parent.newMessage = value
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
methods: {
|
|
239
|
-
/**
|
|
240
|
-
* Field has addons if there are more than one slot
|
|
241
|
-
* (element / component) in the Field.
|
|
242
|
-
* Or is grouped when prop is set.
|
|
243
|
-
* Is a method to be called when component re-render.
|
|
244
|
-
*/
|
|
245
|
-
fieldType() {
|
|
246
|
-
if (this.grouped) return 'is-grouped'
|
|
247
|
-
if (this.hasAddons()) return 'has-addons'
|
|
248
|
-
},
|
|
249
|
-
hasAddons() {
|
|
250
|
-
let renderedNode = 0
|
|
251
|
-
if (this.$slots.default) {
|
|
252
|
-
renderedNode = this.$slots.default.reduce((i, node) => node.tag ? i + 1 : i, 0)
|
|
253
|
-
}
|
|
254
|
-
return (
|
|
255
|
-
renderedNode > 1 &&
|
|
256
|
-
this.addons &&
|
|
257
|
-
!this.horizontal
|
|
258
|
-
)
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
mounted() {
|
|
262
|
-
if (this.horizontal) {
|
|
263
|
-
// Bulma docs: .is-normal for any .input or .button
|
|
264
|
-
const elements = this.$el.querySelectorAll('.input, .select, .button, .textarea, .b-slider')
|
|
265
|
-
if (elements.length > 0) {
|
|
266
|
-
this.fieldLabelSize = 'is-normal'
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="field" :class="rootClasses">
|
|
3
|
+
<div
|
|
4
|
+
v-if="horizontal"
|
|
5
|
+
class="field-label"
|
|
6
|
+
:class="[customClass, fieldLabelSize]">
|
|
7
|
+
<label
|
|
8
|
+
v-if="hasLabel"
|
|
9
|
+
:for="labelFor"
|
|
10
|
+
:class="customClass"
|
|
11
|
+
class="label" >
|
|
12
|
+
<slot v-if="$slots.label" name="label"/>
|
|
13
|
+
<template v-else>{{ label }}</template>
|
|
14
|
+
</label>
|
|
15
|
+
</div>
|
|
16
|
+
<template v-else>
|
|
17
|
+
<label
|
|
18
|
+
v-if="hasLabel"
|
|
19
|
+
:for="labelFor"
|
|
20
|
+
:class="customClass"
|
|
21
|
+
class="label">
|
|
22
|
+
<slot v-if="$slots.label" name="label"/>
|
|
23
|
+
<template v-else>{{ label }}</template>
|
|
24
|
+
</label>
|
|
25
|
+
</template>
|
|
26
|
+
<b-field-body
|
|
27
|
+
v-if="horizontal"
|
|
28
|
+
:message="newMessage ? formattedMessage : ''"
|
|
29
|
+
:type="newType">
|
|
30
|
+
<slot/>
|
|
31
|
+
</b-field-body>
|
|
32
|
+
<div v-else-if="hasInnerField" class="field-body">
|
|
33
|
+
<b-field
|
|
34
|
+
:addons="false"
|
|
35
|
+
:type="newType"
|
|
36
|
+
:class="innerFieldClasses">
|
|
37
|
+
<slot/>
|
|
38
|
+
</b-field>
|
|
39
|
+
</div>
|
|
40
|
+
<template v-else>
|
|
41
|
+
<slot/>
|
|
42
|
+
</template>
|
|
43
|
+
<p
|
|
44
|
+
v-if="hasMessage && !horizontal"
|
|
45
|
+
class="help"
|
|
46
|
+
:class="newType"
|
|
47
|
+
>
|
|
48
|
+
<slot v-if="$slots.message" name="message"/>
|
|
49
|
+
<template v-else>
|
|
50
|
+
<template v-for="(mess, i) in formattedMessage">
|
|
51
|
+
{{ mess }}
|
|
52
|
+
<br :key="i" v-if="(i + 1) < formattedMessage.length">
|
|
53
|
+
</template>
|
|
54
|
+
</template>
|
|
55
|
+
</p>
|
|
56
|
+
</div>
|
|
57
|
+
</template>
|
|
58
|
+
|
|
59
|
+
<script>
|
|
60
|
+
import config from '../../utils/config'
|
|
61
|
+
import FieldBody from './FieldBody'
|
|
62
|
+
|
|
63
|
+
export default {
|
|
64
|
+
name: 'BField',
|
|
65
|
+
components: {
|
|
66
|
+
[FieldBody.name]: FieldBody
|
|
67
|
+
},
|
|
68
|
+
provide() {
|
|
69
|
+
return {
|
|
70
|
+
'BField': this
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
inject: {
|
|
74
|
+
parent: {
|
|
75
|
+
from: 'BField',
|
|
76
|
+
default: false
|
|
77
|
+
}
|
|
78
|
+
}, // Used internally only when using Field in Field
|
|
79
|
+
props: {
|
|
80
|
+
type: [String, Object],
|
|
81
|
+
label: String,
|
|
82
|
+
labelFor: String,
|
|
83
|
+
message: [String, Array, Object],
|
|
84
|
+
grouped: Boolean,
|
|
85
|
+
groupMultiline: Boolean,
|
|
86
|
+
position: String,
|
|
87
|
+
expanded: Boolean,
|
|
88
|
+
horizontal: Boolean,
|
|
89
|
+
addons: {
|
|
90
|
+
type: Boolean,
|
|
91
|
+
default: true
|
|
92
|
+
},
|
|
93
|
+
customClass: String,
|
|
94
|
+
labelPosition: {
|
|
95
|
+
type: String,
|
|
96
|
+
default: () => { return config.defaultFieldLabelPosition }
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
data() {
|
|
100
|
+
return {
|
|
101
|
+
newType: this.type,
|
|
102
|
+
newMessage: this.message,
|
|
103
|
+
fieldLabelSize: null,
|
|
104
|
+
_isField: true // Used internally by Input and Select
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
computed: {
|
|
108
|
+
rootClasses() {
|
|
109
|
+
return [{
|
|
110
|
+
'is-expanded': this.expanded,
|
|
111
|
+
'is-horizontal': this.horizontal,
|
|
112
|
+
'is-floating-in-label': this.hasLabel && !this.horizontal &&
|
|
113
|
+
this.labelPosition === 'inside',
|
|
114
|
+
'is-floating-label': this.hasLabel && !this.horizontal &&
|
|
115
|
+
this.labelPosition === 'on-border'
|
|
116
|
+
},
|
|
117
|
+
this.numberInputClasses]
|
|
118
|
+
},
|
|
119
|
+
innerFieldClasses() {
|
|
120
|
+
return [
|
|
121
|
+
this.fieldType(),
|
|
122
|
+
this.newPosition,
|
|
123
|
+
{
|
|
124
|
+
'is-grouped-multiline': this.groupMultiline
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
},
|
|
128
|
+
hasInnerField() {
|
|
129
|
+
return this.grouped || this.groupMultiline || this.hasAddons()
|
|
130
|
+
},
|
|
131
|
+
/**
|
|
132
|
+
* Correct Bulma class for the side of the addon or group.
|
|
133
|
+
*
|
|
134
|
+
* This is not kept like the others (is-small, etc.),
|
|
135
|
+
* because since 'has-addons' is set automatically it
|
|
136
|
+
* doesn't make sense to teach users what addons are exactly.
|
|
137
|
+
*/
|
|
138
|
+
newPosition() {
|
|
139
|
+
if (this.position === undefined) return
|
|
140
|
+
|
|
141
|
+
const position = this.position.split('-')
|
|
142
|
+
if (position.length < 1) return
|
|
143
|
+
|
|
144
|
+
const prefix = this.grouped
|
|
145
|
+
? 'is-grouped-'
|
|
146
|
+
: 'has-addons-'
|
|
147
|
+
|
|
148
|
+
if (this.position) return prefix + position[1]
|
|
149
|
+
},
|
|
150
|
+
/**
|
|
151
|
+
* Formatted message in case it's an array
|
|
152
|
+
* (each element is separated by <br> tag)
|
|
153
|
+
*/
|
|
154
|
+
formattedMessage() {
|
|
155
|
+
if (this.parent && this.parent.hasInnerField) {
|
|
156
|
+
return '' // Message will be displayed in parent field
|
|
157
|
+
}
|
|
158
|
+
if (typeof this.newMessage === 'string') {
|
|
159
|
+
return [this.newMessage]
|
|
160
|
+
}
|
|
161
|
+
let messages = []
|
|
162
|
+
if (Array.isArray(this.newMessage)) {
|
|
163
|
+
this.newMessage.forEach((message) => {
|
|
164
|
+
if (typeof message === 'string') {
|
|
165
|
+
messages.push(message)
|
|
166
|
+
} else {
|
|
167
|
+
for (let key in message) {
|
|
168
|
+
if (message[key]) {
|
|
169
|
+
messages.push(key)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
})
|
|
174
|
+
} else {
|
|
175
|
+
for (let key in this.newMessage) {
|
|
176
|
+
if (this.newMessage[key]) {
|
|
177
|
+
messages.push(key)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return messages.filter((m) => { if (m) return m })
|
|
182
|
+
},
|
|
183
|
+
hasLabel() {
|
|
184
|
+
return this.label || this.$slots.label
|
|
185
|
+
},
|
|
186
|
+
hasMessage() {
|
|
187
|
+
return ((!this.parent || !this.parent.hasInnerField) && this.newMessage) ||
|
|
188
|
+
this.$slots.message
|
|
189
|
+
},
|
|
190
|
+
numberInputClasses() {
|
|
191
|
+
if (this.$slots.default) {
|
|
192
|
+
const numberinput = this.$slots.default.filter((node) => node.tag && node.tag.toLowerCase().indexOf('numberinput') >= 0)[0]
|
|
193
|
+
if (numberinput) {
|
|
194
|
+
const classes = ['has-numberinput']
|
|
195
|
+
const controlsPosition = numberinput.componentOptions.propsData.controlsPosition
|
|
196
|
+
const size = numberinput.componentOptions.propsData.size
|
|
197
|
+
if (controlsPosition) {
|
|
198
|
+
classes.push(`has-numberinput-${controlsPosition}`)
|
|
199
|
+
}
|
|
200
|
+
if (size) {
|
|
201
|
+
classes.push(`has-numberinput-${size}`)
|
|
202
|
+
}
|
|
203
|
+
return classes
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return null
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
watch: {
|
|
210
|
+
/**
|
|
211
|
+
* Set internal type when prop change.
|
|
212
|
+
*/
|
|
213
|
+
type(value) {
|
|
214
|
+
this.newType = value
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Set internal message when prop change.
|
|
219
|
+
*/
|
|
220
|
+
message(value) {
|
|
221
|
+
this.newMessage = value
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Set parent message if we use Field in Field.
|
|
226
|
+
*/
|
|
227
|
+
newMessage(value) {
|
|
228
|
+
if (this.parent && this.parent.hasInnerField) {
|
|
229
|
+
if (!this.parent.type) {
|
|
230
|
+
this.parent.newType = this.newType
|
|
231
|
+
}
|
|
232
|
+
if (!this.parent.message) {
|
|
233
|
+
this.parent.newMessage = value
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
methods: {
|
|
239
|
+
/**
|
|
240
|
+
* Field has addons if there are more than one slot
|
|
241
|
+
* (element / component) in the Field.
|
|
242
|
+
* Or is grouped when prop is set.
|
|
243
|
+
* Is a method to be called when component re-render.
|
|
244
|
+
*/
|
|
245
|
+
fieldType() {
|
|
246
|
+
if (this.grouped) return 'is-grouped'
|
|
247
|
+
if (this.hasAddons()) return 'has-addons'
|
|
248
|
+
},
|
|
249
|
+
hasAddons() {
|
|
250
|
+
let renderedNode = 0
|
|
251
|
+
if (this.$slots.default) {
|
|
252
|
+
renderedNode = this.$slots.default.reduce((i, node) => node.tag ? i + 1 : i, 0)
|
|
253
|
+
}
|
|
254
|
+
return (
|
|
255
|
+
renderedNode > 1 &&
|
|
256
|
+
this.addons &&
|
|
257
|
+
!this.horizontal
|
|
258
|
+
)
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
mounted() {
|
|
262
|
+
if (this.horizontal) {
|
|
263
|
+
// Bulma docs: .is-normal for any .input or .button
|
|
264
|
+
const elements = this.$el.querySelectorAll('.input, .select, .button, .textarea, .b-slider')
|
|
265
|
+
if (elements.length > 0) {
|
|
266
|
+
this.fieldLabelSize = 'is-normal'
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
</script>
|