@schukai/monster 3.55.0 → 3.55.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.
- package/CHANGELOG.md +16 -0
- package/package.json +1 -1
- package/source/components/datatable/datasource/rest.mjs +313 -326
- package/source/components/datatable/datatable/header.mjs +1 -1
- package/source/components/datatable/datatable.mjs +586 -591
- package/source/components/datatable/embedded-pagination.mjs +42 -49
- package/source/components/datatable/filter/util.mjs +115 -99
- package/source/components/datatable/filter.mjs +901 -842
- package/source/components/datatable/pagination.mjs +333 -334
- package/source/components/datatable/status.mjs +134 -156
- package/source/components/datatable/stylesheet/column-bar.mjs +14 -8
- package/source/components/datatable/stylesheet/dataset.mjs +14 -8
- package/source/components/datatable/stylesheet/datasource.mjs +14 -8
- package/source/components/datatable/stylesheet/datatable.mjs +14 -8
- package/source/components/datatable/stylesheet/embedded-pagination.mjs +14 -8
- package/source/components/datatable/stylesheet/filter-button.mjs +14 -8
- package/source/components/datatable/stylesheet/filter-controls-defaults.mjs +14 -8
- package/source/components/datatable/stylesheet/filter-date-range.mjs +14 -8
- package/source/components/datatable/stylesheet/filter-range.mjs +14 -8
- package/source/components/datatable/stylesheet/filter.mjs +14 -8
- package/source/components/datatable/stylesheet/pagination.mjs +14 -8
- package/source/components/datatable/stylesheet/select-filter.mjs +14 -8
- package/source/components/datatable/stylesheet/status.mjs +14 -8
- package/source/components/form/action-button.mjs +3 -1
- package/source/components/form/confirm-button.mjs +3 -1
- package/source/components/form/context-error.mjs +161 -164
- package/source/components/form/context-help.mjs +3 -1
- package/source/components/form/form.mjs +3 -1
- package/source/components/form/message-state-button.mjs +3 -1
- package/source/components/form/popper-button.mjs +6 -4
- package/source/components/form/popper.mjs +310 -310
- package/source/components/form/select.mjs +2 -2
- package/source/components/form/state-button.mjs +3 -1
- package/source/components/form/stylesheet/action-button.mjs +14 -8
- package/source/components/form/stylesheet/api-button.mjs +14 -8
- package/source/components/form/stylesheet/button-bar.mjs +14 -8
- package/source/components/form/stylesheet/button.mjs +14 -8
- package/source/components/form/stylesheet/confirm-button.mjs +14 -8
- package/source/components/form/stylesheet/context-error.mjs +14 -8
- package/source/components/form/stylesheet/context-help.mjs +14 -8
- package/source/components/form/stylesheet/form.mjs +14 -8
- package/source/components/form/stylesheet/message-state-button.mjs +14 -8
- package/source/components/form/stylesheet/popper-button.mjs +14 -8
- package/source/components/form/stylesheet/popper.mjs +14 -8
- package/source/components/form/stylesheet/select.mjs +14 -8
- package/source/components/form/stylesheet/state-button.mjs +14 -8
- package/source/components/form/stylesheet/tabs.mjs +14 -8
- package/source/components/form/stylesheet/tree-select.mjs +14 -8
- package/source/components/form/tabs.mjs +754 -758
- package/source/components/host/collapse.mjs +2 -4
- package/source/components/host/config-manager.mjs +11 -9
- package/source/components/host/stylesheet/call-button.mjs +14 -8
- package/source/components/host/stylesheet/collapse.mjs +14 -8
- package/source/components/host/stylesheet/config-manager.mjs +14 -8
- package/source/components/host/stylesheet/details.mjs +14 -8
- package/source/components/host/stylesheet/host.mjs +14 -8
- package/source/components/host/stylesheet/overlay.mjs +14 -8
- package/source/components/host/stylesheet/toggle-button.mjs +14 -8
- package/source/components/host/stylesheet/viewer.mjs +14 -8
- package/source/components/host/util.mjs +2 -2
- package/source/components/notify/stylesheet/message.mjs +14 -8
- package/source/components/notify/stylesheet/notify.mjs +14 -8
- package/source/components/state/stylesheet/log.mjs +14 -8
- package/source/components/state/stylesheet/state.mjs +14 -8
- package/source/components/stylesheet/badge.mjs +14 -8
- package/source/components/stylesheet/border.mjs +14 -8
- package/source/components/stylesheet/button.mjs +14 -8
- package/source/components/stylesheet/card.mjs +14 -8
- package/source/components/stylesheet/color.mjs +14 -8
- package/source/components/stylesheet/common.mjs +14 -8
- package/source/components/stylesheet/control.mjs +14 -8
- package/source/components/stylesheet/data-grid.mjs +14 -8
- package/source/components/stylesheet/display.mjs +14 -8
- package/source/components/stylesheet/floating-ui.mjs +14 -8
- package/source/components/stylesheet/form.mjs +14 -8
- package/source/components/stylesheet/host.mjs +14 -8
- package/source/components/stylesheet/icons.mjs +14 -8
- package/source/components/stylesheet/link.mjs +14 -8
- package/source/components/stylesheet/normalize.mjs +14 -8
- package/source/components/stylesheet/popper.mjs +14 -8
- package/source/components/stylesheet/property.mjs +14 -8
- package/source/components/stylesheet/ripple.mjs +14 -8
- package/source/components/stylesheet/skeleton.mjs +14 -8
- package/source/components/stylesheet/space.mjs +14 -8
- package/source/components/stylesheet/spinner.mjs +14 -8
- package/source/components/stylesheet/table.mjs +14 -8
- package/source/components/stylesheet/theme.mjs +14 -8
- package/source/components/stylesheet/typography.mjs +14 -8
- package/source/components/tree-menu/stylesheet/tree-menu.mjs +14 -8
- package/source/data/transformer.mjs +6 -8
- package/source/dom/attributes.mjs +5 -5
- package/source/dom/customelement.mjs +1 -1
- package/source/dom/updater.mjs +697 -700
- package/source/dom/util.mjs +2 -2
- package/source/monster.mjs +0 -1
- package/source/types/noderecursiveiterator.mjs +9 -7
- package/source/types/version.mjs +1 -1
- package/source/util/sleep.mjs +3 -4
- package/test/cases/monster.mjs +1 -1
@@ -4,32 +4,32 @@
|
|
4
4
|
*/
|
5
5
|
|
6
6
|
import {
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
assembleMethodSymbol,
|
8
|
+
CustomElement,
|
9
|
+
registerCustomElement,
|
10
10
|
} from "../../dom/customelement.mjs";
|
11
|
-
import {ThemeStyleSheet} from "../stylesheet/theme.mjs";
|
12
|
-
import {ATTRIBUTE_DATASOURCE_SELECTOR} from "./constants.mjs";
|
13
|
-
import {Datasource} from "./datasource.mjs";
|
14
|
-
import {Observer} from "../../types/observer.mjs";
|
15
|
-
import {ATTRIBUTE_ROLE} from "../../dom/constants.mjs";
|
16
|
-
import {findTargetElementFromEvent} from "../../dom/events.mjs";
|
17
|
-
import {EmbeddedPaginationStyleSheet} from "./stylesheet/embedded-pagination.mjs";
|
18
|
-
import {PaginationStyleSheet} from "./stylesheet/pagination.mjs";
|
11
|
+
import { ThemeStyleSheet } from "../stylesheet/theme.mjs";
|
12
|
+
import { ATTRIBUTE_DATASOURCE_SELECTOR } from "./constants.mjs";
|
13
|
+
import { Datasource } from "./datasource.mjs";
|
14
|
+
import { Observer } from "../../types/observer.mjs";
|
15
|
+
import { ATTRIBUTE_ROLE } from "../../dom/constants.mjs";
|
16
|
+
import { findTargetElementFromEvent } from "../../dom/events.mjs";
|
17
|
+
import { EmbeddedPaginationStyleSheet } from "./stylesheet/embedded-pagination.mjs";
|
18
|
+
import { PaginationStyleSheet } from "./stylesheet/pagination.mjs";
|
19
19
|
//import {SpinnerStyleSheet} from "../stylesheet/spinner.mjs";
|
20
|
-
import {DisplayStyleSheet} from "../stylesheet/display.mjs";
|
21
|
-
import {isString} from "../../types/is.mjs";
|
22
|
-
import {Pathfinder} from "../../data/pathfinder.mjs";
|
23
|
-
import {instanceSymbol} from "../../constants.mjs";
|
24
|
-
import {Formatter} from "../../text/formatter.mjs";
|
20
|
+
import { DisplayStyleSheet } from "../stylesheet/display.mjs";
|
21
|
+
import { isString } from "../../types/is.mjs";
|
22
|
+
import { Pathfinder } from "../../data/pathfinder.mjs";
|
23
|
+
import { instanceSymbol } from "../../constants.mjs";
|
24
|
+
import { Formatter } from "../../text/formatter.mjs";
|
25
25
|
import "../form/select.mjs";
|
26
|
-
import {addAttributeToken} from "../../dom/attributes.mjs";
|
27
|
-
import {ATTRIBUTE_ERRORMESSAGE} from "../../dom/constants.mjs";
|
26
|
+
import { addAttributeToken } from "../../dom/attributes.mjs";
|
27
|
+
import { ATTRIBUTE_ERRORMESSAGE } from "../../dom/constants.mjs";
|
28
28
|
|
29
29
|
import "./datasource/dom.mjs";
|
30
30
|
import "./datasource/rest.mjs";
|
31
31
|
|
32
|
-
export {Pagination};
|
32
|
+
export { Pagination };
|
33
33
|
|
34
34
|
/**
|
35
35
|
* @private
|
@@ -76,144 +76,143 @@ const datasourceLinkedElementSymbol = Symbol("datasourceLinkedElement");
|
|
76
76
|
* @summary A datatable
|
77
77
|
*/
|
78
78
|
class Pagination extends CustomElement {
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
}
|
79
|
+
/**
|
80
|
+
*/
|
81
|
+
constructor() {
|
82
|
+
super();
|
83
|
+
this[datasourceLinkedElementSymbol] = null;
|
84
|
+
}
|
85
|
+
|
86
|
+
/**
|
87
|
+
* This method is called by the `instanceof` operator.
|
88
|
+
* @returns {symbol}
|
89
|
+
*/
|
90
|
+
static get [instanceSymbol]() {
|
91
|
+
return Symbol.for("@schukai/monster/components/pagination");
|
92
|
+
}
|
93
|
+
|
94
|
+
/**
|
95
|
+
* To set the options via the html tag the attribute `data-monster-options` must be used.
|
96
|
+
* @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
|
97
|
+
*
|
98
|
+
* The individual configuration values can be found in the table.
|
99
|
+
*
|
100
|
+
* @property {Object} templates Template definitions
|
101
|
+
* @property {string} templates.main Main template
|
102
|
+
* @property {int} offset Current offset
|
103
|
+
* @property {int} nextOffset Next offset
|
104
|
+
* @property {int} prevOffset Previous offset
|
105
|
+
* @property {int} objectsPerPage Number of objects per page
|
106
|
+
* @property {int} currentPage Current page
|
107
|
+
* @property {int} pages Total number of pages
|
108
|
+
* @property {int} total Total number of objects
|
109
|
+
*/
|
110
|
+
get defaults() {
|
111
|
+
return Object.assign(
|
112
|
+
{},
|
113
|
+
super.defaults,
|
114
|
+
{
|
115
|
+
templates: {
|
116
|
+
main: getTemplate(),
|
117
|
+
},
|
118
|
+
|
119
|
+
datasource: {
|
120
|
+
selector: null,
|
121
|
+
},
|
122
|
+
|
123
|
+
labels: {
|
124
|
+
page: "${page}",
|
125
|
+
description: "Page ${page}",
|
126
|
+
previous: "Previous",
|
127
|
+
next: "Next",
|
128
|
+
of: "of",
|
129
|
+
},
|
130
|
+
|
131
|
+
href: "page-${page}",
|
132
|
+
|
133
|
+
currentPage: undefined,
|
134
|
+
pages: undefined,
|
135
|
+
objectsPerPage: 20,
|
136
|
+
|
137
|
+
mapping: {
|
138
|
+
pages: "sys.pagination.pages",
|
139
|
+
objectsPerPage: "sys.pagination.objectsPerPage",
|
140
|
+
currentPage: "sys.pagination.currentPage",
|
141
|
+
},
|
142
|
+
|
143
|
+
// classes: {
|
144
|
+
// // spinner: "monster-spinner monster-theme-primary-3",
|
145
|
+
// // spinnerContainer: "monster-theme-primary-1 ",
|
146
|
+
// // error: "monster-theme-error-2 monster-bg-color-primary-2",
|
147
|
+
// // errorContainer: "monster-theme-primary-1",
|
148
|
+
// },
|
149
|
+
|
150
|
+
// state: {
|
151
|
+
// // spinner: false,
|
152
|
+
// // error: false,
|
153
|
+
// },
|
154
|
+
|
155
|
+
pagination: {
|
156
|
+
items: [],
|
157
|
+
},
|
158
|
+
},
|
159
|
+
initOptionsFromArguments.call(this),
|
160
|
+
);
|
161
|
+
}
|
162
|
+
|
163
|
+
/**
|
164
|
+
*
|
165
|
+
* @return {string}
|
166
|
+
*/
|
167
|
+
static getTag() {
|
168
|
+
return "monster-pagination";
|
169
|
+
}
|
170
|
+
|
171
|
+
/**
|
172
|
+
*
|
173
|
+
* @return {Monster.Components.Form.Form}
|
174
|
+
*/
|
175
|
+
[assembleMethodSymbol]() {
|
176
|
+
super[assembleMethodSymbol]();
|
177
|
+
|
178
|
+
initControlReferences.call(this);
|
179
|
+
initEventHandler.call(this);
|
180
|
+
|
181
|
+
const selector = this.getOption("datasource.selector", "");
|
182
|
+
|
183
|
+
if (isString(selector)) {
|
184
|
+
const elements = document.querySelectorAll(selector);
|
185
|
+
if (elements.length !== 1) {
|
186
|
+
throw new Error("the selector must match exactly one element");
|
187
|
+
}
|
188
|
+
|
189
|
+
const element = elements[0];
|
190
|
+
if (!(element instanceof Datasource)) {
|
191
|
+
throw new TypeError("the element must be a datasource");
|
192
|
+
}
|
193
|
+
|
194
|
+
this[datasourceLinkedElementSymbol] = element;
|
195
|
+
element.datasource.attachObserver(
|
196
|
+
new Observer(handleDataSourceChanges.bind(this)),
|
197
|
+
);
|
198
|
+
}
|
199
|
+
}
|
200
|
+
|
201
|
+
/**
|
202
|
+
* @private
|
203
|
+
* @returns {CSSStyleSheet}
|
204
|
+
*/
|
205
|
+
static getControlCSSStyleSheet() {
|
206
|
+
return PaginationStyleSheet;
|
207
|
+
}
|
208
|
+
|
209
|
+
/**
|
210
|
+
*
|
211
|
+
* @return [CSSStyleSheet]
|
212
|
+
*/
|
213
|
+
static getCSSStyleSheet() {
|
214
|
+
return [this.getControlCSSStyleSheet(), DisplayStyleSheet, ThemeStyleSheet];
|
215
|
+
}
|
217
216
|
}
|
218
217
|
|
219
218
|
/**
|
@@ -222,73 +221,73 @@ class Pagination extends CustomElement {
|
|
222
221
|
* @throws {Error} no shadow-root is defined
|
223
222
|
*/
|
224
223
|
function initControlReferences() {
|
225
|
-
|
226
|
-
|
227
|
-
|
224
|
+
if (!this.shadowRoot) {
|
225
|
+
throw new Error("no shadow-root is defined");
|
226
|
+
}
|
228
227
|
|
229
|
-
|
230
|
-
|
231
|
-
|
228
|
+
this[paginationElementSymbol] = this.shadowRoot.querySelector(
|
229
|
+
"[data-monster-role=pagination]",
|
230
|
+
);
|
232
231
|
}
|
233
232
|
|
234
233
|
/**
|
235
234
|
* @private
|
236
235
|
*/
|
237
236
|
function initEventHandler() {
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
237
|
+
const self = this;
|
238
|
+
|
239
|
+
self[paginationElementSymbol].addEventListener("click", function (event) {
|
240
|
+
let element = null;
|
241
|
+
const datasource = self[datasourceLinkedElementSymbol];
|
242
|
+
if (!datasource) {
|
243
|
+
return;
|
244
|
+
}
|
245
|
+
|
246
|
+
element = findTargetElementFromEvent(
|
247
|
+
event,
|
248
|
+
ATTRIBUTE_ROLE,
|
249
|
+
"pagination-item",
|
250
|
+
);
|
251
|
+
if (!element) {
|
252
|
+
element = findTargetElementFromEvent(
|
253
|
+
event,
|
254
|
+
ATTRIBUTE_ROLE,
|
255
|
+
"pagination-next",
|
256
|
+
);
|
257
|
+
if (!element) {
|
258
|
+
element = findTargetElementFromEvent(
|
259
|
+
event,
|
260
|
+
ATTRIBUTE_ROLE,
|
261
|
+
"pagination-prev",
|
262
|
+
);
|
263
|
+
if (!element) {
|
264
|
+
return;
|
265
|
+
}
|
266
|
+
}
|
267
|
+
}
|
268
|
+
|
269
|
+
let page = null;
|
270
|
+
|
271
|
+
if (!element.hasAttribute("data-page-no")) {
|
272
|
+
return;
|
273
|
+
}
|
274
|
+
|
275
|
+
page = element.getAttribute("data-page-no");
|
276
|
+
event.preventDefault();
|
277
|
+
|
278
|
+
if (
|
279
|
+
!page ||
|
280
|
+
page === "" ||
|
281
|
+
page === null ||
|
282
|
+
page === undefined ||
|
283
|
+
page === "undefined" ||
|
284
|
+
page === "null"
|
285
|
+
) {
|
286
|
+
return;
|
287
|
+
}
|
288
|
+
|
289
|
+
datasource.setParameters({ page }).reload();
|
290
|
+
});
|
292
291
|
}
|
293
292
|
|
294
293
|
/**
|
@@ -304,46 +303,46 @@ function initEventHandler() {
|
|
304
303
|
* @throws {Error} the datasource could not be initialized
|
305
304
|
*/
|
306
305
|
function initOptionsFromArguments() {
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
306
|
+
const options = {};
|
307
|
+
const selector = this.getAttribute(ATTRIBUTE_DATASOURCE_SELECTOR);
|
308
|
+
if (selector) {
|
309
|
+
options.datasource = { selector: selector };
|
310
|
+
}
|
312
311
|
|
313
|
-
|
312
|
+
return options;
|
314
313
|
}
|
315
314
|
|
316
315
|
/**
|
317
316
|
* @private
|
318
317
|
*/
|
319
318
|
function handleDataSourceChanges() {
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
319
|
+
let pagination;
|
320
|
+
|
321
|
+
if (!this[datasourceLinkedElementSymbol]) {
|
322
|
+
return;
|
323
|
+
}
|
324
|
+
|
325
|
+
const mapping = this.getOption("mapping");
|
326
|
+
for (const key in mapping) {
|
327
|
+
const path = mapping[key];
|
328
|
+
|
329
|
+
let value;
|
330
|
+
try {
|
331
|
+
value = new Pathfinder(this[datasourceLinkedElementSymbol].data).getVia(
|
332
|
+
path,
|
333
|
+
);
|
334
|
+
this.setOption(key, value);
|
335
|
+
} catch (e) {
|
336
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
|
337
|
+
}
|
338
|
+
}
|
339
|
+
|
340
|
+
pagination = buildPagination.call(
|
341
|
+
this,
|
342
|
+
this.getOption("currentPage"),
|
343
|
+
this.getOption("pages"),
|
344
|
+
);
|
345
|
+
this.setOption("pagination", pagination);
|
347
346
|
}
|
348
347
|
|
349
348
|
/**
|
@@ -353,88 +352,88 @@ function handleDataSourceChanges() {
|
|
353
352
|
* @returns {object}
|
354
353
|
*/
|
355
354
|
function buildPagination(current, max) {
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
355
|
+
let prev = current === 1 ? null : current - 1;
|
356
|
+
let next = current === max ? null : current + 1;
|
357
|
+
const itemList = [1];
|
358
|
+
|
359
|
+
if (current > 4) itemList.push("…");
|
360
|
+
|
361
|
+
const r = 2;
|
362
|
+
const r1 = current - r;
|
363
|
+
const r2 = current + r;
|
364
|
+
|
365
|
+
for (let i = r1 > 2 ? r1 : 2; i <= Math.min(max, r2); i++) itemList.push(i);
|
366
|
+
|
367
|
+
if (r2 + 1 < max) itemList.push("…");
|
368
|
+
if (r2 < max) itemList.push(max);
|
369
|
+
|
370
|
+
let prevClass = "";
|
371
|
+
|
372
|
+
if (prev === null) {
|
373
|
+
prevClass = " disabled";
|
374
|
+
}
|
375
|
+
|
376
|
+
let nextClass = "";
|
377
|
+
if (next === null) {
|
378
|
+
nextClass = " disabled";
|
379
|
+
}
|
380
|
+
|
381
|
+
const items = itemList.map((item) => {
|
382
|
+
const p = `${item}`;
|
383
|
+
const c = `${current}`;
|
384
|
+
|
385
|
+
const obj = {
|
386
|
+
pageNo: item, // as integer
|
387
|
+
page: p, // as string
|
388
|
+
current: p === c,
|
389
|
+
class: (p === c ? "current" : "").trim(),
|
390
|
+
};
|
391
|
+
|
392
|
+
if (p === "…") {
|
393
|
+
obj.class += " disabled".trim();
|
394
|
+
}
|
395
|
+
|
396
|
+
const formatter = new Formatter(obj);
|
397
|
+
|
398
|
+
obj.description = formatter.format(this.getOption("labels.description"));
|
399
|
+
obj.label = formatter.format(this.getOption("labels.page"));
|
400
|
+
obj.href =
|
401
|
+
p === "…"
|
402
|
+
? "#"
|
403
|
+
: p === c
|
404
|
+
? "#"
|
405
|
+
: p === "1"
|
406
|
+
? "#"
|
407
|
+
: `#${formatter.format(this.getOption("href"))}`;
|
408
|
+
return obj;
|
409
|
+
});
|
410
|
+
|
411
|
+
const nextNo = next;
|
412
|
+
next = `${next}`;
|
413
|
+
|
414
|
+
const nextHref =
|
415
|
+
next === "null"
|
416
|
+
? "#"
|
417
|
+
: `#${new Formatter({ page: next }).format(this.getOption("href"))}`;
|
418
|
+
const prevNo = prev;
|
419
|
+
prev = `${prev}`;
|
420
|
+
const prevHref =
|
421
|
+
prev === "null"
|
422
|
+
? "#"
|
423
|
+
: `#${new Formatter({ page: prev }).format(this.getOption("href"))}`;
|
424
|
+
|
425
|
+
return {
|
426
|
+
current,
|
427
|
+
nextNo,
|
428
|
+
next,
|
429
|
+
nextClass,
|
430
|
+
nextHref,
|
431
|
+
prevNo,
|
432
|
+
prev,
|
433
|
+
prevClass,
|
434
|
+
prevHref,
|
435
|
+
items,
|
436
|
+
};
|
438
437
|
}
|
439
438
|
|
440
439
|
/**
|
@@ -442,8 +441,8 @@ function buildPagination(current, max) {
|
|
442
441
|
* @return {string}
|
443
442
|
*/
|
444
443
|
function getTemplate() {
|
445
|
-
|
446
|
-
|
444
|
+
// language=HTML
|
445
|
+
return `
|
447
446
|
<template id="items">
|
448
447
|
<li><a data-monster-attributes="class path:items.class,
|
449
448
|
href path:items.href,
|