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