buefy 0.9.12 → 0.9.13
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/dist/buefy.css +1 -1
- package/dist/buefy.esm.js +106 -104
- package/dist/buefy.esm.min.js +2 -2
- package/dist/buefy.js +106 -104
- package/dist/buefy.min.css +1 -1
- package/dist/buefy.min.js +2 -2
- package/dist/cjs/autocomplete.js +4 -4
- package/dist/cjs/button.js +2 -2
- package/dist/cjs/carousel.js +5 -5
- package/dist/cjs/{chunk-47e1b22b.js → chunk-114191ae.js} +2 -2
- package/dist/cjs/{chunk-db3fa73a.js → chunk-2062216d.js} +1 -1
- package/dist/cjs/{chunk-d9a33552.js → chunk-2911aa4b.js} +45 -45
- package/dist/cjs/{chunk-de7a7f98.js → chunk-2ae50815.js} +3 -3
- package/dist/cjs/{chunk-01268607.js → chunk-2c7de785.js} +0 -0
- package/dist/cjs/{chunk-30d55827.js → chunk-30670fac.js} +2 -2
- package/dist/cjs/{chunk-c3495010.js → chunk-34949503.js} +0 -0
- package/dist/cjs/{chunk-2dc027c9.js → chunk-3cc5d9a6.js} +0 -0
- package/dist/cjs/{chunk-a14ca5bf.js → chunk-61023b09.js} +1 -1
- package/dist/cjs/{chunk-c5a552d4.js → chunk-6cb902f8.js} +0 -0
- package/dist/cjs/{chunk-7b13241d.js → chunk-7da0c017.js} +4 -2
- package/dist/cjs/{chunk-bd1feb6c.js → chunk-9e4cf4c5.js} +0 -0
- package/dist/cjs/{chunk-ea7e1e7e.js → chunk-a11294f9.js} +1 -1
- package/dist/cjs/{chunk-3aaecc36.js → chunk-c6fbc7b4.js} +1 -1
- package/dist/cjs/{chunk-dcf024d2.js → chunk-c7b2aa4b.js} +0 -0
- package/dist/cjs/{chunk-40697b2f.js → chunk-d0f8ea39.js} +6 -6
- package/dist/cjs/{chunk-c00639be.js → chunk-d120e215.js} +0 -0
- package/dist/cjs/{chunk-cb3ee6f4.js → chunk-d54e40f6.js} +0 -0
- package/dist/cjs/{chunk-adaa5792.js → chunk-f5106717.js} +2 -2
- package/dist/cjs/{chunk-66710d19.js → chunk-fe2f57ee.js} +1 -1
- package/dist/cjs/{chunk-344f6275.js → chunk-fefd7b77.js} +0 -0
- package/dist/cjs/clockpicker.js +7 -7
- package/dist/cjs/datepicker.js +8 -8
- package/dist/cjs/datetimepicker.js +10 -10
- package/dist/cjs/dialog.js +10 -10
- package/dist/cjs/dropdown.js +2 -2
- package/dist/cjs/field.js +1 -1
- package/dist/cjs/helpers.js +50 -50
- package/dist/cjs/icon.js +1 -1
- package/dist/cjs/image.js +1 -1
- package/dist/cjs/index.js +21 -21
- package/dist/cjs/input.js +3 -3
- package/dist/cjs/loading.js +1 -1
- package/dist/cjs/menu.js +1 -1
- package/dist/cjs/message.js +2 -2
- package/dist/cjs/modal.js +1 -1
- package/dist/cjs/notification.js +3 -3
- package/dist/cjs/numberinput.js +6 -6
- package/dist/cjs/pagination.js +2 -2
- package/dist/cjs/progress.js +1 -1
- package/dist/cjs/rate.js +1 -1
- package/dist/cjs/select.js +3 -3
- package/dist/cjs/slider.js +1 -1
- package/dist/cjs/snackbar.js +1 -1
- package/dist/cjs/steps.js +4 -4
- package/dist/cjs/table.js +7 -7
- package/dist/cjs/tabs.js +4 -4
- package/dist/cjs/taginput.js +4 -4
- package/dist/cjs/timepicker.js +9 -9
- package/dist/cjs/toast.js +1 -1
- package/dist/cjs/tooltip.js +1 -1
- package/dist/cjs/upload.js +1 -1
- package/dist/components/autocomplete/index.js +5 -5
- package/dist/components/autocomplete/index.min.js +1 -1
- package/dist/components/breadcrumb/index.js +1 -1
- package/dist/components/breadcrumb/index.min.js +1 -1
- package/dist/components/button/index.js +3 -3
- package/dist/components/button/index.min.js +1 -1
- package/dist/components/carousel/index.js +26 -26
- package/dist/components/carousel/index.min.js +1 -1
- package/dist/components/checkbox/index.js +1 -1
- package/dist/components/checkbox/index.min.js +1 -1
- package/dist/components/clockpicker/index.js +22 -20
- 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/datepicker/index.js +71 -69
- package/dist/components/datepicker/index.min.js +2 -2
- package/dist/components/datetimepicker/index.js +71 -69
- package/dist/components/datetimepicker/index.min.js +2 -2
- package/dist/components/dialog/index.js +10 -10
- package/dist/components/dialog/index.min.js +1 -1
- package/dist/components/dropdown/index.js +6 -6
- package/dist/components/dropdown/index.min.js +1 -1
- package/dist/components/field/index.js +5 -3
- package/dist/components/field/index.min.js +2 -2
- package/dist/components/icon/index.js +3 -3
- package/dist/components/icon/index.min.js +1 -1
- package/dist/components/image/index.js +4 -4
- package/dist/components/image/index.min.js +1 -1
- package/dist/components/input/index.js +3 -3
- package/dist/components/input/index.min.js +1 -1
- package/dist/components/loading/index.js +3 -3
- package/dist/components/loading/index.min.js +1 -1
- package/dist/components/menu/index.js +3 -3
- package/dist/components/menu/index.min.js +1 -1
- package/dist/components/message/index.js +3 -3
- package/dist/components/message/index.min.js +1 -1
- package/dist/components/modal/index.js +3 -3
- package/dist/components/modal/index.min.js +1 -1
- package/dist/components/navbar/index.js +1 -1
- package/dist/components/navbar/index.min.js +1 -1
- package/dist/components/notification/index.js +3 -3
- package/dist/components/notification/index.min.js +1 -1
- package/dist/components/numberinput/index.js +6 -6
- package/dist/components/numberinput/index.min.js +1 -1
- package/dist/components/pagination/index.js +3 -3
- package/dist/components/pagination/index.min.js +1 -1
- package/dist/components/progress/index.js +6 -6
- package/dist/components/progress/index.min.js +1 -1
- package/dist/components/radio/index.js +1 -1
- package/dist/components/radio/index.min.js +1 -1
- package/dist/components/rate/index.js +3 -3
- package/dist/components/rate/index.min.js +1 -1
- package/dist/components/select/index.js +3 -3
- package/dist/components/select/index.min.js +1 -1
- package/dist/components/sidebar/index.js +1 -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 +7 -7
- package/dist/components/slider/index.min.js +1 -1
- package/dist/components/snackbar/index.js +3 -3
- package/dist/components/snackbar/index.min.js +1 -1
- package/dist/components/steps/index.js +14 -14
- package/dist/components/steps/index.min.js +1 -1
- package/dist/components/switch/index.js +1 -1
- package/dist/components/switch/index.min.js +1 -1
- package/dist/components/table/index.js +10 -10
- package/dist/components/table/index.min.js +1 -1
- package/dist/components/tabs/index.js +14 -14
- package/dist/components/tabs/index.min.js +1 -1
- package/dist/components/tag/index.js +1 -1
- package/dist/components/tag/index.min.js +1 -1
- package/dist/components/taginput/index.js +5 -5
- package/dist/components/taginput/index.min.js +1 -1
- package/dist/components/timepicker/index.js +22 -20
- package/dist/components/timepicker/index.min.js +2 -2
- package/dist/components/toast/index.js +3 -3
- package/dist/components/toast/index.min.js +1 -1
- package/dist/components/tooltip/index.js +1 -1
- package/dist/components/tooltip/index.min.js +1 -1
- package/dist/components/upload/index.js +1 -1
- package/dist/components/upload/index.min.js +1 -1
- package/dist/esm/autocomplete.js +5 -5
- package/dist/esm/button.js +3 -3
- package/dist/esm/carousel.js +5 -5
- package/dist/esm/{chunk-3dbb54cd.js → chunk-18e8b067.js} +1 -1
- package/dist/esm/{chunk-7d9db167.js → chunk-21fc0948.js} +6 -6
- package/dist/esm/{chunk-a146937d.js → chunk-22e9f916.js} +45 -45
- package/dist/esm/{chunk-18fcd4ac.js → chunk-29ca0df8.js} +0 -0
- package/dist/esm/{chunk-affd6df1.js → chunk-3773c62d.js} +0 -0
- package/dist/esm/{chunk-7ee6c15c.js → chunk-4b67a181.js} +1 -1
- package/dist/esm/{chunk-f97f6a90.js → chunk-6019fd7a.js} +2 -2
- package/dist/esm/{chunk-d9794c38.js → chunk-71a547bc.js} +0 -0
- package/dist/esm/{chunk-161dac72.js → chunk-75a5af93.js} +0 -0
- package/dist/esm/{chunk-4f046bae.js → chunk-799e084d.js} +0 -0
- package/dist/esm/{chunk-6b53dd42.js → chunk-83eb0d37.js} +2 -2
- package/dist/esm/{chunk-80ec133b.js → chunk-8d0f95b8.js} +3 -3
- package/dist/esm/{chunk-50188ced.js → chunk-9f7f7441.js} +0 -0
- package/dist/esm/{chunk-3098b0e9.js → chunk-ae8ab23a.js} +2 -2
- package/dist/esm/{chunk-0f30042f.js → chunk-b07e3182.js} +4 -2
- package/dist/esm/{chunk-a64bdef6.js → chunk-b0c0c6b0.js} +0 -0
- package/dist/esm/{chunk-cdfb7fda.js → chunk-c9c58d0c.js} +0 -0
- package/dist/esm/{chunk-f6b30428.js → chunk-d7f92d97.js} +1 -1
- package/dist/esm/{chunk-9957ac1a.js → chunk-d92f0cd9.js} +0 -0
- package/dist/esm/{chunk-72ad8d50.js → chunk-e7c9b2cb.js} +1 -1
- package/dist/esm/{chunk-8b279c1f.js → chunk-ece062a7.js} +1 -1
- package/dist/esm/clockpicker.js +7 -7
- package/dist/esm/datepicker.js +9 -9
- package/dist/esm/datetimepicker.js +10 -10
- package/dist/esm/dialog.js +10 -10
- package/dist/esm/dropdown.js +3 -3
- package/dist/esm/field.js +2 -2
- package/dist/esm/helpers.js +50 -50
- package/dist/esm/icon.js +2 -2
- package/dist/esm/image.js +2 -2
- package/dist/esm/index.js +21 -21
- package/dist/esm/input.js +4 -4
- package/dist/esm/loading.js +2 -2
- package/dist/esm/menu.js +1 -1
- package/dist/esm/message.js +2 -2
- package/dist/esm/modal.js +2 -2
- package/dist/esm/notification.js +3 -3
- package/dist/esm/numberinput.js +6 -6
- package/dist/esm/pagination.js +3 -3
- package/dist/esm/progress.js +1 -1
- package/dist/esm/rate.js +1 -1
- package/dist/esm/select.js +4 -4
- package/dist/esm/slider.js +1 -1
- package/dist/esm/snackbar.js +1 -1
- package/dist/esm/steps.js +4 -4
- package/dist/esm/table.js +7 -7
- package/dist/esm/tabs.js +4 -4
- package/dist/esm/taginput.js +4 -4
- package/dist/esm/timepicker.js +10 -10
- package/dist/esm/toast.js +1 -1
- package/dist/esm/tooltip.js +2 -2
- package/dist/esm/upload.js +1 -1
- package/package.json +171 -171
- package/src/components/breadcrumb/BreadcrumbItem.spec.js +25 -25
- package/src/components/carousel/CarouselList.vue +313 -313
- package/src/components/carousel/__snapshots__/CarouselList.spec.js.snap +156 -156
- package/src/components/datepicker/Datepicker.vue +843 -843
- package/src/components/dialog/Dialog.vue +256 -256
- package/src/components/field/Field.vue +3 -3
- package/src/components/image/Image.vue +309 -309
- package/src/components/numberinput/Numberinput.vue +309 -309
- package/src/utils/helpers.js +291 -291
|
@@ -1,256 +1,256 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<transition :name="animation">
|
|
3
|
-
<div
|
|
4
|
-
v-if="isActive"
|
|
5
|
-
class="dialog modal is-active"
|
|
6
|
-
:class="dialogClass"
|
|
7
|
-
v-trap-focus="trapFocus"
|
|
8
|
-
:role="ariaRole"
|
|
9
|
-
:aria-modal="ariaModal">
|
|
10
|
-
<div class="modal-background" @click="cancel('outside')"/>
|
|
11
|
-
<div class="modal-card animation-content">
|
|
12
|
-
<header class="modal-card-head" v-if="title">
|
|
13
|
-
<p class="modal-card-title">{{ title }}</p>
|
|
14
|
-
</header>
|
|
15
|
-
|
|
16
|
-
<section
|
|
17
|
-
class="modal-card-body"
|
|
18
|
-
:class="{ 'is-titleless': !title, 'is-flex': hasIcon }">
|
|
19
|
-
<div class="media">
|
|
20
|
-
<div
|
|
21
|
-
class="media-left"
|
|
22
|
-
v-if="hasIcon && (icon || iconByType)">
|
|
23
|
-
<b-icon
|
|
24
|
-
:icon="icon ? icon : iconByType"
|
|
25
|
-
:pack="iconPack"
|
|
26
|
-
:type="type"
|
|
27
|
-
:both="!icon"
|
|
28
|
-
size="is-large"/>
|
|
29
|
-
</div>
|
|
30
|
-
<div class="media-content">
|
|
31
|
-
<p>
|
|
32
|
-
<template v-if="$slots.default">
|
|
33
|
-
<slot />
|
|
34
|
-
</template>
|
|
35
|
-
<template v-else>
|
|
36
|
-
<div v-html="message" />
|
|
37
|
-
</template>
|
|
38
|
-
</p>
|
|
39
|
-
|
|
40
|
-
<div v-if="hasInput" class="field">
|
|
41
|
-
<div class="control">
|
|
42
|
-
<input
|
|
43
|
-
v-model="prompt"
|
|
44
|
-
class="input"
|
|
45
|
-
ref="input"
|
|
46
|
-
:class="{ 'is-danger': validationMessage }"
|
|
47
|
-
v-bind="inputAttrs"
|
|
48
|
-
@compositionstart="isCompositing = true"
|
|
49
|
-
@compositionend="isCompositing = false"
|
|
50
|
-
@keydown.enter="confirm">
|
|
51
|
-
</div>
|
|
52
|
-
<p class="help is-danger">{{ validationMessage }}</p>
|
|
53
|
-
</div>
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
</section>
|
|
57
|
-
|
|
58
|
-
<footer class="modal-card-foot">
|
|
59
|
-
<b-button
|
|
60
|
-
v-if="showCancel"
|
|
61
|
-
ref="cancelButton"
|
|
62
|
-
@click="cancel('button')">{{ cancelText }}</b-button>
|
|
63
|
-
<b-button
|
|
64
|
-
:type="type"
|
|
65
|
-
ref="confirmButton"
|
|
66
|
-
@click="confirm">{{ confirmText }}</b-button>
|
|
67
|
-
</footer>
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
70
|
-
</transition>
|
|
71
|
-
</template>
|
|
72
|
-
|
|
73
|
-
<script>
|
|
74
|
-
import trapFocus from '../../directives/trapFocus'
|
|
75
|
-
import Icon from '../icon/Icon'
|
|
76
|
-
import Modal from '../modal/Modal'
|
|
77
|
-
import Button from '../button/Button'
|
|
78
|
-
import config from '../../utils/config'
|
|
79
|
-
import { removeElement } from '../../utils/helpers'
|
|
80
|
-
|
|
81
|
-
export default {
|
|
82
|
-
name: 'BDialog',
|
|
83
|
-
components: {
|
|
84
|
-
[Icon.name]: Icon,
|
|
85
|
-
[Button.name]: Button
|
|
86
|
-
},
|
|
87
|
-
directives: {
|
|
88
|
-
trapFocus
|
|
89
|
-
},
|
|
90
|
-
extends: Modal,
|
|
91
|
-
props: {
|
|
92
|
-
title: String,
|
|
93
|
-
message: [String, Array],
|
|
94
|
-
icon: String,
|
|
95
|
-
iconPack: String,
|
|
96
|
-
hasIcon: Boolean,
|
|
97
|
-
type: {
|
|
98
|
-
type: String,
|
|
99
|
-
default: 'is-primary'
|
|
100
|
-
},
|
|
101
|
-
size: String,
|
|
102
|
-
confirmText: {
|
|
103
|
-
type: String,
|
|
104
|
-
default: () => {
|
|
105
|
-
return config.defaultDialogConfirmText
|
|
106
|
-
? config.defaultDialogConfirmText
|
|
107
|
-
: 'OK'
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
cancelText: {
|
|
111
|
-
type: String,
|
|
112
|
-
default: () => {
|
|
113
|
-
return config.defaultDialogCancelText
|
|
114
|
-
? config.defaultDialogCancelText
|
|
115
|
-
: 'Cancel'
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
hasInput: Boolean, // Used internally to know if it's prompt
|
|
119
|
-
inputAttrs: {
|
|
120
|
-
type: Object,
|
|
121
|
-
default: () => ({})
|
|
122
|
-
},
|
|
123
|
-
onConfirm: {
|
|
124
|
-
type: Function,
|
|
125
|
-
default: () => {}
|
|
126
|
-
},
|
|
127
|
-
closeOnConfirm: {
|
|
128
|
-
type: Boolean,
|
|
129
|
-
default: true
|
|
130
|
-
},
|
|
131
|
-
container: {
|
|
132
|
-
type: String,
|
|
133
|
-
default: () => {
|
|
134
|
-
return config.defaultContainerElement
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
focusOn: {
|
|
138
|
-
type: String,
|
|
139
|
-
default: 'confirm'
|
|
140
|
-
},
|
|
141
|
-
trapFocus: {
|
|
142
|
-
type: Boolean,
|
|
143
|
-
default: () => {
|
|
144
|
-
return config.defaultTrapFocus
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
ariaRole: {
|
|
148
|
-
type: String,
|
|
149
|
-
validator: (value) => {
|
|
150
|
-
return [
|
|
151
|
-
'dialog',
|
|
152
|
-
'alertdialog'
|
|
153
|
-
].indexOf(value) >= 0
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
ariaModal: Boolean
|
|
157
|
-
},
|
|
158
|
-
data() {
|
|
159
|
-
const prompt = this.hasInput
|
|
160
|
-
? this.inputAttrs.value || ''
|
|
161
|
-
: ''
|
|
162
|
-
|
|
163
|
-
return {
|
|
164
|
-
prompt,
|
|
165
|
-
isActive: false,
|
|
166
|
-
validationMessage: '',
|
|
167
|
-
isCompositing: false
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
computed: {
|
|
171
|
-
dialogClass() {
|
|
172
|
-
return [this.size, {
|
|
173
|
-
'has-custom-container': this.container !== null
|
|
174
|
-
}]
|
|
175
|
-
},
|
|
176
|
-
/**
|
|
177
|
-
* Icon name (MDI) based on the type.
|
|
178
|
-
*/
|
|
179
|
-
iconByType() {
|
|
180
|
-
switch (this.type) {
|
|
181
|
-
case 'is-info':
|
|
182
|
-
return 'information'
|
|
183
|
-
case 'is-success':
|
|
184
|
-
return 'check-circle'
|
|
185
|
-
case 'is-warning':
|
|
186
|
-
return 'alert'
|
|
187
|
-
case 'is-danger':
|
|
188
|
-
return 'alert-circle'
|
|
189
|
-
default:
|
|
190
|
-
return null
|
|
191
|
-
}
|
|
192
|
-
},
|
|
193
|
-
showCancel() {
|
|
194
|
-
return this.cancelOptions.indexOf('button') >= 0
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
methods: {
|
|
198
|
-
/**
|
|
199
|
-
* If it's a prompt Dialog, validate the input.
|
|
200
|
-
* Call the onConfirm prop (function) and close the Dialog.
|
|
201
|
-
*/
|
|
202
|
-
confirm() {
|
|
203
|
-
if (this.$refs.input !== undefined) {
|
|
204
|
-
if (this.isCompositing) return
|
|
205
|
-
if (!this.$refs.input.checkValidity()) {
|
|
206
|
-
this.validationMessage = this.$refs.input.validationMessage
|
|
207
|
-
this.$nextTick(() => this.$refs.input.select())
|
|
208
|
-
return
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
this.$emit('confirm', this.prompt)
|
|
212
|
-
this.onConfirm(this.prompt, this)
|
|
213
|
-
if (this.closeOnConfirm) this.close()
|
|
214
|
-
},
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Close the Dialog.
|
|
218
|
-
*/
|
|
219
|
-
close() {
|
|
220
|
-
this.isActive = false
|
|
221
|
-
// Timeout for the animation complete before destroying
|
|
222
|
-
setTimeout(() => {
|
|
223
|
-
this.$destroy()
|
|
224
|
-
removeElement(this.$el)
|
|
225
|
-
}, 150)
|
|
226
|
-
}
|
|
227
|
-
},
|
|
228
|
-
beforeMount() {
|
|
229
|
-
// Insert the Dialog component in the element container
|
|
230
|
-
if (typeof window !== 'undefined') {
|
|
231
|
-
this.$nextTick(() => {
|
|
232
|
-
const container = document.querySelector(this.container) || document.body
|
|
233
|
-
container.appendChild(this.$el)
|
|
234
|
-
})
|
|
235
|
-
}
|
|
236
|
-
},
|
|
237
|
-
mounted() {
|
|
238
|
-
this.isActive = true
|
|
239
|
-
|
|
240
|
-
if (typeof this.inputAttrs.required === 'undefined') {
|
|
241
|
-
this.$set(this.inputAttrs, 'required', true)
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
this.$nextTick(() => {
|
|
245
|
-
// Handle which element receives focus
|
|
246
|
-
if (this.hasInput) {
|
|
247
|
-
this.$refs.input.focus()
|
|
248
|
-
} else if (this.focusOn === 'cancel' && this.showCancel) {
|
|
249
|
-
this.$refs.cancelButton.$el.focus()
|
|
250
|
-
} else {
|
|
251
|
-
this.$refs.confirmButton.$el.focus()
|
|
252
|
-
}
|
|
253
|
-
})
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<transition :name="animation">
|
|
3
|
+
<div
|
|
4
|
+
v-if="isActive"
|
|
5
|
+
class="dialog modal is-active"
|
|
6
|
+
:class="dialogClass"
|
|
7
|
+
v-trap-focus="trapFocus"
|
|
8
|
+
:role="ariaRole"
|
|
9
|
+
:aria-modal="ariaModal">
|
|
10
|
+
<div class="modal-background" @click="cancel('outside')"/>
|
|
11
|
+
<div class="modal-card animation-content">
|
|
12
|
+
<header class="modal-card-head" v-if="title">
|
|
13
|
+
<p class="modal-card-title">{{ title }}</p>
|
|
14
|
+
</header>
|
|
15
|
+
|
|
16
|
+
<section
|
|
17
|
+
class="modal-card-body"
|
|
18
|
+
:class="{ 'is-titleless': !title, 'is-flex': hasIcon }">
|
|
19
|
+
<div class="media">
|
|
20
|
+
<div
|
|
21
|
+
class="media-left"
|
|
22
|
+
v-if="hasIcon && (icon || iconByType)">
|
|
23
|
+
<b-icon
|
|
24
|
+
:icon="icon ? icon : iconByType"
|
|
25
|
+
:pack="iconPack"
|
|
26
|
+
:type="type"
|
|
27
|
+
:both="!icon"
|
|
28
|
+
size="is-large"/>
|
|
29
|
+
</div>
|
|
30
|
+
<div class="media-content">
|
|
31
|
+
<p>
|
|
32
|
+
<template v-if="$slots.default">
|
|
33
|
+
<slot />
|
|
34
|
+
</template>
|
|
35
|
+
<template v-else>
|
|
36
|
+
<div v-html="message" />
|
|
37
|
+
</template>
|
|
38
|
+
</p>
|
|
39
|
+
|
|
40
|
+
<div v-if="hasInput" class="field">
|
|
41
|
+
<div class="control">
|
|
42
|
+
<input
|
|
43
|
+
v-model="prompt"
|
|
44
|
+
class="input"
|
|
45
|
+
ref="input"
|
|
46
|
+
:class="{ 'is-danger': validationMessage }"
|
|
47
|
+
v-bind="inputAttrs"
|
|
48
|
+
@compositionstart="isCompositing = true"
|
|
49
|
+
@compositionend="isCompositing = false"
|
|
50
|
+
@keydown.enter="confirm">
|
|
51
|
+
</div>
|
|
52
|
+
<p class="help is-danger">{{ validationMessage }}</p>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
</section>
|
|
57
|
+
|
|
58
|
+
<footer class="modal-card-foot">
|
|
59
|
+
<b-button
|
|
60
|
+
v-if="showCancel"
|
|
61
|
+
ref="cancelButton"
|
|
62
|
+
@click="cancel('button')">{{ cancelText }}</b-button>
|
|
63
|
+
<b-button
|
|
64
|
+
:type="type"
|
|
65
|
+
ref="confirmButton"
|
|
66
|
+
@click="confirm">{{ confirmText }}</b-button>
|
|
67
|
+
</footer>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</transition>
|
|
71
|
+
</template>
|
|
72
|
+
|
|
73
|
+
<script>
|
|
74
|
+
import trapFocus from '../../directives/trapFocus'
|
|
75
|
+
import Icon from '../icon/Icon'
|
|
76
|
+
import Modal from '../modal/Modal'
|
|
77
|
+
import Button from '../button/Button'
|
|
78
|
+
import config from '../../utils/config'
|
|
79
|
+
import { removeElement } from '../../utils/helpers'
|
|
80
|
+
|
|
81
|
+
export default {
|
|
82
|
+
name: 'BDialog',
|
|
83
|
+
components: {
|
|
84
|
+
[Icon.name]: Icon,
|
|
85
|
+
[Button.name]: Button
|
|
86
|
+
},
|
|
87
|
+
directives: {
|
|
88
|
+
trapFocus
|
|
89
|
+
},
|
|
90
|
+
extends: Modal,
|
|
91
|
+
props: {
|
|
92
|
+
title: String,
|
|
93
|
+
message: [String, Array],
|
|
94
|
+
icon: String,
|
|
95
|
+
iconPack: String,
|
|
96
|
+
hasIcon: Boolean,
|
|
97
|
+
type: {
|
|
98
|
+
type: String,
|
|
99
|
+
default: 'is-primary'
|
|
100
|
+
},
|
|
101
|
+
size: String,
|
|
102
|
+
confirmText: {
|
|
103
|
+
type: String,
|
|
104
|
+
default: () => {
|
|
105
|
+
return config.defaultDialogConfirmText
|
|
106
|
+
? config.defaultDialogConfirmText
|
|
107
|
+
: 'OK'
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
cancelText: {
|
|
111
|
+
type: String,
|
|
112
|
+
default: () => {
|
|
113
|
+
return config.defaultDialogCancelText
|
|
114
|
+
? config.defaultDialogCancelText
|
|
115
|
+
: 'Cancel'
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
hasInput: Boolean, // Used internally to know if it's prompt
|
|
119
|
+
inputAttrs: {
|
|
120
|
+
type: Object,
|
|
121
|
+
default: () => ({})
|
|
122
|
+
},
|
|
123
|
+
onConfirm: {
|
|
124
|
+
type: Function,
|
|
125
|
+
default: () => {}
|
|
126
|
+
},
|
|
127
|
+
closeOnConfirm: {
|
|
128
|
+
type: Boolean,
|
|
129
|
+
default: true
|
|
130
|
+
},
|
|
131
|
+
container: {
|
|
132
|
+
type: String,
|
|
133
|
+
default: () => {
|
|
134
|
+
return config.defaultContainerElement
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
focusOn: {
|
|
138
|
+
type: String,
|
|
139
|
+
default: 'confirm'
|
|
140
|
+
},
|
|
141
|
+
trapFocus: {
|
|
142
|
+
type: Boolean,
|
|
143
|
+
default: () => {
|
|
144
|
+
return config.defaultTrapFocus
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
ariaRole: {
|
|
148
|
+
type: String,
|
|
149
|
+
validator: (value) => {
|
|
150
|
+
return [
|
|
151
|
+
'dialog',
|
|
152
|
+
'alertdialog'
|
|
153
|
+
].indexOf(value) >= 0
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
ariaModal: Boolean
|
|
157
|
+
},
|
|
158
|
+
data() {
|
|
159
|
+
const prompt = this.hasInput
|
|
160
|
+
? this.inputAttrs.value || ''
|
|
161
|
+
: ''
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
prompt,
|
|
165
|
+
isActive: false,
|
|
166
|
+
validationMessage: '',
|
|
167
|
+
isCompositing: false
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
computed: {
|
|
171
|
+
dialogClass() {
|
|
172
|
+
return [this.size, {
|
|
173
|
+
'has-custom-container': this.container !== null
|
|
174
|
+
}]
|
|
175
|
+
},
|
|
176
|
+
/**
|
|
177
|
+
* Icon name (MDI) based on the type.
|
|
178
|
+
*/
|
|
179
|
+
iconByType() {
|
|
180
|
+
switch (this.type) {
|
|
181
|
+
case 'is-info':
|
|
182
|
+
return 'information'
|
|
183
|
+
case 'is-success':
|
|
184
|
+
return 'check-circle'
|
|
185
|
+
case 'is-warning':
|
|
186
|
+
return 'alert'
|
|
187
|
+
case 'is-danger':
|
|
188
|
+
return 'alert-circle'
|
|
189
|
+
default:
|
|
190
|
+
return null
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
showCancel() {
|
|
194
|
+
return this.cancelOptions.indexOf('button') >= 0
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
methods: {
|
|
198
|
+
/**
|
|
199
|
+
* If it's a prompt Dialog, validate the input.
|
|
200
|
+
* Call the onConfirm prop (function) and close the Dialog.
|
|
201
|
+
*/
|
|
202
|
+
confirm() {
|
|
203
|
+
if (this.$refs.input !== undefined) {
|
|
204
|
+
if (this.isCompositing) return
|
|
205
|
+
if (!this.$refs.input.checkValidity()) {
|
|
206
|
+
this.validationMessage = this.$refs.input.validationMessage
|
|
207
|
+
this.$nextTick(() => this.$refs.input.select())
|
|
208
|
+
return
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
this.$emit('confirm', this.prompt)
|
|
212
|
+
this.onConfirm(this.prompt, this)
|
|
213
|
+
if (this.closeOnConfirm) this.close()
|
|
214
|
+
},
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Close the Dialog.
|
|
218
|
+
*/
|
|
219
|
+
close() {
|
|
220
|
+
this.isActive = false
|
|
221
|
+
// Timeout for the animation complete before destroying
|
|
222
|
+
setTimeout(() => {
|
|
223
|
+
this.$destroy()
|
|
224
|
+
removeElement(this.$el)
|
|
225
|
+
}, 150)
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
beforeMount() {
|
|
229
|
+
// Insert the Dialog component in the element container
|
|
230
|
+
if (typeof window !== 'undefined') {
|
|
231
|
+
this.$nextTick(() => {
|
|
232
|
+
const container = document.querySelector(this.container) || document.body
|
|
233
|
+
container.appendChild(this.$el)
|
|
234
|
+
})
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
mounted() {
|
|
238
|
+
this.isActive = true
|
|
239
|
+
|
|
240
|
+
if (typeof this.inputAttrs.required === 'undefined') {
|
|
241
|
+
this.$set(this.inputAttrs, 'required', true)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
this.$nextTick(() => {
|
|
245
|
+
// Handle which element receives focus
|
|
246
|
+
if (this.hasInput) {
|
|
247
|
+
this.$refs.input.focus()
|
|
248
|
+
} else if (this.focusOn === 'cancel' && this.showCancel) {
|
|
249
|
+
this.$refs.cancelButton.$el.focus()
|
|
250
|
+
} else {
|
|
251
|
+
this.$refs.confirmButton.$el.focus()
|
|
252
|
+
}
|
|
253
|
+
})
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
</script>
|
|
@@ -32,8 +32,6 @@
|
|
|
32
32
|
<div v-else-if="hasInnerField" class="field-body">
|
|
33
33
|
<b-field
|
|
34
34
|
:addons="false"
|
|
35
|
-
:type="newType"
|
|
36
|
-
:message="newMessage"
|
|
37
35
|
:class="innerFieldClasses">
|
|
38
36
|
<slot/>
|
|
39
37
|
</b-field>
|
|
@@ -230,7 +228,9 @@ export default {
|
|
|
230
228
|
if (!this.parent.type) {
|
|
231
229
|
this.parent.newType = this.newType
|
|
232
230
|
}
|
|
233
|
-
this.parent.
|
|
231
|
+
if (!this.parent.message) {
|
|
232
|
+
this.parent.newMessage = value
|
|
233
|
+
}
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
},
|