Use localization for default tooltip formatter

pull/1912/head
Matt Pharoah 2024-03-25 18:22:19 -04:00
rodzic 450e3296d0
commit 3b83126851
1 zmienionych plików z 6 dodań i 1 usunięć

Wyświetl plik

@ -110,7 +110,7 @@ export default class SlMultiRange extends ShoelaceElement implements ShoelaceFor
* A function used to format the tooltip's value. The range's value is passed as the first and only argument. The
* function should return a string to display in the tooltip.
*/
@property({ attribute: false }) tooltipFormatter: (value: number) => string = (value: number) => value.toString();
@property({ attribute: false }) tooltipFormatter: (value: number) => string;
@query('.base') baseDiv: HTMLDivElement;
@query('.active-track') activeTrack: HTMLDivElement;
@ -131,6 +131,11 @@ export default class SlMultiRange extends ShoelaceElement implements ShoelaceFor
return this.#localize.dir() === 'rtl';
}
constructor() {
super();
this.tooltipFormatter = this.#localize.number.bind(this.#localize);
}
override render(): unknown {
const hasLabel = !!(this.label || this.#hasSlotController.test('label'));
const hasHelpText = !!(this.helpText || this.#hasSlotController.test('help-text'));