@everymatrix/bonus-pagination-nav 1.0.69
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/bonus-pagination-nav/bonus-pagination-nav.esm.js +1 -0
- package/dist/bonus-pagination-nav/index.esm.js +0 -0
- package/dist/bonus-pagination-nav/p-57809f35.js +2 -0
- package/dist/bonus-pagination-nav/p-e1255160.js +1 -0
- package/dist/bonus-pagination-nav/p-f71ef42b.entry.js +1 -0
- package/dist/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/bonus-pagination-nav.cjs.entry.js +163 -0
- package/dist/cjs/bonus-pagination-nav.cjs.js +25 -0
- package/dist/cjs/index-5f4d615c.js +1233 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +15 -0
- package/dist/collection/collection-manifest.json +12 -0
- package/dist/collection/components/bonus-pagination-nav/bonus-pagination-nav.css +51 -0
- package/dist/collection/components/bonus-pagination-nav/bonus-pagination-nav.js +334 -0
- package/dist/collection/components/bonus-pagination-nav/index.js +1 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/locale.utils.js +65 -0
- package/dist/collection/utils/utils.js +3 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/bonus-pagination-nav.entry.js +159 -0
- package/dist/esm/bonus-pagination-nav.js +20 -0
- package/dist/esm/index-332d0149.js +1206 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +11 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/stencil.config.dev.js +17 -0
- package/dist/stencil.config.js +17 -0
- package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/bonus-pagination-nav/.stencil/packages/stencil/bonus-pagination-nav/stencil.config.d.ts +2 -0
- package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/bonus-pagination-nav/.stencil/packages/stencil/bonus-pagination-nav/stencil.config.dev.d.ts +2 -0
- package/dist/types/components/bonus-pagination-nav/bonus-pagination-nav.d.ts +55 -0
- package/dist/types/components/bonus-pagination-nav/index.d.ts +1 -0
- package/dist/types/components.d.ts +133 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1674 -0
- package/dist/types/utils/locale.utils.d.ts +17 -0
- package/dist/types/utils/utils.d.ts +1 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/loader/package.json +11 -0
- package/package.json +26 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-5f4d615c.js');
|
|
6
|
+
const appGlobals = require('./app-globals-3a1e7e63.js');
|
|
7
|
+
|
|
8
|
+
const defineCustomElements = async (win, options) => {
|
|
9
|
+
if (typeof window === 'undefined') return undefined;
|
|
10
|
+
await appGlobals.globalScripts();
|
|
11
|
+
return index.bootstrapLazy([["bonus-pagination-nav.cjs",[[0,"bonus-pagination-nav",{"total":[1538],"limit":[1538],"offset":[1538],"tableId":[1537,"table-id"],"language":[1537],"translationUrl":[513,"translation-url"],"arrowsActive":[1540,"arrows-active"],"secondaryArrowsActive":[1540,"secondary-arrows-active"],"displayPageNumbers":[1540,"display-page-numbers"],"displayRangeOfTotal":[1540,"display-range-of-total"],"endPageIndex":[32],"pagesArray":[32],"currentPage":[32]},[[8,"paginationReset","pageLimitChangedHandler"],[8,"pageLimitChanged","pageLimitChangedHandler"]]]]]], options);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.setNonce = index.setNonce;
|
|
15
|
+
exports.defineCustomElements = defineCustomElements;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.PageNavigationWrapper {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: row;
|
|
8
|
+
}
|
|
9
|
+
.PageNavigationWrapper .PageOfMessage {
|
|
10
|
+
margin: 5px;
|
|
11
|
+
padding: 5px 6px;
|
|
12
|
+
margin: 2px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.PageNavigation {
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: row;
|
|
18
|
+
align-items: center;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.PageNavigation .PageArrow {
|
|
22
|
+
color: var(--emfe-w-color-primary, #777676);
|
|
23
|
+
padding: 6px 5px;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
font-weight: bold;
|
|
26
|
+
width: 1.2rem;
|
|
27
|
+
text-align: center;
|
|
28
|
+
}
|
|
29
|
+
.PageNavigation .PageArrow.Disabled {
|
|
30
|
+
color: var(--emfe-w-color-gray-100, #e0e0e0);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
ul.PaginationArea {
|
|
34
|
+
list-style: none;
|
|
35
|
+
padding: 0px;
|
|
36
|
+
margin: 0px;
|
|
37
|
+
display: flex;
|
|
38
|
+
}
|
|
39
|
+
ul.PaginationArea li.PageItem {
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
padding: 5px 6px;
|
|
42
|
+
margin: 2px;
|
|
43
|
+
width: 0.9rem;
|
|
44
|
+
text-align: center;
|
|
45
|
+
}
|
|
46
|
+
ul.PaginationArea li.PageItem.Active, ul.PaginationArea li.PageItem:hover {
|
|
47
|
+
font-weight: bold;
|
|
48
|
+
color: var(--emfe-w-color-primary, #f5f1f1);
|
|
49
|
+
background-color: var(--emfe-w-color-secondary, #8c8989);
|
|
50
|
+
border-radius: 0.3rem;
|
|
51
|
+
}
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { translate, TRANSLATIONS } from "../../utils/locale.utils";
|
|
3
|
+
export class BonusPaginationNav {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.total = 1;
|
|
6
|
+
this.limit = 10;
|
|
7
|
+
this.offset = 0;
|
|
8
|
+
this.tableId = 'default';
|
|
9
|
+
this.language = 'en';
|
|
10
|
+
this.translationUrl = '';
|
|
11
|
+
this.arrowsActive = true;
|
|
12
|
+
this.secondaryArrowsActive = true;
|
|
13
|
+
this.displayPageNumbers = true;
|
|
14
|
+
this.displayRangeOfTotal = undefined;
|
|
15
|
+
this.endPageIndex = 0;
|
|
16
|
+
this.pagesArray = undefined;
|
|
17
|
+
this.currentPage = 1;
|
|
18
|
+
}
|
|
19
|
+
pageLimitChangedHandler(event) {
|
|
20
|
+
this.limit = event.detail.limit ? event.detail.limit : this.limit;
|
|
21
|
+
//reset offset = 0, this.currentPage = 1 when page limit changed
|
|
22
|
+
this.currentPage = 1;
|
|
23
|
+
this.offset = 0;
|
|
24
|
+
this.updatePageStatus();
|
|
25
|
+
if (event.type == 'pageLimitChanged') {
|
|
26
|
+
this.reloadPageEmitter.emit({ offset: 0, limit: this.limit, tableId: this.tableId });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
goTo(step) {
|
|
30
|
+
if (step == '...' || step == 0 || parseInt(step.toString(), 10) > (this.endPageIndex + 1)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
this.currentPage = step;
|
|
34
|
+
let offset = (this.currentPage - 1) * this.limit;
|
|
35
|
+
this.reloadPageEmitter.emit({ offset, limit: this.limit, tableId: this.tableId });
|
|
36
|
+
}
|
|
37
|
+
renderPageList() {
|
|
38
|
+
return h("ul", { class: 'PaginationArea' }, this.pagesArray.map((page) => {
|
|
39
|
+
return (h("li", { class: `PageItem ${this.currentPage == page ? 'Active' : ''}`, onClick: () => {
|
|
40
|
+
this.goTo(page);
|
|
41
|
+
} }, page));
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
renderStylingWrapper() {
|
|
45
|
+
return h("general-styling-wrapper", { targetTranslations: TRANSLATIONS, translationUrl: this.translationUrl });
|
|
46
|
+
}
|
|
47
|
+
updatePageStatus() {
|
|
48
|
+
this.endPageIndex = (Math.ceil(this.total / this.limit) - 1);
|
|
49
|
+
this.endPageIndex = this.endPageIndex < 0 ? this.endPageIndex = 0 : this.endPageIndex;
|
|
50
|
+
this.pagesArray = [];
|
|
51
|
+
if (this.endPageIndex < 5) {
|
|
52
|
+
this.pagesArray = Array.from({ length: this.endPageIndex + 1 }, (_, i) => i + 1);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
/**
|
|
56
|
+
* Construct numbered navigation area based on current page position
|
|
57
|
+
*/
|
|
58
|
+
if (this.currentPage == 1 || this.currentPage == 2) {
|
|
59
|
+
this.pagesArray = Array.from({ length: 4 }, (_, i) => i + 1);
|
|
60
|
+
this.pagesArray.push('...');
|
|
61
|
+
}
|
|
62
|
+
else if (this.currentPage >= 3 && ((this.endPageIndex - this.currentPage) >= 2)) {
|
|
63
|
+
this.pagesArray = Array.from({ length: 3 }, (_, i) => this.currentPage + i - 1);
|
|
64
|
+
this.pagesArray.push('...');
|
|
65
|
+
this.pagesArray.unshift('...');
|
|
66
|
+
}
|
|
67
|
+
else if ((this.endPageIndex - this.currentPage) < 3) {
|
|
68
|
+
this.pagesArray = Array.from({ length: 4 }, (_, i) => this.endPageIndex - 2 + i);
|
|
69
|
+
this.pagesArray.unshift('...');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
componentWillRender() {
|
|
74
|
+
this.currentPage = Math.floor(this.offset / this.limit) + 1;
|
|
75
|
+
this.updatePageStatus();
|
|
76
|
+
}
|
|
77
|
+
render() {
|
|
78
|
+
const startOffset = (this.currentPage - 1) * this.limit + 1;
|
|
79
|
+
const endOffset = this.currentPage * this.limit > this.total ? this.total : this.currentPage * this.limit;
|
|
80
|
+
return h("div", { key: 'a6817c12f1e1e9960f8e91cfd5c5e2fa1ea72f7f', class: 'PageNavigationWrapper' }, this.displayRangeOfTotal && this.total > 0 && h("span", { key: '8f7a16c5835147e2a83808f882a66a2463e3998e', class: 'PageOfMessage' }, translate('pageOfTotal', this.language, {
|
|
81
|
+
values: {
|
|
82
|
+
start: startOffset,
|
|
83
|
+
end: endOffset,
|
|
84
|
+
total: this.total
|
|
85
|
+
}
|
|
86
|
+
})), h("div", { key: 'ddc20a86777c2fde667ad8b75ab86f3bc72ccfdb', class: 'PageNavigation' }, this.arrowsActive &&
|
|
87
|
+
h("div", { key: 'ce2a45b8c0d6e32cfa3f1c5cc8b3c9ac58acc409', class: `PageArrow FirstPage ${this.currentPage == 1 ? 'Disabled' : ''}`, onClick: () => {
|
|
88
|
+
this.goTo(1);
|
|
89
|
+
} }, translate('firstPage', this.language)), this.secondaryArrowsActive &&
|
|
90
|
+
h("span", { key: '82dce028e4283dcac511b3b62823e87f2085f4b5', class: `PageArrow PrePage ${this.currentPage == 1 ? 'Disabled' : ''}`, onClick: () => {
|
|
91
|
+
this.goTo(this.currentPage - 1);
|
|
92
|
+
} }, translate('prePage', this.language)), this.displayPageNumbers && this.renderPageList(), this.secondaryArrowsActive &&
|
|
93
|
+
h("span", { key: 'a6ed748ce3e2555ac3d9d4bae174ad5bad0fabec', class: `PageArrow NextPage ${this.currentPage == (this.endPageIndex + 1) ? 'Disabled' : ''}`, onClick: () => {
|
|
94
|
+
this.goTo(this.currentPage + 1);
|
|
95
|
+
} }, translate('nextPage', this.language)), this.arrowsActive &&
|
|
96
|
+
h("div", { key: '60a81a86f11e2bb07ee93b61d6f367a11b0e2b6c', class: `PageArrow LastPage ${this.currentPage == this.endPageIndex + 1 ? 'Disabled' : ''}`, onClick: () => {
|
|
97
|
+
this.goTo(this.endPageIndex + 1);
|
|
98
|
+
} }, " ", translate('lastPage', this.language), " "), this.renderStylingWrapper()));
|
|
99
|
+
}
|
|
100
|
+
static get is() { return "bonus-pagination-nav"; }
|
|
101
|
+
static get originalStyleUrls() {
|
|
102
|
+
return {
|
|
103
|
+
"$": ["bonus-pagination-nav.scss"]
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
static get styleUrls() {
|
|
107
|
+
return {
|
|
108
|
+
"$": ["bonus-pagination-nav.css"]
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
static get properties() {
|
|
112
|
+
return {
|
|
113
|
+
"total": {
|
|
114
|
+
"type": "number",
|
|
115
|
+
"mutable": true,
|
|
116
|
+
"complexType": {
|
|
117
|
+
"original": "number",
|
|
118
|
+
"resolved": "number",
|
|
119
|
+
"references": {}
|
|
120
|
+
},
|
|
121
|
+
"required": false,
|
|
122
|
+
"optional": false,
|
|
123
|
+
"docs": {
|
|
124
|
+
"tags": [],
|
|
125
|
+
"text": "The received length of dataset"
|
|
126
|
+
},
|
|
127
|
+
"attribute": "total",
|
|
128
|
+
"reflect": true,
|
|
129
|
+
"defaultValue": "1"
|
|
130
|
+
},
|
|
131
|
+
"limit": {
|
|
132
|
+
"type": "number",
|
|
133
|
+
"mutable": true,
|
|
134
|
+
"complexType": {
|
|
135
|
+
"original": "number",
|
|
136
|
+
"resolved": "number",
|
|
137
|
+
"references": {}
|
|
138
|
+
},
|
|
139
|
+
"required": false,
|
|
140
|
+
"optional": false,
|
|
141
|
+
"docs": {
|
|
142
|
+
"tags": [],
|
|
143
|
+
"text": "The received limit for the number of pages"
|
|
144
|
+
},
|
|
145
|
+
"attribute": "limit",
|
|
146
|
+
"reflect": true,
|
|
147
|
+
"defaultValue": "10"
|
|
148
|
+
},
|
|
149
|
+
"offset": {
|
|
150
|
+
"type": "number",
|
|
151
|
+
"mutable": true,
|
|
152
|
+
"complexType": {
|
|
153
|
+
"original": "number",
|
|
154
|
+
"resolved": "number",
|
|
155
|
+
"references": {}
|
|
156
|
+
},
|
|
157
|
+
"required": false,
|
|
158
|
+
"optional": false,
|
|
159
|
+
"docs": {
|
|
160
|
+
"tags": [],
|
|
161
|
+
"text": "The offset of dataset"
|
|
162
|
+
},
|
|
163
|
+
"attribute": "offset",
|
|
164
|
+
"reflect": true,
|
|
165
|
+
"defaultValue": "0"
|
|
166
|
+
},
|
|
167
|
+
"tableId": {
|
|
168
|
+
"type": "string",
|
|
169
|
+
"mutable": true,
|
|
170
|
+
"complexType": {
|
|
171
|
+
"original": "string",
|
|
172
|
+
"resolved": "string",
|
|
173
|
+
"references": {}
|
|
174
|
+
},
|
|
175
|
+
"required": false,
|
|
176
|
+
"optional": false,
|
|
177
|
+
"docs": {
|
|
178
|
+
"tags": [],
|
|
179
|
+
"text": "The table id, use to identify which table listen the page change message\nwhen there is more than 1 table on same page"
|
|
180
|
+
},
|
|
181
|
+
"attribute": "table-id",
|
|
182
|
+
"reflect": true,
|
|
183
|
+
"defaultValue": "'default'"
|
|
184
|
+
},
|
|
185
|
+
"language": {
|
|
186
|
+
"type": "string",
|
|
187
|
+
"mutable": true,
|
|
188
|
+
"complexType": {
|
|
189
|
+
"original": "string",
|
|
190
|
+
"resolved": "string",
|
|
191
|
+
"references": {}
|
|
192
|
+
},
|
|
193
|
+
"required": false,
|
|
194
|
+
"optional": false,
|
|
195
|
+
"docs": {
|
|
196
|
+
"tags": [],
|
|
197
|
+
"text": "Language"
|
|
198
|
+
},
|
|
199
|
+
"attribute": "language",
|
|
200
|
+
"reflect": true,
|
|
201
|
+
"defaultValue": "'en'"
|
|
202
|
+
},
|
|
203
|
+
"translationUrl": {
|
|
204
|
+
"type": "string",
|
|
205
|
+
"mutable": false,
|
|
206
|
+
"complexType": {
|
|
207
|
+
"original": "string",
|
|
208
|
+
"resolved": "string",
|
|
209
|
+
"references": {}
|
|
210
|
+
},
|
|
211
|
+
"required": false,
|
|
212
|
+
"optional": false,
|
|
213
|
+
"docs": {
|
|
214
|
+
"tags": [],
|
|
215
|
+
"text": "Translation via url"
|
|
216
|
+
},
|
|
217
|
+
"attribute": "translation-url",
|
|
218
|
+
"reflect": true,
|
|
219
|
+
"defaultValue": "''"
|
|
220
|
+
},
|
|
221
|
+
"arrowsActive": {
|
|
222
|
+
"type": "boolean",
|
|
223
|
+
"mutable": true,
|
|
224
|
+
"complexType": {
|
|
225
|
+
"original": "boolean",
|
|
226
|
+
"resolved": "boolean",
|
|
227
|
+
"references": {}
|
|
228
|
+
},
|
|
229
|
+
"required": false,
|
|
230
|
+
"optional": false,
|
|
231
|
+
"docs": {
|
|
232
|
+
"tags": [],
|
|
233
|
+
"text": "Customize pagination: Activate pagination arrows"
|
|
234
|
+
},
|
|
235
|
+
"attribute": "arrows-active",
|
|
236
|
+
"reflect": true,
|
|
237
|
+
"defaultValue": "true"
|
|
238
|
+
},
|
|
239
|
+
"secondaryArrowsActive": {
|
|
240
|
+
"type": "boolean",
|
|
241
|
+
"mutable": true,
|
|
242
|
+
"complexType": {
|
|
243
|
+
"original": "boolean",
|
|
244
|
+
"resolved": "boolean",
|
|
245
|
+
"references": {}
|
|
246
|
+
},
|
|
247
|
+
"required": false,
|
|
248
|
+
"optional": false,
|
|
249
|
+
"docs": {
|
|
250
|
+
"tags": [],
|
|
251
|
+
"text": "Customize pagination: Activate pagination secondary arrows"
|
|
252
|
+
},
|
|
253
|
+
"attribute": "secondary-arrows-active",
|
|
254
|
+
"reflect": true,
|
|
255
|
+
"defaultValue": "true"
|
|
256
|
+
},
|
|
257
|
+
"displayPageNumbers": {
|
|
258
|
+
"type": "boolean",
|
|
259
|
+
"mutable": true,
|
|
260
|
+
"complexType": {
|
|
261
|
+
"original": "boolean",
|
|
262
|
+
"resolved": "boolean",
|
|
263
|
+
"references": {}
|
|
264
|
+
},
|
|
265
|
+
"required": false,
|
|
266
|
+
"optional": false,
|
|
267
|
+
"docs": {
|
|
268
|
+
"tags": [],
|
|
269
|
+
"text": "Customize pagination: Activate pagination numbered navigation"
|
|
270
|
+
},
|
|
271
|
+
"attribute": "display-page-numbers",
|
|
272
|
+
"reflect": true,
|
|
273
|
+
"defaultValue": "true"
|
|
274
|
+
},
|
|
275
|
+
"displayRangeOfTotal": {
|
|
276
|
+
"type": "boolean",
|
|
277
|
+
"mutable": true,
|
|
278
|
+
"complexType": {
|
|
279
|
+
"original": "boolean",
|
|
280
|
+
"resolved": "boolean",
|
|
281
|
+
"references": {}
|
|
282
|
+
},
|
|
283
|
+
"required": false,
|
|
284
|
+
"optional": false,
|
|
285
|
+
"docs": {
|
|
286
|
+
"tags": [],
|
|
287
|
+
"text": "If show the page of message, eg: `1-20 of 100`"
|
|
288
|
+
},
|
|
289
|
+
"attribute": "display-range-of-total",
|
|
290
|
+
"reflect": true
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
static get states() {
|
|
295
|
+
return {
|
|
296
|
+
"endPageIndex": {},
|
|
297
|
+
"pagesArray": {},
|
|
298
|
+
"currentPage": {}
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
static get events() {
|
|
302
|
+
return [{
|
|
303
|
+
"method": "reloadPageEmitter",
|
|
304
|
+
"name": "reloadPageByType",
|
|
305
|
+
"bubbles": true,
|
|
306
|
+
"cancelable": true,
|
|
307
|
+
"composed": true,
|
|
308
|
+
"docs": {
|
|
309
|
+
"tags": [],
|
|
310
|
+
"text": ""
|
|
311
|
+
},
|
|
312
|
+
"complexType": {
|
|
313
|
+
"original": "any",
|
|
314
|
+
"resolved": "any",
|
|
315
|
+
"references": {}
|
|
316
|
+
}
|
|
317
|
+
}];
|
|
318
|
+
}
|
|
319
|
+
static get listeners() {
|
|
320
|
+
return [{
|
|
321
|
+
"name": "paginationReset",
|
|
322
|
+
"method": "pageLimitChangedHandler",
|
|
323
|
+
"target": "window",
|
|
324
|
+
"capture": false,
|
|
325
|
+
"passive": false
|
|
326
|
+
}, {
|
|
327
|
+
"name": "pageLimitChanged",
|
|
328
|
+
"method": "pageLimitChangedHandler",
|
|
329
|
+
"target": "window",
|
|
330
|
+
"capture": false,
|
|
331
|
+
"passive": false
|
|
332
|
+
}];
|
|
333
|
+
}
|
|
334
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BonusPaginationNav } from './bonus-pagination-nav';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
2
|
+
const SUPPORTED_LANGUAGES = ['pt-br', 'en', 'es-mx', 'hu', 'hr'];
|
|
3
|
+
export const TRANSLATIONS = {
|
|
4
|
+
"en": {
|
|
5
|
+
"firstPage": '|<',
|
|
6
|
+
"lastPage": '>|',
|
|
7
|
+
"prePage": '<',
|
|
8
|
+
"nextPage": '>',
|
|
9
|
+
"pageOfTotal": '{start}-{end} of {total}',
|
|
10
|
+
},
|
|
11
|
+
"hu": {
|
|
12
|
+
"firstPage": 'First',
|
|
13
|
+
"lastPage": 'Last',
|
|
14
|
+
"prePage": '<',
|
|
15
|
+
"nextPage": '>',
|
|
16
|
+
"pageOfTotal": '{start}-{end} of {total}',
|
|
17
|
+
},
|
|
18
|
+
"hr": {
|
|
19
|
+
"firstPage": 'First',
|
|
20
|
+
"lastPage": 'Last',
|
|
21
|
+
"prePage": '<',
|
|
22
|
+
"nextPage": '>',
|
|
23
|
+
"pageOfTotal": '{start}-{end} of {total}',
|
|
24
|
+
},
|
|
25
|
+
"pt-br": {
|
|
26
|
+
"firstPage": 'First',
|
|
27
|
+
"lastPage": 'Last',
|
|
28
|
+
"prePage": '<',
|
|
29
|
+
"nextPage": '>',
|
|
30
|
+
"pageOfTotal": '{start}-{end} of {total}',
|
|
31
|
+
},
|
|
32
|
+
"es-mx": {
|
|
33
|
+
"firstPage": 'First',
|
|
34
|
+
"lastPage": 'Last',
|
|
35
|
+
"prePage": '<',
|
|
36
|
+
"nextPage": '>',
|
|
37
|
+
"pageOfTotal": '{start}-{end} of {total}',
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
export const translate = (key, customLang, values) => {
|
|
41
|
+
const lang = customLang;
|
|
42
|
+
let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
43
|
+
if (values !== undefined) {
|
|
44
|
+
for (const [key, value] of Object.entries(values.values)) {
|
|
45
|
+
const regex = new RegExp(`{${key}}`, 'g');
|
|
46
|
+
translation = translation.replace(regex, value);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return translation;
|
|
50
|
+
};
|
|
51
|
+
export const getTranslations = (url) => {
|
|
52
|
+
// fetch url, get the data, replace the TRANSLATIONS content
|
|
53
|
+
return new Promise((resolve) => {
|
|
54
|
+
fetch(url)
|
|
55
|
+
.then((res) => res.json())
|
|
56
|
+
.then((data) => {
|
|
57
|
+
Object.keys(data).forEach((item) => {
|
|
58
|
+
for (let key in data[item]) {
|
|
59
|
+
TRANSLATIONS[item][key] = data[item][key];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
resolve(true);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { r as registerInstance, c as createEvent, h } from './index-332d0149.js';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
4
|
+
const SUPPORTED_LANGUAGES = ['pt-br', 'en', 'es-mx', 'hu', 'hr'];
|
|
5
|
+
const TRANSLATIONS = {
|
|
6
|
+
"en": {
|
|
7
|
+
"firstPage": '|<',
|
|
8
|
+
"lastPage": '>|',
|
|
9
|
+
"prePage": '<',
|
|
10
|
+
"nextPage": '>',
|
|
11
|
+
"pageOfTotal": '{start}-{end} of {total}',
|
|
12
|
+
},
|
|
13
|
+
"hu": {
|
|
14
|
+
"firstPage": 'First',
|
|
15
|
+
"lastPage": 'Last',
|
|
16
|
+
"prePage": '<',
|
|
17
|
+
"nextPage": '>',
|
|
18
|
+
"pageOfTotal": '{start}-{end} of {total}',
|
|
19
|
+
},
|
|
20
|
+
"hr": {
|
|
21
|
+
"firstPage": 'First',
|
|
22
|
+
"lastPage": 'Last',
|
|
23
|
+
"prePage": '<',
|
|
24
|
+
"nextPage": '>',
|
|
25
|
+
"pageOfTotal": '{start}-{end} of {total}',
|
|
26
|
+
},
|
|
27
|
+
"pt-br": {
|
|
28
|
+
"firstPage": 'First',
|
|
29
|
+
"lastPage": 'Last',
|
|
30
|
+
"prePage": '<',
|
|
31
|
+
"nextPage": '>',
|
|
32
|
+
"pageOfTotal": '{start}-{end} of {total}',
|
|
33
|
+
},
|
|
34
|
+
"es-mx": {
|
|
35
|
+
"firstPage": 'First',
|
|
36
|
+
"lastPage": 'Last',
|
|
37
|
+
"prePage": '<',
|
|
38
|
+
"nextPage": '>',
|
|
39
|
+
"pageOfTotal": '{start}-{end} of {total}',
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const translate = (key, customLang, values) => {
|
|
43
|
+
const lang = customLang;
|
|
44
|
+
let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
45
|
+
if (values !== undefined) {
|
|
46
|
+
for (const [key, value] of Object.entries(values.values)) {
|
|
47
|
+
const regex = new RegExp(`{${key}}`, 'g');
|
|
48
|
+
translation = translation.replace(regex, value);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return translation;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const bonusPaginationNavCss = ":host{display:block}.PageNavigationWrapper{display:flex;flex-direction:row}.PageNavigationWrapper .PageOfMessage{margin:5px;padding:5px 6px;margin:2px}.PageNavigation{display:flex;flex-direction:row;align-items:center}.PageNavigation .PageArrow{color:var(--emfe-w-color-primary, #777676);padding:6px 5px;cursor:pointer;font-weight:bold;width:1.2rem;text-align:center}.PageNavigation .PageArrow.Disabled{color:var(--emfe-w-color-gray-100, #e0e0e0)}ul.PaginationArea{list-style:none;padding:0px;margin:0px;display:flex}ul.PaginationArea li.PageItem{cursor:pointer;padding:5px 6px;margin:2px;width:0.9rem;text-align:center}ul.PaginationArea li.PageItem.Active,ul.PaginationArea li.PageItem:hover{font-weight:bold;color:var(--emfe-w-color-primary, #f5f1f1);background-color:var(--emfe-w-color-secondary, #8c8989);border-radius:0.3rem}";
|
|
55
|
+
const BonusPaginationNavStyle0 = bonusPaginationNavCss;
|
|
56
|
+
|
|
57
|
+
const BonusPaginationNav = class {
|
|
58
|
+
constructor(hostRef) {
|
|
59
|
+
registerInstance(this, hostRef);
|
|
60
|
+
this.reloadPageEmitter = createEvent(this, "reloadPageByType", 7);
|
|
61
|
+
this.total = 1;
|
|
62
|
+
this.limit = 10;
|
|
63
|
+
this.offset = 0;
|
|
64
|
+
this.tableId = 'default';
|
|
65
|
+
this.language = 'en';
|
|
66
|
+
this.translationUrl = '';
|
|
67
|
+
this.arrowsActive = true;
|
|
68
|
+
this.secondaryArrowsActive = true;
|
|
69
|
+
this.displayPageNumbers = true;
|
|
70
|
+
this.displayRangeOfTotal = undefined;
|
|
71
|
+
this.endPageIndex = 0;
|
|
72
|
+
this.pagesArray = undefined;
|
|
73
|
+
this.currentPage = 1;
|
|
74
|
+
}
|
|
75
|
+
pageLimitChangedHandler(event) {
|
|
76
|
+
this.limit = event.detail.limit ? event.detail.limit : this.limit;
|
|
77
|
+
//reset offset = 0, this.currentPage = 1 when page limit changed
|
|
78
|
+
this.currentPage = 1;
|
|
79
|
+
this.offset = 0;
|
|
80
|
+
this.updatePageStatus();
|
|
81
|
+
if (event.type == 'pageLimitChanged') {
|
|
82
|
+
this.reloadPageEmitter.emit({ offset: 0, limit: this.limit, tableId: this.tableId });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
goTo(step) {
|
|
86
|
+
if (step == '...' || step == 0 || parseInt(step.toString(), 10) > (this.endPageIndex + 1)) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
this.currentPage = step;
|
|
90
|
+
let offset = (this.currentPage - 1) * this.limit;
|
|
91
|
+
this.reloadPageEmitter.emit({ offset, limit: this.limit, tableId: this.tableId });
|
|
92
|
+
}
|
|
93
|
+
renderPageList() {
|
|
94
|
+
return h("ul", { class: 'PaginationArea' }, this.pagesArray.map((page) => {
|
|
95
|
+
return (h("li", { class: `PageItem ${this.currentPage == page ? 'Active' : ''}`, onClick: () => {
|
|
96
|
+
this.goTo(page);
|
|
97
|
+
} }, page));
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
renderStylingWrapper() {
|
|
101
|
+
return h("general-styling-wrapper", { targetTranslations: TRANSLATIONS, translationUrl: this.translationUrl });
|
|
102
|
+
}
|
|
103
|
+
updatePageStatus() {
|
|
104
|
+
this.endPageIndex = (Math.ceil(this.total / this.limit) - 1);
|
|
105
|
+
this.endPageIndex = this.endPageIndex < 0 ? this.endPageIndex = 0 : this.endPageIndex;
|
|
106
|
+
this.pagesArray = [];
|
|
107
|
+
if (this.endPageIndex < 5) {
|
|
108
|
+
this.pagesArray = Array.from({ length: this.endPageIndex + 1 }, (_, i) => i + 1);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
/**
|
|
112
|
+
* Construct numbered navigation area based on current page position
|
|
113
|
+
*/
|
|
114
|
+
if (this.currentPage == 1 || this.currentPage == 2) {
|
|
115
|
+
this.pagesArray = Array.from({ length: 4 }, (_, i) => i + 1);
|
|
116
|
+
this.pagesArray.push('...');
|
|
117
|
+
}
|
|
118
|
+
else if (this.currentPage >= 3 && ((this.endPageIndex - this.currentPage) >= 2)) {
|
|
119
|
+
this.pagesArray = Array.from({ length: 3 }, (_, i) => this.currentPage + i - 1);
|
|
120
|
+
this.pagesArray.push('...');
|
|
121
|
+
this.pagesArray.unshift('...');
|
|
122
|
+
}
|
|
123
|
+
else if ((this.endPageIndex - this.currentPage) < 3) {
|
|
124
|
+
this.pagesArray = Array.from({ length: 4 }, (_, i) => this.endPageIndex - 2 + i);
|
|
125
|
+
this.pagesArray.unshift('...');
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
componentWillRender() {
|
|
130
|
+
this.currentPage = Math.floor(this.offset / this.limit) + 1;
|
|
131
|
+
this.updatePageStatus();
|
|
132
|
+
}
|
|
133
|
+
render() {
|
|
134
|
+
const startOffset = (this.currentPage - 1) * this.limit + 1;
|
|
135
|
+
const endOffset = this.currentPage * this.limit > this.total ? this.total : this.currentPage * this.limit;
|
|
136
|
+
return h("div", { key: 'a6817c12f1e1e9960f8e91cfd5c5e2fa1ea72f7f', class: 'PageNavigationWrapper' }, this.displayRangeOfTotal && this.total > 0 && h("span", { key: '8f7a16c5835147e2a83808f882a66a2463e3998e', class: 'PageOfMessage' }, translate('pageOfTotal', this.language, {
|
|
137
|
+
values: {
|
|
138
|
+
start: startOffset,
|
|
139
|
+
end: endOffset,
|
|
140
|
+
total: this.total
|
|
141
|
+
}
|
|
142
|
+
})), h("div", { key: 'ddc20a86777c2fde667ad8b75ab86f3bc72ccfdb', class: 'PageNavigation' }, this.arrowsActive &&
|
|
143
|
+
h("div", { key: 'ce2a45b8c0d6e32cfa3f1c5cc8b3c9ac58acc409', class: `PageArrow FirstPage ${this.currentPage == 1 ? 'Disabled' : ''}`, onClick: () => {
|
|
144
|
+
this.goTo(1);
|
|
145
|
+
} }, translate('firstPage', this.language)), this.secondaryArrowsActive &&
|
|
146
|
+
h("span", { key: '82dce028e4283dcac511b3b62823e87f2085f4b5', class: `PageArrow PrePage ${this.currentPage == 1 ? 'Disabled' : ''}`, onClick: () => {
|
|
147
|
+
this.goTo(this.currentPage - 1);
|
|
148
|
+
} }, translate('prePage', this.language)), this.displayPageNumbers && this.renderPageList(), this.secondaryArrowsActive &&
|
|
149
|
+
h("span", { key: 'a6ed748ce3e2555ac3d9d4bae174ad5bad0fabec', class: `PageArrow NextPage ${this.currentPage == (this.endPageIndex + 1) ? 'Disabled' : ''}`, onClick: () => {
|
|
150
|
+
this.goTo(this.currentPage + 1);
|
|
151
|
+
} }, translate('nextPage', this.language)), this.arrowsActive &&
|
|
152
|
+
h("div", { key: '60a81a86f11e2bb07ee93b61d6f367a11b0e2b6c', class: `PageArrow LastPage ${this.currentPage == this.endPageIndex + 1 ? 'Disabled' : ''}`, onClick: () => {
|
|
153
|
+
this.goTo(this.endPageIndex + 1);
|
|
154
|
+
} }, " ", translate('lastPage', this.language), " "), this.renderStylingWrapper()));
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
BonusPaginationNav.style = BonusPaginationNavStyle0;
|
|
158
|
+
|
|
159
|
+
export { BonusPaginationNav as bonus_pagination_nav };
|