@rozie-ui/pagination-lit 0.0.0-stage → 0.1.8
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 +34 -0
- package/LICENSE +21 -0
- package/README.md +88 -2
- package/custom-elements.json +264 -0
- package/dist/index.cjs +540 -0
- package/dist/index.d.cts +181 -0
- package/dist/index.d.mts +181 -0
- package/dist/index.mjs +535 -0
- package/package.json +73 -3
- package/src/Pagination.ts +472 -0
- package/src/index.ts +4 -0
- package/src/internal/paginationItems.ts +137 -0
- package/src/themes/base.css +74 -0
- package/src/themes/bootstrap.css +46 -0
- package/src/themes/material.css +44 -0
- package/src/themes/shadcn.css +48 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
let lit = require("lit");
|
|
6
|
+
let lit_decorators_js = require("lit/decorators.js");
|
|
7
|
+
let _lit_labs_preact_signals = require("@lit-labs/preact-signals");
|
|
8
|
+
let _rozie_runtime_lit = require("@rozie/runtime-lit");
|
|
9
|
+
let lit_directives_repeat_js = require("lit/directives/repeat.js");
|
|
10
|
+
//#region src/internal/paginationItems.ts
|
|
11
|
+
/** Inclusive integer range [start, end]; empty when start > end. */
|
|
12
|
+
function range(start, end) {
|
|
13
|
+
const out = [];
|
|
14
|
+
for (let i = start; i <= end; i++) out.push(i);
|
|
15
|
+
return out;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Resolve the effective total page count from either an explicit `totalPages`
|
|
19
|
+
* or `ceil(total / pageSize)`. Always at least 1 (an empty data set still has a
|
|
20
|
+
* single page).
|
|
21
|
+
*/
|
|
22
|
+
function resolveTotalPages(input) {
|
|
23
|
+
const tp = input.totalPages;
|
|
24
|
+
if (typeof tp === "number" && tp > 0) return Math.max(1, Math.floor(tp));
|
|
25
|
+
const total = typeof input.total === "number" ? input.total : 0;
|
|
26
|
+
const size = typeof input.pageSize === "number" && input.pageSize > 0 ? input.pageSize : 0;
|
|
27
|
+
if (total > 0 && size > 0) return Math.max(1, Math.ceil(total / size));
|
|
28
|
+
return 1;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Build the windowed page-item model. Pure: no clamping side effects, no DOM.
|
|
32
|
+
*
|
|
33
|
+
* Algorithm (MUI usePagination semantics):
|
|
34
|
+
* - `startPages` = first `boundaryCount` pages; `endPages` = last
|
|
35
|
+
* `boundaryCount` pages.
|
|
36
|
+
* - a sibling window of `siblingCount` pages on each side of `page`, kept
|
|
37
|
+
* clear of the boundary blocks.
|
|
38
|
+
* - an `'ellipsis'` collapses a gap of 2+ pages; a gap of exactly one page is
|
|
39
|
+
* rendered as that single bridging page (never a 1-page ellipsis).
|
|
40
|
+
*/
|
|
41
|
+
function paginationItems(input) {
|
|
42
|
+
const totalPages = resolveTotalPages(input);
|
|
43
|
+
const rawPage = typeof input.page === "number" && Number.isFinite(input.page) ? Math.floor(input.page) : 1;
|
|
44
|
+
const page = Math.min(Math.max(rawPage, 1), totalPages);
|
|
45
|
+
const siblingCount = Math.max(0, Math.floor(input.siblingCount ?? 1));
|
|
46
|
+
const boundaryCount = Math.max(0, Math.floor(input.boundaryCount ?? 1));
|
|
47
|
+
const startPages = range(1, Math.min(boundaryCount, totalPages));
|
|
48
|
+
const endPages = range(Math.max(totalPages - boundaryCount + 1, boundaryCount + 1), totalPages);
|
|
49
|
+
const siblingsStart = Math.max(Math.min(page - siblingCount, totalPages - boundaryCount - siblingCount * 2 - 1), boundaryCount + 2);
|
|
50
|
+
const endPagesFirst = endPages[0];
|
|
51
|
+
const siblingsEnd = Math.min(Math.max(page + siblingCount, boundaryCount + siblingCount * 2 + 2), endPagesFirst !== void 0 ? endPagesFirst - 2 : totalPages - 1);
|
|
52
|
+
const pages = [];
|
|
53
|
+
pages.push(...startPages);
|
|
54
|
+
if (siblingsStart > boundaryCount + 2) pages.push("ellipsis");
|
|
55
|
+
else if (boundaryCount + 1 < totalPages - boundaryCount) pages.push(boundaryCount + 1);
|
|
56
|
+
pages.push(...range(siblingsStart, siblingsEnd));
|
|
57
|
+
if (siblingsEnd < totalPages - boundaryCount - 1) pages.push("ellipsis");
|
|
58
|
+
else if (totalPages - boundaryCount > boundaryCount) pages.push(totalPages - boundaryCount);
|
|
59
|
+
pages.push(...endPages);
|
|
60
|
+
return {
|
|
61
|
+
totalPages,
|
|
62
|
+
page,
|
|
63
|
+
pages,
|
|
64
|
+
hasPrev: page > 1,
|
|
65
|
+
hasNext: page < totalPages
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region \0@oxc-project+runtime@0.127.0/helpers/decorate.js
|
|
70
|
+
function __decorate(decorators, target, key, desc) {
|
|
71
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
72
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
73
|
+
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;
|
|
74
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/Pagination.ts
|
|
78
|
+
let Pagination = class Pagination extends (0, _lit_labs_preact_signals.SignalWatcher)(lit.LitElement) {
|
|
79
|
+
constructor(..._args) {
|
|
80
|
+
super(..._args);
|
|
81
|
+
this._modelValue_attr = 1;
|
|
82
|
+
this._modelValueControllable = (0, _rozie_runtime_lit.createLitControllableProperty)({
|
|
83
|
+
host: this,
|
|
84
|
+
eventName: "model-value-change",
|
|
85
|
+
defaultValue: 1,
|
|
86
|
+
initialControlledValue: void 0
|
|
87
|
+
});
|
|
88
|
+
this.totalPages = null;
|
|
89
|
+
this.total = null;
|
|
90
|
+
this.pageSize = null;
|
|
91
|
+
this.siblingCount = 1;
|
|
92
|
+
this.boundaryCount = 1;
|
|
93
|
+
this.disabled = false;
|
|
94
|
+
this.ariaLabel = "Pagination";
|
|
95
|
+
this._rozieSlotDistributor = new _rozie_runtime_lit.RozieSlotDistributor(this);
|
|
96
|
+
this._hasSlotPrevControl = false;
|
|
97
|
+
this._hasSlotEllipsis = false;
|
|
98
|
+
this._hasSlotItem = false;
|
|
99
|
+
this._hasSlotNextControl = false;
|
|
100
|
+
this._disconnectCleanups = [];
|
|
101
|
+
this._rozieTornDown = false;
|
|
102
|
+
this.model = () => paginationItems({
|
|
103
|
+
page: this.modelValue,
|
|
104
|
+
totalPages: this.totalPages,
|
|
105
|
+
total: this.total,
|
|
106
|
+
pageSize: this.pageSize,
|
|
107
|
+
siblingCount: this.siblingCount,
|
|
108
|
+
boundaryCount: this.boundaryCount
|
|
109
|
+
});
|
|
110
|
+
this.effectivePages = () => this.model().totalPages;
|
|
111
|
+
this.currentPage = () => this.model().page;
|
|
112
|
+
this.canPrev = () => this.model().hasPrev;
|
|
113
|
+
this.canNext = () => this.model().hasNext;
|
|
114
|
+
this.isActive = (page) => page === this.currentPage();
|
|
115
|
+
this.tabIndexFor = (active) => active ? 0 : -1;
|
|
116
|
+
this.goToPage = (page) => {
|
|
117
|
+
if (this.disabled) return;
|
|
118
|
+
const tp = this.effectivePages();
|
|
119
|
+
let target = typeof page === "number" ? Math.floor(page) : 1;
|
|
120
|
+
if (target < 1) target = 1;
|
|
121
|
+
if (target > tp) target = tp;
|
|
122
|
+
if (target === this.currentPage()) return;
|
|
123
|
+
this._modelValueControllable.write(target);
|
|
124
|
+
this.dispatchEvent(new CustomEvent("change", {
|
|
125
|
+
detail: { page: target },
|
|
126
|
+
bubbles: true,
|
|
127
|
+
composed: true
|
|
128
|
+
}));
|
|
129
|
+
};
|
|
130
|
+
this.goNext = () => {
|
|
131
|
+
if (this.canNext()) this.goToPage(this.currentPage() + 1);
|
|
132
|
+
};
|
|
133
|
+
this.goPrev = () => {
|
|
134
|
+
if (this.canPrev()) this.goToPage(this.currentPage() - 1);
|
|
135
|
+
};
|
|
136
|
+
this.goFirst = () => this.goToPage(1);
|
|
137
|
+
this.goLast = () => this.goToPage(this.effectivePages());
|
|
138
|
+
this.controls = () => {
|
|
139
|
+
const nav = this._refNav;
|
|
140
|
+
if (!nav) return [];
|
|
141
|
+
return Array.from(nav.querySelectorAll("[data-page-control]"));
|
|
142
|
+
};
|
|
143
|
+
this.focusControlAt = (idx) => {
|
|
144
|
+
const els = this.controls();
|
|
145
|
+
if (els.length === 0) return;
|
|
146
|
+
let i = idx;
|
|
147
|
+
if (i < 0) i = 0;
|
|
148
|
+
if (i >= els.length) i = els.length - 1;
|
|
149
|
+
const el = els[i];
|
|
150
|
+
if (el && el.focus) el.focus();
|
|
151
|
+
};
|
|
152
|
+
this.focusedIndex = () => {
|
|
153
|
+
const els = this.controls();
|
|
154
|
+
const nav = this._refNav;
|
|
155
|
+
const root = nav ? nav.getRootNode() : null;
|
|
156
|
+
const active = root ? root.activeElement : null;
|
|
157
|
+
return els.indexOf(active);
|
|
158
|
+
};
|
|
159
|
+
this.onControlKeydown = ($event) => {
|
|
160
|
+
if (this.disabled) return;
|
|
161
|
+
const key = $event.key;
|
|
162
|
+
const cur = this.focusedIndex();
|
|
163
|
+
if (key === "ArrowRight" || key === "ArrowDown") {
|
|
164
|
+
$event.preventDefault();
|
|
165
|
+
this.focusControlAt(cur + 1);
|
|
166
|
+
} else if (key === "ArrowLeft" || key === "ArrowUp") {
|
|
167
|
+
$event.preventDefault();
|
|
168
|
+
this.focusControlAt(cur - 1);
|
|
169
|
+
} else if (key === "Home") {
|
|
170
|
+
$event.preventDefault();
|
|
171
|
+
this.focusControlAt(0);
|
|
172
|
+
} else if (key === "End") {
|
|
173
|
+
$event.preventDefault();
|
|
174
|
+
this.focusControlAt(this.controls().length - 1);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
this.goto = (page) => this.goToPage(page);
|
|
178
|
+
this.next = () => this.goNext();
|
|
179
|
+
this.prev = () => this.goPrev();
|
|
180
|
+
this.first = () => this.goFirst();
|
|
181
|
+
this.last = () => this.goLast();
|
|
182
|
+
}
|
|
183
|
+
static {
|
|
184
|
+
this.shadowRootOptions = {
|
|
185
|
+
...lit.LitElement.shadowRootOptions,
|
|
186
|
+
slotAssignment: "manual"
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
static {
|
|
190
|
+
this.styles = lit.css`
|
|
191
|
+
:host{display:contents}
|
|
192
|
+
.rozie-pagination[data-rozie-s-de247ae2] {
|
|
193
|
+
display: inline-flex;
|
|
194
|
+
align-items: center;
|
|
195
|
+
gap: var(--rozie-pagination-gap, var(--rpg-gap, 0.25rem));
|
|
196
|
+
font: var(--rozie-pagination-font, inherit);
|
|
197
|
+
}
|
|
198
|
+
.rozie-pagination-page[data-rozie-s-de247ae2],
|
|
199
|
+
.rozie-pagination-control[data-rozie-s-de247ae2] {
|
|
200
|
+
box-sizing: border-box;
|
|
201
|
+
min-width: var(--rozie-pagination-size, var(--rpg-size, 2.25rem));
|
|
202
|
+
height: var(--rozie-pagination-size, var(--rpg-size, 2.25rem));
|
|
203
|
+
padding: 0 var(--rozie-pagination-padding-x, var(--rpg-padding-x, 0.5rem));
|
|
204
|
+
display: inline-flex;
|
|
205
|
+
align-items: center;
|
|
206
|
+
justify-content: center;
|
|
207
|
+
font: inherit;
|
|
208
|
+
font-weight: var(--rozie-pagination-font-weight, var(--rpg-font-weight, 500));
|
|
209
|
+
color: var(--rozie-pagination-fg, var(--rpg-fg, #1a1a1a));
|
|
210
|
+
background: var(--rozie-pagination-bg, var(--rpg-bg, transparent));
|
|
211
|
+
border: var(--rozie-pagination-border-width, var(--rpg-border-width, 1px)) solid var(--rozie-pagination-border, var(--rpg-border, rgba(0, 0, 0, 0.18)));
|
|
212
|
+
border-radius: var(--rozie-pagination-radius, var(--rpg-radius, 6px));
|
|
213
|
+
cursor: pointer;
|
|
214
|
+
user-select: none;
|
|
215
|
+
transition: background 0.12s, border-color 0.12s, color 0.12s;
|
|
216
|
+
}
|
|
217
|
+
.rozie-pagination-page[data-rozie-s-de247ae2]:hover,
|
|
218
|
+
.rozie-pagination-control[data-rozie-s-de247ae2]:hover {
|
|
219
|
+
background: var(--rozie-pagination-hover-bg, var(--rpg-hover-bg, rgba(0, 0, 0, 0.05)));
|
|
220
|
+
border-color: var(--rozie-pagination-hover-border, var(--rpg-hover-border, rgba(0, 0, 0, 0.28)));
|
|
221
|
+
}
|
|
222
|
+
.rozie-pagination-page[data-rozie-s-de247ae2]:focus-visible,
|
|
223
|
+
.rozie-pagination-control[data-rozie-s-de247ae2]:focus-visible {
|
|
224
|
+
outline: var(--rozie-pagination-ring-width, var(--rpg-ring-width, 2px)) solid var(--rozie-pagination-ring, var(--rozie-pagination-accent, var(--rpg-ring, var(--rpg-accent, #0066cc))));
|
|
225
|
+
outline-offset: var(--rozie-pagination-ring-offset, var(--rpg-ring-offset, 1px));
|
|
226
|
+
}
|
|
227
|
+
.rozie-pagination-page.is-active[data-rozie-s-de247ae2] {
|
|
228
|
+
color: var(--rozie-pagination-active-fg, var(--rpg-active-fg, #fff));
|
|
229
|
+
background: var(--rozie-pagination-active-bg, var(--rozie-pagination-accent, var(--rpg-active-bg, var(--rpg-accent, #0066cc))));
|
|
230
|
+
border-color: var(--rozie-pagination-active-border, var(--rozie-pagination-accent, var(--rpg-active-border, var(--rpg-accent, #0066cc))));
|
|
231
|
+
}
|
|
232
|
+
.rozie-pagination-page[data-rozie-s-de247ae2]:disabled,
|
|
233
|
+
.rozie-pagination-control[data-rozie-s-de247ae2]:disabled {
|
|
234
|
+
cursor: not-allowed;
|
|
235
|
+
opacity: var(--rozie-pagination-disabled-opacity, var(--rpg-disabled-opacity, 0.5));
|
|
236
|
+
pointer-events: none;
|
|
237
|
+
}
|
|
238
|
+
.rozie-pagination--disabled[data-rozie-s-de247ae2] {
|
|
239
|
+
opacity: var(--rozie-pagination-disabled-opacity, var(--rpg-disabled-opacity, 0.5));
|
|
240
|
+
pointer-events: none;
|
|
241
|
+
}
|
|
242
|
+
.rozie-pagination-ellipsis[data-rozie-s-de247ae2] {
|
|
243
|
+
min-width: var(--rozie-pagination-size, var(--rpg-size, 2.25rem));
|
|
244
|
+
height: var(--rozie-pagination-size, var(--rpg-size, 2.25rem));
|
|
245
|
+
display: inline-flex;
|
|
246
|
+
align-items: center;
|
|
247
|
+
justify-content: center;
|
|
248
|
+
color: var(--rozie-pagination-ellipsis-fg, var(--rpg-ellipsis-fg, rgba(0, 0, 0, 0.5)));
|
|
249
|
+
user-select: none;
|
|
250
|
+
}
|
|
251
|
+
`;
|
|
252
|
+
}
|
|
253
|
+
_armListeners() {
|
|
254
|
+
{
|
|
255
|
+
const slotEl = this.shadowRoot?.querySelector("slot[name=\"prevControl\"]");
|
|
256
|
+
if (slotEl !== null && slotEl !== void 0) {
|
|
257
|
+
const update = () => {
|
|
258
|
+
this._hasSlotPrevControl = this._slotPrevControlElements.length > 0;
|
|
259
|
+
};
|
|
260
|
+
slotEl.addEventListener("slotchange", update);
|
|
261
|
+
this._disconnectCleanups.push(() => slotEl.removeEventListener("slotchange", update));
|
|
262
|
+
update();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
{
|
|
266
|
+
const slotEl = this.shadowRoot?.querySelector("slot[name=\"ellipsis\"]");
|
|
267
|
+
if (slotEl !== null && slotEl !== void 0) {
|
|
268
|
+
const update = () => {
|
|
269
|
+
this._hasSlotEllipsis = this._slotEllipsisElements.length > 0;
|
|
270
|
+
};
|
|
271
|
+
slotEl.addEventListener("slotchange", update);
|
|
272
|
+
this._disconnectCleanups.push(() => slotEl.removeEventListener("slotchange", update));
|
|
273
|
+
update();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
{
|
|
277
|
+
const slotEl = this.shadowRoot?.querySelector("slot[name=\"item\"]");
|
|
278
|
+
if (slotEl !== null && slotEl !== void 0) {
|
|
279
|
+
const update = () => {
|
|
280
|
+
this._hasSlotItem = this._slotItemElements.length > 0;
|
|
281
|
+
};
|
|
282
|
+
slotEl.addEventListener("slotchange", update);
|
|
283
|
+
this._disconnectCleanups.push(() => slotEl.removeEventListener("slotchange", update));
|
|
284
|
+
update();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
{
|
|
288
|
+
const slotEl = this.shadowRoot?.querySelector("slot[name=\"nextControl\"]");
|
|
289
|
+
if (slotEl !== null && slotEl !== void 0) {
|
|
290
|
+
const update = () => {
|
|
291
|
+
this._hasSlotNextControl = this._slotNextControlElements.length > 0;
|
|
292
|
+
};
|
|
293
|
+
slotEl.addEventListener("slotchange", update);
|
|
294
|
+
this._disconnectCleanups.push(() => slotEl.removeEventListener("slotchange", update));
|
|
295
|
+
update();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
connectedCallback() {
|
|
300
|
+
this._hasSlotPrevControl = Array.from(this.children).some((el) => el.getAttribute("slot") === "prevControl");
|
|
301
|
+
this._hasSlotEllipsis = Array.from(this.children).some((el) => el.getAttribute("slot") === "ellipsis");
|
|
302
|
+
this._hasSlotItem = Array.from(this.children).some((el) => el.getAttribute("slot") === "item");
|
|
303
|
+
this._hasSlotNextControl = Array.from(this.children).some((el) => el.getAttribute("slot") === "nextControl");
|
|
304
|
+
super.connectedCallback();
|
|
305
|
+
if (this.hasUpdated && this._rozieTornDown) {
|
|
306
|
+
this._rozieTornDown = false;
|
|
307
|
+
this._armListeners();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
firstUpdated() {
|
|
311
|
+
this._armListeners();
|
|
312
|
+
}
|
|
313
|
+
disconnectedCallback() {
|
|
314
|
+
super.disconnectedCallback();
|
|
315
|
+
queueMicrotask(() => {
|
|
316
|
+
if (this.isConnected || this._rozieTornDown) return;
|
|
317
|
+
this._rozieTornDown = true;
|
|
318
|
+
for (const fn of this._disconnectCleanups) fn();
|
|
319
|
+
this._disconnectCleanups = [];
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
attributeChangedCallback(name, old, value) {
|
|
323
|
+
super.attributeChangedCallback(name, old, value);
|
|
324
|
+
if (name === "model-value") this._modelValueControllable.notifyAttributeChange(value === null ? 1 : Number(value));
|
|
325
|
+
}
|
|
326
|
+
render() {
|
|
327
|
+
return lit.html`
|
|
328
|
+
<nav class="${Object.entries({
|
|
329
|
+
"rozie-pagination": true,
|
|
330
|
+
"rozie-pagination--disabled": this.disabled
|
|
331
|
+
}).filter(([, v]) => v).map(([k]) => k).join(" ")}" aria-label=${this.ariaLabel} ${(0, _rozie_runtime_lit.rozieSpread)(this.$attrs)} @keydown=${($event) => {
|
|
332
|
+
this.onControlKeydown($event);
|
|
333
|
+
}} ${(0, _rozie_runtime_lit.rozieListeners)(this.$listeners)} data-rozie-ref="nav" data-rozie-s-de247ae2>
|
|
334
|
+
|
|
335
|
+
${this.prevControl !== void 0 ? this.prevControl({
|
|
336
|
+
disabled: !this.canPrev() || this.disabled,
|
|
337
|
+
goto: this.goPrev,
|
|
338
|
+
page: this.currentPage() - 1
|
|
339
|
+
}) : lit.html`<slot name="prevControl" data-rozie-params=${(() => {
|
|
340
|
+
try {
|
|
341
|
+
return JSON.stringify({
|
|
342
|
+
disabled: !this.canPrev() || this.disabled,
|
|
343
|
+
page: this.currentPage() - 1
|
|
344
|
+
});
|
|
345
|
+
} catch {
|
|
346
|
+
return "{}";
|
|
347
|
+
}
|
|
348
|
+
})()} @rozie-prev-control-goto=${($event) => this.goPrev($event.detail)}>
|
|
349
|
+
<button class="rozie-pagination-control rozie-pagination-prev" type="button" data-page-control="" tabindex=${(0, _rozie_runtime_lit.rozieAttr)(this.tabIndexFor(true))} ?disabled=${!this.canPrev() || this.disabled} aria-disabled=${!!(!this.canPrev() || this.disabled)} aria-label="Previous page" @click=${this.goPrev} data-rozie-s-de247ae2>‹</button>
|
|
350
|
+
</slot>`}
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
${(0, lit_directives_repeat_js.repeat)(this.model().pages, (item, index) => item === "ellipsis" ? "ellipsis-" + index : item, (item, index) => lit.html`
|
|
354
|
+
${item === "ellipsis" ? lit.html`<span class="rozie-pagination-ellipsis" aria-hidden="true" data-rozie-s-de247ae2>
|
|
355
|
+
${this.ellipsis !== void 0 ? this.ellipsis({ index }) : lit.html`<slot name="ellipsis" data-rozie-params=${(() => {
|
|
356
|
+
try {
|
|
357
|
+
return JSON.stringify({ index });
|
|
358
|
+
} catch {
|
|
359
|
+
return "{}";
|
|
360
|
+
}
|
|
361
|
+
})()}>…</slot>`}
|
|
362
|
+
</span>` : lit.nothing}${item !== "ellipsis" ? lit.html`<span class="rozie-pagination-item" data-rozie-s-de247ae2>
|
|
363
|
+
${this.item !== void 0 ? this.item({
|
|
364
|
+
page: item,
|
|
365
|
+
selected: this.isActive(item),
|
|
366
|
+
goto: () => this.goToPage(item)
|
|
367
|
+
}) : lit.html`<slot name="item" data-rozie-params=${(() => {
|
|
368
|
+
try {
|
|
369
|
+
return JSON.stringify({
|
|
370
|
+
page: item,
|
|
371
|
+
selected: this.isActive(item)
|
|
372
|
+
});
|
|
373
|
+
} catch {
|
|
374
|
+
return "{}";
|
|
375
|
+
}
|
|
376
|
+
})()} @rozie-item-goto=${($event) => (() => this.goToPage(item))($event.detail)}>
|
|
377
|
+
<button class="${Object.entries({
|
|
378
|
+
"rozie-pagination-page": true,
|
|
379
|
+
"is-active": this.isActive(item)
|
|
380
|
+
}).filter(([, v]) => v).map(([k]) => k).join(" ")}" type="button" data-page-control="" tabindex=${(0, _rozie_runtime_lit.rozieAttr)(this.tabIndexFor(this.isActive(item)))} ?disabled=${!!this.disabled} aria-disabled=${!!this.disabled} aria-current=${(0, _rozie_runtime_lit.rozieAttr)(this.isActive(item) ? "page" : null)} aria-label=${(0, _rozie_runtime_lit.rozieAttr)("Go to page " + item)} @click=${($event) => {
|
|
381
|
+
this.goToPage(item);
|
|
382
|
+
}} data-rozie-s-de247ae2>${(0, _rozie_runtime_lit.rozieDisplay)(item)}</button>
|
|
383
|
+
</slot>`}
|
|
384
|
+
</span>` : lit.nothing}`)}
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
${this.nextControl !== void 0 ? this.nextControl({
|
|
388
|
+
disabled: !this.canNext() || this.disabled,
|
|
389
|
+
goto: this.goNext,
|
|
390
|
+
page: this.currentPage() + 1
|
|
391
|
+
}) : lit.html`<slot name="nextControl" data-rozie-params=${(() => {
|
|
392
|
+
try {
|
|
393
|
+
return JSON.stringify({
|
|
394
|
+
disabled: !this.canNext() || this.disabled,
|
|
395
|
+
page: this.currentPage() + 1
|
|
396
|
+
});
|
|
397
|
+
} catch {
|
|
398
|
+
return "{}";
|
|
399
|
+
}
|
|
400
|
+
})()} @rozie-next-control-goto=${($event) => this.goNext($event.detail)}>
|
|
401
|
+
<button class="rozie-pagination-control rozie-pagination-next" type="button" data-page-control="" tabindex=${(0, _rozie_runtime_lit.rozieAttr)(this.tabIndexFor(true))} ?disabled=${!this.canNext() || this.disabled} aria-disabled=${!!(!this.canNext() || this.disabled)} aria-label="Next page" @click=${this.goNext} data-rozie-s-de247ae2>›</button>
|
|
402
|
+
</slot>`}
|
|
403
|
+
</nav>
|
|
404
|
+
`;
|
|
405
|
+
}
|
|
406
|
+
get modelValue() {
|
|
407
|
+
return this._modelValueControllable.read();
|
|
408
|
+
}
|
|
409
|
+
set modelValue(v) {
|
|
410
|
+
this._modelValueControllable.notifyPropertyWrite(v);
|
|
411
|
+
}
|
|
412
|
+
addEventListener(type, listener, options) {
|
|
413
|
+
super.addEventListener(type, listener, options);
|
|
414
|
+
}
|
|
415
|
+
removeEventListener(type, listener, options) {
|
|
416
|
+
super.removeEventListener(type, listener, options);
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Plan 14-05 — cross-framework attribute fallthrough source. Reads the
|
|
420
|
+
* host custom element's attributes on each call so a consumer-side bound
|
|
421
|
+
* attribute flows through on every render. The `rozieSpread` directive
|
|
422
|
+
* (D-02) does the cross-render diff downstream.
|
|
423
|
+
*
|
|
424
|
+
* Phase 15 follow-up Bug A — declared-prop attribute names are filtered
|
|
425
|
+
* out so `$attrs` returns "rest after declared props" (semantic parity
|
|
426
|
+
* with React/Vue/Svelte/Solid/Angular). Both Lit attribute-naming
|
|
427
|
+
* forms are folded into the skip set: kebab-case for model props
|
|
428
|
+
* (explicit `attribute:`) AND lowercased property name (Lit's default).
|
|
429
|
+
*
|
|
430
|
+
* command-palette-per-level-virtual / portal-through-portal cluster —
|
|
431
|
+
* `data-rozie-ref` is ALWAYS skipped too (a reserved compiler bookkeeping
|
|
432
|
+
* attribute, never a consumer prop) so a parent-assigned `ref=` on this
|
|
433
|
+
* component's own host tag can never clobber this component's OWN
|
|
434
|
+
* internal `data-rozie-ref` ref markers via fallthrough re-application.
|
|
435
|
+
*/
|
|
436
|
+
get $attrs() {
|
|
437
|
+
const __skip = new Set([
|
|
438
|
+
"data-rozie-ref",
|
|
439
|
+
"model-value",
|
|
440
|
+
"modelvalue",
|
|
441
|
+
"total-pages",
|
|
442
|
+
"totalpages",
|
|
443
|
+
"total",
|
|
444
|
+
"page-size",
|
|
445
|
+
"pagesize",
|
|
446
|
+
"sibling-count",
|
|
447
|
+
"siblingcount",
|
|
448
|
+
"boundary-count",
|
|
449
|
+
"boundarycount",
|
|
450
|
+
"disabled",
|
|
451
|
+
"aria-label",
|
|
452
|
+
"arialabel"
|
|
453
|
+
]);
|
|
454
|
+
const out = {};
|
|
455
|
+
for (const a of Array.from(this.attributes)) {
|
|
456
|
+
if (__skip.has(a.name)) continue;
|
|
457
|
+
out[a.name] = a.value;
|
|
458
|
+
}
|
|
459
|
+
return out;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Phase 15 D-19 — consumer-passed listener cluster placeholder.
|
|
463
|
+
* Lit attaches event listeners directly on the host element via
|
|
464
|
+
* `addEventListener` (no per-instance prop rest binding), so the
|
|
465
|
+
* runtime value is undefined; the `rozieListeners` directive's
|
|
466
|
+
* nullish coercion (`obj ?? {}`) handles the no-op cleanly.
|
|
467
|
+
* The declaration exists to satisfy `tsc --noEmit` on consumer
|
|
468
|
+
* projects with strict mode — bare `$listeners` in `render()`
|
|
469
|
+
* would otherwise raise TS2304 (Cannot find name).
|
|
470
|
+
*/
|
|
471
|
+
get $listeners() {}
|
|
472
|
+
};
|
|
473
|
+
__decorate([(0, lit_decorators_js.property)({
|
|
474
|
+
type: Number,
|
|
475
|
+
attribute: "model-value"
|
|
476
|
+
})], Pagination.prototype, "_modelValue_attr", void 0);
|
|
477
|
+
__decorate([(0, lit_decorators_js.property)({
|
|
478
|
+
type: Number,
|
|
479
|
+
reflect: true,
|
|
480
|
+
attribute: "total-pages"
|
|
481
|
+
})], Pagination.prototype, "totalPages", void 0);
|
|
482
|
+
__decorate([(0, lit_decorators_js.property)({
|
|
483
|
+
type: Number,
|
|
484
|
+
reflect: true
|
|
485
|
+
})], Pagination.prototype, "total", void 0);
|
|
486
|
+
__decorate([(0, lit_decorators_js.property)({
|
|
487
|
+
type: Number,
|
|
488
|
+
reflect: true,
|
|
489
|
+
attribute: "page-size"
|
|
490
|
+
})], Pagination.prototype, "pageSize", void 0);
|
|
491
|
+
__decorate([(0, lit_decorators_js.property)({
|
|
492
|
+
type: Number,
|
|
493
|
+
reflect: true,
|
|
494
|
+
attribute: "sibling-count"
|
|
495
|
+
})], Pagination.prototype, "siblingCount", void 0);
|
|
496
|
+
__decorate([(0, lit_decorators_js.property)({
|
|
497
|
+
type: Number,
|
|
498
|
+
reflect: true,
|
|
499
|
+
attribute: "boundary-count"
|
|
500
|
+
})], Pagination.prototype, "boundaryCount", void 0);
|
|
501
|
+
__decorate([(0, lit_decorators_js.property)({
|
|
502
|
+
type: Boolean,
|
|
503
|
+
reflect: true
|
|
504
|
+
})], Pagination.prototype, "disabled", void 0);
|
|
505
|
+
__decorate([(0, lit_decorators_js.property)({
|
|
506
|
+
type: String,
|
|
507
|
+
reflect: true,
|
|
508
|
+
attribute: "aria-label"
|
|
509
|
+
})], Pagination.prototype, "ariaLabel", void 0);
|
|
510
|
+
__decorate([(0, lit_decorators_js.query)("[data-rozie-ref=\"nav\"]")], Pagination.prototype, "_refNav", void 0);
|
|
511
|
+
__decorate([(0, lit_decorators_js.state)()], Pagination.prototype, "_hasSlotPrevControl", void 0);
|
|
512
|
+
__decorate([(0, lit_decorators_js.queryAssignedElements)({
|
|
513
|
+
slot: "prevControl",
|
|
514
|
+
flatten: true
|
|
515
|
+
})], Pagination.prototype, "_slotPrevControlElements", void 0);
|
|
516
|
+
__decorate([(0, lit_decorators_js.property)({ attribute: false })], Pagination.prototype, "prevControl", void 0);
|
|
517
|
+
__decorate([(0, lit_decorators_js.state)()], Pagination.prototype, "_hasSlotEllipsis", void 0);
|
|
518
|
+
__decorate([(0, lit_decorators_js.queryAssignedElements)({
|
|
519
|
+
slot: "ellipsis",
|
|
520
|
+
flatten: true
|
|
521
|
+
})], Pagination.prototype, "_slotEllipsisElements", void 0);
|
|
522
|
+
__decorate([(0, lit_decorators_js.property)({ attribute: false })], Pagination.prototype, "ellipsis", void 0);
|
|
523
|
+
__decorate([(0, lit_decorators_js.state)()], Pagination.prototype, "_hasSlotItem", void 0);
|
|
524
|
+
__decorate([(0, lit_decorators_js.queryAssignedElements)({
|
|
525
|
+
slot: "item",
|
|
526
|
+
flatten: true
|
|
527
|
+
})], Pagination.prototype, "_slotItemElements", void 0);
|
|
528
|
+
__decorate([(0, lit_decorators_js.property)({ attribute: false })], Pagination.prototype, "item", void 0);
|
|
529
|
+
__decorate([(0, lit_decorators_js.state)()], Pagination.prototype, "_hasSlotNextControl", void 0);
|
|
530
|
+
__decorate([(0, lit_decorators_js.queryAssignedElements)({
|
|
531
|
+
slot: "nextControl",
|
|
532
|
+
flatten: true
|
|
533
|
+
})], Pagination.prototype, "_slotNextControlElements", void 0);
|
|
534
|
+
__decorate([(0, lit_decorators_js.property)({ attribute: false })], Pagination.prototype, "nextControl", void 0);
|
|
535
|
+
__decorate([(0, lit_decorators_js.property)({ attribute: false })], Pagination.prototype, "rozieSlots", void 0);
|
|
536
|
+
Pagination = __decorate([(0, lit_decorators_js.customElement)("rozie-pagination")], Pagination);
|
|
537
|
+
var Pagination_default = Pagination;
|
|
538
|
+
//#endregion
|
|
539
|
+
exports.Pagination = Pagination_default;
|
|
540
|
+
exports.default = Pagination_default;
|