@everymatrix/helper-pagination 1.32.4 → 1.33.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 (48) hide show
  1. package/dist/cjs/helper-pagination.cjs.entry.js +257 -0
  2. package/dist/cjs/helper-pagination.cjs.js +19 -0
  3. package/dist/cjs/index-7c071a78.js +1185 -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 +443 -0
  9. package/dist/collection/index.js +1 -0
  10. package/dist/collection/utils/locale.utils.js +44 -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 +291 -0
  14. package/dist/components/index.d.ts +26 -0
  15. package/dist/components/index.js +1 -0
  16. package/dist/esm/helper-pagination.entry.js +253 -0
  17. package/dist/esm/helper-pagination.js +17 -0
  18. package/dist/esm/index-b281577e.js +1159 -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-ea9ded6d.entry.js +1 -0
  30. package/dist/helper-pagination/p-eab215a1.js +1 -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/adrian.pripon/Documents/Work/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 +96 -0
  36. package/dist/types/components.d.ts +129 -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 +2 -3
  48. package/LICENSE +0 -21
@@ -0,0 +1,257 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-7c071a78.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', 'hu', 'hr'];
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
+ fr: {
36
+ firstPage: 'First',
37
+ previousPage: 'Previous',
38
+ nextPage: 'Next',
39
+ lastPage: 'Last'
40
+ },
41
+ ar: {
42
+ firstPage: 'First',
43
+ previousPage: 'Previous',
44
+ nextPage: 'Next',
45
+ lastPage: 'Last'
46
+ },
47
+ hu: {
48
+ firstPage: 'First',
49
+ previousPage: 'Previous',
50
+ nextPage: 'Következő',
51
+ lastPage: 'Last'
52
+ },
53
+ hr: {
54
+ firstPage: 'Prva',
55
+ previousPage: 'Prethodna',
56
+ nextPage: 'Slijedeća',
57
+ lastPage: 'Zadnja'
58
+ }
59
+ };
60
+ const translate = (key, customLang) => {
61
+ const lang = customLang;
62
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
63
+ };
64
+
65
+ 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}}";
66
+
67
+ const HelperPagination = class {
68
+ constructor(hostRef) {
69
+ index.registerInstance(this, hostRef);
70
+ this.hpPageChange = index.createEvent(this, "hpPageChange", 7);
71
+ /**
72
+ * Next page string value - determines if the next page is disabled or active
73
+ */
74
+ this.nextPage = '';
75
+ /**
76
+ * Previous page string value - determines if the previous page is disabled or active
77
+ */
78
+ this.prevPage = '';
79
+ /**
80
+ * The received offset
81
+ */
82
+ this.offset = 0;
83
+ /**
84
+ * The received limit for the number of pages
85
+ */
86
+ this.limit = 1;
87
+ /**
88
+ * The received total number of pages
89
+ */
90
+ this.total = 1;
91
+ /**
92
+ * Language
93
+ */
94
+ this.language = 'en';
95
+ /**
96
+ * Client custom styling via string
97
+ */
98
+ this.clientStyling = '';
99
+ /**
100
+ * Client custom styling via url content
101
+ */
102
+ this.clientStylingUrlContent = '';
103
+ /**
104
+ * Component working variable for last page
105
+ */
106
+ this.lastPage = false;
107
+ /**
108
+ * Component working variable for prvious page
109
+ */
110
+ this.previousPage = false;
111
+ /**
112
+ * In component working variable for the array of pages
113
+ */
114
+ this.pagesArray = [];
115
+ /**
116
+ * In component working variable for last page
117
+ */
118
+ this.endInt = 0;
119
+ this.userAgent = window.navigator.userAgent;
120
+ this.currentPage = 1;
121
+ this.limitStylingAppends = false;
122
+ /**
123
+ * Navigation logic
124
+ */
125
+ this.navigateTo = (navigationPage) => {
126
+ switch (navigationPage) {
127
+ case 'firstPage':
128
+ this.offsetInt = 0;
129
+ break;
130
+ case 'lastPage':
131
+ this.offsetInt = this.endInt * this.limitInt;
132
+ break;
133
+ case 'previousPage':
134
+ this.offsetInt -= this.limitInt;
135
+ break;
136
+ case 'nextPage':
137
+ this.offsetInt += this.limitInt;
138
+ break;
139
+ case 'fivePagesBack':
140
+ this.offsetInt -= this.limitInt * 5;
141
+ this.offsetInt = this.offsetInt <= 0 ? 0 : this.offsetInt;
142
+ break;
143
+ case 'fivePagesForward':
144
+ this.offsetInt += this.limitInt * 5;
145
+ this.offsetInt = this.offsetInt / this.limitInt >= this.endInt ? this.endInt * this.limitInt : this.offsetInt;
146
+ break;
147
+ }
148
+ this.previousPage = !this.offsetInt ? false : true;
149
+ this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
150
+ };
151
+ /**
152
+ * Handle navigation from here
153
+ */
154
+ this.paginationNavigation = (pageNumber, index) => {
155
+ this.previousPage = true;
156
+ if (!isNaN(pageNumber)) {
157
+ if (pageNumber === 1) {
158
+ this.offsetInt = pageNumber - 1;
159
+ this.previousPage = false;
160
+ }
161
+ else {
162
+ this.offsetInt = (pageNumber - 1) * this.limitInt;
163
+ }
164
+ }
165
+ else {
166
+ if (index === 0 && this.currentPage <= 4) {
167
+ this.navigateTo('firstPage');
168
+ }
169
+ else if (index === 0 && this.currentPage > 4) {
170
+ this.navigateTo('fivePagesBack');
171
+ }
172
+ else if (index === 4 && this.endInt - this.currentPage >= 2) {
173
+ this.navigateTo('fivePagesForward');
174
+ }
175
+ }
176
+ this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
177
+ };
178
+ this.setClientStyling = () => {
179
+ let sheet = document.createElement('style');
180
+ sheet.innerHTML = this.clientStyling;
181
+ this.stylingContainer.prepend(sheet);
182
+ };
183
+ this.setClientStylingURL = () => {
184
+ let cssFile = document.createElement('style');
185
+ setTimeout(() => {
186
+ cssFile.innerHTML = this.clientStylingUrlContent;
187
+ this.stylingContainer.prepend(cssFile);
188
+ }, 1);
189
+ };
190
+ }
191
+ componentWillRender() {
192
+ this.offsetInt = this.offset;
193
+ this.limitInt = this.limit;
194
+ this.currentPage = (this.offsetInt / this.limitInt) + 1;
195
+ this.limitInt = this.limit;
196
+ this.totalInt = this.total;
197
+ this.endInt = (Math.ceil(this.totalInt / this.limitInt) - 1);
198
+ this.lastPage = (this.offsetInt >= this.endInt * this.limitInt) ? false : true;
199
+ /**
200
+ * Construct numbered navigation area based on current page position
201
+ */
202
+ if (this.currentPage == 1 || this.currentPage == 2) {
203
+ this.pagesArray = Array.from({ length: 4 }, (_, i) => i + 1);
204
+ this.pagesArray.push('...');
205
+ }
206
+ else if (this.currentPage >= 3 && ((this.endInt - this.currentPage) >= 2)) {
207
+ this.pagesArray = Array.from({ length: 3 }, (_, i) => this.currentPage + i - 1);
208
+ this.pagesArray.push('...');
209
+ this.pagesArray.unshift('...');
210
+ }
211
+ else if ((this.endInt - this.currentPage) < 3) {
212
+ this.pagesArray = Array.from({ length: 4 }, (_, i) => this.endInt - 2 + i);
213
+ this.pagesArray.unshift('...');
214
+ }
215
+ }
216
+ componentDidRender() {
217
+ // start custom styling area
218
+ if (!this.limitStylingAppends && this.stylingContainer) {
219
+ if (this.clientStyling)
220
+ this.setClientStyling();
221
+ if (this.clientStylingUrlContent)
222
+ this.setClientStylingURL();
223
+ this.limitStylingAppends = true;
224
+ }
225
+ // end custom styling area
226
+ }
227
+ render() {
228
+ /**
229
+ * Center navigation area
230
+ */
231
+ let navigationArea = index.h("ul", { class: "PaginationArea" }, this.pagesArray.map((item, index$1) => {
232
+ 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))));
233
+ }));
234
+ /**
235
+ * Left navigation area
236
+ */
237
+ let buttonSecondaryLeftSide = index.h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'firstPage') }, index.h("span", { class: "NavigationButton" }, translate('firstPage', this.language)), index.h("span", { class: "NavigationIcon" }));
238
+ let buttonsLeftSide = index.h("div", { class: "LeftItems" }, this.secondaryArrowsActive && buttonSecondaryLeftSide, index.h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'previousPage') }, index.h("span", { class: "NavigationButton" }, translate('previousPage', this.language)), index.h("span", { class: "NavigationIcon" })));
239
+ if (isMobile(this.userAgent)) {
240
+ buttonsLeftSide =
241
+ index.h("div", { class: "LeftItems" }, index.h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'previousPage') }, index.h("span", { class: "NavigationButton" }, translate('previousPage', this.language)), index.h("span", { class: "NavigationIcon" })));
242
+ }
243
+ /**
244
+ * Right navigation area
245
+ */
246
+ let buttonSecondaryRightSide = index.h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'lastPage') }, index.h("span", { class: "NavigationButton" }, translate('lastPage', this.language)), index.h("span", { class: "NavigationIcon" }));
247
+ let buttonsRightSide = index.h("div", { class: "RightItems" }, index.h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'nextPage') }, index.h("span", { class: "NavigationButton" }, translate('nextPage', this.language)), index.h("span", { class: "NavigationIcon" })), this.secondaryArrowsActive && buttonSecondaryRightSide);
248
+ if (isMobile(this.userAgent)) {
249
+ buttonsRightSide =
250
+ index.h("div", { class: "RightItems" }, index.h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'nextPage') }, index.h("span", { class: "NavigationButton" }, translate('nextPage', this.language)), index.h("span", { class: "NavigationIcon" })));
251
+ }
252
+ return (index.h("div", { id: "PaginationContainer", ref: el => this.stylingContainer = el }, this.arrowsActive && buttonsLeftSide, this.numberedNavActive && navigationArea, this.arrowsActive && buttonsRightSide));
253
+ }
254
+ };
255
+ HelperPagination.style = helperPaginationCss;
256
+
257
+ exports.helper_pagination = HelperPagination;
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-7c071a78.js');
4
+
5
+ /*
6
+ Stencil Client Patch Browser v2.15.2 | 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",{"nextPage":[1537,"next-page"],"prevPage":[1537,"prev-page"],"offset":[1538],"limit":[1538],"total":[1538],"language":[1537],"clientStyling":[1537,"client-styling"],"clientStylingUrlContent":[1537,"client-styling-url-content"],"arrowsActive":[1540,"arrows-active"],"secondaryArrowsActive":[1540,"secondary-arrows-active"],"numberedNavActive":[1540,"numbered-nav-active"],"offsetInt":[32],"lastPage":[32],"previousPage":[32],"limitInt":[32],"totalInt":[32],"pagesArray":[32],"endInt":[32],"limitStylingAppends":[32]}]]]], options);
19
+ });