Skip to content

Commit

Permalink
feat(Pagination): decouple the Pagination Component to separate package
Browse files Browse the repository at this point in the history
- in order to use this Pagination Component in other framework (like Aurelia-Slickgrid) without rewriting the same code, we can simply extract this into a brand new Pagination Component
  • Loading branch information
ghiscoding committed Jun 28, 2021
1 parent 4f03d0e commit 606795b
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 5 deletions.
22 changes: 22 additions & 0 deletions packages/pagination-component/README.md
@@ -0,0 +1,22 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/)
[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/)
[![npm](https://img.shields.io/npm/v/@slickgrid-universal/pagination-component.svg?color=forest)](https://www.npmjs.com/package/@slickgrid-universal/pagination-component)
[![npm](https://img.shields.io/npm/dy/@slickgrid-universal/pagination-component?color=forest)](https://www.npmjs.com/package/@slickgrid-universal/pagination-component)

[![Actions Status](https://github.com/ghiscoding/slickgrid-universal/workflows/CI%20Build/badge.svg)](https://github.com/ghiscoding/slickgrid-universal/actions)
[![Cypress.io](https://img.shields.io/badge/tested%20with-Cypress-04C38E.svg)](https://www.cypress.io/)
[![jest](https://jestjs.io/img/jest-badge.svg)](https://github.com/facebook/jest)
[![codecov](https://codecov.io/gh/ghiscoding/slickgrid-universal/branch/master/graph/badge.svg)](https://codecov.io/gh/ghiscoding/slickgrid-universal)

## Pagination Component
#### @slickgrid-universal/pagination-component

Vanilla Implementation of a Pagination Component that can optionally be shown at the bottom of the grid. This Pagination will automatically be enabled when using a Backend Service (like OData/GraphQL) but can also optionally be used with a local (in-memory) dataset as well, the data will still remain in memory but it will be shown with pagination.

### Internal Dependencies
- [@slickgrid-universal/binding](https://github.com/ghiscoding/slickgrid-universal/tree/master/packages/binding)
- [@slickgrid-universal/common](https://github.com/ghiscoding/slickgrid-universal/tree/master/packages/common)

### Installation
Follow the instruction provided in the main [README](https://github.com/ghiscoding/slickgrid-universal#installation)
55 changes: 55 additions & 0 deletions packages/pagination-component/package.json
@@ -0,0 +1,55 @@
{
"name": "@slickgrid-universal/pagination-component",
"version": "0.14.1",
"description": "Slick Pagination Component - Vanilla Implementation of a Pagination Component",
"main": "dist/commonjs/index.js",
"browser": "src/index.ts",
"module": "dist/esm/index.js",
"types": "dist/commonjs/index.d.ts",
"typings": "dist/commonjs/index.d.ts",
"publishConfig": {
"access": "public"
},
"directories": {
"src": "src"
},
"scripts": {
"build": "cross-env tsc --build",
"postbuild": "npm-run-all bundle:commonjs",
"build:watch": "cross-env tsc --incremental --watch",
"dev": "run-s build",
"dev:watch": "run-p build:watch",
"bundle": "run-p bundle:commonjs bundle:esm",
"bundle:commonjs": "tsc --project tsconfig.bundle.json --outDir dist/commonjs --module commonjs",
"postbundle:commonjs": "run-s copy:html:cjs",
"bundle:esm": "cross-env tsc --project tsconfig.bundle.json --outDir dist/esm --module esnext --target es2018",
"postbundle:esm": "run-s copy:html:esm",
"copy:html:cjs": "cross-env copyfiles -f src/*.html dist/commonjs",
"copy:html:esm": "cross-env copyfiles -f src/*.html dist/esm",
"prebundle": "npm-run-all delete:dist",
"delete:dist": "cross-env rimraf --maxBusyTries=10 dist",
"package:add-browser-prop": "cross-env node ../change-package-browser.js --add-browser=true --folder-name=pagination-component",
"package:remove-browser-prop": "cross-env node ../change-package-browser.js --remove-browser=true --folder-name=pagination-component"
},
"author": "Ghislain B.",
"license": "MIT",
"engines": {
"node": ">=14.15.0",
"npm": ">=6.14.8"
},
"browserslist": [
"last 2 version",
"> 1%",
"not dead"
],
"dependencies": {
"@slickgrid-universal/binding": "^0.14.1",
"@slickgrid-universal/common": "^0.14.1"
},
"devDependencies": {
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
"npm-run-all": "^4.1.5",
"rimraf": "^3.0.2"
}
}
2 changes: 2 additions & 0 deletions packages/pagination-component/src/.npmignore
@@ -0,0 +1,2 @@
index.ts
**/*.*
@@ -1,8 +1,8 @@

import { PaginationService, SharedService, SlickGrid, GridOption, Locale } from '@slickgrid-universal/common';
import { TranslateServiceStub } from '../../../../test/translateServiceStub';
import { EventPubSubService } from '../../../vanilla-bundle/src/services/eventPubSub.service';
import { SlickPaginationComponent } from '../slick-pagination.component';
import { TranslateServiceStub } from '../../../../../test/translateServiceStub';
import { EventPubSubService } from '../../services/eventPubSub.service';

function removeExtraSpaces(text: string) {
return `${text}`.replace(/\s{2,}/g, '');
Expand Down
@@ -1,8 +1,8 @@

import { PaginationService, SharedService, SlickGrid, GridOption } from '@slickgrid-universal/common';
import { TranslateServiceStub } from '../../../../test/translateServiceStub';
import { EventPubSubService } from '../../../vanilla-bundle/src/services/eventPubSub.service';
import { SlickPaginationComponent } from '../slick-pagination.component';
import { TranslateServiceStub } from '../../../../../test/translateServiceStub';
import { EventPubSubService } from '../../services/eventPubSub.service';

function removeExtraSpaces(text: string) {
return `${text}`.replace(/\s{2,}/g, '');
Expand Down
11 changes: 11 additions & 0 deletions packages/pagination-component/src/index.spec.ts
@@ -0,0 +1,11 @@
import * as entry from './index';

describe('Testing library entry point', () => {
it('should have an index entry point defined', () => {
expect(entry).toBeTruthy();
});

it('should have all exported object defined', () => {
expect(typeof entry.SlickPaginationComponent).toBe('function');
});
});
1 change: 1 addition & 0 deletions packages/pagination-component/src/index.ts
@@ -0,0 +1 @@
export * from './slick-pagination.component';
14 changes: 14 additions & 0 deletions packages/pagination-component/tsconfig.bundle.json
@@ -0,0 +1,14 @@
{
"extends": "../tsconfig.bundle.json",
"compilerOptions": {
"typeRoots": [
"../typings",
"../../node_modules/@types"
],
"outDir": "dist/commonjs"
},
"include": [
"../typings",
"**/*"
]
}
24 changes: 24 additions & 0 deletions packages/pagination-component/tsconfig.json
@@ -0,0 +1,24 @@
{
"extends": "../tsconfig.base.json",
"compileOnSave": false,
"compilerOptions": {
"rootDir": "src",
"declarationDir": "dist/esm",
"outDir": "dist/esm",
"typeRoots": [
"typings"
]
},
"exclude": [
"dist",
"node_modules",
"**/*.spec.ts"
],
"filesGlob": [
"./src/**/*.ts"
],
"include": [
"src/**/*.ts",
"typings/**/*.ts"
]
}
1 change: 1 addition & 0 deletions packages/vanilla-bundle/package.json
Expand Up @@ -51,6 +51,7 @@
"@slickgrid-universal/custom-footer-component": "^0.14.1",
"@slickgrid-universal/empty-warning-component": "^0.14.1",
"@slickgrid-universal/excel-export": "^0.14.1",
"@slickgrid-universal/pagination-component": "^0.14.1",
"@slickgrid-universal/text-export": "^0.14.1",
"whatwg-fetch": "^3.6.2"
},
Expand Down
Expand Up @@ -74,12 +74,12 @@ import {
import { SlickCompositeEditorComponent } from '@slickgrid-universal/composite-editor-component';
import { SlickEmptyWarningComponent } from '@slickgrid-universal/empty-warning-component';
import { SlickFooterComponent } from '@slickgrid-universal/custom-footer-component';
import { SlickPaginationComponent } from '@slickgrid-universal/pagination-component';

import { EventPubSubService } from '../services/eventPubSub.service';
import { TextExportService } from '../services/textExport.service';
import { ResizerService } from '../services/resizer.service';
import { SalesforceGlobalGridOptions } from '../salesforce-global-grid-options';
import { SlickPaginationComponent } from './slick-pagination.component';
import { SlickerGridInstance } from '../interfaces/slickerGridInstance.interface';
import { UniversalContainerService } from '../services/universalContainer.service';

Expand Down

0 comments on commit 606795b

Please sign in to comment.