@everymatrix/lottery-pagination 1.51.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.
Files changed (51) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/index-249d3d4d.js +1186 -0
  3. package/dist/cjs/index.cjs.js +10 -0
  4. package/dist/cjs/loader.cjs.js +15 -0
  5. package/dist/cjs/lottery-pagination-e934e1e8.js +247 -0
  6. package/dist/cjs/lottery-pagination.cjs.entry.js +10 -0
  7. package/dist/cjs/lottery-pagination.cjs.js +25 -0
  8. package/dist/collection/collection-manifest.json +12 -0
  9. package/dist/collection/components/lottery-pagination/index.js +1 -0
  10. package/dist/collection/components/lottery-pagination/lottery-pagination.css +136 -0
  11. package/dist/collection/components/lottery-pagination/lottery-pagination.js +440 -0
  12. package/dist/collection/index.js +1 -0
  13. package/dist/collection/utils/locale.utils.js +43 -0
  14. package/dist/collection/utils/utils.js +15 -0
  15. package/dist/esm/app-globals-0f993ce5.js +3 -0
  16. package/dist/esm/index-49de5c89.js +1159 -0
  17. package/dist/esm/index.js +2 -0
  18. package/dist/esm/loader.js +11 -0
  19. package/dist/esm/lottery-pagination-50564510.js +245 -0
  20. package/dist/esm/lottery-pagination.entry.js +2 -0
  21. package/dist/esm/lottery-pagination.js +20 -0
  22. package/dist/index.cjs.js +1 -0
  23. package/dist/index.js +1 -0
  24. package/dist/lottery-pagination/index.esm.js +1 -0
  25. package/dist/lottery-pagination/lottery-pagination.esm.js +1 -0
  26. package/dist/lottery-pagination/p-9e29d391.js +1 -0
  27. package/dist/lottery-pagination/p-ce0101e8.js +2 -0
  28. package/dist/lottery-pagination/p-e0782a32.entry.js +1 -0
  29. package/dist/lottery-pagination/p-e1255160.js +1 -0
  30. package/dist/stencil.config.dev.js +16 -0
  31. package/dist/stencil.config.js +17 -0
  32. package/dist/storybook/main.js +21 -0
  33. package/dist/storybook/preview.js +9 -0
  34. package/dist/types/Users/maria.bumbar/Desktop/widgets-monorepo/packages/stencil/lottery-pagination/.stencil/packages/stencil/lottery-pagination/stencil.config.d.ts +2 -0
  35. package/dist/types/Users/maria.bumbar/Desktop/widgets-monorepo/packages/stencil/lottery-pagination/.stencil/packages/stencil/lottery-pagination/stencil.config.dev.d.ts +2 -0
  36. package/dist/types/Users/maria.bumbar/Desktop/widgets-monorepo/packages/stencil/lottery-pagination/.stencil/packages/stencil/lottery-pagination/storybook/main.d.ts +3 -0
  37. package/dist/types/Users/maria.bumbar/Desktop/widgets-monorepo/packages/stencil/lottery-pagination/.stencil/packages/stencil/lottery-pagination/storybook/preview.d.ts +70 -0
  38. package/dist/types/components/lottery-pagination/index.d.ts +1 -0
  39. package/dist/types/components/lottery-pagination/lottery-pagination.d.ts +97 -0
  40. package/dist/types/components.d.ts +146 -0
  41. package/dist/types/index.d.ts +1 -0
  42. package/dist/types/stencil-public-runtime.d.ts +1680 -0
  43. package/dist/types/utils/locale.utils.d.ts +1 -0
  44. package/dist/types/utils/utils.d.ts +8 -0
  45. package/loader/cdn.js +1 -0
  46. package/loader/index.cjs.js +1 -0
  47. package/loader/index.d.ts +24 -0
  48. package/loader/index.es2017.js +1 -0
  49. package/loader/index.js +2 -0
  50. package/loader/package.json +11 -0
  51. package/package.json +26 -0
