@schukai/monster 3.96.1 → 3.96.2
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 +10 -5
- package/package.json +1 -1
- package/source/components/datatable/change-button.mjs +39 -41
- package/source/components/datatable/dataset.mjs +335 -325
- package/source/components/datatable/datasource/rest.mjs +0 -19
- package/source/components/datatable/embedded-pagination.mjs +3 -1
- package/source/components/datatable/pagination.mjs +13 -6
- package/source/components/datatable/save-button.mjs +25 -3
- package/source/components/datatable/status.mjs +21 -26
- package/source/components/datatable/style/status.pcss +12 -2
- package/source/components/datatable/stylesheet/status.mjs +1 -1
- package/source/components/datatable/util.mjs +1 -2
- package/source/components/form/form.mjs +1 -2
- package/source/components/form/select.mjs +2008 -2013
- package/source/components/form/style/field-set.pcss +28 -7
- package/source/components/form/style/toggle-switch.pcss +13 -2
- package/source/components/form/stylesheet/field-set.mjs +14 -7
- package/source/components/form/stylesheet/toggle-switch.mjs +14 -7
- package/source/components/form/toggle-switch.mjs +372 -380
- package/source/components/layout/tabs.mjs +1 -2
- package/source/dom/constants.mjs +0 -1
- package/source/types/version.mjs +1 -1
- package/test/cases/monster.mjs +1 -1
- package/test/web/test.html +2 -2
- package/test/web/tests.js +154 -104
@@ -12,61 +12,61 @@
|
|
12
12
|
* SPDX-License-Identifier: AGPL-3.0
|
13
13
|
*/
|
14
14
|
|
15
|
-
import {instanceSymbol} from "../../constants.mjs";
|
16
|
-
import {internalSymbol} from "../../constants.mjs";
|
17
|
-
import {buildMap} from "../../data/buildmap.mjs";
|
18
|
-
import {DeadMansSwitch} from "../../util/deadmansswitch.mjs";
|
19
|
-
import {positionPopper} from "./util/floating-ui.mjs";
|
15
|
+
import { instanceSymbol } from "../../constants.mjs";
|
16
|
+
import { internalSymbol } from "../../constants.mjs";
|
17
|
+
import { buildMap } from "../../data/buildmap.mjs";
|
18
|
+
import { DeadMansSwitch } from "../../util/deadmansswitch.mjs";
|
19
|
+
import { positionPopper } from "./util/floating-ui.mjs";
|
20
20
|
import {
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
addAttributeToken,
|
22
|
+
findClosestByAttribute,
|
23
|
+
removeAttributeToken,
|
24
24
|
} from "../../dom/attributes.mjs";
|
25
25
|
import {
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
ATTRIBUTE_ERRORMESSAGE,
|
27
|
+
ATTRIBUTE_PREFIX,
|
28
|
+
ATTRIBUTE_ROLE,
|
29
29
|
} from "../../dom/constants.mjs";
|
30
|
-
import {CustomControl} from "../../dom/customcontrol.mjs";
|
30
|
+
import { CustomControl } from "../../dom/customcontrol.mjs";
|
31
31
|
import {
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
assembleMethodSymbol,
|
33
|
+
getSlottedElements,
|
34
|
+
registerCustomElement,
|
35
35
|
} from "../../dom/customelement.mjs";
|
36
36
|
import {
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
findTargetElementFromEvent,
|
38
|
+
fireCustomEvent,
|
39
|
+
fireEvent,
|
40
40
|
} from "../../dom/events.mjs";
|
41
|
-
import {getDocument, getWindow} from "../../dom/util.mjs";
|
42
|
-
import {Formatter} from "../../text/formatter.mjs";
|
43
|
-
import {getGlobal} from "../../types/global.mjs";
|
44
|
-
import {ID} from "../../types/id.mjs";
|
41
|
+
import { getDocument, getWindow } from "../../dom/util.mjs";
|
42
|
+
import { Formatter } from "../../text/formatter.mjs";
|
43
|
+
import { getGlobal } from "../../types/global.mjs";
|
44
|
+
import { ID } from "../../types/id.mjs";
|
45
45
|
import {
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
46
|
+
isArray,
|
47
|
+
isFunction,
|
48
|
+
isInteger,
|
49
|
+
isIterable,
|
50
|
+
isObject,
|
51
|
+
isPrimitive,
|
52
|
+
isString,
|
53
53
|
} from "../../types/is.mjs";
|
54
|
-
import {Observer} from "../../types/observer.mjs";
|
55
|
-
import {ProxyObserver} from "../../types/proxyobserver.mjs";
|
56
|
-
import {validateArray, validateString} from "../../types/validate.mjs";
|
57
|
-
import {Processing} from "../../util/processing.mjs";
|
58
|
-
import {STYLE_DISPLAY_MODE_BLOCK} from "./constants.mjs";
|
59
|
-
import {SelectStyleSheet} from "./stylesheet/select.mjs";
|
54
|
+
import { Observer } from "../../types/observer.mjs";
|
55
|
+
import { ProxyObserver } from "../../types/proxyobserver.mjs";
|
56
|
+
import { validateArray, validateString } from "../../types/validate.mjs";
|
57
|
+
import { Processing } from "../../util/processing.mjs";
|
58
|
+
import { STYLE_DISPLAY_MODE_BLOCK } from "./constants.mjs";
|
59
|
+
import { SelectStyleSheet } from "./stylesheet/select.mjs";
|
60
60
|
import {
|
61
|
-
|
62
|
-
|
61
|
+
getDocumentTranslations,
|
62
|
+
Translations,
|
63
63
|
} from "../../i18n/translations.mjs";
|
64
64
|
|
65
65
|
export {
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
Select,
|
67
|
+
popperElementSymbol,
|
68
|
+
getSummaryTemplate,
|
69
|
+
getSelectionTemplate,
|
70
70
|
};
|
71
71
|
|
72
72
|
/**
|
@@ -199,7 +199,7 @@ const popperFilterElementSymbol = Symbol("popperFilterElement");
|
|
199
199
|
* @type {Symbol}
|
200
200
|
*/
|
201
201
|
const popperFilterContainerElementSymbol = Symbol(
|
202
|
-
|
202
|
+
"popperFilterContainerElement",
|
203
203
|
);
|
204
204
|
|
205
205
|
/**
|
@@ -294,613 +294,611 @@ const FILTER_POSITION_INLINE = "inline";
|
|
294
294
|
* @fires monster-changed
|
295
295
|
*/
|
296
296
|
class Select extends CustomControl {
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
return [SelectStyleSheet];
|
780
|
-
}
|
297
|
+
/**
|
298
|
+
*
|
299
|
+
*/
|
300
|
+
constructor() {
|
301
|
+
super();
|
302
|
+
initOptionObserver.call(this);
|
303
|
+
}
|
304
|
+
|
305
|
+
/**
|
306
|
+
* This method is called by the `instanceof` operator.
|
307
|
+
* @return {Symbol}
|
308
|
+
*/
|
309
|
+
static get [instanceSymbol]() {
|
310
|
+
return Symbol.for("@schukai/monster/components/form/select@@instance");
|
311
|
+
}
|
312
|
+
|
313
|
+
/**
|
314
|
+
* The current selection of the Select
|
315
|
+
*
|
316
|
+
* ```
|
317
|
+
* e = document.querySelector('monster-select');
|
318
|
+
* console.log(e.value)
|
319
|
+
* // ↦ 1
|
320
|
+
* // ↦ ['1','2']
|
321
|
+
* ```
|
322
|
+
*
|
323
|
+
* @return {string}
|
324
|
+
*/
|
325
|
+
get value() {
|
326
|
+
return convertSelectionToValue.call(this, this.getOption("selection"));
|
327
|
+
}
|
328
|
+
|
329
|
+
/**
|
330
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals}
|
331
|
+
* @return {boolean}
|
332
|
+
*/
|
333
|
+
static get formAssociated() {
|
334
|
+
return true;
|
335
|
+
}
|
336
|
+
|
337
|
+
/**
|
338
|
+
* Set selection
|
339
|
+
*
|
340
|
+
* ```
|
341
|
+
* e = document.querySelector('monster-select');
|
342
|
+
* e.value=1
|
343
|
+
* ```
|
344
|
+
*
|
345
|
+
* @property {string|array} value
|
346
|
+
* @throws {Error} unsupported type
|
347
|
+
* @fires monster-selected this event is fired when the selection is set
|
348
|
+
*/
|
349
|
+
set value(value) {
|
350
|
+
const result = convertValueToSelection.call(this, value);
|
351
|
+
setSelection
|
352
|
+
.call(this, result.selection)
|
353
|
+
.then(() => {})
|
354
|
+
.catch((e) => {
|
355
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
|
356
|
+
});
|
357
|
+
}
|
358
|
+
|
359
|
+
/**
|
360
|
+
* To set the options via the HTML tag, the attribute `data-monster-options` must be used.
|
361
|
+
* @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
|
362
|
+
*
|
363
|
+
* The individual configuration values can be found in the table.
|
364
|
+
*
|
365
|
+
* @property {Object} toggleEventType=click,touch List of event types to be observed for opening the dropdown
|
366
|
+
* @property {boolean} delegatesFocus=false lorem [see mozilla.org](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/delegatesFocus)
|
367
|
+
* @property {Object[]} options Selection of key identifier pairs available for selection and displayed in the dropdown.
|
368
|
+
* @property {string} options[].label
|
369
|
+
* @property {string} options[].value
|
370
|
+
* @property {string} options[].visibility hidden or visible
|
371
|
+
* @property {Array} selection Selected options
|
372
|
+
* @property {Integer} showMaxOptions=10 Maximum number of visible options before a scroll bar should be displayed.
|
373
|
+
* @property {string} type=radio Multiple (checkbox) or single selection (radio)
|
374
|
+
* @property {string} name=(random id) Name of the form field
|
375
|
+
* @property {string} url Load options from server per url
|
376
|
+
* @property {object} lookup Load options from server per url
|
377
|
+
* @property {string} lookup.url=null Load options from server per url
|
378
|
+
* @property {boolean} lookup.grouping=false Load all selected options from server per url at once (true) or one by one (false)
|
379
|
+
* @property {Object} fetch Fetch [see Using Fetch mozilla.org](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch)
|
380
|
+
* @property {String} fetch.redirect=error
|
381
|
+
* @property {String} fetch.method=GET
|
382
|
+
* @property {String} fetch.mode=same-origin
|
383
|
+
* @property {String} fetch.credentials=same-origin
|
384
|
+
* @property {Object} fetch.headers={"accept":"application/json"}}
|
385
|
+
* @property {Object} labels
|
386
|
+
* @property {string} labels.cannot-be-loaded cannot be loaded
|
387
|
+
* @property {string} labels.no-options-available no options available
|
388
|
+
* @property {string} labels.select-an-option select an option
|
389
|
+
* @property {string} labels.no-option no option in the list, maybe you have to change the filter
|
390
|
+
* @property {Object} features List with features
|
391
|
+
* @property {Boolean} features.clearAll=true Display of a delete button to delete the entire selection
|
392
|
+
* @property {Boolean} features.clear=true Display of a delete key for deleting the specific selection
|
393
|
+
* @property {Boolean} features.lazyLoad=false Load options when first opening the dropdown. (Hint; lazylLoad is not supported with remote filter)
|
394
|
+
* @property {Boolean} features.closeOnSelect=false Close the dropdown when an option is selected (since 3.54.0)
|
395
|
+
* @property {Boolean} features.emptyValueIfNoOptions=false If no options are available, the selection is set to an empty array
|
396
|
+
* @property {Boolean} features.storeFetchedData=false Store fetched data in the object
|
397
|
+
* @property {Boolean} features.useStrictValueComparison=true Use strict value comparison for the selection
|
398
|
+
* @property {string} filter.defaultValue=null Default filter value, if the filter is empty, if the default value is null, then no request is made
|
399
|
+
* @property {Boolean} filter.mode=options Filter mode, values: options, remote, disabled (Hint; lazylLoad is not supported with remote filter, if you use remote filter, the lazyLoad is disabled)
|
400
|
+
* @property {Object} templates Template definitions
|
401
|
+
* @property {string} templates.main Main template
|
402
|
+
* @property {string} templateMapping Mapping of the template placeholders
|
403
|
+
* @property {string} templateMapping.selected Selected Template
|
404
|
+
* @property {Object} popper [PopperJS Options](https://popper.js.org/docs/v2/)
|
405
|
+
* @property {string} popper.placement=bottom PopperJS placement
|
406
|
+
* @property {Object[]} modifiers={name:offset} PopperJS placement
|
407
|
+
* @property {Object} mapping
|
408
|
+
* @property {String} mapping.selector=* Path to select the appropriate entries
|
409
|
+
* @property {String} mapping.labelTemplate="" template with the label placeholders in the form ${name}, where name is the key (**)
|
410
|
+
* @property {String} mapping.valueTemplate="" template with the value placeholders in the form ${name}, where name is the key
|
411
|
+
* @property {Monster.Components.Form~exampleFilterCallback|undefined} mapping.filter Filtering of values via a function
|
412
|
+
* @property {Object} formatter
|
413
|
+
* @property {Monster.Components.Form~formatterSelectionCallback|undefined} formatter.selection format selection label
|
414
|
+
*/
|
415
|
+
get defaults() {
|
416
|
+
return Object.assign(
|
417
|
+
{},
|
418
|
+
super.defaults,
|
419
|
+
{
|
420
|
+
toggleEventType: ["click", "touch"],
|
421
|
+
delegatesFocus: false,
|
422
|
+
options: [],
|
423
|
+
selection: [],
|
424
|
+
showMaxOptions: 10,
|
425
|
+
type: "radio",
|
426
|
+
name: new ID("s").toString(),
|
427
|
+
features: {
|
428
|
+
clearAll: true,
|
429
|
+
clear: true,
|
430
|
+
lazyLoad: false,
|
431
|
+
closeOnSelect: false,
|
432
|
+
emptyValueIfNoOptions: false,
|
433
|
+
storeFetchedData: false,
|
434
|
+
useStrictValueComparison: false,
|
435
|
+
},
|
436
|
+
url: null,
|
437
|
+
lookup: {
|
438
|
+
url: null,
|
439
|
+
grouping: false,
|
440
|
+
},
|
441
|
+
labels: {
|
442
|
+
"cannot-be-loaded": "Cannot be loaded",
|
443
|
+
"no-options-available": noOptionsAvailableMessage,
|
444
|
+
"click-to-load-options": clickToLoadOptionsMessage,
|
445
|
+
"select-an-option": "Select an option",
|
446
|
+
"summary-text": {
|
447
|
+
zero: "No entries were selected",
|
448
|
+
one: '<span class="monster-badge-primary-pill">1</span> entry was selected',
|
449
|
+
other:
|
450
|
+
'<span class="monster-badge-primary-pill">${count}</span> entries were selected',
|
451
|
+
},
|
452
|
+
"no-options":
|
453
|
+
"Unfortunately, there are no options available in the list.",
|
454
|
+
"no-options-found":
|
455
|
+
"No options are available in the list. Please consider modifying the filter.",
|
456
|
+
},
|
457
|
+
messages: {
|
458
|
+
control: null,
|
459
|
+
selected: null,
|
460
|
+
emptyOptions: null,
|
461
|
+
},
|
462
|
+
fetch: {
|
463
|
+
redirect: "error",
|
464
|
+
method: "GET",
|
465
|
+
mode: "same-origin",
|
466
|
+
credentials: "same-origin",
|
467
|
+
headers: {
|
468
|
+
accept: "application/json",
|
469
|
+
},
|
470
|
+
},
|
471
|
+
filter: {
|
472
|
+
defaultValue: null,
|
473
|
+
mode: FILTER_MODE_DISABLED,
|
474
|
+
position: FILTER_POSITION_INLINE,
|
475
|
+
marker: {
|
476
|
+
open: "{",
|
477
|
+
close: "}",
|
478
|
+
},
|
479
|
+
},
|
480
|
+
classes: {
|
481
|
+
badge: "monster-badge-primary",
|
482
|
+
statusOrRemoveBadge: "empty",
|
483
|
+
},
|
484
|
+
mapping: {
|
485
|
+
selector: "*",
|
486
|
+
labelTemplate: "",
|
487
|
+
valueTemplate: "",
|
488
|
+
filter: null,
|
489
|
+
},
|
490
|
+
formatter: {
|
491
|
+
selection: buildSelectionLabel,
|
492
|
+
},
|
493
|
+
templates: {
|
494
|
+
main: getTemplate(),
|
495
|
+
},
|
496
|
+
templateMapping: {
|
497
|
+
/** with the attribute `data-monster-selected-template` the template for the selected options can be defined. */
|
498
|
+
selected: getSelectionTemplate(),
|
499
|
+
},
|
500
|
+
|
501
|
+
popper: {
|
502
|
+
placement: "bottom",
|
503
|
+
middleware: ["flip", "offset:1"],
|
504
|
+
},
|
505
|
+
},
|
506
|
+
initOptionsFromArguments.call(this),
|
507
|
+
);
|
508
|
+
}
|
509
|
+
|
510
|
+
/**
|
511
|
+
* @return {Select}
|
512
|
+
*/
|
513
|
+
[assembleMethodSymbol]() {
|
514
|
+
const self = this;
|
515
|
+
super[assembleMethodSymbol]();
|
516
|
+
|
517
|
+
initControlReferences.call(self);
|
518
|
+
initEventHandler.call(self);
|
519
|
+
|
520
|
+
let lazyLoadFlag = self.getOption("features.lazyLoad", false);
|
521
|
+
let remoteFilterFlag = getFilterMode.call(this) === FILTER_MODE_REMOTE;
|
522
|
+
|
523
|
+
if (getFilterMode.call(this) === FILTER_MODE_REMOTE) {
|
524
|
+
self.getOption("features.lazyLoad", false);
|
525
|
+
if (lazyLoadFlag === true) {
|
526
|
+
addAttributeToken(
|
527
|
+
this,
|
528
|
+
ATTRIBUTE_ERRORMESSAGE,
|
529
|
+
"lazyLoad is not supported with remote filter",
|
530
|
+
);
|
531
|
+
lazyLoadFlag = false;
|
532
|
+
}
|
533
|
+
}
|
534
|
+
|
535
|
+
if (self.hasAttribute("value")) {
|
536
|
+
new Processing(10, () => {
|
537
|
+
this.value = this.getAttribute("value");
|
538
|
+
})
|
539
|
+
.run()
|
540
|
+
.catch((e) => {
|
541
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
|
542
|
+
});
|
543
|
+
}
|
544
|
+
|
545
|
+
if (self.getOption("url") !== null) {
|
546
|
+
if (lazyLoadFlag || remoteFilterFlag) {
|
547
|
+
lookupSelection.call(self);
|
548
|
+
} else {
|
549
|
+
self.fetch().catch((e) => {
|
550
|
+
addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, `${e}`);
|
551
|
+
});
|
552
|
+
}
|
553
|
+
}
|
554
|
+
|
555
|
+
let lastValue = self.value;
|
556
|
+
self[internalSymbol].attachObserver(
|
557
|
+
new Observer(function () {
|
558
|
+
if (isObject(this) && this instanceof ProxyObserver) {
|
559
|
+
const n = this.getSubject()?.options?.value;
|
560
|
+
|
561
|
+
if (lastValue !== n) {
|
562
|
+
lastValue = n;
|
563
|
+
setSelection
|
564
|
+
.call(self, n)
|
565
|
+
.then(() => {})
|
566
|
+
.catch((e) => {
|
567
|
+
addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, `${e}`);
|
568
|
+
});
|
569
|
+
}
|
570
|
+
}
|
571
|
+
}),
|
572
|
+
);
|
573
|
+
|
574
|
+
areOptionsAvailableAndInit.call(self);
|
575
|
+
|
576
|
+
return this;
|
577
|
+
}
|
578
|
+
|
579
|
+
/**
|
580
|
+
*
|
581
|
+
* @return {*}
|
582
|
+
* @throws {Error} storeFetchedData is not enabled
|
583
|
+
* @since 3.66.0
|
584
|
+
*/
|
585
|
+
getLastFetchedData() {
|
586
|
+
if (this.getOption("features.storeFetchedData") === false) {
|
587
|
+
throw new Error("storeFetchedData is not enabled");
|
588
|
+
}
|
589
|
+
|
590
|
+
return this?.[lastFetchedDataSymbol];
|
591
|
+
}
|
592
|
+
|
593
|
+
/**
|
594
|
+
* The Button.click() method simulates a click on the internal button element.
|
595
|
+
*
|
596
|
+
* @since 3.27.0
|
597
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click}
|
598
|
+
*/
|
599
|
+
click() {
|
600
|
+
if (this.getOption("disabled") === true) {
|
601
|
+
return;
|
602
|
+
}
|
603
|
+
|
604
|
+
toggle.call(this);
|
605
|
+
}
|
606
|
+
|
607
|
+
/**
|
608
|
+
* The Button.focus() method sets focus on the internal button element.
|
609
|
+
*
|
610
|
+
* @since 3.27.0
|
611
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus}
|
612
|
+
*/
|
613
|
+
focus(options) {
|
614
|
+
if (this.getOption("disabled") === true) {
|
615
|
+
return;
|
616
|
+
}
|
617
|
+
|
618
|
+
new Processing(() => {
|
619
|
+
gatherState.call(this);
|
620
|
+
focusFilter.call(this, options);
|
621
|
+
})
|
622
|
+
.run()
|
623
|
+
.catch((e) => {
|
624
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, `${e}`);
|
625
|
+
});
|
626
|
+
}
|
627
|
+
|
628
|
+
/**
|
629
|
+
* The Button.blur() method removes focus from the internal button element.
|
630
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur
|
631
|
+
*/
|
632
|
+
blur() {
|
633
|
+
new Processing(() => {
|
634
|
+
gatherState.call(this);
|
635
|
+
blurFilter.call(this);
|
636
|
+
})
|
637
|
+
.run()
|
638
|
+
.catch((e) => {
|
639
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, `${e}`);
|
640
|
+
});
|
641
|
+
}
|
642
|
+
|
643
|
+
/**
|
644
|
+
* If no url is specified, the options are taken from the Component itself.
|
645
|
+
*
|
646
|
+
* @param {string|URL} url URL to fetch the options
|
647
|
+
* @return {Promise}
|
648
|
+
*/
|
649
|
+
fetch(url) {
|
650
|
+
return fetchIt.call(this, url);
|
651
|
+
}
|
652
|
+
|
653
|
+
/**
|
654
|
+
* @return {void}
|
655
|
+
*/
|
656
|
+
connectedCallback() {
|
657
|
+
super.connectedCallback();
|
658
|
+
const document = getDocument();
|
659
|
+
|
660
|
+
for (const [, type] of Object.entries(["click", "touch"])) {
|
661
|
+
// close on outside ui-events
|
662
|
+
document.addEventListener(type, this[closeEventHandler]);
|
663
|
+
}
|
664
|
+
|
665
|
+
parseSlotsToOptions.call(this);
|
666
|
+
attachResizeObserver.call(this);
|
667
|
+
updatePopper.call(this);
|
668
|
+
|
669
|
+
new Processing(() => {
|
670
|
+
gatherState.call(this);
|
671
|
+
focusFilter.call(this);
|
672
|
+
})
|
673
|
+
.run()
|
674
|
+
.catch((e) => {
|
675
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, `${e}`);
|
676
|
+
});
|
677
|
+
}
|
678
|
+
|
679
|
+
/**
|
680
|
+
* @return {void}
|
681
|
+
*/
|
682
|
+
disconnectedCallback() {
|
683
|
+
super.disconnectedCallback();
|
684
|
+
const document = getDocument();
|
685
|
+
|
686
|
+
// close on outside ui-events
|
687
|
+
for (const [, type] of Object.entries(["click", "touch"])) {
|
688
|
+
document.removeEventListener(type, this[closeEventHandler]);
|
689
|
+
}
|
690
|
+
|
691
|
+
disconnectResizeObserver.call(this);
|
692
|
+
}
|
693
|
+
|
694
|
+
/**
|
695
|
+
* Import Select Options from dataset
|
696
|
+
* Not to be confused with the control defaults/options
|
697
|
+
*
|
698
|
+
* @param {array|object|Map|Set} data
|
699
|
+
* @return {Select}
|
700
|
+
* @throws {Error} map is not iterable
|
701
|
+
* @throws {Error} missing label configuration
|
702
|
+
* @fires monster-options-set this event is fired when the options are set
|
703
|
+
*/
|
704
|
+
importOptions(data) {
|
705
|
+
const mappingOptions = this.getOption("mapping", {});
|
706
|
+
const selector = mappingOptions?.["selector"];
|
707
|
+
const labelTemplate = mappingOptions?.["labelTemplate"];
|
708
|
+
const valueTemplate = mappingOptions?.["valueTemplate"];
|
709
|
+
const filter = mappingOptions?.["filter"];
|
710
|
+
|
711
|
+
let flag = false;
|
712
|
+
if (labelTemplate === "") {
|
713
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, "empty label template");
|
714
|
+
flag = true;
|
715
|
+
}
|
716
|
+
|
717
|
+
if (valueTemplate === "") {
|
718
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, "empty value template");
|
719
|
+
flag = true;
|
720
|
+
}
|
721
|
+
|
722
|
+
if (flag === true) {
|
723
|
+
throw new Error("missing label configuration");
|
724
|
+
}
|
725
|
+
|
726
|
+
const map = buildMap(data, selector, labelTemplate, valueTemplate, filter);
|
727
|
+
|
728
|
+
const options = [];
|
729
|
+
|
730
|
+
if (!isIterable(map)) {
|
731
|
+
throw new Error("map is not iterable");
|
732
|
+
}
|
733
|
+
|
734
|
+
const visibility = "visible";
|
735
|
+
|
736
|
+
map.forEach((label, value) => {
|
737
|
+
options.push({
|
738
|
+
value,
|
739
|
+
label,
|
740
|
+
visibility,
|
741
|
+
data: map.get(value),
|
742
|
+
});
|
743
|
+
});
|
744
|
+
|
745
|
+
runAsOptionLengthChanged.call(this, map.size);
|
746
|
+
this.setOption("options", options);
|
747
|
+
|
748
|
+
fireCustomEvent(this, "monster-options-set", {
|
749
|
+
options,
|
750
|
+
});
|
751
|
+
|
752
|
+
return this;
|
753
|
+
}
|
754
|
+
|
755
|
+
/**
|
756
|
+
* @private
|
757
|
+
* @return {Select}
|
758
|
+
*/
|
759
|
+
calcAndSetOptionsDimension() {
|
760
|
+
calcAndSetOptionsDimension.call(this);
|
761
|
+
return this;
|
762
|
+
}
|
763
|
+
|
764
|
+
/**
|
765
|
+
*
|
766
|
+
* @return {string}
|
767
|
+
*/
|
768
|
+
static getTag() {
|
769
|
+
return "monster-select";
|
770
|
+
}
|
771
|
+
|
772
|
+
/**
|
773
|
+
*
|
774
|
+
* @return {CSSStyleSheet[]}
|
775
|
+
*/
|
776
|
+
static getCSSStyleSheet() {
|
777
|
+
return [SelectStyleSheet];
|
778
|
+
}
|
781
779
|
}
|
782
780
|
|
783
781
|
/**
|
784
782
|
* @private
|
785
783
|
*/
|
786
784
|
function lookupSelection() {
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
785
|
+
const self = this;
|
786
|
+
|
787
|
+
setTimeout(() => {
|
788
|
+
const selection = self.getOption("selection");
|
789
|
+
if (selection.length === 0) {
|
790
|
+
return;
|
791
|
+
}
|
792
|
+
|
793
|
+
if (self[isLoadingSymbol] === true) {
|
794
|
+
return;
|
795
|
+
}
|
796
|
+
|
797
|
+
if (self[lazyLoadDoneSymbol] === true) {
|
798
|
+
return;
|
799
|
+
}
|
800
|
+
|
801
|
+
let url = self.getOption("url");
|
802
|
+
let lookupUrl = self.getOption("lookup.url");
|
803
|
+
if (lookupUrl !== null) {
|
804
|
+
url = lookupUrl;
|
805
|
+
}
|
806
|
+
|
807
|
+
if (this.getOption("lookup.grouping") === true) {
|
808
|
+
filterFromRemoteByValue
|
809
|
+
.call(
|
810
|
+
self,
|
811
|
+
url,
|
812
|
+
selection.map((s) => s?.["value"]),
|
813
|
+
)
|
814
|
+
.catch((e) => {
|
815
|
+
addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, `${e}`);
|
816
|
+
});
|
817
|
+
return;
|
818
|
+
}
|
819
|
+
|
820
|
+
for (const s of selection) {
|
821
|
+
if (s?.["value"]) {
|
822
|
+
filterFromRemoteByValue.call(self, url, s?.["value"]).catch((e) => {
|
823
|
+
addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, `${e}`);
|
824
|
+
});
|
825
|
+
}
|
826
|
+
}
|
827
|
+
}, 100);
|
830
828
|
}
|
831
829
|
|
832
830
|
function fetchIt(url, controlOptions) {
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
831
|
+
if (url instanceof URL) {
|
832
|
+
url = url.toString();
|
833
|
+
}
|
834
|
+
|
835
|
+
if (url !== undefined && url !== null) {
|
836
|
+
url = validateString(url);
|
837
|
+
} else {
|
838
|
+
url = this.getOption("url");
|
839
|
+
if (url === null) {
|
840
|
+
return Promise.reject(new Error("No url defined"));
|
841
|
+
}
|
842
|
+
}
|
843
|
+
|
844
|
+
return new Promise((resolve, reject) => {
|
845
|
+
setStatusOrRemoveBadges.call(this, "loading");
|
846
|
+
|
847
|
+
new Processing(10, () => {
|
848
|
+
fetchData
|
849
|
+
.call(this, url)
|
850
|
+
.then((map) => {
|
851
|
+
if (
|
852
|
+
isObject(map) ||
|
853
|
+
isArray(map) ||
|
854
|
+
map instanceof Set ||
|
855
|
+
map instanceof Map
|
856
|
+
) {
|
857
|
+
try {
|
858
|
+
this.importOptions(map);
|
859
|
+
} catch (e) {
|
860
|
+
setStatusOrRemoveBadges.call(this, "error");
|
861
|
+
reject(e);
|
862
|
+
return;
|
863
|
+
}
|
864
|
+
|
865
|
+
this[lastFetchedDataSymbol] = map;
|
866
|
+
|
867
|
+
let result;
|
868
|
+
const selection = this.getOption("selection");
|
869
|
+
let newValue = [];
|
870
|
+
if (selection) {
|
871
|
+
newValue = selection;
|
872
|
+
} else if (this.hasAttribute("value")) {
|
873
|
+
newValue = this.getAttribute("value");
|
874
|
+
}
|
875
|
+
|
876
|
+
result = setSelection.call(this, newValue);
|
877
|
+
requestAnimationFrame(() => {
|
878
|
+
checkOptionState.call(this);
|
879
|
+
setStatusOrRemoveBadges.call(this, "closed");
|
880
|
+
updatePopper.call(this);
|
881
|
+
resolve(result);
|
882
|
+
});
|
883
|
+
|
884
|
+
return;
|
885
|
+
}
|
886
|
+
|
887
|
+
setStatusOrRemoveBadges.call(this, "error");
|
888
|
+
reject(new Error("invalid response"));
|
889
|
+
})
|
890
|
+
.catch((e) => {
|
891
|
+
setStatusOrRemoveBadges.call(this, "error");
|
892
|
+
reject(e);
|
893
|
+
});
|
894
|
+
})
|
895
|
+
.run()
|
896
|
+
.catch((e) => {
|
897
|
+
setStatusOrRemoveBadges.call(this, "error");
|
898
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
|
899
|
+
reject(e);
|
900
|
+
});
|
901
|
+
});
|
904
902
|
}
|
905
903
|
|
906
904
|
/**
|
@@ -915,64 +913,64 @@ function fetchIt(url, controlOptions) {
|
|
915
913
|
* @return {object}
|
916
914
|
*/
|
917
915
|
function initOptionsFromArguments() {
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
916
|
+
const options = {};
|
917
|
+
|
918
|
+
const template = this.getAttribute("data-monster-selected-template");
|
919
|
+
if (isString(template)) {
|
920
|
+
if (!options["templateMapping"]) options["templateMapping"] = {};
|
921
|
+
|
922
|
+
switch (template) {
|
923
|
+
case "summary":
|
924
|
+
case "default":
|
925
|
+
options["templateMapping"]["selected"] = getSummaryTemplate();
|
926
|
+
break;
|
927
|
+
case "selected":
|
928
|
+
options["templateMapping"]["selected"] = getSelectionTemplate();
|
929
|
+
break;
|
930
|
+
default:
|
931
|
+
addAttributeToken(
|
932
|
+
this,
|
933
|
+
ATTRIBUTE_ERRORMESSAGE,
|
934
|
+
"invalid template, use summary or selected",
|
935
|
+
);
|
936
|
+
}
|
937
|
+
}
|
938
|
+
|
939
|
+
return options;
|
942
940
|
}
|
943
941
|
|
944
942
|
/**
|
945
943
|
* @private
|
946
944
|
*/
|
947
945
|
function attachResizeObserver() {
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
946
|
+
// against flickering
|
947
|
+
this[resizeObserverSymbol] = new ResizeObserver((entries) => {
|
948
|
+
if (this[timerCallbackSymbol] instanceof DeadMansSwitch) {
|
949
|
+
try {
|
950
|
+
this[timerCallbackSymbol].touch();
|
951
|
+
return;
|
952
|
+
} catch (e) {
|
953
|
+
delete this[timerCallbackSymbol];
|
954
|
+
}
|
955
|
+
}
|
956
|
+
|
957
|
+
this[timerCallbackSymbol] = new DeadMansSwitch(200, () => {
|
958
|
+
updatePopper.call(this);
|
959
|
+
delete this[timerCallbackSymbol];
|
960
|
+
});
|
961
|
+
});
|
962
|
+
|
963
|
+
this[resizeObserverSymbol].observe(this.parentElement);
|
966
964
|
}
|
967
965
|
|
968
966
|
function disconnectResizeObserver() {
|
969
|
-
|
970
|
-
|
971
|
-
|
967
|
+
if (this[resizeObserverSymbol] instanceof ResizeObserver) {
|
968
|
+
this[resizeObserverSymbol].disconnect();
|
969
|
+
}
|
972
970
|
}
|
973
971
|
|
974
972
|
function getSelectionTemplate() {
|
975
|
-
|
973
|
+
return `<div data-monster-role="selection" part="selection"
|
976
974
|
data-monster-insert="selection path:selection" role="search"
|
977
975
|
><input type="text" role="searchbox"
|
978
976
|
part="inline-filter" name="inline-filter"
|
@@ -984,7 +982,7 @@ function getSelectionTemplate() {
|
|
984
982
|
}
|
985
983
|
|
986
984
|
function getSummaryTemplate() {
|
987
|
-
|
985
|
+
return `<div data-monster-role="selection" role="search" part="summary">
|
988
986
|
<input type="text" role="searchbox"
|
989
987
|
part="inline-filter" name="inline-filter"
|
990
988
|
data-monster-role="filter"
|
@@ -1000,35 +998,35 @@ function getSummaryTemplate() {
|
|
1000
998
|
* @private
|
1001
999
|
*/
|
1002
1000
|
function parseSlotsToOptions() {
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1001
|
+
let options = this.getOption("options");
|
1002
|
+
if (!isIterable(options)) {
|
1003
|
+
options = [];
|
1004
|
+
}
|
1005
|
+
|
1006
|
+
let counter = 1;
|
1007
|
+
getSlottedElements.call(this, "div").forEach((node) => {
|
1008
|
+
let value = (counter++).toString();
|
1009
|
+
let visibility = "visible";
|
1010
|
+
|
1011
|
+
if (node.hasAttribute("data-monster-value")) {
|
1012
|
+
value = node.getAttribute("data-monster-value");
|
1013
|
+
}
|
1014
|
+
|
1015
|
+
let label = node.outerHTML;
|
1016
|
+
|
1017
|
+
if (node.style.display === "none") {
|
1018
|
+
visibility = "hidden";
|
1019
|
+
}
|
1020
|
+
|
1021
|
+
options.push({
|
1022
|
+
value,
|
1023
|
+
label,
|
1024
|
+
visibility,
|
1025
|
+
});
|
1026
|
+
});
|
1027
|
+
|
1028
|
+
runAsOptionLengthChanged.call(this, options.length);
|
1029
|
+
this.setOption("options", options);
|
1032
1030
|
}
|
1033
1031
|
|
1034
1032
|
/**
|
@@ -1038,39 +1036,39 @@ function parseSlotsToOptions() {
|
|
1038
1036
|
* @param {int} targetLength
|
1039
1037
|
*/
|
1040
1038
|
function runAsOptionLengthChanged(targetLength) {
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1039
|
+
const self = this;
|
1040
|
+
|
1041
|
+
if (!self[optionsElementSymbol]) {
|
1042
|
+
return;
|
1043
|
+
}
|
1044
|
+
|
1045
|
+
const callback = function (mutationsList, observer) {
|
1046
|
+
const run = false;
|
1047
|
+
for (const mutation of mutationsList) {
|
1048
|
+
if (mutation.type === "childList") {
|
1049
|
+
const run = true;
|
1050
|
+
break;
|
1051
|
+
}
|
1052
|
+
}
|
1053
|
+
|
1054
|
+
if (run === true) {
|
1055
|
+
const nodes = self[optionsElementSymbol].querySelectorAll(
|
1056
|
+
`div[${ATTRIBUTE_ROLE}=option]`,
|
1057
|
+
);
|
1058
|
+
|
1059
|
+
if (nodes.length === targetLength) {
|
1060
|
+
checkOptionState.call(self);
|
1061
|
+
observer.disconnect();
|
1062
|
+
}
|
1063
|
+
}
|
1064
|
+
};
|
1065
|
+
|
1066
|
+
const observer = new MutationObserver(callback);
|
1067
|
+
observer.observe(self[optionsElementSymbol], {
|
1068
|
+
attributes: false,
|
1069
|
+
childList: true,
|
1070
|
+
subtree: true,
|
1071
|
+
});
|
1074
1072
|
}
|
1075
1073
|
|
1076
1074
|
/**
|
@@ -1079,38 +1077,38 @@ function runAsOptionLengthChanged(targetLength) {
|
|
1079
1077
|
* @return {*}
|
1080
1078
|
*/
|
1081
1079
|
function buildSelectionLabel(value) {
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1080
|
+
const options = this.getOption("options");
|
1081
|
+
|
1082
|
+
for (let i = 0; i < options.length; i++) {
|
1083
|
+
let o = options?.[i];
|
1084
|
+
let l, v, v2;
|
1085
|
+
|
1086
|
+
if (this.getOption("features.useStrictValueComparison") === true) {
|
1087
|
+
v = value;
|
1088
|
+
} else {
|
1089
|
+
v = `${value}`;
|
1090
|
+
}
|
1091
|
+
|
1092
|
+
if (isPrimitive(o) && o === value) {
|
1093
|
+
return o;
|
1094
|
+
} else if (!isObject(o)) {
|
1095
|
+
continue;
|
1096
|
+
}
|
1097
|
+
|
1098
|
+
if (this.getOption("features.useStrictValueComparison") === true) {
|
1099
|
+
l = o?.["label"];
|
1100
|
+
v2 = o?.["value"];
|
1101
|
+
} else {
|
1102
|
+
l = `${o?.["label"]}`;
|
1103
|
+
v2 = `${o?.["value"]}`;
|
1104
|
+
}
|
1105
|
+
|
1106
|
+
if (v2 === v) {
|
1107
|
+
return l;
|
1108
|
+
}
|
1109
|
+
}
|
1110
|
+
|
1111
|
+
return undefined;
|
1114
1112
|
}
|
1115
1113
|
|
1116
1114
|
/**
|
@@ -1120,17 +1118,17 @@ function buildSelectionLabel(value) {
|
|
1120
1118
|
* @throws {Error} no value found
|
1121
1119
|
*/
|
1122
1120
|
function getSelectionLabel(value) {
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1121
|
+
const callback = this.getOption("formatter.selection");
|
1122
|
+
if (isFunction(callback)) {
|
1123
|
+
const label = callback.call(this, value);
|
1124
|
+
if (isString(label)) return label;
|
1125
|
+
}
|
1128
1126
|
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1127
|
+
if (isString(value) || isInteger(value)) {
|
1128
|
+
return `${value}`;
|
1129
|
+
}
|
1132
1130
|
|
1133
|
-
|
1131
|
+
return this.getOption("labels.cannot-be-loaded", value);
|
1134
1132
|
}
|
1135
1133
|
|
1136
1134
|
/**
|
@@ -1138,25 +1136,25 @@ function getSelectionLabel(value) {
|
|
1138
1136
|
* @param {Event} event
|
1139
1137
|
*/
|
1140
1138
|
function handleToggleKeyboardEvents(event) {
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1139
|
+
switch (event?.["code"]) {
|
1140
|
+
case "Escape":
|
1141
|
+
toggle.call(this);
|
1142
|
+
event.preventDefault();
|
1143
|
+
break;
|
1144
|
+
case "Space":
|
1145
|
+
toggle.call(this);
|
1146
|
+
event.preventDefault();
|
1147
|
+
break;
|
1148
|
+
case "ArrowDown":
|
1149
|
+
show.call(this);
|
1150
|
+
activateCurrentOption.call(this, FOCUS_DIRECTION_DOWN);
|
1151
|
+
event.preventDefault();
|
1152
|
+
break;
|
1153
|
+
case "ArrowUp":
|
1154
|
+
hide.call(this);
|
1155
|
+
event.preventDefault();
|
1156
|
+
break;
|
1157
|
+
}
|
1160
1158
|
}
|
1161
1159
|
|
1162
1160
|
/**
|
@@ -1166,46 +1164,45 @@ function handleToggleKeyboardEvents(event) {
|
|
1166
1164
|
* @this CustomElement
|
1167
1165
|
*/
|
1168
1166
|
function initOptionObserver() {
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1167
|
+
const self = this;
|
1168
|
+
|
1169
|
+
self.attachObserver(
|
1170
|
+
new Observer(function () {
|
1171
|
+
new Processing(() => {
|
1172
|
+
try {
|
1173
|
+
self.updateI18n();
|
1174
|
+
} catch (e) {
|
1175
|
+
addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, e.message);
|
1176
|
+
requestAnimationFrame(() => {
|
1177
|
+
setStatusOrRemoveBadges.call(self, "error");
|
1178
|
+
});
|
1179
|
+
}
|
1180
|
+
try {
|
1181
|
+
areOptionsAvailableAndInit.call(self);
|
1182
|
+
} catch (e) {
|
1183
|
+
addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, e.message);
|
1184
|
+
requestAnimationFrame(() => {
|
1185
|
+
setStatusOrRemoveBadges.call(self, "error");
|
1186
|
+
});
|
1187
|
+
}
|
1188
|
+
|
1189
|
+
setSummaryAndControlText.call(self);
|
1190
|
+
}).run();
|
1191
|
+
}),
|
1192
|
+
);
|
1195
1193
|
}
|
1196
1194
|
|
1197
1195
|
function getDefaultTranslation() {
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1196
|
+
const translation = new Translations("en").assignTranslations(
|
1197
|
+
this.getOption("labels", {}),
|
1198
|
+
);
|
1201
1199
|
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
}
|
1200
|
+
try {
|
1201
|
+
const doc = getDocumentTranslations();
|
1202
|
+
translation.locale = doc.locale;
|
1203
|
+
} catch (e) {}
|
1207
1204
|
|
1208
|
-
|
1205
|
+
return translation;
|
1209
1206
|
}
|
1210
1207
|
|
1211
1208
|
/**
|
@@ -1213,36 +1210,36 @@ function getDefaultTranslation() {
|
|
1213
1210
|
* @return {string|*}
|
1214
1211
|
*/
|
1215
1212
|
function setSummaryAndControlText() {
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1213
|
+
const translations = getDefaultTranslation.call(this);
|
1214
|
+
const selections = this.getOption("selection");
|
1215
|
+
|
1216
|
+
const text = translations.getPluralRuleText(
|
1217
|
+
"summary-text",
|
1218
|
+
selections.length,
|
1219
|
+
"",
|
1220
|
+
);
|
1221
|
+
|
1222
|
+
const selectedText = new Formatter({
|
1223
|
+
count: String(selections.length),
|
1224
|
+
}).format(text);
|
1225
|
+
|
1226
|
+
this.setOption("messages.selected", selectedText);
|
1227
|
+
|
1228
|
+
const current = this.getOption("messages.control");
|
1229
|
+
const msg = this.getOption("labels.select-an-option");
|
1230
|
+
|
1231
|
+
if (
|
1232
|
+
current === "" ||
|
1233
|
+
current === undefined ||
|
1234
|
+
current === msg ||
|
1235
|
+
current === null
|
1236
|
+
) {
|
1237
|
+
if (selections.length === 0) {
|
1238
|
+
this.setOption("messages.control", msg);
|
1239
|
+
} else {
|
1240
|
+
this.setOption("messages.control", "");
|
1241
|
+
}
|
1242
|
+
}
|
1246
1243
|
}
|
1247
1244
|
|
1248
1245
|
/**
|
@@ -1250,9 +1247,9 @@ function setSummaryAndControlText() {
|
|
1250
1247
|
* @return {NodeList}
|
1251
1248
|
*/
|
1252
1249
|
function getOptionElements() {
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1250
|
+
return this[optionsElementSymbol].querySelectorAll(
|
1251
|
+
`[${ATTRIBUTE_ROLE}=option]`,
|
1252
|
+
);
|
1256
1253
|
}
|
1257
1254
|
|
1258
1255
|
/**
|
@@ -1276,75 +1273,75 @@ function getOptionElements() {
|
|
1276
1273
|
* @private
|
1277
1274
|
*/
|
1278
1275
|
function calcAndSetOptionsDimension() {
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1276
|
+
const options = getOptionElements.call(this);
|
1277
|
+
const container = this[optionsElementSymbol];
|
1278
|
+
if (!(container instanceof HTMLElement && options instanceof NodeList)) {
|
1279
|
+
return;
|
1280
|
+
}
|
1281
|
+
|
1282
|
+
let visible = 0;
|
1283
|
+
let optionHeight = 0;
|
1284
|
+
const max = this.getOption("showMaxOptions", 10);
|
1285
|
+
|
1286
|
+
let scrollFlag = false;
|
1287
|
+
for (const [, option] of Object.entries(options)) {
|
1288
|
+
const computedStyle = getGlobal().getComputedStyle(option);
|
1289
|
+
if (computedStyle.display === "none") continue;
|
1290
|
+
|
1291
|
+
let h = option.getBoundingClientRect().height;
|
1292
|
+
h += parseInt(computedStyle.getPropertyValue("margin-top"), 10);
|
1293
|
+
h += parseInt(computedStyle.getPropertyValue("margin-bottom"), 10);
|
1294
|
+
optionHeight += h;
|
1295
|
+
|
1296
|
+
visible++;
|
1297
|
+
|
1298
|
+
if (visible > max) {
|
1299
|
+
break;
|
1300
|
+
}
|
1301
|
+
}
|
1302
|
+
|
1303
|
+
if (visible > max) {
|
1304
|
+
visible = max;
|
1305
|
+
scrollFlag = true;
|
1306
|
+
}
|
1307
|
+
|
1308
|
+
if (visible === 0) {
|
1309
|
+
if (getFilterMode.call(this) === FILTER_MODE_DISABLED) {
|
1310
|
+
this.setOption(
|
1311
|
+
"messages.emptyOptions",
|
1312
|
+
this.getOption("labels.no-options-available"),
|
1313
|
+
);
|
1314
|
+
} else {
|
1315
|
+
this.setOption(
|
1316
|
+
"messages.emptyOptions",
|
1317
|
+
this.getOption("labels.no-options-found"),
|
1318
|
+
);
|
1319
|
+
}
|
1320
|
+
this[noOptionsAvailableElementSymbol].classList.remove("d-none");
|
1321
|
+
} else {
|
1322
|
+
this[noOptionsAvailableElementSymbol].classList.add("d-none");
|
1323
|
+
}
|
1324
|
+
|
1325
|
+
const styles = getGlobal().getComputedStyle(this[optionsElementSymbol]);
|
1326
|
+
let padding = parseInt(styles.getPropertyValue("padding-top"), 10);
|
1327
|
+
padding += parseInt(styles.getPropertyValue("padding-bottom"), 10);
|
1328
|
+
|
1329
|
+
let margin = parseInt(styles.getPropertyValue("margin-top"), 10);
|
1330
|
+
margin += parseInt(styles.getPropertyValue("margin-bottom"), 10);
|
1331
|
+
|
1332
|
+
const containerHeight = optionHeight + padding + margin;
|
1333
|
+
container.style.height = `${containerHeight}px`;
|
1334
|
+
|
1335
|
+
if (scrollFlag === true) {
|
1336
|
+
container.style.overflowY = "scroll";
|
1337
|
+
} else {
|
1338
|
+
container.style.overflowY = "auto";
|
1339
|
+
}
|
1340
|
+
|
1341
|
+
const domRect = this[controlElementSymbol].getBoundingClientRect();
|
1342
|
+
|
1343
|
+
this[popperElementSymbol].style.width = `${domRect.width}px`;
|
1344
|
+
container.style.overflowX = "auto";
|
1348
1345
|
}
|
1349
1346
|
|
1350
1347
|
/**
|
@@ -1353,126 +1350,126 @@ function calcAndSetOptionsDimension() {
|
|
1353
1350
|
* @throws {Error} no shadow-root is defined
|
1354
1351
|
*/
|
1355
1352
|
function activateCurrentOption(direction) {
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1353
|
+
if (!this.shadowRoot) {
|
1354
|
+
throw new Error("no shadow-root is defined");
|
1355
|
+
}
|
1356
|
+
|
1357
|
+
let focused = this.shadowRoot.querySelector(`[${ATTRIBUTE_PREFIX}focused]`);
|
1358
|
+
|
1359
|
+
if (
|
1360
|
+
!(focused instanceof HTMLElement) ||
|
1361
|
+
focused.matches("[data-monster-visibility=hidden]")
|
1362
|
+
) {
|
1363
|
+
for (const [, e] of Object.entries(
|
1364
|
+
this.shadowRoot.querySelectorAll(`[${ATTRIBUTE_ROLE}=option]`),
|
1365
|
+
)) {
|
1366
|
+
if (e.matches("[data-monster-visibility=visible]")) {
|
1367
|
+
focused = e;
|
1368
|
+
break;
|
1369
|
+
}
|
1370
|
+
}
|
1371
|
+
} else {
|
1372
|
+
if (direction === FOCUS_DIRECTION_DOWN) {
|
1373
|
+
while (focused.nextSibling) {
|
1374
|
+
focused = focused.nextSibling;
|
1375
|
+
|
1376
|
+
if (
|
1377
|
+
focused instanceof HTMLElement &&
|
1378
|
+
focused.hasAttribute(ATTRIBUTE_ROLE) &&
|
1379
|
+
focused.getAttribute(ATTRIBUTE_ROLE) === "option" &&
|
1380
|
+
focused.matches("[data-monster-visibility=visible]") &&
|
1381
|
+
focused.matches(":not([data-monster-filtered=true])")
|
1382
|
+
) {
|
1383
|
+
break;
|
1384
|
+
}
|
1385
|
+
}
|
1386
|
+
} else {
|
1387
|
+
let found = false;
|
1388
|
+
while (focused.previousSibling) {
|
1389
|
+
focused = focused.previousSibling;
|
1390
|
+
if (
|
1391
|
+
focused instanceof HTMLElement &&
|
1392
|
+
focused.hasAttribute(ATTRIBUTE_ROLE) &&
|
1393
|
+
focused.getAttribute(ATTRIBUTE_ROLE) === "option" &&
|
1394
|
+
focused.matches("[data-monster-visibility=visible]") &&
|
1395
|
+
focused.matches(":not([data-monster-filtered=true])")
|
1396
|
+
) {
|
1397
|
+
found = true;
|
1398
|
+
break;
|
1399
|
+
}
|
1400
|
+
}
|
1401
|
+
if (found === false) {
|
1402
|
+
focusFilter.call(this);
|
1403
|
+
}
|
1404
|
+
}
|
1405
|
+
}
|
1406
|
+
|
1407
|
+
new Processing(() => {
|
1408
|
+
if (focused instanceof HTMLElement) {
|
1409
|
+
this.shadowRoot
|
1410
|
+
.querySelectorAll(`[${ATTRIBUTE_PREFIX}focused]`)
|
1411
|
+
.forEach((e) => {
|
1412
|
+
e.removeAttribute(`${ATTRIBUTE_PREFIX}focused`);
|
1413
|
+
});
|
1414
|
+
|
1415
|
+
focused.focus();
|
1416
|
+
focused.setAttribute(`${ATTRIBUTE_PREFIX}focused`, true);
|
1417
|
+
}
|
1418
|
+
})
|
1419
|
+
.run()
|
1420
|
+
.catch((e) => {
|
1421
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
|
1422
|
+
});
|
1426
1423
|
}
|
1427
1424
|
|
1428
1425
|
/**
|
1429
1426
|
* @private
|
1430
1427
|
*/
|
1431
1428
|
function filterOptions() {
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1429
|
+
new Processing(() => {
|
1430
|
+
let filterValue;
|
1431
|
+
|
1432
|
+
switch (this.getOption("filter.position")) {
|
1433
|
+
case FILTER_POSITION_INLINE:
|
1434
|
+
if (this[inlineFilterElementSymbol] instanceof HTMLElement) {
|
1435
|
+
filterValue = this[inlineFilterElementSymbol].value.toLowerCase();
|
1436
|
+
} else {
|
1437
|
+
return;
|
1438
|
+
}
|
1439
|
+
|
1440
|
+
break;
|
1441
|
+
case FILTER_POSITION_POPPER:
|
1442
|
+
default:
|
1443
|
+
if (this[popperFilterElementSymbol] instanceof HTMLInputElement) {
|
1444
|
+
filterValue = this[popperFilterElementSymbol].value.toLowerCase();
|
1445
|
+
} else {
|
1446
|
+
return;
|
1447
|
+
}
|
1448
|
+
}
|
1449
|
+
|
1450
|
+
const options = this.getOption("options");
|
1451
|
+
for (const [i, option] of Object.entries(options)) {
|
1452
|
+
if (option.label.toLowerCase().indexOf(filterValue) === -1) {
|
1453
|
+
this.setOption(`options.${i}.filtered`, "true");
|
1454
|
+
} else {
|
1455
|
+
this.setOption(`options.${i}.filtered`, undefined);
|
1456
|
+
}
|
1457
|
+
}
|
1458
|
+
})
|
1459
|
+
.run()
|
1460
|
+
.then(() => {
|
1461
|
+
new Processing(100, () => {
|
1462
|
+
calcAndSetOptionsDimension.call(this);
|
1463
|
+
focusFilter.call(this);
|
1464
|
+
})
|
1465
|
+
.run()
|
1466
|
+
.catch((e) => {
|
1467
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
|
1468
|
+
});
|
1469
|
+
})
|
1470
|
+
.catch((e) => {
|
1471
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
|
1472
|
+
});
|
1476
1473
|
}
|
1477
1474
|
|
1478
1475
|
/**
|
@@ -1480,37 +1477,37 @@ function filterOptions() {
|
|
1480
1477
|
* @param {Event} event
|
1481
1478
|
*/
|
1482
1479
|
function handleFilterKeyboardEvents(event) {
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1480
|
+
const shiftKey = event?.["shiftKey"];
|
1481
|
+
|
1482
|
+
switch (event?.["code"]) {
|
1483
|
+
case "Tab":
|
1484
|
+
activateCurrentOption.call(this, FOCUS_DIRECTION_DOWN);
|
1485
|
+
event.preventDefault();
|
1486
|
+
break;
|
1487
|
+
case "Escape":
|
1488
|
+
toggle.call(this);
|
1489
|
+
event.preventDefault();
|
1490
|
+
break;
|
1491
|
+
case "Tab" && shiftKey === true:
|
1492
|
+
case "ArrowUp":
|
1493
|
+
activateCurrentOption.call(this, FOCUS_DIRECTION_UP);
|
1494
|
+
event.preventDefault();
|
1495
|
+
break;
|
1496
|
+
case "Tab" && !shiftKey:
|
1497
|
+
case "ArrowDown":
|
1498
|
+
activateCurrentOption.call(this, FOCUS_DIRECTION_DOWN);
|
1499
|
+
event.preventDefault();
|
1500
|
+
break;
|
1501
|
+
default:
|
1502
|
+
if (
|
1503
|
+
this.getOption("features.lazyLoad") === true &&
|
1504
|
+
this[lazyLoadDoneSymbol] !== true
|
1505
|
+
) {
|
1506
|
+
this.click();
|
1507
|
+
}
|
1508
|
+
|
1509
|
+
handleFilterKeyEvents.call(this);
|
1510
|
+
}
|
1514
1511
|
}
|
1515
1512
|
|
1516
1513
|
/**
|
@@ -1524,90 +1521,90 @@ function handleFilterKeyboardEvents(event) {
|
|
1524
1521
|
* @return {void} This method does not return anything.
|
1525
1522
|
*/
|
1526
1523
|
function handleFilterKeyEvents() {
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1524
|
+
if (this[keyFilterEventSymbol] instanceof DeadMansSwitch) {
|
1525
|
+
try {
|
1526
|
+
this[keyFilterEventSymbol].touch();
|
1527
|
+
return;
|
1528
|
+
} catch (e) {
|
1529
|
+
delete this[keyFilterEventSymbol];
|
1530
|
+
}
|
1531
|
+
}
|
1532
|
+
|
1533
|
+
this[keyFilterEventSymbol] = new DeadMansSwitch(200, () => {
|
1534
|
+
if (getFilterMode.call(this) !== FILTER_MODE_REMOTE) {
|
1535
|
+
filterOptions.call(this);
|
1536
|
+
} else {
|
1537
|
+
filterFromRemote.call(this).catch((e) => {
|
1538
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
|
1539
|
+
});
|
1540
|
+
}
|
1541
|
+
|
1542
|
+
delete this[keyFilterEventSymbol];
|
1543
|
+
});
|
1547
1544
|
}
|
1548
1545
|
|
1549
1546
|
/**
|
1550
1547
|
* @private
|
1551
1548
|
*/
|
1552
1549
|
function filterFromRemote() {
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1550
|
+
if (
|
1551
|
+
!(this[inlineFilterElementSymbol] instanceof HTMLElement) &&
|
1552
|
+
!(this[popperFilterElementSymbol] instanceof HTMLElement)
|
1553
|
+
) {
|
1554
|
+
return;
|
1555
|
+
}
|
1556
|
+
|
1557
|
+
show.call(this);
|
1558
|
+
|
1559
|
+
const url = this.getOption("url");
|
1560
|
+
if (!url) {
|
1561
|
+
addAttributeToken(
|
1562
|
+
this,
|
1563
|
+
ATTRIBUTE_ERRORMESSAGE,
|
1564
|
+
"Missing URL for Remote Filter.",
|
1565
|
+
);
|
1566
|
+
return;
|
1567
|
+
}
|
1568
|
+
|
1569
|
+
let filterValue;
|
1570
|
+
|
1571
|
+
switch (this.getOption("filter.position")) {
|
1572
|
+
case FILTER_POSITION_INLINE:
|
1573
|
+
if (this[inlineFilterElementSymbol] instanceof HTMLElement) {
|
1574
|
+
filterValue = this[inlineFilterElementSymbol].value.toLowerCase();
|
1575
|
+
}
|
1576
|
+
|
1577
|
+
break;
|
1578
|
+
case FILTER_POSITION_POPPER:
|
1579
|
+
default:
|
1580
|
+
if (this[popperFilterElementSymbol] instanceof HTMLInputElement) {
|
1581
|
+
filterValue = this[popperFilterElementSymbol].value.toLowerCase();
|
1582
|
+
}
|
1583
|
+
}
|
1584
|
+
|
1585
|
+
return filterFromRemoteByValue.call(this, url, filterValue);
|
1589
1586
|
}
|
1590
1587
|
|
1591
1588
|
function formatURL(url, value) {
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1589
|
+
if (value === undefined || value === null || value === "") {
|
1590
|
+
value = this.getOption("filter.defaultValue");
|
1591
|
+
if (value === undefined || value === null || value === "") {
|
1592
|
+
value = disabledRequestMarker.toString();
|
1593
|
+
}
|
1594
|
+
}
|
1595
|
+
|
1596
|
+
const formatter = new Formatter({ filter: encodeURI(value) });
|
1597
|
+
const openMarker = this.getOption("filter.marker.open");
|
1598
|
+
let closeMarker = this.getOption("filter.marker.close");
|
1599
|
+
if (!closeMarker) {
|
1600
|
+
closeMarker = openMarker;
|
1601
|
+
}
|
1602
|
+
|
1603
|
+
if (openMarker && closeMarker) {
|
1604
|
+
formatter.setMarker(openMarker, closeMarker);
|
1605
|
+
}
|
1606
|
+
|
1607
|
+
return formatter.format(url);
|
1611
1608
|
}
|
1612
1609
|
|
1613
1610
|
/**
|
@@ -1617,28 +1614,28 @@ function formatURL(url, value) {
|
|
1617
1614
|
* @returns {Promise<unknown>}
|
1618
1615
|
*/
|
1619
1616
|
function filterFromRemoteByValue(optionUrl, value) {
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1617
|
+
return new Processing(() => {
|
1618
|
+
let url = formatURL.call(this, optionUrl, value);
|
1619
|
+
if (url.indexOf(disabledRequestMarker.toString()) !== -1) {
|
1620
|
+
return;
|
1621
|
+
}
|
1622
|
+
|
1623
|
+
fetchIt
|
1624
|
+
.call(this, url, {
|
1625
|
+
disableHiding: true,
|
1626
|
+
})
|
1627
|
+
.then(() => {
|
1628
|
+
checkOptionState.call(this);
|
1629
|
+
show.call(this);
|
1630
|
+
})
|
1631
|
+
.catch((e) => {
|
1632
|
+
throw e;
|
1633
|
+
});
|
1634
|
+
})
|
1635
|
+
.run()
|
1636
|
+
.catch((e) => {
|
1637
|
+
throw e;
|
1638
|
+
});
|
1642
1639
|
}
|
1643
1640
|
|
1644
1641
|
/**
|
@@ -1646,50 +1643,50 @@ function filterFromRemoteByValue(optionUrl, value) {
|
|
1646
1643
|
* @private
|
1647
1644
|
*/
|
1648
1645
|
function handleOptionKeyboardEvents(event) {
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1646
|
+
const shiftKey = event?.["shiftKey"];
|
1647
|
+
|
1648
|
+
switch (event?.["code"]) {
|
1649
|
+
case "Escape":
|
1650
|
+
toggle.call(this);
|
1651
|
+
event.preventDefault();
|
1652
|
+
break;
|
1653
|
+
case "Enter":
|
1654
|
+
case "Space":
|
1655
|
+
const path = event.composedPath();
|
1656
|
+
const element = path?.[0];
|
1657
|
+
if (element instanceof HTMLElement) {
|
1658
|
+
const input = element.getElementsByTagName("input");
|
1659
|
+
if (!input) {
|
1660
|
+
return;
|
1661
|
+
}
|
1662
|
+
fireEvent(input, "click");
|
1663
|
+
}
|
1664
|
+
event.preventDefault();
|
1665
|
+
break;
|
1666
|
+
|
1667
|
+
case "Tab" && shiftKey === true:
|
1668
|
+
case "ArrowUp":
|
1669
|
+
activateCurrentOption.call(this, FOCUS_DIRECTION_UP);
|
1670
|
+
event.preventDefault();
|
1671
|
+
break;
|
1672
|
+
|
1673
|
+
case "Tab" && !shiftKey:
|
1674
|
+
case "ArrowLeft":
|
1675
|
+
case "ArrowRight":
|
1676
|
+
// handled by tree select
|
1677
|
+
break;
|
1678
|
+
case "ArrowDown":
|
1679
|
+
activateCurrentOption.call(this, FOCUS_DIRECTION_DOWN);
|
1680
|
+
event.preventDefault();
|
1681
|
+
break;
|
1682
|
+
default:
|
1683
|
+
const p = event.composedPath();
|
1684
|
+
if (p?.[0] instanceof HTMLInputElement) {
|
1685
|
+
return;
|
1686
|
+
}
|
1687
|
+
focusFilter.call(this);
|
1688
|
+
break;
|
1689
|
+
}
|
1693
1690
|
}
|
1694
1691
|
|
1695
1692
|
/**
|
@@ -1697,33 +1694,33 @@ function handleOptionKeyboardEvents(event) {
|
|
1697
1694
|
* @return {string}
|
1698
1695
|
*/
|
1699
1696
|
function getFilterMode() {
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1697
|
+
switch (this.getOption("filter.mode")) {
|
1698
|
+
case FILTER_MODE_OPTIONS:
|
1699
|
+
return FILTER_MODE_OPTIONS;
|
1700
|
+
case FILTER_MODE_REMOTE:
|
1701
|
+
return FILTER_MODE_REMOTE;
|
1702
|
+
default:
|
1703
|
+
return FILTER_MODE_DISABLED;
|
1704
|
+
}
|
1708
1705
|
}
|
1709
1706
|
|
1710
1707
|
/**
|
1711
1708
|
* @private
|
1712
1709
|
*/
|
1713
1710
|
function blurFilter() {
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1711
|
+
if (!(this[inlineFilterElementSymbol] instanceof HTMLElement)) {
|
1712
|
+
return;
|
1713
|
+
}
|
1717
1714
|
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1715
|
+
if (getFilterMode.call(this) === FILTER_MODE_DISABLED) {
|
1716
|
+
return;
|
1717
|
+
}
|
1721
1718
|
|
1722
|
-
|
1723
|
-
|
1719
|
+
this[popperFilterContainerElementSymbol].classList.remove("active");
|
1720
|
+
this[popperFilterContainerElementSymbol].blur();
|
1724
1721
|
|
1725
|
-
|
1726
|
-
|
1722
|
+
this[inlineFilterElementSymbol].classList.remove("active");
|
1723
|
+
this[inlineFilterElementSymbol].blur();
|
1727
1724
|
}
|
1728
1725
|
|
1729
1726
|
/**
|
@@ -1731,29 +1728,29 @@ function blurFilter() {
|
|
1731
1728
|
* @param focusOptions
|
1732
1729
|
*/
|
1733
1730
|
function focusPopperFilter(focusOptions) {
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1731
|
+
this[popperFilterContainerElementSymbol].classList.remove("d-none");
|
1732
|
+
this[popperFilterElementSymbol].classList.add("active");
|
1733
|
+
this[inlineFilterElementSymbol].classList.remove("active");
|
1734
|
+
this[inlineFilterElementSymbol].classList.add("d-none");
|
1735
|
+
|
1736
|
+
if (!(this[popperFilterElementSymbol] instanceof HTMLElement)) {
|
1737
|
+
addAttributeToken(
|
1738
|
+
this,
|
1739
|
+
ATTRIBUTE_ERRORMESSAGE,
|
1740
|
+
"Missing Popper Filter Element.",
|
1741
|
+
);
|
1742
|
+
return;
|
1743
|
+
}
|
1744
|
+
|
1745
|
+
// visibility is set to visible, because focus() does not work on invisible elements
|
1746
|
+
// and the class definition is assigned later in the processing
|
1747
|
+
setTimeout(() => {
|
1748
|
+
if (focusOptions === undefined || focusOptions === null) {
|
1749
|
+
this[popperFilterElementSymbol].focus();
|
1750
|
+
} else {
|
1751
|
+
this[popperFilterElementSymbol].focus(focusOptions);
|
1752
|
+
}
|
1753
|
+
}, 100);
|
1757
1754
|
}
|
1758
1755
|
|
1759
1756
|
/**
|
@@ -1761,44 +1758,44 @@ function focusPopperFilter(focusOptions) {
|
|
1761
1758
|
* @param focusOptions
|
1762
1759
|
*/
|
1763
1760
|
function focusInlineFilter(focusOptions) {
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1761
|
+
const options = this.getOption("options");
|
1762
|
+
if (
|
1763
|
+
(!isArray(options) || options.length === 0) &&
|
1764
|
+
getFilterMode.call(this) !== FILTER_MODE_REMOTE
|
1765
|
+
) {
|
1766
|
+
return;
|
1767
|
+
}
|
1768
|
+
|
1769
|
+
this[popperFilterContainerElementSymbol].classList.add("d-none");
|
1770
|
+
this[inlineFilterElementSymbol].classList.add("active");
|
1771
|
+
this[inlineFilterElementSymbol].classList.remove("d-none");
|
1772
|
+
|
1773
|
+
// visibility is set to visible, because focus() does not work on invisible elements
|
1774
|
+
// and the class definition is assigned later in the processing
|
1775
|
+
setTimeout(() => {
|
1776
|
+
if (focusOptions === undefined || focusOptions === null) {
|
1777
|
+
this[inlineFilterElementSymbol].focus();
|
1778
|
+
} else {
|
1779
|
+
this[inlineFilterElementSymbol].focus(focusOptions);
|
1780
|
+
}
|
1781
|
+
}, 100);
|
1785
1782
|
}
|
1786
1783
|
|
1787
1784
|
/**
|
1788
1785
|
* @private
|
1789
1786
|
*/
|
1790
1787
|
function focusFilter(focusOptions) {
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1788
|
+
if (getFilterMode.call(this) === FILTER_MODE_DISABLED) {
|
1789
|
+
this[popperFilterContainerElementSymbol].classList.add("d-none");
|
1790
|
+
this[inlineFilterElementSymbol].classList.add("d-none");
|
1791
|
+
return;
|
1792
|
+
}
|
1796
1793
|
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1794
|
+
if (this.getOption("filter.position") === FILTER_POSITION_INLINE) {
|
1795
|
+
return focusInlineFilter.call(this, focusOptions);
|
1796
|
+
}
|
1800
1797
|
|
1801
|
-
|
1798
|
+
return focusPopperFilter.call(this, focusOptions);
|
1802
1799
|
}
|
1803
1800
|
|
1804
1801
|
/**
|
@@ -1808,40 +1805,39 @@ function focusFilter(focusOptions) {
|
|
1808
1805
|
* @throws {Error} unsupported type
|
1809
1806
|
*/
|
1810
1807
|
function gatherState() {
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
return this;
|
1808
|
+
const type = this.getOption("type");
|
1809
|
+
if (["radio", "checkbox"].indexOf(type) === -1) {
|
1810
|
+
throw new Error("unsupported type");
|
1811
|
+
}
|
1812
|
+
|
1813
|
+
if (!this.shadowRoot) {
|
1814
|
+
throw new Error("no shadow-root is defined");
|
1815
|
+
}
|
1816
|
+
|
1817
|
+
const selection = [];
|
1818
|
+
const elements = this.shadowRoot.querySelectorAll(
|
1819
|
+
`input[type=${type}]:checked`,
|
1820
|
+
);
|
1821
|
+
|
1822
|
+
for (const e of elements) {
|
1823
|
+
selection.push({
|
1824
|
+
label: getSelectionLabel.call(this, e.value),
|
1825
|
+
value: e.value,
|
1826
|
+
});
|
1827
|
+
}
|
1828
|
+
|
1829
|
+
setSelection
|
1830
|
+
.call(this, selection)
|
1831
|
+
.then(() => {})
|
1832
|
+
.catch((e) => {
|
1833
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, `${e}`);
|
1834
|
+
});
|
1835
|
+
|
1836
|
+
if (this.getOption("features.closeOnSelect") === true) {
|
1837
|
+
toggle.call(this);
|
1838
|
+
}
|
1839
|
+
|
1840
|
+
return this;
|
1845
1841
|
}
|
1846
1842
|
|
1847
1843
|
/**
|
@@ -1850,121 +1846,120 @@ function gatherState() {
|
|
1850
1846
|
* @throws {Error} unsupported type
|
1851
1847
|
*/
|
1852
1848
|
function clearSelection() {
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
});
|
1849
|
+
const type = this.getOption("type");
|
1850
|
+
if (["radio", "checkbox"].indexOf(type) === -1) {
|
1851
|
+
throw new Error("unsupported type");
|
1852
|
+
}
|
1853
|
+
|
1854
|
+
if (!this.shadowRoot) {
|
1855
|
+
throw new Error("no shadow-root is defined");
|
1856
|
+
}
|
1857
|
+
|
1858
|
+
setSelection
|
1859
|
+
.call(this, [])
|
1860
|
+
.then(() => {})
|
1861
|
+
.catch((e) => {
|
1862
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, `${e}`);
|
1863
|
+
});
|
1869
1864
|
}
|
1870
1865
|
|
1871
1866
|
/**
|
1872
1867
|
* @private
|
1873
1868
|
*/
|
1874
1869
|
function areOptionsAvailableAndInit() {
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1892
|
-
|
1893
|
-
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1955
|
-
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1870
|
+
// prevent multiple calls
|
1871
|
+
if (this[areOptionsAvailableAndInitSymbol] === undefined) {
|
1872
|
+
this[areOptionsAvailableAndInitSymbol] = 0;
|
1873
|
+
}
|
1874
|
+
|
1875
|
+
if (this[areOptionsAvailableAndInitSymbol] > 0) {
|
1876
|
+
this[areOptionsAvailableAndInitSymbol]--;
|
1877
|
+
return true;
|
1878
|
+
}
|
1879
|
+
|
1880
|
+
this[areOptionsAvailableAndInitSymbol]++;
|
1881
|
+
|
1882
|
+
const options = this.getOption("options");
|
1883
|
+
|
1884
|
+
if (
|
1885
|
+
options === undefined ||
|
1886
|
+
options === null ||
|
1887
|
+
(isArray(options) && options.length === 0)
|
1888
|
+
) {
|
1889
|
+
setStatusOrRemoveBadges.call(this, "empty");
|
1890
|
+
|
1891
|
+
// hide.call(this);
|
1892
|
+
|
1893
|
+
let msg = this.getOption("labels.no-options-available");
|
1894
|
+
|
1895
|
+
if (
|
1896
|
+
this.getOption("url") !== null &&
|
1897
|
+
this.getOption("features.lazyLoad") === true &&
|
1898
|
+
this[lazyLoadDoneSymbol] !== true
|
1899
|
+
) {
|
1900
|
+
msg = this.getOption("labels.click-to-load-options");
|
1901
|
+
}
|
1902
|
+
|
1903
|
+
this.setOption("messages.control", msg);
|
1904
|
+
this.setOption("messages.summary", "");
|
1905
|
+
|
1906
|
+
if (this.getOption("features.emptyValueIfNoOptions") === true) {
|
1907
|
+
this.value = "";
|
1908
|
+
}
|
1909
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, noOptionsAvailableMessage);
|
1910
|
+
return false;
|
1911
|
+
}
|
1912
|
+
|
1913
|
+
const selections = this.getOption("selection");
|
1914
|
+
if (
|
1915
|
+
selections === undefined ||
|
1916
|
+
selections === null ||
|
1917
|
+
selections.length === 0
|
1918
|
+
) {
|
1919
|
+
this.setOption(
|
1920
|
+
"messages.control",
|
1921
|
+
this.getOption("labels.select-an-option"),
|
1922
|
+
);
|
1923
|
+
} else {
|
1924
|
+
this.setOption("messages.control", "");
|
1925
|
+
}
|
1926
|
+
|
1927
|
+
this.setOption("messages.summary", setSummaryAndControlText.call(this));
|
1928
|
+
|
1929
|
+
let updated = false;
|
1930
|
+
let valueCounter = 1;
|
1931
|
+
for (const option of options) {
|
1932
|
+
if (option?.visibility === undefined) {
|
1933
|
+
option.visibility = "visible";
|
1934
|
+
updated = true;
|
1935
|
+
}
|
1936
|
+
|
1937
|
+
if (option?.value === undefined && option?.label === undefined) {
|
1938
|
+
option.value = `${valueCounter++}`;
|
1939
|
+
option.label = option.value;
|
1940
|
+
updated = true;
|
1941
|
+
continue;
|
1942
|
+
}
|
1943
|
+
|
1944
|
+
if (option?.value === undefined) {
|
1945
|
+
option.value = option.label;
|
1946
|
+
updated = true;
|
1947
|
+
}
|
1948
|
+
|
1949
|
+
if (option?.label === undefined) {
|
1950
|
+
option.label = option.value;
|
1951
|
+
updated = true;
|
1952
|
+
}
|
1953
|
+
}
|
1954
|
+
|
1955
|
+
if (updated) {
|
1956
|
+
this.setOption("options", options);
|
1957
|
+
}
|
1958
|
+
|
1959
|
+
setStatusOrRemoveBadges.call(this);
|
1960
|
+
|
1961
|
+
removeAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, noOptionsAvailableMessage);
|
1962
|
+
return true;
|
1968
1963
|
}
|
1969
1964
|
|
1970
1965
|
/**
|
@@ -1972,30 +1967,30 @@ function areOptionsAvailableAndInit() {
|
|
1972
1967
|
* @throws {Error} no shadow-root is defined
|
1973
1968
|
*/
|
1974
1969
|
function checkOptionState() {
|
1975
|
-
|
1976
|
-
|
1977
|
-
|
1978
|
-
|
1979
|
-
|
1980
|
-
|
1981
|
-
|
1982
|
-
|
1983
|
-
|
1984
|
-
|
1985
|
-
|
1986
|
-
|
1987
|
-
|
1988
|
-
|
1989
|
-
|
1990
|
-
|
1991
|
-
|
1992
|
-
|
1993
|
-
|
1994
|
-
|
1995
|
-
|
1996
|
-
|
1997
|
-
|
1998
|
-
|
1970
|
+
if (!this.shadowRoot) {
|
1971
|
+
throw new Error("no shadow-root is defined");
|
1972
|
+
}
|
1973
|
+
|
1974
|
+
const elements = this.shadowRoot.querySelectorAll(
|
1975
|
+
`[${ATTRIBUTE_ROLE}=option] input`,
|
1976
|
+
);
|
1977
|
+
|
1978
|
+
let selection = this.getOption("selection");
|
1979
|
+
if (!isArray(selection)) {
|
1980
|
+
selection = [];
|
1981
|
+
}
|
1982
|
+
|
1983
|
+
const checkedValues = selection.map((a) => {
|
1984
|
+
return a.value;
|
1985
|
+
});
|
1986
|
+
|
1987
|
+
for (const e of elements) {
|
1988
|
+
if (checkedValues.indexOf(e.value) !== -1) {
|
1989
|
+
if (e.checked !== true) e.checked = true;
|
1990
|
+
} else {
|
1991
|
+
if (e.checked !== false) e.checked = false;
|
1992
|
+
}
|
1993
|
+
}
|
1999
1994
|
}
|
2000
1995
|
|
2001
1996
|
/**
|
@@ -2004,41 +1999,41 @@ function checkOptionState() {
|
|
2004
1999
|
* @return {Object}
|
2005
2000
|
*/
|
2006
2001
|
function convertValueToSelection(value) {
|
2007
|
-
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2018
|
-
|
2019
|
-
|
2020
|
-
|
2021
|
-
|
2022
|
-
|
2023
|
-
|
2024
|
-
|
2025
|
-
|
2026
|
-
|
2027
|
-
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2031
|
-
|
2032
|
-
|
2033
|
-
|
2034
|
-
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2002
|
+
const selection = [];
|
2003
|
+
|
2004
|
+
if (isString(value)) {
|
2005
|
+
value = value
|
2006
|
+
.split(",")
|
2007
|
+
.map((a) => {
|
2008
|
+
return a.trim();
|
2009
|
+
})
|
2010
|
+
.filter((a) => {
|
2011
|
+
return a !== "";
|
2012
|
+
});
|
2013
|
+
}
|
2014
|
+
|
2015
|
+
if (isString(value) || isInteger(value)) {
|
2016
|
+
selection.push({
|
2017
|
+
label: getSelectionLabel.call(this, value),
|
2018
|
+
value: value,
|
2019
|
+
});
|
2020
|
+
} else if (isArray(value)) {
|
2021
|
+
for (const v of value) {
|
2022
|
+
selection.push({
|
2023
|
+
label: getSelectionLabel.call(this, v),
|
2024
|
+
value: v,
|
2025
|
+
});
|
2026
|
+
}
|
2027
|
+
|
2028
|
+
value = value.join(",");
|
2029
|
+
} else {
|
2030
|
+
throw new Error("unsupported type");
|
2031
|
+
}
|
2032
|
+
|
2033
|
+
return {
|
2034
|
+
selection: selection,
|
2035
|
+
value: value,
|
2036
|
+
};
|
2042
2037
|
}
|
2043
2038
|
|
2044
2039
|
/**
|
@@ -2047,25 +2042,25 @@ function convertValueToSelection(value) {
|
|
2047
2042
|
* @return {string}
|
2048
2043
|
*/
|
2049
2044
|
function convertSelectionToValue(selection) {
|
2050
|
-
|
2051
|
-
|
2052
|
-
|
2053
|
-
|
2054
|
-
|
2055
|
-
|
2056
|
-
|
2057
|
-
|
2058
|
-
|
2059
|
-
|
2060
|
-
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2045
|
+
const value = [];
|
2046
|
+
|
2047
|
+
if (isArray(selection)) {
|
2048
|
+
for (const obj of selection) {
|
2049
|
+
const v = obj?.["value"];
|
2050
|
+
if (v !== undefined) value.push(`${v}`);
|
2051
|
+
}
|
2052
|
+
}
|
2053
|
+
|
2054
|
+
if (value.length === 0) {
|
2055
|
+
return "";
|
2056
|
+
} else if (value.length === 1) {
|
2057
|
+
const v = value.pop();
|
2058
|
+
if (v === undefined) return "";
|
2059
|
+
if (v === null) return "";
|
2060
|
+
return `${v}`;
|
2061
|
+
}
|
2062
|
+
|
2063
|
+
return value.join(",");
|
2069
2064
|
}
|
2070
2065
|
|
2071
2066
|
/**
|
@@ -2075,76 +2070,76 @@ function convertSelectionToValue(selection) {
|
|
2075
2070
|
* @throws {Error} no shadow-root is defined
|
2076
2071
|
*/
|
2077
2072
|
function setSelection(selection) {
|
2078
|
-
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2085
|
-
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2098
|
-
|
2099
|
-
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
|
2105
|
-
|
2106
|
-
|
2107
|
-
|
2108
|
-
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2119
|
-
|
2120
|
-
|
2121
|
-
|
2122
|
-
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2139
|
-
|
2140
|
-
|
2141
|
-
|
2142
|
-
|
2143
|
-
|
2144
|
-
|
2145
|
-
|
2146
|
-
|
2147
|
-
|
2073
|
+
if (isString(selection) || isInteger(selection)) {
|
2074
|
+
const result = convertValueToSelection.call(this, selection);
|
2075
|
+
selection = result?.selection;
|
2076
|
+
} else if (selection === undefined || selection === null) {
|
2077
|
+
selection = [];
|
2078
|
+
}
|
2079
|
+
|
2080
|
+
validateArray(selection);
|
2081
|
+
|
2082
|
+
for (let i = 0; i < selection.length; i++) {
|
2083
|
+
let l = getSelectionLabel.call(this, selection[i].value);
|
2084
|
+
if (l === selection[i].value) {
|
2085
|
+
l = selection[i].label;
|
2086
|
+
}
|
2087
|
+
|
2088
|
+
selection[i] = {
|
2089
|
+
label: l,
|
2090
|
+
value: selection[i].value,
|
2091
|
+
};
|
2092
|
+
}
|
2093
|
+
|
2094
|
+
this.setOption("selection", selection);
|
2095
|
+
checkOptionState.call(this);
|
2096
|
+
setSummaryAndControlText.call(this);
|
2097
|
+
|
2098
|
+
try {
|
2099
|
+
this?.setFormValue(this.value);
|
2100
|
+
} catch (e) {
|
2101
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
|
2102
|
+
}
|
2103
|
+
|
2104
|
+
fireCustomEvent(this, "monster-selected", {
|
2105
|
+
selection,
|
2106
|
+
});
|
2107
|
+
|
2108
|
+
fireEvent(this, "change");
|
2109
|
+
|
2110
|
+
return new Processing(() => {
|
2111
|
+
const CLASSNAME = "selected";
|
2112
|
+
|
2113
|
+
if (!this.shadowRoot) {
|
2114
|
+
throw new Error("no shadow-root is defined");
|
2115
|
+
}
|
2116
|
+
|
2117
|
+
const notSelected = this.shadowRoot.querySelectorAll(":not(:checked)");
|
2118
|
+
|
2119
|
+
if (notSelected) {
|
2120
|
+
notSelected.forEach((node) => {
|
2121
|
+
const parent = node.closest(`[${ATTRIBUTE_ROLE}=option]`);
|
2122
|
+
if (parent) {
|
2123
|
+
parent.classList.remove(CLASSNAME);
|
2124
|
+
}
|
2125
|
+
});
|
2126
|
+
}
|
2127
|
+
|
2128
|
+
const selected = this.shadowRoot.querySelectorAll(":checked");
|
2129
|
+
|
2130
|
+
if (selected) {
|
2131
|
+
selected.forEach((node) => {
|
2132
|
+
const parent = node.closest(`[${ATTRIBUTE_ROLE}=option]`);
|
2133
|
+
if (parent) {
|
2134
|
+
parent.classList.add(CLASSNAME);
|
2135
|
+
}
|
2136
|
+
});
|
2137
|
+
}
|
2138
|
+
})
|
2139
|
+
.run()
|
2140
|
+
.catch((e) => {
|
2141
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
|
2142
|
+
});
|
2148
2143
|
}
|
2149
2144
|
|
2150
2145
|
/**
|
@@ -2155,139 +2150,139 @@ function setSelection(selection) {
|
|
2155
2150
|
* @throws {TypeError} unsupported response
|
2156
2151
|
*/
|
2157
2152
|
function fetchData(url) {
|
2158
|
-
|
2159
|
-
|
2160
|
-
|
2161
|
-
|
2162
|
-
|
2163
|
-
|
2164
|
-
|
2165
|
-
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
2170
|
-
|
2171
|
-
|
2172
|
-
|
2173
|
-
|
2174
|
-
|
2175
|
-
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2181
|
-
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2185
|
-
|
2186
|
-
|
2187
|
-
|
2188
|
-
|
2189
|
-
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
2193
|
-
|
2194
|
-
|
2195
|
-
|
2196
|
-
|
2197
|
-
|
2198
|
-
|
2199
|
-
|
2200
|
-
|
2153
|
+
const self = this;
|
2154
|
+
if (!url) url = this.getOption("url");
|
2155
|
+
if (!url) return Promise.resolve();
|
2156
|
+
|
2157
|
+
const fetchOptions = this.getOption("fetch", {});
|
2158
|
+
|
2159
|
+
let delayWatch = false;
|
2160
|
+
|
2161
|
+
// if fetch short time, do not show loading badge, because of flickering
|
2162
|
+
requestAnimationFrame(() => {
|
2163
|
+
if (delayWatch === true) return;
|
2164
|
+
setStatusOrRemoveBadges.call(this, "loading");
|
2165
|
+
delayWatch = true;
|
2166
|
+
});
|
2167
|
+
|
2168
|
+
url = formatURL.call(this, url);
|
2169
|
+
|
2170
|
+
self[isLoadingSymbol] = true;
|
2171
|
+
const global = getGlobal();
|
2172
|
+
return global
|
2173
|
+
.fetch(url, fetchOptions)
|
2174
|
+
.then((response) => {
|
2175
|
+
self[isLoadingSymbol] = false;
|
2176
|
+
delayWatch = true;
|
2177
|
+
const contentType = response.headers.get("content-type");
|
2178
|
+
if (contentType && contentType.indexOf("application/json") !== -1) {
|
2179
|
+
return response.text();
|
2180
|
+
}
|
2181
|
+
|
2182
|
+
throw new TypeError(`unsupported response ${contentType}`);
|
2183
|
+
})
|
2184
|
+
.then((text) => {
|
2185
|
+
try {
|
2186
|
+
return Promise.resolve(JSON.parse(String(text)));
|
2187
|
+
} catch (e) {
|
2188
|
+
throw new TypeError("the result cannot be parsed, check the URL");
|
2189
|
+
}
|
2190
|
+
})
|
2191
|
+
.catch((e) => {
|
2192
|
+
self[isLoadingSymbol] = false;
|
2193
|
+
delayWatch = true;
|
2194
|
+
throw e;
|
2195
|
+
});
|
2201
2196
|
}
|
2202
2197
|
|
2203
2198
|
/**
|
2204
2199
|
* @private
|
2205
2200
|
*/
|
2206
2201
|
function hide() {
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2202
|
+
this[popperElementSymbol].style.display = "none";
|
2203
|
+
setStatusOrRemoveBadges.call(this, "closed");
|
2204
|
+
removeAttributeToken(this[controlElementSymbol], "class", "open");
|
2210
2205
|
}
|
2211
2206
|
|
2212
2207
|
/**
|
2213
2208
|
* @private
|
2214
2209
|
*/
|
2215
2210
|
function show() {
|
2216
|
-
|
2217
|
-
|
2218
|
-
|
2219
|
-
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2224
|
-
|
2225
|
-
|
2226
|
-
|
2227
|
-
|
2228
|
-
|
2229
|
-
|
2230
|
-
|
2231
|
-
|
2232
|
-
|
2233
|
-
|
2234
|
-
|
2235
|
-
|
2236
|
-
|
2237
|
-
|
2238
|
-
|
2239
|
-
|
2240
|
-
|
2241
|
-
|
2242
|
-
|
2243
|
-
|
2244
|
-
|
2245
|
-
|
2246
|
-
|
2247
|
-
|
2248
|
-
|
2249
|
-
|
2250
|
-
|
2251
|
-
|
2252
|
-
|
2253
|
-
|
2254
|
-
|
2255
|
-
|
2256
|
-
|
2257
|
-
|
2258
|
-
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
2262
|
-
|
2263
|
-
|
2264
|
-
|
2265
|
-
|
2266
|
-
|
2267
|
-
|
2268
|
-
|
2269
|
-
|
2270
|
-
|
2271
|
-
|
2272
|
-
|
2273
|
-
|
2274
|
-
|
2275
|
-
|
2276
|
-
|
2277
|
-
|
2278
|
-
|
2279
|
-
|
2211
|
+
if (this.getOption("disabled", undefined) === true) {
|
2212
|
+
return;
|
2213
|
+
}
|
2214
|
+
|
2215
|
+
if (this[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
|
2216
|
+
return;
|
2217
|
+
}
|
2218
|
+
|
2219
|
+
focusFilter.call(this);
|
2220
|
+
|
2221
|
+
const lazyLoadFlag =
|
2222
|
+
this.getOption("features.lazyLoad") && this[lazyLoadDoneSymbol] !== true;
|
2223
|
+
|
2224
|
+
if (lazyLoadFlag === true) {
|
2225
|
+
this[lazyLoadDoneSymbol] = true;
|
2226
|
+
setStatusOrRemoveBadges.call(this, "loading");
|
2227
|
+
|
2228
|
+
new Processing(200, () => {
|
2229
|
+
this.fetch()
|
2230
|
+
.then(() => {
|
2231
|
+
checkOptionState.call(this);
|
2232
|
+
requestAnimationFrame(() => {
|
2233
|
+
show.call(this);
|
2234
|
+
});
|
2235
|
+
})
|
2236
|
+
.catch((e) => {
|
2237
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
|
2238
|
+
setStatusOrRemoveBadges.call(this, "error");
|
2239
|
+
});
|
2240
|
+
})
|
2241
|
+
.run()
|
2242
|
+
.catch((e) => {
|
2243
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
|
2244
|
+
setStatusOrRemoveBadges.call(this, "error");
|
2245
|
+
});
|
2246
|
+
|
2247
|
+
return;
|
2248
|
+
}
|
2249
|
+
|
2250
|
+
const hasPopperFilterFlag =
|
2251
|
+
this.getOption("filter.position") === FILTER_POSITION_POPPER &&
|
2252
|
+
getFilterMode.call(this) !== FILTER_MODE_DISABLED;
|
2253
|
+
|
2254
|
+
const options = getOptionElements.call(this);
|
2255
|
+
if (options.length === 0 && hasPopperFilterFlag === false) {
|
2256
|
+
return;
|
2257
|
+
}
|
2258
|
+
|
2259
|
+
this[popperElementSymbol].style.visibility = "hidden";
|
2260
|
+
this[popperElementSymbol].style.display = STYLE_DISPLAY_MODE_BLOCK;
|
2261
|
+
setStatusOrRemoveBadges.call(this, "open");
|
2262
|
+
|
2263
|
+
addAttributeToken(this[controlElementSymbol], "class", "open");
|
2264
|
+
|
2265
|
+
new Processing(() => {
|
2266
|
+
calcAndSetOptionsDimension.call(this);
|
2267
|
+
focusFilter.call(this);
|
2268
|
+
this[popperElementSymbol].style.removeProperty("visibility");
|
2269
|
+
updatePopper.call(this);
|
2270
|
+
})
|
2271
|
+
.run()
|
2272
|
+
.catch((e) => {
|
2273
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
|
2274
|
+
});
|
2280
2275
|
}
|
2281
2276
|
|
2282
2277
|
/**
|
2283
2278
|
* @private
|
2284
2279
|
*/
|
2285
2280
|
function toggle() {
|
2286
|
-
|
2287
|
-
|
2288
|
-
|
2289
|
-
|
2290
|
-
|
2281
|
+
if (this[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
|
2282
|
+
hide.call(this);
|
2283
|
+
} else {
|
2284
|
+
show.call(this);
|
2285
|
+
}
|
2291
2286
|
}
|
2292
2287
|
|
2293
2288
|
/**
|
@@ -2296,188 +2291,188 @@ function toggle() {
|
|
2296
2291
|
* @fires monster-selection-cleared
|
2297
2292
|
*/
|
2298
2293
|
function initEventHandler() {
|
2299
|
-
|
2300
|
-
|
2301
|
-
|
2302
|
-
|
2303
|
-
|
2304
|
-
|
2305
|
-
|
2306
|
-
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2323
|
-
|
2324
|
-
|
2325
|
-
|
2326
|
-
|
2327
|
-
|
2328
|
-
|
2329
|
-
|
2330
|
-
|
2331
|
-
|
2332
|
-
|
2333
|
-
|
2334
|
-
|
2335
|
-
|
2336
|
-
|
2337
|
-
|
2338
|
-
|
2339
|
-
|
2340
|
-
|
2341
|
-
|
2342
|
-
|
2343
|
-
|
2344
|
-
|
2345
|
-
|
2346
|
-
|
2347
|
-
|
2348
|
-
|
2349
|
-
|
2350
|
-
|
2351
|
-
|
2352
|
-
|
2353
|
-
|
2354
|
-
|
2355
|
-
|
2356
|
-
|
2357
|
-
|
2358
|
-
|
2359
|
-
|
2360
|
-
|
2361
|
-
|
2362
|
-
|
2363
|
-
|
2364
|
-
|
2365
|
-
|
2366
|
-
|
2367
|
-
|
2368
|
-
|
2369
|
-
|
2370
|
-
|
2371
|
-
|
2372
|
-
|
2373
|
-
|
2374
|
-
|
2375
|
-
|
2376
|
-
|
2377
|
-
|
2378
|
-
|
2379
|
-
|
2380
|
-
|
2381
|
-
|
2382
|
-
|
2383
|
-
|
2384
|
-
|
2385
|
-
|
2386
|
-
|
2387
|
-
|
2388
|
-
|
2389
|
-
|
2390
|
-
|
2391
|
-
|
2392
|
-
|
2393
|
-
|
2394
|
-
|
2395
|
-
|
2396
|
-
|
2397
|
-
|
2398
|
-
|
2399
|
-
|
2400
|
-
|
2401
|
-
|
2402
|
-
|
2403
|
-
|
2404
|
-
|
2405
|
-
|
2406
|
-
|
2407
|
-
|
2408
|
-
|
2409
|
-
|
2410
|
-
|
2411
|
-
|
2412
|
-
|
2413
|
-
|
2414
|
-
|
2415
|
-
|
2416
|
-
|
2417
|
-
|
2418
|
-
|
2419
|
-
|
2420
|
-
|
2421
|
-
|
2422
|
-
|
2423
|
-
|
2424
|
-
|
2425
|
-
|
2426
|
-
|
2427
|
-
|
2428
|
-
|
2429
|
-
|
2430
|
-
|
2431
|
-
|
2432
|
-
|
2433
|
-
|
2434
|
-
|
2435
|
-
|
2436
|
-
|
2437
|
-
|
2438
|
-
|
2439
|
-
|
2440
|
-
|
2441
|
-
|
2442
|
-
|
2443
|
-
|
2444
|
-
|
2445
|
-
|
2446
|
-
|
2447
|
-
|
2448
|
-
|
2449
|
-
|
2450
|
-
|
2451
|
-
|
2452
|
-
|
2453
|
-
|
2454
|
-
|
2455
|
-
|
2456
|
-
|
2457
|
-
|
2458
|
-
|
2459
|
-
|
2460
|
-
|
2461
|
-
|
2462
|
-
|
2463
|
-
|
2464
|
-
|
2465
|
-
|
2466
|
-
|
2467
|
-
|
2468
|
-
|
2469
|
-
|
2470
|
-
|
2471
|
-
|
2472
|
-
|
2473
|
-
|
2474
|
-
|
2475
|
-
|
2476
|
-
|
2477
|
-
|
2478
|
-
|
2479
|
-
|
2480
|
-
|
2294
|
+
const self = this;
|
2295
|
+
|
2296
|
+
/**
|
2297
|
+
* @param {Event} event
|
2298
|
+
*/
|
2299
|
+
self[clearOptionEventHandler] = (event) => {
|
2300
|
+
const element = findTargetElementFromEvent(
|
2301
|
+
event,
|
2302
|
+
ATTRIBUTE_ROLE,
|
2303
|
+
"remove-badge",
|
2304
|
+
);
|
2305
|
+
|
2306
|
+
if (element instanceof HTMLElement) {
|
2307
|
+
const badge = findClosestByAttribute(element, ATTRIBUTE_ROLE, "badge");
|
2308
|
+
if (badge instanceof HTMLElement) {
|
2309
|
+
const value = badge.getAttribute(`${ATTRIBUTE_PREFIX}value`);
|
2310
|
+
|
2311
|
+
let selection = self.getOption("selection");
|
2312
|
+
selection = selection.filter((b) => {
|
2313
|
+
return value !== b.value;
|
2314
|
+
});
|
2315
|
+
|
2316
|
+
setSelection
|
2317
|
+
.call(self, selection)
|
2318
|
+
.then(() => {
|
2319
|
+
fireCustomEvent(self, "monster-selection-removed", {
|
2320
|
+
value,
|
2321
|
+
});
|
2322
|
+
})
|
2323
|
+
.catch((e) => {
|
2324
|
+
addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, e.message);
|
2325
|
+
});
|
2326
|
+
}
|
2327
|
+
}
|
2328
|
+
};
|
2329
|
+
|
2330
|
+
/**
|
2331
|
+
* @param {Event} event
|
2332
|
+
*/
|
2333
|
+
self[closeEventHandler] = (event) => {
|
2334
|
+
const path = event.composedPath();
|
2335
|
+
|
2336
|
+
for (const [, element] of Object.entries(path)) {
|
2337
|
+
if (element === self) {
|
2338
|
+
return;
|
2339
|
+
}
|
2340
|
+
}
|
2341
|
+
hide.call(self);
|
2342
|
+
};
|
2343
|
+
|
2344
|
+
/**
|
2345
|
+
* @param {Event} event
|
2346
|
+
*/
|
2347
|
+
self[inputEventHandler] = (event) => {
|
2348
|
+
const path = event.composedPath();
|
2349
|
+
const element = path?.[0];
|
2350
|
+
|
2351
|
+
if (element instanceof HTMLElement) {
|
2352
|
+
if (
|
2353
|
+
element.hasAttribute(ATTRIBUTE_ROLE) &&
|
2354
|
+
element.getAttribute(ATTRIBUTE_ROLE) === "option-control"
|
2355
|
+
) {
|
2356
|
+
fireCustomEvent(self, "monster-change", {
|
2357
|
+
type: event.type,
|
2358
|
+
value: element.value,
|
2359
|
+
checked: element.checked,
|
2360
|
+
});
|
2361
|
+
} else if (
|
2362
|
+
element.hasAttribute(ATTRIBUTE_ROLE) &&
|
2363
|
+
element.getAttribute(ATTRIBUTE_ROLE) === "filter"
|
2364
|
+
) {
|
2365
|
+
}
|
2366
|
+
}
|
2367
|
+
};
|
2368
|
+
|
2369
|
+
/**
|
2370
|
+
* @param {Event} event
|
2371
|
+
*/
|
2372
|
+
self[changeEventHandler] = (event) => {
|
2373
|
+
gatherState.call(self);
|
2374
|
+
fireCustomEvent(self, "monster-changed", event?.detail);
|
2375
|
+
};
|
2376
|
+
|
2377
|
+
self[keyEventHandler] = (event) => {
|
2378
|
+
const path = event.composedPath();
|
2379
|
+
const element = path.shift();
|
2380
|
+
|
2381
|
+
let role;
|
2382
|
+
|
2383
|
+
if (element instanceof HTMLElement) {
|
2384
|
+
if (element.hasAttribute(ATTRIBUTE_ROLE)) {
|
2385
|
+
role = element.getAttribute(ATTRIBUTE_ROLE);
|
2386
|
+
} else if (element === this) {
|
2387
|
+
show.call(this);
|
2388
|
+
// focusFilter.call(self);
|
2389
|
+
} else {
|
2390
|
+
const e = element.closest(`[${ATTRIBUTE_ROLE}]`);
|
2391
|
+
if (e instanceof HTMLElement && e.hasAttribute(ATTRIBUTE_ROLE)) {
|
2392
|
+
role = e.getAttribute(ATTRIBUTE_ROLE);
|
2393
|
+
}
|
2394
|
+
}
|
2395
|
+
} else {
|
2396
|
+
return;
|
2397
|
+
}
|
2398
|
+
|
2399
|
+
switch (role) {
|
2400
|
+
case "filter":
|
2401
|
+
handleFilterKeyboardEvents.call(self, event);
|
2402
|
+
break;
|
2403
|
+
case "option-label":
|
2404
|
+
case "option-control":
|
2405
|
+
case "option":
|
2406
|
+
handleOptionKeyboardEvents.call(self, event);
|
2407
|
+
break;
|
2408
|
+
case "control":
|
2409
|
+
case "toggle":
|
2410
|
+
handleToggleKeyboardEvents.call(self, event);
|
2411
|
+
break;
|
2412
|
+
}
|
2413
|
+
};
|
2414
|
+
|
2415
|
+
const types = self.getOption("toggleEventType", ["click"]);
|
2416
|
+
|
2417
|
+
for (const [, type] of Object.entries(types)) {
|
2418
|
+
self[controlElementSymbol]
|
2419
|
+
.querySelector(`[${ATTRIBUTE_ROLE}="container"]`)
|
2420
|
+
.addEventListener(type, function (event) {
|
2421
|
+
const element = findTargetElementFromEvent(
|
2422
|
+
event,
|
2423
|
+
ATTRIBUTE_ROLE,
|
2424
|
+
"remove-badge",
|
2425
|
+
);
|
2426
|
+
if (element instanceof HTMLElement) {
|
2427
|
+
return;
|
2428
|
+
}
|
2429
|
+
|
2430
|
+
toggle.call(self);
|
2431
|
+
});
|
2432
|
+
|
2433
|
+
self[controlElementSymbol]
|
2434
|
+
.querySelector(`[${ATTRIBUTE_ROLE}="status-or-remove-badges"]`)
|
2435
|
+
.addEventListener(type, function (event) {
|
2436
|
+
if (self.getOption("disabled", undefined) === true) {
|
2437
|
+
return;
|
2438
|
+
}
|
2439
|
+
|
2440
|
+
const path = event.composedPath();
|
2441
|
+
const element = path?.[0];
|
2442
|
+
if (element instanceof HTMLElement) {
|
2443
|
+
const control = element.closest(
|
2444
|
+
`[${ATTRIBUTE_ROLE}="status-or-remove-badges"]`,
|
2445
|
+
);
|
2446
|
+
if (control instanceof HTMLElement) {
|
2447
|
+
if (control.classList.contains("clear")) {
|
2448
|
+
clearSelection.call(self);
|
2449
|
+
|
2450
|
+
fireCustomEvent(self, "monster-selection-cleared", {});
|
2451
|
+
} else {
|
2452
|
+
const element = findTargetElementFromEvent(
|
2453
|
+
event,
|
2454
|
+
ATTRIBUTE_ROLE,
|
2455
|
+
"remove-badge",
|
2456
|
+
);
|
2457
|
+
if (element instanceof HTMLElement) {
|
2458
|
+
return;
|
2459
|
+
}
|
2460
|
+
|
2461
|
+
toggle.call(self);
|
2462
|
+
}
|
2463
|
+
}
|
2464
|
+
}
|
2465
|
+
});
|
2466
|
+
|
2467
|
+
// badge, selection
|
2468
|
+
self.addEventListener(type, self[clearOptionEventHandler]);
|
2469
|
+
}
|
2470
|
+
|
2471
|
+
self.addEventListener("monster-change", self[changeEventHandler]);
|
2472
|
+
self.addEventListener("input", self[inputEventHandler]);
|
2473
|
+
self.addEventListener("keydown", self[keyEventHandler]);
|
2474
|
+
|
2475
|
+
return self;
|
2481
2476
|
}
|
2482
2477
|
|
2483
2478
|
/**
|
@@ -2485,70 +2480,70 @@ function initEventHandler() {
|
|
2485
2480
|
* @return {Select}
|
2486
2481
|
*/
|
2487
2482
|
function setStatusOrRemoveBadges(suggestion) {
|
2488
|
-
|
2489
|
-
|
2490
|
-
|
2491
|
-
|
2492
|
-
|
2493
|
-
|
2494
|
-
|
2495
|
-
|
2496
|
-
|
2497
|
-
|
2498
|
-
|
2499
|
-
|
2500
|
-
|
2501
|
-
|
2502
|
-
|
2503
|
-
|
2504
|
-
|
2505
|
-
|
2506
|
-
|
2507
|
-
|
2508
|
-
|
2509
|
-
|
2510
|
-
|
2511
|
-
|
2512
|
-
|
2513
|
-
|
2514
|
-
|
2515
|
-
|
2516
|
-
|
2517
|
-
|
2518
|
-
|
2519
|
-
|
2520
|
-
|
2521
|
-
|
2522
|
-
|
2523
|
-
|
2524
|
-
|
2525
|
-
|
2526
|
-
|
2527
|
-
|
2528
|
-
|
2529
|
-
|
2530
|
-
|
2531
|
-
|
2532
|
-
|
2533
|
-
|
2534
|
-
|
2535
|
-
|
2536
|
-
|
2537
|
-
|
2538
|
-
|
2539
|
-
|
2540
|
-
|
2541
|
-
|
2542
|
-
|
2543
|
-
|
2544
|
-
|
2545
|
-
|
2546
|
-
|
2547
|
-
|
2548
|
-
|
2549
|
-
|
2550
|
-
|
2551
|
-
|
2483
|
+
requestAnimationFrame(() => {
|
2484
|
+
const selection = this.getOption("selection");
|
2485
|
+
|
2486
|
+
const clearAllFlag =
|
2487
|
+
isArray(selection) &&
|
2488
|
+
selection.length > 0 &&
|
2489
|
+
this.getOption("features.clearAll") === true;
|
2490
|
+
|
2491
|
+
const current = this.getOption("classes.statusOrRemoveBadge");
|
2492
|
+
|
2493
|
+
if (suggestion === "error") {
|
2494
|
+
if (current !== "error") {
|
2495
|
+
this.setOption("classes.statusOrRemoveBadge", "error");
|
2496
|
+
}
|
2497
|
+
return;
|
2498
|
+
}
|
2499
|
+
|
2500
|
+
if (this[isLoadingSymbol] === true) {
|
2501
|
+
if (current !== "loading") {
|
2502
|
+
this.setOption("classes.statusOrRemoveBadge", "loading");
|
2503
|
+
}
|
2504
|
+
return;
|
2505
|
+
}
|
2506
|
+
|
2507
|
+
if (suggestion === "loading") {
|
2508
|
+
if (current !== "loading") {
|
2509
|
+
this.setOption("classes.statusOrRemoveBadge", "loading");
|
2510
|
+
}
|
2511
|
+
return;
|
2512
|
+
}
|
2513
|
+
|
2514
|
+
if (clearAllFlag) {
|
2515
|
+
if (current !== "clear") {
|
2516
|
+
this.setOption("classes.statusOrRemoveBadge", "clear");
|
2517
|
+
}
|
2518
|
+
return;
|
2519
|
+
}
|
2520
|
+
|
2521
|
+
if (this[controlElementSymbol].classList.contains("open")) {
|
2522
|
+
if (current !== "open") {
|
2523
|
+
this.setOption("classes.statusOrRemoveBadge", "open");
|
2524
|
+
}
|
2525
|
+
return;
|
2526
|
+
}
|
2527
|
+
|
2528
|
+
const options = this.getOption("options");
|
2529
|
+
if (
|
2530
|
+
options === undefined ||
|
2531
|
+
options === null ||
|
2532
|
+
(isArray(options) && options.length === 0)
|
2533
|
+
) {
|
2534
|
+
if (current !== "empty") {
|
2535
|
+
this.setOption("classes.statusOrRemoveBadge", "empty");
|
2536
|
+
}
|
2537
|
+
return;
|
2538
|
+
}
|
2539
|
+
|
2540
|
+
if (suggestion) {
|
2541
|
+
if (current !== suggestion) {
|
2542
|
+
this.setOption("classes.statusOrRemoveBadge", suggestion);
|
2543
|
+
}
|
2544
|
+
return;
|
2545
|
+
}
|
2546
|
+
});
|
2552
2547
|
}
|
2553
2548
|
|
2554
2549
|
/**
|
@@ -2557,68 +2552,68 @@ function setStatusOrRemoveBadges(suggestion) {
|
|
2557
2552
|
* @throws {Error} no shadow-root is defined
|
2558
2553
|
*/
|
2559
2554
|
function initControlReferences() {
|
2560
|
-
|
2561
|
-
|
2562
|
-
|
2563
|
-
|
2564
|
-
|
2565
|
-
|
2566
|
-
|
2567
|
-
|
2568
|
-
|
2569
|
-
|
2570
|
-
|
2571
|
-
|
2572
|
-
|
2573
|
-
|
2574
|
-
|
2575
|
-
|
2576
|
-
|
2577
|
-
|
2578
|
-
|
2579
|
-
|
2580
|
-
|
2581
|
-
|
2582
|
-
|
2583
|
-
|
2584
|
-
|
2585
|
-
|
2586
|
-
|
2587
|
-
|
2588
|
-
|
2589
|
-
|
2590
|
-
|
2591
|
-
|
2592
|
-
|
2555
|
+
if (!this.shadowRoot) {
|
2556
|
+
throw new Error("no shadow-root is defined");
|
2557
|
+
}
|
2558
|
+
|
2559
|
+
this[controlElementSymbol] = this.shadowRoot.querySelector(
|
2560
|
+
`[${ATTRIBUTE_ROLE}=control]`,
|
2561
|
+
);
|
2562
|
+
this[selectionElementSymbol] = this.shadowRoot.querySelector(
|
2563
|
+
`[${ATTRIBUTE_ROLE}=selection]`,
|
2564
|
+
);
|
2565
|
+
this[containerElementSymbol] = this.shadowRoot.querySelector(
|
2566
|
+
`[${ATTRIBUTE_ROLE}=container]`,
|
2567
|
+
);
|
2568
|
+
this[popperElementSymbol] = this.shadowRoot.querySelector(
|
2569
|
+
`[${ATTRIBUTE_ROLE}=popper]`,
|
2570
|
+
);
|
2571
|
+
this[inlineFilterElementSymbol] = this.shadowRoot.querySelector(
|
2572
|
+
`[${ATTRIBUTE_ROLE}=filter][name="inline-filter"]`,
|
2573
|
+
);
|
2574
|
+
this[popperFilterElementSymbol] = this.shadowRoot.querySelector(
|
2575
|
+
`[${ATTRIBUTE_ROLE}=filter][name="popper-filter"]`,
|
2576
|
+
);
|
2577
|
+
this[popperFilterContainerElementSymbol] =
|
2578
|
+
this[popperFilterElementSymbol].parentElement;
|
2579
|
+
this[optionsElementSymbol] = this.shadowRoot.querySelector(
|
2580
|
+
`[${ATTRIBUTE_ROLE}=options]`,
|
2581
|
+
);
|
2582
|
+
this[noOptionsAvailableElementSymbol] = this.shadowRoot.querySelector(
|
2583
|
+
`[${ATTRIBUTE_ROLE}="no-options"]`,
|
2584
|
+
);
|
2585
|
+
this[statusOrRemoveBadgesElementSymbol] = this.shadowRoot.querySelector(
|
2586
|
+
`[${ATTRIBUTE_ROLE}=status-or-remove-badges]`,
|
2587
|
+
);
|
2593
2588
|
}
|
2594
2589
|
|
2595
2590
|
/**
|
2596
2591
|
* @private
|
2597
2592
|
*/
|
2598
2593
|
function updatePopper() {
|
2599
|
-
|
2600
|
-
|
2601
|
-
|
2602
|
-
|
2603
|
-
|
2604
|
-
|
2605
|
-
|
2606
|
-
|
2607
|
-
|
2608
|
-
|
2609
|
-
|
2610
|
-
|
2611
|
-
|
2612
|
-
|
2613
|
-
|
2614
|
-
|
2615
|
-
|
2616
|
-
|
2617
|
-
|
2618
|
-
|
2619
|
-
|
2620
|
-
|
2621
|
-
|
2594
|
+
if (this[popperElementSymbol].style.display !== STYLE_DISPLAY_MODE_BLOCK) {
|
2595
|
+
return;
|
2596
|
+
}
|
2597
|
+
|
2598
|
+
if (this.getOption("disabled", false) === true) {
|
2599
|
+
return;
|
2600
|
+
}
|
2601
|
+
|
2602
|
+
new Processing(() => {
|
2603
|
+
calcAndSetOptionsDimension.call(this);
|
2604
|
+
positionPopper.call(
|
2605
|
+
this,
|
2606
|
+
this[controlElementSymbol],
|
2607
|
+
this[popperElementSymbol],
|
2608
|
+
this.getOption("popper", {}),
|
2609
|
+
);
|
2610
|
+
})
|
2611
|
+
.run()
|
2612
|
+
.catch((e) => {
|
2613
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
|
2614
|
+
});
|
2615
|
+
|
2616
|
+
return this;
|
2622
2617
|
}
|
2623
2618
|
|
2624
2619
|
/**
|
@@ -2626,8 +2621,8 @@ function updatePopper() {
|
|
2626
2621
|
* @return {string}
|
2627
2622
|
*/
|
2628
2623
|
function getTemplate() {
|
2629
|
-
|
2630
|
-
|
2624
|
+
// language=HTML
|
2625
|
+
return `
|
2631
2626
|
<template id="options">
|
2632
2627
|
<div data-monster-role="option" tabindex="-1"
|
2633
2628
|
data-monster-attributes="
|