Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination: implements items per page prop #1697

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
4642352
added items per page prop
tishoyanchev Jan 22, 2025
9e72152
clean install
tishoyanchev Jan 22, 2025
cdd7bc9
npm install
tishoyanchev Jan 22, 2025
e5e5c4d
Merge cdd7bc968df85e5ac5de915c92d6a3efa45cce7a into 8a7cd5fa111b126f6…
tishoyanchev Jan 22, 2025
386d56c
Update Stencil library version to 31.0.0--canary.1697.e5e5c4da838c535…
invalid-email-address Jan 22, 2025
2dd961b
updated stories + table + example apps
tishoyanchev Jan 23, 2025
d8b570e
Merge branch '1665-pagination-make-items-per-page-customizable' of ht…
tishoyanchev Jan 23, 2025
75ba6c5
Merge d8b570e92ee41829f8d1ed96ec940126c246652f into 8a7cd5fa111b126f6…
tishoyanchev Jan 23, 2025
1290c67
Update Stencil library version to 31.0.0--canary.1697.75ba6c50a31eb82…
invalid-email-address Jan 23, 2025
a2cd5aa
clean install
tishoyanchev Jan 23, 2025
3a757c8
Merge branch '1665-pagination-make-items-per-page-customizable' of ht…
tishoyanchev Jan 23, 2025
f45ea0a
npm install
tishoyanchev Jan 23, 2025
d182a3c
Merge f45ea0a1880676628bdb197ee8631196669dc717 into 8a7cd5fa111b126f6…
tishoyanchev Jan 23, 2025
ab5fdde
Update Stencil library version to 31.0.0--canary.1697.d182a3c648fcdb6…
invalid-email-address Jan 23, 2025
006dddb
Merge branch 'master' into 1665-pagination-make-items-per-page-custom…
tishoyanchev Feb 4, 2025
223df0f
Merge 006dddb424402fa6dfd8154d92eb8643c55b1b36 into e0aae4ac1fb286ccb…
tishoyanchev Feb 4, 2025
50acc20
Update Stencil library version to 31.0.0--canary.1697.223df0ff1431a53…
invalid-email-address Feb 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/wrapper-components/react-vite-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"test:local": "run-p preview:link watch:library"
},
"dependencies": {
"@infineon/infineon-design-system-react": "30.9.2--canary.1673.aae465494350113a03d5687dfe66c3823dc98f42.0",
"@infineon/infineon-design-system-react": "31.0.0--canary.1697.d182a3c648fcdb68889698ab9252e421f923fb47.0",
"path": "^0.12.7",
"react": "^18.3.1",
"react-dom": "^18.3.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default function App() {
currentPage={1}
total={36}
onIfxPageChange={handlePageChange}
items-per-page='[{"value":"ten","label":"10","selected":true}, {"value":"Twenty","label":"20","selected":false}, {"value":"Thirty","label":"30","selected":false}]'
/>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion examples/wrapper-components/vue-javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"test:local": "run-p preview:link watch:library"
},
"dependencies": {
"@infineon/infineon-design-system-vue": "30.9.2--canary.1673.aae465494350113a03d5687dfe66c3823dc98f42.0",
"@infineon/infineon-design-system-vue": "31.0.0--canary.1697.d182a3c648fcdb68889698ab9252e421f923fb47.0",
"@vitejs/plugin-vue": "^4.0.0",
"@vitejs/plugin-vue-jsx": "^4.0.0",
"vite": "^5.0.12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div>
<h2>Pagination</h2>
<ifx-pagination @ifxPageChange="handleChange" @ifxPrevPage="handleChange" @ifxNextPage="handleChange" total="500"
items-per-page='[{"value":"ten","label":"10","selected":true}, {"value":"Twenty","label":"20","selected":false}, {"value":"Thirty","label":"30","selected":false}]'
:current-page="current"></ifx-pagination>
</div>
</template>
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "30.9.2--canary.1673.aae465494350113a03d5687dfe66c3823dc98f42.0",
"version": "31.0.0--canary.1697.d182a3c648fcdb68889698ab9252e421f923fb47.0",
"command": {
"publish": {
"verifyAccess": false
Expand Down
1,451 changes: 776 additions & 675 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/components-angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "components-angular",
"version": "30.9.2--canary.1673.aae465494350113a03d5687dfe66c3823dc98f42.0",
"version": "31.0.0--canary.1697.d182a3c648fcdb68889698ab9252e421f923fb47.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand All @@ -26,7 +26,7 @@
"@angular/platform-browser": "^18.0.0",
"@angular/platform-browser-dynamic": "^18.0.0",
"@angular/router": "^18.0.0",
"@infineon/infineon-design-system-angular": "^30.9.2--canary.1673.aae465494350113a03d5687dfe66c3823dc98f42.0",
"@infineon/infineon-design-system-angular": "^31.0.0--canary.1697.d182a3c648fcdb68889698ab9252e421f923fb47.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"typescript": "~5.4.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@infineon/infineon-design-system-angular",
"version": "30.9.2--canary.1673.aae465494350113a03d5687dfe66c3823dc98f42.0",
"version": "31.0.0--canary.1697.d182a3c648fcdb68889698ab9252e421f923fb47.0",
"description": "Infineon design system Stencil web components for Angular",
"author": "Verena Lechner",
"license": "MIT",
Expand All @@ -11,7 +11,7 @@
"@angular/common": "^18.0.0",
"@angular/core": "^18.0.0",
"@infineon/design-system-tokens": "3.3.4",
"@infineon/infineon-design-system-stencil": "30.9.2--canary.1673.aae465494350113a03d5687dfe66c3823dc98f42.0"
"@infineon/infineon-design-system-stencil": "31.0.0--canary.1697.d182a3c648fcdb68889698ab9252e421f923fb47.0"
},
"dependencies": {
"tslib": "^2.3.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ <h2>Number Indicator</h2>
<br />

<h2>Pagination</h2>
<ifx-pagination total="500" current-page="1"></ifx-pagination>
<ifx-pagination total="500" current-page="1" items-per-page='[{"value":"ten","label":"10","selected":true}, {"value":"Twenty","label":"20","selected":false}, {"value":"Thirty","label":"30","selected":false}]'></ifx-pagination>
<br />
<br />

Expand Down
4 changes: 2 additions & 2 deletions packages/components-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@infineon/infineon-design-system-react",
"version": "30.9.2--canary.1673.aae465494350113a03d5687dfe66c3823dc98f42.0",
"version": "31.0.0--canary.1697.d182a3c648fcdb68889698ab9252e421f923fb47.0",
"description": "Infineon design system Stencil web components for React",
"main": "./dist/index.js",
"types": "./dist/types/index.d.ts",
Expand Down Expand Up @@ -28,7 +28,7 @@
},
"dependencies": {
"@infineon/design-system-tokens": "3.3.4",
"@infineon/infineon-design-system-stencil": "^30.9.2--canary.1673.aae465494350113a03d5687dfe66c3823dc98f42.0",
"@infineon/infineon-design-system-stencil": "^31.0.0--canary.1697.d182a3c648fcdb68889698ab9252e421f923fb47.0",
"@stencil/react-output-target": "^0.7.1"
},
"auto": {
Expand Down
4 changes: 2 additions & 2 deletions packages/components-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@infineon/infineon-design-system-vue",
"version": "30.9.2--canary.1673.aae465494350113a03d5687dfe66c3823dc98f42.0",
"version": "31.0.0--canary.1697.d182a3c648fcdb68889698ab9252e421f923fb47.0",
"description": "Infineon design system Stencil web components for Vue",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -30,7 +30,7 @@
},
"dependencies": {
"@infineon/design-system-tokens": "3.3.4",
"@infineon/infineon-design-system-stencil": "^30.9.2--canary.1673.aae465494350113a03d5687dfe66c3823dc98f42.0"
"@infineon/infineon-design-system-stencil": "^31.0.0--canary.1697.d182a3c648fcdb68889698ab9252e421f923fb47.0"
},
"auto": {
"plugins": [
Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@infineon/infineon-design-system-stencil",
"version": "30.9.2--canary.1673.aae465494350113a03d5687dfe66c3823dc98f42.0",
"version": "31.0.0--canary.1697.d182a3c648fcdb68889698ab9252e421f923fb47.0",
"private": false,
"description": "Infineon design system Stencil web components",
"homepage": "https://infineon.github.io/infineon-design-system-stencil",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default {
args: {
total: 50,
currentPage: 1,
itemsPerPage: '[{"value":"ten","label":"10","selected":true}, {"value":"Twenty","label":"20","selected":false}, {"value":"Thirty","label":"30","selected":false}]'
},
argTypes: {
ifxPageChange: {
Expand Down Expand Up @@ -49,6 +50,7 @@ const DefaultTemplate = args => {
const element = document.createElement('ifx-pagination');
element.setAttribute('total', args.total);
element.setAttribute('current-page', args.currentPage);
element.setAttribute('items-per-page', args.itemsPerPage);
element.addEventListener('ifxPageChange', action('ifxPageChange'));
return element;
};
Expand Down
15 changes: 8 additions & 7 deletions packages/components/src/components/pagination/pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ export class Pagination {
@Event() ifxPrevPage: EventEmitter;
@Prop() currentPage: number = 0;
@State() internalPage: number = 1;
@State() itemsPerPage: number = 10;
@State() internalItemsPerPage: number = 10;
@State() numberOfPages: number[] = [];
@Prop() total: number = 1;
@Prop() itemsPerPage: any[] | string;

private CLASS_DISABLED = "disabled"
private CLASS_ACTIVE = "active"
Expand All @@ -25,9 +26,9 @@ export class Pagination {
@Listen('ifxSelect')
setItemsPerPage(e) {
if(e.detail) {
this.itemsPerPage = parseInt(e.detail.label)
this.internalItemsPerPage = parseInt(e.detail.label)
} else {
this.itemsPerPage = 10;
this.internalItemsPerPage = 10;
}
}

Expand All @@ -43,8 +44,8 @@ export class Pagination {
if (isNaN(this.currentPage)) {
this.currentPage = 1;
}
const total = this.total <= this.itemsPerPage ? this.itemsPerPage : this.total;
const itemsPerPage = this.itemsPerPage;
const total = this.total <= this.internalItemsPerPage ? this.internalItemsPerPage : this.total;
const itemsPerPage = this.internalItemsPerPage;
const totalPageNumber = Math.ceil(total / itemsPerPage);

if (this.currentPage <= 0) {
Expand Down Expand Up @@ -81,7 +82,7 @@ export class Pagination {
let totalPages = this.numberOfPages.length;
let prevPage = currActive === 0 ? null : currActive;
let nextPage = currActive + 2 > totalPages ? null : currActive + 2;
let itemsPerPage = this.itemsPerPage
let itemsPerPage = this.internalItemsPerPage
this.ifxPageChange.emit({ currentPage, totalPages, prevPage, nextPage, itemsPerPage })
}

Expand Down Expand Up @@ -188,7 +189,7 @@ export class Pagination {
error-message='Error'
label=''
placeholder-value='Placeholder'
options='[{"value":"ten","label":"10","selected":true}, {"value":"Twenty","label":"20","selected":false}, {"value":"Thirty","label":"30","selected":false}]' >
options={this.itemsPerPage} >
</ifx-select>
</div>
</div>
Expand Down
9 changes: 5 additions & 4 deletions packages/components/src/components/pagination/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

## Properties

| Property | Attribute | Description | Type | Default |
| ------------- | -------------- | ----------- | -------- | ------- |
| `currentPage` | `current-page` | | `number` | `0` |
| `total` | `total` | | `number` | `1` |
| Property | Attribute | Description | Type | Default |
| -------------- | ---------------- | ----------- | ----------------- | ----------- |
| `currentPage` | `current-page` | | `number` | `0` |
| `itemsPerPage` | `items-per-page` | | `any[] \| string` | `undefined` |
| `total` | `total` | | `number` | `1` |


## Events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ export class Table {
<div id={`ifxTable-${this.uniqueKey}`} class='ifx-ag-grid' style={style} ref={(el) => this.container = el}>
</div>
</div>
{this.pagination ? <ifx-pagination total={this.allRowData.length} current-page={this.currentPage}></ifx-pagination> : null}
{this.pagination ? <ifx-pagination total={this.allRowData.length} current-page={this.currentPage} items-per-page='[{"value":"ten","label":"10","selected":true}, {"value":"Twenty","label":"20","selected":false}, {"value":"Thirty","label":"30","selected":false}]'></ifx-pagination> : null}
</div>
</div>
</div>
Expand Down
Loading