@slickgrid-universal/pagination-component
Advanced tools
Comparing version 3.7.1 to 4.0.0-alpha.0
@@ -1,6 +0,5 @@ | ||
import { Constants, createDomElement, getTranslationPrefix, } from '@slickgrid-universal/common'; | ||
import { Constants, createDomElement, getTranslationPrefix } from '@slickgrid-universal/common'; | ||
import { BindingHelper } from '@slickgrid-universal/binding'; | ||
export class SlickPaginationComponent { | ||
constructor(paginationService, pubSubService, sharedService, translaterService) { | ||
var _a, _b, _c, _d, _e; | ||
this.paginationService = paginationService; | ||
@@ -24,3 +23,3 @@ this.pubSubService = pubSubService; | ||
this.currentPagination = this.paginationService.getFullPagination(); | ||
this._enableTranslate = (_b = (_a = this.gridOptions) === null || _a === void 0 ? void 0 : _a.enableTranslate) !== null && _b !== void 0 ? _b : false; | ||
this._enableTranslate = this.gridOptions?.enableTranslate ?? false; | ||
if (this._enableTranslate && (!this.translaterService || !this.translaterService.translate)) { | ||
@@ -30,4 +29,4 @@ throw new Error('[Slickgrid-Universal] requires a Translate Service to be installed and configured when the grid option "enableTranslate" is enabled.'); | ||
this.translatePaginationTexts(); | ||
if (this._enableTranslate && ((_c = this.pubSubService) === null || _c === void 0 ? void 0 : _c.subscribe)) { | ||
const translateEventName = (_e = (_d = this.translaterService) === null || _d === void 0 ? void 0 : _d.eventName) !== null && _e !== void 0 ? _e : 'onLanguageChange'; | ||
if (this._enableTranslate && this.pubSubService?.subscribe) { | ||
const translateEventName = this.translaterService?.eventName ?? 'onLanguageChange'; | ||
this._subscriptions.push(this.pubSubService.subscribe(translateEventName, () => this.translatePaginationTexts())); | ||
@@ -43,3 +42,3 @@ } | ||
const pageFromToElm = document.querySelector(`.${this.gridUid} span.page-info-from-to`); | ||
if (pageFromToElm === null || pageFromToElm === void 0 ? void 0 : pageFromToElm.style) { | ||
if (pageFromToElm?.style) { | ||
pageFromToElm.style.display = (this.currentPagination.totalItems === 0) ? 'none' : ''; | ||
@@ -80,9 +79,7 @@ } | ||
get gridUid() { | ||
var _a, _b; | ||
return (_b = (_a = this.grid) === null || _a === void 0 ? void 0 : _a.getUID()) !== null && _b !== void 0 ? _b : ''; | ||
return this.grid?.getUID() ?? ''; | ||
} | ||
get locales() { | ||
var _a, _b; | ||
// get locales provided by user in main file or else use default English locales via the Constants | ||
return (_b = (_a = this.gridOptions) === null || _a === void 0 ? void 0 : _a.locales) !== null && _b !== void 0 ? _b : Constants.locales; | ||
return this.gridOptions?.locales ?? Constants.locales; | ||
} | ||
@@ -125,3 +122,3 @@ get totalItems() { | ||
this._paginationElement.appendChild(paginationElm); | ||
if ((gridParentContainerElm === null || gridParentContainerElm === void 0 ? void 0 : gridParentContainerElm.appendChild) && this._paginationElement) { | ||
if (gridParentContainerElm?.appendChild && this._paginationElement) { | ||
gridParentContainerElm.appendChild(this._paginationElement); | ||
@@ -169,3 +166,3 @@ } | ||
this._bindingHelper.bindEventHandler('.icon-seek-prev', 'click', this.changeToPreviousPage.bind(this)); | ||
this._bindingHelper.bindEventHandler('select.items-per-page', 'change', (event) => { var _a, _b; return this.itemsPerPage = +((_b = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0); }); | ||
this._bindingHelper.bindEventHandler('select.items-per-page', 'change', (event) => this.itemsPerPage = +(event?.target?.value ?? 0)); | ||
} | ||
@@ -197,4 +194,3 @@ changeToFirstPage(event) { | ||
translatePaginationTexts() { | ||
var _a; | ||
if (this._enableTranslate && ((_a = this.translaterService) === null || _a === void 0 ? void 0 : _a.translate)) { | ||
if (this._enableTranslate && this.translaterService?.translate) { | ||
const translationPrefix = getTranslationPrefix(this.gridOptions); | ||
@@ -201,0 +197,0 @@ this.textItemsPerPage = this.translaterService.translate(`${translationPrefix}ITEMS_PER_PAGE`); |
@@ -1,3 +0,2 @@ | ||
import type { GridOption, Locale, PaginationService, PubSubService, ServicePagination, SharedService, Subscription, TranslaterService } from '@slickgrid-universal/common'; | ||
import { SlickGrid } from '@slickgrid-universal/common'; | ||
import type { GridOption, Locale, PaginationService, PubSubService, ServicePagination, SharedService, SlickGrid, Subscription, TranslaterService } from '@slickgrid-universal/common'; | ||
import { BindingHelper } from '@slickgrid-universal/binding'; | ||
@@ -4,0 +3,0 @@ export declare class SlickPaginationComponent { |
{ | ||
"name": "@slickgrid-universal/pagination-component", | ||
"version": "3.7.1", | ||
"version": "4.0.0-alpha.0", | ||
"description": "Slick Pagination Component - Vanilla Implementation of a Pagination Component", | ||
"main": "./dist/commonjs/index.js", | ||
"main": "./dist/cjs/index.js", | ||
"module": "./dist/esm/index.js", | ||
@@ -18,4 +18,4 @@ "types": "index.d.ts", | ||
"types": "./dist/types/index.d.ts", | ||
"node": "./dist/commonjs/index.js", | ||
"require": "./dist/commonjs/index.js", | ||
"node": "./dist/cjs/index.js", | ||
"require": "./dist/cjs/index.js", | ||
"default": "./dist/esm/index.js" | ||
@@ -48,6 +48,6 @@ }, | ||
"dependencies": { | ||
"@slickgrid-universal/binding": "~3.7.0", | ||
"@slickgrid-universal/common": "~3.7.1" | ||
"@slickgrid-universal/binding": "~4.0.0-alpha.0", | ||
"@slickgrid-universal/common": "~4.0.0-alpha.0" | ||
}, | ||
"gitHead": "25608bee3ad812f08787fa1c13f1700391daa23a" | ||
"gitHead": "0ee39f0a19b203f6b9f3dc389cdcf6801da0b265" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
4
1
160668
2596
649
1
+ Added@slickgrid-universal/binding@4.0.2(transitive)
+ Added@slickgrid-universal/common@4.0.3(transitive)
+ Added@slickgrid-universal/event-pub-sub@4.0.2(transitive)
+ Added@slickgrid-universal/utils@4.0.2(transitive)
+ Addedmultiple-select-vanilla@1.2.5(transitive)
- Removed@slickgrid-universal/binding@3.7.0(transitive)
- Removed@slickgrid-universal/common@3.7.2(transitive)
- Removed@slickgrid-universal/event-pub-sub@3.7.0(transitive)
- Removed@slickgrid-universal/utils@3.7.0(transitive)
- Removedmultiple-select-vanilla@0.6.3(transitive)
- Removedslickgrid@4.1.7(transitive)