@@ -0,0 +1,440 @@
1
+ import { h } from "@stencil/core";
2
+ import { isMobile } from "../../utils/utils";
3
+ import { translate } from "../../utils/locale.utils";
4
+ export class LotteryPagination {
5
+ constructor() {
6
+ this.userAgent = window.navigator.userAgent;
7
+ this.currentPage = 1;
8
+ /**
9
+ * Navigation logic
10
+ */
11
+ this.navigateTo = (navigationPage) => {
12
+ switch (navigationPage) {
13
+ case 'firstPage':
14
+ this.offsetInt = 0;
15
+ break;
16
+ case 'lastPage':
17
+ this.offsetInt = this.endInt * this.limitInt;
18
+ break;
19
+ case 'previousPage':
20
+ this.offsetInt -= this.limitInt;
21
+ this.nextPage = true;
22
+ break;
23
+ case 'nextPage':
24
+ this.offsetInt += this.limitInt;
25
+ // this.nextPage = this.currentPage > this.endInt ? false : this.nextPage;
26
+ this.nextPage = this.offsetInt / this.limitInt >= this.endInt ? false : this.nextPage;
27
+ break;
28
+ case 'fivePagesBack':
29
+ this.offsetInt -= this.limitInt * 5;
30
+ this.offsetInt = this.offsetInt <= 0 ? 0 : this.offsetInt;
31
+ break;
32
+ case 'fivePagesForward':
33
+ this.offsetInt += this.limitInt * 5;
34
+ this.offsetInt = this.offsetInt / this.limitInt >= this.endInt ? this.endInt * this.limitInt : this.offsetInt;
35
+ this.nextPage = this.offsetInt / this.limitInt >= this.endInt ? false : this.nextPage;
36
+ break;
37
+ }
38
+ this.previousPage = !this.offsetInt ? false : true;
39
+ this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
40
+ };
41
+ /**
42
+ * Handle navigation from here
43
+ */
44
+ this.paginationNavigation = (pageNumber, index) => {
45
+ if (!isNaN(pageNumber)) {
46
+ if (pageNumber === 1) {
47
+ this.offsetInt = pageNumber - 1;
48
+ this.previousPage = false;
49
+ }
50
+ else {
51
+ this.offsetInt = (pageNumber - 1) * this.limitInt;
52
+ if (pageNumber > this.endInt) {
53
+ this.nextPage = false;
54
+ }
55
+ else {
56
+ this.nextPage = true;
57
+ }
58
+ }
59
+ this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
60
+ }
61
+ else {
62
+ if (index === 0 && this.currentPage <= 4) {
63
+ this.navigateTo('firstPage');
64
+ }
65
+ else if (index === 0 && this.currentPage > 4) {
66
+ this.navigateTo('fivePagesBack');
67
+ }
68
+ else if (index === 4 && this.endInt - this.currentPage >= 2) {
69
+ this.navigateTo('fivePagesForward');
70
+ }
71
+ }
72
+ };
73
+ this.setClientStyling = () => {
74
+ let sheet = document.createElement('style');
75
+ sheet.innerHTML = this.clientStyling;
76
+ this.stylingContainer.prepend(sheet);
77
+ };
78
+ this.setClientStylingURL = () => {
79
+ let cssFile = document.createElement('style');
80
+ setTimeout(() => {
81
+ cssFile.innerHTML = this.clientStylingUrlContent;
82
+ this.stylingContainer.prepend(cssFile);
83
+ }, 1);
84
+ };
85
+ this.nextPage = false;
86
+ this.prevPage = false;
87
+ this.offset = 0;
88
+ this.limit = 10;
89
+ this.total = 1;
90
+ this.language = 'en';
91
+ this.clientStyling = '';
92
+ this.clientStylingUrlContent = '';
93
+ this.arrowsActive = undefined;
94
+ this.secondaryArrowsActive = undefined;
95
+ this.numberedNavActive = undefined;
96
+ this.isReset = false;
97
+ this.offsetInt = undefined;
98
+ this.lastPage = false;
99
+ this.previousPage = false;
100
+ this.limitInt = undefined;
101
+ this.totalInt = undefined;
102
+ this.pagesArray = [];
103
+ this.endInt = 0;
104
+ this.limitStylingAppends = false;
105
+ }
106
+ componentWillRender() {
107
+ this.offsetInt = this.offset;
108
+ this.limitInt = this.limit;
109
+ this.nextPage = this.isReset ? true : this.nextPage;
110
+ this.currentPage = (this.offsetInt / this.limitInt) + 1;
111
+ this.limitInt = this.limit;
112
+ this.totalInt = this.total;
113
+ this.endInt = (Math.ceil(this.totalInt / this.limitInt) - 1);
114
+ this.lastPage = (this.offsetInt >= this.endInt * this.limitInt) ? false : true;
115
+ /**
116
+ * Construct numbered navigation area based on current page position
117
+ */
118
+ if (this.currentPage == 1 || this.currentPage == 2) {
119
+ if (this.endInt > 3) {
120
+ this.pagesArray = Array.from({ length: 4 }, (_, i) => i + 1);
121
+ this.pagesArray.push('...');
122
+ }
123
+ else {
124
+ this.pagesArray = Array.from({ length: this.endInt + 1 }, (_, i) => i + 1);
125
+ }
126
+ }
127
+ else if (this.currentPage >= 3 && ((this.endInt - this.currentPage) >= 2)) {
128
+ this.pagesArray = Array.from({ length: 3 }, (_, i) => this.currentPage + i - 1);
129
+ this.pagesArray.push('...');
130
+ this.pagesArray.unshift('...');
131
+ }
132
+ else if ((this.endInt - this.currentPage) < 3) {
133
+ if (this.endInt > 4) {
134
+ this.pagesArray = Array.from({ length: 4 }, (_, i) => this.endInt - 2 + i);
135
+ this.pagesArray.unshift('...');
136
+ }
137
+ else {
138
+ this.pagesArray = Array.from({ length: this.endInt + 1 }, (_, i) => i + 1);
139
+ }
140
+ }
141
+ }
142
+ componentDidRender() {
143
+ this.isReset = false;
144
+ // start custom styling area
145
+ if (!this.limitStylingAppends && this.stylingContainer) {
146
+ if (this.clientStyling)
147
+ this.setClientStyling();
148
+ if (this.clientStylingUrlContent)
149
+ this.setClientStylingURL();
150
+ this.limitStylingAppends = true;
151
+ }
152
+ // end custom styling area
153
+ }
154
+ render() {
155
+ /**
156
+ * Center navigation area
157
+ */
158
+ let navigationArea = h("ul", { class: "PaginationArea" }, this.pagesArray.map((item, index) => {
159
+ 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))));
160
+ }));
161
+ /**
162
+ * Left navigation area
163
+ */
164
+ 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" }));
165
+ let buttonsLeftSide = h("div", { class: "LeftItems" }, this.secondaryArrowsActive && buttonSecondaryLeftSide, h("button", { disabled: this.prevPage && this.currentPage !== 1 ? false : true, onClick: this.navigateTo.bind(this, 'previousPage') }, h("span", { class: "NavigationButton" }, translate('previousPage', this.language)), h("span", { class: "NavigationIcon" })));
166
+ if (isMobile(this.userAgent)) {
167
+ buttonsLeftSide =
168
+ 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" })));
169
+ }
170
+ /**
171
+ * Right navigation area
172
+ */
173
+ 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" }));
174
+ 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);
175
+ if (isMobile(this.userAgent)) {
176
+ buttonsRightSide =
177
+ 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" })));
178
+ }
179
+ return (h("div", { id: "PaginationContainer", ref: el => this.stylingContainer = el }, this.arrowsActive && buttonsLeftSide, this.numberedNavActive && navigationArea, this.arrowsActive && buttonsRightSide));
180
+ }
181
+ static get is() { return "lottery-pagination"; }
182
+ static get encapsulation() { return "shadow"; }
183
+ static get originalStyleUrls() {
184
+ return {
185
+ "$": ["lottery-pagination.scss"]
186
+ };
187
+ }
188
+ static get styleUrls() {
189
+ return {
190
+ "$": ["lottery-pagination.css"]
191
+ };
192
+ }
193
+ static get properties() {
194
+ return {
195
+ "nextPage": {
196
+ "type": "boolean",
197
+ "mutable": true,
198
+ "complexType": {
199
+ "original": "boolean",
200
+ "resolved": "boolean",
201
+ "references": {}
202
+ },
203
+ "required": false,
204
+ "optional": false,
205
+ "docs": {
206
+ "tags": [],
207
+ "text": "Next page string value - determines if the next page is disabled or active"
208
+ },
209
+ "attribute": "next-page",
210
+ "reflect": true,
211
+ "defaultValue": "false"
212
+ },
213
+ "prevPage": {
214
+ "type": "boolean",
215
+ "mutable": true,
216
+ "complexType": {
217
+ "original": "boolean",
218
+ "resolved": "boolean",
219
+ "references": {}
220
+ },
221
+ "required": false,
222
+ "optional": false,
223
+ "docs": {
224
+ "tags": [],
225
+ "text": "Previous page string value - determines if the previous page is disabled or active"
226
+ },
227
+ "attribute": "prev-page",
228
+ "reflect": true,
229
+ "defaultValue": "false"
230
+ },
231
+ "offset": {
232
+ "type": "number",
233
+ "mutable": true,
234
+ "complexType": {
235
+ "original": "number",
236
+ "resolved": "number",
237
+ "references": {}
238
+ },
239
+ "required": false,
240
+ "optional": false,
241
+ "docs": {
242
+ "tags": [],
243
+ "text": "The received offset"
244
+ },
245
+ "attribute": "offset",
246
+ "reflect": true,
247
+ "defaultValue": "0"
248
+ },
249
+ "limit": {
250
+ "type": "number",
251
+ "mutable": true,
252
+ "complexType": {
253
+ "original": "number",
254
+ "resolved": "number",
255
+ "references": {}
256
+ },
257
+ "required": false,
258
+ "optional": false,
259
+ "docs": {
260
+ "tags": [],
261
+ "text": "The received limit for the number of pages"
262
+ },
263
+ "attribute": "limit",
264
+ "reflect": true,
265
+ "defaultValue": "10"
266
+ },
267
+ "total": {
268
+ "type": "number",
269
+ "mutable": true,
270
+ "complexType": {
271
+ "original": "number",
272
+ "resolved": "number",
273
+ "references": {}
274
+ },
275
+ "required": false,
276
+ "optional": false,
277
+ "docs": {
278
+ "tags": [],
279
+ "text": "The received total number of pages"
280
+ },
281
+ "attribute": "total",
282
+ "reflect": true,
283
+ "defaultValue": "1"
284
+ },
285
+ "language": {
286
+ "type": "string",
287
+ "mutable": true,
288
+ "complexType": {
289
+ "original": "string",
290
+ "resolved": "string",
291
+ "references": {}
292
+ },
293
+ "required": false,
294
+ "optional": false,
295
+ "docs": {
296
+ "tags": [],
297
+ "text": "Language"
298
+ },
299
+ "attribute": "language",
300
+ "reflect": true,
301
+ "defaultValue": "'en'"
302
+ },
303
+ "clientStyling": {
304
+ "type": "string",
305
+ "mutable": true,
306
+ "complexType": {
307
+ "original": "string",
308
+ "resolved": "string",
309
+ "references": {}
310
+ },
311
+ "required": false,
312
+ "optional": false,
313
+ "docs": {
314
+ "tags": [],
315
+ "text": "Client custom styling via string"
316
+ },
317
+ "attribute": "client-styling",
318
+ "reflect": true,
319
+ "defaultValue": "''"
320
+ },
321
+ "clientStylingUrlContent": {
322
+ "type": "string",
323
+ "mutable": true,
324
+ "complexType": {
325
+ "original": "string",
326
+ "resolved": "string",
327
+ "references": {}
328
+ },
329
+ "required": false,
330
+ "optional": false,
331
+ "docs": {
332
+ "tags": [],
333
+ "text": "Client custom styling via url content"
334
+ },
335
+ "attribute": "client-styling-url-content",
336
+ "reflect": true,
337
+ "defaultValue": "''"
338
+ },
339
+ "arrowsActive": {
340
+ "type": "boolean",
341
+ "mutable": true,
342
+ "complexType": {
343
+ "original": "boolean",
344
+ "resolved": "boolean",
345
+ "references": {}
346
+ },
347
+ "required": false,
348
+ "optional": false,
349
+ "docs": {
350
+ "tags": [],
351
+ "text": "Customize pagination: Activate pagination arrows"
352
+ },
353
+ "attribute": "arrows-active",
354
+ "reflect": true
355
+ },
356
+ "secondaryArrowsActive": {
357
+ "type": "boolean",
358
+ "mutable": true,
359
+ "complexType": {
360
+ "original": "boolean",
361
+ "resolved": "boolean",
362
+ "references": {}
363
+ },
364
+ "required": false,
365
+ "optional": false,
366
+ "docs": {
367
+ "tags": [],
368
+ "text": "Customize pagination: Activate pagination secondary arrows"
369
+ },
370
+ "attribute": "secondary-arrows-active",
371
+ "reflect": true
372
+ },
373
+ "numberedNavActive": {
374
+ "type": "boolean",
375
+ "mutable": true,
376
+ "complexType": {
377
+ "original": "boolean",
378
+ "resolved": "boolean",
379
+ "references": {}
380
+ },
381
+ "required": false,
382
+ "optional": false,
383
+ "docs": {
384
+ "tags": [],
385
+ "text": "Customize pagination: Activate pagination numbered navigation"
386
+ },
387
+ "attribute": "numbered-nav-active",
388
+ "reflect": true
389
+ },
390
+ "isReset": {
391
+ "type": "boolean",
392
+ "mutable": true,
393
+ "complexType": {
394
+ "original": "boolean",
395
+ "resolved": "boolean",
396
+ "references": {}
397
+ },
398
+ "required": false,
399
+ "optional": false,
400
+ "docs": {
401
+ "tags": [],
402
+ "text": ""
403
+ },
404
+ "attribute": "is-reset",
405
+ "reflect": true,
406
+ "defaultValue": "false"
407
+ }
408
+ };
409
+ }
410
+ static get states() {
411
+ return {
412
+ "offsetInt": {},
413
+ "lastPage": {},
414
+ "previousPage": {},
415
+ "limitInt": {},
416
+ "totalInt": {},
417
+ "pagesArray": {},
418
+ "endInt": {},
419
+ "limitStylingAppends": {}
420
+ };
421
+ }
422
+ static get events() {
423
+ return [{
424
+ "method": "hpPageChange",
425
+ "name": "hpPageChange",
426
+ "bubbles": true,
427
+ "cancelable": true,
428
+ "composed": true,
429
+ "docs": {
430
+ "tags": [],
431
+ "text": "Event that handles the navigation, updating the offset, limit and total values"
432
+ },
433
+ "complexType": {
434
+ "original": "any",
435
+ "resolved": "any",
436
+ "references": {}
437
+ }
438
+ }];
439
+ }
440
+ }
@@ -0,0 +1 @@
1
+ export * from './components/lottery-pagination';
@@ -0,0 +1,43 @@
1
+ const DEFAULT_LANGUAGE = 'en';
2
+ const TRANSLATIONS = {
3
+ en: {
4
+ firstPage: 'First',
5
+ previousPage: 'Previous',
6
+ nextPage: 'Next',
7
+ lastPage: 'Last'
8
+ },
9
+ ro: {
10
+ firstPage: 'Prima',
11
+ previousPage: 'Anterior',
12
+ nextPage: 'Urmatoarea',
13
+ lastPage: 'Ultima'
14
+ },
15
+ fr: {
16
+ firstPage: 'First',
17
+ previousPage: 'Previous',
18
+ nextPage: 'Next',
19
+ lastPage: 'Last'
20
+ },
21
+ ar: {
22
+ firstPage: 'First',
23
+ previousPage: 'Previous',
24
+ nextPage: 'Next',
25
+ lastPage: 'Last'
26
+ },
27
+ hu: {
28
+ firstPage: 'First',
29
+ previousPage: 'Previous',
30
+ nextPage: 'Következő',
31
+ lastPage: 'Last'
32
+ },
33
+ hr: {
34
+ firstPage: 'Prva',
35
+ previousPage: 'Prethodna',
36
+ nextPage: 'Slijedeća',
37
+ lastPage: 'Zadnja'
38
+ }
39
+ };
40
+ export const translate = (key, customLang) => {
41
+ const lang = customLang;
42
+ return TRANSLATIONS[(lang !== undefined) && (lang in TRANSLATIONS) ? lang : DEFAULT_LANGUAGE][key];
43
+ };
@@ -0,0 +1,15 @@
1
+ export function format(first, middle, last) {
2
+ return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
3
+ }
4
+ /**
5
+ * @name isMobile
6
+ * @description A method that returns if the browser used to access the app is from a mobile device or not
7
+ * @param {String} userAgent window.navigator.userAgent
8
+ * @returns {Boolean} true or false
9
+ */
10
+ export const isMobile = (userAgent) => {
11
+ return !!(userAgent.toLowerCase().match(/android/i) ||
12
+ userAgent.toLowerCase().match(/blackberry|bb/i) ||
13
+ userAgent.toLowerCase().match(/iphone|ipad|ipod/i) ||
14
+ userAgent.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i));
15
+ };
@@ -0,0 +1,3 @@
1
+ const globalScripts = () => {};
2
+
3
+ export { globalScripts as g };