px-jspreadsheet-ce 0.0.1

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 (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +292 -0
  3. package/dist/index.d.ts +2382 -0
  4. package/dist/index.js +11286 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/jspreadsheet.css +723 -0
  7. package/dist/jspreadsheet.themes.css +104 -0
  8. package/package.json +57 -0
  9. package/src/index.js +95 -0
  10. package/src/test.js +50 -0
  11. package/src/utils/cells.js +36 -0
  12. package/src/utils/columns.js +742 -0
  13. package/src/utils/comments.js +87 -0
  14. package/src/utils/config.js +46 -0
  15. package/src/utils/copyPaste.js +438 -0
  16. package/src/utils/data.js +419 -0
  17. package/src/utils/dispatch.js +115 -0
  18. package/src/utils/download.js +38 -0
  19. package/src/utils/editor.js +430 -0
  20. package/src/utils/events.js +1639 -0
  21. package/src/utils/factory.js +216 -0
  22. package/src/utils/filter.js +128 -0
  23. package/src/utils/footer.js +51 -0
  24. package/src/utils/freeze.js +19 -0
  25. package/src/utils/headers.js +74 -0
  26. package/src/utils/helpers.js +409 -0
  27. package/src/utils/history.js +336 -0
  28. package/src/utils/internal.js +1299 -0
  29. package/src/utils/internalHelpers.js +96 -0
  30. package/src/utils/keys.js +406 -0
  31. package/src/utils/lazyLoading.js +143 -0
  32. package/src/utils/libraryBase.js +5 -0
  33. package/src/utils/merges.js +275 -0
  34. package/src/utils/meta.js +81 -0
  35. package/src/utils/orderBy.js +185 -0
  36. package/src/utils/pagination.js +181 -0
  37. package/src/utils/rows.js +624 -0
  38. package/src/utils/search.js +83 -0
  39. package/src/utils/selection.js +744 -0
  40. package/src/utils/style.js +147 -0
  41. package/src/utils/toolbar.js +566 -0
  42. package/src/utils/version.js +9 -0
  43. package/src/utils/worksheets.js +731 -0
  44. package/src/webcomponent.js +59 -0
@@ -0,0 +1,181 @@
1
+ import jSuites from 'jsuites';
2
+
3
+ import dispatch from './dispatch.js';
4
+ import { updateCornerPosition } from './selection.js';
5
+
6
+ /**
7
+ * Which page the row is
8
+ */
9
+ export const whichPage = function (row) {
10
+ const obj = this;
11
+
12
+ // Search
13
+ if ((obj.options.search == true || obj.options.filters == true) && obj.results) {
14
+ row = obj.results.indexOf(row);
15
+ }
16
+
17
+ return Math.ceil((parseInt(row) + 1) / parseInt(obj.options.pagination)) - 1;
18
+ };
19
+
20
+ /**
21
+ * Update the pagination
22
+ */
23
+ export const updatePagination = function () {
24
+ const obj = this;
25
+
26
+ // Reset container
27
+ obj.pagination.children[0].innerHTML = '';
28
+ obj.pagination.children[1].innerHTML = '';
29
+
30
+ // Start pagination
31
+ if (obj.options.pagination) {
32
+ // Searchable
33
+ let results;
34
+
35
+ if ((obj.options.search == true || obj.options.filters == true) && obj.results) {
36
+ results = obj.results.length;
37
+ } else {
38
+ results = obj.rows.length;
39
+ }
40
+
41
+ if (!results) {
42
+ // No records found
43
+ obj.pagination.children[0].innerHTML = jSuites.translate('No records found');
44
+ } else {
45
+ // Pagination container
46
+ const quantyOfPages = Math.ceil(results / obj.options.pagination);
47
+
48
+ let startNumber, finalNumber;
49
+
50
+ if (obj.pageNumber < 6) {
51
+ startNumber = 1;
52
+ finalNumber = quantyOfPages < 10 ? quantyOfPages : 10;
53
+ } else if (quantyOfPages - obj.pageNumber < 5) {
54
+ startNumber = quantyOfPages - 9;
55
+ finalNumber = quantyOfPages;
56
+ if (startNumber < 1) {
57
+ startNumber = 1;
58
+ }
59
+ } else {
60
+ startNumber = obj.pageNumber - 4;
61
+ finalNumber = obj.pageNumber + 5;
62
+ }
63
+
64
+ // First
65
+ if (startNumber > 1) {
66
+ const paginationItem = document.createElement('div');
67
+ paginationItem.className = 'jss_page';
68
+ paginationItem.innerHTML = '<';
69
+ paginationItem.title = 1;
70
+ obj.pagination.children[1].appendChild(paginationItem);
71
+ }
72
+
73
+ // Get page links
74
+ for (let i = startNumber; i <= finalNumber; i++) {
75
+ const paginationItem = document.createElement('div');
76
+ paginationItem.className = 'jss_page';
77
+ paginationItem.innerHTML = i;
78
+ obj.pagination.children[1].appendChild(paginationItem);
79
+
80
+ if (obj.pageNumber == i - 1) {
81
+ paginationItem.classList.add('jss_page_selected');
82
+ }
83
+ }
84
+
85
+ // Last
86
+ if (finalNumber < quantyOfPages) {
87
+ const paginationItem = document.createElement('div');
88
+ paginationItem.className = 'jss_page';
89
+ paginationItem.innerHTML = '>';
90
+ paginationItem.title = quantyOfPages;
91
+ obj.pagination.children[1].appendChild(paginationItem);
92
+ }
93
+
94
+ // Text
95
+ const format = function (format) {
96
+ const args = Array.prototype.slice.call(arguments, 1);
97
+ return format.replace(/{(\d+)}/g, function (match, number) {
98
+ return typeof args[number] != 'undefined' ? args[number] : match;
99
+ });
100
+ };
101
+
102
+ obj.pagination.children[0].innerHTML = format(jSuites.translate('Showing page {0} of {1} entries'), obj.pageNumber + 1, quantyOfPages);
103
+ }
104
+ }
105
+ };
106
+
107
+ /**
108
+ * Go to page
109
+ */
110
+ export const page = function (pageNumber) {
111
+ const obj = this;
112
+
113
+ const oldPage = obj.pageNumber;
114
+
115
+ // Search
116
+ let results;
117
+
118
+ if ((obj.options.search == true || obj.options.filters == true) && obj.results) {
119
+ results = obj.results;
120
+ } else {
121
+ results = obj.rows;
122
+ }
123
+
124
+ // Per page
125
+ const quantityPerPage = parseInt(obj.options.pagination);
126
+
127
+ // pageNumber
128
+ if (pageNumber == null || pageNumber == -1) {
129
+ // Last page
130
+ pageNumber = Math.ceil(results.length / quantityPerPage) - 1;
131
+ }
132
+
133
+ // Page number
134
+ obj.pageNumber = pageNumber;
135
+
136
+ let startRow = pageNumber * quantityPerPage;
137
+ let finalRow = pageNumber * quantityPerPage + quantityPerPage;
138
+ if (finalRow > results.length) {
139
+ finalRow = results.length;
140
+ }
141
+ if (startRow < 0) {
142
+ startRow = 0;
143
+ }
144
+
145
+ // Reset container
146
+ while (obj.tbody.firstChild) {
147
+ obj.tbody.removeChild(obj.tbody.firstChild);
148
+ }
149
+
150
+ // Appeding items
151
+ for (let j = startRow; j < finalRow; j++) {
152
+ if ((obj.options.search == true || obj.options.filters == true) && obj.results) {
153
+ obj.tbody.appendChild(obj.rows[results[j]].element);
154
+ } else {
155
+ obj.tbody.appendChild(obj.rows[j].element);
156
+ }
157
+ }
158
+
159
+ if (obj.options.pagination > 0) {
160
+ updatePagination.call(obj);
161
+ }
162
+
163
+ // Update corner position
164
+ updateCornerPosition.call(obj);
165
+
166
+ // Events
167
+ dispatch.call(obj, 'onchangepage', obj, pageNumber, oldPage, obj.options.pagination);
168
+ };
169
+
170
+ export const quantiyOfPages = function () {
171
+ const obj = this;
172
+
173
+ let results;
174
+ if ((obj.options.search == true || obj.options.filters == true) && obj.results) {
175
+ results = obj.results.length;
176
+ } else {
177
+ results = obj.rows.length;
178
+ }
179
+
180
+ return Math.ceil(results / obj.options.pagination);
181
+ };