@wavelengthusaf/web-components 1.10.0 → 1.11.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/dist/cjs/index.cjs +163 -1
- package/dist/cjs/index.d.cts +23 -1
- package/dist/esm/index.d.ts +23 -1
- package/dist/esm/index.js +162 -0
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -6345,6 +6345,168 @@ if (!customElements.get("wavelength-menu")) {
|
|
|
6345
6345
|
customElements.define("wavelength-menu", WavelengthMenu);
|
|
6346
6346
|
}
|
|
6347
6347
|
|
|
6348
|
+
// src/web-components/wavelength-pagination.template.html
|
|
6349
|
+
var wavelength_pagination_template_default = '<style>\n :host {\n display: block;\n --local-font: var(--font, "Montserrat", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);\n font-family: var(--local-font);\n }\n\n .pagination-list,\n .pagination-list * {\n font-family: inherit;\n font-size: var(--font-size, 16px);\n color: var(--text-color, black);\n }\n\n .pagination-list {\n display: flex;\n list-style: none;\n padding: var(--padding, 10px);\n margin: 0;\n align-items: center;\n }\n\n .page-item {\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n transition: all 0.3s ease;\n user-select: none;\n background-color: var(--background-color, white);\n }\n\n .page-item.disabled,\n .page-item.disabled * {\n cursor: default;\n background-color: var(--background-color, white);\n color: var(--disabled-color, #ccc);\n border-color: var(--disabled-color, #ccc);\n }\n\n /* --- BASIC VARIANT --- */\n .pagination-list.basic {\n gap: 15px;\n }\n\n .pagination-list.basic .page-info {\n margin-right: 10px;\n font-weight: 500;\n }\n\n .pagination-list.basic .page-item {\n width: 32px;\n height: 32px;\n border: var(--border, none);\n border-radius: var(--border-radius, 50%);\n }\n\n .pagination-list.basic .page-item:not(.disabled):hover {\n filter: brightness(0.95);\n }\n\n /* --- COMMON VARIANT --- */\n .pagination-list.common {\n gap: 8px;\n }\n\n .pagination-list.common .page-item {\n width: 40px;\n height: 40px;\n border: var(--border, none);\n border-radius: var(--border-radius, 50%);\n }\n\n .pagination-list.common .page-item.active,\n .pagination-list.common .page-item.active * {\n background-color: var(--active-color, #49baf7);\n color: var(--active-text-color, #fff);\n border-color: var(--active-color, #49baf7);\n }\n\n .pagination-list.common .page-item:not(.disabled):not(.active):hover {\n filter: brightness(0.95);\n transform: scale(1.1);\n }\n</style>\n<nav aria-label="pagination">\n <ul class="pagination-list"></ul>\n</nav>\n';
|
|
6350
|
+
|
|
6351
|
+
// src/web-components/wavelength-pagination.ts
|
|
6352
|
+
var WavelengthPagination = class extends HTMLElement {
|
|
6353
|
+
constructor() {
|
|
6354
|
+
super();
|
|
6355
|
+
this.styleAttributes = ["variant", "text-color", "font", "font-size", "border", "border-radius", "padding", "active-color", "active-text-color", "background-color", "disabled-color"];
|
|
6356
|
+
this.renderAttributes = ["variant", "total-pages", "current-page"];
|
|
6357
|
+
this.shadow = this.attachShadow({ mode: "open" });
|
|
6358
|
+
this.shadow.innerHTML = wavelength_pagination_template_default;
|
|
6359
|
+
}
|
|
6360
|
+
static get observedAttributes() {
|
|
6361
|
+
return [
|
|
6362
|
+
"variant",
|
|
6363
|
+
"text-color",
|
|
6364
|
+
"font",
|
|
6365
|
+
"font-size",
|
|
6366
|
+
"border",
|
|
6367
|
+
"border-radius",
|
|
6368
|
+
"padding",
|
|
6369
|
+
"total-pages",
|
|
6370
|
+
"current-page",
|
|
6371
|
+
"active-color",
|
|
6372
|
+
"active-text-color",
|
|
6373
|
+
"background-color",
|
|
6374
|
+
"disabled-color"
|
|
6375
|
+
];
|
|
6376
|
+
}
|
|
6377
|
+
get totalPages() {
|
|
6378
|
+
const parsed = Number.parseInt(this.getAttribute("total-pages") || "1", 10);
|
|
6379
|
+
return isNaN(parsed) ? 1 : parsed;
|
|
6380
|
+
}
|
|
6381
|
+
set totalPages(val) {
|
|
6382
|
+
this.setAttribute("total-pages", val.toString());
|
|
6383
|
+
}
|
|
6384
|
+
get currentPage() {
|
|
6385
|
+
const parsed = Number.parseInt(this.getAttribute("current-page") || "1", 10);
|
|
6386
|
+
return isNaN(parsed) ? 1 : parsed;
|
|
6387
|
+
}
|
|
6388
|
+
set currentPage(val) {
|
|
6389
|
+
this.setAttribute("current-page", val.toString());
|
|
6390
|
+
}
|
|
6391
|
+
connectedCallback() {
|
|
6392
|
+
this._clearAndRender();
|
|
6393
|
+
this._syncStyles();
|
|
6394
|
+
}
|
|
6395
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
6396
|
+
if (oldValue === newValue) return;
|
|
6397
|
+
if (this.styleAttributes.includes(name)) {
|
|
6398
|
+
this.style.setProperty(`--${name}`, newValue);
|
|
6399
|
+
}
|
|
6400
|
+
if (this.renderAttributes.includes(name)) {
|
|
6401
|
+
this._clearAndRender();
|
|
6402
|
+
}
|
|
6403
|
+
}
|
|
6404
|
+
_clearAndRender() {
|
|
6405
|
+
const list = this.shadow.querySelector(".pagination-list");
|
|
6406
|
+
if (!list) return;
|
|
6407
|
+
const variant = this.getAttribute("variant") || "basic";
|
|
6408
|
+
list.innerHTML = "";
|
|
6409
|
+
list.className = `pagination-list ${variant}`;
|
|
6410
|
+
this._renderByVariant(list, variant);
|
|
6411
|
+
}
|
|
6412
|
+
_renderByVariant(container, variant) {
|
|
6413
|
+
if (variant === "basic") {
|
|
6414
|
+
this._renderBasic(container);
|
|
6415
|
+
} else {
|
|
6416
|
+
this._renderCommon(container);
|
|
6417
|
+
}
|
|
6418
|
+
}
|
|
6419
|
+
_renderBasic(container) {
|
|
6420
|
+
const { singlePrevSvg, singleNextSvg } = this._getIcons();
|
|
6421
|
+
const textInfo = document.createElement("span");
|
|
6422
|
+
textInfo.className = "page-info";
|
|
6423
|
+
textInfo.textContent = `Page ${this.currentPage} of ${this.totalPages}`;
|
|
6424
|
+
container.appendChild(textInfo);
|
|
6425
|
+
const prevBtn = this._createButton(singlePrevSvg, () => this._changePage(this.currentPage - 1), this.currentPage === 1);
|
|
6426
|
+
const nextBtn = this._createButton(singleNextSvg, () => this._changePage(this.currentPage + 1), this.currentPage === this.totalPages);
|
|
6427
|
+
container.appendChild(prevBtn);
|
|
6428
|
+
container.appendChild(nextBtn);
|
|
6429
|
+
}
|
|
6430
|
+
_getIcons() {
|
|
6431
|
+
const doubleArrowPath = `M185.27637,135.6062q-.36694.4466-.77393.85608c-.00732.00745-.01318.01575-.021.02307l-72,72a12.0001,12.0001,0,0,1-16.97071-16.9707L147.02539,140H31.99609a12,12,0,0,1,0-24h115.0293L95.51074,64.48535a12.0001,12.0001,0,0,1,16.97071-16.9707l72,72c.00781.00732.01367.01562.021.02307q.40723.409.77393.85608c.11425.1394.21386.28662.32129.42993.12744.17.25927.33643.37744.51318.11474.17115.21386.34888.31836.5243.09619.1604.19677.31726.28515.48242.09619.17944.17725.36389.26368.547.08105.17188.1665.34083.23974.51685.07373.17847.1333.36084.19824.54187.06787.18836.14014.37415.19825.56677.05468.18116.09472.36524.14111.54834.04932.19641.10449.39038.144.59034.042.21167.0669.42553.09766.63867.0249.17431.05762.3457.07519.52221a12.07306,12.07306,0,0,1,0,2.36866c-.01757.17651-.05029.3479-.07519.52221-.03076.21314-.05567.427-.09766.63867-.03955.2-.09472.39393-.144.59034-.04639.1831-.08643.36718-.14111.54834-.0586.19287-.13086.3789-.19825.56762-.06494.18067-.12451.36255-.19824.54078-.07324.17651-.15918.34558-.24023.5177-.08594.18286-.16748.36718-.26319.54638-.08838.16516-.189.322-.28515.48242-.1045.17542-.20362.35315-.31836.5243-.11817.17675-.25.34314-.37744.51318C185.49023,135.31958,185.39062,135.4668,185.27637,135.6062ZM216,28a12,12,0,0,0-12,12V216a12,12,0,0,0,24,0V40A12,12,0,0,0,216,28Z`;
|
|
6432
|
+
const singleArrowPath = `M426.6 755.2L375 703.6l193.1-193.2L375 317.3l51.6-51.6 244.7 244.7z`;
|
|
6433
|
+
const iconStyle = `width: 24px; height: 24px;`;
|
|
6434
|
+
return {
|
|
6435
|
+
nextSvg: `<svg fill="currentColor" viewBox="0 0 256 256" id="Flat" xmlns="http://www.w3.org/2000/svg" style="${iconStyle}"><g id="SVGRepo_iconCarrier"> <path d="${doubleArrowPath}"></path> </g></svg>`,
|
|
6436
|
+
prevSvg: `<svg fill="currentColor" viewBox="0 0 256 256" id="Flat" xmlns="http://www.w3.org/2000/svg" style="${iconStyle} transform: scaleX(-1);"><g id="SVGRepo_iconCarrier"> <path d="${doubleArrowPath}"></path> </g></svg>`,
|
|
6437
|
+
singleNextSvg: `<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" style="${iconStyle}"><g id="SVGRepo_iconCarrier"><path d="${singleArrowPath}" fill="currentColor"></path></g></svg>`,
|
|
6438
|
+
singlePrevSvg: `<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" style="${iconStyle} transform: scaleX(-1);"><g id="SVGRepo_iconCarrier"><path d="${singleArrowPath}" fill="currentColor"></path></g></svg>`
|
|
6439
|
+
};
|
|
6440
|
+
}
|
|
6441
|
+
_renderCommon(container) {
|
|
6442
|
+
const { nextSvg, prevSvg, singleNextSvg, singlePrevSvg } = this._getIcons();
|
|
6443
|
+
container.appendChild(this._createButton(prevSvg, () => this._changePage(1), this.currentPage === 1));
|
|
6444
|
+
container.appendChild(this._createButton(singlePrevSvg, () => this._changePage(this.currentPage - 1), this.currentPage === 1));
|
|
6445
|
+
let startPage = Math.max(1, this.currentPage - 3);
|
|
6446
|
+
const endPage = Math.min(this.totalPages, startPage + 6);
|
|
6447
|
+
if (endPage - startPage < 6) {
|
|
6448
|
+
startPage = Math.max(1, endPage - 6);
|
|
6449
|
+
}
|
|
6450
|
+
for (let i = startPage; i <= endPage; i++) {
|
|
6451
|
+
const btn = this._createButton(i.toString(), () => this._changePage(i), false);
|
|
6452
|
+
if (i === this.currentPage) btn.classList.add("active");
|
|
6453
|
+
container.appendChild(btn);
|
|
6454
|
+
}
|
|
6455
|
+
container.appendChild(this._createButton(singleNextSvg, () => this._changePage(this.currentPage + 1), this.currentPage === this.totalPages, false, "Next Page"));
|
|
6456
|
+
container.appendChild(this._createButton(nextSvg, () => this._changePage(this.totalPages), this.currentPage === this.totalPages, false, "Last Page"));
|
|
6457
|
+
}
|
|
6458
|
+
_createButton(content, onClick, disabled, isActive = false, ariaLabel) {
|
|
6459
|
+
const li = document.createElement("li");
|
|
6460
|
+
li.className = "page-item";
|
|
6461
|
+
const btn = document.createElement("button");
|
|
6462
|
+
btn.style.all = "unset";
|
|
6463
|
+
btn.style.width = "100%";
|
|
6464
|
+
btn.style.height = "100%";
|
|
6465
|
+
btn.style.display = "flex";
|
|
6466
|
+
btn.style.alignItems = "center";
|
|
6467
|
+
btn.style.justifyContent = "center";
|
|
6468
|
+
btn.style.cursor = disabled ? "default" : "pointer";
|
|
6469
|
+
if (ariaLabel) btn.setAttribute("aria-label", ariaLabel);
|
|
6470
|
+
if (isActive) btn.setAttribute("aria-current", "page");
|
|
6471
|
+
btn.disabled = disabled;
|
|
6472
|
+
if (!disabled) {
|
|
6473
|
+
btn.onclick = onClick;
|
|
6474
|
+
}
|
|
6475
|
+
if (isActive) li.classList.add("active");
|
|
6476
|
+
if (disabled) li.classList.add("disabled");
|
|
6477
|
+
if (content.includes("<svg")) {
|
|
6478
|
+
btn.innerHTML = content;
|
|
6479
|
+
} else {
|
|
6480
|
+
btn.textContent = content;
|
|
6481
|
+
}
|
|
6482
|
+
li.appendChild(btn);
|
|
6483
|
+
return li;
|
|
6484
|
+
}
|
|
6485
|
+
_changePage(newPage) {
|
|
6486
|
+
if (newPage < 1 || newPage > this.totalPages) return;
|
|
6487
|
+
this.setAttribute("current-page", newPage.toString());
|
|
6488
|
+
this.dispatchEvent(
|
|
6489
|
+
new CustomEvent("page-change", {
|
|
6490
|
+
detail: { page: newPage },
|
|
6491
|
+
bubbles: true,
|
|
6492
|
+
composed: true
|
|
6493
|
+
})
|
|
6494
|
+
);
|
|
6495
|
+
}
|
|
6496
|
+
_syncStyles() {
|
|
6497
|
+
this.styleAttributes.forEach((attr) => {
|
|
6498
|
+
const value = this.getAttribute(attr);
|
|
6499
|
+
if (value) {
|
|
6500
|
+
this.style.setProperty(`--${attr}`, value);
|
|
6501
|
+
}
|
|
6502
|
+
});
|
|
6503
|
+
}
|
|
6504
|
+
};
|
|
6505
|
+
if (!customElements.get("wavelength-pagination")) {
|
|
6506
|
+
customElements.define("wavelength-pagination", WavelengthPagination);
|
|
6507
|
+
}
|
|
6508
|
+
|
|
6509
|
+
|
|
6348
6510
|
|
|
6349
6511
|
|
|
6350
6512
|
|
|
@@ -6367,7 +6529,7 @@ if (!customElements.get("wavelength-menu")) {
|
|
|
6367
6529
|
|
|
6368
6530
|
|
|
6369
6531
|
|
|
6370
|
-
exports.BaseWavelengthInput = BaseWavelengthInput; exports.BaseWavelengthMultiSelectAutocomplete = BaseWavelengthMultiSelectAutocomplete; exports.ChildDataTable = ChildDataTable; exports.SampleComponent = SampleComponent; exports.WavelengthBanner = WavelengthBanner; exports.WavelengthButton = WavelengthButton; exports.WavelengthCheckbox = WavelengthCheckbox; exports.WavelengthDatePicker = WavelengthDatePicker; exports.WavelengthDropdown = WavelengthDropdown; exports.WavelengthFileDropZone = WavelengthFileDropZone; exports.WavelengthForm = WavelengthForm; exports.WavelengthInput = WavelengthInput; exports.WavelengthManyPlanes = WavelengthManyPlanes; exports.WavelengthMenu = WavelengthMenu; exports.WavelengthMultiSelectAutocomplete = WavelengthMultiSelectAutocomplete; exports.WavelengthNavBar = WavelengthNavBar; exports.WavelengthNotificationPanel = WavelengthNotificationPanel; exports.WavelengthPlaneTrail = WavelengthPlaneTrail; exports.WavelengthProgressBar = WavelengthProgressBar; exports.WavelengthSnackbar = WavelengthSnackbar; exports.WavelengthTitleBar = WavelengthTitleBar; exports.WavelengthToolTip = WavelengthToolTip;
|
|
6532
|
+
exports.BaseWavelengthInput = BaseWavelengthInput; exports.BaseWavelengthMultiSelectAutocomplete = BaseWavelengthMultiSelectAutocomplete; exports.ChildDataTable = ChildDataTable; exports.SampleComponent = SampleComponent; exports.WavelengthBanner = WavelengthBanner; exports.WavelengthButton = WavelengthButton; exports.WavelengthCheckbox = WavelengthCheckbox; exports.WavelengthDatePicker = WavelengthDatePicker; exports.WavelengthDropdown = WavelengthDropdown; exports.WavelengthFileDropZone = WavelengthFileDropZone; exports.WavelengthForm = WavelengthForm; exports.WavelengthInput = WavelengthInput; exports.WavelengthManyPlanes = WavelengthManyPlanes; exports.WavelengthMenu = WavelengthMenu; exports.WavelengthMultiSelectAutocomplete = WavelengthMultiSelectAutocomplete; exports.WavelengthNavBar = WavelengthNavBar; exports.WavelengthNotificationPanel = WavelengthNotificationPanel; exports.WavelengthPagination = WavelengthPagination; exports.WavelengthPlaneTrail = WavelengthPlaneTrail; exports.WavelengthProgressBar = WavelengthProgressBar; exports.WavelengthSnackbar = WavelengthSnackbar; exports.WavelengthTitleBar = WavelengthTitleBar; exports.WavelengthToolTip = WavelengthToolTip;
|
|
6371
6533
|
/*! Bundled license information:
|
|
6372
6534
|
|
|
6373
6535
|
react/cjs/react.production.min.js:
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -2286,4 +2286,26 @@ declare class WavelengthMenu extends HTMLElement {
|
|
|
2286
2286
|
private _dispatchSelectEvent;
|
|
2287
2287
|
}
|
|
2288
2288
|
|
|
2289
|
-
|
|
2289
|
+
declare class WavelengthPagination extends HTMLElement {
|
|
2290
|
+
static get observedAttributes(): string[];
|
|
2291
|
+
private shadow;
|
|
2292
|
+
private styleAttributes;
|
|
2293
|
+
private renderAttributes;
|
|
2294
|
+
constructor();
|
|
2295
|
+
get totalPages(): number;
|
|
2296
|
+
set totalPages(val: number);
|
|
2297
|
+
get currentPage(): number;
|
|
2298
|
+
set currentPage(val: number);
|
|
2299
|
+
connectedCallback(): void;
|
|
2300
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
2301
|
+
private _clearAndRender;
|
|
2302
|
+
private _renderByVariant;
|
|
2303
|
+
private _renderBasic;
|
|
2304
|
+
private _getIcons;
|
|
2305
|
+
private _renderCommon;
|
|
2306
|
+
private _createButton;
|
|
2307
|
+
private _changePage;
|
|
2308
|
+
private _syncStyles;
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
export { BaseWavelengthInput, BaseWavelengthMultiSelectAutocomplete, type CheckboxElements, ChildDataTable, SampleComponent, WavelengthBanner, WavelengthButton, WavelengthCheckbox, WavelengthDatePicker, WavelengthDropdown, WavelengthFileDropZone, WavelengthForm, WavelengthInput, WavelengthManyPlanes, WavelengthMenu, WavelengthMultiSelectAutocomplete, WavelengthNavBar, WavelengthNotificationPanel, WavelengthPagination, WavelengthPlaneTrail, WavelengthProgressBar, WavelengthSnackbar, WavelengthTitleBar, WavelengthToolTip };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -2286,4 +2286,26 @@ declare class WavelengthMenu extends HTMLElement {
|
|
|
2286
2286
|
private _dispatchSelectEvent;
|
|
2287
2287
|
}
|
|
2288
2288
|
|
|
2289
|
-
|
|
2289
|
+
declare class WavelengthPagination extends HTMLElement {
|
|
2290
|
+
static get observedAttributes(): string[];
|
|
2291
|
+
private shadow;
|
|
2292
|
+
private styleAttributes;
|
|
2293
|
+
private renderAttributes;
|
|
2294
|
+
constructor();
|
|
2295
|
+
get totalPages(): number;
|
|
2296
|
+
set totalPages(val: number);
|
|
2297
|
+
get currentPage(): number;
|
|
2298
|
+
set currentPage(val: number);
|
|
2299
|
+
connectedCallback(): void;
|
|
2300
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
2301
|
+
private _clearAndRender;
|
|
2302
|
+
private _renderByVariant;
|
|
2303
|
+
private _renderBasic;
|
|
2304
|
+
private _getIcons;
|
|
2305
|
+
private _renderCommon;
|
|
2306
|
+
private _createButton;
|
|
2307
|
+
private _changePage;
|
|
2308
|
+
private _syncStyles;
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
export { BaseWavelengthInput, BaseWavelengthMultiSelectAutocomplete, type CheckboxElements, ChildDataTable, SampleComponent, WavelengthBanner, WavelengthButton, WavelengthCheckbox, WavelengthDatePicker, WavelengthDropdown, WavelengthFileDropZone, WavelengthForm, WavelengthInput, WavelengthManyPlanes, WavelengthMenu, WavelengthMultiSelectAutocomplete, WavelengthNavBar, WavelengthNotificationPanel, WavelengthPagination, WavelengthPlaneTrail, WavelengthProgressBar, WavelengthSnackbar, WavelengthTitleBar, WavelengthToolTip };
|
package/dist/esm/index.js
CHANGED
|
@@ -6344,6 +6344,167 @@ var WavelengthMenu = class extends HTMLElement {
|
|
|
6344
6344
|
if (!customElements.get("wavelength-menu")) {
|
|
6345
6345
|
customElements.define("wavelength-menu", WavelengthMenu);
|
|
6346
6346
|
}
|
|
6347
|
+
|
|
6348
|
+
// src/web-components/wavelength-pagination.template.html
|
|
6349
|
+
var wavelength_pagination_template_default = '<style>\n :host {\n display: block;\n --local-font: var(--font, "Montserrat", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);\n font-family: var(--local-font);\n }\n\n .pagination-list,\n .pagination-list * {\n font-family: inherit;\n font-size: var(--font-size, 16px);\n color: var(--text-color, black);\n }\n\n .pagination-list {\n display: flex;\n list-style: none;\n padding: var(--padding, 10px);\n margin: 0;\n align-items: center;\n }\n\n .page-item {\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n transition: all 0.3s ease;\n user-select: none;\n background-color: var(--background-color, white);\n }\n\n .page-item.disabled,\n .page-item.disabled * {\n cursor: default;\n background-color: var(--background-color, white);\n color: var(--disabled-color, #ccc);\n border-color: var(--disabled-color, #ccc);\n }\n\n /* --- BASIC VARIANT --- */\n .pagination-list.basic {\n gap: 15px;\n }\n\n .pagination-list.basic .page-info {\n margin-right: 10px;\n font-weight: 500;\n }\n\n .pagination-list.basic .page-item {\n width: 32px;\n height: 32px;\n border: var(--border, none);\n border-radius: var(--border-radius, 50%);\n }\n\n .pagination-list.basic .page-item:not(.disabled):hover {\n filter: brightness(0.95);\n }\n\n /* --- COMMON VARIANT --- */\n .pagination-list.common {\n gap: 8px;\n }\n\n .pagination-list.common .page-item {\n width: 40px;\n height: 40px;\n border: var(--border, none);\n border-radius: var(--border-radius, 50%);\n }\n\n .pagination-list.common .page-item.active,\n .pagination-list.common .page-item.active * {\n background-color: var(--active-color, #49baf7);\n color: var(--active-text-color, #fff);\n border-color: var(--active-color, #49baf7);\n }\n\n .pagination-list.common .page-item:not(.disabled):not(.active):hover {\n filter: brightness(0.95);\n transform: scale(1.1);\n }\n</style>\n<nav aria-label="pagination">\n <ul class="pagination-list"></ul>\n</nav>\n';
|
|
6350
|
+
|
|
6351
|
+
// src/web-components/wavelength-pagination.ts
|
|
6352
|
+
var WavelengthPagination = class extends HTMLElement {
|
|
6353
|
+
constructor() {
|
|
6354
|
+
super();
|
|
6355
|
+
this.styleAttributes = ["variant", "text-color", "font", "font-size", "border", "border-radius", "padding", "active-color", "active-text-color", "background-color", "disabled-color"];
|
|
6356
|
+
this.renderAttributes = ["variant", "total-pages", "current-page"];
|
|
6357
|
+
this.shadow = this.attachShadow({ mode: "open" });
|
|
6358
|
+
this.shadow.innerHTML = wavelength_pagination_template_default;
|
|
6359
|
+
}
|
|
6360
|
+
static get observedAttributes() {
|
|
6361
|
+
return [
|
|
6362
|
+
"variant",
|
|
6363
|
+
"text-color",
|
|
6364
|
+
"font",
|
|
6365
|
+
"font-size",
|
|
6366
|
+
"border",
|
|
6367
|
+
"border-radius",
|
|
6368
|
+
"padding",
|
|
6369
|
+
"total-pages",
|
|
6370
|
+
"current-page",
|
|
6371
|
+
"active-color",
|
|
6372
|
+
"active-text-color",
|
|
6373
|
+
"background-color",
|
|
6374
|
+
"disabled-color"
|
|
6375
|
+
];
|
|
6376
|
+
}
|
|
6377
|
+
get totalPages() {
|
|
6378
|
+
const parsed = Number.parseInt(this.getAttribute("total-pages") || "1", 10);
|
|
6379
|
+
return isNaN(parsed) ? 1 : parsed;
|
|
6380
|
+
}
|
|
6381
|
+
set totalPages(val) {
|
|
6382
|
+
this.setAttribute("total-pages", val.toString());
|
|
6383
|
+
}
|
|
6384
|
+
get currentPage() {
|
|
6385
|
+
const parsed = Number.parseInt(this.getAttribute("current-page") || "1", 10);
|
|
6386
|
+
return isNaN(parsed) ? 1 : parsed;
|
|
6387
|
+
}
|
|
6388
|
+
set currentPage(val) {
|
|
6389
|
+
this.setAttribute("current-page", val.toString());
|
|
6390
|
+
}
|
|
6391
|
+
connectedCallback() {
|
|
6392
|
+
this._clearAndRender();
|
|
6393
|
+
this._syncStyles();
|
|
6394
|
+
}
|
|
6395
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
6396
|
+
if (oldValue === newValue) return;
|
|
6397
|
+
if (this.styleAttributes.includes(name)) {
|
|
6398
|
+
this.style.setProperty(`--${name}`, newValue);
|
|
6399
|
+
}
|
|
6400
|
+
if (this.renderAttributes.includes(name)) {
|
|
6401
|
+
this._clearAndRender();
|
|
6402
|
+
}
|
|
6403
|
+
}
|
|
6404
|
+
_clearAndRender() {
|
|
6405
|
+
const list = this.shadow.querySelector(".pagination-list");
|
|
6406
|
+
if (!list) return;
|
|
6407
|
+
const variant = this.getAttribute("variant") || "basic";
|
|
6408
|
+
list.innerHTML = "";
|
|
6409
|
+
list.className = `pagination-list ${variant}`;
|
|
6410
|
+
this._renderByVariant(list, variant);
|
|
6411
|
+
}
|
|
6412
|
+
_renderByVariant(container, variant) {
|
|
6413
|
+
if (variant === "basic") {
|
|
6414
|
+
this._renderBasic(container);
|
|
6415
|
+
} else {
|
|
6416
|
+
this._renderCommon(container);
|
|
6417
|
+
}
|
|
6418
|
+
}
|
|
6419
|
+
_renderBasic(container) {
|
|
6420
|
+
const { singlePrevSvg, singleNextSvg } = this._getIcons();
|
|
6421
|
+
const textInfo = document.createElement("span");
|
|
6422
|
+
textInfo.className = "page-info";
|
|
6423
|
+
textInfo.textContent = `Page ${this.currentPage} of ${this.totalPages}`;
|
|
6424
|
+
container.appendChild(textInfo);
|
|
6425
|
+
const prevBtn = this._createButton(singlePrevSvg, () => this._changePage(this.currentPage - 1), this.currentPage === 1);
|
|
6426
|
+
const nextBtn = this._createButton(singleNextSvg, () => this._changePage(this.currentPage + 1), this.currentPage === this.totalPages);
|
|
6427
|
+
container.appendChild(prevBtn);
|
|
6428
|
+
container.appendChild(nextBtn);
|
|
6429
|
+
}
|
|
6430
|
+
_getIcons() {
|
|
6431
|
+
const doubleArrowPath = `M185.27637,135.6062q-.36694.4466-.77393.85608c-.00732.00745-.01318.01575-.021.02307l-72,72a12.0001,12.0001,0,0,1-16.97071-16.9707L147.02539,140H31.99609a12,12,0,0,1,0-24h115.0293L95.51074,64.48535a12.0001,12.0001,0,0,1,16.97071-16.9707l72,72c.00781.00732.01367.01562.021.02307q.40723.409.77393.85608c.11425.1394.21386.28662.32129.42993.12744.17.25927.33643.37744.51318.11474.17115.21386.34888.31836.5243.09619.1604.19677.31726.28515.48242.09619.17944.17725.36389.26368.547.08105.17188.1665.34083.23974.51685.07373.17847.1333.36084.19824.54187.06787.18836.14014.37415.19825.56677.05468.18116.09472.36524.14111.54834.04932.19641.10449.39038.144.59034.042.21167.0669.42553.09766.63867.0249.17431.05762.3457.07519.52221a12.07306,12.07306,0,0,1,0,2.36866c-.01757.17651-.05029.3479-.07519.52221-.03076.21314-.05567.427-.09766.63867-.03955.2-.09472.39393-.144.59034-.04639.1831-.08643.36718-.14111.54834-.0586.19287-.13086.3789-.19825.56762-.06494.18067-.12451.36255-.19824.54078-.07324.17651-.15918.34558-.24023.5177-.08594.18286-.16748.36718-.26319.54638-.08838.16516-.189.322-.28515.48242-.1045.17542-.20362.35315-.31836.5243-.11817.17675-.25.34314-.37744.51318C185.49023,135.31958,185.39062,135.4668,185.27637,135.6062ZM216,28a12,12,0,0,0-12,12V216a12,12,0,0,0,24,0V40A12,12,0,0,0,216,28Z`;
|
|
6432
|
+
const singleArrowPath = `M426.6 755.2L375 703.6l193.1-193.2L375 317.3l51.6-51.6 244.7 244.7z`;
|
|
6433
|
+
const iconStyle = `width: 24px; height: 24px;`;
|
|
6434
|
+
return {
|
|
6435
|
+
nextSvg: `<svg fill="currentColor" viewBox="0 0 256 256" id="Flat" xmlns="http://www.w3.org/2000/svg" style="${iconStyle}"><g id="SVGRepo_iconCarrier"> <path d="${doubleArrowPath}"></path> </g></svg>`,
|
|
6436
|
+
prevSvg: `<svg fill="currentColor" viewBox="0 0 256 256" id="Flat" xmlns="http://www.w3.org/2000/svg" style="${iconStyle} transform: scaleX(-1);"><g id="SVGRepo_iconCarrier"> <path d="${doubleArrowPath}"></path> </g></svg>`,
|
|
6437
|
+
singleNextSvg: `<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" style="${iconStyle}"><g id="SVGRepo_iconCarrier"><path d="${singleArrowPath}" fill="currentColor"></path></g></svg>`,
|
|
6438
|
+
singlePrevSvg: `<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" style="${iconStyle} transform: scaleX(-1);"><g id="SVGRepo_iconCarrier"><path d="${singleArrowPath}" fill="currentColor"></path></g></svg>`
|
|
6439
|
+
};
|
|
6440
|
+
}
|
|
6441
|
+
_renderCommon(container) {
|
|
6442
|
+
const { nextSvg, prevSvg, singleNextSvg, singlePrevSvg } = this._getIcons();
|
|
6443
|
+
container.appendChild(this._createButton(prevSvg, () => this._changePage(1), this.currentPage === 1));
|
|
6444
|
+
container.appendChild(this._createButton(singlePrevSvg, () => this._changePage(this.currentPage - 1), this.currentPage === 1));
|
|
6445
|
+
let startPage = Math.max(1, this.currentPage - 3);
|
|
6446
|
+
const endPage = Math.min(this.totalPages, startPage + 6);
|
|
6447
|
+
if (endPage - startPage < 6) {
|
|
6448
|
+
startPage = Math.max(1, endPage - 6);
|
|
6449
|
+
}
|
|
6450
|
+
for (let i = startPage; i <= endPage; i++) {
|
|
6451
|
+
const btn = this._createButton(i.toString(), () => this._changePage(i), false);
|
|
6452
|
+
if (i === this.currentPage) btn.classList.add("active");
|
|
6453
|
+
container.appendChild(btn);
|
|
6454
|
+
}
|
|
6455
|
+
container.appendChild(this._createButton(singleNextSvg, () => this._changePage(this.currentPage + 1), this.currentPage === this.totalPages, false, "Next Page"));
|
|
6456
|
+
container.appendChild(this._createButton(nextSvg, () => this._changePage(this.totalPages), this.currentPage === this.totalPages, false, "Last Page"));
|
|
6457
|
+
}
|
|
6458
|
+
_createButton(content, onClick, disabled, isActive = false, ariaLabel) {
|
|
6459
|
+
const li = document.createElement("li");
|
|
6460
|
+
li.className = "page-item";
|
|
6461
|
+
const btn = document.createElement("button");
|
|
6462
|
+
btn.style.all = "unset";
|
|
6463
|
+
btn.style.width = "100%";
|
|
6464
|
+
btn.style.height = "100%";
|
|
6465
|
+
btn.style.display = "flex";
|
|
6466
|
+
btn.style.alignItems = "center";
|
|
6467
|
+
btn.style.justifyContent = "center";
|
|
6468
|
+
btn.style.cursor = disabled ? "default" : "pointer";
|
|
6469
|
+
if (ariaLabel) btn.setAttribute("aria-label", ariaLabel);
|
|
6470
|
+
if (isActive) btn.setAttribute("aria-current", "page");
|
|
6471
|
+
btn.disabled = disabled;
|
|
6472
|
+
if (!disabled) {
|
|
6473
|
+
btn.onclick = onClick;
|
|
6474
|
+
}
|
|
6475
|
+
if (isActive) li.classList.add("active");
|
|
6476
|
+
if (disabled) li.classList.add("disabled");
|
|
6477
|
+
if (content.includes("<svg")) {
|
|
6478
|
+
btn.innerHTML = content;
|
|
6479
|
+
} else {
|
|
6480
|
+
btn.textContent = content;
|
|
6481
|
+
}
|
|
6482
|
+
li.appendChild(btn);
|
|
6483
|
+
return li;
|
|
6484
|
+
}
|
|
6485
|
+
_changePage(newPage) {
|
|
6486
|
+
if (newPage < 1 || newPage > this.totalPages) return;
|
|
6487
|
+
this.setAttribute("current-page", newPage.toString());
|
|
6488
|
+
this.dispatchEvent(
|
|
6489
|
+
new CustomEvent("page-change", {
|
|
6490
|
+
detail: { page: newPage },
|
|
6491
|
+
bubbles: true,
|
|
6492
|
+
composed: true
|
|
6493
|
+
})
|
|
6494
|
+
);
|
|
6495
|
+
}
|
|
6496
|
+
_syncStyles() {
|
|
6497
|
+
this.styleAttributes.forEach((attr) => {
|
|
6498
|
+
const value = this.getAttribute(attr);
|
|
6499
|
+
if (value) {
|
|
6500
|
+
this.style.setProperty(`--${attr}`, value);
|
|
6501
|
+
}
|
|
6502
|
+
});
|
|
6503
|
+
}
|
|
6504
|
+
};
|
|
6505
|
+
if (!customElements.get("wavelength-pagination")) {
|
|
6506
|
+
customElements.define("wavelength-pagination", WavelengthPagination);
|
|
6507
|
+
}
|
|
6347
6508
|
export {
|
|
6348
6509
|
BaseWavelengthInput,
|
|
6349
6510
|
BaseWavelengthMultiSelectAutocomplete,
|
|
@@ -6362,6 +6523,7 @@ export {
|
|
|
6362
6523
|
WavelengthMultiSelectAutocomplete,
|
|
6363
6524
|
WavelengthNavBar,
|
|
6364
6525
|
WavelengthNotificationPanel,
|
|
6526
|
+
WavelengthPagination,
|
|
6365
6527
|
WavelengthPlaneTrail,
|
|
6366
6528
|
WavelengthProgressBar,
|
|
6367
6529
|
WavelengthSnackbar,
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@wavelengthusaf/web-components",
|
|
3
3
|
"author": "563 EWS - Wavelength",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.11.0",
|
|
6
6
|
"description": "Common component library used by Wavelength developers (NATIVE WEB COMPONENTS)",
|
|
7
7
|
"main": "/dist/cjs/index.cjs",
|
|
8
8
|
"module": "/dist/esm/index.js",
|