@m3e/paginator 1.1.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.
- package/LICENSE +22 -0
- package/NOTICE.md +8 -0
- package/README.md +130 -0
- package/dist/css-custom-data.json +42 -0
- package/dist/custom-elements.json +3276 -0
- package/dist/html-custom-data.json +90 -0
- package/dist/index.js +693 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +37 -0
- package/dist/index.min.js.map +1 -0
- package/dist/src/PageEventDetail.d.ts +12 -0
- package/dist/src/PageEventDetail.d.ts.map +1 -0
- package/dist/src/PaginatorElement.d.ts +168 -0
- package/dist/src/PaginatorElement.d.ts.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/package.json +38 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,693 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
* Copyright (c) 2025 matraic
|
|
4
|
+
* See LICENSE file in the project root for full license text.
|
|
5
|
+
*/
|
|
6
|
+
import { LitElement, html, css, nothing } from 'lit';
|
|
7
|
+
import { EventAttribute, Role, DesignToken } from '@m3e/core';
|
|
8
|
+
|
|
9
|
+
/******************************************************************************
|
|
10
|
+
Copyright (c) Microsoft Corporation.
|
|
11
|
+
|
|
12
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
13
|
+
purpose with or without fee is hereby granted.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
16
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
17
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
18
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
19
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
20
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
21
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
22
|
+
***************************************************************************** */
|
|
23
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
24
|
+
|
|
25
|
+
function __decorate(decorators, target, key, desc) {
|
|
26
|
+
var c = arguments.length,
|
|
27
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
28
|
+
d;
|
|
29
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
30
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31
|
+
}
|
|
32
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
33
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
34
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
35
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
36
|
+
}
|
|
37
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
38
|
+
var e = new Error(message);
|
|
39
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @license
|
|
44
|
+
* Copyright 2017 Google LLC
|
|
45
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
46
|
+
*/
|
|
47
|
+
const t$1 = t => (e, o) => {
|
|
48
|
+
void 0 !== o ? o.addInitializer(() => {
|
|
49
|
+
customElements.define(t, e);
|
|
50
|
+
}) : customElements.define(t, e);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @license
|
|
55
|
+
* Copyright 2019 Google LLC
|
|
56
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
57
|
+
*/
|
|
58
|
+
const t = globalThis,
|
|
59
|
+
e$1 = t.ShadowRoot && (void 0 === t.ShadyCSS || t.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype,
|
|
60
|
+
s = Symbol(),
|
|
61
|
+
o$2 = new WeakMap();
|
|
62
|
+
let n$2 = class n {
|
|
63
|
+
constructor(t, e, o) {
|
|
64
|
+
if (this._$cssResult$ = true, o !== s) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
|
|
65
|
+
this.cssText = t, this.t = e;
|
|
66
|
+
}
|
|
67
|
+
get styleSheet() {
|
|
68
|
+
let t = this.o;
|
|
69
|
+
const s = this.t;
|
|
70
|
+
if (e$1 && void 0 === t) {
|
|
71
|
+
const e = void 0 !== s && 1 === s.length;
|
|
72
|
+
e && (t = o$2.get(s)), void 0 === t && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), e && o$2.set(s, t));
|
|
73
|
+
}
|
|
74
|
+
return t;
|
|
75
|
+
}
|
|
76
|
+
toString() {
|
|
77
|
+
return this.cssText;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const r$2 = t => new n$2("string" == typeof t ? t : t + "", void 0, s),
|
|
81
|
+
S = (s, o) => {
|
|
82
|
+
if (e$1) s.adoptedStyleSheets = o.map(t => t instanceof CSSStyleSheet ? t : t.styleSheet);else for (const e of o) {
|
|
83
|
+
const o = document.createElement("style"),
|
|
84
|
+
n = t.litNonce;
|
|
85
|
+
void 0 !== n && o.setAttribute("nonce", n), o.textContent = e.cssText, s.appendChild(o);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
c$1 = e$1 ? t => t : t => t instanceof CSSStyleSheet ? (t => {
|
|
89
|
+
let e = "";
|
|
90
|
+
for (const s of t.cssRules) e += s.cssText;
|
|
91
|
+
return r$2(e);
|
|
92
|
+
})(t) : t;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @license
|
|
96
|
+
* Copyright 2017 Google LLC
|
|
97
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
98
|
+
*/
|
|
99
|
+
const {
|
|
100
|
+
is: i,
|
|
101
|
+
defineProperty: e,
|
|
102
|
+
getOwnPropertyDescriptor: h,
|
|
103
|
+
getOwnPropertyNames: r$1,
|
|
104
|
+
getOwnPropertySymbols: o$1,
|
|
105
|
+
getPrototypeOf: n$1
|
|
106
|
+
} = Object,
|
|
107
|
+
a = globalThis,
|
|
108
|
+
c = a.trustedTypes,
|
|
109
|
+
l = c ? c.emptyScript : "",
|
|
110
|
+
p = a.reactiveElementPolyfillSupport,
|
|
111
|
+
d = (t, s) => t,
|
|
112
|
+
u = {
|
|
113
|
+
toAttribute(t, s) {
|
|
114
|
+
switch (s) {
|
|
115
|
+
case Boolean:
|
|
116
|
+
t = t ? l : null;
|
|
117
|
+
break;
|
|
118
|
+
case Object:
|
|
119
|
+
case Array:
|
|
120
|
+
t = null == t ? t : JSON.stringify(t);
|
|
121
|
+
}
|
|
122
|
+
return t;
|
|
123
|
+
},
|
|
124
|
+
fromAttribute(t, s) {
|
|
125
|
+
let i = t;
|
|
126
|
+
switch (s) {
|
|
127
|
+
case Boolean:
|
|
128
|
+
i = null !== t;
|
|
129
|
+
break;
|
|
130
|
+
case Number:
|
|
131
|
+
i = null === t ? null : Number(t);
|
|
132
|
+
break;
|
|
133
|
+
case Object:
|
|
134
|
+
case Array:
|
|
135
|
+
try {
|
|
136
|
+
i = JSON.parse(t);
|
|
137
|
+
} catch (t) {
|
|
138
|
+
i = null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return i;
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
f = (t, s) => !i(t, s),
|
|
145
|
+
b = {
|
|
146
|
+
attribute: true,
|
|
147
|
+
type: String,
|
|
148
|
+
converter: u,
|
|
149
|
+
reflect: false,
|
|
150
|
+
useDefault: false,
|
|
151
|
+
hasChanged: f
|
|
152
|
+
};
|
|
153
|
+
Symbol.metadata ??= Symbol("metadata"), a.litPropertyMetadata ??= new WeakMap();
|
|
154
|
+
class y extends HTMLElement {
|
|
155
|
+
static addInitializer(t) {
|
|
156
|
+
this._$Ei(), (this.l ??= []).push(t);
|
|
157
|
+
}
|
|
158
|
+
static get observedAttributes() {
|
|
159
|
+
return this.finalize(), this._$Eh && [...this._$Eh.keys()];
|
|
160
|
+
}
|
|
161
|
+
static createProperty(t, s = b) {
|
|
162
|
+
if (s.state && (s.attribute = false), this._$Ei(), this.prototype.hasOwnProperty(t) && ((s = Object.create(s)).wrapped = true), this.elementProperties.set(t, s), !s.noAccessor) {
|
|
163
|
+
const i = Symbol(),
|
|
164
|
+
h = this.getPropertyDescriptor(t, i, s);
|
|
165
|
+
void 0 !== h && e(this.prototype, t, h);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
static getPropertyDescriptor(t, s, i) {
|
|
169
|
+
const {
|
|
170
|
+
get: e,
|
|
171
|
+
set: r
|
|
172
|
+
} = h(this.prototype, t) ?? {
|
|
173
|
+
get() {
|
|
174
|
+
return this[s];
|
|
175
|
+
},
|
|
176
|
+
set(t) {
|
|
177
|
+
this[s] = t;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
return {
|
|
181
|
+
get: e,
|
|
182
|
+
set(s) {
|
|
183
|
+
const h = e?.call(this);
|
|
184
|
+
r?.call(this, s), this.requestUpdate(t, h, i);
|
|
185
|
+
},
|
|
186
|
+
configurable: true,
|
|
187
|
+
enumerable: true
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
static getPropertyOptions(t) {
|
|
191
|
+
return this.elementProperties.get(t) ?? b;
|
|
192
|
+
}
|
|
193
|
+
static _$Ei() {
|
|
194
|
+
if (this.hasOwnProperty(d("elementProperties"))) return;
|
|
195
|
+
const t = n$1(this);
|
|
196
|
+
t.finalize(), void 0 !== t.l && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
|
|
197
|
+
}
|
|
198
|
+
static finalize() {
|
|
199
|
+
if (this.hasOwnProperty(d("finalized"))) return;
|
|
200
|
+
if (this.finalized = true, this._$Ei(), this.hasOwnProperty(d("properties"))) {
|
|
201
|
+
const t = this.properties,
|
|
202
|
+
s = [...r$1(t), ...o$1(t)];
|
|
203
|
+
for (const i of s) this.createProperty(i, t[i]);
|
|
204
|
+
}
|
|
205
|
+
const t = this[Symbol.metadata];
|
|
206
|
+
if (null !== t) {
|
|
207
|
+
const s = litPropertyMetadata.get(t);
|
|
208
|
+
if (void 0 !== s) for (const [t, i] of s) this.elementProperties.set(t, i);
|
|
209
|
+
}
|
|
210
|
+
this._$Eh = new Map();
|
|
211
|
+
for (const [t, s] of this.elementProperties) {
|
|
212
|
+
const i = this._$Eu(t, s);
|
|
213
|
+
void 0 !== i && this._$Eh.set(i, t);
|
|
214
|
+
}
|
|
215
|
+
this.elementStyles = this.finalizeStyles(this.styles);
|
|
216
|
+
}
|
|
217
|
+
static finalizeStyles(s) {
|
|
218
|
+
const i = [];
|
|
219
|
+
if (Array.isArray(s)) {
|
|
220
|
+
const e = new Set(s.flat(1 / 0).reverse());
|
|
221
|
+
for (const s of e) i.unshift(c$1(s));
|
|
222
|
+
} else void 0 !== s && i.push(c$1(s));
|
|
223
|
+
return i;
|
|
224
|
+
}
|
|
225
|
+
static _$Eu(t, s) {
|
|
226
|
+
const i = s.attribute;
|
|
227
|
+
return false === i ? void 0 : "string" == typeof i ? i : "string" == typeof t ? t.toLowerCase() : void 0;
|
|
228
|
+
}
|
|
229
|
+
constructor() {
|
|
230
|
+
super(), this._$Ep = void 0, this.isUpdatePending = false, this.hasUpdated = false, this._$Em = null, this._$Ev();
|
|
231
|
+
}
|
|
232
|
+
_$Ev() {
|
|
233
|
+
this._$ES = new Promise(t => this.enableUpdating = t), this._$AL = new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach(t => t(this));
|
|
234
|
+
}
|
|
235
|
+
addController(t) {
|
|
236
|
+
(this._$EO ??= new Set()).add(t), void 0 !== this.renderRoot && this.isConnected && t.hostConnected?.();
|
|
237
|
+
}
|
|
238
|
+
removeController(t) {
|
|
239
|
+
this._$EO?.delete(t);
|
|
240
|
+
}
|
|
241
|
+
_$E_() {
|
|
242
|
+
const t = new Map(),
|
|
243
|
+
s = this.constructor.elementProperties;
|
|
244
|
+
for (const i of s.keys()) this.hasOwnProperty(i) && (t.set(i, this[i]), delete this[i]);
|
|
245
|
+
t.size > 0 && (this._$Ep = t);
|
|
246
|
+
}
|
|
247
|
+
createRenderRoot() {
|
|
248
|
+
const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
|
|
249
|
+
return S(t, this.constructor.elementStyles), t;
|
|
250
|
+
}
|
|
251
|
+
connectedCallback() {
|
|
252
|
+
this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(true), this._$EO?.forEach(t => t.hostConnected?.());
|
|
253
|
+
}
|
|
254
|
+
enableUpdating(t) {}
|
|
255
|
+
disconnectedCallback() {
|
|
256
|
+
this._$EO?.forEach(t => t.hostDisconnected?.());
|
|
257
|
+
}
|
|
258
|
+
attributeChangedCallback(t, s, i) {
|
|
259
|
+
this._$AK(t, i);
|
|
260
|
+
}
|
|
261
|
+
_$ET(t, s) {
|
|
262
|
+
const i = this.constructor.elementProperties.get(t),
|
|
263
|
+
e = this.constructor._$Eu(t, i);
|
|
264
|
+
if (void 0 !== e && true === i.reflect) {
|
|
265
|
+
const h = (void 0 !== i.converter?.toAttribute ? i.converter : u).toAttribute(s, i.type);
|
|
266
|
+
this._$Em = t, null == h ? this.removeAttribute(e) : this.setAttribute(e, h), this._$Em = null;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
_$AK(t, s) {
|
|
270
|
+
const i = this.constructor,
|
|
271
|
+
e = i._$Eh.get(t);
|
|
272
|
+
if (void 0 !== e && this._$Em !== e) {
|
|
273
|
+
const t = i.getPropertyOptions(e),
|
|
274
|
+
h = "function" == typeof t.converter ? {
|
|
275
|
+
fromAttribute: t.converter
|
|
276
|
+
} : void 0 !== t.converter?.fromAttribute ? t.converter : u;
|
|
277
|
+
this._$Em = e;
|
|
278
|
+
const r = h.fromAttribute(s, t.type);
|
|
279
|
+
this[e] = r ?? this._$Ej?.get(e) ?? r, this._$Em = null;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
requestUpdate(t, s, i) {
|
|
283
|
+
if (void 0 !== t) {
|
|
284
|
+
const e = this.constructor,
|
|
285
|
+
h = this[t];
|
|
286
|
+
if (i ??= e.getPropertyOptions(t), !((i.hasChanged ?? f)(h, s) || i.useDefault && i.reflect && h === this._$Ej?.get(t) && !this.hasAttribute(e._$Eu(t, i)))) return;
|
|
287
|
+
this.C(t, s, i);
|
|
288
|
+
}
|
|
289
|
+
false === this.isUpdatePending && (this._$ES = this._$EP());
|
|
290
|
+
}
|
|
291
|
+
C(t, s, {
|
|
292
|
+
useDefault: i,
|
|
293
|
+
reflect: e,
|
|
294
|
+
wrapped: h
|
|
295
|
+
}, r) {
|
|
296
|
+
i && !(this._$Ej ??= new Map()).has(t) && (this._$Ej.set(t, r ?? s ?? this[t]), true !== h || void 0 !== r) || (this._$AL.has(t) || (this.hasUpdated || i || (s = void 0), this._$AL.set(t, s)), true === e && this._$Em !== t && (this._$Eq ??= new Set()).add(t));
|
|
297
|
+
}
|
|
298
|
+
async _$EP() {
|
|
299
|
+
this.isUpdatePending = true;
|
|
300
|
+
try {
|
|
301
|
+
await this._$ES;
|
|
302
|
+
} catch (t) {
|
|
303
|
+
Promise.reject(t);
|
|
304
|
+
}
|
|
305
|
+
const t = this.scheduleUpdate();
|
|
306
|
+
return null != t && (await t), !this.isUpdatePending;
|
|
307
|
+
}
|
|
308
|
+
scheduleUpdate() {
|
|
309
|
+
return this.performUpdate();
|
|
310
|
+
}
|
|
311
|
+
performUpdate() {
|
|
312
|
+
if (!this.isUpdatePending) return;
|
|
313
|
+
if (!this.hasUpdated) {
|
|
314
|
+
if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
|
|
315
|
+
for (const [t, s] of this._$Ep) this[t] = s;
|
|
316
|
+
this._$Ep = void 0;
|
|
317
|
+
}
|
|
318
|
+
const t = this.constructor.elementProperties;
|
|
319
|
+
if (t.size > 0) for (const [s, i] of t) {
|
|
320
|
+
const {
|
|
321
|
+
wrapped: t
|
|
322
|
+
} = i,
|
|
323
|
+
e = this[s];
|
|
324
|
+
true !== t || this._$AL.has(s) || void 0 === e || this.C(s, void 0, i, e);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
let t = false;
|
|
328
|
+
const s = this._$AL;
|
|
329
|
+
try {
|
|
330
|
+
t = this.shouldUpdate(s), t ? (this.willUpdate(s), this._$EO?.forEach(t => t.hostUpdate?.()), this.update(s)) : this._$EM();
|
|
331
|
+
} catch (s) {
|
|
332
|
+
throw t = false, this._$EM(), s;
|
|
333
|
+
}
|
|
334
|
+
t && this._$AE(s);
|
|
335
|
+
}
|
|
336
|
+
willUpdate(t) {}
|
|
337
|
+
_$AE(t) {
|
|
338
|
+
this._$EO?.forEach(t => t.hostUpdated?.()), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t)), this.updated(t);
|
|
339
|
+
}
|
|
340
|
+
_$EM() {
|
|
341
|
+
this._$AL = new Map(), this.isUpdatePending = false;
|
|
342
|
+
}
|
|
343
|
+
get updateComplete() {
|
|
344
|
+
return this.getUpdateComplete();
|
|
345
|
+
}
|
|
346
|
+
getUpdateComplete() {
|
|
347
|
+
return this._$ES;
|
|
348
|
+
}
|
|
349
|
+
shouldUpdate(t) {
|
|
350
|
+
return true;
|
|
351
|
+
}
|
|
352
|
+
update(t) {
|
|
353
|
+
this._$Eq &&= this._$Eq.forEach(t => this._$ET(t, this[t])), this._$EM();
|
|
354
|
+
}
|
|
355
|
+
updated(t) {}
|
|
356
|
+
firstUpdated(t) {}
|
|
357
|
+
}
|
|
358
|
+
y.elementStyles = [], y.shadowRootOptions = {
|
|
359
|
+
mode: "open"
|
|
360
|
+
}, y[d("elementProperties")] = new Map(), y[d("finalized")] = new Map(), p?.({
|
|
361
|
+
ReactiveElement: y
|
|
362
|
+
}), (a.reactiveElementVersions ??= []).push("2.1.1");
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* @license
|
|
366
|
+
* Copyright 2017 Google LLC
|
|
367
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
368
|
+
*/
|
|
369
|
+
const o = {
|
|
370
|
+
attribute: true,
|
|
371
|
+
type: String,
|
|
372
|
+
converter: u,
|
|
373
|
+
reflect: false,
|
|
374
|
+
hasChanged: f
|
|
375
|
+
},
|
|
376
|
+
r = (t = o, e, r) => {
|
|
377
|
+
const {
|
|
378
|
+
kind: n,
|
|
379
|
+
metadata: i
|
|
380
|
+
} = r;
|
|
381
|
+
let s = globalThis.litPropertyMetadata.get(i);
|
|
382
|
+
if (void 0 === s && globalThis.litPropertyMetadata.set(i, s = new Map()), "setter" === n && ((t = Object.create(t)).wrapped = true), s.set(r.name, t), "accessor" === n) {
|
|
383
|
+
const {
|
|
384
|
+
name: o
|
|
385
|
+
} = r;
|
|
386
|
+
return {
|
|
387
|
+
set(r) {
|
|
388
|
+
const n = e.get.call(this);
|
|
389
|
+
e.set.call(this, r), this.requestUpdate(o, n, t);
|
|
390
|
+
},
|
|
391
|
+
init(e) {
|
|
392
|
+
return void 0 !== e && this.C(o, void 0, t, e), e;
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
if ("setter" === n) {
|
|
397
|
+
const {
|
|
398
|
+
name: o
|
|
399
|
+
} = r;
|
|
400
|
+
return function (r) {
|
|
401
|
+
const n = this[o];
|
|
402
|
+
e.call(this, r), this.requestUpdate(o, n, t);
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
throw Error("Unsupported decorator location: " + n);
|
|
406
|
+
};
|
|
407
|
+
function n(t) {
|
|
408
|
+
return (e, o) => "object" == typeof o ? r(t, e, o) : ((t, e, o) => {
|
|
409
|
+
const r = e.hasOwnProperty(o);
|
|
410
|
+
return e.constructor.createProperty(o, t), r ? Object.getOwnPropertyDescriptor(e, o) : void 0;
|
|
411
|
+
})(t, e, o);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Adapted from Angular Material Paginator
|
|
416
|
+
* Source: https://github.com/angular/components/blob/main/src/material/paginator/paginator.ts
|
|
417
|
+
*
|
|
418
|
+
* @license MIT
|
|
419
|
+
* Copyright (c) 2025 Google LLC
|
|
420
|
+
* See LICENSE file in the project root for full license text.
|
|
421
|
+
*/
|
|
422
|
+
var _M3ePaginatorElement_instances, _M3ePaginatorElement_pageSizeLabelId, _M3ePaginatorElement_defaultRangeLabelFormatter, _M3ePaginatorElement_renderPageSize, _M3ePaginatorElement_parsePageSizes, _M3ePaginatorElement_renderRangeActions, _M3ePaginatorElement_handleSelectChange, _M3ePaginatorElement_emitPageEvent;
|
|
423
|
+
var M3ePaginatorElement_1;
|
|
424
|
+
/**
|
|
425
|
+
* Provides navigation for paged information, typically used with a table.
|
|
426
|
+
*
|
|
427
|
+
* @description
|
|
428
|
+
* The `m3e-paginator` component is a compact, accessible paginator control for navigating
|
|
429
|
+
* paged data sets. It provides semantic first/previous/next/last navigation controls and an
|
|
430
|
+
* optional page-size selector that integrates with Material design tokens and `m3e-form-field` variants
|
|
431
|
+
* to ensure consistent typography, density, and spacing across applications.
|
|
432
|
+
*
|
|
433
|
+
* @example
|
|
434
|
+
* The following example illustrates use of the `m3e-paginator`. In this example, there are 300 total
|
|
435
|
+
* records and the first/last navigation controls are shown.
|
|
436
|
+
* ```html
|
|
437
|
+
* <m3e-paginator show-first-last-buttons length="300"></m3e-paginator>
|
|
438
|
+
* ```
|
|
439
|
+
*
|
|
440
|
+
* @tag m3e-paginator
|
|
441
|
+
*
|
|
442
|
+
* @slot first-page-icon - Slot for a custom first-page icon.
|
|
443
|
+
* @slot previous-page-icon - Slot for a custom previous-page icon.
|
|
444
|
+
* @slot next-page-icon - Slot for a custom next-page icon.
|
|
445
|
+
* @slot last-page-icon - Slot for a custom last-page icon.
|
|
446
|
+
*
|
|
447
|
+
* @attr disabled - Whether the element is disabled.
|
|
448
|
+
* @attr first-page-label - The accessible label given to the button used to move to the first page.
|
|
449
|
+
* @attr hide-page-size - Whether to hide page size selection.
|
|
450
|
+
* @attr items-per-page-label - The label for the page size selector.
|
|
451
|
+
* @attr last-page-label - The accessible label given to the button used to move to the last page.
|
|
452
|
+
* @attr length - The length of the total number of items which are being paginated.
|
|
453
|
+
* @attr next-page-label - The accessible label given to the button used to move to the next page.
|
|
454
|
+
* @attr page-index - The zero-based page index of the displayed list of items.
|
|
455
|
+
* @attr page-size - The number of items to display in a page.
|
|
456
|
+
* @attr page-sizes - A comma separated list of available page sizes.
|
|
457
|
+
* @attr page-size-variant - The appearance variant of the page size field.
|
|
458
|
+
* @attr previous-page-label - The accessible label given to the button used to move to the previous page.
|
|
459
|
+
* @attr show-first-last-buttons - Whether to show first/last buttons.
|
|
460
|
+
*
|
|
461
|
+
* @fires page - Emitted when a user selects a different page size or navigates to another page.
|
|
462
|
+
*
|
|
463
|
+
* @cssprop --m3e-paginator-font-size - The font size used for paginator text.
|
|
464
|
+
* @cssprop --m3e-paginator-font-weight - The font weight used for paginator text.
|
|
465
|
+
* @cssprop --m3e-paginator-line-height - The line height used for paginator text.
|
|
466
|
+
* @cssprop --m3e-paginator-tracking - The letter-spacing used for paginator text.
|
|
467
|
+
*
|
|
468
|
+
*/
|
|
469
|
+
let M3ePaginatorElement = M3ePaginatorElement_1 = class M3ePaginatorElement extends EventAttribute(Role(LitElement, "group"), "page") {
|
|
470
|
+
constructor() {
|
|
471
|
+
super(...arguments);
|
|
472
|
+
_M3ePaginatorElement_instances.add(this);
|
|
473
|
+
/* @private */
|
|
474
|
+
_M3ePaginatorElement_pageSizeLabelId.set(this, `m3e-paginator-page-size-label-${M3ePaginatorElement_1.__nextId++}`);
|
|
475
|
+
/* @private */
|
|
476
|
+
_M3ePaginatorElement_defaultRangeLabelFormatter.set(this, (pageIndex, pageSize, length) => {
|
|
477
|
+
length = Math.max(length, 0);
|
|
478
|
+
if (pageSize === "all") return "";
|
|
479
|
+
if (length === 0 || pageSize <= 0) return `0 of ${length}`;
|
|
480
|
+
const startIndex = pageIndex * pageSize;
|
|
481
|
+
const endIndex = startIndex < length ? Math.min(startIndex + pageSize, length) : startIndex + pageSize;
|
|
482
|
+
return `${startIndex + 1} - ${endIndex} of ${length}`;
|
|
483
|
+
});
|
|
484
|
+
/**
|
|
485
|
+
* Whether the element is disabled.
|
|
486
|
+
* @default false
|
|
487
|
+
*/
|
|
488
|
+
this.disabled = false;
|
|
489
|
+
/**
|
|
490
|
+
* The zero-based page index of the displayed list of items.
|
|
491
|
+
* @default 0
|
|
492
|
+
*/
|
|
493
|
+
this.pageIndex = 0;
|
|
494
|
+
/**
|
|
495
|
+
* The length of the total number of items which are being paginated.
|
|
496
|
+
* @default 0
|
|
497
|
+
*/
|
|
498
|
+
this.length = 0;
|
|
499
|
+
/**
|
|
500
|
+
* The number of items to display in a page.
|
|
501
|
+
* @default 50
|
|
502
|
+
*/
|
|
503
|
+
this.pageSize = 50;
|
|
504
|
+
/**
|
|
505
|
+
* A comma separated list of available page sizes.
|
|
506
|
+
* @default "5,10,25,50,100"
|
|
507
|
+
*/
|
|
508
|
+
this.pageSizes = "5,10,25,50,100";
|
|
509
|
+
/**
|
|
510
|
+
* Whether to hide page size selection.
|
|
511
|
+
* @default false
|
|
512
|
+
*/
|
|
513
|
+
this.hidePageSize = false;
|
|
514
|
+
/**
|
|
515
|
+
* Whether to show first/last buttons.
|
|
516
|
+
* @default false
|
|
517
|
+
*/
|
|
518
|
+
this.showFirstLastButtons = false;
|
|
519
|
+
/**
|
|
520
|
+
* The label for the page size selector.
|
|
521
|
+
* @default "Items per page:"
|
|
522
|
+
*/
|
|
523
|
+
this.itemsPerPageLabel = "Items per page:";
|
|
524
|
+
/**
|
|
525
|
+
* The accessible label given to the button used to move to the previous page.
|
|
526
|
+
* @default "Previous page"
|
|
527
|
+
*/
|
|
528
|
+
this.previousPageLabel = "Previous page";
|
|
529
|
+
/**
|
|
530
|
+
* The accessible label given to the button used to move to the next page.
|
|
531
|
+
* @default "Next page"
|
|
532
|
+
*/
|
|
533
|
+
this.nextPageLabel = "Next page";
|
|
534
|
+
/**
|
|
535
|
+
* The accessible label given to the button used to move to the first page.
|
|
536
|
+
* @default "First page"
|
|
537
|
+
*/
|
|
538
|
+
this.firstPageLabel = "First page";
|
|
539
|
+
/**
|
|
540
|
+
* The accessible label given to the button used to move to the last page.
|
|
541
|
+
* @default "Last page"
|
|
542
|
+
*/
|
|
543
|
+
this.lastPageLabel = "Last page";
|
|
544
|
+
/**
|
|
545
|
+
* The appearance variant of the page size field.
|
|
546
|
+
* @default "outlined"
|
|
547
|
+
*/
|
|
548
|
+
this.pageSizeVariant = "outlined";
|
|
549
|
+
}
|
|
550
|
+
/** The total number of pages. */
|
|
551
|
+
get pageCount() {
|
|
552
|
+
return !this.pageSize || this.pageSize === "all" ? 0 : Math.ceil(this.length / this.pageSize);
|
|
553
|
+
}
|
|
554
|
+
/** Whether a previous page can be displayed. */
|
|
555
|
+
get hasPreviousPage() {
|
|
556
|
+
return this.pageSize !== "all" && this.pageSize > 0 && this.pageIndex >= 1;
|
|
557
|
+
}
|
|
558
|
+
/** Whether a next page can be displayed. */
|
|
559
|
+
get hasNextPage() {
|
|
560
|
+
return this.pageSize !== "all" && this.pageSize > 0 && this.pageIndex < this.pageCount - 1;
|
|
561
|
+
}
|
|
562
|
+
/** Move to the first page. */
|
|
563
|
+
firstPage() {
|
|
564
|
+
if (this.hasPreviousPage) {
|
|
565
|
+
const previousPageIndex = this.pageIndex;
|
|
566
|
+
this.pageIndex = 0;
|
|
567
|
+
__classPrivateFieldGet(this, _M3ePaginatorElement_instances, "m", _M3ePaginatorElement_emitPageEvent).call(this, previousPageIndex);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
/** Move to the previous page. */
|
|
571
|
+
previousPage() {
|
|
572
|
+
if (this.hasPreviousPage) {
|
|
573
|
+
const previousPageIndex = this.pageIndex;
|
|
574
|
+
this.pageIndex--;
|
|
575
|
+
__classPrivateFieldGet(this, _M3ePaginatorElement_instances, "m", _M3ePaginatorElement_emitPageEvent).call(this, previousPageIndex);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
/** Move to the next page. */
|
|
579
|
+
nextPage() {
|
|
580
|
+
if (this.hasNextPage) {
|
|
581
|
+
const previousPageIndex = this.pageIndex;
|
|
582
|
+
this.pageIndex++;
|
|
583
|
+
__classPrivateFieldGet(this, _M3ePaginatorElement_instances, "m", _M3ePaginatorElement_emitPageEvent).call(this, previousPageIndex);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
/** Move to the last page. */
|
|
587
|
+
lastPage() {
|
|
588
|
+
if (this.hasNextPage) {
|
|
589
|
+
const previousPageIndex = this.pageIndex;
|
|
590
|
+
this.pageIndex = this.pageCount - 1;
|
|
591
|
+
__classPrivateFieldGet(this, _M3ePaginatorElement_instances, "m", _M3ePaginatorElement_emitPageEvent).call(this, previousPageIndex);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
/** @inheritdoc */
|
|
595
|
+
render() {
|
|
596
|
+
return html`<div class="outer"><div class="inner">${__classPrivateFieldGet(this, _M3ePaginatorElement_instances, "m", _M3ePaginatorElement_renderPageSize).call(this)} ${__classPrivateFieldGet(this, _M3ePaginatorElement_instances, "m", _M3ePaginatorElement_renderRangeActions).call(this)}</div></div>`;
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
_M3ePaginatorElement_pageSizeLabelId = new WeakMap();
|
|
600
|
+
_M3ePaginatorElement_defaultRangeLabelFormatter = new WeakMap();
|
|
601
|
+
_M3ePaginatorElement_instances = new WeakSet();
|
|
602
|
+
_M3ePaginatorElement_renderPageSize = function _M3ePaginatorElement_renderPageSize() {
|
|
603
|
+
const sizes = __classPrivateFieldGet(this, _M3ePaginatorElement_instances, "m", _M3ePaginatorElement_parsePageSizes).call(this);
|
|
604
|
+
return this.hidePageSize ? nothing : html`<div id="${__classPrivateFieldGet(this, _M3ePaginatorElement_pageSizeLabelId, "f")}" class="items-per-page-label" aria-live="polite">${this.itemsPerPageLabel}</div><m3e-form-field class="form-field" variant="${this.pageSizeVariant}" hide-subscript="always"><m3e-select class="select" aria-labelledby="${__classPrivateFieldGet(this, _M3ePaginatorElement_pageSizeLabelId, "f")}" hide-selection-indicator ?disabled="${this.disabled || sizes.length <= 1}" @change="${__classPrivateFieldGet(this, _M3ePaginatorElement_instances, "m", _M3ePaginatorElement_handleSelectChange)}">${sizes.map(x => html`<m3e-option value="${x}" ?selected="${x === this.pageSize}">${x === "all" ? "All" : x}</m3e-option>`)}</m3e-select></m3e-form-field>`;
|
|
605
|
+
};
|
|
606
|
+
_M3ePaginatorElement_parsePageSizes = function _M3ePaginatorElement_parsePageSizes() {
|
|
607
|
+
const sizes = this.pageSizes.split(",").map(x => x.trim()).filter(x => x !== "").map(x => x === "all" ? x : Number(x));
|
|
608
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
609
|
+
const numericSizes = sizes.filter(x => x !== "all");
|
|
610
|
+
if (this.pageSize !== "all" && numericSizes.indexOf(this.pageSize) === -1) {
|
|
611
|
+
numericSizes.push(this.pageSize);
|
|
612
|
+
}
|
|
613
|
+
numericSizes.sort((a, b) => a - b);
|
|
614
|
+
return sizes.some(x => x === "all") ? [...numericSizes, "all"] : numericSizes;
|
|
615
|
+
};
|
|
616
|
+
_M3ePaginatorElement_renderRangeActions = function _M3ePaginatorElement_renderRangeActions() {
|
|
617
|
+
const rangeLabelFormatter = this.rangeLabelFormatter ?? __classPrivateFieldGet(this, _M3ePaginatorElement_defaultRangeLabelFormatter, "f");
|
|
618
|
+
return this.pageSize === "all" ? nothing : html`<div class="range-actions"><div class="range-label">${rangeLabelFormatter(this.pageIndex, this.pageSize, this.length)}</div>${!this.showFirstLastButtons ? nothing : html`<m3e-icon-button id="firstPageButton" aria-label="${this.firstPageLabel}" ?disabled="${this.disabled || !this.hasPreviousPage}" @click="${this.firstPage}"><slot name="first-page-icon"><svg viewBox="0 -960 960 960" fill="currentColor"><path d="M240-240v-480h80v480h-80Zm440 0L440-480l240-240 56 56-184 184 184 184-56 56Z"/></svg></slot></m3e-icon-button><m3e-tooltip for="firstPageButton" position="above">${this.firstPageLabel}</m3e-tooltip>`}<m3e-icon-button id="previousPageButton" aria-label="${this.previousPageLabel}" ?disabled="${this.disabled || !this.hasPreviousPage}" @click="${this.previousPage}"><slot name="previous-page-icon"><svg viewBox="0 -960 960 960" fill="currentColor"><path d="M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z"/></svg></slot></m3e-icon-button><m3e-tooltip for="previousPageButton" position="above">${this.previousPageLabel}</m3e-tooltip><m3e-icon-button id="nextPageButton" aria-label="${this.nextPageLabel}" ?disabled="${this.disabled || !this.hasNextPage}" @click="${this.nextPage}"><slot name="next-page-icon"><svg viewBox="0 -960 960 960" fill="currentColor"><path d="M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"/></svg></slot></m3e-icon-button><m3e-tooltip for="nextPageButton" position="above">${this.nextPageLabel}</m3e-tooltip>${!this.showFirstLastButtons ? nothing : html`<m3e-icon-button id="lastPageButton" aria-label="${this.lastPageLabel}" ?disabled="${this.disabled || !this.hasNextPage}" @click="${this.lastPage}"><slot name="last-page-icon"><svg viewBox="0 -960 960 960" fill="currentColor"><path d="m280-240-56-56 184-184-184-184 56-56 240 240-240 240Zm360 0v-480h80v480h-80Z"/></svg></slot></m3e-icon-button><m3e-tooltip for="lastPageButton" position="above">${this.lastPageLabel}</m3e-tooltip>`}</div>`;
|
|
619
|
+
};
|
|
620
|
+
_M3ePaginatorElement_handleSelectChange = function _M3ePaginatorElement_handleSelectChange(e) {
|
|
621
|
+
const option = e.target?.selected[0];
|
|
622
|
+
if (!option) return;
|
|
623
|
+
const pageSize = option.value === "all" ? "all" : Number(option.value);
|
|
624
|
+
if (pageSize !== this.pageSize) {
|
|
625
|
+
const previousPageIndex = this.pageIndex;
|
|
626
|
+
this.pageIndex = 0;
|
|
627
|
+
this.pageSize = pageSize;
|
|
628
|
+
__classPrivateFieldGet(this, _M3ePaginatorElement_instances, "m", _M3ePaginatorElement_emitPageEvent).call(this, previousPageIndex);
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
_M3ePaginatorElement_emitPageEvent = function _M3ePaginatorElement_emitPageEvent(previousPageIndex) {
|
|
632
|
+
this.dispatchEvent(new CustomEvent("page", {
|
|
633
|
+
detail: {
|
|
634
|
+
previousPageIndex: previousPageIndex,
|
|
635
|
+
pageIndex: this.pageIndex,
|
|
636
|
+
pageSize: this.pageSize,
|
|
637
|
+
length: this.length
|
|
638
|
+
}
|
|
639
|
+
}));
|
|
640
|
+
};
|
|
641
|
+
/** The styles of the element. */
|
|
642
|
+
M3ePaginatorElement.styles = css`:host { display: block; } .outer { display: flex; font-size: var(--m3e-paginator-font-size, ${DesignToken.typescale.standard.body.small.fontSize}); font-weight: var(--m3e-paginator-font-weight, ${DesignToken.typescale.standard.body.small.fontWeight}); line-height: var(--m3e-paginator-line-height, ${DesignToken.typescale.standard.body.small.lineHeight}); letter-spacing: var(--m3e-paginator-tracking, ${DesignToken.typescale.standard.body.small.tracking}); } .inner { display: flex; align-items: center; justify-content: flex-end; padding-inline: 0.5rem; width: 100%; } .form-field { --md-sys-density-scale: -2; --m3e-form-field-font-size: var(--m3e-paginator-font-size, ${DesignToken.typescale.standard.body.small.fontSize}); --m3e-form-field-font-weight: var( --m3e-paginator-font-weight, ${DesignToken.typescale.standard.body.small.fontWeight} ); --m3e-form-field-line-height: var( --m3e-paginator-line-height, ${DesignToken.typescale.standard.body.small.lineHeight} ); --m3e-form-field-tracking: var(--m3e-paginator-tracking, ${DesignToken.typescale.standard.body.small.tracking}); } .items-per-page-label { display: flex; align-items: center; margin-inline-end: 0.5rem; } .form-field { min-width: auto; width: 6rem; margin-inline: 0.25rem; } .range-label { margin-inline: 1.5rem 2rem; } :host([hide-page-size]) .range-label { margin-inline-start: unset; } .range-actions { display: flex; align-items: center; } ::slotted([slot="first-page-icon"]), ::slotted([slot="previous-page-icon"]), ::slotted([slot="next-page-icon"]), ::slotted([slot="last-page-icon"]), svg { width: 1em; font-size: var(--m3e-icon-button-medium-icon-size, 1.5rem) !important; }`;
|
|
643
|
+
/* @private */
|
|
644
|
+
M3ePaginatorElement.__nextId = 0;
|
|
645
|
+
__decorate([n({
|
|
646
|
+
type: Boolean,
|
|
647
|
+
reflect: true
|
|
648
|
+
})], M3ePaginatorElement.prototype, "disabled", void 0);
|
|
649
|
+
__decorate([n({
|
|
650
|
+
attribute: "page-index",
|
|
651
|
+
type: Number
|
|
652
|
+
})], M3ePaginatorElement.prototype, "pageIndex", void 0);
|
|
653
|
+
__decorate([n({
|
|
654
|
+
type: Number
|
|
655
|
+
})], M3ePaginatorElement.prototype, "length", void 0);
|
|
656
|
+
__decorate([n({
|
|
657
|
+
attribute: "page-size",
|
|
658
|
+
converter: value => value === "all" ? "all" : Number(value)
|
|
659
|
+
})], M3ePaginatorElement.prototype, "pageSize", void 0);
|
|
660
|
+
__decorate([n({
|
|
661
|
+
attribute: "page-sizes"
|
|
662
|
+
})], M3ePaginatorElement.prototype, "pageSizes", void 0);
|
|
663
|
+
__decorate([n({
|
|
664
|
+
attribute: "hide-page-size",
|
|
665
|
+
type: Boolean,
|
|
666
|
+
reflect: true
|
|
667
|
+
})], M3ePaginatorElement.prototype, "hidePageSize", void 0);
|
|
668
|
+
__decorate([n({
|
|
669
|
+
attribute: "show-first-last-buttons",
|
|
670
|
+
type: Boolean
|
|
671
|
+
})], M3ePaginatorElement.prototype, "showFirstLastButtons", void 0);
|
|
672
|
+
__decorate([n({
|
|
673
|
+
attribute: "items-per-page-label"
|
|
674
|
+
})], M3ePaginatorElement.prototype, "itemsPerPageLabel", void 0);
|
|
675
|
+
__decorate([n({
|
|
676
|
+
attribute: "previous-page-label"
|
|
677
|
+
})], M3ePaginatorElement.prototype, "previousPageLabel", void 0);
|
|
678
|
+
__decorate([n({
|
|
679
|
+
attribute: "next-page-label"
|
|
680
|
+
})], M3ePaginatorElement.prototype, "nextPageLabel", void 0);
|
|
681
|
+
__decorate([n({
|
|
682
|
+
attribute: "first-page-label"
|
|
683
|
+
})], M3ePaginatorElement.prototype, "firstPageLabel", void 0);
|
|
684
|
+
__decorate([n({
|
|
685
|
+
attribute: "last-page-label"
|
|
686
|
+
})], M3ePaginatorElement.prototype, "lastPageLabel", void 0);
|
|
687
|
+
__decorate([n({
|
|
688
|
+
attribute: "page-size-variant"
|
|
689
|
+
})], M3ePaginatorElement.prototype, "pageSizeVariant", void 0);
|
|
690
|
+
M3ePaginatorElement = M3ePaginatorElement_1 = __decorate([t$1("m3e-paginator")], M3ePaginatorElement);
|
|
691
|
+
|
|
692
|
+
export { M3ePaginatorElement };
|
|
693
|
+
//# sourceMappingURL=index.js.map
|