Skip to content

Commit ad6e9c7

Browse files
committed
fix(table): add a label for the "Select all rows" checkbox
1 parent d8e2704 commit ad6e9c7

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

etc/lime-elements.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ export namespace Components {
718718
"columns": Column[];
719719
"data": object[];
720720
"emptyMessage": string;
721+
"language": Languages;
721722
"layout": Layout;
722723
"loading": boolean;
723724
"mode": 'local' | 'remote';
@@ -1845,6 +1846,7 @@ export namespace JSX {
18451846
"columns"?: Column[];
18461847
"data"?: object[];
18471848
"emptyMessage"?: string;
1849+
"language"?: Languages;
18481850
"layout"?: Layout;
18491851
"loading"?: boolean;
18501852
"mode"?: 'local' | 'remote';

src/components/table/table.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import { ElementPool } from './element-pool';
2222
import { TableSelection } from './table-selection';
2323
import { mapLayout, Layout } from './layout';
2424
import { areRowsEqual } from './utils';
25+
import { Languages } from '../date-picker/date.types';
26+
import translate from '../../global/translations';
2527

2628
const FIRST_PAGE = 1;
2729

@@ -158,6 +160,12 @@ export class Table {
158160
@Prop()
159161
public selection: object[];
160162

163+
/**
164+
* Defines the language for translations.
165+
*/
166+
@Prop({ reflect: true })
167+
public language: Languages = 'en';
168+
161169
/**
162170
* Emitted when `mode` is `remote` and the table is loading new data. The
163171
* consumer is responsible for giving the table new data
@@ -852,13 +860,15 @@ export class Table {
852860
style={{ display: showSelectAll ? 'inline-block' : 'none' }}
853861
>
854862
<limel-checkbox
863+
class="hide-label"
855864
onChange={this.selectAllOnChange}
856865
disabled={this.data.length === 0}
857866
checked={this.tableSelection?.hasSelection}
858867
indeterminate={
859868
this.tableSelection?.hasSelection &&
860869
this.selection?.length < this.data.length
861870
}
871+
label={this.getTranslation('table.select-all')}
862872
/>
863873
</div>
864874
);
@@ -877,4 +887,8 @@ export class Table {
877887
</div>
878888
);
879889
}
890+
891+
private getTranslation = (key: string) => {
892+
return translate.get(key, this.language);
893+
};
880894
}

0 commit comments

Comments
 (0)