исправил настройку временных слотов

This commit is contained in:
Zuev
2026-05-02 01:34:21 +03:00
parent 3cb311f469
commit 44cfe8ab6e
10 changed files with 390 additions and 154 deletions

View File

@@ -2,10 +2,17 @@
export class CustomSelect {
constructor(originalSelect) {
if (originalSelect.classList.contains('custom-select-initialized')) return;
if (originalSelect.classList.contains('custom-select-initialized')) {
if (originalSelect.customSelectInstance) {
return originalSelect.customSelectInstance;
}
originalSelect.classList.remove('custom-select-initialized');
}
this.originalSelect = originalSelect;
this.originalSelect.classList.add('custom-select-initialized');
this.originalSelect.customSelectInstance = this;
this.layerParent = this.originalSelect.closest('.settings-card, .card');
// Hide original but keep it accessible for form submissions and JS
this.originalSelect.style.display = 'none';
@@ -163,6 +170,7 @@ export class CustomSelect {
this.closeAll(); // Close other open dropdowns
if (!isOpen) {
this.layerParent?.classList.add('select-layer-active');
this.wrapper.classList.add('open');
// Scroll selected item into view
const selectedItem = this.menu.querySelector('.selected');
@@ -178,10 +186,14 @@ export class CustomSelect {
document.querySelectorAll('.custom-select-wrapper.open').forEach(wrapper => {
wrapper.classList.remove('open');
});
document.querySelectorAll('.select-layer-active').forEach(layer => {
layer.classList.remove('select-layer-active');
});
}
close() {
this.wrapper.classList.remove('open');
this.layerParent?.classList.remove('select-layer-active');
}
handleItemClick(e, index) {
@@ -198,12 +210,28 @@ export class CustomSelect {
// Global initializer
export function initAllCustomDropdowns(root = document) {
const selects = root.querySelectorAll('select:not(.custom-select-initialized)');
const selects = root.querySelectorAll('select:not(.custom-select-initialized):not([data-native-select="true"])');
selects.forEach(select => {
new CustomSelect(select);
});
}
export function refreshCustomDropdowns(...selects) {
selects.filter(Boolean).forEach(select => {
if (select.dataset.nativeSelect === 'true') {
return;
}
if (select.customSelectInstance) {
select.customSelectInstance.rebuildMenu();
return;
}
if (select.classList.contains('custom-select-initialized')) {
select.classList.remove('custom-select-initialized');
}
new CustomSelect(select);
});
}
// Observe DOM for automatically picking up new select elements
export function startDropdownAutoObserver() {
const observer = new MutationObserver((mutations) => {