@everymatrix/helper-pagination 1.31.1 → 1.32.4
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/LICENSE +21 -0
- package/package.json +3 -2
- package/dist/cjs/helper-pagination.cjs.entry.js +0 -257
- package/dist/cjs/helper-pagination.cjs.js +0 -19
- package/dist/cjs/index-7c071a78.js +0 -1185
- package/dist/cjs/index.cjs.js +0 -2
- package/dist/cjs/loader.cjs.js +0 -21
- package/dist/collection/collection-manifest.json +0 -12
- package/dist/collection/components/helper-pagination/helper-pagination.css +0 -139
- package/dist/collection/components/helper-pagination/helper-pagination.js +0 -443
- package/dist/collection/index.js +0 -1
- package/dist/collection/utils/locale.utils.js +0 -44
- package/dist/collection/utils/utils.js +0 -15
- package/dist/components/helper-pagination.d.ts +0 -11
- package/dist/components/helper-pagination.js +0 -291
- package/dist/components/index.d.ts +0 -26
- package/dist/components/index.js +0 -1
- package/dist/esm/helper-pagination.entry.js +0 -253
- package/dist/esm/helper-pagination.js +0 -17
- package/dist/esm/index-b281577e.js +0 -1159
- package/dist/esm/index.js +0 -1
- package/dist/esm/loader.js +0 -17
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/helper-pagination/helper-pagination.esm.js +0 -1
- package/dist/helper-pagination/index.esm.js +0 -0
- package/dist/helper-pagination/p-ea9ded6d.entry.js +0 -1
- package/dist/helper-pagination/p-eab215a1.js +0 -1
- package/dist/index.cjs.js +0 -1
- package/dist/index.js +0 -1
- package/dist/stencil.config.js +0 -22
- package/dist/types/Users/sebastian.strulea/Documents/work/widgets-stencil/packages/helper-pagination/.stencil/packages/helper-pagination/stencil.config.d.ts +0 -2
- package/dist/types/components/helper-pagination/helper-pagination.d.ts +0 -96
- package/dist/types/components.d.ts +0 -129
- package/dist/types/index.d.ts +0 -1
- package/dist/types/stencil-public-runtime.d.ts +0 -1565
- package/dist/types/utils/locale.utils.d.ts +0 -1
- package/dist/types/utils/utils.d.ts +0 -8
- package/loader/cdn.js +0 -3
- package/loader/index.cjs.js +0 -3
- package/loader/index.d.ts +0 -12
- package/loader/index.es2017.js +0 -3
- package/loader/index.js +0 -4
- package/loader/package.json +0 -10
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @name isMobile
|
|
5
|
-
* @description A method that returns if the browser used to access the app is from a mobile device or not
|
|
6
|
-
* @param {String} userAgent window.navigator.userAgent
|
|
7
|
-
* @returns {Boolean} true or false
|
|
8
|
-
*/
|
|
9
|
-
const isMobile = (userAgent) => {
|
|
10
|
-
return !!(userAgent.toLowerCase().match(/android/i) ||
|
|
11
|
-
userAgent.toLowerCase().match(/blackberry|bb/i) ||
|
|
12
|
-
userAgent.toLowerCase().match(/iphone|ipad|ipod/i) ||
|
|
13
|
-
userAgent.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i));
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const DEFAULT_LANGUAGE = 'en';
|
|
17
|
-
const SUPPORTED_LANGUAGES = ['ro', 'en', 'hu', 'hr'];
|
|
18
|
-
const TRANSLATIONS = {
|
|
19
|
-
en: {
|
|
20
|
-
firstPage: 'First',
|
|
21
|
-
previousPage: 'Previous',
|
|
22
|
-
nextPage: 'Next',
|
|
23
|
-
lastPage: 'Last'
|
|
24
|
-
},
|
|
25
|
-
ro: {
|
|
26
|
-
firstPage: 'Prima',
|
|
27
|
-
previousPage: 'Anterior',
|
|
28
|
-
nextPage: 'Urmatoarea',
|
|
29
|
-
lastPage: 'Ultima'
|
|
30
|
-
},
|
|
31
|
-
fr: {
|
|
32
|
-
firstPage: 'First',
|
|
33
|
-
previousPage: 'Previous',
|
|
34
|
-
nextPage: 'Next',
|
|
35
|
-
lastPage: 'Last'
|
|
36
|
-
},
|
|
37
|
-
ar: {
|
|
38
|
-
firstPage: 'First',
|
|
39
|
-
previousPage: 'Previous',
|
|
40
|
-
nextPage: 'Next',
|
|
41
|
-
lastPage: 'Last'
|
|
42
|
-
},
|
|
43
|
-
hu: {
|
|
44
|
-
firstPage: 'First',
|
|
45
|
-
previousPage: 'Previous',
|
|
46
|
-
nextPage: 'Következő',
|
|
47
|
-
lastPage: 'Last'
|
|
48
|
-
},
|
|
49
|
-
hr: {
|
|
50
|
-
firstPage: 'Prva',
|
|
51
|
-
previousPage: 'Prethodna',
|
|
52
|
-
nextPage: 'Slijedeća',
|
|
53
|
-
lastPage: 'Zadnja'
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const translate = (key, customLang) => {
|
|
57
|
-
const lang = customLang;
|
|
58
|
-
return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
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}}";
|
|
62
|
-
|
|
63
|
-
const HelperPagination$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
64
|
-
constructor() {
|
|
65
|
-
super();
|
|
66
|
-
this.__registerHost();
|
|
67
|
-
this.__attachShadow();
|
|
68
|
-
this.hpPageChange = createEvent(this, "hpPageChange", 7);
|
|
69
|
-
/**
|
|
70
|
-
* Next page string value - determines if the next page is disabled or active
|
|
71
|
-
*/
|
|
72
|
-
this.nextPage = '';
|
|
73
|
-
/**
|
|
74
|
-
* Previous page string value - determines if the previous page is disabled or active
|
|
75
|
-
*/
|
|
76
|
-
this.prevPage = '';
|
|
77
|
-
/**
|
|
78
|
-
* The received offset
|
|
79
|
-
*/
|
|
80
|
-
this.offset = 0;
|
|
81
|
-
/**
|
|
82
|
-
* The received limit for the number of pages
|
|
83
|
-
*/
|
|
84
|
-
this.limit = 1;
|
|
85
|
-
/**
|
|
86
|
-
* The received total number of pages
|
|
87
|
-
*/
|
|
88
|
-
this.total = 1;
|
|
89
|
-
/**
|
|
90
|
-
* Language
|
|
91
|
-
*/
|
|
92
|
-
this.language = 'en';
|
|
93
|
-
/**
|
|
94
|
-
* Client custom styling via string
|
|
95
|
-
*/
|
|
96
|
-
this.clientStyling = '';
|
|
97
|
-
/**
|
|
98
|
-
* Client custom styling via url content
|
|
99
|
-
*/
|
|
100
|
-
this.clientStylingUrlContent = '';
|
|
101
|
-
/**
|
|
102
|
-
* Component working variable for last page
|
|
103
|
-
*/
|
|
104
|
-
this.lastPage = false;
|
|
105
|
-
/**
|
|
106
|
-
* Component working variable for prvious page
|
|
107
|
-
*/
|
|
108
|
-
this.previousPage = false;
|
|
109
|
-
/**
|
|
110
|
-
* In component working variable for the array of pages
|
|
111
|
-
*/
|
|
112
|
-
this.pagesArray = [];
|
|
113
|
-
/**
|
|
114
|
-
* In component working variable for last page
|
|
115
|
-
*/
|
|
116
|
-
this.endInt = 0;
|
|
117
|
-
this.userAgent = window.navigator.userAgent;
|
|
118
|
-
this.currentPage = 1;
|
|
119
|
-
this.limitStylingAppends = false;
|
|
120
|
-
/**
|
|
121
|
-
* Navigation logic
|
|
122
|
-
*/
|
|
123
|
-
this.navigateTo = (navigationPage) => {
|
|
124
|
-
switch (navigationPage) {
|
|
125
|
-
case 'firstPage':
|
|
126
|
-
this.offsetInt = 0;
|
|
127
|
-
break;
|
|
128
|
-
case 'lastPage':
|
|
129
|
-
this.offsetInt = this.endInt * this.limitInt;
|
|
130
|
-
break;
|
|
131
|
-
case 'previousPage':
|
|
132
|
-
this.offsetInt -= this.limitInt;
|
|
133
|
-
break;
|
|
134
|
-
case 'nextPage':
|
|
135
|
-
this.offsetInt += this.limitInt;
|
|
136
|
-
break;
|
|
137
|
-
case 'fivePagesBack':
|
|
138
|
-
this.offsetInt -= this.limitInt * 5;
|
|
139
|
-
this.offsetInt = this.offsetInt <= 0 ? 0 : this.offsetInt;
|
|
140
|
-
break;
|
|
141
|
-
case 'fivePagesForward':
|
|
142
|
-
this.offsetInt += this.limitInt * 5;
|
|
143
|
-
this.offsetInt = this.offsetInt / this.limitInt >= this.endInt ? this.endInt * this.limitInt : this.offsetInt;
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
this.previousPage = !this.offsetInt ? false : true;
|
|
147
|
-
this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
|
|
148
|
-
};
|
|
149
|
-
/**
|
|
150
|
-
* Handle navigation from here
|
|
151
|
-
*/
|
|
152
|
-
this.paginationNavigation = (pageNumber, index) => {
|
|
153
|
-
this.previousPage = true;
|
|
154
|
-
if (!isNaN(pageNumber)) {
|
|
155
|
-
if (pageNumber === 1) {
|
|
156
|
-
this.offsetInt = pageNumber - 1;
|
|
157
|
-
this.previousPage = false;
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
this.offsetInt = (pageNumber - 1) * this.limitInt;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
if (index === 0 && this.currentPage <= 4) {
|
|
165
|
-
this.navigateTo('firstPage');
|
|
166
|
-
}
|
|
167
|
-
else if (index === 0 && this.currentPage > 4) {
|
|
168
|
-
this.navigateTo('fivePagesBack');
|
|
169
|
-
}
|
|
170
|
-
else if (index === 4 && this.endInt - this.currentPage >= 2) {
|
|
171
|
-
this.navigateTo('fivePagesForward');
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
|
|
175
|
-
};
|
|
176
|
-
this.setClientStyling = () => {
|
|
177
|
-
let sheet = document.createElement('style');
|
|
178
|
-
sheet.innerHTML = this.clientStyling;
|
|
179
|
-
this.stylingContainer.prepend(sheet);
|
|
180
|
-
};
|
|
181
|
-
this.setClientStylingURL = () => {
|
|
182
|
-
let cssFile = document.createElement('style');
|
|
183
|
-
setTimeout(() => {
|
|
184
|
-
cssFile.innerHTML = this.clientStylingUrlContent;
|
|
185
|
-
this.stylingContainer.prepend(cssFile);
|
|
186
|
-
}, 1);
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
componentWillRender() {
|
|
190
|
-
this.offsetInt = this.offset;
|
|
191
|
-
this.limitInt = this.limit;
|
|
192
|
-
this.currentPage = (this.offsetInt / this.limitInt) + 1;
|
|
193
|
-
this.limitInt = this.limit;
|
|
194
|
-
this.totalInt = this.total;
|
|
195
|
-
this.endInt = (Math.ceil(this.totalInt / this.limitInt) - 1);
|
|
196
|
-
this.lastPage = (this.offsetInt >= this.endInt * this.limitInt) ? false : true;
|
|
197
|
-
/**
|
|
198
|
-
* Construct numbered navigation area based on current page position
|
|
199
|
-
*/
|
|
200
|
-
if (this.currentPage == 1 || this.currentPage == 2) {
|
|
201
|
-
this.pagesArray = Array.from({ length: 4 }, (_, i) => i + 1);
|
|
202
|
-
this.pagesArray.push('...');
|
|
203
|
-
}
|
|
204
|
-
else if (this.currentPage >= 3 && ((this.endInt - this.currentPage) >= 2)) {
|
|
205
|
-
this.pagesArray = Array.from({ length: 3 }, (_, i) => this.currentPage + i - 1);
|
|
206
|
-
this.pagesArray.push('...');
|
|
207
|
-
this.pagesArray.unshift('...');
|
|
208
|
-
}
|
|
209
|
-
else if ((this.endInt - this.currentPage) < 3) {
|
|
210
|
-
this.pagesArray = Array.from({ length: 4 }, (_, i) => this.endInt - 2 + i);
|
|
211
|
-
this.pagesArray.unshift('...');
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
componentDidRender() {
|
|
215
|
-
// start custom styling area
|
|
216
|
-
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
217
|
-
if (this.clientStyling)
|
|
218
|
-
this.setClientStyling();
|
|
219
|
-
if (this.clientStylingUrlContent)
|
|
220
|
-
this.setClientStylingURL();
|
|
221
|
-
this.limitStylingAppends = true;
|
|
222
|
-
}
|
|
223
|
-
// end custom styling area
|
|
224
|
-
}
|
|
225
|
-
render() {
|
|
226
|
-
/**
|
|
227
|
-
* Center navigation area
|
|
228
|
-
*/
|
|
229
|
-
let navigationArea = h("ul", { class: "PaginationArea" }, this.pagesArray.map((item, index) => {
|
|
230
|
-
return (h("li", { class: 'PaginationItem' + (item === this.currentPage ? ' ActiveItem' : ' ') + ' ' + (isMobile(this.userAgent) ? 'MobileButtons' : '') }, h("button", { disabled: item === this.currentPage ? true : false, onClick: this.paginationNavigation.bind(this, item, index) }, h("span", null, item))));
|
|
231
|
-
}));
|
|
232
|
-
/**
|
|
233
|
-
* Left navigation area
|
|
234
|
-
*/
|
|
235
|
-
let buttonSecondaryLeftSide = h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'firstPage') }, h("span", { class: "NavigationButton" }, translate('firstPage', this.language)), h("span", { class: "NavigationIcon" }));
|
|
236
|
-
let buttonsLeftSide = h("div", { class: "LeftItems" }, this.secondaryArrowsActive && buttonSecondaryLeftSide, h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'previousPage') }, h("span", { class: "NavigationButton" }, translate('previousPage', this.language)), h("span", { class: "NavigationIcon" })));
|
|
237
|
-
if (isMobile(this.userAgent)) {
|
|
238
|
-
buttonsLeftSide =
|
|
239
|
-
h("div", { class: "LeftItems" }, h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'previousPage') }, h("span", { class: "NavigationButton" }, translate('previousPage', this.language)), h("span", { class: "NavigationIcon" })));
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Right navigation area
|
|
243
|
-
*/
|
|
244
|
-
let buttonSecondaryRightSide = h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'lastPage') }, h("span", { class: "NavigationButton" }, translate('lastPage', this.language)), h("span", { class: "NavigationIcon" }));
|
|
245
|
-
let buttonsRightSide = h("div", { class: "RightItems" }, h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'nextPage') }, h("span", { class: "NavigationButton" }, translate('nextPage', this.language)), h("span", { class: "NavigationIcon" })), this.secondaryArrowsActive && buttonSecondaryRightSide);
|
|
246
|
-
if (isMobile(this.userAgent)) {
|
|
247
|
-
buttonsRightSide =
|
|
248
|
-
h("div", { class: "RightItems" }, h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'nextPage') }, h("span", { class: "NavigationButton" }, translate('nextPage', this.language)), h("span", { class: "NavigationIcon" })));
|
|
249
|
-
}
|
|
250
|
-
return (h("div", { id: "PaginationContainer", ref: el => this.stylingContainer = el }, this.arrowsActive && buttonsLeftSide, this.numberedNavActive && navigationArea, this.arrowsActive && buttonsRightSide));
|
|
251
|
-
}
|
|
252
|
-
static get style() { return helperPaginationCss; }
|
|
253
|
-
}, [1, "helper-pagination", {
|
|
254
|
-
"nextPage": [1537, "next-page"],
|
|
255
|
-
"prevPage": [1537, "prev-page"],
|
|
256
|
-
"offset": [1538],
|
|
257
|
-
"limit": [1538],
|
|
258
|
-
"total": [1538],
|
|
259
|
-
"language": [1537],
|
|
260
|
-
"clientStyling": [1537, "client-styling"],
|
|
261
|
-
"clientStylingUrlContent": [1537, "client-styling-url-content"],
|
|
262
|
-
"arrowsActive": [1540, "arrows-active"],
|
|
263
|
-
"secondaryArrowsActive": [1540, "secondary-arrows-active"],
|
|
264
|
-
"numberedNavActive": [1540, "numbered-nav-active"],
|
|
265
|
-
"offsetInt": [32],
|
|
266
|
-
"lastPage": [32],
|
|
267
|
-
"previousPage": [32],
|
|
268
|
-
"limitInt": [32],
|
|
269
|
-
"totalInt": [32],
|
|
270
|
-
"pagesArray": [32],
|
|
271
|
-
"endInt": [32],
|
|
272
|
-
"limitStylingAppends": [32]
|
|
273
|
-
}]);
|
|
274
|
-
function defineCustomElement$1() {
|
|
275
|
-
if (typeof customElements === "undefined") {
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
const components = ["helper-pagination"];
|
|
279
|
-
components.forEach(tagName => { switch (tagName) {
|
|
280
|
-
case "helper-pagination":
|
|
281
|
-
if (!customElements.get(tagName)) {
|
|
282
|
-
customElements.define(tagName, HelperPagination$1);
|
|
283
|
-
}
|
|
284
|
-
break;
|
|
285
|
-
} });
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
const HelperPagination = HelperPagination$1;
|
|
289
|
-
const defineCustomElement = defineCustomElement$1;
|
|
290
|
-
|
|
291
|
-
export { HelperPagination, defineCustomElement };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/* HelperPagination custom elements */
|
|
2
|
-
|
|
3
|
-
import type { Components, JSX } from "../types/components";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Used to manually set the base path where assets can be found.
|
|
7
|
-
* If the script is used as "module", it's recommended to use "import.meta.url",
|
|
8
|
-
* such as "setAssetPath(import.meta.url)". Other options include
|
|
9
|
-
* "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
|
|
10
|
-
* dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
|
|
11
|
-
* But do note that this configuration depends on how your script is bundled, or lack of
|
|
12
|
-
* bundling, and where your assets can be loaded from. Additionally custom bundling
|
|
13
|
-
* will have to ensure the static assets are copied to its build directory.
|
|
14
|
-
*/
|
|
15
|
-
export declare const setAssetPath: (path: string) => void;
|
|
16
|
-
|
|
17
|
-
export interface SetPlatformOptions {
|
|
18
|
-
raf?: (c: FrameRequestCallback) => number;
|
|
19
|
-
ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
20
|
-
rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
21
|
-
}
|
|
22
|
-
export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
|
|
23
|
-
|
|
24
|
-
export type { Components, JSX };
|
|
25
|
-
|
|
26
|
-
export * from '../types';
|
package/dist/components/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h } from './index-b281577e.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @name isMobile
|
|
5
|
-
* @description A method that returns if the browser used to access the app is from a mobile device or not
|
|
6
|
-
* @param {String} userAgent window.navigator.userAgent
|
|
7
|
-
* @returns {Boolean} true or false
|
|
8
|
-
*/
|
|
9
|
-
const isMobile = (userAgent) => {
|
|
10
|
-
return !!(userAgent.toLowerCase().match(/android/i) ||
|
|
11
|
-
userAgent.toLowerCase().match(/blackberry|bb/i) ||
|
|
12
|
-
userAgent.toLowerCase().match(/iphone|ipad|ipod/i) ||
|
|
13
|
-
userAgent.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i));
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const DEFAULT_LANGUAGE = 'en';
|
|
17
|
-
const SUPPORTED_LANGUAGES = ['ro', 'en', 'hu', 'hr'];
|
|
18
|
-
const TRANSLATIONS = {
|
|
19
|
-
en: {
|
|
20
|
-
firstPage: 'First',
|
|
21
|
-
previousPage: 'Previous',
|
|
22
|
-
nextPage: 'Next',
|
|
23
|
-
lastPage: 'Last'
|
|
24
|
-
},
|
|
25
|
-
ro: {
|
|
26
|
-
firstPage: 'Prima',
|
|
27
|
-
previousPage: 'Anterior',
|
|
28
|
-
nextPage: 'Urmatoarea',
|
|
29
|
-
lastPage: 'Ultima'
|
|
30
|
-
},
|
|
31
|
-
fr: {
|
|
32
|
-
firstPage: 'First',
|
|
33
|
-
previousPage: 'Previous',
|
|
34
|
-
nextPage: 'Next',
|
|
35
|
-
lastPage: 'Last'
|
|
36
|
-
},
|
|
37
|
-
ar: {
|
|
38
|
-
firstPage: 'First',
|
|
39
|
-
previousPage: 'Previous',
|
|
40
|
-
nextPage: 'Next',
|
|
41
|
-
lastPage: 'Last'
|
|
42
|
-
},
|
|
43
|
-
hu: {
|
|
44
|
-
firstPage: 'First',
|
|
45
|
-
previousPage: 'Previous',
|
|
46
|
-
nextPage: 'Következő',
|
|
47
|
-
lastPage: 'Last'
|
|
48
|
-
},
|
|
49
|
-
hr: {
|
|
50
|
-
firstPage: 'Prva',
|
|
51
|
-
previousPage: 'Prethodna',
|
|
52
|
-
nextPage: 'Slijedeća',
|
|
53
|
-
lastPage: 'Zadnja'
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const translate = (key, customLang) => {
|
|
57
|
-
const lang = customLang;
|
|
58
|
-
return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
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}}";
|
|
62
|
-
|
|
63
|
-
const HelperPagination = class {
|
|
64
|
-
constructor(hostRef) {
|
|
65
|
-
registerInstance(this, hostRef);
|
|
66
|
-
this.hpPageChange = createEvent(this, "hpPageChange", 7);
|
|
67
|
-
/**
|
|
68
|
-
* Next page string value - determines if the next page is disabled or active
|
|
69
|
-
*/
|
|
70
|
-
this.nextPage = '';
|
|
71
|
-
/**
|
|
72
|
-
* Previous page string value - determines if the previous page is disabled or active
|
|
73
|
-
*/
|
|
74
|
-
this.prevPage = '';
|
|
75
|
-
/**
|
|
76
|
-
* The received offset
|
|
77
|
-
*/
|
|
78
|
-
this.offset = 0;
|
|
79
|
-
/**
|
|
80
|
-
* The received limit for the number of pages
|
|
81
|
-
*/
|
|
82
|
-
this.limit = 1;
|
|
83
|
-
/**
|
|
84
|
-
* The received total number of pages
|
|
85
|
-
*/
|
|
86
|
-
this.total = 1;
|
|
87
|
-
/**
|
|
88
|
-
* Language
|
|
89
|
-
*/
|
|
90
|
-
this.language = 'en';
|
|
91
|
-
/**
|
|
92
|
-
* Client custom styling via string
|
|
93
|
-
*/
|
|
94
|
-
this.clientStyling = '';
|
|
95
|
-
/**
|
|
96
|
-
* Client custom styling via url content
|
|
97
|
-
*/
|
|
98
|
-
this.clientStylingUrlContent = '';
|
|
99
|
-
/**
|
|
100
|
-
* Component working variable for last page
|
|
101
|
-
*/
|
|
102
|
-
this.lastPage = false;
|
|
103
|
-
/**
|
|
104
|
-
* Component working variable for prvious page
|
|
105
|
-
*/
|
|
106
|
-
this.previousPage = false;
|
|
107
|
-
/**
|
|
108
|
-
* In component working variable for the array of pages
|
|
109
|
-
*/
|
|
110
|
-
this.pagesArray = [];
|
|
111
|
-
/**
|
|
112
|
-
* In component working variable for last page
|
|
113
|
-
*/
|
|
114
|
-
this.endInt = 0;
|
|
115
|
-
this.userAgent = window.navigator.userAgent;
|
|
116
|
-
this.currentPage = 1;
|
|
117
|
-
this.limitStylingAppends = false;
|
|
118
|
-
/**
|
|
119
|
-
* Navigation logic
|
|
120
|
-
*/
|
|
121
|
-
this.navigateTo = (navigationPage) => {
|
|
122
|
-
switch (navigationPage) {
|
|
123
|
-
case 'firstPage':
|
|
124
|
-
this.offsetInt = 0;
|
|
125
|
-
break;
|
|
126
|
-
case 'lastPage':
|
|
127
|
-
this.offsetInt = this.endInt * this.limitInt;
|
|
128
|
-
break;
|
|
129
|
-
case 'previousPage':
|
|
130
|
-
this.offsetInt -= this.limitInt;
|
|
131
|
-
break;
|
|
132
|
-
case 'nextPage':
|
|
133
|
-
this.offsetInt += this.limitInt;
|
|
134
|
-
break;
|
|
135
|
-
case 'fivePagesBack':
|
|
136
|
-
this.offsetInt -= this.limitInt * 5;
|
|
137
|
-
this.offsetInt = this.offsetInt <= 0 ? 0 : this.offsetInt;
|
|
138
|
-
break;
|
|
139
|
-
case 'fivePagesForward':
|
|
140
|
-
this.offsetInt += this.limitInt * 5;
|
|
141
|
-
this.offsetInt = this.offsetInt / this.limitInt >= this.endInt ? this.endInt * this.limitInt : this.offsetInt;
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
this.previousPage = !this.offsetInt ? false : true;
|
|
145
|
-
this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* Handle navigation from here
|
|
149
|
-
*/
|
|
150
|
-
this.paginationNavigation = (pageNumber, index) => {
|
|
151
|
-
this.previousPage = true;
|
|
152
|
-
if (!isNaN(pageNumber)) {
|
|
153
|
-
if (pageNumber === 1) {
|
|
154
|
-
this.offsetInt = pageNumber - 1;
|
|
155
|
-
this.previousPage = false;
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
this.offsetInt = (pageNumber - 1) * this.limitInt;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
if (index === 0 && this.currentPage <= 4) {
|
|
163
|
-
this.navigateTo('firstPage');
|
|
164
|
-
}
|
|
165
|
-
else if (index === 0 && this.currentPage > 4) {
|
|
166
|
-
this.navigateTo('fivePagesBack');
|
|
167
|
-
}
|
|
168
|
-
else if (index === 4 && this.endInt - this.currentPage >= 2) {
|
|
169
|
-
this.navigateTo('fivePagesForward');
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
|
|
173
|
-
};
|
|
174
|
-
this.setClientStyling = () => {
|
|
175
|
-
let sheet = document.createElement('style');
|
|
176
|
-
sheet.innerHTML = this.clientStyling;
|
|
177
|
-
this.stylingContainer.prepend(sheet);
|
|
178
|
-
};
|
|
179
|
-
this.setClientStylingURL = () => {
|
|
180
|
-
let cssFile = document.createElement('style');
|
|
181
|
-
setTimeout(() => {
|
|
182
|
-
cssFile.innerHTML = this.clientStylingUrlContent;
|
|
183
|
-
this.stylingContainer.prepend(cssFile);
|
|
184
|
-
}, 1);
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
componentWillRender() {
|
|
188
|
-
this.offsetInt = this.offset;
|
|
189
|
-
this.limitInt = this.limit;
|
|
190
|
-
this.currentPage = (this.offsetInt / this.limitInt) + 1;
|
|
191
|
-
this.limitInt = this.limit;
|
|
192
|
-
this.totalInt = this.total;
|
|
193
|
-
this.endInt = (Math.ceil(this.totalInt / this.limitInt) - 1);
|
|
194
|
-
this.lastPage = (this.offsetInt >= this.endInt * this.limitInt) ? false : true;
|
|
195
|
-
/**
|
|
196
|
-
* Construct numbered navigation area based on current page position
|
|
197
|
-
*/
|
|
198
|
-
if (this.currentPage == 1 || this.currentPage == 2) {
|
|
199
|
-
this.pagesArray = Array.from({ length: 4 }, (_, i) => i + 1);
|
|
200
|
-
this.pagesArray.push('...');
|
|
201
|
-
}
|
|
202
|
-
else if (this.currentPage >= 3 && ((this.endInt - this.currentPage) >= 2)) {
|
|
203
|
-
this.pagesArray = Array.from({ length: 3 }, (_, i) => this.currentPage + i - 1);
|
|
204
|
-
this.pagesArray.push('...');
|
|
205
|
-
this.pagesArray.unshift('...');
|
|
206
|
-
}
|
|
207
|
-
else if ((this.endInt - this.currentPage) < 3) {
|
|
208
|
-
this.pagesArray = Array.from({ length: 4 }, (_, i) => this.endInt - 2 + i);
|
|
209
|
-
this.pagesArray.unshift('...');
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
componentDidRender() {
|
|
213
|
-
// start custom styling area
|
|
214
|
-
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
215
|
-
if (this.clientStyling)
|
|
216
|
-
this.setClientStyling();
|
|
217
|
-
if (this.clientStylingUrlContent)
|
|
218
|
-
this.setClientStylingURL();
|
|
219
|
-
this.limitStylingAppends = true;
|
|
220
|
-
}
|
|
221
|
-
// end custom styling area
|
|
222
|
-
}
|
|
223
|
-
render() {
|
|
224
|
-
/**
|
|
225
|
-
* Center navigation area
|
|
226
|
-
*/
|
|
227
|
-
let navigationArea = h("ul", { class: "PaginationArea" }, this.pagesArray.map((item, index) => {
|
|
228
|
-
return (h("li", { class: 'PaginationItem' + (item === this.currentPage ? ' ActiveItem' : ' ') + ' ' + (isMobile(this.userAgent) ? 'MobileButtons' : '') }, h("button", { disabled: item === this.currentPage ? true : false, onClick: this.paginationNavigation.bind(this, item, index) }, h("span", null, item))));
|
|
229
|
-
}));
|
|
230
|
-
/**
|
|
231
|
-
* Left navigation area
|
|
232
|
-
*/
|
|
233
|
-
let buttonSecondaryLeftSide = h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'firstPage') }, h("span", { class: "NavigationButton" }, translate('firstPage', this.language)), h("span", { class: "NavigationIcon" }));
|
|
234
|
-
let buttonsLeftSide = h("div", { class: "LeftItems" }, this.secondaryArrowsActive && buttonSecondaryLeftSide, h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'previousPage') }, h("span", { class: "NavigationButton" }, translate('previousPage', this.language)), h("span", { class: "NavigationIcon" })));
|
|
235
|
-
if (isMobile(this.userAgent)) {
|
|
236
|
-
buttonsLeftSide =
|
|
237
|
-
h("div", { class: "LeftItems" }, h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'previousPage') }, h("span", { class: "NavigationButton" }, translate('previousPage', this.language)), h("span", { class: "NavigationIcon" })));
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Right navigation area
|
|
241
|
-
*/
|
|
242
|
-
let buttonSecondaryRightSide = h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'lastPage') }, h("span", { class: "NavigationButton" }, translate('lastPage', this.language)), h("span", { class: "NavigationIcon" }));
|
|
243
|
-
let buttonsRightSide = h("div", { class: "RightItems" }, h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'nextPage') }, h("span", { class: "NavigationButton" }, translate('nextPage', this.language)), h("span", { class: "NavigationIcon" })), this.secondaryArrowsActive && buttonSecondaryRightSide);
|
|
244
|
-
if (isMobile(this.userAgent)) {
|
|
245
|
-
buttonsRightSide =
|
|
246
|
-
h("div", { class: "RightItems" }, h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'nextPage') }, h("span", { class: "NavigationButton" }, translate('nextPage', this.language)), h("span", { class: "NavigationIcon" })));
|
|
247
|
-
}
|
|
248
|
-
return (h("div", { id: "PaginationContainer", ref: el => this.stylingContainer = el }, this.arrowsActive && buttonsLeftSide, this.numberedNavActive && navigationArea, this.arrowsActive && buttonsRightSide));
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
HelperPagination.style = helperPaginationCss;
|
|
252
|
-
|
|
253
|
-
export { HelperPagination as helper_pagination };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { p as promiseResolve, b as bootstrapLazy } from './index-b281577e.js';
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
Stencil Client Patch Browser v2.15.2 | MIT Licensed | https://stenciljs.com
|
|
5
|
-
*/
|
|
6
|
-
const patchBrowser = () => {
|
|
7
|
-
const importMeta = import.meta.url;
|
|
8
|
-
const opts = {};
|
|
9
|
-
if (importMeta !== '') {
|
|
10
|
-
opts.resourcesUrl = new URL('.', importMeta).href;
|
|
11
|
-
}
|
|
12
|
-
return promiseResolve(opts);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
patchBrowser().then(options => {
|
|
16
|
-
return bootstrapLazy([["helper-pagination",[[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);
|
|
17
|
-
});
|