From a3b5ea3bf058cf5666a885cd1f5453d956618730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Gla=CC=88ser?= Date: Thu, 4 Jun 2026 18:28:51 +0200 Subject: [PATCH] Embed interactive search field in large table --- components/data-display.html | 40 +++++++++++++++++++-------- styles/42-components-data-display.css | 36 ------------------------ 2 files changed, 29 insertions(+), 47 deletions(-) diff --git a/components/data-display.html b/components/data-display.html index 41495f4..70e4951 100644 --- a/components/data-display.html +++ b/components/data-display.html @@ -80,17 +80,18 @@
Large Table
- + + + + + +
@@ -221,6 +222,8 @@ const rows = Array.from(table.querySelectorAll('[data-component-part="large-table-row"]')); const headerRow = table.querySelector('[data-component-part="large-table-header-row"]'); const searchInput = table.querySelector('[data-large-table-search]'); + const searchFieldWrap = table.querySelector('[data-component="single-line-input"]'); + const searchClearButton = table.querySelector('.sg-input-clear-button'); const state = { columnIndex: 0, direction: 'ascending', @@ -314,10 +317,25 @@ if (searchInput) { searchInput.addEventListener('input', () => { state.query = searchInput.value.trim().toLowerCase(); + if (searchFieldWrap) { + searchFieldWrap.setAttribute('data-has-value', searchInput.value ? 'true' : 'false'); + } renderRows(); }); } + if (searchClearButton && searchInput) { + searchClearButton.addEventListener('click', () => { + searchInput.value = ''; + state.query = ''; + if (searchFieldWrap) { + searchFieldWrap.setAttribute('data-has-value', 'false'); + } + renderRows(); + searchInput.focus(); + }); + } + if (headerRow) { setHeaderState(state.columnIndex, state.direction); } diff --git a/styles/42-components-data-display.css b/styles/42-components-data-display.css index 0dd0d98..c09226f 100644 --- a/styles/42-components-data-display.css +++ b/styles/42-components-data-display.css @@ -78,42 +78,6 @@ gap: var(--spacing-large); } -.sg-large-table__search { - display: flex; - align-items: center; - justify-content: flex-end; - gap: var(--spacing-small); - margin-left: auto; -} - -.sg-large-table__search-label { - color: var(--text-card-header); - font-family: var(--font-family-base); - font-size: var(--font-size-small); - font-weight: var(--font-weight-semibold); - line-height: var(--line-height-base); - white-space: nowrap; -} - -.sg-large-table__search-input { - width: 14rem; - max-width: 100%; - box-sizing: border-box; - padding: 0.35rem var(--spacing-small); - border: var(--border-none); - border-radius: var(--radius-card); - background: var(--color-white); - color: var(--text-control-default); - font-family: var(--font-family-base); - font-size: var(--font-size-small); - line-height: var(--line-height-base); -} - -.sg-large-table__search-input:focus-visible { - outline: 2px solid var(--color-white); - outline-offset: 2px; -} - .sg-large-table__row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));