@everymatrix/helper-pagination 0.0.3

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 (47) hide show
  1. package/dist/cjs/helper-pagination.cjs.entry.js +188 -0
  2. package/dist/cjs/helper-pagination.cjs.js +19 -0
  3. package/dist/cjs/index-ea71a27d.js +1170 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader.cjs.js +21 -0
  6. package/dist/collection/collection-manifest.json +12 -0
  7. package/dist/collection/components/helper-pagination/helper-pagination.css +139 -0
  8. package/dist/collection/components/helper-pagination/helper-pagination.js +297 -0
  9. package/dist/collection/index.js +1 -0
  10. package/dist/collection/utils/locale.utils.js +20 -0
  11. package/dist/collection/utils/utils.js +15 -0
  12. package/dist/components/helper-pagination.d.ts +11 -0
  13. package/dist/components/helper-pagination.js +215 -0
  14. package/dist/components/index.d.ts +22 -0
  15. package/dist/components/index.js +2 -0
  16. package/dist/esm/helper-pagination.entry.js +184 -0
  17. package/dist/esm/helper-pagination.js +17 -0
  18. package/dist/esm/index-6ba22d2b.js +1144 -0
  19. package/dist/esm/index.js +1 -0
  20. package/dist/esm/loader.js +17 -0
  21. package/dist/esm/polyfills/core-js.js +11 -0
  22. package/dist/esm/polyfills/css-shim.js +1 -0
  23. package/dist/esm/polyfills/dom.js +79 -0
  24. package/dist/esm/polyfills/es5-html-element.js +1 -0
  25. package/dist/esm/polyfills/index.js +34 -0
  26. package/dist/esm/polyfills/system.js +6 -0
  27. package/dist/helper-pagination/helper-pagination.esm.js +1 -0
  28. package/dist/helper-pagination/index.esm.js +0 -0
  29. package/dist/helper-pagination/p-4038ff2e.entry.js +1 -0
  30. package/dist/helper-pagination/p-a4f374fc.js +2 -0
  31. package/dist/index.cjs.js +1 -0
  32. package/dist/index.js +1 -0
  33. package/dist/stencil.config.js +22 -0
  34. package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/helper-pagination/.stencil/packages/helper-pagination/stencil.config.d.ts +2 -0
  35. package/dist/types/components/helper-pagination/helper-pagination.d.ts +67 -0
  36. package/dist/types/components.d.ts +93 -0
  37. package/dist/types/index.d.ts +1 -0
  38. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  39. package/dist/types/utils/locale.utils.d.ts +1 -0
  40. package/dist/types/utils/utils.d.ts +8 -0
  41. package/loader/cdn.js +3 -0
  42. package/loader/index.cjs.js +3 -0
  43. package/loader/index.d.ts +12 -0
  44. package/loader/index.es2017.js +3 -0
  45. package/loader/index.js +4 -0
  46. package/loader/package.json +10 -0
  47. package/package.json +19 -0
