@@ -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));