1+ import { NAME_ALERT } from '../../constants/components'
12import Vue from '../../utils/vue'
23import { getComponentConfig } from '../../utils/config'
34import { requestAF } from '../../utils/dom'
4- import { isBoolean } from '../../utils/inspect'
5+ import { isBoolean , isNumeric } from '../../utils/inspect'
56import { toInteger } from '../../utils/number'
67import BVTransition from '../../utils/bv-transition'
78import normalizeSlotMixin from '../../mixins/normalize-slot'
89import { BButtonClose } from '../button/button-close'
910
10- const NAME = 'BAlert'
11-
1211// Convert `show` value to a number
1312const parseCountDown = show => {
1413 if ( show === '' || isBoolean ( show ) ) {
@@ -30,12 +29,9 @@ const parseShow = show => {
3029 return ! ! show
3130}
3231
33- // Is a value number like (i.e. a number or a number as string)
34- const isNumericLike = value => ! isNaN ( toInteger ( value ) )
35-
3632// @vue /component
3733export const BAlert = /*#__PURE__*/ Vue . extend ( {
38- name : NAME ,
34+ name : NAME_ALERT ,
3935 mixins : [ normalizeSlotMixin ] ,
4036 model : {
4137 prop : 'show' ,
@@ -44,15 +40,15 @@ export const BAlert = /*#__PURE__*/ Vue.extend({
4440 props : {
4541 variant : {
4642 type : String ,
47- default : ( ) => getComponentConfig ( NAME , 'variant' )
43+ default : ( ) => getComponentConfig ( NAME_ALERT , 'variant' )
4844 } ,
4945 dismissible : {
5046 type : Boolean ,
5147 default : false
5248 } ,
5349 dismissLabel : {
5450 type : String ,
55- default : ( ) => getComponentConfig ( NAME , 'dismissLabel' )
51+ default : ( ) => getComponentConfig ( NAME_ALERT , 'dismissLabel' )
5652 } ,
5753 show : {
5854 type : [ Boolean , Number , String ] ,
@@ -78,7 +74,7 @@ export const BAlert = /*#__PURE__*/ Vue.extend({
7874 } ,
7975 countDown ( newVal ) {
8076 this . clearCountDownInterval ( )
81- if ( isNumericLike ( this . show ) ) {
77+ if ( isNumeric ( this . show ) ) {
8278 // Ignore if this.show transitions to a boolean value.
8379 this . $emit ( 'dismiss-count-down' , newVal )
8480 if ( this . show !== newVal ) {
@@ -101,11 +97,11 @@ export const BAlert = /*#__PURE__*/ Vue.extend({
10197 }
10298 } ,
10399 localShow ( newVal ) {
104- if ( ! newVal && ( this . dismissible || isNumericLike ( this . show ) ) ) {
100+ if ( ! newVal && ( this . dismissible || isNumeric ( this . show ) ) ) {
105101 // Only emit dismissed events for dismissible or auto dismissing alerts
106102 this . $emit ( 'dismissed' )
107103 }
108- if ( ! isNumericLike ( this . show ) && this . show !== newVal ) {
104+ if ( ! isNumeric ( this . show ) && this . show !== newVal ) {
109105 // Only emit booleans if we weren't passed a number via `this.show`
110106 this . $emit ( 'input' , newVal )
111107 }
@@ -158,7 +154,7 @@ export const BAlert = /*#__PURE__*/ Vue.extend({
158154 } ,
159155 attrs : { role : 'alert' , 'aria-live' : 'polite' , 'aria-atomic' : true }
160156 } ,
161- [ $dismissBtn , this . normalizeSlot ( 'default' ) ]
157+ [ $dismissBtn , this . normalizeSlot ( ) ]
162158 )
163159 $alert = [ $alert ]
164160 }
0 commit comments