@abgov/web-components 1.15.0 → 1.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/web-components.es.js +46 -31
- package/web-components.umd.js +47 -47
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/web-components",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.1",
|
|
4
4
|
"description": "Government of Alberta - UI Web components",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/GovAlta/ui-components/issues"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"semantic-release": "semantic-release",
|
|
12
12
|
"main": "web-components.es.js",
|
|
13
13
|
"unpkg": "web-components.es.js",
|
|
14
|
-
"module": "web-components.
|
|
14
|
+
"module": "web-components.es.js",
|
|
15
15
|
"scripts": {
|
|
16
16
|
"dev": "rollup -c rollup.config.js -w",
|
|
17
17
|
"playground": "rollup -c rollup.playground.config.js -w",
|
package/web-components.es.js
CHANGED
|
@@ -26176,6 +26176,21 @@ class Pages extends SvelteElement {
|
|
|
26176
26176
|
|
|
26177
26177
|
customElements.define("goa-pages", Pages);
|
|
26178
26178
|
|
|
26179
|
+
function isUrlMatch(windowUrl, testUrl) {
|
|
26180
|
+
if (!testUrl)
|
|
26181
|
+
return false;
|
|
26182
|
+
const pathParts = windowUrl.pathname.split("/");
|
|
26183
|
+
testUrl = testUrl.replace(/^\//, "");
|
|
26184
|
+
for (const part of pathParts) {
|
|
26185
|
+
if (part === testUrl)
|
|
26186
|
+
return true;
|
|
26187
|
+
}
|
|
26188
|
+
if (windowUrl.hash === testUrl) {
|
|
26189
|
+
return true;
|
|
26190
|
+
}
|
|
26191
|
+
return false;
|
|
26192
|
+
}
|
|
26193
|
+
|
|
26179
26194
|
/* src/components/side-menu/SideMenu.svelte generated by Svelte v3.59.2 */
|
|
26180
26195
|
|
|
26181
26196
|
function create_fragment$4(ctx) {
|
|
@@ -26207,11 +26222,11 @@ function instance$4($$self, $$props, $$invalidate) {
|
|
|
26207
26222
|
|
|
26208
26223
|
onMount(async () => {
|
|
26209
26224
|
await tick();
|
|
26210
|
-
|
|
26225
|
+
setCurrentUrl();
|
|
26211
26226
|
addEventListeners();
|
|
26212
26227
|
});
|
|
26213
26228
|
|
|
26214
|
-
function
|
|
26229
|
+
function setCurrentUrl() {
|
|
26215
26230
|
const slot = _rootEl.querySelector("slot");
|
|
26216
26231
|
|
|
26217
26232
|
if (!slot) {
|
|
@@ -26221,7 +26236,7 @@ function instance$4($$self, $$props, $$invalidate) {
|
|
|
26221
26236
|
const links = slot.assignedElements().filter(el => el.tagName === "A");
|
|
26222
26237
|
|
|
26223
26238
|
links.forEach(child => {
|
|
26224
|
-
const current =
|
|
26239
|
+
const current = isUrlMatch(document.location, child.getAttribute("href"));
|
|
26225
26240
|
|
|
26226
26241
|
if (current) {
|
|
26227
26242
|
child.classList.add("current");
|
|
@@ -26236,9 +26251,9 @@ function instance$4($$self, $$props, $$invalidate) {
|
|
|
26236
26251
|
let currentLocation = document.location.href;
|
|
26237
26252
|
|
|
26238
26253
|
const observer = new MutationObserver(_mutationList => {
|
|
26239
|
-
if (
|
|
26254
|
+
if (isUrlMatch(document.location, currentLocation)) {
|
|
26240
26255
|
currentLocation = document.location.href;
|
|
26241
|
-
|
|
26256
|
+
setCurrentUrl();
|
|
26242
26257
|
}
|
|
26243
26258
|
});
|
|
26244
26259
|
|
|
@@ -26246,7 +26261,7 @@ function instance$4($$self, $$props, $$invalidate) {
|
|
|
26246
26261
|
|
|
26247
26262
|
// watch hash / browser history changes
|
|
26248
26263
|
window.addEventListener("popstate", () => {
|
|
26249
|
-
|
|
26264
|
+
setCurrentUrl();
|
|
26250
26265
|
});
|
|
26251
26266
|
}
|
|
26252
26267
|
|
|
@@ -26310,7 +26325,7 @@ function create_else_block(ctx) {
|
|
|
26310
26325
|
};
|
|
26311
26326
|
}
|
|
26312
26327
|
|
|
26313
|
-
// (
|
|
26328
|
+
// (190:4) {#if _open}
|
|
26314
26329
|
function create_if_block$2(ctx) {
|
|
26315
26330
|
let goa_icon;
|
|
26316
26331
|
|
|
@@ -26424,24 +26439,6 @@ function toSlug(path) {
|
|
|
26424
26439
|
: path.toLowerCase().replace(/ /g, "-");
|
|
26425
26440
|
}
|
|
26426
26441
|
|
|
26427
|
-
function matchesChild(el, url) {
|
|
26428
|
-
if (url.endsWith(toSlug(el.heading))) {
|
|
26429
|
-
return true;
|
|
26430
|
-
}
|
|
26431
|
-
|
|
26432
|
-
const slot = el.querySelector("slot");
|
|
26433
|
-
|
|
26434
|
-
if (!slot) {
|
|
26435
|
-
return false;
|
|
26436
|
-
}
|
|
26437
|
-
|
|
26438
|
-
const children = slot.assignedElements();
|
|
26439
|
-
|
|
26440
|
-
return !!children.find(child => {
|
|
26441
|
-
return url.endsWith(child.getAttribute("href"));
|
|
26442
|
-
});
|
|
26443
|
-
}
|
|
26444
|
-
|
|
26445
26442
|
function instance$3($$self, $$props, $$invalidate) {
|
|
26446
26443
|
let _slug;
|
|
26447
26444
|
let { heading } = $$props;
|
|
@@ -26457,8 +26454,7 @@ function instance$3($$self, $$props, $$invalidate) {
|
|
|
26457
26454
|
});
|
|
26458
26455
|
|
|
26459
26456
|
function checkUrlMatches() {
|
|
26460
|
-
|
|
26461
|
-
$$invalidate(1, _open = matchesMenu(url) || matchesChild(_rootEl, url));
|
|
26457
|
+
$$invalidate(1, _open = matchesMenu() || matchesChild(_rootEl));
|
|
26462
26458
|
|
|
26463
26459
|
if (_open) {
|
|
26464
26460
|
notifyParent(true);
|
|
@@ -26491,12 +26487,30 @@ function instance$3($$self, $$props, $$invalidate) {
|
|
|
26491
26487
|
});
|
|
26492
26488
|
}
|
|
26493
26489
|
|
|
26494
|
-
function matchesMenu(
|
|
26495
|
-
return
|
|
26490
|
+
function matchesMenu() {
|
|
26491
|
+
return isUrlMatch(document.location, _slug);
|
|
26492
|
+
}
|
|
26493
|
+
|
|
26494
|
+
function matchesChild(el) {
|
|
26495
|
+
if (isUrlMatch(document.location, toSlug(el.heading))) {
|
|
26496
|
+
return true;
|
|
26497
|
+
}
|
|
26498
|
+
|
|
26499
|
+
const slot = el.querySelector("slot");
|
|
26500
|
+
|
|
26501
|
+
if (!slot) {
|
|
26502
|
+
return false;
|
|
26503
|
+
}
|
|
26504
|
+
|
|
26505
|
+
const children = slot.assignedElements();
|
|
26506
|
+
|
|
26507
|
+
return !!children.find(child => {
|
|
26508
|
+
return isUrlMatch(document.location, child.getAttribute("href"));
|
|
26509
|
+
});
|
|
26496
26510
|
}
|
|
26497
26511
|
|
|
26498
26512
|
function setCurrent() {
|
|
26499
|
-
|
|
26513
|
+
document.location.href;
|
|
26500
26514
|
const slot = _rootEl.querySelector("slot");
|
|
26501
26515
|
|
|
26502
26516
|
if (!slot) {
|
|
@@ -26507,7 +26521,8 @@ function instance$3($$self, $$props, $$invalidate) {
|
|
|
26507
26521
|
$$invalidate(2, _current = false);
|
|
26508
26522
|
|
|
26509
26523
|
children.forEach(child => {
|
|
26510
|
-
const
|
|
26524
|
+
const url = child.getAttribute("href");
|
|
26525
|
+
const current = isUrlMatch(document.location, url);
|
|
26511
26526
|
|
|
26512
26527
|
if (current) {
|
|
26513
26528
|
$$invalidate(2, _current = true);
|