@everymatrix/helper-pagination 0.1.24 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/helper-pagination.cjs.entry.js +43 -24
- package/dist/cjs/helper-pagination.cjs.js +2 -2
- package/dist/cjs/{index-4f0b2d1c.js → index-7c071a78.js} +13 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/components/helper-pagination/helper-pagination.css +4 -4
- package/dist/collection/components/helper-pagination/helper-pagination.js +123 -46
- package/dist/collection/utils/locale.utils.js +7 -1
- package/dist/components/helper-pagination.js +51 -28
- package/dist/esm/helper-pagination.entry.js +43 -24
- package/dist/esm/helper-pagination.js +2 -2
- package/dist/esm/{index-fe031733.js → index-b281577e.js} +13 -0
- package/dist/esm/loader.js +2 -2
- package/dist/helper-pagination/helper-pagination.esm.js +1 -1
- package/dist/helper-pagination/p-c5036ea6.entry.js +1 -0
- package/dist/helper-pagination/p-eab215a1.js +1 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/helper-pagination/.stencil/packages/helper-pagination/stencil.config.d.ts +2 -0
- package/dist/types/components/helper-pagination/helper-pagination.d.ts +23 -7
- package/dist/types/components.d.ts +36 -12
- package/package.json +2 -2
- package/dist/helper-pagination/p-68c68be2.js +0 -1
- package/dist/helper-pagination/p-8258fc5c.entry.js +0 -1
- package/dist/types/Users/dragos.bodea/Documents/everymatrix-prjs/stencil/widgets-stencil/packages/helper-pagination/.stencil/packages/helper-pagination/stencil.config.d.ts +0 -2
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-7c071a78.js');
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @name isMobile
|
|
@@ -18,7 +18,7 @@ const isMobile = (userAgent) => {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const DEFAULT_LANGUAGE = 'en';
|
|
21
|
-
const SUPPORTED_LANGUAGES = ['ro', 'en'];
|
|
21
|
+
const SUPPORTED_LANGUAGES = ['ro', 'en', 'hu'];
|
|
22
22
|
const TRANSLATIONS = {
|
|
23
23
|
en: {
|
|
24
24
|
firstPage: 'First',
|
|
@@ -43,6 +43,12 @@ const TRANSLATIONS = {
|
|
|
43
43
|
previousPage: 'Previous',
|
|
44
44
|
nextPage: 'Next',
|
|
45
45
|
lastPage: 'Last'
|
|
46
|
+
},
|
|
47
|
+
hu: {
|
|
48
|
+
firstPage: 'First',
|
|
49
|
+
previousPage: 'Previous',
|
|
50
|
+
nextPage: 'Következő',
|
|
51
|
+
lastPage: 'Last'
|
|
46
52
|
}
|
|
47
53
|
};
|
|
48
54
|
const translate = (key, customLang) => {
|
|
@@ -50,20 +56,20 @@ const translate = (key, customLang) => {
|
|
|
50
56
|
return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
51
57
|
};
|
|
52
58
|
|
|
53
|
-
const helperPaginationCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}#PaginationContainer{width:100%;margin
|
|
59
|
+
const helperPaginationCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}#PaginationContainer{width:100%;margin:20px 0;display:inline-flex;justify-content:space-between;align-items:center}.LeftItems button:not(:first-child),.RightItems button:not(:last-child){margin:0 10px}.LeftItems button,.RightItems button{padding:0;background-color:#009993;border-color:#009993}.PaginationArea{display:inline-flex;gap:10px;list-style:none}.PaginationArea li{margin:0;padding:0}.PaginationArea li button{width:24px;height:24px;display:flex;border:0;padding:0;justify-content:center;align-items:center;background-color:transparent;color:#000;cursor:pointer;pointer-events:all}.PaginationItem.ActiveItem button{background:#009993;border-color:#009993;color:#fff}.PaginationItem.ActiveItem button:disabled{pointer-events:none;cursor:not-allowed}.PaginationItem button:hover,.PaginationItem button:active{background:#009993;border-color:#009993;color:#fff;opacity:0.8}button{width:100px;height:32px;border:1px solid #524e52;border-radius:5px;background:#524e52;color:#fff;font-size:14px;font:inherit;cursor:pointer;transition:all 0.1s linear;text-transform:uppercase;text-align:center;letter-spacing:0}button:hover,button:active{background:#004D4A;border-color:#004D4A}button:disabled{background-color:#ccc;border-color:#ccc;color:#fff;cursor:not-allowed}@media screen and (max-width: 720px){button{width:90px;font-size:14px}}@media screen and (max-width: 480px){button{width:70px;font-size:14px}.paginationArea{padding:5px}}@media screen and (max-width: 320px){button{width:58px;font-size:12px}.paginationArea{padding:5px;gap:5px}}@media (hover: none){.paginationItem button:hover{background:inherit;border-color:inherit;color:inherit;opacity:1}.paginationItem.activeItem button:hover{background:#009993;border-color:#009993;color:#fff}}";
|
|
54
60
|
|
|
55
61
|
const HelperPagination = class {
|
|
56
62
|
constructor(hostRef) {
|
|
57
63
|
index.registerInstance(this, hostRef);
|
|
58
64
|
this.hpPageChange = index.createEvent(this, "hpPageChange", 7);
|
|
59
65
|
/**
|
|
60
|
-
*
|
|
66
|
+
* Next page string value - determines if the next page is disabled or active
|
|
61
67
|
*/
|
|
62
|
-
this.
|
|
68
|
+
this.nextPage = '';
|
|
63
69
|
/**
|
|
64
|
-
* Previous page
|
|
70
|
+
* Previous page string value - determines if the previous page is disabled or active
|
|
65
71
|
*/
|
|
66
|
-
this.
|
|
72
|
+
this.prevPage = '';
|
|
67
73
|
/**
|
|
68
74
|
* The received offset
|
|
69
75
|
*/
|
|
@@ -81,13 +87,21 @@ const HelperPagination = class {
|
|
|
81
87
|
*/
|
|
82
88
|
this.language = 'en';
|
|
83
89
|
/**
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
* Client custom styling via string
|
|
91
|
+
*/
|
|
86
92
|
this.clientStyling = '';
|
|
87
93
|
/**
|
|
88
94
|
* Client custom styling via url content
|
|
89
95
|
*/
|
|
90
96
|
this.clientStylingUrlContent = '';
|
|
97
|
+
/**
|
|
98
|
+
* Component working variable for last page
|
|
99
|
+
*/
|
|
100
|
+
this.lastPage = false;
|
|
101
|
+
/**
|
|
102
|
+
* Component working variable for prvious page
|
|
103
|
+
*/
|
|
104
|
+
this.previousPage = false;
|
|
91
105
|
/**
|
|
92
106
|
* In component working variable for the array of pages
|
|
93
107
|
*/
|
|
@@ -111,32 +125,35 @@ const HelperPagination = class {
|
|
|
111
125
|
this.offsetInt = this.endInt * this.limitInt;
|
|
112
126
|
break;
|
|
113
127
|
case 'previousPage':
|
|
114
|
-
this.offsetInt -=
|
|
128
|
+
this.offsetInt -= this.limitInt;
|
|
115
129
|
break;
|
|
116
130
|
case 'nextPage':
|
|
117
|
-
this.offsetInt +=
|
|
131
|
+
this.offsetInt += this.limitInt;
|
|
118
132
|
break;
|
|
119
133
|
case 'fivePagesBack':
|
|
120
|
-
this.offsetInt -=
|
|
121
|
-
this.offsetInt = this.offsetInt
|
|
134
|
+
this.offsetInt -= this.limitInt * 5;
|
|
135
|
+
this.offsetInt = this.offsetInt <= 0 ? 0 : this.offsetInt;
|
|
122
136
|
break;
|
|
123
137
|
case 'fivePagesForward':
|
|
124
|
-
this.offsetInt +=
|
|
125
|
-
this.offsetInt = this.offsetInt /
|
|
138
|
+
this.offsetInt += this.limitInt * 5;
|
|
139
|
+
this.offsetInt = this.offsetInt / this.limitInt >= this.endInt ? this.endInt * this.limitInt : this.offsetInt;
|
|
126
140
|
break;
|
|
127
141
|
}
|
|
142
|
+
this.previousPage = !this.offsetInt ? false : true;
|
|
128
143
|
this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
|
|
129
144
|
};
|
|
130
145
|
/**
|
|
131
146
|
* Handle navigation from here
|
|
132
147
|
*/
|
|
133
148
|
this.paginationNavigation = (pageNumber, index) => {
|
|
149
|
+
this.previousPage = true;
|
|
134
150
|
if (!isNaN(pageNumber)) {
|
|
135
151
|
if (pageNumber === 1) {
|
|
136
152
|
this.offsetInt = pageNumber - 1;
|
|
153
|
+
this.previousPage = false;
|
|
137
154
|
}
|
|
138
155
|
else {
|
|
139
|
-
this.offsetInt = (pageNumber - 1) *
|
|
156
|
+
this.offsetInt = (pageNumber - 1) * this.limitInt;
|
|
140
157
|
}
|
|
141
158
|
}
|
|
142
159
|
else {
|
|
@@ -150,7 +167,6 @@ const HelperPagination = class {
|
|
|
150
167
|
this.navigateTo('fivePagesForward');
|
|
151
168
|
}
|
|
152
169
|
}
|
|
153
|
-
this.currentPage = this.offsetInt;
|
|
154
170
|
this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
|
|
155
171
|
};
|
|
156
172
|
this.setClientStyling = () => {
|
|
@@ -168,7 +184,8 @@ const HelperPagination = class {
|
|
|
168
184
|
}
|
|
169
185
|
componentWillRender() {
|
|
170
186
|
this.offsetInt = this.offset;
|
|
171
|
-
this.
|
|
187
|
+
this.limitInt = this.limit;
|
|
188
|
+
this.currentPage = (this.offsetInt / this.limitInt) + 1;
|
|
172
189
|
this.limitInt = this.limit;
|
|
173
190
|
this.totalInt = this.total;
|
|
174
191
|
this.endInt = (Math.ceil(this.totalInt / this.limitInt) - 1);
|
|
@@ -176,7 +193,7 @@ const HelperPagination = class {
|
|
|
176
193
|
/**
|
|
177
194
|
* Construct numbered navigation area based on current page position
|
|
178
195
|
*/
|
|
179
|
-
if (this.currentPage
|
|
196
|
+
if (this.currentPage == 1 || this.currentPage == 2) {
|
|
180
197
|
this.pagesArray = Array.from({ length: 4 }, (_, i) => i + 1);
|
|
181
198
|
this.pagesArray.push('...');
|
|
182
199
|
}
|
|
@@ -211,20 +228,22 @@ const HelperPagination = class {
|
|
|
211
228
|
/**
|
|
212
229
|
* Left navigation area
|
|
213
230
|
*/
|
|
214
|
-
let
|
|
231
|
+
let buttonSecondaryLeftSide = index.h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'firstPage') }, index.h("span", { class: "NavigationButton" }, translate('firstPage', this.language)), index.h("span", { class: "NavigationIcon" }));
|
|
232
|
+
let buttonsLeftSide = index.h("div", { class: "LeftItems" }, this.secondaryArrowsActive && buttonSecondaryLeftSide, index.h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'previousPage') }, index.h("span", { class: "NavigationButton" }, translate('previousPage', this.language)), index.h("span", { class: "NavigationIcon" })));
|
|
215
233
|
if (isMobile(this.userAgent)) {
|
|
216
234
|
buttonsLeftSide =
|
|
217
|
-
index.h("div", { class: "LeftItems" }, index.h("button", { disabled:
|
|
235
|
+
index.h("div", { class: "LeftItems" }, index.h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'previousPage') }, index.h("span", { class: "NavigationButton" }, translate('previousPage', this.language)), index.h("span", { class: "NavigationIcon" })));
|
|
218
236
|
}
|
|
219
237
|
/**
|
|
220
238
|
* Right navigation area
|
|
221
239
|
*/
|
|
222
|
-
let
|
|
240
|
+
let buttonSecondaryRightSide = index.h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'lastPage') }, index.h("span", { class: "NavigationButton" }, translate('lastPage', this.language)), index.h("span", { class: "NavigationIcon" }));
|
|
241
|
+
let buttonsRightSide = index.h("div", { class: "RightItems" }, index.h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'nextPage') }, index.h("span", { class: "NavigationButton" }, translate('nextPage', this.language)), index.h("span", { class: "NavigationIcon" })), this.secondaryArrowsActive && buttonSecondaryRightSide);
|
|
223
242
|
if (isMobile(this.userAgent)) {
|
|
224
243
|
buttonsRightSide =
|
|
225
|
-
index.h("div", { class: "RightItems" }, index.h("button", { disabled:
|
|
244
|
+
index.h("div", { class: "RightItems" }, index.h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'nextPage') }, index.h("span", { class: "NavigationButton" }, translate('nextPage', this.language)), index.h("span", { class: "NavigationIcon" })));
|
|
226
245
|
}
|
|
227
|
-
return (index.h("div", { id: "PaginationContainer" }, buttonsLeftSide, navigationArea, buttonsRightSide));
|
|
246
|
+
return (index.h("div", { id: "PaginationContainer", ref: el => this.stylingContainer = el }, this.arrowsActive && buttonsLeftSide, this.numberedNavActive && navigationArea, this.arrowsActive && buttonsRightSide));
|
|
228
247
|
}
|
|
229
248
|
};
|
|
230
249
|
HelperPagination.style = helperPaginationCss;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const index = require('./index-
|
|
3
|
+
const index = require('./index-7c071a78.js');
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
Stencil Client Patch Browser v2.15.2 | MIT Licensed | https://stenciljs.com
|
|
@@ -15,5 +15,5 @@ const patchBrowser = () => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(options => {
|
|
18
|
-
return index.bootstrapLazy([["helper-pagination.cjs",[[1,"helper-pagination",{"
|
|
18
|
+
return index.bootstrapLazy([["helper-pagination.cjs",[[1,"helper-pagination",{"nextPage":[1537,"next-page"],"prevPage":[1537,"prev-page"],"offset":[1538],"limit":[1538],"total":[1538],"language":[1537],"clientStyling":[1537,"client-styling"],"clientStylingUrlContent":[1537,"client-styling-url-content"],"arrowsActive":[1540,"arrows-active"],"secondaryArrowsActive":[1540,"secondary-arrows-active"],"numberedNavActive":[1540,"numbered-nav-active"],"offsetInt":[32],"lastPage":[32],"previousPage":[32],"limitInt":[32],"totalInt":[32],"pagesArray":[32],"endInt":[32],"limitStylingAppends":[32]}]]]], options);
|
|
19
19
|
});
|
|
@@ -234,6 +234,12 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
234
234
|
classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
|
|
235
235
|
classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
|
|
236
236
|
}
|
|
237
|
+
else if (memberName === 'ref') {
|
|
238
|
+
// minifier will clean this up
|
|
239
|
+
if (newValue) {
|
|
240
|
+
newValue(elm);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
237
243
|
else if ((!isProp ) &&
|
|
238
244
|
memberName[0] === 'o' &&
|
|
239
245
|
memberName[1] === 'n') {
|
|
@@ -390,6 +396,7 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
390
396
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
391
397
|
if ((vnode = vnodes[startIdx])) {
|
|
392
398
|
elm = vnode.$elm$;
|
|
399
|
+
callNodeRefs(vnode);
|
|
393
400
|
// remove the vnode's element from the dom
|
|
394
401
|
elm.remove();
|
|
395
402
|
}
|
|
@@ -508,6 +515,12 @@ const patch = (oldVNode, newVNode) => {
|
|
|
508
515
|
elm.data = text;
|
|
509
516
|
}
|
|
510
517
|
};
|
|
518
|
+
const callNodeRefs = (vNode) => {
|
|
519
|
+
{
|
|
520
|
+
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
|
521
|
+
vNode.$children$ && vNode.$children$.map(callNodeRefs);
|
|
522
|
+
}
|
|
523
|
+
};
|
|
511
524
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
512
525
|
const hostElm = hostRef.$hostElement$;
|
|
513
526
|
const cmpMeta = hostRef.$cmpMeta$;
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-7c071a78.js');
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
Stencil Client Patch Esm v2.15.2 | MIT Licensed | https://stenciljs.com
|
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["helper-pagination.cjs",[[1,"helper-pagination",{"
|
|
17
|
+
return index.bootstrapLazy([["helper-pagination.cjs",[[1,"helper-pagination",{"nextPage":[1537,"next-page"],"prevPage":[1537,"prev-page"],"offset":[1538],"limit":[1538],"total":[1538],"language":[1537],"clientStyling":[1537,"client-styling"],"clientStylingUrlContent":[1537,"client-styling-url-content"],"arrowsActive":[1540,"arrows-active"],"secondaryArrowsActive":[1540,"secondary-arrows-active"],"numberedNavActive":[1540,"numbered-nav-active"],"offsetInt":[32],"lastPage":[32],"previousPage":[32],"limitInt":[32],"totalInt":[32],"pagesArray":[32],"endInt":[32],"limitStylingAppends":[32]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
#PaginationContainer {
|
|
8
8
|
width: 100%;
|
|
9
|
-
margin
|
|
9
|
+
margin: 20px 0;
|
|
10
10
|
display: inline-flex;
|
|
11
11
|
justify-content: space-between;
|
|
12
12
|
align-items: center;
|
|
@@ -98,13 +98,13 @@ button:disabled {
|
|
|
98
98
|
@media screen and (max-width: 720px) {
|
|
99
99
|
button {
|
|
100
100
|
width: 90px;
|
|
101
|
-
font-size:
|
|
101
|
+
font-size: 14px;
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
@media screen and (max-width: 480px) {
|
|
105
105
|
button {
|
|
106
106
|
width: 70px;
|
|
107
|
-
font-size:
|
|
107
|
+
font-size: 14px;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
.paginationArea {
|
|
@@ -114,7 +114,7 @@ button:disabled {
|
|
|
114
114
|
@media screen and (max-width: 320px) {
|
|
115
115
|
button {
|
|
116
116
|
width: 58px;
|
|
117
|
-
font-size:
|
|
117
|
+
font-size: 12px;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
.paginationArea {
|
|
@@ -4,13 +4,13 @@ import { translate } from '../../utils/locale.utils';
|
|
|
4
4
|
export class HelperPagination {
|
|
5
5
|
constructor() {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Next page string value - determines if the next page is disabled or active
|
|
8
8
|
*/
|
|
9
|
-
this.
|
|
9
|
+
this.nextPage = '';
|
|
10
10
|
/**
|
|
11
|
-
* Previous page
|
|
11
|
+
* Previous page string value - determines if the previous page is disabled or active
|
|
12
12
|
*/
|
|
13
|
-
this.
|
|
13
|
+
this.prevPage = '';
|
|
14
14
|
/**
|
|
15
15
|
* The received offset
|
|
16
16
|
*/
|
|
@@ -28,13 +28,21 @@ export class HelperPagination {
|
|
|
28
28
|
*/
|
|
29
29
|
this.language = 'en';
|
|
30
30
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
* Client custom styling via string
|
|
32
|
+
*/
|
|
33
33
|
this.clientStyling = '';
|
|
34
34
|
/**
|
|
35
35
|
* Client custom styling via url content
|
|
36
36
|
*/
|
|
37
37
|
this.clientStylingUrlContent = '';
|
|
38
|
+
/**
|
|
39
|
+
* Component working variable for last page
|
|
40
|
+
*/
|
|
41
|
+
this.lastPage = false;
|
|
42
|
+
/**
|
|
43
|
+
* Component working variable for prvious page
|
|
44
|
+
*/
|
|
45
|
+
this.previousPage = false;
|
|
38
46
|
/**
|
|
39
47
|
* In component working variable for the array of pages
|
|
40
48
|
*/
|
|
@@ -58,32 +66,35 @@ export class HelperPagination {
|
|
|
58
66
|
this.offsetInt = this.endInt * this.limitInt;
|
|
59
67
|
break;
|
|
60
68
|
case 'previousPage':
|
|
61
|
-
this.offsetInt -=
|
|
69
|
+
this.offsetInt -= this.limitInt;
|
|
62
70
|
break;
|
|
63
71
|
case 'nextPage':
|
|
64
|
-
this.offsetInt +=
|
|
72
|
+
this.offsetInt += this.limitInt;
|
|
65
73
|
break;
|
|
66
74
|
case 'fivePagesBack':
|
|
67
|
-
this.offsetInt -=
|
|
68
|
-
this.offsetInt = this.offsetInt
|
|
75
|
+
this.offsetInt -= this.limitInt * 5;
|
|
76
|
+
this.offsetInt = this.offsetInt <= 0 ? 0 : this.offsetInt;
|
|
69
77
|
break;
|
|
70
78
|
case 'fivePagesForward':
|
|
71
|
-
this.offsetInt +=
|
|
72
|
-
this.offsetInt = this.offsetInt /
|
|
79
|
+
this.offsetInt += this.limitInt * 5;
|
|
80
|
+
this.offsetInt = this.offsetInt / this.limitInt >= this.endInt ? this.endInt * this.limitInt : this.offsetInt;
|
|
73
81
|
break;
|
|
74
82
|
}
|
|
83
|
+
this.previousPage = !this.offsetInt ? false : true;
|
|
75
84
|
this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
|
|
76
85
|
};
|
|
77
86
|
/**
|
|
78
87
|
* Handle navigation from here
|
|
79
88
|
*/
|
|
80
89
|
this.paginationNavigation = (pageNumber, index) => {
|
|
90
|
+
this.previousPage = true;
|
|
81
91
|
if (!isNaN(pageNumber)) {
|
|
82
92
|
if (pageNumber === 1) {
|
|
83
93
|
this.offsetInt = pageNumber - 1;
|
|
94
|
+
this.previousPage = false;
|
|
84
95
|
}
|
|
85
96
|
else {
|
|
86
|
-
this.offsetInt = (pageNumber - 1) *
|
|
97
|
+
this.offsetInt = (pageNumber - 1) * this.limitInt;
|
|
87
98
|
}
|
|
88
99
|
}
|
|
89
100
|
else {
|
|
@@ -97,7 +108,6 @@ export class HelperPagination {
|
|
|
97
108
|
this.navigateTo('fivePagesForward');
|
|
98
109
|
}
|
|
99
110
|
}
|
|
100
|
-
this.currentPage = this.offsetInt;
|
|
101
111
|
this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
|
|
102
112
|
};
|
|
103
113
|
this.setClientStyling = () => {
|
|
@@ -115,7 +125,8 @@ export class HelperPagination {
|
|
|
115
125
|
}
|
|
116
126
|
componentWillRender() {
|
|
117
127
|
this.offsetInt = this.offset;
|
|
118
|
-
this.
|
|
128
|
+
this.limitInt = this.limit;
|
|
129
|
+
this.currentPage = (this.offsetInt / this.limitInt) + 1;
|
|
119
130
|
this.limitInt = this.limit;
|
|
120
131
|
this.totalInt = this.total;
|
|
121
132
|
this.endInt = (Math.ceil(this.totalInt / this.limitInt) - 1);
|
|
@@ -123,7 +134,7 @@ export class HelperPagination {
|
|
|
123
134
|
/**
|
|
124
135
|
* Construct numbered navigation area based on current page position
|
|
125
136
|
*/
|
|
126
|
-
if (this.currentPage
|
|
137
|
+
if (this.currentPage == 1 || this.currentPage == 2) {
|
|
127
138
|
this.pagesArray = Array.from({ length: 4 }, (_, i) => i + 1);
|
|
128
139
|
this.pagesArray.push('...');
|
|
129
140
|
}
|
|
@@ -160,29 +171,43 @@ export class HelperPagination {
|
|
|
160
171
|
/**
|
|
161
172
|
* Left navigation area
|
|
162
173
|
*/
|
|
174
|
+
let buttonSecondaryLeftSide = h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'firstPage') },
|
|
175
|
+
h("span", { class: "NavigationButton" }, translate('firstPage', this.language)),
|
|
176
|
+
h("span", { class: "NavigationIcon" }));
|
|
163
177
|
let buttonsLeftSide = h("div", { class: "LeftItems" },
|
|
164
|
-
|
|
165
|
-
h("button", { disabled:
|
|
178
|
+
this.secondaryArrowsActive && buttonSecondaryLeftSide,
|
|
179
|
+
h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'previousPage') },
|
|
180
|
+
h("span", { class: "NavigationButton" }, translate('previousPage', this.language)),
|
|
181
|
+
h("span", { class: "NavigationIcon" })));
|
|
166
182
|
if (isMobile(this.userAgent)) {
|
|
167
183
|
buttonsLeftSide =
|
|
168
184
|
h("div", { class: "LeftItems" },
|
|
169
|
-
h("button", { disabled:
|
|
185
|
+
h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'previousPage') },
|
|
186
|
+
h("span", { class: "NavigationButton" }, translate('previousPage', this.language)),
|
|
187
|
+
h("span", { class: "NavigationIcon" })));
|
|
170
188
|
}
|
|
171
189
|
/**
|
|
172
190
|
* Right navigation area
|
|
173
191
|
*/
|
|
192
|
+
let buttonSecondaryRightSide = h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'lastPage') },
|
|
193
|
+
h("span", { class: "NavigationButton" }, translate('lastPage', this.language)),
|
|
194
|
+
h("span", { class: "NavigationIcon" }));
|
|
174
195
|
let buttonsRightSide = h("div", { class: "RightItems" },
|
|
175
|
-
h("button", { disabled:
|
|
176
|
-
|
|
196
|
+
h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'nextPage') },
|
|
197
|
+
h("span", { class: "NavigationButton" }, translate('nextPage', this.language)),
|
|
198
|
+
h("span", { class: "NavigationIcon" })),
|
|
199
|
+
this.secondaryArrowsActive && buttonSecondaryRightSide);
|
|
177
200
|
if (isMobile(this.userAgent)) {
|
|
178
201
|
buttonsRightSide =
|
|
179
202
|
h("div", { class: "RightItems" },
|
|
180
|
-
h("button", { disabled:
|
|
203
|
+
h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'nextPage') },
|
|
204
|
+
h("span", { class: "NavigationButton" }, translate('nextPage', this.language)),
|
|
205
|
+
h("span", { class: "NavigationIcon" })));
|
|
181
206
|
}
|
|
182
|
-
return (h("div", { id: "PaginationContainer" },
|
|
183
|
-
buttonsLeftSide,
|
|
184
|
-
navigationArea,
|
|
185
|
-
buttonsRightSide));
|
|
207
|
+
return (h("div", { id: "PaginationContainer", ref: el => this.stylingContainer = el },
|
|
208
|
+
this.arrowsActive && buttonsLeftSide,
|
|
209
|
+
this.numberedNavActive && navigationArea,
|
|
210
|
+
this.arrowsActive && buttonsRightSide));
|
|
186
211
|
}
|
|
187
212
|
static get is() { return "helper-pagination"; }
|
|
188
213
|
static get encapsulation() { return "shadow"; }
|
|
@@ -193,41 +218,41 @@ export class HelperPagination {
|
|
|
193
218
|
"$": ["helper-pagination.css"]
|
|
194
219
|
}; }
|
|
195
220
|
static get properties() { return {
|
|
196
|
-
"
|
|
197
|
-
"type": "
|
|
221
|
+
"nextPage": {
|
|
222
|
+
"type": "string",
|
|
198
223
|
"mutable": true,
|
|
199
224
|
"complexType": {
|
|
200
|
-
"original": "
|
|
201
|
-
"resolved": "
|
|
225
|
+
"original": "string",
|
|
226
|
+
"resolved": "string",
|
|
202
227
|
"references": {}
|
|
203
228
|
},
|
|
204
229
|
"required": false,
|
|
205
230
|
"optional": false,
|
|
206
231
|
"docs": {
|
|
207
232
|
"tags": [],
|
|
208
|
-
"text": "
|
|
233
|
+
"text": "Next page string value - determines if the next page is disabled or active"
|
|
209
234
|
},
|
|
210
|
-
"attribute": "
|
|
235
|
+
"attribute": "next-page",
|
|
211
236
|
"reflect": true,
|
|
212
|
-
"defaultValue": "
|
|
237
|
+
"defaultValue": "''"
|
|
213
238
|
},
|
|
214
|
-
"
|
|
215
|
-
"type": "
|
|
239
|
+
"prevPage": {
|
|
240
|
+
"type": "string",
|
|
216
241
|
"mutable": true,
|
|
217
242
|
"complexType": {
|
|
218
|
-
"original": "
|
|
219
|
-
"resolved": "
|
|
243
|
+
"original": "string",
|
|
244
|
+
"resolved": "string",
|
|
220
245
|
"references": {}
|
|
221
246
|
},
|
|
222
247
|
"required": false,
|
|
223
248
|
"optional": false,
|
|
224
249
|
"docs": {
|
|
225
250
|
"tags": [],
|
|
226
|
-
"text": "Previous page
|
|
251
|
+
"text": "Previous page string value - determines if the previous page is disabled or active"
|
|
227
252
|
},
|
|
228
|
-
"attribute": "
|
|
253
|
+
"attribute": "prev-page",
|
|
229
254
|
"reflect": true,
|
|
230
|
-
"defaultValue": "
|
|
255
|
+
"defaultValue": "''"
|
|
231
256
|
},
|
|
232
257
|
"offset": {
|
|
233
258
|
"type": "number",
|
|
@@ -285,7 +310,7 @@ export class HelperPagination {
|
|
|
285
310
|
},
|
|
286
311
|
"language": {
|
|
287
312
|
"type": "string",
|
|
288
|
-
"mutable":
|
|
313
|
+
"mutable": true,
|
|
289
314
|
"complexType": {
|
|
290
315
|
"original": "string",
|
|
291
316
|
"resolved": "string",
|
|
@@ -298,12 +323,12 @@ export class HelperPagination {
|
|
|
298
323
|
"text": "Language"
|
|
299
324
|
},
|
|
300
325
|
"attribute": "language",
|
|
301
|
-
"reflect":
|
|
326
|
+
"reflect": true,
|
|
302
327
|
"defaultValue": "'en'"
|
|
303
328
|
},
|
|
304
329
|
"clientStyling": {
|
|
305
330
|
"type": "string",
|
|
306
|
-
"mutable":
|
|
331
|
+
"mutable": true,
|
|
307
332
|
"complexType": {
|
|
308
333
|
"original": "string",
|
|
309
334
|
"resolved": "string",
|
|
@@ -316,12 +341,12 @@ export class HelperPagination {
|
|
|
316
341
|
"text": "Client custom styling via string"
|
|
317
342
|
},
|
|
318
343
|
"attribute": "client-styling",
|
|
319
|
-
"reflect":
|
|
344
|
+
"reflect": true,
|
|
320
345
|
"defaultValue": "''"
|
|
321
346
|
},
|
|
322
347
|
"clientStylingUrlContent": {
|
|
323
348
|
"type": "string",
|
|
324
|
-
"mutable":
|
|
349
|
+
"mutable": true,
|
|
325
350
|
"complexType": {
|
|
326
351
|
"original": "string",
|
|
327
352
|
"resolved": "string",
|
|
@@ -334,13 +359,65 @@ export class HelperPagination {
|
|
|
334
359
|
"text": "Client custom styling via url content"
|
|
335
360
|
},
|
|
336
361
|
"attribute": "client-styling-url-content",
|
|
337
|
-
"reflect":
|
|
362
|
+
"reflect": true,
|
|
338
363
|
"defaultValue": "''"
|
|
364
|
+
},
|
|
365
|
+
"arrowsActive": {
|
|
366
|
+
"type": "boolean",
|
|
367
|
+
"mutable": true,
|
|
368
|
+
"complexType": {
|
|
369
|
+
"original": "boolean",
|
|
370
|
+
"resolved": "boolean",
|
|
371
|
+
"references": {}
|
|
372
|
+
},
|
|
373
|
+
"required": false,
|
|
374
|
+
"optional": false,
|
|
375
|
+
"docs": {
|
|
376
|
+
"tags": [],
|
|
377
|
+
"text": "Customize pagination: Activate pagination arrows"
|
|
378
|
+
},
|
|
379
|
+
"attribute": "arrows-active",
|
|
380
|
+
"reflect": true
|
|
381
|
+
},
|
|
382
|
+
"secondaryArrowsActive": {
|
|
383
|
+
"type": "boolean",
|
|
384
|
+
"mutable": true,
|
|
385
|
+
"complexType": {
|
|
386
|
+
"original": "boolean",
|
|
387
|
+
"resolved": "boolean",
|
|
388
|
+
"references": {}
|
|
389
|
+
},
|
|
390
|
+
"required": false,
|
|
391
|
+
"optional": false,
|
|
392
|
+
"docs": {
|
|
393
|
+
"tags": [],
|
|
394
|
+
"text": "Customize pagination: Activate pagination secondary arrows"
|
|
395
|
+
},
|
|
396
|
+
"attribute": "secondary-arrows-active",
|
|
397
|
+
"reflect": true
|
|
398
|
+
},
|
|
399
|
+
"numberedNavActive": {
|
|
400
|
+
"type": "boolean",
|
|
401
|
+
"mutable": true,
|
|
402
|
+
"complexType": {
|
|
403
|
+
"original": "boolean",
|
|
404
|
+
"resolved": "boolean",
|
|
405
|
+
"references": {}
|
|
406
|
+
},
|
|
407
|
+
"required": false,
|
|
408
|
+
"optional": false,
|
|
409
|
+
"docs": {
|
|
410
|
+
"tags": [],
|
|
411
|
+
"text": "Customize pagination: Activate pagination numbered navigation"
|
|
412
|
+
},
|
|
413
|
+
"attribute": "numbered-nav-active",
|
|
414
|
+
"reflect": true
|
|
339
415
|
}
|
|
340
416
|
}; }
|
|
341
417
|
static get states() { return {
|
|
342
418
|
"offsetInt": {},
|
|
343
419
|
"lastPage": {},
|
|
420
|
+
"previousPage": {},
|
|
344
421
|
"limitInt": {},
|
|
345
422
|
"totalInt": {},
|
|
346
423
|
"pagesArray": {},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const DEFAULT_LANGUAGE = 'en';
|
|
2
|
-
const SUPPORTED_LANGUAGES = ['ro', 'en'];
|
|
2
|
+
const SUPPORTED_LANGUAGES = ['ro', 'en', 'hu'];
|
|
3
3
|
const TRANSLATIONS = {
|
|
4
4
|
en: {
|
|
5
5
|
firstPage: 'First',
|
|
@@ -24,6 +24,12 @@ const TRANSLATIONS = {
|
|
|
24
24
|
previousPage: 'Previous',
|
|
25
25
|
nextPage: 'Next',
|
|
26
26
|
lastPage: 'Last'
|
|
27
|
+
},
|
|
28
|
+
hu: {
|
|
29
|
+
firstPage: 'First',
|
|
30
|
+
previousPage: 'Previous',
|
|
31
|
+
nextPage: 'Következő',
|
|
32
|
+
lastPage: 'Last'
|
|
27
33
|
}
|
|
28
34
|
};
|
|
29
35
|
export const translate = (key, customLang) => {
|