@hashicorp/design-system-components
Version:
Helios Design System Components
57 lines (52 loc) • 1.81 kB
JavaScript
import Component from '@glimmer/component';
import { service } from '@ember/service';
import { precompileTemplate } from '@ember/template-compilation';
import { g, i } from 'decorator-transforms/runtime';
import { setComponentTemplate } from '@ember/component';
var TEMPLATE = precompileTemplate("{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n<Hds::Text::Body class=\"hds-pagination-info\" @tag=\"div\" @size=\"100\" @weight=\"medium\" ...attributes>\n {{this.translatedItemsRange}}\n</Hds::Text::Body>");
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
class HdsPaginationInfo extends Component {
static {
g(this.prototype, "hdsIntl", [service]);
}
#hdsIntl = (i(this, "hdsIntl"), void 0);
get showTotalItems() {
return this.args.showTotalItems ?? true;
}
get translatedItemsRange() {
const {
itemsRangeStart,
itemsRangeEnd,
totalItems
} = this.args;
let translationKey;
let defaultValue;
let interpolationProps;
if (this.showTotalItems) {
translationKey = 'hds.components.pagination.info.page_range_with_total';
defaultValue = `${itemsRangeStart}–${itemsRangeEnd} of ${totalItems}`;
interpolationProps = {
itemsRangeStart,
itemsRangeEnd,
totalItems
};
} else {
translationKey = 'hds.components.pagination.info.page_range';
defaultValue = `${itemsRangeStart}–${itemsRangeEnd}`;
interpolationProps = {
itemsRangeStart,
itemsRangeEnd
};
}
return this.hdsIntl.t(translationKey, {
...interpolationProps,
default: defaultValue
});
}
}
setComponentTemplate(TEMPLATE, HdsPaginationInfo);
export { HdsPaginationInfo as default };
//# sourceMappingURL=index.js.map