@@ -151,15 +151,15 @@ const MultiselectButtons = function (selectEl, params) {
151
151
selectEl . parentNode . appendChild ( span ) ;
152
152
153
153
// hide the original label/hint and create new ones for the new combobox
154
- const selectLabel = document . querySelector ( " label[for=" . concat ( selectEl . id , "]" ) ) ;
154
+ const selectLabel = document . querySelector ( ` label[for=${ selectEl . id } ]` ) ;
155
155
selectLabel . hidden = true ;
156
- const selectHint = document . querySelector ( " #hint-" . concat ( selectEl . id ) ) ;
156
+ const selectHint = document . querySelector ( ` #hint-${ selectEl . id } ` ) ;
157
157
if ( selectHint ) {
158
158
selectHint . hidden = true ;
159
159
}
160
160
const div = document . createElement ( 'div' ) ;
161
161
div . classList . add ( 'combo' ) ;
162
- div . id = "" . concat ( selectEl . id , " -js-multi-buttons" ) ;
162
+ div . id = ` ${ selectEl . id } -js-multi-buttons` ;
163
163
const divComboBox = document . createElement ( 'div' ) ;
164
164
divComboBox . setAttribute ( 'role' , 'combobox' ) ;
165
165
divComboBox . setAttribute ( 'aria-haspopup' , 'listbox' ) ;
@@ -172,7 +172,7 @@ const MultiselectButtons = function (selectEl, params) {
172
172
input . setAttribute ( 'aria-controls' , baseId + '-listbox' ) ;
173
173
input . id = baseId + "-input" ;
174
174
if ( selectHint ) {
175
- input . setAttribute ( 'aria-describedby' , " hint-" . concat ( input . id ) ) ;
175
+ input . setAttribute ( 'aria-describedby' , ` hint-${ input . id } ` ) ;
176
176
}
177
177
input . classList . add ( 'combo-input' ) ;
178
178
input . setAttribute ( 'autocomplete' , 'off' ) ;
@@ -191,7 +191,7 @@ const MultiselectButtons = function (selectEl, params) {
191
191
const hintComboBox = selectHint ? selectHint . cloneNode ( true ) : null ;
192
192
if ( selectHint ) {
193
193
hintComboBox . hidden = false ;
194
- hintComboBox . id = " hint-" . concat ( input . id ) ;
194
+ hintComboBox . id = ` hint-${ input . id } ` ;
195
195
}
196
196
const ulCombo = document . createElement ( 'ul' ) ;
197
197
ulCombo . setAttribute ( 'role' , 'listbox' ) ;
@@ -248,12 +248,12 @@ const MultiselectButtons = function (selectEl, params) {
248
248
const listItem = document . createElement ( 'li' ) ;
249
249
buttonEl . className = 'remove-option' ;
250
250
buttonEl . type = 'button' ;
251
- buttonEl . id = "" . concat ( this . idBase , " -remove-" ) . concat ( index ) ;
251
+ buttonEl . id = ` ${ this . idBase } -remove-${ index } ` ;
252
252
buttonEl . dataset . value = option . value ;
253
253
buttonEl . addEventListener ( 'click' , ( ) => {
254
254
this . removeOption ( option ) ;
255
255
} ) ;
256
- buttonEl . innerHTML = " <span class=\ "visuallyhidden\ ">Remove </span>" . concat ( option . text , " " ) ;
256
+ buttonEl . innerHTML = ` <span class="visuallyhidden">Remove </span>${ option . text } ` ;
257
257
listItem . appendChild ( buttonEl ) ;
258
258
this . selectedEl . appendChild ( listItem ) ;
259
259
} else {
@@ -281,7 +281,7 @@ MultiselectButtons.prototype.init = function () {
281
281
hint = document . createElement ( 'li' ) ;
282
282
hint . setAttribute ( 'role' , 'alert' ) ;
283
283
}
284
- hint . innerText = " Please enter " . concat ( this . minInput , " or more characters" ) ;
284
+ hint . innerText = ` Please enter ${ this . minInput } or more characters` ;
285
285
if ( ! alreadyExists ) {
286
286
this . listboxEl . prepend ( hint ) ;
287
287
}
@@ -320,7 +320,7 @@ MultiselectButtons.prototype.filterOptions = async function (value) {
320
320
optionEl . setAttribute ( 'aria-setsize' , count ) ;
321
321
optionEl . setAttribute ( 'aria-posinset' , k + 1 ) ;
322
322
}
323
- optionEl . id = "" . concat ( this . idBase , "-" ) . concat ( this . options . indexOf ( o ) ) ;
323
+ optionEl . id = ` ${ this . idBase } - ${ this . options . indexOf ( o ) } ` ;
324
324
optionEl . className = 'combo-option' ;
325
325
optionEl . setAttribute ( 'aria-selected' , alreadySelected ) ;
326
326
optionEl . dataset . value = o . value ;
@@ -356,15 +356,15 @@ MultiselectButtons.prototype.filterOptions = async function (value) {
356
356
} ;
357
357
MultiselectButtons . prototype . updateResults = async function ( ) {
358
358
const url = new URL ( this . source , window . location . protocol + '//' + window . location . host ) ;
359
- url . search = "" . concat ( url . search ? url . search + '&' : '?' , "q=" ) . concat ( this . inputEl . value , " &page=" ) . concat ( this . page ) ;
359
+ url . search = ` ${ url . search ? url . search + '&' : '?' } q= ${ this . inputEl . value } &page=${ this . page } ` ;
360
360
const response = await fetch ( url ) ;
361
361
const data = await response . json ( ) ;
362
362
if ( this . page === 1 ) {
363
363
this . options = [ ] ;
364
364
}
365
365
data . results . forEach ( c => {
366
366
this . ajaxResultCount = data . total ;
367
- if ( ! this . select . querySelector ( " option[value=\"" . concat ( c . id , "\"]" ) ) ) {
367
+ if ( ! this . select . querySelector ( ` option[value=" ${ c . id } "]` ) ) {
368
368
const o = document . createElement ( 'option' ) ;
369
369
o . value = c . id ;
370
370
o . innerText = c . text ;
@@ -395,11 +395,10 @@ MultiselectButtons.prototype.onInput = async function () {
395
395
await this . updateResults ( ) ;
396
396
hint . remove ( ) ;
397
397
} else {
398
- var _hint ;
399
398
this . clearOptions ( ) ;
400
- ( _hint = hint ) !== null && _hint !== void 0 ? _hint : hint = document . createElement ( 'li' ) ;
399
+ hint ?? = document . createElement ( 'li' ) ;
401
400
hint . setAttribute ( 'role' , 'alert' ) ;
402
- hint . innerText = " Please enter " . concat ( this . minInput , " or more characters" ) ;
401
+ hint . innerText = ` Please enter ${ this . minInput } or more characters` ;
403
402
this . listboxEl . prepend ( hint ) ;
404
403
showHint = true ;
405
404
}
@@ -467,11 +466,11 @@ MultiselectButtons.prototype.onInputBlur = function () {
467
466
} ;
468
467
MultiselectButtons . prototype . onOptionChange = function ( index ) {
469
468
this . activeIndex = index ;
470
- this . inputEl . setAttribute ( 'aria-activedescendant' , "" . concat ( this . idBase , "-" ) . concat ( index ) ) ;
469
+ this . inputEl . setAttribute ( 'aria-activedescendant' , ` ${ this . idBase } - ${ index } ` ) ;
471
470
472
471
// update active style
473
472
const options = this . el . querySelectorAll ( '[role=option]' ) ;
474
- const currentOptions = this . el . querySelector ( " [id=" . concat ( this . idBase , "-" ) . concat ( index , "]" ) ) ;
473
+ const currentOptions = this . el . querySelector ( ` [id=${ this . idBase } - ${ index } ]` ) ;
475
474
[ ...options ] . forEach ( optionEl => {
476
475
optionEl . classList . remove ( 'option-current' ) ;
477
476
} ) ;
@@ -502,15 +501,15 @@ MultiselectButtons.prototype.removeOption = function (option) {
502
501
// const index = this.options.indexOf(option);
503
502
504
503
// update aria-selected
505
- const o = this . el . querySelector ( " [data-value=\"" . concat ( option . value , "\"]" ) ) ;
504
+ const o = this . el . querySelector ( ` [data-value=" ${ option . value } "]` ) ;
506
505
if ( o ) {
507
506
o . setAttribute ( 'aria-selected' , 'false' ) ;
508
507
o . classList . remove ( 'option-selected' ) ;
509
508
}
510
509
511
510
// remove button
512
511
if ( this . selectedEl ) {
513
- const buttonEl = this . selectedEl . querySelector ( " [data-value=\"" . concat ( option . value , "\"]" ) ) ;
512
+ const buttonEl = this . selectedEl . querySelector ( ` [data-value=" ${ option . value } "]` ) ;
514
513
this . selectedEl . removeChild ( buttonEl . parentElement ) ;
515
514
}
516
515
this . select . querySelector ( 'option[value="' + option . value + '"]' ) . removeAttribute ( 'selected' ) ;
@@ -521,7 +520,7 @@ MultiselectButtons.prototype.selectOption = function (option) {
521
520
this . activeIndex = index ;
522
521
523
522
// update aria-selected
524
- const o = this . el . querySelector ( " [id=" . concat ( this . idBase , "-" ) . concat ( index , "]" ) ) ;
523
+ const o = this . el . querySelector ( ` [id=${ this . idBase } - ${ index } ]` ) ;
525
524
o . setAttribute ( 'aria-selected' , 'true' ) ;
526
525
o . classList . add ( 'option-selected' ) ;
527
526
@@ -530,7 +529,7 @@ MultiselectButtons.prototype.selectOption = function (option) {
530
529
const listItem = document . createElement ( 'li' ) ;
531
530
buttonEl . className = 'remove-option' ;
532
531
buttonEl . type = 'button' ;
533
- buttonEl . id = "" . concat ( this . idBase , " -remove-" ) . concat ( index ) ;
532
+ buttonEl . id = ` ${ this . idBase } -remove-${ index } ` ;
534
533
buttonEl . dataset . value = selected . value ;
535
534
buttonEl . addEventListener ( 'click' , ( ) => {
536
535
const sibling = listItem . nextSibling ;
@@ -541,7 +540,7 @@ MultiselectButtons.prototype.selectOption = function (option) {
541
540
this . inputEl . focus ( ) ;
542
541
}
543
542
} ) ;
544
- buttonEl . innerHTML = " <span class=\ "visuallyhidden\ ">Remove </span> " . concat ( selected . text , " " ) ;
543
+ buttonEl . innerHTML = ` <span class="visuallyhidden">Remove </span> ${ selected . text } ` ;
545
544
listItem . appendChild ( buttonEl ) ;
546
545
if ( this . select . multiple ) {
547
546
this . selectedEl . appendChild ( listItem ) ;
@@ -552,7 +551,7 @@ MultiselectButtons.prototype.selectOption = function (option) {
552
551
this . select . querySelector ( 'option[value="' + option . value + '"]' ) . setAttribute ( 'selected' , 'selected' ) ;
553
552
} ;
554
553
MultiselectButtons . prototype . updateOption = function ( index ) {
555
- const optionEl = this . el . querySelector ( " [id=" . concat ( this . idBase , "-" ) . concat ( index , "]" ) ) ;
554
+ const optionEl = this . el . querySelector ( ` [id=${ this . idBase } - ${ index } ]` ) ;
556
555
const isSelected = optionEl . getAttribute ( 'aria-selected' ) === 'true' ;
557
556
this . inputEl . value = '' ;
558
557
if ( isSelected ) {
@@ -567,7 +566,7 @@ MultiselectButtons.prototype.updateOption = function (index) {
567
566
} ;
568
567
MultiselectButtons . prototype . updateMenuState = function ( open ) {
569
568
this . open = open ;
570
- this . comboEl . setAttribute ( 'aria-expanded' , "" . concat ( open ) ) ;
569
+ this . comboEl . setAttribute ( 'aria-expanded' , ` ${ open } ` ) ;
571
570
open ? this . el . classList . add ( 'open' ) : this . el . classList . remove ( 'open' ) ;
572
571
} ;
573
572
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ( MultiselectButtons ) ;
0 commit comments