@superleapai/flow-ui 2.2.9 → 2.2.10
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/components/enum-multiselect.js +27 -73
- package/components/enum-select.js +27 -76
- package/components/icon.js +2 -2
- package/components/multiselect.js +64 -40
- package/components/popover.js +33 -48
- package/components/record-multiselect.js +77 -140
- package/components/record-select.js +62 -145
- package/components/select.js +72 -64
- package/components/time-picker.js +4 -6
- package/core/superleapClient.js +3 -10
- package/dist/output.css +1 -1
- package/dist/superleap-flow.js +9 -8
- package/dist/superleap-flow.js.map +1 -1
- package/dist/superleap-flow.min.js +2 -2
- package/index.js +0 -1
- package/package.json +1 -1
|
@@ -76,6 +76,14 @@
|
|
|
76
76
|
return Array.prototype.filter.call(arguments, Boolean).join(" ");
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
function getDep(name) {
|
|
80
|
+
if (typeof global.FlowUI !== "undefined" && typeof global.FlowUI._getComponent === "function") {
|
|
81
|
+
var c = global.FlowUI._getComponent(name);
|
|
82
|
+
if (c) return c;
|
|
83
|
+
}
|
|
84
|
+
return global[name];
|
|
85
|
+
}
|
|
86
|
+
|
|
79
87
|
/** Resolve client: use FlowUI._getComponent when bundle has captured globals, else global.superleapClient */
|
|
80
88
|
function getClient() {
|
|
81
89
|
if (global.FlowUI && typeof global.FlowUI._getComponent === "function") {
|
|
@@ -145,8 +153,10 @@
|
|
|
145
153
|
var error = null;
|
|
146
154
|
var searchQuery = "";
|
|
147
155
|
var popover = null;
|
|
148
|
-
var
|
|
149
|
-
|
|
156
|
+
var Popover = getDep("Popover");
|
|
157
|
+
if (!Popover || typeof Popover.create !== "function") {
|
|
158
|
+
throw new Error("EnumMultiSelect requires Popover");
|
|
159
|
+
}
|
|
150
160
|
|
|
151
161
|
var container = document.createElement("div");
|
|
152
162
|
container.className = "enum-multiselect relative w-full group";
|
|
@@ -248,13 +258,7 @@
|
|
|
248
258
|
var content = document.createElement("div");
|
|
249
259
|
content.setAttribute("role", "listbox");
|
|
250
260
|
content.setAttribute("aria-multiselectable", "true");
|
|
251
|
-
|
|
252
|
-
if (!usePopover) {
|
|
253
|
-
contentBase += " absolute left-0 right-0 z-50 max-h-[30vh] overflow-hidden rounded-4 bg-fill-quarternary-fill-white shadow-default-medium border-1/2 border-border-primary opacity-0 invisible transition-all duration-150 ease-out group-[.open]:opacity-100 group-[.open]:visible top-full mt-1 -translate-y-1 group-[.open]:translate-y-0 flex flex-col";
|
|
254
|
-
} else {
|
|
255
|
-
contentBase += " max-h-[30vh] overflow-hidden flex flex-col";
|
|
256
|
-
}
|
|
257
|
-
content.className = contentBase;
|
|
261
|
+
content.className = "w-full min-w-[200px] max-h-[30vh] overflow-hidden flex flex-col";
|
|
258
262
|
|
|
259
263
|
// Search input (using InputComponent like enum-select)
|
|
260
264
|
var searchContainer = document.createElement("div");
|
|
@@ -320,10 +324,6 @@
|
|
|
320
324
|
content.appendChild(searchContainer);
|
|
321
325
|
content.appendChild(optionsList);
|
|
322
326
|
|
|
323
|
-
if (!usePopover) {
|
|
324
|
-
container.appendChild(content);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
327
|
var highlightedIndex = -1;
|
|
328
328
|
|
|
329
329
|
function showLoading() {
|
|
@@ -496,34 +496,14 @@
|
|
|
496
496
|
|
|
497
497
|
function openDropdown() {
|
|
498
498
|
if (disabled) return;
|
|
499
|
-
if (popover) {
|
|
500
|
-
document
|
|
501
|
-
.querySelectorAll(".enum-select, .enum-multiselect, .custom-select, .record-select, .custom-multiselect")
|
|
502
|
-
.forEach(function (other) {
|
|
503
|
-
if (other !== container && other.popoverInstance) {
|
|
504
|
-
other.popoverInstance.hide();
|
|
505
|
-
}
|
|
506
|
-
});
|
|
507
|
-
popover.show();
|
|
508
|
-
trigger.setAttribute("aria-expanded", "true");
|
|
509
|
-
if (searchInput) {
|
|
510
|
-
setTimeout(function () {
|
|
511
|
-
searchInput.focus();
|
|
512
|
-
}, 50);
|
|
513
|
-
}
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
499
|
document
|
|
517
|
-
.querySelectorAll(".enum-multiselect.
|
|
500
|
+
.querySelectorAll(".enum-select, .enum-multiselect, .custom-select, .record-select, .custom-multiselect")
|
|
518
501
|
.forEach(function (other) {
|
|
519
|
-
if (other !== container) {
|
|
520
|
-
other.
|
|
521
|
-
var t = other.querySelector("button");
|
|
522
|
-
if (t) t.setAttribute("aria-expanded", "false");
|
|
502
|
+
if (other !== container && other.popoverInstance) {
|
|
503
|
+
other.popoverInstance.hide();
|
|
523
504
|
}
|
|
524
505
|
});
|
|
525
|
-
|
|
526
|
-
container.classList.add("open");
|
|
506
|
+
popover.show();
|
|
527
507
|
trigger.setAttribute("aria-expanded", "true");
|
|
528
508
|
if (searchInput) {
|
|
529
509
|
setTimeout(function () {
|
|
@@ -533,12 +513,7 @@
|
|
|
533
513
|
}
|
|
534
514
|
|
|
535
515
|
function closeDropdown() {
|
|
536
|
-
|
|
537
|
-
popover.hide();
|
|
538
|
-
} else {
|
|
539
|
-
isOpen = false;
|
|
540
|
-
container.classList.remove("open");
|
|
541
|
-
}
|
|
516
|
+
popover.hide();
|
|
542
517
|
trigger.setAttribute("aria-expanded", "false");
|
|
543
518
|
highlightedIndex = -1;
|
|
544
519
|
clearSearch();
|
|
@@ -546,9 +521,7 @@
|
|
|
546
521
|
}
|
|
547
522
|
|
|
548
523
|
function toggleDropdown() {
|
|
549
|
-
var isVisible = popover
|
|
550
|
-
? popover.element && popover.element.classList.contains("visible")
|
|
551
|
-
: isOpen;
|
|
524
|
+
var isVisible = popover.element && popover.element.classList.contains("visible");
|
|
552
525
|
if (isVisible) {
|
|
553
526
|
closeDropdown();
|
|
554
527
|
} else {
|
|
@@ -628,10 +601,7 @@
|
|
|
628
601
|
|
|
629
602
|
// Initialize Popover
|
|
630
603
|
function initializePopover() {
|
|
631
|
-
|
|
632
|
-
return;
|
|
633
|
-
}
|
|
634
|
-
popover = global.Popover.create({
|
|
604
|
+
popover = Popover.create({
|
|
635
605
|
trigger: trigger,
|
|
636
606
|
content: content,
|
|
637
607
|
placement: "bottom",
|
|
@@ -647,6 +617,12 @@
|
|
|
647
617
|
onOpen: function () {
|
|
648
618
|
trigger.setAttribute("aria-expanded", "true");
|
|
649
619
|
chevron.style.transform = "rotate(180deg)";
|
|
620
|
+
if (popover.panel) {
|
|
621
|
+
var triggerWidthPx = trigger.offsetWidth + "px";
|
|
622
|
+
popover.panel.style.setProperty("--trigger-width", triggerWidthPx);
|
|
623
|
+
popover.panel.style.minWidth = triggerWidthPx;
|
|
624
|
+
popover.panel.style.width = triggerWidthPx;
|
|
625
|
+
}
|
|
650
626
|
},
|
|
651
627
|
bodyClassName: "p-0 overflow-hidden",
|
|
652
628
|
panelClassName: "min-w-[var(--trigger-width)] overflow-hidden",
|
|
@@ -654,13 +630,6 @@
|
|
|
654
630
|
|
|
655
631
|
// Store popover instance for cleanup
|
|
656
632
|
container.popoverInstance = popover;
|
|
657
|
-
|
|
658
|
-
// Set CSS variable for trigger width
|
|
659
|
-
var triggerWidth = trigger.offsetWidth;
|
|
660
|
-
if (popover.panel) {
|
|
661
|
-
popover.panel.style.setProperty("--trigger-width", triggerWidth + "px");
|
|
662
|
-
popover.panel.style.minWidth = triggerWidth + "px";
|
|
663
|
-
}
|
|
664
633
|
}
|
|
665
634
|
|
|
666
635
|
// Load options from SDK
|
|
@@ -779,21 +748,6 @@
|
|
|
779
748
|
initializePopover();
|
|
780
749
|
loadOptions();
|
|
781
750
|
|
|
782
|
-
if (!usePopover) {
|
|
783
|
-
trigger.addEventListener("click", function (e) {
|
|
784
|
-
e.preventDefault();
|
|
785
|
-
e.stopPropagation();
|
|
786
|
-
if (disabled) return;
|
|
787
|
-
toggleDropdown();
|
|
788
|
-
});
|
|
789
|
-
document.addEventListener("click", function (e) {
|
|
790
|
-
if (isOpen && !container.contains(e.target)) closeDropdown();
|
|
791
|
-
});
|
|
792
|
-
document.addEventListener("keydown", function (e) {
|
|
793
|
-
if (e.key === "Escape" && isOpen) closeDropdown();
|
|
794
|
-
});
|
|
795
|
-
}
|
|
796
|
-
|
|
797
751
|
// Public API
|
|
798
752
|
container.updateValues = function (newValues) {
|
|
799
753
|
values = Array.isArray(newValues) ? newValues.slice() : [];
|
|
@@ -835,7 +789,7 @@
|
|
|
835
789
|
);
|
|
836
790
|
updateClearButton();
|
|
837
791
|
var isVisible = popover && popover.element && popover.element.classList.contains("visible");
|
|
838
|
-
if (disabled &&
|
|
792
|
+
if (disabled && isVisible) closeDropdown();
|
|
839
793
|
};
|
|
840
794
|
|
|
841
795
|
container.reload = function () {
|
|
@@ -72,6 +72,14 @@
|
|
|
72
72
|
return Array.prototype.filter.call(arguments, Boolean).join(" ");
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
function getDep(name) {
|
|
76
|
+
if (typeof global.FlowUI !== "undefined" && typeof global.FlowUI._getComponent === "function") {
|
|
77
|
+
var c = global.FlowUI._getComponent(name);
|
|
78
|
+
if (c) return c;
|
|
79
|
+
}
|
|
80
|
+
return global[name];
|
|
81
|
+
}
|
|
82
|
+
|
|
75
83
|
/** Resolve client: use FlowUI._getComponent when bundle has captured globals, else global.superleapClient */
|
|
76
84
|
function getClient() {
|
|
77
85
|
if (global.FlowUI && typeof global.FlowUI._getComponent === "function") {
|
|
@@ -136,8 +144,10 @@
|
|
|
136
144
|
var error = null;
|
|
137
145
|
var searchQuery = "";
|
|
138
146
|
var popover = null;
|
|
139
|
-
var
|
|
140
|
-
|
|
147
|
+
var Popover = getDep("Popover");
|
|
148
|
+
if (!Popover || typeof Popover.create !== "function") {
|
|
149
|
+
throw new Error("EnumSelect requires Popover");
|
|
150
|
+
}
|
|
141
151
|
|
|
142
152
|
var container = document.createElement("div");
|
|
143
153
|
container.className = "enum-select relative w-full group";
|
|
@@ -221,13 +231,7 @@
|
|
|
221
231
|
// Create dropdown content
|
|
222
232
|
var content = document.createElement("div");
|
|
223
233
|
content.setAttribute("role", "listbox");
|
|
224
|
-
|
|
225
|
-
if (!usePopover) {
|
|
226
|
-
contentBase += " absolute left-0 right-0 z-50 max-h-[30vh] overflow-hidden rounded-4 bg-fill-quarternary-fill-white shadow-default-medium border-1/2 border-border-primary opacity-0 invisible transition-all duration-150 ease-out group-[.open]:opacity-100 group-[.open]:visible top-full mt-1 -translate-y-1 group-[.open]:translate-y-0 flex flex-col";
|
|
227
|
-
} else {
|
|
228
|
-
contentBase += " max-h-[30vh] overflow-hidden flex flex-col";
|
|
229
|
-
}
|
|
230
|
-
content.className = contentBase;
|
|
234
|
+
content.className = "w-full min-w-[200px] max-h-[30vh] overflow-hidden flex flex-col";
|
|
231
235
|
|
|
232
236
|
// Search input (using InputComponent like phone-input)
|
|
233
237
|
var searchContainer = document.createElement("div");
|
|
@@ -293,10 +297,6 @@
|
|
|
293
297
|
content.appendChild(searchContainer);
|
|
294
298
|
content.appendChild(optionsList);
|
|
295
299
|
|
|
296
|
-
if (!usePopover) {
|
|
297
|
-
container.appendChild(content);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
300
|
var highlightedIndex = -1;
|
|
301
301
|
|
|
302
302
|
function showLoading() {
|
|
@@ -419,37 +419,14 @@
|
|
|
419
419
|
|
|
420
420
|
function openDropdown() {
|
|
421
421
|
if (disabled) return;
|
|
422
|
-
if (popover) {
|
|
423
|
-
// Close other open selects
|
|
424
|
-
document
|
|
425
|
-
.querySelectorAll(".enum-select, .custom-select, .record-select")
|
|
426
|
-
.forEach(function (other) {
|
|
427
|
-
if (other !== container && other.popoverInstance) {
|
|
428
|
-
other.popoverInstance.hide();
|
|
429
|
-
}
|
|
430
|
-
});
|
|
431
|
-
popover.show();
|
|
432
|
-
trigger.setAttribute("aria-expanded", "true");
|
|
433
|
-
highlightOptionByValue(value);
|
|
434
|
-
if (searchInput) {
|
|
435
|
-
setTimeout(function () {
|
|
436
|
-
searchInput.focus();
|
|
437
|
-
}, 50);
|
|
438
|
-
}
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
// Fallback when Popover not available
|
|
442
422
|
document
|
|
443
|
-
.querySelectorAll(".enum-select.
|
|
423
|
+
.querySelectorAll(".enum-select, .custom-select, .record-select")
|
|
444
424
|
.forEach(function (other) {
|
|
445
|
-
if (other !== container) {
|
|
446
|
-
other.
|
|
447
|
-
var t = other.querySelector("button");
|
|
448
|
-
if (t) t.setAttribute("aria-expanded", "false");
|
|
425
|
+
if (other !== container && other.popoverInstance) {
|
|
426
|
+
other.popoverInstance.hide();
|
|
449
427
|
}
|
|
450
428
|
});
|
|
451
|
-
|
|
452
|
-
container.classList.add("open");
|
|
429
|
+
popover.show();
|
|
453
430
|
trigger.setAttribute("aria-expanded", "true");
|
|
454
431
|
highlightOptionByValue(value);
|
|
455
432
|
if (searchInput) {
|
|
@@ -460,12 +437,7 @@
|
|
|
460
437
|
}
|
|
461
438
|
|
|
462
439
|
function closeDropdown() {
|
|
463
|
-
|
|
464
|
-
popover.hide();
|
|
465
|
-
} else {
|
|
466
|
-
isOpen = false;
|
|
467
|
-
container.classList.remove("open");
|
|
468
|
-
}
|
|
440
|
+
popover.hide();
|
|
469
441
|
trigger.setAttribute("aria-expanded", "false");
|
|
470
442
|
highlightedIndex = -1;
|
|
471
443
|
clearSearch();
|
|
@@ -473,9 +445,7 @@
|
|
|
473
445
|
}
|
|
474
446
|
|
|
475
447
|
function toggleDropdown() {
|
|
476
|
-
var isVisible = popover
|
|
477
|
-
? popover.element && popover.element.classList.contains("visible")
|
|
478
|
-
: isOpen;
|
|
448
|
+
var isVisible = popover.element && popover.element.classList.contains("visible");
|
|
479
449
|
if (isVisible) {
|
|
480
450
|
closeDropdown();
|
|
481
451
|
} else {
|
|
@@ -586,10 +556,7 @@
|
|
|
586
556
|
|
|
587
557
|
// Initialize Popover
|
|
588
558
|
function initializePopover() {
|
|
589
|
-
|
|
590
|
-
return;
|
|
591
|
-
}
|
|
592
|
-
popover = global.Popover.create({
|
|
559
|
+
popover = Popover.create({
|
|
593
560
|
trigger: trigger,
|
|
594
561
|
content: content,
|
|
595
562
|
placement: "bottom",
|
|
@@ -605,6 +572,12 @@
|
|
|
605
572
|
onOpen: function () {
|
|
606
573
|
trigger.setAttribute("aria-expanded", "true");
|
|
607
574
|
chevron.style.transform = "rotate(180deg)";
|
|
575
|
+
if (popover.panel) {
|
|
576
|
+
var triggerWidthPx = trigger.offsetWidth + "px";
|
|
577
|
+
popover.panel.style.setProperty("--trigger-width", triggerWidthPx);
|
|
578
|
+
popover.panel.style.minWidth = triggerWidthPx;
|
|
579
|
+
popover.panel.style.width = triggerWidthPx;
|
|
580
|
+
}
|
|
608
581
|
},
|
|
609
582
|
bodyClassName: "p-0 overflow-hidden",
|
|
610
583
|
panelClassName: "min-w-[var(--trigger-width)] overflow-hidden",
|
|
@@ -612,13 +585,6 @@
|
|
|
612
585
|
|
|
613
586
|
// Store popover instance for cleanup
|
|
614
587
|
container.popoverInstance = popover;
|
|
615
|
-
|
|
616
|
-
// Set CSS variable for trigger width
|
|
617
|
-
var triggerWidth = trigger.offsetWidth;
|
|
618
|
-
if (popover.panel) {
|
|
619
|
-
popover.panel.style.setProperty("--trigger-width", triggerWidth + "px");
|
|
620
|
-
popover.panel.style.minWidth = triggerWidth + "px";
|
|
621
|
-
}
|
|
622
588
|
}
|
|
623
589
|
|
|
624
590
|
// Load options from SDK
|
|
@@ -742,21 +708,6 @@
|
|
|
742
708
|
initializePopover();
|
|
743
709
|
loadOptions();
|
|
744
710
|
|
|
745
|
-
if (!usePopover) {
|
|
746
|
-
trigger.addEventListener("click", function (e) {
|
|
747
|
-
e.preventDefault();
|
|
748
|
-
e.stopPropagation();
|
|
749
|
-
if (disabled) return;
|
|
750
|
-
toggleDropdown();
|
|
751
|
-
});
|
|
752
|
-
document.addEventListener("click", function (e) {
|
|
753
|
-
if (isOpen && !container.contains(e.target)) closeDropdown();
|
|
754
|
-
});
|
|
755
|
-
document.addEventListener("keydown", function (e) {
|
|
756
|
-
if (e.key === "Escape" && isOpen) closeDropdown();
|
|
757
|
-
});
|
|
758
|
-
}
|
|
759
|
-
|
|
760
711
|
// Public API
|
|
761
712
|
container.updateValue = function (newValue) {
|
|
762
713
|
value = newValue !== undefined && newValue !== null ? newValue : "";
|
|
@@ -801,7 +752,7 @@
|
|
|
801
752
|
);
|
|
802
753
|
updateClearButton();
|
|
803
754
|
var isVisible = popover && popover.element && popover.element.classList.contains("visible");
|
|
804
|
-
if (disabled &&
|
|
755
|
+
if (disabled && isVisible) closeDropdown();
|
|
805
756
|
};
|
|
806
757
|
|
|
807
758
|
container.reload = function () {
|
package/components/icon.js
CHANGED
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
' stroke-width="1.5">' +
|
|
45
45
|
TI_PATH_NONE +
|
|
46
46
|
'<path d="M8 7a4 4 0 1 0 8 0a4 4 0 0 0 -8 0"/><path d="M6 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"/></svg>',
|
|
47
|
-
|
|
47
|
+
IconStar:
|
|
48
48
|
"<svg" +
|
|
49
49
|
TI +
|
|
50
50
|
' stroke-width="1.5">' +
|
|
51
51
|
TI_PATH_NONE +
|
|
52
|
-
'<path d="
|
|
52
|
+
'<path d="M12 17.75l-6.172 3.245l1.179 -6.873l-5 -4.867l6.9 -1l3.086 -6.253l3.086 6.253l6.9 1l-5 4.867l1.179 6.873z"/></svg>',
|
|
53
53
|
IconPhone:
|
|
54
54
|
"<svg" +
|
|
55
55
|
TI +
|
|
@@ -60,6 +60,14 @@
|
|
|
60
60
|
return opt.label || opt.name || opt.display_name || opt.value;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
function getDep(name) {
|
|
64
|
+
if (typeof global.FlowUI !== "undefined" && typeof global.FlowUI._getComponent === "function") {
|
|
65
|
+
var c = global.FlowUI._getComponent(name);
|
|
66
|
+
if (c) return c;
|
|
67
|
+
}
|
|
68
|
+
return global[name];
|
|
69
|
+
}
|
|
70
|
+
|
|
63
71
|
/**
|
|
64
72
|
* Create a multiselect dropdown component
|
|
65
73
|
* @param {Object} config
|
|
@@ -90,6 +98,11 @@
|
|
|
90
98
|
? config.values.slice()
|
|
91
99
|
: [];
|
|
92
100
|
|
|
101
|
+
var Popover = getDep("Popover");
|
|
102
|
+
if (!Popover || typeof Popover.create !== "function") {
|
|
103
|
+
throw new Error("MultiSelect requires Popover");
|
|
104
|
+
}
|
|
105
|
+
|
|
93
106
|
var container = document.createElement("div");
|
|
94
107
|
container.className = "custom-multiselect relative w-full group";
|
|
95
108
|
if (fieldId) container.setAttribute("data-field-id", fieldId);
|
|
@@ -138,14 +151,10 @@
|
|
|
138
151
|
triggerWrapper.appendChild(trigger);
|
|
139
152
|
container.appendChild(triggerWrapper);
|
|
140
153
|
|
|
141
|
-
var contentBase =
|
|
142
|
-
"custom-multiselect-content absolute left-0 right-0 z-50 max-h-[200px] min-w-[8rem] overflow-hidden rounded-4 bg-fill-quarternary-fill-white shadow-default-medium opacity-0 invisible transition-all duration-150 ease-out " +
|
|
143
|
-
"group-[.open]:opacity-100 group-[.open]:visible ";
|
|
144
|
-
|
|
145
154
|
var content = document.createElement("div");
|
|
146
155
|
content.setAttribute("role", "listbox");
|
|
147
156
|
content.setAttribute("aria-multiselectable", "true");
|
|
148
|
-
content.className =
|
|
157
|
+
content.className = "custom-multiselect-content w-full max-h-[200px] overflow-hidden flex flex-col";
|
|
149
158
|
|
|
150
159
|
var optionsList = document.createElement("div");
|
|
151
160
|
optionsList.className =
|
|
@@ -246,47 +255,68 @@
|
|
|
246
255
|
buildOptionsList();
|
|
247
256
|
|
|
248
257
|
content.appendChild(optionsList);
|
|
249
|
-
container.appendChild(content);
|
|
250
258
|
|
|
251
|
-
var
|
|
259
|
+
var popover = Popover.create({
|
|
260
|
+
trigger: trigger,
|
|
261
|
+
content: content,
|
|
262
|
+
placement: "bottom",
|
|
263
|
+
align: "start",
|
|
264
|
+
closeOnClickOutside: true,
|
|
265
|
+
bodyClassName: "p-0 overflow-hidden",
|
|
266
|
+
panelClassName: "min-w-[var(--trigger-width)] max-h-[200px] overflow-hidden",
|
|
267
|
+
onOpen: function () {
|
|
268
|
+
if (disabled) {
|
|
269
|
+
popover.hide();
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
document
|
|
273
|
+
.querySelectorAll(".custom-select, .record-select, .custom-multiselect, .enum-select, .enum-multiselect, .record-multiselect")
|
|
274
|
+
.forEach(function (other) {
|
|
275
|
+
if (other !== container && other.popoverInstance) {
|
|
276
|
+
other.popoverInstance.hide();
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
trigger.setAttribute("aria-expanded", "true");
|
|
280
|
+
chevron.style.transform = "rotate(180deg)";
|
|
281
|
+
if (popover.panel) {
|
|
282
|
+
var triggerWidthPx = trigger.offsetWidth + "px";
|
|
283
|
+
popover.panel.style.setProperty("--trigger-width", triggerWidthPx);
|
|
284
|
+
popover.panel.style.minWidth = triggerWidthPx;
|
|
285
|
+
popover.panel.style.width = triggerWidthPx;
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
onClose: function () {
|
|
289
|
+
trigger.setAttribute("aria-expanded", "false");
|
|
290
|
+
chevron.style.transform = "";
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
container.popoverInstance = popover;
|
|
252
294
|
|
|
253
295
|
function openDropdown() {
|
|
254
296
|
if (disabled) return;
|
|
255
|
-
|
|
256
|
-
.querySelectorAll(".custom-select.open, .record-select.open, .custom-multiselect.open")
|
|
257
|
-
.forEach(function (other) {
|
|
258
|
-
if (other !== container) {
|
|
259
|
-
other.classList.remove("open");
|
|
260
|
-
var t = other.querySelector(
|
|
261
|
-
"button, .custom-select-trigger, .record-select-trigger, .multiselect-trigger-wrapper button"
|
|
262
|
-
);
|
|
263
|
-
if (t) t.setAttribute("aria-expanded", "false");
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
isOpen = true;
|
|
267
|
-
container.classList.add("open");
|
|
268
|
-
trigger.setAttribute("aria-expanded", "true");
|
|
297
|
+
popover.show();
|
|
269
298
|
}
|
|
270
299
|
|
|
271
300
|
function closeDropdown() {
|
|
272
|
-
|
|
273
|
-
container.classList.remove("open");
|
|
274
|
-
trigger.setAttribute("aria-expanded", "false");
|
|
301
|
+
popover.hide();
|
|
275
302
|
}
|
|
276
303
|
|
|
277
304
|
function toggleDropdown() {
|
|
278
|
-
|
|
305
|
+
var isVisible = popover.element && popover.element.classList.contains("visible");
|
|
306
|
+
if (isVisible) closeDropdown();
|
|
279
307
|
else openDropdown();
|
|
280
308
|
}
|
|
281
309
|
|
|
282
310
|
trigger.addEventListener("click", function (e) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
311
|
+
if (disabled) {
|
|
312
|
+
e.preventDefault();
|
|
313
|
+
e.stopImmediatePropagation();
|
|
314
|
+
}
|
|
315
|
+
}, true);
|
|
287
316
|
|
|
288
317
|
trigger.addEventListener("keydown", function (e) {
|
|
289
318
|
if (disabled) return;
|
|
319
|
+
var isVisible = popover.element && popover.element.classList.contains("visible");
|
|
290
320
|
switch (e.key) {
|
|
291
321
|
case "Enter":
|
|
292
322
|
case " ":
|
|
@@ -295,14 +325,14 @@
|
|
|
295
325
|
break;
|
|
296
326
|
case "ArrowDown":
|
|
297
327
|
e.preventDefault();
|
|
298
|
-
if (!
|
|
328
|
+
if (!isVisible) openDropdown();
|
|
299
329
|
break;
|
|
300
330
|
case "ArrowUp":
|
|
301
331
|
e.preventDefault();
|
|
302
|
-
if (!
|
|
332
|
+
if (!isVisible) openDropdown();
|
|
303
333
|
break;
|
|
304
334
|
case "Escape":
|
|
305
|
-
if (
|
|
335
|
+
if (isVisible) {
|
|
306
336
|
e.preventDefault();
|
|
307
337
|
closeDropdown();
|
|
308
338
|
}
|
|
@@ -310,13 +340,6 @@
|
|
|
310
340
|
}
|
|
311
341
|
});
|
|
312
342
|
|
|
313
|
-
document.addEventListener("click", function (e) {
|
|
314
|
-
if (isOpen && !container.contains(e.target)) closeDropdown();
|
|
315
|
-
});
|
|
316
|
-
document.addEventListener("keydown", function (e) {
|
|
317
|
-
if (e.key === "Escape" && isOpen) closeDropdown();
|
|
318
|
-
});
|
|
319
|
-
|
|
320
343
|
container.updateValues = function (newValues) {
|
|
321
344
|
values = Array.isArray(newValues) ? newValues.slice() : [];
|
|
322
345
|
renderTriggerContent();
|
|
@@ -335,7 +358,8 @@
|
|
|
335
358
|
disabled = !!isDisabled;
|
|
336
359
|
trigger.disabled = disabled;
|
|
337
360
|
trigger.className = triggerClasses(variant, size, disabled, values.length === 0);
|
|
338
|
-
|
|
361
|
+
var isVisible = popover.element && popover.element.classList.contains("visible");
|
|
362
|
+
if (disabled && isVisible) closeDropdown();
|
|
339
363
|
};
|
|
340
364
|
|
|
341
365
|
container.getValues = function () {
|