@hashicorp/design-system-components
Version:
Helios Design System Components
62 lines (59 loc) • 1.83 kB
JavaScript
import Component from '@glimmer/component';
import { service } from '@ember/service';
import HdsTextBody from '../../text/body.js';
import { precompileTemplate } from '@ember/template-compilation';
import { setComponentTemplate } from '@ember/component';
import { g, i } from 'decorator-transforms/runtime';
/**
* Copyright IBM Corp. 2021, 2025
* 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
});
}
static {
setComponentTemplate(precompileTemplate("<HdsTextBody class=\"hds-pagination-info\" @tag=\"div\" @size=\"100\" @weight=\"medium\" ...attributes>\n {{this.translatedItemsRange}}\n</HdsTextBody>", {
strictMode: true,
scope: () => ({
HdsTextBody
})
}), this);
}
}
export { HdsPaginationInfo as default };
//# sourceMappingURL=index.js.map