@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,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-ea71a27d.js');
6
+
7
+ /*
8
+ Stencil Client Patch Esm v2.17.0 | MIT Licensed | https://stenciljs.com
9
+ */
10
+ const patchEsm = () => {
11
+ return index.promiseResolve();
12
+ };
13
+
14
+ const defineCustomElements = (win, options) => {
15
+ if (typeof window === 'undefined') return Promise.resolve();
16
+ return patchEsm().then(() => {
17
+ 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);
18
+ });
19
+ };
20
+
21
+ exports.defineCustomElements = defineCustomElements;
@@ -0,0 +1,12 @@
1
+ {
2
+ "entries": [
3
+ "./components/helper-pagination/helper-pagination.js"
4
+ ],
5
+ "compiler": {
6
+ "name": "@stencil/core",
7
+ "version": "2.17.0",
8
+ "typescriptVersion": "4.5.4"
9
+ },
10
+ "collections": [],
11
+ "bundles": []
12
+ }
@@ -0,0 +1,139 @@
1
+ @import url("https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap");
2
+ :host {
3
+ display: block;
4
+ font-family: "Roboto", sans-serif;
5
+ }
6
+
7
+ #PaginationContainer {
8
+ width: 100%;
9
+ margin-top: 20px;
10
+ display: inline-flex;
11
+ justify-content: space-between;
12
+ align-items: center;
13
+ }
14
+
15
+ .LeftItems button:not(:first-child), .RightItems button:not(:last-child) {
16
+ margin: 0 10px;
17
+ }
18
+
19
+ .LeftItems button, .RightItems button {
20
+ padding: 0;
21
+ background-color: #009993;
22
+ border-color: #009993;
23
+ }
24
+
25
+ .PaginationArea {
26
+ display: inline-flex;
27
+ gap: 10px;
28
+ list-style: none;
29
+ }
30
+
31
+ .PaginationArea li {
32
+ margin: 0;
33
+ padding: 0;
34
+ }
35
+
36
+ .PaginationArea li button {
37
+ width: 24px;
38
+ height: 24px;
39
+ display: flex;
40
+ border: 0;
41
+ padding: 0;
42
+ justify-content: center;
43
+ align-items: center;
44
+ background-color: transparent;
45
+ color: #000;
46
+ cursor: pointer;
47
+ pointer-events: all;
48
+ }
49
+
50
+ .PaginationItem.ActiveItem button {
51
+ background: #009993;
52
+ border-color: #009993;
53
+ color: #fff;
54
+ }
55
+
56
+ .PaginationItem.ActiveItem button:disabled {
57
+ pointer-events: none;
58
+ cursor: not-allowed;
59
+ }
60
+
61
+ .PaginationItem button:hover,
62
+ .PaginationItem button:active {
63
+ background: #009993;
64
+ border-color: #009993;
65
+ color: #fff;
66
+ opacity: 0.8;
67
+ }
68
+
69
+ button {
70
+ width: 100px;
71
+ height: 32px;
72
+ border: 1px solid #524e52;
73
+ border-radius: 5px;
74
+ background: #524e52;
75
+ color: #fff;
76
+ font-size: 14px;
77
+ font: inherit;
78
+ cursor: pointer;
79
+ transition: all 0.1s linear;
80
+ text-transform: uppercase;
81
+ text-align: center;
82
+ letter-spacing: 0;
83
+ }
84
+
85
+ button:hover,
86
+ button:active {
87
+ background: #004D4A;
88
+ border-color: #004D4A;
89
+ }
90
+
91
+ button:disabled {
92
+ background-color: #ccc;
93
+ border-color: #ccc;
94
+ color: #fff;
95
+ cursor: not-allowed;
96
+ }
97
+
98
+ @media screen and (max-width: 720px) {
99
+ button {
100
+ width: 90px;
101
+ font-size: 12px;
102
+ }
103
+ }
104
+ @media screen and (max-width: 480px) {
105
+ button {
106
+ width: 70px;
107
+ font-size: 10px;
108
+ }
109
+
110
+ .paginationArea {
111
+ padding: 5px;
112
+ }
113
+ }
114
+ @media screen and (max-width: 320px) {
115
+ button {
116
+ width: 58px;
117
+ font-size: 10px;
118
+ }
119
+
120
+ .paginationArea {
121
+ padding: 5px;
122
+ gap: 5px;
123
+ }
124
+ }
125
+ /* fix for issue on hover/visited for mobile devices */
126
+ @media (hover: none) {
127
+ .paginationItem button:hover {
128
+ background: inherit;
129
+ border-color: inherit;
130
+ color: inherit;
131
+ opacity: 1;
132
+ }
133
+
134
+ .paginationItem.activeItem button:hover {
135
+ background: #009993;
136
+ border-color: #009993;
137
+ color: #fff;
138
+ }
139
+ }
@@ -0,0 +1,297 @@
1
+ import { Component, h, Event, Prop, State } from '@stencil/core';
2
+ import { isMobile } from "../../utils/utils";
3
+ import { translate } from '../../utils/locale.utils';
4
+ export class HelperPagination {
5
+ constructor() {
6
+ /**
7
+ * First page boolean value - determines if the page is disabled or active
8
+ */
9
+ this.firstPage = false;
10
+ /**
11
+ * Previous page boolean value - determines if the page is disabled or active
12
+ */
13
+ this.previousPage = false;
14
+ /**
15
+ * The received offset
16
+ */
17
+ this.offset = 0;
18
+ /**
19
+ * The received limit for the number of pages
20
+ */
21
+ this.limit = 1;
22
+ /**
23
+ * The received total number of pages
24
+ */
25
+ this.total = 1;
26
+ /**
27
+ * Language
28
+ */
29
+ this.language = 'en';
30
+ /**
31
+ * In component working variable for the array of pages
32
+ */
33
+ this.pagesArray = [];
34
+ /**
35
+ * In component working variable for last page
36
+ */
37
+ this.endInt = 0;
38
+ this.userAgent = window.navigator.userAgent;
39
+ this.currentPage = 1;
40
+ /**
41
+ * Navigation logic
42
+ */
43
+ this.navigateTo = (navigationPage) => {
44
+ switch (navigationPage) {
45
+ case 'firstPage':
46
+ this.offsetInt = 0;
47
+ break;
48
+ case 'lastPage':
49
+ this.offsetInt = this.endInt * this.limitInt;
50
+ break;
51
+ case 'previousPage':
52
+ this.offsetInt -= 10;
53
+ break;
54
+ case 'nextPage':
55
+ this.offsetInt += 10;
56
+ break;
57
+ case 'fivePagesBack':
58
+ this.offsetInt -= 30;
59
+ this.offsetInt = this.offsetInt < 0 ? 0 : this.offsetInt;
60
+ break;
61
+ case 'fivePagesForward':
62
+ this.offsetInt += 30;
63
+ this.offsetInt = this.offsetInt / 10 >= this.endInt ? this.endInt * 10 : this.offsetInt;
64
+ break;
65
+ }
66
+ this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
67
+ };
68
+ /**
69
+ * Handle navigation from here
70
+ */
71
+ this.paginationNavigation = (pageNumber, index) => {
72
+ if (!isNaN(pageNumber)) {
73
+ if (pageNumber === 1) {
74
+ this.offsetInt = pageNumber - 1;
75
+ }
76
+ else {
77
+ this.offsetInt = (pageNumber - 1) * 10;
78
+ }
79
+ }
80
+ else {
81
+ if (index === 0 && this.currentPage <= 4) {
82
+ this.navigateTo('firstPage');
83
+ }
84
+ else if (index === 0 && this.currentPage > 4) {
85
+ this.navigateTo('fivePagesBack');
86
+ }
87
+ else if (index === 4 && this.endInt - this.currentPage >= 2) {
88
+ this.navigateTo('fivePagesForward');
89
+ }
90
+ }
91
+ this.currentPage = this.offsetInt;
92
+ this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
93
+ };
94
+ }
95
+ componentWillRender() {
96
+ this.offsetInt = this.offset;
97
+ this.currentPage = this.offsetInt / this.limitInt + 1;
98
+ this.limitInt = this.limit;
99
+ this.totalInt = this.total;
100
+ this.endInt = (Math.ceil(this.totalInt / this.limitInt) - 1);
101
+ this.lastPage = (this.offsetInt >= this.endInt * this.limitInt) ? false : true;
102
+ /**
103
+ * Construct numbered navigation area based on current page position
104
+ */
105
+ if (this.currentPage === 1 || this.currentPage === 2) {
106
+ this.pagesArray = Array.from({ length: 4 }, (_, i) => i + 1);
107
+ this.pagesArray.push('...');
108
+ }
109
+ else if (this.currentPage >= 3 && ((this.endInt - this.currentPage) >= 2)) {
110
+ this.pagesArray = Array.from({ length: 3 }, (_, i) => this.currentPage + i - 1);
111
+ this.pagesArray.push('...');
112
+ this.pagesArray.unshift('...');
113
+ }
114
+ else if ((this.endInt - this.currentPage) < 3) {
115
+ this.pagesArray = Array.from({ length: 4 }, (_, i) => this.endInt - 2 + i);
116
+ this.pagesArray.unshift('...');
117
+ }
118
+ }
119
+ render() {
120
+ /**
121
+ * Center navigation area
122
+ */
123
+ let navigationArea = h("ul", { class: "PaginationArea" }, this.pagesArray.map((item, index) => {
124
+ return (h("li", { class: 'PaginationItem' + (item === this.currentPage ? ' ActiveItem' : ' ') + ' ' + (isMobile(this.userAgent) ? 'MobileButtons' : '') },
125
+ h("button", { disabled: item === this.currentPage ? true : false, onClick: this.paginationNavigation.bind(this, item, index) },
126
+ h("span", null, item))));
127
+ }));
128
+ /**
129
+ * Left navigation area
130
+ */
131
+ let buttonsLeftSide = h("div", { class: "LeftItems" },
132
+ h("button", { disabled: !this.previousPage, onClick: this.navigateTo.bind(this, 'firstPage') }, translate('firstPage', this.language)),
133
+ h("button", { disabled: !this.previousPage ? true : false, onClick: this.navigateTo.bind(this, 'previousPage') }, translate('previousPage', this.language)));
134
+ if (isMobile(this.userAgent)) {
135
+ buttonsLeftSide =
136
+ h("div", { class: "LeftItems" },
137
+ h("button", { disabled: !this.previousPage ? true : false, onClick: this.navigateTo.bind(this, 'previousPage') }, translate('previousPage', this.language)));
138
+ }
139
+ /**
140
+ * Right navigation area
141
+ */
142
+ let buttonsRightSide = h("div", { class: "RightItems" },
143
+ h("button", { disabled: !this.lastPage ? true : false, onClick: this.navigateTo.bind(this, 'nextPage') }, translate('nextPage', this.language)),
144
+ h("button", { disabled: !this.lastPage ? true : false, onClick: this.navigateTo.bind(this, 'lastPage') }, translate('lastPage', this.language)));
145
+ if (isMobile(this.userAgent)) {
146
+ buttonsRightSide =
147
+ h("div", { class: "RightItems" },
148
+ h("button", { disabled: !this.lastPage ? true : false, onClick: this.navigateTo.bind(this, 'nextPage') }, translate('nextPage', this.language)));
149
+ }
150
+ return (h("div", { id: "PaginationContainer" },
151
+ buttonsLeftSide,
152
+ navigationArea,
153
+ buttonsRightSide));
154
+ }
155
+ static get is() { return "helper-pagination"; }
156
+ static get encapsulation() { return "shadow"; }
157
+ static get originalStyleUrls() { return {
158
+ "$": ["helper-pagination.scss"]
159
+ }; }
160
+ static get styleUrls() { return {
161
+ "$": ["helper-pagination.css"]
162
+ }; }
163
+ static get properties() { return {
164
+ "firstPage": {
165
+ "type": "boolean",
166
+ "mutable": true,
167
+ "complexType": {
168
+ "original": "boolean",
169
+ "resolved": "boolean",
170
+ "references": {}
171
+ },
172
+ "required": false,
173
+ "optional": false,
174
+ "docs": {
175
+ "tags": [],
176
+ "text": "First page boolean value - determines if the page is disabled or active"
177
+ },
178
+ "attribute": "first-page",
179
+ "reflect": true,
180
+ "defaultValue": "false"
181
+ },
182
+ "previousPage": {
183
+ "type": "boolean",
184
+ "mutable": true,
185
+ "complexType": {
186
+ "original": "boolean",
187
+ "resolved": "boolean",
188
+ "references": {}
189
+ },
190
+ "required": false,
191
+ "optional": false,
192
+ "docs": {
193
+ "tags": [],
194
+ "text": "Previous page boolean value - determines if the page is disabled or active"
195
+ },
196
+ "attribute": "previous-page",
197
+ "reflect": true,
198
+ "defaultValue": "false"
199
+ },
200
+ "offset": {
201
+ "type": "number",
202
+ "mutable": true,
203
+ "complexType": {
204
+ "original": "number",
205
+ "resolved": "number",
206
+ "references": {}
207
+ },
208
+ "required": false,
209
+ "optional": false,
210
+ "docs": {
211
+ "tags": [],
212
+ "text": "The received offset"
213
+ },
214
+ "attribute": "offset",
215
+ "reflect": true,
216
+ "defaultValue": "0"
217
+ },
218
+ "limit": {
219
+ "type": "number",
220
+ "mutable": true,
221
+ "complexType": {
222
+ "original": "number",
223
+ "resolved": "number",
224
+ "references": {}
225
+ },
226
+ "required": false,
227
+ "optional": false,
228
+ "docs": {
229
+ "tags": [],
230
+ "text": "The received limit for the number of pages"
231
+ },
232
+ "attribute": "limit",
233
+ "reflect": true,
234
+ "defaultValue": "1"
235
+ },
236
+ "total": {
237
+ "type": "number",
238
+ "mutable": true,
239
+ "complexType": {
240
+ "original": "number",
241
+ "resolved": "number",
242
+ "references": {}
243
+ },
244
+ "required": false,
245
+ "optional": false,
246
+ "docs": {
247
+ "tags": [],
248
+ "text": "The received total number of pages"
249
+ },
250
+ "attribute": "total",
251
+ "reflect": true,
252
+ "defaultValue": "1"
253
+ },
254
+ "language": {
255
+ "type": "string",
256
+ "mutable": false,
257
+ "complexType": {
258
+ "original": "string",
259
+ "resolved": "string",
260
+ "references": {}
261
+ },
262
+ "required": false,
263
+ "optional": false,
264
+ "docs": {
265
+ "tags": [],
266
+ "text": "Language"
267
+ },
268
+ "attribute": "language",
269
+ "reflect": false,
270
+ "defaultValue": "'en'"
271
+ }
272
+ }; }
273
+ static get states() { return {
274
+ "offsetInt": {},
275
+ "lastPage": {},
276
+ "limitInt": {},
277
+ "totalInt": {},
278
+ "pagesArray": {},
279
+ "endInt": {}
280
+ }; }
281
+ static get events() { return [{
282
+ "method": "hpPageChange",
283
+ "name": "hpPageChange",
284
+ "bubbles": true,
285
+ "cancelable": true,
286
+ "composed": true,
287
+ "docs": {
288
+ "tags": [],
289
+ "text": "Event that handles the navigation, updating the offset, limit and total values"
290
+ },
291
+ "complexType": {
292
+ "original": "any",
293
+ "resolved": "any",
294
+ "references": {}
295
+ }
296
+ }]; }
297
+ }
@@ -0,0 +1 @@
1
+ export * from './components';
@@ -0,0 +1,20 @@
1
+ const DEFAULT_LANGUAGE = 'en';
2
+ const SUPPORTED_LANGUAGES = ['ro', 'en'];
3
+ const TRANSLATIONS = {
4
+ en: {
5
+ firstPage: 'First',
6
+ previousPage: 'Previous',
7
+ nextPage: 'Next',
8
+ lastPage: 'Last'
9
+ },
10
+ ro: {
11
+ firstPage: 'Prima',
12
+ previousPage: 'Anterior',
13
+ nextPage: 'Urmatoarea',
14
+ lastPage: 'Ultima'
15
+ },
16
+ };
17
+ export const translate = (key, customLang) => {
18
+ const lang = customLang;
19
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
20
+ };
@@ -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,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface HelperPagination extends Components.HelperPagination, HTMLElement {}
4
+ export const HelperPagination: {
5
+ prototype: HelperPagination;
6
+ new (): HelperPagination;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;