@@ -0,0 +1,188 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-ea71a27d.js');
6
+
7
+ /**
8
+ * @name isMobile
9
+ * @description A method that returns if the browser used to access the app is from a mobile device or not
10
+ * @param {String} userAgent window.navigator.userAgent
11
+ * @returns {Boolean} true or false
12
+ */
13
+ const isMobile = (userAgent) => {
14
+ return !!(userAgent.toLowerCase().match(/android/i) ||
15
+ userAgent.toLowerCase().match(/blackberry|bb/i) ||
16
+ userAgent.toLowerCase().match(/iphone|ipad|ipod/i) ||
17
+ userAgent.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i));
18
+ };
19
+
20
+ const DEFAULT_LANGUAGE = 'en';
21
+ const SUPPORTED_LANGUAGES = ['ro', 'en'];
22
+ const TRANSLATIONS = {
23
+ en: {
24
+ firstPage: 'First',
25
+ previousPage: 'Previous',
26
+ nextPage: 'Next',
27
+ lastPage: 'Last'
28
+ },
29
+ ro: {
30
+ firstPage: 'Prima',
31
+ previousPage: 'Anterior',
32
+ nextPage: 'Urmatoarea',
33
+ lastPage: 'Ultima'
34
+ },
35
+ };
36
+ const translate = (key, customLang) => {
37
+ const lang = customLang;
38
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
39
+ };
40
+
41
+ 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-top:20px;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:12px}}@media screen and (max-width: 480px){button{width:70px;font-size:10px}.paginationArea{padding:5px}}@media screen and (max-width: 320px){button{width:58px;font-size:10px}.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}}";
42
+
43
+ const HelperPagination = class {
44
+ constructor(hostRef) {
45
+ index.registerInstance(this, hostRef);
46
+ this.hpPageChange = index.createEvent(this, "hpPageChange", 7);
47
+ /**
48
+ * First page boolean value - determines if the page is disabled or active
49
+ */
50
+ this.firstPage = false;
51
+ /**
52
+ * Previous page boolean value - determines if the page is disabled or active
53
+ */
54
+ this.previousPage = false;
55
+ /**
56
+ * The received offset
57
+ */
58
+ this.offset = 0;
59
+ /**
60
+ * The received limit for the number of pages
61
+ */
62
+ this.limit = 1;
63
+ /**
64
+ * The received total number of pages
65
+ */
66
+ this.total = 1;
67
+ /**
68
+ * Language
69
+ */
70
+ this.language = 'en';
71
+ /**
72
+ * In component working variable for the array of pages
73
+ */
74
+ this.pagesArray = [];
75
+ /**
76
+ * In component working variable for last page
77
+ */
78
+ this.endInt = 0;
79
+ this.userAgent = window.navigator.userAgent;
80
+ this.currentPage = 1;
81
+ /**
82
+ * Navigation logic
83
+ */
84
+ this.navigateTo = (navigationPage) => {
85
+ switch (navigationPage) {
86
+ case 'firstPage':
87
+ this.offsetInt = 0;
88
+ break;
89
+ case 'lastPage':
90
+ this.offsetInt = this.endInt * this.limitInt;
91
+ break;
92
+ case 'previousPage':
93
+ this.offsetInt -= 10;
94
+ break;
95
+ case 'nextPage':
96
+ this.offsetInt += 10;
97
+ break;
98
+ case 'fivePagesBack':
99
+ this.offsetInt -= 30;
100
+ this.offsetInt = this.offsetInt < 0 ? 0 : this.offsetInt;
101
+ break;
102
+ case 'fivePagesForward':
103
+ this.offsetInt += 30;
104
+ this.offsetInt = this.offsetInt / 10 >= this.endInt ? this.endInt * 10 : this.offsetInt;
105
+ break;
106
+ }
107
+ this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
108
+ };
109
+ /**
110
+ * Handle navigation from here
111
+ */
112
+ this.paginationNavigation = (pageNumber, index) => {
113
+ if (!isNaN(pageNumber)) {
114
+ if (pageNumber === 1) {
115
+ this.offsetInt = pageNumber - 1;
116
+ }
117
+ else {
118
+ this.offsetInt = (pageNumber - 1) * 10;
119
+ }
120
+ }
121
+ else {
122
+ if (index === 0 && this.currentPage <= 4) {
123
+ this.navigateTo('firstPage');
124
+ }
125
+ else if (index === 0 && this.currentPage > 4) {
126
+ this.navigateTo('fivePagesBack');
127
+ }
128
+ else if (index === 4 && this.endInt - this.currentPage >= 2) {
129
+ this.navigateTo('fivePagesForward');
130
+ }
131
+ }
132
+ this.currentPage = this.offsetInt;
133
+ this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
134
+ };
135
+ }
136
+ componentWillRender() {
137
+ this.offsetInt = this.offset;
138
+ this.currentPage = this.offsetInt / this.limitInt + 1;
139
+ this.limitInt = this.limit;
140
+ this.totalInt = this.total;
141
+ this.endInt = (Math.ceil(this.totalInt / this.limitInt) - 1);
142
+ this.lastPage = (this.offsetInt >= this.endInt * this.limitInt) ? false : true;
143
+ /**
144
+ * Construct numbered navigation area based on current page position
145
+ */
146
+ if (this.currentPage === 1 || this.currentPage === 2) {
147
+ this.pagesArray = Array.from({ length: 4 }, (_, i) => i + 1);
148
+ this.pagesArray.push('...');
149
+ }
150
+ else if (this.currentPage >= 3 && ((this.endInt - this.currentPage) >= 2)) {
151
+ this.pagesArray = Array.from({ length: 3 }, (_, i) => this.currentPage + i - 1);
152
+ this.pagesArray.push('...');
153
+ this.pagesArray.unshift('...');
154
+ }
155
+ else if ((this.endInt - this.currentPage) < 3) {
156
+ this.pagesArray = Array.from({ length: 4 }, (_, i) => this.endInt - 2 + i);
157
+ this.pagesArray.unshift('...');
158
+ }
159
+ }
160
+ render() {
161
+ /**
162
+ * Center navigation area
163
+ */
164
+ let navigationArea = index.h("ul", { class: "PaginationArea" }, this.pagesArray.map((item, index$1) => {
165
+ return (index.h("li", { class: 'PaginationItem' + (item === this.currentPage ? ' ActiveItem' : ' ') + ' ' + (isMobile(this.userAgent) ? 'MobileButtons' : '') }, index.h("button", { disabled: item === this.currentPage ? true : false, onClick: this.paginationNavigation.bind(this, item, index$1) }, index.h("span", null, item))));
166
+ }));
167
+ /**
168
+ * Left navigation area
169
+ */
170
+ let buttonsLeftSide = index.h("div", { class: "LeftItems" }, index.h("button", { disabled: !this.previousPage, onClick: this.navigateTo.bind(this, 'firstPage') }, translate('firstPage', this.language)), index.h("button", { disabled: !this.previousPage ? true : false, onClick: this.navigateTo.bind(this, 'previousPage') }, translate('previousPage', this.language)));
171
+ if (isMobile(this.userAgent)) {
172
+ buttonsLeftSide =
173
+ index.h("div", { class: "LeftItems" }, index.h("button", { disabled: !this.previousPage ? true : false, onClick: this.navigateTo.bind(this, 'previousPage') }, translate('previousPage', this.language)));
174
+ }
175
+ /**
176
+ * Right navigation area
177
+ */
178
+ let buttonsRightSide = index.h("div", { class: "RightItems" }, index.h("button", { disabled: !this.lastPage ? true : false, onClick: this.navigateTo.bind(this, 'nextPage') }, translate('nextPage', this.language)), index.h("button", { disabled: !this.lastPage ? true : false, onClick: this.navigateTo.bind(this, 'lastPage') }, translate('lastPage', this.language)));
179
+ if (isMobile(this.userAgent)) {
180
+ buttonsRightSide =
181
+ index.h("div", { class: "RightItems" }, index.h("button", { disabled: !this.lastPage ? true : false, onClick: this.navigateTo.bind(this, 'nextPage') }, translate('nextPage', this.language)));
182
+ }
183
+ return (index.h("div", { id: "PaginationContainer" }, buttonsLeftSide, navigationArea, buttonsRightSide));
184
+ }
185
+ };
186
+ HelperPagination.style = helperPaginationCss;
187
+
188
+ exports.helper_pagination = HelperPagination;
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-ea71a27d.js');
4
+
5
+ /*
6
+ Stencil Client Patch Browser v2.17.0 | MIT Licensed | https://stenciljs.com
7
+ */
8
+ const patchBrowser = () => {
9
+ const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('helper-pagination.cjs.js', document.baseURI).href));
10
+ const opts = {};
11
+ if (importMeta !== '') {
12
+ opts.resourcesUrl = new URL('.', importMeta).href;
13
+ }
14
+ return index.promiseResolve(opts);
15
+ };
16
+
17
+ patchBrowser().then(options => {
18
+ return index.bootstrapLazy([["helper-pagination.cjs",[[1,"helper-pagination",{"firstPage":[1540,"first-page"],"previousPage":[1540,"previous-page"],"offset":[1538],"limit":[1538],"total":[1538],"language":[1],"offsetInt":[32],"lastPage":[32],"limitInt":[32],"totalInt":[32],"pagesArray":[32],"endInt":[32]}]]]], options);
19
+ });