Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(datagrid): add string filter label #1645

Merged
merged 24 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fd5bec5
feat(datagrid): add filter title
valentin-mladenov Dec 11, 2024
19158f8
Merge branch 'main' into datagrid-filter-title_cde-2483
valentin-mladenov Dec 13, 2024
5b6681e
fix(datagrid): column story
valentin-mladenov Dec 16, 2024
6114d72
fix(datagrid): add change detector for filter dialog
valentin-mladenov Dec 17, 2024
c1777de
fix(datagrid): fix test
valentin-mladenov Dec 17, 2024
095311c
fix: public api update
valentin-mladenov Dec 18, 2024
9a12647
fix: use mark for check
valentin-mladenov Dec 18, 2024
e9e6bc2
Merge branch 'main' into datagrid-filter-title_cde-2483
valentin-mladenov Dec 18, 2024
828df17
fix: revert story changes
valentin-mladenov Dec 18, 2024
f6070e8
chore: update visual snapshots for `datagrid-filter-title_cde-2483`
web-flow Dec 18, 2024
9612405
fix: pr feedback
valentin-mladenov Dec 18, 2024
99f9eeb
feat(datagrid): new implementation
valentin-mladenov Jan 9, 2025
d622eb8
fix(datagrid): common strings comment
valentin-mladenov Jan 10, 2025
f86fbe1
fix(datagrid): revert datagrid filter changes
valentin-mladenov Jan 10, 2025
4e00146
fix(datagrid): revert datagrid filter changes
valentin-mladenov Jan 10, 2025
92cf798
fix(datagrid): update clarity api
valentin-mladenov Jan 10, 2025
b983f02
Merge branch 'main' into datagrid-filter-title_cde-2483
valentin-mladenov Jan 10, 2025
675a987
feat(datagrid): add string filter popover story
valentin-mladenov Jan 10, 2025
cdd0d4c
chore: update visual snapshots for `datagrid-filter-title_cde-2483`
web-flow Jan 10, 2025
42d1bf1
feat(datagrid): pr feedback
valentin-mladenov Jan 15, 2025
63b3ba1
Merge branch 'main' into datagrid-filter-title_cde-2483
valentin-mladenov Jan 15, 2025
d214bcf
feat(datagrid): update public api
valentin-mladenov Jan 15, 2025
a3a04bc
chore: update visual snapshots for `datagrid-filter-title_cde-2483`
web-flow Jan 15, 2025
7b0bd15
Merge branch 'main' into datagrid-filter-title_cde-2483
valentin-mladenov Jan 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions projects/angular/clarity.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@ export interface ClrCommonStrings {
datagridExpandableRowsHelperText: string;
datagridFilterAriaLabel: string;
datagridFilterDialogAriaLabel: string;
datagridFilterTitle: string;
// (undocumented)
datepickerCurrentDecade: string;
// (undocumented)
Expand Down Expand Up @@ -1510,7 +1511,7 @@ export class ClrDatagridDetailHeader implements AfterViewInit {
//
// @public
export class ClrDatagridFilter<T = any> extends DatagridFilterRegistrar<T, ClrDatagridFilterInterface<T>> implements CustomFilter, OnChanges, OnDestroy {
constructor(_filters: FiltersProvider<T>, commonStrings: ClrCommonStringsService, smartToggleService: ClrPopoverToggleService, platformId: any, elementRef: ElementRef<HTMLElement>, keyNavigation: KeyNavigationGridController);
constructor(_filters: FiltersProvider<T>, commonStrings: ClrCommonStringsService, smartToggleService: ClrPopoverToggleService, platformId: any, elementRef: ElementRef<HTMLElement>, keyNavigation: KeyNavigationGridController, cdr: ChangeDetectorRef);
get active(): boolean;
// (undocumented)
anchor: ElementRef<HTMLButtonElement>;
Expand All @@ -1523,6 +1524,8 @@ export class ClrDatagridFilter<T = any> extends DatagridFilterRegistrar<T, ClrDa
// (undocumented)
set customFilter(filter: ClrDatagridFilterInterface<T> | RegisteredFilter<T, ClrDatagridFilterInterface<T>>);
// (undocumented)
filterTitle: string;
// (undocumented)
ngOnChanges(): void;
// (undocumented)
ngOnDestroy(): void;
Expand All @@ -1540,7 +1543,7 @@ export class ClrDatagridFilter<T = any> extends DatagridFilterRegistrar<T, ClrDa
// (undocumented)
static ɵcmp: i0.ɵɵComponentDeclaration<ClrDatagridFilter<any>, "clr-dg-filter", never, { "open": "clrDgFilterOpen"; "customFilter": "clrDgFilter"; }, { "openChange": "clrDgFilterOpenChange"; }, never, ["*"], false, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<ClrDatagridFilter<any>, [null, null, null, null, null, { optional: true; }]>;
static ɵfac: i0.ɵɵFactoryDeclaration<ClrDatagridFilter<any>, [null, null, null, null, null, { optional: true; }, null]>;
}

// @public (undocumented)
Expand Down
12 changes: 11 additions & 1 deletion projects/angular/src/data/datagrid/_datagrid.clarity.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1411,10 +1411,20 @@
font-weight: normal;

.datagrid-filter-close-wrapper {
text-align: right;
display: flex;
justify-content: space-between;
align-items: center;
gap: #{tokens.$cds-global-space-3};
margin-bottom: #{tokens.$cds-global-space-3};
@include mixins.generate-typography-token('TableHeaders-11-SB-CPT');

.datagrid-filter-title {
display: inline-flex;
}

.close {
float: none;
font-size: unset;
}
}

Expand Down
1 change: 1 addition & 0 deletions projects/angular/src/data/datagrid/datagrid-filter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default function (): void {
toggleService,
'browser' as any,
undefined,
undefined,
undefined
);
});
Expand Down
35 changes: 28 additions & 7 deletions projects/angular/src/data/datagrid/datagrid-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { isPlatformBrowser } from '@angular/common';
import {
ChangeDetectorRef,
Component,
ElementRef,
EventEmitter,
Expand Down Expand Up @@ -72,6 +73,7 @@ import { KeyNavigationGridController } from './utils/key-navigation-grid.control
[attr.aria-label]="commonStrings.keys.datagridFilterDialogAriaLabel"
>
<div class="datagrid-filter-close-wrapper">
<span class="datagrid-filter-title">{{ filterTitle }}</span>
<button type="button" class="close" clrPopoverCloseButton>
<cds-icon shape="window-close" [attr.title]="commonStrings.keys.close"></cds-icon>
</button>
Expand All @@ -90,6 +92,7 @@ export class ClrDatagridFilter<T = any>
ariaExpanded = false;
popoverId = uniqueIdFactory();
toggleButtonAriaLabel: string;
filterTitle: string;

// Smart Popover
smartPosition: ClrPopoverPosition = {
Expand All @@ -110,7 +113,8 @@ export class ClrDatagridFilter<T = any>
private smartToggleService: ClrPopoverToggleService,
@Inject(PLATFORM_ID) private platformId: any,
private elementRef: ElementRef<HTMLElement>,
@Optional() private keyNavigation: KeyNavigationGridController
@Optional() private keyNavigation: KeyNavigationGridController,
private cdr: ChangeDetectorRef
) {
super(_filters);
this.subs.push(
Expand Down Expand Up @@ -155,7 +159,11 @@ export class ClrDatagridFilter<T = any>

ngOnChanges() {
setTimeout(() => {
this.setToggleButtonAriaLabel();
const columnTitle = this.getColumnTitle();

this.setToggleButtonAriaLabel(columnTitle);
this.setTitle(columnTitle);
this.cdr.markForCheck();
});
}

Expand All @@ -168,14 +176,27 @@ export class ClrDatagridFilter<T = any>
* This is not in a getter to prevent "expression has changed after it was checked" errors.
* And it's more performant this way since it only runs on change.
*/
private setToggleButtonAriaLabel() {
const columnElement = this.elementRef.nativeElement?.closest('clr-dg-column');
const columnTitleElement = columnElement?.querySelector('.datagrid-column-title');

const columnTitle = columnTitleElement?.textContent.trim().toLocaleLowerCase();
private setToggleButtonAriaLabel(columnTitle: string) {
columnTitle = columnTitle?.toLocaleLowerCase();

this.toggleButtonAriaLabel = this.commonStrings.parse(this.commonStrings.keys.datagridFilterAriaLabel, {
COLUMN: columnTitle || '',
});
}

/**
* This is not in a getter to prevent "expression has changed after it was checked" errors.
*/
private setTitle(columnTitle: string) {
this.filterTitle = this.commonStrings.parse(this.commonStrings.keys.datagridFilterTitle, {
COLUMN: columnTitle || '',
});
}

private getColumnTitle() {
const columnElement = this.elementRef.nativeElement?.closest('clr-dg-column');
const columnTitleElement = columnElement?.querySelector('.datagrid-column-title');

return columnTitleElement?.textContent.trim();
}
}
1 change: 1 addition & 0 deletions projects/angular/src/utils/i18n/common-strings.default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const commonStringsDefault: ClrCommonStrings = {
singleActionableAriaLabel: 'Single actionable header',
detailExpandableAriaLabel: 'Toggle more row content',
datagridFilterAriaLabel: '{COLUMN} filter',
datagridFilterTitle: '{COLUMN} filter',
datagridFilterDialogAriaLabel: 'Filter dialog',
columnSeparatorAriaLabel: 'Column resize handle',
columnSeparatorDescription: 'Use left or right key to resize the column',
Expand Down
4 changes: 4 additions & 0 deletions projects/angular/src/utils/i18n/common-strings.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ export interface ClrCommonStrings {
* Datagrid filter toggle button
*/
datagridFilterAriaLabel: string;
/**
* Datagrid filter toggle button
*/
datagridFilterTitle: string;
/**
* Datagrid filter dialog
*/
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading