1
0
mirror of git://f0xx.org/android_cast synced 2026-07-29 05:58:14 +03:00
This commit is contained in:
Anton Afanasyeu
2026-05-23 00:21:38 +02:00
parent 91e9b1d9ed
commit 144ddec367
2 changed files with 33 additions and 22 deletions

View File

@@ -469,15 +469,20 @@ a:hover { text-decoration: underline; }
padding-right: 8px; padding-right: 8px;
min-height: 1.5rem; min-height: 1.5rem;
} }
.th-drag { .data-table th.th-draggable {
cursor: grab; cursor: grab;
user-select: none;
}
.data-table th.th-draggable:active {
cursor: grabbing;
}
.th-drag {
color: var(--muted); color: var(--muted);
font-size: 11px; font-size: 11px;
letter-spacing: -2px; letter-spacing: -2px;
user-select: none; user-select: none;
flex-shrink: 0; flex-shrink: 0;
} }
.th-drag:active { cursor: grabbing; }
.th-label { flex: 1; min-width: 0; } .th-label { flex: 1; min-width: 0; }
.th-draggable.th-dragging { opacity: .45; } .th-draggable.th-dragging { opacity: .45; }
.th-draggable.th-dragging .th-label { .th-draggable.th-dragging .th-label {

View File

@@ -350,13 +350,17 @@
table.dataset.layoutBound = '1'; table.dataset.layoutBound = '1';
thead.addEventListener('dragstart', (e) => { thead.addEventListener('dragstart', (e) => {
const handle = e.target.closest('.th-drag'); if (ctx.getGrouped()) return;
if (!handle || ctx.getGrouped()) return; if (e.target.closest('.col-resizer')) {
const sourceKey = handle.getAttribute('data-col-key'); e.preventDefault();
return;
}
const th = e.target.closest('th.th-draggable[data-col-key]');
if (!th) return;
const sourceKey = th.getAttribute('data-col-key');
if (!sourceKey) return; if (!sourceKey) return;
table.dataset.dragColKey = sourceKey; table.dataset.dragColKey = sourceKey;
const th = handle.closest('th'); th.classList.add('th-dragging');
if (th) th.classList.add('th-dragging');
const label = columnLabelByKey(sourceKey); const label = columnLabelByKey(sourceKey);
const ghost = document.createElement('div'); const ghost = document.createElement('div');
ghost.className = 'col-drag-ghost'; ghost.className = 'col-drag-ghost';
@@ -698,16 +702,19 @@
active ? (dir === 'asc' ? '▲' : '▼') : '<span class="sort-idle">↕</span>'; active ? (dir === 'asc' ? '▲' : '▼') : '<span class="sort-idle">↕</span>';
const w = widths[c.key] ? ' style="width:' + widths[c.key] + 'px"' : ''; const w = widths[c.key] ? ' style="width:' + widths[c.key] + 'px"' : '';
let thClass = 'sortable' + (active ? ' sortable--active' : ''); let thClass = 'sortable' + (active ? ' sortable--active' : '');
let thDrag = ''; let thDragAttrs = '';
if (!grouped) { if (!grouped) {
thClass += ' th-draggable'; thClass += ' th-draggable';
thDrag = ' data-col-key="' + escapeHtml(c.key) + '"'; thDragAttrs =
' draggable="true" data-col-key="' +
escapeHtml(c.key) +
'" title="Drag column to reorder"';
} }
html += html +=
'<th class="' + '<th class="' +
thClass + thClass +
'"' + '"' +
thDrag + thDragAttrs +
' data-sort="' + ' data-sort="' +
escapeHtml(c.key) + escapeHtml(c.key) +
'"' + '"' +
@@ -715,9 +722,7 @@
' scope="col"><span class="th-inner">' + ' scope="col"><span class="th-inner">' +
(grouped (grouped
? '' ? ''
: '<span class="th-drag" draggable="true" data-col-key="' + : '<span class="th-drag" aria-hidden="true" title="Drag column">⋮⋮</span>') +
escapeHtml(c.key) +
'" title="Drag to reorder column" aria-hidden="true">⋮⋮</span>') +
'<span class="th-label">' + '<span class="th-label">' +
escapeHtml(c.label) + escapeHtml(c.label) +
'</span> <span class="sort-ind" aria-hidden="true">' + '</span> <span class="sort-ind" aria-hidden="true">' +
@@ -733,7 +738,7 @@
thead.innerHTML = html; thead.innerHTML = html;
thead.querySelectorAll('.sortable').forEach((th) => { thead.querySelectorAll('.sortable').forEach((th) => {
th.addEventListener('click', (e) => { th.addEventListener('click', (e) => {
if (e.target.closest('.col-resizer') || e.target.closest('.th-drag')) return; if (e.target.closest('.col-resizer')) return;
const key = th.getAttribute('data-sort'); const key = th.getAttribute('data-sort');
if (!key) return; if (!key) return;
if (sort === key) { if (sort === key) {
@@ -1060,16 +1065,17 @@
} }
}); });
} }
function appendSearchTerm(term) { function selectSearchSuggestion(term) {
if (!searchInput) return; if (!searchInput) return;
const t = (term || '').trim(); const t = (term || '').trim();
if (!t) return; if (!t) return;
const cur = searchInput.value.trim(); const raw = searchInput.value;
if (!cur) { const withoutTrailing = raw.replace(/\s+$/, '');
searchInput.value = t; const lastSpace = withoutTrailing.lastIndexOf(' ');
} else if (!cur.toLowerCase().includes(t.toLowerCase())) { searchInput.value =
searchInput.value = cur + ' ' + t; lastSpace < 0
} ? t
: withoutTrailing.slice(0, lastSpace + 1) + t;
if (searchClear) searchClear.hidden = !searchInput.value.trim(); if (searchClear) searchClear.hidden = !searchInput.value.trim();
searchInput.focus(); searchInput.focus();
} }
@@ -1078,7 +1084,7 @@
const btn = e.target.closest('[data-suggest]'); const btn = e.target.closest('[data-suggest]');
if (!btn) return; if (!btn) return;
const term = btn.getAttribute('data-suggest') || ''; const term = btn.getAttribute('data-suggest') || '';
appendSearchTerm(term); selectSearchSuggestion(term);
hideSuggest(); hideSuggest();
}); });
} }