shoelace/src/components/format-bytes/format-bytes.ts

26 wiersze
603 B
TypeScript

import { LitElement, customElement, property } from 'lit-element';
import { formatBytes } from '../../internal/number';
/**
* @since 2.0
* @status stable
*/
@customElement('sl-format-bytes')
export class SlFormatBytes extends LitElement {
/** The number to format in bytes. */
@property({ type: Number }) value = 0;
/** The unit to display. */
@property() unit: 'bytes' | 'bits' = 'bytes';
/** The locale to use when formatting the number. */
@property() locale: string;
render() {
return formatBytes(this.value, {
unit: this.unit,
locale: this.locale
});
}
}