@cagovweb/state-template 1.1.0-beta.4 → 6.2.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/css/cagov.core.css +1 -0
- package/dist/css/cagov.core.min.css +1 -1
- package/dist/js/cagov.core.js +258 -255
- package/dist/js/cagov.core.min.js +2 -2
- package/package.json +2 -2
package/dist/js/cagov.core.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var StateTemplateNpmPackageVersion="6.2.0";
|
|
1
2
|
/*!
|
|
2
3
|
* Bootstrap v5.3.0 (https://getbootstrap.com/)
|
|
3
4
|
* Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
|
@@ -6358,91 +6359,94 @@ window.addEventListener("load", () => {
|
|
|
6358
6359
|
// retain scroll position
|
|
6359
6360
|
|
|
6360
6361
|
//@ts-check
|
|
6361
|
-
/**
|
|
6362
|
-
* Accordion web component that collapses and expands content inside itself on click.
|
|
6363
|
-
*
|
|
6364
|
-
* @element cagov-accordion
|
|
6365
|
-
*
|
|
6366
|
-
*
|
|
6367
|
-
* @fires click - Default events which may be listened to in order to discover most popular accordions
|
|
6368
|
-
*
|
|
6369
|
-
* @attr {string} open - set on the internal details element
|
|
6370
|
-
* If this is true the accordion will be open before any user interaction.
|
|
6371
|
-
*
|
|
6372
|
-
* @cssprop --primary-700 - Default value of #165ac2, used for all colors of borders and fills
|
|
6373
|
-
* @cssprop --primary-900 - Default value of #003588, used for background on hover
|
|
6374
|
-
*
|
|
6375
|
-
*/
|
|
6376
|
-
class CaGovAccordion extends HTMLElement {
|
|
6377
|
-
connectedCallback() {
|
|
6378
|
-
this.summaryEl = this.querySelector("summary");
|
|
6379
|
-
// trigger the opening and closing height change animation on summary click
|
|
6380
|
-
|
|
6381
|
-
this.setHeight();
|
|
6382
|
-
this.summaryEl.addEventListener("click", this.listen.bind(this));
|
|
6383
|
-
this.summaryEl.insertAdjacentHTML(
|
|
6384
|
-
"beforeend",
|
|
6385
|
-
`<div class="cagov-open-indicator" aria-hidden="true" />`
|
|
6386
|
-
);
|
|
6387
|
-
this.detailsEl = this.querySelector("details");
|
|
6388
|
-
this.bodyEl = this.querySelector(".accordion-body");
|
|
6389
6362
|
|
|
6390
|
-
|
|
6391
|
-
|
|
6363
|
+
window.addEventListener("load", () => {
|
|
6364
|
+
/**
|
|
6365
|
+
* Accordion web component that collapses and expands content inside itself on click.
|
|
6366
|
+
*
|
|
6367
|
+
* @element cagov-accordion
|
|
6368
|
+
*
|
|
6369
|
+
*
|
|
6370
|
+
* @fires click - Default events which may be listened to in order to discover most popular accordions
|
|
6371
|
+
*
|
|
6372
|
+
* @attr {string} open - set on the internal details element
|
|
6373
|
+
* If this is true the accordion will be open before any user interaction.
|
|
6374
|
+
*
|
|
6375
|
+
* @cssprop --primary-700 - Default value of #165ac2, used for all colors of borders and fills
|
|
6376
|
+
* @cssprop --primary-900 - Default value of #003588, used for background on hover
|
|
6377
|
+
*
|
|
6378
|
+
*/
|
|
6379
|
+
class CaGovAccordion extends HTMLElement {
|
|
6380
|
+
connectedCallback() {
|
|
6381
|
+
this.summaryEl = this.querySelector("summary");
|
|
6382
|
+
// trigger the opening and closing height change animation on summary click
|
|
6383
|
+
|
|
6384
|
+
this.setHeight();
|
|
6385
|
+
this.summaryEl.addEventListener("click", this.listen.bind(this));
|
|
6386
|
+
this.summaryEl.insertAdjacentHTML(
|
|
6387
|
+
"beforeend",
|
|
6388
|
+
`<div class="cagov-open-indicator" aria-hidden="true" />`
|
|
6389
|
+
);
|
|
6390
|
+
this.detailsEl = this.querySelector("details");
|
|
6391
|
+
this.bodyEl = this.querySelector(".accordion-body");
|
|
6392
6392
|
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6393
|
+
window.addEventListener(
|
|
6394
|
+
"resize",
|
|
6395
|
+
this.debounce(this.setHeight).bind(this)
|
|
6396
|
+
);
|
|
6397
|
+
}
|
|
6398
6398
|
|
|
6399
|
-
|
|
6399
|
+
setHeight() {
|
|
6400
|
+
window.requestAnimationFrame(() => {
|
|
6401
|
+
// delay so the desired height is readable in all browsers
|
|
6402
|
+
this.closedHeightInt = this.summaryEl.scrollHeight + 2;
|
|
6403
|
+
this.closedHeight = `${this.closedHeightInt}px`;
|
|
6404
|
+
|
|
6405
|
+
// apply initial height
|
|
6406
|
+
if (this.detailsEl.hasAttribute("open")) {
|
|
6407
|
+
// if open get scrollHeight
|
|
6408
|
+
this.detailsEl.style.height = `${
|
|
6409
|
+
this.bodyEl.scrollHeight + this.closedHeightInt
|
|
6410
|
+
}px`;
|
|
6411
|
+
} else {
|
|
6412
|
+
// else apply closed height
|
|
6413
|
+
this.detailsEl.style.height = this.closedHeight;
|
|
6414
|
+
}
|
|
6415
|
+
});
|
|
6416
|
+
}
|
|
6417
|
+
|
|
6418
|
+
listen() {
|
|
6400
6419
|
if (this.detailsEl.hasAttribute("open")) {
|
|
6401
|
-
//
|
|
6402
|
-
this.detailsEl.style.height = `${
|
|
6403
|
-
this.bodyEl.scrollHeight + this.closedHeightInt
|
|
6404
|
-
}px`;
|
|
6405
|
-
} else {
|
|
6406
|
-
// else apply closed height
|
|
6420
|
+
// was open, now closing
|
|
6407
6421
|
this.detailsEl.style.height = this.closedHeight;
|
|
6422
|
+
} else {
|
|
6423
|
+
// was closed, opening
|
|
6424
|
+
window.requestAnimationFrame(() => {
|
|
6425
|
+
// delay so the desired height is readable in all browsers
|
|
6426
|
+
this.detailsEl.style.height = `${
|
|
6427
|
+
this.bodyEl.scrollHeight + this.closedHeightInt
|
|
6428
|
+
}px`;
|
|
6429
|
+
});
|
|
6408
6430
|
}
|
|
6409
|
-
}
|
|
6410
|
-
}
|
|
6431
|
+
}
|
|
6411
6432
|
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
});
|
|
6433
|
+
/**
|
|
6434
|
+
* @param {function} func
|
|
6435
|
+
*/
|
|
6436
|
+
debounce(func, timeout = 300) {
|
|
6437
|
+
let timer;
|
|
6438
|
+
return (/** @type {any} */ ...args) => {
|
|
6439
|
+
window.clearTimeout(timer);
|
|
6440
|
+
timer = window.setTimeout(() => {
|
|
6441
|
+
func.apply(this, args);
|
|
6442
|
+
}, timeout);
|
|
6443
|
+
};
|
|
6424
6444
|
}
|
|
6425
6445
|
}
|
|
6426
6446
|
|
|
6427
|
-
/**
|
|
6428
|
-
* @param {function} func
|
|
6429
|
-
*/
|
|
6430
|
-
debounce(func, timeout = 300) {
|
|
6431
|
-
let timer;
|
|
6432
|
-
return (/** @type {any} */ ...args) => {
|
|
6433
|
-
window.clearTimeout(timer);
|
|
6434
|
-
timer = window.setTimeout(() => {
|
|
6435
|
-
func.apply(this, args);
|
|
6436
|
-
}, timeout);
|
|
6437
|
-
};
|
|
6438
|
-
}
|
|
6439
|
-
}
|
|
6440
|
-
window.addEventListener("load", () => {
|
|
6441
6447
|
window.customElements.define("cagov-accordion", CaGovAccordion);
|
|
6442
6448
|
});
|
|
6443
6449
|
|
|
6444
|
-
//document.querySelector('head').appendChild(style);
|
|
6445
|
-
|
|
6446
6450
|
//@ts-check
|
|
6447
6451
|
window.addEventListener("load", () => {
|
|
6448
6452
|
const w = window;
|
|
@@ -8046,56 +8050,56 @@ window.addEventListener("load", () => {
|
|
|
8046
8050
|
document.body.scrollTop = 0; // For Safari
|
|
8047
8051
|
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
|
|
8048
8052
|
};
|
|
8049
|
-
});
|
|
8050
8053
|
|
|
8051
|
-
// If an user scrolls down the page for more than 400px activate back to top button
|
|
8052
|
-
// othervise keep it invisible
|
|
8053
|
-
let timer = 0;
|
|
8054
|
+
// If an user scrolls down the page for more than 400px activate back to top button
|
|
8055
|
+
// othervise keep it invisible
|
|
8056
|
+
let timer = 0;
|
|
8054
8057
|
|
|
8055
|
-
let lastScrollTop = 0;
|
|
8058
|
+
let lastScrollTop = 0;
|
|
8056
8059
|
|
|
8057
|
-
window.addEventListener(
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8060
|
+
window.addEventListener(
|
|
8061
|
+
"scroll",
|
|
8062
|
+
() => {
|
|
8063
|
+
const returnTopButton = document.querySelector(".return-top");
|
|
8064
|
+
if (!returnTopButton) return;
|
|
8062
8065
|
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
|
|
8066
|
+
const st = window.pageYOffset || document.documentElement.scrollTop;
|
|
8067
|
+
if (st > lastScrollTop) {
|
|
8068
|
+
// downscroll code
|
|
8069
|
+
returnTopButton.classList.remove("is-visible");
|
|
8070
|
+
} else if (
|
|
8071
|
+
document.body.scrollTop >= 400 ||
|
|
8072
|
+
document.documentElement.scrollTop >= 400
|
|
8073
|
+
) {
|
|
8074
|
+
// upscroll code
|
|
8072
8075
|
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
|
|
8076
|
+
if (timer) {
|
|
8077
|
+
window.clearTimeout(timer);
|
|
8078
|
+
}
|
|
8079
|
+
returnTopButton.classList.add("is-visible");
|
|
8077
8080
|
|
|
8078
|
-
|
|
8081
|
+
timer = window.setTimeout(() => {
|
|
8082
|
+
returnTopButton.classList.remove("is-visible");
|
|
8083
|
+
}, 2000); //Back to top removes itself after 2 sec of inactivity
|
|
8084
|
+
}
|
|
8085
|
+
// bottom of the page
|
|
8086
|
+
else {
|
|
8079
8087
|
returnTopButton.classList.remove("is-visible");
|
|
8080
|
-
}
|
|
8081
|
-
}
|
|
8082
|
-
// bottom of the page
|
|
8083
|
-
else {
|
|
8084
|
-
returnTopButton.classList.remove("is-visible");
|
|
8085
|
-
}
|
|
8088
|
+
}
|
|
8086
8089
|
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
);
|
|
8090
|
+
lastScrollTop = st <= 0 ? 0 : st; // For Mobile or negative scrolling
|
|
8091
|
+
},
|
|
8092
|
+
false
|
|
8093
|
+
);
|
|
8091
8094
|
|
|
8092
|
-
// Hittin' rock bottom
|
|
8093
|
-
window.addEventListener("scroll", () => {
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
|
|
8098
|
-
|
|
8095
|
+
// Hittin' rock bottom
|
|
8096
|
+
window.addEventListener("scroll", () => {
|
|
8097
|
+
const returnTopButton = document.querySelector(".return-top");
|
|
8098
|
+
if (!returnTopButton) return;
|
|
8099
|
+
if (window.innerHeight + window.scrollY >= document.body.offsetHeight) {
|
|
8100
|
+
returnTopButton.classList.add("is-visible");
|
|
8101
|
+
}
|
|
8102
|
+
});
|
|
8099
8103
|
});
|
|
8100
8104
|
|
|
8101
8105
|
//@ts-check
|
|
@@ -8377,13 +8381,13 @@ window.addEventListener("load", () => {
|
|
|
8377
8381
|
/* -----------------------------------------
|
|
8378
8382
|
PAGINATION - /src/js/cagov/pagination.js
|
|
8379
8383
|
----------------------------------------- */
|
|
8380
|
-
|
|
8381
|
-
/**
|
|
8382
|
-
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
function pageListItem(label, number) {
|
|
8386
|
-
|
|
8384
|
+
window.addEventListener("load", () => {
|
|
8385
|
+
/**
|
|
8386
|
+
* @param {string} label
|
|
8387
|
+
* @param {number} number
|
|
8388
|
+
*/
|
|
8389
|
+
function pageListItem(label, number) {
|
|
8390
|
+
return `<li class="cagov-pagination__item">
|
|
8387
8391
|
<a
|
|
8388
8392
|
href="javascript:void(0);"
|
|
8389
8393
|
class="cagov-pagination__button"
|
|
@@ -8393,27 +8397,27 @@ function pageListItem(label, number) {
|
|
|
8393
8397
|
${number}
|
|
8394
8398
|
</a>
|
|
8395
8399
|
</li>`;
|
|
8396
|
-
}
|
|
8400
|
+
}
|
|
8397
8401
|
|
|
8398
|
-
function pageOverflow() {
|
|
8399
|
-
|
|
8402
|
+
function pageOverflow() {
|
|
8403
|
+
return `<li
|
|
8400
8404
|
class="cagov-pagination__item cagov-pagination__overflow"
|
|
8401
8405
|
role="presentation"
|
|
8402
8406
|
>
|
|
8403
8407
|
<span> … </span>
|
|
8404
8408
|
</li>`;
|
|
8405
|
-
}
|
|
8409
|
+
}
|
|
8406
8410
|
|
|
8407
|
-
/**
|
|
8408
|
-
|
|
8409
|
-
|
|
8410
|
-
|
|
8411
|
-
|
|
8412
|
-
|
|
8413
|
-
|
|
8414
|
-
function templateHTML(next, previous, page, currentPage, totalPages) {
|
|
8415
|
-
|
|
8416
|
-
|
|
8411
|
+
/**
|
|
8412
|
+
* @param {string} next
|
|
8413
|
+
* @param {string} previous
|
|
8414
|
+
* @param {string} page
|
|
8415
|
+
* @param {number} currentPage
|
|
8416
|
+
* @param {number} totalPages
|
|
8417
|
+
*/
|
|
8418
|
+
function templateHTML(next, previous, page, currentPage, totalPages) {
|
|
8419
|
+
const unbounded = totalPages == -1;
|
|
8420
|
+
return `<nav aria-label="Pagination" class="cagov-pagination">
|
|
8417
8421
|
<ul class="cagov-pagination__list">
|
|
8418
8422
|
<li class="cagov-pagination__item">
|
|
8419
8423
|
<a
|
|
@@ -8472,9 +8476,9 @@ function templateHTML(next, previous, page, currentPage, totalPages) {
|
|
|
8472
8476
|
</li>
|
|
8473
8477
|
</ul>
|
|
8474
8478
|
</nav>`;
|
|
8475
|
-
}
|
|
8479
|
+
}
|
|
8476
8480
|
|
|
8477
|
-
const styles = `
|
|
8481
|
+
const styles = `
|
|
8478
8482
|
cagov-pagination {
|
|
8479
8483
|
white-space: nowrap;
|
|
8480
8484
|
font-size: .9rem;
|
|
@@ -8518,148 +8522,147 @@ cagov-pagination .cagov-pagination__item:has(.cagov-pagination__link-inactive) {
|
|
|
8518
8522
|
}
|
|
8519
8523
|
`;
|
|
8520
8524
|
|
|
8521
|
-
/**
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
class CAGovPagination extends HTMLElement {
|
|
8534
|
-
|
|
8535
|
-
|
|
8525
|
+
/**
|
|
8526
|
+
* Pagination web component
|
|
8527
|
+
*
|
|
8528
|
+
* @element cagov-pagination
|
|
8529
|
+
*
|
|
8530
|
+
* @fires paginationClick - custom event with object with detail value of current page: {detail: 1}
|
|
8531
|
+
*
|
|
8532
|
+
* @attr {string} [data-yes] - "Yes";
|
|
8533
|
+
* @attr {string} [data-no] - "No";
|
|
8534
|
+
*
|
|
8535
|
+
* @cssprop --primary-700 - Default value of #165ac2, used for text, border color
|
|
8536
|
+
*/
|
|
8537
|
+
class CAGovPagination extends HTMLElement {
|
|
8538
|
+
constructor() {
|
|
8539
|
+
super();
|
|
8536
8540
|
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8541
|
+
if (!document.querySelector("#cagov-pagination-styles")) {
|
|
8542
|
+
const style = document.createElement("style");
|
|
8543
|
+
style.id = "cagov-pagination-styles";
|
|
8544
|
+
style.textContent = styles;
|
|
8545
|
+
document.head.appendChild(style);
|
|
8546
|
+
}
|
|
8542
8547
|
}
|
|
8543
|
-
}
|
|
8544
|
-
|
|
8545
|
-
connectedCallback() {
|
|
8546
|
-
this.currentPage = parseInt(
|
|
8547
|
-
this.dataset.currentPage ? this.dataset.currentPage : "1",
|
|
8548
|
-
10
|
|
8549
|
-
);
|
|
8550
|
-
this.render();
|
|
8551
|
-
}
|
|
8552
8548
|
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
: '<span class="ca-gov-icon-arrow-prev" aria-hidden="true"></span> Previous';
|
|
8558
|
-
const next = this.dataset.next
|
|
8559
|
-
? this.dataset.next
|
|
8560
|
-
: 'Next <span class="ca-gov-icon-arrow-next" aria-hidden="true"></span>';
|
|
8561
|
-
const page = this.dataset.page ? this.dataset.page : "Page";
|
|
8562
|
-
this.totalPages = this.dataset.totalPages
|
|
8563
|
-
? Number(this.dataset.totalPages)
|
|
8564
|
-
: 1;
|
|
8565
|
-
if (this.totalPages < 0 || this.totalPages > 1) {
|
|
8566
|
-
const html = templateHTML(
|
|
8567
|
-
next,
|
|
8568
|
-
previous,
|
|
8569
|
-
page,
|
|
8570
|
-
this.currentPage,
|
|
8571
|
-
this.totalPages
|
|
8549
|
+
connectedCallback() {
|
|
8550
|
+
this.currentPage = parseInt(
|
|
8551
|
+
this.dataset.currentPage ? this.dataset.currentPage : "1",
|
|
8552
|
+
10
|
|
8572
8553
|
);
|
|
8573
|
-
this.
|
|
8574
|
-
this.applyListeners();
|
|
8575
|
-
} else {
|
|
8576
|
-
this.innerHTML = "";
|
|
8554
|
+
this.render();
|
|
8577
8555
|
}
|
|
8578
|
-
}
|
|
8579
8556
|
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8557
|
+
render() {
|
|
8558
|
+
//console.log(this.dataset);
|
|
8559
|
+
const previous = this.dataset.previous
|
|
8560
|
+
? this.dataset.previous
|
|
8561
|
+
: '<span class="ca-gov-icon-arrow-prev" aria-hidden="true"></span> Previous';
|
|
8562
|
+
const next = this.dataset.next
|
|
8563
|
+
? this.dataset.next
|
|
8564
|
+
: 'Next <span class="ca-gov-icon-arrow-next" aria-hidden="true"></span>';
|
|
8565
|
+
const page = this.dataset.page ? this.dataset.page : "Page";
|
|
8566
|
+
this.totalPages = this.dataset.totalPages
|
|
8567
|
+
? Number(this.dataset.totalPages)
|
|
8568
|
+
: 1;
|
|
8569
|
+
if (this.totalPages < 0 || this.totalPages > 1) {
|
|
8570
|
+
const html = templateHTML(
|
|
8571
|
+
next,
|
|
8572
|
+
previous,
|
|
8573
|
+
page,
|
|
8574
|
+
this.currentPage,
|
|
8575
|
+
this.totalPages
|
|
8576
|
+
);
|
|
8577
|
+
this.innerHTML = html;
|
|
8578
|
+
this.applyListeners();
|
|
8579
|
+
} else {
|
|
8580
|
+
this.innerHTML = "";
|
|
8581
|
+
}
|
|
8582
|
+
}
|
|
8583
8583
|
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
this.currentPage = parseInt(newValue, 10);
|
|
8587
|
-
this.render();
|
|
8584
|
+
static get observedAttributes() {
|
|
8585
|
+
return ["data-current-page", "data-total-pages"];
|
|
8588
8586
|
}
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8587
|
+
|
|
8588
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
8589
|
+
if (name === "data-current-page") {
|
|
8590
|
+
this.currentPage = parseInt(newValue, 10);
|
|
8591
|
+
this.render();
|
|
8592
|
+
}
|
|
8593
|
+
if (name === "data-total-pages") {
|
|
8594
|
+
this.totalPages = parseInt(newValue, 10);
|
|
8595
|
+
this.render();
|
|
8596
|
+
}
|
|
8592
8597
|
}
|
|
8593
|
-
}
|
|
8594
8598
|
|
|
8595
|
-
|
|
8596
|
-
|
|
8597
|
-
|
|
8598
|
-
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
|
|
8602
|
-
|
|
8603
|
-
this.dispatchEvent(
|
|
8604
|
-
new CustomEvent("paginationClick", {
|
|
8605
|
-
detail: this.currentPage
|
|
8606
|
-
})
|
|
8607
|
-
);
|
|
8608
|
-
this.dataset.currentPage = this.currentPage.toString();
|
|
8609
|
-
});
|
|
8610
|
-
});
|
|
8611
|
-
this.querySelector(".cagov-pagination__previous-page").addEventListener(
|
|
8612
|
-
"click",
|
|
8613
|
-
event => {
|
|
8614
|
-
if (
|
|
8615
|
-
!(
|
|
8616
|
-
/** @type {Element} */ (event.target).classList.contains(
|
|
8617
|
-
"cagov-pagination__link-inactive"
|
|
8618
|
-
)
|
|
8619
|
-
)
|
|
8620
|
-
) {
|
|
8621
|
-
this.currentPage -= 1;
|
|
8622
|
-
if (this.currentPage < 1) {
|
|
8623
|
-
this.currentPage = 1;
|
|
8624
|
-
}
|
|
8599
|
+
applyListeners() {
|
|
8600
|
+
const pageLinks = this.querySelectorAll(".cagov-pagination__button");
|
|
8601
|
+
pageLinks.forEach(pl => {
|
|
8602
|
+
pl.addEventListener("click", event => {
|
|
8603
|
+
this.currentPage = parseInt(
|
|
8604
|
+
/** @type {CAGovPagination} */ (event.target).dataset.pageNum,
|
|
8605
|
+
10
|
|
8606
|
+
);
|
|
8625
8607
|
this.dispatchEvent(
|
|
8626
8608
|
new CustomEvent("paginationClick", {
|
|
8627
8609
|
detail: this.currentPage
|
|
8628
8610
|
})
|
|
8629
8611
|
);
|
|
8630
8612
|
this.dataset.currentPage = this.currentPage.toString();
|
|
8613
|
+
});
|
|
8614
|
+
});
|
|
8615
|
+
this.querySelector(".cagov-pagination__previous-page").addEventListener(
|
|
8616
|
+
"click",
|
|
8617
|
+
event => {
|
|
8618
|
+
if (
|
|
8619
|
+
!(
|
|
8620
|
+
/** @type {Element} */ (event.target).classList.contains(
|
|
8621
|
+
"cagov-pagination__link-inactive"
|
|
8622
|
+
)
|
|
8623
|
+
)
|
|
8624
|
+
) {
|
|
8625
|
+
this.currentPage -= 1;
|
|
8626
|
+
if (this.currentPage < 1) {
|
|
8627
|
+
this.currentPage = 1;
|
|
8628
|
+
}
|
|
8629
|
+
this.dispatchEvent(
|
|
8630
|
+
new CustomEvent("paginationClick", {
|
|
8631
|
+
detail: this.currentPage
|
|
8632
|
+
})
|
|
8633
|
+
);
|
|
8634
|
+
this.dataset.currentPage = this.currentPage.toString();
|
|
8635
|
+
}
|
|
8631
8636
|
}
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8637
|
+
);
|
|
8638
|
+
this.querySelector(".cagov-pagination__next-page").addEventListener(
|
|
8639
|
+
"click",
|
|
8640
|
+
event => {
|
|
8641
|
+
if (
|
|
8642
|
+
!(
|
|
8643
|
+
/** @type {Element} */ (event.target).classList.contains(
|
|
8644
|
+
"cagov-pagination__link-inactive"
|
|
8645
|
+
)
|
|
8641
8646
|
)
|
|
8642
|
-
)
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
+
) {
|
|
8648
|
+
this.currentPage += 1;
|
|
8649
|
+
if (this.totalPages != -1 && this.currentPage > this.totalPages) {
|
|
8650
|
+
this.currentPage = this.totalPages;
|
|
8651
|
+
}
|
|
8652
|
+
this.dispatchEvent(
|
|
8653
|
+
new CustomEvent("paginationClick", {
|
|
8654
|
+
detail: this.currentPage
|
|
8655
|
+
})
|
|
8656
|
+
);
|
|
8657
|
+
this.dataset.currentPage = this.currentPage.toString();
|
|
8647
8658
|
}
|
|
8648
|
-
this.dispatchEvent(
|
|
8649
|
-
new CustomEvent("paginationClick", {
|
|
8650
|
-
detail: this.currentPage
|
|
8651
|
-
})
|
|
8652
|
-
);
|
|
8653
|
-
this.dataset.currentPage = this.currentPage.toString();
|
|
8654
8659
|
}
|
|
8655
|
-
|
|
8656
|
-
|
|
8660
|
+
);
|
|
8661
|
+
}
|
|
8657
8662
|
}
|
|
8658
|
-
|
|
8659
|
-
window.addEventListener("load", () => {
|
|
8663
|
+
|
|
8660
8664
|
window.customElements.define("cagov-pagination", CAGovPagination);
|
|
8661
8665
|
});
|
|
8662
|
-
//export { CAGovPagination };
|
|
8663
8666
|
|
|
8664
8667
|
//@ts-check
|
|
8665
8668
|
|